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


Java RuntimeEnvironment.application方法代碼示例

本文整理匯總了Java中org.robolectric.RuntimeEnvironment.application方法的典型用法代碼示例。如果您正苦於以下問題:Java RuntimeEnvironment.application方法的具體用法?Java RuntimeEnvironment.application怎麽用?Java RuntimeEnvironment.application使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.robolectric.RuntimeEnvironment的用法示例。


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

示例1: setUp

import org.robolectric.RuntimeEnvironment; //導入方法依賴的package包/類
@Before
public void setUp() throws Exception {
    final Application application = RuntimeEnvironment.application;
    sharedPreferences = application.getSharedPreferences("test", Context.MODE_PRIVATE);
    sharedPreferences.edit().clear().apply();

    //dataSaver = new SharedPreferencesDataSaver(sharedPreferences);
    dataSaver = new PaperDataSaver(application);
    dataSaver = spy(dataSaver);

    AndroidNoSql.initWith(
            dataSaver
    );
    noSql = NoSql.getInstance();
    noSql.reset();
}
 
開發者ID:florent37,項目名稱:Android-NoSql,代碼行數:17,代碼來源:SharedPrefsTest.java

示例2: testSaveFcmCredentials

import org.robolectric.RuntimeEnvironment; //導入方法依賴的package包/類
@Test public void testSaveFcmCredentials() {
  new Prefs(RuntimeEnvironment.application);
  Prefs.saveJwtToken("eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiI0U0lDWk05MmQ3Rnd4VG9lMGlwZUN3ZGRISXNWN1hNMEhmM1ppdUs4Y2hkWEwya3RxdVdJVndNRGlhc3ZRWGtWQ3pDVlV6Y21KSUplTUtEbWkxaXBNT2RlVnJEN1lLaWhrQVJBcmt3SGI1cWU2bTJPUFF4c0JVdTk0Rm1veEtacSJ9.W4AQ4XSV_19IJmELXuyBrbTxNZF28b2wLGVi-tfJjps");
  ServiceBuilder.init(Constants.BASE_URL, RuntimeEnvironment.application);

  try {
    FcmCredentials fcmCredentials = new FcmCredentials();
    fcmCredentials.setAccountId(Long.valueOf("1570123796151534997"));
    fcmCredentials.setToken(
        "e1sAmGApuFg:APA91bFhncSCrYlxuk10Zkcfy4M672gGQN2212MAj2AXTiu2favquLfyRrJkqppSNoc-Cz_tU7orSmeBE5Rmp5xCSEWWzkzn3R3hGyVOEZ2E0_BnbOhSug-fmgHCF-grAVSs3okUegGE");

    Response<BaseResponse<Object>> response =
        ServiceBuilder.getFcmService().saveFcmToken(fcmCredentials).execute();

    assertTrue(response.isSuccessful());
  } catch (Exception e) {
    e.printStackTrace();
  }
}
 
開發者ID:humaniq,項目名稱:react-native-android-library-humaniq-api,代碼行數:20,代碼來源:ProfileApiTest.java

示例3: beforeTest

import org.robolectric.RuntimeEnvironment; //導入方法依賴的package包/類
/**
 */
@Override
@CallSuper
public void beforeTest() throws Exception {
	super.beforeTest();
	this.mApplication = RuntimeEnvironment.application;
}
 
開發者ID:universum-studios,項目名稱:android_ui,代碼行數:9,代碼來源:RobolectricTestCase.java

示例4: shutdownDisallowedOnSingletonInstance

