| 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 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 242 run_loop.Run(); | 242 run_loop.Run(); |
| 243 EXPECT_EQ("A", a_name); | 243 EXPECT_EQ("A", a_name); |
| 244 EXPECT_FALSE(connection->IsPending()); | 244 EXPECT_FALSE(connection->IsPending()); |
| 245 EXPECT_NE(mojom::kInvalidInstanceID, connection->GetRemoteInstanceID()); | 245 EXPECT_NE(mojom::kInvalidInstanceID, connection->GetRemoteInstanceID()); |
| 246 EXPECT_EQ(connection->GetRemoteIdentity().name(), kTestAppAName); | 246 EXPECT_EQ(connection->GetRemoteIdentity().name(), kTestAppAName); |
| 247 } | 247 } |
| 248 | 248 |
| 249 // Ask the target application to attempt to connect to a third application | 249 // Ask the target application to attempt to connect to a third application |
| 250 // provided by a package whose id is permitted by the primary target's | 250 // provided by a package whose id is permitted by the primary target's |
| 251 // CapabilityFilter but whose package is not. The connection should be | 251 // CapabilityFilter but whose package is not. The connection should be |
| 252 // blocked and the returned title should be "uninitialized". | 252 // allowed regardless of the target's CapabilityFilter with respect to the |
| 253 // package. |
| 253 TEST_F(ConnectTest, BlockedPackage) { | 254 TEST_F(ConnectTest, BlockedPackage) { |
| 254 scoped_ptr<Connection> connection = connector()->Connect(kTestAppName); | 255 scoped_ptr<Connection> connection = connector()->Connect(kTestAppName); |
| 255 test::mojom::StandaloneAppPtr standalone_app; | 256 test::mojom::StandaloneAppPtr standalone_app; |
| 256 connection->GetInterface(&standalone_app); | 257 connection->GetInterface(&standalone_app); |
| 257 base::RunLoop run_loop; | 258 base::RunLoop run_loop; |
| 258 std::string title; | 259 std::string title; |
| 259 standalone_app->ConnectToAllowedAppInBlockedPackage( | 260 standalone_app->ConnectToAllowedAppInBlockedPackage( |
| 260 base::Bind(&ReceiveOneString, &title, &run_loop)); | 261 base::Bind(&ReceiveOneString, &title, &run_loop)); |
| 261 run_loop.Run(); | 262 run_loop.Run(); |
| 262 EXPECT_EQ("uninitialized", title); | 263 EXPECT_EQ("A", title); |
| 263 } | 264 } |
| 264 | 265 |
| 265 // BlockedInterface should not be exposed to this application because it is not | 266 // BlockedInterface should not be exposed to this application because it is not |
| 266 // in our CapabilityFilter whitelist. | 267 // in our CapabilityFilter whitelist. |
| 267 TEST_F(ConnectTest, PackagedApp_BlockedInterface) { | 268 TEST_F(ConnectTest, PackagedApp_BlockedInterface) { |
| 268 scoped_ptr<Connection> connection = connector()->Connect(kTestAppAName); | 269 scoped_ptr<Connection> connection = connector()->Connect(kTestAppAName); |
| 269 base::RunLoop run_loop; | 270 base::RunLoop run_loop; |
| 270 test::mojom::BlockedInterfacePtr blocked; | 271 test::mojom::BlockedInterfacePtr blocked; |
| 271 connection->GetInterface(&blocked); | 272 connection->GetInterface(&blocked); |
| 272 blocked.set_connection_error_handler(base::Bind(&QuitLoop, &run_loop)); | 273 blocked.set_connection_error_handler(base::Bind(&QuitLoop, &run_loop)); |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 442 CompareConnectionState( | 443 CompareConnectionState( |
| 443 kTestAppAName, test_name(), test_userid(), test_instance_id(), | 444 kTestAppAName, test_name(), test_userid(), test_instance_id(), |
| 444 kTestAppAName, connection->GetRemoteIdentity().user_id(), remote_id); | 445 kTestAppAName, connection->GetRemoteIdentity().user_id(), remote_id); |
| 445 } | 446 } |
| 446 | 447 |
| 447 } | 448 } |
| 448 } | 449 } |
| 449 | 450 |
| 450 } // namespace shell | 451 } // namespace shell |
| 451 } // namespace mojo | 452 } // namespace mojo |
| OLD | NEW |