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

Unified Diff: build/android/pylib/device/device_utils_test.py

Issue 1315603002: [Android] Add DeviceUtils.GetApplicationVersion (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: 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 580794ddb8c3aca0416ea622c590ebb3c7b4e9a9..84e8205e117cfa35c1b45096110a8fe8edfee046 100755
--- a/build/android/pylib/device/device_utils_test.py
+++ b/build/android/pylib/device/device_utils_test.py
@@ -325,6 +325,36 @@ class DeviceUtils_GetApplicationPathsInternalTest(DeviceUtilsTest):
self.device._GetApplicationPathsInternal('android')
+class DeviceUtils_GetApplicationVersionTest(DeviceUtilsTest):
+
+ def test_GetApplicationVersion_exists(self):
+ with self.assertCalls(
+ (self.call.adb.Shell('dumpsys package com.android.chrome'),
+ 'Packages:\n'
+ ' Package [com.android.chrome] (3901ecfb):\n'
+ ' userId=1234 gids=[123, 456, 789]\n'
+ ' pkg=Package{1fecf634 com.android.chrome}\n'
+ ' versionName=45.0.1234.7\n')):
+ self.assertEquals('45.0.1234.7',
+ self.device.GetApplicationVersion('com.android.chrome'))
+
+ def test_GetApplicationVersion_notExists(self):
+ with self.assertCalls(
+ (self.call.adb.Shell('dumpsys package com.android.chrome'), '')):
+ self.assertEquals(None,
+ self.device.GetApplicationVersion('com.android.chrome'))
+
+ def test_GetApplicationVersion_fails(self):
+ with self.assertCalls(
+ (self.call.adb.Shell('dumpsys package com.android.chrome'),
+ 'Packages:\n'
+ ' Package [com.android.chrome] (3901ecfb):\n'
+ ' userId=1234 gids=[123, 456, 789]\n'
+ ' pkg=Package{1fecf634 com.android.chrome}\n')):
+ with self.assertRaises(device_errors.CommandFailedError):
+ self.device.GetApplicationVersion('com.android.chrome')
+
+
class DeviceUtilsGetApplicationDataDirectoryTest(DeviceUtilsTest):
def testGetApplicationDataDirectory_exists(self):
« build/android/pylib/device/device_utils.py ('K') | « build/android/pylib/device/device_utils.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698