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

Side by Side Diff: ash/wm/window_positioner_unittest.cc

Issue 2886253002: mash: remove more shell/shelf WmWindow usage. (Closed)
Patch Set: Fix WmShelf::ForWindow. Created 3 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/wm/window_positioner.cc ('k') | ash/wm/window_positioning_utils.cc » ('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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/window_positioner.h" 5 #include "ash/wm/window_positioner.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "ash/scoped_root_window_for_new_windows.h" 9 #include "ash/scoped_root_window_for_new_windows.h"
10 #include "ash/shell.h" 10 #include "ash/shell.h"
(...skipping 12 matching lines...) Expand all
23 23
24 namespace ash { 24 namespace ash {
25 25
26 using WindowPositionerTest = test::AshTestBase; 26 using WindowPositionerTest = test::AshTestBase;
27 27
28 TEST_F(WindowPositionerTest, OpenMaximizedWindowOnSecondDisplay) { 28 TEST_F(WindowPositionerTest, OpenMaximizedWindowOnSecondDisplay) {
29 // Tests that for a screen that is narrower than kForceMaximizeWidthLimit 29 // Tests that for a screen that is narrower than kForceMaximizeWidthLimit
30 // a new window gets maximized. 30 // a new window gets maximized.
31 UpdateDisplay("400x400,500x500"); 31 UpdateDisplay("400x400,500x500");
32 ScopedRootWindowForNewWindows root_for_new_windows( 32 ScopedRootWindowForNewWindows root_for_new_windows(
33 ShellPort::Get()->GetAllRootWindows()[1]); 33 Shell::GetAllRootWindows()[1]);
34 shell::ToplevelWindow::CreateParams params; 34 shell::ToplevelWindow::CreateParams params;
35 params.can_resize = true; 35 params.can_resize = true;
36 params.can_maximize = true; 36 params.can_maximize = true;
37 views::Widget* widget = shell::ToplevelWindow::CreateToplevelWindow(params); 37 views::Widget* widget = shell::ToplevelWindow::CreateToplevelWindow(params);
38 EXPECT_EQ(gfx::Rect(400, 0, 500, 452).ToString(), 38 EXPECT_EQ(gfx::Rect(400, 0, 500, 452).ToString(),
39 widget->GetWindowBoundsInScreen().ToString()); 39 widget->GetWindowBoundsInScreen().ToString());
40 } 40 }
41 41
42 TEST_F(WindowPositionerTest, OpenDefaultWindowOnSecondDisplay) { 42 TEST_F(WindowPositionerTest, OpenDefaultWindowOnSecondDisplay) {
43 UpdateDisplay("400x400,1400x900"); 43 UpdateDisplay("400x400,1400x900");
44 WmWindow* second_root_window = ShellPort::Get()->GetAllRootWindows()[1]; 44 aura::Window* second_root_window = Shell::GetAllRootWindows()[1];
45 ScopedRootWindowForNewWindows root_for_new_windows(second_root_window); 45 ScopedRootWindowForNewWindows root_for_new_windows(second_root_window);
46 shell::ToplevelWindow::CreateParams params; 46 shell::ToplevelWindow::CreateParams params;
47 params.can_resize = true; 47 params.can_resize = true;
48 params.can_maximize = true; 48 params.can_maximize = true;
49 views::Widget* widget = shell::ToplevelWindow::CreateToplevelWindow(params); 49 views::Widget* widget = shell::ToplevelWindow::CreateToplevelWindow(params);
50 gfx::Rect bounds = widget->GetWindowBoundsInScreen(); 50 gfx::Rect bounds = widget->GetWindowBoundsInScreen();
51 51
52 // The window should be in the 2nd display with the default size. 52 // The window should be in the 2nd display with the default size.
53 EXPECT_EQ("300x300", bounds.size().ToString()); 53 EXPECT_EQ("300x300", bounds.size().ToString());
54 EXPECT_TRUE( 54 EXPECT_TRUE(display::Screen::GetScreen()
55 second_root_window->GetDisplayNearestWindow().bounds().Contains(bounds)); 55 ->GetDisplayNearestWindow(second_root_window)
56 .bounds()
57 .Contains(bounds));
56 } 58 }
57 59
58 // Tests that second window inherits first window's maximized state as well as 60 // Tests that second window inherits first window's maximized state as well as
59 // its restore bounds. 61 // its restore bounds.
60 TEST_F(WindowPositionerTest, SecondMaximizedWindowHasProperRestoreSize) { 62 TEST_F(WindowPositionerTest, SecondMaximizedWindowHasProperRestoreSize) {
61 UpdateDisplay("1400x900"); 63 UpdateDisplay("1400x900");
62 shell::ToplevelWindow::CreateParams params; 64 shell::ToplevelWindow::CreateParams params;
63 params.can_resize = true; 65 params.can_resize = true;
64 params.can_maximize = true; 66 params.can_maximize = true;
65 views::Widget* widget1 = shell::ToplevelWindow::CreateToplevelWindow(params); 67 views::Widget* widget1 = shell::ToplevelWindow::CreateToplevelWindow(params);
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 widget1->SetFullscreen(false); 204 widget1->SetFullscreen(false);
203 ASSERT_EQ("300x300", widget1->GetWindowBoundsInScreen().size().ToString()); 205 ASSERT_EQ("300x300", widget1->GetWindowBoundsInScreen().size().ToString());
204 206
205 // Closing 2nd widget triggers the rearrange logic but the 1st 207 // Closing 2nd widget triggers the rearrange logic but the 1st
206 // widget should stay in the current size. 208 // widget should stay in the current size.
207 widget2->CloseNow(); 209 widget2->CloseNow();
208 ASSERT_EQ("300x300", widget1->GetWindowBoundsInScreen().size().ToString()); 210 ASSERT_EQ("300x300", widget1->GetWindowBoundsInScreen().size().ToString());
209 } 211 }
210 212
211 } // namespace ash 213 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/window_positioner.cc ('k') | ash/wm/window_positioning_utils.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698