@Test public void migratePgpInlineEncryptedMessage() throws Exception { SQLiteDatabase db = createV50Database(); insertPgpInlineEncryptedMessage(db); db.close(); LocalStore localStore = LocalStore.getInstance(account, RuntimeEnvironment.application); LocalMessage msg = localStore.getFolder("dev").getMessage("7"); FetchProfile fp = new FetchProfile(); fp.add(FetchProfile.Item.BODY); localStore.getFolder("dev").fetch(Collections.singletonList(msg), fp, null); Assert.assertEquals(6, msg.getDatabaseId()); Assert.assertEquals(12, msg.getHeaderNames().size()); Assert.assertEquals("text/plain", msg.getMimeType()); Assert.assertEquals(0, msg.getAttachmentCount()); Assert.assertTrue(msg.getBody() instanceof BinaryMemoryBody); String msgTextContent = MessageExtractor.getTextFromPart(msg); Assert.assertEquals(OpenPgpUtils.PARSE_RESULT_MESSAGE, OpenPgpUtils.parseMessage(msgTextContent)); }
@Test public void migrateTextHtml() throws Exception { SQLiteDatabase db = createV50Database(); insertMultipartAlternativeMessage(db); db.close(); LocalStore localStore = LocalStore.getInstance(account, RuntimeEnvironment.application); LocalMessage msg = localStore.getFolder("dev").getMessage("9"); FetchProfile fp = new FetchProfile(); fp.add(FetchProfile.Item.BODY); localStore.getFolder("dev").fetch(Collections.singletonList(msg), fp, null); Assert.assertEquals(8, msg.getDatabaseId()); Assert.assertEquals(9, msg.getHeaderNames().size()); Assert.assertEquals("multipart/alternative", msg.getMimeType()); Assert.assertEquals(0, msg.getAttachmentCount()); Multipart msgBody = (Multipart) msg.getBody(); Assert.assertEquals("------------060200010509000000040004", msgBody.getBoundary()); }
/** * Verify assets can be read with robolectric. * * @throws IOException if failed. */ @Test public void check() throws IOException { final InputStream s = RuntimeEnvironment.application.getAssets() .open(new File("check.txt").getPath()); Assert.assertNotNull(s); try { MatcherAssert.assertThat( IOUtils.toString(s), Matchers.equalTo("check") ); } finally { //noinspection ThrowFromFinallyBlock s.close(); } }
@Test public void testGetProxiedUrlForPartialCache() throws Exception { File cacheDir = RuntimeEnvironment.application.getExternalCacheDir(); File file = new File(cacheDir, new Md5FileNameGenerator().generate(HTTP_DATA_URL)); int partialCacheSize = 1000; byte[] partialData = ProxyCacheTestUtils.generate(partialCacheSize); File partialCacheFile = ProxyCacheTestUtils.getTempFile(file); IoUtils.saveToFile(partialData, partialCacheFile); HttpProxyCacheServer proxy = newProxy(cacheFolder); String expectedUrl = "http://127.0.0.1:" + getPort(proxy) + "/" + ProxyCacheUtils.encode(HTTP_DATA_URL); assertThat(proxy.getProxyUrl(HTTP_DATA_URL)).isEqualTo(expectedUrl); assertThat(proxy.getProxyUrl(HTTP_DATA_URL, true)).isEqualTo(expectedUrl); assertThat(proxy.getProxyUrl(HTTP_DATA_URL, false)).isEqualTo(expectedUrl); proxy.shutdown(); }
@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"); }
@Test public void create_with_custom_sharables() { final List<Shareable> shareables = Stream.generate(() -> mock(Shareable.class)).limit(2) .collect(Collectors.toList()); final PhialBuilder builder = new PhialBuilder(RuntimeEnvironment.application); shareables.forEach(builder::addShareable); final PhialCore phialCore = PhialCore.create(builder); final List<Shareable> createdShareables = phialCore.getShareManager() .getUserShareItems() .stream() .map(item -> (UserShareItem) item) .map(UserShareItem::getShareable) .collect(Collectors.toList()); assertEquals(shareables, createdShareables); }
@Before public void setUp() throws Exception { Glide.tearDown(); RobolectricPackageManager pm = RuntimeEnvironment.getRobolectricPackageManager(); ApplicationInfo info = pm.getApplicationInfo(RuntimeEnvironment.application.getPackageName(), 0); info.metaData = new Bundle(); info.metaData.putString(SetupModule.class.getName(), "GlideModule"); // Ensure that target's size ready callback will be called synchronously. target = mock(Target.class); imageView = new ImageView(RuntimeEnvironment.application); imageView.setLayoutParams(new ViewGroup.LayoutParams(100, 100)); imageView.layout(0, 0, 100, 100); doAnswer(new CallSizeReady()).when(target).getSize(isA(SizeReadyCallback.class)); Handler bgHandler = mock(Handler.class); when(bgHandler.post(isA(Runnable.class))).thenAnswer(new Answer<Boolean>() { @Override public Boolean answer(InvocationOnMock invocation) throws Throwable { Runnable runnable = (Runnable) invocation.getArguments()[0]; runnable.run(); return true; } }); Lifecycle lifecycle = mock(Lifecycle.class); RequestManagerTreeNode treeNode = mock(RequestManagerTreeNode.class); requestManager = new RequestManager(Glide.get(getContext()), lifecycle, treeNode); requestManager.resumeRequests(); }
@Test public void createIntentForAction_matchingPackage() { shadowPackageManager.addResolveInfoForIntent( saveIntent, createResolveInfo(EXAMPLE_PROVIDER_PACKAGE, EXAMPLE_PROVIDER_ACTIVITY_CLASS)); Intent intentForAction = ProviderResolver.createIntentForAction( RuntimeEnvironment.application, EXAMPLE_PROVIDER_PACKAGE, ProtocolConstants.SAVE_CREDENTIAL_ACTION); assertThat(intentForAction).isNotNull(); assertThat(intentForAction.getAction()) .isEqualTo(ProtocolConstants.SAVE_CREDENTIAL_ACTION); assertThat(intentForAction.getCategories()) .containsExactly(ProtocolConstants.OPENYOLO_CATEGORY); assertThat(intentForAction.getComponent()).isNotNull(); assertThat(intentForAction.getComponent().getPackageName()) .isEqualTo(EXAMPLE_PROVIDER_PACKAGE); assertThat(intentForAction.getComponent().getClassName()) .isEqualTo(EXAMPLE_PROVIDER_ACTIVITY_CLASS); }
@Test public void testCustomTabIntent() { final SessionManager sessionManager = SessionManager.getInstance(); final SafeIntent intent = new SafeIntent(new CustomTabsIntent.Builder() .setToolbarColor(Color.GREEN) .addDefaultShareMenuItem() .build() .intent .setData(Uri.parse(TEST_URL))); sessionManager.handleIntent(RuntimeEnvironment.application, intent, null); final List<Session> sessions = sessionManager.getSessions().getValue(); assertNotNull(sessions); assertEquals(1, sessions.size()); final Session session = sessions.get(0); assertEquals(TEST_URL, session.getUrl().getValue()); assertTrue(sessionManager.hasSession()); }
@Test public void testHandlesPaths() throws IOException { // TODO on windows it will fail with schema being the drive letter (C:\... -> C) assumeTrue(!Util.isWindows()); File f = RuntimeEnvironment.application.getCacheDir(); Uri expected = Uri.fromFile(f); when(uriLoader.buildLoadData(eq(expected), eq(IMAGE_SIDE), eq(IMAGE_SIDE), eq(options))) .thenReturn(new ModelLoader.LoadData<>(key, fetcher)); assertTrue(loader.handles(f.getAbsolutePath())); assertEquals( fetcher, Preconditions.checkNotNull( loader.buildLoadData(f.getAbsolutePath(), IMAGE_SIDE, IMAGE_SIDE, options)).fetcher); }
@Test public void testDispatchDraw(){ Canvas canvas = Mockito.mock(Canvas.class); ShadowSelectorView view = new ShadowSelectorView(RuntimeEnvironment.application); view.setIndicatorPoint(new PointF(0, 0)); view.setSelectorCircleSize(20); view.triggerOnLayout(true, 0, 0, 500, 500); view.triggerDispatchDraw(canvas); final ArgumentCaptor<Paint> captor = ArgumentCaptor.forClass(Paint.class); verify(canvas).drawCircle(eq(0f), eq(0f), eq(20f), captor.capture()); Paint paint = captor.getValue(); Assert.assertEquals(Color.LTGRAY, paint.getColor()); verify(canvas).drawLine(eq(0f), eq(0f), eq(250f), eq(250f), captor.capture()); }
@Before public void setUp() throws Exception { MockitoAnnotations.initMocks(this); options = new Options(); DisplayMetrics displayMetrics = RuntimeEnvironment.application.getResources().getDisplayMetrics(); when(byteArrayPool.get(anyInt(), Matchers.eq(byte[].class))) .thenReturn(new byte[ArrayPool.STANDARD_BUFFER_SIZE_BYTES]); List<ImageHeaderParser> parsers = new ArrayList<ImageHeaderParser>(); parsers.add(new DefaultImageHeaderParser()); downsampler = new Downsampler(parsers, displayMetrics, bitmapPool, byteArrayPool); initialSdkVersion = Build.VERSION.SDK_INT; }
@Test public void testReturnsOpenedInputStreamWhenFileFound() throws FileNotFoundException { InputStream expected = new ByteArrayInputStream(new byte[0]); Shadows.shadowOf(RuntimeEnvironment.application.getContentResolver()) .registerInputStream(harness.uri, expected); assertEquals(expected, harness.get().open(harness.uri)); }
@Before public void setUp() { MockitoAnnotations.initMocks(this); context = RuntimeEnvironment.application; connectivityMonitor = mock(ConnectivityMonitor.class); ConnectivityMonitorFactory factory = mock(ConnectivityMonitorFactory.class); when(factory.build(isA(Context.class), isA(ConnectivityMonitor.ConnectivityListener.class))) .thenAnswer(new Answer<ConnectivityMonitor>() { @Override public ConnectivityMonitor answer(InvocationOnMock invocation) throws Throwable { connectivityListener = (ConnectivityListener) invocation.getArguments()[1]; return connectivityMonitor; } }); target = new BaseTarget<Drawable>() { @Override public void onResourceReady(Drawable resource, Transition<? super Drawable> transition) { // Empty. } @Override public void getSize(SizeReadyCallback cb) { // Empty. } @Override public void removeCallback(SizeReadyCallback cb) { // Empty. } }; requestTracker = mock(RequestTracker.class); manager = new RequestManager( Glide.get(RuntimeEnvironment.application), lifecycle, treeNode, requestTracker, factory, context); }
@Test // https://github.com/danikula/AndroidVideoCache/issues/28 public void testDoesNotWorkWithoutCustomProxySelector() throws Exception { HttpProxyCacheServer httpProxyCacheServer = new HttpProxyCacheServer(RuntimeEnvironment.application); // IgnoreHostProxySelector is set in HttpProxyCacheServer constructor. So let reset it by custom. installExternalSystemProxy(); String proxiedUrl = httpProxyCacheServer.getProxyUrl(HTTP_DATA_URL); // server can't proxy this url due to it is not alive (can't ping itself), so it returns original url assertThat(proxiedUrl).isEqualTo(HTTP_DATA_URL); }
MemorySizeCalculator getCalculator() { when(screenDimensions.getWidthPixels()).thenReturn(pixelSize); when(screenDimensions.getHeightPixels()).thenReturn(pixelSize); return new MemorySizeCalculator.Builder(RuntimeEnvironment.application) .setMemoryCacheScreens(memoryCacheScreens) .setBitmapPoolScreens(bitmapPoolScreens) .setMaxSizeMultiplier(sizeMultiplier) .setActivityManager(activityManager) .setScreenDimensions(screenDimensions) .setArrayPoolSize(byteArrayPoolSizeBytes) .build(); }
@Before public void setUp() throws Exception { context = RuntimeEnvironment.application; GlobalsHelper.setContext(context); HtmlProcessor htmlProcessor = createFakeHtmlProcessor(); attachmentInfoExtractor = spy(AttachmentInfoExtractor.getInstance()); iCalendarInfoExtractor = spy(ICalendarInfoExtractor.getInstance()); messageViewInfoExtractor = new MessageViewInfoExtractor(context, attachmentInfoExtractor, iCalendarInfoExtractor, htmlProcessor); }
@Test public void migrateTextPlain() throws Exception { SQLiteDatabase db = createV50Database(); insertSimplePlaintextMessage(db); db.close(); LocalStore localStore = LocalStore.getInstance(account, RuntimeEnvironment.application); LocalMessage msg = localStore.getFolder("dev").getMessage("3"); FetchProfile fp = new FetchProfile(); fp.add(FetchProfile.Item.BODY); localStore.getFolder("dev").fetch(Collections.singletonList(msg), fp, null); Assert.assertEquals("text/plain", msg.getMimeType()); Assert.assertEquals(2, msg.getDatabaseId()); Assert.assertEquals(13, msg.getHeaderNames().size()); Assert.assertEquals(0, msg.getAttachmentCount()); Assert.assertEquals(1, msg.getHeader("User-Agent").length); Assert.assertEquals("Mutt/1.5.24 (2015-08-30)", msg.getHeader("User-Agent")[0]); Assert.assertEquals(1, msg.getHeader(MimeHeader.HEADER_CONTENT_TYPE).length); Assert.assertEquals("text/plain", MimeUtility.getHeaderParameter(msg.getHeader(MimeHeader.HEADER_CONTENT_TYPE)[0], null)); Assert.assertEquals("utf-8", MimeUtility.getHeaderParameter(msg.getHeader(MimeHeader.HEADER_CONTENT_TYPE)[0], "charset")); Assert.assertTrue(msg.getBody() instanceof BinaryMemoryBody); String msgTextContent = MessageExtractor.getTextFromPart(msg); Assert.assertEquals("nothing special here.\r\n", msgTextContent); }
@Before public void setUp() throws Exception { WXEnvironment.sApplication = RuntimeEnvironment.application; WXDiv div = WXDivTest.create(); ComponentTest.create(div); component = new WXEmbed(div.getInstance(),new TestDomObject(),div); ComponentTest.create(component); component.getDomObject().getStyles().put(Constants.Name.VISIBILITY, Constants.Value.VISIBLE); }
/** * Assuming no other views have been created, the root view will have tag 1, Text tag 2, and * RawText tag 3. */ private ViewGroup createSimpleTextHierarchy(UIManagerModule uiManager, String text) { ReactRootView rootView = new ReactRootView(RuntimeEnvironment.application.getApplicationContext()); int rootTag = uiManager.addMeasuredRootView(rootView); int textTag = rootTag + 1; int rawTextTag = textTag + 1; uiManager.createView( textTag, ReactTextViewManager.REACT_CLASS, rootTag, JavaOnlyMap.of("collapsable", false)); uiManager.createView( rawTextTag, ReactRawTextManager.REACT_CLASS, rootTag, JavaOnlyMap.of(ReactTextShadowNode.PROP_TEXT, text, "collapsable", false)); uiManager.manageChildren( textTag, null, null, JavaOnlyArray.of(rawTextTag), JavaOnlyArray.of(0), null); uiManager.manageChildren( rootTag, null, null, JavaOnlyArray.of(textTag), JavaOnlyArray.of(0), null); uiManager.onBatchComplete(); executePendingFrameCallbacks(); return rootView; }
@Before public void setUp() throws Exception { WXSDKEngine.initialize(RuntimeEnvironment.application,new InitConfig.Builder().build()); instance = WXSDKInstanceTest.createInstance(); WXRenderManager rednerManager = new WXRenderManager(); rednerManager.registerInstance(instance);// WXSDKManagerTest.setRenderManager(rednerManager); }
@Test public void create_with_custom_attachers() { final PhialBuilder builder = new PhialBuilder(RuntimeEnvironment.application); builder.attachKeyValues(false).attachScreenshot(false); final List<ListAttacher> attachers = Stream.generate(() -> mock(ListAttacher.class)).limit(2) .collect(Collectors.toList()); attachers.forEach(builder::addAttachmentProvider); final PhialCore phialCore = PhialCore.create(builder); assertEquals(attachers, phialCore.getAttachmentManager().getProviders()); }
@Before public void setup() { mContext = new ReactApplicationContext(RuntimeEnvironment.application); mCatalystInstanceMock = ReactTestHelper.createMockCatalystInstance(); mContext.initializeWithInstance(mCatalystInstanceMock); mThemedContext = new ThemedReactContext(mContext, mContext); mManager = new ConcreteViewManager(); }
@Test(expected = SettingsImportExportException.class) public void importSettings_throwsExceptionOnBlankFile() throws SettingsImportExportException { InputStream inputStream = new StringInputStream(""); List<String> accountUuids = new ArrayList<>(); SettingsImporter.importSettings(RuntimeEnvironment.application, inputStream, true, accountUuids, true); }
@Test public void intoImageViewSetsPlaceholderDrawable() { Picasso picasso = spy(new Picasso(RuntimeEnvironment.application, mock(Dispatcher.class), Cache.NONE, null, IDENTITY, null, mock(Stats.class), ARGB_8888, false, false)); ImageView target = mockImageViewTarget(); Drawable placeHolderDrawable = mock(Drawable.class); new RequestCreator(picasso, URI_1, 0).placeholder(placeHolderDrawable).into(target); verify(target).setImageDrawable(placeHolderDrawable); verify(picasso).enqueueAndSubmit(actionCaptor.capture()); assertThat(actionCaptor.getValue()).isInstanceOf(ImageViewAction.class); }
@Test(expected = SettingsImportExportException.class) public void importSettings_throwsExceptionOnInvalidVersion() throws SettingsImportExportException { InputStream inputStream = new StringInputStream("<k9settings format=\"1\" version=\"A\"></k9settings>"); List<String> accountUuids = new ArrayList<>(); SettingsImporter.importSettings(RuntimeEnvironment.application, inputStream, true, accountUuids, true); }
@Before public void setup() throws Exception{ supplier = Mockito.mock(WXSQLiteOpenHelper.class); listener = Mockito.mock(IWXStorageAdapter.OnResultReceivedListener.class); storage = new DefaultWXStorage(RuntimeEnvironment.application); mockStatic(WXSQLiteOpenHelper.class); PowerMockito.whenNew(WXSQLiteOpenHelper.class) .withArguments(RuntimeEnvironment.application) .thenReturn(supplier); }
@Test public void testPropsApplied() { UIManagerModule uiManager = getUIManagerModule(); ReactRootView rootView = new ReactRootView(RuntimeEnvironment.application); rootView.setLayoutParams(new ReactRootView.LayoutParams(100, 100)); int rootTag = uiManager.addMeasuredRootView(rootView); int textInputTag = rootTag + 1; final String hintStr = "placeholder text"; uiManager.createView( textInputTag, ReactTextInputManager.REACT_CLASS, rootTag, JavaOnlyMap.of( ViewProps.FONT_SIZE, 13.37, ViewProps.HEIGHT, 20.0, "placeholder", hintStr)); uiManager.manageChildren( rootTag, null, null, JavaOnlyArray.of(textInputTag), JavaOnlyArray.of(0), null); uiManager.onBatchComplete(); executePendingChoreographerCallbacks(); EditText editText = (EditText) rootView.getChildAt(0); assertThat(editText.getHint()).isEqualTo(hintStr); assertThat(editText.getTextSize()).isEqualTo((float) Math.ceil(13.37)); assertThat(editText.getHeight()).isEqualTo(20); }
@Test public void getConstraintLayoutParent_returnsNull_ifParent_isNotConstraintLayout() { //given StaggeredAnimationGroup spiedGroup = prepareSpiedGroup(); ViewParent parent = new FrameLayout(RuntimeEnvironment.application); when(spiedGroup.getParent()).thenReturn(parent); //when ConstraintLayout result = Utils.getConstraintLayoutParent(spiedGroup); //then assertThat(result).isNull(); }
@Before public void setUp() throws IOException { MockitoAnnotations.initMocks(this); waitForResponseLatch = new CountDownLatch(1); doAnswer(new CountDown()).when(callback).onDataReady(any(InputStream.class)); doAnswer(new CountDown()).when(callback).onLoadFailed(any(Exception.class)); requestQueue = Volley.newRequestQueue(RuntimeEnvironment.application); mockWebServer = new MockWebServer(); mockWebServer.start(); streamCaptor = ArgumentCaptor.forClass(InputStream.class); }
@Test(expected = RuntimeException.class) public void testThrowsIfIntoViewCalledOnBackgroundThread() throws InterruptedException { final ImageView imageView = new ImageView(RuntimeEnvironment.application); testInBackground(new BackgroundUtil.BackgroundTester() { @Override public void runTest() throws Exception { getNullModelRequest().into(imageView); } }); }
@Before public void setUp() throws Exception { WXSDKInstance instance = Mockito.mock(WXSDKInstance.class); Mockito.when(instance.getContext()).thenReturn(RuntimeEnvironment.application); WXDomObject divDom = new WXDomObject(); WXDomObject spy = Mockito.spy(divDom); Mockito.when(spy.getPadding()).thenReturn(new Spacing()); Mockito.when(spy.getEvents()).thenReturn(new WXEvent()); Mockito.when(spy.clone()).thenReturn(divDom); TestDomObject.setRef(divDom,"1"); mWXDiv = new WXDiv(instance, divDom, null); mWXDiv.initView(); }
@Test public void testNoSessionIsCreatedIfWeAreRestoring() { final SessionManager sessionManager = SessionManager.getInstance(); final Bundle instanceState = new Bundle(); final SafeIntent intent = new SafeIntent(new Intent(Intent.ACTION_VIEW, Uri.parse(TEST_URL))); sessionManager.handleIntent(RuntimeEnvironment.application, intent, instanceState); final List<Session> sessions = sessionManager.getSessions().getValue(); assertNotNull(sessions); assertEquals(0, sessions.size()); assertFalse(sessionManager.hasSession()); }
@Before public void setUp() { mContext = RuntimeEnvironment.application.getApplicationContext(); mEmailEditText = new EditText(mContext); mEmailEditText.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS); mPasswordEditText = new EditText(mContext); }
private NotificationController createFakeNotificationController(NotificationManagerCompat notificationManager, NotificationCompat.Builder builder) { NotificationController controller = mock(NotificationController.class); when(controller.getContext()).thenReturn(RuntimeEnvironment.application); when(controller.getNotificationManager()).thenReturn(notificationManager); when(controller.createNotificationBuilder()).thenReturn(builder); return controller; }
@Before public void setUp() throws Exception { Context context = RuntimeEnvironment.application; builder = createFakeNotificationBuilder(); publicBuilder = createFakeNotificationBuilder(); NotificationController controller = createFakeController(context, publicBuilder); Account account = createFakeAccount(); notificationData = createFakeNotificationData(account); lockScreenNotification = new LockScreenNotification(controller); }
private NotificationController createFakeNotificationController(NotificationManagerCompat notificationManager, Builder builder) { NotificationController controller = mock(NotificationController.class); when(controller.getContext()).thenReturn(RuntimeEnvironment.application); when(controller.getNotificationManager()).thenReturn(notificationManager); when(controller.createNotificationBuilder()).thenReturn(builder); return controller; }
@Before public void setUp() { rxCursorLoader = new RxCursorLoader<Cursor>(RuntimeEnvironment.systemContext) { @Override protected Observable<Cursor> create(final String query) { return null; } }; cursor = mock(Cursor.class); }
@Before public void init() throws Exception { assertTrue(BuildConfig.DEBUG); // unit test should only be run on debug at this time FlowManager.init(new FlowConfig.Builder(RuntimeEnvironment.application).build()); VolleyRequestQueue.getInstance().initialize(RuntimeEnvironment.application); setInternalState(VolleyRequestQueue.getInstance(), "mRequestQueue", newVolleyRequestQueueForTest(RuntimeEnvironment.application)); ImageHelper.getInstance().initialize(RuntimeEnvironment.application); UserHelper.getInstance().initialize(); GoalHelper.getInstance().initialize(); PreferenceHelper.getInstance().initialize(RuntimeEnvironment.application); UserHelper.getInstance().LoadContacts(); }
@Test public void testSetsBitmapOnRemoteViewsWithViewIdWhenCreatedWithWidgetIds() { int[] widgetIds = new int[] { 1 }; AppWidgetTarget target = new AppWidgetTarget(RuntimeEnvironment.application, viewId, views, widgetIds); Bitmap bitmap = Bitmap.createBitmap(100, 200, Bitmap.Config.RGB_565); target.onResourceReady(bitmap, null /*glideAnimation*/); verify(views).setImageViewBitmap(eq(viewId), eq(bitmap)); }