| Index: chrome/android/javatests/src/org/chromium/chrome/browser/physicalweb/ListUrlsActivityTest.java
|
| diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/physicalweb/ListUrlsActivityTest.java b/chrome/android/javatests/src/org/chromium/chrome/browser/physicalweb/ListUrlsActivityTest.java
|
| index 8515373d910a97af3697541efe583c72b44d1e6d..bbba6468c140847529c08e974f65cd2a28c14135 100644
|
| --- a/chrome/android/javatests/src/org/chromium/chrome/browser/physicalweb/ListUrlsActivityTest.java
|
| +++ b/chrome/android/javatests/src/org/chromium/chrome/browser/physicalweb/ListUrlsActivityTest.java
|
| @@ -9,6 +9,7 @@ import android.content.ComponentName;
|
| import android.content.Context;
|
| import android.content.ContextWrapper;
|
| import android.content.Intent;
|
| +import android.preference.PreferenceManager;
|
| import android.test.InstrumentationTestCase;
|
| import android.test.suitebuilder.annotation.SmallTest;
|
| import android.view.View;
|
| @@ -16,6 +17,8 @@ import android.view.View;
|
| import org.chromium.chrome.R;
|
| import org.chromium.chrome.browser.preferences.privacy.PrivacyPreferencesManager;
|
| import org.chromium.chrome.test.util.browser.notifications.MockNotificationManagerProxy;
|
| +import org.chromium.content.browser.test.util.Criteria;
|
| +import org.chromium.content.browser.test.util.CriteriaHelper;
|
| import org.chromium.content.browser.test.util.TestTouchUtils;
|
|
|
| import java.util.ArrayList;
|
| @@ -45,12 +48,24 @@ public class ListUrlsActivityTest extends InstrumentationTestCase {
|
| startedIntents.add(intent);
|
| super.startActivity(intent);
|
| }
|
| +
|
| + public void waitForStartActivity(long timeout) throws InterruptedException {
|
| + CriteriaHelper.pollInstrumentationThread(new Criteria() {
|
| + @Override
|
| + public boolean isSatisfied() {
|
| + return !startedIntents.isEmpty();
|
| + }
|
| + }, timeout, CriteriaHelper.DEFAULT_POLLING_INTERVAL);
|
| + }
|
| }
|
|
|
| @Override
|
| protected void setUp() throws Exception {
|
| super.setUp();
|
| mContext = getInstrumentation().getTargetContext();
|
| + // Restore the onboarding state
|
| + PreferenceManager.getDefaultSharedPreferences(mContext).edit()
|
| + .putInt("physical_web", 2).apply();
|
| UrlManager urlManager = UrlManager.getInstance(mContext);
|
| mMockPwsClient = new MockPwsClient();
|
| urlManager.overridePwsClientForTesting(mMockPwsClient);
|
| @@ -58,7 +73,7 @@ public class ListUrlsActivityTest extends InstrumentationTestCase {
|
| }
|
|
|
| @SmallTest
|
| - public void testTapEntryOpensUrl() {
|
| + public void testTapEntryOpensUrl() throws InterruptedException {
|
| // Ensure the Physical Web is enabled.
|
| PrivacyPreferencesManager prefsManager = PrivacyPreferencesManager.getInstance(mContext);
|
| prefsManager.setPhysicalWebEnabled(true);
|
| @@ -80,7 +95,8 @@ public class ListUrlsActivityTest extends InstrumentationTestCase {
|
| listView.findViewsWithText(entries, TITLE, View.FIND_VIEWS_WITH_TEXT);
|
| assertEquals(1, entries.size());
|
| View entry = entries.get(0);
|
| - TestTouchUtils.clickView(this, entry);
|
| + TestTouchUtils.singleClickView(getInstrumentation(), entry);
|
| + testContextWrapper.waitForStartActivity(1000);
|
|
|
| // Test the fired intent.
|
| assertEquals(1, testContextWrapper.startedIntents.size());
|
|
|