Commit 514a6aaf authored by bsheedy's avatar bsheedy Committed by Commit Bot

Add additional VR browser modal dialog render tests

Adds render tests for JavaScript confirm and prompt dialogs in the VR
browser.

Additionally, cleans the test file up a bit and adds the golden image
directory as a data dependency so that the tests will actually fail on
a mismatch instead of constantly producing new golden images.

Bug: 810847
Change-Id: I6e4ea25cf6fb84f73ed3a7d90fb02eb5adb9e783
Reviewed-on: https://chromium-review.googlesource.com/1174990Reviewed-by: default avatarAmirhossein Simjour <asimjour@chromium.org>
Commit-Queue: Brian Sheedy <bsheedy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#583279}
parent 93f4eeab
...@@ -804,6 +804,7 @@ if (enable_vr || (enable_arcore && package_arcore)) { ...@@ -804,6 +804,7 @@ if (enable_vr || (enable_arcore && package_arcore)) {
data = [ data = [
"//chrome/android/shared_preference_files/test/", "//chrome/android/shared_preference_files/test/",
"//components/test/data/js_dialogs/render_tests/",
"//third_party/gvr-android-sdk/test-apks/", "//third_party/gvr-android-sdk/test-apks/",
] ]
} }
......
...@@ -19,7 +19,6 @@ import org.chromium.base.ThreadUtils; ...@@ -19,7 +19,6 @@ import org.chromium.base.ThreadUtils;
import org.chromium.base.test.util.CommandLineFlags; import org.chromium.base.test.util.CommandLineFlags;
import org.chromium.base.test.util.Feature; import org.chromium.base.test.util.Feature;
import org.chromium.base.test.util.Restriction; import org.chromium.base.test.util.Restriction;
import org.chromium.base.test.util.UrlUtils;
import org.chromium.chrome.browser.ChromeSwitches; import org.chromium.chrome.browser.ChromeSwitches;
import org.chromium.chrome.browser.ChromeTabbedActivity; import org.chromium.chrome.browser.ChromeTabbedActivity;
import org.chromium.chrome.browser.jsdialog.JavascriptTabModalDialog; import org.chromium.chrome.browser.jsdialog.JavascriptTabModalDialog;
...@@ -32,14 +31,15 @@ import org.chromium.content.browser.test.util.Criteria; ...@@ -32,14 +31,15 @@ import org.chromium.content.browser.test.util.Criteria;
import org.chromium.content.browser.test.util.CriteriaHelper; import org.chromium.content.browser.test.util.CriteriaHelper;
import org.chromium.content.browser.test.util.JavaScriptUtils; import org.chromium.content.browser.test.util.JavaScriptUtils;
import java.io.IOException;
import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeoutException;
/** /**
* Test JavaScript modal dialogs in VR. * Test JavaScript modal dialogs in VR.
*/ */
@RunWith(ChromeJUnit4ClassRunner.class) @RunWith(ChromeJUnit4ClassRunner.class)
@CommandLineFlags.Add({ChromeSwitches.DISABLE_FIRST_RUN_EXPERIENCE}) @CommandLineFlags.Add({ChromeSwitches.DISABLE_FIRST_RUN_EXPERIENCE})
@Restriction(RESTRICTION_TYPE_VIEWER_DAYDREAM)
public class VrBrowserJavaScriptModalDialogTest { public class VrBrowserJavaScriptModalDialogTest {
@Rule @Rule
public ChromeTabbedActivityVrTestRule mActivityTestRule = new ChromeTabbedActivityVrTestRule(); public ChromeTabbedActivityVrTestRule mActivityTestRule = new ChromeTabbedActivityVrTestRule();
...@@ -48,9 +48,6 @@ public class VrBrowserJavaScriptModalDialogTest { ...@@ -48,9 +48,6 @@ public class VrBrowserJavaScriptModalDialogTest {
public RenderTestRule mRenderTestRule = public RenderTestRule mRenderTestRule =
new RenderTestRule("components/test/data/js_dialogs/render_tests"); new RenderTestRule("components/test/data/js_dialogs/render_tests");
private static final String EMPTY_PAGE = UrlUtils.encodeHtmlDataUri(
"<html><title>Modal Dialog Test</title><p>Testcase.</p></title></html>");
private ChromeTabbedActivity mActivity; private ChromeTabbedActivity mActivity;
@Before @Before
...@@ -63,20 +60,43 @@ public class VrBrowserJavaScriptModalDialogTest { ...@@ -63,20 +60,43 @@ public class VrBrowserJavaScriptModalDialogTest {
*/ */
@Test @Test
@MediumTest @MediumTest
@Restriction(RESTRICTION_TYPE_VIEWER_DAYDREAM)
@Feature({"Browser", "RenderTest"}) @Feature({"Browser", "RenderTest"})
public void testAlertModalDialog() public void testAlertModalDialog() throws ExecutionException, IOException {
throws InterruptedException, TimeoutException, ExecutionException, Throwable { testModalDialogImpl("js_modal_view_vr_alert", "alert('Hello Android!')");
}
/**
* Verifies modal confirm-dialog appearance and that it looks as it is expected.
*/
@Test
@MediumTest
@Feature({"Browser", "RenderTest"})
public void testConfirmModalDialog() throws ExecutionException, IOException {
testModalDialogImpl("js_modal_view_vr_confirm", "confirm('Deny?')");
}
/**
* Verifies modal prompt-dialog appearance and that it looks as it is expected.
*/
@Test
@MediumTest
@Feature({"Browser", "RenderTest"})
public void testPromptModalDialog() throws ExecutionException, IOException {
testModalDialogImpl(
"js_modal_view_vr_prompt", "prompt('Is the tree closed?', 'Hopefully not')");
}
private void testModalDialogImpl(String name, String js)
throws ExecutionException, IOException {
VrBrowserTransitionUtils.forceEnterVrBrowserOrFail(POLL_TIMEOUT_LONG_MS); VrBrowserTransitionUtils.forceEnterVrBrowserOrFail(POLL_TIMEOUT_LONG_MS);
executeJavaScriptAndWaitForDialog("alert('Hello Android!')"); executeJavaScriptAndWaitForDialog(js);
JavascriptTabModalDialog jsDialog = getCurrentDialog(); JavascriptTabModalDialog jsDialog = getCurrentDialog();
Assert.assertNotNull("No dialog showing.", jsDialog); Assert.assertNotNull("No dialog showing.", jsDialog);
Assert.assertEquals(NativeUiUtils.getVrViewContainer().getChildCount(), 1); Assert.assertEquals(NativeUiUtils.getVrViewContainer().getChildCount(), 1);
mRenderTestRule.render( mRenderTestRule.render(NativeUiUtils.getVrViewContainer().getChildAt(0), name);
NativeUiUtils.getVrViewContainer().getChildAt(0), "js_modal_view_vr");
} }
/** /**
......
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