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

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

Issue 465483002: Merge NamedNodesCollection and StaticNodeList classes (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebase Created 6 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/testing/Internals.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 void TouchActionTest::runShadowDOMTest(std::string file) 153 void TouchActionTest::runShadowDOMTest(std::string file)
154 { 154 {
155 TouchActionTrackingWebViewClient client; 155 TouchActionTrackingWebViewClient client;
156 156
157 WebView* webView = setupTest(file, client); 157 WebView* webView = setupTest(file, client);
158 158
159 blink::TrackExceptionState es; 159 blink::TrackExceptionState es;
160 160
161 // Oilpan: see runTouchActionTest() comment why these are persistent referen ces. 161 // Oilpan: see runTouchActionTest() comment why these are persistent referen ces.
162 RefPtrWillBePersistent<blink::Document> document = static_cast<PassRefPtrWil lBeRawPtr<blink::Document> >(webView->mainFrame()->document()); 162 RefPtrWillBePersistent<blink::Document> document = static_cast<PassRefPtrWil lBeRawPtr<blink::Document> >(webView->mainFrame()->document());
163 RefPtrWillBePersistent<blink::StaticNodeList> hostNodes = document->querySel ectorAll("[shadow-host]", es); 163 RefPtrWillBePersistent<blink::StaticElementList> hostNodes = document->query SelectorAll("[shadow-host]", es);
164 ASSERT_FALSE(es.hadException()); 164 ASSERT_FALSE(es.hadException());
165 ASSERT_GE(hostNodes->length(), 1u); 165 ASSERT_GE(hostNodes->length(), 1u);
166 166
167 for (unsigned index = 0; index < hostNodes->length(); index++) { 167 for (unsigned index = 0; index < hostNodes->length(); index++) {
168 blink::ShadowRoot* shadowRoot = blink::toElement(hostNodes->item(index)) ->shadowRoot(); 168 blink::ShadowRoot* shadowRoot = hostNodes->item(index)->shadowRoot();
169 runTestOnTree(shadowRoot, webView, client); 169 runTestOnTree(shadowRoot, webView, client);
170 } 170 }
171 171
172 // Projections show up in the main document. 172 // Projections show up in the main document.
173 runTestOnTree(document.get(), webView, client); 173 runTestOnTree(document.get(), webView, client);
174 174
175 m_webViewHelper.reset(); // Explicitly reset to break dependency on locally scoped client. 175 m_webViewHelper.reset(); // Explicitly reset to break dependency on locally scoped client.
176 } 176 }
177 177
178 WebView* TouchActionTest::setupTest(std::string file, TouchActionTrackingWebView Client& client) 178 WebView* TouchActionTest::setupTest(std::string file, TouchActionTrackingWebView Client& client)
(...skipping 15 matching lines...) Expand all
194 194
195 return webView; 195 return webView;
196 } 196 }
197 197
198 void TouchActionTest::runTestOnTree(blink::ContainerNode* root, WebView* webView , TouchActionTrackingWebViewClient& client) 198 void TouchActionTest::runTestOnTree(blink::ContainerNode* root, WebView* webView , TouchActionTrackingWebViewClient& client)
199 { 199 {
200 // Find all elements to test the touch-action of in the document. 200 // Find all elements to test the touch-action of in the document.
201 blink::TrackExceptionState es; 201 blink::TrackExceptionState es;
202 202
203 // Oilpan: see runTouchActionTest() comment why these are persistent referen ces. 203 // Oilpan: see runTouchActionTest() comment why these are persistent referen ces.
204 RefPtrWillBePersistent<blink::StaticNodeList> nodes = root->querySelectorAll ("[expected-action]", es); 204 RefPtrWillBePersistent<blink::StaticElementList> elements = root->querySelec torAll("[expected-action]", es);
205 ASSERT_FALSE(es.hadException()); 205 ASSERT_FALSE(es.hadException());
206 206
207 for (unsigned index = 0; index < nodes->length(); index++) { 207 for (unsigned index = 0; index < elements->length(); index++) {
208 blink::Element* element = toElement(nodes->item(index)); 208 Element* element = elements->item(index);
209 element->scrollIntoViewIfNeeded(); 209 element->scrollIntoViewIfNeeded();
210 ASSERT_TRUE(nodes->item(index)->isElementNode());
211 210
212 std::string failureContext("Test case: "); 211 std::string failureContext("Test case: ");
213 if (element->hasID()) { 212 if (element->hasID()) {
214 failureContext.append(element->getIdAttribute().ascii().data()); 213 failureContext.append(element->getIdAttribute().ascii().data());
215 } else if (element->firstChild()) { 214 } else if (element->firstChild()) {
216 failureContext.append("\""); 215 failureContext.append("\"");
217 failureContext.append(element->firstChild()->textContent(false).stri pWhiteSpace().ascii().data()); 216 failureContext.append(element->firstChild()->textContent(false).stri pWhiteSpace().ascii().data());
218 failureContext.append("\""); 217 failureContext.append("\"");
219 } else { 218 } else {
220 failureContext += "<missing ID>"; 219 failureContext += "<missing ID>";
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
344 { 343 {
345 runShadowDOMTest("touch-action-shadow-dom.html"); 344 runShadowDOMTest("touch-action-shadow-dom.html");
346 } 345 }
347 346
348 TEST_F(TouchActionTest, Pan) 347 TEST_F(TouchActionTest, Pan)
349 { 348 {
350 runTouchActionTest("touch-action-pan.html"); 349 runTouchActionTest("touch-action-pan.html");
351 } 350 }
352 351
353 } 352 }
OLDNEW
« no previous file with comments | « Source/core/testing/Internals.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698