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

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

Issue 1257633002: Componentize VersionInfo. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Convert version_info::Channel to a "class enum" 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
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/strings/string_number_conversions.h" 8 #include "base/strings/string_number_conversions.h"
9 #include "base/strings/stringprintf.h" 9 #include "base/strings/stringprintf.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
(...skipping 1204 matching lines...) Expand 10 before | Expand all | Expand 10 after
1215 } 1215 }
1216 1216
1217 TEST(PermissionsTest, GetWarningMessages_DeclarativeWebRequest) { 1217 TEST(PermissionsTest, GetWarningMessages_DeclarativeWebRequest) {
1218 // Test that if the declarativeWebRequest permission is present 1218 // Test that if the declarativeWebRequest permission is present
1219 // in combination with all hosts permission, then only the warning 1219 // in combination with all hosts permission, then only the warning
1220 // for host permissions is shown, because that covers the use of 1220 // for host permissions is shown, because that covers the use of
1221 // declarativeWebRequest. 1221 // declarativeWebRequest.
1222 1222
1223 // Until Declarative Web Request is in stable, let's make sure it is enabled 1223 // Until Declarative Web Request is in stable, let's make sure it is enabled
1224 // on the current channel. 1224 // on the current channel.
1225 ScopedCurrentChannel sc(chrome::VersionInfo::CHANNEL_CANARY); 1225 ScopedCurrentChannel sc(version_info::Channel::CANARY);
1226 1226
1227 // First verify that declarativeWebRequest produces a message when host 1227 // First verify that declarativeWebRequest produces a message when host
1228 // permissions do not cover all hosts. 1228 // permissions do not cover all hosts.
1229 scoped_refptr<Extension> extension = 1229 scoped_refptr<Extension> extension =
1230 LoadManifest("permissions", "web_request_not_all_host_permissions.json"); 1230 LoadManifest("permissions", "web_request_not_all_host_permissions.json");
1231 const PermissionSet* set = 1231 const PermissionSet* set =
1232 extension->permissions_data()->active_permissions().get(); 1232 extension->permissions_data()->active_permissions().get();
1233 EXPECT_TRUE(VerifyHasPermissionMessage(set, extension->GetType(), 1233 EXPECT_TRUE(VerifyHasPermissionMessage(set, extension->GetType(),
1234 "Block parts of web pages")); 1234 "Block parts of web pages"));
1235 EXPECT_FALSE(VerifyHasPermissionMessage( 1235 EXPECT_FALSE(VerifyHasPermissionMessage(
(...skipping 17 matching lines...) Expand all
1253 LoadManifest("permissions", "serial.json"); 1253 LoadManifest("permissions", "serial.json");
1254 1254
1255 EXPECT_TRUE(extension->is_platform_app()); 1255 EXPECT_TRUE(extension->is_platform_app());
1256 EXPECT_TRUE( 1256 EXPECT_TRUE(
1257 extension->permissions_data()->HasAPIPermission(APIPermission::kSerial)); 1257 extension->permissions_data()->HasAPIPermission(APIPermission::kSerial));
1258 EXPECT_TRUE(VerifyOnePermissionMessage(extension->permissions_data(), 1258 EXPECT_TRUE(VerifyOnePermissionMessage(extension->permissions_data(),
1259 "Access your serial devices")); 1259 "Access your serial devices"));
1260 } 1260 }
1261 1261
1262 TEST(PermissionsTest, GetWarningMessages_Socket_AnyHost) { 1262 TEST(PermissionsTest, GetWarningMessages_Socket_AnyHost) {
1263 ScopedCurrentChannel channel(chrome::VersionInfo::CHANNEL_DEV); 1263 ScopedCurrentChannel channel(version_info::Channel::DEV);
1264 1264
1265 scoped_refptr<Extension> extension = 1265 scoped_refptr<Extension> extension =
1266 LoadManifest("permissions", "socket_any_host.json"); 1266 LoadManifest("permissions", "socket_any_host.json");
1267 EXPECT_TRUE(extension->is_platform_app()); 1267 EXPECT_TRUE(extension->is_platform_app());
1268 EXPECT_TRUE( 1268 EXPECT_TRUE(
1269 extension->permissions_data()->HasAPIPermission(APIPermission::kSocket)); 1269 extension->permissions_data()->HasAPIPermission(APIPermission::kSocket));
1270 EXPECT_TRUE(VerifyOnePermissionMessage( 1270 EXPECT_TRUE(VerifyOnePermissionMessage(
1271 extension->permissions_data(), 1271 extension->permissions_data(),
1272 "Exchange data with any device on the local network or internet")); 1272 "Exchange data with any device on the local network or internet"));
1273 } 1273 }
1274 1274
1275 TEST(PermissionsTest, GetWarningMessages_Socket_OneDomainTwoHostnames) { 1275 TEST(PermissionsTest, GetWarningMessages_Socket_OneDomainTwoHostnames) {
1276 ScopedCurrentChannel channel(chrome::VersionInfo::CHANNEL_DEV); 1276 ScopedCurrentChannel channel(version_info::Channel::DEV);
1277 1277
1278 scoped_refptr<Extension> extension = 1278 scoped_refptr<Extension> extension =
1279 LoadManifest("permissions", "socket_one_domain_two_hostnames.json"); 1279 LoadManifest("permissions", "socket_one_domain_two_hostnames.json");
1280 EXPECT_TRUE(extension->is_platform_app()); 1280 EXPECT_TRUE(extension->is_platform_app());
1281 EXPECT_TRUE( 1281 EXPECT_TRUE(
1282 extension->permissions_data()->HasAPIPermission(APIPermission::kSocket)); 1282 extension->permissions_data()->HasAPIPermission(APIPermission::kSocket));
1283 1283
1284 // Verify the warnings, including support for unicode characters, the fact 1284 // Verify the warnings, including support for unicode characters, the fact
1285 // that domain host warnings come before specific host warnings, and the fact 1285 // that domain host warnings come before specific host warnings, and the fact
1286 // that domains and hostnames are in alphabetical order regardless of the 1286 // that domains and hostnames are in alphabetical order regardless of the
1287 // order in the manifest file. 1287 // order in the manifest file.
1288 EXPECT_TRUE(VerifyTwoPermissionMessages( 1288 EXPECT_TRUE(VerifyTwoPermissionMessages(
1289 extension->permissions_data(), 1289 extension->permissions_data(),
1290 "Exchange data with any device in the domain example.org", 1290 "Exchange data with any device in the domain example.org",
1291 "Exchange data with the devices named: " 1291 "Exchange data with the devices named: "
1292 "b\xC3\xA5r.example.com foo.example.com", 1292 "b\xC3\xA5r.example.com foo.example.com",
1293 // "\xC3\xA5" = UTF-8 for lowercase A with ring above 1293 // "\xC3\xA5" = UTF-8 for lowercase A with ring above
1294 true)); 1294 true));
1295 } 1295 }
1296 1296
1297 TEST(PermissionsTest, GetWarningMessages_Socket_TwoDomainsOneHostname) { 1297 TEST(PermissionsTest, GetWarningMessages_Socket_TwoDomainsOneHostname) {
1298 ScopedCurrentChannel channel(chrome::VersionInfo::CHANNEL_DEV); 1298 ScopedCurrentChannel channel(version_info::Channel::DEV);
1299 1299
1300 scoped_refptr<Extension> extension = 1300 scoped_refptr<Extension> extension =
1301 LoadManifest("permissions", "socket_two_domains_one_hostname.json"); 1301 LoadManifest("permissions", "socket_two_domains_one_hostname.json");
1302 EXPECT_TRUE(extension->is_platform_app()); 1302 EXPECT_TRUE(extension->is_platform_app());
1303 EXPECT_TRUE( 1303 EXPECT_TRUE(
1304 extension->permissions_data()->HasAPIPermission(APIPermission::kSocket)); 1304 extension->permissions_data()->HasAPIPermission(APIPermission::kSocket));
1305 1305
1306 // Verify the warnings, including the fact that domain host warnings come 1306 // Verify the warnings, including the fact that domain host warnings come
1307 // before specific host warnings and the fact that domains and hostnames are 1307 // before specific host warnings and the fact that domains and hostnames are
1308 // in alphabetical order regardless of the order in the manifest file. 1308 // in alphabetical order regardless of the order in the manifest file.
(...skipping 492 matching lines...) Expand 10 before | Expand all | Expand 10 after
1801 scoped_refptr<const PermissionSet> permissions_dwr( 1801 scoped_refptr<const PermissionSet> permissions_dwr(
1802 extension_dwr->permissions_data()->active_permissions()); 1802 extension_dwr->permissions_data()->active_permissions());
1803 1803
1804 EXPECT_FALSE(PermissionMessageProvider::Get()-> 1804 EXPECT_FALSE(PermissionMessageProvider::Get()->
1805 IsPrivilegeIncrease(permissions.get(), 1805 IsPrivilegeIncrease(permissions.get(),
1806 permissions_dwr.get(), 1806 permissions_dwr.get(),
1807 extension->GetType())); 1807 extension->GetType()));
1808 } 1808 }
1809 1809
1810 } // namespace extensions 1810 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/common/extensions/manifest_tests/extension_manifests_background_unittest.cc ('k') | chrome/common/gcm_desktop_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698