Modified PressEnterToContinue() to actualy check if Enter is pressed
Modified PressEnterToContinue() to run the Windows message loop in the
context of the SingleThreadedTaskQueueForTesting thread. The previous
PressEnterToContinue() was running the message loop in the context of
the main thread, but the "Local Preview" and "Loopback Video #0" are
created in the context of the SingleThreadedTaskQueueForTesting thread
and the message loop must be executed in the context of the thread that
created these windows in order for these windows to respond to any
event.
BUG=webrtc:9123
Change-Id: I2ec19f2569a940a510d3b2bd3881a89032d70332
Reviewed-on: https://webrtc-review.googlesource.com/c/67520
Commit-Queue: Patrik Höglund <phoglund@webrtc.org>
Reviewed-by: Patrik Höglund <phoglund@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#25408}
diff --git a/AUTHORS b/AUTHORS
index e24dd51..c85a4e8 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -16,6 +16,7 @@
Colin Plumb
David Porter <david@porter.me>
Dax Booysen <dax@younow.com>
+Danail Kirov <dkirovbroadsoft@gmail.com>
Dmitry Lizin <sdkdimon@gmail.com>
Eric Rescorla, RTFM Inc. <ekr@rtfm.com>
Frederik Riedel, Frogg GmbH <frederik.riedel@frogg.io>
diff --git a/test/run_loop.cc b/test/run_loop.cc
index dc2ec18..052662a 100644
--- a/test/run_loop.cc
+++ b/test/run_loop.cc
@@ -14,7 +14,7 @@
namespace webrtc {
namespace test {
-void PressEnterToContinue() {
+void PressEnterToContinue(SingleThreadedTaskQueueForTesting&) {
puts(">> Press ENTER to continue...");
while (getc(stdin) != '\n' && !feof(stdin))
;
diff --git a/test/run_loop.h b/test/run_loop.h
index 90063dc..36bfa06 100644
--- a/test/run_loop.h
+++ b/test/run_loop.h
@@ -10,11 +10,13 @@
#ifndef TEST_RUN_LOOP_H_
#define TEST_RUN_LOOP_H_
+#include "test/single_threaded_task_queue.h"
+
namespace webrtc {
namespace test {
// Blocks until the user presses enter.
-void PressEnterToContinue();
+void PressEnterToContinue(SingleThreadedTaskQueueForTesting &task_queue);
} // namespace test
} // namespace webrtc
diff --git a/test/win/run_loop_win.cc b/test/win/run_loop_win.cc
index 28dc933..ee93635 100644
--- a/test/win/run_loop_win.cc
+++ b/test/win/run_loop_win.cc
@@ -18,15 +18,18 @@
namespace webrtc {
namespace test {
-void PressEnterToContinue() {
+void PressEnterToContinue(SingleThreadedTaskQueueForTesting &task_queue) {
puts(">> Press ENTER to continue...");
- MSG msg;
- BOOL ret;
- while ((ret = GetMessage(&msg, NULL, 0, 0)) != 0) {
- assert(ret != -1);
- TranslateMessage(&msg);
- DispatchMessage(&msg);
+ while (!_kbhit() || _getch() != '\r') {
+ // Drive the message loop for the thread running the task_queue
+ task_queue.SendTask([&]() {
+ MSG msg;
+ if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) {
+ TranslateMessage(&msg);
+ DispatchMessage(&msg);
+ }
+ });
}
}
} // namespace test
diff --git a/video/video_quality_test.cc b/video/video_quality_test.cc
index 964e918..15579d8 100644
--- a/video/video_quality_test.cc
+++ b/video/video_quality_test.cc
@@ -1381,7 +1381,7 @@
Start();
});
- test::PressEnterToContinue();
+ test::PressEnterToContinue(task_queue_);
task_queue_.SendTask([&]() {
Stop();