OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/themes/theme_syncable_service.h" | 5 #include "chrome/browser/themes/theme_syncable_service.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 | 54 |
55 class FakeThemeService : public ThemeService { | 55 class FakeThemeService : public ThemeService { |
56 public: | 56 public: |
57 FakeThemeService() : | 57 FakeThemeService() : |
58 using_system_theme_(false), | 58 using_system_theme_(false), |
59 using_default_theme_(false), | 59 using_default_theme_(false), |
60 theme_extension_(NULL), | 60 theme_extension_(NULL), |
61 is_dirty_(false) {} | 61 is_dirty_(false) {} |
62 | 62 |
63 // ThemeService implementation | 63 // ThemeService implementation |
64 virtual void SetTheme(const extensions::Extension* extension) OVERRIDE { | 64 virtual void SetTheme(const extensions::Extension* extension) override { |
65 is_dirty_ = true; | 65 is_dirty_ = true; |
66 theme_extension_ = extension; | 66 theme_extension_ = extension; |
67 using_system_theme_ = false; | 67 using_system_theme_ = false; |
68 using_default_theme_ = false; | 68 using_default_theme_ = false; |
69 } | 69 } |
70 | 70 |
71 virtual void UseDefaultTheme() OVERRIDE { | 71 virtual void UseDefaultTheme() override { |
72 is_dirty_ = true; | 72 is_dirty_ = true; |
73 using_default_theme_ = true; | 73 using_default_theme_ = true; |
74 using_system_theme_ = false; | 74 using_system_theme_ = false; |
75 theme_extension_ = NULL; | 75 theme_extension_ = NULL; |
76 } | 76 } |
77 | 77 |
78 virtual void UseSystemTheme() OVERRIDE { | 78 virtual void UseSystemTheme() override { |
79 is_dirty_ = true; | 79 is_dirty_ = true; |
80 using_system_theme_ = true; | 80 using_system_theme_ = true; |
81 using_default_theme_ = false; | 81 using_default_theme_ = false; |
82 theme_extension_ = NULL; | 82 theme_extension_ = NULL; |
83 } | 83 } |
84 | 84 |
85 virtual bool UsingDefaultTheme() const OVERRIDE { | 85 virtual bool UsingDefaultTheme() const override { |
86 return using_default_theme_; | 86 return using_default_theme_; |
87 } | 87 } |
88 | 88 |
89 virtual bool UsingSystemTheme() const OVERRIDE { | 89 virtual bool UsingSystemTheme() const override { |
90 return using_system_theme_; | 90 return using_system_theme_; |
91 } | 91 } |
92 | 92 |
93 virtual string GetThemeID() const OVERRIDE { | 93 virtual string GetThemeID() const override { |
94 if (theme_extension_.get()) | 94 if (theme_extension_.get()) |
95 return theme_extension_->id(); | 95 return theme_extension_->id(); |
96 else | 96 else |
97 return std::string(); | 97 return std::string(); |
98 } | 98 } |
99 | 99 |
100 const extensions::Extension* theme_extension() const { | 100 const extensions::Extension* theme_extension() const { |
101 return theme_extension_.get(); | 101 return theme_extension_.get(); |
102 } | 102 } |
103 | 103 |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
229 #endif | 229 #endif |
230 | 230 |
231 scoped_ptr<TestingProfile> profile_; | 231 scoped_ptr<TestingProfile> profile_; |
232 FakeThemeService* fake_theme_service_; | 232 FakeThemeService* fake_theme_service_; |
233 scoped_refptr<extensions::Extension> theme_extension_; | 233 scoped_refptr<extensions::Extension> theme_extension_; |
234 scoped_ptr<ThemeSyncableService> theme_sync_service_; | 234 scoped_ptr<ThemeSyncableService> theme_sync_service_; |
235 scoped_ptr<syncer::FakeSyncChangeProcessor> fake_change_processor_; | 235 scoped_ptr<syncer::FakeSyncChangeProcessor> fake_change_processor_; |
236 }; | 236 }; |
237 | 237 |
238 class PolicyInstalledThemeTest : public ThemeSyncableServiceTest { | 238 class PolicyInstalledThemeTest : public ThemeSyncableServiceTest { |
239 virtual extensions::Manifest::Location GetThemeLocation() OVERRIDE { | 239 virtual extensions::Manifest::Location GetThemeLocation() override { |
240 return extensions::Manifest::EXTERNAL_POLICY_DOWNLOAD; | 240 return extensions::Manifest::EXTERNAL_POLICY_DOWNLOAD; |
241 } | 241 } |
242 }; | 242 }; |
243 | 243 |
244 TEST_F(ThemeSyncableServiceTest, AreThemeSpecificsEqual) { | 244 TEST_F(ThemeSyncableServiceTest, AreThemeSpecificsEqual) { |
245 sync_pb::ThemeSpecifics a, b; | 245 sync_pb::ThemeSpecifics a, b; |
246 EXPECT_TRUE(ThemeSyncableService::AreThemeSpecificsEqual(a, b, false)); | 246 EXPECT_TRUE(ThemeSyncableService::AreThemeSpecificsEqual(a, b, false)); |
247 EXPECT_TRUE(ThemeSyncableService::AreThemeSpecificsEqual(a, b, true)); | 247 EXPECT_TRUE(ThemeSyncableService::AreThemeSpecificsEqual(a, b, true)); |
248 | 248 |
249 // Custom vs. non-custom. | 249 // Custom vs. non-custom. |
(...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
653 | 653 |
654 TEST_F(PolicyInstalledThemeTest, InstallThemeByPolicy) { | 654 TEST_F(PolicyInstalledThemeTest, InstallThemeByPolicy) { |
655 // Set up theme service to use custom theme that was installed by policy. | 655 // Set up theme service to use custom theme that was installed by policy. |
656 fake_theme_service_->SetTheme(theme_extension_.get()); | 656 fake_theme_service_->SetTheme(theme_extension_.get()); |
657 | 657 |
658 syncer::SyncDataList data_list = | 658 syncer::SyncDataList data_list = |
659 theme_sync_service_->GetAllSyncData(syncer::THEMES); | 659 theme_sync_service_->GetAllSyncData(syncer::THEMES); |
660 | 660 |
661 ASSERT_EQ(0u, data_list.size()); | 661 ASSERT_EQ(0u, data_list.size()); |
662 } | 662 } |
OLD | NEW |