Enable PPAPI tests for non-SFI mode.
[chromium-blink-merge.git] / chrome / test / ppapi / ppapi_test.h
blobd81a9f815418fb44b72820f4fa70dc8f688c8b85
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
3 // found in the LICENSE file.
5 #ifndef CHROME_TEST_PPAPI_PPAPI_TEST_H_
6 #define CHROME_TEST_PPAPI_PPAPI_TEST_H_
8 #include <string>
10 #include "base/basictypes.h"
11 #include "base/compiler_specific.h"
12 #include "chrome/test/base/in_process_browser_test.h"
13 #include "chrome/test/base/javascript_test_observer.h"
14 #include "net/test/spawned_test_server/spawned_test_server.h"
16 namespace content {
17 class RenderViewHost;
20 class PPAPITestMessageHandler : public TestMessageHandler {
21 public:
22 PPAPITestMessageHandler();
24 MessageResponse HandleMessage(const std::string& json);
26 virtual void Reset() OVERRIDE;
28 const std::string& message() const {
29 return message_;
32 private:
33 std::string message_;
35 DISALLOW_COPY_AND_ASSIGN(PPAPITestMessageHandler);
38 class PPAPITestBase : public InProcessBrowserTest {
39 public:
40 PPAPITestBase();
42 // InProcessBrowserTest:
43 virtual void SetUp() OVERRIDE;
44 virtual void SetUpCommandLine(base::CommandLine* command_line) OVERRIDE;
45 virtual void SetUpOnMainThread() OVERRIDE;
47 virtual std::string BuildQuery(const std::string& base,
48 const std::string& test_case) = 0;
50 // Returns the URL to load for file: tests.
51 GURL GetTestFileUrl(const std::string& test_case);
52 virtual void RunTest(const std::string& test_case);
53 // Run the test and reload. This can test for clean shutdown, including leaked
54 // instance object vars.
55 virtual void RunTestAndReload(const std::string& test_case);
56 virtual void RunTestViaHTTP(const std::string& test_case);
57 virtual void RunTestWithSSLServer(const std::string& test_case);
58 virtual void RunTestWithWebSocketServer(const std::string& test_case);
59 virtual void RunTestIfAudioOutputAvailable(const std::string& test_case);
60 virtual void RunTestViaHTTPIfAudioOutputAvailable(
61 const std::string& test_case);
62 std::string StripPrefixes(const std::string& test_name);
64 protected:
65 class InfoBarObserver : public content::NotificationObserver {
66 public:
67 explicit InfoBarObserver(PPAPITestBase* test_base);
68 ~InfoBarObserver();
70 void ExpectInfoBarAndAccept(bool should_accept);
72 private:
73 // content::NotificationObserver:
74 virtual void Observe(int type,
75 const content::NotificationSource& source,
76 const content::NotificationDetails& details) OVERRIDE;
78 void VerifyInfoBarState();
80 content::NotificationRegistrar registrar_;
81 PPAPITestBase* test_base_;
82 bool expecting_infobar_;
83 bool should_accept_;
86 // Runs the test for a tab given the tab that's already navigated to the
87 // given URL.
88 void RunTestURL(const GURL& test_url);
89 // Gets the URL of the the given |test_case| for the given HTTP test server.
90 // If |extra_params| is non-empty, it will be appended as URL parameters.
91 GURL GetTestURL(const net::SpawnedTestServer& http_server,
92 const std::string& test_case,
93 const std::string& extra_params);
96 // In-process plugin test runner. See OutOfProcessPPAPITest below for the
97 // out-of-process version.
98 class PPAPITest : public PPAPITestBase {
99 public:
100 PPAPITest();
102 virtual void SetUpCommandLine(base::CommandLine* command_line) OVERRIDE;
104 virtual std::string BuildQuery(const std::string& base,
105 const std::string& test_case) OVERRIDE;
106 protected:
107 bool in_process_; // Controls the --ppapi-in-process switch.
110 class PPAPIPrivateTest : public PPAPITest {
111 protected:
112 virtual void SetUpCommandLine(base::CommandLine* command_line) OVERRIDE;
115 // Variant of PPAPITest that runs plugins out-of-process to test proxy
116 // codepaths.
117 class OutOfProcessPPAPITest : public PPAPITest {
118 public:
119 OutOfProcessPPAPITest();
121 virtual void SetUpCommandLine(base::CommandLine* command_line) OVERRIDE;
124 class OutOfProcessPPAPIPrivateTest : public OutOfProcessPPAPITest {
125 protected:
126 virtual void SetUpCommandLine(base::CommandLine* command_line) OVERRIDE;
129 // NaCl plugin test runner for Newlib runtime.
130 class PPAPINaClTest : public PPAPITestBase {
131 public:
132 virtual void SetUpCommandLine(base::CommandLine* command_line) OVERRIDE;
133 virtual void SetUpOnMainThread() OVERRIDE;
134 // PPAPITestBase overrides.
135 virtual void RunTest(const std::string& test_case) OVERRIDE;
136 virtual void RunTestAndReload(const std::string& test_case) OVERRIDE;
137 virtual void RunTestViaHTTP(const std::string& test_case) OVERRIDE;
138 virtual void RunTestWithSSLServer(const std::string& test_case) OVERRIDE;
139 virtual void RunTestWithWebSocketServer(
140 const std::string& test_case) OVERRIDE;
141 virtual void RunTestIfAudioOutputAvailable(
142 const std::string& test_case) OVERRIDE;
143 virtual void RunTestViaHTTPIfAudioOutputAvailable(
144 const std::string& test_case) OVERRIDE;
147 // NaCl plugin test runner for Newlib runtime.
148 class PPAPINaClNewlibTest : public PPAPINaClTest {
149 public:
150 virtual std::string BuildQuery(const std::string& base,
151 const std::string& test_case) OVERRIDE;
154 class PPAPIPrivateNaClNewlibTest : public PPAPINaClNewlibTest {
155 protected:
156 virtual void SetUpCommandLine(base::CommandLine* command_line) OVERRIDE;
159 // NaCl plugin test runner for GNU-libc runtime.
160 class PPAPINaClGLibcTest : public PPAPINaClTest {
161 public:
162 virtual std::string BuildQuery(const std::string& base,
163 const std::string& test_case) OVERRIDE;
166 class PPAPIPrivateNaClGLibcTest : public PPAPINaClGLibcTest {
167 protected:
168 virtual void SetUpCommandLine(base::CommandLine* command_line) OVERRIDE;
171 // NaCl plugin test runner for the PNaCl + Newlib runtime.
172 class PPAPINaClPNaClTest : public PPAPINaClTest {
173 public:
174 virtual std::string BuildQuery(const std::string& base,
175 const std::string& test_case) OVERRIDE;
178 class PPAPIPrivateNaClPNaClTest : public PPAPINaClPNaClTest {
179 protected:
180 virtual void SetUpCommandLine(base::CommandLine* command_line) OVERRIDE;
183 // Test Non-SFI Mode, using PNaCl toolchain to produce nexes.
184 class PPAPINaClPNaClNonSfiTest : public PPAPINaClTest {
185 public:
186 virtual void SetUpCommandLine(base::CommandLine* command_line);
188 virtual std::string BuildQuery(const std::string& base,
189 const std::string& test_case) OVERRIDE;
192 class PPAPIPrivateNaClPNaClNonSfiTest : public PPAPINaClPNaClNonSfiTest {
193 protected:
194 virtual void SetUpCommandLine(base::CommandLine* command_line) OVERRIDE;
197 class PPAPINaClTestDisallowedSockets : public PPAPITestBase {
198 public:
199 virtual void SetUpCommandLine(base::CommandLine* command_line) OVERRIDE;
201 virtual std::string BuildQuery(const std::string& base,
202 const std::string& test_case) OVERRIDE;
205 class PPAPIBrokerInfoBarTest : public OutOfProcessPPAPITest {
206 public:
207 // PPAPITestBase override:
208 virtual void SetUpOnMainThread() OVERRIDE;
211 #endif // CHROME_TEST_PPAPI_PPAPI_TEST_H_