Commit 864d4cde authored by gangwu's avatar gangwu Committed by Commit bot

Enable printers sync_integration_tests on chromeos

Fix printer flaky bugs by adding another wait.
The bug is flaky because tests only wait for UI tasks to be completed,
but since PrintersManagerFactory uses
content::BrowserThread::GetBlockingPool() to schedule ModelTypeStore
initialization, and then reply result to UI thread, so we need to wait
on content::BrowserThread::GetBlockingPool() as well.

Remove unnecessary changes from
https://codereview.chromium.org/2758643002 since that did not really
fix this waiting issue.

BUG=689662, 701999

Review-Url: https://codereview.chromium.org/2799103002
Cr-Commit-Position: refs/heads/master@{#462716}
parent 932a1737
...@@ -13,10 +13,12 @@ ...@@ -13,10 +13,12 @@
#include "base/memory/ptr_util.h" #include "base/memory/ptr_util.h"
#include "base/run_loop.h" #include "base/run_loop.h"
#include "base/strings/stringprintf.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.h"
#include "chrome/browser/chromeos/printing/printers_manager_factory.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_datatype_helper.h"
#include "chrome/browser/sync/test/integration/sync_test.h" #include "chrome/browser/sync/test/integration/sync_test.h"
#include "content/public/browser/browser_thread.h"
using sync_datatype_helper::test; using sync_datatype_helper::test;
...@@ -65,6 +67,24 @@ std::string PrinterId(int index) { ...@@ -65,6 +67,24 @@ std::string PrinterId(int index) {
return base::StringPrintf("printer%d", index); return base::StringPrintf("printer%d", index);
} }
chromeos::PrintersManager* GetPrinterStore(content::BrowserContext* context) {
chromeos::PrintersManager* manager =
chromeos::PrintersManagerFactory::GetForBrowserContext(context);
// TODO(sync): crbug.com/709094: Remove all of this once the bug is fixed.
// Must wait for ModelTypeStore initialization.
// 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 } // namespace
void AddPrinter(chromeos::PrintersManager* manager, void AddPrinter(chromeos::PrintersManager* manager,
...@@ -107,20 +127,14 @@ chromeos::Printer CreateTestPrinter(int index) { ...@@ -107,20 +127,14 @@ chromeos::Printer CreateTestPrinter(int index) {
chromeos::PrintersManager* GetVerifierPrinterStore() { chromeos::PrintersManager* GetVerifierPrinterStore() {
chromeos::PrintersManager* manager = chromeos::PrintersManager* manager =
chromeos::PrintersManagerFactory::GetForBrowserContext( GetPrinterStore(sync_datatype_helper::test()->verifier());
sync_datatype_helper::test()->verifier());
// Must wait for ModelTypeStore initialization.
base::RunLoop().RunUntilIdle();
return manager; return manager;
} }
chromeos::PrintersManager* GetPrinterStore(int index) { chromeos::PrintersManager* GetPrinterStore(int index) {
chromeos::PrintersManager* manager = chromeos::PrintersManager* manager =
chromeos::PrintersManagerFactory::GetForBrowserContext( GetPrinterStore(sync_datatype_helper::test()->GetProfile(index));
sync_datatype_helper::test()->GetProfile(index));
// Must wait for ModelTypeStore initialization.
base::RunLoop().RunUntilIdle();
return manager; return manager;
} }
......
...@@ -25,14 +25,6 @@ class SingleClientPrintersSyncTest : public SyncTest { ...@@ -25,14 +25,6 @@ class SingleClientPrintersSyncTest : public SyncTest {
SingleClientPrintersSyncTest() : SyncTest(SINGLE_CLIENT) {} SingleClientPrintersSyncTest() : SyncTest(SINGLE_CLIENT) {}
~SingleClientPrintersSyncTest() override {} ~SingleClientPrintersSyncTest() override {}
bool SetupSync() override {
if (!SyncTest::SetupSync())
return false;
// Wait for sync to complete initialization before proceeding.
return UpdatedProgressMarkerChecker(GetSyncService(0)).Wait();
}
private: private:
DISALLOW_COPY_AND_ASSIGN(SingleClientPrintersSyncTest); DISALLOW_COPY_AND_ASSIGN(SingleClientPrintersSyncTest);
}; };
...@@ -40,6 +32,12 @@ class SingleClientPrintersSyncTest : public SyncTest { ...@@ -40,6 +32,12 @@ class SingleClientPrintersSyncTest : public SyncTest {
// Verify that printers aren't added with a sync call. // Verify that printers aren't added with a sync call.
IN_PROC_BROWSER_TEST_F(SingleClientPrintersSyncTest, NoPrinters) { IN_PROC_BROWSER_TEST_F(SingleClientPrintersSyncTest, NoPrinters) {
ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
// TODO(sync): Should not use UpdatedProgressMarkerChecker here since
// UpdatedProgressMarkerChecker is for SyncableService datatype, but
// syncer::PRINTERS is ModelTypeSyncBridge datatype. So maybe we should create
// another checker for ModelTypeSyncBridge, or some other things to wait for
// ModelTypeSyncBridge datatype.
ASSERT_TRUE(UpdatedProgressMarkerChecker(GetSyncService(0)).Wait());
EXPECT_TRUE(ProfileContainsSamePrintersAsVerifier(0)); EXPECT_TRUE(ProfileContainsSamePrintersAsVerifier(0));
} }
...@@ -60,13 +58,7 @@ IN_PROC_BROWSER_TEST_F(SingleClientPrintersSyncTest, SingleNewPrinter) { ...@@ -60,13 +58,7 @@ IN_PROC_BROWSER_TEST_F(SingleClientPrintersSyncTest, SingleNewPrinter) {
} }
// Verify editing a printer doesn't add it. // Verify editing a printer doesn't add it.
// Flaky on ChromeOS. http://crbug.com/701999 IN_PROC_BROWSER_TEST_F(SingleClientPrintersSyncTest, EditPrinter) {
#if defined(OS_CHROMEOS)
#define MAYBE_EditPrinter DISABLED_EditPrinter
#else
#define MAYBE_EditPrinter EditPrinter
#endif
IN_PROC_BROWSER_TEST_F(SingleClientPrintersSyncTest, MAYBE_EditPrinter) {
ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
AddPrinter(GetPrinterStore(0), printers_helper::CreateTestPrinter(0)); AddPrinter(GetPrinterStore(0), printers_helper::CreateTestPrinter(0));
...@@ -92,13 +84,7 @@ IN_PROC_BROWSER_TEST_F(SingleClientPrintersSyncTest, RemovePrinter) { ...@@ -92,13 +84,7 @@ IN_PROC_BROWSER_TEST_F(SingleClientPrintersSyncTest, RemovePrinter) {
} }
// Verify that merging data added before sync works. // Verify that merging data added before sync works.
// crbug.com/689662 IN_PROC_BROWSER_TEST_F(SingleClientPrintersSyncTest, AddBeforeSetup) {
#if defined(OS_CHROMEOS)
#define MAYBE_AddBeforeSetup DISABLED_AddBeforeSetup
#else
#define MAYBE_AddBeforeSetup AddBeforeSetup
#endif
IN_PROC_BROWSER_TEST_F(SingleClientPrintersSyncTest, MAYBE_AddBeforeSetup) {
ASSERT_TRUE(SetupClients()); ASSERT_TRUE(SetupClients());
AddPrinter(GetPrinterStore(0), printers_helper::CreateTestPrinter(0)); AddPrinter(GetPrinterStore(0), printers_helper::CreateTestPrinter(0));
......
...@@ -128,13 +128,7 @@ IN_PROC_BROWSER_TEST_F(TwoClientPrintersSyncTest, ConflictResolution) { ...@@ -128,13 +128,7 @@ IN_PROC_BROWSER_TEST_F(TwoClientPrintersSyncTest, ConflictResolution) {
EXPECT_EQ(valid_message, GetPrinterStore(1)->GetPrinters()[0]->description()); EXPECT_EQ(valid_message, GetPrinterStore(1)->GetPrinters()[0]->description());
} }
// crbug.com/689662 IN_PROC_BROWSER_TEST_F(TwoClientPrintersSyncTest, SimpleMerge) {
#if defined(OS_CHROMEOS)
#define MAYBE_SimpleMerge DISABLED_SimpleMerge
#else
#define MAYBE_SimpleMerge SimpleMerge
#endif
IN_PROC_BROWSER_TEST_F(TwoClientPrintersSyncTest, MAYBE_SimpleMerge) {
ASSERT_TRUE(SetupClients()); ASSERT_TRUE(SetupClients());
base::RunLoop().RunUntilIdle(); base::RunLoop().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