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

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

Issue 1078543002: [Extensions] Make extension message bubble factory platform-abstract (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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/strings/string_number_conversions.h" 6 #include "base/strings/string_number_conversions.h"
7 #include "base/strings/string_util.h" 7 #include "base/strings/string_util.h"
8 #include "base/strings/utf_string_conversions.h" 8 #include "base/strings/utf_string_conversions.h"
9 #include "base/values.h" 9 #include "base/values.h"
10 #include "chrome/browser/extensions/dev_mode_bubble_controller.h" 10 #include "chrome/browser/extensions/dev_mode_bubble_controller.h"
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 // what should happen when the bubble is "shown" (the bubble is actually not 200 // what should happen when the bubble is "shown" (the bubble is actually not
201 // shown, the corresponding action is taken immediately). 201 // shown, the corresponding action is taken immediately).
202 class FakeExtensionMessageBubble : public ExtensionMessageBubble { 202 class FakeExtensionMessageBubble : public ExtensionMessageBubble {
203 public: 203 public:
204 enum ExtensionBubbleAction { 204 enum ExtensionBubbleAction {
205 BUBBLE_ACTION_CLICK_ACTION_BUTTON = 0, 205 BUBBLE_ACTION_CLICK_ACTION_BUTTON = 0,
206 BUBBLE_ACTION_CLICK_DISMISS_BUTTON, 206 BUBBLE_ACTION_CLICK_DISMISS_BUTTON,
207 BUBBLE_ACTION_CLICK_LINK, 207 BUBBLE_ACTION_CLICK_LINK,
208 }; 208 };
209 209
210 FakeExtensionMessageBubble() {} 210 FakeExtensionMessageBubble() : controller_(nullptr) {}
211 211
212 void set_action_on_show(ExtensionBubbleAction action) { 212 void set_action_on_show(ExtensionBubbleAction action) {
213 action_ = action; 213 action_ = action;
214 } 214 }
215 void set_controller(ExtensionMessageBubbleController* controller) {
216 controller_ = controller;
217 }
215 218
216 void Show() override { 219 void Show() override {
217 if (action_ == BUBBLE_ACTION_CLICK_ACTION_BUTTON) 220 if (action_ == BUBBLE_ACTION_CLICK_ACTION_BUTTON)
218 action_callback_.Run(); 221 controller_->OnBubbleAction();
219 else if (action_ == BUBBLE_ACTION_CLICK_DISMISS_BUTTON) 222 else if (action_ == BUBBLE_ACTION_CLICK_DISMISS_BUTTON)
220 dismiss_callback_.Run(); 223 controller_->OnBubbleDismiss();
221 else if (action_ == BUBBLE_ACTION_CLICK_LINK) 224 else if (action_ == BUBBLE_ACTION_CLICK_LINK)
222 link_callback_.Run(); 225 controller_->OnLinkClicked();
223 }
224
225 void OnActionButtonClicked(const base::Closure& callback) override {
226 action_callback_ = callback;
227 }
228
229 void OnDismissButtonClicked(const base::Closure& callback) override {
230 dismiss_callback_ = callback;
231 }
232
233 void OnLinkClicked(const base::Closure& callback) override {
234 link_callback_ = callback;
235 } 226 }
236 227
237 private: 228 private:
238 ExtensionBubbleAction action_; 229 ExtensionBubbleAction action_;
230 ExtensionMessageBubbleController* controller_;
239 231
240 base::Closure action_callback_; 232 DISALLOW_COPY_AND_ASSIGN(FakeExtensionMessageBubble);
241 base::Closure dismiss_callback_;
242 base::Closure link_callback_;
243 }; 233 };
244 234
245 class ExtensionMessageBubbleTest : public testing::Test { 235 class ExtensionMessageBubbleTest : public testing::Test {
246 public: 236 public:
247 ExtensionMessageBubbleTest() {} 237 ExtensionMessageBubbleTest() {}
248 238
249 testing::AssertionResult LoadGenericExtension(const std::string& index, 239 testing::AssertionResult LoadGenericExtension(const std::string& index,
250 const std::string& id, 240 const std::string& id,
251 Manifest::Location location) { 241 Manifest::Location location) {
252 ExtensionBuilder builder; 242 ExtensionBuilder builder;
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
423 ExtensionService* service_; 413 ExtensionService* service_;
424 414
425 private: 415 private:
426 scoped_ptr<base::CommandLine> command_line_; 416 scoped_ptr<base::CommandLine> command_line_;
427 scoped_ptr<content::TestBrowserThreadBundle> thread_bundle_; 417 scoped_ptr<content::TestBrowserThreadBundle> thread_bundle_;
428 scoped_ptr<TestingProfile> profile_; 418 scoped_ptr<TestingProfile> profile_;
429 419
430 DISALLOW_COPY_AND_ASSIGN(ExtensionMessageBubbleTest); 420 DISALLOW_COPY_AND_ASSIGN(ExtensionMessageBubbleTest);
431 }; 421 };
432 422
433 // The feature this is meant to test is only implemented on Windows. 423 // The feature this is meant to test is only enacted on Windows, but it should
434 #if defined(OS_WIN) 424 // pass on all platforms.
435 #define MAYBE_WipeoutControllerTest WipeoutControllerTest 425 TEST_F(ExtensionMessageBubbleTest, WipeoutControllerTest) {
436 #else
437 #define MAYBE_WipeoutControllerTest DISABLED_WipeoutControllerTest
438 #endif
439
440 TEST_F(ExtensionMessageBubbleTest, MAYBE_WipeoutControllerTest) {
441 Init(); 426 Init();
442 // Add three extensions, and control two of them in this test (extension 1 427 // Add three extensions, and control two of them in this test (extension 1
443 // and 2). 428 // and 2).
444 ASSERT_TRUE(LoadExtensionWithAction("1", kId1, Manifest::COMMAND_LINE)); 429 ASSERT_TRUE(LoadExtensionWithAction("1", kId1, Manifest::COMMAND_LINE));
445 ASSERT_TRUE(LoadGenericExtension("2", kId2, Manifest::UNPACKED)); 430 ASSERT_TRUE(LoadGenericExtension("2", kId2, Manifest::UNPACKED));
446 ASSERT_TRUE(LoadGenericExtension("3", kId3, Manifest::EXTERNAL_POLICY)); 431 ASSERT_TRUE(LoadGenericExtension("3", kId3, Manifest::EXTERNAL_POLICY));
447 432
448 scoped_ptr<TestSuspiciousExtensionBubbleController> controller( 433 scoped_ptr<TestSuspiciousExtensionBubbleController> controller(
449 new TestSuspiciousExtensionBubbleController(profile())); 434 new TestSuspiciousExtensionBubbleController(profile()));
450 FakeExtensionMessageBubble bubble; 435 FakeExtensionMessageBubble bubble;
(...skipping 16 matching lines...) Expand all
467 452
468 EXPECT_FALSE(controller->delegate()->HasBubbleInfoBeenAcknowledged(kId1)); 453 EXPECT_FALSE(controller->delegate()->HasBubbleInfoBeenAcknowledged(kId1));
469 EXPECT_FALSE(controller->delegate()->HasBubbleInfoBeenAcknowledged(kId2)); 454 EXPECT_FALSE(controller->delegate()->HasBubbleInfoBeenAcknowledged(kId2));
470 controller.reset(new TestSuspiciousExtensionBubbleController( 455 controller.reset(new TestSuspiciousExtensionBubbleController(
471 profile())); 456 profile()));
472 SuspiciousExtensionBubbleController::ClearProfileListForTesting(); 457 SuspiciousExtensionBubbleController::ClearProfileListForTesting();
473 EXPECT_TRUE(controller->ShouldShow()); 458 EXPECT_TRUE(controller->ShouldShow());
474 suspicious_extensions = controller->GetExtensionList(); 459 suspicious_extensions = controller->GetExtensionList();
475 ASSERT_EQ(1U, suspicious_extensions.size()); 460 ASSERT_EQ(1U, suspicious_extensions.size());
476 EXPECT_TRUE(base::ASCIIToUTF16("Extension 1") == suspicious_extensions[0]); 461 EXPECT_TRUE(base::ASCIIToUTF16("Extension 1") == suspicious_extensions[0]);
462 bubble.set_controller(controller.get());
477 controller->Show(&bubble); // Simulate showing the bubble. 463 controller->Show(&bubble); // Simulate showing the bubble.
478 EXPECT_EQ(0U, controller->link_click_count()); 464 EXPECT_EQ(0U, controller->link_click_count());
479 EXPECT_EQ(1U, controller->dismiss_click_count()); 465 EXPECT_EQ(1U, controller->dismiss_click_count());
480 // Now the acknowledge flag should be set only for the first extension. 466 // Now the acknowledge flag should be set only for the first extension.
481 EXPECT_TRUE(controller->delegate()->HasBubbleInfoBeenAcknowledged(kId1)); 467 EXPECT_TRUE(controller->delegate()->HasBubbleInfoBeenAcknowledged(kId1));
482 EXPECT_FALSE(controller->delegate()->HasBubbleInfoBeenAcknowledged(kId2)); 468 EXPECT_FALSE(controller->delegate()->HasBubbleInfoBeenAcknowledged(kId2));
483 // Clear the flag. 469 // Clear the flag.
484 controller->delegate()->SetBubbleInfoBeenAcknowledged(kId1, false); 470 controller->delegate()->SetBubbleInfoBeenAcknowledged(kId1, false);
485 EXPECT_FALSE(controller->delegate()->HasBubbleInfoBeenAcknowledged(kId1)); 471 EXPECT_FALSE(controller->delegate()->HasBubbleInfoBeenAcknowledged(kId1));
486 472
487 // Now disable the other extension and exercise the link click code path. 473 // Now disable the other extension and exercise the link click code path.
488 service_->DisableExtension(kId2, Extension::DISABLE_NOT_VERIFIED); 474 service_->DisableExtension(kId2, Extension::DISABLE_NOT_VERIFIED);
489 475
490 bubble.set_action_on_show( 476 bubble.set_action_on_show(
491 FakeExtensionMessageBubble::BUBBLE_ACTION_CLICK_LINK); 477 FakeExtensionMessageBubble::BUBBLE_ACTION_CLICK_LINK);
492 controller.reset(new TestSuspiciousExtensionBubbleController( 478 controller.reset(new TestSuspiciousExtensionBubbleController(
493 profile())); 479 profile()));
494 SuspiciousExtensionBubbleController::ClearProfileListForTesting(); 480 SuspiciousExtensionBubbleController::ClearProfileListForTesting();
495 EXPECT_TRUE(controller->ShouldShow()); 481 EXPECT_TRUE(controller->ShouldShow());
496 suspicious_extensions = controller->GetExtensionList(); 482 suspicious_extensions = controller->GetExtensionList();
497 ASSERT_EQ(2U, suspicious_extensions.size()); 483 ASSERT_EQ(2U, suspicious_extensions.size());
498 EXPECT_TRUE(base::ASCIIToUTF16("Extension 1") == suspicious_extensions[1]); 484 EXPECT_TRUE(base::ASCIIToUTF16("Extension 1") == suspicious_extensions[1]);
499 EXPECT_TRUE(base::ASCIIToUTF16("Extension 2") == suspicious_extensions[0]); 485 EXPECT_TRUE(base::ASCIIToUTF16("Extension 2") == suspicious_extensions[0]);
486 bubble.set_controller(controller.get());
500 controller->Show(&bubble); // Simulate showing the bubble. 487 controller->Show(&bubble); // Simulate showing the bubble.
501 EXPECT_EQ(1U, controller->link_click_count()); 488 EXPECT_EQ(1U, controller->link_click_count());
502 EXPECT_EQ(0U, controller->dismiss_click_count()); 489 EXPECT_EQ(0U, controller->dismiss_click_count());
503 EXPECT_TRUE(controller->delegate()->HasBubbleInfoBeenAcknowledged(kId1)); 490 EXPECT_TRUE(controller->delegate()->HasBubbleInfoBeenAcknowledged(kId1));
504 } 491 }
505 492
506 // The feature this is meant to test is only implemented on Windows. 493 // The feature this is meant to test is only enacted on Windows, but it should
507 #if defined(OS_WIN) 494 // pass on all platforms.
508 #define MAYBE_DevModeControllerTest DevModeControllerTest 495 TEST_F(ExtensionMessageBubbleTest, DevModeControllerTest) {
509 #else
510 #define MAYBE_DevModeControllerTest DISABLED_DevModeControllerTest
511 #endif
512
513 TEST_F(ExtensionMessageBubbleTest, MAYBE_DevModeControllerTest) {
514 FeatureSwitch::ScopedOverride force_dev_mode_highlighting( 496 FeatureSwitch::ScopedOverride force_dev_mode_highlighting(
515 FeatureSwitch::force_dev_mode_highlighting(), true); 497 FeatureSwitch::force_dev_mode_highlighting(), true);
516 Init(); 498 Init();
517 // Add three extensions, and control two of them in this test (extension 1 499 // Add three extensions, and control two of them in this test (extension 1
518 // and 2). Extension 1 is a regular extension, Extension 2 is UNPACKED so it 500 // and 2). Extension 1 is a regular extension, Extension 2 is UNPACKED so it
519 // counts as a DevMode extension. 501 // counts as a DevMode extension.
520 ASSERT_TRUE(LoadExtensionWithAction("1", kId1, Manifest::COMMAND_LINE)); 502 ASSERT_TRUE(LoadExtensionWithAction("1", kId1, Manifest::COMMAND_LINE));
521 ASSERT_TRUE(LoadGenericExtension("2", kId2, Manifest::UNPACKED)); 503 ASSERT_TRUE(LoadGenericExtension("2", kId2, Manifest::UNPACKED));
522 ASSERT_TRUE(LoadGenericExtension("3", kId3, Manifest::EXTERNAL_POLICY)); 504 ASSERT_TRUE(LoadGenericExtension("3", kId3, Manifest::EXTERNAL_POLICY));
523 505
524 scoped_ptr<TestDevModeBubbleController> controller( 506 scoped_ptr<TestDevModeBubbleController> controller(
525 new TestDevModeBubbleController(profile())); 507 new TestDevModeBubbleController(profile()));
526 508
527 // The list will contain one enabled unpacked extension. 509 // The list will contain one enabled unpacked extension.
528 EXPECT_TRUE(controller->ShouldShow()); 510 EXPECT_TRUE(controller->ShouldShow());
529 std::vector<base::string16> dev_mode_extensions = 511 std::vector<base::string16> dev_mode_extensions =
530 controller->GetExtensionList(); 512 controller->GetExtensionList();
531 ASSERT_EQ(2U, dev_mode_extensions.size()); 513 ASSERT_EQ(2U, dev_mode_extensions.size());
532 EXPECT_TRUE(base::ASCIIToUTF16("Extension 2") == dev_mode_extensions[0]); 514 EXPECT_TRUE(base::ASCIIToUTF16("Extension 2") == dev_mode_extensions[0]);
533 EXPECT_TRUE(base::ASCIIToUTF16("Extension 1") == dev_mode_extensions[1]); 515 EXPECT_TRUE(base::ASCIIToUTF16("Extension 1") == dev_mode_extensions[1]);
534 EXPECT_EQ(0U, controller->link_click_count()); 516 EXPECT_EQ(0U, controller->link_click_count());
535 EXPECT_EQ(0U, controller->dismiss_click_count()); 517 EXPECT_EQ(0U, controller->dismiss_click_count());
536 EXPECT_EQ(0U, controller->action_click_count()); 518 EXPECT_EQ(0U, controller->action_click_count());
537 519
538 // Simulate showing the bubble. 520 // Simulate showing the bubble.
539 FakeExtensionMessageBubble bubble; 521 FakeExtensionMessageBubble bubble;
540 bubble.set_action_on_show( 522 bubble.set_action_on_show(
541 FakeExtensionMessageBubble::BUBBLE_ACTION_CLICK_DISMISS_BUTTON); 523 FakeExtensionMessageBubble::BUBBLE_ACTION_CLICK_DISMISS_BUTTON);
524 bubble.set_controller(controller.get());
542 controller->Show(&bubble); 525 controller->Show(&bubble);
543 EXPECT_EQ(0U, controller->link_click_count()); 526 EXPECT_EQ(0U, controller->link_click_count());
544 EXPECT_EQ(0U, controller->action_click_count()); 527 EXPECT_EQ(0U, controller->action_click_count());
545 EXPECT_EQ(1U, controller->dismiss_click_count()); 528 EXPECT_EQ(1U, controller->dismiss_click_count());
546 ExtensionRegistry* registry = ExtensionRegistry::Get(profile()); 529 ExtensionRegistry* registry = ExtensionRegistry::Get(profile());
547 EXPECT_TRUE(registry->enabled_extensions().GetByID(kId1) != NULL); 530 EXPECT_TRUE(registry->enabled_extensions().GetByID(kId1) != NULL);
548 EXPECT_TRUE(registry->enabled_extensions().GetByID(kId2) != NULL); 531 EXPECT_TRUE(registry->enabled_extensions().GetByID(kId2) != NULL);
549 532
550 // Do it again, but now press different button (Disable). 533 // Do it again, but now press different button (Disable).
551 bubble.set_action_on_show( 534 bubble.set_action_on_show(
552 FakeExtensionMessageBubble::BUBBLE_ACTION_CLICK_ACTION_BUTTON); 535 FakeExtensionMessageBubble::BUBBLE_ACTION_CLICK_ACTION_BUTTON);
553 controller.reset(new TestDevModeBubbleController( 536 controller.reset(new TestDevModeBubbleController(
554 profile())); 537 profile()));
555 DevModeBubbleController::ClearProfileListForTesting(); 538 DevModeBubbleController::ClearProfileListForTesting();
556 EXPECT_TRUE(controller->ShouldShow()); 539 EXPECT_TRUE(controller->ShouldShow());
557 dev_mode_extensions = controller->GetExtensionList(); 540 dev_mode_extensions = controller->GetExtensionList();
558 EXPECT_EQ(2U, dev_mode_extensions.size()); 541 EXPECT_EQ(2U, dev_mode_extensions.size());
542 bubble.set_controller(controller.get());
559 controller->Show(&bubble); // Simulate showing the bubble. 543 controller->Show(&bubble); // Simulate showing the bubble.
560 EXPECT_EQ(0U, controller->link_click_count()); 544 EXPECT_EQ(0U, controller->link_click_count());
561 EXPECT_EQ(1U, controller->action_click_count()); 545 EXPECT_EQ(1U, controller->action_click_count());
562 EXPECT_EQ(0U, controller->dismiss_click_count()); 546 EXPECT_EQ(0U, controller->dismiss_click_count());
563 EXPECT_TRUE(registry->disabled_extensions().GetByID(kId1) != NULL); 547 EXPECT_TRUE(registry->disabled_extensions().GetByID(kId1) != NULL);
564 EXPECT_TRUE(registry->disabled_extensions().GetByID(kId2) != NULL); 548 EXPECT_TRUE(registry->disabled_extensions().GetByID(kId2) != NULL);
565 549
566 // Re-enable the extensions (disabled by the action button above). 550 // Re-enable the extensions (disabled by the action button above).
567 service_->EnableExtension(kId1); 551 service_->EnableExtension(kId1);
568 service_->EnableExtension(kId2); 552 service_->EnableExtension(kId2);
569 553
570 // Show the dialog a third time, but now press the learn more link. 554 // Show the dialog a third time, but now press the learn more link.
571 bubble.set_action_on_show( 555 bubble.set_action_on_show(
572 FakeExtensionMessageBubble::BUBBLE_ACTION_CLICK_LINK); 556 FakeExtensionMessageBubble::BUBBLE_ACTION_CLICK_LINK);
573 controller.reset(new TestDevModeBubbleController( 557 controller.reset(new TestDevModeBubbleController(
574 profile())); 558 profile()));
575 DevModeBubbleController::ClearProfileListForTesting(); 559 DevModeBubbleController::ClearProfileListForTesting();
576 EXPECT_TRUE(controller->ShouldShow()); 560 EXPECT_TRUE(controller->ShouldShow());
577 dev_mode_extensions = controller->GetExtensionList(); 561 dev_mode_extensions = controller->GetExtensionList();
578 EXPECT_EQ(2U, dev_mode_extensions.size()); 562 EXPECT_EQ(2U, dev_mode_extensions.size());
563 bubble.set_controller(controller.get());
579 controller->Show(&bubble); // Simulate showing the bubble. 564 controller->Show(&bubble); // Simulate showing the bubble.
580 EXPECT_EQ(1U, controller->link_click_count()); 565 EXPECT_EQ(1U, controller->link_click_count());
581 EXPECT_EQ(0U, controller->action_click_count()); 566 EXPECT_EQ(0U, controller->action_click_count());
582 EXPECT_EQ(0U, controller->dismiss_click_count()); 567 EXPECT_EQ(0U, controller->dismiss_click_count());
583 EXPECT_TRUE(registry->enabled_extensions().GetByID(kId1) != NULL); 568 EXPECT_TRUE(registry->enabled_extensions().GetByID(kId1) != NULL);
584 EXPECT_TRUE(registry->enabled_extensions().GetByID(kId2) != NULL); 569 EXPECT_TRUE(registry->enabled_extensions().GetByID(kId2) != NULL);
585 570
586 // Now disable the unpacked extension. 571 // Now disable the unpacked extension.
587 service_->DisableExtension(kId1, Extension::DISABLE_USER_ACTION); 572 service_->DisableExtension(kId1, Extension::DISABLE_USER_ACTION);
588 service_->DisableExtension(kId2, Extension::DISABLE_USER_ACTION); 573 service_->DisableExtension(kId2, Extension::DISABLE_USER_ACTION);
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
636 default: 621 default:
637 NOTREACHED(); 622 NOTREACHED();
638 break; 623 break;
639 } 624 }
640 625
641 scoped_ptr<TestSettingsApiBubbleController> controller( 626 scoped_ptr<TestSettingsApiBubbleController> controller(
642 new TestSettingsApiBubbleController( 627 new TestSettingsApiBubbleController(
643 profile(), static_cast<SettingsApiOverrideType>(i))); 628 profile(), static_cast<SettingsApiOverrideType>(i)));
644 629
645 // The list will contain one enabled unpacked extension (ext 2). 630 // The list will contain one enabled unpacked extension (ext 2).
646 EXPECT_TRUE(controller->ShouldShow(kId2)); 631 EXPECT_TRUE(controller->ShouldShow());
647 std::vector<base::string16> override_extensions = 632 std::vector<base::string16> override_extensions =
648 controller->GetExtensionList(); 633 controller->GetExtensionList();
649 ASSERT_EQ(1U, override_extensions.size()); 634 ASSERT_EQ(1U, override_extensions.size());
650 EXPECT_TRUE(base::ASCIIToUTF16("Extension 2") == 635 EXPECT_TRUE(base::ASCIIToUTF16("Extension 2") ==
651 override_extensions[0].c_str()); 636 override_extensions[0].c_str());
652 EXPECT_EQ(0U, controller->link_click_count()); 637 EXPECT_EQ(0U, controller->link_click_count());
653 EXPECT_EQ(0U, controller->dismiss_click_count()); 638 EXPECT_EQ(0U, controller->dismiss_click_count());
654 EXPECT_EQ(0U, controller->action_click_count()); 639 EXPECT_EQ(0U, controller->action_click_count());
655 640
656 // Simulate showing the bubble and dismissing it. 641 // Simulate showing the bubble and dismissing it.
657 FakeExtensionMessageBubble bubble; 642 FakeExtensionMessageBubble bubble;
658 bubble.set_action_on_show( 643 bubble.set_action_on_show(
659 FakeExtensionMessageBubble::BUBBLE_ACTION_CLICK_DISMISS_BUTTON); 644 FakeExtensionMessageBubble::BUBBLE_ACTION_CLICK_DISMISS_BUTTON);
645 bubble.set_controller(controller.get());
660 controller->Show(&bubble); 646 controller->Show(&bubble);
661 EXPECT_EQ(0U, controller->link_click_count()); 647 EXPECT_EQ(0U, controller->link_click_count());
662 EXPECT_EQ(0U, controller->action_click_count()); 648 EXPECT_EQ(0U, controller->action_click_count());
663 EXPECT_EQ(1U, controller->dismiss_click_count()); 649 EXPECT_EQ(1U, controller->dismiss_click_count());
664 // No extension should have become disabled. 650 // No extension should have become disabled.
665 ExtensionRegistry* registry = ExtensionRegistry::Get(profile()); 651 ExtensionRegistry* registry = ExtensionRegistry::Get(profile());
666 EXPECT_TRUE(registry->enabled_extensions().GetByID(kId1) != NULL); 652 EXPECT_TRUE(registry->enabled_extensions().GetByID(kId1) != NULL);
667 EXPECT_TRUE(registry->enabled_extensions().GetByID(kId2) != NULL); 653 EXPECT_TRUE(registry->enabled_extensions().GetByID(kId2) != NULL);
668 EXPECT_TRUE(registry->enabled_extensions().GetByID(kId3) != NULL); 654 EXPECT_TRUE(registry->enabled_extensions().GetByID(kId3) != NULL);
669 // Only extension 2 should have been acknowledged. 655 // Only extension 2 should have been acknowledged.
670 EXPECT_FALSE(controller->delegate()->HasBubbleInfoBeenAcknowledged(kId1)); 656 EXPECT_FALSE(controller->delegate()->HasBubbleInfoBeenAcknowledged(kId1));
671 EXPECT_TRUE(controller->delegate()->HasBubbleInfoBeenAcknowledged(kId2)); 657 EXPECT_TRUE(controller->delegate()->HasBubbleInfoBeenAcknowledged(kId2));
672 EXPECT_FALSE(controller->delegate()->HasBubbleInfoBeenAcknowledged(kId3)); 658 EXPECT_FALSE(controller->delegate()->HasBubbleInfoBeenAcknowledged(kId3));
673 // Clean up after ourselves. 659 // Clean up after ourselves.
674 controller->delegate()->SetBubbleInfoBeenAcknowledged(kId2, false); 660 controller->delegate()->SetBubbleInfoBeenAcknowledged(kId2, false);
675 661
676 // Simulate clicking the learn more link to dismiss it. 662 // Simulate clicking the learn more link to dismiss it.
677 bubble.set_action_on_show( 663 bubble.set_action_on_show(
678 FakeExtensionMessageBubble::BUBBLE_ACTION_CLICK_LINK); 664 FakeExtensionMessageBubble::BUBBLE_ACTION_CLICK_LINK);
679 controller.reset(new TestSettingsApiBubbleController( 665 controller.reset(new TestSettingsApiBubbleController(
680 profile(), static_cast<SettingsApiOverrideType>(i))); 666 profile(), static_cast<SettingsApiOverrideType>(i)));
667 bubble.set_controller(controller.get());
681 controller->Show(&bubble); 668 controller->Show(&bubble);
682 EXPECT_EQ(1U, controller->link_click_count()); 669 EXPECT_EQ(1U, controller->link_click_count());
683 EXPECT_EQ(0U, controller->action_click_count()); 670 EXPECT_EQ(0U, controller->action_click_count());
684 EXPECT_EQ(0U, controller->dismiss_click_count()); 671 EXPECT_EQ(0U, controller->dismiss_click_count());
685 // No extension should have become disabled. 672 // No extension should have become disabled.
686 EXPECT_TRUE(registry->enabled_extensions().GetByID(kId1) != NULL); 673 EXPECT_TRUE(registry->enabled_extensions().GetByID(kId1) != NULL);
687 EXPECT_TRUE(registry->enabled_extensions().GetByID(kId2) != NULL); 674 EXPECT_TRUE(registry->enabled_extensions().GetByID(kId2) != NULL);
688 EXPECT_TRUE(registry->enabled_extensions().GetByID(kId3) != NULL); 675 EXPECT_TRUE(registry->enabled_extensions().GetByID(kId3) != NULL);
689 // Only extension 2 should have been acknowledged. 676 // Only extension 2 should have been acknowledged.
690 EXPECT_FALSE(controller->delegate()->HasBubbleInfoBeenAcknowledged(kId1)); 677 EXPECT_FALSE(controller->delegate()->HasBubbleInfoBeenAcknowledged(kId1));
691 EXPECT_TRUE(controller->delegate()->HasBubbleInfoBeenAcknowledged(kId2)); 678 EXPECT_TRUE(controller->delegate()->HasBubbleInfoBeenAcknowledged(kId2));
692 EXPECT_FALSE(controller->delegate()->HasBubbleInfoBeenAcknowledged(kId3)); 679 EXPECT_FALSE(controller->delegate()->HasBubbleInfoBeenAcknowledged(kId3));
693 // Clean up after ourselves. 680 // Clean up after ourselves.
694 controller->delegate()->SetBubbleInfoBeenAcknowledged(kId2, false); 681 controller->delegate()->SetBubbleInfoBeenAcknowledged(kId2, false);
695 682
696 // Do it again, but now opt to disable the extension. 683 // Do it again, but now opt to disable the extension.
697 bubble.set_action_on_show( 684 bubble.set_action_on_show(
698 FakeExtensionMessageBubble::BUBBLE_ACTION_CLICK_ACTION_BUTTON); 685 FakeExtensionMessageBubble::BUBBLE_ACTION_CLICK_ACTION_BUTTON);
699 controller.reset(new TestSettingsApiBubbleController( 686 controller.reset(new TestSettingsApiBubbleController(
700 profile(), static_cast<SettingsApiOverrideType>(i))); 687 profile(), static_cast<SettingsApiOverrideType>(i)));
701 EXPECT_TRUE(controller->ShouldShow(kId2)); 688 EXPECT_TRUE(controller->ShouldShow());
702 override_extensions = controller->GetExtensionList(); 689 override_extensions = controller->GetExtensionList();
703 EXPECT_EQ(1U, override_extensions.size()); 690 EXPECT_EQ(1U, override_extensions.size());
691 bubble.set_controller(controller.get());
704 controller->Show(&bubble); // Simulate showing the bubble. 692 controller->Show(&bubble); // Simulate showing the bubble.
705 EXPECT_EQ(0U, controller->link_click_count()); 693 EXPECT_EQ(0U, controller->link_click_count());
706 EXPECT_EQ(1U, controller->action_click_count()); 694 EXPECT_EQ(1U, controller->action_click_count());
707 EXPECT_EQ(0U, controller->dismiss_click_count()); 695 EXPECT_EQ(0U, controller->dismiss_click_count());
708 // Only extension 2 should have become disabled. 696 // Only extension 2 should have become disabled.
709 EXPECT_TRUE(registry->enabled_extensions().GetByID(kId1) != NULL); 697 EXPECT_TRUE(registry->enabled_extensions().GetByID(kId1) != NULL);
710 EXPECT_TRUE(registry->disabled_extensions().GetByID(kId2) != NULL); 698 EXPECT_TRUE(registry->disabled_extensions().GetByID(kId2) != NULL);
711 EXPECT_TRUE(registry->enabled_extensions().GetByID(kId3) != NULL); 699 EXPECT_TRUE(registry->enabled_extensions().GetByID(kId3) != NULL);
712 // No extension should have been acknowledged (it got disabled). 700 // No extension should have been acknowledged (it got disabled).
713 EXPECT_FALSE(controller->delegate()->HasBubbleInfoBeenAcknowledged(kId1)); 701 EXPECT_FALSE(controller->delegate()->HasBubbleInfoBeenAcknowledged(kId1));
714 EXPECT_FALSE(controller->delegate()->HasBubbleInfoBeenAcknowledged(kId2)); 702 EXPECT_FALSE(controller->delegate()->HasBubbleInfoBeenAcknowledged(kId2));
715 EXPECT_FALSE(controller->delegate()->HasBubbleInfoBeenAcknowledged(kId3)); 703 EXPECT_FALSE(controller->delegate()->HasBubbleInfoBeenAcknowledged(kId3));
716 704
717 // Clean up after ourselves. 705 // Clean up after ourselves.
718 service_->UninstallExtension(kId1, 706 service_->UninstallExtension(kId1,
719 extensions::UNINSTALL_REASON_FOR_TESTING, 707 extensions::UNINSTALL_REASON_FOR_TESTING,
720 base::Bind(&base::DoNothing), 708 base::Bind(&base::DoNothing),
721 NULL); 709 NULL);
722 service_->UninstallExtension(kId2, 710 service_->UninstallExtension(kId2,
723 extensions::UNINSTALL_REASON_FOR_TESTING, 711 extensions::UNINSTALL_REASON_FOR_TESTING,
724 base::Bind(&base::DoNothing), 712 base::Bind(&base::DoNothing),
725 NULL); 713 NULL);
726 service_->UninstallExtension(kId3, 714 service_->UninstallExtension(kId3,
727 extensions::UNINSTALL_REASON_FOR_TESTING, 715 extensions::UNINSTALL_REASON_FOR_TESTING,
728 base::Bind(&base::DoNothing), 716 base::Bind(&base::DoNothing),
729 NULL); 717 NULL);
730 } 718 }
731 } 719 }
732 720
733 // The feature this is meant to test is only implemented on Windows. 721 // The feature this is meant to test is only enacted on Windows, but it should
734 #if defined(OS_WIN) 722 // pass on all platforms.
735 #define MAYBE_NtpOverriddenControllerTest NtpOverriddenControllerTest 723 TEST_F(ExtensionMessageBubbleTest, NtpOverriddenControllerTest) {
736 #else
737 #define MAYBE_NtpOverriddenControllerTest DISABLED_NtpOverriddenControllerTest
738 #endif
739
740 TEST_F(ExtensionMessageBubbleTest, MAYBE_NtpOverriddenControllerTest) {
741 Init(); 724 Init();
742 // Load two extensions overriding new tab page and one overriding something 725 // Load two extensions overriding new tab page and one overriding something
743 // unrelated (to check for interference). Extension 2 should still win 726 // unrelated (to check for interference). Extension 2 should still win
744 // on the new tab page setting. 727 // on the new tab page setting.
745 ASSERT_TRUE(LoadExtensionOverridingNtp("1", kId1, Manifest::UNPACKED)); 728 ASSERT_TRUE(LoadExtensionOverridingNtp("1", kId1, Manifest::UNPACKED));
746 ASSERT_TRUE(LoadExtensionOverridingNtp("2", kId2, Manifest::UNPACKED)); 729 ASSERT_TRUE(LoadExtensionOverridingNtp("2", kId2, Manifest::UNPACKED));
747 ASSERT_TRUE(LoadExtensionOverridingStart("3", kId3, Manifest::UNPACKED)); 730 ASSERT_TRUE(LoadExtensionOverridingStart("3", kId3, Manifest::UNPACKED));
748 731
749 scoped_ptr<TestNtpOverriddenBubbleController> controller( 732 scoped_ptr<TestNtpOverriddenBubbleController> controller(
750 new TestNtpOverriddenBubbleController(profile())); 733 new TestNtpOverriddenBubbleController(profile()));
751 734
752 // The list will contain one enabled unpacked extension (ext 2). 735 // The list will contain one enabled unpacked extension (ext 2).
753 EXPECT_TRUE(controller->ShouldShow(kId2)); 736 EXPECT_TRUE(controller->ShouldShow(kId2));
754 std::vector<base::string16> override_extensions = 737 std::vector<base::string16> override_extensions =
755 controller->GetExtensionList(); 738 controller->GetExtensionList();
756 ASSERT_EQ(1U, override_extensions.size()); 739 ASSERT_EQ(1U, override_extensions.size());
757 EXPECT_TRUE(base::ASCIIToUTF16("Extension 2") == 740 EXPECT_TRUE(base::ASCIIToUTF16("Extension 2") ==
758 override_extensions[0].c_str()); 741 override_extensions[0].c_str());
759 EXPECT_EQ(0U, controller->link_click_count()); 742 EXPECT_EQ(0U, controller->link_click_count());
760 EXPECT_EQ(0U, controller->dismiss_click_count()); 743 EXPECT_EQ(0U, controller->dismiss_click_count());
761 EXPECT_EQ(0U, controller->action_click_count()); 744 EXPECT_EQ(0U, controller->action_click_count());
762 745
763 // Simulate showing the bubble and dismissing it. 746 // Simulate showing the bubble and dismissing it.
764 FakeExtensionMessageBubble bubble; 747 FakeExtensionMessageBubble bubble;
765 bubble.set_action_on_show( 748 bubble.set_action_on_show(
766 FakeExtensionMessageBubble::BUBBLE_ACTION_CLICK_DISMISS_BUTTON); 749 FakeExtensionMessageBubble::BUBBLE_ACTION_CLICK_DISMISS_BUTTON);
767 EXPECT_TRUE(controller->ShouldShow(kId2)); 750 EXPECT_TRUE(controller->ShouldShow(kId2));
751 bubble.set_controller(controller.get());
768 controller->Show(&bubble); 752 controller->Show(&bubble);
769 EXPECT_EQ(0U, controller->link_click_count()); 753 EXPECT_EQ(0U, controller->link_click_count());
770 EXPECT_EQ(0U, controller->action_click_count()); 754 EXPECT_EQ(0U, controller->action_click_count());
771 EXPECT_EQ(1U, controller->dismiss_click_count()); 755 EXPECT_EQ(1U, controller->dismiss_click_count());
772 // No extension should have become disabled. 756 // No extension should have become disabled.
773 ExtensionRegistry* registry = ExtensionRegistry::Get(profile()); 757 ExtensionRegistry* registry = ExtensionRegistry::Get(profile());
774 EXPECT_TRUE(registry->enabled_extensions().GetByID(kId1) != NULL); 758 EXPECT_TRUE(registry->enabled_extensions().GetByID(kId1) != NULL);
775 EXPECT_TRUE(registry->enabled_extensions().GetByID(kId2) != NULL); 759 EXPECT_TRUE(registry->enabled_extensions().GetByID(kId2) != NULL);
776 EXPECT_TRUE(registry->enabled_extensions().GetByID(kId3) != NULL); 760 EXPECT_TRUE(registry->enabled_extensions().GetByID(kId3) != NULL);
777 // Only extension 2 should have been acknowledged. 761 // Only extension 2 should have been acknowledged.
778 EXPECT_FALSE(controller->delegate()->HasBubbleInfoBeenAcknowledged(kId1)); 762 EXPECT_FALSE(controller->delegate()->HasBubbleInfoBeenAcknowledged(kId1));
779 EXPECT_TRUE(controller->delegate()->HasBubbleInfoBeenAcknowledged(kId2)); 763 EXPECT_TRUE(controller->delegate()->HasBubbleInfoBeenAcknowledged(kId2));
780 EXPECT_FALSE(controller->delegate()->HasBubbleInfoBeenAcknowledged(kId3)); 764 EXPECT_FALSE(controller->delegate()->HasBubbleInfoBeenAcknowledged(kId3));
781 // Clean up after ourselves. 765 // Clean up after ourselves.
782 controller->delegate()->SetBubbleInfoBeenAcknowledged(kId2, false); 766 controller->delegate()->SetBubbleInfoBeenAcknowledged(kId2, false);
783 767
784 // Simulate clicking the learn more link to dismiss it. 768 // Simulate clicking the learn more link to dismiss it.
785 bubble.set_action_on_show( 769 bubble.set_action_on_show(
786 FakeExtensionMessageBubble::BUBBLE_ACTION_CLICK_LINK); 770 FakeExtensionMessageBubble::BUBBLE_ACTION_CLICK_LINK);
787 controller.reset(new TestNtpOverriddenBubbleController(profile())); 771 controller.reset(new TestNtpOverriddenBubbleController(profile()));
788 EXPECT_TRUE(controller->ShouldShow(kId2)); 772 EXPECT_TRUE(controller->ShouldShow(kId2));
773 bubble.set_controller(controller.get());
789 controller->Show(&bubble); 774 controller->Show(&bubble);
790 EXPECT_EQ(1U, controller->link_click_count()); 775 EXPECT_EQ(1U, controller->link_click_count());
791 EXPECT_EQ(0U, controller->action_click_count()); 776 EXPECT_EQ(0U, controller->action_click_count());
792 EXPECT_EQ(0U, controller->dismiss_click_count()); 777 EXPECT_EQ(0U, controller->dismiss_click_count());
793 // No extension should have become disabled. 778 // No extension should have become disabled.
794 EXPECT_TRUE(registry->enabled_extensions().GetByID(kId1) != NULL); 779 EXPECT_TRUE(registry->enabled_extensions().GetByID(kId1) != NULL);
795 EXPECT_TRUE(registry->enabled_extensions().GetByID(kId2) != NULL); 780 EXPECT_TRUE(registry->enabled_extensions().GetByID(kId2) != NULL);
796 EXPECT_TRUE(registry->enabled_extensions().GetByID(kId3) != NULL); 781 EXPECT_TRUE(registry->enabled_extensions().GetByID(kId3) != NULL);
797 // Only extension 2 should have been acknowledged. 782 // Only extension 2 should have been acknowledged.
798 EXPECT_FALSE(controller->delegate()->HasBubbleInfoBeenAcknowledged(kId1)); 783 EXPECT_FALSE(controller->delegate()->HasBubbleInfoBeenAcknowledged(kId1));
799 EXPECT_TRUE(controller->delegate()->HasBubbleInfoBeenAcknowledged(kId2)); 784 EXPECT_TRUE(controller->delegate()->HasBubbleInfoBeenAcknowledged(kId2));
800 EXPECT_FALSE(controller->delegate()->HasBubbleInfoBeenAcknowledged(kId3)); 785 EXPECT_FALSE(controller->delegate()->HasBubbleInfoBeenAcknowledged(kId3));
801 // Clean up after ourselves. 786 // Clean up after ourselves.
802 controller->delegate()->SetBubbleInfoBeenAcknowledged(kId2, false); 787 controller->delegate()->SetBubbleInfoBeenAcknowledged(kId2, false);
803 788
804 // Do it again, but now opt to disable the extension. 789 // Do it again, but now opt to disable the extension.
805 bubble.set_action_on_show( 790 bubble.set_action_on_show(
806 FakeExtensionMessageBubble::BUBBLE_ACTION_CLICK_ACTION_BUTTON); 791 FakeExtensionMessageBubble::BUBBLE_ACTION_CLICK_ACTION_BUTTON);
807 controller.reset(new TestNtpOverriddenBubbleController(profile())); 792 controller.reset(new TestNtpOverriddenBubbleController(profile()));
808 EXPECT_TRUE(controller->ShouldShow(kId2)); 793 EXPECT_TRUE(controller->ShouldShow(kId2));
809 override_extensions = controller->GetExtensionList(); 794 override_extensions = controller->GetExtensionList();
810 EXPECT_EQ(1U, override_extensions.size()); 795 EXPECT_EQ(1U, override_extensions.size());
796 bubble.set_controller(controller.get());
811 controller->Show(&bubble); // Simulate showing the bubble. 797 controller->Show(&bubble); // Simulate showing the bubble.
812 EXPECT_EQ(0U, controller->link_click_count()); 798 EXPECT_EQ(0U, controller->link_click_count());
813 EXPECT_EQ(1U, controller->action_click_count()); 799 EXPECT_EQ(1U, controller->action_click_count());
814 EXPECT_EQ(0U, controller->dismiss_click_count()); 800 EXPECT_EQ(0U, controller->dismiss_click_count());
815 // Only extension 2 should have become disabled. 801 // Only extension 2 should have become disabled.
816 EXPECT_TRUE(registry->enabled_extensions().GetByID(kId1) != NULL); 802 EXPECT_TRUE(registry->enabled_extensions().GetByID(kId1) != NULL);
817 EXPECT_TRUE(registry->disabled_extensions().GetByID(kId2) != NULL); 803 EXPECT_TRUE(registry->disabled_extensions().GetByID(kId2) != NULL);
818 EXPECT_TRUE(registry->enabled_extensions().GetByID(kId3) != NULL); 804 EXPECT_TRUE(registry->enabled_extensions().GetByID(kId3) != NULL);
819 // No extension should have been acknowledged (it got disabled). 805 // No extension should have been acknowledged (it got disabled).
820 EXPECT_FALSE(controller->delegate()->HasBubbleInfoBeenAcknowledged(kId1)); 806 EXPECT_FALSE(controller->delegate()->HasBubbleInfoBeenAcknowledged(kId1));
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
888 ASSERT_EQ(1U, override_extensions.size()); 874 ASSERT_EQ(1U, override_extensions.size());
889 EXPECT_EQ(base::ASCIIToUTF16("Extension 2"), override_extensions[0]); 875 EXPECT_EQ(base::ASCIIToUTF16("Extension 2"), override_extensions[0]);
890 EXPECT_EQ(0U, controller->link_click_count()); 876 EXPECT_EQ(0U, controller->link_click_count());
891 EXPECT_EQ(0U, controller->dismiss_click_count()); 877 EXPECT_EQ(0U, controller->dismiss_click_count());
892 EXPECT_EQ(0U, controller->action_click_count()); 878 EXPECT_EQ(0U, controller->action_click_count());
893 879
894 // Simulate showing the bubble and dismissing it. 880 // Simulate showing the bubble and dismissing it.
895 FakeExtensionMessageBubble bubble; 881 FakeExtensionMessageBubble bubble;
896 bubble.set_action_on_show( 882 bubble.set_action_on_show(
897 FakeExtensionMessageBubble::BUBBLE_ACTION_CLICK_DISMISS_BUTTON); 883 FakeExtensionMessageBubble::BUBBLE_ACTION_CLICK_DISMISS_BUTTON);
884 bubble.set_controller(controller.get());
898 controller->Show(&bubble); 885 controller->Show(&bubble);
899 EXPECT_EQ(0U, controller->link_click_count()); 886 EXPECT_EQ(0U, controller->link_click_count());
900 EXPECT_EQ(0U, controller->action_click_count()); 887 EXPECT_EQ(0U, controller->action_click_count());
901 EXPECT_EQ(1U, controller->dismiss_click_count()); 888 EXPECT_EQ(1U, controller->dismiss_click_count());
902 // No extension should have become disabled. 889 // No extension should have become disabled.
903 ExtensionRegistry* registry = ExtensionRegistry::Get(profile()); 890 ExtensionRegistry* registry = ExtensionRegistry::Get(profile());
904 EXPECT_TRUE(registry->enabled_extensions().GetByID(kId1) != NULL); 891 EXPECT_TRUE(registry->enabled_extensions().GetByID(kId1) != NULL);
905 EXPECT_TRUE(registry->enabled_extensions().GetByID(kId2) != NULL); 892 EXPECT_TRUE(registry->enabled_extensions().GetByID(kId2) != NULL);
906 EXPECT_TRUE(registry->enabled_extensions().GetByID(kId3) != NULL); 893 EXPECT_TRUE(registry->enabled_extensions().GetByID(kId3) != NULL);
907 // Only extension 2 should have been acknowledged. 894 // Only extension 2 should have been acknowledged.
908 EXPECT_FALSE(controller->delegate()->HasBubbleInfoBeenAcknowledged(kId1)); 895 EXPECT_FALSE(controller->delegate()->HasBubbleInfoBeenAcknowledged(kId1));
909 EXPECT_TRUE(controller->delegate()->HasBubbleInfoBeenAcknowledged(kId2)); 896 EXPECT_TRUE(controller->delegate()->HasBubbleInfoBeenAcknowledged(kId2));
910 EXPECT_FALSE(controller->delegate()->HasBubbleInfoBeenAcknowledged(kId3)); 897 EXPECT_FALSE(controller->delegate()->HasBubbleInfoBeenAcknowledged(kId3));
911 // Clean up after ourselves. 898 // Clean up after ourselves.
912 controller->delegate()->SetBubbleInfoBeenAcknowledged(kId2, false); 899 controller->delegate()->SetBubbleInfoBeenAcknowledged(kId2, false);
913 900
914 // Simulate clicking the learn more link to dismiss it. 901 // Simulate clicking the learn more link to dismiss it.
915 bubble.set_action_on_show( 902 bubble.set_action_on_show(
916 FakeExtensionMessageBubble::BUBBLE_ACTION_CLICK_LINK); 903 FakeExtensionMessageBubble::BUBBLE_ACTION_CLICK_LINK);
917 controller.reset(new TestProxyOverriddenBubbleController(profile())); 904 controller.reset(new TestProxyOverriddenBubbleController(profile()));
918 EXPECT_TRUE(controller->ShouldShow(kId2)); 905 EXPECT_TRUE(controller->ShouldShow(kId2));
906 bubble.set_controller(controller.get());
919 controller->Show(&bubble); 907 controller->Show(&bubble);
920 EXPECT_EQ(1U, controller->link_click_count()); 908 EXPECT_EQ(1U, controller->link_click_count());
921 EXPECT_EQ(0U, controller->action_click_count()); 909 EXPECT_EQ(0U, controller->action_click_count());
922 EXPECT_EQ(0U, controller->dismiss_click_count()); 910 EXPECT_EQ(0U, controller->dismiss_click_count());
923 // No extension should have become disabled. 911 // No extension should have become disabled.
924 EXPECT_TRUE(registry->enabled_extensions().GetByID(kId1) != NULL); 912 EXPECT_TRUE(registry->enabled_extensions().GetByID(kId1) != NULL);
925 EXPECT_TRUE(registry->enabled_extensions().GetByID(kId2) != NULL); 913 EXPECT_TRUE(registry->enabled_extensions().GetByID(kId2) != NULL);
926 EXPECT_TRUE(registry->enabled_extensions().GetByID(kId3) != NULL); 914 EXPECT_TRUE(registry->enabled_extensions().GetByID(kId3) != NULL);
927 // Only extension 2 should have been acknowledged. 915 // Only extension 2 should have been acknowledged.
928 EXPECT_FALSE(controller->delegate()->HasBubbleInfoBeenAcknowledged(kId1)); 916 EXPECT_FALSE(controller->delegate()->HasBubbleInfoBeenAcknowledged(kId1));
929 EXPECT_TRUE(controller->delegate()->HasBubbleInfoBeenAcknowledged(kId2)); 917 EXPECT_TRUE(controller->delegate()->HasBubbleInfoBeenAcknowledged(kId2));
930 EXPECT_FALSE(controller->delegate()->HasBubbleInfoBeenAcknowledged(kId3)); 918 EXPECT_FALSE(controller->delegate()->HasBubbleInfoBeenAcknowledged(kId3));
931 // Clean up after ourselves. 919 // Clean up after ourselves.
932 controller->delegate()->SetBubbleInfoBeenAcknowledged(kId2, false); 920 controller->delegate()->SetBubbleInfoBeenAcknowledged(kId2, false);
933 921
934 // Do it again, but now opt to disable the extension. 922 // Do it again, but now opt to disable the extension.
935 bubble.set_action_on_show( 923 bubble.set_action_on_show(
936 FakeExtensionMessageBubble::BUBBLE_ACTION_CLICK_ACTION_BUTTON); 924 FakeExtensionMessageBubble::BUBBLE_ACTION_CLICK_ACTION_BUTTON);
937 controller.reset(new TestProxyOverriddenBubbleController(profile())); 925 controller.reset(new TestProxyOverriddenBubbleController(profile()));
938 EXPECT_TRUE(controller->ShouldShow(kId2)); 926 EXPECT_TRUE(controller->ShouldShow(kId2));
939 override_extensions = controller->GetExtensionList(); 927 override_extensions = controller->GetExtensionList();
940 EXPECT_EQ(1U, override_extensions.size()); 928 EXPECT_EQ(1U, override_extensions.size());
929 bubble.set_controller(controller.get());
941 controller->Show(&bubble); // Simulate showing the bubble. 930 controller->Show(&bubble); // Simulate showing the bubble.
942 EXPECT_EQ(0U, controller->link_click_count()); 931 EXPECT_EQ(0U, controller->link_click_count());
943 EXPECT_EQ(1U, controller->action_click_count()); 932 EXPECT_EQ(1U, controller->action_click_count());
944 EXPECT_EQ(0U, controller->dismiss_click_count()); 933 EXPECT_EQ(0U, controller->dismiss_click_count());
945 // Only extension 2 should have become disabled. 934 // Only extension 2 should have become disabled.
946 EXPECT_TRUE(registry->enabled_extensions().GetByID(kId1) != NULL); 935 EXPECT_TRUE(registry->enabled_extensions().GetByID(kId1) != NULL);
947 EXPECT_TRUE(registry->disabled_extensions().GetByID(kId2) != NULL); 936 EXPECT_TRUE(registry->disabled_extensions().GetByID(kId2) != NULL);
948 EXPECT_TRUE(registry->enabled_extensions().GetByID(kId3) != NULL); 937 EXPECT_TRUE(registry->enabled_extensions().GetByID(kId3) != NULL);
949 938
950 // No extension should have been acknowledged (it got disabled). 939 // No extension should have been acknowledged (it got disabled).
(...skipping 10 matching lines...) Expand all
961 extensions::UNINSTALL_REASON_FOR_TESTING, 950 extensions::UNINSTALL_REASON_FOR_TESTING,
962 base::Bind(&base::DoNothing), 951 base::Bind(&base::DoNothing),
963 NULL); 952 NULL);
964 service_->UninstallExtension(kId3, 953 service_->UninstallExtension(kId3,
965 extensions::UNINSTALL_REASON_FOR_TESTING, 954 extensions::UNINSTALL_REASON_FOR_TESTING,
966 base::Bind(&base::DoNothing), 955 base::Bind(&base::DoNothing),
967 NULL); 956 NULL);
968 } 957 }
969 958
970 } // namespace extensions 959 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698