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

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

Issue 2896563002: Update WebLocalFrameImpl with WebLocalFrameBase to break dependencies. (Closed)
Patch Set: Rebase Created 3 years, 7 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 /* 1 /*
2 * Copyright (C) 2011 Google Inc. All rights reserved. 2 * Copyright (C) 2011 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 12 matching lines...) Expand all
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31 #include "web/tests/FrameTestHelpers.h" 31 #include "web/tests/FrameTestHelpers.h"
32 32
33 #include "core/frame/WebLocalFrameBase.h"
33 #include "platform/testing/URLTestHelpers.h" 34 #include "platform/testing/URLTestHelpers.h"
34 #include "platform/testing/UnitTestHelpers.h" 35 #include "platform/testing/UnitTestHelpers.h"
35 #include "platform/testing/WebLayerTreeViewImplForTesting.h" 36 #include "platform/testing/WebLayerTreeViewImplForTesting.h"
36 #include "platform/wtf/Functional.h" 37 #include "platform/wtf/Functional.h"
37 #include "platform/wtf/PtrUtil.h" 38 #include "platform/wtf/PtrUtil.h"
38 #include "platform/wtf/StdLibExtras.h" 39 #include "platform/wtf/StdLibExtras.h"
39 #include "platform/wtf/text/StringBuilder.h" 40 #include "platform/wtf/text/StringBuilder.h"
40 #include "public/platform/Platform.h" 41 #include "public/platform/Platform.h"
41 #include "public/platform/WebData.h" 42 #include "public/platform/WebData.h"
42 #include "public/platform/WebString.h" 43 #include "public/platform/WebString.h"
43 #include "public/platform/WebThread.h" 44 #include "public/platform/WebThread.h"
44 #include "public/platform/WebURLLoaderMockFactory.h" 45 #include "public/platform/WebURLLoaderMockFactory.h"
45 #include "public/platform/WebURLRequest.h" 46 #include "public/platform/WebURLRequest.h"
46 #include "public/platform/WebURLResponse.h" 47 #include "public/platform/WebURLResponse.h"
47 #include "public/web/WebFrameWidget.h" 48 #include "public/web/WebFrameWidget.h"
48 #include "public/web/WebSettings.h" 49 #include "public/web/WebSettings.h"
49 #include "public/web/WebTreeScopeType.h" 50 #include "public/web/WebTreeScopeType.h"
50 #include "public/web/WebViewClient.h" 51 #include "public/web/WebViewClient.h"
51 #include "web/WebLocalFrameImpl.h"
52 #include "web/WebRemoteFrameImpl.h" 52 #include "web/WebRemoteFrameImpl.h"
53 53
54 namespace blink { 54 namespace blink {
55 namespace FrameTestHelpers { 55 namespace FrameTestHelpers {
56 56
57 namespace { 57 namespace {
58 58
59 // The frame test helpers coordinate frame loads in a carefully choreographed 59 // The frame test helpers coordinate frame loads in a carefully choreographed
60 // dance. Since the parser is threaded, simply spinning the run loop once is not 60 // dance. Since the parser is threaded, simply spinning the run loop once is not
61 // enough to ensure completion of a load. Instead, the following pattern is 61 // enough to ensure completion of a load. Instead, the following pattern is
62 // used to ensure that tests see the final state: 62 // used to ensure that tests see the final state:
63 // 1. Starts a load. 63 // 1. Starts a load.
64 // 2. Enter the run loop. 64 // 2. Enter the run loop.
65 // 3. Posted task triggers the load, and starts pumping pending resource 65 // 3. Posted task triggers the load, and starts pumping pending resource
66 // requests using runServeAsyncRequestsTask(). 66 // requests using runServeAsyncRequestsTask().
67 // 4. TestWebFrameClient watches for didStartLoading/didStopLoading calls, 67 // 4. TestWebFrameClient watches for didStartLoading/didStopLoading calls,
68 // keeping track of how many loads it thinks are in flight. 68 // keeping track of how many loads it thinks are in flight.
69 // 5. While runServeAsyncRequestsTask() observes TestWebFrameClient to still 69 // 5. While runServeAsyncRequestsTask() observes TestWebFrameClient to still
70 // have loads in progress, it posts itself back to the run loop. 70 // have loads in progress, it posts itself back to the run loop.
71 // 6. When runServeAsyncRequestsTask() notices there are no more loads in 71 // 6. When runServeAsyncRequestsTask() notices there are no more loads in
72 // progress, it exits the run loop. 72 // progress, it exits the run loop.
73 // 7. At this point, all parsing, resource loads, and layout should be finished. 73 // 7. At this point, all parsing, resource loads, and layout should be finished.
74 TestWebFrameClient* TestClientForFrame(WebFrame* frame) { 74 TestWebFrameClient* TestClientForFrame(WebFrame* frame) {
75 return static_cast<TestWebFrameClient*>(ToWebLocalFrameImpl(frame)->Client()); 75 return static_cast<TestWebFrameClient*>(ToWebLocalFrameBase(frame)->Client());
76 } 76 }
77 77
78 void RunServeAsyncRequestsTask(TestWebFrameClient* client) { 78 void RunServeAsyncRequestsTask(TestWebFrameClient* client) {
79 Platform::Current()->GetURLLoaderMockFactory()->ServeAsynchronousRequests(); 79 Platform::Current()->GetURLLoaderMockFactory()->ServeAsynchronousRequests();
80 if (client->IsLoading()) 80 if (client->IsLoading())
81 Platform::Current()->CurrentThread()->GetWebTaskRunner()->PostTask( 81 Platform::Current()->CurrentThread()->GetWebTaskRunner()->PostTask(
82 BLINK_FROM_HERE, 82 BLINK_FROM_HERE,
83 WTF::Bind(&RunServeAsyncRequestsTask, WTF::Unretained(client))); 83 WTF::Bind(&RunServeAsyncRequestsTask, WTF::Unretained(client)));
84 else 84 else
85 testing::ExitRunLoop(); 85 testing::ExitRunLoop();
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 const IntPoint& point, 142 const IntPoint& point,
143 int modifiers) { 143 int modifiers) {
144 WebMouseEvent result(type, modifiers, WebInputEvent::kTimeStampForTesting); 144 WebMouseEvent result(type, modifiers, WebInputEvent::kTimeStampForTesting);
145 result.SetPositionInWidget(point.X(), point.Y()); 145 result.SetPositionInWidget(point.X(), point.Y());
146 result.SetPositionInScreen(point.X(), point.Y()); 146 result.SetPositionInScreen(point.X(), point.Y());
147 result.button = button; 147 result.button = button;
148 result.click_count = 1; 148 result.click_count = 1;
149 return result; 149 return result;
150 } 150 }
151 151
152 WebLocalFrameImpl* CreateLocalChild(WebRemoteFrame* parent, 152 WebLocalFrameBase* CreateLocalChild(WebRemoteFrame* parent,
153 const WebString& name, 153 const WebString& name,
154 WebFrameClient* client, 154 WebFrameClient* client,
155 WebWidgetClient* widget_client, 155 WebWidgetClient* widget_client,
156 WebFrame* previous_sibling, 156 WebFrame* previous_sibling,
157 const WebFrameOwnerProperties& properties) { 157 const WebFrameOwnerProperties& properties) {
158 if (!client) 158 if (!client)
159 client = DefaultWebFrameClient(); 159 client = DefaultWebFrameClient();
160 160
161 WebLocalFrameImpl* frame = ToWebLocalFrameImpl(parent->CreateLocalChild( 161 WebLocalFrameBase* frame = ToWebLocalFrameBase(parent->CreateLocalChild(
162 WebTreeScopeType::kDocument, name, WebSandboxFlags::kNone, client, 162 WebTreeScopeType::kDocument, name, WebSandboxFlags::kNone, client,
163 static_cast<TestWebFrameClient*>(client)->GetInterfaceProvider(), nullptr, 163 static_cast<TestWebFrameClient*>(client)->GetInterfaceProvider(), nullptr,
164 previous_sibling, WebParsedFeaturePolicy(), properties, nullptr)); 164 previous_sibling, WebParsedFeaturePolicy(), properties, nullptr));
165 165
166 if (!widget_client) 166 if (!widget_client)
167 widget_client = DefaultWebWidgetClient(); 167 widget_client = DefaultWebWidgetClient();
168 WebFrameWidget::Create(widget_client, frame); 168 WebFrameWidget::Create(widget_client, frame);
169 169
170 return frame; 170 return frame;
171 } 171 }
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 // 212 //
213 // Consequently, all external image resources must be mocked. 213 // Consequently, all external image resources must be mocked.
214 web_view_->GetSettings()->SetLoadsImagesAutomatically(true); 214 web_view_->GetSettings()->SetLoadsImagesAutomatically(true);
215 if (update_settings_func) 215 if (update_settings_func)
216 update_settings_func(web_view_->GetSettings()); 216 update_settings_func(web_view_->GetSettings());
217 if (setting_overrider_) 217 if (setting_overrider_)
218 setting_overrider_->OverrideSettings(web_view_->GetSettings()); 218 setting_overrider_->OverrideSettings(web_view_->GetSettings());
219 web_view_->SetDeviceScaleFactor( 219 web_view_->SetDeviceScaleFactor(
220 web_view_client->GetScreenInfo().device_scale_factor); 220 web_view_client->GetScreenInfo().device_scale_factor);
221 web_view_->SetDefaultPageScaleLimits(1, 4); 221 web_view_->SetDefaultPageScaleLimits(1, 4);
222 WebLocalFrame* frame = WebLocalFrameImpl::Create( 222 WebLocalFrame* frame = WebLocalFrameBase::Create(
223 WebTreeScopeType::kDocument, web_frame_client, 223 WebTreeScopeType::kDocument, web_frame_client,
224 web_frame_client->GetInterfaceProvider(), nullptr, opener); 224 web_frame_client->GetInterfaceProvider(), nullptr, opener);
225 web_view_->SetMainFrame(frame); 225 web_view_->SetMainFrame(frame);
226 web_frame_client->SetFrame(frame); 226 web_frame_client->SetFrame(frame);
227 // TODO(dcheng): The main frame widget currently has a special case. 227 // TODO(dcheng): The main frame widget currently has a special case.
228 // Eliminate this once WebView is no longer a WebWidget. 228 // Eliminate this once WebView is no longer a WebWidget.
229 blink::WebFrameWidget::Create(web_widget_client, web_view_, frame); 229 blink::WebFrameWidget::Create(web_widget_client, web_view_, frame);
230 230
231 test_web_view_client_ = web_view_client; 231 test_web_view_client_ = web_view_client;
232 232
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
350 test_web_view_client_->ScheduleAnimation(); 350 test_web_view_client_->ScheduleAnimation();
351 } 351 }
352 352
353 void TestWebViewWidgetClient::DidMeaningfulLayout( 353 void TestWebViewWidgetClient::DidMeaningfulLayout(
354 WebMeaningfulLayout layout_type) { 354 WebMeaningfulLayout layout_type) {
355 test_web_view_client_->DidMeaningfulLayout(layout_type); 355 test_web_view_client_->DidMeaningfulLayout(layout_type);
356 } 356 }
357 357
358 } // namespace FrameTestHelpers 358 } // namespace FrameTestHelpers
359 } // namespace blink 359 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/web/tests/FrameTestHelpers.h ('k') | third_party/WebKit/Source/web/tests/LinkSelectionTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698