summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorphajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-08-30 16:10:30 +0000
committerphajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-08-30 16:10:30 +0000
commit60b6958818d805638ed1a5c3257d6ebe543bc31d (patch)
tree9793e1879d614de7caf53a2c27cf4c88b50762b7
parentbd40c0f9b6ae7c87d254bb6b3f3a46a52fc59a54 (diff)
downloadchromium_src-60b6958818d805638ed1a5c3257d6ebe543bc31d.zip
chromium_src-60b6958818d805638ed1a5c3257d6ebe543bc31d.tar.gz
chromium_src-60b6958818d805638ed1a5c3257d6ebe543bc31d.tar.bz2
Move more files to content_unittests.
Reduce dependencies on chrome/ BUG=90443 Review URL: http://codereview.chromium.org/7800004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@98823 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/chrome_tests.gypi12
-rw-r--r--content/browser/DEPS1
-rw-r--r--content/browser/debugger/devtools_manager_unittest.cc42
-rw-r--r--content/browser/mock_content_browser_client.cc3
-rw-r--r--content/browser/plugin_service_unittest.cc43
-rw-r--r--content/browser/tab_contents/tab_contents_view.h5
-rw-r--r--content/content_tests.gypi2
-rw-r--r--content/test/test_tab_contents_view.cc131
-rw-r--r--content/test/test_tab_contents_view.h74
9 files changed, 242 insertions, 71 deletions
diff --git a/chrome/chrome_tests.gypi b/chrome/chrome_tests.gypi
index e6bc5e1..0e20965 100644
--- a/chrome/chrome_tests.gypi
+++ b/chrome/chrome_tests.gypi
@@ -2001,18 +2001,7 @@
'test/sync/test_http_bridge_factory.h',
'tools/convert_dict/convert_dict_unittest.cc',
'../content/browser/debugger/devtools_manager_unittest.cc',
- '../content/browser/download/download_file_unittest.cc',
- '../content/browser/download/mock_download_manager.h',
- '../content/browser/download/mock_download_manager_delegate.cc',
- '../content/browser/download/mock_download_manager_delegate.h',
'../content/browser/download/save_package_unittest.cc',
- '../content/browser/geolocation/device_data_provider_unittest.cc',
- '../content/browser/geolocation/geolocation_provider_unittest.cc',
- '../content/browser/geolocation/gps_location_provider_unittest_linux.cc',
- '../content/browser/geolocation/location_arbitrator_unittest.cc',
- '../content/browser/geolocation/network_location_provider_unittest.cc',
- '../content/browser/geolocation/wifi_data_provider_common_unittest.cc',
- '../content/browser/geolocation/wifi_data_provider_linux_unittest.cc',
'../content/browser/geolocation/wifi_data_provider_unittest_win.cc',
'../content/browser/geolocation/win7_location_api_unittest_win.cc',
'../content/browser/geolocation/win7_location_provider_unittest_win.cc',
@@ -2021,7 +2010,6 @@
'../content/browser/in_process_webkit/webkit_context_unittest.cc',
'../content/browser/in_process_webkit/webkit_thread_unittest.cc',
'../content/browser/mach_broker_mac_unittest.cc',
- '../content/browser/plugin_service_unittest.cc',
'../content/browser/renderer_host/render_view_host_unittest.cc',
'../content/browser/renderer_host/render_widget_host_unittest.cc',
'../content/browser/site_instance_unittest.cc',
diff --git a/content/browser/DEPS b/content/browser/DEPS
index 7fec844..4794649 100644
--- a/content/browser/DEPS
+++ b/content/browser/DEPS
@@ -6,6 +6,5 @@ include_rules = [
# for more information.
# ONLY USED BY TESTS
- "+chrome/browser/browser_process.h",
"+chrome/browser/ui/browser.h",
]
diff --git a/content/browser/debugger/devtools_manager_unittest.cc b/content/browser/debugger/devtools_manager_unittest.cc
index 668054e..03f541b0 100644
--- a/content/browser/debugger/devtools_manager_unittest.cc
+++ b/content/browser/debugger/devtools_manager_unittest.cc
@@ -4,10 +4,10 @@
#include "base/basictypes.h"
#include "base/time.h"
-#include "chrome/browser/browser_process.h"
-#include "chrome/test/base/testing_browser_process.h"
+#include "content/browser/content_browser_client.h"
#include "content/browser/debugger/devtools_client_host.h"
#include "content/browser/debugger/devtools_manager.h"
+#include "content/browser/mock_content_browser_client.h"
#include "content/browser/renderer_host/test_render_view_host.h"
#include "content/browser/tab_contents/tab_contents_delegate.h"
#include "content/browser/tab_contents/test_tab_contents.h"
@@ -84,6 +84,22 @@ class TestTabContentsDelegate : public TabContentsDelegate {
bool renderer_unresponsive_received_;
};
+class DevToolsManagerTestBrowserClient
+ : public content::MockContentBrowserClient {
+ public:
+ DevToolsManagerTestBrowserClient() {
+ }
+
+ virtual DevToolsManager* GetDevToolsManager() OVERRIDE {
+ return &dev_tools_manager_;
+ }
+
+ private:
+ DevToolsManager dev_tools_manager_;
+
+ DISALLOW_COPY_AND_ASSIGN(DevToolsManagerTestBrowserClient);
+};
+
} // namespace
class DevToolsManagerTest : public RenderViewHostTestHarness {
@@ -92,10 +108,22 @@ class DevToolsManagerTest : public RenderViewHostTestHarness {
}
protected:
- virtual void SetUp() {
+ virtual void SetUp() OVERRIDE {
+ original_browser_client_ = content::GetContentClient()->browser();
+ content::GetContentClient()->set_browser(&browser_client_);
+
RenderViewHostTestHarness::SetUp();
TestDevToolsClientHost::ResetCounters();
}
+
+ virtual void TearDown() OVERRIDE {
+ RenderViewHostTestHarness::TearDown();
+ content::GetContentClient()->set_browser(original_browser_client_);
+ }
+
+ private:
+ content::ContentBrowserClient* original_browser_client_;
+ DevToolsManagerTestBrowserClient browser_client_;
};
TEST_F(DevToolsManagerTest, OpenAndManuallyCloseDevToolsClientHost) {
@@ -144,13 +172,9 @@ TEST_F(DevToolsManagerTest, NoUnresponsiveDialogInInspectedTab) {
TestTabContentsDelegate delegate;
contents()->set_delegate(&delegate);
- static_cast<TestingBrowserProcess*>(g_browser_process)->
- SetDevToolsManager(new DevToolsManager());
- DevToolsManager* manager = DevToolsManager::GetInstance();
- ASSERT_TRUE(manager);
-
TestDevToolsClientHost client_host;
- manager->RegisterDevToolsClientHostFor(inspected_rvh, &client_host);
+ content::GetContentClient()->browser()->GetDevToolsManager()->
+ RegisterDevToolsClientHostFor(inspected_rvh, &client_host);
// Start with a short timeout.
inspected_rvh->StartHangMonitorTimeout(TimeDelta::FromMilliseconds(10));
diff --git a/content/browser/mock_content_browser_client.cc b/content/browser/mock_content_browser_client.cc
index 8bf2e35..026c02b 100644
--- a/content/browser/mock_content_browser_client.cc
+++ b/content/browser/mock_content_browser_client.cc
@@ -8,6 +8,7 @@
#include "base/file_path.h"
#include "content/browser/webui/empty_web_ui_factory.h"
+#include "content/test/test_tab_contents_view.h"
#include "googleurl/src/gurl.h"
#include "third_party/skia/include/core/SkBitmap.h"
#include "ui/base/clipboard/clipboard.h"
@@ -20,7 +21,7 @@ MockContentBrowserClient::~MockContentBrowserClient() {
TabContentsView* MockContentBrowserClient::CreateTabContentsView(
TabContents* tab_contents) {
- return NULL;
+ return new TestTabContentsView;
}
void MockContentBrowserClient::RenderViewHostCreated(
diff --git a/content/browser/plugin_service_unittest.cc b/content/browser/plugin_service_unittest.cc
deleted file mode 100644
index 4d9f420..0000000
--- a/content/browser/plugin_service_unittest.cc
+++ /dev/null
@@ -1,43 +0,0 @@
-// Copyright (c) 2011 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.
-
-#include "content/browser/plugin_service.h"
-
-#include "content/browser/browser_thread.h"
-#include "testing/gtest/include/gtest/gtest.h"
-
-namespace {
-
-class PluginServiceTest : public testing::Test {
- public:
- PluginServiceTest()
- : message_loop_(MessageLoop::TYPE_IO),
- ui_thread_(BrowserThread::UI, &message_loop_),
- file_thread_(BrowserThread::FILE, &message_loop_),
- io_thread_(BrowserThread::IO, &message_loop_) {}
-
-
- virtual void SetUp() {
- plugin_service_ = PluginService::GetInstance();
- ASSERT_TRUE(plugin_service_);
- }
-
- protected:
- MessageLoop message_loop_;
- PluginService* plugin_service_;
-
- private:
- BrowserThread ui_thread_;
- BrowserThread file_thread_;
- BrowserThread io_thread_;
-
- DISALLOW_COPY_AND_ASSIGN(PluginServiceTest);
-};
-
-TEST_F(PluginServiceTest, GetUILocale) {
- // Check for a non-empty locale string.
- EXPECT_NE("", plugin_service_->GetUILocale());
-}
-
-} // namespace
diff --git a/content/browser/tab_contents/tab_contents_view.h b/content/browser/tab_contents/tab_contents_view.h
index bbc6d3b..f5c58be 100644
--- a/content/browser/tab_contents/tab_contents_view.h
+++ b/content/browser/tab_contents/tab_contents_view.h
@@ -27,11 +27,6 @@ class TabContentsView : public RenderViewHostDelegate::View {
public:
virtual ~TabContentsView();
- // Creates the appropriate type of TabContentsView for the current system.
- // The return value is a new heap allocated view with ownership passing to
- // the caller.
- static TabContentsView* Create(TabContents* tab_contents);
-
virtual void CreateView(const gfx::Size& initial_size) = 0;
// Sets up the View that holds the rendered web page, receives messages for
diff --git a/content/content_tests.gypi b/content/content_tests.gypi
index 817cf28..493b590 100644
--- a/content/content_tests.gypi
+++ b/content/content_tests.gypi
@@ -38,6 +38,8 @@
'test/test_browser_context.h',
'test/test_content_client.cc',
'test/test_content_client.h',
+ 'test/test_tab_contents_view.cc',
+ 'test/test_tab_contents_view.h',
'test/test_url_fetcher_factory.cc',
'test/test_url_fetcher_factory.h',
diff --git a/content/test/test_tab_contents_view.cc b/content/test/test_tab_contents_view.cc
new file mode 100644
index 0000000..a60552b
--- /dev/null
+++ b/content/test/test_tab_contents_view.cc
@@ -0,0 +1,131 @@
+// Copyright (c) 2011 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.
+
+#include "content/test/test_tab_contents_view.h"
+
+TestTabContentsView::TestTabContentsView() {
+}
+
+TestTabContentsView::~TestTabContentsView() {
+}
+
+void TestTabContentsView::CreateNewWindow(
+ int route_id,
+ const ViewHostMsg_CreateWindow_Params& params) {
+}
+
+void TestTabContentsView::CreateNewWidget(int route_id,
+ WebKit::WebPopupType popup_type) {
+}
+
+void TestTabContentsView::CreateNewFullscreenWidget(int route_id) {
+}
+
+void TestTabContentsView::ShowCreatedWindow(int route_id,
+ WindowOpenDisposition disposition,
+ const gfx::Rect& initial_pos,
+ bool user_gesture) {
+}
+
+void TestTabContentsView::ShowCreatedWidget(int route_id,
+ const gfx::Rect& initial_pos) {
+}
+
+void TestTabContentsView::ShowCreatedFullscreenWidget(int route_id) {
+}
+
+void TestTabContentsView::ShowContextMenu(const ContextMenuParams& params) {
+}
+
+void TestTabContentsView::ShowPopupMenu(const gfx::Rect& bounds,
+ int item_height,
+ double item_font_size,
+ int selected_item,
+ const std::vector<WebMenuItem>& items,
+ bool right_aligned) {
+}
+
+void TestTabContentsView::StartDragging(
+ const WebDropData& drop_data,
+ WebKit::WebDragOperationsMask allowed_ops,
+ const SkBitmap& image,
+ const gfx::Point& image_offset) {
+}
+
+void TestTabContentsView::UpdateDragCursor(WebKit::WebDragOperation operation) {
+}
+
+void TestTabContentsView::GotFocus() {
+}
+
+void TestTabContentsView::TakeFocus(bool reverse) {
+}
+
+void TestTabContentsView::UpdatePreferredSize(const gfx::Size& pref_size) {
+}
+
+void TestTabContentsView::CreateView(const gfx::Size& initial_size) {
+}
+
+RenderWidgetHostView* TestTabContentsView::CreateViewForWidget(
+ RenderWidgetHost* render_widget_host) {
+ return NULL;
+}
+
+gfx::NativeView TestTabContentsView::GetNativeView() const {
+ return gfx::NativeView();
+}
+
+gfx::NativeView TestTabContentsView::GetContentNativeView() const {
+ return gfx::NativeView();
+}
+
+gfx::NativeWindow TestTabContentsView::GetTopLevelNativeWindow() const {
+ return gfx::NativeWindow();
+}
+
+void TestTabContentsView::GetContainerBounds(gfx::Rect *out) const {
+}
+
+void TestTabContentsView::SetPageTitle(const std::wstring& title) {
+}
+
+void TestTabContentsView::OnTabCrashed(base::TerminationStatus status,
+ int error_code) {
+}
+
+void TestTabContentsView::SizeContents(const gfx::Size& size) {
+}
+
+void TestTabContentsView::RenderViewCreated(RenderViewHost* host) {
+}
+
+void TestTabContentsView::Focus() {
+}
+
+void TestTabContentsView::SetInitialFocus() {
+}
+
+void TestTabContentsView::StoreFocus() {
+}
+
+void TestTabContentsView::RestoreFocus() {
+}
+
+bool TestTabContentsView::IsDoingDrag() const {
+ return false;
+}
+
+void TestTabContentsView::CancelDragAndCloseTab() {
+}
+
+bool TestTabContentsView::IsEventTracking() const {
+ return false;
+}
+
+void TestTabContentsView::CloseTabAfterEventTracking() {
+}
+
+void TestTabContentsView::GetViewBounds(gfx::Rect* out) const {
+}
diff --git a/content/test/test_tab_contents_view.h b/content/test/test_tab_contents_view.h
new file mode 100644
index 0000000..e70e0bc
--- /dev/null
+++ b/content/test/test_tab_contents_view.h
@@ -0,0 +1,74 @@
+// Copyright (c) 2011 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.
+
+#ifndef CONTENT_TEST_TEST_TAB_CONTENTS_VIEW_H_
+#define CONTENT_TEST_TEST_TAB_CONTENTS_VIEW_H_
+#pragma once
+
+#include "base/compiler_specific.h"
+#include "content/browser/tab_contents/tab_contents_view.h"
+
+class TestTabContentsView : public TabContentsView {
+ public:
+ TestTabContentsView();
+ virtual ~TestTabContentsView();
+
+ // RenderViewHostDelegate::View:
+ virtual void CreateNewWindow(
+ int route_id,
+ const ViewHostMsg_CreateWindow_Params& params) OVERRIDE;
+ virtual void CreateNewWidget(int route_id,
+ WebKit::WebPopupType popup_type) OVERRIDE;
+ virtual void CreateNewFullscreenWidget(int route_id) OVERRIDE;
+ virtual void ShowCreatedWindow(int route_id,
+ WindowOpenDisposition disposition,
+ const gfx::Rect& initial_pos,
+ bool user_gesture) OVERRIDE;
+ virtual void ShowCreatedWidget(int route_id,
+ const gfx::Rect& initial_pos) OVERRIDE;
+ virtual void ShowCreatedFullscreenWidget(int route_id) OVERRIDE;
+ virtual void ShowContextMenu(const ContextMenuParams& params) OVERRIDE;
+ virtual void ShowPopupMenu(const gfx::Rect& bounds,
+ int item_height,
+ double item_font_size,
+ int selected_item,
+ const std::vector<WebMenuItem>& items,
+ bool right_aligned) OVERRIDE;
+ virtual void StartDragging(const WebDropData& drop_data,
+ WebKit::WebDragOperationsMask allowed_ops,
+ const SkBitmap& image,
+ const gfx::Point& image_offset) OVERRIDE;
+ virtual void UpdateDragCursor(WebKit::WebDragOperation operation) OVERRIDE;
+ virtual void GotFocus() OVERRIDE;
+ virtual void TakeFocus(bool reverse) OVERRIDE;
+ virtual void UpdatePreferredSize(const gfx::Size& pref_size) OVERRIDE;
+
+ // TabContentsView:
+ virtual void CreateView(const gfx::Size& initial_size) OVERRIDE;
+ virtual RenderWidgetHostView* CreateViewForWidget(
+ RenderWidgetHost* render_widget_host) OVERRIDE;
+ virtual gfx::NativeView GetNativeView() const OVERRIDE;
+ virtual gfx::NativeView GetContentNativeView() const OVERRIDE;
+ virtual gfx::NativeWindow GetTopLevelNativeWindow() const OVERRIDE;
+ virtual void GetContainerBounds(gfx::Rect *out) const OVERRIDE;
+ virtual void SetPageTitle(const std::wstring& title) OVERRIDE;
+ virtual void OnTabCrashed(base::TerminationStatus status,
+ int error_code) OVERRIDE;
+ virtual void SizeContents(const gfx::Size& size) OVERRIDE;
+ virtual void RenderViewCreated(RenderViewHost* host) OVERRIDE;
+ virtual void Focus() OVERRIDE;
+ virtual void SetInitialFocus() OVERRIDE;
+ virtual void StoreFocus() OVERRIDE;
+ virtual void RestoreFocus() OVERRIDE;
+ virtual bool IsDoingDrag() const OVERRIDE;
+ virtual void CancelDragAndCloseTab() OVERRIDE;
+ virtual bool IsEventTracking() const OVERRIDE;
+ virtual void CloseTabAfterEventTracking() OVERRIDE;
+ virtual void GetViewBounds(gfx::Rect* out) const OVERRIDE;
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(TestTabContentsView);
+};
+
+#endif // CONTENT_TEST_TEST_TAB_CONTENTS_VIEW_H_