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_manager.h" | 5 #include "ui/aura_shell/workspace/workspace_manager.h" |
6 #include "ui/aura_shell/workspace/workspace.h" | 6 #include "ui/aura_shell/workspace/workspace.h" |
7 | 7 |
8 #include "ui/aura/test/aura_test_base.h" | 8 #include "ui/aura/test/aura_test_base.h" |
9 #include "ui/aura/test/test_desktop_delegate.h" | 9 #include "ui/aura/test/test_desktop_delegate.h" |
10 #include "ui/aura/desktop.h" | 10 #include "ui/aura/desktop.h" |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 | 154 |
155 // Activate ws2. | 155 // Activate ws2. |
156 ws2->Activate(); | 156 ws2->Activate(); |
157 EXPECT_EQ(ws2, manager.GetActiveWorkspace()); | 157 EXPECT_EQ(ws2, manager.GetActiveWorkspace()); |
158 | 158 |
159 // Deleting active workspace sets active workspace to NULL. | 159 // Deleting active workspace sets active workspace to NULL. |
160 delete ws2; | 160 delete ws2; |
161 EXPECT_EQ(NULL, manager.GetActiveWorkspace()); | 161 EXPECT_EQ(NULL, manager.GetActiveWorkspace()); |
162 } | 162 } |
163 | 163 |
| 164 TEST_F(WorkspaceManagerTest, FindSwapWindow) { |
| 165 WorkspaceManager manager(viewport()); |
| 166 manager.workspace_size_ = gfx::Size(500, 300); |
| 167 |
| 168 Workspace* ws1 = manager.CreateWorkspace(); |
| 169 scoped_ptr<Window> w11(CreateTestWindow()); |
| 170 w11->SetBounds(gfx::Rect(0, 0, 100, 100)); |
| 171 ws1->AddWindowAfter(w11.get(), NULL); |
| 172 |
| 173 scoped_ptr<Window> w12(CreateTestWindow()); |
| 174 w12->SetBounds(gfx::Rect(0, 0, 100, 100)); |
| 175 ws1->AddWindowAfter(w12.get(), NULL); |
| 176 manager.LayoutWorkspaces(); |
| 177 |
| 178 // Workspaces are 0-empt-145-w11-245-margin-265-365-500. |
| 179 EXPECT_EQ(NULL, manager.FindSwapWindowForLocation(gfx::Point(0, 0))); |
| 180 EXPECT_EQ(NULL, manager.FindSwapWindowForLocation(gfx::Point(100, 0))); |
| 181 EXPECT_EQ(w11.get(), manager.FindSwapWindowForLocation(gfx::Point(150, 0))); |
| 182 EXPECT_EQ(w12.get(), manager.FindSwapWindowForLocation(gfx::Point(300, 0))); |
| 183 EXPECT_EQ(NULL, manager.FindSwapWindowForLocation(gfx::Point(400, 0))); |
| 184 |
| 185 w11->SetBounds(gfx::Rect(0, 0, 400, 100)); |
| 186 w12->SetBounds(gfx::Rect(0, 0, 200, 100)); |
| 187 manager.LayoutWorkspaces(); |
| 188 EXPECT_EQ(w11.get(), manager.FindSwapWindowForLocation(gfx::Point(10, 0))); |
| 189 EXPECT_EQ(w11.get(), manager.FindSwapWindowForLocation(gfx::Point(240, 0))); |
| 190 EXPECT_EQ(w12.get(), manager.FindSwapWindowForLocation(gfx::Point(260, 0))); |
| 191 EXPECT_EQ(w12.get(), manager.FindSwapWindowForLocation(gfx::Point(490, 0))); |
| 192 |
| 193 Workspace* ws2 = manager.CreateWorkspace(); |
| 194 scoped_ptr<Window> w21(CreateTestWindow()); |
| 195 w21->SetBounds(gfx::Rect(0, 0, 100, 100)); |
| 196 ws2->AddWindowAfter(w21.get(), NULL); |
| 197 manager.LayoutWorkspaces(); |
| 198 |
| 199 // 2nd workspace starts from 500+50 and the window is centered 750-850. |
| 200 EXPECT_EQ(NULL, manager.FindSwapWindowForLocation(gfx::Point(600, 0))); |
| 201 EXPECT_EQ(NULL, manager.FindSwapWindowForLocation(gfx::Point(740, 0))); |
| 202 EXPECT_EQ(w21.get(), manager.FindSwapWindowForLocation(gfx::Point(760, 0))); |
| 203 EXPECT_EQ(w21.get(), manager.FindSwapWindowForLocation(gfx::Point(840, 0))); |
| 204 EXPECT_EQ(NULL, manager.FindSwapWindowForLocation(gfx::Point(860, 0))); |
| 205 } |
| 206 |
164 class WorkspaceTest : public WorkspaceManagerTestBase { | 207 class WorkspaceTest : public WorkspaceManagerTestBase { |
165 }; | 208 }; |
166 | 209 |
167 TEST_F(WorkspaceTest, WorkspaceBasic) { | 210 TEST_F(WorkspaceTest, WorkspaceBasic) { |
168 WorkspaceManager manager(viewport()); | 211 WorkspaceManager manager(viewport()); |
169 | 212 |
170 Workspace* ws = manager.CreateWorkspace(); | 213 Workspace* ws = manager.CreateWorkspace(); |
171 // Sanity check | 214 // Sanity check |
172 EXPECT_TRUE(ws->is_empty()); | 215 EXPECT_TRUE(ws->is_empty()); |
173 | 216 |
(...skipping 28 matching lines...) Expand all Loading... |
202 EXPECT_EQ(-1, ws->GetIndexOf(w1.get())); | 245 EXPECT_EQ(-1, ws->GetIndexOf(w1.get())); |
203 EXPECT_EQ(0, ws->GetIndexOf(w2.get())); | 246 EXPECT_EQ(0, ws->GetIndexOf(w2.get())); |
204 EXPECT_FALSE(ws->Contains(w1.get())); | 247 EXPECT_FALSE(ws->Contains(w1.get())); |
205 | 248 |
206 // Add w1 back. w1 now has index = 1. | 249 // Add w1 back. w1 now has index = 1. |
207 EXPECT_TRUE(ws->AddWindowAfter(w1.get(), w2.get())); | 250 EXPECT_TRUE(ws->AddWindowAfter(w1.get(), w2.get())); |
208 EXPECT_EQ(0, ws->GetIndexOf(w2.get())); | 251 EXPECT_EQ(0, ws->GetIndexOf(w2.get())); |
209 EXPECT_EQ(1, ws->GetIndexOf(w1.get())); | 252 EXPECT_EQ(1, ws->GetIndexOf(w1.get())); |
210 } | 253 } |
211 | 254 |
| 255 TEST_F(WorkspaceManagerTest, SwapWindow) { |
| 256 } |
| 257 |
212 } // namespace aura_shell | 258 } // namespace aura_shell |
OLD | NEW |