| OLD | NEW |
| 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 <stddef.h> | 5 #include <stddef.h> |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind_helpers.h" | 9 #include "base/bind_helpers.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 316 static_cast<TestExtensionSystem*>(ExtensionSystem::Get(profile())) | 316 static_cast<TestExtensionSystem*>(ExtensionSystem::Get(profile())) |
| 317 ->CreateExtensionService(base::CommandLine::ForCurrentProcess(), | 317 ->CreateExtensionService(base::CommandLine::ForCurrentProcess(), |
| 318 base::FilePath(), false); | 318 base::FilePath(), false); |
| 319 service_ = ExtensionSystem::Get(profile())->extension_service(); | 319 service_ = ExtensionSystem::Get(profile())->extension_service(); |
| 320 service_->Init(); | 320 service_->Init(); |
| 321 | 321 |
| 322 extensions::ExtensionWebUIOverrideRegistrar::GetFactoryInstance()-> | 322 extensions::ExtensionWebUIOverrideRegistrar::GetFactoryInstance()-> |
| 323 SetTestingFactory(profile(), &BuildOverrideRegistrar); | 323 SetTestingFactory(profile(), &BuildOverrideRegistrar); |
| 324 extensions::ExtensionWebUIOverrideRegistrar::GetFactoryInstance()->Get( | 324 extensions::ExtensionWebUIOverrideRegistrar::GetFactoryInstance()->Get( |
| 325 profile()); | 325 profile()); |
| 326 ToolbarActionsModelFactory::GetInstance()->SetTestingFactory( |
| 327 profile(), &BuildToolbarModel); |
| 326 } | 328 } |
| 327 | 329 |
| 328 ~ExtensionMessageBubbleTest() override {} | 330 ~ExtensionMessageBubbleTest() override {} |
| 329 | 331 |
| 330 void SetUp() override { | 332 void SetUp() override { |
| 331 BrowserWithTestWindowTest::SetUp(); | 333 BrowserWithTestWindowTest::SetUp(); |
| 332 command_line_.reset(new base::CommandLine(base::CommandLine::NO_PROGRAM)); | 334 command_line_.reset(new base::CommandLine(base::CommandLine::NO_PROGRAM)); |
| 333 ExtensionMessageBubbleController::set_should_ignore_learn_more_for_testing( | 335 ExtensionMessageBubbleController::set_should_ignore_learn_more_for_testing( |
| 334 true); | 336 true); |
| 335 } | 337 } |
| (...skipping 23 matching lines...) Expand all Loading... |
| 359 }; | 361 }; |
| 360 | 362 |
| 361 TEST_F(ExtensionMessageBubbleTest, BubbleReshowsOnDeactivationDismissal) { | 363 TEST_F(ExtensionMessageBubbleTest, BubbleReshowsOnDeactivationDismissal) { |
| 362 Init(); | 364 Init(); |
| 363 | 365 |
| 364 ASSERT_TRUE(LoadExtensionOverridingNtp("1", kId1, Manifest::INTERNAL)); | 366 ASSERT_TRUE(LoadExtensionOverridingNtp("1", kId1, Manifest::INTERNAL)); |
| 365 ASSERT_TRUE(LoadExtensionOverridingNtp("2", kId2, Manifest::INTERNAL)); | 367 ASSERT_TRUE(LoadExtensionOverridingNtp("2", kId2, Manifest::INTERNAL)); |
| 366 std::unique_ptr<TestExtensionMessageBubbleController> controller( | 368 std::unique_ptr<TestExtensionMessageBubbleController> controller( |
| 367 new TestExtensionMessageBubbleController( | 369 new TestExtensionMessageBubbleController( |
| 368 new NtpOverriddenBubbleDelegate(browser()->profile()), browser())); | 370 new NtpOverriddenBubbleDelegate(browser()->profile()), browser())); |
| 371 controller->SetIsActiveBubble(); |
| 369 | 372 |
| 370 // The list will contain one enabled unpacked extension (ext 2). | 373 // The list will contain one enabled unpacked extension (ext 2). |
| 371 EXPECT_TRUE(controller->ShouldShow()); | 374 EXPECT_TRUE(controller->ShouldShow()); |
| 372 std::vector<base::string16> override_extensions = | 375 std::vector<base::string16> override_extensions = |
| 373 controller->GetExtensionList(); | 376 controller->GetExtensionList(); |
| 374 ASSERT_EQ(1U, override_extensions.size()); | 377 ASSERT_EQ(1U, override_extensions.size()); |
| 375 EXPECT_EQ(base::ASCIIToUTF16("Extension 2"), override_extensions[0]); | 378 EXPECT_EQ(base::ASCIIToUTF16("Extension 2"), override_extensions[0]); |
| 376 EXPECT_EQ(0U, controller->link_click_count()); | 379 EXPECT_EQ(0U, controller->link_click_count()); |
| 377 EXPECT_EQ(0U, controller->dismiss_click_count()); | 380 EXPECT_EQ(0U, controller->dismiss_click_count()); |
| 378 EXPECT_EQ(0U, controller->action_click_count()); | 381 EXPECT_EQ(0U, controller->action_click_count()); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 391 ExtensionRegistry* registry = ExtensionRegistry::Get(profile()); | 394 ExtensionRegistry* registry = ExtensionRegistry::Get(profile()); |
| 392 EXPECT_TRUE(registry->enabled_extensions().GetByID(kId2)); | 395 EXPECT_TRUE(registry->enabled_extensions().GetByID(kId2)); |
| 393 // And since it was dismissed due to deactivation, the extension should not | 396 // And since it was dismissed due to deactivation, the extension should not |
| 394 // have been acknowledged. | 397 // have been acknowledged. |
| 395 EXPECT_FALSE(controller->delegate()->HasBubbleInfoBeenAcknowledged(kId2)); | 398 EXPECT_FALSE(controller->delegate()->HasBubbleInfoBeenAcknowledged(kId2)); |
| 396 | 399 |
| 397 bubble.set_action_on_show( | 400 bubble.set_action_on_show( |
| 398 FakeExtensionMessageBubble::BUBBLE_ACTION_DISMISS_DEACTIVATION); | 401 FakeExtensionMessageBubble::BUBBLE_ACTION_DISMISS_DEACTIVATION); |
| 399 controller.reset(new TestExtensionMessageBubbleController( | 402 controller.reset(new TestExtensionMessageBubbleController( |
| 400 new NtpOverriddenBubbleDelegate(browser()->profile()), browser())); | 403 new NtpOverriddenBubbleDelegate(browser()->profile()), browser())); |
| 404 controller->SetIsActiveBubble(); |
| 401 // The bubble shouldn't show again for the same profile (we don't want to | 405 // The bubble shouldn't show again for the same profile (we don't want to |
| 402 // be annoying). | 406 // be annoying). |
| 403 EXPECT_FALSE(controller->ShouldShow()); | 407 EXPECT_FALSE(controller->ShouldShow()); |
| 404 controller->ClearProfileListForTesting(); | 408 controller->ClearProfileListForTesting(); |
| 405 EXPECT_TRUE(controller->ShouldShow()); | 409 EXPECT_TRUE(controller->ShouldShow()); |
| 406 // Explicitly click the dismiss button. The extension should be acknowledged. | 410 // Explicitly click the dismiss button. The extension should be acknowledged. |
| 407 bubble.set_controller(controller.get()); | 411 bubble.set_controller(controller.get()); |
| 408 bubble.set_action_on_show( | 412 bubble.set_action_on_show( |
| 409 FakeExtensionMessageBubble::BUBBLE_ACTION_CLICK_DISMISS_BUTTON); | 413 FakeExtensionMessageBubble::BUBBLE_ACTION_CLICK_DISMISS_BUTTON); |
| 410 bubble.Show(); | 414 bubble.Show(); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 429 // Add three extensions, and control two of them in this test (extension 1 | 433 // Add three extensions, and control two of them in this test (extension 1 |
| 430 // and 2). | 434 // and 2). |
| 431 ASSERT_TRUE(LoadExtensionWithAction("1", kId1, Manifest::COMMAND_LINE)); | 435 ASSERT_TRUE(LoadExtensionWithAction("1", kId1, Manifest::COMMAND_LINE)); |
| 432 ASSERT_TRUE(LoadGenericExtension("2", kId2, Manifest::UNPACKED)); | 436 ASSERT_TRUE(LoadGenericExtension("2", kId2, Manifest::UNPACKED)); |
| 433 ASSERT_TRUE(LoadGenericExtension("3", kId3, Manifest::EXTERNAL_POLICY)); | 437 ASSERT_TRUE(LoadGenericExtension("3", kId3, Manifest::EXTERNAL_POLICY)); |
| 434 | 438 |
| 435 std::unique_ptr<TestExtensionMessageBubbleController> controller( | 439 std::unique_ptr<TestExtensionMessageBubbleController> controller( |
| 436 new TestExtensionMessageBubbleController( | 440 new TestExtensionMessageBubbleController( |
| 437 new SuspiciousExtensionBubbleDelegate(browser()->profile()), | 441 new SuspiciousExtensionBubbleDelegate(browser()->profile()), |
| 438 browser())); | 442 browser())); |
| 443 controller->SetIsActiveBubble(); |
| 439 FakeExtensionMessageBubble bubble; | 444 FakeExtensionMessageBubble bubble; |
| 440 bubble.set_action_on_show( | 445 bubble.set_action_on_show( |
| 441 FakeExtensionMessageBubble::BUBBLE_ACTION_CLICK_DISMISS_BUTTON); | 446 FakeExtensionMessageBubble::BUBBLE_ACTION_CLICK_DISMISS_BUTTON); |
| 442 | 447 |
| 443 // Validate that we don't have a suppress value for the extensions. | 448 // Validate that we don't have a suppress value for the extensions. |
| 444 EXPECT_FALSE(controller->delegate()->HasBubbleInfoBeenAcknowledged(kId1)); | 449 EXPECT_FALSE(controller->delegate()->HasBubbleInfoBeenAcknowledged(kId1)); |
| 445 EXPECT_FALSE(controller->delegate()->HasBubbleInfoBeenAcknowledged(kId1)); | 450 EXPECT_FALSE(controller->delegate()->HasBubbleInfoBeenAcknowledged(kId1)); |
| 446 | 451 |
| 447 EXPECT_FALSE(controller->ShouldShow()); | 452 EXPECT_FALSE(controller->ShouldShow()); |
| 448 std::vector<base::string16> suspicious_extensions = | 453 std::vector<base::string16> suspicious_extensions = |
| 449 controller->GetExtensionList(); | 454 controller->GetExtensionList(); |
| 450 EXPECT_EQ(0U, suspicious_extensions.size()); | 455 EXPECT_EQ(0U, suspicious_extensions.size()); |
| 451 EXPECT_EQ(0U, controller->link_click_count()); | 456 EXPECT_EQ(0U, controller->link_click_count()); |
| 452 EXPECT_EQ(0U, controller->dismiss_click_count()); | 457 EXPECT_EQ(0U, controller->dismiss_click_count()); |
| 453 | 458 |
| 454 // Now disable an extension, specifying the wipeout flag. | 459 // Now disable an extension, specifying the wipeout flag. |
| 455 service_->DisableExtension(kId1, Extension::DISABLE_NOT_VERIFIED); | 460 service_->DisableExtension(kId1, Extension::DISABLE_NOT_VERIFIED); |
| 456 | 461 |
| 457 EXPECT_FALSE(controller->delegate()->HasBubbleInfoBeenAcknowledged(kId1)); | 462 EXPECT_FALSE(controller->delegate()->HasBubbleInfoBeenAcknowledged(kId1)); |
| 458 EXPECT_FALSE(controller->delegate()->HasBubbleInfoBeenAcknowledged(kId2)); | 463 EXPECT_FALSE(controller->delegate()->HasBubbleInfoBeenAcknowledged(kId2)); |
| 459 controller.reset( | 464 controller.reset( |
| 460 new TestExtensionMessageBubbleController( | 465 new TestExtensionMessageBubbleController( |
| 461 new SuspiciousExtensionBubbleDelegate(browser()->profile()), | 466 new SuspiciousExtensionBubbleDelegate(browser()->profile()), |
| 462 browser())); | 467 browser())); |
| 468 controller->SetIsActiveBubble(); |
| 463 controller->ClearProfileListForTesting(); | 469 controller->ClearProfileListForTesting(); |
| 464 EXPECT_TRUE(controller->ShouldShow()); | 470 EXPECT_TRUE(controller->ShouldShow()); |
| 465 suspicious_extensions = controller->GetExtensionList(); | 471 suspicious_extensions = controller->GetExtensionList(); |
| 466 ASSERT_EQ(1U, suspicious_extensions.size()); | 472 ASSERT_EQ(1U, suspicious_extensions.size()); |
| 467 EXPECT_TRUE(base::ASCIIToUTF16("Extension 1") == suspicious_extensions[0]); | 473 EXPECT_TRUE(base::ASCIIToUTF16("Extension 1") == suspicious_extensions[0]); |
| 468 bubble.set_controller(controller.get()); | 474 bubble.set_controller(controller.get()); |
| 469 bubble.Show(); // Simulate showing the bubble. | 475 bubble.Show(); // Simulate showing the bubble. |
| 470 EXPECT_EQ(0U, controller->link_click_count()); | 476 EXPECT_EQ(0U, controller->link_click_count()); |
| 471 EXPECT_EQ(1U, controller->dismiss_click_count()); | 477 EXPECT_EQ(1U, controller->dismiss_click_count()); |
| 472 // Now the acknowledge flag should be set only for the first extension. | 478 // Now the acknowledge flag should be set only for the first extension. |
| 473 EXPECT_TRUE(controller->delegate()->HasBubbleInfoBeenAcknowledged(kId1)); | 479 EXPECT_TRUE(controller->delegate()->HasBubbleInfoBeenAcknowledged(kId1)); |
| 474 EXPECT_FALSE(controller->delegate()->HasBubbleInfoBeenAcknowledged(kId2)); | 480 EXPECT_FALSE(controller->delegate()->HasBubbleInfoBeenAcknowledged(kId2)); |
| 475 // Clear the flag. | 481 // Clear the flag. |
| 476 controller->delegate()->SetBubbleInfoBeenAcknowledged(kId1, false); | 482 controller->delegate()->SetBubbleInfoBeenAcknowledged(kId1, false); |
| 477 EXPECT_FALSE(controller->delegate()->HasBubbleInfoBeenAcknowledged(kId1)); | 483 EXPECT_FALSE(controller->delegate()->HasBubbleInfoBeenAcknowledged(kId1)); |
| 478 | 484 |
| 479 // Now disable the other extension and exercise the link click code path. | 485 // Now disable the other extension and exercise the link click code path. |
| 480 service_->DisableExtension(kId2, Extension::DISABLE_NOT_VERIFIED); | 486 service_->DisableExtension(kId2, Extension::DISABLE_NOT_VERIFIED); |
| 481 | 487 |
| 482 bubble.set_action_on_show( | 488 bubble.set_action_on_show( |
| 483 FakeExtensionMessageBubble::BUBBLE_ACTION_CLICK_LINK); | 489 FakeExtensionMessageBubble::BUBBLE_ACTION_CLICK_LINK); |
| 484 controller.reset( | 490 controller.reset( |
| 485 new TestExtensionMessageBubbleController( | 491 new TestExtensionMessageBubbleController( |
| 486 new SuspiciousExtensionBubbleDelegate(browser()->profile()), | 492 new SuspiciousExtensionBubbleDelegate(browser()->profile()), |
| 487 browser())); | 493 browser())); |
| 494 controller->SetIsActiveBubble(); |
| 488 controller->ClearProfileListForTesting(); | 495 controller->ClearProfileListForTesting(); |
| 489 EXPECT_TRUE(controller->ShouldShow()); | 496 EXPECT_TRUE(controller->ShouldShow()); |
| 490 suspicious_extensions = controller->GetExtensionList(); | 497 suspicious_extensions = controller->GetExtensionList(); |
| 491 ASSERT_EQ(2U, suspicious_extensions.size()); | 498 ASSERT_EQ(2U, suspicious_extensions.size()); |
| 492 EXPECT_TRUE(base::ASCIIToUTF16("Extension 1") == suspicious_extensions[1]); | 499 EXPECT_TRUE(base::ASCIIToUTF16("Extension 1") == suspicious_extensions[1]); |
| 493 EXPECT_TRUE(base::ASCIIToUTF16("Extension 2") == suspicious_extensions[0]); | 500 EXPECT_TRUE(base::ASCIIToUTF16("Extension 2") == suspicious_extensions[0]); |
| 494 bubble.set_controller(controller.get()); | 501 bubble.set_controller(controller.get()); |
| 495 bubble.Show(); // Simulate showing the bubble. | 502 bubble.Show(); // Simulate showing the bubble. |
| 496 EXPECT_EQ(1U, controller->link_click_count()); | 503 EXPECT_EQ(1U, controller->link_click_count()); |
| 497 EXPECT_EQ(0U, controller->dismiss_click_count()); | 504 EXPECT_EQ(0U, controller->dismiss_click_count()); |
| 498 EXPECT_TRUE(controller->delegate()->HasBubbleInfoBeenAcknowledged(kId1)); | 505 EXPECT_TRUE(controller->delegate()->HasBubbleInfoBeenAcknowledged(kId1)); |
| 499 } | 506 } |
| 500 | 507 |
| 501 // The feature this is meant to test is only enacted on Windows, but it should | 508 // The feature this is meant to test is only enacted on Windows, but it should |
| 502 // pass on all platforms. | 509 // pass on all platforms. |
| 503 TEST_F(ExtensionMessageBubbleTest, DevModeControllerTest) { | 510 TEST_F(ExtensionMessageBubbleTest, DevModeControllerTest) { |
| 504 FeatureSwitch::ScopedOverride force_dev_mode_highlighting( | 511 FeatureSwitch::ScopedOverride force_dev_mode_highlighting( |
| 505 FeatureSwitch::force_dev_mode_highlighting(), true); | 512 FeatureSwitch::force_dev_mode_highlighting(), true); |
| 506 Init(); | 513 Init(); |
| 507 // Add three extensions, and control two of them in this test (extension 1 | 514 // Add three extensions, and control two of them in this test (extension 1 |
| 508 // and 2). Extension 1 is a regular extension, Extension 2 is UNPACKED so it | 515 // and 2). Extension 1 is a regular extension, Extension 2 is UNPACKED so it |
| 509 // counts as a DevMode extension. | 516 // counts as a DevMode extension. |
| 510 ASSERT_TRUE(LoadExtensionWithAction("1", kId1, Manifest::COMMAND_LINE)); | 517 ASSERT_TRUE(LoadExtensionWithAction("1", kId1, Manifest::COMMAND_LINE)); |
| 511 ASSERT_TRUE(LoadGenericExtension("2", kId2, Manifest::UNPACKED)); | 518 ASSERT_TRUE(LoadGenericExtension("2", kId2, Manifest::UNPACKED)); |
| 512 ASSERT_TRUE(LoadGenericExtension("3", kId3, Manifest::EXTERNAL_POLICY)); | 519 ASSERT_TRUE(LoadGenericExtension("3", kId3, Manifest::EXTERNAL_POLICY)); |
| 513 | 520 |
| 514 std::unique_ptr<TestExtensionMessageBubbleController> controller( | 521 std::unique_ptr<TestExtensionMessageBubbleController> controller( |
| 515 new TestExtensionMessageBubbleController( | 522 new TestExtensionMessageBubbleController( |
| 516 new DevModeBubbleDelegate(browser()->profile()), browser())); | 523 new DevModeBubbleDelegate(browser()->profile()), browser())); |
| 524 controller->SetIsActiveBubble(); |
| 517 | 525 |
| 518 // The list will contain one enabled unpacked extension. | 526 // The list will contain one enabled unpacked extension. |
| 519 EXPECT_TRUE(controller->ShouldShow()); | 527 EXPECT_TRUE(controller->ShouldShow()); |
| 520 std::vector<base::string16> dev_mode_extensions = | 528 std::vector<base::string16> dev_mode_extensions = |
| 521 controller->GetExtensionList(); | 529 controller->GetExtensionList(); |
| 522 ASSERT_EQ(2U, dev_mode_extensions.size()); | 530 ASSERT_EQ(2U, dev_mode_extensions.size()); |
| 523 EXPECT_TRUE(base::ASCIIToUTF16("Extension 2") == dev_mode_extensions[0]); | 531 EXPECT_TRUE(base::ASCIIToUTF16("Extension 2") == dev_mode_extensions[0]); |
| 524 EXPECT_TRUE(base::ASCIIToUTF16("Extension 1") == dev_mode_extensions[1]); | 532 EXPECT_TRUE(base::ASCIIToUTF16("Extension 1") == dev_mode_extensions[1]); |
| 525 EXPECT_EQ(0U, controller->link_click_count()); | 533 EXPECT_EQ(0U, controller->link_click_count()); |
| 526 EXPECT_EQ(0U, controller->dismiss_click_count()); | 534 EXPECT_EQ(0U, controller->dismiss_click_count()); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 539 EXPECT_TRUE(registry->enabled_extensions().GetByID(kId1) != NULL); | 547 EXPECT_TRUE(registry->enabled_extensions().GetByID(kId1) != NULL); |
| 540 EXPECT_TRUE(registry->enabled_extensions().GetByID(kId2) != NULL); | 548 EXPECT_TRUE(registry->enabled_extensions().GetByID(kId2) != NULL); |
| 541 | 549 |
| 542 // Do it again, but now press different button (Disable). | 550 // Do it again, but now press different button (Disable). |
| 543 bubble.set_action_on_show( | 551 bubble.set_action_on_show( |
| 544 FakeExtensionMessageBubble::BUBBLE_ACTION_CLICK_ACTION_BUTTON); | 552 FakeExtensionMessageBubble::BUBBLE_ACTION_CLICK_ACTION_BUTTON); |
| 545 controller.reset( | 553 controller.reset( |
| 546 new TestExtensionMessageBubbleController( | 554 new TestExtensionMessageBubbleController( |
| 547 new DevModeBubbleDelegate(browser()->profile()), | 555 new DevModeBubbleDelegate(browser()->profile()), |
| 548 browser())); | 556 browser())); |
| 557 controller->SetIsActiveBubble(); |
| 549 // Most bubbles would want to show again as long as the extensions weren't | 558 // Most bubbles would want to show again as long as the extensions weren't |
| 550 // acknowledged and the bubble wasn't dismissed due to deactivation. Since dev | 559 // acknowledged and the bubble wasn't dismissed due to deactivation. Since dev |
| 551 // mode extensions can't be (persistently) acknowledged, this isn't the case | 560 // mode extensions can't be (persistently) acknowledged, this isn't the case |
| 552 // for the dev mode bubble, and we should only show once per profile. | 561 // for the dev mode bubble, and we should only show once per profile. |
| 553 EXPECT_FALSE(controller->ShouldShow()); | 562 EXPECT_FALSE(controller->ShouldShow()); |
| 554 controller->ClearProfileListForTesting(); | 563 controller->ClearProfileListForTesting(); |
| 555 EXPECT_TRUE(controller->ShouldShow()); | 564 EXPECT_TRUE(controller->ShouldShow()); |
| 556 dev_mode_extensions = controller->GetExtensionList(); | 565 dev_mode_extensions = controller->GetExtensionList(); |
| 557 EXPECT_EQ(2U, dev_mode_extensions.size()); | 566 EXPECT_EQ(2U, dev_mode_extensions.size()); |
| 558 bubble.set_controller(controller.get()); | 567 bubble.set_controller(controller.get()); |
| 559 bubble.Show(); // Simulate showing the bubble. | 568 bubble.Show(); // Simulate showing the bubble. |
| 560 EXPECT_EQ(0U, controller->link_click_count()); | 569 EXPECT_EQ(0U, controller->link_click_count()); |
| 561 EXPECT_EQ(1U, controller->action_click_count()); | 570 EXPECT_EQ(1U, controller->action_click_count()); |
| 562 EXPECT_EQ(0U, controller->dismiss_click_count()); | 571 EXPECT_EQ(0U, controller->dismiss_click_count()); |
| 563 EXPECT_TRUE(registry->disabled_extensions().GetByID(kId1) != NULL); | 572 EXPECT_TRUE(registry->disabled_extensions().GetByID(kId1) != NULL); |
| 564 EXPECT_TRUE(registry->disabled_extensions().GetByID(kId2) != NULL); | 573 EXPECT_TRUE(registry->disabled_extensions().GetByID(kId2) != NULL); |
| 565 | 574 |
| 566 // Re-enable the extensions (disabled by the action button above). | 575 // Re-enable the extensions (disabled by the action button above). |
| 567 service_->EnableExtension(kId1); | 576 service_->EnableExtension(kId1); |
| 568 service_->EnableExtension(kId2); | 577 service_->EnableExtension(kId2); |
| 569 | 578 |
| 570 // Show the dialog a third time, but now press the learn more link. | 579 // Show the dialog a third time, but now press the learn more link. |
| 571 bubble.set_action_on_show( | 580 bubble.set_action_on_show( |
| 572 FakeExtensionMessageBubble::BUBBLE_ACTION_CLICK_LINK); | 581 FakeExtensionMessageBubble::BUBBLE_ACTION_CLICK_LINK); |
| 573 controller.reset( | 582 controller.reset( |
| 574 new TestExtensionMessageBubbleController( | 583 new TestExtensionMessageBubbleController( |
| 575 new DevModeBubbleDelegate(browser()->profile()), | 584 new DevModeBubbleDelegate(browser()->profile()), |
| 576 browser())); | 585 browser())); |
| 586 controller->SetIsActiveBubble(); |
| 577 controller->ClearProfileListForTesting(); | 587 controller->ClearProfileListForTesting(); |
| 578 EXPECT_TRUE(controller->ShouldShow()); | 588 EXPECT_TRUE(controller->ShouldShow()); |
| 579 dev_mode_extensions = controller->GetExtensionList(); | 589 dev_mode_extensions = controller->GetExtensionList(); |
| 580 EXPECT_EQ(2U, dev_mode_extensions.size()); | 590 EXPECT_EQ(2U, dev_mode_extensions.size()); |
| 581 bubble.set_controller(controller.get()); | 591 bubble.set_controller(controller.get()); |
| 582 bubble.Show(); // Simulate showing the bubble. | 592 bubble.Show(); // Simulate showing the bubble. |
| 583 EXPECT_EQ(1U, controller->link_click_count()); | 593 EXPECT_EQ(1U, controller->link_click_count()); |
| 584 EXPECT_EQ(0U, controller->action_click_count()); | 594 EXPECT_EQ(0U, controller->action_click_count()); |
| 585 EXPECT_EQ(0U, controller->dismiss_click_count()); | 595 EXPECT_EQ(0U, controller->dismiss_click_count()); |
| 586 EXPECT_TRUE(registry->enabled_extensions().GetByID(kId1) != NULL); | 596 EXPECT_TRUE(registry->enabled_extensions().GetByID(kId1) != NULL); |
| 587 EXPECT_TRUE(registry->enabled_extensions().GetByID(kId2) != NULL); | 597 EXPECT_TRUE(registry->enabled_extensions().GetByID(kId2) != NULL); |
| 588 | 598 |
| 589 // Now disable the unpacked extension. | 599 // Now disable the unpacked extension. |
| 590 service_->DisableExtension(kId1, Extension::DISABLE_USER_ACTION); | 600 service_->DisableExtension(kId1, Extension::DISABLE_USER_ACTION); |
| 591 service_->DisableExtension(kId2, Extension::DISABLE_USER_ACTION); | 601 service_->DisableExtension(kId2, Extension::DISABLE_USER_ACTION); |
| 592 | 602 |
| 593 controller.reset( | 603 controller.reset( |
| 594 new TestExtensionMessageBubbleController( | 604 new TestExtensionMessageBubbleController( |
| 595 new DevModeBubbleDelegate(browser()->profile()), | 605 new DevModeBubbleDelegate(browser()->profile()), |
| 596 browser())); | 606 browser())); |
| 607 controller->SetIsActiveBubble(); |
| 597 controller->ClearProfileListForTesting(); | 608 controller->ClearProfileListForTesting(); |
| 598 EXPECT_FALSE(controller->ShouldShow()); | 609 EXPECT_FALSE(controller->ShouldShow()); |
| 599 dev_mode_extensions = controller->GetExtensionList(); | 610 dev_mode_extensions = controller->GetExtensionList(); |
| 600 EXPECT_EQ(0U, dev_mode_extensions.size()); | 611 EXPECT_EQ(0U, dev_mode_extensions.size()); |
| 601 } | 612 } |
| 602 | 613 |
| 603 // The feature this is meant to test is only implemented on Windows and Mac. | 614 // The feature this is meant to test is only implemented on Windows and Mac. |
| 604 #if defined(OS_WIN) || defined(OS_MACOSX) | 615 #if defined(OS_WIN) || defined(OS_MACOSX) |
| 605 #define MAYBE_SettingsApiControllerTest SettingsApiControllerTest | 616 #define MAYBE_SettingsApiControllerTest SettingsApiControllerTest |
| 606 #else | 617 #else |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 646 default: | 657 default: |
| 647 NOTREACHED(); | 658 NOTREACHED(); |
| 648 break; | 659 break; |
| 649 } | 660 } |
| 650 | 661 |
| 651 SettingsApiOverrideType type = static_cast<SettingsApiOverrideType>(i); | 662 SettingsApiOverrideType type = static_cast<SettingsApiOverrideType>(i); |
| 652 std::unique_ptr<TestExtensionMessageBubbleController> controller( | 663 std::unique_ptr<TestExtensionMessageBubbleController> controller( |
| 653 new TestExtensionMessageBubbleController( | 664 new TestExtensionMessageBubbleController( |
| 654 new SettingsApiBubbleDelegate(browser()->profile(), type), | 665 new SettingsApiBubbleDelegate(browser()->profile(), type), |
| 655 browser())); | 666 browser())); |
| 667 controller->SetIsActiveBubble(); |
| 656 | 668 |
| 657 // The list will contain one enabled unpacked extension (ext 2). | 669 // The list will contain one enabled unpacked extension (ext 2). |
| 658 EXPECT_TRUE(controller->ShouldShow()); | 670 EXPECT_TRUE(controller->ShouldShow()); |
| 659 std::vector<base::string16> override_extensions = | 671 std::vector<base::string16> override_extensions = |
| 660 controller->GetExtensionList(); | 672 controller->GetExtensionList(); |
| 661 ASSERT_EQ(1U, override_extensions.size()); | 673 ASSERT_EQ(1U, override_extensions.size()); |
| 662 EXPECT_TRUE(base::ASCIIToUTF16("Extension 2") == | 674 EXPECT_TRUE(base::ASCIIToUTF16("Extension 2") == |
| 663 override_extensions[0].c_str()); | 675 override_extensions[0].c_str()); |
| 664 EXPECT_EQ(0U, controller->link_click_count()); | 676 EXPECT_EQ(0U, controller->link_click_count()); |
| 665 EXPECT_EQ(0U, controller->dismiss_click_count()); | 677 EXPECT_EQ(0U, controller->dismiss_click_count()); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 686 // Clean up after ourselves. | 698 // Clean up after ourselves. |
| 687 controller->delegate()->SetBubbleInfoBeenAcknowledged(kId2, false); | 699 controller->delegate()->SetBubbleInfoBeenAcknowledged(kId2, false); |
| 688 | 700 |
| 689 // Simulate clicking the learn more link to dismiss it. | 701 // Simulate clicking the learn more link to dismiss it. |
| 690 bubble.set_action_on_show( | 702 bubble.set_action_on_show( |
| 691 FakeExtensionMessageBubble::BUBBLE_ACTION_CLICK_LINK); | 703 FakeExtensionMessageBubble::BUBBLE_ACTION_CLICK_LINK); |
| 692 controller.reset( | 704 controller.reset( |
| 693 new TestExtensionMessageBubbleController( | 705 new TestExtensionMessageBubbleController( |
| 694 new SettingsApiBubbleDelegate(browser()->profile(), type), | 706 new SettingsApiBubbleDelegate(browser()->profile(), type), |
| 695 browser())); | 707 browser())); |
| 708 controller->SetIsActiveBubble(); |
| 696 bubble.set_controller(controller.get()); | 709 bubble.set_controller(controller.get()); |
| 697 bubble.Show(); | 710 bubble.Show(); |
| 698 EXPECT_EQ(1U, controller->link_click_count()); | 711 EXPECT_EQ(1U, controller->link_click_count()); |
| 699 EXPECT_EQ(0U, controller->action_click_count()); | 712 EXPECT_EQ(0U, controller->action_click_count()); |
| 700 EXPECT_EQ(0U, controller->dismiss_click_count()); | 713 EXPECT_EQ(0U, controller->dismiss_click_count()); |
| 701 // No extension should have become disabled. | 714 // No extension should have become disabled. |
| 702 EXPECT_TRUE(registry->enabled_extensions().GetByID(kId1) != NULL); | 715 EXPECT_TRUE(registry->enabled_extensions().GetByID(kId1) != NULL); |
| 703 EXPECT_TRUE(registry->enabled_extensions().GetByID(kId2) != NULL); | 716 EXPECT_TRUE(registry->enabled_extensions().GetByID(kId2) != NULL); |
| 704 EXPECT_TRUE(registry->enabled_extensions().GetByID(kId3) != NULL); | 717 EXPECT_TRUE(registry->enabled_extensions().GetByID(kId3) != NULL); |
| 705 // Only extension 2 should have been acknowledged. | 718 // Only extension 2 should have been acknowledged. |
| 706 EXPECT_FALSE(controller->delegate()->HasBubbleInfoBeenAcknowledged(kId1)); | 719 EXPECT_FALSE(controller->delegate()->HasBubbleInfoBeenAcknowledged(kId1)); |
| 707 EXPECT_TRUE(controller->delegate()->HasBubbleInfoBeenAcknowledged(kId2)); | 720 EXPECT_TRUE(controller->delegate()->HasBubbleInfoBeenAcknowledged(kId2)); |
| 708 EXPECT_FALSE(controller->delegate()->HasBubbleInfoBeenAcknowledged(kId3)); | 721 EXPECT_FALSE(controller->delegate()->HasBubbleInfoBeenAcknowledged(kId3)); |
| 709 // Clean up after ourselves. | 722 // Clean up after ourselves. |
| 710 controller->delegate()->SetBubbleInfoBeenAcknowledged(kId2, false); | 723 controller->delegate()->SetBubbleInfoBeenAcknowledged(kId2, false); |
| 711 | 724 |
| 712 // Do it again, but now opt to disable the extension. | 725 // Do it again, but now opt to disable the extension. |
| 713 bubble.set_action_on_show( | 726 bubble.set_action_on_show( |
| 714 FakeExtensionMessageBubble::BUBBLE_ACTION_CLICK_ACTION_BUTTON); | 727 FakeExtensionMessageBubble::BUBBLE_ACTION_CLICK_ACTION_BUTTON); |
| 715 controller.reset( | 728 controller.reset( |
| 716 new TestExtensionMessageBubbleController( | 729 new TestExtensionMessageBubbleController( |
| 717 new SettingsApiBubbleDelegate(browser()->profile(), type), | 730 new SettingsApiBubbleDelegate(browser()->profile(), type), |
| 718 browser())); | 731 browser())); |
| 732 controller->SetIsActiveBubble(); |
| 719 EXPECT_TRUE(controller->ShouldShow()); | 733 EXPECT_TRUE(controller->ShouldShow()); |
| 720 override_extensions = controller->GetExtensionList(); | 734 override_extensions = controller->GetExtensionList(); |
| 721 EXPECT_EQ(1U, override_extensions.size()); | 735 EXPECT_EQ(1U, override_extensions.size()); |
| 722 bubble.set_controller(controller.get()); | 736 bubble.set_controller(controller.get()); |
| 723 bubble.Show(); // Simulate showing the bubble. | 737 bubble.Show(); // Simulate showing the bubble. |
| 724 EXPECT_EQ(0U, controller->link_click_count()); | 738 EXPECT_EQ(0U, controller->link_click_count()); |
| 725 EXPECT_EQ(1U, controller->action_click_count()); | 739 EXPECT_EQ(1U, controller->action_click_count()); |
| 726 EXPECT_EQ(0U, controller->dismiss_click_count()); | 740 EXPECT_EQ(0U, controller->dismiss_click_count()); |
| 727 // Only extension 2 should have become disabled. | 741 // Only extension 2 should have become disabled. |
| 728 EXPECT_TRUE(registry->enabled_extensions().GetByID(kId1) != NULL); | 742 EXPECT_TRUE(registry->enabled_extensions().GetByID(kId1) != NULL); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 756 // Load two extensions overriding new tab page and one overriding something | 770 // Load two extensions overriding new tab page and one overriding something |
| 757 // unrelated (to check for interference). Extension 2 should still win | 771 // unrelated (to check for interference). Extension 2 should still win |
| 758 // on the new tab page setting. | 772 // on the new tab page setting. |
| 759 ASSERT_TRUE(LoadExtensionOverridingNtp("1", kId1, Manifest::UNPACKED)); | 773 ASSERT_TRUE(LoadExtensionOverridingNtp("1", kId1, Manifest::UNPACKED)); |
| 760 ASSERT_TRUE(LoadExtensionOverridingNtp("2", kId2, Manifest::UNPACKED)); | 774 ASSERT_TRUE(LoadExtensionOverridingNtp("2", kId2, Manifest::UNPACKED)); |
| 761 ASSERT_TRUE(LoadExtensionOverridingStart("3", kId3, Manifest::UNPACKED)); | 775 ASSERT_TRUE(LoadExtensionOverridingStart("3", kId3, Manifest::UNPACKED)); |
| 762 | 776 |
| 763 std::unique_ptr<TestExtensionMessageBubbleController> controller( | 777 std::unique_ptr<TestExtensionMessageBubbleController> controller( |
| 764 new TestExtensionMessageBubbleController( | 778 new TestExtensionMessageBubbleController( |
| 765 new NtpOverriddenBubbleDelegate(browser()->profile()), browser())); | 779 new NtpOverriddenBubbleDelegate(browser()->profile()), browser())); |
| 780 controller->SetIsActiveBubble(); |
| 766 | 781 |
| 767 // The list will contain one enabled unpacked extension (ext 2). | 782 // The list will contain one enabled unpacked extension (ext 2). |
| 768 EXPECT_TRUE(controller->ShouldShow()); | 783 EXPECT_TRUE(controller->ShouldShow()); |
| 769 std::vector<base::string16> override_extensions = | 784 std::vector<base::string16> override_extensions = |
| 770 controller->GetExtensionList(); | 785 controller->GetExtensionList(); |
| 771 ASSERT_EQ(1U, override_extensions.size()); | 786 ASSERT_EQ(1U, override_extensions.size()); |
| 772 EXPECT_TRUE(base::ASCIIToUTF16("Extension 2") == | 787 EXPECT_TRUE(base::ASCIIToUTF16("Extension 2") == |
| 773 override_extensions[0].c_str()); | 788 override_extensions[0].c_str()); |
| 774 EXPECT_EQ(0U, controller->link_click_count()); | 789 EXPECT_EQ(0U, controller->link_click_count()); |
| 775 EXPECT_EQ(0U, controller->dismiss_click_count()); | 790 EXPECT_EQ(0U, controller->dismiss_click_count()); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 797 // Clean up after ourselves. | 812 // Clean up after ourselves. |
| 798 controller->delegate()->SetBubbleInfoBeenAcknowledged(kId2, false); | 813 controller->delegate()->SetBubbleInfoBeenAcknowledged(kId2, false); |
| 799 | 814 |
| 800 // Simulate clicking the learn more link to dismiss it. | 815 // Simulate clicking the learn more link to dismiss it. |
| 801 bubble.set_action_on_show( | 816 bubble.set_action_on_show( |
| 802 FakeExtensionMessageBubble::BUBBLE_ACTION_CLICK_LINK); | 817 FakeExtensionMessageBubble::BUBBLE_ACTION_CLICK_LINK); |
| 803 controller.reset( | 818 controller.reset( |
| 804 new TestExtensionMessageBubbleController( | 819 new TestExtensionMessageBubbleController( |
| 805 new NtpOverriddenBubbleDelegate(browser()->profile()), | 820 new NtpOverriddenBubbleDelegate(browser()->profile()), |
| 806 browser())); | 821 browser())); |
| 822 controller->SetIsActiveBubble(); |
| 807 EXPECT_TRUE(controller->ShouldShow()); | 823 EXPECT_TRUE(controller->ShouldShow()); |
| 808 bubble.set_controller(controller.get()); | 824 bubble.set_controller(controller.get()); |
| 809 bubble.Show(); | 825 bubble.Show(); |
| 810 EXPECT_EQ(1U, controller->link_click_count()); | 826 EXPECT_EQ(1U, controller->link_click_count()); |
| 811 EXPECT_EQ(0U, controller->action_click_count()); | 827 EXPECT_EQ(0U, controller->action_click_count()); |
| 812 EXPECT_EQ(0U, controller->dismiss_click_count()); | 828 EXPECT_EQ(0U, controller->dismiss_click_count()); |
| 813 // No extension should have become disabled. | 829 // No extension should have become disabled. |
| 814 EXPECT_TRUE(registry->enabled_extensions().GetByID(kId1) != NULL); | 830 EXPECT_TRUE(registry->enabled_extensions().GetByID(kId1) != NULL); |
| 815 EXPECT_TRUE(registry->enabled_extensions().GetByID(kId2) != NULL); | 831 EXPECT_TRUE(registry->enabled_extensions().GetByID(kId2) != NULL); |
| 816 EXPECT_TRUE(registry->enabled_extensions().GetByID(kId3) != NULL); | 832 EXPECT_TRUE(registry->enabled_extensions().GetByID(kId3) != NULL); |
| 817 // Only extension 2 should have been acknowledged. | 833 // Only extension 2 should have been acknowledged. |
| 818 EXPECT_FALSE(controller->delegate()->HasBubbleInfoBeenAcknowledged(kId1)); | 834 EXPECT_FALSE(controller->delegate()->HasBubbleInfoBeenAcknowledged(kId1)); |
| 819 EXPECT_TRUE(controller->delegate()->HasBubbleInfoBeenAcknowledged(kId2)); | 835 EXPECT_TRUE(controller->delegate()->HasBubbleInfoBeenAcknowledged(kId2)); |
| 820 EXPECT_FALSE(controller->delegate()->HasBubbleInfoBeenAcknowledged(kId3)); | 836 EXPECT_FALSE(controller->delegate()->HasBubbleInfoBeenAcknowledged(kId3)); |
| 821 // Clean up after ourselves. | 837 // Clean up after ourselves. |
| 822 controller->delegate()->SetBubbleInfoBeenAcknowledged(kId2, false); | 838 controller->delegate()->SetBubbleInfoBeenAcknowledged(kId2, false); |
| 823 | 839 |
| 824 // Do it again, but now opt to disable the extension. | 840 // Do it again, but now opt to disable the extension. |
| 825 bubble.set_action_on_show( | 841 bubble.set_action_on_show( |
| 826 FakeExtensionMessageBubble::BUBBLE_ACTION_CLICK_ACTION_BUTTON); | 842 FakeExtensionMessageBubble::BUBBLE_ACTION_CLICK_ACTION_BUTTON); |
| 827 controller.reset( | 843 controller.reset( |
| 828 new TestExtensionMessageBubbleController( | 844 new TestExtensionMessageBubbleController( |
| 829 new NtpOverriddenBubbleDelegate(browser()->profile()), | 845 new NtpOverriddenBubbleDelegate(browser()->profile()), |
| 830 browser())); | 846 browser())); |
| 847 controller->SetIsActiveBubble(); |
| 831 EXPECT_TRUE(controller->ShouldShow()); | 848 EXPECT_TRUE(controller->ShouldShow()); |
| 832 override_extensions = controller->GetExtensionList(); | 849 override_extensions = controller->GetExtensionList(); |
| 833 EXPECT_EQ(1U, override_extensions.size()); | 850 EXPECT_EQ(1U, override_extensions.size()); |
| 834 bubble.set_controller(controller.get()); | 851 bubble.set_controller(controller.get()); |
| 835 bubble.Show(); // Simulate showing the bubble. | 852 bubble.Show(); // Simulate showing the bubble. |
| 836 EXPECT_EQ(0U, controller->link_click_count()); | 853 EXPECT_EQ(0U, controller->link_click_count()); |
| 837 EXPECT_EQ(1U, controller->action_click_count()); | 854 EXPECT_EQ(1U, controller->action_click_count()); |
| 838 EXPECT_EQ(0U, controller->dismiss_click_count()); | 855 EXPECT_EQ(0U, controller->dismiss_click_count()); |
| 839 // Only extension 2 should have become disabled. | 856 // Only extension 2 should have become disabled. |
| 840 EXPECT_TRUE(registry->enabled_extensions().GetByID(kId1) != NULL); | 857 EXPECT_TRUE(registry->enabled_extensions().GetByID(kId1) != NULL); |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 896 // so we artificially set the install time to simulate an old install during | 913 // so we artificially set the install time to simulate an old install during |
| 897 // testing. | 914 // testing. |
| 898 base::Time old_enough = base::Time::Now() - base::TimeDelta::FromDays(8); | 915 base::Time old_enough = base::Time::Now() - base::TimeDelta::FromDays(8); |
| 899 SetInstallTime(kId1, old_enough, prefs); | 916 SetInstallTime(kId1, old_enough, prefs); |
| 900 SetInstallTime(kId2, base::Time::Now(), prefs); | 917 SetInstallTime(kId2, base::Time::Now(), prefs); |
| 901 SetInstallTime(kId3, old_enough, prefs); | 918 SetInstallTime(kId3, old_enough, prefs); |
| 902 | 919 |
| 903 std::unique_ptr<TestExtensionMessageBubbleController> controller( | 920 std::unique_ptr<TestExtensionMessageBubbleController> controller( |
| 904 new TestExtensionMessageBubbleController( | 921 new TestExtensionMessageBubbleController( |
| 905 new ProxyOverriddenBubbleDelegate(browser()->profile()), browser())); | 922 new ProxyOverriddenBubbleDelegate(browser()->profile()), browser())); |
| 923 controller->SetIsActiveBubble(); |
| 906 | 924 |
| 907 // The second extension is too new to warn about. | 925 // The second extension is too new to warn about. |
| 908 EXPECT_FALSE(controller->ShouldShow()); | 926 EXPECT_FALSE(controller->ShouldShow()); |
| 909 EXPECT_FALSE(controller->ShouldShow()); | |
| 910 // Lets make it old enough. | 927 // Lets make it old enough. |
| 911 SetInstallTime(kId2, old_enough, prefs); | 928 SetInstallTime(kId2, old_enough, prefs); |
| 912 | 929 |
| 913 // The list will contain one enabled unpacked extension (ext 2). | 930 // The list will contain one enabled unpacked extension (ext 2). |
| 914 EXPECT_TRUE(controller->ShouldShow()); | 931 EXPECT_TRUE(controller->ShouldShow()); |
| 915 EXPECT_FALSE(controller->ShouldShow()); | 932 EXPECT_FALSE(controller->ShouldShow()); |
| 916 std::vector<base::string16> override_extensions = | 933 std::vector<base::string16> override_extensions = |
| 917 controller->GetExtensionList(); | 934 controller->GetExtensionList(); |
| 918 ASSERT_EQ(1U, override_extensions.size()); | 935 ASSERT_EQ(1U, override_extensions.size()); |
| 919 EXPECT_EQ(base::ASCIIToUTF16("Extension 2"), override_extensions[0]); | 936 EXPECT_EQ(base::ASCIIToUTF16("Extension 2"), override_extensions[0]); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 942 // Clean up after ourselves. | 959 // Clean up after ourselves. |
| 943 controller->delegate()->SetBubbleInfoBeenAcknowledged(kId2, false); | 960 controller->delegate()->SetBubbleInfoBeenAcknowledged(kId2, false); |
| 944 | 961 |
| 945 // Simulate clicking the learn more link to dismiss it. | 962 // Simulate clicking the learn more link to dismiss it. |
| 946 bubble.set_action_on_show( | 963 bubble.set_action_on_show( |
| 947 FakeExtensionMessageBubble::BUBBLE_ACTION_CLICK_LINK); | 964 FakeExtensionMessageBubble::BUBBLE_ACTION_CLICK_LINK); |
| 948 controller.reset( | 965 controller.reset( |
| 949 new TestExtensionMessageBubbleController( | 966 new TestExtensionMessageBubbleController( |
| 950 new ProxyOverriddenBubbleDelegate(browser()->profile()), | 967 new ProxyOverriddenBubbleDelegate(browser()->profile()), |
| 951 browser())); | 968 browser())); |
| 969 controller->SetIsActiveBubble(); |
| 952 EXPECT_TRUE(controller->ShouldShow()); | 970 EXPECT_TRUE(controller->ShouldShow()); |
| 953 bubble.set_controller(controller.get()); | 971 bubble.set_controller(controller.get()); |
| 954 bubble.Show(); | 972 bubble.Show(); |
| 955 EXPECT_EQ(1U, controller->link_click_count()); | 973 EXPECT_EQ(1U, controller->link_click_count()); |
| 956 EXPECT_EQ(0U, controller->action_click_count()); | 974 EXPECT_EQ(0U, controller->action_click_count()); |
| 957 EXPECT_EQ(0U, controller->dismiss_click_count()); | 975 EXPECT_EQ(0U, controller->dismiss_click_count()); |
| 958 // No extension should have become disabled. | 976 // No extension should have become disabled. |
| 959 EXPECT_TRUE(registry->enabled_extensions().GetByID(kId1) != NULL); | 977 EXPECT_TRUE(registry->enabled_extensions().GetByID(kId1) != NULL); |
| 960 EXPECT_TRUE(registry->enabled_extensions().GetByID(kId2) != NULL); | 978 EXPECT_TRUE(registry->enabled_extensions().GetByID(kId2) != NULL); |
| 961 EXPECT_TRUE(registry->enabled_extensions().GetByID(kId3) != NULL); | 979 EXPECT_TRUE(registry->enabled_extensions().GetByID(kId3) != NULL); |
| 962 // Only extension 2 should have been acknowledged. | 980 // Only extension 2 should have been acknowledged. |
| 963 EXPECT_FALSE(controller->delegate()->HasBubbleInfoBeenAcknowledged(kId1)); | 981 EXPECT_FALSE(controller->delegate()->HasBubbleInfoBeenAcknowledged(kId1)); |
| 964 EXPECT_TRUE(controller->delegate()->HasBubbleInfoBeenAcknowledged(kId2)); | 982 EXPECT_TRUE(controller->delegate()->HasBubbleInfoBeenAcknowledged(kId2)); |
| 965 EXPECT_FALSE(controller->delegate()->HasBubbleInfoBeenAcknowledged(kId3)); | 983 EXPECT_FALSE(controller->delegate()->HasBubbleInfoBeenAcknowledged(kId3)); |
| 966 // Clean up after ourselves. | 984 // Clean up after ourselves. |
| 967 controller->delegate()->SetBubbleInfoBeenAcknowledged(kId2, false); | 985 controller->delegate()->SetBubbleInfoBeenAcknowledged(kId2, false); |
| 968 | 986 |
| 969 // Do it again, but now opt to disable the extension. | 987 // Do it again, but now opt to disable the extension. |
| 970 bubble.set_action_on_show( | 988 bubble.set_action_on_show( |
| 971 FakeExtensionMessageBubble::BUBBLE_ACTION_CLICK_ACTION_BUTTON); | 989 FakeExtensionMessageBubble::BUBBLE_ACTION_CLICK_ACTION_BUTTON); |
| 972 controller.reset( | 990 controller.reset( |
| 973 new TestExtensionMessageBubbleController( | 991 new TestExtensionMessageBubbleController( |
| 974 new ProxyOverriddenBubbleDelegate(browser()->profile()), | 992 new ProxyOverriddenBubbleDelegate(browser()->profile()), |
| 975 browser())); | 993 browser())); |
| 994 controller->SetIsActiveBubble(); |
| 976 EXPECT_TRUE(controller->ShouldShow()); | 995 EXPECT_TRUE(controller->ShouldShow()); |
| 977 override_extensions = controller->GetExtensionList(); | 996 override_extensions = controller->GetExtensionList(); |
| 978 EXPECT_EQ(1U, override_extensions.size()); | 997 EXPECT_EQ(1U, override_extensions.size()); |
| 979 bubble.set_controller(controller.get()); | 998 bubble.set_controller(controller.get()); |
| 980 bubble.Show(); // Simulate showing the bubble. | 999 bubble.Show(); // Simulate showing the bubble. |
| 981 EXPECT_EQ(0U, controller->link_click_count()); | 1000 EXPECT_EQ(0U, controller->link_click_count()); |
| 982 EXPECT_EQ(1U, controller->action_click_count()); | 1001 EXPECT_EQ(1U, controller->action_click_count()); |
| 983 EXPECT_EQ(0U, controller->dismiss_click_count()); | 1002 EXPECT_EQ(0U, controller->dismiss_click_count()); |
| 984 // Only extension 2 should have become disabled. | 1003 // Only extension 2 should have become disabled. |
| 985 EXPECT_TRUE(registry->enabled_extensions().GetByID(kId1) != NULL); | 1004 EXPECT_TRUE(registry->enabled_extensions().GetByID(kId1) != NULL); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 1005 base::Bind(&base::DoNothing), | 1024 base::Bind(&base::DoNothing), |
| 1006 NULL); | 1025 NULL); |
| 1007 } | 1026 } |
| 1008 | 1027 |
| 1009 // Tests that a bubble outliving the associated browser object doesn't crash. | 1028 // Tests that a bubble outliving the associated browser object doesn't crash. |
| 1010 // crbug.com/604003 | 1029 // crbug.com/604003 |
| 1011 TEST_F(ExtensionMessageBubbleTest, TestBubbleOutlivesBrowser) { | 1030 TEST_F(ExtensionMessageBubbleTest, TestBubbleOutlivesBrowser) { |
| 1012 FeatureSwitch::ScopedOverride force_dev_mode_highlighting( | 1031 FeatureSwitch::ScopedOverride force_dev_mode_highlighting( |
| 1013 FeatureSwitch::force_dev_mode_highlighting(), true); | 1032 FeatureSwitch::force_dev_mode_highlighting(), true); |
| 1014 Init(); | 1033 Init(); |
| 1015 ToolbarActionsModelFactory::GetInstance()->SetTestingFactory( | |
| 1016 profile(), &BuildToolbarModel); | |
| 1017 ToolbarActionsModel* model = ToolbarActionsModel::Get(profile()); | 1034 ToolbarActionsModel* model = ToolbarActionsModel::Get(profile()); |
| 1018 base::RunLoop().RunUntilIdle(); | 1035 base::RunLoop().RunUntilIdle(); |
| 1019 | 1036 |
| 1020 ASSERT_TRUE(LoadExtensionWithAction("1", kId1, Manifest::UNPACKED)); | 1037 ASSERT_TRUE(LoadExtensionWithAction("1", kId1, Manifest::UNPACKED)); |
| 1021 | 1038 |
| 1022 std::unique_ptr<TestExtensionMessageBubbleController> controller( | 1039 std::unique_ptr<TestExtensionMessageBubbleController> controller( |
| 1023 new TestExtensionMessageBubbleController( | 1040 new TestExtensionMessageBubbleController( |
| 1024 new DevModeBubbleDelegate(browser()->profile()), browser())); | 1041 new DevModeBubbleDelegate(browser()->profile()), browser())); |
| 1042 controller->SetIsActiveBubble(); |
| 1025 EXPECT_TRUE(controller->ShouldShow()); | 1043 EXPECT_TRUE(controller->ShouldShow()); |
| 1026 EXPECT_EQ(1u, model->toolbar_items().size()); | 1044 EXPECT_EQ(1u, model->toolbar_items().size()); |
| 1027 controller->HighlightExtensionsIfNecessary(); | 1045 controller->HighlightExtensionsIfNecessary(); |
| 1028 EXPECT_TRUE(ToolbarActionsModel::Get(profile())->is_highlighting()); | 1046 EXPECT_TRUE(ToolbarActionsModel::Get(profile())->is_highlighting()); |
| 1029 set_browser(nullptr); | 1047 set_browser(nullptr); |
| 1030 EXPECT_FALSE(ToolbarActionsModel::Get(profile())->is_highlighting()); | 1048 EXPECT_FALSE(ToolbarActionsModel::Get(profile())->is_highlighting()); |
| 1031 controller.reset(); | 1049 controller.reset(); |
| 1032 } | 1050 } |
| 1033 | 1051 |
| 1034 } // namespace extensions | 1052 } // namespace extensions |
| OLD | NEW |