| 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 class FilePath; | 16 class FilePath; |
| 17 | 17 |
| 18 namespace content { | |
| 19 class TestWebSocketServer; | |
| 20 } | |
| 21 | |
| 22 namespace extensions { | 18 namespace extensions { |
| 23 class Extension; | 19 class Extension; |
| 24 } | 20 } |
| 25 | 21 |
| 26 | 22 |
| 27 // The general flow of these API tests should work like this: | 23 // The general flow of these API tests should work like this: |
| 28 // (1) Setup initial browser state (e.g. create some bookmarks for the | 24 // (1) Setup initial browser state (e.g. create some bookmarks for the |
| 29 // bookmark test) | 25 // bookmark test) |
| 30 // (2) Call ASSERT_TRUE(RunExtensionTest(name)); | 26 // (2) Call ASSERT_TRUE(RunExtensionTest(name)); |
| 31 // (3) In your extension code, run your test and call chrome.test.pass or | 27 // (3) In your extension code, run your test and call chrome.test.pass or |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 bool RunPageTest(const std::string& page_url, int flags); | 148 bool RunPageTest(const std::string& page_url, int flags); |
| 153 | 149 |
| 154 // Similar to RunExtensionTest, except used for running tests in platform app | 150 // Similar to RunExtensionTest, except used for running tests in platform app |
| 155 // shell windows. | 151 // shell windows. |
| 156 bool RunPlatformAppTest(const char* extension_name); | 152 bool RunPlatformAppTest(const char* extension_name); |
| 157 | 153 |
| 158 // Start the test server, and store details of its state. Those details | 154 // Start the test server, and store details of its state. Those details |
| 159 // will be available to javascript tests using chrome.test.getConfig(). | 155 // will be available to javascript tests using chrome.test.getConfig(). |
| 160 bool StartTestServer(); | 156 bool StartTestServer(); |
| 161 | 157 |
| 162 // Start the test WebSocket server, and store details of its state. Those | 158 // Start the other test server in WebSocket mode, and store details of its |
| 163 // details will be available to javascript tests using | 159 // state. Those details will be available to javascript tests using |
| 164 // chrome.test.getConfig(). | 160 // chrome.test.getConfig(). |
| 165 bool StartWebSocketServer(const FilePath& root_directory); | 161 bool StartWebSocketServer(const FilePath& root_directory); |
| 166 | 162 |
| 167 // Test that exactly one extension loaded. If so, return a pointer to | 163 // Test that exactly one extension loaded. If so, return a pointer to |
| 168 // the extension. If not, return NULL and set message_. | 164 // the extension. If not, return NULL and set message_. |
| 169 const extensions::Extension* GetSingleLoadedExtension(); | 165 const extensions::Extension* GetSingleLoadedExtension(); |
| 170 | 166 |
| 171 // All extensions tested by ExtensionApiTest are in the "api_test" dir. | 167 // All extensions tested by ExtensionApiTest are in the "api_test" dir. |
| 172 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE; | 168 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE; |
| 173 | 169 |
| 174 // If it failed, what was the error message? | 170 // If it failed, what was the error message? |
| 175 std::string message_; | 171 std::string message_; |
| 176 | 172 |
| 177 private: | 173 private: |
| 178 bool RunExtensionTestImpl(const char* extension_name, | 174 bool RunExtensionTestImpl(const char* extension_name, |
| 179 const std::string& test_page, | 175 const std::string& test_page, |
| 180 int flags); | 176 int flags); |
| 181 | 177 |
| 182 // Hold details of the test, set in C++, which can be accessed by | 178 // Hold details of the test, set in C++, which can be accessed by |
| 183 // javascript using chrome.test.getConfig(). | 179 // javascript using chrome.test.getConfig(). |
| 184 scoped_ptr<DictionaryValue> test_config_; | 180 scoped_ptr<DictionaryValue> test_config_; |
| 185 | 181 |
| 186 // Hold the test WebSocket server. | 182 // Hold the test WebSocket server. |
| 187 scoped_ptr<content::TestWebSocketServer> websocket_server_; | 183 scoped_ptr<net::TestServer> websocket_server_; |
| 188 }; | 184 }; |
| 189 | 185 |
| 190 // PlatformAppApiTest sets up the command-line flags necessary for platform | 186 // PlatformAppApiTest sets up the command-line flags necessary for platform |
| 191 // apps (if any). | 187 // apps (if any). |
| 192 class PlatformAppApiTest : public ExtensionApiTest { | 188 class PlatformAppApiTest : public ExtensionApiTest { |
| 193 public: | 189 public: |
| 194 PlatformAppApiTest(); | 190 PlatformAppApiTest(); |
| 195 virtual ~PlatformAppApiTest(); | 191 virtual ~PlatformAppApiTest(); |
| 196 | 192 |
| 197 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE; | 193 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE; |
| 198 }; | 194 }; |
| 199 | 195 |
| 200 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_APITEST_H_ | 196 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_APITEST_H_ |
| OLD | NEW |