import org.robolectric.RuntimeEnvironment; //導入方法依賴的package包/類
@Test public void shutdownDisallowedOnSingletonInstance() {
  Picasso.singleton = null;
  PicassoProvider.context = RuntimeEnvironment.application;
  try {
    Picasso.with().shutdown();
    fail("Calling shutdown() on static singleton instance should throw");
  } catch (UnsupportedOperationException expected) {
  }
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:10,代碼來源:PicassoTest.java

示例5: setup

import org.robolectric.RuntimeEnvironment; //導入方法依賴的package包/類
@Before
public void setup() {
    context = RuntimeEnvironment.application;
    packageManager = context.getPackageManager();
    jobStore = JobStore.get(context);
    service = Robolectric.buildService(AlarmJobService.class).create();
}
 
開發者ID:Doist,項目名稱:JobSchedulerCompat,代碼行數:8,代碼來源:AlarmReceiverTest.java

示例6: setup

import org.robolectric.RuntimeEnvironment; //導入方法依賴的package包/類
@Before
public void setup() {
  mContext = new ReactApplicationContext(RuntimeEnvironment.application);
  mCatalystInstanceMock = ReactTestHelper.createMockCatalystInstance();
  mContext.initializeWithInstance(mCatalystInstanceMock);
  mThemeContext = new ThemedReactContext(mContext, mContext);
  Fresco.initialize(mContext);
  DisplayMetricsHolder.setWindowDisplayMetrics(new DisplayMetrics());
}
 
開發者ID:qq565999484,項目名稱:RNLearn_Project1,代碼行數:10,代碼來源:ReactImagePropertyTest.java

示例7: setUp

import org.robolectric.RuntimeEnvironment; //導入方法依賴的package包/類
@Before
public void setUp() {
  MockitoAnnotations.initMocks(this);
  bitmapToTransform = Bitmap.createBitmap(100, 100, Bitmap.Config.ARGB_8888);

  context = RuntimeEnvironment.application;
  Glide.init(new GlideBuilder().setBitmapPool(bitmapPool).build(context));
  when(drawableResourceToTransform.get()).thenReturn(drawableToTransform);
  when(drawableToTransform.getBitmap()).thenReturn(bitmapToTransform);
  transformation = new BitmapDrawableTransformation(wrapped);
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:12,代碼來源:BitmapDrawableTransformationTest.java

示例8: setUp

import org.robolectric.RuntimeEnvironment; //導入方法依賴的package包/類
@Before
public void setUp()
{
    // Output logs emitted during tests so they may be accessed
    ShadowLog.stream = System.out;
    db = new DBHelper(RuntimeEnvironment.application);

    prefs = RuntimeEnvironment.application.getSharedPreferences("protect.rentalcalc", Context.MODE_PRIVATE);
    // Assume that this is not the first launch
    prefs.edit().putBoolean("firstrun", false).commit();
}
 
開發者ID:brarcher,項目名稱:rental-calc,代碼行數:12,代碼來源:PropertiesListActivityTest.java

示例9: setUp

import org.robolectric.RuntimeEnvironment; //導入方法依賴的package包/類
@Before
public void setUp() {
  MockitoAnnotations.initMocks(this);
  context = RuntimeEnvironment.application;

  Glide.init(context, new GlideBuilder().setBitmapPool(bitmapPool));
  transformation = new GifDrawableTransformation(wrapped);
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:9,代碼來源:GifDrawableTransformationTest.java

示例10: testUpdatesAppWidgetWhenCreatedWithWidgetIds

import org.robolectric.RuntimeEnvironment; //導入方法依賴的package包/類
@Test
public void testUpdatesAppWidgetWhenCreatedWithWidgetIds() {
  int[] widgetIds = new int[] { 1 };
  AppWidgetTarget target =
      new AppWidgetTarget(RuntimeEnvironment.application, viewId, views, widgetIds);

  target.onResourceReady(Bitmap.createBitmap(200, 100, Bitmap.Config.ARGB_8888), null
  /*glideAnimation*/);

  assertThat(widgetIds).isEqualTo(shadowManager.updatedWidgetIds);
  assertEquals(views, shadowManager.updatedRemoteViews);
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:13,代碼來源:AppWidgetTargetTest.java

示例11: setup

import org.robolectric.RuntimeEnvironment; //導入方法依賴的package包/類
@Before
public void setup() {
    trackingProtectionWebViewClient = new TrackingProtectionWebViewClient(RuntimeEnvironment.application);

    webView = mock(WebView.class);
    when(webView.getContext()).thenReturn(RuntimeEnvironment.application);
}
 
開發者ID:mozilla-mobile,項目名稱:firefox-tv,代碼行數:8,代碼來源:TrackingProtectionWebViewClientTest.java

示例12: setUp

import org.robolectric.RuntimeEnvironment; //導入方法依賴的package包/類
@Before
public void setUp() {
  listener = mock(ConnectivityMonitor.ConnectivityListener.class);
  monitor = new DefaultConnectivityMonitor(RuntimeEnvironment.application, listener);
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:6,代碼來源:DefaultConnectivityMonitorTest.java

示例13: beforeEachTest

import org.robolectric.RuntimeEnvironment; //導入方法依賴的package包/類
@Before public void beforeEachTest() {
    Context context = RuntimeEnvironment.application;
    mapper = new FactsViewModelMapper(context);
}
 
開發者ID:ubiratansoares,項目名稱:reactive-architectures-playground,代碼行數:5,代碼來源:FactsViewModelMapperTests.java

示例14: getTestApplication

import org.robolectric.RuntimeEnvironment; //導入方法依賴的package包/類
private PostsApplication getTestApplication() {
    return (PostsApplication) RuntimeEnvironment.application;
}
 
開發者ID:ParaskP7,項目名稱:sample-code-posts,代碼行數:4,代碼來源:RobolectricGeneralTestHelper.java

示例15: before

import org.robolectric.RuntimeEnvironment; //導入方法依賴的package包/類
@Before
public void before() {
    context = RuntimeEnvironment.application;
    mockAccount = mock(Account.class);
}
 
開發者ID:philipwhiuk,項目名稱:q-mail,代碼行數:6,代碼來源:FolderInfoHolderTest.java


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