def setUp(self): # Mock the device self.mock_device = mock.Mock(spec=device_utils.DeviceUtils) self.mock_device.build_product = 'blueline' self.mock_device.adb = mock.Mock(spec=adb_wrapper.AdbWrapper) self.mock_device.FileExists.return_value = True self.cpu_temp = cpu_temperature.CpuTemperature(self.mock_device) self.cpu_temp.InitThermalDeviceInformation()
def WaitForCpuTemperature(self, temp): controller = cpu_temperature.CpuTemperature(self._device) # Check if the device temperature zones are known if controller.IsSupported(): controller.LetCpuCoolToTemperature(temp) else: logging.warn('CPU temperature cooling delay - ' 'CPU temperature cannot be read: Either the current ' 'device is not supported or the specified temperature ' 'zones do not exist.')
def testIsSupported_returnsFalse(self): d = mock.Mock(spec=device_utils.DeviceUtils) d.build_product = 'blueline' d.FileExists.return_value = False c = cpu_temperature.CpuTemperature(d) self.assertFalse(c.IsSupported())
def testGetThermalDeviceInformation_noneWhenIncorrectLabel(self): invalid_device = mock.Mock(spec=device_utils.DeviceUtils) invalid_device.build_product = 'invalid_name' c = cpu_temperature.CpuTemperature(invalid_device) c.InitThermalDeviceInformation() self.assertEqual(c.GetDeviceInfoForTesting(), None)
def testInitWithMissing_fails(self): with self.assertRaises(TypeError): cpu_temperature.CpuTemperature(None) with self.assertRaises(TypeError): cpu_temperature.CpuTemperature('')
def testInitWithDeviceUtil(self): d = mock.Mock(spec=device_utils.DeviceUtils) d.build_product = 'blueline' c = cpu_temperature.CpuTemperature(d) self.assertEqual(d, c.GetDeviceForTesting())