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

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: Re-Upload 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 15 matching lines...) Expand all
26 #include "extensions/browser/extension_prefs.h" 26 #include "extensions/browser/extension_prefs.h"
27 #include "extensions/browser/extension_registry.h" 27 #include "extensions/browser/extension_registry.h"
28 #include "extensions/browser/extension_system.h" 28 #include "extensions/browser/extension_system.h"
29 #include "extensions/browser/uninstall_reason.h" 29 #include "extensions/browser/uninstall_reason.h"
30 #include "extensions/common/extension.h" 30 #include "extensions/common/extension.h"
31 #include "extensions/common/extension_builder.h" 31 #include "extensions/common/extension_builder.h"
32 #include "extensions/common/feature_switch.h" 32 #include "extensions/common/feature_switch.h"
33 #include "extensions/common/value_builder.h" 33 #include "extensions/common/value_builder.h"
34 #include "testing/gtest/include/gtest/gtest.h" 34 #include "testing/gtest/include/gtest/gtest.h"
35 35
36 #if defined(OS_CHROMEOS)
37 #include "chrome/browser/chromeos/login/users/scoped_test_user_manager.h"
38 #include "chrome/browser/chromeos/settings/cros_settings.h"
39 #include "chrome/browser/chromeos/settings/device_settings_service.h"
40 #endif
41
36 namespace { 42 namespace {
37 43
38 const char kId1[] = "iccfkkhkfiphcjdakkmcjmkfboccmndk"; 44 const char kId1[] = "iccfkkhkfiphcjdakkmcjmkfboccmndk";
39 const char kId2[] = "ajjhifimiemdpmophmkkkcijegphclbl"; 45 const char kId2[] = "ajjhifimiemdpmophmkkkcijegphclbl";
40 const char kId3[] = "ioibbbfddncmmabjmpokikkeiofalaek"; 46 const char kId3[] = "ioibbbfddncmmabjmpokikkeiofalaek";
41 47
42 } // namespace 48 } // namespace
43 49
44 namespace extensions { 50 namespace extensions {
45 51
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 // what should happen when the bubble is "shown" (the bubble is actually not 206 // what should happen when the bubble is "shown" (the bubble is actually not
201 // shown, the corresponding action is taken immediately). 207 // shown, the corresponding action is taken immediately).
202 class FakeExtensionMessageBubble : public ExtensionMessageBubble { 208 class FakeExtensionMessageBubble : public ExtensionMessageBubble {
203 public: 209 public:
204 enum ExtensionBubbleAction { 210 enum ExtensionBubbleAction {
205 BUBBLE_ACTION_CLICK_ACTION_BUTTON = 0, 211 BUBBLE_ACTION_CLICK_ACTION_BUTTON = 0,
206 BUBBLE_ACTION_CLICK_DISMISS_BUTTON, 212 BUBBLE_ACTION_CLICK_DISMISS_BUTTON,
207 BUBBLE_ACTION_CLICK_LINK, 213 BUBBLE_ACTION_CLICK_LINK,
208 }; 214 };
209 215
210 FakeExtensionMessageBubble() {} 216 FakeExtensionMessageBubble() : controller_(nullptr) {}
211 217
212 void set_action_on_show(ExtensionBubbleAction action) { 218 void set_action_on_show(ExtensionBubbleAction action) {
213 action_ = action; 219 action_ = action;
214 } 220 }
221 void set_controller(ExtensionMessageBubbleController* controller) {
222 controller_ = controller;
223 }
215 224
216 void Show() override { 225 void Show() override {
217 if (action_ == BUBBLE_ACTION_CLICK_ACTION_BUTTON) 226 if (action_ == BUBBLE_ACTION_CLICK_ACTION_BUTTON)
218 action_callback_.Run(); 227 controller_->OnBubbleAction();
219 else if (action_ == BUBBLE_ACTION_CLICK_DISMISS_BUTTON) 228 else if (action_ == BUBBLE_ACTION_CLICK_DISMISS_BUTTON)
220 dismiss_callback_.Run(); 229 controller_->OnBubbleDismiss();
221 else if (action_ == BUBBLE_ACTION_CLICK_LINK) 230 else if (action_ == BUBBLE_ACTION_CLICK_LINK)
222 link_callback_.Run(); 231 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 } 232 }
236 233
237 private: 234 private:
238 ExtensionBubbleAction action_; 235 ExtensionBubbleAction action_;
236 ExtensionMessageBubbleController* controller_;
239 237
240 base::Closure action_callback_; 238 DISALLOW_COPY_AND_ASSIGN(FakeExtensionMessageBubble);
241 base::Closure dismiss_callback_;
242 base::Closure link_callback_;
243 }; 239 };
244 240
245 class ExtensionMessageBubbleTest : public testing::Test { 241 class ExtensionMessageBubbleTest : public testing::Test {
246 public: 242 public:
247 ExtensionMessageBubbleTest() {} 243 ExtensionMessageBubbleTest() {}
248 244
249 testing::AssertionResult LoadGenericExtension(const std::string& index, 245 testing::AssertionResult LoadGenericExtension(const std::string& index,
250 const std::string& id, 246 const std::string& id,
251 Manifest::Location location) { 247 Manifest::Location location) {
252 ExtensionBuilder builder; 248 ExtensionBuilder builder;
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
383 new base::StringValue(id)); 379 new base::StringValue(id));
384 380
385 if (ExtensionRegistry::Get(profile())->enabled_extensions().GetByID(id)) 381 if (ExtensionRegistry::Get(profile())->enabled_extensions().GetByID(id))
386 return testing::AssertionSuccess(); 382 return testing::AssertionSuccess();
387 return testing::AssertionFailure() << "Could not install extension: " << id; 383 return testing::AssertionFailure() << "Could not install extension: " << id;
388 } 384 }
389 385
390 void Init() { 386 void Init() {
391 // The two lines of magical incantation required to get the extension 387 // The two lines of magical incantation required to get the extension
392 // service to work inside a unit test and access the extension prefs. 388 // service to work inside a unit test and access the extension prefs.
393 thread_bundle_.reset(new content::TestBrowserThreadBundle);
394 profile_.reset(new TestingProfile); 389 profile_.reset(new TestingProfile);
395 static_cast<TestExtensionSystem*>(ExtensionSystem::Get(profile())) 390 static_cast<TestExtensionSystem*>(ExtensionSystem::Get(profile()))
396 ->CreateExtensionService(base::CommandLine::ForCurrentProcess(), 391 ->CreateExtensionService(base::CommandLine::ForCurrentProcess(),
397 base::FilePath(), false); 392 base::FilePath(), false);
398 service_ = ExtensionSystem::Get(profile())->extension_service(); 393 service_ = ExtensionSystem::Get(profile())->extension_service();
399 service_->Init(); 394 service_->Init();
400 } 395 }
401 396
402 ~ExtensionMessageBubbleTest() override { 397 ~ExtensionMessageBubbleTest() override {
403 // Make sure the profile is destroyed before the thread bundle. 398 // Make sure the profile is destroyed before the thread bundle.
(...skipping 12 matching lines...) Expand all
416 const std::string& data, 411 const std::string& data,
417 const std::string& id) { 412 const std::string& id) {
418 scoped_ptr<base::DictionaryValue> parsed_manifest( 413 scoped_ptr<base::DictionaryValue> parsed_manifest(
419 api_test_utils::ParseDictionary(data)); 414 api_test_utils::ParseDictionary(data));
420 return api_test_utils::CreateExtension(location, parsed_manifest.get(), id); 415 return api_test_utils::CreateExtension(location, parsed_manifest.get(), id);
421 } 416 }
422 417
423 ExtensionService* service_; 418 ExtensionService* service_;
424 419
425 private: 420 private:
421 content::TestBrowserThreadBundle thread_bundle_;
426 scoped_ptr<base::CommandLine> command_line_; 422 scoped_ptr<base::CommandLine> command_line_;
427 scoped_ptr<content::TestBrowserThreadBundle> thread_bundle_;
428 scoped_ptr<TestingProfile> profile_; 423 scoped_ptr<TestingProfile> profile_;
429 424
425 #if defined OS_CHROMEOS
426 chromeos::ScopedTestDeviceSettingsService test_device_settings_service_;
427 chromeos::ScopedTestCrosSettings test_cros_settings_;
428 chromeos::ScopedTestUserManager test_user_manager_;
429 #endif
430
430 DISALLOW_COPY_AND_ASSIGN(ExtensionMessageBubbleTest); 431 DISALLOW_COPY_AND_ASSIGN(ExtensionMessageBubbleTest);
431 }; 432 };
432 433
433 // The feature this is meant to test is only implemented on Windows. 434 // The feature this is meant to test is only enacted on Windows, but it should
434 #if defined(OS_WIN) 435 // pass on all platforms.
435 #define MAYBE_WipeoutControllerTest WipeoutControllerTest 436 TEST_F(ExtensionMessageBubbleTest, WipeoutControllerTest) {
436 #else
437 #define MAYBE_WipeoutControllerTest DISABLED_WipeoutControllerTest
438 #endif
439
440 TEST_F(ExtensionMessageBubbleTest, MAYBE_WipeoutControllerTest) {
441 Init(); 437 Init();
442 // Add three extensions, and control two of them in this test (extension 1 438 // Add three extensions, and control two of them in this test (extension 1
443 // and 2). 439 // and 2).
444 ASSERT_TRUE(LoadExtensionWithAction("1", kId1, Manifest::COMMAND_LINE)); 440 ASSERT_TRUE(LoadExtensionWithAction("1", kId1, Manifest::COMMAND_LINE));
445 ASSERT_TRUE(LoadGenericExtension("2", kId2, Manifest::UNPACKED)); 441 ASSERT_TRUE(LoadGenericExtension("2", kId2, Manifest::UNPACKED));
446 ASSERT_TRUE(LoadGenericExtension("3", kId3, Manifest::EXTERNAL_POLICY)); 442 ASSERT_TRUE(LoadGenericExtension("3", kId3, Manifest::EXTERNAL_POLICY));
447 443
448 scoped_ptr<TestSuspiciousExtensionBubbleController> controller( 444 scoped_ptr<TestSuspiciousExtensionBubbleController> controller(
449 new TestSuspiciousExtensionBubbleController(profile())); 445 new TestSuspiciousExtensionBubbleController(profile()));
450 FakeExtensionMessageBubble bubble; 446 FakeExtensionMessageBubble bubble;
(...skipping 16 matching lines...) Expand all
467 463
468 EXPECT_FALSE(controller->delegate()->HasBubbleInfoBeenAcknowledged(kId1)); 464 EXPECT_FALSE(controller->delegate()->HasBubbleInfoBeenAcknowledged(kId1));
469 EXPECT_FALSE(controller->delegate()->HasBubbleInfoBeenAcknowledged(kId2)); 465 EXPECT_FALSE(controller->delegate()->HasBubbleInfoBeenAcknowledged(kId2));
470 controller.reset(new TestSuspiciousExtensionBubbleController( 466 controller.reset(new TestSuspiciousExtensionBubbleController(
471 profile())); 467 profile()));
472 SuspiciousExtensionBubbleController::ClearProfileListForTesting(); 468 SuspiciousExtensionBubbleController::ClearProfileListForTesting();
473 EXPECT_TRUE(controller->ShouldShow()); 469 EXPECT_TRUE(controller->ShouldShow());
474 suspicious_extensions = controller->GetExtensionList(); 470 suspicious_extensions = controller->GetExtensionList();
475 ASSERT_EQ(1U, suspicious_extensions.size()); 471 ASSERT_EQ(1U, suspicious_extensions.size());
476 EXPECT_TRUE(base::ASCIIToUTF16("Extension 1") == suspicious_extensions[0]); 472 EXPECT_TRUE(base::ASCIIToUTF16("Extension 1") == suspicious_extensions[0]);
473 bubble.set_controller(controller.get());
477 controller->Show(&bubble); // Simulate showing the bubble. 474 controller->Show(&bubble); // Simulate showing the bubble.
478 EXPECT_EQ(0U, controller->link_click_count()); 475 EXPECT_EQ(0U, controller->link_click_count());
479 EXPECT_EQ(1U, controller->dismiss_click_count()); 476 EXPECT_EQ(1U, controller->dismiss_click_count());
480 // Now the acknowledge flag should be set only for the first extension. 477 // Now the acknowledge flag should be set only for the first extension.
481 EXPECT_TRUE(controller->delegate()->HasBubbleInfoBeenAcknowledged(kId1)); 478 EXPECT_TRUE(controller->delegate()->HasBubbleInfoBeenAcknowledged(kId1));
482 EXPECT_FALSE(controller->delegate()->HasBubbleInfoBeenAcknowledged(kId2)); 479 EXPECT_FALSE(controller->delegate()->HasBubbleInfoBeenAcknowledged(kId2));
483 // Clear the flag. 480 // Clear the flag.
484 controller->delegate()->SetBubbleInfoBeenAcknowledged(kId1, false); 481 controller->delegate()->SetBubbleInfoBeenAcknowledged(kId1, false);
485 EXPECT_FALSE(controller->delegate()->HasBubbleInfoBeenAcknowledged(kId1)); 482 EXPECT_FALSE(controller->delegate()->HasBubbleInfoBeenAcknowledged(kId1));
486 483
487 // Now disable the other extension and exercise the link click code path. 484 // Now disable the other extension and exercise the link click code path.
488 service_->DisableExtension(kId2, Extension::DISABLE_NOT_VERIFIED); 485 service_->DisableExtension(kId2, Extension::DISABLE_NOT_VERIFIED);
489 486
490 bubble.set_action_on_show( 487 bubble.set_action_on_show(
491 FakeExtensionMessageBubble::BUBBLE_ACTION_CLICK_LINK); 488 FakeExtensionMessageBubble::BUBBLE_ACTION_CLICK_LINK);
492 controller.reset(new TestSuspiciousExtensionBubbleController( 489 controller.reset(new TestSuspiciousExtensionBubbleController(
493 profile())); 490 profile()));
494 SuspiciousExtensionBubbleController::ClearProfileListForTesting(); 491 SuspiciousExtensionBubbleController::ClearProfileListForTesting();
495 EXPECT_TRUE(controller->ShouldShow()); 492 EXPECT_TRUE(controller->ShouldShow());
496 suspicious_extensions = controller->GetExtensionList(); 493 suspicious_extensions = controller->GetExtensionList();
497 ASSERT_EQ(2U, suspicious_extensions.size()); 494 ASSERT_EQ(2U, suspicious_extensions.size());
498 EXPECT_TRUE(base::ASCIIToUTF16("Extension 1") == suspicious_extensions[1]); 495 EXPECT_TRUE(base::ASCIIToUTF16("Extension 1") == suspicious_extensions[1]);
499 EXPECT_TRUE(base::ASCIIToUTF16("Extension 2") == suspicious_extensions[0]); 496 EXPECT_TRUE(base::ASCIIToUTF16("Extension 2") == suspicious_extensions[0]);
497 bubble.set_controller(controller.get());
500 controller->Show(&bubble); // Simulate showing the bubble. 498 controller->Show(&bubble); // Simulate showing the bubble.
501 EXPECT_EQ(1U, controller->link_click_count()); 499 EXPECT_EQ(1U, controller->link_click_count());
502 EXPECT_EQ(0U, controller->dismiss_click_count()); 500 EXPECT_EQ(0U, controller->dismiss_click_count());
503 EXPECT_TRUE(controller->delegate()->HasBubbleInfoBeenAcknowledged(kId1)); 501 EXPECT_TRUE(controller->delegate()->HasBubbleInfoBeenAcknowledged(kId1));
504 } 502 }
505 503
506 // The feature this is meant to test is only implemented on Windows. 504 // The feature this is meant to test is only enacted on Windows, but it should
507 #if defined(OS_WIN) 505 // pass on all platforms.
508 #define MAYBE_DevModeControllerTest DevModeControllerTest 506 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( 507 FeatureSwitch::ScopedOverride force_dev_mode_highlighting(
515 FeatureSwitch::force_dev_mode_highlighting(), true); 508 FeatureSwitch::force_dev_mode_highlighting(), true);
516 Init(); 509 Init();
517 // Add three extensions, and control two of them in this test (extension 1 510 // 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 511 // and 2). Extension 1 is a regular extension, Extension 2 is UNPACKED so it
519 // counts as a DevMode extension. 512 // counts as a DevMode extension.
520 ASSERT_TRUE(LoadExtensionWithAction("1", kId1, Manifest::COMMAND_LINE)); 513 ASSERT_TRUE(LoadExtensionWithAction("1", kId1, Manifest::COMMAND_LINE));
521 ASSERT_TRUE(LoadGenericExtension("2", kId2, Manifest::UNPACKED)); 514 ASSERT_TRUE(LoadGenericExtension("2", kId2, Manifest::UNPACKED));
522 ASSERT_TRUE(LoadGenericExtension("3", kId3, Manifest::EXTERNAL_POLICY)); 515 ASSERT_TRUE(LoadGenericExtension("3", kId3, Manifest::EXTERNAL_POLICY));
523 516
524 scoped_ptr<TestDevModeBubbleController> controller( 517 scoped_ptr<TestDevModeBubbleController> controller(
525 new TestDevModeBubbleController(profile())); 518 new TestDevModeBubbleController(profile()));
526 519
527 // The list will contain one enabled unpacked extension. 520 // The list will contain one enabled unpacked extension.
528 EXPECT_TRUE(controller->ShouldShow()); 521 EXPECT_TRUE(controller->ShouldShow());
529 std::vector<base::string16> dev_mode_extensions = 522 std::vector<base::string16> dev_mode_extensions =
530 controller->GetExtensionList(); 523 controller->GetExtensionList();
531 ASSERT_EQ(2U, dev_mode_extensions.size()); 524 ASSERT_EQ(2U, dev_mode_extensions.size());
532 EXPECT_TRUE(base::ASCIIToUTF16("Extension 2") == dev_mode_extensions[0]); 525 EXPECT_TRUE(base::ASCIIToUTF16("Extension 2") == dev_mode_extensions[0]);
533 EXPECT_TRUE(base::ASCIIToUTF16("Extension 1") == dev_mode_extensions[1]); 526 EXPECT_TRUE(base::ASCIIToUTF16("Extension 1") == dev_mode_extensions[1]);
534 EXPECT_EQ(0U, controller->link_click_count()); 527 EXPECT_EQ(0U, controller->link_click_count());
535 EXPECT_EQ(0U, controller->dismiss_click_count()); 528 EXPECT_EQ(0U, controller->dismiss_click_count());
536 EXPECT_EQ(0U, controller->action_click_count()); 529 EXPECT_EQ(0U, controller->action_click_count());
537 530
538 // Simulate showing the bubble. 531 // Simulate showing the bubble.
539 FakeExtensionMessageBubble bubble; 532 FakeExtensionMessageBubble bubble;
540 bubble.set_action_on_show( 533 bubble.set_action_on_show(
541 FakeExtensionMessageBubble::BUBBLE_ACTION_CLICK_DISMISS_BUTTON); 534 FakeExtensionMessageBubble::BUBBLE_ACTION_CLICK_DISMISS_BUTTON);
535 bubble.set_controller(controller.get());
542 controller->Show(&bubble); 536 controller->Show(&bubble);
543 EXPECT_EQ(0U, controller->link_click_count()); 537 EXPECT_EQ(0U, controller->link_click_count());
544 EXPECT_EQ(0U, controller->action_click_count()); 538 EXPECT_EQ(0U, controller->action_click_count());
545 EXPECT_EQ(1U, controller->dismiss_click_count()); 539 EXPECT_EQ(1U, controller->dismiss_click_count());
546 ExtensionRegistry* registry = ExtensionRegistry::Get(profile()); 540 ExtensionRegistry* registry = ExtensionRegistry::Get(profile());
547 EXPECT_TRUE(registry->enabled_extensions().GetByID(kId1) != NULL); 541 EXPECT_TRUE(registry->enabled_extensions().GetByID(kId1) != NULL);
548 EXPECT_TRUE(registry->enabled_extensions().GetByID(kId2) != NULL); 542 EXPECT_TRUE(registry->enabled_extensions().GetByID(kId2) != NULL);
549 543
550 // Do it again, but now press different button (Disable). 544 // Do it again, but now press different button (Disable).
551 bubble.set_action_on_show( 545 bubble.set_action_on_show(
552 FakeExtensionMessageBubble::BUBBLE_ACTION_CLICK_ACTION_BUTTON); 546 FakeExtensionMessageBubble::BUBBLE_ACTION_CLICK_ACTION_BUTTON);
553 controller.reset(new TestDevModeBubbleController( 547 controller.reset(new TestDevModeBubbleController(
554 profile())); 548 profile()));
555 DevModeBubbleController::ClearProfileListForTesting(); 549 DevModeBubbleController::ClearProfileListForTesting();
556 EXPECT_TRUE(controller->ShouldShow()); 550 EXPECT_TRUE(controller->ShouldShow());
557 dev_mode_extensions = controller->GetExtensionList(); 551 dev_mode_extensions = controller->GetExtensionList();
558 EXPECT_EQ(2U, dev_mode_extensions.size()); 552 EXPECT_EQ(2U, dev_mode_extensions.size());
553 bubble.set_controller(controller.get());
559 controller->Show(&bubble); // Simulate showing the bubble. 554 controller->Show(&bubble); // Simulate showing the bubble.
560 EXPECT_EQ(0U, controller->link_click_count()); 555 EXPECT_EQ(0U, controller->link_click_count());
561 EXPECT_EQ(1U, controller->action_click_count()); 556 EXPECT_EQ(1U, controller->action_click_count());
562 EXPECT_EQ(0U, controller->dismiss_click_count()); 557 EXPECT_EQ(0U, controller->dismiss_click_count());
563 EXPECT_TRUE(registry->disabled_extensions().GetByID(kId1) != NULL); 558 EXPECT_TRUE(registry->disabled_extensions().GetByID(kId1) != NULL);
564 EXPECT_TRUE(registry->disabled_extensions().GetByID(kId2) != NULL); 559 EXPECT_TRUE(registry->disabled_extensions().GetByID(kId2) != NULL);
565 560
566 // Re-enable the extensions (disabled by the action button above). 561 // Re-enable the extensions (disabled by the action button above).
567 service_->EnableExtension(kId1); 562 service_->EnableExtension(kId1);
568 service_->EnableExtension(kId2); 563 service_->EnableExtension(kId2);
569 564
570 // Show the dialog a third time, but now press the learn more link. 565 // Show the dialog a third time, but now press the learn more link.
571 bubble.set_action_on_show( 566 bubble.set_action_on_show(
572 FakeExtensionMessageBubble::BUBBLE_ACTION_CLICK_LINK); 567 FakeExtensionMessageBubble::BUBBLE_ACTION_CLICK_LINK);
573 controller.reset(new TestDevModeBubbleController( 568 controller.reset(new TestDevModeBubbleController(
574 profile())); 569 profile()));
575 DevModeBubbleController::ClearProfileListForTesting(); 570 DevModeBubbleController::ClearProfileListForTesting();
576 EXPECT_TRUE(controller->ShouldShow()); 571 EXPECT_TRUE(controller->ShouldShow());
577 dev_mode_extensions = controller->GetExtensionList(); 572 dev_mode_extensions = controller->GetExtensionList();
578 EXPECT_EQ(2U, dev_mode_extensions.size()); 573 EXPECT_EQ(2U, dev_mode_extensions.size());
574 bubble.set_controller(controller.get());
579 controller->Show(&bubble); // Simulate showing the bubble. 575 controller->Show(&bubble); // Simulate showing the bubble.
580 EXPECT_EQ(1U, controller->link_click_count()); 576 EXPECT_EQ(1U, controller->link_click_count());
581 EXPECT_EQ(0U, controller->action_click_count()); 577 EXPECT_EQ(0U, controller->action_click_count());
582 EXPECT_EQ(0U, controller->dismiss_click_count()); 578 EXPECT_EQ(0U, controller->dismiss_click_count());
583 EXPECT_TRUE(registry->enabled_extensions().GetByID(kId1) != NULL); 579 EXPECT_TRUE(registry->enabled_extensions().GetByID(kId1) != NULL);
584 EXPECT_TRUE(registry->enabled_extensions().GetByID(kId2) != NULL); 580 EXPECT_TRUE(registry->enabled_extensions().GetByID(kId2) != NULL);
585 581
586 // Now disable the unpacked extension. 582 // Now disable the unpacked extension.
587 service_->DisableExtension(kId1, Extension::DISABLE_USER_ACTION); 583 service_->DisableExtension(kId1, Extension::DISABLE_USER_ACTION);
588 service_->DisableExtension(kId2, Extension::DISABLE_USER_ACTION); 584 service_->DisableExtension(kId2, Extension::DISABLE_USER_ACTION);
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
636 default: 632 default:
637 NOTREACHED(); 633 NOTREACHED();
638 break; 634 break;
639 } 635 }
640 636
641 scoped_ptr<TestSettingsApiBubbleController> controller( 637 scoped_ptr<TestSettingsApiBubbleController> controller(
642 new TestSettingsApiBubbleController( 638 new TestSettingsApiBubbleController(
643 profile(), static_cast<SettingsApiOverrideType>(i))); 639 profile(), static_cast<SettingsApiOverrideType>(i)));
644 640
645 // The list will contain one enabled unpacked extension (ext 2). 641 // The list will contain one enabled unpacked extension (ext 2).
646 EXPECT_TRUE(controller->ShouldShow(kId2)); 642 EXPECT_TRUE(controller->ShouldShow());
647 std::vector<base::string16> override_extensions = 643 std::vector<base::string16> override_extensions =
648 controller->GetExtensionList(); 644 controller->GetExtensionList();
649 ASSERT_EQ(1U, override_extensions.size()); 645 ASSERT_EQ(1U, override_extensions.size());
650 EXPECT_TRUE(base::ASCIIToUTF16("Extension 2") == 646 EXPECT_TRUE(base::ASCIIToUTF16("Extension 2") ==
651 override_extensions[0].c_str()); 647 override_extensions[0].c_str());
652 EXPECT_EQ(0U, controller->link_click_count()); 648 EXPECT_EQ(0U, controller->link_click_count());
653 EXPECT_EQ(0U, controller->dismiss_click_count()); 649 EXPECT_EQ(0U, controller->dismiss_click_count());
654 EXPECT_EQ(0U, controller->action_click_count()); 650 EXPECT_EQ(0U, controller->action_click_count());
655 651
656 // Simulate showing the bubble and dismissing it. 652 // Simulate showing the bubble and dismissing it.
657 FakeExtensionMessageBubble bubble; 653 FakeExtensionMessageBubble bubble;
658 bubble.set_action_on_show( 654 bubble.set_action_on_show(
659 FakeExtensionMessageBubble::BUBBLE_ACTION_CLICK_DISMISS_BUTTON); 655 FakeExtensionMessageBubble::BUBBLE_ACTION_CLICK_DISMISS_BUTTON);
656 bubble.set_controller(controller.get());
660 controller->Show(&bubble); 657 controller->Show(&bubble);
661 EXPECT_EQ(0U, controller->link_click_count()); 658 EXPECT_EQ(0U, controller->link_click_count());
662 EXPECT_EQ(0U, controller->action_click_count()); 659 EXPECT_EQ(0U, controller->action_click_count());
663 EXPECT_EQ(1U, controller->dismiss_click_count()); 660 EXPECT_EQ(1U, controller->dismiss_click_count());
664 // No extension should have become disabled. 661 // No extension should have become disabled.
665 ExtensionRegistry* registry = ExtensionRegistry::Get(profile()); 662 ExtensionRegistry* registry = ExtensionRegistry::Get(profile());
666 EXPECT_TRUE(registry->enabled_extensions().GetByID(kId1) != NULL); 663 EXPECT_TRUE(registry->enabled_extensions().GetByID(kId1) != NULL);
667 EXPECT_TRUE(registry->enabled_extensions().GetByID(kId2) != NULL); 664 EXPECT_TRUE(registry->enabled_extensions().GetByID(kId2) != NULL);
668 EXPECT_TRUE(registry->enabled_extensions().GetByID(kId3) != NULL); 665 EXPECT_TRUE(registry->enabled_extensions().GetByID(kId3) != NULL);
669 // Only extension 2 should have been acknowledged. 666 // Only extension 2 should have been acknowledged.
670 EXPECT_FALSE(controller->delegate()->HasBubbleInfoBeenAcknowledged(kId1)); 667 EXPECT_FALSE(controller->delegate()->HasBubbleInfoBeenAcknowledged(kId1));
671 EXPECT_TRUE(controller->delegate()->HasBubbleInfoBeenAcknowledged(kId2)); 668 EXPECT_TRUE(controller->delegate()->HasBubbleInfoBeenAcknowledged(kId2));
672 EXPECT_FALSE(controller->delegate()->HasBubbleInfoBeenAcknowledged(kId3)); 669 EXPECT_FALSE(controller->delegate()->HasBubbleInfoBeenAcknowledged(kId3));
673 // Clean up after ourselves. 670 // Clean up after ourselves.
674 controller->delegate()->SetBubbleInfoBeenAcknowledged(kId2, false); 671 controller->delegate()->SetBubbleInfoBeenAcknowledged(kId2, false);
675 672
676 // Simulate clicking the learn more link to dismiss it. 673 // Simulate clicking the learn more link to dismiss it.
677 bubble.set_action_on_show( 674 bubble.set_action_on_show(
678 FakeExtensionMessageBubble::BUBBLE_ACTION_CLICK_LINK); 675 FakeExtensionMessageBubble::BUBBLE_ACTION_CLICK_LINK);
679 controller.reset(new TestSettingsApiBubbleController( 676 controller.reset(new TestSettingsApiBubbleController(
680 profile(), static_cast<SettingsApiOverrideType>(i))); 677 profile(), static_cast<SettingsApiOverrideType>(i)));
678 bubble.set_controller(controller.get());
681 controller->Show(&bubble); 679 controller->Show(&bubble);
682 EXPECT_EQ(1U, controller->link_click_count()); 680 EXPECT_EQ(1U, controller->link_click_count());
683 EXPECT_EQ(0U, controller->action_click_count()); 681 EXPECT_EQ(0U, controller->action_click_count());
684 EXPECT_EQ(0U, controller->dismiss_click_count()); 682 EXPECT_EQ(0U, controller->dismiss_click_count());
685 // No extension should have become disabled. 683 // No extension should have become disabled.
686 EXPECT_TRUE(registry->enabled_extensions().GetByID(kId1) != NULL); 684 EXPECT_TRUE(registry->enabled_extensions().GetByID(kId1) != NULL);
687 EXPECT_TRUE(registry->enabled_extensions().GetByID(kId2) != NULL); 685 EXPECT_TRUE(registry->enabled_extensions().GetByID(kId2) != NULL);
688 EXPECT_TRUE(registry->enabled_extensions().GetByID(kId3) != NULL); 686 EXPECT_TRUE(registry->enabled_extensions().GetByID(kId3) != NULL);
689 // Only extension 2 should have been acknowledged. 687 // Only extension 2 should have been acknowledged.
690 EXPECT_FALSE(controller->delegate()->HasBubbleInfoBeenAcknowledged(kId1)); 688 EXPECT_FALSE(controller->delegate()->HasBubbleInfoBeenAcknowledged(kId1));
691 EXPECT_TRUE(controller->delegate()->HasBubbleInfoBeenAcknowledged(kId2)); 689 EXPECT_TRUE(controller->delegate()->HasBubbleInfoBeenAcknowledged(kId2));
692 EXPECT_FALSE(controller->delegate()->HasBubbleInfoBeenAcknowledged(kId3)); 690 EXPECT_FALSE(controller->delegate()->HasBubbleInfoBeenAcknowledged(kId3));
693 // Clean up after ourselves. 691 // Clean up after ourselves.
694 controller->delegate()->SetBubbleInfoBeenAcknowledged(kId2, false); 692 controller->delegate()->SetBubbleInfoBeenAcknowledged(kId2, false);
695 693
696 // Do it again, but now opt to disable the extension. 694 // Do it again, but now opt to disable the extension.
697 bubble.set_action_on_show( 695 bubble.set_action_on_show(
698 FakeExtensionMessageBubble::BUBBLE_ACTION_CLICK_ACTION_BUTTON); 696 FakeExtensionMessageBubble::BUBBLE_ACTION_CLICK_ACTION_BUTTON);
699 controller.reset(new TestSettingsApiBubbleController( 697 controller.reset(new TestSettingsApiBubbleController(
700 profile(), static_cast<SettingsApiOverrideType>(i))); 698 profile(), static_cast<SettingsApiOverrideType>(i)));
701 EXPECT_TRUE(controller->ShouldShow(kId2)); 699 EXPECT_TRUE(controller->ShouldShow());
702 override_extensions = controller->GetExtensionList(); 700 override_extensions = controller->GetExtensionList();
703 EXPECT_EQ(1U, override_extensions.size()); 701 EXPECT_EQ(1U, override_extensions.size());
702 bubble.set_controller(controller.get());
704 controller->Show(&bubble); // Simulate showing the bubble. 703 controller->Show(&bubble); // Simulate showing the bubble.
705 EXPECT_EQ(0U, controller->link_click_count()); 704 EXPECT_EQ(0U, controller->link_click_count());
706 EXPECT_EQ(1U, controller->action_click_count()); 705 EXPECT_EQ(1U, controller->action_click_count());
707 EXPECT_EQ(0U, controller->dismiss_click_count()); 706 EXPECT_EQ(0U, controller->dismiss_click_count());
708 // Only extension 2 should have become disabled. 707 // Only extension 2 should have become disabled.
709 EXPECT_TRUE(registry->enabled_extensions().GetByID(kId1) != NULL); 708 EXPECT_TRUE(registry->enabled_extensions().GetByID(kId1) != NULL);
710 EXPECT_TRUE(registry->disabled_extensions().GetByID(kId2) != NULL); 709 EXPECT_TRUE(registry->disabled_extensions().GetByID(kId2) != NULL);
711 EXPECT_TRUE(registry->enabled_extensions().GetByID(kId3) != NULL); 710 EXPECT_TRUE(registry->enabled_extensions().GetByID(kId3) != NULL);
712 // No extension should have been acknowledged (it got disabled). 711 // No extension should have been acknowledged (it got disabled).
713 EXPECT_FALSE(controller->delegate()->HasBubbleInfoBeenAcknowledged(kId1)); 712 EXPECT_FALSE(controller->delegate()->HasBubbleInfoBeenAcknowledged(kId1));
714 EXPECT_FALSE(controller->delegate()->HasBubbleInfoBeenAcknowledged(kId2)); 713 EXPECT_FALSE(controller->delegate()->HasBubbleInfoBeenAcknowledged(kId2));
715 EXPECT_FALSE(controller->delegate()->HasBubbleInfoBeenAcknowledged(kId3)); 714 EXPECT_FALSE(controller->delegate()->HasBubbleInfoBeenAcknowledged(kId3));
716 715
717 // Clean up after ourselves. 716 // Clean up after ourselves.
718 service_->UninstallExtension(kId1, 717 service_->UninstallExtension(kId1,
719 extensions::UNINSTALL_REASON_FOR_TESTING, 718 extensions::UNINSTALL_REASON_FOR_TESTING,
720 base::Bind(&base::DoNothing), 719 base::Bind(&base::DoNothing),
721 NULL); 720 NULL);
722 service_->UninstallExtension(kId2, 721 service_->UninstallExtension(kId2,
723 extensions::UNINSTALL_REASON_FOR_TESTING, 722 extensions::UNINSTALL_REASON_FOR_TESTING,
724 base::Bind(&base::DoNothing), 723 base::Bind(&base::DoNothing),
725 NULL); 724 NULL);
726 service_->UninstallExtension(kId3, 725 service_->UninstallExtension(kId3,
727 extensions::UNINSTALL_REASON_FOR_TESTING, 726 extensions::UNINSTALL_REASON_FOR_TESTING,
728 base::Bind(&base::DoNothing), 727 base::Bind(&base::DoNothing),
729 NULL); 728 NULL);
730 } 729 }
731 } 730 }
732 731
733 // The feature this is meant to test is only implemented on Windows. 732 // The feature this is meant to test is only enacted on Windows, but it should
734 #if defined(OS_WIN) 733 // pass on all platforms.
735 #define MAYBE_NtpOverriddenControllerTest NtpOverriddenControllerTest 734 TEST_F(ExtensionMessageBubbleTest, NtpOverriddenControllerTest) {
736 #else
737 #define MAYBE_NtpOverriddenControllerTest DISABLED_NtpOverriddenControllerTest
738 #endif
739
740 TEST_F(ExtensionMessageBubbleTest, MAYBE_NtpOverriddenControllerTest) {
741 Init(); 735 Init();
742 // Load two extensions overriding new tab page and one overriding something 736 // Load two extensions overriding new tab page and one overriding something
743 // unrelated (to check for interference). Extension 2 should still win 737 // unrelated (to check for interference). Extension 2 should still win
744 // on the new tab page setting. 738 // on the new tab page setting.
745 ASSERT_TRUE(LoadExtensionOverridingNtp("1", kId1, Manifest::UNPACKED)); 739 ASSERT_TRUE(LoadExtensionOverridingNtp("1", kId1, Manifest::UNPACKED));
746 ASSERT_TRUE(LoadExtensionOverridingNtp("2", kId2, Manifest::UNPACKED)); 740 ASSERT_TRUE(LoadExtensionOverridingNtp("2", kId2, Manifest::UNPACKED));
747 ASSERT_TRUE(LoadExtensionOverridingStart("3", kId3, Manifest::UNPACKED)); 741 ASSERT_TRUE(LoadExtensionOverridingStart("3", kId3, Manifest::UNPACKED));
748 742
749 scoped_ptr<TestNtpOverriddenBubbleController> controller( 743 scoped_ptr<TestNtpOverriddenBubbleController> controller(
750 new TestNtpOverriddenBubbleController(profile())); 744 new TestNtpOverriddenBubbleController(profile()));
751 745
752 // The list will contain one enabled unpacked extension (ext 2). 746 // The list will contain one enabled unpacked extension (ext 2).
753 EXPECT_TRUE(controller->ShouldShow(kId2)); 747 EXPECT_TRUE(controller->ShouldShow(kId2));
754 std::vector<base::string16> override_extensions = 748 std::vector<base::string16> override_extensions =
755 controller->GetExtensionList(); 749 controller->GetExtensionList();
756 ASSERT_EQ(1U, override_extensions.size()); 750 ASSERT_EQ(1U, override_extensions.size());
757 EXPECT_TRUE(base::ASCIIToUTF16("Extension 2") == 751 EXPECT_TRUE(base::ASCIIToUTF16("Extension 2") ==
758 override_extensions[0].c_str()); 752 override_extensions[0].c_str());
759 EXPECT_EQ(0U, controller->link_click_count()); 753 EXPECT_EQ(0U, controller->link_click_count());
760 EXPECT_EQ(0U, controller->dismiss_click_count()); 754 EXPECT_EQ(0U, controller->dismiss_click_count());
761 EXPECT_EQ(0U, controller->action_click_count()); 755 EXPECT_EQ(0U, controller->action_click_count());
762 756
763 // Simulate showing the bubble and dismissing it. 757 // Simulate showing the bubble and dismissing it.
764 FakeExtensionMessageBubble bubble; 758 FakeExtensionMessageBubble bubble;
765 bubble.set_action_on_show( 759 bubble.set_action_on_show(
766 FakeExtensionMessageBubble::BUBBLE_ACTION_CLICK_DISMISS_BUTTON); 760 FakeExtensionMessageBubble::BUBBLE_ACTION_CLICK_DISMISS_BUTTON);
767 EXPECT_TRUE(controller->ShouldShow(kId2)); 761 EXPECT_TRUE(controller->ShouldShow(kId2));
762 bubble.set_controller(controller.get());
768 controller->Show(&bubble); 763 controller->Show(&bubble);
769 EXPECT_EQ(0U, controller->link_click_count()); 764 EXPECT_EQ(0U, controller->link_click_count());
770 EXPECT_EQ(0U, controller->action_click_count()); 765 EXPECT_EQ(0U, controller->action_click_count());
771 EXPECT_EQ(1U, controller->dismiss_click_count()); 766 EXPECT_EQ(1U, controller->dismiss_click_count());
772 // No extension should have become disabled. 767 // No extension should have become disabled.
773 ExtensionRegistry* registry = ExtensionRegistry::Get(profile()); 768 ExtensionRegistry* registry = ExtensionRegistry::Get(profile());
774 EXPECT_TRUE(registry->enabled_extensions().GetByID(kId1) != NULL); 769 EXPECT_TRUE(registry->enabled_extensions().GetByID(kId1) != NULL);
775 EXPECT_TRUE(registry->enabled_extensions().GetByID(kId2) != NULL); 770 EXPECT_TRUE(registry->enabled_extensions().GetByID(kId2) != NULL);
776 EXPECT_TRUE(registry->enabled_extensions().GetByID(kId3) != NULL); 771 EXPECT_TRUE(registry->enabled_extensions().GetByID(kId3) != NULL);
777 // Only extension 2 should have been acknowledged. 772 // Only extension 2 should have been acknowledged.
778 EXPECT_FALSE(controller->delegate()->HasBubbleInfoBeenAcknowledged(kId1)); 773 EXPECT_FALSE(controller->delegate()->HasBubbleInfoBeenAcknowledged(kId1));
779 EXPECT_TRUE(controller->delegate()->HasBubbleInfoBeenAcknowledged(kId2)); 774 EXPECT_TRUE(controller->delegate()->HasBubbleInfoBeenAcknowledged(kId2));
780 EXPECT_FALSE(controller->delegate()->HasBubbleInfoBeenAcknowledged(kId3)); 775 EXPECT_FALSE(controller->delegate()->HasBubbleInfoBeenAcknowledged(kId3));
781 // Clean up after ourselves. 776 // Clean up after ourselves.
782 controller->delegate()->SetBubbleInfoBeenAcknowledged(kId2, false); 777 controller->delegate()->SetBubbleInfoBeenAcknowledged(kId2, false);
783 778
784 // Simulate clicking the learn more link to dismiss it. 779 // Simulate clicking the learn more link to dismiss it.
785 bubble.set_action_on_show( 780 bubble.set_action_on_show(
786 FakeExtensionMessageBubble::BUBBLE_ACTION_CLICK_LINK); 781 FakeExtensionMessageBubble::BUBBLE_ACTION_CLICK_LINK);
787 controller.reset(new TestNtpOverriddenBubbleController(profile())); 782 controller.reset(new TestNtpOverriddenBubbleController(profile()));
788 EXPECT_TRUE(controller->ShouldShow(kId2)); 783 EXPECT_TRUE(controller->ShouldShow(kId2));
784 bubble.set_controller(controller.get());
789 controller->Show(&bubble); 785 controller->Show(&bubble);
790 EXPECT_EQ(1U, controller->link_click_count()); 786 EXPECT_EQ(1U, controller->link_click_count());
791 EXPECT_EQ(0U, controller->action_click_count()); 787 EXPECT_EQ(0U, controller->action_click_count());
792 EXPECT_EQ(0U, controller->dismiss_click_count()); 788 EXPECT_EQ(0U, controller->dismiss_click_count());
793 // No extension should have become disabled. 789 // No extension should have become disabled.
794 EXPECT_TRUE(registry->enabled_extensions().GetByID(kId1) != NULL); 790 EXPECT_TRUE(registry->enabled_extensions().GetByID(kId1) != NULL);
795 EXPECT_TRUE(registry->enabled_extensions().GetByID(kId2) != NULL); 791 EXPECT_TRUE(registry->enabled_extensions().GetByID(kId2) != NULL);
796 EXPECT_TRUE(registry->enabled_extensions().GetByID(kId3) != NULL); 792 EXPECT_TRUE(registry->enabled_extensions().GetByID(kId3) != NULL);
797 // Only extension 2 should have been acknowledged. 793 // Only extension 2 should have been acknowledged.
798 EXPECT_FALSE(controller->delegate()->HasBubbleInfoBeenAcknowledged(kId1)); 794 EXPECT_FALSE(controller->delegate()->HasBubbleInfoBeenAcknowledged(kId1));
799 EXPECT_TRUE(controller->delegate()->HasBubbleInfoBeenAcknowledged(kId2)); 795 EXPECT_TRUE(controller->delegate()->HasBubbleInfoBeenAcknowledged(kId2));
800 EXPECT_FALSE(controller->delegate()->HasBubbleInfoBeenAcknowledged(kId3)); 796 EXPECT_FALSE(controller->delegate()->HasBubbleInfoBeenAcknowledged(kId3));
801 // Clean up after ourselves. 797 // Clean up after ourselves.
802 controller->delegate()->SetBubbleInfoBeenAcknowledged(kId2, false); 798 controller->delegate()->SetBubbleInfoBeenAcknowledged(kId2, false);
803 799
804 // Do it again, but now opt to disable the extension. 800 // Do it again, but now opt to disable the extension.
805 bubble.set_action_on_show( 801 bubble.set_action_on_show(
806 FakeExtensionMessageBubble::BUBBLE_ACTION_CLICK_ACTION_BUTTON); 802 FakeExtensionMessageBubble::BUBBLE_ACTION_CLICK_ACTION_BUTTON);
807 controller.reset(new TestNtpOverriddenBubbleController(profile())); 803 controller.reset(new TestNtpOverriddenBubbleController(profile()));
808 EXPECT_TRUE(controller->ShouldShow(kId2)); 804 EXPECT_TRUE(controller->ShouldShow(kId2));
809 override_extensions = controller->GetExtensionList(); 805 override_extensions = controller->GetExtensionList();
810 EXPECT_EQ(1U, override_extensions.size()); 806 EXPECT_EQ(1U, override_extensions.size());
807 bubble.set_controller(controller.get());
811 controller->Show(&bubble); // Simulate showing the bubble. 808 controller->Show(&bubble); // Simulate showing the bubble.
812 EXPECT_EQ(0U, controller->link_click_count()); 809 EXPECT_EQ(0U, controller->link_click_count());
813 EXPECT_EQ(1U, controller->action_click_count()); 810 EXPECT_EQ(1U, controller->action_click_count());
814 EXPECT_EQ(0U, controller->dismiss_click_count()); 811 EXPECT_EQ(0U, controller->dismiss_click_count());
815 // Only extension 2 should have become disabled. 812 // Only extension 2 should have become disabled.
816 EXPECT_TRUE(registry->enabled_extensions().GetByID(kId1) != NULL); 813 EXPECT_TRUE(registry->enabled_extensions().GetByID(kId1) != NULL);
817 EXPECT_TRUE(registry->disabled_extensions().GetByID(kId2) != NULL); 814 EXPECT_TRUE(registry->disabled_extensions().GetByID(kId2) != NULL);
818 EXPECT_TRUE(registry->enabled_extensions().GetByID(kId3) != NULL); 815 EXPECT_TRUE(registry->enabled_extensions().GetByID(kId3) != NULL);
819 // No extension should have been acknowledged (it got disabled). 816 // No extension should have been acknowledged (it got disabled).
820 EXPECT_FALSE(controller->delegate()->HasBubbleInfoBeenAcknowledged(kId1)); 817 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()); 885 ASSERT_EQ(1U, override_extensions.size());
889 EXPECT_EQ(base::ASCIIToUTF16("Extension 2"), override_extensions[0]); 886 EXPECT_EQ(base::ASCIIToUTF16("Extension 2"), override_extensions[0]);
890 EXPECT_EQ(0U, controller->link_click_count()); 887 EXPECT_EQ(0U, controller->link_click_count());
891 EXPECT_EQ(0U, controller->dismiss_click_count()); 888 EXPECT_EQ(0U, controller->dismiss_click_count());
892 EXPECT_EQ(0U, controller->action_click_count()); 889 EXPECT_EQ(0U, controller->action_click_count());
893 890
894 // Simulate showing the bubble and dismissing it. 891 // Simulate showing the bubble and dismissing it.
895 FakeExtensionMessageBubble bubble; 892 FakeExtensionMessageBubble bubble;
896 bubble.set_action_on_show( 893 bubble.set_action_on_show(
897 FakeExtensionMessageBubble::BUBBLE_ACTION_CLICK_DISMISS_BUTTON); 894 FakeExtensionMessageBubble::BUBBLE_ACTION_CLICK_DISMISS_BUTTON);
895 bubble.set_controller(controller.get());
898 controller->Show(&bubble); 896 controller->Show(&bubble);
899 EXPECT_EQ(0U, controller->link_click_count()); 897 EXPECT_EQ(0U, controller->link_click_count());
900 EXPECT_EQ(0U, controller->action_click_count()); 898 EXPECT_EQ(0U, controller->action_click_count());
901 EXPECT_EQ(1U, controller->dismiss_click_count()); 899 EXPECT_EQ(1U, controller->dismiss_click_count());
902 // No extension should have become disabled. 900 // No extension should have become disabled.
903 ExtensionRegistry* registry = ExtensionRegistry::Get(profile()); 901 ExtensionRegistry* registry = ExtensionRegistry::Get(profile());
904 EXPECT_TRUE(registry->enabled_extensions().GetByID(kId1) != NULL); 902 EXPECT_TRUE(registry->enabled_extensions().GetByID(kId1) != NULL);
905 EXPECT_TRUE(registry->enabled_extensions().GetByID(kId2) != NULL); 903 EXPECT_TRUE(registry->enabled_extensions().GetByID(kId2) != NULL);
906 EXPECT_TRUE(registry->enabled_extensions().GetByID(kId3) != NULL); 904 EXPECT_TRUE(registry->enabled_extensions().GetByID(kId3) != NULL);
907 // Only extension 2 should have been acknowledged. 905 // Only extension 2 should have been acknowledged.
908 EXPECT_FALSE(controller->delegate()->HasBubbleInfoBeenAcknowledged(kId1)); 906 EXPECT_FALSE(controller->delegate()->HasBubbleInfoBeenAcknowledged(kId1));
909 EXPECT_TRUE(controller->delegate()->HasBubbleInfoBeenAcknowledged(kId2)); 907 EXPECT_TRUE(controller->delegate()->HasBubbleInfoBeenAcknowledged(kId2));
910 EXPECT_FALSE(controller->delegate()->HasBubbleInfoBeenAcknowledged(kId3)); 908 EXPECT_FALSE(controller->delegate()->HasBubbleInfoBeenAcknowledged(kId3));
911 // Clean up after ourselves. 909 // Clean up after ourselves.
912 controller->delegate()->SetBubbleInfoBeenAcknowledged(kId2, false); 910 controller->delegate()->SetBubbleInfoBeenAcknowledged(kId2, false);
913 911
914 // Simulate clicking the learn more link to dismiss it. 912 // Simulate clicking the learn more link to dismiss it.
915 bubble.set_action_on_show( 913 bubble.set_action_on_show(
916 FakeExtensionMessageBubble::BUBBLE_ACTION_CLICK_LINK); 914 FakeExtensionMessageBubble::BUBBLE_ACTION_CLICK_LINK);
917 controller.reset(new TestProxyOverriddenBubbleController(profile())); 915 controller.reset(new TestProxyOverriddenBubbleController(profile()));
918 EXPECT_TRUE(controller->ShouldShow(kId2)); 916 EXPECT_TRUE(controller->ShouldShow(kId2));
917 bubble.set_controller(controller.get());
919 controller->Show(&bubble); 918 controller->Show(&bubble);
920 EXPECT_EQ(1U, controller->link_click_count()); 919 EXPECT_EQ(1U, controller->link_click_count());
921 EXPECT_EQ(0U, controller->action_click_count()); 920 EXPECT_EQ(0U, controller->action_click_count());
922 EXPECT_EQ(0U, controller->dismiss_click_count()); 921 EXPECT_EQ(0U, controller->dismiss_click_count());
923 // No extension should have become disabled. 922 // No extension should have become disabled.
924 EXPECT_TRUE(registry->enabled_extensions().GetByID(kId1) != NULL); 923 EXPECT_TRUE(registry->enabled_extensions().GetByID(kId1) != NULL);
925 EXPECT_TRUE(registry->enabled_extensions().GetByID(kId2) != NULL); 924 EXPECT_TRUE(registry->enabled_extensions().GetByID(kId2) != NULL);
926 EXPECT_TRUE(registry->enabled_extensions().GetByID(kId3) != NULL); 925 EXPECT_TRUE(registry->enabled_extensions().GetByID(kId3) != NULL);
927 // Only extension 2 should have been acknowledged. 926 // Only extension 2 should have been acknowledged.
928 EXPECT_FALSE(controller->delegate()->HasBubbleInfoBeenAcknowledged(kId1)); 927 EXPECT_FALSE(controller->delegate()->HasBubbleInfoBeenAcknowledged(kId1));
929 EXPECT_TRUE(controller->delegate()->HasBubbleInfoBeenAcknowledged(kId2)); 928 EXPECT_TRUE(controller->delegate()->HasBubbleInfoBeenAcknowledged(kId2));
930 EXPECT_FALSE(controller->delegate()->HasBubbleInfoBeenAcknowledged(kId3)); 929 EXPECT_FALSE(controller->delegate()->HasBubbleInfoBeenAcknowledged(kId3));
931 // Clean up after ourselves. 930 // Clean up after ourselves.
932 controller->delegate()->SetBubbleInfoBeenAcknowledged(kId2, false); 931 controller->delegate()->SetBubbleInfoBeenAcknowledged(kId2, false);
933 932
934 // Do it again, but now opt to disable the extension. 933 // Do it again, but now opt to disable the extension.
935 bubble.set_action_on_show( 934 bubble.set_action_on_show(
936 FakeExtensionMessageBubble::BUBBLE_ACTION_CLICK_ACTION_BUTTON); 935 FakeExtensionMessageBubble::BUBBLE_ACTION_CLICK_ACTION_BUTTON);
937 controller.reset(new TestProxyOverriddenBubbleController(profile())); 936 controller.reset(new TestProxyOverriddenBubbleController(profile()));
938 EXPECT_TRUE(controller->ShouldShow(kId2)); 937 EXPECT_TRUE(controller->ShouldShow(kId2));
939 override_extensions = controller->GetExtensionList(); 938 override_extensions = controller->GetExtensionList();
940 EXPECT_EQ(1U, override_extensions.size()); 939 EXPECT_EQ(1U, override_extensions.size());
940 bubble.set_controller(controller.get());
941 controller->Show(&bubble); // Simulate showing the bubble. 941 controller->Show(&bubble); // Simulate showing the bubble.
942 EXPECT_EQ(0U, controller->link_click_count()); 942 EXPECT_EQ(0U, controller->link_click_count());
943 EXPECT_EQ(1U, controller->action_click_count()); 943 EXPECT_EQ(1U, controller->action_click_count());
944 EXPECT_EQ(0U, controller->dismiss_click_count()); 944 EXPECT_EQ(0U, controller->dismiss_click_count());
945 // Only extension 2 should have become disabled. 945 // Only extension 2 should have become disabled.
946 EXPECT_TRUE(registry->enabled_extensions().GetByID(kId1) != NULL); 946 EXPECT_TRUE(registry->enabled_extensions().GetByID(kId1) != NULL);
947 EXPECT_TRUE(registry->disabled_extensions().GetByID(kId2) != NULL); 947 EXPECT_TRUE(registry->disabled_extensions().GetByID(kId2) != NULL);
948 EXPECT_TRUE(registry->enabled_extensions().GetByID(kId3) != NULL); 948 EXPECT_TRUE(registry->enabled_extensions().GetByID(kId3) != NULL);
949 949
950 // No extension should have been acknowledged (it got disabled). 950 // No extension should have been acknowledged (it got disabled).
(...skipping 10 matching lines...) Expand all
961 extensions::UNINSTALL_REASON_FOR_TESTING, 961 extensions::UNINSTALL_REASON_FOR_TESTING,
962 base::Bind(&base::DoNothing), 962 base::Bind(&base::DoNothing),
963 NULL); 963 NULL);
964 service_->UninstallExtension(kId3, 964 service_->UninstallExtension(kId3,
965 extensions::UNINSTALL_REASON_FOR_TESTING, 965 extensions::UNINSTALL_REASON_FOR_TESTING,
966 base::Bind(&base::DoNothing), 966 base::Bind(&base::DoNothing),
967 NULL); 967 NULL);
968 } 968 }
969 969
970 } // namespace extensions 970 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698