OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "ui/aura_shell/workspace/workspace.h" | 5 #include "ui/aura/aura_constants.h" |
6 #include "ui/aura_shell/workspace/workspace_manager.h" | |
7 #include "ui/aura/desktop.h" | 6 #include "ui/aura/desktop.h" |
8 #include "ui/aura/screen_aura.h" | 7 #include "ui/aura/screen_aura.h" |
9 #include "ui/aura/test/aura_test_base.h" | 8 #include "ui/aura/test/aura_test_base.h" |
10 #include "ui/aura/test/test_desktop_delegate.h" | 9 #include "ui/aura/test/test_desktop_delegate.h" |
11 #include "ui/aura/window.h" | 10 #include "ui/aura/window.h" |
| 11 #include "ui/aura_shell/workspace/workspace.h" |
| 12 #include "ui/aura_shell/workspace/workspace_manager.h" |
| 13 #include "ui/base/ui_base_types.h" |
12 | 14 |
13 using aura::Window; | 15 using aura::Window; |
14 | 16 |
15 namespace aura_shell { | 17 namespace aura_shell { |
16 namespace internal { | 18 namespace internal { |
17 | 19 |
18 class WorkspaceManagerTestBase : public aura::test::AuraTestBase { | 20 class WorkspaceManagerTestBase : public aura::test::AuraTestBase { |
19 public: | 21 public: |
20 WorkspaceManagerTestBase() {} | 22 WorkspaceManagerTestBase() {} |
21 virtual ~WorkspaceManagerTestBase() {} | 23 virtual ~WorkspaceManagerTestBase() {} |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 Workspace* ws1 = manager_->CreateWorkspace(); | 197 Workspace* ws1 = manager_->CreateWorkspace(); |
196 scoped_ptr<Window> w11(CreateTestWindow()); | 198 scoped_ptr<Window> w11(CreateTestWindow()); |
197 w11->SetBounds(gfx::Rect(0, 0, 100, 100)); | 199 w11->SetBounds(gfx::Rect(0, 0, 100, 100)); |
198 ws1->AddWindowAfter(w11.get(), NULL); | 200 ws1->AddWindowAfter(w11.get(), NULL); |
199 | 201 |
200 scoped_ptr<Window> w12(CreateTestWindow()); | 202 scoped_ptr<Window> w12(CreateTestWindow()); |
201 w12->SetBounds(gfx::Rect(0, 0, 100, 100)); | 203 w12->SetBounds(gfx::Rect(0, 0, 100, 100)); |
202 ws1->AddWindowAfter(w12.get(), NULL); | 204 ws1->AddWindowAfter(w12.get(), NULL); |
203 manager_->LayoutWorkspaces(); | 205 manager_->LayoutWorkspaces(); |
204 | 206 |
205 // Workspaces are 0-empt-145-w11-245-margin-265-365-500. | 207 // Workspaces are 0-<lmgn>-145-<w11>-245-<wmng>-255-<w12>-355-<rmgn>-500. |
206 EXPECT_EQ(NULL, manager_->FindRotateWindowForLocation(gfx::Point(0, 0))); | 208 EXPECT_EQ(NULL, manager_->FindRotateWindowForLocation(gfx::Point(0, 0))); |
207 EXPECT_EQ(NULL, manager_->FindRotateWindowForLocation(gfx::Point(100, 0))); | 209 EXPECT_EQ(NULL, manager_->FindRotateWindowForLocation(gfx::Point(100, 0))); |
208 EXPECT_EQ(w11.get(), | 210 EXPECT_EQ(w11.get(), |
209 manager_->FindRotateWindowForLocation(gfx::Point(150, 0))); | 211 manager_->FindRotateWindowForLocation(gfx::Point(150, 0))); |
210 EXPECT_EQ(w12.get(), | 212 EXPECT_EQ(w12.get(), |
211 manager_->FindRotateWindowForLocation(gfx::Point(300, 0))); | 213 manager_->FindRotateWindowForLocation(gfx::Point(300, 0))); |
212 EXPECT_EQ(NULL, manager_->FindRotateWindowForLocation(gfx::Point(400, 0))); | 214 EXPECT_EQ(NULL, manager_->FindRotateWindowForLocation(gfx::Point(400, 0))); |
213 | 215 |
| 216 |
| 217 // The following test does not pass due to crbug.com/102413. |
| 218 // TODO(oshima): Re-enable this once the bug is fixed. |
| 219 /* |
214 w11->SetBounds(gfx::Rect(0, 0, 400, 100)); | 220 w11->SetBounds(gfx::Rect(0, 0, 400, 100)); |
215 w12->SetBounds(gfx::Rect(0, 0, 200, 100)); | 221 w12->SetBounds(gfx::Rect(0, 0, 200, 100)); |
216 manager_->LayoutWorkspaces(); | 222 manager_->FindBy(w11.get())->Layout(NULL, NULL); |
217 EXPECT_EQ(w11.get(), | 223 EXPECT_EQ(w11.get(), |
218 manager_->FindRotateWindowForLocation(gfx::Point(10, 0))); | 224 manager_->FindRotateWindowForLocation(gfx::Point(10, 0))); |
219 EXPECT_EQ(w11.get(), | 225 EXPECT_EQ(w11.get(), |
220 manager_->FindRotateWindowForLocation(gfx::Point(240, 0))); | 226 manager_->FindRotateWindowForLocation(gfx::Point(240, 0))); |
221 EXPECT_EQ(w12.get(), | 227 EXPECT_EQ(w12.get(), |
222 manager_->FindRotateWindowForLocation(gfx::Point(260, 0))); | 228 manager_->FindRotateWindowForLocation(gfx::Point(260, 0))); |
223 EXPECT_EQ(w12.get(), | 229 EXPECT_EQ(w12.get(), |
224 manager_->FindRotateWindowForLocation(gfx::Point(490, 0))); | 230 manager_->FindRotateWindowForLocation(gfx::Point(490, 0))); |
| 231 */ |
225 | 232 |
226 Workspace* ws2 = manager_->CreateWorkspace(); | 233 Workspace* ws2 = manager_->CreateWorkspace(); |
227 scoped_ptr<Window> w21(CreateTestWindow()); | 234 scoped_ptr<Window> w21(CreateTestWindow()); |
228 w21->SetBounds(gfx::Rect(0, 0, 100, 100)); | 235 w21->SetBounds(gfx::Rect(0, 0, 100, 100)); |
229 ws2->AddWindowAfter(w21.get(), NULL); | 236 ws2->AddWindowAfter(w21.get(), NULL); |
230 manager_->LayoutWorkspaces(); | 237 manager_->LayoutWorkspaces(); |
231 | 238 |
232 // 2nd workspace starts from 500+50 and the window is centered 750-850. | 239 // 2nd workspace starts from 500+50 and the window is centered 750-850. |
233 EXPECT_EQ(NULL, manager_->FindRotateWindowForLocation(gfx::Point(600, 0))); | 240 EXPECT_EQ(NULL, manager_->FindRotateWindowForLocation(gfx::Point(600, 0))); |
234 EXPECT_EQ(NULL, manager_->FindRotateWindowForLocation(gfx::Point(740, 0))); | 241 EXPECT_EQ(NULL, manager_->FindRotateWindowForLocation(gfx::Point(740, 0))); |
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
493 Workspace::SHIFT_TO_LEFT); | 500 Workspace::SHIFT_TO_LEFT); |
494 EXPECT_EQ(w2.get(), overflow); | 501 EXPECT_EQ(w2.get(), overflow); |
495 EXPECT_EQ(-1, ws->GetIndexOf(w2.get())); | 502 EXPECT_EQ(-1, ws->GetIndexOf(w2.get())); |
496 EXPECT_EQ(0, ws->GetIndexOf(w1.get())); | 503 EXPECT_EQ(0, ws->GetIndexOf(w1.get())); |
497 EXPECT_EQ(1, ws->GetIndexOf(w3.get())); | 504 EXPECT_EQ(1, ws->GetIndexOf(w3.get())); |
498 | 505 |
499 // Reset now before windows are destroyed. | 506 // Reset now before windows are destroyed. |
500 manager_.reset(); | 507 manager_.reset(); |
501 } | 508 } |
502 | 509 |
| 510 TEST_F(WorkspaceTest, ContainsFullscreenWindow) { |
| 511 Workspace* ws = manager_->CreateWorkspace(); |
| 512 scoped_ptr<Window> w1(CreateTestWindow()); |
| 513 scoped_ptr<Window> w2(CreateTestWindow()); |
| 514 ws->AddWindowAfter(w1.get(), NULL); |
| 515 ws->AddWindowAfter(w2.get(), NULL); |
| 516 w1->Show(); |
| 517 w2->Show(); |
| 518 |
| 519 EXPECT_FALSE(ws->ContainsFullscreenWindow()); |
| 520 |
| 521 w1->SetIntProperty(aura::kShowStateKey, ui::SHOW_STATE_FULLSCREEN); |
| 522 EXPECT_TRUE(ws->ContainsFullscreenWindow()); |
| 523 |
| 524 w1->SetIntProperty(aura::kShowStateKey, ui::SHOW_STATE_NORMAL); |
| 525 EXPECT_FALSE(ws->ContainsFullscreenWindow()); |
| 526 |
| 527 w2->SetIntProperty(aura::kShowStateKey, ui::SHOW_STATE_FULLSCREEN); |
| 528 EXPECT_TRUE(ws->ContainsFullscreenWindow()); |
| 529 |
| 530 w2->Hide(); |
| 531 EXPECT_FALSE(ws->ContainsFullscreenWindow()); |
| 532 } |
| 533 |
503 } // namespace internal | 534 } // namespace internal |
504 } // namespace aura_shell | 535 } // namespace aura_shell |
OLD | NEW |