| 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));
|
| + }
|
| +}
|
|
|