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

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

Issue 14113053: chrome: Use base::MessageLoop. (Part 3) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase again Created 7 years, 6 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
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/browser/extensions/extension_action.h" 6 #include "chrome/browser/extensions/extension_action.h"
7 #include "chrome/common/extensions/api/extension_action/action_info.h" 7 #include "chrome/common/extensions/api/extension_action/action_info.h"
8 #include "googleurl/src/gurl.h" 8 #include "googleurl/src/gurl.h"
9 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
10 10
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 ASSERT_FALSE(action.GetIsVisible(1)); 52 ASSERT_FALSE(action.GetIsVisible(1));
53 ASSERT_FALSE(action.GetIsVisible(100)); 53 ASSERT_FALSE(action.GetIsVisible(100));
54 54
55 ExtensionAction browser_action( 55 ExtensionAction browser_action(
56 std::string(), ActionInfo::TYPE_BROWSER, ActionInfo()); 56 std::string(), ActionInfo::TYPE_BROWSER, ActionInfo());
57 ASSERT_TRUE(browser_action.GetIsVisible(1)); 57 ASSERT_TRUE(browser_action.GetIsVisible(1));
58 } 58 }
59 59
60 TEST(ExtensionActionTest, ScriptBadgeAnimation) { 60 TEST(ExtensionActionTest, ScriptBadgeAnimation) {
61 // Supports the icon animation. 61 // Supports the icon animation.
62 MessageLoop message_loop; 62 base::MessageLoop message_loop;
63 63
64 ExtensionAction script_badge( 64 ExtensionAction script_badge(
65 std::string(), ActionInfo::TYPE_SCRIPT_BADGE, ActionInfo()); 65 std::string(), ActionInfo::TYPE_SCRIPT_BADGE, ActionInfo());
66 EXPECT_FALSE(script_badge.GetIconAnimation(ExtensionAction::kDefaultTabId)); 66 EXPECT_FALSE(script_badge.GetIconAnimation(ExtensionAction::kDefaultTabId));
67 script_badge.SetAppearance(ExtensionAction::kDefaultTabId, 67 script_badge.SetAppearance(ExtensionAction::kDefaultTabId,
68 ExtensionAction::ACTIVE); 68 ExtensionAction::ACTIVE);
69 EXPECT_FALSE(script_badge.GetIconAnimation(ExtensionAction::kDefaultTabId)) 69 EXPECT_FALSE(script_badge.GetIconAnimation(ExtensionAction::kDefaultTabId))
70 << "Showing the default tab should not animate script badges."; 70 << "Showing the default tab should not animate script badges.";
71 71
72 script_badge.SetAppearance(ExtensionAction::kDefaultTabId, 72 script_badge.SetAppearance(ExtensionAction::kDefaultTabId,
73 ExtensionAction::INVISIBLE); 73 ExtensionAction::INVISIBLE);
74 EXPECT_FALSE(script_badge.GetIconAnimation(1)) 74 EXPECT_FALSE(script_badge.GetIconAnimation(1))
75 << "Making a script badge invisible should not show its animation."; 75 << "Making a script badge invisible should not show its animation.";
76 script_badge.SetAppearance(1, ExtensionAction::ACTIVE); 76 script_badge.SetAppearance(1, ExtensionAction::ACTIVE);
77 EXPECT_TRUE(script_badge.GetIconAnimation(1)) 77 EXPECT_TRUE(script_badge.GetIconAnimation(1))
78 << "Making a script badge visible should show its animation."; 78 << "Making a script badge visible should show its animation.";
79 79
80 script_badge.ClearAllValuesForTab(1); 80 script_badge.ClearAllValuesForTab(1);
81 EXPECT_FALSE(script_badge.GetIconAnimation(100)); 81 EXPECT_FALSE(script_badge.GetIconAnimation(100));
82 } 82 }
83 83
84 TEST(ExtensionActionTest, GetAttention) { 84 TEST(ExtensionActionTest, GetAttention) {
85 // Supports the icon animation. 85 // Supports the icon animation.
86 scoped_ptr<MessageLoop> message_loop(new MessageLoop); 86 scoped_ptr<base::MessageLoop> message_loop(new base::MessageLoop);
87 87
88 ExtensionAction script_badge( 88 ExtensionAction script_badge(
89 std::string(), ActionInfo::TYPE_SCRIPT_BADGE, ActionInfo()); 89 std::string(), ActionInfo::TYPE_SCRIPT_BADGE, ActionInfo());
90 EXPECT_FALSE(script_badge.GetIsVisible(1)); 90 EXPECT_FALSE(script_badge.GetIsVisible(1));
91 EXPECT_FALSE(script_badge.GetIconAnimation(1)); 91 EXPECT_FALSE(script_badge.GetIconAnimation(1));
92 script_badge.SetAppearance(1, ExtensionAction::WANTS_ATTENTION); 92 script_badge.SetAppearance(1, ExtensionAction::WANTS_ATTENTION);
93 EXPECT_TRUE(script_badge.GetIsVisible(1)); 93 EXPECT_TRUE(script_badge.GetIsVisible(1));
94 EXPECT_TRUE(script_badge.GetIconAnimation(1)); 94 EXPECT_TRUE(script_badge.GetIconAnimation(1));
95 95
96 // Simulate waiting long enough for the animation to end. 96 // Simulate waiting long enough for the animation to end.
97 message_loop.reset(); // Can't have 2 MessageLoops alive at once. 97 message_loop.reset(); // Can't have 2 MessageLoops alive at once.
98 message_loop.reset(new MessageLoop); 98 message_loop.reset(new base::MessageLoop);
99 EXPECT_FALSE(script_badge.GetIconAnimation(1)); // Sanity check. 99 EXPECT_FALSE(script_badge.GetIconAnimation(1)); // Sanity check.
100 100
101 script_badge.SetAppearance(1, ExtensionAction::ACTIVE); 101 script_badge.SetAppearance(1, ExtensionAction::ACTIVE);
102 EXPECT_FALSE(script_badge.GetIconAnimation(1)) 102 EXPECT_FALSE(script_badge.GetIconAnimation(1))
103 << "The animation should not play again if the icon was already visible."; 103 << "The animation should not play again if the icon was already visible.";
104 } 104 }
105 105
106 TEST(ExtensionActionTest, Icon) { 106 TEST(ExtensionActionTest, Icon) {
107 ActionInfo action_info; 107 ActionInfo action_info;
108 action_info.default_icon.Add(16, "icon16.png"); 108 action_info.default_icon.Add(16, "icon16.png");
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 action.SetPopupUrl(ExtensionAction::kDefaultTabId, url_baz); 192 action.SetPopupUrl(ExtensionAction::kDefaultTabId, url_baz);
193 ASSERT_EQ(url_baz, action.GetPopupUrl(1)); 193 ASSERT_EQ(url_baz, action.GetPopupUrl(1));
194 ASSERT_EQ(url_bar, action.GetPopupUrl(100)); 194 ASSERT_EQ(url_bar, action.GetPopupUrl(100));
195 195
196 action.ClearAllValuesForTab(100); 196 action.ClearAllValuesForTab(100);
197 ASSERT_EQ(url_baz, action.GetPopupUrl(1)); 197 ASSERT_EQ(url_baz, action.GetPopupUrl(1));
198 ASSERT_EQ(url_baz, action.GetPopupUrl(100)); 198 ASSERT_EQ(url_baz, action.GetPopupUrl(100));
199 } 199 }
200 200
201 } // namespace 201 } // namespace
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_action_icon_factory_unittest.cc ('k') | chrome/browser/extensions/extension_apitest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698