simple_test_app.cpp 149 KB
Newer Older
1
/**************************************************************************
con's avatar
con committed
2
3
4
**
** This file is part of Qt Creator
**
con's avatar
con committed
5
** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
con's avatar
con committed
6
**
7
** Contact: Nokia Corporation (qt-info@nokia.com)
con's avatar
con committed
8
**
9
**
10
** GNU Lesser General Public License Usage
11
**
hjk's avatar
hjk committed
12
13
14
15
16
17
** This file may be used under the terms of the GNU Lesser General Public
** License version 2.1 as published by the Free Software Foundation and
** appearing in the file LICENSE.LGPL included in the packaging of this file.
** Please review the following information to ensure the GNU Lesser General
** Public License version 2.1 requirements will be met:
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
18
**
con's avatar
con committed
19
** In addition, as a special exception, Nokia gives you certain additional
hjk's avatar
hjk committed
20
** rights. These rights are described in the Nokia Qt LGPL Exception
con's avatar
con committed
21
22
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
hjk's avatar
hjk committed
23
24
25
26
27
** Other Usage
**
** Alternatively, this file may be used in accordance with the terms and
** conditions contained in a signed written agreement between you and Nokia.
**
con's avatar
con committed
28
** If you have questions regarding the use of this file, please contact
29
** Nokia at qt-info@nokia.com.
con's avatar
con committed
30
**
31
**************************************************************************/
con's avatar
con committed
32

hjk's avatar
hjk committed
33
34
35
36
37
38
39
40
41
////////////////  Some global configuration below ////////////////


// The following defines can be used to steer the kind of tests that
// can be done.

// With USE_AUTOBREAK, the debugger will stop automatically on all
// lines containing the BREAK_HERE macro. This should be enabled
// during manual testing.
42
// Default: 0
43
#define USE_AUTOBREAK 0
hjk's avatar
hjk committed
44

45
46
47
48
49
// With USE_AUTORUN, creator will automatically "execute" the commands
// in a comment following a BREAK_HERE line.
// The following commands are supported:
//   // Check <name> <value> <type>
//         - Checks whether the local variable is displayed with value and type.
50
//   //// Continue
51
52
53
54
55
56
//         - Continues execution
// If the line after a BREAK_HERE line does not contain one of the
// supported commands, the test stops.
// Default: 0
#define USE_AUTORUN 0

hjk's avatar
hjk committed
57
58
59
// With USE_UNINITIALIZE_AUTOBREAK, the debugger will stop automatically
// on all lines containing the BREAK_UNINITIALIZED_HERE macro.
// This should be enabled during manual testing.
60
// Default: 0
61
#define USE_UNINITIALIZED_AUTOBREAK 0
hjk's avatar
hjk committed
62

hjk's avatar
hjk committed
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
// With USE_PRIVATE tests that require private headers are enabled.
// Default: 1
#define USE_PRIVATE 1

// With USE_BOOST tests of boost data dumpers are enabled. You need
// some boost headers installed.
// Default: 0
#define USE_BOOST 0

// With USE_EGIEN tests of data dumpers for the "Eigen" library are
// enabled. You need some eigen headers installed.
// Default: 0
#define USE_EIGEN 0

////////////// No further global configuration below ////////////////

79
80
81
82
83
84
85
86
87
88
89
#if QT_SCRIPT_LIB
#define USE_SCRIPTLIB 1
#else
#define USE_SCRIPTLIB 0
#endif

#if QT_VERSION >= 0x040500
#define USE_SHARED_POINTER 1
#else
#define USE_SHARED_POINTER 0
#endif
90

hjk's avatar
hjk committed
91
void dummyStatement(...) {}
hjk's avatar
hjk committed
92

con's avatar
con committed
93
#include <QtCore/QDebug>
94
#include <QtCore/QDateTime>
con's avatar
con committed
95
96
97
#include <QtCore/QDir>
#include <QtCore/QHash>
#include <QtCore/QLibrary>
98
99
#include <QtCore/QLinkedList>
#include <QtCore/QList>
con's avatar
con committed
100
101
#include <QtCore/QMap>
#include <QtCore/QPointer>
102
#include <QtCore/QProcess>
hjk's avatar
hjk committed
103
#include <QtCore/QRegExp>
con's avatar
con committed
104
#include <QtCore/QString>
105
#include <QtCore/QStringList>
hjk's avatar
hjk committed
106
#include <QtCore/QSettings>
hjk's avatar
hjk committed
107
#include <QtCore/QStack>
con's avatar
con committed
108
109
110
#include <QtCore/QThread>
#include <QtCore/QVariant>
#include <QtCore/QVector>
hjk's avatar
hjk committed
111
#include <QtCore/QUrl>
112
#if USE_SHARED_POINTER
113
#include <QtCore/QSharedPointer>
114
#endif
con's avatar
con committed
115
116
117

