OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/message_loop.h" | 5 #include "base/message_loop.h" |
6 #include "base/path_service.h" | 6 #include "base/path_service.h" |
7 #include "base/scoped_temp_dir.h" | 7 #include "base/scoped_temp_dir.h" |
8 #include "base/stl_util.h" | 8 #include "base/stl_util.h" |
9 #include "base/string_number_conversions.h" | 9 #include "base/string_number_conversions.h" |
10 #include "base/stringprintf.h" | 10 #include "base/stringprintf.h" |
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
314 URLPatternSet shost_perm_set1_; | 314 URLPatternSet shost_perm_set1_; |
315 URLPatternSet shost_perm_set2_; | 315 URLPatternSet shost_perm_set2_; |
316 | 316 |
317 ExtensionAPIPermissionSet api_permissions_; | 317 ExtensionAPIPermissionSet api_permissions_; |
318 URLPatternSet ehost_permissions_; | 318 URLPatternSet ehost_permissions_; |
319 URLPatternSet shost_permissions_; | 319 URLPatternSet shost_permissions_; |
320 URLPatternSet effective_permissions_; | 320 URLPatternSet effective_permissions_; |
321 }; | 321 }; |
322 TEST_F(ExtensionPrefsGrantedPermissions, GrantedPermissions) {} | 322 TEST_F(ExtensionPrefsGrantedPermissions, GrantedPermissions) {} |
323 | 323 |
| 324 // Tests the SetActivePermissions / GetActivePermissions functions. |
| 325 class ExtensionPrefsActivePermissions : public ExtensionPrefsTest { |
| 326 public: |
| 327 virtual void Initialize() { |
| 328 extension_id_ = prefs_.AddExtensionAndReturnId("test"); |
| 329 |
| 330 ExtensionAPIPermissionSet api_perms; |
| 331 api_perms.insert(ExtensionAPIPermission::kTab); |
| 332 api_perms.insert(ExtensionAPIPermission::kBookmark); |
| 333 api_perms.insert(ExtensionAPIPermission::kHistory); |
| 334 |
| 335 URLPatternSet ehosts; |
| 336 AddPattern(&ehosts, "http://*.google.com/*"); |
| 337 AddPattern(&ehosts, "http://example.com/*"); |
| 338 AddPattern(&ehosts, "chrome://favicon/*"); |
| 339 |
| 340 URLPatternSet shosts; |
| 341 AddPattern(&shosts, "https://*.google.com/*"); |
| 342 AddPattern(&shosts, "http://reddit.com/r/test/*"); |
| 343 |
| 344 active_perms_.reset(new ExtensionPermissionSet(api_perms, ehosts, shosts)); |
| 345 |
| 346 // Make sure the active permissions start empty. |
| 347 scoped_ptr<ExtensionPermissionSet> active( |
| 348 prefs()->GetActivePermissions(extension_id_)); |
| 349 EXPECT_TRUE(active->IsEmpty()); |
| 350 |
| 351 // Set the active permissions. |
| 352 prefs()->SetActivePermissions(extension_id_, active_perms_.get()); |
| 353 active.reset(prefs()->GetActivePermissions(extension_id_)); |
| 354 EXPECT_EQ(active_perms_->apis(), active->apis()); |
| 355 EXPECT_EQ(active_perms_->explicit_hosts(), active->explicit_hosts()); |
| 356 EXPECT_EQ(active_perms_->scriptable_hosts(), active->scriptable_hosts()); |
| 357 EXPECT_EQ(*active_perms_, *active); |
| 358 } |
| 359 |
| 360 virtual void Verify() { |
| 361 scoped_ptr<ExtensionPermissionSet> permissions( |
| 362 prefs()->GetActivePermissions(extension_id_)); |
| 363 EXPECT_EQ(*active_perms_, *permissions); |
| 364 } |
| 365 |
| 366 private: |
| 367 std::string extension_id_; |
| 368 scoped_ptr<ExtensionPermissionSet> active_perms_; |
| 369 }; |
| 370 TEST_F(ExtensionPrefsActivePermissions, SetAndGetActivePermissions) {} |
| 371 |
324 // Tests the GetVersionString function. | 372 // Tests the GetVersionString function. |
325 class ExtensionPrefsVersionString : public ExtensionPrefsTest { | 373 class ExtensionPrefsVersionString : public ExtensionPrefsTest { |
326 public: | 374 public: |
327 virtual void Initialize() { | 375 virtual void Initialize() { |
328 extension = prefs_.AddExtension("test"); | 376 extension = prefs_.AddExtension("test"); |
329 EXPECT_EQ("0.1", prefs()->GetVersionString(extension->id())); | 377 EXPECT_EQ("0.1", prefs()->GetVersionString(extension->id())); |
330 prefs()->OnExtensionUninstalled(extension->id(), | 378 prefs()->OnExtensionUninstalled(extension->id(), |
331 Extension::INTERNAL, false); | 379 Extension::INTERNAL, false); |
332 } | 380 } |
333 | 381 |
(...skipping 649 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
983 testing::Mock::VerifyAndClearExpectations(v1i); | 1031 testing::Mock::VerifyAndClearExpectations(v1i); |
984 testing::Mock::VerifyAndClearExpectations(v2); | 1032 testing::Mock::VerifyAndClearExpectations(v2); |
985 testing::Mock::VerifyAndClearExpectations(v2i); | 1033 testing::Mock::VerifyAndClearExpectations(v2i); |
986 } | 1034 } |
987 | 1035 |
988 virtual void Verify() { | 1036 virtual void Verify() { |
989 } | 1037 } |
990 }; | 1038 }; |
991 TEST_F(ExtensionPrefsSetExtensionControlledPref, | 1039 TEST_F(ExtensionPrefsSetExtensionControlledPref, |
992 ExtensionPrefsSetExtensionControlledPref) {} | 1040 ExtensionPrefsSetExtensionControlledPref) {} |
OLD | NEW |