Builder templated constant expansion
[platform/core/uifw/dali-toolkit.git] / automated-tests / TET / dali-toolkit-test-utils / toolkit-style-monitor.h
1 #ifndef __DALI_TOOLKIT_TOOLKIT_STYLE_MONITOR_H__
2 #define __DALI_TOOLKIT_TOOLKIT_STYLE_MONITOR_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/style-monitor.h>
25
26 namespace Dali
27 {
28
29 namespace Internal
30 {
31 namespace Adaptor
32 {
33 class StyleMonitor;
34 }
35 }
36
37 /**
38  * This creates a stubbed StyleMonitor so that internal Toolkit Adaptor calls work.
39  * Furthermore, it provides an interface to see if certain methods were invoked.
40  */
41 class ToolkitStyleMonitor
42 {
43 public: // Constants
44
45   static const std::string DEFAULT_FONT_FAMILY;
46   static const float       DEFAULT_FONT_SIZE;
47
48 public: // Construction & Destruction
49
50   ToolkitStyleMonitor();
51   ~ToolkitStyleMonitor();
52
53 public: // Getters
54
55   StyleMonitor GetStyleMonitor();
56
57 public: // Signal Emissions
58
59   void EmitSignalStyleChange(StyleChange styleChange);
60
61 public: // TEST FUNCTIONS
62
63   // Enumeration of Adaptor methods
64   enum TestFuncEnum
65   {
66     GetDefaultFontFamilyType,
67     GetDefaultFontSizeType,
68     SignalStyleChangeType,
69   };
70
71   void Reset()
72   {
73     mFunctionsCalled.Reset();
74   }
75
76   bool WasCalled(TestFuncEnum func)
77   {
78     switch(func)
79     {
80       case GetDefaultFontFamilyType:          return mFunctionsCalled.GetDefaultFontFamily;
81       case GetDefaultFontSizeType:            return mFunctionsCalled.GetDefaultFontSize;
82       case SignalStyleChangeType:             return mFunctionsCalled.SignalStyleChange;
83     }
84     return false;
85   }
86
87   void ResetCallStatistics(TestFuncEnum func)
88   {
89     switch(func)
90     {
91       case GetDefaultFontFamilyType:          mFunctionsCalled.GetDefaultFontFamily = false; break;
92       case GetDefaultFontSizeType:            mFunctionsCalled.GetDefaultFontSize = false; break;
93       case SignalStyleChangeType:             mFunctionsCalled.SignalStyleChange = false; break;
94     }
95   }
96
97 private:
98
99   struct TestFunctions
100   {
101     TestFunctions()
102     : GetDefaultFontFamily(false),
103       GetDefaultFontSize(false),
104       SignalStyleChange(false)
105     {
106     }
107
108     void Reset()
109     {
110       GetDefaultFontFamily = false;
111       GetDefaultFontSize = false;
112       SignalStyleChange = false;
113     }
114
115     bool GetDefaultFontFamily;
116     bool GetDefaultFontSize;
117     bool SignalStyleChange;
118   };
119
120   TestFunctions mFunctionsCalled;
121
122   // The StyleMonitor stub
123   Internal::Adaptor::StyleMonitor* mStyleMonitorStub;
124   friend class Internal::Adaptor::StyleMonitor;
125   StyleMonitor mStyleMonitor; // Hold a handle ourselves.
126 };
127
128 } // namespace Dali
129
130 #endif // __DALI_TOOLKIT_TOOLKIT_STYLE_MONITOR_H__