summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjamescook <jamescook@chromium.org>2014-09-06 17:08:08 -0700
committerCommit bot <commit-bot@chromium.org>2014-09-07 00:10:43 +0000
commit843ee06eec3984c6b850906d51d7923ca1f9bee0 (patch)
tree165f131ba846ca3eef8a5cf8c5b1e1dba5e94eba
parent0f9a432e5e5fe32767111f1ff4db558839852d1b (diff)
downloadchromium_src-843ee06eec3984c6b850906d51d7923ca1f9bee0.zip
chromium_src-843ee06eec3984c6b850906d51d7923ca1f9bee0.tar.gz
chromium_src-843ee06eec3984c6b850906d51d7923ca1f9bee0.tar.bz2
Move ExtensionIconImageTest to extensions_unittests
It doesn't need to run in Chrome's unit_tests suite. BUG=397164 TEST=extensions_unittests Review URL: https://codereview.chromium.org/546933002 Cr-Commit-Position: refs/heads/master@{#293644}
-rw-r--r--chrome/chrome_tests_unit.gypi1
-rw-r--r--extensions/browser/extension_icon_image_unittest.cc55
-rw-r--r--extensions/extensions.gyp1
3 files changed, 27 insertions, 30 deletions
diff --git a/chrome/chrome_tests_unit.gypi b/chrome/chrome_tests_unit.gypi
index 1916c5e..d27bd81 100644
--- a/chrome/chrome_tests_unit.gypi
+++ b/chrome/chrome_tests_unit.gypi
@@ -538,7 +538,6 @@
'../extensions/browser/error_map_unittest.cc',
'../extensions/browser/extension_error_test_util.cc',
'../extensions/browser/extension_error_test_util.h',
- '../extensions/browser/extension_icon_image_unittest.cc',
'../extensions/common/extension_l10n_util_unittest.cc',
'../extensions/common/features/base_feature_provider_unittest.cc',
'../extensions/common/features/complex_feature_unittest.cc',
diff --git a/extensions/browser/extension_icon_image_unittest.cc b/extensions/browser/extension_icon_image_unittest.cc
index 57b5c47..9cc10a4 100644
--- a/extensions/browser/extension_icon_image_unittest.cc
+++ b/extensions/browser/extension_icon_image_unittest.cc
@@ -4,11 +4,15 @@
#include "extensions/browser/extension_icon_image.h"
+#include <vector>
+
#include "base/json/json_file_value_serializer.h"
#include "base/message_loop/message_loop.h"
#include "base/path_service.h"
-#include "chrome/test/base/testing_profile.h"
+#include "content/public/browser/notification_service.h"
+#include "content/public/test/test_browser_context.h"
#include "content/public/test/test_browser_thread.h"
+#include "extensions/browser/extensions_test.h"
#include "extensions/browser/image_loader.h"
#include "extensions/common/extension.h"
#include "extensions/common/extension_paths.h"
@@ -21,10 +25,8 @@
#include "ui/gfx/skia_util.h"
using content::BrowserThread;
-using extensions::Extension;
-using extensions::IconImage;
-using extensions::Manifest;
+namespace extensions {
namespace {
SkBitmap CreateBlankBitmapForScale(int size_dip, ui::ScaleFactor scale_factor) {
@@ -107,12 +109,12 @@ class TestImageLoader {
bool waiting_;
bool image_loaded_;
gfx::Image image_;
- extensions::ImageLoader image_loader_;
+ ImageLoader image_loader_;
DISALLOW_COPY_AND_ASSIGN(TestImageLoader);
};
-class ExtensionIconImageTest : public testing::Test,
+class ExtensionIconImageTest : public ExtensionsTest,
public IconImage::Observer {
public:
ExtensionIconImageTest()
@@ -120,8 +122,8 @@ class ExtensionIconImageTest : public testing::Test,
quit_in_image_loaded_(false),
ui_thread_(BrowserThread::UI, &ui_loop_),
file_thread_(BrowserThread::FILE),
- io_thread_(BrowserThread::IO) {
- }
+ io_thread_(BrowserThread::IO),
+ notification_service_(content::NotificationService::Create()) {}
virtual ~ExtensionIconImageTest() {}
@@ -141,7 +143,7 @@ class ExtensionIconImageTest : public testing::Test,
Manifest::Location location) {
// Create and load an extension.
base::FilePath test_file;
- if (!PathService::Get(extensions::DIR_TEST_DATA, &test_file)) {
+ if (!PathService::Get(DIR_TEST_DATA, &test_file)) {
EXPECT_FALSE(true);
return NULL;
}
@@ -197,6 +199,7 @@ class ExtensionIconImageTest : public testing::Test,
content::TestBrowserThread ui_thread_;
content::TestBrowserThread file_thread_;
content::TestBrowserThread io_thread_;
+ scoped_ptr<content::NotificationService> notification_service_;
DISALLOW_COPY_AND_ASSIGN(ExtensionIconImageTest);
};
@@ -208,7 +211,6 @@ TEST_F(ExtensionIconImageTest, Basic) {
supported_factors.push_back(ui::SCALE_FACTOR_100P);
supported_factors.push_back(ui::SCALE_FACTOR_200P);
ui::test::ScopedSetSupportedScaleFactors scoped_supported(supported_factors);
- scoped_ptr<content::BrowserContext> profile(new TestingProfile());
scoped_refptr<Extension> extension(CreateExtension(
"extension_icon_image", Manifest::INVALID_LOCATION));
ASSERT_TRUE(extension.get() != NULL);
@@ -226,9 +228,9 @@ TEST_F(ExtensionIconImageTest, Basic) {
GetTestBitmap(extension.get(), "48.png", 32);
ASSERT_FALSE(bitmap_48_resized_to_32.empty());
- IconImage image(profile.get(),
+ IconImage image(browser_context(),
extension.get(),
- extensions::IconsInfo::GetIcons(extension.get()),
+ IconsInfo::GetIcons(extension.get()),
16,
default_icon,
this);
@@ -282,7 +284,6 @@ TEST_F(ExtensionIconImageTest, FallbackToSmallerWhenNoBigger) {
supported_factors.push_back(ui::SCALE_FACTOR_100P);
supported_factors.push_back(ui::SCALE_FACTOR_200P);
ui::test::ScopedSetSupportedScaleFactors scoped_supported(supported_factors);
- scoped_ptr<content::BrowserContext> profile(new TestingProfile());
scoped_refptr<Extension> extension(CreateExtension(
"extension_icon_image", Manifest::INVALID_LOCATION));
ASSERT_TRUE(extension.get() != NULL);
@@ -294,9 +295,9 @@ TEST_F(ExtensionIconImageTest, FallbackToSmallerWhenNoBigger) {
SkBitmap bitmap_48 = GetTestBitmap(extension.get(), "48.png", 48);
ASSERT_FALSE(bitmap_48.empty());
- IconImage image(profile.get(),
+ IconImage image(browser_context(),
extension.get(),
- extensions::IconsInfo::GetIcons(extension.get()),
+ IconsInfo::GetIcons(extension.get()),
32,
default_icon,
this);
@@ -320,7 +321,6 @@ TEST_F(ExtensionIconImageTest, FallbackToSmallerWhenNoBigger) {
// There is no resource with exact size, but there is a smaller and a bigger
// one. The bigger resource should be loaded.
TEST_F(ExtensionIconImageTest, FallbackToBigger) {
- scoped_ptr<content::BrowserContext> profile(new TestingProfile());
scoped_refptr<Extension> extension(CreateExtension(
"extension_icon_image", Manifest::INVALID_LOCATION));
ASSERT_TRUE(extension.get() != NULL);
@@ -332,9 +332,9 @@ TEST_F(ExtensionIconImageTest, FallbackToBigger) {
SkBitmap bitmap_24 = GetTestBitmap(extension.get(), "24.png", 24);
ASSERT_FALSE(bitmap_24.empty());
- IconImage image(profile.get(),
+ IconImage image(browser_context(),
extension.get(),
- extensions::IconsInfo::GetIcons(extension.get()),
+ IconsInfo::GetIcons(extension.get()),
17,
default_icon,
this);
@@ -357,7 +357,6 @@ TEST_F(ExtensionIconImageTest, FallbackToBigger) {
// If resource set is empty, |GetRepresentation| should synchronously return
// default icon, without notifying observer of image change.
TEST_F(ExtensionIconImageTest, NoResources) {
- scoped_ptr<content::BrowserContext> profile(new TestingProfile());
scoped_refptr<Extension> extension(CreateExtension(
"extension_icon_image", Manifest::INVALID_LOCATION));
ASSERT_TRUE(extension.get() != NULL);
@@ -366,7 +365,7 @@ TEST_F(ExtensionIconImageTest, NoResources) {
gfx::ImageSkia default_icon = GetDefaultIcon();
const int kRequestedSize = 24;
- IconImage image(profile.get(),
+ IconImage image(browser_context(),
extension.get(),
empty_icon_set,
kRequestedSize,
@@ -396,7 +395,6 @@ TEST_F(ExtensionIconImageTest, NoResources) {
// the observer should be notified when it's done. |GetRepresentation| should
// return the default icon representation once image load is done.
TEST_F(ExtensionIconImageTest, InvalidResource) {
- scoped_ptr<content::BrowserContext> profile(new TestingProfile());
scoped_refptr<Extension> extension(CreateExtension(
"extension_icon_image", Manifest::INVALID_LOCATION));
ASSERT_TRUE(extension.get() != NULL);
@@ -407,7 +405,7 @@ TEST_F(ExtensionIconImageTest, InvalidResource) {
gfx::ImageSkia default_icon = GetDefaultIcon();
- IconImage image(profile.get(),
+ IconImage image(browser_context(),
extension.get(),
invalid_icon_set,
kInvalidIconSize,
@@ -435,7 +433,6 @@ TEST_F(ExtensionIconImageTest, InvalidResource) {
// Test that IconImage works with lazily (but synchronously) created default
// icon when IconImage returns synchronously.
TEST_F(ExtensionIconImageTest, LazyDefaultIcon) {
- scoped_ptr<content::BrowserContext> profile(new TestingProfile());
scoped_refptr<Extension> extension(CreateExtension(
"extension_icon_image", Manifest::INVALID_LOCATION));
ASSERT_TRUE(extension.get() != NULL);
@@ -447,7 +444,7 @@ TEST_F(ExtensionIconImageTest, LazyDefaultIcon) {
ExtensionIconSet empty_icon_set;
const int kRequestedSize = 128;
- IconImage image(profile.get(),
+ IconImage image(browser_context(),
extension.get(),
empty_icon_set,
kRequestedSize,
@@ -473,7 +470,6 @@ TEST_F(ExtensionIconImageTest, LazyDefaultIcon) {
// Test that IconImage works with lazily (but synchronously) created default
// icon when IconImage returns asynchronously.
TEST_F(ExtensionIconImageTest, LazyDefaultIcon_AsyncIconImage) {
- scoped_ptr<content::BrowserContext> profile(new TestingProfile());
scoped_refptr<Extension> extension(CreateExtension(
"extension_icon_image", Manifest::INVALID_LOCATION));
ASSERT_TRUE(extension.get() != NULL);
@@ -486,7 +482,7 @@ TEST_F(ExtensionIconImageTest, LazyDefaultIcon_AsyncIconImage) {
ExtensionIconSet invalid_icon_set;
invalid_icon_set.Add(kInvalidIconSize, "invalid.png");
- IconImage image(profile.get(),
+ IconImage image(browser_context(),
extension.get(),
invalid_icon_set,
kInvalidIconSize,
@@ -517,7 +513,6 @@ TEST_F(ExtensionIconImageTest, LazyDefaultIcon_AsyncIconImage) {
// representation was not loaded while IconImage host was around, transparent
// representations should be returned.
TEST_F(ExtensionIconImageTest, IconImageDestruction) {
- scoped_ptr<content::BrowserContext> profile(new TestingProfile());
scoped_refptr<Extension> extension(CreateExtension(
"extension_icon_image", Manifest::INVALID_LOCATION));
ASSERT_TRUE(extension.get() != NULL);
@@ -530,9 +525,9 @@ TEST_F(ExtensionIconImageTest, IconImageDestruction) {
ASSERT_FALSE(bitmap_16.empty());
scoped_ptr<IconImage> image(
- new IconImage(profile.get(),
+ new IconImage(browser_context(),
extension.get(),
- extensions::IconsInfo::GetIcons(extension.get()),
+ IconsInfo::GetIcons(extension.get()),
16,
default_icon,
this));
@@ -566,3 +561,5 @@ TEST_F(ExtensionIconImageTest, IconImageDestruction) {
EXPECT_EQ(16, representation.GetHeight());
EXPECT_EQ(2.0f, representation.scale());
}
+
+} // namespace extensions
diff --git a/extensions/extensions.gyp b/extensions/extensions.gyp
index d23ebed..cca73d6 100644
--- a/extensions/extensions.gyp
+++ b/extensions/extensions.gyp
@@ -1014,6 +1014,7 @@
'browser/event_router_unittest.cc',
'browser/api_unittest.cc',
'browser/api_unittest.h',
+ 'browser/extension_icon_image_unittest.cc',
'browser/extension_pref_value_map_unittest.cc',
'browser/extension_registry_unittest.cc',
'browser/file_highlighter_unittest.cc',