Commit ae54805d authored by Rohit Agarwal's avatar Rohit Agarwal Committed by Chromium LUCI CQ

Separate CCT toolbar test and ChromeTabbedActivity toolbar test.

ToolbarDataProviderTest is a batch tests which keeps the
ChromeTabbedActivity alive in between the tests. These tests also
included CCT tests which launched CustomTabActivity on top of the
existing ChromeTabbedActivity.

In test environment, launching multiple Activities often results in
Android killing the background process and all the Activities
encapsulating it.

This CL, therefore decouples the CCT tests from ToolbarDataProviderTest
and move it to CustomTabActivityIncognitoTest.

Bug: 1154445
Change-Id: If7a69773fb441d17439401fe2881a11d7a1c5eba
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2621058Reviewed-by: default avatarPeter Conn <peconn@chromium.org>
Commit-Queue: Rohit Agarwal <roagarwal@chromium.org>
Cr-Commit-Position: refs/heads/master@{#841997}
parent 57f977f0
...@@ -55,6 +55,7 @@ import org.chromium.chrome.browser.customtabs.features.toolbar.CustomTabToolbar; ...@@ -55,6 +55,7 @@ import org.chromium.chrome.browser.customtabs.features.toolbar.CustomTabToolbar;
import org.chromium.chrome.browser.flags.ChromeFeatureList; 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.incognito.IncognitoDataTestUtils; import org.chromium.chrome.browser.incognito.IncognitoDataTestUtils;
import org.chromium.chrome.browser.profiles.Profile;
import org.chromium.chrome.test.ChromeJUnit4ClassRunner; import org.chromium.chrome.test.ChromeJUnit4ClassRunner;
import org.chromium.chrome.test.util.browser.Features; import org.chromium.chrome.test.util.browser.Features;
import org.chromium.components.browser_ui.styles.ChromeColors; import org.chromium.components.browser_ui.styles.ChromeColors;
...@@ -209,6 +210,36 @@ public class CustomTabActivityIncognitoTest { ...@@ -209,6 +210,36 @@ public class CustomTabActivityIncognitoTest {
.check(matches(not(isDisplayed()))); .check(matches(not(isDisplayed())));
} }
@Test
@MediumTest
@Features.EnableFeatures({ChromeFeatureList.CCT_INCOGNITO})
public void toolbarHasNonPrimaryIncognitoProfile_ForIncognitoCCT() throws Exception {
Intent intent = createMinimalIncognitoCustomTabIntent();
launchIncognitoCustomTab(intent);
CustomTabToolbar customTabToolbar =
mCustomTabActivityTestRule.getActivity().findViewById(R.id.toolbar);
TestThreadUtils.runOnUiThreadBlocking(() -> {
Profile profile = customTabToolbar.getToolbarDataProvider().getProfile();
assertTrue(profile.isOffTheRecord());
assertFalse(profile.isPrimaryOTRProfile());
});
}
@Test
@MediumTest
public void toolbarHasRegularProfile_ForRegularCCT() {
Intent intent = CustomTabsTestUtils.createMinimalCustomTabIntent(
InstrumentationRegistry.getContext(), "about:blank");
mCustomTabActivityTestRule.startCustomTabActivityWithIntent(intent);
CustomTabToolbar customTabToolbar =
mCustomTabActivityTestRule.getActivity().findViewById(R.id.toolbar);
TestThreadUtils.runOnUiThreadBlocking(() -> {
Profile profile = customTabToolbar.getToolbarDataProvider().getProfile();
assertFalse(profile.isOffTheRecord());
});
}
@Test @Test
@MediumTest @MediumTest
@Features.DisableFeatures({ChromeFeatureList.CCT_INCOGNITO}) @Features.DisableFeatures({ChromeFeatureList.CCT_INCOGNITO})
......
...@@ -9,9 +9,6 @@ import static org.junit.Assert.assertTrue; ...@@ -9,9 +9,6 @@ import static org.junit.Assert.assertTrue;
import static org.chromium.base.test.util.Batch.PER_CLASS; import static org.chromium.base.test.util.Batch.PER_CLASS;
import android.content.Intent;
import android.support.test.InstrumentationRegistry;
import androidx.test.filters.MediumTest; import androidx.test.filters.MediumTest;
import org.junit.Rule; import org.junit.Rule;
...@@ -21,15 +18,9 @@ import org.junit.runner.RunWith; ...@@ -21,15 +18,9 @@ import org.junit.runner.RunWith;
import org.chromium.base.test.util.Batch; import org.chromium.base.test.util.Batch;
import org.chromium.base.test.util.CommandLineFlags; import org.chromium.base.test.util.CommandLineFlags;
import org.chromium.base.test.util.FlakyTest;
import org.chromium.base.test.util.Restriction; import org.chromium.base.test.util.Restriction;
import org.chromium.chrome.R; import org.chromium.chrome.R;
import org.chromium.chrome.browser.customtabs.CustomTabsTestUtils;
import org.chromium.chrome.browser.customtabs.IncognitoCustomTabActivityTestRule;
import org.chromium.chrome.browser.customtabs.features.toolbar.CustomTabToolbar;
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.incognito.IncognitoDataTestUtils;
import org.chromium.chrome.browser.profiles.Profile; import org.chromium.chrome.browser.profiles.Profile;
import org.chromium.chrome.browser.toolbar.top.ToolbarPhone; import org.chromium.chrome.browser.toolbar.top.ToolbarPhone;
import org.chromium.chrome.test.ChromeJUnit4ClassRunner; import org.chromium.chrome.test.ChromeJUnit4ClassRunner;
...@@ -39,15 +30,12 @@ import org.chromium.chrome.test.util.browser.Features; ...@@ -39,15 +30,12 @@ import org.chromium.chrome.test.util.browser.Features;
import org.chromium.content_public.browser.test.util.TestThreadUtils; import org.chromium.content_public.browser.test.util.TestThreadUtils;
import org.chromium.ui.test.util.UiRestriction; import org.chromium.ui.test.util.UiRestriction;
import java.util.concurrent.TimeoutException;
/** /**
* Instrumentation tests for {@link ToolbarDataProvider}. * Instrumentation tests for {@link ToolbarDataProvider}.
*/ */
@RunWith(ChromeJUnit4ClassRunner.class) @RunWith(ChromeJUnit4ClassRunner.class)
@CommandLineFlags.Add({ChromeSwitches.DISABLE_FIRST_RUN_EXPERIENCE}) @CommandLineFlags.Add({ChromeSwitches.DISABLE_FIRST_RUN_EXPERIENCE})
@Restriction(UiRestriction.RESTRICTION_TYPE_PHONE) @Restriction(UiRestriction.RESTRICTION_TYPE_PHONE)
@Features.EnableFeatures({ChromeFeatureList.CCT_INCOGNITO})
@Batch(PER_CLASS) @Batch(PER_CLASS)
public class ToolbarDataProviderTest { public class ToolbarDataProviderTest {
@Rule @Rule
...@@ -56,10 +44,6 @@ public class ToolbarDataProviderTest { ...@@ -56,10 +44,6 @@ public class ToolbarDataProviderTest {
@Rule @Rule
public ChromeTabbedActivityTestRule mActivityTestRule = new ChromeTabbedActivityTestRule(); public ChromeTabbedActivityTestRule mActivityTestRule = new ChromeTabbedActivityTestRule();
@Rule
public IncognitoCustomTabActivityTestRule mCustomTabActivityTestRule =
new IncognitoCustomTabActivityTestRule();
@Rule @Rule
public BlankCTATabInitialStateRule mBlankCTATabInitialStateRule = public BlankCTATabInitialStateRule mBlankCTATabInitialStateRule =
new BlankCTATabInitialStateRule(mActivityTestRule, false); new BlankCTATabInitialStateRule(mActivityTestRule, false);
...@@ -85,35 +69,4 @@ public class ToolbarDataProviderTest { ...@@ -85,35 +69,4 @@ public class ToolbarDataProviderTest {
assertFalse(profile.isOffTheRecord()); assertFalse(profile.isOffTheRecord());
}); });
} }
@Test
@MediumTest
@FlakyTest(message = "https://crbug.com/1154445")
public void testNonPrimaryOTRProfileUsedForIncognitoCCT() throws TimeoutException {
Intent intent = CustomTabsTestUtils.createMinimalIncognitoCustomTabIntent(
InstrumentationRegistry.getContext(), "about:blank");
IncognitoDataTestUtils.fireAndWaitForCctWarmup();
mCustomTabActivityTestRule.startCustomTabActivityWithIntent(intent);
CustomTabToolbar customTabToolbar =
mCustomTabActivityTestRule.getActivity().findViewById(R.id.toolbar);
TestThreadUtils.runOnUiThreadBlocking(() -> {
Profile profile = customTabToolbar.getToolbarDataProvider().getProfile();
assertTrue(profile.isOffTheRecord());
assertFalse(profile.isPrimaryOTRProfile());
});
}
@Test
@MediumTest
public void testRegularProfileUsedForRegularCCT() {
Intent intent = CustomTabsTestUtils.createMinimalCustomTabIntent(
InstrumentationRegistry.getContext(), "about:blank");
mCustomTabActivityTestRule.startCustomTabActivityWithIntent(intent);
CustomTabToolbar customTabToolbar =
mCustomTabActivityTestRule.getActivity().findViewById(R.id.toolbar);
TestThreadUtils.runOnUiThreadBlocking(() -> {
Profile profile = customTabToolbar.getToolbarDataProvider().getProfile();
assertFalse(profile.isOffTheRecord());
});
}
} }
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