diff options
author | joi@chromium.org <joi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-03-22 13:04:48 +0000 |
---|---|---|
committer | joi@chromium.org <joi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-03-22 13:04:48 +0000 |
commit | 46a32b92e76b665e79bc3ee3b309766a47dbcf9d (patch) | |
tree | ef7bab9dc47d5a2473ac07f3998357b08106fd73 /chrome | |
parent | 2e0a8e5d4e235bac3a687e289de5bdfb6399a1e9 (diff) | |
download | chromium_src-46a32b92e76b665e79bc3ee3b309766a47dbcf9d.zip chromium_src-46a32b92e76b665e79bc3ee3b309766a47dbcf9d.tar.gz chromium_src-46a32b92e76b665e79bc3ee3b309766a47dbcf9d.tar.bz2 |
Add abstractions that let embedders drive tests of WebContents, without exposing the internals of content/.
A separate WebContentsTester interface is used. For reasons this approach was chosen, see comments on the interface.
As part of this work, removed a bunch of references to TabContents from Chrome, some of which were true usages (leaked to Chrome via the test_tab_contents.h header), others of which were just forward declarations and never used. Also removed a chunk of code from autofill_manager.cc that isn't called from anywhere that referenced TabContents.
TBR=ben@chromium.org
BUG=98716
Review URL: https://chromiumcodereview.appspot.com/9706012
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@128198 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
70 files changed, 187 insertions, 270 deletions
diff --git a/chrome/browser/autocomplete_history_manager_unittest.cc b/chrome/browser/autocomplete_history_manager_unittest.cc index d49f03d..6cd211a 100644 --- a/chrome/browser/autocomplete_history_manager_unittest.cc +++ b/chrome/browser/autocomplete_history_manager_unittest.cc @@ -14,7 +14,6 @@ #include "chrome/test/base/chrome_render_view_host_test_harness.h" #include "chrome/test/base/testing_browser_process.h" #include "chrome/test/base/testing_profile.h" -#include "content/browser/tab_contents/test_tab_contents.h" #include "content/test/test_browser_thread.h" #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h" diff --git a/chrome/browser/autofill/autofill_manager.cc b/chrome/browser/autofill/autofill_manager.cc index 00f311a..5a5ff2f 100644 --- a/chrome/browser/autofill/autofill_manager.cc +++ b/chrome/browser/autofill/autofill_manager.cc @@ -168,82 +168,6 @@ void DeterminePossibleFieldTypesForUpload( } } -// Check for unidentified forms among those with the most query or upload -// requests. If found, present an infobar prompting the user to send Google -// Feedback identifying these forms. Only executes if the appropriate flag is -// set in about:flags. -const char* kPopularFormSignatures[] = { - "10135289994685082173", - "7883844738557049416", - "14651966297402649464", - "17177862793067325164", - "15222964025577790589", - "14138834153984647462", - "1522221299769735301", - "8604254969743383026", - "1080809576396139601", - "10591138561307360539", - "3483444043750493124", - "3764098888295731941", - "957190629194980629", - "11314948061179499915", - "2226179674176240706", - "9886974103926218264", - "16089161644523512553", - "17395441333004474813", - "7131540066857838464", - "1799736626243038725", - "4314535457620699296", - "16597101416150066076", - "11571064402466920341", - "17529644200058912705", - "17442663271235869548", - "10423886468225016833", - "8205718441232482003", - "12566467866837059201", - "14998753650075003914", - "8463873542596795823", - "3341181348270175432", - "12047213380448477438", - "7626117232464424739", - "6755316823149690927", - "17343480863386343671", - "4345267765838738360" -}; - -void CheckForPopularForms(const std::vector<FormStructure*>& forms, - TabContentsWrapper* tab_contents_wrapper, - TabContents* tab_contents) { - if (!CommandLine::ForCurrentProcess()->HasSwitch(kEnableAutofillFeedback)) - return; - - for (std::vector<FormStructure*>::const_iterator it = forms.begin(); - it != forms.end(); - ++it) { - std::string form_signature = (*it)->FormSignature(); - for (size_t i = 0; i < arraysize(kPopularFormSignatures); ++i) { - if (form_signature != kPopularFormSignatures[i]) - continue; - - string16 text = - l10n_util::GetStringUTF16(IDS_AUTOFILL_FEEDBACK_INFOBAR_TEXT); - string16 link = - l10n_util::GetStringUTF16(IDS_AUTOFILL_FEEDBACK_INFOBAR_LINK_TEXT); - std::string message = - l10n_util::GetStringFUTF8(IDS_AUTOFILL_FEEDBACK_POPULAR_FORM_MESSAGE, - ASCIIToUTF16(form_signature), - UTF8ToUTF16((*it)->source_url().spec())); - - InfoBarTabHelper* infobar_helper = - tab_contents_wrapper->infobar_tab_helper(); - infobar_helper->AddInfoBar( - new AutofillFeedbackInfoBarDelegate(infobar_helper, text, link, - message)); - break; - } - } -} - } // namespace AutofillManager::AutofillManager(TabContentsWrapper* tab_contents) diff --git a/chrome/browser/autofill/autofill_manager_unittest.cc b/chrome/browser/autofill/autofill_manager_unittest.cc index 2938428..a50cff2 100644 --- a/chrome/browser/autofill/autofill_manager_unittest.cc +++ b/chrome/browser/autofill/autofill_manager_unittest.cc @@ -30,7 +30,7 @@ #include "chrome/common/chrome_switches.h" #include "chrome/common/pref_names.h" #include "chrome/test/base/testing_profile.h" -#include "content/browser/tab_contents/test_tab_contents.h" +#include "content/public/browser/web_contents.h" #include "content/test/mock_render_process_host.h" #include "content/test/test_browser_thread.h" #include "googleurl/src/gurl.h" @@ -44,6 +44,7 @@ #include "webkit/forms/form_field.h" using content::BrowserThread; +using content::WebContents; using testing::_; using webkit::forms::FormData; using webkit::forms::FormField; @@ -2916,7 +2917,7 @@ TEST_F(AutofillManagerTest, TestTabContentsWithExternalDelegate) { switches::kExternalAutofillPopup); // Setting the contents creates a new TabContentsWrapper. - TestTabContents* contents = CreateTestTabContents(); + WebContents* contents = CreateTestWebContents(); SetContents(contents); AutofillManager* autofill_manager = contents_wrapper()->autofill_manager(); diff --git a/chrome/browser/autofill/autofill_metrics_unittest.cc b/chrome/browser/autofill/autofill_metrics_unittest.cc index ba2a6ae..df71b84 100644 --- a/chrome/browser/autofill/autofill_metrics_unittest.cc +++ b/chrome/browser/autofill/autofill_metrics_unittest.cc @@ -18,7 +18,6 @@ #include "chrome/browser/ui/tab_contents/test_tab_contents_wrapper.h" #include "chrome/browser/webdata/web_data_service.h" #include "chrome/test/base/testing_profile.h" -#include "content/browser/tab_contents/test_tab_contents.h" #include "content/test/test_browser_thread.h" #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h" diff --git a/chrome/browser/automation/automation_provider.h b/chrome/browser/automation/automation_provider.h index 21b4557..3b16e45 100644 --- a/chrome/browser/automation/automation_provider.h +++ b/chrome/browser/automation/automation_provider.h @@ -53,7 +53,6 @@ class LoginHandler; class MetricEventDurationObserver; class NavigationControllerRestoredObserver; class Profile; -class TabContents; struct AutomationMsg_Find_Params; struct Reposition_Params; struct ExternalTabSettings; diff --git a/chrome/browser/automation/automation_provider_observers.h b/chrome/browser/automation/automation_provider_observers.h index 879bfdb..e2ea69c 100644 --- a/chrome/browser/automation/automation_provider_observers.h +++ b/chrome/browser/automation/automation_provider_observers.h @@ -64,7 +64,6 @@ class InfoBarTabHelper; class Notification; class Profile; class SavePackage; -class TabContents; class TranslateInfoBarDelegate; #if defined(OS_CHROMEOS) diff --git a/chrome/browser/automation/automation_tab_helper_unittest.cc b/chrome/browser/automation/automation_tab_helper_unittest.cc index b766f02..f75a5cb 100644 --- a/chrome/browser/automation/automation_tab_helper_unittest.cc +++ b/chrome/browser/automation/automation_tab_helper_unittest.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -9,7 +9,6 @@ #include "chrome/browser/automation/mock_tab_event_observer.h" #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" #include "chrome/browser/ui/tab_contents/test_tab_contents_wrapper.h" -#include "content/browser/tab_contents/test_tab_contents.h" #include "content/test/test_browser_thread.h" #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h" diff --git a/chrome/browser/background/background_contents_service.h b/chrome/browser/background/background_contents_service.h index 457d0ab..10b7677 100644 --- a/chrome/browser/background/background_contents_service.h +++ b/chrome/browser/background/background_contents_service.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -23,7 +23,6 @@ class CommandLine; class PrefService; class Profile; -class TabContents; namespace base { class DictionaryValue; diff --git a/chrome/browser/bookmarks/bookmark_utils.h b/chrome/browser/bookmarks/bookmark_utils.h index 97f83f5..ac8af5f 100644 --- a/chrome/browser/bookmarks/bookmark_utils.h +++ b/chrome/browser/bookmarks/bookmark_utils.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -21,7 +21,6 @@ class BookmarkNode; class Browser; class PrefService; class Profile; -class TabContents; namespace content { class PageNavigator; diff --git a/chrome/browser/chromeos/offline/offline_load_page_unittest.cc b/chrome/browser/chromeos/offline/offline_load_page_unittest.cc index b307cd1..32d275e 100644 --- a/chrome/browser/chromeos/offline/offline_load_page_unittest.cc +++ b/chrome/browser/chromeos/offline/offline_load_page_unittest.cc @@ -5,12 +5,16 @@ #include "chrome/browser/chromeos/cros/cros_library.h" #include "chrome/browser/chromeos/offline/offline_load_page.h" #include "chrome/test/base/chrome_render_view_host_test_harness.h" -#include "content/browser/tab_contents/test_tab_contents.h" #include "content/public/browser/interstitial_page.h" +#include "content/public/browser/navigation_controller.h" +#include "content/public/browser/web_contents.h" #include "content/test/test_browser_thread.h" +#include "content/test/web_contents_tester.h" using content::BrowserThread; using content::InterstitialPage; +using content::WebContents; +using content::WebContentsTester; static const char* kURL1 = "http://www.google.com/"; static const char* kURL2 = "http://www.gmail.com/"; @@ -22,10 +26,10 @@ class OfflineLoadPageTest; // An OfflineLoadPage class that does not create windows. class TestOfflineLoadPage : public chromeos::OfflineLoadPage { public: - TestOfflineLoadPage(TabContents* tab_contents, + TestOfflineLoadPage(WebContents* web_contents, const GURL& url, OfflineLoadPageTest* test_page) - : chromeos::OfflineLoadPage(tab_contents, url, CompletionCallback()), + : chromeos::OfflineLoadPage(web_contents, url, CompletionCallback()), test_page_(test_page) { interstitial_page_->DontCreateViewForTesting(); } @@ -68,7 +72,7 @@ class OfflineLoadPageTest : public ChromeRenderViewHostTestHarness { } void Navigate(const char* url, int page_id) { - contents()->TestDidNavigate( + WebContentsTester::For(contents())->TestDidNavigate( contents()->GetRenderViewHost(), page_id, GURL(url), content::PAGE_TRANSITION_TYPED); } diff --git a/chrome/browser/content_settings/tab_specific_content_settings_unittest.cc b/chrome/browser/content_settings/tab_specific_content_settings_unittest.cc index 283857d..3c693c5 100644 --- a/chrome/browser/content_settings/tab_specific_content_settings_unittest.cc +++ b/chrome/browser/content_settings/tab_specific_content_settings_unittest.cc @@ -5,7 +5,6 @@ #include "chrome/browser/content_settings/tab_specific_content_settings.h" #include "chrome/test/base/chrome_render_view_host_test_harness.h" #include "chrome/test/base/testing_profile.h" -#include "content/browser/tab_contents/test_tab_contents.h" #include "content/test/test_browser_thread.h" #include "net/cookies/cookie_monster.h" #include "testing/gtest/include/gtest/gtest.h" diff --git a/chrome/browser/download/download_request_limiter_unittest.cc b/chrome/browser/download/download_request_limiter_unittest.cc index 65d49c0..0bbbf40d 100644 --- a/chrome/browser/download/download_request_limiter_unittest.cc +++ b/chrome/browser/download/download_request_limiter_unittest.cc @@ -6,7 +6,6 @@ #include "chrome/browser/download/download_request_limiter.h" #include "chrome/browser/ui/tab_contents/test_tab_contents_wrapper.h" #include "chrome/test/base/testing_profile.h" -#include "content/browser/tab_contents/test_tab_contents.h" #include "content/public/browser/navigation_controller.h" #include "content/test/test_browser_thread.h" #include "testing/gtest/include/gtest/gtest.h" diff --git a/chrome/browser/extensions/extension_tab_util.h b/chrome/browser/extensions/extension_tab_util.h index ed11e2c..20b9a7d 100644 --- a/chrome/browser/extensions/extension_tab_util.h +++ b/chrome/browser/extensions/extension_tab_util.h @@ -12,7 +12,6 @@ class Browser; class Extension; class GURL; class Profile; -class TabContents; class TabContentsWrapper; class TabStripModel; diff --git a/chrome/browser/extensions/extension_webnavigation_unittest.cc b/chrome/browser/extensions/extension_webnavigation_unittest.cc index fbcd2ce..8747c95 100644 --- a/chrome/browser/extensions/extension_webnavigation_unittest.cc +++ b/chrome/browser/extensions/extension_webnavigation_unittest.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -9,7 +9,6 @@ #include "chrome/browser/extensions/extension_webnavigation_api.h" #include "chrome/test/base/chrome_render_view_host_test_harness.h" #include "chrome/test/base/testing_profile.h" -#include "content/browser/tab_contents/test_tab_contents.h" #include "testing/gtest/include/gtest/gtest.h" diff --git a/chrome/browser/external_tab_container_win.h b/chrome/browser/external_tab_container_win.h index 114b179..7f76a28 100644 --- a/chrome/browser/external_tab_container_win.h +++ b/chrome/browser/external_tab_container_win.h @@ -391,7 +391,7 @@ class TemporaryPopupExternalTabContainer : public ExternalTabContainer { NOTREACHED(); } - virtual void CloseContents(TabContents* source) { + virtual void CloseContents(content::WebContents* source) { NOTREACHED(); } diff --git a/chrome/browser/favicon/favicon_handler.h b/chrome/browser/favicon/favicon_handler.h index 6f93fb6..b892f06 100644 --- a/chrome/browser/favicon/favicon_handler.h +++ b/chrome/browser/favicon/favicon_handler.h @@ -24,7 +24,6 @@ class FaviconHandlerDelegate; class Profile; class RefCountedMemory; class SkBitmap; -class TabContents; namespace content { class NavigationEntry; diff --git a/chrome/browser/favicon/favicon_handler_unittest.cc b/chrome/browser/favicon/favicon_handler_unittest.cc index 745b77a..d595c75 100644 --- a/chrome/browser/favicon/favicon_handler_unittest.cc +++ b/chrome/browser/favicon/favicon_handler_unittest.cc @@ -6,10 +6,10 @@ #include "chrome/browser/favicon/favicon_handler.h" #include "chrome/browser/profiles/profile.h" #include "chrome/test/base/chrome_render_view_host_test_harness.h" -#include "content/browser/tab_contents/test_tab_contents.h" #include "content/public/browser/invalidate_type.h" #include "content/public/browser/navigation_entry.h" #include "content/public/browser/favicon_status.h" +#include "content/public/browser/web_contents.h" #include "ui/gfx/codec/png_codec.h" #include "ui/gfx/favicon_size.h" #include "ui/gfx/image/image.h" @@ -17,6 +17,7 @@ class TestFaviconHandler; using content::NavigationEntry; +using content::WebContents; namespace { @@ -141,7 +142,7 @@ class HistoryRequestHandler { // of subclassing. class TestFaviconHandlerDelegate : public FaviconHandlerDelegate { public: - explicit TestFaviconHandlerDelegate(TabContents* tab_contents) + explicit TestFaviconHandlerDelegate(WebContents* tab_contents) : tab_contents_(tab_contents) { } @@ -161,7 +162,7 @@ class TestFaviconHandlerDelegate : public FaviconHandlerDelegate { } private: - TabContents* tab_contents_; // weak + WebContents* tab_contents_; // weak }; // This class is used to catch the FaviconHandler's download and history diff --git a/chrome/browser/geolocation/chrome_geolocation_permission_context_unittest.cc b/chrome/browser/geolocation/chrome_geolocation_permission_context_unittest.cc index dfa3cd3..628a8f7 100644 --- a/chrome/browser/geolocation/chrome_geolocation_permission_context_unittest.cc +++ b/chrome/browser/geolocation/chrome_geolocation_permission_context_unittest.cc @@ -19,20 +19,22 @@ #include "chrome/browser/ui/tab_contents/test_tab_contents_wrapper.h" #include "chrome/common/chrome_notification_types.h" #include "chrome/test/base/testing_profile.h" -#include "content/browser/tab_contents/test_tab_contents.h" #include "content/public/browser/navigation_details.h" #include "content/public/browser/notification_registrar.h" #include "content/public/browser/notification_service.h" +#include "content/public/browser/web_contents.h" #include "content/test/mock_geolocation.h" #include "content/test/mock_render_process_host.h" #include "content/test/test_browser_thread.h" #include "content/test/test_renderer_host.h" +#include "content/test/web_contents_tester.h" #include "testing/gtest/include/gtest/gtest.h" using content::BrowserThread; using content::MockRenderProcessHost; using content::RenderViewHostTester; using content::WebContents; +using content::WebContentsTester; // ClosedDelegateTracker ------------------------------------------------------ @@ -590,7 +592,7 @@ TEST_F(GeolocationPermissionContextTests, InfoBarUsesCommittedEntry) { details.entry = contents()->GetController().GetLastCommittedEntry(); ASSERT_FALSE(infobar_0->ShouldExpire(details)); // Commit the "GoBack()" above, and ensure the infobar is now expired. - contents()->CommitPendingNavigation(); + WebContentsTester::For(contents())->CommitPendingNavigation(); details.entry = contents()->GetController().GetLastCommittedEntry(); ASSERT_TRUE(infobar_0->ShouldExpire(details)); diff --git a/chrome/browser/instant/instant_controller.h b/chrome/browser/instant/instant_controller.h index 8526065..767e361 100644 --- a/chrome/browser/instant/instant_controller.h +++ b/chrome/browser/instant/instant_controller.h @@ -29,7 +29,6 @@ class InstantLoader; class InstantTest; class PrefService; class Profile; -class TabContents; class TabContentsWrapper; class TemplateURL; class TemplateURLService; diff --git a/chrome/browser/instant/instant_loader.h b/chrome/browser/instant/instant_loader.h index 05ed6de..e5a8019 100644 --- a/chrome/browser/instant/instant_loader.h +++ b/chrome/browser/instant/instant_loader.h @@ -24,7 +24,6 @@ class InstantLoaderDelegate; class InstantLoaderManagerTest; -class TabContents; class TabContentsWrapper; class TemplateURL; diff --git a/chrome/browser/intents/register_intent_handler_infobar_delegate_unittest.cc b/chrome/browser/intents/register_intent_handler_infobar_delegate_unittest.cc index 2743a28..559a09e 100644 --- a/chrome/browser/intents/register_intent_handler_infobar_delegate_unittest.cc +++ b/chrome/browser/intents/register_intent_handler_infobar_delegate_unittest.cc @@ -9,7 +9,6 @@ #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" #include "chrome/browser/ui/tab_contents/test_tab_contents_wrapper.h" #include "chrome/test/base/testing_profile.h" -#include "content/browser/tab_contents/test_tab_contents.h" #include "content/test/test_browser_thread.h" #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h" diff --git a/chrome/browser/notifications/desktop_notification_service.h b/chrome/browser/notifications/desktop_notification_service.h index e41b192..b56d118 100644 --- a/chrome/browser/notifications/desktop_notification_service.h +++ b/chrome/browser/notifications/desktop_notification_service.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -26,7 +26,6 @@ class ContentSettingsPattern; class Notification; class NotificationUIManager; class Profile; -class TabContents; namespace content { class WebContents; diff --git a/chrome/browser/oom_priority_manager.h b/chrome/browser/oom_priority_manager.h index 6ab588b..87ff7db 100644 --- a/chrome/browser/oom_priority_manager.h +++ b/chrome/browser/oom_priority_manager.h @@ -20,8 +20,6 @@ #include "content/public/browser/notification_observer.h" #include "content/public/browser/notification_registrar.h" -class TabContents; - namespace browser { class LowMemoryObserver; diff --git a/chrome/browser/password_manager/password_manager_unittest.cc b/chrome/browser/password_manager/password_manager_unittest.cc index 72aa4fa2..5056080 100644 --- a/chrome/browser/password_manager/password_manager_unittest.cc +++ b/chrome/browser/password_manager/password_manager_unittest.cc @@ -15,7 +15,6 @@ #include "chrome/common/url_constants.h" #include "chrome/test/base/chrome_render_view_host_test_harness.h" #include "chrome/test/base/testing_profile.h" -#include "content/browser/tab_contents/test_tab_contents.h" #include "content/public/browser/navigation_details.h" #include "content/public/common/frame_navigate_params.h" #include "content/test/test_browser_thread.h" diff --git a/chrome/browser/prefs/pref_service_unittest.cc b/chrome/browser/prefs/pref_service_unittest.cc index 95d8f46..9f99922 100644 --- a/chrome/browser/prefs/pref_service_unittest.cc +++ b/chrome/browser/prefs/pref_service_unittest.cc @@ -23,13 +23,15 @@ #include "chrome/test/base/chrome_render_view_host_test_harness.h" #include "chrome/test/base/testing_pref_service.h" #include "chrome/test/base/testing_profile.h" -#include "content/browser/tab_contents/test_tab_contents.h" #include "content/test/test_browser_thread.h" +#include "content/test/web_contents_tester.h" #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h" #include "ui/base/test/data/resource.h" +#include "webkit/glue/webpreferences.h" using content::BrowserThread; +using content::WebContentsTester; using testing::_; using testing::Mock; @@ -304,7 +306,8 @@ class PrefServiceWebKitPrefs : public ChromeRenderViewHostTestHarness { // Tests to see that webkit preferences are properly loaded and copied over // to a WebPreferences object. TEST_F(PrefServiceWebKitPrefs, PrefsCopied) { - WebPreferences webkit_prefs = contents()->TestGetWebkitPrefs(); + WebPreferences webkit_prefs = + WebContentsTester::For(contents())->TestGetWebkitPrefs(); // These values have been overridden by the profile preferences. EXPECT_EQ("UTF-8", webkit_prefs.default_encoding); diff --git a/chrome/browser/prerender/prerender_manager.h b/chrome/browser/prerender/prerender_manager.h index fa0d320..07f300f 100644 --- a/chrome/browser/prerender/prerender_manager.h +++ b/chrome/browser/prerender/prerender_manager.h @@ -25,7 +25,6 @@ #include "googleurl/src/gurl.h" class Profile; -class TabContents; namespace base { class DictionaryValue; diff --git a/chrome/browser/safe_browsing/browser_feature_extractor_unittest.cc b/chrome/browser/safe_browsing/browser_feature_extractor_unittest.cc index 1a0bad6..e8d0b99 100644 --- a/chrome/browser/safe_browsing/browser_feature_extractor_unittest.cc +++ b/chrome/browser/safe_browsing/browser_feature_extractor_unittest.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -20,10 +20,12 @@ #include "chrome/common/safe_browsing/csd.pb.h" #include "chrome/test/base/chrome_render_view_host_test_harness.h" #include "chrome/test/base/testing_profile.h" -#include "content/browser/tab_contents/test_tab_contents.h" +#include "content/public/browser/web_contents.h" #include "content/public/common/page_transition_types.h" #include "content/public/common/referrer.h" +#include "content/public/browser/navigation_controller.h" #include "content/test/test_browser_thread.h" +#include "content/test/web_contents_tester.h" #include "googleurl/src/gurl.h" #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h" @@ -31,6 +33,7 @@ using ::testing::Return; using ::testing::StrictMock; using content::BrowserThread; +using content::WebContentsTester; namespace safe_browsing { namespace { @@ -96,12 +99,13 @@ class BrowserFeatureExtractorTest : public ChromeRenderViewHostTestHarness { type, std::string()); static int page_id = 0; - content::RenderViewHost* rvh = contents()->pending_rvh(); + content::RenderViewHost* rvh = + WebContentsTester::For(contents())->pending_rvh(); if (!rvh) { rvh = contents()->GetRenderViewHost(); } - contents()->ProceedWithCrossSiteNavigation(); - contents()->TestDidNavigateWithReferrer( + WebContentsTester::For(contents())->ProceedWithCrossSiteNavigation(); + WebContentsTester::For(contents())->TestDidNavigateWithReferrer( rvh, ++page_id, url, content::Referrer(referrer, WebKit::WebReferrerPolicyDefault), type); } diff --git a/chrome/browser/safe_browsing/client_side_detection_host_unittest.cc b/chrome/browser/safe_browsing/client_side_detection_host_unittest.cc index 6fd68cc..5630528 100644 --- a/chrome/browser/safe_browsing/client_side_detection_host_unittest.cc +++ b/chrome/browser/safe_browsing/client_side_detection_host_unittest.cc @@ -16,7 +16,7 @@ #include "chrome/common/safe_browsing/csd.pb.h" #include "chrome/common/safe_browsing/safebrowsing_messages.h" #include "chrome/test/base/testing_profile.h" -#include "content/browser/tab_contents/test_tab_contents.h" +#include "content/public/browser/web_contents.h" #include "content/test/mock_render_process_host.h" #include "content/test/test_browser_thread.h" #include "content/test/test_renderer_host.h" @@ -40,6 +40,7 @@ using ::testing::SetArgumentPointee; using ::testing::StrictMock; using content::BrowserThread; using content::RenderViewHostTester; +using content::WebContents; namespace { const bool kFalse = false; @@ -131,7 +132,7 @@ class MockTestingProfile : public TestingProfile { class MockBrowserFeatureExtractor : public BrowserFeatureExtractor { public: explicit MockBrowserFeatureExtractor( - TabContents* tab, + WebContents* tab, ClientSideDetectionService* service) : BrowserFeatureExtractor(tab, service) {} virtual ~MockBrowserFeatureExtractor() {} diff --git a/chrome/browser/safe_browsing/malware_details_unittest.cc b/chrome/browser/safe_browsing/malware_details_unittest.cc index 5530af1..4e3593e 100644 --- a/chrome/browser/safe_browsing/malware_details_unittest.cc +++ b/chrome/browser/safe_browsing/malware_details_unittest.cc @@ -17,9 +17,11 @@ #include "chrome/common/safe_browsing/safebrowsing_messages.h" #include "chrome/test/base/chrome_render_view_host_test_harness.h" #include "chrome/test/base/testing_profile.h" -#include "content/browser/tab_contents/test_tab_contents.h" +#include "content/public/browser/render_process_host.h" +#include "content/public/browser/web_contents.h" #include "content/test/test_browser_thread.h" #include "net/base/io_buffer.h" +#include "net/base/net_errors.h" #include "net/base/test_completion_callback.h" #include "net/disk_cache/disk_cache.h" #include "net/http/http_cache.h" @@ -51,6 +53,7 @@ static const char* kLandingHeaders = static const char* kLandingData = "<iframe src='http://www.malware.com'>"; using content::BrowserThread; +using content::WebContents; using safe_browsing::ClientMalwareReportRequest; namespace { @@ -128,10 +131,10 @@ void QuitUIMessageLoop() { class MalwareDetailsWrap : public MalwareDetails { public: MalwareDetailsWrap(SafeBrowsingService* sb_service, - TabContents* tab_contents, + WebContents* web_contents, const SafeBrowsingService::UnsafeResource& unsafe_resource, net::URLRequestContextGetter* request_context_getter) - : MalwareDetails(sb_service, tab_contents, unsafe_resource) { + : MalwareDetails(sb_service, web_contents, unsafe_resource) { request_context_getter_ = request_context_getter; } diff --git a/chrome/browser/safe_browsing/safe_browsing_blocking_page_unittest.cc b/chrome/browser/safe_browsing/safe_browsing_blocking_page_unittest.cc index 07c5003..581358d 100644 --- a/chrome/browser/safe_browsing/safe_browsing_blocking_page_unittest.cc +++ b/chrome/browser/safe_browsing/safe_browsing_blocking_page_unittest.cc @@ -8,15 +8,19 @@ #include "chrome/browser/safe_browsing/safe_browsing_blocking_page.h" #include "chrome/common/pref_names.h" #include "chrome/test/base/chrome_render_view_host_test_harness.h" -#include "content/browser/tab_contents/test_tab_contents.h" #include "content/public/browser/interstitial_page.h" #include "content/public/browser/navigation_entry.h" +#include "content/public/browser/render_process_host.h" +#include "content/public/browser/web_contents.h" +#include "content/public/browser/web_contents_view.h" #include "content/test/test_browser_thread.h" +#include "content/test/web_contents_tester.h" using content::BrowserThread; using content::InterstitialPage; using content::NavigationEntry; using content::WebContents; +using content::WebContentsTester; using content::WebContentsView; static const char* kGoogleURL = "http://www.google.com/"; @@ -110,7 +114,7 @@ class SafeBrowsingBlockingPageTest : public ChromeRenderViewHostTestHarness { } void Navigate(const char* url, int page_id) { - contents()->TestDidNavigate( + WebContentsTester::For(contents())->TestDidNavigate( contents()->GetRenderViewHost(), page_id, GURL(url), content::PAGE_TRANSITION_TYPED); } @@ -122,10 +126,13 @@ class SafeBrowsingBlockingPageTest : public ChromeRenderViewHostTestHarness { // The pending RVH should commit for cross-site navigations. content::RenderViewHost* rvh = is_cross_site ? - contents()->pending_rvh() : + WebContentsTester::For(contents())->pending_rvh() : contents()->GetRenderViewHost(); - contents()->TestDidNavigate(rvh, entry->GetPageID(), GURL(entry->GetURL()), - content::PAGE_TRANSITION_TYPED); + WebContentsTester::For(contents())->TestDidNavigate( + rvh, + entry->GetPageID(), + GURL(entry->GetURL()), + content::PAGE_TRANSITION_TYPED); } void ShowInterstitial(bool is_subresource, const char* url) { diff --git a/chrome/browser/sessions/tab_restore_service_browsertest.cc b/chrome/browser/sessions/tab_restore_service_browsertest.cc index cccf9ee..104e7eb 100644 --- a/chrome/browser/sessions/tab_restore_service_browsertest.cc +++ b/chrome/browser/sessions/tab_restore_service_browsertest.cc @@ -17,17 +17,18 @@ #include "chrome/test/base/in_process_browser_test.h" #include "chrome/test/base/testing_profile.h" #include "chrome/test/base/ui_test_utils.h" -#include "content/browser/tab_contents/test_tab_contents.h" #include "content/public/browser/navigation_controller.h" #include "content/public/browser/navigation_entry.h" #include "content/public/browser/notification_service.h" #include "content/public/browser/notification_types.h" #include "content/test/render_view_test.h" +#include "content/test/web_contents_tester.h" #include "testing/gtest/include/gtest/gtest.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebKit.h" typedef TabRestoreService::Tab Tab; typedef TabRestoreService::Window Window; +using content::WebContentsTester; using content::NavigationEntry; @@ -86,7 +87,7 @@ class TabRestoreServiceTest : public ChromeRenderViewHostTestHarness { // Navigate back. We have to do this song and dance as NavigationController // isn't happy if you navigate immediately while going back. controller().GoToIndex(index); - contents()->CommitPendingNavigation(); + WebContentsTester::For(contents())->CommitPendingNavigation(); } void RecreateService() { diff --git a/chrome/browser/tabs/tab_strip_model.h b/chrome/browser/tabs/tab_strip_model.h index 68e9f05..1943d82 100644 --- a/chrome/browser/tabs/tab_strip_model.h +++ b/chrome/browser/tabs/tab_strip_model.h @@ -16,7 +16,6 @@ #include "content/public/common/page_transition_types.h" class Profile; -class TabContents; class TabContentsWrapper; class TabStripModelDelegate; class TabStripModelOrderController; diff --git a/chrome/browser/tabs/tab_strip_model_delegate.h b/chrome/browser/tabs/tab_strip_model_delegate.h index 0f552fd..6415440 100644 --- a/chrome/browser/tabs/tab_strip_model_delegate.h +++ b/chrome/browser/tabs/tab_strip_model_delegate.h @@ -14,7 +14,6 @@ class Browser; class DockInfo; class GURL; class Profile; -class TabContents; class TabContentsWrapper; namespace content { class SiteInstance; diff --git a/chrome/browser/translate/translate_manager_browsertest.cc b/chrome/browser/translate/translate_manager_browsertest.cc index 578cf82..8e3ce44 100644 --- a/chrome/browser/translate/translate_manager_browsertest.cc +++ b/chrome/browser/translate/translate_manager_browsertest.cc @@ -28,11 +28,11 @@ #include "chrome/common/render_messages.h" #include "chrome/test/base/testing_browser_process.h" #include "chrome/test/base/testing_profile.h" -#include "content/browser/tab_contents/test_tab_contents.h" #include "content/public/browser/navigation_details.h" #include "content/public/browser/navigation_entry.h" #include "content/public/browser/notification_details.h" #include "content/public/browser/notification_registrar.h" +#include "content/public/browser/web_contents.h" #include "content/test/mock_render_process_host.h" #include "content/test/notification_observer_mock.h" #include "content/test/render_view_test.h" @@ -266,10 +266,10 @@ class TranslateManagerTest : public TabContentsWrapperTestHarness, // An observer that keeps track of whether a navigation entry was committed. class NavEntryCommittedObserver : public content::NotificationObserver { public: - explicit NavEntryCommittedObserver(TabContents* tab_contents) { + explicit NavEntryCommittedObserver(WebContents* web_contents) { registrar_.Add(this, content::NOTIFICATION_NAV_ENTRY_COMMITTED, content::Source<NavigationController>( - &tab_contents->GetController())); + &web_contents->GetController())); } virtual void Observe(int type, diff --git a/chrome/browser/ui/blocked_content/blocked_content_container.h b/chrome/browser/ui/blocked_content/blocked_content_container.h index b0637a9..3e20d6e 100644 --- a/chrome/browser/ui/blocked_content/blocked_content_container.h +++ b/chrome/browser/ui/blocked_content/blocked_content_container.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -18,7 +18,6 @@ #include "chrome/browser/ui/blocked_content/blocked_content_tab_helper_delegate.h" #include "content/public/browser/web_contents_delegate.h" -class TabContents; class TabContentsWrapper; // Takes ownership of TabContents that are unrequested popup windows. diff --git a/chrome/browser/ui/browser_dialogs.h b/chrome/browser/ui/browser_dialogs.h index 6c3b552..1f47e87 100644 --- a/chrome/browser/ui/browser_dialogs.h +++ b/chrome/browser/ui/browser_dialogs.h @@ -15,7 +15,6 @@ class Extension; class HtmlDialogUIDelegate; class Profile; class SkBitmap; -class TabContents; class TabContentsWrapper; class TabModalConfirmDialogDelegate; class TemplateURL; diff --git a/chrome/browser/ui/browser_window.h b/chrome/browser/ui/browser_window.h index 3d3851bb..52d7c20 100644 --- a/chrome/browser/ui/browser_window.h +++ b/chrome/browser/ui/browser_window.h @@ -21,7 +21,6 @@ class GURL; class LocationBar; class Profile; class StatusBubble; -class TabContents; class TabContentsWrapper; class TemplateURL; #if !defined(OS_MACOSX) diff --git a/chrome/browser/ui/cocoa/bookmarks/bookmark_bar_toolbar_view.h b/chrome/browser/ui/cocoa/bookmarks/bookmark_bar_toolbar_view.h index 02936ae..503531e 100644 --- a/chrome/browser/ui/cocoa/bookmarks/bookmark_bar_toolbar_view.h +++ b/chrome/browser/ui/cocoa/bookmarks/bookmark_bar_toolbar_view.h @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -17,7 +17,6 @@ #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_state.h" @class BookmarkBarView; -class TabContents; namespace ui { class ThemeProvider; diff --git a/chrome/browser/ui/cocoa/content_settings/collected_cookies_mac_unittest.mm b/chrome/browser/ui/cocoa/content_settings/collected_cookies_mac_unittest.mm index 3698921..fd5a0ea 100644 --- a/chrome/browser/ui/cocoa/content_settings/collected_cookies_mac_unittest.mm +++ b/chrome/browser/ui/cocoa/content_settings/collected_cookies_mac_unittest.mm @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -8,7 +8,6 @@ #include "chrome/browser/profiles/profile.h" #import "chrome/browser/ui/cocoa/content_settings/collected_cookies_mac.h" #include "chrome/browser/ui/tab_contents/test_tab_contents_wrapper.h" -#include "content/browser/tab_contents/test_tab_contents.h" #include "content/test/test_browser_thread.h" #include "chrome/test/base/testing_profile.h" diff --git a/chrome/browser/ui/cocoa/tab_contents/sad_tab_controller_unittest.mm b/chrome/browser/ui/cocoa/tab_contents/sad_tab_controller_unittest.mm index 00d687e..592dc92 100644 --- a/chrome/browser/ui/cocoa/tab_contents/sad_tab_controller_unittest.mm +++ b/chrome/browser/ui/cocoa/tab_contents/sad_tab_controller_unittest.mm @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -10,7 +10,6 @@ #import "chrome/browser/ui/cocoa/tab_contents/sad_tab_view.h" #include "chrome/test/base/chrome_render_view_host_test_harness.h" #include "chrome/test/base/testing_profile.h" -#include "content/browser/tab_contents/test_tab_contents.h" @interface SadTabView (ExposedForTesting) // Implementation is below. diff --git a/chrome/browser/ui/cocoa/web_intent_sheet_controller_unittest.mm b/chrome/browser/ui/cocoa/web_intent_sheet_controller_unittest.mm index 3155611..c1524f0 100644 --- a/chrome/browser/ui/cocoa/web_intent_sheet_controller_unittest.mm +++ b/chrome/browser/ui/cocoa/web_intent_sheet_controller_unittest.mm @@ -12,7 +12,6 @@ #include "chrome/browser/ui/cocoa/web_intent_picker_cocoa.h" #include "chrome/browser/ui/intents/web_intent_picker_delegate.h" #include "chrome/browser/ui/tab_contents/test_tab_contents_wrapper.h" -#include "content/browser/tab_contents/test_tab_contents.h" #include "content/test/test_browser_thread.h" #include "testing/gmock/include/gmock/gmock.h" diff --git a/chrome/browser/ui/content_settings/content_setting_bubble_model_unittest.cc b/chrome/browser/ui/content_settings/content_setting_bubble_model_unittest.cc index 5fa44ed..671ea3a 100644 --- a/chrome/browser/ui/content_settings/content_setting_bubble_model_unittest.cc +++ b/chrome/browser/ui/content_settings/content_setting_bubble_model_unittest.cc @@ -12,11 +12,13 @@ #include "chrome/browser/ui/tab_contents/test_tab_contents_wrapper.h" #include "chrome/common/chrome_switches.h" #include "chrome/test/base/testing_profile.h" -#include "content/browser/tab_contents/test_tab_contents.h" +#include "content/public/browser/web_contents.h" #include "content/test/test_browser_thread.h" +#include "content/test/web_contents_tester.h" #include "testing/gtest/include/gtest/gtest.h" using content::BrowserThread; +using content::WebContentsTester; class ContentSettingBubbleModelTest : public TabContentsWrapperTestHarness { protected: @@ -114,7 +116,8 @@ TEST_F(ContentSettingBubbleModelTest, MultiplePlugins) { // Navigating to some sample url prevents the GetURL method from returning an // invalid empty URL. - contents()->NavigateAndCommit(GURL("http://www.example.com")); + WebContentsTester::For( + contents())->NavigateAndCommit(GURL("http://www.example.com")); GURL url = contents()->GetURL(); map->AddExceptionForURL(url, url, diff --git a/chrome/browser/ui/content_settings/content_setting_image_model_unittest.cc b/chrome/browser/ui/content_settings/content_setting_image_model_unittest.cc index ac2e26d..7158c04 100644 --- a/chrome/browser/ui/content_settings/content_setting_image_model_unittest.cc +++ b/chrome/browser/ui/content_settings/content_setting_image_model_unittest.cc @@ -10,7 +10,6 @@ #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" #include "chrome/browser/ui/tab_contents/test_tab_contents_wrapper.h" #include "chrome/test/base/testing_profile.h" -#include "content/browser/tab_contents/test_tab_contents.h" #include "content/test/test_browser_thread.h" #include "content/test/test_renderer_host.h" #include "net/cookies/cookie_options.h" diff --git a/chrome/browser/ui/find_bar/find_backend_unittest.cc b/chrome/browser/ui/find_bar/find_backend_unittest.cc index ec2ba02..3b761b9 100644 --- a/chrome/browser/ui/find_bar/find_backend_unittest.cc +++ b/chrome/browser/ui/find_bar/find_backend_unittest.cc @@ -12,10 +12,13 @@ #include "chrome/browser/ui/tab_contents/test_tab_contents_wrapper.h" #include "chrome/common/url_constants.h" #include "chrome/test/base/testing_profile.h" -#include "content/browser/tab_contents/test_tab_contents.h" +#include "content/public/browser/web_contents.h" #include "content/test/test_browser_thread.h" +#include "content/test/web_contents_tester.h" using content::BrowserThread; +using content::WebContents; +using content::WebContentsTester; class FindBackendTest : public TabContentsWrapperTestHarness { public: @@ -29,7 +32,7 @@ class FindBackendTest : public TabContentsWrapperTestHarness { namespace { -string16 FindPrepopulateText(TabContents* contents) { +string16 FindPrepopulateText(WebContents* contents) { Profile* profile = Profile::FromBrowserContext(contents->GetBrowserContext()); return FindBarStateFactory::GetLastPrepopulateText(profile); } @@ -45,7 +48,8 @@ TEST_F(FindBackendTest, InternalState) { EXPECT_EQ(string16(), find_tab_helper->find_text()); // Get another TabContents object ready. - TestTabContents* contents2 = new TestTabContents(profile(), NULL); + WebContents* contents2 = + WebContentsTester::CreateTestWebContents(profile(), NULL); TabContentsWrapper wrapper2(contents2); FindTabHelper* find_tab_helper2 = wrapper2.find_tab_helper(); diff --git a/chrome/browser/ui/fullscreen_controller.h b/chrome/browser/ui/fullscreen_controller.h index 9af0e7d..e3bc446 100644 --- a/chrome/browser/ui/fullscreen_controller.h +++ b/chrome/browser/ui/fullscreen_controller.h @@ -15,7 +15,6 @@ class Browser; class BrowserWindow; class GURL; class Profile; -class TabContents; class TabContentsWrapper; namespace content { diff --git a/chrome/browser/ui/gtk/browser_titlebar.h b/chrome/browser/ui/gtk/browser_titlebar.h index b7dab91..cd80237 100644 --- a/chrome/browser/ui/gtk/browser_titlebar.h +++ b/chrome/browser/ui/gtk/browser_titlebar.h @@ -28,7 +28,6 @@ class CustomDrawButton; class ThemeServiceGtk; class MenuGtk; class PopupPageMenuModel; -class TabContents; namespace content { class WebContents; diff --git a/chrome/browser/ui/gtk/create_application_shortcuts_dialog_gtk.h b/chrome/browser/ui/gtk/create_application_shortcuts_dialog_gtk.h index 2bfeb27..eb9e513 100644 --- a/chrome/browser/ui/gtk/create_application_shortcuts_dialog_gtk.h +++ b/chrome/browser/ui/gtk/create_application_shortcuts_dialog_gtk.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -23,7 +23,6 @@ typedef struct _GtkWidget GtkWidget; typedef struct _GtkWindow GtkWindow; class Extension; -class TabContents; class TabContentsWrapper; class CreateApplicationShortcutsDialogGtk diff --git a/chrome/browser/ui/gtk/html_dialog_gtk.h b/chrome/browser/ui/gtk/html_dialog_gtk.h index f2ea226..bbcf957 100644 --- a/chrome/browser/ui/gtk/html_dialog_gtk.h +++ b/chrome/browser/ui/gtk/html_dialog_gtk.h @@ -22,7 +22,6 @@ typedef struct _GtkWidget GtkWidget; class Browser; class HtmlDialogController; class Profile; -class TabContents; class TabContentsContainerGtk; class TabContentsWrapper; diff --git a/chrome/browser/ui/gtk/tabs/dragged_view_gtk.h b/chrome/browser/ui/gtk/tabs/dragged_view_gtk.h index ffa2b76..18ec4572 100644 --- a/chrome/browser/ui/gtk/tabs/dragged_view_gtk.h +++ b/chrome/browser/ui/gtk/tabs/dragged_view_gtk.h @@ -21,7 +21,6 @@ #include "ui/gfx/size.h" class DragData; -class TabContents; class TabRendererGtk; class DraggedViewGtk : public ui::AnimationDelegate { diff --git a/chrome/browser/ui/gtk/web_intent_picker_gtk.h b/chrome/browser/ui/gtk/web_intent_picker_gtk.h index c2f0935..bdd86d38 100644 --- a/chrome/browser/ui/gtk/web_intent_picker_gtk.h +++ b/chrome/browser/ui/gtk/web_intent_picker_gtk.h @@ -25,7 +25,6 @@ class Browser; class CustomDrawButton; class GURL; -class TabContents; class TabContentsContainerGtk; class TabContentsWrapper; class WebIntentPickerDelegate; diff --git a/chrome/browser/ui/media_stream_infobar_delegate.h b/chrome/browser/ui/media_stream_infobar_delegate.h index 925e00d..7dab826 100644 --- a/chrome/browser/ui/media_stream_infobar_delegate.h +++ b/chrome/browser/ui/media_stream_infobar_delegate.h @@ -14,7 +14,6 @@ #include "content/public/common/media_stream_request.h" class MessageLoop; -class TabContents; class TabContentsWrapper; // This class configures an infobar shown when a page requests access to a diff --git a/chrome/browser/ui/panels/base_panel_browser_test.cc b/chrome/browser/ui/panels/base_panel_browser_test.cc index 0429173..f468b18 100644 --- a/chrome/browser/ui/panels/base_panel_browser_test.cc +++ b/chrome/browser/ui/panels/base_panel_browser_test.cc @@ -24,15 +24,21 @@ #include "chrome/common/chrome_switches.h" #include "chrome/common/string_ordinal.h" #include "chrome/test/base/ui_test_utils.h" -#include "content/browser/tab_contents/test_tab_contents.h" +#include "content/test/web_contents_tester.h" #include "content/public/browser/notification_service.h" #include "content/public/common/url_constants.h" +#if defined(OS_LINUX) +#include "ui/base/x/x11_util.h" +#endif + #if defined(OS_MACOSX) #include "base/mac/scoped_nsautorelease_pool.h" #include "chrome/browser/ui/cocoa/find_bar/find_bar_bridge.h" #endif +using content::WebContentsTester; + namespace { const int kTestingWorkAreaWidth = 800; @@ -431,7 +437,8 @@ Panel* BasePanelBrowserTest::CreateOverflowPanel(const std::string& name, void BasePanelBrowserTest::CreateTestTabContents(Browser* browser) { TabContentsWrapper* tab_contents = - new TabContentsWrapper(new TestTabContents(browser->profile(), NULL)); + new TabContentsWrapper( + WebContentsTester::CreateTestWebContents(browser->profile(), NULL)); browser->AddTab(tab_contents, content::PAGE_TRANSITION_LINK); } diff --git a/chrome/browser/ui/prefs/prefs_tab_helper_unittest.cc b/chrome/browser/ui/prefs/prefs_tab_helper_unittest.cc index 0b49361..e32cde3 100644 --- a/chrome/browser/ui/prefs/prefs_tab_helper_unittest.cc +++ b/chrome/browser/ui/prefs/prefs_tab_helper_unittest.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -7,7 +7,6 @@ #include "chrome/browser/ui/prefs/prefs_tab_helper.h" #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" #include "chrome/browser/ui/tab_contents/test_tab_contents_wrapper.h" -#include "content/browser/tab_contents/test_tab_contents.h" #include "content/test/test_browser_thread.h" using content::BrowserThread; @@ -57,7 +56,7 @@ class PrefsTabHelperTest : public TabContentsWrapperTestHarness { return test_prefs_helper; } - void SetContents2(TestTabContents* contents) { + void SetContents2(WebContents* contents) { contents_wrapper2_.reset( contents ? new TabContentsWrapper(contents) : NULL); } @@ -142,7 +141,7 @@ class PrefsTabHelperTest : public TabContentsWrapperTestHarness { protected: virtual void SetUp() OVERRIDE { TabContentsWrapperTestHarness::SetUp(); - SetContents2(CreateTestTabContents()); + SetContents2(CreateTestWebContents()); } virtual void TearDown() OVERRIDE { diff --git a/chrome/browser/ui/select_file_dialog.cc b/chrome/browser/ui/select_file_dialog.cc index 65883c5..4c8abb1 100644 --- a/chrome/browser/ui/select_file_dialog.cc +++ b/chrome/browser/ui/select_file_dialog.cc @@ -83,7 +83,7 @@ void SelectFileDialog::SelectFile(Type type, l10n_util::GetStringUTF16(IDS_FILE_SELECTION_DIALOG_INFOBAR), true)); } else { - LOG(WARNING) << "File-selection dialogs are disabled but no TabContents " + LOG(WARNING) << "File-selection dialogs are disabled but no WebContents " << "is given to display the InfoBar."; } diff --git a/chrome/browser/ui/tab_contents/test_tab_contents_wrapper.cc b/chrome/browser/ui/tab_contents/test_tab_contents_wrapper.cc index 5e40c7d..620a9c99 100644 --- a/chrome/browser/ui/tab_contents/test_tab_contents_wrapper.cc +++ b/chrome/browser/ui/tab_contents/test_tab_contents_wrapper.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -6,7 +6,9 @@ #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" #include "chrome/test/base/testing_profile.h" -#include "content/browser/tab_contents/test_tab_contents.h" +#include "content/public/browser/web_contents.h" + +using content::WebContents; TabContentsWrapperTestHarness::TabContentsWrapperTestHarness() : ChromeRenderViewHostTestHarness() { @@ -15,22 +17,21 @@ TabContentsWrapperTestHarness::TabContentsWrapperTestHarness() TabContentsWrapperTestHarness::~TabContentsWrapperTestHarness() { } -TestTabContents* TabContentsWrapperTestHarness::contents() { - return contents_wrapper_.get() ? - static_cast<TestTabContents*>(contents_wrapper_->web_contents()) : NULL; +WebContents* TabContentsWrapperTestHarness::web_contents() { + return contents_wrapper_.get() ? contents_wrapper_->web_contents() : NULL; } TabContentsWrapper* TabContentsWrapperTestHarness::contents_wrapper() { return contents_wrapper_.get(); } -void TabContentsWrapperTestHarness::SetContents(TestTabContents* contents) { +void TabContentsWrapperTestHarness::SetContents(WebContents* contents) { contents_wrapper_.reset(contents ? new TabContentsWrapper(contents) : NULL); } void TabContentsWrapperTestHarness::SetUp() { ChromeRenderViewHostTestHarness::SetUp(); - SetContents(CreateTestTabContents()); + SetContents(CreateTestWebContents()); } void TabContentsWrapperTestHarness::TearDown() { diff --git a/chrome/browser/ui/tab_contents/test_tab_contents_wrapper.h b/chrome/browser/ui/tab_contents/test_tab_contents_wrapper.h index 2c050ee..0efccca 100644 --- a/chrome/browser/ui/tab_contents/test_tab_contents_wrapper.h +++ b/chrome/browser/ui/tab_contents/test_tab_contents_wrapper.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -11,15 +11,19 @@ class TabContentsWrapper; +namespace content { +class WebContents; +} + class TabContentsWrapperTestHarness : public ChromeRenderViewHostTestHarness { public: TabContentsWrapperTestHarness(); virtual ~TabContentsWrapperTestHarness(); - virtual TestTabContents* contents() OVERRIDE; + virtual content::WebContents* web_contents() OVERRIDE; TabContentsWrapper* contents_wrapper(); - virtual void SetContents(TestTabContents* contents) OVERRIDE; + virtual void SetContents(content::WebContents* contents) OVERRIDE; protected: // testing::Test diff --git a/chrome/browser/ui/toolbar/back_forward_menu_model_unittest.cc b/chrome/browser/ui/toolbar/back_forward_menu_model_unittest.cc index 09bfc39..cb8e775 100644 --- a/chrome/browser/ui/toolbar/back_forward_menu_model_unittest.cc +++ b/chrome/browser/ui/toolbar/back_forward_menu_model_unittest.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -14,16 +14,17 @@ #include "chrome/common/url_constants.h" #include "chrome/test/base/chrome_render_view_host_test_harness.h" #include "chrome/test/base/testing_profile.h" -#include "content/browser/tab_contents/test_tab_contents.h" #include "content/public/browser/navigation_controller.h" #include "content/public/browser/navigation_entry.h" #include "content/public/browser/web_contents.h" #include "content/test/test_browser_thread.h" +#include "content/test/web_contents_tester.h" #include "testing/gtest/include/gtest/gtest.h" #include "third_party/skia/include/core/SkBitmap.h" #include "ui/gfx/codec/png_codec.h" using content::BrowserThread; +using content::WebContentsTester; namespace { @@ -83,23 +84,23 @@ class BackFwdMenuModelTest : public ChromeRenderViewHostTestHarness { // will be pending after we ask to navigate there). void NavigateToOffset(int offset) { controller().GoToOffset(offset); - contents()->CommitPendingNavigation(); + WebContentsTester::For(contents())->CommitPendingNavigation(); } // Same as NavigateToOffset but goes to an absolute index. void NavigateToIndex(int index) { controller().GoToIndex(index); - contents()->CommitPendingNavigation(); + WebContentsTester::For(contents())->CommitPendingNavigation(); } // Goes back/forward and commits the load. void GoBack() { controller().GoBack(); - contents()->CommitPendingNavigation(); + WebContentsTester::For(contents())->CommitPendingNavigation(); } void GoForward() { controller().GoForward(); - contents()->CommitPendingNavigation(); + WebContentsTester::For(contents())->CommitPendingNavigation(); } content::TestBrowserThread ui_thread_; diff --git a/chrome/browser/ui/views/ash/launcher/launcher_updater_unittest.cc b/chrome/browser/ui/views/ash/launcher/launcher_updater_unittest.cc index 11d96b4..5a32006 100644 --- a/chrome/browser/ui/views/ash/launcher/launcher_updater_unittest.cc +++ b/chrome/browser/ui/views/ash/launcher/launcher_updater_unittest.cc @@ -15,7 +15,6 @@ #include "chrome/browser/tabs/test_tab_strip_model_delegate.h" #include "chrome/test/base/chrome_render_view_host_test_harness.h" #include "chrome/test/base/testing_profile.h" -#include "content/browser/tab_contents/test_tab_contents.h" #include "content/test/test_browser_thread.h" #include "testing/gtest/include/gtest/gtest.h" #include "third_party/skia/include/core/SkBitmap.h" @@ -196,7 +195,7 @@ class LauncherUpdaterTest : public ChromeRenderViewHostTestHarness { TEST_F(LauncherUpdaterTest, TabbedSetup) { size_t initial_size = launcher_model_->items().size(); { - TabContentsWrapper wrapper(CreateTestTabContents()); + TabContentsWrapper wrapper(CreateTestWebContents()); State state(this, std::string(), LauncherUpdater::TYPE_TABBED); // Since the type is tabbed and there is nothing in the tabstrip an item @@ -216,7 +215,7 @@ TEST_F(LauncherUpdaterTest, TabbedSetup) { // Do the same, but this time add the tab first. { - TabContentsWrapper wrapper(CreateTestTabContents()); + TabContentsWrapper wrapper(CreateTestWebContents()); TestTabStripModelDelegate tab_strip_delegate; TabStripModel tab_strip(&tab_strip_delegate, profile()); @@ -254,7 +253,7 @@ TEST_F(LauncherUpdaterTest, AppSetup) { TEST_F(LauncherUpdaterTest, TabbedWithApp) { size_t initial_size = launcher_model_->items().size(); { - TabContentsWrapper initial_tab(CreateTestTabContents()); + TabContentsWrapper initial_tab(CreateTestWebContents()); State state(this, std::string(), LauncherUpdater::TYPE_TABBED); // Add a tab. state.tab_strip.InsertTabContentsAt(0, &initial_tab, @@ -267,7 +266,7 @@ TEST_F(LauncherUpdaterTest, TabbedWithApp) { ash::LauncherID tabbed_id = launcher_model_->items()[initial_size].id; // Add another tab, configure it so that the launcher thinks it's an app. - TabContentsWrapper app_tab(CreateTestTabContents()); + TabContentsWrapper app_tab(CreateTestWebContents()); app_icon_loader_->SetAppID(&app_tab, "1"); state.tab_strip.InsertTabContentsAt(1, &app_tab, TabStripModel::ADD_NONE); @@ -301,7 +300,7 @@ TEST_F(LauncherUpdaterTest, TabbedWithAppOnCreate) { root_window()->AddChild(&window); TestTabStripModelDelegate tab_strip_delegate; TabStripModel tab_strip(&tab_strip_delegate, profile()); - TabContentsWrapper app_tab(CreateTestTabContents()); + TabContentsWrapper app_tab(CreateTestWebContents()); app_icon_loader_->SetAppID(&app_tab, "1"); tab_strip.InsertTabContentsAt(0, &app_tab, TabStripModel::ADD_ACTIVE); LauncherUpdater updater(&window, &tab_strip, launcher_delegate_.get(), @@ -315,7 +314,7 @@ TEST_F(LauncherUpdaterTest, TabbedWithAppOnCreate) { TEST_F(LauncherUpdaterTest, ChangeToApp) { size_t initial_size = launcher_model_->items().size(); { - TabContentsWrapper initial_tab(CreateTestTabContents()); + TabContentsWrapper initial_tab(CreateTestWebContents()); State state(this, std::string(), LauncherUpdater::TYPE_TABBED); // Add a tab. state.tab_strip.InsertTabContentsAt(0, &initial_tab, @@ -349,7 +348,7 @@ TEST_F(LauncherUpdaterTest, ChangeToApp) { TEST_F(LauncherUpdaterTest, QueryAppIconLoader) { size_t initial_size = launcher_model_->items().size(); { - TabContentsWrapper initial_tab(CreateTestTabContents()); + TabContentsWrapper initial_tab(CreateTestWebContents()); State state(this, std::string(), LauncherUpdater::TYPE_TABBED); // Configure the tab as an app. app_icon_loader_->SetAppID(&initial_tab, "1"); @@ -368,7 +367,7 @@ TEST_F(LauncherUpdaterTest, QueryAppIconLoader) { // Verifies SetAppImage works. TEST_F(LauncherUpdaterTest, SetAppImage) { size_t initial_size = launcher_model_->items().size(); - TabContentsWrapper initial_tab(CreateTestTabContents()); + TabContentsWrapper initial_tab(CreateTestWebContents()); State state(this, std::string(), LauncherUpdater::TYPE_TABBED); // Configure the tab as an app. app_icon_loader_->SetAppID(&initial_tab, "1"); @@ -390,7 +389,7 @@ TEST_F(LauncherUpdaterTest, PanelItem) { aura::Window window(NULL); TestTabStripModelDelegate tab_strip_delegate; TabStripModel tab_strip(&tab_strip_delegate, profile()); - TabContentsWrapper panel_tab(CreateTestTabContents()); + TabContentsWrapper panel_tab(CreateTestWebContents()); app_icon_loader_->SetAppID(&panel_tab, "1"); // Panels are apps. tab_strip.InsertTabContentsAt(0, &panel_tab, TabStripModel::ADD_ACTIVE); LauncherUpdater updater(&window, &tab_strip, launcher_delegate_.get(), @@ -404,7 +403,7 @@ TEST_F(LauncherUpdaterTest, PanelItem) { // Verifies app tabs are added right after the existing tabbed item. TEST_F(LauncherUpdaterTest, AddAppAfterTabbed) { size_t initial_size = launcher_model_->items().size(); - TabContentsWrapper tab1(CreateTestTabContents()); + TabContentsWrapper tab1(CreateTestWebContents()); State state1(this, std::string(), LauncherUpdater::TYPE_TABBED); // Add a tab. state1.tab_strip.InsertTabContentsAt(0, &tab1, TabStripModel::ADD_ACTIVE); @@ -420,7 +419,7 @@ TEST_F(LauncherUpdaterTest, AddAppAfterTabbed) { // Add an app tab to state1, it should go after the item for state1 but // before the item for state2. int next_id = launcher_model_->next_id(); - TabContentsWrapper app_tab(CreateTestTabContents()); + TabContentsWrapper app_tab(CreateTestWebContents()); app_icon_loader_->SetAppID(&app_tab, "1"); state1.tab_strip.InsertTabContentsAt(1, &app_tab, TabStripModel::ADD_ACTIVE); @@ -444,9 +443,9 @@ TEST_F(LauncherUpdaterTest, AddAppAfterTabbed) { // Verifies GetWindowAndTabByID works. TEST_F(LauncherUpdaterTest, GetUpdaterByID) { size_t initial_size = launcher_model_->items().size(); - TabContentsWrapper tab1(CreateTestTabContents()); - TabContentsWrapper tab2(CreateTestTabContents()); - TabContentsWrapper tab3(CreateTestTabContents()); + TabContentsWrapper tab1(CreateTestWebContents()); + TabContentsWrapper tab2(CreateTestWebContents()); + TabContentsWrapper tab3(CreateTestWebContents()); // Create 3 states: // . tabbed with an app tab and normal tab. @@ -494,9 +493,9 @@ TEST_F(LauncherUpdaterTest, GetUpdaterByID) { // LauncherUpdater doesn't remove the entry for a pinned app. TEST_F(LauncherUpdaterTest, Pin) { size_t initial_size = launcher_model_->items().size(); - TabContentsWrapper tab1(CreateTestTabContents()); - TabContentsWrapper tab2(CreateTestTabContents()); - TabContentsWrapper tab3(CreateTestTabContents()); + TabContentsWrapper tab1(CreateTestWebContents()); + TabContentsWrapper tab2(CreateTestWebContents()); + TabContentsWrapper tab3(CreateTestWebContents()); ash::LauncherID id; { @@ -583,7 +582,7 @@ TEST_F(LauncherUpdaterTest, Pin) { // Verifies pinned apps are persisted and restored. TEST_F(LauncherUpdaterTest, PersistPinned) { size_t initial_size = launcher_model_->items().size(); - TabContentsWrapper tab1(CreateTestTabContents()); + TabContentsWrapper tab1(CreateTestWebContents()); app_icon_loader_->SetAppID(&tab1, "1"); app_icon_loader_->SetAppID(NULL, "2"); @@ -641,11 +640,11 @@ TEST_F(LauncherUpdaterTest, PersistPinned) { // Confirm that tabbed browsers with apps handle activation correctly. TEST_F(LauncherUpdaterTest, ActivateAppsInBrowser) { State state(this, std::string(), LauncherUpdater::TYPE_TABBED); - TabContentsWrapper app_tab1(CreateTestTabContents()); + TabContentsWrapper app_tab1(CreateTestWebContents()); app_icon_loader_->SetAppID(&app_tab1, "1"); - TabContentsWrapper app_tab2(CreateTestTabContents()); + TabContentsWrapper app_tab2(CreateTestWebContents()); app_icon_loader_->SetAppID(&app_tab2, "2"); - TabContentsWrapper app_tab3(CreateTestTabContents()); + TabContentsWrapper app_tab3(CreateTestWebContents()); app_icon_loader_->SetAppID(&app_tab3, "3"); // Insert an app tab. @@ -675,7 +674,7 @@ TEST_F(LauncherUpdaterTest, ActivateAppsInBrowser) { { // Add a 4th tab. - TabContentsWrapper app_tab4(CreateTestTabContents()); + TabContentsWrapper app_tab4(CreateTestWebContents()); app_icon_loader_->SetAppID(&app_tab3, "4"); state.tab_strip.InsertTabContentsAt( 4, &app_tab4, TabStripModel::ADD_ACTIVE); @@ -696,7 +695,7 @@ TEST_F(LauncherUpdaterTest, ActivateAppsInBrowser) { // Confirm that tabbed browsers handle activation correctly. TEST_F(LauncherUpdaterTest, ActivateBrowsers) { State state1(this, std::string(), LauncherUpdater::TYPE_TABBED); - TabContentsWrapper tab1(CreateTestTabContents()); + TabContentsWrapper tab1(CreateTestWebContents()); state1.tab_strip.InsertTabContentsAt(0, &tab1, TabStripModel::ADD_ACTIVE); // First browser is active. @@ -705,7 +704,7 @@ TEST_F(LauncherUpdaterTest, ActivateBrowsers) { { // Second browser is active and first is inactive. State state2(this, std::string(), LauncherUpdater::TYPE_TABBED); - TabContentsWrapper tab2(CreateTestTabContents()); + TabContentsWrapper tab2(CreateTestWebContents()); state2.tab_strip.InsertTabContentsAt(0, &tab1, TabStripModel::ADD_ACTIVE); EXPECT_EQ(ash::STATUS_ACTIVE, state2.GetUpdaterItem().status); EXPECT_EQ(ash::STATUS_RUNNING, state1.GetUpdaterItem().status); diff --git a/chrome/browser/ui/views/browser_dialogs.h b/chrome/browser/ui/views/browser_dialogs.h index 7f68b98..d29b3e7 100644 --- a/chrome/browser/ui/views/browser_dialogs.h +++ b/chrome/browser/ui/views/browser_dialogs.h @@ -23,7 +23,6 @@ class Extension; class FindBar; class GURL; class Profile; -class TabContents; class TabContentsWrapper; class TemplateURL; diff --git a/chrome/browser/ui/views/collected_cookies_views.h b/chrome/browser/ui/views/collected_cookies_views.h index 764d27c..9c8558a 100644 --- a/chrome/browser/ui/views/collected_cookies_views.h +++ b/chrome/browser/ui/views/collected_cookies_views.h @@ -18,7 +18,6 @@ class ConstrainedWindow; class CookieInfoView; class CookiesTreeModel; class InfobarView; -class TabContents; class TabContentsWrapper; namespace views { diff --git a/chrome/browser/ui/views/location_bar/content_setting_image_view.h b/chrome/browser/ui/views/location_bar/content_setting_image_view.h index 58c6e5f..b9144cc 100644 --- a/chrome/browser/ui/views/location_bar/content_setting_image_view.h +++ b/chrome/browser/ui/views/location_bar/content_setting_image_view.h @@ -17,7 +17,6 @@ class ContentSettingImageModel; class ContentSettingBubbleContents; class LocationBarView; -class TabContents; namespace content { class WebContents; diff --git a/chrome/browser/ui/views/omnibox/omnibox_view_views.h b/chrome/browser/ui/views/omnibox/omnibox_view_views.h index 7852d41..f74f6d2 100644 --- a/chrome/browser/ui/views/omnibox/omnibox_view_views.h +++ b/chrome/browser/ui/views/omnibox/omnibox_view_views.h @@ -26,7 +26,6 @@ class AutocompleteEditController; class AutocompleteEditModel; class AutocompletePopupView; class Profile; -class TabContents; namespace ui { class OSExchangeData; diff --git a/chrome/browser/ui/views/omnibox/omnibox_view_win.h b/chrome/browser/ui/views/omnibox/omnibox_view_win.h index 088b0e9..8919875 100644 --- a/chrome/browser/ui/views/omnibox/omnibox_view_win.h +++ b/chrome/browser/ui/views/omnibox/omnibox_view_win.h @@ -29,7 +29,6 @@ class AutocompleteEditController; class AutocompleteEditModel; class AutocompletePopupView; class LocationBarView; -class TabContents; namespace views { class NativeViewHost; diff --git a/chrome/browser/ui/views/stubs_aura.cc b/chrome/browser/ui/views/stubs_aura.cc index 7e73157..4bae160 100644 --- a/chrome/browser/ui/views/stubs_aura.cc +++ b/chrome/browser/ui/views/stubs_aura.cc @@ -22,7 +22,6 @@ #endif class SSLClientAuthHandler; -class TabContents; class TabContentsWrapper; namespace net { diff --git a/chrome/browser/ui/webui/html_dialog_tab_contents_delegate_unittest.cc b/chrome/browser/ui/webui/html_dialog_tab_contents_delegate_unittest.cc index 01d61783..cc07b5c 100644 --- a/chrome/browser/ui/webui/html_dialog_tab_contents_delegate_unittest.cc +++ b/chrome/browser/ui/webui/html_dialog_tab_contents_delegate_unittest.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -15,7 +15,8 @@ #include "chrome/test/base/browser_with_test_window_test.h" #include "chrome/test/base/test_browser_window.h" #include "chrome/test/base/testing_profile.h" -#include "content/browser/tab_contents/test_tab_contents.h" +#include "content/public/browser/web_contents.h" +#include "content/test/web_contents_tester.h" #include "googleurl/src/gurl.h" #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h" @@ -23,6 +24,8 @@ using content::OpenURLParams; using content::Referrer; +using content::WebContents; +using content::WebContentsTester; namespace { @@ -83,8 +86,8 @@ TEST_F(HtmlDialogTabContentsDelegateTest, OpenURLFromTabTest) { } TEST_F(HtmlDialogTabContentsDelegateTest, AddNewContentsForegroundTabTest) { - TabContents* contents = - new TabContents(profile(), NULL, MSG_ROUTING_NONE, NULL, NULL); + WebContents* contents = + WebContentsTester::CreateTestWebContents(profile(), NULL); test_tab_contents_delegate_->AddNewContents( NULL, contents, NEW_FOREGROUND_TAB, gfx::Rect(), false); // This should create a new foreground tab in the existing browser. diff --git a/chrome/browser/ui/webui/print_preview/print_preview_ui_unittest.cc b/chrome/browser/ui/webui/print_preview/print_preview_ui_unittest.cc index bad7a03..75f9ed5 100644 --- a/chrome/browser/ui/webui/print_preview/print_preview_ui_unittest.cc +++ b/chrome/browser/ui/webui/print_preview/print_preview_ui_unittest.cc @@ -12,11 +12,14 @@ #include "chrome/browser/ui/constrained_window_tab_helper.h" #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" #include "chrome/browser/ui/webui/print_preview/print_preview_ui.h" -#include "content/browser/tab_contents/test_tab_contents.h" #include "content/public/browser/site_instance.h" #include "content/public/browser/web_contents.h" +#include "content/test/web_contents_tester.h" #include "printing/print_job_constants.h" +using content::WebContents; +using content::WebContentsTester; + namespace { const unsigned char blob1[] = @@ -26,23 +29,6 @@ size_t GetConstrainedWindowCount(TabContentsWrapper* tab) { return tab->constrained_window_tab_helper()->constrained_window_count(); } -class FocusTestTabContents : public TestTabContents { - public: - FocusTestTabContents(content::BrowserContext* browser_context, - content::SiteInstance* instance) - : TestTabContents(browser_context, instance), focus_called_(0) { - } - - int focus_called() const { return focus_called_; } - - virtual void Focus() OVERRIDE { - focus_called_++; - } - - private: - int focus_called_; -}; - } // namespace class PrintPreviewUIUnitTest : public PrintPreviewUnitTestBase { @@ -232,8 +218,10 @@ TEST_F(PrintPreviewUIUnitTest, GetCurrentPrintPreviewStatus) { TEST_F(PrintPreviewUIUnitTest, InitiatorTabGetsFocusOnPrintPreviewTabClose) { EXPECT_EQ(1, browser()->tab_count()); - FocusTestTabContents* initiator_contents = - new FocusTestTabContents(profile(), NULL); + WebContents* initiator_contents = + WebContentsTester::CreateTestWebContentsCountFocus(profile(), NULL); + WebContentsTester* initiator_tester = + WebContentsTester::For(initiator_contents); browser()->AddWebContents(initiator_contents, NEW_FOREGROUND_TAB, gfx::Rect(), @@ -242,7 +230,7 @@ TEST_F(PrintPreviewUIUnitTest, InitiatorTabGetsFocusOnPrintPreviewTabClose) { TabContentsWrapper::GetCurrentWrapperForContents(initiator_contents); ASSERT_TRUE(initiator_tab); EXPECT_EQ(2, browser()->tab_count()); - EXPECT_EQ(0, initiator_contents->focus_called()); + EXPECT_EQ(0, initiator_tester->GetNumberOfFocusCalls()); printing::PrintPreviewTabController* controller = printing::PrintPreviewTabController::GetInstance(); @@ -255,7 +243,7 @@ TEST_F(PrintPreviewUIUnitTest, InitiatorTabGetsFocusOnPrintPreviewTabClose) { EXPECT_NE(initiator_tab, preview_tab); EXPECT_EQ(2, browser()->tab_count()); EXPECT_EQ(1U, GetConstrainedWindowCount(initiator_tab)); - EXPECT_EQ(0, initiator_contents->focus_called()); + EXPECT_EQ(0, initiator_tester->GetNumberOfFocusCalls()); PrintPreviewUI* preview_ui = static_cast<PrintPreviewUI*>( preview_tab->web_contents()->GetWebUI()->GetController()); @@ -265,5 +253,5 @@ TEST_F(PrintPreviewUIUnitTest, InitiatorTabGetsFocusOnPrintPreviewTabClose) { EXPECT_EQ(2, browser()->tab_count()); EXPECT_EQ(0U, GetConstrainedWindowCount(initiator_tab)); - EXPECT_EQ(1, initiator_contents->focus_called()); + EXPECT_EQ(1, initiator_tester->GetNumberOfFocusCalls()); } diff --git a/chrome/browser/ui/webui/sync_internals_ui_unittest.cc b/chrome/browser/ui/webui/sync_internals_ui_unittest.cc index 00d3096..f5c4230 100644 --- a/chrome/browser/ui/webui/sync_internals_ui_unittest.cc +++ b/chrome/browser/ui/webui/sync_internals_ui_unittest.cc @@ -13,7 +13,6 @@ #include "chrome/browser/sync/profile_sync_service_mock.h" #include "chrome/test/base/chrome_render_view_host_test_harness.h" #include "chrome/test/base/profile_mock.h" -#include "content/browser/tab_contents/test_tab_contents.h" #include "content/public/browser/web_ui_controller.h" #include "content/test/test_browser_thread.h" #include "sync/js/js_arg_list.h" diff --git a/chrome/browser/ui/webui/web_ui_unittest.cc b/chrome/browser/ui/webui/web_ui_unittest.cc index 0673726..57073ba 100644 --- a/chrome/browser/ui/webui/web_ui_unittest.cc +++ b/chrome/browser/ui/webui/web_ui_unittest.cc @@ -8,11 +8,13 @@ #include "chrome/browser/ui/tab_contents/test_tab_contents_wrapper.h" #include "chrome/common/url_constants.h" #include "chrome/test/base/testing_profile.h" -#include "content/browser/tab_contents/test_tab_contents.h" #include "content/public/browser/navigation_controller.h" #include "content/public/browser/site_instance.h" +#include "content/public/browser/web_contents.h" +#include "content/public/common/referrer.h" #include "content/test/test_browser_thread.h" #include "content/test/test_renderer_host.h" +#include "content/test/web_contents_tester.h" #include "testing/gtest/include/gtest/gtest.h" using content::BrowserThread; @@ -21,6 +23,7 @@ using content::RenderViewHost; using content::RenderViewHostTester; using content::SiteInstance; using content::WebContents; +using content::WebContentsTester; class WebUITest : public TabContentsWrapperTestHarness { public: @@ -103,7 +106,8 @@ TEST_F(WebUITest, WebUIToStandard) { // slightly different than the very-first-navigation case since the // SiteInstance will be the same (the original TabContents must still be // alive), which will trigger different behavior in RenderViewHostManager. - TestTabContents* contents2 = new TestTabContents(profile(), NULL); + WebContents* contents2 = + WebContentsTester::CreateTestWebContents(profile(), NULL); TabContentsWrapper wrapper2(contents2); DoNavigationTest(&wrapper2, 101); @@ -157,27 +161,15 @@ TEST_F(WebUITest, StandardToWebUI) { // Committing Web UI is tested above. } -class TabContentsForFocusTest : public TestTabContents { - public: - TabContentsForFocusTest(content::BrowserContext* browser_context, - SiteInstance* instance) - : TestTabContents(browser_context, instance), focus_called_(0) { - } - - virtual void SetFocusToLocationBar(bool select_all) { ++focus_called_; } - int focus_called() const { return focus_called_; } - - private: - int focus_called_; -}; - TEST_F(WebUITest, FocusOnNavigate) { - // Setup. |tc| will be used to track when we try to focus the location bar. - TabContentsForFocusTest* tc = new TabContentsForFocusTest( - contents()->GetBrowserContext(), - SiteInstance::Create(contents()->GetBrowserContext())); - tc->GetController().CopyStateFrom(controller()); - SetContents(tc); + // Setup. |wc| will be used to track when we try to focus the location bar. + WebContents* wc = + WebContentsTester::CreateTestWebContentsCountSetFocusToLocationBar( + contents()->GetBrowserContext(), + SiteInstance::Create(contents()->GetBrowserContext())); + WebContentsTester* wct = WebContentsTester::For(wc); + wc->GetController().CopyStateFrom(controller()); + SetContents(wc); int page_id = 200; // Load the NTP. @@ -200,17 +192,17 @@ TEST_F(WebUITest, FocusOnNavigate) { RenderViewHostTester::For(old_rvh)->SimulateSwapOutACK(); // Navigate back. Should focus the location bar. - int focus_called = tc->focus_called(); + int focus_called = wct->GetNumberOfFocusCalls(); ASSERT_TRUE(controller().CanGoBack()); controller().GoBack(); old_rvh = rvh(); RenderViewHostTester::For(old_rvh)->SendShouldCloseACK(true); RenderViewHostTester::For(pending_rvh())->SendNavigate(page_id, new_tab_url); RenderViewHostTester::For(old_rvh)->SimulateSwapOutACK(); - EXPECT_LT(focus_called, tc->focus_called()); + EXPECT_LT(focus_called, wct->GetNumberOfFocusCalls()); // Navigate forward. Shouldn't focus the location bar. - focus_called = tc->focus_called(); + focus_called = wct->GetNumberOfFocusCalls(); ASSERT_TRUE(controller().CanGoForward()); controller().GoForward(); old_rvh = rvh(); @@ -218,5 +210,5 @@ TEST_F(WebUITest, FocusOnNavigate) { RenderViewHostTester::For( pending_rvh())->SendNavigate(next_page_id, next_url); RenderViewHostTester::For(old_rvh)->SimulateSwapOutACK(); - EXPECT_EQ(focus_called, tc->focus_called()); + EXPECT_EQ(focus_called, wct->GetNumberOfFocusCalls()); } diff --git a/chrome/test/base/chrome_render_view_host_test_harness.cc b/chrome/test/base/chrome_render_view_host_test_harness.cc index 5eae53c..1380ca9 100644 --- a/chrome/test/base/chrome_render_view_host_test_harness.cc +++ b/chrome/test/base/chrome_render_view_host_test_harness.cc @@ -25,6 +25,10 @@ TestingProfile* ChromeRenderViewHostTestHarness::profile() { return static_cast<TestingProfile*>(browser_context_.get()); } +content::WebContents* ChromeRenderViewHostTestHarness::contents() { + return web_contents(); +} + RenderViewHostTester* ChromeRenderViewHostTestHarness::rvh_tester() { return RenderViewHostTester::For(rvh()); } diff --git a/chrome/test/base/chrome_render_view_host_test_harness.h b/chrome/test/base/chrome_render_view_host_test_harness.h index 10a5ca4..f8d15f5 100644 --- a/chrome/test/base/chrome_render_view_host_test_harness.h +++ b/chrome/test/base/chrome_render_view_host_test_harness.h @@ -11,6 +11,10 @@ class TestingProfile; +namespace content { +class WebContents; +} + // Wrapper around RenderViewHostTestHarness that uses a TestingProfile as // browser context instead of a TestBrowserContext. class ChromeRenderViewHostTestHarness : public RenderViewHostTestHarness { @@ -20,6 +24,7 @@ class ChromeRenderViewHostTestHarness : public RenderViewHostTestHarness { TestingProfile* profile(); + content::WebContents* contents(); content::RenderViewHostTester* rvh_tester(); protected: |