#include <QtGui/QColor>
#include <QtGui/QFont>
hjk's avatar
hjk committed
118

hjk's avatar
hjk committed
119
//#include <QtGui/private/qfixed_p.h>
con's avatar
con committed
120
121
#include <QtGui/QPainter>
#include <QtGui/QPainterPath>
122
#include <QtGui/QRegion>
123

124
125
#include <QtGui/QTextCursor>
#include <QtGui/QTextDocument>
con's avatar
con committed
126

127
#if USE_SCRIPTLIB
128
129
#include <QtScript/QScriptEngine>
#include <QtScript/QScriptValue>
130
#endif
131

hjk's avatar
hjk committed
132
133
#include <QtXml/QXmlAttributes>

con's avatar
con committed
134
#include <QtNetwork/QHostAddress>
135
#include <QtNetwork/QNetworkRequest>
con's avatar
con committed
136

137
138
139
140
141
#include <QApplication> // QWidgets: Separate module as of Qt 5
#include <QAction>
#include <QStandardItemModel>
#include <QLabel>

hjk's avatar
hjk committed
142
#include <deque>
con's avatar
con committed
143
#include <iostream>
hjk's avatar
hjk committed
144
#include <iterator>
145
#include <fstream>
146
#include <map>
hjk's avatar
hjk committed
147
#include <list>
148
#include <limits>
149
#include <set>
hjk's avatar
hjk committed
150
#include <stack>
con's avatar
con committed
151
152
153
#include <string>
#include <vector>

hjk's avatar
hjk committed
154
155
#include <stdarg.h>

156
157
#include "../simple/deep/deep/simple_test_app.h"

158
159

#if USE_BOOST
160
#include <boost/optional.hpp>
161
#include <boost/shared_ptr.hpp>
162
#include <boost/date_time/gregorian/gregorian.hpp>
163
#endif
164

hjk's avatar
hjk committed
165
166
167
168
#if USE_EIGEN
#include <eigen2/Eigen/Core>
#endif

169
170
171
172
#if USE_PRIVATE
#include <QtCore/private/qobject_p.h>
#endif

173
#if defined(__GNUC__) && !defined(__llvm__) && !defined(Q_OS_MAC)
174
#    define USE_GCC_EXT 1
175
#    undef __DEPRECATED
176
#    include <ext/hash_set>
177
178
#endif

con's avatar
con committed
179
180
#ifdef Q_OS_WIN
#include <windows.h>
181
182
#undef min
#undef max
con's avatar
con committed
183
184
#endif

185
#ifdef __SSE__
hjk's avatar
hjk committed
186
187
188
#include <xmmintrin.h>
#include <stddef.h>
#endif
189

hjk's avatar
hjk committed
190
#if USE_AUTOBREAK
191
#   ifdef Q_CC_MSVC
hjk's avatar
hjk committed
192
193
194
195
196
#       define BREAK_HERE __asm { int 3 }; __asm { mov eax, eax }
#   else
#       define BREAK_HERE asm("int $3; mov %eax, %eax")
#   endif
#else
197
#   define BREAK_HERE dummyStatement()
hjk's avatar
hjk committed
198
199
#endif

hjk's avatar
hjk committed
200
#if USE_UNINITIALIZED_AUTOBREAK
201
#   ifdef Q_CC_MSVC
hjk's avatar
hjk committed
202
203
204
205
206
#       define BREAK_UNINITIALIZED_HERE __asm { int 3 }; __asm { mov eax, eax }
#   else
#       define BREAK_UNINITIALIZED_HERE asm("int $3; mov %eax, %eax")
#   endif
#else
207
#   define BREAK_UNINITIALIZED_HERE dummyStatement()
hjk's avatar
hjk committed
208
209
210
#endif


211
QT_BEGIN_NAMESPACE
hjk's avatar
hjk committed
212
213
uint qHash(const QMap<int, int> &) { return 0; }
uint qHash(const double & f) { return int(f); }
214
uint qHash(const QPointer<QObject> &p) { return (ulong)p.data(); }
215
216
217
218
219
220
221
222
223
224
225
226
227
228
QT_END_NAMESPACE


namespace nsA {
namespace nsB {

struct SomeType
{
    SomeType(int a) : a(a) {}
    int a;
};

} // namespace nsB
} // namespace nsA
hjk's avatar
hjk committed
229
230


