OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 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/c/ppb_core.h" |
| 6 #include "ppapi/proxy/interface_list.h" |
| 7 #include "ppapi/proxy/ppapi_proxy_test.h" |
| 8 |
| 9 namespace ppapi { |
| 10 namespace proxy { |
| 11 |
| 12 class InterfaceListTest : public PluginProxyTest { |
| 13 public: |
| 14 // Wrapper function so we can use the private InterfaceList::AddPPB. |
| 15 void AddPPB(InterfaceList* list, |
| 16 const char* iface_name, void* iface_addr, Permission perm) { |
| 17 list->AddPPB(iface_name, iface_addr, perm); |
| 18 } |
| 19 }; |
| 20 |
| 21 // Tests looking up a stable interface. |
| 22 TEST_F(InterfaceListTest, Stable) { |
| 23 InterfaceList list; |
| 24 ASSERT_TRUE(list.GetInterfaceForPPB(PPB_CORE_INTERFACE_1_0) != NULL); |
| 25 ASSERT_TRUE(list.GetInterfaceForPPB("FakeUnknownInterface") == NULL); |
| 26 } |
| 27 |
| 28 // Tests that dev channel restrictions work properly. |
| 29 TEST_F(InterfaceListTest, DevChannel) { |
| 30 InterfaceList list; |
| 31 // "Dev channel" interface. |
| 32 static const char* dev_channel_iface_name = "TestDevChannelInterface"; |
| 33 void* dev_channel_iface_addr = (void*)0xdeadbeef; |
| 34 // "Dev" interface |
| 35 static const char* dev_iface_name = "TestDevInterface"; |
| 36 void* dev_iface_addr = (void*)0xcafefade; |
| 37 |
| 38 AddPPB(&list, dev_channel_iface_name, dev_channel_iface_addr, |
| 39 PERMISSION_DEV_CHANNEL); |
| 40 AddPPB(&list, dev_iface_name, dev_iface_addr, PERMISSION_DEV); |
| 41 |
| 42 InterfaceList::SetProcessGlobalPermissions( |
| 43 PpapiPermissions(PERMISSION_NONE)); |
| 44 ASSERT_TRUE(list.GetInterfaceForPPB(dev_channel_iface_name) == NULL); |
| 45 ASSERT_TRUE(list.GetInterfaceForPPB(dev_iface_name) == NULL); |
| 46 |
| 47 InterfaceList::SetProcessGlobalPermissions( |
| 48 PpapiPermissions(PERMISSION_DEV_CHANNEL)); |
| 49 ASSERT_TRUE(list.GetInterfaceForPPB(dev_channel_iface_name) == |
| 50 dev_channel_iface_addr); |
| 51 ASSERT_TRUE(list.GetInterfaceForPPB(dev_iface_name) == NULL); |
| 52 |
| 53 InterfaceList::SetProcessGlobalPermissions( |
| 54 PpapiPermissions(PERMISSION_DEV)); |
| 55 ASSERT_TRUE(list.GetInterfaceForPPB(dev_channel_iface_name) == NULL); |
| 56 ASSERT_TRUE(list.GetInterfaceForPPB(dev_iface_name) == dev_iface_addr); |
| 57 |
| 58 InterfaceList::SetProcessGlobalPermissions( |
| 59 PpapiPermissions(PERMISSION_DEV | PERMISSION_DEV_CHANNEL)); |
| 60 ASSERT_TRUE(list.GetInterfaceForPPB(dev_channel_iface_name) == |
| 61 dev_channel_iface_addr); |
| 62 ASSERT_TRUE(list.GetInterfaceForPPB(dev_iface_name) == dev_iface_addr); |
| 63 } |
| 64 |
| 65 } // namespace proxy |
| 66 } // namespace ppapi |
OLD | NEW |