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 "base/message_pump_glib.h" | 5 #include "base/message_pump_glib.h" |
6 | 6 |
7 #include <glib.h> | 7 #include <glib.h> |
8 #include <math.h> | 8 #include <math.h> |
9 | 9 |
10 #include <algorithm> | 10 #include <algorithm> |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 void PostMessageLoopTask(const tracked_objects::Location& from_here, | 155 void PostMessageLoopTask(const tracked_objects::Location& from_here, |
156 const base::Closure& task) { | 156 const base::Closure& task) { |
157 MessageLoop::current()->PostTask(from_here, task); | 157 MessageLoop::current()->PostTask(from_here, task); |
158 } | 158 } |
159 | 159 |
160 // Test fixture. | 160 // Test fixture. |
161 class MessagePumpGLibTest : public testing::Test { | 161 class MessagePumpGLibTest : public testing::Test { |
162 public: | 162 public: |
163 MessagePumpGLibTest() : loop_(NULL), injector_(NULL) { } | 163 MessagePumpGLibTest() : loop_(NULL), injector_(NULL) { } |
164 | 164 |
165 virtual void SetUp() { | 165 // Overridden from testing::Test: |
| 166 virtual void SetUp() OVERRIDE { |
166 loop_ = new MessageLoop(MessageLoop::TYPE_UI); | 167 loop_ = new MessageLoop(MessageLoop::TYPE_UI); |
167 injector_ = new EventInjector(); | 168 injector_ = new EventInjector(); |
168 } | 169 } |
169 | 170 virtual void TearDown() OVERRIDE { |
170 virtual void TearDown() { | |
171 delete injector_; | 171 delete injector_; |
172 injector_ = NULL; | 172 injector_ = NULL; |
173 delete loop_; | 173 delete loop_; |
174 loop_ = NULL; | 174 loop_ = NULL; |
175 } | 175 } |
176 | 176 |
177 MessageLoop* loop() const { return loop_; } | 177 MessageLoop* loop() const { return loop_; } |
178 EventInjector* injector() const { return injector_; } | 178 EventInjector* injector() const { return injector_; } |
179 | 179 |
180 private: | 180 private: |
(...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
568 TEST_F(MessagePumpGLibTest, TestGtkLoop) { | 568 TEST_F(MessagePumpGLibTest, TestGtkLoop) { |
569 // Tests that events and posted tasks are correctly executed if the message | 569 // Tests that events and posted tasks are correctly executed if the message |
570 // loop is not run by MessageLoop::Run() but by a straight Gtk loop. | 570 // loop is not run by MessageLoop::Run() but by a straight Gtk loop. |
571 // Note that in this case we don't make strong guarantees about niceness | 571 // Note that in this case we don't make strong guarantees about niceness |
572 // between events and posted tasks. | 572 // between events and posted tasks. |
573 loop()->PostTask( | 573 loop()->PostTask( |
574 FROM_HERE, | 574 FROM_HERE, |
575 base::Bind(&TestGtkLoopInternal, base::Unretained(injector()))); | 575 base::Bind(&TestGtkLoopInternal, base::Unretained(injector()))); |
576 loop()->Run(); | 576 loop()->Run(); |
577 } | 577 } |
OLD | NEW |