Codota Logo
ShadowAppWidgetManager.getViewFor
Code IndexAdd Codota to your IDE (free)

How to use
getViewFor
method
in
org.robolectric.shadows.ShadowAppWidgetManager

Best Java code snippets using org.robolectric.shadows.ShadowAppWidgetManager.getViewFor (Showing top 6 results out of 315)

  • Common ways to obtain ShadowAppWidgetManager
private void myMethod () {
ShadowAppWidgetManager s =
  • Codota IconObject instance;(ShadowAppWidgetManager) Shadow.extract(instance)
  • Smart code suggestions by Codota
}
origin: robolectric/robolectric

@Test
public void createWidget_shouldInflateViewAndAssignId() throws Exception {
 int widgetId = shadowAppWidgetManager.createWidget(SpanishTestAppWidgetProvider.class, R.layout.main);
 View widgetView = shadowAppWidgetManager.getViewFor(widgetId);
 assertEquals("Hola", ((TextView) widgetView.findViewById(R.id.subtitle)).getText());
}
origin: robolectric/robolectric

@Test
public void getViewFor_shouldReturnSameViewEveryTimeForGivenWidgetId() throws Exception {
 int widgetId = shadowAppWidgetManager.createWidget(SpanishTestAppWidgetProvider.class, R.layout.main);
 View widgetView = shadowAppWidgetManager.getViewFor(widgetId);
 assertNotNull(widgetView);
 assertSame(widgetView, shadowAppWidgetManager.getViewFor(widgetId));
}
origin: robolectric/robolectric

@Test
public void createWidget_shouldAllowForMultipleInstancesOfWidgets() throws Exception {
 int widgetId = shadowAppWidgetManager.createWidget(SpanishTestAppWidgetProvider.class, R.layout.main);
 View widgetView = shadowAppWidgetManager.getViewFor(widgetId);
 assertNotSame(widgetId,
   shadowAppWidgetManager.createWidget(SpanishTestAppWidgetProvider.class, R.layout.main));
 assertNotSame(widgetView,
   shadowAppWidgetManager.getViewFor(shadowAppWidgetManager.createWidget(SpanishTestAppWidgetProvider.class, R.layout.main)));
}
origin: robolectric/robolectric

@Test
public void shouldReplaceLayoutIfAndOnlyIfLayoutIdIsDifferent() throws Exception {
 int widgetId = shadowAppWidgetManager.createWidget(SpanishTestAppWidgetProvider.class, R.layout.main);
 View originalWidgetView = shadowAppWidgetManager.getViewFor(widgetId);
 assertContains("Main Layout", originalWidgetView);
 appWidgetManager.updateAppWidget(
   widgetId,
   new RemoteViews(
     ApplicationProvider.getApplicationContext().getPackageName(), R.layout.main));
 assertSame(originalWidgetView, shadowAppWidgetManager.getViewFor(widgetId));
 appWidgetManager.updateAppWidget(
   widgetId,
   new RemoteViews(
     ApplicationProvider.getApplicationContext().getPackageName(), R.layout.media));
 assertNotSame(originalWidgetView, shadowAppWidgetManager.getViewFor(widgetId));
 View mediaWidgetView = shadowAppWidgetManager.getViewFor(widgetId);
 assertContains("Media Layout", mediaWidgetView);
}
origin: hidroh/materialistic

  @Test
  public void testRefreshQuery() {
    RuntimeEnvironment.application.getSharedPreferences("WidgetConfiguration_" + appWidgetId, MODE_PRIVATE)
        .edit()
        .putString(RuntimeEnvironment.application.getString(R.string.pref_widget_theme),
            RuntimeEnvironment.application.getString(R.string.pref_widget_theme_value_light))
        .putString(RuntimeEnvironment.application.getString(R.string.pref_widget_query), "Google")
        .apply();
    widgetProvider.onReceive(RuntimeEnvironment.application,
        new Intent(BuildConfig.APPLICATION_ID + ".ACTION_REFRESH_WIDGET")
            .putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId));
    View view = shadowOf(widgetManager).getViewFor(appWidgetId);
    assertThat((TextView) view.findViewById(R.id.title))
        .containsText("Google");
    assertThat((TextView) view.findViewById(R.id.subtitle))
        .doesNotContainText(R.string.loading_text);
  }
}
origin: hidroh/materialistic

@Test
public void testUpdateBest() {
  RuntimeEnvironment.application.getSharedPreferences("WidgetConfiguration_" + appWidgetId, MODE_PRIVATE)
      .edit()
      .putString(RuntimeEnvironment.application.getString(R.string.pref_widget_theme),
          RuntimeEnvironment.application.getString(R.string.pref_widget_theme_value_dark))
      .putString(RuntimeEnvironment.application.getString(R.string.pref_widget_section),
          RuntimeEnvironment.application.getString(R.string.pref_widget_section_value_best))
      .apply();
  widgetProvider.onReceive(RuntimeEnvironment.application,
      new Intent(AppWidgetManager.ACTION_APPWIDGET_UPDATE)
          .putExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS, new int[]{appWidgetId}));
  View view = shadowOf(widgetManager).getViewFor(appWidgetId);
  assertThat((TextView) view.findViewById(R.id.title))
      .containsText(R.string.title_activity_best);
  assertThat((TextView) view.findViewById(R.id.subtitle))
      .doesNotContainText(R.string.loading_text);
}
org.robolectric.shadowsShadowAppWidgetManagergetViewFor

Popular methods of ShadowAppWidgetManager

  • addBoundWidget
  • addInstalledProvider
  • createWidgets
    Creates a bunch of widgets by inflating the same layout multiple times.
  • bindAppWidgetId
  • createWidgetView
  • updateAppWidget
  • createWidget
    Creates a widget by inflating its layout.
  • bindAppWidgetIdIfAllowed
  • setAllowedToBindAppWidgets
  • setValidWidgetProviderComponentName

Popular in Java

  • Finding current android device location
  • setContentView (Activity)
  • notifyDataSetChanged (ArrayAdapter)
  • requestLocationUpdates (LocationManager)
  • Kernel (java.awt.image)
  • InputStream (java.io)
    A readable source of bytes.Most clients will use input streams that read data from the file system (
  • HttpURLConnection (java.net)
    An URLConnection for HTTP (RFC 2616 [http://tools.ietf.org/html/rfc2616]) used to send and receive d
  • Random (java.util)
    This class provides methods that return pseudo-random values.It is dangerous to seed Random with the
  • Callable (java.util.concurrent)
    A task that returns a result and may throw an exception. Implementors define a single method with no
  • Scheduler (org.quartz)
    This is the main interface of a Quartz Scheduler. A Scheduler maintains a registery of org.quartz
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now