Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(96)

Side by Side Diff: message_loop/message_pump_libevent_unittest.cc

Issue 1951103002: Fix build on non-X11 platforms. (Closed) Base URL: git@github.com:domokit/base.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_loop/message_pump_libevent.h" 5 #include "base/message_loop/message_pump_libevent.h"
6 6
7 #include <unistd.h> 7 #include <unistd.h>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 if (!work_units_) 283 if (!work_units_)
284 return false; 284 return false;
285 work_units_--; 285 work_units_--;
286 return true; 286 return true;
287 } 287 }
288 288
289 private: 289 private:
290 uint32_t work_units_; 290 uint32_t work_units_;
291 }; 291 };
292 292
293 TEST_F(MessagePumpLibeventTest, PollEventSource) { 293 TEST(MessagePumpLibeventEventSourceTest, Poll) {
294 MessagePumpLibevent* pump = new MessagePumpLibevent; // owned by |loop|.
295 MessageLoop loop(make_scoped_ptr(pump));
294 FakeEventSource event_source; 296 FakeEventSource event_source;
295 297
296 // Verify event source gets polled repeatedly until no work remains. 298 // Verify event source gets polled repeatedly until no work remains.
297 MessageLoopForUI::current()->SetEventSource(&event_source); 299 pump->SetEventSource(&event_source);
298 event_source.set_work_units(5u); 300 event_source.set_work_units(5u);
299 ui_loop_->RunUntilIdle(); 301 loop.RunUntilIdle();
300 EXPECT_EQ(0u, event_source.work_units()); 302 EXPECT_EQ(0u, event_source.work_units());
301 303
302 // After removing the event source, it should no longer be polled. 304 // After removing the event source, it should no longer be polled.
303 MessageLoopForUI::current()->ClearEventSource(); 305 pump->ClearEventSource();
304 event_source.set_work_units(5u); 306 event_source.set_work_units(5u);
305 ui_loop_->RunUntilIdle(); 307 loop.RunUntilIdle();
306 EXPECT_EQ(5u, event_source.work_units()); 308 EXPECT_EQ(5u, event_source.work_units());
307 } 309 }
308 310
309 } // namespace 311 } // namespace
310 312
311 } // namespace base 313 } // namespace base
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698