Commit 5a665c1c authored by rbpotter's avatar rbpotter Committed by Commit Bot

PDFViewerUpdate: Update remaining two tests

Update ContextMenuOpensFromTouchSelectionMenu to pass with both flag
states, and run it as a parameterized test.

Also update PdfZoomWithoutBubble to pass with both states in builds with
DCHECKs off, but do not enable this test with the PDFViewerUpdate flag
since there is a Blink DCHECK triggered by this test (see
crbug.com/1048876).

Bug: 1120279
Change-Id: I73fc8ebe083aad410c39aeeb26266424192f2f8e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2400239Reviewed-by: default avatarLei Zhang <thestig@chromium.org>
Commit-Queue: Rebekah Potter <rbpotter@chromium.org>
Cr-Commit-Position: refs/heads/master@{#806059}
parent 17ce9dc5
...@@ -1336,11 +1336,13 @@ IN_PROC_BROWSER_TEST_F(PDFExtensionTest, MAYBE_PdfZoomWithoutBubble) { ...@@ -1336,11 +1336,13 @@ IN_PROC_BROWSER_TEST_F(PDFExtensionTest, MAYBE_PdfZoomWithoutBubble) {
ASSERT_TRUE(guest_contents); ASSERT_TRUE(guest_contents);
WebContents* web_contents = GetActiveWebContents(); WebContents* web_contents = GetActiveWebContents();
// The PDF viewer always starts at default zoom, which for tests is 100% or // The PDF viewer, when the update is disabled, always starts at default zoom,
// zoom level 0.0. Here we look at the presets to find the next zoom level // which for tests is 100% or zoom level 0.0. Here we look at the presets to
// above 0. Ideally we should look at the zoom levels from the PDF viewer // find the next zoom level above 0. Ideally we should look at the zoom levels
// javascript, but we assume they'll always match the browser presets, which // from the PDF viewer javascript, but we assume they'll always match the
// are easier to access. // browser presets, which are easier to access. When the update is enabled,
// the presence of the sidenav causes the default zoom to be just under 90%.
// 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());
...@@ -1363,6 +1365,17 @@ IN_PROC_BROWSER_TEST_F(PDFExtensionTest, MAYBE_PdfZoomWithoutBubble) { ...@@ -1363,6 +1365,17 @@ IN_PROC_BROWSER_TEST_F(PDFExtensionTest, MAYBE_PdfZoomWithoutBubble) {
ASSERT_TRUE( ASSERT_TRUE(
content::ExecuteScript(guest_contents, "viewer.viewport.zoomIn();")); content::ExecuteScript(guest_contents, "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
// result for this test.
ASSERT_TRUE(
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)
EXPECT_EQ(nullptr, ZoomBubbleView::GetZoomBubble()); EXPECT_EQ(nullptr, ZoomBubbleView::GetZoomBubble());
...@@ -2560,7 +2573,7 @@ INSTANTIATE_TEST_SUITE_P(/* no prefix */, ...@@ -2560,7 +2573,7 @@ INSTANTIATE_TEST_SUITE_P(/* no prefix */,
#if defined(TOOLKIT_VIEWS) && defined(USE_AURA) #if defined(TOOLKIT_VIEWS) && defined(USE_AURA)
// On text selection, a touch selection menu should pop up. On clicking ellipsis // On text selection, a touch selection menu should pop up. On clicking ellipsis
// icon on the menu, the context menu should open up. // icon on the menu, the context menu should open up.
IN_PROC_BROWSER_TEST_F(PDFExtensionTest, IN_PROC_BROWSER_TEST_P(PDFExtensionTestWithParam,
ContextMenuOpensFromTouchSelectionMenu) { ContextMenuOpensFromTouchSelectionMenu) {
const GURL url = embedded_test_server()->GetURL("/pdf/text_large.pdf"); const GURL url = embedded_test_server()->GetURL("/pdf/text_large.pdf");
WebContents* const guest_contents = LoadPdfGetGuestContents(url); WebContents* const guest_contents = LoadPdfGetGuestContents(url);
...@@ -2568,7 +2581,7 @@ IN_PROC_BROWSER_TEST_F(PDFExtensionTest, ...@@ -2568,7 +2581,7 @@ IN_PROC_BROWSER_TEST_F(PDFExtensionTest,
views::NamedWidgetShownWaiter waiter(views::test::AnyWidgetTestPasskey{}, views::NamedWidgetShownWaiter waiter(views::test::AnyWidgetTestPasskey{},
"TouchSelectionMenuViews"); "TouchSelectionMenuViews");
gfx::Point text_selection_position(10, 10); gfx::Point text_selection_position(12, 12);
ConvertPageCoordToScreenCoord(guest_contents, &text_selection_position); ConvertPageCoordToScreenCoord(guest_contents, &text_selection_position);
content::SimulateTouchEventAt(GetActiveWebContents(), ui::ET_TOUCH_PRESSED, content::SimulateTouchEventAt(GetActiveWebContents(), ui::ET_TOUCH_PRESSED,
text_selection_position); text_selection_position);
......
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