| OLD | NEW |
| 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" | |
| 9 #include "chrome/test/base/testing_profile.h" | 8 #include "chrome/test/base/testing_profile.h" |
| 9 #include "components/syncable_prefs/testing_pref_service_syncable.h" |
| 10 #include "content/public/test/test_browser_thread_bundle.h" | 10 #include "content/public/test/test_browser_thread_bundle.h" |
| 11 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
| 12 | 12 |
| 13 namespace { | 13 namespace { |
| 14 | 14 |
| 15 class TestingFontFamilyCache : public FontFamilyCache { | 15 class TestingFontFamilyCache : public FontFamilyCache { |
| 16 public: | 16 public: |
| 17 explicit TestingFontFamilyCache(Profile* profile) | 17 explicit TestingFontFamilyCache(Profile* profile) |
| 18 : FontFamilyCache(profile), fetch_font_count_(0) {} | 18 : FontFamilyCache(profile), fetch_font_count_(0) {} |
| 19 ~TestingFontFamilyCache() override {} | 19 ~TestingFontFamilyCache() override {} |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 EXPECT_EQ(font1, result); | 68 EXPECT_EQ(font1, result); |
| 69 EXPECT_EQ(1, cache.fetch_font_count_); | 69 EXPECT_EQ(1, cache.fetch_font_count_); |
| 70 | 70 |
| 71 // Changing the preferences invalidates the cache. | 71 // Changing the preferences invalidates the cache. |
| 72 prefs->SetString(pref_name.c_str(), font2.c_str()); | 72 prefs->SetString(pref_name.c_str(), font2.c_str()); |
| 73 result = base::UTF16ToUTF8( | 73 result = base::UTF16ToUTF8( |
| 74 cache.FetchAndCacheFont(script.c_str(), map_name.c_str())); | 74 cache.FetchAndCacheFont(script.c_str(), map_name.c_str())); |
| 75 EXPECT_EQ(font2, result); | 75 EXPECT_EQ(font2, result); |
| 76 EXPECT_EQ(2, cache.fetch_font_count_); | 76 EXPECT_EQ(2, cache.fetch_font_count_); |
| 77 } | 77 } |
| OLD | NEW |