3adb2fb0899451db9bd8eb6ccf081e6d61ddfe9a
[platform/framework/web/crosswalk.git] / src / mojo / android / javatests / src / org / chromium / mojo / MojoTestCase.java
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
3 // found in the LICENSE file.
4
5 package org.chromium.mojo;
6
7 import android.content.Context;
8 import android.test.InstrumentationTestCase;
9
10 import org.chromium.base.JNINamespace;
11 import org.chromium.base.library_loader.LibraryLoader;
12
13 /**
14  * Base class to test mojo. Setup the environment.
15  */
16 @JNINamespace("mojo::android")
17 public class MojoTestCase extends InstrumentationTestCase {
18
19     private long mTestEnvironmentPointer;
20
21     /**
22      * @see junit.framework.TestCase#setUp()
23      */
24     @Override
25     protected void setUp() throws Exception {
26         super.setUp();
27         LibraryLoader.ensureInitialized();
28         nativeInitApplicationContext(getInstrumentation().getTargetContext());
29         mTestEnvironmentPointer = nativeSetupTestEnvironment();
30     }
31
32     /**
33      * @see android.test.InstrumentationTestCase#tearDown()
34      */
35     @Override
36     protected void tearDown() throws Exception {
37         nativeTearDownTestEnvironment(mTestEnvironmentPointer);
38         super.tearDown();
39     }
40
41     private native void nativeInitApplicationContext(Context context);
42
43     private native long nativeSetupTestEnvironment();
44
45     private native void nativeTearDownTestEnvironment(long testEnvironment);
46
47     protected native void nativeRunLoop(long timeoutMS);
48
49 }