| 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 |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 | 57 |
| 58 // Allow manifest versions older that Extension::kModernManifestVersion. | 58 // Allow manifest versions older that Extension::kModernManifestVersion. |
| 59 // Used to test old manifest features. | 59 // Used to test old manifest features. |
| 60 kFlagAllowOldManifestVersions = 1 << 6, | 60 kFlagAllowOldManifestVersions = 1 << 6, |
| 61 }; | 61 }; |
| 62 | 62 |
| 63 ExtensionApiTest(); | 63 ExtensionApiTest(); |
| 64 virtual ~ExtensionApiTest(); | 64 virtual ~ExtensionApiTest(); |
| 65 | 65 |
| 66 protected: | 66 protected: |
| 67 // Helper class that observes tests failing or passing. Observation starts | 67 // InProcessBrowserTest: |
| 68 // when the class is constructed. Get the next result by calling | |
| 69 // GetNextResult() and message() if GetNextResult() return false. If there | |
| 70 // are no results, this method will pump the UI message loop until one is | |
| 71 // received. | |
| 72 // DEPRECATED: Use extensions/test/result_catcher.h instead. | |
| 73 class ResultCatcher : public content::NotificationObserver { | |
| 74 public: | |
| 75 ResultCatcher(); | |
| 76 virtual ~ResultCatcher(); | |
| 77 | |
| 78 // Pumps the UI loop until a notification is received that an API test | |
| 79 // succeeded or failed. Returns true if the test succeeded, false otherwise. | |
| 80 bool GetNextResult(); | |
| 81 | |
| 82 void RestrictToProfile(Profile* profile) { profile_restriction_ = profile; } | |
| 83 | |
| 84 const std::string& message() { return message_; } | |
| 85 | |
| 86 private: | |
| 87 virtual void Observe(int type, | |
| 88 const content::NotificationSource& source, | |
| 89 const content::NotificationDetails& details) OVERRIDE; | |
| 90 | |
| 91 content::NotificationRegistrar registrar_; | |
| 92 | |
| 93 // A sequential list of pass/fail notifications from the test extension(s). | |
| 94 std::deque<bool> results_; | |
| 95 | |
| 96 // If it failed, what was the error message? | |
| 97 std::deque<std::string> messages_; | |
| 98 std::string message_; | |
| 99 | |
| 100 // If non-NULL, we will listen to events from this profile only. | |
| 101 Profile* profile_restriction_; | |
| 102 | |
| 103 // True if we're in a nested message loop waiting for results from | |
| 104 // the extension. | |
| 105 bool waiting_; | |
| 106 }; | |
| 107 | |
| 108 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE; | 68 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE; |
| 109 virtual void TearDownInProcessBrowserTestFixture() OVERRIDE; | 69 virtual void TearDownInProcessBrowserTestFixture() OVERRIDE; |
| 110 | 70 |
| 111 // Load |extension_name| and wait for pass / fail notification. | 71 // Load |extension_name| and wait for pass / fail notification. |
| 112 // |extension_name| is a directory in "test/data/extensions/api_test". | 72 // |extension_name| is a directory in "test/data/extensions/api_test". |
| 113 bool RunExtensionTest(const std::string& extension_name); | 73 bool RunExtensionTest(const std::string& extension_name); |
| 114 | 74 |
| 115 // Same as RunExtensionTest, but enables the extension for incognito mode. | 75 // Same as RunExtensionTest, but enables the extension for incognito mode. |
| 116 bool RunExtensionTestIncognito(const std::string& extension_name); | 76 bool RunExtensionTestIncognito(const std::string& extension_name); |
| 117 | 77 |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 205 scoped_ptr<base::DictionaryValue> test_config_; | 165 scoped_ptr<base::DictionaryValue> test_config_; |
| 206 | 166 |
| 207 // Hold the test WebSocket server. | 167 // Hold the test WebSocket server. |
| 208 scoped_ptr<net::SpawnedTestServer> websocket_server_; | 168 scoped_ptr<net::SpawnedTestServer> websocket_server_; |
| 209 | 169 |
| 210 // Hold the test FTP server. | 170 // Hold the test FTP server. |
| 211 scoped_ptr<net::SpawnedTestServer> ftp_server_; | 171 scoped_ptr<net::SpawnedTestServer> ftp_server_; |
| 212 }; | 172 }; |
| 213 | 173 |
| 214 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_APITEST_H_ | 174 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_APITEST_H_ |
| OLD | NEW |