Commit df9f847f authored by Boris Sazonov's avatar Boris Sazonov Committed by Commit Bot

Revert "[Test] Refactor BookmarkPersonalizedSigninPromoDismissTest"

This reverts commit f4a2ff7e.

Reason for revert: https://crbug.com/1149027.

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}

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

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

Bug: 1145843, 1149027
Change-Id: I59fad358639d2b85378dfff422fbe9adf7b75a82
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2540287Reviewed-by: default avatarBoris Sazonov <bsazonov@chromium.org>
Commit-Queue: Boris Sazonov <bsazonov@chromium.org>
Cr-Commit-Position: refs/heads/master@{#827763}
parent 41291e14
...@@ -30,12 +30,11 @@ import org.chromium.chrome.browser.ChromeTabbedActivity; ...@@ -30,12 +30,11 @@ import org.chromium.chrome.browser.ChromeTabbedActivity;
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.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;
import org.chromium.chrome.test.util.browser.signin.AccountManagerTestRule;
import org.chromium.content_public.browser.test.util.TestThreadUtils; import org.chromium.content_public.browser.test.util.TestThreadUtils;
/** /**
...@@ -44,30 +43,25 @@ import org.chromium.content_public.browser.test.util.TestThreadUtils; ...@@ -44,30 +43,25 @@ import org.chromium.content_public.browser.test.util.TestThreadUtils;
@RunWith(ChromeJUnit4ClassRunner.class) @RunWith(ChromeJUnit4ClassRunner.class)
@CommandLineFlags.Add({ChromeSwitches.DISABLE_FIRST_RUN_EXPERIENCE}) @CommandLineFlags.Add({ChromeSwitches.DISABLE_FIRST_RUN_EXPERIENCE})
public class BookmarkPersonalizedSigninPromoDismissTest { public class BookmarkPersonalizedSigninPromoDismissTest {
private final AccountManagerTestRule mAccountManagerTestRule = new AccountManagerTestRule(); 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();
// As bookmarks need the fake AccountManagerFacade in AccountManagerTestRule, // As bookmarks need the fake AccountManagerFacade in SyncTestRule,
// BookmarkTestRule should be initialized after and destroyed before the // BookmarkTestRule should be initialized after and destroyed before the
// AccountManagerTestRule. // SyncTestRule.
@Rule @Rule
public final RuleChain chain = public final RuleChain chain = RuleChain.outerRule(mSyncTestRule).around(mBookmarkTestRule);
RuleChain.outerRule(mAccountManagerTestRule).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();
...@@ -82,19 +76,20 @@ public class BookmarkPersonalizedSigninPromoDismissTest { ...@@ -82,19 +76,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 {
...@@ -107,7 +102,7 @@ public class BookmarkPersonalizedSigninPromoDismissTest { ...@@ -107,7 +102,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());
} }
...@@ -115,7 +110,7 @@ public class BookmarkPersonalizedSigninPromoDismissTest { ...@@ -115,7 +110,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