Commit cf5d5d82 authored by Sean Kau's avatar Sean Kau Committed by Commit Bot

Convert test to QuitClosure

Use a QuitClosure instead of RunUntilIdle in the CupsPrintersHandlerTest.
Test started failing if CupsPrinterManager creation was delayed.

Bug: 954623
Change-Id: I0ce986ce0995f678197b88c06186737ab56787aa
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1579325Reviewed-by: default avatarSteven Bennetts <stevenjb@chromium.org>
Commit-Queue: Sean Kau <skau@chromium.org>
Cr-Commit-Position: refs/heads/master@{#653650}
parent fec5ba94
...@@ -42,8 +42,11 @@ void AddedPrinter(int32_t status) { ...@@ -42,8 +42,11 @@ void AddedPrinter(int32_t status) {
} }
// Callback used for testing CupsRemovePrinter(). // Callback used for testing CupsRemovePrinter().
void RemovedPrinter(bool* expected, bool result) { void RemovedPrinter(base::OnceClosure quit_closure,
EXPECT_EQ(*expected, result); bool* expected,
bool result) {
*expected = result;
std::move(quit_closure).Run();
} }
class FakePrinterConfigurer : public PrinterConfigurer { class FakePrinterConfigurer : public PrinterConfigurer {
...@@ -135,11 +138,14 @@ TEST_F(CupsPrintersHandlerTest, RemoveCorrectPrinter) { ...@@ -135,11 +138,14 @@ TEST_F(CupsPrintersHandlerTest, RemoveCorrectPrinter) {
// We expect this printer removal to fail since the printer should have // We expect this printer removal to fail since the printer should have
// already been removed by the previous call to 'removeCupsPrinter'. // already been removed by the previous call to 'removeCupsPrinter'.
bool expected = false; base::RunLoop run_loop;
client->CupsRemovePrinter("testprinter1", bool expected = true;
base::BindRepeating(&RemovedPrinter, &expected), client->CupsRemovePrinter(
base::DoNothing()); "testprinter1",
thread_bundle_.RunUntilIdle(); base::BindRepeating(&RemovedPrinter, run_loop.QuitClosure(), &expected),
base::DoNothing());
run_loop.Run();
EXPECT_FALSE(expected);
} }
} // namespace settings. } // namespace settings.
......
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