Commit e2ea2d5b authored by Ken Rockot's avatar Ken Rockot Committed by Commit Bot

Fix FrameSinkVideoCaptureDevice tests

Fixes the behavior of some of these tests with
https://chromium-review.googlesource.com/c/chromium/src/+/1145692
applied. That CL changes how Mojo bindings dispatch messages, but
only timing (not ordering) is changed. This can break subtle test
expecations, as is the case here.

This change replaces use of deprecated RunAllPendingInMessageLoop with
either RunLoop usage or TestBrowserThreadBundle::RunIOThreadUntilIdle.
In the latter case, in order to achieve synchronization parity with the
code before this change, note that it is also necessary to have
WAIT_FOR_DEVICE_TASKS wait for the UI thread to idle after the IO
thread has idled, due to the way RunAllPendingInMessageLoop worked.

Bug: 895693
Change-Id: I15552766245eda0bdce141c40643ee4b44cc90a8
Reviewed-on: https://chromium-review.googlesource.com/c/1286432
Commit-Queue: Yuri Wiitala <miu@chromium.org>
Reviewed-by: default avatarYuri Wiitala <miu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#600601}
parent 235eeefa
......@@ -49,7 +49,7 @@ namespace {
#define DCHECK_NOT_ON_DEVICE_THREAD() DCHECK_CURRENTLY_ON(BrowserThread::UI)
// Convenience macro to block the test procedure and run all pending UI tasks.
#define RUN_UI_TASKS() RunAllPendingInMessageLoop(BrowserThread::UI)
#define RUN_UI_TASKS() base::RunLoop().RunUntilIdle()
// Convenience macro to post a task to run on the device thread.
#define POST_DEVICE_TASK(closure) \
......@@ -57,7 +57,9 @@ namespace {
// Convenience macro to block the test procedure until all pending tasks have
// run on the device thread.
#define WAIT_FOR_DEVICE_TASKS() RunAllPendingInMessageLoop(BrowserThread::IO)
#define WAIT_FOR_DEVICE_TASKS() \
browser_threads_.RunIOThreadUntilIdle(); \
RUN_UI_TASKS()
// Capture parameters.
constexpr gfx::Size kResolution = gfx::Size(320, 180);
......@@ -407,11 +409,10 @@ class FrameSinkVideoCaptureDeviceTest : public testing::Test {
return true;
}
private:
protected:
// See the threading notes at top of this file.
TestBrowserThreadBundle browser_threads_;
protected:
NiceMock<MockFrameSinkVideoCapturer> capturer_;
std::unique_ptr<FrameSinkVideoCaptureDevice> device_;
};
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment