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

Unified Diff: components/autofill/content/renderer/form_cache_unittest.cc

Issue 1411363003: [Autofill] Always show available data when encountering autocomplete attributes (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 5 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 side-by-side diff with in-line comments
Download patch
Index: components/autofill/content/renderer/form_cache_unittest.cc
diff --git a/components/autofill/content/renderer/form_cache_unittest.cc b/components/autofill/content/renderer/form_cache_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..0c428e9aaf31b79ce9de3e7dad1ef73df41cbfaa
--- /dev/null
+++ b/components/autofill/content/renderer/form_cache_unittest.cc
@@ -0,0 +1,43 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "components/autofill/content/renderer/form_cache.h"
+
+#include "base/strings/utf_string_conversions.h"
+#include "components/autofill/core/browser/autofill_test_utils.h"
+#include "components/autofill/core/common/form_data.h"
+#include "components/autofill/core/common/form_field_data.h"
+#include "testing/gmock/include/gmock/gmock.h"
+
+namespace autofill {
+
+TEST(FormCacheTest, IsFormInteresting) {
+ FormData form;
+ form.name = base::ASCIIToUTF16("TestForm");
+ form.origin = GURL("http://example.com/form.html");
+ form.action = GURL("http://example.com/submit.html");
+
+ // No fields.
+ EXPECT_FALSE(FormCache::IsFormInteresting(form));
+
+ // One field without an autocomplete attribute.
+ FormFieldData field;
+ test::CreateTestFormField("Name", "name", "", "text", &field);
+ form.fields.push_back(field);
+ EXPECT_FALSE(FormCache::IsFormInteresting(form));
+
+ // One field with an autocomplete attribute.
+ form.fields[0].autocomplete_attribute = "given-name";
+ EXPECT_TRUE(FormCache::IsFormInteresting(form));
+
+ // Three fields with no autocomplete attributes.
+ form.fields[0].autocomplete_attribute = "";
+ test::CreateTestFormField("Country", "country", "", "text", &field);
+ form.fields.push_back(field);
+ test::CreateTestFormField("Email", "email", "", "text", &field);
+ form.fields.push_back(field);
+ EXPECT_TRUE(FormCache::IsFormInteresting(form));
+}
+
+} // namespace autofill

Powered by Google App Engine
This is Rietveld 408576698