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/extensions/extension_action_icon_factory.h" | 5 #include "chrome/browser/extensions/extension_action_icon_factory.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
9 #include "base/json/json_file_value_serializer.h" | 9 #include "base/json/json_file_value_serializer.h" |
10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 : quit_in_icon_updated_(false), | 89 : quit_in_icon_updated_(false), |
90 ui_thread_(BrowserThread::UI, &ui_loop_), | 90 ui_thread_(BrowserThread::UI, &ui_loop_), |
91 file_thread_(BrowserThread::FILE), | 91 file_thread_(BrowserThread::FILE), |
92 io_thread_(BrowserThread::IO) { | 92 io_thread_(BrowserThread::IO) { |
93 } | 93 } |
94 | 94 |
95 virtual ~ExtensionActionIconFactoryTest() {} | 95 virtual ~ExtensionActionIconFactoryTest() {} |
96 | 96 |
97 void WaitForIconUpdate() { | 97 void WaitForIconUpdate() { |
98 quit_in_icon_updated_ = true; | 98 quit_in_icon_updated_ = true; |
99 MessageLoop::current()->Run(); | 99 base::MessageLoop::current()->Run(); |
100 quit_in_icon_updated_ = false; | 100 quit_in_icon_updated_ = false; |
101 } | 101 } |
102 | 102 |
103 scoped_refptr<Extension> CreateExtension(const char* name, | 103 scoped_refptr<Extension> CreateExtension(const char* name, |
104 Manifest::Location location) { | 104 Manifest::Location location) { |
105 // Create and load an extension. | 105 // Create and load an extension. |
106 base::FilePath test_file; | 106 base::FilePath test_file; |
107 if (!PathService::Get(chrome::DIR_TEST_DATA, &test_file)) { | 107 if (!PathService::Get(chrome::DIR_TEST_DATA, &test_file)) { |
108 EXPECT_FALSE(true); | 108 EXPECT_FALSE(true); |
109 return NULL; | 109 return NULL; |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 } | 144 } |
145 | 145 |
146 virtual void TearDown() OVERRIDE { | 146 virtual void TearDown() OVERRIDE { |
147 profile_.reset(); // Get all DeleteSoon calls sent to ui_loop_. | 147 profile_.reset(); // Get all DeleteSoon calls sent to ui_loop_. |
148 ui_loop_.RunUntilIdle(); | 148 ui_loop_.RunUntilIdle(); |
149 } | 149 } |
150 | 150 |
151 // ExtensionActionIconFactory::Observer overrides: | 151 // ExtensionActionIconFactory::Observer overrides: |
152 virtual void OnIconUpdated() OVERRIDE { | 152 virtual void OnIconUpdated() OVERRIDE { |
153 if (quit_in_icon_updated_) | 153 if (quit_in_icon_updated_) |
154 MessageLoop::current()->Quit(); | 154 base::MessageLoop::current()->Quit(); |
155 } | 155 } |
156 | 156 |
157 gfx::ImageSkia GetFavicon() { | 157 gfx::ImageSkia GetFavicon() { |
158 return *ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed( | 158 return *ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed( |
159 IDR_EXTENSIONS_FAVICON); | 159 IDR_EXTENSIONS_FAVICON); |
160 } | 160 } |
161 | 161 |
162 ExtensionAction* GetBrowserAction(const Extension& extension) { | 162 ExtensionAction* GetBrowserAction(const Extension& extension) { |
163 return ExtensionActionManager::Get(profile())->GetBrowserAction(extension); | 163 return ExtensionActionManager::Get(profile())->GetBrowserAction(extension); |
164 } | 164 } |
165 | 165 |
166 TestingProfile* profile() { return profile_.get(); } | 166 TestingProfile* profile() { return profile_.get(); } |
167 | 167 |
168 private: | 168 private: |
169 bool quit_in_icon_updated_; | 169 bool quit_in_icon_updated_; |
170 MessageLoop ui_loop_; | 170 base::MessageLoop ui_loop_; |
171 content::TestBrowserThread ui_thread_; | 171 content::TestBrowserThread ui_thread_; |
172 content::TestBrowserThread file_thread_; | 172 content::TestBrowserThread file_thread_; |
173 content::TestBrowserThread io_thread_; | 173 content::TestBrowserThread io_thread_; |
174 scoped_ptr<TestingProfile> profile_; | 174 scoped_ptr<TestingProfile> profile_; |
175 ExtensionService* extension_service_; | 175 ExtensionService* extension_service_; |
176 | 176 |
177 #if defined OS_CHROMEOS | 177 #if defined OS_CHROMEOS |
178 chromeos::ScopedTestDeviceSettingsService test_device_settings_service_; | 178 chromeos::ScopedTestDeviceSettingsService test_device_settings_service_; |
179 chromeos::ScopedTestCrosSettings test_cros_settings_; | 179 chromeos::ScopedTestCrosSettings test_cros_settings_; |
180 chromeos::ScopedTestUserManager test_user_manager_; | 180 chromeos::ScopedTestUserManager test_user_manager_; |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
294 icon = icon_factory.GetIcon(1); | 294 icon = icon_factory.GetIcon(1); |
295 | 295 |
296 EXPECT_TRUE(ImageRepsAreEqual( | 296 EXPECT_TRUE(ImageRepsAreEqual( |
297 default_icon.ToImageSkia()->GetRepresentation(ui::SCALE_FACTOR_100P), | 297 default_icon.ToImageSkia()->GetRepresentation(ui::SCALE_FACTOR_100P), |
298 icon.ToImageSkia()->GetRepresentation(ui::SCALE_FACTOR_100P))); | 298 icon.ToImageSkia()->GetRepresentation(ui::SCALE_FACTOR_100P))); |
299 | 299 |
300 } | 300 } |
301 | 301 |
302 } // namespace | 302 } // namespace |
303 } // namespace extensions | 303 } // namespace extensions |
OLD | NEW |