| 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" |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 #include "content/public/browser/browser_thread.h" | 24 #include "content/public/browser/browser_thread.h" |
| 25 #include "content/public/browser/navigation_entry.h" | 25 #include "content/public/browser/navigation_entry.h" |
| 26 #include "content/public/test/test_browser_thread.h" | 26 #include "content/public/test/test_browser_thread.h" |
| 27 | 27 |
| 28 #if defined(OS_CHROMEOS) | 28 #if defined(OS_CHROMEOS) |
| 29 #include "chrome/browser/chromeos/login/user_manager.h" | 29 #include "chrome/browser/chromeos/login/user_manager.h" |
| 30 #include "chrome/browser/chromeos/settings/cros_settings.h" | 30 #include "chrome/browser/chromeos/settings/cros_settings.h" |
| 31 #include "chrome/browser/chromeos/settings/device_settings_service.h" | 31 #include "chrome/browser/chromeos/settings/device_settings_service.h" |
| 32 #endif | 32 #endif |
| 33 | 33 |
| 34 using content::BrowserThread; | |
| 35 | |
| 36 namespace extensions { | 34 namespace extensions { |
| 37 namespace { | 35 namespace { |
| 38 | 36 |
| 39 class ScriptBubbleControllerTest : public ChromeRenderViewHostTestHarness { | 37 class ScriptBubbleControllerTest : public ChromeRenderViewHostTestHarness { |
| 40 public: | 38 protected: |
| 41 ScriptBubbleControllerTest() | 39 ScriptBubbleControllerTest() |
| 42 : ui_thread_(BrowserThread::UI, base::MessageLoop::current()), | 40 : enable_script_bubble_(FeatureSwitch::script_bubble(), true) { |
| 43 file_thread_(BrowserThread::FILE, base::MessageLoop::current()), | |
| 44 enable_script_bubble_(FeatureSwitch::script_bubble(), true) { | |
| 45 } | 41 } |
| 46 | 42 |
| 47 virtual void SetUp() OVERRIDE { | 43 virtual void SetUp() OVERRIDE { |
| 48 ChromeRenderViewHostTestHarness::SetUp(); | 44 ChromeRenderViewHostTestHarness::SetUp(); |
| 45 #if defined OS_CHROMEOS |
| 46 test_user_manager_.reset(new chromeos::ScopedTestUserManager()); |
| 47 #endif |
| 49 CommandLine command_line(CommandLine::NO_PROGRAM); | 48 CommandLine command_line(CommandLine::NO_PROGRAM); |
| 50 Profile* profile = | 49 Profile* profile = |
| 51 Profile::FromBrowserContext(web_contents()->GetBrowserContext()); | 50 Profile::FromBrowserContext(web_contents()->GetBrowserContext()); |
| 52 extension_service_ = static_cast<TestExtensionSystem*>( | 51 extension_service_ = static_cast<TestExtensionSystem*>( |
| 53 ExtensionSystem::Get(profile))->CreateExtensionService( | 52 ExtensionSystem::Get(profile))->CreateExtensionService( |
| 54 &command_line, base::FilePath(), false); | 53 &command_line, base::FilePath(), false); |
| 55 extension_service_->Init(); | 54 extension_service_->Init(); |
| 56 | 55 |
| 57 TabHelper::CreateForWebContents(web_contents()); | 56 TabHelper::CreateForWebContents(web_contents()); |
| 58 | 57 |
| 59 script_bubble_controller_ = | 58 script_bubble_controller_ = |
| 60 TabHelper::FromWebContents(web_contents())->script_bubble_controller(); | 59 TabHelper::FromWebContents(web_contents())->script_bubble_controller(); |
| 61 } | 60 } |
| 62 | 61 |
| 63 protected: | 62 virtual void TearDown() OVERRIDE { |
| 63 #if defined OS_CHROMEOS |
| 64 test_user_manager_.reset(); |
| 65 #endif |
| 66 ChromeRenderViewHostTestHarness::TearDown(); |
| 67 } |
| 68 |
| 64 int tab_id() { | 69 int tab_id() { |
| 65 return ExtensionTabUtil::GetTabId(web_contents()); | 70 return ExtensionTabUtil::GetTabId(web_contents()); |
| 66 } | 71 } |
| 67 | 72 |
| 68 ExtensionService* extension_service_; | 73 ExtensionService* extension_service_; |
| 69 ScriptBubbleController* script_bubble_controller_; | 74 ScriptBubbleController* script_bubble_controller_; |
| 70 | 75 |
| 71 private: | 76 private: |
| 72 content::TestBrowserThread ui_thread_; | |
| 73 content::TestBrowserThread file_thread_; | |
| 74 FeatureSwitch::ScopedOverride enable_script_bubble_; | 77 FeatureSwitch::ScopedOverride enable_script_bubble_; |
| 75 | 78 |
| 76 #if defined OS_CHROMEOS | 79 #if defined OS_CHROMEOS |
| 77 chromeos::ScopedTestDeviceSettingsService test_device_settings_service_; | 80 chromeos::ScopedTestDeviceSettingsService test_device_settings_service_; |
| 78 chromeos::ScopedTestCrosSettings test_cros_settings_; | 81 chromeos::ScopedTestCrosSettings test_cros_settings_; |
| 79 chromeos::ScopedTestUserManager test_user_manager_; | 82 scoped_ptr<chromeos::ScopedTestUserManager> test_user_manager_; |
| 80 #endif | 83 #endif |
| 81 }; | 84 }; |
| 82 | 85 |
| 83 TEST_F(ScriptBubbleControllerTest, Basics) { | 86 TEST_F(ScriptBubbleControllerTest, Basics) { |
| 84 #if defined(OS_WIN) | 87 #if defined(OS_WIN) |
| 85 base::FilePath root(FILE_PATH_LITERAL("c:\\")); | 88 base::FilePath root(FILE_PATH_LITERAL("c:\\")); |
| 86 #else | 89 #else |
| 87 base::FilePath root(FILE_PATH_LITERAL("/root")); | 90 base::FilePath root(FILE_PATH_LITERAL("/root")); |
| 88 #endif | 91 #endif |
| 89 scoped_refptr<const Extension> extension1 = | 92 scoped_refptr<const Extension> extension1 = |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 web_contents(), executing_scripts, 0, GURL()); | 184 web_contents(), executing_scripts, 0, GURL()); |
| 182 EXPECT_EQ(3u, script_bubble_controller_->extensions_running_scripts().size()); | 185 EXPECT_EQ(3u, script_bubble_controller_->extensions_running_scripts().size()); |
| 183 | 186 |
| 184 // Navigating away resets the badge. | 187 // Navigating away resets the badge. |
| 185 NavigateAndCommit(GURL("http://www.google.com")); | 188 NavigateAndCommit(GURL("http://www.google.com")); |
| 186 EXPECT_EQ(0u, script_bubble_controller_->extensions_running_scripts().size()); | 189 EXPECT_EQ(0u, script_bubble_controller_->extensions_running_scripts().size()); |
| 187 }; | 190 }; |
| 188 | 191 |
| 189 } // namespace | 192 } // namespace |
| 190 } // namespace extensions | 193 } // namespace extensions |
| OLD | NEW |