231
namespace multibp {
232

hjk's avatar
hjk committed
233
234
    // This tests multiple breakpoints. When a
    // the b
235
236
237
238
239
    template <typename T> class Vector
    {
    public:
        explicit Vector(int size)
            : m_size(size), m_data(new T[size])
240
241
        {
            BREAK_HERE;
242
243
            // Check size 10 int.
            // Continue.
hjk's avatar
hjk committed
244
            // Check there are multiple entries in the Breakpoint vie.
hjk's avatar
hjk committed
245
            dummyStatement(this);
246
        }
247
248
249
250
251
252
253
        ~Vector() { delete [] m_data; }
        int size() const { return m_size; }
    private:
        int m_size;
        T *m_data;
    };

hjk's avatar
hjk committed
254
    void testMultiBp()
255
256
257
258
259
    {
        Vector<int> vi(10);
        Vector<float> vf(10);
        Vector<double> vd(10);
        Vector<char> vc(10);
hjk's avatar
hjk committed
260
        dummyStatement(&vi, &vf, &vd, &vc);
261
    }
262
263

} // namespace multibp
264

hjk's avatar
hjk committed
265

266

hjk's avatar
hjk committed
267

hjk's avatar
hjk committed
268
class Foo
con's avatar
con committed
269
270
{
public:
hjk's avatar
hjk committed
271
    Foo(int i = 0)
con's avatar
con committed
272
273
274
275
276
        : a(i), b(2)
    {
        int s = 1;
        int t = 2;
        b = 2 + s + t;
hjk's avatar
hjk committed
277
        dummyStatement(&s, &t);
con's avatar
con committed
278
    }
279

280
    virtual ~Foo()
281
282
283
284
    {
        a = 5;
    }

con's avatar
con committed
285
286
287
288
289
290
291
292
    void doit()
    {
        static QObject ob;
        m["1"] = "2";
        h[&ob] = m.begin();

        a += 1;
        --b;
293
        dummyStatement(&a, &b);
con's avatar
con committed
294
295
296
297
298
299
300
301
302
303
304
305
    }

public:
    int a, b;
    char x[6];

private:
    typedef QMap<QString, QString> Map;
    Map m;
    QHash<QObject *, Map::iterator> h;
};

hjk's avatar
hjk committed
306
class X : virtual public Foo { public: X() { } };
hjk's avatar
hjk committed
307

hjk's avatar
hjk committed
308
class XX : virtual public Foo { public: XX() { } };
309

hjk's avatar
hjk committed
310
class Y : virtual public Foo { public: Y() { } };
hjk's avatar
hjk committed
311

hjk's avatar
hjk committed
312
class D : public X, public Y { int diamond; };
313

hjk's avatar
hjk committed
314
315
316
317

namespace peekandpoke {

