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