| 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/files/file_path.h" | 10 #include "base/files/file_path.h" |
| 11 #include "base/file_util.h" | 11 #include "base/file_util.h" |
| 12 #include "base/logging.h" | 12 #include "base/logging.h" |
| 13 #include "base/memory/linked_ptr.h" | 13 #include "base/memory/linked_ptr.h" |
| 14 #include "base/process_util.h" | 14 #include "base/process_util.h" |
| 15 #include "base/run_loop.h" | 15 #include "base/run_loop.h" |
| 16 #include "base/string_util.h" | 16 #include "base/string_util.h" |
| 17 #include "base/test/test_file_util.h" | 17 #include "base/test/test_file_util.h" |
| 18 #include "chrome/app/chrome_main_delegate.h" | 18 #include "chrome/app/chrome_main_delegate.h" |
| 19 #include "chrome/common/chrome_switches.h" | 19 #include "chrome/common/chrome_switches.h" |
| 20 #include "chrome/common/chrome_constants.h" | 20 #include "chrome/common/chrome_constants.h" |
| 21 #include "chrome/common/chrome_switches.h" | 21 #include "chrome/common/chrome_switches.h" |
| 22 #include "chrome/test/base/chrome_test_suite.h" | 22 #include "chrome/test/base/chrome_test_suite.h" |
| 23 #include "content/public/app/content_main.h" | 23 #include "content/public/app/content_main.h" |
| 24 #include "content/public/browser/browser_thread.h" | 24 #include "content/public/browser/browser_thread.h" |
| 25 #include "content/public/test/test_utils.h" |
| 25 | 26 |
| 26 #if defined(OS_MACOSX) | 27 #if defined(OS_MACOSX) |
| 27 #include "chrome/browser/chrome_browser_application_mac.h" | 28 #include "chrome/browser/chrome_browser_application_mac.h" |
| 28 #endif // defined(OS_MACOSX) | 29 #endif // defined(OS_MACOSX) |
| 29 | 30 |
| 30 #if defined(OS_WIN) | 31 #if defined(OS_WIN) |
| 31 #include "content/public/app/startup_helper_win.h" | 32 #include "content/public/app/startup_helper_win.h" |
| 32 #include "sandbox/win/src/sandbox_types.h" | 33 #include "sandbox/win/src/sandbox_types.h" |
| 33 #endif // defined(OS_WIN) | 34 #endif // defined(OS_WIN) |
| 34 | 35 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 46 class ChromeTestLauncherDelegate : public content::TestLauncherDelegate { | 47 class ChromeTestLauncherDelegate : public content::TestLauncherDelegate { |
| 47 public: | 48 public: |
| 48 ChromeTestLauncherDelegate() {} | 49 ChromeTestLauncherDelegate() {} |
| 49 virtual ~ChromeTestLauncherDelegate() {} | 50 virtual ~ChromeTestLauncherDelegate() {} |
| 50 | 51 |
| 51 virtual std::string GetEmptyTestName() OVERRIDE { | 52 virtual std::string GetEmptyTestName() OVERRIDE { |
| 52 return kEmptyTestName; | 53 return kEmptyTestName; |
| 53 } | 54 } |
| 54 | 55 |
| 55 virtual int RunTestSuite(int argc, char** argv) OVERRIDE { | 56 virtual int RunTestSuite(int argc, char** argv) OVERRIDE { |
| 57 content::AddPreRunMessageLoopHook(base::Bind( |
| 58 &ChromeTestLauncherDelegate::PreRunMessageLoop, |
| 59 base::Unretained(this))); |
| 60 content::AddPostRunMessageLoopHook(base::Bind( |
| 61 &ChromeTestLauncherDelegate::PostRunMessageLoop, |
| 62 base::Unretained(this))); |
| 56 return ChromeTestSuite(argc, argv).Run(); | 63 return ChromeTestSuite(argc, argv).Run(); |
| 57 } | 64 } |
| 58 | 65 |
| 59 virtual bool AdjustChildProcessCommandLine( | 66 virtual bool AdjustChildProcessCommandLine( |
| 60 CommandLine* command_line, const base::FilePath& temp_data_dir) OVERRIDE { | 67 CommandLine* command_line, const base::FilePath& temp_data_dir) OVERRIDE { |
| 61 CommandLine new_command_line(command_line->GetProgram()); | 68 CommandLine new_command_line(command_line->GetProgram()); |
| 62 CommandLine::SwitchMap switches = command_line->GetSwitches(); | 69 CommandLine::SwitchMap switches = command_line->GetSwitches(); |
| 63 | 70 |
| 64 // Strip out user-data-dir if present. We will add it back in again later. | 71 // Strip out user-data-dir if present. We will add it back in again later. |
| 65 switches.erase(switches::kUserDataDir); | 72 switches.erase(switches::kUserDataDir); |
| 66 | 73 |
| 67 for (CommandLine::SwitchMap::const_iterator iter = switches.begin(); | 74 for (CommandLine::SwitchMap::const_iterator iter = switches.begin(); |
| 68 iter != switches.end(); ++iter) { | 75 iter != switches.end(); ++iter) { |
| 69 new_command_line.AppendSwitchNative((*iter).first, (*iter).second); | 76 new_command_line.AppendSwitchNative((*iter).first, (*iter).second); |
| 70 } | 77 } |
| 71 | 78 |
| 72 new_command_line.AppendSwitchPath(switches::kUserDataDir, temp_data_dir); | 79 new_command_line.AppendSwitchPath(switches::kUserDataDir, temp_data_dir); |
| 73 | 80 |
| 74 // file:// access for ChromeOS. | 81 // file:// access for ChromeOS. |
| 75 new_command_line.AppendSwitch(switches::kAllowFileAccess); | 82 new_command_line.AppendSwitch(switches::kAllowFileAccess); |
| 76 | 83 |
| 77 *command_line = new_command_line; | 84 *command_line = new_command_line; |
| 78 return true; | 85 return true; |
| 79 } | 86 } |
| 80 | 87 |
| 81 virtual void PreRunMessageLoop(base::RunLoop* run_loop) OVERRIDE { | 88 void PreRunMessageLoop(base::RunLoop* run_loop) { |
| 89 // TODO(phajdan.jr): Remove message loop hooks after switch to Aura. |
| 90 // This includes removing content::Add{Pre,Post}RunMessageLoopHook. |
| 82 #if !defined(USE_AURA) && defined(TOOLKIT_VIEWS) | 91 #if !defined(USE_AURA) && defined(TOOLKIT_VIEWS) |
| 83 if (content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)) { | 92 if (content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)) { |
| 84 linked_ptr<views::AcceleratorHandler> handler( | 93 linked_ptr<views::AcceleratorHandler> handler( |
| 85 new views::AcceleratorHandler); | 94 new views::AcceleratorHandler); |
| 86 handlers_.push(handler); | 95 handlers_.push(handler); |
| 87 run_loop->set_dispatcher(handler.get()); | 96 run_loop->set_dispatcher(handler.get()); |
| 88 } | 97 } |
| 89 #endif | 98 #endif |
| 90 } | 99 } |
| 91 | 100 |
| 92 virtual void PostRunMessageLoop() OVERRIDE { | 101 void PostRunMessageLoop(base::RunLoop* run_loop) { |
| 102 // TODO(phajdan.jr): Remove message loop hooks after switch to Aura. |
| 103 // This includes removing content::Add{Pre,Post}RunMessageLoopHook. |
| 93 #if !defined(USE_AURA) && defined(TOOLKIT_VIEWS) | 104 #if !defined(USE_AURA) && defined(TOOLKIT_VIEWS) |
| 94 if (content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)) { | 105 if (content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)) { |
| 95 DCHECK_EQ(handlers_.empty(), false); | 106 DCHECK_EQ(handlers_.empty(), false); |
| 96 handlers_.pop(); | 107 handlers_.pop(); |
| 97 } | 108 } |
| 98 #endif | 109 #endif |
| 99 } | 110 } |
| 100 | 111 |
| 112 |
| 101 protected: | 113 protected: |
| 102 virtual content::ContentMainDelegate* CreateContentMainDelegate() OVERRIDE { | 114 virtual content::ContentMainDelegate* CreateContentMainDelegate() OVERRIDE { |
| 103 #if defined(OS_WIN) || defined (OS_LINUX) | 115 #if defined(OS_WIN) || defined (OS_LINUX) |
| 104 return new ChromeMainDelegate(); | 116 return new ChromeMainDelegate(); |
| 105 #else | 117 #else |
| 106 // This delegate is only guaranteed to link on linux and windows, so just | 118 // This delegate is only guaranteed to link on linux and windows, so just |
| 107 // bail out if we are on any other platform. | 119 // bail out if we are on any other platform. |
| 108 NOTREACHED(); | 120 NOTREACHED(); |
| 109 return NULL; | 121 return NULL; |
| 110 #endif | 122 #endif |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 #elif defined(USE_AURA) | 158 #elif defined(USE_AURA) |
| 147 // TODO(win_ash): when running interactive_ui_tests for Win Ash, use above. | 159 // TODO(win_ash): when running interactive_ui_tests for Win Ash, use above. |
| 148 ui_controls::InstallUIControlsAura(ui_controls::CreateUIControlsAura(NULL)); | 160 ui_controls::InstallUIControlsAura(ui_controls::CreateUIControlsAura(NULL)); |
| 149 #endif | 161 #endif |
| 150 | 162 |
| 151 #endif | 163 #endif |
| 152 | 164 |
| 153 ChromeTestLauncherDelegate launcher_delegate; | 165 ChromeTestLauncherDelegate launcher_delegate; |
| 154 return content::LaunchTests(&launcher_delegate, argc, argv); | 166 return content::LaunchTests(&launcher_delegate, argc, argv); |
| 155 } | 167 } |
| OLD | NEW |