Chromium Code Reviews| 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(); |
| + } |
| + }); |
| + } |
| +} |