From 6fcf6ca71088691913042998db1816e51b9e08c2 Mon Sep 17 00:00:00 2001 From: Danail Kirov Date: Thu, 25 Oct 2018 10:45:47 -0700 Subject: [PATCH] Modified PressEnterToContinue() to actualy check if Enter is pressed MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Reviewed-by: Patrik Höglund Cr-Commit-Position: refs/heads/master@{#25408} --- AUTHORS | 1 + test/run_loop.cc | 2 +- test/run_loop.h | 4 +++- test/win/run_loop_win.cc | 17 ++++++++++------- video/video_quality_test.cc | 2 +- 5 files changed, 16 insertions(+), 10 deletions(-) diff --git a/AUTHORS b/AUTHORS index e24dd518dd..c85a4e8764 100644 --- a/AUTHORS +++ b/AUTHORS @@ -16,6 +16,7 @@ Cody Barnes Colin Plumb David Porter Dax Booysen +Danail Kirov Dmitry Lizin Eric Rescorla, RTFM Inc. Frederik Riedel, Frogg GmbH diff --git a/test/run_loop.cc b/test/run_loop.cc index dc2ec18eea..052662a464 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 90063dc3e8..36bfa06697 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 28dc9334e0..ee936358fa 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 964e918989..15579d855b 100644 --- a/video/video_quality_test.cc +++ b/video/video_quality_test.cc @@ -1381,7 +1381,7 @@ void VideoQualityTest::RunWithRenderers(const Params& params) { Start(); }); - test::PressEnterToContinue(); + test::PressEnterToContinue(task_queue_); task_queue_.SendTask([&]() { Stop();