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

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

Issue 1926823003: (Merge to M-51) Fix Chrome OS shelf locking for chromebook lid open/close. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2704
Patch Set: Created 4 years, 7 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
« no previous file with comments | « ash/shelf/shelf.cc ('k') | ash/shelf/shelf_locking_manager.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 (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_manager.h" 10 #include "ash/display/display_manager.h"
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after
371 Shell::GetInstance()->OnLockStateChanged(true); 371 Shell::GetInstance()->OnLockStateChanged(true);
372 } 372 }
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.
382 void ShowAddUserScreen(bool show) {
383 SetUserAddingScreenRunning(show);
384
385 const SessionStateDelegate::SessionState state =
386 show ? SessionStateDelegate::SESSION_STATE_LOGIN_SECONDARY
387 : SessionStateDelegate::SESSION_STATE_ACTIVE;
388 GetShelfWidget()->shelf_layout_manager()->SessionStateChanged(state);
389 test::ShelfTestAPI(GetShelfWidget()->shelf())
390 .shelf_locking_manager()
391 ->SessionStateChanged(state);
392 }
393
394 private: 381 private:
395 DISALLOW_COPY_AND_ASSIGN(ShelfLayoutManagerTest); 382 DISALLOW_COPY_AND_ASSIGN(ShelfLayoutManagerTest);
396 }; 383 };
397 384
398 void ShelfLayoutManagerTest::RunGestureDragTests(gfx::Vector2d delta) { 385 void ShelfLayoutManagerTest::RunGestureDragTests(gfx::Vector2d delta) {
399 ShelfLayoutManager* shelf = GetShelfLayoutManager(); 386 ShelfLayoutManager* shelf = GetShelfLayoutManager();
400 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); 387 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER);
401 views::Widget* widget = new views::Widget; 388 views::Widget* widget = new views::Widget;
402 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); 389 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW);
403 params.bounds = gfx::Rect(0, 0, 200, 200); 390 params.bounds = gfx::Rect(0, 0, 200, 200);
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after
755 EXPECT_EQ(shelf_height, display.GetWorkAreaInsets().bottom()); 742 EXPECT_EQ(shelf_height, display.GetWorkAreaInsets().bottom());
756 743
757 // Make sure the bounds of the two widgets changed. 744 // Make sure the bounds of the two widgets changed.
758 shelf_bounds = shelf->GetNativeView()->bounds(); 745 shelf_bounds = shelf->GetNativeView()->bounds();
759 EXPECT_LT(shelf_bounds.y(), screen->GetPrimaryDisplay().bounds().bottom()); 746 EXPECT_LT(shelf_bounds.y(), screen->GetPrimaryDisplay().bounds().bottom());
760 status_bounds = shelf->status_area_widget()->GetNativeView()->bounds(); 747 status_bounds = shelf->status_area_widget()->GetNativeView()->bounds();
761 EXPECT_LT(status_bounds.y(), 748 EXPECT_LT(status_bounds.y(),
762 screen->GetPrimaryDisplay().bounds().bottom()); 749 screen->GetPrimaryDisplay().bounds().bottom());
763 } 750 }
764 751
765 // Makes sure shelf alignment is correct for lock screen.
766 TEST_F(ShelfLayoutManagerTest, SideAlignmentInteractionWithLockScreen) {
767 ShelfLayoutManager* manager = GetShelfWidget()->shelf_layout_manager();
768 manager->SetAlignment(SHELF_ALIGNMENT_LEFT);
769 EXPECT_EQ(SHELF_ALIGNMENT_LEFT, manager->GetAlignment());
770 LockScreen();
771 EXPECT_EQ(SHELF_ALIGNMENT_BOTTOM_LOCKED, manager->GetAlignment());
772 UnlockScreen();
773 EXPECT_EQ(SHELF_ALIGNMENT_LEFT, manager->GetAlignment());
774 }
775
776 // Makes sure shelf alignment is correct for add user screen.
777 TEST_F(ShelfLayoutManagerTest, SideAlignmentInteractionWithAddUserScreen) {
778 ShelfLayoutManager* manager = GetShelfWidget()->shelf_layout_manager();
779 manager->SetAlignment(SHELF_ALIGNMENT_LEFT);
780 EXPECT_EQ(SHELF_ALIGNMENT_LEFT, manager->GetAlignment());
781 ShowAddUserScreen(true);
782 EXPECT_EQ(SHELF_ALIGNMENT_BOTTOM_LOCKED, manager->GetAlignment());
783 ShowAddUserScreen(false);
784 EXPECT_EQ(SHELF_ALIGNMENT_LEFT, manager->GetAlignment());
785 }
786
787 // Makes sure shelf alignment is correct for login screen.
788 TEST_F(ShelfLayoutManagerTest, SideAlignmentInteractionWithLoginScreen) {
789 ShelfLayoutManager* manager = GetShelfWidget()->shelf_layout_manager();
790 ASSERT_EQ(SHELF_ALIGNMENT_BOTTOM, manager->GetAlignment());
791 SetUserLoggedIn(false);
792 SetSessionStarted(false);
793
794 // The test session state delegate does not fire state changes.
795 SetSessionStarting();
796 manager->SessionStateChanged(
797 Shell::GetInstance()->session_state_delegate()->GetSessionState());
798
799 // Login sets alignment preferences before the session completes startup.
800 manager->SetAlignment(SHELF_ALIGNMENT_LEFT);
801 SetUserLoggedIn(true);
802 SetSessionStarted(true);
803
804 EXPECT_EQ(SHELF_ALIGNMENT_LEFT, manager->GetAlignment());
805 // Ensure that the shelf has been notified.
806 EXPECT_EQ(SHELF_ALIGNMENT_LEFT, GetShelfWidget()->shelf()->alignment());
807 }
808
809 // Makes sure LayoutShelf invoked while animating cleans things up. 752 // Makes sure LayoutShelf invoked while animating cleans things up.
810 TEST_F(ShelfLayoutManagerTest, LayoutShelfWhileAnimating) { 753 TEST_F(ShelfLayoutManagerTest, LayoutShelfWhileAnimating) {
811 ShelfWidget* shelf = GetShelfWidget(); 754 ShelfWidget* shelf = GetShelfWidget();
812 // Force an initial layout. 755 // Force an initial layout.
813 shelf->shelf_layout_manager()->LayoutShelf(); 756 shelf->shelf_layout_manager()->LayoutShelf();
814 EXPECT_EQ(SHELF_VISIBLE, shelf->shelf_layout_manager()->visibility_state()); 757 EXPECT_EQ(SHELF_VISIBLE, shelf->shelf_layout_manager()->visibility_state());
815 758
816 // Hide the shelf. 759 // Hide the shelf.
817 SetState(shelf->shelf_layout_manager(), SHELF_HIDDEN); 760 SetState(shelf->shelf_layout_manager(), SHELF_HIDDEN);
818 shelf->shelf_layout_manager()->LayoutShelf(); 761 shelf->shelf_layout_manager()->LayoutShelf();
(...skipping 1517 matching lines...) Expand 10 before | Expand all | Expand 10 after
2336 StatusAreaWidget* status_area_widget = 2279 StatusAreaWidget* status_area_widget =
2337 Shell::GetPrimaryRootWindowController()->shelf()->status_area_widget(); 2280 Shell::GetPrimaryRootWindowController()->shelf()->status_area_widget();
2338 EXPECT_TRUE(status_area_widget->IsVisible()); 2281 EXPECT_TRUE(status_area_widget->IsVisible());
2339 // Shelf should be in the first display's area. 2282 // Shelf should be in the first display's area.
2340 gfx::Rect status_area_bounds(status_area_widget->GetWindowBoundsInScreen()); 2283 gfx::Rect status_area_bounds(status_area_widget->GetWindowBoundsInScreen());
2341 EXPECT_TRUE(gfx::Rect(0, 0, 500, 400).Contains(status_area_bounds)); 2284 EXPECT_TRUE(gfx::Rect(0, 0, 500, 400).Contains(status_area_bounds));
2342 EXPECT_EQ(gfx::Point(500, 400), status_area_bounds.bottom_right()); 2285 EXPECT_EQ(gfx::Point(500, 400), status_area_bounds.bottom_right());
2343 } 2286 }
2344 2287
2345 } // namespace ash 2288 } // namespace ash
OLDNEW
« no previous file with comments | « ash/shelf/shelf.cc ('k') | ash/shelf/shelf_locking_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698