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.mojo; | 5 package org.chromium.mojo; |
6 | 6 |
7 import android.content.Context; | |
8 import android.test.InstrumentationTestCase; | 7 import android.test.InstrumentationTestCase; |
9 | 8 |
10 import org.chromium.base.ContextUtils; | 9 import org.chromium.base.ContextUtils; |
11 import org.chromium.base.annotations.JNINamespace; | 10 import org.chromium.base.annotations.JNINamespace; |
12 import org.chromium.base.library_loader.LibraryLoader; | 11 import org.chromium.base.library_loader.LibraryLoader; |
13 import org.chromium.base.library_loader.LibraryProcessType; | 12 import org.chromium.base.library_loader.LibraryProcessType; |
14 | 13 |
15 /** | 14 /** |
16 * Base class to test mojo. Setup the environment. | 15 * Base class to test mojo. Setup the environment. |
17 */ | 16 */ |
18 @JNINamespace("mojo::android") | 17 @JNINamespace("mojo::android") |
19 public class MojoTestCase extends InstrumentationTestCase { | 18 public class MojoTestCase extends InstrumentationTestCase { |
20 | 19 |
21 private long mTestEnvironmentPointer; | 20 private long mTestEnvironmentPointer; |
22 | 21 |
23 /** | 22 /** |
24 * @see junit.framework.TestCase#setUp() | 23 * @see junit.framework.TestCase#setUp() |
25 */ | 24 */ |
26 @Override | 25 @Override |
27 protected void setUp() throws Exception { | 26 protected void setUp() throws Exception { |
28 super.setUp(); | 27 super.setUp(); |
29 Context appContext = getInstrumentation().getTargetContext().getApplicat
ionContext(); | 28 ContextUtils.initApplicationContext( |
30 ContextUtils.initApplicationContext(appContext); | 29 getInstrumentation().getTargetContext().getApplicationContext())
; |
31 LibraryLoader.get(LibraryProcessType.PROCESS_BROWSER).ensureInitialized(
appContext); | 30 LibraryLoader.get(LibraryProcessType.PROCESS_BROWSER).ensureInitialized(
); |
32 nativeInit(); | 31 nativeInit(); |
33 mTestEnvironmentPointer = nativeSetupTestEnvironment(); | 32 mTestEnvironmentPointer = nativeSetupTestEnvironment(); |
34 } | 33 } |
35 | 34 |
36 /** | 35 /** |
37 * @see android.test.InstrumentationTestCase#tearDown() | 36 * @see android.test.InstrumentationTestCase#tearDown() |
38 */ | 37 */ |
39 @Override | 38 @Override |
40 protected void tearDown() throws Exception { | 39 protected void tearDown() throws Exception { |
41 nativeTearDownTestEnvironment(mTestEnvironmentPointer); | 40 nativeTearDownTestEnvironment(mTestEnvironmentPointer); |
(...skipping 16 matching lines...) Expand all Loading... |
58 | 57 |
59 private native void nativeInit(); | 58 private native void nativeInit(); |
60 | 59 |
61 private native long nativeSetupTestEnvironment(); | 60 private native long nativeSetupTestEnvironment(); |
62 | 61 |
63 private native void nativeTearDownTestEnvironment(long testEnvironment); | 62 private native void nativeTearDownTestEnvironment(long testEnvironment); |
64 | 63 |
65 private native void nativeRunLoop(long timeoutMS); | 64 private native void nativeRunLoop(long timeoutMS); |
66 | 65 |
67 } | 66 } |
OLD | NEW |