Chromium Code Reviews| Index: ppapi/proxy/interface_list_unittest.cc |
| diff --git a/ppapi/proxy/interface_list_unittest.cc b/ppapi/proxy/interface_list_unittest.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..48f10652ffd9e5ed7b4f5f78aa3152ba71792473 |
| --- /dev/null |
| +++ b/ppapi/proxy/interface_list_unittest.cc |
| @@ -0,0 +1,43 @@ |
| +// Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "ppapi/c/ppb_core.h" |
| +#include "ppapi/proxy/interface_list.h" |
| +#include "ppapi/proxy/ppapi_proxy_test.h" |
| + |
| +namespace ppapi { |
| +namespace proxy { |
| + |
| +class InterfaceListTest : public PluginProxyTest { |
| + public: |
| + // Wrapper function so we can use the private InterfaceList::AddPPB. |
| + void AddPPB(InterfaceList* list, |
| + const char* iface_name, void* iface_addr, Permission perm) { |
| + list->AddPPB(iface_name, iface_addr, perm); |
| + } |
| +}; |
| + |
| +// Tests looking up a stable interface. |
| +TEST_F(InterfaceListTest, Stable) { |
| + InterfaceList list; |
| + ASSERT_TRUE(list.GetInterfaceForPPB(PPB_CORE_INTERFACE_1_0) != NULL); |
| + ASSERT_TRUE(list.GetInterfaceForPPB("FakeUnknownInterface") == NULL); |
| +} |
| + |
| +// Tests that dev channel restrictions work properly. |
| +TEST_F(InterfaceListTest, DevChannel) { |
| + InterfaceList list; |
| + static const char* iface_name = "TestDevChannelInterface"; |
| + void* iface_addr = (void*)0xdeadbeef; |
| + AddPPB(&list, iface_name, iface_addr, PERMISSION_DEV_CHANNEL); |
| + InterfaceList::SetProcessGlobalPermissions( |
| + PpapiPermissions(PERMISSION_NONE)); |
|
dmichael (off chromium)
2013/12/18 22:40:50
Might be good to make sure PERMISSION_DEV doesn't
|
| + ASSERT_TRUE(list.GetInterfaceForPPB(iface_name) == NULL); |
| + InterfaceList::SetProcessGlobalPermissions( |
| + PpapiPermissions(PERMISSION_DEV_CHANNEL)); |
| + ASSERT_TRUE(list.GetInterfaceForPPB(iface_name) == iface_addr); |
| +} |
| + |
| +} // namespace proxy |
| +} // namespace ppapi |