OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "ppapi/tests/test_broker.h" | 5 #include "ppapi/tests/test_broker.h" |
6 | 6 |
7 #if defined(_MSC_VER) | 7 #if defined(_MSC_VER) |
8 #define OS_WIN 1 | 8 #define OS_WIN 1 |
9 #include <windows.h> | 9 #include <windows.h> |
10 #else | 10 #else |
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
215 RUN_TEST_FORCEASYNC_AND_NOT(ConnectFailure, filter); | 215 RUN_TEST_FORCEASYNC_AND_NOT(ConnectFailure, filter); |
216 RUN_TEST_FORCEASYNC_AND_NOT(ConnectAndPipe, filter); | 216 RUN_TEST_FORCEASYNC_AND_NOT(ConnectAndPipe, filter); |
217 | 217 |
218 // The following tests require special setup, so only run them if they're | 218 // The following tests require special setup, so only run them if they're |
219 // explicitly specified by the filter. | 219 // explicitly specified by the filter. |
220 if (filter.empty()) | 220 if (filter.empty()) |
221 return; | 221 return; |
222 | 222 |
223 RUN_TEST(ConnectPermissionDenied, filter); | 223 RUN_TEST(ConnectPermissionDenied, filter); |
224 RUN_TEST(ConnectPermissionGranted, filter); | 224 RUN_TEST(ConnectPermissionGranted, filter); |
| 225 RUN_TEST(IsAllowedPermissionDenied, filter); |
| 226 RUN_TEST(IsAllowedPermissionGranted, filter); |
225 } | 227 } |
226 | 228 |
227 std::string TestBroker::TestCreate() { | 229 std::string TestBroker::TestCreate() { |
228 // Very simplistic test to make sure we can create a broker interface. | 230 // Very simplistic test to make sure we can create a broker interface. |
| 231 // TODO(raymes): All of the resources created in this file are leaked. Write |
| 232 // a C++ wrapper for PPB_Broker_Trusted to avoid these leaks. |
229 PP_Resource broker = broker_interface_->CreateTrusted( | 233 PP_Resource broker = broker_interface_->CreateTrusted( |
230 instance_->pp_instance()); | 234 instance_->pp_instance()); |
231 ASSERT_TRUE(broker); | 235 ASSERT_TRUE(broker); |
232 | 236 |
233 ASSERT_FALSE(broker_interface_->IsBrokerTrusted(0)); | 237 ASSERT_FALSE(broker_interface_->IsBrokerTrusted(0)); |
234 ASSERT_TRUE(broker_interface_->IsBrokerTrusted(broker)); | 238 ASSERT_TRUE(broker_interface_->IsBrokerTrusted(broker)); |
235 | 239 |
236 PASS(); | 240 PASS(); |
237 } | 241 } |
238 | 242 |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
310 | 314 |
311 TestCompletionCallback callback(instance_->pp_instance(), callback_type()); | 315 TestCompletionCallback callback(instance_->pp_instance(), callback_type()); |
312 callback.WaitForResult(broker_interface_->Connect(broker, | 316 callback.WaitForResult(broker_interface_->Connect(broker, |
313 callback.GetCallback().pp_completion_callback())); | 317 callback.GetCallback().pp_completion_callback())); |
314 CHECK_CALLBACK_BEHAVIOR(callback); | 318 CHECK_CALLBACK_BEHAVIOR(callback); |
315 ASSERT_EQ(PP_OK, callback.result()); | 319 ASSERT_EQ(PP_OK, callback.result()); |
316 | 320 |
317 PASS(); | 321 PASS(); |
318 } | 322 } |
319 | 323 |
| 324 std::string TestBroker::TestIsAllowedPermissionDenied() { |
| 325 PP_Resource broker = broker_interface_->CreateTrusted( |
| 326 instance_->pp_instance()); |
| 327 ASSERT_TRUE(broker); |
| 328 ASSERT_EQ(PP_FALSE, broker_interface_->IsAllowed(broker)); |
| 329 |
| 330 PASS(); |
| 331 } |
| 332 |
| 333 std::string TestBroker::TestIsAllowedPermissionGranted() { |
| 334 PP_Resource broker = broker_interface_->CreateTrusted( |
| 335 instance_->pp_instance()); |
| 336 ASSERT_TRUE(broker); |
| 337 ASSERT_EQ(PP_TRUE, broker_interface_->IsAllowed(broker)); |
| 338 |
| 339 PASS(); |
| 340 } |
OLD | NEW |