303f3a6268ecddaa63f4ce38c384023bdafd0997
[platform/core/uifw/dali-toolkit.git] / automated-tests / src / dali-toolkit / dali-toolkit-test-utils / toolkit-orientation.h
1 #ifndef __DALI_TOOLKIT_TOOLKIT_ORIENTATION_H__
2 #define __DALI_TOOLKIT_TOOLKIT_ORIENTATION_H__
3
4 /*
5  * Copyright (c) 2014 Samsung Electronics Co., Ltd.
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  */
20
21 // EXTERNAL INCLUDES
22 #include <string>
23
24 // INTERNAL INCLUDES
25 #include <dali/public-api/orientation.h>
26
27 namespace Dali
28 {
29
30 namespace Internal
31 {
32 namespace Adaptor
33 {
34 class Orientation;
35 }
36 }
37
38 /**
39  * This creates a stubbed Orientation so that internal Toolkit Adaptor calls work.
40  * Furthermore, it provides an interface to see if certain methods were invoked.
41  */
42 class ToolkitOrientation
43 {
44 public: // Construction & Destruction
45
46   ToolkitOrientation();
47   ~ToolkitOrientation();
48
49 public: // Getters
50
51   Orientation GetHandle();
52
53 public: // Setters
54
55   void SetDegrees( int degrees );
56
57 public: // Signal Emissions
58
59   void EmitChangedSignal();
60
61 public: // TEST FUNCTIONS
62
63   // Enumeration of Adaptor methods
64   enum TestFuncEnum
65   {
66     GetDegrees,
67     GetRadians,
68     ChangedSignal,
69   };
70
71   void Reset()
72   {
73     mFunctionsCalled.Reset();
74   }
75
76   bool WasCalled(TestFuncEnum func)
77   {
78     switch(func)
79     {
80       case GetDegrees:          return mFunctionsCalled.GetDegrees;
81       case GetRadians:          return mFunctionsCalled.GetRadians;
82       case ChangedSignal:       return mFunctionsCalled.ChangedSignal;
83     }
84     return false;
85   }
86
87   void ResetCallStatistics(TestFuncEnum func)
88   {
89     switch(func)
90     {
91       case GetDegrees:          mFunctionsCalled.GetDegrees = false; break;
92       case GetRadians:          mFunctionsCalled.GetRadians = false; break;
93       case ChangedSignal:       mFunctionsCalled.ChangedSignal = false; break;
94     }
95   }
96
97 private:
98
99   struct TestFunctions
100   {
101     TestFunctions()
102     : GetDegrees(false),
103       GetRadians(false),
104       ChangedSignal(false)
105     {
106     }
107
108     void Reset()
109     {
110       GetDegrees = false;
111       GetRadians = false;
112       ChangedSignal = false;
113     }
114
115     bool GetDegrees;
116     bool GetRadians;
117     bool ChangedSignal;
118   };
119
120   TestFunctions mFunctionsCalled;
121
122   // The stub
123   Internal::Adaptor::Orientation* mOrientationStub;
124   friend class Internal::Adaptor::Orientation;
125   Orientation mOrientation; // Hold a handle ourselves.
126 };
127
128 } // namespace Dali
129
130 #endif // __DALI_TOOLKIT_TOOLKIT_ORIENTATION_H__