OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 <memory> | 8 #include <memory> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
11 #include "base/bind.h" | 11 #include "base/bind.h" |
12 #include "base/guid.h" | 12 #include "base/guid.h" |
13 #include "base/macros.h" | 13 #include "base/macros.h" |
14 #include "base/run_loop.h" | 14 #include "base/run_loop.h" |
15 #include "base/test/test_suite.h" | 15 #include "base/test/test_suite.h" |
16 #include "mojo/public/cpp/bindings/binding_set.h" | 16 #include "mojo/public/cpp/bindings/binding_set.h" |
17 #include "services/shell/public/cpp/names.h" | 17 #include "services/shell/public/cpp/names.h" |
18 #include "services/shell/public/cpp/shell_test.h" | 18 #include "services/shell/public/cpp/service_test.h" |
19 #include "services/shell/public/interfaces/service_manager.mojom.h" | 19 #include "services/shell/public/interfaces/service_manager.mojom.h" |
20 #include "services/shell/tests/connect/connect_test.mojom.h" | 20 #include "services/shell/tests/connect/connect_test.mojom.h" |
21 | 21 |
22 // Tests that multiple applications can be packaged in a single Mojo application | 22 // Tests that multiple applications can be packaged in a single Mojo application |
23 // implementing ServiceFactory; that these applications can be specified by | 23 // implementing ServiceFactory; that these applications can be specified by |
24 // the package's manifest and are thus registered with the PackageManager. | 24 // the package's manifest and are thus registered with the PackageManager. |
25 | 25 |
26 namespace shell { | 26 namespace shell { |
27 | 27 |
28 namespace { | 28 namespace { |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 *out_target = in_identity.To<Identity>(); | 61 *out_target = in_identity.To<Identity>(); |
62 loop->Quit(); | 62 loop->Quit(); |
63 } | 63 } |
64 | 64 |
65 void QuitLoop(base::RunLoop* loop) { | 65 void QuitLoop(base::RunLoop* loop) { |
66 loop->Quit(); | 66 loop->Quit(); |
67 } | 67 } |
68 | 68 |
69 } // namespace | 69 } // namespace |
70 | 70 |
71 class ConnectTest : public test::ShellTest, | 71 class ConnectTest : public test::ServiceTest, |
72 public InterfaceFactory<test::mojom::ExposedInterface>, | 72 public InterfaceFactory<test::mojom::ExposedInterface>, |
73 public test::mojom::ExposedInterface { | 73 public test::mojom::ExposedInterface { |
74 public: | 74 public: |
75 ConnectTest() : ShellTest("mojo:connect_unittests") {} | 75 ConnectTest() : ServiceTest("mojo:connect_unittests") {} |
76 ~ConnectTest() override {} | 76 ~ConnectTest() override {} |
77 | 77 |
78 protected: | 78 protected: |
79 std::unique_ptr<Connection> ConnectTo(Connector::ConnectParams* params) { | 79 std::unique_ptr<Connection> ConnectTo(Connector::ConnectParams* params) { |
80 std::unique_ptr<Connection> connection = connector()->Connect(params); | 80 std::unique_ptr<Connection> connection = connector()->Connect(params); |
81 base::RunLoop loop; | 81 base::RunLoop loop; |
82 connection->AddConnectionCompletedClosure(base::Bind(&QuitLoop, &loop)); | 82 connection->AddConnectionCompletedClosure(base::Bind(&QuitLoop, &loop)); |
83 loop.Run(); | 83 loop.Run(); |
84 return connection; | 84 return connection; |
85 } | 85 } |
(...skipping 15 matching lines...) Expand all Loading... |
101 connection_state_->connection_remote_name); | 101 connection_state_->connection_remote_name); |
102 EXPECT_EQ(connection_remote_userid, | 102 EXPECT_EQ(connection_remote_userid, |
103 connection_state_->connection_remote_userid); | 103 connection_state_->connection_remote_userid); |
104 EXPECT_EQ(connection_remote_id, connection_state_->connection_remote_id); | 104 EXPECT_EQ(connection_remote_id, connection_state_->connection_remote_id); |
105 EXPECT_EQ(initialize_local_name, connection_state_->initialize_local_name); | 105 EXPECT_EQ(initialize_local_name, connection_state_->initialize_local_name); |
106 EXPECT_EQ(initialize_id, connection_state_->initialize_id); | 106 EXPECT_EQ(initialize_id, connection_state_->initialize_id); |
107 EXPECT_EQ(initialize_userid, connection_state_->initialize_userid); | 107 EXPECT_EQ(initialize_userid, connection_state_->initialize_userid); |
108 } | 108 } |
109 | 109 |
110 private: | 110 private: |
111 // test::ShellTest: | 111 // test::ServiceTest: |
112 void SetUp() override { | 112 void SetUp() override { |
113 test::ShellTest::SetUp(); | 113 test::ServiceTest::SetUp(); |
114 // We need to connect to the package first to force the shell to read the | 114 // We need to connect to the package first to force the shell to read the |
115 // package app's manifest and register aliases for the applications it | 115 // package app's manifest and register aliases for the applications it |
116 // provides. | 116 // provides. |
117 test::mojom::ConnectTestServicePtr root_service; | 117 test::mojom::ConnectTestServicePtr root_service; |
118 std::unique_ptr<Connection> connection = | 118 std::unique_ptr<Connection> connection = |
119 connector()->Connect(kTestPackageName); | 119 connector()->Connect(kTestPackageName); |
120 connection->GetInterface(&root_service); | 120 connection->GetInterface(&root_service); |
121 base::RunLoop run_loop; | 121 base::RunLoop run_loop; |
122 std::string root_name; | 122 std::string root_name; |
123 root_service->GetTitle( | 123 root_service->GetTitle( |
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
463 run_loop.Run(); | 463 run_loop.Run(); |
464 CompareConnectionState( | 464 CompareConnectionState( |
465 kTestAppAName, test_name(), test_userid(), test_instance_id(), | 465 kTestAppAName, test_name(), test_userid(), test_instance_id(), |
466 kTestAppAName, connection->GetRemoteIdentity().user_id(), remote_id); | 466 kTestAppAName, connection->GetRemoteIdentity().user_id(), remote_id); |
467 } | 467 } |
468 | 468 |
469 } | 469 } |
470 } | 470 } |
471 | 471 |
472 } // namespace shell | 472 } // namespace shell |
OLD | NEW |