Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/workspace/workspace_manager.h" | 5 #include "ash/wm/workspace/workspace_manager.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 | 8 |
| 9 #include "ash/ash_switches.h" | 9 #include "ash/ash_switches.h" |
| 10 #include "ash/root_window_controller.h" | 10 #include "ash/root_window_controller.h" |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 142 | 142 |
| 143 bool GetWindowOverlapsShelf() { | 143 bool GetWindowOverlapsShelf() { |
| 144 return shelf_layout_manager()->window_overlaps_shelf(); | 144 return shelf_layout_manager()->window_overlaps_shelf(); |
| 145 } | 145 } |
| 146 | 146 |
| 147 Workspace* FindBy(aura::Window* window) const { | 147 Workspace* FindBy(aura::Window* window) const { |
| 148 return manager_->FindBy(window); | 148 return manager_->FindBy(window); |
| 149 } | 149 } |
| 150 | 150 |
| 151 std::string WorkspaceStateString(Workspace* workspace) { | 151 std::string WorkspaceStateString(Workspace* workspace) { |
| 152 return (workspace->is_maximized() ? "M" : "") + | 152 return (workspace->is_fullscreen() ? "F" : "") + |
| 153 base::IntToString(static_cast<int>( | 153 base::IntToString(static_cast<int>( |
| 154 workspace->window()->children().size())); | 154 workspace->window()->children().size())); |
| 155 } | 155 } |
| 156 | 156 |
| 157 int active_index() { | 157 int active_index() { |
| 158 return static_cast<int>( | 158 return static_cast<int>( |
| 159 manager_->FindWorkspace(manager_->active_workspace_) - | 159 manager_->FindWorkspace(manager_->active_workspace_) - |
| 160 manager_->workspaces_.begin()); | 160 manager_->workspaces_.begin()); |
| 161 } | 161 } |
| 162 | 162 |
| 163 // Returns a string description of the current state. The string has the | 163 // Returns a string description of the current state. The string has the |
| 164 // following format: | 164 // following format: |
| 165 // W* P=W* active=N | 165 // W* P=W* active=N |
| 166 // Each W corresponds to a workspace. Each workspace is prefixed with an 'M' | 166 // Each W corresponds to a workspace. Each workspace is prefixed with an 'F' |
| 167 // if the workspace is maximized and is followed by the number of windows in | 167 // if the workspace is fullscreen and is followed by the number of windows in |
| 168 // the workspace. | 168 // the workspace. |
| 169 // 'P=' is used for the pending workspaces (see | 169 // 'P=' is used for the pending workspaces (see |
| 170 // WorkspaceManager::pending_workspaces_ for details on pending workspaces). | 170 // WorkspaceManager::pending_workspaces_ for details on pending workspaces). |
| 171 // N is the index of the active workspace (index into | 171 // N is the index of the active workspace (index into |
| 172 // WorkspaceManager::workspaces_). | 172 // WorkspaceManager::workspaces_). |
| 173 // For example, '2 M1 P=M1 active=1' means the first workspace (the desktop) | 173 // For example, '2 F1 P=F1 active=1' means the first workspace (the desktop) |
| 174 // has 2 windows, the second workspace is a maximized workspace with 1 window, | 174 // has 2 windows, the second workspace is a maximized workspace with 1 window, |
| 175 // there is a pending maximized workspace with 1 window and the second | 175 // there is a pending maximized workspace with 1 window and the second |
| 176 // workspace is active. | 176 // workspace is active. |
| 177 std::string StateString() { | 177 std::string StateString() { |
| 178 std::string result; | 178 std::string result; |
| 179 for (size_t i = 0; i < manager_->workspaces_.size(); ++i) { | 179 for (size_t i = 0; i < manager_->workspaces_.size(); ++i) { |
| 180 if (i > 0) | 180 if (i > 0) |
| 181 result += " "; | 181 result += " "; |
| 182 result += WorkspaceStateString(manager_->workspaces_[i]); | 182 result += WorkspaceStateString(manager_->workspaces_[i]); |
| 183 } | 183 } |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 253 ASSERT_TRUE(w1->layer() != NULL); | 253 ASSERT_TRUE(w1->layer() != NULL); |
| 254 EXPECT_TRUE(w1->layer()->visible()); | 254 EXPECT_TRUE(w1->layer()->visible()); |
| 255 | 255 |
| 256 EXPECT_EQ("0,0 250x251", w1->bounds().ToString()); | 256 EXPECT_EQ("0,0 250x251", w1->bounds().ToString()); |
| 257 | 257 |
| 258 // Maximize the window. | 258 // Maximize the window. |
| 259 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); | 259 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); |
| 260 | 260 |
| 261 EXPECT_TRUE(wm::IsActiveWindow(w1.get())); | 261 EXPECT_TRUE(wm::IsActiveWindow(w1.get())); |
| 262 | 262 |
| 263 // Should be 2 workspaces, the second maximized with w1. | 263 // Should be 1 workspace. |
| 264 ASSERT_EQ("0 M1 active=1", StateString()); | 264 ASSERT_EQ("1 active=0", StateString()); |
| 265 EXPECT_EQ(w1.get(), workspaces()[1]->window()->children()[0]); | 265 EXPECT_EQ(w1.get(), workspaces()[0]->window()->children()[0]); |
| 266 EXPECT_EQ(ScreenAsh::GetMaximizedWindowBoundsInParent(w1.get()).width(), | 266 EXPECT_EQ(ScreenAsh::GetMaximizedWindowBoundsInParent(w1.get()).width(), |
| 267 w1->bounds().width()); | 267 w1->bounds().width()); |
| 268 EXPECT_EQ(ScreenAsh::GetMaximizedWindowBoundsInParent(w1.get()).height(), | 268 EXPECT_EQ(ScreenAsh::GetMaximizedWindowBoundsInParent(w1.get()).height(), |
| 269 w1->bounds().height()); | 269 w1->bounds().height()); |
| 270 | 270 |
| 271 // Restore the window. | 271 // Restore the window. |
| 272 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); | 272 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); |
| 273 | 273 |
| 274 // Should be 1 workspace for the desktop. | |
| 275 ASSERT_EQ("1 active=0", StateString()); | 274 ASSERT_EQ("1 active=0", StateString()); |
| 276 EXPECT_EQ(w1.get(), workspaces()[0]->window()->children()[0]); | 275 EXPECT_EQ(w1.get(), workspaces()[0]->window()->children()[0]); |
| 277 EXPECT_EQ("0,0 250x251", w1->bounds().ToString()); | 276 EXPECT_EQ("0,0 250x251", w1->bounds().ToString()); |
| 278 } | 277 } |
| 279 | 278 |
| 280 // Assertions around closing the last window in a workspace. | 279 // Assertions around closing the last window in a workspace. |
| 281 TEST_F(WorkspaceManagerTest, CloseLastWindowInWorkspace) { | 280 TEST_F(WorkspaceManagerTest, CloseLastWindowInWorkspace) { |
| 282 scoped_ptr<Window> w1(CreateTestWindow()); | 281 scoped_ptr<Window> w1(CreateTestWindow()); |
| 283 scoped_ptr<Window> w2(CreateTestWindow()); | 282 scoped_ptr<Window> w2(CreateTestWindow()); |
| 284 w1->SetBounds(gfx::Rect(0, 0, 250, 251)); | 283 w1->SetBounds(gfx::Rect(0, 0, 250, 251)); |
| 285 w1->Show(); | 284 w1->Show(); |
| 286 w2->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); | 285 w2->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); |
| 287 w2->Show(); | 286 w2->Show(); |
| 288 wm::ActivateWindow(w1.get()); | 287 wm::ActivateWindow(w1.get()); |
| 289 | 288 |
| 290 // Should be 1 workspace and 1 pending, !maximized and maximized. The second | 289 // Maximized window will be in the same workspace. |
| 291 // workspace is pending since the window wasn't active. | 290 ASSERT_EQ("2 active=0", StateString()); |
| 292 ASSERT_EQ("1 P=M1 active=0", StateString()); | 291 EXPECT_EQ(w1.get(), workspaces()[0]->window()->children()[1]); |
| 293 EXPECT_EQ(w1.get(), workspaces()[0]->window()->children()[0]); | 292 EXPECT_EQ(w2.get(), workspaces()[0]->window()->children()[0]); |
| 294 | 293 |
| 295 // Close w2. | 294 // Close w2. |
| 296 w2.reset(); | 295 w2.reset(); |
| 297 | 296 |
| 298 // Should have one workspace. | 297 // Should have one workspace. |
| 299 ASSERT_EQ("1 active=0", StateString()); | 298 ASSERT_EQ("1 active=0", StateString()); |
| 300 EXPECT_EQ(w1.get(), workspaces()[0]->window()->children()[0]); | 299 EXPECT_EQ(w1.get(), workspaces()[0]->window()->children()[0]); |
| 301 EXPECT_TRUE(w1->IsVisible()); | 300 EXPECT_TRUE(w1->IsVisible()); |
| 302 } | 301 } |
| 303 | 302 |
| 304 // Assertions around adding a maximized window when empty. | 303 // Assertions around adding a maximized window when empty. |
| 305 TEST_F(WorkspaceManagerTest, AddMaximizedWindowWhenEmpty) { | 304 TEST_F(WorkspaceManagerTest, AddMaximizedWindowWhenEmpty) { |
| 306 scoped_ptr<Window> w1(CreateTestWindow()); | 305 scoped_ptr<Window> w1(CreateTestWindow()); |
| 307 w1->SetBounds(gfx::Rect(0, 0, 250, 251)); | 306 w1->SetBounds(gfx::Rect(0, 0, 250, 251)); |
| 308 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); | 307 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); |
| 309 w1->Show(); | 308 w1->Show(); |
| 310 wm::ActivateWindow(w1.get()); | 309 wm::ActivateWindow(w1.get()); |
| 311 | 310 |
| 312 ASSERT_TRUE(w1->layer() != NULL); | 311 ASSERT_TRUE(w1->layer() != NULL); |
| 313 EXPECT_TRUE(w1->layer()->visible()); | 312 EXPECT_TRUE(w1->layer()->visible()); |
| 314 gfx::Rect work_area( | 313 gfx::Rect work_area( |
| 315 ScreenAsh::GetMaximizedWindowBoundsInParent(w1.get())); | 314 ScreenAsh::GetMaximizedWindowBoundsInParent(w1.get())); |
| 316 EXPECT_EQ(work_area.width(), w1->bounds().width()); | 315 EXPECT_EQ(work_area.width(), w1->bounds().width()); |
| 317 EXPECT_EQ(work_area.height(), w1->bounds().height()); | 316 EXPECT_EQ(work_area.height(), w1->bounds().height()); |
| 318 | 317 |
| 319 // Should be 2 workspaces (since we always keep the desktop). | 318 ASSERT_EQ("1 active=0", StateString()); |
| 320 ASSERT_EQ("0 M1 active=1", StateString()); | 319 EXPECT_EQ(w1.get(), workspaces()[0]->window()->children()[0]); |
| 321 EXPECT_EQ(w1.get(), workspaces()[1]->window()->children()[0]); | |
| 322 } | 320 } |
| 323 | 321 |
| 324 // Assertions around two windows and toggling one to be maximized. | 322 // Assertions around two windows and toggling one to be maximized. |
| 325 TEST_F(WorkspaceManagerTest, MaximizeWithNormalWindow) { | 323 TEST_F(WorkspaceManagerTest, MaximizeWithNormalWindow) { |
| 326 scoped_ptr<Window> w1(CreateTestWindow()); | 324 scoped_ptr<Window> w1(CreateTestWindow()); |
| 327 scoped_ptr<Window> w2(CreateTestWindow()); | 325 scoped_ptr<Window> w2(CreateTestWindow()); |
| 328 w1->SetBounds(gfx::Rect(0, 0, 250, 251)); | 326 w1->SetBounds(gfx::Rect(0, 0, 250, 251)); |
| 329 w1->Show(); | 327 w1->Show(); |
| 330 | 328 |
| 331 ASSERT_TRUE(w1->layer() != NULL); | 329 ASSERT_TRUE(w1->layer() != NULL); |
| 332 EXPECT_TRUE(w1->layer()->visible()); | 330 EXPECT_TRUE(w1->layer()->visible()); |
| 333 | 331 |
| 334 w2->SetBounds(gfx::Rect(0, 0, 50, 51)); | 332 w2->SetBounds(gfx::Rect(0, 0, 50, 51)); |
| 335 w2->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); | 333 w2->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); |
| 336 w2->Show(); | 334 w2->Show(); |
| 337 wm::ActivateWindow(w2.get()); | 335 wm::ActivateWindow(w2.get()); |
| 338 | 336 |
| 339 // Should now be two workspaces. | 337 // Both w1 and w2 should be in the same workspace. |
| 340 ASSERT_EQ("1 M1 active=1", StateString()); | 338 ASSERT_EQ("2 active=0", StateString()); |
| 341 EXPECT_EQ(w1.get(), workspaces()[0]->window()->children()[0]); | 339 EXPECT_EQ(w1.get(), workspaces()[0]->window()->children()[0]); |
| 342 EXPECT_EQ(w2.get(), workspaces()[1]->window()->children()[0]); | 340 EXPECT_EQ(w2.get(), workspaces()[0]->window()->children()[1]); |
| 343 | 341 |
| 344 gfx::Rect work_area(ScreenAsh::GetMaximizedWindowBoundsInParent(w1.get())); | 342 gfx::Rect work_area(ScreenAsh::GetMaximizedWindowBoundsInParent(w1.get())); |
| 345 EXPECT_EQ(work_area.width(), w2->bounds().width()); | 343 EXPECT_EQ(work_area.width(), w2->bounds().width()); |
| 346 EXPECT_EQ(work_area.height(), w2->bounds().height()); | 344 EXPECT_EQ(work_area.height(), w2->bounds().height()); |
| 347 | 345 |
| 348 // Restore w2, which should then go back to one workspace. | 346 // Restore w2 |
| 349 w2->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); | 347 w2->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); |
| 350 ASSERT_EQ("2 active=0", StateString()); | 348 ASSERT_EQ("2 active=0", StateString()); |
| 351 EXPECT_EQ(w1.get(), workspaces()[0]->window()->children()[0]); | 349 EXPECT_EQ(w1.get(), workspaces()[0]->window()->children()[0]); |
| 352 EXPECT_EQ(w2.get(), workspaces()[0]->window()->children()[1]); | 350 EXPECT_EQ(w2.get(), workspaces()[0]->window()->children()[1]); |
| 353 EXPECT_EQ(50, w2->bounds().width()); | 351 EXPECT_EQ(50, w2->bounds().width()); |
| 354 EXPECT_EQ(51, w2->bounds().height()); | 352 EXPECT_EQ(51, w2->bounds().height()); |
| 355 EXPECT_TRUE(wm::IsActiveWindow(w2.get())); | 353 EXPECT_TRUE(wm::IsActiveWindow(w2.get())); |
| 356 } | 354 } |
| 357 | 355 |
| 358 // Assertions around two maximized windows. | 356 // Assertions around two maximized windows. |
| 359 TEST_F(WorkspaceManagerTest, TwoMaximized) { | 357 TEST_F(WorkspaceManagerTest, TwoMaximized) { |
| 360 scoped_ptr<Window> w1(CreateTestWindow()); | 358 scoped_ptr<Window> w1(CreateTestWindow()); |
| 361 scoped_ptr<Window> w2(CreateTestWindow()); | 359 scoped_ptr<Window> w2(CreateTestWindow()); |
| 362 w1->SetBounds(gfx::Rect(0, 0, 250, 251)); | 360 w1->SetBounds(gfx::Rect(0, 0, 250, 251)); |
| 363 w1->Show(); | 361 w1->Show(); |
| 364 wm::ActivateWindow(w1.get()); | 362 wm::ActivateWindow(w1.get()); |
| 365 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); | 363 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); |
|
sky
2013/06/07 19:44:35
I tend to think that for all these tests you need
Jun Mukai
2013/06/08 00:00:39
Done.
| |
| 366 ASSERT_EQ("1 M1 active=1", StateString()); | 364 ASSERT_EQ("2 active=0", StateString()); |
| 367 | 365 |
| 368 w2->SetBounds(gfx::Rect(0, 0, 50, 51)); | 366 w2->SetBounds(gfx::Rect(0, 0, 50, 51)); |
| 369 w2->Show(); | 367 w2->Show(); |
| 370 wm::ActivateWindow(w2.get()); | 368 wm::ActivateWindow(w2.get()); |
| 371 ASSERT_EQ("1 M1 active=0", StateString()); | 369 ASSERT_EQ("2 active=0", StateString()); |
| 372 | 370 |
| 373 w2->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); | 371 w2->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); |
| 374 EXPECT_TRUE(wm::IsActiveWindow(w2.get())); | 372 EXPECT_TRUE(wm::IsActiveWindow(w2.get())); |
| 375 ASSERT_EQ("0 M1 M1 active=2", StateString()); | 373 ASSERT_EQ("2 active=0", StateString()); |
| 376 | 374 |
| 377 // The last stacked window (|w2|) should be last since it was maximized last. | 375 // The last stacked window (|w2|) should be last since it was maximized last. |
| 378 EXPECT_EQ(w1.get(), workspaces()[1]->window()->children()[0]); | 376 EXPECT_EQ(w1.get(), workspaces()[0]->window()->children()[0]); |
| 379 EXPECT_EQ(w2.get(), workspaces()[2]->window()->children()[0]); | 377 EXPECT_EQ(w2.get(), workspaces()[0]->window()->children()[1]); |
| 380 } | 378 } |
| 381 | 379 |
| 382 // Get the index of the layer inside its parent. This index can be used to | 380 // Get the index of the layer inside its parent. This index can be used to |
| 383 // determine the z-order / draw-order of objects in the render tree. | 381 // determine the z-order / draw-order of objects in the render tree. |
| 384 size_t IndexOfLayerInParent(ui::Layer* layer) { | 382 size_t IndexOfLayerInParent(ui::Layer* layer) { |
| 385 ui::Layer* parent = layer->parent(); | 383 ui::Layer* parent = layer->parent(); |
| 386 for (size_t i = 0; i < parent->children().size(); i++) { | 384 for (size_t i = 0; i < parent->children().size(); i++) { |
| 387 if (layer == parent->children()[i]) | 385 if (layer == parent->children()[i]) |
| 388 return i; | 386 return i; |
| 389 } | 387 } |
| 390 // This should never be reached. | 388 // This should never be reached. |
| 391 NOTREACHED(); | 389 NOTREACHED(); |
| 392 return 0; | 390 return 0; |
| 393 } | 391 } |
| 394 | 392 |
| 395 // Make sure that the layer z-order is correct for the time of the animation | 393 // Make sure that the layer z-order is correct for the time of the animation |
| 396 // when in a workspace with a normal and a maximized window the normal window | 394 // when in a workspace with a normal and a maximized window the normal window |
| 397 // gets maximized. See crbug.com/232399. | 395 // gets maximized. See crbug.com/232399. |
| 398 TEST_F(WorkspaceManagerTest, MaximizeSecondInWorkspace) { | 396 TEST_F(WorkspaceManagerTest, MaximizeSecondInWorkspace) { |
| 399 // Create a maximized window. | 397 // Create a maximized window. |
| 400 scoped_ptr<Window> w1(CreateTestWindow()); | 398 scoped_ptr<Window> w1(CreateTestWindow()); |
| 401 ASSERT_EQ(1U, w1->layer()->parent()->children().size()); | 399 ASSERT_EQ(1U, w1->layer()->parent()->children().size()); |
| 402 w1->SetBounds(gfx::Rect(0, 0, 250, 251)); | 400 w1->SetBounds(gfx::Rect(0, 0, 250, 251)); |
| 403 w1->Show(); | 401 w1->Show(); |
| 404 wm::ActivateWindow(w1.get()); | 402 wm::ActivateWindow(w1.get()); |
| 405 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); | 403 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); |
| 406 wm::ActivateWindow(w1.get()); | 404 wm::ActivateWindow(w1.get()); |
| 407 // There are two workspaces: A normal and a maximized one. | 405 // There are two workspaces: A normal and a maximized one. |
| 408 ASSERT_EQ("0 M1 active=1", StateString()); | 406 ASSERT_EQ("1 active=0", StateString()); |
| 409 | 407 |
| 410 // Create a second window and make it part of the maximized workspace. | 408 // Create a second window and make it part of the maximized workspace. |
| 411 scoped_ptr<Window> w2(CreateAppTestWindow(w1->parent())); | 409 scoped_ptr<Window> w2(CreateAppTestWindow(w1->parent())); |
| 412 w2->SetBounds(gfx::Rect(0, 0, 50, 51)); | 410 w2->SetBounds(gfx::Rect(0, 0, 50, 51)); |
| 413 w2->Show(); | 411 w2->Show(); |
| 414 wm::ActivateWindow(w2.get()); | 412 wm::ActivateWindow(w2.get()); |
| 415 // There are still two workspaces and two windows in the (maximized) | 413 // There are still two workspaces and two windows in the (maximized) |
| 416 // workspace. | 414 // workspace. |
| 417 ASSERT_EQ("0 M2 active=1", StateString()); | 415 ASSERT_EQ("2 active=0", StateString()); |
| 418 ASSERT_EQ(w1->layer()->parent()->children()[0], w1->layer()); | 416 ASSERT_EQ(w1->layer()->parent()->children()[0], w1->layer()); |
| 419 ASSERT_EQ(w1->layer()->parent()->children()[1], w2->layer()); | 417 ASSERT_EQ(w1->layer()->parent()->children()[1], w2->layer()); |
| 420 | 418 |
| 421 // Now we need to enable all animations since the incorrect layer ordering we | 419 // Now we need to enable all animations since the incorrect layer ordering we |
| 422 // want to test against happens only while the animation is going on. | 420 // want to test against happens only while the animation is going on. |
| 423 scoped_ptr<ui::ScopedAnimationDurationScaleMode> animation_duration( | 421 scoped_ptr<ui::ScopedAnimationDurationScaleMode> animation_duration( |
| 424 new ui::ScopedAnimationDurationScaleMode( | 422 new ui::ScopedAnimationDurationScaleMode( |
| 425 ui::ScopedAnimationDurationScaleMode::FAST_DURATION)); | 423 ui::ScopedAnimationDurationScaleMode::FAST_DURATION)); |
| 426 | 424 |
| 427 ui::Layer* old_w2_layer = w2->layer(); | |
| 428 | |
| 429 // Maximize the second window and make sure that the workspace changes. | 425 // Maximize the second window and make sure that the workspace changes. |
| 430 w2->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); | 426 w2->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); |
| 431 | 427 |
| 432 // Check the correct window hierarchy - (|w2|) should be last since it was | 428 // Check the correct window hierarchy - (|w2|) should be last since it was |
| 433 // maximized last. | 429 // maximized last. |
| 434 ASSERT_EQ("0 M1 M1 active=2", StateString()); | 430 ASSERT_EQ("2 active=0", StateString()); |
| 435 EXPECT_EQ(3U, workspaces().size()); | 431 EXPECT_EQ(1U, workspaces().size()); |
| 436 EXPECT_EQ(w1.get(), workspaces()[1]->window()->children()[0]); | 432 EXPECT_EQ(w1.get(), workspaces()[0]->window()->children()[0]); |
| 437 EXPECT_EQ(w2.get(), workspaces()[2]->window()->children()[0]); | 433 EXPECT_EQ(w2.get(), workspaces()[0]->window()->children()[1]); |
| 438 | |
| 439 // Check the workspace layer visibility. | |
| 440 EXPECT_EQ(1, workspaces()[1]->window()->layer()->opacity()); | |
| 441 EXPECT_EQ(1, workspaces()[2]->window()->layer()->opacity()); | |
| 442 | |
| 443 // Check that |w2| got a new layer and that the old layer is still visible, | |
| 444 // while the new one is not. Further and foremost the old layer should be a | |
| 445 // member of the workspace's window and it should be the second last of the | |
| 446 // list to be properly stacked while the animation is going on. | |
| 447 EXPECT_NE(w2->layer(), old_w2_layer); | |
| 448 EXPECT_EQ(0, w2->layer()->opacity()); | |
| 449 EXPECT_EQ(1, old_w2_layer->opacity()); | |
| 450 | |
| 451 // For the animation to look right we need the following ordering: | |
| 452 // workspace_1_layer_index < old_layer_index < workspace_2_layer_index. | |
| 453 ASSERT_EQ(workspaces()[1]->window()->parent()->layer(), | |
| 454 old_w2_layer->parent()); | |
| 455 const size_t workspace_1_layer_index = IndexOfLayerInParent( | |
| 456 workspaces()[1]->window()->layer()); | |
| 457 const size_t workspace_2_layer_index = IndexOfLayerInParent( | |
| 458 workspaces()[2]->window()->layer()); | |
| 459 const size_t old_layer_index = IndexOfLayerInParent(old_w2_layer); | |
| 460 EXPECT_LT(workspace_1_layer_index, old_layer_index); | |
| 461 EXPECT_LT(old_layer_index, workspace_2_layer_index); | |
| 462 } | 434 } |
| 463 | 435 |
| 464 // Makes sure requests to change the bounds of a normal window go through. | 436 // Makes sure requests to change the bounds of a normal window go through. |
| 465 TEST_F(WorkspaceManagerTest, ChangeBoundsOfNormalWindow) { | 437 TEST_F(WorkspaceManagerTest, ChangeBoundsOfNormalWindow) { |
| 466 scoped_ptr<Window> w1(CreateTestWindow()); | 438 scoped_ptr<Window> w1(CreateTestWindow()); |
| 467 w1->Show(); | 439 w1->Show(); |
| 468 | 440 |
| 469 // Setting the bounds should go through since the window is in the normal | 441 // Setting the bounds should go through since the window is in the normal |
| 470 // workspace. | 442 // workspace. |
| 471 w1->SetBounds(gfx::Rect(0, 0, 200, 500)); | 443 w1->SetBounds(gfx::Rect(0, 0, 200, 500)); |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 488 // Assertions around a fullscreen window. | 460 // Assertions around a fullscreen window. |
| 489 TEST_F(WorkspaceManagerTest, SingleFullscreenWindow) { | 461 TEST_F(WorkspaceManagerTest, SingleFullscreenWindow) { |
| 490 scoped_ptr<Window> w1(CreateTestWindow()); | 462 scoped_ptr<Window> w1(CreateTestWindow()); |
| 491 w1->SetBounds(gfx::Rect(0, 0, 250, 251)); | 463 w1->SetBounds(gfx::Rect(0, 0, 250, 251)); |
| 492 // Make the window fullscreen. | 464 // Make the window fullscreen. |
| 493 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN); | 465 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN); |
| 494 w1->Show(); | 466 w1->Show(); |
| 495 wm::ActivateWindow(w1.get()); | 467 wm::ActivateWindow(w1.get()); |
| 496 | 468 |
| 497 // Should be 2 workspaces, normal and maximized. | 469 // Should be 2 workspaces, normal and maximized. |
| 498 ASSERT_EQ("0 M1 active=1", StateString()); | 470 ASSERT_EQ("0 F1 active=1", StateString()); |
| 499 EXPECT_EQ(w1.get(), workspaces()[1]->window()->children()[0]); | 471 EXPECT_EQ(w1.get(), workspaces()[1]->window()->children()[0]); |
| 500 EXPECT_EQ(GetFullscreenBounds(w1.get()).width(), w1->bounds().width()); | 472 EXPECT_EQ(GetFullscreenBounds(w1.get()).width(), w1->bounds().width()); |
| 501 EXPECT_EQ(GetFullscreenBounds(w1.get()).height(), w1->bounds().height()); | 473 EXPECT_EQ(GetFullscreenBounds(w1.get()).height(), w1->bounds().height()); |
| 502 | 474 |
| 503 // Restore the window. Use SHOW_STATE_DEFAULT as that is what we'll end up | 475 // Restore the window. Use SHOW_STATE_DEFAULT as that is what we'll end up |
| 504 // with when using views::Widget. | 476 // with when using views::Widget. |
| 505 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_DEFAULT); | 477 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_DEFAULT); |
| 506 EXPECT_EQ("0,0 250x251", w1->bounds().ToString()); | 478 EXPECT_EQ("0,0 250x251", w1->bounds().ToString()); |
| 507 | 479 |
| 508 // Should be 1 workspace for the desktop. | 480 // Should be 1 workspace for the desktop. |
| 509 ASSERT_EQ("1 active=0", StateString()); | 481 ASSERT_EQ("1 active=0", StateString()); |
| 510 EXPECT_EQ(w1.get(), workspaces()[0]->window()->children()[0]); | 482 EXPECT_EQ(w1.get(), workspaces()[0]->window()->children()[0]); |
| 511 EXPECT_EQ(250, w1->bounds().width()); | 483 EXPECT_EQ(250, w1->bounds().width()); |
| 512 EXPECT_EQ(251, w1->bounds().height()); | 484 EXPECT_EQ(251, w1->bounds().height()); |
| 513 | 485 |
| 514 // Back to fullscreen. | 486 // Back to fullscreen. |
| 515 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN); | 487 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN); |
| 516 ASSERT_EQ("0 M1 active=1", StateString()); | 488 ASSERT_EQ("0 F1 active=1", StateString()); |
| 517 EXPECT_EQ(w1.get(), workspaces()[1]->window()->children()[0]); | 489 EXPECT_EQ(w1.get(), workspaces()[1]->window()->children()[0]); |
| 518 EXPECT_EQ(GetFullscreenBounds(w1.get()).width(), w1->bounds().width()); | 490 EXPECT_EQ(GetFullscreenBounds(w1.get()).width(), w1->bounds().width()); |
| 519 EXPECT_EQ(GetFullscreenBounds(w1.get()).height(), w1->bounds().height()); | 491 EXPECT_EQ(GetFullscreenBounds(w1.get()).height(), w1->bounds().height()); |
| 520 ASSERT_TRUE(GetRestoreBoundsInScreen(w1.get())); | 492 ASSERT_TRUE(GetRestoreBoundsInScreen(w1.get())); |
| 521 EXPECT_EQ("0,0 250x251", GetRestoreBoundsInScreen(w1.get())->ToString()); | 493 EXPECT_EQ("0,0 250x251", GetRestoreBoundsInScreen(w1.get())->ToString()); |
| 522 } | 494 } |
| 523 | 495 |
| 524 // Makes sure switching workspaces doesn't show transient windows. | 496 // Makes sure switching workspaces doesn't show transient windows. |
| 525 TEST_F(WorkspaceManagerTest, DontShowTransientsOnSwitch) { | 497 TEST_F(WorkspaceManagerTest, DontShowTransientsOnSwitch) { |
| 526 scoped_ptr<Window> w1(CreateTestWindow()); | 498 scoped_ptr<Window> w1(CreateTestWindow()); |
| 527 scoped_ptr<Window> w2(CreateTestWindow()); | 499 scoped_ptr<Window> w2(CreateTestWindow()); |
| 528 | 500 |
| 529 w1->SetBounds(gfx::Rect(0, 0, 250, 251)); | 501 w1->SetBounds(gfx::Rect(0, 0, 250, 251)); |
| 530 w2->SetBounds(gfx::Rect(0, 0, 250, 251)); | 502 w2->SetBounds(gfx::Rect(0, 0, 250, 251)); |
| 531 w1->AddTransientChild(w2.get()); | 503 w1->AddTransientChild(w2.get()); |
| 532 | 504 |
| 533 w1->Show(); | 505 w1->Show(); |
| 534 | 506 |
| 535 scoped_ptr<Window> w3(CreateTestWindow()); | 507 scoped_ptr<Window> w3(CreateTestWindow()); |
| 536 w3->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); | 508 w3->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); |
| 537 w3->Show(); | 509 w3->Show(); |
| 538 wm::ActivateWindow(w3.get()); | 510 wm::ActivateWindow(w3.get()); |
| 539 | 511 |
| 540 EXPECT_FALSE(w1->layer()->IsDrawn()); | 512 EXPECT_TRUE(w1->layer()->IsDrawn()); |
| 541 EXPECT_FALSE(w2->layer()->IsDrawn()); | 513 EXPECT_FALSE(w2->layer()->IsDrawn()); |
| 542 EXPECT_TRUE(w3->layer()->IsDrawn()); | 514 EXPECT_TRUE(w3->layer()->IsDrawn()); |
| 543 | 515 |
| 544 wm::ActivateWindow(w1.get()); | 516 wm::ActivateWindow(w1.get()); |
| 545 EXPECT_TRUE(w1->layer()->IsDrawn()); | 517 EXPECT_TRUE(w1->layer()->IsDrawn()); |
| 546 EXPECT_FALSE(w2->layer()->IsDrawn()); | 518 EXPECT_FALSE(w2->layer()->IsDrawn()); |
| 547 EXPECT_FALSE(w3->layer()->IsDrawn()); | 519 EXPECT_TRUE(w3->layer()->IsDrawn()); |
| 548 } | 520 } |
| 549 | 521 |
| 550 // Persists-across-all-workspace flag should not cause a transient child | 522 // Persists-across-all-workspace flag should not cause a transient child |
| 551 // to be activated at desktop workspace. | 523 // to be activated at desktop workspace. |
| 552 TEST_F(WorkspaceManagerTest, PersistsTransientChildStayInSameWorkspace) { | 524 TEST_F(WorkspaceManagerTest, PersistsTransientChildStayInSameWorkspace) { |
| 553 scoped_ptr<Window> w1(CreateTestWindow()); | 525 scoped_ptr<Window> w1(CreateTestWindow()); |
| 554 SetPersistsAcrossAllWorkspaces( | 526 SetPersistsAcrossAllWorkspaces( |
| 555 w1.get(), | 527 w1.get(), |
| 556 WINDOW_PERSISTS_ACROSS_ALL_WORKSPACES_VALUE_YES); | 528 WINDOW_PERSISTS_ACROSS_ALL_WORKSPACES_VALUE_YES); |
| 557 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); | 529 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); |
| 558 w1->Show(); | 530 w1->Show(); |
| 559 wm::ActivateWindow(w1.get()); | 531 wm::ActivateWindow(w1.get()); |
| 560 ASSERT_EQ("0 M1 active=1", StateString()); | 532 ASSERT_EQ("1 active=0", StateString()); |
| 561 | 533 |
| 562 scoped_ptr<Window> w2(CreateTestWindowUnparented()); | 534 scoped_ptr<Window> w2(CreateTestWindowUnparented()); |
| 563 w1->AddTransientChild(w2.get()); | 535 w1->AddTransientChild(w2.get()); |
| 564 SetPersistsAcrossAllWorkspaces( | 536 SetPersistsAcrossAllWorkspaces( |
| 565 w2.get(), | 537 w2.get(), |
| 566 WINDOW_PERSISTS_ACROSS_ALL_WORKSPACES_VALUE_YES); | 538 WINDOW_PERSISTS_ACROSS_ALL_WORKSPACES_VALUE_YES); |
| 567 SetDefaultParentByPrimaryRootWindow(w2.get()); | 539 SetDefaultParentByPrimaryRootWindow(w2.get()); |
| 568 w2->Show(); | 540 w2->Show(); |
| 569 wm::ActivateWindow(w2.get()); | 541 wm::ActivateWindow(w2.get()); |
| 570 | 542 |
| 571 ASSERT_EQ("0 M2 active=1", StateString()); | 543 ASSERT_EQ("2 active=0", StateString()); |
| 572 } | 544 } |
| 573 | 545 |
| 574 // Assertions around minimizing a single window. | 546 // Assertions around minimizing a single window. |
| 575 TEST_F(WorkspaceManagerTest, MinimizeSingleWindow) { | 547 TEST_F(WorkspaceManagerTest, MinimizeSingleWindow) { |
| 576 scoped_ptr<Window> w1(CreateTestWindow()); | 548 scoped_ptr<Window> w1(CreateTestWindow()); |
| 577 | 549 |
| 578 w1->Show(); | 550 w1->Show(); |
| 579 ASSERT_EQ("1 active=0", StateString()); | 551 ASSERT_EQ("1 active=0", StateString()); |
| 580 | 552 |
| 581 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MINIMIZED); | 553 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MINIMIZED); |
| 582 ASSERT_EQ("1 active=0", StateString()); | 554 ASSERT_EQ("1 active=0", StateString()); |
| 583 EXPECT_FALSE(w1->layer()->IsDrawn()); | 555 EXPECT_FALSE(w1->layer()->IsDrawn()); |
| 584 | 556 |
| 585 // Show the window. | 557 // Show the window. |
| 586 w1->Show(); | 558 w1->Show(); |
| 587 EXPECT_TRUE(wm::IsWindowNormal(w1.get())); | 559 EXPECT_TRUE(wm::IsWindowNormal(w1.get())); |
| 588 ASSERT_EQ("1 active=0", StateString()); | 560 ASSERT_EQ("1 active=0", StateString()); |
| 589 EXPECT_TRUE(w1->layer()->IsDrawn()); | 561 EXPECT_TRUE(w1->layer()->IsDrawn()); |
| 590 } | 562 } |
| 591 | 563 |
| 592 // Assertions around minimizing a maximized window. | 564 // Assertions around minimizing a maximized window. |
| 593 TEST_F(WorkspaceManagerTest, MinimizeMaximizedWindow) { | 565 TEST_F(WorkspaceManagerTest, MinimizeMaximizedWindow) { |
| 594 // Two windows, w1 normal, w2 maximized. | 566 // Two windows, w1 normal, w2 maximized. |
| 595 scoped_ptr<Window> w1(CreateTestWindow()); | 567 scoped_ptr<Window> w1(CreateTestWindow()); |
| 596 scoped_ptr<Window> w2(CreateTestWindow()); | 568 scoped_ptr<Window> w2(CreateTestWindow()); |
| 597 w1->Show(); | 569 w1->Show(); |
| 598 w2->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); | 570 w2->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); |
| 599 w2->Show(); | 571 w2->Show(); |
| 600 wm::ActivateWindow(w2.get()); | 572 wm::ActivateWindow(w2.get()); |
| 601 ASSERT_EQ("1 M1 active=1", StateString()); | 573 ASSERT_EQ("2 active=0", StateString()); |
| 602 | 574 |
| 603 // Minimize w2. | 575 // Minimize w2. |
| 604 w2->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MINIMIZED); | 576 w2->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MINIMIZED); |
| 605 ASSERT_EQ("1 P=M1 active=0", StateString()); | 577 ASSERT_EQ("2 active=0", StateString()); |
| 606 EXPECT_TRUE(w1->layer()->IsDrawn()); | 578 EXPECT_TRUE(w1->layer()->IsDrawn()); |
| 607 EXPECT_FALSE(w2->layer()->IsDrawn()); | 579 EXPECT_FALSE(w2->layer()->IsDrawn()); |
| 608 | 580 |
| 609 // Show the window, which should trigger unminimizing. | 581 // Show the window, which should trigger unminimizing. |
| 610 w2->Show(); | 582 w2->Show(); |
| 611 ASSERT_EQ("1 P=M1 active=0", StateString()); | 583 ASSERT_EQ("2 active=0", StateString()); |
| 612 | 584 |
| 613 wm::ActivateWindow(w2.get()); | 585 wm::ActivateWindow(w2.get()); |
| 614 ASSERT_EQ("1 M1 active=1", StateString()); | 586 ASSERT_EQ("2 active=0", StateString()); |
| 615 | 587 |
| 616 EXPECT_TRUE(wm::IsWindowMaximized(w2.get())); | 588 EXPECT_TRUE(wm::IsWindowMaximized(w2.get())); |
| 617 EXPECT_FALSE(w1->layer()->IsDrawn()); | 589 EXPECT_TRUE(w1->layer()->IsDrawn()); |
| 618 EXPECT_TRUE(w2->layer()->IsDrawn()); | 590 EXPECT_TRUE(w2->layer()->IsDrawn()); |
| 619 | 591 |
| 620 // Minimize the window, which should hide the window and activate another. | 592 // Minimize the window, which should hide the window and activate another. |
| 621 EXPECT_TRUE(wm::IsActiveWindow(w2.get())); | 593 EXPECT_TRUE(wm::IsActiveWindow(w2.get())); |
| 622 w2->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MINIMIZED); | 594 w2->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MINIMIZED); |
| 623 EXPECT_FALSE(wm::IsActiveWindow(w2.get())); | 595 EXPECT_FALSE(wm::IsActiveWindow(w2.get())); |
| 624 EXPECT_FALSE(w2->layer()->IsDrawn()); | 596 EXPECT_FALSE(w2->layer()->IsDrawn()); |
| 625 EXPECT_TRUE(wm::IsActiveWindow(w1.get())); | 597 EXPECT_TRUE(wm::IsActiveWindow(w1.get())); |
| 626 | 598 |
| 627 // Make the window normal. | 599 // Make the window normal. |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 719 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); | 691 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); |
| 720 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state()); | 692 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state()); |
| 721 EXPECT_EQ("0,1 101x102", w1->bounds().ToString()); | 693 EXPECT_EQ("0,1 101x102", w1->bounds().ToString()); |
| 722 | 694 |
| 723 // Create another window, maximized. | 695 // Create another window, maximized. |
| 724 scoped_ptr<Window> w2(CreateTestWindow()); | 696 scoped_ptr<Window> w2(CreateTestWindow()); |
| 725 w2->SetBounds(gfx::Rect(10, 11, 250, 251)); | 697 w2->SetBounds(gfx::Rect(10, 11, 250, 251)); |
| 726 w2->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); | 698 w2->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); |
| 727 w2->Show(); | 699 w2->Show(); |
| 728 wm::ActivateWindow(w2.get()); | 700 wm::ActivateWindow(w2.get()); |
| 729 EXPECT_EQ(1, active_index()); | 701 EXPECT_EQ(0, active_index()); |
| 730 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state()); | 702 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state()); |
| 731 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); | 703 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); |
| 732 EXPECT_EQ("0,1 101x102", w1->bounds().ToString()); | 704 EXPECT_EQ("0,1 101x102", w1->bounds().ToString()); |
| 733 | 705 |
| 734 // Switch to w1. | 706 // Switch to w1. |
| 735 wm::ActivateWindow(w1.get()); | 707 wm::ActivateWindow(w1.get()); |
| 736 EXPECT_EQ(0, active_index()); | 708 EXPECT_EQ(0, active_index()); |
| 737 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state()); | 709 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state()); |
| 738 EXPECT_EQ("0,1 101x102", w1->bounds().ToString()); | 710 EXPECT_EQ("0,1 101x102", w1->bounds().ToString()); |
| 739 EXPECT_EQ(ScreenAsh::GetMaximizedWindowBoundsInParent( | 711 EXPECT_EQ(ScreenAsh::GetMaximizedWindowBoundsInParent( |
| 740 w2->parent()).ToString(), | 712 w2->parent()).ToString(), |
| 741 w2->bounds().ToString()); | 713 w2->bounds().ToString()); |
| 742 | 714 |
| 743 // Switch to w2. | 715 // Switch to w2. |
| 744 wm::ActivateWindow(w2.get()); | 716 wm::ActivateWindow(w2.get()); |
| 745 EXPECT_EQ(1, active_index()); | 717 EXPECT_EQ(0, active_index()); |
| 746 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state()); | 718 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state()); |
| 747 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); | 719 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); |
| 748 EXPECT_EQ("0,1 101x102", w1->bounds().ToString()); | 720 EXPECT_EQ("0,1 101x102", w1->bounds().ToString()); |
| 749 EXPECT_EQ(ScreenAsh::GetMaximizedWindowBoundsInParent(w2.get()).ToString(), | 721 EXPECT_EQ(ScreenAsh::GetMaximizedWindowBoundsInParent(w2.get()).ToString(), |
| 750 w2->bounds().ToString()); | 722 w2->bounds().ToString()); |
| 751 | 723 |
| 752 // Turn off auto-hide, switch back to w2 (maximized) and verify overlap. | 724 // Turn off auto-hide, switch back to w2 (maximized) and verify overlap. |
| 753 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); | 725 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); |
| 754 wm::ActivateWindow(w2.get()); | 726 wm::ActivateWindow(w2.get()); |
| 755 EXPECT_FALSE(GetWindowOverlapsShelf()); | 727 EXPECT_FALSE(GetWindowOverlapsShelf()); |
| 756 | 728 |
| 757 // Move w1 to overlap shelf, it shouldn't change window overlaps shelf since | 729 // Move w1 to overlap shelf, it shouldn't change window overlaps shelf since |
| 758 // the window isn't in the visible workspace. | 730 // the window isn't in the visible workspace. |
| 759 w1->SetBounds(touches_shelf_bounds); | 731 w1->SetBounds(touches_shelf_bounds); |
| 760 EXPECT_FALSE(GetWindowOverlapsShelf()); | 732 EXPECT_FALSE(GetWindowOverlapsShelf()); |
| 761 | 733 |
| 762 // Activate w1. Since w1 is visible the overlap state should be true. | 734 // Activate w1. Although w1 is visible, the overlap state is still false since |
| 735 // w2 is maximized. | |
| 763 wm::ActivateWindow(w1.get()); | 736 wm::ActivateWindow(w1.get()); |
| 737 EXPECT_FALSE(GetWindowOverlapsShelf()); | |
| 738 | |
| 739 // Restore w2. | |
| 740 w2->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); | |
| 764 EXPECT_TRUE(GetWindowOverlapsShelf()); | 741 EXPECT_TRUE(GetWindowOverlapsShelf()); |
| 765 } | 742 } |
| 766 | 743 |
| 767 // Verifies persist across all workspaces. | 744 // Verifies persist across all workspaces. |
| 768 TEST_F(WorkspaceManagerTest, PersistAcrossAllWorkspaces) { | 745 TEST_F(WorkspaceManagerTest, PersistAcrossAllWorkspaces) { |
| 769 // Create a maximized window. | 746 // Create a maximized window. |
| 770 scoped_ptr<Window> w1(CreateTestWindow()); | 747 scoped_ptr<Window> w1(CreateTestWindow()); |
| 771 w1->Show(); | 748 w1->Show(); |
| 772 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); | 749 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); |
| 773 wm::ActivateWindow(w1.get()); | 750 wm::ActivateWindow(w1.get()); |
| 774 ASSERT_EQ("0 M1 active=1", StateString()); | 751 ASSERT_EQ("1 active=0", StateString()); |
| 775 | 752 |
| 776 // Create a window that persists across all workspaces. It should be placed in | 753 // Create a window that persists across all workspaces. It should be placed in |
| 777 // the current maximized workspace. | 754 // the current maximized workspace. |
| 778 scoped_ptr<Window> w2(CreateTestWindow()); | 755 scoped_ptr<Window> w2(CreateTestWindow()); |
| 779 SetPersistsAcrossAllWorkspaces( | 756 SetPersistsAcrossAllWorkspaces( |
| 780 w2.get(), | 757 w2.get(), |
| 781 WINDOW_PERSISTS_ACROSS_ALL_WORKSPACES_VALUE_YES); | 758 WINDOW_PERSISTS_ACROSS_ALL_WORKSPACES_VALUE_YES); |
| 782 w2->Show(); | 759 w2->Show(); |
| 783 ASSERT_EQ("1 M1 active=1", StateString()); | 760 ASSERT_EQ("2 active=0", StateString()); |
| 784 | 761 |
| 785 // Activate w2, which should move it to the 2nd workspace. | 762 // Activate w2, which should move it to the 2nd workspace. |
| 786 wm::ActivateWindow(w2.get()); | 763 wm::ActivateWindow(w2.get()); |
| 787 ASSERT_EQ("0 M2 active=1", StateString()); | 764 ASSERT_EQ("2 active=0", StateString()); |
| 788 | 765 |
| 789 // Restoring w2 should drop the persists window back to the desktop, and drop | 766 // Restoring w2 should drop the persists window back to the desktop, and drop |
| 790 // it to the bottom of the stack. | 767 // it to the bottom of the stack. |
| 791 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); | 768 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); |
| 792 ASSERT_EQ("2 active=0", StateString()); | 769 ASSERT_EQ("2 active=0", StateString()); |
| 793 EXPECT_EQ(w2.get(), workspaces()[0]->window()->children()[0]); | 770 EXPECT_EQ(w2.get(), workspaces()[0]->window()->children()[1]); |
| 794 EXPECT_EQ(w1.get(), workspaces()[0]->window()->children()[1]); | 771 EXPECT_EQ(w1.get(), workspaces()[0]->window()->children()[0]); |
| 795 | 772 |
| 796 // Repeat, but this time minimize. The minimized window should end up in | 773 // Repeat, but this time minimize. The minimized window should end up in |
| 797 // pending. | 774 // pending. |
| 798 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); | 775 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); |
| 799 ASSERT_EQ("1 P=M1 active=0", StateString()); | 776 ASSERT_EQ("2 active=0", StateString()); |
| 800 w2.reset(CreateTestWindow()); | 777 w2.reset(CreateTestWindow()); |
| 801 SetPersistsAcrossAllWorkspaces( | 778 SetPersistsAcrossAllWorkspaces( |
| 802 w2.get(), | 779 w2.get(), |
| 803 WINDOW_PERSISTS_ACROSS_ALL_WORKSPACES_VALUE_YES); | 780 WINDOW_PERSISTS_ACROSS_ALL_WORKSPACES_VALUE_YES); |
| 804 w2->Show(); | 781 w2->Show(); |
| 805 ASSERT_EQ("1 P=M1 active=0", StateString()); | 782 ASSERT_EQ("2 active=0", StateString()); |
| 806 wm::ActivateWindow(w2.get()); | 783 wm::ActivateWindow(w2.get()); |
| 807 ASSERT_EQ("1 P=M1 active=0", StateString()); | 784 ASSERT_EQ("2 active=0", StateString()); |
| 808 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MINIMIZED); | 785 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MINIMIZED); |
| 809 ASSERT_EQ("1 P=M1 active=0", StateString()); | 786 ASSERT_EQ("2 active=0", StateString()); |
| 810 EXPECT_EQ(w2.get(), workspaces()[0]->window()->children()[0]); | 787 EXPECT_EQ(w2.get(), workspaces()[0]->window()->children()[1]); |
| 811 } | 788 } |
| 812 | 789 |
| 813 // Verifies that when a window persists across all workpaces is activated that | 790 // Verifies that when a window persists across all workpaces is activated that |
| 814 // it moves to the current workspace. | 791 // it moves to the current workspace. |
| 815 TEST_F(WorkspaceManagerTest, ActivatePersistAcrossAllWorkspacesWhenNotActive) { | 792 TEST_F(WorkspaceManagerTest, ActivatePersistAcrossAllWorkspacesWhenNotActive) { |
| 816 // Create a window that persists across all workspaces. | 793 // Create a window that persists across all workspaces. |
| 817 scoped_ptr<Window> w2(CreateTestWindow()); | 794 scoped_ptr<Window> w2(CreateTestWindow()); |
| 818 SetPersistsAcrossAllWorkspaces( | 795 SetPersistsAcrossAllWorkspaces( |
| 819 w2.get(), | 796 w2.get(), |
| 820 WINDOW_PERSISTS_ACROSS_ALL_WORKSPACES_VALUE_YES); | 797 WINDOW_PERSISTS_ACROSS_ALL_WORKSPACES_VALUE_YES); |
| 821 w2->Show(); | 798 w2->Show(); |
| 822 ASSERT_EQ("1 active=0", StateString()); | 799 ASSERT_EQ("1 active=0", StateString()); |
| 823 | 800 |
| 824 // Create a maximized window. | 801 // Create a maximized window. |
| 825 scoped_ptr<Window> w1(CreateTestWindow()); | 802 scoped_ptr<Window> w1(CreateTestWindow()); |
| 826 w1->Show(); | 803 w1->Show(); |
| 827 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); | 804 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); |
| 828 wm::ActivateWindow(w1.get()); | 805 wm::ActivateWindow(w1.get()); |
| 829 ASSERT_EQ("1 M1 active=1", StateString()); | 806 ASSERT_EQ("2 active=0", StateString()); |
| 830 | 807 |
| 831 // Activate the persists across all workspace window. It should move to the | 808 // Activate the persists across all workspace window. It should move to the |
| 832 // current workspace. | 809 // current workspace. |
| 833 wm::ActivateWindow(w2.get()); | 810 wm::ActivateWindow(w2.get()); |
| 834 ASSERT_EQ("0 M2 active=1", StateString()); | 811 ASSERT_EQ("2 active=0", StateString()); |
| 835 // The window that persists across all workspaces should be moved to the top | 812 // The window that persists across all workspaces should be moved to the top |
| 836 // of the stacking order. | 813 // of the stacking order. |
| 837 EXPECT_EQ(w1.get(), workspaces()[1]->window()->children()[0]); | 814 EXPECT_EQ(w1.get(), workspaces()[0]->window()->children()[0]); |
| 838 EXPECT_EQ(w2.get(), workspaces()[1]->window()->children()[1]); | 815 EXPECT_EQ(w2.get(), workspaces()[0]->window()->children()[1]); |
| 839 EXPECT_TRUE(wm::IsActiveWindow(w2.get())); | 816 EXPECT_TRUE(wm::IsActiveWindow(w2.get())); |
| 840 } | 817 } |
| 841 | 818 |
| 842 // Verifies Show()ing a minimized window that persists across all workspaces | 819 // Verifies Show()ing a minimized window that persists across all workspaces |
| 843 // unminimizes the window. | 820 // unminimizes the window. |
| 844 TEST_F(WorkspaceManagerTest, ShowMinimizedPersistWindow) { | 821 TEST_F(WorkspaceManagerTest, ShowMinimizedPersistWindow) { |
| 845 // Create a window that persists across all workspaces. | 822 // Create a window that persists across all workspaces. |
| 846 scoped_ptr<Window> w1(CreateTestWindow()); | 823 scoped_ptr<Window> w1(CreateTestWindow()); |
| 847 SetPersistsAcrossAllWorkspaces( | 824 SetPersistsAcrossAllWorkspaces( |
| 848 w1.get(), | 825 w1.get(), |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 893 w1->Show(); | 870 w1->Show(); |
| 894 | 871 |
| 895 scoped_ptr<Window> w2(CreateTestWindow()); | 872 scoped_ptr<Window> w2(CreateTestWindow()); |
| 896 w2->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN); | 873 w2->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN); |
| 897 SetPersistsAcrossAllWorkspaces( | 874 SetPersistsAcrossAllWorkspaces( |
| 898 w2.get(), | 875 w2.get(), |
| 899 WINDOW_PERSISTS_ACROSS_ALL_WORKSPACES_VALUE_YES); | 876 WINDOW_PERSISTS_ACROSS_ALL_WORKSPACES_VALUE_YES); |
| 900 w2->Show(); | 877 w2->Show(); |
| 901 wm::ActivateWindow(w2.get()); | 878 wm::ActivateWindow(w2.get()); |
| 902 | 879 |
| 903 ASSERT_EQ("1 M1 active=1", StateString()); | 880 ASSERT_EQ("1 F1 active=1", StateString()); |
| 904 | 881 |
| 905 EXPECT_EQ(SHELF_HIDDEN, shelf->visibility_state()); | 882 EXPECT_EQ(SHELF_HIDDEN, shelf->visibility_state()); |
| 906 EXPECT_EQ(WORKSPACE_WINDOW_STATE_FULL_SCREEN, manager_->GetWindowState()); | 883 EXPECT_EQ(WORKSPACE_WINDOW_STATE_FULL_SCREEN, manager_->GetWindowState()); |
| 907 | 884 |
| 908 w2->Hide(); | 885 w2->Hide(); |
| 909 ASSERT_EQ("1 P=M1 active=0", StateString()); | 886 ASSERT_EQ("1 P=F1 active=0", StateString()); |
| 910 EXPECT_EQ(SHELF_VISIBLE, shelf->visibility_state()); | 887 EXPECT_EQ(SHELF_VISIBLE, shelf->visibility_state()); |
| 911 | 888 |
| 912 w2->Show(); | 889 w2->Show(); |
| 913 ASSERT_EQ("1 P=M1 active=0", StateString()); | 890 ASSERT_EQ("1 P=F1 active=0", StateString()); |
| 914 EXPECT_EQ(SHELF_VISIBLE, shelf->visibility_state()); | 891 EXPECT_EQ(SHELF_VISIBLE, shelf->visibility_state()); |
| 915 EXPECT_EQ(WORKSPACE_WINDOW_STATE_DEFAULT, manager_->GetWindowState()); | 892 EXPECT_EQ(WORKSPACE_WINDOW_STATE_DEFAULT, manager_->GetWindowState()); |
| 916 | 893 |
| 917 wm::ActivateWindow(w2.get()); | 894 wm::ActivateWindow(w2.get()); |
| 918 ASSERT_EQ("1 M1 active=1", StateString()); | 895 ASSERT_EQ("1 F1 active=1", StateString()); |
| 919 EXPECT_EQ(SHELF_HIDDEN, shelf->visibility_state()); | 896 EXPECT_EQ(SHELF_HIDDEN, shelf->visibility_state()); |
| 920 EXPECT_EQ(WORKSPACE_WINDOW_STATE_FULL_SCREEN, manager_->GetWindowState()); | 897 EXPECT_EQ(WORKSPACE_WINDOW_STATE_FULL_SCREEN, manager_->GetWindowState()); |
| 921 | 898 |
| 922 w2.reset(); | 899 w2.reset(); |
| 923 ASSERT_EQ("1 active=0", StateString()); | 900 ASSERT_EQ("1 active=0", StateString()); |
| 924 EXPECT_EQ(SHELF_VISIBLE, shelf->visibility_state()); | 901 EXPECT_EQ(SHELF_VISIBLE, shelf->visibility_state()); |
| 925 EXPECT_EQ(WORKSPACE_WINDOW_STATE_DEFAULT, manager_->GetWindowState()); | 902 EXPECT_EQ(WORKSPACE_WINDOW_STATE_DEFAULT, manager_->GetWindowState()); |
| 926 } | 903 } |
| 927 | 904 |
| 928 // Variant of GetWindowStateWithUnmanagedFullscreenWindow that uses a maximized | 905 // Variant of GetWindowStateWithUnmanagedFullscreenWindow that uses a maximized |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 971 | 948 |
| 972 SetPersistsAcrossAllWorkspaces( | 949 SetPersistsAcrossAllWorkspaces( |
| 973 w1.get(), | 950 w1.get(), |
| 974 WINDOW_PERSISTS_ACROSS_ALL_WORKSPACES_VALUE_YES); | 951 WINDOW_PERSISTS_ACROSS_ALL_WORKSPACES_VALUE_YES); |
| 975 w1->Show(); | 952 w1->Show(); |
| 976 | 953 |
| 977 ASSERT_EQ("1 active=0", StateString()); | 954 ASSERT_EQ("1 active=0", StateString()); |
| 978 | 955 |
| 979 // Maximize should trigger containing the window. | 956 // Maximize should trigger containing the window. |
| 980 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); | 957 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); |
| 981 ASSERT_EQ("0 P=M1 active=0", StateString()); | 958 ASSERT_EQ("1 active=0", StateString()); |
| 982 | 959 |
| 983 // And resetting to normal should remove it. | 960 // And resetting to normal should remove it. |
| 984 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); | 961 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); |
| 985 ASSERT_EQ("1 active=0", StateString()); | 962 ASSERT_EQ("1 active=0", StateString()); |
| 986 } | 963 } |
| 987 | 964 |
| 988 // Verifies going from maximized to minimized sets the right state for painting | 965 // Verifies going from maximized to minimized sets the right state for painting |
| 989 // the background of the launcher. | 966 // the background of the launcher. |
| 990 TEST_F(WorkspaceManagerTest, MinimizeResetsVisibility) { | 967 TEST_F(WorkspaceManagerTest, MinimizeResetsVisibility) { |
| 991 scoped_ptr<Window> w1(CreateTestWindow()); | 968 scoped_ptr<Window> w1(CreateTestWindow()); |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 1002 TEST_F(WorkspaceManagerTest, MoveTransientOnMaximize) { | 979 TEST_F(WorkspaceManagerTest, MoveTransientOnMaximize) { |
| 1003 scoped_ptr<Window> w1(CreateTestWindow()); | 980 scoped_ptr<Window> w1(CreateTestWindow()); |
| 1004 w1->Show(); | 981 w1->Show(); |
| 1005 scoped_ptr<Window> w2(CreateTestWindow()); | 982 scoped_ptr<Window> w2(CreateTestWindow()); |
| 1006 w1->AddTransientChild(w2.get()); | 983 w1->AddTransientChild(w2.get()); |
| 1007 w2->Show(); | 984 w2->Show(); |
| 1008 wm::ActivateWindow(w1.get()); | 985 wm::ActivateWindow(w1.get()); |
| 1009 ASSERT_EQ("2 active=0", StateString()); | 986 ASSERT_EQ("2 active=0", StateString()); |
| 1010 | 987 |
| 1011 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); | 988 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); |
| 1012 ASSERT_EQ("0 M2 active=1", StateString()); | 989 ASSERT_EQ("2 active=0", StateString()); |
| 1013 EXPECT_TRUE(wm::IsActiveWindow(w1.get())); | 990 EXPECT_TRUE(wm::IsActiveWindow(w1.get())); |
| 1014 | 991 |
| 1015 // Create another transient child of |w1|. We do this unparented, set up the | 992 // Create another transient child of |w1|. We do this unparented, set up the |
| 1016 // transient parent then set parent. This is how NativeWidgetAura does things | 993 // transient parent then set parent. This is how NativeWidgetAura does things |
| 1017 // too. | 994 // too. |
| 1018 scoped_ptr<Window> w3(CreateTestWindowUnparented()); | 995 scoped_ptr<Window> w3(CreateTestWindowUnparented()); |
| 1019 w1->AddTransientChild(w3.get()); | 996 w1->AddTransientChild(w3.get()); |
| 1020 SetDefaultParentByPrimaryRootWindow(w3.get()); | 997 SetDefaultParentByPrimaryRootWindow(w3.get()); |
| 1021 w3->Show(); | 998 w3->Show(); |
| 1022 ASSERT_EQ("0 M3 active=1", StateString()); | 999 ASSERT_EQ("3 active=0", StateString()); |
| 1023 | 1000 |
| 1024 // Minimize the window. All the transients are hidden as a result, so it ends | 1001 // Minimize the window. All the transients are hidden as a result, so it ends |
| 1025 // up in pending. | 1002 // up in pending. |
| 1026 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MINIMIZED); | 1003 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MINIMIZED); |
| 1027 ASSERT_EQ("0 P=M3 active=0", StateString()); | 1004 ASSERT_EQ("3 active=0", StateString()); |
| 1028 | 1005 |
| 1029 // Restore and everything should go back to the first workspace. | 1006 // Restore and everything should go back to the first workspace. |
| 1030 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); | 1007 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); |
| 1031 ASSERT_EQ("3 active=0", StateString()); | 1008 ASSERT_EQ("3 active=0", StateString()); |
| 1032 } | 1009 } |
| 1033 | 1010 |
| 1034 // Verifies window visibility during various workspace changes. | 1011 // Verifies window visibility during various workspace changes. |
| 1035 TEST_F(WorkspaceManagerTest, VisibilityTests) { | 1012 TEST_F(WorkspaceManagerTest, VisibilityTests) { |
| 1036 scoped_ptr<Window> w1(CreateTestWindow()); | 1013 scoped_ptr<Window> w1(CreateTestWindow()); |
| 1037 w1->Show(); | 1014 w1->Show(); |
| 1038 EXPECT_TRUE(w1->IsVisible()); | 1015 EXPECT_TRUE(w1->IsVisible()); |
| 1039 EXPECT_EQ(1.0f, w1->layer()->GetCombinedOpacity()); | 1016 EXPECT_EQ(1.0f, w1->layer()->GetCombinedOpacity()); |
| 1040 | 1017 |
| 1041 // Create another window, activate it and maximized it. | 1018 // Create another window, activate it and maximized it. |
| 1042 scoped_ptr<Window> w2(CreateTestWindow()); | 1019 scoped_ptr<Window> w2(CreateTestWindow()); |
| 1043 w2->Show(); | 1020 w2->Show(); |
| 1044 wm::ActivateWindow(w2.get()); | 1021 wm::ActivateWindow(w2.get()); |
| 1045 w2->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); | 1022 w2->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); |
| 1046 EXPECT_TRUE(w2->IsVisible()); | 1023 EXPECT_TRUE(w2->IsVisible()); |
| 1047 EXPECT_EQ(1.0f, w2->layer()->GetCombinedOpacity()); | 1024 EXPECT_EQ(1.0f, w2->layer()->GetCombinedOpacity()); |
| 1048 EXPECT_FALSE(w1->IsVisible()); | 1025 EXPECT_TRUE(w1->IsVisible()); |
| 1049 | 1026 |
| 1050 // Switch to w1. |w1| should be visible and |w2| hidden. | 1027 // Switch to w1. |w1| should be visible and |w2| hidden. |
| 1051 wm::ActivateWindow(w1.get()); | 1028 wm::ActivateWindow(w1.get()); |
| 1052 EXPECT_TRUE(w1->IsVisible()); | 1029 EXPECT_TRUE(w1->IsVisible()); |
| 1053 EXPECT_EQ(1.0f, w1->layer()->GetCombinedOpacity()); | 1030 EXPECT_EQ(1.0f, w1->layer()->GetCombinedOpacity()); |
| 1054 EXPECT_FALSE(w2->IsVisible()); | 1031 EXPECT_TRUE(w2->IsVisible()); |
| 1055 | 1032 |
| 1056 // Switch back to |w2|. | 1033 // Switch back to |w2|. |
| 1057 wm::ActivateWindow(w2.get()); | 1034 wm::ActivateWindow(w2.get()); |
| 1058 EXPECT_TRUE(w2->IsVisible()); | 1035 EXPECT_TRUE(w2->IsVisible()); |
| 1059 EXPECT_EQ(1.0f, w2->layer()->GetCombinedOpacity()); | 1036 EXPECT_EQ(1.0f, w2->layer()->GetCombinedOpacity()); |
| 1060 EXPECT_FALSE(w1->IsVisible()); | 1037 EXPECT_TRUE(w1->IsVisible()); |
| 1061 | 1038 |
| 1062 // Restore |w2|, both windows should be visible. | 1039 // Restore |w2|, both windows should be visible. |
| 1063 w2->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); | 1040 w2->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); |
| 1064 EXPECT_TRUE(w1->IsVisible()); | 1041 EXPECT_TRUE(w1->IsVisible()); |
| 1065 EXPECT_EQ(1.0f, w1->layer()->GetCombinedOpacity()); | 1042 EXPECT_EQ(1.0f, w1->layer()->GetCombinedOpacity()); |
| 1066 EXPECT_TRUE(w2->IsVisible()); | 1043 EXPECT_TRUE(w2->IsVisible()); |
| 1067 EXPECT_EQ(1.0f, w2->layer()->GetCombinedOpacity()); | 1044 EXPECT_EQ(1.0f, w2->layer()->GetCombinedOpacity()); |
| 1068 | 1045 |
| 1069 // Maximize |w2| again, then close it. | 1046 // Maximize |w2| again, then close it. |
| 1070 w2->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); | 1047 w2->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1278 // Because |w2| isn't tracked we should be able to set the bounds of it. | 1255 // Because |w2| isn't tracked we should be able to set the bounds of it. |
| 1279 gfx::Rect bounds(w2->bounds()); | 1256 gfx::Rect bounds(w2->bounds()); |
| 1280 bounds.Offset(4, 5); | 1257 bounds.Offset(4, 5); |
| 1281 w2->SetBounds(bounds); | 1258 w2->SetBounds(bounds); |
| 1282 EXPECT_EQ(bounds.ToString(), w2->bounds().ToString()); | 1259 EXPECT_EQ(bounds.ToString(), w2->bounds().ToString()); |
| 1283 | 1260 |
| 1284 // Transition it to tracked by worskpace. It should end up in its own | 1261 // Transition it to tracked by worskpace. It should end up in its own |
| 1285 // workspace. | 1262 // workspace. |
| 1286 SetTrackedByWorkspace(w2.get(), true); | 1263 SetTrackedByWorkspace(w2.get(), true); |
| 1287 EXPECT_TRUE(wm::IsActiveWindow(w2.get())); | 1264 EXPECT_TRUE(wm::IsActiveWindow(w2.get())); |
| 1288 EXPECT_FALSE(w1->IsVisible()); | 1265 EXPECT_TRUE(w1->IsVisible()); |
| 1289 EXPECT_TRUE(w2->IsVisible()); | 1266 EXPECT_TRUE(w2->IsVisible()); |
| 1290 EXPECT_NE(w1->parent(), w2->parent()); | 1267 EXPECT_EQ(w1->parent(), w2->parent()); |
| 1291 } | 1268 } |
| 1292 | 1269 |
| 1293 // Verifies a window marked as persisting across all workspaces ends up in its | 1270 // Verifies a window marked as persisting across all workspaces ends up in its |
| 1294 // own workspace when maximized. | 1271 // own workspace when maximized. |
| 1295 TEST_F(WorkspaceManagerTest, DeactivateDropsToDesktop) { | 1272 TEST_F(WorkspaceManagerTest, DeactivateDropsToDesktop) { |
| 1296 // Create a window maximized. | 1273 // Create a window maximized. |
| 1297 scoped_ptr<Window> w1(CreateTestWindow()); | 1274 scoped_ptr<Window> w1(CreateTestWindow()); |
| 1298 w1->Show(); | 1275 w1->Show(); |
| 1299 wm::ActivateWindow(w1.get()); | 1276 wm::ActivateWindow(w1.get()); |
| 1300 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); | 1277 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); |
| 1301 EXPECT_TRUE(wm::IsActiveWindow(w1.get())); | 1278 EXPECT_TRUE(wm::IsActiveWindow(w1.get())); |
| 1302 EXPECT_TRUE(w1->IsVisible()); | 1279 EXPECT_TRUE(w1->IsVisible()); |
| 1303 | 1280 |
| 1304 // Create another window that persists across all workspaces. It should end | 1281 // Create another window that persists across all workspaces. It should end |
| 1305 // up with the same parent as |w1|. | 1282 // up with the same parent as |w1|. |
| 1306 scoped_ptr<Window> w2(CreateTestWindow()); | 1283 scoped_ptr<Window> w2(CreateTestWindow()); |
| 1307 SetPersistsAcrossAllWorkspaces( | 1284 SetPersistsAcrossAllWorkspaces( |
| 1308 w2.get(), | 1285 w2.get(), |
| 1309 WINDOW_PERSISTS_ACROSS_ALL_WORKSPACES_VALUE_YES); | 1286 WINDOW_PERSISTS_ACROSS_ALL_WORKSPACES_VALUE_YES); |
| 1310 w2->Show(); | 1287 w2->Show(); |
| 1311 wm::ActivateWindow(w2.get()); | 1288 wm::ActivateWindow(w2.get()); |
| 1312 EXPECT_EQ(w1->parent(), w2->parent()); | 1289 EXPECT_EQ(w1->parent(), w2->parent()); |
| 1313 ASSERT_EQ("0 M2 active=1", StateString()); | 1290 ASSERT_EQ("2 active=0", StateString()); |
| 1314 | 1291 |
| 1315 // Activate |w1|, should result in dropping |w2| to the desktop. | 1292 // Activate |w1|, should result in dropping |w2| to the desktop. |
| 1316 wm::ActivateWindow(w1.get()); | 1293 wm::ActivateWindow(w1.get()); |
| 1317 ASSERT_EQ("1 M1 active=1", StateString()); | 1294 ASSERT_EQ("2 active=0", StateString()); |
| 1318 } | 1295 } |
| 1319 | 1296 |
| 1320 // Test the basic auto placement of one and or two windows in a "simulated | 1297 // Test the basic auto placement of one and or two windows in a "simulated |
| 1321 // session" of sequential window operations. | 1298 // session" of sequential window operations. |
| 1322 TEST_F(WorkspaceManagerTest, BasicAutoPlacing) { | 1299 TEST_F(WorkspaceManagerTest, BasicAutoPlacing) { |
| 1323 // Test 1: In case there is no manageable window, no window should shift. | 1300 // Test 1: In case there is no manageable window, no window should shift. |
| 1324 | 1301 |
| 1325 scoped_ptr<aura::Window> window1(CreateTestWindowInShellWithId(0)); | 1302 scoped_ptr<aura::Window> window1(CreateTestWindowInShellWithId(0)); |
| 1326 window1->SetBounds(gfx::Rect(16, 32, 640, 320)); | 1303 window1->SetBounds(gfx::Rect(16, 32, 640, 320)); |
| 1327 gfx::Rect desktop_area = window1->parent()->bounds(); | 1304 gfx::Rect desktop_area = window1->parent()->bounds(); |
| (...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1748 SetDefaultParentByPrimaryRootWindow(w1.get()); | 1725 SetDefaultParentByPrimaryRootWindow(w1.get()); |
| 1749 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); | 1726 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); |
| 1750 w1->Show(); | 1727 w1->Show(); |
| 1751 wm::ActivateWindow(w1.get()); | 1728 wm::ActivateWindow(w1.get()); |
| 1752 DragMaximizedNonTrackedWindowObserver observer; | 1729 DragMaximizedNonTrackedWindowObserver observer; |
| 1753 w1->parent()->parent()->AddObserver(&observer); | 1730 w1->parent()->parent()->AddObserver(&observer); |
| 1754 const gfx::Rect max_bounds(w1->bounds()); | 1731 const gfx::Rect max_bounds(w1->bounds()); |
| 1755 | 1732 |
| 1756 // There should be two workspace, one for the desktop and one for the | 1733 // There should be two workspace, one for the desktop and one for the |
| 1757 // maximized window with the maximized active. | 1734 // maximized window with the maximized active. |
| 1758 EXPECT_EQ("0 M1 active=1", StateString()); | 1735 EXPECT_EQ("1 active=0", StateString()); |
| 1759 | 1736 |
| 1760 generator.PressLeftButton(); | 1737 generator.PressLeftButton(); |
| 1761 generator.MoveMouseTo(100, 100); | 1738 generator.MoveMouseTo(100, 100); |
| 1762 // The bounds shouldn't change (drag should result in nothing happening | 1739 // The bounds shouldn't change (drag should result in nothing happening |
| 1763 // now. | 1740 // now. |
| 1764 EXPECT_EQ(max_bounds.ToString(), w1->bounds().ToString()); | 1741 EXPECT_EQ(max_bounds.ToString(), w1->bounds().ToString()); |
| 1765 EXPECT_EQ("0 M1 active=1", StateString()); | 1742 EXPECT_EQ("1 active=0", StateString()); |
| 1766 | 1743 |
| 1767 generator.ReleaseLeftButton(); | 1744 generator.ReleaseLeftButton(); |
| 1768 EXPECT_EQ(0, observer.change_count()); | 1745 EXPECT_EQ(0, observer.change_count()); |
| 1769 | 1746 |
| 1770 // Set tracked to false and repeat, now the window should move. | 1747 // Set tracked to false and repeat, now the window should move. |
| 1771 SetTrackedByWorkspace(w1.get(), false); | 1748 SetTrackedByWorkspace(w1.get(), false); |
| 1772 generator.MoveMouseTo(5, 5); | 1749 generator.MoveMouseTo(5, 5); |
| 1773 generator.PressLeftButton(); | 1750 generator.PressLeftButton(); |
| 1774 generator.MoveMouseBy(100, 100); | 1751 generator.MoveMouseBy(100, 100); |
| 1775 EXPECT_EQ(gfx::Rect(max_bounds.x() + 100, max_bounds.y() + 100, | 1752 EXPECT_EQ(gfx::Rect(max_bounds.x() + 100, max_bounds.y() + 100, |
| 1776 max_bounds.width(), max_bounds.height()).ToString(), | 1753 max_bounds.width(), max_bounds.height()).ToString(), |
| 1777 w1->bounds().ToString()); | 1754 w1->bounds().ToString()); |
| 1778 EXPECT_EQ("0 M1 active=1", StateString()); | 1755 EXPECT_EQ("1 active=0", StateString()); |
| 1779 | 1756 |
| 1780 generator.ReleaseLeftButton(); | 1757 generator.ReleaseLeftButton(); |
| 1781 SetTrackedByWorkspace(w1.get(), true); | 1758 SetTrackedByWorkspace(w1.get(), true); |
| 1782 // Marking the window tracked again should snap back to origin. | 1759 // Marking the window tracked again should snap back to origin. |
| 1783 EXPECT_EQ("0 M1 active=1", StateString()); | 1760 EXPECT_EQ("1 active=0", StateString()); |
| 1784 EXPECT_EQ(max_bounds.ToString(), w1->bounds().ToString()); | 1761 EXPECT_EQ(max_bounds.ToString(), w1->bounds().ToString()); |
| 1785 EXPECT_EQ(0, observer.change_count()); | 1762 EXPECT_EQ(0, observer.change_count()); |
| 1786 | 1763 |
| 1787 w1->parent()->parent()->RemoveObserver(&observer); | 1764 w1->parent()->parent()->RemoveObserver(&observer); |
| 1788 } | 1765 } |
| 1789 | 1766 |
| 1790 // Verifies that a new maximized window becomes visible after its activation | 1767 // Verifies that a new maximized window becomes visible after its activation |
| 1791 // is requested, even though it does not become activated because a system | 1768 // is requested, even though it does not become activated because a system |
| 1792 // modal window is active. | 1769 // modal window is active. |
| 1793 TEST_F(WorkspaceManagerTest, SwitchFromModal) { | 1770 TEST_F(WorkspaceManagerTest, SwitchFromModal) { |
| 1794 scoped_ptr<Window> modal_window(CreateTestWindowUnparented()); | 1771 scoped_ptr<Window> modal_window(CreateTestWindowUnparented()); |
| 1795 modal_window->SetBounds(gfx::Rect(10, 11, 21, 22)); | 1772 modal_window->SetBounds(gfx::Rect(10, 11, 21, 22)); |
| 1796 modal_window->SetProperty(aura::client::kModalKey, ui::MODAL_TYPE_SYSTEM); | 1773 modal_window->SetProperty(aura::client::kModalKey, ui::MODAL_TYPE_SYSTEM); |
| 1797 SetDefaultParentByPrimaryRootWindow(modal_window.get()); | 1774 SetDefaultParentByPrimaryRootWindow(modal_window.get()); |
| 1798 modal_window->Show(); | 1775 modal_window->Show(); |
| 1799 wm::ActivateWindow(modal_window.get()); | 1776 wm::ActivateWindow(modal_window.get()); |
| 1800 | 1777 |
| 1801 scoped_ptr<Window> maximized_window(CreateTestWindow()); | 1778 scoped_ptr<Window> maximized_window(CreateTestWindow()); |
| 1802 maximized_window->SetProperty( | 1779 maximized_window->SetProperty( |
| 1803 aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); | 1780 aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); |
| 1804 maximized_window->Show(); | 1781 maximized_window->Show(); |
| 1805 wm::ActivateWindow(maximized_window.get()); | 1782 wm::ActivateWindow(maximized_window.get()); |
| 1806 EXPECT_TRUE(maximized_window->IsVisible()); | 1783 EXPECT_TRUE(maximized_window->IsVisible()); |
| 1807 } | 1784 } |
| 1808 | 1785 |
| 1809 } // namespace internal | 1786 } // namespace internal |
| 1810 } // namespace ash | 1787 } // namespace ash |
| OLD | NEW |