summaryrefslogtreecommitdiffstats
path: root/ppapi/proxy/interface_list_unittest.cc
diff options
context:
space:
mode:
authorteravest@chromium.org <teravest@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-12-19 17:10:50 +0000
committerteravest@chromium.org <teravest@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-12-19 17:10:50 +0000
commit84350ef4536f877c2e1e5f3b6766a1c9361d76d4 (patch)
treef30ce70c8b8a979aafe94e94cfe2c7eb447d9fe7 /ppapi/proxy/interface_list_unittest.cc
parent3037a702987ad70ba53e3cf4707c397658ed3f23 (diff)
downloadchromium_src-84350ef4536f877c2e1e5f3b6766a1c9361d76d4.zip
chromium_src-84350ef4536f877c2e1e5f3b6766a1c9361d76d4.tar.gz
chromium_src-84350ef4536f877c2e1e5f3b6766a1c9361d76d4.tar.bz2
Pepper: Finish support for dev channel APIs.
This change completes the wiring, adding a file to list dev channel interfaces, analogous to what exists for different permissions today. We only need to introduce interfaces_ppb_public_dev_channel.h since we don't anticipate dev channel APIs with permissions other than NONE. BUG=325403 R=dmichael@chromium.org Review URL: https://codereview.chromium.org/112343005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@241877 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi/proxy/interface_list_unittest.cc')
-rw-r--r--ppapi/proxy/interface_list_unittest.cc66
1 files changed, 66 insertions, 0 deletions
diff --git a/ppapi/proxy/interface_list_unittest.cc b/ppapi/proxy/interface_list_unittest.cc
new file mode 100644
index 0000000..17140f0
--- /dev/null
+++ b/ppapi/proxy/interface_list_unittest.cc
@@ -0,0 +1,66 @@
+// 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;
+ // "Dev channel" interface.
+ static const char* dev_channel_iface_name = "TestDevChannelInterface";
+ void* dev_channel_iface_addr = (void*)0xdeadbeef;
+ // "Dev" interface
+ static const char* dev_iface_name = "TestDevInterface";
+ void* dev_iface_addr = (void*)0xcafefade;
+
+ AddPPB(&list, dev_channel_iface_name, dev_channel_iface_addr,
+ PERMISSION_DEV_CHANNEL);
+ AddPPB(&list, dev_iface_name, dev_iface_addr, PERMISSION_DEV);
+
+ InterfaceList::SetProcessGlobalPermissions(
+ PpapiPermissions(PERMISSION_NONE));
+ ASSERT_TRUE(list.GetInterfaceForPPB(dev_channel_iface_name) == NULL);
+ ASSERT_TRUE(list.GetInterfaceForPPB(dev_iface_name) == NULL);
+
+ InterfaceList::SetProcessGlobalPermissions(
+ PpapiPermissions(PERMISSION_DEV_CHANNEL));
+ ASSERT_TRUE(list.GetInterfaceForPPB(dev_channel_iface_name) ==
+ dev_channel_iface_addr);
+ ASSERT_TRUE(list.GetInterfaceForPPB(dev_iface_name) == NULL);
+
+ InterfaceList::SetProcessGlobalPermissions(
+ PpapiPermissions(PERMISSION_DEV));
+ ASSERT_TRUE(list.GetInterfaceForPPB(dev_channel_iface_name) == NULL);
+ ASSERT_TRUE(list.GetInterfaceForPPB(dev_iface_name) == dev_iface_addr);
+
+ InterfaceList::SetProcessGlobalPermissions(
+ PpapiPermissions(PERMISSION_DEV | PERMISSION_DEV_CHANNEL));
+ ASSERT_TRUE(list.GetInterfaceForPPB(dev_channel_iface_name) ==
+ dev_channel_iface_addr);
+ ASSERT_TRUE(list.GetInterfaceForPPB(dev_iface_name) == dev_iface_addr);
+}
+
+} // namespace proxy
+} // namespace ppapi