| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "base/message_pump_glib.h" | 5 #include "base/message_pump_glib.h" |
| 6 | 6 |
| 7 #include <math.h> | 7 #include <math.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 EventInjector* injector() const { return injector_; } | 181 EventInjector* injector() const { return injector_; } |
| 182 | 182 |
| 183 private: | 183 private: |
| 184 MessageLoop* loop_; | 184 MessageLoop* loop_; |
| 185 EventInjector* injector_; | 185 EventInjector* injector_; |
| 186 DISALLOW_COPY_AND_ASSIGN(MessagePumpGLibTest); | 186 DISALLOW_COPY_AND_ASSIGN(MessagePumpGLibTest); |
| 187 }; | 187 }; |
| 188 | 188 |
| 189 } // namespace | 189 } // namespace |
| 190 | 190 |
| 191 // EventInjector is expected to always live longer than the runnable methods. | |
| 192 DISABLE_RUNNABLE_METHOD_REFCOUNT(EventInjector); | |
| 193 | |
| 194 TEST_F(MessagePumpGLibTest, TestQuit) { | 191 TEST_F(MessagePumpGLibTest, TestQuit) { |
| 195 // Checks that Quit works and that the basic infrastructure is working. | 192 // Checks that Quit works and that the basic infrastructure is working. |
| 196 | 193 |
| 197 // Quit from a task | 194 // Quit from a task |
| 198 loop()->PostTask(FROM_HERE, MessageLoop::QuitClosure()); | 195 loop()->PostTask(FROM_HERE, MessageLoop::QuitClosure()); |
| 199 loop()->Run(); | 196 loop()->Run(); |
| 200 EXPECT_EQ(0, injector()->processed_events()); | 197 EXPECT_EQ(0, injector()->processed_events()); |
| 201 | 198 |
| 202 injector()->Reset(); | 199 injector()->Reset(); |
| 203 // Quit from an event | 200 // Quit from an event |
| (...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 563 TEST_F(MessagePumpGLibTest, TestGtkLoop) { | 560 TEST_F(MessagePumpGLibTest, TestGtkLoop) { |
| 564 // Tests that events and posted tasks are correctly executed if the message | 561 // Tests that events and posted tasks are correctly executed if the message |
| 565 // loop is not run by MessageLoop::Run() but by a straight Gtk loop. | 562 // loop is not run by MessageLoop::Run() but by a straight Gtk loop. |
| 566 // Note that in this case we don't make strong guarantees about niceness | 563 // Note that in this case we don't make strong guarantees about niceness |
| 567 // between events and posted tasks. | 564 // between events and posted tasks. |
| 568 loop()->PostTask( | 565 loop()->PostTask( |
| 569 FROM_HERE, | 566 FROM_HERE, |
| 570 base::Bind(&TestGtkLoopInternal, base::Unretained(injector()))); | 567 base::Bind(&TestGtkLoopInternal, base::Unretained(injector()))); |
| 571 loop()->Run(); | 568 loop()->Run(); |
| 572 } | 569 } |
| OLD | NEW |