| Index: devil/devil/android/apk_helper_test.py
|
| diff --git a/devil/devil/android/apk_helper_test.py b/devil/devil/android/apk_helper_test.py
|
| index f7d077dd62570b5ce915a5ceca9f841f58bae5df..b8f2d7e80c12c5e71a23783b08b3dbee38c249c4 100755
|
| --- a/devil/devil/android/apk_helper_test.py
|
| +++ b/devil/devil/android/apk_helper_test.py
|
| @@ -3,6 +3,8 @@
|
| # Use of this source code is governed by a BSD-style license that can be
|
| # found in the LICENSE file.
|
|
|
| +import unittest
|
| +
|
| from devil import base_error
|
| from devil import devil_env
|
| from devil.android import apk_helper
|
| @@ -29,6 +31,27 @@ _MANIFEST_DUMP = """N: android=http://schemas.android.com/apk/res/android
|
| E: service (line=7)
|
| A: android:name(0x01010001)="org.chromium.RandomService" (Raw: "org.chromium.RandomService")
|
| A: android:isolatedProcess(0x01010888)=(type 0x12)0xffffffff
|
| + E: activity (line=173)
|
| + A: android:name(0x01010003)=".MainActivity" (Raw: ".MainActivity")
|
| + A: android:exported(0x01010010)=(type 0x12)0xffffffff
|
| + E: intent-filter (line=177)
|
| + E: action (line=178)
|
| + A: android:name(0x01010003)="android.intent.action.MAIN" (Raw: "android.intent.action.MAIN")
|
| + E: category (line=180)
|
| + A: android:name(0x01010003)="android.intent.category.DEFAULT" (Raw: "android.intent.category.DEFAULT")
|
| + E: category (line=181)
|
| + A: android:name(0x01010003)="android.intent.category.LAUNCHER" (Raw: "android.intent.category.LAUNCHER")
|
| + E: activity-alias (line=173)
|
| + A: android:name(0x01010003)="org.chromium.ViewActivity" (Raw: "org.chromium.ViewActivity")
|
| + A: android:exported(0x01010010)=(type 0x12)0xffffffff
|
| + A: android:targetActivity(0x01010202)="org.chromium.ActivityName" (Raw: "org.chromium.ActivityName")
|
| + E: intent-filter (line=191)
|
| + E: action (line=192)
|
| + A: android:name(0x01010003)="android.intent.action.VIEW" (Raw: "android.intent.action.VIEW")
|
| + E: data (line=198)
|
| + A: android:scheme(0x01010027)="http" (Raw: "http")
|
| + E: data (line=199)
|
| + A: android:scheme(0x01010027)="https" (Raw: "https")
|
| E: instrumentation (line=8)
|
| A: android:label(0x01010001)="abc" (Raw: "abc")
|
| A: android:name(0x01010003)="org.chromium.RandomJUnit4TestRunner" (Raw: "org.chromium.RandomJUnit4TestRunner")
|
| @@ -94,19 +117,25 @@ class ApkHelperTest(mock_calls.TestCase):
|
|
|
| def testGetInstrumentationName(self):
|
| with _MockAaptDump(_MANIFEST_DUMP):
|
| - helper = apk_helper.ApkHelper("")
|
| + helper = apk_helper.ApkHelper('')
|
| with self.assertRaises(base_error.BaseError):
|
| helper.GetInstrumentationName()
|
|
|
| def testGetActivityName(self):
|
| with _MockAaptDump(_MANIFEST_DUMP):
|
| - helper = apk_helper.ApkHelper("")
|
| + helper = apk_helper.ApkHelper('')
|
| self.assertEquals(
|
| - helper.GetActivityName(), 'org.chromium.ActivityName')
|
| + helper.GetActivityName(), 'org.chromium.abc.MainActivity')
|
| +
|
| + def testGetViewActivityName(self):
|
| + with _MockAaptDump(_MANIFEST_DUMP):
|
| + helper = apk_helper.ApkHelper('')
|
| + self.assertEquals(
|
| + helper.GetViewActivityName(), 'org.chromium.ViewActivity')
|
|
|
| def testGetAllInstrumentations(self):
|
| with _MockAaptDump(_MANIFEST_DUMP):
|
| - helper = apk_helper.ApkHelper("")
|
| + helper = apk_helper.ApkHelper('')
|
| all_instrumentations = helper.GetAllInstrumentations()
|
| self.assertEquals(len(all_instrumentations), 2)
|
| self.assertEquals(all_instrumentations[0]['android:name'],
|
| @@ -116,12 +145,12 @@ class ApkHelperTest(mock_calls.TestCase):
|
|
|
| def testGetPackageName(self):
|
| with _MockAaptDump(_MANIFEST_DUMP):
|
| - helper = apk_helper.ApkHelper("")
|
| + helper = apk_helper.ApkHelper('')
|
| self.assertEquals(helper.GetPackageName(), 'org.chromium.abc')
|
|
|
| def testGetPermssions(self):
|
| with _MockAaptDump(_MANIFEST_DUMP):
|
| - helper = apk_helper.ApkHelper("")
|
| + helper = apk_helper.ApkHelper('')
|
| all_permissions = helper.GetPermissions()
|
| self.assertEquals(len(all_permissions), 3)
|
| self.assertTrue('android.permission.INTERNET' in all_permissions)
|
| @@ -132,38 +161,41 @@ class ApkHelperTest(mock_calls.TestCase):
|
|
|
| def testGetSplitName(self):
|
| with _MockAaptDump(_MANIFEST_DUMP):
|
| - helper = apk_helper.ApkHelper("")
|
| + helper = apk_helper.ApkHelper('')
|
| self.assertEquals(helper.GetSplitName(), 'random_split')
|
|
|
| def testHasIsolatedProcesses_noApplication(self):
|
| with _MockAaptDump(_NO_APPLICATION):
|
| - helper = apk_helper.ApkHelper("")
|
| + helper = apk_helper.ApkHelper('')
|
| self.assertFalse(helper.HasIsolatedProcesses())
|
|
|
| def testHasIsolatedProcesses_noServices(self):
|
| with _MockAaptDump(_NO_SERVICES):
|
| - helper = apk_helper.ApkHelper("")
|
| + helper = apk_helper.ApkHelper('')
|
| self.assertFalse(helper.HasIsolatedProcesses())
|
|
|
| def testHasIsolatedProcesses_oneNotIsolatedProcess(self):
|
| with _MockAaptDump(_NO_ISOLATED_SERVICES):
|
| - helper = apk_helper.ApkHelper("")
|
| + helper = apk_helper.ApkHelper('')
|
| self.assertFalse(helper.HasIsolatedProcesses())
|
|
|
| def testHasIsolatedProcesses_oneIsolatedProcess(self):
|
| with _MockAaptDump(_MANIFEST_DUMP):
|
| - helper = apk_helper.ApkHelper("")
|
| + helper = apk_helper.ApkHelper('')
|
| self.assertTrue(helper.HasIsolatedProcesses())
|
|
|
| def testGetSingleInstrumentationName(self):
|
| with _MockAaptDump(_SINGLE_INSTRUMENTATION_MANIFEST_DUMP):
|
| - helper = apk_helper.ApkHelper("")
|
| + helper = apk_helper.ApkHelper('')
|
| self.assertEquals('org.chromium.RandomTestRunner',
|
| helper.GetInstrumentationName())
|
|
|
| def testGetSingleJUnit4InstrumentationName(self):
|
| with _MockAaptDump(_SINGLE_J4_INSTRUMENTATION_MANIFEST_DUMP):
|
| - helper = apk_helper.ApkHelper("")
|
| + helper = apk_helper.ApkHelper('')
|
| self.assertEquals('org.chromium.RandomJ4TestRunner',
|
| helper.GetInstrumentationName())
|
|
|
| +
|
| +if __name__ == '__main__':
|
| + unittest.main(verbosity=2)
|
|
|