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

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: 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..ff90c21455299e8079164f78f1983d85e736c04c 100644
--- a/components/dom_distiller/core/distilled_page_prefs_unittests.cc
+++ b/components/dom_distiller/core/distilled_page_prefs_unittests.cc
@@ -15,15 +15,23 @@ 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_; }
robliao 2014/08/10 02:43:45 Linebreak above here.
sunangel 2014/08/11 21:51:33 Done.
virtual void OnChangeTheme(DistilledPagePrefs::Theme new_theme) OVERRIDE {
theme_ = new_theme;
}
-
DistilledPagePrefs::Theme GetTheme() { return theme_; }
private:
+ DistilledPagePrefs::FontFamily font_;
DistilledPagePrefs::Theme theme_;
};
@@ -44,6 +52,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 +95,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;

Powered by Google App Engine
This is Rietveld 408576698