1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "ppapi/tests/test_platform_verification_private.h"
7 #include "ppapi/cpp/instance.h"
8 #include "ppapi/cpp/module.h"
9 #include "ppapi/cpp/private/platform_verification.h"
10 #include "ppapi/cpp/var.h"
11 #include "ppapi/cpp/var_array_buffer.h"
12 #include "ppapi/tests/test_utils.h"
13 #include "ppapi/tests/testing_instance.h"
15 REGISTER_TEST_CASE(PlatformVerificationPrivate
);
17 TestPlatformVerificationPrivate::TestPlatformVerificationPrivate(
18 TestingInstance
* instance
)
19 : TestCase(instance
) {}
21 void TestPlatformVerificationPrivate::RunTests(const std::string
& filter
) {
22 RUN_CALLBACK_TEST(TestPlatformVerificationPrivate
, ChallengePlatform
, filter
);
25 std::string
TestPlatformVerificationPrivate::TestChallengePlatform() {
26 pp::PlatformVerification
platform_verification_api(instance_
);
28 pp::VarArrayBuffer
challenge_array(256);
29 uint8_t* var_data
= static_cast<uint8_t*>(challenge_array
.Map());
30 for (uint32_t i
= 0; i
< challenge_array
.ByteLength(); ++i
)
33 TestCompletionCallback
callback(instance_
->pp_instance(), callback_type());
34 std::string
service_id_str("fake.service.id");
35 pp::Var signed_data
, signed_data_signature
, platform_key_certificate
;
36 callback
.WaitForResult(platform_verification_api
.ChallengePlatform(
37 pp::Var(service_id_str
), challenge_array
, &signed_data
,
38 &signed_data_signature
, &platform_key_certificate
,
39 callback
.GetCallback()));
40 CHECK_CALLBACK_BEHAVIOR(callback
);
41 ASSERT_EQ(PP_ERROR_FAILED
, callback
.result());