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

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

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

Powered by Google App Engine
This is Rietveld 408576698