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

Side by Side Diff: chrome/common/extensions/permissions/usb_device_permission_unittest.cc

Issue 15663003: Fixing memory leak in newly added USB device permission unit tests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 7 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 | « no previous file | no next file » | 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 <set> 5 #include <set>
6 #include <string> 6 #include <string>
7 7
8 #include "base/memory/scoped_ptr.h"
8 #include "base/pickle.h" 9 #include "base/pickle.h"
9 #include "base/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
10 #include "base/values.h" 11 #include "base/values.h"
11 #include "chrome/common/extensions/permissions/api_permission.h" 12 #include "chrome/common/extensions/permissions/api_permission.h"
12 #include "chrome/common/extensions/permissions/chrome_api_permissions.h" 13 #include "chrome/common/extensions/permissions/chrome_api_permissions.h"
13 #include "chrome/common/extensions/permissions/usb_device_permission.h" 14 #include "chrome/common/extensions/permissions/usb_device_permission.h"
14 #include "chrome/common/extensions/permissions/usb_device_permission_data.h" 15 #include "chrome/common/extensions/permissions/usb_device_permission_data.h"
15 #include "ipc/ipc_message.h" 16 #include "ipc/ipc_message.h"
16 #include "testing/gtest/include/gtest/gtest.h" 17 #include "testing/gtest/include/gtest/gtest.h"
17 18
(...skipping 13 matching lines...) Expand all
31 #endif // defined(ENABLE_EXTENSIONS) 32 #endif // defined(ENABLE_EXTENSIONS)
32 33
33 TEST(USBDevicePermissionTest, MAYBE_PermissionMessage) { 34 TEST(USBDevicePermissionTest, MAYBE_PermissionMessage) {
34 const char* const kMessages[] = { 35 const char* const kMessages[] = {
35 "Access the USB device PVR Mass Storage from HUMAX Co., Ltd..", 36 "Access the USB device PVR Mass Storage from HUMAX Co., Ltd..",
36 "Access the USB device from HUMAX Co., Ltd..", 37 "Access the USB device from HUMAX Co., Ltd..",
37 "Access the USB device.", 38 "Access the USB device.",
38 }; 39 };
39 40
40 // Prepare data set 41 // Prepare data set
41 base::ListValue* permission_list = new base::ListValue(); 42 scoped_ptr<base::ListValue> permission_list(new base::ListValue());
42 permission_list->Append( 43 permission_list->Append(
43 UsbDevicePermissionData(0x02ad, 0x138c).ToValue()->DeepCopy()); 44 UsbDevicePermissionData(0x02ad, 0x138c).ToValue()->DeepCopy());
44 permission_list->Append( 45 permission_list->Append(
45 UsbDevicePermissionData(0x02ad, 0x138d).ToValue()->DeepCopy()); 46 UsbDevicePermissionData(0x02ad, 0x138d).ToValue()->DeepCopy());
46 permission_list->Append( 47 permission_list->Append(
47 UsbDevicePermissionData(0x02ae, 0x138d).ToValue()->DeepCopy()); 48 UsbDevicePermissionData(0x02ae, 0x138d).ToValue()->DeepCopy());
48 49
49 UsbDevicePermission permission( 50 UsbDevicePermission permission(
50 PermissionsInfo::GetInstance()->GetByID(APIPermission::kUsbDevice)); 51 PermissionsInfo::GetInstance()->GetByID(APIPermission::kUsbDevice));
51 ASSERT_TRUE(permission.FromValue(permission_list)); 52 ASSERT_TRUE(permission.FromValue(permission_list.get()));
52 53
53 PermissionMessages messages = permission.GetMessages(); 54 PermissionMessages messages = permission.GetMessages();
54 ASSERT_EQ(3U, messages.size()); 55 ASSERT_EQ(3U, messages.size());
55 EXPECT_EQ(ASCIIToUTF16(kMessages[0]), messages.at(0).message()); 56 EXPECT_EQ(ASCIIToUTF16(kMessages[0]), messages.at(0).message());
56 EXPECT_EQ(ASCIIToUTF16(kMessages[1]), messages.at(1).message()); 57 EXPECT_EQ(ASCIIToUTF16(kMessages[1]), messages.at(1).message());
57 EXPECT_EQ(ASCIIToUTF16(kMessages[2]), messages.at(2).message()); 58 EXPECT_EQ(ASCIIToUTF16(kMessages[2]), messages.at(2).message());
58 } 59 }
59 60
60 } // namespace extensions 61 } // namespace extensions
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698