| 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 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 179 content::Source<Profile>(tab_contents()->profile())); | 179 content::Source<Profile>(tab_contents()->profile())); |
| 180 | 180 |
| 181 Reload(); | 181 Reload(); |
| 182 | 182 |
| 183 EXPECT_THAT(script_badge_controller_->GetCurrentActions(), | 183 EXPECT_THAT(script_badge_controller_->GetCurrentActions(), |
| 184 testing::ElementsAre()); | 184 testing::ElementsAre()); |
| 185 EXPECT_EQ(0, location_bar_updated.events); | 185 EXPECT_EQ(0, location_bar_updated.events); |
| 186 } | 186 } |
| 187 } | 187 } |
| 188 | 188 |
| 189 TEST_F(ScriptBadgeControllerTest, GetAttentionMakesBadgeVisible) { |
| 190 content::NotificationRegistrar notification_registrar; |
| 191 |
| 192 scoped_refptr<const Extension> extension = |
| 193 ExtensionBuilder() |
| 194 .SetManifest(DictionaryBuilder() |
| 195 .Set("name", "Extension") |
| 196 .Set("version", "1.0.0") |
| 197 .Set("manifest_version", 2) |
| 198 .Set("permissions", ListBuilder() |
| 199 .Append("tabs"))) |
| 200 .Build(); |
| 201 extension_service_->AddExtension(extension); |
| 202 |
| 203 // Establish a page id. |
| 204 NavigateAndCommit(GURL("http://www.google.com")); |
| 205 |
| 206 CountingNotificationObserver initial_badge_display; |
| 207 notification_registrar.Add( |
| 208 &initial_badge_display, |
| 209 chrome::NOTIFICATION_EXTENSION_LOCATION_BAR_UPDATED, |
| 210 content::Source<Profile>(tab_contents()->profile())); |
| 211 |
| 212 // Initially, no script badges. |
| 213 EXPECT_THAT(script_badge_controller_->GetCurrentActions(), |
| 214 testing::ElementsAre()); |
| 215 |
| 216 // Getting attention the first time should display the badge. |
| 217 script_badge_controller_->GetAttentionFor(extension->id()); |
| 218 |
| 219 EXPECT_THAT(script_badge_controller_->GetCurrentActions(), |
| 220 testing::ElementsAre(extension->script_badge())); |
| 221 EXPECT_THAT(initial_badge_display.events, testing::Gt(0)); |
| 222 |
| 223 CountingNotificationObserver subsequent_get_attention_call; |
| 224 notification_registrar.Add( |
| 225 &subsequent_get_attention_call, |
| 226 chrome::NOTIFICATION_EXTENSION_LOCATION_BAR_UPDATED, |
| 227 content::Source<Profile>(tab_contents()->profile())); |
| 228 |
| 229 // Getting attention a second time should have no effect. |
| 230 script_badge_controller_->GetAttentionFor(extension->id()); |
| 231 |
| 232 EXPECT_THAT(script_badge_controller_->GetCurrentActions(), |
| 233 testing::ElementsAre(extension->script_badge())); |
| 234 EXPECT_EQ(0, subsequent_get_attention_call.events); |
| 235 }; |
| 236 |
| 189 } // namespace | 237 } // namespace |
| 190 } // namespace extensions | 238 } // namespace extensions |
| OLD | NEW |