Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(271)

Side by Side Diff: ppapi/proxy/interface_list_unittest.cc

Issue 141523010: Pepper: Log in UMA when an interface is used. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased again Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ppapi/proxy/interface_list.cc ('k') | ppapi/proxy/ppapi_messages.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
OLDNEW
« no previous file with comments | « ppapi/proxy/interface_list.cc ('k') | ppapi/proxy/ppapi_messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698