| 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 "components/dom_distiller/core/distilled_page_prefs.h" | 5 #include "components/dom_distiller/core/distilled_page_prefs.h" |
| 6 | 6 |
| 7 #include "base/message_loop/message_loop.h" | 7 #include "base/message_loop/message_loop.h" |
| 8 #include "base/run_loop.h" | 8 #include "base/run_loop.h" |
| 9 #include "components/pref_registry/testing_pref_service_syncable.h" | 9 #include "components/pref_registry/testing_pref_service_syncable.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
| 11 | 11 |
| 12 namespace dom_distiller { | 12 namespace dom_distiller { |
| 13 | 13 |
| 14 namespace { | 14 namespace { |
| 15 | 15 |
| 16 class TestingObserver : public DistilledPagePrefs::Observer { | 16 class TestingObserver : public DistilledPagePrefs::Observer { |
| 17 public: | 17 public: |
| 18 TestingObserver() | 18 TestingObserver() |
| 19 : font_(DistilledPagePrefs::SANS_SERIF), | 19 : font_(DistilledPagePrefs::SANS_SERIF), |
| 20 theme_(DistilledPagePrefs::LIGHT) {} | 20 theme_(DistilledPagePrefs::LIGHT) {} |
| 21 | 21 |
| 22 virtual void OnChangeFontFamily( | 22 void OnChangeFontFamily(DistilledPagePrefs::FontFamily new_font) override { |
| 23 DistilledPagePrefs::FontFamily new_font) override { | |
| 24 font_ = new_font; | 23 font_ = new_font; |
| 25 } | 24 } |
| 26 | 25 |
| 27 DistilledPagePrefs::FontFamily GetFontFamily() { return font_; } | 26 DistilledPagePrefs::FontFamily GetFontFamily() { return font_; } |
| 28 | 27 |
| 29 virtual void OnChangeTheme(DistilledPagePrefs::Theme new_theme) override { | 28 void OnChangeTheme(DistilledPagePrefs::Theme new_theme) override { |
| 30 theme_ = new_theme; | 29 theme_ = new_theme; |
| 31 } | 30 } |
| 32 | 31 |
| 33 DistilledPagePrefs::Theme GetTheme() { return theme_; } | 32 DistilledPagePrefs::Theme GetTheme() { return theme_; } |
| 34 | 33 |
| 35 private: | 34 private: |
| 36 DistilledPagePrefs::FontFamily font_; | 35 DistilledPagePrefs::FontFamily font_; |
| 37 DistilledPagePrefs::Theme theme_; | 36 DistilledPagePrefs::Theme theme_; |
| 38 }; | 37 }; |
| 39 | 38 |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 EXPECT_EQ(DistilledPagePrefs::SEPIA, obs2.GetTheme()); | 107 EXPECT_EQ(DistilledPagePrefs::SEPIA, obs2.GetTheme()); |
| 109 distilled_page_prefs_->RemoveObserver(&obs); | 108 distilled_page_prefs_->RemoveObserver(&obs); |
| 110 distilled_page_prefs_->SetTheme(DistilledPagePrefs::LIGHT); | 109 distilled_page_prefs_->SetTheme(DistilledPagePrefs::LIGHT); |
| 111 base::RunLoop().RunUntilIdle(); | 110 base::RunLoop().RunUntilIdle(); |
| 112 EXPECT_EQ(DistilledPagePrefs::SEPIA, obs.GetTheme()); | 111 EXPECT_EQ(DistilledPagePrefs::SEPIA, obs.GetTheme()); |
| 113 EXPECT_EQ(DistilledPagePrefs::LIGHT, obs2.GetTheme()); | 112 EXPECT_EQ(DistilledPagePrefs::LIGHT, obs2.GetTheme()); |
| 114 distilled_page_prefs_->RemoveObserver(&obs2); | 113 distilled_page_prefs_->RemoveObserver(&obs2); |
| 115 } | 114 } |
| 116 | 115 |
| 117 } // namespace dom_distiller | 116 } // namespace dom_distiller |
| OLD | NEW |