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