Java Code Examples for android.support.test.InstrumentationRegistry.getTargetContext()

The following are Jave code examples for showing how to use getTargetContext() of the android.support.test.InstrumentationRegistry class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: ExpandableMenu   File: ExampleInstrumentedTest.java   View Source Code Vote up 5 votes
@Test
public void useAppContext() throws Exception {
    // Context of the app under test.
    Context appContext = InstrumentationRegistry.getTargetContext();

    assertEquals("me.anshulagarwal.expandablemenuoption.test", appContext.getPackageName());
}
 
Example 2
Project: lostfilm-android-client   File: ExampleInstrumentedTest.java   View Source Code Vote up 5 votes
@Test
public void useAppContext() throws Exception {
    // Context of the app under test.
    Context appContext = InstrumentationRegistry.getTargetContext();

    assertEquals("com.crazydude.common.test", appContext.getPackageName());
}
 
Example 3
Project: FaBo-Serial-Kit   File: Test10.java   View Source Code Vote up 5 votes
@Test
public void useAppContext() throws Exception {
    // Context of the app under test.
    Context appContext = InstrumentationRegistry.getTargetContext();

    mFaBoUsbManger = new FaBoUsbManager(appContext);
    mFaBoUsbManger.setParameter(FaBoUsbConst.BAUNDRATE_115200);
    mFaBoUsbManger.setListener(this);
    mFaBoUsbManger.findDevice();
}
 
Example 4
Project: TWStreaming   File: ExampleInstrumentedTest.java   View Source Code Vote up 5 votes
@Test
public void useAppContext() throws Exception {
    // Context of the app under test.
    Context appContext = InstrumentationRegistry.getTargetContext();

    assertEquals("com.beraldo.twstreaming", appContext.getPackageName());
}
 
Example 5
Project: Songify   File: ExampleInstrumentedTest.java   View Source Code Vote up 5 votes
@Test
public void useAppContext() throws Exception {
    // Context of the app under test.
    Context appContext = InstrumentationRegistry.getTargetContext();

    assertEquals("songify.akshaypall.com.songifymusicplayer", appContext.getPackageName());
}
 
Example 6
Project: coin_hive_android_sdk   File: ExampleInstrumentedTest.java   View Source Code Vote up 5 votes
@Test
public void useAppContext() throws Exception {
    // Context of the app under test.
    Context appContext = InstrumentationRegistry.getTargetContext();

    assertEquals("com.theah64.coinhive.test", appContext.getPackageName());
}
 
Example 7
Project: ItemContainer   File: ExampleInstrumentedTest.java   View Source Code Vote up 5 votes
@Test
public void useAppContext() throws Exception {
    // Context of the app under test.
    Context appContext = InstrumentationRegistry.getTargetContext();

    assertEquals("com.zterry.itemcontainer", appContext.getPackageName());
}
 
Example 8
Project: AdSimasTeam   File: ExampleInstrumentedTest.java   View Source Code Vote up 5 votes
@Test
public void useAppContext() throws Exception {
    // Context of the app under test.
    Context appContext = InstrumentationRegistry.getTargetContext();

    assertEquals("com.simasteam.adsimasteam.test", appContext.getPackageName());
}
 
Example 9
Project: sekai   File: ExampleInstrumentedTest.java   View Source Code Vote up 5 votes
@Test
public void useAppContext() throws Exception {
    // Context of the app under test.
    Context appContext = InstrumentationRegistry.getTargetContext();

    assertEquals("emeline.mysekai", appContext.getPackageName());
}
 
Example 10
Project: CustomTextView   File: ExampleInstrumentedTest.java   View Source Code Vote up 5 votes
@Test
public void useAppContext() throws Exception {
    // Context of the app under test.
    Context appContext = InstrumentationRegistry.getTargetContext();

    assertEquals("com.slobodanantonijevic.customtextviewexample", appContext.getPackageName());
}
 
Example 11
Project: snu-artoon   File: ExampleInstrumentedTest.java   View Source Code Vote up 5 votes
@Test
public void useAppContext() throws Exception {
    // Context of the app under test.
    Context appContext = InstrumentationRegistry.getTargetContext();

    assertEquals("baryberri.a3_6_gridlayout", appContext.getPackageName());
}
 
Example 12
Project: RendererRecyclerViewAdapter   File: ExampleInstrumentedTest.java   View Source Code Vote up 5 votes
@Test
public
void useAppContext() throws Exception {
	// Context of the app under test.
	Context appContext = InstrumentationRegistry.getTargetContext();

	assertEquals("com.example.vivchar.rendererrecyclerviewadapter.test", appContext.getPackageName());
}
 
