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

Unified Diff: components/dom_distiller/core/distilled_page_prefs_unittests.cc

Issue 430473007: Font Family Preferences for Distilled Pages (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: synced Created 6 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: components/dom_distiller/core/distilled_page_prefs_unittests.cc
diff --git a/components/dom_distiller/core/distilled_page_prefs_unittests.cc b/components/dom_distiller/core/distilled_page_prefs_unittests.cc
index 700a9fcf089fbebc3a5f1a449dfa46af146e21e5..fe9df73096afb6455f84eb04f7ed923707b2b16a 100644
--- a/components/dom_distiller/core/distilled_page_prefs_unittests.cc
+++ b/components/dom_distiller/core/distilled_page_prefs_unittests.cc
@@ -15,7 +15,16 @@ namespace {
class TestingObserver : public DistilledPagePrefs::Observer {
public:
- TestingObserver() : theme_(DistilledPagePrefs::LIGHT) {}
+ TestingObserver()
+ : font_(DistilledPagePrefs::SANS_SERIF),
+ theme_(DistilledPagePrefs::LIGHT) {}
+
+ virtual void OnChangeFontFamily(
+ DistilledPagePrefs::FontFamily new_font) OVERRIDE {
+ font_ = new_font;
+ }
+
+ DistilledPagePrefs::FontFamily GetFontFamily() { return font_; }
virtual void OnChangeTheme(DistilledPagePrefs::Theme new_theme) OVERRIDE {
theme_ = new_theme;
@@ -24,6 +33,7 @@ class TestingObserver : public DistilledPagePrefs::Observer {
DistilledPagePrefs::Theme GetTheme() { return theme_; }
private:
+ DistilledPagePrefs::FontFamily font_;
DistilledPagePrefs::Theme theme_;
};
@@ -44,6 +54,36 @@ class DistilledPagePrefsTest : public testing::Test {
base::MessageLoop message_loop_;
};
+TEST_F(DistilledPagePrefsTest, TestingOnChangeFontIsBeingCalled) {
+ TestingObserver obs;
+ distilled_page_prefs_->AddObserver(&obs);
+ distilled_page_prefs_->SetFontFamily(DistilledPagePrefs::MONOSPACE);
+ EXPECT_EQ(DistilledPagePrefs::SANS_SERIF, obs.GetFontFamily());
+ base::RunLoop().RunUntilIdle();
+ EXPECT_EQ(DistilledPagePrefs::MONOSPACE, obs.GetFontFamily());
+ distilled_page_prefs_->SetFontFamily(DistilledPagePrefs::SERIF);
+ base::RunLoop().RunUntilIdle();
+ EXPECT_EQ(DistilledPagePrefs::SERIF, obs.GetFontFamily());
+ distilled_page_prefs_->RemoveObserver(&obs);
+}
+
+TEST_F(DistilledPagePrefsTest, TestingMultipleObserversFont) {
+ TestingObserver obs;
+ distilled_page_prefs_->AddObserver(&obs);
+ TestingObserver obs2;
+ distilled_page_prefs_->AddObserver(&obs2);
+ distilled_page_prefs_->SetFontFamily(DistilledPagePrefs::SERIF);
+ base::RunLoop().RunUntilIdle();
+ EXPECT_EQ(DistilledPagePrefs::SERIF, obs.GetFontFamily());
+ EXPECT_EQ(DistilledPagePrefs::SERIF, obs2.GetFontFamily());
+ distilled_page_prefs_->RemoveObserver(&obs);
+ distilled_page_prefs_->SetFontFamily(DistilledPagePrefs::MONOSPACE);
+ base::RunLoop().RunUntilIdle();
+ EXPECT_EQ(DistilledPagePrefs::SERIF, obs.GetFontFamily());
+ EXPECT_EQ(DistilledPagePrefs::MONOSPACE, obs2.GetFontFamily());
+ distilled_page_prefs_->RemoveObserver(&obs2);
+}
+
TEST_F(DistilledPagePrefsTest, TestingOnChangeThemeIsBeingCalled) {
TestingObserver obs;
distilled_page_prefs_->AddObserver(&obs);
@@ -57,7 +97,7 @@ TEST_F(DistilledPagePrefsTest, TestingOnChangeThemeIsBeingCalled) {
distilled_page_prefs_->RemoveObserver(&obs);
}
-TEST_F(DistilledPagePrefsTest, TestingMultipleObservers) {
+TEST_F(DistilledPagePrefsTest, TestingMultipleObserversTheme) {
TestingObserver obs;
distilled_page_prefs_->AddObserver(&obs);
TestingObserver obs2;
« no previous file with comments | « components/dom_distiller/core/distilled_page_prefs_android.cc ('k') | components/dom_distiller/core/font_family_list.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698