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 #ifndef CHROME_BROWSER_UI_PDF_PDF_BROWSERTEST_BASE_H_ | 5 #ifndef CHROME_BROWSER_UI_PDF_PDF_BROWSERTEST_BASE_H_ |
6 #define CHROME_BROWSER_UI_PDF_PDF_BROWSERTEST_BASE_H_ | 6 #define CHROME_BROWSER_UI_PDF_PDF_BROWSERTEST_BASE_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
11 #include "chrome/test/base/in_process_browser_test.h" | 11 #include "chrome/test/base/in_process_browser_test.h" |
12 #include "content/public/browser/notification_observer.h" | 12 #include "content/public/browser/notification_observer.h" |
13 #include "content/public/browser/readback_types.h" | 13 #include "content/public/browser/readback_types.h" |
14 #include "net/test/embedded_test_server/embedded_test_server.h" | 14 #include "net/test/embedded_test_server/embedded_test_server.h" |
15 | 15 |
16 namespace base { | 16 namespace base { |
17 class CommandLine; | 17 class CommandLine; |
18 } | 18 } |
19 | 19 |
20 class SkBitmap; | 20 class SkBitmap; |
21 | 21 |
22 // This class is in its own separate file because it is used in both | 22 // This class is in its own separate file because it is used in both |
23 // browser_tests and interactive_ui_tests. | 23 // browser_tests and interactive_ui_tests. |
24 class PDFBrowserTest : public InProcessBrowserTest, | 24 class PDFBrowserTest : public InProcessBrowserTest, |
25 public testing::WithParamInterface<int>, | 25 public testing::WithParamInterface<int>, |
26 public content::NotificationObserver { | 26 public content::NotificationObserver { |
27 public: | 27 public: |
28 PDFBrowserTest(); | 28 PDFBrowserTest(); |
29 virtual ~PDFBrowserTest(); | 29 ~PDFBrowserTest() override; |
30 | 30 |
31 protected: | 31 protected: |
32 // Use our own TestServer so that we can serve files from the pdf directory. | 32 // Use our own TestServer so that we can serve files from the pdf directory. |
33 net::test_server::EmbeddedTestServer* pdf_test_server() { | 33 net::test_server::EmbeddedTestServer* pdf_test_server() { |
34 return &pdf_test_server_; | 34 return &pdf_test_server_; |
35 } | 35 } |
36 | 36 |
37 int load_stop_notification_count() const { | 37 int load_stop_notification_count() const { |
38 return load_stop_notification_count_; | 38 return load_stop_notification_count_; |
39 } | 39 } |
40 | 40 |
41 void Load(); | 41 void Load(); |
42 void WaitForResponse(); | 42 void WaitForResponse(); |
43 bool VerifySnapshot(const std::string& expected_filename); | 43 bool VerifySnapshot(const std::string& expected_filename); |
44 | 44 |
45 private: | 45 private: |
46 void CopyFromBackingStoreCallback(const SkBitmap& bitmap, | 46 void CopyFromBackingStoreCallback(const SkBitmap& bitmap, |
47 content::ReadbackResponse response); | 47 content::ReadbackResponse response); |
48 | 48 |
49 // content::NotificationObserver | 49 // content::NotificationObserver |
50 virtual void Observe(int type, | 50 void Observe(int type, |
51 const content::NotificationSource& source, | 51 const content::NotificationSource& source, |
52 const content::NotificationDetails& details) override; | 52 const content::NotificationDetails& details) override; |
53 | 53 |
54 // InProcessBrowserTest | 54 // InProcessBrowserTest |
55 virtual void SetUpCommandLine(base::CommandLine* command_line) override; | 55 void SetUpCommandLine(base::CommandLine* command_line) override; |
56 | 56 |
57 // True if the snapshot differed from the expected value. | 57 // True if the snapshot differed from the expected value. |
58 bool snapshot_different_; | 58 bool snapshot_different_; |
59 // Internal variable used to synchronize to the renderer. | 59 // Internal variable used to synchronize to the renderer. |
60 int next_dummy_search_value_; | 60 int next_dummy_search_value_; |
61 // The filename of the bitmap to compare the snapshot to. | 61 // The filename of the bitmap to compare the snapshot to. |
62 std::string expected_filename_; | 62 std::string expected_filename_; |
63 // If the snapshot is different, holds the location where it's saved. | 63 // If the snapshot is different, holds the location where it's saved. |
64 base::FilePath snapshot_filename_; | 64 base::FilePath snapshot_filename_; |
65 // How many times we've seen chrome::LOAD_STOP. | 65 // How many times we've seen chrome::LOAD_STOP. |
66 int load_stop_notification_count_; | 66 int load_stop_notification_count_; |
67 | 67 |
68 net::test_server::EmbeddedTestServer pdf_test_server_; | 68 net::test_server::EmbeddedTestServer pdf_test_server_; |
69 | 69 |
70 DISALLOW_COPY_AND_ASSIGN(PDFBrowserTest); | 70 DISALLOW_COPY_AND_ASSIGN(PDFBrowserTest); |
71 }; | 71 }; |
72 | 72 |
73 #endif // CHROME_BROWSER_UI_PDF_PDF_BROWSERTEST_BASE_H_ | 73 #endif // CHROME_BROWSER_UI_PDF_PDF_BROWSERTEST_BASE_H_ |
OLD | NEW |