Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1282)

Side by Side Diff: chrome/browser/sync/test/integration/single_client_wallet_sync_test.cc

Issue 2455343003: [Sync] Replaced ASSERT/EXPECT_TRUE/FALSE with expected/actual checks. (Closed)
Patch Set: \Updates for Max and rebase. Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2015 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/command_line.h" 5 #include "base/command_line.h"
6 #include "base/macros.h" 6 #include "base/macros.h"
7 #include "base/strings/utf_string_conversions.h" 7 #include "base/strings/utf_string_conversions.h"
8 #include "chrome/browser/chrome_notification_types.h" 8 #include "chrome/browser/chrome_notification_types.h"
9 #include "chrome/browser/sync/test/integration/autofill_helper.h" 9 #include "chrome/browser/sync/test/integration/autofill_helper.h"
10 #include "chrome/browser/sync/test/integration/profile_sync_service_harness.h" 10 #include "chrome/browser/sync/test/integration/profile_sync_service_harness.h"
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 // exists. 112 // exists.
113 ASSERT_TRUE(GetClient(0)->service()->GetActiveDataTypes().Has( 113 ASSERT_TRUE(GetClient(0)->service()->GetActiveDataTypes().Has(
114 syncer::AUTOFILL_WALLET_METADATA)); 114 syncer::AUTOFILL_WALLET_METADATA));
115 } 115 }
116 116
117 IN_PROC_BROWSER_TEST_F(SingleClientWalletSyncTest, Download) { 117 IN_PROC_BROWSER_TEST_F(SingleClientWalletSyncTest, Download) {
118 AddDefaultCard(GetFakeServer()); 118 AddDefaultCard(GetFakeServer());
119 ASSERT_TRUE(SetupSync()) << "SetupSync() failed"; 119 ASSERT_TRUE(SetupSync()) << "SetupSync() failed";
120 120
121 autofill::PersonalDataManager* pdm = GetPersonalDataManager(0); 121 autofill::PersonalDataManager* pdm = GetPersonalDataManager(0);
122 ASSERT_TRUE(pdm != nullptr); 122 ASSERT_NE(nullptr, pdm);
123 std::vector<autofill::CreditCard*> cards = pdm->GetCreditCards(); 123 std::vector<autofill::CreditCard*> cards = pdm->GetCreditCards();
124 ASSERT_EQ(1uL, cards.size()); 124 ASSERT_EQ(1uL, cards.size());
125 125
126 autofill::CreditCard* card = cards[0]; 126 autofill::CreditCard* card = cards[0];
127 ASSERT_EQ(autofill::CreditCard::MASKED_SERVER_CARD, card->record_type()); 127 ASSERT_EQ(autofill::CreditCard::MASKED_SERVER_CARD, card->record_type());
128 ASSERT_EQ(kDefaultCardID, card->server_id()); 128 ASSERT_EQ(kDefaultCardID, card->server_id());
129 ASSERT_EQ(base::UTF8ToUTF16(kDefaultCardLastFour), card->LastFourDigits()); 129 ASSERT_EQ(base::UTF8ToUTF16(kDefaultCardLastFour), card->LastFourDigits());
130 ASSERT_EQ(autofill::kAmericanExpressCard, card->type()); 130 ASSERT_EQ(autofill::kAmericanExpressCard, card->type());
131 ASSERT_EQ(kDefaultCardExpMonth, card->expiration_month()); 131 ASSERT_EQ(kDefaultCardExpMonth, card->expiration_month());
132 ASSERT_EQ(kDefaultCardExpYear, card->expiration_year()); 132 ASSERT_EQ(kDefaultCardExpYear, card->expiration_year());
133 ASSERT_EQ(base::UTF8ToUTF16(kDefaultCardName), 133 ASSERT_EQ(base::UTF8ToUTF16(kDefaultCardName),
134 card->GetRawInfo(autofill::ServerFieldType::CREDIT_CARD_NAME_FULL)); 134 card->GetRawInfo(autofill::ServerFieldType::CREDIT_CARD_NAME_FULL));
135 } 135 }
136 136
137 // Wallet data should get cleared from the database when sync is disabled. 137 // Wallet data should get cleared from the database when sync is disabled.
138 IN_PROC_BROWSER_TEST_F(SingleClientWalletSyncTest, ClearOnDisableSync) { 138 IN_PROC_BROWSER_TEST_F(SingleClientWalletSyncTest, ClearOnDisableSync) {
139 AddDefaultCard(GetFakeServer()); 139 AddDefaultCard(GetFakeServer());
140 ASSERT_TRUE(SetupSync()) << "SetupSync() failed"; 140 ASSERT_TRUE(SetupSync()) << "SetupSync() failed";
141 141
142 // Make sure the card is in the DB. 142 // Make sure the card is in the DB.
143 autofill::PersonalDataManager* pdm = GetPersonalDataManager(0); 143 autofill::PersonalDataManager* pdm = GetPersonalDataManager(0);
144 ASSERT_TRUE(pdm != nullptr); 144 ASSERT_NE(nullptr, pdm);
145 std::vector<autofill::CreditCard*> cards = pdm->GetCreditCards(); 145 std::vector<autofill::CreditCard*> cards = pdm->GetCreditCards();
146 ASSERT_EQ(1uL, cards.size()); 146 ASSERT_EQ(1uL, cards.size());
147 147
148 // Turn off sync, the card should be gone. 148 // Turn off sync, the card should be gone.
149 ASSERT_TRUE(GetClient(0)->DisableSyncForAllDatatypes()); 149 ASSERT_TRUE(GetClient(0)->DisableSyncForAllDatatypes());
150 cards = pdm->GetCreditCards(); 150 cards = pdm->GetCreditCards();
151 ASSERT_EQ(0uL, cards.size()); 151 ASSERT_EQ(0uL, cards.size());
152 } 152 }
153 153
154 // Wallet data should get cleared from the database when the wallet sync type 154 // Wallet data should get cleared from the database when the wallet sync type
155 // flag is disabled. 155 // flag is disabled.
156 IN_PROC_BROWSER_TEST_F(SingleClientWalletSyncTest, ClearOnDisableWalletSync) { 156 IN_PROC_BROWSER_TEST_F(SingleClientWalletSyncTest, ClearOnDisableWalletSync) {
157 AddDefaultCard(GetFakeServer()); 157 AddDefaultCard(GetFakeServer());
158 ASSERT_TRUE(SetupSync()) << "SetupSync() failed"; 158 ASSERT_TRUE(SetupSync()) << "SetupSync() failed";
159 159
160 // Make sure the card is in the DB. 160 // Make sure the card is in the DB.
161 autofill::PersonalDataManager* pdm = GetPersonalDataManager(0); 161 autofill::PersonalDataManager* pdm = GetPersonalDataManager(0);
162 ASSERT_TRUE(pdm != nullptr); 162 ASSERT_NE(nullptr, pdm);
163 std::vector<autofill::CreditCard*> cards = pdm->GetCreditCards(); 163 std::vector<autofill::CreditCard*> cards = pdm->GetCreditCards();
164 ASSERT_EQ(1uL, cards.size()); 164 ASSERT_EQ(1uL, cards.size());
165 165
166 // Turn off autofill sync, the card should be gone. 166 // Turn off autofill sync, the card should be gone.
167 ASSERT_TRUE(GetClient(0)->DisableSyncForDatatype(syncer::AUTOFILL)); 167 ASSERT_TRUE(GetClient(0)->DisableSyncForDatatype(syncer::AUTOFILL));
168 cards = pdm->GetCreditCards(); 168 cards = pdm->GetCreditCards();
169 ASSERT_EQ(0uL, cards.size()); 169 ASSERT_EQ(0uL, cards.size());
170 } 170 }
171 171
172 // Wallet data should get cleared from the database when the wallet autofill 172 // Wallet data should get cleared from the database when the wallet autofill
173 // integration flag is disabled. 173 // integration flag is disabled.
174 IN_PROC_BROWSER_TEST_F(SingleClientWalletSyncTest, 174 IN_PROC_BROWSER_TEST_F(SingleClientWalletSyncTest,
175 ClearOnDisableWalletAutofill) { 175 ClearOnDisableWalletAutofill) {
176 AddDefaultCard(GetFakeServer()); 176 AddDefaultCard(GetFakeServer());
177 ASSERT_TRUE(SetupSync()) << "SetupSync() failed"; 177 ASSERT_TRUE(SetupSync()) << "SetupSync() failed";
178 178
179 // Make sure the card is in the DB. 179 // Make sure the card is in the DB.
180 autofill::PersonalDataManager* pdm = GetPersonalDataManager(0); 180 autofill::PersonalDataManager* pdm = GetPersonalDataManager(0);
181 ASSERT_TRUE(pdm != nullptr); 181 ASSERT_NE(nullptr, pdm);
182 std::vector<autofill::CreditCard*> cards = pdm->GetCreditCards(); 182 std::vector<autofill::CreditCard*> cards = pdm->GetCreditCards();
183 ASSERT_EQ(1uL, cards.size()); 183 ASSERT_EQ(1uL, cards.size());
184 184
185 // Turn off the wallet autofill pref, the card should be gone as a side 185 // Turn off the wallet autofill pref, the card should be gone as a side
186 // effect of the wallet data type controller noticing. 186 // effect of the wallet data type controller noticing.
187 GetProfile(0)->GetPrefs()->SetBoolean( 187 GetProfile(0)->GetPrefs()->SetBoolean(
188 autofill::prefs::kAutofillWalletImportEnabled, false); 188 autofill::prefs::kAutofillWalletImportEnabled, false);
189 cards = pdm->GetCreditCards(); 189 cards = pdm->GetCreditCards();
190 ASSERT_EQ(0uL, cards.size()); 190 ASSERT_EQ(0uL, cards.size());
191 } 191 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698