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