Adding the ability to use a simulated clock for unit tests.
This will be useful for any tests that test objects with time-dependent behavior. It will allow such tests to be written in such a way that their outcome is more repeatable (less flaky), and will also allow such tests to finish quicker. For example, a test for STUN timeout doesn't need to wait the full timeout interval in real time; it can simply advance the simulated clock. BUG=webrtc:4925 R=pthatcher@webrtc.org Review URL: https://codereview.webrtc.org/1895933003 . Cr-Commit-Position: refs/heads/master@{#12950}
This commit is contained in:
@ -37,7 +37,7 @@ class MessageQueue;
|
||||
|
||||
// MessageQueueManager does cleanup of of message queues
|
||||
|
||||
class MessageQueueManager {
|
||||
class MessageQueueManager : public MessageHandler {
|
||||
public:
|
||||
static void Add(MessageQueue *message_queue);
|
||||
static void Remove(MessageQueue *message_queue);
|
||||
@ -49,15 +49,22 @@ class MessageQueueManager {
|
||||
// MessageQueueManager instance when necessary.
|
||||
static bool IsInitialized();
|
||||
|
||||
// Mainly for testing purposes, for use with a simulated clock.
|
||||
// Posts a no-op event on all message queues so they will wake from the
|
||||
// socket server select() and process messages again.
|
||||
static void WakeAllMessageQueues();
|
||||
|
||||
private:
|
||||
static MessageQueueManager* Instance();
|
||||
|
||||
MessageQueueManager();
|
||||
~MessageQueueManager();
|
||||
~MessageQueueManager() override;
|
||||
|
||||
void AddInternal(MessageQueue *message_queue);
|
||||
void RemoveInternal(MessageQueue *message_queue);
|
||||
void ClearInternal(MessageHandler *handler);
|
||||
void WakeAllMessageQueuesInternal();
|
||||
void OnMessage(Message* pmsg) override;
|
||||
|
||||
static MessageQueueManager* instance_;
|
||||
// This list contains all live MessageQueues.
|
||||
|
||||
Reference in New Issue
Block a user