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

Side by Side Diff: base/message_loop_proxy_impl_unittest.cc

Issue 7583053: Add MessageLoopProxy::current (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: No need for MessageLoopProxy destruction observer. Created 9 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « base/message_loop_proxy_impl.cc ('k') | base/observer_list_threadsafe.h » ('j') | 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) 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_loop_proxy_impl.h" 5 #include "base/message_loop_proxy_impl.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "base/message_loop_proxy.h"
10 #include "base/threading/thread.h" 11 #include "base/threading/thread.h"
11 #include "testing/gtest/include/gtest/gtest.h" 12 #include "testing/gtest/include/gtest/gtest.h"
12 #include "testing/platform_test.h" 13 #include "testing/platform_test.h"
13 14
14 15
15 class MessageLoopProxyImplTest : public testing::Test { 16 class MessageLoopProxyImplTest : public testing::Test {
16 public: 17 public:
17 void Release() const { 18 void Release() const {
18 AssertOnIOThread(); 19 AssertOnIOThread();
19 Quit(); 20 Quit();
20 } 21 }
21 22
22 void Quit() const { 23 void Quit() const {
23 loop_.PostTask(FROM_HERE, new MessageLoop::QuitTask); 24 loop_.PostTask(FROM_HERE, new MessageLoop::QuitTask);
24 } 25 }
25 26
26 void AssertOnIOThread() const { 27 void AssertOnIOThread() const {
27 ASSERT_TRUE(io_thread_->message_loop_proxy()->BelongsToCurrentThread()); 28 ASSERT_TRUE(io_thread_->message_loop_proxy()->BelongsToCurrentThread());
29 ASSERT_EQ(io_thread_->message_loop_proxy(),
30 base::MessageLoopProxy::current());
28 } 31 }
29 32
30 void AssertOnFileThread() const { 33 void AssertOnFileThread() const {
31 ASSERT_TRUE(file_thread_->message_loop_proxy()->BelongsToCurrentThread()); 34 ASSERT_TRUE(file_thread_->message_loop_proxy()->BelongsToCurrentThread());
35 ASSERT_EQ(file_thread_->message_loop_proxy(),
36 base::MessageLoopProxy::current());
32 } 37 }
33 38
34 protected: 39 protected:
35 virtual void SetUp() { 40 virtual void SetUp() {
36 io_thread_.reset(new base::Thread("MessageLoopProxyImplTest_IO")); 41 io_thread_.reset(new base::Thread("MessageLoopProxyImplTest_IO"));
37 file_thread_.reset(new base::Thread("MessageLoopProxyImplTest_File")); 42 file_thread_.reset(new base::Thread("MessageLoopProxyImplTest_File"));
38 io_thread_->Start(); 43 io_thread_->Start();
39 file_thread_->Start(); 44 file_thread_->Start();
40 } 45 }
41 46
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 scoped_ptr<base::Thread> test_thread( 168 scoped_ptr<base::Thread> test_thread(
164 new base::Thread("MessageLoopProxyImplTest_Dummy")); 169 new base::Thread("MessageLoopProxyImplTest_Dummy"));
165 test_thread->Start(); 170 test_thread->Start();
166 message_loop_proxy = test_thread->message_loop_proxy(); 171 message_loop_proxy = test_thread->message_loop_proxy();
167 } 172 }
168 bool ret = message_loop_proxy->PostTask( 173 bool ret = message_loop_proxy->PostTask(
169 FROM_HERE, 174 FROM_HERE,
170 base::Bind(&MessageLoopProxyImplTest::AssertNotRun)); 175 base::Bind(&MessageLoopProxyImplTest::AssertNotRun));
171 EXPECT_FALSE(ret); 176 EXPECT_FALSE(ret);
172 } 177 }
OLDNEW
« no previous file with comments | « base/message_loop_proxy_impl.cc ('k') | base/observer_list_threadsafe.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698