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

Side by Side Diff: chrome/browser/extensions/permission_messages_unittest.cc

Issue 1300353002: Make USB permissions work in the new permission message system (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@kill_permissionmessage
Patch Set: review Created 5 years, 4 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 | « no previous file | chrome/common/extensions/permissions/chrome_permission_message_provider.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/memory/scoped_ptr.h" 5 #include "base/memory/scoped_ptr.h"
6 #include "base/strings/utf_string_conversions.h" 6 #include "base/strings/utf_string_conversions.h"
7 #include "chrome/browser/extensions/extension_service.h" 7 #include "chrome/browser/extensions/extension_service.h"
8 #include "chrome/browser/extensions/permissions_updater.h" 8 #include "chrome/browser/extensions/permissions_updater.h"
9 #include "chrome/browser/extensions/test_extension_environment.h" 9 #include "chrome/browser/extensions/test_extension_environment.h"
10 #include "chrome/common/extensions/permissions/chrome_permission_message_provide r.h" 10 #include "chrome/common/extensions/permissions/chrome_permission_message_provide r.h"
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 GetMessages(permission.GetPermissions()); 316 GetMessages(permission.GetPermissions());
317 ASSERT_EQ(1U, messages.size()); 317 ASSERT_EQ(1U, messages.size());
318 EXPECT_EQ(base::ASCIIToUTF16(kMessage), messages.front().message()); 318 EXPECT_EQ(base::ASCIIToUTF16(kMessage), messages.front().message());
319 } 319 }
320 } 320 }
321 321
322 TEST_F(USBDevicePermissionMessagesTest, MultipleDevice) { 322 TEST_F(USBDevicePermissionMessagesTest, MultipleDevice) {
323 const char kMessage[] = "Access any of these USB devices"; 323 const char kMessage[] = "Access any of these USB devices";
324 const char* kDetails[] = { 324 const char* kDetails[] = {
325 "PVR Mass Storage from HUMAX Co., Ltd.", 325 "PVR Mass Storage from HUMAX Co., Ltd.",
326 // TODO(treib): The following two should be the other way around - 326 "unknown devices from HUMAX Co., Ltd.",
327 // "unknown devices from Vendor" first, then the catch-all "devices from 327 "devices from an unknown vendor"
328 // unknown vendor". crbug.com/522842
329 "devices from an unknown vendor",
330 "unknown devices from HUMAX Co., Ltd."
331 }; 328 };
332 329
333 // Prepare data set 330 // Prepare data set
334 scoped_ptr<base::ListValue> permission_list(new base::ListValue()); 331 scoped_ptr<base::ListValue> permission_list(new base::ListValue());
335 permission_list->Append( 332 permission_list->Append(
336 UsbDevicePermissionData(0x02ad, 0x138c, -1).ToValue().release()); 333 UsbDevicePermissionData(0x02ad, 0x138c, -1).ToValue().release());
337 // This device's product ID is not in Chrome's database. 334 // This device's product ID is not in Chrome's database.
338 permission_list->Append( 335 permission_list->Append(
339 UsbDevicePermissionData(0x02ad, 0x138d, -1).ToValue().release()); 336 UsbDevicePermissionData(0x02ad, 0x138d, -1).ToValue().release());
340 // This additional unknown product will be collapsed into the entry above. 337 // This additional unknown product will be collapsed into the entry above.
(...skipping 15 matching lines...) Expand all
356 ASSERT_EQ(1U, messages.size()); 353 ASSERT_EQ(1U, messages.size());
357 EXPECT_EQ(base::ASCIIToUTF16(kMessage), messages.front().message()); 354 EXPECT_EQ(base::ASCIIToUTF16(kMessage), messages.front().message());
358 const std::vector<base::string16>& submessages = 355 const std::vector<base::string16>& submessages =
359 messages.front().submessages(); 356 messages.front().submessages();
360 ASSERT_EQ(arraysize(kDetails), submessages.size()); 357 ASSERT_EQ(arraysize(kDetails), submessages.size());
361 for (size_t i = 0; i < submessages.size(); i++) 358 for (size_t i = 0; i < submessages.size(); i++)
362 EXPECT_EQ(base::ASCIIToUTF16(kDetails[i]), submessages[i]); 359 EXPECT_EQ(base::ASCIIToUTF16(kDetails[i]), submessages[i]);
363 } 360 }
364 361
365 } // namespace extensions 362 } // namespace extensions
OLDNEW
« no previous file with comments | « no previous file | chrome/common/extensions/permissions/chrome_permission_message_provider.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698