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 "components/mus/public/cpp/tests/window_server_shelltest_base.h" | 13 #include "components/mus/public/cpp/tests/window_server_shelltest_base.h" |
14 #include "components/mus/public/interfaces/window_tree.mojom.h" | 14 #include "components/mus/public/interfaces/window_tree.mojom.h" |
15 #include "components/mus/public/interfaces/window_tree_host.mojom.h" | 15 #include "components/mus/public/interfaces/window_tree_host.mojom.h" |
16 #include "components/mus/ws/ids.h" | 16 #include "components/mus/ws/ids.h" |
17 #include "components/mus/ws/test_change_tracker.h" | 17 #include "components/mus/ws/test_change_tracker.h" |
18 #include "mojo/converters/geometry/geometry_type_converters.h" | 18 #include "mojo/converters/geometry/geometry_type_converters.h" |
19 #include "mojo/public/cpp/bindings/associated_binding.h" | 19 #include "mojo/public/cpp/bindings/associated_binding.h" |
20 #include "services/shell/public/cpp/shell_test.h" | 20 #include "services/shell/public/cpp/shell_test.h" |
21 | 21 |
22 using mojo::Array; | 22 using mojo::Array; |
23 using mojo::Callback; | 23 using mojo::Callback; |
24 using mojo::Connection; | 24 using shell::Connection; |
25 using mojo::InterfaceRequest; | 25 using mojo::InterfaceRequest; |
26 using mojo::RectPtr; | 26 using mojo::RectPtr; |
27 using mojo::ShellClient; | 27 using shell::ShellClient; |
28 using mojo::String; | 28 using mojo::String; |
29 using mus::mojom::ErrorCode; | 29 using mus::mojom::ErrorCode; |
30 using mus::mojom::EventPtr; | 30 using mus::mojom::EventPtr; |
31 using mus::mojom::ViewportMetricsPtr; | 31 using mus::mojom::ViewportMetricsPtr; |
32 using mus::mojom::WindowDataPtr; | 32 using mus::mojom::WindowDataPtr; |
33 using mus::mojom::WindowTree; | 33 using mus::mojom::WindowTree; |
34 using mus::mojom::WindowTreeClient; | 34 using mus::mojom::WindowTreeClient; |
35 | 35 |
36 namespace mus { | 36 namespace mus { |
37 namespace ws { | 37 namespace ws { |
(...skipping 19 matching lines...) Expand all Loading... |
57 | 57 |
58 void EmbedCallbackImpl(base::RunLoop* run_loop, | 58 void EmbedCallbackImpl(base::RunLoop* run_loop, |
59 bool* result_cache, | 59 bool* result_cache, |
60 bool result) { | 60 bool result) { |
61 *result_cache = result; | 61 *result_cache = result; |
62 run_loop->Quit(); | 62 run_loop->Quit(); |
63 } | 63 } |
64 | 64 |
65 // ----------------------------------------------------------------------------- | 65 // ----------------------------------------------------------------------------- |
66 | 66 |
67 bool EmbedUrl(mojo::Connector* connector, | 67 bool EmbedUrl(shell::Connector* connector, |
68 WindowTree* tree, | 68 WindowTree* tree, |
69 const String& url, | 69 const String& url, |
70 Id root_id) { | 70 Id root_id) { |
71 bool result = false; | 71 bool result = false; |
72 base::RunLoop run_loop; | 72 base::RunLoop run_loop; |
73 { | 73 { |
74 mojom::WindowTreeClientPtr client; | 74 mojom::WindowTreeClientPtr client; |
75 connector->ConnectToInterface(url.get(), &client); | 75 connector->ConnectToInterface(url.get(), &client); |
76 tree->Embed(root_id, std::move(client), | 76 tree->Embed(root_id, std::move(client), |
77 base::Bind(&EmbedCallbackImpl, &run_loop, &result)); | 77 base::Bind(&EmbedCallbackImpl, &run_loop, &result)); |
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
437 window_manager_binding_; | 437 window_manager_binding_; |
438 mojom::WindowManagerClientAssociatedPtr window_manager_client_; | 438 mojom::WindowManagerClientAssociatedPtr window_manager_client_; |
439 | 439 |
440 DISALLOW_COPY_AND_ASSIGN(TestWindowTreeClientImpl); | 440 DISALLOW_COPY_AND_ASSIGN(TestWindowTreeClientImpl); |
441 }; | 441 }; |
442 | 442 |
443 // ----------------------------------------------------------------------------- | 443 // ----------------------------------------------------------------------------- |
444 | 444 |
445 // InterfaceFactory for vending TestWindowTreeClientImpls. | 445 // InterfaceFactory for vending TestWindowTreeClientImpls. |
446 class WindowTreeClientFactory | 446 class WindowTreeClientFactory |
447 : public mojo::InterfaceFactory<WindowTreeClient> { | 447 : public shell::InterfaceFactory<WindowTreeClient> { |
448 public: | 448 public: |
449 WindowTreeClientFactory() {} | 449 WindowTreeClientFactory() {} |
450 ~WindowTreeClientFactory() override {} | 450 ~WindowTreeClientFactory() override {} |
451 | 451 |
452 // Runs a nested MessageLoop until a new instance has been created. | 452 // Runs a nested MessageLoop until a new instance has been created. |
453 scoped_ptr<TestWindowTreeClientImpl> WaitForInstance() { | 453 scoped_ptr<TestWindowTreeClientImpl> WaitForInstance() { |
454 if (!client_impl_.get()) { | 454 if (!client_impl_.get()) { |
455 DCHECK(!run_loop_); | 455 DCHECK(!run_loop_); |
456 run_loop_.reset(new base::RunLoop); | 456 run_loop_.reset(new base::RunLoop); |
457 run_loop_->Run(); | 457 run_loop_->Run(); |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
566 client->WaitForOnEmbed(); | 566 client->WaitForOnEmbed(); |
567 | 567 |
568 EXPECT_EQ("OnEmbed", | 568 EXPECT_EQ("OnEmbed", |
569 SingleChangeToDescription(*client->tracker()->changes())); | 569 SingleChangeToDescription(*client->tracker()->changes())); |
570 if (connection_id) | 570 if (connection_id) |
571 *connection_id = (*client->tracker()->changes())[0].connection_id; | 571 *connection_id = (*client->tracker()->changes())[0].connection_id; |
572 return client; | 572 return client; |
573 } | 573 } |
574 | 574 |
575 // WindowServerShellTestBase: | 575 // WindowServerShellTestBase: |
576 bool AcceptConnection(mojo::Connection* connection) override { | 576 bool AcceptConnection(shell::Connection* connection) override { |
577 connection->AddInterface(client_factory_.get()); | 577 connection->AddInterface(client_factory_.get()); |
578 return true; | 578 return true; |
579 } | 579 } |
580 | 580 |
581 void SetUp() override { | 581 void SetUp() override { |
582 client_factory_.reset(new WindowTreeClientFactory()); | 582 client_factory_.reset(new WindowTreeClientFactory()); |
583 | 583 |
584 WindowServerShellTestBase::SetUp(); | 584 WindowServerShellTestBase::SetUp(); |
585 | 585 |
586 mojom::WindowTreeHostFactoryPtr factory; | 586 mojom::WindowTreeHostFactoryPtr factory; |
(...skipping 1446 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 mus | 2042 } // namespace mus |
OLD | NEW |