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/service_manager/public/cpp/service_test.h" | 14 #include "services/service_manager/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 service_manager::Connection; |
23 using mojo::InterfaceRequest; | 23 using mojo::InterfaceRequest; |
24 using shell::Service; | 24 using service_manager::Service; |
25 using mojo::String; | 25 using mojo::String; |
26 using ui::mojom::WindowDataPtr; | 26 using ui::mojom::WindowDataPtr; |
27 using ui::mojom::WindowTree; | 27 using ui::mojom::WindowTree; |
28 using ui::mojom::WindowTreeClient; | 28 using ui::mojom::WindowTreeClient; |
29 | 29 |
30 namespace ui { | 30 namespace ui { |
31 namespace ws { | 31 namespace ws { |
32 namespace test { | 32 namespace test { |
33 | 33 |
34 namespace { | 34 namespace { |
(...skipping 16 matching lines...) Expand all Loading... |
51 | 51 |
52 void EmbedCallbackImpl(base::RunLoop* run_loop, | 52 void EmbedCallbackImpl(base::RunLoop* run_loop, |
53 bool* result_cache, | 53 bool* result_cache, |
54 bool result) { | 54 bool result) { |
55 *result_cache = result; | 55 *result_cache = result; |
56 run_loop->Quit(); | 56 run_loop->Quit(); |
57 } | 57 } |
58 | 58 |
59 // ----------------------------------------------------------------------------- | 59 // ----------------------------------------------------------------------------- |
60 | 60 |
61 bool EmbedUrl(shell::Connector* connector, | 61 bool EmbedUrl(service_manager::Connector* connector, |
62 WindowTree* tree, | 62 WindowTree* tree, |
63 const String& url, | 63 const String& url, |
64 Id root_id) { | 64 Id root_id) { |
65 bool result = false; | 65 bool result = false; |
66 base::RunLoop run_loop; | 66 base::RunLoop run_loop; |
67 { | 67 { |
68 mojom::WindowTreeClientPtr client; | 68 mojom::WindowTreeClientPtr client; |
69 connector->ConnectToInterface(url.get(), &client); | 69 connector->ConnectToInterface(url.get(), &client); |
70 const uint32_t embed_flags = 0; | 70 const uint32_t embed_flags = 0; |
71 tree->Embed(root_id, std::move(client), embed_flags, | 71 tree->Embed(root_id, std::move(client), embed_flags, |
(...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
499 window_manager_binding_; | 499 window_manager_binding_; |
500 mojom::WindowManagerClientAssociatedPtr window_manager_client_; | 500 mojom::WindowManagerClientAssociatedPtr window_manager_client_; |
501 | 501 |
502 DISALLOW_COPY_AND_ASSIGN(TestWindowTreeClient); | 502 DISALLOW_COPY_AND_ASSIGN(TestWindowTreeClient); |
503 }; | 503 }; |
504 | 504 |
505 // ----------------------------------------------------------------------------- | 505 // ----------------------------------------------------------------------------- |
506 | 506 |
507 // InterfaceFactory for vending TestWindowTreeClients. | 507 // InterfaceFactory for vending TestWindowTreeClients. |
508 class WindowTreeClientFactory | 508 class WindowTreeClientFactory |
509 : public shell::InterfaceFactory<WindowTreeClient> { | 509 : public service_manager::InterfaceFactory<WindowTreeClient> { |
510 public: | 510 public: |
511 WindowTreeClientFactory() {} | 511 WindowTreeClientFactory() {} |
512 ~WindowTreeClientFactory() override {} | 512 ~WindowTreeClientFactory() override {} |
513 | 513 |
514 // Runs a nested MessageLoop until a new instance has been created. | 514 // Runs a nested MessageLoop until a new instance has been created. |
515 std::unique_ptr<TestWindowTreeClient> WaitForInstance() { | 515 std::unique_ptr<TestWindowTreeClient> WaitForInstance() { |
516 if (!client_impl_.get()) { | 516 if (!client_impl_.get()) { |
517 DCHECK(!run_loop_); | 517 DCHECK(!run_loop_); |
518 run_loop_ = base::MakeUnique<base::RunLoop>(); | 518 run_loop_ = base::MakeUnique<base::RunLoop>(); |
519 run_loop_->Run(); | 519 run_loop_->Run(); |
520 run_loop_.reset(); | 520 run_loop_.reset(); |
521 } | 521 } |
522 return std::move(client_impl_); | 522 return std::move(client_impl_); |
523 } | 523 } |
524 | 524 |
525 private: | 525 private: |
526 // InterfaceFactory<WindowTreeClient>: | 526 // InterfaceFactory<WindowTreeClient>: |
527 void Create(const shell::Identity& remote_identity, | 527 void Create(const service_manager::Identity& remote_identity, |
528 InterfaceRequest<WindowTreeClient> request) override { | 528 InterfaceRequest<WindowTreeClient> request) override { |
529 client_impl_ = base::MakeUnique<TestWindowTreeClient>(); | 529 client_impl_ = base::MakeUnique<TestWindowTreeClient>(); |
530 client_impl_->Bind(std::move(request)); | 530 client_impl_->Bind(std::move(request)); |
531 if (run_loop_.get()) | 531 if (run_loop_.get()) |
532 run_loop_->Quit(); | 532 run_loop_->Quit(); |
533 } | 533 } |
534 | 534 |
535 std::unique_ptr<TestWindowTreeClient> client_impl_; | 535 std::unique_ptr<TestWindowTreeClient> client_impl_; |
536 std::unique_ptr<base::RunLoop> run_loop_; | 536 std::unique_ptr<base::RunLoop> run_loop_; |
537 | 537 |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
626 client->WaitForOnEmbed(); | 626 client->WaitForOnEmbed(); |
627 | 627 |
628 EXPECT_EQ("OnEmbed", | 628 EXPECT_EQ("OnEmbed", |
629 SingleChangeToDescription(*client->tracker()->changes())); | 629 SingleChangeToDescription(*client->tracker()->changes())); |
630 if (client_id) | 630 if (client_id) |
631 *client_id = (*client->tracker()->changes())[0].client_id; | 631 *client_id = (*client->tracker()->changes())[0].client_id; |
632 return client; | 632 return client; |
633 } | 633 } |
634 | 634 |
635 // WindowServerServiceTestBase: | 635 // WindowServerServiceTestBase: |
636 bool OnConnect(const shell::Identity& remote_identity, | 636 bool OnConnect(const service_manager::Identity& remote_identity, |
637 shell::InterfaceRegistry* registry) override { | 637 service_manager::InterfaceRegistry* registry) override { |
638 registry->AddInterface(client_factory_.get()); | 638 registry->AddInterface(client_factory_.get()); |
639 return true; | 639 return true; |
640 } | 640 } |
641 | 641 |
642 void SetUp() override { | 642 void SetUp() override { |
643 client_factory_ = base::MakeUnique<WindowTreeClientFactory>(); | 643 client_factory_ = base::MakeUnique<WindowTreeClientFactory>(); |
644 | 644 |
645 WindowServerServiceTestBase::SetUp(); | 645 WindowServerServiceTestBase::SetUp(); |
646 | 646 |
647 mojom::WindowTreeHostFactoryPtr factory; | 647 mojom::WindowTreeHostFactoryPtr factory; |
(...skipping 1529 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2177 | 2177 |
2178 // TODO(sky): make sure coverage of what was | 2178 // TODO(sky): make sure coverage of what was |
2179 // WindowManagerTest.SecondEmbedRoot_InitService and | 2179 // WindowManagerTest.SecondEmbedRoot_InitService and |
2180 // WindowManagerTest.MultipleEmbedRootsBeforeWTHReady gets added to window | 2180 // WindowManagerTest.MultipleEmbedRootsBeforeWTHReady gets added to window |
2181 // manager | 2181 // manager |
2182 // tests. | 2182 // tests. |
2183 | 2183 |
2184 } // namespace test | 2184 } // namespace test |
2185 } // namespace ws | 2185 } // namespace ws |
2186 } // namespace ui | 2186 } // namespace ui |
OLD | NEW |