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

Unified Diff: chrome/browser/importer/firefox_importer_utils_unittest.cc

Issue 3221007: Fix a couple of firefox search engine import bugs. (Closed) Base URL: http://src.chromium.org/git/chromium.git
Patch Set: added test, TODO Created 10 years, 4 months 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
« no previous file with comments | « chrome/browser/importer/firefox_importer_utils.cc ('k') | chrome/chrome_tests.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/importer/firefox_importer_utils_unittest.cc
diff --git a/chrome/browser/importer/firefox_importer_utils_unittest.cc b/chrome/browser/importer/firefox_importer_utils_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..7e5fadcabb9222f6652c094d3b47b71af6a323b9
--- /dev/null
+++ b/chrome/browser/importer/firefox_importer_utils_unittest.cc
@@ -0,0 +1,42 @@
+// 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 "testing/gtest/include/gtest/gtest.h"
+
+#include "chrome/browser/importer/firefox_importer_utils.h"
+
+struct GetPrefsJsValueCase {
+ std::string prefs_content;
+ std::string pref_name;
+ std::string pref_value;
+} GetPrefsJsValueCases[] = {
+ // Basic case. Single pref, unquoted value.
+ { "user_pref(\"foo.bar\", 1);", "foo.bar", "1" },
+ // Value is quoted. Quotes should be stripped.
+ { "user_pref(\"foo.bar\", \"1\");", "foo.bar", "1" },
+ // Value has parens.
+ { "user_pref(\"foo.bar\", \"Value (detail)\");",
+ "foo.bar", "Value (detail)" },
+ // Multi-line case.
+ { "user_pref(\"foo.bar\", 1);\n"
+ "user_pref(\"foo.baz\", 2);\n"
+ "user_pref(\"foo.bag\", 3);",
+ "foo.baz", "2" },
+ // Malformed content.
+ { "user_pref(\"foo.bar\", 1);\n"
+ "user_pref(\"foo.baz\", 2;\n"
+ "user_pref(\"foo.bag\", 3);",
+ "foo.baz", "" },
+ // Malformed content.
+ { "uesr_pref(\"foo.bar\", 1);", "foo.bar", "" },
+};
+
+TEST(FirefoxImporterUtilsTest, GetPrefsJsValue) {
+ for (size_t i = 0; i < arraysize(GetPrefsJsValueCases); ++i) {
+ EXPECT_EQ(
+ GetPrefsJsValueCases[i].pref_value,
+ GetPrefsJsValue(GetPrefsJsValueCases[i].prefs_content,
+ GetPrefsJsValueCases[i].pref_name));
+ }
+}
« no previous file with comments | « chrome/browser/importer/firefox_importer_utils.cc ('k') | chrome/chrome_tests.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698