Revert "License conversion from Flora to Apache 2.0"
[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 Flora License, Version 1.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://floralicense.org/license/
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 // EXTERNAL INCLUDES
21 #include <string>
22
23 // INTERNAL INCLUDES
24 #include <dali/public-api/adaptor-framework/common/orientation.h>
25
26 namespace Dali
27 {
28
29 namespace Internal
30 {
31 namespace Adaptor
32 {
33 class Orientation;
34 }
35 }
36
37 /**
38  * This creates a stubbed Orientation so that internal Toolkit Adaptor calls work.
39  * Furthermore, it provides an interface to see if certain methods were invoked.
40  */
41 class ToolkitOrientation
42 {
43 public: // Construction & Destruction
44
45   ToolkitOrientation();
46   ~ToolkitOrientation();
47
48 public: // Getters
49
50   Orientation GetHandle();
51
52 public: // Setters
53
54   void SetDegrees( int degrees );
55
56 public: // Signal Emissions
57
58   void EmitChangedSignal();
59
60 public: // TEST FUNCTIONS
61
62   // Enumeration of Adaptor methods
63   enum TestFuncEnum
64   {
65     GetDegrees,
66     GetRadians,
67     ChangedSignal,
68   };
69
70   void Reset()
71   {
72     mFunctionsCalled.Reset();
73   }
74
75   bool WasCalled(TestFuncEnum func)
76   {
77     switch(func)
78     {
79       case GetDegrees:          return mFunctionsCalled.GetDegrees;
80       case GetRadians:          return mFunctionsCalled.GetRadians;
81       case ChangedSignal:       return mFunctionsCalled.ChangedSignal;
82     }
83     return false;
84   }
85
86   void ResetCallStatistics(TestFuncEnum func)
87   {
88     switch(func)
89     {
90       case GetDegrees:          mFunctionsCalled.GetDegrees = false; break;
91       case GetRadians:          mFunctionsCalled.GetRadians = false; break;
92       case ChangedSignal:       mFunctionsCalled.ChangedSignal = false; break;
93     }
94   }
95
96 private:
97
98   struct TestFunctions
99   {
100     TestFunctions()
101     : GetDegrees(false),
102       GetRadians(false),
103       ChangedSignal(false)
104     {
105     }
106
107     void Reset()
108     {
109       GetDegrees = false;
110       GetRadians = false;
111       ChangedSignal = false;
112     }
113
114     bool GetDegrees;
115     bool GetRadians;
116     bool ChangedSignal;
117   };
118
119   TestFunctions mFunctionsCalled;
120
121   // The stub
122   Internal::Adaptor::Orientation* mOrientationStub;
123   friend class Internal::Adaptor::Orientation;
124   Orientation mOrientation; // Hold a handle ourselves.
125 };
126
127 } // namespace Dali
128
129 #endif // __DALI_TOOLKIT_TOOLKIT_ORIENTATION_H__