OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "base/prefs/pref_member.h" | 5 #include "base/prefs/pref_member.h" |
6 #include "base/prefs/pref_service.h" | 6 #include "base/prefs/pref_service.h" |
7 #include "base/run_loop.h" | 7 #include "base/run_loop.h" |
8 #include "chrome/browser/sync/profile_sync_service.h" | 8 #include "chrome/browser/sync/profile_sync_service.h" |
9 #include "chrome/browser/sync/test/integration/bookmarks_helper.h" | 9 #include "chrome/browser/sync/test/integration/bookmarks_helper.h" |
10 #include "chrome/browser/sync/test/integration/passwords_helper.h" | 10 #include "chrome/browser/sync/test/integration/passwords_helper.h" |
11 #include "chrome/browser/sync/test/integration/profile_sync_service_harness.h" | 11 #include "chrome/browser/sync/test/integration/profile_sync_service_harness.h" |
12 #include "chrome/browser/sync/test/integration/single_client_status_change_check
er.h" | 12 #include "chrome/browser/sync/test/integration/single_client_status_change_check
er.h" |
13 #include "chrome/browser/sync/test/integration/sync_integration_test_util.h" | 13 #include "chrome/browser/sync/test/integration/sync_integration_test_util.h" |
14 #include "chrome/browser/sync/test/integration/sync_test.h" | 14 #include "chrome/browser/sync/test/integration/sync_test.h" |
15 #include "chrome/common/pref_names.h" | 15 #include "chrome/common/pref_names.h" |
16 #include "google_apis/gaia/google_service_auth_error.h" | 16 #include "google_apis/gaia/google_service_auth_error.h" |
17 #include "sync/protocol/sync_protocol_error.h" | 17 #include "sync/protocol/sync_protocol_error.h" |
18 | 18 |
19 using bookmarks_helper::AddFolder; | 19 using bookmarks_helper::AddFolder; |
20 using bookmarks_helper::SetTitle; | 20 using bookmarks_helper::SetTitle; |
21 using sync_integration_test_util::AwaitCommitActivityCompletion; | 21 using sync_integration_test_util::AwaitCommitActivityCompletion; |
22 | 22 |
23 namespace { | 23 namespace { |
24 | 24 |
25 class SyncDisabledChecker : public SingleClientStatusChangeChecker { | 25 class SyncDisabledChecker : public SingleClientStatusChangeChecker { |
26 public: | 26 public: |
27 explicit SyncDisabledChecker(ProfileSyncService* service) | 27 explicit SyncDisabledChecker(ProfileSyncService* service) |
28 : SingleClientStatusChangeChecker(service) {} | 28 : SingleClientStatusChangeChecker(service) {} |
29 | 29 |
30 virtual bool IsExitConditionSatisfied() override { | 30 bool IsExitConditionSatisfied() override { |
31 return !service()->setup_in_progress() && | 31 return !service()->setup_in_progress() && |
32 !service()->HasSyncSetupCompleted(); | 32 !service()->HasSyncSetupCompleted(); |
33 } | 33 } |
34 | 34 |
35 virtual std::string GetDebugMessage() const override { | 35 std::string GetDebugMessage() const override { return "Sync Disabled"; } |
36 return "Sync Disabled"; | |
37 } | |
38 }; | 36 }; |
39 | 37 |
40 class TypeDisabledChecker : public SingleClientStatusChangeChecker { | 38 class TypeDisabledChecker : public SingleClientStatusChangeChecker { |
41 public: | 39 public: |
42 explicit TypeDisabledChecker(ProfileSyncService* service, | 40 explicit TypeDisabledChecker(ProfileSyncService* service, |
43 syncer::ModelType type) | 41 syncer::ModelType type) |
44 : SingleClientStatusChangeChecker(service), type_(type) {} | 42 : SingleClientStatusChangeChecker(service), type_(type) {} |
45 | 43 |
46 virtual bool IsExitConditionSatisfied() override { | 44 bool IsExitConditionSatisfied() override { |
47 return !service()->GetActiveDataTypes().Has(type_); | 45 return !service()->GetActiveDataTypes().Has(type_); |
48 } | 46 } |
49 | 47 |
50 virtual std::string GetDebugMessage() const override { | 48 std::string GetDebugMessage() const override { return "Type disabled"; } |
51 return "Type disabled"; | |
52 } | |
53 private: | 49 private: |
54 syncer::ModelType type_; | 50 syncer::ModelType type_; |
55 }; | 51 }; |
56 | 52 |
57 bool AwaitSyncDisabled(ProfileSyncService* service) { | 53 bool AwaitSyncDisabled(ProfileSyncService* service) { |
58 SyncDisabledChecker checker(service); | 54 SyncDisabledChecker checker(service); |
59 checker.Wait(); | 55 checker.Wait(); |
60 return !checker.TimedOut(); | 56 return !checker.TimedOut(); |
61 } | 57 } |
62 | 58 |
(...skipping 12 matching lines...) Expand all Loading... |
75 private: | 71 private: |
76 DISALLOW_COPY_AND_ASSIGN(SyncErrorTest); | 72 DISALLOW_COPY_AND_ASSIGN(SyncErrorTest); |
77 }; | 73 }; |
78 | 74 |
79 // Helper class that waits until the sync engine has hit an actionable error. | 75 // Helper class that waits until the sync engine has hit an actionable error. |
80 class ActionableErrorChecker : public SingleClientStatusChangeChecker { | 76 class ActionableErrorChecker : public SingleClientStatusChangeChecker { |
81 public: | 77 public: |
82 explicit ActionableErrorChecker(ProfileSyncService* service) | 78 explicit ActionableErrorChecker(ProfileSyncService* service) |
83 : SingleClientStatusChangeChecker(service) {} | 79 : SingleClientStatusChangeChecker(service) {} |
84 | 80 |
85 virtual ~ActionableErrorChecker() {} | 81 ~ActionableErrorChecker() override {} |
86 | 82 |
87 // Checks if an actionable error has been hit. Called repeatedly each time PSS | 83 // Checks if an actionable error has been hit. Called repeatedly each time PSS |
88 // notifies observers of a state change. | 84 // notifies observers of a state change. |
89 virtual bool IsExitConditionSatisfied() override { | 85 bool IsExitConditionSatisfied() override { |
90 ProfileSyncService::Status status; | 86 ProfileSyncService::Status status; |
91 service()->QueryDetailedSyncStatus(&status); | 87 service()->QueryDetailedSyncStatus(&status); |
92 return (status.sync_protocol_error.action != syncer::UNKNOWN_ACTION && | 88 return (status.sync_protocol_error.action != syncer::UNKNOWN_ACTION && |
93 service()->HasUnrecoverableError()); | 89 service()->HasUnrecoverableError()); |
94 } | 90 } |
95 | 91 |
96 virtual std::string GetDebugMessage() const override { | 92 std::string GetDebugMessage() const override { |
97 return "ActionableErrorChecker"; | 93 return "ActionableErrorChecker"; |
98 } | 94 } |
99 | 95 |
100 private: | 96 private: |
101 DISALLOW_COPY_AND_ASSIGN(ActionableErrorChecker); | 97 DISALLOW_COPY_AND_ASSIGN(ActionableErrorChecker); |
102 }; | 98 }; |
103 | 99 |
104 IN_PROC_BROWSER_TEST_F(SyncErrorTest, BirthdayErrorTest) { | 100 IN_PROC_BROWSER_TEST_F(SyncErrorTest, BirthdayErrorTest) { |
105 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | 101 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; |
106 | 102 |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
225 ASSERT_TRUE(AwaitTypeDisabled(GetSyncService(0), syncer::TYPED_URLS)); | 221 ASSERT_TRUE(AwaitTypeDisabled(GetSyncService(0), syncer::TYPED_URLS)); |
226 ASSERT_TRUE(AwaitTypeDisabled(GetSyncService(0), syncer::SESSIONS)); | 222 ASSERT_TRUE(AwaitTypeDisabled(GetSyncService(0), syncer::SESSIONS)); |
227 | 223 |
228 const BookmarkNode* node1 = AddFolder(0, 0, "title1"); | 224 const BookmarkNode* node1 = AddFolder(0, 0, "title1"); |
229 SetTitle(0, node1, "new_title1"); | 225 SetTitle(0, node1, "new_title1"); |
230 ASSERT_TRUE(AwaitCommitActivityCompletion(GetSyncService((0)))); | 226 ASSERT_TRUE(AwaitCommitActivityCompletion(GetSyncService((0)))); |
231 // TODO(lipalani)" Verify initial sync ended for typed url is false. | 227 // TODO(lipalani)" Verify initial sync ended for typed url is false. |
232 } | 228 } |
233 | 229 |
234 } // namespace | 230 } // namespace |
OLD | NEW |