Index: build/android/pylib/device/device_utils_test.py |
diff --git a/build/android/pylib/device/device_utils_test.py b/build/android/pylib/device/device_utils_test.py |
index 760e61fa9476f0e199ad86e0eea636aa6f5a2079..5f2249da740dd2379d9a4ea7de6c489a7aa62ea9 100755 |
--- a/build/android/pylib/device/device_utils_test.py |
+++ b/build/android/pylib/device/device_utils_test.py |
@@ -943,33 +943,30 @@ class DeviceUtilsStartInstrumentationTest(DeviceUtilsNewImplTest): |
finish=False, raw=False, extras={'foo': 'Foo', 'bar': 'Bar'}) |
-class DeviceUtilsBroadcastIntentTest(DeviceUtilsOldImplTest): |
+class DeviceUtilsBroadcastIntentTest(DeviceUtilsNewImplTest): |
def testBroadcastIntent_noExtras(self): |
test_intent = intent.Intent(action='test.package.with.an.INTENT') |
- with self.assertCalls( |
- "adb -s 0123456789abcdef shell 'am broadcast " |
- "-a test.package.with.an.INTENT '", |
+ with self.assertCall( |
+ self.call.adb.Shell('am broadcast -a test.package.with.an.INTENT'), |
'Broadcasting: Intent { act=test.package.with.an.INTENT } '): |
self.device.BroadcastIntent(test_intent) |
def testBroadcastIntent_withExtra(self): |
test_intent = intent.Intent(action='test.package.with.an.INTENT', |
- extras={'foo': 'bar'}) |
- with self.assertCalls( |
- "adb -s 0123456789abcdef shell 'am broadcast " |
- "-a test.package.with.an.INTENT " |
- "-e foo \"bar\"'", |
+ extras={'foo': 'bar value'}) |
+ with self.assertCall( |
+ self.call.adb.Shell( |
+ "am broadcast -a test.package.with.an.INTENT -e foo 'bar value'"), |
'Broadcasting: Intent { act=test.package.with.an.INTENT } '): |
self.device.BroadcastIntent(test_intent) |
def testBroadcastIntent_withExtra_noValue(self): |
test_intent = intent.Intent(action='test.package.with.an.INTENT', |
extras={'foo': None}) |
- with self.assertCalls( |
- "adb -s 0123456789abcdef shell 'am broadcast " |
- "-a test.package.with.an.INTENT " |
- "-e foo'", |
+ with self.assertCall( |
+ self.call.adb.Shell( |
+ 'am broadcast -a test.package.with.an.INTENT -e foo'), |
'Broadcasting: Intent { act=test.package.with.an.INTENT } '): |
self.device.BroadcastIntent(test_intent) |
@@ -986,38 +983,36 @@ class DeviceUtilsGoHomeTest(DeviceUtilsOldImplTest): |
self.device.GoHome() |
-class DeviceUtilsForceStopTest(DeviceUtilsOldImplTest): |
+class DeviceUtilsForceStopTest(DeviceUtilsNewImplTest): |
def testForceStop(self): |
- with self.assertCalls( |
- "adb -s 0123456789abcdef shell 'am force-stop this.is.a.test.package'", |
+ with self.assertCall( |
+ self.call.adb.Shell('am force-stop this.is.a.test.package'), |
''): |
self.device.ForceStop('this.is.a.test.package') |
-class DeviceUtilsClearApplicationStateTest(DeviceUtilsOldImplTest): |
+class DeviceUtilsClearApplicationStateTest(DeviceUtilsNewImplTest): |
- def testClearApplicationState_packageExists(self): |
- with self.assertCalls( |
- "adb -s 0123456789abcdef shell 'pm path this.package.does.not.exist'", |
- ''): |
+ def testClearApplicationState_packageDoesntExist(self): |
+ with self.assertCall( |
+ self.call.device.GetApplicationPath('this.package.does.not.exist'), |
+ None): |
self.device.ClearApplicationState('this.package.does.not.exist') |
- def testClearApplicationState_packageDoesntExist(self): |
- with self.assertCallsSequence([ |
- ("adb -s 0123456789abcdef shell 'pm path this.package.exists'", |
- 'package:/data/app/this.package.exists.apk'), |
- ("adb -s 0123456789abcdef shell 'pm clear this.package.exists'", |
- 'Success\r\n')]): |
+ def testClearApplicationState_packageExists(self): |
+ with self.assertCalls( |
+ (self.call.device.GetApplicationPath('this.package.exists'), |
+ '/data/app/this.package.exists.apk'), |
+ (self.call.adb.Shell('pm clear this.package.exists'), |
+ 'Success\r\n')): |
self.device.ClearApplicationState('this.package.exists') |
-class DeviceUtilsSendKeyEventTest(DeviceUtilsOldImplTest): |
+class DeviceUtilsSendKeyEventTest(DeviceUtilsNewImplTest): |
def testSendKeyEvent(self): |
- with self.assertCalls( |
- "adb -s 0123456789abcdef shell 'input keyevent 66'", |
- ''): |
+ with self.assertCall(self.call.adb.Shell('input keyevent 66'), ''): |
self.device.SendKeyEvent(66) |
@@ -1237,49 +1232,52 @@ class DeviceUtilsWriteFileTest(DeviceUtilsNewImplTest): |
self.device.WriteFile('/test/file', 'contents', as_root=True) |
-class DeviceUtilsLsTest(DeviceUtilsOldImplTest): |
+class DeviceUtilsLsTest(DeviceUtilsNewImplTest): |
+ |
+ def testLs_directory(self): |
+ result = [('.', adb_wrapper.DeviceStat(16889, 4096, 1417436123)), |
+ ('..', adb_wrapper.DeviceStat(16873, 4096, 12382237)), |
+ ('testfile.txt', adb_wrapper.DeviceStat(33206, 3, 1417436122))] |
+ with self.assertCalls( |
+ (self.call.adb.Ls('/data/local/tmp'), result)): |
+ self.assertEquals(result, |
+ self.device.Ls('/data/local/tmp')) |
def testLs_nothing(self): |
- with self.assertCallsSequence([ |
- ("adb -s 0123456789abcdef shell 'ls -lR /this/file/does.not.exist'", |
- '/this/file/does.not.exist: No such file or directory\r\n'), |
- ("adb -s 0123456789abcdef shell 'date +%z'", '+0000')]): |
- self.assertEqual({}, self.device.Ls('/this/file/does.not.exist')) |
+ with self.assertCalls( |
+ (self.call.adb.Ls('/data/local/tmp/testfile.txt'), [])): |
+ self.assertEquals([], |
+ self.device.Ls('/data/local/tmp/testfile.txt')) |
- def testLs_file(self): |
- with self.assertCallsSequence([ |
- ("adb -s 0123456789abcdef shell 'ls -lR /this/is/a/test.file'", |
- '-rw-rw---- testuser testgroup 4096 1970-01-01 00:00 test.file\r\n'), |
- ("adb -s 0123456789abcdef shell 'date +%z'", '+0000')]): |
- self.assertEqual( |
- {'test.file': (4096, datetime.datetime(1970, 1, 1))}, |
- self.device.Ls('/this/is/a/test.file')) |
- def testLs_directory(self): |
- with self.assertCallsSequence([ |
- ("adb -s 0123456789abcdef shell 'ls -lR /this/is/a/test.directory'", |
- '\r\n' |
- '/this/is/a/test.directory:\r\n' |
- '-rw-rw---- testuser testgroup 4096 1970-01-01 18:19 test.file\r\n'), |
- ("adb -s 0123456789abcdef shell 'date +%z'", '+0000')]): |
- self.assertEqual( |
- {'test.file': (4096, datetime.datetime(1970, 1, 1, 18, 19))}, |
- self.device.Ls('/this/is/a/test.directory')) |
+class DeviceUtilsStatTest(DeviceUtilsNewImplTest): |
- def testLs_directories(self): |
- with self.assertCallsSequence([ |
- ("adb -s 0123456789abcdef shell 'ls -lR /this/is/a/test.directory'", |
- '\r\n' |
- '/this/is/a/test.directory:\r\n' |
- 'drwxr-xr-x testuser testgroup 1970-01-01 00:00 test.subdirectory\r\n' |
- '\r\n' |
- '/this/is/a/test.directory/test.subdirectory:\r\n' |
- '-rw-rw---- testuser testgroup 4096 1970-01-01 00:00 test.file\r\n'), |
- ("adb -s 0123456789abcdef shell 'date +%z'", '-0700')]): |
- self.assertEqual( |
- {'test.subdirectory/test.file': |
- (4096, datetime.datetime(1970, 1, 1, 7, 0, 0))}, |
- self.device.Ls('/this/is/a/test.directory')) |
+ def testStat_file(self): |
+ result = [('.', adb_wrapper.DeviceStat(16889, 4096, 1417436123)), |
+ ('..', adb_wrapper.DeviceStat(16873, 4096, 12382237)), |
+ ('testfile.txt', adb_wrapper.DeviceStat(33206, 3, 1417436122))] |
+ with self.assertCalls( |
+ (self.call.adb.Ls('/data/local/tmp'), result)): |
+ self.assertEquals(adb_wrapper.DeviceStat(33206, 3, 1417436122), |
+ self.device.Stat('/data/local/tmp/testfile.txt')) |
+ |
+ def testStat_directory(self): |
+ result = [('.', adb_wrapper.DeviceStat(16873, 4096, 12382237)), |
+ ('..', adb_wrapper.DeviceStat(16873, 4096, 12382237)), |
+ ('tmp', adb_wrapper.DeviceStat(16889, 4096, 1417436123))] |
+ with self.assertCalls( |
+ (self.call.adb.Ls('/data/local'), result)): |
+ self.assertEquals(adb_wrapper.DeviceStat(16889, 4096, 1417436123), |
+ self.device.Stat('/data/local/tmp')) |
+ |
+ def testStat_doesNotExist(self): |
+ result = [('.', adb_wrapper.DeviceStat(16889, 4096, 1417436123)), |
+ ('..', adb_wrapper.DeviceStat(16873, 4096, 12382237)), |
+ ('testfile.txt', adb_wrapper.DeviceStat(33206, 3, 1417436122))] |
+ with self.assertCalls( |
+ (self.call.adb.Ls('/data/local/tmp'), result)): |
+ with self.assertRaises(device_errors.CommandFailedError): |
+ self.device.Stat('/data/local/tmp/does.not.exist.txt') |
class DeviceUtilsSetJavaAssertsTest(DeviceUtilsOldImplTest): |