24
24
#include " attributefilterdialog.h"
25
25
#include < QTreeWidgetItem>
26
26
#include < QTest>
27
+ #include < QScopedPointer>
27
28
#include " ui_attributeprofilemgmtdialog.h"
28
29
#include " ui_attributefilterdetaildialog.h"
29
30
@@ -95,52 +96,47 @@ bool TestFilterAttributes::testBaseMethodsDetail()
95
96
{
96
97
QString testName = " testBaseMethodsDetail" ;
97
98
98
- AttrFilterDetail * detail1 = createDetail (" name a" , " name" );
99
- AttrFilterDetail * detail2 = createDetail (" name b" , " name" );
100
- AttrFilterDetail * detail3 = createDetail (" name b" , " " );
101
- AttrFilterDetail * detail4 = createDetail (" name a" , " name" );
99
+ const QScopedPointer< AttrFilterDetail> detail1 ( createDetail (" name a" , " name" ) );
100
+ const QScopedPointer< AttrFilterDetail> detail2 ( createDetail (" name b" , " name" ) );
101
+ const QScopedPointer< AttrFilterDetail> detail3 ( createDetail (" name b" , " " ) );
102
+ const QScopedPointer< AttrFilterDetail> detail4 ( createDetail (" name a" , " name" ) );
102
103
103
104
if ( detail1->compareTo (NULL )) {
104
105
return error (testName, " detail compare to null" );
105
106
}
106
- if ( !detail1->compareTo (detail1)) {
107
+ if ( !detail1->compareTo (detail1. data () )) {
107
108
return error (testName, " detail compare same object" );
108
109
}
109
- if ( detail1->compareTo (detail2)) {
110
+ if ( detail1->compareTo (detail2. data () )) {
110
111
return error (testName, " detail compare to same size false" );
111
112
}
112
113
if ( detail3->names ().size () != 1 ) {
113
114
return error (testName, " detail bad size data." );
114
115
}
115
- if ( detail1->compareTo (detail3)) {
116
+ if ( detail1->compareTo (detail3. data () )) {
116
117
return error (testName, " detail compare to different size" );
117
118
}
118
- if ( !detail1->compareTo (detail4)) {
119
+ if ( !detail1->compareTo (detail4. data () )) {
119
120
return error (testName, " detail compare equals" );
120
121
}
121
122
122
- deleteDetail (detail1);
123
- deleteDetail (detail2);
124
- deleteDetail (detail3);
125
- deleteDetail (detail4);
126
-
127
123
return true ;
128
124
}
129
125
130
126
bool TestFilterAttributes::testBaseMethodsProfile ()
131
127
{
132
128
QString testName = " testBaseMethodsProfile" ;
133
129
134
- AttrFilterProfile * profile1 = createProfile ( 1 , " name" );
135
- AttrFilterProfile * profile2 = createProfile ( 1 , " name" );
136
- AttrFilterProfile * profile3 = createProfile ( 2 , " name" );
137
- AttrFilterProfile * profile4 = createProfile ( 1 , " name" );
138
- AttrFilterProfile * profile5 = createProfile ( 1 , " name" );
139
- AttrFilterProfile * profile6 = createProfile ( 1 , " name" );
140
- AttrFilterProfile * profile7 = createProfile ( 1 , " name" );
141
- AttrFilterProfile * profile8 = createProfile ( 1 , " name" );
130
+ const QScopedPointer< AttrFilterProfile> profile1 ( createProfile ( 1 , " name" ) );
131
+ const QScopedPointer< AttrFilterProfile> profile2 ( createProfile ( 1 , " name" ) );
132
+ const QScopedPointer< AttrFilterProfile> profile3 ( createProfile ( 2 , " name" ) );
133
+ const QScopedPointer< AttrFilterProfile> profile4 ( createProfile ( 1 , " name" ) );
134
+ const QScopedPointer< AttrFilterProfile> profile5 ( createProfile ( 1 , " name" ) );
135
+ const QScopedPointer< AttrFilterProfile> profile6 ( createProfile ( 1 , " name" ) );
136
+ const QScopedPointer< AttrFilterProfile> profile7 ( createProfile ( 1 , " name" ) );
137
+ const QScopedPointer< AttrFilterProfile> profile8 ( createProfile ( 1 , " name" ) );
142
138
143
- if ( !profile1->compareTo (profile1)) {
139
+ if ( !profile1->compareTo (profile1. data () )) {
144
140
return error (testName, " profile compare to itself" );
145
141
}
146
142
@@ -151,80 +147,71 @@ bool TestFilterAttributes::testBaseMethodsProfile()
151
147
return error (testName, " profile compare b to null" );
152
148
}
153
149
// --
154
- if ( !profile1->compareTo (profile2)) {
150
+ if ( !profile1->compareTo (profile2. data () )) {
155
151
return error (testName, " profile compare to equals" );
156
152
}
157
- if ( !profile1->compareToBase (profile2)) {
153
+ if ( !profile1->compareToBase (profile2. data () )) {
158
154
return error (testName, " profile compare b to equals" );
159
155
}
160
156
// --
161
157
profile3->setId (100 );
162
- if ( profile1->compareTo (profile3)) {
158
+ if ( profile1->compareTo (profile3. data () )) {
163
159
return error (testName, " profile compare id" );
164
160
}
165
- if ( profile1->compareToBase (profile3)) {
161
+ if ( profile1->compareToBase (profile3. data () )) {
166
162
return error (testName, " profile compare b id" );
167
163
}
168
164
// --
169
165
profile4->setName (" x" );
170
- if ( profile1->compareTo (profile4)) {
166
+ if ( profile1->compareTo (profile4. data () )) {
171
167
return error (testName, " profile compare name" );
172
168
}
173
- if ( profile1->compareToBase (profile4)) {
169
+ if ( profile1->compareToBase (profile4. data () )) {
174
170
return error (testName, " profile compare b name" );
175
171
}
176
172
// --
177
173
profile5->setDescription (" x" );
178
- if ( profile1->compareTo (profile5)) {
174
+ if ( profile1->compareTo (profile5. data () )) {
179
175
return error (testName, " profile compare description" );
180
176
}
181
- if ( profile1->compareToBase (profile5)) {
177
+ if ( profile1->compareToBase (profile5. data () )) {
182
178
return error (testName, " profile compare b description" );
183
179
}
184
180
// --
185
181
profile1->setWhiteList (true );
186
182
profile6->setWhiteList (false );
187
- if ( profile1->compareTo (profile6)) {
183
+ if ( profile1->compareTo (profile6. data () )) {
188
184
return error (testName, " profile compare whitelist" );
189
185
}
190
- if ( profile1->compareToBase (profile6)) {
186
+ if ( profile1->compareToBase (profile6. data () )) {
191
187
return error (testName, " profile compare whitelist" );
192
188
}
193
189
// --
194
190
QDateTime dtUpdate;
195
191
dtUpdate.setMSecsSinceEpoch (profile1->updateTime ().toMSecsSinceEpoch ()+1000 );
196
192
profile7->setUpdateTime (dtUpdate);
197
- if ( profile1->compareTo (profile7)) {
193
+ if ( profile1->compareTo (profile7. data () )) {
198
194
return error (testName, " profile compare update time" );
199
195
}
200
196
// --
201
197
QDateTime dtCreation;
202
198
dtCreation.setMSecsSinceEpoch (profile1->creationTime ().toMSecsSinceEpoch ()+1000 );
203
199
profile8->setCreationTime (dtCreation);
204
- if ( profile1->compareTo (profile8)) {
200
+ if ( profile1->compareTo (profile8. data () )) {
205
201
return error (testName, " profile compare creation time" );
206
202
}
207
203
// ---
208
204
dtUpdate.setMSecsSinceEpoch (profile1->updateTime ().toMSecsSinceEpoch ()+10000 );
209
205
dtCreation.setMSecsSinceEpoch (profile1->creationTime ().toMSecsSinceEpoch ()+10000 );
210
206
profile8->setUpdateTime (dtUpdate);
211
207
profile8->setCreationTime (dtCreation);
212
- if ( profile1->compareTo (profile8)) {
208
+ if ( profile1->compareTo (profile8. data () )) {
213
209
return error (testName, " profile compare times " );
214
210
}
215
- if ( !profile1->compareToBase (profile8)) {
211
+ if ( !profile1->compareToBase (profile8. data () )) {
216
212
return error (testName, " profile compare base time differ" );
217
213
}
218
214
219
- deleteProfile (profile1);
220
- deleteProfile (profile2);
221
- deleteProfile (profile3);
222
- deleteProfile (profile4);
223
- deleteProfile (profile5);
224
- deleteProfile (profile6);
225
- deleteProfile (profile7);
226
- deleteProfile (profile8);
227
-
228
215
return true ;
229
216
}
230
217
0 commit comments