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

Side by Side Diff: webrtc/base/messagequeue_unittest.cc

Issue 1891293002: Adds clearer function to create rtc::Thread without Physical SocketServer (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 7 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 unified diff | Download patch
« no previous file with comments | « webrtc/base/messagequeue.cc ('k') | webrtc/base/nullsocketserver.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. 2 * Copyright 2004 The WebRTC Project Authors. All rights reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
11 #include "webrtc/base/messagequeue.h" 11 #include "webrtc/base/messagequeue.h"
12 12
13 #include "webrtc/base/bind.h" 13 #include "webrtc/base/bind.h"
14 #include "webrtc/base/gunit.h" 14 #include "webrtc/base/gunit.h"
15 #include "webrtc/base/logging.h" 15 #include "webrtc/base/logging.h"
16 #include "webrtc/base/thread.h" 16 #include "webrtc/base/thread.h"
17 #include "webrtc/base/timeutils.h" 17 #include "webrtc/base/timeutils.h"
18 #include "webrtc/base/nullsocketserver.h" 18 #include "webrtc/base/nullsocketserver.h"
19 19
20 using namespace rtc; 20 using namespace rtc;
21 21
22 class MessageQueueTest: public testing::Test, public MessageQueue { 22 class MessageQueueTest: public testing::Test, public MessageQueue {
23 public: 23 public:
24 MessageQueueTest() : MessageQueue(SocketServer::CreateDefault(), true) {}
24 bool IsLocked_Worker() { 25 bool IsLocked_Worker() {
25 if (!crit_.TryEnter()) { 26 if (!crit_.TryEnter()) {
26 return true; 27 return true;
27 } 28 }
28 crit_.Leave(); 29 crit_.Leave();
29 return false; 30 return false;
30 } 31 }
31 bool IsLocked() { 32 bool IsLocked() {
32 // We have to do this on a worker thread, or else the TryEnter will 33 // We have to do this on a worker thread, or else the TryEnter will
33 // succeed, since our critical sections are reentrant. 34 // succeed, since our critical sections are reentrant.
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 memset(&msg, 0, sizeof(msg)); 66 memset(&msg, 0, sizeof(msg));
66 EXPECT_TRUE(q->Get(&msg, 0)); 67 EXPECT_TRUE(q->Get(&msg, 0));
67 EXPECT_EQ(i, msg.message_id); 68 EXPECT_EQ(i, msg.message_id);
68 } 69 }
69 70
70 EXPECT_FALSE(q->Get(&msg, 0)); // No more messages 71 EXPECT_FALSE(q->Get(&msg, 0)); // No more messages
71 } 72 }
72 73
73 TEST_F(MessageQueueTest, 74 TEST_F(MessageQueueTest,
74 DelayedPostsWithIdenticalTimesAreProcessedInFifoOrder) { 75 DelayedPostsWithIdenticalTimesAreProcessedInFifoOrder) {
75 MessageQueue q; 76 MessageQueue q(SocketServer::CreateDefault(), true);
76 DelayedPostsWithIdenticalTimesAreProcessedInFifoOrder(&q); 77 DelayedPostsWithIdenticalTimesAreProcessedInFifoOrder(&q);
78
77 NullSocketServer nullss; 79 NullSocketServer nullss;
78 MessageQueue q_nullss(&nullss); 80 MessageQueue q_nullss(&nullss, true);
79 DelayedPostsWithIdenticalTimesAreProcessedInFifoOrder(&q_nullss); 81 DelayedPostsWithIdenticalTimesAreProcessedInFifoOrder(&q_nullss);
80 } 82 }
81 83
82 TEST_F(MessageQueueTest, DisposeNotLocked) { 84 TEST_F(MessageQueueTest, DisposeNotLocked) {
83 bool was_locked = true; 85 bool was_locked = true;
84 bool deleted = false; 86 bool deleted = false;
85 DeletedLockChecker* d = new DeletedLockChecker(this, &was_locked, &deleted); 87 DeletedLockChecker* d = new DeletedLockChecker(this, &was_locked, &deleted);
86 Dispose(d); 88 Dispose(d);
87 Message msg; 89 Message msg;
88 EXPECT_FALSE(Get(&msg, 0)); 90 EXPECT_FALSE(Get(&msg, 0));
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 << "MessageQueueManager was already initialized by some " 133 << "MessageQueueManager was already initialized by some "
132 << "other test in this run."; 134 << "other test in this run.";
133 return; 135 return;
134 } 136 }
135 bool deleted = false; 137 bool deleted = false;
136 DeletedMessageHandler* handler = new DeletedMessageHandler(&deleted); 138 DeletedMessageHandler* handler = new DeletedMessageHandler(&deleted);
137 delete handler; 139 delete handler;
138 EXPECT_TRUE(deleted); 140 EXPECT_TRUE(deleted);
139 EXPECT_FALSE(MessageQueueManager::IsInitialized()); 141 EXPECT_FALSE(MessageQueueManager::IsInitialized());
140 } 142 }
OLDNEW
« no previous file with comments | « webrtc/base/messagequeue.cc ('k') | webrtc/base/nullsocketserver.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698