| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "base/files/file_util.h" | 5 #include "base/files/file_util.h" |
| 6 #include "base/macros.h" | 6 #include "base/macros.h" |
| 7 #include "base/memory/ref_counted.h" | 7 #include "base/memory/ref_counted.h" |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
| 10 #include "chrome/browser/extensions/api/extension_action/extension_action_api.h" | 10 #include "chrome/browser/extensions/api/extension_action/extension_action_api.h" |
| 11 #include "chrome/browser/extensions/extension_action_manager.h" | 11 #include "chrome/browser/extensions/extension_action_manager.h" |
| 12 #include "chrome/browser/extensions/extension_action_test_util.h" | 12 #include "chrome/browser/extensions/extension_action_test_util.h" |
| 13 #include "chrome/browser/extensions/extension_service.h" | 13 #include "chrome/browser/extensions/extension_service.h" |
| 14 #include "chrome/browser/extensions/extension_service_test_base.h" | 14 #include "chrome/browser/extensions/extension_service_test_base.h" |
| 15 #include "chrome/browser/extensions/extension_toolbar_model.h" | 15 #include "chrome/browser/extensions/extension_toolbar_model.h" |
| 16 #include "chrome/browser/extensions/extension_util.h" | 16 #include "chrome/browser/extensions/extension_util.h" |
| 17 #include "chrome/browser/extensions/test_extension_dir.h" | 17 #include "chrome/browser/extensions/test_extension_dir.h" |
| 18 #include "chrome/browser/extensions/test_extension_system.h" | 18 #include "chrome/browser/extensions/test_extension_system.h" |
| 19 #include "chrome/browser/extensions/unpacked_installer.h" | 19 #include "chrome/browser/extensions/unpacked_installer.h" |
| 20 #include "chrome/browser/profiles/profile.h" | 20 #include "chrome/browser/profiles/profile.h" |
| 21 #include "chrome/browser/sessions/session_tab_helper.h" | 21 #include "chrome/browser/sessions/session_tab_helper.h" |
| 22 #include "chrome/browser/ui/extensions/extension_toolbar_icon_surfacing_bubble_d
elegate.h" |
| 22 #include "chrome/common/extensions/api/extension_action/action_info.h" | 23 #include "chrome/common/extensions/api/extension_action/action_info.h" |
| 23 #include "components/crx_file/id_util.h" | 24 #include "components/crx_file/id_util.h" |
| 24 #include "content/public/test/test_renderer_host.h" | 25 #include "content/public/test/test_renderer_host.h" |
| 25 #include "content/public/test/web_contents_tester.h" | 26 #include "content/public/test/web_contents_tester.h" |
| 26 #include "extensions/browser/extension_prefs.h" | 27 #include "extensions/browser/extension_prefs.h" |
| 27 #include "extensions/browser/extension_registry.h" | 28 #include "extensions/browser/extension_registry.h" |
| 28 #include "extensions/browser/extension_system.h" | 29 #include "extensions/browser/extension_system.h" |
| 30 #include "extensions/browser/pref_names.h" |
| 29 #include "extensions/browser/test_extension_registry_observer.h" | 31 #include "extensions/browser/test_extension_registry_observer.h" |
| 30 #include "extensions/common/extension.h" | 32 #include "extensions/common/extension.h" |
| 31 #include "extensions/common/extension_builder.h" | 33 #include "extensions/common/extension_builder.h" |
| 32 #include "extensions/common/feature_switch.h" | 34 #include "extensions/common/feature_switch.h" |
| 33 #include "extensions/common/value_builder.h" | 35 #include "extensions/common/value_builder.h" |
| 34 | 36 |
| 35 #if defined(USE_AURA) | 37 #if defined(USE_AURA) |
| 36 #include "ui/aura/env.h" | 38 #include "ui/aura/env.h" |
| 37 #endif | 39 #endif |
| 38 | 40 |
| (...skipping 515 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 554 EXPECT_EQ(3u, toolbar_model()->visible_icon_count()); | 556 EXPECT_EQ(3u, toolbar_model()->visible_icon_count()); |
| 555 EXPECT_EQ(extension_b.get(), GetExtensionAtIndex(0u)); | 557 EXPECT_EQ(extension_b.get(), GetExtensionAtIndex(0u)); |
| 556 EXPECT_EQ(extension_a.get(), GetExtensionAtIndex(1u)); | 558 EXPECT_EQ(extension_a.get(), GetExtensionAtIndex(1u)); |
| 557 EXPECT_EQ(extension_d.get(), GetExtensionAtIndex(2u)); | 559 EXPECT_EQ(extension_d.get(), GetExtensionAtIndex(2u)); |
| 558 EXPECT_EQ(extension_c.get(), GetExtensionAtIndex(3u)); | 560 EXPECT_EQ(extension_c.get(), GetExtensionAtIndex(3u)); |
| 559 } | 561 } |
| 560 | 562 |
| 561 TEST_F(ExtensionToolbarModelUnitTest, ExtensionToolbarHighlightMode) { | 563 TEST_F(ExtensionToolbarModelUnitTest, ExtensionToolbarHighlightMode) { |
| 562 Init(); | 564 Init(); |
| 563 | 565 |
| 564 EXPECT_FALSE(toolbar_model()->HighlightExtensions(ExtensionIdList())); | 566 EXPECT_FALSE(toolbar_model()->HighlightExtensions( |
| 567 ExtensionIdList(), ExtensionToolbarModel::HIGHLIGHT_WARNING)); |
| 565 EXPECT_EQ(0, observer()->highlight_mode_count()); | 568 EXPECT_EQ(0, observer()->highlight_mode_count()); |
| 566 | 569 |
| 567 // Add the three browser action extensions. | 570 // Add the three browser action extensions. |
| 568 ASSERT_TRUE(AddBrowserActionExtensions()); | 571 ASSERT_TRUE(AddBrowserActionExtensions()); |
| 569 EXPECT_EQ(3u, num_toolbar_items()); | 572 EXPECT_EQ(3u, num_toolbar_items()); |
| 570 | 573 |
| 574 // Start with a visible count of 2 (non-zero, and not all). |
| 575 toolbar_model()->SetVisibleIconCount(2u); |
| 576 |
| 571 // Highlight one extension. | 577 // Highlight one extension. |
| 572 ExtensionIdList extension_ids; | 578 ExtensionIdList extension_ids; |
| 573 extension_ids.push_back(browser_action_b()->id()); | 579 extension_ids.push_back(browser_action_b()->id()); |
| 574 toolbar_model()->HighlightExtensions(extension_ids); | 580 toolbar_model()->HighlightExtensions( |
| 581 extension_ids, ExtensionToolbarModel::HIGHLIGHT_WARNING); |
| 575 EXPECT_EQ(1, observer()->highlight_mode_count()); | 582 EXPECT_EQ(1, observer()->highlight_mode_count()); |
| 576 EXPECT_TRUE(toolbar_model()->is_highlighting()); | 583 EXPECT_TRUE(toolbar_model()->is_highlighting()); |
| 577 | 584 |
| 578 EXPECT_EQ(1u, num_toolbar_items()); | 585 EXPECT_EQ(1u, num_toolbar_items()); |
| 579 EXPECT_EQ(browser_action_b(), GetExtensionAtIndex(0u)); | 586 EXPECT_EQ(browser_action_b(), GetExtensionAtIndex(0u)); |
| 587 EXPECT_EQ(1u, toolbar_model()->visible_icon_count()); |
| 580 | 588 |
| 581 // Stop highlighting. | 589 // Stop highlighting. |
| 582 toolbar_model()->StopHighlighting(); | 590 toolbar_model()->StopHighlighting(); |
| 583 EXPECT_EQ(0, observer()->highlight_mode_count()); | 591 EXPECT_EQ(0, observer()->highlight_mode_count()); |
| 584 EXPECT_FALSE(toolbar_model()->is_highlighting()); | 592 EXPECT_FALSE(toolbar_model()->is_highlighting()); |
| 585 | 593 |
| 586 // Verify that the extensions are back to normal. | 594 // Verify that the extensions are back to normal. |
| 587 EXPECT_EQ(3u, num_toolbar_items()); | 595 EXPECT_EQ(3u, num_toolbar_items()); |
| 588 EXPECT_EQ(browser_action_a(), GetExtensionAtIndex(0u)); | 596 EXPECT_EQ(browser_action_a(), GetExtensionAtIndex(0u)); |
| 589 EXPECT_EQ(browser_action_b(), GetExtensionAtIndex(1u)); | 597 EXPECT_EQ(browser_action_b(), GetExtensionAtIndex(1u)); |
| 590 EXPECT_EQ(browser_action_c(), GetExtensionAtIndex(2u)); | 598 EXPECT_EQ(browser_action_c(), GetExtensionAtIndex(2u)); |
| 599 EXPECT_EQ(2u, toolbar_model()->visible_icon_count()); |
| 591 | 600 |
| 592 // Call stop highlighting a second time (shouldn't be notified). | 601 // Call stop highlighting a second time (shouldn't be notified). |
| 593 toolbar_model()->StopHighlighting(); | 602 toolbar_model()->StopHighlighting(); |
| 594 EXPECT_EQ(0, observer()->highlight_mode_count()); | 603 EXPECT_EQ(0, observer()->highlight_mode_count()); |
| 595 EXPECT_FALSE(toolbar_model()->is_highlighting()); | 604 EXPECT_FALSE(toolbar_model()->is_highlighting()); |
| 596 | 605 |
| 597 // Highlight all extensions. | 606 // Highlight all extensions. |
| 598 extension_ids.clear(); | 607 extension_ids.clear(); |
| 599 extension_ids.push_back(browser_action_a()->id()); | 608 extension_ids.push_back(browser_action_a()->id()); |
| 600 extension_ids.push_back(browser_action_b()->id()); | 609 extension_ids.push_back(browser_action_b()->id()); |
| 601 extension_ids.push_back(browser_action_c()->id()); | 610 extension_ids.push_back(browser_action_c()->id()); |
| 602 toolbar_model()->HighlightExtensions(extension_ids); | 611 toolbar_model()->HighlightExtensions( |
| 612 extension_ids, ExtensionToolbarModel::HIGHLIGHT_WARNING); |
| 603 EXPECT_EQ(1, observer()->highlight_mode_count()); | 613 EXPECT_EQ(1, observer()->highlight_mode_count()); |
| 604 EXPECT_EQ(3u, num_toolbar_items()); | 614 EXPECT_EQ(3u, num_toolbar_items()); |
| 605 EXPECT_EQ(browser_action_a(), GetExtensionAtIndex(0u)); | 615 EXPECT_EQ(browser_action_a(), GetExtensionAtIndex(0u)); |
| 606 EXPECT_EQ(browser_action_b(), GetExtensionAtIndex(1u)); | 616 EXPECT_EQ(browser_action_b(), GetExtensionAtIndex(1u)); |
| 607 EXPECT_EQ(browser_action_c(), GetExtensionAtIndex(2u)); | 617 EXPECT_EQ(browser_action_c(), GetExtensionAtIndex(2u)); |
| 618 EXPECT_EQ(3u, toolbar_model()->visible_icon_count()); |
| 619 // Even though the visible count is 3, we shouldn't adjust the stored |
| 620 // preference. |
| 621 EXPECT_EQ(2, profile()->GetPrefs()->GetInteger(pref_names::kToolbarSize)); |
| 608 | 622 |
| 609 // Highlight only extension b (shrink the highlight list). | 623 // Highlight only extension b (shrink the highlight list). |
| 610 extension_ids.clear(); | 624 extension_ids.clear(); |
| 611 extension_ids.push_back(browser_action_b()->id()); | 625 extension_ids.push_back(browser_action_b()->id()); |
| 612 toolbar_model()->HighlightExtensions(extension_ids); | 626 toolbar_model()->HighlightExtensions( |
| 627 extension_ids, ExtensionToolbarModel::HIGHLIGHT_WARNING); |
| 613 EXPECT_EQ(2, observer()->highlight_mode_count()); | 628 EXPECT_EQ(2, observer()->highlight_mode_count()); |
| 614 EXPECT_EQ(1u, num_toolbar_items()); | 629 EXPECT_EQ(1u, num_toolbar_items()); |
| 615 EXPECT_EQ(browser_action_b(), GetExtensionAtIndex(0u)); | 630 EXPECT_EQ(browser_action_b(), GetExtensionAtIndex(0u)); |
| 616 | 631 |
| 617 // Highlight extensions a and b (grow the highlight list). | 632 // Highlight extensions a and b (grow the highlight list). |
| 618 extension_ids.clear(); | 633 extension_ids.clear(); |
| 619 extension_ids.push_back(browser_action_a()->id()); | 634 extension_ids.push_back(browser_action_a()->id()); |
| 620 extension_ids.push_back(browser_action_b()->id()); | 635 extension_ids.push_back(browser_action_b()->id()); |
| 621 toolbar_model()->HighlightExtensions(extension_ids); | 636 toolbar_model()->HighlightExtensions( |
| 637 extension_ids, ExtensionToolbarModel::HIGHLIGHT_WARNING); |
| 622 EXPECT_EQ(3, observer()->highlight_mode_count()); | 638 EXPECT_EQ(3, observer()->highlight_mode_count()); |
| 623 EXPECT_EQ(2u, num_toolbar_items()); | 639 EXPECT_EQ(2u, num_toolbar_items()); |
| 624 EXPECT_EQ(browser_action_a(), GetExtensionAtIndex(0u)); | 640 EXPECT_EQ(browser_action_a(), GetExtensionAtIndex(0u)); |
| 625 EXPECT_EQ(browser_action_b(), GetExtensionAtIndex(1u)); | 641 EXPECT_EQ(browser_action_b(), GetExtensionAtIndex(1u)); |
| 626 | 642 |
| 627 // Highlight no extensions (empty the highlight list). | 643 // Highlight no extensions (empty the highlight list). |
| 628 extension_ids.clear(); | 644 extension_ids.clear(); |
| 629 toolbar_model()->HighlightExtensions(extension_ids); | 645 toolbar_model()->HighlightExtensions( |
| 646 extension_ids, ExtensionToolbarModel::HIGHLIGHT_WARNING); |
| 630 EXPECT_EQ(2, observer()->highlight_mode_count()); | 647 EXPECT_EQ(2, observer()->highlight_mode_count()); |
| 631 EXPECT_FALSE(toolbar_model()->is_highlighting()); | 648 EXPECT_FALSE(toolbar_model()->is_highlighting()); |
| 632 EXPECT_EQ(browser_action_a(), GetExtensionAtIndex(0u)); | 649 EXPECT_EQ(browser_action_a(), GetExtensionAtIndex(0u)); |
| 633 EXPECT_EQ(browser_action_b(), GetExtensionAtIndex(1u)); | 650 EXPECT_EQ(browser_action_b(), GetExtensionAtIndex(1u)); |
| 634 EXPECT_EQ(browser_action_c(), GetExtensionAtIndex(2u)); | 651 EXPECT_EQ(browser_action_c(), GetExtensionAtIndex(2u)); |
| 652 |
| 653 // Our toolbar size should be back to normal. |
| 654 EXPECT_EQ(2u, toolbar_model()->visible_icon_count()); |
| 655 EXPECT_EQ(2, profile()->GetPrefs()->GetInteger(pref_names::kToolbarSize)); |
| 635 } | 656 } |
| 636 | 657 |
| 637 TEST_F(ExtensionToolbarModelUnitTest, ExtensionToolbarHighlightModeRemove) { | 658 TEST_F(ExtensionToolbarModelUnitTest, ExtensionToolbarHighlightModeRemove) { |
| 638 Init(); | 659 Init(); |
| 639 | 660 |
| 640 // Add the three browser action extensions. | 661 // Add the three browser action extensions. |
| 641 ASSERT_TRUE(AddBrowserActionExtensions()); | 662 ASSERT_TRUE(AddBrowserActionExtensions()); |
| 642 EXPECT_EQ(3u, num_toolbar_items()); | 663 EXPECT_EQ(3u, num_toolbar_items()); |
| 643 | 664 |
| 644 // Highlight two of the extensions. | 665 // Highlight two of the extensions. |
| 645 ExtensionIdList extension_ids; | 666 ExtensionIdList extension_ids; |
| 646 extension_ids.push_back(browser_action_a()->id()); | 667 extension_ids.push_back(browser_action_a()->id()); |
| 647 extension_ids.push_back(browser_action_b()->id()); | 668 extension_ids.push_back(browser_action_b()->id()); |
| 648 toolbar_model()->HighlightExtensions(extension_ids); | 669 toolbar_model()->HighlightExtensions( |
| 670 extension_ids, ExtensionToolbarModel::HIGHLIGHT_WARNING); |
| 649 EXPECT_TRUE(toolbar_model()->is_highlighting()); | 671 EXPECT_TRUE(toolbar_model()->is_highlighting()); |
| 650 EXPECT_EQ(1, observer()->highlight_mode_count()); | 672 EXPECT_EQ(1, observer()->highlight_mode_count()); |
| 651 EXPECT_EQ(2u, num_toolbar_items()); | 673 EXPECT_EQ(2u, num_toolbar_items()); |
| 652 | 674 |
| 653 // Disable one of them - only one should remain highlighted. | 675 // Disable one of them - only one should remain highlighted. |
| 654 service()->DisableExtension(browser_action_a()->id(), | 676 service()->DisableExtension(browser_action_a()->id(), |
| 655 Extension::DISABLE_USER_ACTION); | 677 Extension::DISABLE_USER_ACTION); |
| 656 EXPECT_TRUE(toolbar_model()->is_highlighting()); | 678 EXPECT_TRUE(toolbar_model()->is_highlighting()); |
| 657 EXPECT_EQ(1u, num_toolbar_items()); | 679 EXPECT_EQ(1u, num_toolbar_items()); |
| 658 EXPECT_EQ(browser_action_b(), GetExtensionAtIndex(0u)); | 680 EXPECT_EQ(browser_action_b(), GetExtensionAtIndex(0u)); |
| 659 | 681 |
| 660 // Uninstall the remaining highlighted extension. This should result in | 682 // Uninstall the remaining highlighted extension. This should result in |
| 661 // highlight mode exiting. | 683 // highlight mode exiting. |
| 662 service()->UninstallExtension(browser_action_b()->id(), | 684 service()->UninstallExtension(browser_action_b()->id(), |
| 663 UNINSTALL_REASON_FOR_TESTING, | 685 UNINSTALL_REASON_FOR_TESTING, |
| 664 base::Bind(&base::DoNothing), | 686 base::Bind(&base::DoNothing), |
| 665 NULL); // Ignore error. | 687 NULL); // Ignore error. |
| 666 EXPECT_FALSE(toolbar_model()->is_highlighting()); | 688 EXPECT_FALSE(toolbar_model()->is_highlighting()); |
| 667 EXPECT_EQ(0, observer()->highlight_mode_count()); | 689 EXPECT_EQ(0, observer()->highlight_mode_count()); |
| 668 EXPECT_EQ(1u, num_toolbar_items()); | 690 EXPECT_EQ(1u, num_toolbar_items()); |
| 669 EXPECT_EQ(browser_action_c(), GetExtensionAtIndex(0u)); | 691 EXPECT_EQ(browser_action_c(), GetExtensionAtIndex(0u)); |
| 670 | 692 |
| 671 // Test that removing an unhighlighted extension still works. | 693 // Test that removing an unhighlighted extension still works. |
| 672 // Reinstall extension b, and then highlight extension c. | 694 // Reinstall extension b, and then highlight extension c. |
| 673 ASSERT_TRUE(AddExtension(browser_action_b())); | 695 ASSERT_TRUE(AddExtension(browser_action_b())); |
| 674 EXPECT_EQ(browser_action_b(), GetExtensionAtIndex(1u)); | 696 EXPECT_EQ(browser_action_b(), GetExtensionAtIndex(1u)); |
| 675 extension_ids.clear(); | 697 extension_ids.clear(); |
| 676 extension_ids.push_back(browser_action_c()->id()); | 698 extension_ids.push_back(browser_action_c()->id()); |
| 677 toolbar_model()->HighlightExtensions(extension_ids); | 699 toolbar_model()->HighlightExtensions( |
| 700 extension_ids, ExtensionToolbarModel::HIGHLIGHT_WARNING); |
| 678 EXPECT_EQ(1, observer()->highlight_mode_count()); | 701 EXPECT_EQ(1, observer()->highlight_mode_count()); |
| 679 EXPECT_TRUE(toolbar_model()->is_highlighting()); | 702 EXPECT_TRUE(toolbar_model()->is_highlighting()); |
| 680 EXPECT_EQ(1u, num_toolbar_items()); | 703 EXPECT_EQ(1u, num_toolbar_items()); |
| 681 EXPECT_EQ(browser_action_c(), GetExtensionAtIndex(0u)); | 704 EXPECT_EQ(browser_action_c(), GetExtensionAtIndex(0u)); |
| 682 | 705 |
| 683 // Uninstalling b should not have visible impact. | 706 // Uninstalling b should not have visible impact. |
| 684 service()->UninstallExtension(browser_action_b()->id(), | 707 service()->UninstallExtension(browser_action_b()->id(), |
| 685 UNINSTALL_REASON_FOR_TESTING, | 708 UNINSTALL_REASON_FOR_TESTING, |
| 686 base::Bind(&base::DoNothing), | 709 base::Bind(&base::DoNothing), |
| 687 NULL); // Ignore error. | 710 NULL); // Ignore error. |
| (...skipping 16 matching lines...) Expand all Loading... |
| 704 // Add the three browser action extensions. | 727 // Add the three browser action extensions. |
| 705 ASSERT_TRUE(AddBrowserActionExtensions()); | 728 ASSERT_TRUE(AddBrowserActionExtensions()); |
| 706 EXPECT_EQ(3u, num_toolbar_items()); | 729 EXPECT_EQ(3u, num_toolbar_items()); |
| 707 | 730 |
| 708 // Remove one (down to two). | 731 // Remove one (down to two). |
| 709 ASSERT_TRUE(RemoveExtension(browser_action_c())); | 732 ASSERT_TRUE(RemoveExtension(browser_action_c())); |
| 710 | 733 |
| 711 // Highlight one of the two extensions. | 734 // Highlight one of the two extensions. |
| 712 ExtensionIdList extension_ids; | 735 ExtensionIdList extension_ids; |
| 713 extension_ids.push_back(browser_action_a()->id()); | 736 extension_ids.push_back(browser_action_a()->id()); |
| 714 toolbar_model()->HighlightExtensions(extension_ids); | 737 toolbar_model()->HighlightExtensions( |
| 738 extension_ids, ExtensionToolbarModel::HIGHLIGHT_WARNING); |
| 715 EXPECT_TRUE(toolbar_model()->is_highlighting()); | 739 EXPECT_TRUE(toolbar_model()->is_highlighting()); |
| 716 EXPECT_EQ(1u, num_toolbar_items()); | 740 EXPECT_EQ(1u, num_toolbar_items()); |
| 717 EXPECT_EQ(browser_action_a(), GetExtensionAtIndex(0u)); | 741 EXPECT_EQ(browser_action_a(), GetExtensionAtIndex(0u)); |
| 718 | 742 |
| 719 // Adding a new extension should have no visible effect. | 743 // Adding a new extension should have no visible effect. |
| 720 ASSERT_TRUE(AddExtension(browser_action_c())); | 744 ASSERT_TRUE(AddExtension(browser_action_c())); |
| 721 EXPECT_TRUE(toolbar_model()->is_highlighting()); | 745 EXPECT_TRUE(toolbar_model()->is_highlighting()); |
| 722 EXPECT_EQ(1u, num_toolbar_items()); | 746 EXPECT_EQ(1u, num_toolbar_items()); |
| 723 EXPECT_EQ(browser_action_a(), GetExtensionAtIndex(0u)); | 747 EXPECT_EQ(browser_action_a(), GetExtensionAtIndex(0u)); |
| 724 | 748 |
| (...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1140 .SetLocation(Manifest::COMPONENT) | 1164 .SetLocation(Manifest::COMPONENT) |
| 1141 .Build(); | 1165 .Build(); |
| 1142 service()->AddExtension(component_extension.get()); | 1166 service()->AddExtension(component_extension.get()); |
| 1143 | 1167 |
| 1144 EXPECT_EQ(component_extension.get(), GetExtensionAtIndex(0)); | 1168 EXPECT_EQ(component_extension.get(), GetExtensionAtIndex(0)); |
| 1145 EXPECT_EQ(browser_action_a(), GetExtensionAtIndex(1)); | 1169 EXPECT_EQ(browser_action_a(), GetExtensionAtIndex(1)); |
| 1146 EXPECT_EQ(browser_action_b(), GetExtensionAtIndex(2)); | 1170 EXPECT_EQ(browser_action_b(), GetExtensionAtIndex(2)); |
| 1147 EXPECT_EQ(browser_action_c(), GetExtensionAtIndex(3)); | 1171 EXPECT_EQ(browser_action_c(), GetExtensionAtIndex(3)); |
| 1148 } | 1172 } |
| 1149 | 1173 |
| 1174 TEST_F(ExtensionToolbarModelUnitTest, |
| 1175 ToolbarModelHighlightsForToolbarRedesign) { |
| 1176 FeatureSwitch::ScopedOverride enable_redesign( |
| 1177 FeatureSwitch::extension_action_redesign(), true); |
| 1178 InitializeEmptyExtensionService(); |
| 1179 EXPECT_TRUE(AddActionExtensions()); |
| 1180 ExtensionToolbarModel* toolbar_model = |
| 1181 extension_action_test_util::CreateToolbarModelForProfile(profile()); |
| 1182 EXPECT_TRUE(toolbar_model); |
| 1183 base::RunLoop().RunUntilIdle(); |
| 1184 |
| 1185 EXPECT_TRUE(ExtensionToolbarIconSurfacingBubbleDelegate::ShouldShowForProfile( |
| 1186 profile())); |
| 1187 EXPECT_TRUE(toolbar_model->is_highlighting()); |
| 1188 EXPECT_EQ(ExtensionToolbarModel::HIGHLIGHT_INFO, |
| 1189 toolbar_model->highlight_type()); |
| 1190 EXPECT_EQ(3u, toolbar_model->visible_icon_count()); |
| 1191 EXPECT_EQ(3u, toolbar_model->toolbar_items().size()); |
| 1192 |
| 1193 scoped_ptr<ToolbarActionsBarBubbleDelegate> bubble( |
| 1194 new ExtensionToolbarIconSurfacingBubbleDelegate(profile())); |
| 1195 bubble->OnBubbleClosed(ToolbarActionsBarBubbleDelegate::CLOSE_DISMISS); |
| 1196 |
| 1197 EXPECT_FALSE(toolbar_model->is_highlighting()); |
| 1198 EXPECT_EQ(ExtensionToolbarModel::HIGHLIGHT_NONE, |
| 1199 toolbar_model->highlight_type()); |
| 1200 } |
| 1201 |
| 1150 } // namespace extensions | 1202 } // namespace extensions |
| OLD | NEW |