Chromium Code Reviews| 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 1aebcdec0c5ed501767ab4e207bf383b23168f26..4d7e83d4ddbff0a20bb58b818c86ae005170fda9 100644 |
| --- a/chrome/browser/pdf/pdf_extension_test.cc |
| +++ b/chrome/browser/pdf/pdf_extension_test.cc |
| @@ -22,10 +22,16 @@ |
| #include "chrome/browser/profiles/profile.h" |
| #include "chrome/browser/ui/browser.h" |
| #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| +#if !defined(OS_MACOSX) |
|
Lei Zhang
2015/10/23 18:14:32
should this be TOOLKIT_VIEWS, since there exists M
Lei Zhang
2015/10/23 18:14:32
platform-specific #includes go in a separate secti
wjmaclean
2015/10/29 15:33:36
Hmm, when I try using TOOLKIT_VIEWS, I still seem
wjmaclean
2015/10/29 15:33:36
Done.
|
| +#include "chrome/browser/ui/views/location_bar/zoom_bubble_view.h" |
| +#endif |
| #include "chrome/common/chrome_content_client.h" |
| #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/zoom_controller.h" |
| +#include "components/ui/zoom/zoom_test_utils.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 +39,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" |
| @@ -412,6 +420,49 @@ IN_PROC_BROWSER_TEST_F(PDFExtensionTest, LinkPermissions) { |
| EXPECT_EQ(GURL("about:blank"), invalid_link_url); |
| } |
| +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 = |
| + find(preset_zoom_levels.begin(), preset_zoom_levels.end(), 0.0); |
|
Lei Zhang
2015/10/23 18:14:32
std::find?
wjmaclean
2015/10/29 15:33:36
Done.
|
| + 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(OS_MACOSX) |
| + EXPECT_EQ(nullptr, ZoomBubbleView::GetZoomBubble()); |
| +#endif |
| + ASSERT_TRUE( |
| + content::ExecuteScript(guest_contents, "viewer.viewport.zoomIn();")); |
| + |
| + watcher.Wait(); |
| +#if !defined(OS_MACOSX) |
| + EXPECT_EQ(nullptr, ZoomBubbleView::GetZoomBubble()); |
|
Ken Rockot(use gerrit already)
2015/10/23 17:58:43
Sorry, I don't know much about zoom or Mac; is the
wjmaclean
2015/10/29 15:33:36
This test *does* have a testable on Mac; the can_s
|
| +#endif |
| +} |
| + |
| class MaterialPDFExtensionTest : public PDFExtensionTest { |
| void SetUpCommandLine(base::CommandLine* command_line) override { |
| command_line->AppendSwitch(switches::kEnablePdfMaterialUI); |