| 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/files/file_path.h" | 8 #include "base/files/file_path.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
| 11 #include "chrome/browser/extensions/component_loader.h" | 11 #include "chrome/browser/extensions/component_loader.h" |
| 12 #include "chrome/browser/extensions/extension_action.h" | 12 #include "chrome/browser/extensions/extension_action.h" |
| 13 #include "chrome/browser/extensions/extension_action_manager.h" | 13 #include "chrome/browser/extensions/extension_action_manager.h" |
| 14 #include "chrome/browser/extensions/extension_service.h" | 14 #include "chrome/browser/extensions/extension_service.h" |
| 15 #include "chrome/browser/extensions/extension_tab_util.h" | 15 #include "chrome/browser/extensions/extension_tab_util.h" |
| 16 #include "chrome/browser/extensions/script_bubble_controller.h" | 16 #include "chrome/browser/extensions/script_bubble_controller.h" |
| 17 #include "chrome/browser/extensions/test_extension_system.h" | 17 #include "chrome/browser/extensions/test_extension_system.h" |
| 18 #include "chrome/common/extensions/extension.h" | 18 #include "chrome/common/extensions/extension.h" |
| 19 #include "chrome/common/extensions/extension_builder.h" | 19 #include "chrome/common/extensions/extension_builder.h" |
| 20 #include "chrome/common/extensions/feature_switch.h" | 20 #include "chrome/common/extensions/feature_switch.h" |
| 21 #include "chrome/common/extensions/permissions/chrome_api_permissions.h" | |
| 22 #include "chrome/common/extensions/permissions/scoped_testing_permissions_info.h
" | |
| 23 #include "chrome/common/extensions/value_builder.h" | 21 #include "chrome/common/extensions/value_builder.h" |
| 24 #include "chrome/test/base/chrome_render_view_host_test_harness.h" | 22 #include "chrome/test/base/chrome_render_view_host_test_harness.h" |
| 25 #include "chrome/test/base/testing_profile.h" | 23 #include "chrome/test/base/testing_profile.h" |
| 26 #include "content/public/browser/browser_thread.h" | 24 #include "content/public/browser/browser_thread.h" |
| 27 #include "content/public/browser/navigation_entry.h" | 25 #include "content/public/browser/navigation_entry.h" |
| 28 #include "content/public/test/test_browser_thread.h" | 26 #include "content/public/test/test_browser_thread.h" |
| 29 | 27 |
| 30 #if defined(OS_CHROMEOS) | 28 #if defined(OS_CHROMEOS) |
| 31 #include "chrome/browser/chromeos/login/user_manager.h" | 29 #include "chrome/browser/chromeos/login/user_manager.h" |
| 32 #include "chrome/browser/chromeos/settings/cros_settings.h" | 30 #include "chrome/browser/chromeos/settings/cros_settings.h" |
| 33 #include "chrome/browser/chromeos/settings/device_settings_service.h" | 31 #include "chrome/browser/chromeos/settings/device_settings_service.h" |
| 34 #endif | 32 #endif |
| 35 | 33 |
| 36 using content::BrowserThread; | 34 using content::BrowserThread; |
| 37 | 35 |
| 38 namespace extensions { | 36 namespace extensions { |
| 39 namespace { | 37 namespace { |
| 40 | 38 |
| 41 class ScriptBubbleControllerTest : public ChromeRenderViewHostTestHarness { | 39 class ScriptBubbleControllerTest : public ChromeRenderViewHostTestHarness { |
| 42 public: | 40 public: |
| 43 ScriptBubbleControllerTest() | 41 ScriptBubbleControllerTest() |
| 44 : ui_thread_(BrowserThread::UI, MessageLoop::current()), | 42 : ui_thread_(BrowserThread::UI, MessageLoop::current()), |
| 45 file_thread_(BrowserThread::FILE, MessageLoop::current()), | 43 file_thread_(BrowserThread::FILE, MessageLoop::current()), |
| 46 enable_script_bubble_(FeatureSwitch::script_bubble(), true), | 44 enable_script_bubble_(FeatureSwitch::script_bubble(), true) { |
| 47 permissions_info_(ChromeAPIPermissions()) { | |
| 48 } | 45 } |
| 49 | 46 |
| 50 virtual void SetUp() OVERRIDE { | 47 virtual void SetUp() OVERRIDE { |
| 51 ChromeRenderViewHostTestHarness::SetUp(); | 48 ChromeRenderViewHostTestHarness::SetUp(); |
| 52 CommandLine command_line(CommandLine::NO_PROGRAM); | 49 CommandLine command_line(CommandLine::NO_PROGRAM); |
| 53 Profile* profile = | 50 Profile* profile = |
| 54 Profile::FromBrowserContext(web_contents()->GetBrowserContext()); | 51 Profile::FromBrowserContext(web_contents()->GetBrowserContext()); |
| 55 extension_service_ = static_cast<TestExtensionSystem*>( | 52 extension_service_ = static_cast<TestExtensionSystem*>( |
| 56 ExtensionSystem::Get(profile))->CreateExtensionService( | 53 ExtensionSystem::Get(profile))->CreateExtensionService( |
| 57 &command_line, base::FilePath(), false); | 54 &command_line, base::FilePath(), false); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 68 return ExtensionTabUtil::GetTabId(web_contents()); | 65 return ExtensionTabUtil::GetTabId(web_contents()); |
| 69 } | 66 } |
| 70 | 67 |
| 71 ExtensionService* extension_service_; | 68 ExtensionService* extension_service_; |
| 72 ScriptBubbleController* script_bubble_controller_; | 69 ScriptBubbleController* script_bubble_controller_; |
| 73 | 70 |
| 74 private: | 71 private: |
| 75 content::TestBrowserThread ui_thread_; | 72 content::TestBrowserThread ui_thread_; |
| 76 content::TestBrowserThread file_thread_; | 73 content::TestBrowserThread file_thread_; |
| 77 FeatureSwitch::ScopedOverride enable_script_bubble_; | 74 FeatureSwitch::ScopedOverride enable_script_bubble_; |
| 78 ScopedTestingPermissionsInfo permissions_info_; | |
| 79 | 75 |
| 80 #if defined OS_CHROMEOS | 76 #if defined OS_CHROMEOS |
| 81 chromeos::ScopedTestDeviceSettingsService test_device_settings_service_; | 77 chromeos::ScopedTestDeviceSettingsService test_device_settings_service_; |
| 82 chromeos::ScopedTestCrosSettings test_cros_settings_; | 78 chromeos::ScopedTestCrosSettings test_cros_settings_; |
| 83 chromeos::ScopedTestUserManager test_user_manager_; | 79 chromeos::ScopedTestUserManager test_user_manager_; |
| 84 #endif | 80 #endif |
| 85 }; | 81 }; |
| 86 | 82 |
| 87 TEST_F(ScriptBubbleControllerTest, Basics) { | 83 TEST_F(ScriptBubbleControllerTest, Basics) { |
| 88 #if defined(OS_WIN) | 84 #if defined(OS_WIN) |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 185 web_contents(), executing_scripts, 0, GURL()); | 181 web_contents(), executing_scripts, 0, GURL()); |
| 186 EXPECT_EQ(3u, script_bubble_controller_->extensions_running_scripts().size()); | 182 EXPECT_EQ(3u, script_bubble_controller_->extensions_running_scripts().size()); |
| 187 | 183 |
| 188 // Navigating away resets the badge. | 184 // Navigating away resets the badge. |
| 189 NavigateAndCommit(GURL("http://www.google.com")); | 185 NavigateAndCommit(GURL("http://www.google.com")); |
| 190 EXPECT_EQ(0u, script_bubble_controller_->extensions_running_scripts().size()); | 186 EXPECT_EQ(0u, script_bubble_controller_->extensions_running_scripts().size()); |
| 191 }; | 187 }; |
| 192 | 188 |
| 193 } // namespace | 189 } // namespace |
| 194 } // namespace extensions | 190 } // namespace extensions |
| OLD | NEW |