Chromium Code Reviews| Index: chrome/browser/ui/toolbar/toolbar_actions_bar_unittest.cc |
| diff --git a/chrome/browser/ui/toolbar/toolbar_actions_bar_unittest.cc b/chrome/browser/ui/toolbar/toolbar_actions_bar_unittest.cc |
| index 4924008668efcaded906e8bdf40ad2baccc686cf..b9a24ea6d10ec1ee523156c4f4f91bf6f3d1c589 100644 |
| --- a/chrome/browser/ui/toolbar/toolbar_actions_bar_unittest.cc |
| +++ b/chrome/browser/ui/toolbar/toolbar_actions_bar_unittest.cc |
| @@ -21,6 +21,7 @@ |
| #include "chrome/browser/ui/toolbar/test_toolbar_actions_bar_helper.h" |
| #include "chrome/browser/ui/toolbar/toolbar_action_view_controller.h" |
| #include "chrome/browser/ui/toolbar/toolbar_actions_bar_delegate.h" |
| +#include "chrome/common/pref_names.h" |
| #include "chrome/test/base/browser_with_test_window_test.h" |
| #include "extensions/browser/extension_system.h" |
| #include "extensions/common/extension.h" |
| @@ -389,10 +390,62 @@ TEST_F(ToolbarActionsBarUnitTest, BasicToolbarActionsBarTest) { |
| EXPECT_EQ(1u, toolbar_actions_bar()->GetIconCount()); |
| } |
| +class ToolbarActionsBarRedesignUnitTest : public ToolbarActionsBarUnitTest { |
| + public: |
| + ToolbarActionsBarRedesignUnitTest() : ToolbarActionsBarUnitTest(true) {} |
| + ~ToolbarActionsBarRedesignUnitTest() override {} |
| + |
| + private: |
| + DISALLOW_COPY_AND_ASSIGN(ToolbarActionsBarRedesignUnitTest); |
| +}; |
| + |
| +TEST_F(ToolbarActionsBarRedesignUnitTest, IconSurfacingBubbleAppearance) { |
| + // Without showing anything new, we shouldn't show the bubble, and should |
| + // auto-acknowledge it. |
| + PrefService* prefs = profile()->GetPrefs(); |
| +// ToolbarActionsBar::RegisterPrefs(prefs); |
|
battre
2015/03/19 09:28:45
indenting / should this be commented out?
Devlin
2015/03/19 16:28:08
Done.
|
| + EXPECT_FALSE(toolbar_actions_bar()->ShouldShowInfoBubble()); |
| + EXPECT_TRUE( |
| + prefs->GetBoolean(prefs::kToolbarIconSurfacingBubbleAcknowledged)); |
| + |
| + // Clear the pref for testing, and add an extension that wouldn't normally |
| + // have an icon. We should now show the bubble. |
| + prefs->ClearPref(prefs::kToolbarIconSurfacingBubbleAcknowledged); |
| + CreateAndAddExtension("extension", |
| + extensions::extension_action_test_util::NO_ACTION); |
| + EXPECT_TRUE(toolbar_actions_bar()->ShouldShowInfoBubble()); |
| + |
| + // If the bubble was recently shown, we shouldn't show it again... |
| + ToolbarActionsBarBubbleDelegate* bubble_delegate = |
| + static_cast<ToolbarActionsBarBubbleDelegate*>(toolbar_actions_bar()); |
| + bubble_delegate->OnToolbarActionsBarBubbleShown(); |
| + bubble_delegate->OnToolbarActionsBarBubbleClosed( |
| + ToolbarActionsBarBubbleDelegate::DISMISSED); |
| + EXPECT_FALSE(toolbar_actions_bar()->ShouldShowInfoBubble()); |
| + |
| + // ...But if it was only dismissed, we should show it before too long. |
| + base::Time two_days_ago = base::Time::Now() - base::TimeDelta::FromDays(2); |
| + prefs->SetInt64(prefs::kToolbarIconSurfacingBubbleLastShowTime, |
| + two_days_ago.ToInternalValue()); |
| + EXPECT_TRUE(toolbar_actions_bar()->ShouldShowInfoBubble()); |
| + |
| + // If it's acknowledged, then it should never show again, and should be |
| + // recorded as acknowledged. |
| + bubble_delegate->OnToolbarActionsBarBubbleShown(); |
| + bubble_delegate->OnToolbarActionsBarBubbleClosed( |
| + ToolbarActionsBarBubbleDelegate::ACKNOWLEDGED); |
| + EXPECT_FALSE(toolbar_actions_bar()->ShouldShowInfoBubble()); |
| + base::Time one_week_ago = base::Time::Now() - base::TimeDelta::FromDays(7); |
| + prefs->SetInt64(prefs::kToolbarIconSurfacingBubbleLastShowTime, |
| + one_week_ago.ToInternalValue()); |
| + EXPECT_TRUE( |
| + prefs->GetBoolean(prefs::kToolbarIconSurfacingBubbleAcknowledged)); |
| +} |
| + |
| class ToolbarActionsBarPopOutUnitTest |
| - : public ToolbarActionsBarUnitTest { |
| + : public ToolbarActionsBarRedesignUnitTest { |
| public: |
| - ToolbarActionsBarPopOutUnitTest() : ToolbarActionsBarUnitTest(true) {} |
| + ToolbarActionsBarPopOutUnitTest() {} |
| protected: |
| void SetUp() override { |