Commit 31641efc authored by Tanmoy Mollik's avatar Tanmoy Mollik Committed by Commit Bot

Revert "Reland "[Test] Refactor BookmarkPersonalizedSigninPromoDismissTest""

This reverts commit d26915b9.

Reason for revert: Tests still failing

Original change's description:
> Reland "[Test] Refactor BookmarkPersonalizedSigninPromoDismissTest"
>
> This is a reland of f4a2ff7e
>
> The cl was reverted because testPromoNotShownAfterBeingDismissed and
> testPromoImpressionCountIncrementAfterDisplayingSigninPromo were flaky.
>
> After looking into more details about why the tests are flaky it seems
> that SyncTestRule calls
> NativeLibraryTestUtils.loadNativeLibraryAndInitBrowserProcess() as part
> or rule set up. Other tests like BookmarkBridgeTest and BookmarkModelTest
> uses ChromeBrowserTestRule which also calls this method during rule
> setup. Changing AccountManagerTestRule to ChromeBrowserTestRule should
> fix it.
>
>
> Original change's description:
> > [Test] Refactor BookmarkPersonalizedSigninPromoDismissTest
> >
> > Refactor BookmarkPersonalizedSigninPromoDismissTest to use
> > AccountManagerTestRule and ChromeActivityTestRule instead of
> > SyncTestRule so that it can be batched easily.
> >
> > Bug: 1145843
> > Change-Id: Ia005508ccd84c439b04b25a65af0930b5a15ee0e
> > Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2527021
> > Commit-Queue: Tanmoy Mollik <triploblastic@chromium.org>
> > Reviewed-by: Marc Treib <treib@chromium.org>
> > Reviewed-by: Tanmoy Mollik <triploblastic@chromium.org>
> > Reviewed-by: Alice Wang <aliceywang@chromium.org>
> > Cr-Commit-Position: refs/heads/master@{#827278}
>
> Bug: 1145843
> Change-Id: I261da247b78cd33d2314be6aa40668a9dcdafa98
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2540669
> Reviewed-by: Marc Treib <treib@chromium.org>
> Commit-Queue: Tanmoy Mollik <triploblastic@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#828412}

TBR=treib@chromium.org,triploblastic@chromium.org,aliceywang@chromium.org

# Not skipping CQ checks because original CL landed > 1 day ago.

Bug: 1145843
Change-Id: Ifdd6babc6ded7b5f1fc98c07eb0a8f0a17f1189f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2553424Reviewed-by: default avatarTanmoy Mollik <triploblastic@chromium.org>
Commit-Queue: Tanmoy Mollik <triploblastic@chromium.org>
Cr-Commit-Position: refs/heads/master@{#830141}
parent ca403202
...@@ -31,9 +31,8 @@ import org.chromium.chrome.browser.flags.ChromeFeatureList; ...@@ -31,9 +31,8 @@ import org.chromium.chrome.browser.flags.ChromeFeatureList;
import org.chromium.chrome.browser.flags.ChromeSwitches; import org.chromium.chrome.browser.flags.ChromeSwitches;
import org.chromium.chrome.browser.profiles.Profile; import org.chromium.chrome.browser.profiles.Profile;
import org.chromium.chrome.browser.signin.SigninPromoController; import org.chromium.chrome.browser.signin.SigninPromoController;
import org.chromium.chrome.test.ChromeBrowserTestRule; import org.chromium.chrome.browser.sync.SyncTestRule;
import org.chromium.chrome.test.ChromeJUnit4ClassRunner; import org.chromium.chrome.test.ChromeJUnit4ClassRunner;
import org.chromium.chrome.test.ChromeTabbedActivityTestRule;
import org.chromium.chrome.test.util.BookmarkTestRule; import org.chromium.chrome.test.util.BookmarkTestRule;
import org.chromium.chrome.test.util.BookmarkTestUtil; import org.chromium.chrome.test.util.BookmarkTestUtil;
import org.chromium.chrome.test.util.ChromeTabUtils; import org.chromium.chrome.test.util.ChromeTabUtils;
...@@ -48,31 +47,25 @@ import org.chromium.content_public.browser.test.util.TestThreadUtils; ...@@ -48,31 +47,25 @@ import org.chromium.content_public.browser.test.util.TestThreadUtils;
@Features.DisableFeatures({ChromeFeatureList.INTEREST_FEEDV1_CLICKS_AND_VIEWS_CONDITIONAL_UPLOAD, @Features.DisableFeatures({ChromeFeatureList.INTEREST_FEEDV1_CLICKS_AND_VIEWS_CONDITIONAL_UPLOAD,
ChromeFeatureList.INTEREST_FEED_V2}) ChromeFeatureList.INTEREST_FEED_V2})
public class BookmarkPersonalizedSigninPromoDismissTest { public class BookmarkPersonalizedSigninPromoDismissTest {
private final ChromeBrowserTestRule mChromeBrowserTestRule = new ChromeBrowserTestRule(); private final SyncTestRule mSyncTestRule = new SyncTestRule();
private final BookmarkTestRule mBookmarkTestRule = new BookmarkTestRule();
@Rule private final BookmarkTestRule mBookmarkTestRule = new BookmarkTestRule();
public final ChromeTabbedActivityTestRule mActivityTestRule =
new ChromeTabbedActivityTestRule();
// Bookmarks need fake AccountManagerFacade. ChromeBrowserTestRule initializes fake // As bookmarks need the fake AccountManagerFacade in SyncTestRule,
// AccountManagerFacade as part of initializing AccountManagerTestRule inside it.
// BookmarkTestRule should be initialized after and destroyed before the // BookmarkTestRule should be initialized after and destroyed before the
// ChromeBrowserTestRule. // SyncTestRule.
@Rule @Rule
public final RuleChain chain = public final RuleChain chain = RuleChain.outerRule(mSyncTestRule).around(mBookmarkTestRule);
RuleChain.outerRule(mChromeBrowserTestRule).around(mBookmarkTestRule);
@Before @Before
public void setUp() throws Exception { public void setUp() throws Exception {
mActivityTestRule.startMainActivityOnBlankPage();
BookmarkPromoHeader.forcePromoStateForTests(null); BookmarkPromoHeader.forcePromoStateForTests(null);
BookmarkPromoHeader.setPrefPersonalizedSigninPromoDeclinedForTests(false); BookmarkPromoHeader.setPrefPersonalizedSigninPromoDeclinedForTests(false);
SigninPromoController.setSigninPromoImpressionsCountBookmarksForTests(0); SigninPromoController.setSigninPromoImpressionsCountBookmarksForTests(0);
TestThreadUtils.runOnUiThreadBlocking(() -> { TestThreadUtils.runOnUiThreadBlocking(() -> {
BookmarkModel bookmarkModel = new BookmarkModel(Profile.fromWebContents( BookmarkModel bookmarkModel = new BookmarkModel(Profile.fromWebContents(
mActivityTestRule.getActivity().getActivityTab().getWebContents())); mSyncTestRule.getActivity().getActivityTab().getWebContents()));
bookmarkModel.loadFakePartnerBookmarkShimForTesting(); bookmarkModel.loadFakePartnerBookmarkShimForTesting();
}); });
BookmarkTestUtil.waitForBookmarkModelLoaded(); BookmarkTestUtil.waitForBookmarkModelLoaded();
...@@ -87,19 +80,20 @@ public class BookmarkPersonalizedSigninPromoDismissTest { ...@@ -87,19 +80,20 @@ public class BookmarkPersonalizedSigninPromoDismissTest {
@Test @Test
@MediumTest @MediumTest
public void testPromoNotShownAfterBeingDismissed() { public void testPromoNotShownAfterBeingDismissed() {
mBookmarkTestRule.showBookmarkManager(mActivityTestRule.getActivity()); mBookmarkTestRule.showBookmarkManager(mSyncTestRule.getActivity());
onView(withId(R.id.signin_promo_view_container)).check(matches(isDisplayed())); onView(withId(R.id.signin_promo_view_container)).check(matches(isDisplayed()));
onView(withId(R.id.signin_promo_close_button)).perform(click()); onView(withId(R.id.signin_promo_close_button)).perform(click());
onView(withId(R.id.signin_promo_view_container)).check(doesNotExist()); onView(withId(R.id.signin_promo_view_container)).check(doesNotExist());
closeBookmarkManager(); closeBookmarkManager();
mBookmarkTestRule.showBookmarkManager(mActivityTestRule.getActivity()); mBookmarkTestRule.showBookmarkManager(mSyncTestRule.getActivity());
onView(withId(R.id.signin_promo_view_container)).check(doesNotExist()); onView(withId(R.id.signin_promo_view_container)).check(doesNotExist());
} }
private void closeBookmarkManager() { private void closeBookmarkManager() {
if (mActivityTestRule.getActivity().isTablet()) { if (mSyncTestRule.getActivity().isTablet()) {
ChromeTabbedActivity chromeTabbedActivity = mActivityTestRule.getActivity(); ChromeTabbedActivity chromeTabbedActivity =
(ChromeTabbedActivity) mSyncTestRule.getActivity();
ChromeTabUtils.closeCurrentTab( ChromeTabUtils.closeCurrentTab(
InstrumentationRegistry.getInstrumentation(), chromeTabbedActivity); InstrumentationRegistry.getInstrumentation(), chromeTabbedActivity);
} else { } else {
...@@ -112,7 +106,7 @@ public class BookmarkPersonalizedSigninPromoDismissTest { ...@@ -112,7 +106,7 @@ public class BookmarkPersonalizedSigninPromoDismissTest {
public void testPromoNotExistWhenImpressionLimitReached() { public void testPromoNotExistWhenImpressionLimitReached() {
SigninPromoController.setSigninPromoImpressionsCountBookmarksForTests( SigninPromoController.setSigninPromoImpressionsCountBookmarksForTests(
SigninPromoController.getMaxImpressionsBookmarksForTests()); SigninPromoController.getMaxImpressionsBookmarksForTests());
mBookmarkTestRule.showBookmarkManager(mActivityTestRule.getActivity()); mBookmarkTestRule.showBookmarkManager(mSyncTestRule.getActivity());
onView(withId(R.id.signin_promo_view_container)).check(doesNotExist()); onView(withId(R.id.signin_promo_view_container)).check(doesNotExist());
} }
...@@ -120,7 +114,7 @@ public class BookmarkPersonalizedSigninPromoDismissTest { ...@@ -120,7 +114,7 @@ public class BookmarkPersonalizedSigninPromoDismissTest {
@MediumTest @MediumTest
public void testPromoImpressionCountIncrementAfterDisplayingSigninPromo() { public void testPromoImpressionCountIncrementAfterDisplayingSigninPromo() {
assertEquals(0, SigninPromoController.getSigninPromoImpressionsCountBookmarks()); assertEquals(0, SigninPromoController.getSigninPromoImpressionsCountBookmarks());
mBookmarkTestRule.showBookmarkManager(mActivityTestRule.getActivity()); mBookmarkTestRule.showBookmarkManager(mSyncTestRule.getActivity());
onView(withId(R.id.signin_promo_view_container)).check(matches(isDisplayed())); onView(withId(R.id.signin_promo_view_container)).check(matches(isDisplayed()));
assertEquals(1, SigninPromoController.getSigninPromoImpressionsCountBookmarks()); assertEquals(1, SigninPromoController.getSigninPromoImpressionsCountBookmarks());
} }
......
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