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

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

Issue 563663002: Clean up extensions permissions unit tests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: (permissions-data) fix android Created 6 years, 3 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
« no previous file with comments | « chrome/common/extensions/permissions/socket_permission_unittest.cc ('k') | extensions/DEPS » ('j') | 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/memory/scoped_ptr.h"
9 #include "base/pickle.h"
10 #include "base/strings/utf_string_conversions.h"
11 #include "base/values.h"
12 #include "extensions/common/permissions/api_permission.h"
13 #include "extensions/common/permissions/permissions_info.h"
14 #include "extensions/common/permissions/usb_device_permission.h"
15 #include "extensions/common/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 TEST(USBDevicePermissionTest, PermissionDataOrder) {
22 EXPECT_LT(UsbDevicePermissionData(0x02ad, 0x138c, -1),
23 UsbDevicePermissionData(0x02ad, 0x138d, -1));
24 ASSERT_LT(UsbDevicePermissionData(0x02ad, 0x138d, -1),
25 UsbDevicePermissionData(0x02ae, 0x138c, -1));
26 EXPECT_LT(UsbDevicePermissionData(0x02ad, 0x138c, -1),
27 UsbDevicePermissionData(0x02ad, 0x138c, 0));
28 }
29
30 #if defined(ENABLE_EXTENSIONS)
31 #define MAYBE_PermissionMessage PermissionMessage
32 #else
33 #define MAYBE_PermissionMessage DISABLED_PermissionMessage
34 #endif // defined(ENABLE_EXTENSIONS)
35
36 TEST(USBDevicePermissionTest, MAYBE_PermissionMessage) {
37 const char* const kMessages[] = {
38 "Access the USB device PVR Mass Storage from HUMAX Co., Ltd.",
39 "Access the USB device from HUMAX Co., Ltd.",
40 "Access the USB device",
41 };
42
43 // Prepare data set
44 scoped_ptr<base::ListValue> permission_list(new base::ListValue());
45 permission_list->Append(
46 UsbDevicePermissionData(0x02ad, 0x138c, -1).ToValue()->DeepCopy());
47 permission_list->Append(
48 UsbDevicePermissionData(0x02ad, 0x138d, -1).ToValue()->DeepCopy());
49 permission_list->Append(
50 UsbDevicePermissionData(0x02ae, 0x138d, -1).ToValue()->DeepCopy());
51
52 UsbDevicePermission permission(
53 PermissionsInfo::GetInstance()->GetByID(APIPermission::kUsbDevice));
54 ASSERT_TRUE(permission.FromValue(permission_list.get(), NULL, NULL));
55
56 PermissionMessages messages = permission.GetMessages();
57 ASSERT_EQ(3U, messages.size());
58 EXPECT_EQ(base::ASCIIToUTF16(kMessages[0]), messages.at(0).message());
59 EXPECT_EQ(base::ASCIIToUTF16(kMessages[1]), messages.at(1).message());
60 EXPECT_EQ(base::ASCIIToUTF16(kMessages[2]), messages.at(2).message());
61 }
62
63 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/common/extensions/permissions/socket_permission_unittest.cc ('k') | extensions/DEPS » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698