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

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

Issue 11043004: Merge 157903 - Turn off animations for page actions and browser actions. (Closed) Base URL: svn://svn.chromium.org/chrome/branches/1271/src/
Patch Set: Created 8 years, 2 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/message_loop.h" 5 #include "base/message_loop.h"
6 #include "chrome/common/extensions/extension_action.h" 6 #include "chrome/common/extensions/extension_action.h"
7 #include "googleurl/src/gurl.h" 7 #include "googleurl/src/gurl.h"
8 #include "testing/gtest/include/gtest/gtest.h" 8 #include "testing/gtest/include/gtest/gtest.h"
9 9
10 namespace { 10 namespace {
(...skipping 15 matching lines...) Expand all
26 action.SetTitle(100, "bar"); 26 action.SetTitle(100, "bar");
27 ASSERT_EQ("foo", action.GetTitle(1)); 27 ASSERT_EQ("foo", action.GetTitle(1));
28 ASSERT_EQ("bar", action.GetTitle(100)); 28 ASSERT_EQ("bar", action.GetTitle(100));
29 action.SetTitle(ExtensionAction::kDefaultTabId, "baz"); 29 action.SetTitle(ExtensionAction::kDefaultTabId, "baz");
30 ASSERT_EQ("baz", action.GetTitle(1)); 30 ASSERT_EQ("baz", action.GetTitle(1));
31 action.ClearAllValuesForTab(100); 31 action.ClearAllValuesForTab(100);
32 ASSERT_EQ("baz", action.GetTitle(100)); 32 ASSERT_EQ("baz", action.GetTitle(100));
33 } 33 }
34 34
35 TEST_F(ExtensionActionTest, Visibility) { 35 TEST_F(ExtensionActionTest, Visibility) {
36 // Supports the icon animation.
37 MessageLoop message_loop;
38
39 ASSERT_FALSE(action.GetIsVisible(1)); 36 ASSERT_FALSE(action.GetIsVisible(1));
40 EXPECT_FALSE(action.GetIconAnimation(ExtensionAction::kDefaultTabId));
41 action.SetAppearance(ExtensionAction::kDefaultTabId, ExtensionAction::ACTIVE); 37 action.SetAppearance(ExtensionAction::kDefaultTabId, ExtensionAction::ACTIVE);
42 ASSERT_TRUE(action.GetIsVisible(1)); 38 ASSERT_TRUE(action.GetIsVisible(1));
43 ASSERT_TRUE(action.GetIsVisible(100)); 39 ASSERT_TRUE(action.GetIsVisible(100));
44 EXPECT_FALSE(action.GetIconAnimation(ExtensionAction::kDefaultTabId));
45 40
46 action.SetAppearance(ExtensionAction::kDefaultTabId, 41 action.SetAppearance(ExtensionAction::kDefaultTabId,
47 ExtensionAction::INVISIBLE); 42 ExtensionAction::INVISIBLE);
48 ASSERT_FALSE(action.GetIsVisible(1)); 43 ASSERT_FALSE(action.GetIsVisible(1));
49 ASSERT_FALSE(action.GetIsVisible(100)); 44 ASSERT_FALSE(action.GetIsVisible(100));
50 EXPECT_FALSE(action.GetIconAnimation(100));
51 action.SetAppearance(100, ExtensionAction::ACTIVE); 45 action.SetAppearance(100, ExtensionAction::ACTIVE);
52 ASSERT_FALSE(action.GetIsVisible(1)); 46 ASSERT_FALSE(action.GetIsVisible(1));
53 ASSERT_TRUE(action.GetIsVisible(100)); 47 ASSERT_TRUE(action.GetIsVisible(100));
54 EXPECT_TRUE(action.GetIconAnimation(100)); 48 EXPECT_FALSE(action.GetIconAnimation(100))
49 << "Page actions should not animate.";
55 50
56 action.ClearAllValuesForTab(100); 51 action.ClearAllValuesForTab(100);
57 ASSERT_FALSE(action.GetIsVisible(1)); 52 ASSERT_FALSE(action.GetIsVisible(1));
58 ASSERT_FALSE(action.GetIsVisible(100)); 53 ASSERT_FALSE(action.GetIsVisible(100));
59 EXPECT_FALSE(action.GetIconAnimation(100)); 54 }
55
56 TEST_F(ExtensionActionTest, ScriptBadgeAnimation) {
57 // Supports the icon animation.
58 MessageLoop message_loop;
59
60 ExtensionAction script_badge("", ExtensionAction::TYPE_SCRIPT_BADGE);
61 EXPECT_FALSE(script_badge.GetIconAnimation(ExtensionAction::kDefaultTabId));
62 script_badge.SetAppearance(ExtensionAction::kDefaultTabId,
63 ExtensionAction::ACTIVE);
64 EXPECT_FALSE(script_badge.GetIconAnimation(ExtensionAction::kDefaultTabId))
65 << "Showing the default tab should not animate script badges.";
66
67 script_badge.SetAppearance(ExtensionAction::kDefaultTabId,
68 ExtensionAction::INVISIBLE);
69 EXPECT_FALSE(script_badge.GetIconAnimation(1))
70 << "Making a script badge invisible should not show its animation.";
71 script_badge.SetAppearance(1, ExtensionAction::ACTIVE);
72 EXPECT_TRUE(script_badge.GetIconAnimation(1))
73 << "Making a script badge visible should show its animation.";
74
75 script_badge.ClearAllValuesForTab(1);
76 EXPECT_FALSE(script_badge.GetIconAnimation(100));
60 } 77 }
61 78
62 TEST_F(ExtensionActionTest, GetAttention) { 79 TEST_F(ExtensionActionTest, GetAttention) {
63 // Supports the icon animation. 80 // Supports the icon animation.
64 scoped_ptr<MessageLoop> message_loop(new MessageLoop); 81 scoped_ptr<MessageLoop> message_loop(new MessageLoop);
65 82
66 EXPECT_FALSE(action.GetIsVisible(1)); 83 ExtensionAction script_badge("", ExtensionAction::TYPE_SCRIPT_BADGE);
67 EXPECT_FALSE(action.GetIconAnimation(1)); 84 EXPECT_FALSE(script_badge.GetIsVisible(1));
68 action.SetAppearance(1, ExtensionAction::WANTS_ATTENTION); 85 EXPECT_FALSE(script_badge.GetIconAnimation(1));
69 EXPECT_TRUE(action.GetIsVisible(1)); 86 script_badge.SetAppearance(1, ExtensionAction::WANTS_ATTENTION);
70 EXPECT_TRUE(action.GetIconAnimation(1)); 87 EXPECT_TRUE(script_badge.GetIsVisible(1));
88 EXPECT_TRUE(script_badge.GetIconAnimation(1));
71 89
72 // Simulate waiting long enough for the animation to end. 90 // Simulate waiting long enough for the animation to end.
73 message_loop.reset(); // Can't have 2 MessageLoops alive at once. 91 message_loop.reset(); // Can't have 2 MessageLoops alive at once.
74 message_loop.reset(new MessageLoop); 92 message_loop.reset(new MessageLoop);
75 EXPECT_FALSE(action.GetIconAnimation(1)); // Sanity check. 93 EXPECT_FALSE(script_badge.GetIconAnimation(1)); // Sanity check.
76 94
77 action.SetAppearance(1, ExtensionAction::ACTIVE); 95 script_badge.SetAppearance(1, ExtensionAction::ACTIVE);
78 EXPECT_FALSE(action.GetIconAnimation(1)) 96 EXPECT_FALSE(script_badge.GetIconAnimation(1))
79 << "The animation should not play again if the icon was already visible."; 97 << "The animation should not play again if the icon was already visible.";
80 } 98 }
81 99
82 TEST_F(ExtensionActionTest, Badge) { 100 TEST_F(ExtensionActionTest, Badge) {
83 ASSERT_EQ("", action.GetBadgeText(1)); 101 ASSERT_EQ("", action.GetBadgeText(1));
84 action.SetBadgeText(ExtensionAction::kDefaultTabId, "foo"); 102 action.SetBadgeText(ExtensionAction::kDefaultTabId, "foo");
85 ASSERT_EQ("foo", action.GetBadgeText(1)); 103 ASSERT_EQ("foo", action.GetBadgeText(1));
86 ASSERT_EQ("foo", action.GetBadgeText(100)); 104 ASSERT_EQ("foo", action.GetBadgeText(100));
87 action.SetBadgeText(100, "bar"); 105 action.SetBadgeText(100, "bar");
88 ASSERT_EQ("foo", action.GetBadgeText(1)); 106 ASSERT_EQ("foo", action.GetBadgeText(1));
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 action.SetPopupUrl(ExtensionAction::kDefaultTabId, url_baz); 163 action.SetPopupUrl(ExtensionAction::kDefaultTabId, url_baz);
146 ASSERT_EQ(url_baz, action.GetPopupUrl(1)); 164 ASSERT_EQ(url_baz, action.GetPopupUrl(1));
147 ASSERT_EQ(url_bar, action.GetPopupUrl(100)); 165 ASSERT_EQ(url_bar, action.GetPopupUrl(100));
148 166
149 action.ClearAllValuesForTab(100); 167 action.ClearAllValuesForTab(100);
150 ASSERT_EQ(url_baz, action.GetPopupUrl(1)); 168 ASSERT_EQ(url_baz, action.GetPopupUrl(1));
151 ASSERT_EQ(url_baz, action.GetPopupUrl(100)); 169 ASSERT_EQ(url_baz, action.GetPopupUrl(100));
152 } 170 }
153 171
154 } // namespace 172 } // 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