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

Side by Side Diff: chrome/browser/ui/autofill/autofill_dialog_controller_unittest.cc

Issue 15961007: Highlight fields we know to be invalid but have no way of locally checking. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 7 years, 6 months 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 | Annotate | Revision Log
OLDNEW
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/guid.h" 5 #include "base/guid.h"
6 #include "base/memory/scoped_ptr.h" 6 #include "base/memory/scoped_ptr.h"
7 #include "base/message_loop.h" 7 #include "base/message_loop.h"
8 #include "base/prefs/pref_service.h" 8 #include "base/prefs/pref_service.h"
9 #include "base/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
10 #include "chrome/browser/ui/autofill/autofill_dialog_controller_impl.h" 10 #include "chrome/browser/ui/autofill/autofill_dialog_controller_impl.h"
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 void set_is_first_run(bool is_first_run) { is_first_run_ = is_first_run; } 233 void set_is_first_run(bool is_first_run) { is_first_run_ = is_first_run; }
234 234
235 const GURL& open_tab_url() { return open_tab_url_; } 235 const GURL& open_tab_url() { return open_tab_url_; }
236 236
237 virtual DialogType GetDialogType() const OVERRIDE { 237 virtual DialogType GetDialogType() const OVERRIDE {
238 return dialog_type_; 238 return dialog_type_;
239 } 239 }
240 240
241 void set_dialog_type(DialogType dialog_type) { dialog_type_ = dialog_type; } 241 void set_dialog_type(DialogType dialog_type) { dialog_type_ = dialog_type; }
242 242
243 bool IsSectionInEditState(DialogSection section) { 243 bool IsSectionInEditState(DialogSection section) const {
244 std::map<DialogSection, bool> state = section_editing_state(); 244 std::map<DialogSection, bool> state = section_editing_state();
245 return state[section]; 245 std::map<DialogSection, bool>::const_iterator it = state.find(section);
246 return it != state.end() && it->second;
246 } 247 }
247 248
248 MOCK_METHOD0(LoadRiskFingerprintData, void()); 249 MOCK_METHOD0(LoadRiskFingerprintData, void());
249 using AutofillDialogControllerImpl::OnDidLoadRiskFingerprintData; 250 using AutofillDialogControllerImpl::OnDidLoadRiskFingerprintData;
250 251
251 protected: 252 protected:
252 virtual PersonalDataManager* GetManager() OVERRIDE { 253 virtual PersonalDataManager* GetManager() OVERRIDE {
253 return &test_manager_; 254 return &test_manager_;
254 } 255 }
255 256
(...skipping 1559 matching lines...) Expand 10 before | Expand all | Expand 10 after
1815 dict.Set("required_action", required_actions.release()); 1816 dict.Set("required_action", required_actions.release());
1816 controller()->OnDidGetWalletItems( 1817 controller()->OnDidGetWalletItems(
1817 wallet::WalletItems::CreateWalletItems(dict).Pass()); 1818 wallet::WalletItems::CreateWalletItems(dict).Pass());
1818 1819
1819 EXPECT_FALSE(controller()->MenuModelForSection(SECTION_CC_BILLING)); 1820 EXPECT_FALSE(controller()->MenuModelForSection(SECTION_CC_BILLING));
1820 // "Same as billing" and "Add address...". 1821 // "Same as billing" and "Add address...".
1821 EXPECT_EQ( 1822 EXPECT_EQ(
1822 2, controller()->MenuModelForSection(SECTION_SHIPPING)->GetItemCount()); 1823 2, controller()->MenuModelForSection(SECTION_SHIPPING)->GetItemCount());
1823 } 1824 }
1824 1825
1826 // Ensure Wallet instruments marked expired by the server are shown as invalid.
1827 TEST_F(AutofillDialogControllerTest, WalletExpiredCard) {
1828 scoped_ptr<wallet::WalletItems> wallet_items = wallet::GetTestWalletItems();
1829 wallet_items->AddInstrument(wallet::GetTestMaskedInstrumentExpired());
1830 controller()->OnDidGetWalletItems(wallet_items.Pass());
1831
1832 EXPECT_TRUE(controller()->IsSectionInEditState(SECTION_CC_BILLING));
1833
1834 // Use |SetOutputValue()| to put the right AutofillFieldTypes into the map.
1835 DetailOutputMap outputs;
1836 SetOutputValue(controller()->RequestedFieldsForSection(SECTION_CC_BILLING),
1837 &outputs, COMPANY_NAME, "Bluth Company");
1838
1839 ValidityData validity_data = controller()->InputsAreValid(
1840 outputs, AutofillDialogController::VALIDATE_SELECT);
1841 EXPECT_EQ(1U, validity_data.count(CREDIT_CARD_EXP_MONTH));
1842 EXPECT_EQ(1U, validity_data.count(CREDIT_CARD_EXP_4_DIGIT_YEAR));
1843
1844 validity_data = controller()->InputsAreValid(
1845 outputs, AutofillDialogController::VALIDATE_EDIT);
1846 EXPECT_EQ(0U, validity_data.count(CREDIT_CARD_EXP_MONTH));
1847 EXPECT_EQ(0U, validity_data.count(CREDIT_CARD_EXP_4_DIGIT_YEAR));
1848 }
1849
1825 } // namespace autofill 1850 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698