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

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

Issue 2863693003: Unify TouchAction classes (Closed)
Patch Set: add cstdlib 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
« no previous file with comments | « third_party/WebKit/Source/web/WebViewImpl.cpp ('k') | third_party/WebKit/public/BUILD.gn » ('j') | 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 24 matching lines...) Expand all
35 #include "core/dom/StaticNodeList.h" 35 #include "core/dom/StaticNodeList.h"
36 #include "core/dom/shadow/ShadowRoot.h" 36 #include "core/dom/shadow/ShadowRoot.h"
37 #include "core/exported/WebViewBase.h" 37 #include "core/exported/WebViewBase.h"
38 #include "core/frame/FrameView.h" 38 #include "core/frame/FrameView.h"
39 #include "core/frame/LocalFrame.h" 39 #include "core/frame/LocalFrame.h"
40 #include "core/html/HTMLIFrameElement.h" 40 #include "core/html/HTMLIFrameElement.h"
41 #include "core/input/EventHandler.h" 41 #include "core/input/EventHandler.h"
42 #include "core/layout/HitTestResult.h" 42 #include "core/layout/HitTestResult.h"
43 #include "core/layout/LayoutTreeAsText.h" 43 #include "core/layout/LayoutTreeAsText.h"
44 #include "core/layout/api/LayoutViewItem.h" 44 #include "core/layout/api/LayoutViewItem.h"
45 #include "platform/graphics/TouchAction.h"
45 #include "platform/testing/URLTestHelpers.h" 46 #include "platform/testing/URLTestHelpers.h"
46 #include "platform/testing/UnitTestHelpers.h" 47 #include "platform/testing/UnitTestHelpers.h"
47 #include "public/platform/Platform.h" 48 #include "public/platform/Platform.h"
48 #include "public/platform/WebCoalescedInputEvent.h" 49 #include "public/platform/WebCoalescedInputEvent.h"
49 #include "public/platform/WebTouchEvent.h" 50 #include "public/platform/WebTouchEvent.h"
50 #include "public/platform/WebURLLoaderMockFactory.h" 51 #include "public/platform/WebURLLoaderMockFactory.h"
51 #include "public/web/WebDocument.h" 52 #include "public/web/WebDocument.h"
52 #include "public/web/WebFrame.h" 53 #include "public/web/WebFrame.h"
53 #include "public/web/WebHitTestResult.h" 54 #include "public/web/WebHitTestResult.h"
54 #include "public/web/WebTouchAction.h"
55 #include "public/web/WebView.h" 55 #include "public/web/WebView.h"
56 #include "public/web/WebViewClient.h" 56 #include "public/web/WebViewClient.h"
57 #include "public/web/WebWidgetClient.h" 57 #include "public/web/WebWidgetClient.h"
58 #include "testing/gtest/include/gtest/gtest.h" 58 #include "testing/gtest/include/gtest/gtest.h"
59 #include "web/tests/FrameTestHelpers.h" 59 #include "web/tests/FrameTestHelpers.h"
60 60
61 using blink::testing::RunPendingTasks; 61 using blink::testing::RunPendingTasks;
62 62
63 namespace blink { 63 namespace blink {
64 64
65 class TouchActionTrackingWebWidgetClient 65 class TouchActionTrackingWebWidgetClient
66 : public FrameTestHelpers::TestWebWidgetClient { 66 : public FrameTestHelpers::TestWebWidgetClient {
67 public: 67 public:
68 TouchActionTrackingWebWidgetClient() 68 TouchActionTrackingWebWidgetClient()
69 : action_set_count_(0), action_(kWebTouchActionAuto) {} 69 : action_set_count_(0), action_(TouchAction::kTouchActionAuto) {}
70 70
71 // WebWidgetClient methods 71 // WebWidgetClient methods
72 void SetTouchAction(WebTouchAction touch_action) override { 72 void SetTouchAction(TouchAction touch_action) override {
73 action_set_count_++; 73 action_set_count_++;
74 action_ = touch_action; 74 action_ = touch_action;
75 } 75 }
76 76
77 // Local methods 77 // Local methods
78 void Reset() { 78 void Reset() {
79 action_set_count_ = 0; 79 action_set_count_ = 0;
80 action_ = kWebTouchActionAuto; 80 action_ = TouchAction::kTouchActionAuto;
81 } 81 }
82 82
83 int TouchActionSetCount() { return action_set_count_; } 83 int TouchActionSetCount() { return action_set_count_; }
84 84
85 WebTouchAction LastTouchAction() { return action_; } 85 TouchAction LastTouchAction() { return action_; }
86 86
87 private: 87 private:
88 int action_set_count_; 88 int action_set_count_;
89 WebTouchAction action_; 89 TouchAction action_;
90 }; 90 };
91 91
92 const int kKfakeTouchId = 7; 92 const int kKfakeTouchId = 7;
93 93
94 class TouchActionTest : public ::testing::Test { 94 class TouchActionTest : public ::testing::Test {
95 public: 95 public:
96 TouchActionTest() : base_url_("http://www.test.com/") { 96 TouchActionTest() : base_url_("http://www.test.com/") {
97 URLTestHelpers::RegisterMockedURLLoadFromBase( 97 URLTestHelpers::RegisterMockedURLLoadFromBase(
98 WebString::FromUTF8(base_url_), testing::WebTestDataPath(), 98 WebString::FromUTF8(base_url_), testing::WebTestDataPath(),
99 "touch-action-tests.css"); 99 "touch-action-tests.css");
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
332 .Utf8() 332 .Utf8()
333 .data(); 333 .data();
334 334
335 // Now send the touch event and check any touch action result. 335 // Now send the touch event and check any touch action result.
336 SendTouchEvent(web_view, WebInputEvent::kTouchStart, window_point); 336 SendTouchEvent(web_view, WebInputEvent::kTouchStart, window_point);
337 337
338 AtomicString expected_action = element->getAttribute("expected-action"); 338 AtomicString expected_action = element->getAttribute("expected-action");
339 if (expected_action == "auto") { 339 if (expected_action == "auto") {
340 // Auto is the default - no action set. 340 // Auto is the default - no action set.
341 EXPECT_EQ(0, client.TouchActionSetCount()) << failure_context_pos; 341 EXPECT_EQ(0, client.TouchActionSetCount()) << failure_context_pos;
342 EXPECT_EQ(kWebTouchActionAuto, client.LastTouchAction()) 342 EXPECT_EQ(TouchAction::kTouchActionAuto, client.LastTouchAction())
343 << failure_context_pos; 343 << failure_context_pos;
344 } else { 344 } else {
345 // Should have received exactly one touch action. 345 // Should have received exactly one touch action.
346 EXPECT_EQ(1, client.TouchActionSetCount()) << failure_context_pos; 346 EXPECT_EQ(1, client.TouchActionSetCount()) << failure_context_pos;
347 if (client.TouchActionSetCount()) { 347 if (client.TouchActionSetCount()) {
348 if (expected_action == "none") { 348 if (expected_action == "none") {
349 EXPECT_EQ(kWebTouchActionNone, client.LastTouchAction()) 349 EXPECT_EQ(TouchAction::kTouchActionNone, client.LastTouchAction())
350 << failure_context_pos; 350 << failure_context_pos;
351 } else if (expected_action == "pan-x") { 351 } else if (expected_action == "pan-x") {
352 EXPECT_EQ(kWebTouchActionPanX, client.LastTouchAction()) 352 EXPECT_EQ(TouchAction::kTouchActionPanX, client.LastTouchAction())
353 << failure_context_pos; 353 << failure_context_pos;
354 } else if (expected_action == "pan-y") { 354 } else if (expected_action == "pan-y") {
355 EXPECT_EQ(kWebTouchActionPanY, client.LastTouchAction()) 355 EXPECT_EQ(TouchAction::kTouchActionPanY, client.LastTouchAction())
356 << failure_context_pos; 356 << failure_context_pos;
357 } else if (expected_action == "pan-x-y") { 357 } else if (expected_action == "pan-x-y") {
358 EXPECT_EQ((kWebTouchActionPan), client.LastTouchAction()) 358 EXPECT_EQ((TouchAction::kTouchActionPan), client.LastTouchAction())
359 << failure_context_pos; 359 << failure_context_pos;
360 } else if (expected_action == "manipulation") { 360 } else if (expected_action == "manipulation") {
361 EXPECT_EQ((kWebTouchActionManipulation), client.LastTouchAction()) 361 EXPECT_EQ((TouchAction::kTouchActionManipulation),
362 client.LastTouchAction())
362 << failure_context_pos; 363 << failure_context_pos;
363 } else { 364 } else {
364 FAIL() << "Unrecognized expected-action \"" 365 FAIL() << "Unrecognized expected-action \""
365 << expected_action.Ascii().data() << "\" " 366 << expected_action.Ascii().data() << "\" "
366 << failure_context_pos; 367 << failure_context_pos;
367 } 368 }
368 } 369 }
369 } 370 }
370 371
371 // Reset webview touch state. 372 // Reset webview touch state.
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
417 418
418 TEST_F(TouchActionTest, ShadowDOM) { 419 TEST_F(TouchActionTest, ShadowDOM) {
419 RunShadowDOMTest("touch-action-shadow-dom.html"); 420 RunShadowDOMTest("touch-action-shadow-dom.html");
420 } 421 }
421 422
422 TEST_F(TouchActionTest, Pan) { 423 TEST_F(TouchActionTest, Pan) {
423 RunTouchActionTest("touch-action-pan.html"); 424 RunTouchActionTest("touch-action-pan.html");
424 } 425 }
425 426
426 } // namespace blink 427 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/web/WebViewImpl.cpp ('k') | third_party/WebKit/public/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698