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

Side by Side Diff: chrome/test/base/chrome_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: Removed accidently added files. 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
« no previous file with comments | « no previous file | chrome/test/base/chrome_test_suite.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <stack> 7 #include <stack>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 24 matching lines...) Expand all
35 35
36 class ChromeTestLauncherDelegate : public test_launcher::TestLauncherDelegate { 36 class ChromeTestLauncherDelegate : public test_launcher::TestLauncherDelegate {
37 public: 37 public:
38 ChromeTestLauncherDelegate() {} 38 ChromeTestLauncherDelegate() {}
39 virtual ~ChromeTestLauncherDelegate() {} 39 virtual ~ChromeTestLauncherDelegate() {}
40 40
41 virtual std::string GetEmptyTestName() OVERRIDE { 41 virtual std::string GetEmptyTestName() OVERRIDE {
42 return kEmptyTestName; 42 return kEmptyTestName;
43 } 43 }
44 44
45 virtual bool Run(int argc, char** argv, int* return_code) OVERRIDE {
46 #if defined(OS_WIN) || defined(OS_LINUX)
47 CommandLine* command_line = CommandLine::ForCurrentProcess();
48 bool launch_chrome =
49 command_line->HasSwitch(switches::kProcessType) ||
50 command_line->HasSwitch(ChromeTestSuite::kLaunchAsBrowser);
51 #endif
52 #if defined(OS_WIN)
53 if (launch_chrome) {
54 sandbox::SandboxInterfaceInfo sandbox_info = {0};
55 content::InitializeSandboxInfo(&sandbox_info);
56 ChromeMainDelegate chrome_main_delegate;
57 *return_code = content::ContentMain(GetModuleHandle(NULL),
58 &sandbox_info,
59 &chrome_main_delegate);
60 return true;
61 }
62 #elif defined(OS_LINUX)
63 if (launch_chrome) {
64 ChromeMainDelegate chrome_main_delegate;
65 *return_code = content::ContentMain(argc,
66 const_cast<const char**>(argv),
67 &chrome_main_delegate);
68 return true;
69 }
70 #endif // defined(OS_WIN)
71
72 return false;
73 }
74
75 virtual int RunTestSuite(int argc, char** argv) OVERRIDE { 45 virtual int RunTestSuite(int argc, char** argv) OVERRIDE {
76 return ChromeTestSuite(argc, argv).Run(); 46 return ChromeTestSuite(argc, argv).Run();
77 } 47 }
78 48
79 virtual bool AdjustChildProcessCommandLine( 49 virtual bool AdjustChildProcessCommandLine(
80 CommandLine* command_line, const FilePath& temp_data_dir) OVERRIDE { 50 CommandLine* command_line, const FilePath& temp_data_dir) OVERRIDE {
81 CommandLine new_command_line(command_line->GetProgram()); 51 CommandLine new_command_line(command_line->GetProgram());
82 CommandLine::SwitchMap switches = command_line->GetSwitches(); 52 CommandLine::SwitchMap switches = command_line->GetSwitches();
83 53
84 // Strip out user-data-dir if present. We will add it back in again later. 54 // Strip out user-data-dir if present. We will add it back in again later.
(...skipping 26 matching lines...) Expand all
111 81
112 virtual void PostRunMessageLoop() { 82 virtual void PostRunMessageLoop() {
113 #if !defined(USE_AURA) && defined(TOOLKIT_VIEWS) 83 #if !defined(USE_AURA) && defined(TOOLKIT_VIEWS)
114 if (content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)) { 84 if (content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)) {
115 DCHECK_EQ(handlers_.empty(), false); 85 DCHECK_EQ(handlers_.empty(), false);
116 handlers_.pop(); 86 handlers_.pop();
117 } 87 }
118 #endif 88 #endif
119 } 89 }
120 90
91 protected:
92 virtual content::ContentMainDelegate* CreateContentMainDelegate() OVERRIDE {
93 #if defined(OS_WIN) || defined (OS_LINUX)
94 return new ChromeMainDelegate();
95 #else
96 // This delegate is only guaranteed to link on linux and windows, so just
97 // bail out if we are on any other platform.
98 NOTREACHED();
99 return NULL;
100 #endif
101 }
102
121 private: 103 private:
122 #if !defined(USE_AURA) && defined(TOOLKIT_VIEWS) 104 #if !defined(USE_AURA) && defined(TOOLKIT_VIEWS)
123 std::stack<linked_ptr<views::AcceleratorHandler> > handlers_; 105 std::stack<linked_ptr<views::AcceleratorHandler> > handlers_;
124 #endif 106 #endif
125 107
126 DISALLOW_COPY_AND_ASSIGN(ChromeTestLauncherDelegate); 108 DISALLOW_COPY_AND_ASSIGN(ChromeTestLauncherDelegate);
127 }; 109 };
128 110
129 int main(int argc, char** argv) { 111 int main(int argc, char** argv) {
130 #if defined(OS_MACOSX) 112 #if defined(OS_MACOSX)
131 chrome_browser_application_mac::RegisterBrowserCrApp(); 113 chrome_browser_application_mac::RegisterBrowserCrApp();
132 #endif 114 #endif
133 ChromeTestLauncherDelegate launcher_delegate; 115 ChromeTestLauncherDelegate launcher_delegate;
134 return test_launcher::LaunchTests(&launcher_delegate, argc, argv); 116 return test_launcher::LaunchTests(&launcher_delegate, argc, argv);
135 } 117 }
OLDNEW
« no previous file with comments | « no previous file | chrome/test/base/chrome_test_suite.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698