Java Code Examples for androidx.test.InstrumentationRegistry#getTargetContext()

The following examples show how to use androidx.test.InstrumentationRegistry#getTargetContext() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ExampleInstrumentedTest.java    From Moneycim with MIT License 5 votes vote down vote up
@Test
public void useAppContext() throws Exception {
    // Context of the app under test.
    Context appContext = InstrumentationRegistry.getTargetContext();

    assertEquals("com.vsahin.moneycim", appContext.getPackageName());
}
 
Example 2
Source File: BlacklistedApis.java    From dexmaker with Apache License 2.0 5 votes vote down vote up
/**
 * Check if the application is marked as {@code android:debuggable} in the manifest
 *
 * @return {@code true} iff it is marked as such
 */
private boolean isDebuggable() throws PackageManager.NameNotFoundException {
    Context context = InstrumentationRegistry.getTargetContext();
    PackageInfo packageInfo = context.getPackageManager().getPackageInfo(
            context.getPackageName(), 0);

    return (packageInfo.applicationInfo.flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0;
}
 
Example 3
Source File: ExampleInstrumentedTest.java    From VyAPI with MIT License 5 votes vote down vote up
@Test
public void useAppContext() {
    // Context of the app under test.
    Context appContext = InstrumentationRegistry.getTargetContext();

    assertEquals("com.example.mvvm", appContext.getPackageName());
}
 
Example 4
Source File: ExampleInstrumentedTest.java    From Mysplash with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Test
public void useAppContext() {
    // Context of the app under test.
    Context appContext = InstrumentationRegistry.getTargetContext();

    assertEquals("com.wangdaye.db.test", appContext.getPackageName());
}
 
Example 5
Source File: ExampleInstrumentedTest.java    From Alligator with MIT License 5 votes vote down vote up
@Test
public void useAppContext() throws Exception {
	// Context of the app under test.
	Context appContext = InstrumentationRegistry.getTargetContext();

	assertEquals("me.aartikov.simplescreenswitchersample", appContext.getPackageName());
}
 
Example 6
Source File: ExampleInstrumentedTest.java    From ridesharing-android with MIT License 5 votes vote down vote up
@Test
public void useAppContext() {
    // Context of the app under test.
    Context appContext = InstrumentationRegistry.getTargetContext();

    assertEquals("com.hypertrack.uberx", appContext.getPackageName());
}
 
Example 7
Source File: ExampleInstrumentedTest.java    From PerfMon-Plus with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Test
public void useAppContext() {
    // Context of the app under test.
    Context appContext = InstrumentationRegistry.getTargetContext();

    assertEquals("xzr.perfmon", appContext.getPackageName());
}
 
Example 8
Source File: ExampleInstrumentedTest.java    From circle-menu-android with MIT License 5 votes vote down vote up
@Test
public void useAppContext() throws Exception {
    // Context of the app under test.
    Context appContext = InstrumentationRegistry.getTargetContext();

    assertEquals("com.ramotion.circlemenu", appContext.getPackageName());
}
 
Example 9
Source File: ExampleInstrumentedTest.java    From TimeIt with Apache License 2.0 5 votes vote down vote up
@Test
public void useAppContext() {
    // Context of the app under test.
    Context appContext = InstrumentationRegistry.getTargetContext();

    assertEquals("com.yashovardhan99.stopwatch", appContext.getPackageName());
}
 
Example 10
Source File: ExampleInstrumentedTest.java    From Android-Developer-Fundamentals-Version-2 with GNU General Public License v3.0 5 votes vote down vote up
@Test
public void useAppContext() {
    // Context of the app under test.
    Context appContext = InstrumentationRegistry.getTargetContext();

    assertEquals("me.mahakagg.datastoragetypes", appContext.getPackageName());
}
 
Example 11
Source File: ExampleInstrumentedTest.java    From OneText_For_Android with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Test
public void useAppContext() {
    // Context of the app under test.
    Context appContext = InstrumentationRegistry.getTargetContext();

    assertEquals("com.lz233.onetext", appContext.getPackageName());
}
 
Example 12
Source File: ExampleInstrumentedTest.java    From Android-Image-Slider with Apache License 2.0 5 votes vote down vote up
@Test
public void useAppContext() {
    // Context of the app under test.
    Context appContext = InstrumentationRegistry.getTargetContext();

    assertEquals("com.smarteist.imageslider", appContext.getPackageName());
}
 
Example 13
Source File: ExampleInstrumentedTest.java    From ScreenCapture with MIT License 5 votes vote down vote up
@Test
public void useAppContext() throws Exception {
    // Context of the app under test.
    Context appContext = InstrumentationRegistry.getTargetContext();

    assertEquals("com.softard.wow.screencapture", appContext.getPackageName());
}
 
Example 14
Source File: ExampleInstrumentedTest.java    From Android-Developer-Fundamentals-Version-2 with GNU General Public License v3.0 5 votes vote down vote up
@Test
public void useAppContext() {
    // Context of the app under test.
    Context appContext = InstrumentationRegistry.getTargetContext();

    assertEquals("me.mahakagg.roomwordssample", appContext.getPackageName());
}
 
Example 15
Source File: ExampleInstrumentedTest.java    From TikTok with Apache License 2.0 5 votes vote down vote up
@Test
public void useAppContext() {
    // Context of the app under test.
    Context appContext = InstrumentationRegistry.getTargetContext();

    assertEquals("com.taopao.tiktok", appContext.getPackageName());
}
 
Example 16
Source File: ExampleInstrumentedTest.java    From Mysplash with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Test
public void useAppContext() {
    // Context of the app under test.
    Context appContext = InstrumentationRegistry.getTargetContext();

    assertEquals("com.wangdaye.photo.test", appContext.getPackageName());
}
 
Example 17
Source File: ExampleInstrumentedTest.java    From Mysplash with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Test
public void useAppContext() {
    // Context of the app under test.
    Context appContext = InstrumentationRegistry.getTargetContext();

    assertEquals("com.wangdaye.base.test", appContext.getPackageName());
}
 
Example 18
Source File: ExampleInstrumentedTest.java    From WhatsApp-Cleaner with MIT License 5 votes vote down vote up
@Test
public void useAppContext() {
    // Context of the app under test.
    Context appContext = InstrumentationRegistry.getTargetContext();

    assertEquals("com.example.pawan.whatsupcleaner", appContext.getPackageName());
}
 
Example 19
Source File: ExampleInstrumentedTest.java    From shinny-futures-android with GNU General Public License v3.0 5 votes vote down vote up
@Test
public void useAppContext() throws Exception {
    // Context of the app under test.
    Context appContext = InstrumentationRegistry.getTargetContext();

    assertEquals("com.xinyi.shinnyfutures.haitongfutures.debug", appContext.getPackageName());
}
 
Example 20
Source File: ExampleInstrumentedTest.java    From journaldev with MIT License 5 votes vote down vote up
@Test
public void useAppContext() {
    // Context of the app under test.
    Context appContext = InstrumentationRegistry.getTargetContext();

    assertEquals("com.journaldev.androidcameraxopencv", appContext.getPackageName());
}