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

Unified Diff: components/devtools_bridge/android/client/javatests/src/org/chromium/components/devtools_bridge/WebClientTest.java

Issue 736363002: Stub for web-base client for DevTools bridge and tests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month 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: components/devtools_bridge/android/client/javatests/src/org/chromium/components/devtools_bridge/WebClientTest.java
diff --git a/components/devtools_bridge/android/client/javatests/src/org/chromium/components/devtools_bridge/WebClientTest.java b/components/devtools_bridge/android/client/javatests/src/org/chromium/components/devtools_bridge/WebClientTest.java
new file mode 100644
index 0000000000000000000000000000000000000000..58b45c9bb38fb3ce8da93b1deed27c03199ffb06
--- /dev/null
+++ b/components/devtools_bridge/android/client/javatests/src/org/chromium/components/devtools_bridge/WebClientTest.java
@@ -0,0 +1,54 @@
+// Copyright 2014 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.components.devtools_bridge;
+
+import android.content.Context;
+import android.test.InstrumentationTestCase;
+import android.test.suitebuilder.annotation.SmallTest;
+import android.util.Log;
+
+import org.chromium.base.ThreadUtils;
+import org.chromium.base.library_loader.ProcessInitException;
+import org.chromium.chrome.browser.profiles.Profile;
+import org.chromium.content.browser.BrowserStartupController;
+
+/**
+ * Tests for {@link WebClient}. WebClient is not intended to run on Android but
+ * it can. It is useful for tests: we can test it against the server in the
+ * same process (without dependency on network and cloud services).
+ */
+public class WebClientTest extends InstrumentationTestCase {
+ private static final String TAG = "WebClientTest";
+ private Profile mProfile;
+
+ @Override
+ protected void setUp() throws Exception {
mnaganov (inactive) 2014/11/20 19:02:42 No need to override if you only call super.
SeRya 2014/11/20 21:10:38 Done.
+ super.setUp();
+ }
+
+ protected void startChromeBrowserProcessSyncOnUIThread() {
+ final Context targetContext = getInstrumentation().getTargetContext();
+ try {
+ BrowserStartupController.get(targetContext).startBrowserProcessesSync(false);
+ } catch (ProcessInitException e) {
mnaganov (inactive) 2014/11/20 19:02:42 You can avoid catching exceptions yourself, if you
SeRya 2014/11/20 21:10:38 It would be so unless this method is used not insi
mnaganov (inactive) 2014/11/20 21:54:48 I'm not convinced. If the operation has thrown an
SeRya 2014/11/20 22:37:24 Done.
+ Log.e(TAG, "Unable to load native library.", e);
+ fail("Unable to load native library");
+ }
+ mProfile = Profile.getLastUsedProfile();
+ }
+
+ @SmallTest
+ public void testCreationWebClient() {
+ ThreadUtils.runOnUiThreadBlocking(new Runnable() {
+ @Override
+ public void run() {
+ startChromeBrowserProcessSyncOnUIThread();
+ assert mProfile != null;
+
+ new WebClient(mProfile).dispose();
+ }
+ });
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698