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

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

Issue 1877543002: Revise the shelf alignment locking mechanism. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update and cleanup tests. Created 4 years, 8 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_layout_manager.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"
11 #include "ash/display/window_tree_host_manager.h" 11 #include "ash/display/window_tree_host_manager.h"
12 #include "ash/focus_cycler.h" 12 #include "ash/focus_cycler.h"
13 #include "ash/root_window_controller.h" 13 #include "ash/root_window_controller.h"
14 #include "ash/session/session_state_delegate.h" 14 #include "ash/session/session_state_delegate.h"
15 #include "ash/shelf/shelf.h" 15 #include "ash/shelf/shelf.h"
16 #include "ash/shelf/shelf_layout_manager_observer.h" 16 #include "ash/shelf/shelf_layout_manager_observer.h"
17 #include "ash/shelf/shelf_locking_manager.h"
17 #include "ash/shelf/shelf_view.h" 18 #include "ash/shelf/shelf_view.h"
18 #include "ash/shelf/shelf_widget.h" 19 #include "ash/shelf/shelf_widget.h"
19 #include "ash/shell.h" 20 #include "ash/shell.h"
20 #include "ash/shell_window_ids.h" 21 #include "ash/shell_window_ids.h"
21 #include "ash/system/status_area_widget.h" 22 #include "ash/system/status_area_widget.h"
22 #include "ash/system/tray/system_tray.h" 23 #include "ash/system/tray/system_tray.h"
23 #include "ash/system/tray/system_tray_item.h" 24 #include "ash/system/tray/system_tray_item.h"
24 #include "ash/test/ash_test_base.h" 25 #include "ash/test/ash_test_base.h"
25 #include "ash/test/display_manager_test_api.h" 26 #include "ash/test/display_manager_test_api.h"
26 #include "ash/test/shelf_test_api.h" 27 #include "ash/test/shelf_test_api.h"
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after
374 // Turn off the lock screen. 375 // Turn off the lock screen.
375 void UnlockScreen() { 376 void UnlockScreen() {
376 Shell::GetInstance()->session_state_delegate()->UnlockScreen(); 377 Shell::GetInstance()->session_state_delegate()->UnlockScreen();
377 // The test session state delegate does not fire the lock state change. 378 // The test session state delegate does not fire the lock state change.
378 Shell::GetInstance()->OnLockStateChanged(false); 379 Shell::GetInstance()->OnLockStateChanged(false);
379 } 380 }
380 381
381 // Open the add user screen if |show| is true, otherwise end it. 382 // Open the add user screen if |show| is true, otherwise end it.
382 void ShowAddUserScreen(bool show) { 383 void ShowAddUserScreen(bool show) {
383 SetUserAddingScreenRunning(show); 384 SetUserAddingScreenRunning(show);
384 ShelfLayoutManager* manager = GetShelfWidget()->shelf_layout_manager(); 385
385 manager->SessionStateChanged( 386 const SessionStateDelegate::SessionState state =
386 show ? SessionStateDelegate::SESSION_STATE_LOGIN_SECONDARY : 387 show ? SessionStateDelegate::SESSION_STATE_LOGIN_SECONDARY
387 SessionStateDelegate::SESSION_STATE_ACTIVE); 388 : SessionStateDelegate::SESSION_STATE_ACTIVE;
389 GetShelfWidget()->shelf_layout_manager()->SessionStateChanged(state);
390 test::ShelfTestAPI(GetShelfWidget()->shelf())
391 .shelf_locking_manager()
392 ->SessionStateChanged(state);
388 } 393 }
389 394
390 private: 395 private:
391 DISALLOW_COPY_AND_ASSIGN(ShelfLayoutManagerTest); 396 DISALLOW_COPY_AND_ASSIGN(ShelfLayoutManagerTest);
392 }; 397 };
393 398
394 void ShelfLayoutManagerTest::RunGestureDragTests(gfx::Vector2d delta) { 399 void ShelfLayoutManagerTest::RunGestureDragTests(gfx::Vector2d delta) {
395 ShelfLayoutManager* shelf = GetShelfLayoutManager(); 400 ShelfLayoutManager* shelf = GetShelfLayoutManager();
396 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); 401 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER);
397 views::Widget* widget = new views::Widget; 402 views::Widget* widget = new views::Widget;
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after
757 EXPECT_LT(status_bounds.y(), 762 EXPECT_LT(status_bounds.y(),
758 screen->GetPrimaryDisplay().bounds().bottom()); 763 screen->GetPrimaryDisplay().bounds().bottom());
759 } 764 }
760 765
761 // Makes sure shelf alignment is correct for lock screen. 766 // Makes sure shelf alignment is correct for lock screen.
762 TEST_F(ShelfLayoutManagerTest, SideAlignmentInteractionWithLockScreen) { 767 TEST_F(ShelfLayoutManagerTest, SideAlignmentInteractionWithLockScreen) {
763 ShelfLayoutManager* manager = GetShelfWidget()->shelf_layout_manager(); 768 ShelfLayoutManager* manager = GetShelfWidget()->shelf_layout_manager();
764 manager->SetAlignment(SHELF_ALIGNMENT_LEFT); 769 manager->SetAlignment(SHELF_ALIGNMENT_LEFT);
765 EXPECT_EQ(SHELF_ALIGNMENT_LEFT, manager->GetAlignment()); 770 EXPECT_EQ(SHELF_ALIGNMENT_LEFT, manager->GetAlignment());
766 LockScreen(); 771 LockScreen();
767 EXPECT_EQ(SHELF_ALIGNMENT_BOTTOM, manager->GetAlignment()); 772 EXPECT_EQ(SHELF_ALIGNMENT_BOTTOM_LOCKED, manager->GetAlignment());
768 UnlockScreen(); 773 UnlockScreen();
769 EXPECT_EQ(SHELF_ALIGNMENT_LEFT, manager->GetAlignment()); 774 EXPECT_EQ(SHELF_ALIGNMENT_LEFT, manager->GetAlignment());
770 } 775 }
771 776
772 // Makes sure shelf alignment is correct for add user screen. 777 // Makes sure shelf alignment is correct for add user screen.
773 TEST_F(ShelfLayoutManagerTest, SideAlignmentInteractionWithAddUserScreen) { 778 TEST_F(ShelfLayoutManagerTest, SideAlignmentInteractionWithAddUserScreen) {
774 ShelfLayoutManager* manager = GetShelfWidget()->shelf_layout_manager(); 779 ShelfLayoutManager* manager = GetShelfWidget()->shelf_layout_manager();
775 manager->SetAlignment(SHELF_ALIGNMENT_LEFT); 780 manager->SetAlignment(SHELF_ALIGNMENT_LEFT);
776 EXPECT_EQ(SHELF_ALIGNMENT_LEFT, manager->GetAlignment()); 781 EXPECT_EQ(SHELF_ALIGNMENT_LEFT, manager->GetAlignment());
777 ShowAddUserScreen(true); 782 ShowAddUserScreen(true);
778 EXPECT_EQ(SHELF_ALIGNMENT_BOTTOM, manager->GetAlignment()); 783 EXPECT_EQ(SHELF_ALIGNMENT_BOTTOM_LOCKED, manager->GetAlignment());
779 ShowAddUserScreen(false); 784 ShowAddUserScreen(false);
780 EXPECT_EQ(SHELF_ALIGNMENT_LEFT, manager->GetAlignment()); 785 EXPECT_EQ(SHELF_ALIGNMENT_LEFT, manager->GetAlignment());
781 } 786 }
782 787
783 // Makes sure shelf alignment is correct for login screen. 788 // Makes sure shelf alignment is correct for login screen.
784 TEST_F(ShelfLayoutManagerTest, SideAlignmentInteractionWithLoginScreen) { 789 TEST_F(ShelfLayoutManagerTest, SideAlignmentInteractionWithLoginScreen) {
785 ShelfLayoutManager* manager = GetShelfWidget()->shelf_layout_manager(); 790 ShelfLayoutManager* manager = GetShelfWidget()->shelf_layout_manager();
786 ASSERT_EQ(SHELF_ALIGNMENT_BOTTOM, manager->GetAlignment()); 791 ASSERT_EQ(SHELF_ALIGNMENT_BOTTOM, manager->GetAlignment());
787 SetUserLoggedIn(false); 792 SetUserLoggedIn(false);
788 SetSessionStarted(false); 793 SetSessionStarted(false);
(...skipping 1543 matching lines...) Expand 10 before | Expand all | Expand 10 after
2332 StatusAreaWidget* status_area_widget = 2337 StatusAreaWidget* status_area_widget =
2333 Shell::GetPrimaryRootWindowController()->shelf()->status_area_widget(); 2338 Shell::GetPrimaryRootWindowController()->shelf()->status_area_widget();
2334 EXPECT_TRUE(status_area_widget->IsVisible()); 2339 EXPECT_TRUE(status_area_widget->IsVisible());
2335 // Shelf should be in the first display's area. 2340 // Shelf should be in the first display's area.
2336 gfx::Rect status_area_bounds(status_area_widget->GetWindowBoundsInScreen()); 2341 gfx::Rect status_area_bounds(status_area_widget->GetWindowBoundsInScreen());
2337 EXPECT_TRUE(gfx::Rect(0, 0, 500, 400).Contains(status_area_bounds)); 2342 EXPECT_TRUE(gfx::Rect(0, 0, 500, 400).Contains(status_area_bounds));
2338 EXPECT_EQ(gfx::Point(500, 400), status_area_bounds.bottom_right()); 2343 EXPECT_EQ(gfx::Point(500, 400), status_area_bounds.bottom_right());
2339 } 2344 }
2340 2345
2341 } // namespace ash 2346 } // namespace ash
OLDNEW
« no previous file with comments | « ash/shelf/shelf_layout_manager.cc ('k') | ash/shelf/shelf_locking_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698