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

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

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