| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/file_path.h" | 5 #include "base/file_path.h" |
| 6 #include "base/file_util.h" | 6 #include "base/file_util.h" |
| 7 #include "base/message_loop.h" | 7 #include "base/message_loop.h" |
| 8 #include "base/path_service.h" | 8 #include "base/path_service.h" |
| 9 #include "chrome/common/chrome_paths.h" | 9 #include "chrome/common/chrome_paths.h" |
| 10 #include "chrome/common/extensions/extension_action.h" | 10 #include "chrome/common/extensions/extension_action.h" |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 ASSERT_FALSE(action.GetIsVisible(100)); | 124 ASSERT_FALSE(action.GetIsVisible(100)); |
| 125 action.SetAppearance(100, ExtensionAction::ACTIVE); | 125 action.SetAppearance(100, ExtensionAction::ACTIVE); |
| 126 ASSERT_FALSE(action.GetIsVisible(1)); | 126 ASSERT_FALSE(action.GetIsVisible(1)); |
| 127 ASSERT_TRUE(action.GetIsVisible(100)); | 127 ASSERT_TRUE(action.GetIsVisible(100)); |
| 128 EXPECT_FALSE(action.GetIconAnimation(100)) | 128 EXPECT_FALSE(action.GetIconAnimation(100)) |
| 129 << "Page actions should not animate."; | 129 << "Page actions should not animate."; |
| 130 | 130 |
| 131 action.ClearAllValuesForTab(100); | 131 action.ClearAllValuesForTab(100); |
| 132 ASSERT_FALSE(action.GetIsVisible(1)); | 132 ASSERT_FALSE(action.GetIsVisible(1)); |
| 133 ASSERT_FALSE(action.GetIsVisible(100)); | 133 ASSERT_FALSE(action.GetIsVisible(100)); |
| 134 | |
| 135 message_loop.RunAllPending(); | |
| 136 } | 134 } |
| 137 | 135 |
| 138 TEST_F(ExtensionActionTest, ScriptBadgeAnimation) { | 136 TEST_F(ExtensionActionTest, ScriptBadgeAnimation) { |
| 139 // Supports the icon animation. | 137 // Supports the icon animation. |
| 140 MessageLoop message_loop; | 138 MessageLoop message_loop; |
| 141 | 139 |
| 142 ExtensionAction script_badge("", ExtensionAction::TYPE_SCRIPT_BADGE); | 140 ExtensionAction script_badge("", ExtensionAction::TYPE_SCRIPT_BADGE); |
| 143 EXPECT_FALSE(script_badge.GetIconAnimation(ExtensionAction::kDefaultTabId)); | 141 EXPECT_FALSE(script_badge.GetIconAnimation(ExtensionAction::kDefaultTabId)); |
| 144 script_badge.SetAppearance(ExtensionAction::kDefaultTabId, | 142 script_badge.SetAppearance(ExtensionAction::kDefaultTabId, |
| 145 ExtensionAction::ACTIVE); | 143 ExtensionAction::ACTIVE); |
| 146 EXPECT_FALSE(script_badge.GetIconAnimation(ExtensionAction::kDefaultTabId)) | 144 EXPECT_FALSE(script_badge.GetIconAnimation(ExtensionAction::kDefaultTabId)) |
| 147 << "Showing the default tab should not animate script badges."; | 145 << "Showing the default tab should not animate script badges."; |
| 148 | 146 |
| 149 script_badge.SetAppearance(ExtensionAction::kDefaultTabId, | 147 script_badge.SetAppearance(ExtensionAction::kDefaultTabId, |
| 150 ExtensionAction::INVISIBLE); | 148 ExtensionAction::INVISIBLE); |
| 151 EXPECT_FALSE(script_badge.GetIconAnimation(1)) | 149 EXPECT_FALSE(script_badge.GetIconAnimation(1)) |
| 152 << "Making a script badge invisible should not show its animation."; | 150 << "Making a script badge invisible should not show its animation."; |
| 153 script_badge.SetAppearance(1, ExtensionAction::ACTIVE); | 151 script_badge.SetAppearance(1, ExtensionAction::ACTIVE); |
| 154 EXPECT_TRUE(script_badge.GetIconAnimation(1)) | 152 EXPECT_TRUE(script_badge.GetIconAnimation(1)) |
| 155 << "Making a script badge visible should show its animation."; | 153 << "Making a script badge visible should show its animation."; |
| 156 | 154 |
| 157 script_badge.ClearAllValuesForTab(1); | 155 script_badge.ClearAllValuesForTab(1); |
| 158 EXPECT_FALSE(script_badge.GetIconAnimation(100)); | 156 EXPECT_FALSE(script_badge.GetIconAnimation(100)); |
| 157 |
| 158 message_loop.RunAllPending(); |
| 159 } | 159 } |
| 160 | 160 |
| 161 TEST_F(ExtensionActionTest, GetAttention) { | 161 TEST_F(ExtensionActionTest, GetAttention) { |
| 162 // Supports the icon animation. | 162 // Supports the icon animation. |
| 163 MessageLoop message_loop; | 163 MessageLoop message_loop; |
| 164 | 164 |
| 165 ExtensionAction script_badge("", ExtensionAction::TYPE_SCRIPT_BADGE); | 165 ExtensionAction script_badge("", ExtensionAction::TYPE_SCRIPT_BADGE); |
| 166 EXPECT_FALSE(script_badge.GetIsVisible(1)); | 166 EXPECT_FALSE(script_badge.GetIsVisible(1)); |
| 167 EXPECT_FALSE(script_badge.GetIconAnimation(1)); | 167 EXPECT_FALSE(script_badge.GetIconAnimation(1)); |
| 168 script_badge.SetAppearance(1, ExtensionAction::WANTS_ATTENTION); | 168 script_badge.SetAppearance(1, ExtensionAction::WANTS_ATTENTION); |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 246 action.SetPopupUrl(ExtensionAction::kDefaultTabId, url_baz); | 246 action.SetPopupUrl(ExtensionAction::kDefaultTabId, url_baz); |
| 247 ASSERT_EQ(url_baz, action.GetPopupUrl(1)); | 247 ASSERT_EQ(url_baz, action.GetPopupUrl(1)); |
| 248 ASSERT_EQ(url_bar, action.GetPopupUrl(100)); | 248 ASSERT_EQ(url_bar, action.GetPopupUrl(100)); |
| 249 | 249 |
| 250 action.ClearAllValuesForTab(100); | 250 action.ClearAllValuesForTab(100); |
| 251 ASSERT_EQ(url_baz, action.GetPopupUrl(1)); | 251 ASSERT_EQ(url_baz, action.GetPopupUrl(1)); |
| 252 ASSERT_EQ(url_baz, action.GetPopupUrl(100)); | 252 ASSERT_EQ(url_baz, action.GetPopupUrl(100)); |
| 253 } | 253 } |
| 254 | 254 |
| 255 } // namespace | 255 } // namespace |
| OLD | NEW |