Commit 74e8e314 authored by rbpotter's avatar rbpotter Committed by Commit Bot

PDF Viewer Update: Enable zoom tests in both flag states

Enable the 5 zoom related tests that had been disabled with the update
enabled in both flag states, as the underlying Blink issue has now
been resolved.

Make a few adjustments to the ZoomWithoutBubble test, as recent updates
to the new UI had caused the test to fail with the update flag on.

Bug: 1137905
Change-Id: Iead2dfb1f0dc3eab30553bc8b1e75a353049b5c8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2538367Reviewed-by: default avatardpapad <dpapad@chromium.org>
Commit-Queue: Rebekah Potter <rbpotter@chromium.org>
Cr-Commit-Position: refs/heads/master@{#827949}
parent 706526c7
...@@ -1372,19 +1372,18 @@ IN_PROC_BROWSER_TEST_P(PDFExtensionTestWithParam, TabTitleWithEmbeddedPdf) { ...@@ -1372,19 +1372,18 @@ IN_PROC_BROWSER_TEST_P(PDFExtensionTestWithParam, TabTitleWithEmbeddedPdf) {
#else #else
#define MAYBE_PdfZoomWithoutBubble PdfZoomWithoutBubble #define MAYBE_PdfZoomWithoutBubble PdfZoomWithoutBubble
#endif #endif
IN_PROC_BROWSER_TEST_F(PDFExtensionTest, MAYBE_PdfZoomWithoutBubble) { IN_PROC_BROWSER_TEST_P(PDFExtensionTestWithParam, MAYBE_PdfZoomWithoutBubble) {
GURL test_pdf_url(embedded_test_server()->GetURL("/pdf/test.pdf")); GURL test_pdf_url(embedded_test_server()->GetURL("/pdf/test.pdf"));
WebContents* guest_contents = LoadPdfGetGuestContents(test_pdf_url); WebContents* guest_contents = LoadPdfGetGuestContents(test_pdf_url);
ASSERT_TRUE(guest_contents); ASSERT_TRUE(guest_contents);
WebContents* web_contents = GetActiveWebContents(); WebContents* web_contents = GetActiveWebContents();
// The PDF viewer, when the update is disabled, always starts at default zoom, // Here we look at the presets to find the next zoom level above 0. Ideally
// which for tests is 100% or zoom level 0.0. Here we look at the presets to // we should look at the zoom levels from the PDF viewer javascript, but we
// find the next zoom level above 0. Ideally we should look at the zoom levels // assume they'll always match the browser presets, which are easier to
// from the PDF viewer javascript, but we assume they'll always match the // access. In the script below, we zoom to 100% (0), then wait for this to be
// browser presets, which are easier to access. When the update is enabled, // picked up by the browser zoom, then zoom to the next zoom level. This
// the presence of the sidenav causes the default zoom to be just under 90%. // ensures the test passes regardless of the initial default zoom level.
// In this case, we add 2 additional zoom calls to match the final result.
std::vector<double> preset_zoom_levels = zoom::PageZoom::PresetZoomLevels(0); std::vector<double> preset_zoom_levels = zoom::PageZoom::PresetZoomLevels(0);
auto it = std::find(preset_zoom_levels.begin(), preset_zoom_levels.end(), 0); auto it = std::find(preset_zoom_levels.begin(), preset_zoom_levels.end(), 0);
ASSERT_TRUE(it != preset_zoom_levels.end()); ASSERT_TRUE(it != preset_zoom_levels.end());
...@@ -1404,19 +1403,13 @@ IN_PROC_BROWSER_TEST_F(PDFExtensionTest, MAYBE_PdfZoomWithoutBubble) { ...@@ -1404,19 +1403,13 @@ IN_PROC_BROWSER_TEST_F(PDFExtensionTest, MAYBE_PdfZoomWithoutBubble) {
#if defined(TOOLKIT_VIEWS) && !defined(OS_MAC) #if defined(TOOLKIT_VIEWS) && !defined(OS_MAC)
EXPECT_EQ(nullptr, ZoomBubbleView::GetZoomBubble()); EXPECT_EQ(nullptr, ZoomBubbleView::GetZoomBubble());
#endif #endif
ASSERT_TRUE( ASSERT_TRUE(content::ExecuteScript(guest_contents,
content::ExecuteScript(guest_contents, "viewer.viewport.zoomIn();")); "while (viewer.viewport.getZoom() < 1) {"
" viewer.viewport.zoomIn();"
// Two extra calls - the first zoomIn() takes zoom to 90%, the second to 100%, "}"
// and the third goes to the next zoom level above 100%, which is the desired "setTimeout(() => {"
// result for this test. " viewer.viewport.zoomIn();"
ASSERT_TRUE( "}, 1);"));
content::ExecuteScript(guest_contents,
"if (document.documentElement.hasAttribute("
" 'pdf-viewer-update-enabled')) {"
" viewer.viewport.zoomIn();"
" viewer.viewport.zoomIn();"
"}"));
watcher.Wait(); watcher.Wait();
#if defined(TOOLKIT_VIEWS) && !defined(OS_MAC) #if defined(TOOLKIT_VIEWS) && !defined(OS_MAC)
...@@ -2428,7 +2421,8 @@ void EnsureCustomPinchZoomInvoked(WebContents* guest_contents, ...@@ -2428,7 +2421,8 @@ void EnsureCustomPinchZoomInvoked(WebContents* guest_contents,
} }
// Ensure that touchpad pinch events are handled by the PDF viewer. // Ensure that touchpad pinch events are handled by the PDF viewer.
IN_PROC_BROWSER_TEST_F(PDFExtensionTest, TouchpadPinchInvokesCustomZoom) { IN_PROC_BROWSER_TEST_P(PDFExtensionTestWithParam,
TouchpadPinchInvokesCustomZoom) {
GURL test_pdf_url(embedded_test_server()->GetURL("/pdf/test.pdf")); GURL test_pdf_url(embedded_test_server()->GetURL("/pdf/test.pdf"));
WebContents* guest_contents = LoadPdfGetGuestContents(test_pdf_url); WebContents* guest_contents = LoadPdfGetGuestContents(test_pdf_url);
ASSERT_TRUE(guest_contents); ASSERT_TRUE(guest_contents);
...@@ -2450,7 +2444,7 @@ IN_PROC_BROWSER_TEST_F(PDFExtensionTest, TouchpadPinchInvokesCustomZoom) { ...@@ -2450,7 +2444,7 @@ IN_PROC_BROWSER_TEST_F(PDFExtensionTest, TouchpadPinchInvokesCustomZoom) {
#if !defined(OS_MAC) #if !defined(OS_MAC)
// Ensure that ctrl-wheel events are handled by the PDF viewer. // Ensure that ctrl-wheel events are handled by the PDF viewer.
IN_PROC_BROWSER_TEST_F(PDFExtensionTest, CtrlWheelInvokesCustomZoom) { IN_PROC_BROWSER_TEST_P(PDFExtensionTestWithParam, CtrlWheelInvokesCustomZoom) {
GURL test_pdf_url(embedded_test_server()->GetURL("/pdf/test.pdf")); GURL test_pdf_url(embedded_test_server()->GetURL("/pdf/test.pdf"));
WebContents* guest_contents = LoadPdfGetGuestContents(test_pdf_url); WebContents* guest_contents = LoadPdfGetGuestContents(test_pdf_url);
ASSERT_TRUE(guest_contents); ASSERT_TRUE(guest_contents);
...@@ -2478,7 +2472,7 @@ IN_PROC_BROWSER_TEST_F(PDFExtensionTest, CtrlWheelInvokesCustomZoom) { ...@@ -2478,7 +2472,7 @@ IN_PROC_BROWSER_TEST_F(PDFExtensionTest, CtrlWheelInvokesCustomZoom) {
#define MAYBE_TouchscreenPinchInvokesCustomZoom \ #define MAYBE_TouchscreenPinchInvokesCustomZoom \
TouchscreenPinchInvokesCustomZoom TouchscreenPinchInvokesCustomZoom
#endif #endif
IN_PROC_BROWSER_TEST_F(PDFExtensionTest, IN_PROC_BROWSER_TEST_P(PDFExtensionTestWithParam,
MAYBE_TouchscreenPinchInvokesCustomZoom) { MAYBE_TouchscreenPinchInvokesCustomZoom) {
GURL test_pdf_url(embedded_test_server()->GetURL("/pdf/test.pdf")); GURL test_pdf_url(embedded_test_server()->GetURL("/pdf/test.pdf"));
WebContents* guest_contents = LoadPdfGetGuestContents(test_pdf_url); WebContents* guest_contents = LoadPdfGetGuestContents(test_pdf_url);
......
...@@ -18,14 +18,6 @@ const tests = [ ...@@ -18,14 +18,6 @@ const tests = [
// Verify that the initial zoom is less than or equal to 100%. // Verify that the initial zoom is less than or equal to 100%.
chrome.test.assertTrue(viewer.viewport.getZoom() <= 1); chrome.test.assertTrue(viewer.viewport.getZoom() <= 1);
// TODO (https://crbug.com/1120279): Currently, calling setZoom() on the
// viewport with the new UI enabled triggers a crash in Blink. Fix this
// issue and remove the lines below.
if (document.documentElement.hasAttribute('pdf-viewer-update-enabled')) {
chrome.test.succeed();
return;
}
viewer.viewport.setZoom(1); viewer.viewport.setZoom(1);
const sizer = viewer.shadowRoot.querySelector('#sizer'); const sizer = viewer.shadowRoot.querySelector('#sizer');
chrome.test.assertEq(826, sizer.offsetWidth); chrome.test.assertEq(826, sizer.offsetWidth);
......
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