Remove "All rights reserved" line from license headers.
[profile/ivi/qtdeclarative.git] / tests / auto / declarative / qdeclarativechangeset / tst_qdeclarativechangeset.cpp
1 /****************************************************************************
2 **
3 ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/
5 **
6 ** This file is part of the test suite of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** GNU Lesser General Public License Usage
10 ** This file may be used under the terms of the GNU Lesser General Public
11 ** License version 2.1 as published by the Free Software Foundation and
12 ** appearing in the file LICENSE.LGPL included in the packaging of this
13 ** file. Please review the following information to ensure the GNU Lesser
14 ** General Public License version 2.1 requirements will be met:
15 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
16 **
17 ** In addition, as a special exception, Nokia gives you certain additional
18 ** rights. These rights are described in the Nokia Qt LGPL Exception
19 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
20 **
21 ** GNU General Public License Usage
22 ** Alternatively, this file may be used under the terms of the GNU General
23 ** Public License version 3.0 as published by the Free Software Foundation
24 ** and appearing in the file LICENSE.GPL included in the packaging of this
25 ** file. Please review the following information to ensure the GNU General
26 ** Public License version 3.0 requirements will be met:
27 ** http://www.gnu.org/copyleft/gpl.html.
28 **
29 ** Other Usage
30 ** Alternatively, this file may be used in accordance with the terms and
31 ** conditions contained in a signed written agreement between you and Nokia.
32 **
33 **
34 **
35 **
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41 #include <qtest.h>
42 #include <private/qdeclarativechangeset_p.h>
43
44 #define VERIFY_EXPECTED_OUTPUT
45
46 class tst_qdeclarativemodelchange : public QObject
47 {
48     Q_OBJECT
49 public:
50     struct Signal
51     {
52         int index;
53         int count;
54         int to;
55         int moveId;
56
57         bool isInsert() const { return to == -1; }
58         bool isRemove() const { return to == -2; }
59         bool isMove() const { return to >= 0; }
60         bool isChange() const { return to == -3; }
61     };
62
63     static Signal Insert(int index, int count, int moveId = -1) { Signal signal = { index, count, -1, moveId }; return signal; }
64     static Signal Remove(int index, int count, int moveId = -1) { Signal signal = { index, count, -2, moveId }; return signal; }
65     static Signal Move(int from, int to, int count) { Signal signal = { from, count, to, -1 }; return signal; }
66     static Signal Change(int index, int count) { Signal signal = { index, count, -3, -1 }; return signal; }
67
68     typedef QVector<Signal> SignalList;
69
70
71 #ifdef VERIFY_EXPECTED_OUTPUT
72
73     template<typename T>
74     void move(int from, int to, int n, T *items)
75     {
76         if (from > to) {
77             // Only move forwards - flip if backwards moving
78             int tfrom = from;
79             int tto = to;
80             from = tto;
81             to = tto+n;
82             n = tfrom-tto;
83         }
84
85         T replaced;
86         int i=0;
87         typename T::ConstIterator it=items->begin(); it += from+n;
88         for (; i<to-from; ++i,++it)
89             replaced.append(*it);
90         i=0;
91         it=items->begin(); it += from;
92         for (; i<n; ++i,++it)
93             replaced.append(*it);
94         typename T::ConstIterator f=replaced.begin();
95         typename T::Iterator t=items->begin(); t += from;
96         for (; f != replaced.end(); ++f, ++t)
97             *t = *f;
98     }
99
100     QVector<int> applyChanges(const QVector<int> &list, const QVector<Signal> &changes)
101     {
102         QHash<int, QVector<int> > removedValues;
103         QVector<int> alteredList = list;
104         foreach (const Signal &signal, changes) {
105             if (signal.isInsert()) {
106                 if (signal.moveId != -1) {
107                     QVector<int> tail = alteredList.mid(signal.index);
108                     alteredList = alteredList.mid(0, signal.index) + removedValues.take(signal.moveId) + tail;
109                 } else {
110                     alteredList.insert(signal.index, signal.count, 100);
111                 }
112             } else if (signal.isRemove()) {
113                 if (signal.moveId != -1)
114                     removedValues.insert(signal.moveId, alteredList.mid(signal.index, signal.count));
115                 alteredList.erase(alteredList.begin() + signal.index, alteredList.begin() + signal.index + signal.count);
116             } else if (signal.isMove()) {
117                 move(signal.index, signal.to, signal.count, &alteredList);
118             } else if (signal.isChange()) {
119                 for (int i = signal.index; i < signal.index + signal.count; ++i) {
120                     if (alteredList[i] < 100)
121                         alteredList[i] = 100;
122                 }
123             }
124         }
125         return alteredList;
126     }
127
128 #endif
129
130 private slots:
131     void sequence_data();
132     void sequence();
133 };
134
135 bool operator ==(const tst_qdeclarativemodelchange::Signal &left, const tst_qdeclarativemodelchange::Signal &right)
136 {
137     return left.index == right.index
138             && left.count == right.count
139             && left.to == right.to
140             && ((left.moveId == -1 && right.moveId == -1) || (left.moveId != -1 && right.moveId != -1));
141 }
142
143
144 QDebug operator <<(QDebug debug, const tst_qdeclarativemodelchange::Signal &signal)
145 {
146     if (signal.isInsert())
147         debug.nospace() << "Insert(" << signal.index << "," << signal.count << "," << signal.moveId << ")";
148     else if (signal.isRemove())
149         debug.nospace() << "Remove(" << signal.index << "," << signal.count << "," << signal.moveId << ")";
150     else if (signal.isMove())
151         debug.nospace() << "Move(" << signal.index << "," << signal.to << "," << signal.count << ")";
152     else if (signal.isChange())
153         debug.nospace() << "Change(" << signal.index << "," << signal.count << ")";
154     return debug;
155 }
156
157 Q_DECLARE_METATYPE(tst_qdeclarativemodelchange::SignalList)
158
159 void tst_qdeclarativemodelchange::sequence_data()
160 {
161     QTest::addColumn<SignalList>("input");
162     QTest::addColumn<SignalList>("output");
163
164     // Insert
165     QTest::newRow("i(12,5)")
166             << (SignalList() << Insert(12,5))
167             << (SignalList() << Insert(12,5));
168     QTest::newRow("i(2,3),i(12,5)")
169             << (SignalList() << Insert(2,3) << Insert(12,5))
170             << (SignalList() << Insert(2,3) << Insert(12,5));
171     QTest::newRow("i(12,5),i(2,3)")
172             << (SignalList() << Insert(12,5) << Insert(2,3))
173             << (SignalList() << Insert(2,3) << Insert(15,5));
174     QTest::newRow("i(12,5),i(12,3)")
175             << (SignalList() << Insert(12,5) << Insert(12,3))
176             << (SignalList() << Insert(12,8));
177     QTest::newRow("i(12,5),i(17,3)")
178             << (SignalList() << Insert(12,5) << Insert(17,3))
179             << (SignalList() << Insert(12,8));
180     QTest::newRow("i(12,5),i(15,3)")
181             << (SignalList() << Insert(12,5) << Insert(15,3))
182             << (SignalList() << Insert(12,8));
183
184     // Remove
185     QTest::newRow("r(3,9)")
186             << (SignalList() << Remove(3,9))
187             << (SignalList() << Remove(3,9));
188     QTest::newRow("r(3,4),r(3,2)")
189             << (SignalList() << Remove(3,4) << Remove(3,2))
190             << (SignalList() << Remove(3,6));
191     QTest::newRow("r(4,3),r(14,5)")
192             << (SignalList() << Remove(4,3) << Remove(14,5))
193             << (SignalList() << Remove(4,3) << Remove(14,5));
194     QTest::newRow("r(14,5),r(4,3)")
195             << (SignalList() << Remove(14,5) << Remove(4,3))
196             << (SignalList() << Remove(4,3) << Remove(11,5));
197     QTest::newRow("r(4,3),r(2,9)")
198             << (SignalList() << Remove(4,3) << Remove(2,9))
199             << (SignalList() << Remove(2,12));
200
201     // Move
202     QTest::newRow("m(8-10,2)")
203             << (SignalList() << Move(8,10,2))
204             << (SignalList() << Remove(8,2,1) << Insert(10,2,1));
205
206     QTest::newRow("m(23-12,6),m(13-15,5)")
207             << (SignalList() << Move(23,12,6) << Move(13,15,5))
208             << (SignalList() << Remove(23,1,0) << Remove(23,5,1) << Insert(12,1,0) << Insert(15,5,1));
209     QTest::newRow("m(23-12,6),m(13-15,2)")
210             << (SignalList() << Move(23,12,6) << Move(13,20,2))
211             << (SignalList() << Remove(23,1,0) << Remove(23,2,1) << Remove(23,3,2) << Insert(12,1,0) << Insert(13,3,2) << Insert(20,2,1));
212     QTest::newRow("m(23-12,6),m(13-2,2)")
213             << (SignalList() << Move(23,12,6) << Move(13,2,2))
214             << (SignalList() << Remove(23,1,0) << Remove(23,2,1) << Remove(23,3,2) << Insert(2,2,1) << Insert(14,1,0) << Insert(15,3,2));
215     QTest::newRow("m(23-12,6),m(12-6,5)")
216             << (SignalList() << Move(23,12,6) << Move(12,6,5))
217             << (SignalList() << Remove(23,5,0) << Remove(23,1,1) << Insert(6,5,0) << Insert(17,1,1));
218     QTest::newRow("m(23-12,6),m(10-5,4)")
219             << (SignalList() << Move(23,12,6) << Move(10,5,4))
220             << (SignalList() << Remove(10,2,0) << Remove(21,2,1) << Remove(21,4,2) << Insert(5,2,0) << Insert(7,2,1) << Insert(14,4,2));
221     QTest::newRow("m(23-12,6),m(16-5,4)")
222             << (SignalList() << Move(23,12,6) << Move(16,5,4))
223             << (SignalList() << Remove(12,2,0) << Remove(21,4,1) << Remove(21,2,2) << Insert(5,2,2) << Insert(7,2,0) << Insert(16,4,1));
224     QTest::newRow("m(23-12,6),m(13-5,4)")
225             << (SignalList() << Move(23,12,6) << Move(13,5,4))
226             << (SignalList() << Remove(23,1,0) << Remove(23,4,1) << Remove(23,1,2) << Insert(5,4,1) << Insert(16,1,0) << Insert(17,1,2));
227     QTest::newRow("m(23-12,6),m(14-5,4)")
228             << (SignalList() << Move(23,12,6) << Move(14,5,4))
229             << (SignalList() << Remove(23,2,0) << Remove(23,4,1) << Insert(5,4,1) << Insert(16,2,0));
230     QTest::newRow("m(23-12,6),m(12-5,4)")
231             << (SignalList() << Move(23,12,6) << Move(12,5,4))
232             << (SignalList() << Remove(23,4,0) << Remove(23,2,1) << Insert(5,4,0) << Insert(16,2,1));
233     QTest::newRow("m(23-12,6),m(11-5,8)")
234             << (SignalList() << Move(23,12,6) << Move(11,5,8))
235             << (SignalList() << Remove(11,1,0) << Remove(11,1,1) << Remove(21,6,2) << Insert(5,1,0) << Insert(6,6,2) << Insert(12,1,1));
236     QTest::newRow("m(23-12,6),m(8-5,4)")
237             << (SignalList() << Move(23,12,6) << Move(8,5,4))
238             << (SignalList() << Remove(8,4,0) << Remove(19,6,1) << Insert(5,4,0) << Insert(12,6,1));
239     QTest::newRow("m(23-12,6),m(2-5,4)")
240             << (SignalList() << Move(23,12,6) << Move(2,5,4))
241             << (SignalList() << Remove(2,4,0) << Remove(19,6,1) << Insert(5,4,0) << Insert(12,6,1));
242     QTest::newRow("m(23-12,6),m(18-5,4)")
243             << (SignalList() << Move(23,12,6) << Move(18,5,4))
244             << (SignalList() << Remove(12,4,0) << Remove(19,6,1) << Insert(5,4,0) << Insert(16,6,1));
245     QTest::newRow("m(23-12,6),m(20-5,4)")
246             << (SignalList() << Move(23,12,6) << Move(20,5,4))
247             << (SignalList() << Remove(14,4,0) << Remove(19,6,1) << Insert(5,4,0) << Insert(16,6,1));
248
249     QTest::newRow("m(23-12,6),m(5-13,11)")
250             << (SignalList() << Move(23,12,6) << Move(5,13,11))
251             << (SignalList() << Remove(5,7,0) << Remove(16,4,1) << Remove(16,2,2) << Insert(5,2,2) << Insert(13,7,0) << Insert(20,4,1));
252
253     QTest::newRow("m(23-12,6),m(12-23,6)")
254             << (SignalList() << Move(23,12,6) << Move(12,23,6))
255             << (SignalList() << Remove(23,6,0) << Insert(23,6,0));  // ### These cancel out.
256     QTest::newRow("m(23-12,6),m(10-23,4)")
257             << (SignalList() << Move(23,12,6) << Move(10,23,4))
258             << (SignalList() << Remove(10,2 ,0) << Remove(21,2,1) << Remove(21,4,2) << Insert(10,4,2) << Insert(23,2,0) << Insert(25,2,1));
259     QTest::newRow("m(23-12,6),m(16-23.4)")
260             << (SignalList() << Move(23,12,6) << Move(16,23,4))
261             << (SignalList() << Remove(12,2,0) << Remove(21,4,1) << Remove(21,2,2) << Insert(12,4,1) << Insert(23,2,2) << Insert(25,2,0));
262     QTest::newRow("m(23-12,6),m(13-23,4)")
263             << (SignalList() << Move(23,12,6) << Move(13,23,4))
264             << (SignalList() << Remove(23,1,0) << Remove(23,4,1) << Remove(23,1,2) << Insert(12,1,0) << Insert(13,1,2) << Insert(23,4,1));
265     QTest::newRow("m(23-12,6),m(14-23,)")
266             << (SignalList() << Move(23,12,6) << Move(14,23,4))
267             << (SignalList() << Remove(23,2,0) << Remove(23,4,1) << Insert(12,2,0) << Insert(23,4,1));
268     QTest::newRow("m(23-12,6),m(12-23,4)")
269             << (SignalList() << Move(23,12,6) << Move(12,23,4))
270             << (SignalList() << Remove(23,4,0) << Remove(23,2,1) << Insert(12,2,1) << Insert(23,4,0));
271     QTest::newRow("m(23-12,6),m(11-23,8)")
272             << (SignalList() << Move(23,12,6) << Move(11,23,8))
273             << (SignalList() << Remove(11,1,0) << Remove(11,1,1) << Remove(21,6,2) << Insert(23,1,0) << Insert(24,6,2) << Insert(30,1,1));
274     QTest::newRow("m(23-12,6),m(8-23,4)")
275             << (SignalList() << Move(23,12,6) << Move(8,23,4))
276             << (SignalList() << Remove(8,4,0) << Remove(19,6,1) << Insert(8,6,1) << Insert(23,4,0));
277     QTest::newRow("m(23-12,6),m(2-23,4)")
278             << (SignalList() << Move(23,12,6) << Move(2,23,4))
279             << (SignalList() << Remove(2,4,0) << Remove(19,6,1) << Insert(8,6,1) << Insert(23,4,0));
280     QTest::newRow("m(23-12,6),m(18-23,4)")
281             << (SignalList() << Move(23,12,6) << Move(18,23,4))
282             << (SignalList() << Remove(12,4,0) << Remove(19,6,1) << Insert(12,6,1) << Insert(23,4,0));
283     QTest::newRow("m(23-12,6),m(20-23,4)")
284             << (SignalList() << Move(23,12,6) << Move(20,23,4))
285             << (SignalList() << Remove(14,4,1) << Remove(19,6,0) << Insert(12,6,0) << Insert(23,4,1));
286
287     QTest::newRow("m(23-12,6),m(11-23,10)")
288             << (SignalList() << Move(23,12,6) << Move(11,23,10))
289             << (SignalList() << Remove(11,1,3) << Remove(11,3,1) << Remove(19,6,2) << Insert(23,1,3) << Insert(24,6,2) << Insert(30,3,1));
290
291     QTest::newRow("m(3-9,12),m(13-5,12)")
292             << (SignalList() << Move(3,9,12) << Move(13,15,5))
293             << (SignalList() << Remove(3,4,2) << Remove(3,5,1) << Remove(3,2,0) << Remove(3,1,3) << Insert(9,4,2) << Insert(13,2,0) << Insert(15,5,1) << Insert(20,1,3));
294     QTest::newRow("m(3-9,12),m(13-15,20)")
295             << (SignalList() << Move(3,9,12) << Move(13,15,20))
296             << (SignalList() << Remove(3,4,0) << Remove(3,8,1) << Remove(9,12,2) << Insert(9,4,0) << Insert(15,8,1) << Insert(23,12,2));
297     QTest::newRow("m(3-9,12),m(13-15,2)")
298             << (SignalList() << Move(3,9,12) << Move(13,15,2))
299             << (SignalList() << Remove(3,4,2) << Remove(3,2,1) << Remove(3,2,0) << Remove(3,4,3) << Insert(9,4,2) << Insert(13,2,0) << Insert(15,2,1) << Insert(17,4,3));
300     QTest::newRow("m(3-9,12),m(12-5,6)")
301             << (SignalList() << Move(3,9,12) << Move(12,5,6))
302             << (SignalList() << Remove(3,3,0) << Remove(3,6,1) << Remove(3,3,2) << Insert(5,6,1) << Insert(15,3,0) << Insert(18,3,2));
303     QTest::newRow("m(3-9,12),m(10-14,5)")
304             << (SignalList() << Move(3,9,12) << Move(10,14,5))
305             << (SignalList() << Remove(3,1,2) << Remove(3,5,1) << Remove(3,4,0) << Remove(3,2,3) << Insert(9,1,2) << Insert(10,4,0) << Insert(14,5,1) << Insert(19,2,3));
306     QTest::newRow("m(3-9,12),m(16-20,5)")
307             << (SignalList() << Move(3,9,12) << Move(16,20,5))
308             << (SignalList() << Remove(3,7,0) << Remove(3,5,1) << Insert(9,7,0) << Insert(20,5,1));
309     QTest::newRow("m(3-9,12),m(13-17,5)")
310             << (SignalList() << Move(3,9,12) << Move(13,17,5))
311             << (SignalList() << Remove(3,4,0) << Remove(3,5,1) << Remove(3,3,2) << Insert(9,4,0) << Insert(13,3,2) << Insert(17,5,1));
312     QTest::newRow("m(3-9,12),m(14-18,5)")
313             << (SignalList() << Move(3,9,12) << Move(14,18,5))
314             << (SignalList() << Remove(3,5,0) << Remove(3,5,1) << Remove(3,2,2) << Insert(9,5,0) << Insert(14,2,2) << Insert(18,5,1));
315     QTest::newRow("m(3-9,12),m(12-16,5)")
316             << (SignalList() << Move(3,9,12) << Move(12,16,5))
317             << (SignalList() << Remove(3,3,2) << Remove(3,5,1) << Remove(3,4,0) << Insert(9,3,2) << Insert(12,4,0) << Insert(16,5,1));
318     QTest::newRow("m(3-9,12),m(11-19,5)")
319             << (SignalList() << Move(3,9,12) << Move(11,19,5))
320             << (SignalList() << Remove(3,2,0) << Remove(3,5,1) << Remove(3,5,2) << Insert(9,2,0) << Insert(11,5,2) << Insert(19,5,1));
321     QTest::newRow("m(3-9,12),m(8-12,5)")
322             << (SignalList() << Move(3,9,12) << Move(8,12,5))
323             << (SignalList() << Remove(3,4,1) << Remove(3,4,0) << Remove(3,4,4) << Remove(8,1,2) << Insert(8,4,0) << Insert(12,1,2) << Insert(13,4,1) << Insert(17,4,4));
324     QTest::newRow("m(3-9,12),m(2-6,5)")
325             << (SignalList() << Move(3,9,12) << Move(2,6,5))
326             << (SignalList() <<  Remove(2,1,2) << Remove(2,2,0) << Remove(2,10,3) << Remove(2,4,1) << Insert(4,2,0) << Insert(6,1,2) << Insert(7,4,1) << Insert(11,10,3));
327     QTest::newRow("m(3-9,12),m(18-22,5)")
328             << (SignalList() << Move(3,9,12) << Move(18,22,5))
329             << (SignalList() << Remove(3,9,0) << Remove(3,3,1) << Remove(9,2,2) << Insert(9,9,0) << Insert(22,3,1) << Insert(25,2,2));
330     QTest::newRow("m(3-9,12),m(20-24,5)")
331             << (SignalList() << Move(3,9,12) << Move(20,24,5))
332             << (SignalList() << Remove(3,11,0) << Remove(3,1,1) << Remove(9,4,2) << Insert(9,11,0) << Insert(24,1,1) << Insert(25,4,2));
333
334     QTest::newRow("m(3-9,12),m(5-11,8)")
335             << (SignalList() << Move(3,9,12) << Move(5,11,8))
336             << (SignalList() << Remove(3,4,1) << Remove(3,6,0) << Remove(3,2,3) << Remove(5,4,2) << Insert(5,6,0) << Insert(11,4,2) << Insert(15,2,3) << Insert(15,4,1));
337
338     QTest::newRow("m(3-9,12),m(12-23,6)")
339             << (SignalList() << Move(3,9,12) << Move(12,23,6))
340             << (SignalList() << Remove(3,3,2) << Remove(3,6,1) << Remove(3,3,0) << Insert(9,3,2) << Insert(12,3,0) << Insert(23,6,1));
341     QTest::newRow("m(3-9,12),m(10-23,4)")
342             << (SignalList() << Move(3,9,12) << Move(10,23,4))
343             << (SignalList() << Remove(3,1,2) << Remove(3,4,1) << Remove(3,7,0) << Insert(9,1,2) << Insert(10,7,0) << Insert(23,4,1));
344     QTest::newRow("m(3-9,12),m(16-23,4)")
345             << (SignalList() << Move(3,9,12) << Move(16,23,4))
346             << (SignalList() << Remove(3,7,2) << Remove(3,4,1) << Remove(3,1,0) << Insert(9,7,2) << Insert(16,1,0) << Insert(23,4,1));
347     QTest::newRow("m(3-9,12),m(13-23,4)")
348             << (SignalList() << Move(3,9,12) << Move(13,23,4))
349             << (SignalList() << Remove(3,4,2) << Remove(3,4,1) << Remove(3,4,0) << Insert(9,4,2) << Insert(13,4,0) << Insert(23,4,1));
350     QTest::newRow("m(3-9,12),m(14-23,4)")
351             << (SignalList() << Move(3,9,12) << Move(14,23,4))
352             << (SignalList() << Remove(3,5,2) << Remove(3,4,1) << Remove(3,3,0) << Insert(9,5,2) << Insert(14,3,0) << Insert(23,4,1));
353     QTest::newRow("m(3-9,12),m(12-23,4)")
354             << (SignalList() << Move(3,9,12) << Move(12,23,4))
355             << (SignalList() << Remove(3,3,2) << Remove(3,4,1) << Remove(3,5,0) << Insert(9,3,2) << Insert(12,5,0) << Insert(23,4,1));
356     QTest::newRow("m(3-9,12),m(11-23,8)")
357             << (SignalList() << Move(3,9,12) << Move(11,23,8))
358             << (SignalList() << Remove(3,2,2) << Remove(3,8,1) << Remove(3,2,0) << Insert(9,2,2) << Insert(11,2,0) << Insert(23,8,1));
359     QTest::newRow("m(3-9,12),m(8-23,4)")
360             << (SignalList() << Move(3,9,12) << Move(8,23,4))
361             << (SignalList() << Remove(3,3,1) << Remove(3,9,0) << Remove(8,1,2) << Insert(8,9,0) << Insert(23,1,2) << Insert(24,3,1));
362     QTest::newRow("m(3-9,12),m(2-23,4)")
363             << (SignalList() << Move(3,9,12) << Move(2,23,4))
364             << (SignalList() << Remove(2,1,2) << Remove(2,12,0) << Remove(2,3,1) << Insert(5,12,0) << Insert(23,1,2) << Insert(24,3,1));
365     QTest::newRow("m(3-9,12),m(18-23,4)")
366             << (SignalList() << Move(3,9,12) << Move(18,23,4))
367             << (SignalList() << Remove(3,9,3) << Remove(3,3,2) << Remove(9,1,1) << Insert(9,9,3) << Insert(23,3,2) << Insert(26,1,1));
368     QTest::newRow("m(3-9,12),m(20-23,4)")
369             << (SignalList() << Move(3,9,12) << Move(20,23,4))
370             << (SignalList() << Remove(3,11,3) << Remove(3,1,2) << Remove(9,3,1) << Insert(9,11,3) << Insert(23,1,2) << Insert(24,3,1));
371
372     QTest::newRow("m(3-9,12),m(11-23,10)")
373             << (SignalList() << Move(3,9,12) << Move(11,23,10))
374             << (SignalList() << Remove(3,2,2) << Remove(3,10,1) << Insert(9,2,2) << Insert(23,10,1));
375
376     // Change
377     QTest::newRow("c(4,5)")
378             << (SignalList() << Change(4,5))
379             << (SignalList() << Change(4,5));
380     QTest::newRow("c(4,5),c(12,2)")
381             << (SignalList() << Change(4,5) << Change(12,2))
382             << (SignalList() << Change(4,5) << Change(12,2));
383     QTest::newRow("c(12,2),c(4,5)")
384             << (SignalList() << Change(12,2) << Change(4,5))
385             << (SignalList() << Change(4,5) << Change(12,2));
386     QTest::newRow("c(4,5),c(2,2)")
387             << (SignalList() << Change(4,5) << Change(2,2))
388             << (SignalList() << Change(2,7));
389     QTest::newRow("c(4,5),c(9,2)")
390             << (SignalList() << Change(4,5) << Change(9,2))
391             << (SignalList() << Change(4,7));
392     QTest::newRow("c(4,5),c(3,2)")
393             << (SignalList() << Change(4,5) << Change(3,2))
394             << (SignalList() << Change(3,6));
395     QTest::newRow("c(4,5),c(8,2)")
396             << (SignalList() << Change(4,5) << Change(8,2))
397             << (SignalList() << Change(4,6));
398     QTest::newRow("c(4,5),c(3,2)")
399             << (SignalList() << Change(4,5) << Change(3,2))
400             << (SignalList() << Change(3,6));
401     QTest::newRow("c(4,5),c(2,9)")
402             << (SignalList() << Change(4,5) << Change(2,9))
403             << (SignalList() << Change(2,9));
404     QTest::newRow("c(4,5),c(12,3),c(8,6)")
405             << (SignalList() << Change(4,5) << Change(12,3) << Change(8,6))
406             << (SignalList() << Change(4,11));
407
408     // Insert,then remove.
409     QTest::newRow("i(12,6),r(12,6)")
410             << (SignalList() << Insert(12,6) << Remove(12,6))
411             << (SignalList());
412     QTest::newRow("i(12,6),r(10,4)")
413             << (SignalList() << Insert(12,6) << Remove(10,4))
414             << (SignalList() << Remove(10,2) << Insert(10,4));
415     QTest::newRow("i(12,6),r(16,4)")
416             << (SignalList() << Insert(12,6) << Remove(16,4))
417             << (SignalList() << Remove(12,2) << Insert(12,4));
418     QTest::newRow("i(12,6),r(13,4)")
419             << (SignalList() << Insert(12,6) << Remove(13,4))
420             << (SignalList() << Insert(12,2));
421     QTest::newRow("i(12,6),r(14,4)")
422             << (SignalList() << Insert(12,6) << Remove(14,4))
423             << (SignalList() << Insert(12,2));
424     QTest::newRow("i(12,6),r(12,4)")
425             << (SignalList() << Insert(12,6) << Remove(12,4))
426             << (SignalList() << Insert(12,2));
427     QTest::newRow("i(12,6),r(11,8)")
428             << (SignalList() << Insert(12,6) << Remove(11,8))
429             << (SignalList() << Remove(11,2));
430     QTest::newRow("i(12,6),r(8,4)")
431             << (SignalList() << Insert(12,6) << Remove(8,4))
432             << (SignalList() << Remove(8,4) << Insert(8,6));
433     QTest::newRow("i(12,6),r(2,4)")
434             << (SignalList() << Insert(12,6) << Remove(2,4))
435             << (SignalList() << Remove(2,4) << Insert(8,6));
436     QTest::newRow("i(12,6),r(18,4)")
437             << (SignalList() << Insert(12,6) << Remove(18,4))
438             << (SignalList() << Remove(12,4) << Insert(12,6));
439     QTest::newRow("i(12,6),r(20,4)")
440             << (SignalList() << Insert(12,6) << Remove(20,4))
441             << (SignalList() << Remove(14,4) << Insert(12,6));
442
443     // Insert,then move
444     QTest::newRow("i(12,6),m(12-5,6)")
445             << (SignalList() << Insert(12,6) << Move(12,5,6))
446             << (SignalList() << Insert(5,6));
447     QTest::newRow("i(12,6),m(10-5,4)")
448             << (SignalList() << Insert(12,6) << Move(10,5,4))
449             << (SignalList() << Remove(10,2,0) << Insert(5,2,0) << Insert(7,2) << Insert(14,4));
450     QTest::newRow("i(12,6),m(16-5,4)")
451             << (SignalList() << Insert(12,6) << Move(16,5,4))
452             << (SignalList() << Remove(12,2,0) << Insert(5,2) << Insert(7,2,0) << Insert(16,4));
453     QTest::newRow("i(12,6),m(13-5,4)")
454             << (SignalList() << Insert(12,6) << Move(13,5,4))
455             << (SignalList() << Insert(5,4) << Insert(16,2));
456     QTest::newRow("i(12,6),m(14-5,4)")
457             << (SignalList() << Insert(12,6) << Move(14,5,4))
458             << (SignalList() << Insert(5,4) << Insert(16,2));
459     QTest::newRow("i(12,6),m(12-5,4)")
460             << (SignalList() << Insert(12,6) << Move(12,5,4))
461             << (SignalList() << Insert(5,4) << Insert(16,2));
462     QTest::newRow("i(12,6),m(11-5,8)")
463             << (SignalList() << Insert(12,6) << Move(11,5,8))
464             << (SignalList() << Remove(11,1,0) << Remove(11,1,1) << Insert(5,1,0) << Insert(6,6) << Insert(12,1,1));
465     QTest::newRow("i(12,6),m(8-5,4)")
466             << (SignalList() << Insert(12,6) << Move(8,5,4))
467             << (SignalList() << Remove(8,4,0) << Insert(5,4,0) << Insert(12,6));
468     QTest::newRow("i(12,6),m(2-5,4)")
469             << (SignalList() << Insert(12,6) << Move(2,5,4))
470             << (SignalList() << Remove(2,4,0) << Insert(5,4,0) << Insert(12,6));
471     QTest::newRow("i(12,6),m(18-5,4)")
472             << (SignalList() << Insert(12,6) << Move(18,5,4))
473             << (SignalList() << Remove(12,4,0) << Insert(5,4,0) << Insert(16,6));
474     QTest::newRow("i(12,6),m(20-5,4)")
475             << (SignalList() << Insert(12,6) << Move(20,5,4))
476             << (SignalList() << Remove(14,4,0) << Insert(5,4,0) << Insert(16,6));
477
478     QTest::newRow("i(12,6),m(5-13,11)")
479             << (SignalList() << Insert(12,6) << Move(5,11,8))
480             << (SignalList() << Remove(5,7,0) << Insert(5,5) << Insert(11,7,0) << Insert(18,1));
481
482     QTest::newRow("i(12,6),m(12-23,6)")
483             << (SignalList() << Insert(12,6) << Move(12,23,6))
484             << (SignalList() << Insert(23,6));
485     QTest::newRow("i(12,6),m(10-23,4)")
486             << (SignalList() << Insert(12,6) << Move(10,23,4))
487             << (SignalList() << Remove(10,2,0) << Insert(10,4) << Insert(23,2,0) << Insert(25,2));
488     QTest::newRow("i(12,6),m(16-23,4)")
489             << (SignalList() << Insert(12,6) << Move(16,23,4))
490             << (SignalList() << Remove(12,2,0) << Insert(12,4) << Insert(23,2) << Insert(25,2,0));
491     QTest::newRow("i(12,6),m(13-23,4)")
492             << (SignalList() << Insert(12,6) << Move(13,23,4))
493             << (SignalList() << Insert(12,2) << Insert(23,4));
494     QTest::newRow("i(12,6),m(14-23,4)")
495             << (SignalList() << Insert(12,6) << Move(14,23,4))
496             << (SignalList() << Insert(12,2) << Insert(23,4));
497     QTest::newRow("i(12,6),m(12-23,4)")
498             << (SignalList() << Insert(12,6) << Move(12,23,4))
499             << (SignalList() << Insert(12,2) << Insert(23,4));
500     QTest::newRow("i(12,6),m(11-23,8)")
501             << (SignalList() << Insert(12,6) << Move(11,23,8))
502             << (SignalList() << Remove(11,1,0) << Remove(11,1,1) << Insert(23,1,0)<< Insert(24,6) << Insert(30,1,1));
503     QTest::newRow("i(12,6),m(8-23,4)")
504             << (SignalList() << Insert(12,6) << Move(8,23,4))
505             << (SignalList() << Remove(8,4,0) << Insert(8,6) << Insert(23,4,0));
506     QTest::newRow("i(12,6),m(2-23,4)")
507             << (SignalList() << Insert(12,6) << Move(2,23,4))
508             << (SignalList() << Remove(2,4,0) << Insert(8,6) << Insert(23,4,0));
509     QTest::newRow("i(12,6),m(18-23,4)")
510             << (SignalList() << Insert(12,6) << Move(18,23,4))
511             << (SignalList() << Remove(12,4,0) << Insert(12,6) << Insert(23,4,0));
512     QTest::newRow("i(12,6),m(20-23,4)")
513             << (SignalList() << Insert(12,6) << Move(20,23,4))
514             << (SignalList() << Remove(14,4,0) << Insert(12,6) << Insert(23,4,0));
515
516     QTest::newRow("i(12,6),m(11-23,10)")
517             << (SignalList() << Insert(12,6) << Move(11,23,10))
518             << (SignalList() << Remove(11,1,0) << Remove(11,3,1) << Insert(23,1,0) << Insert(24,6) << Insert(30,3,1));
519
520     // Insert,then change
521     QTest::newRow("i(12,6),c(12,6)")
522             << (SignalList() << Insert(12,6) << Change(12,6))
523             << (SignalList() << Insert(12,6));
524     QTest::newRow("i(12,6),c(10,6)")
525             << (SignalList() << Insert(12,6) << Change(10,6))
526             << (SignalList() << Insert(12,6) << Change(10,2));
527     QTest::newRow("i(12,6),c(16,4)")
528             << (SignalList() << Insert(12,6) << Change(16,4))
529             << (SignalList() << Insert(12,6) << Change(18,2));
530     QTest::newRow("i(12,6),c(13,4)")
531             << (SignalList() << Insert(12,6) << Change(13,4))
532             << (SignalList() << Insert(12,6));
533     QTest::newRow("i(12,6),c(14,4)")
534             << (SignalList() << Insert(12,6) << Change(14,4))
535             << (SignalList() << Insert(12,6));
536     QTest::newRow("i(12,6),c(12,4)")
537             << (SignalList() << Insert(12,6) << Change(12,4))
538             << (SignalList() << Insert(12,6));
539     QTest::newRow("i(12,6),c(11,8)")
540             << (SignalList() << Insert(12,6) << Change(11,8))
541             << (SignalList() << Insert(12,6) << Change(11,1) << Change(18,1));
542     QTest::newRow("i(12,6),c(8,4)")
543             << (SignalList() << Insert(12,6) << Change(8,4))
544             << (SignalList() << Insert(12,6) << Change(8,4));
545     QTest::newRow("i(12,6),c(2,4)")
546             << (SignalList() << Insert(12,6) << Change(2,4))
547             << (SignalList() << Insert(12,6) << Change(2,4));
548     QTest::newRow("i(12,6),c(18,4)")
549             << (SignalList() << Insert(12,6) << Change(18,4))
550             << (SignalList() << Insert(12,6) << Change(18,4));
551     QTest::newRow("i(12,6),c(20,4)")
552             << (SignalList() << Insert(12,6) << Change(20,4))
553             << (SignalList() << Insert(12,6) << Change(20,4));
554
555     // Remove,then insert
556     QTest::newRow("r(12,6),i(12,6)")
557             << (SignalList() << Remove(12,6) << Insert(12,6))
558             << (SignalList() << Remove(12,6) << Insert(12,6));
559     QTest::newRow("r(12,6),i(10,4)")
560             << (SignalList() << Remove(12,6) << Insert(10,14))
561             << (SignalList() << Remove(12,6) << Insert(10,14));
562     QTest::newRow("r(12,6),i(16,4)")
563             << (SignalList() << Remove(12,6) << Insert(16,4))
564             << (SignalList() << Remove(12,6) << Insert(16,4));
565     QTest::newRow("r(12,6),i(13,4)")
566             << (SignalList() << Remove(12,6) << Insert(13,4))
567             << (SignalList() << Remove(12,6) << Insert(13,4));
568     QTest::newRow("r(12,6),i(14,4)")
569             << (SignalList() << Remove(12,6) << Insert(14,4))
570             << (SignalList() << Remove(12,6) << Insert(14,4));
571     QTest::newRow("r(12,6),i(12,4)")
572             << (SignalList() << Remove(12,6) << Insert(12,4))
573             << (SignalList() << Remove(12,6) << Insert(12,4));
574     QTest::newRow("r(12,6),i(11,8)")
575             << (SignalList() << Remove(12,6) << Insert(11,8))
576             << (SignalList() << Remove(12,6) << Insert(11,8));
577     QTest::newRow("r(12,6),i(8,4)")
578             << (SignalList() << Remove(12,6) << Insert(8,4))
579             << (SignalList() << Remove(12,6) << Insert(8,4));
580     QTest::newRow("r(12,6),i(2,4)")
581             << (SignalList() << Remove(12,6) << Insert(2,4))
582             << (SignalList() << Remove(12,6) << Insert(2,4));
583     QTest::newRow("r(12,6),i(18,4)")
584             << (SignalList() << Remove(12,6) << Insert(18,4))
585             << (SignalList() << Remove(12,6) << Insert(18,4));
586     QTest::newRow("r(12,6),i(20,4)")
587             << (SignalList() << Remove(12,6) << Insert(20,4))
588             << (SignalList() << Remove(12,6) << Insert(20,4));
589
590     // Move,then insert
591     QTest::newRow("m(12-5,6),i(12,6)")
592             << (SignalList() << Move(12,5,6) << Insert(12,6))
593             << (SignalList() << Remove(12,6,0) << Insert(5,6,0) << Insert(12,6));
594     QTest::newRow("m(12-5,6),i(10,4)")
595             << (SignalList() << Move(12,5,6) << Insert(10,4))
596             << (SignalList() << Remove(12,5,0) << Remove(12,1,1) << Insert(5,5,0) << Insert(10,4) << Insert(14,1,1));
597     QTest::newRow("m(12-5,6),i(16,4)")
598             << (SignalList() << Move(12,5,6) << Insert(16,4))
599             << (SignalList() << Remove(12,6,0) << Insert(5,6,0) << Insert(16,4));
600     QTest::newRow("m(12-5,6),i(13,4)")
601             << (SignalList() << Move(12,5,6) << Insert(13,4))
602             << (SignalList() << Remove(12,6,0) << Insert(5,6,0) << Insert(13,4));
603     QTest::newRow("m(12-5,6),i(14,4)")
604             << (SignalList() << Move(12,5,6) << Insert(14,4))
605             << (SignalList() << Remove(12,6,0) << Insert(5,6,0) << Insert(14,4));
606     QTest::newRow("m(12-5,6),i(12,4)")
607             << (SignalList() << Move(12,5,6) << Insert(12,4))
608             << (SignalList() << Remove(12,6,0) << Insert(5,6,0) << Insert(12,4));
609     QTest::newRow("m(12-5,6),i(11,8)")
610             << (SignalList() << Move(12,5,6) << Insert(11,8))
611             << (SignalList() << Remove(12,6,0) << Insert(5,6,0) << Insert(11,8));
612     QTest::newRow("m(12-5,6),i(8,4)")
613             << (SignalList() << Move(12,5,6) << Insert(8,4))
614             << (SignalList() << Remove(12,3,0) << Remove(12,3,1) << Insert(5,3,0) << Insert(8,4) << Insert(12,3,1));
615     QTest::newRow("m(12-5,6),i(2,4)")
616             << (SignalList() << Move(12,5,6) << Insert(2,4))
617             << (SignalList() << Remove(12,6,0) << Insert(2,4) << Insert(9,6,0));
618     QTest::newRow("m(12-5,6),i(18,4)")
619             << (SignalList() << Move(12,5,6) << Insert(18,4))
620             << (SignalList() << Remove(12,6,0) << Insert(5,6,0) << Insert(18,4));
621     QTest::newRow("m(12-5,6),i(20,4)")
622             << (SignalList() << Move(12,5,6) << Insert(20,4))
623             << (SignalList() << Remove(12,6,0) << Insert(5,6,0) << Insert(20,4));
624
625     QTest::newRow("m(12-23,6),i(12,6)")
626             << (SignalList() << Move(12,23,6) << Insert(12,6))
627             << (SignalList() << Remove(12,6,0) << Insert(12,6) << Insert(29,6,0));
628     QTest::newRow("m(12-23,6),i(10,4)")
629             << (SignalList() << Move(12,23,6) << Insert(10,4))
630             << (SignalList() << Remove(12,6,0) << Insert(10,4) << Insert(27,6,0));
631     QTest::newRow("m(12-23,6),i(16,4)")
632             << (SignalList() << Move(12,23,6) << Insert(16,4))
633             << (SignalList() << Remove(12,6,0) << Insert(16,4) << Insert(27,6,0));
634     QTest::newRow("m(12-23,6),i(13,4)")
635             << (SignalList() << Move(12,23,6) << Insert(13,4))
636             << (SignalList() << Remove(12,6,0) << Insert(13,4) << Insert(27,6,0));
637     QTest::newRow("m(12-23,6),i(14,4)")
638             << (SignalList() << Move(12,23,6) << Insert(14,4))
639             << (SignalList() << Remove(12,6,0) << Insert(14,4) << Insert(27,6,0));
640     QTest::newRow("m(12-23,6),i(12,4)")
641             << (SignalList() << Move(12,23,6) << Insert(12,4))
642             << (SignalList() << Remove(12,6,0) << Insert(12,4) << Insert(27,6,0));
643     QTest::newRow("m(12-23,6),i(11,8)")
644             << (SignalList() << Move(12,23,6) << Insert(11,8))
645             << (SignalList() << Remove(12,6,0) << Insert(11,8) << Insert(31,6,0));
646     QTest::newRow("m(12-23,6),i(8,4)")
647             << (SignalList() << Move(12,23,6) << Insert(8,4))
648             << (SignalList() << Remove(12,6,0) << Insert(8,4) << Insert(27,6,0));
649     QTest::newRow("m(12-23,6),i(2,4)")
650             << (SignalList() << Move(12,23,6) << Insert(2,4))
651             << (SignalList() << Remove(12,6,0) << Insert(2,4) << Insert(27,6,0));
652     QTest::newRow("m(12-23,6),i(18,4)")
653             << (SignalList() << Move(12,23,6) << Insert(18,4))
654             << (SignalList() << Remove(12,6,0) << Insert(18,4) << Insert(27,6,0));
655     QTest::newRow("m(12-23,6),i(20,4)")
656             << (SignalList() << Move(12,23,6) << Insert(20,4))
657             << (SignalList() << Remove(12,6,0) << Insert(20,4) << Insert(27,6,0));
658
659     // Move,then remove
660     QTest::newRow("m(12-5,6),r(12,6)")
661             << (SignalList() << Move(12,5,6) << Remove(12,6))
662             << (SignalList() << Remove(6,6) << Remove(6,6,0) << Insert(5,6,0));
663     QTest::newRow("m(12-5,6),r(10,4)")
664             << (SignalList() << Move(12,5,6) << Remove(10,4))
665             << (SignalList() << Remove(5,3) << Remove(9,5,0) << Remove(9,1) << Insert(5,5,0));
666     QTest::newRow("m(12-5,6),r(16,4)")
667             << (SignalList() << Move(12,5,6) << Remove(16,4))
668             << (SignalList() << Remove(10,2) << Remove(10,6,0) << Remove(10,2) << Insert(5,6,0));
669     QTest::newRow("m(12-5,6),r(13,4)")
670             << (SignalList() << Move(12,5,6) << Remove(13,4))
671             << (SignalList() << Remove(7,4) << Remove(8,6,0) << Insert(5,6,0));
672     QTest::newRow("m(12-5,6),r(14,4)")
673             << (SignalList() << Move(12,5,6) << Remove(14,4))
674             << (SignalList() << Remove(8,4) << Remove(8,6,0) << Insert(5,6,0));
675     QTest::newRow("m(12-5,6),r(12,4)")
676             << (SignalList() << Move(12,5,6) << Remove(12,4))
677             << (SignalList() << Remove(6,4) << Remove(8,6,0) << Insert(5,6,0));
678     QTest::newRow("m(12-5,6),r(11,8)")
679             << (SignalList() << Move(12,5,6) << Remove(11,8))
680             << (SignalList() << Remove(5,7) << Remove(5,6,0) << Remove(5,1) << Insert(5,6,0));
681     QTest::newRow("m(12-5,6),r(8,4)")
682             << (SignalList() << Move(12,5,6) << Remove(8,4))
683             << (SignalList() << Remove(5,1) << Remove(11,3,0) << Remove(11,3) << Insert(5,3,0));
684     QTest::newRow("m(12-5,6),r(2,4)")
685             << (SignalList() << Move(12,5,6) << Remove(2,4))
686             << (SignalList() << Remove(2,3) << Remove(9,1) << Remove(9,5,0) << Insert(2,5,0));
687     QTest::newRow("m(12-5,6),r(6,4)")
688             << (SignalList() << Move(12,5,6) << Remove(6,4))
689             << (SignalList() << Remove(12,1,0) << Remove(12,4) << Remove(12,1,1) << Insert(5,1,0) << Insert(6,1,1));
690     QTest::newRow("m(12-5,6),r(18,4)")
691             << (SignalList() << Move(12,5,6) << Remove(18,4))
692             << (SignalList() << Remove(12,6,0) << Remove(12,4) << Insert(5,6,0));
693     QTest::newRow("m(12-5,6),r(20,4)")
694             << (SignalList() << Move(12,5,6) << Remove(20,4))
695             << (SignalList() << Remove(12,6,0) << Remove(14,4) << Insert(5,6,0));
696
697     QTest::newRow("m(12-23,6),r(12,6)")
698             << (SignalList() << Move(12,23,6) << Remove(12,6))
699             << (SignalList() << Remove(12,6,0) << Remove(12,6) << Insert(17,6,0));
700     QTest::newRow("m(12-23,6),r(10,4)")
701             << (SignalList() << Move(12,23,6) << Remove(10,4))
702             << (SignalList() << Remove(10,2) << Remove(10,6,0) << Remove(10,2) << Insert(19,6,0));
703     QTest::newRow("m(12-23,6),r(16,4)")
704             << (SignalList() << Move(12,23,6) << Remove(16,4))
705             << (SignalList() << Remove(12,6,0) << Remove(16,4) << Insert(19,6,0));
706     QTest::newRow("m(12-23,6),r(13,4)")
707             << (SignalList() << Move(12,23,6) << Remove(13,4))
708             << (SignalList() << Remove(12,6,0) << Remove(13,4) << Insert(19,6,0));
709     QTest::newRow("m(12-23,6),r(14,4)")
710             << (SignalList() << Move(12,23,6) << Remove(14,4))
711             << (SignalList() << Remove(12,6,0) << Remove(14,4) << Insert(19,6,0));
712     QTest::newRow("m(12-23,6),r(12,4)")
713             << (SignalList() << Move(12,23,6) << Remove(12,4))
714             << (SignalList() << Remove(12,6,0) << Remove(12,4) << Insert(19,6,0));
715     QTest::newRow("m(12-23,6),r(11,8)")
716             << (SignalList() << Move(12,23,6) << Remove(11,8))
717             << (SignalList() << Remove(11,1) << Remove(11,6,0) << Remove(11,7) << Insert(15,6,0));
718     QTest::newRow("m(12-23,6),r(8,4)")
719             << (SignalList() << Move(12,23,6) << Remove(8,4))
720             << (SignalList() << Remove(8,4) << Remove(8,6,0) << Insert(19,6,0));
721     QTest::newRow("m(12-23,6),r(2,4)")
722             << (SignalList() << Move(12,23,6) << Remove(2,4))
723             << (SignalList() << Remove(2,4) << Remove(8,6,0) << Insert(19,6,0));
724     QTest::newRow("m(12-23,6),r(18,4)")
725             << (SignalList() << Move(12,23,6) << Remove(18,4))
726             << (SignalList() << Remove(12,6,0) << Remove(18,4) << Insert(19,6,0));
727     QTest::newRow("m(12-23,6),r(20,4)")
728             << (SignalList() << Move(12,23,6) << Remove(20,4))
729             << (SignalList() << Remove(12,1) << Remove(12,5,0) << Remove(20,3) << Insert(20,5,0));
730
731
732     // Complex
733     QTest::newRow("r(15,1),r(22,1)")
734             << (SignalList() << Remove(15,1) << Remove(22,1))
735             << (SignalList() << Remove(15,1) << Remove(22,1));
736     QTest::newRow("r(15,1),r(22,1),r(25,1)")
737             << (SignalList() << Remove(15,1) << Remove(22,1) << Remove(25,1))
738             << (SignalList() << Remove(15,1) << Remove(22,1) << Remove(25,1));
739     QTest::newRow("r(15,1),r(22,1),r(25,1),r(15,1)")
740             << (SignalList() << Remove(15,1) << Remove(22,1) << Remove(25,1) << Remove(15,1))
741             << (SignalList() << Remove(15,2) << Remove(21,1) << Remove(24,1));
742     QTest::newRow("r(15,1),r(22,1),r(25,1),r(15,1),r(13,1)")
743             << (SignalList() << Remove(15,1) << Remove(22,1) << Remove(25,1) << Remove(15,1) << Remove(13,1))
744             << (SignalList() << Remove(13,1) << Remove(14,2) << Remove(20,1) << Remove(23,1));
745     QTest::newRow("r(15,1),r(22,1),r(25,1),r(15,1),r(13,1),r(13,1)")
746             << (SignalList() << Remove(15,1) << Remove(22,1) << Remove(25,1) << Remove(15,1) << Remove(13,1) << Remove(13,1))
747             << (SignalList() << Remove(13,4) << Remove(19,1) << Remove(22,1));
748     QTest::newRow("r(15,1),r(22,1),r(25,1),r(15,1),r(13,1),r(13,1),m(12,13,1)")
749             << (SignalList() << Remove(15,1) << Remove(22,1) << Remove(25,1) << Remove(15,1) << Remove(13,1) << Remove(13,1) << Move(12,13,1))
750             << (SignalList() << Remove(12,1,0) << Remove(12,4) << Remove(18,1) << Remove(21,1) << Insert(13,1,0));
751
752 }
753
754 void tst_qdeclarativemodelchange::sequence()
755 {
756     QFETCH(SignalList, input);
757     QFETCH(SignalList, output);
758
759     QDeclarativeChangeSet set;
760
761     foreach (const Signal &signal, input) {
762         if (signal.isRemove())
763             set.remove(signal.index, signal.count);
764         else if (signal.isInsert())
765             set.insert(signal.index, signal.count);
766         else if (signal.isMove())
767             set.move(signal.index, signal.to, signal.count);
768         else if (signal.isChange())
769             set.change(signal.index, signal.count);
770     }
771
772     SignalList changes;
773     foreach (const QDeclarativeChangeSet::Remove &remove, set.removes())
774         changes << Remove(remove.index, remove.count, remove.moveId);
775     foreach (const QDeclarativeChangeSet::Insert &insert, set.inserts())
776         changes << Insert(insert.index, insert.count, insert.moveId);
777     foreach (const QDeclarativeChangeSet::Change &change, set.changes())
778         changes << Change(change.index, change.count);
779
780 #ifdef VERIFY_EXPECTED_OUTPUT
781     QVector<int> list;
782     for (int i = 0; i < 40; ++i)
783         list.append(i);
784     QVector<int> inputList = applyChanges(list, input);
785     QVector<int> outputList = applyChanges(list, output);
786     if (outputList != inputList /* || changes != output*/) {
787         qDebug() << input;
788         qDebug() << output;
789         qDebug() << changes;
790         qDebug() << inputList;
791         qDebug() << outputList;
792     } else if (changes != output) {
793         qDebug() << output;
794         qDebug() << changes;
795     }
796     QCOMPARE(outputList, inputList);
797 #else
798
799     if (changes != output) {
800         qDebug() << output;
801         qDebug() << changes;
802     }
803
804 #endif
805
806     QCOMPARE(changes, output);
807 }
808
809
810 QTEST_MAIN(tst_qdeclarativemodelchange)
811
812 #include "tst_qdeclarativechangeset.moc"