• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
setUp()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
tearDown()36     protected void tearDown() throws Exception {
37         nativeTearDownTestEnvironment(mTestEnvironmentPointer);
38         super.tearDown();
39     }
40 
nativeInitApplicationContext(Context context)41     private native void nativeInitApplicationContext(Context context);
42 
nativeSetupTestEnvironment()43     private native long nativeSetupTestEnvironment();
44 
nativeTearDownTestEnvironment(long testEnvironment)45     private native void nativeTearDownTestEnvironment(long testEnvironment);
46 
nativeRunLoop(long timeoutMS)47     protected native void nativeRunLoop(long timeoutMS);
48 
49 }
50