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
.internal
.platform
import gpu_device
9 class TestGPUDevice(unittest
.TestCase
):
11 def testConstruction(self
):
12 device
= gpu_device
.GPUDevice(1000, 2000, 'test_vendor', 'test_device')
13 self
.assertEquals(device
.vendor_id
, 1000)
14 self
.assertEquals(device
.device_id
, 2000)
15 self
.assertEquals(device
.vendor_string
, 'test_vendor')
16 self
.assertEquals(device
.device_string
, 'test_device')
18 def testFromDict(self
):
19 dictionary
= {'vendor_id': 3000,
21 'vendor_string': 'test_vendor_2',
22 'device_string': 'test_device_2'}
23 device
= gpu_device
.GPUDevice
.FromDict(dictionary
)
24 self
.assertEquals(device
.vendor_id
, 3000)
25 self
.assertEquals(device
.device_id
, 4000)
26 self
.assertEquals(device
.vendor_string
, 'test_vendor_2')
27 self
.assertEquals(device
.device_string
, 'test_device_2')
29 def testMissingAttrsFromDict(self
):
38 data_copy
= data
.copy()
41 gpu_device
.GPUDevice
.FromDict(data_copy
)
42 self
.fail('Should raise exception if attribute "%s" is missing' % k
)
43 except AssertionError: