Chromium Code Reviews| Index: chrome/browser/sync/test/integration/printers_helper.cc |
| diff --git a/chrome/browser/sync/test/integration/printers_helper.cc b/chrome/browser/sync/test/integration/printers_helper.cc |
| index 084e1d02ae2293e88a6eed2792136d7bf88200b0..bea64e6d9d27d7c5a3bd7938f59ff865f2927ee2 100644 |
| --- a/chrome/browser/sync/test/integration/printers_helper.cc |
| +++ b/chrome/browser/sync/test/integration/printers_helper.cc |
| @@ -13,10 +13,12 @@ |
| #include "base/memory/ptr_util.h" |
| #include "base/run_loop.h" |
| #include "base/strings/stringprintf.h" |
| +#include "base/threading/sequenced_worker_pool.h" |
| #include "chrome/browser/chromeos/printing/printers_manager.h" |
| #include "chrome/browser/chromeos/printing/printers_manager_factory.h" |
| #include "chrome/browser/sync/test/integration/sync_datatype_helper.h" |
| #include "chrome/browser/sync/test/integration/sync_test.h" |
| +#include "content/public/browser/browser_thread.h" |
| using sync_datatype_helper::test; |
| @@ -65,6 +67,23 @@ std::string PrinterId(int index) { |
| return base::StringPrintf("printer%d", index); |
| } |
| +chromeos::PrintersManager* GetPrinterStore(content::BrowserContext* context) { |
| + chromeos::PrintersManager* manager = |
| + chromeos::PrintersManagerFactory::GetForBrowserContext(context); |
| + |
| + // Must wait for ModelTypeStore initialization. |
|
skym
2017/04/06 22:52:11
Can you add that we can probably remove all of thi
Gang Wu
2017/04/07 22:02:55
Done.
|
| + // Since PrintersManagerFactory::BuildServiceInstanceFor() uses |
| + // content::BrowserThread::GetBlockingPool() to schedule ModelTypeStore |
| + // initialization, tests need to wait for initialization to be completed and |
| + // sent ModelTypeStore to UI thread. |
| + content::BrowserThread::GetBlockingPool()->FlushForTesting(); |
| + // Wait for UI thread task completion to make sure PrintersSyncBridge received |
| + // ModelTypeStore. |
| + base::RunLoop().RunUntilIdle(); |
| + |
| + return manager; |
| +} |
| + |
| } // namespace |
| void AddPrinter(chromeos::PrintersManager* manager, |
| @@ -107,20 +126,14 @@ chromeos::Printer CreateTestPrinter(int index) { |
| chromeos::PrintersManager* GetVerifierPrinterStore() { |
| chromeos::PrintersManager* manager = |
| - chromeos::PrintersManagerFactory::GetForBrowserContext( |
| - sync_datatype_helper::test()->verifier()); |
| - // Must wait for ModelTypeStore initialization. |
| - base::RunLoop().RunUntilIdle(); |
| + GetPrinterStore(sync_datatype_helper::test()->verifier()); |
| return manager; |
| } |
| chromeos::PrintersManager* GetPrinterStore(int index) { |
| chromeos::PrintersManager* manager = |
| - chromeos::PrintersManagerFactory::GetForBrowserContext( |
| - sync_datatype_helper::test()->GetProfile(index)); |
| - // Must wait for ModelTypeStore initialization. |
| - base::RunLoop().RunUntilIdle(); |
| + GetPrinterStore(sync_datatype_helper::test()->GetProfile(index)); |
| return manager; |
| } |