Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(77)

Side by Side Diff: third_party/WebKit/Source/web/tests/ProgrammaticScrollTest.cpp

Issue 2936423003: Move Get/SetScrollOffset methods from WebFrame to WebLocalFrame. (Closed)
Patch Set: Use WebViewHelper::LocalMainFrame() where possible. Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 #include "core/exported/WebViewBase.h" 1 #include "core/exported/WebViewBase.h"
2 #include "core/frame/FrameTestHelpers.h" 2 #include "core/frame/FrameTestHelpers.h"
3 #include "core/frame/LocalFrameView.h" 3 #include "core/frame/LocalFrameView.h"
4 #include "core/frame/WebLocalFrameBase.h" 4 #include "core/frame/WebLocalFrameBase.h"
5 #include "core/loader/DocumentLoader.h" 5 #include "core/loader/DocumentLoader.h"
6 #include "core/loader/FrameLoader.h" 6 #include "core/loader/FrameLoader.h"
7 #include "platform/testing/URLTestHelpers.h" 7 #include "platform/testing/URLTestHelpers.h"
8 #include "platform/testing/UnitTestHelpers.h" 8 #include "platform/testing/UnitTestHelpers.h"
9 #include "public/platform/Platform.h" 9 #include "public/platform/Platform.h"
10 #include "public/platform/WebInputEvent.h" 10 #include "public/platform/WebInputEvent.h"
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 FrameTestHelpers::WebViewHelper web_view_helper; 45 FrameTestHelpers::WebViewHelper web_view_helper;
46 WebViewBase* web_view = 46 WebViewBase* web_view =
47 web_view_helper.InitializeAndLoad(base_url_ + "long_scroll.html"); 47 web_view_helper.InitializeAndLoad(base_url_ + "long_scroll.html");
48 web_view->Resize(WebSize(1000, 1000)); 48 web_view->Resize(WebSize(1000, 1000));
49 web_view->UpdateAllLifecyclePhases(); 49 web_view->UpdateAllLifecyclePhases();
50 50
51 FrameLoader& loader = web_view->MainFrameImpl()->GetFrame()->Loader(); 51 FrameLoader& loader = web_view->MainFrameImpl()->GetFrame()->Loader();
52 loader.GetDocumentLoader()->SetLoadType(kFrameLoadTypeBackForward); 52 loader.GetDocumentLoader()->SetLoadType(kFrameLoadTypeBackForward);
53 53
54 web_view->SetPageScaleFactor(3.0f); 54 web_view->SetPageScaleFactor(3.0f);
55 web_view->MainFrame()->SetScrollOffset(WebSize(0, 500)); 55 web_view->MainFrameImpl()->SetScrollOffset(WebSize(0, 500));
56 loader.GetDocumentLoader()->GetInitialScrollState().was_scrolled_by_user = 56 loader.GetDocumentLoader()->GetInitialScrollState().was_scrolled_by_user =
57 false; 57 false;
58 loader.GetDocumentLoader()->GetHistoryItem()->SetPageScaleFactor(2); 58 loader.GetDocumentLoader()->GetHistoryItem()->SetPageScaleFactor(2);
59 loader.GetDocumentLoader()->GetHistoryItem()->SetScrollOffset( 59 loader.GetDocumentLoader()->GetHistoryItem()->SetScrollOffset(
60 ScrollOffset(0, 200)); 60 ScrollOffset(0, 200));
61 61
62 // Flip back the wasScrolledByUser flag which was set to true by 62 // Flip back the wasScrolledByUser flag which was set to true by
63 // setPageScaleFactor because otherwise 63 // setPageScaleFactor because otherwise
64 // FrameLoader::restoreScrollPositionAndViewState does nothing. 64 // FrameLoader::restoreScrollPositionAndViewState does nothing.
65 loader.GetDocumentLoader()->GetInitialScrollState().was_scrolled_by_user = 65 loader.GetDocumentLoader()->GetInitialScrollState().was_scrolled_by_user =
(...skipping 11 matching lines...) Expand all
77 FrameTestHelpers::WebViewHelper web_view_helper; 77 FrameTestHelpers::WebViewHelper web_view_helper;
78 WebViewBase* web_view = 78 WebViewBase* web_view =
79 web_view_helper.InitializeAndLoad(base_url_ + "long_scroll.html"); 79 web_view_helper.InitializeAndLoad(base_url_ + "long_scroll.html");
80 web_view->Resize(WebSize(1000, 1000)); 80 web_view->Resize(WebSize(1000, 1000));
81 web_view->UpdateAllLifecyclePhases(); 81 web_view->UpdateAllLifecyclePhases();
82 82
83 FrameLoader& loader = web_view->MainFrameImpl()->GetFrame()->Loader(); 83 FrameLoader& loader = web_view->MainFrameImpl()->GetFrame()->Loader();
84 loader.GetDocumentLoader()->SetLoadType(kFrameLoadTypeBackForward); 84 loader.GetDocumentLoader()->SetLoadType(kFrameLoadTypeBackForward);
85 85
86 web_view->SetPageScaleFactor(3.0f); 86 web_view->SetPageScaleFactor(3.0f);
87 web_view->MainFrame()->SetScrollOffset(WebSize(0, 500)); 87 web_view->MainFrameImpl()->SetScrollOffset(WebSize(0, 500));
88 loader.GetDocumentLoader()->GetInitialScrollState().was_scrolled_by_user = 88 loader.GetDocumentLoader()->GetInitialScrollState().was_scrolled_by_user =
89 false; 89 false;
90 loader.GetDocumentLoader()->GetHistoryItem()->SetPageScaleFactor(0); 90 loader.GetDocumentLoader()->GetHistoryItem()->SetPageScaleFactor(0);
91 loader.GetDocumentLoader()->GetHistoryItem()->SetScrollOffset( 91 loader.GetDocumentLoader()->GetHistoryItem()->SetScrollOffset(
92 ScrollOffset(0, 400)); 92 ScrollOffset(0, 400));
93 93
94 // FrameLoader::restoreScrollPositionAndViewState flows differently if scale 94 // FrameLoader::restoreScrollPositionAndViewState flows differently if scale
95 // is zero. 95 // is zero.
96 loader.RestoreScrollPositionAndViewState(); 96 loader.RestoreScrollPositionAndViewState();
97 97
98 // Expect that only the scroll position was restored. 98 // Expect that only the scroll position was restored.
99 EXPECT_EQ(3.0f, web_view->PageScaleFactor()); 99 EXPECT_EQ(3.0f, web_view->PageScaleFactor());
100 EXPECT_EQ(400, web_view->MainFrameImpl()->GetScrollOffset().height); 100 EXPECT_EQ(400, web_view->MainFrameImpl()->GetScrollOffset().height);
101 } 101 }
102 102
103 } // namespace blink 103 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698