    void testAnonymousStructs()
hjk's avatar
hjk committed
318
    {
hjk's avatar
hjk committed
319
        #ifndef Q_CC_RVCT
hjk's avatar
hjk committed
320
321
322
323
        union {
            struct { int i; int b; };
            struct { float f; };
            double d;
324
        } a = { { 42, 43 } };
hjk's avatar
hjk committed
325
        BREAK_HERE;
326
        // CheckType a union {...}.
327
328
329
330
331
        // Expand a.
        // Check a.b 43 int.
        // Check a.d 9.1245819032257467e-313 double.
        // Check a.f 5.88545355e-44 float.
        // Check a.i 42 int.
332
333
        // Continue.

hjk's avatar
hjk committed
334
335
336
        // Expand a. Step.
        a.i = 1;
        BREAK_HERE;
337
338
339
340
341
342
        // CheckType a union {...}.
        // Expand a.
        // Check a.b 43 int.
        // Check a.d 9.1245819012000775e-313 double.
        // Check a.f 1.40129846e-45 float.
        // Check a.i 1 int.
343
        // Continue.
hjk's avatar
hjk committed
344
345
        a.i = 2;
        BREAK_HERE;
346
347
348
349
350
351
        // CheckType a union {...}.
        // Expand a.
        // Check a.b 43 int.
        // Check a.d 9.1245819012494841e-313 double.
        // Check a.f 2.80259693e-45 float.
        // Check a.i 2 int.
352
        // Continue.
hjk's avatar
hjk committed
353
354
355
        a.i = 3;
        dummyStatement(&a);
        #endif
hjk's avatar
hjk committed
356
357
    }

hjk's avatar
hjk committed
358
    void testComplexWatchers()
hjk's avatar
hjk committed
359
360
    {
        struct S { int a; double b; } s[10];
hjk's avatar
hjk committed
361
362
363
        for (int i = 0; i != 10; ++i)
            s[i].a = i;
        BREAK_HERE;
364
365
366
        // CheckType s peekandpoke::S [10].
        // Continue.

hjk's avatar
hjk committed
367
368
369
370
371
372
        // Expand s and s[0]. Step.
        // Watcher Context: "Add New Watcher".
        // Type    ['s[%d].a' % i for i in range(5)]
        // Expand it, continue stepping. This should result in a list
        // of five items containing the .a fields of s[0]..s[4].
        dummyStatement(&s);
hjk's avatar
hjk committed
373
    }
hjk's avatar
hjk committed
374

hjk's avatar
hjk committed
375
    void testQImageDisplay()
hjk's avatar
hjk committed
376
377
378
379
380
381
    {
        QImage im(QSize(200, 200), QImage::Format_RGB32);
        im.fill(QColor(200, 10, 30).rgba());
        QPainter pain;
        pain.begin(&im);
        pain.setPen(QPen(Qt::black, 5.0, Qt::SolidLine, Qt::RoundCap));
hjk's avatar
hjk committed
382
        BREAK_HERE;
383
384
385
        // Check im (200x200) QImage.
        // CheckType pain QPainter.
        // Continue.
hjk's avatar
hjk committed
386
387
        pain.drawEllipse(20, 20, 160, 160);
        BREAK_HERE;
388
        // Continue.
hjk's avatar
hjk committed
389
        // Toggle between "Normal" and "Displayed" in L&W Context Menu, entry "Display of Type QImage".
hjk's avatar
hjk committed
390
        pain.drawArc(70, 115, 60, 30, 200 * 16, 140 * 16);
hjk's avatar
hjk committed
391
        BREAK_HERE;
392
        // Continue.
hjk's avatar
hjk committed
393
        pain.setBrush(Qt::black);
hjk's avatar
hjk committed
394
        BREAK_HERE;
395
        // Continue.
hjk's avatar
hjk committed
396
397
        pain.drawEllipse(65, 70, 15, 15);
        BREAK_HERE;
398
        // Continue.
hjk's avatar
hjk committed
399
400
401
        // Toggle between "Normal" and "Displayed" in L&W Context Menu, entry "Display of Type QImage".
        pain.drawEllipse(120, 70, 15, 15);
        BREAK_HERE;
402
        // Continue.
hjk's avatar
hjk committed
403
        pain.end();
hjk's avatar
hjk committed
404
        dummyStatement(&pain);
hjk's avatar
hjk committed
405
406
    }

hjk's avatar
hjk committed
407
408
409
410
411
412
413
414
    void testPeekAndPoke3()
    {
        testAnonymousStructs();
        testComplexWatchers();
        testQImageDisplay();
    }

} // namespace peekandpoke
415

416

hjk's avatar
hjk committed
417
namespace anon {
418

hjk's avatar
hjk committed
419
420
    #ifndef Q_CC_RVCT
    struct TestAnonymous
421
    {
hjk's avatar
hjk committed
422
423
424
425
426
427
        union {
            struct { int i; int b; };
            struct { float f; };
            double d;
        };
    };
428

hjk's avatar
hjk committed
429
    namespace {
430

hjk's avatar
hjk committed
431
432
433
        struct Something
        {
            Something() { a = b = 1; }
434

hjk's avatar
hjk committed
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
            void foo()
            {
                a = 42;
                b = 43;
            }

            int a, b;
        };

    }
    #endif

    void testAnonymous()
    {
    #ifndef Q_CC_RVCT
        TestAnonymous a;
451
452
453
454
455
456
457
458
459
460
461
462
        BREAK_HERE;
        // CheckType a anon::TestAnonymous.
        // Expand a.
        // Check a.#1   {...}.
        // Expand a.#1.
        // CheckType a.#1.b int.
        // CheckType a.#1.i int.
        // Check a.#2   {...}.
        // Expand a.#2.
        // CheckType a.#2.f float.
        // CheckType a.d double.
        // Continue.
hjk's avatar
hjk committed
463
464
465
466
        a.i = 1;
        a.i = 2;
        a.i = 3;
        Something s;
467
        BREAK_HERE;
468
        // CheckType s anon::(anonymous namespace)::Something.
469
470
471
        // Expand s.
        // Check s.a 1 int.
        // Check s.b 1 int.
472
        // Continue.
hjk's avatar
hjk committed
473
        s.foo();
474
475
476
477
478
        BREAK_HERE;
        // Expand s.
        // Check s.a 42 int.
        // Check s.b 43 int.
        // Continue.
hjk's avatar
hjk committed
479
480
481
482
483
        dummyStatement(&a, &s);
    #endif
    }

} // namespace anon
484

