summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorskrul@chromium.org <skrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-08 18:01:59 +0000
committerskrul@chromium.org <skrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-08 18:01:59 +0000
commitdf4370a438b17411b818d779253687a7cd2bcd8f (patch)
treeef1f79509a4e6faaa21c259a3a9fbde32862ab11 /chrome
parent90711a98a094c8fed2b4875131f4fa1c90990253 (diff)
downloadchromium_src-df4370a438b17411b818d779253687a7cd2bcd8f.zip
chromium_src-df4370a438b17411b818d779253687a7cd2bcd8f.tar.gz
chromium_src-df4370a438b17411b818d779253687a7cd2bcd8f.tar.bz2
Fix KeyToTag and add unit test
BUG=37559 Review URL: http://codereview.chromium.org/669211 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@40908 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rwxr-xr-xchrome/browser/sync/glue/autofill_model_associator.cc3
-rw-r--r--chrome/browser/sync/glue/autofill_model_associator_unittest.cc28
-rw-r--r--chrome/chrome_tests.gypi1
3 files changed, 30 insertions, 2 deletions
diff --git a/chrome/browser/sync/glue/autofill_model_associator.cc b/chrome/browser/sync/glue/autofill_model_associator.cc
index e8236fa..a180d43 100755
--- a/chrome/browser/sync/glue/autofill_model_associator.cc
+++ b/chrome/browser/sync/glue/autofill_model_associator.cc
@@ -261,8 +261,7 @@ void AutofillModelAssociator::PersistAssociations() {
// static
std::string AutofillModelAssociator::KeyToTag(const string16& name,
const string16& value) {
- return EscapePath(UTF16ToUTF8(name) + "|" +
- UTF16ToUTF8(value));
+ return EscapePath(UTF16ToUTF8(name)) + "|" + EscapePath(UTF16ToUTF8(value));
}
// static
bool AutofillModelAssociator::MergeTimestamps(
diff --git a/chrome/browser/sync/glue/autofill_model_associator_unittest.cc b/chrome/browser/sync/glue/autofill_model_associator_unittest.cc
new file mode 100644
index 0000000..240962a
--- /dev/null
+++ b/chrome/browser/sync/glue/autofill_model_associator_unittest.cc
@@ -0,0 +1,28 @@
+// 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/string16.h"
+#include "base/utf_string_conversions.h"
+#include "testing/gtest/include/gtest/gtest.h"
+#include "chrome/browser/sync/glue/autofill_model_associator.h"
+
+using browser_sync::AutofillModelAssociator;
+
+class AutofillModelAssociatorTest : public testing::Test {
+};
+
+TEST_F(AutofillModelAssociatorTest, KeyToTag) {
+ EXPECT_EQ("foo|bar",
+ AutofillModelAssociator::KeyToTag(UTF8ToUTF16("foo"),
+ UTF8ToUTF16("bar")));
+ EXPECT_EQ("%7C|%7C",
+ AutofillModelAssociator::KeyToTag(UTF8ToUTF16("|"),
+ UTF8ToUTF16("|")));
+ EXPECT_EQ("%7C|",
+ AutofillModelAssociator::KeyToTag(UTF8ToUTF16("|"),
+ UTF8ToUTF16("")));
+ EXPECT_EQ("|%7C",
+ AutofillModelAssociator::KeyToTag(UTF8ToUTF16(""),
+ UTF8ToUTF16("|")));
+}
diff --git a/chrome/chrome_tests.gypi b/chrome/chrome_tests.gypi
index aa07ec4..599f305 100644
--- a/chrome/chrome_tests.gypi
+++ b/chrome/chrome_tests.gypi
@@ -844,6 +844,7 @@
'browser/spellchecker_platform_engine_unittest.cc',
'browser/ssl/ssl_host_state_unittest.cc',
'browser/status_icons/status_tray_unittest.cc',
+ 'browser/sync/glue/autofill_model_associator_unittest.cc',
'browser/sync/glue/change_processor_mock.h',
'browser/sync/glue/data_type_controller_mock.h',
'browser/sync/glue/data_type_manager_impl_unittest.cc',