OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "base/message_loop.h" | 5 #include "base/message_loop.h" |
6 #include "base/path_service.h" | 6 #include "base/path_service.h" |
7 #include "chrome/browser/extensions/image_loading_tracker.h" | 7 #include "chrome/browser/extensions/image_loading_tracker.h" |
| 8 #include "chrome/common/chrome_notification_types.h" |
8 #include "chrome/common/chrome_paths.h" | 9 #include "chrome/common/chrome_paths.h" |
9 #include "chrome/common/extensions/extension.h" | 10 #include "chrome/common/extensions/extension.h" |
10 #include "chrome/common/extensions/extension_icon_set.h" | 11 #include "chrome/common/extensions/extension_icon_set.h" |
11 #include "chrome/common/extensions/extension_resource.h" | 12 #include "chrome/common/extensions/extension_resource.h" |
12 #include "content/browser/browser_thread.h" | 13 #include "content/browser/browser_thread.h" |
13 #include "content/common/json_value_serializer.h" | 14 #include "content/common/json_value_serializer.h" |
14 #include "content/common/notification_service.h" | 15 #include "content/common/notification_service.h" |
15 #include "content/common/notification_type.h" | |
16 #include "testing/gtest/include/gtest/gtest.h" | 16 #include "testing/gtest/include/gtest/gtest.h" |
17 #include "third_party/skia/include/core/SkBitmap.h" | 17 #include "third_party/skia/include/core/SkBitmap.h" |
18 #include "ui/gfx/size.h" | 18 #include "ui/gfx/size.h" |
19 | 19 |
20 class ImageLoadingTrackerTest : public testing::Test, | 20 class ImageLoadingTrackerTest : public testing::Test, |
21 public ImageLoadingTracker::Observer { | 21 public ImageLoadingTracker::Observer { |
22 public: | 22 public: |
23 ImageLoadingTrackerTest() | 23 ImageLoadingTrackerTest() |
24 : image_loaded_count_(0), | 24 : image_loaded_count_(0), |
25 quit_in_image_loaded_(false), | 25 quit_in_image_loaded_(false), |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 Extension::EXTENSION_ICON_SMALLISH), | 156 Extension::EXTENSION_ICON_SMALLISH), |
157 ImageLoadingTracker::CACHE); | 157 ImageLoadingTracker::CACHE); |
158 | 158 |
159 // The image isn't cached, so we should not have received notification. | 159 // The image isn't cached, so we should not have received notification. |
160 EXPECT_EQ(0, image_loaded_count()); | 160 EXPECT_EQ(0, image_loaded_count()); |
161 | 161 |
162 // Send out notification the extension was uninstalled. | 162 // Send out notification the extension was uninstalled. |
163 UnloadedExtensionInfo details(extension.get(), | 163 UnloadedExtensionInfo details(extension.get(), |
164 UnloadedExtensionInfo::UNINSTALL); | 164 UnloadedExtensionInfo::UNINSTALL); |
165 NotificationService::current()->Notify( | 165 NotificationService::current()->Notify( |
166 NotificationType::EXTENSION_UNLOADED, | 166 chrome::NOTIFICATION_EXTENSION_UNLOADED, |
167 NotificationService::AllSources(), | 167 NotificationService::AllSources(), |
168 Details<UnloadedExtensionInfo>(&details)); | 168 Details<UnloadedExtensionInfo>(&details)); |
169 | 169 |
170 // Chuck the extension, that way if anyone tries to access it we should crash | 170 // Chuck the extension, that way if anyone tries to access it we should crash |
171 // or get valgrind errors. | 171 // or get valgrind errors. |
172 extension = NULL; | 172 extension = NULL; |
173 | 173 |
174 WaitForImageLoad(); | 174 WaitForImageLoad(); |
175 | 175 |
176 // Even though we deleted the extension, we should still get the image. | 176 // Even though we deleted the extension, we should still get the image. |
177 // We should still have gotten the image. | 177 // We should still have gotten the image. |
178 EXPECT_EQ(1, image_loaded_count()); | 178 EXPECT_EQ(1, image_loaded_count()); |
179 | 179 |
180 // Check that the image was loaded. | 180 // Check that the image was loaded. |
181 EXPECT_EQ(Extension::EXTENSION_ICON_SMALLISH, image_.width()); | 181 EXPECT_EQ(Extension::EXTENSION_ICON_SMALLISH, image_.width()); |
182 } | 182 } |
OLD | NEW |