diff options
author | aruslan@chromium.org <aruslan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-03-27 22:03:12 +0000 |
---|---|---|
committer | aruslan@chromium.org <aruslan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-03-27 22:03:12 +0000 |
commit | 6100f23ca5e65f4da37eae9b77732ed420206ee8 (patch) | |
tree | 89faff1c7a20d31a6e465f458f84e86d2deb458b | |
parent | a3ad1ba5c549d0dd8dc051cf1c9efaa5fc65972c (diff) | |
download | chromium_src-6100f23ca5e65f4da37eae9b77732ed420206ee8.zip chromium_src-6100f23ca5e65f4da37eae9b77732ed420206ee8.tar.gz chromium_src-6100f23ca5e65f4da37eae9b77732ed420206ee8.tar.bz2 |
Deflake ContentDetection tests.
All pages used by the test have <meta viewport> tag, so
we assert-wait till the compositor sends correct coordinates
to the ContentViewCore (cf http://crbug.com/179511).
BUG=172786, 167022
NOTRY=True
Review URL: https://chromiumcodereview.appspot.com/12594042
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@191041 0039d316-1c4b-4281-b951-d872f2087c98
4 files changed, 28 insertions, 43 deletions
diff --git a/content/public/android/javatests/src/org/chromium/content/browser/AddressDetectionTest.java b/content/public/android/javatests/src/org/chromium/content/browser/AddressDetectionTest.java index 32ed9e7..ce7cfd6 100644 --- a/content/public/android/javatests/src/org/chromium/content/browser/AddressDetectionTest.java +++ b/content/public/android/javatests/src/org/chromium/content/browser/AddressDetectionTest.java @@ -6,7 +6,6 @@ package org.chromium.content.browser; import android.test.suitebuilder.annotation.MediumTest; -import org.chromium.base.test.util.DisabledTest; import org.chromium.base.test.util.Feature; /** @@ -22,14 +21,11 @@ public class AddressDetectionTest extends ContentDetectionTestBase { return intentUrl.equals(expectedUrl); } - /* @MediumTest @Feature({"ContentDetection", "TabContents"}) - http://crbug.com/172786 - */ - @DisabledTest public void testMultipleAddressesInText() throws Throwable { startActivityWithTestUrl("content/content_detection/geo_address_multiple.html"); + assertWaitForPageScaleFactorMatch(1.0f); assertTrue(isExpectedGeoIntent(scrollAndTapExpectingIntent("test1"), "1600 Amphitheatre Parkway Mountain View, CA 94043")); @@ -38,14 +34,11 @@ public class AddressDetectionTest extends ContentDetectionTestBase { "76 Ninth Avenue 4th Floor New York, NY 10011")); } - /* @MediumTest @Feature({"ContentDetection", "TabContents"}) - http://crbug.com/172786 - */ - @DisabledTest public void testSplitAddresses() throws Throwable { startActivityWithTestUrl("content/content_detection/geo_address_split.html"); + assertWaitForPageScaleFactorMatch(1.0f); assertTrue(isExpectedGeoIntent(scrollAndTapExpectingIntent("test1"), "9606 North MoPac Expressway Suite 400 Austin, TX 78759")); @@ -60,14 +53,11 @@ public class AddressDetectionTest extends ContentDetectionTestBase { "1818 Library Street Suite 400, VA 20190")); } - /* @MediumTest @Feature({"ContentDetection", "TabContents"}) - http://crbug.com/172786 - */ - @DisabledTest public void testAddressLimits() throws Throwable { startActivityWithTestUrl("content/content_detection/geo_address_limits.html"); + assertWaitForPageScaleFactorMatch(1.0f); assertTrue(isExpectedGeoIntent(scrollAndTapExpectingIntent("test1"), "2590 Pearl Street Suite 100 Boulder, CO 80302")); @@ -82,14 +72,11 @@ public class AddressDetectionTest extends ContentDetectionTestBase { "1600 Amphitheatre Parkway Mountain View, CA 94043")); } - /* @MediumTest @Feature({"ContentDetection", "TabContents"}) - http://crbug.com/172786 - */ - @DisabledTest public void testRealAddresses() throws Throwable { startActivityWithTestUrl("content/content_detection/geo_address_real.html"); + assertWaitForPageScaleFactorMatch(1.0f); assertTrue(isExpectedGeoIntent(scrollAndTapExpectingIntent("test1"), "57th Street and Lake Shore Drive Chicago, IL 60637")); @@ -104,14 +91,11 @@ public class AddressDetectionTest extends ContentDetectionTestBase { "79th Street, New York, NY, 10024-5192")); } - /* @MediumTest @Feature({"ContentDetection", "TabContents"}) - http://crbug.com/172786 - */ - @DisabledTest public void testSpecialChars() throws Throwable { startActivityWithTestUrl("content/content_detection/geo_address_special_chars.html"); + assertWaitForPageScaleFactorMatch(1.0f); assertTrue(isExpectedGeoIntent(scrollAndTapExpectingIntent("test1"), "100 34th Avenue , San Francisco, CA 94121")); diff --git a/content/public/android/javatests/src/org/chromium/content/browser/ContentDetectionTestBase.java b/content/public/android/javatests/src/org/chromium/content/browser/ContentDetectionTestBase.java index 648bfde..5ee5d32 100644 --- a/content/public/android/javatests/src/org/chromium/content/browser/ContentDetectionTestBase.java +++ b/content/public/android/javatests/src/org/chromium/content/browser/ContentDetectionTestBase.java @@ -10,6 +10,8 @@ import android.net.Uri; import java.util.concurrent.TimeUnit; import org.chromium.base.test.util.UrlUtils; +import org.chromium.content.browser.test.util.Criteria; +import org.chromium.content.browser.test.util.CriteriaHelper; import org.chromium.content.browser.test.util.DOMUtils; import org.chromium.content.browser.test.util.JavaScriptUtils; import org.chromium.content.browser.test.util.TestCallbackHelperContainer; @@ -94,4 +96,20 @@ public class ContentDetectionTestBase extends ContentShellTestBase { TimeUnit.SECONDS); getInstrumentation().waitForIdleSync(); } + + // TODO(aelias): This method needs to be removed once http://crbug.com/179511 is fixed. + // Meanwhile, we have to wait if the page has the <meta viewport> tag. + /** + * Waits till the ContentViewCore receives the expected page scale factor + * from the compositor and asserts that this happens. + */ + protected void assertWaitForPageScaleFactorMatch(final float expectedScale) + throws InterruptedException { + assertTrue(CriteriaHelper.pollForCriteria(new Criteria() { + @Override + public boolean isSatisfied() { + return getContentViewCore().getScale() == expectedScale; + } + })); + } } diff --git a/content/public/android/javatests/src/org/chromium/content/browser/EmailAddressDetectionTest.java b/content/public/android/javatests/src/org/chromium/content/browser/EmailAddressDetectionTest.java index 2dd5d34e..2bd8797 100644 --- a/content/public/android/javatests/src/org/chromium/content/browser/EmailAddressDetectionTest.java +++ b/content/public/android/javatests/src/org/chromium/content/browser/EmailAddressDetectionTest.java @@ -6,7 +6,6 @@ package org.chromium.content.browser; import android.test.suitebuilder.annotation.MediumTest; -import org.chromium.base.test.util.DisabledTest; import org.chromium.base.test.util.Feature; /** @@ -22,14 +21,11 @@ public class EmailAddressDetectionTest extends ContentDetectionTestBase { return intentUrl.equals(expectedUrl); } - /* @MediumTest @Feature({"ContentDetection", "TabContents"}) - http://crbug.com/172786 - */ - @DisabledTest public void testValidEmailAddresses() throws Throwable { startActivityWithTestUrl("content/content_detection/email.html"); + assertWaitForPageScaleFactorMatch(1.0f); // valid_1: i.want.a.pony@chromium.org. String intentUrl = scrollAndTapExpectingIntent("valid_1"); diff --git a/content/public/android/javatests/src/org/chromium/content/browser/PhoneNumberDetectionTest.java b/content/public/android/javatests/src/org/chromium/content/browser/PhoneNumberDetectionTest.java index 34432d6..031cf62 100644 --- a/content/public/android/javatests/src/org/chromium/content/browser/PhoneNumberDetectionTest.java +++ b/content/public/android/javatests/src/org/chromium/content/browser/PhoneNumberDetectionTest.java @@ -7,7 +7,6 @@ package org.chromium.content.browser; import android.test.suitebuilder.annotation.LargeTest; import android.test.suitebuilder.annotation.MediumTest; -import org.chromium.base.test.util.DisabledTest; import org.chromium.base.test.util.Feature; import org.chromium.content.common.CommandLine; @@ -38,14 +37,11 @@ public class PhoneNumberDetectionTest extends ContentDetectionTestBase { startActivityWithTestUrlAndCommandLineArgs(testUrl, cmdlineArgs); } - /* @LargeTest @Feature({"ContentDetection", "TabContents"}) - http://crbug.com/172786 - */ - @DisabledTest public void testInternationalNumberIntents() throws Throwable { startActivityWithTestUrl("content/content_detection/phone_international.html"); + assertWaitForPageScaleFactorMatch(1.0f); // US: +1 650-253-0000. String intentUrl = scrollAndTapExpectingIntent("US"); @@ -156,14 +152,11 @@ public class PhoneNumberDetectionTest extends ContentDetectionTestBase { assertTrue(isExpectedTelephoneIntent(intentUrl, "+97144509500")); } - /* @MediumTest @Feature({"ContentDetection", "TabContents"}) - http://crbug.com/172786 - */ - @DisabledTest public void testLocalUSNumbers() throws Throwable { startActivityWithTestUrlAndCountryIso("content/content_detection/phone_local.html", "US"); + assertWaitForPageScaleFactorMatch(1.0f); // US_1: 1-888-433-5788. String intentUrl = scrollAndTapExpectingIntent("US_1"); @@ -182,14 +175,11 @@ public class PhoneNumberDetectionTest extends ContentDetectionTestBase { assertTrue(isExpectedTelephoneIntent(intentUrl, "+31205045100")); } - /* @MediumTest @Feature({"ContentDetection", "TabContents"}) - http://crbug.com/172786 - */ - @DisabledTest public void testLocalUKNumbers() throws Throwable { startActivityWithTestUrlAndCountryIso("content/content_detection/phone_local.html", "GB"); + assertWaitForPageScaleFactorMatch(1.0f); // GB_1: (0) 20 7323 8299. String intentUrl = scrollAndTapExpectingIntent("GB_1"); @@ -208,14 +198,11 @@ public class PhoneNumberDetectionTest extends ContentDetectionTestBase { assertTrue(isExpectedTelephoneIntent(intentUrl, "+31205045100")); } - /* @MediumTest @Feature({"ContentDetection", "TabContents"}) - http://crbug.com/172786 - */ - @DisabledTest public void testLocalFRNumbers() throws Throwable { startActivityWithTestUrlAndCountryIso("content/content_detection/phone_local.html", "FR"); + assertWaitForPageScaleFactorMatch(1.0f); // FR_1: 01 40 20 50 50. String intentUrl = scrollAndTapExpectingIntent("FR_1"); |