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/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
11 #include "base/message_loop/message_loop.h" | 11 #include "base/message_loop/message_loop.h" |
12 #include "base/run_loop.h" | 12 #include "base/run_loop.h" |
13 #include "base/strings/stringprintf.h" | 13 #include "base/strings/stringprintf.h" |
14 #include "cc/surfaces/local_surface_id_allocator.h" | 14 #include "cc/surfaces/local_surface_id_allocator.h" |
15 #include "mojo/public/cpp/bindings/associated_binding.h" | 15 #include "mojo/public/cpp/bindings/associated_binding.h" |
16 #include "mojo/public/cpp/bindings/binding.h" | 16 #include "mojo/public/cpp/bindings/binding.h" |
| 17 #include "services/service_manager/public/cpp/binder_registry.h" |
17 #include "services/service_manager/public/cpp/interface_factory.h" | 18 #include "services/service_manager/public/cpp/interface_factory.h" |
18 #include "services/service_manager/public/cpp/interface_registry.h" | |
19 #include "services/service_manager/public/cpp/service_test.h" | 19 #include "services/service_manager/public/cpp/service_test.h" |
20 #include "services/ui/public/interfaces/constants.mojom.h" | 20 #include "services/ui/public/interfaces/constants.mojom.h" |
21 #include "services/ui/public/interfaces/window_tree.mojom.h" | 21 #include "services/ui/public/interfaces/window_tree.mojom.h" |
22 #include "services/ui/public/interfaces/window_tree_host.mojom.h" | 22 #include "services/ui/public/interfaces/window_tree_host.mojom.h" |
23 #include "services/ui/ws/ids.h" | 23 #include "services/ui/ws/ids.h" |
24 #include "services/ui/ws/test_change_tracker.h" | 24 #include "services/ui/ws/test_change_tracker.h" |
25 #include "services/ui/ws/window_server_service_test_base.h" | 25 #include "services/ui/ws/window_server_service_test_base.h" |
26 | 26 |
27 using service_manager::Connection; | 27 using service_manager::Connection; |
28 using mojo::InterfaceRequest; | 28 using mojo::InterfaceRequest; |
(...skipping 642 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
671 // window ID. This is likely bad from a security perspective and should be | 671 // window ID. This is likely bad from a security perspective and should be |
672 // fixed. | 672 // fixed. |
673 EXPECT_EQ("OnEmbed", | 673 EXPECT_EQ("OnEmbed", |
674 SingleChangeToDescription(*client->tracker()->changes())); | 674 SingleChangeToDescription(*client->tracker()->changes())); |
675 if (client_id) | 675 if (client_id) |
676 *client_id = (*client->tracker()->changes())[0].client_id; | 676 *client_id = (*client->tracker()->changes())[0].client_id; |
677 return client; | 677 return client; |
678 } | 678 } |
679 | 679 |
680 // WindowServerServiceTestBase: | 680 // WindowServerServiceTestBase: |
681 bool OnConnect(const service_manager::Identity& remote_identity, | 681 void OnBindInterface(const service_manager::ServiceInfo& source_info, |
682 service_manager::InterfaceRegistry* registry) override { | 682 const std::string& interface_name, |
683 registry->AddInterface(client_factory_.get()); | 683 mojo::ScopedMessagePipeHandle interface_pipe) override { |
684 return true; | 684 registry_.BindInterface(source_info.identity, interface_name, |
| 685 std::move(interface_pipe)); |
685 } | 686 } |
686 | 687 |
687 void SetUp() override { | 688 void SetUp() override { |
688 client_factory_ = base::MakeUnique<WindowTreeClientFactory>(); | 689 client_factory_ = base::MakeUnique<WindowTreeClientFactory>(); |
| 690 registry_.AddInterface(client_factory_.get()); |
689 | 691 |
690 WindowServerServiceTestBase::SetUp(); | 692 WindowServerServiceTestBase::SetUp(); |
691 | 693 |
692 mojom::WindowTreeHostFactoryPtr factory; | 694 mojom::WindowTreeHostFactoryPtr factory; |
693 connector()->BindInterface(ui::mojom::kServiceName, &factory); | 695 connector()->BindInterface(ui::mojom::kServiceName, &factory); |
694 | 696 |
695 mojom::WindowTreeClientPtr tree_client_ptr; | 697 mojom::WindowTreeClientPtr tree_client_ptr; |
696 wt_client1_ = base::MakeUnique<TestWindowTreeClient>(); | 698 wt_client1_ = base::MakeUnique<TestWindowTreeClient>(); |
697 wt_client1_->Bind(MakeRequest(&tree_client_ptr)); | 699 wt_client1_->Bind(MakeRequest(&tree_client_ptr)); |
698 | 700 |
(...skipping 30 matching lines...) Expand all Loading... |
729 std::unique_ptr<TestWindowTreeClient> wt_client2_; | 731 std::unique_ptr<TestWindowTreeClient> wt_client2_; |
730 std::unique_ptr<TestWindowTreeClient> wt_client3_; | 732 std::unique_ptr<TestWindowTreeClient> wt_client3_; |
731 | 733 |
732 mojom::WindowTreeHostPtr host_; | 734 mojom::WindowTreeHostPtr host_; |
733 | 735 |
734 private: | 736 private: |
735 std::unique_ptr<WindowTreeClientFactory> client_factory_; | 737 std::unique_ptr<WindowTreeClientFactory> client_factory_; |
736 int client_id_1_; | 738 int client_id_1_; |
737 int client_id_2_; | 739 int client_id_2_; |
738 Id root_window_id_; | 740 Id root_window_id_; |
| 741 service_manager::BinderRegistry registry_; |
739 | 742 |
740 DISALLOW_COPY_AND_ASSIGN(WindowTreeClientTest); | 743 DISALLOW_COPY_AND_ASSIGN(WindowTreeClientTest); |
741 }; | 744 }; |
742 | 745 |
743 // Verifies two clients get different ids. | 746 // Verifies two clients get different ids. |
744 TEST_F(WindowTreeClientTest, TwoClientsGetDifferentClientIds) { | 747 TEST_F(WindowTreeClientTest, TwoClientsGetDifferentClientIds) { |
745 ASSERT_NO_FATAL_FAILURE(EstablishSecondClient(true)); | 748 ASSERT_NO_FATAL_FAILURE(EstablishSecondClient(true)); |
746 | 749 |
747 ASSERT_EQ(1u, changes2()->size()); | 750 ASSERT_EQ(1u, changes2()->size()); |
748 ASSERT_NE(client_id_1(), client_id_2()); | 751 ASSERT_NE(client_id_1(), client_id_2()); |
(...skipping 1518 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2267 | 2270 |
2268 // TODO(sky): make sure coverage of what was | 2271 // TODO(sky): make sure coverage of what was |
2269 // WindowManagerTest.SecondEmbedRoot_InitService and | 2272 // WindowManagerTest.SecondEmbedRoot_InitService and |
2270 // WindowManagerTest.MultipleEmbedRootsBeforeWTHReady gets added to window | 2273 // WindowManagerTest.MultipleEmbedRootsBeforeWTHReady gets added to window |
2271 // manager | 2274 // manager |
2272 // tests. | 2275 // tests. |
2273 | 2276 |
2274 } // namespace test | 2277 } // namespace test |
2275 } // namespace ws | 2278 } // namespace ws |
2276 } // namespace ui | 2279 } // namespace ui |
OLD | NEW |