Commit 24feac12 authored by Evan Shrubsole's avatar Evan Shrubsole Committed by Commit Bot

Fix flaky FakeAudioWorkerTest::FakeBasicCallback

Bug: 945486
Change-Id: I6adac460304d7477c548bc5efc062e147cdc99f6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1660650
Commit-Queue: Evan Shrubsole <eshr@google.com>
Reviewed-by: default avatarMax Morin <maxmorin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#670022}
parent f1309530
...@@ -44,16 +44,6 @@ class FakeAudioWorkerTest : public testing::Test { ...@@ -44,16 +44,6 @@ class FakeAudioWorkerTest : public testing::Test {
&FakeAudioWorkerTest::CalledByFakeWorker, base::Unretained(this))); &FakeAudioWorkerTest::CalledByFakeWorker, base::Unretained(this)));
} }
void RunOnceOnAudioThread() {
ASSERT_TRUE(TaskRunner()->BelongsToCurrentThread());
RunOnAudioThread();
// Start() should immediately post a task to run the callback, so we
// should end up with only a single callback being run.
TaskRunner()->PostTask(FROM_HERE,
base::BindOnce(&FakeAudioWorkerTest::EndTest,
base::Unretained(this), 1));
}
void StopStartOnAudioThread() { void StopStartOnAudioThread() {
ASSERT_TRUE(TaskRunner()->BelongsToCurrentThread()); ASSERT_TRUE(TaskRunner()->BelongsToCurrentThread());
fake_worker_.Stop(); fake_worker_.Stop();
...@@ -102,17 +92,21 @@ class FakeAudioWorkerTest : public testing::Test { ...@@ -102,17 +92,21 @@ class FakeAudioWorkerTest : public testing::Test {
DISALLOW_COPY_AND_ASSIGN(FakeAudioWorkerTest); DISALLOW_COPY_AND_ASSIGN(FakeAudioWorkerTest);
}; };
// Ensure the worker runs on the audio thread and fires callbacks. TEST_F(FakeAudioWorkerTest, FakeBasicCallback) {
// TODO(https://crbug.com/945486): Flakily failing on Fuchsia. base::OnceClosure run_on_audio_thread = base::BindOnce(
#if defined(OS_FUCHSIA) &FakeAudioWorkerTest::RunOnAudioThread, base::Unretained(this));
#define MAYBE_FakeBasicCallback DISABLED_FakeBasicCallback base::OnceClosure end_test =
#else base::BindOnce(&FakeAudioWorkerTest::EndTest, base::Unretained(this), 1);
#define MAYBE_FakeBasicCallback FakeBasicCallback
#endif // Start() should immediately post a task to run the callback, so we
TEST_F(FakeAudioWorkerTest, MAYBE_FakeBasicCallback) { // should end up with only a single callback being run.
scoped_task_environment_.GetMainThreadTaskRunner()->PostTask( //
FROM_HERE, base::BindOnce(&FakeAudioWorkerTest::RunOnceOnAudioThread, // PostTaskAndReply because we want to end_test after run_on_audio_thread is
base::Unretained(this))); // finished. This is because RunOnAudioThread may post other tasks which
// should run before we end_test.
scoped_task_environment_.GetMainThreadTaskRunner()->PostTaskAndReply(
FROM_HERE, std::move(run_on_audio_thread), std::move(end_test));
scoped_task_environment_.RunUntilIdle(); scoped_task_environment_.RunUntilIdle();
} }
......
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