OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 <stddef.h> | 5 #include <stddef.h> |
6 #include <stdint.h> | 6 #include <stdint.h> |
7 | 7 |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 958 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
969 // It should be possible to delete an unbound message loop on a thread which | 969 // It should be possible to delete an unbound message loop on a thread which |
970 // already has another active loop. This happens when thread creation fails. | 970 // already has another active loop. This happens when thread creation fails. |
971 MessageLoop loop; | 971 MessageLoop loop; |
972 std::unique_ptr<MessageLoop> unbound_loop(MessageLoop::CreateUnbound( | 972 std::unique_ptr<MessageLoop> unbound_loop(MessageLoop::CreateUnbound( |
973 MessageLoop::TYPE_DEFAULT, MessageLoop::MessagePumpFactoryCallback())); | 973 MessageLoop::TYPE_DEFAULT, MessageLoop::MessagePumpFactoryCallback())); |
974 unbound_loop.reset(); | 974 unbound_loop.reset(); |
975 EXPECT_EQ(&loop, MessageLoop::current()); | 975 EXPECT_EQ(&loop, MessageLoop::current()); |
976 EXPECT_EQ(loop.task_runner(), ThreadTaskRunnerHandle::Get()); | 976 EXPECT_EQ(loop.task_runner(), ThreadTaskRunnerHandle::Get()); |
977 } | 977 } |
978 | 978 |
| 979 TEST(MessageLoopTest, ThreadName) { |
| 980 { |
| 981 std::string kThreadName("foo"); |
| 982 MessageLoop loop; |
| 983 PlatformThread::SetName(kThreadName); |
| 984 EXPECT_EQ(kThreadName, loop.GetThreadName()); |
| 985 } |
| 986 |
| 987 { |
| 988 std::string kThreadName("bar"); |
| 989 base::Thread thread(kThreadName); |
| 990 ASSERT_TRUE(thread.StartAndWaitForTesting()); |
| 991 EXPECT_EQ(kThreadName, thread.message_loop()->GetThreadName()); |
| 992 } |
| 993 } |
| 994 |
979 } // namespace base | 995 } // namespace base |
OLD | NEW |