| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include <stddef.h> | 5 #include <stddef.h> |
| 6 #include <stdint.h> | 6 #include <stdint.h> |
| 7 | 7 |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| (...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 213 window_ = nullptr; | 213 window_ = nullptr; |
| 214 } | 214 } |
| 215 | 215 |
| 216 aura::Window* window_; | 216 aura::Window* window_; |
| 217 | 217 |
| 218 DISALLOW_COPY_AND_ASSIGN(WindowTracker); | 218 DISALLOW_COPY_AND_ASSIGN(WindowTracker); |
| 219 }; | 219 }; |
| 220 | 220 |
| 221 // Creates a new visible Window. If |parent| is non-null the newly created | 221 // Creates a new visible Window. If |parent| is non-null the newly created |
| 222 // window is added to it. | 222 // window is added to it. |
| 223 aura::Window* NewVisibleWindow(aura::Window* parent, | 223 aura::Window* NewVisibleWindow( |
| 224 aura::WindowTreeClient* client) { | 224 aura::Window* parent, |
| 225 aura::WindowTreeClient* client, |
| 226 aura::WindowMusType type = aura::WindowMusType::LOCAL) { |
| 225 std::unique_ptr<aura::WindowPortMus> window_port_mus = | 227 std::unique_ptr<aura::WindowPortMus> window_port_mus = |
| 226 base::MakeUnique<aura::WindowPortMus>(client, aura::WindowMusType::LOCAL); | 228 base::MakeUnique<aura::WindowPortMus>(client, type); |
| 227 aura::Window* window = new aura::Window(nullptr, std::move(window_port_mus)); | 229 aura::Window* window = new aura::Window(nullptr, std::move(window_port_mus)); |
| 228 window->Init(ui::LAYER_NOT_DRAWN); | 230 window->Init(ui::LAYER_NOT_DRAWN); |
| 229 window->Show(); | 231 window->Show(); |
| 230 if (parent) | 232 if (parent) |
| 231 parent->AddChild(window); | 233 parent->AddChild(window); |
| 232 return window; | 234 return window; |
| 233 } | 235 } |
| 234 | 236 |
| 235 } // namespace | 237 } // namespace |
| 236 | 238 |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 369 | 371 |
| 370 DISALLOW_COPY_AND_ASSIGN(WindowServerTest); | 372 DISALLOW_COPY_AND_ASSIGN(WindowServerTest); |
| 371 }; | 373 }; |
| 372 | 374 |
| 373 TEST_F(WindowServerTest, RootWindow) { | 375 TEST_F(WindowServerTest, RootWindow) { |
| 374 ASSERT_NE(nullptr, window_manager()); | 376 ASSERT_NE(nullptr, window_manager()); |
| 375 EXPECT_EQ(1u, window_manager()->GetRoots().size()); | 377 EXPECT_EQ(1u, window_manager()->GetRoots().size()); |
| 376 } | 378 } |
| 377 | 379 |
| 378 TEST_F(WindowServerTest, Embed) { | 380 TEST_F(WindowServerTest, Embed) { |
| 379 aura::Window* window = NewVisibleWindow(GetFirstWMRoot(), window_manager()); | 381 aura::Window* window = NewVisibleWindow(GetFirstWMRoot(), window_manager(), |
| 382 aura::WindowMusType::EMBED_IN_OWNER); |
| 380 std::unique_ptr<EmbedResult> embed_result = Embed(window_manager(), window); | 383 std::unique_ptr<EmbedResult> embed_result = Embed(window_manager(), window); |
| 381 ASSERT_TRUE(embed_result->IsValid()); | 384 ASSERT_TRUE(embed_result->IsValid()); |
| 382 | 385 |
| 383 aura::Window* embed_root = embed_result->window_tree_host->window(); | 386 aura::Window* embed_root = embed_result->window_tree_host->window(); |
| 384 // WindowTreeHost::window() is the single root of the embed. | 387 // WindowTreeHost::window() is the single root of the embed. |
| 385 EXPECT_EQ(1u, embed_result->window_tree_client->GetRoots().size()); | 388 EXPECT_EQ(1u, embed_result->window_tree_client->GetRoots().size()); |
| 386 EXPECT_EQ(embed_root, GetFirstRoot(embed_result->window_tree_client.get())); | 389 EXPECT_EQ(embed_root, GetFirstRoot(embed_result->window_tree_client.get())); |
| 387 EXPECT_EQ(server_id(window), server_id(embed_root)); | 390 EXPECT_EQ(server_id(window), server_id(embed_root)); |
| 388 EXPECT_EQ(nullptr, embed_root->parent()); | 391 EXPECT_EQ(nullptr, embed_root->parent()); |
| 389 EXPECT_TRUE(embed_root->children().empty()); | 392 EXPECT_TRUE(embed_root->children().empty()); |
| 390 } | 393 } |
| 391 | 394 |
| 392 // Window manager has two windows, N1 and N11. Embeds A at N1. A should not see | 395 // Window manager has two windows, N1 and N11. Embeds A at N1. A should not see |
| 393 // N11. | 396 // N11. |
| 394 TEST_F(WindowServerTest, EmbeddedDoesntSeeChild) { | 397 TEST_F(WindowServerTest, EmbeddedDoesntSeeChild) { |
| 395 aura::Window* window = NewVisibleWindow(GetFirstWMRoot(), window_manager()); | 398 aura::Window* window = NewVisibleWindow(GetFirstWMRoot(), window_manager(), |
| 399 aura::WindowMusType::EMBED_IN_OWNER); |
| 396 std::unique_ptr<EmbedResult> embed_result = Embed(window_manager(), window); | 400 std::unique_ptr<EmbedResult> embed_result = Embed(window_manager(), window); |
| 397 ASSERT_TRUE(embed_result->IsValid()); | 401 ASSERT_TRUE(embed_result->IsValid()); |
| 398 aura::Window* embed_root = embed_result->window_tree_host->window(); | 402 aura::Window* embed_root = embed_result->window_tree_host->window(); |
| 399 EXPECT_EQ(server_id(window), server_id(embed_root)); | 403 EXPECT_EQ(server_id(window), server_id(embed_root)); |
| 400 EXPECT_EQ(nullptr, embed_root->parent()); | 404 EXPECT_EQ(nullptr, embed_root->parent()); |
| 401 EXPECT_TRUE(embed_root->children().empty()); | 405 EXPECT_TRUE(embed_root->children().empty()); |
| 402 } | 406 } |
| 403 | 407 |
| 404 // TODO(beng): write a replacement test for the one that once existed here: | 408 // TODO(beng): write a replacement test for the one that once existed here: |
| 405 // This test validates the following scenario: | 409 // This test validates the following scenario: |
| 406 // - a window originating from one client | 410 // - a window originating from one client |
| 407 // - a window originating from a second client | 411 // - a window originating from a second client |
| 408 // + the client originating the window is destroyed | 412 // + the client originating the window is destroyed |
| 409 // -> the window should still exist (since the second client is live) but | 413 // -> the window should still exist (since the second client is live) but |
| 410 // should be disconnected from any windows. | 414 // should be disconnected from any windows. |
| 411 // http://crbug.com/396300 | 415 // http://crbug.com/396300 |
| 412 // | 416 // |
| 413 // TODO(beng): The new test should validate the scenario as described above | 417 // TODO(beng): The new test should validate the scenario as described above |
| 414 // except that the second client still has a valid tree. | 418 // except that the second client still has a valid tree. |
| 415 | 419 |
| 416 // Verifies that bounds changes applied to a window hierarchy in one client | 420 // Verifies that bounds changes applied to a window hierarchy in one client |
| 417 // are reflected to another. | 421 // are reflected to another. |
| 418 TEST_F(WindowServerTest, SetBounds) { | 422 TEST_F(WindowServerTest, SetBounds) { |
| 419 aura::Window* window = NewVisibleWindow(GetFirstWMRoot(), window_manager()); | 423 aura::Window* window = NewVisibleWindow(GetFirstWMRoot(), window_manager(), |
| 424 aura::WindowMusType::EMBED_IN_OWNER); |
| 420 | 425 |
| 421 std::unique_ptr<EmbedResult> embed_result = Embed(window_manager(), window); | 426 std::unique_ptr<EmbedResult> embed_result = Embed(window_manager(), window); |
| 422 ASSERT_TRUE(embed_result->IsValid()); | 427 ASSERT_TRUE(embed_result->IsValid()); |
| 423 aura::Window* embed_root = embed_result->window_tree_host->window(); | 428 aura::Window* embed_root = embed_result->window_tree_host->window(); |
| 424 EXPECT_EQ(window->bounds(), embed_root->bounds()); | 429 EXPECT_EQ(window->bounds(), embed_root->bounds()); |
| 425 | 430 |
| 426 window->SetBounds(gfx::Rect(0, 0, 100, 100)); | 431 window->SetBounds(gfx::Rect(0, 0, 100, 100)); |
| 427 ASSERT_TRUE(WaitForBoundsToChange(embed_root)); | 432 ASSERT_TRUE(WaitForBoundsToChange(embed_root)); |
| 428 EXPECT_EQ(window->bounds(), embed_root->bounds()); | 433 EXPECT_EQ(window->bounds(), embed_root->bounds()); |
| 429 } | 434 } |
| 430 | 435 |
| 431 // Verifies that bounds changes applied to a window owned by a different | 436 // Verifies that bounds changes applied to a window owned by a different |
| 432 // client can be refused. | 437 // client can be refused. |
| 433 TEST_F(WindowServerTest, SetBoundsSecurity) { | 438 TEST_F(WindowServerTest, SetBoundsSecurity) { |
| 434 TestWindowManagerDelegate wm_delegate; | 439 TestWindowManagerDelegate wm_delegate; |
| 435 set_window_manager_delegate(&wm_delegate); | 440 set_window_manager_delegate(&wm_delegate); |
| 436 | 441 |
| 437 aura::Window* window = NewVisibleWindow(GetFirstWMRoot(), window_manager()); | 442 aura::Window* window = NewVisibleWindow(GetFirstWMRoot(), window_manager(), |
| 443 aura::WindowMusType::EMBED_IN_OWNER); |
| 438 | 444 |
| 439 std::unique_ptr<EmbedResult> embed_result = Embed(window_manager(), window); | 445 std::unique_ptr<EmbedResult> embed_result = Embed(window_manager(), window); |
| 440 ASSERT_TRUE(embed_result->IsValid()); | 446 ASSERT_TRUE(embed_result->IsValid()); |
| 441 aura::Window* embed_root = embed_result->window_tree_host->window(); | 447 aura::Window* embed_root = embed_result->window_tree_host->window(); |
| 442 window->SetBounds(gfx::Rect(0, 0, 800, 600)); | 448 window->SetBounds(gfx::Rect(0, 0, 800, 600)); |
| 443 ASSERT_TRUE(WaitForBoundsToChange(embed_root)); | 449 ASSERT_TRUE(WaitForBoundsToChange(embed_root)); |
| 444 | 450 |
| 445 embed_result->window_tree_host->SetBoundsInPixels(gfx::Rect(0, 0, 1024, 768)); | 451 embed_result->window_tree_host->SetBoundsInPixels(gfx::Rect(0, 0, 1024, 768)); |
| 446 // Bounds change is initially accepted, but the server declines the request. | 452 // Bounds change is initially accepted, but the server declines the request. |
| 447 EXPECT_NE(window->bounds(), embed_root->bounds()); | 453 EXPECT_NE(window->bounds(), embed_root->bounds()); |
| 448 | 454 |
| 449 // The client is notified when the requested is declined, and updates the | 455 // The client is notified when the requested is declined, and updates the |
| 450 // local bounds accordingly. | 456 // local bounds accordingly. |
| 451 ASSERT_TRUE(WaitForBoundsToChange(embed_root)); | 457 ASSERT_TRUE(WaitForBoundsToChange(embed_root)); |
| 452 EXPECT_EQ(window->bounds(), embed_root->bounds()); | 458 EXPECT_EQ(window->bounds(), embed_root->bounds()); |
| 453 set_window_manager_delegate(nullptr); | 459 set_window_manager_delegate(nullptr); |
| 454 } | 460 } |
| 455 | 461 |
| 456 // Verifies that a root window can always be destroyed. | 462 // Verifies that a root window can always be destroyed. |
| 457 TEST_F(WindowServerTest, DestroySecurity) { | 463 TEST_F(WindowServerTest, DestroySecurity) { |
| 458 aura::Window* window = NewVisibleWindow(GetFirstWMRoot(), window_manager()); | 464 aura::Window* window = NewVisibleWindow(GetFirstWMRoot(), window_manager(), |
| 465 aura::WindowMusType::EMBED_IN_OWNER); |
| 459 | 466 |
| 460 std::unique_ptr<EmbedResult> embed_result = Embed(window_manager(), window); | 467 std::unique_ptr<EmbedResult> embed_result = Embed(window_manager(), window); |
| 461 ASSERT_TRUE(embed_result->IsValid()); | 468 ASSERT_TRUE(embed_result->IsValid()); |
| 462 aura::Window* embed_root = embed_result->window_tree_host->window(); | 469 aura::Window* embed_root = embed_result->window_tree_host->window(); |
| 463 | 470 |
| 464 // The root can be destroyed, even though it was not created by the client. | 471 // The root can be destroyed, even though it was not created by the client. |
| 465 aura::WindowTracker tracker; | 472 aura::WindowTracker tracker; |
| 466 tracker.Add(window); | 473 tracker.Add(window); |
| 467 tracker.Add(embed_root); | 474 tracker.Add(embed_root); |
| 468 embed_result->window_tree_host.reset(); | 475 embed_result->window_tree_host.reset(); |
| 469 EXPECT_FALSE(tracker.Contains(embed_root)); | 476 EXPECT_FALSE(tracker.Contains(embed_root)); |
| 470 EXPECT_TRUE(tracker.Contains(window)); | 477 EXPECT_TRUE(tracker.Contains(window)); |
| 471 | 478 |
| 472 delete window; | 479 delete window; |
| 473 EXPECT_FALSE(tracker.Contains(window)); | 480 EXPECT_FALSE(tracker.Contains(window)); |
| 474 } | 481 } |
| 475 | 482 |
| 476 TEST_F(WindowServerTest, MultiRoots) { | 483 TEST_F(WindowServerTest, MultiRoots) { |
| 477 aura::Window* window1 = NewVisibleWindow(GetFirstWMRoot(), window_manager()); | 484 aura::Window* window1 = NewVisibleWindow(GetFirstWMRoot(), window_manager(), |
| 478 aura::Window* window2 = NewVisibleWindow(GetFirstWMRoot(), window_manager()); | 485 aura::WindowMusType::EMBED_IN_OWNER); |
| 486 aura::Window* window2 = NewVisibleWindow(GetFirstWMRoot(), window_manager(), |
| 487 aura::WindowMusType::EMBED_IN_OWNER); |
| 479 std::unique_ptr<EmbedResult> embed_result1 = Embed(window_manager(), window1); | 488 std::unique_ptr<EmbedResult> embed_result1 = Embed(window_manager(), window1); |
| 480 ASSERT_TRUE(embed_result1->IsValid()); | 489 ASSERT_TRUE(embed_result1->IsValid()); |
| 481 std::unique_ptr<EmbedResult> embed_result2 = Embed(window_manager(), window2); | 490 std::unique_ptr<EmbedResult> embed_result2 = Embed(window_manager(), window2); |
| 482 ASSERT_TRUE(embed_result2->IsValid()); | 491 ASSERT_TRUE(embed_result2->IsValid()); |
| 483 } | 492 } |
| 484 | 493 |
| 485 TEST_F(WindowServerTest, Reorder) { | 494 TEST_F(WindowServerTest, Reorder) { |
| 486 aura::Window* window1 = NewVisibleWindow(GetFirstWMRoot(), window_manager()); | 495 aura::Window* window1 = NewVisibleWindow(GetFirstWMRoot(), window_manager(), |
| 496 aura::WindowMusType::EMBED_IN_OWNER); |
| 487 | 497 |
| 488 std::unique_ptr<EmbedResult> embed_result = Embed(window_manager(), window1); | 498 std::unique_ptr<EmbedResult> embed_result = Embed(window_manager(), window1); |
| 489 ASSERT_TRUE(embed_result->IsValid()); | 499 ASSERT_TRUE(embed_result->IsValid()); |
| 490 aura::WindowTreeClient* embedded = embed_result->window_tree_client.get(); | 500 aura::WindowTreeClient* embedded = embed_result->window_tree_client.get(); |
| 491 aura::Window* embed_root = embed_result->window_tree_host->window(); | 501 aura::Window* embed_root = embed_result->window_tree_host->window(); |
| 492 | 502 |
| 493 aura::Window* window11 = NewVisibleWindow(embed_root, embedded); | 503 aura::Window* window11 = NewVisibleWindow(embed_root, embedded); |
| 494 aura::Window* window12 = NewVisibleWindow(embed_root, embedded); | 504 aura::Window* window12 = NewVisibleWindow(embed_root, embedded); |
| 495 ASSERT_TRUE(WaitForTreeSizeToMatch(window1, 3u)); | 505 ASSERT_TRUE(WaitForTreeSizeToMatch(window1, 3u)); |
| 496 | 506 |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 553 } | 563 } |
| 554 | 564 |
| 555 aura::Window* window_; | 565 aura::Window* window_; |
| 556 | 566 |
| 557 DISALLOW_COPY_AND_ASSIGN(VisibilityChangeObserver); | 567 DISALLOW_COPY_AND_ASSIGN(VisibilityChangeObserver); |
| 558 }; | 568 }; |
| 559 | 569 |
| 560 } // namespace | 570 } // namespace |
| 561 | 571 |
| 562 TEST_F(WindowServerTest, Visible) { | 572 TEST_F(WindowServerTest, Visible) { |
| 563 aura::Window* window1 = NewVisibleWindow(GetFirstWMRoot(), window_manager()); | 573 aura::Window* window1 = NewVisibleWindow(GetFirstWMRoot(), window_manager(), |
| 574 aura::WindowMusType::EMBED_IN_OWNER); |
| 564 | 575 |
| 565 // Embed another app and verify initial state. | 576 // Embed another app and verify initial state. |
| 566 std::unique_ptr<EmbedResult> embed_result = Embed(window_manager(), window1); | 577 std::unique_ptr<EmbedResult> embed_result = Embed(window_manager(), window1); |
| 567 ASSERT_TRUE(embed_result->IsValid()); | 578 ASSERT_TRUE(embed_result->IsValid()); |
| 568 aura::Window* embed_root = embed_result->window_tree_host->window(); | 579 aura::Window* embed_root = embed_result->window_tree_host->window(); |
| 569 EXPECT_TRUE(embed_root->TargetVisibility()); | 580 EXPECT_TRUE(embed_root->TargetVisibility()); |
| 570 EXPECT_TRUE(embed_root->IsVisible()); | 581 EXPECT_TRUE(embed_root->IsVisible()); |
| 571 | 582 |
| 572 // Change the visible state from the first client and verify its mirrored | 583 // Change the visible state from the first client and verify its mirrored |
| 573 // correctly to the embedded app. | 584 // correctly to the embedded app. |
| (...skipping 20 matching lines...) Expand all Loading... |
| 594 EXPECT_TRUE(window1->IsVisible()); | 605 EXPECT_TRUE(window1->IsVisible()); |
| 595 | 606 |
| 596 EXPECT_TRUE(embed_root->TargetVisibility()); | 607 EXPECT_TRUE(embed_root->TargetVisibility()); |
| 597 EXPECT_TRUE(embed_root->IsVisible()); | 608 EXPECT_TRUE(embed_root->IsVisible()); |
| 598 } | 609 } |
| 599 | 610 |
| 600 // TODO(beng): tests for window event dispatcher. | 611 // TODO(beng): tests for window event dispatcher. |
| 601 // - verify that we see events for all windows. | 612 // - verify that we see events for all windows. |
| 602 | 613 |
| 603 TEST_F(WindowServerTest, EmbedFailsWithChildren) { | 614 TEST_F(WindowServerTest, EmbedFailsWithChildren) { |
| 604 aura::Window* window1 = NewVisibleWindow(GetFirstWMRoot(), window_manager()); | 615 aura::Window* window1 = NewVisibleWindow(GetFirstWMRoot(), window_manager(), |
| 616 aura::WindowMusType::EMBED_IN_OWNER); |
| 605 ASSERT_TRUE(NewVisibleWindow(window1, window_manager())); | 617 ASSERT_TRUE(NewVisibleWindow(window1, window_manager())); |
| 606 std::unique_ptr<EmbedResult> embed_result = Embed(window_manager(), window1); | 618 std::unique_ptr<EmbedResult> embed_result = Embed(window_manager(), window1); |
| 607 // Embed() should fail as |window1| has a child. | 619 // Embed() should fail as |window1| has a child. |
| 608 EXPECT_FALSE(embed_result->IsValid()); | 620 EXPECT_FALSE(embed_result->IsValid()); |
| 609 } | 621 } |
| 610 | 622 |
| 611 namespace { | 623 namespace { |
| 612 | 624 |
| 613 class DestroyObserver : public aura::WindowObserver { | 625 class DestroyObserver : public aura::WindowObserver { |
| 614 public: | 626 public: |
| (...skipping 16 matching lines...) Expand all Loading... |
| 631 | 643 |
| 632 DISALLOW_COPY_AND_ASSIGN(DestroyObserver); | 644 DISALLOW_COPY_AND_ASSIGN(DestroyObserver); |
| 633 }; | 645 }; |
| 634 | 646 |
| 635 } // namespace | 647 } // namespace |
| 636 | 648 |
| 637 // Verifies deleting a Window that is the root of another client notifies | 649 // Verifies deleting a Window that is the root of another client notifies |
| 638 // observers in the right order (OnWindowDestroyed() before | 650 // observers in the right order (OnWindowDestroyed() before |
| 639 // OnWindowManagerDestroyed()). | 651 // OnWindowManagerDestroyed()). |
| 640 TEST_F(WindowServerTest, WindowServerDestroyedAfterRootObserver) { | 652 TEST_F(WindowServerTest, WindowServerDestroyedAfterRootObserver) { |
| 641 aura::Window* window = NewVisibleWindow(GetFirstWMRoot(), window_manager()); | 653 aura::Window* window = NewVisibleWindow(GetFirstWMRoot(), window_manager(), |
| 654 aura::WindowMusType::EMBED_IN_OWNER); |
| 642 | 655 |
| 643 std::unique_ptr<EmbedResult> embed_result = Embed(window_manager(), window); | 656 std::unique_ptr<EmbedResult> embed_result = Embed(window_manager(), window); |
| 644 ASSERT_TRUE(embed_result->IsValid()); | 657 ASSERT_TRUE(embed_result->IsValid()); |
| 645 aura::WindowTreeClient* embedded_client = | 658 aura::WindowTreeClient* embedded_client = |
| 646 embed_result->window_tree_client.get(); | 659 embed_result->window_tree_client.get(); |
| 647 | 660 |
| 648 bool got_destroy = false; | 661 bool got_destroy = false; |
| 649 DestroyObserver observer(embedded_client, &got_destroy); | 662 DestroyObserver observer(embedded_client, &got_destroy); |
| 650 // Delete the window |embedded_client| is embedded in. |embedded_client| is | 663 // Delete the window |embedded_client| is embedded in. |embedded_client| is |
| 651 // asynchronously notified and cleans up. | 664 // asynchronously notified and cleans up. |
| 652 delete window; | 665 delete window; |
| 653 EXPECT_TRUE(DoRunLoopWithTimeout()); | 666 EXPECT_TRUE(DoRunLoopWithTimeout()); |
| 654 ASSERT_TRUE(got_destroy); | 667 ASSERT_TRUE(got_destroy); |
| 655 // The WindowTreeHost was destroyed as well (by | 668 // The WindowTreeHost was destroyed as well (by |
| 656 // WindowServerTestBase::OnEmbedRootDestroyed()). | 669 // WindowServerTestBase::OnEmbedRootDestroyed()). |
| 657 embed_result->window_tree_host.release(); | 670 embed_result->window_tree_host.release(); |
| 658 EXPECT_EQ(0u, embed_result->window_tree_client->GetRoots().size()); | 671 EXPECT_EQ(0u, embed_result->window_tree_client->GetRoots().size()); |
| 659 } | 672 } |
| 660 | 673 |
| 661 TEST_F(WindowServerTest, ClientAreaChanged) { | 674 TEST_F(WindowServerTest, ClientAreaChanged) { |
| 662 aura::Window* window = NewVisibleWindow(GetFirstWMRoot(), window_manager()); | 675 aura::Window* window = NewVisibleWindow(GetFirstWMRoot(), window_manager(), |
| 676 aura::WindowMusType::EMBED_IN_OWNER); |
| 663 | 677 |
| 664 std::unique_ptr<EmbedResult> embed_result = Embed(window_manager(), window); | 678 std::unique_ptr<EmbedResult> embed_result = Embed(window_manager(), window); |
| 665 ASSERT_TRUE(embed_result->IsValid()); | 679 ASSERT_TRUE(embed_result->IsValid()); |
| 666 | 680 |
| 667 // Verify change from embedded makes it to parent. | 681 // Verify change from embedded makes it to parent. |
| 668 const gfx::Insets insets(1, 2, 3, 4); | 682 const gfx::Insets insets(1, 2, 3, 4); |
| 669 embed_result->window_tree_host->SetClientArea(insets, | 683 embed_result->window_tree_host->SetClientArea(insets, |
| 670 std::vector<gfx::Rect>()); | 684 std::vector<gfx::Rect>()); |
| 671 std::unique_ptr<ClientAreaChange> client_area_change = | 685 std::unique_ptr<ClientAreaChange> client_area_change = |
| 672 WaitForClientAreaToChange(); | 686 WaitForClientAreaToChange(); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 691 run_loop_.reset(); | 705 run_loop_.reset(); |
| 692 return created_window_ != nullptr; | 706 return created_window_ != nullptr; |
| 693 } | 707 } |
| 694 | 708 |
| 695 aura::Window* created_window() { return created_window_; } | 709 aura::Window* created_window() { return created_window_; } |
| 696 | 710 |
| 697 // WindowManagerDelegate: | 711 // WindowManagerDelegate: |
| 698 aura::Window* OnWmCreateTopLevelWindow( | 712 aura::Window* OnWmCreateTopLevelWindow( |
| 699 ui::mojom::WindowType window_type, | 713 ui::mojom::WindowType window_type, |
| 700 std::map<std::string, std::vector<uint8_t>>* properties) override { | 714 std::map<std::string, std::vector<uint8_t>>* properties) override { |
| 701 created_window_ = NewVisibleWindow((*client_->GetRoots().begin()), client_); | 715 created_window_ = NewVisibleWindow((*client_->GetRoots().begin()), client_, |
| 716 aura::WindowMusType::TOP_LEVEL_IN_WM); |
| 702 if (run_loop_) | 717 if (run_loop_) |
| 703 run_loop_->Quit(); | 718 run_loop_->Quit(); |
| 704 return created_window_; | 719 return created_window_; |
| 705 } | 720 } |
| 706 | 721 |
| 707 private: | 722 private: |
| 708 aura::WindowTreeClient* client_; | 723 aura::WindowTreeClient* client_; |
| 709 std::unique_ptr<base::RunLoop> run_loop_; | 724 std::unique_ptr<base::RunLoop> run_loop_; |
| 710 aura::Window* created_window_; | 725 aura::Window* created_window_; |
| 711 | 726 |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 774 ASSERT_EQ(1u, top_level_in_wm->children().size()); | 789 ASSERT_EQ(1u, top_level_in_wm->children().size()); |
| 775 aura::Window* second_client_child_in_wm = top_level_in_wm->children()[0]; | 790 aura::Window* second_client_child_in_wm = top_level_in_wm->children()[0]; |
| 776 ASSERT_EQ(1u, second_client_child_in_wm->children().size()); | 791 ASSERT_EQ(1u, second_client_child_in_wm->children().size()); |
| 777 aura::Window* transient_in_wm = second_client_child_in_wm->children()[0]; | 792 aura::Window* transient_in_wm = second_client_child_in_wm->children()[0]; |
| 778 ASSERT_EQ(second_client_child_in_wm, | 793 ASSERT_EQ(second_client_child_in_wm, |
| 779 transient_window_client->GetTransientParent(transient_in_wm)); | 794 transient_window_client->GetTransientParent(transient_in_wm)); |
| 780 } | 795 } |
| 781 | 796 |
| 782 } // namespace ws | 797 } // namespace ws |
| 783 } // namespace ui | 798 } // namespace ui |
| OLD | NEW |