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/bind.h" | 5 #include "base/bind.h" |
| 6 #include "base/bind_helpers.h" |
6 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
7 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
8 #include "base/message_loop_proxy.h" | 9 #include "base/message_loop_proxy.h" |
9 #include "content/browser/browser_thread_impl.h" | 10 #include "content/browser/browser_thread_impl.h" |
10 #include "content/test/test_browser_thread.h" | 11 #include "content/test/test_browser_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 namespace content { | 15 namespace content { |
15 | 16 |
(...skipping 15 matching lines...) Expand all Loading... |
31 virtual void TearDown() { | 32 virtual void TearDown() { |
32 ui_thread_->Stop(); | 33 ui_thread_->Stop(); |
33 file_thread_->Stop(); | 34 file_thread_->Stop(); |
34 } | 35 } |
35 | 36 |
36 static void BasicFunction(MessageLoop* message_loop) { | 37 static void BasicFunction(MessageLoop* message_loop) { |
37 CHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 38 CHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
38 message_loop->PostTask(FROM_HERE, MessageLoop::QuitClosure()); | 39 message_loop->PostTask(FROM_HERE, MessageLoop::QuitClosure()); |
39 } | 40 } |
40 | 41 |
41 static void DoNothing() { | |
42 } | |
43 | |
44 class DeletedOnFile | 42 class DeletedOnFile |
45 : public base::RefCountedThreadSafe< | 43 : public base::RefCountedThreadSafe< |
46 DeletedOnFile, BrowserThread::DeleteOnFileThread> { | 44 DeletedOnFile, BrowserThread::DeleteOnFileThread> { |
47 public: | 45 public: |
48 explicit DeletedOnFile(MessageLoop* message_loop) | 46 explicit DeletedOnFile(MessageLoop* message_loop) |
49 : message_loop_(message_loop) { } | 47 : message_loop_(message_loop) { } |
50 | 48 |
51 ~DeletedOnFile() { | 49 ~DeletedOnFile() { |
52 CHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 50 CHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
53 message_loop_->PostTask(FROM_HERE, MessageLoop::QuitClosure()); | 51 message_loop_->PostTask(FROM_HERE, MessageLoop::QuitClosure()); |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 message_loop_proxy->ReleaseSoon(FROM_HERE, this); | 110 message_loop_proxy->ReleaseSoon(FROM_HERE, this); |
113 MessageLoop::current()->Run(); | 111 MessageLoop::current()->Run(); |
114 } | 112 } |
115 | 113 |
116 TEST_F(BrowserThreadTest, PostTaskAndReply) { | 114 TEST_F(BrowserThreadTest, PostTaskAndReply) { |
117 // Most of the heavy testing for PostTaskAndReply() is done inside the | 115 // Most of the heavy testing for PostTaskAndReply() is done inside the |
118 // MessageLoopProxy test. This just makes sure we get piped through at all. | 116 // MessageLoopProxy test. This just makes sure we get piped through at all. |
119 ASSERT_TRUE(BrowserThread::PostTaskAndReply( | 117 ASSERT_TRUE(BrowserThread::PostTaskAndReply( |
120 BrowserThread::FILE, | 118 BrowserThread::FILE, |
121 FROM_HERE, | 119 FROM_HERE, |
122 base::Bind(&BrowserThreadTest::DoNothing), | 120 base::Bind(&base::DoNothing), |
123 base::Bind(&MessageLoop::Quit, | 121 base::Bind(&MessageLoop::Quit, |
124 base::Unretained(MessageLoop::current()->current())))); | 122 base::Unretained(MessageLoop::current()->current())))); |
125 MessageLoop::current()->Run(); | 123 MessageLoop::current()->Run(); |
126 } | 124 } |
127 | 125 |
128 } | 126 } |
OLD | NEW |