summaryrefslogtreecommitdiffstats
path: root/chrome/browser/autofill/autofill_profile_unittest.cc
diff options
context:
space:
mode:
authordhollowa@chromium.org <dhollowa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-02-13 02:58:20 +0000
committerdhollowa@chromium.org <dhollowa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-02-13 02:58:20 +0000
commit280356aaff018a2b33defe80d0c4c73c81883c44 (patch)
treeb1dc5edc46757eb911d6112acf38284b7f306918 /chrome/browser/autofill/autofill_profile_unittest.cc
parenta1aee38539cdd177ce3f034677f55327051e3763 (diff)
downloadchromium_src-280356aaff018a2b33defe80d0c4c73c81883c44.zip
chromium_src-280356aaff018a2b33defe80d0c4c73c81883c44.tar.gz
chromium_src-280356aaff018a2b33defe80d0c4c73c81883c44.tar.bz2
Adding summary string generation for the AutoFill feature.
Includes a small modification to the generated resources, needed additional whitespace in credit card summary. Added summary generation to autofill_profile.* and modified summary generation in credit_card.* to match. credit_card.* modifications were largely to use string16 instead of std::wstring. Factored out common unit testing utilities into autofill_common_unittest.*, and added unit tests for summary string generation for credit_card.* and autofill_profile.*. BUG=35551 TEST=unit_tests --gtest_filter=AutoFillProfileTest.*:CreditCardTest.* Review URL: http://codereview.chromium.org/606031 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@39002 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/autofill/autofill_profile_unittest.cc')
-rw-r--r--chrome/browser/autofill/autofill_profile_unittest.cc191
1 files changed, 191 insertions, 0 deletions
diff --git a/chrome/browser/autofill/autofill_profile_unittest.cc b/chrome/browser/autofill/autofill_profile_unittest.cc
new file mode 100644
index 0000000..344cdfe
--- /dev/null
+++ b/chrome/browser/autofill/autofill_profile_unittest.cc
@@ -0,0 +1,191 @@
+// Copyright (c) 2010 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 "base/basictypes.h"
+#include "chrome/browser/autofill/autofill_common_unittest.h"
+#include "chrome/browser/autofill/autofill_profile.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace {
+
+// Unit tests for autofill |AutoFillProfile| class.
+class AutoFillProfileTest : public testing::Test {
+ protected:
+ AutoFillProfileTest() {
+ }
+ private:
+ DISALLOW_COPY_AND_ASSIGN(AutoFillProfileTest);
+};
+
+// Tests different possibilities for summary string generation.
+// Based on existence of first name, last name, and address line 1.
+TEST_F(AutoFillProfileTest, PreviewSummaryString) {
+ // Case 0/null: ""
+ AutoFillProfile profile0(string16(), 0);
+ string16 summary0 = profile0.PreviewSummary();
+ EXPECT_EQ(summary0, string16(ASCIIToUTF16("")));
+
+ // Case 0/empty: ""
+ AutoFillProfile profile00(string16(), 0);
+ autofill_unittest::SetProfileInfo(
+ &profile00,
+ "Billing",
+ "",
+ "Mitchell",
+ "",
+ "johnwayne@me.xyz",
+ "Fox",
+ "",
+ "unit 5",
+ "Hollywood", "CA",
+ "91601",
+ "US",
+ "12345678910",
+ "01987654321");
+ string16 summary00 = profile00.PreviewSummary();
+ EXPECT_EQ(summary00, string16(ASCIIToUTF16("")));
+
+ // Case 1: "<address>"
+ AutoFillProfile profile1(string16(), 0);
+ autofill_unittest::SetProfileInfo(
+ &profile1,
+ "Billing",
+ "",
+ "Mitchell",
+ "",
+ "johnwayne@me.xyz",
+ "Fox",
+ "123 Zoo St.",
+ "unit 5",
+ "Hollywood", "CA",
+ "91601",
+ "US",
+ "12345678910",
+ "01987654321");
+ string16 summary1 = profile1.PreviewSummary();
+ EXPECT_EQ(summary1, string16(ASCIIToUTF16("123 Zoo St.")));
+
+ // Case 2: "<lastname>"
+ AutoFillProfile profile2(string16(), 0);
+ autofill_unittest::SetProfileInfo(
+ &profile2,
+ "Billing",
+ "",
+ "Mitchell",
+ "Morrison",
+ "johnwayne@me.xyz",
+ "Fox",
+ "",
+ "unit 5",
+ "Hollywood", "CA",
+ "91601",
+ "US",
+ "12345678910",
+ "01987654321");
+ string16 summary2 = profile2.PreviewSummary();
+ EXPECT_EQ(summary2, string16(ASCIIToUTF16("Morrison")));
+
+ // Case 3: "<lastname>, <address>"
+ AutoFillProfile profile3(string16(), 0);
+ autofill_unittest::SetProfileInfo(
+ &profile3,
+ "Billing",
+ "",
+ "Mitchell",
+ "Morrison",
+ "johnwayne@me.xyz",
+ "Fox",
+ "123 Zoo St.",
+ "unit 5",
+ "Hollywood", "CA",
+ "91601",
+ "US",
+ "12345678910",
+ "01987654321");
+ string16 summary3 = profile3.PreviewSummary();
+ EXPECT_EQ(summary3, string16(ASCIIToUTF16("Morrison, 123 Zoo St.")));
+
+ // Case 4: "<firstname>"
+ AutoFillProfile profile4(string16(), 0);
+ autofill_unittest::SetProfileInfo(
+ &profile4,
+ "Billing",
+ "Marion",
+ "Mitchell",
+ "",
+ "johnwayne@me.xyz",
+ "Fox",
+ "",
+ "unit 5",
+ "Hollywood", "CA",
+ "91601",
+ "US",
+ "12345678910",
+ "01987654321");
+ string16 summary4 = profile4.PreviewSummary();
+ EXPECT_EQ(summary4, string16(ASCIIToUTF16("Marion")));
+
+ // Case 5: "<firstname>, <address>"
+ AutoFillProfile profile5(string16(), 0);
+ autofill_unittest::SetProfileInfo(
+ &profile5,
+ "Billing",
+ "Marion",
+ "Mitchell",
+ "",
+ "johnwayne@me.xyz",
+ "Fox",
+ "123 Zoo St.",
+ "unit 5",
+ "Hollywood", "CA",
+ "91601",
+ "US",
+ "12345678910",
+ "01987654321");
+ string16 summary5 = profile5.PreviewSummary();
+ EXPECT_EQ(summary5, string16(ASCIIToUTF16("Marion, 123 Zoo St.")));
+
+ // Case 6: "<firstname> <lastname>"
+ AutoFillProfile profile6(string16(), 0);
+ autofill_unittest::SetProfileInfo(
+ &profile6,
+ "Billing",
+ "Marion",
+ "Mitchell",
+ "Morrison",
+ "johnwayne@me.xyz",
+ "Fox",
+ "",
+ "unit 5",
+ "Hollywood", "CA",
+ "91601",
+ "US",
+ "12345678910",
+ "01987654321");
+ string16 summary6 = profile6.PreviewSummary();
+ EXPECT_EQ(summary6, string16(ASCIIToUTF16("Marion Morrison")));
+
+ // Case 7: "<firstname> <lastname>, <address>"
+ AutoFillProfile profile7(string16(), 0);
+ autofill_unittest::SetProfileInfo(
+ &profile7,
+ "Billing",
+ "Marion",
+ "Mitchell",
+ "Morrison",
+ "johnwayne@me.xyz",
+ "Fox",
+ "123 Zoo St.",
+ "unit 5",
+ "Hollywood", "CA",
+ "91601",
+ "US",
+ "12345678910",
+ "01987654321");
+ string16 summary7 = profile7.PreviewSummary();
+ EXPECT_EQ(summary7, string16(ASCIIToUTF16("Marion Morrison, 123 Zoo St.")));
+}
+
+} // namespace
+