Java Code Examples for android.support.test.InstrumentationRegistry

The following are top voted examples for showing how to use android.support.test.InstrumentationRegistry. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: GitHub   File: BaseIntegrationTest.java   View source code 6 votes vote down vote up
protected void prepareEnvironmentForTest() throws IOException {
    // FIXME Trying to reset the device environment is crashing tests somehow
    deleteRosFiles();
    if (BaseRealm.applicationContext != null) {
        // Realm was already initialized. Reset all internal state
        // in order to be able fully re-initialize.

        // This will set the 'm_metadata_manager' in 'sync_manager.cpp' to be 'null'
        // causing the SyncUser to remain in memory.
        // They're actually not persisted into disk.
        // move this call to 'tearDown' to clean in-memory & on-disk users
        // once https://github.com/realm/realm-object-store/issues/207 is resolved
        SyncManager.reset();
        BaseRealm.applicationContext = null; // Required for Realm.init() to work
    }
    Realm.init(InstrumentationRegistry.getContext());
    originalLogLevel = RealmLog.getLevel();
    RealmLog.setLevel(LogLevel.DEBUG);
}
 
Example 2
Project: wcs-android-sdk   File: UploadFileTest.java   View source code 6 votes vote down vote up
@Test
public void testNullToken() throws Exception {
    Log.d(TAG, "uploadNullToken");
    final String token = null;
    final String filePath = getPath();
    final CountDownLatch signal = new CountDownLatch(1);
    FileUploader.upload(InstrumentationRegistry.getTargetContext(),
            token, filePath, null, new FileUploaderListener() {

                @Override
                public void onFailure(OperationMessage operationMessage) {
                    Log.d(TAG, "onFailure: " + operationMessage.getMessage());
                    signal.countDown();
                    Assert.assertTrue(operationMessage.getMessage().contains("token invalidate"));
                }

                @Override
                public void onSuccess(int status, JSONObject responseJson) {
                    Log.d(TAG, "onSuccess: " + responseJson);
                    signal.countDown();
                    Assert.assertNull(responseJson);
                }
            });
    signal.await(WAIT_TIME, TimeUnit.MILLISECONDS);
}
 
Example 3
Project: WebPager   File: ExampleInstrumentedTest.java   View source code 6 votes vote down vote up
@Test
public void useAppContext() throws Exception {
	// Context of the app under test.
	Context appContext = InstrumentationRegistry.getTargetContext();

	assertEquals("com.fengshihao.webpager", appContext.getPackageName());
}
 
Example 4
Project: GitHub   File: SortTest.java   View source code 6 votes vote down vote up
@Before
public void setUp() {
    // Creates a Realm with the following objects:
    // 0: (5, "Adam")
    // 1: (4, "Brian")
    // 2: (4, "Adam")
    // 3: (5, "Adam")

    // Injecting the Instrumentation instance is required
    // for your test to run with AndroidJUnitRunner.
    context = InstrumentationRegistry.getInstrumentation().getContext();
    realmConfig = configFactory.createConfiguration();
    realm = Realm.getInstance(realmConfig);

    populateRealm(realm);
}
 
Example 5
Project: AndroidDeviceName   File: ExampleInstrumentedTest.java   View source code 5 votes vote down vote up
@Test
public void useAppContext() throws Exception {
    // Context of the app under test.
    Context appContext = InstrumentationRegistry.getTargetContext();

    assertEquals("com.rednineteen.android.adn", appContext.getPackageName());
}
 
Example 6
Project: renderingPerformance   File: ExampleInstrumentedTest.java   View source code 5 votes vote down vote up
@Test
public void useAppContext() throws Exception {
    // Context of the app under test.
    Context appContext = InstrumentationRegistry.getTargetContext();

    assertEquals("wanjian.renderingperformance.test", appContext.getPackageName());
}
 
