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 "content/browser/web_contents/web_contents_view_aura.h" | 5 #include "content/browser/web_contents/web_contents_view_aura.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/run_loop.h" | 8 #include "base/run_loop.h" |
9 #include "base/test/test_timeouts.h" | 9 #include "base/test/test_timeouts.h" |
10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
271 DISABLED_OverscrollScreenshot | 271 DISABLED_OverscrollScreenshot |
272 #else | 272 #else |
273 #define MAYBE_OverscrollScreenshot \ | 273 #define MAYBE_OverscrollScreenshot \ |
274 OverscrollScreenshot | 274 OverscrollScreenshot |
275 #endif | 275 #endif |
276 // Tests that the page has has a screenshot when navigation happens: | 276 // Tests that the page has has a screenshot when navigation happens: |
277 // - from within the page (from a JS function) | 277 // - from within the page (from a JS function) |
278 // - interactively, when user does an overscroll gesture | 278 // - interactively, when user does an overscroll gesture |
279 // - interactively, when user navigates in history without the overscroll | 279 // - interactively, when user navigates in history without the overscroll |
280 // gesture. | 280 // gesture. |
| 281 // - interactively, by the user navigating to a new page from the UI (e.g. |
| 282 // entering a URL in the omnibox, or navigating to a bookmark) |
281 IN_PROC_BROWSER_TEST_F(WebContentsViewAuraTest, | 283 IN_PROC_BROWSER_TEST_F(WebContentsViewAuraTest, |
282 OverscrollScreenshot) { | 284 OverscrollScreenshot) { |
283 ASSERT_NO_FATAL_FAILURE( | 285 ASSERT_NO_FATAL_FAILURE( |
284 StartTestWithPage("files/overscroll_navigation.html")); | 286 StartTestWithPage("files/overscroll_navigation.html")); |
285 WebContentsImpl* web_contents = | 287 WebContentsImpl* web_contents = |
286 static_cast<WebContentsImpl*>(shell()->web_contents()); | 288 static_cast<WebContentsImpl*>(shell()->web_contents()); |
287 RenderViewHostImpl* view_host = static_cast<RenderViewHostImpl*>( | 289 RenderViewHostImpl* view_host = static_cast<RenderViewHostImpl*>( |
288 web_contents->GetRenderViewHost()); | 290 web_contents->GetRenderViewHost()); |
289 | 291 |
290 // Do a few navigations initiated by the page. | 292 // Do a few navigations initiated by the page. |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
354 string16 expected_title = ASCIIToUTF16("Title: #3"); | 356 string16 expected_title = ASCIIToUTF16("Title: #3"); |
355 content::TitleWatcher title_watcher(web_contents, expected_title); | 357 content::TitleWatcher title_watcher(web_contents, expected_title); |
356 web_contents->GetController().GoBack(); | 358 web_contents->GetController().GoBack(); |
357 string16 actual_title = title_watcher.WaitAndGetTitle(); | 359 string16 actual_title = title_watcher.WaitAndGetTitle(); |
358 EXPECT_EQ(expected_title, actual_title); | 360 EXPECT_EQ(expected_title, actual_title); |
359 EXPECT_EQ(3, GetCurrentIndex()); | 361 EXPECT_EQ(3, GetCurrentIndex()); |
360 entry = NavigationEntryImpl::FromNavigationEntry( | 362 entry = NavigationEntryImpl::FromNavigationEntry( |
361 web_contents->GetController().GetEntryAtIndex(4)); | 363 web_contents->GetController().GetEntryAtIndex(4)); |
362 EXPECT_TRUE(entry->screenshot().get()); | 364 EXPECT_TRUE(entry->screenshot().get()); |
363 } | 365 } |
| 366 |
| 367 for (int index = 6; index <= 7; ++index) { |
| 368 // Navigate via the user initiating a navigation from the UI. |
| 369 string16 expected_title = |
| 370 ASCIIToUTF16(base::StringPrintf("Title: #%d", index)); |
| 371 content::TitleWatcher title_watcher(web_contents, expected_title); |
| 372 |
| 373 GURL url(test_server()->GetURL( |
| 374 base::StringPrintf("files/overscroll_navigation.html#%d", index))); |
| 375 NavigationController::LoadURLParams params(url); |
| 376 params.transition_type = PageTransitionFromInt( |
| 377 PAGE_TRANSITION_TYPED | PAGE_TRANSITION_FROM_ADDRESS_BAR); |
| 378 web_contents->GetController().LoadURLWithParams(params); |
| 379 string16 actual_title = title_watcher.WaitAndGetTitle(); |
| 380 EXPECT_EQ(expected_title, actual_title); |
| 381 EXPECT_EQ(index, GetCurrentIndex()); |
| 382 entry = NavigationEntryImpl::FromNavigationEntry( |
| 383 web_contents->GetController().GetEntryAtOffset(-1)); |
| 384 EXPECT_TRUE(entry->screenshot().get()); |
| 385 |
| 386 entry = NavigationEntryImpl::FromNavigationEntry( |
| 387 web_contents->GetController().GetActiveEntry()); |
| 388 EXPECT_FALSE(entry->screenshot().get()); |
| 389 } |
| 390 |
| 391 for (int index = 8; index <= 9; ++index) { |
| 392 // Navigate to a bookmark from the UI. |
| 393 string16 expected_title = |
| 394 ASCIIToUTF16(base::StringPrintf("Title: #%d", index)); |
| 395 content::TitleWatcher title_watcher(web_contents, expected_title); |
| 396 |
| 397 GURL url(test_server()->GetURL( |
| 398 base::StringPrintf("files/overscroll_navigation.html#%d", index))); |
| 399 NavigationController::LoadURLParams params(url); |
| 400 params.transition_type = PageTransitionFromInt( |
| 401 PAGE_TRANSITION_AUTO_BOOKMARK); |
| 402 web_contents->GetController().LoadURLWithParams(params); |
| 403 string16 actual_title = title_watcher.WaitAndGetTitle(); |
| 404 EXPECT_EQ(expected_title, actual_title); |
| 405 EXPECT_EQ(index, GetCurrentIndex()); |
| 406 entry = NavigationEntryImpl::FromNavigationEntry( |
| 407 web_contents->GetController().GetEntryAtOffset(-1)); |
| 408 EXPECT_TRUE(entry->screenshot().get()); |
| 409 |
| 410 entry = NavigationEntryImpl::FromNavigationEntry( |
| 411 web_contents->GetController().GetActiveEntry()); |
| 412 EXPECT_FALSE(entry->screenshot().get()); |
| 413 } |
364 } | 414 } |
365 | 415 |
366 } // namespace content | 416 } // namespace content |
OLD | NEW |