Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 162 m_webViewHelper.reset(); // Explicitly reset to break dependency on locally scoped client. | 162 m_webViewHelper.reset(); // Explicitly reset to break dependency on locally scoped client. |
| 163 } | 163 } |
| 164 | 164 |
| 165 WebView* TouchActionTest::setupTest(std::string file, TouchActionTrackingWebView Client& client) | 165 WebView* TouchActionTest::setupTest(std::string file, TouchActionTrackingWebView Client& client) |
| 166 { | 166 { |
| 167 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL), WebString::fromUTF8(file)); | 167 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL), WebString::fromUTF8(file)); |
| 168 // Note that JavaScript must be enabled for shadow DOM tests. | 168 // Note that JavaScript must be enabled for shadow DOM tests. |
| 169 WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + file, true, 0, &client); | 169 WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + file, true, 0, &client); |
| 170 | 170 |
| 171 // Set size to enable hit testing, and avoid line wrapping for consistency w ith browser. | 171 // Set size to enable hit testing, and avoid line wrapping for consistency w ith browser. |
| 172 webView->resize(WebSize(700, 1000)); | 172 webView->resize(WebSize(800, 1200)); |
|
gnana
2014/02/24 18:59:50
I changed this to fix the unit test failure for
Rick Byers
2014/02/25 22:52:03
Yeah, that should be fine. At some point we may w
gnana
2014/02/27 13:26:59
Done.
| |
| 173 | 173 |
| 174 // Scroll to verify the code properly transforms windows to client co-ords. | 174 // Scroll to verify the code properly transforms windows to client co-ords. |
| 175 const int kScrollOffset = 100; | 175 const int kScrollOffset = 100; |
| 176 RefPtr<WebCore::Document> document = static_cast<PassRefPtr<WebCore::Documen t> >(webView->mainFrame()->document()); | 176 RefPtr<WebCore::Document> document = static_cast<PassRefPtr<WebCore::Documen t> >(webView->mainFrame()->document()); |
| 177 document->frame()->view()->setScrollOffset(WebCore::IntPoint(0, kScrollOffse t)); | 177 document->frame()->view()->setScrollOffset(WebCore::IntPoint(0, kScrollOffse t)); |
| 178 | 178 |
| 179 return webView; | 179 return webView; |
| 180 } | 180 } |
| 181 | 181 |
| 182 void TouchActionTest::runTestOnTree(WebCore::ContainerNode* root, WebView* webVi ew, TouchActionTrackingWebViewClient& client) | 182 void TouchActionTest::runTestOnTree(WebCore::ContainerNode* root, WebView* webVi ew, TouchActionTrackingWebViewClient& client) |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 245 // First validate that a hit test at this point will really hit the element | 245 // First validate that a hit test at this point will really hit the element |
| 246 // we intended. This is the easiest way for a test to be broken, but has nothing really | 246 // we intended. This is the easiest way for a test to be broken, but has nothing really |
| 247 // to do with touch action. | 247 // to do with touch action. |
| 248 // Note that we can't use WebView's hit test API because it doesn't look into shadow DOM. | 248 // Note that we can't use WebView's hit test API because it doesn't look into shadow DOM. |
| 249 WebCore::IntPoint docPoint(frameView->windowToContents(clientPoint)) ; | 249 WebCore::IntPoint docPoint(frameView->windowToContents(clientPoint)) ; |
| 250 WebCore::HitTestResult result = frame->eventHandler().hitTestResultA tPoint(docPoint, WebCore::HitTestRequest::ReadOnly | WebCore::HitTestRequest::Ac tive); | 250 WebCore::HitTestResult result = frame->eventHandler().hitTestResultA tPoint(docPoint, WebCore::HitTestRequest::ReadOnly | WebCore::HitTestRequest::Ac tive); |
| 251 ASSERT_EQ(element, result.innerElement()) << "Unexpected hit test re sult " << failureContextPos | 251 ASSERT_EQ(element, result.innerElement()) << "Unexpected hit test re sult " << failureContextPos |
| 252 << " Got element: \"" << result.innerElement()->outerHTML().str ipWhiteSpace().left(80).ascii().data() << "\"" | 252 << " Got element: \"" << result.innerElement()->outerHTML().str ipWhiteSpace().left(80).ascii().data() << "\"" |
| 253 << std::endl << "Document render tree:" << std::endl << external Representation(root->document().frame()).utf8().data(); | 253 << std::endl << "Document render tree:" << std::endl << external Representation(root->document().frame()).utf8().data(); |
| 254 | 254 |
| 255 WebCore::HitTestResult taResult = frame->eventHandler().hitTestResul tAtPoint(docPoint, WebCore::HitTestRequest::ReadOnly | WebCore::HitTestRequest:: Active | WebCore::HitTestRequest::TouchAction); | |
| 256 | |
| 255 // Now send the touch event and check any touch action result. | 257 // Now send the touch event and check any touch action result. |
| 256 sendTouchEvent(webView, WebInputEvent::TouchStart, clientPoint); | 258 sendTouchEvent(webView, WebInputEvent::TouchStart, clientPoint); |
| 257 | 259 |
| 258 AtomicString expectedAction = element->getAttribute("expected-action "); | 260 AtomicString expectedAction = element->getAttribute("expected-action "); |
| 259 if (expectedAction == "auto") { | 261 if (expectedAction == "auto") { |
| 260 // Auto is the default - no action set. | 262 if (taResult.innerElement() == result.innerElement()) { |
|
gnana
2014/02/24 18:59:50
I have added this check for cases similar to this
Rick Byers
2014/02/25 22:52:03
Oh! Something is wrong with the hit testing code
gnana
2014/02/27 13:26:59
Debugged and found that this issue caused in inlin
Rick Byers
2014/02/27 14:53:11
Good work!
| |
| 261 EXPECT_EQ(0, client.touchActionSetCount()) << failureContextPos; | 263 // Auto is the default - no action set. |
| 262 EXPECT_EQ(WebTouchActionAuto, client.lastTouchAction()) << failu reContextPos; | 264 EXPECT_EQ(0, client.touchActionSetCount()) << failureContext Pos; |
| 265 EXPECT_EQ(WebTouchActionAuto, client.lastTouchAction()) << f ailureContextPos; | |
| 266 } | |
| 263 } else { | 267 } else { |
| 264 // Should have received exactly one touch action. | 268 // Should have received exactly one touch action. |
| 265 EXPECT_EQ(1, client.touchActionSetCount()) << failureContextPos; | 269 EXPECT_EQ(1, client.touchActionSetCount()) << failureContextPos; |
| 266 if (client.touchActionSetCount()) { | 270 if (client.touchActionSetCount()) { |
| 267 if (expectedAction == "none") { | 271 if (expectedAction == "none") { |
| 268 EXPECT_EQ(WebTouchActionNone, client.lastTouchAction()) << failureContextPos; | 272 EXPECT_EQ(WebTouchActionNone, client.lastTouchAction()) << failureContextPos; |
| 269 } else if (expectedAction == "pan-x") { | 273 } else if (expectedAction == "pan-x") { |
| 270 EXPECT_EQ(WebTouchActionPanX, client.lastTouchAction()) << failureContextPos; | 274 EXPECT_EQ(WebTouchActionPanX, client.lastTouchAction()) << failureContextPos; |
| 271 } else if (expectedAction == "pan-y") { | 275 } else if (expectedAction == "pan-y") { |
| 272 EXPECT_EQ(WebTouchActionPanY, client.lastTouchAction()) << failureContextPos; | 276 EXPECT_EQ(WebTouchActionPanY, client.lastTouchAction()) << failureContextPos; |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 322 { | 326 { |
| 323 runShadowDOMTest("touch-action-shadow-dom.html"); | 327 runShadowDOMTest("touch-action-shadow-dom.html"); |
| 324 } | 328 } |
| 325 | 329 |
| 326 TEST_F(TouchActionTest, Pan) | 330 TEST_F(TouchActionTest, Pan) |
| 327 { | 331 { |
| 328 runTouchActionTest("touch-action-pan.html"); | 332 runTouchActionTest("touch-action-pan.html"); |
| 329 } | 333 } |
| 330 | 334 |
| 331 } | 335 } |
| OLD | NEW |