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

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: Created 7 years, 8 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) 2012 The Chromium Authors. All rights reserved.
miket_OOO 2013/05/07 20:13:59 2013
Bei Zhang 2013/05/08 20:07:38 Done.
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/extension_unittest.h"
12 #include "chrome/common/extensions/permissions/api_permission.h"
13 #include "chrome/common/extensions/permissions/chrome_api_permissions.h"
14 #include "chrome/common/extensions/permissions/usb_device_permission.h"
15 #include "chrome/common/extensions/permissions/usb_device_permission_data.h"
16 #include "ipc/ipc_message.h"
17 #include "testing/gtest/include/gtest/gtest.h"
18
19 namespace extensions {
20
21 class USBDevicePermissionTest : public ExtensionTest {
22 };
23
24 TEST_F(USBDevicePermissionTest, PermissionDataOrder) {
25 EXPECT_LT(UsbDevicePermissionData(0x02ad, 0x138c),
26 UsbDevicePermissionData(0x02ad, 0x138d));
27 ASSERT_LT(UsbDevicePermissionData(0x02ad, 0x138d),
28 UsbDevicePermissionData(0x02ae, 0x138c));
29 }
30
31 TEST_F(USBDevicePermissionTest, PermissionMessage) {
32 const char* const kMessages[] = {
33 "Access the USB device PVR Mass Storage from HUMAX Co., Ltd..",
34 "Access the USB device from HUMAX Co., Ltd..",
35 "Access the USB device.",
36 };
37
38 // Prepare data set
39 base::ListValue* permission_list = new base::ListValue();
40 permission_list->Append(
41 UsbDevicePermissionData(0x02ad, 0x138c).ToValue()->DeepCopy());
42 permission_list->Append(
43 UsbDevicePermissionData(0x02ad, 0x138d).ToValue()->DeepCopy());
44 permission_list->Append(
45 UsbDevicePermissionData(0x02ae, 0x138d).ToValue()->DeepCopy());
46
47 UsbDevicePermission permission(
48 PermissionsInfo::GetInstance()->GetByID(APIPermission::kUsbDevice));
49 ASSERT_TRUE(permission.FromValue(permission_list));
50
51 PermissionMessages messages = permission.GetMessages();
52 ASSERT_EQ(3U, messages.size());
53 EXPECT_EQ(ASCIIToUTF16(kMessages[0]), messages.at(0).message());
54 EXPECT_EQ(ASCIIToUTF16(kMessages[1]), messages.at(1).message());
55 EXPECT_EQ(ASCIIToUTF16(kMessages[2]), messages.at(2).message());
56 }
57
58 } // 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