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

Side by Side Diff: ash/common/wm/workspace/workspace_layout_manager_unittest.cc

Issue 2734933004: ash: Use SessionController instead of SessionStateDelegate (Closed)
Patch Set: rebase Created 3 years, 9 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/common/wm/workspace/workspace_layout_manager.h" 5 #include "ash/common/wm/workspace/workspace_layout_manager.h"
6 6
7 #include <memory>
7 #include <string> 8 #include <string>
8 #include <utility> 9 #include <utility>
9 10
10 #include "ash/common/session/session_state_delegate.h" 11 #include "ash/common/session/session_controller.h"
11 #include "ash/common/shelf/shelf_constants.h" 12 #include "ash/common/shelf/shelf_constants.h"
12 #include "ash/common/shelf/shelf_layout_manager.h" 13 #include "ash/common/shelf/shelf_layout_manager.h"
13 #include "ash/common/shelf/wm_shelf.h" 14 #include "ash/common/shelf/wm_shelf.h"
14 #include "ash/common/shell_observer.h" 15 #include "ash/common/shell_observer.h"
15 #include "ash/common/test/ash_test.h" 16 #include "ash/common/test/ash_test.h"
16 #include "ash/common/test/test_session_state_delegate.h" 17 #include "ash/common/test/test_session_controller_client.h"
17 #include "ash/common/wm/fullscreen_window_finder.h" 18 #include "ash/common/wm/fullscreen_window_finder.h"
18 #include "ash/common/wm/maximize_mode/workspace_backdrop_delegate.h" 19 #include "ash/common/wm/maximize_mode/workspace_backdrop_delegate.h"
19 #include "ash/common/wm/window_state.h" 20 #include "ash/common/wm/window_state.h"
20 #include "ash/common/wm/wm_event.h" 21 #include "ash/common/wm/wm_event.h"
21 #include "ash/common/wm/wm_screen_util.h" 22 #include "ash/common/wm/wm_screen_util.h"
22 #include "ash/common/wm/workspace/workspace_window_resizer.h" 23 #include "ash/common/wm/workspace/workspace_window_resizer.h"
23 #include "ash/common/wm_shell.h" 24 #include "ash/common/wm_shell.h"
24 #include "ash/common/wm_window.h" 25 #include "ash/common/wm_window.h"
25 #include "ash/public/cpp/shell_window_ids.h" 26 #include "ash/public/cpp/shell_window_ids.h"
26 #include "ash/root_window_controller.h" 27 #include "ash/root_window_controller.h"
27 #include "ash/shell.h" 28 #include "ash/shell.h"
28 #include "ash/wm/window_state_aura.h" 29 #include "ash/wm/window_state_aura.h"
29 #include "base/command_line.h" 30 #include "base/command_line.h"
31 #include "base/memory/ptr_util.h"
30 #include "base/run_loop.h" 32 #include "base/run_loop.h"
31 #include "ui/aura/env.h" 33 #include "ui/aura/env.h"
32 #include "ui/aura/window.h" 34 #include "ui/aura/window.h"
33 #include "ui/base/ui_base_switches.h" 35 #include "ui/base/ui_base_switches.h"
34 #include "ui/base/ui_base_types.h" 36 #include "ui/base/ui_base_types.h"
35 #include "ui/compositor/layer_type.h" 37 #include "ui/compositor/layer_type.h"
36 #include "ui/compositor/scoped_animation_duration_scale_mode.h" 38 #include "ui/compositor/scoped_animation_duration_scale_mode.h"
37 #include "ui/display/display.h" 39 #include "ui/display/display.h"
38 #include "ui/display/screen.h" 40 #include "ui/display/screen.h"
39 #include "ui/gfx/geometry/insets.h" 41 #include "ui/gfx/geometry/insets.h"
(...skipping 849 matching lines...) Expand 10 before | Expand all | Expand 10 after
889 EXPECT_EQ(bounds.ToString(), 891 EXPECT_EQ(bounds.ToString(),
890 window_state->GetRestoreBoundsInParent().ToString()); 892 window_state->GetRestoreBoundsInParent().ToString());
891 EXPECT_TRUE(window_state->IsMaximized()); 893 EXPECT_TRUE(window_state->IsMaximized());
892 894
893 window_state->Restore(); 895 window_state->Restore();
894 EXPECT_EQ(bounds.ToString(), window->GetBounds().ToString()); 896 EXPECT_EQ(bounds.ToString(), window->GetBounds().ToString());
895 } 897 }
896 898
897 // Verify if the window is not resized during screen lock. See: crbug.com/173127 899 // Verify if the window is not resized during screen lock. See: crbug.com/173127
898 TEST_F(WorkspaceLayoutManagerSoloTest, NotResizeWhenScreenIsLocked) { 900 TEST_F(WorkspaceLayoutManagerSoloTest, NotResizeWhenScreenIsLocked) {
899 test::TestSessionStateDelegate::SetCanLockScreen(true); 901 std::unique_ptr<test::TestSessionControllerClient> session_controller_client =
xiyuan 2017/03/17 07:08:15 Creating a new TestSessionControllerClient because
James Cook 2017/03/17 17:14:36 Could this test be switched to use AshTestBase? We
xiyuan 2017/03/17 22:52:02 That works in both ash_unittests and mash_unittest
James Cook 2017/03/18 18:40:05 Sounds good. I'm pretty sure we run tests based on
902 base::MakeUnique<test::TestSessionControllerClient>(
903 WmShell::Get()->session_controller());
904 session_controller_client->InitializeAndBind();
905 session_controller_client->SetCanLockScreen(true);
900 std::unique_ptr<WindowOwner> window_owner( 906 std::unique_ptr<WindowOwner> window_owner(
901 CreateTestWindow(gfx::Rect(1, 2, 3, 4))); 907 CreateTestWindow(gfx::Rect(1, 2, 3, 4)));
902 WmWindow* window = window_owner->window(); 908 WmWindow* window = window_owner->window();
903 // window with AlwaysOnTop will be managed by BaseLayoutManager. 909 // window with AlwaysOnTop will be managed by BaseLayoutManager.
904 window->SetAlwaysOnTop(true); 910 window->SetAlwaysOnTop(true);
905 window->Show(); 911 window->Show();
906 912
907 WmShelf* shelf = GetPrimaryShelf(); 913 WmShelf* shelf = GetPrimaryShelf();
908 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); 914 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
909 915
910 window->SetBounds(wm::GetMaximizedWindowBoundsInParent(window)); 916 window->SetBounds(wm::GetMaximizedWindowBoundsInParent(window));
911 gfx::Rect window_bounds = window->GetBounds(); 917 gfx::Rect window_bounds = window->GetBounds();
912 EXPECT_EQ(wm::GetMaximizedWindowBoundsInParent(window).ToString(), 918 EXPECT_EQ(wm::GetMaximizedWindowBoundsInParent(window).ToString(),
913 window_bounds.ToString()); 919 window_bounds.ToString());
914 920
915 // The window size should not get touched while we are in lock screen. 921 // The window size should not get touched while we are in lock screen.
916 WmShell::Get()->GetSessionStateDelegate()->LockScreen(); 922 WmShell::Get()->session_controller()->LockScreenAndFlushForTest();
917 ShelfLayoutManager* shelf_layout_manager = shelf->shelf_layout_manager(); 923 ShelfLayoutManager* shelf_layout_manager = shelf->shelf_layout_manager();
918 shelf_layout_manager->UpdateVisibilityState(); 924 shelf_layout_manager->UpdateVisibilityState();
919 EXPECT_EQ(window_bounds.ToString(), window->GetBounds().ToString()); 925 EXPECT_EQ(window_bounds.ToString(), window->GetBounds().ToString());
920 926
921 // Coming out of the lock screen the window size should still remain. 927 // Coming out of the lock screen the window size should still remain.
922 WmShell::Get()->GetSessionStateDelegate()->UnlockScreen(); 928 session_controller_client->UnlockScreen();
923 shelf_layout_manager->UpdateVisibilityState(); 929 shelf_layout_manager->UpdateVisibilityState();
924 EXPECT_EQ(wm::GetMaximizedWindowBoundsInParent(window).ToString(), 930 EXPECT_EQ(wm::GetMaximizedWindowBoundsInParent(window).ToString(),
925 window_bounds.ToString()); 931 window_bounds.ToString());
926 EXPECT_EQ(window_bounds.ToString(), window->GetBounds().ToString()); 932 EXPECT_EQ(window_bounds.ToString(), window->GetBounds().ToString());
927 } 933 }
928 934
929 // Following tests are written to test the backdrop functionality. 935 // Following tests are written to test the backdrop functionality.
930 936
931 namespace { 937 namespace {
932 938
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after
1265 window->SetBounds(keyboard_bounds()); 1271 window->SetBounds(keyboard_bounds());
1266 window->GetWindowState()->set_ignore_keyboard_bounds_change(true); 1272 window->GetWindowState()->set_ignore_keyboard_bounds_change(true);
1267 window->Activate(); 1273 window->Activate();
1268 1274
1269 EXPECT_EQ(keyboard_bounds(), window->GetBounds()); 1275 EXPECT_EQ(keyboard_bounds(), window->GetBounds());
1270 ShowKeyboard(); 1276 ShowKeyboard();
1271 EXPECT_EQ(keyboard_bounds(), window->GetBounds()); 1277 EXPECT_EQ(keyboard_bounds(), window->GetBounds());
1272 } 1278 }
1273 1279
1274 } // namespace ash 1280 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698