OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #include "ppapi/c/pp_errors.h" | 7 #include "ppapi/c/pp_errors.h" |
8 #include "ppapi/c/trusted/ppb_broker_trusted.h" | 8 #include "ppapi/c/trusted/ppb_broker_trusted.h" |
9 #include "ppapi/cpp/module.h" | 9 #include "ppapi/cpp/module.h" |
10 #include "ppapi/tests/testing_instance.h" | 10 #include "ppapi/tests/testing_instance.h" |
11 | 11 |
12 REGISTER_TEST_CASE(Broker); | 12 REGISTER_TEST_CASE(Broker); |
13 | 13 |
14 TestBroker::TestBroker(TestingInstance* instance) | 14 TestBroker::TestBroker(TestingInstance* instance) |
15 : TestCase(instance), | 15 : TestCase(instance), |
16 broker_interface_(NULL) { | 16 broker_interface_(NULL) { |
17 } | 17 } |
18 | 18 |
19 bool TestBroker::Init() { | 19 bool TestBroker::Init() { |
20 broker_interface_ = static_cast<PPB_BrokerTrusted const*>( | 20 broker_interface_ = static_cast<PPB_BrokerTrusted const*>( |
21 pp::Module::Get()->GetBrowserInterface(PPB_BROKER_TRUSTED_INTERFACE)); | 21 pp::Module::Get()->GetBrowserInterface(PPB_BROKER_TRUSTED_INTERFACE)); |
22 return !!broker_interface_; | 22 return !!broker_interface_; |
23 } | 23 } |
24 | 24 |
25 void TestBroker::RunTest() { | 25 void TestBroker::RunTests(const std::string& filter) { |
26 RUN_TEST(Create); | 26 RUN_TEST(Create, filter); |
27 } | 27 } |
28 | 28 |
29 std::string TestBroker::TestCreate() { | 29 std::string TestBroker::TestCreate() { |
30 // Very simplistic test to make sure we can create a broker interface. | 30 // Very simplistic test to make sure we can create a broker interface. |
31 PP_Resource broker = broker_interface_->CreateTrusted( | 31 PP_Resource broker = broker_interface_->CreateTrusted( |
32 instance_->pp_instance()); | 32 instance_->pp_instance()); |
33 ASSERT_TRUE(broker); | 33 ASSERT_TRUE(broker); |
34 | 34 |
35 ASSERT_FALSE(broker_interface_->IsBrokerTrusted(0)); | 35 ASSERT_FALSE(broker_interface_->IsBrokerTrusted(0)); |
36 ASSERT_TRUE(broker_interface_->IsBrokerTrusted(broker)); | 36 ASSERT_TRUE(broker_interface_->IsBrokerTrusted(broker)); |
37 | 37 |
38 // Test getting the handle for an invalid resource. | 38 // Test getting the handle for an invalid resource. |
39 int32_t handle; | 39 int32_t handle; |
40 ASSERT_TRUE(broker_interface_->GetHandle(0, &handle) == PP_ERROR_BADRESOURCE); | 40 ASSERT_TRUE(broker_interface_->GetHandle(0, &handle) == PP_ERROR_BADRESOURCE); |
41 | 41 |
42 // Connect hasn't been called so this should fail. | 42 // Connect hasn't been called so this should fail. |
43 ASSERT_TRUE(broker_interface_->GetHandle(broker, &handle) == PP_ERROR_FAILED); | 43 ASSERT_TRUE(broker_interface_->GetHandle(broker, &handle) == PP_ERROR_FAILED); |
44 | 44 |
45 PASS(); | 45 PASS(); |
46 } | 46 } |
OLD | NEW |