OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 "chrome/test/ui_test_utils.h" | 5 #include "chrome/test/ui_test_utils.h" |
6 | 6 |
7 #include "base/json_reader.h" | 7 #include "base/json_reader.h" |
8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
9 #include "base/path_service.h" | 9 #include "base/path_service.h" |
10 #include "chrome/browser/browser.h" | 10 #include "chrome/browser/browser.h" |
11 #include "chrome/browser/dom_operation_notification_details.h" | 11 #include "chrome/browser/dom_operation_notification_details.h" |
12 #include "chrome/browser/tab_contents/navigation_controller.h" | 12 #include "chrome/browser/tab_contents/navigation_controller.h" |
13 #include "chrome/browser/tab_contents/tab_contents.h" | 13 #include "chrome/browser/tab_contents/tab_contents.h" |
14 #include "chrome/common/chrome_paths.h" | 14 #include "chrome/common/chrome_paths.h" |
15 #include "chrome/common/notification_registrar.h" | 15 #include "chrome/common/notification_registrar.h" |
16 #include "chrome/common/notification_service.h" | 16 #include "chrome/common/notification_service.h" |
| 17 #if defined (OS_WIN) |
| 18 #include "views/widget/accelerator_handler.h" |
| 19 #endif |
17 #include "googleurl/src/gurl.h" | 20 #include "googleurl/src/gurl.h" |
18 #include "net/base/net_util.h" | 21 #include "net/base/net_util.h" |
19 #include "views/widget/accelerator_handler.h" | |
20 | 22 |
21 namespace ui_test_utils { | 23 namespace ui_test_utils { |
22 | 24 |
23 namespace { | 25 namespace { |
24 | 26 |
25 // Used to block until a navigation completes. | 27 // Used to block until a navigation completes. |
26 class NavigationNotificationObserver : public NotificationObserver { | 28 class NavigationNotificationObserver : public NotificationObserver { |
27 public: | 29 public: |
28 NavigationNotificationObserver(NavigationController* controller, | 30 NavigationNotificationObserver(NavigationController* controller, |
29 int number_of_navigations) | 31 int number_of_navigations) |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 | 96 |
95 DISALLOW_COPY_AND_ASSIGN(DOMOperationObserver); | 97 DISALLOW_COPY_AND_ASSIGN(DOMOperationObserver); |
96 }; | 98 }; |
97 | 99 |
98 } // namespace | 100 } // namespace |
99 | 101 |
100 void RunMessageLoop() { | 102 void RunMessageLoop() { |
101 MessageLoopForUI* loop = MessageLoopForUI::current(); | 103 MessageLoopForUI* loop = MessageLoopForUI::current(); |
102 bool did_allow_task_nesting = loop->NestableTasksAllowed(); | 104 bool did_allow_task_nesting = loop->NestableTasksAllowed(); |
103 loop->SetNestableTasksAllowed(true); | 105 loop->SetNestableTasksAllowed(true); |
| 106 #if defined (OS_WIN) |
104 views::AcceleratorHandler handler; | 107 views::AcceleratorHandler handler; |
105 loop->Run(&handler); | 108 loop->Run(&handler); |
| 109 #else |
| 110 loop->Run(); |
| 111 #endif |
106 loop->SetNestableTasksAllowed(did_allow_task_nesting); | 112 loop->SetNestableTasksAllowed(did_allow_task_nesting); |
107 } | 113 } |
108 | 114 |
109 void WaitForNavigation(NavigationController* controller) { | 115 void WaitForNavigation(NavigationController* controller) { |
110 WaitForNavigations(controller, 1); | 116 WaitForNavigations(controller, 1); |
111 } | 117 } |
112 | 118 |
113 void WaitForNavigations(NavigationController* controller, | 119 void WaitForNavigations(NavigationController* controller, |
114 int number_of_navigations) { | 120 int number_of_navigations) { |
115 NavigationNotificationObserver observer(controller, number_of_navigations); | 121 NavigationNotificationObserver observer(controller, number_of_navigations); |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 | 201 |
196 GURL GetTestUrl(const std::wstring& dir, const std::wstring file) { | 202 GURL GetTestUrl(const std::wstring& dir, const std::wstring file) { |
197 FilePath path; | 203 FilePath path; |
198 PathService::Get(chrome::DIR_TEST_DATA, &path); | 204 PathService::Get(chrome::DIR_TEST_DATA, &path); |
199 path = path.Append(FilePath::FromWStringHack(dir)); | 205 path = path.Append(FilePath::FromWStringHack(dir)); |
200 path = path.Append(FilePath::FromWStringHack(file)); | 206 path = path.Append(FilePath::FromWStringHack(file)); |
201 return net::FilePathToFileURL(path); | 207 return net::FilePathToFileURL(path); |
202 } | 208 } |
203 | 209 |
204 } // namespace ui_test_utils | 210 } // namespace ui_test_utils |
OLD | NEW |