Disable view source for Developer Tools.
[chromium-blink-merge.git] / chrome / test / ppapi / ppapi_test.h
blobfb5e6c73a5145f6dac51905b99508c4939635036
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 SetUpCommandLine(CommandLine* command_line) OVERRIDE;
44 virtual void SetUpOnMainThread() OVERRIDE;
46 virtual std::string BuildQuery(const std::string& base,
47 const std::string& test_case) = 0;
49 // Returns the URL to load for file: tests.
50 GURL GetTestFileUrl(const std::string& test_case);
51 void RunTest(const std::string& test_case);
52 // Run the test and reload. This can test for clean shutdown, including leaked
53 // instance object vars.
54 void RunTestAndReload(const std::string& test_case);
55 void RunTestViaHTTP(const std::string& test_case);
56 void RunTestWithSSLServer(const std::string& test_case);
57 void RunTestWithWebSocketServer(const std::string& test_case);
58 void RunTestIfAudioOutputAvailable(const std::string& test_case);
59 void RunTestViaHTTPIfAudioOutputAvailable(const std::string& test_case);
60 std::string StripPrefixes(const std::string& test_name);
62 protected:
63 class InfoBarObserver : public content::NotificationObserver {
64 public:
65 explicit InfoBarObserver(PPAPITestBase* test_base);
66 ~InfoBarObserver();
68 void ExpectInfoBarAndAccept(bool should_accept);
70 private:
71 // content::NotificationObserver:
72 virtual void Observe(int type,
73 const content::NotificationSource& source,
74 const content::NotificationDetails& details) OVERRIDE;
76 void VerifyInfoBarState();
78 content::NotificationRegistrar registrar_;
79 PPAPITestBase* test_base_;
80 bool expecting_infobar_;
81 bool should_accept_;
84 // Runs the test for a tab given the tab that's already navigated to the
85 // given URL.
86 void RunTestURL(const GURL& test_url);
87 // Gets the URL of the the given |test_case| for the given HTTP test server.
88 // If |extra_params| is non-empty, it will be appended as URL parameters.
89 GURL GetTestURL(const net::SpawnedTestServer& http_server,
90 const std::string& test_case,
91 const std::string& extra_params);
94 // In-process plugin test runner. See OutOfProcessPPAPITest below for the
95 // out-of-process version.
96 class PPAPITest : public PPAPITestBase {
97 public:
98 PPAPITest();
100 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE;
102 virtual std::string BuildQuery(const std::string& base,
103 const std::string& test_case) OVERRIDE;
104 protected:
105 bool in_process_; // Controls the --ppapi-in-process switch.
108 class PPAPIPrivateTest : public PPAPITest {
109 protected:
110 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE;
113 // Variant of PPAPITest that runs plugins out-of-process to test proxy
114 // codepaths.
115 class OutOfProcessPPAPITest : public PPAPITest {
116 public:
117 OutOfProcessPPAPITest();
119 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE;
122 class OutOfProcessPPAPIPrivateTest : public OutOfProcessPPAPITest {
123 protected:
124 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE;
127 // NaCl plugin test runner for Newlib runtime.
128 class PPAPINaClTest : public PPAPITestBase {
129 public:
130 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE;
133 // NaCl plugin test runner for Newlib runtime.
134 class PPAPINaClNewlibTest : public PPAPINaClTest {
135 public:
136 virtual std::string BuildQuery(const std::string& base,
137 const std::string& test_case) OVERRIDE;
140 class PPAPIPrivateNaClNewlibTest : public PPAPINaClNewlibTest {
141 protected:
142 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE;
145 // NaCl plugin test runner for GNU-libc runtime.
146 class PPAPINaClGLibcTest : public PPAPINaClTest {
147 public:
148 virtual std::string BuildQuery(const std::string& base,
149 const std::string& test_case) OVERRIDE;
152 class PPAPIPrivateNaClGLibcTest : public PPAPINaClGLibcTest {
153 protected:
154 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE;
157 // NaCl plugin test runner for the PNaCl + Newlib runtime.
158 class PPAPINaClPNaClTest : public PPAPINaClTest {
159 public:
160 virtual std::string BuildQuery(const std::string& base,
161 const std::string& test_case) OVERRIDE;
164 class PPAPIPrivateNaClPNaClTest : public PPAPINaClPNaClTest {
165 protected:
166 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE;
169 class PPAPINaClTestDisallowedSockets : public PPAPITestBase {
170 public:
171 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE;
173 virtual std::string BuildQuery(const std::string& base,
174 const std::string& test_case) OVERRIDE;
177 class PPAPIBrokerInfoBarTest : public OutOfProcessPPAPITest {
178 public:
179 // PPAPITestBase override:
180 virtual void SetUpOnMainThread() OVERRIDE;
183 #endif // CHROME_TEST_PPAPI_PPAPI_TEST_H_