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

Side by Side Diff: chrome/browser/themes/theme_service_unittest.cc

Issue 16290004: Update chrome/ to use scoped_refptr<T>::get() rather than implicit "operator T*" (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 6 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 12 matching lines...) Expand all
23 DictionaryValue source; 23 DictionaryValue source;
24 source.SetString(extension_manifest_keys::kName, "theme"); 24 source.SetString(extension_manifest_keys::kName, "theme");
25 source.Set(extension_manifest_keys::kTheme, new DictionaryValue()); 25 source.Set(extension_manifest_keys::kTheme, new DictionaryValue());
26 source.SetString(extension_manifest_keys::kUpdateURL, "http://foo.com"); 26 source.SetString(extension_manifest_keys::kUpdateURL, "http://foo.com");
27 source.SetString(extension_manifest_keys::kVersion, "0.0.0.0"); 27 source.SetString(extension_manifest_keys::kVersion, "0.0.0.0");
28 std::string error; 28 std::string error;
29 scoped_refptr<extensions::Extension> extension = 29 scoped_refptr<extensions::Extension> extension =
30 extensions::Extension::Create( 30 extensions::Extension::Create(
31 path, extensions::Manifest::EXTERNAL_PREF_DOWNLOAD, 31 path, extensions::Manifest::EXTERNAL_PREF_DOWNLOAD,
32 source, extensions::Extension::NO_FLAGS, &error); 32 source, extensions::Extension::NO_FLAGS, &error);
33 EXPECT_TRUE(extension); 33 EXPECT_TRUE(extension.get());
34 EXPECT_EQ("", error); 34 EXPECT_EQ("", error);
35 return extension; 35 return extension;
36 } 36 }
37 37
38 virtual void SetUp() { 38 virtual void SetUp() {
39 ExtensionServiceTestBase::SetUp(); 39 ExtensionServiceTestBase::SetUp();
40 InitializeEmptyExtensionService(); 40 InitializeEmptyExtensionService();
41 } 41 }
42 }; 42 };
43 43
44 // Installs then uninstalls a theme and makes sure that the ThemeService 44 // Installs then uninstalls a theme and makes sure that the ThemeService
45 // reverts to the default theme after the uninstall. 45 // reverts to the default theme after the uninstall.
46 TEST_F(ThemeServiceTest, ThemeInstallUninstall) { 46 TEST_F(ThemeServiceTest, ThemeInstallUninstall) {
47 base::ScopedTempDir temp_dir; 47 base::ScopedTempDir temp_dir;
48 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); 48 ASSERT_TRUE(temp_dir.CreateUniqueTempDir());
49 ThemeService* theme_service = 49 ThemeService* theme_service =
50 ThemeServiceFactory::GetForProfile(profile_.get()); 50 ThemeServiceFactory::GetForProfile(profile_.get());
51 theme_service->UseDefaultTheme(); 51 theme_service->UseDefaultTheme();
52 scoped_refptr<extensions::Extension> extension = 52 scoped_refptr<extensions::Extension> extension =
53 MakeThemeExtension(temp_dir.path()); 53 MakeThemeExtension(temp_dir.path());
54 service_->FinishInstallationForTest(extension); 54 service_->FinishInstallationForTest(extension.get());
55 // Let ThemeService finish creating the theme pack. 55 // Let ThemeService finish creating the theme pack.
56 base::MessageLoop::current()->RunUntilIdle(); 56 base::MessageLoop::current()->RunUntilIdle();
57 EXPECT_FALSE(theme_service->UsingDefaultTheme()); 57 EXPECT_FALSE(theme_service->UsingDefaultTheme());
58 EXPECT_EQ(extension->id(), theme_service->GetThemeID()); 58 EXPECT_EQ(extension->id(), theme_service->GetThemeID());
59 59
60 // Now unload the extension, should revert to the default theme. 60 // Now unload the extension, should revert to the default theme.
61 service_->UnloadExtension(extension->id(), 61 service_->UnloadExtension(extension->id(),
62 extension_misc::UNLOAD_REASON_UNINSTALL); 62 extension_misc::UNLOAD_REASON_UNINSTALL);
63 EXPECT_TRUE(theme_service->UsingDefaultTheme()); 63 EXPECT_TRUE(theme_service->UsingDefaultTheme());
64 } 64 }
65 65
66 // Upgrades a theme and ensures that the ThemeService does not revert to the 66 // Upgrades a theme and ensures that the ThemeService does not revert to the
67 // default theme. 67 // default theme.
68 TEST_F(ThemeServiceTest, ThemeUpgrade) { 68 TEST_F(ThemeServiceTest, ThemeUpgrade) {
69 base::ScopedTempDir temp_dir; 69 base::ScopedTempDir temp_dir;
70 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); 70 ASSERT_TRUE(temp_dir.CreateUniqueTempDir());
71 ThemeService* theme_service = 71 ThemeService* theme_service =
72 ThemeServiceFactory::GetForProfile(profile_.get()); 72 ThemeServiceFactory::GetForProfile(profile_.get());
73 theme_service->UseDefaultTheme(); 73 theme_service->UseDefaultTheme();
74 scoped_refptr<extensions::Extension> extension = 74 scoped_refptr<extensions::Extension> extension =
75 MakeThemeExtension(temp_dir.path()); 75 MakeThemeExtension(temp_dir.path());
76 service_->FinishInstallationForTest(extension); 76 service_->FinishInstallationForTest(extension.get());
77 // Let ThemeService finish creating the theme pack. 77 // Let ThemeService finish creating the theme pack.
78 base::MessageLoop::current()->RunUntilIdle(); 78 base::MessageLoop::current()->RunUntilIdle();
79 EXPECT_FALSE(theme_service->UsingDefaultTheme()); 79 EXPECT_FALSE(theme_service->UsingDefaultTheme());
80 EXPECT_EQ(extension->id(), theme_service->GetThemeID()); 80 EXPECT_EQ(extension->id(), theme_service->GetThemeID());
81 81
82 // Now unload the extension, should revert to the default theme. 82 // Now unload the extension, should revert to the default theme.
83 service_->UnloadExtension(extension->id(), 83 service_->UnloadExtension(extension->id(),
84 extension_misc::UNLOAD_REASON_UPDATE); 84 extension_misc::UNLOAD_REASON_UPDATE);
85 EXPECT_FALSE(theme_service->UsingDefaultTheme()); 85 EXPECT_FALSE(theme_service->UsingDefaultTheme());
86 } 86 }
87 87
88 }; // namespace 88 }; // namespace
OLDNEW
« no previous file with comments | « chrome/browser/themes/theme_service.cc ('k') | chrome/browser/themes/theme_syncable_service_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698