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

Unified Diff: content/browser/site_instance_impl_unittest.cc

Issue 11346016: Move remaining content test code into the content namespace. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: 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/plugin_browsertest.cc ('k') | content/public/test/accessibility_test_utils_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
===================================================================
--- content/browser/site_instance_impl_unittest.cc (revision 164732)
+++ content/browser/site_instance_impl_unittest.cc (working copy)
@@ -28,18 +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 {
const char kSameAsAnyInstanceURL[] = "about:internets";
@@ -47,7 +36,7 @@
const char kPrivilegedScheme[] = "privileged";
class SiteInstanceTestWebUIControllerFactory
- : public content::WebUIControllerFactory {
+ : public WebUIControllerFactory {
public:
virtual WebUIController* CreateWebUIControllerForURL(
WebUI* web_ui, const GURL& url) const OVERRIDE {
@@ -59,11 +48,11 @@
}
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 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 @@
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 @@
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 @@
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 @@
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 @@
// 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 @@
// 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 @@
&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 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 @@
// 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 @@
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,10 +455,8 @@
// 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(
- site_instance_a2_2->GetProcess());
+ 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());
// Should be able to see that we do have SiteInstances.
@@ -505,8 +485,7 @@
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,8 +494,7 @@
static_cast<SiteInstanceImpl*>(
browsing_instance->GetSiteInstanceForURL(url_a1)));
EXPECT_TRUE(site_instance_a1.get() != NULL);
- scoped_ptr<content::RenderProcessHost> process_a1(
- site_instance_a1->GetProcess());
+ scoped_ptr<RenderProcessHost> process_a1(site_instance_a1->GetProcess());
// A separate site should create a separate SiteInstance.
const GURL url_b1("http://www.yahoo.com/");
@@ -551,16 +529,14 @@
// 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(
- site_instance_a2_3->GetProcess());
+ 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());
@@ -587,8 +563,8 @@
}
static SiteInstanceImpl* CreateSiteInstance(
- content::BrowserContext* browser_context,
- content::RenderProcessHostFactory* factory,
+ BrowserContext* browser_context,
+ RenderProcessHostFactory* factory,
const GURL& url) {
SiteInstanceImpl* instance =
reinterpret_cast<SiteInstanceImpl*>(
@@ -605,10 +581,9 @@
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 +596,7 @@
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 +611,13 @@
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 +630,8 @@
// 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 +659,5 @@
DrainMessageLoops();
}
+
+} // namespace content
« no previous file with comments | « content/browser/plugin_browsertest.cc ('k') | content/public/test/accessibility_test_utils_win.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698