OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright 2014 The Chromium Authors. All rights reserved. | 2 # Copyright 2014 The Chromium Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 """ | 6 """ |
7 Unit tests for the contents of device_utils.py (mostly DeviceUtils). | 7 Unit tests for the contents of device_utils.py (mostly DeviceUtils). |
8 """ | 8 """ |
9 | 9 |
10 # pylint: disable=C0321 | 10 # pylint: disable=C0321 |
11 # pylint: disable=W0212 | 11 # pylint: disable=W0212 |
12 # pylint: disable=W0613 | 12 # pylint: disable=W0613 |
13 | 13 |
14 import collections | 14 import collections |
15 import datetime | 15 import datetime |
16 import logging | 16 import logging |
17 import os | 17 import os |
18 import re | 18 import re |
19 import sys | 19 import sys |
20 import unittest | 20 import unittest |
21 | 21 |
22 from pylib import android_commands | 22 from pylib import android_commands |
23 from pylib import cmd_helper | 23 from pylib import cmd_helper |
24 from pylib import constants | 24 from pylib import constants |
25 from pylib import device_signal | 25 from pylib import device_signal |
26 from pylib.device import adb_wrapper | 26 from pylib.device import adb_wrapper |
27 from pylib.device import device_errors | 27 from pylib.device import device_errors |
28 from pylib.device import device_utils | 28 from pylib.device import device_utils |
29 from pylib.device import intent | 29 from pylib.device import intent |
| 30 from pylib.sdk import split_select |
30 from pylib.utils import mock_calls | 31 from pylib.utils import mock_calls |
31 | 32 |
32 # RunCommand from third_party/android_testrunner/run_command.py is mocked | 33 # RunCommand from third_party/android_testrunner/run_command.py is mocked |
33 # below, so its path needs to be in sys.path. | 34 # below, so its path needs to be in sys.path. |
34 sys.path.append(os.path.join( | 35 sys.path.append(os.path.join( |
35 constants.DIR_SOURCE_ROOT, 'third_party', 'android_testrunner')) | 36 constants.DIR_SOURCE_ROOT, 'third_party', 'android_testrunner')) |
36 | 37 |
37 sys.path.append(os.path.join( | 38 sys.path.append(os.path.join( |
38 constants.DIR_SOURCE_ROOT, 'third_party', 'pymock')) | 39 constants.DIR_SOURCE_ROOT, 'third_party', 'pymock')) |
39 import mock # pylint: disable=F0401 | 40 import mock # pylint: disable=F0401 |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 | 134 |
134 | 135 |
135 class DeviceUtilsTest(mock_calls.TestCase): | 136 class DeviceUtilsTest(mock_calls.TestCase): |
136 | 137 |
137 def setUp(self): | 138 def setUp(self): |
138 self.adb = _AdbWrapperMock('0123456789abcdef') | 139 self.adb = _AdbWrapperMock('0123456789abcdef') |
139 self.device = device_utils.DeviceUtils( | 140 self.device = device_utils.DeviceUtils( |
140 self.adb, default_timeout=10, default_retries=0) | 141 self.adb, default_timeout=10, default_retries=0) |
141 self.watchMethodCalls(self.call.adb, ignore=['GetDeviceSerial']) | 142 self.watchMethodCalls(self.call.adb, ignore=['GetDeviceSerial']) |
142 | 143 |
| 144 def AdbCommandError(self, args=None, output=None, status=None, msg=None): |
| 145 if args is None: |
| 146 args = ['[unspecified]'] |
| 147 return mock.Mock(side_effect=device_errors.AdbCommandFailedError( |
| 148 args, output, status, msg, str(self.device))) |
| 149 |
| 150 def CommandError(self, msg=None): |
| 151 if msg is None: |
| 152 msg = 'Command failed' |
| 153 return mock.Mock(side_effect=device_errors.CommandFailedError( |
| 154 msg, str(self.device))) |
| 155 |
143 def ShellError(self, output=None, status=1): | 156 def ShellError(self, output=None, status=1): |
144 def action(cmd, *args, **kwargs): | 157 def action(cmd, *args, **kwargs): |
145 raise device_errors.AdbShellCommandFailedError( | 158 raise device_errors.AdbShellCommandFailedError( |
146 cmd, output, status, str(self.device)) | 159 cmd, output, status, str(self.device)) |
147 if output is None: | 160 if output is None: |
148 output = 'Permission denied\n' | 161 output = 'Permission denied\n' |
149 return action | 162 return action |
150 | 163 |
151 def TimeoutError(self, msg=None): | 164 def TimeoutError(self, msg=None): |
152 if msg is None: | 165 if msg is None: |
153 msg = 'Operation timed out' | 166 msg = 'Operation timed out' |
154 return mock.Mock(side_effect=device_errors.CommandTimeoutError( | 167 return mock.Mock(side_effect=device_errors.CommandTimeoutError( |
155 msg, str(self.device))) | 168 msg, str(self.device))) |
156 | 169 |
157 def CommandError(self, msg=None): | |
158 if msg is None: | |
159 msg = 'Command failed' | |
160 return mock.Mock(side_effect=device_errors.CommandFailedError( | |
161 msg, str(self.device))) | |
162 | |
163 | 170 |
164 class DeviceUtilsEqTest(DeviceUtilsTest): | 171 class DeviceUtilsEqTest(DeviceUtilsTest): |
165 | 172 |
166 def testEq_equal_deviceUtils(self): | 173 def testEq_equal_deviceUtils(self): |
167 other = device_utils.DeviceUtils(_AdbWrapperMock('0123456789abcdef')) | 174 other = device_utils.DeviceUtils(_AdbWrapperMock('0123456789abcdef')) |
168 self.assertTrue(self.device == other) | 175 self.assertTrue(self.device == other) |
169 self.assertTrue(other == self.device) | 176 self.assertTrue(other == self.device) |
170 | 177 |
171 def testEq_equal_adbWrapper(self): | 178 def testEq_equal_adbWrapper(self): |
172 other = adb_wrapper.AdbWrapper('0123456789abcdef') | 179 other = adb_wrapper.AdbWrapper('0123456789abcdef') |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
252 def testHasRoot_false(self): | 259 def testHasRoot_false(self): |
253 with self.assertCall(self.call.adb.Shell('ls /root'), self.ShellError()): | 260 with self.assertCall(self.call.adb.Shell('ls /root'), self.ShellError()): |
254 self.assertFalse(self.device.HasRoot()) | 261 self.assertFalse(self.device.HasRoot()) |
255 | 262 |
256 | 263 |
257 class DeviceUtilsEnableRootTest(DeviceUtilsTest): | 264 class DeviceUtilsEnableRootTest(DeviceUtilsTest): |
258 | 265 |
259 def testEnableRoot_succeeds(self): | 266 def testEnableRoot_succeeds(self): |
260 with self.assertCalls( | 267 with self.assertCalls( |
261 (self.call.device.IsUserBuild(), False), | 268 (self.call.device.IsUserBuild(), False), |
262 self.call.adb.Root(), | 269 self.call.adb.Root(), |
263 self.call.adb.WaitForDevice()): | 270 self.call.device.WaitUntilFullyBooted()): |
264 self.device.EnableRoot() | 271 self.device.EnableRoot() |
265 | 272 |
266 def testEnableRoot_userBuild(self): | 273 def testEnableRoot_userBuild(self): |
267 with self.assertCalls( | 274 with self.assertCalls( |
268 (self.call.device.IsUserBuild(), True)): | 275 (self.call.device.IsUserBuild(), True)): |
269 with self.assertRaises(device_errors.CommandFailedError): | 276 with self.assertRaises(device_errors.CommandFailedError): |
270 self.device.EnableRoot() | 277 self.device.EnableRoot() |
271 | 278 |
272 def testEnableRoot_rootFails(self): | 279 def testEnableRoot_rootFails(self): |
273 with self.assertCalls( | 280 with self.assertCalls( |
(...skipping 23 matching lines...) Expand all Loading... |
297 self.call.adb.Shell('echo $EXTERNAL_STORAGE'), '/fake/storage/path\n'): | 304 self.call.adb.Shell('echo $EXTERNAL_STORAGE'), '/fake/storage/path\n'): |
298 self.assertEquals('/fake/storage/path', | 305 self.assertEquals('/fake/storage/path', |
299 self.device.GetExternalStoragePath()) | 306 self.device.GetExternalStoragePath()) |
300 | 307 |
301 def testGetExternalStoragePath_fails(self): | 308 def testGetExternalStoragePath_fails(self): |
302 with self.assertCall(self.call.adb.Shell('echo $EXTERNAL_STORAGE'), '\n'): | 309 with self.assertCall(self.call.adb.Shell('echo $EXTERNAL_STORAGE'), '\n'): |
303 with self.assertRaises(device_errors.CommandFailedError): | 310 with self.assertRaises(device_errors.CommandFailedError): |
304 self.device.GetExternalStoragePath() | 311 self.device.GetExternalStoragePath() |
305 | 312 |
306 | 313 |
307 class DeviceUtilsGetApplicationPathTest(DeviceUtilsTest): | 314 class DeviceUtilsGetApplicationPathsTest(DeviceUtilsTest): |
308 | 315 |
309 def testGetApplicationPath_exists(self): | 316 def testGetApplicationPaths_exists(self): |
310 with self.assertCalls( | 317 with self.assertCalls( |
311 (self.call.adb.Shell('getprop ro.build.version.sdk'), '19\n'), | 318 (self.call.adb.Shell('getprop ro.build.version.sdk'), '19\n'), |
312 (self.call.adb.Shell('pm path android'), | 319 (self.call.adb.Shell('pm path android'), |
313 'package:/path/to/android.apk\n')): | 320 'package:/path/to/android.apk\n')): |
314 self.assertEquals('/path/to/android.apk', | 321 self.assertEquals(['/path/to/android.apk'], |
315 self.device.GetApplicationPath('android')) | 322 self.device.GetApplicationPaths('android')) |
316 | 323 |
317 def testGetApplicationPath_notExists(self): | 324 def testGetApplicationPaths_notExists(self): |
318 with self.assertCalls( | 325 with self.assertCalls( |
319 (self.call.adb.Shell('getprop ro.build.version.sdk'), '19\n'), | 326 (self.call.adb.Shell('getprop ro.build.version.sdk'), '19\n'), |
320 (self.call.adb.Shell('pm path not.installed.app'), '')): | 327 (self.call.adb.Shell('pm path not.installed.app'), '')): |
321 self.assertEquals(None, | 328 self.assertEquals([], |
322 self.device.GetApplicationPath('not.installed.app')) | 329 self.device.GetApplicationPaths('not.installed.app')) |
323 | 330 |
324 def testGetApplicationPath_fails(self): | 331 def testGetApplicationPaths_fails(self): |
325 with self.assertCalls( | 332 with self.assertCalls( |
326 (self.call.adb.Shell('getprop ro.build.version.sdk'), '19\n'), | 333 (self.call.adb.Shell('getprop ro.build.version.sdk'), '19\n'), |
327 (self.call.adb.Shell('pm path android'), | 334 (self.call.adb.Shell('pm path android'), |
328 self.CommandError('ERROR. Is package manager running?\n'))): | 335 self.CommandError('ERROR. Is package manager running?\n'))): |
329 with self.assertRaises(device_errors.CommandFailedError): | 336 with self.assertRaises(device_errors.CommandFailedError): |
330 self.device.GetApplicationPath('android') | 337 self.device.GetApplicationPaths('android') |
| 338 |
| 339 |
| 340 class DeviceUtilsGetApplicationDataDirectoryTest(DeviceUtilsTest): |
| 341 |
| 342 def testGetApplicationDataDirectory_exists(self): |
| 343 with self.assertCall( |
| 344 self.call.device._RunPipedShellCommand( |
| 345 'pm dump foo.bar.baz | grep dataDir='), |
| 346 ['dataDir=/data/data/foo.bar.baz']): |
| 347 self.assertEquals( |
| 348 '/data/data/foo.bar.baz', |
| 349 self.device.GetApplicationDataDirectory('foo.bar.baz')) |
| 350 |
| 351 def testGetApplicationDataDirectory_notExists(self): |
| 352 with self.assertCall( |
| 353 self.call.device._RunPipedShellCommand( |
| 354 'pm dump foo.bar.baz | grep dataDir='), |
| 355 self.ShellError()): |
| 356 self.assertIsNone(self.device.GetApplicationDataDirectory('foo.bar.baz')) |
331 | 357 |
332 | 358 |
333 @mock.patch('time.sleep', mock.Mock()) | 359 @mock.patch('time.sleep', mock.Mock()) |
334 class DeviceUtilsWaitUntilFullyBootedTest(DeviceUtilsTest): | 360 class DeviceUtilsWaitUntilFullyBootedTest(DeviceUtilsTest): |
335 | 361 |
336 def testWaitUntilFullyBooted_succeedsNoWifi(self): | 362 def testWaitUntilFullyBooted_succeedsNoWifi(self): |
337 with self.assertCalls( | 363 with self.assertCalls( |
338 self.call.adb.WaitForDevice(), | 364 self.call.adb.WaitForDevice(), |
339 # sd_card_ready | 365 # sd_card_ready |
340 (self.call.device.GetExternalStoragePath(), '/fake/storage/path'), | 366 (self.call.device.GetExternalStoragePath(), '/fake/storage/path'), |
341 (self.call.adb.Shell('test -d /fake/storage/path'), ''), | 367 (self.call.adb.Shell('test -d /fake/storage/path'), ''), |
342 # pm_ready | 368 # pm_ready |
343 (self.call.device.GetApplicationPath('android'), | 369 (self.call.device.GetApplicationPaths('android'), |
344 'package:/some/fake/path'), | 370 ['package:/some/fake/path']), |
345 # boot_completed | 371 # boot_completed |
346 (self.call.device.GetProp('sys.boot_completed'), '1')): | 372 (self.call.device.GetProp('sys.boot_completed'), '1')): |
347 self.device.WaitUntilFullyBooted(wifi=False) | 373 self.device.WaitUntilFullyBooted(wifi=False) |
348 | 374 |
349 def testWaitUntilFullyBooted_succeedsWithWifi(self): | 375 def testWaitUntilFullyBooted_succeedsWithWifi(self): |
350 with self.assertCalls( | 376 with self.assertCalls( |
351 self.call.adb.WaitForDevice(), | 377 self.call.adb.WaitForDevice(), |
352 # sd_card_ready | 378 # sd_card_ready |
353 (self.call.device.GetExternalStoragePath(), '/fake/storage/path'), | 379 (self.call.device.GetExternalStoragePath(), '/fake/storage/path'), |
354 (self.call.adb.Shell('test -d /fake/storage/path'), ''), | 380 (self.call.adb.Shell('test -d /fake/storage/path'), ''), |
355 # pm_ready | 381 # pm_ready |
356 (self.call.device.GetApplicationPath('android'), | 382 (self.call.device.GetApplicationPaths('android'), |
357 'package:/some/fake/path'), | 383 ['package:/some/fake/path']), |
358 # boot_completed | 384 # boot_completed |
359 (self.call.device.GetProp('sys.boot_completed'), '1'), | 385 (self.call.device.GetProp('sys.boot_completed'), '1'), |
360 # wifi_enabled | 386 # wifi_enabled |
361 (self.call.adb.Shell('dumpsys wifi'), | 387 (self.call.adb.Shell('dumpsys wifi'), |
362 'stuff\nWi-Fi is enabled\nmore stuff\n')): | 388 'stuff\nWi-Fi is enabled\nmore stuff\n')): |
363 self.device.WaitUntilFullyBooted(wifi=True) | 389 self.device.WaitUntilFullyBooted(wifi=True) |
364 | 390 |
| 391 def testWaitUntilFullyBooted_deviceNotInitiallyAvailable(self): |
| 392 with self.assertCalls( |
| 393 self.call.adb.WaitForDevice(), |
| 394 # sd_card_ready |
| 395 (self.call.device.GetExternalStoragePath(), self.AdbCommandError()), |
| 396 # sd_card_ready |
| 397 (self.call.device.GetExternalStoragePath(), self.AdbCommandError()), |
| 398 # sd_card_ready |
| 399 (self.call.device.GetExternalStoragePath(), self.AdbCommandError()), |
| 400 # sd_card_ready |
| 401 (self.call.device.GetExternalStoragePath(), self.AdbCommandError()), |
| 402 # sd_card_ready |
| 403 (self.call.device.GetExternalStoragePath(), '/fake/storage/path'), |
| 404 (self.call.adb.Shell('test -d /fake/storage/path'), ''), |
| 405 # pm_ready |
| 406 (self.call.device.GetApplicationPaths('android'), |
| 407 ['package:/some/fake/path']), |
| 408 # boot_completed |
| 409 (self.call.device.GetProp('sys.boot_completed'), '1')): |
| 410 self.device.WaitUntilFullyBooted(wifi=False) |
| 411 |
365 def testWaitUntilFullyBooted_sdCardReadyFails_noPath(self): | 412 def testWaitUntilFullyBooted_sdCardReadyFails_noPath(self): |
366 with self.assertCalls( | 413 with self.assertCalls( |
367 self.call.adb.WaitForDevice(), | 414 self.call.adb.WaitForDevice(), |
368 # sd_card_ready | 415 # sd_card_ready |
369 (self.call.device.GetExternalStoragePath(), self.CommandError())): | 416 (self.call.device.GetExternalStoragePath(), self.CommandError())): |
370 with self.assertRaises(device_errors.CommandFailedError): | 417 with self.assertRaises(device_errors.CommandFailedError): |
371 self.device.WaitUntilFullyBooted(wifi=False) | 418 self.device.WaitUntilFullyBooted(wifi=False) |
372 | 419 |
373 def testWaitUntilFullyBooted_sdCardReadyFails_notExists(self): | 420 def testWaitUntilFullyBooted_sdCardReadyFails_notExists(self): |
374 with self.assertCalls( | 421 with self.assertCalls( |
(...skipping 11 matching lines...) Expand all Loading... |
386 with self.assertRaises(device_errors.CommandTimeoutError): | 433 with self.assertRaises(device_errors.CommandTimeoutError): |
387 self.device.WaitUntilFullyBooted(wifi=False) | 434 self.device.WaitUntilFullyBooted(wifi=False) |
388 | 435 |
389 def testWaitUntilFullyBooted_devicePmFails(self): | 436 def testWaitUntilFullyBooted_devicePmFails(self): |
390 with self.assertCalls( | 437 with self.assertCalls( |
391 self.call.adb.WaitForDevice(), | 438 self.call.adb.WaitForDevice(), |
392 # sd_card_ready | 439 # sd_card_ready |
393 (self.call.device.GetExternalStoragePath(), '/fake/storage/path'), | 440 (self.call.device.GetExternalStoragePath(), '/fake/storage/path'), |
394 (self.call.adb.Shell('test -d /fake/storage/path'), ''), | 441 (self.call.adb.Shell('test -d /fake/storage/path'), ''), |
395 # pm_ready | 442 # pm_ready |
396 (self.call.device.GetApplicationPath('android'), self.CommandError()), | 443 (self.call.device.GetApplicationPaths('android'), self.CommandError()), |
397 # pm_ready | 444 # pm_ready |
398 (self.call.device.GetApplicationPath('android'), self.CommandError()), | 445 (self.call.device.GetApplicationPaths('android'), self.CommandError()), |
399 # pm_ready | 446 # pm_ready |
400 (self.call.device.GetApplicationPath('android'), self.TimeoutError())): | 447 (self.call.device.GetApplicationPaths('android'), self.TimeoutError())): |
401 with self.assertRaises(device_errors.CommandTimeoutError): | 448 with self.assertRaises(device_errors.CommandTimeoutError): |
402 self.device.WaitUntilFullyBooted(wifi=False) | 449 self.device.WaitUntilFullyBooted(wifi=False) |
403 | 450 |
404 def testWaitUntilFullyBooted_bootFails(self): | 451 def testWaitUntilFullyBooted_bootFails(self): |
405 with self.assertCalls( | 452 with self.assertCalls( |
406 self.call.adb.WaitForDevice(), | 453 self.call.adb.WaitForDevice(), |
407 # sd_card_ready | 454 # sd_card_ready |
408 (self.call.device.GetExternalStoragePath(), '/fake/storage/path'), | 455 (self.call.device.GetExternalStoragePath(), '/fake/storage/path'), |
409 (self.call.adb.Shell('test -d /fake/storage/path'), ''), | 456 (self.call.adb.Shell('test -d /fake/storage/path'), ''), |
410 # pm_ready | 457 # pm_ready |
411 (self.call.device.GetApplicationPath('android'), | 458 (self.call.device.GetApplicationPaths('android'), |
412 'package:/some/fake/path'), | 459 ['package:/some/fake/path']), |
413 # boot_completed | 460 # boot_completed |
414 (self.call.device.GetProp('sys.boot_completed'), '0'), | 461 (self.call.device.GetProp('sys.boot_completed'), '0'), |
415 # boot_completed | 462 # boot_completed |
416 (self.call.device.GetProp('sys.boot_completed'), '0'), | 463 (self.call.device.GetProp('sys.boot_completed'), '0'), |
417 # boot_completed | 464 # boot_completed |
418 (self.call.device.GetProp('sys.boot_completed'), self.TimeoutError())): | 465 (self.call.device.GetProp('sys.boot_completed'), self.TimeoutError())): |
419 with self.assertRaises(device_errors.CommandTimeoutError): | 466 with self.assertRaises(device_errors.CommandTimeoutError): |
420 self.device.WaitUntilFullyBooted(wifi=False) | 467 self.device.WaitUntilFullyBooted(wifi=False) |
421 | 468 |
422 def testWaitUntilFullyBooted_wifiFails(self): | 469 def testWaitUntilFullyBooted_wifiFails(self): |
423 with self.assertCalls( | 470 with self.assertCalls( |
424 self.call.adb.WaitForDevice(), | 471 self.call.adb.WaitForDevice(), |
425 # sd_card_ready | 472 # sd_card_ready |
426 (self.call.device.GetExternalStoragePath(), '/fake/storage/path'), | 473 (self.call.device.GetExternalStoragePath(), '/fake/storage/path'), |
427 (self.call.adb.Shell('test -d /fake/storage/path'), ''), | 474 (self.call.adb.Shell('test -d /fake/storage/path'), ''), |
428 # pm_ready | 475 # pm_ready |
429 (self.call.device.GetApplicationPath('android'), | 476 (self.call.device.GetApplicationPaths('android'), |
430 'package:/some/fake/path'), | 477 ['package:/some/fake/path']), |
431 # boot_completed | 478 # boot_completed |
432 (self.call.device.GetProp('sys.boot_completed'), '1'), | 479 (self.call.device.GetProp('sys.boot_completed'), '1'), |
433 # wifi_enabled | 480 # wifi_enabled |
434 (self.call.adb.Shell('dumpsys wifi'), 'stuff\nmore stuff\n'), | 481 (self.call.adb.Shell('dumpsys wifi'), 'stuff\nmore stuff\n'), |
435 # wifi_enabled | 482 # wifi_enabled |
436 (self.call.adb.Shell('dumpsys wifi'), 'stuff\nmore stuff\n'), | 483 (self.call.adb.Shell('dumpsys wifi'), 'stuff\nmore stuff\n'), |
437 # wifi_enabled | 484 # wifi_enabled |
438 (self.call.adb.Shell('dumpsys wifi'), self.TimeoutError())): | 485 (self.call.adb.Shell('dumpsys wifi'), self.TimeoutError())): |
439 with self.assertRaises(device_errors.CommandTimeoutError): | 486 with self.assertRaises(device_errors.CommandTimeoutError): |
440 self.device.WaitUntilFullyBooted(wifi=True) | 487 self.device.WaitUntilFullyBooted(wifi=True) |
(...skipping 25 matching lines...) Expand all Loading... |
466 self.call.device.WaitUntilFullyBooted(wifi=True)): | 513 self.call.device.WaitUntilFullyBooted(wifi=True)): |
467 self.device.Reboot(block=True, wifi=True) | 514 self.device.Reboot(block=True, wifi=True) |
468 | 515 |
469 | 516 |
470 class DeviceUtilsInstallTest(DeviceUtilsTest): | 517 class DeviceUtilsInstallTest(DeviceUtilsTest): |
471 | 518 |
472 def testInstall_noPriorInstall(self): | 519 def testInstall_noPriorInstall(self): |
473 with self.assertCalls( | 520 with self.assertCalls( |
474 (mock.call.pylib.utils.apk_helper.GetPackageName('/fake/test/app.apk'), | 521 (mock.call.pylib.utils.apk_helper.GetPackageName('/fake/test/app.apk'), |
475 'this.is.a.test.package'), | 522 'this.is.a.test.package'), |
476 (self.call.device.GetApplicationPath('this.is.a.test.package'), None), | 523 (self.call.device.GetApplicationPaths('this.is.a.test.package'), []), |
477 self.call.adb.Install('/fake/test/app.apk', reinstall=False)): | 524 self.call.adb.Install('/fake/test/app.apk', reinstall=False)): |
478 self.device.Install('/fake/test/app.apk', retries=0) | 525 self.device.Install('/fake/test/app.apk', retries=0) |
479 | 526 |
480 def testInstall_differentPriorInstall(self): | 527 def testInstall_differentPriorInstall(self): |
481 with self.assertCalls( | 528 with self.assertCalls( |
482 (mock.call.pylib.utils.apk_helper.GetPackageName('/fake/test/app.apk'), | 529 (mock.call.pylib.utils.apk_helper.GetPackageName('/fake/test/app.apk'), |
483 'this.is.a.test.package'), | 530 'this.is.a.test.package'), |
484 (self.call.device.GetApplicationPath('this.is.a.test.package'), | 531 (self.call.device.GetApplicationPaths('this.is.a.test.package'), |
485 '/fake/data/app/this.is.a.test.package.apk'), | 532 ['/fake/data/app/this.is.a.test.package.apk']), |
486 (self.call.device._GetChangedFilesImpl( | 533 (self.call.device._GetChangedAndStaleFiles( |
487 '/fake/test/app.apk', '/fake/data/app/this.is.a.test.package.apk'), | 534 '/fake/test/app.apk', '/fake/data/app/this.is.a.test.package.apk'), |
488 [('/fake/test/app.apk', '/fake/data/app/this.is.a.test.package.apk')]), | 535 ([('/fake/test/app.apk', '/fake/data/app/this.is.a.test.package.apk')], |
| 536 [])), |
489 self.call.adb.Uninstall('this.is.a.test.package'), | 537 self.call.adb.Uninstall('this.is.a.test.package'), |
490 self.call.adb.Install('/fake/test/app.apk', reinstall=False)): | 538 self.call.adb.Install('/fake/test/app.apk', reinstall=False)): |
491 self.device.Install('/fake/test/app.apk', retries=0) | 539 self.device.Install('/fake/test/app.apk', retries=0) |
492 | 540 |
493 def testInstall_differentPriorInstall_reinstall(self): | 541 def testInstall_differentPriorInstall_reinstall(self): |
494 with self.assertCalls( | 542 with self.assertCalls( |
495 (mock.call.pylib.utils.apk_helper.GetPackageName('/fake/test/app.apk'), | 543 (mock.call.pylib.utils.apk_helper.GetPackageName('/fake/test/app.apk'), |
496 'this.is.a.test.package'), | 544 'this.is.a.test.package'), |
497 (self.call.device.GetApplicationPath('this.is.a.test.package'), | 545 (self.call.device.GetApplicationPaths('this.is.a.test.package'), |
498 '/fake/data/app/this.is.a.test.package.apk'), | 546 ['/fake/data/app/this.is.a.test.package.apk']), |
499 (self.call.device._GetChangedFilesImpl( | 547 (self.call.device._GetChangedAndStaleFiles( |
500 '/fake/test/app.apk', '/fake/data/app/this.is.a.test.package.apk'), | 548 '/fake/test/app.apk', '/fake/data/app/this.is.a.test.package.apk'), |
501 [('/fake/test/app.apk', '/fake/data/app/this.is.a.test.package.apk')]), | 549 ([('/fake/test/app.apk', '/fake/data/app/this.is.a.test.package.apk')], |
| 550 [])), |
502 self.call.adb.Install('/fake/test/app.apk', reinstall=True)): | 551 self.call.adb.Install('/fake/test/app.apk', reinstall=True)): |
503 self.device.Install('/fake/test/app.apk', reinstall=True, retries=0) | 552 self.device.Install('/fake/test/app.apk', reinstall=True, retries=0) |
504 | 553 |
505 def testInstall_identicalPriorInstall(self): | 554 def testInstall_identicalPriorInstall(self): |
506 with self.assertCalls( | 555 with self.assertCalls( |
507 (mock.call.pylib.utils.apk_helper.GetPackageName('/fake/test/app.apk'), | 556 (mock.call.pylib.utils.apk_helper.GetPackageName('/fake/test/app.apk'), |
508 'this.is.a.test.package'), | 557 'this.is.a.test.package'), |
509 (self.call.device.GetApplicationPath('this.is.a.test.package'), | 558 (self.call.device.GetApplicationPaths('this.is.a.test.package'), |
510 '/fake/data/app/this.is.a.test.package.apk'), | 559 ['/fake/data/app/this.is.a.test.package.apk']), |
511 (self.call.device._GetChangedFilesImpl( | 560 (self.call.device._GetChangedAndStaleFiles( |
512 '/fake/test/app.apk', '/fake/data/app/this.is.a.test.package.apk'), | 561 '/fake/test/app.apk', '/fake/data/app/this.is.a.test.package.apk'), |
513 [])): | 562 ([], []))): |
514 self.device.Install('/fake/test/app.apk', retries=0) | 563 self.device.Install('/fake/test/app.apk', retries=0) |
515 | 564 |
516 def testInstall_fails(self): | 565 def testInstall_fails(self): |
517 with self.assertCalls( | 566 with self.assertCalls( |
518 (mock.call.pylib.utils.apk_helper.GetPackageName('/fake/test/app.apk'), | 567 (mock.call.pylib.utils.apk_helper.GetPackageName('/fake/test/app.apk'), |
519 'this.is.a.test.package'), | 568 'this.is.a.test.package'), |
520 (self.call.device.GetApplicationPath('this.is.a.test.package'), None), | 569 (self.call.device.GetApplicationPaths('this.is.a.test.package'), []), |
521 (self.call.adb.Install('/fake/test/app.apk', reinstall=False), | 570 (self.call.adb.Install('/fake/test/app.apk', reinstall=False), |
522 self.CommandError('Failure\r\n'))): | 571 self.CommandError('Failure\r\n'))): |
523 with self.assertRaises(device_errors.CommandFailedError): | 572 with self.assertRaises(device_errors.CommandFailedError): |
524 self.device.Install('/fake/test/app.apk', retries=0) | 573 self.device.Install('/fake/test/app.apk', retries=0) |
525 | 574 |
| 575 class DeviceUtilsInstallSplitApkTest(DeviceUtilsTest): |
| 576 |
| 577 def testInstallSplitApk_noPriorInstall(self): |
| 578 with self.assertCalls( |
| 579 (self.call.device._CheckSdkLevel(21)), |
| 580 (mock.call.pylib.sdk.split_select.SelectSplits( |
| 581 self.device, 'base.apk', |
| 582 ['split1.apk', 'split2.apk', 'split3.apk']), |
| 583 ['split2.apk']), |
| 584 (mock.call.pylib.utils.apk_helper.GetPackageName('base.apk'), |
| 585 'this.is.a.test.package'), |
| 586 (self.call.device.GetApplicationPaths('this.is.a.test.package'), []), |
| 587 (self.call.adb.InstallMultiple( |
| 588 ['base.apk', 'split2.apk'], partial=None, reinstall=False))): |
| 589 self.device.InstallSplitApk('base.apk', |
| 590 ['split1.apk', 'split2.apk', 'split3.apk'], retries=0) |
| 591 |
| 592 def testInstallSplitApk_partialInstall(self): |
| 593 with self.assertCalls( |
| 594 (self.call.device._CheckSdkLevel(21)), |
| 595 (mock.call.pylib.sdk.split_select.SelectSplits( |
| 596 self.device, 'base.apk', |
| 597 ['split1.apk', 'split2.apk', 'split3.apk']), |
| 598 ['split2.apk']), |
| 599 (mock.call.pylib.utils.apk_helper.GetPackageName('base.apk'), |
| 600 'test.package'), |
| 601 (self.call.device.GetApplicationPaths('test.package'), |
| 602 ['base-on-device.apk', 'split2-on-device.apk']), |
| 603 (mock.call.pylib.utils.md5sum.CalculateDeviceMd5Sums( |
| 604 ['base-on-device.apk', 'split2-on-device.apk'], self.device), |
| 605 {'base-on-device.apk': 'AAA', 'split2-on-device.apk': 'BBB'}), |
| 606 (mock.call.pylib.utils.md5sum.CalculateHostMd5Sums( |
| 607 ['base.apk', 'split2.apk']), |
| 608 {'base.apk': 'AAA', 'split2.apk': 'CCC'}), |
| 609 (self.call.adb.InstallMultiple( |
| 610 ['split2.apk'], partial='test.package', reinstall=True))): |
| 611 self.device.InstallSplitApk('base.apk', |
| 612 ['split1.apk', 'split2.apk', 'split3.apk'], reinstall=True, retries=0) |
| 613 |
526 | 614 |
527 class DeviceUtilsRunShellCommandTest(DeviceUtilsTest): | 615 class DeviceUtilsRunShellCommandTest(DeviceUtilsTest): |
528 | 616 |
529 def setUp(self): | 617 def setUp(self): |
530 super(DeviceUtilsRunShellCommandTest, self).setUp() | 618 super(DeviceUtilsRunShellCommandTest, self).setUp() |
531 self.device.NeedsSU = mock.Mock(return_value=False) | 619 self.device.NeedsSU = mock.Mock(return_value=False) |
532 | 620 |
533 def testRunShellCommand_commandAsList(self): | 621 def testRunShellCommand_commandAsList(self): |
534 with self.assertCall(self.call.adb.Shell('pm list packages'), ''): | 622 with self.assertCall(self.call.adb.Shell('pm list packages'), ''): |
535 self.device.RunShellCommand(['pm', 'list', 'packages']) | 623 self.device.RunShellCommand(['pm', 'list', 'packages']) |
(...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
938 'Starting: Intent { act=android.intent.action.VIEW }'): | 1026 'Starting: Intent { act=android.intent.action.VIEW }'): |
939 self.device.StartActivity(test_intent) | 1027 self.device.StartActivity(test_intent) |
940 | 1028 |
941 | 1029 |
942 class DeviceUtilsStartInstrumentationTest(DeviceUtilsTest): | 1030 class DeviceUtilsStartInstrumentationTest(DeviceUtilsTest): |
943 | 1031 |
944 def testStartInstrumentation_nothing(self): | 1032 def testStartInstrumentation_nothing(self): |
945 with self.assertCalls( | 1033 with self.assertCalls( |
946 self.call.device.RunShellCommand( | 1034 self.call.device.RunShellCommand( |
947 ['am', 'instrument', 'test.package/.TestInstrumentation'], | 1035 ['am', 'instrument', 'test.package/.TestInstrumentation'], |
948 check_return=True)): | 1036 check_return=True, large_output=True)): |
949 self.device.StartInstrumentation( | 1037 self.device.StartInstrumentation( |
950 'test.package/.TestInstrumentation', | 1038 'test.package/.TestInstrumentation', |
951 finish=False, raw=False, extras=None) | 1039 finish=False, raw=False, extras=None) |
952 | 1040 |
953 def testStartInstrumentation_finish(self): | 1041 def testStartInstrumentation_finish(self): |
954 with self.assertCalls( | 1042 with self.assertCalls( |
955 (self.call.device.RunShellCommand( | 1043 (self.call.device.RunShellCommand( |
956 ['am', 'instrument', '-w', 'test.package/.TestInstrumentation'], | 1044 ['am', 'instrument', '-w', 'test.package/.TestInstrumentation'], |
957 check_return=True), | 1045 check_return=True, large_output=True), |
958 ['OK (1 test)'])): | 1046 ['OK (1 test)'])): |
959 output = self.device.StartInstrumentation( | 1047 output = self.device.StartInstrumentation( |
960 'test.package/.TestInstrumentation', | 1048 'test.package/.TestInstrumentation', |
961 finish=True, raw=False, extras=None) | 1049 finish=True, raw=False, extras=None) |
962 self.assertEquals(['OK (1 test)'], output) | 1050 self.assertEquals(['OK (1 test)'], output) |
963 | 1051 |
964 def testStartInstrumentation_raw(self): | 1052 def testStartInstrumentation_raw(self): |
965 with self.assertCalls( | 1053 with self.assertCalls( |
966 self.call.device.RunShellCommand( | 1054 self.call.device.RunShellCommand( |
967 ['am', 'instrument', '-r', 'test.package/.TestInstrumentation'], | 1055 ['am', 'instrument', '-r', 'test.package/.TestInstrumentation'], |
968 check_return=True)): | 1056 check_return=True, large_output=True)): |
969 self.device.StartInstrumentation( | 1057 self.device.StartInstrumentation( |
970 'test.package/.TestInstrumentation', | 1058 'test.package/.TestInstrumentation', |
971 finish=False, raw=True, extras=None) | 1059 finish=False, raw=True, extras=None) |
972 | 1060 |
973 def testStartInstrumentation_extras(self): | 1061 def testStartInstrumentation_extras(self): |
974 with self.assertCalls( | 1062 with self.assertCalls( |
975 self.call.device.RunShellCommand( | 1063 self.call.device.RunShellCommand( |
976 ['am', 'instrument', '-e', 'foo', 'Foo', '-e', 'bar', 'Bar', | 1064 ['am', 'instrument', '-e', 'foo', 'Foo', '-e', 'bar', 'Bar', |
977 'test.package/.TestInstrumentation'], | 1065 'test.package/.TestInstrumentation'], |
978 check_return=True)): | 1066 check_return=True, large_output=True)): |
979 self.device.StartInstrumentation( | 1067 self.device.StartInstrumentation( |
980 'test.package/.TestInstrumentation', | 1068 'test.package/.TestInstrumentation', |
981 finish=False, raw=False, extras={'foo': 'Foo', 'bar': 'Bar'}) | 1069 finish=False, raw=False, extras={'foo': 'Foo', 'bar': 'Bar'}) |
982 | 1070 |
983 | 1071 |
984 class DeviceUtilsBroadcastIntentTest(DeviceUtilsTest): | 1072 class DeviceUtilsBroadcastIntentTest(DeviceUtilsTest): |
985 | 1073 |
986 def testBroadcastIntent_noExtras(self): | 1074 def testBroadcastIntent_noExtras(self): |
987 test_intent = intent.Intent(action='test.package.with.an.INTENT') | 1075 test_intent = intent.Intent(action='test.package.with.an.INTENT') |
988 with self.assertCall( | 1076 with self.assertCall( |
(...skipping 15 matching lines...) Expand all Loading... |
1004 extras={'foo': None}) | 1092 extras={'foo': None}) |
1005 with self.assertCall( | 1093 with self.assertCall( |
1006 self.call.adb.Shell( | 1094 self.call.adb.Shell( |
1007 'am broadcast -a test.package.with.an.INTENT --esn foo'), | 1095 'am broadcast -a test.package.with.an.INTENT --esn foo'), |
1008 'Broadcasting: Intent { act=test.package.with.an.INTENT } '): | 1096 'Broadcasting: Intent { act=test.package.with.an.INTENT } '): |
1009 self.device.BroadcastIntent(test_intent) | 1097 self.device.BroadcastIntent(test_intent) |
1010 | 1098 |
1011 | 1099 |
1012 class DeviceUtilsGoHomeTest(DeviceUtilsTest): | 1100 class DeviceUtilsGoHomeTest(DeviceUtilsTest): |
1013 | 1101 |
1014 def testGoHome(self): | 1102 def testGoHome_popupsExist(self): |
1015 with self.assertCall( | 1103 with self.assertCalls( |
1016 self.call.adb.Shell('am start -W -a android.intent.action.MAIN ' | 1104 (self.call.device.RunShellCommand( |
1017 '-c android.intent.category.HOME'), | 1105 ['dumpsys', 'window', 'windows'], check_return=True, |
1018 'Starting: Intent { act=android.intent.action.MAIN }\r\n'): | 1106 large_output=True), []), |
| 1107 (self.call.device.RunShellCommand( |
| 1108 ['am', 'start', '-W', '-a', 'android.intent.action.MAIN', |
| 1109 '-c', 'android.intent.category.HOME'], check_return=True), |
| 1110 'Starting: Intent { act=android.intent.action.MAIN }\r\n'''), |
| 1111 (self.call.device.RunShellCommand( |
| 1112 ['dumpsys', 'window', 'windows'], check_return=True, |
| 1113 large_output=True), []), |
| 1114 (self.call.device.RunShellCommand( |
| 1115 ['input', 'keyevent', '66'], check_return=True)), |
| 1116 (self.call.device.RunShellCommand( |
| 1117 ['input', 'keyevent', '4'], check_return=True)), |
| 1118 (self.call.device.RunShellCommand( |
| 1119 ['dumpsys', 'window', 'windows'], check_return=True, |
| 1120 large_output=True), |
| 1121 ['mCurrentFocus Launcher'])): |
1019 self.device.GoHome() | 1122 self.device.GoHome() |
1020 | 1123 |
| 1124 def testGoHome_willRetry(self): |
| 1125 with self.assertCalls( |
| 1126 (self.call.device.RunShellCommand( |
| 1127 ['dumpsys', 'window', 'windows'], check_return=True, |
| 1128 large_output=True), []), |
| 1129 (self.call.device.RunShellCommand( |
| 1130 ['am', 'start', '-W', '-a', 'android.intent.action.MAIN', |
| 1131 '-c', 'android.intent.category.HOME'], check_return=True), |
| 1132 'Starting: Intent { act=android.intent.action.MAIN }\r\n'''), |
| 1133 (self.call.device.RunShellCommand( |
| 1134 ['dumpsys', 'window', 'windows'], check_return=True, |
| 1135 large_output=True), []), |
| 1136 (self.call.device.RunShellCommand( |
| 1137 ['input', 'keyevent', '66'], check_return=True,)), |
| 1138 (self.call.device.RunShellCommand( |
| 1139 ['input', 'keyevent', '4'], check_return=True)), |
| 1140 (self.call.device.RunShellCommand( |
| 1141 ['dumpsys', 'window', 'windows'], check_return=True, |
| 1142 large_output=True), []), |
| 1143 (self.call.device.RunShellCommand( |
| 1144 ['input', 'keyevent', '66'], check_return=True)), |
| 1145 (self.call.device.RunShellCommand( |
| 1146 ['input', 'keyevent', '4'], check_return=True)), |
| 1147 (self.call.device.RunShellCommand( |
| 1148 ['dumpsys', 'window', 'windows'], check_return=True, |
| 1149 large_output=True), |
| 1150 self.TimeoutError())): |
| 1151 with self.assertRaises(device_errors.CommandTimeoutError): |
| 1152 self.device.GoHome() |
| 1153 |
| 1154 def testGoHome_alreadyFocused(self): |
| 1155 with self.assertCall( |
| 1156 self.call.device.RunShellCommand( |
| 1157 ['dumpsys', 'window', 'windows'], check_return=True, |
| 1158 large_output=True), |
| 1159 ['mCurrentFocus Launcher']): |
| 1160 self.device.GoHome() |
| 1161 |
| 1162 def testGoHome_alreadyFocusedAlternateCase(self): |
| 1163 with self.assertCall( |
| 1164 self.call.device.RunShellCommand( |
| 1165 ['dumpsys', 'window', 'windows'], check_return=True, |
| 1166 large_output=True), |
| 1167 [' mCurrentFocus .launcher/.']): |
| 1168 self.device.GoHome() |
| 1169 |
| 1170 def testGoHome_obtainsFocusAfterGoingHome(self): |
| 1171 with self.assertCalls( |
| 1172 (self.call.device.RunShellCommand( |
| 1173 ['dumpsys', 'window', 'windows'], check_return=True, |
| 1174 large_output=True), []), |
| 1175 (self.call.device.RunShellCommand( |
| 1176 ['am', 'start', '-W', '-a', 'android.intent.action.MAIN', |
| 1177 '-c', 'android.intent.category.HOME'], check_return=True), |
| 1178 'Starting: Intent { act=android.intent.action.MAIN }\r\n'''), |
| 1179 (self.call.device.RunShellCommand( |
| 1180 ['dumpsys', 'window', 'windows'], check_return=True, |
| 1181 large_output=True), |
| 1182 ['mCurrentFocus Launcher'])): |
| 1183 self.device.GoHome() |
1021 | 1184 |
1022 class DeviceUtilsForceStopTest(DeviceUtilsTest): | 1185 class DeviceUtilsForceStopTest(DeviceUtilsTest): |
1023 | 1186 |
1024 def testForceStop(self): | 1187 def testForceStop(self): |
1025 with self.assertCall( | 1188 with self.assertCall( |
1026 self.call.adb.Shell('am force-stop this.is.a.test.package'), | 1189 self.call.adb.Shell('am force-stop this.is.a.test.package'), |
1027 ''): | 1190 ''): |
1028 self.device.ForceStop('this.is.a.test.package') | 1191 self.device.ForceStop('this.is.a.test.package') |
1029 | 1192 |
1030 | 1193 |
1031 class DeviceUtilsClearApplicationStateTest(DeviceUtilsTest): | 1194 class DeviceUtilsClearApplicationStateTest(DeviceUtilsTest): |
1032 | 1195 |
1033 def testClearApplicationState_packageDoesntExist(self): | 1196 def testClearApplicationState_packageDoesntExist(self): |
1034 with self.assertCalls( | 1197 with self.assertCalls( |
1035 (self.call.adb.Shell('getprop ro.build.version.sdk'), '17\n'), | 1198 (self.call.adb.Shell('getprop ro.build.version.sdk'), '17\n'), |
1036 (self.call.device.GetApplicationPath('this.package.does.not.exist'), | 1199 (self.call.device.GetApplicationPaths('this.package.does.not.exist'), |
1037 None)): | 1200 [])): |
1038 self.device.ClearApplicationState('this.package.does.not.exist') | 1201 self.device.ClearApplicationState('this.package.does.not.exist') |
1039 | 1202 |
1040 def testClearApplicationState_packageDoesntExistOnAndroidJBMR2OrAbove(self): | 1203 def testClearApplicationState_packageDoesntExistOnAndroidJBMR2OrAbove(self): |
1041 with self.assertCalls( | 1204 with self.assertCalls( |
1042 (self.call.adb.Shell('getprop ro.build.version.sdk'), '18\n'), | 1205 (self.call.adb.Shell('getprop ro.build.version.sdk'), '18\n'), |
1043 (self.call.adb.Shell('pm clear this.package.does.not.exist'), | 1206 (self.call.adb.Shell('pm clear this.package.does.not.exist'), |
1044 'Failed\r\n')): | 1207 'Failed\r\n')): |
1045 self.device.ClearApplicationState('this.package.does.not.exist') | 1208 self.device.ClearApplicationState('this.package.does.not.exist') |
1046 | 1209 |
1047 def testClearApplicationState_packageExists(self): | 1210 def testClearApplicationState_packageExists(self): |
1048 with self.assertCalls( | 1211 with self.assertCalls( |
1049 (self.call.adb.Shell('getprop ro.build.version.sdk'), '17\n'), | 1212 (self.call.adb.Shell('getprop ro.build.version.sdk'), '17\n'), |
1050 (self.call.device.GetApplicationPath('this.package.exists'), | 1213 (self.call.device.GetApplicationPaths('this.package.exists'), |
1051 '/data/app/this.package.exists.apk'), | 1214 ['/data/app/this.package.exists.apk']), |
1052 (self.call.adb.Shell('pm clear this.package.exists'), | 1215 (self.call.adb.Shell('pm clear this.package.exists'), |
1053 'Success\r\n')): | 1216 'Success\r\n')): |
1054 self.device.ClearApplicationState('this.package.exists') | 1217 self.device.ClearApplicationState('this.package.exists') |
1055 | 1218 |
1056 def testClearApplicationState_packageExistsOnAndroidJBMR2OrAbove(self): | 1219 def testClearApplicationState_packageExistsOnAndroidJBMR2OrAbove(self): |
1057 with self.assertCalls( | 1220 with self.assertCalls( |
1058 (self.call.adb.Shell('getprop ro.build.version.sdk'), '18\n'), | 1221 (self.call.adb.Shell('getprop ro.build.version.sdk'), '18\n'), |
1059 (self.call.adb.Shell('pm clear this.package.exists'), | 1222 (self.call.adb.Shell('pm clear this.package.exists'), |
1060 'Success\r\n')): | 1223 'Success\r\n')): |
1061 self.device.ClearApplicationState('this.package.exists') | 1224 self.device.ClearApplicationState('this.package.exists') |
(...skipping 611 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1673 devices = device_utils.DeviceUtils.HealthyDevices() | 1836 devices = device_utils.DeviceUtils.HealthyDevices() |
1674 self.assertEquals(1, len(devices)) | 1837 self.assertEquals(1, len(devices)) |
1675 self.assertTrue(isinstance(devices[0], device_utils.DeviceUtils)) | 1838 self.assertTrue(isinstance(devices[0], device_utils.DeviceUtils)) |
1676 self.assertEquals('0123456789abcdef', devices[0].adb.GetDeviceSerial()) | 1839 self.assertEquals('0123456789abcdef', devices[0].adb.GetDeviceSerial()) |
1677 | 1840 |
1678 | 1841 |
1679 if __name__ == '__main__': | 1842 if __name__ == '__main__': |
1680 logging.getLogger().setLevel(logging.DEBUG) | 1843 logging.getLogger().setLevel(logging.DEBUG) |
1681 unittest.main(verbosity=2) | 1844 unittest.main(verbosity=2) |
1682 | 1845 |
OLD | NEW |