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 bool requires_dev_channel) { |
| 18 list->AddPPB(iface_name, iface_addr, perm, requires_dev_channel); |
| 19 } |
| 20 }; |
| 21 |
| 22 // Tests looking up a stable interface. |
| 23 TEST_F(InterfaceListTest, Stable) { |
| 24 InterfaceList list; |
| 25 ASSERT_TRUE(list.GetInterfaceForPPB(PPB_CORE_INTERFACE_1_0) != NULL); |
| 26 ASSERT_TRUE(list.GetInterfaceForPPB("FakeUnknownInterface") == NULL); |
| 27 } |
| 28 |
| 29 // Tests that dev channel restrictions work properly. |
| 30 TEST_F(InterfaceListTest, DevChannel) { |
| 31 InterfaceList list; |
| 32 static const char* iface_name = "TestDevChannelInterface"; |
| 33 void* iface_addr = (void*)0xdeadbeef; |
| 34 AddPPB(&list, iface_name, iface_addr, PERMISSION_NONE, true); |
| 35 InterfaceList::SetSupportsDevChannel(false); |
| 36 ASSERT_TRUE(list.GetInterfaceForPPB(iface_name) == NULL); |
| 37 InterfaceList::SetSupportsDevChannel(true); |
| 38 ASSERT_TRUE(list.GetInterfaceForPPB(iface_name) == iface_addr); |
| 39 } |
| 40 |
| 41 } // namespace proxy |
| 42 } // namespace ppapi |
OLD | NEW |