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

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

Issue 236113002: Suppress tabs permission warning if there is already a browsingHistory warning. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix tests Created 6 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/command_line.h" 5 #include "base/command_line.h"
6 #include "base/json/json_file_value_serializer.h" 6 #include "base/json/json_file_value_serializer.h"
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/path_service.h" 8 #include "base/path_service.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "chrome/common/chrome_paths.h" 10 #include "chrome/common/chrome_paths.h"
(...skipping 793 matching lines...) Expand 10 before | Expand all | Expand 10 after
804 scoped_refptr<PermissionSet> permissions( 804 scoped_refptr<PermissionSet> permissions(
805 new PermissionSet(api_permissions, ManifestPermissionSet(), 805 new PermissionSet(api_permissions, ManifestPermissionSet(),
806 URLPatternSet(), URLPatternSet())); 806 URLPatternSet(), URLPatternSet()));
807 PermissionMessages messages = 807 PermissionMessages messages =
808 PermissionMessageProvider::Get()->GetPermissionMessages( 808 PermissionMessageProvider::Get()->GetPermissionMessages(
809 permissions, Manifest::TYPE_PLATFORM_APP); 809 permissions, Manifest::TYPE_PLATFORM_APP);
810 ASSERT_EQ(1u, messages.size()); 810 ASSERT_EQ(1u, messages.size());
811 EXPECT_EQ(PermissionMessage::kFileSystemWriteDirectory, messages[0].id()); 811 EXPECT_EQ(PermissionMessage::kFileSystemWriteDirectory, messages[0].id());
812 } 812 }
813 813
814 TEST(PermissionsTest, SuppressedPermissionMessages) {
815 APIPermissionSet api_permissions;
816 api_permissions.insert(APIPermission::kTab);
817 api_permissions.insert(APIPermission::kHistory);
818 scoped_refptr<PermissionSet> permissions(
819 new PermissionSet(api_permissions, ManifestPermissionSet(),
820 URLPatternSet(), URLPatternSet()));
821 PermissionMessages messages =
822 PermissionMessageProvider::Get()->GetPermissionMessages(
823 permissions, Manifest::TYPE_EXTENSION);
824 EXPECT_EQ(1u, messages.size());
825 EXPECT_EQ(PermissionMessage::kBrowsingHistory, messages[0].id());
826 }
827
814 TEST(PermissionsTest, MergedFileSystemPermissionComparison) { 828 TEST(PermissionsTest, MergedFileSystemPermissionComparison) {
815 APIPermissionSet write_api_permissions; 829 APIPermissionSet write_api_permissions;
816 write_api_permissions.insert(APIPermission::kFileSystemWrite); 830 write_api_permissions.insert(APIPermission::kFileSystemWrite);
817 scoped_refptr<PermissionSet> write_permissions( 831 scoped_refptr<PermissionSet> write_permissions(
818 new PermissionSet(write_api_permissions, ManifestPermissionSet(), 832 new PermissionSet(write_api_permissions, ManifestPermissionSet(),
819 URLPatternSet(), URLPatternSet())); 833 URLPatternSet(), URLPatternSet()));
820 834
821 APIPermissionSet directory_api_permissions; 835 APIPermissionSet directory_api_permissions;
822 directory_api_permissions.insert(APIPermission::kFileSystemDirectory); 836 directory_api_permissions.insert(APIPermission::kFileSystemDirectory);
823 scoped_refptr<PermissionSet> directory_permissions( 837 scoped_refptr<PermissionSet> directory_permissions(
(...skipping 695 matching lines...) Expand 10 before | Expand all | Expand 10 after
1519 scoped_refptr<const PermissionSet> permissions_dwr( 1533 scoped_refptr<const PermissionSet> permissions_dwr(
1520 extension_dwr->GetActivePermissions()); 1534 extension_dwr->GetActivePermissions());
1521 1535
1522 EXPECT_FALSE(PermissionMessageProvider::Get()-> 1536 EXPECT_FALSE(PermissionMessageProvider::Get()->
1523 IsPrivilegeIncrease(permissions.get(), 1537 IsPrivilegeIncrease(permissions.get(),
1524 permissions_dwr.get(), 1538 permissions_dwr.get(),
1525 extension->GetType())); 1539 extension->GetType()));
1526 } 1540 }
1527 1541
1528 } // namespace extensions 1542 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698