485

hjk's avatar
hjk committed
486
namespace qbytearray {
hjk's avatar
hjk committed
487

hjk's avatar
hjk committed
488
489
490
    void testQByteArray1()
    {
        QByteArray ba;
491
        BREAK_HERE;
492
493
        // Check ba "" QByteArray.
        // Continue.
hjk's avatar
hjk committed
494
495
496
497
498
499
        ba += "Hello";
        ba += '"';
        ba += "World";
        ba += char(0);
        ba += 1;
        ba += 2;
500
501
        BREAK_HERE;
        // Check ba "Hello"World" QByteArray.
502
503
504
505
506
        // Expand ba.
        // Check ba.0 72 'H' char.
        // Check ba.11 0 '\0' char.
        // Check ba.12 1 char.
        // Check ba.13 2 char.
507
        // Continue.
hjk's avatar
hjk committed
508
509
510
511
512
513
514
515
516
517
        dummyStatement(&ba);
    }

    void testQByteArray2()
    {
        QByteArray ba;
        for (int i = 256; --i >= 0; )
            ba.append(char(i));
        QString s(10000, 'x');
        std::string ss(10000, 'c');
518
519
520
521
522
        BREAK_HERE;
        // Check ba "\377\376\375\374\373\372\371\370\367\366\365\364\363\362\361\360\357\356\355\354\353\352\351\350\347\346\345\344\343\342\341\340\337\336\335\334\333\332\331\330\327\326\325\324\323\322\321\320\317\316\315\314\313\312\311\310\307\306\305\304\303\302\301\300\277\276\275\274\273\272\271\270\267\266\265\264\263\262\261\260\257\256\255\254\253\252\251\250\247\246\245\244\243\242\241\240\237\236\235\234\233\232\231\230\227\226\225\224\223\222\221\220\217\216\215\214\213\212\211\210\207\206\205\204\203\202\201\20..." QByteArray.
        // Check s "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx..." QString.
        // Check ss "ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc..." std::string.
        // Continue.
hjk's avatar
hjk committed
523
524
525
526
527
528
529
530
531
532
533
        dummyStatement(&ba, &ss, &s);
    }

    void testQByteArray3()
    {
        const char *str1 = "\356";
        const char *str2 = "\xee";
        const char *str3 = "\\ee";
        QByteArray buf1(str1);
        QByteArray buf2(str2);
        QByteArray buf3(str3);
534
        BREAK_HERE;
535
536
537
538
539
        // Check buf1 "\356" QByteArray.
        // Check buf2 "\356" QByteArray.
        // Check buf3 "\ee" QByteArray.
        // CheckType str1 char *.
        // Continue.
hjk's avatar
hjk committed
540
541
542
543
544
545
546
547
548
549
550
        dummyStatement(&buf1, &buf2, &buf3);
    }

    void testQByteArray()
    {
        testQByteArray1();
        testQByteArray2();
        testQByteArray3();
    }

} // namespace qbytearray
con's avatar
con committed
551

552

553
namespace catchthrow {
554

555
556
557
    static void throwit1()
    {
        BREAK_HERE;
558
        // Continue.
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
        // Set a breakpoint on "throw" in the BreakWindow context menu
        // before stepping further.
        throw 14;
    }

    static void throwit()
    {
        throwit1();
    }

    void testCatchThrow()
    {
        int gotit = 0;
        try {
            throwit();
        } catch (int what) {
            gotit = what;
        }
        dummyStatement(&gotit);
    }

} // namespace catchthrow
581
582


hjk's avatar
hjk committed
583
namespace qdatetime {
584

hjk's avatar
hjk committed
585
586
587
    void testQDate()
    {
        QDate date;
588
        BREAK_HERE;
589
        // CheckType date QDate.
590
591
592
593
594
        // Expand date.
        // Check date.(ISO) "" QString.
        // Check date.(Locale) "" QString.
        // Check date.(SystemLocale) "" QString.
        // Check date.toString "" QString.
595
596
        // Continue.

hjk's avatar
hjk committed
597
598
599
600
601
602
        // Step, check display.
        date = QDate::currentDate();
        date = date.addDays(5);
        date = date.addDays(5);
        dummyStatement(&date);
    }
603

hjk's avatar
hjk committed
604
605
606
    void testQTime()
    {
        QTime time;
607
        BREAK_HERE;
608
609
610
611
612
613
614
        // CheckType date QDateTime.
        // Expand date.
        // Check date.(ISO) "" QString.
        // Check date.(Locale) "" QString.
        // Check date.(SystemLocale) "" QString.
        // CheckType date.toLocalTime QDateTime.
        // Check date.toString "" QString.
615
        // Continue.
616

hjk's avatar
hjk committed
617
618
619
620
621
622
623
624
625
626
        // Step, check display.
        time = QTime::currentTime();
        time = time.addSecs(5);
        time = time.addSecs(5);
        dummyStatement(&time);
    }

