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

Side by Side Diff: chrome/browser/ui/views/payments/validating_textfield_unittest.cc

Issue 2896263002: [Payments] Changes to validation in the Credit Card editor (Closed)
Patch Set: rebase Created 3 years, 7 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
OLDNEW
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 "chrome/browser/ui/views/payments/validating_textfield.h" 5 #include "chrome/browser/ui/views/payments/validating_textfield.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 10 matching lines...) Expand all
21 ValidatingTextfieldTest() {} 21 ValidatingTextfieldTest() {}
22 ~ValidatingTextfieldTest() override {} 22 ~ValidatingTextfieldTest() override {}
23 23
24 protected: 24 protected:
25 class TestValidationDelegate : public ValidationDelegate { 25 class TestValidationDelegate : public ValidationDelegate {
26 public: 26 public:
27 TestValidationDelegate() {} 27 TestValidationDelegate() {}
28 ~TestValidationDelegate() override {} 28 ~TestValidationDelegate() override {}
29 29
30 // ValidationDelegate: 30 // ValidationDelegate:
31 bool TextfieldValueChanged(views::Textfield* textfield) override { 31 bool TextfieldValueChanged(views::Textfield* textfield,
32 return IsValidTextfield(textfield); 32 bool was_blurred) override {
33 return !was_blurred || IsValidTextfield(textfield);
33 } 34 }
34 bool ComboboxValueChanged(views::Combobox* combobox) override { 35 bool ComboboxValueChanged(views::Combobox* combobox) override {
35 return IsValidCombobox(combobox); 36 return IsValidCombobox(combobox);
36 } 37 }
37 bool IsValidTextfield(views::Textfield* textfield) override { 38 bool IsValidTextfield(views::Textfield* textfield) override {
38 // We really don't like textfields with more than 5 characters in them. 39 // We really don't like textfields with more than 5 characters in them.
39 return textfield->text().size() <= 5u; 40 return textfield->text().size() <= 5u;
40 } 41 }
41 bool IsValidCombobox(views::Combobox* combobox) override { return true; } 42 bool IsValidCombobox(views::Combobox* combobox) override { return true; }
42 void ComboboxModelChanged(views::Combobox* combobox) override {} 43 void ComboboxModelChanged(views::Combobox* combobox) override {}
(...skipping 27 matching lines...) Expand all
70 // On further text adjustements, the validation runs now. Set a valid string 71 // On further text adjustements, the validation runs now. Set a valid string
71 // (<=5 characters). 72 // (<=5 characters).
72 textfield->SetText(base::ASCIIToUTF16("good")); 73 textfield->SetText(base::ASCIIToUTF16("good"));
73 textfield->OnContentsChanged(); 74 textfield->OnContentsChanged();
74 75
75 // No longer invalid. 76 // No longer invalid.
76 EXPECT_FALSE(textfield->invalid()); 77 EXPECT_FALSE(textfield->invalid());
77 } 78 }
78 79
79 } // namespace payments 80 } // namespace payments
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/payments/validating_textfield.cc ('k') | chrome/browser/ui/views/payments/validation_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698