| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/string16.h" | 5 #include "base/string16.h" |
| 6 #include "chrome/browser/renderer_host/browser_render_process_host.h" | 6 #include "chrome/browser/renderer_host/browser_render_process_host.h" |
| 7 #include "chrome/browser/renderer_host/render_view_host.h" | 7 #include "chrome/browser/renderer_host/render_view_host.h" |
| 8 #include "chrome/browser/tab_contents/navigation_entry.h" | 8 #include "chrome/browser/tab_contents/navigation_entry.h" |
| 9 #include "chrome/browser/tab_contents/web_contents.h" | 9 #include "chrome/browser/tab_contents/web_contents.h" |
| 10 #include "chrome/common/render_messages.h" | 10 #include "chrome/common/render_messages.h" |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 EXPECT_EQ(-1, instance.get()->max_page_id()); | 170 EXPECT_EQ(-1, instance.get()->max_page_id()); |
| 171 | 171 |
| 172 // Make sure max_page_id_ is monotonically increasing. | 172 // Make sure max_page_id_ is monotonically increasing. |
| 173 instance.get()->UpdateMaxPageID(3); | 173 instance.get()->UpdateMaxPageID(3); |
| 174 instance.get()->UpdateMaxPageID(1); | 174 instance.get()->UpdateMaxPageID(1); |
| 175 EXPECT_EQ(3, instance.get()->max_page_id()); | 175 EXPECT_EQ(3, instance.get()->max_page_id()); |
| 176 } | 176 } |
| 177 | 177 |
| 178 // Test to ensure GetProcess returns and creates processes correctly. | 178 // Test to ensure GetProcess returns and creates processes correctly. |
| 179 TEST_F(SiteInstanceTest, GetProcess) { | 179 TEST_F(SiteInstanceTest, GetProcess) { |
| 180 // Ensure that GetProcess returns the process based on its host id. | 180 // Ensure that GetProcess returns a process. |
| 181 scoped_ptr<TestingProfile> profile(new TestingProfile()); | 181 scoped_ptr<TestingProfile> profile(new TestingProfile()); |
| 182 scoped_ptr<BrowserRenderProcessHost> host1( | 182 scoped_ptr<RenderProcessHost> host1; |
| 183 new BrowserRenderProcessHost(profile.get())); | |
| 184 scoped_refptr<SiteInstance> instance( | 183 scoped_refptr<SiteInstance> instance( |
| 185 SiteInstance::CreateSiteInstance(profile.get())); | 184 SiteInstance::CreateSiteInstance(profile.get())); |
| 186 instance.get()->set_process_host_id(host1.get()->host_id()); | 185 host1.reset(instance.get()->GetProcess()); |
| 187 EXPECT_EQ(host1.get(), instance.get()->GetProcess()); | 186 EXPECT_TRUE(host1.get() != NULL); |
| 188 | 187 |
| 189 // Ensure that GetProcess creates a new process if no host id is set. | 188 // Ensure that GetProcess creates a new process. |
| 190 scoped_refptr<SiteInstance> instance2( | 189 scoped_refptr<SiteInstance> instance2( |
| 191 SiteInstance::CreateSiteInstance(profile.get())); | 190 SiteInstance::CreateSiteInstance(profile.get())); |
| 192 scoped_ptr<RenderProcessHost> host2(instance2.get()->GetProcess()); | 191 scoped_ptr<RenderProcessHost> host2(instance2.get()->GetProcess()); |
| 193 EXPECT_TRUE(host2.get() != NULL); | 192 EXPECT_TRUE(host2.get() != NULL); |
| 194 EXPECT_NE(host1.get(), host2.get()); | 193 EXPECT_NE(host1.get(), host2.get()); |
| 195 } | 194 } |
| 196 | 195 |
| 197 // Test to ensure SetSite and site() work properly. | 196 // Test to ensure SetSite and site() work properly. |
| 198 TEST_F(SiteInstanceTest, SetSite) { | 197 TEST_F(SiteInstanceTest, SetSite) { |
| 199 scoped_refptr<SiteInstance> instance(SiteInstance::CreateSiteInstance(NULL)); | 198 scoped_refptr<SiteInstance> instance(SiteInstance::CreateSiteInstance(NULL)); |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 389 GURL("http://www.yahoo.com"))); // different BI, but same profile | 388 GURL("http://www.yahoo.com"))); // different BI, but same profile |
| 390 | 389 |
| 391 // Should be able to see that we don't have SiteInstances. | 390 // Should be able to see that we don't have SiteInstances. |
| 392 EXPECT_FALSE(browsing_instance->HasSiteInstance( | 391 EXPECT_FALSE(browsing_instance->HasSiteInstance( |
| 393 GURL("https://www.google.com"))); // not visited before | 392 GURL("https://www.google.com"))); // not visited before |
| 394 EXPECT_FALSE(browsing_instance3->HasSiteInstance( | 393 EXPECT_FALSE(browsing_instance3->HasSiteInstance( |
| 395 GURL("http://www.yahoo.com"))); // different BI, different profile | 394 GURL("http://www.yahoo.com"))); // different BI, different profile |
| 396 | 395 |
| 397 // browsing_instances will be deleted when their SiteInstances are deleted | 396 // browsing_instances will be deleted when their SiteInstances are deleted |
| 398 } | 397 } |
| OLD | NEW |