OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "ui/wm/core/shadow.h" | 5 #include "ui/wm/core/shadow.h" |
6 | 6 |
7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
8 #include "base/path_service.h" | 8 #include "base/path_service.h" |
9 #include "third_party/skia/include/core/SkBitmap.h" | 9 #include "third_party/skia/include/core/SkBitmap.h" |
10 #include "ui/aura/test/aura_test_base.h" | 10 #include "ui/aura/test/aura_test_base.h" |
(...skipping 22 matching lines...) Expand all Loading... |
33 bitmap_large.allocPixels( | 33 bitmap_large.allocPixels( |
34 SkImageInfo::MakeN32Premul(kLargeBitmapSize, kLargeBitmapSize)); | 34 SkImageInfo::MakeN32Premul(kLargeBitmapSize, kLargeBitmapSize)); |
35 image_small_ = gfx::Image::CreateFrom1xBitmap(bitmap_small); | 35 image_small_ = gfx::Image::CreateFrom1xBitmap(bitmap_small); |
36 image_large_ = gfx::Image::CreateFrom1xBitmap(bitmap_large); | 36 image_large_ = gfx::Image::CreateFrom1xBitmap(bitmap_large); |
37 } | 37 } |
38 virtual ~MockResourceBundleDelegate() {} | 38 virtual ~MockResourceBundleDelegate() {} |
39 | 39 |
40 // ResourceBundle::Delegate: | 40 // ResourceBundle::Delegate: |
41 virtual base::FilePath GetPathForResourcePack( | 41 virtual base::FilePath GetPathForResourcePack( |
42 const base::FilePath& pack_path, | 42 const base::FilePath& pack_path, |
43 ui::ScaleFactor scale_factor) OVERRIDE { | 43 ui::ScaleFactor scale_factor) override { |
44 return base::FilePath(); | 44 return base::FilePath(); |
45 } | 45 } |
46 virtual base::FilePath GetPathForLocalePack( | 46 virtual base::FilePath GetPathForLocalePack( |
47 const base::FilePath& pack_path, | 47 const base::FilePath& pack_path, |
48 const std::string& locale) OVERRIDE { | 48 const std::string& locale) override { |
49 return base::FilePath(); | 49 return base::FilePath(); |
50 } | 50 } |
51 virtual gfx::Image GetImageNamed(int resource_id) OVERRIDE { | 51 virtual gfx::Image GetImageNamed(int resource_id) override { |
52 last_resource_id_ = resource_id; | 52 last_resource_id_ = resource_id; |
53 switch (resource_id) { | 53 switch (resource_id) { |
54 case IDR_WINDOW_BUBBLE_SHADOW_SMALL: | 54 case IDR_WINDOW_BUBBLE_SHADOW_SMALL: |
55 return image_small_; | 55 return image_small_; |
56 case IDR_AURA_SHADOW_ACTIVE: | 56 case IDR_AURA_SHADOW_ACTIVE: |
57 case IDR_AURA_SHADOW_INACTIVE: | 57 case IDR_AURA_SHADOW_INACTIVE: |
58 return image_large_; | 58 return image_large_; |
59 default: | 59 default: |
60 NOTREACHED(); | 60 NOTREACHED(); |
61 return gfx::Image(); | 61 return gfx::Image(); |
62 } | 62 } |
63 } | 63 } |
64 virtual gfx::Image GetNativeImageNamed( | 64 virtual gfx::Image GetNativeImageNamed( |
65 int resource_id, ui::ResourceBundle::ImageRTL rtl) OVERRIDE { | 65 int resource_id, ui::ResourceBundle::ImageRTL rtl) override { |
66 return gfx::Image(); | 66 return gfx::Image(); |
67 } | 67 } |
68 virtual base::RefCountedStaticMemory* LoadDataResourceBytes( | 68 virtual base::RefCountedStaticMemory* LoadDataResourceBytes( |
69 int resource_id, ui::ScaleFactor scale_factor) OVERRIDE { | 69 int resource_id, ui::ScaleFactor scale_factor) override { |
70 return NULL; | 70 return NULL; |
71 } | 71 } |
72 virtual bool GetRawDataResource( | 72 virtual bool GetRawDataResource( |
73 int resource_id, ui::ScaleFactor scale_factor, | 73 int resource_id, ui::ScaleFactor scale_factor, |
74 base::StringPiece* value) OVERRIDE { | 74 base::StringPiece* value) override { |
75 return false; | 75 return false; |
76 } | 76 } |
77 virtual bool GetLocalizedString( | 77 virtual bool GetLocalizedString( |
78 int message_id, base::string16* value) OVERRIDE { | 78 int message_id, base::string16* value) override { |
79 return false; | 79 return false; |
80 } | 80 } |
81 virtual scoped_ptr<gfx::Font> GetFont( | 81 virtual scoped_ptr<gfx::Font> GetFont( |
82 ui::ResourceBundle::FontStyle style) OVERRIDE { | 82 ui::ResourceBundle::FontStyle style) override { |
83 return scoped_ptr<gfx::Font>(); | 83 return scoped_ptr<gfx::Font>(); |
84 } | 84 } |
85 | 85 |
86 int last_resource_id() const { return last_resource_id_; } | 86 int last_resource_id() const { return last_resource_id_; } |
87 | 87 |
88 private: | 88 private: |
89 gfx::Image image_small_; | 89 gfx::Image image_small_; |
90 gfx::Image image_large_; | 90 gfx::Image image_large_; |
91 int last_resource_id_; | 91 int last_resource_id_; |
92 | 92 |
93 DISALLOW_COPY_AND_ASSIGN(MockResourceBundleDelegate); | 93 DISALLOW_COPY_AND_ASSIGN(MockResourceBundleDelegate); |
94 }; | 94 }; |
95 | 95 |
96 } // namespace | 96 } // namespace |
97 | 97 |
98 class ShadowTest: public aura::test::AuraTestBase { | 98 class ShadowTest: public aura::test::AuraTestBase { |
99 public: | 99 public: |
100 ShadowTest() {} | 100 ShadowTest() {} |
101 virtual ~ShadowTest() {} | 101 virtual ~ShadowTest() {} |
102 | 102 |
103 MockResourceBundleDelegate* delegate() { return delegate_.get(); } | 103 MockResourceBundleDelegate* delegate() { return delegate_.get(); } |
104 | 104 |
105 // aura::testAuraBase: | 105 // aura::testAuraBase: |
106 virtual void SetUp() OVERRIDE { | 106 virtual void SetUp() override { |
107 aura::test::AuraTestBase::SetUp(); | 107 aura::test::AuraTestBase::SetUp(); |
108 delegate_.reset(new MockResourceBundleDelegate()); | 108 delegate_.reset(new MockResourceBundleDelegate()); |
109 if (ResourceBundle::HasSharedInstance()) | 109 if (ResourceBundle::HasSharedInstance()) |
110 ui::ResourceBundle::CleanupSharedInstance(); | 110 ui::ResourceBundle::CleanupSharedInstance(); |
111 ui::ResourceBundle::InitSharedInstanceWithLocale( | 111 ui::ResourceBundle::InitSharedInstanceWithLocale( |
112 "en-US", delegate(), ui::ResourceBundle::LOAD_COMMON_RESOURCES); | 112 "en-US", delegate(), ui::ResourceBundle::LOAD_COMMON_RESOURCES); |
113 } | 113 } |
114 virtual void TearDown() OVERRIDE { | 114 virtual void TearDown() override { |
115 ui::ResourceBundle::CleanupSharedInstance(); | 115 ui::ResourceBundle::CleanupSharedInstance(); |
116 base::FilePath ui_test_pak_path; | 116 base::FilePath ui_test_pak_path; |
117 ASSERT_TRUE(PathService::Get(ui::UI_TEST_PAK, &ui_test_pak_path)); | 117 ASSERT_TRUE(PathService::Get(ui::UI_TEST_PAK, &ui_test_pak_path)); |
118 ui::ResourceBundle::InitSharedInstanceWithPakPath(ui_test_pak_path); | 118 ui::ResourceBundle::InitSharedInstanceWithPakPath(ui_test_pak_path); |
119 aura::test::AuraTestBase::TearDown(); | 119 aura::test::AuraTestBase::TearDown(); |
120 } | 120 } |
121 private: | 121 private: |
122 scoped_ptr<MockResourceBundleDelegate> delegate_; | 122 scoped_ptr<MockResourceBundleDelegate> delegate_; |
123 DISALLOW_COPY_AND_ASSIGN(ShadowTest); | 123 DISALLOW_COPY_AND_ASSIGN(ShadowTest); |
124 }; | 124 }; |
(...skipping 19 matching lines...) Expand all Loading... |
144 gfx::Rect content_bounds(100, 100, 300, 300); | 144 gfx::Rect content_bounds(100, 100, 300, 300); |
145 shadow.SetContentBounds(content_bounds); | 145 shadow.SetContentBounds(content_bounds); |
146 EXPECT_EQ(shadow.content_bounds(), content_bounds); | 146 EXPECT_EQ(shadow.content_bounds(), content_bounds); |
147 EXPECT_EQ(shadow.layer()->bounds(), gfx::Rect(36, 36, 428, 428)); | 147 EXPECT_EQ(shadow.layer()->bounds(), gfx::Rect(36, 36, 428, 428)); |
148 | 148 |
149 shadow.SetStyle(Shadow::STYLE_SMALL); | 149 shadow.SetStyle(Shadow::STYLE_SMALL); |
150 EXPECT_EQ(shadow.content_bounds(), content_bounds); | 150 EXPECT_EQ(shadow.content_bounds(), content_bounds); |
151 EXPECT_EQ(shadow.layer()->bounds(), gfx::Rect(96, 96, 308, 308)); | 151 EXPECT_EQ(shadow.layer()->bounds(), gfx::Rect(96, 96, 308, 308)); |
152 } | 152 } |
153 } // namespace wm | 153 } // namespace wm |
OLD | NEW |