OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "ui/views/controls/menu/menu_controller.h" | 5 #include "ui/views/controls/menu/menu_controller.h" |
6 | 6 |
7 #include "base/run_loop.h" | 7 #include "base/run_loop.h" |
8 #include "ui/aura/scoped_window_targeter.h" | 8 #include "ui/aura/scoped_window_targeter.h" |
9 #include "ui/aura/window.h" | 9 #include "ui/aura/window.h" |
10 #include "ui/events/event_targeter.h" | 10 #include "ui/events/event_targeter.h" |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 class TestDispatcherClient : public aura::client::DispatcherClient { | 67 class TestDispatcherClient : public aura::client::DispatcherClient { |
68 public: | 68 public: |
69 TestDispatcherClient() : dispatcher_(NULL) {} | 69 TestDispatcherClient() : dispatcher_(NULL) {} |
70 virtual ~TestDispatcherClient() {} | 70 virtual ~TestDispatcherClient() {} |
71 | 71 |
72 base::MessagePumpDispatcher* dispatcher() { | 72 base::MessagePumpDispatcher* dispatcher() { |
73 return dispatcher_; | 73 return dispatcher_; |
74 } | 74 } |
75 | 75 |
76 // aura::client::DispatcherClient: | 76 // aura::client::DispatcherClient: |
77 virtual void RunWithDispatcher( | 77 virtual void PrepareNestedLoopClosures( |
78 base::MessagePumpDispatcher* dispatcher) OVERRIDE { | 78 base::MessagePumpDispatcher* dispatcher, |
| 79 base::Closure* run_closure, |
| 80 base::Closure* quit_closure) OVERRIDE { |
| 81 scoped_ptr<base::RunLoop> run_loop(new base::RunLoop()); |
| 82 *quit_closure = run_loop->QuitClosure(); |
| 83 *run_closure = base::Bind(&TestDispatcherClient::RunNestedDispatcher, |
| 84 base::Unretained(this), |
| 85 base::Passed(&run_loop), |
| 86 dispatcher); |
| 87 } |
| 88 |
| 89 private: |
| 90 void RunNestedDispatcher(scoped_ptr<base::RunLoop> run_loop, |
| 91 base::MessagePumpDispatcher* dispatcher) { |
79 base::AutoReset<base::MessagePumpDispatcher*> reset_dispatcher(&dispatcher_, | 92 base::AutoReset<base::MessagePumpDispatcher*> reset_dispatcher(&dispatcher_, |
80 dispatcher); | 93 dispatcher); |
81 base::MessageLoopForUI* loop = base::MessageLoopForUI::current(); | 94 base::MessageLoopForUI* loop = base::MessageLoopForUI::current(); |
82 base::MessageLoop::ScopedNestableTaskAllower allow(loop); | 95 base::MessageLoop::ScopedNestableTaskAllower allow(loop); |
83 base::RunLoop run_loop; | 96 run_loop->Run(); |
84 quit_callback_ = run_loop.QuitClosure(); | |
85 run_loop.Run(); | |
86 } | 97 } |
87 | 98 |
88 virtual void QuitNestedMessageLoop() OVERRIDE { quit_callback_.Run(); } | |
89 | |
90 private: | |
91 base::MessagePumpDispatcher* dispatcher_; | 99 base::MessagePumpDispatcher* dispatcher_; |
92 base::Closure quit_callback_; | |
93 | 100 |
94 DISALLOW_COPY_AND_ASSIGN(TestDispatcherClient); | 101 DISALLOW_COPY_AND_ASSIGN(TestDispatcherClient); |
95 }; | 102 }; |
96 | 103 |
97 } // namespace | 104 } // namespace |
98 | 105 |
99 class MenuControllerTest : public ViewsTestBase { | 106 class MenuControllerTest : public ViewsTestBase { |
100 public: | 107 public: |
101 MenuControllerTest() : controller_(NULL) {} | 108 MenuControllerTest() : controller_(NULL) {} |
102 virtual ~MenuControllerTest() { | 109 virtual ~MenuControllerTest() { |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
251 FROM_HERE, | 258 FROM_HERE, |
252 base::Bind(&MenuControllerTest::DispatchEscapeAndExpect, | 259 base::Bind(&MenuControllerTest::DispatchEscapeAndExpect, |
253 base::Unretained(this), | 260 base::Unretained(this), |
254 MenuController::EXIT_NONE)); | 261 MenuController::EXIT_NONE)); |
255 RunMenu(owner.get()); | 262 RunMenu(owner.get()); |
256 } | 263 } |
257 } | 264 } |
258 #endif | 265 #endif |
259 | 266 |
260 } // namespace views | 267 } // namespace views |
OLD | NEW |