Index: base/threading/thread_checker_unittest.cc |
diff --git a/base/threading/thread_checker_unittest.cc b/base/threading/thread_checker_unittest.cc |
index e1e571588f462dcc79d7d214559b664ed76a5e6e..a79e7ba348d9b647d5457bca21f83999f2e4ce1b 100644 |
--- a/base/threading/thread_checker_unittest.cc |
+++ b/base/threading/thread_checker_unittest.cc |
@@ -9,6 +9,10 @@ |
#include "base/threading/simple_thread.h" |
#include "testing/gtest/include/gtest/gtest.h" |
+// Duplicated from base/threading/thread_checker.h so that we can be |
+// good citizens there and undef the macro. |
+#define ENABLE_THREAD_CHECKER (!defined(NDEBUG) || defined(DCHECK_ALWAYS_ON)) |
+ |
namespace base { |
// Simple class to exercise the basics of ThreadChecker. |
@@ -107,7 +111,7 @@ TEST(ThreadCheckerTest, DetachFromThread) { |
call_on_thread.Join(); |
} |
-#if GTEST_HAS_DEATH_TEST || NDEBUG |
+#if GTEST_HAS_DEATH_TEST || !ENABLE_THREAD_CHECKER |
void ThreadCheckerClass::MethodOnDifferentThreadImpl() { |
scoped_ptr<ThreadCheckerClass> thread_checker_class( |
@@ -121,7 +125,7 @@ void ThreadCheckerClass::MethodOnDifferentThreadImpl() { |
call_on_thread.Join(); |
} |
-#ifndef NDEBUG |
+#if ENABLE_THREAD_CHECKER |
TEST(ThreadCheckerDeathTest, MethodNotAllowedOnDifferentThreadInDebug) { |
ASSERT_DEBUG_DEATH({ |
ThreadCheckerClass::MethodOnDifferentThreadImpl(); |
@@ -131,7 +135,7 @@ TEST(ThreadCheckerDeathTest, MethodNotAllowedOnDifferentThreadInDebug) { |
TEST(ThreadCheckerTest, MethodAllowedOnDifferentThreadInRelease) { |
ThreadCheckerClass::MethodOnDifferentThreadImpl(); |
} |
-#endif // NDEBUG |
+#endif // ENABLE_THREAD_CHECKER |
void ThreadCheckerClass::DetachThenCallFromDifferentThreadImpl() { |
scoped_ptr<ThreadCheckerClass> thread_checker_class( |
@@ -150,7 +154,7 @@ void ThreadCheckerClass::DetachThenCallFromDifferentThreadImpl() { |
thread_checker_class->DoStuff(); |
} |
-#ifndef NDEBUG |
+#if ENABLE_THREAD_CHECKER |
TEST(ThreadCheckerDeathTest, DetachFromThreadInDebug) { |
ASSERT_DEBUG_DEATH({ |
ThreadCheckerClass::DetachThenCallFromDifferentThreadImpl(); |
@@ -160,8 +164,11 @@ TEST(ThreadCheckerDeathTest, DetachFromThreadInDebug) { |
TEST(ThreadCheckerTest, DetachFromThreadInRelease) { |
ThreadCheckerClass::DetachThenCallFromDifferentThreadImpl(); |
} |
-#endif // NDEBUG |
+#endif // ENABLE_THREAD_CHECKER |
+ |
+#endif // GTEST_HAS_DEATH_TEST || !ENABLE_THREAD_CHECKER |
-#endif // GTEST_HAS_DEATH_TEST || NDEBUG |
+// Just in case we ever get lumped together with other compilation units. |
+#undef ENABLE_THREAD_CHECKER |
} // namespace base |