Chromium Code Reviews| Index: base/threading/simple_thread_unittest.cc | 
| diff --git a/base/threading/simple_thread_unittest.cc b/base/threading/simple_thread_unittest.cc | 
| index 14dd4591f1819d8e505911cd9f4cb9fb09cd54f2..bcd07354e4f01f28db066bc5c45d1e5ae7b9251f 100644 | 
| --- a/base/threading/simple_thread_unittest.cc | 
| +++ b/base/threading/simple_thread_unittest.cc | 
| @@ -2,16 +2,29 @@ | 
| // Use of this source code is governed by a BSD-style license that can be | 
| // found in the LICENSE file. | 
| +#include <memory> | 
| + | 
| #include "base/atomic_sequence_num.h" | 
| #include "base/strings/string_number_conversions.h" | 
| #include "base/synchronization/waitable_event.h" | 
| +#include "base/test/gtest_util.h" | 
| +#include "base/threading/platform_thread.h" | 
| #include "base/threading/simple_thread.h" | 
| +#include "base/time/time.h" | 
| #include "testing/gtest/include/gtest/gtest.h" | 
| namespace base { | 
| namespace { | 
| +// Sleeps a tiny amount to augment chances of tests using it running in races | 
| +// should there be any while the tested thread is alive. | 
| +class SleepRunner : public DelegateSimpleThread::Delegate { | 
| + void Run() override { | 
| + PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(20)); | 
| 
 
Lei Zhang
2016/08/03 23:24:12
no need for base:: inside base.
 
gab
2016/08/04 14:35:01
Done.
 
 | 
| + } | 
| +}; | 
| + | 
| class SetIntRunner : public DelegateSimpleThread::Delegate { | 
| public: | 
| SetIntRunner(int* ptr, int val) : ptr_(ptr), val_(val) { } | 
| @@ -133,6 +146,25 @@ TEST(SimpleThreadTest, NamedWithOptions) { | 
| std::string("event_waiter/") + IntToString(thread.tid())); | 
| } | 
| +TEST(SimpleThreadTest, JoinNonJoinableThreadDeath) { | 
| + SleepRunner runner; | 
| + SimpleThread::Options options; | 
| + options.joinable = false; | 
| + DelegateSimpleThread thread(&runner, "noop_runner", options); | 
| + | 
| + thread.Start(); | 
| + EXPECT_DCHECK_DEATH(thread.Join(), ""); | 
| +} | 
| + | 
| +TEST(SimpleThreadTest, DeleteNonJoinableWithoutJoinIsSafe) { | 
| + SleepRunner runner; | 
| + SimpleThread::Options options; | 
| + options.joinable = false; | 
| + DelegateSimpleThread thread(&runner, "noop_runner", options); | 
| + thread.Start(); | 
| + // Nothing blows up when |thread| goes out of scope. | 
| +} | 
| + | 
| TEST(SimpleThreadTest, ThreadPool) { | 
| AtomicSequenceNumber seq; | 
| SeqRunner runner(&seq); |