0
+ − 1
/****************************************************************************
+ − 2
**
18
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 3
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
0
+ − 4
** All rights reserved.
+ − 5
** Contact: Nokia Corporation (qt-info@nokia.com)
+ − 6
**
+ − 7
** This file is part of the test suite of the Qt Toolkit.
+ − 8
**
+ − 9
** $QT_BEGIN_LICENSE:LGPL$
+ − 10
** No Commercial Usage
+ − 11
** This file contains pre-release code and may not be distributed.
+ − 12
** You may use this file in accordance with the terms and conditions
+ − 13
** contained in the Technology Preview License Agreement accompanying
+ − 14
** this package.
+ − 15
**
+ − 16
** GNU Lesser General Public License Usage
+ − 17
** Alternatively, this file may be used under the terms of the GNU Lesser
+ − 18
** General Public License version 2.1 as published by the Free Software
+ − 19
** Foundation and appearing in the file LICENSE.LGPL included in the
+ − 20
** packaging of this file. Please review the following information to
+ − 21
** ensure the GNU Lesser General Public License version 2.1 requirements
+ − 22
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+ − 23
**
+ − 24
** In addition, as a special exception, Nokia gives you certain additional
+ − 25
** rights. These rights are described in the Nokia Qt LGPL Exception
+ − 26
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+ − 27
**
+ − 28
** If you have questions regarding the use of this file, please contact
+ − 29
** Nokia at qt-info@nokia.com.
+ − 30
**
+ − 31
**
+ − 32
**
+ − 33
**
+ − 34
**
+ − 35
**
+ − 36
**
+ − 37
**
+ − 38
** $QT_END_LICENSE$
+ − 39
**
+ − 40
****************************************************************************/
+ − 41
+ − 42
+ − 43
+ − 44
#include <QtTest/QtTest>
+ − 45
#include <stdio.h>
+ − 46
#include <qobject.h>
+ − 47
+ − 48
#include "using-namespaces.h"
+ − 49
#include "assign-namespace.h"
+ − 50
#include "no-keywords.h"
+ − 51
#include "single_function_keyword.h"
+ − 52
#include "backslash-newlines.h"
+ − 53
#include "slots-with-void-template.h"
+ − 54
#include "pure-virtual-signals.h"
+ − 55
#include "qinvokable.h"
+ − 56
// msvc and friends crap out on it
+ − 57
#if !defined(Q_CC_GNU) || defined(Q_OS_IRIX) || defined(Q_OS_WIN)
+ − 58
#define SKIP_NEWLINE_TEST
+ − 59
#endif
+ − 60
#if !defined(SKIP_NEWLINE_TEST)
+ − 61
#include "os9-newlines.h"
+ − 62
// msvc and friends crap out on this file too,
+ − 63
// it seems to contain Mac 9 EOLs, and not windows EOLs.
+ − 64
#include "win-newlines.h"
+ − 65
#endif
+ − 66
#include "escapes-in-string-literals.h"
+ − 67
#include "cstyle-enums.h"
+ − 68
+ − 69
+ − 70
#if defined(PARSE_BOOST)
+ − 71
#include "parse-boost.h"
+ − 72
#endif
+ − 73
+ − 74
// No such thing as "long long" in Microsoft's compiler 13.0 and before
+ − 75
#if defined Q_CC_MSVC && _MSC_VER <= 1310
+ − 76
# define NOLONGLONG
+ − 77
#endif
+ − 78
+ − 79
QT_USE_NAMESPACE
+ − 80
+ − 81
struct MyStruct {};
+ − 82
struct MyStruct2 {};
+ − 83
+ − 84
struct SuperClass {};
+ − 85
+ − 86
// Try to avoid inserting for instance a comment with a quote between the following line and the Q_OBJECT
+ − 87
// That will make the test give a false positive.
+ − 88
const char* test_multiple_number_of_escapes = "\\\"";
+ − 89
namespace MyNamespace
+ − 90
{
+ − 91
class TestSuperClass : public QObject
+ − 92
{
+ − 93
Q_OBJECT
+ − 94
public:
+ − 95
inline TestSuperClass() {}
+ − 96
};
+ − 97
}
+ − 98
+ − 99
namespace String
+ − 100
{
+ − 101
typedef QString Type;
+ − 102
}
+ − 103
+ − 104
namespace Int
+ − 105
{
+ − 106
typedef int Type;
+ − 107
}
+ − 108
+ − 109
typedef struct {
+ − 110
int doNotConfuseMoc;
+ − 111
} OldStyleCStruct;
+ − 112
+ − 113
class Sender : public QObject
+ − 114
{
+ − 115
Q_OBJECT
+ − 116
+ − 117
public:
+ − 118
void sendValue(const String::Type& value)
+ − 119
{
+ − 120
emit send(value);
+ − 121
}
+ − 122
void sendValue(const Int::Type& value)
+ − 123
{
+ − 124
emit send(value);
+ − 125
}
+ − 126
+ − 127
signals:
+ − 128
void send(const String::Type&);
+ − 129
void send(const Int::Type&);
+ − 130
};
+ − 131
+ − 132
class Receiver : public QObject
+ − 133
{
+ − 134
Q_OBJECT
+ − 135
public:
+ − 136
Receiver() : stringCallCount(0), intCallCount(0) {}
+ − 137
+ − 138
int stringCallCount;
+ − 139
int intCallCount;
+ − 140
+ − 141
public slots:
+ − 142
void receive(const String::Type&) { stringCallCount++; }
+ − 143
void receive(const Int::Type&) { intCallCount++; }
+ − 144
};
+ − 145
+ − 146
#define MACRO_WITH_POSSIBLE_COMPILER_SPECIFIC_ATTRIBUTES
+ − 147
+ − 148
#define DONT_CONFUSE_MOC(klass) klass
+ − 149
#define DONT_CONFUSE_MOC_EVEN_MORE(klass, dummy, dummy2) klass
+ − 150
+ − 151
Q_DECLARE_METATYPE(MyStruct)
+ − 152
Q_DECLARE_METATYPE(MyStruct*)
+ − 153
+ − 154
namespace myNS {
+ − 155
struct Points
+ − 156
{
+ − 157
Points() : p1(0xBEEF), p2(0xBABE) { }
+ − 158
int p1, p2;
+ − 159
};
+ − 160
}
+ − 161
+ − 162
Q_DECLARE_METATYPE(myNS::Points)
+ − 163
+ − 164
class TestClassinfoWithEscapes: public QObject
+ − 165
{
+ − 166
Q_OBJECT
+ − 167
Q_CLASSINFO("escaped", "\"bar\"")
+ − 168
Q_CLASSINFO("\"escaped\"", "foo")
+ − 169
public slots:
+ − 170
void slotWithAReallyLongName(int)
+ − 171
{ }
+ − 172
};
+ − 173
+ − 174
struct ForwardDeclaredStruct;
+ − 175
+ − 176
struct StructQObject : public QObject
+ − 177
{
+ − 178
Q_OBJECT
+ − 179
public:
+ − 180
void foo(struct ForwardDeclaredStruct *);
+ − 181
};
+ − 182
+ − 183
void StructQObject::foo(struct ForwardDeclaredStruct *)
+ − 184
{
+ − 185
struct Inner {
+ − 186
bool field;
+ − 187
};
+ − 188
+ − 189
struct Inner unusedVariable;
+ − 190
}
+ − 191
+ − 192
class TestClass : public MyNamespace::TestSuperClass, public DONT_CONFUSE_MOC(MyStruct),
+ − 193
public DONT_CONFUSE_MOC_EVEN_MORE(MyStruct2, dummy, ignored)
+ − 194
{
+ − 195
Q_OBJECT
+ − 196
Q_CLASSINFO("help", QT_TR_NOOP("Opening this will let you configure something"))
+ − 197
Q_PROPERTY(short int shortIntProperty READ shortIntProperty)
+ − 198
Q_PROPERTY(unsigned short int unsignedShortIntProperty READ unsignedShortIntProperty)
+ − 199
Q_PROPERTY(signed short int signedShortIntProperty READ signedShortIntProperty)
+ − 200
Q_PROPERTY(long int longIntProperty READ longIntProperty)
+ − 201
Q_PROPERTY(unsigned long int unsignedLongIntProperty READ unsignedLongIntProperty)
+ − 202
Q_PROPERTY(signed long int signedLongIntProperty READ signedLongIntProperty)
+ − 203
Q_PROPERTY(long double longDoubleProperty READ longDoubleProperty)
+ − 204
Q_PROPERTY(myNS::Points points READ points WRITE setPoints)
+ − 205
+ − 206
Q_CLASSINFO("Multi"
+ − 207
"line",
+ − 208
""
+ − 209
"This is a "
+ − 210
"multiline Q_CLASSINFO"
+ − 211
"")
+ − 212
+ − 213
// a really really long string that we have to cut into pieces in the generated stringdata
+ − 214
// table, otherwise msvc craps out
+ − 215
Q_CLASSINFO("D-Bus Introspection", ""
+ − 216
" <interface name=\"org.kde.KCookieServer\" >\n"
+ − 217
" <method name=\"findCookies\" >\n"
+ − 218
" <arg direction=\"in\" type=\"s\" name=\"url\" />\n"
+ − 219
" <arg direction=\"in\" type=\"x\" name=\"windowId\" />\n"
+ − 220
" <arg direction=\"out\" type=\"s\" name=\"cookies\" />\n"
+ − 221
" </method>\n"
+ − 222
" <method name=\"findDomains\" >\n"
+ − 223
" <arg direction=\"out\" type=\"as\" name=\"domains\" />\n"
+ − 224
" </method>\n"
+ − 225
" <method name=\"findCookies\" >\n"
+ − 226
" <arg direction=\"in\" type=\"ai\" name=\"fields\" />\n"
+ − 227
" <arg direction=\"in\" type=\"s\" name=\"domain\" />\n"
+ − 228
" <arg direction=\"in\" type=\"s\" name=\"fqdn\" />\n"
+ − 229
" <arg direction=\"in\" type=\"s\" name=\"path\" />\n"
+ − 230
" <arg direction=\"in\" type=\"s\" name=\"name\" />\n"
+ − 231
" <arg direction=\"out\" type=\"as\" name=\"cookies\" />\n"
+ − 232
" <annotation value=\"QList<int>\" name=\"com.trolltech.QtDBus.QtTypeName.In0\" />\n"
+ − 233
" </method>\n"
+ − 234
" <method name=\"findDOMCookies\" >\n"
+ − 235
" <arg direction=\"in\" type=\"s\" name=\"url\" />\n"
+ − 236
" <arg direction=\"in\" type=\"x\" name=\"windowId\" />\n"
+ − 237
" <arg direction=\"out\" type=\"s\" name=\"cookies\" />\n"
+ − 238
" </method>\n"
+ − 239
" <method name=\"addCookies\" >\n"
+ − 240
" <arg direction=\"in\" type=\"s\" name=\"url\" />\n"
+ − 241
" <arg direction=\"in\" type=\"ay\" name=\"cookieHeader\" />\n"
+ − 242
" <arg direction=\"in\" type=\"x\" name=\"windowId\" />\n"
+ − 243
" </method>\n"
+ − 244
" <method name=\"deleteCookie\" >\n"
+ − 245
" <arg direction=\"in\" type=\"s\" name=\"domain\" />\n"
+ − 246
" <arg direction=\"in\" type=\"s\" name=\"fqdn\" />\n"
+ − 247
" <arg direction=\"in\" type=\"s\" name=\"path\" />\n"
+ − 248
" <arg direction=\"in\" type=\"s\" name=\"name\" />\n"
+ − 249
" </method>\n"
+ − 250
" <method name=\"deleteCookiesFromDomain\" >\n"
+ − 251
" <arg direction=\"in\" type=\"s\" name=\"domain\" />\n"
+ − 252
" </method>\n"
+ − 253
" <method name=\"deleteSessionCookies\" >\n"
+ − 254
" <arg direction=\"in\" type=\"x\" name=\"windowId\" />\n"
+ − 255
" </method>\n"
+ − 256
" <method name=\"deleteSessionCookiesFor\" >\n"
+ − 257
" <arg direction=\"in\" type=\"s\" name=\"fqdn\" />\n"
+ − 258
" <arg direction=\"in\" type=\"x\" name=\"windowId\" />\n"
+ − 259
" </method>\n"
+ − 260
" <method name=\"deleteAllCookies\" />\n"
+ − 261
" <method name=\"addDOMCookies\" >\n"
+ − 262
" <arg direction=\"in\" type=\"s\" name=\"url\" />\n"
+ − 263
" <arg direction=\"in\" type=\"ay\" name=\"cookieHeader\" />\n"
+ − 264
" <arg direction=\"in\" type=\"x\" name=\"windowId\" />\n"
+ − 265
" </method>\n"
+ − 266
" <method name=\"setDomainAdvice\" >\n"
+ − 267
" <arg direction=\"in\" type=\"s\" name=\"url\" />\n"
+ − 268
" <arg direction=\"in\" type=\"s\" name=\"advice\" />\n"
+ − 269
" </method>\n"
+ − 270
" <method name=\"getDomainAdvice\" >\n"
+ − 271
" <arg direction=\"in\" type=\"s\" name=\"url\" />\n"
+ − 272
" <arg direction=\"out\" type=\"s\" name=\"advice\" />\n"
+ − 273
" </method>\n"
+ − 274
" <method name=\"reloadPolicy\" />\n"
+ − 275
" <method name=\"shutdown\" />\n"
+ − 276
" </interface>\n"
+ − 277
"")
+ − 278
+ − 279
public:
+ − 280
inline TestClass() {}
+ − 281
+ − 282
private slots:
+ − 283
inline void dummy1() MACRO_WITH_POSSIBLE_COMPILER_SPECIFIC_ATTRIBUTES {}
+ − 284
inline void dummy2() MACRO_WITH_POSSIBLE_COMPILER_SPECIFIC_ATTRIBUTES const {}
+ − 285
inline void dummy3() const MACRO_WITH_POSSIBLE_COMPILER_SPECIFIC_ATTRIBUTES {}
+ − 286
+ − 287
#ifndef NOLONGLONG
+ − 288
void slotWithULongLong(unsigned long long) {}
+ − 289
void slotWithULongLongP(unsigned long long*) {}
+ − 290
void slotWithULong(unsigned long) {}
+ − 291
void slotWithLongLong(long long) {}
+ − 292
void slotWithLong(long) {}
+ − 293
#endif
+ − 294
+ − 295
void slotWithColonColonType(::Int::Type) {}
+ − 296
+ − 297
TestClass &slotWithReferenceReturnType() { return *this; }
+ − 298
+ − 299
#if (0 && 1) || 1
+ − 300
void expressionEvaluationShortcut1() {}
+ − 301
#endif
+ − 302
#if (1 || 0) && 0
+ − 303
#else
+ − 304
void expressionEvaluationShortcut2() {}
+ − 305
#endif
+ − 306
+ − 307
public slots:
+ − 308
void slotWithArray(const double[3]) {}
+ − 309
void slotWithNamedArray(const double namedArray[3]) {}
+ − 310
void slotWithMultiArray(const double[3][4]) {}
+ − 311
+ − 312
short int shortIntProperty() { return 0; }
+ − 313
unsigned short int unsignedShortIntProperty() { return 0; }
+ − 314
signed short int signedShortIntProperty() { return 0; }
+ − 315
long int longIntProperty() { return 0; }
+ − 316
unsigned long int unsignedLongIntProperty() { return 0; }
+ − 317
signed long int signedLongIntProperty() { return 0; }
+ − 318
long double longDoubleProperty() { return 0.0; }
+ − 319
+ − 320
myNS::Points points() { return m_points; }
+ − 321
void setPoints(myNS::Points points) { m_points = points; }
+ − 322
+ − 323
signals:
+ − 324
void signalWithArray(const double[3]);
+ − 325
void signalWithNamedArray(const double namedArray[3]);
+ − 326
+ − 327
private slots:
+ − 328
// for tst_Moc::preprocessorConditionals
+ − 329
#if 0
+ − 330
void invalidSlot() {}
+ − 331
#else
+ − 332
void slotInElse() {}
+ − 333
#endif
+ − 334
+ − 335
#if 1
+ − 336
void slotInIf() {}
+ − 337
#else
+ − 338
void invalidSlot() {}
+ − 339
#endif
+ − 340
+ − 341
#if 0
+ − 342
void invalidSlot() {}
+ − 343
#elif 0
+ − 344
#else
+ − 345
void slotInLastElse() {}
+ − 346
#endif
+ − 347
+ − 348
#if 0
+ − 349
void invalidSlot() {}
+ − 350
#elif 1
+ − 351
void slotInElif() {}
+ − 352
#else
+ − 353
void invalidSlot() {}
+ − 354
#endif
+ − 355
+ − 356
+ − 357
friend class Receiver; // task #85783
+ − 358
signals:
+ − 359
friend class Sender; // task #85783
+ − 360
+ − 361
public slots:
+ − 362
void const slotWithSillyConst() {}
+ − 363
+ − 364
public:
+ − 365
Q_INVOKABLE void const slotWithSillyConst2() {}
+ − 366
+ − 367
// that one however should be fine
+ − 368
public slots:
+ − 369
void slotWithVoidStar(void *) {}
+ − 370
+ − 371
private:
+ − 372
myNS::Points m_points;
+ − 373
+ − 374
private slots:
+ − 375
inline virtual void blub1() {}
+ − 376
virtual inline void blub2() {}
+ − 377
};
+ − 378
+ − 379
class PropertyTestClass : public QObject
+ − 380
{
+ − 381
Q_OBJECT
+ − 382
public:
+ − 383
+ − 384
enum TestEnum { One, Two, Three };
+ − 385
+ − 386
Q_ENUMS(TestEnum)
+ − 387
};
+ − 388
+ − 389
class PropertyUseClass : public QObject
+ − 390
{
+ − 391
Q_OBJECT
+ − 392
Q_PROPERTY(PropertyTestClass::TestEnum foo READ foo)
+ − 393
public:
+ − 394
+ − 395
inline PropertyTestClass::TestEnum foo() const { return PropertyTestClass::One; }
+ − 396
};
+ − 397
+ − 398
#if defined(Q_MOC_RUN)
+ − 399
// Task #119503
+ − 400
#define _TASK_119503
+ − 401
#if !_TASK_119503
+ − 402
#endif
+ − 403
#endif
+ − 404
+ − 405
static QString srcify(const char *path)
+ − 406
{
+ − 407
#ifndef Q_OS_IRIX
+ − 408
return QString(SRCDIR) + QLatin1Char('/') + QLatin1String(path);
+ − 409
#else
+ − 410
return QString(QLatin1String(path));
+ − 411
#endif
+ − 412
}
+ − 413
+ − 414
class CtorTestClass : public QObject
+ − 415
{
+ − 416
Q_OBJECT
+ − 417
public:
+ − 418
Q_INVOKABLE CtorTestClass(QObject *parent = 0);
+ − 419
+ − 420
CtorTestClass(int foo);
+ − 421
+ − 422
inline Q_INVOKABLE CtorTestClass(const QString &str)
+ − 423
{ m_str = str; }
+ − 424
+ − 425
QString m_str;
+ − 426
+ − 427
protected:
+ − 428
CtorTestClass(int foo, int bar, int baz);
+ − 429
private:
+ − 430
CtorTestClass(float, float) {}
+ − 431
};
+ − 432
+ − 433
CtorTestClass::CtorTestClass(QObject *parent)
+ − 434
: QObject(parent) {}
+ − 435
+ − 436
CtorTestClass::CtorTestClass(int, int, int) {}
+ − 437
+ − 438
+ − 439
class tst_Moc : public QObject
+ − 440
{
+ − 441
Q_OBJECT
+ − 442
+ − 443
Q_PROPERTY(bool user1 READ user1 USER true )
+ − 444
Q_PROPERTY(bool user2 READ user2 USER false)
+ − 445
Q_PROPERTY(bool user3 READ user3 USER userFunction())
+ − 446
+ − 447
public:
+ − 448
inline tst_Moc() {}
+ − 449
+ − 450
private slots:
+ − 451
void initTestCase();
+ − 452
+ − 453
void slotWithException() throw(MyStruct);
+ − 454
void dontStripNamespaces();
+ − 455
void oldStyleCasts();
+ − 456
void warnOnExtraSignalSlotQualifiaction();
+ − 457
void uLongLong();
+ − 458
void inputFileNameWithDotsButNoExtension();
+ − 459
void userProperties();
+ − 460
void supportConstSignals();
+ − 461
void task87883();
+ − 462
void multilineComments();
+ − 463
void classinfoWithEscapes();
+ − 464
void trNoopInClassInfo();
+ − 465
void ppExpressionEvaluation();
+ − 466
void arrayArguments();
+ − 467
void preprocessorConditionals();
+ − 468
void blackslashNewlines();
+ − 469
void slotWithSillyConst();
+ − 470
void testExtraData();
+ − 471
void namespaceTypeProperty();
+ − 472
void slotsWithVoidTemplate();
+ − 473
void structQObject();
+ − 474
void namespacedFlags();
+ − 475
void warnOnMultipleInheritance();
+ − 476
void forgottenQInterface();
+ − 477
void os9Newline();
+ − 478
void winNewline();
+ − 479
void escapesInStringLiterals();
+ − 480
void frameworkSearchPath();
+ − 481
void cstyleEnums();
+ − 482
void defineMacroViaCmdline();
+ − 483
void invokable();
+ − 484
void singleFunctionKeywordSignalAndSlot();
+ − 485
void templateGtGt();
+ − 486
void qprivateslots();
19
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 487
void qprivateproperties();
0
+ − 488
void inlineSlotsWithThrowDeclaration();
+ − 489
void warnOnPropertyWithoutREAD();
+ − 490
void constructors();
+ − 491
void typenameWithUnsigned();
+ − 492
void warnOnVirtualSignal();
3
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 493
void QTBUG5590_dummyProperty();
33
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 494
void QTBUG12260_defaultTemplate();
37
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 495
void notifyError();
0
+ − 496
signals:
+ − 497
void sigWithUnsignedArg(unsigned foo);
+ − 498
void sigWithSignedArg(signed foo);
+ − 499
void sigWithConstSignedArg(const signed foo);
+ − 500
void sigWithVolatileConstSignedArg(volatile const signed foo);
+ − 501
void sigWithCustomType(const MyStruct);
+ − 502
void constSignal1() const;
+ − 503
void constSignal2(int arg) const;
+ − 504
+ − 505
private:
+ − 506
bool user1() { return true; };
+ − 507
bool user2() { return false; };
+ − 508
bool user3() { return false; };
+ − 509
bool userFunction(){ return false; };
+ − 510
+ − 511
private:
+ − 512
QString qtIncludePath;
+ − 513
};
+ − 514
+ − 515
void tst_Moc::initTestCase()
+ − 516
{
+ − 517
#if defined(Q_OS_UNIX) && !defined(QT_NO_PROCESS)
+ − 518
QProcess proc;
+ − 519
proc.start("qmake", QStringList() << "-query" << "QT_INSTALL_HEADERS");
+ − 520
QVERIFY(proc.waitForFinished());
+ − 521
QCOMPARE(proc.exitCode(), 0);
+ − 522
QByteArray output = proc.readAllStandardOutput();
+ − 523
QVERIFY(!output.isEmpty());
+ − 524
QCOMPARE(proc.readAllStandardError(), QByteArray());
+ − 525
qtIncludePath = QString::fromLocal8Bit(output).trimmed();
+ − 526
QFileInfo fi(qtIncludePath);
+ − 527
QVERIFY(fi.exists());
+ − 528
QVERIFY(fi.isDir());
+ − 529
#endif
+ − 530
}
+ − 531
+ − 532
void tst_Moc::slotWithException() throw(MyStruct)
+ − 533
{
+ − 534
// be happy
+ − 535
QVERIFY(true);
+ − 536
}
+ − 537
+ − 538
void tst_Moc::dontStripNamespaces()
+ − 539
{
+ − 540
Sender sender;
+ − 541
Receiver receiver;
+ − 542
+ − 543
connect(&sender, SIGNAL(send(const String::Type &)),
+ − 544
&receiver, SLOT(receive(const String::Type &)));
+ − 545
connect(&sender, SIGNAL(send(const Int::Type &)),
+ − 546
&receiver, SLOT(receive(const Int::Type &)));
+ − 547
+ − 548
sender.sendValue(String::Type("Hello"));
+ − 549
QCOMPARE(receiver.stringCallCount, 1);
+ − 550
QCOMPARE(receiver.intCallCount, 0);
+ − 551
sender.sendValue(Int::Type(42));
+ − 552
QCOMPARE(receiver.stringCallCount, 1);
+ − 553
QCOMPARE(receiver.intCallCount, 1);
+ − 554
}
+ − 555
+ − 556
+ − 557
void tst_Moc::oldStyleCasts()
+ − 558
{
+ − 559
#ifdef MOC_CROSS_COMPILED
+ − 560
QSKIP("Not tested when cross-compiled", SkipAll);
+ − 561
#endif
+ − 562
#if defined(Q_OS_LINUX) && defined(Q_CC_GNU) && !defined(QT_NO_PROCESS)
+ − 563
QProcess proc;
+ − 564
proc.start("moc", QStringList(srcify("/oldstyle-casts.h")));
+ − 565
QVERIFY(proc.waitForFinished());
+ − 566
QCOMPARE(proc.exitCode(), 0);
+ − 567
QByteArray mocOut = proc.readAllStandardOutput();
+ − 568
QVERIFY(!mocOut.isEmpty());
+ − 569
QCOMPARE(proc.readAllStandardError(), QByteArray());
+ − 570
+ − 571
QStringList args;
+ − 572
args << "-c" << "-x" << "c++" << "-Wold-style-cast" << "-I" << "."
+ − 573
<< "-I" << qtIncludePath << "-o" << "/dev/null" << "-";
+ − 574
proc.start("gcc", args);
+ − 575
QVERIFY(proc.waitForStarted());
+ − 576
proc.write(mocOut);
+ − 577
proc.closeWriteChannel();
+ − 578
+ − 579
QVERIFY(proc.waitForFinished());
+ − 580
QCOMPARE(proc.exitCode(), 0);
+ − 581
QCOMPARE(QString::fromLocal8Bit(proc.readAllStandardError()), QString());
+ − 582
#else
+ − 583
QSKIP("Only tested on linux/gcc", SkipAll);
+ − 584
#endif
+ − 585
}
+ − 586
+ − 587
void tst_Moc::warnOnExtraSignalSlotQualifiaction()
+ − 588
{
+ − 589
#ifdef MOC_CROSS_COMPILED
+ − 590
QSKIP("Not tested when cross-compiled", SkipAll);
+ − 591
#endif
+ − 592
#if defined(Q_OS_LINUX) && defined(Q_CC_GNU) && !defined(QT_NO_PROCESS)
+ − 593
QProcess proc;
+ − 594
proc.start("moc", QStringList(srcify("extraqualification.h")));
+ − 595
QVERIFY(proc.waitForFinished());
+ − 596
QCOMPARE(proc.exitCode(), 0);
+ − 597
QByteArray mocOut = proc.readAllStandardOutput();
+ − 598
QVERIFY(!mocOut.isEmpty());
+ − 599
QString mocWarning = QString::fromLocal8Bit(proc.readAllStandardError());
+ − 600
QCOMPARE(mocWarning, QString(SRCDIR) +
+ − 601
QString("/extraqualification.h:53: Warning: Function declaration Test::badFunctionDeclaration contains extra qualification. Ignoring as signal or slot.\n") +
+ − 602
QString(SRCDIR) + QString("/extraqualification.h:56: Warning: parsemaybe: Function declaration Test::anotherOne contains extra qualification. Ignoring as signal or slot.\n"));
+ − 603
#else
+ − 604
QSKIP("Only tested on linux/gcc", SkipAll);
+ − 605
#endif
+ − 606
}
+ − 607
+ − 608
void tst_Moc::uLongLong()
+ − 609
{
+ − 610
#ifndef NOLONGLONG
+ − 611
TestClass tst;
+ − 612
const QMetaObject *mobj = tst.metaObject();
+ − 613
int idx = mobj->indexOfSlot("slotWithULong(ulong)");
+ − 614
QVERIFY(idx != -1);
+ − 615
idx = mobj->indexOfSlot("slotWithULongLong(unsigned long long)");
+ − 616
QVERIFY(idx != -1);
+ − 617
idx = mobj->indexOfSlot("slotWithULongLongP(unsigned long long*)");
+ − 618
QVERIFY(idx != -1);
+ − 619
+ − 620
idx = mobj->indexOfSlot("slotWithLong(long)");
+ − 621
QVERIFY(idx != -1);
+ − 622
idx = mobj->indexOfSlot("slotWithLongLong(long long)");
+ − 623
QVERIFY(idx != -1);
+ − 624
#else
+ − 625
QSKIP("long long doesn't work on MSVC6 & .NET 2002, also skipped on 2003 due to compiler version issue with moc", SkipAll);
+ − 626
#endif
+ − 627
}
+ − 628
+ − 629
void tst_Moc::inputFileNameWithDotsButNoExtension()
+ − 630
{
+ − 631
#ifdef MOC_CROSS_COMPILED
+ − 632
QSKIP("Not tested when cross-compiled", SkipAll);
+ − 633
#endif
+ − 634
#if defined(Q_OS_LINUX) && defined(Q_CC_GNU) && !defined(QT_NO_PROCESS)
+ − 635
QProcess proc;
+ − 636
proc.setWorkingDirectory(QString(SRCDIR) + "/task71021");
+ − 637
proc.start("moc", QStringList("../Header"));
+ − 638
QVERIFY(proc.waitForFinished());
+ − 639
QCOMPARE(proc.exitCode(), 0);
+ − 640
QByteArray mocOut = proc.readAllStandardOutput();
+ − 641
QVERIFY(!mocOut.isEmpty());
+ − 642
QCOMPARE(proc.readAllStandardError(), QByteArray());
+ − 643
+ − 644
QStringList args;
+ − 645
args << "-c" << "-x" << "c++" << "-I" << ".."
+ − 646
<< "-I" << qtIncludePath << "-o" << "/dev/null" << "-";
+ − 647
proc.start("gcc", args);
+ − 648
QVERIFY(proc.waitForStarted());
+ − 649
proc.write(mocOut);
+ − 650
proc.closeWriteChannel();
+ − 651
+ − 652
QVERIFY(proc.waitForFinished());
+ − 653
QCOMPARE(QString::fromLocal8Bit(proc.readAllStandardError()), QString());
+ − 654
QCOMPARE(proc.exitCode(), 0);
+ − 655
#else
+ − 656
QSKIP("Only tested on linux/gcc", SkipAll);
+ − 657
#endif
+ − 658
}
+ − 659
+ − 660
void tst_Moc::userProperties()
+ − 661
{
+ − 662
const QMetaObject *mobj = metaObject();
+ − 663
QMetaProperty property = mobj->property(mobj->indexOfProperty("user1"));
+ − 664
QVERIFY(property.isValid());
+ − 665
QVERIFY(property.isUser());
+ − 666
+ − 667
property = mobj->property(mobj->indexOfProperty("user2"));
+ − 668
QVERIFY(property.isValid());
+ − 669
QVERIFY(!property.isUser());
+ − 670
+ − 671
property = mobj->property(mobj->indexOfProperty("user3"));
+ − 672
QVERIFY(property.isValid());
+ − 673
QVERIFY(!property.isUser(this));
+ − 674
}
+ − 675
+ − 676
void tst_Moc::supportConstSignals()
+ − 677
{
+ − 678
QSignalSpy spy1(this, SIGNAL(constSignal1()));
+ − 679
QVERIFY(spy1.isEmpty());
+ − 680
emit constSignal1();
+ − 681
QCOMPARE(spy1.count(), 1);
+ − 682
+ − 683
QSignalSpy spy2(this, SIGNAL(constSignal2(int)));
+ − 684
QVERIFY(spy2.isEmpty());
+ − 685
emit constSignal2(42);
+ − 686
QCOMPARE(spy2.count(), 1);
+ − 687
QCOMPARE(spy2.at(0).at(0).toInt(), 42);
+ − 688
}
+ − 689
+ − 690
#include "task87883.h"
+ − 691
+ − 692
void tst_Moc::task87883()
+ − 693
{
+ − 694
QVERIFY(Task87883::staticMetaObject.className());
+ − 695
}
+ − 696
+ − 697
#include "c-comments.h"
+ − 698
+ − 699
void tst_Moc::multilineComments()
+ − 700
{
+ − 701
QVERIFY(IfdefedClass::staticMetaObject.className());
+ − 702
}
+ − 703
+ − 704
void tst_Moc::classinfoWithEscapes()
+ − 705
{
+ − 706
const QMetaObject *mobj = &TestClassinfoWithEscapes::staticMetaObject;
+ − 707
QCOMPARE(mobj->methodCount() - mobj->methodOffset(), 1);
+ − 708
+ − 709
QMetaMethod mm = mobj->method(mobj->methodOffset());
+ − 710
QCOMPARE(mm.signature(), "slotWithAReallyLongName(int)");
+ − 711
}
+ − 712
+ − 713
void tst_Moc::trNoopInClassInfo()
+ − 714
{
+ − 715
TestClass t;
+ − 716
const QMetaObject *mobj = t.metaObject();
+ − 717
QVERIFY(mobj);
+ − 718
QCOMPARE(mobj->classInfoCount(), 3);
+ − 719
QCOMPARE(mobj->indexOfClassInfo("help"), 0);
+ − 720
QCOMPARE(QString(mobj->classInfo(0).value()), QString("Opening this will let you configure something"));
+ − 721
}
+ − 722
+ − 723
void tst_Moc::ppExpressionEvaluation()
+ − 724
{
+ − 725
TestClass tst;
+ − 726
const QMetaObject *mobj = tst.metaObject();
+ − 727
int idx = mobj->indexOfSlot("expressionEvaluationShortcut1()");
+ − 728
QVERIFY(idx != -1);
+ − 729
+ − 730
idx = mobj->indexOfSlot("expressionEvaluationShortcut2()");
+ − 731
QVERIFY(idx != -1);
+ − 732
}
+ − 733
+ − 734
void tst_Moc::arrayArguments()
+ − 735
{
+ − 736
TestClass tst;
+ − 737
const QMetaObject *mobj = tst.metaObject();
+ − 738
QVERIFY(mobj->indexOfSlot("slotWithArray(const double[3])") != -1);
+ − 739
QVERIFY(mobj->indexOfSlot("slotWithNamedArray(const double[3])") != -1);
+ − 740
QVERIFY(mobj->indexOfSlot("slotWithMultiArray(const double[3][4])") != -1);
+ − 741
QVERIFY(mobj->indexOfSignal("signalWithArray(const double[3])") != -1);
+ − 742
QVERIFY(mobj->indexOfSignal("signalWithNamedArray(const double[3])") != -1);
+ − 743
}
+ − 744
+ − 745
void tst_Moc::preprocessorConditionals()
+ − 746
{
+ − 747
TestClass tst;
+ − 748
const QMetaObject *mobj = tst.metaObject();
+ − 749
QVERIFY(mobj->indexOfSlot("slotInElse()") != -1);
+ − 750
QVERIFY(mobj->indexOfSlot("slotInIf()") != -1);
+ − 751
QVERIFY(mobj->indexOfSlot("slotInLastElse()") != -1);
+ − 752
QVERIFY(mobj->indexOfSlot("slotInElif()") != -1);
+ − 753
}
+ − 754
+ − 755
void tst_Moc::blackslashNewlines()
+ − 756
{
+ − 757
BackslashNewlines tst;
+ − 758
const QMetaObject *mobj = tst.metaObject();
+ − 759
QVERIFY(mobj->indexOfSlot("works()") != -1);
+ − 760
QVERIFY(mobj->indexOfSlot("buggy()") == -1);
+ − 761
}
+ − 762
+ − 763
void tst_Moc::slotWithSillyConst()
+ − 764
{
+ − 765
TestClass tst;
+ − 766
const QMetaObject *mobj = tst.metaObject();
+ − 767
QVERIFY(mobj->indexOfSlot("slotWithSillyConst()") != -1);
+ − 768
QVERIFY(mobj->indexOfMethod("slotWithSillyConst2()") != -1);
+ − 769
QVERIFY(mobj->indexOfSlot("slotWithVoidStar(void*)") != -1);
+ − 770
}
+ − 771
+ − 772
void tst_Moc::testExtraData()
+ − 773
{
+ − 774
const QMetaObject *mobj = &PropertyTestClass::staticMetaObject;
+ − 775
QCOMPARE(mobj->enumeratorCount(), 1);
+ − 776
QCOMPARE(QByteArray(mobj->enumerator(0).name()), QByteArray("TestEnum"));
+ − 777
+ − 778
mobj = &PropertyUseClass::staticMetaObject;
+ − 779
const int idx = mobj->indexOfProperty("foo");
+ − 780
QVERIFY(idx != -1);
+ − 781
const QMetaProperty prop = mobj->property(idx);
+ − 782
QVERIFY(prop.isValid());
+ − 783
QVERIFY(prop.isEnumType());
+ − 784
const QMetaEnum en = prop.enumerator();
+ − 785
QCOMPARE(QByteArray(en.name()), QByteArray("TestEnum"));
+ − 786
}
+ − 787
+ − 788
void tst_Moc::namespaceTypeProperty()
+ − 789
{
+ − 790
qRegisterMetaType<myNS::Points>("myNS::Points");
+ − 791
TestClass tst;
+ − 792
QByteArray ba = QByteArray("points");
+ − 793
QVariant v = tst.property(ba);
+ − 794
QVERIFY(v.isValid());
+ − 795
myNS::Points p = qVariantValue<myNS::Points>(v);
+ − 796
QCOMPARE(p.p1, 0xBEEF);
+ − 797
QCOMPARE(p.p2, 0xBABE);
+ − 798
p.p1 = 0xCAFE;
+ − 799
p.p2 = 0x1EE7;
+ − 800
QVERIFY(tst.setProperty(ba, qVariantFromValue(p)));
+ − 801
myNS::Points pp = qVariantValue<myNS::Points>(tst.property(ba));
+ − 802
QCOMPARE(p.p1, pp.p1);
+ − 803
QCOMPARE(p.p2, pp.p2);
+ − 804
}
+ − 805
+ − 806
void tst_Moc::slotsWithVoidTemplate()
+ − 807
{
+ − 808
SlotsWithVoidTemplateTest test;
+ − 809
QVERIFY(QObject::connect(&test, SIGNAL(myVoidSignal(void)),
+ − 810
&test, SLOT(dummySlot(void))));
+ − 811
QVERIFY(QObject::connect(&test, SIGNAL(mySignal(const TestTemplate<void> &)),
+ − 812
&test, SLOT(anotherSlot(const TestTemplate<void> &))));
+ − 813
}
+ − 814
+ − 815
void tst_Moc::structQObject()
+ − 816
{
+ − 817
StructQObject o;
+ − 818
QCOMPARE(QByteArray(o.metaObject()->className()), QByteArray("StructQObject"));
+ − 819
}
+ − 820
+ − 821
#include "namespaced-flags.h"
+ − 822
3
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 823
Q_DECLARE_METATYPE(QList<Foo::Bar::Flags>);
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 824
0
+ − 825
void tst_Moc::namespacedFlags()
+ − 826
{
+ − 827
Foo::Baz baz;
+ − 828
Foo::Bar bar;
+ − 829
+ − 830
bar.setFlags(Foo::Bar::Read | Foo::Bar::Write);
+ − 831
QVERIFY(baz.flags() != bar.flags());
+ − 832
+ − 833
const QVariant v = bar.property("flags");
+ − 834
QVERIFY(v.isValid());
+ − 835
QVERIFY(baz.setProperty("flags", v));
+ − 836
QVERIFY(baz.flags() == bar.flags());
3
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 837
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 838
QList<Foo::Bar::Flags> l;
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 839
l << baz.flags();
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 840
QVariant v2 = baz.setProperty("flagsList", QVariant::fromValue(l));
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 841
QCOMPARE(l, baz.flagsList());
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 842
QCOMPARE(l, qvariant_cast<QList<Foo::Bar::Flags> >(baz.property("flagsList")));
0
+ − 843
}
+ − 844
+ − 845
void tst_Moc::warnOnMultipleInheritance()
+ − 846
{
+ − 847
#ifdef MOC_CROSS_COMPILED
+ − 848
QSKIP("Not tested when cross-compiled", SkipAll);
+ − 849
#endif
+ − 850
#if defined(Q_OS_LINUX) && defined(Q_CC_GNU) && !defined(QT_NO_PROCESS)
+ − 851
QProcess proc;
+ − 852
QStringList args;
+ − 853
args << "-I" << qtIncludePath + "/QtGui"
+ − 854
<< srcify("warn-on-multiple-qobject-subclasses.h");
+ − 855
proc.start("moc", args);
+ − 856
QVERIFY(proc.waitForFinished());
+ − 857
QCOMPARE(proc.exitCode(), 0);
+ − 858
QByteArray mocOut = proc.readAllStandardOutput();
+ − 859
QVERIFY(!mocOut.isEmpty());
+ − 860
QString mocWarning = QString::fromLocal8Bit(proc.readAllStandardError());
+ − 861
QCOMPARE(mocWarning, QString(SRCDIR) +
+ − 862
QString("/warn-on-multiple-qobject-subclasses.h:53: Warning: Class Bar inherits from two QObject subclasses QWidget and Foo. This is not supported!\n"));
+ − 863
#else
+ − 864
QSKIP("Only tested on linux/gcc", SkipAll);
+ − 865
#endif
+ − 866
}
+ − 867
+ − 868
void tst_Moc::forgottenQInterface()
+ − 869
{
+ − 870
#ifdef MOC_CROSS_COMPILED
+ − 871
QSKIP("Not tested when cross-compiled", SkipAll);
+ − 872
#endif
+ − 873
#if defined(Q_OS_LINUX) && defined(Q_CC_GNU) && !defined(QT_NO_PROCESS)
+ − 874
QProcess proc;
+ − 875
QStringList args;
+ − 876
args << "-I" << qtIncludePath + "/QtCore"
+ − 877
<< srcify("forgotten-qinterface.h");
+ − 878
proc.start("moc", args);
+ − 879
QVERIFY(proc.waitForFinished());
+ − 880
QCOMPARE(proc.exitCode(), 0);
+ − 881
QByteArray mocOut = proc.readAllStandardOutput();
+ − 882
QVERIFY(!mocOut.isEmpty());
+ − 883
QString mocWarning = QString::fromLocal8Bit(proc.readAllStandardError());
+ − 884
QCOMPARE(mocWarning, QString(SRCDIR) +
+ − 885
QString("/forgotten-qinterface.h:55: Warning: Class Test implements the interface MyInterface but does not list it in Q_INTERFACES. qobject_cast to MyInterface will not work!\n"));
+ − 886
#else
+ − 887
QSKIP("Only tested on linux/gcc", SkipAll);
+ − 888
#endif
+ − 889
}
+ − 890
+ − 891
void tst_Moc::os9Newline()
+ − 892
{
+ − 893
#if !defined(SKIP_NEWLINE_TEST)
+ − 894
const QMetaObject &mo = Os9Newlines::staticMetaObject;
+ − 895
QVERIFY(mo.indexOfSlot("testSlot()") != -1);
+ − 896
QFile f(srcify("os9-newlines.h"));
+ − 897
QVERIFY(f.open(QIODevice::ReadOnly)); // no QIODevice::Text!
+ − 898
QByteArray data = f.readAll();
+ − 899
f.close();
+ − 900
QVERIFY(!data.contains('\n'));
+ − 901
QVERIFY(data.contains('\r'));
+ − 902
#endif
+ − 903
}
+ − 904
+ − 905
void tst_Moc::winNewline()
+ − 906
{
+ − 907
#if !defined(SKIP_NEWLINE_TEST)
+ − 908
const QMetaObject &mo = WinNewlines::staticMetaObject;
+ − 909
QVERIFY(mo.indexOfSlot("testSlot()") != -1);
+ − 910
QFile f(srcify("win-newlines.h"));
+ − 911
QVERIFY(f.open(QIODevice::ReadOnly)); // no QIODevice::Text!
+ − 912
QByteArray data = f.readAll();
+ − 913
f.close();
+ − 914
for (int i = 0; i < data.count(); ++i) {
+ − 915
if (data.at(i) == QLatin1Char('\r')) {
+ − 916
QVERIFY(i < data.count() - 1);
+ − 917
++i;
+ − 918
QVERIFY(data.at(i) == '\n');
+ − 919
} else {
+ − 920
QVERIFY(data.at(i) != '\n');
+ − 921
}
+ − 922
}
+ − 923
#endif
+ − 924
}
+ − 925
+ − 926
void tst_Moc::escapesInStringLiterals()
+ − 927
{
+ − 928
const QMetaObject &mo = StringLiterals::staticMetaObject;
+ − 929
QCOMPARE(mo.classInfoCount(), 3);
+ − 930
+ − 931
int idx = mo.indexOfClassInfo("Test");
+ − 932
QVERIFY(idx != -1);
+ − 933
QMetaClassInfo info = mo.classInfo(idx);
+ − 934
QCOMPARE(QByteArray(info.value()),
+ − 935
QByteArray("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\x53"));
+ − 936
+ − 937
QVERIFY(idx != -1);
+ − 938
idx = mo.indexOfClassInfo("Test2");
+ − 939
info = mo.classInfo(idx);
+ − 940
QCOMPARE(QByteArray(info.value()),
+ − 941
QByteArray("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\123"));
+ − 942
+ − 943
QVERIFY(idx != -1);
+ − 944
idx = mo.indexOfClassInfo("Test3");
+ − 945
info = mo.classInfo(idx);
+ − 946
QCOMPARE(QByteArray(info.value()),
+ − 947
QByteArray("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\nb"));
+ − 948
}
+ − 949
+ − 950
void tst_Moc::frameworkSearchPath()
+ − 951
{
+ − 952
#ifdef MOC_CROSS_COMPILED
+ − 953
QSKIP("Not tested when cross-compiled", SkipAll);
+ − 954
#endif
+ − 955
#if defined(Q_OS_UNIX) && !defined(QT_NO_PROCESS)
+ − 956
QStringList args;
+ − 957
args << "-F" << srcify(".")
+ − 958
<< srcify("interface-from-framework.h")
+ − 959
;
+ − 960
+ − 961
QProcess proc;
+ − 962
proc.start("moc", args);
+ − 963
bool finished = proc.waitForFinished();
+ − 964
if (!finished)
+ − 965
qWarning("waitForFinished failed. QProcess error: %d", (int)proc.error());
+ − 966
QVERIFY(finished);
+ − 967
if (proc.exitCode() != 0) {
+ − 968
qDebug() << proc.readAllStandardError();
+ − 969
}
+ − 970
QCOMPARE(proc.exitCode(), 0);
+ − 971
QCOMPARE(proc.readAllStandardError(), QByteArray());
+ − 972
#else
+ − 973
QSKIP("Only tested/relevant on unixy platforms", SkipAll);
+ − 974
#endif
+ − 975
}
+ − 976
+ − 977
void tst_Moc::cstyleEnums()
+ − 978
{
+ − 979
const QMetaObject &obj = CStyleEnums::staticMetaObject;
+ − 980
QCOMPARE(obj.enumeratorCount(), 1);
+ − 981
QMetaEnum metaEnum = obj.enumerator(0);
+ − 982
QCOMPARE(metaEnum.name(), "Baz");
+ − 983
QCOMPARE(metaEnum.keyCount(), 2);
+ − 984
QCOMPARE(metaEnum.key(0), "Foo");
+ − 985
QCOMPARE(metaEnum.key(1), "Bar");
+ − 986
}
+ − 987
+ − 988
void tst_Moc::templateGtGt()
+ − 989
{
+ − 990
#ifdef MOC_CROSS_COMPILED
+ − 991
QSKIP("Not tested when cross-compiled", SkipAll);
+ − 992
#endif
+ − 993
#if defined(Q_OS_LINUX) && defined(Q_CC_GNU) && !defined(QT_NO_PROCESS)
+ − 994
QProcess proc;
+ − 995
proc.start("moc", QStringList(srcify("template-gtgt.h")));
+ − 996
QVERIFY(proc.waitForFinished());
+ − 997
QCOMPARE(proc.exitCode(), 0);
+ − 998
QByteArray mocOut = proc.readAllStandardOutput();
+ − 999
QVERIFY(!mocOut.isEmpty());
+ − 1000
QString mocWarning = QString::fromLocal8Bit(proc.readAllStandardError());
+ − 1001
QVERIFY(mocWarning.isEmpty());
+ − 1002
#else
+ − 1003
QSKIP("Only tested on linux/gcc", SkipAll);
+ − 1004
#endif
+ − 1005
}
+ − 1006
+ − 1007
void tst_Moc::defineMacroViaCmdline()
+ − 1008
{
+ − 1009
#if defined(Q_OS_LINUX) && defined(Q_CC_GNU) && !defined(QT_NO_PROCESS)
+ − 1010
QProcess proc;
+ − 1011
+ − 1012
QStringList args;
+ − 1013
args << "-DFOO";
+ − 1014
args << srcify("macro-on-cmdline.h");
+ − 1015
+ − 1016
proc.start("moc", args);
+ − 1017
QVERIFY(proc.waitForFinished());
+ − 1018
QCOMPARE(proc.exitCode(), 0);
+ − 1019
QCOMPARE(proc.readAllStandardError(), QByteArray());
+ − 1020
QByteArray mocOut = proc.readAllStandardOutput();
+ − 1021
QVERIFY(!mocOut.isEmpty());
+ − 1022
#else
+ − 1023
QSKIP("Only tested on linux/gcc", SkipAll);
+ − 1024
#endif
+ − 1025
}
+ − 1026
+ − 1027
void tst_Moc::invokable()
+ − 1028
{
+ − 1029
{
+ − 1030
const QMetaObject &mobj = InvokableBeforeReturnType::staticMetaObject;
+ − 1031
QCOMPARE(mobj.methodCount(), 5);
+ − 1032
QVERIFY(mobj.method(4).signature() == QByteArray("foo()"));
+ − 1033
}
+ − 1034
+ − 1035
{
+ − 1036
const QMetaObject &mobj = InvokableBeforeInline::staticMetaObject;
+ − 1037
QCOMPARE(mobj.methodCount(), 6);
+ − 1038
QVERIFY(mobj.method(4).signature() == QByteArray("foo()"));
+ − 1039
QVERIFY(mobj.method(5).signature() == QByteArray("bar()"));
+ − 1040
}
+ − 1041
}
+ − 1042
+ − 1043
void tst_Moc::singleFunctionKeywordSignalAndSlot()
+ − 1044
{
+ − 1045
{
+ − 1046
const QMetaObject &mobj = SingleFunctionKeywordBeforeReturnType::staticMetaObject;
+ − 1047
QCOMPARE(mobj.methodCount(), 6);
+ − 1048
QVERIFY(mobj.method(4).signature() == QByteArray("mySignal()"));
+ − 1049
QVERIFY(mobj.method(5).signature() == QByteArray("mySlot()"));
+ − 1050
}
+ − 1051
+ − 1052
{
+ − 1053
const QMetaObject &mobj = SingleFunctionKeywordBeforeInline::staticMetaObject;
+ − 1054
QCOMPARE(mobj.methodCount(), 6);
+ − 1055
QVERIFY(mobj.method(4).signature() == QByteArray("mySignal()"));
+ − 1056
QVERIFY(mobj.method(5).signature() == QByteArray("mySlot()"));
+ − 1057
}
+ − 1058
+ − 1059
{
+ − 1060
const QMetaObject &mobj = SingleFunctionKeywordAfterInline::staticMetaObject;
+ − 1061
QCOMPARE(mobj.methodCount(), 6);
+ − 1062
QVERIFY(mobj.method(4).signature() == QByteArray("mySignal()"));
+ − 1063
QVERIFY(mobj.method(5).signature() == QByteArray("mySlot()"));
+ − 1064
}
+ − 1065
}
+ − 1066
+ − 1067
#include "qprivateslots.h"
+ − 1068
+ − 1069
void tst_Moc::qprivateslots()
+ − 1070
{
+ − 1071
TestQPrivateSlots tst;
+ − 1072
const QMetaObject *mobj = tst.metaObject();
+ − 1073
QVERIFY(mobj->indexOfSlot("_q_privateslot()") != -1);
+ − 1074
QVERIFY(mobj->indexOfMethod("method1()") != -1); //tast204730
+ − 1075
}
+ − 1076
19
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 1077
class PrivatePropertyTest : public QObject
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 1078
{
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 1079
Q_OBJECT
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 1080
Q_PROPERTY(int foo READ foo WRITE setFoo);
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 1081
Q_PRIVATE_PROPERTY(d, int bar READ bar WRITE setBar);
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 1082
Q_PRIVATE_PROPERTY(PrivatePropertyTest::d, int plop READ plop WRITE setPlop);
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 1083
Q_PRIVATE_PROPERTY(PrivatePropertyTest::d_func(), int baz READ baz WRITE setBaz);
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 1084
class MyDPointer {
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 1085
public:
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 1086
MyDPointer() : mBar(0), mPlop(0) {}
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 1087
int bar() { return mBar ; }
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 1088
void setBar(int value) { mBar = value; }
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 1089
int plop() { return mPlop ; }
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 1090
void setPlop(int value) { mPlop = value; }
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 1091
int baz() { return mBaz ; }
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 1092
void setBaz(int value) { mBaz = value; }
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 1093
private:
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 1094
int mBar;
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 1095
int mPlop;
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 1096
int mBaz;
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 1097
};
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 1098
public:
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 1099
PrivatePropertyTest() : mFoo(0), d (new MyDPointer) {}
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 1100
int foo() { return mFoo ; }
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 1101
void setFoo(int value) { mFoo = value; }
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 1102
MyDPointer *d_func() {return d;}
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 1103
private:
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 1104
int mFoo;
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 1105
MyDPointer *d;
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 1106
};
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 1107
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 1108
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 1109
void tst_Moc::qprivateproperties()
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 1110
{
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 1111
PrivatePropertyTest test;
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 1112
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 1113
test.setProperty("foo", 1);
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 1114
QCOMPARE(test.property("foo"), qVariantFromValue(1));
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 1115
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 1116
test.setProperty("bar", 2);
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 1117
QCOMPARE(test.property("bar"), qVariantFromValue(2));
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 1118
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 1119
test.setProperty("plop", 3);
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 1120
QCOMPARE(test.property("plop"), qVariantFromValue(3));
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 1121
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 1122
test.setProperty("baz", 4);
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 1123
QCOMPARE(test.property("baz"), qVariantFromValue(4));
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 1124
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 1125
}
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 1126
0
+ − 1127
#include "task189996.h"
+ − 1128
+ − 1129
void InlineSlotsWithThrowDeclaration::c() throw() {}
+ − 1130
+ − 1131
void tst_Moc::inlineSlotsWithThrowDeclaration()
+ − 1132
{
+ − 1133
InlineSlotsWithThrowDeclaration tst;
+ − 1134
const QMetaObject *mobj = tst.metaObject();
+ − 1135
QVERIFY(mobj->indexOfSlot("a()") != -1);
+ − 1136
QVERIFY(mobj->indexOfSlot("b()") != -1);
+ − 1137
QVERIFY(mobj->indexOfSlot("c()") != -1);
+ − 1138
QVERIFY(mobj->indexOfSlot("d()") != -1);
+ − 1139
QVERIFY(mobj->indexOfSlot("e()") != -1);
+ − 1140
}
+ − 1141
+ − 1142
void tst_Moc::warnOnPropertyWithoutREAD()
+ − 1143
{
+ − 1144
#ifdef MOC_CROSS_COMPILED
+ − 1145
QSKIP("Not tested when cross-compiled", SkipAll);
+ − 1146
#endif
+ − 1147
#if defined(Q_OS_LINUX) && defined(Q_CC_GNU) && !defined(QT_NO_PROCESS)
+ − 1148
QProcess proc;
+ − 1149
proc.start("moc", QStringList(srcify("warn-on-property-without-read.h")));
+ − 1150
QVERIFY(proc.waitForFinished());
+ − 1151
QCOMPARE(proc.exitCode(), 0);
+ − 1152
QByteArray mocOut = proc.readAllStandardOutput();
+ − 1153
QVERIFY(!mocOut.isEmpty());
+ − 1154
QString mocWarning = QString::fromLocal8Bit(proc.readAllStandardError());
+ − 1155
QCOMPARE(mocWarning, QString(SRCDIR) +
+ − 1156
QString("/warn-on-property-without-read.h:46: Warning: Property declaration foo has no READ accessor function. The property will be invalid.\n"));
+ − 1157
#else
+ − 1158
QSKIP("Only tested on linux/gcc", SkipAll);
+ − 1159
#endif
+ − 1160
}
+ − 1161
+ − 1162
void tst_Moc::constructors()
+ − 1163
{
+ − 1164
const QMetaObject *mo = &CtorTestClass::staticMetaObject;
+ − 1165
QCOMPARE(mo->constructorCount(), 3);
+ − 1166
{
+ − 1167
QMetaMethod mm = mo->constructor(0);
+ − 1168
QCOMPARE(mm.access(), QMetaMethod::Public);
+ − 1169
QCOMPARE(mm.methodType(), QMetaMethod::Constructor);
+ − 1170
QCOMPARE(mm.signature(), "CtorTestClass(QObject*)");
+ − 1171
QCOMPARE(mm.typeName(), "");
+ − 1172
QList<QByteArray> paramNames = mm.parameterNames();
+ − 1173
QCOMPARE(paramNames.size(), 1);
+ − 1174
QCOMPARE(paramNames.at(0), QByteArray("parent"));
+ − 1175
QList<QByteArray> paramTypes = mm.parameterTypes();
+ − 1176
QCOMPARE(paramTypes.size(), 1);
+ − 1177
QCOMPARE(paramTypes.at(0), QByteArray("QObject*"));
+ − 1178
}
+ − 1179
{
+ − 1180
QMetaMethod mm = mo->constructor(1);
+ − 1181
QCOMPARE(mm.access(), QMetaMethod::Public);
+ − 1182
QCOMPARE(mm.methodType(), QMetaMethod::Constructor);
+ − 1183
QCOMPARE(mm.signature(), "CtorTestClass()");
+ − 1184
QCOMPARE(mm.typeName(), "");
+ − 1185
QCOMPARE(mm.parameterNames().size(), 0);
+ − 1186
QCOMPARE(mm.parameterTypes().size(), 0);
+ − 1187
}
+ − 1188
{
+ − 1189
QMetaMethod mm = mo->constructor(2);
+ − 1190
QCOMPARE(mm.access(), QMetaMethod::Public);
+ − 1191
QCOMPARE(mm.methodType(), QMetaMethod::Constructor);
+ − 1192
QCOMPARE(mm.signature(), "CtorTestClass(QString)");
+ − 1193
QCOMPARE(mm.typeName(), "");
+ − 1194
QList<QByteArray> paramNames = mm.parameterNames();
+ − 1195
QCOMPARE(paramNames.size(), 1);
+ − 1196
QCOMPARE(paramNames.at(0), QByteArray("str"));
+ − 1197
QList<QByteArray> paramTypes = mm.parameterTypes();
+ − 1198
QCOMPARE(paramTypes.size(), 1);
+ − 1199
QCOMPARE(paramTypes.at(0), QByteArray("QString"));
+ − 1200
}
+ − 1201
+ − 1202
QCOMPARE(mo->indexOfConstructor("CtorTestClass(QObject*)"), 0);
+ − 1203
QCOMPARE(mo->indexOfConstructor("CtorTestClass()"), 1);
+ − 1204
QCOMPARE(mo->indexOfConstructor("CtorTestClass(QString)"), 2);
+ − 1205
QCOMPARE(mo->indexOfConstructor("CtorTestClass2(QObject*)"), -1);
+ − 1206
QCOMPARE(mo->indexOfConstructor("CtorTestClass(float,float)"), -1);
+ − 1207
+ − 1208
QObject *o1 = mo->newInstance();
+ − 1209
QVERIFY(o1 != 0);
+ − 1210
QCOMPARE(o1->parent(), (QObject*)0);
+ − 1211
QVERIFY(qobject_cast<CtorTestClass*>(o1) != 0);
+ − 1212
+ − 1213
QObject *o2 = mo->newInstance(Q_ARG(QObject*, o1));
+ − 1214
QVERIFY(o2 != 0);
+ − 1215
QCOMPARE(o2->parent(), o1);
+ − 1216
+ − 1217
QString str = QString::fromLatin1("hello");
+ − 1218
QObject *o3 = mo->newInstance(Q_ARG(QString, str));
+ − 1219
QVERIFY(o3 != 0);
+ − 1220
QCOMPARE(qobject_cast<CtorTestClass*>(o3)->m_str, str);
+ − 1221
+ − 1222
{
+ − 1223
//explicit constructor
+ − 1224
QObject *o = QObject::staticMetaObject.newInstance();
+ − 1225
QVERIFY(o);
+ − 1226
delete o;
+ − 1227
}
+ − 1228
}
+ − 1229
+ − 1230
#include "task234909.h"
+ − 1231
+ − 1232
#include "task240368.h"
+ − 1233
+ − 1234
void tst_Moc::typenameWithUnsigned()
+ − 1235
{
+ − 1236
TypenameWithUnsigned tst;
+ − 1237
const QMetaObject *mobj = tst.metaObject();
+ − 1238
QVERIFY(mobj->indexOfSlot("a(uint)") != -1);
+ − 1239
QVERIFY(mobj->indexOfSlot("b(uint)") != -1);
+ − 1240
QVERIFY(mobj->indexOfSlot("c(uint*)") != -1);
+ − 1241
QVERIFY(mobj->indexOfSlot("d(uint*)") != -1);
+ − 1242
QVERIFY(mobj->indexOfSlot("e(uint&)") != -1);
+ − 1243
QVERIFY(mobj->indexOfSlot("f(uint&)") != -1);
+ − 1244
QVERIFY(mobj->indexOfSlot("g(unsigned1)") != -1);
+ − 1245
QVERIFY(mobj->indexOfSlot("h(unsigned1)") != -1);
+ − 1246
QVERIFY(mobj->indexOfSlot("i(uint,unsigned1)") != -1);
+ − 1247
QVERIFY(mobj->indexOfSlot("j(unsigned1,uint)") != -1);
+ − 1248
QVERIFY(mobj->indexOfSlot("k(unsignedQImage)") != -1);
+ − 1249
QVERIFY(mobj->indexOfSlot("l(unsignedQImage)") != -1);
+ − 1250
}
+ − 1251
+ − 1252
+ − 1253
void tst_Moc::warnOnVirtualSignal()
+ − 1254
{
+ − 1255
#ifdef MOC_CROSS_COMPILED
+ − 1256
QSKIP("Not tested when cross-compiled", SkipAll);
+ − 1257
#endif
+ − 1258
#if defined(Q_OS_LINUX) && defined(Q_CC_GNU) && !defined(QT_NO_PROCESS)
+ − 1259
QProcess proc;
+ − 1260
proc.start("moc", QStringList(srcify("pure-virtual-signals.h")));
+ − 1261
QVERIFY(proc.waitForFinished());
+ − 1262
QCOMPARE(proc.exitCode(), 0);
+ − 1263
QByteArray mocOut = proc.readAllStandardOutput();
+ − 1264
QVERIFY(!mocOut.isEmpty());
+ − 1265
QString mocWarning = QString::fromLocal8Bit(proc.readAllStandardError());
+ − 1266
QCOMPARE(mocWarning, QString(SRCDIR) + QString("/pure-virtual-signals.h:48: Warning: Signals cannot be declared virtual\n") +
+ − 1267
QString(SRCDIR) + QString("/pure-virtual-signals.h:50: Warning: Signals cannot be declared virtual\n"));
+ − 1268
#else
+ − 1269
QSKIP("Only tested on linux/gcc", SkipAll);
+ − 1270
#endif
+ − 1271
}
+ − 1272
3
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 1273
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 1274
class QTBUG5590_DummyObject: public QObject
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 1275
{
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 1276
Q_OBJECT
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 1277
Q_PROPERTY(bool dummy)
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 1278
};
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 1279
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 1280
class QTBUG5590_PropertyObject: public QTBUG5590_DummyObject
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 1281
{
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 1282
Q_OBJECT
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 1283
Q_PROPERTY(int value READ value WRITE setValue)
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 1284
Q_PROPERTY(int value2 READ value2 WRITE setValue2)
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 1285
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 1286
public:
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 1287
QTBUG5590_PropertyObject() : m_value(85), m_value2(40) { }
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 1288
int value() const { return m_value; }
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 1289
void setValue(int value) { m_value = value; }
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 1290
int value2() const { return m_value2; }
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 1291
void setValue2(int value) { m_value2 = value; }
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 1292
private:
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 1293
int m_value, m_value2;
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 1294
};
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 1295
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 1296
void tst_Moc::QTBUG5590_dummyProperty()
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 1297
{
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 1298
QTBUG5590_PropertyObject o;
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 1299
QCOMPARE(o.property("value").toInt(), 85);
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 1300
QCOMPARE(o.property("value2").toInt(), 40);
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 1301
o.setProperty("value", 32);
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 1302
QCOMPARE(o.value(), 32);
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 1303
o.setProperty("value2", 82);
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 1304
QCOMPARE(o.value2(), 82);
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 1305
}
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 1306
30
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 1307
class QTBUG7421_ReturnConstTemplate: public QObject
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 1308
{ Q_OBJECT
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 1309
public slots:
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 1310
const QList<int> returnConstTemplate1() { return QList<int>(); }
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 1311
QList<int> const returnConstTemplate2() { return QList<int>(); }
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 1312
const int returnConstInt() { return 0; }
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 1313
const QString returnConstString(const QString s) { return s; }
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 1314
QString const returnConstString2( QString const s) { return s; }
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 1315
};
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 1316
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 1317
class QTBUG9354_constInName: public QObject
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 1318
{ Q_OBJECT
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 1319
public slots:
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 1320
void slotChooseScientificConst0(struct science_constant const &) {};
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 1321
void foo(struct science_const const &) {};
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 1322
void foo(struct constconst const &) {};
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 1323
void foo(struct constconst *) {};
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 1324
void foo(struct const_ *) {};
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 1325
};
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 1326
33
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 1327
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 1328
template<typename T1, typename T2>
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 1329
class TestTemplate2
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 1330
{
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 1331
};
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 1332
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 1333
class QTBUG11647_constInTemplateParameter : public QObject
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 1334
{ Q_OBJECT
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 1335
public slots:
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 1336
void testSlot(TestTemplate2<const int, const short*>) {}
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 1337
void testSlot2(TestTemplate2<int, short const * const >) {}
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 1338
void testSlot3(TestTemplate2<TestTemplate2 < const int, const short* > const *,
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 1339
TestTemplate2< TestTemplate2 < void, int > , unsigned char *> > ) {}
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 1340
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 1341
signals:
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 1342
void testSignal(TestTemplate2<const int, const short*>);
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 1343
};
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 1344
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 1345
class QTBUG12260_defaultTemplate_Object : public QObject
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 1346
{ Q_OBJECT
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 1347
public slots:
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 1348
#if !(defined(Q_CC_GNU) && __GNUC__ == 4 && __GNUC_MINOR__ <= 3) || defined(Q_MOC_RUN)
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 1349
void doSomething(QHash<QString, QVariant> values = QHash<QString, QVariant>() ) { Q_UNUSED(values); }
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 1350
#else
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 1351
// we want to test the previous function, but gcc < 4.4 seemed to have a bug similar to the one moc has.
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 1352
typedef QHash<QString, QVariant> WorkaroundGCCBug;
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 1353
void doSomething(QHash<QString, QVariant> values = WorkaroundGCCBug() ) { Q_UNUSED(values); }
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 1354
#endif
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 1355
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 1356
void doAnotherThing(bool a = (1 < 3), bool b = (1 > 4)) { Q_UNUSED(a); Q_UNUSED(b); }
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 1357
};
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 1358
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 1359
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 1360
void tst_Moc::QTBUG12260_defaultTemplate()
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 1361
{
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 1362
QVERIFY(QTBUG12260_defaultTemplate_Object::staticMetaObject.indexOfSlot("doSomething(QHash<QString,QVariant>)") != -1);
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 1363
QVERIFY(QTBUG12260_defaultTemplate_Object::staticMetaObject.indexOfSlot("doAnotherThing(bool,bool)") != -1);
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 1364
}
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 1365
37
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 1366
void tst_Moc::notifyError()
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 1367
{
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 1368
#ifdef MOC_CROSS_COMPILED
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 1369
QSKIP("Not tested when cross-compiled", SkipAll);
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 1370
#endif
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 1371
#if defined(Q_OS_LINUX) && defined(Q_CC_GNU) && !defined(QT_NO_PROCESS)
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 1372
QProcess proc;
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 1373
proc.start("moc", QStringList(srcify("error-on-wrong-notify.h")));
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 1374
QVERIFY(proc.waitForFinished());
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 1375
QCOMPARE(proc.exitCode(), 1);
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 1376
QCOMPARE(proc.exitStatus(), QProcess::NormalExit);
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 1377
QByteArray mocOut = proc.readAllStandardOutput();
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 1378
QVERIFY(mocOut.isEmpty());
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 1379
QString mocError = QString::fromLocal8Bit(proc.readAllStandardError());
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 1380
QCOMPARE(mocError, QString(SRCDIR) +
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 1381
QString("/error-on-wrong-notify.h:52: Error: NOTIFY signal 'fooChanged' of property 'foo' does not exist in class ClassWithWrongNOTIFY.\n"));
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 1382
#else
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 1383
QSKIP("Only tested on linux/gcc", SkipAll);
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 1384
#endif
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 1385
}
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 1386
33
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
diff
changeset
+ − 1387
0
+ − 1388
QTEST_APPLESS_MAIN(tst_Moc)
+ − 1389
#include "tst_moc.moc"
+ − 1390
+ − 1391
+ − 1392