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" |
11 #include "chrome/browser/extensions/extension_service.h" | 11 #include "chrome/browser/extensions/extension_service.h" |
12 #include "chrome/browser/extensions/script_badge_controller.h" | 12 #include "chrome/browser/extensions/script_badge_controller.h" |
13 #include "chrome/browser/extensions/tab_helper.h" | 13 #include "chrome/browser/extensions/tab_helper.h" |
14 #include "chrome/browser/extensions/test_extension_system.h" | 14 #include "chrome/browser/extensions/test_extension_system.h" |
15 #include "chrome/browser/ui/tab_contents/tab_contents.h" | 15 #include "chrome/browser/ui/tab_contents/tab_contents.h" |
16 #include "chrome/browser/ui/tab_contents/test_tab_contents.h" | 16 #include "chrome/browser/ui/tab_contents/test_tab_contents.h" |
17 #include "chrome/common/chrome_notification_types.h" | 17 #include "chrome/common/chrome_notification_types.h" |
| 18 #include "chrome/common/chrome_version_info.h" |
18 #include "chrome/common/extensions/extension.h" | 19 #include "chrome/common/extensions/extension.h" |
19 #include "chrome/common/extensions/extension_builder.h" | 20 #include "chrome/common/extensions/extension_builder.h" |
| 21 #include "chrome/common/extensions/features/feature.h" |
20 #include "chrome/common/extensions/value_builder.h" | 22 #include "chrome/common/extensions/value_builder.h" |
21 #include "chrome/test/base/testing_profile.h" | 23 #include "chrome/test/base/testing_profile.h" |
22 #include "content/public/browser/browser_thread.h" | 24 #include "content/public/browser/browser_thread.h" |
23 #include "content/public/browser/navigation_entry.h" | 25 #include "content/public/browser/navigation_entry.h" |
24 #include "content/public/browser/notification_registrar.h" | 26 #include "content/public/browser/notification_registrar.h" |
25 #include "content/public/browser/notification_source.h" | 27 #include "content/public/browser/notification_source.h" |
26 #include "content/public/browser/web_contents.h" | 28 #include "content/public/browser/web_contents.h" |
27 #include "content/public/test/test_browser_thread.h" | 29 #include "content/public/test/test_browser_thread.h" |
28 #include "testing/gmock/include/gmock/gmock.h" | 30 #include "testing/gmock/include/gmock/gmock.h" |
29 | 31 |
30 using content::BrowserThread; | 32 using content::BrowserThread; |
31 | 33 |
32 namespace extensions { | 34 namespace extensions { |
33 namespace { | 35 namespace { |
34 | 36 |
35 class ScriptBadgeControllerTest : public TabContentsTestHarness { | 37 class ScriptBadgeControllerTest : public TabContentsTestHarness { |
36 public: | 38 public: |
37 ScriptBadgeControllerTest() | 39 ScriptBadgeControllerTest() |
38 : ui_thread_(BrowserThread::UI, MessageLoop::current()), | 40 : ui_thread_(BrowserThread::UI, MessageLoop::current()), |
39 file_thread_(BrowserThread::FILE, MessageLoop::current()) {} | 41 file_thread_(BrowserThread::FILE, MessageLoop::current()), |
| 42 current_channel_(chrome::VersionInfo::CHANNEL_DEV) {} |
40 | 43 |
41 virtual void SetUp() OVERRIDE { | 44 virtual void SetUp() OVERRIDE { |
42 // Note that this sets a PageActionController into the | 45 // Note that this sets a PageActionController into the |
43 // extension_tab_helper()->location_bar_controller() field. Do | 46 // extension_tab_helper()->location_bar_controller() field. Do |
44 // not use that for testing. | 47 // not use that for testing. |
45 TabContentsTestHarness::SetUp(); | 48 TabContentsTestHarness::SetUp(); |
46 | 49 |
47 TestExtensionSystem* extension_system = | 50 TestExtensionSystem* extension_system = |
48 static_cast<TestExtensionSystem*>(ExtensionSystem::Get( | 51 static_cast<TestExtensionSystem*>(ExtensionSystem::Get( |
49 tab_contents()->profile())); | 52 tab_contents()->profile())); |
(...skipping 26 matching lines...) Expand all Loading... |
76 return extension; | 79 return extension; |
77 } | 80 } |
78 | 81 |
79 ExtensionService* extension_service_; | 82 ExtensionService* extension_service_; |
80 scoped_ptr<ScriptExecutor> script_executor_; | 83 scoped_ptr<ScriptExecutor> script_executor_; |
81 scoped_ptr<ScriptBadgeController> script_badge_controller_; | 84 scoped_ptr<ScriptBadgeController> script_badge_controller_; |
82 | 85 |
83 private: | 86 private: |
84 content::TestBrowserThread ui_thread_; | 87 content::TestBrowserThread ui_thread_; |
85 content::TestBrowserThread file_thread_; | 88 content::TestBrowserThread file_thread_; |
| 89 Feature::ScopedCurrentChannel current_channel_; |
86 }; | 90 }; |
87 | 91 |
88 struct CountingNotificationObserver : public content::NotificationObserver { | 92 struct CountingNotificationObserver : public content::NotificationObserver { |
89 CountingNotificationObserver() : events(0) {} | 93 CountingNotificationObserver() : events(0) {} |
90 | 94 |
91 virtual void Observe(int type, | 95 virtual void Observe(int type, |
92 const content::NotificationSource& source, | 96 const content::NotificationSource& source, |
93 const content::NotificationDetails& details) OVERRIDE { | 97 const content::NotificationDetails& details) OVERRIDE { |
94 events++; | 98 events++; |
95 } | 99 } |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
236 // Getting attention a second time should have no effect. | 240 // Getting attention a second time should have no effect. |
237 script_badge_controller_->GetAttentionFor(extension->id()); | 241 script_badge_controller_->GetAttentionFor(extension->id()); |
238 | 242 |
239 EXPECT_THAT(script_badge_controller_->GetCurrentActions(), | 243 EXPECT_THAT(script_badge_controller_->GetCurrentActions(), |
240 testing::ElementsAre(extension->script_badge())); | 244 testing::ElementsAre(extension->script_badge())); |
241 EXPECT_EQ(0, subsequent_get_attention_call.events); | 245 EXPECT_EQ(0, subsequent_get_attention_call.events); |
242 }; | 246 }; |
243 | 247 |
244 } // namespace | 248 } // namespace |
245 } // namespace extensions | 249 } // namespace extensions |
OLD | NEW |