Codota Logo
TextViewAssert
Code IndexAdd Codota to your IDE (free)

How to use
TextViewAssert
in
org.assertj.android.api.widget

Best Java code snippets using org.assertj.android.api.widget.TextViewAssert (Showing top 20 results out of 315)

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
StringBuilder s =
  • Codota Iconnew StringBuilder()
  • Codota Iconnew StringBuilder(32)
  • Codota IconString str;new StringBuilder(str)
  • Smart code suggestions by Codota
}
origin: square/assertj-android

public static org.assertj.android.api.widget.TextViewAssert assertThat(
  android.widget.TextView actual) {
 return new org.assertj.android.api.widget.TextViewAssert(actual);
}
origin: hidroh/materialistic

@Test
public void testNullResponse() {
  verify(itemManager).getItem(any(), eq(ItemManager.MODE_DEFAULT), listener.capture());
  listener.getValue().onResponse(null);
  assertThat((TextView) holder.itemView.findViewById(R.id.title))
      .hasText(R.string.loading_text);
}
origin: hidroh/materialistic

@Test
public void testStory() {
  item.setIsViewed(true);
  verify(itemManager).getItem(any(), eq(ItemManager.MODE_DEFAULT), itemListener.capture());
  itemListener.getValue().onResponse(item);
  RecyclerView.ViewHolder holder = adapter.getViewHolder(0);
  assertThat((View) holder.itemView.findViewById(R.id.bookmarked)).isNotVisible();
  assertThat((TextView) holder.itemView.findViewById(R.id.rank)).hasTextString("46");
  assertThat((TextView) holder.itemView.findViewById(R.id.title)).hasTextString("title");
  assertThat((TextView) holder.itemView.findViewById(R.id.comment))
      .isVisible()
      .isEmpty();
  assertViewed();
}
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

@Config(shadows = {ShadowRecyclerView.class, ShadowItemTouchHelper.class})
@Test
public void testSwipeToDelete() {
  RecyclerView.ViewHolder holder = shadowAdapter.getViewHolder(0);
  customShadowOf(recyclerView).getItemTouchHelperCallback()
      .onSwiped(holder, ItemTouchHelper.LEFT);
  verify(favoriteManager).remove(any(Context.class), anyCollection());
  when(favoriteManager.getSize()).thenReturn(1);
  observerCaptor.getValue().onChanged();
  assertEquals(1, adapter.getItemCount());
  assertThat((TextView) activity.findViewById(R.id.snackbar_text))
      .isNotNull()
      .containsText(R.string.toast_removed);
  activity.findViewById(R.id.snackbar_action).performClick();
  verify(favoriteManager).add(any(Context.class), any(WebItem.class));
  when(favoriteManager.getSize()).thenReturn(2);
  observerCaptor.getValue().onChanged();
  assertEquals(2, adapter.getItemCount());
}
origin: hidroh/materialistic

RecyclerView.ViewHolder viewHolder = customShadowOf(recyclerView.getAdapter()).getViewHolder(1);
assertThat((TextView) viewHolder.itemView.findViewById(R.id.posted))
    .containsText(activity.getResources().getQuantityString(R.plurals.score, 46, 46));
assertThat((TextView) viewHolder.itemView.findViewById(R.id.title))
    .isVisible()
    .hasTextString("title");
assertThat((TextView) viewHolder.itemView.findViewById(R.id.text))
    .isVisible()
    .hasTextString("content");
viewHolder.itemView.findViewById(R.id.comment).performClick();
assertThat(shadowOf(activity).getNextStartedActivity())
origin: passy/Android-DirectoryChooser

@Test
public void testCreateDirectoryDialogAllowFolderNameModification() {
  final String directoryName = "mydir";
  final DirectoryChooserFragment fragment = DirectoryChooserFragment.newInstance(
      DirectoryChooserConfig.builder()
          .newDirectoryName(directoryName)
          .initialDirectory("")
          .allowReadOnlyDirectory(false)
          .allowNewDirectoryNameModification(true)
          .build());
  startFragment(fragment, DirectoryChooserActivityMock.class);
  fragment.onOptionsItemSelected(new TestMenuItem() {
    @Override
    public int getItemId() {
      return R.id.new_folder_item;
    }
  });
  final AlertDialog dialog = (AlertDialog) ShadowDialog.getLatestDialog();
  final ShadowAlertDialog shadowAlertDialog = Shadows.shadowOf(dialog);
  assertThat(shadowAlertDialog.getTitle()).isEqualTo("Create folder");
  assertThat(ShadowDialog.getShownDialogs()).contains(dialog);
  final TextView msgView = (TextView) dialog.findViewById(R.id.msgText);
  assertThat(msgView).hasText("Create new folder with name \"mydir\"?");
  final EditText editText = (EditText) dialog.findViewById(R.id.editText);
  assertThat(editText).isVisible();
  assertThat(editText).hasTextString(directoryName);
}
origin: hidroh/materialistic

