Loading apct-tests/perftests/core/AndroidManifest.xml +5 −1 Original line number Diff line number Diff line Loading @@ -10,7 +10,11 @@ <application> <uses-library android:name="android.test.runner" /> <activity android:name="android.perftests.utils.StubActivity" /> <activity android:name="android.perftests.utils.StubActivity"> <intent-filter> <action android:name="com.android.perftests.core.PERFTEST" /> </intent-filter> </activity> <service android:name="android.os.SomeService" android:exported="false" android:process=":some_service" /> </application> Loading apct-tests/perftests/core/src/android/os/PermissionTest.java→apct-tests/perftests/core/src/android/os/PackageManagerPerfTest.java +114 −0 Original line number Diff line number Diff line Loading @@ -19,7 +19,10 @@ package android.os; import static android.content.pm.PackageManager.PERMISSION_DENIED; import static android.content.pm.PackageManager.PERMISSION_GRANTED; import android.content.ComponentName; import android.content.Context; import android.content.Intent; import android.content.pm.PackageManager; import android.perftests.utils.BenchmarkState; import android.perftests.utils.PerfStatusReporter; import android.support.test.InstrumentationRegistry; Loading @@ -33,34 +36,79 @@ import org.junit.runner.RunWith; @RunWith(AndroidJUnit4.class) @LargeTest public class PermissionTest { private static final String PERMISSION_HAS_NAME = "com.android.perftests.core.TestPermission"; private static final String PERMISSION_DOESNT_HAVE_NAME = public class PackageManagerPerfTest { private static final String PERMISSION_NAME_EXISTS = "com.android.perftests.core.TestPermission"; private static final String PERMISSION_NAME_DOESNT_EXIST = "com.android.perftests.core.TestBadPermission"; private static final String THIS_PACKAGE_NAME = "com.android.perftests.core"; private static final ComponentName TEST_ACTIVITY = new ComponentName("com.android.perftests.core", "android.perftests.utils.StubActivity"); @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); @Test public void testHasPermission() { public void testCheckPermissionExists() { final BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); final Context context = InstrumentationRegistry.getTargetContext(); final PackageManager pm = InstrumentationRegistry.getTargetContext().getPackageManager(); final String packageName = TEST_ACTIVITY.getPackageName(); while (state.keepRunning()) { int ret = pm.checkPermission(PERMISSION_NAME_EXISTS, packageName); } } @Test public void testCheckPermissionDoesntExist() { final BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); final PackageManager pm = InstrumentationRegistry.getTargetContext().getPackageManager(); final String packageName = TEST_ACTIVITY.getPackageName(); while (state.keepRunning()) { int ret = pm.checkPermission(PERMISSION_NAME_DOESNT_EXIST, packageName); } } @Test public void testQueryIntentActivities() { final BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); final PackageManager pm = InstrumentationRegistry.getTargetContext().getPackageManager(); final Intent intent = new Intent("com.android.perftests.core.PERFTEST"); while (state.keepRunning()) { pm.queryIntentActivities(intent, 0); } } @Test public void testGetPackageInfo() throws Exception { final BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); final PackageManager pm = InstrumentationRegistry.getTargetContext().getPackageManager(); final String packageName = TEST_ACTIVITY.getPackageName(); while (state.keepRunning()) { int ret = context.getPackageManager().checkPermission(PERMISSION_HAS_NAME, THIS_PACKAGE_NAME); pm.getPackageInfo(packageName, 0); } } @Test public void testDoesntHavePermission() { public void testGetApplicationInfo() throws Exception { final BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); final Context context = InstrumentationRegistry.getTargetContext(); final PackageManager pm = InstrumentationRegistry.getTargetContext().getPackageManager(); final String packageName = TEST_ACTIVITY.getPackageName(); while (state.keepRunning()) { int ret = context.getPackageManager().checkPermission(PERMISSION_DOESNT_HAVE_NAME, THIS_PACKAGE_NAME); pm.getApplicationInfo(packageName, 0); } } @Test public void testGetActivityInfo() throws Exception { final BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); final PackageManager pm = InstrumentationRegistry.getTargetContext().getPackageManager(); while (state.keepRunning()) { pm.getActivityInfo(TEST_ACTIVITY, 0); } } } Loading
apct-tests/perftests/core/AndroidManifest.xml +5 −1 Original line number Diff line number Diff line Loading @@ -10,7 +10,11 @@ <application> <uses-library android:name="android.test.runner" /> <activity android:name="android.perftests.utils.StubActivity" /> <activity android:name="android.perftests.utils.StubActivity"> <intent-filter> <action android:name="com.android.perftests.core.PERFTEST" /> </intent-filter> </activity> <service android:name="android.os.SomeService" android:exported="false" android:process=":some_service" /> </application> Loading
apct-tests/perftests/core/src/android/os/PermissionTest.java→apct-tests/perftests/core/src/android/os/PackageManagerPerfTest.java +114 −0 Original line number Diff line number Diff line Loading @@ -19,7 +19,10 @@ package android.os; import static android.content.pm.PackageManager.PERMISSION_DENIED; import static android.content.pm.PackageManager.PERMISSION_GRANTED; import android.content.ComponentName; import android.content.Context; import android.content.Intent; import android.content.pm.PackageManager; import android.perftests.utils.BenchmarkState; import android.perftests.utils.PerfStatusReporter; import android.support.test.InstrumentationRegistry; Loading @@ -33,34 +36,79 @@ import org.junit.runner.RunWith; @RunWith(AndroidJUnit4.class) @LargeTest public class PermissionTest { private static final String PERMISSION_HAS_NAME = "com.android.perftests.core.TestPermission"; private static final String PERMISSION_DOESNT_HAVE_NAME = public class PackageManagerPerfTest { private static final String PERMISSION_NAME_EXISTS = "com.android.perftests.core.TestPermission"; private static final String PERMISSION_NAME_DOESNT_EXIST = "com.android.perftests.core.TestBadPermission"; private static final String THIS_PACKAGE_NAME = "com.android.perftests.core"; private static final ComponentName TEST_ACTIVITY = new ComponentName("com.android.perftests.core", "android.perftests.utils.StubActivity"); @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); @Test public void testHasPermission() { public void testCheckPermissionExists() { final BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); final Context context = InstrumentationRegistry.getTargetContext(); final PackageManager pm = InstrumentationRegistry.getTargetContext().getPackageManager(); final String packageName = TEST_ACTIVITY.getPackageName(); while (state.keepRunning()) { int ret = pm.checkPermission(PERMISSION_NAME_EXISTS, packageName); } } @Test public void testCheckPermissionDoesntExist() { final BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); final PackageManager pm = InstrumentationRegistry.getTargetContext().getPackageManager(); final String packageName = TEST_ACTIVITY.getPackageName(); while (state.keepRunning()) { int ret = pm.checkPermission(PERMISSION_NAME_DOESNT_EXIST, packageName); } } @Test public void testQueryIntentActivities() { final BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); final PackageManager pm = InstrumentationRegistry.getTargetContext().getPackageManager(); final Intent intent = new Intent("com.android.perftests.core.PERFTEST"); while (state.keepRunning()) { pm.queryIntentActivities(intent, 0); } } @Test public void testGetPackageInfo() throws Exception { final BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); final PackageManager pm = InstrumentationRegistry.getTargetContext().getPackageManager(); final String packageName = TEST_ACTIVITY.getPackageName(); while (state.keepRunning()) { int ret = context.getPackageManager().checkPermission(PERMISSION_HAS_NAME, THIS_PACKAGE_NAME); pm.getPackageInfo(packageName, 0); } } @Test public void testDoesntHavePermission() { public void testGetApplicationInfo() throws Exception { final BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); final Context context = InstrumentationRegistry.getTargetContext(); final PackageManager pm = InstrumentationRegistry.getTargetContext().getPackageManager(); final String packageName = TEST_ACTIVITY.getPackageName(); while (state.keepRunning()) { int ret = context.getPackageManager().checkPermission(PERMISSION_DOESNT_HAVE_NAME, THIS_PACKAGE_NAME); pm.getApplicationInfo(packageName, 0); } } @Test public void testGetActivityInfo() throws Exception { final BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); final PackageManager pm = InstrumentationRegistry.getTargetContext().getPackageManager(); while (state.keepRunning()) { pm.getActivityInfo(TEST_ACTIVITY, 0); } } }