Merge lp:~compiz-team/compiz/compiz.fix_1063617.9.1 into lp:compiz/0.9.9
- compiz.fix_1063617.9.1
- Merge into 0.9.9
Status: | Merged |
---|---|
Approved by: | Marco Trevisan (Treviño) |
Approved revision: | 3517 |
Merged at revision: | 3610 |
Proposed branch: | lp:~compiz-team/compiz/compiz.fix_1063617.9.1 |
Merge into: | lp:compiz/0.9.9 |
Prerequisite: | lp:~compiz-team/compiz/compiz.fix_1063617.8 |
Diff against target: |
612 lines (+282/-79) 1 file modified
compizconfig/libcompizconfig/tests/compizconfig_test_ccs_setting.cpp (+282/-79) |
To merge this branch: | bzr merge lp:~compiz-team/compiz/compiz.fix_1063617.9.1 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Marco Trevisan (Treviño) | Approve | ||
PS Jenkins bot (community) | continuous-integration | Approve | |
Review via email: mp+148003@code.launchpad.net |
This proposal supersedes a proposal from 2013-02-12.
Commit message
Also allow the tests to run through ccsSetValue
Description of the change
Also allow the tests to run through ccsSetValue (increases coverage)
MC Return (mc-return) wrote : Posted in a previous version of this proposal | # |
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal | # |
FAILED: Continuous integration, rev:3514
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal | # |
FAILED: Continuous integration, rev:3515
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal | # |
FAILED: Continuous integration, rev:3515
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
MC Return (mc-return) wrote : | # |
There is a typo here:
246 + throw std::runtime_error ("called PerfomSet with unknown SetMethod");
it should probably read:
246 + throw std::runtime_error ("called performSet with unknown SetMethod");
- 3517. By Sam Spilsbury
-
Small typo fix
Sam Spilsbury (smspillaz) wrote : | # |
Thanks, fixed.
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:3517
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Preview Diff
1 | === modified file 'compizconfig/libcompizconfig/tests/compizconfig_test_ccs_setting.cpp' | |||
2 | --- compizconfig/libcompizconfig/tests/compizconfig_test_ccs_setting.cpp 2012-12-12 08:54:11 +0000 | |||
3 | +++ compizconfig/libcompizconfig/tests/compizconfig_test_ccs_setting.cpp 2013-02-13 01:43:22 +0000 | |||
4 | @@ -18,6 +18,8 @@ | |||
5 | 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
6 | 19 | */ | 19 | */ |
7 | 20 | 20 | ||
8 | 21 | #include <tr1/tuple> | ||
9 | 22 | |||
10 | 21 | #include <gtest/gtest.h> | 23 | #include <gtest/gtest.h> |
11 | 22 | #include <gmock/gmock.h> | 24 | #include <gmock/gmock.h> |
12 | 23 | 25 | ||
13 | @@ -45,6 +47,7 @@ | |||
14 | 45 | using ::testing::Invoke; | 47 | using ::testing::Invoke; |
15 | 46 | using ::testing::ReturnNull; | 48 | using ::testing::ReturnNull; |
16 | 47 | using ::testing::Values; | 49 | using ::testing::Values; |
17 | 50 | using ::testing::Combine; | ||
18 | 48 | 51 | ||
19 | 49 | TEST(CCSSettingTest, TestMock) | 52 | TEST(CCSSettingTest, TestMock) |
20 | 50 | { | 53 | { |
21 | @@ -497,7 +500,11 @@ | |||
22 | 497 | 500 | ||
23 | 498 | ReturnType operator () () | 501 | ReturnType operator () () |
24 | 499 | { | 502 | { |
26 | 500 | return strdup (Parent::mValue); | 503 | /* Passing an illegal value is okay */ |
27 | 504 | if (Parent::mValue) | ||
28 | 505 | return strdup (Parent::mValue); | ||
29 | 506 | else | ||
30 | 507 | return NULL; | ||
31 | 501 | } | 508 | } |
32 | 502 | 509 | ||
33 | 503 | private: | 510 | private: |
34 | @@ -521,8 +528,11 @@ | |||
35 | 521 | 528 | ||
36 | 522 | ReturnType operator () () | 529 | ReturnType operator () () |
37 | 523 | { | 530 | { |
40 | 524 | return ccsCopyList (*Parent::mValue, | 531 | if (Parent::mValue) |
41 | 525 | Parent::mValue->setting ().get ()); | 532 | return ccsCopyList (*Parent::mValue, |
42 | 533 | Parent::mValue->setting ().get ()); | ||
43 | 534 | else | ||
44 | 535 | return NULL; | ||
45 | 526 | } | 536 | } |
46 | 527 | }; | 537 | }; |
47 | 528 | 538 | ||
48 | @@ -732,7 +742,17 @@ | |||
49 | 732 | 742 | ||
50 | 733 | private: | 743 | private: |
51 | 734 | 744 | ||
53 | 735 | const cci::SettingValueListWrapper::Ptr & | 745 | virtual const cci::SettingValueListWrapper::Ptr & |
54 | 746 | SetupWrapper (CCSSettingType type, | ||
55 | 747 | const CCSSettingInfoPtr &info) = 0; | ||
56 | 748 | }; | ||
57 | 749 | |||
58 | 750 | class ListValueContainerFromChildValueBase : | ||
59 | 751 | public ListValueContainerBase | ||
60 | 752 | { | ||
61 | 753 | private: | ||
62 | 754 | |||
63 | 755 | virtual const cci::SettingValueListWrapper::Ptr & | ||
64 | 736 | SetupWrapper (CCSSettingType type, | 756 | SetupWrapper (CCSSettingType type, |
65 | 737 | const CCSSettingInfoPtr &info) | 757 | const CCSSettingInfoPtr &info) |
66 | 738 | { | 758 | { |
67 | @@ -757,13 +777,45 @@ | |||
68 | 757 | virtual CCSSettingValue * GetValueForListWrapper () = 0; | 777 | virtual CCSSettingValue * GetValueForListWrapper () = 0; |
69 | 758 | }; | 778 | }; |
70 | 759 | 779 | ||
71 | 780 | class ListValueContainerFromList : | ||
72 | 781 | public ListValueContainerBase | ||
73 | 782 | { | ||
74 | 783 | public: | ||
75 | 784 | |||
76 | 785 | ListValueContainerFromList (CCSSettingValueList rawValueList) : | ||
77 | 786 | mRawValueList (rawValueList) | ||
78 | 787 | { | ||
79 | 788 | } | ||
80 | 789 | |||
81 | 790 | private: | ||
82 | 791 | |||
83 | 792 | const cci::SettingValueListWrapper::Ptr & | ||
84 | 793 | SetupWrapper (CCSSettingType type, | ||
85 | 794 | const CCSSettingInfoPtr &info) | ||
86 | 795 | { | ||
87 | 796 | if (!mWrapper) | ||
88 | 797 | { | ||
89 | 798 | const CCSSettingPtr &setting (mContainedValueGenerator.GetSetting (type, info)); | ||
90 | 799 | mWrapper.reset (new cci::SettingValueListWrapper (ccsCopyList (mRawValueList, setting.get ()), | ||
91 | 800 | cci::Deep, | ||
92 | 801 | type, | ||
93 | 802 | info, | ||
94 | 803 | setting)); | ||
95 | 804 | } | ||
96 | 805 | |||
97 | 806 | return mWrapper; | ||
98 | 807 | } | ||
99 | 808 | |||
100 | 809 | CCSSettingValueList mRawValueList; | ||
101 | 810 | }; | ||
102 | 811 | |||
103 | 760 | template <typename SettingValueType> | 812 | template <typename SettingValueType> |
106 | 761 | class ListValueContainer : | 813 | class ChildValueListValueContainer : |
107 | 762 | public ListValueContainerBase | 814 | public ListValueContainerFromChildValueBase |
108 | 763 | { | 815 | { |
109 | 764 | public: | 816 | public: |
110 | 765 | 817 | ||
112 | 766 | ListValueContainer (const SettingValueType &value) : | 818 | ChildValueListValueContainer (const SettingValueType &value) : |
113 | 767 | mRawChildValue (value) | 819 | mRawChildValue (value) |
114 | 768 | { | 820 | { |
115 | 769 | } | 821 | } |
116 | @@ -782,8 +834,136 @@ | |||
117 | 782 | typename ValueContainer <CCSSettingValueList>::Ptr | 834 | typename ValueContainer <CCSSettingValueList>::Ptr |
118 | 783 | ContainList (const SettingValueType &value) | 835 | ContainList (const SettingValueType &value) |
119 | 784 | { | 836 | { |
122 | 785 | return boost::make_shared <ListValueContainer <SettingValueType> > (value); | 837 | return boost::make_shared <ChildValueListValueContainer <SettingValueType> > (value); |
123 | 786 | } | 838 | } |
124 | 839 | |||
125 | 840 | typename ValueContainer <CCSSettingValueList>::Ptr | ||
126 | 841 | ContainPrexistingList (const CCSSettingValueList &value) | ||
127 | 842 | { | ||
128 | 843 | return boost::make_shared <ListValueContainerFromList> (value); | ||
129 | 844 | } | ||
130 | 845 | |||
131 | 846 | template <typename SettingValueType> | ||
132 | 847 | struct SettingMutators | ||
133 | 848 | { | ||
134 | 849 | typedef CCSSetStatus (*SetFunction) (CCSSetting *setting, | ||
135 | 850 | SettingValueType data, | ||
136 | 851 | Bool); | ||
137 | 852 | typedef Bool (*GetFunction) (CCSSetting *setting, | ||
138 | 853 | SettingValueType *); | ||
139 | 854 | }; | ||
140 | 855 | |||
141 | 856 | typedef enum _SetMethod | ||
142 | 857 | { | ||
143 | 858 | ThroughRaw, | ||
144 | 859 | ThroughValue | ||
145 | 860 | } SetMethod; | ||
146 | 861 | |||
147 | 862 | template <typename SettingValueType> | ||
148 | 863 | CCSSetStatus performRawSet (const SettingValueType &rawValue, | ||
149 | 864 | const CCSSettingPtr &setting, | ||
150 | 865 | typename SettingMutators<SettingValueType>::SetFunction setFunction) | ||
151 | 866 | { | ||
152 | 867 | return (*setFunction) (setting.get (), rawValue, FALSE); | ||
153 | 868 | } | ||
154 | 869 | |||
155 | 870 | template <typename SettingValueType> | ||
156 | 871 | class RawValueContainmentPacker | ||
157 | 872 | { | ||
158 | 873 | public: | ||
159 | 874 | |||
160 | 875 | RawValueContainmentPacker (const SettingValueType &value) : | ||
161 | 876 | mValue (value) | ||
162 | 877 | { | ||
163 | 878 | } | ||
164 | 879 | |||
165 | 880 | typename ValueContainer <SettingValueType>::Ptr | ||
166 | 881 | operator () () | ||
167 | 882 | { | ||
168 | 883 | return ContainNormal (mValue); | ||
169 | 884 | } | ||
170 | 885 | |||
171 | 886 | private: | ||
172 | 887 | |||
173 | 888 | const SettingValueType &mValue; | ||
174 | 889 | }; | ||
175 | 890 | |||
176 | 891 | template <> | ||
177 | 892 | class RawValueContainmentPacker <CCSSettingValueList> | ||
178 | 893 | { | ||
179 | 894 | public: | ||
180 | 895 | |||
181 | 896 | RawValueContainmentPacker (const CCSSettingValueList &value) : | ||
182 | 897 | mValue (value) | ||
183 | 898 | { | ||
184 | 899 | } | ||
185 | 900 | |||
186 | 901 | typename ValueContainer <CCSSettingValueList>::Ptr | ||
187 | 902 | operator () () | ||
188 | 903 | { | ||
189 | 904 | return ContainPrexistingList (mValue); | ||
190 | 905 | } | ||
191 | 906 | |||
192 | 907 | private: | ||
193 | 908 | |||
194 | 909 | const CCSSettingValueList &mValue; | ||
195 | 910 | }; | ||
196 | 911 | |||
197 | 912 | template <typename SettingValueType> | ||
198 | 913 | typename ValueContainer <SettingValueType>::Ptr | ||
199 | 914 | ContainRawValue (const SettingValueType &value) | ||
200 | 915 | { | ||
201 | 916 | return RawValueContainmentPacker <SettingValueType> (value) (); | ||
202 | 917 | } | ||
203 | 918 | |||
204 | 919 | template <typename SettingValueType> | ||
205 | 920 | CCSSetStatus performValueSet (const SettingValueType &rawValue, | ||
206 | 921 | const CCSSettingInfoPtr &info, | ||
207 | 922 | CCSSettingType type, | ||
208 | 923 | const CCSSettingPtr &setting) | ||
209 | 924 | { | ||
210 | 925 | typename ValueContainer <SettingValueType>::Ptr container (ContainRawValue (rawValue)); | ||
211 | 926 | const CCSSettingValuePtr &value (container->getContainedValue (type, | ||
212 | 927 | info)); | ||
213 | 928 | |||
214 | 929 | return ccsSetValue (setting.get (), value.get (), FALSE); | ||
215 | 930 | } | ||
216 | 931 | |||
217 | 932 | template <typename SettingValueType> | ||
218 | 933 | CCSSetStatus performSet (const SettingValueType &rawValue, | ||
219 | 934 | const CCSSettingPtr &setting, | ||
220 | 935 | const CCSSettingInfoPtr &info, | ||
221 | 936 | CCSSettingType type, | ||
222 | 937 | typename SettingMutators<SettingValueType>::SetFunction setFunction, | ||
223 | 938 | SetMethod method) | ||
224 | 939 | { | ||
225 | 940 | /* XXX: | ||
226 | 941 | * This is really bad design because it effectively involves runtime | ||
227 | 942 | * switching on types. Unfortunately, there doesn't seem to be a better | ||
228 | 943 | * way to do this that's not hugely verbose - injecting the method | ||
229 | 944 | * as a class or a function would mean that we'd have to expose | ||
230 | 945 | * template parameters to areas where we can't do that because we | ||
231 | 946 | * want the tests to run once for ccsSetValue and once for | ||
232 | 947 | * ccsSet* . If we did that, we'd have to either write the tests | ||
233 | 948 | * twice, or write the INSTANTIATE_TEST_CASE_P sections twice and | ||
234 | 949 | * both are 200+ lines of copy-and-paste as opposed to this type-switch | ||
235 | 950 | * here | ||
236 | 951 | */ | ||
237 | 952 | switch (method) | ||
238 | 953 | { | ||
239 | 954 | case ThroughRaw: | ||
240 | 955 | return performRawSet (rawValue, setting, setFunction); | ||
241 | 956 | break; | ||
242 | 957 | case ThroughValue: | ||
243 | 958 | return performValueSet (rawValue, info, type, setting); | ||
244 | 959 | break; | ||
245 | 960 | default: | ||
246 | 961 | throw std::runtime_error ("called perfomSet with unknown SetMethod"); | ||
247 | 962 | } | ||
248 | 963 | |||
249 | 964 | throw std::runtime_error ("Unreachable"); | ||
250 | 965 | } | ||
251 | 966 | |||
252 | 787 | 967 | ||
253 | 788 | class SetParam | 968 | class SetParam |
254 | 789 | { | 969 | { |
255 | @@ -798,10 +978,10 @@ | |||
256 | 798 | virtual void TearDownSetting () = 0; | 978 | virtual void TearDownSetting () = 0; |
257 | 799 | virtual CCSSettingType GetSettingType () = 0; | 979 | virtual CCSSettingType GetSettingType () = 0; |
258 | 800 | virtual void SetUpParam (const CCSSettingPtr &) = 0; | 980 | virtual void SetUpParam (const CCSSettingPtr &) = 0; |
263 | 801 | virtual CCSSetStatus setWithInvalidType () = 0; | 981 | virtual CCSSetStatus setWithInvalidType (SetMethod) = 0; |
264 | 802 | virtual CCSSetStatus setToFailValue () = 0; | 982 | virtual CCSSetStatus setToFailValue (SetMethod) = 0; |
265 | 803 | virtual CCSSetStatus setToNonDefaultValue () = 0; | 983 | virtual CCSSetStatus setToNonDefaultValue (SetMethod) = 0; |
266 | 804 | virtual CCSSetStatus setToDefaultValue () = 0; | 984 | virtual CCSSetStatus setToDefaultValue (SetMethod) = 0; |
267 | 805 | }; | 985 | }; |
268 | 806 | 986 | ||
269 | 807 | void stubInitInfo (CCSSettingType type, | 987 | void stubInitInfo (CCSSettingType type, |
270 | @@ -871,16 +1051,6 @@ | |||
271 | 871 | CCSSettingValue *mValue; | 1051 | CCSSettingValue *mValue; |
272 | 872 | }; | 1052 | }; |
273 | 873 | 1053 | ||
274 | 874 | template <typename SettingValueType> | ||
275 | 875 | struct SettingMutators | ||
276 | 876 | { | ||
277 | 877 | typedef CCSSetStatus (*SetFunction) (CCSSetting *setting, | ||
278 | 878 | SettingValueType data, | ||
279 | 879 | Bool); | ||
280 | 880 | typedef Bool (*GetFunction) (CCSSetting *setting, | ||
281 | 881 | SettingValueType *); | ||
282 | 882 | }; | ||
283 | 883 | |||
284 | 884 | class InternalSetParam : | 1054 | class InternalSetParam : |
285 | 885 | public SetParam | 1055 | public SetParam |
286 | 886 | { | 1056 | { |
287 | @@ -895,8 +1065,6 @@ | |||
288 | 895 | 1065 | ||
289 | 896 | virtual void TearDownSetting () | 1066 | virtual void TearDownSetting () |
290 | 897 | { | 1067 | { |
291 | 898 | if (mSetting) | ||
292 | 899 | setToDefaultValue (); | ||
293 | 900 | } | 1068 | } |
294 | 901 | 1069 | ||
295 | 902 | void InitDefaultsForSetting (const SetUpSettingFunc &func) | 1070 | void InitDefaultsForSetting (const SetUpSettingFunc &func) |
296 | @@ -944,7 +1112,7 @@ | |||
297 | 944 | GET_INTERFACE_TYPE (CCSSettingInterface)); | 1112 | GET_INTERFACE_TYPE (CCSSettingInterface)); |
298 | 945 | } | 1113 | } |
299 | 946 | 1114 | ||
301 | 947 | virtual CCSSetStatus setToFailValue () | 1115 | virtual CCSSetStatus setToFailValue (SetMethod method) |
302 | 948 | { | 1116 | { |
303 | 949 | return SetFailed; | 1117 | return SetFailed; |
304 | 950 | } | 1118 | } |
305 | @@ -961,6 +1129,8 @@ | |||
306 | 961 | CCSSettingType mType; | 1129 | CCSSettingType mType; |
307 | 962 | CCSSettingPtr mSetting; | 1130 | CCSSettingPtr mSetting; |
308 | 963 | 1131 | ||
309 | 1132 | CCSSettingInterface tmpSettingInterface; | ||
310 | 1133 | |||
311 | 964 | private: | 1134 | private: |
312 | 965 | 1135 | ||
313 | 966 | static const CCSSettingType incorrectSettingType = TypeNum; | 1136 | static const CCSSettingType incorrectSettingType = TypeNum; |
314 | @@ -1034,26 +1204,25 @@ | |||
315 | 1034 | TakeReferenceToCreatedSetting (setting); | 1204 | TakeReferenceToCreatedSetting (setting); |
316 | 1035 | } | 1205 | } |
317 | 1036 | 1206 | ||
319 | 1037 | virtual CCSSetStatus setWithInvalidType () | 1207 | virtual CCSSetStatus setWithInvalidType (SetMethod method) |
320 | 1038 | { | 1208 | { |
321 | 1039 | /* Temporarily redirect the setting interface to | 1209 | /* Temporarily redirect the setting interface to |
322 | 1040 | * our own with an overloaded settingGetType function */ | 1210 | * our own with an overloaded settingGetType function */ |
323 | 1041 | |||
324 | 1042 | const CCSSettingInterface *iface = RedirectSettingInterface (); | 1211 | const CCSSettingInterface *iface = RedirectSettingInterface (); |
326 | 1043 | CCSSetStatus ret = (*mSetFunction) (mSetting.get (), mNonDefaultValue, FALSE); | 1212 | CCSSetStatus ret = performSet (mNonDefaultValue, mSetting, mInfo, mType, mSetFunction, method); |
327 | 1044 | RestoreSettingInterface (iface); | 1213 | RestoreSettingInterface (iface); |
328 | 1045 | 1214 | ||
329 | 1046 | return ret; | 1215 | return ret; |
330 | 1047 | } | 1216 | } |
331 | 1048 | 1217 | ||
333 | 1049 | virtual CCSSetStatus setToNonDefaultValue () | 1218 | virtual CCSSetStatus setToNonDefaultValue (SetMethod method) |
334 | 1050 | { | 1219 | { |
336 | 1051 | return (*mSetFunction) (mSetting.get (), mNonDefaultValue, FALSE); | 1220 | return performSet (mNonDefaultValue, mSetting, mInfo, mType, mSetFunction, method); |
337 | 1052 | } | 1221 | } |
338 | 1053 | 1222 | ||
340 | 1054 | virtual CCSSetStatus setToDefaultValue () | 1223 | virtual CCSSetStatus setToDefaultValue (SetMethod method) |
341 | 1055 | { | 1224 | { |
343 | 1056 | return (*mSetFunction) (mSetting.get (), mDefaultValue, FALSE); | 1225 | return performSet (mDefaultValue, mSetting, mInfo, mType, mSetFunction, method); |
344 | 1057 | } | 1226 | } |
345 | 1058 | 1227 | ||
346 | 1059 | private: | 1228 | private: |
347 | @@ -1073,14 +1242,17 @@ | |||
348 | 1073 | protected: | 1242 | protected: |
349 | 1074 | 1243 | ||
350 | 1075 | SetWithDisallowedValueBase (const CCSSettingPtr &setting, | 1244 | SetWithDisallowedValueBase (const CCSSettingPtr &setting, |
352 | 1076 | const CCSSettingInfoPtr &info) : | 1245 | const CCSSettingInfoPtr &info, |
353 | 1246 | CCSSettingType type) : | ||
354 | 1077 | mSetting (setting), | 1247 | mSetting (setting), |
356 | 1078 | mInfo (info) | 1248 | mInfo (info), |
357 | 1249 | mType (type) | ||
358 | 1079 | { | 1250 | { |
359 | 1080 | } | 1251 | } |
360 | 1081 | 1252 | ||
361 | 1082 | CCSSettingPtr mSetting; | 1253 | CCSSettingPtr mSetting; |
362 | 1083 | CCSSettingInfoPtr mInfo; | 1254 | CCSSettingInfoPtr mInfo; |
363 | 1255 | CCSSettingType mType; | ||
364 | 1084 | }; | 1256 | }; |
365 | 1085 | 1257 | ||
366 | 1086 | template <typename SettingValueType> | 1258 | template <typename SettingValueType> |
367 | @@ -1093,8 +1265,9 @@ | |||
368 | 1093 | 1265 | ||
369 | 1094 | SetWithDisallowedValueTemplatedBase (SetFunction setFunction, | 1266 | SetWithDisallowedValueTemplatedBase (SetFunction setFunction, |
370 | 1095 | const CCSSettingPtr &setting, | 1267 | const CCSSettingPtr &setting, |
373 | 1096 | const CCSSettingInfoPtr &info) : | 1268 | const CCSSettingInfoPtr &info, |
374 | 1097 | SetWithDisallowedValueBase (setting, info), | 1269 | CCSSettingType type) : |
375 | 1270 | SetWithDisallowedValueBase (setting, info, type), | ||
376 | 1098 | mSetFunction (setFunction) | 1271 | mSetFunction (setFunction) |
377 | 1099 | { | 1272 | { |
378 | 1100 | } | 1273 | } |
379 | @@ -1112,12 +1285,13 @@ | |||
380 | 1112 | 1285 | ||
381 | 1113 | SetWithDisallowedValue (SetFunction setFunction, | 1286 | SetWithDisallowedValue (SetFunction setFunction, |
382 | 1114 | const CCSSettingPtr &setting, | 1287 | const CCSSettingPtr &setting, |
385 | 1115 | const CCSSettingInfoPtr &info) : | 1288 | const CCSSettingInfoPtr &info, |
386 | 1116 | SetWithDisallowedValueTemplatedBase <SettingValueType> (setFunction, setting, info) | 1289 | CCSSettingType type) : |
387 | 1290 | SetWithDisallowedValueTemplatedBase <SettingValueType> (setFunction, setting, info, type) | ||
388 | 1117 | { | 1291 | { |
389 | 1118 | } | 1292 | } |
390 | 1119 | 1293 | ||
392 | 1120 | CCSSetStatus operator () () | 1294 | CCSSetStatus operator () (SetMethod method) |
393 | 1121 | { | 1295 | { |
394 | 1122 | return SetFailed; | 1296 | return SetFailed; |
395 | 1123 | } | 1297 | } |
396 | @@ -1134,16 +1308,20 @@ | |||
397 | 1134 | 1308 | ||
398 | 1135 | SetWithDisallowedValue (SetFunction setFunction, | 1309 | SetWithDisallowedValue (SetFunction setFunction, |
399 | 1136 | const CCSSettingPtr &setting, | 1310 | const CCSSettingPtr &setting, |
402 | 1137 | const CCSSettingInfoPtr &info) : | 1311 | const CCSSettingInfoPtr &info, |
403 | 1138 | SetWithDisallowedValueTemplatedBase <int> (setFunction, setting, info) | 1312 | CCSSettingType type) : |
404 | 1313 | SetWithDisallowedValueTemplatedBase <int> (setFunction, setting, info, type) | ||
405 | 1139 | { | 1314 | { |
406 | 1140 | } | 1315 | } |
407 | 1141 | 1316 | ||
409 | 1142 | CCSSetStatus operator () () | 1317 | CCSSetStatus operator () (SetMethod method) |
410 | 1143 | { | 1318 | { |
414 | 1144 | return (*Parent::mSetFunction) (Parent::mSetting.get (), | 1319 | return performSet <int> (Parent::mInfo->forInt.min - 1, |
415 | 1145 | Parent::mInfo->forInt.min - 1, | 1320 | Parent::mSetting, |
416 | 1146 | FALSE); | 1321 | Parent::mInfo, |
417 | 1322 | Parent::mType, | ||
418 | 1323 | Parent::mSetFunction, | ||
419 | 1324 | method); | ||
420 | 1147 | } | 1325 | } |
421 | 1148 | }; | 1326 | }; |
422 | 1149 | 1327 | ||
423 | @@ -1158,16 +1336,20 @@ | |||
424 | 1158 | 1336 | ||
425 | 1159 | SetWithDisallowedValue (SetFunction setFunction, | 1337 | SetWithDisallowedValue (SetFunction setFunction, |
426 | 1160 | const CCSSettingPtr &setting, | 1338 | const CCSSettingPtr &setting, |
429 | 1161 | const CCSSettingInfoPtr &info) : | 1339 | const CCSSettingInfoPtr &info, |
430 | 1162 | SetWithDisallowedValueTemplatedBase <float> (setFunction, setting, info) | 1340 | CCSSettingType type) : |
431 | 1341 | SetWithDisallowedValueTemplatedBase <float> (setFunction, setting, info, type) | ||
432 | 1163 | { | 1342 | { |
433 | 1164 | } | 1343 | } |
434 | 1165 | 1344 | ||
436 | 1166 | CCSSetStatus operator () () | 1345 | CCSSetStatus operator () (SetMethod method) |
437 | 1167 | { | 1346 | { |
441 | 1168 | return (*Parent::mSetFunction) (Parent::mSetting.get (), | 1347 | return performSet <float> (Parent::mInfo->forFloat.min - 1.0f, |
442 | 1169 | Parent::mInfo->forFloat.min - 1, | 1348 | Parent::mSetting, |
443 | 1170 | FALSE); | 1349 | Parent::mInfo, |
444 | 1350 | Parent::mType, | ||
445 | 1351 | Parent::mSetFunction, | ||
446 | 1352 | method); | ||
447 | 1171 | } | 1353 | } |
448 | 1172 | }; | 1354 | }; |
449 | 1173 | 1355 | ||
450 | @@ -1182,16 +1364,20 @@ | |||
451 | 1182 | 1364 | ||
452 | 1183 | SetWithDisallowedValue (SetFunction setFunction, | 1365 | SetWithDisallowedValue (SetFunction setFunction, |
453 | 1184 | const CCSSettingPtr &setting, | 1366 | const CCSSettingPtr &setting, |
456 | 1185 | const CCSSettingInfoPtr &info) : | 1367 | const CCSSettingInfoPtr &info, |
457 | 1186 | SetWithDisallowedValueTemplatedBase <const char *> (setFunction, setting, info) | 1368 | CCSSettingType type) : |
458 | 1369 | SetWithDisallowedValueTemplatedBase <const char *> (setFunction, setting, info, type) | ||
459 | 1187 | { | 1370 | { |
460 | 1188 | } | 1371 | } |
461 | 1189 | 1372 | ||
463 | 1190 | CCSSetStatus operator () () | 1373 | CCSSetStatus operator () (SetMethod method) |
464 | 1191 | { | 1374 | { |
468 | 1192 | return (*Parent::mSetFunction) (Parent::mSetting.get (), | 1375 | return performSet <const char *> (NULL, |
469 | 1193 | NULL, | 1376 | Parent::mSetting, |
470 | 1194 | FALSE); | 1377 | Parent::mInfo, |
471 | 1378 | Parent::mType, | ||
472 | 1379 | Parent::mSetFunction, | ||
473 | 1380 | method); | ||
474 | 1195 | } | 1381 | } |
475 | 1196 | }; | 1382 | }; |
476 | 1197 | 1383 | ||
477 | @@ -1221,12 +1407,13 @@ | |||
478 | 1221 | { | 1407 | { |
479 | 1222 | } | 1408 | } |
480 | 1223 | 1409 | ||
482 | 1224 | virtual CCSSetStatus setToFailValue () | 1410 | virtual CCSSetStatus setToFailValue (SetMethod method) |
483 | 1225 | { | 1411 | { |
484 | 1226 | typedef TypedSetParam <SettingValueType> Parent; | 1412 | typedef TypedSetParam <SettingValueType> Parent; |
485 | 1227 | return SetWithDisallowedValue <SettingValueType> (Parent::mSetFunction, | 1413 | return SetWithDisallowedValue <SettingValueType> (Parent::mSetFunction, |
486 | 1228 | Parent::mSetting, | 1414 | Parent::mSetting, |
488 | 1229 | Parent::mInfo) (); | 1415 | Parent::mInfo, |
489 | 1416 | Parent::mType) (method); | ||
490 | 1230 | } | 1417 | } |
491 | 1231 | }; | 1418 | }; |
492 | 1232 | 1419 | ||
493 | @@ -1264,27 +1451,41 @@ | |||
494 | 1264 | changeTo); | 1451 | changeTo); |
495 | 1265 | } | 1452 | } |
496 | 1266 | 1453 | ||
497 | 1454 | typedef std::tr1::tuple <SetParam::Ptr, | ||
498 | 1455 | SetMethod> SettingDefaultImplSetParamType; | ||
499 | 1456 | |||
500 | 1267 | class SettingDefaultImplSet : | 1457 | class SettingDefaultImplSet : |
501 | 1268 | public CCSSettingDefaultImplTest, | 1458 | public CCSSettingDefaultImplTest, |
503 | 1269 | public WithParamInterface <SetParam::Ptr> | 1459 | public WithParamInterface <SettingDefaultImplSetParamType> |
504 | 1270 | { | 1460 | { |
505 | 1271 | public: | 1461 | public: |
506 | 1272 | 1462 | ||
507 | 1463 | SettingDefaultImplSet () : | ||
508 | 1464 | setHarness (std::tr1::get <0> (GetParam ())), | ||
509 | 1465 | setMethod (std::tr1::get <1> (GetParam ())) | ||
510 | 1466 | { | ||
511 | 1467 | } | ||
512 | 1468 | |||
513 | 1273 | virtual void SetUp () | 1469 | virtual void SetUp () |
514 | 1274 | { | 1470 | { |
517 | 1275 | GetParam ()->SetUpSetting (boost::bind (&CCSSettingDefaultImplTest::SetUpSetting, this, _1)); | 1471 | setHarness->SetUpSetting (boost::bind (&CCSSettingDefaultImplTest::SetUpSetting, this, _1)); |
518 | 1276 | GetParam ()->SetUpParam (setting); | 1472 | setHarness->SetUpParam (setting); |
519 | 1277 | } | 1473 | } |
520 | 1278 | 1474 | ||
521 | 1279 | virtual void TearDown () | 1475 | virtual void TearDown () |
522 | 1280 | { | 1476 | { |
524 | 1281 | GetParam ()->TearDownSetting (); | 1477 | setHarness->TearDownSetting (); |
525 | 1282 | } | 1478 | } |
526 | 1283 | 1479 | ||
527 | 1284 | CCSSettingType GetSettingType () | 1480 | CCSSettingType GetSettingType () |
528 | 1285 | { | 1481 | { |
530 | 1286 | return GetParam ()->GetSettingType (); | 1482 | return setHarness->GetSettingType (); |
531 | 1287 | } | 1483 | } |
532 | 1484 | |||
533 | 1485 | protected: | ||
534 | 1486 | |||
535 | 1487 | SetParam::Ptr setHarness; | ||
536 | 1488 | SetMethod setMethod; | ||
537 | 1288 | }; | 1489 | }; |
538 | 1289 | 1490 | ||
539 | 1290 | class SettingDefaulImplSetFailure : | 1491 | class SettingDefaulImplSetFailure : |
540 | @@ -1302,41 +1503,41 @@ | |||
541 | 1302 | 1503 | ||
542 | 1303 | TEST_P (SettingDefaultImplSet, WithInvalidType) | 1504 | TEST_P (SettingDefaultImplSet, WithInvalidType) |
543 | 1304 | { | 1505 | { |
545 | 1305 | EXPECT_EQ (SetFailed, GetParam ()->setWithInvalidType ()); | 1506 | EXPECT_EQ (SetFailed, setHarness->setWithInvalidType (setMethod)); |
546 | 1306 | } | 1507 | } |
547 | 1307 | 1508 | ||
548 | 1308 | TEST_P (SettingDefaultImplSet, ToNewValue) | 1509 | TEST_P (SettingDefaultImplSet, ToNewValue) |
549 | 1309 | { | 1510 | { |
551 | 1310 | EXPECT_EQ (SetToNewValue, GetParam ()->setToNonDefaultValue ()); | 1511 | EXPECT_EQ (SetToNewValue, setHarness->setToNonDefaultValue (setMethod)); |
552 | 1311 | } | 1512 | } |
553 | 1312 | 1513 | ||
554 | 1313 | TEST_P (SettingDefaultImplSet, ToSameValue) | 1514 | TEST_P (SettingDefaultImplSet, ToSameValue) |
555 | 1314 | { | 1515 | { |
558 | 1315 | EXPECT_EQ (SetToNewValue, GetParam ()->setToNonDefaultValue ()); | 1516 | EXPECT_EQ (SetToNewValue, setHarness->setToNonDefaultValue (setMethod)); |
559 | 1316 | EXPECT_EQ (SetToSameValue, GetParam ()->setToNonDefaultValue ()); | 1517 | EXPECT_EQ (SetToSameValue, setHarness->setToNonDefaultValue (setMethod)); |
560 | 1317 | } | 1518 | } |
561 | 1318 | 1519 | ||
562 | 1319 | TEST_P (SettingDefaultImplSet, ToDefaultValue) | 1520 | TEST_P (SettingDefaultImplSet, ToDefaultValue) |
563 | 1320 | { | 1521 | { |
566 | 1321 | EXPECT_EQ (SetToNewValue, GetParam ()->setToNonDefaultValue ()); | 1522 | EXPECT_EQ (SetToNewValue, setHarness->setToNonDefaultValue (setMethod)); |
567 | 1322 | EXPECT_EQ (SetToDefault, GetParam ()->setToDefaultValue ()); | 1523 | EXPECT_EQ (SetToDefault, setHarness->setToDefaultValue (setMethod)); |
568 | 1323 | } | 1524 | } |
569 | 1324 | 1525 | ||
570 | 1325 | TEST_P (SettingDefaultImplSet, IsDefaultValue) | 1526 | TEST_P (SettingDefaultImplSet, IsDefaultValue) |
571 | 1326 | { | 1527 | { |
575 | 1327 | EXPECT_EQ (SetToNewValue, GetParam ()->setToNonDefaultValue ()); | 1528 | EXPECT_EQ (SetToNewValue, setHarness->setToNonDefaultValue (setMethod)); |
576 | 1328 | EXPECT_EQ (SetToDefault, GetParam ()->setToDefaultValue ()); | 1529 | EXPECT_EQ (SetToDefault, setHarness->setToDefaultValue (setMethod)); |
577 | 1329 | EXPECT_EQ (SetIsDefault, GetParam ()->setToDefaultValue ()); | 1530 | EXPECT_EQ (SetIsDefault, setHarness->setToDefaultValue (setMethod)); |
578 | 1330 | } | 1531 | } |
579 | 1331 | 1532 | ||
580 | 1332 | TEST_P (SettingDefaulImplSetFailure, ToFailValue) | 1533 | TEST_P (SettingDefaulImplSetFailure, ToFailValue) |
581 | 1333 | { | 1534 | { |
583 | 1334 | EXPECT_EQ (SetFailed, GetParam ()->setToFailValue ()); | 1535 | EXPECT_EQ (SetFailed, setHarness->setToFailValue (setMethod)); |
584 | 1335 | } | 1536 | } |
585 | 1336 | 1537 | ||
586 | 1337 | #define VALUE_TEST INSTANTIATE_TEST_CASE_P | 1538 | #define VALUE_TEST INSTANTIATE_TEST_CASE_P |
587 | 1338 | 1539 | ||
589 | 1339 | VALUE_TEST (SetSemantics, SettingDefaulImplSetFailure, | 1540 | VALUE_TEST (SetSemantics, SettingDefaulImplSetFailure, Combine ( |
590 | 1340 | Values (FailSParam <int> (ContainNormal (INTEGER_DEFAULT_VALUE), | 1541 | Values (FailSParam <int> (ContainNormal (INTEGER_DEFAULT_VALUE), |
591 | 1341 | TypeInt, | 1542 | TypeInt, |
592 | 1342 | ccsSetInt, | 1543 | ccsSetInt, |
593 | @@ -1364,9 +1565,10 @@ | |||
594 | 1364 | ccsGetMatch, | 1565 | ccsGetMatch, |
595 | 1365 | AutoDestroyInfo (getGenericInfo (TypeMatch), | 1566 | AutoDestroyInfo (getGenericInfo (TypeMatch), |
596 | 1366 | TypeMatch), | 1567 | TypeMatch), |
598 | 1367 | ContainNormal (MATCH_VALUE)))); | 1568 | ContainNormal (MATCH_VALUE))), |
599 | 1569 | Values (ThroughRaw, ThroughValue))); | ||
600 | 1368 | 1570 | ||
602 | 1369 | VALUE_TEST (SetSemantics, SettingDefaultImplSet, | 1571 | VALUE_TEST (SetSemantics, SettingDefaultImplSet, Combine ( |
603 | 1370 | Values (SParam <int> (ContainNormal (INTEGER_DEFAULT_VALUE), | 1572 | Values (SParam <int> (ContainNormal (INTEGER_DEFAULT_VALUE), |
604 | 1371 | TypeInt, | 1573 | TypeInt, |
605 | 1372 | ccsSetInt, | 1574 | ccsSetInt, |
606 | @@ -1506,4 +1708,5 @@ | |||
607 | 1506 | ccsGetList, | 1708 | ccsGetList, |
608 | 1507 | getListInfo (TypeBell, | 1709 | getListInfo (TypeBell, |
609 | 1508 | getActionInfo (TypeBell)), | 1710 | getActionInfo (TypeBell)), |
611 | 1509 | ContainList (BELL_VALUE)))); | 1711 | ContainList (BELL_VALUE))), |
612 | 1712 | Values (ThroughRaw, ThroughValue))); |
Your commit message needs fixing here ^^