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

Side by Side Diff: ash/shelf/shelf_layout_manager_unittest.cc

Issue 909293002: Properly set ShelfAlignment during login (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/shelf/shelf_layout_manager.h" 5 #include "ash/shelf/shelf_layout_manager.h"
6 6
7 #include "ash/accelerators/accelerator_controller.h" 7 #include "ash/accelerators/accelerator_controller.h"
8 #include "ash/accelerators/accelerator_table.h" 8 #include "ash/accelerators/accelerator_table.h"
9 #include "ash/ash_switches.h" 9 #include "ash/ash_switches.h"
10 #include "ash/display/display_controller.h" 10 #include "ash/display/display_controller.h"
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after
373 373
374 // Turn off the lock screen. 374 // Turn off the lock screen.
375 void UnlockScreen() { 375 void UnlockScreen() {
376 Shell::GetInstance()->session_state_delegate()->UnlockScreen(); 376 Shell::GetInstance()->session_state_delegate()->UnlockScreen();
377 // The test session state delegate does not fire the lock state change. 377 // The test session state delegate does not fire the lock state change.
378 Shell::GetInstance()->OnLockStateChanged(false); 378 Shell::GetInstance()->OnLockStateChanged(false);
379 } 379 }
380 380
381 // Open the add user screen if |show| is true, otherwise end it. 381 // Open the add user screen if |show| is true, otherwise end it.
382 void ShowAddUserScreen(bool show) { 382 void ShowAddUserScreen(bool show) {
383 SetUserAddingScreenRunning(show);
383 ShelfLayoutManager* manager = GetShelfWidget()->shelf_layout_manager(); 384 ShelfLayoutManager* manager = GetShelfWidget()->shelf_layout_manager();
384 manager->SessionStateChanged( 385 manager->SessionStateChanged(
385 show ? SessionStateDelegate::SESSION_STATE_LOGIN_SECONDARY : 386 show ? SessionStateDelegate::SESSION_STATE_LOGIN_SECONDARY :
386 SessionStateDelegate::SESSION_STATE_ACTIVE); 387 SessionStateDelegate::SESSION_STATE_ACTIVE);
387 } 388 }
388 389
389 private: 390 private:
390 DISALLOW_COPY_AND_ASSIGN(ShelfLayoutManagerTest); 391 DISALLOW_COPY_AND_ASSIGN(ShelfLayoutManagerTest);
391 }; 392 };
392 393
(...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after
772 TEST_F(ShelfLayoutManagerTest, SideAlignmentInteractionWithAddUserScreen) { 773 TEST_F(ShelfLayoutManagerTest, SideAlignmentInteractionWithAddUserScreen) {
773 ShelfLayoutManager* manager = GetShelfWidget()->shelf_layout_manager(); 774 ShelfLayoutManager* manager = GetShelfWidget()->shelf_layout_manager();
774 manager->SetAlignment(SHELF_ALIGNMENT_LEFT); 775 manager->SetAlignment(SHELF_ALIGNMENT_LEFT);
775 EXPECT_EQ(SHELF_ALIGNMENT_LEFT, manager->GetAlignment()); 776 EXPECT_EQ(SHELF_ALIGNMENT_LEFT, manager->GetAlignment());
776 ShowAddUserScreen(true); 777 ShowAddUserScreen(true);
777 EXPECT_EQ(SHELF_ALIGNMENT_BOTTOM, manager->GetAlignment()); 778 EXPECT_EQ(SHELF_ALIGNMENT_BOTTOM, manager->GetAlignment());
778 ShowAddUserScreen(false); 779 ShowAddUserScreen(false);
779 EXPECT_EQ(SHELF_ALIGNMENT_LEFT, manager->GetAlignment()); 780 EXPECT_EQ(SHELF_ALIGNMENT_LEFT, manager->GetAlignment());
780 } 781 }
781 782
783 // Makes sure shelf alignment is correct for login screen.
784 TEST_F(ShelfLayoutManagerTest, SideAlignmentInteractionWithLoginScreen) {
785 ShelfLayoutManager* manager = GetShelfWidget()->shelf_layout_manager();
786 ASSERT_EQ(SHELF_ALIGNMENT_BOTTOM, manager->GetAlignment());
787 SetUserLoggedIn(false);
788 SetSessionStarted(false);
789
790 // The test session state delegate does not fire state changes.
791 SetSessionStarting();
792 manager->SessionStateChanged(
793 Shell::GetInstance()->session_state_delegate()->GetSessionState());
794
795 // Login sets alignment preferences before the session completes startup.
796 manager->SetAlignment(SHELF_ALIGNMENT_LEFT);
797 SetUserLoggedIn(true);
798 SetSessionStarted(true);
799
800 EXPECT_EQ(SHELF_ALIGNMENT_LEFT, manager->GetAlignment());
801 // Ensure that the shelf has been notified.
802 EXPECT_EQ(SHELF_ALIGNMENT_LEFT, GetShelfWidget()->shelf()->alignment());
803 }
804
782 // Makes sure LayoutShelf invoked while animating cleans things up. 805 // Makes sure LayoutShelf invoked while animating cleans things up.
783 TEST_F(ShelfLayoutManagerTest, LayoutShelfWhileAnimating) { 806 TEST_F(ShelfLayoutManagerTest, LayoutShelfWhileAnimating) {
784 ShelfWidget* shelf = GetShelfWidget(); 807 ShelfWidget* shelf = GetShelfWidget();
785 // Force an initial layout. 808 // Force an initial layout.
786 shelf->shelf_layout_manager()->LayoutShelf(); 809 shelf->shelf_layout_manager()->LayoutShelf();
787 EXPECT_EQ(SHELF_VISIBLE, shelf->shelf_layout_manager()->visibility_state()); 810 EXPECT_EQ(SHELF_VISIBLE, shelf->shelf_layout_manager()->visibility_state());
788 811
789 // Hide the shelf. 812 // Hide the shelf.
790 SetState(shelf->shelf_layout_manager(), SHELF_HIDDEN); 813 SetState(shelf->shelf_layout_manager(), SHELF_HIDDEN);
791 shelf->shelf_layout_manager()->LayoutShelf(); 814 shelf->shelf_layout_manager()->LayoutShelf();
(...skipping 1368 matching lines...) Expand 10 before | Expand all | Expand 10 after
2160 shelf_manager->SetAutoHideBehavior(SHELF_AUTO_HIDE_ALWAYS_HIDDEN); 2183 shelf_manager->SetAutoHideBehavior(SHELF_AUTO_HIDE_ALWAYS_HIDDEN);
2161 gfx::Rect hide_target_bounds = status_window->GetTargetBounds(); 2184 gfx::Rect hide_target_bounds = status_window->GetTargetBounds();
2162 EXPECT_GT(hide_target_bounds.y(), initial_bounds.y()); 2185 EXPECT_GT(hide_target_bounds.y(), initial_bounds.y());
2163 2186
2164 shelf_manager->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); 2187 shelf_manager->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER);
2165 gfx::Rect reshow_target_bounds = status_window->GetTargetBounds(); 2188 gfx::Rect reshow_target_bounds = status_window->GetTargetBounds();
2166 EXPECT_EQ(initial_bounds, reshow_target_bounds); 2189 EXPECT_EQ(initial_bounds, reshow_target_bounds);
2167 } 2190 }
2168 2191
2169 } // namespace ash 2192 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698