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_libevent.h" | 5 #include "base/message_pump_libevent.h" |
6 | 6 |
7 #include <unistd.h> | 7 #include <unistd.h> |
8 | 8 |
9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
10 #include "base/threading/thread.h" | 10 #include "base/threading/thread.h" |
11 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
12 | 12 |
13 #if defined(USE_SYSTEM_LIBEVENT) | 13 #if defined(USE_SYSTEM_LIBEVENT) |
14 #include <event.h> | 14 #include <event.h> |
15 #else | 15 #else |
16 #include "third_party/libevent/event.h" | 16 #include "third_party/libevent/event.h" |
17 #endif | 17 #endif |
18 | 18 |
19 namespace base { | 19 namespace base { |
20 | 20 |
21 class MessagePumpLibeventTest : public testing::Test { | 21 class MessagePumpLibeventTest : public testing::Test { |
22 protected: | 22 protected: |
23 MessagePumpLibeventTest() | 23 MessagePumpLibeventTest() |
24 : ui_loop_(MessageLoop::TYPE_UI), | 24 : ui_loop_("MessagePumpLibeventTest", MessageLoop::TYPE_UI), |
25 io_thread_("MessagePumpLibeventTestIOThread") {} | 25 io_thread_("MessagePumpLibeventTestIOThread") {} |
26 virtual ~MessagePumpLibeventTest() {} | 26 virtual ~MessagePumpLibeventTest() {} |
27 | 27 |
28 virtual void SetUp() { | 28 virtual void SetUp() { |
29 Thread::Options options(MessageLoop::TYPE_IO, 0); | 29 Thread::Options options(MessageLoop::TYPE_IO, 0); |
30 ASSERT_TRUE(io_thread_.StartWithOptions(options)); | 30 ASSERT_TRUE(io_thread_.StartWithOptions(options)); |
31 ASSERT_EQ(MessageLoop::TYPE_IO, io_thread_.message_loop()->type()); | 31 ASSERT_EQ(MessageLoop::TYPE_IO, io_thread_.message_loop()->type()); |
32 } | 32 } |
33 | 33 |
34 MessageLoop* ui_loop() { return &ui_loop_; } | 34 MessageLoop* ui_loop() { return &ui_loop_; } |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 pump->WatchFileDescriptor( | 136 pump->WatchFileDescriptor( |
137 0, false, MessagePumpLibevent::WATCH_READ_WRITE, &watcher, &delegate); | 137 0, false, MessagePumpLibevent::WATCH_READ_WRITE, &watcher, &delegate); |
138 | 138 |
139 // Spoof a libevent notification. | 139 // Spoof a libevent notification. |
140 OnLibeventNotification(pump, &watcher); | 140 OnLibeventNotification(pump, &watcher); |
141 } | 141 } |
142 | 142 |
143 } // namespace | 143 } // namespace |
144 | 144 |
145 } // namespace base | 145 } // namespace base |
OLD | NEW |