OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_TEST_PPAPI_PPAPI_TEST_H_ | 5 #ifndef CHROME_TEST_PPAPI_PPAPI_TEST_H_ |
6 #define CHROME_TEST_PPAPI_PPAPI_TEST_H_ | 6 #define CHROME_TEST_PPAPI_PPAPI_TEST_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
12 #include "base/timer.h" | 12 #include "base/timer.h" |
13 #include "chrome/test/base/in_process_browser_test.h" | 13 #include "chrome/test/base/in_process_browser_test.h" |
14 #include "content/public/browser/notification_observer.h" | 14 #include "content/public/browser/notification_observer.h" |
15 #include "content/public/browser/notification_registrar.h" | 15 #include "content/public/browser/notification_registrar.h" |
| 16 #include "testing/gmock/include/gmock/gmock.h" |
| 17 |
| 18 class ConfirmInfoBarDelegate; |
16 | 19 |
17 namespace content { | 20 namespace content { |
18 class RenderViewHost; | 21 class RenderViewHost; |
19 } | 22 } |
20 | 23 |
21 class PPAPITestBase : public InProcessBrowserTest { | 24 class PPAPITestBase : public InProcessBrowserTest { |
22 public: | 25 public: |
23 PPAPITestBase(); | 26 PPAPITestBase(); |
24 | 27 |
| 28 // InProcessBrowserTest: |
25 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE; | 29 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE; |
| 30 virtual void SetUpOnMainThread() OVERRIDE; |
26 | 31 |
27 virtual std::string BuildQuery(const std::string& base, | 32 virtual std::string BuildQuery(const std::string& base, |
28 const std::string& test_case) = 0; | 33 const std::string& test_case) = 0; |
29 | 34 |
30 // Returns the URL to load for file: tests. | 35 // Returns the URL to load for file: tests. |
31 GURL GetTestFileUrl(const std::string& test_case); | 36 GURL GetTestFileUrl(const std::string& test_case); |
32 void RunTest(const std::string& test_case); | 37 void RunTest(const std::string& test_case); |
33 // Run the test and reload. This can test for clean shutdown, including leaked | 38 // Run the test and reload. This can test for clean shutdown, including leaked |
34 // instance object vars. | 39 // instance object vars. |
35 void RunTestAndReload(const std::string& test_case); | 40 void RunTestAndReload(const std::string& test_case); |
(...skipping 26 matching lines...) Expand all Loading... |
62 bool finished_; | 67 bool finished_; |
63 bool waiting_; | 68 bool waiting_; |
64 base::TimeDelta timeout_; | 69 base::TimeDelta timeout_; |
65 std::string result_; | 70 std::string result_; |
66 content::NotificationRegistrar registrar_; | 71 content::NotificationRegistrar registrar_; |
67 base::RepeatingTimer<TestFinishObserver> timer_; | 72 base::RepeatingTimer<TestFinishObserver> timer_; |
68 | 73 |
69 DISALLOW_COPY_AND_ASSIGN(TestFinishObserver); | 74 DISALLOW_COPY_AND_ASSIGN(TestFinishObserver); |
70 }; | 75 }; |
71 | 76 |
| 77 class InfoBarObserver : public content::NotificationObserver { |
| 78 public: |
| 79 InfoBarObserver(); |
| 80 ~InfoBarObserver(); |
| 81 |
| 82 virtual void Observe(int type, |
| 83 const content::NotificationSource& source, |
| 84 const content::NotificationDetails& details) OVERRIDE; |
| 85 |
| 86 MOCK_METHOD1(ShouldAcceptInfoBar, bool(ConfirmInfoBarDelegate* delegate)); |
| 87 |
| 88 private: |
| 89 content::NotificationRegistrar registrar_; |
| 90 }; |
| 91 |
72 // Runs the test for a tab given the tab that's already navigated to the | 92 // Runs the test for a tab given the tab that's already navigated to the |
73 // given URL. | 93 // given URL. |
74 void RunTestURL(const GURL& test_url); | 94 void RunTestURL(const GURL& test_url); |
75 // Run the given |test_case| on a HTTP test server whose document root is | 95 // Run the given |test_case| on a HTTP test server whose document root is |
76 // specified by |document_root|. |extra_params| will be passed as URL | 96 // specified by |document_root|. |extra_params| will be passed as URL |
77 // parameters to the test. | 97 // parameters to the test. |
78 void RunHTTPTestServer(const FilePath& document_root, | 98 void RunHTTPTestServer(const FilePath& document_root, |
79 const std::string& test_case, | 99 const std::string& test_case, |
80 const std::string& extra_params); | 100 const std::string& extra_params); |
81 // Return the document root for the HTTP server on which tests will be run. | 101 // Return the document root for the HTTP server on which tests will be run. |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 }; | 145 }; |
126 | 146 |
127 class PPAPINaClTestDisallowedSockets : public PPAPITestBase { | 147 class PPAPINaClTestDisallowedSockets : public PPAPITestBase { |
128 public: | 148 public: |
129 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE; | 149 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE; |
130 | 150 |
131 virtual std::string BuildQuery(const std::string& base, | 151 virtual std::string BuildQuery(const std::string& base, |
132 const std::string& test_case) OVERRIDE; | 152 const std::string& test_case) OVERRIDE; |
133 }; | 153 }; |
134 | 154 |
| 155 class PPAPIBrokerInfoBarTest : public PPAPITest { |
| 156 public: |
| 157 // PPAPITestBase override: |
| 158 virtual void SetUpOnMainThread() OVERRIDE; |
| 159 }; |
| 160 |
135 #endif // CHROME_TEST_PPAPI_PPAPI_TEST_H_ | 161 #endif // CHROME_TEST_PPAPI_PPAPI_TEST_H_ |
OLD | NEW |