[M120 Migration][MM] Support W3C EME
[platform/framework/web/chromium-efl.git] / tizen_src / ewk / unittest / utc_blink_ewk_view_horizontal_panning_hold_set_func.cpp
1 // Copyright 2016 Samsung Electronics. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "utc_blink_ewk_base.h"
6
7 static const char* kURL = "/ewk_view/index_big_red_square.html";
8 static const int kFirstTouchPosition = 500;
9 static const double kTouchEventInterval = 0.012;
10
11 class utc_blink_ewk_view_horizontal_panning_hold_set
12     : public utc_blink_ewk_base {
13  protected:
14   void LoadFinished(Evas_Object*) override { EventLoopStop(Success); }
15
16   // Move touch point from (500, 500) to (400, 400).
17   void Panning() {
18     Ewk_Touch_Point* touch_point = new Ewk_Touch_Point;
19     touch_point->id = 0;
20     touch_point->x = kFirstTouchPosition;
21     touch_point->y = kFirstTouchPosition;
22     touch_point->state = EVAS_TOUCH_POINT_DOWN;
23
24     Eina_List* list = nullptr;
25     list = eina_list_append(list, touch_point);
26
27     ewk_view_feed_touch_event(GetEwkWebView(), EWK_TOUCH_START, list, nullptr);
28
29     for (int i = 1; i <= 10; ++i) {
30       touch_point->x = kFirstTouchPosition - i * 10;
31       touch_point->y = kFirstTouchPosition - i * 10;
32       touch_point->state = EVAS_TOUCH_POINT_MOVE;
33
34       ewk_view_feed_touch_event(GetEwkWebView(), EWK_TOUCH_MOVE, list, nullptr);
35       EventLoopWait(kTouchEventInterval);
36     }
37
38     eina_list_free(list);
39     delete touch_point;
40   }
41 };
42
43 TEST_F(utc_blink_ewk_view_horizontal_panning_hold_set, POS_HOLD_TRUE) {
44   ASSERT_TRUE(ewk_view_url_set(GetEwkWebView(), GetResourceUrl(kURL).c_str()));
45   ASSERT_EQ(Success, EventLoopStart());
46
47   ewk_view_touch_events_enabled_set(GetEwkWebView(), EINA_TRUE);
48   ewk_view_horizontal_panning_hold_set(GetEwkWebView(), EINA_TRUE);
49   Panning();
50   EventLoopWait(1.0);
51
52   int x, y;
53   ASSERT_TRUE(ewk_view_scroll_pos_get(GetEwkWebView(), &x, &y));
54   EXPECT_NE(0, y);
55   EXPECT_EQ(0, x);
56 }
57
58 TEST_F(utc_blink_ewk_view_horizontal_panning_hold_set, POS_HOLD_FALSE) {
59   ASSERT_TRUE(ewk_view_url_set(GetEwkWebView(), GetResourceUrl(kURL).c_str()));
60   ASSERT_EQ(Success, EventLoopStart());
61
62   ewk_view_touch_events_enabled_set(GetEwkWebView(), EINA_TRUE);
63   ewk_view_horizontal_panning_hold_set(GetEwkWebView(), EINA_FALSE);
64   Panning();
65   EventLoopWait(1.0);
66
67   int x, y;
68   ASSERT_TRUE(ewk_view_scroll_pos_get(GetEwkWebView(), &x, &y));
69   EXPECT_NE(0, x);
70   EXPECT_NE(0, y);
71 }
72
73 TEST_F(utc_blink_ewk_view_horizontal_panning_hold_set, NEG_INVALID_VIEW) {
74   ASSERT_TRUE(ewk_view_url_set(GetEwkWebView(), GetResourceUrl(kURL).c_str()));
75   ASSERT_EQ(Success, EventLoopStart());
76
77   ewk_view_touch_events_enabled_set(GetEwkWebView(), EINA_TRUE);
78   ewk_view_horizontal_panning_hold_set(nullptr, EINA_TRUE);
79   Panning();
80   EventLoopWait(1.0);
81
82   int x, y;
83   ASSERT_TRUE(ewk_view_scroll_pos_get(GetEwkWebView(), &x, &y));
84   EXPECT_NE(0, x);
85   EXPECT_NE(0, y);
86 }