OLD | NEW |
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.library_loader.LibraryLoader; | 9 import org.chromium.base.library_loader.LibraryLoader; |
10 import org.chromium.base.library_loader.LibraryProcessType; | 10 import org.chromium.base.library_loader.LibraryProcessType; |
(...skipping 13 matching lines...) Expand all Loading... |
24 import java.util.ArrayList; | 24 import java.util.ArrayList; |
25 import java.util.List; | 25 import java.util.List; |
26 | 26 |
27 /** | 27 /** |
28 * Instrumentation tests for InterfaceRegistry. | 28 * Instrumentation tests for InterfaceRegistry. |
29 */ | 29 */ |
30 public class InterfaceRegistryTest extends ContentShellTestBase { | 30 public class InterfaceRegistryTest extends ContentShellTestBase { |
31 | 31 |
32 private static final long RUN_LOOP_TIMEOUT_MS = 25; | 32 private static final long RUN_LOOP_TIMEOUT_MS = 25; |
33 | 33 |
34 private final List<Closeable> mCloseablesToClose = new ArrayList<Closeable>(
); | 34 private final List<Closeable> mCloseablesToClose = new ArrayList<>(); |
35 private long mNativeTestEnvironment; | 35 private long mNativeTestEnvironment; |
36 | 36 |
37 static class CalcConnectionErrorHandler implements ConnectionErrorHandler { | 37 static class CalcConnectionErrorHandler implements ConnectionErrorHandler { |
38 | 38 |
39 MojoException mLastMojoException; | 39 MojoException mLastMojoException; |
40 | 40 |
41 @Override | 41 @Override |
42 public void onConnectionError(MojoException e) { | 42 public void onConnectionError(MojoException e) { |
43 mLastMojoException = e; | 43 mLastMojoException = e; |
44 } | 44 } |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 @Override | 92 @Override |
93 public Calculator createImpl() { | 93 public Calculator createImpl() { |
94 return new CalculatorImpl(); | 94 return new CalculatorImpl(); |
95 } | 95 } |
96 } | 96 } |
97 | 97 |
98 | 98 |
99 @Override | 99 @Override |
100 protected void setUp() throws Exception { | 100 protected void setUp() throws Exception { |
101 super.setUp(); | 101 super.setUp(); |
102 LibraryLoader.get(LibraryProcessType.PROCESS_BROWSER).ensureInitialized( | 102 LibraryLoader.get(LibraryProcessType.PROCESS_BROWSER).ensureInitialized(
); |
103 getInstrumentation().getTargetContext()); | |
104 launchContentShellWithUrl("about://blank"); | 103 launchContentShellWithUrl("about://blank"); |
105 mNativeTestEnvironment = ShellMojoTestUtils.setupTestEnvironment(); | 104 mNativeTestEnvironment = ShellMojoTestUtils.setupTestEnvironment(); |
106 } | 105 } |
107 | 106 |
108 @Override | 107 @Override |
109 protected void tearDown() throws Exception { | 108 protected void tearDown() throws Exception { |
110 for (Closeable c : mCloseablesToClose) { | 109 for (Closeable c : mCloseablesToClose) { |
111 c.close(); | 110 c.close(); |
112 } | 111 } |
113 ShellMojoTestUtils.tearDownTestEnvironment(mNativeTestEnvironment); | 112 ShellMojoTestUtils.tearDownTestEnvironment(mNativeTestEnvironment); |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
199 calculator.getProxyHandler().setErrorHandler(errorHandler); | 198 calculator.getProxyHandler().setErrorHandler(errorHandler); |
200 mCloseablesToClose.add(calculator); | 199 mCloseablesToClose.add(calculator); |
201 provider.getInterface(Calculator.MANAGER, requestPair.second); | 200 provider.getInterface(Calculator.MANAGER, requestPair.second); |
202 | 201 |
203 // Spin the message loop and verify that an error occured. | 202 // Spin the message loop and verify that an error occured. |
204 assertNull(errorHandler.mLastMojoException); | 203 assertNull(errorHandler.mLastMojoException); |
205 ShellMojoTestUtils.runLoop(RUN_LOOP_TIMEOUT_MS); | 204 ShellMojoTestUtils.runLoop(RUN_LOOP_TIMEOUT_MS); |
206 assertNotNull(errorHandler.mLastMojoException); | 205 assertNotNull(errorHandler.mLastMojoException); |
207 } | 206 } |
208 } | 207 } |
OLD | NEW |