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_BROWSER_EXTENSIONS_EXTENSION_APITEST_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_APITEST_H_ |
6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_APITEST_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_APITEST_H_ |
7 | 7 |
8 #include <deque> | 8 #include <deque> |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
12 #include "base/values.h" | 12 #include "base/values.h" |
13 #include "chrome/browser/extensions/extension_browsertest.h" | 13 #include "chrome/browser/extensions/extension_browsertest.h" |
14 #include "content/public/browser/notification_registrar.h" | 14 #include "content/public/browser/notification_registrar.h" |
15 | 15 |
| 16 namespace base { |
16 class FilePath; | 17 class FilePath; |
| 18 } |
17 | 19 |
18 namespace extensions { | 20 namespace extensions { |
19 class Extension; | 21 class Extension; |
20 } | 22 } |
21 | 23 |
22 | |
23 // The general flow of these API tests should work like this: | 24 // The general flow of these API tests should work like this: |
24 // (1) Setup initial browser state (e.g. create some bookmarks for the | 25 // (1) Setup initial browser state (e.g. create some bookmarks for the |
25 // bookmark test) | 26 // bookmark test) |
26 // (2) Call ASSERT_TRUE(RunExtensionTest(name)); | 27 // (2) Call ASSERT_TRUE(RunExtensionTest(name)); |
27 // (3) In your extension code, run your test and call chrome.test.pass or | 28 // (3) In your extension code, run your test and call chrome.test.pass or |
28 // chrome.test.fail | 29 // chrome.test.fail |
29 // (4) Verify expected browser state. | 30 // (4) Verify expected browser state. |
30 // TODO(erikkay): There should also be a way to drive events in these tests. | 31 // TODO(erikkay): There should also be a way to drive events in these tests. |
31 class ExtensionApiTest : public ExtensionBrowserTest { | 32 class ExtensionApiTest : public ExtensionBrowserTest { |
32 public: | 33 public: |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 // shell windows. | 152 // shell windows. |
152 bool RunPlatformAppTest(const char* extension_name); | 153 bool RunPlatformAppTest(const char* extension_name); |
153 | 154 |
154 // Start the test server, and store details of its state. Those details | 155 // Start the test server, and store details of its state. Those details |
155 // will be available to javascript tests using chrome.test.getConfig(). | 156 // will be available to javascript tests using chrome.test.getConfig(). |
156 bool StartTestServer(); | 157 bool StartTestServer(); |
157 | 158 |
158 // Start the test WebSocket server, and store details of its state. Those | 159 // Start the test WebSocket server, and store details of its state. Those |
159 // details will be available to javascript tests using | 160 // details will be available to javascript tests using |
160 // chrome.test.getConfig(). | 161 // chrome.test.getConfig(). |
161 bool StartWebSocketServer(const FilePath& root_directory); | 162 bool StartWebSocketServer(const base::FilePath& root_directory); |
162 | 163 |
163 // Test that exactly one extension loaded. If so, return a pointer to | 164 // Test that exactly one extension loaded. If so, return a pointer to |
164 // the extension. If not, return NULL and set message_. | 165 // the extension. If not, return NULL and set message_. |
165 const extensions::Extension* GetSingleLoadedExtension(); | 166 const extensions::Extension* GetSingleLoadedExtension(); |
166 | 167 |
167 // All extensions tested by ExtensionApiTest are in the "api_test" dir. | 168 // All extensions tested by ExtensionApiTest are in the "api_test" dir. |
168 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE; | 169 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE; |
169 | 170 |
170 // If it failed, what was the error message? | 171 // If it failed, what was the error message? |
171 std::string message_; | 172 std::string message_; |
172 | 173 |
173 private: | 174 private: |
174 bool RunExtensionTestImpl(const char* extension_name, | 175 bool RunExtensionTestImpl(const char* extension_name, |
175 const std::string& test_page, | 176 const std::string& test_page, |
176 int flags); | 177 int flags); |
177 | 178 |
178 // Hold details of the test, set in C++, which can be accessed by | 179 // Hold details of the test, set in C++, which can be accessed by |
179 // javascript using chrome.test.getConfig(). | 180 // javascript using chrome.test.getConfig(). |
180 scoped_ptr<DictionaryValue> test_config_; | 181 scoped_ptr<DictionaryValue> test_config_; |
181 | 182 |
182 // Hold the test WebSocket server. | 183 // Hold the test WebSocket server. |
183 scoped_ptr<net::TestServer> websocket_server_; | 184 scoped_ptr<net::TestServer> websocket_server_; |
184 }; | 185 }; |
185 | 186 |
186 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_APITEST_H_ | 187 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_APITEST_H_ |
OLD | NEW |