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

Side by Side Diff: content/public/test/test_launcher.cc

Issue 10912070: Makes it possible to run content_browsertests with --as-browser and fake WebRTC devices. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 3 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 "content/public/test/test_launcher.h" 5 #include "content/public/test/test_launcher.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/command_line.h" 10 #include "base/command_line.h"
11 #include "base/environment.h" 11 #include "base/environment.h"
12 #include "base/file_util.h" 12 #include "base/file_util.h"
13 #include "base/hash_tables.h" 13 #include "base/hash_tables.h"
14 #include "base/logging.h" 14 #include "base/logging.h"
15 #include "base/memory/linked_ptr.h" 15 #include "base/memory/linked_ptr.h"
16 #include "base/memory/scoped_ptr.h" 16 #include "base/memory/scoped_ptr.h"
17 #include "base/process_util.h" 17 #include "base/process_util.h"
18 #include "base/scoped_temp_dir.h" 18 #include "base/scoped_temp_dir.h"
19 #include "base/string_number_conversions.h" 19 #include "base/string_number_conversions.h"
20 #include "base/string_util.h" 20 #include "base/string_util.h"
21 #include "base/test/test_suite.h" 21 #include "base/test/test_suite.h"
22 #include "base/test/test_timeouts.h" 22 #include "base/test/test_timeouts.h"
23 #include "base/time.h" 23 #include "base/time.h"
24 #include "base/utf_string_conversions.h" 24 #include "base/utf_string_conversions.h"
25 #include "content/public/app/content_main.h"
26 #include "content/public/app/content_main_delegate.h"
25 #include "content/public/app/startup_helper_win.h" 27 #include "content/public/app/startup_helper_win.h"
26 #include "content/public/common/sandbox_init.h" 28 #include "content/public/common/sandbox_init.h"
29 #include "content/public/common/content_switches.h"
27 #include "content/public/test/browser_test.h" 30 #include "content/public/test/browser_test.h"
28 #include "net/base/escape.h" 31 #include "net/base/escape.h"
29 #include "testing/gtest/include/gtest/gtest.h" 32 #include "testing/gtest/include/gtest/gtest.h"
30 33
31 #if defined(OS_WIN) 34 #if defined(OS_WIN)
32 #include "base/base_switches.h" 35 #include "base/base_switches.h"
33 #include "content/common/sandbox_policy.h" 36 #include "content/common/sandbox_policy.h"
34 #include "sandbox/win/src/dep.h" 37 #include "sandbox/win/src/dep.h"
35 #include "sandbox/win/src/sandbox_factory.h" 38 #include "sandbox/win/src/sandbox_factory.h"
36 #include "sandbox/win/src/sandbox_types.h" 39 #include "sandbox/win/src/sandbox_types.h"
(...skipping 599 matching lines...) Expand 10 before | Expand all | Expand 10 after
636 const char kRunManualTestsFlag[] = "run-manual"; 639 const char kRunManualTestsFlag[] = "run-manual";
637 640
638 // The following is kept for historical reasons (so people that are used to 641 // The following is kept for historical reasons (so people that are used to
639 // using it don't get surprised). 642 // using it don't get surprised).
640 const char kChildProcessFlag[] = "child"; 643 const char kChildProcessFlag[] = "child";
641 644
642 const char kHelpFlag[] = "help"; 645 const char kHelpFlag[] = "help";
643 646
644 const char kWarmupFlag[] = "warmup"; 647 const char kWarmupFlag[] = "warmup";
645 648
649 extern const char kLaunchAsBrowser[] = "as-browser";
jam 2012/09/04 15:18:14 nit: no extern
phoglund_chromium 2012/09/05 09:41:05 Done.
650
646 TestLauncherDelegate::~TestLauncherDelegate() { 651 TestLauncherDelegate::~TestLauncherDelegate() {
647 } 652 }
648 653
654 bool TestLauncherDelegate::Run(int argc, char** argv, int* return_code) {
655 #if defined(OS_WIN) || defined(OS_LINUX)
656 CommandLine* command_line = CommandLine::ForCurrentProcess();
657 bool launch_chrome =
jam 2012/09/04 15:18:14 nit: now that this code is in content, launch_chro
phoglund_chromium 2012/09/05 09:41:05 I split this method into two instead, so that vari
658 command_line->HasSwitch(switches::kProcessType) ||
659 command_line->HasSwitch(kLaunchAsBrowser);
660 #endif
661 #if defined(OS_WIN)
662 if (launch_chrome) {
663 sandbox::SandboxInterfaceInfo sandbox_info = {0};
664 content::InitializeSandboxInfo(&sandbox_info);
665 scoped_ptr<content::ContentMainDelegate> chrome_main_delegate(
666 CreateContentMainDelegate());
667 *return_code = content::ContentMain(GetModuleHandle(NULL),
668 &sandbox_info,
669 chrome_main_delegate.get());
670 return true;
671 }
672 #elif defined(OS_LINUX)
673 if (launch_chrome) {
674 scoped_ptr<content::ContentMainDelegate> chrome_main_delegate(
675 CreateContentMainDelegate());
676 *return_code = content::ContentMain(argc,
677 const_cast<const char**>(argv),
678 chrome_main_delegate.get());
679 return true;
680 }
681 #endif // defined(OS_WIN)
682
683 return false;
684 }
685
649 int LaunchTests(TestLauncherDelegate* launcher_delegate, 686 int LaunchTests(TestLauncherDelegate* launcher_delegate,
650 int argc, 687 int argc,
651 char** argv) { 688 char** argv) {
652 DCHECK(!g_launcher_delegate); 689 DCHECK(!g_launcher_delegate);
653 g_launcher_delegate = launcher_delegate; 690 g_launcher_delegate = launcher_delegate;
654 691
655 CommandLine::Init(argc, argv); 692 CommandLine::Init(argc, argv);
656 const CommandLine* command_line = CommandLine::ForCurrentProcess(); 693 const CommandLine* command_line = CommandLine::ForCurrentProcess();
657 694
658 if (command_line->HasSwitch(kHelpFlag)) { 695 if (command_line->HasSwitch(kHelpFlag)) {
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
743 cycles--; 780 cycles--;
744 } 781 }
745 return exit_code; 782 return exit_code;
746 } 783 }
747 784
748 TestLauncherDelegate* GetCurrentTestLauncherDelegate() { 785 TestLauncherDelegate* GetCurrentTestLauncherDelegate() {
749 return g_launcher_delegate; 786 return g_launcher_delegate;
750 } 787 }
751 788
752 } // namespace test_launcher 789 } // namespace test_launcher
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698