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
parent bd40c0f9
...@@ -2001,18 +2001,7 @@ ...@@ -2001,18 +2001,7 @@
'test/sync/test_http_bridge_factory.h', 'test/sync/test_http_bridge_factory.h',
'tools/convert_dict/convert_dict_unittest.cc', 'tools/convert_dict/convert_dict_unittest.cc',
'../content/browser/debugger/devtools_manager_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/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/wifi_data_provider_unittest_win.cc',
'../content/browser/geolocation/win7_location_api_unittest_win.cc', '../content/browser/geolocation/win7_location_api_unittest_win.cc',
'../content/browser/geolocation/win7_location_provider_unittest_win.cc', '../content/browser/geolocation/win7_location_provider_unittest_win.cc',
...@@ -2021,7 +2010,6 @@ ...@@ -2021,7 +2010,6 @@
'../content/browser/in_process_webkit/webkit_context_unittest.cc', '../content/browser/in_process_webkit/webkit_context_unittest.cc',
'../content/browser/in_process_webkit/webkit_thread_unittest.cc', '../content/browser/in_process_webkit/webkit_thread_unittest.cc',
'../content/browser/mach_broker_mac_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_view_host_unittest.cc',
'../content/browser/renderer_host/render_widget_host_unittest.cc', '../content/browser/renderer_host/render_widget_host_unittest.cc',
'../content/browser/site_instance_unittest.cc', '../content/browser/site_instance_unittest.cc',
......
...@@ -6,6 +6,5 @@ include_rules = [ ...@@ -6,6 +6,5 @@ include_rules = [
# for more information. # for more information.
# ONLY USED BY TESTS # ONLY USED BY TESTS
"+chrome/browser/browser_process.h",
"+chrome/browser/ui/browser.h", "+chrome/browser/ui/browser.h",
] ]
...@@ -4,10 +4,10 @@ ...@@ -4,10 +4,10 @@
#include "base/basictypes.h" #include "base/basictypes.h"
#include "base/time.h" #include "base/time.h"
#include "chrome/browser/browser_process.h" #include "content/browser/content_browser_client.h"
#include "chrome/test/base/testing_browser_process.h"
#include "content/browser/debugger/devtools_client_host.h" #include "content/browser/debugger/devtools_client_host.h"
#include "content/browser/debugger/devtools_manager.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/renderer_host/test_render_view_host.h"
#include "content/browser/tab_contents/tab_contents_delegate.h" #include "content/browser/tab_contents/tab_contents_delegate.h"
#include "content/browser/tab_contents/test_tab_contents.h" #include "content/browser/tab_contents/test_tab_contents.h"
...@@ -84,6 +84,22 @@ class TestTabContentsDelegate : public TabContentsDelegate { ...@@ -84,6 +84,22 @@ class TestTabContentsDelegate : public TabContentsDelegate {
bool renderer_unresponsive_received_; 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 } // namespace
class DevToolsManagerTest : public RenderViewHostTestHarness { class DevToolsManagerTest : public RenderViewHostTestHarness {
...@@ -92,10 +108,22 @@ class DevToolsManagerTest : public RenderViewHostTestHarness { ...@@ -92,10 +108,22 @@ class DevToolsManagerTest : public RenderViewHostTestHarness {
} }
protected: protected:
virtual void SetUp() { virtual void SetUp() OVERRIDE {
original_browser_client_ = content::GetContentClient()->browser();
content::GetContentClient()->set_browser(&browser_client_);
RenderViewHostTestHarness::SetUp(); RenderViewHostTestHarness::SetUp();
TestDevToolsClientHost::ResetCounters(); 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) { TEST_F(DevToolsManagerTest, OpenAndManuallyCloseDevToolsClientHost) {
...@@ -144,13 +172,9 @@ TEST_F(DevToolsManagerTest, NoUnresponsiveDialogInInspectedTab) { ...@@ -144,13 +172,9 @@ TEST_F(DevToolsManagerTest, NoUnresponsiveDialogInInspectedTab) {
TestTabContentsDelegate delegate; TestTabContentsDelegate delegate;
contents()->set_delegate(&delegate); contents()->set_delegate(&delegate);
static_cast<TestingBrowserProcess*>(g_browser_process)->
SetDevToolsManager(new DevToolsManager());
DevToolsManager* manager = DevToolsManager::GetInstance();
ASSERT_TRUE(manager);
TestDevToolsClientHost client_host; TestDevToolsClientHost client_host;
manager->RegisterDevToolsClientHostFor(inspected_rvh, &client_host); content::GetContentClient()->browser()->GetDevToolsManager()->
RegisterDevToolsClientHostFor(inspected_rvh, &client_host);
// Start with a short timeout. // Start with a short timeout.
inspected_rvh->StartHangMonitorTimeout(TimeDelta::FromMilliseconds(10)); inspected_rvh->StartHangMonitorTimeout(TimeDelta::FromMilliseconds(10));
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include "base/file_path.h" #include "base/file_path.h"
#include "content/browser/webui/empty_web_ui_factory.h" #include "content/browser/webui/empty_web_ui_factory.h"
#include "content/test/test_tab_contents_view.h"
#include "googleurl/src/gurl.h" #include "googleurl/src/gurl.h"
#include "third_party/skia/include/core/SkBitmap.h" #include "third_party/skia/include/core/SkBitmap.h"
#include "ui/base/clipboard/clipboard.h" #include "ui/base/clipboard/clipboard.h"
...@@ -20,7 +21,7 @@ MockContentBrowserClient::~MockContentBrowserClient() { ...@@ -20,7 +21,7 @@ MockContentBrowserClient::~MockContentBrowserClient() {
TabContentsView* MockContentBrowserClient::CreateTabContentsView( TabContentsView* MockContentBrowserClient::CreateTabContentsView(
TabContents* tab_contents) { TabContents* tab_contents) {
return NULL; return new TestTabContentsView;
} }
void MockContentBrowserClient::RenderViewHostCreated( void MockContentBrowserClient::RenderViewHostCreated(
......
// 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
...@@ -27,11 +27,6 @@ class TabContentsView : public RenderViewHostDelegate::View { ...@@ -27,11 +27,6 @@ class TabContentsView : public RenderViewHostDelegate::View {
public: public:
virtual ~TabContentsView(); 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; virtual void CreateView(const gfx::Size& initial_size) = 0;
// Sets up the View that holds the rendered web page, receives messages for // Sets up the View that holds the rendered web page, receives messages for
......
...@@ -38,6 +38,8 @@ ...@@ -38,6 +38,8 @@
'test/test_browser_context.h', 'test/test_browser_context.h',
'test/test_content_client.cc', 'test/test_content_client.cc',
'test/test_content_client.h', '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.cc',
'test/test_url_fetcher_factory.h', 'test/test_url_fetcher_factory.h',
......
// 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 {
}
// 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_
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment