Index: ash/frame/custom_frame_view_ash_unittest.cc |
diff --git a/ash/frame/custom_frame_view_ash_unittest.cc b/ash/frame/custom_frame_view_ash_unittest.cc |
index 014f586bcd37f55763ef4da1bd3a0915011314f5..cb97b1edee2284e6903b337da3c046b75ba9b946 100644 |
--- a/ash/frame/custom_frame_view_ash_unittest.cc |
+++ b/ash/frame/custom_frame_view_ash_unittest.cc |
@@ -4,7 +4,9 @@ |
#include "ash/frame/custom_frame_view_ash.h" |
+#include "ash/shell.h" |
#include "ash/test/ash_test_base.h" |
+#include "ash/test/test_session_state_delegate.h" |
#include "base/memory/scoped_ptr.h" |
#include "grit/ash_resources.h" |
#include "ui/base/resource/resource_bundle.h" |
@@ -97,6 +99,11 @@ class CustomFrameViewAshTest : public test::AshTestBase { |
return widget.Pass(); |
} |
+ test::TestSessionStateDelegate* GetTestSessionStateDelegate() { |
+ return static_cast<ash::test::TestSessionStateDelegate*>( |
+ Shell::GetInstance()->session_state_delegate()); |
+ } |
+ |
private: |
DISALLOW_COPY_AND_ASSIGN(CustomFrameViewAshTest); |
}; |
@@ -168,4 +175,29 @@ TEST_F(CustomFrameViewAshTest, MinimumAndMaximumSize) { |
max_frame_size.height()); |
} |
+// Verify that CustomFrameViewAsh updates the avatar icon based on the |
+// state of the SessionStateDelegate after visibility change. |
+TEST_F(CustomFrameViewAshTest, AvatarIcon) { |
+ TestWidgetConstraintsDelegate* delegate = new TestWidgetConstraintsDelegate; |
+ scoped_ptr<views::Widget> widget(CreateWidget(delegate)); |
+ |
+ CustomFrameViewAsh* custom_frame_view = delegate->custom_frame_view(); |
+ EXPECT_FALSE(custom_frame_view->GetAvatarIconViewForTest()); |
+ |
+ // Avatar icon becomes available. |
+ const gfx::ImageSkia user_image = |
+ *ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed( |
+ IDR_AURA_UBER_TRAY_GUEST_ICON); |
+ GetTestSessionStateDelegate()->SetUserImage(user_image); |
+ widget->Hide(); |
+ widget->Show(); |
+ EXPECT_TRUE(custom_frame_view->GetAvatarIconViewForTest()); |
+ |
+ // Avatar icon is gone, so is the avatar icon. |
+ GetTestSessionStateDelegate()->SetUserImage(gfx::ImageSkia()); |
+ widget->Hide(); |
+ widget->Show(); |
+ EXPECT_FALSE(custom_frame_view->GetAvatarIconViewForTest()); |
+} |
+ |
} // namespace ash |