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

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

Issue 9837045: Expand usage of platform-apps flag and permission features. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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 #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/extension_test_api.h" 10 #include "chrome/browser/extensions/extension_test_api.h"
11 #include "chrome/browser/extensions/unpacked_installer.h"
12 #include "chrome/browser/profiles/profile.h"
11 #include "chrome/browser/profiles/profile.h" 13 #include "chrome/browser/profiles/profile.h"
12 #include "chrome/browser/ui/browser.h" 14 #include "chrome/browser/ui/browser.h"
13 #include "chrome/common/chrome_notification_types.h" 15 #include "chrome/common/chrome_notification_types.h"
16 #include "chrome/common/chrome_switches.h"
14 #include "chrome/test/base/ui_test_utils.h" 17 #include "chrome/test/base/ui_test_utils.h"
15 #include "content/public/browser/notification_registrar.h" 18 #include "content/public/browser/notification_registrar.h"
16 #include "content/public/browser/notification_service.h" 19 #include "content/public/browser/notification_service.h"
17 #include "net/base/net_util.h" 20 #include "net/base/net_util.h"
18 21
19 namespace { 22 namespace {
20 23
21 const char kTestServerPort[] = "testServer.port"; 24 const char kTestServerPort[] = "testServer.port";
22 const char kTestDataDirectory[] = "testDataDirectory"; 25 const char kTestDataDirectory[] = "testDataDirectory";
23 const char kTestWebSocketPort[] = "testWebSocketPort"; 26 const char kTestWebSocketPort[] = "testWebSocketPort";
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after
286 return false; 289 return false;
287 290
288 test_config_->SetInteger(kTestWebSocketPort, port); 291 test_config_->SetInteger(kTestWebSocketPort, port);
289 return true; 292 return true;
290 } 293 }
291 294
292 void ExtensionApiTest::SetUpCommandLine(CommandLine* command_line) { 295 void ExtensionApiTest::SetUpCommandLine(CommandLine* command_line) {
293 ExtensionBrowserTest::SetUpCommandLine(command_line); 296 ExtensionBrowserTest::SetUpCommandLine(command_line);
294 test_data_dir_ = test_data_dir_.AppendASCII("api_test"); 297 test_data_dir_ = test_data_dir_.AppendASCII("api_test");
295 } 298 }
299
300 PlatformAppApiTest::PlatformAppApiTest()
301 : previous_command_line_(CommandLine::NO_PROGRAM) {}
302
303 PlatformAppApiTest::~PlatformAppApiTest() {}
304
305 void PlatformAppApiTest::SetUpCommandLine(CommandLine* command_line) {
306 ExtensionApiTest::SetUpCommandLine(command_line);
307
308 // If someone is using this class, we're going to insist on management of the
309 // relevant flags. If these flags are already set, die.
310 DCHECK(!command_line->HasSwitch(switches::kEnablePlatformApps));
311 DCHECK(!command_line->HasSwitch(switches::kEnableExperimentalExtensionApis));
312
313 // Squirrel away for potential use in VerifyPermissions.
314 //
315 // TODO(miket): I _could_ just call VerifyPermissions here instead of
316 // requiring everyone who inherits from PlatformAppApiTest to explicitly call
317 // it within a test, but that feels overbearing.
318 previous_command_line_ = *command_line;
319
320 command_line->AppendSwitch(switches::kEnableExperimentalExtensionApis);
321 command_line->AppendSwitch(switches::kEnablePlatformApps);
322 }
323
324 void PlatformAppApiTest::VerifyPermissions(const FilePath& extension_path) {
325 #if defined(OS_WIN)
miket_OOO 2012/03/23 17:12:03 This #ifdef is the only change between this CL and
326 // See http://code.google.com/p/chromium/issues/detail?id=119758.
327 //
328 // TODO(miket): investigate why WaitForExtensionLoadError() doesn't receive
329 // the expected notification on XP/Vista, but succeeds on other platforms.
330 #else
331 CommandLine old_command_line(*CommandLine::ForCurrentProcess());
332 ExtensionService* service = browser()->profile()->GetExtensionService();
333
334 // Neither experimental nor platform-app flag.
335 *CommandLine::ForCurrentProcess() = previous_command_line_;
336 extensions::UnpackedInstaller::Create(service)->Load(extension_path);
337 ASSERT_TRUE(WaitForExtensionLoadError());
338
339 // Only experimental flag.
340 *CommandLine::ForCurrentProcess() = previous_command_line_;
341 CommandLine::ForCurrentProcess()->AppendSwitch(
342 switches::kEnableExperimentalExtensionApis);
343 extensions::UnpackedInstaller::Create(service)->Load(extension_path);
344 ASSERT_TRUE(WaitForExtensionLoadError());
345
346 // Only platform-app flag.
347 *CommandLine::ForCurrentProcess() = previous_command_line_;
348 CommandLine::ForCurrentProcess()->AppendSwitch(
349 switches::kEnablePlatformApps);
350 extensions::UnpackedInstaller::Create(service)->Load(extension_path);
351 ASSERT_TRUE(WaitForExtensionLoadError());
352
353 *CommandLine::ForCurrentProcess() = old_command_line;
354 #endif
355 }
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