Commit f89d98db authored by Jenna Himawan's avatar Jenna Himawan Committed by Commit Bot

Trying to fix bookmark tests

Bug: 990051
Change-Id: I3db913053bcd038514cde1cf26f6a72de4102a90
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1730775
Commit-Queue: Jenna Himawan <jhimawan@google.com>
Reviewed-by: default avatarTheresa  <twellington@chromium.org>
Reviewed-by: default avatarMatthew Jones <mdjones@chromium.org>
Cr-Commit-Position: refs/heads/master@{#683404}
parent 04aa9e52
...@@ -74,6 +74,7 @@ public class BookmarkReorderTest extends BookmarkTest { ...@@ -74,6 +74,7 @@ public class BookmarkReorderTest extends BookmarkTest {
BookmarkId testId = addFolder(TEST_FOLDER_TITLE); BookmarkId testId = addFolder(TEST_FOLDER_TITLE);
addBookmark(TEST_TITLE_A, TEST_URL_A); addBookmark(TEST_TITLE_A, TEST_URL_A);
BookmarkPromoHeader.forcePromoStateForTests(BookmarkPromoHeader.PromoState.PROMO_SYNC);
openBookmarkManager(); openBookmarkManager();
BookmarkRow test = BookmarkRow test =
...@@ -115,6 +116,7 @@ public class BookmarkReorderTest extends BookmarkTest { ...@@ -115,6 +116,7 @@ public class BookmarkReorderTest extends BookmarkTest {
BookmarkId testId = addFolder(TEST_FOLDER_TITLE); BookmarkId testId = addFolder(TEST_FOLDER_TITLE);
addFolder(TEST_TITLE_A); addFolder(TEST_TITLE_A);
BookmarkPromoHeader.forcePromoStateForTests(BookmarkPromoHeader.PromoState.PROMO_SYNC);
openBookmarkManager(); openBookmarkManager();
View searchButton = mManager.getToolbarForTests().findViewById(R.id.search_menu_id); View searchButton = mManager.getToolbarForTests().findViewById(R.id.search_menu_id);
...@@ -131,11 +133,8 @@ public class BookmarkReorderTest extends BookmarkTest { ...@@ -131,11 +133,8 @@ public class BookmarkReorderTest extends BookmarkTest {
TestThreadUtils.runOnUiThreadBlocking(searchButton::performClick); TestThreadUtils.runOnUiThreadBlocking(searchButton::performClick);
// Callback occurs when Item "test" is selected. // Callback occurs when Item "test" is selected.
CriteriaHelper.pollUiThread(() CriteriaHelper.pollUiThread(
-> mBookmarkActivity.getManagerForTesting() () -> mManager.getToolbarForTests().isSearching(), "Expected to enter search mode");
.getToolbarForTests()
.isSearching(),
"Expected to enter search mode");
toggleSelectionAndEndAnimation(testId, test); toggleSelectionAndEndAnimation(testId, test);
...@@ -188,6 +187,7 @@ public class BookmarkReorderTest extends BookmarkTest { ...@@ -188,6 +187,7 @@ public class BookmarkReorderTest extends BookmarkTest {
expected.add(aId); expected.add(aId);
expected.add(googleId); expected.add(googleId);
BookmarkPromoHeader.forcePromoStateForTests(BookmarkPromoHeader.PromoState.PROMO_SYNC);
openBookmarkManager(); openBookmarkManager();
// Callback occurs upon changes inside of the bookmark model. // Callback occurs upon changes inside of the bookmark model.
...@@ -252,6 +252,7 @@ public class BookmarkReorderTest extends BookmarkTest { ...@@ -252,6 +252,7 @@ public class BookmarkReorderTest extends BookmarkTest {
expected.add(aId); expected.add(aId);
expected.add(testId); expected.add(testId);
BookmarkPromoHeader.forcePromoStateForTests(BookmarkPromoHeader.PromoState.PROMO_SYNC);
openBookmarkManager(); openBookmarkManager();
// Callback occurs upon changes inside of the bookmark model. // Callback occurs upon changes inside of the bookmark model.
...@@ -314,6 +315,7 @@ public class BookmarkReorderTest extends BookmarkTest { ...@@ -314,6 +315,7 @@ public class BookmarkReorderTest extends BookmarkTest {
expected.add(testId); expected.add(testId);
expected.add(aId); expected.add(aId);
BookmarkPromoHeader.forcePromoStateForTests(BookmarkPromoHeader.PromoState.PROMO_SYNC);
openBookmarkManager(); openBookmarkManager();
// Callback occurs upon changes inside of the bookmark model. // Callback occurs upon changes inside of the bookmark model.
...@@ -357,6 +359,7 @@ public class BookmarkReorderTest extends BookmarkTest { ...@@ -357,6 +359,7 @@ public class BookmarkReorderTest extends BookmarkTest {
public void testPromoDraggability() throws Exception { public void testPromoDraggability() throws Exception {
BookmarkId testId = addFolder(TEST_FOLDER_TITLE); BookmarkId testId = addFolder(TEST_FOLDER_TITLE);
BookmarkPromoHeader.forcePromoStateForTests(BookmarkPromoHeader.PromoState.PROMO_SYNC);
openBookmarkManager(); openBookmarkManager();
ViewHolder promo = mItemsContainer.findViewHolderForAdapterPosition(0); ViewHolder promo = mItemsContainer.findViewHolderForAdapterPosition(0);
...@@ -376,6 +379,7 @@ public class BookmarkReorderTest extends BookmarkTest { ...@@ -376,6 +379,7 @@ public class BookmarkReorderTest extends BookmarkTest {
@MediumTest @MediumTest
public void testPartnerFolderDraggability() throws Exception { public void testPartnerFolderDraggability() throws Exception {
BookmarkId testId = addFolderWithPartner(TEST_FOLDER_TITLE); BookmarkId testId = addFolderWithPartner(TEST_FOLDER_TITLE);
BookmarkPromoHeader.forcePromoStateForTests(BookmarkPromoHeader.PromoState.PROMO_SYNC);
openBookmarkManager(); openBookmarkManager();
ViewHolder partner = mItemsContainer.findViewHolderForAdapterPosition(2); ViewHolder partner = mItemsContainer.findViewHolderForAdapterPosition(2);
...@@ -397,6 +401,7 @@ public class BookmarkReorderTest extends BookmarkTest { ...@@ -397,6 +401,7 @@ public class BookmarkReorderTest extends BookmarkTest {
BookmarkId aId = addBookmark("a", "http://a.com"); BookmarkId aId = addBookmark("a", "http://a.com");
addFolder(TEST_FOLDER_TITLE); addFolder(TEST_FOLDER_TITLE);
BookmarkPromoHeader.forcePromoStateForTests(BookmarkPromoHeader.PromoState.PROMO_SYNC);
openBookmarkManager(); openBookmarkManager();
ViewHolder test = mItemsContainer.findViewHolderForAdapterPosition(1); ViewHolder test = mItemsContainer.findViewHolderForAdapterPosition(1);
...@@ -419,6 +424,7 @@ public class BookmarkReorderTest extends BookmarkTest { ...@@ -419,6 +424,7 @@ public class BookmarkReorderTest extends BookmarkTest {
public void testCannotSelectPromo() throws Exception { public void testCannotSelectPromo() throws Exception {
addFolder(TEST_FOLDER_TITLE); addFolder(TEST_FOLDER_TITLE);
BookmarkPromoHeader.forcePromoStateForTests(BookmarkPromoHeader.PromoState.PROMO_SYNC);
openBookmarkManager(); openBookmarkManager();
View promo = mItemsContainer.findViewHolderForAdapterPosition(0).itemView; View promo = mItemsContainer.findViewHolderForAdapterPosition(0).itemView;
...@@ -433,6 +439,7 @@ public class BookmarkReorderTest extends BookmarkTest { ...@@ -433,6 +439,7 @@ public class BookmarkReorderTest extends BookmarkTest {
@MediumTest @MediumTest
public void testCannotSelectPartner() throws Exception { public void testCannotSelectPartner() throws Exception {
addFolderWithPartner(TEST_FOLDER_TITLE); addFolderWithPartner(TEST_FOLDER_TITLE);
BookmarkPromoHeader.forcePromoStateForTests(BookmarkPromoHeader.PromoState.PROMO_SYNC);
openBookmarkManager(); openBookmarkManager();
View partner = mItemsContainer.findViewHolderForAdapterPosition(2).itemView; View partner = mItemsContainer.findViewHolderForAdapterPosition(2).itemView;
...@@ -448,6 +455,7 @@ public class BookmarkReorderTest extends BookmarkTest { ...@@ -448,6 +455,7 @@ public class BookmarkReorderTest extends BookmarkTest {
public void testMoveUpMenuItem() throws Exception { public void testMoveUpMenuItem() throws Exception {
addBookmark(TEST_PAGE_TITLE_GOOGLE, TEST_URL_A); addBookmark(TEST_PAGE_TITLE_GOOGLE, TEST_URL_A);
addFolder(TEST_FOLDER_TITLE); addFolder(TEST_FOLDER_TITLE);
BookmarkPromoHeader.forcePromoStateForTests(BookmarkPromoHeader.PromoState.PROMO_SYNC);
openBookmarkManager(); openBookmarkManager();
View google = mItemsContainer.findViewHolderForAdapterPosition(2).itemView; View google = mItemsContainer.findViewHolderForAdapterPosition(2).itemView;
...@@ -473,6 +481,7 @@ public class BookmarkReorderTest extends BookmarkTest { ...@@ -473,6 +481,7 @@ public class BookmarkReorderTest extends BookmarkTest {
public void testMoveDownMenuItem() throws Exception { public void testMoveDownMenuItem() throws Exception {
addBookmark(TEST_PAGE_TITLE_GOOGLE, TEST_URL_A); addBookmark(TEST_PAGE_TITLE_GOOGLE, TEST_URL_A);
addFolder(TEST_FOLDER_TITLE); addFolder(TEST_FOLDER_TITLE);
BookmarkPromoHeader.forcePromoStateForTests(BookmarkPromoHeader.PromoState.PROMO_SYNC);
openBookmarkManager(); openBookmarkManager();
View testFolder = mItemsContainer.findViewHolderForAdapterPosition(1).itemView; View testFolder = mItemsContainer.findViewHolderForAdapterPosition(1).itemView;
...@@ -498,6 +507,7 @@ public class BookmarkReorderTest extends BookmarkTest { ...@@ -498,6 +507,7 @@ public class BookmarkReorderTest extends BookmarkTest {
public void testMoveDownGoneForBottomElement() throws Exception { public void testMoveDownGoneForBottomElement() throws Exception {
addBookmarkWithPartner(TEST_PAGE_TITLE_GOOGLE, TEST_URL_A); addBookmarkWithPartner(TEST_PAGE_TITLE_GOOGLE, TEST_URL_A);
addFolderWithPartner(TEST_FOLDER_TITLE); addFolderWithPartner(TEST_FOLDER_TITLE);
BookmarkPromoHeader.forcePromoStateForTests(BookmarkPromoHeader.PromoState.PROMO_SYNC);
openBookmarkManager(); openBookmarkManager();
View google = mItemsContainer.findViewHolderForAdapterPosition(2).itemView; View google = mItemsContainer.findViewHolderForAdapterPosition(2).itemView;
...@@ -513,6 +523,7 @@ public class BookmarkReorderTest extends BookmarkTest { ...@@ -513,6 +523,7 @@ public class BookmarkReorderTest extends BookmarkTest {
public void testMoveUpGoneForTopElement() throws Exception { public void testMoveUpGoneForTopElement() throws Exception {
addBookmark(TEST_PAGE_TITLE_GOOGLE, TEST_URL_A); addBookmark(TEST_PAGE_TITLE_GOOGLE, TEST_URL_A);
addFolder(TEST_FOLDER_TITLE); addFolder(TEST_FOLDER_TITLE);
BookmarkPromoHeader.forcePromoStateForTests(BookmarkPromoHeader.PromoState.PROMO_SYNC);
openBookmarkManager(); openBookmarkManager();
View testFolder = mItemsContainer.findViewHolderForAdapterPosition(1).itemView; View testFolder = mItemsContainer.findViewHolderForAdapterPosition(1).itemView;
...@@ -533,11 +544,8 @@ public class BookmarkReorderTest extends BookmarkTest { ...@@ -533,11 +544,8 @@ public class BookmarkReorderTest extends BookmarkTest {
TestThreadUtils.runOnUiThreadBlocking(searchButton::performClick); TestThreadUtils.runOnUiThreadBlocking(searchButton::performClick);
// Callback occurs when Item "test" is selected. // Callback occurs when Item "test" is selected.
CriteriaHelper.pollUiThread(() CriteriaHelper.pollUiThread(
-> mBookmarkActivity.getManagerForTesting() () -> mManager.getToolbarForTests().isSearching(), "Expected to enter search mode");
.getToolbarForTests()
.isSearching(),
"Expected to enter search mode");
View testFolder = mItemsContainer.findViewHolderForAdapterPosition(0).itemView; View testFolder = mItemsContainer.findViewHolderForAdapterPosition(0).itemView;
Assert.assertEquals("Wrong bookmark item selected.", TEST_FOLDER_TITLE, Assert.assertEquals("Wrong bookmark item selected.", TEST_FOLDER_TITLE,
...@@ -554,7 +562,6 @@ public class BookmarkReorderTest extends BookmarkTest { ...@@ -554,7 +562,6 @@ public class BookmarkReorderTest extends BookmarkTest {
super.openBookmarkManager(); super.openBookmarkManager();
TestThreadUtils.runOnUiThreadBlocking(() -> { TestThreadUtils.runOnUiThreadBlocking(() -> {
mManager.getDragStateDelegate().setA11yStateForTesting(false); mManager.getDragStateDelegate().setA11yStateForTesting(false);
BookmarkPromoHeader.forcePromoStateForTests(BookmarkPromoHeader.PromoState.PROMO_SYNC);
}); });
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment