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