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

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

Issue 1686483002: Oilpan: Remove most WillBe types from the code base (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 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) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 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 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 // effect, the implicit assumption that we're outside any event 136 // effect, the implicit assumption that we're outside any event
137 // loop (=> there being no pointers on the stack needing scanning) 137 // loop (=> there being no pointers on the stack needing scanning)
138 // when that GC strikes will no longer hold. 138 // when that GC strikes will no longer hold.
139 // 139 //
140 // To ensure that the references on the stack are also traced, we 140 // To ensure that the references on the stack are also traced, we
141 // turn them into persistent, stack allocated references. This 141 // turn them into persistent, stack allocated references. This
142 // workaround is sufficient to handle this artificial test 142 // workaround is sufficient to handle this artificial test
143 // scenario. 143 // scenario.
144 WebView* webView = setupTest(file, client); 144 WebView* webView = setupTest(file, client);
145 145
146 RefPtrWillBePersistent<Document> document = static_cast<PassRefPtrWillBeRawP tr<Document>>(webView->mainFrame()->document()); 146 Persistent<Document> document = static_cast<RawPtr<Document>>(webView->mainF rame()->document());
147 runTestOnTree(document.get(), webView, client); 147 runTestOnTree(document.get(), webView, client);
148 148
149 m_webViewHelper.reset(); // Explicitly reset to break dependency on locally scoped client. 149 m_webViewHelper.reset(); // Explicitly reset to break dependency on locally scoped client.
150 } 150 }
151 151
152 void TouchActionTest::runShadowDOMTest(std::string file) 152 void TouchActionTest::runShadowDOMTest(std::string file)
153 { 153 {
154 TouchActionTrackingWebViewClient client; 154 TouchActionTrackingWebViewClient client;
155 155
156 WebView* webView = setupTest(file, client); 156 WebView* webView = setupTest(file, client);
157 157
158 TrackExceptionState es; 158 TrackExceptionState es;
159 159
160 // Oilpan: see runTouchActionTest() comment why these are persistent referen ces. 160 // Oilpan: see runTouchActionTest() comment why these are persistent referen ces.
161 RefPtrWillBePersistent<Document> document = static_cast<PassRefPtrWillBeRawP tr<Document>>(webView->mainFrame()->document()); 161 Persistent<Document> document = static_cast<RawPtr<Document>>(webView->mainF rame()->document());
162 RefPtrWillBePersistent<StaticElementList> hostNodes = document->querySelecto rAll("[shadow-host]", es); 162 Persistent<StaticElementList> hostNodes = document->querySelectorAll("[shado w-host]", es);
163 ASSERT_FALSE(es.hadException()); 163 ASSERT_FALSE(es.hadException());
164 ASSERT_GE(hostNodes->length(), 1u); 164 ASSERT_GE(hostNodes->length(), 1u);
165 165
166 for (unsigned index = 0; index < hostNodes->length(); index++) { 166 for (unsigned index = 0; index < hostNodes->length(); index++) {
167 ShadowRoot* shadowRoot = hostNodes->item(index)->openShadowRoot(); 167 ShadowRoot* shadowRoot = hostNodes->item(index)->openShadowRoot();
168 runTestOnTree(shadowRoot, webView, client); 168 runTestOnTree(shadowRoot, webView, client);
169 } 169 }
170 170
171 // Projections show up in the main document. 171 // Projections show up in the main document.
172 runTestOnTree(document.get(), webView, client); 172 runTestOnTree(document.get(), webView, client);
173 173
174 m_webViewHelper.reset(); // Explicitly reset to break dependency on locally scoped client. 174 m_webViewHelper.reset(); // Explicitly reset to break dependency on locally scoped client.
175 } 175 }
176 176
177 void TouchActionTest::runIFrameTest(std::string file) 177 void TouchActionTest::runIFrameTest(std::string file)
178 { 178 {
179 TouchActionTrackingWebViewClient client; 179 TouchActionTrackingWebViewClient client;
180 180
181 WebView* webView = setupTest(file, client); 181 WebView* webView = setupTest(file, client);
182 WebFrame* curFrame = webView->mainFrame()->firstChild(); 182 WebFrame* curFrame = webView->mainFrame()->firstChild();
183 ASSERT_TRUE(curFrame); 183 ASSERT_TRUE(curFrame);
184 184
185 for (; curFrame; curFrame = curFrame->nextSibling()) { 185 for (; curFrame; curFrame = curFrame->nextSibling()) {
186 // Oilpan: see runTouchActionTest() comment why these are persistent ref erences. 186 // Oilpan: see runTouchActionTest() comment why these are persistent ref erences.
187 RefPtrWillBePersistent<Document> contentDoc = static_cast<PassRefPtrWill BeRawPtr<Document>>(curFrame->document()); 187 Persistent<Document> contentDoc = static_cast<RawPtr<Document>>(curFrame ->document());
188 runTestOnTree(contentDoc.get(), webView, client); 188 runTestOnTree(contentDoc.get(), webView, client);
189 } 189 }
190 190
191 m_webViewHelper.reset(); // Explicitly reset to break dependency on locally scoped client. 191 m_webViewHelper.reset(); // Explicitly reset to break dependency on locally scoped client.
192 } 192 }
193 193
194 WebView* TouchActionTest::setupTest(std::string file, TouchActionTrackingWebView Client& client) 194 WebView* TouchActionTest::setupTest(std::string file, TouchActionTrackingWebView Client& client)
195 { 195 {
196 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL), WebString::fromUTF8(file)); 196 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL), WebString::fromUTF8(file));
197 // Note that JavaScript must be enabled for shadow DOM tests. 197 // Note that JavaScript must be enabled for shadow DOM tests.
198 WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + file, true, 0, &client); 198 WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + file, true, 0, &client);
199 199
200 // Set size to enable hit testing, and avoid line wrapping for consistency w ith browser. 200 // Set size to enable hit testing, and avoid line wrapping for consistency w ith browser.
201 webView->resize(WebSize(800, 1200)); 201 webView->resize(WebSize(800, 1200));
202 202
203 // Scroll to verify the code properly transforms windows to client co-ords. 203 // Scroll to verify the code properly transforms windows to client co-ords.
204 const int kScrollOffset = 100; 204 const int kScrollOffset = 100;
205 RefPtrWillBeRawPtr<Document> document = static_cast<PassRefPtrWillBeRawPtr<D ocument>>(webView->mainFrame()->document()); 205 RawPtr<Document> document = static_cast<RawPtr<Document>>(webView->mainFrame ()->document());
206 document->frame()->view()->setScrollPosition(IntPoint(0, kScrollOffset), Pro grammaticScroll); 206 document->frame()->view()->setScrollPosition(IntPoint(0, kScrollOffset), Pro grammaticScroll);
207 207
208 return webView; 208 return webView;
209 } 209 }
210 210
211 void TouchActionTest::runTestOnTree(ContainerNode* root, WebView* webView, Touch ActionTrackingWebViewClient& client) 211 void TouchActionTest::runTestOnTree(ContainerNode* root, WebView* webView, Touch ActionTrackingWebViewClient& client)
212 { 212 {
213 // Find all elements to test the touch-action of in the document. 213 // Find all elements to test the touch-action of in the document.
214 TrackExceptionState es; 214 TrackExceptionState es;
215 215
216 // Oilpan: see runTouchActionTest() comment why these are persistent referen ces. 216 // Oilpan: see runTouchActionTest() comment why these are persistent referen ces.
217 RefPtrWillBePersistent<StaticElementList> elements = root->querySelectorAll( "[expected-action]", es); 217 Persistent<StaticElementList> elements = root->querySelectorAll("[expected-a ction]", es);
218 ASSERT_FALSE(es.hadException()); 218 ASSERT_FALSE(es.hadException());
219 219
220 for (unsigned index = 0; index < elements->length(); index++) { 220 for (unsigned index = 0; index < elements->length(); index++) {
221 Element* element = elements->item(index); 221 Element* element = elements->item(index);
222 element->scrollIntoViewIfNeeded(); 222 element->scrollIntoViewIfNeeded();
223 223
224 std::string failureContext("Test case: "); 224 std::string failureContext("Test case: ");
225 if (element->hasID()) { 225 if (element->hasID()) {
226 failureContext.append(element->getIdAttribute().ascii().data()); 226 failureContext.append(element->getIdAttribute().ascii().data());
227 } else if (element->firstChild()) { 227 } else if (element->firstChild()) {
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
365 { 365 {
366 runShadowDOMTest("touch-action-shadow-dom.html"); 366 runShadowDOMTest("touch-action-shadow-dom.html");
367 } 367 }
368 368
369 TEST_F(TouchActionTest, Pan) 369 TEST_F(TouchActionTest, Pan)
370 { 370 {
371 runTouchActionTest("touch-action-pan.html"); 371 runTouchActionTest("touch-action-pan.html");
372 } 372 }
373 373
374 } // namespace blink 374 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698