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

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

Issue 16226028: Fix even more remaining uses of WeakPtr<T>'s operator T* conversion (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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 27 matching lines...) Expand all
38 ASSERT_TRUE(action.GetIsVisible(1)); 38 ASSERT_TRUE(action.GetIsVisible(1));
39 ASSERT_TRUE(action.GetIsVisible(100)); 39 ASSERT_TRUE(action.GetIsVisible(100));
40 40
41 action.SetAppearance(ExtensionAction::kDefaultTabId, 41 action.SetAppearance(ExtensionAction::kDefaultTabId,
42 ExtensionAction::INVISIBLE); 42 ExtensionAction::INVISIBLE);
43 ASSERT_FALSE(action.GetIsVisible(1)); 43 ASSERT_FALSE(action.GetIsVisible(1));
44 ASSERT_FALSE(action.GetIsVisible(100)); 44 ASSERT_FALSE(action.GetIsVisible(100));
45 action.SetAppearance(100, ExtensionAction::ACTIVE); 45 action.SetAppearance(100, ExtensionAction::ACTIVE);
46 ASSERT_FALSE(action.GetIsVisible(1)); 46 ASSERT_FALSE(action.GetIsVisible(1));
47 ASSERT_TRUE(action.GetIsVisible(100)); 47 ASSERT_TRUE(action.GetIsVisible(100));
48 EXPECT_FALSE(action.GetIconAnimation(100)) 48 EXPECT_FALSE(action.GetIconAnimation(100).get())
49 << "Page actions should not animate."; 49 << "Page actions should not animate.";
50 50
51 action.ClearAllValuesForTab(100); 51 action.ClearAllValuesForTab(100);
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 base::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(
67 script_badge.GetIconAnimation(ExtensionAction::kDefaultTabId).get());
67 script_badge.SetAppearance(ExtensionAction::kDefaultTabId, 68 script_badge.SetAppearance(ExtensionAction::kDefaultTabId,
68 ExtensionAction::ACTIVE); 69 ExtensionAction::ACTIVE);
69 EXPECT_FALSE(script_badge.GetIconAnimation(ExtensionAction::kDefaultTabId)) 70 EXPECT_FALSE(
71 script_badge.GetIconAnimation(ExtensionAction::kDefaultTabId).get())
70 << "Showing the default tab should not animate script badges."; 72 << "Showing the default tab should not animate script badges.";
71 73
72 script_badge.SetAppearance(ExtensionAction::kDefaultTabId, 74 script_badge.SetAppearance(ExtensionAction::kDefaultTabId,
73 ExtensionAction::INVISIBLE); 75 ExtensionAction::INVISIBLE);
74 EXPECT_FALSE(script_badge.GetIconAnimation(1)) 76 EXPECT_FALSE(script_badge.GetIconAnimation(1).get())
75 << "Making a script badge invisible should not show its animation."; 77 << "Making a script badge invisible should not show its animation.";
76 script_badge.SetAppearance(1, ExtensionAction::ACTIVE); 78 script_badge.SetAppearance(1, ExtensionAction::ACTIVE);
77 EXPECT_TRUE(script_badge.GetIconAnimation(1)) 79 EXPECT_TRUE(script_badge.GetIconAnimation(1).get())
78 << "Making a script badge visible should show its animation."; 80 << "Making a script badge visible should show its animation.";
79 81
80 script_badge.ClearAllValuesForTab(1); 82 script_badge.ClearAllValuesForTab(1);
81 EXPECT_FALSE(script_badge.GetIconAnimation(100)); 83 EXPECT_FALSE(script_badge.GetIconAnimation(100).get());
82 } 84 }
83 85
84 TEST(ExtensionActionTest, GetAttention) { 86 TEST(ExtensionActionTest, GetAttention) {
85 // Supports the icon animation. 87 // Supports the icon animation.
86 scoped_ptr<base::MessageLoop> message_loop(new base::MessageLoop); 88 scoped_ptr<base::MessageLoop> message_loop(new base::MessageLoop);
87 89
88 ExtensionAction script_badge( 90 ExtensionAction script_badge(
89 std::string(), ActionInfo::TYPE_SCRIPT_BADGE, ActionInfo()); 91 std::string(), ActionInfo::TYPE_SCRIPT_BADGE, ActionInfo());
90 EXPECT_FALSE(script_badge.GetIsVisible(1)); 92 EXPECT_FALSE(script_badge.GetIsVisible(1));
91 EXPECT_FALSE(script_badge.GetIconAnimation(1)); 93 EXPECT_FALSE(script_badge.GetIconAnimation(1).get());
92 script_badge.SetAppearance(1, ExtensionAction::WANTS_ATTENTION); 94 script_badge.SetAppearance(1, ExtensionAction::WANTS_ATTENTION);
93 EXPECT_TRUE(script_badge.GetIsVisible(1)); 95 EXPECT_TRUE(script_badge.GetIsVisible(1));
94 EXPECT_TRUE(script_badge.GetIconAnimation(1)); 96 EXPECT_TRUE(script_badge.GetIconAnimation(1).get());
95 97
96 // Simulate waiting long enough for the animation to end. 98 // Simulate waiting long enough for the animation to end.
97 message_loop.reset(); // Can't have 2 MessageLoops alive at once. 99 message_loop.reset(); // Can't have 2 MessageLoops alive at once.
98 message_loop.reset(new base::MessageLoop); 100 message_loop.reset(new base::MessageLoop);
99 EXPECT_FALSE(script_badge.GetIconAnimation(1)); // Sanity check. 101 EXPECT_FALSE(script_badge.GetIconAnimation(1).get()); // Sanity check.
100 102
101 script_badge.SetAppearance(1, ExtensionAction::ACTIVE); 103 script_badge.SetAppearance(1, ExtensionAction::ACTIVE);
102 EXPECT_FALSE(script_badge.GetIconAnimation(1)) 104 EXPECT_FALSE(script_badge.GetIconAnimation(1).get())
103 << "The animation should not play again if the icon was already visible."; 105 << "The animation should not play again if the icon was already visible.";
104 } 106 }
105 107
106 TEST(ExtensionActionTest, Icon) { 108 TEST(ExtensionActionTest, Icon) {
107 ActionInfo action_info; 109 ActionInfo action_info;
108 action_info.default_icon.Add(16, "icon16.png"); 110 action_info.default_icon.Add(16, "icon16.png");
109 ExtensionAction page_action( 111 ExtensionAction page_action(
110 std::string(), ActionInfo::TYPE_PAGE, action_info); 112 std::string(), ActionInfo::TYPE_PAGE, action_info);
111 ASSERT_TRUE(page_action.default_icon()); 113 ASSERT_TRUE(page_action.default_icon());
112 EXPECT_EQ("icon16.png", 114 EXPECT_EQ("icon16.png",
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 action.SetPopupUrl(ExtensionAction::kDefaultTabId, url_baz); 194 action.SetPopupUrl(ExtensionAction::kDefaultTabId, url_baz);
193 ASSERT_EQ(url_baz, action.GetPopupUrl(1)); 195 ASSERT_EQ(url_baz, action.GetPopupUrl(1));
194 ASSERT_EQ(url_bar, action.GetPopupUrl(100)); 196 ASSERT_EQ(url_bar, action.GetPopupUrl(100));
195 197
196 action.ClearAllValuesForTab(100); 198 action.ClearAllValuesForTab(100);
197 ASSERT_EQ(url_baz, action.GetPopupUrl(1)); 199 ASSERT_EQ(url_baz, action.GetPopupUrl(1));
198 ASSERT_EQ(url_baz, action.GetPopupUrl(100)); 200 ASSERT_EQ(url_baz, action.GetPopupUrl(100));
199 } 201 }
200 202
201 } // namespace 203 } // namespace
OLDNEW
« no previous file with comments | « base/memory/weak_ptr_unittest.cc ('k') | chrome/browser/sync/glue/shared_change_processor_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698