Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(310)

Unified Diff: webrtc/base/platform_thread_unittest.cc

Issue 2708723003: Introduce new constructor to PlatformThread. (Closed)
Patch Set: Disable RTC_DCHECK in channel_proxy + add TODO Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webrtc/base/platform_thread.cc ('k') | webrtc/base/rate_limiter_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/base/platform_thread_unittest.cc
diff --git a/webrtc/base/platform_thread_unittest.cc b/webrtc/base/platform_thread_unittest.cc
index 322eb35ffcb747e7f12e84244926d720a26be36f..d6d35e40e4955dfe82367ac29e3ed2de00c1efbf 100644
--- a/webrtc/base/platform_thread_unittest.cc
+++ b/webrtc/base/platform_thread_unittest.cc
@@ -16,20 +16,65 @@
namespace rtc {
namespace {
// Function that does nothing, and reports success.
-bool NullRunFunction(void* obj) {
+bool NullRunFunctionDeprecated(void* obj) {
webrtc::SleepMs(0); // Hand over timeslice, prevents busy looping.
return true;
}
+void NullRunFunction(void* obj) {}
+
// Function that sets a boolean.
-bool SetFlagRunFunction(void* obj) {
+bool SetFlagRunFunctionDeprecated(void* obj) {
bool* obj_as_bool = static_cast<bool*>(obj);
*obj_as_bool = true;
webrtc::SleepMs(0); // Hand over timeslice, prevents busy looping.
return true;
}
+
+void SetFlagRunFunction(void* obj) {
+ bool* obj_as_bool = static_cast<bool*>(obj);
+ *obj_as_bool = true;
+}
+
} // namespace
+TEST(PlatformThreadTest, StartStopDeprecated) {
+ PlatformThread thread(&NullRunFunctionDeprecated, nullptr,
+ "PlatformThreadTest");
+ EXPECT_TRUE(thread.name() == "PlatformThreadTest");
+ EXPECT_TRUE(thread.GetThreadRef() == 0);
+ thread.Start();
+ EXPECT_TRUE(thread.GetThreadRef() != 0);
+ thread.Stop();
+ EXPECT_TRUE(thread.GetThreadRef() == 0);
+}
+
+TEST(PlatformThreadTest, StartStop2Deprecated) {
+ PlatformThread thread1(&NullRunFunctionDeprecated, nullptr,
+ "PlatformThreadTest1");
+ PlatformThread thread2(&NullRunFunctionDeprecated, nullptr,
+ "PlatformThreadTest2");
+ EXPECT_TRUE(thread1.GetThreadRef() == thread2.GetThreadRef());
+ thread1.Start();
+ thread2.Start();
+ EXPECT_TRUE(thread1.GetThreadRef() != thread2.GetThreadRef());
+ thread2.Stop();
+ thread1.Stop();
+}
+
+TEST(PlatformThreadTest, RunFunctionIsCalledDeprecated) {
+ bool flag = false;
+ PlatformThread thread(&SetFlagRunFunctionDeprecated, &flag,
+ "RunFunctionIsCalled");
+ thread.Start();
+
+ // At this point, the flag may be either true or false.
+ thread.Stop();
+
+ // We expect the thread to have run at least once.
+ EXPECT_TRUE(flag);
+}
+
TEST(PlatformThreadTest, StartStop) {
PlatformThread thread(&NullRunFunction, nullptr, "PlatformThreadTest");
EXPECT_TRUE(thread.name() == "PlatformThreadTest");
@@ -62,4 +107,5 @@ TEST(PlatformThreadTest, RunFunctionIsCalled) {
// We expect the thread to have run at least once.
EXPECT_TRUE(flag);
}
+
} // rtc
« no previous file with comments | « webrtc/base/platform_thread.cc ('k') | webrtc/base/rate_limiter_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698