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

Side by Side Diff: chrome/common/extensions/extension_action_unittest.cc

Issue 10823143: Make the getAttention badge grey. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Move the Grant/Appearance code into the switch Created 8 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « chrome/common/extensions/extension_action.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/path_service.h" 8 #include "base/path_service.h"
8 #include "chrome/common/chrome_paths.h" 9 #include "chrome/common/chrome_paths.h"
9 #include "chrome/common/extensions/extension_action.h" 10 #include "chrome/common/extensions/extension_action.h"
10 #include "googleurl/src/gurl.h" 11 #include "googleurl/src/gurl.h"
11 #include "grit/theme_resources.h" 12 #include "grit/theme_resources.h"
12 #include "testing/gtest/include/gtest/gtest.h" 13 #include "testing/gtest/include/gtest/gtest.h"
13 #include "third_party/skia/include/core/SkBitmap.h" 14 #include "third_party/skia/include/core/SkBitmap.h"
14 #include "ui/base/resource/resource_bundle.h" 15 #include "ui/base/resource/resource_bundle.h"
15 #include "ui/gfx/image/image.h" 16 #include "ui/gfx/image/image.h"
16 #include "ui/gfx/skia_util.h" 17 #include "ui/gfx/skia_util.h"
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 106
106 action.SetIconIndex(100, 0); 107 action.SetIconIndex(100, 0);
107 ASSERT_EQ(0, action.GetIconIndex(100)); 108 ASSERT_EQ(0, action.GetIconIndex(100));
108 ASSERT_EQ(1, action.GetIconIndex(1)); 109 ASSERT_EQ(1, action.GetIconIndex(1));
109 action.ClearAllValuesForTab(100); 110 action.ClearAllValuesForTab(100);
110 ASSERT_EQ(1, action.GetIconIndex(100)); 111 ASSERT_EQ(1, action.GetIconIndex(100));
111 ASSERT_EQ(1, action.GetIconIndex(1)); 112 ASSERT_EQ(1, action.GetIconIndex(1));
112 } 113 }
113 114
114 TEST_F(ExtensionActionTest, Visibility) { 115 TEST_F(ExtensionActionTest, Visibility) {
116 // Supports the icon animation.
117 MessageLoop message_loop;
118
115 ASSERT_FALSE(action.GetIsVisible(1)); 119 ASSERT_FALSE(action.GetIsVisible(1));
116 action.SetIsVisible(ExtensionAction::kDefaultTabId, true); 120 EXPECT_FALSE(action.GetIconAnimation(ExtensionAction::kDefaultTabId));
121 action.SetAppearance(ExtensionAction::kDefaultTabId, ExtensionAction::ACTIVE);
117 ASSERT_TRUE(action.GetIsVisible(1)); 122 ASSERT_TRUE(action.GetIsVisible(1));
118 ASSERT_TRUE(action.GetIsVisible(100)); 123 ASSERT_TRUE(action.GetIsVisible(100));
119 action.SetIsVisible(ExtensionAction::kDefaultTabId, false); 124 EXPECT_FALSE(action.GetIconAnimation(ExtensionAction::kDefaultTabId));
125
126 action.SetAppearance(ExtensionAction::kDefaultTabId,
127 ExtensionAction::INVISIBLE);
120 ASSERT_FALSE(action.GetIsVisible(1)); 128 ASSERT_FALSE(action.GetIsVisible(1));
121 ASSERT_FALSE(action.GetIsVisible(100)); 129 ASSERT_FALSE(action.GetIsVisible(100));
122 action.SetIsVisible(100, true); 130 EXPECT_FALSE(action.GetIconAnimation(100));
131 action.SetAppearance(100, ExtensionAction::ACTIVE);
123 ASSERT_FALSE(action.GetIsVisible(1)); 132 ASSERT_FALSE(action.GetIsVisible(1));
124 ASSERT_TRUE(action.GetIsVisible(100)); 133 ASSERT_TRUE(action.GetIsVisible(100));
134 EXPECT_TRUE(action.GetIconAnimation(100));
135
125 action.ClearAllValuesForTab(100); 136 action.ClearAllValuesForTab(100);
126 ASSERT_FALSE(action.GetIsVisible(1)); 137 ASSERT_FALSE(action.GetIsVisible(1));
127 ASSERT_FALSE(action.GetIsVisible(100)); 138 ASSERT_FALSE(action.GetIsVisible(100));
139 EXPECT_FALSE(action.GetIconAnimation(100));
140 }
141
142 TEST_F(ExtensionActionTest, GetAttention) {
143 // Supports the icon animation.
144 MessageLoop message_loop;
145
146 EXPECT_FALSE(action.GetIsVisible(1));
147 EXPECT_FALSE(action.GetIconAnimation(1));
148 action.SetAppearance(1, ExtensionAction::WANTS_ATTENTION);
149 EXPECT_TRUE(action.GetIsVisible(1));
150 EXPECT_TRUE(action.GetIconAnimation(1));
151
152 // Simulate waiting long enough for the animation to end.
153 action.GetIconAnimation(1)->Stop();
154 EXPECT_FALSE(action.GetIconAnimation(1)); // Sanity check.
155
156 action.SetAppearance(1, ExtensionAction::ACTIVE);
157 EXPECT_FALSE(action.GetIconAnimation(1))
158 << "The animation should not play again if the icon was already visible.";
128 } 159 }
129 160
130 TEST_F(ExtensionActionTest, Badge) { 161 TEST_F(ExtensionActionTest, Badge) {
131 ASSERT_EQ("", action.GetBadgeText(1)); 162 ASSERT_EQ("", action.GetBadgeText(1));
132 action.SetBadgeText(ExtensionAction::kDefaultTabId, "foo"); 163 action.SetBadgeText(ExtensionAction::kDefaultTabId, "foo");
133 ASSERT_EQ("foo", action.GetBadgeText(1)); 164 ASSERT_EQ("foo", action.GetBadgeText(1));
134 ASSERT_EQ("foo", action.GetBadgeText(100)); 165 ASSERT_EQ("foo", action.GetBadgeText(100));
135 action.SetBadgeText(100, "bar"); 166 action.SetBadgeText(100, "bar");
136 ASSERT_EQ("foo", action.GetBadgeText(1)); 167 ASSERT_EQ("foo", action.GetBadgeText(1));
137 ASSERT_EQ("bar", action.GetBadgeText(100)); 168 ASSERT_EQ("bar", action.GetBadgeText(100));
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 action.SetPopupUrl(ExtensionAction::kDefaultTabId, url_baz); 224 action.SetPopupUrl(ExtensionAction::kDefaultTabId, url_baz);
194 ASSERT_EQ(url_baz, action.GetPopupUrl(1)); 225 ASSERT_EQ(url_baz, action.GetPopupUrl(1));
195 ASSERT_EQ(url_bar, action.GetPopupUrl(100)); 226 ASSERT_EQ(url_bar, action.GetPopupUrl(100));
196 227
197 action.ClearAllValuesForTab(100); 228 action.ClearAllValuesForTab(100);
198 ASSERT_EQ(url_baz, action.GetPopupUrl(1)); 229 ASSERT_EQ(url_baz, action.GetPopupUrl(1));
199 ASSERT_EQ(url_baz, action.GetPopupUrl(100)); 230 ASSERT_EQ(url_baz, action.GetPopupUrl(100));
200 } 231 }
201 232
202 } // namespace 233 } // namespace
OLDNEW
« no previous file with comments | « chrome/common/extensions/extension_action.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698