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. 4 5 #include "ppapi/tests/test_platform_verification_private.h" 6 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/tests/test_utils.h" 12 #include "ppapi/tests/testing_instance.h" 13 14 REGISTER_TEST_CASE(PlatformVerificationPrivate); 15 16 TestPlatformVerificationPrivate::TestPlatformVerificationPrivate( 17 TestingInstance* instance) 18 : TestCase(instance) {} 19 20 void TestPlatformVerificationPrivate::RunTests(const std::string& filter) { 21 RUN_CALLBACK_TEST(TestPlatformVerificationPrivate, ChallengePlatform, filter); 22 } 23 24 std::string TestPlatformVerificationPrivate::TestChallengePlatform() { 25 pp::PlatformVerification platform_verification_api(instance_); 26 27 pp::VarArrayBuffer challenge_array(256); 28 uint8_t* var_data = static_cast<uint8_t*>(challenge_array.Map()); 29 for (uint32_t i = 0; i < challenge_array.ByteLength(); ++i) 30 var_data[i] = i; 31 32 TestCompletionCallback callback(instance_->pp_instance(), callback_type()); 33 std::string service_id_str("fake.service.id"); 34 pp::Var signed_data, signed_data_signature, platform_key_certificate; 35 callback.WaitForResult(platform_verification_api.ChallengePlatform( 36 pp::Var(service_id_str), challenge_array, &signed_data, 37 &signed_data_signature, &platform_key_certificate, 38 callback.GetCallback())); 39 CHECK_CALLBACK_BEHAVIOR(callback); 40 ASSERT_EQ(callback.result(), PP_ERROR_FAILED); 41 PASS(); 42 } 43