Example 7
Project: GitHub   File: UpdateAvailableTest.java   View source code 5 votes vote down vote up
@Test
public void updateAvailable_Basic_XML() throws Throwable {
    final CountDownLatch signal = new CountDownLatch(1);

    uiThreadTestRule.runOnUiThread(new Runnable() {
        @Override
        public void run() {
            new AppUpdaterUtils(InstrumentationRegistry.getTargetContext())
                    .setUpdateFrom(UpdateFrom.XML)
                    .setUpdateJSON("https://raw.githubusercontent.com/javiersantos/AppUpdater/master/app/src/androidTest/java/com/github/javiersantos/appupdater/files/update-available-basic.xml")
                    .withListener(new AppUpdaterUtils.UpdateListener() {
                        @Override
                        public void onSuccess(Update update, Boolean isUpdateAvailable) {
                            assertTrue(isUpdateAvailable);
                            signal.countDown();
                        }

                        @Override
                        public void onFailed(AppUpdaterError error) {
                            assertNotNull(error);
                            signal.countDown();
                        }
                    })
                    .start();
        }
    });

    signal.await(30, TimeUnit.SECONDS);
}
 
Example 8
Project: GPSTracker-Android   File: ExampleInstrumentedTest.java   View source code 5 votes vote down vote up
@Test
public void useAppContext() throws Exception {
    // Context of the app under test.
    Context appContext = InstrumentationRegistry.getTargetContext();

    assertEquals("com.highbryds.tracker", appContext.getPackageName());
}
 
Example 9
Project: RewardLayout   File: ExampleInstrumentedTest.java   View source code 5 votes vote down vote up
@Test
public void useAppContext() throws Exception {
    // Context of the app under test.
    Context appContext = InstrumentationRegistry.getTargetContext();

    assertEquals("com.zhangyf.reward", appContext.getPackageName());
}
 
Example 10
Project: iSPY   File: ExampleInstrumentedTest.java   View source code 5 votes vote down vote up
@Test
public void useAppContext() throws Exception {
    // Context of the app under test.
    Context appContext = InstrumentationRegistry.getTargetContext();

    assertEquals("com.example.ajaykumar.drawer", appContext.getPackageName());
}
 
Example 11
Project: Android-Validator   File: ExampleInstrumentedTest.java   View source code 5 votes vote down vote up
@Test
public void useAppContext() throws Exception {
    // Context of the app under test.
    Context appContext = InstrumentationRegistry.getTargetContext();

    assertEquals("com.harpz.androidvalidator.test", appContext.getPackageName());
}
 
Example 12
Project: AppRater-Dialog   File: ExampleInstrumentedTest.java   View source code 5 votes vote down vote up
@Test
public void useAppContext() throws Exception {
    // Context of the app under test.
    Context appContext = InstrumentationRegistry.getTargetContext();

    assertEquals("com.kila.apprater_dialog.lars.test", appContext.getPackageName());
}
 
Example 13
Project: quidditchtimekeeper   File: ExampleInstrumentedTest.java   View source code 5 votes vote down vote up
@Test
public void useAppContext() throws Exception {
    // Context of the app under test.
    Context appContext = InstrumentationRegistry.getTargetContext();

    assertEquals("de.lucasscheuvens.qtk", appContext.getPackageName());
}
 
Example 14
Project: Bridge   File: ExampleInstrumentedTest.java   View source code 5 votes vote down vote up
@Test
public void useAppContext() throws Exception {
    // Context of the app under test.
    Context appContext = InstrumentationRegistry.getTargetContext();

    assertEquals("moe.shizuku.bridge", appContext.getPackageName());
}
 
Example 15
Project: AutoScrollr   File: ExampleInstrumentedTest.java   View source code 5 votes vote down vote up
@Test
public void useAppContext() throws Exception {
    // Context of the app under test.
    Context appContext = InstrumentationRegistry.getTargetContext();

    assertEquals("com.suyashsrijan.autoscrollr", appContext.getPackageName());
}
 
Example 16
Project: CameraSample   File: ExampleInstrumentedTest.java   View source code 5 votes vote down vote up
@Test
public void useAppContext() throws Exception {
    // Context of the app under test.
    Context appContext = InstrumentationRegistry.getTargetContext();

    assertEquals("com.akexorcist.cameraapi", appContext.getPackageName());
}
 
Example 17
Project: Discover   File: ExampleInstrumentedTest.java   View source code 5 votes vote down vote up
@Test
public void useAppContext() throws Exception {
    // Context of the app under test.
    Context appContext = InstrumentationRegistry.getTargetContext();

    assertEquals("com.example.discover", appContext.getPackageName());
}
 
Example 18
Project: Khonsu   File: ExampleInstrumentedTest.java   View source code 5 votes vote down vote up
@Test
public void useAppContext() throws Exception {
    // Context of the app under test.
    Context appContext = InstrumentationRegistry.getTargetContext();

    assertEquals("com.example.a.vinpal", appContext.getPackageName());
}
 
Example 19
Project: DateTimeUtils   File: ExampleInstrumentedTest.java   View source code 5 votes vote down vote up
@Test
public void useAppContext() throws Exception {
    // Context of the app under test.
    Context appContext = InstrumentationRegistry.getTargetContext();

    assertEquals("com.github.thunder413.datetimeutilssample", appContext.getPackageName());
}
 
Example 20
Project: AnimationTextView   File: ExampleInstrumentedTest.java   View source code 5 votes vote down vote up
@Test
public void useAppContext() throws Exception {
    // Context of the app under test.
    Context appContext = InstrumentationRegistry.getTargetContext();

    assertEquals("com.totcy.animationtextview.test", appContext.getPackageName());
}
 
Example 21
Project: ToDay   File: ExampleInstrumentedTest.java   View source code 5 votes vote down vote up
@Test
public void useAppContext() throws Exception {
    // Context of the app under test.
    Context appContext = InstrumentationRegistry.getTargetContext();

    assertEquals("mn.pomodoro", appContext.getPackageName());
}
 
Example 22
Project: Kawaii_LoadingView   File: ExampleInstrumentedTest.java   View source code 5 votes vote down vote up
@Test
public void useAppContext() throws Exception {
    // Context of the app under test.
    Context appContext = InstrumentationRegistry.getTargetContext();

    assertEquals("scut.carson_ho.view_testdemo", appContext.getPackageName());
}
 
Example 23
Project: Typesetter   File: ExampleInstrumentedTest.java   View source code 5 votes vote down vote up
@Test
public void useAppContext() throws Exception {
    // Context of the app under test.
    Context appContext = InstrumentationRegistry.getTargetContext();

    assertEquals("com.bignerdranch.android.typesetter", appContext.getPackageName());
}
 
Example 24
Project: AFRouter   File: ExampleInstrumentedTest.java   View source code 5 votes vote down vote up
@Test
public void useAppContext() throws Exception {
    // Context of the app under test.
    Context appContext = InstrumentationRegistry.getTargetContext();

    assertEquals("com.tubb.afrouter.test", appContext.getPackageName());
}
 
Example 25
Project: OkayCamera-Android   File: ExampleInstrumentedTest.java   View source code 5 votes vote down vote up
@Test
public void useAppContext() throws Exception {
    // Context of the app under test.
    Context appContext = InstrumentationRegistry.getTargetContext();

    assertEquals("com.example.databindingdemo", appContext.getPackageName());
}
 
Example 26
Project: GifEmoji   File: ExampleInstrumentedTest.java   View source code 5 votes vote down vote up
@Test
public void useAppContext() throws Exception {
    // Context of the app under test.
    Context appContext = InstrumentationRegistry.getTargetContext();

    assertEquals("com.hoanganhtuan95ptit.gifemoji.test", appContext.getPackageName());
}
 
Example 27
Project: WalkGraph   File: ExampleInstrumentedTest.java   View source code 5 votes vote down vote up
@Test
public void useAppContext() throws Exception {
    // Context of the app under test.
    Context appContext = InstrumentationRegistry.getTargetContext();

    assertEquals("com.example.ahmed.walkgraph", appContext.getPackageName());
}
 
Example 28
Project: FestaFimDeAno   File: ExampleInstrumentedTest.java   View source code 5 votes vote down vote up
@Test
public void useAppContext() throws Exception {
    // Context of the app under test.
    Context appContext = InstrumentationRegistry.getTargetContext();

    assertEquals("com.devmasterteam.festafimdeano", appContext.getPackageName());
}
 
Example 29
Project: AndroidThemeChange   File: ExampleInstrumentedTest.java   View source code 5 votes vote down vote up
@Test
public void useAppContext() throws Exception {
    // Context of the app under test.
    Context appContext = InstrumentationRegistry.getTargetContext();

    assertEquals("test.fadai.com.test", appContext.getPackageName());
}
 
Example 30
Project: Aardvark   File: ExampleInstrumentedTest.java   View source code 5 votes vote down vote up
@Test
public void useAppContext() throws Exception {
    // Context of the app under test.
    Context appContext = InstrumentationRegistry.getTargetContext();

    assertEquals("com.example.ekanugrahapratama.aardvark_project", appContext.getPackageName());
}
 
Example 31
Project: Samantha   File: ExampleInstrumentedTest.java   View source code 5 votes vote down vote up
@Test
public void useAppContext() throws Exception {
    // Context of the app under test.
    Context appContext = InstrumentationRegistry.getTargetContext();

    assertEquals("com.junnanhao.samanthaviews.test", appContext.getPackageName());
}
 
Example 32
Project: Android-Practice   File: ExampleInstrumentedTest.java   View source code 5 votes vote down vote up
@Test
public void useAppContext() throws Exception {
    // Context of the app under test.
    Context appContext = InstrumentationRegistry.getTargetContext();

    assertEquals("com.example.jjuiddong.myapplication", appContext.getPackageName());
}
 
Example 33
Project: SafeMediaPlayer   File: ExampleInstrumentedTest.java   View source code 5 votes vote down vote up
@Test
public void useAppContext() throws Exception {
    // Context of the app under test.
    Context appContext = InstrumentationRegistry.getTargetContext();

    assertEquals("com.hss01248.safemedia", appContext.getPackageName());
}
 
Example 34
Project: ModesoActionOverlay-Android   File: ExampleInstrumentedTest.java   View source code 5 votes vote down vote up
@Test
public void useAppContext() throws Exception {
    // Context of the app under test.
    Context appContext = InstrumentationRegistry.getTargetContext();

    assertEquals("ch.modeso.profilemenuanimation", appContext.getPackageName());
}
 
Example 35
Project: Google-Developer-Challenge-Scholarship-Android-Basics   File: ExampleInstrumentedTest.java   View source code 5 votes vote down vote up
@Test
public void useAppContext() throws Exception {
    // Context of the app under test.
    Context appContext = InstrumentationRegistry.getTargetContext();

    assertEquals("com.example.android.courtcounter", appContext.getPackageName());
}
 
Example 36
Project: FlexibleRichTextView   File: ExampleInstrumentedTest.java   View source code 5 votes vote down vote up
@Test
public void useAppContext() throws Exception {
    // Context of the app under test.
    Context appContext = InstrumentationRegistry.getTargetContext();

    assertEquals("com.daquexian.flexiblerichtextview.test", appContext.getPackageName());
}
 
Example 37
Project: MyCleanArchitecture   File: ExampleInstrumentedTest.java   View source code 5 votes vote down vote up
@Test
public void useAppContext() throws Exception {
    // Context of the app under test.
    Context appContext = InstrumentationRegistry.getTargetContext();

    assertEquals("herry.architec", appContext.getPackageName());
}
 
Example 38
Project: ZhidaoDaily-android   File: ExampleInstrumentedTest.java   View source code 5 votes vote down vote up
@Test
public void useAppContext() throws Exception {
    // Context of the app under test.
    Context appContext = InstrumentationRegistry.getTargetContext();

    assertEquals("com.shenhua.zhidaodaily", appContext.getPackageName());
}
 
Example 39
Project: RecyclerViewTutorial2017   File: ExampleInstrumentedTest.java   View source code 5 votes vote down vote up
@Test
public void useAppContext() throws Exception {
    // Context of the app under test.
    Context appContext = InstrumentationRegistry.getTargetContext();

    assertEquals("forgettery.wiseass.com.recyclerviewprebuilt", appContext.getPackageName());
}
 
Example 40
Project: TensorFlowAndroidDynamic   File: ExampleInstrumentedTest.java   View source code 5 votes vote down vote up
@Test
public void useAppContext() throws Exception {
    // Context of the app under test.
    Context appContext = InstrumentationRegistry.getTargetContext();

    assertEquals("com.hss01248.tensorflowdynamic.test", appContext.getPackageName());
}