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

Side by Side Diff: athena/wm/window_manager_unittest.cc

Issue 668513003: Selecting an app window from the overview mode maximizes the window only if it's maximizable (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Acknowledging the code review and fixing other relevant bugs related to the fix and split mode. Created 6 years, 2 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "athena/wm/public/window_manager.h" 5 #include "athena/wm/public/window_manager.h"
6 6
7 #include "athena/screen/public/screen_manager.h" 7 #include "athena/screen/public/screen_manager.h"
8 #include "athena/test/base/athena_test_base.h" 8 #include "athena/test/base/athena_test_base.h"
9 #include "athena/wm/public/window_list_provider.h" 9 #include "athena/wm/public/window_list_provider.h"
10 #include "athena/wm/split_view_controller.h" 10 #include "athena/wm/split_view_controller.h"
11 #include "athena/wm/test/window_manager_impl_test_api.h" 11 #include "athena/wm/test/window_manager_impl_test_api.h"
12 #include "athena/wm/window_manager_impl.h" 12 #include "athena/wm/window_manager_impl.h"
13 #include "ui/aura/client/aura_constants.h"
13 #include "ui/aura/client/window_tree_client.h" 14 #include "ui/aura/client/window_tree_client.h"
14 #include "ui/aura/test/test_window_delegate.h" 15 #include "ui/aura/test/test_window_delegate.h"
15 #include "ui/aura/window.h" 16 #include "ui/aura/window.h"
16 #include "ui/base/hit_test.h" 17 #include "ui/base/hit_test.h"
17 #include "ui/events/test/event_generator.h" 18 #include "ui/events/test/event_generator.h"
18 #include "ui/gfx/display.h" 19 #include "ui/gfx/display.h"
19 #include "ui/gfx/screen.h" 20 #include "ui/gfx/screen.h"
20 #include "ui/wm/core/window_util.h" 21 #include "ui/wm/core/window_util.h"
21 22
22 namespace athena { 23 namespace athena {
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 EXPECT_TRUE(w3->IsVisible()); 93 EXPECT_TRUE(w3->IsVisible());
93 94
94 // Go into split-view mode. 95 // Go into split-view mode.
95 WindowOverviewModeDelegate* overview_delegate = wm_api.wm(); 96 WindowOverviewModeDelegate* overview_delegate = wm_api.wm();
96 overview_delegate->OnSelectSplitViewWindow(w3.get(), NULL, w3.get()); 97 overview_delegate->OnSelectSplitViewWindow(w3.get(), NULL, w3.get());
97 EXPECT_TRUE(w3->IsVisible()); 98 EXPECT_TRUE(w3->IsVisible());
98 EXPECT_TRUE(w2->IsVisible()); 99 EXPECT_TRUE(w2->IsVisible());
99 EXPECT_FALSE(w1->IsVisible()); 100 EXPECT_FALSE(w1->IsVisible());
100 } 101 }
101 102
103 TEST_F(WindowManagerTest, OnSelectWindow) {
104 test::WindowManagerImplTestApi wm_api;
105 aura::test::TestWindowDelegate delegate1;
106 aura::test::TestWindowDelegate delegate2;
107 aura::test::TestWindowDelegate delegate3;
108
109 // (w1): A window that sets a maximum size
110 delegate1.set_maximum_size(gfx::Size(300, 200));
111 scoped_ptr<aura::Window> w1(CreateAndActivateWindow(&delegate1));
112 w1->SetBounds(gfx::Rect(0, 0, 300, 200));
113
114 // (w2): A window that doesn't set a max size and is maximizable
115 scoped_ptr<aura::Window> w2(CreateAndActivateWindow(&delegate2));
116 w2->SetBounds(gfx::Rect(0, 0, 300, 200));
117 w2->SetProperty(aura::client::kCanMaximizeKey, true);
118
119 // (w3): A window that doesn't set a max size but is NOT maximizable
120 scoped_ptr<aura::Window> w3(CreateAndActivateWindow(&delegate3));
121 w3->SetBounds(gfx::Rect(0, 0, 300, 200));
122 w3->SetProperty(aura::client::kCanMaximizeKey, false);
123
124 const gfx::Size old_bounds1 = w1->GetTargetBounds().size();
125 const gfx::Size old_bounds2 = w2->GetTargetBounds().size();
126 const gfx::Size old_bounds3 = w3->GetTargetBounds().size();
127 const gfx::Size work_area =
128 gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().work_area().size();
129
130 // Select w1, which has a max size, in the overview mode and make sure it's
131 // not maximized.
132 WindowManager::Get()->EnterOverview();
133 WindowOverviewModeDelegate* overview_delegate = wm_api.wm();
134 overview_delegate->OnSelectWindow(w1.get());
135 const gfx::Size new_bounds1 = w1->GetTargetBounds().size();
136 EXPECT_EQ(new_bounds1.ToString(), old_bounds1.ToString());
137 EXPECT_NE(work_area.ToString(), new_bounds1.ToString());
138
139 // Select w2, which has no max size & can be maximized, in the overview
140 // mode and make sure it's actually maximized.
141 WindowManager::Get()->EnterOverview();
142 overview_delegate->OnSelectWindow(w2.get());
143 const gfx::Size new_bounds2 = w2->GetTargetBounds().size();
144 EXPECT_NE(new_bounds2.ToString(), old_bounds2.ToString());
145 EXPECT_EQ(work_area.ToString(), new_bounds2.ToString());
146
147 // Select w3, which has no max size & cannot be maximized, in the overview
148 // mode and make sure it's not maximized.
149 WindowManager::Get()->EnterOverview();
150 overview_delegate->OnSelectWindow(w3.get());
151 const gfx::Size new_bounds3 = w3->GetTargetBounds().size();
152 EXPECT_EQ(new_bounds3.ToString(), old_bounds3.ToString());
153 EXPECT_NE(work_area.ToString(), new_bounds3.ToString());
154 }
155
102 TEST_F(WindowManagerTest, NewWindowFromOverview) { 156 TEST_F(WindowManagerTest, NewWindowFromOverview) {
103 aura::test::TestWindowDelegate delegate; 157 aura::test::TestWindowDelegate delegate;
104 scoped_ptr<aura::Window> w1(CreateAndActivateWindow(&delegate)); 158 scoped_ptr<aura::Window> w1(CreateAndActivateWindow(&delegate));
105 scoped_ptr<aura::Window> w2(CreateAndActivateWindow(&delegate)); 159 scoped_ptr<aura::Window> w2(CreateAndActivateWindow(&delegate));
106 160
107 WindowManager::Get()->EnterOverview(); 161 WindowManager::Get()->EnterOverview();
108 EXPECT_TRUE(w1->IsVisible()); 162 EXPECT_TRUE(w1->IsVisible());
109 EXPECT_TRUE(w2->IsVisible()); 163 EXPECT_TRUE(w2->IsVisible());
110 164
111 // Test that opening a new window exits overview mode. The new window could 165 // Test that opening a new window exits overview mode. The new window could
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
343 int width = 397 int width =
344 gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().work_area().width(); 398 gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().work_area().width();
345 399
346 EXPECT_EQ(w1->bounds().width(), w2->bounds().width()); 400 EXPECT_EQ(w1->bounds().width(), w2->bounds().width());
347 EXPECT_GE(width / 2, w1->bounds().width()); 401 EXPECT_GE(width / 2, w1->bounds().width());
348 402
349 // Toggle back to normal mode. 403 // Toggle back to normal mode.
350 wm_api.wm()->ToggleSplitView(); 404 wm_api.wm()->ToggleSplitView();
351 EXPECT_FALSE(wm_api.GetSplitViewController()->IsSplitViewModeActive()); 405 EXPECT_FALSE(wm_api.GetSplitViewController()->IsSplitViewModeActive());
352 406
353 EXPECT_EQ(width, w1->bounds().width()); 407 // w2 is the top window, it should be resized to max width and must be visible
408 // w1 should be hidden.
354 EXPECT_EQ(width, w2->bounds().width()); 409 EXPECT_EQ(width, w2->bounds().width());
410 EXPECT_TRUE(w2->IsVisible());
411 EXPECT_FALSE(w1->IsVisible());
oshima 2014/10/24 18:39:56 can you activate w1 and check if it's properly res
afakhry 2014/10/25 00:35:08 Done.
355 } 412 }
356 413
357 TEST_F(WindowManagerTest, OverviewModeFromSplitMode) { 414 TEST_F(WindowManagerTest, OverviewModeFromSplitMode) {
358 test::WindowManagerImplTestApi wm_api; 415 test::WindowManagerImplTestApi wm_api;
359 416
360 aura::test::TestWindowDelegate delegate; 417 aura::test::TestWindowDelegate delegate;
361 scoped_ptr<aura::Window> w1(CreateAndActivateWindow(&delegate)); 418 scoped_ptr<aura::Window> w1(CreateAndActivateWindow(&delegate));
362 scoped_ptr<aura::Window> w2(CreateAndActivateWindow(&delegate)); 419 scoped_ptr<aura::Window> w2(CreateAndActivateWindow(&delegate));
363 scoped_ptr<aura::Window> w3(CreateAndActivateWindow(&delegate)); 420 scoped_ptr<aura::Window> w3(CreateAndActivateWindow(&delegate));
364 421
(...skipping 20 matching lines...) Expand all
385 aura::test::TestWindowDelegate delegate; 442 aura::test::TestWindowDelegate delegate;
386 scoped_ptr<aura::Window> w1(CreateAndActivateWindow(&delegate)); 443 scoped_ptr<aura::Window> w1(CreateAndActivateWindow(&delegate));
387 WindowManager::Get()->EnterOverview(); 444 WindowManager::Get()->EnterOverview();
388 445
389 ui::test::EventGenerator generator(root_window()); 446 ui::test::EventGenerator generator(root_window());
390 generator.MoveMouseTo(1, 1); 447 generator.MoveMouseTo(1, 1);
391 generator.ClickLeftButton(); 448 generator.ClickLeftButton();
392 } 449 }
393 450
394 } // namespace athena 451 } // namespace athena
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698