Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(65)

Side by Side Diff: chrome/browser/extensions/extension_apitest.h

Issue 9737001: Fix crash in AppNotifyChannelSetup when incognito profiles are used. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: forgot a file Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 #pragma once 7 #pragma once
8 8
9 #include <deque> 9 #include <deque>
10 #include <string> 10 #include <string>
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 std::string message_; 69 std::string message_;
70 70
71 // If non-NULL, we will listen to events from this profile only. 71 // If non-NULL, we will listen to events from this profile only.
72 Profile* profile_restriction_; 72 Profile* profile_restriction_;
73 73
74 // True if we're in a nested message loop waiting for results from 74 // True if we're in a nested message loop waiting for results from
75 // the extension. 75 // the extension.
76 bool waiting_; 76 bool waiting_;
77 }; 77 };
78 78
79 // Flags used to configure how the tests are run.
80 enum Flags {
81 kFlagNone = 0,
82
83 // Allow the extension to run in incognito mode.
84 kFlagEnableIncognito = 1 << 0,
85
86 // Launch the test page in an incognito window.
87 kFlagUseIncognito = 1 << 1,
88
89 // Allow file access for the extension.
90 kFlagEnableFileAccess = 1 << 2,
91
92 // Loads the extension with location COMPONENT.
93 kFlagLoadAsComponent = 1 << 3,
94
95 // Launch the extension in a platform app shell.
96 kFlagLaunchAppShell = 1 << 4
97 };
98
79 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE; 99 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE;
80 virtual void TearDownInProcessBrowserTestFixture() OVERRIDE; 100 virtual void TearDownInProcessBrowserTestFixture() OVERRIDE;
81 101
82 // Load |extension_name| and wait for pass / fail notification. 102 // Load |extension_name| and wait for pass / fail notification.
83 // |extension_name| is a directory in "test/data/extensions/api_test". 103 // |extension_name| is a directory in "test/data/extensions/api_test".
84 bool RunExtensionTest(const char* extension_name); 104 bool RunExtensionTest(const char* extension_name);
85 105
86 // Same as RunExtensionTest, but enables the extension for incognito mode. 106 // Same as RunExtensionTest, but enables the extension for incognito mode.
87 bool RunExtensionTestIncognito(const char* extension_name); 107 bool RunExtensionTestIncognito(const char* extension_name);
88 108
89 // Same as RunExtensionTest, but loads extension as component. 109 // Same as RunExtensionTest, but loads extension as component.
90 bool RunComponentExtensionTest(const char* extension_name); 110 bool RunComponentExtensionTest(const char* extension_name);
91 111
92 // Same as RunExtensionTest, but disables file access. 112 // Same as RunExtensionTest, but disables file access.
93 bool RunExtensionTestNoFileAccess(const char* extension_name); 113 bool RunExtensionTestNoFileAccess(const char* extension_name);
94 114
95 // Same as RunExtensionTestIncognito, but disables file access. 115 // Same as RunExtensionTestIncognito, but disables file access.
96 bool RunExtensionTestIncognitoNoFileAccess(const char* extension_name); 116 bool RunExtensionTestIncognitoNoFileAccess(const char* extension_name);
97 117
98 // If not empty, Load |extension_name|, load |page_url| and wait for pass / 118 // If not empty, Load |extension_name|, load |page_url| and wait for pass /
99 // fail notification from the extension API on the page. Note that if 119 // fail notification from the extension API on the page. Note that if
100 // |page_url| is not a valid url, it will be treated as a resource within 120 // |page_url| is not a valid url, it will be treated as a resource within
101 // the extension. |extension_name| is a directory in 121 // the extension. |extension_name| is a directory in
102 // "test/data/extensions/api_test". 122 // "test/data/extensions/api_test".
103 bool RunExtensionSubtest(const char* extension_name, 123 bool RunExtensionSubtest(const char* extension_name,
104 const std::string& page_url); 124 const std::string& page_url);
105 125
106 // Same as RunExtensionSubtest, but loads extension as component. 126 // Same as RunExtensionSubtest, except run with the specific |flags|.
107 bool RunComponentExtensionSubtest(const char* extension_name, 127 bool RunExtensionSubtest(const char* extension_name,
108 const std::string& page_url); 128 const std::string& page_url,
109 129 int flags);
110 // Same as RunExtensionSubtest, but disables file access.
111 bool RunExtensionSubtestNoFileAccess(const char* extension_name,
112 const std::string& page_url);
113
114 // Same as RunExtensionSubtest, but enables the extension for incognito mode.
115 bool RunExtensionSubtestIncognito(const char* extension_name,
116 const std::string& page_url);
117
118 // Same as RunExtensionSubtestIncognito, but disables file access.
119 bool RunExtensionSubtestIncognitoNoFileAccess(const char* extension_name,
120 const std::string& page_url);
121 130
122 // Load |page_url| and wait for pass / fail notification from the extension 131 // Load |page_url| and wait for pass / fail notification from the extension
123 // API on the page. 132 // API on the page.
124 bool RunPageTest(const std::string& page_url); 133 bool RunPageTest(const std::string& page_url);
125 134
126 // Similar to RunExtensionTest, except used for running tests in platform app 135 // Similar to RunExtensionTest, except used for running tests in platform app
127 // shell windows. 136 // shell windows.
128 bool RunPlatformAppTest(const char* extension_name); 137 bool RunPlatformAppTest(const char* extension_name);
129 138
130 // Start the test server, and store details of its state. Those details 139 // Start the test server, and store details of its state. Those details
131 // will be available to javascript tests using chrome.test.getConfig(). 140 // will be available to javascript tests using chrome.test.getConfig().
132 bool StartTestServer(); 141 bool StartTestServer();
133 142
134 // Start the test WebSocket server, and store details of its state. Those 143 // Start the test WebSocket server, and store details of its state. Those
135 // details will be available to javascript tests using 144 // details will be available to javascript tests using
136 // chrome.test.getConfig(). 145 // chrome.test.getConfig().
137 bool StartWebSocketServer(const FilePath& root_directory); 146 bool StartWebSocketServer(const FilePath& root_directory);
138 147
139 // Test that exactly one extension loaded. If so, return a pointer to 148 // Test that exactly one extension loaded. If so, return a pointer to
140 // the extension. If not, return NULL and set message_. 149 // the extension. If not, return NULL and set message_.
141 const Extension* GetSingleLoadedExtension(); 150 const Extension* GetSingleLoadedExtension();
142 151
143 // All extensions tested by ExtensionApiTest are in the "api_test" dir. 152 // All extensions tested by ExtensionApiTest are in the "api_test" dir.
144 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE; 153 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE;
145 154
146 // If it failed, what was the error message? 155 // If it failed, what was the error message?
147 std::string message_; 156 std::string message_;
148 157
149 private: 158 private:
150 enum Flags {
151 kFlagNone = 0,
152 kFlagEnableIncognito = 1 << 0,
153 kFlagEnableFileAccess = 1 << 1,
154 kFlagLoadAsComponent = 1 << 2,
155 kFlagLaunchAppShell = 1 << 3
156 };
157 bool RunExtensionTestImpl(const char* extension_name, 159 bool RunExtensionTestImpl(const char* extension_name,
158 const std::string& test_page, 160 const std::string& test_page,
159 int flags); 161 int flags);
160 162
161 // Hold details of the test, set in C++, which can be accessed by 163 // Hold details of the test, set in C++, which can be accessed by
162 // javascript using chrome.test.getConfig(). 164 // javascript using chrome.test.getConfig().
163 scoped_ptr<DictionaryValue> test_config_; 165 scoped_ptr<DictionaryValue> test_config_;
164 166
165 // Hold the test WebSocket server. 167 // Hold the test WebSocket server.
166 scoped_ptr<ui_test_utils::TestWebSocketServer> websocket_server_; 168 scoped_ptr<ui_test_utils::TestWebSocketServer> websocket_server_;
167 }; 169 };
168 170
169 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_APITEST_H_ 171 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_APITEST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698