| Index: base/threading/thread_checker_unittest.cc
|
| diff --git a/base/threading/thread_checker_unittest.cc b/base/threading/thread_checker_unittest.cc
|
| index 96455e66c704efee659099ff6db2fd484b4b550e..3a66bcd3009500ca49d0802aae46795778633a31 100644
|
| --- a/base/threading/thread_checker_unittest.cc
|
| +++ b/base/threading/thread_checker_unittest.cc
|
| @@ -2,6 +2,8 @@
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| +#include "base/threading/thread_checker.h"
|
| +
|
| #include <memory>
|
|
|
| #include "base/bind.h"
|
| @@ -9,9 +11,9 @@
|
| #include "base/macros.h"
|
| #include "base/memory/ref_counted.h"
|
| #include "base/sequence_token.h"
|
| +#include "base/test/gtest_util.h"
|
| #include "base/test/test_simple_task_runner.h"
|
| #include "base/threading/simple_thread.h"
|
| -#include "base/threading/thread_checker_impl.h"
|
| #include "base/threading/thread_task_runner_handle.h"
|
| #include "testing/gtest/include/gtest/gtest.h"
|
|
|
| @@ -192,4 +194,24 @@ TEST(ThreadCheckerTest, DetachFromThreadWithSequenceToken) {
|
| EXPECT_FALSE(thread_checker.CalledOnValidThread());
|
| }
|
|
|
| +TEST(ThreadCheckerTest, Macros) {
|
| + THREAD_CHECKER(my_thread_checker);
|
| +
|
| + RunCallbackOnNewThreadSynchronously(Bind([](ThreadChecker* thread_checker) {
|
| +#if DCHECK_IS_ON()
|
| + EXPECT_DCHECK_DEATH({ DCHECK_CALLED_ON_VALID_THREAD(*thread_checker); });
|
| +#else
|
| + // Happily no-ops on non-dcheck builds.
|
| + DCHECK_CALLED_ON_VALID_THREAD(*thread_checker);
|
| +#endif
|
| + }, Unretained(&my_thread_checker)));
|
| +
|
| + DETACH_FROM_THREAD(my_thread_checker);
|
| +
|
| + RunCallbackOnNewThreadSynchronously(Bind([](ThreadChecker* thread_checker) {
|
| + // Happily passes after detaching from original thread.
|
| + DCHECK_CALLED_ON_VALID_THREAD(*thread_checker);
|
| + }, Unretained(&my_thread_checker)));
|
| +}
|
| +
|
| } // namespace base
|
|
|