當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。