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

Side by Side 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, 1 month 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <vector> 5 #include <vector>
6 6
7 #include "base/base_paths.h" 7 #include "base/base_paths.h"
8 #include "base/files/file_enumerator.h" 8 #include "base/files/file_enumerator.h"
9 #include "base/files/file_util.h" 9 #include "base/files/file_util.h"
10 #include "base/hash.h" 10 #include "base/hash.h"
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/memory/ref_counted.h" 12 #include "base/memory/ref_counted.h"
13 #include "base/path_service.h" 13 #include "base/path_service.h"
14 #include "base/strings/utf_string_conversions.h" 14 #include "base/strings/utf_string_conversions.h"
15 #include "chrome/browser/chrome_notification_types.h" 15 #include "chrome/browser/chrome_notification_types.h"
16 #include "chrome/browser/extensions/component_loader.h" 16 #include "chrome/browser/extensions/component_loader.h"
17 #include "chrome/browser/extensions/extension_apitest.h" 17 #include "chrome/browser/extensions/extension_apitest.h"
18 #include "chrome/browser/extensions/extension_service.h" 18 #include "chrome/browser/extensions/extension_service.h"
19 #include "chrome/browser/pdf/pdf_extension_test_util.h" 19 #include "chrome/browser/pdf/pdf_extension_test_util.h"
20 #include "chrome/browser/pdf/pdf_extension_util.h" 20 #include "chrome/browser/pdf/pdf_extension_util.h"
21 #include "chrome/browser/plugins/plugin_prefs.h" 21 #include "chrome/browser/plugins/plugin_prefs.h"
22 #include "chrome/browser/profiles/profile.h" 22 #include "chrome/browser/profiles/profile.h"
23 #include "chrome/browser/ui/browser.h" 23 #include "chrome/browser/ui/browser.h"
24 #include "chrome/browser/ui/tabs/tab_strip_model.h" 24 #include "chrome/browser/ui/tabs/tab_strip_model.h"
25 #include "chrome/common/chrome_content_client.h" 25 #include "chrome/common/chrome_content_client.h"
26 #include "chrome/common/chrome_paths.h" 26 #include "chrome/common/chrome_paths.h"
27 #include "chrome/common/chrome_switches.h" 27 #include "chrome/common/chrome_switches.h"
28 #include "chrome/test/base/ui_test_utils.h" 28 #include "chrome/test/base/ui_test_utils.h"
29 #include "components/ui/zoom/page_zoom.h"
30 #include "components/ui/zoom/test/zoom_test_utils.h"
31 #include "components/ui/zoom/zoom_controller.h"
29 #include "content/public/browser/browser_plugin_guest_manager.h" 32 #include "content/public/browser/browser_plugin_guest_manager.h"
30 #include "content/public/browser/download_item.h" 33 #include "content/public/browser/download_item.h"
31 #include "content/public/browser/download_manager.h" 34 #include "content/public/browser/download_manager.h"
32 #include "content/public/browser/notification_observer.h" 35 #include "content/public/browser/notification_observer.h"
33 #include "content/public/browser/notification_registrar.h" 36 #include "content/public/browser/notification_registrar.h"
34 #include "content/public/browser/plugin_service.h" 37 #include "content/public/browser/plugin_service.h"
35 #include "content/public/browser/render_process_host.h" 38 #include "content/public/browser/render_process_host.h"
39 #include "content/public/browser/render_view_host.h"
40 #include "content/public/browser/render_widget_host.h"
36 #include "content/public/browser/web_contents.h" 41 #include "content/public/browser/web_contents.h"
37 #include "content/public/test/browser_test_utils.h" 42 #include "content/public/test/browser_test_utils.h"
38 #include "extensions/browser/extension_registry.h" 43 #include "extensions/browser/extension_registry.h"
39 #include "extensions/common/manifest_handlers/mime_types_handler.h" 44 #include "extensions/common/manifest_handlers/mime_types_handler.h"
40 #include "extensions/test/result_catcher.h" 45 #include "extensions/test/result_catcher.h"
41 #include "net/test/embedded_test_server/embedded_test_server.h" 46 #include "net/test/embedded_test_server/embedded_test_server.h"
42 #include "ui/base/resource/resource_bundle.h" 47 #include "ui/base/resource/resource_bundle.h"
43 #include "url/gurl.h" 48 #include "url/gurl.h"
44 49
50 #if defined(TOOLKIT_VIEWS) && !defined(OS_MACOSX)
51 #include "chrome/browser/ui/views/location_bar/zoom_bubble_view.h"
52 #endif
53
45 const int kNumberLoadTestParts = 10; 54 const int kNumberLoadTestParts = 10;
46 55
47 bool GetGuestCallback(content::WebContents** guest_out, 56 bool GetGuestCallback(content::WebContents** guest_out,
48 content::WebContents* guest) { 57 content::WebContents* guest) {
49 EXPECT_FALSE(*guest_out); 58 EXPECT_FALSE(*guest_out);
50 *guest_out = guest; 59 *guest_out = guest;
51 // Return false so that we iterate through all the guests and verify there is 60 // Return false so that we iterate through all the guests and verify there is
52 // only one. 61 // only one.
53 return false; 62 return false;
54 } 63 }
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after
443 url + 452 url +
444 "\"></body></html>"; 453 "\"></body></html>";
445 ui_test_utils::NavigateToURL(browser(), GURL(data_url)); 454 ui_test_utils::NavigateToURL(browser(), GURL(data_url));
446 content::WebContents* web_contents = 455 content::WebContents* web_contents =
447 browser()->tab_strip_model()->GetActiveWebContents(); 456 browser()->tab_strip_model()->GetActiveWebContents();
448 ASSERT_TRUE(pdf_extension_test_util::EnsurePDFHasLoaded(web_contents)); 457 ASSERT_TRUE(pdf_extension_test_util::EnsurePDFHasLoaded(web_contents));
449 EXPECT_EQ(base::ASCIIToUTF16("TabTitleWithEmbeddedPdf"), 458 EXPECT_EQ(base::ASCIIToUTF16("TabTitleWithEmbeddedPdf"),
450 web_contents->GetTitle()); 459 web_contents->GetTitle());
451 } 460 }
452 461
462 IN_PROC_BROWSER_TEST_F(PDFExtensionTest, PdfZoomWithoutBubble) {
463 using namespace ui_zoom;
464
465 GURL test_pdf_url(embedded_test_server()->GetURL("/pdf/test.pdf"));
466 content::WebContents* guest_contents = LoadPdfGetGuestContents(test_pdf_url);
467 ASSERT_TRUE(guest_contents);
468 content::WebContents* web_contents =
469 browser()->tab_strip_model()->GetActiveWebContents();
470
471 // The PDF viewer always starts at default zoom, which for tests is 100% or
472 // zoom level 0.0. Here we look at the presets to find the next zoom level
473 // above 0. Ideally we should look at the zoom levels from the PDF viewer
474 // javascript, but we assume they'll always match the browser presets, which
475 // are easier to access.
476 std::vector<double> preset_zoom_levels = PageZoom::PresetZoomLevels(0.0);
477 std::vector<double>::iterator it =
478 std::find(preset_zoom_levels.begin(), preset_zoom_levels.end(), 0.0);
479 ASSERT_TRUE(it != preset_zoom_levels.end());
480 it++;
481 ASSERT_TRUE(it != preset_zoom_levels.end());
482 double new_zoom_level = *it;
483
484 auto zoom_controller = ZoomController::FromWebContents(web_contents);
485 // We expect a ZoomChangedEvent with can_show_bubble == false if the PDF
486 // extension behaviour is properly picked up. The test times out otherwise.
487 ZoomChangedWatcher watcher(zoom_controller,
488 ZoomController::ZoomChangedEventData(
489 web_contents, 0.f, new_zoom_level,
490 ZoomController::ZOOM_MODE_MANUAL, false));
491
492 // Zoom PDF via script.
493 #if defined(TOOLKIT_VIEWS) && !defined(OS_MACOSX)
494 EXPECT_EQ(nullptr, ZoomBubbleView::GetZoomBubble());
495 #endif
496 ASSERT_TRUE(
497 content::ExecuteScript(guest_contents, "viewer.viewport.zoomIn();"));
498
499 watcher.Wait();
500 #if defined(TOOLKIT_VIEWS) && !defined(OS_MACOSX)
501 EXPECT_EQ(nullptr, ZoomBubbleView::GetZoomBubble());
502 #endif
503 }
504
453 class MaterialPDFExtensionTest : public PDFExtensionTest { 505 class MaterialPDFExtensionTest : public PDFExtensionTest {
454 void SetUpCommandLine(base::CommandLine* command_line) override { 506 void SetUpCommandLine(base::CommandLine* command_line) override {
455 command_line->AppendSwitch(switches::kEnablePdfMaterialUI); 507 command_line->AppendSwitch(switches::kEnablePdfMaterialUI);
456 } 508 }
457 }; 509 };
458 510
459 IN_PROC_BROWSER_TEST_F(MaterialPDFExtensionTest, Basic) { 511 IN_PROC_BROWSER_TEST_F(MaterialPDFExtensionTest, Basic) {
460 RunTestsInFile("basic_test_material.js", "test.pdf"); 512 RunTestsInFile("basic_test_material.js", "test.pdf");
461 } 513 }
462 514
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
498 RunTestsInFile("title_test.js", "test-title.pdf"); 550 RunTestsInFile("title_test.js", "test-title.pdf");
499 } 551 }
500 552
501 IN_PROC_BROWSER_TEST_F(MaterialPDFExtensionTest, WhitespaceTitle) { 553 IN_PROC_BROWSER_TEST_F(MaterialPDFExtensionTest, WhitespaceTitle) {
502 RunTestsInFile("whitespace_title_test.js", "test-whitespace-title.pdf"); 554 RunTestsInFile("whitespace_title_test.js", "test-whitespace-title.pdf");
503 } 555 }
504 556
505 IN_PROC_BROWSER_TEST_F(MaterialPDFExtensionTest, PageChange) { 557 IN_PROC_BROWSER_TEST_F(MaterialPDFExtensionTest, PageChange) {
506 RunTestsInFile("page_change_test.js", "test-bookmarks.pdf"); 558 RunTestsInFile("page_change_test.js", "test-bookmarks.pdf");
507 } 559 }
OLDNEW
« 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