当前位置: 首页>>代码示例>>Java>>正文


Java InstrumentationRegistry.getContext方法代码示例

本文整理汇总了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);
}
 
开发者ID:PacktPublishing,项目名称:Expert-Android-Programming,代码行数:27,代码来源:UIAnimatorTest.java

示例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();
}
 
开发者ID:hortonworks,项目名称:nifi-android-s2s,代码行数:22,代码来源:SiteToSiteServiceTest.java

示例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);
}
 
开发者ID:emartech,项目名称:android-mobile-engage-sdk,代码行数:27,代码来源:MobileEngageInternalTest.java

示例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());
}
 
开发者ID:emartech,项目名称:android-mobile-engage-sdk,代码行数:23,代码来源:RequestUtilsTest.java

示例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();
}
 
开发者ID:hortonworks,项目名称:nifi-android-s2s,代码行数:21,代码来源:SiteToSiteRepeatingTest.java

示例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);
}
 
开发者ID:jiechic,项目名称:sqlbrite-sqlcipher,代码行数:19,代码来源:BriteDatabaseTest.java

示例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());
}
 
开发者ID:jakdor,项目名称:LabDayApp,代码行数:9,代码来源:ProjectRepositoryIntegrationTest.java

示例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);
}
 
开发者ID:emartech,项目名称:android-mobile-engage-sdk,代码行数:10,代码来源:ButtonClickedRepositoryTest.java

示例9: init

import android.support.test.InstrumentationRegistry; //导入方法依赖的package包/类
@Before
public void init() {
    DatabaseTestUtils.deleteMobileEngageDatabase();

    Context context = InstrumentationRegistry.getContext();
    dbHelper = new MobileEngageDbHelper(context);
}
 
开发者ID:emartech,项目名称:android-mobile-engage-sdk,代码行数:8,代码来源:MobileEngageDbHelperTest.java

示例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);
}
 
开发者ID:emartech,项目名称:android-mobile-engage-sdk,代码行数:14,代码来源:MessagingServiceUtilsTest.java

示例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();
}
 
开发者ID:google,项目名称:mobly-bundled-snippets,代码行数:8,代码来源:AccountSnippet.java

示例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);
}
 
开发者ID:victoraldir,项目名称:BuddyBook,代码行数:10,代码来源:LoginWithEmailTest.java

示例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);
}
 
开发者ID:uniquid,项目名称:uidcore-android,代码行数:11,代码来源:RegisterFactoryTest.java

示例14: getContext

import android.support.test.InstrumentationRegistry; //导入方法依赖的package包/类
protected Context getContext() {
    return mThemeContext != null ? mThemeContext : InstrumentationRegistry.getContext();
}
 
开发者ID:Axe-Ishmael,项目名称:Blockly,代码行数:4,代码来源:BlocklyTestCase.java

示例15: getRegisterFactory

import android.support.test.InstrumentationRegistry; //导入方法依赖的package包/类
@Override
public RegisterFactory getRegisterFactory() throws RegisterException {
    return new RegisterFactoryImpl(InstrumentationRegistry.getContext(), 5);
}
 
开发者ID:uniquid,项目名称:uidcore-android,代码行数:5,代码来源:AndroidDataSourceTest.java


注:本文中的android.support.test.InstrumentationRegistry.getContext方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。