Example 13
Project: lighthouse   File: ExampleInstrumentedTest.java   View Source Code Vote up 5 votes
@Test
public void useAppContext() throws Exception {
    // Context of the app under test.
    Context appContext = InstrumentationRegistry.getTargetContext();

    assertEquals("ru.radiomayak", appContext.getPackageName());
}
 
Example 14
Project: AndroidProgramming3e   File: ExampleInstrumentedTest.java   View Source Code Vote up 5 votes
@Test
public void useAppContext() throws Exception {
    // Context of the app under test.
    Context appContext = InstrumentationRegistry.getTargetContext();

    assertEquals("com.bignerdranch.android.criminalintent", appContext.getPackageName());
}
 
Example 15
Project: Month_Calendar   File: ExampleInstrumentedTest.java   View Source Code Vote up 5 votes
@Test
public void useAppContext() throws Exception {
    // Context of the app under test.
    Context appContext = InstrumentationRegistry.getTargetContext();

    assertEquals("com.beiing.monthcalendar.test", appContext.getPackageName());
}
 
Example 16
Project: ScreenShotAnywhere   File: ExampleInstrumentedTest.java   View Source Code Vote up 5 votes
@Test
public void useAppContext() throws Exception {
    // Context of the app under test.
    Context appContext = InstrumentationRegistry.getTargetContext();

    assertEquals("com.infinitestack.shotanywhere", appContext.getPackageName());
}
 
Example 17
Project: AndroidProgramming3e   File: ExampleInstrumentedTest.java   View Source Code Vote up 5 votes
@Test
public void useAppContext() throws Exception {
    // Context of the app under test.
    Context appContext = InstrumentationRegistry.getTargetContext();

    assertEquals("com.bignerdranch.android.beatbox", appContext.getPackageName());
}
 
Example 18
Project: MovieGuide   File: TestDB.java   View Source Code Vote up 4 votes
/**
 * Tests that we can insert and query the database.
 */
@Test
public void testFavoriteTVShowsTable() {
    // Step 1: Get reference to writable database
    // If there's an error in the SQL table creation Strings,
    // errors will be thrown here when you try to get a writable database.
    Context appContext = InstrumentationRegistry.getTargetContext();
    FavoritesDbHelper dbHelper = new FavoritesDbHelper(appContext);
    SQLiteDatabase db = dbHelper.getWritableDatabase();

    // Step 2: Create ContentValues of what you want to insert
    ContentValues testValues = TestUtilities.createTheSimpsonsValues();

    // Step 3: Insert ContentValues into database and get a row ID back
    long locationRowId = db.insert(FavoritesContract.FavoriteColumns.FAVORITE_TV_SHOWS_TBL, null,
            testValues);

    // Verify we got a row back.
    assertTrue(locationRowId != -1);

    // Data's inserted.  IN THEORY.  Now pull some out to stare at it and verify it made
    // the round trip.

    // Step 4: Query the database and receive a Cursor back
    // A cursor is your primary interface to the query results.
    Cursor cursor = db.query(
            FavoritesContract.FavoriteColumns.FAVORITE_TV_SHOWS_TBL,  // Table to Query
            null, // all columns
            null, // Columns for the "where" clause
            null, // Values for the "where" clause
            null, // columns to group by
            null, // columns to filter by row groups
            null // sort order
    );

    // Move the cursor to a valid database row and check to see if we got any records back
    // from the query
    assertTrue( "Error: No Records returned from location query", cursor.moveToFirst() );

    // Step 5: Validate data in resulting Cursor with the original ContentValues
    TestUtilities.validateCurrentRecord("Error: Location Query Validation Failed",
            cursor, testValues);

    // Move the cursor to demonstrate that there is only one record in the database
    assertFalse( "Error: More than one record returned from location query",
            cursor.moveToNext() );

    // Step 6: Close Cursor and Database
    cursor.close();
    db.close();
}
 
Example 19
Project: Spyglass   File: TestIntegerHandlerCombinations.java   View Source Code Vote up 4 votes
@Before
public void setup() {
	context = InstrumentationRegistry.getTargetContext();
}
 
Example 20
Project: lighthouse   File: PodcastsUtilsTest.java   View Source Code Vote up 4 votes
@After
public void after() {
    Context context = InstrumentationRegistry.getTargetContext();
    String path = context.getDatabasePath(PodcastsUtils.PODCASTS_DATABASE_NAME).getPath();
    SQLiteDatabase.deleteDatabase(new File(path));
}