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.
5 package org.chromium.mojo;
7 import android.content.Context;
8 import android.test.InstrumentationTestCase;
10 import org.chromium.base.JNINamespace;
11 import org.chromium.base.library_loader.LibraryLoader;
14 * Base class to test mojo. Setup the environment.
16 @JNINamespace("mojo::android")
17 public class MojoTestCase extends InstrumentationTestCase {
19 private long mTestEnvironmentPointer;
22 * @see junit.framework.TestCase#setUp()
25 protected void setUp() throws Exception {
27 LibraryLoader.ensureInitialized();
28 nativeInitApplicationContext(getInstrumentation().getTargetContext());
29 mTestEnvironmentPointer = nativeSetupTestEnvironment();
33 * @see android.test.InstrumentationTestCase#tearDown()
36 protected void tearDown() throws Exception {
37 nativeTearDownTestEnvironment(mTestEnvironmentPointer);
41 private native void nativeInitApplicationContext(Context context);
43 private native long nativeSetupTestEnvironment();
45 private native void nativeTearDownTestEnvironment(long testEnvironment);
47 protected native void nativeRunLoop(long timeoutMS);