| 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 |
| (...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 304 self.call.adb.Shell('echo $EXTERNAL_STORAGE'), '/fake/storage/path\n'): | 304 self.call.adb.Shell('echo $EXTERNAL_STORAGE'), '/fake/storage/path\n'): |
| 305 self.assertEquals('/fake/storage/path', | 305 self.assertEquals('/fake/storage/path', |
| 306 self.device.GetExternalStoragePath()) | 306 self.device.GetExternalStoragePath()) |
| 307 | 307 |
| 308 def testGetExternalStoragePath_fails(self): | 308 def testGetExternalStoragePath_fails(self): |
| 309 with self.assertCall(self.call.adb.Shell('echo $EXTERNAL_STORAGE'), '\n'): | 309 with self.assertCall(self.call.adb.Shell('echo $EXTERNAL_STORAGE'), '\n'): |
| 310 with self.assertRaises(device_errors.CommandFailedError): | 310 with self.assertRaises(device_errors.CommandFailedError): |
| 311 self.device.GetExternalStoragePath() | 311 self.device.GetExternalStoragePath() |
| 312 | 312 |
| 313 | 313 |
| 314 class DeviceUtilsGetApplicationPathsTest(DeviceUtilsTest): | 314 class DeviceUtils_GetApplicationPathsInternalTest(DeviceUtilsTest): |
| 315 | 315 |
| 316 def testGetApplicationPaths_exists(self): | 316 def test_GetApplicationPathsInternal_exists(self): |
| 317 with self.assertCalls( | 317 with self.assertCalls( |
| 318 (self.call.adb.Shell('getprop ro.build.version.sdk'), '19\n'), | 318 (self.call.adb.Shell('getprop ro.build.version.sdk'), '19\n'), |
| 319 (self.call.adb.Shell('pm path android'), | 319 (self.call.adb.Shell('pm path android'), |
| 320 'package:/path/to/android.apk\n')): | 320 'package:/path/to/android.apk\n')): |
| 321 self.assertEquals(['/path/to/android.apk'], | 321 self.assertEquals(['/path/to/android.apk'], |
| 322 self.device.GetApplicationPaths('android')) | 322 self.device._GetApplicationPathsInternal('android')) |
| 323 | 323 |
| 324 def testGetApplicationPaths_notExists(self): | 324 def test_GetApplicationPathsInternal_notExists(self): |
| 325 with self.assertCalls( | 325 with self.assertCalls( |
| 326 (self.call.adb.Shell('getprop ro.build.version.sdk'), '19\n'), | 326 (self.call.adb.Shell('getprop ro.build.version.sdk'), '19\n'), |
| 327 (self.call.adb.Shell('pm path not.installed.app'), '')): | 327 (self.call.adb.Shell('pm path not.installed.app'), '')): |
| 328 self.assertEquals([], | 328 self.assertEquals([], |
| 329 self.device.GetApplicationPaths('not.installed.app')) | 329 self.device._GetApplicationPathsInternal('not.installed.app')) |
| 330 | 330 |
| 331 def testGetApplicationPaths_fails(self): | 331 def test_GetApplicationPathsInternal_fails(self): |
| 332 with self.assertCalls( | 332 with self.assertCalls( |
| 333 (self.call.adb.Shell('getprop ro.build.version.sdk'), '19\n'), | 333 (self.call.adb.Shell('getprop ro.build.version.sdk'), '19\n'), |
| 334 (self.call.adb.Shell('pm path android'), | 334 (self.call.adb.Shell('pm path android'), |
| 335 self.CommandError('ERROR. Is package manager running?\n'))): | 335 self.CommandError('ERROR. Is package manager running?\n'))): |
| 336 with self.assertRaises(device_errors.CommandFailedError): | 336 with self.assertRaises(device_errors.CommandFailedError): |
| 337 self.device.GetApplicationPaths('android') | 337 self.device._GetApplicationPathsInternal('android') |
| 338 | 338 |
| 339 | 339 |
| 340 class DeviceUtilsGetApplicationDataDirectoryTest(DeviceUtilsTest): | 340 class DeviceUtilsGetApplicationDataDirectoryTest(DeviceUtilsTest): |
| 341 | 341 |
| 342 def testGetApplicationDataDirectory_exists(self): | 342 def testGetApplicationDataDirectory_exists(self): |
| 343 with self.assertCall( | 343 with self.assertCall( |
| 344 self.call.device._RunPipedShellCommand( | 344 self.call.device._RunPipedShellCommand( |
| 345 'pm dump foo.bar.baz | grep dataDir='), | 345 'pm dump foo.bar.baz | grep dataDir='), |
| 346 ['dataDir=/data/data/foo.bar.baz']): | 346 ['dataDir=/data/data/foo.bar.baz']): |
| 347 self.assertEquals( | 347 self.assertEquals( |
| (...skipping 11 matching lines...) Expand all Loading... |
| 359 @mock.patch('time.sleep', mock.Mock()) | 359 @mock.patch('time.sleep', mock.Mock()) |
| 360 class DeviceUtilsWaitUntilFullyBootedTest(DeviceUtilsTest): | 360 class DeviceUtilsWaitUntilFullyBootedTest(DeviceUtilsTest): |
| 361 | 361 |
| 362 def testWaitUntilFullyBooted_succeedsNoWifi(self): | 362 def testWaitUntilFullyBooted_succeedsNoWifi(self): |
| 363 with self.assertCalls( | 363 with self.assertCalls( |
| 364 self.call.adb.WaitForDevice(), | 364 self.call.adb.WaitForDevice(), |
| 365 # sd_card_ready | 365 # sd_card_ready |
| 366 (self.call.device.GetExternalStoragePath(), '/fake/storage/path'), | 366 (self.call.device.GetExternalStoragePath(), '/fake/storage/path'), |
| 367 (self.call.adb.Shell('test -d /fake/storage/path'), ''), | 367 (self.call.adb.Shell('test -d /fake/storage/path'), ''), |
| 368 # pm_ready | 368 # pm_ready |
| 369 (self.call.device.GetApplicationPaths('android'), | 369 (self.call.device._GetApplicationPathsInternal('android', |
| 370 skip_cache=True), |
| 370 ['package:/some/fake/path']), | 371 ['package:/some/fake/path']), |
| 371 # boot_completed | 372 # boot_completed |
| 372 (self.call.device.GetProp('sys.boot_completed'), '1')): | 373 (self.call.device.GetProp('sys.boot_completed'), '1')): |
| 373 self.device.WaitUntilFullyBooted(wifi=False) | 374 self.device.WaitUntilFullyBooted(wifi=False) |
| 374 | 375 |
| 375 def testWaitUntilFullyBooted_succeedsWithWifi(self): | 376 def testWaitUntilFullyBooted_succeedsWithWifi(self): |
| 376 with self.assertCalls( | 377 with self.assertCalls( |
| 377 self.call.adb.WaitForDevice(), | 378 self.call.adb.WaitForDevice(), |
| 378 # sd_card_ready | 379 # sd_card_ready |
| 379 (self.call.device.GetExternalStoragePath(), '/fake/storage/path'), | 380 (self.call.device.GetExternalStoragePath(), '/fake/storage/path'), |
| 380 (self.call.adb.Shell('test -d /fake/storage/path'), ''), | 381 (self.call.adb.Shell('test -d /fake/storage/path'), ''), |
| 381 # pm_ready | 382 # pm_ready |
| 382 (self.call.device.GetApplicationPaths('android'), | 383 (self.call.device._GetApplicationPathsInternal('android', |
| 384 skip_cache=True), |
| 383 ['package:/some/fake/path']), | 385 ['package:/some/fake/path']), |
| 384 # boot_completed | 386 # boot_completed |
| 385 (self.call.device.GetProp('sys.boot_completed'), '1'), | 387 (self.call.device.GetProp('sys.boot_completed'), '1'), |
| 386 # wifi_enabled | 388 # wifi_enabled |
| 387 (self.call.adb.Shell('dumpsys wifi'), | 389 (self.call.adb.Shell('dumpsys wifi'), |
| 388 'stuff\nWi-Fi is enabled\nmore stuff\n')): | 390 'stuff\nWi-Fi is enabled\nmore stuff\n')): |
| 389 self.device.WaitUntilFullyBooted(wifi=True) | 391 self.device.WaitUntilFullyBooted(wifi=True) |
| 390 | 392 |
| 391 def testWaitUntilFullyBooted_deviceNotInitiallyAvailable(self): | 393 def testWaitUntilFullyBooted_deviceNotInitiallyAvailable(self): |
| 392 with self.assertCalls( | 394 with self.assertCalls( |
| 393 self.call.adb.WaitForDevice(), | 395 self.call.adb.WaitForDevice(), |
| 394 # sd_card_ready | 396 # sd_card_ready |
| 395 (self.call.device.GetExternalStoragePath(), self.AdbCommandError()), | 397 (self.call.device.GetExternalStoragePath(), self.AdbCommandError()), |
| 396 # sd_card_ready | 398 # sd_card_ready |
| 397 (self.call.device.GetExternalStoragePath(), self.AdbCommandError()), | 399 (self.call.device.GetExternalStoragePath(), self.AdbCommandError()), |
| 398 # sd_card_ready | 400 # sd_card_ready |
| 399 (self.call.device.GetExternalStoragePath(), self.AdbCommandError()), | 401 (self.call.device.GetExternalStoragePath(), self.AdbCommandError()), |
| 400 # sd_card_ready | 402 # sd_card_ready |
| 401 (self.call.device.GetExternalStoragePath(), self.AdbCommandError()), | 403 (self.call.device.GetExternalStoragePath(), self.AdbCommandError()), |
| 402 # sd_card_ready | 404 # sd_card_ready |
| 403 (self.call.device.GetExternalStoragePath(), '/fake/storage/path'), | 405 (self.call.device.GetExternalStoragePath(), '/fake/storage/path'), |
| 404 (self.call.adb.Shell('test -d /fake/storage/path'), ''), | 406 (self.call.adb.Shell('test -d /fake/storage/path'), ''), |
| 405 # pm_ready | 407 # pm_ready |
| 406 (self.call.device.GetApplicationPaths('android'), | 408 (self.call.device._GetApplicationPathsInternal('android', |
| 409 skip_cache=True), |
| 407 ['package:/some/fake/path']), | 410 ['package:/some/fake/path']), |
| 408 # boot_completed | 411 # boot_completed |
| 409 (self.call.device.GetProp('sys.boot_completed'), '1')): | 412 (self.call.device.GetProp('sys.boot_completed'), '1')): |
| 410 self.device.WaitUntilFullyBooted(wifi=False) | 413 self.device.WaitUntilFullyBooted(wifi=False) |
| 411 | 414 |
| 412 def testWaitUntilFullyBooted_sdCardReadyFails_noPath(self): | 415 def testWaitUntilFullyBooted_sdCardReadyFails_noPath(self): |
| 413 with self.assertCalls( | 416 with self.assertCalls( |
| 414 self.call.adb.WaitForDevice(), | 417 self.call.adb.WaitForDevice(), |
| 415 # sd_card_ready | 418 # sd_card_ready |
| 416 (self.call.device.GetExternalStoragePath(), self.CommandError())): | 419 (self.call.device.GetExternalStoragePath(), self.CommandError())): |
| (...skipping 16 matching lines...) Expand all Loading... |
| 433 with self.assertRaises(device_errors.CommandTimeoutError): | 436 with self.assertRaises(device_errors.CommandTimeoutError): |
| 434 self.device.WaitUntilFullyBooted(wifi=False) | 437 self.device.WaitUntilFullyBooted(wifi=False) |
| 435 | 438 |
| 436 def testWaitUntilFullyBooted_devicePmFails(self): | 439 def testWaitUntilFullyBooted_devicePmFails(self): |
| 437 with self.assertCalls( | 440 with self.assertCalls( |
| 438 self.call.adb.WaitForDevice(), | 441 self.call.adb.WaitForDevice(), |
| 439 # sd_card_ready | 442 # sd_card_ready |
| 440 (self.call.device.GetExternalStoragePath(), '/fake/storage/path'), | 443 (self.call.device.GetExternalStoragePath(), '/fake/storage/path'), |
| 441 (self.call.adb.Shell('test -d /fake/storage/path'), ''), | 444 (self.call.adb.Shell('test -d /fake/storage/path'), ''), |
| 442 # pm_ready | 445 # pm_ready |
| 443 (self.call.device.GetApplicationPaths('android'), self.CommandError()), | 446 (self.call.device._GetApplicationPathsInternal('android', |
| 447 skip_cache=True), |
| 448 self.CommandError()), |
| 444 # pm_ready | 449 # pm_ready |
| 445 (self.call.device.GetApplicationPaths('android'), self.CommandError()), | 450 (self.call.device._GetApplicationPathsInternal('android', |
| 451 skip_cache=True), |
| 452 self.CommandError()), |
| 446 # pm_ready | 453 # pm_ready |
| 447 (self.call.device.GetApplicationPaths('android'), self.TimeoutError())): | 454 (self.call.device._GetApplicationPathsInternal('android', |
| 455 skip_cache=True), |
| 456 self.TimeoutError())): |
| 448 with self.assertRaises(device_errors.CommandTimeoutError): | 457 with self.assertRaises(device_errors.CommandTimeoutError): |
| 449 self.device.WaitUntilFullyBooted(wifi=False) | 458 self.device.WaitUntilFullyBooted(wifi=False) |
| 450 | 459 |
| 451 def testWaitUntilFullyBooted_bootFails(self): | 460 def testWaitUntilFullyBooted_bootFails(self): |
| 452 with self.assertCalls( | 461 with self.assertCalls( |
| 453 self.call.adb.WaitForDevice(), | 462 self.call.adb.WaitForDevice(), |
| 454 # sd_card_ready | 463 # sd_card_ready |
| 455 (self.call.device.GetExternalStoragePath(), '/fake/storage/path'), | 464 (self.call.device.GetExternalStoragePath(), '/fake/storage/path'), |
| 456 (self.call.adb.Shell('test -d /fake/storage/path'), ''), | 465 (self.call.adb.Shell('test -d /fake/storage/path'), ''), |
| 457 # pm_ready | 466 # pm_ready |
| 458 (self.call.device.GetApplicationPaths('android'), | 467 (self.call.device._GetApplicationPathsInternal('android', |
| 468 skip_cache=True), |
| 459 ['package:/some/fake/path']), | 469 ['package:/some/fake/path']), |
| 460 # boot_completed | 470 # boot_completed |
| 461 (self.call.device.GetProp('sys.boot_completed'), '0'), | 471 (self.call.device.GetProp('sys.boot_completed'), '0'), |
| 462 # boot_completed | 472 # boot_completed |
| 463 (self.call.device.GetProp('sys.boot_completed'), '0'), | 473 (self.call.device.GetProp('sys.boot_completed'), '0'), |
| 464 # boot_completed | 474 # boot_completed |
| 465 (self.call.device.GetProp('sys.boot_completed'), self.TimeoutError())): | 475 (self.call.device.GetProp('sys.boot_completed'), self.TimeoutError())): |
| 466 with self.assertRaises(device_errors.CommandTimeoutError): | 476 with self.assertRaises(device_errors.CommandTimeoutError): |
| 467 self.device.WaitUntilFullyBooted(wifi=False) | 477 self.device.WaitUntilFullyBooted(wifi=False) |
| 468 | 478 |
| 469 def testWaitUntilFullyBooted_wifiFails(self): | 479 def testWaitUntilFullyBooted_wifiFails(self): |
| 470 with self.assertCalls( | 480 with self.assertCalls( |
| 471 self.call.adb.WaitForDevice(), | 481 self.call.adb.WaitForDevice(), |
| 472 # sd_card_ready | 482 # sd_card_ready |
| 473 (self.call.device.GetExternalStoragePath(), '/fake/storage/path'), | 483 (self.call.device.GetExternalStoragePath(), '/fake/storage/path'), |
| 474 (self.call.adb.Shell('test -d /fake/storage/path'), ''), | 484 (self.call.adb.Shell('test -d /fake/storage/path'), ''), |
| 475 # pm_ready | 485 # pm_ready |
| 476 (self.call.device.GetApplicationPaths('android'), | 486 (self.call.device._GetApplicationPathsInternal('android', |
| 487 skip_cache=True), |
| 477 ['package:/some/fake/path']), | 488 ['package:/some/fake/path']), |
| 478 # boot_completed | 489 # boot_completed |
| 479 (self.call.device.GetProp('sys.boot_completed'), '1'), | 490 (self.call.device.GetProp('sys.boot_completed'), '1'), |
| 480 # wifi_enabled | 491 # wifi_enabled |
| 481 (self.call.adb.Shell('dumpsys wifi'), 'stuff\nmore stuff\n'), | 492 (self.call.adb.Shell('dumpsys wifi'), 'stuff\nmore stuff\n'), |
| 482 # wifi_enabled | 493 # wifi_enabled |
| 483 (self.call.adb.Shell('dumpsys wifi'), 'stuff\nmore stuff\n'), | 494 (self.call.adb.Shell('dumpsys wifi'), 'stuff\nmore stuff\n'), |
| 484 # wifi_enabled | 495 # wifi_enabled |
| 485 (self.call.adb.Shell('dumpsys wifi'), self.TimeoutError())): | 496 (self.call.adb.Shell('dumpsys wifi'), self.TimeoutError())): |
| 486 with self.assertRaises(device_errors.CommandTimeoutError): | 497 with self.assertRaises(device_errors.CommandTimeoutError): |
| (...skipping 25 matching lines...) Expand all Loading... |
| 512 (self.call.device.IsOnline(), False), | 523 (self.call.device.IsOnline(), False), |
| 513 self.call.device.WaitUntilFullyBooted(wifi=True)): | 524 self.call.device.WaitUntilFullyBooted(wifi=True)): |
| 514 self.device.Reboot(block=True, wifi=True) | 525 self.device.Reboot(block=True, wifi=True) |
| 515 | 526 |
| 516 | 527 |
| 517 class DeviceUtilsInstallTest(DeviceUtilsTest): | 528 class DeviceUtilsInstallTest(DeviceUtilsTest): |
| 518 | 529 |
| 519 def testInstall_noPriorInstall(self): | 530 def testInstall_noPriorInstall(self): |
| 520 with self.assertCalls( | 531 with self.assertCalls( |
| 521 (mock.call.pylib.utils.apk_helper.GetPackageName('/fake/test/app.apk'), | 532 (mock.call.pylib.utils.apk_helper.GetPackageName('/fake/test/app.apk'), |
| 522 'this.is.a.test.package'), | 533 'test.package'), |
| 523 (self.call.device.GetApplicationPaths('this.is.a.test.package'), []), | 534 (self.call.device._GetApplicationPathsInternal('test.package'), []), |
| 524 self.call.adb.Install('/fake/test/app.apk', reinstall=False)): | 535 self.call.adb.Install('/fake/test/app.apk', reinstall=False)): |
| 525 self.device.Install('/fake/test/app.apk', retries=0) | 536 self.device.Install('/fake/test/app.apk', retries=0) |
| 526 | 537 |
| 527 def testInstall_differentPriorInstall(self): | 538 def testInstall_differentPriorInstall(self): |
| 528 with self.assertCalls( | 539 with self.assertCalls( |
| 529 (mock.call.pylib.utils.apk_helper.GetPackageName('/fake/test/app.apk'), | 540 (mock.call.pylib.utils.apk_helper.GetPackageName('/fake/test/app.apk'), |
| 530 'this.is.a.test.package'), | 541 'test.package'), |
| 531 (self.call.device.GetApplicationPaths('this.is.a.test.package'), | 542 (self.call.device._GetApplicationPathsInternal('test.package'), |
| 532 ['/fake/data/app/this.is.a.test.package.apk']), | 543 ['/fake/data/app/test.package.apk']), |
| 533 (self.call.device._GetChangedAndStaleFiles( | 544 (self.call.device._ComputeStaleApks('test.package', |
| 534 '/fake/test/app.apk', '/fake/data/app/this.is.a.test.package.apk'), | 545 ['/fake/test/app.apk']), |
| 535 ([('/fake/test/app.apk', '/fake/data/app/this.is.a.test.package.apk')], | 546 (['/fake/test/app.apk'], None)), |
| 536 [])), | 547 self.call.adb.Uninstall('test.package'), |
| 537 self.call.adb.Uninstall('this.is.a.test.package'), | |
| 538 self.call.adb.Install('/fake/test/app.apk', reinstall=False)): | 548 self.call.adb.Install('/fake/test/app.apk', reinstall=False)): |
| 539 self.device.Install('/fake/test/app.apk', retries=0) | 549 self.device.Install('/fake/test/app.apk', retries=0) |
| 540 | 550 |
| 541 def testInstall_differentPriorInstall_reinstall(self): | 551 def testInstall_differentPriorInstall_reinstall(self): |
| 542 with self.assertCalls( | 552 with self.assertCalls( |
| 543 (mock.call.pylib.utils.apk_helper.GetPackageName('/fake/test/app.apk'), | 553 (mock.call.pylib.utils.apk_helper.GetPackageName('/fake/test/app.apk'), |
| 544 'this.is.a.test.package'), | 554 'test.package'), |
| 545 (self.call.device.GetApplicationPaths('this.is.a.test.package'), | 555 (self.call.device._GetApplicationPathsInternal('test.package'), |
| 546 ['/fake/data/app/this.is.a.test.package.apk']), | 556 ['/fake/data/app/test.package.apk']), |
| 547 (self.call.device._GetChangedAndStaleFiles( | 557 (self.call.device._ComputeStaleApks('test.package', |
| 548 '/fake/test/app.apk', '/fake/data/app/this.is.a.test.package.apk'), | 558 ['/fake/test/app.apk']), |
| 549 ([('/fake/test/app.apk', '/fake/data/app/this.is.a.test.package.apk')], | 559 (['/fake/test/app.apk'], None)), |
| 550 [])), | |
| 551 self.call.adb.Install('/fake/test/app.apk', reinstall=True)): | 560 self.call.adb.Install('/fake/test/app.apk', reinstall=True)): |
| 552 self.device.Install('/fake/test/app.apk', reinstall=True, retries=0) | 561 self.device.Install('/fake/test/app.apk', reinstall=True, retries=0) |
| 553 | 562 |
| 554 def testInstall_identicalPriorInstall(self): | 563 def testInstall_identicalPriorInstall(self): |
| 555 with self.assertCalls( | 564 with self.assertCalls( |
| 556 (mock.call.pylib.utils.apk_helper.GetPackageName('/fake/test/app.apk'), | 565 (mock.call.pylib.utils.apk_helper.GetPackageName('/fake/test/app.apk'), |
| 557 'this.is.a.test.package'), | 566 'test.package'), |
| 558 (self.call.device.GetApplicationPaths('this.is.a.test.package'), | 567 (self.call.device._GetApplicationPathsInternal('test.package'), |
| 559 ['/fake/data/app/this.is.a.test.package.apk']), | 568 ['/fake/data/app/test.package.apk']), |
| 560 (self.call.device._GetChangedAndStaleFiles( | 569 (self.call.device._ComputeStaleApks('test.package', |
| 561 '/fake/test/app.apk', '/fake/data/app/this.is.a.test.package.apk'), | 570 ['/fake/test/app.apk']), |
| 562 ([], []))): | 571 ([], None))): |
| 563 self.device.Install('/fake/test/app.apk', retries=0) | 572 self.device.Install('/fake/test/app.apk', retries=0) |
| 564 | 573 |
| 565 def testInstall_fails(self): | 574 def testInstall_fails(self): |
| 566 with self.assertCalls( | 575 with self.assertCalls( |
| 567 (mock.call.pylib.utils.apk_helper.GetPackageName('/fake/test/app.apk'), | 576 (mock.call.pylib.utils.apk_helper.GetPackageName('/fake/test/app.apk'), |
| 568 'this.is.a.test.package'), | 577 'test.package'), |
| 569 (self.call.device.GetApplicationPaths('this.is.a.test.package'), []), | 578 (self.call.device._GetApplicationPathsInternal('test.package'), []), |
| 570 (self.call.adb.Install('/fake/test/app.apk', reinstall=False), | 579 (self.call.adb.Install('/fake/test/app.apk', reinstall=False), |
| 571 self.CommandError('Failure\r\n'))): | 580 self.CommandError('Failure\r\n'))): |
| 572 with self.assertRaises(device_errors.CommandFailedError): | 581 with self.assertRaises(device_errors.CommandFailedError): |
| 573 self.device.Install('/fake/test/app.apk', retries=0) | 582 self.device.Install('/fake/test/app.apk', retries=0) |
| 574 | 583 |
| 575 class DeviceUtilsInstallSplitApkTest(DeviceUtilsTest): | 584 class DeviceUtilsInstallSplitApkTest(DeviceUtilsTest): |
| 576 | 585 |
| 577 def testInstallSplitApk_noPriorInstall(self): | 586 def testInstallSplitApk_noPriorInstall(self): |
| 578 with self.assertCalls( | 587 with self.assertCalls( |
| 579 (self.call.device._CheckSdkLevel(21)), | 588 (self.call.device._CheckSdkLevel(21)), |
| 580 (mock.call.pylib.sdk.split_select.SelectSplits( | 589 (mock.call.pylib.sdk.split_select.SelectSplits( |
| 581 self.device, 'base.apk', | 590 self.device, 'base.apk', |
| 582 ['split1.apk', 'split2.apk', 'split3.apk']), | 591 ['split1.apk', 'split2.apk', 'split3.apk']), |
| 583 ['split2.apk']), | 592 ['split2.apk']), |
| 584 (mock.call.pylib.utils.apk_helper.GetPackageName('base.apk'), | 593 (mock.call.pylib.utils.apk_helper.GetPackageName('base.apk'), |
| 585 'this.is.a.test.package'), | 594 'test.package'), |
| 586 (self.call.device.GetApplicationPaths('this.is.a.test.package'), []), | 595 (self.call.device._GetApplicationPathsInternal('test.package'), []), |
| 587 (self.call.adb.InstallMultiple( | 596 (self.call.adb.InstallMultiple( |
| 588 ['base.apk', 'split2.apk'], partial=None, reinstall=False))): | 597 ['base.apk', 'split2.apk'], partial=None, reinstall=False))): |
| 589 self.device.InstallSplitApk('base.apk', | 598 self.device.InstallSplitApk('base.apk', |
| 590 ['split1.apk', 'split2.apk', 'split3.apk'], retries=0) | 599 ['split1.apk', 'split2.apk', 'split3.apk'], retries=0) |
| 591 | 600 |
| 592 def testInstallSplitApk_partialInstall(self): | 601 def testInstallSplitApk_partialInstall(self): |
| 593 with self.assertCalls( | 602 with self.assertCalls( |
| 594 (self.call.device._CheckSdkLevel(21)), | 603 (self.call.device._CheckSdkLevel(21)), |
| 595 (mock.call.pylib.sdk.split_select.SelectSplits( | 604 (mock.call.pylib.sdk.split_select.SelectSplits( |
| 596 self.device, 'base.apk', | 605 self.device, 'base.apk', |
| 597 ['split1.apk', 'split2.apk', 'split3.apk']), | 606 ['split1.apk', 'split2.apk', 'split3.apk']), |
| 598 ['split2.apk']), | 607 ['split2.apk']), |
| 599 (mock.call.pylib.utils.apk_helper.GetPackageName('base.apk'), | 608 (mock.call.pylib.utils.apk_helper.GetPackageName('base.apk'), |
| 600 'test.package'), | 609 'test.package'), |
| 601 (self.call.device.GetApplicationPaths('test.package'), | 610 (self.call.device._GetApplicationPathsInternal('test.package'), |
| 602 ['base-on-device.apk', 'split2-on-device.apk']), | 611 ['base-on-device.apk', 'split2-on-device.apk']), |
| 603 (mock.call.pylib.utils.md5sum.CalculateDeviceMd5Sums( | 612 (self.call.device._ComputeStaleApks('test.package', |
| 604 ['base-on-device.apk', 'split2-on-device.apk'], self.device), | 613 ['base.apk', 'split2.apk']), |
| 605 {'base-on-device.apk': 'AAA', 'split2-on-device.apk': 'BBB'}), | 614 (['split2.apk'], None)), |
| 606 (mock.call.pylib.utils.md5sum.CalculateHostMd5Sums( | |
| 607 ['base.apk', 'split2.apk']), | |
| 608 {'base.apk': 'AAA', 'split2.apk': 'CCC'}), | |
| 609 (self.call.adb.InstallMultiple( | 615 (self.call.adb.InstallMultiple( |
| 610 ['split2.apk'], partial='test.package', reinstall=True))): | 616 ['split2.apk'], partial='test.package', reinstall=True))): |
| 611 self.device.InstallSplitApk('base.apk', | 617 self.device.InstallSplitApk('base.apk', |
| 612 ['split1.apk', 'split2.apk', 'split3.apk'], reinstall=True, retries=0) | 618 ['split1.apk', 'split2.apk', 'split3.apk'], reinstall=True, retries=0) |
| 613 | 619 |
| 614 | 620 |
| 615 class DeviceUtilsRunShellCommandTest(DeviceUtilsTest): | 621 class DeviceUtilsRunShellCommandTest(DeviceUtilsTest): |
| 616 | 622 |
| 617 def setUp(self): | 623 def setUp(self): |
| 618 super(DeviceUtilsRunShellCommandTest, self).setUp() | 624 super(DeviceUtilsRunShellCommandTest, self).setUp() |
| (...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 868 def testStartActivity_actionOnly(self): | 874 def testStartActivity_actionOnly(self): |
| 869 test_intent = intent.Intent(action='android.intent.action.VIEW') | 875 test_intent = intent.Intent(action='android.intent.action.VIEW') |
| 870 with self.assertCall( | 876 with self.assertCall( |
| 871 self.call.adb.Shell('am start ' | 877 self.call.adb.Shell('am start ' |
| 872 '-a android.intent.action.VIEW'), | 878 '-a android.intent.action.VIEW'), |
| 873 'Starting: Intent { act=android.intent.action.VIEW }'): | 879 'Starting: Intent { act=android.intent.action.VIEW }'): |
| 874 self.device.StartActivity(test_intent) | 880 self.device.StartActivity(test_intent) |
| 875 | 881 |
| 876 def testStartActivity_success(self): | 882 def testStartActivity_success(self): |
| 877 test_intent = intent.Intent(action='android.intent.action.VIEW', | 883 test_intent = intent.Intent(action='android.intent.action.VIEW', |
| 878 package='this.is.a.test.package', | 884 package='test.package', |
| 879 activity='.Main') | 885 activity='.Main') |
| 880 with self.assertCall( | 886 with self.assertCall( |
| 881 self.call.adb.Shell('am start ' | 887 self.call.adb.Shell('am start ' |
| 882 '-a android.intent.action.VIEW ' | 888 '-a android.intent.action.VIEW ' |
| 883 '-n this.is.a.test.package/.Main'), | 889 '-n test.package/.Main'), |
| 884 'Starting: Intent { act=android.intent.action.VIEW }'): | 890 'Starting: Intent { act=android.intent.action.VIEW }'): |
| 885 self.device.StartActivity(test_intent) | 891 self.device.StartActivity(test_intent) |
| 886 | 892 |
| 887 def testStartActivity_failure(self): | 893 def testStartActivity_failure(self): |
| 888 test_intent = intent.Intent(action='android.intent.action.VIEW', | 894 test_intent = intent.Intent(action='android.intent.action.VIEW', |
| 889 package='this.is.a.test.package', | 895 package='test.package', |
| 890 activity='.Main') | 896 activity='.Main') |
| 891 with self.assertCall( | 897 with self.assertCall( |
| 892 self.call.adb.Shell('am start ' | 898 self.call.adb.Shell('am start ' |
| 893 '-a android.intent.action.VIEW ' | 899 '-a android.intent.action.VIEW ' |
| 894 '-n this.is.a.test.package/.Main'), | 900 '-n test.package/.Main'), |
| 895 'Error: Failed to start test activity'): | 901 'Error: Failed to start test activity'): |
| 896 with self.assertRaises(device_errors.CommandFailedError): | 902 with self.assertRaises(device_errors.CommandFailedError): |
| 897 self.device.StartActivity(test_intent) | 903 self.device.StartActivity(test_intent) |
| 898 | 904 |
| 899 def testStartActivity_blocking(self): | 905 def testStartActivity_blocking(self): |
| 900 test_intent = intent.Intent(action='android.intent.action.VIEW', | 906 test_intent = intent.Intent(action='android.intent.action.VIEW', |
| 901 package='this.is.a.test.package', | 907 package='test.package', |
| 902 activity='.Main') | 908 activity='.Main') |
| 903 with self.assertCall( | 909 with self.assertCall( |
| 904 self.call.adb.Shell('am start ' | 910 self.call.adb.Shell('am start ' |
| 905 '-W ' | 911 '-W ' |
| 906 '-a android.intent.action.VIEW ' | 912 '-a android.intent.action.VIEW ' |
| 907 '-n this.is.a.test.package/.Main'), | 913 '-n test.package/.Main'), |
| 908 'Starting: Intent { act=android.intent.action.VIEW }'): | 914 'Starting: Intent { act=android.intent.action.VIEW }'): |
| 909 self.device.StartActivity(test_intent, blocking=True) | 915 self.device.StartActivity(test_intent, blocking=True) |
| 910 | 916 |
| 911 def testStartActivity_withCategory(self): | 917 def testStartActivity_withCategory(self): |
| 912 test_intent = intent.Intent(action='android.intent.action.VIEW', | 918 test_intent = intent.Intent(action='android.intent.action.VIEW', |
| 913 package='this.is.a.test.package', | 919 package='test.package', |
| 914 activity='.Main', | 920 activity='.Main', |
| 915 category='android.intent.category.HOME') | 921 category='android.intent.category.HOME') |
| 916 with self.assertCall( | 922 with self.assertCall( |
| 917 self.call.adb.Shell('am start ' | 923 self.call.adb.Shell('am start ' |
| 918 '-a android.intent.action.VIEW ' | 924 '-a android.intent.action.VIEW ' |
| 919 '-c android.intent.category.HOME ' | 925 '-c android.intent.category.HOME ' |
| 920 '-n this.is.a.test.package/.Main'), | 926 '-n test.package/.Main'), |
| 921 'Starting: Intent { act=android.intent.action.VIEW }'): | 927 'Starting: Intent { act=android.intent.action.VIEW }'): |
| 922 self.device.StartActivity(test_intent) | 928 self.device.StartActivity(test_intent) |
| 923 | 929 |
| 924 def testStartActivity_withMultipleCategories(self): | 930 def testStartActivity_withMultipleCategories(self): |
| 925 test_intent = intent.Intent(action='android.intent.action.VIEW', | 931 test_intent = intent.Intent(action='android.intent.action.VIEW', |
| 926 package='this.is.a.test.package', | 932 package='test.package', |
| 927 activity='.Main', | 933 activity='.Main', |
| 928 category=['android.intent.category.HOME', | 934 category=['android.intent.category.HOME', |
| 929 'android.intent.category.BROWSABLE']) | 935 'android.intent.category.BROWSABLE']) |
| 930 with self.assertCall( | 936 with self.assertCall( |
| 931 self.call.adb.Shell('am start ' | 937 self.call.adb.Shell('am start ' |
| 932 '-a android.intent.action.VIEW ' | 938 '-a android.intent.action.VIEW ' |
| 933 '-c android.intent.category.HOME ' | 939 '-c android.intent.category.HOME ' |
| 934 '-c android.intent.category.BROWSABLE ' | 940 '-c android.intent.category.BROWSABLE ' |
| 935 '-n this.is.a.test.package/.Main'), | 941 '-n test.package/.Main'), |
| 936 'Starting: Intent { act=android.intent.action.VIEW }'): | 942 'Starting: Intent { act=android.intent.action.VIEW }'): |
| 937 self.device.StartActivity(test_intent) | 943 self.device.StartActivity(test_intent) |
| 938 | 944 |
| 939 def testStartActivity_withData(self): | 945 def testStartActivity_withData(self): |
| 940 test_intent = intent.Intent(action='android.intent.action.VIEW', | 946 test_intent = intent.Intent(action='android.intent.action.VIEW', |
| 941 package='this.is.a.test.package', | 947 package='test.package', |
| 942 activity='.Main', | 948 activity='.Main', |
| 943 data='http://www.google.com/') | 949 data='http://www.google.com/') |
| 944 with self.assertCall( | 950 with self.assertCall( |
| 945 self.call.adb.Shell('am start ' | 951 self.call.adb.Shell('am start ' |
| 946 '-a android.intent.action.VIEW ' | 952 '-a android.intent.action.VIEW ' |
| 947 '-d http://www.google.com/ ' | 953 '-d http://www.google.com/ ' |
| 948 '-n this.is.a.test.package/.Main'), | 954 '-n test.package/.Main'), |
| 949 'Starting: Intent { act=android.intent.action.VIEW }'): | 955 'Starting: Intent { act=android.intent.action.VIEW }'): |
| 950 self.device.StartActivity(test_intent) | 956 self.device.StartActivity(test_intent) |
| 951 | 957 |
| 952 def testStartActivity_withStringExtra(self): | 958 def testStartActivity_withStringExtra(self): |
| 953 test_intent = intent.Intent(action='android.intent.action.VIEW', | 959 test_intent = intent.Intent(action='android.intent.action.VIEW', |
| 954 package='this.is.a.test.package', | 960 package='test.package', |
| 955 activity='.Main', | 961 activity='.Main', |
| 956 extras={'foo': 'test'}) | 962 extras={'foo': 'test'}) |
| 957 with self.assertCall( | 963 with self.assertCall( |
| 958 self.call.adb.Shell('am start ' | 964 self.call.adb.Shell('am start ' |
| 959 '-a android.intent.action.VIEW ' | 965 '-a android.intent.action.VIEW ' |
| 960 '-n this.is.a.test.package/.Main ' | 966 '-n test.package/.Main ' |
| 961 '--es foo test'), | 967 '--es foo test'), |
| 962 'Starting: Intent { act=android.intent.action.VIEW }'): | 968 'Starting: Intent { act=android.intent.action.VIEW }'): |
| 963 self.device.StartActivity(test_intent) | 969 self.device.StartActivity(test_intent) |
| 964 | 970 |
| 965 def testStartActivity_withBoolExtra(self): | 971 def testStartActivity_withBoolExtra(self): |
| 966 test_intent = intent.Intent(action='android.intent.action.VIEW', | 972 test_intent = intent.Intent(action='android.intent.action.VIEW', |
| 967 package='this.is.a.test.package', | 973 package='test.package', |
| 968 activity='.Main', | 974 activity='.Main', |
| 969 extras={'foo': True}) | 975 extras={'foo': True}) |
| 970 with self.assertCall( | 976 with self.assertCall( |
| 971 self.call.adb.Shell('am start ' | 977 self.call.adb.Shell('am start ' |
| 972 '-a android.intent.action.VIEW ' | 978 '-a android.intent.action.VIEW ' |
| 973 '-n this.is.a.test.package/.Main ' | 979 '-n test.package/.Main ' |
| 974 '--ez foo True'), | 980 '--ez foo True'), |
| 975 'Starting: Intent { act=android.intent.action.VIEW }'): | 981 'Starting: Intent { act=android.intent.action.VIEW }'): |
| 976 self.device.StartActivity(test_intent) | 982 self.device.StartActivity(test_intent) |
| 977 | 983 |
| 978 def testStartActivity_withIntExtra(self): | 984 def testStartActivity_withIntExtra(self): |
| 979 test_intent = intent.Intent(action='android.intent.action.VIEW', | 985 test_intent = intent.Intent(action='android.intent.action.VIEW', |
| 980 package='this.is.a.test.package', | 986 package='test.package', |
| 981 activity='.Main', | 987 activity='.Main', |
| 982 extras={'foo': 123}) | 988 extras={'foo': 123}) |
| 983 with self.assertCall( | 989 with self.assertCall( |
| 984 self.call.adb.Shell('am start ' | 990 self.call.adb.Shell('am start ' |
| 985 '-a android.intent.action.VIEW ' | 991 '-a android.intent.action.VIEW ' |
| 986 '-n this.is.a.test.package/.Main ' | 992 '-n test.package/.Main ' |
| 987 '--ei foo 123'), | 993 '--ei foo 123'), |
| 988 'Starting: Intent { act=android.intent.action.VIEW }'): | 994 'Starting: Intent { act=android.intent.action.VIEW }'): |
| 989 self.device.StartActivity(test_intent) | 995 self.device.StartActivity(test_intent) |
| 990 | 996 |
| 991 def testStartActivity_withTraceFile(self): | 997 def testStartActivity_withTraceFile(self): |
| 992 test_intent = intent.Intent(action='android.intent.action.VIEW', | 998 test_intent = intent.Intent(action='android.intent.action.VIEW', |
| 993 package='this.is.a.test.package', | 999 package='test.package', |
| 994 activity='.Main') | 1000 activity='.Main') |
| 995 with self.assertCall( | 1001 with self.assertCall( |
| 996 self.call.adb.Shell('am start ' | 1002 self.call.adb.Shell('am start ' |
| 997 '--start-profiler test_trace_file.out ' | 1003 '--start-profiler test_trace_file.out ' |
| 998 '-a android.intent.action.VIEW ' | 1004 '-a android.intent.action.VIEW ' |
| 999 '-n this.is.a.test.package/.Main'), | 1005 '-n test.package/.Main'), |
| 1000 'Starting: Intent { act=android.intent.action.VIEW }'): | 1006 'Starting: Intent { act=android.intent.action.VIEW }'): |
| 1001 self.device.StartActivity(test_intent, | 1007 self.device.StartActivity(test_intent, |
| 1002 trace_file_name='test_trace_file.out') | 1008 trace_file_name='test_trace_file.out') |
| 1003 | 1009 |
| 1004 def testStartActivity_withForceStop(self): | 1010 def testStartActivity_withForceStop(self): |
| 1005 test_intent = intent.Intent(action='android.intent.action.VIEW', | 1011 test_intent = intent.Intent(action='android.intent.action.VIEW', |
| 1006 package='this.is.a.test.package', | 1012 package='test.package', |
| 1007 activity='.Main') | 1013 activity='.Main') |
| 1008 with self.assertCall( | 1014 with self.assertCall( |
| 1009 self.call.adb.Shell('am start ' | 1015 self.call.adb.Shell('am start ' |
| 1010 '-S ' | 1016 '-S ' |
| 1011 '-a android.intent.action.VIEW ' | 1017 '-a android.intent.action.VIEW ' |
| 1012 '-n this.is.a.test.package/.Main'), | 1018 '-n test.package/.Main'), |
| 1013 'Starting: Intent { act=android.intent.action.VIEW }'): | 1019 'Starting: Intent { act=android.intent.action.VIEW }'): |
| 1014 self.device.StartActivity(test_intent, force_stop=True) | 1020 self.device.StartActivity(test_intent, force_stop=True) |
| 1015 | 1021 |
| 1016 def testStartActivity_withFlags(self): | 1022 def testStartActivity_withFlags(self): |
| 1017 test_intent = intent.Intent(action='android.intent.action.VIEW', | 1023 test_intent = intent.Intent(action='android.intent.action.VIEW', |
| 1018 package='this.is.a.test.package', | 1024 package='test.package', |
| 1019 activity='.Main', | 1025 activity='.Main', |
| 1020 flags='0x10000000') | 1026 flags='0x10000000') |
| 1021 with self.assertCall( | 1027 with self.assertCall( |
| 1022 self.call.adb.Shell('am start ' | 1028 self.call.adb.Shell('am start ' |
| 1023 '-a android.intent.action.VIEW ' | 1029 '-a android.intent.action.VIEW ' |
| 1024 '-n this.is.a.test.package/.Main ' | 1030 '-n test.package/.Main ' |
| 1025 '-f 0x10000000'), | 1031 '-f 0x10000000'), |
| 1026 'Starting: Intent { act=android.intent.action.VIEW }'): | 1032 'Starting: Intent { act=android.intent.action.VIEW }'): |
| 1027 self.device.StartActivity(test_intent) | 1033 self.device.StartActivity(test_intent) |
| 1028 | 1034 |
| 1029 | 1035 |
| 1030 class DeviceUtilsStartInstrumentationTest(DeviceUtilsTest): | 1036 class DeviceUtilsStartInstrumentationTest(DeviceUtilsTest): |
| 1031 | 1037 |
| 1032 def testStartInstrumentation_nothing(self): | 1038 def testStartInstrumentation_nothing(self): |
| 1033 with self.assertCalls( | 1039 with self.assertCalls( |
| 1034 self.call.device.RunShellCommand( | 1040 self.call.device.RunShellCommand( |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1179 (self.call.device.RunShellCommand( | 1185 (self.call.device.RunShellCommand( |
| 1180 ['dumpsys', 'window', 'windows'], check_return=True, | 1186 ['dumpsys', 'window', 'windows'], check_return=True, |
| 1181 large_output=True), | 1187 large_output=True), |
| 1182 ['mCurrentFocus Launcher'])): | 1188 ['mCurrentFocus Launcher'])): |
| 1183 self.device.GoHome() | 1189 self.device.GoHome() |
| 1184 | 1190 |
| 1185 class DeviceUtilsForceStopTest(DeviceUtilsTest): | 1191 class DeviceUtilsForceStopTest(DeviceUtilsTest): |
| 1186 | 1192 |
| 1187 def testForceStop(self): | 1193 def testForceStop(self): |
| 1188 with self.assertCall( | 1194 with self.assertCall( |
| 1189 self.call.adb.Shell('am force-stop this.is.a.test.package'), | 1195 self.call.adb.Shell('am force-stop test.package'), |
| 1190 ''): | 1196 ''): |
| 1191 self.device.ForceStop('this.is.a.test.package') | 1197 self.device.ForceStop('test.package') |
| 1192 | 1198 |
| 1193 | 1199 |
| 1194 class DeviceUtilsClearApplicationStateTest(DeviceUtilsTest): | 1200 class DeviceUtilsClearApplicationStateTest(DeviceUtilsTest): |
| 1195 | 1201 |
| 1196 def testClearApplicationState_packageDoesntExist(self): | 1202 def testClearApplicationState_packageDoesntExist(self): |
| 1197 with self.assertCalls( | 1203 with self.assertCalls( |
| 1198 (self.call.adb.Shell('getprop ro.build.version.sdk'), '17\n'), | 1204 (self.call.adb.Shell('getprop ro.build.version.sdk'), '17\n'), |
| 1199 (self.call.device.GetApplicationPaths('this.package.does.not.exist'), | 1205 (self.call.device._GetApplicationPathsInternal('does.not.exist'), |
| 1200 [])): | 1206 [])): |
| 1201 self.device.ClearApplicationState('this.package.does.not.exist') | 1207 self.device.ClearApplicationState('does.not.exist') |
| 1202 | 1208 |
| 1203 def testClearApplicationState_packageDoesntExistOnAndroidJBMR2OrAbove(self): | 1209 def testClearApplicationState_packageDoesntExistOnAndroidJBMR2OrAbove(self): |
| 1204 with self.assertCalls( | 1210 with self.assertCalls( |
| 1205 (self.call.adb.Shell('getprop ro.build.version.sdk'), '18\n'), | 1211 (self.call.adb.Shell('getprop ro.build.version.sdk'), '18\n'), |
| 1206 (self.call.adb.Shell('pm clear this.package.does.not.exist'), | 1212 (self.call.adb.Shell('pm clear this.package.does.not.exist'), |
| 1207 'Failed\r\n')): | 1213 'Failed\r\n')): |
| 1208 self.device.ClearApplicationState('this.package.does.not.exist') | 1214 self.device.ClearApplicationState('this.package.does.not.exist') |
| 1209 | 1215 |
| 1210 def testClearApplicationState_packageExists(self): | 1216 def testClearApplicationState_packageExists(self): |
| 1211 with self.assertCalls( | 1217 with self.assertCalls( |
| 1212 (self.call.adb.Shell('getprop ro.build.version.sdk'), '17\n'), | 1218 (self.call.adb.Shell('getprop ro.build.version.sdk'), '17\n'), |
| 1213 (self.call.device.GetApplicationPaths('this.package.exists'), | 1219 (self.call.device._GetApplicationPathsInternal('this.package.exists'), |
| 1214 ['/data/app/this.package.exists.apk']), | 1220 ['/data/app/this.package.exists.apk']), |
| 1215 (self.call.adb.Shell('pm clear this.package.exists'), | 1221 (self.call.adb.Shell('pm clear this.package.exists'), |
| 1216 'Success\r\n')): | 1222 'Success\r\n')): |
| 1217 self.device.ClearApplicationState('this.package.exists') | 1223 self.device.ClearApplicationState('this.package.exists') |
| 1218 | 1224 |
| 1219 def testClearApplicationState_packageExistsOnAndroidJBMR2OrAbove(self): | 1225 def testClearApplicationState_packageExistsOnAndroidJBMR2OrAbove(self): |
| 1220 with self.assertCalls( | 1226 with self.assertCalls( |
| 1221 (self.call.adb.Shell('getprop ro.build.version.sdk'), '18\n'), | 1227 (self.call.adb.Shell('getprop ro.build.version.sdk'), '18\n'), |
| 1222 (self.call.adb.Shell('pm clear this.package.exists'), | 1228 (self.call.adb.Shell('pm clear this.package.exists'), |
| 1223 'Success\r\n')): | 1229 'Success\r\n')): |
| (...skipping 612 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1836 devices = device_utils.DeviceUtils.HealthyDevices() | 1842 devices = device_utils.DeviceUtils.HealthyDevices() |
| 1837 self.assertEquals(1, len(devices)) | 1843 self.assertEquals(1, len(devices)) |
| 1838 self.assertTrue(isinstance(devices[0], device_utils.DeviceUtils)) | 1844 self.assertTrue(isinstance(devices[0], device_utils.DeviceUtils)) |
| 1839 self.assertEquals('0123456789abcdef', devices[0].adb.GetDeviceSerial()) | 1845 self.assertEquals('0123456789abcdef', devices[0].adb.GetDeviceSerial()) |
| 1840 | 1846 |
| 1841 | 1847 |
| 1842 if __name__ == '__main__': | 1848 if __name__ == '__main__': |
| 1843 logging.getLogger().setLevel(logging.DEBUG) | 1849 logging.getLogger().setLevel(logging.DEBUG) |
| 1844 unittest.main(verbosity=2) | 1850 unittest.main(verbosity=2) |
| 1845 | 1851 |
| OLD | NEW |