OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "base/file_util.h" | 5 #include "base/file_util.h" |
6 #include "base/path_service.h" | 6 #include "base/path_service.h" |
7 #include "base/string_number_conversions.h" | 7 #include "base/string_number_conversions.h" |
8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
10 #include "chrome/browser/ui/browser.h" | 10 #include "chrome/browser/ui/browser.h" |
11 #include "chrome/browser/ui/browser_window.h" | 11 #include "chrome/browser/ui/browser_window.h" |
12 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 12 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
13 #include "chrome/browser/ui/window_sizer.h" | |
14 #include "chrome/common/chrome_notification_types.h" | 13 #include "chrome/common/chrome_notification_types.h" |
15 #include "chrome/common/chrome_paths.h" | 14 #include "chrome/common/chrome_paths.h" |
16 #include "chrome/test/base/in_process_browser_test.h" | 15 #include "chrome/test/base/in_process_browser_test.h" |
17 #include "chrome/test/base/ui_test_utils.h" | 16 #include "chrome/test/base/ui_test_utils.h" |
18 #include "content/browser/renderer_host/render_view_host.h" | 17 #include "content/browser/renderer_host/render_view_host.h" |
19 #include "content/browser/tab_contents/tab_contents.h" | 18 #include "content/browser/tab_contents/tab_contents.h" |
20 #include "content/public/browser/notification_observer.h" | 19 #include "content/public/browser/notification_observer.h" |
21 #include "net/test/test_server.h" | 20 #include "net/test/test_server.h" |
22 #include "ui/base/clipboard/clipboard.h" | 21 #include "ui/base/clipboard/clipboard.h" |
23 #include "ui/gfx/codec/png_codec.h" | 22 #include "ui/gfx/codec/png_codec.h" |
| 23 #include "ui/gfx/screen.h" |
24 | 24 |
25 namespace { | 25 namespace { |
26 | 26 |
27 // Include things like browser frame and scrollbar and make sure we're bigger | 27 // Include things like browser frame and scrollbar and make sure we're bigger |
28 // than the test pdf document. | 28 // than the test pdf document. |
29 static const int kBrowserWidth = 1000; | 29 static const int kBrowserWidth = 1000; |
30 static const int kBrowserHeight = 600; | 30 static const int kBrowserHeight = 600; |
31 | 31 |
32 class PDFBrowserTest : public InProcessBrowserTest, | 32 class PDFBrowserTest : public InProcessBrowserTest, |
33 public content::NotificationObserver { | 33 public content::NotificationObserver { |
(...skipping 21 matching lines...) Expand all Loading... |
55 return FilePath(FilePath::kCurrentDirectory).AppendASCII(".."). | 55 return FilePath(FilePath::kCurrentDirectory).AppendASCII(".."). |
56 AppendASCII("..").AppendASCII("..").AppendASCII("pdf"). | 56 AppendASCII("..").AppendASCII("..").AppendASCII("pdf"). |
57 AppendASCII("test"); | 57 AppendASCII("test"); |
58 } | 58 } |
59 | 59 |
60 void Load() { | 60 void Load() { |
61 // Make sure to set the window size before rendering, as otherwise rendering | 61 // Make sure to set the window size before rendering, as otherwise rendering |
62 // to a smaller window and then expanding leads to slight anti-aliasing | 62 // to a smaller window and then expanding leads to slight anti-aliasing |
63 // differences of the text and the pixel comparison fails. | 63 // differences of the text and the pixel comparison fails. |
64 gfx::Rect bounds(gfx::Rect(0, 0, kBrowserWidth, kBrowserHeight)); | 64 gfx::Rect bounds(gfx::Rect(0, 0, kBrowserWidth, kBrowserHeight)); |
65 scoped_ptr<WindowSizer::MonitorInfoProvider> monitor_info( | 65 gfx::Rect screen_bounds = gfx::Screen::GetPrimaryMonitorBounds(); |
66 WindowSizer::CreateDefaultMonitorInfoProvider()); | |
67 gfx::Rect screen_bounds = monitor_info->GetPrimaryMonitorBounds(); | |
68 ASSERT_GT(screen_bounds.width(), kBrowserWidth); | 66 ASSERT_GT(screen_bounds.width(), kBrowserWidth); |
69 ASSERT_GT(screen_bounds.height(), kBrowserHeight); | 67 ASSERT_GT(screen_bounds.height(), kBrowserHeight); |
70 browser()->window()->SetBounds(bounds); | 68 browser()->window()->SetBounds(bounds); |
71 | 69 |
72 GURL url(ui_test_utils::GetTestUrl( | 70 GURL url(ui_test_utils::GetTestUrl( |
73 GetPDFTestDir(), | 71 GetPDFTestDir(), |
74 FilePath(FILE_PATH_LITERAL("pdf_browsertest.pdf")))); | 72 FilePath(FILE_PATH_LITERAL("pdf_browsertest.pdf")))); |
75 ui_test_utils::NavigateToURL(browser(), url); | 73 ui_test_utils::NavigateToURL(browser(), url); |
76 } | 74 } |
77 | 75 |
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
353 ASSERT_TRUE(ui_test_utils::ExecuteJavaScript( | 351 ASSERT_TRUE(ui_test_utils::ExecuteJavaScript( |
354 browser()->GetSelectedTabContents()->render_view_host(), | 352 browser()->GetSelectedTabContents()->render_view_host(), |
355 std::wstring(), | 353 std::wstring(), |
356 L"reloadPDF();")); | 354 L"reloadPDF();")); |
357 observer.Wait(); | 355 observer.Wait(); |
358 | 356 |
359 ASSERT_EQ("success", browser()->GetSelectedTabContents()->GetURL().query()); | 357 ASSERT_EQ("success", browser()->GetSelectedTabContents()->GetURL().query()); |
360 } | 358 } |
361 | 359 |
362 } // namespace | 360 } // namespace |
OLD | NEW |