@Test
public void testCommentBinding() {
  verify(userManager).getUser(eq("username"), userCaptor.capture());
  userCaptor.getValue().onResponse(user);
  RecyclerView recyclerView = (RecyclerView) activity.findViewById(R.id.recycler_view);
  verify(itemManager).getItem(eq("1"),
      eq(ItemManager.MODE_DEFAULT),
      itemCaptor.capture());
  itemCaptor.getValue().onResponse(new TestHnItem(1L) {
    @Override
    public String getText() {
      return "content";
    }
    @Override
    public String getParent() {
      return "2";
    }
  });
  RecyclerView.ViewHolder viewHolder = customShadowOf(recyclerView.getAdapter()).getViewHolder(0);
  assertThat((View) viewHolder.itemView.findViewById(R.id.title)).isNotVisible();
  assertThat((TextView) viewHolder.itemView.findViewById(R.id.text))
      .isVisible()
      .hasTextString("content");
  viewHolder.itemView.findViewById(R.id.comment).performClick();
  assertThat(shadowOf(activity).getNextStartedActivity())
      .hasComponent(activity, ThreadPreviewActivity.class)
      .hasExtra(ThreadPreviewActivity.EXTRA_ITEM);
}
origin: hidroh/materialistic

@Test
public void testTrimHtmlWhitespaces() {
  TextView textView = new TextView(context);
  textView.setText(AppUtils.fromHtml("<p>paragraph</p><p><br/><br/><br/></p>"));
  assertThat(textView).hasTextString("paragraph");
  textView.setText(AppUtils.fromHtml(""));
  assertThat(textView).hasTextString("");
  textView.setText(AppUtils.fromHtml("paragraph"));
  assertThat(textView).hasTextString("paragraph");
}
origin: hidroh/materialistic

@Test
public void testDeriveEmptyTitle() {
  controller.pause().stop().destroy();
  controller = Robolectric.buildActivity(SubmitActivity.class,
      new Intent().putExtra(Intent.EXTRA_TEXT, " : http://example.com"));
  activity = controller
      .create().start().resume().visible().get();
  assertThat((EditText) activity.findViewById(R.id.edittext_title)).isEmpty();
  assertThat((EditText) activity.findViewById(R.id.edittext_content)).hasTextString("http://example.com");
}
origin: passy/Android-DirectoryChooser

@Test
public void testCreateDirectoryDialogDisallowFolderNameModification() {
  final String directoryName = "mydir";
  final DirectoryChooserFragment fragment = DirectoryChooserFragment.newInstance(
      DirectoryChooserConfig.builder()
          .newDirectoryName(directoryName)
          .initialDirectory("")
          .allowReadOnlyDirectory(false)
          .allowNewDirectoryNameModification(false)
          .build());
  startFragment(fragment, DirectoryChooserActivityMock.class);
  fragment.onOptionsItemSelected(new TestMenuItem() {
    @Override
    public int getItemId() {
      return R.id.new_folder_item;
    }
  });
  final AlertDialog dialog = (AlertDialog) ShadowDialog.getLatestDialog();
  final ShadowAlertDialog shadowAlertDialog = Shadows.shadowOf(dialog);
  assertThat(shadowAlertDialog.getTitle()).isEqualTo("Create folder");
  assertThat(ShadowDialog.getShownDialogs()).contains(dialog);
  final TextView msgView = (TextView) dialog.findViewById(R.id.msgText);
  assertThat(msgView).hasText("Create new folder with name \"mydir\"?");
  final EditText editText = (EditText) dialog.findViewById(R.id.editText);
  assertThat(editText).isGone();
}
origin: hidroh/materialistic

private void assertNotViewed() {
  RecyclerView.ViewHolder holder = adapter.getViewHolder(0);
  assertThat((TextView) holder.itemView.findViewById(R.id.title))
      .hasCurrentTextColor(ContextCompat.getColor(activity, R.color.blackT87));
}
origin: hidroh/materialistic

@Test
public void testPoll() {
  item.populate(new PopulatedStory(1) {
    @Override
    public String getRawType() {
      return POLL_TYPE;
    }
  });
  verify(itemManager).getItem(any(), eq(ItemManager.MODE_DEFAULT), itemListener.capture());
  itemListener.getValue().onResponse(item);
  RecyclerView.ViewHolder holder = adapter.getViewHolder(0);
  assertThat((TextView) holder.itemView.findViewById(R.id.source)).isEmpty();
}
origin: hidroh/materialistic

