| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2011 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_query_policy.h" | |
| 6 | |
| 7 #include "ppapi/c/dev/ppb_query_policy_dev.h" | |
| 8 #include "ppapi/c/dev/ppp_policy_update_dev.h" | |
| 9 #include "ppapi/cpp/instance.h" | |
| 10 #include "ppapi/cpp/module.h" | |
| 11 #include "ppapi/cpp/var.h" | |
| 12 #include "ppapi/tests/test_utils.h" | |
| 13 #include "ppapi/tests/testing_instance.h" | |
| 14 | |
| 15 REGISTER_TEST_CASE(QueryPolicy); | |
| 16 | |
| 17 namespace { | |
| 18 | |
| 19 // Since this is a unittest, we don't care about a global string. | |
| 20 std::string g_received_policy; | |
| 21 | |
| 22 void PolicyUpdated(PP_Instance instance, PP_Var pp_policy_json) { | |
| 23 g_received_policy = pp::Var(pp::Var::DontManage(), pp_policy_json).AsString(); | |
| 24 GetTestingInterface()->QuitMessageLoop(instance); | |
| 25 } | |
| 26 | |
| 27 static PPP_PolicyUpdate_Dev policy_updated_interface = { | |
| 28 &PolicyUpdated, | |
| 29 }; | |
| 30 | |
| 31 } // namespace | |
| 32 | |
| 33 bool TestQueryPolicy::Init() { | |
| 34 query_policy_interface_ = static_cast<PPB_QueryPolicy_Dev const*>( | |
| 35 pp::Module::Get()->GetBrowserInterface(PPB_QUERYPOLICY_DEV_INTERFACE)); | |
| 36 pp::Module::Get()->AddPluginInterface(PPP_POLICYUPDATE_DEV_INTERFACE, | |
| 37 &policy_updated_interface); | |
| 38 | |
| 39 return query_policy_interface_ && InitTestingInterface(); | |
| 40 } | |
| 41 | |
| 42 void TestQueryPolicy::RunTest() { | |
| 43 RUN_TEST(SubscribeToPolicyUpdates); | |
| 44 } | |
| 45 | |
| 46 std::string TestQueryPolicy::TestSubscribeToPolicyUpdates() { | |
| 47 query_policy_interface_->SubscribeToPolicyUpdates( | |
| 48 instance_->pp_instance()); | |
| 49 | |
| 50 // Wait for a response on PPP_PolicyUpdate_Dev. | |
| 51 GetTestingInterface()->RunMessageLoop(instance_->pp_instance()); | |
| 52 | |
| 53 ASSERT_FALSE(g_received_policy.empty()); | |
| 54 | |
| 55 PASS(); | |
| 56 } | |
| OLD | NEW |