OLD | NEW |
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 Loading... |
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 ValidateTextfield(views::Textfield* textfield) override { | 31 bool ValidateTextfield(views::Textfield* textfield, |
| 32 bool display_error) override { |
32 // We really don't like textfields with more than 5 characters in them. | 33 // We really don't like textfields with more than 5 characters in them. |
33 return textfield->text().size() <= 5u; | 34 return textfield->text().size() <= 5u; |
34 } | 35 } |
35 bool ValidateCombobox(views::Combobox* combobox) override { return true; } | 36 bool ValidateCombobox(views::Combobox* combobox, |
| 37 bool display_error) override { |
| 38 return true; |
| 39 } |
36 void ComboboxModelChanged(views::Combobox* combobox) override {} | 40 void ComboboxModelChanged(views::Combobox* combobox) override {} |
37 | 41 |
38 private: | 42 private: |
39 DISALLOW_COPY_AND_ASSIGN(TestValidationDelegate); | 43 DISALLOW_COPY_AND_ASSIGN(TestValidationDelegate); |
40 }; | 44 }; |
41 | 45 |
42 private: | 46 private: |
43 DISALLOW_COPY_AND_ASSIGN(ValidatingTextfieldTest); | 47 DISALLOW_COPY_AND_ASSIGN(ValidatingTextfieldTest); |
44 }; | 48 }; |
45 | 49 |
(...skipping 18 matching lines...) Expand all Loading... |
64 // On further text adjustements, the validation runs now. Set a valid string | 68 // On further text adjustements, the validation runs now. Set a valid string |
65 // (<=5 characters). | 69 // (<=5 characters). |
66 textfield->SetText(base::ASCIIToUTF16("good")); | 70 textfield->SetText(base::ASCIIToUTF16("good")); |
67 textfield->OnContentsChanged(); | 71 textfield->OnContentsChanged(); |
68 | 72 |
69 // No longer invalid. | 73 // No longer invalid. |
70 EXPECT_FALSE(textfield->invalid()); | 74 EXPECT_FALSE(textfield->invalid()); |
71 } | 75 } |
72 | 76 |
73 } // namespace payments | 77 } // namespace payments |
OLD | NEW |