| Index: content/browser/web_contents/web_contents_view_aura_browsertest.cc
|
| diff --git a/content/browser/web_contents/web_contents_view_aura_browsertest.cc b/content/browser/web_contents/web_contents_view_aura_browsertest.cc
|
| index 5af07d2a8f97eb5d08ad1b13cdb16a456f9f3c42..214008db892ffaf838a1689bf3f8f4e102d9f516 100644
|
| --- a/content/browser/web_contents/web_contents_view_aura_browsertest.cc
|
| +++ b/content/browser/web_contents/web_contents_view_aura_browsertest.cc
|
| @@ -9,6 +9,8 @@
|
| #include "base/test/test_timeouts.h"
|
| #include "base/utf_string_conversions.h"
|
| #include "content/browser/renderer_host/render_view_host_impl.h"
|
| +#include "content/browser/web_contents/navigation_controller_impl.h"
|
| +#include "content/browser/web_contents/navigation_entry_impl.h"
|
| #include "content/browser/web_contents/web_contents_impl.h"
|
| #include "content/public/common/content_switches.h"
|
| #include "content/public/test/browser_test_utils.h"
|
| @@ -261,4 +263,103 @@ IN_PROC_BROWSER_TEST_F(WebContentsViewAuraTest,
|
| // Do not end the overscroll sequence.
|
| }
|
|
|
| +// The test is disabled on windows since the gesture support in win-aura isn't
|
| +// complete yet. See http://crbug.com/157268
|
| +#if defined(OS_WIN)
|
| +#define MAYBE_OverscrollScreenshot \
|
| + DISABLED_OverscrollScreenshot
|
| +#else
|
| +#define MAYBE_OverscrollScreenshot \
|
| + OverscrollScreenshot
|
| +#endif
|
| +// Tests that the page has has a screenshot when navigation happens:
|
| +// - from within the page (from a JS function)
|
| +// - interactively, when user does an overscroll gesture
|
| +// - interactively, when user navigates in history without the overscroll
|
| +// gesture.
|
| +IN_PROC_BROWSER_TEST_F(WebContentsViewAuraTest,
|
| + OverscrollScreenshot) {
|
| + ASSERT_NO_FATAL_FAILURE(
|
| + StartTestWithPage("files/overscroll_navigation.html"));
|
| + WebContentsImpl* web_contents =
|
| + static_cast<WebContentsImpl*>(shell()->web_contents());
|
| + RenderViewHostImpl* view_host = static_cast<RenderViewHostImpl*>(
|
| + web_contents->GetRenderViewHost());
|
| +
|
| + // Do a few navigations initiated by the page.
|
| + ExecuteSyncJSFunction(view_host, "navigate_next()");
|
| + EXPECT_EQ(1, GetCurrentIndex());
|
| + ExecuteSyncJSFunction(view_host, "navigate_next()");
|
| + EXPECT_EQ(2, GetCurrentIndex());
|
| +
|
| + // The current entry won't have any screenshots. But the entries in the
|
| + // history should now have screenshots.
|
| + NavigationEntryImpl* entry = NavigationEntryImpl::FromNavigationEntry(
|
| + web_contents->GetController().GetEntryAtIndex(2));
|
| + EXPECT_FALSE(entry->screenshot().get());
|
| +
|
| + entry = NavigationEntryImpl::FromNavigationEntry(
|
| + web_contents->GetController().GetEntryAtIndex(1));
|
| + EXPECT_TRUE(entry->screenshot().get());
|
| +
|
| + entry = NavigationEntryImpl::FromNavigationEntry(
|
| + web_contents->GetController().GetEntryAtIndex(0));
|
| + EXPECT_TRUE(entry->screenshot().get());
|
| +
|
| + // Navigate again. Index 2 should now have a screenshot.
|
| + ExecuteSyncJSFunction(view_host, "navigate_next()");
|
| + EXPECT_EQ(3, GetCurrentIndex());
|
| +
|
| + entry = NavigationEntryImpl::FromNavigationEntry(
|
| + web_contents->GetController().GetEntryAtIndex(2));
|
| + EXPECT_TRUE(entry->screenshot().get());
|
| +
|
| + entry = NavigationEntryImpl::FromNavigationEntry(
|
| + web_contents->GetController().GetEntryAtIndex(3));
|
| + EXPECT_FALSE(entry->screenshot().get());
|
| +
|
| + {
|
| + // Now, swipe right to navigate backwards. This should navigate away from
|
| + // index 3 to index 2, and index 3 should have a screenshot.
|
| + string16 expected_title = ASCIIToUTF16("Title: #2");
|
| + content::TitleWatcher title_watcher(web_contents, expected_title);
|
| + aura::Window* content = web_contents->GetContentNativeView();
|
| + gfx::Rect bounds = content->GetBoundsInRootWindow();
|
| + aura::test::EventGenerator generator(content->GetRootWindow(), content);
|
| + generator.GestureScrollSequence(
|
| + gfx::Point(bounds.x() + 2, bounds.y() + 10),
|
| + gfx::Point(bounds.right() - 10, bounds.y() + 10),
|
| + base::TimeDelta::FromMilliseconds(20),
|
| + 1);
|
| + string16 actual_title = title_watcher.WaitAndGetTitle();
|
| + EXPECT_EQ(expected_title, actual_title);
|
| + EXPECT_EQ(2, GetCurrentIndex());
|
| + entry = NavigationEntryImpl::FromNavigationEntry(
|
| + web_contents->GetController().GetEntryAtIndex(3));
|
| + EXPECT_TRUE(entry->screenshot().get());
|
| + }
|
| +
|
| + // Navigate a couple more times.
|
| + ExecuteSyncJSFunction(view_host, "navigate_next()");
|
| + EXPECT_EQ(3, GetCurrentIndex());
|
| + ExecuteSyncJSFunction(view_host, "navigate_next()");
|
| + EXPECT_EQ(4, GetCurrentIndex());
|
| + entry = NavigationEntryImpl::FromNavigationEntry(
|
| + web_contents->GetController().GetEntryAtIndex(4));
|
| + EXPECT_FALSE(entry->screenshot().get());
|
| +
|
| + {
|
| + // Navigate back in history.
|
| + string16 expected_title = ASCIIToUTF16("Title: #3");
|
| + content::TitleWatcher title_watcher(web_contents, expected_title);
|
| + web_contents->GetController().GoBack();
|
| + string16 actual_title = title_watcher.WaitAndGetTitle();
|
| + EXPECT_EQ(expected_title, actual_title);
|
| + EXPECT_EQ(3, GetCurrentIndex());
|
| + entry = NavigationEntryImpl::FromNavigationEntry(
|
| + web_contents->GetController().GetEntryAtIndex(4));
|
| + EXPECT_TRUE(entry->screenshot().get());
|
| + }
|
| +}
|
| +
|
| } // namespace content
|
|
|