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