OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "chrome/browser/sync/profile_sync_service.h" | 5 #include "chrome/browser/sync/profile_sync_service.h" |
6 #include "chrome/browser/sync/profile_sync_service_harness.h" | 6 #include "chrome/browser/sync/profile_sync_service_harness.h" |
7 #include "chrome/browser/sync/protocol/sync_protocol_error.h" | 7 #include "chrome/browser/sync/protocol/sync_protocol_error.h" |
8 #include "chrome/browser/sync/test/integration/bookmarks_helper.h" | 8 #include "chrome/browser/sync/test/integration/bookmarks_helper.h" |
| 9 #include "chrome/browser/sync/test/integration/passwords_helper.h" |
9 #include "chrome/browser/sync/test/integration/sync_test.h" | 10 #include "chrome/browser/sync/test/integration/sync_test.h" |
| 11 #include "chrome/common/net/gaia/google_service_auth_error.h" |
10 | 12 |
11 using bookmarks_helper::AddFolder; | 13 using bookmarks_helper::AddFolder; |
12 using bookmarks_helper::SetTitle; | 14 using bookmarks_helper::SetTitle; |
| 15 using passwords_helper::AddLogin; |
| 16 using passwords_helper::CreateTestPasswordForm; |
| 17 using passwords_helper::GetPasswordCount; |
| 18 using passwords_helper::GetPasswordStore; |
| 19 using passwords_helper::GetVerifierPasswordCount; |
| 20 using passwords_helper::GetVerifierPasswordStore; |
| 21 using passwords_helper::ProfileContainsSamePasswordFormsAsVerifier; |
| 22 |
| 23 using webkit_glue::PasswordForm; |
13 | 24 |
14 class SyncErrorTest : public SyncTest{ | 25 class SyncErrorTest : public SyncTest{ |
15 public: | 26 public: |
16 SyncErrorTest() : SyncTest(SINGLE_CLIENT) {} | 27 SyncErrorTest() : SyncTest(SINGLE_CLIENT) {} |
17 virtual ~SyncErrorTest() {} | 28 virtual ~SyncErrorTest() {} |
18 | 29 |
19 private: | 30 private: |
20 DISALLOW_COPY_AND_ASSIGN(SyncErrorTest); | 31 DISALLOW_COPY_AND_ASSIGN(SyncErrorTest); |
21 }; | 32 }; |
22 | 33 |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 SetTitle(0, node2, L"new_title2"); | 107 SetTitle(0, node2, L"new_title2"); |
97 ASSERT_TRUE( | 108 ASSERT_TRUE( |
98 GetClient(0)->AwaitSyncDisabled("Birthday Error.")); | 109 GetClient(0)->AwaitSyncDisabled("Birthday Error.")); |
99 ProfileSyncService::Status status = GetClient(0)->GetStatus(); | 110 ProfileSyncService::Status status = GetClient(0)->GetStatus(); |
100 ASSERT_EQ(status.sync_protocol_error.error_type, protocol_error.error_type); | 111 ASSERT_EQ(status.sync_protocol_error.error_type, protocol_error.error_type); |
101 ASSERT_EQ(status.sync_protocol_error.action, protocol_error.action); | 112 ASSERT_EQ(status.sync_protocol_error.action, protocol_error.action); |
102 ASSERT_EQ(status.sync_protocol_error.url, protocol_error.url); | 113 ASSERT_EQ(status.sync_protocol_error.url, protocol_error.url); |
103 ASSERT_EQ(status.sync_protocol_error.error_description, | 114 ASSERT_EQ(status.sync_protocol_error.error_description, |
104 protocol_error.error_description); | 115 protocol_error.error_description); |
105 } | 116 } |
| 117 |
| 118 IN_PROC_BROWSER_TEST_F(SyncErrorTest, AuthErrorTest) { |
| 119 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; |
| 120 |
| 121 PasswordForm form0 = CreateTestPasswordForm(0); |
| 122 AddLogin(GetVerifierPasswordStore(), form0); |
| 123 ASSERT_EQ(1, GetVerifierPasswordCount()); |
| 124 AddLogin(GetPasswordStore(0), form0); |
| 125 ASSERT_EQ(1, GetPasswordCount(0)); |
| 126 |
| 127 ASSERT_TRUE(GetClient(0)->AwaitFullSyncCompletion("Added a login.")); |
| 128 ASSERT_TRUE(ProfileContainsSamePasswordFormsAsVerifier(0)); |
| 129 ASSERT_EQ(1, GetPasswordCount(0)); |
| 130 |
| 131 TriggerAuthError(); |
| 132 PasswordForm form1 = CreateTestPasswordForm(1); |
| 133 AddLogin(GetPasswordStore(0), form1); |
| 134 ASSERT_FALSE(GetClient(0)->AwaitFullSyncCompletion("Must get auth error.")); |
| 135 ASSERT_EQ(GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS, |
| 136 GetClient(0)->service()->GetAuthError().state()); |
| 137 ASSERT_EQ(ProfileSyncService::Status::OFFLINE_UNSYNCED, |
| 138 GetClient(0)->GetStatus().summary); |
| 139 } |
OLD | NEW |