Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1991)

Unified Diff: chrome/browser/sync/test/integration/printers_helper.cc

Issue 2799103002: Enable printers sync_integration_tests on chromeos (Closed)
Patch Set: update comments Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/browser/sync/test/integration/single_client_printers_sync_test.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..82040ab22e901271f66c99df6de8314665acdc7e 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,16 @@ std::string PrinterId(int index) {
return base::StringPrintf("printer%d", index);
}
+void WaitForTaskCompletion() {
+ // Since PrintersManagerFactory::BuildServiceInstanceFor() uses
+ // content::BrowserThread::GetBlockingPool() to schedule tasks, tests need to
skym 2017/04/06 21:03:03 So what if the PrintersManagerFactory schedules ta
Gang Wu 2017/04/06 21:50:56 Done.
+ // Wait for tasks running on content::BrowserThread::GetBlockingPool() to be
skym 2017/04/06 21:03:03 Wait shouldn't be capitalized
Gang Wu 2017/04/06 21:50:56 Done.
+ // completed and sent replay to UI thread.
+ content::BrowserThread::GetBlockingPool()->FlushForTesting();
+ // Wait for UI thread task completion.
skym 2017/04/06 21:03:03 Can you elaborate what's going on here? What's bei
Gang Wu 2017/04/06 21:50:56 Done.
+ base::RunLoop().RunUntilIdle();
+}
+
} // namespace
void AddPrinter(chromeos::PrintersManager* manager,
@@ -110,7 +122,7 @@ chromeos::PrintersManager* GetVerifierPrinterStore() {
chromeos::PrintersManagerFactory::GetForBrowserContext(
skym 2017/04/06 21:03:03 It seems like there's more stuff that can be moved
Gang Wu 2017/04/06 21:50:56 Done.
sync_datatype_helper::test()->verifier());
// Must wait for ModelTypeStore initialization.
- base::RunLoop().RunUntilIdle();
+ WaitForTaskCompletion();
skym 2017/04/06 21:03:03 Does this really need to be called on every GetVer
Gang Wu 2017/04/06 21:50:56 no, just first one. but I think there is no harm t
skym 2017/04/06 22:52:11 I don't think I agree there is no harm done, but I
return manager;
}
@@ -120,7 +132,7 @@ chromeos::PrintersManager* GetPrinterStore(int index) {
chromeos::PrintersManagerFactory::GetForBrowserContext(
sync_datatype_helper::test()->GetProfile(index));
// Must wait for ModelTypeStore initialization.
- base::RunLoop().RunUntilIdle();
+ WaitForTaskCompletion();
return manager;
}
« no previous file with comments | « no previous file | chrome/browser/sync/test/integration/single_client_printers_sync_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698