@Test public void testSetsBitmapOnRemoteViewsWithViewIdWhenCreatedWithWidgetIds() { int[] widgetIds = new int[] {1}; AppWidgetTarget target = new AppWidgetTarget(Robolectric.application, views, viewId, widgetIds); Bitmap bitmap = Bitmap.createBitmap(100, 200, Bitmap.Config.RGB_565); target.onResourceReady(bitmap, null /*glideAnimation*/); verify(views).setImageViewBitmap(eq(viewId), eq(bitmap)); }
@Test public void testUpdatesAppWidgetWhenCreatedWithWidgetIds() { int[] widgetIds = new int[] {1}; AppWidgetTarget target = new AppWidgetTarget(Robolectric.application, views, viewId, widgetIds); target.onResourceReady( Bitmap.createBitmap(200, 100, Bitmap.Config.ARGB_8888), null /*glideAnimation*/); assertThat(widgetIds).isEqualTo(shadowManager.updatedWidgetIds); assertEquals(views, shadowManager.updatedRemoteViews); }
@Test public void testSetsBitmapOnRemoteViewsWithViewIdWhenCreatedWithComponentName() { ComponentName componentName = mock(ComponentName.class); AppWidgetTarget target = new AppWidgetTarget(Robolectric.application, views, viewId, componentName); Bitmap bitmap = Bitmap.createBitmap(100, 100, Bitmap.Config.ARGB_8888); target.onResourceReady(bitmap, null /*glideAnimation*/); verify(views).setImageViewBitmap(eq(viewId), eq(bitmap)); }
@Test public void testUpdatesAppWidgetWhenCreatedWithComponentName() { ComponentName componentName = mock(ComponentName.class); AppWidgetTarget target = new AppWidgetTarget(Robolectric.application, views, viewId, componentName); target.onResourceReady( Bitmap.createBitmap(100, 100, Bitmap.Config.ARGB_8888), null /*glideAnimation*/); assertEquals(componentName, shadowManager.updatedComponentName); assertEquals(views, shadowManager.updatedRemoteViews); }