Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2578)

Unified Diff: content/renderer/render_view_browsertest.cc

Issue 10832014: Move the browser tests inside content/renderer to run under content_browsertests. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: fix mac Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/renderer/render_view_browsertest.cc
===================================================================
--- content/renderer/render_view_browsertest.cc (revision 148353)
+++ content/renderer/render_view_browsertest.cc (working copy)
@@ -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 @@
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 @@
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, 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 @@
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) {
« no previous file with comments | « content/renderer/pepper/pepper_file_chooser_host_unittest.cc ('k') | content/renderer/render_view_browsertest_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698