| 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; |
| 11 import org.chromium.base.test.util.RetryOnFailure; |
| 11 import org.chromium.content.browser.InterfaceRegistry.ImplementationFactory; | 12 import org.chromium.content.browser.InterfaceRegistry.ImplementationFactory; |
| 12 import org.chromium.content_shell.ShellMojoTestUtils; | 13 import org.chromium.content_shell.ShellMojoTestUtils; |
| 13 import org.chromium.content_shell_apk.ContentShellTestBase; | 14 import org.chromium.content_shell_apk.ContentShellTestBase; |
| 14 import org.chromium.mojo.bindings.ConnectionErrorHandler; | 15 import org.chromium.mojo.bindings.ConnectionErrorHandler; |
| 15 import org.chromium.mojo.bindings.InterfaceRequest; | 16 import org.chromium.mojo.bindings.InterfaceRequest; |
| 16 import org.chromium.mojo.bindings.test.mojom.math.Calculator; | 17 import org.chromium.mojo.bindings.test.mojom.math.Calculator; |
| 17 import org.chromium.mojo.system.MojoException; | 18 import org.chromium.mojo.system.MojoException; |
| 18 import org.chromium.mojo.system.Pair; | 19 import org.chromium.mojo.system.Pair; |
| 19 import org.chromium.mojo.system.impl.CoreImpl; | 20 import org.chromium.mojo.system.impl.CoreImpl; |
| 20 | 21 |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 } | 111 } |
| 111 ShellMojoTestUtils.tearDownTestEnvironment(mNativeTestEnvironment); | 112 ShellMojoTestUtils.tearDownTestEnvironment(mNativeTestEnvironment); |
| 112 mNativeTestEnvironment = 0; | 113 mNativeTestEnvironment = 0; |
| 113 super.tearDown(); | 114 super.tearDown(); |
| 114 } | 115 } |
| 115 | 116 |
| 116 /** | 117 /** |
| 117 * Verifies that remote interface can be requested and works. | 118 * Verifies that remote interface can be requested and works. |
| 118 */ | 119 */ |
| 119 @SmallTest | 120 @SmallTest |
| 121 @RetryOnFailure |
| 120 public void testGetInterface() { | 122 public void testGetInterface() { |
| 121 Pair<InterfaceRegistry, InterfaceProvider> registryAndProvider = | 123 Pair<InterfaceRegistry, InterfaceProvider> registryAndProvider = |
| 122 ShellMojoTestUtils.createInterfaceRegistryAndProvider(mNativeTes
tEnvironment); | 124 ShellMojoTestUtils.createInterfaceRegistryAndProvider(mNativeTes
tEnvironment); |
| 123 InterfaceRegistry registry = registryAndProvider.first; | 125 InterfaceRegistry registry = registryAndProvider.first; |
| 124 InterfaceProvider provider = registryAndProvider.second; | 126 InterfaceProvider provider = registryAndProvider.second; |
| 125 | 127 |
| 126 // Add the Calculator interface. | 128 // Add the Calculator interface. |
| 127 registry.addInterface(Calculator.MANAGER, new CalculatorFactory()); | 129 registry.addInterface(Calculator.MANAGER, new CalculatorFactory()); |
| 128 | 130 |
| 129 Pair<Calculator.Proxy, InterfaceRequest<Calculator>> requestPair = | 131 Pair<Calculator.Proxy, InterfaceRequest<Calculator>> requestPair = |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 195 calculator.getProxyHandler().setErrorHandler(errorHandler); | 197 calculator.getProxyHandler().setErrorHandler(errorHandler); |
| 196 mCloseablesToClose.add(calculator); | 198 mCloseablesToClose.add(calculator); |
| 197 provider.getInterface(Calculator.MANAGER, requestPair.second); | 199 provider.getInterface(Calculator.MANAGER, requestPair.second); |
| 198 | 200 |
| 199 // Spin the message loop and verify that an error occured. | 201 // Spin the message loop and verify that an error occured. |
| 200 assertNull(errorHandler.mLastMojoException); | 202 assertNull(errorHandler.mLastMojoException); |
| 201 ShellMojoTestUtils.runLoop(RUN_LOOP_TIMEOUT_MS); | 203 ShellMojoTestUtils.runLoop(RUN_LOOP_TIMEOUT_MS); |
| 202 assertNotNull(errorHandler.mLastMojoException); | 204 assertNotNull(errorHandler.mLastMojoException); |
| 203 } | 205 } |
| 204 } | 206 } |
| OLD | NEW |