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

Unified Diff: content/browser/site_instance_unittest.cc

Issue 6731060: Move WebUIFactory to chrome/, try 2. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 9 years, 9 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
« no previous file with comments | « content/browser/site_instance.cc ('k') | content/browser/tab_contents/render_view_host_manager.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/site_instance_unittest.cc
diff --git a/content/browser/site_instance_unittest.cc b/content/browser/site_instance_unittest.cc
index 1b072aac162ff08b08bac962c3c4b8a5a4c9e4b7..247dd133c86703b7d94423f866b2157c63c5594a 100644
--- a/content/browser/site_instance_unittest.cc
+++ b/content/browser/site_instance_unittest.cc
@@ -10,21 +10,55 @@
#include "chrome/common/url_constants.h"
#include "chrome/test/testing_profile.h"
#include "content/browser/browsing_instance.h"
-#include "testing/gtest/include/gtest/gtest.h"
-#include "content/browser/browsing_instance.h"
#include "content/browser/child_process_security_policy.h"
+#include "content/browser/content_browser_client.h"
#include "content/browser/renderer_host/render_view_host.h"
-#include "content/browser/site_instance.h"
#include "content/browser/renderer_host/test_render_view_host.h"
+#include "content/browser/site_instance.h"
#include "content/browser/tab_contents/navigation_entry.h"
#include "content/browser/tab_contents/tab_contents.h"
+#include "content/browser/webui/empty_web_ui_factory.h"
+#include "content/common/content_client.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace {
+
+// TODO(estade): this shouldn't need to be chrome:, but it does (or else GURL
+// doesn't think that the webui URLs have a host). Figure out where this is
+// coming from and fix it.
+const char kWebUIScheme[] = "chrome";
+
+class SiteInstanceTestWebUIFactory : public content::EmptyWebUIFactory {
+ public:
+ virtual bool UseWebUIForURL(Profile* profile, const GURL& url) const {
+ return HasWebUIScheme(url);
+ }
+ virtual bool HasWebUIScheme(const GURL& url) const {
+ return url.SchemeIs(kWebUIScheme);
+ }
+};
+
+class SiteInstanceTestBrowserClient : public content::ContentBrowserClient {
+ public:
+ virtual content::WebUIFactory* GetWebUIFactory() {
+ return &factory_;
+ }
+
+ private:
+ SiteInstanceTestWebUIFactory factory_;
+};
class SiteInstanceTest : public testing::Test {
+ public:
+ virtual void SetUp() {
+ content::GetContentClient()->set_browser(&browser_client_);
+ }
+
private:
MessageLoopForUI message_loop_;
-};
-namespace {
+ SiteInstanceTestBrowserClient browser_client_;
+};
class TestBrowsingInstance : public BrowsingInstance {
public:
@@ -51,14 +85,13 @@ class TestBrowsingInstance : public BrowsingInstance {
int* deleteCounter_;
};
-
class TestSiteInstance : public SiteInstance {
public:
static TestSiteInstance* CreateTestSiteInstance(Profile* profile,
int* siteDeleteCounter,
int* browsingDeleteCounter) {
TestBrowsingInstance* browsing_instance =
- new TestBrowsingInstance(profile, browsingDeleteCounter);
+ new TestBrowsingInstance(profile, browsingDeleteCounter);
return new TestSiteInstance(browsing_instance, siteDeleteCounter);
}
@@ -441,22 +474,24 @@ TEST_F(SiteInstanceTest, ProcessSharingByType) {
extension2_instance->GetProcess());
// Create some WebUI instances and make sure they share a process.
- scoped_refptr<SiteInstance> dom1_instance(
- CreateSiteInstance(&rph_factory, GURL("chrome://newtab")));
- policy->GrantWebUIBindings(dom1_instance->GetProcess()->id());
+ scoped_refptr<SiteInstance> webui1_instance(
+ CreateSiteInstance(&rph_factory,
+ GURL(kWebUIScheme + std::string("://newtab"))));
+ policy->GrantWebUIBindings(webui1_instance->GetProcess()->id());
- scoped_refptr<SiteInstance> dom2_instance(
- CreateSiteInstance(&rph_factory, GURL("chrome://history")));
+ scoped_refptr<SiteInstance> webui2_instance(
+ CreateSiteInstance(&rph_factory,
+ GURL(kWebUIScheme + std::string("://history"))));
- scoped_ptr<RenderProcessHost> dom_host(dom1_instance->GetProcess());
- EXPECT_EQ(dom1_instance->GetProcess(), dom2_instance->GetProcess());
+ scoped_ptr<RenderProcessHost> dom_host(webui1_instance->GetProcess());
+ EXPECT_EQ(webui1_instance->GetProcess(), webui2_instance->GetProcess());
// Make sure none of differing privilege processes are mixed.
- EXPECT_NE(extension1_instance->GetProcess(), dom1_instance->GetProcess());
+ EXPECT_NE(extension1_instance->GetProcess(), webui1_instance->GetProcess());
for (size_t i = 0; i < chrome::kMaxRendererProcessCount; ++i) {
EXPECT_NE(extension1_instance->GetProcess(), hosts[i]);
- EXPECT_NE(dom1_instance->GetProcess(), hosts[i]);
+ EXPECT_NE(webui1_instance->GetProcess(), hosts[i]);
}
STLDeleteContainerPointers(hosts.begin(), hosts.end());
« no previous file with comments | « content/browser/site_instance.cc ('k') | content/browser/tab_contents/render_view_host_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698