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 <string> | 5 #include <string> |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
10 #include "base/stringprintf.h" | 10 #include "base/stringprintf.h" |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 &location_bar_updated, | 113 &location_bar_updated, |
114 chrome::NOTIFICATION_EXTENSION_LOCATION_BAR_UPDATED, | 114 chrome::NOTIFICATION_EXTENSION_LOCATION_BAR_UPDATED, |
115 content::Source<Profile>(tab_contents()->profile())); | 115 content::Source<Profile>(tab_contents()->profile())); |
116 | 116 |
117 // Initially, no script badges. | 117 // Initially, no script badges. |
118 EXPECT_THAT(script_badge_controller_->GetCurrentActions(), | 118 EXPECT_THAT(script_badge_controller_->GetCurrentActions(), |
119 testing::ElementsAre()); | 119 testing::ElementsAre()); |
120 | 120 |
121 ListValue val; | 121 ListValue val; |
122 script_badge_controller_->OnExecuteScriptFinished( | 122 script_badge_controller_->OnExecuteScriptFinished( |
123 extension->id(), true, | 123 extension->id(), |
| 124 "", // no error |
124 tab_contents()->web_contents()->GetController().GetActiveEntry()-> | 125 tab_contents()->web_contents()->GetController().GetActiveEntry()-> |
125 GetPageID(), | 126 GetPageID(), |
126 "", | 127 GURL(""), |
127 val); | 128 val); |
128 EXPECT_THAT(script_badge_controller_->GetCurrentActions(), | 129 EXPECT_THAT(script_badge_controller_->GetCurrentActions(), |
129 testing::ElementsAre(extension->script_badge())); | 130 testing::ElementsAre(extension->script_badge())); |
130 EXPECT_THAT(location_bar_updated.events, testing::Gt(0)); | 131 EXPECT_THAT(location_bar_updated.events, testing::Gt(0)); |
131 }; | 132 }; |
132 | 133 |
133 TEST_F(ScriptBadgeControllerTest, FragmentNavigation) { | 134 TEST_F(ScriptBadgeControllerTest, FragmentNavigation) { |
134 scoped_refptr<const Extension> extension = AddTestExtension(); | 135 scoped_refptr<const Extension> extension = AddTestExtension(); |
135 | 136 |
136 // Establish a page id. | 137 // Establish a page id. |
137 NavigateAndCommit(GURL("http://www.google.com")); | 138 NavigateAndCommit(GURL("http://www.google.com")); |
138 | 139 |
139 // Run script. Should be a notification and a script badge. | 140 // Run script. Should be a notification and a script badge. |
140 { | 141 { |
141 content::NotificationRegistrar notification_registrar; | 142 content::NotificationRegistrar notification_registrar; |
142 CountingNotificationObserver location_bar_updated; | 143 CountingNotificationObserver location_bar_updated; |
143 notification_registrar.Add( | 144 notification_registrar.Add( |
144 &location_bar_updated, | 145 &location_bar_updated, |
145 chrome::NOTIFICATION_EXTENSION_LOCATION_BAR_UPDATED, | 146 chrome::NOTIFICATION_EXTENSION_LOCATION_BAR_UPDATED, |
146 content::Source<Profile>(tab_contents()->profile())); | 147 content::Source<Profile>(tab_contents()->profile())); |
147 | 148 |
148 ListValue val; | 149 ListValue val; |
149 script_badge_controller_->OnExecuteScriptFinished( | 150 script_badge_controller_->OnExecuteScriptFinished( |
150 extension->id(), true, | 151 extension->id(), |
| 152 "", // no error |
151 tab_contents()->web_contents()->GetController().GetActiveEntry()-> | 153 tab_contents()->web_contents()->GetController().GetActiveEntry()-> |
152 GetPageID(), | 154 GetPageID(), |
153 "", | 155 GURL(""), |
154 val); | 156 val); |
155 | 157 |
156 EXPECT_THAT(script_badge_controller_->GetCurrentActions(), | 158 EXPECT_THAT(script_badge_controller_->GetCurrentActions(), |
157 testing::ElementsAre(extension->script_badge())); | 159 testing::ElementsAre(extension->script_badge())); |
158 EXPECT_EQ(1, location_bar_updated.events); | 160 EXPECT_EQ(1, location_bar_updated.events); |
159 } | 161 } |
160 | 162 |
161 // Navigate to a hash fragment. Shouldn't change. | 163 // Navigate to a hash fragment. Shouldn't change. |
162 { | 164 { |
163 content::NotificationRegistrar notification_registrar; | 165 content::NotificationRegistrar notification_registrar; |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
234 // Getting attention a second time should have no effect. | 236 // Getting attention a second time should have no effect. |
235 script_badge_controller_->GetAttentionFor(extension->id()); | 237 script_badge_controller_->GetAttentionFor(extension->id()); |
236 | 238 |
237 EXPECT_THAT(script_badge_controller_->GetCurrentActions(), | 239 EXPECT_THAT(script_badge_controller_->GetCurrentActions(), |
238 testing::ElementsAre(extension->script_badge())); | 240 testing::ElementsAre(extension->script_badge())); |
239 EXPECT_EQ(0, subsequent_get_attention_call.events); | 241 EXPECT_EQ(0, subsequent_get_attention_call.events); |
240 }; | 242 }; |
241 | 243 |
242 } // namespace | 244 } // namespace |
243 } // namespace extensions | 245 } // namespace extensions |
OLD | NEW |