author | Eckhart Koeppen <eckhart.koppen@nokia.com> |
Thu, 22 Apr 2010 16:15:11 +0300 | |
branch | RCL_3 |
changeset 14 | 8c4229025c0b |
parent 4 | 3b1da2848fc7 |
permissions | -rw-r--r-- |
0 | 1 |
/**************************************************************************** |
2 |
** |
|
4
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3 |
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). |
0 | 4 |
** All rights reserved. |
5 |
** Contact: Nokia Corporation (qt-info@nokia.com) |
|
6 |
** |
|
7 |
** This file is part of the test suite of the Qt Toolkit. |
|
8 |
** |
|
9 |
** $QT_BEGIN_LICENSE:LGPL$ |
|
10 |
** No Commercial Usage |
|
11 |
** This file contains pre-release code and may not be distributed. |
|
12 |
** You may use this file in accordance with the terms and conditions |
|
13 |
** contained in the Technology Preview License Agreement accompanying |
|
14 |
** this package. |
|
15 |
** |
|
16 |
** GNU Lesser General Public License Usage |
|
17 |
** Alternatively, this file may be used under the terms of the GNU Lesser |
|
18 |
** General Public License version 2.1 as published by the Free Software |
|
19 |
** Foundation and appearing in the file LICENSE.LGPL included in the |
|
20 |
** packaging of this file. Please review the following information to |
|
21 |
** ensure the GNU Lesser General Public License version 2.1 requirements |
|
22 |
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
|
23 |
** |
|
24 |
** In addition, as a special exception, Nokia gives you certain additional |
|
25 |
** rights. These rights are described in the Nokia Qt LGPL Exception |
|
26 |
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
|
27 |
** |
|
28 |
** If you have questions regarding the use of this file, please contact |
|
29 |
** Nokia at qt-info@nokia.com. |
|
30 |
** |
|
31 |
** |
|
32 |
** |
|
33 |
** |
|
34 |
** |
|
35 |
** |
|
36 |
** |
|
37 |
** |
|
38 |
** $QT_END_LICENSE$ |
|
39 |
** |
|
40 |
****************************************************************************/ |
|
41 |
#include <QtTest/QtTest> |
|
42 |
#include <QUndoGroup> |
|
43 |
#include <QUndoStack> |
|
44 |
#include <QAction> |
|
45 |
||
46 |
// Temporarily disabling IRIX due to build issuues with GCC |
|
47 |
#if !defined(__sgi) || defined(__sgi) && !defined(__GNUC__) |
|
48 |
||
49 |
/****************************************************************************** |
|
50 |
** Commands |
|
51 |
*/ |
|
52 |
||
53 |
class InsertCommand : public QUndoCommand |
|
54 |
{ |
|
55 |
public: |
|
56 |
InsertCommand(QString *str, int idx, const QString &text, |
|
57 |
QUndoCommand *parent = 0); |
|
58 |
||
59 |
virtual void undo(); |
|
60 |
virtual void redo(); |
|
61 |
||
62 |
private: |
|
63 |
QString *m_str; |
|
64 |
int m_idx; |
|
65 |
QString m_text; |
|
66 |
}; |
|
67 |
||
68 |
class RemoveCommand : public QUndoCommand |
|
69 |
{ |
|
70 |
public: |
|
71 |
RemoveCommand(QString *str, int idx, int len, QUndoCommand *parent = 0); |
|
72 |
||
73 |
virtual void undo(); |
|
74 |
virtual void redo(); |
|
75 |
||
76 |
private: |
|
77 |
QString *m_str; |
|
78 |
int m_idx; |
|
79 |
QString m_text; |
|
80 |
}; |
|
81 |
||
82 |
class AppendCommand : public QUndoCommand |
|
83 |
{ |
|
84 |
public: |
|
85 |
AppendCommand(QString *str, const QString &text, QUndoCommand *parent = 0); |
|
86 |
||
87 |
virtual void undo(); |
|
88 |
virtual void redo(); |
|
89 |
virtual int id() const; |
|
90 |
virtual bool mergeWith(const QUndoCommand *other); |
|
91 |
||
92 |
bool merged; |
|
93 |
||
94 |
private: |
|
95 |
QString *m_str; |
|
96 |
QString m_text; |
|
97 |
}; |
|
98 |
||
99 |
InsertCommand::InsertCommand(QString *str, int idx, const QString &text, |
|
100 |
QUndoCommand *parent) |
|
101 |
: QUndoCommand(parent) |
|
102 |
{ |
|
103 |
QVERIFY(str->length() >= idx); |
|
104 |
||
105 |
setText("insert"); |
|
106 |
||
107 |
m_str = str; |
|
108 |
m_idx = idx; |
|
109 |
m_text = text; |
|
110 |
} |
|
111 |
||
112 |
void InsertCommand::redo() |
|
113 |
{ |
|
114 |
QVERIFY(m_str->length() >= m_idx); |
|
115 |
||
116 |
m_str->insert(m_idx, m_text); |
|
117 |
} |
|
118 |
||
119 |
void InsertCommand::undo() |
|
120 |
{ |
|
121 |
QCOMPARE(m_str->mid(m_idx, m_text.length()), m_text); |
|
122 |
||
123 |
m_str->remove(m_idx, m_text.length()); |
|
124 |
} |
|
125 |
||
126 |
RemoveCommand::RemoveCommand(QString *str, int idx, int len, QUndoCommand *parent) |
|
127 |
: QUndoCommand(parent) |
|
128 |
{ |
|
129 |
QVERIFY(str->length() >= idx + len); |
|
130 |
||
131 |
setText("remove"); |
|
132 |
||
133 |
m_str = str; |
|
134 |
m_idx = idx; |
|
135 |
m_text = m_str->mid(m_idx, len); |
|
136 |
} |
|
137 |
||
138 |
void RemoveCommand::redo() |
|
139 |
{ |
|
140 |
QCOMPARE(m_str->mid(m_idx, m_text.length()), m_text); |
|
141 |
||
142 |
m_str->remove(m_idx, m_text.length()); |
|
143 |
} |
|
144 |
||
145 |
void RemoveCommand::undo() |
|
146 |
{ |
|
147 |
QVERIFY(m_str->length() >= m_idx); |
|
148 |
||
149 |
m_str->insert(m_idx, m_text); |
|
150 |
} |
|
151 |
||
152 |
AppendCommand::AppendCommand(QString *str, const QString &text, QUndoCommand *parent) |
|
153 |
: QUndoCommand(parent) |
|
154 |
{ |
|
155 |
setText("append"); |
|
156 |
||
157 |
m_str = str; |
|
158 |
m_text = text; |
|
159 |
merged = false; |
|
160 |
} |
|
161 |
||
162 |
void AppendCommand::redo() |
|
163 |
{ |
|
164 |
m_str->append(m_text); |
|
165 |
} |
|
166 |
||
167 |
void AppendCommand::undo() |
|
168 |
{ |
|
169 |
QCOMPARE(m_str->mid(m_str->length() - m_text.length()), m_text); |
|
170 |
||
171 |
m_str->truncate(m_str->length() - m_text.length()); |
|
172 |
} |
|
173 |
||
174 |
int AppendCommand::id() const |
|
175 |
{ |
|
176 |
return 1; |
|
177 |
} |
|
178 |
||
179 |
bool AppendCommand::mergeWith(const QUndoCommand *other) |
|
180 |
{ |
|
181 |
if (other->id() != id()) |
|
182 |
return false; |
|
183 |
m_text += static_cast<const AppendCommand*>(other)->m_text; |
|
184 |
merged = true; |
|
185 |
return true; |
|
186 |
} |
|
187 |
||
188 |
/****************************************************************************** |
|
189 |
** tst_QUndoStack |
|
190 |
*/ |
|
191 |
||
192 |
class tst_QUndoGroup : public QObject |
|
193 |
{ |
|
194 |
Q_OBJECT |
|
195 |
public: |
|
196 |
tst_QUndoGroup(); |
|
197 |
||
198 |
private slots: |
|
199 |
void setActive(); |
|
200 |
void addRemoveStack(); |
|
201 |
void deleteStack(); |
|
202 |
void checkSignals(); |
|
203 |
void addStackAndDie(); |
|
204 |
}; |
|
205 |
||
206 |
tst_QUndoGroup::tst_QUndoGroup() |
|
207 |
{ |
|
208 |
} |
|
209 |
||
210 |
void tst_QUndoGroup::setActive() |
|
211 |
{ |
|
212 |
QUndoGroup group; |
|
213 |
QUndoStack stack1(&group), stack2(&group); |
|
214 |
||
215 |
QCOMPARE(group.activeStack(), (QUndoStack*)0); |
|
216 |
QCOMPARE(stack1.isActive(), false); |
|
217 |
QCOMPARE(stack2.isActive(), false); |
|
218 |
||
219 |
QUndoStack stack3; |
|
220 |
QCOMPARE(stack3.isActive(), true); |
|
221 |
||
222 |
group.addStack(&stack3); |
|
223 |
QCOMPARE(stack3.isActive(), false); |
|
224 |
||
225 |
stack1.setActive(); |
|
226 |
QCOMPARE(group.activeStack(), &stack1); |
|
227 |
QCOMPARE(stack1.isActive(), true); |
|
228 |
QCOMPARE(stack2.isActive(), false); |
|
229 |
QCOMPARE(stack3.isActive(), false); |
|
230 |
||
231 |
group.setActiveStack(&stack2); |
|
232 |
QCOMPARE(group.activeStack(), &stack2); |
|
233 |
QCOMPARE(stack1.isActive(), false); |
|
234 |
QCOMPARE(stack2.isActive(), true); |
|
235 |
QCOMPARE(stack3.isActive(), false); |
|
236 |
||
237 |
group.removeStack(&stack2); |
|
238 |
QCOMPARE(group.activeStack(), (QUndoStack*)0); |
|
239 |
QCOMPARE(stack1.isActive(), false); |
|
240 |
QCOMPARE(stack2.isActive(), true); |
|
241 |
QCOMPARE(stack3.isActive(), false); |
|
242 |
||
243 |
group.removeStack(&stack2); |
|
244 |
QCOMPARE(group.activeStack(), (QUndoStack*)0); |
|
245 |
QCOMPARE(stack1.isActive(), false); |
|
246 |
QCOMPARE(stack2.isActive(), true); |
|
247 |
QCOMPARE(stack3.isActive(), false); |
|
248 |
} |
|
249 |
||
250 |
void tst_QUndoGroup::addRemoveStack() |
|
251 |
{ |
|
252 |
QUndoGroup group; |
|
253 |
||
254 |
QUndoStack stack1(&group); |
|
255 |
QCOMPARE(group.stacks(), QList<QUndoStack*>() << &stack1); |
|
256 |
||
257 |
QUndoStack stack2; |
|
258 |
group.addStack(&stack2); |
|
259 |
QCOMPARE(group.stacks(), QList<QUndoStack*>() << &stack1 << &stack2); |
|
260 |
||
261 |
group.addStack(&stack1); |
|
262 |
QCOMPARE(group.stacks(), QList<QUndoStack*>() << &stack1 << &stack2); |
|
263 |
||
264 |
group.removeStack(&stack1); |
|
265 |
QCOMPARE(group.stacks(), QList<QUndoStack*>() << &stack2); |
|
266 |
||
267 |
group.removeStack(&stack1); |
|
268 |
QCOMPARE(group.stacks(), QList<QUndoStack*>() << &stack2); |
|
269 |
||
270 |
group.removeStack(&stack2); |
|
271 |
QCOMPARE(group.stacks(), QList<QUndoStack*>()); |
|
272 |
} |
|
273 |
||
274 |
void tst_QUndoGroup::deleteStack() |
|
275 |
{ |
|
276 |
QUndoGroup group; |
|
277 |
||
278 |
QUndoStack *stack1 = new QUndoStack(&group); |
|
279 |
QCOMPARE(group.stacks(), QList<QUndoStack*>() << stack1); |
|
280 |
QCOMPARE(group.activeStack(), (QUndoStack*)0); |
|
281 |
||
282 |
stack1->setActive(); |
|
283 |
QCOMPARE(group.activeStack(), stack1); |
|
284 |
||
285 |
QUndoStack *stack2 = new QUndoStack(&group); |
|
286 |
QCOMPARE(group.stacks(), QList<QUndoStack*>() << stack1 << stack2); |
|
287 |
QCOMPARE(group.activeStack(), stack1); |
|
288 |
||
289 |
QUndoStack *stack3 = new QUndoStack(&group); |
|
290 |
QCOMPARE(group.stacks(), QList<QUndoStack*>() << stack1 << stack2 << stack3); |
|
291 |
QCOMPARE(group.activeStack(), stack1); |
|
292 |
||
293 |
delete stack2; |
|
294 |
QCOMPARE(group.stacks(), QList<QUndoStack*>() << stack1 << stack3); |
|
295 |
QCOMPARE(group.activeStack(), stack1); |
|
296 |
||
297 |
delete stack1; |
|
298 |
QCOMPARE(group.stacks(), QList<QUndoStack*>() << stack3); |
|
299 |
QCOMPARE(group.activeStack(), (QUndoStack*)0); |
|
300 |
||
301 |
stack3->setActive(false); |
|
302 |
QCOMPARE(group.activeStack(), (QUndoStack*)0); |
|
303 |
||
304 |
stack3->setActive(true); |
|
305 |
QCOMPARE(group.activeStack(), stack3); |
|
306 |
||
307 |
group.removeStack(stack3); |
|
308 |
QCOMPARE(group.stacks(), QList<QUndoStack*>()); |
|
309 |
QCOMPARE(group.activeStack(), (QUndoStack*)0); |
|
310 |
||
311 |
delete stack3; |
|
312 |
} |
|
313 |
||
314 |
static QString glue(const QString &s1, const QString &s2) |
|
315 |
{ |
|
316 |
QString result; |
|
317 |
||
318 |
result.append(s1); |
|
319 |
if (!s1.isEmpty() && !s2.isEmpty()) |
|
320 |
result.append(' '); |
|
321 |
result.append(s2); |
|
322 |
||
323 |
return result; |
|
324 |
} |
|
325 |
||
326 |
#define CHECK_STATE(_activeStack, _clean, _canUndo, _undoText, _canRedo, _redoText, \ |
|
327 |
_cleanChanged, _indexChanged, _undoChanged, _redoChanged) \ |
|
328 |
QCOMPARE(group.activeStack(), (QUndoStack*)_activeStack); \ |
|
329 |
QCOMPARE(group.isClean(), _clean); \ |
|
330 |
QCOMPARE(group.canUndo(), _canUndo); \ |
|
331 |
QCOMPARE(group.undoText(), QString(_undoText)); \ |
|
332 |
QCOMPARE(group.canRedo(), _canRedo); \ |
|
333 |
QCOMPARE(group.redoText(), QString(_redoText)); \ |
|
334 |
if (_indexChanged) { \ |
|
335 |
QCOMPARE(indexChangedSpy.count(), 1); \ |
|
336 |
indexChangedSpy.clear(); \ |
|
337 |
} else { \ |
|
338 |
QCOMPARE(indexChangedSpy.count(), 0); \ |
|
339 |
} \ |
|
340 |
if (_cleanChanged) { \ |
|
341 |
QCOMPARE(cleanChangedSpy.count(), 1); \ |
|
342 |
QCOMPARE(cleanChangedSpy.at(0).at(0).toBool(), _clean); \ |
|
343 |
cleanChangedSpy.clear(); \ |
|
344 |
} else { \ |
|
345 |
QCOMPARE(cleanChangedSpy.count(), 0); \ |
|
346 |
} \ |
|
347 |
if (_undoChanged) { \ |
|
348 |
QCOMPARE(canUndoChangedSpy.count(), 1); \ |
|
349 |
QCOMPARE(canUndoChangedSpy.at(0).at(0).toBool(), _canUndo); \ |
|
350 |
QCOMPARE(undo_action->isEnabled(), _canUndo); \ |
|
351 |
QCOMPARE(undoTextChangedSpy.count(), 1); \ |
|
352 |
QCOMPARE(undoTextChangedSpy.at(0).at(0).toString(), QString(_undoText)); \ |
|
353 |
QCOMPARE(undo_action->text(), glue("foo", _undoText)); \ |
|
354 |
canUndoChangedSpy.clear(); \ |
|
355 |
undoTextChangedSpy.clear(); \ |
|
356 |
} else { \ |
|
357 |
QCOMPARE(canUndoChangedSpy.count(), 0); \ |
|
358 |
QCOMPARE(undoTextChangedSpy.count(), 0); \ |
|
359 |
} \ |
|
360 |
if (_redoChanged) { \ |
|
361 |
QCOMPARE(canRedoChangedSpy.count(), 1); \ |
|
362 |
QCOMPARE(canRedoChangedSpy.at(0).at(0).toBool(), _canRedo); \ |
|
363 |
QCOMPARE(redo_action->isEnabled(), _canRedo); \ |
|
364 |
QCOMPARE(redoTextChangedSpy.count(), 1); \ |
|
365 |
QCOMPARE(redoTextChangedSpy.at(0).at(0).toString(), QString(_redoText)); \ |
|
366 |
QCOMPARE(redo_action->text(), glue("bar", _redoText)); \ |
|
367 |
canRedoChangedSpy.clear(); \ |
|
368 |
redoTextChangedSpy.clear(); \ |
|
369 |
} else { \ |
|
370 |
QCOMPARE(canRedoChangedSpy.count(), 0); \ |
|
371 |
QCOMPARE(redoTextChangedSpy.count(), 0); \ |
|
372 |
} |
|
373 |
||
374 |
void tst_QUndoGroup::checkSignals() |
|
375 |
{ |
|
376 |
QUndoGroup group; |
|
377 |
QAction *undo_action = group.createUndoAction(0, QString("foo")); |
|
378 |
QAction *redo_action = group.createRedoAction(0, QString("bar")); |
|
379 |
QSignalSpy indexChangedSpy(&group, SIGNAL(indexChanged(int))); |
|
380 |
QSignalSpy cleanChangedSpy(&group, SIGNAL(cleanChanged(bool))); |
|
381 |
QSignalSpy canUndoChangedSpy(&group, SIGNAL(canUndoChanged(bool))); |
|
382 |
QSignalSpy undoTextChangedSpy(&group, SIGNAL(undoTextChanged(QString))); |
|
383 |
QSignalSpy canRedoChangedSpy(&group, SIGNAL(canRedoChanged(bool))); |
|
384 |
QSignalSpy redoTextChangedSpy(&group, SIGNAL(redoTextChanged(QString))); |
|
385 |
||
386 |
QString str; |
|
387 |
||
388 |
CHECK_STATE(0, // activeStack |
|
389 |
true, // clean |
|
390 |
false, // canUndo |
|
391 |
"", // undoText |
|
392 |
false, // canRedo |
|
393 |
"", // redoText |
|
394 |
false, // cleanChanged |
|
395 |
false, // indexChanged |
|
396 |
false, // undoChanged |
|
397 |
false) // redoChanged |
|
398 |
||
399 |
group.undo(); |
|
400 |
CHECK_STATE(0, // activeStack |
|
401 |
true, // clean |
|
402 |
false, // canUndo |
|
403 |
"", // undoText |
|
404 |
false, // canRedo |
|
405 |
"", // redoText |
|
406 |
false, // cleanChanged |
|
407 |
false, // indexChanged |
|
408 |
false, // undoChanged |
|
409 |
false) // redoChanged |
|
410 |
||
411 |
group.redo(); |
|
412 |
CHECK_STATE(0, // activeStack |
|
413 |
true, // clean |
|
414 |
false, // canUndo |
|
415 |
"", // undoText |
|
416 |
false, // canRedo |
|
417 |
"", // redoText |
|
418 |
false, // cleanChanged |
|
419 |
false, // indexChanged |
|
420 |
false, // undoChanged |
|
421 |
false) // redoChanged |
|
422 |
||
423 |
QUndoStack *stack1 = new QUndoStack(&group); |
|
424 |
CHECK_STATE(0, // activeStack |
|
425 |
true, // clean |
|
426 |
false, // canUndo |
|
427 |
"", // undoText |
|
428 |
false, // canRedo |
|
429 |
"", // redoText |
|
430 |
false, // cleanChanged |
|
431 |
false, // indexChanged |
|
432 |
false, // undoChanged |
|
433 |
false) // redoChanged |
|
434 |
||
435 |
stack1->push(new AppendCommand(&str, "foo")); |
|
436 |
CHECK_STATE(0, // activeStack |
|
437 |
true, // clean |
|
438 |
false, // canUndo |
|
439 |
"", // undoText |
|
440 |
false, // canRedo |
|
441 |
"", // redoText |
|
442 |
false, // cleanChanged |
|
443 |
false, // indexChanged |
|
444 |
false, // undoChanged |
|
445 |
false) // redoChanged |
|
446 |
||
447 |
stack1->setActive(); |
|
448 |
CHECK_STATE(stack1, // activeStack |
|
449 |
false, // clean |
|
450 |
true, // canUndo |
|
451 |
"append", // undoText |
|
452 |
false, // canRedo |
|
453 |
"", // redoText |
|
454 |
true, // cleanChanged |
|
455 |
true, // indexChanged |
|
456 |
true, // undoChanged |
|
457 |
true) // redoChanged |
|
458 |
||
459 |
stack1->push(new InsertCommand(&str, 0, "bar")); |
|
460 |
CHECK_STATE(stack1, // activeStack |
|
461 |
false, // clean |
|
462 |
true, // canUndo |
|
463 |
"insert", // undoText |
|
464 |
false, // canRedo |
|
465 |
"", // redoText |
|
466 |
false, // cleanChanged |
|
467 |
true, // indexChanged |
|
468 |
true, // undoChanged |
|
469 |
true) // redoChanged |
|
470 |
||
471 |
stack1->undo(); |
|
472 |
CHECK_STATE(stack1, // activeStack |
|
473 |
false, // clean |
|
474 |
true, // canUndo |
|
475 |
"append", // undoText |
|
476 |
true, // canRedo |
|
477 |
"insert", // redoText |
|
478 |
false, // cleanChanged |
|
479 |
true, // indexChanged |
|
480 |
true, // undoChanged |
|
481 |
true) // redoChanged |
|
482 |
||
483 |
stack1->undo(); |
|
484 |
CHECK_STATE(stack1, // activeStack |
|
485 |
true, // clean |
|
486 |
false, // canUndo |
|
487 |
"", // undoText |
|
488 |
true, // canRedo |
|
489 |
"append", // redoText |
|
490 |
true, // cleanChanged |
|
491 |
true, // indexChanged |
|
492 |
true, // undoChanged |
|
493 |
true) // redoChanged |
|
494 |
||
495 |
stack1->undo(); |
|
496 |
CHECK_STATE(stack1, // activeStack |
|
497 |
true, // clean |
|
498 |
false, // canUndo |
|
499 |
"", // undoText |
|
500 |
true, // canRedo |
|
501 |
"append", // redoText |
|
502 |
false, // cleanChanged |
|
503 |
false, // indexChanged |
|
504 |
false, // undoChanged |
|
505 |
false) // redoChanged |
|
506 |
||
507 |
group.undo(); |
|
508 |
CHECK_STATE(stack1, // activeStack |
|
509 |
true, // clean |
|
510 |
false, // canUndo |
|
511 |
"", // undoText |
|
512 |
true, // canRedo |
|
513 |
"append", // redoText |
|
514 |
false, // cleanChanged |
|
515 |
false, // indexChanged |
|
516 |
false, // undoChanged |
|
517 |
false) // redoChanged |
|
518 |
||
519 |
group.redo(); |
|
520 |
CHECK_STATE(stack1, // activeStack |
|
521 |
false, // clean |
|
522 |
true, // canUndo |
|
523 |
"append", // undoText |
|
524 |
true, // canRedo |
|
525 |
"insert", // redoText |
|
526 |
true, // cleanChanged |
|
527 |
true, // indexChanged |
|
528 |
true, // undoChanged |
|
529 |
true) // redoChanged |
|
530 |
||
531 |
stack1->setActive(false); |
|
532 |
CHECK_STATE(0, // activeStack |
|
533 |
true, // clean |
|
534 |
false, // canUndo |
|
535 |
"", // undoText |
|
536 |
false, // canRedo |
|
537 |
"", // redoText |
|
538 |
true, // cleanChanged |
|
539 |
true, // indexChanged |
|
540 |
true, // undoChanged |
|
541 |
true) // redoChanged |
|
542 |
||
543 |
QUndoStack *stack2 = new QUndoStack(&group); |
|
544 |
CHECK_STATE(0, // activeStack |
|
545 |
true, // clean |
|
546 |
false, // canUndo |
|
547 |
"", // undoText |
|
548 |
false, // canRedo |
|
549 |
"", // redoText |
|
550 |
false, // cleanChanged |
|
551 |
false, // indexChanged |
|
552 |
false, // undoChanged |
|
553 |
false) // redoChanged |
|
554 |
||
555 |
stack2->setActive(); |
|
556 |
CHECK_STATE(stack2, // activeStack |
|
557 |
true, // clean |
|
558 |
false, // canUndo |
|
559 |
"", // undoText |
|
560 |
false, // canRedo |
|
561 |
"", // redoText |
|
562 |
true, // cleanChanged |
|
563 |
true, // indexChanged |
|
564 |
true, // undoChanged |
|
565 |
true) // redoChanged |
|
566 |
||
567 |
stack1->setActive(); |
|
568 |
CHECK_STATE(stack1, // activeStack |
|
569 |
false, // clean |
|
570 |
true, // canUndo |
|
571 |
"append", // undoText |
|
572 |
true, // canRedo |
|
573 |
"insert", // redoText |
|
574 |
true, // cleanChanged |
|
575 |
true, // indexChanged |
|
576 |
true, // undoChanged |
|
577 |
true) // redoChanged |
|
578 |
||
579 |
delete stack1; |
|
580 |
CHECK_STATE(0, // activeStack |
|
581 |
true, // clean |
|
582 |
false, // canUndo |
|
583 |
"", // undoText |
|
584 |
false, // canRedo |
|
585 |
"", // redoText |
|
586 |
true, // cleanChanged |
|
587 |
true, // indexChanged |
|
588 |
true, // undoChanged |
|
589 |
true) // redoChanged |
|
590 |
||
591 |
delete undo_action; |
|
592 |
delete redo_action; |
|
593 |
} |
|
594 |
||
595 |
void tst_QUndoGroup::addStackAndDie() |
|
596 |
{ |
|
597 |
// Test that QUndoStack doesn't keep a reference to QUndoGroup after the |
|
598 |
// group is deleted. |
|
599 |
QUndoStack *stack = new QUndoStack; |
|
600 |
QUndoGroup *group = new QUndoGroup; |
|
601 |
group->addStack(stack); |
|
602 |
delete group; |
|
603 |
stack->setActive(true); |
|
604 |
delete stack; |
|
605 |
} |
|
606 |
||
607 |
#else |
|
608 |
class tst_QUndoGroup : public QObject |
|
609 |
{ |
|
610 |
Q_OBJECT |
|
611 |
public: |
|
612 |
tst_QUndoGroup() {} |
|
613 |
||
614 |
private slots: |
|
615 |
void setActive() { QSKIP( "Not tested on irix-g++", SkipAll); } |
|
616 |
void addRemoveStack() { QSKIP( "Not tested on irix-g++", SkipAll); } |
|
617 |
void deleteStack() { QSKIP( "Not tested on irix-g++", SkipAll); } |
|
618 |
void checkSignals() { QSKIP( "Not tested on irix-g++", SkipAll); } |
|
619 |
void addStackAndDie() { QSKIP( "Not tested on irix-g++", SkipAll); } |
|
620 |
}; |
|
621 |
#endif |
|
622 |
||
623 |
QTEST_MAIN(tst_QUndoGroup) |
|
624 |
||
625 |
#include "tst_qundogroup.moc" |
|
626 |