1 # Copyright 2013 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
6 from telemetry.core import gpu_device
7 from telemetry.core import gpu_info
8 from telemetry.core import system_info
10 class TestSystemInfo(unittest.TestCase):
11 def testConstruction(self):
13 'model_name': 'MacBookPro 10.1',
16 { 'vendor_id': 1000, 'device_id': 2000,
17 'vendor_string': 'a', 'device_string': 'b' },
21 info = system_info.SystemInfo.FromDict(data)
22 self.assertTrue(isinstance(info, system_info.SystemInfo))
23 self.assertTrue(isinstance(info.gpu, gpu_info.GPUInfo))
24 self.assertEquals(info.model_name, 'MacBookPro 10.1')
25 self.assertTrue(len(info.gpu.devices) == 1)
26 self.assertTrue(isinstance(info.gpu.devices[0], gpu_device.GPUDevice))
27 self.assertEquals(info.gpu.devices[0].vendor_id, 1000)
28 self.assertEquals(info.gpu.devices[0].device_id, 2000)
29 self.assertEquals(info.gpu.devices[0].vendor_string, 'a')
30 self.assertEquals(info.gpu.devices[0].device_string, 'b')
32 def testEmptyModelName(self):
37 { 'vendor_id': 1000, 'device_id': 2000,
38 'vendor_string': 'a', 'device_string': 'b' },
43 info = system_info.SystemInfo.FromDict(data)
44 self.assertEquals(info.model_name, '')
45 except AssertionError:
48 self.fail('Should not raise exception for empty model_name string')
50 def testMissingAttrsFromDict(self):
52 'model_name': 'MacBookPro 10.1',
53 'devices': [{ 'vendor_id': 1000, 'device_id': 2000,
54 'vendor_string': 'a', 'device_string': 'b' }]
58 data_copy = data.copy()
61 system_info.SystemInfo.FromDict(data_copy)
62 self.fail('Should raise exception if attribute "%s" is missing' % k)
63 except AssertionError: