| Index: chrome/browser/pdf/pdf_extension_test.cc
|
| diff --git a/chrome/browser/pdf/pdf_extension_test.cc b/chrome/browser/pdf/pdf_extension_test.cc
|
| index cba4460ca0ac52fac41437393b045ba6844a91c0..8f2d0e9cdff5c0bc414ce2c0ebcaa01438480a02 100644
|
| --- a/chrome/browser/pdf/pdf_extension_test.cc
|
| +++ b/chrome/browser/pdf/pdf_extension_test.cc
|
| @@ -26,6 +26,9 @@
|
| #include "chrome/common/chrome_paths.h"
|
| #include "chrome/common/chrome_switches.h"
|
| #include "chrome/test/base/ui_test_utils.h"
|
| +#include "components/ui/zoom/page_zoom.h"
|
| +#include "components/ui/zoom/test/zoom_test_utils.h"
|
| +#include "components/ui/zoom/zoom_controller.h"
|
| #include "content/public/browser/browser_plugin_guest_manager.h"
|
| #include "content/public/browser/download_item.h"
|
| #include "content/public/browser/download_manager.h"
|
| @@ -33,6 +36,8 @@
|
| #include "content/public/browser/notification_registrar.h"
|
| #include "content/public/browser/plugin_service.h"
|
| #include "content/public/browser/render_process_host.h"
|
| +#include "content/public/browser/render_view_host.h"
|
| +#include "content/public/browser/render_widget_host.h"
|
| #include "content/public/browser/web_contents.h"
|
| #include "content/public/test/browser_test_utils.h"
|
| #include "extensions/browser/extension_registry.h"
|
| @@ -42,6 +47,10 @@
|
| #include "ui/base/resource/resource_bundle.h"
|
| #include "url/gurl.h"
|
|
|
| +#if defined(TOOLKIT_VIEWS) && !defined(OS_MACOSX)
|
| +#include "chrome/browser/ui/views/location_bar/zoom_bubble_view.h"
|
| +#endif
|
| +
|
| const int kNumberLoadTestParts = 10;
|
|
|
| bool GetGuestCallback(content::WebContents** guest_out,
|
| @@ -450,6 +459,49 @@ IN_PROC_BROWSER_TEST_F(PDFExtensionTest, TabTitleWithEmbeddedPdf) {
|
| web_contents->GetTitle());
|
| }
|
|
|
| +IN_PROC_BROWSER_TEST_F(PDFExtensionTest, PdfZoomWithoutBubble) {
|
| + using namespace ui_zoom;
|
| +
|
| + GURL test_pdf_url(embedded_test_server()->GetURL("/pdf/test.pdf"));
|
| + content::WebContents* guest_contents = LoadPdfGetGuestContents(test_pdf_url);
|
| + ASSERT_TRUE(guest_contents);
|
| + content::WebContents* web_contents =
|
| + browser()->tab_strip_model()->GetActiveWebContents();
|
| +
|
| + // The PDF viewer always starts at default zoom, which for tests is 100% or
|
| + // zoom level 0.0. Here we look at the presets to find the next zoom level
|
| + // above 0. Ideally we should look at the zoom levels from the PDF viewer
|
| + // javascript, but we assume they'll always match the browser presets, which
|
| + // are easier to access.
|
| + std::vector<double> preset_zoom_levels = PageZoom::PresetZoomLevels(0.0);
|
| + std::vector<double>::iterator it =
|
| + std::find(preset_zoom_levels.begin(), preset_zoom_levels.end(), 0.0);
|
| + ASSERT_TRUE(it != preset_zoom_levels.end());
|
| + it++;
|
| + ASSERT_TRUE(it != preset_zoom_levels.end());
|
| + double new_zoom_level = *it;
|
| +
|
| + auto zoom_controller = ZoomController::FromWebContents(web_contents);
|
| + // We expect a ZoomChangedEvent with can_show_bubble == false if the PDF
|
| + // extension behaviour is properly picked up. The test times out otherwise.
|
| + ZoomChangedWatcher watcher(zoom_controller,
|
| + ZoomController::ZoomChangedEventData(
|
| + web_contents, 0.f, new_zoom_level,
|
| + ZoomController::ZOOM_MODE_MANUAL, false));
|
| +
|
| + // Zoom PDF via script.
|
| +#if defined(TOOLKIT_VIEWS) && !defined(OS_MACOSX)
|
| + EXPECT_EQ(nullptr, ZoomBubbleView::GetZoomBubble());
|
| +#endif
|
| + ASSERT_TRUE(
|
| + content::ExecuteScript(guest_contents, "viewer.viewport.zoomIn();"));
|
| +
|
| + watcher.Wait();
|
| +#if defined(TOOLKIT_VIEWS) && !defined(OS_MACOSX)
|
| + EXPECT_EQ(nullptr, ZoomBubbleView::GetZoomBubble());
|
| +#endif
|
| +}
|
| +
|
| class MaterialPDFExtensionTest : public PDFExtensionTest {
|
| void SetUpCommandLine(base::CommandLine* command_line) override {
|
| command_line->AppendSwitch(switches::kEnablePdfMaterialUI);
|
|
|