OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "testing/gtest/include/gtest/gtest.h" |
| 6 |
| 7 #include "chrome/browser/importer/firefox_importer_utils.h" |
| 8 |
| 9 struct GetPrefsJsValueCase { |
| 10 std::string prefs_content; |
| 11 std::string pref_name; |
| 12 std::string pref_value; |
| 13 } GetPrefsJsValueCases[] = { |
| 14 // Basic case. Single pref, unquoted value. |
| 15 { "user_pref(\"foo.bar\", 1);", "foo.bar", "1" }, |
| 16 // Value is quoted. Quotes should be stripped. |
| 17 { "user_pref(\"foo.bar\", \"1\");", "foo.bar", "1" }, |
| 18 // Value has parens. |
| 19 { "user_pref(\"foo.bar\", \"Value (detail)\");", |
| 20 "foo.bar", "Value (detail)" }, |
| 21 // Multi-line case. |
| 22 { "user_pref(\"foo.bar\", 1);\n" |
| 23 "user_pref(\"foo.baz\", 2);\n" |
| 24 "user_pref(\"foo.bag\", 3);", |
| 25 "foo.baz", "2" }, |
| 26 // Malformed content. |
| 27 { "user_pref(\"foo.bar\", 1);\n" |
| 28 "user_pref(\"foo.baz\", 2;\n" |
| 29 "user_pref(\"foo.bag\", 3);", |
| 30 "foo.baz", "" }, |
| 31 // Malformed content. |
| 32 { "uesr_pref(\"foo.bar\", 1);", "foo.bar", "" }, |
| 33 }; |
| 34 |
| 35 TEST(FirefoxImporterUtilsTest, GetPrefsJsValue) { |
| 36 for (size_t i = 0; i < arraysize(GetPrefsJsValueCases); ++i) { |
| 37 EXPECT_EQ( |
| 38 GetPrefsJsValueCases[i].pref_value, |
| 39 GetPrefsJsValue(GetPrefsJsValueCases[i].prefs_content, |
| 40 GetPrefsJsValueCases[i].pref_name)); |
| 41 } |
| 42 } |
OLD | NEW |