OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
| 5 #include "base/hash.h" |
5 #include "ppapi/c/ppb_core.h" | 6 #include "ppapi/c/ppb_core.h" |
6 #include "ppapi/proxy/interface_list.h" | 7 #include "ppapi/proxy/interface_list.h" |
7 #include "ppapi/proxy/ppapi_proxy_test.h" | 8 #include "ppapi/proxy/ppapi_proxy_test.h" |
8 | 9 |
9 namespace ppapi { | 10 namespace ppapi { |
10 namespace proxy { | 11 namespace proxy { |
11 | 12 |
12 class InterfaceListTest : public PluginProxyTest { | 13 class InterfaceListTest : public PluginProxyTest { |
13 public: | 14 public: |
14 // Wrapper function so we can use the private InterfaceList::AddPPB. | 15 // Wrapper function so we can use the private InterfaceList::AddPPB. |
15 void AddPPB(InterfaceList* list, | 16 void AddPPB(InterfaceList* list, |
16 const char* iface_name, void* iface_addr, Permission perm) { | 17 const char* iface_name, void* iface_addr, Permission perm) { |
17 list->AddPPB(iface_name, iface_addr, perm); | 18 list->AddPPB(iface_name, iface_addr, perm); |
18 } | 19 } |
| 20 |
| 21 // Wrapper function so we can use the private |
| 22 // InterfaceList::HashInterfaceName. |
| 23 int HashInterfaceName(const std::string& name) { |
| 24 return InterfaceList::HashInterfaceName(name); |
| 25 } |
19 }; | 26 }; |
20 | 27 |
21 // Tests looking up a stable interface. | 28 // Tests looking up a stable interface. |
22 TEST_F(InterfaceListTest, Stable) { | 29 TEST_F(InterfaceListTest, Stable) { |
23 InterfaceList list; | 30 InterfaceList list; |
24 ASSERT_TRUE(list.GetInterfaceForPPB(PPB_CORE_INTERFACE_1_0) != NULL); | 31 ASSERT_TRUE(list.GetInterfaceForPPB(PPB_CORE_INTERFACE_1_0) != NULL); |
25 ASSERT_TRUE(list.GetInterfaceForPPB("FakeUnknownInterface") == NULL); | 32 ASSERT_TRUE(list.GetInterfaceForPPB("FakeUnknownInterface") == NULL); |
26 } | 33 } |
27 | 34 |
28 // Tests that dev channel restrictions work properly. | 35 // Tests that dev channel restrictions work properly. |
(...skipping 26 matching lines...) Expand all Loading... |
55 ASSERT_TRUE(list.GetInterfaceForPPB(dev_channel_iface_name) == NULL); | 62 ASSERT_TRUE(list.GetInterfaceForPPB(dev_channel_iface_name) == NULL); |
56 ASSERT_TRUE(list.GetInterfaceForPPB(dev_iface_name) == dev_iface_addr); | 63 ASSERT_TRUE(list.GetInterfaceForPPB(dev_iface_name) == dev_iface_addr); |
57 | 64 |
58 InterfaceList::SetProcessGlobalPermissions( | 65 InterfaceList::SetProcessGlobalPermissions( |
59 PpapiPermissions(PERMISSION_DEV | PERMISSION_DEV_CHANNEL)); | 66 PpapiPermissions(PERMISSION_DEV | PERMISSION_DEV_CHANNEL)); |
60 ASSERT_TRUE(list.GetInterfaceForPPB(dev_channel_iface_name) == | 67 ASSERT_TRUE(list.GetInterfaceForPPB(dev_channel_iface_name) == |
61 dev_channel_iface_addr); | 68 dev_channel_iface_addr); |
62 ASSERT_TRUE(list.GetInterfaceForPPB(dev_iface_name) == dev_iface_addr); | 69 ASSERT_TRUE(list.GetInterfaceForPPB(dev_iface_name) == dev_iface_addr); |
63 } | 70 } |
64 | 71 |
| 72 // Test that the hash function provided by base::Hash is unchanged. This is so |
| 73 // that we will generate correct values when logging interface use to UMA. |
| 74 TEST_F(InterfaceListTest, InterfaceHash) { |
| 75 EXPECT_EQ(612625164, HashInterfaceName("PPB_InputEvent;1.0")); |
| 76 EXPECT_EQ(79708274, HashInterfaceName("PPB_TCPSocket;1.1")); |
| 77 } |
| 78 |
65 } // namespace proxy | 79 } // namespace proxy |
66 } // namespace ppapi | 80 } // namespace ppapi |
OLD | NEW |