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

Side by Side Diff: content/public/android/javatests/src/org/chromium/content/browser/InterfaceRegistryTest.java

Issue 2247143004: Remove app context init from LibraryLoader. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix ChildProcessServiceImpl. Created 4 years, 2 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package org.chromium.content.browser; 5 package org.chromium.content.browser;
6 6
7 import android.test.suitebuilder.annotation.SmallTest; 7 import android.test.suitebuilder.annotation.SmallTest;
8 8
9 import org.chromium.base.ContextUtils;
9 import org.chromium.base.library_loader.LibraryLoader; 10 import org.chromium.base.library_loader.LibraryLoader;
10 import org.chromium.base.library_loader.LibraryProcessType; 11 import org.chromium.base.library_loader.LibraryProcessType;
11 import org.chromium.base.test.util.DisabledTest; 12 import org.chromium.base.test.util.DisabledTest;
12 import org.chromium.base.test.util.RetryOnFailure; 13 import org.chromium.base.test.util.RetryOnFailure;
13 import org.chromium.content.browser.InterfaceRegistry.ImplementationFactory; 14 import org.chromium.content.browser.InterfaceRegistry.ImplementationFactory;
14 import org.chromium.content_shell.ShellMojoTestUtils; 15 import org.chromium.content_shell.ShellMojoTestUtils;
15 import org.chromium.content_shell_apk.ContentShellTestBase; 16 import org.chromium.content_shell_apk.ContentShellTestBase;
16 import org.chromium.mojo.bindings.ConnectionErrorHandler; 17 import org.chromium.mojo.bindings.ConnectionErrorHandler;
17 import org.chromium.mojo.bindings.InterfaceRequest; 18 import org.chromium.mojo.bindings.InterfaceRequest;
18 import org.chromium.mojo.bindings.test.mojom.math.Calculator; 19 import org.chromium.mojo.bindings.test.mojom.math.Calculator;
19 import org.chromium.mojo.system.MojoException; 20 import org.chromium.mojo.system.MojoException;
20 import org.chromium.mojo.system.Pair; 21 import org.chromium.mojo.system.Pair;
21 import org.chromium.mojo.system.impl.CoreImpl; 22 import org.chromium.mojo.system.impl.CoreImpl;
22 23
23 import java.io.Closeable; 24 import java.io.Closeable;
24 import java.util.ArrayList; 25 import java.util.ArrayList;
25 import java.util.List; 26 import java.util.List;
26 27
27 /** 28 /**
28 * Instrumentation tests for InterfaceRegistry. 29 * Instrumentation tests for InterfaceRegistry.
29 */ 30 */
30 public class InterfaceRegistryTest extends ContentShellTestBase { 31 public class InterfaceRegistryTest extends ContentShellTestBase {
31 32
32 private static final long RUN_LOOP_TIMEOUT_MS = 25; 33 private static final long RUN_LOOP_TIMEOUT_MS = 25;
33 34
34 private final List<Closeable> mCloseablesToClose = new ArrayList<Closeable>( ); 35 private final List<Closeable> mCloseablesToClose = new ArrayList<>();
35 private long mNativeTestEnvironment; 36 private long mNativeTestEnvironment;
36 37
37 static class CalcConnectionErrorHandler implements ConnectionErrorHandler { 38 static class CalcConnectionErrorHandler implements ConnectionErrorHandler {
38 39
39 MojoException mLastMojoException; 40 MojoException mLastMojoException;
40 41
41 @Override 42 @Override
42 public void onConnectionError(MojoException e) { 43 public void onConnectionError(MojoException e) {
43 mLastMojoException = e; 44 mLastMojoException = e;
44 } 45 }
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 @Override 93 @Override
93 public Calculator createImpl() { 94 public Calculator createImpl() {
94 return new CalculatorImpl(); 95 return new CalculatorImpl();
95 } 96 }
96 } 97 }
97 98
98 99
99 @Override 100 @Override
100 protected void setUp() throws Exception { 101 protected void setUp() throws Exception {
101 super.setUp(); 102 super.setUp();
102 LibraryLoader.get(LibraryProcessType.PROCESS_BROWSER).ensureInitialized( 103 ContextUtils.initApplicationContext(
103 getInstrumentation().getTargetContext()); 104 getInstrumentation().getTargetContext().getApplicationContext()) ;
105 LibraryLoader.get(LibraryProcessType.PROCESS_BROWSER).ensureInitialized( );
104 launchContentShellWithUrl("about://blank"); 106 launchContentShellWithUrl("about://blank");
105 mNativeTestEnvironment = ShellMojoTestUtils.setupTestEnvironment(); 107 mNativeTestEnvironment = ShellMojoTestUtils.setupTestEnvironment();
106 } 108 }
107 109
108 @Override 110 @Override
109 protected void tearDown() throws Exception { 111 protected void tearDown() throws Exception {
110 for (Closeable c : mCloseablesToClose) { 112 for (Closeable c : mCloseablesToClose) {
111 c.close(); 113 c.close();
112 } 114 }
113 ShellMojoTestUtils.tearDownTestEnvironment(mNativeTestEnvironment); 115 ShellMojoTestUtils.tearDownTestEnvironment(mNativeTestEnvironment);
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 calculator.getProxyHandler().setErrorHandler(errorHandler); 201 calculator.getProxyHandler().setErrorHandler(errorHandler);
200 mCloseablesToClose.add(calculator); 202 mCloseablesToClose.add(calculator);
201 provider.getInterface(Calculator.MANAGER, requestPair.second); 203 provider.getInterface(Calculator.MANAGER, requestPair.second);
202 204
203 // Spin the message loop and verify that an error occured. 205 // Spin the message loop and verify that an error occured.
204 assertNull(errorHandler.mLastMojoException); 206 assertNull(errorHandler.mLastMojoException);
205 ShellMojoTestUtils.runLoop(RUN_LOOP_TIMEOUT_MS); 207 ShellMojoTestUtils.runLoop(RUN_LOOP_TIMEOUT_MS);
206 assertNotNull(errorHandler.mLastMojoException); 208 assertNotNull(errorHandler.mLastMojoException);
207 } 209 }
208 } 210 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698