@Test
public void testBinding() {
  verify(userManager).getUser(eq("username"), userCaptor.capture());
  userCaptor.getValue().onResponse(user);
  assertThat((TextView) activity.findViewById(R.id.title)).hasTextString("username (2,016)");
  assertThat((TextView) activity.findViewById(R.id.about)).hasTextString("about");
  assertEquals(activity.getResources().getQuantityString(R.plurals.submissions_count, 2, 2),
      ((TabLayout) activity.findViewById(R.id.tab_layout)).getTabAt(0).getText());
  assertEquals(2, (((RecyclerView) activity.findViewById(R.id.recycler_view)).getAdapter())
      .getItemCount());
  shadowOf(activity).recreate();
  assertThat((TextView) activity.findViewById(R.id.title)).hasTextString("username (2,016)");
}
origin: hidroh/materialistic

@Test
public void testDeriveNoMatches() {
  controller.pause().stop().destroy();
  controller = Robolectric.buildActivity(SubmitActivity.class,
      new Intent().putExtra(Intent.EXTRA_TEXT, "title - http://example.com blah blah"));
  activity = controller
      .create().start().resume().visible().get();
  assertThat((EditText) activity.findViewById(R.id.edittext_title)).isEmpty();
  assertThat((EditText) activity.findViewById(R.id.edittext_content))
      .hasTextString("title - http://example.com blah blah");
}
origin: hidroh/materialistic

View snackbarView = ShadowSnackbar.getLatestView();
Assertions.assertThat((TextView) snackbarView.findViewById(R.id.snackbar_text))
    .isNotNull()
    .containsText(activity.getResources().getQuantityString(R.plurals.new_stories_count, 1, 1));
snackbarView.findViewById(R.id.snackbar_action).performClick();
assertEquals(1, ((RecyclerView) activity.findViewById(R.id.recycler_view)).getAdapter().getItemCount());
snackbarView = ShadowSnackbar.getLatestView();
Assertions.assertThat((TextView) snackbarView.findViewById(R.id.snackbar_text))
    .isNotNull()
    .containsText(activity.getResources().getQuantityString(R.plurals.showing_new_stories, 1, 1));
snackbarView.findViewById(R.id.snackbar_action).performClick();
assertEquals(2, ((RecyclerView) activity.findViewById(R.id.recycler_view)).getAdapter().getItemCount());
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);
}
origin: hidroh/materialistic

@Test
public void testDead() {
  assertThat(((TextView) viewHolder.itemView.findViewById(R.id.text)))
      .hasCurrentTextColor(ContextCompat.getColor(activity, R.color.blackT87));
  assertThat(((TextView) viewHolder2.itemView.findViewById(R.id.text)))
      .hasCurrentTextColor(ContextCompat.getColor(activity,
          AppUtils.getThemedResId(activity, android.R.attr.textColorSecondary)));
}
origin: hidroh/materialistic

@Test
public void testJob() {
  item.populate(new PopulatedStory(1) {
    @Override
    public String getRawType() {
      return JOB_TYPE;
    }
  });
  verify(itemManager).getItem(any(), eq(ItemManager.MODE_DEFAULT), itemListener.capture());
  itemListener.getValue().onResponse(item);
  RecyclerView.ViewHolder holder = adapter.getViewHolder(0);
  assertThat((TextView) holder.itemView.findViewById(R.id.source)).isEmpty();
}
origin: hidroh/materialistic

@Test
public void testErrorResponse() {
  verify(itemManager).getItem(any(), eq(ItemManager.MODE_DEFAULT), listener.capture());
  listener.getValue().onError(null);
  assertThat((TextView) holder.itemView.findViewById(R.id.title))
      .hasText(R.string.loading_text);
}
org.assertj.android.api.widgetTextViewAssert

Javadoc

Assertions for TextView instances.

This class is final. To extend use AbstractTextViewAssert.

Most used methods

  • <init>
  • hasText
  • hasTextString
  • isVisible
  • containsText
  • doesNotContainText
  • hasCurrentTextColor
  • isEmpty
  • isGone
  • isNotNull
  • isNotVisible
  • isNotVisible

Popular in Java

  • Reactive rest calls using spring rest template
  • getOriginalFilename (MultipartFile)
    Return the original filename in the client's filesystem.This may contain path information depending
  • onRequestPermissionsResult (Fragment)
  • scheduleAtFixedRate (ScheduledExecutorService)
    Creates and executes a periodic action that becomes enabled first after the given initial delay, and
  • Table (com.google.common.collect)
    A collection that associates an ordered pair of keys, called a row key and a column key, with a sing
  • HttpServer (com.sun.net.httpserver)
    This class implements a simple HTTP server. A HttpServer is bound to an IP address and port number a
  • BigInteger (java.math)
    Immutable arbitrary-precision integers. All operations behave as if BigIntegers were represented in
  • Executor (java.util.concurrent)
    An object that executes submitted Runnable tasks. This interface provides a way of decoupling task s
  • JCheckBox (javax.swing)
  • Join (org.hibernate.mapping)
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