blob: f4d7ab72366bb8529b29f71dcff3a9abda739418 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package org.chromium.mojo;
import android.test.InstrumentationTestCase;
import org.chromium.base.ContextUtils;
import org.chromium.base.annotations.JNINamespace;
import org.chromium.base.library_loader.LibraryLoader;
import org.chromium.base.library_loader.LibraryProcessType;
/**
* Base class to test mojo. Setup the environment.
*/
@JNINamespace("mojo::android")
public class MojoTestCase extends InstrumentationTestCase {
private long mTestEnvironmentPointer;
/**
* @see junit.framework.TestCase#setUp()
*/
@Override
protected void setUp() throws Exception {
super.setUp();
ContextUtils.initApplicationContext(
getInstrumentation().getTargetContext().getApplicationContext());
LibraryLoader.get(LibraryProcessType.PROCESS_BROWSER).ensureInitialized();
nativeInit();
mTestEnvironmentPointer = nativeSetupTestEnvironment();
}
/**
* @see android.test.InstrumentationTestCase#tearDown()
*/
@Override
protected void tearDown() throws Exception {
nativeTearDownTestEnvironment(mTestEnvironmentPointer);
super.tearDown();
}
/**
* Runs the run loop for the given time.
*/
protected void runLoop(long timeoutMS) {
nativeRunLoop(timeoutMS);
}
/**
* Runs the run loop until no handle or task are immediately available.
*/
protected void runLoopUntilIdle() {
nativeRunLoop(0);
}
private native void nativeInit();
private native long nativeSetupTestEnvironment();
private native void nativeTearDownTestEnvironment(long testEnvironment);
private native void nativeRunLoop(long timeoutMS);
}
|