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
Contextual code suggestions in your IDE  Get Codota for Java
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
Contextual code suggestions in your IDE  Get Codota for Java
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
Contextual code suggestions in your IDE  Get Codota for Java
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
Contextual code suggestions in your IDE  Get Codota for Java
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
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods: getInstrumentation
This code example shows how to use the following methods: getInstrumentation
        this.instrumentationTestCase = instrumentationTestCase;
    } 
 
    @Override 
    public Resources getResources() {
        return instrumentationTestCase.getInstrumentation().getTargetContext().getResources();
    } 
 
    @Override 
    public Resources.Theme getTheme() {
        return instrumentationTestCase.getInstrumentation().getTargetContext().getTheme();
    } 
 
    @Override 
    public Object getSystemService(String name) {
        if (Context.LAYOUT_INFLATER_SERVICE.equals(name)) {
            return instrumentationTestCase.getInstrumentation().getTargetContext().getSystemService(name);
        } 
        return super.getSystemService(name);
    } 
Full Snippet Info
4
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods: getInstrumentation
This code example shows how to use the following methods: getInstrumentation
This code example shows how to use the following methods: sendKeys
  public static void tapDialogNegativeButton(InstrumentationTestCase testCase) {
    // The order of the buttons is reversed from ICS onwards 
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
      testCase.sendKeys("DPAD_RIGHT DPAD_CENTER");
    } else { 
      testCase.sendKeys("DPAD_LEFT DPAD_CENTER");
    } 
  } 
 
  /** 
   * Taps the negative button of a currently displayed dialog. This method assumes that a button 
   * of the dialog is currently selected. 
   * 
   * @see #tapDialogNegativeButton(InstrumentationTestCase) 
   */ 
  public static void tapDialogPositiveButton(InstrumentationTestCase testCase) {
    // The order of the buttons is reversed from ICS onwards 
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
      testCase.sendKeys("DPAD_LEFT DPAD_CENTER");
    } else { 
Full Snippet Info
3
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java

Related Android InstrumentationTestCase Questions & Answers:

See Code Examples for Android InstrumentationTestCase Methods: