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

Side by Side Diff: Tools/Scripts/webkitpy/layout_tests/port/chromium_android_unittest.py

Issue 16917006: Only consider Android devices with more than 30% battery remaining for layout tests (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 6 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 | Annotate | Revision Log
OLDNEW
1 # Copyright (C) 2012 Google Inc. All rights reserved. 1 # Copyright (C) 2012 Google Inc. All rights reserved.
2 # 2 #
3 # Redistribution and use in source and binary forms, with or without 3 # Redistribution and use in source and binary forms, with or without
4 # modification, are permitted provided that the following conditions are 4 # modification, are permitted provided that the following conditions are
5 # met: 5 # met:
6 # 6 #
7 # * Redistributions of source code must retain the above copyright 7 # * Redistributions of source code must retain the above copyright
8 # notice, this list of conditions and the following disclaimer. 8 # notice, this list of conditions and the following disclaimer.
9 # * Redistributions in binary form must reproduce the above 9 # * Redistributions in binary form must reproduce the above
10 # copyright notice, this list of conditions and the following disclaimer 10 # copyright notice, this list of conditions and the following disclaimer
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 61
62 return 'version 1.0' 62 return 'version 1.0'
63 63
64 if args[0] == 'adb': 64 if args[0] == 'adb':
65 if len(args) > 1 and args[1] == 'version': 65 if len(args) > 1 and args[1] == 'version':
66 return 'version 1.0' 66 return 'version 1.0'
67 if len(args) > 1 and args[1] == 'devices': 67 if len(args) > 1 and args[1] == 'devices':
68 return self._get_device_output() 68 return self._get_device_output()
69 if len(args) > 3 and args[3] == 'command': 69 if len(args) > 3 and args[3] == 'command':
70 return 'mockoutput' 70 return 'mockoutput'
71 if len(args) > 5 and args[5] == 'battery':
72 return 'level: 99'
71 73
72 return '' 74 return ''
73 75
74 def last_command(self): 76 def last_command(self):
75 return self._last_command 77 return self._last_command
76 78
77 # Local private methods. 79 # Local private methods.
78 80
79 def _get_device_output(self): 81 def _get_device_output(self):
80 serials = ['123456789ABCDEF0', '123456789ABCDEF1', '123456789ABCDEF2', 82 serials = ['123456789ABCDEF0', '123456789ABCDEF1', '123456789ABCDEF2',
(...skipping 16 matching lines...) Expand all
97 def make_android_commands(self, device_count, serial): 99 def make_android_commands(self, device_count, serial):
98 return chromium_android.AndroidCommands(self.make_executive(device_count ), serial) 100 return chromium_android.AndroidCommands(self.make_executive(device_count ), serial)
99 101
100 # The "adb" binary with the latest version should be used. 102 # The "adb" binary with the latest version should be used.
101 def serial_test_adb_command_path(self): 103 def serial_test_adb_command_path(self):
102 executive = self.make_executive(0) 104 executive = self.make_executive(0)
103 105
104 chromium_android.AndroidCommands.set_adb_command_path_options(['path1', 'path2', 'path3']) 106 chromium_android.AndroidCommands.set_adb_command_path_options(['path1', 'path2', 'path3'])
105 self.assertEqual('path2', chromium_android.AndroidCommands.adb_command_p ath(executive)) 107 self.assertEqual('path2', chromium_android.AndroidCommands.adb_command_p ath(executive))
106 108
107 # The get_devices() method should throw if there aren't any devices. Otherwi se it returns an array.
108 def test_get_devices(self):
109 self.assertRaises(AssertionError, chromium_android.AndroidCommands.get_d evices, self.make_executive(0))
110 self.assertEquals(1, len(chromium_android.AndroidCommands.get_devices(se lf.make_executive(1))))
111 self.assertEquals(5, len(chromium_android.AndroidCommands.get_devices(se lf.make_executive(5))))
112
113 # The used adb command should include the device's serial number, and get_se rial() should reflect this. 109 # The used adb command should include the device's serial number, and get_se rial() should reflect this.
114 def test_adb_command_and_get_serial(self): 110 def test_adb_command_and_get_serial(self):
115 android_commands = self.make_android_commands(1, '123456789ABCDEF0') 111 android_commands = self.make_android_commands(1, '123456789ABCDEF0')
116 self.assertEquals(['adb', '-s', '123456789ABCDEF0'], android_commands.ad b_command()) 112 self.assertEquals(['adb', '-s', '123456789ABCDEF0'], android_commands.ad b_command())
117 self.assertEquals('123456789ABCDEF0', android_commands.get_serial()) 113 self.assertEquals('123456789ABCDEF0', android_commands.get_serial())
118 114
119 # Running an adb command should return the command's output. 115 # Running an adb command should return the command's output.
120 def test_run_command(self): 116 def test_run_command(self):
121 android_commands = self.make_android_commands(1, '123456789ABCDEF0') 117 android_commands = self.make_android_commands(1, '123456789ABCDEF0')
122 118
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 # Tests the default timeouts for Android, which are different than the rest of Chromium. 180 # Tests the default timeouts for Android, which are different than the rest of Chromium.
185 def test_default_timeout_ms(self): 181 def test_default_timeout_ms(self):
186 self.assertEqual(self.make_port(options=optparse.Values({'configuration' : 'Release'})).default_timeout_ms(), 10000) 182 self.assertEqual(self.make_port(options=optparse.Values({'configuration' : 'Release'})).default_timeout_ms(), 10000)
187 self.assertEqual(self.make_port(options=optparse.Values({'configuration' : 'Debug'})).default_timeout_ms(), 10000) 183 self.assertEqual(self.make_port(options=optparse.Values({'configuration' : 'Debug'})).default_timeout_ms(), 10000)
188 184
189 185
190 class ChromiumAndroidDriverTest(unittest.TestCase): 186 class ChromiumAndroidDriverTest(unittest.TestCase):
191 def setUp(self): 187 def setUp(self):
192 self._mock_adb = MockAndroidDebugBridge(1) 188 self._mock_adb = MockAndroidDebugBridge(1)
193 self._mock_executive = MockExecutive2(run_command_fn=self._mock_adb.run_ command) 189 self._mock_executive = MockExecutive2(run_command_fn=self._mock_adb.run_ command)
190
191 android_commands = chromium_android.AndroidCommands(self._mock_executive , '123456789ABCDEF0')
194 self._port = chromium_android.ChromiumAndroidPort(MockSystemHost(executi ve=self._mock_executive), 'chromium-android') 192 self._port = chromium_android.ChromiumAndroidPort(MockSystemHost(executi ve=self._mock_executive), 'chromium-android')
195 self._driver = chromium_android.ChromiumAndroidDriver(self._port, worker _number=0, 193 self._driver = chromium_android.ChromiumAndroidDriver(self._port, worker _number=0,
196 pixel_tests=True, driver_details=chromium_android.ContentShellDriver Details()) 194 pixel_tests=True, driver_details=chromium_android.ContentShellDriver Details(), android_commands=android_commands)
197 195
198 # The cmd_line() method in the Android port is used for starting a shell, no t the test runner. 196 # The cmd_line() method in the Android port is used for starting a shell, no t the test runner.
199 def test_cmd_line(self): 197 def test_cmd_line(self):
200 self.assertEquals(['adb', '-s', '123456789ABCDEF0', 'shell'], self._driv er.cmd_line(False, [])) 198 self.assertEquals(['adb', '-s', '123456789ABCDEF0', 'shell'], self._driv er.cmd_line(False, []))
201 199
202 # Test that the Chromium Android port can interpret Android's shell output. 200 # Test that the Chromium Android port can interpret Android's shell output.
203 def test_read_prompt(self): 201 def test_read_prompt(self):
204 self._driver._server_process = driver_unittest.MockServerProcess(lines=[ 'root@android:/ # ']) 202 self._driver._server_process = driver_unittest.MockServerProcess(lines=[ 'root@android:/ # '])
205 self.assertIsNone(self._driver._read_prompt(time.time() + 1)) 203 self.assertIsNone(self._driver._read_prompt(time.time() + 1))
206 self._driver._server_process = driver_unittest.MockServerProcess(lines=[ '$ ']) 204 self._driver._server_process = driver_unittest.MockServerProcess(lines=[ '$ '])
207 self.assertIsNone(self._driver._read_prompt(time.time() + 1)) 205 self.assertIsNone(self._driver._read_prompt(time.time() + 1))
208 206
209 207
210 class ChromiumAndroidDriverTwoDriverTest(unittest.TestCase): 208 class ChromiumAndroidDriverTwoDriversTest(unittest.TestCase):
211 # Test two drivers getting the right serial numbers, and that we disregard p er-test arguments. 209 # Test two drivers getting the right serial numbers, and that we disregard p er-test arguments.
212 def test_two_drivers(self): 210 def test_two_drivers(self):
213 mock_adb = MockAndroidDebugBridge(2) 211 mock_adb = MockAndroidDebugBridge(2)
214 mock_executive = MockExecutive2(run_command_fn=mock_adb.run_command) 212 mock_executive = MockExecutive2(run_command_fn=mock_adb.run_command)
215 213
216 port = chromium_android.ChromiumAndroidPort(MockSystemHost(executive=moc k_executive), 'chromium-android') 214 port = chromium_android.ChromiumAndroidPort(MockSystemHost(executive=moc k_executive), 'chromium-android')
217 driver0 = chromium_android.ChromiumAndroidDriver(port, worker_number=0, pixel_tests=True, 215 driver0 = chromium_android.ChromiumAndroidDriver(port, worker_number=0, pixel_tests=True,
218 driver_details=chromium_android.DumpRenderTreeDriverDetails()) 216 driver_details=chromium_android.DumpRenderTreeDriverDetails(), andro id_commands=port._devices.get_device(mock_executive, 0))
219 driver1 = chromium_android.ChromiumAndroidDriver(port, worker_number=1, pixel_tests=True, 217 driver1 = chromium_android.ChromiumAndroidDriver(port, worker_number=1, pixel_tests=True,
220 driver_details=chromium_android.DumpRenderTreeDriverDetails()) 218 driver_details=chromium_android.DumpRenderTreeDriverDetails(), andro id_commands=port._devices.get_device(mock_executive, 1))
221 219
222 self.assertEqual(['adb', '-s', '123456789ABCDEF0', 'shell'], driver0.cmd _line(True, [])) 220 self.assertEqual(['adb', '-s', '123456789ABCDEF0', 'shell'], driver0.cmd _line(True, []))
223 self.assertEqual(['adb', '-s', '123456789ABCDEF1', 'shell'], driver1.cmd _line(True, ['anything'])) 221 self.assertEqual(['adb', '-s', '123456789ABCDEF1', 'shell'], driver1.cmd _line(True, ['anything']))
224 222
225 223
226 class ChromiumAndroidTwoPortsTest(unittest.TestCase): 224 class ChromiumAndroidTwoPortsTest(unittest.TestCase):
227 # Test that the driver's command line indeed goes through to the driver. 225 # Test that the driver's command line indeed goes through to the driver.
228 def test_options_with_two_ports(self): 226 def test_options_with_two_ports(self):
229 mock_adb = MockAndroidDebugBridge(2) 227 mock_adb = MockAndroidDebugBridge(2)
230 mock_executive = MockExecutive2(run_command_fn=mock_adb.run_command) 228 mock_executive = MockExecutive2(run_command_fn=mock_adb.run_command)
231 229
232 port0 = chromium_android.ChromiumAndroidPort(MockSystemHost(executive=mo ck_executive), 230 port0 = chromium_android.ChromiumAndroidPort(MockSystemHost(executive=mo ck_executive),
233 'chromium-android', options=MockOptions(additional_drt_flag=['--foo= bar'])) 231 'chromium-android', options=MockOptions(additional_drt_flag=['--foo= bar']))
234 port1 = chromium_android.ChromiumAndroidPort(MockSystemHost(executive=mo ck_executive), 232 port1 = chromium_android.ChromiumAndroidPort(MockSystemHost(executive=mo ck_executive),
235 'chromium-android', options=MockOptions(driver_name='content_shell') ) 233 'chromium-android', options=MockOptions(driver_name='content_shell') )
236 234
237 self.assertEqual(1, port0.driver_cmd_line().count('--foo=bar')) 235 self.assertEqual(1, port0.driver_cmd_line().count('--foo=bar'))
238 self.assertEqual(0, port1.driver_cmd_line().count('--create-stdin-fifo') ) 236 self.assertEqual(0, port1.driver_cmd_line().count('--create-stdin-fifo') )
239 237
240 238
241 class ChromiumAndroidDriverTwoDriversTest(unittest.TestCase):
242 # Test two drivers getting the right serial numbers, and that we disregard p er-test arguments.
243 def test_two_drivers(self):
244 mock_adb = MockAndroidDebugBridge(2)
245 mock_executive = MockExecutive2(run_command_fn=mock_adb.run_command)
246
247 port = chromium_android.ChromiumAndroidPort(MockSystemHost(executive=moc k_executive), 'chromium-android')
248 driver0 = chromium_android.ChromiumAndroidDriver(port, worker_number=0, pixel_tests=True,
249 driver_details=chromium_android.ContentShellDriverDetails())
250 driver1 = chromium_android.ChromiumAndroidDriver(port, worker_number=1, pixel_tests=True,
251 driver_details=chromium_android.ContentShellDriverDetails())
252
253 self.assertEqual(['adb', '-s', '123456789ABCDEF0', 'shell'], driver0.cmd _line(True, []))
254 self.assertEqual(['adb', '-s', '123456789ABCDEF1', 'shell'], driver1.cmd _line(True, []))
255
256
257 class ChromiumAndroidTwoPortsTest(unittest.TestCase): 239 class ChromiumAndroidTwoPortsTest(unittest.TestCase):
258 # Test that the driver's command line indeed goes through to the driver. 240 # Test that the driver's command line indeed goes through to the driver.
259 def test_options_with_two_ports(self): 241 def test_options_with_two_ports(self):
260 mock_adb = MockAndroidDebugBridge(2) 242 mock_adb = MockAndroidDebugBridge(2)
261 mock_executive = MockExecutive2(run_command_fn=mock_adb.run_command) 243 mock_executive = MockExecutive2(run_command_fn=mock_adb.run_command)
262 244
263 port0 = chromium_android.ChromiumAndroidPort(MockSystemHost(executive=mo ck_executive), 245 port0 = chromium_android.ChromiumAndroidPort(MockSystemHost(executive=mo ck_executive),
264 'chromium-android', options=MockOptions(additional_drt_flag=['--foo= bar'])) 246 'chromium-android', options=MockOptions(additional_drt_flag=['--foo= bar']))
265 port1 = chromium_android.ChromiumAndroidPort(MockSystemHost(executive=mo ck_executive), 247 port1 = chromium_android.ChromiumAndroidPort(MockSystemHost(executive=mo ck_executive),
266 'chromium-android', options=MockOptions(driver_name='content_shell') ) 248 'chromium-android', options=MockOptions(driver_name='content_shell') )
267 249
268 self.assertEqual(1, port0.driver_cmd_line().count('--foo=bar')) 250 self.assertEqual(1, port0.driver_cmd_line().count('--foo=bar'))
269 self.assertEqual(0, port1.driver_cmd_line().count('--create-stdin-fifo') ) 251 self.assertEqual(0, port1.driver_cmd_line().count('--create-stdin-fifo') )
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698