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

Unified Diff: webapk/libs/runtime_library/junit/src/org/chromium/webapk/lib/runtime_library/WebApkServiceImplTest.java

Issue 1965583002: Move //webapk to //chrome/android/webapk (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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
« no previous file with comments | « webapk/libs/runtime_library/BUILD.gn ('k') | webapk/libs/runtime_library/src/README » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webapk/libs/runtime_library/junit/src/org/chromium/webapk/lib/runtime_library/WebApkServiceImplTest.java
diff --git a/webapk/libs/runtime_library/junit/src/org/chromium/webapk/lib/runtime_library/WebApkServiceImplTest.java b/webapk/libs/runtime_library/junit/src/org/chromium/webapk/lib/runtime_library/WebApkServiceImplTest.java
deleted file mode 100644
index a3cd1ced10fd8912012140f9648eda535c1dba55..0000000000000000000000000000000000000000
--- a/webapk/libs/runtime_library/junit/src/org/chromium/webapk/lib/runtime_library/WebApkServiceImplTest.java
+++ /dev/null
@@ -1,100 +0,0 @@
-// Copyright 2016 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-package org.chromium.webapk.lib.runtime_library;
-
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-import android.content.pm.PackageManager;
-import android.os.Bundle;
-import android.os.RemoteException;
-
-import org.chromium.testing.local.LocalRobolectricTestRunner;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.robolectric.Robolectric;
-import org.robolectric.annotation.Config;
-
-/**
- * Unit tests for {@link org.chromium.webapk.WebApkServiceImpl}.
- */
-@RunWith(LocalRobolectricTestRunner.class)
-@Config(manifest = Config.NONE)
-public class WebApkServiceImplTest {
-
- private static final String ALLOWED_PACKAGE = "com.allowed.package";
- private static final int ALLOWED_UID = 0;
-
- private PackageManager mPackageManager;
-
- @Before
- public void setUp() {
- mPackageManager = mock(PackageManager.class);
- when(mPackageManager.getPackagesForUid(ALLOWED_UID)).thenReturn(
- new String[] { ALLOWED_PACKAGE });
- }
-
- @Test
- public void testAllowedCaller() {
- WebApkServiceImpl service =
- new WebApkServiceImpl(Robolectric.application, createBundle(ALLOWED_PACKAGE));
- assertTrue(service.checkHasAccess(ALLOWED_UID, mPackageManager));
- }
-
- @Test
- public void testProhibitedCaller() {
- WebApkServiceImpl service =
- new WebApkServiceImpl(Robolectric.application, createBundle(ALLOWED_PACKAGE));
- assertFalse(service.checkHasAccess(ALLOWED_UID + 1, mPackageManager));
- }
-
- @Test
- public void testOnTransactThrowsIfNoPermission() {
- WebApkServiceImpl service = new WebApkServiceImpl(
- Robolectric.application, createBundle(ALLOWED_PACKAGE)) {
- @Override
- boolean checkHasAccess(int uid, PackageManager packageManager) {
- return false;
- }
- };
- try {
- service.onTransact(0, null, null, 0);
- Assert.fail("Should have thrown an exception for no access.");
- } catch (RemoteException e) {
- }
- }
-
- @Test
- public void testOnTransactRunsIfHasPermission() {
- WebApkServiceImpl service = new WebApkServiceImpl(
- Robolectric.application, createBundle(ALLOWED_PACKAGE)) {
- @Override
- boolean checkHasAccess(int uid, PackageManager packageManager) {
- return true;
- }
- };
- try {
- service.onTransact(0, null, null, 0);
- } catch (RemoteException e) {
- e.printStackTrace();
- Assert.fail("Should not have thrown an exception when permission is granted.");
- }
- }
-
- /**
- * Creates Bundle to pass to WebApkServiceImpl constructor.
- * @param expectedHostBrowser
- * @return The bundle
- */
- private static Bundle createBundle(String expectedHostBrowser) {
- Bundle bundle = new Bundle();
- bundle.putString(WebApkServiceImpl.KEY_EXPECTED_HOST_BROWSER, expectedHostBrowser);
- return bundle;
- }
-}
« no previous file with comments | « webapk/libs/runtime_library/BUILD.gn ('k') | webapk/libs/runtime_library/src/README » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698