| 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/common/frame/custom_frame_view_ash.h" | 5 #include "ash/common/frame/custom_frame_view_ash.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "ash/common/ash_layout_constants.h" | 9 #include "ash/common/ash_layout_constants.h" |
| 10 #include "ash/common/frame/caption_buttons/frame_caption_button.h" | 10 #include "ash/common/frame/caption_buttons/frame_caption_button.h" |
| 11 #include "ash/common/frame/caption_buttons/frame_caption_button_container_view.h
" | 11 #include "ash/common/frame/caption_buttons/frame_caption_button_container_view.h
" |
| 12 #include "ash/common/test/test_session_state_delegate.h" | 12 #include "ash/common/test/test_session_state_delegate.h" |
| 13 #include "ash/common/wm/maximize_mode/maximize_mode_controller.h" | 13 #include "ash/common/wm/maximize_mode/maximize_mode_controller.h" |
| 14 #include "ash/common/wm_shell.h" | 14 #include "ash/common/wm_shell.h" |
| 15 #include "ash/test/ash_test_base.h" | 15 #include "ash/test/ash_test_base.h" |
| 16 #include "grit/ash_resources.h" | |
| 17 #include "ui/base/resource/resource_bundle.h" | |
| 18 #include "ui/gfx/geometry/rect.h" | 16 #include "ui/gfx/geometry/rect.h" |
| 19 #include "ui/gfx/image/image_skia.h" | 17 #include "ui/gfx/image/image_skia.h" |
| 18 #include "ui/gfx/image/image_unittest_util.h" |
| 20 #include "ui/views/widget/widget.h" | 19 #include "ui/views/widget/widget.h" |
| 21 #include "ui/views/widget/widget_delegate.h" | 20 #include "ui/views/widget/widget_delegate.h" |
| 22 | 21 |
| 23 namespace ash { | 22 namespace ash { |
| 24 | 23 |
| 25 // A views::WidgetDelegate which uses a CustomFrameViewAsh. | 24 // A views::WidgetDelegate which uses a CustomFrameViewAsh. |
| 26 class TestWidgetDelegate : public views::WidgetDelegateView { | 25 class TestWidgetDelegate : public views::WidgetDelegateView { |
| 27 public: | 26 public: |
| 28 TestWidgetDelegate() {} | 27 TestWidgetDelegate() {} |
| 29 ~TestWidgetDelegate() override {} | 28 ~TestWidgetDelegate() override {} |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 // Verify that CustomFrameViewAsh updates the avatar icon based on the | 180 // Verify that CustomFrameViewAsh updates the avatar icon based on the |
| 182 // state of the SessionStateDelegate after visibility change. | 181 // state of the SessionStateDelegate after visibility change. |
| 183 TEST_F(CustomFrameViewAshTest, AvatarIcon) { | 182 TEST_F(CustomFrameViewAshTest, AvatarIcon) { |
| 184 TestWidgetConstraintsDelegate* delegate = new TestWidgetConstraintsDelegate; | 183 TestWidgetConstraintsDelegate* delegate = new TestWidgetConstraintsDelegate; |
| 185 std::unique_ptr<views::Widget> widget(CreateWidget(delegate)); | 184 std::unique_ptr<views::Widget> widget(CreateWidget(delegate)); |
| 186 | 185 |
| 187 CustomFrameViewAsh* custom_frame_view = delegate->custom_frame_view(); | 186 CustomFrameViewAsh* custom_frame_view = delegate->custom_frame_view(); |
| 188 EXPECT_FALSE(custom_frame_view->GetAvatarIconViewForTest()); | 187 EXPECT_FALSE(custom_frame_view->GetAvatarIconViewForTest()); |
| 189 | 188 |
| 190 // Avatar image becomes available. | 189 // Avatar image becomes available. |
| 191 const gfx::ImageSkia user_image = | 190 GetTestSessionStateDelegate()->SetUserImage( |
| 192 *ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed( | 191 gfx::test::CreateImage(27, 27).AsImageSkia()); |
| 193 IDR_AURA_UBER_TRAY_GUEST_ICON); | |
| 194 GetTestSessionStateDelegate()->SetUserImage(user_image); | |
| 195 widget->Hide(); | 192 widget->Hide(); |
| 196 widget->Show(); | 193 widget->Show(); |
| 197 EXPECT_TRUE(custom_frame_view->GetAvatarIconViewForTest()); | 194 EXPECT_TRUE(custom_frame_view->GetAvatarIconViewForTest()); |
| 198 | 195 |
| 199 // Avatar image is gone; the ImageView for the avatar icon should be | 196 // Avatar image is gone; the ImageView for the avatar icon should be |
| 200 // removed. | 197 // removed. |
| 201 GetTestSessionStateDelegate()->SetUserImage(gfx::ImageSkia()); | 198 GetTestSessionStateDelegate()->SetUserImage(gfx::ImageSkia()); |
| 202 widget->Hide(); | 199 widget->Hide(); |
| 203 widget->Show(); | 200 widget->Show(); |
| 204 EXPECT_FALSE(custom_frame_view->GetAvatarIconViewForTest()); | 201 EXPECT_FALSE(custom_frame_view->GetAvatarIconViewForTest()); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 221 EXPECT_GT(initial.width(), maximize_mode_bounds.width()); | 218 EXPECT_GT(initial.width(), maximize_mode_bounds.width()); |
| 222 WmShell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager( | 219 WmShell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager( |
| 223 false); | 220 false); |
| 224 delegate->EndFrameCaptionButtonContainerViewAnimations(); | 221 delegate->EndFrameCaptionButtonContainerViewAnimations(); |
| 225 const gfx::Rect after_restore = | 222 const gfx::Rect after_restore = |
| 226 delegate->GetFrameCaptionButtonContainerViewBounds(); | 223 delegate->GetFrameCaptionButtonContainerViewBounds(); |
| 227 EXPECT_EQ(initial, after_restore); | 224 EXPECT_EQ(initial, after_restore); |
| 228 } | 225 } |
| 229 | 226 |
| 230 } // namespace ash | 227 } // namespace ash |
| OLD | NEW |