aura: Remove more code that explicitly creates/destroys aura::Env.
[chromium-blink-merge.git] / chrome / common / pref_names_util_unittest.cc
blob9f215ea5808d145664170c204f3c2b1523e5e35d
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.
5 #include "chrome/common/pref_names_util.h"
7 #include "testing/gtest/include/gtest/gtest.h"
9 namespace {
11 void ExpectNoParse(const std::string& path) {
12 EXPECT_FALSE(pref_names_util::ParseFontNamePrefPath(path, NULL, NULL));
15 void ExpectParse(const std::string& path,
16 const std::string& expected_generic_family,
17 const std::string& expected_script)
19 std::string generic_family;
20 std::string script;
22 ASSERT_TRUE(pref_names_util::ParseFontNamePrefPath(path, &generic_family,
23 &script));
24 EXPECT_EQ(expected_generic_family, generic_family);
25 EXPECT_EQ(expected_script, script);
28 } // namespace
30 TEST(PrefNamesUtilTest, Basic) {
31 ExpectNoParse(std::string());
32 ExpectNoParse(".");
33 ExpectNoParse(".....");
34 ExpectNoParse("webkit.webprefs.fonts.");
35 ExpectNoParse("webkit.webprefs.fonts..");
36 ExpectNoParse("webkit.webprefs.fontsfoobar.standard.Hrkt");
37 ExpectNoParse("foobar.webprefs.fonts.standard.Hrkt");
38 ExpectParse("webkit.webprefs.fonts.standard.Hrkt", "standard", "Hrkt");
39 ExpectParse("webkit.webprefs.fonts.standard.Hrkt.", "standard", "Hrkt.");
40 ExpectParse("webkit.webprefs.fonts.standard.Hrkt.Foobar", "standard",
41 "Hrkt.Foobar");
43 // We don't particularly care about the parsed family and script for these
44 // inputs, but just want to make sure it does something reasonable. Returning
45 // false may also be an option.
46 ExpectParse("webkit.webprefs.fonts...", std::string(), ".");
47 ExpectParse("webkit.webprefs.fonts....", std::string(), "..");
49 // Check that passing NULL output params is okay.
50 EXPECT_TRUE(pref_names_util::ParseFontNamePrefPath(
51 "webkit.webprefs.fonts.standard.Hrkt", NULL, NULL));