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

Side by Side Diff: content/browser/site_instance_impl_unittest.cc

Issue 10073023: TabContents -> WebContentsImpl, part 14. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 8 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/compiler_specific.h" 5 #include "base/compiler_specific.h"
6 #include "base/stl_util.h" 6 #include "base/stl_util.h"
7 #include "base/string16.h" 7 #include "base/string16.h"
8 #include "content/browser/browser_thread_impl.h" 8 #include "content/browser/browser_thread_impl.h"
9 #include "content/browser/browsing_instance.h" 9 #include "content/browser/browsing_instance.h"
10 #include "content/browser/child_process_security_policy_impl.h" 10 #include "content/browser/child_process_security_policy_impl.h"
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 (*delete_counter_)++; 199 (*delete_counter_)++;
200 } 200 }
201 201
202 int* delete_counter_; 202 int* delete_counter_;
203 }; 203 };
204 204
205 } // namespace 205 } // namespace
206 206
207 // Test to ensure no memory leaks for SiteInstance objects. 207 // Test to ensure no memory leaks for SiteInstance objects.
208 TEST_F(SiteInstanceTest, SiteInstanceDestructor) { 208 TEST_F(SiteInstanceTest, SiteInstanceDestructor) {
209 // The existence of this object will cause TabContents to create our 209 // The existence of this object will cause WebContentsImpl to create our
210 // test one instead of the real one. 210 // test one instead of the real one.
211 content::RenderViewHostTestEnabler rvh_test_enabler; 211 content::RenderViewHostTestEnabler rvh_test_enabler;
212 int site_delete_counter = 0; 212 int site_delete_counter = 0;
213 int browsing_delete_counter = 0; 213 int browsing_delete_counter = 0;
214 const GURL url("test:foo"); 214 const GURL url("test:foo");
215 215
216 // Ensure that instances are deleted when their NavigationEntries are gone. 216 // Ensure that instances are deleted when their NavigationEntries are gone.
217 TestSiteInstance* instance = 217 TestSiteInstance* instance =
218 TestSiteInstance::CreateTestSiteInstance(NULL, &site_delete_counter, 218 TestSiteInstance::CreateTestSiteInstance(NULL, &site_delete_counter,
219 &browsing_delete_counter); 219 &browsing_delete_counter);
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
251 { 251 {
252 WebContentsImpl web_contents(browser_context.get(), 252 WebContentsImpl web_contents(browser_context.get(),
253 instance, 253 instance,
254 MSG_ROUTING_NONE, 254 MSG_ROUTING_NONE,
255 NULL, 255 NULL,
256 NULL); 256 NULL);
257 EXPECT_EQ(1, site_delete_counter); 257 EXPECT_EQ(1, site_delete_counter);
258 EXPECT_EQ(1, browsing_delete_counter); 258 EXPECT_EQ(1, browsing_delete_counter);
259 } 259 }
260 260
261 // Make sure that we flush any messages related to the above TabContents 261 // Make sure that we flush any messages related to the above WebContentsImpl
262 // destruction. 262 // destruction.
263 MessageLoop::current()->RunAllPending(); 263 MessageLoop::current()->RunAllPending();
264 264
265 EXPECT_EQ(2, site_delete_counter); 265 EXPECT_EQ(2, site_delete_counter);
266 EXPECT_EQ(2, browsing_delete_counter); 266 EXPECT_EQ(2, browsing_delete_counter);
267 // contents is now deleted, along with instance and browsing_instance 267 // contents is now deleted, along with instance and browsing_instance
268 } 268 }
269 269
270 // Test that NavigationEntries with SiteInstances can be cloned, but that their 270 // Test that NavigationEntries with SiteInstances can be cloned, but that their
271 // SiteInstances can be changed afterwards. Also tests that the ref counts are 271 // SiteInstances can be changed afterwards. Also tests that the ref counts are
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after
614 host.reset(instance->GetProcess()); 614 host.reset(instance->GetProcess());
615 EXPECT_TRUE(host.get() != NULL); 615 EXPECT_TRUE(host.get() != NULL);
616 EXPECT_TRUE(instance->HasProcess()); 616 EXPECT_TRUE(instance->HasProcess());
617 617
618 EXPECT_FALSE(instance->HasWrongProcessForURL(GURL("http://evernote.com"))); 618 EXPECT_FALSE(instance->HasWrongProcessForURL(GURL("http://evernote.com")));
619 EXPECT_FALSE(instance->HasWrongProcessForURL( 619 EXPECT_FALSE(instance->HasWrongProcessForURL(
620 GURL("javascript:alert(document.location.href);"))); 620 GURL("javascript:alert(document.location.href);")));
621 621
622 EXPECT_TRUE(instance->HasWrongProcessForURL(GURL("chrome://settings"))); 622 EXPECT_TRUE(instance->HasWrongProcessForURL(GURL("chrome://settings")));
623 } 623 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698