    void testQDateTime()
    {
        QDateTime date;
627
        BREAK_HERE;
628
629
630
631
632
633
634
        // CheckType time QTime.
        // Expand time.
        // Check time.(ISO) "" QString.
        // Check time.(Locale) "" QString.
        // Check time.(SystemLocale) "" QString.
        // Check time.toString "" QString.
        // Check time.toUTC <not available> <unknown>.
635
        // Continue.
636

hjk's avatar
hjk committed
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
        // Step, check display.
        date = QDateTime::currentDateTime();
        date = date.addSecs(5);
        date = date.addSecs(5);
        dummyStatement(&date);
    }

    void testDateTime()
    {
        testQDate();
        testQDateTime();
        testQTime();
    }

} // namespace qdatetime
652

653

hjk's avatar
hjk committed
654
655
656
657
658
namespace qfileinfo {

    void testQFileInfo()
    {
        QFile file("/tmp/t");
hjk's avatar
hjk committed
659
660
        file.setObjectName("A QFile instance");
        QFileInfo fi("/tmp/tt");
hjk's avatar
hjk committed
661
        QString s = fi.absoluteFilePath();
hjk's avatar
hjk committed
662
663
664
665
666
        BREAK_HERE;
        // Check fi "/tmp/tt" QFileInfo.
        // Check file "/tmp/t" QFile.
        // Check s "/tmp/t" QString.
        // Continue.
hjk's avatar
hjk committed
667
668
669
670
671
        dummyStatement(&file, &s);
    }

} // namespace qfileinfo

672

673
674
675
676
677
678
679
680
681
682
namespace qhash {

    void testQHash1()
    {
        QHash<QString, QList<int> > hash;
        hash.insert("Hallo", QList<int>());
        hash.insert("Welt", QList<int>() << 1);
        hash.insert("!", QList<int>() << 1 << 2);
        hash.insert("!", QList<int>() << 1 << 2);
        BREAK_HERE;
683
        // Check hash <3 items> QHash<QString, QList<int>>.
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
        // Expand hash.
        // Check hash.0   QHashNode<QString, QList<int>>.
        // Expand hash.0.
        // Check hash.0.key "Hallo" QString.
        // Check hash.0.value <0 items> QList<int>.
        // Check hash.1   QHashNode<QString, QList<int>>.
        // Expand hash.1.
        // Check hash.1.key "Welt" QString.
        // Check hash.1.value <1 items> QList<int>.
        // Expand hash.1.value.
        // Check hash.1.value.0 1 int.
        // Check hash.2   QHashNode<QString, QList<int>>.
        // Expand hash.2.
        // Check hash.2.key "!" QString.
        // Check hash.2.value <2 items> QList<int>.
        // Expand hash.2.value.
        // Check hash.2.value.0 1 int.
        // Check hash.2.value.1 2 int.
702
        // Continue.
703
704
705
706
707
708
709
710
711
        dummyStatement(&hash);
    }

    void testQHash2()
    {
        QHash<int, float> hash;
        hash[11] = 11.0;
        hash[22] = 22.0;
        BREAK_HERE;
712
        // Check hash <2 items> QHash<int, float>.
713
714
715
        // Expand hash.
        // Check hash.22 22 float.
        // Check hash.11 11 float.
716
        // Continue.
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
        dummyStatement(&hash);
    }

    void testQHash3()
    {
        QHash<QString, int> hash;
        hash["22.0"] = 22.0;
        hash["123.0"] = 22.0;
        hash["111111ss111128.0"] = 28.0;
        hash["11124.0"] = 22.0;
        hash["1111125.0"] = 22.0;
        hash["11111126.0"] = 22.0;
        hash["111111127.0"] = 27.0;
        hash["111111111128.0"] = 28.0;
        hash["111111111111111111129.0"] = 29.0;
        BREAK_HERE;
733
        // Check hash <9 items> QHash<QString, int>.
734
735
736
737
738
739
740
741
742
        // Expand hash.
        // Check hash.0   QHashNode<QString, int>.
        // Expand hash.0.
        // Check hash.0.key "123.0" QString.
        // Check hash.0.value 22 int.
        // Check hash.8   QHashNode<QString, int>.
        // Expand hash.8.
        // Check hash.8.key "11124.0" QString.
        // Check hash.8.value 22 int.
743
        // Continue.
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
        dummyStatement(&hash);
    }

