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

Unified Diff: chrome/android/webapk/libs/client/junit/src/org/chromium/webapk/lib/client/WebApkServiceConnectionManagerTest.java

Issue 2974573002: Refactor WebApkServiceConnectionManager. (Closed)
Patch Set: Clean up. Created 3 years, 5 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: chrome/android/webapk/libs/client/junit/src/org/chromium/webapk/lib/client/WebApkServiceConnectionManagerTest.java
diff --git a/chrome/android/webapk/libs/client/junit/src/org/chromium/webapk/lib/client/WebApkServiceConnectionManagerTest.java b/chrome/android/webapk/libs/client/junit/src/org/chromium/webapk/lib/client/WebApkServiceConnectionManagerTest.java
index 6f486c90c7f5fecdd5951a0698805954b48b31b9..11a3e53db25e2d8d694532283f876c5b15932d8e 100644
--- a/chrome/android/webapk/libs/client/junit/src/org/chromium/webapk/lib/client/WebApkServiceConnectionManagerTest.java
+++ b/chrome/android/webapk/libs/client/junit/src/org/chromium/webapk/lib/client/WebApkServiceConnectionManagerTest.java
@@ -4,26 +4,28 @@
package org.chromium.webapk.lib.client;
+import android.content.ComponentName;
import android.content.Context;
import android.content.ContextWrapper;
import android.content.Intent;
import android.content.ServiceConnection;
-
-import org.chromium.testing.local.CustomShadowAsyncTask;
-import org.chromium.testing.local.LocalRobolectricTestRunner;
-import org.chromium.webapk.lib.runtime_library.IWebApkApi;
+import android.os.IBinder;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
+import org.mockito.Mockito;
import org.robolectric.RuntimeEnvironment;
import org.robolectric.Shadows;
import org.robolectric.annotation.Config;
import org.robolectric.shadows.ShadowApplication;
+import org.chromium.testing.local.CustomShadowAsyncTask;
+import org.chromium.testing.local.LocalRobolectricTestRunner;
+
/**
- * Unit tests for {@link org.chromium.libs.client.WebApkServiceConnectionManager}.
+ * Unit tests for {@link org.chromium.webapk.lib.client.WebApkServiceConnectionManager}.
*/
@RunWith(LocalRobolectricTestRunner.class)
@Config(manifest = Config.NONE, shadows = {CustomShadowAsyncTask.class})
@@ -31,6 +33,8 @@ public class WebApkServiceConnectionManagerTest {
private static final String WEB_APK_PACKAGE = "com.webapk.package";
+ private static final String CATEGORY_WEBAPK_SERVICE_API = "android.intent.category.WEBAPK_API";
+
private ShadowApplication mShadowApplication;
private WebApkServiceConnectionManager mConnectionManager;
@@ -38,7 +42,7 @@ public class WebApkServiceConnectionManagerTest {
public boolean mGotResult = false;
@Override
- public void onConnected(IWebApkApi api) {
+ public void onConnected(IBinder service) {
mGotResult = true;
}
}
@@ -46,7 +50,11 @@ public class WebApkServiceConnectionManagerTest {
@Before
public void setUp() {
mShadowApplication = Shadows.shadowOf(RuntimeEnvironment.application);
- mConnectionManager = new WebApkServiceConnectionManager();
+ mConnectionManager =
+ new WebApkServiceConnectionManager(CATEGORY_WEBAPK_SERVICE_API, null /* action*/);
+ Intent intent = mConnectionManager.createConnectIntent(WEB_APK_PACKAGE);
+ mShadowApplication.setComponentNameAndServiceForBindServiceForIntent(
+ intent, new ComponentName(WEB_APK_PACKAGE, ""), Mockito.mock(IBinder.class));
}
/**
@@ -134,7 +142,7 @@ public class WebApkServiceConnectionManagerTest {
Assert.assertEquals(WEB_APK_PACKAGE, getNextStartedServicePackage());
Assert.assertEquals(null, getNextStartedServicePackage());
- mConnectionManager.disconnect(RuntimeEnvironment.application, WEB_APK_PACKAGE);
+ mConnectionManager.disconnect(RuntimeEnvironment.application);
mConnectionManager.connect(
RuntimeEnvironment.application, WEB_APK_PACKAGE, new TestCallback());
Assert.assertEquals(WEB_APK_PACKAGE, getNextStartedServicePackage());

Powered by Google App Engine
This is Rietveld 408576698