Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(52)

Side by Side Diff: components/mus/ws/window_tree_client_unittest.cc

Issue 1771393002: Convert mus apptests to shelltests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « components/mus/ws/window_tree_apptest.cc ('k') | mash/wm/BUILD.gn » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/macros.h" 9 #include "base/macros.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
11 #include "base/run_loop.h" 11 #include "base/run_loop.h"
12 #include "base/strings/stringprintf.h" 12 #include "base/strings/stringprintf.h"
13 #include "components/mus/public/cpp/tests/window_server_shelltest_base.h"
13 #include "components/mus/public/interfaces/window_tree.mojom.h" 14 #include "components/mus/public/interfaces/window_tree.mojom.h"
14 #include "components/mus/public/interfaces/window_tree_host.mojom.h" 15 #include "components/mus/public/interfaces/window_tree_host.mojom.h"
15 #include "components/mus/ws/ids.h" 16 #include "components/mus/ws/ids.h"
16 #include "components/mus/ws/test_change_tracker.h" 17 #include "components/mus/ws/test_change_tracker.h"
17 #include "mojo/converters/geometry/geometry_type_converters.h" 18 #include "mojo/converters/geometry/geometry_type_converters.h"
18 #include "mojo/public/cpp/bindings/associated_binding.h" 19 #include "mojo/public/cpp/bindings/associated_binding.h"
19 #include "mojo/shell/public/cpp/application_test_base.h" 20 #include "mojo/shell/public/cpp/shell_test.h"
20 21
21 using mojo::Array; 22 using mojo::Array;
22 using mojo::Callback; 23 using mojo::Callback;
23 using mojo::Connection; 24 using mojo::Connection;
24 using mojo::InterfaceRequest; 25 using mojo::InterfaceRequest;
25 using mojo::RectPtr; 26 using mojo::RectPtr;
26 using mojo::ShellClient; 27 using mojo::ShellClient;
27 using mojo::String; 28 using mojo::String;
28 using mus::mojom::ErrorCode; 29 using mus::mojom::ErrorCode;
29 using mus::mojom::EventPtr; 30 using mus::mojom::EventPtr;
(...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after
465 } 466 }
466 467
467 scoped_ptr<TestWindowTreeClientImpl> client_impl_; 468 scoped_ptr<TestWindowTreeClientImpl> client_impl_;
468 scoped_ptr<base::RunLoop> run_loop_; 469 scoped_ptr<base::RunLoop> run_loop_;
469 470
470 DISALLOW_COPY_AND_ASSIGN(WindowTreeClientFactory); 471 DISALLOW_COPY_AND_ASSIGN(WindowTreeClientFactory);
471 }; 472 };
472 473
473 } // namespace 474 } // namespace
474 475
475 class WindowTreeAppTest : public mojo::test::ApplicationTestBase, 476 class WindowTreeClientTest : public WindowServerShellTestBase {
476 public mojo::ShellClient {
477 public: 477 public:
478 WindowTreeAppTest() 478 WindowTreeClientTest()
479 : connection_id_1_(0), connection_id_2_(0), root_window_id_(0) {} 479 : connection_id_1_(0), connection_id_2_(0), root_window_id_(0) {}
480 ~WindowTreeAppTest() override {} 480
481 ~WindowTreeClientTest() override {}
481 482
482 protected: 483 protected:
483 // Returns the changes from the various connections. 484 // Returns the changes from the various connections.
484 std::vector<Change>* changes1() { return wt_client1_->tracker()->changes(); } 485 std::vector<Change>* changes1() { return wt_client1_->tracker()->changes(); }
485 std::vector<Change>* changes2() { return wt_client2_->tracker()->changes(); } 486 std::vector<Change>* changes2() { return wt_client2_->tracker()->changes(); }
486 std::vector<Change>* changes3() { return wt_client3_->tracker()->changes(); } 487 std::vector<Change>* changes3() { return wt_client3_->tracker()->changes(); }
487 488
488 // Various connections. |wt1()|, being the first connection, has special 489 // Various connections. |wt1()|, being the first connection, has special
489 // permissions (it's treated as the window manager). 490 // permissions (it's treated as the window manager).
490 WindowTree* wt1() { return wt_client1_->tree(); } 491 WindowTree* wt1() { return wt_client1_->tree(); }
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
560 } 561 }
561 client->WaitForOnEmbed(); 562 client->WaitForOnEmbed();
562 563
563 EXPECT_EQ("OnEmbed", 564 EXPECT_EQ("OnEmbed",
564 SingleChangeToDescription(*client->tracker()->changes())); 565 SingleChangeToDescription(*client->tracker()->changes()));
565 if (connection_id) 566 if (connection_id)
566 *connection_id = (*client->tracker()->changes())[0].connection_id; 567 *connection_id = (*client->tracker()->changes())[0].connection_id;
567 return client; 568 return client;
568 } 569 }
569 570
570 // ApplicationTestBase: 571 // WindowServerShellTestBase:
571 mojo::ShellClient* GetShellClient() override { return this; } 572 bool AcceptConnection(mojo::Connection* connection) override {
573 connection->AddInterface(client_factory_.get());
574 return true;
575 }
576
572 void SetUp() override { 577 void SetUp() override {
573 ApplicationTestBase::SetUp();
574 client_factory_.reset(new WindowTreeClientFactory()); 578 client_factory_.reset(new WindowTreeClientFactory());
575 579
580 WindowServerShellTestBase::SetUp();
581
576 mojom::WindowTreeHostFactoryPtr factory; 582 mojom::WindowTreeHostFactoryPtr factory;
577 connector()->ConnectToInterface("mojo:mus", &factory); 583 connector()->ConnectToInterface("mojo:mus", &factory);
578 584
579 mojom::WindowTreeClientPtr tree_client_ptr; 585 mojom::WindowTreeClientPtr tree_client_ptr;
580 wt_client1_.reset(new TestWindowTreeClientImpl()); 586 wt_client1_.reset(new TestWindowTreeClientImpl());
581 wt_client1_->Bind(GetProxy(&tree_client_ptr)); 587 wt_client1_->Bind(GetProxy(&tree_client_ptr));
582 588
583 factory->CreateWindowTreeHost(GetProxy(&host_), 589 factory->CreateWindowTreeHost(GetProxy(&host_),
584 std::move(tree_client_ptr)); 590 std::move(tree_client_ptr));
585 591
586 // Next we should get an embed call on the "window manager" client. 592 // Next we should get an embed call on the "window manager" client.
587 wt_client1_->WaitForIncomingMethodCall(); 593 wt_client1_->WaitForIncomingMethodCall();
588 594
589 ASSERT_EQ(1u, changes1()->size()); 595 ASSERT_EQ(1u, changes1()->size());
590 EXPECT_EQ(CHANGE_TYPE_EMBED, (*changes1())[0].type); 596 EXPECT_EQ(CHANGE_TYPE_EMBED, (*changes1())[0].type);
591 // All these tests assume 1 for the client id. The only real assertion here 597 // All these tests assume 1 for the client id. The only real assertion here
592 // is the client id is not zero, but adding this as rest of code here 598 // is the client id is not zero, but adding this as rest of code here
593 // assumes 1. 599 // assumes 1.
594 ASSERT_GT((*changes1())[0].connection_id, 0); 600 ASSERT_GT((*changes1())[0].connection_id, 0);
595 connection_id_1_ = (*changes1())[0].connection_id; 601 connection_id_1_ = (*changes1())[0].connection_id;
596 ASSERT_FALSE((*changes1())[0].windows.empty()); 602 ASSERT_FALSE((*changes1())[0].windows.empty());
597 root_window_id_ = (*changes1())[0].windows[0].window_id; 603 root_window_id_ = (*changes1())[0].windows[0].window_id;
598 ASSERT_EQ(root_window_id_, wt_client1_->root_window_id()); 604 ASSERT_EQ(root_window_id_, wt_client1_->root_window_id());
599 changes1()->clear(); 605 changes1()->clear();
600 } 606 }
601 607
602 // mojo::ShellClient implementation.
603 bool AcceptConnection(Connection* connection) override {
604 connection->AddInterface(client_factory_.get());
605 return true;
606 }
607
608 scoped_ptr<TestWindowTreeClientImpl> wt_client1_; 608 scoped_ptr<TestWindowTreeClientImpl> wt_client1_;
609 scoped_ptr<TestWindowTreeClientImpl> wt_client2_; 609 scoped_ptr<TestWindowTreeClientImpl> wt_client2_;
610 scoped_ptr<TestWindowTreeClientImpl> wt_client3_; 610 scoped_ptr<TestWindowTreeClientImpl> wt_client3_;
611 611
612 mojom::WindowTreeHostPtr host_; 612 mojom::WindowTreeHostPtr host_;
613 613
614 private: 614 private:
615 scoped_ptr<WindowTreeClientFactory> client_factory_; 615 scoped_ptr<WindowTreeClientFactory> client_factory_;
616 int connection_id_1_; 616 int connection_id_1_;
617 int connection_id_2_; 617 int connection_id_2_;
618 Id root_window_id_; 618 Id root_window_id_;
619 619
620 DISALLOW_COPY_AND_ASSIGN(WindowTreeAppTest); 620 DISALLOW_COPY_AND_ASSIGN(WindowTreeClientTest);
621 }; 621 };
622 622
623 // Verifies two clients/connections get different ids. 623 // Verifies two clients/connections get different ids.
624 TEST_F(WindowTreeAppTest, TwoClientsGetDifferentConnectionIds) { 624 TEST_F(WindowTreeClientTest, TwoClientsGetDifferentConnectionIds) {
625 ASSERT_NO_FATAL_FAILURE(EstablishSecondConnection(true)); 625 ASSERT_NO_FATAL_FAILURE(EstablishSecondConnection(true));
626 626
627 ASSERT_EQ(1u, changes2()->size()); 627 ASSERT_EQ(1u, changes2()->size());
628 ASSERT_NE(connection_id_1(), connection_id_2()); 628 ASSERT_NE(connection_id_1(), connection_id_2());
629 } 629 }
630 630
631 // Verifies when Embed() is invoked any child windows are removed. 631 // Verifies when Embed() is invoked any child windows are removed.
632 TEST_F(WindowTreeAppTest, WindowsRemovedWhenEmbedding) { 632 TEST_F(WindowTreeClientTest, WindowsRemovedWhenEmbedding) {
633 // Two windows 1 and 2. 2 is parented to 1. 633 // Two windows 1 and 2. 2 is parented to 1.
634 Id window_1_1 = wt_client1()->NewWindow(1); 634 Id window_1_1 = wt_client1()->NewWindow(1);
635 ASSERT_TRUE(window_1_1); 635 ASSERT_TRUE(window_1_1);
636 ASSERT_TRUE(wt_client1()->AddWindow(root_window_id(), window_1_1)); 636 ASSERT_TRUE(wt_client1()->AddWindow(root_window_id(), window_1_1));
637 637
638 Id window_1_2 = wt_client1()->NewWindow(2); 638 Id window_1_2 = wt_client1()->NewWindow(2);
639 ASSERT_TRUE(window_1_2); 639 ASSERT_TRUE(window_1_2);
640 ASSERT_TRUE(wt_client1()->AddWindow(window_1_1, window_1_2)); 640 ASSERT_TRUE(wt_client1()->AddWindow(window_1_1, window_1_2));
641 641
642 ASSERT_NO_FATAL_FAILURE(EstablishSecondConnection(false)); 642 ASSERT_NO_FATAL_FAILURE(EstablishSecondConnection(false));
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
692 // And window 4 should not be visible to connection 3. 692 // And window 4 should not be visible to connection 3.
693 { 693 {
694 std::vector<TestWindow> windows; 694 std::vector<TestWindow> windows;
695 GetWindowTree(wt3(), window_2_3, &windows); 695 GetWindowTree(wt3(), window_2_3, &windows);
696 EXPECT_EQ("no windows", SingleWindowDescription(windows)); 696 EXPECT_EQ("no windows", SingleWindowDescription(windows));
697 } 697 }
698 } 698 }
699 699
700 // Verifies once Embed() has been invoked the parent connection can't see any 700 // Verifies once Embed() has been invoked the parent connection can't see any
701 // children. 701 // children.
702 TEST_F(WindowTreeAppTest, CantAccessChildrenOfEmbeddedWindow) { 702 TEST_F(WindowTreeClientTest, CantAccessChildrenOfEmbeddedWindow) {
703 ASSERT_NO_FATAL_FAILURE(EstablishSecondConnection(true)); 703 ASSERT_NO_FATAL_FAILURE(EstablishSecondConnection(true));
704 704
705 Id window_1_1 = BuildWindowId(connection_id_1(), 1); 705 Id window_1_1 = BuildWindowId(connection_id_1(), 1);
706 Id window_2_2 = wt_client2()->NewWindow(2); 706 Id window_2_2 = wt_client2()->NewWindow(2);
707 ASSERT_TRUE(window_2_2); 707 ASSERT_TRUE(window_2_2);
708 ASSERT_TRUE(wt_client2()->AddWindow(window_1_1, window_2_2)); 708 ASSERT_TRUE(wt_client2()->AddWindow(window_1_1, window_2_2));
709 709
710 ASSERT_NO_FATAL_FAILURE(EstablishThirdConnection(wt2(), window_2_2)); 710 ASSERT_NO_FATAL_FAILURE(EstablishThirdConnection(wt2(), window_2_2));
711 711
712 Id window_3_3 = wt_client3()->NewWindow(3); 712 Id window_3_3 = wt_client3()->NewWindow(3);
(...skipping 28 matching lines...) Expand all
741 // but the ids are in the id space of client2, which is not the same as 741 // but the ids are in the id space of client2, which is not the same as
742 // the id space of wt1(). 742 // the id space of wt1().
743 EXPECT_EQ("window=2,1 parent=1,1", windows[1].ToString()); 743 EXPECT_EQ("window=2,1 parent=1,1", windows[1].ToString());
744 // Same thing here, we really want to test for 744 // Same thing here, we really want to test for
745 // WindowParentToString(window_3_3, window_2_2). 745 // WindowParentToString(window_3_3, window_2_2).
746 EXPECT_EQ("window=3,1 parent=2,1", windows[2].ToString()); 746 EXPECT_EQ("window=3,1 parent=2,1", windows[2].ToString());
747 } 747 }
748 } 748 }
749 749
750 // Verifies once Embed() has been invoked the parent can't mutate the children. 750 // Verifies once Embed() has been invoked the parent can't mutate the children.
751 TEST_F(WindowTreeAppTest, CantModifyChildrenOfEmbeddedWindow) { 751 TEST_F(WindowTreeClientTest, CantModifyChildrenOfEmbeddedWindow) {
752 ASSERT_NO_FATAL_FAILURE(EstablishSecondConnection(true)); 752 ASSERT_NO_FATAL_FAILURE(EstablishSecondConnection(true));
753 753
754 Id window_1_1 = BuildWindowId(connection_id_1(), 1); 754 Id window_1_1 = BuildWindowId(connection_id_1(), 1);
755 Id window_2_1 = wt_client2()->NewWindow(1); 755 Id window_2_1 = wt_client2()->NewWindow(1);
756 ASSERT_TRUE(window_2_1); 756 ASSERT_TRUE(window_2_1);
757 ASSERT_TRUE(wt_client2()->AddWindow(window_1_1, window_2_1)); 757 ASSERT_TRUE(wt_client2()->AddWindow(window_1_1, window_2_1));
758 758
759 ASSERT_NO_FATAL_FAILURE(EstablishThirdConnection(wt2(), window_2_1)); 759 ASSERT_NO_FATAL_FAILURE(EstablishThirdConnection(wt2(), window_2_1));
760 760
761 Id window_2_2 = wt_client2()->NewWindow(2); 761 Id window_2_2 = wt_client2()->NewWindow(2);
762 ASSERT_TRUE(window_2_2); 762 ASSERT_TRUE(window_2_2);
763 // Connection 2 shouldn't be able to add anything to the window anymore. 763 // Connection 2 shouldn't be able to add anything to the window anymore.
764 ASSERT_FALSE(wt_client2()->AddWindow(window_2_1, window_2_2)); 764 ASSERT_FALSE(wt_client2()->AddWindow(window_2_1, window_2_2));
765 765
766 // Create window 3 in connection 3 and add it to window 3. 766 // Create window 3 in connection 3 and add it to window 3.
767 Id window_3_1 = wt_client3()->NewWindow(1); 767 Id window_3_1 = wt_client3()->NewWindow(1);
768 ASSERT_TRUE(window_3_1); 768 ASSERT_TRUE(window_3_1);
769 ASSERT_TRUE(wt_client3()->AddWindow(window_2_1, window_3_1)); 769 ASSERT_TRUE(wt_client3()->AddWindow(window_2_1, window_3_1));
770 770
771 // Connection 2 shouldn't be able to remove window 3. 771 // Connection 2 shouldn't be able to remove window 3.
772 ASSERT_FALSE(wt_client2()->RemoveWindowFromParent(window_3_1)); 772 ASSERT_FALSE(wt_client2()->RemoveWindowFromParent(window_3_1));
773 } 773 }
774 774
775 // Verifies client gets a valid id. 775 // Verifies client gets a valid id.
776 TEST_F(WindowTreeAppTest, NewWindow) { 776 TEST_F(WindowTreeClientTest, NewWindow) {
777 Id window_1_1 = wt_client1()->NewWindow(1); 777 Id window_1_1 = wt_client1()->NewWindow(1);
778 ASSERT_TRUE(window_1_1); 778 ASSERT_TRUE(window_1_1);
779 EXPECT_TRUE(changes1()->empty()); 779 EXPECT_TRUE(changes1()->empty());
780 780
781 // Can't create a window with the same id. 781 // Can't create a window with the same id.
782 ASSERT_EQ(0u, wt_client1()->NewWindowWithCompleteId(window_1_1)); 782 ASSERT_EQ(0u, wt_client1()->NewWindowWithCompleteId(window_1_1));
783 EXPECT_TRUE(changes1()->empty()); 783 EXPECT_TRUE(changes1()->empty());
784 784
785 // Can't create a window with a bogus connection id. 785 // Can't create a window with a bogus connection id.
786 ASSERT_EQ(0u, wt_client1()->NewWindowWithCompleteId( 786 ASSERT_EQ(0u, wt_client1()->NewWindowWithCompleteId(
787 BuildWindowId(connection_id_1() + 1, 1))); 787 BuildWindowId(connection_id_1() + 1, 1)));
788 EXPECT_TRUE(changes1()->empty()); 788 EXPECT_TRUE(changes1()->empty());
789 } 789 }
790 790
791 // Verifies AddWindow fails when window is already in position. 791 // Verifies AddWindow fails when window is already in position.
792 TEST_F(WindowTreeAppTest, AddWindowWithNoChange) { 792 TEST_F(WindowTreeClientTest, AddWindowWithNoChange) {
793 // Create the embed point now so that the ids line up. 793 // Create the embed point now so that the ids line up.
794 ASSERT_TRUE(wt_client1()->NewWindow(1)); 794 ASSERT_TRUE(wt_client1()->NewWindow(1));
795 Id window_1_2 = wt_client1()->NewWindow(2); 795 Id window_1_2 = wt_client1()->NewWindow(2);
796 Id window_1_3 = wt_client1()->NewWindow(3); 796 Id window_1_3 = wt_client1()->NewWindow(3);
797 ASSERT_TRUE(window_1_2); 797 ASSERT_TRUE(window_1_2);
798 ASSERT_TRUE(window_1_3); 798 ASSERT_TRUE(window_1_3);
799 799
800 ASSERT_NO_FATAL_FAILURE(EstablishSecondConnection(false)); 800 ASSERT_NO_FATAL_FAILURE(EstablishSecondConnection(false));
801 801
802 // Make 3 a child of 2. 802 // Make 3 a child of 2.
803 ASSERT_TRUE(wt_client1()->AddWindow(window_1_2, window_1_3)); 803 ASSERT_TRUE(wt_client1()->AddWindow(window_1_2, window_1_3));
804 804
805 // Try again, this should fail. 805 // Try again, this should fail.
806 EXPECT_FALSE(wt_client1()->AddWindow(window_1_2, window_1_3)); 806 EXPECT_FALSE(wt_client1()->AddWindow(window_1_2, window_1_3));
807 } 807 }
808 808
809 // Verifies AddWindow fails when window is already in position. 809 // Verifies AddWindow fails when window is already in position.
810 TEST_F(WindowTreeAppTest, AddAncestorFails) { 810 TEST_F(WindowTreeClientTest, AddAncestorFails) {
811 // Create the embed point now so that the ids line up. 811 // Create the embed point now so that the ids line up.
812 ASSERT_TRUE(wt_client1()->NewWindow(1)); 812 ASSERT_TRUE(wt_client1()->NewWindow(1));
813 Id window_1_2 = wt_client1()->NewWindow(2); 813 Id window_1_2 = wt_client1()->NewWindow(2);
814 Id window_1_3 = wt_client1()->NewWindow(3); 814 Id window_1_3 = wt_client1()->NewWindow(3);
815 ASSERT_TRUE(window_1_2); 815 ASSERT_TRUE(window_1_2);
816 ASSERT_TRUE(window_1_3); 816 ASSERT_TRUE(window_1_3);
817 817
818 ASSERT_NO_FATAL_FAILURE(EstablishSecondConnection(false)); 818 ASSERT_NO_FATAL_FAILURE(EstablishSecondConnection(false));
819 819
820 // Make 3 a child of 2. 820 // Make 3 a child of 2.
821 ASSERT_TRUE(wt_client1()->AddWindow(window_1_2, window_1_3)); 821 ASSERT_TRUE(wt_client1()->AddWindow(window_1_2, window_1_3));
822 822
823 // Try to make 2 a child of 3, this should fail since 2 is an ancestor of 3. 823 // Try to make 2 a child of 3, this should fail since 2 is an ancestor of 3.
824 EXPECT_FALSE(wt_client1()->AddWindow(window_1_3, window_1_2)); 824 EXPECT_FALSE(wt_client1()->AddWindow(window_1_3, window_1_2));
825 } 825 }
826 826
827 // Verifies adding to root sends right notifications. 827 // Verifies adding to root sends right notifications.
828 TEST_F(WindowTreeAppTest, AddToRoot) { 828 TEST_F(WindowTreeClientTest, AddToRoot) {
829 // Create the embed point now so that the ids line up. 829 // Create the embed point now so that the ids line up.
830 Id window_1_1 = wt_client1()->NewWindow(1); 830 Id window_1_1 = wt_client1()->NewWindow(1);
831 ASSERT_TRUE(window_1_1); 831 ASSERT_TRUE(window_1_1);
832 Id window_1_21 = wt_client1()->NewWindow(21); 832 Id window_1_21 = wt_client1()->NewWindow(21);
833 Id window_1_3 = wt_client1()->NewWindow(3); 833 Id window_1_3 = wt_client1()->NewWindow(3);
834 ASSERT_TRUE(window_1_21); 834 ASSERT_TRUE(window_1_21);
835 ASSERT_TRUE(window_1_3); 835 ASSERT_TRUE(window_1_3);
836 836
837 ASSERT_NO_FATAL_FAILURE(EstablishSecondConnection(false)); 837 ASSERT_NO_FATAL_FAILURE(EstablishSecondConnection(false));
838 changes2()->clear(); 838 changes2()->clear();
839 839
840 // Make 3 a child of 21. 840 // Make 3 a child of 21.
841 ASSERT_TRUE(wt_client1()->AddWindow(window_1_21, window_1_3)); 841 ASSERT_TRUE(wt_client1()->AddWindow(window_1_21, window_1_3));
842 842
843 // Make 21 a child of 1. 843 // Make 21 a child of 1.
844 ASSERT_TRUE(wt_client1()->AddWindow(window_1_1, window_1_21)); 844 ASSERT_TRUE(wt_client1()->AddWindow(window_1_1, window_1_21));
845 845
846 // Connection 2 should not be told anything (because the window is from a 846 // Connection 2 should not be told anything (because the window is from a
847 // different connection). Create a window to ensure we got a response from 847 // different connection). Create a window to ensure we got a response from
848 // the server. 848 // the server.
849 ASSERT_TRUE(wt_client2()->NewWindow(100)); 849 ASSERT_TRUE(wt_client2()->NewWindow(100));
850 EXPECT_TRUE(changes2()->empty()); 850 EXPECT_TRUE(changes2()->empty());
851 } 851 }
852 852
853 // Verifies HierarchyChanged is correctly sent for various adds/removes. 853 // Verifies HierarchyChanged is correctly sent for various adds/removes.
854 TEST_F(WindowTreeAppTest, WindowHierarchyChangedWindows) { 854 TEST_F(WindowTreeClientTest, WindowHierarchyChangedWindows) {
855 // Create the embed point now so that the ids line up. 855 // Create the embed point now so that the ids line up.
856 Id window_1_1 = wt_client1()->NewWindow(1); 856 Id window_1_1 = wt_client1()->NewWindow(1);
857 // 1,2->1,11. 857 // 1,2->1,11.
858 Id window_1_2 = wt_client1()->NewWindow(2); 858 Id window_1_2 = wt_client1()->NewWindow(2);
859 ASSERT_TRUE(window_1_2); 859 ASSERT_TRUE(window_1_2);
860 ASSERT_TRUE(wt_client1()->SetWindowVisibility(window_1_2, true)); 860 ASSERT_TRUE(wt_client1()->SetWindowVisibility(window_1_2, true));
861 Id window_1_11 = wt_client1()->NewWindow(11); 861 Id window_1_11 = wt_client1()->NewWindow(11);
862 ASSERT_TRUE(window_1_11); 862 ASSERT_TRUE(window_1_11);
863 ASSERT_TRUE(wt_client1()->SetWindowVisibility(window_1_11, true)); 863 ASSERT_TRUE(wt_client1()->SetWindowVisibility(window_1_11, true));
864 ASSERT_TRUE(wt_client1()->AddWindow(window_1_2, window_1_11)); 864 ASSERT_TRUE(wt_client1()->AddWindow(window_1_2, window_1_11));
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
915 { 915 {
916 changes2()->clear(); 916 changes2()->clear();
917 ASSERT_TRUE(wt_client1()->AddWindow(root_window_id(), window_1_1)); 917 ASSERT_TRUE(wt_client1()->AddWindow(root_window_id(), window_1_1));
918 wt_client2_->WaitForChangeCount(1); 918 wt_client2_->WaitForChangeCount(1);
919 EXPECT_EQ( 919 EXPECT_EQ(
920 "DrawnStateChanged window=" + IdToString(window_1_1) + " drawn=true", 920 "DrawnStateChanged window=" + IdToString(window_1_1) + " drawn=true",
921 SingleChangeToDescription(*changes2())); 921 SingleChangeToDescription(*changes2()));
922 } 922 }
923 } 923 }
924 924
925 TEST_F(WindowTreeAppTest, WindowHierarchyChangedAddingKnownToUnknown) { 925 TEST_F(WindowTreeClientTest, WindowHierarchyChangedAddingKnownToUnknown) {
926 // Create the following structure: root -> 1 -> 11 and 2->21 (2 has no 926 // Create the following structure: root -> 1 -> 11 and 2->21 (2 has no
927 // parent). 927 // parent).
928 ASSERT_NO_FATAL_FAILURE(EstablishSecondConnection(true)); 928 ASSERT_NO_FATAL_FAILURE(EstablishSecondConnection(true));
929 Id window_1_1 = BuildWindowId(connection_id_1(), 1); 929 Id window_1_1 = BuildWindowId(connection_id_1(), 1);
930 930
931 Id window_2_11 = wt_client2()->NewWindow(11); 931 Id window_2_11 = wt_client2()->NewWindow(11);
932 Id window_2_2 = wt_client2()->NewWindow(2); 932 Id window_2_2 = wt_client2()->NewWindow(2);
933 Id window_2_21 = wt_client2()->NewWindow(21); 933 Id window_2_21 = wt_client2()->NewWindow(21);
934 ASSERT_TRUE(window_2_11); 934 ASSERT_TRUE(window_2_11);
935 ASSERT_TRUE(window_2_2); 935 ASSERT_TRUE(window_2_2);
(...skipping 27 matching lines...) Expand all
963 SingleChangeToDescription(*changes1())); 963 SingleChangeToDescription(*changes1()));
964 // "window=2,3 parent=2,2]" should be, 964 // "window=2,3 parent=2,2]" should be,
965 // WindowParentToString(window_2_21, window_2_2), but isn't because of 965 // WindowParentToString(window_2_21, window_2_2), but isn't because of
966 // differing id spaces. 966 // differing id spaces.
967 EXPECT_EQ("[" + WindowParentToString(window_2_2, window_1_1) + 967 EXPECT_EQ("[" + WindowParentToString(window_2_2, window_1_1) +
968 "],[window=2,3 parent=2,2]", 968 "],[window=2,3 parent=2,2]",
969 ChangeWindowDescription(*changes1())); 969 ChangeWindowDescription(*changes1()));
970 } 970 }
971 } 971 }
972 972
973 TEST_F(WindowTreeAppTest, ReorderWindow) { 973 TEST_F(WindowTreeClientTest, ReorderWindow) {
974 ASSERT_NO_FATAL_FAILURE(EstablishSecondConnection(true)); 974 ASSERT_NO_FATAL_FAILURE(EstablishSecondConnection(true));
975 975
976 Id window_2_1 = wt_client2()->NewWindow(1); 976 Id window_2_1 = wt_client2()->NewWindow(1);
977 Id window_2_2 = wt_client2()->NewWindow(2); 977 Id window_2_2 = wt_client2()->NewWindow(2);
978 Id window_2_3 = wt_client2()->NewWindow(3); 978 Id window_2_3 = wt_client2()->NewWindow(3);
979 Id window_1_4 = wt_client1()->NewWindow(4); // Peer to 1,1 979 Id window_1_4 = wt_client1()->NewWindow(4); // Peer to 1,1
980 Id window_1_5 = wt_client1()->NewWindow(5); // Peer to 1,1 980 Id window_1_5 = wt_client1()->NewWindow(5); // Peer to 1,1
981 Id window_2_6 = wt_client2()->NewWindow(6); // Child of 1,2. 981 Id window_2_6 = wt_client2()->NewWindow(6); // Child of 1,2.
982 Id window_2_7 = wt_client2()->NewWindow(7); // Unparented. 982 Id window_2_7 = wt_client2()->NewWindow(7); // Unparented.
983 Id window_2_8 = wt_client2()->NewWindow(8); // Unparented. 983 Id window_2_8 = wt_client2()->NewWindow(8); // Unparented.
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
1036 EXPECT_FALSE(wt_client1()->ReorderWindow(BuildWindowId(connection_id_1(), 27), 1036 EXPECT_FALSE(wt_client1()->ReorderWindow(BuildWindowId(connection_id_1(), 27),
1037 BuildWindowId(connection_id_1(), 28), 1037 BuildWindowId(connection_id_1(), 28),
1038 mojom::OrderDirection::ABOVE)); 1038 mojom::OrderDirection::ABOVE));
1039 1039
1040 // view7 & view8 are un-parented. 1040 // view7 & view8 are un-parented.
1041 EXPECT_FALSE(wt_client1()->ReorderWindow(window_2_7, window_2_8, 1041 EXPECT_FALSE(wt_client1()->ReorderWindow(window_2_7, window_2_8,
1042 mojom::OrderDirection::ABOVE)); 1042 mojom::OrderDirection::ABOVE));
1043 } 1043 }
1044 1044
1045 // Verifies DeleteWindow works. 1045 // Verifies DeleteWindow works.
1046 TEST_F(WindowTreeAppTest, DeleteWindow) { 1046 TEST_F(WindowTreeClientTest, DeleteWindow) {
1047 ASSERT_NO_FATAL_FAILURE(EstablishSecondConnection(true)); 1047 ASSERT_NO_FATAL_FAILURE(EstablishSecondConnection(true));
1048 Id window_1_1 = BuildWindowId(connection_id_1(), 1); 1048 Id window_1_1 = BuildWindowId(connection_id_1(), 1);
1049 Id window_2_1 = wt_client2()->NewWindow(1); 1049 Id window_2_1 = wt_client2()->NewWindow(1);
1050 ASSERT_TRUE(window_2_1); 1050 ASSERT_TRUE(window_2_1);
1051 1051
1052 // Make 2 a child of 1. 1052 // Make 2 a child of 1.
1053 { 1053 {
1054 changes1()->clear(); 1054 changes1()->clear();
1055 ASSERT_TRUE(wt_client2()->AddWindow(window_1_1, window_2_1)); 1055 ASSERT_TRUE(wt_client2()->AddWindow(window_1_1, window_2_1));
1056 wt_client1_->WaitForChangeCount(1); 1056 wt_client1_->WaitForChangeCount(1);
1057 EXPECT_EQ("HierarchyChanged window=" + IdToString(window_2_1) + 1057 EXPECT_EQ("HierarchyChanged window=" + IdToString(window_2_1) +
1058 " new_parent=" + IdToString(window_1_1) + " old_parent=null", 1058 " new_parent=" + IdToString(window_1_1) + " old_parent=null",
1059 SingleChangeToDescription(*changes1())); 1059 SingleChangeToDescription(*changes1()));
1060 } 1060 }
1061 1061
1062 // Delete 2. 1062 // Delete 2.
1063 { 1063 {
1064 changes1()->clear(); 1064 changes1()->clear();
1065 changes2()->clear(); 1065 changes2()->clear();
1066 ASSERT_TRUE(wt_client2()->DeleteWindow(window_2_1)); 1066 ASSERT_TRUE(wt_client2()->DeleteWindow(window_2_1));
1067 EXPECT_TRUE(changes2()->empty()); 1067 EXPECT_TRUE(changes2()->empty());
1068 1068
1069 wt_client1_->WaitForChangeCount(1); 1069 wt_client1_->WaitForChangeCount(1);
1070 EXPECT_EQ("WindowDeleted window=" + IdToString(window_2_1), 1070 EXPECT_EQ("WindowDeleted window=" + IdToString(window_2_1),
1071 SingleChangeToDescription(*changes1())); 1071 SingleChangeToDescription(*changes1()));
1072 } 1072 }
1073 } 1073 }
1074 1074
1075 // Verifies DeleteWindow isn't allowed from a separate connection. 1075 // Verifies DeleteWindow isn't allowed from a separate connection.
1076 TEST_F(WindowTreeAppTest, DeleteWindowFromAnotherConnectionDisallowed) { 1076 TEST_F(WindowTreeClientTest, DeleteWindowFromAnotherConnectionDisallowed) {
1077 ASSERT_NO_FATAL_FAILURE(EstablishSecondConnection(true)); 1077 ASSERT_NO_FATAL_FAILURE(EstablishSecondConnection(true));
1078 EXPECT_FALSE(wt_client2()->DeleteWindow(BuildWindowId(connection_id_1(), 1))); 1078 EXPECT_FALSE(wt_client2()->DeleteWindow(BuildWindowId(connection_id_1(), 1)));
1079 } 1079 }
1080 1080
1081 // Verifies if a window was deleted and then reused that other clients are 1081 // Verifies if a window was deleted and then reused that other clients are
1082 // properly notified. 1082 // properly notified.
1083 TEST_F(WindowTreeAppTest, ReuseDeletedWindowId) { 1083 TEST_F(WindowTreeClientTest, ReuseDeletedWindowId) {
1084 ASSERT_NO_FATAL_FAILURE(EstablishSecondConnection(true)); 1084 ASSERT_NO_FATAL_FAILURE(EstablishSecondConnection(true));
1085 Id window_1_1 = BuildWindowId(connection_id_1(), 1); 1085 Id window_1_1 = BuildWindowId(connection_id_1(), 1);
1086 Id window_2_1 = wt_client2()->NewWindow(1); 1086 Id window_2_1 = wt_client2()->NewWindow(1);
1087 ASSERT_TRUE(window_2_1); 1087 ASSERT_TRUE(window_2_1);
1088 1088
1089 // Add 2 to 1. 1089 // Add 2 to 1.
1090 { 1090 {
1091 changes1()->clear(); 1091 changes1()->clear();
1092 ASSERT_TRUE(wt_client2()->AddWindow(window_1_1, window_2_1)); 1092 ASSERT_TRUE(wt_client2()->AddWindow(window_1_1, window_2_1));
1093 wt_client1_->WaitForChangeCount(1); 1093 wt_client1_->WaitForChangeCount(1);
(...skipping 24 matching lines...) Expand all
1118 wt_client1_->WaitForChangeCount(1); 1118 wt_client1_->WaitForChangeCount(1);
1119 EXPECT_EQ("HierarchyChanged window=" + IdToString(window_2_1) + 1119 EXPECT_EQ("HierarchyChanged window=" + IdToString(window_2_1) +
1120 " new_parent=" + IdToString(window_1_1) + " old_parent=null", 1120 " new_parent=" + IdToString(window_1_1) + " old_parent=null",
1121 SingleChangeToDescription(*changes1())); 1121 SingleChangeToDescription(*changes1()));
1122 EXPECT_EQ("[" + WindowParentToString(window_2_1, window_1_1) + "]", 1122 EXPECT_EQ("[" + WindowParentToString(window_2_1, window_1_1) + "]",
1123 ChangeWindowDescription(*changes1())); 1123 ChangeWindowDescription(*changes1()));
1124 } 1124 }
1125 } 1125 }
1126 1126
1127 // Assertions for GetWindowTree. 1127 // Assertions for GetWindowTree.
1128 TEST_F(WindowTreeAppTest, GetWindowTree) { 1128 TEST_F(WindowTreeClientTest, GetWindowTree) {
1129 ASSERT_NO_FATAL_FAILURE(EstablishSecondConnection(true)); 1129 ASSERT_NO_FATAL_FAILURE(EstablishSecondConnection(true));
1130 Id window_1_1 = BuildWindowId(connection_id_1(), 1); 1130 Id window_1_1 = BuildWindowId(connection_id_1(), 1);
1131 1131
1132 // Create 11 in first connection and make it a child of 1. 1132 // Create 11 in first connection and make it a child of 1.
1133 Id window_1_11 = wt_client1()->NewWindow(11); 1133 Id window_1_11 = wt_client1()->NewWindow(11);
1134 ASSERT_TRUE(window_1_11); 1134 ASSERT_TRUE(window_1_11);
1135 ASSERT_TRUE(wt_client1()->AddWindow(root_window_id(), window_1_1)); 1135 ASSERT_TRUE(wt_client1()->AddWindow(root_window_id(), window_1_1));
1136 ASSERT_TRUE(wt_client1()->AddWindow(window_1_1, window_1_11)); 1136 ASSERT_TRUE(wt_client1()->AddWindow(window_1_1, window_1_11));
1137 1137
1138 // Create two windows in second connection, 2 and 3, both children of 1. 1138 // Create two windows in second connection, 2 and 3, both children of 1.
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
1176 } 1176 }
1177 1177
1178 // Connection 2 shouldn't be able to get the root tree. 1178 // Connection 2 shouldn't be able to get the root tree.
1179 { 1179 {
1180 std::vector<TestWindow> windows; 1180 std::vector<TestWindow> windows;
1181 GetWindowTree(wt2(), root_window_id(), &windows); 1181 GetWindowTree(wt2(), root_window_id(), &windows);
1182 ASSERT_EQ(0u, windows.size()); 1182 ASSERT_EQ(0u, windows.size());
1183 } 1183 }
1184 } 1184 }
1185 1185
1186 TEST_F(WindowTreeAppTest, SetWindowBounds) { 1186 TEST_F(WindowTreeClientTest, SetWindowBounds) {
1187 Id window_1_1 = wt_client1()->NewWindow(1); 1187 Id window_1_1 = wt_client1()->NewWindow(1);
1188 ASSERT_TRUE(window_1_1); 1188 ASSERT_TRUE(window_1_1);
1189 ASSERT_TRUE(wt_client1()->AddWindow(root_window_id(), window_1_1)); 1189 ASSERT_TRUE(wt_client1()->AddWindow(root_window_id(), window_1_1));
1190 1190
1191 ASSERT_NO_FATAL_FAILURE(EstablishSecondConnection(false)); 1191 ASSERT_NO_FATAL_FAILURE(EstablishSecondConnection(false));
1192 1192
1193 changes2()->clear(); 1193 changes2()->clear();
1194 1194
1195 wt_client2_->set_track_root_bounds_changes(true); 1195 wt_client2_->set_track_root_bounds_changes(true);
1196 1196
1197 wt1()->SetWindowBounds(10, window_1_1, 1197 wt1()->SetWindowBounds(10, window_1_1,
1198 mojo::Rect::From(gfx::Rect(0, 0, 100, 100))); 1198 mojo::Rect::From(gfx::Rect(0, 0, 100, 100)));
1199 ASSERT_TRUE(wt_client1()->WaitForChangeCompleted(10)); 1199 ASSERT_TRUE(wt_client1()->WaitForChangeCompleted(10));
1200 1200
1201 wt_client2_->WaitForChangeCount(1); 1201 wt_client2_->WaitForChangeCount(1);
1202 EXPECT_EQ("BoundsChanged window=" + IdToString(window_1_1) + 1202 EXPECT_EQ("BoundsChanged window=" + IdToString(window_1_1) +
1203 " old_bounds=0,0 0x0 new_bounds=0,0 100x100", 1203 " old_bounds=0,0 0x0 new_bounds=0,0 100x100",
1204 SingleChangeToDescription(*changes2())); 1204 SingleChangeToDescription(*changes2()));
1205 1205
1206 // Should not be possible to change the bounds of a window created by another 1206 // Should not be possible to change the bounds of a window created by another
1207 // connection. 1207 // connection.
1208 wt2()->SetWindowBounds(11, window_1_1, 1208 wt2()->SetWindowBounds(11, window_1_1,
1209 mojo::Rect::From(gfx::Rect(0, 0, 0, 0))); 1209 mojo::Rect::From(gfx::Rect(0, 0, 0, 0)));
1210 ASSERT_FALSE(wt_client2()->WaitForChangeCompleted(11)); 1210 ASSERT_FALSE(wt_client2()->WaitForChangeCompleted(11));
1211 } 1211 }
1212 1212
1213 // Verify AddWindow fails when trying to manipulate windows in other roots. 1213 // Verify AddWindow fails when trying to manipulate windows in other roots.
1214 TEST_F(WindowTreeAppTest, CantMoveWindowsFromOtherRoot) { 1214 TEST_F(WindowTreeClientTest, CantMoveWindowsFromOtherRoot) {
1215 // Create 1 and 2 in the first connection. 1215 // Create 1 and 2 in the first connection.
1216 Id window_1_1 = wt_client1()->NewWindow(1); 1216 Id window_1_1 = wt_client1()->NewWindow(1);
1217 Id window_1_2 = wt_client1()->NewWindow(2); 1217 Id window_1_2 = wt_client1()->NewWindow(2);
1218 ASSERT_TRUE(window_1_1); 1218 ASSERT_TRUE(window_1_1);
1219 ASSERT_TRUE(window_1_2); 1219 ASSERT_TRUE(window_1_2);
1220 1220
1221 ASSERT_NO_FATAL_FAILURE(EstablishSecondConnection(false)); 1221 ASSERT_NO_FATAL_FAILURE(EstablishSecondConnection(false));
1222 1222
1223 // Try to move 2 to be a child of 1 from connection 2. This should fail as 2 1223 // Try to move 2 to be a child of 1 from connection 2. This should fail as 2
1224 // should not be able to access 1. 1224 // should not be able to access 1.
1225 ASSERT_FALSE(wt_client2()->AddWindow(window_1_1, window_1_2)); 1225 ASSERT_FALSE(wt_client2()->AddWindow(window_1_1, window_1_2));
1226 1226
1227 // Try to reparent 1 to the root. A connection is not allowed to reparent its 1227 // Try to reparent 1 to the root. A connection is not allowed to reparent its
1228 // roots. 1228 // roots.
1229 ASSERT_FALSE(wt_client2()->AddWindow(root_window_id(), window_1_1)); 1229 ASSERT_FALSE(wt_client2()->AddWindow(root_window_id(), window_1_1));
1230 } 1230 }
1231 1231
1232 // Verify RemoveWindowFromParent fails for windows that are descendants of the 1232 // Verify RemoveWindowFromParent fails for windows that are descendants of the
1233 // roots. 1233 // roots.
1234 TEST_F(WindowTreeAppTest, CantRemoveWindowsInOtherRoots) { 1234 TEST_F(WindowTreeClientTest, CantRemoveWindowsInOtherRoots) {
1235 // Create 1 and 2 in the first connection and parent both to the root. 1235 // Create 1 and 2 in the first connection and parent both to the root.
1236 Id window_1_1 = wt_client1()->NewWindow(1); 1236 Id window_1_1 = wt_client1()->NewWindow(1);
1237 Id window_1_2 = wt_client1()->NewWindow(2); 1237 Id window_1_2 = wt_client1()->NewWindow(2);
1238 ASSERT_TRUE(window_1_1); 1238 ASSERT_TRUE(window_1_1);
1239 ASSERT_TRUE(window_1_2); 1239 ASSERT_TRUE(window_1_2);
1240 1240
1241 ASSERT_TRUE(wt_client1()->AddWindow(root_window_id(), window_1_1)); 1241 ASSERT_TRUE(wt_client1()->AddWindow(root_window_id(), window_1_1));
1242 ASSERT_TRUE(wt_client1()->AddWindow(root_window_id(), window_1_2)); 1242 ASSERT_TRUE(wt_client1()->AddWindow(root_window_id(), window_1_2));
1243 1243
1244 // Establish the second connection and give it the root 1. 1244 // Establish the second connection and give it the root 1.
(...skipping 22 matching lines...) Expand all
1267 EXPECT_EQ(WindowParentToString(root_window_id(), kNullParentId), 1267 EXPECT_EQ(WindowParentToString(root_window_id(), kNullParentId),
1268 windows[0].ToString()); 1268 windows[0].ToString());
1269 EXPECT_EQ(WindowParentToString(window_1_1, root_window_id()), 1269 EXPECT_EQ(WindowParentToString(window_1_1, root_window_id()),
1270 windows[1].ToString()); 1270 windows[1].ToString());
1271 EXPECT_EQ(WindowParentToString(window_1_2, root_window_id()), 1271 EXPECT_EQ(WindowParentToString(window_1_2, root_window_id()),
1272 windows[2].ToString()); 1272 windows[2].ToString());
1273 } 1273 }
1274 } 1274 }
1275 1275
1276 // Verify GetWindowTree fails for windows that are not descendants of the roots. 1276 // Verify GetWindowTree fails for windows that are not descendants of the roots.
1277 TEST_F(WindowTreeAppTest, CantGetWindowTreeOfOtherRoots) { 1277 TEST_F(WindowTreeClientTest, CantGetWindowTreeOfOtherRoots) {
1278 // Create 1 and 2 in the first connection and parent both to the root. 1278 // Create 1 and 2 in the first connection and parent both to the root.
1279 Id window_1_1 = wt_client1()->NewWindow(1); 1279 Id window_1_1 = wt_client1()->NewWindow(1);
1280 Id window_1_2 = wt_client1()->NewWindow(2); 1280 Id window_1_2 = wt_client1()->NewWindow(2);
1281 ASSERT_TRUE(window_1_1); 1281 ASSERT_TRUE(window_1_1);
1282 ASSERT_TRUE(window_1_2); 1282 ASSERT_TRUE(window_1_2);
1283 1283
1284 ASSERT_TRUE(wt_client1()->AddWindow(root_window_id(), window_1_1)); 1284 ASSERT_TRUE(wt_client1()->AddWindow(root_window_id(), window_1_1));
1285 ASSERT_TRUE(wt_client1()->AddWindow(root_window_id(), window_1_2)); 1285 ASSERT_TRUE(wt_client1()->AddWindow(root_window_id(), window_1_2));
1286 1286
1287 ASSERT_NO_FATAL_FAILURE(EstablishSecondConnection(false)); 1287 ASSERT_NO_FATAL_FAILURE(EstablishSecondConnection(false));
1288 1288
1289 std::vector<TestWindow> windows; 1289 std::vector<TestWindow> windows;
1290 1290
1291 // Should get nothing for the root. 1291 // Should get nothing for the root.
1292 GetWindowTree(wt2(), root_window_id(), &windows); 1292 GetWindowTree(wt2(), root_window_id(), &windows);
1293 ASSERT_TRUE(windows.empty()); 1293 ASSERT_TRUE(windows.empty());
1294 1294
1295 // Should get nothing for window 2. 1295 // Should get nothing for window 2.
1296 GetWindowTree(wt2(), window_1_2, &windows); 1296 GetWindowTree(wt2(), window_1_2, &windows);
1297 ASSERT_TRUE(windows.empty()); 1297 ASSERT_TRUE(windows.empty());
1298 1298
1299 // Should get window 1 if asked for. 1299 // Should get window 1 if asked for.
1300 GetWindowTree(wt2(), window_1_1, &windows); 1300 GetWindowTree(wt2(), window_1_1, &windows);
1301 ASSERT_EQ(1u, windows.size()); 1301 ASSERT_EQ(1u, windows.size());
1302 EXPECT_EQ(WindowParentToString(window_1_1, kNullParentId), 1302 EXPECT_EQ(WindowParentToString(window_1_1, kNullParentId),
1303 windows[0].ToString()); 1303 windows[0].ToString());
1304 } 1304 }
1305 1305
1306 TEST_F(WindowTreeAppTest, EmbedWithSameWindowId) { 1306 TEST_F(WindowTreeClientTest, EmbedWithSameWindowId) {
1307 ASSERT_NO_FATAL_FAILURE(EstablishSecondConnection(true)); 1307 ASSERT_NO_FATAL_FAILURE(EstablishSecondConnection(true));
1308 changes2()->clear(); 1308 changes2()->clear();
1309 1309
1310 Id window_1_1 = BuildWindowId(connection_id_1(), 1); 1310 Id window_1_1 = BuildWindowId(connection_id_1(), 1);
1311 ASSERT_NO_FATAL_FAILURE(EstablishThirdConnection(wt1(), window_1_1)); 1311 ASSERT_NO_FATAL_FAILURE(EstablishThirdConnection(wt1(), window_1_1));
1312 1312
1313 // Connection2 should have been told of the unembed and delete. 1313 // Connection2 should have been told of the unembed and delete.
1314 { 1314 {
1315 wt_client2_->WaitForChangeCount(2); 1315 wt_client2_->WaitForChangeCount(2);
1316 EXPECT_EQ("OnUnembed window=" + IdToString(window_1_1), 1316 EXPECT_EQ("OnUnembed window=" + IdToString(window_1_1),
1317 ChangesToDescription1(*changes2())[0]); 1317 ChangesToDescription1(*changes2())[0]);
1318 EXPECT_EQ("WindowDeleted window=" + IdToString(window_1_1), 1318 EXPECT_EQ("WindowDeleted window=" + IdToString(window_1_1),
1319 ChangesToDescription1(*changes2())[1]); 1319 ChangesToDescription1(*changes2())[1]);
1320 } 1320 }
1321 1321
1322 // Connection2 has no root. Verify it can't see window 1,1 anymore. 1322 // Connection2 has no root. Verify it can't see window 1,1 anymore.
1323 { 1323 {
1324 std::vector<TestWindow> windows; 1324 std::vector<TestWindow> windows;
1325 GetWindowTree(wt2(), window_1_1, &windows); 1325 GetWindowTree(wt2(), window_1_1, &windows);
1326 EXPECT_TRUE(windows.empty()); 1326 EXPECT_TRUE(windows.empty());
1327 } 1327 }
1328 } 1328 }
1329 1329
1330 TEST_F(WindowTreeAppTest, EmbedWithSameWindowId2) { 1330 TEST_F(WindowTreeClientTest, EmbedWithSameWindowId2) {
1331 ASSERT_NO_FATAL_FAILURE(EstablishSecondConnection(true)); 1331 ASSERT_NO_FATAL_FAILURE(EstablishSecondConnection(true));
1332 Id window_1_1 = BuildWindowId(connection_id_1(), 1); 1332 Id window_1_1 = BuildWindowId(connection_id_1(), 1);
1333 changes2()->clear(); 1333 changes2()->clear();
1334 1334
1335 ASSERT_NO_FATAL_FAILURE(EstablishThirdConnection(wt1(), window_1_1)); 1335 ASSERT_NO_FATAL_FAILURE(EstablishThirdConnection(wt1(), window_1_1));
1336 1336
1337 // Connection2 should have been told about the unembed and delete. 1337 // Connection2 should have been told about the unembed and delete.
1338 wt_client2_->WaitForChangeCount(2); 1338 wt_client2_->WaitForChangeCount(2);
1339 changes2()->clear(); 1339 changes2()->clear();
1340 1340
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
1391 { 1391 {
1392 std::vector<TestWindow> windows; 1392 std::vector<TestWindow> windows;
1393 GetWindowTree(wt3(), window_3_1, &windows); 1393 GetWindowTree(wt3(), window_3_1, &windows);
1394 ASSERT_EQ(1u, windows.size()); 1394 ASSERT_EQ(1u, windows.size());
1395 EXPECT_EQ(WindowParentToString(window_3_1, kNullParentId), 1395 EXPECT_EQ(WindowParentToString(window_3_1, kNullParentId),
1396 windows[0].ToString()); 1396 windows[0].ToString());
1397 } 1397 }
1398 } 1398 }
1399 1399
1400 // Assertions for SetWindowVisibility. 1400 // Assertions for SetWindowVisibility.
1401 TEST_F(WindowTreeAppTest, SetWindowVisibility) { 1401 TEST_F(WindowTreeClientTest, SetWindowVisibility) {
1402 // Create 1 and 2 in the first connection and parent both to the root. 1402 // Create 1 and 2 in the first connection and parent both to the root.
1403 Id window_1_1 = wt_client1()->NewWindow(1); 1403 Id window_1_1 = wt_client1()->NewWindow(1);
1404 Id window_1_2 = wt_client1()->NewWindow(2); 1404 Id window_1_2 = wt_client1()->NewWindow(2);
1405 ASSERT_TRUE(window_1_1); 1405 ASSERT_TRUE(window_1_1);
1406 ASSERT_TRUE(window_1_2); 1406 ASSERT_TRUE(window_1_2);
1407 1407
1408 ASSERT_TRUE(wt_client1()->AddWindow(root_window_id(), window_1_1)); 1408 ASSERT_TRUE(wt_client1()->AddWindow(root_window_id(), window_1_1));
1409 { 1409 {
1410 std::vector<TestWindow> windows; 1410 std::vector<TestWindow> windows;
1411 GetWindowTree(wt1(), root_window_id(), &windows); 1411 GetWindowTree(wt1(), root_window_id(), &windows);
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
1467 EXPECT_EQ(WindowParentToString(window_1_1, root_window_id()) + 1467 EXPECT_EQ(WindowParentToString(window_1_1, root_window_id()) +
1468 " visible=true drawn=true", 1468 " visible=true drawn=true",
1469 windows[0].ToString2()); 1469 windows[0].ToString2());
1470 EXPECT_EQ(WindowParentToString(window_1_2, window_1_1) + 1470 EXPECT_EQ(WindowParentToString(window_1_2, window_1_1) +
1471 " visible=true drawn=true", 1471 " visible=true drawn=true",
1472 windows[1].ToString2()); 1472 windows[1].ToString2());
1473 } 1473 }
1474 } 1474 }
1475 1475
1476 // Test that we hear the cursor change in other connections. 1476 // Test that we hear the cursor change in other connections.
1477 TEST_F(WindowTreeAppTest, SetCursor) { 1477 TEST_F(WindowTreeClientTest, SetCursor) {
1478 // Get a second connection to listen in. 1478 // Get a second connection to listen in.
1479 ASSERT_NO_FATAL_FAILURE(EstablishSecondConnection(true)); 1479 ASSERT_NO_FATAL_FAILURE(EstablishSecondConnection(true));
1480 Id window_1_1 = BuildWindowId(connection_id_1(), 1); 1480 Id window_1_1 = BuildWindowId(connection_id_1(), 1);
1481 changes2()->clear(); 1481 changes2()->clear();
1482 1482
1483 ASSERT_TRUE( 1483 ASSERT_TRUE(
1484 wt_client1()->SetPredefinedCursor(window_1_1, mojom::Cursor::IBEAM)); 1484 wt_client1()->SetPredefinedCursor(window_1_1, mojom::Cursor::IBEAM));
1485 wt_client2_->WaitForChangeCount(1u); 1485 wt_client2_->WaitForChangeCount(1u);
1486 1486
1487 EXPECT_EQ("CursorChanged id=" + IdToString(window_1_1) + " cursor_id=4", 1487 EXPECT_EQ("CursorChanged id=" + IdToString(window_1_1) + " cursor_id=4",
1488 SingleChangeToDescription(*changes2())); 1488 SingleChangeToDescription(*changes2()));
1489 } 1489 }
1490 1490
1491 // Assertions for SetWindowVisibility sending notifications. 1491 // Assertions for SetWindowVisibility sending notifications.
1492 TEST_F(WindowTreeAppTest, SetWindowVisibilityNotifications) { 1492 TEST_F(WindowTreeClientTest, SetWindowVisibilityNotifications) {
1493 // Create 1,1 and 1,2. 1,2 is made a child of 1,1 and 1,1 a child of the root. 1493 // Create 1,1 and 1,2. 1,2 is made a child of 1,1 and 1,1 a child of the root.
1494 Id window_1_1 = wt_client1()->NewWindow(1); 1494 Id window_1_1 = wt_client1()->NewWindow(1);
1495 ASSERT_TRUE(window_1_1); 1495 ASSERT_TRUE(window_1_1);
1496 ASSERT_TRUE(wt_client1()->SetWindowVisibility(window_1_1, true)); 1496 ASSERT_TRUE(wt_client1()->SetWindowVisibility(window_1_1, true));
1497 Id window_1_2 = wt_client1()->NewWindow(2); 1497 Id window_1_2 = wt_client1()->NewWindow(2);
1498 ASSERT_TRUE(window_1_2); 1498 ASSERT_TRUE(window_1_2);
1499 ASSERT_TRUE(wt_client1()->SetWindowVisibility(window_1_2, true)); 1499 ASSERT_TRUE(wt_client1()->SetWindowVisibility(window_1_2, true));
1500 ASSERT_TRUE(wt_client1()->AddWindow(root_window_id(), window_1_1)); 1500 ASSERT_TRUE(wt_client1()->AddWindow(root_window_id(), window_1_1));
1501 ASSERT_TRUE(wt_client1()->AddWindow(window_1_1, window_1_2)); 1501 ASSERT_TRUE(wt_client1()->AddWindow(window_1_1, window_1_2));
1502 1502
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
1574 // Add 1,1 back to the root, connection 2 should see drawn state changed. 1574 // Add 1,1 back to the root, connection 2 should see drawn state changed.
1575 ASSERT_TRUE(wt_client1()->AddWindow(root_window_id(), window_1_1)); 1575 ASSERT_TRUE(wt_client1()->AddWindow(root_window_id(), window_1_1));
1576 { 1576 {
1577 wt_client2_->WaitForChangeCount(1); 1577 wt_client2_->WaitForChangeCount(1);
1578 EXPECT_EQ( 1578 EXPECT_EQ(
1579 "DrawnStateChanged window=" + IdToString(window_1_2) + " drawn=true", 1579 "DrawnStateChanged window=" + IdToString(window_1_2) + " drawn=true",
1580 SingleChangeToDescription(*changes2())); 1580 SingleChangeToDescription(*changes2()));
1581 } 1581 }
1582 } 1582 }
1583 1583
1584 TEST_F(WindowTreeAppTest, SetWindowProperty) { 1584 TEST_F(WindowTreeClientTest, SetWindowProperty) {
1585 Id window_1_1 = wt_client1()->NewWindow(1); 1585 Id window_1_1 = wt_client1()->NewWindow(1);
1586 ASSERT_TRUE(window_1_1); 1586 ASSERT_TRUE(window_1_1);
1587 1587
1588 ASSERT_NO_FATAL_FAILURE(EstablishSecondConnection(false)); 1588 ASSERT_NO_FATAL_FAILURE(EstablishSecondConnection(false));
1589 changes2()->clear(); 1589 changes2()->clear();
1590 1590
1591 ASSERT_TRUE(wt_client1()->AddWindow(root_window_id(), window_1_1)); 1591 ASSERT_TRUE(wt_client1()->AddWindow(root_window_id(), window_1_1));
1592 { 1592 {
1593 std::vector<TestWindow> windows; 1593 std::vector<TestWindow> windows;
1594 GetWindowTree(wt1(), root_window_id(), &windows); 1594 GetWindowTree(wt1(), root_window_id(), &windows);
(...skipping 27 matching lines...) Expand all
1622 // Set back to null. 1622 // Set back to null.
1623 ASSERT_TRUE(wt_client1()->SetWindowProperty(window_1_1, "one", NULL)); 1623 ASSERT_TRUE(wt_client1()->SetWindowProperty(window_1_1, "one", NULL));
1624 { 1624 {
1625 wt_client2_->WaitForChangeCount(1); 1625 wt_client2_->WaitForChangeCount(1);
1626 EXPECT_EQ("PropertyChanged window=" + IdToString(window_1_1) + 1626 EXPECT_EQ("PropertyChanged window=" + IdToString(window_1_1) +
1627 " key=one value=NULL", 1627 " key=one value=NULL",
1628 SingleChangeToDescription(*changes2())); 1628 SingleChangeToDescription(*changes2()));
1629 } 1629 }
1630 } 1630 }
1631 1631
1632 TEST_F(WindowTreeAppTest, OnEmbeddedAppDisconnected) { 1632 TEST_F(WindowTreeClientTest, OnEmbeddedAppDisconnected) {
1633 // Create connection 2 and 3. 1633 // Create connection 2 and 3.
1634 ASSERT_NO_FATAL_FAILURE(EstablishSecondConnection(true)); 1634 ASSERT_NO_FATAL_FAILURE(EstablishSecondConnection(true));
1635 Id window_1_1 = BuildWindowId(connection_id_1(), 1); 1635 Id window_1_1 = BuildWindowId(connection_id_1(), 1);
1636 Id window_2_1 = wt_client2()->NewWindow(1); 1636 Id window_2_1 = wt_client2()->NewWindow(1);
1637 ASSERT_TRUE(window_2_1); 1637 ASSERT_TRUE(window_2_1);
1638 ASSERT_TRUE(wt_client2()->AddWindow(window_1_1, window_2_1)); 1638 ASSERT_TRUE(wt_client2()->AddWindow(window_1_1, window_2_1));
1639 changes2()->clear(); 1639 changes2()->clear();
1640 ASSERT_NO_FATAL_FAILURE(EstablishThirdConnection(wt2(), window_2_1)); 1640 ASSERT_NO_FATAL_FAILURE(EstablishThirdConnection(wt2(), window_2_1));
1641 1641
1642 // Connection 1 should get a hierarchy change for window_2_1. 1642 // Connection 1 should get a hierarchy change for window_2_1.
1643 wt_client1_->WaitForChangeCount(1); 1643 wt_client1_->WaitForChangeCount(1);
1644 changes1()->clear(); 1644 changes1()->clear();
1645 1645
1646 // Close connection 3. Connection 2 (which had previously embedded 3) should 1646 // Close connection 3. Connection 2 (which had previously embedded 3) should
1647 // be notified of this. 1647 // be notified of this.
1648 wt_client3_.reset(); 1648 wt_client3_.reset();
1649 wt_client2_->WaitForChangeCount(1); 1649 wt_client2_->WaitForChangeCount(1);
1650 EXPECT_EQ("OnEmbeddedAppDisconnected window=" + IdToString(window_2_1), 1650 EXPECT_EQ("OnEmbeddedAppDisconnected window=" + IdToString(window_2_1),
1651 SingleChangeToDescription(*changes2())); 1651 SingleChangeToDescription(*changes2()));
1652 1652
1653 wt_client1_->WaitForChangeCount(1); 1653 wt_client1_->WaitForChangeCount(1);
1654 EXPECT_EQ("OnEmbeddedAppDisconnected window=" + IdToString(window_2_1), 1654 EXPECT_EQ("OnEmbeddedAppDisconnected window=" + IdToString(window_2_1),
1655 SingleChangeToDescription(*changes1())); 1655 SingleChangeToDescription(*changes1()));
1656 } 1656 }
1657 1657
1658 // Verifies when the parent of an Embed() is destroyed the embedded app gets 1658 // Verifies when the parent of an Embed() is destroyed the embedded app gets
1659 // a WindowDeleted (and doesn't trigger a DCHECK). 1659 // a WindowDeleted (and doesn't trigger a DCHECK).
1660 TEST_F(WindowTreeAppTest, OnParentOfEmbedDisconnects) { 1660 TEST_F(WindowTreeClientTest, OnParentOfEmbedDisconnects) {
1661 // Create connection 2 and 3. 1661 // Create connection 2 and 3.
1662 ASSERT_NO_FATAL_FAILURE(EstablishSecondConnection(true)); 1662 ASSERT_NO_FATAL_FAILURE(EstablishSecondConnection(true));
1663 Id window_1_1 = BuildWindowId(connection_id_1(), 1); 1663 Id window_1_1 = BuildWindowId(connection_id_1(), 1);
1664 ASSERT_TRUE(wt_client1()->AddWindow(root_window_id(), window_1_1)); 1664 ASSERT_TRUE(wt_client1()->AddWindow(root_window_id(), window_1_1));
1665 Id window_2_1 = wt_client2()->NewWindow(1); 1665 Id window_2_1 = wt_client2()->NewWindow(1);
1666 Id window_2_2 = wt_client2()->NewWindow(2); 1666 Id window_2_2 = wt_client2()->NewWindow(2);
1667 ASSERT_TRUE(window_2_1); 1667 ASSERT_TRUE(window_2_1);
1668 ASSERT_TRUE(window_2_2); 1668 ASSERT_TRUE(window_2_2);
1669 ASSERT_TRUE(wt_client2()->AddWindow(window_1_1, window_2_1)); 1669 ASSERT_TRUE(wt_client2()->AddWindow(window_1_1, window_2_1));
1670 ASSERT_TRUE(wt_client2()->AddWindow(window_2_1, window_2_2)); 1670 ASSERT_TRUE(wt_client2()->AddWindow(window_2_1, window_2_2));
1671 changes2()->clear(); 1671 changes2()->clear();
1672 ASSERT_NO_FATAL_FAILURE(EstablishThirdConnection(wt2(), window_2_2)); 1672 ASSERT_NO_FATAL_FAILURE(EstablishThirdConnection(wt2(), window_2_2));
1673 changes3()->clear(); 1673 changes3()->clear();
1674 1674
1675 // Close connection 2. Connection 3 should get a delete (for its root). 1675 // Close connection 2. Connection 3 should get a delete (for its root).
1676 wt_client2_.reset(); 1676 wt_client2_.reset();
1677 wt_client3_->WaitForChangeCount(1); 1677 wt_client3_->WaitForChangeCount(1);
1678 EXPECT_EQ("WindowDeleted window=" + IdToString(window_2_2), 1678 EXPECT_EQ("WindowDeleted window=" + IdToString(window_2_2),
1679 SingleChangeToDescription(*changes3())); 1679 SingleChangeToDescription(*changes3()));
1680 } 1680 }
1681 1681
1682 // Verifies WindowTreeImpl doesn't incorrectly erase from its internal 1682 // Verifies WindowTreeImpl doesn't incorrectly erase from its internal
1683 // map when a window from another connection with the same window_id is removed. 1683 // map when a window from another connection with the same window_id is removed.
1684 TEST_F(WindowTreeAppTest, DontCleanMapOnDestroy) { 1684 TEST_F(WindowTreeClientTest, DontCleanMapOnDestroy) {
1685 ASSERT_NO_FATAL_FAILURE(EstablishSecondConnection(true)); 1685 ASSERT_NO_FATAL_FAILURE(EstablishSecondConnection(true));
1686 Id window_1_1 = BuildWindowId(connection_id_1(), 1); 1686 Id window_1_1 = BuildWindowId(connection_id_1(), 1);
1687 ASSERT_TRUE(wt_client2()->NewWindow(1)); 1687 ASSERT_TRUE(wt_client2()->NewWindow(1));
1688 changes1()->clear(); 1688 changes1()->clear();
1689 wt_client2_.reset(); 1689 wt_client2_.reset();
1690 wt_client1_->WaitForChangeCount(1); 1690 wt_client1_->WaitForChangeCount(1);
1691 EXPECT_EQ("OnEmbeddedAppDisconnected window=" + IdToString(window_1_1), 1691 EXPECT_EQ("OnEmbeddedAppDisconnected window=" + IdToString(window_1_1),
1692 SingleChangeToDescription(*changes1())); 1692 SingleChangeToDescription(*changes1()));
1693 std::vector<TestWindow> windows; 1693 std::vector<TestWindow> windows;
1694 GetWindowTree(wt1(), window_1_1, &windows); 1694 GetWindowTree(wt1(), window_1_1, &windows);
1695 EXPECT_FALSE(windows.empty()); 1695 EXPECT_FALSE(windows.empty());
1696 } 1696 }
1697 1697
1698 // Verifies Embed() works when supplying a WindowTreeClient. 1698 // Verifies Embed() works when supplying a WindowTreeClient.
1699 TEST_F(WindowTreeAppTest, EmbedSupplyingWindowTreeClient) { 1699 TEST_F(WindowTreeClientTest, EmbedSupplyingWindowTreeClient) {
1700 ASSERT_TRUE(wt_client1()->NewWindow(1)); 1700 ASSERT_TRUE(wt_client1()->NewWindow(1));
1701 1701
1702 TestWindowTreeClientImpl client2; 1702 TestWindowTreeClientImpl client2;
1703 mojom::WindowTreeClientPtr client2_ptr; 1703 mojom::WindowTreeClientPtr client2_ptr;
1704 mojo::Binding<WindowTreeClient> client2_binding(&client2, &client2_ptr); 1704 mojo::Binding<WindowTreeClient> client2_binding(&client2, &client2_ptr);
1705 ASSERT_TRUE(Embed(wt1(), BuildWindowId(connection_id_1(), 1), 1705 ASSERT_TRUE(Embed(wt1(), BuildWindowId(connection_id_1(), 1),
1706 std::move(client2_ptr))); 1706 std::move(client2_ptr)));
1707 client2.WaitForOnEmbed(); 1707 client2.WaitForOnEmbed();
1708 EXPECT_EQ("OnEmbed", 1708 EXPECT_EQ("OnEmbed",
1709 SingleChangeToDescription(*client2.tracker()->changes())); 1709 SingleChangeToDescription(*client2.tracker()->changes()));
1710 } 1710 }
1711 1711
1712 TEST_F(WindowTreeAppTest, EmbedFailsFromOtherConnection) { 1712 TEST_F(WindowTreeClientTest, EmbedFailsFromOtherConnection) {
1713 ASSERT_NO_FATAL_FAILURE(EstablishSecondConnection(true)); 1713 ASSERT_NO_FATAL_FAILURE(EstablishSecondConnection(true));
1714 1714
1715 Id window_1_1 = BuildWindowId(connection_id_1(), 1); 1715 Id window_1_1 = BuildWindowId(connection_id_1(), 1);
1716 Id window_2_1 = wt_client2()->NewWindow(1); 1716 Id window_2_1 = wt_client2()->NewWindow(1);
1717 ASSERT_TRUE(window_2_1); 1717 ASSERT_TRUE(window_2_1);
1718 ASSERT_TRUE(wt_client2()->AddWindow(window_1_1, window_2_1)); 1718 ASSERT_TRUE(wt_client2()->AddWindow(window_1_1, window_2_1));
1719 ASSERT_NO_FATAL_FAILURE(EstablishThirdConnection(wt2(), window_2_1)); 1719 ASSERT_NO_FATAL_FAILURE(EstablishThirdConnection(wt2(), window_2_1));
1720 1720
1721 Id window_3_3 = wt_client3()->NewWindow(3); 1721 Id window_3_3 = wt_client3()->NewWindow(3);
1722 ASSERT_TRUE(window_3_3); 1722 ASSERT_TRUE(window_3_3);
1723 ASSERT_TRUE(wt_client3()->AddWindow(window_2_1, window_3_3)); 1723 ASSERT_TRUE(wt_client3()->AddWindow(window_2_1, window_3_3));
1724 1724
1725 // 2 should not be able to embed in window_3_3 as window_3_3 was not created 1725 // 2 should not be able to embed in window_3_3 as window_3_3 was not created
1726 // by 1726 // by
1727 // 2. 1727 // 2.
1728 EXPECT_FALSE(EmbedUrl(connector(), wt2(), test_name(), window_3_3)); 1728 EXPECT_FALSE(EmbedUrl(connector(), wt2(), test_name(), window_3_3));
1729 } 1729 }
1730 1730
1731 // Verifies Embed() from window manager on another connections window works. 1731 // Verifies Embed() from window manager on another connections window works.
1732 TEST_F(WindowTreeAppTest, EmbedFromOtherConnection) { 1732 TEST_F(WindowTreeClientTest, EmbedFromOtherConnection) {
1733 ASSERT_NO_FATAL_FAILURE(EstablishSecondConnection(true)); 1733 ASSERT_NO_FATAL_FAILURE(EstablishSecondConnection(true));
1734 1734
1735 Id window_1_1 = BuildWindowId(connection_id_1(), 1); 1735 Id window_1_1 = BuildWindowId(connection_id_1(), 1);
1736 Id window_2_1 = wt_client2()->NewWindow(1); 1736 Id window_2_1 = wt_client2()->NewWindow(1);
1737 ASSERT_TRUE(window_2_1); 1737 ASSERT_TRUE(window_2_1);
1738 ASSERT_TRUE(wt_client2()->AddWindow(window_1_1, window_2_1)); 1738 ASSERT_TRUE(wt_client2()->AddWindow(window_1_1, window_2_1));
1739 1739
1740 changes2()->clear(); 1740 changes2()->clear();
1741 1741
1742 // Establish a third connection in window_2_1. 1742 // Establish a third connection in window_2_1.
1743 ASSERT_NO_FATAL_FAILURE(EstablishThirdConnection(wt1(), window_2_1)); 1743 ASSERT_NO_FATAL_FAILURE(EstablishThirdConnection(wt1(), window_2_1));
1744 1744
1745 ASSERT_TRUE(wt_client2()->WaitForAllMessages()); 1745 ASSERT_TRUE(wt_client2()->WaitForAllMessages());
1746 EXPECT_EQ(std::string(), SingleChangeToDescription(*changes2())); 1746 EXPECT_EQ(std::string(), SingleChangeToDescription(*changes2()));
1747 } 1747 }
1748 1748
1749 TEST_F(WindowTreeAppTest, CantEmbedFromConnectionRoot) { 1749 TEST_F(WindowTreeClientTest, CantEmbedFromConnectionRoot) {
1750 // Shouldn't be able to embed into the root. 1750 // Shouldn't be able to embed into the root.
1751 ASSERT_FALSE(EmbedUrl(connector(), wt1(), test_name(), root_window_id())); 1751 ASSERT_FALSE(EmbedUrl(connector(), wt1(), test_name(), root_window_id()));
1752 1752
1753 // Even though the call above failed a WindowTreeClient was obtained. We need 1753 // Even though the call above failed a WindowTreeClient was obtained. We need
1754 // to 1754 // to
1755 // wait for it else we throw off the next connect. 1755 // wait for it else we throw off the next connect.
1756 WaitForWindowTreeClient(); 1756 WaitForWindowTreeClient();
1757 1757
1758 // Don't allow a connection to embed into its own root. 1758 // Don't allow a connection to embed into its own root.
1759 ASSERT_NO_FATAL_FAILURE(EstablishSecondConnection(true)); 1759 ASSERT_NO_FATAL_FAILURE(EstablishSecondConnection(true));
(...skipping 11 matching lines...) Expand all
1771 wt_client3_ = EstablishConnectionViaEmbedWithPolicyBitmask( 1771 wt_client3_ = EstablishConnectionViaEmbedWithPolicyBitmask(
1772 wt1(), window_1_2, mojom::WindowTree::kAccessPolicyEmbedRoot, nullptr); 1772 wt1(), window_1_2, mojom::WindowTree::kAccessPolicyEmbedRoot, nullptr);
1773 ASSERT_TRUE(wt_client3_.get() != nullptr); 1773 ASSERT_TRUE(wt_client3_.get() != nullptr);
1774 1774
1775 // window_1_2 is ws3's root, so even though v3 is an embed root it should not 1775 // window_1_2 is ws3's root, so even though v3 is an embed root it should not
1776 // be able to Embed into itself. 1776 // be able to Embed into itself.
1777 ASSERT_FALSE(EmbedUrl(connector(), wt3(), test_name(), window_1_2)); 1777 ASSERT_FALSE(EmbedUrl(connector(), wt3(), test_name(), window_1_2));
1778 } 1778 }
1779 1779
1780 // Verifies that a transient window tracks its parent's lifetime. 1780 // Verifies that a transient window tracks its parent's lifetime.
1781 TEST_F(WindowTreeAppTest, TransientWindowTracksTransientParentLifetime) { 1781 TEST_F(WindowTreeClientTest, TransientWindowTracksTransientParentLifetime) {
1782 ASSERT_NO_FATAL_FAILURE(EstablishSecondConnection(true)); 1782 ASSERT_NO_FATAL_FAILURE(EstablishSecondConnection(true));
1783 Id window_1_1 = BuildWindowId(connection_id_1(), 1); 1783 Id window_1_1 = BuildWindowId(connection_id_1(), 1);
1784 1784
1785 Id window_2_1 = wt_client2()->NewWindow(1); 1785 Id window_2_1 = wt_client2()->NewWindow(1);
1786 Id window_2_2 = wt_client2()->NewWindow(2); 1786 Id window_2_2 = wt_client2()->NewWindow(2);
1787 Id window_2_3 = wt_client2()->NewWindow(3); 1787 Id window_2_3 = wt_client2()->NewWindow(3);
1788 ASSERT_TRUE(window_2_1); 1788 ASSERT_TRUE(window_2_1);
1789 1789
1790 // root -> window_1_1 -> window_2_1 1790 // root -> window_1_1 -> window_2_1
1791 // root -> window_1_1 -> window_2_2 1791 // root -> window_1_1 -> window_2_2
(...skipping 24 matching lines...) Expand all
1816 1816
1817 changes1()->clear(); 1817 changes1()->clear();
1818 ASSERT_TRUE(wt_client2()->DeleteWindow(window_2_1)); 1818 ASSERT_TRUE(wt_client2()->DeleteWindow(window_2_1));
1819 wt_client1()->WaitForChangeCount(2); 1819 wt_client1()->WaitForChangeCount(2);
1820 EXPECT_EQ("WindowDeleted window=" + IdToString(window_2_2), 1820 EXPECT_EQ("WindowDeleted window=" + IdToString(window_2_2),
1821 ChangesToDescription1(*changes1())[0]); 1821 ChangesToDescription1(*changes1())[0]);
1822 EXPECT_EQ("WindowDeleted window=" + IdToString(window_2_1), 1822 EXPECT_EQ("WindowDeleted window=" + IdToString(window_2_1),
1823 ChangesToDescription1(*changes1())[1]); 1823 ChangesToDescription1(*changes1())[1]);
1824 } 1824 }
1825 1825
1826 TEST_F(WindowTreeAppTest, Ids) { 1826 TEST_F(WindowTreeClientTest, Ids) {
1827 const Id window_1_100 = wt_client1()->NewWindow(100); 1827 const Id window_1_100 = wt_client1()->NewWindow(100);
1828 ASSERT_TRUE(window_1_100); 1828 ASSERT_TRUE(window_1_100);
1829 ASSERT_TRUE(wt_client1()->AddWindow(root_window_id(), window_1_100)); 1829 ASSERT_TRUE(wt_client1()->AddWindow(root_window_id(), window_1_100));
1830 1830
1831 // Establish the second connection at 1,100. 1831 // Establish the second connection at 1,100.
1832 ASSERT_NO_FATAL_FAILURE(EstablishSecondConnectionWithRoot(window_1_100)); 1832 ASSERT_NO_FATAL_FAILURE(EstablishSecondConnectionWithRoot(window_1_100));
1833 1833
1834 // 1,100 is the id in the wt_client1's id space. The new client should see 1834 // 1,100 is the id in the wt_client1's id space. The new client should see
1835 // 2,1 (the server id). 1835 // 2,1 (the server id).
1836 const Id window_1_100_in_ws2 = BuildWindowId(connection_id_1(), 1); 1836 const Id window_1_100_in_ws2 = BuildWindowId(connection_id_1(), 1);
(...skipping 25 matching lines...) Expand all
1862 ASSERT_TRUE(wt_client1()->WaitForChangeCompleted(12)); 1862 ASSERT_TRUE(wt_client1()->WaitForChangeCompleted(12));
1863 wt_client2()->WaitForChangeCount(1); 1863 wt_client2()->WaitForChangeCount(1);
1864 EXPECT_EQ("HierarchyChanged window=" + IdToString(window_2_101) + 1864 EXPECT_EQ("HierarchyChanged window=" + IdToString(window_2_101) +
1865 " new_parent=null old_parent=" + 1865 " new_parent=null old_parent=" +
1866 IdToString(window_1_100_in_ws2), 1866 IdToString(window_1_100_in_ws2),
1867 SingleChangeToDescription(*changes2())); 1867 SingleChangeToDescription(*changes2()));
1868 } 1868 }
1869 1869
1870 // Tests that setting capture fails when no input event has occurred, and there 1870 // Tests that setting capture fails when no input event has occurred, and there
1871 // is no notification of lost capture. 1871 // is no notification of lost capture.
1872 TEST_F(WindowTreeAppTest, ExplicitCaptureWithoutInput) { 1872 TEST_F(WindowTreeClientTest, ExplicitCaptureWithoutInput) {
1873 Id window_1_1 = wt_client1()->NewWindow(1); 1873 Id window_1_1 = wt_client1()->NewWindow(1);
1874 1874
1875 // Add the window to the root, so that they have a Display to handle input 1875 // Add the window to the root, so that they have a Display to handle input
1876 // capture. 1876 // capture.
1877 ASSERT_TRUE(wt_client1()->AddWindow(root_window_id(), window_1_1)); 1877 ASSERT_TRUE(wt_client1()->AddWindow(root_window_id(), window_1_1));
1878 changes1()->clear(); 1878 changes1()->clear();
1879 1879
1880 // Since there has been no input, capture should not succeed. No lost capture 1880 // Since there has been no input, capture should not succeed. No lost capture
1881 // message is expected. 1881 // message is expected.
1882 wt1()->SetCapture(1, window_1_1); 1882 wt1()->SetCapture(1, window_1_1);
1883 wt_client1_->WaitForAllMessages(); 1883 wt_client1_->WaitForAllMessages();
1884 EXPECT_TRUE(changes1()->empty()); 1884 EXPECT_TRUE(changes1()->empty());
1885 1885
1886 // Since there is no window with capture, lost capture should not be notified. 1886 // Since there is no window with capture, lost capture should not be notified.
1887 wt1()->ReleaseCapture(3, window_1_1); 1887 wt1()->ReleaseCapture(3, window_1_1);
1888 wt_client1_->WaitForAllMessages(); 1888 wt_client1_->WaitForAllMessages();
1889 EXPECT_TRUE(changes1()->empty()); 1889 EXPECT_TRUE(changes1()->empty());
1890 } 1890 }
1891 1891
1892 // TODO(jonross): Enable this once apptests can send input events to the server. 1892 // TODO(jonross): Enable this once apptests can send input events to the server.
1893 // Enabling capture requires that the connection be processing events. 1893 // Enabling capture requires that the connection be processing events.
1894 TEST_F(WindowTreeAppTest, DISABLED_ExplicitCapturePropagation) { 1894 TEST_F(WindowTreeClientTest, DISABLED_ExplicitCapturePropagation) {
1895 Id window_1_1 = wt_client1()->NewWindow(1); 1895 Id window_1_1 = wt_client1()->NewWindow(1);
1896 Id window_1_2 = wt_client1()->NewWindow(2); 1896 Id window_1_2 = wt_client1()->NewWindow(2);
1897 1897
1898 // Add the windows to the root, so that they have a Display to handle input 1898 // Add the windows to the root, so that they have a Display to handle input
1899 // capture. 1899 // capture.
1900 ASSERT_TRUE(wt_client1()->AddWindow(root_window_id(), window_1_1)); 1900 ASSERT_TRUE(wt_client1()->AddWindow(root_window_id(), window_1_1));
1901 ASSERT_TRUE(wt_client1()->AddWindow(root_window_id(), window_1_2)); 1901 ASSERT_TRUE(wt_client1()->AddWindow(root_window_id(), window_1_2));
1902 1902
1903 changes1()->clear(); 1903 changes1()->clear();
1904 // Window 1 takes capture then Window 2 takes capture. 1904 // Window 1 takes capture then Window 2 takes capture.
(...skipping 19 matching lines...) Expand all
1924 1924
1925 // TODO(sky): make sure coverage of what was 1925 // TODO(sky): make sure coverage of what was
1926 // WindowManagerTest.SecondEmbedRoot_InitService and 1926 // WindowManagerTest.SecondEmbedRoot_InitService and
1927 // WindowManagerTest.MultipleEmbedRootsBeforeWTHReady gets added to window 1927 // WindowManagerTest.MultipleEmbedRootsBeforeWTHReady gets added to window
1928 // manager 1928 // manager
1929 // tests. 1929 // tests.
1930 1930
1931 } // namespace test 1931 } // namespace test
1932 } // namespace ws 1932 } // namespace ws
1933 } // namespace mus 1933 } // namespace mus
OLDNEW
« no previous file with comments | « components/mus/ws/window_tree_apptest.cc ('k') | mash/wm/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698