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

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

Issue 2803443003: [Payments] Added region load failure tolerance and tests to PR editor. (Closed)
Patch Set: Sign bot error fixes Created 3 years, 8 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 9
9 #include "base/macros.h" 10 #include "base/macros.h"
10 #include "base/strings/string16.h" 11 #include "base/strings/string16.h"
11 #include "base/strings/utf_string_conversions.h" 12 #include "base/strings/utf_string_conversions.h"
12 #include "chrome/browser/ui/views/payments/validation_delegate.h" 13 #include "chrome/browser/ui/views/payments/validation_delegate.h"
13 #include "testing/gtest/include/gtest/gtest.h" 14 #include "testing/gtest/include/gtest/gtest.h"
14 #include "ui/views/controls/textfield/textfield.h" 15 #include "ui/views/controls/textfield/textfield.h"
15 16
16 namespace payments { 17 namespace payments {
17 18
18 class ValidatingTextfieldTest : public testing::Test { 19 class ValidatingTextfieldTest : public testing::Test {
19 public: 20 public:
20 ValidatingTextfieldTest() {} 21 ValidatingTextfieldTest() {}
21 ~ValidatingTextfieldTest() override {} 22 ~ValidatingTextfieldTest() override {}
22 23
23 protected: 24 protected:
24 class TestValidationDelegate : public ValidationDelegate { 25 class TestValidationDelegate : public ValidationDelegate {
25 public: 26 public:
26 TestValidationDelegate() {} 27 TestValidationDelegate() {}
27 ~TestValidationDelegate() override {} 28 ~TestValidationDelegate() override {}
28 29
29 // ValidationDelegate: 30 // ValidationDelegate:
30 bool ValidateTextfield(views::Textfield* textfield) override { 31 bool ValidateTextfield(views::Textfield* textfield) override {
31 // We really don't like textfields with more than 5 characters in them. 32 // We really don't like textfields with more than 5 characters in them.
32 return textfield->text().size() <= 5u; 33 return textfield->text().size() <= 5u;
33 } 34 }
34 bool ValidateCombobox(views::Combobox* combobox) override { return true; } 35 bool ValidateCombobox(views::Combobox* combobox) override { return true; }
36 void ComboboxModelChanged(views::Combobox* combobox) override {}
35 37
36 private: 38 private:
37 DISALLOW_COPY_AND_ASSIGN(TestValidationDelegate); 39 DISALLOW_COPY_AND_ASSIGN(TestValidationDelegate);
38 }; 40 };
39 41
40 private: 42 private:
41 DISALLOW_COPY_AND_ASSIGN(ValidatingTextfieldTest); 43 DISALLOW_COPY_AND_ASSIGN(ValidatingTextfieldTest);
42 }; 44 };
43 45
44 TEST_F(ValidatingTextfieldTest, Validation) { 46 TEST_F(ValidatingTextfieldTest, Validation) {
(...skipping 17 matching lines...) Expand all
62 // On further text adjustements, the validation runs now. Set a valid string 64 // On further text adjustements, the validation runs now. Set a valid string
63 // (<=5 characters). 65 // (<=5 characters).
64 textfield->SetText(base::ASCIIToUTF16("good")); 66 textfield->SetText(base::ASCIIToUTF16("good"));
65 textfield->OnContentsChanged(); 67 textfield->OnContentsChanged();
66 68
67 // No longer invalid. 69 // No longer invalid.
68 EXPECT_FALSE(textfield->invalid()); 70 EXPECT_FALSE(textfield->invalid());
69 } 71 }
70 72
71 } // namespace payments 73 } // namespace payments
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698