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 <memory> | 5 #include <memory> |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/location.h" | 9 #include "base/location.h" |
10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
(...skipping 22 matching lines...) Expand all Loading... |
33 void SetUp() override { | 33 void SetUp() override { |
34 ui_thread_.reset(new BrowserThreadImpl(BrowserThread::UI)); | 34 ui_thread_.reset(new BrowserThreadImpl(BrowserThread::UI)); |
35 file_thread_.reset(new BrowserThreadImpl(BrowserThread::FILE)); | 35 file_thread_.reset(new BrowserThreadImpl(BrowserThread::FILE)); |
36 ui_thread_->Start(); | 36 ui_thread_->Start(); |
37 file_thread_->Start(); | 37 file_thread_->Start(); |
38 } | 38 } |
39 | 39 |
40 void TearDown() override { | 40 void TearDown() override { |
41 StopUIThread(); | 41 StopUIThread(); |
42 file_thread_->Stop(); | 42 file_thread_->Stop(); |
| 43 ui_thread_ = nullptr; |
| 44 file_thread_ = nullptr; |
| 45 BrowserThreadImpl::ResetGlobalsForTesting(BrowserThread::UI); |
| 46 BrowserThreadImpl::ResetGlobalsForTesting(BrowserThread::FILE); |
43 } | 47 } |
44 | 48 |
45 static void BasicFunction(base::MessageLoop* message_loop) { | 49 static void BasicFunction(base::MessageLoop* message_loop) { |
46 CHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 50 CHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
47 message_loop->task_runner()->PostTask( | 51 message_loop->task_runner()->PostTask( |
48 FROM_HERE, base::MessageLoop::QuitWhenIdleClosure()); | 52 FROM_HERE, base::MessageLoop::QuitWhenIdleClosure()); |
49 } | 53 } |
50 | 54 |
51 class DeletedOnFile | 55 class DeletedOnFile |
52 : public base::RefCountedThreadSafe< | 56 : public base::RefCountedThreadSafe< |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 UIThreadDestructionObserver observer(&did_shutdown, loop.QuitClosure()); | 170 UIThreadDestructionObserver observer(&did_shutdown, loop.QuitClosure()); |
167 base::ThreadTaskRunnerHandle::Get()->PostTask( | 171 base::ThreadTaskRunnerHandle::Get()->PostTask( |
168 FROM_HERE, | 172 FROM_HERE, |
169 base::Bind(&BrowserThreadTest::StopUIThread, base::Unretained(this))); | 173 base::Bind(&BrowserThreadTest::StopUIThread, base::Unretained(this))); |
170 loop.Run(); | 174 loop.Run(); |
171 | 175 |
172 EXPECT_TRUE(did_shutdown); | 176 EXPECT_TRUE(did_shutdown); |
173 } | 177 } |
174 | 178 |
175 } // namespace content | 179 } // namespace content |
OLD | NEW |