Commit f1f22b29 authored by Eugene But's avatar Eugene But Committed by Commit Bot

Remove CRWWebControllerPageScrollStateTest.

This test tests implementation specific details, was a maintenance
burden for chrome and never caught regressions in page state restoration
code.

Given that state restoration is a part of CRWWebController, the only way
to test page state code is to write an EG test: crbug.com/897768

Removing this test does not really change anything, because the test has
been failing consistently for very long time.

Bug: 897467
Change-Id: Iaff4a9dc60b720c280c73f00b29ebcae04994e1c
Reviewed-on: https://chromium-review.googlesource.com/c/1294196
Commit-Queue: Kurt Horimoto <kkhorimoto@chromium.org>
Reviewed-by: default avatarKurt Horimoto <kkhorimoto@chromium.org>
Cr-Commit-Position: refs/heads/master@{#601724}
parent 8a0db319
...@@ -187,10 +187,6 @@ class WebStateImpl; ...@@ -187,10 +187,6 @@ class WebStateImpl;
// Records the state (scroll position, form values, whatever can be harvested) // Records the state (scroll position, form values, whatever can be harvested)
// from the current page into the current session entry. // from the current page into the current session entry.
- (void)recordStateInHistory; - (void)recordStateInHistory;
// Restores the state for this page from session history.
// TODO(stuartmorgan): This is public only temporarily; once refactoring is
// complete it will be handled internally.
- (void)restoreStateFromHistory;
// Notifies the CRWWebController that it has been shown. // Notifies the CRWWebController that it has been shown.
- (void)wasShown; - (void)wasShown;
......
...@@ -717,6 +717,8 @@ registerLoadRequestForURL:(const GURL&)URL ...@@ -717,6 +717,8 @@ registerLoadRequestForURL:(const GURL&)URL
// Returns YES if the current live view is a web view with an image MIME type. // Returns YES if the current live view is a web view with an image MIME type.
- (BOOL)contentIsImage; - (BOOL)contentIsImage;
// Restores the state for this page from session history.
- (void)restoreStateFromHistory;
// Extracts the current page's viewport tag information and calls |completion|. // Extracts the current page's viewport tag information and calls |completion|.
// If the page has changed before the viewport tag is successfully extracted, // If the page has changed before the viewport tag is successfully extracted,
// |completion| is called with nullptr. // |completion| is called with nullptr.
......
...@@ -59,7 +59,6 @@ ...@@ -59,7 +59,6 @@
#include "third_party/ocmock/OCMock/OCMock.h" #include "third_party/ocmock/OCMock/OCMock.h"
#include "third_party/ocmock/gtest_support.h" #include "third_party/ocmock/gtest_support.h"
#include "third_party/ocmock/ocmock_extensions.h" #include "third_party/ocmock/ocmock_extensions.h"
#import "ui/base/test/ios/ui_view_test_utils.h"
#include "url/scheme_host_port.h" #include "url/scheme_host_port.h"
#if !defined(__has_feature) || !__has_feature(objc_arc) #if !defined(__has_feature) || !__has_feature(objc_arc)
...@@ -69,10 +68,6 @@ ...@@ -69,10 +68,6 @@
using base::test::ios::WaitUntilConditionOrTimeout; using base::test::ios::WaitUntilConditionOrTimeout;
using base::test::ios::kWaitForPageLoadTimeout; using base::test::ios::kWaitForPageLoadTimeout;
@interface CRWWebController (PrivateAPI)
@property(nonatomic, readwrite) web::PageDisplayState pageDisplayState;
@end
namespace web { namespace web {
namespace { namespace {
...@@ -91,31 +86,6 @@ enum PageScalabilityType { ...@@ -91,31 +86,6 @@ enum PageScalabilityType {
PAGE_SCALABILITY_DISABLED = 0, PAGE_SCALABILITY_DISABLED = 0,
PAGE_SCALABILITY_ENABLED, PAGE_SCALABILITY_ENABLED,
}; };
NSString* GetHTMLForZoomState(const PageZoomState& zoom_state,
PageScalabilityType scalability_type) {
NSString* const kHTMLFormat =
@"<html><head><meta name='viewport' content="
"'width=%f,minimum-scale=%f,maximum-scale=%f,initial-scale=%f,"
"user-scalable=%@'/></head><body>Test</body></html>";
CGFloat width =
CGRectGetWidth(UIApplication.sharedApplication.keyWindow.bounds) /
zoom_state.minimum_zoom_scale();
BOOL scalability_enabled = scalability_type == PAGE_SCALABILITY_ENABLED;
return [NSString
stringWithFormat:kHTMLFormat, width, zoom_state.minimum_zoom_scale(),
zoom_state.maximum_zoom_scale(), zoom_state.zoom_scale(),
scalability_enabled ? @"yes" : @"no"];
}
// Forces |webController|'s view to render and waits until |webController|'s
// PageZoomState matches |zoom_state|.
void WaitForZoomRendering(CRWWebController* webController,
const PageZoomState& zoom_state) {
ui::test::uiview_utils::ForceViewRendering(webController.view);
base::test::ios::WaitUntilCondition(^bool() {
return webController.pageDisplayState.zoom_state() == zoom_state;
});
}
// Tests in this file are parameterized on this enum to test both // Tests in this file are parameterized on this enum to test both
// LegacyNavigationManagerImpl and WKBasedNavigationManagerImpl. // LegacyNavigationManagerImpl and WKBasedNavigationManagerImpl.
...@@ -507,91 +477,6 @@ TEST_P(DialogsSuppressionTest, SuppressWindowOpen) { ...@@ -507,91 +477,6 @@ TEST_P(DialogsSuppressionTest, SuppressWindowOpen) {
INSTANTIATE_TEST_CASES(DialogsSuppressionTest); INSTANTIATE_TEST_CASES(DialogsSuppressionTest);
// A separate test class, as none of the |CRWWebControllerTest| setup is
// needed.
class CRWWebControllerPageScrollStateTest
: public ProgrammaticWebTestWithWebController {
protected:
// Returns a PageDisplayState that will scroll a WKWebView to
// |scrollOffset| and zoom the content by |relativeZoomScale|.
inline PageDisplayState CreateTestPageDisplayState(
CGPoint scroll_offset,
CGFloat relative_zoom_scale,
CGFloat original_minimum_zoom_scale,
CGFloat original_maximum_zoom_scale,
CGFloat original_zoom_scale) const {
return PageDisplayState(scroll_offset.x, scroll_offset.y,
original_minimum_zoom_scale,
original_maximum_zoom_scale,
relative_zoom_scale * original_minimum_zoom_scale);
}
};
// TODO(crbug/493427): Flaky on the bots.
TEST_P(CRWWebControllerPageScrollStateTest,
FLAKY_SetPageDisplayStateWithUserScalableDisabled) {
#if !TARGET_IPHONE_SIMULATOR
// TODO(crbug.com/493427): fails flakily on device, so skip it there.
return;
#endif
PageZoomState zoom_state(1.0, 5.0, 1.0);
LoadHtml(GetHTMLForZoomState(zoom_state, PAGE_SCALABILITY_DISABLED));
WaitForZoomRendering(web_controller(), zoom_state);
PageZoomState original_zoom_state =
web_controller().pageDisplayState.zoom_state();
NavigationManager* nagivation_manager = web_state()->GetNavigationManager();
nagivation_manager->GetLastCommittedItem()->SetPageDisplayState(
CreateTestPageDisplayState(CGPointMake(1.0, 1.0), // scroll offset
3.0, // relative zoom scale
1.0, // original minimum zoom scale
5.0, // original maximum zoom scale
1.0)); // original zoom scale
[web_controller() restoreStateFromHistory];
// |-restoreStateFromHistory| is async; wait for its completion.
ASSERT_TRUE(WaitUntilConditionOrTimeout(kWaitForPageLoadTimeout, ^{
return web_controller().pageDisplayState.scroll_state().offset_x() == 1.0;
}));
ASSERT_EQ(original_zoom_state,
web_controller().pageDisplayState.zoom_state());
};
// TODO(crbug/493427): Flaky on the bots.
TEST_P(CRWWebControllerPageScrollStateTest,
FLAKY_SetPageDisplayStateWithUserScalableEnabled) {
#if !TARGET_IPHONE_SIMULATOR
// TODO(crbug.com/493427): fails flakily on device, so skip it there.
return;
#endif
PageZoomState zoom_state(1.0, 5.0, 1.0);
LoadHtml(GetHTMLForZoomState(zoom_state, PAGE_SCALABILITY_ENABLED));
WaitForZoomRendering(web_controller(), zoom_state);
NavigationManager* nagivation_manager = web_state()->GetNavigationManager();
nagivation_manager->GetLastCommittedItem()->SetPageDisplayState(
CreateTestPageDisplayState(CGPointMake(1.0, 1.0), // scroll offset
3.0, // relative zoom scale
1.0, // original minimum zoom scale
5.0, // original maximum zoom scale
1.0)); // original zoom scale
[web_controller() restoreStateFromHistory];
// |-restoreStateFromHistory| is async; wait for its completion.
ASSERT_TRUE(WaitUntilConditionOrTimeout(kWaitForPageLoadTimeout, ^{
return web_controller().pageDisplayState.scroll_state().offset_x() == 1.0;
}));
PageZoomState final_zoom_state =
web_controller().pageDisplayState.zoom_state();
EXPECT_FLOAT_EQ(3, final_zoom_state.zoom_scale() /
final_zoom_state.minimum_zoom_scale());
};
INSTANTIATE_TEST_CASES(CRWWebControllerPageScrollStateTest);
// Test fixture for testing visible security state. // Test fixture for testing visible security state.
typedef ProgrammaticWebTestWithWebState CRWWebStateSecurityStateTest; typedef ProgrammaticWebTestWithWebState CRWWebStateSecurityStateTest;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment