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}
This commit is contained in:
Danail Kirov 2018-10-25 10:45:47 -07:00 committed by Commit Bot
parent 2c16cc61c2
commit 6fcf6ca710
5 changed files with 16 additions and 10 deletions

View File

@ -16,6 +16,7 @@ Cody Barnes <conceptgenesis@gmail.com>
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>

View File

@ -14,7 +14,7 @@
namespace webrtc {
namespace test {
void PressEnterToContinue() {
void PressEnterToContinue(SingleThreadedTaskQueueForTesting&) {
puts(">> Press ENTER to continue...");
while (getc(stdin) != '\n' && !feof(stdin))
;

View File

@ -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

View File

@ -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

View File

@ -1381,7 +1381,7 @@ void VideoQualityTest::RunWithRenderers(const Params& params) {
Start();
});
test::PressEnterToContinue();
test::PressEnterToContinue(task_queue_);
task_queue_.SendTask([&]() {
Stop();