OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 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_platform_verification_private.h" | 5 #include "ppapi/tests/test_platform_verification_private.h" |
6 | 6 |
7 #include "ppapi/cpp/instance.h" | 7 #include "ppapi/cpp/instance.h" |
8 #include "ppapi/cpp/module.h" | 8 #include "ppapi/cpp/module.h" |
9 #include "ppapi/cpp/private/platform_verification.h" | 9 #include "ppapi/cpp/private/platform_verification.h" |
10 #include "ppapi/cpp/var.h" | 10 #include "ppapi/cpp/var.h" |
11 #include "ppapi/tests/test_utils.h" | 11 #include "ppapi/tests/test_utils.h" |
12 #include "ppapi/tests/testing_instance.h" | 12 #include "ppapi/tests/testing_instance.h" |
13 | 13 |
14 REGISTER_TEST_CASE(PlatformVerificationPrivate); | 14 REGISTER_TEST_CASE(PlatformVerificationPrivate); |
15 | 15 |
16 TestPlatformVerificationPrivate::TestPlatformVerificationPrivate( | 16 TestPlatformVerificationPrivate::TestPlatformVerificationPrivate( |
17 TestingInstance* instance) | 17 TestingInstance* instance) |
18 : TestCase(instance) {} | 18 : TestCase(instance) {} |
19 | 19 |
20 void TestPlatformVerificationPrivate::RunTests(const std::string& filter) { | 20 void TestPlatformVerificationPrivate::RunTests(const std::string& filter) { |
21 RUN_CALLBACK_TEST( | |
22 TestPlatformVerificationPrivate, CanChallengePlatform, filter); | |
23 RUN_CALLBACK_TEST(TestPlatformVerificationPrivate, ChallengePlatform, filter); | 21 RUN_CALLBACK_TEST(TestPlatformVerificationPrivate, ChallengePlatform, filter); |
24 } | 22 } |
25 | 23 |
26 std::string TestPlatformVerificationPrivate::TestCanChallengePlatform() { | |
27 TestCompletionCallbackWithOutput<bool> callback( | |
28 instance_->pp_instance(), callback_type()); | |
29 | |
30 pp::PlatformVerification platform_verification_api(instance_); | |
31 callback.WaitForResult(platform_verification_api.CanChallengePlatform( | |
32 callback.GetCallback())); | |
33 CHECK_CALLBACK_BEHAVIOR(callback); | |
34 | |
35 // Doesn't work on all platforms, so just ensure the function runs. | |
36 ASSERT_EQ(callback.result(), PP_OK); | |
37 PASS(); | |
38 } | |
39 | |
40 std::string TestPlatformVerificationPrivate::TestChallengePlatform() { | 24 std::string TestPlatformVerificationPrivate::TestChallengePlatform() { |
41 pp::PlatformVerification platform_verification_api(instance_); | 25 pp::PlatformVerification platform_verification_api(instance_); |
42 | 26 |
43 pp::VarArrayBuffer challenge_array(256); | 27 pp::VarArrayBuffer challenge_array(256); |
44 uint8_t* var_data = static_cast<uint8_t*>(challenge_array.Map()); | 28 uint8_t* var_data = static_cast<uint8_t*>(challenge_array.Map()); |
45 for (uint32_t i = 0; i < challenge_array.ByteLength(); ++i) | 29 for (uint32_t i = 0; i < challenge_array.ByteLength(); ++i) |
46 var_data[i] = i; | 30 var_data[i] = i; |
47 | 31 |
48 TestCompletionCallback callback(instance_->pp_instance(), callback_type()); | 32 TestCompletionCallback callback(instance_->pp_instance(), callback_type()); |
49 std::string service_id_str("fake.service.id"); | 33 std::string service_id_str("fake.service.id"); |
50 pp::Var signed_data, signed_data_signature, platform_key_certificate; | 34 pp::Var signed_data, signed_data_signature, platform_key_certificate; |
51 callback.WaitForResult(platform_verification_api.ChallengePlatform( | 35 callback.WaitForResult(platform_verification_api.ChallengePlatform( |
52 pp::Var(service_id_str), challenge_array, &signed_data, | 36 pp::Var(service_id_str), challenge_array, &signed_data, |
53 &signed_data_signature, &platform_key_certificate, | 37 &signed_data_signature, &platform_key_certificate, |
54 callback.GetCallback())); | 38 callback.GetCallback())); |
55 CHECK_CALLBACK_BEHAVIOR(callback); | 39 CHECK_CALLBACK_BEHAVIOR(callback); |
56 ASSERT_EQ(callback.result(), PP_ERROR_FAILED); | 40 ASSERT_EQ(callback.result(), PP_ERROR_FAILED); |
57 PASS(); | 41 PASS(); |
58 } | 42 } |
OLD | NEW |