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 | |
36 private: | 28 private: |
37 DISALLOW_COPY_AND_ASSIGN(SingleClientPrintersSyncTest); | 29 DISALLOW_COPY_AND_ASSIGN(SingleClientPrintersSyncTest); |
38 }; | 30 }; |
39 | 31 |
40 // Verify that printers aren't added with a sync call. | 32 // Verify that printers aren't added with a sync call. |
41 IN_PROC_BROWSER_TEST_F(SingleClientPrintersSyncTest, NoPrinters) { | 33 IN_PROC_BROWSER_TEST_F(SingleClientPrintersSyncTest, NoPrinters) { |
42 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | 34 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; |
35 ASSERT_TRUE(UpdatedProgressMarkerChecker(GetSyncService(0)).Wait()); | |
skym
2017/04/06 16:48:44
Why is this being added back? I know this isn't yo
Gang Wu
2017/04/06 19:22:59
Done.
| |
43 EXPECT_TRUE(ProfileContainsSamePrintersAsVerifier(0)); | 36 EXPECT_TRUE(ProfileContainsSamePrintersAsVerifier(0)); |
44 } | 37 } |
45 | 38 |
46 // Verify syncing doesn't randomly remove a printer. | 39 // Verify syncing doesn't randomly remove a printer. |
47 IN_PROC_BROWSER_TEST_F(SingleClientPrintersSyncTest, SingleNewPrinter) { | 40 IN_PROC_BROWSER_TEST_F(SingleClientPrintersSyncTest, SingleNewPrinter) { |
48 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | 41 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; |
49 | 42 |
50 ASSERT_EQ(0, GetVerifierPrinterCount()); | 43 ASSERT_EQ(0, GetVerifierPrinterCount()); |
51 | 44 |
52 AddPrinter(GetPrinterStore(0), printers_helper::CreateTestPrinter(0)); | 45 AddPrinter(GetPrinterStore(0), printers_helper::CreateTestPrinter(0)); |
53 AddPrinter(GetVerifierPrinterStore(), printers_helper::CreateTestPrinter(0)); | 46 AddPrinter(GetVerifierPrinterStore(), printers_helper::CreateTestPrinter(0)); |
54 ASSERT_EQ(1, GetPrinterCount(0)); | 47 ASSERT_EQ(1, GetPrinterCount(0)); |
55 ASSERT_EQ(1, GetVerifierPrinterCount()); | 48 ASSERT_EQ(1, GetVerifierPrinterCount()); |
56 | 49 |
57 ASSERT_TRUE(UpdatedProgressMarkerChecker(GetSyncService(0)).Wait()); | 50 ASSERT_TRUE(UpdatedProgressMarkerChecker(GetSyncService(0)).Wait()); |
58 EXPECT_EQ(1, GetVerifierPrinterCount()); | 51 EXPECT_EQ(1, GetVerifierPrinterCount()); |
59 EXPECT_TRUE(ProfileContainsSamePrintersAsVerifier(0)); | 52 EXPECT_TRUE(ProfileContainsSamePrintersAsVerifier(0)); |
60 } | 53 } |
61 | 54 |
62 // Verify editing a printer doesn't add it. | 55 // Verify editing a printer doesn't add it. |
63 // Flaky on ChromeOS. http://crbug.com/701999 | 56 IN_PROC_BROWSER_TEST_F(SingleClientPrintersSyncTest, EditPrinter) { |
64 #if defined(OS_CHROMEOS) | |
65 #define MAYBE_EditPrinter DISABLED_EditPrinter | |
66 #else | |
67 #define MAYBE_EditPrinter EditPrinter | |
68 #endif | |
69 IN_PROC_BROWSER_TEST_F(SingleClientPrintersSyncTest, MAYBE_EditPrinter) { | |
70 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | 57 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; |
71 | 58 |
72 AddPrinter(GetPrinterStore(0), printers_helper::CreateTestPrinter(0)); | 59 AddPrinter(GetPrinterStore(0), printers_helper::CreateTestPrinter(0)); |
73 AddPrinter(GetVerifierPrinterStore(), printers_helper::CreateTestPrinter(0)); | 60 AddPrinter(GetVerifierPrinterStore(), printers_helper::CreateTestPrinter(0)); |
74 | 61 |
75 ASSERT_TRUE( | 62 ASSERT_TRUE( |
76 EditPrinterDescription(GetPrinterStore(0), 0, "Updated description")); | 63 EditPrinterDescription(GetPrinterStore(0), 0, "Updated description")); |
77 | 64 |
78 EXPECT_EQ(1, GetPrinterCount(0)); | 65 EXPECT_EQ(1, GetPrinterCount(0)); |
79 EXPECT_EQ(1, GetVerifierPrinterCount()); | 66 EXPECT_EQ(1, GetVerifierPrinterCount()); |
80 EXPECT_FALSE(ProfileContainsSamePrintersAsVerifier(0)); | 67 EXPECT_FALSE(ProfileContainsSamePrintersAsVerifier(0)); |
81 } | 68 } |
82 | 69 |
83 // Verify that removing a printer works. | 70 // Verify that removing a printer works. |
84 IN_PROC_BROWSER_TEST_F(SingleClientPrintersSyncTest, RemovePrinter) { | 71 IN_PROC_BROWSER_TEST_F(SingleClientPrintersSyncTest, RemovePrinter) { |
85 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | 72 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; |
86 | 73 |
87 AddPrinter(GetPrinterStore(0), printers_helper::CreateTestPrinter(0)); | 74 AddPrinter(GetPrinterStore(0), printers_helper::CreateTestPrinter(0)); |
88 EXPECT_EQ(1, GetPrinterCount(0)); | 75 EXPECT_EQ(1, GetPrinterCount(0)); |
89 | 76 |
90 RemovePrinter(GetPrinterStore(0), 0); | 77 RemovePrinter(GetPrinterStore(0), 0); |
91 EXPECT_EQ(0, GetPrinterCount(0)); | 78 EXPECT_EQ(0, GetPrinterCount(0)); |
92 } | 79 } |
93 | 80 |
94 // Verify that merging data added before sync works. | 81 // Verify that merging data added before sync works. |
95 // crbug.com/689662 | 82 IN_PROC_BROWSER_TEST_F(SingleClientPrintersSyncTest, AddBeforeSetup) { |
96 #if defined(OS_CHROMEOS) | |
97 #define MAYBE_AddBeforeSetup DISABLED_AddBeforeSetup | |
98 #else | |
99 #define MAYBE_AddBeforeSetup AddBeforeSetup | |
100 #endif | |
101 IN_PROC_BROWSER_TEST_F(SingleClientPrintersSyncTest, MAYBE_AddBeforeSetup) { | |
102 ASSERT_TRUE(SetupClients()); | 83 ASSERT_TRUE(SetupClients()); |
103 | 84 |
104 AddPrinter(GetPrinterStore(0), printers_helper::CreateTestPrinter(0)); | 85 AddPrinter(GetPrinterStore(0), printers_helper::CreateTestPrinter(0)); |
105 EXPECT_EQ(1, GetPrinterCount(0)); | 86 EXPECT_EQ(1, GetPrinterCount(0)); |
106 | 87 |
107 EXPECT_TRUE(SetupSync()) << "SetupSync() failed."; | 88 EXPECT_TRUE(SetupSync()) << "SetupSync() failed."; |
108 } | 89 } |
OLD | NEW |