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

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

Issue 55303006: Make sure the non browser/non app widget is fully visible when created on ash (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « ash/wm/window_positioner.cc ('k') | ash/wm/window_state.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 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 "ash/shell.h" 7 #include "ash/shell.h"
8 #include "ash/shell/toplevel_window.h" 8 #include "ash/shell/toplevel_window.h"
9 #include "ash/test/ash_test_base.h" 9 #include "ash/test/ash_test_base.h"
10 #include "ash/wm/window_state.h" 10 #include "ash/wm/window_state.h"
11 #include "ui/aura/root_window.h" 11 #include "ui/aura/root_window.h"
12 #include "ui/gfx/screen.h" 12 #include "ui/gfx/screen.h"
13 #include "ui/views/widget/widget.h" 13 #include "ui/views/widget/widget.h"
14 #include "ui/views/widget/widget_delegate.h"
14 15
15 namespace ash { 16 namespace ash {
16 17
17 typedef test::AshTestBase WindowPositionerTest; 18 typedef test::AshTestBase WindowPositionerTest;
18 19
19 TEST_F(WindowPositionerTest, OpenMaximizedWindowOnSecondDisplay) { 20 TEST_F(WindowPositionerTest, OpenMaximizedWindowOnSecondDisplay) {
20 if (!SupportsMultipleDisplays()) 21 if (!SupportsMultipleDisplays())
21 return; 22 return;
22 UpdateDisplay("400x400,500x500"); 23 UpdateDisplay("400x400,500x500");
23 Shell::GetInstance()->set_target_root_window( 24 Shell::GetInstance()->set_target_root_window(
(...skipping 18 matching lines...) Expand all
42 params.can_maximize = true; 43 params.can_maximize = true;
43 views::Widget* widget = 44 views::Widget* widget =
44 shell::ToplevelWindow::CreateToplevelWindow(params); 45 shell::ToplevelWindow::CreateToplevelWindow(params);
45 gfx::Rect bounds = widget->GetWindowBoundsInScreen(); 46 gfx::Rect bounds = widget->GetWindowBoundsInScreen();
46 // The window should be in the 2nd display with the default size. 47 // The window should be in the 2nd display with the default size.
47 EXPECT_EQ("300x300", bounds.size().ToString()); 48 EXPECT_EQ("300x300", bounds.size().ToString());
48 EXPECT_TRUE(Shell::GetScreen()->GetDisplayNearestWindow( 49 EXPECT_TRUE(Shell::GetScreen()->GetDisplayNearestWindow(
49 second_root_window).bounds().Contains(bounds)); 50 second_root_window).bounds().Contains(bounds));
50 } 51 }
51 52
53 namespace {
54
55 // A WidgetDelegate that returns the out of display saved bounds.
56 class OutOfDisplayDelegate : public views::WidgetDelegate {
57 public:
58 explicit OutOfDisplayDelegate(views::Widget* widget) : widget_(widget) {}
59 virtual ~OutOfDisplayDelegate() {}
60
61 // Overridden from WidgetDelegate:
62 virtual void DeleteDelegate() OVERRIDE {
63 delete this;
64 }
65 virtual views::Widget* GetWidget() OVERRIDE {
66 return widget_;
67 }
68 virtual const views::Widget* GetWidget() const OVERRIDE {
69 return widget_;
70 }
71 virtual bool GetSavedWindowPlacement(
72 const views::Widget* widget,
73 gfx::Rect* bounds,
74 ui::WindowShowState* show_state) const OVERRIDE {
75 bounds->SetRect(450, 10, 100, 100);
76 *show_state = ui::SHOW_STATE_NORMAL;
77 return true;
78 }
79
80 private:
81 views::Widget* widget_;
82
83 DISALLOW_COPY_AND_ASSIGN(OutOfDisplayDelegate);
84 };
85
52 } // namespace 86 } // namespace
87
88 TEST_F(WindowPositionerTest, EnsureMinimumVisibility) {
89 UpdateDisplay("400x400");
90 views::Widget* widget = new views::Widget();
91 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW);
92 params.delegate = new OutOfDisplayDelegate(widget);
93 params.context = Shell::GetPrimaryRootWindow();
94 widget->Init(params);
95 widget->SetBounds(gfx::Rect(450,10, 100, 100));
96 wm::GetWindowState(widget->GetNativeView())->set_minimum_visibility(true);
97 widget->Show();
98 // Make sure the bounds is adjusted to be inside the work area.
99 EXPECT_EQ("390,10 100x100", widget->GetWindowBoundsInScreen().ToString());
100 widget->CloseNow();
101 }
102
103 } // namespace
OLDNEW
« no previous file with comments | « ash/wm/window_positioner.cc ('k') | ash/wm/window_state.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698