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

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

Issue 14473014: Fix USB Permission string (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Disable USBDevicePermissionTest on platforms does not support extension 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 | « chrome/common/extensions/permissions/usb_device_permission.cc ('k') | 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include <set>
6 #include <string>
7
8 #include "base/pickle.h"
9 #include "base/utf_string_conversions.h"
10 #include "base/values.h"
11 #include "chrome/common/extensions/permissions/api_permission.h"
12 #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_data.h"
15 #include "ipc/ipc_message.h"
16 #include "testing/gtest/include/gtest/gtest.h"
17
18 namespace extensions {
19
20 TEST(USBDevicePermissionTest, PermissionDataOrder) {
21 EXPECT_LT(UsbDevicePermissionData(0x02ad, 0x138c),
22 UsbDevicePermissionData(0x02ad, 0x138d));
23 ASSERT_LT(UsbDevicePermissionData(0x02ad, 0x138d),
24 UsbDevicePermissionData(0x02ae, 0x138c));
25 }
26
27 #if defined(ENABLE_EXTENSIONS)
28 #define MAYBE_PermissionMessage PermissionMessage
29 #else
30 #define MAYBE_PermissionMessage DISABLED_PermissionMessage
31 #endif // defined(ENABLE_EXTENSIONS)
32
33 TEST(USBDevicePermissionTest, MAYBE_PermissionMessage) {
34 const char* const kMessages[] = {
35 "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.",
38 };
39
40 // Prepare data set
41 base::ListValue* permission_list = new base::ListValue();
Dan Beam 2013/05/24 07:50:31 this probably ought to be a scoped_ptr<>, the heap
42 permission_list->Append(
43 UsbDevicePermissionData(0x02ad, 0x138c).ToValue()->DeepCopy());
44 permission_list->Append(
45 UsbDevicePermissionData(0x02ad, 0x138d).ToValue()->DeepCopy());
46 permission_list->Append(
47 UsbDevicePermissionData(0x02ae, 0x138d).ToValue()->DeepCopy());
48
49 UsbDevicePermission permission(
50 PermissionsInfo::GetInstance()->GetByID(APIPermission::kUsbDevice));
51 ASSERT_TRUE(permission.FromValue(permission_list));
52
53 PermissionMessages messages = permission.GetMessages();
54 ASSERT_EQ(3U, messages.size());
55 EXPECT_EQ(ASCIIToUTF16(kMessages[0]), messages.at(0).message());
56 EXPECT_EQ(ASCIIToUTF16(kMessages[1]), messages.at(1).message());
57 EXPECT_EQ(ASCIIToUTF16(kMessages[2]), messages.at(2).message());
58 }
59
60 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/common/extensions/permissions/usb_device_permission.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698