Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(99)

Side by Side Diff: ash/frame/custom_frame_view_ash_unittest.cc

Issue 200483004: Show avatar icon on V2 app's frame (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ash/frame/custom_frame_view_ash.cc ('k') | ash/frame/default_header_painter.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 gfx::Size max_frame_size = custom_frame_view->GetMaximumSize(); 158 gfx::Size max_frame_size = custom_frame_view->GetMaximumSize();
152 159
153 EXPECT_EQ(min_client_size.width(), min_frame_size.width()); 160 EXPECT_EQ(min_client_size.width(), min_frame_size.width());
154 EXPECT_EQ(max_client_size.width(), max_frame_size.width()); 161 EXPECT_EQ(max_client_size.width(), max_frame_size.width());
155 EXPECT_EQ(min_client_size.height() + delegate->GetTitleBarHeight(), 162 EXPECT_EQ(min_client_size.height() + delegate->GetTitleBarHeight(),
156 min_frame_size.height()); 163 min_frame_size.height());
157 EXPECT_EQ(max_client_size.height() + delegate->GetTitleBarHeight(), 164 EXPECT_EQ(max_client_size.height() + delegate->GetTitleBarHeight(),
158 max_frame_size.height()); 165 max_frame_size.height());
159 } 166 }
160 167
168 // Verify that CustomFrameViewAsh updates the avatar icon based on the
169 // state of the SessionStateDelegate after visibility change.
170 TEST_F(CustomFrameViewAshTest, AvatarIcon) {
171 TestWidgetConstraintsDelegate* delegate = new TestWidgetConstraintsDelegate;
172 scoped_ptr<views::Widget> widget(CreateWidget(delegate));
173
174 CustomFrameViewAsh* custom_frame_view = delegate->custom_frame_view();
175 EXPECT_FALSE(custom_frame_view->GetAvatarIconViewForTest());
176
177 // Avatar image becomes available.
178 const gfx::ImageSkia user_image =
179 *ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed(
180 IDR_AURA_UBER_TRAY_GUEST_ICON);
181 GetTestSessionStateDelegate()->SetUserImage(user_image);
182 widget->Hide();
183 widget->Show();
184 EXPECT_TRUE(custom_frame_view->GetAvatarIconViewForTest());
185
186 // Avatar image is gone; the ImageView for the avatar icon should be
187 // removed.
188 GetTestSessionStateDelegate()->SetUserImage(gfx::ImageSkia());
189 widget->Hide();
190 widget->Show();
191 EXPECT_FALSE(custom_frame_view->GetAvatarIconViewForTest());
192 }
193
161 } // namespace ash 194 } // namespace ash
OLDNEW
« no previous file with comments | « ash/frame/custom_frame_view_ash.cc ('k') | ash/frame/default_header_painter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698