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 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 EXPECT_FALSE(action.GetIconAnimation(100)); | 130 EXPECT_FALSE(action.GetIconAnimation(100)); |
131 action.SetAppearance(100, ExtensionAction::ACTIVE); | 131 action.SetAppearance(100, ExtensionAction::ACTIVE); |
132 ASSERT_FALSE(action.GetIsVisible(1)); | 132 ASSERT_FALSE(action.GetIsVisible(1)); |
133 ASSERT_TRUE(action.GetIsVisible(100)); | 133 ASSERT_TRUE(action.GetIsVisible(100)); |
134 EXPECT_TRUE(action.GetIconAnimation(100)); | 134 EXPECT_TRUE(action.GetIconAnimation(100)); |
135 | 135 |
136 action.ClearAllValuesForTab(100); | 136 action.ClearAllValuesForTab(100); |
137 ASSERT_FALSE(action.GetIsVisible(1)); | 137 ASSERT_FALSE(action.GetIsVisible(1)); |
138 ASSERT_FALSE(action.GetIsVisible(100)); | 138 ASSERT_FALSE(action.GetIsVisible(100)); |
139 EXPECT_FALSE(action.GetIconAnimation(100)); | 139 EXPECT_FALSE(action.GetIconAnimation(100)); |
| 140 |
| 141 message_loop.RunAllPending(); |
140 } | 142 } |
141 | 143 |
142 TEST_F(ExtensionActionTest, GetAttention) { | 144 TEST_F(ExtensionActionTest, GetAttention) { |
143 // Supports the icon animation. | 145 // Supports the icon animation. |
144 MessageLoop message_loop; | 146 MessageLoop message_loop; |
145 | 147 |
146 EXPECT_FALSE(action.GetIsVisible(1)); | 148 EXPECT_FALSE(action.GetIsVisible(1)); |
147 EXPECT_FALSE(action.GetIconAnimation(1)); | 149 EXPECT_FALSE(action.GetIconAnimation(1)); |
148 action.SetAppearance(1, ExtensionAction::WANTS_ATTENTION); | 150 action.SetAppearance(1, ExtensionAction::WANTS_ATTENTION); |
149 EXPECT_TRUE(action.GetIsVisible(1)); | 151 EXPECT_TRUE(action.GetIsVisible(1)); |
150 EXPECT_TRUE(action.GetIconAnimation(1)); | 152 EXPECT_TRUE(action.GetIconAnimation(1)); |
151 | 153 |
152 // Simulate waiting long enough for the animation to end. | 154 // Simulate waiting long enough for the animation to end. |
153 action.GetIconAnimation(1)->Stop(); | 155 action.GetIconAnimation(1)->Stop(); |
154 EXPECT_FALSE(action.GetIconAnimation(1)); // Sanity check. | 156 EXPECT_FALSE(action.GetIconAnimation(1)); // Sanity check. |
155 | 157 |
156 action.SetAppearance(1, ExtensionAction::ACTIVE); | 158 action.SetAppearance(1, ExtensionAction::ACTIVE); |
157 EXPECT_FALSE(action.GetIconAnimation(1)) | 159 EXPECT_FALSE(action.GetIconAnimation(1)) |
158 << "The animation should not play again if the icon was already visible."; | 160 << "The animation should not play again if the icon was already visible."; |
| 161 |
| 162 message_loop.RunAllPending(); |
159 } | 163 } |
160 | 164 |
161 TEST_F(ExtensionActionTest, Badge) { | 165 TEST_F(ExtensionActionTest, Badge) { |
162 ASSERT_EQ("", action.GetBadgeText(1)); | 166 ASSERT_EQ("", action.GetBadgeText(1)); |
163 action.SetBadgeText(ExtensionAction::kDefaultTabId, "foo"); | 167 action.SetBadgeText(ExtensionAction::kDefaultTabId, "foo"); |
164 ASSERT_EQ("foo", action.GetBadgeText(1)); | 168 ASSERT_EQ("foo", action.GetBadgeText(1)); |
165 ASSERT_EQ("foo", action.GetBadgeText(100)); | 169 ASSERT_EQ("foo", action.GetBadgeText(100)); |
166 action.SetBadgeText(100, "bar"); | 170 action.SetBadgeText(100, "bar"); |
167 ASSERT_EQ("foo", action.GetBadgeText(1)); | 171 ASSERT_EQ("foo", action.GetBadgeText(1)); |
168 ASSERT_EQ("bar", action.GetBadgeText(100)); | 172 ASSERT_EQ("bar", action.GetBadgeText(100)); |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
224 action.SetPopupUrl(ExtensionAction::kDefaultTabId, url_baz); | 228 action.SetPopupUrl(ExtensionAction::kDefaultTabId, url_baz); |
225 ASSERT_EQ(url_baz, action.GetPopupUrl(1)); | 229 ASSERT_EQ(url_baz, action.GetPopupUrl(1)); |
226 ASSERT_EQ(url_bar, action.GetPopupUrl(100)); | 230 ASSERT_EQ(url_bar, action.GetPopupUrl(100)); |
227 | 231 |
228 action.ClearAllValuesForTab(100); | 232 action.ClearAllValuesForTab(100); |
229 ASSERT_EQ(url_baz, action.GetPopupUrl(1)); | 233 ASSERT_EQ(url_baz, action.GetPopupUrl(1)); |
230 ASSERT_EQ(url_baz, action.GetPopupUrl(100)); | 234 ASSERT_EQ(url_baz, action.GetPopupUrl(100)); |
231 } | 235 } |
232 | 236 |
233 } // namespace | 237 } // namespace |
OLD | NEW |