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 "ash/frame/custom_frame_view_ash.h" | 5 #include "ash/frame/custom_frame_view_ash.h" |
6 | 6 |
7 #include "ash/shell.h" | |
7 #include "ash/test/ash_test_base.h" | 8 #include "ash/test/ash_test_base.h" |
9 #include "ash/test/test_session_state_delegate.h" | |
8 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
9 #include "grit/ash_resources.h" | 11 #include "grit/ash_resources.h" |
10 #include "ui/base/resource/resource_bundle.h" | 12 #include "ui/base/resource/resource_bundle.h" |
11 #include "ui/gfx/image/image_skia.h" | 13 #include "ui/gfx/image/image_skia.h" |
12 #include "ui/views/widget/widget.h" | 14 #include "ui/views/widget/widget.h" |
13 #include "ui/views/widget/widget_delegate.h" | 15 #include "ui/views/widget/widget_delegate.h" |
14 | 16 |
15 namespace ash { | 17 namespace ash { |
16 | 18 |
17 // A views::WidgetDelegate which uses a CustomFrameViewAsh. | 19 // A views::WidgetDelegate which uses a CustomFrameViewAsh. |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
90 scoped_ptr<views::Widget> widget(new views::Widget); | 92 scoped_ptr<views::Widget> widget(new views::Widget); |
91 views::Widget::InitParams params; | 93 views::Widget::InitParams params; |
92 params.delegate = delegate; | 94 params.delegate = delegate; |
93 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; | 95 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; |
94 params.bounds = gfx::Rect(0, 0, 100, 100); | 96 params.bounds = gfx::Rect(0, 0, 100, 100); |
95 params.context = CurrentContext(); | 97 params.context = CurrentContext(); |
96 widget->Init(params); | 98 widget->Init(params); |
97 return widget.Pass(); | 99 return widget.Pass(); |
98 } | 100 } |
99 | 101 |
102 test::TestSessionStateDelegate* GetTestSessionStateDelegate() { | |
103 return static_cast<ash::test::TestSessionStateDelegate*>( | |
104 Shell::GetInstance()->session_state_delegate()); | |
105 } | |
106 | |
100 private: | 107 private: |
101 DISALLOW_COPY_AND_ASSIGN(CustomFrameViewAshTest); | 108 DISALLOW_COPY_AND_ASSIGN(CustomFrameViewAshTest); |
102 }; | 109 }; |
103 | 110 |
104 // Test that the height of the header is correct upon initially displaying | 111 // Test that the height of the header is correct upon initially displaying |
105 // the widget. | 112 // the widget. |
106 TEST_F(CustomFrameViewAshTest, HeaderHeight) { | 113 TEST_F(CustomFrameViewAshTest, HeaderHeight) { |
107 TestWidgetDelegate* delegate = new TestWidgetDelegate; | 114 TestWidgetDelegate* delegate = new TestWidgetDelegate; |
108 | 115 |
109 scoped_ptr<views::Widget> widget(CreateWidget(delegate)); | 116 scoped_ptr<views::Widget> widget(CreateWidget(delegate)); |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
161 gfx::Size max_frame_size = custom_frame_view->GetMaximumSize(); | 168 gfx::Size max_frame_size = custom_frame_view->GetMaximumSize(); |
162 | 169 |
163 EXPECT_EQ(min_client_size.width(), min_frame_size.width()); | 170 EXPECT_EQ(min_client_size.width(), min_frame_size.width()); |
164 EXPECT_EQ(max_client_size.width(), max_frame_size.width()); | 171 EXPECT_EQ(max_client_size.width(), max_frame_size.width()); |
165 EXPECT_EQ(min_client_size.height() + delegate->GetTitleBarHeight(), | 172 EXPECT_EQ(min_client_size.height() + delegate->GetTitleBarHeight(), |
166 min_frame_size.height()); | 173 min_frame_size.height()); |
167 EXPECT_EQ(max_client_size.height() + delegate->GetTitleBarHeight(), | 174 EXPECT_EQ(max_client_size.height() + delegate->GetTitleBarHeight(), |
168 max_frame_size.height()); | 175 max_frame_size.height()); |
169 } | 176 } |
170 | 177 |
178 // Verify that CustomFrameViewAsh updates the avatar icon based on the | |
179 // state of the SessionStateDelegate after visibility change. | |
180 TEST_F(CustomFrameViewAshTest, AvatarIcon) { | |
181 TestWidgetConstraintsDelegate* delegate = new TestWidgetConstraintsDelegate; | |
182 scoped_ptr<views::Widget> widget(CreateWidget(delegate)); | |
183 | |
184 CustomFrameViewAsh* custom_frame_view = delegate->custom_frame_view(); | |
185 EXPECT_FALSE(custom_frame_view->GetAvatarIconViewForTest()); | |
186 | |
187 // Avatar icon becomes available. | |
pkotwicz
2014/03/18 04:41:15
How about: "Avatar image becomes available."
oshima
2014/03/18 14:57:03
Done.
| |
188 const gfx::ImageSkia user_image = | |
189 *ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed( | |
190 IDR_AURA_UBER_TRAY_GUEST_ICON); | |
191 GetTestSessionStateDelegate()->SetUserImage(user_image); | |
192 widget->Hide(); | |
193 widget->Show(); | |
194 EXPECT_TRUE(custom_frame_view->GetAvatarIconViewForTest()); | |
195 | |
196 // Avatar icon is gone, so is the avatar icon. | |
pkotwicz
2014/03/18 04:41:15
How about: "Avatar image is gone; the ImageView sh
oshima
2014/03/18 14:57:03
Done.
| |
197 GetTestSessionStateDelegate()->SetUserImage(gfx::ImageSkia()); | |
198 widget->Hide(); | |
199 widget->Show(); | |
200 EXPECT_FALSE(custom_frame_view->GetAvatarIconViewForTest()); | |
201 } | |
202 | |
171 } // namespace ash | 203 } // namespace ash |
OLD | NEW |