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 |