Code example for ComponentName

0
    assertArrayEquals(new int[]{789}, appWidgetManager.getAppWidgetIds(provider));
  } 
 
  @Test 
  public void bindAppWidgetId_shouldRecordAppWidgetInfo() throws Exception { 
    ComponentName provider = new ComponentName("abc", "123");
    AppWidgetProviderInfo providerInfo = new AppWidgetProviderInfo();
    providerInfo.provider = provider;
    shadowAppWidgetManager.addInstalledProvider(providerInfo);
 
    appWidgetManager.bindAppWidgetIdIfAllowed(90210, provider);
 
    assertSame(providerInfo, appWidgetManager.getAppWidgetInfo(90210));
  } 
 
  @Test(expected = IllegalArgumentException.class) 
  public void bindAppWidgetIdIfAllowed_shouldThrowIllegalArgumentExceptionWhenPrompted() throws Exception { 
    shadowAppWidgetManager.setValidWidgetProviderComponentName(false);
    shadowAppWidgetManager.bindAppWidgetIdIfAllowed(12345, new ComponentName("", ""));
  }