org.robolectric.RuntimeEnvironment Java Examples
The following examples show how to use
org.robolectric.RuntimeEnvironment.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CctTransportBackendTest.java From firebase-android-sdk with Apache License 2.0 | 6 votes |
@Test public void decorate_whenOnline_shouldProperlyPopulateNetworkInfo() { CctTransportBackend backend = new CctTransportBackend(RuntimeEnvironment.application, wallClock, uptimeClock, 300); EventInternal result = backend.decorate( EventInternal.builder() .setEventMillis(INITIAL_WALL_TIME) .setUptimeMillis(INITIAL_UPTIME) .setTransportName("3") .setEncodedPayload(new EncodedPayload(PROTOBUF_ENCODING, PAYLOAD.toByteArray())) .build()); assertThat(result.get(CctTransportBackend.KEY_NETWORK_TYPE)) .isEqualTo(String.valueOf(NetworkConnectionInfo.NetworkType.MOBILE.getValue())); assertThat(result.get(CctTransportBackend.KEY_MOBILE_SUBTYPE)) .isEqualTo(String.valueOf(NetworkConnectionInfo.MobileSubtype.EDGE.getValue())); }
Example #2
Source File: RequestCreatorTest.java From picasso with Apache License 2.0 | 6 votes |
@Test public void intoImageViewSetsPlaceholderWithResourceId() { PlatformLruCache cache = new PlatformLruCache(0); Picasso picasso = spy(new Picasso(RuntimeEnvironment.application, mock(Dispatcher.class), UNUSED_CALL_FACTORY, null, cache, null, NO_TRANSFORMERS, NO_HANDLERS, NO_EVENT_LISTENERS, ARGB_8888, false, false)); ImageView target = mockImageViewTarget(); new RequestCreator(picasso, URI_1, 0).placeholder(android.R.drawable.picture_frame) .into(target); ArgumentCaptor<Drawable> drawableCaptor = ArgumentCaptor.forClass(Drawable.class); verify(target).setImageDrawable(drawableCaptor.capture()); assertThat(shadowOf(drawableCaptor.getValue()).getCreatedFromResId()) .isEqualTo(android.R.drawable.picture_frame); verify(picasso).enqueueAndSubmit(actionCaptor.capture()); assertThat(actionCaptor.getValue()).isInstanceOf(ImageViewAction.class); }
Example #3
Source File: UploadTest.java From firebase-android-sdk with Apache License 2.0 | 6 votes |
@Test public void fileUploadNoRecovery() throws Exception { System.out.println("Starting test fileUploadNoRecovery."); MockConnectionFactory factory = NetworkLayerMock.ensureNetworkMock("fileUploadNoRecovery", false); String filename = TEST_ASSET_ROOT + "flubbertest.jpg"; ClassLoader classLoader = UploadTest.class.getClassLoader(); InputStream imageStream = classLoader.getResourceAsStream(filename); Uri sourceFile = Uri.parse("file://" + filename); ContentResolver resolver = RuntimeEnvironment.application.getApplicationContext().getContentResolver(); Shadows.shadowOf(resolver).registerInputStream(sourceFile, imageStream); Task<StringBuilder> task = TestUploadHelper.fileUpload(sourceFile, "flubbertest.jpg"); TestUtil.await(task, 5, TimeUnit.SECONDS); factory.verifyOldMock(); TestUtil.verifyTaskStateChanges("fileUploadNoRecovery", task.getResult().toString()); }
Example #4
Source File: HttpProxyCacheServerTest.java From AndriodVideoCache with Apache License 2.0 | 6 votes |
@Test public void testTrimFileCacheForTotalCountLru() throws Exception { FileNameGenerator fileNameGenerator = new Md5FileNameGenerator(); HttpProxyCacheServer proxy = new HttpProxyCacheServer.Builder(RuntimeEnvironment.application) .cacheDirectory(cacheFolder) .fileNameGenerator(fileNameGenerator) .maxCacheFilesCount(2) .build(); readProxyResponse(proxy, proxy.getProxyUrl(HTTP_DATA_URL), 0); assertThat(new File(cacheFolder, fileNameGenerator.generate(HTTP_DATA_URL))).exists(); readProxyResponse(proxy, proxy.getProxyUrl(HTTP_DATA_URL_ONE_REDIRECT), 0); assertThat(new File(cacheFolder, fileNameGenerator.generate(HTTP_DATA_URL_ONE_REDIRECT))).exists(); readProxyResponse(proxy, proxy.getProxyUrl(HTTP_DATA_URL_3_REDIRECTS), 0); assertThat(new File(cacheFolder, fileNameGenerator.generate(HTTP_DATA_URL_3_REDIRECTS))).exists(); waitForAsyncTrimming(); assertThat(new File(cacheFolder, fileNameGenerator.generate(HTTP_DATA_URL))).doesNotExist(); }
Example #5
Source File: ViewUtilsAndroidTest.java From PainlessMusicPlayer with Apache License 2.0 | 6 votes |
@Test public void testIsScrollableViewLargeEnoughToScrollWhenTrue() { final Context context = RuntimeEnvironment.application; final Pair<Integer, ViewGroup> heightsResult = prepareViewGroupWithValidChildHeights(); final ViewGroup rootView = new FrameLayout(context); rootView.setBottom(heightsResult.first / 2); final ViewGroup appBarLayout = new FrameLayout(context); appBarLayout.setBottom(heightsResult.first / 2); final ViewGroup scrollableView = heightsResult.second; rootView.addView(appBarLayout); rootView.addView(scrollableView); assertTrue(ViewUtils.isScrollableViewLargeEnoughToScroll(rootView, appBarLayout, scrollableView, 0)); }
Example #6
Source File: WebFragmentTest.java From materialistic with Apache License 2.0 | 6 votes |
@Test public void testDownloadPdf() { ResolveInfo resolverInfo = new ResolveInfo(); resolverInfo.activityInfo = new ActivityInfo(); resolverInfo.activityInfo.applicationInfo = new ApplicationInfo(); resolverInfo.activityInfo.applicationInfo.packageName = ListActivity.class.getPackage().getName(); resolverInfo.activityInfo.name = ListActivity.class.getName(); ShadowPackageManager rpm = shadowOf(RuntimeEnvironment.application.getPackageManager()); when(item.getUrl()).thenReturn("http://example.com/file.pdf"); rpm.addResolveInfoForIntent(new Intent(Intent.ACTION_VIEW, Uri.parse(item.getUrl())), resolverInfo); WebView webView = activity.findViewById(R.id.web_view); ShadowWebView shadowWebView = Shadow.extract(webView); WebFragment fragment = (WebFragment) activity.getSupportFragmentManager() .findFragmentByTag(WebFragment.class.getName()); shadowWebView.getDownloadListener().onDownloadStart(item.getUrl(), "", "", "application/pdf", 0L); shadowWebView.getWebViewClient().onPageFinished(webView, PDF_LOADER_URL); verify(fragment.mFileDownloader).downloadFile( eq(item.getUrl()), eq("application/pdf"), any(FileDownloader.FileDownloaderCallback.class)); }
Example #7
Source File: InterceptorTest.java From storio with Apache License 2.0 | 6 votes |
@Before public void setUp() throws Exception { final SQLiteOpenHelper sqLiteOpenHelper = new TestSQLiteOpenHelper(RuntimeEnvironment.application); callCount = new AtomicInteger(0); interceptor1 = createInterceptor(); interceptor2 = createInterceptor(); storIOSQLite = DefaultStorIOSQLite.builder() .sqliteOpenHelper(sqLiteOpenHelper) .addTypeMapping(Tweet.class, SQLiteTypeMapping.<Tweet>builder() .putResolver(TweetTableMeta.PUT_RESOLVER) .getResolver(TweetTableMeta.GET_RESOLVER) .deleteResolver(TweetTableMeta.DELETE_RESOLVER) .build()) .addInterceptor(interceptor1) .addInterceptor(interceptor2) .build(); }
Example #8
Source File: RxBatteryManagerTest.java From rx-receivers with Apache License 2.0 | 6 votes |
@Test public void batteryStateChanges() { Application application = RuntimeEnvironment.application; TestSubscriber<BatteryState> o = new TestSubscriber<>(); RxBatteryManager.batteryChanges(application).subscribe(o); o.assertValues(); Intent intent1 = new Intent(Intent.ACTION_BATTERY_CHANGED) // .putExtra(BatteryManager.EXTRA_HEALTH, BatteryManager.BATTERY_HEALTH_COLD) .putExtra(BatteryManager.EXTRA_ICON_SMALL, 0x3def2) .putExtra(BatteryManager.EXTRA_LEVEL, 10) .putExtra(BatteryManager.EXTRA_PLUGGED, 0) .putExtra(BatteryManager.EXTRA_PRESENT, true) .putExtra(BatteryManager.EXTRA_SCALE, 100) .putExtra(BatteryManager.EXTRA_STATUS, BatteryManager.BATTERY_STATUS_CHARGING) .putExtra(BatteryManager.EXTRA_TECHNOLOGY, "unknown") .putExtra(BatteryManager.EXTRA_TEMPERATURE, 40) .putExtra(BatteryManager.EXTRA_VOLTAGE, 10000); application.sendBroadcast(intent1); BatteryState event1 = BatteryState.create(BatteryHealth.COLD, 0x3def2, 10, 0, true, 100, BatteryStatus.CHARGING, "unknown", 40, 10000); o.assertValues(event1); }
Example #9
Source File: DropInActivityUnitTest.java From braintree-android-drop-in with MIT License | 6 votes |
@Test public void onPaymentMethodNonceCreated_requestsThreeDSecureVerificationForNonNetworkTokenizedGooglePayWhenEnabled() throws Exception { PackageManager packageManager = mockPackageManagerSupportsThreeDSecure(); Context context = spy(RuntimeEnvironment.application); when(context.getPackageManager()).thenReturn(packageManager); mActivity.context = context; mActivity.setDropInRequest(new DropInRequest() .tokenizationKey(TOKENIZATION_KEY) .amount("1.00") .requestThreeDSecureVerification(true)); mActivity.httpClient = spy(new BraintreeUnitTestHttpClient() .configuration(new TestConfigurationBuilder() .threeDSecureEnabled(true) .build())); mActivityController.setup(); GooglePaymentCardNonce googlePaymentCardNonce = GooglePaymentCardNonce.fromJson( stringFromFixture("responses/google_pay_non_network_tokenized_response.json")); mActivity.onPaymentMethodNonceCreated(googlePaymentCardNonce); verify(mActivity.httpClient).post(matches(BraintreeUnitTestHttpClient.THREE_D_SECURE_LOOKUP), anyString(), any(HttpResponseCallback.class)); }
Example #10
Source File: BindingAdaptersTest.java From PainlessMusicPlayer with Apache License 2.0 | 6 votes |
@Test public void testSetFormattedDuration() { final TextView textView = new TextView(RuntimeEnvironment.application); assertEquals("", textView.getText()); BindingAdapters.setFormattedDuration(textView, 0); assertEquals("0:00", textView.getText()); BindingAdapters.setFormattedDuration(textView, 59); assertEquals("0:59", textView.getText()); BindingAdapters.setFormattedDuration(textView, 60); assertEquals("1:00", textView.getText()); BindingAdapters.setFormattedDuration(textView, 61); assertEquals("1:01", textView.getText()); BindingAdapters.setFormattedDuration(textView, 3600); assertEquals("1:00:00", textView.getText()); BindingAdapters.setFormattedDuration(textView, 3661); assertEquals("1:01:01", textView.getText()); }
Example #11
Source File: DefaultUriAdapterTest.java From weex-uikit with MIT License | 6 votes |
@Before public void setup() { WXEnvironment.sApplication = RuntimeEnvironment.application; WXSDKManager wxsdkManager = WXSDKManager.getInstance(); if (!new MockUtil().isSpy(wxsdkManager)) { WXSDKManager spy = Mockito.spy(wxsdkManager); WXSDKManagerTest.setInstance(spy); Mockito.when(spy.getIWXHttpAdapter()).thenReturn(new IWXHttpAdapter() { @Override public void sendRequest(WXRequest request, OnHttpListener listener) { //do nothing. } }); } adapter = new DefaultUriAdapter(); instance = WXSDKInstanceTest.createInstance(); }
Example #12
Source File: AndroidChannelBuilderTest.java From grpc-nebula-java with Apache License 2.0 | 6 votes |
@Test @Config(sdk = 23) public void shutdownNowUnregistersBroadcastReceiver_api23() { TestChannel delegateChannel = new TestChannel(); ManagedChannel androidChannel = new AndroidChannelBuilder.AndroidChannel( delegateChannel, RuntimeEnvironment.application.getApplicationContext()); shadowOf(connectivityManager).setActiveNetworkInfo(null); RuntimeEnvironment.application.sendBroadcast( new Intent(ConnectivityManager.CONNECTIVITY_ACTION)); androidChannel.shutdownNow(); shadowOf(connectivityManager).setActiveNetworkInfo(WIFI_CONNECTED); RuntimeEnvironment.application.sendBroadcast( new Intent(ConnectivityManager.CONNECTIVITY_ACTION)); assertThat(delegateChannel.resetCount).isEqualTo(0); }
Example #13
Source File: AndroidChannelBuilderTest.java From grpc-nebula-java with Apache License 2.0 | 6 votes |
@Test @Config(sdk = 24) public void newChannelWithConnection_entersIdleOnSecondConnectionChange_api24() { shadowOf(connectivityManager).setActiveNetworkInfo(MOBILE_CONNECTED); TestChannel delegateChannel = new TestChannel(); ManagedChannel androidChannel = new AndroidChannelBuilder.AndroidChannel( delegateChannel, RuntimeEnvironment.application.getApplicationContext()); // The first onAvailable() may just signal that the device was connected when the callback is // registered, rather than indicating a changed network, so we do not enter idle. shadowOf(connectivityManager).setActiveNetworkInfo(WIFI_CONNECTED); assertThat(delegateChannel.resetCount).isEqualTo(1); assertThat(delegateChannel.enterIdleCount).isEqualTo(0); shadowOf(connectivityManager).setActiveNetworkInfo(MOBILE_CONNECTED); assertThat(delegateChannel.resetCount).isEqualTo(1); assertThat(delegateChannel.enterIdleCount).isEqualTo(1); androidChannel.shutdown(); }
Example #14
Source File: ConcatAdapterTest.java From power-adapters with Apache License 2.0 | 6 votes |
@Before public void setUp() throws Exception { mChildAdapters = newArrayList( spy(new FakeAdapter(3)), spy(new FakeAdapter(4)), spy(new FakeAdapter(5)) ); mConcatAdapter = new ConcatAdapterBuilder().addAll(mChildAdapters).build(); mConcatAdapter.registerDataObserver(mObserver); mVerifyingObserver = new VerifyingAdapterObserver(mConcatAdapter); mConcatAdapter.registerDataObserver(mVerifyingObserver); for (PowerAdapter adapter : mChildAdapters) { verify(adapter).registerDataObserver(any(DataObserver.class)); verify(adapter).onFirstObserverRegistered(); } mParent = new FrameLayout(RuntimeEnvironment.application); mContainerViewGroup = new FrameLayout(RuntimeEnvironment.application); mItemView = new View(RuntimeEnvironment.application); }
Example #15
Source File: HttpProxyCacheTest.java From AndroidVideoCache with Apache License 2.0 | 6 votes |
@Test public void testReuseSourceInfo() throws Exception { SourceInfoStorage sourceInfoStorage = SourceInfoStorageFactory.newSourceInfoStorage(RuntimeEnvironment.application); HttpUrlSource source = new HttpUrlSource(HTTP_DATA_URL, sourceInfoStorage); File cacheFile = newCacheFile(); HttpProxyCache proxyCache = new HttpProxyCache(source, new FileCache(cacheFile)); processRequest(proxyCache, "GET /" + HTTP_DATA_URL + " HTTP/1.1"); HttpUrlSource notOpenableSource = ProxyCacheTestUtils.newNotOpenableHttpUrlSource(HTTP_DATA_URL, sourceInfoStorage); HttpProxyCache proxyCache2 = new HttpProxyCache(notOpenableSource, new FileCache(cacheFile)); Response response = processRequest(proxyCache2, "GET /" + HTTP_DATA_URL + " HTTP/1.1"); proxyCache.shutdown(); assertThat(response.data).isEqualTo(loadAssetFile(ASSETS_DATA_NAME)); assertThat(response.contentLength).isEqualTo(HTTP_DATA_SIZE); assertThat(response.contentType).isEqualTo("image/jpeg"); }
Example #16
Source File: SnackbarWrapperTest.java From SnackbarBuilder with Apache License 2.0 | 5 votes |
@Before public void before() { MockitoAnnotations.initMocks(this); RuntimeEnvironment.application.setTheme(R.style.TestSnackbarBuilder_AppTheme); CoordinatorLayout layout = new CoordinatorLayout(RuntimeEnvironment.application); snackbar = Snackbar.make(layout, "SomeText", Snackbar.LENGTH_LONG); wrapper = new SnackbarWrapper(snackbar); resourceCreator = MockResourceCreator .fromWrapper(wrapper) .withContext(context) .withResources(resources); }
Example #17
Source File: MatchResultControllerTest.java From android with Apache License 2.0 | 5 votes |
@Before public void setUp() { TestElifutApplication application = (TestElifutApplication) RuntimeEnvironment.application; application.testComponent().inject(this); userPreferences.clubPreference().set(userClub); persistenceService.create(leagueClubs.toList().toBlocking().first()); }
Example #18
Source File: WXDivTest.java From weex-uikit with MIT License | 5 votes |
@Test public void testAddChild(){ WXSDKInstance instance = Mockito.mock(WXSDKInstance.class); Mockito.when(instance.getContext()).thenReturn(RuntimeEnvironment.application); WXDomObject testDom = Mockito.mock(WXDomObject.class); Mockito.when(testDom.getPadding()).thenReturn(new Spacing()); Mockito.when(testDom.clone()).thenReturn(testDom); TestDomObject.setRef(testDom,"2"); WXText child1 = new WXText(instance, testDom, mWXDiv); child1.initView(); mWXDiv.addChild(child1, 0); assertEquals(1, mWXDiv.childCount()); WXDomObject testDom2 = Mockito.spy(new WXDomObject()); Mockito.when(testDom2.getPadding()).thenReturn(new Spacing()); Mockito.when(testDom2.clone()).thenReturn(testDom2); TestDomObject.setRef(testDom2,"3"); child2 = new WXText(instance, testDom2, mWXDiv); child2.initView(); mWXDiv.addChild(child2, -1); assertEquals(2, mWXDiv.childCount()); assertEquals(child2, mWXDiv.getChild(1)); WXDomObject testDom3 = Mockito.mock(WXDomObject.class); Mockito.when(testDom3.getPadding()).thenReturn(new Spacing()); Mockito.when(testDom3.clone()).thenReturn(testDom3); TestDomObject.setRef(testDom3,"4"); WXText child3 = new WXText(instance, testDom3, mWXDiv); child3.initView(); mWXDiv.addChild(child3, 1); assertEquals(3, mWXDiv.childCount()); assertEquals(child3, mWXDiv.getChild(1)); }
Example #19
Source File: LeanplumInflaterTest.java From Leanplum-Android-SDK with Apache License 2.0 | 5 votes |
/** * Test Inflator configuration */ @Test public void testInflater() { LeanplumInflater inflater = LeanplumInflater.from(RuntimeEnvironment.application.getApplicationContext()); assertNotNull(inflater); assertNotNull(inflater.getLeanplumResources()); }
Example #20
Source File: WXTimerModuleTest.java From ucar-weex-core with Apache License 2.0 | 5 votes |
@Before public void setup() throws Exception { WXSDKEngine.initialize(RuntimeEnvironment.application, new InitConfig.Builder().build()); WXBridgeManager bridge = Mockito.mock(WXBridgeManager.class); when(bridge.getJSLooper()).thenReturn(new WXThread("js").getLooper()); WXBridgeManagerTest.setBridgeManager(bridge); module = Mockito.spy(new WXTimerModule()); module.mWXSDKInstance = WXSDKInstanceTest.createInstance(); Handler handler = new Handler(WXBridgeManager.getInstance().getJSLooper(), module); mLooper = Shadows.shadowOf(handler.getLooper()); module.setHandler(handler); }
Example #21
Source File: VolleyXTest.java From VolleyX with Apache License 2.0 | 5 votes |
@Test public void testInit_context() throws Exception { VolleyX.init(RuntimeEnvironment.application); assertThat(VolleyX.DEFAULT_REQUESTQUEUE, is(not(nullValue()))); assertThat(VolleyX.sRequestQueue, is(not(nullValue()))); assertThat(VolleyX.sContext, is(not(nullValue()))); assertThat(VolleyX.sInited, is(true)); }
Example #22
Source File: LineApiClientImplTest.java From line-sdk-android with Apache License 2.0 | 5 votes |
@Before public void setUp() { MockitoAnnotations.initMocks(this); accessTokenCache = new AccessTokenCache( RuntimeEnvironment.application, CHANNEL_ID, new TestStringCipher()); target = new LineApiClientImpl( CHANNEL_ID, internalOauthApiClient, internalTalkApiClient, accessTokenCache); }
Example #23
Source File: ConfigurationManagerUnitTest.java From braintree_android with MIT License | 5 votes |
@Test(timeout = 1000) public void getConfiguration_writesConfigToDiskWithValidTimestampAfterFetch() throws InterruptedException { stubConfigurationFromGateway(stringFromFixture("configuration/configuration.json")); ConfigurationManager.getConfiguration(mBraintreeFragment, new ConfigurationListener() { @Override public void onConfigurationFetched(Configuration configuration) { String key = Base64.encodeToString( Uri.parse(mTokenizationKey.getConfigUrl()) .buildUpon() .appendQueryParameter("configVersion", "3") .build() .toString() .concat(mTokenizationKey.getBearer()) .getBytes(), 0); assertEquals(stringFromFixture("configuration/configuration.json"), getSharedPreferences(RuntimeEnvironment.application).getString(key, "")); assertTrue(System.currentTimeMillis() - getSharedPreferences(RuntimeEnvironment.application).getLong(key + "_timestamp", 0) < 1000); mCountDownLatch.countDown(); } }, new BraintreeResponseListener<Exception>() { @Override public void onResponse(Exception e) { fail(e.getMessage()); } }); mCountDownLatch.await(); }
Example #24
Source File: ReactTestHelper.java From react-native-GPay with MIT License | 5 votes |
/** * @return a ReactApplicationContext that has a CatalystInstance mock returned by * {@link #createMockCatalystInstance} */ public static ReactApplicationContext createCatalystContextForTest() { ReactApplicationContext context = new ReactApplicationContext(RuntimeEnvironment.application); context.initializeWithInstance(createMockCatalystInstance()); return context; }
Example #25
Source File: BaseActivityUnitTest.java From braintree-android-drop-in with MIT License | 5 votes |
@Test public void shouldRequestThreeDSecureVerification_returnsFalseWhenNotRequested() { setup(new DropInRequest() .tokenizationKey(TOKENIZATION_KEY) .amount("1.00") .requestThreeDSecureVerification(false) .getIntent(RuntimeEnvironment.application)); mActivity.mConfiguration = new TestConfigurationBuilder() .threeDSecureEnabled(true) .buildConfiguration(); assertFalse(mActivity.shouldRequestThreeDSecureVerification()); }
Example #26
Source File: WXSDKEngineTest.java From ucar-weex-core with Apache License 2.0 | 5 votes |
@Test public void testInit() throws Exception { assertFalse(WXSDKEngine.isInitialized()); WXSDKEngine.initialize(RuntimeEnvironment.application,null); assertTrue(WXSDKEngine.isInitialized()); //keep compatible WXSDKEngine.init(RuntimeEnvironment.application); WXSDKEngine.init(RuntimeEnvironment.application,null); WXSDKEngine.init(RuntimeEnvironment.application,null,null); WXSDKEngine.init(RuntimeEnvironment.application,null,null,null,null); }
Example #27
Source File: HostsTest.java From EhViewer with Apache License 2.0 | 5 votes |
@Test public void testDelete() { Hosts hosts = new Hosts(RuntimeEnvironment.application, "hosts.db"); hosts.put("ni.hao", "127.0.0.1"); assertEquals("ni.hao/127.0.0.1", hosts.get("ni.hao").toString()); hosts.put("ni.hao", "127.0.0.2"); hosts.delete("ni.hao"); assertEquals(null, hosts.get("ni.hao")); hosts.delete(null); }
Example #28
Source File: LegacyUriRedirectHandlerTest.java From rides-android-sdk with MIT License | 5 votes |
@Before public void setup() { MockitoAnnotations.initMocks(this); applicationInfo = new ApplicationInfo(); applicationInfo.flags = ApplicationInfo.FLAG_DEBUGGABLE; activity = spy(Robolectric.setupActivity(Activity.class)); //applicationInfo.flags = 0; when(sessionConfiguration.getRedirectUri()).thenReturn("com.example.uberauth://redirect"); when(loginManager.getSessionConfiguration()).thenReturn(sessionConfiguration); when(activity.getApplicationInfo()).thenReturn(applicationInfo); when(activity.getPackageManager()).thenReturn(packageManager); when(activity.getPackageName()).thenReturn("com.example"); legacyUriRedirectHandler = new LegacyUriRedirectHandler(); misconfiguredAuthCode = RuntimeEnvironment.application.getString( R.string.ub__misconfigured_auth_code_flow_log); missingRedirectUri = RuntimeEnvironment.application.getString( R.string.ub__missing_redirect_uri_log); mismatchingRedirectUri = RuntimeEnvironment.application.getString( R.string.ub__mismatching_redirect_uri_log); alertTitle = RuntimeEnvironment.application.getString( R.string.ub__misconfigured_redirect_uri_title); alertMessage = RuntimeEnvironment.application.getString( R.string.ub__misconfigured_redirect_uri_message); }
Example #29
Source File: LightActivityTest.java From openwebnet-android with MIT License | 5 votes |
private void createWithIntent(String uuidExtra) { Intent intent = new Intent(RuntimeEnvironment.application, LightActivity.class); intent.putExtra(RealmModel.FIELD_UUID, uuidExtra); controller = Robolectric.buildActivity(LightActivity.class, intent); activity = controller .create() .start() .resume() .visible() .get(); ButterKnife.bind(this, activity); }
Example #30
Source File: NoInternetActivityTest.java From ello-android with MIT License | 5 votes |
@Before public void setup() { testNetComponent = ((TestNetComponent)((TestElloApp) RuntimeEnvironment.application).getNetComponent()); testNetComponent.inject(this); activity = Robolectric.buildActivity(NoInternetActivity.class).create().get(); button = (Button) activity.findViewById(R.id.refreshButton); }