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

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

Issue 8202011: Notify users about certain changes in installed extensions. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Change #if false to #if 0 for win compiler. Created 9 years, 2 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) 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 425 matching lines...) Expand 10 before | Expand all | Expand 10 after
436 } 436 }
437 437
438 private: 438 private:
439 ExtensionList extensions_; 439 ExtensionList extensions_;
440 440
441 // An id we'll make up that doesn't match any installed extension id. 441 // An id we'll make up that doesn't match any installed extension id.
442 std::string not_installed_id_; 442 std::string not_installed_id_;
443 }; 443 };
444 TEST_F(ExtensionPrefsBlacklist, Blacklist) {} 444 TEST_F(ExtensionPrefsBlacklist, Blacklist) {}
445 445
446 class ExtensionPrefsAcknowledgment : public ExtensionPrefsTest {
447 public:
448 virtual void Initialize() {
449 not_installed_id_ = "pghjnghklobnfoidcldiidjjjhkeeaoi";
450
451 // Install some extensions.
452 for (int i = 0; i < 5; i++) {
453 std::string name = "test" + base::IntToString(i);
454 extensions_.push_back(prefs_.AddExtension(name));
455 }
456 EXPECT_EQ(NULL, prefs()->GetInstalledExtensionInfo(not_installed_id_));
457
458 ExtensionList::const_iterator iter;
459 for (iter = extensions_.begin(); iter != extensions_.end(); ++iter) {
460 std::string id = (*iter)->id();
461 EXPECT_FALSE(prefs()->IsExternalExtensionAcknowledged(id));
462 EXPECT_FALSE(prefs()->IsBlacklistedExtensionAcknowledged(id));
463 EXPECT_FALSE(prefs()->IsOrphanedExtensionAcknowledged(id));
464 if (external_id_.empty()) {
465 external_id_ = id;
466 continue;
467 }
468 if (blacklisted_id_.empty()) {
469 blacklisted_id_ = id;
470 continue;
471 }
472 if (orphaned_id_.empty()) {
473 orphaned_id_ = id;
474 continue;
475 }
476 }
477 // For each type of acknowledgment, acknowledge one installed and one
478 // not-installed extension id.
479 prefs()->AcknowledgeExternalExtension(external_id_);
480 prefs()->AcknowledgeBlacklistedExtension(blacklisted_id_);
481 prefs()->AcknowledgeOrphanedExtension(orphaned_id_);
482 prefs()->AcknowledgeExternalExtension(not_installed_id_);
483 prefs()->AcknowledgeBlacklistedExtension(not_installed_id_);
484 prefs()->AcknowledgeOrphanedExtension(not_installed_id_);
485 }
486
487 virtual void Verify() {
488 ExtensionList::const_iterator iter;
489 for (iter = extensions_.begin(); iter != extensions_.end(); ++iter) {
490 std::string id = (*iter)->id();
491 if (id == external_id_) {
492 EXPECT_TRUE(prefs()->IsExternalExtensionAcknowledged(id));
493 } else {
494 EXPECT_FALSE(prefs()->IsExternalExtensionAcknowledged(id));
495 }
496 if (id == blacklisted_id_) {
497 EXPECT_TRUE(prefs()->IsBlacklistedExtensionAcknowledged(id));
498 } else {
499 EXPECT_FALSE(prefs()->IsBlacklistedExtensionAcknowledged(id));
500 }
501 if (id == orphaned_id_) {
502 EXPECT_TRUE(prefs()->IsOrphanedExtensionAcknowledged(id));
503 } else {
504 EXPECT_FALSE(prefs()->IsOrphanedExtensionAcknowledged(id));
505 }
506 }
507 EXPECT_TRUE(prefs()->IsExternalExtensionAcknowledged(not_installed_id_));
508 EXPECT_TRUE(prefs()->IsBlacklistedExtensionAcknowledged(not_installed_id_));
509 EXPECT_TRUE(prefs()->IsOrphanedExtensionAcknowledged(not_installed_id_));
510 }
511
512 private:
513 ExtensionList extensions_;
514
515 std::string not_installed_id_;
516 std::string external_id_;
517 std::string blacklisted_id_;
518 std::string orphaned_id_;
519 };
520 TEST_F(ExtensionPrefsAcknowledgment, Acknowledgment) {}
521
446 // Tests force hiding browser actions. 522 // Tests force hiding browser actions.
447 class ExtensionPrefsHidingBrowserActions : public ExtensionPrefsTest { 523 class ExtensionPrefsHidingBrowserActions : public ExtensionPrefsTest {
448 public: 524 public:
449 virtual void Initialize() { 525 virtual void Initialize() {
450 // Install 5 extensions. 526 // Install 5 extensions.
451 for (int i = 0; i < 5; i++) { 527 for (int i = 0; i < 5; i++) {
452 std::string name = "test" + base::IntToString(i); 528 std::string name = "test" + base::IntToString(i);
453 extensions_.push_back(prefs_.AddExtension(name)); 529 extensions_.push_back(prefs_.AddExtension(name));
454 } 530 }
455 531
(...skipping 676 matching lines...) Expand 10 before | Expand all | Expand 10 after
1132 ++iteration_; 1208 ++iteration_;
1133 } else { 1209 } else {
1134 EXPECT_EQ(kDefaultPref1, actual); 1210 EXPECT_EQ(kDefaultPref1, actual);
1135 } 1211 }
1136 } 1212 }
1137 1213
1138 private: 1214 private:
1139 int iteration_; 1215 int iteration_;
1140 }; 1216 };
1141 TEST_F(ExtensionPrefsDisableExtensions, ExtensionPrefsDisableExtensions) {} 1217 TEST_F(ExtensionPrefsDisableExtensions, ExtensionPrefsDisableExtensions) {}
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_prefs.cc ('k') | chrome/browser/extensions/extension_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698