| 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, maximized window doesn't create its own 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()); | |
| 276 EXPECT_EQ(w1.get(), workspaces()[0]->window()->children()[0]); | 274 EXPECT_EQ(w1.get(), workspaces()[0]->window()->children()[0]); |
| 277 EXPECT_EQ("0,0 250x251", w1->bounds().ToString()); | 275 EXPECT_EQ("0,0 250x251", w1->bounds().ToString()); |
| 278 } | 276 } |
| 279 | 277 |
| 280 // Assertions around closing the last window in a workspace. | 278 // Assertions around closing the last window in a workspace. |
| 281 TEST_F(WorkspaceManagerTest, CloseLastWindowInWorkspace) { | 279 TEST_F(WorkspaceManagerTest, CloseLastWindowInWorkspace) { |
| 282 scoped_ptr<Window> w1(CreateTestWindow()); | 280 scoped_ptr<Window> w1(CreateTestWindow()); |
| 283 scoped_ptr<Window> w2(CreateTestWindow()); | 281 scoped_ptr<Window> w2(CreateTestWindow()); |
| 284 w1->SetBounds(gfx::Rect(0, 0, 250, 251)); | 282 w1->SetBounds(gfx::Rect(0, 0, 250, 251)); |
| 285 w1->Show(); | 283 w1->Show(); |
| 286 w2->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); | 284 w2->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN); |
| 287 w2->Show(); | 285 w2->Show(); |
| 288 wm::ActivateWindow(w1.get()); | 286 wm::ActivateWindow(w1.get()); |
| 289 | 287 |
| 290 // Should be 1 workspace and 1 pending, !maximized and maximized. The second | 288 // Should be 1 workspace and 1 pending, !fullscreen and fullsceen. The second |
| 291 // workspace is pending since the window wasn't active. | 289 // workspace is pending since the window wasn't active. |
| 292 ASSERT_EQ("1 P=M1 active=0", StateString()); | 290 ASSERT_EQ("1 P=F1 active=0", StateString()); |
| 293 EXPECT_EQ(w1.get(), workspaces()[0]->window()->children()[0]); | 291 EXPECT_EQ(w1.get(), workspaces()[0]->window()->children()[0]); |
| 294 | 292 |
| 295 // Close w2. | 293 // Close w2. |
| 296 w2.reset(); | 294 w2.reset(); |
| 297 | 295 |
| 298 // Should have one workspace. | 296 // Should have one workspace. |
| 299 ASSERT_EQ("1 active=0", StateString()); | 297 ASSERT_EQ("1 active=0", StateString()); |
| 300 EXPECT_EQ(w1.get(), workspaces()[0]->window()->children()[0]); | 298 EXPECT_EQ(w1.get(), workspaces()[0]->window()->children()[0]); |
| 301 EXPECT_TRUE(w1->IsVisible()); | 299 EXPECT_TRUE(w1->IsVisible()); |
| 302 } | 300 } |
| 303 | 301 |
| 304 // Assertions around adding a maximized window when empty. | 302 // Assertions around adding a fullscreen window when empty. |
| 305 TEST_F(WorkspaceManagerTest, AddMaximizedWindowWhenEmpty) { | 303 TEST_F(WorkspaceManagerTest, AddFullscreenWindowWhenEmpty) { |
| 306 scoped_ptr<Window> w1(CreateTestWindow()); | 304 scoped_ptr<Window> w1(CreateTestWindow()); |
| 307 w1->SetBounds(gfx::Rect(0, 0, 250, 251)); | 305 w1->SetBounds(gfx::Rect(0, 0, 250, 251)); |
| 308 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); | 306 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN); |
| 309 w1->Show(); | 307 w1->Show(); |
| 310 wm::ActivateWindow(w1.get()); | 308 wm::ActivateWindow(w1.get()); |
| 311 | 309 |
| 312 ASSERT_TRUE(w1->layer() != NULL); | 310 ASSERT_TRUE(w1->layer() != NULL); |
| 313 EXPECT_TRUE(w1->layer()->visible()); | 311 EXPECT_TRUE(w1->layer()->visible()); |
| 314 gfx::Rect work_area( | 312 gfx::Rect fullscreen_area = w1->GetRootWindow()->bounds(); |
| 315 ScreenAsh::GetMaximizedWindowBoundsInParent(w1.get())); | 313 EXPECT_EQ(fullscreen_area.width(), w1->bounds().width()); |
| 316 EXPECT_EQ(work_area.width(), w1->bounds().width()); | 314 EXPECT_EQ(fullscreen_area.height(), w1->bounds().height()); |
| 317 EXPECT_EQ(work_area.height(), w1->bounds().height()); | |
| 318 | 315 |
| 319 // Should be 2 workspaces (since we always keep the desktop). | 316 // Should be 2 workspaces (since we always keep the desktop). |
| 320 ASSERT_EQ("0 M1 active=1", StateString()); | 317 ASSERT_EQ("0 F1 active=1", StateString()); |
| 321 EXPECT_EQ(w1.get(), workspaces()[1]->window()->children()[0]); | 318 EXPECT_EQ(w1.get(), workspaces()[1]->window()->children()[0]); |
| 322 } | 319 } |
| 323 | 320 |
| 324 // Assertions around two windows and toggling one to be maximized. | 321 // Assertions around two windows and toggling one to be fullscreen. |
| 325 TEST_F(WorkspaceManagerTest, MaximizeWithNormalWindow) { | 322 TEST_F(WorkspaceManagerTest, FullscreenWithNormalWindow) { |
| 326 scoped_ptr<Window> w1(CreateTestWindow()); | 323 scoped_ptr<Window> w1(CreateTestWindow()); |
| 327 scoped_ptr<Window> w2(CreateTestWindow()); | 324 scoped_ptr<Window> w2(CreateTestWindow()); |
| 328 w1->SetBounds(gfx::Rect(0, 0, 250, 251)); | 325 w1->SetBounds(gfx::Rect(0, 0, 250, 251)); |
| 329 w1->Show(); | 326 w1->Show(); |
| 330 | 327 |
| 331 ASSERT_TRUE(w1->layer() != NULL); | 328 ASSERT_TRUE(w1->layer() != NULL); |
| 332 EXPECT_TRUE(w1->layer()->visible()); | 329 EXPECT_TRUE(w1->layer()->visible()); |
| 333 | 330 |
| 334 w2->SetBounds(gfx::Rect(0, 0, 50, 51)); | 331 w2->SetBounds(gfx::Rect(0, 0, 50, 51)); |
| 335 w2->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); | 332 w2->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN); |
| 336 w2->Show(); | 333 w2->Show(); |
| 337 wm::ActivateWindow(w2.get()); | 334 wm::ActivateWindow(w2.get()); |
| 338 | 335 |
| 339 // Should now be two workspaces. | 336 // Should now be two workspaces. |
| 340 ASSERT_EQ("1 M1 active=1", StateString()); | 337 ASSERT_EQ("1 F1 active=1", StateString()); |
| 341 EXPECT_EQ(w1.get(), workspaces()[0]->window()->children()[0]); | 338 EXPECT_EQ(w1.get(), workspaces()[0]->window()->children()[0]); |
| 342 EXPECT_EQ(w2.get(), workspaces()[1]->window()->children()[0]); | 339 EXPECT_EQ(w2.get(), workspaces()[1]->window()->children()[0]); |
| 343 | 340 |
| 344 gfx::Rect work_area(ScreenAsh::GetMaximizedWindowBoundsInParent(w1.get())); | 341 gfx::Rect fullscreen_area = w1->GetRootWindow()->bounds(); |
| 345 EXPECT_EQ(work_area.width(), w2->bounds().width()); | 342 EXPECT_EQ(fullscreen_area.width(), w2->bounds().width()); |
| 346 EXPECT_EQ(work_area.height(), w2->bounds().height()); | 343 EXPECT_EQ(fullscreen_area.height(), w2->bounds().height()); |
| 347 | 344 |
| 348 // Restore w2, which should then go back to one workspace. | 345 // Restore w2, which should then go back to one workspace. |
| 349 w2->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); | 346 w2->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); |
| 350 ASSERT_EQ("2 active=0", StateString()); | 347 ASSERT_EQ("2 active=0", StateString()); |
| 351 EXPECT_EQ(w1.get(), workspaces()[0]->window()->children()[0]); | 348 EXPECT_EQ(w1.get(), workspaces()[0]->window()->children()[0]); |
| 352 EXPECT_EQ(w2.get(), workspaces()[0]->window()->children()[1]); | 349 EXPECT_EQ(w2.get(), workspaces()[0]->window()->children()[1]); |
| 353 EXPECT_EQ(50, w2->bounds().width()); | 350 EXPECT_EQ(50, w2->bounds().width()); |
| 354 EXPECT_EQ(51, w2->bounds().height()); | 351 EXPECT_EQ(51, w2->bounds().height()); |
| 355 EXPECT_TRUE(wm::IsActiveWindow(w2.get())); | 352 EXPECT_TRUE(wm::IsActiveWindow(w2.get())); |
| 356 } | 353 } |
| 357 | 354 |
| 358 // Assertions around two maximized windows. | 355 // Assertions around two fullscreen windows. |
| 359 TEST_F(WorkspaceManagerTest, TwoMaximized) { | 356 TEST_F(WorkspaceManagerTest, TwoFullscreen) { |
| 360 scoped_ptr<Window> w1(CreateTestWindow()); | 357 scoped_ptr<Window> w1(CreateTestWindow()); |
| 361 scoped_ptr<Window> w2(CreateTestWindow()); | 358 scoped_ptr<Window> w2(CreateTestWindow()); |
| 362 w1->SetBounds(gfx::Rect(0, 0, 250, 251)); | 359 w1->SetBounds(gfx::Rect(0, 0, 250, 251)); |
| 363 w1->Show(); | 360 w1->Show(); |
| 364 wm::ActivateWindow(w1.get()); | 361 wm::ActivateWindow(w1.get()); |
| 365 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); | 362 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN); |
| 366 ASSERT_EQ("1 M1 active=1", StateString()); | 363 ASSERT_EQ("1 F1 active=1", StateString()); |
| 367 | 364 |
| 368 w2->SetBounds(gfx::Rect(0, 0, 50, 51)); | 365 w2->SetBounds(gfx::Rect(0, 0, 50, 51)); |
| 369 w2->Show(); | 366 w2->Show(); |
| 370 wm::ActivateWindow(w2.get()); | 367 wm::ActivateWindow(w2.get()); |
| 371 ASSERT_EQ("1 M1 active=0", StateString()); | 368 ASSERT_EQ("1 F1 active=0", StateString()); |
| 372 | 369 |
| 373 w2->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); | 370 w2->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN); |
| 374 EXPECT_TRUE(wm::IsActiveWindow(w2.get())); | 371 EXPECT_TRUE(wm::IsActiveWindow(w2.get())); |
| 375 ASSERT_EQ("0 M1 M1 active=2", StateString()); | 372 ASSERT_EQ("0 F1 F1 active=2", StateString()); |
| 376 | 373 |
| 377 // The last stacked window (|w2|) should be last since it was maximized last. | 374 // The last stacked window (|w2|) should be last since it was fullscreen last. |
| 378 EXPECT_EQ(w1.get(), workspaces()[1]->window()->children()[0]); | 375 EXPECT_EQ(w1.get(), workspaces()[1]->window()->children()[0]); |
| 379 EXPECT_EQ(w2.get(), workspaces()[2]->window()->children()[0]); | 376 EXPECT_EQ(w2.get(), workspaces()[2]->window()->children()[0]); |
| 380 } | 377 } |
| 381 | 378 |
| 382 // Get the index of the layer inside its parent. This index can be used to | 379 // 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. | 380 // determine the z-order / draw-order of objects in the render tree. |
| 384 size_t IndexOfLayerInParent(ui::Layer* layer) { | 381 size_t IndexOfLayerInParent(ui::Layer* layer) { |
| 385 ui::Layer* parent = layer->parent(); | 382 ui::Layer* parent = layer->parent(); |
| 386 for (size_t i = 0; i < parent->children().size(); i++) { | 383 for (size_t i = 0; i < parent->children().size(); i++) { |
| 387 if (layer == parent->children()[i]) | 384 if (layer == parent->children()[i]) |
| 388 return i; | 385 return i; |
| 389 } | 386 } |
| 390 // This should never be reached. | 387 // This should never be reached. |
| 391 NOTREACHED(); | 388 NOTREACHED(); |
| 392 return 0; | 389 return 0; |
| 393 } | 390 } |
| 394 | 391 |
| 395 // Make sure that the layer z-order is correct for the time of the animation | 392 // 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 | 393 // when in a workspace with a normal and a fullscreen window the normal window |
| 397 // gets maximized. See crbug.com/232399. | 394 // gets fullscreen. See crbug.com/232399. |
| 398 TEST_F(WorkspaceManagerTest, MaximizeSecondInWorkspace) { | 395 TEST_F(WorkspaceManagerTest, FullscreenSecondInWorkspace) { |
| 399 // Create a maximized window. | 396 // Create a fullscreen window. |
| 400 scoped_ptr<Window> w1(CreateTestWindow()); | 397 scoped_ptr<Window> w1(CreateTestWindow()); |
| 401 ASSERT_EQ(1U, w1->layer()->parent()->children().size()); | 398 ASSERT_EQ(1U, w1->layer()->parent()->children().size()); |
| 402 w1->SetBounds(gfx::Rect(0, 0, 250, 251)); | 399 w1->SetBounds(gfx::Rect(0, 0, 250, 251)); |
| 403 w1->Show(); | 400 w1->Show(); |
| 404 wm::ActivateWindow(w1.get()); | 401 wm::ActivateWindow(w1.get()); |
| 405 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); | 402 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN); |
| 406 wm::ActivateWindow(w1.get()); | 403 wm::ActivateWindow(w1.get()); |
| 407 // There are two workspaces: A normal and a maximized one. | 404 // There are two workspaces: A normal and a fullscreen one. |
| 408 ASSERT_EQ("0 M1 active=1", StateString()); | 405 ASSERT_EQ("0 F1 active=1", StateString()); |
| 409 | 406 |
| 410 // Create a second window and make it part of the maximized workspace. | 407 // Create a second window and make it part of the fullscreen workspace. |
| 411 scoped_ptr<Window> w2(CreateAppTestWindow(w1->parent())); | 408 scoped_ptr<Window> w2(CreateAppTestWindow(w1->parent())); |
| 412 w2->SetBounds(gfx::Rect(0, 0, 50, 51)); | 409 w2->SetBounds(gfx::Rect(0, 0, 50, 51)); |
| 413 w2->Show(); | 410 w2->Show(); |
| 414 wm::ActivateWindow(w2.get()); | 411 wm::ActivateWindow(w2.get()); |
| 415 // There are still two workspaces and two windows in the (maximized) | 412 // There are still two workspaces and two windows in the (fullscreen) |
| 416 // workspace. | 413 // workspace. |
| 417 ASSERT_EQ("0 M2 active=1", StateString()); | 414 ASSERT_EQ("0 F2 active=1", StateString()); |
| 418 ASSERT_EQ(w1->layer()->parent()->children()[0], w1->layer()); | 415 ASSERT_EQ(w1->layer()->parent()->children()[0], w1->layer()); |
| 419 ASSERT_EQ(w1->layer()->parent()->children()[1], w2->layer()); | 416 ASSERT_EQ(w1->layer()->parent()->children()[1], w2->layer()); |
| 420 | 417 |
| 421 // Now we need to enable all animations since the incorrect layer ordering we | 418 // 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. | 419 // want to test against happens only while the animation is going on. |
| 423 scoped_ptr<ui::ScopedAnimationDurationScaleMode> animation_duration( | 420 scoped_ptr<ui::ScopedAnimationDurationScaleMode> animation_duration( |
| 424 new ui::ScopedAnimationDurationScaleMode( | 421 new ui::ScopedAnimationDurationScaleMode( |
| 425 ui::ScopedAnimationDurationScaleMode::FAST_DURATION)); | 422 ui::ScopedAnimationDurationScaleMode::FAST_DURATION)); |
| 426 | 423 |
| 427 ui::Layer* old_w2_layer = w2->layer(); | 424 ui::Layer* old_w2_layer = w2->layer(); |
| 428 | 425 |
| 429 // Maximize the second window and make sure that the workspace changes. | 426 // Maximize the second window and make sure that the workspace changes. |
| 430 w2->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); | 427 w2->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN); |
| 431 | 428 |
| 432 // Check the correct window hierarchy - (|w2|) should be last since it was | 429 // Check the correct window hierarchy - (|w2|) should be last since it got |
| 433 // maximized last. | 430 // fullscreen last. |
| 434 ASSERT_EQ("0 M1 M1 active=2", StateString()); | 431 ASSERT_EQ("0 F1 F1 active=2", StateString()); |
| 435 EXPECT_EQ(3U, workspaces().size()); | 432 EXPECT_EQ(3U, workspaces().size()); |
| 436 EXPECT_EQ(w1.get(), workspaces()[1]->window()->children()[0]); | 433 EXPECT_EQ(w1.get(), workspaces()[1]->window()->children()[0]); |
| 437 EXPECT_EQ(w2.get(), workspaces()[2]->window()->children()[0]); | 434 EXPECT_EQ(w2.get(), workspaces()[2]->window()->children()[0]); |
| 438 | 435 |
| 439 // Check the workspace layer visibility. | 436 // Check the workspace layer visibility. |
| 440 EXPECT_EQ(1, workspaces()[1]->window()->layer()->opacity()); | 437 EXPECT_EQ(1, workspaces()[1]->window()->layer()->opacity()); |
| 441 EXPECT_EQ(1, workspaces()[2]->window()->layer()->opacity()); | 438 EXPECT_EQ(1, workspaces()[2]->window()->layer()->opacity()); |
| 442 | 439 |
| 443 // Check that |w2| got a new layer and that the old layer is still visible, | 440 // 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 | 441 // while the new one is not. Further and foremost the old layer should be a |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 487 | 484 |
| 488 // Assertions around a fullscreen window. | 485 // Assertions around a fullscreen window. |
| 489 TEST_F(WorkspaceManagerTest, SingleFullscreenWindow) { | 486 TEST_F(WorkspaceManagerTest, SingleFullscreenWindow) { |
| 490 scoped_ptr<Window> w1(CreateTestWindow()); | 487 scoped_ptr<Window> w1(CreateTestWindow()); |
| 491 w1->SetBounds(gfx::Rect(0, 0, 250, 251)); | 488 w1->SetBounds(gfx::Rect(0, 0, 250, 251)); |
| 492 // Make the window fullscreen. | 489 // Make the window fullscreen. |
| 493 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN); | 490 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN); |
| 494 w1->Show(); | 491 w1->Show(); |
| 495 wm::ActivateWindow(w1.get()); | 492 wm::ActivateWindow(w1.get()); |
| 496 | 493 |
| 497 // Should be 2 workspaces, normal and maximized. | 494 // Should be 2 workspaces, normal and fullscreen. |
| 498 ASSERT_EQ("0 M1 active=1", StateString()); | 495 ASSERT_EQ("0 F1 active=1", StateString()); |
| 499 EXPECT_EQ(w1.get(), workspaces()[1]->window()->children()[0]); | 496 EXPECT_EQ(w1.get(), workspaces()[1]->window()->children()[0]); |
| 500 EXPECT_EQ(GetFullscreenBounds(w1.get()).width(), w1->bounds().width()); | 497 EXPECT_EQ(GetFullscreenBounds(w1.get()).width(), w1->bounds().width()); |
| 501 EXPECT_EQ(GetFullscreenBounds(w1.get()).height(), w1->bounds().height()); | 498 EXPECT_EQ(GetFullscreenBounds(w1.get()).height(), w1->bounds().height()); |
| 502 | 499 |
| 503 // Restore the window. Use SHOW_STATE_DEFAULT as that is what we'll end up | 500 // Restore the window. Use SHOW_STATE_DEFAULT as that is what we'll end up |
| 504 // with when using views::Widget. | 501 // with when using views::Widget. |
| 505 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_DEFAULT); | 502 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_DEFAULT); |
| 506 EXPECT_EQ("0,0 250x251", w1->bounds().ToString()); | 503 EXPECT_EQ("0,0 250x251", w1->bounds().ToString()); |
| 507 | 504 |
| 508 // Should be 1 workspace for the desktop. | 505 // Should be 1 workspace for the desktop. |
| 509 ASSERT_EQ("1 active=0", StateString()); | 506 ASSERT_EQ("1 active=0", StateString()); |
| 510 EXPECT_EQ(w1.get(), workspaces()[0]->window()->children()[0]); | 507 EXPECT_EQ(w1.get(), workspaces()[0]->window()->children()[0]); |
| 511 EXPECT_EQ(250, w1->bounds().width()); | 508 EXPECT_EQ(250, w1->bounds().width()); |
| 512 EXPECT_EQ(251, w1->bounds().height()); | 509 EXPECT_EQ(251, w1->bounds().height()); |
| 513 | 510 |
| 514 // Back to fullscreen. | 511 // Back to fullscreen. |
| 515 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN); | 512 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN); |
| 516 ASSERT_EQ("0 M1 active=1", StateString()); | 513 ASSERT_EQ("0 F1 active=1", StateString()); |
| 517 EXPECT_EQ(w1.get(), workspaces()[1]->window()->children()[0]); | 514 EXPECT_EQ(w1.get(), workspaces()[1]->window()->children()[0]); |
| 518 EXPECT_EQ(GetFullscreenBounds(w1.get()).width(), w1->bounds().width()); | 515 EXPECT_EQ(GetFullscreenBounds(w1.get()).width(), w1->bounds().width()); |
| 519 EXPECT_EQ(GetFullscreenBounds(w1.get()).height(), w1->bounds().height()); | 516 EXPECT_EQ(GetFullscreenBounds(w1.get()).height(), w1->bounds().height()); |
| 520 ASSERT_TRUE(GetRestoreBoundsInScreen(w1.get())); | 517 ASSERT_TRUE(GetRestoreBoundsInScreen(w1.get())); |
| 521 EXPECT_EQ("0,0 250x251", GetRestoreBoundsInScreen(w1.get())->ToString()); | 518 EXPECT_EQ("0,0 250x251", GetRestoreBoundsInScreen(w1.get())->ToString()); |
| 522 } | 519 } |
| 523 | 520 |
| 524 // Makes sure switching workspaces doesn't show transient windows. | 521 // Makes sure switching workspaces doesn't show transient windows. |
| 525 TEST_F(WorkspaceManagerTest, DontShowTransientsOnSwitch) { | 522 TEST_F(WorkspaceManagerTest, DontShowTransientsOnSwitch) { |
| 526 scoped_ptr<Window> w1(CreateTestWindow()); | 523 scoped_ptr<Window> w1(CreateTestWindow()); |
| 527 scoped_ptr<Window> w2(CreateTestWindow()); | 524 scoped_ptr<Window> w2(CreateTestWindow()); |
| 528 | 525 |
| 529 w1->SetBounds(gfx::Rect(0, 0, 250, 251)); | 526 w1->SetBounds(gfx::Rect(0, 0, 250, 251)); |
| 530 w2->SetBounds(gfx::Rect(0, 0, 250, 251)); | 527 w2->SetBounds(gfx::Rect(0, 0, 250, 251)); |
| 531 w1->AddTransientChild(w2.get()); | 528 w1->AddTransientChild(w2.get()); |
| 532 | 529 |
| 533 w1->Show(); | 530 w1->Show(); |
| 534 | 531 |
| 535 scoped_ptr<Window> w3(CreateTestWindow()); | 532 scoped_ptr<Window> w3(CreateTestWindow()); |
| 536 w3->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); | 533 w3->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN); |
| 537 w3->Show(); | 534 w3->Show(); |
| 538 wm::ActivateWindow(w3.get()); | 535 wm::ActivateWindow(w3.get()); |
| 539 | 536 |
| 540 EXPECT_FALSE(w1->layer()->IsDrawn()); | 537 EXPECT_FALSE(w1->layer()->IsDrawn()); |
| 541 EXPECT_FALSE(w2->layer()->IsDrawn()); | 538 EXPECT_FALSE(w2->layer()->IsDrawn()); |
| 542 EXPECT_TRUE(w3->layer()->IsDrawn()); | 539 EXPECT_TRUE(w3->layer()->IsDrawn()); |
| 543 | 540 |
| 544 wm::ActivateWindow(w1.get()); | 541 wm::ActivateWindow(w1.get()); |
| 545 EXPECT_TRUE(w1->layer()->IsDrawn()); | 542 EXPECT_TRUE(w1->layer()->IsDrawn()); |
| 546 EXPECT_FALSE(w2->layer()->IsDrawn()); | 543 EXPECT_FALSE(w2->layer()->IsDrawn()); |
| 547 EXPECT_FALSE(w3->layer()->IsDrawn()); | 544 EXPECT_FALSE(w3->layer()->IsDrawn()); |
| 548 } | 545 } |
| 549 | 546 |
| 550 // Persists-across-all-workspace flag should not cause a transient child | 547 // Persists-across-all-workspace flag should not cause a transient child |
| 551 // to be activated at desktop workspace. | 548 // to be activated at desktop workspace. |
| 552 TEST_F(WorkspaceManagerTest, PersistsTransientChildStayInSameWorkspace) { | 549 TEST_F(WorkspaceManagerTest, PersistsTransientChildStayInSameWorkspace) { |
| 553 scoped_ptr<Window> w1(CreateTestWindow()); | 550 scoped_ptr<Window> w1(CreateTestWindow()); |
| 554 SetPersistsAcrossAllWorkspaces( | 551 SetPersistsAcrossAllWorkspaces( |
| 555 w1.get(), | 552 w1.get(), |
| 556 WINDOW_PERSISTS_ACROSS_ALL_WORKSPACES_VALUE_YES); | 553 WINDOW_PERSISTS_ACROSS_ALL_WORKSPACES_VALUE_YES); |
| 557 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); | 554 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN); |
| 558 w1->Show(); | 555 w1->Show(); |
| 559 wm::ActivateWindow(w1.get()); | 556 wm::ActivateWindow(w1.get()); |
| 560 ASSERT_EQ("0 M1 active=1", StateString()); | 557 ASSERT_EQ("0 F1 active=1", StateString()); |
| 561 | 558 |
| 562 scoped_ptr<Window> w2(CreateTestWindowUnparented()); | 559 scoped_ptr<Window> w2(CreateTestWindowUnparented()); |
| 563 w1->AddTransientChild(w2.get()); | 560 w1->AddTransientChild(w2.get()); |
| 564 SetPersistsAcrossAllWorkspaces( | 561 SetPersistsAcrossAllWorkspaces( |
| 565 w2.get(), | 562 w2.get(), |
| 566 WINDOW_PERSISTS_ACROSS_ALL_WORKSPACES_VALUE_YES); | 563 WINDOW_PERSISTS_ACROSS_ALL_WORKSPACES_VALUE_YES); |
| 567 SetDefaultParentByPrimaryRootWindow(w2.get()); | 564 SetDefaultParentByPrimaryRootWindow(w2.get()); |
| 568 w2->Show(); | 565 w2->Show(); |
| 569 wm::ActivateWindow(w2.get()); | 566 wm::ActivateWindow(w2.get()); |
| 570 | 567 |
| 571 ASSERT_EQ("0 M2 active=1", StateString()); | 568 ASSERT_EQ("0 F2 active=1", StateString()); |
| 572 } | 569 } |
| 573 | 570 |
| 574 // Assertions around minimizing a single window. | 571 // Assertions around minimizing a single window. |
| 575 TEST_F(WorkspaceManagerTest, MinimizeSingleWindow) { | 572 TEST_F(WorkspaceManagerTest, MinimizeSingleWindow) { |
| 576 scoped_ptr<Window> w1(CreateTestWindow()); | 573 scoped_ptr<Window> w1(CreateTestWindow()); |
| 577 | 574 |
| 578 w1->Show(); | 575 w1->Show(); |
| 579 ASSERT_EQ("1 active=0", StateString()); | 576 ASSERT_EQ("1 active=0", StateString()); |
| 580 | 577 |
| 581 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MINIMIZED); | 578 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MINIMIZED); |
| 582 ASSERT_EQ("1 active=0", StateString()); | 579 ASSERT_EQ("1 active=0", StateString()); |
| 583 EXPECT_FALSE(w1->layer()->IsDrawn()); | 580 EXPECT_FALSE(w1->layer()->IsDrawn()); |
| 584 | 581 |
| 585 // Show the window. | 582 // Show the window. |
| 586 w1->Show(); | 583 w1->Show(); |
| 587 EXPECT_TRUE(wm::IsWindowNormal(w1.get())); | 584 EXPECT_TRUE(wm::IsWindowNormal(w1.get())); |
| 588 ASSERT_EQ("1 active=0", StateString()); | 585 ASSERT_EQ("1 active=0", StateString()); |
| 589 EXPECT_TRUE(w1->layer()->IsDrawn()); | 586 EXPECT_TRUE(w1->layer()->IsDrawn()); |
| 590 } | 587 } |
| 591 | 588 |
| 592 // Assertions around minimizing a maximized window. | 589 // Assertions around minimizing a fullscreen window. |
| 593 TEST_F(WorkspaceManagerTest, MinimizeMaximizedWindow) { | 590 TEST_F(WorkspaceManagerTest, MinimizeFullscreenWindow) { |
| 594 // Two windows, w1 normal, w2 maximized. | 591 // Two windows, w1 normal, w2 fullscreen. |
| 595 scoped_ptr<Window> w1(CreateTestWindow()); | 592 scoped_ptr<Window> w1(CreateTestWindow()); |
| 596 scoped_ptr<Window> w2(CreateTestWindow()); | 593 scoped_ptr<Window> w2(CreateTestWindow()); |
| 597 w1->Show(); | 594 w1->Show(); |
| 598 w2->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); | 595 w2->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN); |
| 599 w2->Show(); | 596 w2->Show(); |
| 600 wm::ActivateWindow(w2.get()); | 597 wm::ActivateWindow(w2.get()); |
| 601 ASSERT_EQ("1 M1 active=1", StateString()); | 598 ASSERT_EQ("1 F1 active=1", StateString()); |
| 602 | 599 |
| 603 // Minimize w2. | 600 // Minimize w2. |
| 604 w2->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MINIMIZED); | 601 w2->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MINIMIZED); |
| 605 ASSERT_EQ("1 P=M1 active=0", StateString()); | 602 ASSERT_EQ("1 P=F1 active=0", StateString()); |
| 606 EXPECT_TRUE(w1->layer()->IsDrawn()); | 603 EXPECT_TRUE(w1->layer()->IsDrawn()); |
| 607 EXPECT_FALSE(w2->layer()->IsDrawn()); | 604 EXPECT_FALSE(w2->layer()->IsDrawn()); |
| 608 | 605 |
| 609 // Show the window, which should trigger unminimizing. | 606 // Show the window, which should trigger unminimizing. |
| 610 w2->Show(); | 607 w2->Show(); |
| 611 ASSERT_EQ("1 P=M1 active=0", StateString()); | 608 ASSERT_EQ("1 P=F1 active=0", StateString()); |
| 612 | 609 |
| 613 wm::ActivateWindow(w2.get()); | 610 wm::ActivateWindow(w2.get()); |
| 614 ASSERT_EQ("1 M1 active=1", StateString()); | 611 ASSERT_EQ("1 F1 active=1", StateString()); |
| 615 | 612 |
| 616 EXPECT_TRUE(wm::IsWindowMaximized(w2.get())); | 613 EXPECT_TRUE(wm::IsWindowFullscreen(w2.get())); |
| 617 EXPECT_FALSE(w1->layer()->IsDrawn()); | 614 EXPECT_FALSE(w1->layer()->IsDrawn()); |
| 618 EXPECT_TRUE(w2->layer()->IsDrawn()); | 615 EXPECT_TRUE(w2->layer()->IsDrawn()); |
| 619 | 616 |
| 620 // Minimize the window, which should hide the window and activate another. | 617 // Minimize the window, which should hide the window and activate another. |
| 621 EXPECT_TRUE(wm::IsActiveWindow(w2.get())); | 618 EXPECT_TRUE(wm::IsActiveWindow(w2.get())); |
| 622 w2->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MINIMIZED); | 619 w2->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MINIMIZED); |
| 623 EXPECT_FALSE(wm::IsActiveWindow(w2.get())); | 620 EXPECT_FALSE(wm::IsActiveWindow(w2.get())); |
| 624 EXPECT_FALSE(w2->layer()->IsDrawn()); | 621 EXPECT_FALSE(w2->layer()->IsDrawn()); |
| 625 EXPECT_TRUE(wm::IsActiveWindow(w1.get())); | 622 EXPECT_TRUE(wm::IsActiveWindow(w1.get())); |
| 626 | 623 |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 719 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); | 716 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); |
| 720 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state()); | 717 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state()); |
| 721 EXPECT_EQ("0,1 101x102", w1->bounds().ToString()); | 718 EXPECT_EQ("0,1 101x102", w1->bounds().ToString()); |
| 722 | 719 |
| 723 // Create another window, maximized. | 720 // Create another window, maximized. |
| 724 scoped_ptr<Window> w2(CreateTestWindow()); | 721 scoped_ptr<Window> w2(CreateTestWindow()); |
| 725 w2->SetBounds(gfx::Rect(10, 11, 250, 251)); | 722 w2->SetBounds(gfx::Rect(10, 11, 250, 251)); |
| 726 w2->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); | 723 w2->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); |
| 727 w2->Show(); | 724 w2->Show(); |
| 728 wm::ActivateWindow(w2.get()); | 725 wm::ActivateWindow(w2.get()); |
| 729 EXPECT_EQ(1, active_index()); | 726 EXPECT_EQ(0, active_index()); |
| 730 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state()); | 727 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state()); |
| 731 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); | 728 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); |
| 732 EXPECT_EQ("0,1 101x102", w1->bounds().ToString()); | 729 EXPECT_EQ("0,1 101x102", w1->bounds().ToString()); |
| 733 | 730 |
| 734 // Switch to w1. | 731 // Switch to w1. |
| 735 wm::ActivateWindow(w1.get()); | 732 wm::ActivateWindow(w1.get()); |
| 736 EXPECT_EQ(0, active_index()); | 733 EXPECT_EQ(0, active_index()); |
| 737 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state()); | 734 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state()); |
| 738 EXPECT_EQ("0,1 101x102", w1->bounds().ToString()); | 735 EXPECT_EQ("0,1 101x102", w1->bounds().ToString()); |
| 739 EXPECT_EQ(ScreenAsh::GetMaximizedWindowBoundsInParent( | 736 EXPECT_EQ(ScreenAsh::GetMaximizedWindowBoundsInParent( |
| 740 w2->parent()).ToString(), | 737 w2->parent()).ToString(), |
| 741 w2->bounds().ToString()); | 738 w2->bounds().ToString()); |
| 742 | 739 |
| 743 // Switch to w2. | 740 // Switch to w2. |
| 744 wm::ActivateWindow(w2.get()); | 741 wm::ActivateWindow(w2.get()); |
| 745 EXPECT_EQ(1, active_index()); | 742 EXPECT_EQ(0, active_index()); |
| 746 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state()); | 743 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state()); |
| 747 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); | 744 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); |
| 748 EXPECT_EQ("0,1 101x102", w1->bounds().ToString()); | 745 EXPECT_EQ("0,1 101x102", w1->bounds().ToString()); |
| 749 EXPECT_EQ(ScreenAsh::GetMaximizedWindowBoundsInParent(w2.get()).ToString(), | 746 EXPECT_EQ(ScreenAsh::GetMaximizedWindowBoundsInParent(w2.get()).ToString(), |
| 750 w2->bounds().ToString()); | 747 w2->bounds().ToString()); |
| 751 | 748 |
| 752 // Turn off auto-hide, switch back to w2 (maximized) and verify overlap. | 749 // Turn off auto-hide, switch back to w2 (maximized) and verify overlap. |
| 753 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); | 750 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); |
| 754 wm::ActivateWindow(w2.get()); | 751 wm::ActivateWindow(w2.get()); |
| 755 EXPECT_FALSE(GetWindowOverlapsShelf()); | 752 EXPECT_FALSE(GetWindowOverlapsShelf()); |
| 756 | 753 |
| 757 // Move w1 to overlap shelf, it shouldn't change window overlaps shelf since | 754 // Move w1 to overlap shelf, it shouldn't change window overlaps shelf since |
| 758 // the window isn't in the visible workspace. | 755 // the window isn't in the visible workspace. |
| 759 w1->SetBounds(touches_shelf_bounds); | 756 w1->SetBounds(touches_shelf_bounds); |
| 760 EXPECT_FALSE(GetWindowOverlapsShelf()); | 757 EXPECT_FALSE(GetWindowOverlapsShelf()); |
| 761 | 758 |
| 762 // Activate w1. Since w1 is visible the overlap state should be true. | 759 // Activate w1. Although w1 is visible, the overlap state is still false since |
| 760 // w2 is maximized. |
| 763 wm::ActivateWindow(w1.get()); | 761 wm::ActivateWindow(w1.get()); |
| 762 EXPECT_FALSE(GetWindowOverlapsShelf()); |
| 763 |
| 764 // Restore w2. |
| 765 w2->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); |
| 764 EXPECT_TRUE(GetWindowOverlapsShelf()); | 766 EXPECT_TRUE(GetWindowOverlapsShelf()); |
| 765 } | 767 } |
| 766 | 768 |
| 767 // Verifies persist across all workspaces. | 769 // Verifies persist across all workspaces. |
| 768 TEST_F(WorkspaceManagerTest, PersistAcrossAllWorkspaces) { | 770 TEST_F(WorkspaceManagerTest, PersistAcrossAllWorkspaces) { |
| 769 // Create a maximized window. | 771 // Create a fullscreen window. |
| 770 scoped_ptr<Window> w1(CreateTestWindow()); | 772 scoped_ptr<Window> w1(CreateTestWindow()); |
| 771 w1->Show(); | 773 w1->Show(); |
| 772 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); | 774 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN); |
| 773 wm::ActivateWindow(w1.get()); | 775 wm::ActivateWindow(w1.get()); |
| 774 ASSERT_EQ("0 M1 active=1", StateString()); | 776 ASSERT_EQ("0 F1 active=1", StateString()); |
| 775 | 777 |
| 776 // Create a window that persists across all workspaces. It should be placed in | 778 // Create a window that persists across all workspaces. It should be placed in |
| 777 // the current maximized workspace. | 779 // the current fullscreen workspace. |
| 778 scoped_ptr<Window> w2(CreateTestWindow()); | 780 scoped_ptr<Window> w2(CreateTestWindow()); |
| 779 SetPersistsAcrossAllWorkspaces( | 781 SetPersistsAcrossAllWorkspaces( |
| 780 w2.get(), | 782 w2.get(), |
| 781 WINDOW_PERSISTS_ACROSS_ALL_WORKSPACES_VALUE_YES); | 783 WINDOW_PERSISTS_ACROSS_ALL_WORKSPACES_VALUE_YES); |
| 782 w2->Show(); | 784 w2->Show(); |
| 783 ASSERT_EQ("1 M1 active=1", StateString()); | 785 ASSERT_EQ("1 F1 active=1", StateString()); |
| 784 | 786 |
| 785 // Activate w2, which should move it to the 2nd workspace. | 787 // Activate w2, which should move it to the 2nd workspace. |
| 786 wm::ActivateWindow(w2.get()); | 788 wm::ActivateWindow(w2.get()); |
| 787 ASSERT_EQ("0 M2 active=1", StateString()); | 789 ASSERT_EQ("0 F2 active=1", StateString()); |
| 788 | 790 |
| 789 // Restoring w2 should drop the persists window back to the desktop, and drop | 791 // Restoring w2 should drop the persists window back to the desktop, and drop |
| 790 // it to the bottom of the stack. | 792 // it to the bottom of the stack. |
| 791 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); | 793 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); |
| 792 ASSERT_EQ("2 active=0", StateString()); | 794 ASSERT_EQ("2 active=0", StateString()); |
| 793 EXPECT_EQ(w2.get(), workspaces()[0]->window()->children()[0]); | 795 EXPECT_EQ(w2.get(), workspaces()[0]->window()->children()[0]); |
| 794 EXPECT_EQ(w1.get(), workspaces()[0]->window()->children()[1]); | 796 EXPECT_EQ(w1.get(), workspaces()[0]->window()->children()[1]); |
| 795 | 797 |
| 796 // Repeat, but this time minimize. The minimized window should end up in | 798 // Repeat, but this time minimize. The minimized window should end up in |
| 797 // pending. | 799 // pending. |
| 798 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); | 800 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN); |
| 799 ASSERT_EQ("1 P=M1 active=0", StateString()); | 801 ASSERT_EQ("1 P=F1 active=0", StateString()); |
| 800 w2.reset(CreateTestWindow()); | 802 w2.reset(CreateTestWindow()); |
| 801 SetPersistsAcrossAllWorkspaces( | 803 SetPersistsAcrossAllWorkspaces( |
| 802 w2.get(), | 804 w2.get(), |
| 803 WINDOW_PERSISTS_ACROSS_ALL_WORKSPACES_VALUE_YES); | 805 WINDOW_PERSISTS_ACROSS_ALL_WORKSPACES_VALUE_YES); |
| 804 w2->Show(); | 806 w2->Show(); |
| 805 ASSERT_EQ("1 P=M1 active=0", StateString()); | 807 ASSERT_EQ("1 P=F1 active=0", StateString()); |
| 806 wm::ActivateWindow(w2.get()); | 808 wm::ActivateWindow(w2.get()); |
| 807 ASSERT_EQ("1 P=M1 active=0", StateString()); | 809 ASSERT_EQ("1 P=F1 active=0", StateString()); |
| 808 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MINIMIZED); | 810 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MINIMIZED); |
| 809 ASSERT_EQ("1 P=M1 active=0", StateString()); | 811 ASSERT_EQ("1 P=F1 active=0", StateString()); |
| 810 EXPECT_EQ(w2.get(), workspaces()[0]->window()->children()[0]); | 812 EXPECT_EQ(w2.get(), workspaces()[0]->window()->children()[0]); |
| 811 } | 813 } |
| 812 | 814 |
| 813 // Verifies that when a window persists across all workpaces is activated that | 815 // Verifies that when a window persists across all workpaces is activated that |
| 814 // it moves to the current workspace. | 816 // it moves to the current workspace. |
| 815 TEST_F(WorkspaceManagerTest, ActivatePersistAcrossAllWorkspacesWhenNotActive) { | 817 TEST_F(WorkspaceManagerTest, ActivatePersistAcrossAllWorkspacesWhenNotActive) { |
| 816 // Create a window that persists across all workspaces. | 818 // Create a window that persists across all workspaces. |
| 817 scoped_ptr<Window> w2(CreateTestWindow()); | 819 scoped_ptr<Window> w2(CreateTestWindow()); |
| 818 SetPersistsAcrossAllWorkspaces( | 820 SetPersistsAcrossAllWorkspaces( |
| 819 w2.get(), | 821 w2.get(), |
| 820 WINDOW_PERSISTS_ACROSS_ALL_WORKSPACES_VALUE_YES); | 822 WINDOW_PERSISTS_ACROSS_ALL_WORKSPACES_VALUE_YES); |
| 821 w2->Show(); | 823 w2->Show(); |
| 822 ASSERT_EQ("1 active=0", StateString()); | 824 ASSERT_EQ("1 active=0", StateString()); |
| 823 | 825 |
| 824 // Create a maximized window. | 826 // Create a maximized window. |
| 825 scoped_ptr<Window> w1(CreateTestWindow()); | 827 scoped_ptr<Window> w1(CreateTestWindow()); |
| 826 w1->Show(); | 828 w1->Show(); |
| 827 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); | 829 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN); |
| 828 wm::ActivateWindow(w1.get()); | 830 wm::ActivateWindow(w1.get()); |
| 829 ASSERT_EQ("1 M1 active=1", StateString()); | 831 ASSERT_EQ("1 F1 active=1", StateString()); |
| 830 | 832 |
| 831 // Activate the persists across all workspace window. It should move to the | 833 // Activate the persists across all workspace window. It should move to the |
| 832 // current workspace. | 834 // current workspace. |
| 833 wm::ActivateWindow(w2.get()); | 835 wm::ActivateWindow(w2.get()); |
| 834 ASSERT_EQ("0 M2 active=1", StateString()); | 836 ASSERT_EQ("0 F2 active=1", StateString()); |
| 835 // The window that persists across all workspaces should be moved to the top | 837 // The window that persists across all workspaces should be moved to the top |
| 836 // of the stacking order. | 838 // of the stacking order. |
| 837 EXPECT_EQ(w1.get(), workspaces()[1]->window()->children()[0]); | 839 EXPECT_EQ(w1.get(), workspaces()[1]->window()->children()[0]); |
| 838 EXPECT_EQ(w2.get(), workspaces()[1]->window()->children()[1]); | 840 EXPECT_EQ(w2.get(), workspaces()[1]->window()->children()[1]); |
| 839 EXPECT_TRUE(wm::IsActiveWindow(w2.get())); | 841 EXPECT_TRUE(wm::IsActiveWindow(w2.get())); |
| 840 } | 842 } |
| 841 | 843 |
| 842 // Verifies Show()ing a minimized window that persists across all workspaces | 844 // Verifies Show()ing a minimized window that persists across all workspaces |
| 843 // unminimizes the window. | 845 // unminimizes the window. |
| 844 TEST_F(WorkspaceManagerTest, ShowMinimizedPersistWindow) { | 846 TEST_F(WorkspaceManagerTest, ShowMinimizedPersistWindow) { |
| 845 // Create a window that persists across all workspaces. | 847 // Create a window that persists across all workspaces. |
| 846 scoped_ptr<Window> w1(CreateTestWindow()); | 848 scoped_ptr<Window> w1(CreateTestWindow()); |
| 847 SetPersistsAcrossAllWorkspaces( | 849 SetPersistsAcrossAllWorkspaces( |
| 848 w1.get(), | 850 w1.get(), |
| 849 WINDOW_PERSISTS_ACROSS_ALL_WORKSPACES_VALUE_YES); | 851 WINDOW_PERSISTS_ACROSS_ALL_WORKSPACES_VALUE_YES); |
| 850 w1->Show(); | 852 w1->Show(); |
| 851 wm::ActivateWindow(w1.get()); | 853 wm::ActivateWindow(w1.get()); |
| 852 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MINIMIZED); | 854 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MINIMIZED); |
| 853 EXPECT_FALSE(w1->IsVisible()); | 855 EXPECT_FALSE(w1->IsVisible()); |
| 854 w1->Show(); | 856 w1->Show(); |
| 855 EXPECT_TRUE(w1->IsVisible()); | 857 EXPECT_TRUE(w1->IsVisible()); |
| 856 } | 858 } |
| 857 | 859 |
| 858 // Test that a persistent window across all workspaces which was first | 860 // Test that a persistent window across all workspaces which got fullscreen |
| 859 // maximized, then got minimized and finally got restored does not crash the | 861 // first, then got minimized and finally got restored does not crash the |
| 860 // system (see http://crbug.com/151698) and restores its maximized workspace | 862 // system (see http://crbug.com/151698) and restores its fullscreen workspace |
| 861 // instead. | 863 // instead. |
| 862 TEST_F(WorkspaceManagerTest, MaximizeMinimizeRestoreDoesNotCrash) { | 864 TEST_F(WorkspaceManagerTest, MaximizeMinimizeRestoreDoesNotCrash) { |
| 863 // We need to create a regular window first so there's an active workspace. | 865 // We need to create a regular window first so there's an active workspace. |
| 864 scoped_ptr<Window> w1(CreateTestWindow()); | 866 scoped_ptr<Window> w1(CreateTestWindow()); |
| 865 w1->Show(); | 867 w1->Show(); |
| 866 | 868 |
| 867 // Create a window that persists across all workspaces. | 869 // Create a window that persists across all workspaces. |
| 868 scoped_ptr<Window> w2(CreateTestWindow()); | 870 scoped_ptr<Window> w2(CreateTestWindow()); |
| 869 SetPersistsAcrossAllWorkspaces( | 871 SetPersistsAcrossAllWorkspaces( |
| 870 w2.get(), | 872 w2.get(), |
| 871 WINDOW_PERSISTS_ACROSS_ALL_WORKSPACES_VALUE_YES); | 873 WINDOW_PERSISTS_ACROSS_ALL_WORKSPACES_VALUE_YES); |
| 872 w2->Show(); | 874 w2->Show(); |
| 873 wm::ActivateWindow(w2.get()); | 875 wm::ActivateWindow(w2.get()); |
| 874 w2->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); | 876 w2->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN); |
| 875 w2->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MINIMIZED); | 877 w2->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MINIMIZED); |
| 876 EXPECT_FALSE(w2->IsVisible()); | 878 EXPECT_FALSE(w2->IsVisible()); |
| 877 // This is the critical call which should switch to the maximized workspace | 879 // This is the critical call which should switch to the fullscreen workspace |
| 878 // of that window instead of reparenting it to the other workspace (and | 880 // of that window instead of reparenting it to the other workspace (and |
| 879 // crashing while trying to do so). | 881 // crashing while trying to do so). |
| 880 wm::ActivateWindow(w2.get()); | 882 wm::ActivateWindow(w2.get()); |
| 881 EXPECT_EQ(ui::SHOW_STATE_MAXIMIZED, | 883 EXPECT_EQ(ui::SHOW_STATE_FULLSCREEN, |
| 882 w2->GetProperty(aura::client::kShowStateKey)); | 884 w2->GetProperty(aura::client::kShowStateKey)); |
| 883 EXPECT_TRUE(w2->IsVisible()); | 885 EXPECT_TRUE(w2->IsVisible()); |
| 884 } | 886 } |
| 885 | 887 |
| 886 // Test that we report we're in the fullscreen state even if the fullscreen | 888 // Test that we report we're in the fullscreen state even if the fullscreen |
| 887 // window isn't being managed by us (http://crbug.com/123931). | 889 // window isn't being managed by us (http://crbug.com/123931). |
| 888 TEST_F(WorkspaceManagerTest, GetWindowStateWithUnmanagedFullscreenWindow) { | 890 TEST_F(WorkspaceManagerTest, GetWindowStateWithUnmanagedFullscreenWindow) { |
| 889 ShelfLayoutManager* shelf = shelf_layout_manager(); | 891 ShelfLayoutManager* shelf = shelf_layout_manager(); |
| 890 | 892 |
| 891 // We need to create a regular window first so there's an active workspace. | 893 // We need to create a regular window first so there's an active workspace. |
| 892 scoped_ptr<Window> w1(CreateTestWindow()); | 894 scoped_ptr<Window> w1(CreateTestWindow()); |
| 893 w1->Show(); | 895 w1->Show(); |
| 894 | 896 |
| 895 scoped_ptr<Window> w2(CreateTestWindow()); | 897 scoped_ptr<Window> w2(CreateTestWindow()); |
| 896 w2->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN); | 898 w2->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN); |
| 897 SetPersistsAcrossAllWorkspaces( | 899 SetPersistsAcrossAllWorkspaces( |
| 898 w2.get(), | 900 w2.get(), |
| 899 WINDOW_PERSISTS_ACROSS_ALL_WORKSPACES_VALUE_YES); | 901 WINDOW_PERSISTS_ACROSS_ALL_WORKSPACES_VALUE_YES); |
| 900 w2->Show(); | 902 w2->Show(); |
| 901 wm::ActivateWindow(w2.get()); | 903 wm::ActivateWindow(w2.get()); |
| 902 | 904 |
| 903 ASSERT_EQ("1 M1 active=1", StateString()); | 905 ASSERT_EQ("1 F1 active=1", StateString()); |
| 904 | 906 |
| 905 EXPECT_EQ(SHELF_HIDDEN, shelf->visibility_state()); | 907 EXPECT_EQ(SHELF_HIDDEN, shelf->visibility_state()); |
| 906 EXPECT_EQ(WORKSPACE_WINDOW_STATE_FULL_SCREEN, manager_->GetWindowState()); | 908 EXPECT_EQ(WORKSPACE_WINDOW_STATE_FULL_SCREEN, manager_->GetWindowState()); |
| 907 | 909 |
| 908 w2->Hide(); | 910 w2->Hide(); |
| 909 ASSERT_EQ("1 P=M1 active=0", StateString()); | 911 ASSERT_EQ("1 P=F1 active=0", StateString()); |
| 910 EXPECT_EQ(SHELF_VISIBLE, shelf->visibility_state()); | 912 EXPECT_EQ(SHELF_VISIBLE, shelf->visibility_state()); |
| 911 | 913 |
| 912 w2->Show(); | 914 w2->Show(); |
| 913 ASSERT_EQ("1 P=M1 active=0", StateString()); | 915 ASSERT_EQ("1 P=F1 active=0", StateString()); |
| 914 EXPECT_EQ(SHELF_VISIBLE, shelf->visibility_state()); | 916 EXPECT_EQ(SHELF_VISIBLE, shelf->visibility_state()); |
| 915 EXPECT_EQ(WORKSPACE_WINDOW_STATE_DEFAULT, manager_->GetWindowState()); | 917 EXPECT_EQ(WORKSPACE_WINDOW_STATE_DEFAULT, manager_->GetWindowState()); |
| 916 | 918 |
| 917 wm::ActivateWindow(w2.get()); | 919 wm::ActivateWindow(w2.get()); |
| 918 ASSERT_EQ("1 M1 active=1", StateString()); | 920 ASSERT_EQ("1 F1 active=1", StateString()); |
| 919 EXPECT_EQ(SHELF_HIDDEN, shelf->visibility_state()); | 921 EXPECT_EQ(SHELF_HIDDEN, shelf->visibility_state()); |
| 920 EXPECT_EQ(WORKSPACE_WINDOW_STATE_FULL_SCREEN, manager_->GetWindowState()); | 922 EXPECT_EQ(WORKSPACE_WINDOW_STATE_FULL_SCREEN, manager_->GetWindowState()); |
| 921 | 923 |
| 922 w2.reset(); | 924 w2.reset(); |
| 923 ASSERT_EQ("1 active=0", StateString()); | 925 ASSERT_EQ("1 active=0", StateString()); |
| 924 EXPECT_EQ(SHELF_VISIBLE, shelf->visibility_state()); | 926 EXPECT_EQ(SHELF_VISIBLE, shelf->visibility_state()); |
| 925 EXPECT_EQ(WORKSPACE_WINDOW_STATE_DEFAULT, manager_->GetWindowState()); | 927 EXPECT_EQ(WORKSPACE_WINDOW_STATE_DEFAULT, manager_->GetWindowState()); |
| 926 } | 928 } |
| 927 | 929 |
| 928 // Variant of GetWindowStateWithUnmanagedFullscreenWindow that uses a maximized | 930 // Variant of GetWindowStateWithUnmanagedFullscreenWindow that uses a maximized |
| 929 // window rather than a normal window. | 931 // window rather than a normal window. It should be same as the normal window. |
| 930 TEST_F(WorkspaceManagerTest, | 932 TEST_F(WorkspaceManagerTest, |
| 931 GetWindowStateWithUnmanagedFullscreenWindowWithMaximized) { | 933 GetWindowStateWithUnmanagedFullscreenWindowWithMaximized) { |
| 932 ShelfLayoutManager* shelf = shelf_layout_manager(); | 934 ShelfLayoutManager* shelf = shelf_layout_manager(); |
| 933 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); | 935 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); |
| 934 | 936 |
| 935 // Make the first window maximized. | 937 // Make the first window maximized. |
| 936 scoped_ptr<Window> w1(CreateTestWindow()); | 938 scoped_ptr<Window> w1(CreateTestWindow()); |
| 937 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); | 939 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); |
| 938 w1->Show(); | 940 w1->Show(); |
| 939 | 941 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 958 wm::ActivateWindow(w2.get()); | 960 wm::ActivateWindow(w2.get()); |
| 959 EXPECT_EQ(SHELF_HIDDEN, shelf->visibility_state()); | 961 EXPECT_EQ(SHELF_HIDDEN, shelf->visibility_state()); |
| 960 EXPECT_EQ(WORKSPACE_WINDOW_STATE_FULL_SCREEN, | 962 EXPECT_EQ(WORKSPACE_WINDOW_STATE_FULL_SCREEN, |
| 961 manager_->GetWindowState()); | 963 manager_->GetWindowState()); |
| 962 | 964 |
| 963 w2.reset(); | 965 w2.reset(); |
| 964 EXPECT_EQ(SHELF_VISIBLE, shelf->visibility_state()); | 966 EXPECT_EQ(SHELF_VISIBLE, shelf->visibility_state()); |
| 965 } | 967 } |
| 966 | 968 |
| 967 // Verifies a window marked as persisting across all workspaces ends up in its | 969 // Verifies a window marked as persisting across all workspaces ends up in its |
| 968 // own workspace when maximized. | 970 // own workspace when got fullscreen. |
| 969 TEST_F(WorkspaceManagerTest, MaximizeDontPersistEndsUpInOwnWorkspace) { | 971 TEST_F(WorkspaceManagerTest, FullscreenDontPersistEndsUpInOwnWorkspace) { |
| 970 scoped_ptr<Window> w1(CreateTestWindow()); | 972 scoped_ptr<Window> w1(CreateTestWindow()); |
| 971 | 973 |
| 972 SetPersistsAcrossAllWorkspaces( | 974 SetPersistsAcrossAllWorkspaces( |
| 973 w1.get(), | 975 w1.get(), |
| 974 WINDOW_PERSISTS_ACROSS_ALL_WORKSPACES_VALUE_YES); | 976 WINDOW_PERSISTS_ACROSS_ALL_WORKSPACES_VALUE_YES); |
| 975 w1->Show(); | 977 w1->Show(); |
| 976 | 978 |
| 977 ASSERT_EQ("1 active=0", StateString()); | 979 ASSERT_EQ("1 active=0", StateString()); |
| 978 | 980 |
| 979 // Maximize should trigger containing the window. | 981 // Maximize should trigger containing the window. |
| 980 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); | 982 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN); |
| 981 ASSERT_EQ("0 P=M1 active=0", StateString()); | 983 ASSERT_EQ("0 P=F1 active=0", StateString()); |
| 982 | 984 |
| 983 // And resetting to normal should remove it. | 985 // And resetting to normal should remove it. |
| 984 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); | 986 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); |
| 985 ASSERT_EQ("1 active=0", StateString()); | 987 ASSERT_EQ("1 active=0", StateString()); |
| 986 } | 988 } |
| 987 | 989 |
| 988 // Verifies going from maximized to minimized sets the right state for painting | 990 // Verifies going from maximized to minimized sets the right state for painting |
| 989 // the background of the launcher. | 991 // the background of the launcher. |
| 990 TEST_F(WorkspaceManagerTest, MinimizeResetsVisibility) { | 992 TEST_F(WorkspaceManagerTest, MinimizeResetsVisibility) { |
| 991 scoped_ptr<Window> w1(CreateTestWindow()); | 993 scoped_ptr<Window> w1(CreateTestWindow()); |
| 992 w1->Show(); | 994 w1->Show(); |
| 993 wm::ActivateWindow(w1.get()); | 995 wm::ActivateWindow(w1.get()); |
| 994 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); | 996 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); |
| 995 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MINIMIZED); | 997 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MINIMIZED); |
| 996 EXPECT_EQ(SHELF_VISIBLE, | 998 EXPECT_EQ(SHELF_VISIBLE, |
| 997 shelf_layout_manager()->visibility_state()); | 999 shelf_layout_manager()->visibility_state()); |
| 998 EXPECT_FALSE(shelf_widget()->paints_background()); | 1000 EXPECT_FALSE(shelf_widget()->paints_background()); |
| 999 } | 1001 } |
| 1000 | 1002 |
| 1001 // Verifies transients are moved when maximizing. | 1003 // Verifies transients are moved when fullscreen. |
| 1002 TEST_F(WorkspaceManagerTest, MoveTransientOnMaximize) { | 1004 TEST_F(WorkspaceManagerTest, MoveTransientOnFullscreen) { |
| 1003 scoped_ptr<Window> w1(CreateTestWindow()); | 1005 scoped_ptr<Window> w1(CreateTestWindow()); |
| 1004 w1->Show(); | 1006 w1->Show(); |
| 1005 scoped_ptr<Window> w2(CreateTestWindow()); | 1007 scoped_ptr<Window> w2(CreateTestWindow()); |
| 1006 w1->AddTransientChild(w2.get()); | 1008 w1->AddTransientChild(w2.get()); |
| 1007 w2->Show(); | 1009 w2->Show(); |
| 1008 wm::ActivateWindow(w1.get()); | 1010 wm::ActivateWindow(w1.get()); |
| 1009 ASSERT_EQ("2 active=0", StateString()); | 1011 ASSERT_EQ("2 active=0", StateString()); |
| 1010 | 1012 |
| 1011 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); | 1013 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN); |
| 1012 ASSERT_EQ("0 M2 active=1", StateString()); | 1014 ASSERT_EQ("0 F2 active=1", StateString()); |
| 1013 EXPECT_TRUE(wm::IsActiveWindow(w1.get())); | 1015 EXPECT_TRUE(wm::IsActiveWindow(w1.get())); |
| 1014 | 1016 |
| 1015 // Create another transient child of |w1|. We do this unparented, set up the | 1017 // 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 | 1018 // transient parent then set parent. This is how NativeWidgetAura does things |
| 1017 // too. | 1019 // too. |
| 1018 scoped_ptr<Window> w3(CreateTestWindowUnparented()); | 1020 scoped_ptr<Window> w3(CreateTestWindowUnparented()); |
| 1019 w1->AddTransientChild(w3.get()); | 1021 w1->AddTransientChild(w3.get()); |
| 1020 SetDefaultParentByPrimaryRootWindow(w3.get()); | 1022 SetDefaultParentByPrimaryRootWindow(w3.get()); |
| 1021 w3->Show(); | 1023 w3->Show(); |
| 1022 ASSERT_EQ("0 M3 active=1", StateString()); | 1024 ASSERT_EQ("0 F3 active=1", StateString()); |
| 1023 | 1025 |
| 1024 // Minimize the window. All the transients are hidden as a result, so it ends | 1026 // Minimize the window. All the transients are hidden as a result, so it ends |
| 1025 // up in pending. | 1027 // up in pending. |
| 1026 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MINIMIZED); | 1028 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MINIMIZED); |
| 1027 ASSERT_EQ("0 P=M3 active=0", StateString()); | 1029 ASSERT_EQ("0 P=F3 active=0", StateString()); |
| 1028 | 1030 |
| 1029 // Restore and everything should go back to the first workspace. | 1031 // Restore and everything should go back to the first workspace. |
| 1030 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); | 1032 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); |
| 1031 ASSERT_EQ("3 active=0", StateString()); | 1033 ASSERT_EQ("3 active=0", StateString()); |
| 1032 } | 1034 } |
| 1033 | 1035 |
| 1034 // Verifies window visibility during various workspace changes. | 1036 // Verifies window visibility during various workspace changes. |
| 1035 TEST_F(WorkspaceManagerTest, VisibilityTests) { | 1037 TEST_F(WorkspaceManagerTest, VisibilityTests) { |
| 1036 scoped_ptr<Window> w1(CreateTestWindow()); | 1038 scoped_ptr<Window> w1(CreateTestWindow()); |
| 1037 w1->Show(); | 1039 w1->Show(); |
| 1038 EXPECT_TRUE(w1->IsVisible()); | 1040 EXPECT_TRUE(w1->IsVisible()); |
| 1039 EXPECT_EQ(1.0f, w1->layer()->GetCombinedOpacity()); | 1041 EXPECT_EQ(1.0f, w1->layer()->GetCombinedOpacity()); |
| 1040 | 1042 |
| 1041 // Create another window, activate it and maximized it. | 1043 // Create another window, activate it and make it fullscreen. |
| 1042 scoped_ptr<Window> w2(CreateTestWindow()); | 1044 scoped_ptr<Window> w2(CreateTestWindow()); |
| 1043 w2->Show(); | 1045 w2->Show(); |
| 1044 wm::ActivateWindow(w2.get()); | 1046 wm::ActivateWindow(w2.get()); |
| 1045 w2->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); | 1047 w2->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN); |
| 1046 EXPECT_TRUE(w2->IsVisible()); | 1048 EXPECT_TRUE(w2->IsVisible()); |
| 1047 EXPECT_EQ(1.0f, w2->layer()->GetCombinedOpacity()); | 1049 EXPECT_EQ(1.0f, w2->layer()->GetCombinedOpacity()); |
| 1048 EXPECT_FALSE(w1->IsVisible()); | 1050 EXPECT_FALSE(w1->IsVisible()); |
| 1049 | 1051 |
| 1050 // Switch to w1. |w1| should be visible and |w2| hidden. | 1052 // Switch to w1. |w1| should be visible and |w2| hidden. |
| 1051 wm::ActivateWindow(w1.get()); | 1053 wm::ActivateWindow(w1.get()); |
| 1052 EXPECT_TRUE(w1->IsVisible()); | 1054 EXPECT_TRUE(w1->IsVisible()); |
| 1053 EXPECT_EQ(1.0f, w1->layer()->GetCombinedOpacity()); | 1055 EXPECT_EQ(1.0f, w1->layer()->GetCombinedOpacity()); |
| 1054 EXPECT_FALSE(w2->IsVisible()); | 1056 EXPECT_FALSE(w2->IsVisible()); |
| 1055 | 1057 |
| 1056 // Switch back to |w2|. | 1058 // Switch back to |w2|. |
| 1057 wm::ActivateWindow(w2.get()); | 1059 wm::ActivateWindow(w2.get()); |
| 1058 EXPECT_TRUE(w2->IsVisible()); | 1060 EXPECT_TRUE(w2->IsVisible()); |
| 1059 EXPECT_EQ(1.0f, w2->layer()->GetCombinedOpacity()); | 1061 EXPECT_EQ(1.0f, w2->layer()->GetCombinedOpacity()); |
| 1060 EXPECT_FALSE(w1->IsVisible()); | 1062 EXPECT_FALSE(w1->IsVisible()); |
| 1061 | 1063 |
| 1062 // Restore |w2|, both windows should be visible. | 1064 // Restore |w2|, both windows should be visible. |
| 1063 w2->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); | 1065 w2->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); |
| 1064 EXPECT_TRUE(w1->IsVisible()); | 1066 EXPECT_TRUE(w1->IsVisible()); |
| 1065 EXPECT_EQ(1.0f, w1->layer()->GetCombinedOpacity()); | 1067 EXPECT_EQ(1.0f, w1->layer()->GetCombinedOpacity()); |
| 1066 EXPECT_TRUE(w2->IsVisible()); | 1068 EXPECT_TRUE(w2->IsVisible()); |
| 1067 EXPECT_EQ(1.0f, w2->layer()->GetCombinedOpacity()); | 1069 EXPECT_EQ(1.0f, w2->layer()->GetCombinedOpacity()); |
| 1068 | 1070 |
| 1069 // Maximize |w2| again, then close it. | 1071 // Make |w2| fullscreen again, then close it. |
| 1070 w2->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); | 1072 w2->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN); |
| 1071 w2->Hide(); | 1073 w2->Hide(); |
| 1072 EXPECT_FALSE(w2->IsVisible()); | 1074 EXPECT_FALSE(w2->IsVisible()); |
| 1073 EXPECT_EQ(1.0f, w1->layer()->GetCombinedOpacity()); | 1075 EXPECT_EQ(1.0f, w1->layer()->GetCombinedOpacity()); |
| 1074 EXPECT_TRUE(w1->IsVisible()); | 1076 EXPECT_TRUE(w1->IsVisible()); |
| 1075 | 1077 |
| 1076 // Create |w2| and make it fullscreen. | 1078 // Create |w2| and maximize it. |
| 1077 w2.reset(CreateTestWindow()); | 1079 w2.reset(CreateTestWindow()); |
| 1078 w2->Show(); | 1080 w2->Show(); |
| 1079 wm::ActivateWindow(w2.get()); | 1081 wm::ActivateWindow(w2.get()); |
| 1080 w2->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN); | 1082 w2->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); |
| 1081 EXPECT_TRUE(w2->IsVisible()); | 1083 EXPECT_TRUE(w2->IsVisible()); |
| 1082 EXPECT_EQ(1.0f, w2->layer()->GetCombinedOpacity()); | 1084 EXPECT_EQ(1.0f, w2->layer()->GetCombinedOpacity()); |
| 1083 EXPECT_FALSE(w1->IsVisible()); | 1085 EXPECT_TRUE(w1->IsVisible()); |
| 1084 | 1086 |
| 1085 // Close |w2|. | 1087 // Close |w2|. |
| 1086 w2.reset(); | 1088 w2.reset(); |
| 1087 EXPECT_EQ(1.0f, w1->layer()->GetCombinedOpacity()); | 1089 EXPECT_EQ(1.0f, w1->layer()->GetCombinedOpacity()); |
| 1088 EXPECT_TRUE(w1->IsVisible()); | 1090 EXPECT_TRUE(w1->IsVisible()); |
| 1089 } | 1091 } |
| 1090 | 1092 |
| 1091 // Verifies windows that are offscreen don't move when switching workspaces. | 1093 // Verifies windows that are offscreen don't move when switching workspaces. |
| 1092 TEST_F(WorkspaceManagerTest, DontMoveOnSwitch) { | 1094 TEST_F(WorkspaceManagerTest, DontMoveOnSwitch) { |
| 1093 aura::test::EventGenerator generator( | 1095 aura::test::EventGenerator generator( |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1244 w1->Show(); | 1246 w1->Show(); |
| 1245 wm::ActivateWindow(w1.get()); | 1247 wm::ActivateWindow(w1.get()); |
| 1246 | 1248 |
| 1247 // The window with the transient parent should get added to the same parent as | 1249 // The window with the transient parent should get added to the same parent as |
| 1248 // the normal window. | 1250 // the normal window. |
| 1249 EXPECT_EQ(w2->parent(), w1->parent()); | 1251 EXPECT_EQ(w2->parent(), w1->parent()); |
| 1250 } | 1252 } |
| 1251 | 1253 |
| 1252 // Verifies changing TrackedByWorkspace works. | 1254 // Verifies changing TrackedByWorkspace works. |
| 1253 TEST_F(WorkspaceManagerTest, TrackedByWorkspace) { | 1255 TEST_F(WorkspaceManagerTest, TrackedByWorkspace) { |
| 1254 // Create a window maximized. | 1256 // Create a fullscreen window. |
| 1255 scoped_ptr<Window> w1(CreateTestWindow()); | 1257 scoped_ptr<Window> w1(CreateTestWindow()); |
| 1256 w1->Show(); | 1258 w1->Show(); |
| 1257 wm::ActivateWindow(w1.get()); | 1259 wm::ActivateWindow(w1.get()); |
| 1258 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); | 1260 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN); |
| 1259 EXPECT_TRUE(wm::IsActiveWindow(w1.get())); | 1261 EXPECT_TRUE(wm::IsActiveWindow(w1.get())); |
| 1260 EXPECT_TRUE(w1->IsVisible()); | 1262 EXPECT_TRUE(w1->IsVisible()); |
| 1261 | 1263 |
| 1262 // Create a second window maximized and mark it not tracked by workspace | 1264 // Create a second fullscreen window and mark it not tracked by workspace |
| 1263 // manager. | 1265 // manager. |
| 1264 scoped_ptr<Window> w2(CreateTestWindowUnparented()); | 1266 scoped_ptr<Window> w2(CreateTestWindowUnparented()); |
| 1265 w2->SetBounds(gfx::Rect(1, 6, 25, 30)); | 1267 w2->SetBounds(gfx::Rect(1, 6, 25, 30)); |
| 1266 w2->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); | 1268 w2->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN); |
| 1267 SetDefaultParentByPrimaryRootWindow(w2.get()); | 1269 SetDefaultParentByPrimaryRootWindow(w2.get()); |
| 1268 w2->Show(); | 1270 w2->Show(); |
| 1269 SetTrackedByWorkspace(w2.get(), false); | 1271 SetTrackedByWorkspace(w2.get(), false); |
| 1270 wm::ActivateWindow(w2.get()); | 1272 wm::ActivateWindow(w2.get()); |
| 1271 | 1273 |
| 1272 // Activating |w2| should force it to have the same parent as |w1|. | 1274 // Activating |w2| should force it to have the same parent as |w1|. |
| 1273 EXPECT_EQ(w1->parent(), w2->parent()); | 1275 EXPECT_EQ(w1->parent(), w2->parent()); |
| 1274 EXPECT_TRUE(wm::IsActiveWindow(w2.get())); | 1276 EXPECT_TRUE(wm::IsActiveWindow(w2.get())); |
| 1275 EXPECT_TRUE(w1->IsVisible()); | 1277 EXPECT_TRUE(w1->IsVisible()); |
| 1276 EXPECT_TRUE(w2->IsVisible()); | 1278 EXPECT_TRUE(w2->IsVisible()); |
| 1277 | 1279 |
| 1278 // Because |w2| isn't tracked we should be able to set the bounds of it. | 1280 // Because |w2| isn't tracked we should be able to set the bounds of it. |
| 1279 gfx::Rect bounds(w2->bounds()); | 1281 gfx::Rect bounds(w2->bounds()); |
| 1280 bounds.Offset(4, 5); | 1282 bounds.Offset(4, 5); |
| 1281 w2->SetBounds(bounds); | 1283 w2->SetBounds(bounds); |
| 1282 EXPECT_EQ(bounds.ToString(), w2->bounds().ToString()); | 1284 EXPECT_EQ(bounds.ToString(), w2->bounds().ToString()); |
| 1283 | 1285 |
| 1284 // Transition it to tracked by worskpace. It should end up in its own | 1286 // Transition it to tracked by worskpace. It should end up in its own |
| 1285 // workspace. | 1287 // workspace. |
| 1286 SetTrackedByWorkspace(w2.get(), true); | 1288 SetTrackedByWorkspace(w2.get(), true); |
| 1287 EXPECT_TRUE(wm::IsActiveWindow(w2.get())); | 1289 EXPECT_TRUE(wm::IsActiveWindow(w2.get())); |
| 1288 EXPECT_FALSE(w1->IsVisible()); | 1290 EXPECT_FALSE(w1->IsVisible()); |
| 1289 EXPECT_TRUE(w2->IsVisible()); | 1291 EXPECT_TRUE(w2->IsVisible()); |
| 1290 EXPECT_NE(w1->parent(), w2->parent()); | 1292 EXPECT_NE(w1->parent(), w2->parent()); |
| 1291 } | 1293 } |
| 1292 | 1294 |
| 1293 // Verifies a window marked as persisting across all workspaces ends up in its | 1295 // Verifies a window marked as persisting across all workspaces ends up in its |
| 1294 // own workspace when maximized. | 1296 // own workspace when get fullscreen. |
| 1295 TEST_F(WorkspaceManagerTest, DeactivateDropsToDesktop) { | 1297 TEST_F(WorkspaceManagerTest, DeactivateDropsToDesktop) { |
| 1296 // Create a window maximized. | 1298 // Create a fullscreen window. |
| 1297 scoped_ptr<Window> w1(CreateTestWindow()); | 1299 scoped_ptr<Window> w1(CreateTestWindow()); |
| 1298 w1->Show(); | 1300 w1->Show(); |
| 1299 wm::ActivateWindow(w1.get()); | 1301 wm::ActivateWindow(w1.get()); |
| 1300 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); | 1302 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN); |
| 1301 EXPECT_TRUE(wm::IsActiveWindow(w1.get())); | 1303 EXPECT_TRUE(wm::IsActiveWindow(w1.get())); |
| 1302 EXPECT_TRUE(w1->IsVisible()); | 1304 EXPECT_TRUE(w1->IsVisible()); |
| 1303 | 1305 |
| 1304 // Create another window that persists across all workspaces. It should end | 1306 // Create another window that persists across all workspaces. It should end |
| 1305 // up with the same parent as |w1|. | 1307 // up with the same parent as |w1|. |
| 1306 scoped_ptr<Window> w2(CreateTestWindow()); | 1308 scoped_ptr<Window> w2(CreateTestWindow()); |
| 1307 SetPersistsAcrossAllWorkspaces( | 1309 SetPersistsAcrossAllWorkspaces( |
| 1308 w2.get(), | 1310 w2.get(), |
| 1309 WINDOW_PERSISTS_ACROSS_ALL_WORKSPACES_VALUE_YES); | 1311 WINDOW_PERSISTS_ACROSS_ALL_WORKSPACES_VALUE_YES); |
| 1310 w2->Show(); | 1312 w2->Show(); |
| 1311 wm::ActivateWindow(w2.get()); | 1313 wm::ActivateWindow(w2.get()); |
| 1312 EXPECT_EQ(w1->parent(), w2->parent()); | 1314 EXPECT_EQ(w1->parent(), w2->parent()); |
| 1313 ASSERT_EQ("0 M2 active=1", StateString()); | 1315 ASSERT_EQ("0 F2 active=1", StateString()); |
| 1314 | 1316 |
| 1315 // Activate |w1|, should result in dropping |w2| to the desktop. | 1317 // Activate |w1|, should result in dropping |w2| to the desktop. |
| 1316 wm::ActivateWindow(w1.get()); | 1318 wm::ActivateWindow(w1.get()); |
| 1317 ASSERT_EQ("1 M1 active=1", StateString()); | 1319 ASSERT_EQ("1 F1 active=1", StateString()); |
| 1318 } | 1320 } |
| 1319 | 1321 |
| 1320 // Test the basic auto placement of one and or two windows in a "simulated | 1322 // Test the basic auto placement of one and or two windows in a "simulated |
| 1321 // session" of sequential window operations. | 1323 // session" of sequential window operations. |
| 1322 TEST_F(WorkspaceManagerTest, BasicAutoPlacing) { | 1324 TEST_F(WorkspaceManagerTest, BasicAutoPlacing) { |
| 1323 // Test 1: In case there is no manageable window, no window should shift. | 1325 // Test 1: In case there is no manageable window, no window should shift. |
| 1324 | 1326 |
| 1325 scoped_ptr<aura::Window> window1(CreateTestWindowInShellWithId(0)); | 1327 scoped_ptr<aura::Window> window1(CreateTestWindowInShellWithId(0)); |
| 1326 window1->SetBounds(gfx::Rect(16, 32, 640, 320)); | 1328 window1->SetBounds(gfx::Rect(16, 32, 640, 320)); |
| 1327 gfx::Rect desktop_area = window1->parent()->bounds(); | 1329 gfx::Rect desktop_area = window1->parent()->bounds(); |
| (...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1723 } | 1725 } |
| 1724 | 1726 |
| 1725 private: | 1727 private: |
| 1726 int change_count_; | 1728 int change_count_; |
| 1727 | 1729 |
| 1728 DISALLOW_COPY_AND_ASSIGN(DragMaximizedNonTrackedWindowObserver); | 1730 DISALLOW_COPY_AND_ASSIGN(DragMaximizedNonTrackedWindowObserver); |
| 1729 }; | 1731 }; |
| 1730 | 1732 |
| 1731 } // namespace | 1733 } // namespace |
| 1732 | 1734 |
| 1733 // Verifies setting tracked by workspace to false and then dragging a maximized | 1735 // Verifies setting tracked by workspace to false and then dragging a fullscreen |
| 1734 // window doesn't result in changing the window hierarchy (which typically | 1736 // window doesn't result in changing the window hierarchy (which typically |
| 1735 // indicates new workspaces have been created). | 1737 // indicates new workspaces have been created). |
| 1736 TEST_F(WorkspaceManagerTest, DragMaximizedNonTrackedWindow) { | 1738 TEST_F(WorkspaceManagerTest, DragFullscreenNonTrackedWindow) { |
| 1737 aura::test::EventGenerator generator( | 1739 aura::test::EventGenerator generator( |
| 1738 Shell::GetPrimaryRootWindow(), gfx::Point()); | 1740 Shell::GetPrimaryRootWindow(), gfx::Point()); |
| 1739 generator.MoveMouseTo(5, 5); | 1741 generator.MoveMouseTo(5, 5); |
| 1740 | 1742 |
| 1741 aura::test::TestWindowDelegate delegate; | 1743 aura::test::TestWindowDelegate delegate; |
| 1742 delegate.set_window_component(HTCAPTION); | 1744 delegate.set_window_component(HTCAPTION); |
| 1743 scoped_ptr<Window> w1( | 1745 scoped_ptr<Window> w1( |
| 1744 aura::test::CreateTestWindowWithDelegate(&delegate, | 1746 aura::test::CreateTestWindowWithDelegate(&delegate, |
| 1745 aura::client::WINDOW_TYPE_NORMAL, | 1747 aura::client::WINDOW_TYPE_NORMAL, |
| 1746 gfx::Rect(5, 6, 7, 8), | 1748 gfx::Rect(5, 6, 7, 8), |
| 1747 NULL)); | 1749 NULL)); |
| 1748 SetDefaultParentByPrimaryRootWindow(w1.get()); | 1750 SetDefaultParentByPrimaryRootWindow(w1.get()); |
| 1749 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); | 1751 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN); |
| 1750 w1->Show(); | 1752 w1->Show(); |
| 1751 wm::ActivateWindow(w1.get()); | 1753 wm::ActivateWindow(w1.get()); |
| 1752 DragMaximizedNonTrackedWindowObserver observer; | 1754 DragMaximizedNonTrackedWindowObserver observer; |
| 1753 w1->parent()->parent()->AddObserver(&observer); | 1755 w1->parent()->parent()->AddObserver(&observer); |
| 1754 const gfx::Rect max_bounds(w1->bounds()); | 1756 const gfx::Rect max_bounds(w1->bounds()); |
| 1755 | 1757 |
| 1756 // There should be two workspace, one for the desktop and one for the | 1758 // There should be two workspace, one for the desktop and one for the |
| 1757 // maximized window with the maximized active. | 1759 // maximized window with the maximized active. |
| 1758 EXPECT_EQ("0 M1 active=1", StateString()); | 1760 EXPECT_EQ("0 F1 active=1", StateString()); |
| 1759 | 1761 |
| 1760 generator.PressLeftButton(); | 1762 generator.PressLeftButton(); |
| 1761 generator.MoveMouseTo(100, 100); | 1763 generator.MoveMouseTo(100, 100); |
| 1762 // The bounds shouldn't change (drag should result in nothing happening | 1764 // The bounds shouldn't change (drag should result in nothing happening |
| 1763 // now. | 1765 // now. |
| 1764 EXPECT_EQ(max_bounds.ToString(), w1->bounds().ToString()); | 1766 EXPECT_EQ(max_bounds.ToString(), w1->bounds().ToString()); |
| 1765 EXPECT_EQ("0 M1 active=1", StateString()); | 1767 EXPECT_EQ("0 F1 active=1", StateString()); |
| 1766 | 1768 |
| 1767 generator.ReleaseLeftButton(); | 1769 generator.ReleaseLeftButton(); |
| 1768 EXPECT_EQ(0, observer.change_count()); | 1770 EXPECT_EQ(0, observer.change_count()); |
| 1771 |
| 1772 // Set tracked to false and repeat, now the window should move. |
| 1773 SetTrackedByWorkspace(w1.get(), false); |
| 1774 generator.MoveMouseTo(5, 5); |
| 1775 generator.PressLeftButton(); |
| 1776 generator.MoveMouseBy(100, 100); |
| 1777 EXPECT_EQ(gfx::Rect(max_bounds.x() + 100, max_bounds.y() + 100, |
| 1778 max_bounds.width(), max_bounds.height()).ToString(), |
| 1779 w1->bounds().ToString()); |
| 1780 EXPECT_EQ("0 F1 active=1", StateString()); |
| 1781 |
| 1782 generator.ReleaseLeftButton(); |
| 1783 SetTrackedByWorkspace(w1.get(), true); |
| 1784 // Marking the window tracked again should snap back to origin. |
| 1785 EXPECT_EQ("0 F1 active=1", StateString()); |
| 1786 EXPECT_EQ(max_bounds.ToString(), w1->bounds().ToString()); |
| 1787 EXPECT_EQ(0, observer.change_count()); |
| 1788 |
| 1789 w1->parent()->parent()->RemoveObserver(&observer); |
| 1790 } |
| 1791 |
| 1792 // Verifies setting tracked by workspace to false and then dragging a maximized |
| 1793 // window can change the bound. |
| 1794 TEST_F(WorkspaceManagerTest, DragMaximizedNonTrackedWindow) { |
| 1795 aura::test::EventGenerator generator( |
| 1796 Shell::GetPrimaryRootWindow(), gfx::Point()); |
| 1797 generator.MoveMouseTo(5, 5); |
| 1798 |
| 1799 aura::test::TestWindowDelegate delegate; |
| 1800 delegate.set_window_component(HTCAPTION); |
| 1801 scoped_ptr<Window> w1( |
| 1802 aura::test::CreateTestWindowWithDelegate(&delegate, |
| 1803 aura::client::WINDOW_TYPE_NORMAL, |
| 1804 gfx::Rect(5, 6, 7, 8), |
| 1805 NULL)); |
| 1806 SetDefaultParentByPrimaryRootWindow(w1.get()); |
| 1807 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); |
| 1808 w1->Show(); |
| 1809 wm::ActivateWindow(w1.get()); |
| 1810 DragMaximizedNonTrackedWindowObserver observer; |
| 1811 w1->parent()->parent()->AddObserver(&observer); |
| 1812 const gfx::Rect max_bounds(w1->bounds()); |
| 1813 |
| 1814 generator.PressLeftButton(); |
| 1815 generator.MoveMouseTo(100, 100); |
| 1816 // The bounds shouldn't change (drag should result in nothing happening |
| 1817 // now. |
| 1818 EXPECT_EQ(max_bounds.ToString(), w1->bounds().ToString()); |
| 1819 |
| 1820 generator.ReleaseLeftButton(); |
| 1821 EXPECT_EQ(0, observer.change_count()); |
| 1769 | 1822 |
| 1770 // Set tracked to false and repeat, now the window should move. | 1823 // Set tracked to false and repeat, now the window should move. |
| 1771 SetTrackedByWorkspace(w1.get(), false); | 1824 SetTrackedByWorkspace(w1.get(), false); |
| 1772 generator.MoveMouseTo(5, 5); | 1825 generator.MoveMouseTo(5, 5); |
| 1773 generator.PressLeftButton(); | 1826 generator.PressLeftButton(); |
| 1774 generator.MoveMouseBy(100, 100); | 1827 generator.MoveMouseBy(100, 100); |
| 1775 EXPECT_EQ(gfx::Rect(max_bounds.x() + 100, max_bounds.y() + 100, | 1828 EXPECT_EQ(gfx::Rect(max_bounds.x() + 100, max_bounds.y() + 100, |
| 1776 max_bounds.width(), max_bounds.height()).ToString(), | 1829 max_bounds.width(), max_bounds.height()).ToString(), |
| 1777 w1->bounds().ToString()); | 1830 w1->bounds().ToString()); |
| 1778 EXPECT_EQ("0 M1 active=1", StateString()); | |
| 1779 | 1831 |
| 1780 generator.ReleaseLeftButton(); | 1832 generator.ReleaseLeftButton(); |
| 1781 SetTrackedByWorkspace(w1.get(), true); | 1833 SetTrackedByWorkspace(w1.get(), true); |
| 1782 // Marking the window tracked again should snap back to origin. | 1834 // Marking the window tracked again should snap back to origin. |
| 1783 EXPECT_EQ("0 M1 active=1", StateString()); | |
| 1784 EXPECT_EQ(max_bounds.ToString(), w1->bounds().ToString()); | 1835 EXPECT_EQ(max_bounds.ToString(), w1->bounds().ToString()); |
| 1785 EXPECT_EQ(0, observer.change_count()); | 1836 EXPECT_EQ(0, observer.change_count()); |
| 1786 | 1837 |
| 1787 w1->parent()->parent()->RemoveObserver(&observer); | 1838 w1->parent()->parent()->RemoveObserver(&observer); |
| 1788 } | 1839 } |
| 1789 | 1840 |
| 1790 // Verifies that a new maximized window becomes visible after its activation | 1841 // Verifies that a new maximized window becomes visible after its activation |
| 1791 // is requested, even though it does not become activated because a system | 1842 // is requested, even though it does not become activated because a system |
| 1792 // modal window is active. | 1843 // modal window is active. |
| 1793 TEST_F(WorkspaceManagerTest, SwitchFromModal) { | 1844 TEST_F(WorkspaceManagerTest, SwitchFromModal) { |
| 1794 scoped_ptr<Window> modal_window(CreateTestWindowUnparented()); | 1845 scoped_ptr<Window> modal_window(CreateTestWindowUnparented()); |
| 1795 modal_window->SetBounds(gfx::Rect(10, 11, 21, 22)); | 1846 modal_window->SetBounds(gfx::Rect(10, 11, 21, 22)); |
| 1796 modal_window->SetProperty(aura::client::kModalKey, ui::MODAL_TYPE_SYSTEM); | 1847 modal_window->SetProperty(aura::client::kModalKey, ui::MODAL_TYPE_SYSTEM); |
| 1797 SetDefaultParentByPrimaryRootWindow(modal_window.get()); | 1848 SetDefaultParentByPrimaryRootWindow(modal_window.get()); |
| 1798 modal_window->Show(); | 1849 modal_window->Show(); |
| 1799 wm::ActivateWindow(modal_window.get()); | 1850 wm::ActivateWindow(modal_window.get()); |
| 1800 | 1851 |
| 1801 scoped_ptr<Window> maximized_window(CreateTestWindow()); | 1852 scoped_ptr<Window> maximized_window(CreateTestWindow()); |
| 1802 maximized_window->SetProperty( | 1853 maximized_window->SetProperty( |
| 1803 aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); | 1854 aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); |
| 1804 maximized_window->Show(); | 1855 maximized_window->Show(); |
| 1805 wm::ActivateWindow(maximized_window.get()); | 1856 wm::ActivateWindow(maximized_window.get()); |
| 1806 EXPECT_TRUE(maximized_window->IsVisible()); | 1857 EXPECT_TRUE(maximized_window->IsVisible()); |
| 1807 } | 1858 } |
| 1808 | 1859 |
| 1809 } // namespace internal | 1860 } // namespace internal |
| 1810 } // namespace ash | 1861 } // namespace ash |
| OLD | NEW |