Android InstrumentationTestCase - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Android InstrumentationTestCase class.

This code example shows how to use the following methods: getInstrumentation
    @Mock 
    Bundle bundle;
 
    @Before 
    public void setup() { 
        when(testCase.getInstrumentation()).thenReturn(instrumentation);
    } 
} 
Full Snippet Info
6
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: runTestOnUiThread
            final ContentView view, TestCallbackHelperContainer viewClient, final String code)
                    throws Throwable { 
        TestCallbackHelperContainer.OnEvaluateJavaScriptResultHelper 
                onEvaluateJavaScriptResultHelper = viewClient.getOnEvaluateJavaScriptResultHelper();
        int currentCallCount = onEvaluateJavaScriptResultHelper.getCallCount();
        test.runTestOnUiThread(new Runnable() {
            @Override 
            public void run() { 
                mRequestId = view.evaluateJavaScript(code);
            } 
        }); 
        onEvaluateJavaScriptResultHelper.waitForCallback(currentCallCount);
        Assert.assertEquals("Response ID mismatch when evaluating JavaScript.",
                mRequestId, onEvaluateJavaScriptResultHelper.getId());
        return onEvaluateJavaScriptResultHelper.getJsonResult();
    } 
 
    /** 
     * Executes the given snippet of JavaScript code but does not wait for the result. 
     */ 
Full Snippet Info
5
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: injectInstrumentation
 
        @TargetApi(5) 
        @Override 
        public void injectInstrumentation(InstrumentationTestCase test,
                                          Instrumentation instrumentation) {
            test.injectInstrumentation(instrumentation);
        } 
    } 
} 
Full Snippet Info
5
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: getTargetContext, injectInstrumentation
    } 
 
    @Override 
    public void runTest(Test test, TestResult result) {
        if (test instanceof AndroidTestCase) {
            ((AndroidTestCase)test).setContext(mInstr.getTargetContext());
        } 
        if (test instanceof InstrumentationTestCase) {
            ((InstrumentationTestCase)test).injectInstrumentation(mInstr);
        } 
        super.runTest(test, result);
    } 
 
    Instrumentation getInstrumentation() {
        return mInstr;
    } 
} 
Full Snippet Info
5
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: getInstrumentation, runTestOnUiThread
    } 
 
 
    public static void navigateActionBarToIndex(final ActionBar actionBar, final int indexToSelect, InstrumentationTestCase instrumentationTestCase) {
        try { 
            instrumentationTestCase.runTestOnUiThread(new Runnable() {
                @Override 
                public void run() { 
 
                    actionBar.setSelectedNavigationItem(indexToSelect);
                } 
            }); 
        } catch (Throwable e) {
            e.printStackTrace();
        } 
        instrumentationTestCase.getInstrumentation().waitForIdleSync();
    } 
 
    public static void navigateSpinnerToIndex(final Spinner spinner, final int indexToSelect, InstrumentationTestCase instrumentationTestCase) {
        try { 
            instrumentationTestCase.runTestOnUiThread(new Runnable() {
Full Snippet Info
5
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE

Related Android InstrumentationTestCase Questions & Answers:

See Code Examples for Android InstrumentationTestCase Methods: