當前位置: 首頁>>代碼示例>>Java>>正文


Java InstrumentationRegistry類代碼示例

本文整理匯總了Java中android.support.test.InstrumentationRegistry的典型用法代碼示例。如果您正苦於以下問題:Java InstrumentationRegistry類的具體用法?Java InstrumentationRegistry怎麽用?Java InstrumentationRegistry使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


InstrumentationRegistry類屬於android.support.test包,在下文中一共展示了InstrumentationRegistry類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: prepareEnvironmentForTest

import android.support.test.InstrumentationRegistry; //導入依賴的package包/類
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);
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:20,代碼來源:BaseIntegrationTest.java

示例2: testNullToken

import android.support.test.InstrumentationRegistry; //導入依賴的package包/類
@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);
}
 
開發者ID:Wangsu-Cloud-Storage,項目名稱:wcs-android-sdk,代碼行數:26,代碼來源:UploadFileTest.java

示例3: useAppContext

import android.support.test.InstrumentationRegistry; //導入依賴的package包/類
@Test
public void useAppContext() throws Exception {
	// Context of the app under test.
	Context appContext = InstrumentationRegistry.getTargetContext();

	assertEquals("com.fengshihao.webpager", appContext.getPackageName());
}
 
開發者ID:fengshihao,項目名稱:WebPager,代碼行數:8,代碼來源:ExampleInstrumentedTest.java

示例4: setUp

import android.support.test.InstrumentationRegistry; //導入依賴的package包/類
@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);
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:17,代碼來源:SortTest.java

示例5: useAppContext

import android.support.test.InstrumentationRegistry; //導入依賴的package包/類
@Test
public void useAppContext() throws Exception {
    // Context of the app under test.
    Context appContext = InstrumentationRegistry.getTargetContext();

    assertEquals("com.rednineteen.android.adn", appContext.getPackageName());
}
 
開發者ID:rednineteen,項目名稱:AndroidDeviceName,代碼行數:8,代碼來源:ExampleInstrumentedTest.java

示例6: useAppContext

import android.support.test.InstrumentationRegistry; //導入依賴的package包/類
@Test
public void useAppContext() throws Exception {
    // Context of the app under test.
    Context appContext = InstrumentationRegistry.getTargetContext();

    assertEquals("wanjian.renderingperformance.test", appContext.getPackageName());
}
 
開發者ID:android-notes,項目名稱:renderingPerformance,代碼行數:8,代碼來源:ExampleInstrumentedTest.java

示例7: updateAvailable_Basic_XML

import android.support.test.InstrumentationRegistry; //導入依賴的package包/類
@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);
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:30,代碼來源:UpdateAvailableTest.java

示例8: useAppContext

import android.support.test.InstrumentationRegistry; //導入依賴的package包/類
@Test
public void useAppContext() throws Exception {
    // Context of the app under test.
    Context appContext = InstrumentationRegistry.getTargetContext();

    assertEquals("com.highbryds.tracker", appContext.getPackageName());
}
 
開發者ID:smtrz,項目名稱:GPSTracker-Android,代碼行數:8,代碼來源:ExampleInstrumentedTest.java

示例9: useAppContext

import android.support.test.InstrumentationRegistry; //導入依賴的package包/類
@Test
public void useAppContext() throws Exception {
    // Context of the app under test.
    Context appContext = InstrumentationRegistry.getTargetContext();

    assertEquals("com.zhangyf.reward", appContext.getPackageName());
}
 
開發者ID:Yuphee,項目名稱:RewardLayout,代碼行數:8,代碼來源:ExampleInstrumentedTest.java

示例10: useAppContext

import android.support.test.InstrumentationRegistry; //導入依賴的package包/類
@Test
public void useAppContext() throws Exception {
    // Context of the app under test.
    Context appContext = InstrumentationRegistry.getTargetContext();

    assertEquals("com.example.ajaykumar.drawer", appContext.getPackageName());
}
 
開發者ID:ayushghd,項目名稱:iSPY,代碼行數:8,代碼來源:ExampleInstrumentedTest.java

示例11: useAppContext

import android.support.test.InstrumentationRegistry; //導入依賴的package包/類
@Test
public void useAppContext() throws Exception {
    // Context of the app under test.
    Context appContext = InstrumentationRegistry.getTargetContext();

    assertEquals("com.harpz.androidvalidator.test", appContext.getPackageName());
}
 
開發者ID:harpzzz,項目名稱:Android-Validator,代碼行數:8,代碼來源:ExampleInstrumentedTest.java

示例12: useAppContext

import android.support.test.InstrumentationRegistry; //導入依賴的package包/類
@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());
}
 
開發者ID:Lars3n95,項目名稱:AppRater-Dialog,代碼行數:8,代碼來源:ExampleInstrumentedTest.java

示例13: useAppContext

import android.support.test.InstrumentationRegistry; //導入依賴的package包/類
@Test
public void useAppContext() throws Exception {
    // Context of the app under test.
    Context appContext = InstrumentationRegistry.getTargetContext();

    assertEquals("de.lucasscheuvens.qtk", appContext.getPackageName());
}
 
開發者ID:kingblaubart,項目名稱:quidditchtimekeeper,代碼行數:8,代碼來源:ExampleInstrumentedTest.java

示例14: useAppContext

import android.support.test.InstrumentationRegistry; //導入依賴的package包/類
@Test
public void useAppContext() throws Exception {
    // Context of the app under test.
    Context appContext = InstrumentationRegistry.getTargetContext();

    assertEquals("moe.shizuku.bridge", appContext.getPackageName());
}
 
開發者ID:RikkaW,項目名稱:Bridge,代碼行數:8,代碼來源:ExampleInstrumentedTest.java

示例15: useAppContext

import android.support.test.InstrumentationRegistry; //導入依賴的package包/類
@Test
public void useAppContext() throws Exception {
    // Context of the app under test.
    Context appContext = InstrumentationRegistry.getTargetContext();

    assertEquals("com.suyashsrijan.autoscrollr", appContext.getPackageName());
}
 
開發者ID:theblixguy,項目名稱:AutoScrollr,代碼行數:8,代碼來源:ExampleInstrumentedTest.java


注:本文中的android.support.test.InstrumentationRegistry類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。