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

Side by Side Diff: chrome/browser/permissions/permission_util_unittest.cc

Issue 2715643002: Replace all enums with enum classes in permissions code. (Closed)
Patch Set: Rebase Created 3 years, 10 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
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/test/histogram_tester.h" 5 #include "base/test/histogram_tester.h"
6 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" 6 #include "chrome/browser/content_settings/host_content_settings_map_factory.h"
7 #include "chrome/browser/permissions/permission_uma_util.h" 7 #include "chrome/browser/permissions/permission_uma_util.h"
8 #include "chrome/browser/permissions/permission_util.h" 8 #include "chrome/browser/permissions/permission_util.h"
9 #include "chrome/test/base/testing_profile.h" 9 #include "chrome/test/base/testing_profile.h"
10 #include "components/content_settings/core/browser/host_content_settings_map.h" 10 #include "components/content_settings/core/browser/host_content_settings_map.h"
(...skipping 21 matching lines...) Expand all
32 // Allow->Block triggers a revocation. 32 // Allow->Block triggers a revocation.
33 map->SetContentSettingDefaultScope(host, host, type, std::string(), 33 map->SetContentSettingDefaultScope(host, host, type, std::string(),
34 CONTENT_SETTING_ALLOW); 34 CONTENT_SETTING_ALLOW);
35 { 35 {
36 PermissionUtil::ScopedRevocationReporter scoped_revocation_reporter( 36 PermissionUtil::ScopedRevocationReporter scoped_revocation_reporter(
37 &profile, host, host, type, source_ui); 37 &profile, host, host, type, source_ui);
38 map->SetContentSettingDefaultScope(host, host, type, std::string(), 38 map->SetContentSettingDefaultScope(host, host, type, std::string(),
39 CONTENT_SETTING_BLOCK); 39 CONTENT_SETTING_BLOCK);
40 } 40 }
41 histograms.ExpectBucketCount("Permissions.Action.Geolocation", 41 histograms.ExpectBucketCount("Permissions.Action.Geolocation",
42 PermissionAction::REVOKED, 1); 42 static_cast<int>(PermissionAction::REVOKED), 1);
43 43
44 // Block->Allow does not trigger a revocation. 44 // Block->Allow does not trigger a revocation.
45 { 45 {
46 PermissionUtil::ScopedRevocationReporter scoped_revocation_reporter( 46 PermissionUtil::ScopedRevocationReporter scoped_revocation_reporter(
47 &profile, host, host, type, source_ui); 47 &profile, host, host, type, source_ui);
48 map->SetContentSettingDefaultScope(host, host, type, std::string(), 48 map->SetContentSettingDefaultScope(host, host, type, std::string(),
49 CONTENT_SETTING_ALLOW); 49 CONTENT_SETTING_ALLOW);
50 } 50 }
51 histograms.ExpectBucketCount("Permissions.Action.Geolocation", 51 histograms.ExpectBucketCount("Permissions.Action.Geolocation",
52 PermissionAction::REVOKED, 1); 52 static_cast<int>(PermissionAction::REVOKED), 1);
53 53
54 // Allow->Default triggers a revocation when default is 'ask'. 54 // Allow->Default triggers a revocation when default is 'ask'.
55 map->SetDefaultContentSetting(type, CONTENT_SETTING_ASK); 55 map->SetDefaultContentSetting(type, CONTENT_SETTING_ASK);
56 { 56 {
57 PermissionUtil::ScopedRevocationReporter scoped_revocation_reporter( 57 PermissionUtil::ScopedRevocationReporter scoped_revocation_reporter(
58 &profile, host, host, type, source_ui); 58 &profile, host, host, type, source_ui);
59 map->SetContentSettingDefaultScope(host, host, type, std::string(), 59 map->SetContentSettingDefaultScope(host, host, type, std::string(),
60 CONTENT_SETTING_DEFAULT); 60 CONTENT_SETTING_DEFAULT);
61 } 61 }
62 histograms.ExpectBucketCount("Permissions.Action.Geolocation", 62 histograms.ExpectBucketCount("Permissions.Action.Geolocation",
63 PermissionAction::REVOKED, 2); 63 static_cast<int>(PermissionAction::REVOKED), 2);
64 64
65 // Allow->Default does not trigger a revocation when default is 'allow'. 65 // Allow->Default does not trigger a revocation when default is 'allow'.
66 map->SetDefaultContentSetting(type, CONTENT_SETTING_ALLOW); 66 map->SetDefaultContentSetting(type, CONTENT_SETTING_ALLOW);
67 { 67 {
68 PermissionUtil::ScopedRevocationReporter scoped_revocation_reporter( 68 PermissionUtil::ScopedRevocationReporter scoped_revocation_reporter(
69 &profile, host, host, type, source_ui); 69 &profile, host, host, type, source_ui);
70 map->SetContentSettingDefaultScope(host, host, type, std::string(), 70 map->SetContentSettingDefaultScope(host, host, type, std::string(),
71 CONTENT_SETTING_DEFAULT); 71 CONTENT_SETTING_DEFAULT);
72 } 72 }
73 histograms.ExpectBucketCount("Permissions.Action.Geolocation", 73 histograms.ExpectBucketCount("Permissions.Action.Geolocation",
74 PermissionAction::REVOKED, 2); 74 static_cast<int>(PermissionAction::REVOKED), 2);
75 75
76 // Allow->Block with url pattern string triggers a revocation. 76 // Allow->Block with url pattern string triggers a revocation.
77 map->SetContentSettingDefaultScope(host, host, type, std::string(), 77 map->SetContentSettingDefaultScope(host, host, type, std::string(),
78 CONTENT_SETTING_ALLOW); 78 CONTENT_SETTING_ALLOW);
79 { 79 {
80 PermissionUtil::ScopedRevocationReporter scoped_revocation_reporter( 80 PermissionUtil::ScopedRevocationReporter scoped_revocation_reporter(
81 &profile, host_pattern, host_pattern, type, source_ui); 81 &profile, host_pattern, host_pattern, type, source_ui);
82 map->SetContentSettingCustomScope(host_pattern, host_pattern, type, 82 map->SetContentSettingCustomScope(host_pattern, host_pattern, type,
83 std::string(), CONTENT_SETTING_BLOCK); 83 std::string(), CONTENT_SETTING_BLOCK);
84 } 84 }
85 histograms.ExpectBucketCount("Permissions.Action.Geolocation", 85 histograms.ExpectBucketCount("Permissions.Action.Geolocation",
86 PermissionAction::REVOKED, 3); 86 static_cast<int>(PermissionAction::REVOKED), 3);
87 87
88 // Allow->Block with non url pattern string does not trigger a revocation. 88 // Allow->Block with non url pattern string does not trigger a revocation.
89 map->SetContentSettingDefaultScope(host, host, type, std::string(), 89 map->SetContentSettingDefaultScope(host, host, type, std::string(),
90 CONTENT_SETTING_ALLOW); 90 CONTENT_SETTING_ALLOW);
91 { 91 {
92 PermissionUtil::ScopedRevocationReporter scoped_revocation_reporter( 92 PermissionUtil::ScopedRevocationReporter scoped_revocation_reporter(
93 &profile, host_containing_wildcards_pattern, host_pattern, type, 93 &profile, host_containing_wildcards_pattern, host_pattern, type,
94 source_ui); 94 source_ui);
95 map->SetContentSettingCustomScope(host_containing_wildcards_pattern, 95 map->SetContentSettingCustomScope(host_containing_wildcards_pattern,
96 host_pattern, type, std::string(), 96 host_pattern, type, std::string(),
97 CONTENT_SETTING_BLOCK); 97 CONTENT_SETTING_BLOCK);
98 } 98 }
99 histograms.ExpectBucketCount("Permissions.Action.Geolocation", 99 histograms.ExpectBucketCount("Permissions.Action.Geolocation",
100 PermissionAction::REVOKED, 3); 100 static_cast<int>(PermissionAction::REVOKED), 3);
101 } 101 }
OLDNEW
« no previous file with comments | « chrome/browser/permissions/permission_util.h ('k') | chrome/browser/safe_browsing/permission_reporter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698