OLD | NEW |
---|---|
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 Loading... | |
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 // Get the current bounds | |
oshima
2014/10/23 01:05:46
nit: you don't need this comment as it's obvious
afakhry
2014/10/24 02:09:45
Acknowledged.
| |
125 const gfx::Size old_bounds1 = w1->GetTargetBounds().size(); | |
126 const gfx::Size old_bounds2 = w2->GetTargetBounds().size(); | |
127 const gfx::Size old_bounds3 = w3->GetTargetBounds().size(); | |
128 | |
129 // Get the screen bounds | |
oshima
2014/10/23 01:05:46
ditto
afakhry
2014/10/24 02:09:45
Acknowledged.
| |
130 const gfx::Size work_area = | |
131 gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().work_area().size(); | |
132 | |
133 // Enter the overview mode and select window 1 (has a max size). | |
oshima
2014/10/23 01:05:46
This is probably simpler.
// Select w1 which has
afakhry
2014/10/24 02:09:45
Acknowledged.
| |
134 WindowManager::Get()->EnterOverview(); | |
135 WindowOverviewModeDelegate* overview_delegate = wm_api.wm(); | |
136 overview_delegate->OnSelectWindow(w1.get()); | |
137 | |
138 // Test that the window was not maximized | |
oshima
2014/10/23 01:05:46
and remove this comment.
afakhry
2014/10/24 02:09:45
Acknowledged.
| |
139 const gfx::Size new_bounds1 = w1->GetTargetBounds().size(); | |
140 EXPECT_EQ(new_bounds1, old_bounds1); | |
141 EXPECT_NE(work_area, new_bounds1); | |
oshima
2014/10/23 01:05:46
can you check using string (ToString)? That'll giv
afakhry
2014/10/24 02:09:45
Acknowledged.
| |
142 | |
143 // Enter the overview mode and select window 2 (has no max size & can be | |
144 // maximized). | |
oshima
2014/10/23 01:05:46
ditto
afakhry
2014/10/24 02:09:45
Acknowledged.
| |
145 WindowManager::Get()->EnterOverview(); | |
146 overview_delegate->OnSelectWindow(w2.get()); | |
147 | |
148 // Test that the window was actually maximized. | |
149 const gfx::Size new_bounds2 = w2->GetTargetBounds().size(); | |
150 EXPECT_NE(new_bounds2, old_bounds2); | |
151 EXPECT_EQ(work_area, new_bounds2); | |
152 | |
153 // Enter the overview mode and select window 3 (has no max size but cannot be | |
154 // maximized). | |
oshima
2014/10/23 01:05:46
ditto
afakhry
2014/10/24 02:09:45
Acknowledged.
| |
155 WindowManager::Get()->EnterOverview(); | |
156 overview_delegate->OnSelectWindow(w3.get()); | |
157 | |
158 // Test that the window was not maximized | |
159 const gfx::Size new_bounds3 = w3->GetTargetBounds().size(); | |
160 EXPECT_EQ(new_bounds3, old_bounds3); | |
161 EXPECT_NE(work_area, new_bounds3); | |
162 } | |
163 | |
102 TEST_F(WindowManagerTest, NewWindowFromOverview) { | 164 TEST_F(WindowManagerTest, NewWindowFromOverview) { |
103 aura::test::TestWindowDelegate delegate; | 165 aura::test::TestWindowDelegate delegate; |
104 scoped_ptr<aura::Window> w1(CreateAndActivateWindow(&delegate)); | 166 scoped_ptr<aura::Window> w1(CreateAndActivateWindow(&delegate)); |
105 scoped_ptr<aura::Window> w2(CreateAndActivateWindow(&delegate)); | 167 scoped_ptr<aura::Window> w2(CreateAndActivateWindow(&delegate)); |
106 | 168 |
107 WindowManager::Get()->EnterOverview(); | 169 WindowManager::Get()->EnterOverview(); |
108 EXPECT_TRUE(w1->IsVisible()); | 170 EXPECT_TRUE(w1->IsVisible()); |
109 EXPECT_TRUE(w2->IsVisible()); | 171 EXPECT_TRUE(w2->IsVisible()); |
110 | 172 |
111 // Test that opening a new window exits overview mode. The new window could | 173 // Test that opening a new window exits overview mode. The new window could |
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
385 aura::test::TestWindowDelegate delegate; | 447 aura::test::TestWindowDelegate delegate; |
386 scoped_ptr<aura::Window> w1(CreateAndActivateWindow(&delegate)); | 448 scoped_ptr<aura::Window> w1(CreateAndActivateWindow(&delegate)); |
387 WindowManager::Get()->EnterOverview(); | 449 WindowManager::Get()->EnterOverview(); |
388 | 450 |
389 ui::test::EventGenerator generator(root_window()); | 451 ui::test::EventGenerator generator(root_window()); |
390 generator.MoveMouseTo(1, 1); | 452 generator.MoveMouseTo(1, 1); |
391 generator.ClickLeftButton(); | 453 generator.ClickLeftButton(); |
392 } | 454 } |
393 | 455 |
394 } // namespace athena | 456 } // namespace athena |
OLD | NEW |