Commit 862f8ec2 authored by Theresa Wellington's avatar Theresa Wellington Committed by Chromium LUCI CQ

Re-enable HistoryActivityTest#testOpenSelectedItems

Change HistoryActivityTest#testOpenSelectedItems and #testOpenItem to
capture the intents sent when items are clicked, preventing
ChromeTabbedActivity from actually starting (which is not needed as
part of the validation in these tests).

BUG=1157189

Change-Id: I46cc42ecdff320944e42a608c142bdc852734344
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2594312
Commit-Queue: Wenyu Fu <wenyufu@chromium.org>
Auto-Submit: Theresa  <twellington@chromium.org>
Reviewed-by: default avatarWenyu Fu <wenyufu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#837618}
parent d13a5081
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
package org.chromium.chrome.browser.history; package org.chromium.chrome.browser.history;
import static androidx.test.espresso.intent.Intents.intended; import static androidx.test.espresso.intent.Intents.intended;
import static androidx.test.espresso.intent.Intents.intending;
import static androidx.test.espresso.intent.Intents.times; import static androidx.test.espresso.intent.Intents.times;
import static androidx.test.espresso.intent.matcher.IntentMatchers.hasAction; import static androidx.test.espresso.intent.matcher.IntentMatchers.hasAction;
import static androidx.test.espresso.intent.matcher.IntentMatchers.hasData; import static androidx.test.espresso.intent.matcher.IntentMatchers.hasData;
...@@ -13,6 +14,8 @@ import static org.hamcrest.Matchers.allOf; ...@@ -13,6 +14,8 @@ import static org.hamcrest.Matchers.allOf;
import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.is;
import android.app.Activity;
import android.app.Instrumentation.ActivityResult;
import android.content.ClipData; import android.content.ClipData;
import android.content.ClipboardManager; import android.content.ClipboardManager;
import android.content.Context; import android.content.Context;
...@@ -37,7 +40,6 @@ import org.chromium.base.test.util.CloseableOnMainThread; ...@@ -37,7 +40,6 @@ import org.chromium.base.test.util.CloseableOnMainThread;
import org.chromium.base.test.util.CommandLineFlags; import org.chromium.base.test.util.CommandLineFlags;
import org.chromium.base.test.util.Criteria; import org.chromium.base.test.util.Criteria;
import org.chromium.base.test.util.CriteriaHelper; import org.chromium.base.test.util.CriteriaHelper;
import org.chromium.base.test.util.DisabledTest;
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.IntentHandler; import org.chromium.chrome.browser.IntentHandler;
...@@ -209,19 +211,23 @@ public class HistoryActivityTest { ...@@ -209,19 +211,23 @@ public class HistoryActivityTest {
@Test @Test
@SmallTest @SmallTest
public void testOpenItem() throws Exception { public void testOpenItem() throws Exception {
intending(allOf(hasAction(equalTo(Intent.ACTION_VIEW)), hasData(mItem1.getUrl())))
.respondWith(new ActivityResult(Activity.RESULT_OK, null));
clickItem(2); clickItem(2);
// Match history item open intent twice (once for launcher, once for tab activity)
intended( intended(allOf(hasAction(equalTo(Intent.ACTION_VIEW)), hasData(mItem1.getUrl())), times(1));
allOf(
hasAction(equalTo(Intent.ACTION_VIEW)),
hasData(mItem1.getUrl())),
times(2));
} }
@Test @Test
@SmallTest @SmallTest
@DisabledTest(message = "https://crbug.com/1157189")
public void testOpenSelectedItems() throws Exception { public void testOpenSelectedItems() throws Exception {
// Stub out intent responses to prevent them from actually being sent.
intending(allOf(hasAction(equalTo(Intent.ACTION_VIEW)), hasData(mItem1.getUrl())))
.respondWith(new ActivityResult(Activity.RESULT_OK, null));
intending(allOf(hasAction(equalTo(Intent.ACTION_VIEW)), hasData(mItem2.getUrl())))
.respondWith(new ActivityResult(Activity.RESULT_OK, null));
toggleItemSelection(2); toggleItemSelection(2);
toggleItemSelection(3); toggleItemSelection(3);
...@@ -231,16 +237,8 @@ public class HistoryActivityTest { ...@@ -231,16 +237,8 @@ public class HistoryActivityTest {
R.id.selection_mode_open_in_incognito, 0)); R.id.selection_mode_open_in_incognito, 0));
}); });
intended( intended(allOf(hasAction(equalTo(Intent.ACTION_VIEW)), hasData(mItem1.getUrl())), times(1));
allOf( intended(allOf(hasAction(equalTo(Intent.ACTION_VIEW)), hasData(mItem2.getUrl())), times(1));
hasAction(equalTo(Intent.ACTION_VIEW)),
hasData(mItem1.getUrl())),
times(2));
intended(
allOf(
hasAction(equalTo(Intent.ACTION_VIEW)),
hasData(mItem2.getUrl())),
times(2));
} }
@Test @Test
......
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