Commit 7dbfe501 authored by Evan Stade's avatar Evan Stade Committed by Commit Bot

WebLayer: Add sanity test for Page Info UI.

Bug: none
Change-Id: I3a6df417b0bdbb105e0f22506ca764a2d328c818
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2347048Reviewed-by: default avatarMugdha Lakhani <nator@chromium.org>
Commit-Queue: Evan Stade <estade@chromium.org>
Cr-Commit-Position: refs/heads/master@{#796504}
parent 0086b1f3
...@@ -72,6 +72,7 @@ android_library("weblayer_private_java_tests") { ...@@ -72,6 +72,7 @@ android_library("weblayer_private_java_tests") {
"src/org/chromium/weblayer/test/InfoBarTest.java", "src/org/chromium/weblayer/test/InfoBarTest.java",
"src/org/chromium/weblayer/test/MediaCaptureTest.java", "src/org/chromium/weblayer/test/MediaCaptureTest.java",
"src/org/chromium/weblayer/test/NetworkChangeNotifierTest.java", "src/org/chromium/weblayer/test/NetworkChangeNotifierTest.java",
"src/org/chromium/weblayer/test/PageInfoTest.java",
"src/org/chromium/weblayer/test/PopupTest.java", "src/org/chromium/weblayer/test/PopupTest.java",
"src/org/chromium/weblayer/test/ResourceLoadingTest.java", "src/org/chromium/weblayer/test/ResourceLoadingTest.java",
"src/org/chromium/weblayer/test/TranslateTest.java", "src/org/chromium/weblayer/test/TranslateTest.java",
...@@ -87,6 +88,8 @@ android_library("weblayer_private_java_tests") { ...@@ -87,6 +88,8 @@ android_library("weblayer_private_java_tests") {
"//third_party/android_deps:android_support_v4_java", "//third_party/android_deps:android_support_v4_java",
"//third_party/android_deps:androidx_fragment_fragment_java", "//third_party/android_deps:androidx_fragment_fragment_java",
"//third_party/android_deps:androidx_test_runner_java", "//third_party/android_deps:androidx_test_runner_java",
"//third_party/android_deps:espresso_java",
"//third_party/android_sdk:android_test_base_java",
"//third_party/android_support_test_runner:rules_java", "//third_party/android_support_test_runner:rules_java",
"//third_party/android_support_test_runner:runner_java", "//third_party/android_support_test_runner:runner_java",
"//third_party/hamcrest:hamcrest_java", "//third_party/hamcrest:hamcrest_java",
......
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package org.chromium.weblayer.test;
import static androidx.test.espresso.Espresso.onView;
import static androidx.test.espresso.assertion.ViewAssertions.matches;
import static androidx.test.espresso.matcher.ViewMatchers.isDisplayed;
import static androidx.test.espresso.matcher.ViewMatchers.withText;
import android.content.Context;
import androidx.test.filters.SmallTest;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.chromium.base.StrictModeContext;
import org.chromium.content_public.browser.test.util.CriteriaHelper;
import org.chromium.content_public.browser.test.util.CriteriaNotSatisfiedException;
import org.chromium.content_public.browser.test.util.TestThreadUtils;
import org.chromium.weblayer.TestWebLayer;
import org.chromium.weblayer.shell.InstrumentationActivity;
/**
* Tests the behavior of the Page Info UI.
*/
@RunWith(WebLayerJUnit4ClassRunner.class)
public class PageInfoTest {
@Rule
public InstrumentationActivityTestRule mActivityTestRule =
new InstrumentationActivityTestRule();
@Test
@SmallTest
@MinWebLayerVersion(84)
public void testPageInfoLaunches() {
InstrumentationActivity activity = mActivityTestRule.launchShellWithUrl(
mActivityTestRule.getTestDataURL("simple_page.html"));
Context remoteContext = TestWebLayer.getRemoteContext(activity.getApplicationContext());
int buttonId = ResourceUtil.getIdentifier(remoteContext, "id/security_button");
TestThreadUtils.runOnUiThreadBlocking(() -> {
StrictModeContext ignored = StrictModeContext.allowDiskReads();
EventUtils.simulateTouchCenterOfView(activity.findViewById(buttonId));
});
CriteriaHelper.pollInstrumentationThread(() -> {
try {
onView(withText("Your connection to this site is not secure"))
.check(matches(isDisplayed()));
} catch (Error e) {
throw new CriteriaNotSatisfiedException(e.toString());
}
});
}
}
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