| 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 <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 | 31 |
| 32 using PackageApptest = mojo::test::ApplicationTestBase; | 32 using PackageApptest = mojo::test::ApplicationTestBase; |
| 33 | 33 |
| 34 TEST_F(PackageApptest, Basic) { | 34 TEST_F(PackageApptest, Basic) { |
| 35 std::set<uint32_t> ids; | 35 std::set<uint32_t> ids; |
| 36 { | 36 { |
| 37 // We need to do this to force the shell to read the test app's manifest and | 37 // We need to do this to force the shell to read the test app's manifest and |
| 38 // register aliases. | 38 // register aliases. |
| 39 test::mojom::PackageTestServicePtr root_service; | 39 test::mojom::PackageTestServicePtr root_service; |
| 40 scoped_ptr<Connection> connection = | 40 scoped_ptr<Connection> connection = |
| 41 shell()->Connect("mojo:package_test_package"); | 41 connector()->Connect("mojo:package_test_package"); |
| 42 connection->GetInterface(&root_service); | 42 connection->GetInterface(&root_service); |
| 43 base::RunLoop run_loop; | 43 base::RunLoop run_loop; |
| 44 std::string root_name; | 44 std::string root_name; |
| 45 root_service->GetName(base::Bind(&ReceiveName, &root_name, &run_loop)); | 45 root_service->GetName(base::Bind(&ReceiveName, &root_name, &run_loop)); |
| 46 run_loop.Run(); | 46 run_loop.Run(); |
| 47 uint32_t id = mojom::Connector::kInvalidApplicationID; | 47 uint32_t id = mojom::Connector::kInvalidApplicationID; |
| 48 EXPECT_TRUE(connection->GetRemoteApplicationID(&id)); | 48 EXPECT_TRUE(connection->GetRemoteApplicationID(&id)); |
| 49 ids.insert(id); | 49 ids.insert(id); |
| 50 } | 50 } |
| 51 | 51 |
| 52 { | 52 { |
| 53 // Now subsequent connects to applications provided by the root app will be | 53 // Now subsequent connects to applications provided by the root app will be |
| 54 // resolved correctly. | 54 // resolved correctly. |
| 55 test::mojom::PackageTestServicePtr service_a; | 55 test::mojom::PackageTestServicePtr service_a; |
| 56 scoped_ptr<Connection> connection = shell()->Connect("mojo:package_test_a"); | 56 scoped_ptr<Connection> connection = |
| 57 connector()->Connect("mojo:package_test_a"); |
| 57 connection->GetInterface(&service_a); | 58 connection->GetInterface(&service_a); |
| 58 base::RunLoop run_loop; | 59 base::RunLoop run_loop; |
| 59 std::string a_name; | 60 std::string a_name; |
| 60 service_a->GetName(base::Bind(&ReceiveName, &a_name, &run_loop)); | 61 service_a->GetName(base::Bind(&ReceiveName, &a_name, &run_loop)); |
| 61 run_loop.Run(); | 62 run_loop.Run(); |
| 62 EXPECT_EQ("A", a_name); | 63 EXPECT_EQ("A", a_name); |
| 63 uint32_t id = mojom::Connector::kInvalidApplicationID; | 64 uint32_t id = mojom::Connector::kInvalidApplicationID; |
| 64 EXPECT_TRUE(connection->GetRemoteApplicationID(&id)); | 65 EXPECT_TRUE(connection->GetRemoteApplicationID(&id)); |
| 65 ids.insert(id); | 66 ids.insert(id); |
| 66 } | 67 } |
| 67 | 68 |
| 68 { | 69 { |
| 69 test::mojom::PackageTestServicePtr service_b; | 70 test::mojom::PackageTestServicePtr service_b; |
| 70 scoped_ptr<Connection> connection = shell()->Connect("mojo:package_test_b"); | 71 scoped_ptr<Connection> connection = |
| 72 connector()->Connect("mojo:package_test_b"); |
| 71 connection->GetInterface(&service_b); | 73 connection->GetInterface(&service_b); |
| 72 base::RunLoop run_loop; | 74 base::RunLoop run_loop; |
| 73 std::string b_name; | 75 std::string b_name; |
| 74 service_b->GetName(base::Bind(&ReceiveName, &b_name, &run_loop)); | 76 service_b->GetName(base::Bind(&ReceiveName, &b_name, &run_loop)); |
| 75 run_loop.Run(); | 77 run_loop.Run(); |
| 76 EXPECT_EQ("B", b_name); | 78 EXPECT_EQ("B", b_name); |
| 77 uint32_t id = mojom::Connector::kInvalidApplicationID; | 79 uint32_t id = mojom::Connector::kInvalidApplicationID; |
| 78 EXPECT_TRUE(connection->GetRemoteApplicationID(&id)); | 80 EXPECT_TRUE(connection->GetRemoteApplicationID(&id)); |
| 79 ids.insert(id); | 81 ids.insert(id); |
| 80 } | 82 } |
| 81 } | 83 } |
| 82 | 84 |
| 83 } // namespace shell | 85 } // namespace shell |
| 84 } // namespace mojo | 86 } // namespace mojo |
| OLD | NEW |