Commit 568372e8 authored by Josh Simmons's avatar Josh Simmons Committed by Commit Bot

Add network restriction for translate tests so we can reenable them.

These tests were failing on networkless phones in lab. We should probably figure out how to mock out the translate service for these, but for now this is a step in the right direction.

Bug: 1130712
Bug: 1127786

Change-Id: Ifd7cb1176ae9beb89c1f44268af9c0add9f29a99
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2446894
Commit-Queue: Josh Simmons <jds@google.com>
Reviewed-by: default avatarScott Little <sclittle@chromium.org>
Cr-Commit-Position: refs/heads/master@{#813456}
parent 4cd6dcd2
...@@ -17,7 +17,6 @@ import org.junit.Test; ...@@ -17,7 +17,6 @@ import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.chromium.base.test.util.CommandLineFlags; import org.chromium.base.test.util.CommandLineFlags;
import org.chromium.base.test.util.DisabledTest;
import org.chromium.base.test.util.Feature; import org.chromium.base.test.util.Feature;
import org.chromium.base.test.util.Restriction; import org.chromium.base.test.util.Restriction;
import org.chromium.chrome.R; import org.chromium.chrome.R;
...@@ -73,9 +72,11 @@ public class TranslateCompactInfoBarTest { ...@@ -73,9 +72,11 @@ public class TranslateCompactInfoBarTest {
@Test @Test
@MediumTest @MediumTest
@Feature({"Browser", "Main"}) @Feature({"Browser", "Main"})
@Restriction(ChromeRestriction.RESTRICTION_TYPE_GOOGLE_PLAY_SERVICES) // TODO(crbug.com/1134812): Remove the reliance on a network connection for these tests.
@DisabledTest(message = "https://crbug.com/1130712") @Restriction({ChromeRestriction.RESTRICTION_TYPE_GOOGLE_PLAY_SERVICES,
public void testTranslateCompactInfoBarAppears() throws TimeoutException { Restriction.RESTRICTION_TYPE_INTERNET})
public void
testTranslateCompactInfoBarAppears() throws TimeoutException {
mActivityTestRule.loadUrl(mTestServer.getURL(TRANSLATE_PAGE)); mActivityTestRule.loadUrl(mTestServer.getURL(TRANSLATE_PAGE));
mListener.addInfoBarAnimationFinished("InfoBar not opened."); mListener.addInfoBarAnimationFinished("InfoBar not opened.");
InfoBar infoBar = mInfoBarContainer.getInfoBarsForTesting().get(0); InfoBar infoBar = mInfoBarContainer.getInfoBarsForTesting().get(0);
...@@ -89,9 +90,10 @@ public class TranslateCompactInfoBarTest { ...@@ -89,9 +90,10 @@ public class TranslateCompactInfoBarTest {
@Test @Test
@MediumTest @MediumTest
@Feature({"Browser", "Main"}) @Feature({"Browser", "Main"})
@Restriction(ChromeRestriction.RESTRICTION_TYPE_GOOGLE_PLAY_SERVICES) @Restriction({ChromeRestriction.RESTRICTION_TYPE_GOOGLE_PLAY_SERVICES,
@DisabledTest(message = "https://crbug.com/1130712") Restriction.RESTRICTION_TYPE_INTERNET})
public void testTranslateCompactInfoBarOverflowMenus() throws TimeoutException { public void
testTranslateCompactInfoBarOverflowMenus() throws TimeoutException {
mActivityTestRule.loadUrl(mTestServer.getURL(TRANSLATE_PAGE)); mActivityTestRule.loadUrl(mTestServer.getURL(TRANSLATE_PAGE));
mListener.addInfoBarAnimationFinished("InfoBar not opened."); mListener.addInfoBarAnimationFinished("InfoBar not opened.");
TranslateCompactInfoBar infoBar = TranslateCompactInfoBar infoBar =
...@@ -112,9 +114,10 @@ public class TranslateCompactInfoBarTest { ...@@ -112,9 +114,10 @@ public class TranslateCompactInfoBarTest {
@Test @Test
@MediumTest @MediumTest
@Feature({"Browser", "Main"}) @Feature({"Browser", "Main"})
@Restriction(ChromeRestriction.RESTRICTION_TYPE_GOOGLE_PLAY_SERVICES) @Restriction({ChromeRestriction.RESTRICTION_TYPE_GOOGLE_PLAY_SERVICES,
@DisabledTest(message = "https://crbug.com/1130712") Restriction.RESTRICTION_TYPE_INTERNET})
public void testTabMenuDismissedOnOrientationChange() throws Exception { public void
testTabMenuDismissedOnOrientationChange() throws Exception {
mActivityTestRule.loadUrl(mTestServer.getURL(TRANSLATE_PAGE)); mActivityTestRule.loadUrl(mTestServer.getURL(TRANSLATE_PAGE));
mListener.addInfoBarAnimationFinished("InfoBar not opened."); mListener.addInfoBarAnimationFinished("InfoBar not opened.");
TranslateCompactInfoBar infoBar = TranslateCompactInfoBar infoBar =
...@@ -142,9 +145,10 @@ public class TranslateCompactInfoBarTest { ...@@ -142,9 +145,10 @@ public class TranslateCompactInfoBarTest {
@Test @Test
@MediumTest @MediumTest
@Feature({"Browser", "Main"}) @Feature({"Browser", "Main"})
@Restriction(ChromeRestriction.RESTRICTION_TYPE_GOOGLE_PLAY_SERVICES) @Restriction({ChromeRestriction.RESTRICTION_TYPE_GOOGLE_PLAY_SERVICES,
@DisabledTest(message = "https://crbug.com/1130712") Restriction.RESTRICTION_TYPE_INTERNET})
public void testTranslateCompactInfoBarReopenOnTarget() throws TimeoutException { public void
testTranslateCompactInfoBarReopenOnTarget() throws TimeoutException {
mActivityTestRule.loadUrl(mTestServer.getURL(TRANSLATE_PAGE)); mActivityTestRule.loadUrl(mTestServer.getURL(TRANSLATE_PAGE));
mListener.addInfoBarAnimationFinished("InfoBar not opened."); mListener.addInfoBarAnimationFinished("InfoBar not opened.");
...@@ -177,9 +181,10 @@ public class TranslateCompactInfoBarTest { ...@@ -177,9 +181,10 @@ public class TranslateCompactInfoBarTest {
@Test @Test
@MediumTest @MediumTest
@Feature({"Browser", "Main"}) @Feature({"Browser", "Main"})
@Restriction(ChromeRestriction.RESTRICTION_TYPE_GOOGLE_PLAY_SERVICES) @Restriction({ChromeRestriction.RESTRICTION_TYPE_GOOGLE_PLAY_SERVICES,
@DisabledTest(message = "https://crbug.com/1130712") Restriction.RESTRICTION_TYPE_INTERNET})
public void testStartTranslateOnManualInitiation() throws TimeoutException { public void
testStartTranslateOnManualInitiation() throws TimeoutException {
// Load a page that won't trigger the translate recommendation. // Load a page that won't trigger the translate recommendation.
mActivityTestRule.loadUrl(mTestServer.getURL(NON_TRANSLATE_PAGE)); mActivityTestRule.loadUrl(mTestServer.getURL(NON_TRANSLATE_PAGE));
...@@ -204,9 +209,10 @@ public class TranslateCompactInfoBarTest { ...@@ -204,9 +209,10 @@ public class TranslateCompactInfoBarTest {
@Test @Test
@MediumTest @MediumTest
@Feature({"Browser", "Main"}) @Feature({"Browser", "Main"})
@Restriction(ChromeRestriction.RESTRICTION_TYPE_GOOGLE_PLAY_SERVICES) @Restriction({ChromeRestriction.RESTRICTION_TYPE_GOOGLE_PLAY_SERVICES,
@DisabledTest(message = "https://crbug.com/1130712") Restriction.RESTRICTION_TYPE_INTERNET})
public void testManualInitiationWithBarOpen() throws TimeoutException { public void
testManualInitiationWithBarOpen() throws TimeoutException {
mActivityTestRule.loadUrl(mTestServer.getURL(TRANSLATE_PAGE)); mActivityTestRule.loadUrl(mTestServer.getURL(TRANSLATE_PAGE));
mListener.addInfoBarAnimationFinished("InfoBar not opened."); mListener.addInfoBarAnimationFinished("InfoBar not opened.");
......
...@@ -8,7 +8,6 @@ import android.content.ComponentName; ...@@ -8,7 +8,6 @@ import android.content.ComponentName;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.pm.PackageManager; import android.content.pm.PackageManager;
import android.os.Build.VERSION_CODES;
import androidx.test.filters.MediumTest; import androidx.test.filters.MediumTest;
import androidx.test.filters.SmallTest; import androidx.test.filters.SmallTest;
...@@ -25,7 +24,7 @@ import org.junit.runner.RunWith; ...@@ -25,7 +24,7 @@ import org.junit.runner.RunWith;
import org.chromium.base.ContextUtils; import org.chromium.base.ContextUtils;
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.DisableIf; import org.chromium.base.test.util.Restriction;
import org.chromium.chrome.browser.IntentHandler; import org.chromium.chrome.browser.IntentHandler;
import org.chromium.chrome.browser.document.ChromeLauncherActivity; import org.chromium.chrome.browser.document.ChromeLauncherActivity;
import org.chromium.chrome.browser.flags.ChromeFeatureList; import org.chromium.chrome.browser.flags.ChromeFeatureList;
...@@ -136,12 +135,10 @@ public class TranslateIntentTest { ...@@ -136,12 +135,10 @@ public class TranslateIntentTest {
@Test @Test
@MediumTest @MediumTest
@DisableIf. // TODO(crbug.com/1134812): Remove the reliance on a network connection for these tests.
Build(sdk_is_greater_than = VERSION_CODES.LOLLIPOP_MR1, sdk_is_less_than = VERSION_CODES.N, @Restriction(Restriction.RESTRICTION_TYPE_INTERNET)
message = "Consistently failing on Marshmallow https://crbug.com/1127786")
@Features.DisableFeatures({ChromeFeatureList.TRANSLATE_INTENT}) @Features.DisableFeatures({ChromeFeatureList.TRANSLATE_INTENT})
public void public void testTranslateIntentDisabled() throws TimeoutException {
testTranslateIntentDisabled() throws TimeoutException {
final String url = sActivityTestRule.getTestServer().getURL(TRANSLATE_PAGE); final String url = sActivityTestRule.getTestServer().getURL(TRANSLATE_PAGE);
// Load a page that triggers the translate recommendation. // Load a page that triggers the translate recommendation.
sActivityTestRule.loadUrl(url); sActivityTestRule.loadUrl(url);
...@@ -156,12 +153,9 @@ public class TranslateIntentTest { ...@@ -156,12 +153,9 @@ public class TranslateIntentTest {
@Test @Test
@MediumTest @MediumTest
@DisableIf. @Restriction(Restriction.RESTRICTION_TYPE_INTERNET)
Build(sdk_is_greater_than = VERSION_CODES.LOLLIPOP_MR1, sdk_is_less_than = VERSION_CODES.N,
message = "Consistently failing on Marshmallow https://crbug.com/1127786")
@Features.EnableFeatures({ChromeFeatureList.TRANSLATE_INTENT}) @Features.EnableFeatures({ChromeFeatureList.TRANSLATE_INTENT})
public void public void testTranslateIntentOnTranslatePage() throws TimeoutException {
testTranslateIntentOnTranslatePage() throws TimeoutException {
final String url = sActivityTestRule.getTestServer().getURL(TRANSLATE_PAGE); final String url = sActivityTestRule.getTestServer().getURL(TRANSLATE_PAGE);
// Load a page that triggers the translate recommendation. // Load a page that triggers the translate recommendation.
sActivityTestRule.loadUrl(url); sActivityTestRule.loadUrl(url);
...@@ -176,12 +170,9 @@ public class TranslateIntentTest { ...@@ -176,12 +170,9 @@ public class TranslateIntentTest {
@Test @Test
@MediumTest @MediumTest
@DisableIf. @Restriction(Restriction.RESTRICTION_TYPE_INTERNET)
Build(sdk_is_greater_than = VERSION_CODES.LOLLIPOP_MR1, sdk_is_less_than = VERSION_CODES.N,
message = "Consistently failing on Marshmallow https://crbug.com/1127786")
@Features.EnableFeatures({ChromeFeatureList.TRANSLATE_INTENT}) @Features.EnableFeatures({ChromeFeatureList.TRANSLATE_INTENT})
public void public void testTranslateIntentOnNonTranslatePage() throws TimeoutException {
testTranslateIntentOnNonTranslatePage() throws TimeoutException {
final String url = sActivityTestRule.getTestServer().getURL(NON_TRANSLATE_PAGE); final String url = sActivityTestRule.getTestServer().getURL(NON_TRANSLATE_PAGE);
// Load a page that doesn't trigger the translate recommendation. // Load a page that doesn't trigger the translate recommendation.
sActivityTestRule.loadUrl(url); sActivityTestRule.loadUrl(url);
...@@ -198,12 +189,10 @@ public class TranslateIntentTest { ...@@ -198,12 +189,10 @@ public class TranslateIntentTest {
@Test @Test
@MediumTest @MediumTest
@DisableIf. @Restriction(Restriction.RESTRICTION_TYPE_INTERNET)
Build(sdk_is_greater_than = VERSION_CODES.LOLLIPOP_MR1, sdk_is_less_than = VERSION_CODES.N,
message = "Consistently failing on Marshmallow https://crbug.com/1127786")
@Features.EnableFeatures({ChromeFeatureList.TRANSLATE_INTENT}) @Features.EnableFeatures({ChromeFeatureList.TRANSLATE_INTENT})
public void public void testTranslateIntentWithTargetLanguage()
testTranslateIntentWithTargetLanguage() throws TimeoutException, ExecutionException { throws TimeoutException, ExecutionException {
final String url = sActivityTestRule.getTestServer().getURL(NON_TRANSLATE_PAGE); final String url = sActivityTestRule.getTestServer().getURL(NON_TRANSLATE_PAGE);
// Load a page that doesn't trigger the translate recommendation. // Load a page that doesn't trigger the translate recommendation.
sActivityTestRule.loadUrl(url); sActivityTestRule.loadUrl(url);
...@@ -229,12 +218,9 @@ public class TranslateIntentTest { ...@@ -229,12 +218,9 @@ public class TranslateIntentTest {
@Test @Test
@MediumTest @MediumTest
@DisableIf. @Restriction(Restriction.RESTRICTION_TYPE_INTERNET)
Build(sdk_is_greater_than = VERSION_CODES.LOLLIPOP_MR1, sdk_is_less_than = VERSION_CODES.N,
message = "Consistently failing on Marshmallow https://crbug.com/1127786")
@Features.EnableFeatures({ChromeFeatureList.TRANSLATE_INTENT}) @Features.EnableFeatures({ChromeFeatureList.TRANSLATE_INTENT})
public void public void testTranslateIntentWithUnsupportedTargetLanguage() throws TimeoutException {
testTranslateIntentWithUnsupportedTargetLanguage() throws TimeoutException {
final String url = sActivityTestRule.getTestServer().getURL(NON_TRANSLATE_PAGE); final String url = sActivityTestRule.getTestServer().getURL(NON_TRANSLATE_PAGE);
// Load a page that doesn't trigger the translate recommendation. // Load a page that doesn't trigger the translate recommendation.
sActivityTestRule.loadUrl(url); sActivityTestRule.loadUrl(url);
...@@ -249,12 +235,9 @@ public class TranslateIntentTest { ...@@ -249,12 +235,9 @@ public class TranslateIntentTest {
@Test @Test
@MediumTest @MediumTest
@DisableIf. @Restriction(Restriction.RESTRICTION_TYPE_INTERNET)
Build(sdk_is_greater_than = VERSION_CODES.LOLLIPOP_MR1, sdk_is_less_than = VERSION_CODES.N,
message = "Consistently failing on Marshmallow https://crbug.com/1127786")
@Features.EnableFeatures({ChromeFeatureList.TRANSLATE_INTENT}) @Features.EnableFeatures({ChromeFeatureList.TRANSLATE_INTENT})
public void public void testTranslateIntentOnIncognito() throws TimeoutException {
testTranslateIntentOnIncognito() throws TimeoutException {
final String url = sActivityTestRule.getTestServer().getURL(TRANSLATE_PAGE); final String url = sActivityTestRule.getTestServer().getURL(TRANSLATE_PAGE);
// Load a page that triggers the translate recommendation. // Load a page that triggers the translate recommendation.
sActivityTestRule.loadUrlInNewTab(url, /*incognito=*/true); sActivityTestRule.loadUrlInNewTab(url, /*incognito=*/true);
...@@ -273,12 +256,9 @@ public class TranslateIntentTest { ...@@ -273,12 +256,9 @@ public class TranslateIntentTest {
@Test @Test
@MediumTest @MediumTest
@DisableIf. @Restriction(Restriction.RESTRICTION_TYPE_INTERNET)
Build(sdk_is_greater_than = VERSION_CODES.LOLLIPOP_MR1, sdk_is_less_than = VERSION_CODES.N,
message = "Consistently failing on Marshmallow https://crbug.com/1127786")
@Features.EnableFeatures({ChromeFeatureList.TRANSLATE_INTENT}) @Features.EnableFeatures({ChromeFeatureList.TRANSLATE_INTENT})
public void public void testTranslateIntentWithUrlMismatch() throws TimeoutException {
testTranslateIntentWithUrlMismatch() throws TimeoutException {
final String url = sActivityTestRule.getTestServer().getURL(TRANSLATE_PAGE); final String url = sActivityTestRule.getTestServer().getURL(TRANSLATE_PAGE);
// Load a page that triggers the translate recommendation. // Load a page that triggers the translate recommendation.
sActivityTestRule.loadUrl(url); sActivityTestRule.loadUrl(url);
...@@ -293,12 +273,9 @@ public class TranslateIntentTest { ...@@ -293,12 +273,9 @@ public class TranslateIntentTest {
@Test @Test
@MediumTest @MediumTest
@DisableIf. @Restriction(Restriction.RESTRICTION_TYPE_INTERNET)
Build(sdk_is_greater_than = VERSION_CODES.LOLLIPOP_MR1, sdk_is_less_than = VERSION_CODES.N,
message = "Consistently failing on Marshmallow https://crbug.com/1127786")
@Features.EnableFeatures({ChromeFeatureList.TRANSLATE_INTENT}) @Features.EnableFeatures({ChromeFeatureList.TRANSLATE_INTENT})
public void public void testTranslateIntentWithoutExpectedUrl() throws TimeoutException {
testTranslateIntentWithoutExpectedUrl() throws TimeoutException {
final String url = sActivityTestRule.getTestServer().getURL(TRANSLATE_PAGE); final String url = sActivityTestRule.getTestServer().getURL(TRANSLATE_PAGE);
// Load a page that triggers the translate recommendation. // Load a page that triggers the translate recommendation.
sActivityTestRule.loadUrl(url); sActivityTestRule.loadUrl(url);
...@@ -313,12 +290,9 @@ public class TranslateIntentTest { ...@@ -313,12 +290,9 @@ public class TranslateIntentTest {
@Test @Test
@MediumTest @MediumTest
@DisableIf. @Restriction(Restriction.RESTRICTION_TYPE_INTERNET)
Build(sdk_is_greater_than = VERSION_CODES.LOLLIPOP_MR1, sdk_is_less_than = VERSION_CODES.N,
message = "Consistently failing on Marshmallow https://crbug.com/1127786")
@Features.EnableFeatures({ChromeFeatureList.TRANSLATE_INTENT}) @Features.EnableFeatures({ChromeFeatureList.TRANSLATE_INTENT})
public void public void testTranslateIntentVerifyComponent() throws TimeoutException {
testTranslateIntentVerifyComponent() throws TimeoutException {
final String url = sActivityTestRule.getTestServer().getURL(TRANSLATE_PAGE); final String url = sActivityTestRule.getTestServer().getURL(TRANSLATE_PAGE);
// Load a page that triggers the translate recommendation. // Load a page that triggers the translate recommendation.
sActivityTestRule.loadUrl(url); sActivityTestRule.loadUrl(url);
...@@ -339,12 +313,9 @@ public class TranslateIntentTest { ...@@ -339,12 +313,9 @@ public class TranslateIntentTest {
@Test @Test
@MediumTest @MediumTest
@DisableIf. @Restriction(Restriction.RESTRICTION_TYPE_INTERNET)
Build(sdk_is_greater_than = VERSION_CODES.LOLLIPOP_MR1, sdk_is_less_than = VERSION_CODES.N,
message = "Consistently failing on Marshmallow https://crbug.com/1127786")
@Features.EnableFeatures({ChromeFeatureList.TRANSLATE_INTENT}) @Features.EnableFeatures({ChromeFeatureList.TRANSLATE_INTENT})
public void public void testTranslateIntentIncorrectComponent() throws TimeoutException {
testTranslateIntentIncorrectComponent() throws TimeoutException {
final String url = sActivityTestRule.getTestServer().getURL(TRANSLATE_PAGE); final String url = sActivityTestRule.getTestServer().getURL(TRANSLATE_PAGE);
// Load a page that triggers the translate recommendation. // Load a page that triggers the translate recommendation.
sActivityTestRule.loadUrl(url); sActivityTestRule.loadUrl(url);
......
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