Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / ash / system / overview / overview_button_tray_unittest.cc
index 201fd1d..bc3fd69 100644 (file)
@@ -10,7 +10,9 @@
 #include "ash/shelf/shelf_widget.h"
 #include "ash/shell.h"
 #include "ash/system/status_area_widget.h"
+#include "ash/system/user/login_status.h"
 #include "ash/test/ash_test_base.h"
+#include "ash/test/status_area_widget_test_helper.h"
 #include "ash/wm/overview/window_selector_controller.h"
 #include "base/time/time.h"
 #include "ui/events/event.h"
@@ -23,23 +25,13 @@ namespace ash {
 namespace {
 
 OverviewButtonTray* GetTray() {
-  return Shell::GetPrimaryRootWindowController()->shelf()->
-      status_area_widget()->overview_button_tray();
+  return StatusAreaWidgetTestHelper::GetStatusAreaWidget()->
+      overview_button_tray();
 }
 
 OverviewButtonTray* GetSecondaryTray() {
-  internal::RootWindowController* primary_controller =
-      Shell::GetPrimaryRootWindowController();
-  Shell::RootWindowControllerList controllers =
-      Shell::GetAllRootWindowControllers();
-  for (size_t i = 0; i < controllers.size(); ++i) {
-    if (controllers[i] != primary_controller) {
-      return controllers[i]->shelf()->
-          status_area_widget()->overview_button_tray();
-    }
-  }
-
-  return NULL;
+  return StatusAreaWidgetTestHelper::GetSecondaryStatusAreaWidget()->
+      overview_button_tray();
 }
 
 }  // namespace
@@ -118,4 +110,18 @@ TEST_F(OverviewButtonTrayTest, SecondaryTrayCreatedVisible) {
   Shell::GetInstance()->EnableMaximizeModeWindowManager(false);
 }
 
+// Tests that the tray loses visibility when a user logs out, and that it
+// regains visibility when a user logs back in.
+TEST_F(OverviewButtonTrayTest, VisibilityChangesForLoginStatus) {
+  Shell::GetInstance()->EnableMaximizeModeWindowManager(true);
+  SetUserLoggedIn(false);
+  Shell::GetInstance()->UpdateAfterLoginStatusChange(user::LOGGED_IN_NONE);
+  EXPECT_FALSE(GetTray()->visible());
+  SetUserLoggedIn(true);
+  SetSessionStarted(true);
+  Shell::GetInstance()->UpdateAfterLoginStatusChange(user::LOGGED_IN_USER);
+  EXPECT_TRUE(GetTray()->visible());
+  Shell::GetInstance()->EnableMaximizeModeWindowManager(false);
+}
+
 }  // namespace ash