Commit ca7e803a authored by jam@chromium.org's avatar jam@chromium.org

Move the browser tests inside content/renderer to run under content_browsertests.

BUG=90448
Review URL: https://chromiumcodereview.appspot.com/10832014

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@148446 0039d316-1c4b-4281-b951-d872f2087c98
parent 11d12ba3
......@@ -2612,13 +2612,8 @@
'../base/base.gyp:base',
'../base/base.gyp:base_i18n',
'../base/base.gyp:test_support_base',
'../ipc/ipc.gyp:test_support_ipc',
'../net/net.gyp:net',
'../net/net.gyp:net_test_support',
'../ppapi/ppapi_internal.gyp:ppapi_host',
'../ppapi/ppapi_internal.gyp:ppapi_proxy',
'../ppapi/ppapi_internal.gyp:ppapi_shared',
'../ppapi/ppapi_internal.gyp:ppapi_unittest_shared',
'../skia/skia.gyp:skia',
'../sync/sync.gyp:test_support_syncapi_service',
'../testing/gmock.gyp:gmock',
......@@ -3062,13 +3057,6 @@
'../content/browser/session_history_browsertest.cc',
'../content/browser/speech/speech_recognition_browsertest.cc',
'../content/browser/webkit_browsertest.cc',
'../content/public/test/render_widget_browsertest.h',
'../content/renderer/mouse_lock_dispatcher_browsertest.cc',
'../content/renderer/pepper/pepper_file_chooser_host_unittest.cc',
'../content/renderer/render_view_browsertest.cc',
'../content/renderer/render_view_browsertest_mac.mm',
'../content/renderer/renderer_accessibility_browsertest.cc',
'../content/test/render_widget_browsertest.cc',
],
'rules': [
{
......
......@@ -39,6 +39,7 @@
'public/test/mock_resource_context.h',
'public/test/render_view_fake_resources_test.h',
'public/test/render_view_test.h',
'public/test/render_widget_browsertest.h',
'public/test/test_browser_context.h',
'public/test/test_browser_thread.h',
'public/test/test_content_client_initializer.h',
......@@ -109,6 +110,7 @@
'test/net/url_request_abort_on_end_job.h',
'test/render_view_fake_resources_test.cc',
'test/render_view_test.cc',
'test/render_widget_browsertest.cc',
'test/test_browser_context.cc',
'test/test_browser_thread.cc',
'test/test_content_browser_client.cc',
......@@ -529,8 +531,14 @@
'content_shell_pak',
'test_support_content',
'../base/base.gyp:test_support_base',
'../ipc/ipc.gyp:test_support_ipc',
'../net/net.gyp:net_test_support',
'../ppapi/ppapi_internal.gyp:ppapi_host',
'../ppapi/ppapi_internal.gyp:ppapi_proxy',
'../ppapi/ppapi_internal.gyp:ppapi_shared',
'../ppapi/ppapi_internal.gyp:ppapi_unittest_shared',
'../skia/skia.gyp:skia',
'../testing/gmock.gyp:gmock',
'../testing/gtest.gyp:gtest',
'../ui/ui.gyp:ui',
'../webkit/support/webkit_support.gyp:glue',
......@@ -548,6 +556,11 @@
'browser/media_browsertest.cc',
'browser/plugin_browsertest.cc',
'browser/worker_host/test/worker_browsertest.cc',
'renderer/mouse_lock_dispatcher_browsertest.cc',
'renderer/pepper/pepper_file_chooser_host_unittest.cc',
'renderer/render_view_browsertest.cc',
'renderer/render_view_browsertest_mac.mm',
'renderer/renderer_accessibility_browsertest.cc',
'test/content_browser_test.h',
'test/content_browser_test.cc',
'test/content_browser_test_utils.cc',
......
......@@ -2,6 +2,7 @@ include_rules = [
"+chrome/test",
"+content/public/renderer",
"+content/public/browser/native_web_keyboard_event.h", # For tests.
"+content/public/browser/web_ui_controller_factory.h", # For tests.
"+jingle/glue",
"+media", # For audio input/output and audio/video decoding.
"+third_party/hyphen/hyphen.h",
......
......@@ -4,8 +4,8 @@
#include "base/file_path.h"
#include "base/utf_string_conversions.h"
#include "content/public/test/render_view_test.h"
#include "content/common/view_messages.h"
#include "content/public/test/render_view_test.h"
#include "content/public/common/file_chooser_params.h"
#include "content/renderer/pepper/pepper_file_chooser_host.h"
#include "content/renderer/pepper/pepper_instance_state_accessor.h"
......
......@@ -10,9 +10,14 @@
#include "content/common/intents_messages.h"
#include "content/common/view_messages.h"
#include "content/public/browser/native_web_keyboard_event.h"
#include "content/public/browser/web_ui_controller_factory.h"
#include "content/public/common/bindings_policy.h"
#include "content/public/common/url_constants.h"
#include "content/public/test/render_view_test.h"
#include "content/renderer/render_view_impl.h"
#include "content/shell/shell_content_client.h"
#include "content/shell/shell_content_browser_client.h"
#include "content/shell/shell_main_delegate.h"
#include "content/test/mock_keyboard.h"
#include "net/base/net_errors.h"
#include "testing/gtest/include/gtest/gtest.h"
......@@ -73,6 +78,57 @@ int ConvertMockKeyboardModifier(MockKeyboard::Modifiers modifiers) {
return flags;
}
#endif
class WebUITestWebUIControllerFactory : public content::WebUIControllerFactory {
public:
virtual content::WebUIController* CreateWebUIControllerForURL(
content::WebUI* web_ui, const GURL& url) const OVERRIDE {
return NULL;
}
virtual content::WebUI::TypeID GetWebUIType(
content::BrowserContext* browser_context,
const GURL& url) const OVERRIDE {
return content::WebUI::kNoWebUI;
}
virtual bool UseWebUIForURL(content::BrowserContext* browser_context,
const GURL& url) const OVERRIDE {
return content::GetContentClient()->HasWebUIScheme(url);
}
virtual bool UseWebUIBindingsForURL(content::BrowserContext* browser_context,
const GURL& url) const OVERRIDE {
return content::GetContentClient()->HasWebUIScheme(url);
}
virtual bool IsURLAcceptableForWebUI(
content::BrowserContext* browser_context,
const GURL& url,
bool data_urls_allowed) const OVERRIDE {
return false;
}
};
class WebUITestClient : public content::ShellContentClient {
public:
WebUITestClient() {
}
virtual bool HasWebUIScheme(const GURL& url) const OVERRIDE {
return url.SchemeIs(chrome::kChromeUIScheme);
}
};
class WebUITestBrowserClient : public content::ShellContentBrowserClient {
public:
WebUITestBrowserClient() {}
virtual content::WebUIControllerFactory*
GetWebUIControllerFactory() OVERRIDE {
return &factory_;
}
private:
WebUITestWebUIControllerFactory factory_;
};
}
class RenderViewImplTest : public content::RenderViewTest {
......@@ -82,6 +138,11 @@ class RenderViewImplTest : public content::RenderViewTest {
mock_keyboard_.reset(new MockKeyboard());
}
virtual void SetUp() OVERRIDE {
content::RenderViewTest::SetUp();
content::ShellMainDelegate::InitializeResourceBundle();
}
RenderViewImpl* view() {
return static_cast<RenderViewImpl*>(view_);
}
......@@ -240,6 +301,16 @@ TEST_F(RenderViewImplTest, OnNavStateChanged) {
}
TEST_F(RenderViewImplTest, DecideNavigationPolicy) {
WebUITestClient client;
WebUITestBrowserClient browser_client;
content::ContentClient* old_client = content::GetContentClient();
content::ContentBrowserClient* old_browser_client =
content::GetContentClient()->browser();
content::SetContentClient(&client);
content::GetContentClient()->set_browser_for_testing(&browser_client);
client.set_renderer_for_testing(old_client->renderer());
// Navigations to normal HTTP URLs can be handled locally.
WebKit::WebURLRequest request(GURL("http://foo.com"));
WebKit::WebNavigationPolicy policy = view()->decidePolicyForNavigation(
......@@ -273,6 +344,9 @@ TEST_F(RenderViewImplTest, DecideNavigationPolicy) {
WebKit::WebNavigationPolicyNewForegroundTab,
false);
EXPECT_EQ(WebKit::WebNavigationPolicyIgnore, policy);
content::GetContentClient()->set_browser_for_testing(old_browser_client);
content::SetContentClient(old_client);
}
TEST_F(RenderViewImplTest, DecideNavigationPolicyForWebUI) {
......
......@@ -7,6 +7,7 @@
#include "content/public/browser/native_web_keyboard_event.h"
#include "content/public/test/render_view_test.h"
#include "content/renderer/render_view_impl.h"
#include "content/shell/shell_main_delegate.h"
#include "testing/gtest/include/gtest/gtest.h"
#include <Cocoa/Cocoa.h>
......@@ -44,6 +45,7 @@ NSEvent* CmdDeadKeyEvent(NSEventType type, unsigned short code) {
// Test that cmd-up/down scrolls the page exactly if it is not intercepted by
// javascript.
TEST_F(RenderViewTest, MacTestCmdUp) {
content::ShellMainDelegate::InitializeResourceBundle();
// Some preprocessor trickery so that we can have literal html in our source,
// makes it easier to copy html to and from an html file for testing (the
// preprocessor will remove the newlines at the line ends, turning this into
......
......@@ -8,6 +8,7 @@
#include "content/common/view_messages.h"
#include "content/renderer/render_view_impl.h"
#include "content/public/test/render_view_test.h"
#include "content/shell/shell_main_delegate.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebSize.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h"
......@@ -25,6 +26,7 @@ class RendererAccessibilityTest : public content::RenderViewTest {
virtual void SetUp() {
content::RenderViewTest::SetUp();
sink_ = &render_thread_->sink();
content::ShellMainDelegate::InitializeResourceBundle();
}
void SetMode(AccessibilityMode mode) {
......
......@@ -32,9 +32,9 @@ class ShellMainDelegate : public ContentMainDelegate {
virtual ContentBrowserClient* CreateContentBrowserClient() OVERRIDE;
virtual ContentRendererClient* CreateContentRendererClient() OVERRIDE;
private:
void InitializeResourceBundle();
static void InitializeResourceBundle();
private:
scoped_ptr<ShellContentBrowserClient> browser_client_;
scoped_ptr<ShellContentRendererClient> renderer_client_;
ShellContentClient content_client_;
......
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