Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2012 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 "chrome/common/pref_names_util.h" | |
| 6 | |
| 7 #include "testing/gtest/include/gtest/gtest.h" | |
| 8 | |
| 9 namespace { | |
| 10 | |
| 11 void ExpectNoParse(const std::string& path) | |
| 12 { | |
|
Bernhard Bauer
2012/10/30 20:57:51
Nit: brace on previous line
falken
2012/10/31 06:27:59
Done.
| |
| 13 EXPECT_FALSE(pref_names_util::ParseFontNamePrefPath(path, NULL, NULL)); | |
| 14 } | |
| 15 | |
| 16 void ExpectParse(const std::string& path, | |
| 17 const std::string& expected_generic_family, | |
| 18 const std::string& expected_script) | |
| 19 { | |
| 20 std::string generic_family; | |
| 21 std::string script; | |
| 22 | |
| 23 EXPECT_TRUE(pref_names_util::ParseFontNamePrefPath(path, &generic_family, | |
|
Bernhard Bauer
2012/10/30 20:57:51
It doesn't really make a difference, but I think y
falken
2012/10/31 06:27:59
Done.
| |
| 24 &script)); | |
| 25 ASSERT_EQ(expected_generic_family, generic_family); | |
| 26 ASSERT_EQ(expected_script, script); | |
| 27 } | |
| 28 | |
| 29 } // namespace | |
| 30 | |
| 31 TEST(PrefNamesUtilTest, Basic) { | |
| 32 ExpectNoParse(""); | |
| 33 ExpectNoParse("."); | |
| 34 ExpectNoParse("....."); | |
| 35 ExpectNoParse("webkit.webprefs.fonts."); | |
| 36 ExpectNoParse("webkit.webprefs.fonts.."); | |
| 37 ExpectNoParse("webkit.webprefs.fontsfoobar.standard.Hrkt"); | |
| 38 ExpectNoParse("foobar.webprefs.fonts.standard.Hrkt"); | |
| 39 ExpectParse("webkit.webprefs.fonts.standard.Hrkt", "standard", "Hrkt"); | |
| 40 ExpectParse("webkit.webprefs.fonts.standard.Hrkt.", "standard", "Hrkt."); | |
| 41 ExpectParse("webkit.webprefs.fonts.standard.Hrkt.Foobar", "standard", | |
| 42 "Hrkt.Foobar"); | |
| 43 | |
| 44 // We don't particularly care about the parsed family and script for these | |
| 45 // inputs, but just want to make sure it does something reasonable. Returning | |
| 46 // false may also be an option. | |
| 47 ExpectParse("webkit.webprefs.fonts...", "", "."); | |
| 48 ExpectParse("webkit.webprefs.fonts....", "", ".."); | |
| 49 | |
| 50 // Check that passing NULL output params is okay. | |
| 51 EXPECT_TRUE(pref_names_util::ParseFontNamePrefPath( | |
| 52 "webkit.webprefs.fonts.standard.Hrkt", NULL, NULL)); | |
| 53 } | |
| OLD | NEW |