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

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

Issue 1086733002: Ensure tests have an active task runner (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased. Created 5 years, 8 months 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/strings/utf_string_conversions.h" 7 #include "base/strings/utf_string_conversions.h"
8 #include "chrome/test/base/testing_pref_service_syncable.h" 8 #include "chrome/test/base/testing_pref_service_syncable.h"
9 #include "chrome/test/base/testing_profile.h" 9 #include "chrome/test/base/testing_profile.h"
10 #include "content/public/test/test_browser_thread_bundle.h"
10 #include "testing/gtest/include/gtest/gtest.h" 11 #include "testing/gtest/include/gtest/gtest.h"
11 12
12 namespace { 13 namespace {
13 14
14 class TestingFontFamilyCache : public FontFamilyCache { 15 class TestingFontFamilyCache : public FontFamilyCache {
15 public: 16 public:
16 explicit TestingFontFamilyCache(Profile* profile) 17 explicit TestingFontFamilyCache(Profile* profile)
17 : FontFamilyCache(profile), fetch_font_count_(0) {} 18 : FontFamilyCache(profile), fetch_font_count_(0) {}
18 ~TestingFontFamilyCache() override {} 19 ~TestingFontFamilyCache() override {}
19 base::string16 FetchFont(const char* script, const char* map_name) override { 20 base::string16 FetchFont(const char* script, const char* map_name) override {
20 ++fetch_font_count_; 21 ++fetch_font_count_;
21 return FontFamilyCache::FetchFont(script, map_name); 22 return FontFamilyCache::FetchFont(script, map_name);
22 } 23 }
23 24
24 int fetch_font_count_; 25 int fetch_font_count_;
25 26
26 private: 27 private:
27 DISALLOW_COPY_AND_ASSIGN(TestingFontFamilyCache); 28 DISALLOW_COPY_AND_ASSIGN(TestingFontFamilyCache);
28 }; 29 };
29 30
30 } // namespace 31 } // namespace
31 32
32 // Tests that the cache is correctly set and cleared. 33 // Tests that the cache is correctly set and cleared.
33 TEST(FontFamilyCacheTest, Caching) { 34 TEST(FontFamilyCacheTest, Caching) {
35 content::TestBrowserThreadBundle thread_bundle_;
34 TestingProfile profile; 36 TestingProfile profile;
35 TestingFontFamilyCache cache(&profile); 37 TestingFontFamilyCache cache(&profile);
36 TestingPrefServiceSyncable* prefs = profile.GetTestingPrefService(); 38 TestingPrefServiceSyncable* prefs = profile.GetTestingPrefService();
37 39
38 std::string font1("font 1"); 40 std::string font1("font 1");
39 std::string font2("font 2"); 41 std::string font2("font 2");
40 std::string map_name("webkit.webprefs.fonts.pictograph"); 42 std::string map_name("webkit.webprefs.fonts.pictograph");
41 std::string script("Zzyxca"); 43 std::string script("Zzyxca");
42 std::string pref_name(map_name + '.' + script); 44 std::string pref_name(map_name + '.' + script);
43 std::string pref_name2(map_name + '.' + "adsf"); 45 std::string pref_name2(map_name + '.' + "adsf");
(...skipping 22 matching lines...) Expand all
66 EXPECT_EQ(font1, result); 68 EXPECT_EQ(font1, result);
67 EXPECT_EQ(1, cache.fetch_font_count_); 69 EXPECT_EQ(1, cache.fetch_font_count_);
68 70
69 // Changing the preferences invalidates the cache. 71 // Changing the preferences invalidates the cache.
70 prefs->SetString(pref_name.c_str(), font2.c_str()); 72 prefs->SetString(pref_name.c_str(), font2.c_str());
71 result = base::UTF16ToUTF8( 73 result = base::UTF16ToUTF8(
72 cache.FetchAndCacheFont(script.c_str(), map_name.c_str())); 74 cache.FetchAndCacheFont(script.c_str(), map_name.c_str()));
73 EXPECT_EQ(font2, result); 75 EXPECT_EQ(font2, result);
74 EXPECT_EQ(2, cache.fetch_font_count_); 76 EXPECT_EQ(2, cache.fetch_font_count_);
75 } 77 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/warning_badge_service_unittest.cc ('k') | chrome/browser/lifetime/application_lifetime.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698