Introduce a RunLoop class that supports the TaskQueue interface
on the current thread.
This simplifies writing async tests that use TaskQueue and doesn't
require spinning up a new thread for simple things. The implementation
is currently based on rtc::Thread, which could also be useful in
some circumstances while migrating code over to TQ.
Remove PressEnterToContinue from the test_common files since
it's very specific and only used from one file.
Bug: none
Change-Id: I8b2c6c40809271a109ec17cf7e1120847645d58a
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/174260
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Commit-Queue: Tommi <tommi@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#31160}
diff --git a/video/video_quality_test.cc b/video/video_quality_test.cc
index 0482cb0..a8f475a 100644
--- a/video/video_quality_test.cc
+++ b/video/video_quality_test.cc
@@ -11,6 +11,10 @@
#include <stdio.h>
+#if defined(WEBRTC_WIN)
+#include <conio.h>
+#endif
+
#include <algorithm>
#include <deque>
#include <map>
@@ -43,7 +47,6 @@
#include "rtc_base/strings/string_builder.h"
#include "rtc_base/task_queue_for_test.h"
#include "test/platform_video_capturer.h"
-#include "test/run_loop.h"
#include "test/testsupport/file_utils.h"
#include "test/video_renderer.h"
#include "video/frame_dumping_decoder.h"
@@ -270,6 +273,29 @@
VideoCodec codec_settings_;
};
+#if defined(WEBRTC_WIN) && !defined(WINUWP)
+void PressEnterToContinue(TaskQueueBase* task_queue) {
+ puts(">> Press ENTER to continue...");
+
+ while (!_kbhit() || _getch() != '\r') {
+ // Drive the message loop for the thread running the task_queue
+ SendTask(RTC_FROM_HERE, task_queue, [&]() {
+ MSG msg;
+ if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) {
+ TranslateMessage(&msg);
+ DispatchMessage(&msg);
+ }
+ });
+ }
+}
+#else
+void PressEnterToContinue(TaskQueueBase* /*task_queue*/) {
+ puts(">> Press ENTER to continue...");
+ while (getc(stdin) != '\n' && !feof(stdin))
+ ; // NOLINT
+}
+#endif
+
} // namespace
std::unique_ptr<VideoDecoder> VideoQualityTest::CreateVideoDecoder(
@@ -1570,7 +1596,7 @@
Start();
});
- test::PressEnterToContinue(task_queue());
+ PressEnterToContinue(task_queue());
SendTask(RTC_FROM_HERE, task_queue(), [&]() {
Stop();