| OLD | NEW |
| 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/logging.h" | 5 #include "base/logging.h" |
| 6 #include "base/strings/utf_string_conversions.h" | 6 #include "base/strings/utf_string_conversions.h" |
| 7 #include "content/browser/frame_host/interstitial_page_impl.h" | 7 #include "content/browser/frame_host/interstitial_page_impl.h" |
| 8 #include "content/browser/frame_host/navigation_entry_impl.h" | 8 #include "content/browser/frame_host/navigation_entry_impl.h" |
| 9 #include "content/browser/renderer_host/cross_site_transferring_request.h" | 9 #include "content/browser/renderer_host/cross_site_transferring_request.h" |
| 10 #include "content/browser/renderer_host/render_view_host_impl.h" | 10 #include "content/browser/renderer_host/render_view_host_impl.h" |
| (...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 296 } // namespace | 296 } // namespace |
| 297 | 297 |
| 298 // Test to make sure that title updates get stripped of whitespace. | 298 // Test to make sure that title updates get stripped of whitespace. |
| 299 TEST_F(WebContentsImplTest, UpdateTitle) { | 299 TEST_F(WebContentsImplTest, UpdateTitle) { |
| 300 NavigationControllerImpl& cont = | 300 NavigationControllerImpl& cont = |
| 301 static_cast<NavigationControllerImpl&>(controller()); | 301 static_cast<NavigationControllerImpl&>(controller()); |
| 302 FrameHostMsg_DidCommitProvisionalLoad_Params params; | 302 FrameHostMsg_DidCommitProvisionalLoad_Params params; |
| 303 InitNavigateParams(¶ms, 0, GURL(kAboutBlankURL), PAGE_TRANSITION_TYPED); | 303 InitNavigateParams(¶ms, 0, GURL(kAboutBlankURL), PAGE_TRANSITION_TYPED); |
| 304 | 304 |
| 305 LoadCommittedDetails details; | 305 LoadCommittedDetails details; |
| 306 cont.RendererDidNavigate(test_rvh(), params, &details); | 306 cont.RendererDidNavigate(main_test_rfh(), params, &details); |
| 307 | 307 |
| 308 contents()->UpdateTitle(rvh(), 0, | 308 contents()->UpdateTitle(rvh(), 0, |
| 309 base::ASCIIToUTF16(" Lots O' Whitespace\n"), | 309 base::ASCIIToUTF16(" Lots O' Whitespace\n"), |
| 310 base::i18n::LEFT_TO_RIGHT); | 310 base::i18n::LEFT_TO_RIGHT); |
| 311 EXPECT_EQ(base::ASCIIToUTF16("Lots O' Whitespace"), contents()->GetTitle()); | 311 EXPECT_EQ(base::ASCIIToUTF16("Lots O' Whitespace"), contents()->GetTitle()); |
| 312 } | 312 } |
| 313 | 313 |
| 314 TEST_F(WebContentsImplTest, DontUseTitleFromPendingEntry) { | 314 TEST_F(WebContentsImplTest, DontUseTitleFromPendingEntry) { |
| 315 const GURL kGURL("chrome://blah"); | 315 const GURL kGURL("chrome://blah"); |
| 316 controller().LoadURL( | 316 controller().LoadURL( |
| (...skipping 26 matching lines...) Expand all Loading... |
| 343 cont.LoadURL( | 343 cont.LoadURL( |
| 344 kGURL, Referrer(), PAGE_TRANSITION_TYPED, std::string()); | 344 kGURL, Referrer(), PAGE_TRANSITION_TYPED, std::string()); |
| 345 rvh()->GetDelegate()->RenderViewCreated(rvh()); | 345 rvh()->GetDelegate()->RenderViewCreated(rvh()); |
| 346 // Did we get the expected message? | 346 // Did we get the expected message? |
| 347 EXPECT_TRUE(process()->sink().GetFirstMessageMatching( | 347 EXPECT_TRUE(process()->sink().GetFirstMessageMatching( |
| 348 ViewMsg_EnableViewSourceMode::ID)); | 348 ViewMsg_EnableViewSourceMode::ID)); |
| 349 | 349 |
| 350 FrameHostMsg_DidCommitProvisionalLoad_Params params; | 350 FrameHostMsg_DidCommitProvisionalLoad_Params params; |
| 351 InitNavigateParams(¶ms, 0, kGURL, PAGE_TRANSITION_TYPED); | 351 InitNavigateParams(¶ms, 0, kGURL, PAGE_TRANSITION_TYPED); |
| 352 LoadCommittedDetails details; | 352 LoadCommittedDetails details; |
| 353 cont.RendererDidNavigate(test_rvh(), params, &details); | 353 cont.RendererDidNavigate(main_test_rfh(), params, &details); |
| 354 // Also check title and url. | 354 // Also check title and url. |
| 355 EXPECT_EQ(base::ASCIIToUTF16(kUrl), contents()->GetTitle()); | 355 EXPECT_EQ(base::ASCIIToUTF16(kUrl), contents()->GetTitle()); |
| 356 } | 356 } |
| 357 | 357 |
| 358 // Test to ensure UpdateMaxPageID is working properly. | 358 // Test to ensure UpdateMaxPageID is working properly. |
| 359 TEST_F(WebContentsImplTest, UpdateMaxPageID) { | 359 TEST_F(WebContentsImplTest, UpdateMaxPageID) { |
| 360 SiteInstance* instance1 = contents()->GetSiteInstance(); | 360 SiteInstance* instance1 = contents()->GetSiteInstance(); |
| 361 scoped_refptr<SiteInstance> instance2(SiteInstance::Create(NULL)); | 361 scoped_refptr<SiteInstance> instance2(SiteInstance::Create(NULL)); |
| 362 | 362 |
| 363 // Starts at -1. | 363 // Starts at -1. |
| (...skipping 1862 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2226 // Reset the last active time to a known-bad value. | 2226 // Reset the last active time to a known-bad value. |
| 2227 contents()->last_active_time_ = base::TimeTicks(); | 2227 contents()->last_active_time_ = base::TimeTicks(); |
| 2228 ASSERT_TRUE(contents()->GetLastActiveTime().is_null()); | 2228 ASSERT_TRUE(contents()->GetLastActiveTime().is_null()); |
| 2229 | 2229 |
| 2230 // Simulate activating the WebContents. The active time should update. | 2230 // Simulate activating the WebContents. The active time should update. |
| 2231 contents()->WasShown(); | 2231 contents()->WasShown(); |
| 2232 EXPECT_FALSE(contents()->GetLastActiveTime().is_null()); | 2232 EXPECT_FALSE(contents()->GetLastActiveTime().is_null()); |
| 2233 } | 2233 } |
| 2234 | 2234 |
| 2235 } // namespace content | 2235 } // namespace content |
| OLD | NEW |