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

Side by Side Diff: chrome/browser/font_family_cache_unittest.cc

Issue 2459823002: [Sync] Rename syncable_prefs to sync_preferences. (Closed)
Patch Set: Created 4 years, 1 month 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/font_family_cache.h" 5 #include "chrome/browser/font_family_cache.h"
6 6
7 #include "base/macros.h" 7 #include "base/macros.h"
8 #include "base/strings/utf_string_conversions.h" 8 #include "base/strings/utf_string_conversions.h"
9 #include "chrome/test/base/testing_profile.h" 9 #include "chrome/test/base/testing_profile.h"
10 #include "components/syncable_prefs/testing_pref_service_syncable.h" 10 #include "components/sync_preferences/testing_pref_service_syncable.h"
11 #include "content/public/test/test_browser_thread_bundle.h" 11 #include "content/public/test/test_browser_thread_bundle.h"
12 #include "testing/gtest/include/gtest/gtest.h" 12 #include "testing/gtest/include/gtest/gtest.h"
13 13
14 namespace { 14 namespace {
15 15
16 class TestingFontFamilyCache : public FontFamilyCache { 16 class TestingFontFamilyCache : public FontFamilyCache {
17 public: 17 public:
18 explicit TestingFontFamilyCache(Profile* profile) 18 explicit TestingFontFamilyCache(Profile* profile)
19 : FontFamilyCache(profile), fetch_font_count_(0) {} 19 : FontFamilyCache(profile), fetch_font_count_(0) {}
20 ~TestingFontFamilyCache() override {} 20 ~TestingFontFamilyCache() override {}
21 base::string16 FetchFont(const char* script, const char* map_name) override { 21 base::string16 FetchFont(const char* script, const char* map_name) override {
22 ++fetch_font_count_; 22 ++fetch_font_count_;
23 return FontFamilyCache::FetchFont(script, map_name); 23 return FontFamilyCache::FetchFont(script, map_name);
24 } 24 }
25 25
26 int fetch_font_count_; 26 int fetch_font_count_;
27 27
28 private: 28 private:
29 DISALLOW_COPY_AND_ASSIGN(TestingFontFamilyCache); 29 DISALLOW_COPY_AND_ASSIGN(TestingFontFamilyCache);
30 }; 30 };
31 31
32 } // namespace 32 } // namespace
33 33
34 // Tests that the cache is correctly set and cleared. 34 // Tests that the cache is correctly set and cleared.
35 TEST(FontFamilyCacheTest, Caching) { 35 TEST(FontFamilyCacheTest, Caching) {
36 content::TestBrowserThreadBundle thread_bundle_; 36 content::TestBrowserThreadBundle thread_bundle_;
37 TestingProfile profile; 37 TestingProfile profile;
38 TestingFontFamilyCache cache(&profile); 38 TestingFontFamilyCache cache(&profile);
39 syncable_prefs::TestingPrefServiceSyncable* prefs = 39 sync_preferences::TestingPrefServiceSyncable* prefs =
40 profile.GetTestingPrefService(); 40 profile.GetTestingPrefService();
41 41
42 std::string font1("font 1"); 42 std::string font1("font 1");
43 std::string font2("font 2"); 43 std::string font2("font 2");
44 std::string map_name("webkit.webprefs.fonts.pictograph"); 44 std::string map_name("webkit.webprefs.fonts.pictograph");
45 std::string script("Zzyxca"); 45 std::string script("Zzyxca");
46 std::string pref_name(map_name + '.' + script); 46 std::string pref_name(map_name + '.' + script);
47 std::string pref_name2(map_name + '.' + "adsf"); 47 std::string pref_name2(map_name + '.' + "adsf");
48 48
49 // Registers 2 preferences, and sets the first one. 49 // Registers 2 preferences, and sets the first one.
(...skipping 20 matching lines...) Expand all
70 EXPECT_EQ(font1, result); 70 EXPECT_EQ(font1, result);
71 EXPECT_EQ(1, cache.fetch_font_count_); 71 EXPECT_EQ(1, cache.fetch_font_count_);
72 72
73 // Changing the preferences invalidates the cache. 73 // Changing the preferences invalidates the cache.
74 prefs->SetString(pref_name.c_str(), font2.c_str()); 74 prefs->SetString(pref_name.c_str(), font2.c_str());
75 result = base::UTF16ToUTF8( 75 result = base::UTF16ToUTF8(
76 cache.FetchAndCacheFont(script.c_str(), map_name.c_str())); 76 cache.FetchAndCacheFont(script.c_str(), map_name.c_str()));
77 EXPECT_EQ(font2, result); 77 EXPECT_EQ(font2, result);
78 EXPECT_EQ(2, cache.fetch_font_count_); 78 EXPECT_EQ(2, cache.fetch_font_count_);
79 } 79 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698