base/thread_unittest: wrap test was setting current thread to NULL.

This broke unittests following ThreadTest.Wrap

BUG=3836
R=pbos@webrtc.org

Review URL: https://webrtc-codereview.appspot.com/28689004

git-svn-id: http://webrtc.googlecode.com/svn/trunk@7413 4adac7df-926f-26a2-2b94-8c16560cd09d
diff --git a/webrtc/base/base_tests.gyp b/webrtc/base/base_tests.gyp
index 77bed2c..457fbdc 100644
--- a/webrtc/base/base_tests.gyp
+++ b/webrtc/base/base_tests.gyp
@@ -105,7 +105,7 @@
           'task_unittest.cc',
           'testclient_unittest.cc',
           'thread_checker_unittest.cc',
-          #'thread_unittest.cc',
+          'thread_unittest.cc',
           #'timeutils_unittest.cc',
           'urlencode_unittest.cc',
           #'versionparsing_unittest.cc',
diff --git a/webrtc/base/thread.h b/webrtc/base/thread.h
index 8276f4e..b05d6a9 100644
--- a/webrtc/base/thread.h
+++ b/webrtc/base/thread.h
@@ -213,7 +213,8 @@
   // value. Must be called on this thread.
   bool SetAllowBlockingCalls(bool allow);
 
- protected:
+  // These functions are public to avoid injecting test hooks. Don't call them
+  // outside of tests.
   // This method should be called when thread is created using non standard
   // method, like derived implementation of rtc::Thread and it can not be
   // started by calling Start(). This will set started flag to true and
@@ -221,6 +222,7 @@
   bool WrapCurrent();
   void UnwrapCurrent();
 
+ protected:
   // Same as WrapCurrent except that it never fails as it does not try to
   // acquire the synchronization access of the thread. The caller should never
   // call Stop() or Join() on this thread.
diff --git a/webrtc/base/thread_unittest.cc b/webrtc/base/thread_unittest.cc
index 57b6df6..41edd73 100644
--- a/webrtc/base/thread_unittest.cc
+++ b/webrtc/base/thread_unittest.cc
@@ -247,7 +247,9 @@
 
 }
 
-TEST(ThreadTest, DISABLED_ON_MAC(Wrap)) {
+TEST(ThreadTest, Wrap) {
+  Thread* current_thread = Thread::Current();
+  current_thread->UnwrapCurrent();
   CustomThread* cthread = new CustomThread();
   EXPECT_TRUE(cthread->WrapCurrent());
   EXPECT_TRUE(cthread->RunningForTest());
@@ -255,6 +257,7 @@
   cthread->UnwrapCurrent();
   EXPECT_FALSE(cthread->RunningForTest());
   delete cthread;
+  current_thread->WrapCurrent();
 }
 
 TEST(ThreadTest, DISABLED_ON_MAC(Invoke)) {
@@ -377,7 +380,7 @@
   Thread* expected_thread_;
 };
 
-TEST_F(AsyncInvokeTest, DISABLED_FireAndForget) {
+TEST_F(AsyncInvokeTest, FireAndForget) {
   AsyncInvoker invoker;
   // Create and start the thread.
   Thread thread;
diff --git a/webrtc/build/tsan_suppressions_webrtc.cc b/webrtc/build/tsan_suppressions_webrtc.cc
index 548045b..c18bcfc 100644
--- a/webrtc/build/tsan_suppressions_webrtc.cc
+++ b/webrtc/build/tsan_suppressions_webrtc.cc
@@ -41,6 +41,13 @@
 "race:webrtc/modules/audio_processing/aec/aec_core.c\n"
 "race:webrtc/modules/audio_processing/aec/aec_rdft.c\n"
 
+// rtc_unittest
+// https://code.google.com/p/webrtc/issues/detail?id=3911 for details.
+"race:ThreadTest_ThreeThreadsInvoke_Test::TestBody()::LocalFuncs::SetAndInvokeSet\n"
+"race:rtc::FireAndForgetAsyncClosure<FunctorB>::Execute\n"
+"race:rtc::MessageQueueManager::Clear\n"
+"race:rtc::Thread::Clear\n"
+
 // libjingle_p2p_unittest
 // https://code.google.com/p/webrtc/issues/detail?id=2079
 "race:webrtc/base/testclient.cc\n"