Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1126)

Unified Diff: chrome/android/javatests/src/org/chromium/chrome/browser/firstrun/FirstRunIntegrationTest.java

Issue 2839943002: Revert of 🔍 Don't display the search engine until First Run completes (Closed)
Patch Set: Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/android/javatests/src/org/chromium/chrome/browser/firstrun/FirstRunIntegrationTest.java
diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/firstrun/FirstRunIntegrationTest.java b/chrome/android/javatests/src/org/chromium/chrome/browser/firstrun/FirstRunIntegrationTest.java
index 0e4a031c307e883dbe9e6062859a210d496d1fa1..df5bf024cee399ad568a479bf270aae5b1245f4a 100644
--- a/chrome/android/javatests/src/org/chromium/chrome/browser/firstrun/FirstRunIntegrationTest.java
+++ b/chrome/android/javatests/src/org/chromium/chrome/browser/firstrun/FirstRunIntegrationTest.java
@@ -11,19 +11,16 @@
import android.content.Intent;
import android.net.Uri;
import android.support.customtabs.CustomTabsIntent;
-import android.support.test.filters.MediumTest;
import android.support.test.filters.SmallTest;
-import android.widget.Button;
+import android.test.InstrumentationTestCase;
-import org.chromium.base.ThreadUtils;
import org.chromium.base.test.util.CommandLineFlags;
-import org.chromium.chrome.R;
import org.chromium.chrome.browser.ChromeSwitches;
import org.chromium.chrome.browser.ChromeTabbedActivity;
import org.chromium.chrome.browser.customtabs.CustomTabActivity;
import org.chromium.chrome.browser.document.ChromeLauncherActivity;
import org.chromium.chrome.browser.searchwidget.SearchActivity;
-import org.chromium.chrome.test.MultiActivityTestBase;
+import org.chromium.chrome.test.util.ApplicationTestUtils;
import org.chromium.content.browser.test.util.Criteria;
import org.chromium.content.browser.test.util.CriteriaHelper;
@@ -31,19 +28,16 @@
* Integration test suite for the first run experience.
*/
@CommandLineFlags.Remove(ChromeSwitches.DISABLE_FIRST_RUN_EXPERIENCE)
-public class FirstRunIntegrationTest extends MultiActivityTestBase {
- private FirstRunActivityTestObserver mTestObserver = new FirstRunActivityTestObserver();
- private Activity mActivity;
-
+public class FirstRunIntegrationTest extends InstrumentationTestCase {
@Override
public void setUp() throws Exception {
super.setUp();
- FirstRunActivity.setObserverForTest(mTestObserver);
+ ApplicationTestUtils.setUp(getInstrumentation().getTargetContext(), true);
}
@Override
public void tearDown() throws Exception {
- if (mActivity != null) mActivity.finish();
+ ApplicationTestUtils.tearDown(getInstrumentation().getTargetContext());
super.tearDown();
}
@@ -170,105 +164,4 @@
assertEquals(0, freMonitor.getHits());
}
- @SmallTest
- public void testAbortFirstRun() throws Exception {
- final ActivityMonitor freMonitor =
- new ActivityMonitor(FirstRunActivity.class.getName(), null, false);
- Instrumentation instrumentation = getInstrumentation();
- instrumentation.addMonitor(freMonitor);
-
- final Context context = instrumentation.getTargetContext();
- Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://test.com"));
- intent.setPackage(context.getPackageName());
- intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- context.startActivity(intent);
-
- // Because the AsyncInitializationActivity notices that the FRE hasn't been run yet, it
- // redirects to it. Once the user closes the FRE, the user should be kicked back into the
- // startup flow where they were interrupted.
- mActivity = instrumentation.waitForMonitorWithTimeout(
- freMonitor, CriteriaHelper.DEFAULT_MAX_TIME_TO_POLL);
- instrumentation.removeMonitor(freMonitor);
- ActivityMonitor activityMonitor =
- new ActivityMonitor(ChromeLauncherActivity.class.getName(), null, false);
- instrumentation.addMonitor(activityMonitor);
-
- assertEquals(0, mTestObserver.abortFirstRunExperienceCallback.getCallCount());
- mActivity.onBackPressed();
- mTestObserver.abortFirstRunExperienceCallback.waitForCallback(
- "FirstRunActivity didn't abort", 0);
-
- mActivity = instrumentation.waitForMonitorWithTimeout(
- activityMonitor, CriteriaHelper.DEFAULT_MAX_TIME_TO_POLL);
- CriteriaHelper.pollInstrumentationThread(new Criteria() {
- @Override
- public boolean isSatisfied() {
- return mActivity.isFinishing();
- }
- });
- }
-
- @MediumTest
- public void testClickThroughFirstRun() throws Exception {
- final ActivityMonitor freMonitor =
- new ActivityMonitor(FirstRunActivity.class.getName(), null, false);
- Instrumentation instrumentation = getInstrumentation();
- instrumentation.addMonitor(freMonitor);
-
- final Context context = instrumentation.getTargetContext();
- Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://test.com"));
- intent.setPackage(context.getPackageName());
- intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- context.startActivity(intent);
-
- // Because the AsyncInitializationActivity notices that the FRE hasn't been run yet, it
- // redirects to it. Once the user closes the FRE, the user should be kicked back into the
- // startup flow where they were interrupted.
- mActivity = instrumentation.waitForMonitorWithTimeout(
- freMonitor, CriteriaHelper.DEFAULT_MAX_TIME_TO_POLL);
- instrumentation.removeMonitor(freMonitor);
- ActivityMonitor activityMonitor =
- new ActivityMonitor(ChromeTabbedActivity.class.getName(), null, false);
- instrumentation.addMonitor(activityMonitor);
-
- // Accept the ToS.
- mTestObserver.flowIsKnownCallback.waitForCallback("Failed to finalize the flow", 0);
- clickButton(mActivity, R.id.terms_accept);
- mTestObserver.acceptTermsOfServiceCallback.waitForCallback("Failed to accept the ToS", 0);
- mTestObserver.jumpToPageCallback.waitForCallback(
- "Failed to try moving to the next screen", 0);
-
- // Acknowledge that Data Saver will be enabled.
- int jumpCallCount = mTestObserver.jumpToPageCallback.getCallCount();
- clickButton(mActivity, R.id.next_button);
- mTestObserver.jumpToPageCallback.waitForCallback(
- "Failed to try moving to next screen", jumpCallCount);
-
- // Don't sign in the user.
- assertEquals(0, mTestObserver.updateCachedEngineCallback.getCallCount());
- jumpCallCount = mTestObserver.jumpToPageCallback.getCallCount();
- clickButton(mActivity, R.id.negative_button);
- mTestObserver.jumpToPageCallback.waitForCallback(
- "Failed to try moving to next screen", jumpCallCount);
- mTestObserver.updateCachedEngineCallback.waitForCallback(
- "Failed to alert search widgets that an update is necessary", 0);
-
- // FRE should be completed now, which will kick the user back into the interrupted flow.
- // In this case, the user gets sent to the ChromeTabbedActivity after a View Intent is
- // processed by ChromeLauncherActivity.
- mActivity = instrumentation.waitForMonitorWithTimeout(
- activityMonitor, CriteriaHelper.DEFAULT_MAX_TIME_TO_POLL);
- assertNotNull(mActivity);
- }
-
- private void clickButton(final Activity activity, final int id) {
- ThreadUtils.runOnUiThread(new Runnable() {
- @Override
- public void run() {
- Button button = (Button) activity.findViewById(id);
- assertNotNull(button);
- button.performClick();
- }
- });
- }
}

Powered by Google App Engine
This is Rietveld 408576698