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

Unified Diff: content/browser/site_instance_impl_unittest.cc

Issue 11274038: content/browser: Move more files into the content namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix win - part2 Created 8 years, 2 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_impl.cc ('k') | content/browser/system_message_window_win.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/site_instance_impl_unittest.cc
diff --git a/content/browser/site_instance_impl_unittest.cc b/content/browser/site_instance_impl_unittest.cc
index 21e6914c5ae94a5c6f4cfdc1c1cecf0fa735bee3..ee14b162294a2e2a03646c75268d87cb8b571818 100644
--- a/content/browser/site_instance_impl_unittest.cc
+++ b/content/browser/site_instance_impl_unittest.cc
@@ -28,17 +28,7 @@
#include "googleurl/src/url_util.h"
#include "testing/gtest/include/gtest/gtest.h"
-using content::BrowserContext;
-using content::BrowserThread;
-using content::BrowserThreadImpl;
-using content::MockRenderProcessHost;
-using content::MockRenderProcessHostFactory;
-using content::NavigationEntry;
-using content::NavigationEntryImpl;
-using content::SiteInstance;
-using content::WebContentsImpl;
-using content::WebUI;
-using content::WebUIController;
+namespace content {
namespace {
@@ -46,8 +36,7 @@ const char kSameAsAnyInstanceURL[] = "about:internets";
const char kPrivilegedScheme[] = "privileged";
-class SiteInstanceTestWebUIControllerFactory
- : public content::WebUIControllerFactory {
+class SiteInstanceTestWebUIControllerFactory : public WebUIControllerFactory {
public:
virtual WebUIController* CreateWebUIControllerForURL(
WebUI* web_ui, const GURL& url) const OVERRIDE {
@@ -59,11 +48,11 @@ class SiteInstanceTestWebUIControllerFactory
}
virtual bool UseWebUIForURL(BrowserContext* browser_context,
const GURL& url) const OVERRIDE {
- return content::GetContentClient()->HasWebUIScheme(url);
+ return GetContentClient()->HasWebUIScheme(url);
}
virtual bool UseWebUIBindingsForURL(BrowserContext* browser_context,
const GURL& url) const OVERRIDE {
- return content::GetContentClient()->HasWebUIScheme(url);
+ return GetContentClient()->HasWebUIScheme(url);
}
virtual bool IsURLAcceptableForWebUI(
BrowserContext* browser_context,
@@ -83,18 +72,17 @@ class SiteInstanceTestClient : public TestContentClient {
}
};
-class SiteInstanceTestBrowserClient : public content::TestContentBrowserClient {
+class SiteInstanceTestBrowserClient : public TestContentBrowserClient {
public:
SiteInstanceTestBrowserClient()
: privileged_process_id_(-1) {
}
- virtual content::WebUIControllerFactory*
- GetWebUIControllerFactory() OVERRIDE {
+ virtual WebUIControllerFactory* GetWebUIControllerFactory() OVERRIDE {
return &factory_;
}
- virtual bool IsSuitableHost(content::RenderProcessHost* process_host,
+ virtual bool IsSuitableHost(RenderProcessHost* process_host,
const GURL& site_url) OVERRIDE {
return (privileged_process_id_ == process_host->GetID()) ==
site_url.SchemeIs(kPrivilegedScheme);
@@ -113,28 +101,28 @@ class SiteInstanceTest : public testing::Test {
public:
SiteInstanceTest()
: ui_thread_(BrowserThread::UI, &message_loop_),
- file_user_blocking_thread_(content::BrowserThread::FILE_USER_BLOCKING,
+ file_user_blocking_thread_(BrowserThread::FILE_USER_BLOCKING,
&message_loop_),
- io_thread_(content::BrowserThread::IO, &message_loop_),
+ io_thread_(BrowserThread::IO, &message_loop_),
old_client_(NULL),
old_browser_client_(NULL) {
}
virtual void SetUp() {
- old_client_ = content::GetContentClient();
- old_browser_client_ = content::GetContentClient()->browser();
- content::SetContentClient(&client_);
- content::GetContentClient()->set_browser_for_testing(&browser_client_);
+ old_client_ = GetContentClient();
+ old_browser_client_ = GetContentClient()->browser();
+ SetContentClient(&client_);
+ GetContentClient()->set_browser_for_testing(&browser_client_);
url_util::AddStandardScheme(kPrivilegedScheme);
url_util::AddStandardScheme(chrome::kChromeUIScheme);
}
virtual void TearDown() {
// Ensure that no RenderProcessHosts are left over after the tests.
- EXPECT_TRUE(content::RenderProcessHost::AllHostsIterator().IsAtEnd());
+ EXPECT_TRUE(RenderProcessHost::AllHostsIterator().IsAtEnd());
- content::GetContentClient()->set_browser_for_testing(old_browser_client_);
- content::SetContentClient(old_client_);
+ GetContentClient()->set_browser_for_testing(old_browser_client_);
+ SetContentClient(old_client_);
// http://crbug.com/143565 found SiteInstanceTest leaking an
// AppCacheDatabase. This happens because some part of the test indirectly
@@ -162,14 +150,14 @@ class SiteInstanceTest : public testing::Test {
private:
MessageLoopForUI message_loop_;
- content::TestBrowserThread ui_thread_;
- content::TestBrowserThread file_user_blocking_thread_;
- content::TestBrowserThread io_thread_;
+ TestBrowserThread ui_thread_;
+ TestBrowserThread file_user_blocking_thread_;
+ TestBrowserThread io_thread_;
SiteInstanceTestClient client_;
SiteInstanceTestBrowserClient browser_client_;
- content::ContentClient* old_client_;
- content::ContentBrowserClient* old_browser_client_;
+ ContentClient* old_client_;
+ ContentBrowserClient* old_browser_client_;
};
// Subclass of BrowsingInstance that updates a counter when deleted and
@@ -224,7 +212,7 @@ class TestSiteInstance : public SiteInstanceImpl {
TEST_F(SiteInstanceTest, SiteInstanceDestructor) {
// The existence of this object will cause WebContentsImpl to create our
// test one instead of the real one.
- content::RenderViewHostTestEnabler rvh_test_enabler;
+ RenderViewHostTestEnabler rvh_test_enabler;
int site_delete_counter = 0;
int browsing_delete_counter = 0;
const GURL url("test:foo");
@@ -236,8 +224,7 @@ TEST_F(SiteInstanceTest, SiteInstanceDestructor) {
EXPECT_EQ(0, site_delete_counter);
NavigationEntryImpl* e1 = new NavigationEntryImpl(
- instance, 0, url, content::Referrer(), string16(),
- content::PAGE_TRANSITION_LINK, false);
+ instance, 0, url, Referrer(), string16(), PAGE_TRANSITION_LINK, false);
// Redundantly setting e1's SiteInstance shouldn't affect the ref count.
e1->set_site_instance(instance);
@@ -245,8 +232,7 @@ TEST_F(SiteInstanceTest, SiteInstanceDestructor) {
// Add a second reference
NavigationEntryImpl* e2 = new NavigationEntryImpl(
- instance, 0, url, content::Referrer(), string16(),
- content::PAGE_TRANSITION_LINK, false);
+ instance, 0, url, Referrer(), string16(), PAGE_TRANSITION_LINK, false);
// Now delete both entries and be sure the SiteInstance goes away.
delete e1;
@@ -259,8 +245,7 @@ TEST_F(SiteInstanceTest, SiteInstanceDestructor) {
// browsing_instance is now deleted
// Ensure that instances are deleted when their RenderViewHosts are gone.
- scoped_ptr<content::TestBrowserContext> browser_context(
- new content::TestBrowserContext());
+ scoped_ptr<TestBrowserContext> browser_context(new TestBrowserContext());
instance =
TestSiteInstance::CreateTestSiteInstance(browser_context.get(),
&site_delete_counter,
@@ -299,8 +284,7 @@ TEST_F(SiteInstanceTest, CloneNavigationEntry) {
&browsing_delete_counter);
NavigationEntryImpl* e1 = new NavigationEntryImpl(
- instance1, 0, url, content::Referrer(), string16(),
- content::PAGE_TRANSITION_LINK, false);
+ instance1, 0, url, Referrer(), string16(), PAGE_TRANSITION_LINK, false);
// Clone the entry
NavigationEntryImpl* e2 = new NavigationEntryImpl(*e1);
@@ -327,9 +311,8 @@ TEST_F(SiteInstanceTest, CloneNavigationEntry) {
// Test to ensure GetProcess returns and creates processes correctly.
TEST_F(SiteInstanceTest, GetProcess) {
// Ensure that GetProcess returns a process.
- scoped_ptr<content::TestBrowserContext> browser_context(
- new content::TestBrowserContext());
- scoped_ptr<content::RenderProcessHost> host1;
+ scoped_ptr<TestBrowserContext> browser_context(new TestBrowserContext());
+ scoped_ptr<RenderProcessHost> host1;
scoped_refptr<SiteInstanceImpl> instance(static_cast<SiteInstanceImpl*>(
SiteInstance::Create(browser_context.get())));
host1.reset(instance->GetProcess());
@@ -338,7 +321,7 @@ TEST_F(SiteInstanceTest, GetProcess) {
// Ensure that GetProcess creates a new process.
scoped_refptr<SiteInstanceImpl> instance2(static_cast<SiteInstanceImpl*>(
SiteInstance::Create(browser_context.get())));
- scoped_ptr<content::RenderProcessHost> host2(instance2->GetProcess());
+ scoped_ptr<RenderProcessHost> host2(instance2->GetProcess());
EXPECT_TRUE(host2.get() != NULL);
EXPECT_NE(host1.get(), host2.get());
@@ -429,8 +412,7 @@ TEST_F(SiteInstanceTest, OneSiteInstancePerSite) {
ASSERT_FALSE(CommandLine::ForCurrentProcess()->HasSwitch(
switches::kProcessPerSite));
int delete_counter = 0;
- scoped_ptr<content::TestBrowserContext> browser_context(
- new content::TestBrowserContext());
+ scoped_ptr<TestBrowserContext> browser_context(new TestBrowserContext());
TestBrowsingInstance* browsing_instance =
new TestBrowsingInstance(browser_context.get(), &delete_counter);
@@ -473,9 +455,8 @@ TEST_F(SiteInstanceTest, OneSiteInstancePerSite) {
// The two SiteInstances for http://google.com should not use the same process
// if process-per-site is not enabled.
- scoped_ptr<content::RenderProcessHost> process_a1(
- site_instance_a1->GetProcess());
- scoped_ptr<content::RenderProcessHost> process_a2_2(
+ scoped_ptr<RenderProcessHost> process_a1(site_instance_a1->GetProcess());
+ scoped_ptr<RenderProcessHost> process_a2_2(
site_instance_a2_2->GetProcess());
EXPECT_NE(process_a1.get(), process_a2_2.get());
@@ -505,8 +486,7 @@ TEST_F(SiteInstanceTest, OneSiteInstancePerSiteInBrowserContext) {
CommandLine::ForCurrentProcess()->AppendSwitch(
switches::kProcessPerSite);
int delete_counter = 0;
- scoped_ptr<content::TestBrowserContext> browser_context(
- new content::TestBrowserContext());
+ scoped_ptr<TestBrowserContext> browser_context(new TestBrowserContext());
TestBrowsingInstance* browsing_instance =
new TestBrowsingInstance(browser_context.get(), &delete_counter);
@@ -515,7 +495,7 @@ TEST_F(SiteInstanceTest, OneSiteInstancePerSiteInBrowserContext) {
static_cast<SiteInstanceImpl*>(
browsing_instance->GetSiteInstanceForURL(url_a1)));
EXPECT_TRUE(site_instance_a1.get() != NULL);
- scoped_ptr<content::RenderProcessHost> process_a1(
+ scoped_ptr<RenderProcessHost> process_a1(
site_instance_a1->GetProcess());
// A separate site should create a separate SiteInstance.
@@ -551,15 +531,14 @@ TEST_F(SiteInstanceTest, OneSiteInstancePerSiteInBrowserContext) {
// A visit to the original site in a new BrowsingInstance (different browser
// context) should return a different SiteInstance with a different process.
- scoped_ptr<content::TestBrowserContext> browser_context2(
- new content::TestBrowserContext());
+ scoped_ptr<TestBrowserContext> browser_context2(new TestBrowserContext());
TestBrowsingInstance* browsing_instance3 =
new TestBrowsingInstance(browser_context2.get(), &delete_counter);
scoped_refptr<SiteInstanceImpl> site_instance_a2_3(
static_cast<SiteInstanceImpl*>(
browsing_instance3->GetSiteInstanceForURL(url_a2)));
EXPECT_TRUE(site_instance_a2_3.get() != NULL);
- scoped_ptr<content::RenderProcessHost> process_a2_3(
+ scoped_ptr<RenderProcessHost> process_a2_3(
site_instance_a2_3->GetProcess());
EXPECT_NE(site_instance_a1.get(), site_instance_a2_3.get());
EXPECT_NE(process_a1.get(), process_a2_3.get());
@@ -586,10 +565,9 @@ TEST_F(SiteInstanceTest, OneSiteInstancePerSiteInBrowserContext) {
DrainMessageLoops();
}
-static SiteInstanceImpl* CreateSiteInstance(
- content::BrowserContext* browser_context,
- content::RenderProcessHostFactory* factory,
- const GURL& url) {
+static SiteInstanceImpl* CreateSiteInstance(BrowserContext* browser_context,
+ RenderProcessHostFactory* factory,
+ const GURL& url) {
SiteInstanceImpl* instance =
reinterpret_cast<SiteInstanceImpl*>(
SiteInstance::CreateForURL(browser_context, url));
@@ -605,10 +583,9 @@ TEST_F(SiteInstanceTest, ProcessSharingByType) {
ChildProcessSecurityPolicyImpl::GetInstance();
// Make a bunch of mock renderers so that we hit the limit.
- scoped_ptr<content::TestBrowserContext> browser_context(
- new content::TestBrowserContext());
+ scoped_ptr<TestBrowserContext> browser_context(new TestBrowserContext());
std::vector<MockRenderProcessHost*> hosts;
- for (size_t i = 0; i < content::kMaxRendererProcessCount; ++i)
+ for (size_t i = 0; i < kMaxRendererProcessCount; ++i)
hosts.push_back(new MockRenderProcessHost(browser_context.get()));
// Create some extension instances and make sure they share a process.
@@ -621,7 +598,7 @@ TEST_F(SiteInstanceTest, ProcessSharingByType) {
CreateSiteInstance(browser_context.get(), &rph_factory,
GURL(kPrivilegedScheme + std::string("://baz/bar"))));
- scoped_ptr<content::RenderProcessHost> extension_host(
+ scoped_ptr<RenderProcessHost> extension_host(
extension1_instance->GetProcess());
EXPECT_EQ(extension1_instance->GetProcess(),
extension2_instance->GetProcess());
@@ -636,14 +613,13 @@ TEST_F(SiteInstanceTest, ProcessSharingByType) {
browser_context.get(), &rph_factory,
GURL(chrome::kChromeUIScheme + std::string("://history"))));
- scoped_ptr<content::RenderProcessHost> dom_host(
- webui1_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(), webui1_instance->GetProcess());
- for (size_t i = 0; i < content::kMaxRendererProcessCount; ++i) {
+ for (size_t i = 0; i < kMaxRendererProcessCount; ++i) {
EXPECT_NE(extension1_instance->GetProcess(), hosts[i]);
EXPECT_NE(webui1_instance->GetProcess(), hosts[i]);
}
@@ -656,9 +632,8 @@ TEST_F(SiteInstanceTest, ProcessSharingByType) {
// Test to ensure that HasWrongProcessForURL behaves properly for different
// types of URLs.
TEST_F(SiteInstanceTest, HasWrongProcessForURL) {
- scoped_ptr<content::TestBrowserContext> browser_context(
- new content::TestBrowserContext());
- scoped_ptr<content::RenderProcessHost> host;
+ scoped_ptr<TestBrowserContext> browser_context(new TestBrowserContext());
+ scoped_ptr<RenderProcessHost> host;
scoped_refptr<SiteInstanceImpl> instance(static_cast<SiteInstanceImpl*>(
SiteInstance::Create(browser_context.get())));
@@ -686,3 +661,5 @@ TEST_F(SiteInstanceTest, HasWrongProcessForURL) {
DrainMessageLoops();
}
+
+} // namespace content
« no previous file with comments | « content/browser/site_instance_impl.cc ('k') | content/browser/system_message_window_win.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698