Upload package dali_0.9.11.
[platform/core/uifw/dali-core.git] / automated-tests / TET / dali-test-suite / events / utc-Dali-LongPressGesture.cpp
1 //
2 // Copyright (c) 2014 Samsung Electronics Co., Ltd.
3 //
4 // Licensed under the Flora License, Version 1.0 (the License);
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 //     http://floralicense.org/license/
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an AS IS BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 //
16
17 #include <iostream>
18
19 #include <stdlib.h>
20 #include <tet_api.h>
21
22 #include <dali/public-api/dali-core.h>
23
24 #include <dali-test-suite-utils.h>
25
26 using namespace Dali;
27
28 static void Startup();
29 static void Cleanup();
30
31 extern "C" {
32   void (*tet_startup)() = Startup;
33   void (*tet_cleanup)() = Cleanup;
34 }
35
36 enum {
37   POSITIVE_TC_IDX = 0x01,
38   NEGATIVE_TC_IDX,
39 };
40
41 #define MAX_NUMBER_OF_TESTS 10000
42 extern "C" {
43   struct tet_testlist tet_testlist[MAX_NUMBER_OF_TESTS];
44 }
45
46 // Add test functionality for all APIs in the class (Positive and Negative)
47 TEST_FUNCTION( UtcDaliLongPressGestureConstructor, POSITIVE_TC_IDX );
48 TEST_FUNCTION( UtcDaliLongPressGestureAssignment, POSITIVE_TC_IDX );
49
50 // Called only once before first test is run.
51 static void Startup()
52 {
53 }
54
55 // Called only once after last test is run
56 static void Cleanup()
57 {
58 }
59
60
61 // Positive test case for a method
62 static void UtcDaliLongPressGestureConstructor()
63 {
64   TestApplication application; // Reset all test adapter return codes
65
66   LongPressGesture gesture( Gesture::Started );
67   DALI_TEST_EQUALS(1u, gesture.numberOfTouches, TEST_LOCATION);
68   DALI_TEST_EQUALS(Gesture::LongPress, gesture.type, TEST_LOCATION);
69
70   // Test Copy constructor
71   gesture.numberOfTouches = 5u;
72
73   LongPressGesture gesture2(gesture);
74   DALI_TEST_EQUALS(5u, gesture2.numberOfTouches, TEST_LOCATION);
75   DALI_TEST_EQUALS(Gesture::LongPress, gesture2.type, TEST_LOCATION);
76   DALI_TEST_EQUALS(Gesture::Started, gesture2.state, TEST_LOCATION);
77 }
78
79 static void UtcDaliLongPressGestureAssignment()
80 {
81   // Test Assignment operator
82   LongPressGesture gesture( Gesture::Started );
83   DALI_TEST_EQUALS(1u, gesture.numberOfTouches, TEST_LOCATION);
84   DALI_TEST_EQUALS(Gesture::LongPress, gesture.type, TEST_LOCATION);
85
86   gesture.numberOfTouches = 5u;
87
88   LongPressGesture gesture2( Gesture::Finished );
89   DALI_TEST_EQUALS(Gesture::Finished, gesture2.state, TEST_LOCATION);
90   gesture2 = gesture;
91   DALI_TEST_EQUALS(5u, gesture2.numberOfTouches, TEST_LOCATION);
92   DALI_TEST_EQUALS(Gesture::LongPress, gesture2.type, TEST_LOCATION);
93   DALI_TEST_EQUALS(Gesture::Started, gesture2.state, TEST_LOCATION);
94 }