Index: chrome/common/extensions/permissions/usb_device_permission_unittest.cc |
diff --git a/chrome/common/extensions/permissions/usb_device_permission_unittest.cc b/chrome/common/extensions/permissions/usb_device_permission_unittest.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..81f2f228a1442043e1fd6b8c10387682059a32ff |
--- /dev/null |
+++ b/chrome/common/extensions/permissions/usb_device_permission_unittest.cc |
@@ -0,0 +1,60 @@ |
+// Copyright (c) 2013 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include <set> |
+#include <string> |
+ |
+#include "base/pickle.h" |
+#include "base/utf_string_conversions.h" |
+#include "base/values.h" |
+#include "chrome/common/extensions/permissions/api_permission.h" |
+#include "chrome/common/extensions/permissions/chrome_api_permissions.h" |
+#include "chrome/common/extensions/permissions/usb_device_permission.h" |
+#include "chrome/common/extensions/permissions/usb_device_permission_data.h" |
+#include "ipc/ipc_message.h" |
+#include "testing/gtest/include/gtest/gtest.h" |
+ |
+namespace extensions { |
+ |
+TEST(USBDevicePermissionTest, PermissionDataOrder) { |
+ EXPECT_LT(UsbDevicePermissionData(0x02ad, 0x138c), |
+ UsbDevicePermissionData(0x02ad, 0x138d)); |
+ ASSERT_LT(UsbDevicePermissionData(0x02ad, 0x138d), |
+ UsbDevicePermissionData(0x02ae, 0x138c)); |
+} |
+ |
+#if defined(ENABLE_EXTENSIONS) |
+#define MAYBE_PermissionMessage PermissionMessage |
+#else |
+#define MAYBE_PermissionMessage DISABLED_PermissionMessage |
+#endif // defined(ENABLE_EXTENSIONS) |
+ |
+TEST(USBDevicePermissionTest, MAYBE_PermissionMessage) { |
+ const char* const kMessages[] = { |
+ "Access the USB device PVR Mass Storage from HUMAX Co., Ltd..", |
+ "Access the USB device from HUMAX Co., Ltd..", |
+ "Access the USB device.", |
+ }; |
+ |
+ // Prepare data set |
+ 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
|
+ permission_list->Append( |
+ UsbDevicePermissionData(0x02ad, 0x138c).ToValue()->DeepCopy()); |
+ permission_list->Append( |
+ UsbDevicePermissionData(0x02ad, 0x138d).ToValue()->DeepCopy()); |
+ permission_list->Append( |
+ UsbDevicePermissionData(0x02ae, 0x138d).ToValue()->DeepCopy()); |
+ |
+ UsbDevicePermission permission( |
+ PermissionsInfo::GetInstance()->GetByID(APIPermission::kUsbDevice)); |
+ ASSERT_TRUE(permission.FromValue(permission_list)); |
+ |
+ PermissionMessages messages = permission.GetMessages(); |
+ ASSERT_EQ(3U, messages.size()); |
+ EXPECT_EQ(ASCIIToUTF16(kMessages[0]), messages.at(0).message()); |
+ EXPECT_EQ(ASCIIToUTF16(kMessages[1]), messages.at(1).message()); |
+ EXPECT_EQ(ASCIIToUTF16(kMessages[2]), messages.at(2).message()); |
+} |
+ |
+} // namespace extensions |