Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(616)

Side by Side Diff: tools/telemetry/telemetry/core/platform/android_platform_backend_unittest.py

Issue 806843002: Reland of Migrate DeviceUtils.ReadFile to adb_wrapper (try 3) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: enable command line test only for android Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 # Copyright 2013 The Chromium Authors. All rights reserved. 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 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 import unittest 5 import unittest
6 6
7 from telemetry import decorators 7 from telemetry import decorators
8 from telemetry.core.platform import android_device 8 from telemetry.core.platform import android_device
9 from telemetry.core.platform import android_platform_backend 9 from telemetry.core.platform import android_platform_backend
10 from telemetry.unittest_util import system_stub 10 from telemetry.unittest_util import system_stub
11 11
12 12
13 class AndroidPlatformBackendTest(unittest.TestCase): 13 class AndroidPlatformBackendTest(unittest.TestCase):
14 def setUp(self): 14 def setUp(self):
15 self._stubs = system_stub.Override( 15 self._stubs = system_stub.Override(
16 android_platform_backend, 16 android_platform_backend,
17 ['perf_control', 'thermal_throttle', 'adb_commands', 'certutils', 17 ['perf_control', 'thermal_throttle', 'adb_commands', 'certutils',
18 'adb_install_cert']) 18 'adb_install_cert'])
19 19
20 # Skip _FixPossibleAdbInstability by setting psutil to None. 20 # Skip _FixPossibleAdbInstability by setting psutil to None.
21 self._actual_ps_util = android_platform_backend.psutil 21 self._actual_ps_util = android_platform_backend.psutil
22 android_platform_backend.psutil = None 22 android_platform_backend.psutil = None
23 23
24 def tearDown(self): 24 def tearDown(self):
25 self._stubs.Restore() 25 self._stubs.Restore()
26 android_platform_backend.psutil = self._actual_ps_util 26 android_platform_backend.psutil = self._actual_ps_util
27 27
28 @decorators.Disabled('chromeos') 28 @decorators.Disabled('chromeos')
29 def testGetCpuStats(self): 29 def testGetCpuStats(self):
30 proc_stat_content = [ 30 proc_stat_content = (
31 '7702 (.android.chrome) S 167 167 0 0 -1 1077936448 ' 31 '7702 (.android.chrome) S 167 167 0 0 -1 1077936448 '
32 '3247 0 0 0 4 1 0 0 20 0 9 0 5603962 337379328 5867 ' 32 '3247 0 0 0 4 1 0 0 20 0 9 0 5603962 337379328 5867 '
33 '4294967295 1074458624 1074463824 3197495984 3197494152 ' 33 '4294967295 1074458624 1074463824 3197495984 3197494152 '
34 '1074767676 0 4612 0 38136 4294967295 0 0 17 0 0 0 0 0 0 ' 34 '1074767676 0 4612 0 38136 4294967295 0 0 17 0 0 0 0 0 0 '
35 '1074470376 1074470912 1102155776'] 35 '1074470376 1074470912 1102155776\n')
36 self._stubs.adb_commands.adb_device.mock_content = proc_stat_content 36 self._stubs.adb_commands.adb_device.mock_content = proc_stat_content
37 old_interface = self._stubs.adb_commands.adb_device.old_interface 37 old_interface = self._stubs.adb_commands.adb_device.old_interface
38 old_interface.can_access_protected_file_contents = True 38 old_interface.can_access_protected_file_contents = True
39 backend = android_platform_backend.AndroidPlatformBackend( 39 backend = android_platform_backend.AndroidPlatformBackend(
40 android_device.AndroidDevice('12345')) 40 android_device.AndroidDevice('12345'))
41 cpu_stats = backend.GetCpuStats('7702') 41 cpu_stats = backend.GetCpuStats('7702')
42 self.assertEquals(cpu_stats, {'CpuProcessTime': 0.05}) 42 self.assertEquals(cpu_stats, {'CpuProcessTime': 0.05})
43 43
44 @decorators.Disabled('chromeos') 44 @decorators.Disabled('chromeos')
45 def testGetCpuStatsInvalidPID(self): 45 def testGetCpuStatsInvalidPID(self):
(...skipping 30 matching lines...) Expand all
76 backend = android_platform_backend.AndroidPlatformBackend( 76 backend = android_platform_backend.AndroidPlatformBackend(
77 android_device.AndroidDevice('failure')) 77 android_device.AndroidDevice('failure'))
78 backend.InstallTestCa() 78 backend.InstallTestCa()
79 self.assertFalse(backend.is_test_ca_installed) 79 self.assertFalse(backend.is_test_ca_installed)
80 80
81 def testInstallTestCaSuccess(self): 81 def testInstallTestCaSuccess(self):
82 backend = android_platform_backend.AndroidPlatformBackend( 82 backend = android_platform_backend.AndroidPlatformBackend(
83 android_device.AndroidDevice('success')) 83 android_device.AndroidDevice('success'))
84 backend.InstallTestCa() 84 backend.InstallTestCa()
85 self.assertTrue(backend.is_test_ca_installed) 85 self.assertTrue(backend.is_test_ca_installed)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698