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_service.h" | 5 #include "chrome/browser/themes/theme_service.h" |
6 | 6 |
7 #include "base/json/json_reader.h" | 7 #include "base/json/json_reader.h" |
8 #include "chrome/browser/extensions/extension_service_unittest.h" | 8 #include "chrome/browser/extensions/extension_service_unittest.h" |
9 #include "chrome/browser/themes/theme_service_factory.h" | 9 #include "chrome/browser/themes/theme_service_factory.h" |
10 #include "chrome/common/extensions/extension.h" | 10 #include "chrome/common/extensions/extension.h" |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 // Installs then uninstalls a theme and makes sure that the ThemeService | 87 // Installs then uninstalls a theme and makes sure that the ThemeService |
88 // reverts to the default theme after the uninstall. | 88 // reverts to the default theme after the uninstall. |
89 TEST_F(ThemeServiceTest, ThemeInstallUninstall) { | 89 TEST_F(ThemeServiceTest, ThemeInstallUninstall) { |
90 base::ScopedTempDir temp_dir; | 90 base::ScopedTempDir temp_dir; |
91 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); | 91 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); |
92 ThemeService* theme_service = | 92 ThemeService* theme_service = |
93 ThemeServiceFactory::GetForProfile(profile_.get()); | 93 ThemeServiceFactory::GetForProfile(profile_.get()); |
94 theme_service->UseDefaultTheme(); | 94 theme_service->UseDefaultTheme(); |
95 scoped_refptr<extensions::Extension> extension = | 95 scoped_refptr<extensions::Extension> extension = |
96 MakeThemeExtension(temp_dir.path()); | 96 MakeThemeExtension(temp_dir.path()); |
97 service_->FinishInstallationForTest(extension); | 97 service_->AddExtension(extension); |
98 // Let ThemeService finish creating the theme pack. | 98 // Let ThemeService finish creating the theme pack. |
99 MessageLoop::current()->RunUntilIdle(); | 99 MessageLoop::current()->RunUntilIdle(); |
100 EXPECT_FALSE(theme_service->UsingDefaultTheme()); | 100 EXPECT_FALSE(theme_service->UsingDefaultTheme()); |
101 EXPECT_EQ(extension->id(), theme_service->GetThemeID()); | 101 EXPECT_EQ(extension->id(), theme_service->GetThemeID()); |
102 | 102 |
103 // Now unload the extension, should revert to the default theme. | 103 // Now unload the extension, should revert to the default theme. |
104 service_->UnloadExtension(extension->id(), | 104 service_->UnloadExtension(extension->id(), |
105 extension_misc::UNLOAD_REASON_UNINSTALL); | 105 extension_misc::UNLOAD_REASON_UNINSTALL); |
106 EXPECT_TRUE(theme_service->UsingDefaultTheme()); | 106 EXPECT_TRUE(theme_service->UsingDefaultTheme()); |
107 } | 107 } |
108 | 108 |
109 // Upgrades a theme and ensures that the ThemeService does not revert to the | 109 // Upgrades a theme and ensures that the ThemeService does not revert to the |
110 // default theme. | 110 // default theme. |
111 TEST_F(ThemeServiceTest, ThemeUpgrade) { | 111 TEST_F(ThemeServiceTest, ThemeUpgrade) { |
112 base::ScopedTempDir temp_dir; | 112 base::ScopedTempDir temp_dir; |
113 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); | 113 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); |
114 ThemeService* theme_service = | 114 ThemeService* theme_service = |
115 ThemeServiceFactory::GetForProfile(profile_.get()); | 115 ThemeServiceFactory::GetForProfile(profile_.get()); |
116 theme_service->UseDefaultTheme(); | 116 theme_service->UseDefaultTheme(); |
117 scoped_refptr<extensions::Extension> extension = | 117 scoped_refptr<extensions::Extension> extension = |
118 MakeThemeExtension(temp_dir.path()); | 118 MakeThemeExtension(temp_dir.path()); |
119 service_->FinishInstallationForTest(extension); | 119 service_->AddExtension(extension); |
120 // Let ThemeService finish creating the theme pack. | 120 // Let ThemeService finish creating the theme pack. |
121 MessageLoop::current()->RunUntilIdle(); | 121 MessageLoop::current()->RunUntilIdle(); |
122 EXPECT_FALSE(theme_service->UsingDefaultTheme()); | 122 EXPECT_FALSE(theme_service->UsingDefaultTheme()); |
123 EXPECT_EQ(extension->id(), theme_service->GetThemeID()); | 123 EXPECT_EQ(extension->id(), theme_service->GetThemeID()); |
124 | 124 |
125 // Now unload the extension, should revert to the default theme. | 125 // Now unload the extension, should revert to the default theme. |
126 service_->UnloadExtension(extension->id(), | 126 service_->UnloadExtension(extension->id(), |
127 extension_misc::UNLOAD_REASON_UPDATE); | 127 extension_misc::UNLOAD_REASON_UPDATE); |
128 EXPECT_FALSE(theme_service->UsingDefaultTheme()); | 128 EXPECT_FALSE(theme_service->UsingDefaultTheme()); |
129 } | 129 } |
130 | 130 |
131 }; // namespace | 131 }; // namespace |
OLD | NEW |