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 2019423006: Adding more detail to MessageQueue::Dispatch logging. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Fixing one more place where RTC_FROM_HERE wasn't used. Created 4 years, 6 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/network.cc » ('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
(...skipping 17 matching lines...) Expand all
28 } 28 }
29 crit_.Leave(); 29 crit_.Leave();
30 return false; 30 return false;
31 } 31 }
32 bool IsLocked() { 32 bool IsLocked() {
33 // 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
34 // succeed, since our critical sections are reentrant. 34 // succeed, since our critical sections are reentrant.
35 Thread worker; 35 Thread worker;
36 worker.Start(); 36 worker.Start();
37 return worker.Invoke<bool>( 37 return worker.Invoke<bool>(
38 rtc::Bind(&MessageQueueTest::IsLocked_Worker, this)); 38 RTC_FROM_HERE, rtc::Bind(&MessageQueueTest::IsLocked_Worker, this));
39 } 39 }
40 }; 40 };
41 41
42 struct DeletedLockChecker { 42 struct DeletedLockChecker {
43 DeletedLockChecker(MessageQueueTest* test, bool* was_locked, bool* deleted) 43 DeletedLockChecker(MessageQueueTest* test, bool* was_locked, bool* deleted)
44 : test(test), was_locked(was_locked), deleted(deleted) { } 44 : test(test), was_locked(was_locked), deleted(deleted) { }
45 ~DeletedLockChecker() { 45 ~DeletedLockChecker() {
46 *deleted = true; 46 *deleted = true;
47 *was_locked = test->IsLocked(); 47 *was_locked = test->IsLocked();
48 } 48 }
49 MessageQueueTest* test; 49 MessageQueueTest* test;
50 bool* was_locked; 50 bool* was_locked;
51 bool* deleted; 51 bool* deleted;
52 }; 52 };
53 53
54 static void DelayedPostsWithIdenticalTimesAreProcessedInFifoOrder( 54 static void DelayedPostsWithIdenticalTimesAreProcessedInFifoOrder(
55 MessageQueue* q) { 55 MessageQueue* q) {
56 EXPECT_TRUE(q != NULL); 56 EXPECT_TRUE(q != NULL);
57 int64_t now = TimeMillis(); 57 int64_t now = TimeMillis();
58 q->PostAt(now, NULL, 3); 58 q->PostAt(RTC_FROM_HERE, now, NULL, 3);
59 q->PostAt(now - 2, NULL, 0); 59 q->PostAt(RTC_FROM_HERE, now - 2, NULL, 0);
60 q->PostAt(now - 1, NULL, 1); 60 q->PostAt(RTC_FROM_HERE, now - 1, NULL, 1);
61 q->PostAt(now, NULL, 4); 61 q->PostAt(RTC_FROM_HERE, now, NULL, 4);
62 q->PostAt(now - 1, NULL, 2); 62 q->PostAt(RTC_FROM_HERE, now - 1, NULL, 2);
63 63
64 Message msg; 64 Message msg;
65 for (size_t i=0; i<5; ++i) { 65 for (size_t i=0; i<5; ++i) {
66 memset(&msg, 0, sizeof(msg)); 66 memset(&msg, 0, sizeof(msg));
67 EXPECT_TRUE(q->Get(&msg, 0)); 67 EXPECT_TRUE(q->Get(&msg, 0));
68 EXPECT_EQ(i, msg.message_id); 68 EXPECT_EQ(i, msg.message_id);
69 } 69 }
70 70
71 EXPECT_FALSE(q->Get(&msg, 0)); // No more messages 71 EXPECT_FALSE(q->Get(&msg, 0)); // No more messages
72 } 72 }
(...skipping 29 matching lines...) Expand all
102 private: 102 private:
103 bool* deleted_; 103 bool* deleted_;
104 }; 104 };
105 105
106 TEST_F(MessageQueueTest, DiposeHandlerWithPostedMessagePending) { 106 TEST_F(MessageQueueTest, DiposeHandlerWithPostedMessagePending) {
107 bool deleted = false; 107 bool deleted = false;
108 DeletedMessageHandler *handler = new DeletedMessageHandler(&deleted); 108 DeletedMessageHandler *handler = new DeletedMessageHandler(&deleted);
109 // First, post a dispose. 109 // First, post a dispose.
110 Dispose(handler); 110 Dispose(handler);
111 // Now, post a message, which should *not* be returned by Get(). 111 // Now, post a message, which should *not* be returned by Get().
112 Post(handler, 1); 112 Post(RTC_FROM_HERE, handler, 1);
113 Message msg; 113 Message msg;
114 EXPECT_FALSE(Get(&msg, 0)); 114 EXPECT_FALSE(Get(&msg, 0));
115 EXPECT_TRUE(deleted); 115 EXPECT_TRUE(deleted);
116 } 116 }
117 117
118 struct UnwrapMainThreadScope { 118 struct UnwrapMainThreadScope {
119 UnwrapMainThreadScope() : rewrap_(Thread::Current() != NULL) { 119 UnwrapMainThreadScope() : rewrap_(Thread::Current() != NULL) {
120 if (rewrap_) ThreadManager::Instance()->UnwrapCurrentThread(); 120 if (rewrap_) ThreadManager::Instance()->UnwrapCurrentThread();
121 } 121 }
122 ~UnwrapMainThreadScope() { 122 ~UnwrapMainThreadScope() {
(...skipping 10 matching lines...) Expand all
133 << "MessageQueueManager was already initialized by some " 133 << "MessageQueueManager was already initialized by some "
134 << "other test in this run."; 134 << "other test in this run.";
135 return; 135 return;
136 } 136 }
137 bool deleted = false; 137 bool deleted = false;
138 DeletedMessageHandler* handler = new DeletedMessageHandler(&deleted); 138 DeletedMessageHandler* handler = new DeletedMessageHandler(&deleted);
139 delete handler; 139 delete handler;
140 EXPECT_TRUE(deleted); 140 EXPECT_TRUE(deleted);
141 EXPECT_FALSE(MessageQueueManager::IsInitialized()); 141 EXPECT_FALSE(MessageQueueManager::IsInitialized());
142 } 142 }
OLDNEW
« no previous file with comments | « webrtc/base/messagequeue.cc ('k') | webrtc/base/network.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698