Instrumentation getTargetContext - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Instrumentation getTargetContext method.

This code example shows how to use the following methods:getTargetContext
     * 
     * @param instrumentation 
     */ 
    public BootstrapApplication(final Instrumentation instrumentation) {
        this(); 
        attachBaseContext(instrumentation.getTargetContext());
    } 
 
    public static BootstrapApplication getInstance() { 
        return instance;
    } 
} 
7
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:getTargetContext
            intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
            ((ActivityInstrumentationTestCase2) instance).setActivityIntent(intent);
        } else if (instance instanceof InstrumentationTestCase) {
            ((InstrumentationTestCase) instance).injectInstrumentation(instrumentation);
        } else if (instance instanceof AndroidTestCase) {
            ((AndroidTestCase) instance).setContext(instrumentation.getTargetContext());
        } 
    } 
} 
7
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:getTargetContext
    @Override 
    protected void setUp() throws Exception { 
 
        super.setUp(); 
        mInstrumentation = this.getInstrumentation();
        mContext = mInstrumentation.getTargetContext();
    } 
 
    @Override 
    protected void tearDown() throws Exception { 
 
        super.tearDown(); 
    } 
 
    /** 
     * Confirm that Login is presented. 
     */ 
    @SmallTest 
    public void testLoginOffered() { 
 
6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:getTargetContext
     * 
     * @param instrumentation 
     */ 
    public BootstrapApplication(final Instrumentation instrumentation) {
        this(); 
        attachBaseContext(instrumentation.getTargetContext());
    } 
 
    public static BootstrapApplication getInstance() { 
        return instance;
    } 
} 
5
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:getTargetContext
 
    private Context mTestContext;;
    private Context mTargetContext;
 
    public TestHelper(Instrumentation ins) {
        mTestContext = ins.getTargetContext();
        mTargetContext = ins.getTargetContext();
    } 
 
    /* Set up the french-body-parts database */ 
    public void setUpFBPDatabase() { 
        try { 
            InputStream in = mTestContext.getResources().getAssets().open(AMEnv.DEFAULT_DB_NAME);
            File outFile = new File(SAMPLE_DB_PATH);
            outFile.delete();
 
            FileUtils.copyInputStreamToFile(in, outFile);
            in.close();
        } catch (IOException e) {
            throw new RuntimeException(e);
5
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:getTargetContext
 
    private Context mTestContext;;
    private Context mTargetContext;
 
    public UITestHelper(Instrumentation ins) {
        mTestContext = ins.getTargetContext();
        mTargetContext = ins.getTargetContext();
    } 
 
    /* Set up the french-body-parts database */ 
    public void setUpFBPDatabase() { 
        try { 
            InputStream in = mTestContext.getResources().getAssets().open(AMEnv.DEFAULT_DB_NAME);
            File outFile = new File(SAMPLE_DB_PATH);
            outFile.delete();
 
            FileUtils.copyInputStreamToFile(in, outFile);
            in.close();
        } catch (IOException e) {
            throw new RuntimeException(e);
5
CodeRank
Experience pair programming with AI  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;
    } 
} 
5
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:getTargetContext
	} 
	 
	public void setUp() throws Exception{ 
		super.setUp(); 
        mInstrumentation = getInstrumentation();
        mContext = mInstrumentation.getTargetContext();
	} 
 
	public void tearDown() throws Exception { 
		try { 
			PerformanceTestRunner.closeLauncherplus(mLauncher);
		} catch (Exception e) {
		} 
 
		super.tearDown(); 
	} 
	 
	/** 
	 * Test launch Time 
	 */ 
3
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:getTargetContext
		super.setUp(); 
		Log.i(TAG, "setUp()");
		setActivityInitialTouchMode(false); 
		mActivity = this.getActivity();
		mInstr = this.getInstrumentation();
		mWifiManager = (WifiManager)mInstr.getTargetContext().getSystemService(Context.WIFI_SERVICE);
		mHelper = new InstrumentationHelper(mActivity);
	} 
	 
	/** 
	 * test pre conditions 
	 */ 
	public void testPreConditions(){ 
		Log.i(TAG, "testPreConditions()");
		assertNotNull(mActivity);
		assertNotNull(mInstr);
		assertNotNull(mWifiManager);
		assertNotNull(mHelper);
	} 
	 
3
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:getTargetContext
	} 
	 
	public void setUp() throws Exception{ 
		super.setUp(); 
        mInstrumentation = getInstrumentation();
        mContext = mInstrumentation.getTargetContext();
	} 
 
	public void tearDown() throws Exception { 
		try { 
			PerformanceTestRunner.closeLauncherplus(mLauncher);
		} catch (Exception e) {
		} 
 
		super.tearDown(); 
	} 
	 
	/** 
	 * Test Launcher+(default) launch Time. 
	 */ 
3
CodeRank
Experience pair programming with AI  Get Codota for Java

Related Instrumentation getTargetContext Questions & Answers:

Other Instrumentation getTargetContext Examples

7:	        super.setUp();
8:	        mLaunchIntent = new Intent(getInstrumentation()
9:	                .getTargetContext(), LaunchActivity.class);
10:	        startActivity(mLaunchIntent, null, null);
11:	        final Button launchNextButton =

Read More

getTargetContext Method Overview
Return a Context for the target application being instrumented.
See Code Examples for other Android Instrumentation Methods: