本文整理汇总了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);
}
示例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);
}
示例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());
}
示例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);
}
示例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());
}
示例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());
}
示例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);
}
示例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());
}
示例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());
}
示例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());
}
示例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());
}
示例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());
}
示例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());
}
示例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());
}
示例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());
}