| 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/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 "mojo/public/cpp/bindings/associated_binding.h" | 13 #include "mojo/public/cpp/bindings/associated_binding.h" |
| 14 #include "services/shell/public/cpp/shell_test.h" | 14 #include "services/shell/public/cpp/service_test.h" |
| 15 #include "services/ui/public/cpp/tests/window_server_shelltest_base.h" | 15 #include "services/ui/public/cpp/tests/window_server_shelltest_base.h" |
| 16 #include "services/ui/public/interfaces/window_tree.mojom.h" | 16 #include "services/ui/public/interfaces/window_tree.mojom.h" |
| 17 #include "services/ui/public/interfaces/window_tree_host.mojom.h" | 17 #include "services/ui/public/interfaces/window_tree_host.mojom.h" |
| 18 #include "services/ui/ws/ids.h" | 18 #include "services/ui/ws/ids.h" |
| 19 #include "services/ui/ws/test_change_tracker.h" | 19 #include "services/ui/ws/test_change_tracker.h" |
| 20 | 20 |
| 21 using mojo::Array; | 21 using mojo::Array; |
| 22 using shell::Connection; | 22 using shell::Connection; |
| 23 using mojo::InterfaceRequest; | 23 using mojo::InterfaceRequest; |
| 24 using shell::Service; | 24 using shell::Service; |
| (...skipping 451 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 476 } | 476 } |
| 477 | 477 |
| 478 std::unique_ptr<TestWindowTreeClient> client_impl_; | 478 std::unique_ptr<TestWindowTreeClient> client_impl_; |
| 479 std::unique_ptr<base::RunLoop> run_loop_; | 479 std::unique_ptr<base::RunLoop> run_loop_; |
| 480 | 480 |
| 481 DISALLOW_COPY_AND_ASSIGN(WindowTreeClientFactory); | 481 DISALLOW_COPY_AND_ASSIGN(WindowTreeClientFactory); |
| 482 }; | 482 }; |
| 483 | 483 |
| 484 } // namespace | 484 } // namespace |
| 485 | 485 |
| 486 class WindowTreeClientTest : public WindowServerShellTestBase { | 486 class WindowTreeClientTest : public WindowServerServiceTestBase { |
| 487 public: | 487 public: |
| 488 WindowTreeClientTest() | 488 WindowTreeClientTest() |
| 489 : client_id_1_(0), client_id_2_(0), root_window_id_(0) {} | 489 : client_id_1_(0), client_id_2_(0), root_window_id_(0) {} |
| 490 | 490 |
| 491 ~WindowTreeClientTest() override {} | 491 ~WindowTreeClientTest() override {} |
| 492 | 492 |
| 493 protected: | 493 protected: |
| 494 // Returns the changes from the various clients. | 494 // Returns the changes from the various clients. |
| 495 std::vector<Change>* changes1() { return wt_client1_->tracker()->changes(); } | 495 std::vector<Change>* changes1() { return wt_client1_->tracker()->changes(); } |
| 496 std::vector<Change>* changes2() { return wt_client2_->tracker()->changes(); } | 496 std::vector<Change>* changes2() { return wt_client2_->tracker()->changes(); } |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 568 } | 568 } |
| 569 client->WaitForOnEmbed(); | 569 client->WaitForOnEmbed(); |
| 570 | 570 |
| 571 EXPECT_EQ("OnEmbed", | 571 EXPECT_EQ("OnEmbed", |
| 572 SingleChangeToDescription(*client->tracker()->changes())); | 572 SingleChangeToDescription(*client->tracker()->changes())); |
| 573 if (client_id) | 573 if (client_id) |
| 574 *client_id = (*client->tracker()->changes())[0].client_id; | 574 *client_id = (*client->tracker()->changes())[0].client_id; |
| 575 return client; | 575 return client; |
| 576 } | 576 } |
| 577 | 577 |
| 578 // WindowServerShellTestBase: | 578 // WindowServerServiceTestBase: |
| 579 bool OnConnect(shell::Connection* connection) override { | 579 bool OnConnect(shell::Connection* connection) override { |
| 580 connection->AddInterface(client_factory_.get()); | 580 connection->AddInterface(client_factory_.get()); |
| 581 return true; | 581 return true; |
| 582 } | 582 } |
| 583 | 583 |
| 584 void SetUp() override { | 584 void SetUp() override { |
| 585 client_factory_.reset(new WindowTreeClientFactory()); | 585 client_factory_.reset(new WindowTreeClientFactory()); |
| 586 | 586 |
| 587 WindowServerShellTestBase::SetUp(); | 587 WindowServerServiceTestBase::SetUp(); |
| 588 | 588 |
| 589 mojom::WindowTreeHostFactoryPtr factory; | 589 mojom::WindowTreeHostFactoryPtr factory; |
| 590 connector()->ConnectToInterface("mojo:ui", &factory); | 590 connector()->ConnectToInterface("mojo:ui", &factory); |
| 591 | 591 |
| 592 mojom::WindowTreeClientPtr tree_client_ptr; | 592 mojom::WindowTreeClientPtr tree_client_ptr; |
| 593 wt_client1_.reset(new TestWindowTreeClient()); | 593 wt_client1_.reset(new TestWindowTreeClient()); |
| 594 wt_client1_->Bind(GetProxy(&tree_client_ptr)); | 594 wt_client1_->Bind(GetProxy(&tree_client_ptr)); |
| 595 | 595 |
| 596 factory->CreateWindowTreeHost(GetProxy(&host_), | 596 factory->CreateWindowTreeHost(GetProxy(&host_), |
| 597 std::move(tree_client_ptr)); | 597 std::move(tree_client_ptr)); |
| 598 | 598 |
| 599 // Next we should get an embed call on the "window manager" client. | 599 // Next we should get an embed call on the "window manager" client. |
| 600 wt_client1_->WaitForOnEmbed(); | 600 wt_client1_->WaitForOnEmbed(); |
| 601 | 601 |
| 602 ASSERT_EQ(1u, changes1()->size()); | 602 ASSERT_EQ(1u, changes1()->size()); |
| 603 EXPECT_EQ(CHANGE_TYPE_EMBED, (*changes1())[0].type); | 603 EXPECT_EQ(CHANGE_TYPE_EMBED, (*changes1())[0].type); |
| 604 // All these tests assume 1 for the client id. The only real assertion here | 604 // All these tests assume 1 for the client id. The only real assertion here |
| 605 // is the client id is not zero, but adding this as rest of code here | 605 // is the client id is not zero, but adding this as rest of code here |
| 606 // assumes 1. | 606 // assumes 1. |
| 607 ASSERT_GT((*changes1())[0].client_id, 0); | 607 ASSERT_GT((*changes1())[0].client_id, 0); |
| 608 client_id_1_ = (*changes1())[0].client_id; | 608 client_id_1_ = (*changes1())[0].client_id; |
| 609 ASSERT_FALSE((*changes1())[0].windows.empty()); | 609 ASSERT_FALSE((*changes1())[0].windows.empty()); |
| 610 root_window_id_ = (*changes1())[0].windows[0].window_id; | 610 root_window_id_ = (*changes1())[0].windows[0].window_id; |
| 611 ASSERT_EQ(root_window_id_, wt_client1_->root_window_id()); | 611 ASSERT_EQ(root_window_id_, wt_client1_->root_window_id()); |
| 612 changes1()->clear(); | 612 changes1()->clear(); |
| 613 } | 613 } |
| 614 | 614 |
| 615 void TearDown() override { | 615 void TearDown() override { |
| 616 // Destroy these before the message loop is destroyed (happens in | 616 // Destroy these before the message loop is destroyed (happens in |
| 617 // WindowServerShellTestBase::TearDown). | 617 // WindowServerServiceTestBase::TearDown). |
| 618 wt_client1_.reset(); | 618 wt_client1_.reset(); |
| 619 wt_client2_.reset(); | 619 wt_client2_.reset(); |
| 620 wt_client3_.reset(); | 620 wt_client3_.reset(); |
| 621 client_factory_.reset(); | 621 client_factory_.reset(); |
| 622 WindowServerShellTestBase::TearDown(); | 622 WindowServerServiceTestBase::TearDown(); |
| 623 } | 623 } |
| 624 | 624 |
| 625 std::unique_ptr<TestWindowTreeClient> wt_client1_; | 625 std::unique_ptr<TestWindowTreeClient> wt_client1_; |
| 626 std::unique_ptr<TestWindowTreeClient> wt_client2_; | 626 std::unique_ptr<TestWindowTreeClient> wt_client2_; |
| 627 std::unique_ptr<TestWindowTreeClient> wt_client3_; | 627 std::unique_ptr<TestWindowTreeClient> wt_client3_; |
| 628 | 628 |
| 629 mojom::WindowTreeHostPtr host_; | 629 mojom::WindowTreeHostPtr host_; |
| 630 | 630 |
| 631 private: | 631 private: |
| 632 std::unique_ptr<WindowTreeClientFactory> client_factory_; | 632 std::unique_ptr<WindowTreeClientFactory> client_factory_; |
| (...skipping 1400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2033 | 2033 |
| 2034 // TODO(sky): make sure coverage of what was | 2034 // TODO(sky): make sure coverage of what was |
| 2035 // WindowManagerTest.SecondEmbedRoot_InitService and | 2035 // WindowManagerTest.SecondEmbedRoot_InitService and |
| 2036 // WindowManagerTest.MultipleEmbedRootsBeforeWTHReady gets added to window | 2036 // WindowManagerTest.MultipleEmbedRootsBeforeWTHReady gets added to window |
| 2037 // manager | 2037 // manager |
| 2038 // tests. | 2038 // tests. |
| 2039 | 2039 |
| 2040 } // namespace test | 2040 } // namespace test |
| 2041 } // namespace ws | 2041 } // namespace ws |
| 2042 } // namespace ui | 2042 } // namespace ui |
| OLD | NEW |