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

Unified Diff: tools/telemetry/telemetry/core/platform/android_platform_backend_unittest.py

Issue 522553002: Move remote platforms creation logic from android_browser_finder to platform (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix android_browser_finder_unittest Created 6 years, 3 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 side-by-side diff with in-line comments
Download patch
Index: tools/telemetry/telemetry/core/platform/android_platform_backend_unittest.py
diff --git a/tools/telemetry/telemetry/core/platform/android_platform_backend_unittest.py b/tools/telemetry/telemetry/core/platform/android_platform_backend_unittest.py
index 1120c613ccd79c4cea18d96183709c41c468d3be..99564d6ce2365b8bacb5f1a8663f588c94627862 100644
--- a/tools/telemetry/telemetry/core/platform/android_platform_backend_unittest.py
+++ b/tools/telemetry/telemetry/core/platform/android_platform_backend_unittest.py
@@ -5,49 +5,16 @@
import unittest
from telemetry import benchmark
+from telemetry.core.platform import android_device
from telemetry.core.platform import android_platform_backend
from telemetry.unittest import system_stub
-class MockAdbCommands(object):
- def __init__(self, mock_content, system_properties):
- self.mock_content = mock_content
- self.system_properties = system_properties
- if self.system_properties.get('ro.product.cpu.abi') == None:
- self.system_properties['ro.product.cpu.abi'] = 'armeabi-v7a'
-
- def CanAccessProtectedFileContents(self):
- return True
-
- # pylint: disable=W0613
- def GetProtectedFileContents(self, file_name):
- return self.mock_content
-
- def PushIfNeeded(self, host_binary, device_path):
- pass
-
- def RunShellCommand(self, command):
- return []
-
-
-class MockDevice(object):
- def __init__(self, mock_adb_commands):
- self.old_interface = mock_adb_commands
-
- def ReadFile(self, device_path, as_root=False): # pylint: disable=W0613
- return self.old_interface.GetProtectedFileContents(device_path)
-
- def GetProp(self, property_name):
- return self.old_interface.system_properties[property_name]
-
- def SetProp(self, property_name, property_value):
- self.old_interface.system_properties[property_name] = property_value
-
-
class AndroidPlatformBackendTest(unittest.TestCase):
def setUp(self):
- self._stubs = system_stub.Override(android_platform_backend,
- ['perf_control', 'thermal_throttle'])
+ self._stubs = system_stub.Override(
+ android_platform_backend,
+ ['perf_control', 'thermal_throttle', 'adb_commands'])
def tearDown(self):
self._stubs.Restore()
@@ -60,18 +27,19 @@ class AndroidPlatformBackendTest(unittest.TestCase):
'4294967295 1074458624 1074463824 3197495984 3197494152 '
'1074767676 0 4612 0 38136 4294967295 0 0 17 0 0 0 0 0 0 '
'1074470376 1074470912 1102155776']
- adb_valid_proc_content = MockDevice(MockAdbCommands(proc_stat_content, {}))
+ self._stubs.adb_commands.adb_device.mock_content = proc_stat_content
+ old_interface = self._stubs.adb_commands.adb_device.old_interface
+ old_interface.can_access_protected_file_contents = True
backend = android_platform_backend.AndroidPlatformBackend(
- adb_valid_proc_content, False)
+ android_device.AndroidDevice('12345'))
cpu_stats = backend.GetCpuStats('7702')
self.assertEquals(cpu_stats, {'CpuProcessTime': 5.0})
@benchmark.Disabled('chromeos')
def testGetCpuStatsInvalidPID(self):
# Mock an empty /proc/pid/stat.
- adb_empty_proc_stat = MockDevice(MockAdbCommands([], {}))
backend = android_platform_backend.AndroidPlatformBackend(
- adb_empty_proc_stat, False)
+ android_device.AndroidDevice('1234'))
cpu_stats = backend.GetCpuStats('7702')
self.assertEquals(cpu_stats, {})

Powered by Google App Engine
This is Rietveld 408576698