    void testQHash4()
    {
        QHash<QByteArray, float> hash;
        hash["22.0"] = 22.0;
        hash["123.0"] = 22.0;
        hash["111111ss111128.0"] = 28.0;
        hash["11124.0"] = 22.0;
        hash["1111125.0"] = 22.0;
        hash["11111126.0"] = 22.0;
        hash["111111127.0"] = 27.0;
        hash["111111111128.0"] = 28.0;
        hash["111111111111111111129.0"] = 29.0;
        BREAK_HERE;
760
        // Check hash <9 items> QHash<QByteArray, float>.
761
762
763
764
765
766
767
768
769
        // Expand hash.
        // Check hash.0   QHashNode<QByteArray, float>.
        // Expand hash.0.
        // Check hash.0.key "123.0" QByteArray.
        // Check hash.0.value 22 float.
        // Check hash.8   QHashNode<QByteArray, float>.
        // Expand hash.8.
        // Check hash.8.key "11124.0" QByteArray.
        // Check hash.8.value 22 float.
770
        // Continue.
771
772
773
774
775
776
777
778
        dummyStatement(&hash);
    }

    void testQHash5()
    {
        QHash<int, QString> hash;
        hash[22] = "22.0";
        BREAK_HERE;
779
        // Check hash <1 items> QHash<int, QString>.
780
781
782
783
784
        // Expand hash.
        // Check hash.0   QHashNode<int, QString>.
        // Expand hash.0.
        // Check hash.0.key 22 int.
        // Check hash.0.value "22.0" QString.
785
        // Continue.
786
787
788
789
790
791
792
793
794
        dummyStatement(&hash);
    }

    void testQHash6()
    {
        QHash<QString, Foo> hash;
        hash["22.0"] = Foo(22);
        hash["33.0"] = Foo(33);
        BREAK_HERE;
795
        // Check hash <2 items> QHash<QString, Foo>.
796
797
798
799
800
801
802
803
804
805
806
        // Expand hash.
        // Check hash.0   QHashNode<QString, Foo>.
        // Expand hash.0.
        // Check hash.0.key "22.0" QString.
        // CheckType hash.0.value Foo.
        // Expand hash.0.value.
        // Check hash.0.value.a 22 int.
        // Check hash.1   QHashNode<QString, Foo>.
        // Expand hash.1.
        // Check hash.1.key "33.0" QString.
        // CheckType hash.1.value Foo.
807
        // Continue.
808
809
810
811
812
813
814
815
816
817
818
        dummyStatement(&hash);
    }

    void testQHash7()
    {
        QObject ob;
        QHash<QString, QPointer<QObject> > hash;
        hash.insert("Hallo", QPointer<QObject>(&ob));
        hash.insert("Welt", QPointer<QObject>(&ob));
        hash.insert(".", QPointer<QObject>(&ob));
        BREAK_HERE;
819
        // Check hash <3 items> QHash<QString, QPointer<QObject>>.
820
821
822
823
824
825
826
827
828
829
830
        // Expand hash.
        // Check hash.0   QHashNode<QString, QPointer<QObject>>.
        // Expand hash.0.
        // Check hash.0.key "Hallo" QString.
        // CheckType hash.0.value QPointer<QObject>.
        // Expand hash.0.value.
        // CheckType hash.0.value.o QObject.
        // Check hash.2   QHashNode<QString, QPointer<QObject>>.
        // Expand hash.2.
        // Check hash.2.key "." QString.
        // CheckType hash.2.value QPointer<QObject>.
831
        // Continue.
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
        dummyStatement(&hash, &ob);
    }

    void testQHash()
    {
        testQHash1();
        testQHash2();
        testQHash3();
        testQHash4();
        testQHash5();
        testQHash6();
        testQHash7();
    }

} // namespace qhash

848

849
850
851
852
namespace qhostaddress {

    void testQHostAddress()
    {
hjk's avatar
hjk committed
853
        QHostAddress ha1(129u * 256u * 256u * 256u + 130u);
854
        QHostAddress ha2("127.0.0.1");
855
        BREAK_HERE;
856
857
858
        // Check ha1 129.0.0.130 QHostAddress.
        // Check ha2 "127.0.0.1" QHostAddress.
        // Continue.
859
860
861
862
863
        dummyStatement(&ha1, &ha2);
    }

} // namespace qhostaddress

