| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include <stddef.h> | 5 #include <stddef.h> |
| 6 | 6 |
| 7 #include "base/macros.h" | 7 #include "base/macros.h" |
| 8 #include "chrome/browser/sync/test/integration/printers_helper.h" | 8 #include "chrome/browser/sync/test/integration/printers_helper.h" |
| 9 #include "chrome/browser/sync/test/integration/sync_test.h" | 9 #include "chrome/browser/sync/test/integration/sync_test.h" |
| 10 #include "chrome/browser/sync/test/integration/updated_progress_marker_checker.h
" | 10 #include "chrome/browser/sync/test/integration/updated_progress_marker_checker.h
" |
| 11 #include "chromeos/printing/printer_configuration.h" | 11 #include "chromeos/printing/printer_configuration.h" |
| 12 | 12 |
| 13 using printers_helper::AddPrinter; | 13 using printers_helper::AddPrinter; |
| 14 using printers_helper::CreateTestPrinter; | 14 using printers_helper::CreateTestPrinter; |
| 15 using printers_helper::EditPrinterDescription; | 15 using printers_helper::EditPrinterDescription; |
| 16 using printers_helper::GetVerifierPrinterCount; | 16 using printers_helper::GetVerifierPrinterCount; |
| 17 using printers_helper::GetVerifierPrinterStore; | 17 using printers_helper::GetVerifierPrinterStore; |
| 18 using printers_helper::GetPrinterCount; | 18 using printers_helper::GetPrinterCount; |
| 19 using printers_helper::GetPrinterStore; | 19 using printers_helper::GetPrinterStore; |
| 20 using printers_helper::ProfileContainsSamePrintersAsVerifier; | 20 using printers_helper::ProfileContainsSamePrintersAsVerifier; |
| 21 using printers_helper::RemovePrinter; | 21 using printers_helper::RemovePrinter; |
| 22 | 22 |
| 23 class SingleClientPrintersSyncTest : public SyncTest { | 23 class SingleClientPrintersSyncTest : public SyncTest { |
| 24 public: | 24 public: |
| 25 SingleClientPrintersSyncTest() : SyncTest(SINGLE_CLIENT) {} | 25 SingleClientPrintersSyncTest() : SyncTest(SINGLE_CLIENT) {} |
| 26 ~SingleClientPrintersSyncTest() override {} | 26 ~SingleClientPrintersSyncTest() override {} |
| 27 | 27 |
| 28 bool SetupSync() override { |
| 29 if (!SyncTest::SetupSync()) |
| 30 return false; |
| 31 |
| 32 // Wait for sync to complete initialization before proceeding. |
| 33 return UpdatedProgressMarkerChecker(GetSyncService(0)).Wait(); |
| 34 } |
| 35 |
| 28 private: | 36 private: |
| 29 DISALLOW_COPY_AND_ASSIGN(SingleClientPrintersSyncTest); | 37 DISALLOW_COPY_AND_ASSIGN(SingleClientPrintersSyncTest); |
| 30 }; | 38 }; |
| 31 | 39 |
| 32 // Verify that printers aren't added with a sync call. | 40 // Verify that printers aren't added with a sync call. |
| 33 IN_PROC_BROWSER_TEST_F(SingleClientPrintersSyncTest, NoPrinters) { | 41 IN_PROC_BROWSER_TEST_F(SingleClientPrintersSyncTest, NoPrinters) { |
| 34 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | 42 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; |
| 35 ASSERT_TRUE(UpdatedProgressMarkerChecker(GetSyncService(0)).Wait()); | |
| 36 EXPECT_TRUE(ProfileContainsSamePrintersAsVerifier(0)); | 43 EXPECT_TRUE(ProfileContainsSamePrintersAsVerifier(0)); |
| 37 } | 44 } |
| 38 | 45 |
| 39 // Verify syncing doesn't randomly remove a printer. | 46 // Verify syncing doesn't randomly remove a printer. |
| 40 IN_PROC_BROWSER_TEST_F(SingleClientPrintersSyncTest, SingleNewPrinter) { | 47 IN_PROC_BROWSER_TEST_F(SingleClientPrintersSyncTest, SingleNewPrinter) { |
| 41 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | 48 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; |
| 42 | 49 |
| 43 ASSERT_EQ(0, GetVerifierPrinterCount()); | 50 ASSERT_EQ(0, GetVerifierPrinterCount()); |
| 44 | 51 |
| 45 AddPrinter(GetPrinterStore(0), printers_helper::CreateTestPrinter(0)); | 52 AddPrinter(GetPrinterStore(0), printers_helper::CreateTestPrinter(0)); |
| 46 AddPrinter(GetVerifierPrinterStore(), printers_helper::CreateTestPrinter(0)); | 53 AddPrinter(GetVerifierPrinterStore(), printers_helper::CreateTestPrinter(0)); |
| 47 ASSERT_EQ(1, GetPrinterCount(0)); | 54 ASSERT_EQ(1, GetPrinterCount(0)); |
| 48 ASSERT_EQ(1, GetVerifierPrinterCount()); | 55 ASSERT_EQ(1, GetVerifierPrinterCount()); |
| 49 | 56 |
| 50 ASSERT_TRUE(UpdatedProgressMarkerChecker(GetSyncService(0)).Wait()); | 57 ASSERT_TRUE(UpdatedProgressMarkerChecker(GetSyncService(0)).Wait()); |
| 51 EXPECT_EQ(1, GetVerifierPrinterCount()); | 58 EXPECT_EQ(1, GetVerifierPrinterCount()); |
| 52 EXPECT_TRUE(ProfileContainsSamePrintersAsVerifier(0)); | 59 EXPECT_TRUE(ProfileContainsSamePrintersAsVerifier(0)); |
| 53 } | 60 } |
| 54 | 61 |
| 55 // Verify editing a printer doesn't add it. | 62 // Verify editing a printer doesn't add it. |
| 56 // Flaky on ChromeOS. http://crbug.com/701999 | 63 IN_PROC_BROWSER_TEST_F(SingleClientPrintersSyncTest, EditPrinter) { |
| 57 #if defined(OS_CHROMEOS) | |
| 58 #define MAYBE_EditPrinter DISABLED_EditPrinter | |
| 59 #else | |
| 60 #define MAYBE_EditPrinter EditPrinter | |
| 61 #endif | |
| 62 IN_PROC_BROWSER_TEST_F(SingleClientPrintersSyncTest, MAYBE_EditPrinter) { | |
| 63 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | 64 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; |
| 64 | 65 |
| 65 AddPrinter(GetPrinterStore(0), printers_helper::CreateTestPrinter(0)); | 66 AddPrinter(GetPrinterStore(0), printers_helper::CreateTestPrinter(0)); |
| 66 AddPrinter(GetVerifierPrinterStore(), printers_helper::CreateTestPrinter(0)); | 67 AddPrinter(GetVerifierPrinterStore(), printers_helper::CreateTestPrinter(0)); |
| 67 | 68 |
| 68 ASSERT_TRUE( | 69 ASSERT_TRUE( |
| 69 EditPrinterDescription(GetPrinterStore(0), 0, "Updated description")); | 70 EditPrinterDescription(GetPrinterStore(0), 0, "Updated description")); |
| 70 | 71 |
| 71 EXPECT_EQ(1, GetPrinterCount(0)); | 72 EXPECT_EQ(1, GetPrinterCount(0)); |
| 72 EXPECT_EQ(1, GetVerifierPrinterCount()); | 73 EXPECT_EQ(1, GetVerifierPrinterCount()); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 92 #define MAYBE_AddBeforeSetup AddBeforeSetup | 93 #define MAYBE_AddBeforeSetup AddBeforeSetup |
| 93 #endif | 94 #endif |
| 94 IN_PROC_BROWSER_TEST_F(SingleClientPrintersSyncTest, MAYBE_AddBeforeSetup) { | 95 IN_PROC_BROWSER_TEST_F(SingleClientPrintersSyncTest, MAYBE_AddBeforeSetup) { |
| 95 ASSERT_TRUE(SetupClients()); | 96 ASSERT_TRUE(SetupClients()); |
| 96 | 97 |
| 97 AddPrinter(GetPrinterStore(0), printers_helper::CreateTestPrinter(0)); | 98 AddPrinter(GetPrinterStore(0), printers_helper::CreateTestPrinter(0)); |
| 98 EXPECT_EQ(1, GetPrinterCount(0)); | 99 EXPECT_EQ(1, GetPrinterCount(0)); |
| 99 | 100 |
| 100 EXPECT_TRUE(SetupSync()) << "SetupSync() failed."; | 101 EXPECT_TRUE(SetupSync()) << "SetupSync() failed."; |
| 101 } | 102 } |
| OLD | NEW |