OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/message_loop.h" | 7 #include "base/message_loop.h" |
8 #include "chrome/browser/browser.h" | 8 #include "chrome/browser/browser.h" |
9 #include "chrome/browser/tab_contents/navigation_controller.h" | 9 #include "chrome/browser/tab_contents/navigation_controller.h" |
10 #include "chrome/browser/tab_contents/web_contents.h" | 10 #include "chrome/browser/tab_contents/web_contents.h" |
11 #include "chrome/common/notification_registrar.h" | 11 #include "chrome/common/notification_registrar.h" |
12 #include "chrome/common/notification_service.h" | 12 #include "chrome/common/notification_service.h" |
| 13 #include "chrome/views/accelerator_handler.h" |
13 #include "googleurl/src/gurl.h" | 14 #include "googleurl/src/gurl.h" |
14 | 15 |
15 namespace ui_test_utils { | 16 namespace ui_test_utils { |
16 | 17 |
17 namespace { | 18 namespace { |
18 | 19 |
19 // Used to block until a navigation completes. | 20 // Used to block until a navigation completes. |
20 class NavigationNotificationObserver : public NotificationObserver { | 21 class NavigationNotificationObserver : public NotificationObserver { |
21 public: | 22 public: |
22 explicit NavigationNotificationObserver(NavigationController* controller) | 23 explicit NavigationNotificationObserver(NavigationController* controller) |
(...skipping 29 matching lines...) Expand all Loading... |
52 | 53 |
53 DISALLOW_COPY_AND_ASSIGN(NavigationNotificationObserver); | 54 DISALLOW_COPY_AND_ASSIGN(NavigationNotificationObserver); |
54 }; | 55 }; |
55 | 56 |
56 } // namespace | 57 } // namespace |
57 | 58 |
58 void RunMessageLoop() { | 59 void RunMessageLoop() { |
59 MessageLoopForUI* loop = MessageLoopForUI::current(); | 60 MessageLoopForUI* loop = MessageLoopForUI::current(); |
60 bool did_allow_task_nesting = loop->NestableTasksAllowed(); | 61 bool did_allow_task_nesting = loop->NestableTasksAllowed(); |
61 loop->SetNestableTasksAllowed(true); | 62 loop->SetNestableTasksAllowed(true); |
62 loop->Run(NULL); | 63 views::AcceleratorHandler handler; |
| 64 loop->Run(&handler); |
63 loop->SetNestableTasksAllowed(did_allow_task_nesting); | 65 loop->SetNestableTasksAllowed(did_allow_task_nesting); |
64 } | 66 } |
65 | 67 |
66 void WaitForNavigation(NavigationController* controller) { | 68 void WaitForNavigation(NavigationController* controller) { |
67 NavigationNotificationObserver observer(controller); | 69 NavigationNotificationObserver observer(controller); |
68 } | 70 } |
69 | 71 |
70 void NavigateToURL(Browser* browser, const GURL& url) { | 72 void NavigateToURL(Browser* browser, const GURL& url) { |
71 NavigationController* controller = | 73 NavigationController* controller = |
72 browser->GetSelectedTabContents()->controller(); | 74 browser->GetSelectedTabContents()->controller(); |
73 browser->OpenURLFromTab(browser->GetSelectedTabContents(), url, GURL(), | 75 browser->OpenURLFromTab(browser->GetSelectedTabContents(), url, GURL(), |
74 CURRENT_TAB, PageTransition::TYPED); | 76 CURRENT_TAB, PageTransition::TYPED); |
75 WaitForNavigation(controller); | 77 WaitForNavigation(controller); |
76 } | 78 } |
77 | 79 |
78 } // namespace ui_test_utils | 80 } // namespace ui_test_utils |
OLD | NEW |