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

Side by Side Diff: mojo/android/javatests/src/org/chromium/mojo/MojoTestCase.java

Issue 1407233017: Define a Java-side global application context. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Undo changes to ApplicationStatus Created 5 years, 1 month 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.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
9 import org.chromium.base.ContextUtils;
10 import org.chromium.base.annotations.JNINamespace; 10 import org.chromium.base.annotations.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) 28 LibraryLoader.get(LibraryProcessType.PROCESS_BROWSER)
29 .ensureInitialized(getInstrumentation().getTargetContext()); 29 .ensureInitialized(getInstrumentation().getTargetContext());
30 nativeInitApplicationContext(getInstrumentation().getTargetContext()); 30 ContextUtils.initApplicationContext(getInstrumentation().getTargetContex t());
31 nativeInit();
31 mTestEnvironmentPointer = nativeSetupTestEnvironment(); 32 mTestEnvironmentPointer = nativeSetupTestEnvironment();
32 } 33 }
33 34
34 /** 35 /**
35 * @see android.test.InstrumentationTestCase#tearDown() 36 * @see android.test.InstrumentationTestCase#tearDown()
36 */ 37 */
37 @Override 38 @Override
38 protected void tearDown() throws Exception { 39 protected void tearDown() throws Exception {
39 nativeTearDownTestEnvironment(mTestEnvironmentPointer); 40 nativeTearDownTestEnvironment(mTestEnvironmentPointer);
40 super.tearDown(); 41 super.tearDown();
41 } 42 }
42 43
43 /** 44 /**
44 * Runs the run loop for the given time. 45 * Runs the run loop for the given time.
45 */ 46 */
46 protected void runLoop(long timeoutMS) { 47 protected void runLoop(long timeoutMS) {
47 nativeRunLoop(timeoutMS); 48 nativeRunLoop(timeoutMS);
48 } 49 }
49 50
50 /** 51 /**
51 * Runs the run loop until no handle or task are immediately available. 52 * Runs the run loop until no handle or task are immediately available.
52 */ 53 */
53 protected void runLoopUntilIdle() { 54 protected void runLoopUntilIdle() {
54 nativeRunLoop(0); 55 nativeRunLoop(0);
55 } 56 }
56 57
57 private native void nativeInitApplicationContext(Context context); 58 private native void nativeInit();
58 59
59 private native long nativeSetupTestEnvironment(); 60 private native long nativeSetupTestEnvironment();
60 61
61 private native void nativeTearDownTestEnvironment(long testEnvironment); 62 private native void nativeTearDownTestEnvironment(long testEnvironment);
62 63
63 private native void nativeRunLoop(long timeoutMS); 64 private native void nativeRunLoop(long timeoutMS);
64 65
65 } 66 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698