Commit 1903072d authored by Mugdha Lakhani's avatar Mugdha Lakhani Committed by Commit Bot

[WebLayer] Add test for single tap target.

Update existing PageInfo test and add another one to verify the
container UrlBarView shows Page Info when clicked by default.

Bug: 1116056
Change-Id: I26719b3d47184a5fcf8132c00f9fce32c7a7874d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2359075
Auto-Submit: Mugdha Lakhani <nator@chromium.org>
Commit-Queue: Bo <boliu@chromium.org>
Reviewed-by: default avatarBo <boliu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#798605}
parent 44d6d78e
......@@ -10,6 +10,7 @@ import static androidx.test.espresso.matcher.ViewMatchers.isDisplayed;
import static androidx.test.espresso.matcher.ViewMatchers.withText;
import android.content.Context;
import android.os.Bundle;
import androidx.test.filters.SmallTest;
......@@ -37,8 +38,10 @@ public class PageInfoTest {
@SmallTest
@MinWebLayerVersion(84)
public void testPageInfoLaunches() {
Bundle extras = new Bundle();
extras.putBoolean(InstrumentationActivity.EXTRA_URLBAR_TEXT_CLICKABLE, false);
InstrumentationActivity activity = mActivityTestRule.launchShellWithUrl(
mActivityTestRule.getTestDataURL("simple_page.html"));
mActivityTestRule.getTestDataURL("simple_page.html"), extras);
Context remoteContext = TestWebLayer.getRemoteContext(activity.getApplicationContext());
int buttonId = ResourceUtil.getIdentifier(remoteContext, "id/security_button");
......@@ -56,4 +59,27 @@ public class PageInfoTest {
}
});
}
@Test
@SmallTest
@MinWebLayerVersion(86)
public void testSingleTappableContainer() {
Bundle extras = new Bundle();
extras.putBoolean(InstrumentationActivity.EXTRA_URLBAR_TEXT_CLICKABLE, true);
InstrumentationActivity activity = mActivityTestRule.launchShellWithUrl(
mActivityTestRule.getTestDataURL("simple_page.html"), extras);
TestThreadUtils.runOnUiThreadBlocking(() -> {
StrictModeContext ignored = StrictModeContext.allowDiskReads();
EventUtils.simulateTouchCenterOfView(activity.getUrlBarView());
});
CriteriaHelper.pollInstrumentationThread(() -> {
try {
onView(withText("Your connection to this site is not secure"))
.check(matches(isDisplayed()));
} catch (Error e) {
throw new CriteriaNotSatisfiedException(e.toString());
}
});
}
}
......@@ -54,6 +54,10 @@ public class InstrumentationActivity extends FragmentActivity {
// True by default. If set to false, the test should call loadWebLayerSync.
public static final String EXTRA_CREATE_WEBLAYER = "EXTRA_CREATE_WEBLAYER";
// Used in tests to specify whether WebLayer URL bar should set default click listeners
// that show Page Info UI on its TextView.
public static final String EXTRA_URLBAR_TEXT_CLICKABLE = "EXTRA_URLBAR_TEXT_CLICKABLE";
private Profile mProfile;
private Fragment mFragment;
private Browser mBrowser;
......@@ -332,12 +336,15 @@ public class InstrumentationActivity extends FragmentActivity {
}
private void createUrlBarView() {
mUrlBarView = mBrowser.getUrlBarController().createUrlBarView(
UrlBarOptions.builder()
.setTextSizeSP(DEFAULT_TEXT_SIZE)
.setTextColor(android.R.color.black)
.setIconColor(android.R.color.black)
.build());
UrlBarOptions.Builder optionsBuilder = UrlBarOptions.builder()
.setTextSizeSP(DEFAULT_TEXT_SIZE)
.setTextColor(android.R.color.black)
.setIconColor(android.R.color.black);
if (getIntent().getBooleanExtra(EXTRA_URLBAR_TEXT_CLICKABLE, true)) {
optionsBuilder = optionsBuilder.showPageInfoWhenTextIsClicked();
}
mUrlBarView = mBrowser.getUrlBarController().createUrlBarView(optionsBuilder.build());
// The background of the top-view must be opaque, otherwise it bleeds through to the
// cc::Layer that mirrors the contents of the top-view.
......
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