示例#1
0
 def testIsNotSvelte(self):
     with mock.patch(
             'devil.android.device_utils.DeviceUtils.RunShellCommand',
             side_effect=device_errors.AdbCommandFailedError('m', 'n')):
         backend = android_platform_backend.AndroidPlatformBackend(
             android_device.AndroidDevice('12345'), self._options)
         self.assertFalse(backend.IsSvelte())
示例#2
0
 def testIsSvelte(self):
     with mock.patch(
             'devil.android.device_utils.DeviceUtils.RunShellCommand',
             return_value=0):
         backend = android_platform_backend.AndroidPlatformBackend(
             android_device.AndroidDevice('12345'), self._options)
         self.assertTrue(backend.IsSvelte())
示例#3
0
 def testGetCpuStatsInvalidPID(self):
     # Mock an empty /proc/pid/stat.
     with mock.patch('devil.android.device_utils.DeviceUtils.ReadFile',
                     return_value=''):
         backend = android_platform_backend.AndroidPlatformBackend(
             android_device.AndroidDevice('1234'), self._options)
         cpu_stats = backend.GetCpuStats('7702')
         self.assertEquals(cpu_stats, {})
示例#4
0
    def testInstallTestCaSuccess(self):
        backend = android_platform_backend.AndroidPlatformBackend(
            android_device.AndroidDevice('success'))
        with mock.patch('adb_install_cert.AndroidCertInstaller'):
            backend.InstallTestCa('testca.pem')
            self.assertIsNotNone(backend._device_cert_util)

            backend.RemoveTestCa()
            self.assertIsNone(backend._device_cert_util)
 def testPsutil2(self):
     with mock.patch.object(android_platform_backend, 'psutil',
                            self.psutil_2_0()) as psutil:
         # Mock an empty /proc/pid/stat.
         with mock.patch('devil.android.device_utils.DeviceUtils.ReadFile',
                         return_value=''):
             backend = android_platform_backend.AndroidPlatformBackend(
                 android_device.AndroidDevice('1234'), True)
             cpu_stats = backend.GetCpuStats('7702')
             self.assertEquals({}, cpu_stats)
             self.assertEquals([[0]], psutil.set_cpu_affinity_args)
示例#6
0
    def testPsutil1(self):
        psutil = self.psutil_1_0()
        android_platform_backend.psutil = psutil

        # Mock an empty /proc/pid/stat.
        with mock.patch('devil.android.device_utils.DeviceUtils.ReadFile',
                        return_value=''):
            backend = android_platform_backend.AndroidPlatformBackend(
                android_device.AndroidDevice('1234'), self._options)
            cpu_stats = backend.GetCpuStats('7702')
            self.assertEquals({}, cpu_stats)
            self.assertEquals([[0]], psutil.set_cpu_affinity_args)
示例#7
0
 def testGetCpuStats(self):
     proc_stat_content = (
         '7702 (.android.chrome) S 167 167 0 0 -1 1077936448 '
         '3247 0 0 0 4 1 0 0 20 0 9 0 5603962 337379328 5867 '
         '4294967295 1074458624 1074463824 3197495984 3197494152 '
         '1074767676 0 4612 0 38136 4294967295 0 0 17 0 0 0 0 0 0 '
         '1074470376 1074470912 1102155776\n')
     with mock.patch('devil.android.device_utils.DeviceUtils.ReadFile',
                     return_value=proc_stat_content):
         backend = android_platform_backend.AndroidPlatformBackend(
             android_device.AndroidDevice('12345'), self._options)
         cpu_stats = backend.GetCpuStats('7702')
         self.assertEquals(cpu_stats, {'CpuProcessTime': 0.05})
 def CreatePlatformBackendForTest():
     return android_platform_backend.AndroidPlatformBackend(
         android_device.AndroidDevice('12345'), True)
示例#9
0
 def testIsScreenLockedFalse(self):
     test_input = ['a=b', 'mHasBeenInactive=false']
     backend = android_platform_backend.AndroidPlatformBackend(
         android_device.AndroidDevice('success'), self._options)
     self.assertFalse(backend._IsScreenLocked(test_input))
示例#10
0
 def testInstallTestCaSuccess(self):
     backend = android_platform_backend.AndroidPlatformBackend(
         android_device.AndroidDevice('success'), self._options)
     backend.InstallTestCa()
     self.assertTrue(backend.is_test_ca_installed)
示例#11
0
 def testInstallTestCaFailure(self):
     backend = android_platform_backend.AndroidPlatformBackend(
         android_device.AndroidDevice('failure'), self._options)
     backend.InstallTestCa()
     self.assertFalse(backend.is_test_ca_installed)
示例#12
0
 def testIsNotSvelte(self):
     with mock.patch('devil.android.device_utils.DeviceUtils.GetProp',
                     return_value='foo'):
         backend = android_platform_backend.AndroidPlatformBackend(
             android_device.AndroidDevice('12345'))
         self.assertFalse(backend.IsSvelte())
示例#13
0
 def testIsScreenLockedTrue(self):
     test_input = ['a=b', 'mHasBeenInactive=true']
     backend = android_platform_backend.AndroidPlatformBackend(
         android_device.AndroidDevice('success'))
     self.assertTrue(backend._IsScreenLocked(test_input))
 def testIsScreenOnmInteractiveTrue(self):
     test_input = ['a=b', 'mInteractive=true']
     backend = android_platform_backend.AndroidPlatformBackend(
         android_device.AndroidDevice('success'), self._options)
     self.assertTrue(backend._IsScreenOn(test_input))
 def testIsScreenOnmScreenOnFalse(self):
     test_input = ['a=b', 'mScreenOn=false']
     backend = android_platform_backend.AndroidPlatformBackend(
         android_device.AndroidDevice('success'), self._options)
     self.assertFalse(backend._IsScreenOn(test_input))
 def testIsAosp(self):
     with mock.patch('devil.android.device_utils.DeviceUtils.GetProp',
                     return_value='aosp'):
         backend = android_platform_backend.AndroidPlatformBackend(
             android_device.AndroidDevice('12345'))
         self.assertTrue(backend.IsAosp())