con's avatar
con committed
864

865
namespace painting {
866

867
868
869
870
871
872
873
874
    void testQImage()
    {
        // only works with Python dumper
        QImage im(QSize(200, 200), QImage::Format_RGB32);
        im.fill(QColor(200, 100, 130).rgba());
        QPainter pain;
        pain.begin(&im);
        BREAK_HERE;
875
876
877
        // Check im (200x200) QImage.
        // CheckType pain QPainter.
        // Continue.
878
879
880
881
882
883
884
        // Step.
        pain.drawLine(2, 2, 130, 130);
        pain.drawLine(4, 2, 130, 140);
        pain.drawRect(30, 30, 80, 80);
        pain.end();
        dummyStatement(&pain, &im);
    }
con's avatar
con committed
885

886
887
888
889
890
891
892
893
894
895
    void testQPixmap()
    {
        QImage im(QSize(200, 200), QImage::Format_RGB32);
        im.fill(QColor(200, 100, 130).rgba());
        QPainter pain;
        pain.begin(&im);
        pain.drawLine(2, 2, 130, 130);
        pain.end();
        QPixmap pm = QPixmap::fromImage(im);
        BREAK_HERE;
896
897
898
899
        // Check im (200x200) QImage.
        // CheckType pain QPainter.
        // Check pm (200x200) QPixmap.
        // Continue.
900
901
        dummyStatement(&im, &pm);
    }
con's avatar
con committed
902

903
904
905
906
907
    void testPainting()
    {
        testQImage();
        testQPixmap();
    }
908

909
} // namespace painting
910

911

912
namespace qlinkedlist {
913

914
915
916
917
918
919
    void testQLinkedListInt()
    {
        QLinkedList<int> list;
        list.append(101);
        list.append(102);
        BREAK_HERE;
920
        // Check list <2 items> QLinkedList<int>.
921
922
923
        // Expand list.
        // Check list.0 101 int.
        // Check list.1 102 int.
924
        // Continue.
925
926
        dummyStatement(&list);
    }
927

928
929
930
931
932
933
    void testQLinkedListUInt()
    {
        QLinkedList<uint> list;
        list.append(103);
        list.append(104);
        BREAK_HERE;
934
        // Check list <2 items> QLinkedList<unsigned int>.
935
936
937
        // Expand list.
        // Check list.0 103 unsigned int.
        // Check list.1 104 unsigned int.
938
        // Continue.
939
940
        dummyStatement(&list);
    }
941

942
943
944
945
946
947
948
    void testQLinkedListFooStar()
    {
        QLinkedList<Foo *> list;
        list.append(new Foo(1));
        list.append(0);
        list.append(new Foo(3));
        BREAK_HERE;
949
        // Check list <3 items> QLinkedList<Foo*>.
950
951
952
953
954
955
956
957
        // Expand list.
        // CheckType list.0 Foo.
        // Expand list.0.
        // Check list.0.a 1 int.
        // Check list.1 0x0 Foo *.
        // CheckType list.2 Foo.
        // Expand list.2.
        // Check list.2.a 3 int.
958
        // Continue.
959
960
        dummyStatement(&list);
    }
hjk's avatar
hjk committed
961

962
963
964
965
966
967
    void testQLinkedListULongLong()
    {
        QLinkedList<qulonglong> list;
        list.append(42);
        list.append(43);
        BREAK_HERE;
968
        // Check list <2 items> QLinkedList<unsigned long long>.
969
970
971
        // Expand list.
        // Check list.0 42 unsigned long long.
        // Check list.1 43 unsigned long long.
972
        // Continue.
973
974
975
976
977
978
979
980
981
        dummyStatement(&list);
    }

    void testQLinkedListFoo()
    {
        QLinkedList<Foo> list;
        list.append(Foo(1));
        list.append(Foo(2));
        BREAK_HERE;
982
        // Check list <2 items> QLinkedList<Foo>.
983
984
985
986
987
988
989
        // Expand list.
        // CheckType list.0 Foo.
        // Expand list.0.
        // Check list.0.a 1 int.
        // CheckType list.1 Foo.
        // Expand list.1.
        // Check list.1.a 2 int.
990
        // Continue.
991
992
993
994
995
996
997
998
999
        dummyStatement(&list);
    }

    void testQLinkedListStdString()
    {
        QLinkedList<std::string> list;
        list.push_back("aa");
        list.push_back("bb");
        BREAK_HERE;
1000
        // Check list <2 items> QLinkedList<std::string>.
For faster browsing, not all history is shown. View entire blame