Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1799)

Unified Diff: chrome/browser/pdf/pdf_extension_test.cc

Issue 1414643005: Disable zoom bubble for PDF extension. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Test rebuilding patch from .diff file. Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/pdf/DEPS ('k') | chrome/browser/ui/zoom/zoom_controller_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
« no previous file with comments | « chrome/browser/pdf/DEPS ('k') | chrome/browser/ui/zoom/zoom_controller_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698