| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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 return new ChromeMainDelegate(); |
| 94 } |
| 95 |
| 121 private: | 96 private: |
| 122 #if !defined(USE_AURA) && defined(TOOLKIT_VIEWS) | 97 #if !defined(USE_AURA) && defined(TOOLKIT_VIEWS) |
| 123 std::stack<linked_ptr<views::AcceleratorHandler> > handlers_; | 98 std::stack<linked_ptr<views::AcceleratorHandler> > handlers_; |
| 124 #endif | 99 #endif |
| 125 | 100 |
| 126 DISALLOW_COPY_AND_ASSIGN(ChromeTestLauncherDelegate); | 101 DISALLOW_COPY_AND_ASSIGN(ChromeTestLauncherDelegate); |
| 127 }; | 102 }; |
| 128 | 103 |
| 129 int main(int argc, char** argv) { | 104 int main(int argc, char** argv) { |
| 130 #if defined(OS_MACOSX) | 105 #if defined(OS_MACOSX) |
| 131 chrome_browser_application_mac::RegisterBrowserCrApp(); | 106 chrome_browser_application_mac::RegisterBrowserCrApp(); |
| 132 #endif | 107 #endif |
| 133 ChromeTestLauncherDelegate launcher_delegate; | 108 ChromeTestLauncherDelegate launcher_delegate; |
| 134 return test_launcher::LaunchTests(&launcher_delegate, argc, argv); | 109 return test_launcher::LaunchTests(&launcher_delegate, argc, argv); |
| 135 } | 110 } |
| OLD | NEW |