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 "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/run_loop.h" |
9 #include "base/scoped_temp_dir.h" | 10 #include "base/scoped_temp_dir.h" |
10 #include "base/test/test_file_util.h" | 11 #include "base/test/test_file_util.h" |
11 #include "chrome/app/chrome_main_delegate.h" | 12 #include "chrome/app/chrome_main_delegate.h" |
12 #include "chrome/common/chrome_switches.h" | 13 #include "chrome/common/chrome_switches.h" |
13 #include "chrome/common/chrome_constants.h" | 14 #include "chrome/common/chrome_constants.h" |
14 #include "chrome/test/base/chrome_test_suite.h" | 15 #include "chrome/test/base/chrome_test_suite.h" |
15 #include "content/public/app/content_main.h" | 16 #include "content/public/app/content_main.h" |
| 17 #include "content/public/browser/browser_thread.h" |
16 | 18 |
17 #if defined(OS_MACOSX) | 19 #if defined(OS_MACOSX) |
18 #include "chrome/browser/chrome_browser_application_mac.h" | 20 #include "chrome/browser/chrome_browser_application_mac.h" |
19 #endif // defined(OS_MACOSX) | 21 #endif // defined(OS_MACOSX) |
20 | 22 |
21 #if defined(OS_WIN) | 23 #if defined(OS_WIN) |
22 #include "content/public/app/startup_helper_win.h" | 24 #include "content/public/app/startup_helper_win.h" |
23 #include "sandbox/src/sandbox_types.h" | 25 #include "sandbox/src/sandbox_types.h" |
24 #endif // defined(OS_WIN) | 26 #endif // defined(OS_WIN) |
25 | 27 |
| 28 #if defined(TOOLKIT_VIEWS) |
| 29 #include "ui/views/focus/accelerator_handler.h" |
| 30 #endif |
| 31 |
26 class ChromeTestLauncherDelegate : public test_launcher::TestLauncherDelegate { | 32 class ChromeTestLauncherDelegate : public test_launcher::TestLauncherDelegate { |
27 public: | 33 public: |
28 ChromeTestLauncherDelegate() { | 34 ChromeTestLauncherDelegate() { |
29 } | 35 } |
30 | 36 |
31 virtual ~ChromeTestLauncherDelegate() { | 37 virtual ~ChromeTestLauncherDelegate() { |
32 } | 38 } |
33 | 39 |
34 virtual void EarlyInitialize() OVERRIDE { | 40 virtual void EarlyInitialize() OVERRIDE { |
35 #if defined(OS_MACOSX) | 41 #if defined(OS_MACOSX) |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 } | 105 } |
100 new_command_line.AppendSwitchPath(switches::kUserDataDir, temp_dir_.path()); | 106 new_command_line.AppendSwitchPath(switches::kUserDataDir, temp_dir_.path()); |
101 | 107 |
102 // file:// access for ChromeOS. | 108 // file:// access for ChromeOS. |
103 new_command_line.AppendSwitch(switches::kAllowFileAccess); | 109 new_command_line.AppendSwitch(switches::kAllowFileAccess); |
104 | 110 |
105 *command_line = new_command_line; | 111 *command_line = new_command_line; |
106 return true; | 112 return true; |
107 } | 113 } |
108 | 114 |
| 115 virtual void PreRunMessageLoop(base::RunLoop* run_loop) OVERRIDE { |
| 116 #if !defined(USE_AURA) && defined(TOOLKIT_VIEWS) |
| 117 DCHECK(!handler_.get()); |
| 118 if (content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)) { |
| 119 handler_.reset(new views::AcceleratorHandler); |
| 120 run_loop->set_dispatcher(handler_.get()); |
| 121 } |
| 122 #endif |
| 123 } |
| 124 |
| 125 virtual void PostRunMessageLoop() { |
| 126 #if !defined(USE_AURA) && defined(TOOLKIT_VIEWS) |
| 127 handler_.reset(); |
| 128 #endif |
| 129 } |
| 130 |
109 private: | 131 private: |
110 ScopedTempDir temp_dir_; | 132 ScopedTempDir temp_dir_; |
111 | 133 |
| 134 #if !defined(USE_AURA) && defined(TOOLKIT_VIEWS) |
| 135 scoped_ptr<views::AcceleratorHandler> handler_; |
| 136 #endif |
| 137 |
112 DISALLOW_COPY_AND_ASSIGN(ChromeTestLauncherDelegate); | 138 DISALLOW_COPY_AND_ASSIGN(ChromeTestLauncherDelegate); |
113 }; | 139 }; |
114 | 140 |
115 int main(int argc, char** argv) { | 141 int main(int argc, char** argv) { |
116 ChromeTestLauncherDelegate launcher_delegate; | 142 ChromeTestLauncherDelegate launcher_delegate; |
117 return test_launcher::LaunchTests(&launcher_delegate, argc, argv); | 143 return test_launcher::LaunchTests(&launcher_delegate, argc, argv); |
118 } | 144 } |
OLD | NEW |