diff options
author | avi@chromium.org <avi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-10-17 21:34:50 +0000 |
---|---|---|
committer | avi@chromium.org <avi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-10-17 21:34:50 +0000 |
commit | 94323102a80f786255342a4e73690b163cbbcb36 (patch) | |
tree | 343e77052c14fad4315d454ceaa2a41b1843d977 /chrome | |
parent | e2a04d0fd207cce42fcfd40dd87fdf0cd98cddaa (diff) | |
download | chromium_src-94323102a80f786255342a4e73690b163cbbcb36.zip chromium_src-94323102a80f786255342a4e73690b163cbbcb36.tar.gz chromium_src-94323102a80f786255342a4e73690b163cbbcb36.tar.bz2 |
Remove TabContents from extension tests.
BUG=107201
TEST=no visible change
Review URL: https://chromiumcodereview.appspot.com/11198015
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@162533 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
4 files changed, 46 insertions, 37 deletions
diff --git a/chrome/browser/extensions/active_tab_unittest.cc b/chrome/browser/extensions/active_tab_unittest.cc index 550327a..49813ca 100644 --- a/chrome/browser/extensions/active_tab_unittest.cc +++ b/chrome/browser/extensions/active_tab_unittest.cc @@ -11,13 +11,12 @@ #include "chrome/browser/extensions/active_tab_permission_granter.h" #include "chrome/browser/extensions/tab_helper.h" #include "chrome/browser/sessions/session_id.h" -#include "chrome/browser/ui/tab_contents/tab_contents.h" -#include "chrome/browser/ui/tab_contents/test_tab_contents.h" #include "chrome/common/chrome_notification_types.h" #include "chrome/common/extensions/extension.h" #include "chrome/common/extensions/extension_builder.h" #include "chrome/common/extensions/features/feature.h" #include "chrome/common/extensions/value_builder.h" +#include "chrome/test/base/chrome_render_view_host_test_harness.h" #include "content/public/browser/browser_thread.h" #include "content/public/browser/navigation_details.h" #include "content/public/browser/navigation_entry.h" @@ -52,7 +51,7 @@ scoped_refptr<const Extension> CreateTestExtension( .Build(); } -class ActiveTabTest : public TabContentsTestHarness { +class ActiveTabTest : public ChromeRenderViewHostTestHarness { public: ActiveTabTest() : current_channel_(chrome::VersionInfo::CHANNEL_DEV), @@ -62,8 +61,13 @@ class ActiveTabTest : public TabContentsTestHarness { ui_thread_(BrowserThread::UI, MessageLoop::current()) {} protected: + virtual void SetUp() OVERRIDE { + ChromeRenderViewHostTestHarness::SetUp(); + TabHelper::CreateForWebContents(web_contents()); + } + int tab_id() { - return SessionID::IdForTab(tab_contents()->web_contents()); + return SessionID::IdForTab(web_contents()); } ActiveTabPermissionGranter* active_tab_permission_granter() { @@ -250,7 +254,8 @@ TEST_F(ActiveTabTest, Uninstalling) { extension_misc::UNLOAD_REASON_DISABLE); content::NotificationService::current()->Notify( chrome::NOTIFICATION_EXTENSION_UNLOADED, - content::Source<Profile>(tab_contents()->profile()), + content::Source<Profile>(Profile::FromBrowserContext( + web_contents()->GetBrowserContext())), content::Details<UnloadedExtensionInfo>(&details)); EXPECT_FALSE(active_tab_permission_granter()->IsGranted(extension)); diff --git a/chrome/browser/extensions/page_action_controller_unittest.cc b/chrome/browser/extensions/page_action_controller_unittest.cc index 72ffbe5..832d659 100644 --- a/chrome/browser/extensions/page_action_controller_unittest.cc +++ b/chrome/browser/extensions/page_action_controller_unittest.cc @@ -11,13 +11,13 @@ #include "chrome/browser/extensions/extension_action_manager.h" #include "chrome/browser/extensions/extension_service.h" #include "chrome/browser/extensions/page_action_controller.h" +#include "chrome/browser/extensions/tab_helper.h" #include "chrome/browser/extensions/test_extension_system.h" #include "chrome/browser/sessions/session_id.h" -#include "chrome/browser/ui/tab_contents/tab_contents.h" -#include "chrome/browser/ui/tab_contents/test_tab_contents.h" #include "chrome/common/extensions/extension.h" #include "chrome/common/extensions/extension_builder.h" #include "chrome/common/extensions/value_builder.h" +#include "chrome/test/base/chrome_render_view_host_test_harness.h" #include "chrome/test/base/testing_profile.h" #include "content/public/browser/browser_thread.h" #include "content/public/test/test_browser_thread.h" @@ -27,21 +27,22 @@ using content::BrowserThread; namespace extensions { namespace { -class PageActionControllerTest : public TabContentsTestHarness { +class PageActionControllerTest : public ChromeRenderViewHostTestHarness { public: PageActionControllerTest() : ui_thread_(BrowserThread::UI, MessageLoop::current()), file_thread_(BrowserThread::FILE, MessageLoop::current()) {} virtual void SetUp() OVERRIDE { - TabContentsTestHarness::SetUp(); + ChromeRenderViewHostTestHarness::SetUp(); + TabHelper::CreateForWebContents(web_contents()); // Create an ExtensionService so the PageActionController can find its // extensions. CommandLine command_line(CommandLine::NO_PROGRAM); - extension_service_ = - static_cast<TestExtensionSystem*>( - ExtensionSystem::Get(tab_contents()->profile()))-> - CreateExtensionService( + Profile* profile = + Profile::FromBrowserContext(web_contents()->GetBrowserContext()); + extension_service_ = static_cast<TestExtensionSystem*>( + ExtensionSystem::Get(profile))->CreateExtensionService( &command_line, FilePath(), false); } diff --git a/chrome/browser/extensions/script_badge_controller_unittest.cc b/chrome/browser/extensions/script_badge_controller_unittest.cc index 1403495..6a6075f 100644 --- a/chrome/browser/extensions/script_badge_controller_unittest.cc +++ b/chrome/browser/extensions/script_badge_controller_unittest.cc @@ -13,8 +13,6 @@ #include "chrome/browser/extensions/script_badge_controller.h" #include "chrome/browser/extensions/tab_helper.h" #include "chrome/browser/extensions/test_extension_system.h" -#include "chrome/browser/ui/tab_contents/tab_contents.h" -#include "chrome/browser/ui/tab_contents/test_tab_contents.h" #include "chrome/common/chrome_notification_types.h" #include "chrome/common/chrome_switches.h" #include "chrome/common/chrome_version_info.h" @@ -23,6 +21,7 @@ #include "chrome/common/extensions/feature_switch.h" #include "chrome/common/extensions/features/feature.h" #include "chrome/common/extensions/value_builder.h" +#include "chrome/test/base/chrome_render_view_host_test_harness.h" #include "chrome/test/base/testing_profile.h" #include "content/public/browser/browser_thread.h" #include "content/public/browser/navigation_entry.h" @@ -37,7 +36,7 @@ using content::BrowserThread; namespace extensions { namespace { -class ScriptBadgeControllerTest : public TabContentsTestHarness { +class ScriptBadgeControllerTest : public ChromeRenderViewHostTestHarness { public: ScriptBadgeControllerTest() : feature_override_(FeatureSwitch::script_badges(), true), @@ -49,11 +48,12 @@ class ScriptBadgeControllerTest : public TabContentsTestHarness { // Note that this sets a PageActionController into the // extensions::TabHelper's location_bar_controller field. Do // not use that for testing. - TabContentsTestHarness::SetUp(); + ChromeRenderViewHostTestHarness::SetUp(); + Profile* profile = + Profile::FromBrowserContext(web_contents()->GetBrowserContext()); TestExtensionSystem* extension_system = - static_cast<TestExtensionSystem*>(ExtensionSystem::Get( - tab_contents()->profile())); + static_cast<TestExtensionSystem*>(ExtensionSystem::Get(profile)); // Create an ExtensionService so the ScriptBadgeController can find its // extensions. @@ -121,10 +121,12 @@ TEST_F(ScriptBadgeControllerTest, ExecutionMakesBadgeVisible) { NavigateAndCommit(GURL("http://www.google.com")); CountingNotificationObserver location_bar_updated; + Profile* profile = + Profile::FromBrowserContext(web_contents()->GetBrowserContext()); notification_registrar.Add( &location_bar_updated, chrome::NOTIFICATION_EXTENSION_LOCATION_BAR_UPDATED, - content::Source<Profile>(tab_contents()->profile())); + content::Source<Profile>(profile)); // Initially, no script badges. EXPECT_THAT(script_badge_controller_->GetCurrentActions(), @@ -134,8 +136,7 @@ TEST_F(ScriptBadgeControllerTest, ExecutionMakesBadgeVisible) { script_badge_controller_->OnExecuteScriptFinished( extension->id(), "", // no error - tab_contents()->web_contents()->GetController().GetActiveEntry()-> - GetPageID(), + web_contents()->GetController().GetActiveEntry()->GetPageID(), GURL(""), val); EXPECT_THAT(script_badge_controller_->GetCurrentActions(), @@ -145,6 +146,8 @@ TEST_F(ScriptBadgeControllerTest, ExecutionMakesBadgeVisible) { TEST_F(ScriptBadgeControllerTest, FragmentNavigation) { scoped_refptr<const Extension> extension = AddTestExtension(); + Profile* profile = + Profile::FromBrowserContext(web_contents()->GetBrowserContext()); // Establish a page id. NavigateAndCommit(GURL("http://www.google.com")); @@ -156,14 +159,13 @@ TEST_F(ScriptBadgeControllerTest, FragmentNavigation) { notification_registrar.Add( &location_bar_updated, chrome::NOTIFICATION_EXTENSION_LOCATION_BAR_UPDATED, - content::Source<Profile>(tab_contents()->profile())); + content::Source<Profile>(profile)); ListValue val; script_badge_controller_->OnExecuteScriptFinished( extension->id(), "", // no error - tab_contents()->web_contents()->GetController().GetActiveEntry()-> - GetPageID(), + web_contents()->GetController().GetActiveEntry()->GetPageID(), GURL(""), val); @@ -179,7 +181,7 @@ TEST_F(ScriptBadgeControllerTest, FragmentNavigation) { notification_registrar.Add( &location_bar_updated, chrome::NOTIFICATION_EXTENSION_LOCATION_BAR_UPDATED, - content::Source<Profile>(tab_contents()->profile())); + content::Source<Profile>(profile)); NavigateAndCommit(GURL("http://www.google.com#hash")); @@ -195,7 +197,7 @@ TEST_F(ScriptBadgeControllerTest, FragmentNavigation) { notification_registrar.Add( &location_bar_updated, chrome::NOTIFICATION_EXTENSION_LOCATION_BAR_UPDATED, - content::Source<Profile>(tab_contents()->profile())); + content::Source<Profile>(profile)); Reload(); @@ -223,10 +225,12 @@ TEST_F(ScriptBadgeControllerTest, GetAttentionMakesBadgeVisible) { NavigateAndCommit(GURL("http://www.google.com")); CountingNotificationObserver initial_badge_display; + Profile* profile = + Profile::FromBrowserContext(web_contents()->GetBrowserContext()); notification_registrar.Add( &initial_badge_display, chrome::NOTIFICATION_EXTENSION_LOCATION_BAR_UPDATED, - content::Source<Profile>(tab_contents()->profile())); + content::Source<Profile>(profile)); // Initially, no script badges. EXPECT_THAT(script_badge_controller_->GetCurrentActions(), @@ -243,7 +247,7 @@ TEST_F(ScriptBadgeControllerTest, GetAttentionMakesBadgeVisible) { notification_registrar.Add( &subsequent_get_attention_call, chrome::NOTIFICATION_EXTENSION_LOCATION_BAR_UPDATED, - content::Source<Profile>(tab_contents()->profile())); + content::Source<Profile>(profile)); // Getting attention a second time should have no effect. script_badge_controller_->GetAttentionFor(extension->id()); diff --git a/chrome/browser/extensions/script_bubble_controller_unittest.cc b/chrome/browser/extensions/script_bubble_controller_unittest.cc index f37ece5..89006be 100644 --- a/chrome/browser/extensions/script_bubble_controller_unittest.cc +++ b/chrome/browser/extensions/script_bubble_controller_unittest.cc @@ -15,12 +15,11 @@ #include "chrome/browser/extensions/extension_tab_util.h" #include "chrome/browser/extensions/script_bubble_controller.h" #include "chrome/browser/extensions/test_extension_system.h" -#include "chrome/browser/ui/tab_contents/tab_contents.h" -#include "chrome/browser/ui/tab_contents/test_tab_contents.h" #include "chrome/common/extensions/extension.h" #include "chrome/common/extensions/extension_builder.h" #include "chrome/common/extensions/feature_switch.h" #include "chrome/common/extensions/value_builder.h" +#include "chrome/test/base/chrome_render_view_host_test_harness.h" #include "chrome/test/base/testing_profile.h" #include "content/public/browser/browser_thread.h" #include "content/public/browser/navigation_entry.h" @@ -31,7 +30,7 @@ using content::BrowserThread; namespace extensions { namespace { -class ScriptBubbleControllerTest : public TabContentsTestHarness { +class ScriptBubbleControllerTest : public ChromeRenderViewHostTestHarness { public: ScriptBubbleControllerTest() : ui_thread_(BrowserThread::UI, MessageLoop::current()), @@ -40,12 +39,12 @@ class ScriptBubbleControllerTest : public TabContentsTestHarness { } virtual void SetUp() OVERRIDE { - TabContentsTestHarness::SetUp(); + ChromeRenderViewHostTestHarness::SetUp(); CommandLine command_line(CommandLine::NO_PROGRAM); - extension_service_ = - static_cast<TestExtensionSystem*>( - ExtensionSystem::Get(tab_contents()->profile()))-> - CreateExtensionService( + Profile* profile = + Profile::FromBrowserContext(web_contents()->GetBrowserContext()); + extension_service_ = static_cast<TestExtensionSystem*>( + ExtensionSystem::Get(profile))->CreateExtensionService( &command_line, FilePath(), false); extension_service_->component_loader()->AddScriptBubble(); extension_service_->Init(); |