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/file_util.h" | 10 #include "base/file_util.h" |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 class ChromeTestLauncherDelegate : public content::TestLauncherDelegate { | 52 class ChromeTestLauncherDelegate : public content::TestLauncherDelegate { |
53 public: | 53 public: |
54 ChromeTestLauncherDelegate() {} | 54 ChromeTestLauncherDelegate() {} |
55 virtual ~ChromeTestLauncherDelegate() {} | 55 virtual ~ChromeTestLauncherDelegate() {} |
56 | 56 |
57 virtual std::string GetEmptyTestName() OVERRIDE { | 57 virtual std::string GetEmptyTestName() OVERRIDE { |
58 return kEmptyTestName; | 58 return kEmptyTestName; |
59 } | 59 } |
60 | 60 |
61 virtual int RunTestSuite(int argc, char** argv) OVERRIDE { | 61 virtual int RunTestSuite(int argc, char** argv) OVERRIDE { |
62 content::AddPreRunMessageLoopHook(base::Bind( | |
63 &ChromeTestLauncherDelegate::PreRunMessageLoop, | |
64 base::Unretained(this))); | |
65 content::AddPostRunMessageLoopHook(base::Bind( | |
66 &ChromeTestLauncherDelegate::PostRunMessageLoop, | |
67 base::Unretained(this))); | |
68 return ChromeTestSuite(argc, argv).Run(); | 62 return ChromeTestSuite(argc, argv).Run(); |
69 } | 63 } |
70 | 64 |
71 virtual bool AdjustChildProcessCommandLine( | 65 virtual bool AdjustChildProcessCommandLine( |
72 CommandLine* command_line, const base::FilePath& temp_data_dir) OVERRIDE { | 66 CommandLine* command_line, const base::FilePath& temp_data_dir) OVERRIDE { |
73 CommandLine new_command_line(command_line->GetProgram()); | 67 CommandLine new_command_line(command_line->GetProgram()); |
74 CommandLine::SwitchMap switches = command_line->GetSwitches(); | 68 CommandLine::SwitchMap switches = command_line->GetSwitches(); |
75 | 69 |
76 // Strip out user-data-dir if present. We will add it back in again later. | 70 // Strip out user-data-dir if present. We will add it back in again later. |
77 switches.erase(switches::kUserDataDir); | 71 switches.erase(switches::kUserDataDir); |
78 | 72 |
79 for (CommandLine::SwitchMap::const_iterator iter = switches.begin(); | 73 for (CommandLine::SwitchMap::const_iterator iter = switches.begin(); |
80 iter != switches.end(); ++iter) { | 74 iter != switches.end(); ++iter) { |
81 new_command_line.AppendSwitchNative((*iter).first, (*iter).second); | 75 new_command_line.AppendSwitchNative((*iter).first, (*iter).second); |
82 } | 76 } |
83 | 77 |
84 new_command_line.AppendSwitchPath(switches::kUserDataDir, temp_data_dir); | 78 new_command_line.AppendSwitchPath(switches::kUserDataDir, temp_data_dir); |
85 | 79 |
86 // file:// access for ChromeOS. | 80 // file:// access for ChromeOS. |
87 new_command_line.AppendSwitch(switches::kAllowFileAccess); | 81 new_command_line.AppendSwitch(switches::kAllowFileAccess); |
88 | 82 |
89 *command_line = new_command_line; | 83 *command_line = new_command_line; |
90 return true; | 84 return true; |
91 } | 85 } |
92 | 86 |
93 void PreRunMessageLoop(base::RunLoop* run_loop) { | 87 virtual void PreRunMessageLoop(base::RunLoop* run_loop) OVERRIDE { |
94 // TODO(phajdan.jr): Remove message loop hooks after switch to Aura. | |
95 // This includes removing content::Add{Pre,Post}RunMessageLoopHook. | |
96 #if !defined(USE_AURA) && defined(TOOLKIT_VIEWS) | 88 #if !defined(USE_AURA) && defined(TOOLKIT_VIEWS) |
97 if (content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)) { | 89 if (content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)) { |
98 linked_ptr<views::AcceleratorHandler> handler( | 90 linked_ptr<views::AcceleratorHandler> handler( |
99 new views::AcceleratorHandler); | 91 new views::AcceleratorHandler); |
100 handlers_.push(handler); | 92 handlers_.push(handler); |
101 run_loop->set_dispatcher(handler.get()); | 93 run_loop->set_dispatcher(handler.get()); |
102 } | 94 } |
103 #endif | 95 #endif |
104 } | 96 } |
105 | 97 |
106 void PostRunMessageLoop(base::RunLoop* run_loop) { | 98 virtual void PostRunMessageLoop() OVERRIDE { |
107 // TODO(phajdan.jr): Remove message loop hooks after switch to Aura. | |
108 // This includes removing content::Add{Pre,Post}RunMessageLoopHook. | |
109 #if !defined(USE_AURA) && defined(TOOLKIT_VIEWS) | 99 #if !defined(USE_AURA) && defined(TOOLKIT_VIEWS) |
110 if (content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)) { | 100 if (content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)) { |
111 DCHECK_EQ(handlers_.empty(), false); | 101 DCHECK_EQ(handlers_.empty(), false); |
112 handlers_.pop(); | 102 handlers_.pop(); |
113 } | 103 } |
114 #endif | 104 #endif |
115 } | 105 } |
116 | 106 |
117 | |
118 protected: | 107 protected: |
119 virtual content::ContentMainDelegate* CreateContentMainDelegate() OVERRIDE { | 108 virtual content::ContentMainDelegate* CreateContentMainDelegate() OVERRIDE { |
120 #if defined(OS_WIN) || defined (OS_LINUX) | 109 #if defined(OS_WIN) || defined (OS_LINUX) |
121 return new ChromeMainDelegate(); | 110 return new ChromeMainDelegate(); |
122 #else | 111 #else |
123 // This delegate is only guaranteed to link on linux and windows, so just | 112 // This delegate is only guaranteed to link on linux and windows, so just |
124 // bail out if we are on any other platform. | 113 // bail out if we are on any other platform. |
125 NOTREACHED(); | 114 NOTREACHED(); |
126 return NULL; | 115 return NULL; |
127 #endif | 116 #endif |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 #elif defined(USE_AURA) | 153 #elif defined(USE_AURA) |
165 // TODO(win_ash): when running interactive_ui_tests for Win Ash, use above. | 154 // TODO(win_ash): when running interactive_ui_tests for Win Ash, use above. |
166 ui_controls::InstallUIControlsAura(aura::test::CreateUIControlsAura(NULL)); | 155 ui_controls::InstallUIControlsAura(aura::test::CreateUIControlsAura(NULL)); |
167 #endif | 156 #endif |
168 | 157 |
169 #endif | 158 #endif |
170 | 159 |
171 ChromeTestLauncherDelegate launcher_delegate; | 160 ChromeTestLauncherDelegate launcher_delegate; |
172 return content::LaunchTests(&launcher_delegate, argc, argv); | 161 return content::LaunchTests(&launcher_delegate, argc, argv); |
173 } | 162 } |
OLD | NEW |