| 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 |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 201 { | 201 { |
| 202 connection_b->GetInterface(&service_b); | 202 connection_b->GetInterface(&service_b); |
| 203 base::RunLoop loop; | 203 base::RunLoop loop; |
| 204 service_b->GetInstance(base::Bind(&ReceiveOneString, &instance_b, &loop)); | 204 service_b->GetInstance(base::Bind(&ReceiveOneString, &instance_b, &loop)); |
| 205 loop.Run(); | 205 loop.Run(); |
| 206 } | 206 } |
| 207 | 207 |
| 208 EXPECT_NE(instance_a1, instance_b); | 208 EXPECT_NE(instance_a1, instance_b); |
| 209 } | 209 } |
| 210 | 210 |
| 211 // When both the unresolved and resolved instance names are their default | |
| 212 // values, the instance name from the unresolved name must be used. | |
| 213 // (The case where the instance names differ is covered by | |
| 214 // LifecycleTest.PackagedApp_CrashCrashesOtherProvidedApp). | |
| 215 TEST_F(ConnectTest, PreferUnresolvedDefaultInstanceName) { | |
| 216 // Connect to an app with no manifest-supplied instance name provided by a | |
| 217 // package, the instance name must be derived from the application instance | |
| 218 // name, not the package. | |
| 219 std::unique_ptr<Connection> connection = connector()->Connect(kTestAppName); | |
| 220 { | |
| 221 base::RunLoop loop; | |
| 222 connection->AddConnectionCompletedClosure(base::Bind(&QuitLoop, &loop)); | |
| 223 loop.Run(); | |
| 224 } | |
| 225 | |
| 226 std::string instance; | |
| 227 { | |
| 228 test::mojom::ConnectTestServicePtr service; | |
| 229 connection->GetInterface(&service); | |
| 230 base::RunLoop loop; | |
| 231 service->GetInstance(base::Bind(&ReceiveOneString, &instance, &loop)); | |
| 232 loop.Run(); | |
| 233 } | |
| 234 EXPECT_EQ(GetNamePath(kTestAppName), instance); | |
| 235 } | |
| 236 | |
| 237 // BlockedInterface should not be exposed to this application because it is not | 211 // BlockedInterface should not be exposed to this application because it is not |
| 238 // in our CapabilityFilter whitelist. | 212 // in our CapabilityFilter whitelist. |
| 239 TEST_F(ConnectTest, BlockedInterface) { | 213 TEST_F(ConnectTest, BlockedInterface) { |
| 240 std::unique_ptr<Connection> connection = connector()->Connect(kTestAppName); | 214 std::unique_ptr<Connection> connection = connector()->Connect(kTestAppName); |
| 241 base::RunLoop run_loop; | 215 base::RunLoop run_loop; |
| 242 test::mojom::BlockedInterfacePtr blocked; | 216 test::mojom::BlockedInterfacePtr blocked; |
| 243 connection->GetInterface(&blocked); | 217 connection->GetInterface(&blocked); |
| 244 blocked.set_connection_error_handler(base::Bind(&QuitLoop, &run_loop)); | 218 blocked.set_connection_error_handler(base::Bind(&QuitLoop, &run_loop)); |
| 245 std::string title = "unchanged"; | 219 std::string title = "unchanged"; |
| 246 blocked->GetTitleBlocked(base::Bind(&ReceiveOneString, &title, &run_loop)); | 220 blocked->GetTitleBlocked(base::Bind(&ReceiveOneString, &title, &run_loop)); |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 410 base::RunLoop loop; | 384 base::RunLoop loop; |
| 411 inherit_connection->AddConnectionCompletedClosure( | 385 inherit_connection->AddConnectionCompletedClosure( |
| 412 base::Bind(&QuitLoop, &loop)); | 386 base::Bind(&QuitLoop, &loop)); |
| 413 loop.Run(); | 387 loop.Run(); |
| 414 EXPECT_EQ(inherit_connection->GetRemoteIdentity().user_id(), | 388 EXPECT_EQ(inherit_connection->GetRemoteIdentity().user_id(), |
| 415 connection->GetRemoteIdentity().user_id()); | 389 connection->GetRemoteIdentity().user_id()); |
| 416 } | 390 } |
| 417 } | 391 } |
| 418 | 392 |
| 419 } // namespace service_manager | 393 } // namespace service_manager |
| OLD | NEW |