Home | History | Annotate | Download | only in tests
      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_output_protection_private.h"
      6 
      7 #include "ppapi/tests/testing_instance.h"
      8 
      9 REGISTER_TEST_CASE(OutputProtectionPrivate);
     10 
     11 TestOutputProtectionPrivate::TestOutputProtectionPrivate(
     12     TestingInstance* instance)
     13     : TestCase(instance) {
     14 }
     15 
     16 bool TestOutputProtectionPrivate::Init() {
     17   output_protection_interface_ =
     18       static_cast<const PPB_OutputProtection_Private*>(
     19           pp::Module::Get()->GetBrowserInterface(
     20               PPB_OUTPUTPROTECTION_PRIVATE_INTERFACE_0_1));
     21   return output_protection_interface_ && CheckTestingInterface();
     22 }
     23 
     24 void TestOutputProtectionPrivate::RunTests(const std::string& filter) {
     25   RUN_TEST(QueryStatus, filter);
     26   RUN_TEST(EnableProtection, filter);
     27 }
     28 
     29 std::string TestOutputProtectionPrivate::TestQueryStatus() {
     30   TestCompletionCallback callback(instance_->pp_instance(), callback_type());
     31 
     32   PP_Resource output_protection_resource = output_protection_interface_->
     33       Create(instance_->pp_instance());
     34   uint32_t link_mask;
     35   uint32_t protection_mask;
     36   callback.WaitForResult(
     37       output_protection_interface_->QueryStatus(
     38           output_protection_resource,
     39           &link_mask,
     40           &protection_mask,
     41           callback.GetCallback().pp_completion_callback()));
     42   CHECK_CALLBACK_BEHAVIOR(callback);
     43 
     44   PASS();
     45 }
     46 
     47 std::string TestOutputProtectionPrivate::TestEnableProtection() {
     48   TestCompletionCallback callback(instance_->pp_instance(), callback_type());
     49 
     50   PP_Resource output_protection_resource = output_protection_interface_->
     51       Create(instance_->pp_instance());
     52   callback.WaitForResult(
     53       output_protection_interface_->EnableProtection(
     54           output_protection_resource,
     55           PP_OUTPUT_PROTECTION_METHOD_PRIVATE_NONE,
     56           callback.GetCallback().pp_completion_callback()));
     57   CHECK_CALLBACK_BEHAVIOR(callback);
     58 
     59   PASS();
     60 }
     61