Cast: Stop logging kVideoFrameSentToEncoder and rename a couple events.
[chromium-blink-merge.git] / chrome / common / extensions / permissions / usb_device_permission_unittest.cc
blobee929326046cce45af29dd510d4e84b338fcdab2
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.
5 #include <set>
6 #include <string>
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"
19 namespace extensions {
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));
30 #if defined(ENABLE_EXTENSIONS)
31 #define MAYBE_PermissionMessage PermissionMessage
32 #else
33 #define MAYBE_PermissionMessage DISABLED_PermissionMessage
34 #endif // defined(ENABLE_EXTENSIONS)
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",
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());
52 UsbDevicePermission permission(
53 PermissionsInfo::GetInstance()->GetByID(APIPermission::kUsbDevice));
54 ASSERT_TRUE(permission.FromValue(permission_list.get(), NULL, NULL));
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());
63 } // namespace extensions