| 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 "chrome/test/base/in_process_browser_test.h" | 12 #include "chrome/test/base/in_process_browser_test.h" |
| 13 #include "content/public/test/javascript_test_observer.h" | 13 #include "content/public/test/javascript_test_observer.h" |
| 14 #include "net/test/spawned_test_server/spawned_test_server.h" | 14 #include "net/test/spawned_test_server/spawned_test_server.h" |
| 15 | 15 |
| 16 namespace content { | 16 namespace content { |
| 17 class RenderViewHost; | 17 class RenderViewHost; |
| 18 } | 18 } |
| 19 | 19 |
| 20 class PPAPITestMessageHandler : public content::TestMessageHandler { | 20 class PPAPITestMessageHandler : public content::TestMessageHandler { |
| 21 public: | 21 public: |
| 22 PPAPITestMessageHandler(); | 22 PPAPITestMessageHandler(); |
| 23 | 23 |
| 24 virtual MessageResponse HandleMessage(const std::string& json) override; | 24 MessageResponse HandleMessage(const std::string& json) override; |
| 25 virtual void Reset() override; | 25 void Reset() override; |
| 26 | 26 |
| 27 const std::string& message() const { | 27 const std::string& message() const { |
| 28 return message_; | 28 return message_; |
| 29 } | 29 } |
| 30 | 30 |
| 31 private: | 31 private: |
| 32 std::string message_; | 32 std::string message_; |
| 33 | 33 |
| 34 DISALLOW_COPY_AND_ASSIGN(PPAPITestMessageHandler); | 34 DISALLOW_COPY_AND_ASSIGN(PPAPITestMessageHandler); |
| 35 }; | 35 }; |
| 36 | 36 |
| 37 class PPAPITestBase : public InProcessBrowserTest { | 37 class PPAPITestBase : public InProcessBrowserTest { |
| 38 public: | 38 public: |
| 39 PPAPITestBase(); | 39 PPAPITestBase(); |
| 40 | 40 |
| 41 // InProcessBrowserTest: | 41 // InProcessBrowserTest: |
| 42 virtual void SetUp() override; | 42 void SetUp() override; |
| 43 virtual void SetUpCommandLine(base::CommandLine* command_line) override; | 43 void SetUpCommandLine(base::CommandLine* command_line) override; |
| 44 virtual void SetUpOnMainThread() override; | 44 void SetUpOnMainThread() override; |
| 45 | 45 |
| 46 virtual std::string BuildQuery(const std::string& base, | 46 virtual std::string BuildQuery(const std::string& base, |
| 47 const std::string& test_case) = 0; | 47 const std::string& test_case) = 0; |
| 48 | 48 |
| 49 // Returns the URL to load for file: tests. | 49 // Returns the URL to load for file: tests. |
| 50 GURL GetTestFileUrl(const std::string& test_case); | 50 GURL GetTestFileUrl(const std::string& test_case); |
| 51 virtual void RunTest(const std::string& test_case); | 51 virtual void RunTest(const std::string& test_case); |
| 52 virtual void RunTestViaHTTP(const std::string& test_case); | 52 virtual void RunTestViaHTTP(const std::string& test_case); |
| 53 virtual void RunTestWithSSLServer(const std::string& test_case); | 53 virtual void RunTestWithSSLServer(const std::string& test_case); |
| 54 virtual void RunTestWithWebSocketServer(const std::string& test_case); | 54 virtual void RunTestWithWebSocketServer(const std::string& test_case); |
| 55 virtual void RunTestIfAudioOutputAvailable(const std::string& test_case); | 55 virtual void RunTestIfAudioOutputAvailable(const std::string& test_case); |
| 56 virtual void RunTestViaHTTPIfAudioOutputAvailable( | 56 virtual void RunTestViaHTTPIfAudioOutputAvailable( |
| 57 const std::string& test_case); | 57 const std::string& test_case); |
| 58 | 58 |
| 59 protected: | 59 protected: |
| 60 class InfoBarObserver : public content::NotificationObserver { | 60 class InfoBarObserver : public content::NotificationObserver { |
| 61 public: | 61 public: |
| 62 explicit InfoBarObserver(PPAPITestBase* test_base); | 62 explicit InfoBarObserver(PPAPITestBase* test_base); |
| 63 ~InfoBarObserver(); | 63 ~InfoBarObserver(); |
| 64 | 64 |
| 65 void ExpectInfoBarAndAccept(bool should_accept); | 65 void ExpectInfoBarAndAccept(bool should_accept); |
| 66 | 66 |
| 67 private: | 67 private: |
| 68 // content::NotificationObserver: | 68 // content::NotificationObserver: |
| 69 virtual void Observe(int type, | 69 void Observe(int type, |
| 70 const content::NotificationSource& source, | 70 const content::NotificationSource& source, |
| 71 const content::NotificationDetails& details) override; | 71 const content::NotificationDetails& details) override; |
| 72 | 72 |
| 73 void VerifyInfoBarState(); | 73 void VerifyInfoBarState(); |
| 74 | 74 |
| 75 content::NotificationRegistrar registrar_; | 75 content::NotificationRegistrar registrar_; |
| 76 PPAPITestBase* test_base_; | 76 PPAPITestBase* test_base_; |
| 77 bool expecting_infobar_; | 77 bool expecting_infobar_; |
| 78 bool should_accept_; | 78 bool should_accept_; |
| 79 }; | 79 }; |
| 80 | 80 |
| 81 // Runs the test for a tab given the tab that's already navigated to the | 81 // Runs the test for a tab given the tab that's already navigated to the |
| 82 // given URL. | 82 // given URL. |
| 83 void RunTestURL(const GURL& test_url); | 83 void RunTestURL(const GURL& test_url); |
| 84 // Gets the URL of the the given |test_case| for the given HTTP test server. | 84 // Gets the URL of the the given |test_case| for the given HTTP test server. |
| 85 // If |extra_params| is non-empty, it will be appended as URL parameters. | 85 // If |extra_params| is non-empty, it will be appended as URL parameters. |
| 86 GURL GetTestURL(const net::SpawnedTestServer& http_server, | 86 GURL GetTestURL(const net::SpawnedTestServer& http_server, |
| 87 const std::string& test_case, | 87 const std::string& test_case, |
| 88 const std::string& extra_params); | 88 const std::string& extra_params); |
| 89 }; | 89 }; |
| 90 | 90 |
| 91 // In-process plugin test runner. See OutOfProcessPPAPITest below for the | 91 // In-process plugin test runner. See OutOfProcessPPAPITest below for the |
| 92 // out-of-process version. | 92 // out-of-process version. |
| 93 class PPAPITest : public PPAPITestBase { | 93 class PPAPITest : public PPAPITestBase { |
| 94 public: | 94 public: |
| 95 PPAPITest(); | 95 PPAPITest(); |
| 96 | 96 |
| 97 virtual void SetUpCommandLine(base::CommandLine* command_line) override; | 97 void SetUpCommandLine(base::CommandLine* command_line) override; |
| 98 | 98 |
| 99 virtual std::string BuildQuery(const std::string& base, | 99 std::string BuildQuery(const std::string& base, |
| 100 const std::string& test_case) override; | 100 const std::string& test_case) override; |
| 101 |
| 101 protected: | 102 protected: |
| 102 bool in_process_; // Controls the --ppapi-in-process switch. | 103 bool in_process_; // Controls the --ppapi-in-process switch. |
| 103 }; | 104 }; |
| 104 | 105 |
| 105 class PPAPIPrivateTest : public PPAPITest { | 106 class PPAPIPrivateTest : public PPAPITest { |
| 106 protected: | 107 protected: |
| 107 virtual void SetUpCommandLine(base::CommandLine* command_line) override; | 108 void SetUpCommandLine(base::CommandLine* command_line) override; |
| 108 }; | 109 }; |
| 109 | 110 |
| 110 // Variant of PPAPITest that runs plugins out-of-process to test proxy | 111 // Variant of PPAPITest that runs plugins out-of-process to test proxy |
| 111 // codepaths. | 112 // codepaths. |
| 112 class OutOfProcessPPAPITest : public PPAPITest { | 113 class OutOfProcessPPAPITest : public PPAPITest { |
| 113 public: | 114 public: |
| 114 OutOfProcessPPAPITest(); | 115 OutOfProcessPPAPITest(); |
| 115 | 116 |
| 116 virtual void SetUpCommandLine(base::CommandLine* command_line) override; | 117 void SetUpCommandLine(base::CommandLine* command_line) override; |
| 117 }; | 118 }; |
| 118 | 119 |
| 119 class OutOfProcessPPAPIPrivateTest : public OutOfProcessPPAPITest { | 120 class OutOfProcessPPAPIPrivateTest : public OutOfProcessPPAPITest { |
| 120 protected: | 121 protected: |
| 121 virtual void SetUpCommandLine(base::CommandLine* command_line) override; | 122 void SetUpCommandLine(base::CommandLine* command_line) override; |
| 122 }; | 123 }; |
| 123 | 124 |
| 124 // NaCl plugin test runner for Newlib runtime. | 125 // NaCl plugin test runner for Newlib runtime. |
| 125 class PPAPINaClTest : public PPAPITestBase { | 126 class PPAPINaClTest : public PPAPITestBase { |
| 126 public: | 127 public: |
| 127 virtual void SetUpCommandLine(base::CommandLine* command_line) override; | 128 void SetUpCommandLine(base::CommandLine* command_line) override; |
| 128 virtual void SetUpOnMainThread() override; | 129 void SetUpOnMainThread() override; |
| 129 // PPAPITestBase overrides. | 130 // PPAPITestBase overrides. |
| 130 virtual void RunTest(const std::string& test_case) override; | 131 void RunTest(const std::string& test_case) override; |
| 131 virtual void RunTestViaHTTP(const std::string& test_case) override; | 132 void RunTestViaHTTP(const std::string& test_case) override; |
| 132 virtual void RunTestWithSSLServer(const std::string& test_case) override; | 133 void RunTestWithSSLServer(const std::string& test_case) override; |
| 133 virtual void RunTestWithWebSocketServer( | 134 void RunTestWithWebSocketServer(const std::string& test_case) override; |
| 134 const std::string& test_case) override; | 135 void RunTestIfAudioOutputAvailable(const std::string& test_case) override; |
| 135 virtual void RunTestIfAudioOutputAvailable( | 136 void RunTestViaHTTPIfAudioOutputAvailable( |
| 136 const std::string& test_case) override; | |
| 137 virtual void RunTestViaHTTPIfAudioOutputAvailable( | |
| 138 const std::string& test_case) override; | 137 const std::string& test_case) override; |
| 139 }; | 138 }; |
| 140 | 139 |
| 141 // NaCl plugin test runner for Newlib runtime. | 140 // NaCl plugin test runner for Newlib runtime. |
| 142 class PPAPINaClNewlibTest : public PPAPINaClTest { | 141 class PPAPINaClNewlibTest : public PPAPINaClTest { |
| 143 public: | 142 public: |
| 144 virtual std::string BuildQuery(const std::string& base, | 143 std::string BuildQuery(const std::string& base, |
| 145 const std::string& test_case) override; | 144 const std::string& test_case) override; |
| 146 }; | 145 }; |
| 147 | 146 |
| 148 class PPAPIPrivateNaClNewlibTest : public PPAPINaClNewlibTest { | 147 class PPAPIPrivateNaClNewlibTest : public PPAPINaClNewlibTest { |
| 149 protected: | 148 protected: |
| 150 virtual void SetUpCommandLine(base::CommandLine* command_line) override; | 149 void SetUpCommandLine(base::CommandLine* command_line) override; |
| 151 }; | 150 }; |
| 152 | 151 |
| 153 // NaCl plugin test runner for GNU-libc runtime. | 152 // NaCl plugin test runner for GNU-libc runtime. |
| 154 class PPAPINaClGLibcTest : public PPAPINaClTest { | 153 class PPAPINaClGLibcTest : public PPAPINaClTest { |
| 155 public: | 154 public: |
| 156 virtual std::string BuildQuery(const std::string& base, | 155 std::string BuildQuery(const std::string& base, |
| 157 const std::string& test_case) override; | 156 const std::string& test_case) override; |
| 158 }; | 157 }; |
| 159 | 158 |
| 160 class PPAPIPrivateNaClGLibcTest : public PPAPINaClGLibcTest { | 159 class PPAPIPrivateNaClGLibcTest : public PPAPINaClGLibcTest { |
| 161 protected: | 160 protected: |
| 162 virtual void SetUpCommandLine(base::CommandLine* command_line) override; | 161 void SetUpCommandLine(base::CommandLine* command_line) override; |
| 163 }; | 162 }; |
| 164 | 163 |
| 165 // NaCl plugin test runner for the PNaCl + Newlib runtime. | 164 // NaCl plugin test runner for the PNaCl + Newlib runtime. |
| 166 class PPAPINaClPNaClTest : public PPAPINaClTest { | 165 class PPAPINaClPNaClTest : public PPAPINaClTest { |
| 167 public: | 166 public: |
| 168 virtual std::string BuildQuery(const std::string& base, | 167 std::string BuildQuery(const std::string& base, |
| 169 const std::string& test_case) override; | 168 const std::string& test_case) override; |
| 170 }; | 169 }; |
| 171 | 170 |
| 172 class PPAPIPrivateNaClPNaClTest : public PPAPINaClPNaClTest { | 171 class PPAPIPrivateNaClPNaClTest : public PPAPINaClPNaClTest { |
| 173 protected: | 172 protected: |
| 174 virtual void SetUpCommandLine(base::CommandLine* command_line) override; | 173 void SetUpCommandLine(base::CommandLine* command_line) override; |
| 175 }; | 174 }; |
| 176 | 175 |
| 177 // Test Non-SFI Mode, using PNaCl toolchain to produce nexes. | 176 // Test Non-SFI Mode, using PNaCl toolchain to produce nexes. |
| 178 class PPAPINaClPNaClNonSfiTest : public PPAPINaClTest { | 177 class PPAPINaClPNaClNonSfiTest : public PPAPINaClTest { |
| 179 public: | 178 public: |
| 180 virtual void SetUpCommandLine(base::CommandLine* command_line); | 179 void SetUpCommandLine(base::CommandLine* command_line) override; |
| 181 | 180 |
| 182 virtual std::string BuildQuery(const std::string& base, | 181 std::string BuildQuery(const std::string& base, |
| 183 const std::string& test_case) override; | 182 const std::string& test_case) override; |
| 184 }; | 183 }; |
| 185 | 184 |
| 186 // TODO(hidehiko): Switch NonSfi tests to use nacl_helper_nonsfi, when | 185 // TODO(hidehiko): Switch NonSfi tests to use nacl_helper_nonsfi, when |
| 187 // it is launched officially. See NaClBrowserTestPnaclTransitionalNonSfi | 186 // it is launched officially. See NaClBrowserTestPnaclTransitionalNonSfi |
| 188 // for more details. | 187 // for more details. |
| 189 class PPAPINaClPNaClTransitionalNonSfiTest : public PPAPINaClPNaClNonSfiTest { | 188 class PPAPINaClPNaClTransitionalNonSfiTest : public PPAPINaClPNaClNonSfiTest { |
| 190 public: | 189 public: |
| 191 virtual void SetUpCommandLine(base::CommandLine* command_line) override; | 190 void SetUpCommandLine(base::CommandLine* command_line) override; |
| 192 }; | 191 }; |
| 193 | 192 |
| 194 class PPAPIPrivateNaClPNaClNonSfiTest : public PPAPINaClPNaClNonSfiTest { | 193 class PPAPIPrivateNaClPNaClNonSfiTest : public PPAPINaClPNaClNonSfiTest { |
| 195 protected: | 194 protected: |
| 196 virtual void SetUpCommandLine(base::CommandLine* command_line) override; | 195 void SetUpCommandLine(base::CommandLine* command_line) override; |
| 197 }; | 196 }; |
| 198 | 197 |
| 199 // TODO(hidehiko): Switch NonSfi tests to use nacl_helper_nonsfi, when | 198 // TODO(hidehiko): Switch NonSfi tests to use nacl_helper_nonsfi, when |
| 200 // it is launched officially. See NaClBrowserTestPnaclTransitionalNonSfi | 199 // it is launched officially. See NaClBrowserTestPnaclTransitionalNonSfi |
| 201 // for more details. | 200 // for more details. |
| 202 class PPAPIPrivateNaClPNaClTransitionalNonSfiTest | 201 class PPAPIPrivateNaClPNaClTransitionalNonSfiTest |
| 203 : public PPAPIPrivateNaClPNaClNonSfiTest { | 202 : public PPAPIPrivateNaClPNaClNonSfiTest { |
| 204 protected: | 203 protected: |
| 205 virtual void SetUpCommandLine(base::CommandLine* command_line) override; | 204 void SetUpCommandLine(base::CommandLine* command_line) override; |
| 206 }; | 205 }; |
| 207 | 206 |
| 208 | 207 |
| 209 class PPAPINaClTestDisallowedSockets : public PPAPITestBase { | 208 class PPAPINaClTestDisallowedSockets : public PPAPITestBase { |
| 210 public: | 209 public: |
| 211 virtual void SetUpCommandLine(base::CommandLine* command_line) override; | 210 void SetUpCommandLine(base::CommandLine* command_line) override; |
| 212 | 211 |
| 213 virtual std::string BuildQuery(const std::string& base, | 212 std::string BuildQuery(const std::string& base, |
| 214 const std::string& test_case) override; | 213 const std::string& test_case) override; |
| 215 }; | 214 }; |
| 216 | 215 |
| 217 class PPAPIBrokerInfoBarTest : public OutOfProcessPPAPITest { | 216 class PPAPIBrokerInfoBarTest : public OutOfProcessPPAPITest { |
| 218 public: | 217 public: |
| 219 // PPAPITestBase override: | 218 // PPAPITestBase override: |
| 220 virtual void SetUpOnMainThread() override; | 219 void SetUpOnMainThread() override; |
| 221 }; | 220 }; |
| 222 | 221 |
| 223 #endif // CHROME_TEST_PPAPI_PPAPI_TEST_H_ | 222 #endif // CHROME_TEST_PPAPI_PPAPI_TEST_H_ |
| OLD | NEW |