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

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

Issue 1743493002: Cleanup ash shelf accessor functions. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Revert ash/shelf/shelf_widget.cc for browser_tests crash... Created 4 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/wm/workspace/workspace_layout_manager.h" 5 #include "ash/wm/workspace/workspace_layout_manager.h"
6 6
7 #include <string> 7 #include <string>
8 #include <utility> 8 #include <utility>
9 9
10 #include "ash/display/display_layout.h" 10 #include "ash/display/display_layout.h"
11 #include "ash/display/display_manager.h" 11 #include "ash/display/display_manager.h"
12 #include "ash/root_window_controller.h" 12 #include "ash/root_window_controller.h"
13 #include "ash/screen_util.h" 13 #include "ash/screen_util.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_layout_manager.h" 16 #include "ash/shelf/shelf_layout_manager.h"
16 #include "ash/shell.h" 17 #include "ash/shell.h"
17 #include "ash/shell_observer.h" 18 #include "ash/shell_observer.h"
18 #include "ash/shell_window_ids.h" 19 #include "ash/shell_window_ids.h"
19 #include "ash/test/ash_test_base.h" 20 #include "ash/test/ash_test_base.h"
20 #include "ash/test/display_manager_test_api.h" 21 #include "ash/test/display_manager_test_api.h"
21 #include "ash/wm/maximize_mode/workspace_backdrop_delegate.h" 22 #include "ash/wm/maximize_mode/workspace_backdrop_delegate.h"
22 #include "ash/wm/window_state.h" 23 #include "ash/wm/window_state.h"
23 #include "ash/wm/window_util.h" 24 #include "ash/wm/window_util.h"
24 #include "ash/wm/wm_event.h" 25 #include "ash/wm/wm_event.h"
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 void OnWindowPropertyChanged(aura::Window* window, 309 void OnWindowPropertyChanged(aura::Window* window,
309 const void* key, 310 const void* key,
310 intptr_t old) override { 311 intptr_t old) override {
311 if (!window_) 312 if (!window_)
312 return; 313 return;
313 314
314 if (wm::GetWindowState(window)->IsMaximized()) { 315 if (wm::GetWindowState(window)->IsMaximized()) {
315 aura::Window* w = window_; 316 aura::Window* w = window_;
316 window_ = nullptr; 317 window_ = nullptr;
317 318
318 gfx::Rect shelf_bounds(Shell::GetPrimaryRootWindowController()-> 319 gfx::Rect shelf_bounds(
319 GetShelfLayoutManager()->GetIdealBounds()); 320 Shelf::ForPrimaryDisplay()->shelf_layout_manager()->GetIdealBounds());
320 const gfx::Rect& window_bounds(w->bounds()); 321 const gfx::Rect& window_bounds(w->bounds());
321 w->SetBounds(gfx::Rect(window_bounds.x(), shelf_bounds.y() - 1, 322 w->SetBounds(gfx::Rect(window_bounds.x(), shelf_bounds.y() - 1,
322 window_bounds.width(), window_bounds.height())); 323 window_bounds.width(), window_bounds.height()));
323 } 324 }
324 } 325 }
325 326
326 private: 327 private:
327 aura::Window* window_; 328 aura::Window* window_;
328 329
329 DISALLOW_COPY_AND_ASSIGN(DontClobberRestoreBoundsWindowObserver); 330 DISALLOW_COPY_AND_ASSIGN(DontClobberRestoreBoundsWindowObserver);
(...skipping 455 matching lines...) Expand 10 before | Expand all | Expand 10 after
785 } 786 }
786 787
787 // Verify if the window is not resized during screen lock. See: crbug.com/173127 788 // Verify if the window is not resized during screen lock. See: crbug.com/173127
788 TEST_F(WorkspaceLayoutManagerSoloTest, NotResizeWhenScreenIsLocked) { 789 TEST_F(WorkspaceLayoutManagerSoloTest, NotResizeWhenScreenIsLocked) {
789 SetCanLockScreen(true); 790 SetCanLockScreen(true);
790 scoped_ptr<aura::Window> window(CreateTestWindow(gfx::Rect(1, 2, 3, 4))); 791 scoped_ptr<aura::Window> window(CreateTestWindow(gfx::Rect(1, 2, 3, 4)));
791 // window with AlwaysOnTop will be managed by BaseLayoutManager. 792 // window with AlwaysOnTop will be managed by BaseLayoutManager.
792 window->SetProperty(aura::client::kAlwaysOnTopKey, true); 793 window->SetProperty(aura::client::kAlwaysOnTopKey, true);
793 window->Show(); 794 window->Show();
794 795
795 ShelfLayoutManager* shelf = ShelfLayoutManager::ForShelf(window.get()); 796 ShelfLayoutManager* shelf_layout_manager =
796 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); 797 Shelf::ForWindow(window.get())->shelf_layout_manager();
798 shelf_layout_manager->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
797 799
798 window->SetBounds(ScreenUtil::GetMaximizedWindowBoundsInParent(window.get())); 800 window->SetBounds(ScreenUtil::GetMaximizedWindowBoundsInParent(window.get()));
799 gfx::Rect window_bounds = window->bounds(); 801 gfx::Rect window_bounds = window->bounds();
800 EXPECT_EQ( 802 EXPECT_EQ(
801 ScreenUtil::GetMaximizedWindowBoundsInParent(window.get()).ToString(), 803 ScreenUtil::GetMaximizedWindowBoundsInParent(window.get()).ToString(),
802 window_bounds.ToString()); 804 window_bounds.ToString());
803 805
804 // The window size should not get touched while we are in lock screen. 806 // The window size should not get touched while we are in lock screen.
805 Shell::GetInstance()->session_state_delegate()->LockScreen(); 807 Shell::GetInstance()->session_state_delegate()->LockScreen();
806 shelf->UpdateVisibilityState(); 808 shelf_layout_manager->UpdateVisibilityState();
807 EXPECT_EQ(window_bounds.ToString(), window->bounds().ToString()); 809 EXPECT_EQ(window_bounds.ToString(), window->bounds().ToString());
808 810
809 // Coming out of the lock screen the window size should still remain. 811 // Coming out of the lock screen the window size should still remain.
810 Shell::GetInstance()->session_state_delegate()->UnlockScreen(); 812 Shell::GetInstance()->session_state_delegate()->UnlockScreen();
811 shelf->UpdateVisibilityState(); 813 shelf_layout_manager->UpdateVisibilityState();
812 EXPECT_EQ( 814 EXPECT_EQ(
813 ScreenUtil::GetMaximizedWindowBoundsInParent(window.get()).ToString(), 815 ScreenUtil::GetMaximizedWindowBoundsInParent(window.get()).ToString(),
814 window_bounds.ToString()); 816 window_bounds.ToString());
815 EXPECT_EQ(window_bounds.ToString(), window->bounds().ToString()); 817 EXPECT_EQ(window_bounds.ToString(), window->bounds().ToString());
816 } 818 }
817 819
818 // Following tests are written to test the backdrop functionality. 820 // Following tests are written to test the backdrop functionality.
819 821
820 namespace { 822 namespace {
821 823
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
977 window3.get())); 979 window3.get()));
978 ShowTopWindowBackdrop(false); 980 ShowTopWindowBackdrop(false);
979 EXPECT_EQ("b", GetWindowOrderAsString(nullptr, window1.get(), window2.get(), 981 EXPECT_EQ("b", GetWindowOrderAsString(nullptr, window1.get(), window2.get(),
980 window3.get())); 982 window3.get()));
981 } 983 }
982 984
983 // Tests that when hidding the shelf, that the backdrop resizes to fill the 985 // Tests that when hidding the shelf, that the backdrop resizes to fill the
984 // entire workspace area. 986 // entire workspace area.
985 TEST_F(WorkspaceLayoutManagerBackdropTest, ShelfVisibilityChangesBounds) { 987 TEST_F(WorkspaceLayoutManagerBackdropTest, ShelfVisibilityChangesBounds) {
986 ShelfLayoutManager* shelf_layout_manager = 988 ShelfLayoutManager* shelf_layout_manager =
987 Shell::GetPrimaryRootWindowController()->GetShelfLayoutManager(); 989 Shelf::ForPrimaryDisplay()->shelf_layout_manager();
988 ShowTopWindowBackdrop(true); 990 ShowTopWindowBackdrop(true);
989 RunAllPendingInMessageLoop(); 991 RunAllPendingInMessageLoop();
990 992
991 ASSERT_EQ(SHELF_VISIBLE, shelf_layout_manager->visibility_state()); 993 ASSERT_EQ(SHELF_VISIBLE, shelf_layout_manager->visibility_state());
992 gfx::Rect initial_bounds = default_container()->children()[0]->bounds(); 994 gfx::Rect initial_bounds = default_container()->children()[0]->bounds();
993 shelf_layout_manager->SetAutoHideBehavior(SHELF_AUTO_HIDE_ALWAYS_HIDDEN); 995 shelf_layout_manager->SetAutoHideBehavior(SHELF_AUTO_HIDE_ALWAYS_HIDDEN);
994 shelf_layout_manager->UpdateVisibilityState(); 996 shelf_layout_manager->UpdateVisibilityState();
995 997
996 // When the shelf is re-shown WorkspaceLayoutManager shrinks all children 998 // When the shelf is re-shown WorkspaceLayoutManager shrinks all children
997 // including the backdrop. 999 // including the backdrop.
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
1138 EXPECT_EQ(gfx::Rect(50, 1140 EXPECT_EQ(gfx::Rect(50,
1139 keyboard_bounds.y() - keyboard_bounds.height()/2, 1141 keyboard_bounds.y() - keyboard_bounds.height()/2,
1140 occluded_window_bounds.width(), 1142 occluded_window_bounds.width(),
1141 occluded_window_bounds.height()).ToString(), 1143 occluded_window_bounds.height()).ToString(),
1142 window->bounds().ToString()); 1144 window->bounds().ToString());
1143 HideKeyboard(); 1145 HideKeyboard();
1144 EXPECT_EQ(occluded_window_bounds.ToString(), window->bounds().ToString()); 1146 EXPECT_EQ(occluded_window_bounds.ToString(), window->bounds().ToString());
1145 } 1147 }
1146 1148
1147 } // namespace ash 1149 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/window_animations.cc ('k') | chrome/browser/chromeos/accessibility/accessibility_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698