Index: webrtc/base/thread_checker_unittest.cc |
diff --git a/webrtc/base/thread_checker_unittest.cc b/webrtc/base/thread_checker_unittest.cc |
index 372f6f4a77fb921d1801fd0fb8e171346b727dc1..48c4cd1960d28ebce9138144c5ff5d891e564c4d 100644 |
--- a/webrtc/base/thread_checker_unittest.cc |
+++ b/webrtc/base/thread_checker_unittest.cc |
@@ -15,6 +15,7 @@ |
#include "testing/gtest/include/gtest/gtest.h" |
#include "webrtc/base/checks.h" |
#include "webrtc/base/constructormagic.h" |
+#include "webrtc/base/task_queue.h" |
#include "webrtc/base/thread.h" |
#include "webrtc/base/thread_checker.h" |
@@ -194,6 +195,59 @@ TEST(ThreadCheckerTest, DetachFromThreadInRelease) { |
#endif // GTEST_HAS_DEATH_TEST || !ENABLE_THREAD_CHECKER |
+class ThreadAnnotateTest { |
+ public: |
+ rtc::Thread* thread; |
tommi
2016/05/19 08:26:14
move these member variables to the bottom of the c
danilchap
2016/05/19 11:45:29
Done.
|
+ rtc::ThreadChecker checker; |
+ rtc::TaskQueue* queue; |
+ |
+ int var_thread ACCESS_ON(thread); |
+ int var_checker ACCESS_ON(checker); |
+ int var_queue ACCESS_ON(queue); |
+ void function() RUN_ON(thread) {} |
+ void fun_acccess_var() RUN_ON(thread) { var_thread = 13; } |
+ |
+ // Next two function should create warnings when compile (e.g. if used with |
+ // specific T) |
+ // TODO(danilchap): Find a way to test they do not compile when thread |
+ // annotation checks enabled. |
+ template<typename T> |
+ void access_var_no_annotate() { |
+ var_thread = 42; |
+ } |
+ |
+ template<typename T> |
+ void access_fun_no_annotate() { |
+ function(); |
+ } |
+ |
+ // Functions below should be able to compile. |
+ void access_var_annotate_thread() { |
+ RTC_DCHECK_RUN_ON(thread); |
+ var_thread = 42; |
+ } |
+ |
+ void access_var_annotate_checker() { |
+ RTC_DCHECK_RUN_ON(&checker); |
+ var_checker = 44; |
+ } |
+ |
+ void access_var_annotate_queue() { |
+ RTC_DCHECK_RUN_ON(queue); |
+ var_queue = 46; |
+ } |
+ |
+ void access_fun_annotate() { |
+ RTC_DCHECK_RUN_ON(thread); |
+ function(); |
+ } |
+ |
+ void access_fun_and_var() { |
+ RTC_DCHECK_RUN_ON(thread); |
+ fun_acccess_var(); |
+ } |
+}; |
+ |
// Just in case we ever get lumped together with other compilation units. |
#undef ENABLE_THREAD_CHECKER |