本文整理汇总了Java中android.support.test.InstrumentationRegistry.getContext方法的典型用法代码示例。如果您正苦于以下问题:Java InstrumentationRegistry.getContext方法的具体用法?Java InstrumentationRegistry.getContext怎么用?Java InstrumentationRegistry.getContext使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.support.test.InstrumentationRegistry
的用法示例。
在下文中一共展示了InstrumentationRegistry.getContext方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: startMainActivityFromHomeScreen
import android.support.test.InstrumentationRegistry; //导入方法依赖的package包/类
@Before
public void startMainActivityFromHomeScreen() {
// Initialize UiDevice instance
mDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation());
// Start from the home screen
mDevice.pressHome();
// Wait for launcher
final String launcherPackage = mDevice.getLauncherPackageName();
Assert.assertThat(launcherPackage, CoreMatchers.notNullValue());
mDevice.wait(Until.hasObject(By.pkg(launcherPackage).depth(0)),
LAUNCH_TIMEOUT);
// Launch the app
Context context = InstrumentationRegistry.getContext();
final Intent intent = context.getPackageManager()
.getLaunchIntentForPackage(BASIC_SAMPLE_PACKAGE);
// Clear out any previous instances
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
context.startActivity(intent);
// Wait for the app to appear
mDevice.wait(Until.hasObject(By.pkg(BASIC_SAMPLE_PACKAGE).depth(0)),
LAUNCH_TIMEOUT);
}
示例2: setup
import android.support.test.InstrumentationRegistry; //导入方法依赖的package包/类
@Before
public void setup() throws IOException {
context = InstrumentationRegistry.getContext();
siteToSiteDB = SiteToSiteDBTestUtil.getCleanSiteToSiteDB(context);
mockNiFiS2SServer = new MockNiFiS2SServer();
portIdentifier = "testPortIdentifier";
transactionIdentifier = "testTransactionId";
peer = new Peer(mockNiFiS2SServer.getNifiApiUrl(), 0);
siteToSiteClientConfig = new SiteToSiteClientConfig();
siteToSiteClientConfig.setPortIdentifier(portIdentifier);
SiteToSiteRemoteCluster siteToSiteRemoteCluster = new SiteToSiteRemoteCluster();
siteToSiteRemoteCluster.setUrls(Collections.singleton(mockNiFiS2SServer.getNifiApiUrl()));
siteToSiteClientConfig.setRemoteClusters(Collections.singletonList(siteToSiteRemoteCluster));
queuedSiteToSiteClientConfig = new QueuedSiteToSiteClientConfig(siteToSiteClientConfig);
queuedOperationResultCallback = new QueuedOperationResultCallbackTestImpl();
transactionResultCallback = new TransactionResultCallbackTestImpl();
}
示例3: init
import android.support.test.InstrumentationRegistry; //导入方法依赖的package包/类
@Before
public void init() {
MobileEngageExperimental.enableFeature(MobileEngageFeature.IN_APP_MESSAGING);
manager = mock(RequestManager.class);
coreCompletionHandler = mock(MobileEngageCoreCompletionHandler.class);
application = (Application) InstrumentationRegistry.getTargetContext().getApplicationContext();
deviceInfo = new DeviceInfo(application);
appLoginStorage = new AppLoginStorage(application);
appLoginStorage.remove();
statusListener = mock(MobileEngageStatusListener.class);
baseConfig = new MobileEngageConfig.Builder()
.application(application)
.credentials(APPLICATION_ID, APPLICATION_SECRET)
.statusListener(statusListener)
.disableDefaultChannel()
.build();
defaultHeaders = RequestUtils.createDefaultHeaders(baseConfig);
mobileEngage = new MobileEngageInternal(baseConfig, manager, appLoginStorage, coreCompletionHandler);
context = InstrumentationRegistry.getContext();
new MeIdStorage(context).set(ME_ID);
}
示例4: setup
import android.support.test.InstrumentationRegistry; //导入方法依赖的package包/类
@Before
public void setup() {
config = new MobileEngageConfig.Builder()
.application((Application) InstrumentationRegistry.getTargetContext().getApplicationContext())
.credentials(APPLICATION_CODE, APPLICATION_PASSWORD)
.disableDefaultChannel()
.build();
debugConfig = new MobileEngageConfig.Builder()
.application(ApplicationTestUtils.applicationDebug())
.credentials(APPLICATION_CODE, APPLICATION_PASSWORD)
.disableDefaultChannel()
.build();
releaseConfig = new MobileEngageConfig.Builder()
.application(ApplicationTestUtils.applicationRelease())
.credentials(APPLICATION_CODE, APPLICATION_PASSWORD)
.disableDefaultChannel()
.build();
deviceInfo = new DeviceInfo(InstrumentationRegistry.getContext());
}
示例5: setup
import android.support.test.InstrumentationRegistry; //导入方法依赖的package包/类
@Before
public void setup() throws IOException {
context = InstrumentationRegistry.getContext();
siteToSiteDB = SiteToSiteDBTestUtil.getCleanSiteToSiteDB(context);
mockNiFiS2SServer = new MockNiFiS2SServer();
portIdentifier = "testPortIdentifier";
transactionIdentifier = "testTransactionId";
peer = new Peer(mockNiFiS2SServer.getNifiApiUrl(), 0);
siteToSiteClientConfig = new SiteToSiteClientConfig();
siteToSiteClientConfig.setPortIdentifier(portIdentifier);
SiteToSiteRemoteCluster siteToSiteRemoteCluster = new SiteToSiteRemoteCluster();
siteToSiteRemoteCluster.setUrls(Collections.singleton(mockNiFiS2SServer.getNifiApiUrl()));
siteToSiteClientConfig.setRemoteClusters(Collections.singletonList(siteToSiteRemoteCluster));
queuedSiteToSiteClientConfig = new QueuedSiteToSiteClientConfig(siteToSiteClientConfig);
parcelableQueuedOperationResultCallback = new ParcelableQueuedOperationResultCallbackTestImpl();
parcelableTransactionResultCallback = new ParcelableTransactionResultCallbackTestImpl();
}
示例6: setUp
import android.support.test.InstrumentationRegistry; //导入方法依赖的package包/类
@Before public void setUp() throws IOException {
helper = new TestDb(InstrumentationRegistry.getContext(), dbFolder.newFile().getPath());
real = helper.getWritableDatabase();
SqlBrite.Logger logger = new SqlBrite.Logger() {
@Override public void log(String message) {
logs.add(message);
}
};
ObservableTransformer<Query, Query> queryTransformer =
new ObservableTransformer<Query, Query>() {
@Override public ObservableSource<Query> apply(Observable<Query> upstream) {
return upstream.takeUntil(killSwitch);
}
};
PublishSubject<Set<String>> triggers = PublishSubject.create();
db = new BriteDatabase(helper, logger, triggers, triggers, scheduler, queryTransformer);
}
示例7: setUp
import android.support.test.InstrumentationRegistry; //导入方法依赖的package包/类
@Before
public void setUp() throws Exception {
testContext = InstrumentationRegistry.getContext();
targetContext = InstrumentationRegistry.getTargetContext(); //todo replace with mock
projectRepository = new ProjectRepository(
new NetworkManager(new RetrofitBuilder()), new RxSchedulersFacade());
}
示例8: init
import android.support.test.InstrumentationRegistry; //导入方法依赖的package包/类
@Before
public void init() {
DatabaseTestUtils.deleteMobileEngageDatabase();
Context context = InstrumentationRegistry.getContext();
repository = new ButtonClickedRepository(context);
buttonClicked1 = new ButtonClicked("campaign1", "button1", new Date().getTime());
buttonClicked2 = new ButtonClicked("campaign2", "button2", new Date().getTime() + 1000);
}
示例9: init
import android.support.test.InstrumentationRegistry; //导入方法依赖的package包/类
@Before
public void init() {
DatabaseTestUtils.deleteMobileEngageDatabase();
Context context = InstrumentationRegistry.getContext();
dbHelper = new MobileEngageDbHelper(context);
}
示例10: init
import android.support.test.InstrumentationRegistry; //导入方法依赖的package包/类
@Before
@SuppressWarnings("unchecked")
public void init() throws Exception {
context = InstrumentationRegistry.getContext();
Field cacheField = NotificationCache.class.getDeclaredField("internalCache");
cacheField.setAccessible(true);
notificationCache = (List) cacheField.get(null);
notificationCache.clear();
enabledOreoConfig = new OreoConfig(true, "name", "description");
disabledOreoConfig = new OreoConfig(false);
}
示例11: AccountSnippet
import android.support.test.InstrumentationRegistry; //导入方法依赖的package包/类
public AccountSnippet() {
Context context = InstrumentationRegistry.getContext();
mAccountManager = AccountManager.get(context);
mSyncStatusObserverHandles = new LinkedList<>();
mSyncWhitelist = new HashMap<>();
mLock = new ReentrantReadWriteLock();
}
示例12: registerIdlingResource
import android.support.test.InstrumentationRegistry; //导入方法依赖的package包/类
@Before
public void registerIdlingResource() {
instrumentationCtx = InstrumentationRegistry.getContext();
mIdlingResource = mActivityTestRule.getActivity().getIdlingResource();
// To prove that the test fails, omit this call:
Espresso.registerIdlingResources(mIdlingResource);
}
示例13: testConstructor
import android.support.test.InstrumentationRegistry; //导入方法依赖的package包/类
@Test
public void testConstructor() throws RegisterException {
RegisterFactoryImpl registerFactory = new RegisterFactoryImpl(InstrumentationRegistry.getContext(), 5);
assertNotNull(registerFactory);
RegisterFactoryImpl registerName = new RegisterFactoryImpl(InstrumentationRegistry.getContext(), 5, "test.db");
assertNotNull(registerName);
assertNotSame(registerFactory, registerName);
}
示例14: getContext
import android.support.test.InstrumentationRegistry; //导入方法依赖的package包/类
protected Context getContext() {
return mThemeContext != null ? mThemeContext : InstrumentationRegistry.getContext();
}
示例15: getRegisterFactory
import android.support.test.InstrumentationRegistry; //导入方法依赖的package包/类
@Override
public RegisterFactory getRegisterFactory() throws RegisterException {
return new RegisterFactoryImpl(InstrumentationRegistry.getContext(), 5);
}