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

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

Issue 10826157: Check for warnings when loading extensions in browser tests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix ExtensionTerminalPrivateApiTest.TerminalTest Created 8 years, 4 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 #include "chrome/browser/extensions/extension_apitest.h" 5 #include "chrome/browser/extensions/extension_apitest.h"
6 6
7 #include "base/string_util.h" 7 #include "base/string_util.h"
8 #include "base/stringprintf.h" 8 #include "base/stringprintf.h"
9 #include "chrome/browser/extensions/extension_service.h" 9 #include "chrome/browser/extensions/extension_service.h"
10 #include "chrome/browser/extensions/api/test/test_api.h" 10 #include "chrome/browser/extensions/api/test/test_api.h"
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 114
115 bool ExtensionApiTest::RunExtensionTest(const char* extension_name) { 115 bool ExtensionApiTest::RunExtensionTest(const char* extension_name) {
116 return RunExtensionTestImpl(extension_name, "", kFlagEnableFileAccess); 116 return RunExtensionTestImpl(extension_name, "", kFlagEnableFileAccess);
117 } 117 }
118 118
119 bool ExtensionApiTest::RunExtensionTestIncognito(const char* extension_name) { 119 bool ExtensionApiTest::RunExtensionTestIncognito(const char* extension_name) {
120 return RunExtensionTestImpl( 120 return RunExtensionTestImpl(
121 extension_name, "", kFlagEnableIncognito | kFlagEnableFileAccess); 121 extension_name, "", kFlagEnableIncognito | kFlagEnableFileAccess);
122 } 122 }
123 123
124 bool ExtensionApiTest::RunExtensionTestIgnoreManifestWarnings(
125 const char* extension_name) {
126 return RunExtensionTestImpl(
127 extension_name, "", kFlagEnableFileAccess | kFlagIgnoreManifestWarnings);
128 }
129
124 bool ExtensionApiTest::RunComponentExtensionTest(const char* extension_name) { 130 bool ExtensionApiTest::RunComponentExtensionTest(const char* extension_name) {
125 return RunExtensionTestImpl( 131 return RunExtensionTestImpl(
126 extension_name, "", kFlagEnableFileAccess | kFlagLoadAsComponent); 132 extension_name, "", kFlagEnableFileAccess | kFlagLoadAsComponent);
127 } 133 }
128 134
129 bool ExtensionApiTest::RunExtensionTestNoFileAccess( 135 bool ExtensionApiTest::RunExtensionTestNoFileAccess(
130 const char* extension_name) { 136 const char* extension_name) {
131 return RunExtensionTestImpl(extension_name, "", kFlagNone); 137 return RunExtensionTestImpl(extension_name, "", kFlagNone);
132 } 138 }
133 139
(...skipping 26 matching lines...) Expand all
160 166
161 bool ExtensionApiTest::RunPlatformAppTest(const char* extension_name) { 167 bool ExtensionApiTest::RunPlatformAppTest(const char* extension_name) {
162 return RunExtensionTestImpl(extension_name, "", kFlagLaunchPlatformApp); 168 return RunExtensionTestImpl(extension_name, "", kFlagLaunchPlatformApp);
163 } 169 }
164 170
165 // Load |extension_name| extension and/or |page_url| and wait for 171 // Load |extension_name| extension and/or |page_url| and wait for
166 // PASSED or FAILED notification. 172 // PASSED or FAILED notification.
167 bool ExtensionApiTest::RunExtensionTestImpl(const char* extension_name, 173 bool ExtensionApiTest::RunExtensionTestImpl(const char* extension_name,
168 const std::string& page_url, 174 const std::string& page_url,
169 int flags) { 175 int flags) {
170 bool enable_incognito = (flags & kFlagEnableIncognito) != 0;
171 bool enable_fileaccess = (flags & kFlagEnableFileAccess) != 0;
172 bool load_as_component = (flags & kFlagLoadAsComponent) != 0; 176 bool load_as_component = (flags & kFlagLoadAsComponent) != 0;
173 bool launch_platform_app = (flags & kFlagLaunchPlatformApp) != 0; 177 bool launch_platform_app = (flags & kFlagLaunchPlatformApp) != 0;
174 bool use_incognito = (flags & kFlagUseIncognito) != 0; 178 bool use_incognito = (flags & kFlagUseIncognito) != 0;
175 179
176 ResultCatcher catcher; 180 ResultCatcher catcher;
177 DCHECK(!std::string(extension_name).empty() || !page_url.empty()) << 181 DCHECK(!std::string(extension_name).empty() || !page_url.empty()) <<
178 "extension_name and page_url cannot both be empty"; 182 "extension_name and page_url cannot both be empty";
179 183
180 const extensions::Extension* extension = NULL; 184 const extensions::Extension* extension = NULL;
181 if (!std::string(extension_name).empty()) { 185 if (!std::string(extension_name).empty()) {
182 FilePath extension_path = test_data_dir_.AppendASCII(extension_name); 186 FilePath extension_path = test_data_dir_.AppendASCII(extension_name);
183 if (load_as_component) { 187 if (load_as_component) {
184 extension = LoadExtensionAsComponent(extension_path); 188 extension = LoadExtensionAsComponent(extension_path);
185 } else { 189 } else {
186 extension = LoadExtensionWithOptions(extension_path, 190 int browser_test_flags = ExtensionBrowserTest::kFlagNone;
187 enable_incognito, enable_fileaccess); 191 if (flags & kFlagEnableIncognito)
192 browser_test_flags |= ExtensionBrowserTest::kFlagEnableIncognito;
193 if (flags & kFlagEnableFileAccess)
194 browser_test_flags |= ExtensionBrowserTest::kFlagEnableFileAccess;
195 if (flags & kFlagIgnoreManifestWarnings)
196 browser_test_flags |= ExtensionBrowserTest::kFlagIgnoreManifestWarnings;
197 extension = LoadExtensionWithFlags(extension_path, browser_test_flags);
188 } 198 }
189 if (!extension) { 199 if (!extension) {
190 message_ = "Failed to load extension."; 200 message_ = "Failed to load extension.";
191 return false; 201 return false;
192 } 202 }
193 } 203 }
194 204
195 // If there is a page_url to load, navigate it. 205 // If there is a page_url to load, navigate it.
196 if (!page_url.empty()) { 206 if (!page_url.empty()) {
197 GURL url = GURL(page_url); 207 GURL url = GURL(page_url);
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
291 301
292 void PlatformAppApiTest::SetUpCommandLine(CommandLine* command_line) { 302 void PlatformAppApiTest::SetUpCommandLine(CommandLine* command_line) {
293 ExtensionApiTest::SetUpCommandLine(command_line); 303 ExtensionApiTest::SetUpCommandLine(command_line);
294 304
295 // If someone is using this class, we're going to insist on management of the 305 // If someone is using this class, we're going to insist on management of the
296 // relevant flags. If these flags are already set, die. 306 // relevant flags. If these flags are already set, die.
297 DCHECK(!command_line->HasSwitch(switches::kEnableExperimentalExtensionApis)); 307 DCHECK(!command_line->HasSwitch(switches::kEnableExperimentalExtensionApis));
298 308
299 command_line->AppendSwitch(switches::kEnableExperimentalExtensionApis); 309 command_line->AppendSwitch(switches::kEnableExperimentalExtensionApis);
300 } 310 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_apitest.h ('k') | chrome/browser/extensions/extension_browsertest.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698