Reland "Explicitly wrap main thread in test_main.cc."
This is a reland of 711a31aead9007e42dd73c302c8ec40f9e931619
Changes since original landing:
Rename methods only used by tests, mainly via FakeClock,
MessageQueueManager::ProcessAllMessageQueues
--> ProcessAllMessageQueuesForTesting
MessageQueue::IsProcessingMessages
--> IsProcessingMessagesForTesting
Fix the handling of null rtc::Thread::Current() in
ProcessAllMessageQueuesInternal().
Add override Thread::IsProcessingMessagesForTesting() to return false
for the wrapped main thread, unless it's also the current thread. In
tests, the main thread is typically not processing any messages,
but blocked in an Event::Wait().
Original change's description:
> Explicitly wrap main thread in test_main.cc.
>
> Bug: webrtc:9714
> Change-Id: I6ee234f9a0b88b3656a683f2455c3e4b2acf0d54
> Reviewed-on: https://webrtc-review.googlesource.com/97683
> Reviewed-by: Tommi <tommi@webrtc.org>
> Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
> Commit-Queue: Niels Moller <nisse@webrtc.org>
> Cr-Commit-Position: refs/heads/master@{#24560}
Bug: webrtc:9714
Change-Id: I6f022d46aaf1e28f86f09f2d68c1803b69770126
Reviewed-on: https://webrtc-review.googlesource.com/98060
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Reviewed-by: Tommi <tommi@webrtc.org>
Commit-Queue: Niels Moller <nisse@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#24596}
diff --git a/rtc_base/messagequeue.h b/rtc_base/messagequeue.h
index fe64c9c..d64ea86 100644
--- a/rtc_base/messagequeue.h
+++ b/rtc_base/messagequeue.h
@@ -49,10 +49,13 @@
// MessageQueueManager instance when necessary.
static bool IsInitialized();
- // Mainly for testing purposes, for use with a simulated clock.
+ // TODO(nisse): Delete alias, as soon as downstream code is updated.
+ static void ProcessAllMessageQueues() { ProcessAllMessageQueuesForTesting(); }
+
+ // For testing purposes, for use with a simulated clock.
// Ensures that all message queues have processed delayed messages
// up until the current point in time.
- static void ProcessAllMessageQueues();
+ static void ProcessAllMessageQueuesForTesting();
private:
static MessageQueueManager* Instance();
@@ -226,7 +229,7 @@
// Not all message queues actually process messages (such as SignalThread).
// In those cases, it's important to know, before posting, that it won't be
// Processed. Normally, this would be true until IsQuitting() is true.
- virtual bool IsProcessingMessages();
+ virtual bool IsProcessingMessagesForTesting();
// Get() will process I/O until:
// 1) A message is available (returns true)