| Index: base/threading/non_thread_safe_unittest.cc
|
| diff --git a/base/threading/non_thread_safe_unittest.cc b/base/threading/non_thread_safe_unittest.cc
|
| index b8376f3969c34f1ca236c15de224cb269c3ee366..ee31701dc65ec6067d3c84702591040dc46acddb 100644
|
| --- a/base/threading/non_thread_safe_unittest.cc
|
| +++ b/base/threading/non_thread_safe_unittest.cc
|
| @@ -9,8 +9,18 @@
|
| #include "base/threading/simple_thread.h"
|
| #include "testing/gtest/include/gtest/gtest.h"
|
|
|
| +// Duplicated from base/threading/non_thread_safe.h so that we can be
|
| +// good citizens there and undef the macro.
|
| +#if (!defined(NDEBUG) || defined(DCHECK_ALWAYS_ON))
|
| +#define ENABLE_NON_THREAD_SAFE 1
|
| +#else
|
| +#define ENABLE_NON_THREAD_SAFE 0
|
| +#endif
|
| +
|
| namespace base {
|
|
|
| +namespace {
|
| +
|
| // Simple class to exersice the basics of NonThreadSafe.
|
| // Both the destructor and DoStuff should verify that they were
|
| // called on the same thread as the constructor.
|
| @@ -70,6 +80,8 @@ class DeleteNonThreadSafeClassOnThread : public SimpleThread {
|
| DISALLOW_COPY_AND_ASSIGN(DeleteNonThreadSafeClassOnThread);
|
| };
|
|
|
| +} // namespace
|
| +
|
| TEST(NonThreadSafeTest, CallsAllowedOnSameThread) {
|
| scoped_ptr<NonThreadSafeClass> non_thread_safe_class(
|
| new NonThreadSafeClass);
|
| @@ -95,7 +107,7 @@ TEST(NonThreadSafeTest, DetachThenDestructOnDifferentThread) {
|
| delete_on_thread.Join();
|
| }
|
|
|
| -#if GTEST_HAS_DEATH_TEST || NDEBUG
|
| +#if GTEST_HAS_DEATH_TEST || !ENABLE_NON_THREAD_SAFE
|
|
|
| void NonThreadSafeClass::MethodOnDifferentThreadImpl() {
|
| scoped_ptr<NonThreadSafeClass> non_thread_safe_class(
|
| @@ -109,9 +121,9 @@ void NonThreadSafeClass::MethodOnDifferentThreadImpl() {
|
| call_on_thread.Join();
|
| }
|
|
|
| -#ifndef NDEBUG
|
| +#if ENABLE_NON_THREAD_SAFE
|
| TEST(NonThreadSafeDeathTest, MethodNotAllowedOnDifferentThreadInDebug) {
|
| - ASSERT_DEBUG_DEATH({
|
| + ASSERT_DEATH({
|
| NonThreadSafeClass::MethodOnDifferentThreadImpl();
|
| }, "");
|
| }
|
| @@ -119,7 +131,7 @@ TEST(NonThreadSafeDeathTest, MethodNotAllowedOnDifferentThreadInDebug) {
|
| TEST(NonThreadSafeTest, MethodAllowedOnDifferentThreadInRelease) {
|
| NonThreadSafeClass::MethodOnDifferentThreadImpl();
|
| }
|
| -#endif // NDEBUG
|
| +#endif // ENABLE_NON_THREAD_SAFE
|
|
|
| void NonThreadSafeClass::DestructorOnDifferentThreadImpl() {
|
| scoped_ptr<NonThreadSafeClass> non_thread_safe_class(
|
| @@ -134,9 +146,9 @@ void NonThreadSafeClass::DestructorOnDifferentThreadImpl() {
|
| delete_on_thread.Join();
|
| }
|
|
|
| -#ifndef NDEBUG
|
| +#if ENABLE_NON_THREAD_SAFE
|
| TEST(NonThreadSafeDeathTest, DestructorNotAllowedOnDifferentThreadInDebug) {
|
| - ASSERT_DEBUG_DEATH({
|
| + ASSERT_DEATH({
|
| NonThreadSafeClass::DestructorOnDifferentThreadImpl();
|
| }, "");
|
| }
|
| @@ -144,8 +156,11 @@ TEST(NonThreadSafeDeathTest, DestructorNotAllowedOnDifferentThreadInDebug) {
|
| TEST(NonThreadSafeTest, DestructorAllowedOnDifferentThreadInRelease) {
|
| NonThreadSafeClass::DestructorOnDifferentThreadImpl();
|
| }
|
| -#endif // NDEBUG
|
| +#endif // ENABLE_NON_THREAD_SAFE
|
| +
|
| +#endif // GTEST_HAS_DEATH_TEST || !ENABLE_NON_THREAD_SAFE
|
|
|
| -#endif // GTEST_HAS_DEATH_TEST || NDEBUG
|
| +// Just in case we ever get lumped together with other compilation units.
|
| +#undef ENABLE_NON_THREAD_SAFE
|
|
|
| } // namespace base
|
|
|