simple_test_app.cpp 154 KB
Newer Older
1
/**************************************************************************
con's avatar
con committed
2 3 4
**
** This file is part of Qt Creator
**
hjk's avatar
hjk committed
5
** Copyright (c) 2012 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
////////////////  Some global configuration below ////////////////


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

39 40 41 42 43
// 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.
hjk's avatar
hjk committed
44 45 46 47 48 49 50
//   // CheckType <name> <type>
//         - Checks whether the local variable is displayed with type.
//           The value is untested, so it can be used with pointers values etc.
//           that would change between test runs
//   // Continue
//       - Continues execution
// On the TODO list:
51
//   // Expand <name1>[ <name2> ...].
hjk's avatar
hjk committed
52
//         - Expands local variables with given names.
53 54
//           There should be at most one "Expand" line per BREAK_HERE,
//           and this should placed on the line following the BREAK_HERE
hjk's avatar
hjk committed
55 56 57
//           FIXME: Not implemented yet.


David Schulz's avatar
David Schulz committed
58
// Value: 1
59 60
// If the line after a BREAK_HERE line does not contain one of the
// supported commands, the test stops.
David Schulz's avatar
David Schulz committed
61 62 63
// Value: 2
// Same as 1, except that the debugger will stop automatically when
// a test after a BREAK_HERE failed
64
// Default: 0
hjk's avatar
hjk committed
65
#ifndef USE_AUTORUN
66
#define USE_AUTORUN 0
hjk's avatar
hjk committed
67 68 69 70 71 72 73 74 75
#endif

// With USE_AUTOBREAK, the debugger will stop automatically on all
// lines containing the BREAK_HERE macro. This should be enabled
// during manual testing.
// Default: 0
#ifndef USE_AUTOBREAK
#define USE_AUTOBREAK 0
#endif
76

hjk's avatar
hjk committed
77
// With USE_UNINITIALIZED_AUTOBREAK, the debugger will stop automatically
hjk's avatar
hjk committed
78 79
// on all lines containing the BREAK_UNINITIALIZED_HERE macro.
// This should be enabled during manual testing.
80
// Default: 0
hjk's avatar
hjk committed
81
#ifndef USE_UNINITIALIZED_AUTOBREAK
82
#define USE_UNINITIALIZED_AUTOBREAK 0
hjk's avatar
hjk committed
83
#endif
hjk's avatar
hjk committed
84

hjk's avatar
hjk committed
85 86 87

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

hjk's avatar
hjk committed
88 89 90 91 92 93 94 95 96 97 98 99 100 101
// AUTORUN is only sensibly with AUTOBREAK and without UNINITIALIZED_AUTOBREAK
#if USE_AUTORUN
#if !(USE_AUTOBREAK)
#undef USE_AUTOBREAK
#define USE_AUTOBREAK 1
#warning Switching on USE_AUTOBREAK
#endif // !USE_AUTOBREAK
#if USE_UNINITIALIZED_AUTOBREAK
#undef USE_UNINITIALIZED_AUTOBREAK
#define USE_UNINITIALIZED_AUTOBREAK 0
#warning Switching off USE_AUTOBREAK
#endif // USE_UNINITIALIZED_AUTOBREAK
#endif

102 103 104 105 106 107 108 109 110 111 112
#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
113

hjk's avatar
hjk committed
114
void dummyStatement(...) {}
hjk's avatar
hjk committed
115

116 117 118 119
#if USE_CXX11 && defined(__GNUC__) && defined(__STRICT_ANSI__)
#undef __STRICT_ANSI__ // working around compile error with MinGW
#endif

120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138
#include <QDebug>
#include <QDateTime>
#include <QDir>
#include <QHash>
#include <QLibrary>
#include <QLinkedList>
#include <QList>
#include <QMap>
#include <QPointer>
#include <QProcess>
#include <QRegExp>
#include <QString>
#include <QStringList>
#include <QSettings>
#include <QStack>
#include <QThread>
#include <QVariant>
#include <QVector>
#include <QUrl>
139
#if USE_SHARED_POINTER
140
#include <QSharedPointer>
141
#endif
con's avatar
con committed
142

143 144
#include <QColor>
#include <QFont>
hjk's avatar
hjk committed
145

hjk's avatar
hjk committed
146
//#include <QtGui/private/qfixed_p.h>
147 148 149
#include <QPainter>
#include <QPainterPath>
#include <QRegion>
150

151 152
#include <QTextCursor>
#include <QTextDocument>
con's avatar
con committed
153

154
#if USE_SCRIPTLIB
155 156
#include <QScriptEngine>
#include <QScriptValue>
157
#endif
158

159
#include <QXmlAttributes>
hjk's avatar
hjk committed
160

161 162
#include <QHostAddress>
#include <QNetworkRequest>
con's avatar
con committed
163

164 165 166 167 168
#include <QApplication> // QWidgets: Separate module as of Qt 5
#include <QAction>
#include <QStandardItemModel>
#include <QLabel>

169 170 171
#if USE_CXX11
#include <array>
#endif
172
#include <complex>
hjk's avatar
hjk committed
173
#include <deque>
con's avatar
con committed
174
#include <iostream>
hjk's avatar
hjk committed
175
#include <iterator>
176
#include <fstream>
177
#include <map>
178
#include <memory>
hjk's avatar
hjk committed
179
#include <list>
180
#include <limits>
181
#include <set>
hjk's avatar
hjk committed
182
#include <stack>
con's avatar
con committed
183 184 185
#include <string>
#include <vector>

hjk's avatar
hjk committed
186 187
#include <stdarg.h>

188 189
#include "../simple/deep/deep/simple_test_app.h"

190 191

#if USE_BOOST
192
#include <boost/optional.hpp>
193
#include <boost/shared_ptr.hpp>
194
#include <boost/date_time.hpp>
195
#include <boost/date_time/gregorian/gregorian.hpp>
196
#include <boost/date_time/posix_time/posix_time.hpp>
197
#endif
198

hjk's avatar
hjk committed
199 200 201 202
#if USE_EIGEN
#include <eigen2/Eigen/Core>
#endif

203
#if USE_PRIVATE
204
#include <private/qobject_p.h>
205 206
#endif

207
#if defined(__GNUC__) && !defined(__llvm__) && !defined(Q_OS_MAC)
208
#    define USE_GCC_EXT 1
209
#    undef __DEPRECATED
210
#    include <ext/hash_set>
211 212
#endif

con's avatar
con committed
213 214
#ifdef Q_OS_WIN
#include <windows.h>
215 216
#undef min
#undef max
con's avatar
con committed
217 218
#endif

219
#ifdef __SSE__
hjk's avatar
hjk committed
220 221 222
#include <xmmintrin.h>
#include <stddef.h>
#endif
223

hjk's avatar
hjk committed
224
#if USE_AUTOBREAK
225
#   ifdef Q_CC_MSVC
hjk's avatar
hjk committed
226 227 228 229 230
#       define BREAK_HERE __asm { int 3 }; __asm { mov eax, eax }
#   else
#       define BREAK_HERE asm("int $3; mov %eax, %eax")
#   endif
#else
231
#   define BREAK_HERE dummyStatement()
hjk's avatar
hjk committed
232 233
#endif

hjk's avatar
hjk committed
234
#if USE_UNINITIALIZED_AUTOBREAK
235
#   ifdef Q_CC_MSVC
hjk's avatar
hjk committed
236 237 238 239 240
#       define BREAK_UNINITIALIZED_HERE __asm { int 3 }; __asm { mov eax, eax }
#   else
#       define BREAK_UNINITIALIZED_HERE asm("int $3; mov %eax, %eax")
#   endif
#else
241
#   define BREAK_UNINITIALIZED_HERE dummyStatement()
hjk's avatar
hjk committed
242 243 244
#endif


245
QT_BEGIN_NAMESPACE
hjk's avatar
hjk committed
246 247
uint qHash(const QMap<int, int> &) { return 0; }
uint qHash(const double & f) { return int(f); }
248
uint qHash(const QPointer<QObject> &p) { return (ulong)p.data(); }
249 250 251 252 253 254 255 256 257 258 259 260 261 262
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
263 264


265
namespace multibp {
266

hjk's avatar
hjk committed
267 268
    // This tests multiple breakpoints. When a
    // the b
269 270 271 272 273
    template <typename T> class Vector
    {
    public:
        explicit Vector(int size)
            : m_size(size), m_data(new T[size])
274 275
        {
            BREAK_HERE;
276 277
            // Check size 10 int.
            // Continue.
hjk's avatar
hjk committed
278
            // Check there are multiple entries in the Breakpoint vie.
hjk's avatar
hjk committed
279
            dummyStatement(this);
280
        }
281 282 283 284 285 286 287
        ~Vector() { delete [] m_data; }
        int size() const { return m_size; }
    private:
        int m_size;
        T *m_data;
    };

hjk's avatar
hjk committed
288
    void testMultiBp()
289 290 291 292 293
    {
        Vector<int> vi(10);
        Vector<float> vf(10);
        Vector<double> vd(10);
        Vector<char> vc(10);
hjk's avatar
hjk committed
294
        dummyStatement(&vi, &vf, &vd, &vc);
295
    }
296 297

} // namespace multibp
298

hjk's avatar
hjk committed
299

300

hjk's avatar
hjk committed
301

hjk's avatar
hjk committed
302
class Foo
con's avatar
con committed
303 304
{
public:
hjk's avatar
hjk committed
305
    Foo(int i = 0)
con's avatar
con committed
306 307 308 309 310
        : a(i), b(2)
    {
        int s = 1;
        int t = 2;
        b = 2 + s + t;
hjk's avatar
hjk committed
311
        dummyStatement(&s, &t);
con's avatar
con committed
312
    }
313

314
    virtual ~Foo()
315 316 317 318
    {
        a = 5;
    }

con's avatar
con committed
319 320 321 322 323 324 325 326
    void doit()
    {
        static QObject ob;
        m["1"] = "2";
        h[&ob] = m.begin();

        a += 1;
        --b;
327
        dummyStatement(&a, &b);
con's avatar
con committed
328 329 330 331 332 333 334 335 336 337 338 339
    }

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
340
class X : virtual public Foo { public: X() { } };
hjk's avatar
hjk committed
341

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

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

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

hjk's avatar
hjk committed
348 349 350 351

namespace peekandpoke {

    void testAnonymousStructs()
hjk's avatar
hjk committed
352
    {
hjk's avatar
hjk committed
353
        #ifndef Q_CC_RVCT
hjk's avatar
hjk committed
354 355 356 357
        union {
            struct { int i; int b; };
            struct { float f; };
            double d;
358
        } a = { { 42, 43 } };
hjk's avatar
hjk committed
359
        BREAK_HERE;
360
        // Expand a.
361
        // CheckType a union {...}.
362 363 364 365
        // Check a.b 43 int.
        // Check a.d 9.1245819032257467e-313 double.
        // Check a.f 5.88545355e-44 float.
        // Check a.i 42 int.
366 367
        // Continue.

hjk's avatar
hjk committed
368 369
        a.i = 1;
        BREAK_HERE;
370
        // Expand a.
371
        // CheckType a union {...}.
372 373 374 375
        // Check a.b 43 int.
        // Check a.d 9.1245819012000775e-313 double.
        // Check a.f 1.40129846e-45 float.
        // Check a.i 1 int.
376
        // Continue.
377

hjk's avatar
hjk committed
378 379
        a.i = 2;
        BREAK_HERE;
380
        // Expand a.
381
        // CheckType a union {...}.
382 383 384 385
        // Check a.b 43 int.
        // Check a.d 9.1245819012494841e-313 double.
        // Check a.f 2.80259693e-45 float.
        // Check a.i 2 int.
386
        // Continue.
387

hjk's avatar
hjk committed
388 389
        dummyStatement(&a);
        #endif
hjk's avatar
hjk committed
390 391
    }

hjk's avatar
hjk committed
392
    void testComplexWatchers()
hjk's avatar
hjk committed
393 394
    {
        struct S { int a; double b; } s[10];
hjk's avatar
hjk committed
395 396 397
        for (int i = 0; i != 10; ++i)
            s[i].a = i;
        BREAK_HERE;
398
        // Expand s and s[0].
399 400 401
        // CheckType s peekandpoke::S [10].
        // Continue.

402 403 404 405
        // Manual: Watcher Context: "Add New Watcher".
        // Manual: Type    ['s[%d].a' % i for i in range(5)]
        // Manual: Expand it, continue stepping. This should result in a list
        // Manual: of five items containing the .a fields of s[0]..s[4].
hjk's avatar
hjk committed
406
        dummyStatement(&s);
hjk's avatar
hjk committed
407
    }
hjk's avatar
hjk committed
408

hjk's avatar
hjk committed
409
    void testQImageDisplay()
hjk's avatar
hjk committed
410 411 412 413 414 415
    {
        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
416
        BREAK_HERE;
417 418 419
        // Check im (200x200) QImage.
        // CheckType pain QPainter.
        // Continue.
420

hjk's avatar
hjk committed
421 422
        pain.drawEllipse(20, 20, 160, 160);
        BREAK_HERE;
423
        // Continue.
424 425 426

        // Manual: Toggle between "Normal" and "Displayed" in L&W Context Menu,
        // Manual: entry "Display of Type QImage".
hjk's avatar
hjk committed
427
        pain.drawArc(70, 115, 60, 30, 200 * 16, 140 * 16);
hjk's avatar
hjk committed
428
        BREAK_HERE;
429
        // Continue.
430

hjk's avatar
hjk committed
431
        pain.setBrush(Qt::black);
hjk's avatar
hjk committed
432
        BREAK_HERE;
433
        // Continue.
434

hjk's avatar
hjk committed
435 436
        pain.drawEllipse(65, 70, 15, 15);
        BREAK_HERE;
437
        // Continue.
438 439 440

        // Manual: Toggle between "Normal" and "Displayed" in L&W Context Menu,
        // Manual: entry "Display of Type QImage".
hjk's avatar
hjk committed
441 442
        pain.drawEllipse(120, 70, 15, 15);
        BREAK_HERE;
443
        // Continue.
444

hjk's avatar
hjk committed
445
        pain.end();
hjk's avatar
hjk committed
446
        dummyStatement(&pain);
hjk's avatar
hjk committed
447 448
    }

hjk's avatar
hjk committed
449 450 451 452 453 454 455 456
    void testPeekAndPoke3()
    {
        testAnonymousStructs();
        testComplexWatchers();
        testQImageDisplay();
    }

} // namespace peekandpoke
457

458

hjk's avatar
hjk committed
459
namespace anon {
460

hjk's avatar
hjk committed
461 462
    #ifndef Q_CC_RVCT
    struct TestAnonymous
463
    {
hjk's avatar
hjk committed
464 465 466 467 468 469
        union {
            struct { int i; int b; };
            struct { float f; };
            double d;
        };
    };
470

hjk's avatar
hjk committed
471
    namespace {
472

hjk's avatar
hjk committed
473 474 475
        struct Something
        {
            Something() { a = b = 1; }
476

hjk's avatar
hjk committed
477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492
            void foo()
            {
                a = 42;
                b = 43;
            }

            int a, b;
        };

    }
    #endif

    void testAnonymous()
    {
    #ifndef Q_CC_RVCT
        TestAnonymous a;
493
        BREAK_HERE;
494
        // Expand a a.#1 a.#2.
495 496 497 498 499 500 501
        // CheckType a anon::TestAnonymous.
        // Check a.#1   {...}.
        // CheckType a.#1.b int.
        // CheckType a.#1.i int.
        // CheckType a.#2.f float.
        // CheckType a.d double.
        // Continue.
hjk's avatar
hjk committed
502 503 504 505
        a.i = 1;
        a.i = 2;
        a.i = 3;
        Something s;
506
        BREAK_HERE;
507
        // Expand s.
508
        // CheckType s anon::(anonymous namespace)::Something.
509 510
        // Check s.a 1 int.
        // Check s.b 1 int.
511
        // Continue.
hjk's avatar
hjk committed
512
        s.foo();
513 514 515 516 517
        BREAK_HERE;
        // Expand s.
        // Check s.a 42 int.
        // Check s.b 43 int.
        // Continue.
hjk's avatar
hjk committed
518 519 520 521 522
        dummyStatement(&a, &s);
    #endif
    }

} // namespace anon
523

524

hjk's avatar
hjk committed
525
namespace qbytearray {
hjk's avatar
hjk committed
526

hjk's avatar
hjk committed
527 528 529
    void testQByteArray1()
    {
        QByteArray ba;
530
        BREAK_HERE;
531 532
        // Check ba "" QByteArray.
        // Continue.
hjk's avatar
hjk committed
533 534 535 536 537 538
        ba += "Hello";
        ba += '"';
        ba += "World";
        ba += char(0);
        ba += 1;
        ba += 2;
539
        BREAK_HERE;
540
        // Expand ba.
541
        // Check ba "Hello"World" QByteArray.
542 543 544 545
        // Check ba.0 72 'H' char.
        // Check ba.11 0 '\0' char.
        // Check ba.12 1 char.
        // Check ba.13 2 char.
546
        // Continue.
hjk's avatar
hjk committed
547 548 549 550 551 552 553 554 555 556
        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');
557 558 559 560 561
        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
562 563 564 565 566 567 568 569 570 571 572
        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);
573
        BREAK_HERE;
574 575 576 577 578
        // Check buf1 "\356" QByteArray.
        // Check buf2 "\356" QByteArray.
        // Check buf3 "\ee" QByteArray.
        // CheckType str1 char *.
        // Continue.
hjk's avatar
hjk committed
579 580 581 582 583 584 585 586 587 588 589
        dummyStatement(&buf1, &buf2, &buf3);
    }

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

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

591

592
namespace catchthrow {
593

594 595 596
    static void throwit1()
    {
        BREAK_HERE;
597
        // Continue.
598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619
        // 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
620 621


hjk's avatar
hjk committed
622
namespace qdatetime {
623

hjk's avatar
hjk committed
624 625 626
    void testQDate()
    {
        QDate date;
627
        BREAK_HERE;
628
        // Expand date.
629
        // CheckType date QDate.
630 631 632 633
        // Check date.(ISO) "" QString.
        // Check date.(Locale) "" QString.
        // Check date.(SystemLocale) "" QString.
        // Check date.toString "" QString.
634 635
        // Continue.

hjk's avatar
hjk committed
636 637 638 639 640 641
        // Step, check display.
        date = QDate::currentDate();
        date = date.addDays(5);
        date = date.addDays(5);
        dummyStatement(&date);
    }
642

hjk's avatar
hjk committed
643 644 645
    void testQTime()
    {
        QTime time;
646
        BREAK_HERE;
647 648 649 650 651 652 653
        // Expand time.
        // CheckType time QTime.
        // Check time.(ISO) "" QString.
        // Check time.(Locale) "" QString.
        // Check time.(SystemLocale) "" QString.
        // CheckType time.toLocalTime QDateTime.
        // Check time.toString "" QString.
654
        // Continue.
655

hjk's avatar
hjk committed
656 657 658 659 660 661 662 663 664 665
        // Step, check display.
        time = QTime::currentTime();
        time = time.addSecs(5);
        time = time.addSecs(5);
        dummyStatement(&time);
    }

    void testQDateTime()
    {
        QDateTime date;
666
        BREAK_HERE;
667
        // Expand date.
668
        // CheckType date QDateTime.
669 670 671 672 673
        // Check date.(ISO) "" QString.
        // Check date.(Locale) "" QString.
        // Check date.(SystemLocale) "" QString.
        // Check date.toString "" QString.
        // Check date.toUTC <not available> <unknown>.
674
        // Continue.
675

hjk's avatar
hjk committed
676 677 678 679 680 681 682 683 684 685 686 687 688 689
        date = QDateTime::currentDateTime();
        date = date.addSecs(5);
        date = date.addSecs(5);
        dummyStatement(&date);
    }

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

} // namespace qdatetime
690

691

hjk's avatar
hjk committed
692 693 694 695 696
namespace qfileinfo {

    void testQFileInfo()
    {
        QFile file("/tmp/t");
hjk's avatar
hjk committed
697 698
        file.setObjectName("A QFile instance");
        QFileInfo fi("/tmp/tt");
hjk's avatar
hjk committed
699
        QString s = fi.absoluteFilePath();
hjk's avatar
hjk committed
700 701 702
        BREAK_HERE;
        // Check fi "/tmp/tt" QFileInfo.
        // Check file "/tmp/t" QFile.
703
        // Check s "/tmp/tt" QString.
hjk's avatar
hjk committed
704
        // Continue.
hjk's avatar
hjk committed
705 706 707 708 709
        dummyStatement(&file, &s);
    }

} // namespace qfileinfo

710

711 712 713 714 715 716 717 718 719 720
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;
721
        // Expand hash hash.0 hash.1 hash.1.value hash.2 hash.2.value.
722
        // Check hash <3 items> QHash<QString, QList<int>>.
723 724 725 726 727 728 729 730 731 732 733 734
        // Check hash.0   QHashNode<QString, QList<int>>.
        // Check hash.0.key "Hallo" QString.
        // Check hash.0.value <0 items> QList<int>.
        // Check hash.1   QHashNode<QString, QList<int>>.
        // Check hash.1.key "Welt" QString.
        // Check hash.1.value <1 items> QList<int>.
        // Check hash.1.value.0 1 int.
        // Check hash.2   QHashNode<QString, QList<int>>.
        // Check hash.2.key "!" QString.
        // Check hash.2.value <2 items> QList<int>.
        // Check hash.2.value.0 1 int.
        // Check hash.2.value.1 2 int.
735
        // Continue.
736 737 738 739 740 741 742 743 744
        dummyStatement(&hash);
    }

    void testQHash2()
    {
        QHash<int, float> hash;
        hash[11] = 11.0;
        hash[22] = 22.0;
        BREAK_HERE;
745
        // Expand hash.
746
        // Check hash <2 items> QHash<int, float>.
747 748
        // Check hash.22 22 float.
        // Check hash.11 11 float.
749
        // Continue.
750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765
        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;
766
        // Expand hash hash.0 hash.8.
767
        // Check hash <9 items> QHash<QString, int>.
768 769 770 771 772 773
        // Check hash.0   QHashNode<QString, int>.
        // Check hash.0.key "123.0" QString.
        // Check hash.0.value 22 int.
        // Check hash.8   QHashNode<QString, int>.
        // Check hash.8.key "11124.0" QString.
        // Check hash.8.value 22 int.
774
        // Continue.
775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790
        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;
791
        // Expand hash hash.0 hash.8/
792
        // Check hash <9 items> QHash<QByteArray, float>.
793 794 795 796 797 798
        // Check hash.0   QHashNode<QByteArray, float>.
        // Check hash.0.key "123.0" QByteArray.
        // Check hash.0.value 22 float.
        // Check hash.8   QHashNode<QByteArray, float>.
        // Check hash.8.key "11124.0" QByteArray.
        // Check hash.8.value 22 float.
799
        // Continue.
800 801 802 803 804 805 806 807
        dummyStatement(&hash);
    }

    void testQHash5()
    {
        QHash<int, QString> hash;
        hash[22] = "22.0";
        BREAK_HERE;
808
        // Expand hash hash.0.
809
        // Check hash <1 items> QHash<int, QString>.
810 811 812
        // Check hash.0   QHashNode<int, QString>.
        // Check hash.0.key 22 int.
        // Check hash.0.value "22.0" QString.
813
        // Continue.
814 815 816 817 818 819 820 821 822
        dummyStatement(&hash);
    }

    void testQHash6()
    {
        QHash<QString, Foo> hash;
        hash["22.0"] = Foo(22);
        hash["33.0"] = Foo(33);
        BREAK_HERE;
823
        // Expand hash hash.0 hash.0.value hash.1.
824
        // Check hash <2 items> QHash<QString, Foo>.
825 826 827 828 829 830 831
        // Check hash.0   QHashNode<QString, Foo>.
        // Check hash.0.key "22.0" QString.
        // CheckType hash.0.value Foo.
        // Check hash.0.value.a 22 int.
        // Check hash.1   QHashNode<QString, Foo>.
        // Check hash.1.key "33.0" QString.
        // CheckType hash.1.value Foo.
832
        // Continue.
833 834 835 836 837 838 839 840 841 842 843
        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;
844
        // Expand hash hash.0 hash.0.value hash.2.
845
        // Check hash <3 items> QHash<QString, QPointer<QObject>>.
846 847 848 849 850 851 852
        // Check hash.0   QHashNode<QString, QPointer<QObject>>.
        // Check hash.0.key "Hallo" QString.
        // CheckType hash.0.value QPointer<QObject>.
        // CheckType hash.0.value.o QObject.
        // Check hash.2   QHashNode<QString, QPointer<QObject>>.
        // Check hash.2.key "." QString.
        // CheckType hash.2.value QPointer<QObject>.
853
        // Continue.
854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869
        dummyStatement(&hash, &ob);
    }

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

} // namespace qhash

870

871 872 873 874
namespace qhostaddress {

    void testQHostAddress()
    {
hjk's avatar
hjk committed
875
        QHostAddress ha1(129u * 256u * 256u * 256u + 130u);
876
        QHostAddress ha2("127.0.0.1");
877
        BREAK_HERE;
878 879 880
        // Check ha1 129.0.0.130 QHostAddress.
        // Check ha2 "127.0.0.1" QHostAddress.
        // Continue.
881 882 883 884 885
        dummyStatement(&ha1, &ha2);
    }

} // namespace qhostaddress

con's avatar
con committed
886

887
namespace painting {
888

889 890 891 892 893 894 895 896
    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;
897 898 899
        // Check im (200x200) QImage.
        // CheckType pain QPainter.
        // Continue.
900 901 902 903 904 905 906
        // 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
907

908 909 910 911 912 913 914 915 916 917
    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;
918 919 920 921
        // Check im (200x200) QImage.
        // CheckType pain QPainter.
        // Check pm (200x200) QPixmap.
        // Continue.
922 923
        dummyStatement(&im, &pm);
    }
con's avatar
con committed
924

925 926 927 928 929
    void testPainting()
    {
        testQImage();
        testQPixmap();
    }
930

931
} // namespace painting
932

933

934
namespace qlinkedlist {
935

936 937 938 939 940 941
    void testQLinkedListInt()
    {
        QLinkedList<int> list;
        list.append(101);
        list.append(102);
        BREAK_HERE;
942
        // Expand list.
943
        // Check list <2 items> QLinkedList<int>.
944 945
        // Check list.0 101 int.
        // Check list.1 102 int.
946
        // Continue.
947 948
        dummyStatement(&list);
    }
949

950 951 952 953 954 955
    void testQLinkedListUInt()
    {
        QLinkedList<uint> list;
        list.append(103);
        list.append(104);
        BREAK_HERE;
956
        // Expand list.
957
        // Check list <2 items> QLinkedList<unsigned int>.
958 959
        // Check list.0 103 unsigned int.
        // Check list.1 104 unsigned int.
960
        // Continue.
961 962
        dummyStatement(&list);
    }
963

964 965 966 967 968 969 970
    void testQLinkedListFooStar()
    {
        QLinkedList<Foo *> list;
        list.append(new Foo(1));
        list.append(0);
        list.append(new Foo(3));
        BREAK_HERE;
971
        // Expand list list.0 list.2.
972
        // Check list <3 items> QLinkedList<Foo*>.
973 974 975 976 977
        // CheckType list.0 Foo.
        // Check list.0.a 1 int.
        // Check list.1 0x0 Foo *.
        // CheckType list.2 Foo.
        // Check list.2.a 3 int.
978
        // Continue.
979 980
        dummyStatement(&list);
    }
hjk's avatar
hjk committed
981

982 983 984 985 986 987
    void testQLinkedListULongLong()
    {
        QLinkedList<qulonglong> list;
        list.append(42);
        list.append(43);
        BREAK_HERE;
988
        // Expand list.
989
        // Check list <2 items> QLinkedList<unsigned long long>.
990 991
        // Check list.0 42 unsigned long long.
        // Check list.1 43 unsigned long long.
992
        // Continue.
993 994 995 996 997 998 999 1000 1001
        dummyStatement(&list);
    }

    void testQLinkedListFoo()
    {
        QLinkedList<Foo> list;
        list.append(Foo(1));
        list.append(Foo(2));
        BREAK_HERE;
1002
        // Expand list list.0 list.1.
1003
        // Check list <2 items> QLinkedList<Foo>.
1004 1005 1006 1007
        // CheckType list.0 Foo.
        // Check list.0.a 1 int.
        // CheckType list.1 Foo.
        // Check list.1.a 2 int.
1008
        // Continue.
1009 1010 1011 1012 1013 1014 1015 1016 1017
        dummyStatement(&list);
    }

    void testQLinkedListStdString()
    {
        QLinkedList<std::string> list;
        list.push_back("aa");
        list.push_back("bb");
        BREAK_HERE;
1018
        // Expand list.
1019
        // Check list <2 items> QLinkedList<std::string>.
1020 1021
        // Check list.0 "aa" std::string.
        // Check list.1 "bb" std::string.
1022
        // Continue.
1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036
        dummyStatement(&list);
    }

    void testQLinkedList()
    {
        testQLinkedListInt();
        testQLinkedListUInt();
        testQLinkedListFooStar();
        testQLinkedListULongLong();
        testQLinkedListFoo();
        testQLinkedListStdString();
    }

} // namespace qlinkedlist
1037

1038

hjk's avatar
hjk committed
1039
namespace qlist {
1040

hjk's avatar
hjk committed
1041 1042 1043 1044 1045 1046
    void testQListInt()
    {
        QList<int> big;
        for (int i = 0; i < 10000; ++i)
            big.push_back(i);
        BREAK_HERE;
1047
        // Expand big.
1048
        // Check big <10000 items> QList<int>.
1049 1050
        // Check big.0 0 int.
        // Check big.1999 1999 int.
1051
        // Continue.
hjk's avatar
hjk committed
1052 1053
        dummyStatement(&big);
    }
con's avatar
con committed