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

Side by Side Diff: components/autofill/core/browser/webdata/autofill_table_unittest.cc

Issue 2478463002: Reland of place for loops with |arraysize| with for each loops (Closed)
Patch Set: Created 4 years, 1 month 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 <stddef.h> 5 #include <stddef.h>
6 6
7 #include <map> 7 #include <map>
8 #include <set> 8 #include <set>
9 #include <string> 9 #include <string>
10 #include <tuple> 10 #include <tuple>
(...skipping 1978 matching lines...) Expand 10 before | Expand all | Expand 10 after
1989 {{"user@test", "test_user"}, "user@t", 1, {"user@test", nullptr}}, 1989 {{"user@test", "test_user"}, "user@t", 1, {"user@test", nullptr}},
1990 {{"user.test", "test_user"}, "er.tes", 0, {nullptr, nullptr}}, 1990 {{"user.test", "test_user"}, "er.tes", 0, {nullptr, nullptr}},
1991 {{"user test", "test_user"}, "_ser", 0, {nullptr, nullptr}}, 1991 {{"user test", "test_user"}, "_ser", 0, {nullptr, nullptr}},
1992 {{"user.test", "test_user"}, "%ser", 0, {nullptr, nullptr}}, 1992 {{"user.test", "test_user"}, "%ser", 0, {nullptr, nullptr}},
1993 {{"user.test", "test_user"}, 1993 {{"user.test", "test_user"},
1994 "; DROP TABLE autofill;", 1994 "; DROP TABLE autofill;",
1995 0, 1995 0,
1996 {nullptr, nullptr}}, 1996 {nullptr, nullptr}},
1997 }; 1997 };
1998 1998
1999 for (size_t i = 0; i < arraysize(kTestCases); ++i) { 1999 for (const auto& test_case : kTestCases) {
2000 SCOPED_TRACE(testing::Message() 2000 SCOPED_TRACE(testing::Message()
2001 << "suggestion = " << kTestCases[i].field_suggestion[0] 2001 << "suggestion = " << test_case.field_suggestion[0]
2002 << ", contents = " << kTestCases[i].field_contents); 2002 << ", contents = " << test_case.field_contents);
2003 2003
2004 Time t1 = Time::Now(); 2004 Time t1 = Time::Now();
2005 2005
2006 // Simulate the submission of a handful of entries in a field called "Name". 2006 // Simulate the submission of a handful of entries in a field called "Name".
2007 AutofillChangeList changes; 2007 AutofillChangeList changes;
2008 FormFieldData field; 2008 FormFieldData field;
2009 for (size_t k = 0; k < kMaxCount; ++k) { 2009 for (size_t k = 0; k < kMaxCount; ++k) {
2010 field.name = ASCIIToUTF16("Name"); 2010 field.name = ASCIIToUTF16("Name");
2011 field.value = ASCIIToUTF16(kTestCases[i].field_suggestion[k]); 2011 field.value = ASCIIToUTF16(test_case.field_suggestion[k]);
2012 table_->AddFormFieldValue(field, &changes); 2012 table_->AddFormFieldValue(field, &changes);
2013 } 2013 }
2014 2014
2015 std::vector<base::string16> v; 2015 std::vector<base::string16> v;
2016 table_->GetFormValuesForElementName( 2016 table_->GetFormValuesForElementName(
2017 ASCIIToUTF16("Name"), ASCIIToUTF16(kTestCases[i].field_contents), &v, 2017 ASCIIToUTF16("Name"), ASCIIToUTF16(test_case.field_contents), &v, 6);
2018 6);
2019 2018
2020 EXPECT_EQ(kTestCases[i].expected_suggestion_count, v.size()); 2019 EXPECT_EQ(test_case.expected_suggestion_count, v.size());
2021 for (size_t j = 0; j < kTestCases[i].expected_suggestion_count; ++j) { 2020 for (size_t j = 0; j < test_case.expected_suggestion_count; ++j) {
2022 EXPECT_EQ(ASCIIToUTF16(kTestCases[i].expected_suggestion[j]), v[j]); 2021 EXPECT_EQ(ASCIIToUTF16(test_case.expected_suggestion[j]), v[j]);
2023 } 2022 }
2024 2023
2025 changes.clear(); 2024 changes.clear();
2026 table_->RemoveFormElementsAddedBetween(t1, Time(), &changes); 2025 table_->RemoveFormElementsAddedBetween(t1, Time(), &changes);
2027 } 2026 }
2028 } 2027 }
2029 2028
2030 } // namespace autofill 2029 } // namespace autofill
OLDNEW
« no previous file with comments | « components/autofill/core/browser/validation_unittest.cc ('k') | components/autofill/core/common/autofill_regexes_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698