Skip to content

Commit

Permalink
test: tag sorting
Browse files Browse the repository at this point in the history
  • Loading branch information
TarekkMA committed May 3, 2021
1 parent 5d8fe7a commit d3bb04c
Showing 1 changed file with 12 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.core.IsNull.notNullValue;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;
Expand Down Expand Up @@ -157,8 +159,9 @@ public void testTagsDialogCustomStudyOptionFragmentAPI() {


// regression test #8762
// test for #8763
@Test
public void test_AddNewTag_shouldBeVisibleInRecyclerView() {
public void test_AddNewTag_shouldBeVisibleInRecyclerView_andSortedCorrectly() {
final DialogType type = DialogType.ADD_TAG;
final List<String> allTags = Arrays.asList("a", "b", "d", "e");
final List<String> checkedTags = Arrays.asList("a", "b");
Expand All @@ -181,7 +184,7 @@ public void test_AddNewTag_shouldBeVisibleInRecyclerView() {
final View body = dialog.getCustomView();
RecyclerView recycler = body.findViewById(R.id.tags_dialog_tags_list);

final String NEW_TAG = "c";
final String NEW_TAG = "zzzz";

f.addTag(NEW_TAG);

Expand All @@ -190,11 +193,14 @@ public void test_AddNewTag_shouldBeVisibleInRecyclerView() {
recycler.measure(0, 0);
recycler.layout(0, 0, 100, 1000);

TagsArrayAdapter.ViewHolder vh = (TagsArrayAdapter.ViewHolder) recycler.findViewHolderForAdapterPosition(2);
CheckedTextView itemView = (CheckedTextView) vh.itemView;
CheckedTextView lastItem = (CheckedTextView) ((TagsArrayAdapter.ViewHolder) recycler.findViewHolderForAdapterPosition(4)).itemView;
CheckedTextView newTagItemItem = (CheckedTextView) ((TagsArrayAdapter.ViewHolder) recycler.findViewHolderForAdapterPosition(2)).itemView;

assertEquals(NEW_TAG, itemView.getText());
assertTrue(itemView.isChecked());
assertEquals(NEW_TAG, newTagItemItem.getText());
assertTrue(newTagItemItem.isChecked());

assertNotEquals(NEW_TAG, lastItem.getText());
assertFalse(lastItem.isChecked());
});
}

Expand Down

0 comments on commit d3bb04c

Please sign in to comment.