Upload package dali_0.9.11.
[platform/core/uifw/dali-core.git] / automated-tests / TET / dali-test-suite / events / utc-Dali-Gesture.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( UtcDaliGestureConstructor, POSITIVE_TC_IDX );
48 TEST_FUNCTION( UtcDaliGestureAssignment, 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 // TestGesture Struct (Gesture constructor is protected)
61 struct TestGesture : public Gesture
62 {
63 public:
64   TestGesture(Gesture::Type type, Gesture::State state)
65   : Gesture(type, state) {}
66
67   virtual ~TestGesture() {}
68 };
69
70 static void UtcDaliGestureConstructor()
71 {
72   TestApplication application; // Reset all test adapter return codes
73
74   TestGesture pan(Gesture::Pan, Gesture::Started);
75   DALI_TEST_EQUALS(Gesture::Pan, pan.type, TEST_LOCATION);
76   DALI_TEST_EQUALS(Gesture::Started, pan.state, TEST_LOCATION);
77
78   TestGesture pinch(Gesture::Pinch, Gesture::Clear);
79   DALI_TEST_EQUALS(Gesture::Pinch, pinch.type, TEST_LOCATION);
80   DALI_TEST_EQUALS(Gesture::Clear, pinch.state, TEST_LOCATION);
81
82   // Test copy constructor
83   TestGesture pan2(pan);
84   DALI_TEST_EQUALS(Gesture::Pan, pan2.type, TEST_LOCATION);
85   DALI_TEST_EQUALS(Gesture::Started, pan2.state, TEST_LOCATION);
86 }
87
88 static void UtcDaliGestureAssignment()
89 {
90   // Test Assignment operator
91   TestGesture pan(Gesture::Pan, Gesture::Finished);
92   DALI_TEST_EQUALS(Gesture::Pan, pan.type, TEST_LOCATION);
93   DALI_TEST_EQUALS(Gesture::Finished, pan.state, TEST_LOCATION);
94
95   TestGesture test(Gesture::Pinch, Gesture::Started);
96   DALI_TEST_EQUALS(Gesture::Pinch, test.type, TEST_LOCATION);
97   DALI_TEST_EQUALS(Gesture::Started, test.state, TEST_LOCATION);
98
99   test = pan;
100   DALI_TEST_EQUALS(Gesture::Pan, test.type, TEST_LOCATION);
101   DALI_TEST_EQUALS(Gesture::Finished, test.state, TEST_LOCATION);
102 }