OLD | NEW |
---|---|
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 #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.
| |
26 #include "chrome/browser/ui/views/location_bar/zoom_bubble_view.h" | |
27 #endif | |
25 #include "chrome/common/chrome_content_client.h" | 28 #include "chrome/common/chrome_content_client.h" |
26 #include "chrome/common/chrome_paths.h" | 29 #include "chrome/common/chrome_paths.h" |
27 #include "chrome/common/chrome_switches.h" | 30 #include "chrome/common/chrome_switches.h" |
28 #include "chrome/test/base/ui_test_utils.h" | 31 #include "chrome/test/base/ui_test_utils.h" |
32 #include "components/ui/zoom/page_zoom.h" | |
33 #include "components/ui/zoom/zoom_controller.h" | |
34 #include "components/ui/zoom/zoom_test_utils.h" | |
29 #include "content/public/browser/browser_plugin_guest_manager.h" | 35 #include "content/public/browser/browser_plugin_guest_manager.h" |
30 #include "content/public/browser/download_item.h" | 36 #include "content/public/browser/download_item.h" |
31 #include "content/public/browser/download_manager.h" | 37 #include "content/public/browser/download_manager.h" |
32 #include "content/public/browser/notification_observer.h" | 38 #include "content/public/browser/notification_observer.h" |
33 #include "content/public/browser/notification_registrar.h" | 39 #include "content/public/browser/notification_registrar.h" |
34 #include "content/public/browser/plugin_service.h" | 40 #include "content/public/browser/plugin_service.h" |
35 #include "content/public/browser/render_process_host.h" | 41 #include "content/public/browser/render_process_host.h" |
42 #include "content/public/browser/render_view_host.h" | |
43 #include "content/public/browser/render_widget_host.h" | |
36 #include "content/public/browser/web_contents.h" | 44 #include "content/public/browser/web_contents.h" |
37 #include "content/public/test/browser_test_utils.h" | 45 #include "content/public/test/browser_test_utils.h" |
38 #include "extensions/browser/extension_registry.h" | 46 #include "extensions/browser/extension_registry.h" |
39 #include "extensions/common/manifest_handlers/mime_types_handler.h" | 47 #include "extensions/common/manifest_handlers/mime_types_handler.h" |
40 #include "extensions/test/result_catcher.h" | 48 #include "extensions/test/result_catcher.h" |
41 #include "net/test/embedded_test_server/embedded_test_server.h" | 49 #include "net/test/embedded_test_server/embedded_test_server.h" |
42 #include "ui/base/resource/resource_bundle.h" | 50 #include "ui/base/resource/resource_bundle.h" |
43 #include "url/gurl.h" | 51 #include "url/gurl.h" |
44 | 52 |
45 const int kNumberLoadTestParts = 10; | 53 const int kNumberLoadTestParts = 10; |
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
405 GURL unfiltered_valid_link_url(valid_link_url); | 413 GURL unfiltered_valid_link_url(valid_link_url); |
406 content::RenderProcessHost* rph = guest_contents->GetRenderProcessHost(); | 414 content::RenderProcessHost* rph = guest_contents->GetRenderProcessHost(); |
407 rph->FilterURL(true, &valid_link_url); | 415 rph->FilterURL(true, &valid_link_url); |
408 rph->FilterURL(true, &invalid_link_url); | 416 rph->FilterURL(true, &invalid_link_url); |
409 | 417 |
410 // Invalid link URLs should be changed to "about:blank" when filtered. | 418 // Invalid link URLs should be changed to "about:blank" when filtered. |
411 EXPECT_EQ(unfiltered_valid_link_url, valid_link_url); | 419 EXPECT_EQ(unfiltered_valid_link_url, valid_link_url); |
412 EXPECT_EQ(GURL("about:blank"), invalid_link_url); | 420 EXPECT_EQ(GURL("about:blank"), invalid_link_url); |
413 } | 421 } |
414 | 422 |
423 IN_PROC_BROWSER_TEST_F(PDFExtensionTest, PdfZoomWithoutBubble) { | |
424 using namespace ui_zoom; | |
425 | |
426 GURL test_pdf_url(embedded_test_server()->GetURL("/pdf/test.pdf")); | |
427 content::WebContents* guest_contents = LoadPdfGetGuestContents(test_pdf_url); | |
428 ASSERT_TRUE(guest_contents); | |
429 content::WebContents* web_contents = | |
430 browser()->tab_strip_model()->GetActiveWebContents(); | |
431 | |
432 // The PDF viewer always starts at default zoom, which for tests is 100% or | |
433 // zoom level 0.0. Here we look at the presets to find the next zoom level | |
434 // above 0. Ideally we should look at the zoom levels from the PDF viewer | |
435 // javascript, but we assume they'll always match the browser presets, which | |
436 // are easier to access. | |
437 std::vector<double> preset_zoom_levels = PageZoom::PresetZoomLevels(0.0); | |
438 std::vector<double>::iterator it = | |
439 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.
| |
440 ASSERT_TRUE(it != preset_zoom_levels.end()); | |
441 it++; | |
442 ASSERT_TRUE(it != preset_zoom_levels.end()); | |
443 double new_zoom_level = *it; | |
444 | |
445 auto zoom_controller = ZoomController::FromWebContents(web_contents); | |
446 // We expect a ZoomChangedEvent with can_show_bubble == false if the PDF | |
447 // extension behaviour is properly picked up. The test times out otherwise. | |
448 ZoomChangedWatcher watcher(zoom_controller, | |
449 ZoomController::ZoomChangedEventData( | |
450 web_contents, 0.f, new_zoom_level, | |
451 ZoomController::ZOOM_MODE_MANUAL, false)); | |
452 | |
453 // Zoom PDF via script. | |
454 #if !defined(OS_MACOSX) | |
455 EXPECT_EQ(nullptr, ZoomBubbleView::GetZoomBubble()); | |
456 #endif | |
457 ASSERT_TRUE( | |
458 content::ExecuteScript(guest_contents, "viewer.viewport.zoomIn();")); | |
459 | |
460 watcher.Wait(); | |
461 #if !defined(OS_MACOSX) | |
462 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
| |
463 #endif | |
464 } | |
465 | |
415 class MaterialPDFExtensionTest : public PDFExtensionTest { | 466 class MaterialPDFExtensionTest : public PDFExtensionTest { |
416 void SetUpCommandLine(base::CommandLine* command_line) override { | 467 void SetUpCommandLine(base::CommandLine* command_line) override { |
417 command_line->AppendSwitch(switches::kEnablePdfMaterialUI); | 468 command_line->AppendSwitch(switches::kEnablePdfMaterialUI); |
418 } | 469 } |
419 }; | 470 }; |
420 | 471 |
421 IN_PROC_BROWSER_TEST_F(MaterialPDFExtensionTest, Basic) { | 472 IN_PROC_BROWSER_TEST_F(MaterialPDFExtensionTest, Basic) { |
422 RunTestsInFile("basic_test_material.js", "test.pdf"); | 473 RunTestsInFile("basic_test_material.js", "test.pdf"); |
423 } | 474 } |
424 | 475 |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
460 RunTestsInFile("title_test.js", "test-title.pdf"); | 511 RunTestsInFile("title_test.js", "test-title.pdf"); |
461 } | 512 } |
462 | 513 |
463 IN_PROC_BROWSER_TEST_F(MaterialPDFExtensionTest, WhitespaceTitle) { | 514 IN_PROC_BROWSER_TEST_F(MaterialPDFExtensionTest, WhitespaceTitle) { |
464 RunTestsInFile("whitespace_title_test.js", "test-whitespace-title.pdf"); | 515 RunTestsInFile("whitespace_title_test.js", "test-whitespace-title.pdf"); |
465 } | 516 } |
466 | 517 |
467 IN_PROC_BROWSER_TEST_F(MaterialPDFExtensionTest, PageChange) { | 518 IN_PROC_BROWSER_TEST_F(MaterialPDFExtensionTest, PageChange) { |
468 RunTestsInFile("page_change_test.js", "test-bookmarks.pdf"); | 519 RunTestsInFile("page_change_test.js", "test-bookmarks.pdf"); |
469 } | 520 } |
OLD | NEW |