Code example for AppWidgetManager

Methods: getAppWidgetInfo

0
  @Test 
  public void getAppWidgetInfo_shouldReturnSpecifiedAppWidgetInfo() throws Exception { 
    AppWidgetProviderInfo expectedWidgetInfo = new AppWidgetProviderInfo(Parcel.obtain());
    shadowAppWidgetManager.addBoundWidget(26, expectedWidgetInfo);
 
    assertEquals(expectedWidgetInfo, appWidgetManager.getAppWidgetInfo(26));
    assertEquals(null, appWidgetManager.getAppWidgetInfo(27));
  } 
 
  @Test 
  public void bindAppWidgetIdIfAllowed_shouldReturnThePresetBoolean() throws Exception { 
    shadowAppWidgetManager.setAllowedToBindAppWidgets(false);
    assertEquals(shadowAppWidgetManager.bindAppWidgetIdIfAllowed(12345, new ComponentName("", "")), false);
    shadowAppWidgetManager.setAllowedToBindAppWidgets(true);
    assertEquals(shadowAppWidgetManager.bindAppWidgetIdIfAllowed(12345, new ComponentName("", "")), true);
  } 
 
  @Test 
  public void bindAppWidgetIdIfAllowed_shouldRecordTheBinding() throws Exception { 
    ComponentName provider = new ComponentName("A", "B");
    appWidgetManager.bindAppWidgetIdIfAllowed(789, provider);