diff options
author | Michael Brasser <michael.brasser@nokia.com> | 2009-08-25 23:06:36 (GMT) |
---|---|---|
committer | Michael Brasser <michael.brasser@nokia.com> | 2009-08-25 23:06:36 (GMT) |
commit | 8484fc497f9d02b708cb23adb8ab6102d63a7753 (patch) | |
tree | eb6aacda7fda551bcfbcfd6b0d192b2389bd094e /tests/auto | |
parent | 314c6ec54e4cb4e2ec936ada7e0a112a60b87832 (diff) | |
parent | 1470504e15662acf37bacc58359527f88efc43ab (diff) | |
download | Qt-8484fc497f9d02b708cb23adb8ab6102d63a7753.zip Qt-8484fc497f9d02b708cb23adb8ab6102d63a7753.tar.gz Qt-8484fc497f9d02b708cb23adb8ab6102d63a7753.tar.bz2 |
Merge branch '4.6' of git@scm.dev.nokia.troll.no:qt/qt into kinetic-declarativeui
Conflicts:
configure
configure.exe
mkspecs/features/qt.prf
tools/configure/configureapp.cpp
Diffstat (limited to 'tests/auto')
408 files changed, 18963 insertions, 3602 deletions
diff --git a/tests/auto/auto.pro b/tests/auto/auto.pro index eae873d..e8add04 100644 --- a/tests/auto/auto.pro +++ b/tests/auto/auto.pro @@ -1,3 +1,4 @@ +QT = core TEMPLATE = subdirs # Directories @@ -7,7 +8,7 @@ TEMPLATE = subdirs SUBDIRS += \ bic \ collections \ - compile \ + compiler \ compilerwarnings \ exceptionsafety \ linguist \ @@ -71,6 +72,8 @@ SUBDIRS += \ qabstractsocket \ qabstractspinbox \ qabstracttextdocumentlayout \ + qabstractvideobuffer \ + qabstractvideosurface \ qaccessibility \ qaction \ qactiongroup \ @@ -134,9 +137,12 @@ SUBDIRS += \ qgetputenv \ qgl \ qglobal \ + qgraphicseffect \ + qgraphicseffectsource \ qgraphicsgridlayout \ qgraphicsitem \ qgraphicsitemanimation \ + qgraphicsanchorlayout \ qgraphicslayout \ qgraphicslayoutitem \ qgraphicslinearlayout \ @@ -178,7 +184,6 @@ SUBDIRS += \ qitemmodel \ qitemselectionmodel \ qitemview \ - qkeyevent \ qkeysequence \ qlabel \ qlayout \ @@ -252,19 +257,7 @@ SUBDIRS += \ qregion \ qresourceengine \ qringbuffer \ - qscriptable \ - qscriptclass \ - qscriptcontext \ - qscriptcontextinfo \ - qscriptengine \ - qscriptengineagent \ - qscriptextqobject \ - qscriptjstestsuite \ - qscriptv8testsuite \ - qscriptstring \ - qscriptvalue \ - qscriptvalueiterator \ - qscriptenginedebugger \ + qscopedpointer \ qscrollarea \ qsemaphore \ qsharedpointer \ @@ -312,7 +305,10 @@ SUBDIRS += \ qstatusbar \ qstl \ qstring \ - qstringbuilder \ + qstringbuilder1 \ + qstringbuilder2 \ + qstringbuilder3 \ + qstringbuilder4 \ qstringmatcher \ qstringlist \ qstringlistmodel \ @@ -374,6 +370,8 @@ SUBDIRS += \ qvariant \ qvarlengtharray \ qvector \ + qvideoframe \ + qvideosurfaceformat \ qvectornd \ qwaitcondition \ qwidget \ @@ -473,6 +471,21 @@ unix:!embedded:contains(QT_CONFIG, dbus):SUBDIRS += \ qdbusthreading \ qdbusxmlparser +contains(QT_CONFIG, script): SUBDIRS += \ + qscriptable \ + qscriptclass \ + qscriptcontext \ + qscriptcontextinfo \ + qscriptengine \ + qscriptengineagent \ + qscriptextqobject \ + qscriptjstestsuite \ + qscriptv8testsuite \ + qscriptstring \ + qscriptvalue \ + qscriptvalueiterator \ + qscriptenginedebugger + contains(QT_CONFIG, webkit): SUBDIRS += \ qwebframe \ qwebpage \ diff --git a/tests/auto/checkxmlfiles/checkxmlfiles.pro b/tests/auto/checkxmlfiles/checkxmlfiles.pro index 96985c9..c368c02 100644 --- a/tests/auto/checkxmlfiles/checkxmlfiles.pro +++ b/tests/auto/checkxmlfiles/checkxmlfiles.pro @@ -6,7 +6,7 @@ QT -= gui include (../xmlpatterns.pri) -wince*: { +wince*|symbian*: { QT += network addFiles.sources = \ $$QT_SOURCE_TREE/examples/sql/masterdetail/albumdetails.xml \ diff --git a/tests/auto/collections/collections.pro b/tests/auto/collections/collections.pro index f47c2eb..876e903 100644 --- a/tests/auto/collections/collections.pro +++ b/tests/auto/collections/collections.pro @@ -1,7 +1,3 @@ load(qttest_p4) SOURCES += tst_collections.cpp - - QT = core - - diff --git a/tests/auto/collections/tst_collections.cpp b/tests/auto/collections/tst_collections.cpp index ebe7d94..675eabb 100644 --- a/tests/auto/collections/tst_collections.cpp +++ b/tests/auto/collections/tst_collections.cpp @@ -992,7 +992,7 @@ void tst_Collections::linkedList() QVERIFY(*(list.begin() + 2) == "alpha"); QVERIFY(*(list.begin() + 3) == "beta"); } - + { QLinkedList<int> a; QCOMPARE(a.startsWith(1), false); @@ -1364,6 +1364,9 @@ void tst_Collections::byteArray() ba1 = "FooFoo"; ba1.replace(char('F'), ba1); QCOMPARE(ba1, QByteArray("FooFooooFooFoooo")); + ba1 = "FooFoo"; + ba1.replace(char('o'), ba1); + QCOMPARE(ba1, QByteArray("FFooFooFooFooFFooFooFooFoo")); ba1.replace(ba1, "xxx"); QCOMPARE(ba1, QByteArray("xxx")); @@ -2354,6 +2357,9 @@ void tst_Collections::qstring() str1 = "FooFoo"; str1.replace(char('F'), str1); QCOMPARE(str1, QString("FooFooooFooFoooo")); + str1 = "FooFoo"; + str1.replace(char('o'), str1); + QCOMPARE(str1, QString("FFooFooFooFooFFooFooFooFoo")); str1 = "Foo"; str1.replace("Foo", str1); @@ -3447,7 +3453,7 @@ class Key1 class T1 {}; class T2 -}; +{}; #else class Key1; class T1; @@ -3462,7 +3468,11 @@ void tst_Collections::forwardDeclared() { typedef QMap<Key1, T1> C; C *x = 0; C::iterator i; C::const_iterator j; Q_UNUSED(x) } { typedef QMultiMap<Key1, T1> C; C *x = 0; C::iterator i; C::const_iterator j; Q_UNUSED(x) } #endif +#if !defined(Q_CC_RVCT) + // RVCT can't handle forward declared template parameters if those are used to declare + // class members inside templated class. { typedef QPair<T1, T2> C; C *x = 0; Q_UNUSED(x) } +#endif { typedef QList<T1> C; C *x = 0; C::iterator i; C::const_iterator j; Q_UNUSED(x) } { typedef QLinkedList<T1> C; C *x = 0; C::iterator i; C::const_iterator j; Q_UNUSED(x) } { typedef QVector<T1> C; C *x = 0; C::iterator i; C::const_iterator j; Q_UNUSED(x) Q_UNUSED(i) Q_UNUSED(j) } diff --git a/tests/auto/compile/.gitignore b/tests/auto/compiler/.gitignore index bdcee46..bdcee46 100644 --- a/tests/auto/compile/.gitignore +++ b/tests/auto/compiler/.gitignore diff --git a/tests/auto/compile/baseclass.cpp b/tests/auto/compiler/baseclass.cpp index 5479532..5479532 100644 --- a/tests/auto/compile/baseclass.cpp +++ b/tests/auto/compiler/baseclass.cpp diff --git a/tests/auto/compile/baseclass.h b/tests/auto/compiler/baseclass.h index 25abbfe..25abbfe 100644 --- a/tests/auto/compile/baseclass.h +++ b/tests/auto/compiler/baseclass.h diff --git a/tests/auto/compile/compile.pro b/tests/auto/compiler/compiler.pro index 6c38078..c444c63 100644 --- a/tests/auto/compile/compile.pro +++ b/tests/auto/compiler/compiler.pro @@ -1,5 +1,5 @@ load(qttest_p4) -SOURCES += tst_compile.cpp baseclass.cpp derivedclass.cpp +SOURCES += tst_compiler.cpp baseclass.cpp derivedclass.cpp HEADERS += baseclass.h derivedclass.h QT = core diff --git a/tests/auto/compile/derivedclass.cpp b/tests/auto/compiler/derivedclass.cpp index 3b71861..3b71861 100644 --- a/tests/auto/compile/derivedclass.cpp +++ b/tests/auto/compiler/derivedclass.cpp diff --git a/tests/auto/compile/derivedclass.h b/tests/auto/compiler/derivedclass.h index 9396ff9..9396ff9 100644 --- a/tests/auto/compile/derivedclass.h +++ b/tests/auto/compiler/derivedclass.h diff --git a/tests/auto/compile/tst_compile.cpp b/tests/auto/compiler/tst_compiler.cpp index cef798a..78c1a56 100644 --- a/tests/auto/compile/tst_compile.cpp +++ b/tests/auto/compiler/tst_compiler.cpp @@ -653,4 +653,4 @@ void tst_Compiler::staticConstUnionWithInitializerList() const } QTEST_MAIN(tst_Compiler) -#include "tst_compile.moc" +#include "tst_compiler.moc" diff --git a/tests/auto/compilerwarnings/compilerwarnings.pro b/tests/auto/compilerwarnings/compilerwarnings.pro index 9e16c5e..beb0279 100644 --- a/tests/auto/compilerwarnings/compilerwarnings.pro +++ b/tests/auto/compilerwarnings/compilerwarnings.pro @@ -1,5 +1,4 @@ load(qttest_p4) SOURCES += tst_compilerwarnings.cpp QT = core - RESOURCES = compilerwarnings.qrc diff --git a/tests/auto/exceptionsafety/exceptionsafety.pro b/tests/auto/exceptionsafety/exceptionsafety.pro index 23b8f73..d162219 100644 --- a/tests/auto/exceptionsafety/exceptionsafety.pro +++ b/tests/auto/exceptionsafety/exceptionsafety.pro @@ -1,3 +1,3 @@ load(qttest_p4) -QT -= gui SOURCES += tst_exceptionsafety.cpp +QT = core diff --git a/tests/auto/exceptionsafety/tst_exceptionsafety.cpp b/tests/auto/exceptionsafety/tst_exceptionsafety.cpp index a598146..37fdf84 100644 --- a/tests/auto/exceptionsafety/tst_exceptionsafety.cpp +++ b/tests/auto/exceptionsafety/tst_exceptionsafety.cpp @@ -52,9 +52,16 @@ class tst_ExceptionSafety: public QObject Q_OBJECT private slots: void exceptionInSlot(); + void exceptionVector(); + void exceptionHash(); + void exceptionMap(); + void exceptionList(); + void exceptionLinkedList(); +// void exceptionEventLoop(); +// void exceptionSignalSlot(); }; -class Emitter: public QObject +class Emitter : public QObject { Q_OBJECT public: @@ -63,13 +70,111 @@ signals: void testSignal(); }; -class ExceptionThrower: public QObject +class ExceptionThrower : public QObject { Q_OBJECT public slots: void thrower() { throw 5; } }; +class Receiver : public QObject +{ + Q_OBJECT +public: + Receiver() + : received(0) {} + int received; + +public slots: + void receiver() { ++received; } +}; + +enum ThrowType { ThrowNot = 0, ThrowAtCreate = 1, ThrowAtCopy = 2, ThrowLater = 3, ThrowAtComparison = 4 }; + +ThrowType throwType = ThrowNot; // global flag to indicate when an exception should be throw. Will be reset when the exception has been generated. + +int objCounter = 0; + +/*! Class that does not throw any exceptions. Used as baseclass for all the other ones. + */ +template <int T> +class FlexibleThrower +{ + public: + FlexibleThrower() : _value(-1) { + if( throwType == ThrowAtCreate ) { + throwType = ThrowNot; + throw ThrowAtCreate; + } + objCounter++; + } + + FlexibleThrower( short value ) : _value(value) { + if( throwType == ThrowAtCreate ) { + throwType = ThrowNot; + throw ThrowAtCreate; + } + objCounter++; + } + + FlexibleThrower(FlexibleThrower const& other ) { + // qDebug("cc"); + + if( throwType == ThrowAtCopy ) { + throwType = ThrowNot; + throw ThrowAtCopy; + + } else if( throwType == ThrowLater ) { + throwType = ThrowAtCopy; + } + + objCounter++; + _value = other.value(); + } + + ~FlexibleThrower() { objCounter--; } + + bool operator==(const FlexibleThrower<T> &t) const + { + // qDebug("vv == %d %d", value(), t.value()); + if( throwType == ThrowAtComparison ) { + throwType = ThrowNot; + throw ThrowAtComparison; + } + return value()==t.value(); + } + + bool operator<(const FlexibleThrower<T> &t) const + { + // qDebug("vv < %d %d", value(), t.value()); + if( throwType == ThrowAtComparison ) { + throwType = ThrowNot; + throw ThrowAtComparison; + } + return value()<t.value(); + } + + int value() const + { return (int)_value; } + + short _value; + char dummy[T]; +}; + +uint qHash(const FlexibleThrower<2>& t) +{ + // qDebug("ha"); + if( throwType == ThrowAtComparison ) { + throwType = ThrowNot; + throw ThrowAtComparison; + } + return (uint)t.value(); +} + +typedef FlexibleThrower<2> FlexibleThrowerSmall; +typedef QMap<FlexibleThrowerSmall,FlexibleThrowerSmall> MyMap; +typedef QHash<FlexibleThrowerSmall,FlexibleThrowerSmall> MyHash; + // connect a signal to a slot that throws an exception // run this through valgrind to make sure it doesn't corrupt void tst_ExceptionSafety::exceptionInSlot() @@ -86,6 +191,537 @@ void tst_ExceptionSafety::exceptionInSlot() } } +void tst_ExceptionSafety::exceptionList() { + + { + QList<FlexibleThrowerSmall> list; + QList<FlexibleThrowerSmall> list2; + QList<FlexibleThrowerSmall> list3; + + for( int i = 0; i<10; i++ ) + list.append( FlexibleThrowerSmall(i) ); + + try { + throwType = ThrowAtCopy; + list.append( FlexibleThrowerSmall(10)); + } catch (...) { + } + QCOMPARE( list.size(), 10 ); + + try { + throwType = ThrowAtCopy; + list.prepend( FlexibleThrowerSmall(10)); + } catch (...) { + } + QCOMPARE( list.at(0).value(), 0 ); + QCOMPARE( list.size(), 10 ); + + try { + throwType = ThrowAtCopy; + list.insert( 8, FlexibleThrowerSmall(10)); + } catch (...) { + } + QCOMPARE( list.at(7).value(), 7 ); + QCOMPARE( list.at(8).value(), 8 ); + QCOMPARE( list.size(), 10 ); + + try { + throwType = ThrowAtCopy; + FlexibleThrowerSmall t = list.takeAt( 6 ); + } catch (...) { + } + QCOMPARE( list.at(6).value(), 6 ); + QCOMPARE( list.at(7).value(), 7 ); + QCOMPARE( list.size(), 10 ); + + try { + throwType = ThrowAtCopy; + list3 = list; + } catch (...) { + } + QCOMPARE( list.at(0).value(), 0 ); + QCOMPARE( list.at(7).value(), 7 ); + QCOMPARE( list.size(), 10 ); + QCOMPARE( list3.at(0).value(), 0 ); + QCOMPARE( list3.at(7).value(), 7 ); + QCOMPARE( list3.size(), 10 ); + + try { + throwType = ThrowAtCopy; + list3.append( FlexibleThrowerSmall(11) ); + } catch (...) { + } + QCOMPARE( list.at(0).value(), 0 ); + QCOMPARE( list.at(7).value(), 7 ); + QCOMPARE( list.size(), 10 ); + QCOMPARE( list3.at(0).value(), 0 ); + QCOMPARE( list3.at(7).value(), 7 ); + QCOMPARE( list3.size(), 10 ); + + try { + list2.clear(); + list2.append( FlexibleThrowerSmall(11)); + throwType = ThrowAtCopy; + list3 = list+list2; + } catch (...) { + } + QCOMPARE( list.at(0).value(), 0 ); + QCOMPARE( list.at(7).value(), 7 ); + QCOMPARE( list.size(), 10 ); + + // check that copy on write works atomar + list2.clear(); + list2.append( FlexibleThrowerSmall(11)); + list3 = list+list2; + try { + throwType = ThrowAtCreate; + list3[7]=FlexibleThrowerSmall(12); + } catch (...) { + } + QCOMPARE( list.at(7).value(), 7 ); + QCOMPARE( list.size(), 10 ); + QCOMPARE( list3.at(7).value(), 7 ); + QCOMPARE( list3.size(), 11 ); + + } + QCOMPARE(objCounter, 0 ); // check that every object has been freed +} + +void tst_ExceptionSafety::exceptionLinkedList() { + + { + QLinkedList<FlexibleThrowerSmall> list; + QLinkedList<FlexibleThrowerSmall> list2; + QLinkedList<FlexibleThrowerSmall> list3; + + for( int i = 0; i<10; i++ ) + list.append( FlexibleThrowerSmall(i) ); + + try { + throwType = ThrowAtCopy; + list.append( FlexibleThrowerSmall(10)); + } catch (...) { + } + QCOMPARE( list.size(), 10 ); + + try { + throwType = ThrowAtCopy; + list.prepend( FlexibleThrowerSmall(10)); + } catch (...) { + } + QCOMPARE( list.first().value(), 0 ); + QCOMPARE( list.size(), 10 ); + + try { + throwType = ThrowAtCopy; + list3 = list; + list3.append( FlexibleThrowerSmall(11) ); + } catch (...) { + } + QCOMPARE( list.first().value(), 0 ); + QCOMPARE( list.size(), 10 ); + QCOMPARE( list3.size(), 10 ); + } + QCOMPARE(objCounter, 0 ); // check that every object has been freed +} + +void tst_ExceptionSafety::exceptionVector() { + + { + QVector<FlexibleThrowerSmall> vector; + QVector<FlexibleThrowerSmall> vector2; + QVector<FlexibleThrowerSmall> vector3; + + for (int i = 0; i<10; i++) + vector.append( FlexibleThrowerSmall(i) ); + + try { + throwType = ThrowAtCopy; + vector.append( FlexibleThrowerSmall(10)); + } catch (...) { + } + QCOMPARE( vector.size(), 10 ); + + try { + throwType = ThrowAtCopy; + vector.prepend( FlexibleThrowerSmall(10)); + } catch (...) { + } + QCOMPARE( vector.at(0).value(), 0 ); + QCOMPARE( vector.size(), 10 ); + + try { + throwType = ThrowAtCopy; + vector.insert( 8, FlexibleThrowerSmall(10)); + } catch (...) { + } + QCOMPARE( vector.at(7).value(), 7 ); + QCOMPARE( vector.at(8).value(), 8 ); + QCOMPARE( vector.size(), 10 ); + + try { + throwType = ThrowAtCopy; + vector3 = vector; + } catch (...) { + } + QCOMPARE( vector.at(0).value(), 0 ); + QCOMPARE( vector.at(7).value(), 7 ); + QCOMPARE( vector.size(), 10 ); + QCOMPARE( vector3.at(0).value(), 0 ); + QCOMPARE( vector3.at(7).value(), 7 ); + QCOMPARE( vector3.size(), 10 ); + + try { + throwType = ThrowAtCopy; + vector3.append( FlexibleThrowerSmall(11) ); + } catch (...) { + } + QCOMPARE( vector.at(0).value(), 0 ); + QCOMPARE( vector.at(7).value(), 7 ); + QCOMPARE( vector.size(), 10 ); + QCOMPARE( vector3.at(0).value(), 0 ); + QCOMPARE( vector3.at(7).value(), 7 ); + + try { + vector2.clear(); + vector2.append( FlexibleThrowerSmall(11)); + throwType = ThrowAtCopy; + vector3 = vector+vector2; + } catch (...) { + } + QCOMPARE( vector.at(0).value(), 0 ); + QCOMPARE( vector.at(7).value(), 7 ); + QCOMPARE( vector.size(), 10 ); + + // check that copy on write works atomar + vector2.clear(); + vector2.append( FlexibleThrowerSmall(11)); + vector3 = vector+vector2; + try { + throwType = ThrowAtCreate; + vector3[7]=FlexibleThrowerSmall(12); + } catch (...) { + } + QCOMPARE( vector.at(7).value(), 7 ); + QCOMPARE( vector.size(), 10 ); + QCOMPARE( vector3.at(7).value(), 7 ); + QCOMPARE( vector3.size(), 11 ); + + try { + throwType = ThrowAtCreate; + vector.resize(15); + } catch (...) { + } + QCOMPARE( vector.at(7).value(), 7 ); + QCOMPARE( vector.size(), 10 ); + + try { + throwType = ThrowAtCreate; + vector.resize(15); + } catch (...) { + } + QCOMPARE( vector.at(7).value(), 7 ); + QCOMPARE( vector.size(), 10 ); + + try { + throwType = ThrowLater; + vector.fill(FlexibleThrowerSmall(1), 15); + } catch (...) { + } + QCOMPARE( vector.at(0).value(), 0 ); + QCOMPARE( vector.size(), 10 ); + + + } + QCOMPARE(objCounter, 0 ); // check that every object has been freed +} + + +void tst_ExceptionSafety::exceptionMap() { + + { + MyMap map; + MyMap map2; + MyMap map3; + + throwType = ThrowNot; + for (int i = 0; i<10; i++) + map[ FlexibleThrowerSmall(i) ] = FlexibleThrowerSmall(i); + + return; // further test are deactivated until Map is fixed. + + for( int i = ThrowAtCopy; i<=ThrowAtComparison; i++ ) { + try { + throwType = (ThrowType)i; + map[ FlexibleThrowerSmall(10) ] = FlexibleThrowerSmall(10); + } catch(...) { + } + QCOMPARE( map.size(), 10 ); + QCOMPARE( map[ FlexibleThrowerSmall(1) ], FlexibleThrowerSmall(1) ); + } + + map2 = map; + try { + throwType = ThrowLater; + map2[ FlexibleThrowerSmall(10) ] = FlexibleThrowerSmall(10); + } catch(...) { + } + /* qDebug("%d %d", map.size(), map2.size() ); + for( int i=0; i<map.size(); i++ ) + qDebug( "Value at %d: %d",i, map.value(FlexibleThrowerSmall(i), FlexibleThrowerSmall()).value() ); + QCOMPARE( map.value(FlexibleThrowerSmall(1), FlexibleThrowerSmall()), FlexibleThrowerSmall(1) ); + qDebug( "Value at %d: %d",1, map[FlexibleThrowerSmall(1)].value() ); + qDebug("%d %d", map.size(), map2.size() ); + */ + QCOMPARE( map[ FlexibleThrowerSmall(1) ], FlexibleThrowerSmall(1) ); + QCOMPARE( map.size(), 10 ); + QCOMPARE( map2[ FlexibleThrowerSmall(1) ], FlexibleThrowerSmall(1) ); + QCOMPARE( map2.size(), 10 ); + + } + QCOMPARE(objCounter, 0 ); // check that every object has been freed +} + +void tst_ExceptionSafety::exceptionHash() { + + { + MyHash hash; + MyHash hash2; + MyHash hash3; + + for( int i = 0; i<10; i++ ) + hash[ FlexibleThrowerSmall(i) ] = FlexibleThrowerSmall(i); + + for( int i = ThrowAtCopy; i<=ThrowAtComparison; i++ ) { + try { + throwType = (ThrowType)i; + hash[ FlexibleThrowerSmall(10) ] = FlexibleThrowerSmall(10); + } catch(...) { + } + QCOMPARE( hash.size(), 10 ); + } + + hash2 = hash; + try { + throwType = ThrowLater; + hash2[ FlexibleThrowerSmall(10) ] = FlexibleThrowerSmall(10); + } catch(...) { + } + QCOMPARE( hash[ FlexibleThrowerSmall(1) ], FlexibleThrowerSmall(1) ); + QCOMPARE( hash.size(), 10 ); + QCOMPARE( hash2[ FlexibleThrowerSmall(1) ], FlexibleThrowerSmall(1) ); + QCOMPARE( hash2.size(), 10 ); + + hash2.clear(); + try { + throwType = ThrowLater; + hash2.reserve(30); + } catch(...) { + } + QCOMPARE( hash2.size(), 0 ); + + /* + try { + throwType = ThrowAtCopy; + hash.prepend( FlexibleThrowerSmall(10)); + } catch (...) { + } + QCOMPARE( hash.at(0).value(), 0 ); + QCOMPARE( hash.size(), 10 ); + + try { + throwType = ThrowAtCopy; + hash.insert( 8, FlexibleThrowerSmall(10)); + } catch (...) { + } + QCOMPARE( hash.at(7).value(), 7 ); + QCOMPARE( hash.at(8).value(), 8 ); + QCOMPARE( hash.size(), 10 ); + + qDebug("val"); + try { + throwType = ThrowAtCopy; + hash3 = hash; + } catch (...) { + } + QCOMPARE( hash.at(0).value(), 0 ); + QCOMPARE( hash.at(7).value(), 7 ); + QCOMPARE( hash.size(), 10 ); + QCOMPARE( hash3.at(0).value(), 0 ); + QCOMPARE( hash3.at(7).value(), 7 ); + QCOMPARE( hash3.size(), 10 ); + + try { + throwType = ThrowAtCopy; + hash3.append( FlexibleThrowerSmall(11) ); + } catch (...) { + } + QCOMPARE( hash.at(0).value(), 0 ); + QCOMPARE( hash.at(7).value(), 7 ); + QCOMPARE( hash.size(), 10 ); + QCOMPARE( hash3.at(0).value(), 0 ); + QCOMPARE( hash3.at(7).value(), 7 ); + QCOMPARE( hash3.at(11).value(), 11 ); + + try { + hash2.clear(); + hash2.append( FlexibleThrowerSmall(11)); + throwType = ThrowAtCopy; + hash3 = hash+hash2; + } catch (...) { + } + QCOMPARE( hash.at(0).value(), 0 ); + QCOMPARE( hash.at(7).value(), 7 ); + QCOMPARE( hash.size(), 10 ); + + // check that copy on write works atomar + hash2.clear(); + hash2.append( FlexibleThrowerSmall(11)); + hash3 = hash+hash2; + try { + throwType = ThrowAtCopy; + hash3[7]=FlexibleThrowerSmall(12); + } catch (...) { + } + QCOMPARE( hash.at(7).value(), 7 ); + QCOMPARE( hash.size(), 10 ); + QCOMPARE( hash3.at(7).value(), 7 ); + QCOMPARE( hash3.size(), 11 ); + */ + + + } + QCOMPARE(objCounter, 0 ); // check that every object has been freed +} + +// Disable these tests until the level of exception safety in event loops is clear +#if 0 +enum +{ + ThrowEventId = QEvent::User + 42, + NoThrowEventId = QEvent::User + 43 +}; + +class ThrowEvent : public QEvent +{ +public: + ThrowEvent() + : QEvent(static_cast<QEvent::Type>(ThrowEventId)) + { + } +}; + +class NoThrowEvent : public QEvent +{ +public: + NoThrowEvent() + : QEvent(static_cast<QEvent::Type>(NoThrowEventId)) + {} +}; + +struct IntEx : public std::exception +{ + IntEx(int aEx) : ex(aEx) {} + int ex; +}; + +class TestObject : public QObject +{ +public: + TestObject() + : throwEventCount(0), noThrowEventCount(0) {} + + int throwEventCount; + int noThrowEventCount; + +protected: + bool event(QEvent *event) + { + if (int(event->type()) == ThrowEventId) { + throw IntEx(++throwEventCount); + } else if (int(event->type()) == NoThrowEventId) { + ++noThrowEventCount; + } + return QObject::event(event); + } +}; + +void tst_ExceptionSafety::exceptionEventLoop() +{ + // send an event that throws + TestObject obj; + ThrowEvent throwEvent; + try { + qApp->sendEvent(&obj, &throwEvent); + } catch (IntEx code) { + QCOMPARE(code.ex, 1); + } + QCOMPARE(obj.throwEventCount, 1); + + // post an event that throws + qApp->postEvent(&obj, new ThrowEvent); + + try { + qApp->processEvents(); + } catch (IntEx code) { + QCOMPARE(code.ex, 2); + } + QCOMPARE(obj.throwEventCount, 2); + + // post a normal event, then a throwing event, then a normal event + // run this in valgrind to ensure that it doesn't leak. + + qApp->postEvent(&obj, new NoThrowEvent); + qApp->postEvent(&obj, new ThrowEvent); + qApp->postEvent(&obj, new NoThrowEvent); + + try { + qApp->processEvents(); + } catch (IntEx code) { + QCOMPARE(code.ex, 3); + } + // here, we should have received on non-throwing event and one throwing one + QCOMPARE(obj.throwEventCount, 3); +#ifndef __SYMBIAN32__ + // symbian event loops will have absorbed the exceptions + QCOMPARE(obj.noThrowEventCount, 1); +#endif + + // spin the event loop again + qApp->processEvents(); + + // now, we should have received the second non-throwing event + QCOMPARE(obj.noThrowEventCount, 2); +} + +void tst_ExceptionSafety::exceptionSignalSlot() +{ + Emitter e; + ExceptionThrower thrower; + Receiver r1; + Receiver r2; + + // connect a signal to a normal object, a thrower and a normal object again + connect(&e, SIGNAL(testSignal()), &r1, SLOT(receiver())); + connect(&e, SIGNAL(testSignal()), &thrower, SLOT(thrower())); + connect(&e, SIGNAL(testSignal()), &r2, SLOT(receiver())); + + int code = 0; + try { + e.emitTestSignal(); + } catch (int c) { + code = c; + } + + // 5 is the magic number that's thrown by thrower + QCOMPARE(code, 5); + + // assumption: slots are called in the connection order + QCOMPARE(r1.received, 1); + QCOMPARE(r2.received, 0); +} +#endif + QTEST_MAIN(tst_ExceptionSafety) #include "tst_exceptionsafety.moc" #endif // QT_NO_EXCEPTIONS diff --git a/tests/auto/exceptionsafety_objects/3rdparty/memcheck.h b/tests/auto/exceptionsafety_objects/3rdparty/memcheck.h new file mode 100644 index 0000000..72a02ca --- /dev/null +++ b/tests/auto/exceptionsafety_objects/3rdparty/memcheck.h @@ -0,0 +1,319 @@ + +/* + ---------------------------------------------------------------- + + Notice that the following BSD-style license applies to this one + file (memcheck.h) only. The rest of Valgrind is licensed under the + terms of the GNU General Public License, version 2, unless + otherwise indicated. See the COPYING file in the source + distribution for details. + + ---------------------------------------------------------------- + + This file is part of MemCheck, a heavyweight Valgrind tool for + detecting memory errors. + + Copyright (C) 2000-2008 Julian Seward. All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + 2. The origin of this software must not be misrepresented; you must + not claim that you wrote the original software. If you use this + software in a product, an acknowledgment in the product + documentation would be appreciated but is not required. + + 3. Altered source versions must be plainly marked as such, and must + not be misrepresented as being the original software. + + 4. The name of the author may not be used to endorse or promote + products derived from this software without specific prior written + permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS + OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + ---------------------------------------------------------------- + + Notice that the above BSD-style license applies to this one file + (memcheck.h) only. The entire rest of Valgrind is licensed under + the terms of the GNU General Public License, version 2. See the + COPYING file in the source distribution for details. + + ---------------------------------------------------------------- +*/ + + +#ifndef __MEMCHECK_H +#define __MEMCHECK_H + + +/* This file is for inclusion into client (your!) code. + + You can use these macros to manipulate and query memory permissions + inside your own programs. + + See comment near the top of valgrind.h on how to use them. +*/ + +#include "valgrind.h" + +/* !! ABIWARNING !! ABIWARNING !! ABIWARNING !! ABIWARNING !! + This enum comprises an ABI exported by Valgrind to programs + which use client requests. DO NOT CHANGE THE ORDER OF THESE + ENTRIES, NOR DELETE ANY -- add new ones at the end. */ +typedef + enum { + VG_USERREQ__MAKE_MEM_NOACCESS = VG_USERREQ_TOOL_BASE('M','C'), + VG_USERREQ__MAKE_MEM_UNDEFINED, + VG_USERREQ__MAKE_MEM_DEFINED, + VG_USERREQ__DISCARD, + VG_USERREQ__CHECK_MEM_IS_ADDRESSABLE, + VG_USERREQ__CHECK_MEM_IS_DEFINED, + VG_USERREQ__DO_LEAK_CHECK, + VG_USERREQ__COUNT_LEAKS, + + VG_USERREQ__GET_VBITS, + VG_USERREQ__SET_VBITS, + + VG_USERREQ__CREATE_BLOCK, + + VG_USERREQ__MAKE_MEM_DEFINED_IF_ADDRESSABLE, + + VG_USERREQ__ENABLE_OOM, + VG_USERREQ__GET_ALLOC_INDEX, + + /* This is just for memcheck's internal use - don't use it */ + _VG_USERREQ__MEMCHECK_RECORD_OVERLAP_ERROR + = VG_USERREQ_TOOL_BASE('M','C') + 256, + + /* This is just for memcheck's internal use - don't use it */ + _VG_USERREQ__EXCEPTION + = VG_USERREQ_TOOL_BASE('M','C') + 512, + } Vg_MemCheckClientRequest; + + + +/* Client-code macros to manipulate the state of memory. */ + +/* Mark memory at _qzz_addr as unaddressable for _qzz_len bytes. */ +#define VALGRIND_MAKE_MEM_NOACCESS(_qzz_addr,_qzz_len) \ + (__extension__({unsigned long _qzz_res; \ + VALGRIND_DO_CLIENT_REQUEST(_qzz_res, 0 /* default return */, \ + VG_USERREQ__MAKE_MEM_NOACCESS, \ + _qzz_addr, _qzz_len, 0, 0, 0); \ + _qzz_res; \ + })) + +/* Similarly, mark memory at _qzz_addr as addressable but undefined + for _qzz_len bytes. */ +#define VALGRIND_MAKE_MEM_UNDEFINED(_qzz_addr,_qzz_len) \ + (__extension__({unsigned long _qzz_res; \ + VALGRIND_DO_CLIENT_REQUEST(_qzz_res, 0 /* default return */, \ + VG_USERREQ__MAKE_MEM_UNDEFINED, \ + _qzz_addr, _qzz_len, 0, 0, 0); \ + _qzz_res; \ + })) + +/* Similarly, mark memory at _qzz_addr as addressable and defined + for _qzz_len bytes. */ +#define VALGRIND_MAKE_MEM_DEFINED(_qzz_addr,_qzz_len) \ + (__extension__({unsigned long _qzz_res; \ + VALGRIND_DO_CLIENT_REQUEST(_qzz_res, 0 /* default return */, \ + VG_USERREQ__MAKE_MEM_DEFINED, \ + _qzz_addr, _qzz_len, 0, 0, 0); \ + _qzz_res; \ + })) + +/* Similar to VALGRIND_MAKE_MEM_DEFINED except that addressability is + not altered: bytes which are addressable are marked as defined, + but those which are not addressable are left unchanged. */ +#define VALGRIND_MAKE_MEM_DEFINED_IF_ADDRESSABLE(_qzz_addr,_qzz_len) \ + (__extension__({unsigned long _qzz_res; \ + VALGRIND_DO_CLIENT_REQUEST(_qzz_res, 0 /* default return */, \ + VG_USERREQ__MAKE_MEM_DEFINED_IF_ADDRESSABLE, \ + _qzz_addr, _qzz_len, 0, 0, 0); \ + _qzz_res; \ + })) + +/* Create a block-description handle. The description is an ascii + string which is included in any messages pertaining to addresses + within the specified memory range. Has no other effect on the + properties of the memory range. */ +#define VALGRIND_CREATE_BLOCK(_qzz_addr,_qzz_len, _qzz_desc) \ + (__extension__({unsigned long _qzz_res; \ + VALGRIND_DO_CLIENT_REQUEST(_qzz_res, 0 /* default return */, \ + VG_USERREQ__CREATE_BLOCK, \ + _qzz_addr, _qzz_len, _qzz_desc, \ + 0, 0); \ + _qzz_res; \ + })) + +/* Discard a block-description-handle. Returns 1 for an + invalid handle, 0 for a valid handle. */ +#define VALGRIND_DISCARD(_qzz_blkindex) \ + (__extension__ ({unsigned long _qzz_res; \ + VALGRIND_DO_CLIENT_REQUEST(_qzz_res, 0 /* default return */, \ + VG_USERREQ__DISCARD, \ + 0, _qzz_blkindex, 0, 0, 0); \ + _qzz_res; \ + })) + + +/* Client-code macros to check the state of memory. */ + +/* Check that memory at _qzz_addr is addressable for _qzz_len bytes. + If suitable addressibility is not established, Valgrind prints an + error message and returns the address of the first offending byte. + Otherwise it returns zero. */ +#define VALGRIND_CHECK_MEM_IS_ADDRESSABLE(_qzz_addr,_qzz_len) \ + (__extension__({unsigned long _qzz_res; \ + VALGRIND_DO_CLIENT_REQUEST(_qzz_res, 0, \ + VG_USERREQ__CHECK_MEM_IS_ADDRESSABLE,\ + _qzz_addr, _qzz_len, 0, 0, 0); \ + _qzz_res; \ + })) + +/* Check that memory at _qzz_addr is addressable and defined for + _qzz_len bytes. If suitable addressibility and definedness are not + established, Valgrind prints an error message and returns the + address of the first offending byte. Otherwise it returns zero. */ +#define VALGRIND_CHECK_MEM_IS_DEFINED(_qzz_addr,_qzz_len) \ + (__extension__({unsigned long _qzz_res; \ + VALGRIND_DO_CLIENT_REQUEST(_qzz_res, 0, \ + VG_USERREQ__CHECK_MEM_IS_DEFINED, \ + _qzz_addr, _qzz_len, 0, 0, 0); \ + _qzz_res; \ + })) + +/* Use this macro to force the definedness and addressibility of an + lvalue to be checked. If suitable addressibility and definedness + are not established, Valgrind prints an error message and returns + the address of the first offending byte. Otherwise it returns + zero. */ +#define VALGRIND_CHECK_VALUE_IS_DEFINED(__lvalue) \ + VALGRIND_CHECK_MEM_IS_DEFINED( \ + (volatile unsigned char *)&(__lvalue), \ + (unsigned long)(sizeof (__lvalue))) + + +/* Do a memory leak check mid-execution. */ +#define VALGRIND_DO_LEAK_CHECK \ + {unsigned long _qzz_res; \ + VALGRIND_DO_CLIENT_REQUEST(_qzz_res, 0, \ + VG_USERREQ__DO_LEAK_CHECK, \ + 0, 0, 0, 0, 0); \ + } + +/* Just display summaries of leaked memory, rather than all the + details */ +#define VALGRIND_DO_QUICK_LEAK_CHECK \ + {unsigned long _qzz_res; \ + VALGRIND_DO_CLIENT_REQUEST(_qzz_res, 0, \ + VG_USERREQ__DO_LEAK_CHECK, \ + 1, 0, 0, 0, 0); \ + } + +/* Return number of leaked, dubious, reachable and suppressed bytes found by + all previous leak checks. They must be lvalues. */ +#define VALGRIND_COUNT_LEAKS(leaked, dubious, reachable, suppressed) \ + /* For safety on 64-bit platforms we assign the results to private + unsigned long variables, then assign these to the lvalues the user + specified, which works no matter what type 'leaked', 'dubious', etc + are. We also initialise '_qzz_leaked', etc because + VG_USERREQ__COUNT_LEAKS doesn't mark the values returned as + initialised. */ \ + {unsigned long _qzz_res; \ + unsigned long _qzz_leaked = 0, _qzz_dubious = 0; \ + unsigned long _qzz_reachable = 0, _qzz_suppressed = 0; \ + VALGRIND_DO_CLIENT_REQUEST(_qzz_res, 0, \ + VG_USERREQ__COUNT_LEAKS, \ + &_qzz_leaked, &_qzz_dubious, \ + &_qzz_reachable, &_qzz_suppressed, 0); \ + leaked = _qzz_leaked; \ + dubious = _qzz_dubious; \ + reachable = _qzz_reachable; \ + suppressed = _qzz_suppressed; \ + } + + +/* Get the validity data for addresses [zza..zza+zznbytes-1] and copy it + into the provided zzvbits array. Return values: + 0 if not running on valgrind + 1 success + 2 [previously indicated unaligned arrays; these are now allowed] + 3 if any parts of zzsrc/zzvbits are not addressable. + The metadata is not copied in cases 0, 2 or 3 so it should be + impossible to segfault your system by using this call. +*/ +#define VALGRIND_GET_VBITS(zza,zzvbits,zznbytes) \ + (__extension__({unsigned long _qzz_res; \ + char* czza = (char*)zza; \ + char* czzvbits = (char*)zzvbits; \ + VALGRIND_DO_CLIENT_REQUEST(_qzz_res, 0, \ + VG_USERREQ__GET_VBITS, \ + czza, czzvbits, zznbytes, 0, 0 ); \ + _qzz_res; \ + })) + +/* Set the validity data for addresses [zza..zza+zznbytes-1], copying it + from the provided zzvbits array. Return values: + 0 if not running on valgrind + 1 success + 2 [previously indicated unaligned arrays; these are now allowed] + 3 if any parts of zza/zzvbits are not addressable. + The metadata is not copied in cases 0, 2 or 3 so it should be + impossible to segfault your system by using this call. +*/ +#define VALGRIND_SET_VBITS(zza,zzvbits,zznbytes) \ + (__extension__({unsigned int _qzz_res; \ + char* czza = (char*)zza; \ + char* czzvbits = (char*)zzvbits; \ + VALGRIND_DO_CLIENT_REQUEST(_qzz_res, 0, \ + VG_USERREQ__SET_VBITS, \ + czza, czzvbits, zznbytes, 0, 0 ); \ + _qzz_res; \ + })) + +/* Enable or disable OOM simulation. */ +#define VALGRIND_ENABLE_OOM_AT_ALLOC_INDEX(index) \ + (__extension__ ({unsigned long _qzz_res; \ + VALGRIND_DO_CLIENT_REQUEST(_qzz_res, 0 /* default return */, \ + VG_USERREQ__ENABLE_OOM, \ + 1, index, 0, 0, 0); \ + _qzz_res; \ + })) + +#define VALGRIND_DISABLE_OOM_AT_ALLOC_INDEX(index) \ + (__extension__ ({unsigned long _qzz_res; \ + VALGRIND_DO_CLIENT_REQUEST(_qzz_res, 0 /* default return */, \ + VG_USERREQ__ENABLE_OOM, \ + 0, index, 0, 0, 0); \ + _qzz_res; \ + })) + +/* Get the current allocation index. */ +#define VALGRIND_GET_ALLOC_INDEX \ + (__extension__ ({unsigned long _qzz_res; \ + VALGRIND_DO_CLIENT_REQUEST(_qzz_res, -1 /* default return */, \ + VG_USERREQ__GET_ALLOC_INDEX, \ + 0, 0, 0, 0, 0); \ + _qzz_res; \ + })) + + +#endif + diff --git a/tests/auto/exceptionsafety_objects/3rdparty/valgrind.h b/tests/auto/exceptionsafety_objects/3rdparty/valgrind.h new file mode 100644 index 0000000..577c59a --- /dev/null +++ b/tests/auto/exceptionsafety_objects/3rdparty/valgrind.h @@ -0,0 +1,3924 @@ +/* -*- c -*- + ---------------------------------------------------------------- + + Notice that the following BSD-style license applies to this one + file (valgrind.h) only. The rest of Valgrind is licensed under the + terms of the GNU General Public License, version 2, unless + otherwise indicated. See the COPYING file in the source + distribution for details. + + ---------------------------------------------------------------- + + This file is part of Valgrind, a dynamic binary instrumentation + framework. + + Copyright (C) 2000-2008 Julian Seward. All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + 2. The origin of this software must not be misrepresented; you must + not claim that you wrote the original software. If you use this + software in a product, an acknowledgment in the product + documentation would be appreciated but is not required. + + 3. Altered source versions must be plainly marked as such, and must + not be misrepresented as being the original software. + + 4. The name of the author may not be used to endorse or promote + products derived from this software without specific prior written + permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS + OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + ---------------------------------------------------------------- + + Notice that the above BSD-style license applies to this one file + (valgrind.h) only. The entire rest of Valgrind is licensed under + the terms of the GNU General Public License, version 2. See the + COPYING file in the source distribution for details. + + ---------------------------------------------------------------- +*/ + + +/* This file is for inclusion into client (your!) code. + + You can use these macros to manipulate and query Valgrind's + execution inside your own programs. + + The resulting executables will still run without Valgrind, just a + little bit more slowly than they otherwise would, but otherwise + unchanged. When not running on valgrind, each client request + consumes very few (eg. 7) instructions, so the resulting performance + loss is negligible unless you plan to execute client requests + millions of times per second. Nevertheless, if that is still a + problem, you can compile with the NVALGRIND symbol defined (gcc + -DNVALGRIND) so that client requests are not even compiled in. */ + +#ifndef __VALGRIND_H +#define __VALGRIND_H + +#include <stdarg.h> + +/* Nb: this file might be included in a file compiled with -ansi. So + we can't use C++ style "//" comments nor the "asm" keyword (instead + use "__asm__"). */ + +/* Derive some tags indicating what the target platform is. Note + that in this file we're using the compiler's CPP symbols for + identifying architectures, which are different to the ones we use + within the rest of Valgrind. Note, __powerpc__ is active for both + 32 and 64-bit PPC, whereas __powerpc64__ is only active for the + latter (on Linux, that is). */ +#undef PLAT_x86_linux +#undef PLAT_amd64_linux +#undef PLAT_ppc32_linux +#undef PLAT_ppc64_linux +#undef PLAT_ppc32_aix5 +#undef PLAT_ppc64_aix5 + +#if !defined(_AIX) && defined(__i386__) +# define PLAT_x86_linux 1 +#elif !defined(_AIX) && defined(__x86_64__) +# define PLAT_amd64_linux 1 +#elif !defined(_AIX) && defined(__powerpc__) && !defined(__powerpc64__) +# define PLAT_ppc32_linux 1 +#elif !defined(_AIX) && defined(__powerpc__) && defined(__powerpc64__) +# define PLAT_ppc64_linux 1 +#elif defined(_AIX) && defined(__64BIT__) +# define PLAT_ppc64_aix5 1 +#elif defined(_AIX) && !defined(__64BIT__) +# define PLAT_ppc32_aix5 1 +#endif + + +/* If we're not compiling for our target platform, don't generate + any inline asms. */ +#if !defined(PLAT_x86_linux) && !defined(PLAT_amd64_linux) \ + && !defined(PLAT_ppc32_linux) && !defined(PLAT_ppc64_linux) \ + && !defined(PLAT_ppc32_aix5) && !defined(PLAT_ppc64_aix5) +# if !defined(NVALGRIND) +# define NVALGRIND 1 +# endif +#endif + + +/* ------------------------------------------------------------------ */ +/* ARCHITECTURE SPECIFICS for SPECIAL INSTRUCTIONS. There is nothing */ +/* in here of use to end-users -- skip to the next section. */ +/* ------------------------------------------------------------------ */ + +#if defined(NVALGRIND) + +/* Define NVALGRIND to completely remove the Valgrind magic sequence + from the compiled code (analogous to NDEBUG's effects on + assert()) */ +#define VALGRIND_DO_CLIENT_REQUEST( \ + _zzq_rlval, _zzq_default, _zzq_request, \ + _zzq_arg1, _zzq_arg2, _zzq_arg3, _zzq_arg4, _zzq_arg5) \ + { \ + (_zzq_rlval) = (_zzq_default); \ + } + +#else /* ! NVALGRIND */ + +/* The following defines the magic code sequences which the JITter + spots and handles magically. Don't look too closely at them as + they will rot your brain. + + The assembly code sequences for all architectures is in this one + file. This is because this file must be stand-alone, and we don't + want to have multiple files. + + For VALGRIND_DO_CLIENT_REQUEST, we must ensure that the default + value gets put in the return slot, so that everything works when + this is executed not under Valgrind. Args are passed in a memory + block, and so there's no intrinsic limit to the number that could + be passed, but it's currently five. + + The macro args are: + _zzq_rlval result lvalue + _zzq_default default value (result returned when running on real CPU) + _zzq_request request code + _zzq_arg1..5 request params + + The other two macros are used to support function wrapping, and are + a lot simpler. VALGRIND_GET_NR_CONTEXT returns the value of the + guest's NRADDR pseudo-register and whatever other information is + needed to safely run the call original from the wrapper: on + ppc64-linux, the R2 value at the divert point is also needed. This + information is abstracted into a user-visible type, OrigFn. + + VALGRIND_CALL_NOREDIR_* behaves the same as the following on the + guest, but guarantees that the branch instruction will not be + redirected: x86: call *%eax, amd64: call *%rax, ppc32/ppc64: + branch-and-link-to-r11. VALGRIND_CALL_NOREDIR is just text, not a + complete inline asm, since it needs to be combined with more magic + inline asm stuff to be useful. +*/ + +/* ------------------------- x86-linux ------------------------- */ + +#if defined(PLAT_x86_linux) + +typedef + struct { + unsigned int nraddr; /* where's the code? */ + } + OrigFn; + +#define __SPECIAL_INSTRUCTION_PREAMBLE \ + "roll $3, %%edi ; roll $13, %%edi\n\t" \ + "roll $29, %%edi ; roll $19, %%edi\n\t" + +#define VALGRIND_DO_CLIENT_REQUEST( \ + _zzq_rlval, _zzq_default, _zzq_request, \ + _zzq_arg1, _zzq_arg2, _zzq_arg3, _zzq_arg4, _zzq_arg5) \ + { volatile unsigned int _zzq_args[6]; \ + volatile unsigned int _zzq_result; \ + _zzq_args[0] = (unsigned int)(_zzq_request); \ + _zzq_args[1] = (unsigned int)(_zzq_arg1); \ + _zzq_args[2] = (unsigned int)(_zzq_arg2); \ + _zzq_args[3] = (unsigned int)(_zzq_arg3); \ + _zzq_args[4] = (unsigned int)(_zzq_arg4); \ + _zzq_args[5] = (unsigned int)(_zzq_arg5); \ + __asm__ volatile(__SPECIAL_INSTRUCTION_PREAMBLE \ + /* %EDX = client_request ( %EAX ) */ \ + "xchgl %%ebx,%%ebx" \ + : "=d" (_zzq_result) \ + : "a" (&_zzq_args[0]), "0" (_zzq_default) \ + : "cc", "memory" \ + ); \ + _zzq_rlval = _zzq_result; \ + } + +#define VALGRIND_GET_NR_CONTEXT(_zzq_rlval) \ + { volatile OrigFn* _zzq_orig = &(_zzq_rlval); \ + volatile unsigned int __addr; \ + __asm__ volatile(__SPECIAL_INSTRUCTION_PREAMBLE \ + /* %EAX = guest_NRADDR */ \ + "xchgl %%ecx,%%ecx" \ + : "=a" (__addr) \ + : \ + : "cc", "memory" \ + ); \ + _zzq_orig->nraddr = __addr; \ + } + +#define VALGRIND_CALL_NOREDIR_EAX \ + __SPECIAL_INSTRUCTION_PREAMBLE \ + /* call-noredir *%EAX */ \ + "xchgl %%edx,%%edx\n\t" +#endif /* PLAT_x86_linux */ + +/* ------------------------ amd64-linux ------------------------ */ + +#if defined(PLAT_amd64_linux) + +typedef + struct { + unsigned long long int nraddr; /* where's the code? */ + } + OrigFn; + +#define __SPECIAL_INSTRUCTION_PREAMBLE \ + "rolq $3, %%rdi ; rolq $13, %%rdi\n\t" \ + "rolq $61, %%rdi ; rolq $51, %%rdi\n\t" + +#define VALGRIND_DO_CLIENT_REQUEST( \ + _zzq_rlval, _zzq_default, _zzq_request, \ + _zzq_arg1, _zzq_arg2, _zzq_arg3, _zzq_arg4, _zzq_arg5) \ + { volatile unsigned long long int _zzq_args[6]; \ + volatile unsigned long long int _zzq_result; \ + _zzq_args[0] = (unsigned long long int)(_zzq_request); \ + _zzq_args[1] = (unsigned long long int)(_zzq_arg1); \ + _zzq_args[2] = (unsigned long long int)(_zzq_arg2); \ + _zzq_args[3] = (unsigned long long int)(_zzq_arg3); \ + _zzq_args[4] = (unsigned long long int)(_zzq_arg4); \ + _zzq_args[5] = (unsigned long long int)(_zzq_arg5); \ + __asm__ volatile(__SPECIAL_INSTRUCTION_PREAMBLE \ + /* %RDX = client_request ( %RAX ) */ \ + "xchgq %%rbx,%%rbx" \ + : "=d" (_zzq_result) \ + : "a" (&_zzq_args[0]), "0" (_zzq_default) \ + : "cc", "memory" \ + ); \ + _zzq_rlval = _zzq_result; \ + } + +#define VALGRIND_GET_NR_CONTEXT(_zzq_rlval) \ + { volatile OrigFn* _zzq_orig = &(_zzq_rlval); \ + volatile unsigned long long int __addr; \ + __asm__ volatile(__SPECIAL_INSTRUCTION_PREAMBLE \ + /* %RAX = guest_NRADDR */ \ + "xchgq %%rcx,%%rcx" \ + : "=a" (__addr) \ + : \ + : "cc", "memory" \ + ); \ + _zzq_orig->nraddr = __addr; \ + } + +#define VALGRIND_CALL_NOREDIR_RAX \ + __SPECIAL_INSTRUCTION_PREAMBLE \ + /* call-noredir *%RAX */ \ + "xchgq %%rdx,%%rdx\n\t" +#endif /* PLAT_amd64_linux */ + +/* ------------------------ ppc32-linux ------------------------ */ + +#if defined(PLAT_ppc32_linux) + +typedef + struct { + unsigned int nraddr; /* where's the code? */ + } + OrigFn; + +#define __SPECIAL_INSTRUCTION_PREAMBLE \ + "rlwinm 0,0,3,0,0 ; rlwinm 0,0,13,0,0\n\t" \ + "rlwinm 0,0,29,0,0 ; rlwinm 0,0,19,0,0\n\t" + +#define VALGRIND_DO_CLIENT_REQUEST( \ + _zzq_rlval, _zzq_default, _zzq_request, \ + _zzq_arg1, _zzq_arg2, _zzq_arg3, _zzq_arg4, _zzq_arg5) \ + \ + { unsigned int _zzq_args[6]; \ + unsigned int _zzq_result; \ + unsigned int* _zzq_ptr; \ + _zzq_args[0] = (unsigned int)(_zzq_request); \ + _zzq_args[1] = (unsigned int)(_zzq_arg1); \ + _zzq_args[2] = (unsigned int)(_zzq_arg2); \ + _zzq_args[3] = (unsigned int)(_zzq_arg3); \ + _zzq_args[4] = (unsigned int)(_zzq_arg4); \ + _zzq_args[5] = (unsigned int)(_zzq_arg5); \ + _zzq_ptr = _zzq_args; \ + __asm__ volatile("mr 3,%1\n\t" /*default*/ \ + "mr 4,%2\n\t" /*ptr*/ \ + __SPECIAL_INSTRUCTION_PREAMBLE \ + /* %R3 = client_request ( %R4 ) */ \ + "or 1,1,1\n\t" \ + "mr %0,3" /*result*/ \ + : "=b" (_zzq_result) \ + : "b" (_zzq_default), "b" (_zzq_ptr) \ + : "cc", "memory", "r3", "r4"); \ + _zzq_rlval = _zzq_result; \ + } + +#define VALGRIND_GET_NR_CONTEXT(_zzq_rlval) \ + { volatile OrigFn* _zzq_orig = &(_zzq_rlval); \ + unsigned int __addr; \ + __asm__ volatile(__SPECIAL_INSTRUCTION_PREAMBLE \ + /* %R3 = guest_NRADDR */ \ + "or 2,2,2\n\t" \ + "mr %0,3" \ + : "=b" (__addr) \ + : \ + : "cc", "memory", "r3" \ + ); \ + _zzq_orig->nraddr = __addr; \ + } + +#define VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11 \ + __SPECIAL_INSTRUCTION_PREAMBLE \ + /* branch-and-link-to-noredir *%R11 */ \ + "or 3,3,3\n\t" +#endif /* PLAT_ppc32_linux */ + +/* ------------------------ ppc64-linux ------------------------ */ + +#if defined(PLAT_ppc64_linux) + +typedef + struct { + unsigned long long int nraddr; /* where's the code? */ + unsigned long long int r2; /* what tocptr do we need? */ + } + OrigFn; + +#define __SPECIAL_INSTRUCTION_PREAMBLE \ + "rotldi 0,0,3 ; rotldi 0,0,13\n\t" \ + "rotldi 0,0,61 ; rotldi 0,0,51\n\t" + +#define VALGRIND_DO_CLIENT_REQUEST( \ + _zzq_rlval, _zzq_default, _zzq_request, \ + _zzq_arg1, _zzq_arg2, _zzq_arg3, _zzq_arg4, _zzq_arg5) \ + \ + { unsigned long long int _zzq_args[6]; \ + register unsigned long long int _zzq_result __asm__("r3"); \ + register unsigned long long int* _zzq_ptr __asm__("r4"); \ + _zzq_args[0] = (unsigned long long int)(_zzq_request); \ + _zzq_args[1] = (unsigned long long int)(_zzq_arg1); \ + _zzq_args[2] = (unsigned long long int)(_zzq_arg2); \ + _zzq_args[3] = (unsigned long long int)(_zzq_arg3); \ + _zzq_args[4] = (unsigned long long int)(_zzq_arg4); \ + _zzq_args[5] = (unsigned long long int)(_zzq_arg5); \ + _zzq_ptr = _zzq_args; \ + __asm__ volatile(__SPECIAL_INSTRUCTION_PREAMBLE \ + /* %R3 = client_request ( %R4 ) */ \ + "or 1,1,1" \ + : "=r" (_zzq_result) \ + : "0" (_zzq_default), "r" (_zzq_ptr) \ + : "cc", "memory"); \ + _zzq_rlval = _zzq_result; \ + } + +#define VALGRIND_GET_NR_CONTEXT(_zzq_rlval) \ + { volatile OrigFn* _zzq_orig = &(_zzq_rlval); \ + register unsigned long long int __addr __asm__("r3"); \ + __asm__ volatile(__SPECIAL_INSTRUCTION_PREAMBLE \ + /* %R3 = guest_NRADDR */ \ + "or 2,2,2" \ + : "=r" (__addr) \ + : \ + : "cc", "memory" \ + ); \ + _zzq_orig->nraddr = __addr; \ + __asm__ volatile(__SPECIAL_INSTRUCTION_PREAMBLE \ + /* %R3 = guest_NRADDR_GPR2 */ \ + "or 4,4,4" \ + : "=r" (__addr) \ + : \ + : "cc", "memory" \ + ); \ + _zzq_orig->r2 = __addr; \ + } + +#define VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11 \ + __SPECIAL_INSTRUCTION_PREAMBLE \ + /* branch-and-link-to-noredir *%R11 */ \ + "or 3,3,3\n\t" + +#endif /* PLAT_ppc64_linux */ + +/* ------------------------ ppc32-aix5 ------------------------- */ + +#if defined(PLAT_ppc32_aix5) + +typedef + struct { + unsigned int nraddr; /* where's the code? */ + unsigned int r2; /* what tocptr do we need? */ + } + OrigFn; + +#define __SPECIAL_INSTRUCTION_PREAMBLE \ + "rlwinm 0,0,3,0,0 ; rlwinm 0,0,13,0,0\n\t" \ + "rlwinm 0,0,29,0,0 ; rlwinm 0,0,19,0,0\n\t" + +#define VALGRIND_DO_CLIENT_REQUEST( \ + _zzq_rlval, _zzq_default, _zzq_request, \ + _zzq_arg1, _zzq_arg2, _zzq_arg3, _zzq_arg4, _zzq_arg5) \ + \ + { unsigned int _zzq_args[7]; \ + register unsigned int _zzq_result; \ + register unsigned int* _zzq_ptr; \ + _zzq_args[0] = (unsigned int)(_zzq_request); \ + _zzq_args[1] = (unsigned int)(_zzq_arg1); \ + _zzq_args[2] = (unsigned int)(_zzq_arg2); \ + _zzq_args[3] = (unsigned int)(_zzq_arg3); \ + _zzq_args[4] = (unsigned int)(_zzq_arg4); \ + _zzq_args[5] = (unsigned int)(_zzq_arg5); \ + _zzq_args[6] = (unsigned int)(_zzq_default); \ + _zzq_ptr = _zzq_args; \ + __asm__ volatile("mr 4,%1\n\t" \ + "lwz 3, 24(4)\n\t" \ + __SPECIAL_INSTRUCTION_PREAMBLE \ + /* %R3 = client_request ( %R4 ) */ \ + "or 1,1,1\n\t" \ + "mr %0,3" \ + : "=b" (_zzq_result) \ + : "b" (_zzq_ptr) \ + : "r3", "r4", "cc", "memory"); \ + _zzq_rlval = _zzq_result; \ + } + +#define VALGRIND_GET_NR_CONTEXT(_zzq_rlval) \ + { volatile OrigFn* _zzq_orig = &(_zzq_rlval); \ + register unsigned int __addr; \ + __asm__ volatile(__SPECIAL_INSTRUCTION_PREAMBLE \ + /* %R3 = guest_NRADDR */ \ + "or 2,2,2\n\t" \ + "mr %0,3" \ + : "=b" (__addr) \ + : \ + : "r3", "cc", "memory" \ + ); \ + _zzq_orig->nraddr = __addr; \ + __asm__ volatile(__SPECIAL_INSTRUCTION_PREAMBLE \ + /* %R3 = guest_NRADDR_GPR2 */ \ + "or 4,4,4\n\t" \ + "mr %0,3" \ + : "=b" (__addr) \ + : \ + : "r3", "cc", "memory" \ + ); \ + _zzq_orig->r2 = __addr; \ + } + +#define VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11 \ + __SPECIAL_INSTRUCTION_PREAMBLE \ + /* branch-and-link-to-noredir *%R11 */ \ + "or 3,3,3\n\t" + +#endif /* PLAT_ppc32_aix5 */ + +/* ------------------------ ppc64-aix5 ------------------------- */ + +#if defined(PLAT_ppc64_aix5) + +typedef + struct { + unsigned long long int nraddr; /* where's the code? */ + unsigned long long int r2; /* what tocptr do we need? */ + } + OrigFn; + +#define __SPECIAL_INSTRUCTION_PREAMBLE \ + "rotldi 0,0,3 ; rotldi 0,0,13\n\t" \ + "rotldi 0,0,61 ; rotldi 0,0,51\n\t" + +#define VALGRIND_DO_CLIENT_REQUEST( \ + _zzq_rlval, _zzq_default, _zzq_request, \ + _zzq_arg1, _zzq_arg2, _zzq_arg3, _zzq_arg4, _zzq_arg5) \ + \ + { unsigned long long int _zzq_args[7]; \ + register unsigned long long int _zzq_result; \ + register unsigned long long int* _zzq_ptr; \ + _zzq_args[0] = (unsigned int long long)(_zzq_request); \ + _zzq_args[1] = (unsigned int long long)(_zzq_arg1); \ + _zzq_args[2] = (unsigned int long long)(_zzq_arg2); \ + _zzq_args[3] = (unsigned int long long)(_zzq_arg3); \ + _zzq_args[4] = (unsigned int long long)(_zzq_arg4); \ + _zzq_args[5] = (unsigned int long long)(_zzq_arg5); \ + _zzq_args[6] = (unsigned int long long)(_zzq_default); \ + _zzq_ptr = _zzq_args; \ + __asm__ volatile("mr 4,%1\n\t" \ + "ld 3, 48(4)\n\t" \ + __SPECIAL_INSTRUCTION_PREAMBLE \ + /* %R3 = client_request ( %R4 ) */ \ + "or 1,1,1\n\t" \ + "mr %0,3" \ + : "=b" (_zzq_result) \ + : "b" (_zzq_ptr) \ + : "r3", "r4", "cc", "memory"); \ + _zzq_rlval = _zzq_result; \ + } + +#define VALGRIND_GET_NR_CONTEXT(_zzq_rlval) \ + { volatile OrigFn* _zzq_orig = &(_zzq_rlval); \ + register unsigned long long int __addr; \ + __asm__ volatile(__SPECIAL_INSTRUCTION_PREAMBLE \ + /* %R3 = guest_NRADDR */ \ + "or 2,2,2\n\t" \ + "mr %0,3" \ + : "=b" (__addr) \ + : \ + : "r3", "cc", "memory" \ + ); \ + _zzq_orig->nraddr = __addr; \ + __asm__ volatile(__SPECIAL_INSTRUCTION_PREAMBLE \ + /* %R3 = guest_NRADDR_GPR2 */ \ + "or 4,4,4\n\t" \ + "mr %0,3" \ + : "=b" (__addr) \ + : \ + : "r3", "cc", "memory" \ + ); \ + _zzq_orig->r2 = __addr; \ + } + +#define VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11 \ + __SPECIAL_INSTRUCTION_PREAMBLE \ + /* branch-and-link-to-noredir *%R11 */ \ + "or 3,3,3\n\t" + +#endif /* PLAT_ppc64_aix5 */ + +/* Insert assembly code for other platforms here... */ + +#endif /* NVALGRIND */ + + +/* ------------------------------------------------------------------ */ +/* PLATFORM SPECIFICS for FUNCTION WRAPPING. This is all very */ +/* ugly. It's the least-worst tradeoff I can think of. */ +/* ------------------------------------------------------------------ */ + +/* This section defines magic (a.k.a appalling-hack) macros for doing + guaranteed-no-redirection macros, so as to get from function + wrappers to the functions they are wrapping. The whole point is to + construct standard call sequences, but to do the call itself with a + special no-redirect call pseudo-instruction that the JIT + understands and handles specially. This section is long and + repetitious, and I can't see a way to make it shorter. + + The naming scheme is as follows: + + CALL_FN_{W,v}_{v,W,WW,WWW,WWWW,5W,6W,7W,etc} + + 'W' stands for "word" and 'v' for "void". Hence there are + different macros for calling arity 0, 1, 2, 3, 4, etc, functions, + and for each, the possibility of returning a word-typed result, or + no result. +*/ + +/* Use these to write the name of your wrapper. NOTE: duplicates + VG_WRAP_FUNCTION_Z{U,Z} in pub_tool_redir.h. */ + +#define I_WRAP_SONAME_FNNAME_ZU(soname,fnname) \ + _vgwZU_##soname##_##fnname + +#define I_WRAP_SONAME_FNNAME_ZZ(soname,fnname) \ + _vgwZZ_##soname##_##fnname + +/* Use this macro from within a wrapper function to collect the + context (address and possibly other info) of the original function. + Once you have that you can then use it in one of the CALL_FN_ + macros. The type of the argument _lval is OrigFn. */ +#define VALGRIND_GET_ORIG_FN(_lval) VALGRIND_GET_NR_CONTEXT(_lval) + +/* Derivatives of the main macros below, for calling functions + returning void. */ + +#define CALL_FN_v_v(fnptr) \ + do { volatile unsigned long _junk; \ + CALL_FN_W_v(_junk,fnptr); } while (0) + +#define CALL_FN_v_W(fnptr, arg1) \ + do { volatile unsigned long _junk; \ + CALL_FN_W_W(_junk,fnptr,arg1); } while (0) + +#define CALL_FN_v_WW(fnptr, arg1,arg2) \ + do { volatile unsigned long _junk; \ + CALL_FN_W_WW(_junk,fnptr,arg1,arg2); } while (0) + +#define CALL_FN_v_WWW(fnptr, arg1,arg2,arg3) \ + do { volatile unsigned long _junk; \ + CALL_FN_W_WWW(_junk,fnptr,arg1,arg2,arg3); } while (0) + +/* ------------------------- x86-linux ------------------------- */ + +#if defined(PLAT_x86_linux) + +/* These regs are trashed by the hidden call. No need to mention eax + as gcc can already see that, plus causes gcc to bomb. */ +#define __CALLER_SAVED_REGS /*"eax"*/ "ecx", "edx" + +/* These CALL_FN_ macros assume that on x86-linux, sizeof(unsigned + long) == 4. */ + +#define CALL_FN_W_v(lval, orig) \ + do { \ + volatile OrigFn _orig = (orig); \ + volatile unsigned long _argvec[1]; \ + volatile unsigned long _res; \ + _argvec[0] = (unsigned long)_orig.nraddr; \ + __asm__ volatile( \ + "movl (%%eax), %%eax\n\t" /* target->%eax */ \ + VALGRIND_CALL_NOREDIR_EAX \ + : /*out*/ "=a" (_res) \ + : /*in*/ "a" (&_argvec[0]) \ + : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \ + ); \ + lval = (__typeof__(lval)) _res; \ + } while (0) + +#define CALL_FN_W_W(lval, orig, arg1) \ + do { \ + volatile OrigFn _orig = (orig); \ + volatile unsigned long _argvec[2]; \ + volatile unsigned long _res; \ + _argvec[0] = (unsigned long)_orig.nraddr; \ + _argvec[1] = (unsigned long)(arg1); \ + __asm__ volatile( \ + "pushl 4(%%eax)\n\t" \ + "movl (%%eax), %%eax\n\t" /* target->%eax */ \ + VALGRIND_CALL_NOREDIR_EAX \ + "addl $4, %%esp\n" \ + : /*out*/ "=a" (_res) \ + : /*in*/ "a" (&_argvec[0]) \ + : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \ + ); \ + lval = (__typeof__(lval)) _res; \ + } while (0) + +#define CALL_FN_W_WW(lval, orig, arg1,arg2) \ + do { \ + volatile OrigFn _orig = (orig); \ + volatile unsigned long _argvec[3]; \ + volatile unsigned long _res; \ + _argvec[0] = (unsigned long)_orig.nraddr; \ + _argvec[1] = (unsigned long)(arg1); \ + _argvec[2] = (unsigned long)(arg2); \ + __asm__ volatile( \ + "pushl 8(%%eax)\n\t" \ + "pushl 4(%%eax)\n\t" \ + "movl (%%eax), %%eax\n\t" /* target->%eax */ \ + VALGRIND_CALL_NOREDIR_EAX \ + "addl $8, %%esp\n" \ + : /*out*/ "=a" (_res) \ + : /*in*/ "a" (&_argvec[0]) \ + : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \ + ); \ + lval = (__typeof__(lval)) _res; \ + } while (0) + +#define CALL_FN_W_WWW(lval, orig, arg1,arg2,arg3) \ + do { \ + volatile OrigFn _orig = (orig); \ + volatile unsigned long _argvec[4]; \ + volatile unsigned long _res; \ + _argvec[0] = (unsigned long)_orig.nraddr; \ + _argvec[1] = (unsigned long)(arg1); \ + _argvec[2] = (unsigned long)(arg2); \ + _argvec[3] = (unsigned long)(arg3); \ + __asm__ volatile( \ + "pushl 12(%%eax)\n\t" \ + "pushl 8(%%eax)\n\t" \ + "pushl 4(%%eax)\n\t" \ + "movl (%%eax), %%eax\n\t" /* target->%eax */ \ + VALGRIND_CALL_NOREDIR_EAX \ + "addl $12, %%esp\n" \ + : /*out*/ "=a" (_res) \ + : /*in*/ "a" (&_argvec[0]) \ + : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \ + ); \ + lval = (__typeof__(lval)) _res; \ + } while (0) + +#define CALL_FN_W_WWWW(lval, orig, arg1,arg2,arg3,arg4) \ + do { \ + volatile OrigFn _orig = (orig); \ + volatile unsigned long _argvec[5]; \ + volatile unsigned long _res; \ + _argvec[0] = (unsigned long)_orig.nraddr; \ + _argvec[1] = (unsigned long)(arg1); \ + _argvec[2] = (unsigned long)(arg2); \ + _argvec[3] = (unsigned long)(arg3); \ + _argvec[4] = (unsigned long)(arg4); \ + __asm__ volatile( \ + "pushl 16(%%eax)\n\t" \ + "pushl 12(%%eax)\n\t" \ + "pushl 8(%%eax)\n\t" \ + "pushl 4(%%eax)\n\t" \ + "movl (%%eax), %%eax\n\t" /* target->%eax */ \ + VALGRIND_CALL_NOREDIR_EAX \ + "addl $16, %%esp\n" \ + : /*out*/ "=a" (_res) \ + : /*in*/ "a" (&_argvec[0]) \ + : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \ + ); \ + lval = (__typeof__(lval)) _res; \ + } while (0) + +#define CALL_FN_W_5W(lval, orig, arg1,arg2,arg3,arg4,arg5) \ + do { \ + volatile OrigFn _orig = (orig); \ + volatile unsigned long _argvec[6]; \ + volatile unsigned long _res; \ + _argvec[0] = (unsigned long)_orig.nraddr; \ + _argvec[1] = (unsigned long)(arg1); \ + _argvec[2] = (unsigned long)(arg2); \ + _argvec[3] = (unsigned long)(arg3); \ + _argvec[4] = (unsigned long)(arg4); \ + _argvec[5] = (unsigned long)(arg5); \ + __asm__ volatile( \ + "pushl 20(%%eax)\n\t" \ + "pushl 16(%%eax)\n\t" \ + "pushl 12(%%eax)\n\t" \ + "pushl 8(%%eax)\n\t" \ + "pushl 4(%%eax)\n\t" \ + "movl (%%eax), %%eax\n\t" /* target->%eax */ \ + VALGRIND_CALL_NOREDIR_EAX \ + "addl $20, %%esp\n" \ + : /*out*/ "=a" (_res) \ + : /*in*/ "a" (&_argvec[0]) \ + : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \ + ); \ + lval = (__typeof__(lval)) _res; \ + } while (0) + +#define CALL_FN_W_6W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6) \ + do { \ + volatile OrigFn _orig = (orig); \ + volatile unsigned long _argvec[7]; \ + volatile unsigned long _res; \ + _argvec[0] = (unsigned long)_orig.nraddr; \ + _argvec[1] = (unsigned long)(arg1); \ + _argvec[2] = (unsigned long)(arg2); \ + _argvec[3] = (unsigned long)(arg3); \ + _argvec[4] = (unsigned long)(arg4); \ + _argvec[5] = (unsigned long)(arg5); \ + _argvec[6] = (unsigned long)(arg6); \ + __asm__ volatile( \ + "pushl 24(%%eax)\n\t" \ + "pushl 20(%%eax)\n\t" \ + "pushl 16(%%eax)\n\t" \ + "pushl 12(%%eax)\n\t" \ + "pushl 8(%%eax)\n\t" \ + "pushl 4(%%eax)\n\t" \ + "movl (%%eax), %%eax\n\t" /* target->%eax */ \ + VALGRIND_CALL_NOREDIR_EAX \ + "addl $24, %%esp\n" \ + : /*out*/ "=a" (_res) \ + : /*in*/ "a" (&_argvec[0]) \ + : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \ + ); \ + lval = (__typeof__(lval)) _res; \ + } while (0) + +#define CALL_FN_W_7W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6, \ + arg7) \ + do { \ + volatile OrigFn _orig = (orig); \ + volatile unsigned long _argvec[8]; \ + volatile unsigned long _res; \ + _argvec[0] = (unsigned long)_orig.nraddr; \ + _argvec[1] = (unsigned long)(arg1); \ + _argvec[2] = (unsigned long)(arg2); \ + _argvec[3] = (unsigned long)(arg3); \ + _argvec[4] = (unsigned long)(arg4); \ + _argvec[5] = (unsigned long)(arg5); \ + _argvec[6] = (unsigned long)(arg6); \ + _argvec[7] = (unsigned long)(arg7); \ + __asm__ volatile( \ + "pushl 28(%%eax)\n\t" \ + "pushl 24(%%eax)\n\t" \ + "pushl 20(%%eax)\n\t" \ + "pushl 16(%%eax)\n\t" \ + "pushl 12(%%eax)\n\t" \ + "pushl 8(%%eax)\n\t" \ + "pushl 4(%%eax)\n\t" \ + "movl (%%eax), %%eax\n\t" /* target->%eax */ \ + VALGRIND_CALL_NOREDIR_EAX \ + "addl $28, %%esp\n" \ + : /*out*/ "=a" (_res) \ + : /*in*/ "a" (&_argvec[0]) \ + : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \ + ); \ + lval = (__typeof__(lval)) _res; \ + } while (0) + +#define CALL_FN_W_8W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6, \ + arg7,arg8) \ + do { \ + volatile OrigFn _orig = (orig); \ + volatile unsigned long _argvec[9]; \ + volatile unsigned long _res; \ + _argvec[0] = (unsigned long)_orig.nraddr; \ + _argvec[1] = (unsigned long)(arg1); \ + _argvec[2] = (unsigned long)(arg2); \ + _argvec[3] = (unsigned long)(arg3); \ + _argvec[4] = (unsigned long)(arg4); \ + _argvec[5] = (unsigned long)(arg5); \ + _argvec[6] = (unsigned long)(arg6); \ + _argvec[7] = (unsigned long)(arg7); \ + _argvec[8] = (unsigned long)(arg8); \ + __asm__ volatile( \ + "pushl 32(%%eax)\n\t" \ + "pushl 28(%%eax)\n\t" \ + "pushl 24(%%eax)\n\t" \ + "pushl 20(%%eax)\n\t" \ + "pushl 16(%%eax)\n\t" \ + "pushl 12(%%eax)\n\t" \ + "pushl 8(%%eax)\n\t" \ + "pushl 4(%%eax)\n\t" \ + "movl (%%eax), %%eax\n\t" /* target->%eax */ \ + VALGRIND_CALL_NOREDIR_EAX \ + "addl $32, %%esp\n" \ + : /*out*/ "=a" (_res) \ + : /*in*/ "a" (&_argvec[0]) \ + : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \ + ); \ + lval = (__typeof__(lval)) _res; \ + } while (0) + +#define CALL_FN_W_9W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6, \ + arg7,arg8,arg9) \ + do { \ + volatile OrigFn _orig = (orig); \ + volatile unsigned long _argvec[10]; \ + volatile unsigned long _res; \ + _argvec[0] = (unsigned long)_orig.nraddr; \ + _argvec[1] = (unsigned long)(arg1); \ + _argvec[2] = (unsigned long)(arg2); \ + _argvec[3] = (unsigned long)(arg3); \ + _argvec[4] = (unsigned long)(arg4); \ + _argvec[5] = (unsigned long)(arg5); \ + _argvec[6] = (unsigned long)(arg6); \ + _argvec[7] = (unsigned long)(arg7); \ + _argvec[8] = (unsigned long)(arg8); \ + _argvec[9] = (unsigned long)(arg9); \ + __asm__ volatile( \ + "pushl 36(%%eax)\n\t" \ + "pushl 32(%%eax)\n\t" \ + "pushl 28(%%eax)\n\t" \ + "pushl 24(%%eax)\n\t" \ + "pushl 20(%%eax)\n\t" \ + "pushl 16(%%eax)\n\t" \ + "pushl 12(%%eax)\n\t" \ + "pushl 8(%%eax)\n\t" \ + "pushl 4(%%eax)\n\t" \ + "movl (%%eax), %%eax\n\t" /* target->%eax */ \ + VALGRIND_CALL_NOREDIR_EAX \ + "addl $36, %%esp\n" \ + : /*out*/ "=a" (_res) \ + : /*in*/ "a" (&_argvec[0]) \ + : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \ + ); \ + lval = (__typeof__(lval)) _res; \ + } while (0) + +#define CALL_FN_W_10W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6, \ + arg7,arg8,arg9,arg10) \ + do { \ + volatile OrigFn _orig = (orig); \ + volatile unsigned long _argvec[11]; \ + volatile unsigned long _res; \ + _argvec[0] = (unsigned long)_orig.nraddr; \ + _argvec[1] = (unsigned long)(arg1); \ + _argvec[2] = (unsigned long)(arg2); \ + _argvec[3] = (unsigned long)(arg3); \ + _argvec[4] = (unsigned long)(arg4); \ + _argvec[5] = (unsigned long)(arg5); \ + _argvec[6] = (unsigned long)(arg6); \ + _argvec[7] = (unsigned long)(arg7); \ + _argvec[8] = (unsigned long)(arg8); \ + _argvec[9] = (unsigned long)(arg9); \ + _argvec[10] = (unsigned long)(arg10); \ + __asm__ volatile( \ + "pushl 40(%%eax)\n\t" \ + "pushl 36(%%eax)\n\t" \ + "pushl 32(%%eax)\n\t" \ + "pushl 28(%%eax)\n\t" \ + "pushl 24(%%eax)\n\t" \ + "pushl 20(%%eax)\n\t" \ + "pushl 16(%%eax)\n\t" \ + "pushl 12(%%eax)\n\t" \ + "pushl 8(%%eax)\n\t" \ + "pushl 4(%%eax)\n\t" \ + "movl (%%eax), %%eax\n\t" /* target->%eax */ \ + VALGRIND_CALL_NOREDIR_EAX \ + "addl $40, %%esp\n" \ + : /*out*/ "=a" (_res) \ + : /*in*/ "a" (&_argvec[0]) \ + : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \ + ); \ + lval = (__typeof__(lval)) _res; \ + } while (0) + +#define CALL_FN_W_11W(lval, orig, arg1,arg2,arg3,arg4,arg5, \ + arg6,arg7,arg8,arg9,arg10, \ + arg11) \ + do { \ + volatile OrigFn _orig = (orig); \ + volatile unsigned long _argvec[12]; \ + volatile unsigned long _res; \ + _argvec[0] = (unsigned long)_orig.nraddr; \ + _argvec[1] = (unsigned long)(arg1); \ + _argvec[2] = (unsigned long)(arg2); \ + _argvec[3] = (unsigned long)(arg3); \ + _argvec[4] = (unsigned long)(arg4); \ + _argvec[5] = (unsigned long)(arg5); \ + _argvec[6] = (unsigned long)(arg6); \ + _argvec[7] = (unsigned long)(arg7); \ + _argvec[8] = (unsigned long)(arg8); \ + _argvec[9] = (unsigned long)(arg9); \ + _argvec[10] = (unsigned long)(arg10); \ + _argvec[11] = (unsigned long)(arg11); \ + __asm__ volatile( \ + "pushl 44(%%eax)\n\t" \ + "pushl 40(%%eax)\n\t" \ + "pushl 36(%%eax)\n\t" \ + "pushl 32(%%eax)\n\t" \ + "pushl 28(%%eax)\n\t" \ + "pushl 24(%%eax)\n\t" \ + "pushl 20(%%eax)\n\t" \ + "pushl 16(%%eax)\n\t" \ + "pushl 12(%%eax)\n\t" \ + "pushl 8(%%eax)\n\t" \ + "pushl 4(%%eax)\n\t" \ + "movl (%%eax), %%eax\n\t" /* target->%eax */ \ + VALGRIND_CALL_NOREDIR_EAX \ + "addl $44, %%esp\n" \ + : /*out*/ "=a" (_res) \ + : /*in*/ "a" (&_argvec[0]) \ + : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \ + ); \ + lval = (__typeof__(lval)) _res; \ + } while (0) + +#define CALL_FN_W_12W(lval, orig, arg1,arg2,arg3,arg4,arg5, \ + arg6,arg7,arg8,arg9,arg10, \ + arg11,arg12) \ + do { \ + volatile OrigFn _orig = (orig); \ + volatile unsigned long _argvec[13]; \ + volatile unsigned long _res; \ + _argvec[0] = (unsigned long)_orig.nraddr; \ + _argvec[1] = (unsigned long)(arg1); \ + _argvec[2] = (unsigned long)(arg2); \ + _argvec[3] = (unsigned long)(arg3); \ + _argvec[4] = (unsigned long)(arg4); \ + _argvec[5] = (unsigned long)(arg5); \ + _argvec[6] = (unsigned long)(arg6); \ + _argvec[7] = (unsigned long)(arg7); \ + _argvec[8] = (unsigned long)(arg8); \ + _argvec[9] = (unsigned long)(arg9); \ + _argvec[10] = (unsigned long)(arg10); \ + _argvec[11] = (unsigned long)(arg11); \ + _argvec[12] = (unsigned long)(arg12); \ + __asm__ volatile( \ + "pushl 48(%%eax)\n\t" \ + "pushl 44(%%eax)\n\t" \ + "pushl 40(%%eax)\n\t" \ + "pushl 36(%%eax)\n\t" \ + "pushl 32(%%eax)\n\t" \ + "pushl 28(%%eax)\n\t" \ + "pushl 24(%%eax)\n\t" \ + "pushl 20(%%eax)\n\t" \ + "pushl 16(%%eax)\n\t" \ + "pushl 12(%%eax)\n\t" \ + "pushl 8(%%eax)\n\t" \ + "pushl 4(%%eax)\n\t" \ + "movl (%%eax), %%eax\n\t" /* target->%eax */ \ + VALGRIND_CALL_NOREDIR_EAX \ + "addl $48, %%esp\n" \ + : /*out*/ "=a" (_res) \ + : /*in*/ "a" (&_argvec[0]) \ + : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \ + ); \ + lval = (__typeof__(lval)) _res; \ + } while (0) + +#endif /* PLAT_x86_linux */ + +/* ------------------------ amd64-linux ------------------------ */ + +#if defined(PLAT_amd64_linux) + +/* ARGREGS: rdi rsi rdx rcx r8 r9 (the rest on stack in R-to-L order) */ + +/* These regs are trashed by the hidden call. */ +#define __CALLER_SAVED_REGS /*"rax",*/ "rcx", "rdx", "rsi", \ + "rdi", "r8", "r9", "r10", "r11" + +/* These CALL_FN_ macros assume that on amd64-linux, sizeof(unsigned + long) == 8. */ + +/* NB 9 Sept 07. There is a nasty kludge here in all these CALL_FN_ + macros. In order not to trash the stack redzone, we need to drop + %rsp by 128 before the hidden call, and restore afterwards. The + nastyness is that it is only by luck that the stack still appears + to be unwindable during the hidden call - since then the behaviour + of any routine using this macro does not match what the CFI data + says. Sigh. + + Why is this important? Imagine that a wrapper has a stack + allocated local, and passes to the hidden call, a pointer to it. + Because gcc does not know about the hidden call, it may allocate + that local in the redzone. Unfortunately the hidden call may then + trash it before it comes to use it. So we must step clear of the + redzone, for the duration of the hidden call, to make it safe. + + Probably the same problem afflicts the other redzone-style ABIs too + (ppc64-linux, ppc32-aix5, ppc64-aix5); but for those, the stack is + self describing (none of this CFI nonsense) so at least messing + with the stack pointer doesn't give a danger of non-unwindable + stack. */ + +#define CALL_FN_W_v(lval, orig) \ + do { \ + volatile OrigFn _orig = (orig); \ + volatile unsigned long _argvec[1]; \ + volatile unsigned long _res; \ + _argvec[0] = (unsigned long)_orig.nraddr; \ + __asm__ volatile( \ + "subq $128,%%rsp\n\t" \ + "movq (%%rax), %%rax\n\t" /* target->%rax */ \ + VALGRIND_CALL_NOREDIR_RAX \ + "addq $128,%%rsp\n\t" \ + : /*out*/ "=a" (_res) \ + : /*in*/ "a" (&_argvec[0]) \ + : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \ + ); \ + lval = (__typeof__(lval)) _res; \ + } while (0) + +#define CALL_FN_W_W(lval, orig, arg1) \ + do { \ + volatile OrigFn _orig = (orig); \ + volatile unsigned long _argvec[2]; \ + volatile unsigned long _res; \ + _argvec[0] = (unsigned long)_orig.nraddr; \ + _argvec[1] = (unsigned long)(arg1); \ + __asm__ volatile( \ + "subq $128,%%rsp\n\t" \ + "movq 8(%%rax), %%rdi\n\t" \ + "movq (%%rax), %%rax\n\t" /* target->%rax */ \ + VALGRIND_CALL_NOREDIR_RAX \ + "addq $128,%%rsp\n\t" \ + : /*out*/ "=a" (_res) \ + : /*in*/ "a" (&_argvec[0]) \ + : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \ + ); \ + lval = (__typeof__(lval)) _res; \ + } while (0) + +#define CALL_FN_W_WW(lval, orig, arg1,arg2) \ + do { \ + volatile OrigFn _orig = (orig); \ + volatile unsigned long _argvec[3]; \ + volatile unsigned long _res; \ + _argvec[0] = (unsigned long)_orig.nraddr; \ + _argvec[1] = (unsigned long)(arg1); \ + _argvec[2] = (unsigned long)(arg2); \ + __asm__ volatile( \ + "subq $128,%%rsp\n\t" \ + "movq 16(%%rax), %%rsi\n\t" \ + "movq 8(%%rax), %%rdi\n\t" \ + "movq (%%rax), %%rax\n\t" /* target->%rax */ \ + VALGRIND_CALL_NOREDIR_RAX \ + "addq $128,%%rsp\n\t" \ + : /*out*/ "=a" (_res) \ + : /*in*/ "a" (&_argvec[0]) \ + : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \ + ); \ + lval = (__typeof__(lval)) _res; \ + } while (0) + +#define CALL_FN_W_WWW(lval, orig, arg1,arg2,arg3) \ + do { \ + volatile OrigFn _orig = (orig); \ + volatile unsigned long _argvec[4]; \ + volatile unsigned long _res; \ + _argvec[0] = (unsigned long)_orig.nraddr; \ + _argvec[1] = (unsigned long)(arg1); \ + _argvec[2] = (unsigned long)(arg2); \ + _argvec[3] = (unsigned long)(arg3); \ + __asm__ volatile( \ + "subq $128,%%rsp\n\t" \ + "movq 24(%%rax), %%rdx\n\t" \ + "movq 16(%%rax), %%rsi\n\t" \ + "movq 8(%%rax), %%rdi\n\t" \ + "movq (%%rax), %%rax\n\t" /* target->%rax */ \ + VALGRIND_CALL_NOREDIR_RAX \ + "addq $128,%%rsp\n\t" \ + : /*out*/ "=a" (_res) \ + : /*in*/ "a" (&_argvec[0]) \ + : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \ + ); \ + lval = (__typeof__(lval)) _res; \ + } while (0) + +#define CALL_FN_W_WWWW(lval, orig, arg1,arg2,arg3,arg4) \ + do { \ + volatile OrigFn _orig = (orig); \ + volatile unsigned long _argvec[5]; \ + volatile unsigned long _res; \ + _argvec[0] = (unsigned long)_orig.nraddr; \ + _argvec[1] = (unsigned long)(arg1); \ + _argvec[2] = (unsigned long)(arg2); \ + _argvec[3] = (unsigned long)(arg3); \ + _argvec[4] = (unsigned long)(arg4); \ + __asm__ volatile( \ + "subq $128,%%rsp\n\t" \ + "movq 32(%%rax), %%rcx\n\t" \ + "movq 24(%%rax), %%rdx\n\t" \ + "movq 16(%%rax), %%rsi\n\t" \ + "movq 8(%%rax), %%rdi\n\t" \ + "movq (%%rax), %%rax\n\t" /* target->%rax */ \ + VALGRIND_CALL_NOREDIR_RAX \ + "addq $128,%%rsp\n\t" \ + : /*out*/ "=a" (_res) \ + : /*in*/ "a" (&_argvec[0]) \ + : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \ + ); \ + lval = (__typeof__(lval)) _res; \ + } while (0) + +#define CALL_FN_W_5W(lval, orig, arg1,arg2,arg3,arg4,arg5) \ + do { \ + volatile OrigFn _orig = (orig); \ + volatile unsigned long _argvec[6]; \ + volatile unsigned long _res; \ + _argvec[0] = (unsigned long)_orig.nraddr; \ + _argvec[1] = (unsigned long)(arg1); \ + _argvec[2] = (unsigned long)(arg2); \ + _argvec[3] = (unsigned long)(arg3); \ + _argvec[4] = (unsigned long)(arg4); \ + _argvec[5] = (unsigned long)(arg5); \ + __asm__ volatile( \ + "subq $128,%%rsp\n\t" \ + "movq 40(%%rax), %%r8\n\t" \ + "movq 32(%%rax), %%rcx\n\t" \ + "movq 24(%%rax), %%rdx\n\t" \ + "movq 16(%%rax), %%rsi\n\t" \ + "movq 8(%%rax), %%rdi\n\t" \ + "movq (%%rax), %%rax\n\t" /* target->%rax */ \ + VALGRIND_CALL_NOREDIR_RAX \ + "addq $128,%%rsp\n\t" \ + : /*out*/ "=a" (_res) \ + : /*in*/ "a" (&_argvec[0]) \ + : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \ + ); \ + lval = (__typeof__(lval)) _res; \ + } while (0) + +#define CALL_FN_W_6W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6) \ + do { \ + volatile OrigFn _orig = (orig); \ + volatile unsigned long _argvec[7]; \ + volatile unsigned long _res; \ + _argvec[0] = (unsigned long)_orig.nraddr; \ + _argvec[1] = (unsigned long)(arg1); \ + _argvec[2] = (unsigned long)(arg2); \ + _argvec[3] = (unsigned long)(arg3); \ + _argvec[4] = (unsigned long)(arg4); \ + _argvec[5] = (unsigned long)(arg5); \ + _argvec[6] = (unsigned long)(arg6); \ + __asm__ volatile( \ + "subq $128,%%rsp\n\t" \ + "movq 48(%%rax), %%r9\n\t" \ + "movq 40(%%rax), %%r8\n\t" \ + "movq 32(%%rax), %%rcx\n\t" \ + "movq 24(%%rax), %%rdx\n\t" \ + "movq 16(%%rax), %%rsi\n\t" \ + "movq 8(%%rax), %%rdi\n\t" \ + "movq (%%rax), %%rax\n\t" /* target->%rax */ \ + "addq $128,%%rsp\n\t" \ + VALGRIND_CALL_NOREDIR_RAX \ + : /*out*/ "=a" (_res) \ + : /*in*/ "a" (&_argvec[0]) \ + : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \ + ); \ + lval = (__typeof__(lval)) _res; \ + } while (0) + +#define CALL_FN_W_7W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6, \ + arg7) \ + do { \ + volatile OrigFn _orig = (orig); \ + volatile unsigned long _argvec[8]; \ + volatile unsigned long _res; \ + _argvec[0] = (unsigned long)_orig.nraddr; \ + _argvec[1] = (unsigned long)(arg1); \ + _argvec[2] = (unsigned long)(arg2); \ + _argvec[3] = (unsigned long)(arg3); \ + _argvec[4] = (unsigned long)(arg4); \ + _argvec[5] = (unsigned long)(arg5); \ + _argvec[6] = (unsigned long)(arg6); \ + _argvec[7] = (unsigned long)(arg7); \ + __asm__ volatile( \ + "subq $128,%%rsp\n\t" \ + "pushq 56(%%rax)\n\t" \ + "movq 48(%%rax), %%r9\n\t" \ + "movq 40(%%rax), %%r8\n\t" \ + "movq 32(%%rax), %%rcx\n\t" \ + "movq 24(%%rax), %%rdx\n\t" \ + "movq 16(%%rax), %%rsi\n\t" \ + "movq 8(%%rax), %%rdi\n\t" \ + "movq (%%rax), %%rax\n\t" /* target->%rax */ \ + VALGRIND_CALL_NOREDIR_RAX \ + "addq $8, %%rsp\n" \ + "addq $128,%%rsp\n\t" \ + : /*out*/ "=a" (_res) \ + : /*in*/ "a" (&_argvec[0]) \ + : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \ + ); \ + lval = (__typeof__(lval)) _res; \ + } while (0) + +#define CALL_FN_W_8W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6, \ + arg7,arg8) \ + do { \ + volatile OrigFn _orig = (orig); \ + volatile unsigned long _argvec[9]; \ + volatile unsigned long _res; \ + _argvec[0] = (unsigned long)_orig.nraddr; \ + _argvec[1] = (unsigned long)(arg1); \ + _argvec[2] = (unsigned long)(arg2); \ + _argvec[3] = (unsigned long)(arg3); \ + _argvec[4] = (unsigned long)(arg4); \ + _argvec[5] = (unsigned long)(arg5); \ + _argvec[6] = (unsigned long)(arg6); \ + _argvec[7] = (unsigned long)(arg7); \ + _argvec[8] = (unsigned long)(arg8); \ + __asm__ volatile( \ + "subq $128,%%rsp\n\t" \ + "pushq 64(%%rax)\n\t" \ + "pushq 56(%%rax)\n\t" \ + "movq 48(%%rax), %%r9\n\t" \ + "movq 40(%%rax), %%r8\n\t" \ + "movq 32(%%rax), %%rcx\n\t" \ + "movq 24(%%rax), %%rdx\n\t" \ + "movq 16(%%rax), %%rsi\n\t" \ + "movq 8(%%rax), %%rdi\n\t" \ + "movq (%%rax), %%rax\n\t" /* target->%rax */ \ + VALGRIND_CALL_NOREDIR_RAX \ + "addq $16, %%rsp\n" \ + "addq $128,%%rsp\n\t" \ + : /*out*/ "=a" (_res) \ + : /*in*/ "a" (&_argvec[0]) \ + : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \ + ); \ + lval = (__typeof__(lval)) _res; \ + } while (0) + +#define CALL_FN_W_9W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6, \ + arg7,arg8,arg9) \ + do { \ + volatile OrigFn _orig = (orig); \ + volatile unsigned long _argvec[10]; \ + volatile unsigned long _res; \ + _argvec[0] = (unsigned long)_orig.nraddr; \ + _argvec[1] = (unsigned long)(arg1); \ + _argvec[2] = (unsigned long)(arg2); \ + _argvec[3] = (unsigned long)(arg3); \ + _argvec[4] = (unsigned long)(arg4); \ + _argvec[5] = (unsigned long)(arg5); \ + _argvec[6] = (unsigned long)(arg6); \ + _argvec[7] = (unsigned long)(arg7); \ + _argvec[8] = (unsigned long)(arg8); \ + _argvec[9] = (unsigned long)(arg9); \ + __asm__ volatile( \ + "subq $128,%%rsp\n\t" \ + "pushq 72(%%rax)\n\t" \ + "pushq 64(%%rax)\n\t" \ + "pushq 56(%%rax)\n\t" \ + "movq 48(%%rax), %%r9\n\t" \ + "movq 40(%%rax), %%r8\n\t" \ + "movq 32(%%rax), %%rcx\n\t" \ + "movq 24(%%rax), %%rdx\n\t" \ + "movq 16(%%rax), %%rsi\n\t" \ + "movq 8(%%rax), %%rdi\n\t" \ + "movq (%%rax), %%rax\n\t" /* target->%rax */ \ + VALGRIND_CALL_NOREDIR_RAX \ + "addq $24, %%rsp\n" \ + "addq $128,%%rsp\n\t" \ + : /*out*/ "=a" (_res) \ + : /*in*/ "a" (&_argvec[0]) \ + : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \ + ); \ + lval = (__typeof__(lval)) _res; \ + } while (0) + +#define CALL_FN_W_10W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6, \ + arg7,arg8,arg9,arg10) \ + do { \ + volatile OrigFn _orig = (orig); \ + volatile unsigned long _argvec[11]; \ + volatile unsigned long _res; \ + _argvec[0] = (unsigned long)_orig.nraddr; \ + _argvec[1] = (unsigned long)(arg1); \ + _argvec[2] = (unsigned long)(arg2); \ + _argvec[3] = (unsigned long)(arg3); \ + _argvec[4] = (unsigned long)(arg4); \ + _argvec[5] = (unsigned long)(arg5); \ + _argvec[6] = (unsigned long)(arg6); \ + _argvec[7] = (unsigned long)(arg7); \ + _argvec[8] = (unsigned long)(arg8); \ + _argvec[9] = (unsigned long)(arg9); \ + _argvec[10] = (unsigned long)(arg10); \ + __asm__ volatile( \ + "subq $128,%%rsp\n\t" \ + "pushq 80(%%rax)\n\t" \ + "pushq 72(%%rax)\n\t" \ + "pushq 64(%%rax)\n\t" \ + "pushq 56(%%rax)\n\t" \ + "movq 48(%%rax), %%r9\n\t" \ + "movq 40(%%rax), %%r8\n\t" \ + "movq 32(%%rax), %%rcx\n\t" \ + "movq 24(%%rax), %%rdx\n\t" \ + "movq 16(%%rax), %%rsi\n\t" \ + "movq 8(%%rax), %%rdi\n\t" \ + "movq (%%rax), %%rax\n\t" /* target->%rax */ \ + VALGRIND_CALL_NOREDIR_RAX \ + "addq $32, %%rsp\n" \ + "addq $128,%%rsp\n\t" \ + : /*out*/ "=a" (_res) \ + : /*in*/ "a" (&_argvec[0]) \ + : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \ + ); \ + lval = (__typeof__(lval)) _res; \ + } while (0) + +#define CALL_FN_W_11W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6, \ + arg7,arg8,arg9,arg10,arg11) \ + do { \ + volatile OrigFn _orig = (orig); \ + volatile unsigned long _argvec[12]; \ + volatile unsigned long _res; \ + _argvec[0] = (unsigned long)_orig.nraddr; \ + _argvec[1] = (unsigned long)(arg1); \ + _argvec[2] = (unsigned long)(arg2); \ + _argvec[3] = (unsigned long)(arg3); \ + _argvec[4] = (unsigned long)(arg4); \ + _argvec[5] = (unsigned long)(arg5); \ + _argvec[6] = (unsigned long)(arg6); \ + _argvec[7] = (unsigned long)(arg7); \ + _argvec[8] = (unsigned long)(arg8); \ + _argvec[9] = (unsigned long)(arg9); \ + _argvec[10] = (unsigned long)(arg10); \ + _argvec[11] = (unsigned long)(arg11); \ + __asm__ volatile( \ + "subq $128,%%rsp\n\t" \ + "pushq 88(%%rax)\n\t" \ + "pushq 80(%%rax)\n\t" \ + "pushq 72(%%rax)\n\t" \ + "pushq 64(%%rax)\n\t" \ + "pushq 56(%%rax)\n\t" \ + "movq 48(%%rax), %%r9\n\t" \ + "movq 40(%%rax), %%r8\n\t" \ + "movq 32(%%rax), %%rcx\n\t" \ + "movq 24(%%rax), %%rdx\n\t" \ + "movq 16(%%rax), %%rsi\n\t" \ + "movq 8(%%rax), %%rdi\n\t" \ + "movq (%%rax), %%rax\n\t" /* target->%rax */ \ + VALGRIND_CALL_NOREDIR_RAX \ + "addq $40, %%rsp\n" \ + "addq $128,%%rsp\n\t" \ + : /*out*/ "=a" (_res) \ + : /*in*/ "a" (&_argvec[0]) \ + : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \ + ); \ + lval = (__typeof__(lval)) _res; \ + } while (0) + +#define CALL_FN_W_12W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6, \ + arg7,arg8,arg9,arg10,arg11,arg12) \ + do { \ + volatile OrigFn _orig = (orig); \ + volatile unsigned long _argvec[13]; \ + volatile unsigned long _res; \ + _argvec[0] = (unsigned long)_orig.nraddr; \ + _argvec[1] = (unsigned long)(arg1); \ + _argvec[2] = (unsigned long)(arg2); \ + _argvec[3] = (unsigned long)(arg3); \ + _argvec[4] = (unsigned long)(arg4); \ + _argvec[5] = (unsigned long)(arg5); \ + _argvec[6] = (unsigned long)(arg6); \ + _argvec[7] = (unsigned long)(arg7); \ + _argvec[8] = (unsigned long)(arg8); \ + _argvec[9] = (unsigned long)(arg9); \ + _argvec[10] = (unsigned long)(arg10); \ + _argvec[11] = (unsigned long)(arg11); \ + _argvec[12] = (unsigned long)(arg12); \ + __asm__ volatile( \ + "subq $128,%%rsp\n\t" \ + "pushq 96(%%rax)\n\t" \ + "pushq 88(%%rax)\n\t" \ + "pushq 80(%%rax)\n\t" \ + "pushq 72(%%rax)\n\t" \ + "pushq 64(%%rax)\n\t" \ + "pushq 56(%%rax)\n\t" \ + "movq 48(%%rax), %%r9\n\t" \ + "movq 40(%%rax), %%r8\n\t" \ + "movq 32(%%rax), %%rcx\n\t" \ + "movq 24(%%rax), %%rdx\n\t" \ + "movq 16(%%rax), %%rsi\n\t" \ + "movq 8(%%rax), %%rdi\n\t" \ + "movq (%%rax), %%rax\n\t" /* target->%rax */ \ + VALGRIND_CALL_NOREDIR_RAX \ + "addq $48, %%rsp\n" \ + "addq $128,%%rsp\n\t" \ + : /*out*/ "=a" (_res) \ + : /*in*/ "a" (&_argvec[0]) \ + : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \ + ); \ + lval = (__typeof__(lval)) _res; \ + } while (0) + +#endif /* PLAT_amd64_linux */ + +/* ------------------------ ppc32-linux ------------------------ */ + +#if defined(PLAT_ppc32_linux) + +/* This is useful for finding out about the on-stack stuff: + + extern int f9 ( int,int,int,int,int,int,int,int,int ); + extern int f10 ( int,int,int,int,int,int,int,int,int,int ); + extern int f11 ( int,int,int,int,int,int,int,int,int,int,int ); + extern int f12 ( int,int,int,int,int,int,int,int,int,int,int,int ); + + int g9 ( void ) { + return f9(11,22,33,44,55,66,77,88,99); + } + int g10 ( void ) { + return f10(11,22,33,44,55,66,77,88,99,110); + } + int g11 ( void ) { + return f11(11,22,33,44,55,66,77,88,99,110,121); + } + int g12 ( void ) { + return f12(11,22,33,44,55,66,77,88,99,110,121,132); + } +*/ + +/* ARGREGS: r3 r4 r5 r6 r7 r8 r9 r10 (the rest on stack somewhere) */ + +/* These regs are trashed by the hidden call. */ +#define __CALLER_SAVED_REGS \ + "lr", "ctr", "xer", \ + "cr0", "cr1", "cr2", "cr3", "cr4", "cr5", "cr6", "cr7", \ + "r0", "r2", "r3", "r4", "r5", "r6", "r7", "r8", "r9", "r10", \ + "r11", "r12", "r13" + +/* These CALL_FN_ macros assume that on ppc32-linux, + sizeof(unsigned long) == 4. */ + +#define CALL_FN_W_v(lval, orig) \ + do { \ + volatile OrigFn _orig = (orig); \ + volatile unsigned long _argvec[1]; \ + volatile unsigned long _res; \ + _argvec[0] = (unsigned long)_orig.nraddr; \ + __asm__ volatile( \ + "mr 11,%1\n\t" \ + "lwz 11,0(11)\n\t" /* target->r11 */ \ + VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11 \ + "mr %0,3" \ + : /*out*/ "=r" (_res) \ + : /*in*/ "r" (&_argvec[0]) \ + : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \ + ); \ + lval = (__typeof__(lval)) _res; \ + } while (0) + +#define CALL_FN_W_W(lval, orig, arg1) \ + do { \ + volatile OrigFn _orig = (orig); \ + volatile unsigned long _argvec[2]; \ + volatile unsigned long _res; \ + _argvec[0] = (unsigned long)_orig.nraddr; \ + _argvec[1] = (unsigned long)arg1; \ + __asm__ volatile( \ + "mr 11,%1\n\t" \ + "lwz 3,4(11)\n\t" /* arg1->r3 */ \ + "lwz 11,0(11)\n\t" /* target->r11 */ \ + VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11 \ + "mr %0,3" \ + : /*out*/ "=r" (_res) \ + : /*in*/ "r" (&_argvec[0]) \ + : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \ + ); \ + lval = (__typeof__(lval)) _res; \ + } while (0) + +#define CALL_FN_W_WW(lval, orig, arg1,arg2) \ + do { \ + volatile OrigFn _orig = (orig); \ + volatile unsigned long _argvec[3]; \ + volatile unsigned long _res; \ + _argvec[0] = (unsigned long)_orig.nraddr; \ + _argvec[1] = (unsigned long)arg1; \ + _argvec[2] = (unsigned long)arg2; \ + __asm__ volatile( \ + "mr 11,%1\n\t" \ + "lwz 3,4(11)\n\t" /* arg1->r3 */ \ + "lwz 4,8(11)\n\t" \ + "lwz 11,0(11)\n\t" /* target->r11 */ \ + VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11 \ + "mr %0,3" \ + : /*out*/ "=r" (_res) \ + : /*in*/ "r" (&_argvec[0]) \ + : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \ + ); \ + lval = (__typeof__(lval)) _res; \ + } while (0) + +#define CALL_FN_W_WWW(lval, orig, arg1,arg2,arg3) \ + do { \ + volatile OrigFn _orig = (orig); \ + volatile unsigned long _argvec[4]; \ + volatile unsigned long _res; \ + _argvec[0] = (unsigned long)_orig.nraddr; \ + _argvec[1] = (unsigned long)arg1; \ + _argvec[2] = (unsigned long)arg2; \ + _argvec[3] = (unsigned long)arg3; \ + __asm__ volatile( \ + "mr 11,%1\n\t" \ + "lwz 3,4(11)\n\t" /* arg1->r3 */ \ + "lwz 4,8(11)\n\t" \ + "lwz 5,12(11)\n\t" \ + "lwz 11,0(11)\n\t" /* target->r11 */ \ + VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11 \ + "mr %0,3" \ + : /*out*/ "=r" (_res) \ + : /*in*/ "r" (&_argvec[0]) \ + : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \ + ); \ + lval = (__typeof__(lval)) _res; \ + } while (0) + +#define CALL_FN_W_WWWW(lval, orig, arg1,arg2,arg3,arg4) \ + do { \ + volatile OrigFn _orig = (orig); \ + volatile unsigned long _argvec[5]; \ + volatile unsigned long _res; \ + _argvec[0] = (unsigned long)_orig.nraddr; \ + _argvec[1] = (unsigned long)arg1; \ + _argvec[2] = (unsigned long)arg2; \ + _argvec[3] = (unsigned long)arg3; \ + _argvec[4] = (unsigned long)arg4; \ + __asm__ volatile( \ + "mr 11,%1\n\t" \ + "lwz 3,4(11)\n\t" /* arg1->r3 */ \ + "lwz 4,8(11)\n\t" \ + "lwz 5,12(11)\n\t" \ + "lwz 6,16(11)\n\t" /* arg4->r6 */ \ + "lwz 11,0(11)\n\t" /* target->r11 */ \ + VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11 \ + "mr %0,3" \ + : /*out*/ "=r" (_res) \ + : /*in*/ "r" (&_argvec[0]) \ + : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \ + ); \ + lval = (__typeof__(lval)) _res; \ + } while (0) + +#define CALL_FN_W_5W(lval, orig, arg1,arg2,arg3,arg4,arg5) \ + do { \ + volatile OrigFn _orig = (orig); \ + volatile unsigned long _argvec[6]; \ + volatile unsigned long _res; \ + _argvec[0] = (unsigned long)_orig.nraddr; \ + _argvec[1] = (unsigned long)arg1; \ + _argvec[2] = (unsigned long)arg2; \ + _argvec[3] = (unsigned long)arg3; \ + _argvec[4] = (unsigned long)arg4; \ + _argvec[5] = (unsigned long)arg5; \ + __asm__ volatile( \ + "mr 11,%1\n\t" \ + "lwz 3,4(11)\n\t" /* arg1->r3 */ \ + "lwz 4,8(11)\n\t" \ + "lwz 5,12(11)\n\t" \ + "lwz 6,16(11)\n\t" /* arg4->r6 */ \ + "lwz 7,20(11)\n\t" \ + "lwz 11,0(11)\n\t" /* target->r11 */ \ + VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11 \ + "mr %0,3" \ + : /*out*/ "=r" (_res) \ + : /*in*/ "r" (&_argvec[0]) \ + : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \ + ); \ + lval = (__typeof__(lval)) _res; \ + } while (0) + +#define CALL_FN_W_6W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6) \ + do { \ + volatile OrigFn _orig = (orig); \ + volatile unsigned long _argvec[7]; \ + volatile unsigned long _res; \ + _argvec[0] = (unsigned long)_orig.nraddr; \ + _argvec[1] = (unsigned long)arg1; \ + _argvec[2] = (unsigned long)arg2; \ + _argvec[3] = (unsigned long)arg3; \ + _argvec[4] = (unsigned long)arg4; \ + _argvec[5] = (unsigned long)arg5; \ + _argvec[6] = (unsigned long)arg6; \ + __asm__ volatile( \ + "mr 11,%1\n\t" \ + "lwz 3,4(11)\n\t" /* arg1->r3 */ \ + "lwz 4,8(11)\n\t" \ + "lwz 5,12(11)\n\t" \ + "lwz 6,16(11)\n\t" /* arg4->r6 */ \ + "lwz 7,20(11)\n\t" \ + "lwz 8,24(11)\n\t" \ + "lwz 11,0(11)\n\t" /* target->r11 */ \ + VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11 \ + "mr %0,3" \ + : /*out*/ "=r" (_res) \ + : /*in*/ "r" (&_argvec[0]) \ + : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \ + ); \ + lval = (__typeof__(lval)) _res; \ + } while (0) + +#define CALL_FN_W_7W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6, \ + arg7) \ + do { \ + volatile OrigFn _orig = (orig); \ + volatile unsigned long _argvec[8]; \ + volatile unsigned long _res; \ + _argvec[0] = (unsigned long)_orig.nraddr; \ + _argvec[1] = (unsigned long)arg1; \ + _argvec[2] = (unsigned long)arg2; \ + _argvec[3] = (unsigned long)arg3; \ + _argvec[4] = (unsigned long)arg4; \ + _argvec[5] = (unsigned long)arg5; \ + _argvec[6] = (unsigned long)arg6; \ + _argvec[7] = (unsigned long)arg7; \ + __asm__ volatile( \ + "mr 11,%1\n\t" \ + "lwz 3,4(11)\n\t" /* arg1->r3 */ \ + "lwz 4,8(11)\n\t" \ + "lwz 5,12(11)\n\t" \ + "lwz 6,16(11)\n\t" /* arg4->r6 */ \ + "lwz 7,20(11)\n\t" \ + "lwz 8,24(11)\n\t" \ + "lwz 9,28(11)\n\t" \ + "lwz 11,0(11)\n\t" /* target->r11 */ \ + VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11 \ + "mr %0,3" \ + : /*out*/ "=r" (_res) \ + : /*in*/ "r" (&_argvec[0]) \ + : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \ + ); \ + lval = (__typeof__(lval)) _res; \ + } while (0) + +#define CALL_FN_W_8W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6, \ + arg7,arg8) \ + do { \ + volatile OrigFn _orig = (orig); \ + volatile unsigned long _argvec[9]; \ + volatile unsigned long _res; \ + _argvec[0] = (unsigned long)_orig.nraddr; \ + _argvec[1] = (unsigned long)arg1; \ + _argvec[2] = (unsigned long)arg2; \ + _argvec[3] = (unsigned long)arg3; \ + _argvec[4] = (unsigned long)arg4; \ + _argvec[5] = (unsigned long)arg5; \ + _argvec[6] = (unsigned long)arg6; \ + _argvec[7] = (unsigned long)arg7; \ + _argvec[8] = (unsigned long)arg8; \ + __asm__ volatile( \ + "mr 11,%1\n\t" \ + "lwz 3,4(11)\n\t" /* arg1->r3 */ \ + "lwz 4,8(11)\n\t" \ + "lwz 5,12(11)\n\t" \ + "lwz 6,16(11)\n\t" /* arg4->r6 */ \ + "lwz 7,20(11)\n\t" \ + "lwz 8,24(11)\n\t" \ + "lwz 9,28(11)\n\t" \ + "lwz 10,32(11)\n\t" /* arg8->r10 */ \ + "lwz 11,0(11)\n\t" /* target->r11 */ \ + VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11 \ + "mr %0,3" \ + : /*out*/ "=r" (_res) \ + : /*in*/ "r" (&_argvec[0]) \ + : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \ + ); \ + lval = (__typeof__(lval)) _res; \ + } while (0) + +#define CALL_FN_W_9W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6, \ + arg7,arg8,arg9) \ + do { \ + volatile OrigFn _orig = (orig); \ + volatile unsigned long _argvec[10]; \ + volatile unsigned long _res; \ + _argvec[0] = (unsigned long)_orig.nraddr; \ + _argvec[1] = (unsigned long)arg1; \ + _argvec[2] = (unsigned long)arg2; \ + _argvec[3] = (unsigned long)arg3; \ + _argvec[4] = (unsigned long)arg4; \ + _argvec[5] = (unsigned long)arg5; \ + _argvec[6] = (unsigned long)arg6; \ + _argvec[7] = (unsigned long)arg7; \ + _argvec[8] = (unsigned long)arg8; \ + _argvec[9] = (unsigned long)arg9; \ + __asm__ volatile( \ + "mr 11,%1\n\t" \ + "addi 1,1,-16\n\t" \ + /* arg9 */ \ + "lwz 3,36(11)\n\t" \ + "stw 3,8(1)\n\t" \ + /* args1-8 */ \ + "lwz 3,4(11)\n\t" /* arg1->r3 */ \ + "lwz 4,8(11)\n\t" \ + "lwz 5,12(11)\n\t" \ + "lwz 6,16(11)\n\t" /* arg4->r6 */ \ + "lwz 7,20(11)\n\t" \ + "lwz 8,24(11)\n\t" \ + "lwz 9,28(11)\n\t" \ + "lwz 10,32(11)\n\t" /* arg8->r10 */ \ + "lwz 11,0(11)\n\t" /* target->r11 */ \ + VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11 \ + "addi 1,1,16\n\t" \ + "mr %0,3" \ + : /*out*/ "=r" (_res) \ + : /*in*/ "r" (&_argvec[0]) \ + : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \ + ); \ + lval = (__typeof__(lval)) _res; \ + } while (0) + +#define CALL_FN_W_10W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6, \ + arg7,arg8,arg9,arg10) \ + do { \ + volatile OrigFn _orig = (orig); \ + volatile unsigned long _argvec[11]; \ + volatile unsigned long _res; \ + _argvec[0] = (unsigned long)_orig.nraddr; \ + _argvec[1] = (unsigned long)arg1; \ + _argvec[2] = (unsigned long)arg2; \ + _argvec[3] = (unsigned long)arg3; \ + _argvec[4] = (unsigned long)arg4; \ + _argvec[5] = (unsigned long)arg5; \ + _argvec[6] = (unsigned long)arg6; \ + _argvec[7] = (unsigned long)arg7; \ + _argvec[8] = (unsigned long)arg8; \ + _argvec[9] = (unsigned long)arg9; \ + _argvec[10] = (unsigned long)arg10; \ + __asm__ volatile( \ + "mr 11,%1\n\t" \ + "addi 1,1,-16\n\t" \ + /* arg10 */ \ + "lwz 3,40(11)\n\t" \ + "stw 3,12(1)\n\t" \ + /* arg9 */ \ + "lwz 3,36(11)\n\t" \ + "stw 3,8(1)\n\t" \ + /* args1-8 */ \ + "lwz 3,4(11)\n\t" /* arg1->r3 */ \ + "lwz 4,8(11)\n\t" \ + "lwz 5,12(11)\n\t" \ + "lwz 6,16(11)\n\t" /* arg4->r6 */ \ + "lwz 7,20(11)\n\t" \ + "lwz 8,24(11)\n\t" \ + "lwz 9,28(11)\n\t" \ + "lwz 10,32(11)\n\t" /* arg8->r10 */ \ + "lwz 11,0(11)\n\t" /* target->r11 */ \ + VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11 \ + "addi 1,1,16\n\t" \ + "mr %0,3" \ + : /*out*/ "=r" (_res) \ + : /*in*/ "r" (&_argvec[0]) \ + : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \ + ); \ + lval = (__typeof__(lval)) _res; \ + } while (0) + +#define CALL_FN_W_11W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6, \ + arg7,arg8,arg9,arg10,arg11) \ + do { \ + volatile OrigFn _orig = (orig); \ + volatile unsigned long _argvec[12]; \ + volatile unsigned long _res; \ + _argvec[0] = (unsigned long)_orig.nraddr; \ + _argvec[1] = (unsigned long)arg1; \ + _argvec[2] = (unsigned long)arg2; \ + _argvec[3] = (unsigned long)arg3; \ + _argvec[4] = (unsigned long)arg4; \ + _argvec[5] = (unsigned long)arg5; \ + _argvec[6] = (unsigned long)arg6; \ + _argvec[7] = (unsigned long)arg7; \ + _argvec[8] = (unsigned long)arg8; \ + _argvec[9] = (unsigned long)arg9; \ + _argvec[10] = (unsigned long)arg10; \ + _argvec[11] = (unsigned long)arg11; \ + __asm__ volatile( \ + "mr 11,%1\n\t" \ + "addi 1,1,-32\n\t" \ + /* arg11 */ \ + "lwz 3,44(11)\n\t" \ + "stw 3,16(1)\n\t" \ + /* arg10 */ \ + "lwz 3,40(11)\n\t" \ + "stw 3,12(1)\n\t" \ + /* arg9 */ \ + "lwz 3,36(11)\n\t" \ + "stw 3,8(1)\n\t" \ + /* args1-8 */ \ + "lwz 3,4(11)\n\t" /* arg1->r3 */ \ + "lwz 4,8(11)\n\t" \ + "lwz 5,12(11)\n\t" \ + "lwz 6,16(11)\n\t" /* arg4->r6 */ \ + "lwz 7,20(11)\n\t" \ + "lwz 8,24(11)\n\t" \ + "lwz 9,28(11)\n\t" \ + "lwz 10,32(11)\n\t" /* arg8->r10 */ \ + "lwz 11,0(11)\n\t" /* target->r11 */ \ + VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11 \ + "addi 1,1,32\n\t" \ + "mr %0,3" \ + : /*out*/ "=r" (_res) \ + : /*in*/ "r" (&_argvec[0]) \ + : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \ + ); \ + lval = (__typeof__(lval)) _res; \ + } while (0) + +#define CALL_FN_W_12W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6, \ + arg7,arg8,arg9,arg10,arg11,arg12) \ + do { \ + volatile OrigFn _orig = (orig); \ + volatile unsigned long _argvec[13]; \ + volatile unsigned long _res; \ + _argvec[0] = (unsigned long)_orig.nraddr; \ + _argvec[1] = (unsigned long)arg1; \ + _argvec[2] = (unsigned long)arg2; \ + _argvec[3] = (unsigned long)arg3; \ + _argvec[4] = (unsigned long)arg4; \ + _argvec[5] = (unsigned long)arg5; \ + _argvec[6] = (unsigned long)arg6; \ + _argvec[7] = (unsigned long)arg7; \ + _argvec[8] = (unsigned long)arg8; \ + _argvec[9] = (unsigned long)arg9; \ + _argvec[10] = (unsigned long)arg10; \ + _argvec[11] = (unsigned long)arg11; \ + _argvec[12] = (unsigned long)arg12; \ + __asm__ volatile( \ + "mr 11,%1\n\t" \ + "addi 1,1,-32\n\t" \ + /* arg12 */ \ + "lwz 3,48(11)\n\t" \ + "stw 3,20(1)\n\t" \ + /* arg11 */ \ + "lwz 3,44(11)\n\t" \ + "stw 3,16(1)\n\t" \ + /* arg10 */ \ + "lwz 3,40(11)\n\t" \ + "stw 3,12(1)\n\t" \ + /* arg9 */ \ + "lwz 3,36(11)\n\t" \ + "stw 3,8(1)\n\t" \ + /* args1-8 */ \ + "lwz 3,4(11)\n\t" /* arg1->r3 */ \ + "lwz 4,8(11)\n\t" \ + "lwz 5,12(11)\n\t" \ + "lwz 6,16(11)\n\t" /* arg4->r6 */ \ + "lwz 7,20(11)\n\t" \ + "lwz 8,24(11)\n\t" \ + "lwz 9,28(11)\n\t" \ + "lwz 10,32(11)\n\t" /* arg8->r10 */ \ + "lwz 11,0(11)\n\t" /* target->r11 */ \ + VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11 \ + "addi 1,1,32\n\t" \ + "mr %0,3" \ + : /*out*/ "=r" (_res) \ + : /*in*/ "r" (&_argvec[0]) \ + : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \ + ); \ + lval = (__typeof__(lval)) _res; \ + } while (0) + +#endif /* PLAT_ppc32_linux */ + +/* ------------------------ ppc64-linux ------------------------ */ + +#if defined(PLAT_ppc64_linux) + +/* ARGREGS: r3 r4 r5 r6 r7 r8 r9 r10 (the rest on stack somewhere) */ + +/* These regs are trashed by the hidden call. */ +#define __CALLER_SAVED_REGS \ + "lr", "ctr", "xer", \ + "cr0", "cr1", "cr2", "cr3", "cr4", "cr5", "cr6", "cr7", \ + "r0", "r2", "r3", "r4", "r5", "r6", "r7", "r8", "r9", "r10", \ + "r11", "r12", "r13" + +/* These CALL_FN_ macros assume that on ppc64-linux, sizeof(unsigned + long) == 8. */ + +#define CALL_FN_W_v(lval, orig) \ + do { \ + volatile OrigFn _orig = (orig); \ + volatile unsigned long _argvec[3+0]; \ + volatile unsigned long _res; \ + /* _argvec[0] holds current r2 across the call */ \ + _argvec[1] = (unsigned long)_orig.r2; \ + _argvec[2] = (unsigned long)_orig.nraddr; \ + __asm__ volatile( \ + "mr 11,%1\n\t" \ + "std 2,-16(11)\n\t" /* save tocptr */ \ + "ld 2,-8(11)\n\t" /* use nraddr's tocptr */ \ + "ld 11, 0(11)\n\t" /* target->r11 */ \ + VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11 \ + "mr 11,%1\n\t" \ + "mr %0,3\n\t" \ + "ld 2,-16(11)" /* restore tocptr */ \ + : /*out*/ "=r" (_res) \ + : /*in*/ "r" (&_argvec[2]) \ + : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \ + ); \ + lval = (__typeof__(lval)) _res; \ + } while (0) + +#define CALL_FN_W_W(lval, orig, arg1) \ + do { \ + volatile OrigFn _orig = (orig); \ + volatile unsigned long _argvec[3+1]; \ + volatile unsigned long _res; \ + /* _argvec[0] holds current r2 across the call */ \ + _argvec[1] = (unsigned long)_orig.r2; \ + _argvec[2] = (unsigned long)_orig.nraddr; \ + _argvec[2+1] = (unsigned long)arg1; \ + __asm__ volatile( \ + "mr 11,%1\n\t" \ + "std 2,-16(11)\n\t" /* save tocptr */ \ + "ld 2,-8(11)\n\t" /* use nraddr's tocptr */ \ + "ld 3, 8(11)\n\t" /* arg1->r3 */ \ + "ld 11, 0(11)\n\t" /* target->r11 */ \ + VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11 \ + "mr 11,%1\n\t" \ + "mr %0,3\n\t" \ + "ld 2,-16(11)" /* restore tocptr */ \ + : /*out*/ "=r" (_res) \ + : /*in*/ "r" (&_argvec[2]) \ + : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \ + ); \ + lval = (__typeof__(lval)) _res; \ + } while (0) + +#define CALL_FN_W_WW(lval, orig, arg1,arg2) \ + do { \ + volatile OrigFn _orig = (orig); \ + volatile unsigned long _argvec[3+2]; \ + volatile unsigned long _res; \ + /* _argvec[0] holds current r2 across the call */ \ + _argvec[1] = (unsigned long)_orig.r2; \ + _argvec[2] = (unsigned long)_orig.nraddr; \ + _argvec[2+1] = (unsigned long)arg1; \ + _argvec[2+2] = (unsigned long)arg2; \ + __asm__ volatile( \ + "mr 11,%1\n\t" \ + "std 2,-16(11)\n\t" /* save tocptr */ \ + "ld 2,-8(11)\n\t" /* use nraddr's tocptr */ \ + "ld 3, 8(11)\n\t" /* arg1->r3 */ \ + "ld 4, 16(11)\n\t" /* arg2->r4 */ \ + "ld 11, 0(11)\n\t" /* target->r11 */ \ + VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11 \ + "mr 11,%1\n\t" \ + "mr %0,3\n\t" \ + "ld 2,-16(11)" /* restore tocptr */ \ + : /*out*/ "=r" (_res) \ + : /*in*/ "r" (&_argvec[2]) \ + : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \ + ); \ + lval = (__typeof__(lval)) _res; \ + } while (0) + +#define CALL_FN_W_WWW(lval, orig, arg1,arg2,arg3) \ + do { \ + volatile OrigFn _orig = (orig); \ + volatile unsigned long _argvec[3+3]; \ + volatile unsigned long _res; \ + /* _argvec[0] holds current r2 across the call */ \ + _argvec[1] = (unsigned long)_orig.r2; \ + _argvec[2] = (unsigned long)_orig.nraddr; \ + _argvec[2+1] = (unsigned long)arg1; \ + _argvec[2+2] = (unsigned long)arg2; \ + _argvec[2+3] = (unsigned long)arg3; \ + __asm__ volatile( \ + "mr 11,%1\n\t" \ + "std 2,-16(11)\n\t" /* save tocptr */ \ + "ld 2,-8(11)\n\t" /* use nraddr's tocptr */ \ + "ld 3, 8(11)\n\t" /* arg1->r3 */ \ + "ld 4, 16(11)\n\t" /* arg2->r4 */ \ + "ld 5, 24(11)\n\t" /* arg3->r5 */ \ + "ld 11, 0(11)\n\t" /* target->r11 */ \ + VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11 \ + "mr 11,%1\n\t" \ + "mr %0,3\n\t" \ + "ld 2,-16(11)" /* restore tocptr */ \ + : /*out*/ "=r" (_res) \ + : /*in*/ "r" (&_argvec[2]) \ + : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \ + ); \ + lval = (__typeof__(lval)) _res; \ + } while (0) + +#define CALL_FN_W_WWWW(lval, orig, arg1,arg2,arg3,arg4) \ + do { \ + volatile OrigFn _orig = (orig); \ + volatile unsigned long _argvec[3+4]; \ + volatile unsigned long _res; \ + /* _argvec[0] holds current r2 across the call */ \ + _argvec[1] = (unsigned long)_orig.r2; \ + _argvec[2] = (unsigned long)_orig.nraddr; \ + _argvec[2+1] = (unsigned long)arg1; \ + _argvec[2+2] = (unsigned long)arg2; \ + _argvec[2+3] = (unsigned long)arg3; \ + _argvec[2+4] = (unsigned long)arg4; \ + __asm__ volatile( \ + "mr 11,%1\n\t" \ + "std 2,-16(11)\n\t" /* save tocptr */ \ + "ld 2,-8(11)\n\t" /* use nraddr's tocptr */ \ + "ld 3, 8(11)\n\t" /* arg1->r3 */ \ + "ld 4, 16(11)\n\t" /* arg2->r4 */ \ + "ld 5, 24(11)\n\t" /* arg3->r5 */ \ + "ld 6, 32(11)\n\t" /* arg4->r6 */ \ + "ld 11, 0(11)\n\t" /* target->r11 */ \ + VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11 \ + "mr 11,%1\n\t" \ + "mr %0,3\n\t" \ + "ld 2,-16(11)" /* restore tocptr */ \ + : /*out*/ "=r" (_res) \ + : /*in*/ "r" (&_argvec[2]) \ + : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \ + ); \ + lval = (__typeof__(lval)) _res; \ + } while (0) + +#define CALL_FN_W_5W(lval, orig, arg1,arg2,arg3,arg4,arg5) \ + do { \ + volatile OrigFn _orig = (orig); \ + volatile unsigned long _argvec[3+5]; \ + volatile unsigned long _res; \ + /* _argvec[0] holds current r2 across the call */ \ + _argvec[1] = (unsigned long)_orig.r2; \ + _argvec[2] = (unsigned long)_orig.nraddr; \ + _argvec[2+1] = (unsigned long)arg1; \ + _argvec[2+2] = (unsigned long)arg2; \ + _argvec[2+3] = (unsigned long)arg3; \ + _argvec[2+4] = (unsigned long)arg4; \ + _argvec[2+5] = (unsigned long)arg5; \ + __asm__ volatile( \ + "mr 11,%1\n\t" \ + "std 2,-16(11)\n\t" /* save tocptr */ \ + "ld 2,-8(11)\n\t" /* use nraddr's tocptr */ \ + "ld 3, 8(11)\n\t" /* arg1->r3 */ \ + "ld 4, 16(11)\n\t" /* arg2->r4 */ \ + "ld 5, 24(11)\n\t" /* arg3->r5 */ \ + "ld 6, 32(11)\n\t" /* arg4->r6 */ \ + "ld 7, 40(11)\n\t" /* arg5->r7 */ \ + "ld 11, 0(11)\n\t" /* target->r11 */ \ + VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11 \ + "mr 11,%1\n\t" \ + "mr %0,3\n\t" \ + "ld 2,-16(11)" /* restore tocptr */ \ + : /*out*/ "=r" (_res) \ + : /*in*/ "r" (&_argvec[2]) \ + : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \ + ); \ + lval = (__typeof__(lval)) _res; \ + } while (0) + +#define CALL_FN_W_6W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6) \ + do { \ + volatile OrigFn _orig = (orig); \ + volatile unsigned long _argvec[3+6]; \ + volatile unsigned long _res; \ + /* _argvec[0] holds current r2 across the call */ \ + _argvec[1] = (unsigned long)_orig.r2; \ + _argvec[2] = (unsigned long)_orig.nraddr; \ + _argvec[2+1] = (unsigned long)arg1; \ + _argvec[2+2] = (unsigned long)arg2; \ + _argvec[2+3] = (unsigned long)arg3; \ + _argvec[2+4] = (unsigned long)arg4; \ + _argvec[2+5] = (unsigned long)arg5; \ + _argvec[2+6] = (unsigned long)arg6; \ + __asm__ volatile( \ + "mr 11,%1\n\t" \ + "std 2,-16(11)\n\t" /* save tocptr */ \ + "ld 2,-8(11)\n\t" /* use nraddr's tocptr */ \ + "ld 3, 8(11)\n\t" /* arg1->r3 */ \ + "ld 4, 16(11)\n\t" /* arg2->r4 */ \ + "ld 5, 24(11)\n\t" /* arg3->r5 */ \ + "ld 6, 32(11)\n\t" /* arg4->r6 */ \ + "ld 7, 40(11)\n\t" /* arg5->r7 */ \ + "ld 8, 48(11)\n\t" /* arg6->r8 */ \ + "ld 11, 0(11)\n\t" /* target->r11 */ \ + VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11 \ + "mr 11,%1\n\t" \ + "mr %0,3\n\t" \ + "ld 2,-16(11)" /* restore tocptr */ \ + : /*out*/ "=r" (_res) \ + : /*in*/ "r" (&_argvec[2]) \ + : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \ + ); \ + lval = (__typeof__(lval)) _res; \ + } while (0) + +#define CALL_FN_W_7W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6, \ + arg7) \ + do { \ + volatile OrigFn _orig = (orig); \ + volatile unsigned long _argvec[3+7]; \ + volatile unsigned long _res; \ + /* _argvec[0] holds current r2 across the call */ \ + _argvec[1] = (unsigned long)_orig.r2; \ + _argvec[2] = (unsigned long)_orig.nraddr; \ + _argvec[2+1] = (unsigned long)arg1; \ + _argvec[2+2] = (unsigned long)arg2; \ + _argvec[2+3] = (unsigned long)arg3; \ + _argvec[2+4] = (unsigned long)arg4; \ + _argvec[2+5] = (unsigned long)arg5; \ + _argvec[2+6] = (unsigned long)arg6; \ + _argvec[2+7] = (unsigned long)arg7; \ + __asm__ volatile( \ + "mr 11,%1\n\t" \ + "std 2,-16(11)\n\t" /* save tocptr */ \ + "ld 2,-8(11)\n\t" /* use nraddr's tocptr */ \ + "ld 3, 8(11)\n\t" /* arg1->r3 */ \ + "ld 4, 16(11)\n\t" /* arg2->r4 */ \ + "ld 5, 24(11)\n\t" /* arg3->r5 */ \ + "ld 6, 32(11)\n\t" /* arg4->r6 */ \ + "ld 7, 40(11)\n\t" /* arg5->r7 */ \ + "ld 8, 48(11)\n\t" /* arg6->r8 */ \ + "ld 9, 56(11)\n\t" /* arg7->r9 */ \ + "ld 11, 0(11)\n\t" /* target->r11 */ \ + VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11 \ + "mr 11,%1\n\t" \ + "mr %0,3\n\t" \ + "ld 2,-16(11)" /* restore tocptr */ \ + : /*out*/ "=r" (_res) \ + : /*in*/ "r" (&_argvec[2]) \ + : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \ + ); \ + lval = (__typeof__(lval)) _res; \ + } while (0) + +#define CALL_FN_W_8W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6, \ + arg7,arg8) \ + do { \ + volatile OrigFn _orig = (orig); \ + volatile unsigned long _argvec[3+8]; \ + volatile unsigned long _res; \ + /* _argvec[0] holds current r2 across the call */ \ + _argvec[1] = (unsigned long)_orig.r2; \ + _argvec[2] = (unsigned long)_orig.nraddr; \ + _argvec[2+1] = (unsigned long)arg1; \ + _argvec[2+2] = (unsigned long)arg2; \ + _argvec[2+3] = (unsigned long)arg3; \ + _argvec[2+4] = (unsigned long)arg4; \ + _argvec[2+5] = (unsigned long)arg5; \ + _argvec[2+6] = (unsigned long)arg6; \ + _argvec[2+7] = (unsigned long)arg7; \ + _argvec[2+8] = (unsigned long)arg8; \ + __asm__ volatile( \ + "mr 11,%1\n\t" \ + "std 2,-16(11)\n\t" /* save tocptr */ \ + "ld 2,-8(11)\n\t" /* use nraddr's tocptr */ \ + "ld 3, 8(11)\n\t" /* arg1->r3 */ \ + "ld 4, 16(11)\n\t" /* arg2->r4 */ \ + "ld 5, 24(11)\n\t" /* arg3->r5 */ \ + "ld 6, 32(11)\n\t" /* arg4->r6 */ \ + "ld 7, 40(11)\n\t" /* arg5->r7 */ \ + "ld 8, 48(11)\n\t" /* arg6->r8 */ \ + "ld 9, 56(11)\n\t" /* arg7->r9 */ \ + "ld 10, 64(11)\n\t" /* arg8->r10 */ \ + "ld 11, 0(11)\n\t" /* target->r11 */ \ + VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11 \ + "mr 11,%1\n\t" \ + "mr %0,3\n\t" \ + "ld 2,-16(11)" /* restore tocptr */ \ + : /*out*/ "=r" (_res) \ + : /*in*/ "r" (&_argvec[2]) \ + : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \ + ); \ + lval = (__typeof__(lval)) _res; \ + } while (0) + +#define CALL_FN_W_9W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6, \ + arg7,arg8,arg9) \ + do { \ + volatile OrigFn _orig = (orig); \ + volatile unsigned long _argvec[3+9]; \ + volatile unsigned long _res; \ + /* _argvec[0] holds current r2 across the call */ \ + _argvec[1] = (unsigned long)_orig.r2; \ + _argvec[2] = (unsigned long)_orig.nraddr; \ + _argvec[2+1] = (unsigned long)arg1; \ + _argvec[2+2] = (unsigned long)arg2; \ + _argvec[2+3] = (unsigned long)arg3; \ + _argvec[2+4] = (unsigned long)arg4; \ + _argvec[2+5] = (unsigned long)arg5; \ + _argvec[2+6] = (unsigned long)arg6; \ + _argvec[2+7] = (unsigned long)arg7; \ + _argvec[2+8] = (unsigned long)arg8; \ + _argvec[2+9] = (unsigned long)arg9; \ + __asm__ volatile( \ + "mr 11,%1\n\t" \ + "std 2,-16(11)\n\t" /* save tocptr */ \ + "ld 2,-8(11)\n\t" /* use nraddr's tocptr */ \ + "addi 1,1,-128\n\t" /* expand stack frame */ \ + /* arg9 */ \ + "ld 3,72(11)\n\t" \ + "std 3,112(1)\n\t" \ + /* args1-8 */ \ + "ld 3, 8(11)\n\t" /* arg1->r3 */ \ + "ld 4, 16(11)\n\t" /* arg2->r4 */ \ + "ld 5, 24(11)\n\t" /* arg3->r5 */ \ + "ld 6, 32(11)\n\t" /* arg4->r6 */ \ + "ld 7, 40(11)\n\t" /* arg5->r7 */ \ + "ld 8, 48(11)\n\t" /* arg6->r8 */ \ + "ld 9, 56(11)\n\t" /* arg7->r9 */ \ + "ld 10, 64(11)\n\t" /* arg8->r10 */ \ + "ld 11, 0(11)\n\t" /* target->r11 */ \ + VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11 \ + "mr 11,%1\n\t" \ + "mr %0,3\n\t" \ + "ld 2,-16(11)\n\t" /* restore tocptr */ \ + "addi 1,1,128" /* restore frame */ \ + : /*out*/ "=r" (_res) \ + : /*in*/ "r" (&_argvec[2]) \ + : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \ + ); \ + lval = (__typeof__(lval)) _res; \ + } while (0) + +#define CALL_FN_W_10W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6, \ + arg7,arg8,arg9,arg10) \ + do { \ + volatile OrigFn _orig = (orig); \ + volatile unsigned long _argvec[3+10]; \ + volatile unsigned long _res; \ + /* _argvec[0] holds current r2 across the call */ \ + _argvec[1] = (unsigned long)_orig.r2; \ + _argvec[2] = (unsigned long)_orig.nraddr; \ + _argvec[2+1] = (unsigned long)arg1; \ + _argvec[2+2] = (unsigned long)arg2; \ + _argvec[2+3] = (unsigned long)arg3; \ + _argvec[2+4] = (unsigned long)arg4; \ + _argvec[2+5] = (unsigned long)arg5; \ + _argvec[2+6] = (unsigned long)arg6; \ + _argvec[2+7] = (unsigned long)arg7; \ + _argvec[2+8] = (unsigned long)arg8; \ + _argvec[2+9] = (unsigned long)arg9; \ + _argvec[2+10] = (unsigned long)arg10; \ + __asm__ volatile( \ + "mr 11,%1\n\t" \ + "std 2,-16(11)\n\t" /* save tocptr */ \ + "ld 2,-8(11)\n\t" /* use nraddr's tocptr */ \ + "addi 1,1,-128\n\t" /* expand stack frame */ \ + /* arg10 */ \ + "ld 3,80(11)\n\t" \ + "std 3,120(1)\n\t" \ + /* arg9 */ \ + "ld 3,72(11)\n\t" \ + "std 3,112(1)\n\t" \ + /* args1-8 */ \ + "ld 3, 8(11)\n\t" /* arg1->r3 */ \ + "ld 4, 16(11)\n\t" /* arg2->r4 */ \ + "ld 5, 24(11)\n\t" /* arg3->r5 */ \ + "ld 6, 32(11)\n\t" /* arg4->r6 */ \ + "ld 7, 40(11)\n\t" /* arg5->r7 */ \ + "ld 8, 48(11)\n\t" /* arg6->r8 */ \ + "ld 9, 56(11)\n\t" /* arg7->r9 */ \ + "ld 10, 64(11)\n\t" /* arg8->r10 */ \ + "ld 11, 0(11)\n\t" /* target->r11 */ \ + VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11 \ + "mr 11,%1\n\t" \ + "mr %0,3\n\t" \ + "ld 2,-16(11)\n\t" /* restore tocptr */ \ + "addi 1,1,128" /* restore frame */ \ + : /*out*/ "=r" (_res) \ + : /*in*/ "r" (&_argvec[2]) \ + : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \ + ); \ + lval = (__typeof__(lval)) _res; \ + } while (0) + +#define CALL_FN_W_11W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6, \ + arg7,arg8,arg9,arg10,arg11) \ + do { \ + volatile OrigFn _orig = (orig); \ + volatile unsigned long _argvec[3+11]; \ + volatile unsigned long _res; \ + /* _argvec[0] holds current r2 across the call */ \ + _argvec[1] = (unsigned long)_orig.r2; \ + _argvec[2] = (unsigned long)_orig.nraddr; \ + _argvec[2+1] = (unsigned long)arg1; \ + _argvec[2+2] = (unsigned long)arg2; \ + _argvec[2+3] = (unsigned long)arg3; \ + _argvec[2+4] = (unsigned long)arg4; \ + _argvec[2+5] = (unsigned long)arg5; \ + _argvec[2+6] = (unsigned long)arg6; \ + _argvec[2+7] = (unsigned long)arg7; \ + _argvec[2+8] = (unsigned long)arg8; \ + _argvec[2+9] = (unsigned long)arg9; \ + _argvec[2+10] = (unsigned long)arg10; \ + _argvec[2+11] = (unsigned long)arg11; \ + __asm__ volatile( \ + "mr 11,%1\n\t" \ + "std 2,-16(11)\n\t" /* save tocptr */ \ + "ld 2,-8(11)\n\t" /* use nraddr's tocptr */ \ + "addi 1,1,-144\n\t" /* expand stack frame */ \ + /* arg11 */ \ + "ld 3,88(11)\n\t" \ + "std 3,128(1)\n\t" \ + /* arg10 */ \ + "ld 3,80(11)\n\t" \ + "std 3,120(1)\n\t" \ + /* arg9 */ \ + "ld 3,72(11)\n\t" \ + "std 3,112(1)\n\t" \ + /* args1-8 */ \ + "ld 3, 8(11)\n\t" /* arg1->r3 */ \ + "ld 4, 16(11)\n\t" /* arg2->r4 */ \ + "ld 5, 24(11)\n\t" /* arg3->r5 */ \ + "ld 6, 32(11)\n\t" /* arg4->r6 */ \ + "ld 7, 40(11)\n\t" /* arg5->r7 */ \ + "ld 8, 48(11)\n\t" /* arg6->r8 */ \ + "ld 9, 56(11)\n\t" /* arg7->r9 */ \ + "ld 10, 64(11)\n\t" /* arg8->r10 */ \ + "ld 11, 0(11)\n\t" /* target->r11 */ \ + VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11 \ + "mr 11,%1\n\t" \ + "mr %0,3\n\t" \ + "ld 2,-16(11)\n\t" /* restore tocptr */ \ + "addi 1,1,144" /* restore frame */ \ + : /*out*/ "=r" (_res) \ + : /*in*/ "r" (&_argvec[2]) \ + : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \ + ); \ + lval = (__typeof__(lval)) _res; \ + } while (0) + +#define CALL_FN_W_12W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6, \ + arg7,arg8,arg9,arg10,arg11,arg12) \ + do { \ + volatile OrigFn _orig = (orig); \ + volatile unsigned long _argvec[3+12]; \ + volatile unsigned long _res; \ + /* _argvec[0] holds current r2 across the call */ \ + _argvec[1] = (unsigned long)_orig.r2; \ + _argvec[2] = (unsigned long)_orig.nraddr; \ + _argvec[2+1] = (unsigned long)arg1; \ + _argvec[2+2] = (unsigned long)arg2; \ + _argvec[2+3] = (unsigned long)arg3; \ + _argvec[2+4] = (unsigned long)arg4; \ + _argvec[2+5] = (unsigned long)arg5; \ + _argvec[2+6] = (unsigned long)arg6; \ + _argvec[2+7] = (unsigned long)arg7; \ + _argvec[2+8] = (unsigned long)arg8; \ + _argvec[2+9] = (unsigned long)arg9; \ + _argvec[2+10] = (unsigned long)arg10; \ + _argvec[2+11] = (unsigned long)arg11; \ + _argvec[2+12] = (unsigned long)arg12; \ + __asm__ volatile( \ + "mr 11,%1\n\t" \ + "std 2,-16(11)\n\t" /* save tocptr */ \ + "ld 2,-8(11)\n\t" /* use nraddr's tocptr */ \ + "addi 1,1,-144\n\t" /* expand stack frame */ \ + /* arg12 */ \ + "ld 3,96(11)\n\t" \ + "std 3,136(1)\n\t" \ + /* arg11 */ \ + "ld 3,88(11)\n\t" \ + "std 3,128(1)\n\t" \ + /* arg10 */ \ + "ld 3,80(11)\n\t" \ + "std 3,120(1)\n\t" \ + /* arg9 */ \ + "ld 3,72(11)\n\t" \ + "std 3,112(1)\n\t" \ + /* args1-8 */ \ + "ld 3, 8(11)\n\t" /* arg1->r3 */ \ + "ld 4, 16(11)\n\t" /* arg2->r4 */ \ + "ld 5, 24(11)\n\t" /* arg3->r5 */ \ + "ld 6, 32(11)\n\t" /* arg4->r6 */ \ + "ld 7, 40(11)\n\t" /* arg5->r7 */ \ + "ld 8, 48(11)\n\t" /* arg6->r8 */ \ + "ld 9, 56(11)\n\t" /* arg7->r9 */ \ + "ld 10, 64(11)\n\t" /* arg8->r10 */ \ + "ld 11, 0(11)\n\t" /* target->r11 */ \ + VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11 \ + "mr 11,%1\n\t" \ + "mr %0,3\n\t" \ + "ld 2,-16(11)\n\t" /* restore tocptr */ \ + "addi 1,1,144" /* restore frame */ \ + : /*out*/ "=r" (_res) \ + : /*in*/ "r" (&_argvec[2]) \ + : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \ + ); \ + lval = (__typeof__(lval)) _res; \ + } while (0) + +#endif /* PLAT_ppc64_linux */ + +/* ------------------------ ppc32-aix5 ------------------------- */ + +#if defined(PLAT_ppc32_aix5) + +/* ARGREGS: r3 r4 r5 r6 r7 r8 r9 r10 (the rest on stack somewhere) */ + +/* These regs are trashed by the hidden call. */ +#define __CALLER_SAVED_REGS \ + "lr", "ctr", "xer", \ + "cr0", "cr1", "cr2", "cr3", "cr4", "cr5", "cr6", "cr7", \ + "r0", "r2", "r3", "r4", "r5", "r6", "r7", "r8", "r9", "r10", \ + "r11", "r12", "r13" + +/* Expand the stack frame, copying enough info that unwinding + still works. Trashes r3. */ + +#define VG_EXPAND_FRAME_BY_trashes_r3(_n_fr) \ + "addi 1,1,-" #_n_fr "\n\t" \ + "lwz 3," #_n_fr "(1)\n\t" \ + "stw 3,0(1)\n\t" + +#define VG_CONTRACT_FRAME_BY(_n_fr) \ + "addi 1,1," #_n_fr "\n\t" + +/* These CALL_FN_ macros assume that on ppc32-aix5, sizeof(unsigned + long) == 4. */ + +#define CALL_FN_W_v(lval, orig) \ + do { \ + volatile OrigFn _orig = (orig); \ + volatile unsigned long _argvec[3+0]; \ + volatile unsigned long _res; \ + /* _argvec[0] holds current r2 across the call */ \ + _argvec[1] = (unsigned long)_orig.r2; \ + _argvec[2] = (unsigned long)_orig.nraddr; \ + __asm__ volatile( \ + "mr 11,%1\n\t" \ + VG_EXPAND_FRAME_BY_trashes_r3(512) \ + "stw 2,-8(11)\n\t" /* save tocptr */ \ + "lwz 2,-4(11)\n\t" /* use nraddr's tocptr */ \ + "lwz 11, 0(11)\n\t" /* target->r11 */ \ + VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11 \ + "mr 11,%1\n\t" \ + "mr %0,3\n\t" \ + "lwz 2,-8(11)\n\t" /* restore tocptr */ \ + VG_CONTRACT_FRAME_BY(512) \ + : /*out*/ "=r" (_res) \ + : /*in*/ "r" (&_argvec[2]) \ + : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \ + ); \ + lval = (__typeof__(lval)) _res; \ + } while (0) + +#define CALL_FN_W_W(lval, orig, arg1) \ + do { \ + volatile OrigFn _orig = (orig); \ + volatile unsigned long _argvec[3+1]; \ + volatile unsigned long _res; \ + /* _argvec[0] holds current r2 across the call */ \ + _argvec[1] = (unsigned long)_orig.r2; \ + _argvec[2] = (unsigned long)_orig.nraddr; \ + _argvec[2+1] = (unsigned long)arg1; \ + __asm__ volatile( \ + "mr 11,%1\n\t" \ + VG_EXPAND_FRAME_BY_trashes_r3(512) \ + "stw 2,-8(11)\n\t" /* save tocptr */ \ + "lwz 2,-4(11)\n\t" /* use nraddr's tocptr */ \ + "lwz 3, 4(11)\n\t" /* arg1->r3 */ \ + "lwz 11, 0(11)\n\t" /* target->r11 */ \ + VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11 \ + "mr 11,%1\n\t" \ + "mr %0,3\n\t" \ + "lwz 2,-8(11)\n\t" /* restore tocptr */ \ + VG_CONTRACT_FRAME_BY(512) \ + : /*out*/ "=r" (_res) \ + : /*in*/ "r" (&_argvec[2]) \ + : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \ + ); \ + lval = (__typeof__(lval)) _res; \ + } while (0) + +#define CALL_FN_W_WW(lval, orig, arg1,arg2) \ + do { \ + volatile OrigFn _orig = (orig); \ + volatile unsigned long _argvec[3+2]; \ + volatile unsigned long _res; \ + /* _argvec[0] holds current r2 across the call */ \ + _argvec[1] = (unsigned long)_orig.r2; \ + _argvec[2] = (unsigned long)_orig.nraddr; \ + _argvec[2+1] = (unsigned long)arg1; \ + _argvec[2+2] = (unsigned long)arg2; \ + __asm__ volatile( \ + "mr 11,%1\n\t" \ + VG_EXPAND_FRAME_BY_trashes_r3(512) \ + "stw 2,-8(11)\n\t" /* save tocptr */ \ + "lwz 2,-4(11)\n\t" /* use nraddr's tocptr */ \ + "lwz 3, 4(11)\n\t" /* arg1->r3 */ \ + "lwz 4, 8(11)\n\t" /* arg2->r4 */ \ + "lwz 11, 0(11)\n\t" /* target->r11 */ \ + VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11 \ + "mr 11,%1\n\t" \ + "mr %0,3\n\t" \ + "lwz 2,-8(11)\n\t" /* restore tocptr */ \ + VG_CONTRACT_FRAME_BY(512) \ + : /*out*/ "=r" (_res) \ + : /*in*/ "r" (&_argvec[2]) \ + : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \ + ); \ + lval = (__typeof__(lval)) _res; \ + } while (0) + +#define CALL_FN_W_WWW(lval, orig, arg1,arg2,arg3) \ + do { \ + volatile OrigFn _orig = (orig); \ + volatile unsigned long _argvec[3+3]; \ + volatile unsigned long _res; \ + /* _argvec[0] holds current r2 across the call */ \ + _argvec[1] = (unsigned long)_orig.r2; \ + _argvec[2] = (unsigned long)_orig.nraddr; \ + _argvec[2+1] = (unsigned long)arg1; \ + _argvec[2+2] = (unsigned long)arg2; \ + _argvec[2+3] = (unsigned long)arg3; \ + __asm__ volatile( \ + "mr 11,%1\n\t" \ + VG_EXPAND_FRAME_BY_trashes_r3(512) \ + "stw 2,-8(11)\n\t" /* save tocptr */ \ + "lwz 2,-4(11)\n\t" /* use nraddr's tocptr */ \ + "lwz 3, 4(11)\n\t" /* arg1->r3 */ \ + "lwz 4, 8(11)\n\t" /* arg2->r4 */ \ + "lwz 5, 12(11)\n\t" /* arg3->r5 */ \ + "lwz 11, 0(11)\n\t" /* target->r11 */ \ + VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11 \ + "mr 11,%1\n\t" \ + "mr %0,3\n\t" \ + "lwz 2,-8(11)\n\t" /* restore tocptr */ \ + VG_CONTRACT_FRAME_BY(512) \ + : /*out*/ "=r" (_res) \ + : /*in*/ "r" (&_argvec[2]) \ + : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \ + ); \ + lval = (__typeof__(lval)) _res; \ + } while (0) + +#define CALL_FN_W_WWWW(lval, orig, arg1,arg2,arg3,arg4) \ + do { \ + volatile OrigFn _orig = (orig); \ + volatile unsigned long _argvec[3+4]; \ + volatile unsigned long _res; \ + /* _argvec[0] holds current r2 across the call */ \ + _argvec[1] = (unsigned long)_orig.r2; \ + _argvec[2] = (unsigned long)_orig.nraddr; \ + _argvec[2+1] = (unsigned long)arg1; \ + _argvec[2+2] = (unsigned long)arg2; \ + _argvec[2+3] = (unsigned long)arg3; \ + _argvec[2+4] = (unsigned long)arg4; \ + __asm__ volatile( \ + "mr 11,%1\n\t" \ + VG_EXPAND_FRAME_BY_trashes_r3(512) \ + "stw 2,-8(11)\n\t" /* save tocptr */ \ + "lwz 2,-4(11)\n\t" /* use nraddr's tocptr */ \ + "lwz 3, 4(11)\n\t" /* arg1->r3 */ \ + "lwz 4, 8(11)\n\t" /* arg2->r4 */ \ + "lwz 5, 12(11)\n\t" /* arg3->r5 */ \ + "lwz 6, 16(11)\n\t" /* arg4->r6 */ \ + "lwz 11, 0(11)\n\t" /* target->r11 */ \ + VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11 \ + "mr 11,%1\n\t" \ + "mr %0,3\n\t" \ + "lwz 2,-8(11)\n\t" /* restore tocptr */ \ + VG_CONTRACT_FRAME_BY(512) \ + : /*out*/ "=r" (_res) \ + : /*in*/ "r" (&_argvec[2]) \ + : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \ + ); \ + lval = (__typeof__(lval)) _res; \ + } while (0) + +#define CALL_FN_W_5W(lval, orig, arg1,arg2,arg3,arg4,arg5) \ + do { \ + volatile OrigFn _orig = (orig); \ + volatile unsigned long _argvec[3+5]; \ + volatile unsigned long _res; \ + /* _argvec[0] holds current r2 across the call */ \ + _argvec[1] = (unsigned long)_orig.r2; \ + _argvec[2] = (unsigned long)_orig.nraddr; \ + _argvec[2+1] = (unsigned long)arg1; \ + _argvec[2+2] = (unsigned long)arg2; \ + _argvec[2+3] = (unsigned long)arg3; \ + _argvec[2+4] = (unsigned long)arg4; \ + _argvec[2+5] = (unsigned long)arg5; \ + __asm__ volatile( \ + "mr 11,%1\n\t" \ + VG_EXPAND_FRAME_BY_trashes_r3(512) \ + "stw 2,-8(11)\n\t" /* save tocptr */ \ + "lwz 2,-4(11)\n\t" /* use nraddr's tocptr */ \ + "lwz 3, 4(11)\n\t" /* arg1->r3 */ \ + "lwz 4, 8(11)\n\t" /* arg2->r4 */ \ + "lwz 5, 12(11)\n\t" /* arg3->r5 */ \ + "lwz 6, 16(11)\n\t" /* arg4->r6 */ \ + "lwz 7, 20(11)\n\t" /* arg5->r7 */ \ + "lwz 11, 0(11)\n\t" /* target->r11 */ \ + VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11 \ + "mr 11,%1\n\t" \ + "mr %0,3\n\t" \ + "lwz 2,-8(11)\n\t" /* restore tocptr */ \ + VG_CONTRACT_FRAME_BY(512) \ + : /*out*/ "=r" (_res) \ + : /*in*/ "r" (&_argvec[2]) \ + : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \ + ); \ + lval = (__typeof__(lval)) _res; \ + } while (0) + +#define CALL_FN_W_6W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6) \ + do { \ + volatile OrigFn _orig = (orig); \ + volatile unsigned long _argvec[3+6]; \ + volatile unsigned long _res; \ + /* _argvec[0] holds current r2 across the call */ \ + _argvec[1] = (unsigned long)_orig.r2; \ + _argvec[2] = (unsigned long)_orig.nraddr; \ + _argvec[2+1] = (unsigned long)arg1; \ + _argvec[2+2] = (unsigned long)arg2; \ + _argvec[2+3] = (unsigned long)arg3; \ + _argvec[2+4] = (unsigned long)arg4; \ + _argvec[2+5] = (unsigned long)arg5; \ + _argvec[2+6] = (unsigned long)arg6; \ + __asm__ volatile( \ + "mr 11,%1\n\t" \ + VG_EXPAND_FRAME_BY_trashes_r3(512) \ + "stw 2,-8(11)\n\t" /* save tocptr */ \ + "lwz 2,-4(11)\n\t" /* use nraddr's tocptr */ \ + "lwz 3, 4(11)\n\t" /* arg1->r3 */ \ + "lwz 4, 8(11)\n\t" /* arg2->r4 */ \ + "lwz 5, 12(11)\n\t" /* arg3->r5 */ \ + "lwz 6, 16(11)\n\t" /* arg4->r6 */ \ + "lwz 7, 20(11)\n\t" /* arg5->r7 */ \ + "lwz 8, 24(11)\n\t" /* arg6->r8 */ \ + "lwz 11, 0(11)\n\t" /* target->r11 */ \ + VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11 \ + "mr 11,%1\n\t" \ + "mr %0,3\n\t" \ + "lwz 2,-8(11)\n\t" /* restore tocptr */ \ + VG_CONTRACT_FRAME_BY(512) \ + : /*out*/ "=r" (_res) \ + : /*in*/ "r" (&_argvec[2]) \ + : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \ + ); \ + lval = (__typeof__(lval)) _res; \ + } while (0) + +#define CALL_FN_W_7W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6, \ + arg7) \ + do { \ + volatile OrigFn _orig = (orig); \ + volatile unsigned long _argvec[3+7]; \ + volatile unsigned long _res; \ + /* _argvec[0] holds current r2 across the call */ \ + _argvec[1] = (unsigned long)_orig.r2; \ + _argvec[2] = (unsigned long)_orig.nraddr; \ + _argvec[2+1] = (unsigned long)arg1; \ + _argvec[2+2] = (unsigned long)arg2; \ + _argvec[2+3] = (unsigned long)arg3; \ + _argvec[2+4] = (unsigned long)arg4; \ + _argvec[2+5] = (unsigned long)arg5; \ + _argvec[2+6] = (unsigned long)arg6; \ + _argvec[2+7] = (unsigned long)arg7; \ + __asm__ volatile( \ + "mr 11,%1\n\t" \ + VG_EXPAND_FRAME_BY_trashes_r3(512) \ + "stw 2,-8(11)\n\t" /* save tocptr */ \ + "lwz 2,-4(11)\n\t" /* use nraddr's tocptr */ \ + "lwz 3, 4(11)\n\t" /* arg1->r3 */ \ + "lwz 4, 8(11)\n\t" /* arg2->r4 */ \ + "lwz 5, 12(11)\n\t" /* arg3->r5 */ \ + "lwz 6, 16(11)\n\t" /* arg4->r6 */ \ + "lwz 7, 20(11)\n\t" /* arg5->r7 */ \ + "lwz 8, 24(11)\n\t" /* arg6->r8 */ \ + "lwz 9, 28(11)\n\t" /* arg7->r9 */ \ + "lwz 11, 0(11)\n\t" /* target->r11 */ \ + VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11 \ + "mr 11,%1\n\t" \ + "mr %0,3\n\t" \ + "lwz 2,-8(11)\n\t" /* restore tocptr */ \ + VG_CONTRACT_FRAME_BY(512) \ + : /*out*/ "=r" (_res) \ + : /*in*/ "r" (&_argvec[2]) \ + : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \ + ); \ + lval = (__typeof__(lval)) _res; \ + } while (0) + +#define CALL_FN_W_8W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6, \ + arg7,arg8) \ + do { \ + volatile OrigFn _orig = (orig); \ + volatile unsigned long _argvec[3+8]; \ + volatile unsigned long _res; \ + /* _argvec[0] holds current r2 across the call */ \ + _argvec[1] = (unsigned long)_orig.r2; \ + _argvec[2] = (unsigned long)_orig.nraddr; \ + _argvec[2+1] = (unsigned long)arg1; \ + _argvec[2+2] = (unsigned long)arg2; \ + _argvec[2+3] = (unsigned long)arg3; \ + _argvec[2+4] = (unsigned long)arg4; \ + _argvec[2+5] = (unsigned long)arg5; \ + _argvec[2+6] = (unsigned long)arg6; \ + _argvec[2+7] = (unsigned long)arg7; \ + _argvec[2+8] = (unsigned long)arg8; \ + __asm__ volatile( \ + "mr 11,%1\n\t" \ + VG_EXPAND_FRAME_BY_trashes_r3(512) \ + "stw 2,-8(11)\n\t" /* save tocptr */ \ + "lwz 2,-4(11)\n\t" /* use nraddr's tocptr */ \ + "lwz 3, 4(11)\n\t" /* arg1->r3 */ \ + "lwz 4, 8(11)\n\t" /* arg2->r4 */ \ + "lwz 5, 12(11)\n\t" /* arg3->r5 */ \ + "lwz 6, 16(11)\n\t" /* arg4->r6 */ \ + "lwz 7, 20(11)\n\t" /* arg5->r7 */ \ + "lwz 8, 24(11)\n\t" /* arg6->r8 */ \ + "lwz 9, 28(11)\n\t" /* arg7->r9 */ \ + "lwz 10, 32(11)\n\t" /* arg8->r10 */ \ + "lwz 11, 0(11)\n\t" /* target->r11 */ \ + VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11 \ + "mr 11,%1\n\t" \ + "mr %0,3\n\t" \ + "lwz 2,-8(11)\n\t" /* restore tocptr */ \ + VG_CONTRACT_FRAME_BY(512) \ + : /*out*/ "=r" (_res) \ + : /*in*/ "r" (&_argvec[2]) \ + : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \ + ); \ + lval = (__typeof__(lval)) _res; \ + } while (0) + +#define CALL_FN_W_9W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6, \ + arg7,arg8,arg9) \ + do { \ + volatile OrigFn _orig = (orig); \ + volatile unsigned long _argvec[3+9]; \ + volatile unsigned long _res; \ + /* _argvec[0] holds current r2 across the call */ \ + _argvec[1] = (unsigned long)_orig.r2; \ + _argvec[2] = (unsigned long)_orig.nraddr; \ + _argvec[2+1] = (unsigned long)arg1; \ + _argvec[2+2] = (unsigned long)arg2; \ + _argvec[2+3] = (unsigned long)arg3; \ + _argvec[2+4] = (unsigned long)arg4; \ + _argvec[2+5] = (unsigned long)arg5; \ + _argvec[2+6] = (unsigned long)arg6; \ + _argvec[2+7] = (unsigned long)arg7; \ + _argvec[2+8] = (unsigned long)arg8; \ + _argvec[2+9] = (unsigned long)arg9; \ + __asm__ volatile( \ + "mr 11,%1\n\t" \ + VG_EXPAND_FRAME_BY_trashes_r3(512) \ + "stw 2,-8(11)\n\t" /* save tocptr */ \ + "lwz 2,-4(11)\n\t" /* use nraddr's tocptr */ \ + VG_EXPAND_FRAME_BY_trashes_r3(64) \ + /* arg9 */ \ + "lwz 3,36(11)\n\t" \ + "stw 3,56(1)\n\t" \ + /* args1-8 */ \ + "lwz 3, 4(11)\n\t" /* arg1->r3 */ \ + "lwz 4, 8(11)\n\t" /* arg2->r4 */ \ + "lwz 5, 12(11)\n\t" /* arg3->r5 */ \ + "lwz 6, 16(11)\n\t" /* arg4->r6 */ \ + "lwz 7, 20(11)\n\t" /* arg5->r7 */ \ + "lwz 8, 24(11)\n\t" /* arg6->r8 */ \ + "lwz 9, 28(11)\n\t" /* arg7->r9 */ \ + "lwz 10, 32(11)\n\t" /* arg8->r10 */ \ + "lwz 11, 0(11)\n\t" /* target->r11 */ \ + VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11 \ + "mr 11,%1\n\t" \ + "mr %0,3\n\t" \ + "lwz 2,-8(11)\n\t" /* restore tocptr */ \ + VG_CONTRACT_FRAME_BY(64) \ + VG_CONTRACT_FRAME_BY(512) \ + : /*out*/ "=r" (_res) \ + : /*in*/ "r" (&_argvec[2]) \ + : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \ + ); \ + lval = (__typeof__(lval)) _res; \ + } while (0) + +#define CALL_FN_W_10W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6, \ + arg7,arg8,arg9,arg10) \ + do { \ + volatile OrigFn _orig = (orig); \ + volatile unsigned long _argvec[3+10]; \ + volatile unsigned long _res; \ + /* _argvec[0] holds current r2 across the call */ \ + _argvec[1] = (unsigned long)_orig.r2; \ + _argvec[2] = (unsigned long)_orig.nraddr; \ + _argvec[2+1] = (unsigned long)arg1; \ + _argvec[2+2] = (unsigned long)arg2; \ + _argvec[2+3] = (unsigned long)arg3; \ + _argvec[2+4] = (unsigned long)arg4; \ + _argvec[2+5] = (unsigned long)arg5; \ + _argvec[2+6] = (unsigned long)arg6; \ + _argvec[2+7] = (unsigned long)arg7; \ + _argvec[2+8] = (unsigned long)arg8; \ + _argvec[2+9] = (unsigned long)arg9; \ + _argvec[2+10] = (unsigned long)arg10; \ + __asm__ volatile( \ + "mr 11,%1\n\t" \ + VG_EXPAND_FRAME_BY_trashes_r3(512) \ + "stw 2,-8(11)\n\t" /* save tocptr */ \ + "lwz 2,-4(11)\n\t" /* use nraddr's tocptr */ \ + VG_EXPAND_FRAME_BY_trashes_r3(64) \ + /* arg10 */ \ + "lwz 3,40(11)\n\t" \ + "stw 3,60(1)\n\t" \ + /* arg9 */ \ + "lwz 3,36(11)\n\t" \ + "stw 3,56(1)\n\t" \ + /* args1-8 */ \ + "lwz 3, 4(11)\n\t" /* arg1->r3 */ \ + "lwz 4, 8(11)\n\t" /* arg2->r4 */ \ + "lwz 5, 12(11)\n\t" /* arg3->r5 */ \ + "lwz 6, 16(11)\n\t" /* arg4->r6 */ \ + "lwz 7, 20(11)\n\t" /* arg5->r7 */ \ + "lwz 8, 24(11)\n\t" /* arg6->r8 */ \ + "lwz 9, 28(11)\n\t" /* arg7->r9 */ \ + "lwz 10, 32(11)\n\t" /* arg8->r10 */ \ + "lwz 11, 0(11)\n\t" /* target->r11 */ \ + VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11 \ + "mr 11,%1\n\t" \ + "mr %0,3\n\t" \ + "lwz 2,-8(11)\n\t" /* restore tocptr */ \ + VG_CONTRACT_FRAME_BY(64) \ + VG_CONTRACT_FRAME_BY(512) \ + : /*out*/ "=r" (_res) \ + : /*in*/ "r" (&_argvec[2]) \ + : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \ + ); \ + lval = (__typeof__(lval)) _res; \ + } while (0) + +#define CALL_FN_W_11W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6, \ + arg7,arg8,arg9,arg10,arg11) \ + do { \ + volatile OrigFn _orig = (orig); \ + volatile unsigned long _argvec[3+11]; \ + volatile unsigned long _res; \ + /* _argvec[0] holds current r2 across the call */ \ + _argvec[1] = (unsigned long)_orig.r2; \ + _argvec[2] = (unsigned long)_orig.nraddr; \ + _argvec[2+1] = (unsigned long)arg1; \ + _argvec[2+2] = (unsigned long)arg2; \ + _argvec[2+3] = (unsigned long)arg3; \ + _argvec[2+4] = (unsigned long)arg4; \ + _argvec[2+5] = (unsigned long)arg5; \ + _argvec[2+6] = (unsigned long)arg6; \ + _argvec[2+7] = (unsigned long)arg7; \ + _argvec[2+8] = (unsigned long)arg8; \ + _argvec[2+9] = (unsigned long)arg9; \ + _argvec[2+10] = (unsigned long)arg10; \ + _argvec[2+11] = (unsigned long)arg11; \ + __asm__ volatile( \ + "mr 11,%1\n\t" \ + VG_EXPAND_FRAME_BY_trashes_r3(512) \ + "stw 2,-8(11)\n\t" /* save tocptr */ \ + "lwz 2,-4(11)\n\t" /* use nraddr's tocptr */ \ + VG_EXPAND_FRAME_BY_trashes_r3(72) \ + /* arg11 */ \ + "lwz 3,44(11)\n\t" \ + "stw 3,64(1)\n\t" \ + /* arg10 */ \ + "lwz 3,40(11)\n\t" \ + "stw 3,60(1)\n\t" \ + /* arg9 */ \ + "lwz 3,36(11)\n\t" \ + "stw 3,56(1)\n\t" \ + /* args1-8 */ \ + "lwz 3, 4(11)\n\t" /* arg1->r3 */ \ + "lwz 4, 8(11)\n\t" /* arg2->r4 */ \ + "lwz 5, 12(11)\n\t" /* arg3->r5 */ \ + "lwz 6, 16(11)\n\t" /* arg4->r6 */ \ + "lwz 7, 20(11)\n\t" /* arg5->r7 */ \ + "lwz 8, 24(11)\n\t" /* arg6->r8 */ \ + "lwz 9, 28(11)\n\t" /* arg7->r9 */ \ + "lwz 10, 32(11)\n\t" /* arg8->r10 */ \ + "lwz 11, 0(11)\n\t" /* target->r11 */ \ + VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11 \ + "mr 11,%1\n\t" \ + "mr %0,3\n\t" \ + "lwz 2,-8(11)\n\t" /* restore tocptr */ \ + VG_CONTRACT_FRAME_BY(72) \ + VG_CONTRACT_FRAME_BY(512) \ + : /*out*/ "=r" (_res) \ + : /*in*/ "r" (&_argvec[2]) \ + : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \ + ); \ + lval = (__typeof__(lval)) _res; \ + } while (0) + +#define CALL_FN_W_12W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6, \ + arg7,arg8,arg9,arg10,arg11,arg12) \ + do { \ + volatile OrigFn _orig = (orig); \ + volatile unsigned long _argvec[3+12]; \ + volatile unsigned long _res; \ + /* _argvec[0] holds current r2 across the call */ \ + _argvec[1] = (unsigned long)_orig.r2; \ + _argvec[2] = (unsigned long)_orig.nraddr; \ + _argvec[2+1] = (unsigned long)arg1; \ + _argvec[2+2] = (unsigned long)arg2; \ + _argvec[2+3] = (unsigned long)arg3; \ + _argvec[2+4] = (unsigned long)arg4; \ + _argvec[2+5] = (unsigned long)arg5; \ + _argvec[2+6] = (unsigned long)arg6; \ + _argvec[2+7] = (unsigned long)arg7; \ + _argvec[2+8] = (unsigned long)arg8; \ + _argvec[2+9] = (unsigned long)arg9; \ + _argvec[2+10] = (unsigned long)arg10; \ + _argvec[2+11] = (unsigned long)arg11; \ + _argvec[2+12] = (unsigned long)arg12; \ + __asm__ volatile( \ + "mr 11,%1\n\t" \ + VG_EXPAND_FRAME_BY_trashes_r3(512) \ + "stw 2,-8(11)\n\t" /* save tocptr */ \ + "lwz 2,-4(11)\n\t" /* use nraddr's tocptr */ \ + VG_EXPAND_FRAME_BY_trashes_r3(72) \ + /* arg12 */ \ + "lwz 3,48(11)\n\t" \ + "stw 3,68(1)\n\t" \ + /* arg11 */ \ + "lwz 3,44(11)\n\t" \ + "stw 3,64(1)\n\t" \ + /* arg10 */ \ + "lwz 3,40(11)\n\t" \ + "stw 3,60(1)\n\t" \ + /* arg9 */ \ + "lwz 3,36(11)\n\t" \ + "stw 3,56(1)\n\t" \ + /* args1-8 */ \ + "lwz 3, 4(11)\n\t" /* arg1->r3 */ \ + "lwz 4, 8(11)\n\t" /* arg2->r4 */ \ + "lwz 5, 12(11)\n\t" /* arg3->r5 */ \ + "lwz 6, 16(11)\n\t" /* arg4->r6 */ \ + "lwz 7, 20(11)\n\t" /* arg5->r7 */ \ + "lwz 8, 24(11)\n\t" /* arg6->r8 */ \ + "lwz 9, 28(11)\n\t" /* arg7->r9 */ \ + "lwz 10, 32(11)\n\t" /* arg8->r10 */ \ + "lwz 11, 0(11)\n\t" /* target->r11 */ \ + VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11 \ + "mr 11,%1\n\t" \ + "mr %0,3\n\t" \ + "lwz 2,-8(11)\n\t" /* restore tocptr */ \ + VG_CONTRACT_FRAME_BY(72) \ + VG_CONTRACT_FRAME_BY(512) \ + : /*out*/ "=r" (_res) \ + : /*in*/ "r" (&_argvec[2]) \ + : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \ + ); \ + lval = (__typeof__(lval)) _res; \ + } while (0) + +#endif /* PLAT_ppc32_aix5 */ + +/* ------------------------ ppc64-aix5 ------------------------- */ + +#if defined(PLAT_ppc64_aix5) + +/* ARGREGS: r3 r4 r5 r6 r7 r8 r9 r10 (the rest on stack somewhere) */ + +/* These regs are trashed by the hidden call. */ +#define __CALLER_SAVED_REGS \ + "lr", "ctr", "xer", \ + "cr0", "cr1", "cr2", "cr3", "cr4", "cr5", "cr6", "cr7", \ + "r0", "r2", "r3", "r4", "r5", "r6", "r7", "r8", "r9", "r10", \ + "r11", "r12", "r13" + +/* Expand the stack frame, copying enough info that unwinding + still works. Trashes r3. */ + +#define VG_EXPAND_FRAME_BY_trashes_r3(_n_fr) \ + "addi 1,1,-" #_n_fr "\n\t" \ + "ld 3," #_n_fr "(1)\n\t" \ + "std 3,0(1)\n\t" + +#define VG_CONTRACT_FRAME_BY(_n_fr) \ + "addi 1,1," #_n_fr "\n\t" + +/* These CALL_FN_ macros assume that on ppc64-aix5, sizeof(unsigned + long) == 8. */ + +#define CALL_FN_W_v(lval, orig) \ + do { \ + volatile OrigFn _orig = (orig); \ + volatile unsigned long _argvec[3+0]; \ + volatile unsigned long _res; \ + /* _argvec[0] holds current r2 across the call */ \ + _argvec[1] = (unsigned long)_orig.r2; \ + _argvec[2] = (unsigned long)_orig.nraddr; \ + __asm__ volatile( \ + "mr 11,%1\n\t" \ + VG_EXPAND_FRAME_BY_trashes_r3(512) \ + "std 2,-16(11)\n\t" /* save tocptr */ \ + "ld 2,-8(11)\n\t" /* use nraddr's tocptr */ \ + "ld 11, 0(11)\n\t" /* target->r11 */ \ + VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11 \ + "mr 11,%1\n\t" \ + "mr %0,3\n\t" \ + "ld 2,-16(11)\n\t" /* restore tocptr */ \ + VG_CONTRACT_FRAME_BY(512) \ + : /*out*/ "=r" (_res) \ + : /*in*/ "r" (&_argvec[2]) \ + : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \ + ); \ + lval = (__typeof__(lval)) _res; \ + } while (0) + +#define CALL_FN_W_W(lval, orig, arg1) \ + do { \ + volatile OrigFn _orig = (orig); \ + volatile unsigned long _argvec[3+1]; \ + volatile unsigned long _res; \ + /* _argvec[0] holds current r2 across the call */ \ + _argvec[1] = (unsigned long)_orig.r2; \ + _argvec[2] = (unsigned long)_orig.nraddr; \ + _argvec[2+1] = (unsigned long)arg1; \ + __asm__ volatile( \ + "mr 11,%1\n\t" \ + VG_EXPAND_FRAME_BY_trashes_r3(512) \ + "std 2,-16(11)\n\t" /* save tocptr */ \ + "ld 2,-8(11)\n\t" /* use nraddr's tocptr */ \ + "ld 3, 8(11)\n\t" /* arg1->r3 */ \ + "ld 11, 0(11)\n\t" /* target->r11 */ \ + VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11 \ + "mr 11,%1\n\t" \ + "mr %0,3\n\t" \ + "ld 2,-16(11)\n\t" /* restore tocptr */ \ + VG_CONTRACT_FRAME_BY(512) \ + : /*out*/ "=r" (_res) \ + : /*in*/ "r" (&_argvec[2]) \ + : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \ + ); \ + lval = (__typeof__(lval)) _res; \ + } while (0) + +#define CALL_FN_W_WW(lval, orig, arg1,arg2) \ + do { \ + volatile OrigFn _orig = (orig); \ + volatile unsigned long _argvec[3+2]; \ + volatile unsigned long _res; \ + /* _argvec[0] holds current r2 across the call */ \ + _argvec[1] = (unsigned long)_orig.r2; \ + _argvec[2] = (unsigned long)_orig.nraddr; \ + _argvec[2+1] = (unsigned long)arg1; \ + _argvec[2+2] = (unsigned long)arg2; \ + __asm__ volatile( \ + "mr 11,%1\n\t" \ + VG_EXPAND_FRAME_BY_trashes_r3(512) \ + "std 2,-16(11)\n\t" /* save tocptr */ \ + "ld 2,-8(11)\n\t" /* use nraddr's tocptr */ \ + "ld 3, 8(11)\n\t" /* arg1->r3 */ \ + "ld 4, 16(11)\n\t" /* arg2->r4 */ \ + "ld 11, 0(11)\n\t" /* target->r11 */ \ + VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11 \ + "mr 11,%1\n\t" \ + "mr %0,3\n\t" \ + "ld 2,-16(11)\n\t" /* restore tocptr */ \ + VG_CONTRACT_FRAME_BY(512) \ + : /*out*/ "=r" (_res) \ + : /*in*/ "r" (&_argvec[2]) \ + : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \ + ); \ + lval = (__typeof__(lval)) _res; \ + } while (0) + +#define CALL_FN_W_WWW(lval, orig, arg1,arg2,arg3) \ + do { \ + volatile OrigFn _orig = (orig); \ + volatile unsigned long _argvec[3+3]; \ + volatile unsigned long _res; \ + /* _argvec[0] holds current r2 across the call */ \ + _argvec[1] = (unsigned long)_orig.r2; \ + _argvec[2] = (unsigned long)_orig.nraddr; \ + _argvec[2+1] = (unsigned long)arg1; \ + _argvec[2+2] = (unsigned long)arg2; \ + _argvec[2+3] = (unsigned long)arg3; \ + __asm__ volatile( \ + "mr 11,%1\n\t" \ + VG_EXPAND_FRAME_BY_trashes_r3(512) \ + "std 2,-16(11)\n\t" /* save tocptr */ \ + "ld 2,-8(11)\n\t" /* use nraddr's tocptr */ \ + "ld 3, 8(11)\n\t" /* arg1->r3 */ \ + "ld 4, 16(11)\n\t" /* arg2->r4 */ \ + "ld 5, 24(11)\n\t" /* arg3->r5 */ \ + "ld 11, 0(11)\n\t" /* target->r11 */ \ + VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11 \ + "mr 11,%1\n\t" \ + "mr %0,3\n\t" \ + "ld 2,-16(11)\n\t" /* restore tocptr */ \ + VG_CONTRACT_FRAME_BY(512) \ + : /*out*/ "=r" (_res) \ + : /*in*/ "r" (&_argvec[2]) \ + : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \ + ); \ + lval = (__typeof__(lval)) _res; \ + } while (0) + +#define CALL_FN_W_WWWW(lval, orig, arg1,arg2,arg3,arg4) \ + do { \ + volatile OrigFn _orig = (orig); \ + volatile unsigned long _argvec[3+4]; \ + volatile unsigned long _res; \ + /* _argvec[0] holds current r2 across the call */ \ + _argvec[1] = (unsigned long)_orig.r2; \ + _argvec[2] = (unsigned long)_orig.nraddr; \ + _argvec[2+1] = (unsigned long)arg1; \ + _argvec[2+2] = (unsigned long)arg2; \ + _argvec[2+3] = (unsigned long)arg3; \ + _argvec[2+4] = (unsigned long)arg4; \ + __asm__ volatile( \ + "mr 11,%1\n\t" \ + VG_EXPAND_FRAME_BY_trashes_r3(512) \ + "std 2,-16(11)\n\t" /* save tocptr */ \ + "ld 2,-8(11)\n\t" /* use nraddr's tocptr */ \ + "ld 3, 8(11)\n\t" /* arg1->r3 */ \ + "ld 4, 16(11)\n\t" /* arg2->r4 */ \ + "ld 5, 24(11)\n\t" /* arg3->r5 */ \ + "ld 6, 32(11)\n\t" /* arg4->r6 */ \ + "ld 11, 0(11)\n\t" /* target->r11 */ \ + VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11 \ + "mr 11,%1\n\t" \ + "mr %0,3\n\t" \ + "ld 2,-16(11)\n\t" /* restore tocptr */ \ + VG_CONTRACT_FRAME_BY(512) \ + : /*out*/ "=r" (_res) \ + : /*in*/ "r" (&_argvec[2]) \ + : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \ + ); \ + lval = (__typeof__(lval)) _res; \ + } while (0) + +#define CALL_FN_W_5W(lval, orig, arg1,arg2,arg3,arg4,arg5) \ + do { \ + volatile OrigFn _orig = (orig); \ + volatile unsigned long _argvec[3+5]; \ + volatile unsigned long _res; \ + /* _argvec[0] holds current r2 across the call */ \ + _argvec[1] = (unsigned long)_orig.r2; \ + _argvec[2] = (unsigned long)_orig.nraddr; \ + _argvec[2+1] = (unsigned long)arg1; \ + _argvec[2+2] = (unsigned long)arg2; \ + _argvec[2+3] = (unsigned long)arg3; \ + _argvec[2+4] = (unsigned long)arg4; \ + _argvec[2+5] = (unsigned long)arg5; \ + __asm__ volatile( \ + "mr 11,%1\n\t" \ + VG_EXPAND_FRAME_BY_trashes_r3(512) \ + "std 2,-16(11)\n\t" /* save tocptr */ \ + "ld 2,-8(11)\n\t" /* use nraddr's tocptr */ \ + "ld 3, 8(11)\n\t" /* arg1->r3 */ \ + "ld 4, 16(11)\n\t" /* arg2->r4 */ \ + "ld 5, 24(11)\n\t" /* arg3->r5 */ \ + "ld 6, 32(11)\n\t" /* arg4->r6 */ \ + "ld 7, 40(11)\n\t" /* arg5->r7 */ \ + "ld 11, 0(11)\n\t" /* target->r11 */ \ + VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11 \ + "mr 11,%1\n\t" \ + "mr %0,3\n\t" \ + "ld 2,-16(11)\n\t" /* restore tocptr */ \ + VG_CONTRACT_FRAME_BY(512) \ + : /*out*/ "=r" (_res) \ + : /*in*/ "r" (&_argvec[2]) \ + : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \ + ); \ + lval = (__typeof__(lval)) _res; \ + } while (0) + +#define CALL_FN_W_6W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6) \ + do { \ + volatile OrigFn _orig = (orig); \ + volatile unsigned long _argvec[3+6]; \ + volatile unsigned long _res; \ + /* _argvec[0] holds current r2 across the call */ \ + _argvec[1] = (unsigned long)_orig.r2; \ + _argvec[2] = (unsigned long)_orig.nraddr; \ + _argvec[2+1] = (unsigned long)arg1; \ + _argvec[2+2] = (unsigned long)arg2; \ + _argvec[2+3] = (unsigned long)arg3; \ + _argvec[2+4] = (unsigned long)arg4; \ + _argvec[2+5] = (unsigned long)arg5; \ + _argvec[2+6] = (unsigned long)arg6; \ + __asm__ volatile( \ + "mr 11,%1\n\t" \ + VG_EXPAND_FRAME_BY_trashes_r3(512) \ + "std 2,-16(11)\n\t" /* save tocptr */ \ + "ld 2,-8(11)\n\t" /* use nraddr's tocptr */ \ + "ld 3, 8(11)\n\t" /* arg1->r3 */ \ + "ld 4, 16(11)\n\t" /* arg2->r4 */ \ + "ld 5, 24(11)\n\t" /* arg3->r5 */ \ + "ld 6, 32(11)\n\t" /* arg4->r6 */ \ + "ld 7, 40(11)\n\t" /* arg5->r7 */ \ + "ld 8, 48(11)\n\t" /* arg6->r8 */ \ + "ld 11, 0(11)\n\t" /* target->r11 */ \ + VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11 \ + "mr 11,%1\n\t" \ + "mr %0,3\n\t" \ + "ld 2,-16(11)\n\t" /* restore tocptr */ \ + VG_CONTRACT_FRAME_BY(512) \ + : /*out*/ "=r" (_res) \ + : /*in*/ "r" (&_argvec[2]) \ + : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \ + ); \ + lval = (__typeof__(lval)) _res; \ + } while (0) + +#define CALL_FN_W_7W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6, \ + arg7) \ + do { \ + volatile OrigFn _orig = (orig); \ + volatile unsigned long _argvec[3+7]; \ + volatile unsigned long _res; \ + /* _argvec[0] holds current r2 across the call */ \ + _argvec[1] = (unsigned long)_orig.r2; \ + _argvec[2] = (unsigned long)_orig.nraddr; \ + _argvec[2+1] = (unsigned long)arg1; \ + _argvec[2+2] = (unsigned long)arg2; \ + _argvec[2+3] = (unsigned long)arg3; \ + _argvec[2+4] = (unsigned long)arg4; \ + _argvec[2+5] = (unsigned long)arg5; \ + _argvec[2+6] = (unsigned long)arg6; \ + _argvec[2+7] = (unsigned long)arg7; \ + __asm__ volatile( \ + "mr 11,%1\n\t" \ + VG_EXPAND_FRAME_BY_trashes_r3(512) \ + "std 2,-16(11)\n\t" /* save tocptr */ \ + "ld 2,-8(11)\n\t" /* use nraddr's tocptr */ \ + "ld 3, 8(11)\n\t" /* arg1->r3 */ \ + "ld 4, 16(11)\n\t" /* arg2->r4 */ \ + "ld 5, 24(11)\n\t" /* arg3->r5 */ \ + "ld 6, 32(11)\n\t" /* arg4->r6 */ \ + "ld 7, 40(11)\n\t" /* arg5->r7 */ \ + "ld 8, 48(11)\n\t" /* arg6->r8 */ \ + "ld 9, 56(11)\n\t" /* arg7->r9 */ \ + "ld 11, 0(11)\n\t" /* target->r11 */ \ + VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11 \ + "mr 11,%1\n\t" \ + "mr %0,3\n\t" \ + "ld 2,-16(11)\n\t" /* restore tocptr */ \ + VG_CONTRACT_FRAME_BY(512) \ + : /*out*/ "=r" (_res) \ + : /*in*/ "r" (&_argvec[2]) \ + : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \ + ); \ + lval = (__typeof__(lval)) _res; \ + } while (0) + +#define CALL_FN_W_8W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6, \ + arg7,arg8) \ + do { \ + volatile OrigFn _orig = (orig); \ + volatile unsigned long _argvec[3+8]; \ + volatile unsigned long _res; \ + /* _argvec[0] holds current r2 across the call */ \ + _argvec[1] = (unsigned long)_orig.r2; \ + _argvec[2] = (unsigned long)_orig.nraddr; \ + _argvec[2+1] = (unsigned long)arg1; \ + _argvec[2+2] = (unsigned long)arg2; \ + _argvec[2+3] = (unsigned long)arg3; \ + _argvec[2+4] = (unsigned long)arg4; \ + _argvec[2+5] = (unsigned long)arg5; \ + _argvec[2+6] = (unsigned long)arg6; \ + _argvec[2+7] = (unsigned long)arg7; \ + _argvec[2+8] = (unsigned long)arg8; \ + __asm__ volatile( \ + "mr 11,%1\n\t" \ + VG_EXPAND_FRAME_BY_trashes_r3(512) \ + "std 2,-16(11)\n\t" /* save tocptr */ \ + "ld 2,-8(11)\n\t" /* use nraddr's tocptr */ \ + "ld 3, 8(11)\n\t" /* arg1->r3 */ \ + "ld 4, 16(11)\n\t" /* arg2->r4 */ \ + "ld 5, 24(11)\n\t" /* arg3->r5 */ \ + "ld 6, 32(11)\n\t" /* arg4->r6 */ \ + "ld 7, 40(11)\n\t" /* arg5->r7 */ \ + "ld 8, 48(11)\n\t" /* arg6->r8 */ \ + "ld 9, 56(11)\n\t" /* arg7->r9 */ \ + "ld 10, 64(11)\n\t" /* arg8->r10 */ \ + "ld 11, 0(11)\n\t" /* target->r11 */ \ + VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11 \ + "mr 11,%1\n\t" \ + "mr %0,3\n\t" \ + "ld 2,-16(11)\n\t" /* restore tocptr */ \ + VG_CONTRACT_FRAME_BY(512) \ + : /*out*/ "=r" (_res) \ + : /*in*/ "r" (&_argvec[2]) \ + : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \ + ); \ + lval = (__typeof__(lval)) _res; \ + } while (0) + +#define CALL_FN_W_9W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6, \ + arg7,arg8,arg9) \ + do { \ + volatile OrigFn _orig = (orig); \ + volatile unsigned long _argvec[3+9]; \ + volatile unsigned long _res; \ + /* _argvec[0] holds current r2 across the call */ \ + _argvec[1] = (unsigned long)_orig.r2; \ + _argvec[2] = (unsigned long)_orig.nraddr; \ + _argvec[2+1] = (unsigned long)arg1; \ + _argvec[2+2] = (unsigned long)arg2; \ + _argvec[2+3] = (unsigned long)arg3; \ + _argvec[2+4] = (unsigned long)arg4; \ + _argvec[2+5] = (unsigned long)arg5; \ + _argvec[2+6] = (unsigned long)arg6; \ + _argvec[2+7] = (unsigned long)arg7; \ + _argvec[2+8] = (unsigned long)arg8; \ + _argvec[2+9] = (unsigned long)arg9; \ + __asm__ volatile( \ + "mr 11,%1\n\t" \ + VG_EXPAND_FRAME_BY_trashes_r3(512) \ + "std 2,-16(11)\n\t" /* save tocptr */ \ + "ld 2,-8(11)\n\t" /* use nraddr's tocptr */ \ + VG_EXPAND_FRAME_BY_trashes_r3(128) \ + /* arg9 */ \ + "ld 3,72(11)\n\t" \ + "std 3,112(1)\n\t" \ + /* args1-8 */ \ + "ld 3, 8(11)\n\t" /* arg1->r3 */ \ + "ld 4, 16(11)\n\t" /* arg2->r4 */ \ + "ld 5, 24(11)\n\t" /* arg3->r5 */ \ + "ld 6, 32(11)\n\t" /* arg4->r6 */ \ + "ld 7, 40(11)\n\t" /* arg5->r7 */ \ + "ld 8, 48(11)\n\t" /* arg6->r8 */ \ + "ld 9, 56(11)\n\t" /* arg7->r9 */ \ + "ld 10, 64(11)\n\t" /* arg8->r10 */ \ + "ld 11, 0(11)\n\t" /* target->r11 */ \ + VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11 \ + "mr 11,%1\n\t" \ + "mr %0,3\n\t" \ + "ld 2,-16(11)\n\t" /* restore tocptr */ \ + VG_CONTRACT_FRAME_BY(128) \ + VG_CONTRACT_FRAME_BY(512) \ + : /*out*/ "=r" (_res) \ + : /*in*/ "r" (&_argvec[2]) \ + : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \ + ); \ + lval = (__typeof__(lval)) _res; \ + } while (0) + +#define CALL_FN_W_10W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6, \ + arg7,arg8,arg9,arg10) \ + do { \ + volatile OrigFn _orig = (orig); \ + volatile unsigned long _argvec[3+10]; \ + volatile unsigned long _res; \ + /* _argvec[0] holds current r2 across the call */ \ + _argvec[1] = (unsigned long)_orig.r2; \ + _argvec[2] = (unsigned long)_orig.nraddr; \ + _argvec[2+1] = (unsigned long)arg1; \ + _argvec[2+2] = (unsigned long)arg2; \ + _argvec[2+3] = (unsigned long)arg3; \ + _argvec[2+4] = (unsigned long)arg4; \ + _argvec[2+5] = (unsigned long)arg5; \ + _argvec[2+6] = (unsigned long)arg6; \ + _argvec[2+7] = (unsigned long)arg7; \ + _argvec[2+8] = (unsigned long)arg8; \ + _argvec[2+9] = (unsigned long)arg9; \ + _argvec[2+10] = (unsigned long)arg10; \ + __asm__ volatile( \ + "mr 11,%1\n\t" \ + VG_EXPAND_FRAME_BY_trashes_r3(512) \ + "std 2,-16(11)\n\t" /* save tocptr */ \ + "ld 2,-8(11)\n\t" /* use nraddr's tocptr */ \ + VG_EXPAND_FRAME_BY_trashes_r3(128) \ + /* arg10 */ \ + "ld 3,80(11)\n\t" \ + "std 3,120(1)\n\t" \ + /* arg9 */ \ + "ld 3,72(11)\n\t" \ + "std 3,112(1)\n\t" \ + /* args1-8 */ \ + "ld 3, 8(11)\n\t" /* arg1->r3 */ \ + "ld 4, 16(11)\n\t" /* arg2->r4 */ \ + "ld 5, 24(11)\n\t" /* arg3->r5 */ \ + "ld 6, 32(11)\n\t" /* arg4->r6 */ \ + "ld 7, 40(11)\n\t" /* arg5->r7 */ \ + "ld 8, 48(11)\n\t" /* arg6->r8 */ \ + "ld 9, 56(11)\n\t" /* arg7->r9 */ \ + "ld 10, 64(11)\n\t" /* arg8->r10 */ \ + "ld 11, 0(11)\n\t" /* target->r11 */ \ + VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11 \ + "mr 11,%1\n\t" \ + "mr %0,3\n\t" \ + "ld 2,-16(11)\n\t" /* restore tocptr */ \ + VG_CONTRACT_FRAME_BY(128) \ + VG_CONTRACT_FRAME_BY(512) \ + : /*out*/ "=r" (_res) \ + : /*in*/ "r" (&_argvec[2]) \ + : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \ + ); \ + lval = (__typeof__(lval)) _res; \ + } while (0) + +#define CALL_FN_W_11W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6, \ + arg7,arg8,arg9,arg10,arg11) \ + do { \ + volatile OrigFn _orig = (orig); \ + volatile unsigned long _argvec[3+11]; \ + volatile unsigned long _res; \ + /* _argvec[0] holds current r2 across the call */ \ + _argvec[1] = (unsigned long)_orig.r2; \ + _argvec[2] = (unsigned long)_orig.nraddr; \ + _argvec[2+1] = (unsigned long)arg1; \ + _argvec[2+2] = (unsigned long)arg2; \ + _argvec[2+3] = (unsigned long)arg3; \ + _argvec[2+4] = (unsigned long)arg4; \ + _argvec[2+5] = (unsigned long)arg5; \ + _argvec[2+6] = (unsigned long)arg6; \ + _argvec[2+7] = (unsigned long)arg7; \ + _argvec[2+8] = (unsigned long)arg8; \ + _argvec[2+9] = (unsigned long)arg9; \ + _argvec[2+10] = (unsigned long)arg10; \ + _argvec[2+11] = (unsigned long)arg11; \ + __asm__ volatile( \ + "mr 11,%1\n\t" \ + VG_EXPAND_FRAME_BY_trashes_r3(512) \ + "std 2,-16(11)\n\t" /* save tocptr */ \ + "ld 2,-8(11)\n\t" /* use nraddr's tocptr */ \ + VG_EXPAND_FRAME_BY_trashes_r3(144) \ + /* arg11 */ \ + "ld 3,88(11)\n\t" \ + "std 3,128(1)\n\t" \ + /* arg10 */ \ + "ld 3,80(11)\n\t" \ + "std 3,120(1)\n\t" \ + /* arg9 */ \ + "ld 3,72(11)\n\t" \ + "std 3,112(1)\n\t" \ + /* args1-8 */ \ + "ld 3, 8(11)\n\t" /* arg1->r3 */ \ + "ld 4, 16(11)\n\t" /* arg2->r4 */ \ + "ld 5, 24(11)\n\t" /* arg3->r5 */ \ + "ld 6, 32(11)\n\t" /* arg4->r6 */ \ + "ld 7, 40(11)\n\t" /* arg5->r7 */ \ + "ld 8, 48(11)\n\t" /* arg6->r8 */ \ + "ld 9, 56(11)\n\t" /* arg7->r9 */ \ + "ld 10, 64(11)\n\t" /* arg8->r10 */ \ + "ld 11, 0(11)\n\t" /* target->r11 */ \ + VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11 \ + "mr 11,%1\n\t" \ + "mr %0,3\n\t" \ + "ld 2,-16(11)\n\t" /* restore tocptr */ \ + VG_CONTRACT_FRAME_BY(144) \ + VG_CONTRACT_FRAME_BY(512) \ + : /*out*/ "=r" (_res) \ + : /*in*/ "r" (&_argvec[2]) \ + : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \ + ); \ + lval = (__typeof__(lval)) _res; \ + } while (0) + +#define CALL_FN_W_12W(lval, orig, arg1,arg2,arg3,arg4,arg5,arg6, \ + arg7,arg8,arg9,arg10,arg11,arg12) \ + do { \ + volatile OrigFn _orig = (orig); \ + volatile unsigned long _argvec[3+12]; \ + volatile unsigned long _res; \ + /* _argvec[0] holds current r2 across the call */ \ + _argvec[1] = (unsigned long)_orig.r2; \ + _argvec[2] = (unsigned long)_orig.nraddr; \ + _argvec[2+1] = (unsigned long)arg1; \ + _argvec[2+2] = (unsigned long)arg2; \ + _argvec[2+3] = (unsigned long)arg3; \ + _argvec[2+4] = (unsigned long)arg4; \ + _argvec[2+5] = (unsigned long)arg5; \ + _argvec[2+6] = (unsigned long)arg6; \ + _argvec[2+7] = (unsigned long)arg7; \ + _argvec[2+8] = (unsigned long)arg8; \ + _argvec[2+9] = (unsigned long)arg9; \ + _argvec[2+10] = (unsigned long)arg10; \ + _argvec[2+11] = (unsigned long)arg11; \ + _argvec[2+12] = (unsigned long)arg12; \ + __asm__ volatile( \ + "mr 11,%1\n\t" \ + VG_EXPAND_FRAME_BY_trashes_r3(512) \ + "std 2,-16(11)\n\t" /* save tocptr */ \ + "ld 2,-8(11)\n\t" /* use nraddr's tocptr */ \ + VG_EXPAND_FRAME_BY_trashes_r3(144) \ + /* arg12 */ \ + "ld 3,96(11)\n\t" \ + "std 3,136(1)\n\t" \ + /* arg11 */ \ + "ld 3,88(11)\n\t" \ + "std 3,128(1)\n\t" \ + /* arg10 */ \ + "ld 3,80(11)\n\t" \ + "std 3,120(1)\n\t" \ + /* arg9 */ \ + "ld 3,72(11)\n\t" \ + "std 3,112(1)\n\t" \ + /* args1-8 */ \ + "ld 3, 8(11)\n\t" /* arg1->r3 */ \ + "ld 4, 16(11)\n\t" /* arg2->r4 */ \ + "ld 5, 24(11)\n\t" /* arg3->r5 */ \ + "ld 6, 32(11)\n\t" /* arg4->r6 */ \ + "ld 7, 40(11)\n\t" /* arg5->r7 */ \ + "ld 8, 48(11)\n\t" /* arg6->r8 */ \ + "ld 9, 56(11)\n\t" /* arg7->r9 */ \ + "ld 10, 64(11)\n\t" /* arg8->r10 */ \ + "ld 11, 0(11)\n\t" /* target->r11 */ \ + VALGRIND_BRANCH_AND_LINK_TO_NOREDIR_R11 \ + "mr 11,%1\n\t" \ + "mr %0,3\n\t" \ + "ld 2,-16(11)\n\t" /* restore tocptr */ \ + VG_CONTRACT_FRAME_BY(144) \ + VG_CONTRACT_FRAME_BY(512) \ + : /*out*/ "=r" (_res) \ + : /*in*/ "r" (&_argvec[2]) \ + : /*trash*/ "cc", "memory", __CALLER_SAVED_REGS \ + ); \ + lval = (__typeof__(lval)) _res; \ + } while (0) + +#endif /* PLAT_ppc64_aix5 */ + + +/* ------------------------------------------------------------------ */ +/* ARCHITECTURE INDEPENDENT MACROS for CLIENT REQUESTS. */ +/* */ +/* ------------------------------------------------------------------ */ + +/* Some request codes. There are many more of these, but most are not + exposed to end-user view. These are the public ones, all of the + form 0x1000 + small_number. + + Core ones are in the range 0x00000000--0x0000ffff. The non-public + ones start at 0x2000. +*/ + +/* These macros are used by tools -- they must be public, but don't + embed them into other programs. */ +#define VG_USERREQ_TOOL_BASE(a,b) \ + ((unsigned int)(((a)&0xff) << 24 | ((b)&0xff) << 16)) +#define VG_IS_TOOL_USERREQ(a, b, v) \ + (VG_USERREQ_TOOL_BASE(a,b) == ((v) & 0xffff0000)) + +/* !! ABIWARNING !! ABIWARNING !! ABIWARNING !! ABIWARNING !! + This enum comprises an ABI exported by Valgrind to programs + which use client requests. DO NOT CHANGE THE ORDER OF THESE + ENTRIES, NOR DELETE ANY -- add new ones at the end. */ +typedef + enum { VG_USERREQ__RUNNING_ON_VALGRIND = 0x1001, + VG_USERREQ__DISCARD_TRANSLATIONS = 0x1002, + + /* These allow any function to be called from the simulated + CPU but run on the real CPU. Nb: the first arg passed to + the function is always the ThreadId of the running + thread! So CLIENT_CALL0 actually requires a 1 arg + function, etc. */ + VG_USERREQ__CLIENT_CALL0 = 0x1101, + VG_USERREQ__CLIENT_CALL1 = 0x1102, + VG_USERREQ__CLIENT_CALL2 = 0x1103, + VG_USERREQ__CLIENT_CALL3 = 0x1104, + + /* Can be useful in regression testing suites -- eg. can + send Valgrind's output to /dev/null and still count + errors. */ + VG_USERREQ__COUNT_ERRORS = 0x1201, + + /* These are useful and can be interpreted by any tool that + tracks malloc() et al, by using vg_replace_malloc.c. */ + VG_USERREQ__MALLOCLIKE_BLOCK = 0x1301, + VG_USERREQ__FREELIKE_BLOCK = 0x1302, + /* Memory pool support. */ + VG_USERREQ__CREATE_MEMPOOL = 0x1303, + VG_USERREQ__DESTROY_MEMPOOL = 0x1304, + VG_USERREQ__MEMPOOL_ALLOC = 0x1305, + VG_USERREQ__MEMPOOL_FREE = 0x1306, + VG_USERREQ__MEMPOOL_TRIM = 0x1307, + VG_USERREQ__MOVE_MEMPOOL = 0x1308, + VG_USERREQ__MEMPOOL_CHANGE = 0x1309, + VG_USERREQ__MEMPOOL_EXISTS = 0x130a, + + /* Allow printfs to valgrind log. */ + VG_USERREQ__PRINTF = 0x1401, + VG_USERREQ__PRINTF_BACKTRACE = 0x1402, + + /* Stack support. */ + VG_USERREQ__STACK_REGISTER = 0x1501, + VG_USERREQ__STACK_DEREGISTER = 0x1502, + VG_USERREQ__STACK_CHANGE = 0x1503 + } Vg_ClientRequest; + +#if !defined(__GNUC__) +# define __extension__ /* */ +#endif + +/* Returns the number of Valgrinds this code is running under. That + is, 0 if running natively, 1 if running under Valgrind, 2 if + running under Valgrind which is running under another Valgrind, + etc. */ +#define RUNNING_ON_VALGRIND __extension__ \ + ({unsigned int _qzz_res; \ + VALGRIND_DO_CLIENT_REQUEST(_qzz_res, 0 /* if not */, \ + VG_USERREQ__RUNNING_ON_VALGRIND, \ + 0, 0, 0, 0, 0); \ + _qzz_res; \ + }) + + +/* Discard translation of code in the range [_qzz_addr .. _qzz_addr + + _qzz_len - 1]. Useful if you are debugging a JITter or some such, + since it provides a way to make sure valgrind will retranslate the + invalidated area. Returns no value. */ +#define VALGRIND_DISCARD_TRANSLATIONS(_qzz_addr,_qzz_len) \ + {unsigned int _qzz_res; \ + VALGRIND_DO_CLIENT_REQUEST(_qzz_res, 0, \ + VG_USERREQ__DISCARD_TRANSLATIONS, \ + _qzz_addr, _qzz_len, 0, 0, 0); \ + } + + +/* These requests are for getting Valgrind itself to print something. + Possibly with a backtrace. This is a really ugly hack. */ + +#if defined(NVALGRIND) + +# define VALGRIND_PRINTF(...) +# define VALGRIND_PRINTF_BACKTRACE(...) + +#else /* NVALGRIND */ + +/* Modern GCC will optimize the static routine out if unused, + and unused attribute will shut down warnings about it. */ +static int VALGRIND_PRINTF(const char *format, ...) + __attribute__((format(__printf__, 1, 2), __unused__)); +static int +VALGRIND_PRINTF(const char *format, ...) +{ + unsigned long _qzz_res; + va_list vargs; + va_start(vargs, format); + VALGRIND_DO_CLIENT_REQUEST(_qzz_res, 0, VG_USERREQ__PRINTF, + (unsigned long)format, (unsigned long)vargs, + 0, 0, 0); + va_end(vargs); + return (int)_qzz_res; +} + +static int VALGRIND_PRINTF_BACKTRACE(const char *format, ...) + __attribute__((format(__printf__, 1, 2), __unused__)); +static int +VALGRIND_PRINTF_BACKTRACE(const char *format, ...) +{ + unsigned long _qzz_res; + va_list vargs; + va_start(vargs, format); + VALGRIND_DO_CLIENT_REQUEST(_qzz_res, 0, VG_USERREQ__PRINTF_BACKTRACE, + (unsigned long)format, (unsigned long)vargs, + 0, 0, 0); + va_end(vargs); + return (int)_qzz_res; +} + +#endif /* NVALGRIND */ + + +/* These requests allow control to move from the simulated CPU to the + real CPU, calling an arbitary function. + + Note that the current ThreadId is inserted as the first argument. + So this call: + + VALGRIND_NON_SIMD_CALL2(f, arg1, arg2) + + requires f to have this signature: + + Word f(Word tid, Word arg1, Word arg2) + + where "Word" is a word-sized type. + + Note that these client requests are not entirely reliable. For example, + if you call a function with them that subsequently calls printf(), + there's a high chance Valgrind will crash. Generally, your prospects of + these working are made higher if the called function does not refer to + any global variables, and does not refer to any libc or other functions + (printf et al). Any kind of entanglement with libc or dynamic linking is + likely to have a bad outcome, for tricky reasons which we've grappled + with a lot in the past. +*/ +#define VALGRIND_NON_SIMD_CALL0(_qyy_fn) \ + __extension__ \ + ({unsigned long _qyy_res; \ + VALGRIND_DO_CLIENT_REQUEST(_qyy_res, 0 /* default return */, \ + VG_USERREQ__CLIENT_CALL0, \ + _qyy_fn, \ + 0, 0, 0, 0); \ + _qyy_res; \ + }) + +#define VALGRIND_NON_SIMD_CALL1(_qyy_fn, _qyy_arg1) \ + __extension__ \ + ({unsigned long _qyy_res; \ + VALGRIND_DO_CLIENT_REQUEST(_qyy_res, 0 /* default return */, \ + VG_USERREQ__CLIENT_CALL1, \ + _qyy_fn, \ + _qyy_arg1, 0, 0, 0); \ + _qyy_res; \ + }) + +#define VALGRIND_NON_SIMD_CALL2(_qyy_fn, _qyy_arg1, _qyy_arg2) \ + __extension__ \ + ({unsigned long _qyy_res; \ + VALGRIND_DO_CLIENT_REQUEST(_qyy_res, 0 /* default return */, \ + VG_USERREQ__CLIENT_CALL2, \ + _qyy_fn, \ + _qyy_arg1, _qyy_arg2, 0, 0); \ + _qyy_res; \ + }) + +#define VALGRIND_NON_SIMD_CALL3(_qyy_fn, _qyy_arg1, _qyy_arg2, _qyy_arg3) \ + __extension__ \ + ({unsigned long _qyy_res; \ + VALGRIND_DO_CLIENT_REQUEST(_qyy_res, 0 /* default return */, \ + VG_USERREQ__CLIENT_CALL3, \ + _qyy_fn, \ + _qyy_arg1, _qyy_arg2, \ + _qyy_arg3, 0); \ + _qyy_res; \ + }) + + +/* Counts the number of errors that have been recorded by a tool. Nb: + the tool must record the errors with VG_(maybe_record_error)() or + VG_(unique_error)() for them to be counted. */ +#define VALGRIND_COUNT_ERRORS \ + __extension__ \ + ({unsigned int _qyy_res; \ + VALGRIND_DO_CLIENT_REQUEST(_qyy_res, 0 /* default return */, \ + VG_USERREQ__COUNT_ERRORS, \ + 0, 0, 0, 0, 0); \ + _qyy_res; \ + }) + +/* Mark a block of memory as having been allocated by a malloc()-like + function. `addr' is the start of the usable block (ie. after any + redzone) `rzB' is redzone size if the allocator can apply redzones; + use '0' if not. Adding redzones makes it more likely Valgrind will spot + block overruns. `is_zeroed' indicates if the memory is zeroed, as it is + for calloc(). Put it immediately after the point where a block is + allocated. + + If you're using Memcheck: If you're allocating memory via superblocks, + and then handing out small chunks of each superblock, if you don't have + redzones on your small blocks, it's worth marking the superblock with + VALGRIND_MAKE_MEM_NOACCESS when it's created, so that block overruns are + detected. But if you can put redzones on, it's probably better to not do + this, so that messages for small overruns are described in terms of the + small block rather than the superblock (but if you have a big overrun + that skips over a redzone, you could miss an error this way). See + memcheck/tests/custom_alloc.c for an example. + + WARNING: if your allocator uses malloc() or 'new' to allocate + superblocks, rather than mmap() or brk(), this will not work properly -- + you'll likely get assertion failures during leak detection. This is + because Valgrind doesn't like seeing overlapping heap blocks. Sorry. + + Nb: block must be freed via a free()-like function specified + with VALGRIND_FREELIKE_BLOCK or mismatch errors will occur. */ +#define VALGRIND_MALLOCLIKE_BLOCK(addr, sizeB, rzB, is_zeroed) \ + {unsigned int _qzz_res; \ + VALGRIND_DO_CLIENT_REQUEST(_qzz_res, 0, \ + VG_USERREQ__MALLOCLIKE_BLOCK, \ + addr, sizeB, rzB, is_zeroed, 0); \ + } + +/* Mark a block of memory as having been freed by a free()-like function. + `rzB' is redzone size; it must match that given to + VALGRIND_MALLOCLIKE_BLOCK. Memory not freed will be detected by the leak + checker. Put it immediately after the point where the block is freed. */ +#define VALGRIND_FREELIKE_BLOCK(addr, rzB) \ + {unsigned int _qzz_res; \ + VALGRIND_DO_CLIENT_REQUEST(_qzz_res, 0, \ + VG_USERREQ__FREELIKE_BLOCK, \ + addr, rzB, 0, 0, 0); \ + } + +/* Create a memory pool. */ +#define VALGRIND_CREATE_MEMPOOL(pool, rzB, is_zeroed) \ + {unsigned int _qzz_res; \ + VALGRIND_DO_CLIENT_REQUEST(_qzz_res, 0, \ + VG_USERREQ__CREATE_MEMPOOL, \ + pool, rzB, is_zeroed, 0, 0); \ + } + +/* Destroy a memory pool. */ +#define VALGRIND_DESTROY_MEMPOOL(pool) \ + {unsigned int _qzz_res; \ + VALGRIND_DO_CLIENT_REQUEST(_qzz_res, 0, \ + VG_USERREQ__DESTROY_MEMPOOL, \ + pool, 0, 0, 0, 0); \ + } + +/* Associate a piece of memory with a memory pool. */ +#define VALGRIND_MEMPOOL_ALLOC(pool, addr, size) \ + {unsigned int _qzz_res; \ + VALGRIND_DO_CLIENT_REQUEST(_qzz_res, 0, \ + VG_USERREQ__MEMPOOL_ALLOC, \ + pool, addr, size, 0, 0); \ + } + +/* Disassociate a piece of memory from a memory pool. */ +#define VALGRIND_MEMPOOL_FREE(pool, addr) \ + {unsigned int _qzz_res; \ + VALGRIND_DO_CLIENT_REQUEST(_qzz_res, 0, \ + VG_USERREQ__MEMPOOL_FREE, \ + pool, addr, 0, 0, 0); \ + } + +/* Disassociate any pieces outside a particular range. */ +#define VALGRIND_MEMPOOL_TRIM(pool, addr, size) \ + {unsigned int _qzz_res; \ + VALGRIND_DO_CLIENT_REQUEST(_qzz_res, 0, \ + VG_USERREQ__MEMPOOL_TRIM, \ + pool, addr, size, 0, 0); \ + } + +/* Resize and/or move a piece associated with a memory pool. */ +#define VALGRIND_MOVE_MEMPOOL(poolA, poolB) \ + {unsigned int _qzz_res; \ + VALGRIND_DO_CLIENT_REQUEST(_qzz_res, 0, \ + VG_USERREQ__MOVE_MEMPOOL, \ + poolA, poolB, 0, 0, 0); \ + } + +/* Resize and/or move a piece associated with a memory pool. */ +#define VALGRIND_MEMPOOL_CHANGE(pool, addrA, addrB, size) \ + {unsigned int _qzz_res; \ + VALGRIND_DO_CLIENT_REQUEST(_qzz_res, 0, \ + VG_USERREQ__MEMPOOL_CHANGE, \ + pool, addrA, addrB, size, 0); \ + } + +/* Return 1 if a mempool exists, else 0. */ +#define VALGRIND_MEMPOOL_EXISTS(pool) \ + ({unsigned int _qzz_res; \ + VALGRIND_DO_CLIENT_REQUEST(_qzz_res, 0, \ + VG_USERREQ__MEMPOOL_EXISTS, \ + pool, 0, 0, 0, 0); \ + _qzz_res; \ + }) + +/* Mark a piece of memory as being a stack. Returns a stack id. */ +#define VALGRIND_STACK_REGISTER(start, end) \ + ({unsigned int _qzz_res; \ + VALGRIND_DO_CLIENT_REQUEST(_qzz_res, 0, \ + VG_USERREQ__STACK_REGISTER, \ + start, end, 0, 0, 0); \ + _qzz_res; \ + }) + +/* Unmark the piece of memory associated with a stack id as being a + stack. */ +#define VALGRIND_STACK_DEREGISTER(id) \ + {unsigned int _qzz_res; \ + VALGRIND_DO_CLIENT_REQUEST(_qzz_res, 0, \ + VG_USERREQ__STACK_DEREGISTER, \ + id, 0, 0, 0, 0); \ + } + +/* Change the start and end address of the stack id. */ +#define VALGRIND_STACK_CHANGE(id, start, end) \ + {unsigned int _qzz_res; \ + VALGRIND_DO_CLIENT_REQUEST(_qzz_res, 0, \ + VG_USERREQ__STACK_CHANGE, \ + id, start, end, 0, 0); \ + } + + +#undef PLAT_x86_linux +#undef PLAT_amd64_linux +#undef PLAT_ppc32_linux +#undef PLAT_ppc64_linux +#undef PLAT_ppc32_aix5 +#undef PLAT_ppc64_aix5 + +#endif /* __VALGRIND_H */ diff --git a/tests/auto/exceptionsafety_objects/exceptionsafety_objects.pro b/tests/auto/exceptionsafety_objects/exceptionsafety_objects.pro new file mode 100644 index 0000000..d0945a4 --- /dev/null +++ b/tests/auto/exceptionsafety_objects/exceptionsafety_objects.pro @@ -0,0 +1,3 @@ +load(qttest_p4) +HEADERS += oomsimulator.h 3rdparty/valgrind.h 3rdparty/memcheck.h +SOURCES += tst_exceptionsafety_objects.cpp diff --git a/tests/auto/exceptionsafety_objects/oomsimulator.h b/tests/auto/exceptionsafety_objects/oomsimulator.h new file mode 100644 index 0000000..88d8039 --- /dev/null +++ b/tests/auto/exceptionsafety_objects/oomsimulator.h @@ -0,0 +1,286 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, 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. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef Q_OS_SYMBIAN +#include <malloc.h> +#endif +#include <limits.h> +#include <stdio.h> +#include <exception> + +#if !defined(Q_OS_WIN) && !defined(Q_OS_SYMBIAN) +# include "3rdparty/memcheck.h" +#endif + +static bool mallocFailActive = false; +static int mallocFailIndex = 0; +static int mallocCount = 0; + +static void my_terminate_handler() +{ + // set a breakpoint here to get a backtrace for your uncaught exceptions + fprintf(stderr, "Uncaught Exception Detected. Set a breakpoint in my_terminate_handler()\n"); + exit(1); +} + +#ifdef __GLIBC__ +/* Use glibc's memory allocation hooks */ + +/* our hooks */ +static void *my_malloc_hook(size_t, const void *); +static void *my_realloc_hook(void *, size_t, const void *); +static void *my_memalign_hook(size_t, size_t, const void *); +static void my_free_hook(void *, const void *); + +/* original hooks. */ +static void *(*old_malloc_hook)(size_t, const void *); +static void *(*old_realloc_hook)(void *, size_t, const void *); +static void *(*old_memalign_hook)(size_t, size_t, const void *); +static void (*old_free_hook)(void *, const void *); + +/* initializer function */ +static void my_init_hook(); + +/* Override initialising hook from the C library. */ +void (*__malloc_initialize_hook) (void) = my_init_hook; + +static void disableHooks() +{ + __malloc_hook = old_malloc_hook; + __realloc_hook = old_realloc_hook; + __memalign_hook = old_memalign_hook; + __free_hook = old_free_hook; +} + +static void enableHooks() +{ + __malloc_hook = my_malloc_hook; + __realloc_hook = my_realloc_hook; + __memalign_hook = my_memalign_hook; + __free_hook = my_free_hook; +} + +void my_init_hook() +{ + old_malloc_hook = __malloc_hook; + old_realloc_hook = __realloc_hook; + old_memalign_hook = __memalign_hook; + old_free_hook = __free_hook; + enableHooks(); +} + +void *my_malloc_hook(size_t size, const void *) +{ + ++mallocCount; + + if (mallocFailActive && --mallocFailIndex < 0) + return 0; // simulate OOM + + __malloc_hook = old_malloc_hook; + void *result = ::malloc (size); + __malloc_hook = my_malloc_hook; + + return result; +} + +void *my_memalign_hook(size_t alignment, size_t size, const void *) +{ + ++mallocCount; + + if (mallocFailActive && --mallocFailIndex < 0) + return 0; // simulate OOM + + __memalign_hook = old_memalign_hook; + void *result = ::memalign(alignment, size); + __memalign_hook = my_memalign_hook; + + return result; +} + +void *my_realloc_hook(void *ptr, size_t size, const void *) +{ + ++mallocCount; + + if (mallocFailActive && --mallocFailIndex < 0) + return 0; // simulate OOM + + __realloc_hook = old_realloc_hook; + __malloc_hook = old_malloc_hook; + void *result = ::realloc(ptr, size); + __malloc_hook = my_malloc_hook; + __realloc_hook = my_realloc_hook; + + return result; +} + +void my_free_hook(void *ptr, const void *) +{ + __free_hook = old_free_hook; + ::free(ptr); + __free_hook = my_free_hook; +} + +#elif defined(Q_CC_MSVC) + +#include "crtdbg.h" + +static int qCrtAllocHook(int allocType, void * /*userData*/, size_t /*size*/, + int blockType, long /*requestNumber*/, + const unsigned char * /*filename*/, int /*lineNumber*/) +{ + if (blockType == _CRT_BLOCK) + return TRUE; // ignore allocations from the C library + + switch (allocType) { + case _HOOK_ALLOC: + case _HOOK_REALLOC: + ++mallocCount; + if (mallocFailActive && --mallocFailIndex < 0) + return FALSE; // simulate OOM + } + + return TRUE; +} + +static struct QCrtDebugRegistrator +{ + QCrtDebugRegistrator() + { + _CrtSetAllocHook(qCrtAllocHook); + } + +} crtDebugRegistrator; + +#endif + +struct AllocFailer +{ + inline AllocFailer(int index) { reactivateAt(index); } + inline ~AllocFailer() { deactivate(); } + + inline void reactivateAt(int index) + { +#ifdef RUNNING_ON_VALGRIND + if (RUNNING_ON_VALGRIND) + VALGRIND_ENABLE_OOM_AT_ALLOC_INDEX(VALGRIND_GET_ALLOC_INDEX + index + 1); +#elif defined(Q_OS_SYMBIAN) + // symbian alloc fail index is 1 based + __UHEAP_BURSTFAILNEXT(index+1, KMaxTUint16); +#endif + mallocFailIndex = index; + mallocFailActive = true; + } + + inline void deactivate() + { + mallocFailActive = false; +#ifdef RUNNING_ON_VALGRIND + VALGRIND_ENABLE_OOM_AT_ALLOC_INDEX(0); +#elif defined(Q_OS_SYMBIAN) + __UHEAP_RESET; +#endif + } + + inline int currentAllocIndex() const + { +#ifdef RUNNING_ON_VALGRIND + if (RUNNING_ON_VALGRIND) + return VALGRIND_GET_ALLOC_INDEX; +#endif + return mallocCount; + } + + static bool initialize() + { + std::set_terminate(my_terminate_handler); +#ifdef RUNNING_ON_VALGRIND + if (RUNNING_ON_VALGRIND) { + if (VALGRIND_GET_ALLOC_INDEX == -1u) { + qWarning("You must use a valgrind with oom simulation support"); + return false; + } + // running in valgrind - don't use glibc hooks + disableHooks(); + + // never stop simulating OOM + VALGRIND_DISABLE_OOM_AT_ALLOC_INDEX(-1u); + } +#endif + return true; + } +}; + +#ifndef Q_OS_SYMBIAN + +static void *new_helper(std::size_t size) +{ + void *ptr = malloc(size); + if (!ptr) + throw std::bad_alloc(); + return ptr; +} + +#ifdef Q_CC_MSVC +# pragma warning(push) +# pragma warning(disable: 4290) +#endif + +// overload operator new +void* operator new(size_t size) throw (std::bad_alloc) { return new_helper(size); } +void* operator new[](size_t size) throw (std::bad_alloc) { return new_helper(size); } +void* operator new(size_t size, const std::nothrow_t&) throw() { return malloc(size); } +void* operator new[](std::size_t size, const std::nothrow_t&) throw() { return malloc(size); } + +// overload operator delete +void operator delete(void *ptr) throw() { if (ptr) free(ptr); } +void operator delete[](void *ptr) throw() { if (ptr) free(ptr); } +void operator delete(void *ptr, const std::nothrow_t&) throw() { if (ptr) free(ptr); } +void operator delete[](void *ptr, const std::nothrow_t&) throw() { if (ptr) free (ptr); } + +#ifdef Q_CC_MSVC +# pragma warning(pop) +#endif + +#endif + +// ignore placement new and placement delete - those don't allocate. + + diff --git a/tests/auto/exceptionsafety_objects/tst_exceptionsafety_objects.cpp b/tests/auto/exceptionsafety_objects/tst_exceptionsafety_objects.cpp new file mode 100644 index 0000000..c18b5c8 --- /dev/null +++ b/tests/auto/exceptionsafety_objects/tst_exceptionsafety_objects.cpp @@ -0,0 +1,651 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, 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. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QtGui/QtGui> +#include <QtTest/QtTest> + +#include <stddef.h> + +QT_USE_NAMESPACE + +// this test only works with +// * GLIBC +// * MSVC - only debug builds (we need the crtdbg.h helpers) +// * SYMBIAN - only when __UHEAP_BURSTFAILNEXT is available +#if (defined(QT_NO_EXCEPTIONS) || (!defined(__GLIBC__) && !defined(Q_CC_MSVC) && (!defined(Q_OS_SYMBIAN) || !defined(__UHEAP_BURSTFAILNEXT)))) && !defined(Q_MOC_RUN) + QTEST_NOOP_MAIN +#else + +#include "oomsimulator.h" +#if !defined(Q_OS_SYMBIAN) +#include "3rdparty/memcheck.h" +#endif + +class tst_ExceptionSafetyObjects: public QObject +{ + Q_OBJECT + +public slots: + void initTestCase(); + +private slots: + void objects_data(); + void objects(); + + void widgets_data(); + void widgets(); + + void vector_data(); + void vector(); + + void list_data(); + void list(); + + void linkedList_data(); + void linkedList(); +}; + +// helper structs to create an arbitrary widget +struct AbstractTester +{ + virtual void operator()(QObject *parent) = 0; +}; +Q_DECLARE_METATYPE(AbstractTester *) + +typedef void (*TestFunction)(QObject*); +Q_DECLARE_METATYPE(TestFunction) + +template <typename T> +struct ObjectCreator : public AbstractTester +{ + void operator()(QObject *) + { + QScopedPointer<T> ptr(new T); + } +}; + +struct BitArrayCreator : public AbstractTester +{ + void operator()(QObject *) + { QScopedPointer<QBitArray> bitArray(new QBitArray(100, true)); } +}; + +struct ByteArrayMatcherCreator : public AbstractTester +{ + void operator()(QObject *) + { QScopedPointer<QByteArrayMatcher> ptr(new QByteArrayMatcher("ralf test",8)); } +}; + +struct CryptographicHashCreator : public AbstractTester +{ + void operator()(QObject *) + { + QScopedPointer<QCryptographicHash> ptr(new QCryptographicHash(QCryptographicHash::Sha1)); + ptr->addData("ralf test",8); + } +}; + +struct DataStreamCreator : public AbstractTester +{ + void operator()(QObject *) + { + QScopedPointer<QByteArray> arr(new QByteArray("hallo, test")); + QScopedPointer<QDataStream> ptr(new QDataStream(arr.data(), QIODevice::ReadWrite)); + ptr->writeBytes("ralf test",8); + } +}; + +struct DirCreator : public AbstractTester +{ + void operator()(QObject *) + { + QDir::cleanPath("../////././"); + QScopedPointer<QDir> ptr(new QDir(".")); + while( ptr->cdUp() ) + ; // just going up + ptr->count(); + ptr->exists(ptr->path()); + + QStringList filters; + filters << "*.cpp" << "*.cxx" << "*.cc"; + ptr->setNameFilters(filters); + } +}; + +void tst_ExceptionSafetyObjects::objects_data() +{ + QTest::addColumn<AbstractTester *>("objectCreator"); + +#define NEWROW(T) QTest::newRow(#T) << static_cast<AbstractTester *>(new ObjectCreator<T >) + NEWROW(QObject); + NEWROW(QBuffer); + NEWROW(QFile); + NEWROW(QProcess); + NEWROW(QSettings); + NEWROW(QThread); + NEWROW(QThreadPool); + NEWROW(QTranslator); + NEWROW(QFSFileEngine); + +#define NEWROW2(T, CREATOR) QTest::newRow(#T) << static_cast<AbstractTester *>(new CREATOR) + NEWROW2(QBitArray, BitArrayCreator); + NEWROW2(QByteArrayMatcher, ByteArrayMatcherCreator); + NEWROW2(QCryptographicHash, CryptographicHashCreator); + NEWROW2(QDataStream, DataStreamCreator); + NEWROW2(QDir, DirCreator); + +} + +// create and destructs an object, and lets each and every allocation +// during construction and destruction fail. +template <typename T> +static void doOOMTest(T &testFunc, QObject *parent, int start=0) +{ + int currentOOMIndex = start; + bool caught = false; + bool done = false; + + AllocFailer allocFailer(0); + int allocCountBefore = allocFailer.currentAllocIndex(); + + do { + allocFailer.reactivateAt(++currentOOMIndex); + + caught = false; + + try { + testFunc(parent); + } catch (const std::bad_alloc &) { + caught = true; + } catch (const std::exception &ex) { + if (strcmp(ex.what(), "autotest swallow") != 0) + throw; + caught = true; + } + + if (!caught) { + void *buf = malloc(42); + if (buf) { + // we got memory here - oom test is over. + free(buf); + done = true; + } + } + + // if we get a FAIL, stop executing now + if (QTest::currentTestFailed()) + done = true; + +//#define REALLY_VERBOSE +#ifdef REALLY_VERBOSE + fprintf(stderr, " OOM Index: %d\n", currentOOMIndex); +#endif + + + } while (caught || !done); + + allocFailer.deactivate(); + +//#define VERBOSE +#ifdef VERBOSE + fprintf(stderr, "OOM Test done, checked allocs: %d (range %d - %d)\n", currentOOMIndex, + allocCountBefore, allocFailer.currentAllocIndex()); +#else + Q_UNUSED(allocCountBefore); +#endif +} + +static int alloc1Failed = 0; +static int alloc2Failed = 0; +static int alloc3Failed = 0; +static int alloc4Failed = 0; +static int malloc1Failed = 0; +static int malloc2Failed = 0; + +// Tests that new, new[] and malloc() fail at least once during OOM testing. +class SelfTestObject : public QObject +{ +public: + SelfTestObject(QObject *parent = 0) + : QObject(parent) + { + try { delete new int; } catch (const std::bad_alloc &) { ++alloc1Failed; throw; } + try { delete [] new double[5]; } catch (const std::bad_alloc &) { ++alloc2Failed; throw ;} + void *buf = malloc(42); + if (buf) + free(buf); + else + ++malloc1Failed; + } + + ~SelfTestObject() + { + try { delete new int; } catch (const std::bad_alloc &) { ++alloc3Failed; } + try { delete [] new double[5]; } catch (const std::bad_alloc &) { ++alloc4Failed; } + void *buf = malloc(42); + if (buf) + free(buf); + else + ++malloc2Failed = true; + } +}; + +void tst_ExceptionSafetyObjects::initTestCase() +{ + QVERIFY(AllocFailer::initialize()); + + // sanity check whether OOM simulation works + AllocFailer allocFailer(0); + + // malloc fail index is 0 -> this malloc should fail. + void *buf = malloc(42); + allocFailer.deactivate(); + QVERIFY(!buf); + + // malloc fail index is 1 - second malloc should fail. + allocFailer.reactivateAt(1); + buf = malloc(42); + void *buf2 = malloc(42); + allocFailer.deactivate(); + + QVERIFY(buf); + free(buf); + QVERIFY(!buf2); + +#ifdef Q_OS_SYMBIAN + // temporary workaround for INC138398 + std::new_handler nh_func = std::set_new_handler(0); + (void) std::set_new_handler(nh_func); +#endif + + ObjectCreator<SelfTestObject> *selfTest = new ObjectCreator<SelfTestObject>; + doOOMTest(*selfTest, 0); + delete selfTest; + QCOMPARE(alloc1Failed, 1); + QCOMPARE(alloc2Failed, 1); + QCOMPARE(alloc3Failed, 2); + QCOMPARE(alloc4Failed, 3); + QCOMPARE(malloc1Failed, 1); + QCOMPARE(malloc2Failed, 1); +} + +void tst_ExceptionSafetyObjects::objects() +{ + QFETCH(AbstractTester *, objectCreator); + + doOOMTest(*objectCreator, 0); + + delete objectCreator; +} + +template <typename T> +struct WidgetCreator : public AbstractTester +{ + void operator()(QObject *parent) + { + Q_ASSERT(!parent || parent->isWidgetType()); + QScopedPointer<T> ptr(parent ? new T(static_cast<QWidget *>(parent)) : new T); + } +}; + +// QSizeGrip doesn't have a default constructor - always pass parent (even though it might be 0) +template <> struct WidgetCreator<QSizeGrip> : public AbstractTester +{ + void operator()(QObject *parent) + { + Q_ASSERT(!parent || parent->isWidgetType()); + QScopedPointer<QSizeGrip> ptr(new QSizeGrip(static_cast<QWidget *>(parent))); + } +}; + +// QDesktopWidget doesn't need a parent. +template <> struct WidgetCreator<QDesktopWidget> : public AbstractTester +{ + void operator()(QObject *parent) + { + Q_ASSERT(!parent || parent->isWidgetType()); + QScopedPointer<QDesktopWidget> ptr(new QDesktopWidget()); + } +}; +void tst_ExceptionSafetyObjects::widgets_data() +{ + QTest::addColumn<AbstractTester *>("widgetCreator"); + +#undef NEWROW +#define NEWROW(T) QTest::newRow(#T) << static_cast<AbstractTester *>(new WidgetCreator<T >) + + NEWROW(QWidget); + + NEWROW(QButtonGroup); + NEWROW(QDesktopWidget); + NEWROW(QCheckBox); + NEWROW(QComboBox); + NEWROW(QCommandLinkButton); + NEWROW(QDateEdit); + NEWROW(QDateTimeEdit); + NEWROW(QDial); + NEWROW(QDoubleSpinBox); + NEWROW(QFocusFrame); + NEWROW(QFontComboBox); + NEWROW(QFrame); + NEWROW(QGroupBox); + NEWROW(QLCDNumber); + NEWROW(QLabel); + NEWROW(QLCDNumber); + NEWROW(QLineEdit); + NEWROW(QMenu); + NEWROW(QPlainTextEdit); + NEWROW(QProgressBar); + NEWROW(QPushButton); + NEWROW(QRadioButton); + NEWROW(QScrollArea); + NEWROW(QScrollBar); + NEWROW(QSizeGrip); + NEWROW(QSlider); + NEWROW(QSpinBox); + NEWROW(QSplitter); + NEWROW(QStackedWidget); + NEWROW(QStatusBar); + NEWROW(QTabBar); + NEWROW(QTabWidget); + NEWROW(QTextBrowser); + NEWROW(QTextEdit); + NEWROW(QTimeEdit); + NEWROW(QToolBox); + NEWROW(QToolButton); + NEWROW(QStatusBar); + NEWROW(QSplitter); + NEWROW(QTextEdit); + NEWROW(QTextBrowser); + NEWROW(QToolBar); + NEWROW(QMenuBar); + NEWROW(QMainWindow); + NEWROW(QWorkspace); + NEWROW(QColumnView); + NEWROW(QListView); + NEWROW(QListWidget); + NEWROW(QTableView); + NEWROW(QTableWidget); + NEWROW(QTreeView); + NEWROW(QTreeWidget); +} + +void tst_ExceptionSafetyObjects::widgets() +{ + QFETCH(AbstractTester *, widgetCreator); + + doOOMTest(*widgetCreator, 0, 00000); + + QWidget parent; + doOOMTest(*widgetCreator, &parent, 00000); + + delete widgetCreator; + + // if the test reaches here without crashing, we passed :) + QVERIFY(true); +} + +struct Integer +{ + Integer(int value = 42) + : ptr(new int(value)) + { + ++instanceCount; + } + + Integer(const Integer &other) + : ptr(new int(*other.ptr)) + { + ++instanceCount; + } + + Integer &operator=(const Integer &other) + { + int *newPtr = new int(*other.ptr); + delete ptr; + ptr = newPtr; + return *this; + } + + ~Integer() + { + --instanceCount; + delete ptr; + } + + int value() const + { + return *ptr; + } + + int *ptr; + static int instanceCount; +}; + +int Integer::instanceCount = 0; + +template <template<typename T> class Container> +void containerInsertTest(QObject*) +{ + Container<Integer> container; + + // insert an item in an empty container + try { + container.insert(container.begin(), 41); + } catch (...) { + QVERIFY(container.isEmpty()); + QCOMPARE(Integer::instanceCount, 0); + return; + } + + QCOMPARE(container.size(), 1); + QCOMPARE(Integer::instanceCount, 1); + + // insert an item before another item + try { + container.insert(container.begin(), 42); + } catch (...) { + QCOMPARE(container.size(), 1); + QCOMPARE(container.first().value(), 41); + QCOMPARE(Integer::instanceCount, 1); + return; + } + + QCOMPARE(Integer::instanceCount, 2); + + // insert an item in between + try { + container.insert(container.begin() + 1, 43); + } catch (...) { + QCOMPARE(container.size(), 2); + QCOMPARE(container.first().value(), 41); + QCOMPARE((container.begin() + 1)->value(), 42); + QCOMPARE(Integer::instanceCount, 2); + return; + } + + QCOMPARE(Integer::instanceCount, 3); +} + +template <template<typename T> class Container> +void containerAppendTest(QObject*) +{ + Container<Integer> container; + + // append to an empty container + try { + container.append(42); + } catch (...) { + QCOMPARE(container.size(), 0); + QCOMPARE(Integer::instanceCount, 0); + return; + } + + // append to a container with one item + try { + container.append(43); + } catch (...) { + QCOMPARE(container.size(), 1); + QCOMPARE(container.first().value(), 42); + QCOMPARE(Integer::instanceCount, 1); + return; + } +} + +template <template<typename T> class Container> +void containerEraseTest(QObject*) +{ + Container<Integer> container; + + try { + container.append(42); + container.append(43); + container.append(44); + container.append(45); + container.append(46); + } catch (...) { + // don't care + return; + } + + // sanity checks + QCOMPARE(container.size(), 5); + QCOMPARE(Integer::instanceCount, 5); + + // delete the first one + try { + container.erase(container.begin()); + } catch (...) { + QCOMPARE(container.size(), 5); + QCOMPARE(container.first().value(), 42); + QCOMPARE(Integer::instanceCount, 5); + return; + } + + QCOMPARE(container.size(), 4); + QCOMPARE(container.first().value(), 43); + QCOMPARE(Integer::instanceCount, 4); + + // delete the last one + try { + container.erase(container.end() - 1); + } catch (...) { + QCOMPARE(container.size(), 4); + QCOMPARE(Integer::instanceCount, 4); + return; + } + + QCOMPARE(container.size(), 3); + QCOMPARE(container.first().value(), 43); + QCOMPARE((container.begin() + 1)->value(), 44); + QCOMPARE((container.begin() + 2)->value(), 45); + QCOMPARE(Integer::instanceCount, 3); + + // delete the middle one + try { + container.erase(container.begin() + 1); + } catch (...) { + QCOMPARE(container.size(), 3); + QCOMPARE(container.first().value(), 43); + QCOMPARE((container.begin() + 1)->value(), 44); + QCOMPARE((container.begin() + 2)->value(), 45); + QCOMPARE(Integer::instanceCount, 3); + return; + } + + QCOMPARE(container.size(), 2); + QCOMPARE(container.first().value(), 43); + QCOMPARE((container.begin() + 1)->value(), 45); + QCOMPARE(Integer::instanceCount, 2); +} + +template <template<typename T> class Container> +static void containerData() +{ + QTest::addColumn<TestFunction>("testFunction"); + + QTest::newRow("insert") << static_cast<TestFunction>(containerInsertTest<Container>); + QTest::newRow("append") << static_cast<TestFunction>(containerAppendTest<Container>); + QTest::newRow("erase") << static_cast<TestFunction>(containerEraseTest<Container>); +} + +void tst_ExceptionSafetyObjects::vector_data() +{ + containerData<QVector>(); +} + +void tst_ExceptionSafetyObjects::vector() +{ + QFETCH(TestFunction, testFunction); + + if (QLatin1String(QTest::currentDataTag()) == QLatin1String("insert")) + QSKIP("QVector::insert is currently not strongly exception safe", SkipSingle); + + doOOMTest(testFunction, 0); +} + +void tst_ExceptionSafetyObjects::list_data() +{ + containerData<QList>(); +} + +void tst_ExceptionSafetyObjects::list() +{ + QFETCH(TestFunction, testFunction); + + doOOMTest(testFunction, 0); +} + +void tst_ExceptionSafetyObjects::linkedList_data() +{ + containerData<QLinkedList>(); +} + +void tst_ExceptionSafetyObjects::linkedList() +{ + QFETCH(TestFunction, testFunction); + + doOOMTest(testFunction, 0); +} + +QTEST_MAIN(tst_ExceptionSafetyObjects) +#include "tst_exceptionsafety_objects.moc" +#endif // QT_NO_EXCEPTIONS diff --git a/tests/auto/headers/headers.pro b/tests/auto/headers/headers.pro index 9da40ce..703da7c 100644 --- a/tests/auto/headers/headers.pro +++ b/tests/auto/headers/headers.pro @@ -1,5 +1,3 @@ load(qttest_p4) SOURCES += tst_headers.cpp QT = core - - diff --git a/tests/auto/languagechange/tst_languagechange.cpp b/tests/auto/languagechange/tst_languagechange.cpp index cb4cf1e..7c98809 100644 --- a/tests/auto/languagechange/tst_languagechange.cpp +++ b/tests/auto/languagechange/tst_languagechange.cpp @@ -122,10 +122,7 @@ public slots: void install() { QCoreApplication::installTranslator(this); QTest::qWait(2500); - //### is there any better way to close a Qt dialog? - QThreadData *data = QThreadData::current(); - if (!data->eventLoops.isEmpty()) - data->eventLoops.top()->quit(); + QApplication::closeAllWindows(); } public: mutable QSet<QByteArray> m_translations; @@ -212,7 +209,12 @@ void tst_languageChange::retranslatability() "languages or to 'RTL' in right-to-left languages (such as Hebrew and Arabic) to " "get proper widget layout."); TransformTranslator translator; +#if defined(Q_OS_SYMBIAN) && defined(Q_CC_NOKIAX86) + // Allow a little extra time or emulator startup delays cause failure + QTimer::singleShot(5000, &translator, SLOT(install())); +#else QTimer::singleShot(500, &translator, SLOT(install())); +#endif switch (dialogType) { case InputDialog: (void)QInputDialog::getInteger(0, QLatin1String("title"), QLatin1String("label")); @@ -235,7 +237,17 @@ void tst_languageChange::retranslatability() QString fooName = tmpParentDir + "/foo"; QDir dir; QCOMPARE(dir.mkpath(tmpDir), true); +#if defined(Q_OS_SYMBIAN) && defined(Q_CC_NOKIAX86) + // Just create a new file instead of copying exe, because exe is not there in emulator + { + QFile fooFile(fooName); + QVERIFY(fooFile.open(QIODevice::WriteOnly | QIODevice::Text)); + for(int i=0; i<2048; i++) // File needs to be big enough for size to read in KB + fooFile.write("@"); + } +#else QCOMPARE(QFile::copy(QApplication::applicationFilePath(), fooName), true); +#endif dlg.setDirectory(tmpParentDir); #ifdef Q_OS_WINCE @@ -244,7 +256,12 @@ void tst_languageChange::retranslatability() dlg.setFileMode(QFileDialog::ExistingFiles); dlg.setViewMode(QFileDialog::Detail); dlg.exec(); +#if defined(Q_OS_SYMBIAN) && defined(Q_CC_NOKIAX86) + // increase the wait time because of increased delay caused by emulator startup + QTest::qWait(15000); +#else QTest::qWait(3000); +#endif QCOMPARE(QFile::remove(fooName), true); QCOMPARE(dir.rmdir(tmpDir), true); QCOMPARE(dir.rmdir(tmpParentDir), true); diff --git a/tests/auto/moc/moc.pro b/tests/auto/moc/moc.pro index f96b4e2..a89ff07 100644 --- a/tests/auto/moc/moc.pro +++ b/tests/auto/moc/moc.pro @@ -20,7 +20,8 @@ HEADERS += using-namespaces.h no-keywords.h task87883.h c-comments.h backslash-n if(*-g++*|*-icc*):!irix-*:!win32-*: HEADERS += os9-newlines.h win-newlines.h SOURCES += tst_moc.cpp -QT += sql network svg script +QT += sql network svg +contains(QT_CONFIG, script): QT += script contains(QT_CONFIG, qt3support): QT += qt3support contains(QT_CONFIG, dbus){ DEFINES += WITH_DBUS diff --git a/tests/auto/moc/no-keywords.h b/tests/auto/moc/no-keywords.h index f062dff..a7d76e7 100644 --- a/tests/auto/moc/no-keywords.h +++ b/tests/auto/moc/no-keywords.h @@ -58,7 +58,9 @@ #if defined(WITH_DBUS) #include <QtDBus> #endif +#ifdef QT_SCRIPT_LIB #include <QtScript> +#endif #undef signals #undef slots diff --git a/tests/auto/moc/testproject/Plugin/Plugin.h b/tests/auto/moc/testproject/Plugin/Plugin.h index da3fa16..90fd985 100644 --- a/tests/auto/moc/testproject/Plugin/Plugin.h +++ b/tests/auto/moc/testproject/Plugin/Plugin.h @@ -45,6 +45,8 @@ struct MyInterface virtual void blah() = 0; }; +QT_BEGIN_NAMESPACE Q_DECLARE_INTERFACE(MyInterface, "MyInterface") +QT_END_NAMESPACE diff --git a/tests/auto/network-settings.h b/tests/auto/network-settings.h index 64bfaee..702dabb 100644 --- a/tests/auto/network-settings.h +++ b/tests/auto/network-settings.h @@ -1,6 +1,4 @@ /**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). ** Contact: Nokia Corporation (qt-info@nokia.com) ** ** This file is part of the test suite of the Qt Toolkit. @@ -39,21 +37,84 @@ ** ****************************************************************************/ #include <QString> +#ifdef QT_NETWORK_LIB #include <QtNetwork/QHostInfo> +#endif + + +#ifdef Q_OS_SYMBIAN +#include <sys/socket.h> +#include <net/if.h> +#include <QSharedPointer> +#include <QHash> +#endif +#if defined(Q_OS_SYMBIAN) +#if defined(Q_CC_NOKIAX86) +// In emulator we use WINSOCK connectivity by default. Unfortunately winsock +// does not work very well with UDP sockets. This defines skips some test +// cases which have known problems. + +// NOTE: Prefer to use WINPCAP based connectivity in S60 emulator when running +// network tests. WINPCAP connectivity uses Symbian OS IP stack, +// correspondingly as HW does. When using WINPCAP disable this define +//#define SYMBIAN_WINSOCK_CONNECTIVITY +#endif // Q_CC_NOKIAX86 + +class QtNetworkSettingsRecord { +public: + QtNetworkSettingsRecord() { } + + QtNetworkSettingsRecord(const QString& recName, const QString& recVal) + : strRecordName(recName), strRecordValue(recVal) { } + + QtNetworkSettingsRecord(const QtNetworkSettingsRecord & other) + : strRecordName(other.strRecordName), strRecordValue(other.strRecordValue) { } + + ~QtNetworkSettingsRecord() { } + + const QString& recordName() const { return strRecordName; } + const QString& recordValue() const { return strRecordValue; } + +private: + QString strRecordName; + QString strRecordValue; +}; + +#endif // Q_OS_SYMBIAN class QtNetworkSettings { public: + static QString serverLocalName() { +#ifdef Q_OS_SYMBIAN + loadTestSettings(); + + if(QtNetworkSettings::entries.contains("server.localname")) { + QtNetworkSettingsRecord* entry = entries["server.localname"]; + return entry->recordValue(); + } +#endif return QString("qt-test-server"); } static QString serverDomainName() { +#ifdef Q_OS_SYMBIAN + loadTestSettings(); + + if(QtNetworkSettings::entries.contains("server.domainname")) { + QtNetworkSettingsRecord* entry = entries["server.domainname"]; + return entry->recordValue(); + } +#endif return QString("qt-test-net"); } static QString serverName() { +#ifdef Q_OS_SYMBIAN + loadTestSettings(); +#endif return serverLocalName() + "." + serverDomainName(); } static QString winServerName() @@ -63,13 +124,205 @@ public: static QString wildcardServerName() { return "qt-test-server.wildcard.dev." + serverDomainName(); + //return "qttest.wildcard.dev." + serverDomainName(); } #ifdef QT_NETWORK_LIB static QHostAddress serverIP() { +#ifdef Q_OS_SYMBIAN + loadTestSettings(); + + if(QtNetworkSettings::entries.contains("server.ip")) { + QtNetworkSettingsRecord* entry = entries["server.ip"]; + if(serverIp.isNull()) { + serverIp = entry->recordValue().toAscii(); + } + return QHostAddress(serverIp.data()); + } +#endif return QHostInfo::fromName(serverName()).addresses().first(); } #endif + static QByteArray expectedReplyIMAP() + { +#ifdef Q_OS_SYMBIAN + loadTestSettings(); + + if(QtNetworkSettings::entries.contains("imap.expectedreply")) { + QtNetworkSettingsRecord* entry = entries["imap.expectedreply"]; + if(imapExpectedReply.isNull()) { + imapExpectedReply = entry->recordValue().toAscii(); + imapExpectedReply.append('\r').append('\n'); + } + return imapExpectedReply.data(); + } +#else + QByteArray expected( "* OK [CAPABILITY IMAP4 IMAP4rev1 LITERAL+ ID STARTTLS LOGINDISABLED] " ); + expected = expected.append(QtNetworkSettings::serverName().toAscii()); + expected = expected.append(" Cyrus IMAP4 v2.3.11-Mandriva-RPM-2.3.11-6mdv2008.1 server ready\r\n"); + return expected; +#endif + } + + static QByteArray expectedReplySSL() + { +#ifdef Q_OS_SYMBIAN + loadTestSettings(); + + if(QtNetworkSettings::entries.contains("imap.expectedreplyssl")) { + QtNetworkSettingsRecord* entry = entries["imap.expectedreplyssl"]; + if(imapExpectedReplySsl.isNull()) { + imapExpectedReplySsl = entry->recordValue().toAscii(); + imapExpectedReplySsl.append('\r').append('\n'); + } + return imapExpectedReplySsl.data(); + } +#endif + QByteArray expected( "* OK [CAPABILITY IMAP4 IMAP4rev1 LITERAL+ ID AUTH=PLAIN SASL-IR] " ); + expected = expected.append(QtNetworkSettings::serverLocalName().toAscii()); + expected = expected.append(" Cyrus IMAP4 v2.3.11-Mandriva-RPM-2.3.11-6mdv2008.1 server ready\r\n"); + return expected; + } + + static QByteArray expectedReplyFtp() + { + QByteArray expected( "220 (vsFTPd 2.0.5)\r\n221 Goodbye.\r\n" ); + return expected; + } + +#ifdef Q_OS_SYMBIAN + static void setDefaultIap() + { + loadDefaultIap(); + + struct ifreq ifReq; + if(entries.contains("iap.default")) { + QtNetworkSettingsRecord* entry = entries["iap.default"]; + QByteArray tmp(entry->recordValue().toAscii()); + strcpy( ifReq.ifr_name, tmp.data()); + } + else // some default value + strcpy( ifReq.ifr_name, "Lab"); + + int err = setdefaultif( &ifReq ); + if(err) + printf("Setting default IAP - '%s' failed: %d\n", ifReq.ifr_name, err); + else + printf("'%s' used as an default IAP\n", ifReq.ifr_name); + } +#endif + +private: + +#ifdef Q_OS_SYMBIAN + + static QHash<QString, QtNetworkSettingsRecord* > entries; + static bool bDefaultIapLoaded; + static bool bTestSettingsLoaded; + static QString iapFileFullPath; + static QByteArray serverIp; + static QByteArray imapExpectedReply; + static QByteArray imapExpectedReplySsl; + + static bool loadDefaultIap() { + if(bDefaultIapLoaded) + return true; + + QFile iapCfgFile(iapFileFullPath); + + bool bFoundDefaultIapTag = false; + + if (iapCfgFile.open(QFile::ReadOnly)) { + QTextStream input(&iapCfgFile); + QString line; + do { + line = input.readLine().trimmed(); + if(line.startsWith(QString("#"))) + continue; // comment found + + if(line.contains(QString("[DEFAULT]"))) { + bFoundDefaultIapTag = true; + } else if(line.contains(QString("[")) && bFoundDefaultIapTag) { + break; + } + + if(bFoundDefaultIapTag && line.contains("name")) { + int position = line.indexOf(QString("=")); + position += QString("=").length(); + + //create record + QtNetworkSettingsRecord *entry = + new QtNetworkSettingsRecord( QString("iap.default"), line.mid(position).trimmed() ); + entries.insert(entry->recordName(), entry); + break; + } + } while (!line.isNull()); + } + + return bDefaultIapLoaded = bFoundDefaultIapTag; + } + + static bool loadTestSettings() { + if(bTestSettingsLoaded) + return true; + + QFile cfgFile(iapFileFullPath); + bool bFoundTestTag = false; + + if (cfgFile.open(QFile::ReadOnly)) { + QTextStream input(&cfgFile); + QString line; + do { + line = input.readLine().trimmed(); + + if(line.startsWith(QString("#")) || line.length() == 0) + continue; // comment or empty line found + + if(line.contains(QString("[TEST]"))) { + bFoundTestTag = true; + } else if(line.startsWith(QString("[")) && bFoundTestTag) { + bFoundTestTag = false; + break; // finished with test tag + } + + if(bFoundTestTag) { // non-empty line + int position = line.indexOf(QString("=")); + + if(position <= 0) // not found + continue; + + // found - extract + + QString recname = line.mid(0, position - QString("=").length()).trimmed(); + QString recval = line.mid(position + QString("=").length()).trimmed(); + + //create record + QtNetworkSettingsRecord *entry = new QtNetworkSettingsRecord(recname, recval); + entries.insert(entry->recordName(), entry); + } + } while (!line.isNull()); + } + + return bTestSettingsLoaded = true; + } +#endif + + }; +#ifdef Q_OS_SYMBIAN +QHash<QString, QtNetworkSettingsRecord* > QtNetworkSettings::entries = QHash<QString, QtNetworkSettingsRecord* > (); +bool QtNetworkSettings::bDefaultIapLoaded = false; +bool QtNetworkSettings::bTestSettingsLoaded = false; +QString QtNetworkSettings::iapFileFullPath = QString("C:\\Data\\iap.txt"); +QByteArray QtNetworkSettings::serverIp; +QByteArray QtNetworkSettings::imapExpectedReply; +QByteArray QtNetworkSettings::imapExpectedReplySsl; +#endif + +#ifdef Q_OS_SYMBIAN +#define Q_SET_DEFAULT_IAP QtNetworkSettings::setDefaultIap(); +#else +#define Q_SET_DEFAULT_IAP +#endif diff --git a/tests/auto/networkselftest/networkselftest.pro b/tests/auto/networkselftest/networkselftest.pro index 9e2ad0e..ac610de 100644 --- a/tests/auto/networkselftest/networkselftest.pro +++ b/tests/auto/networkselftest/networkselftest.pro @@ -2,5 +2,4 @@ load(qttest_p4) SOURCES += tst_networkselftest.cpp QT = core network -DEFINES += SRCDIR=\\\"$$PWD\\\" diff --git a/tests/auto/networkselftest/tst_networkselftest.cpp b/tests/auto/networkselftest/tst_networkselftest.cpp index 0dc3c62..5e07762 100644 --- a/tests/auto/networkselftest/tst_networkselftest.cpp +++ b/tests/auto/networkselftest/tst_networkselftest.cpp @@ -46,6 +46,10 @@ class tst_NetworkSelfTest: public QObject { Q_OBJECT +public: + tst_NetworkSelfTest(); + virtual ~tst_NetworkSelfTest(); + private slots: void hostTest(); void dnsResolution_data(); @@ -303,6 +307,15 @@ static void netChat(int port, const QList<Chat> &chat) } } +tst_NetworkSelfTest::tst_NetworkSelfTest() +{ + Q_SET_DEFAULT_IAP +} + +tst_NetworkSelfTest::~tst_NetworkSelfTest() +{ +} + void tst_NetworkSelfTest::hostTest() { // this is a localhost self-test @@ -361,6 +374,11 @@ void tst_NetworkSelfTest::remotePortsOpen_data() void tst_NetworkSelfTest::remotePortsOpen() { +#ifdef Q_OS_SYMBIAN + if (qstrcmp(QTest::currentDataTag(), "http-proxy-auth-ntlm") == 0) + QSKIP("NTML authentication not yet supported in Symbian", SkipSingle); +#endif + QFETCH(int, portNumber); QTcpSocket socket; socket.connectToHost(QtNetworkSettings::serverName(), portNumber); @@ -514,6 +532,9 @@ void tst_NetworkSelfTest::httpProxyBasicAuth() void tst_NetworkSelfTest::httpProxyNtlmAuth() { +#ifdef Q_OS_SYMBIAN + QSKIP("NTML authentication not yet supported in Symbian", SkipAll); +#else netChat(3130, QList<Chat>() // test auth required response << Chat::send("GET http://" + QtNetworkSettings::serverName().toLatin1() + "/ HTTP/1.0\r\n" @@ -526,6 +547,7 @@ void tst_NetworkSelfTest::httpProxyNtlmAuth() << Chat::discardUntil("\r\nProxy-Authenticate: NTLM\r\n") << Chat::DiscardUntilDisconnect ); +#endif } // SOCKSv5 is a binary protocol diff --git a/tests/auto/patternistexamplefiletree/patternistexamplefiletree.pro b/tests/auto/patternistexamplefiletree/patternistexamplefiletree.pro index 9e962d0..772c833 100644 --- a/tests/auto/patternistexamplefiletree/patternistexamplefiletree.pro +++ b/tests/auto/patternistexamplefiletree/patternistexamplefiletree.pro @@ -1,4 +1,5 @@ load(qttest_p4) SOURCES += tst_patternistexamplefiletree.cpp +QT = core include (../xmlpatterns.pri) diff --git a/tests/auto/patternistexamples/patternistexamples.pro b/tests/auto/patternistexamples/patternistexamples.pro index 90fc166..4092fc8 100644 --- a/tests/auto/patternistexamples/patternistexamples.pro +++ b/tests/auto/patternistexamples/patternistexamples.pro @@ -1,7 +1,7 @@ load(qttest_p4) SOURCES += tst_patternistexamples.cpp CONFIG += qtestlib -wince*: { +wince*|symbian*: { snippets.sources = $$QT_SOURCE_TREE/doc/src/snippets/patternist/* snippets.path = patternist widgetRen.sources = $$QT_SOURCE_TREE/examples/xmlpatterns/xquery/widgetRenderer/* diff --git a/tests/auto/patternistheaders/patternistheaders.pro b/tests/auto/patternistheaders/patternistheaders.pro index be93266..fe4d670 100644 --- a/tests/auto/patternistheaders/patternistheaders.pro +++ b/tests/auto/patternistheaders/patternistheaders.pro @@ -1,4 +1,5 @@ load(qttest_p4) SOURCES += tst_patternistheaders.cpp +QT = core include (../xmlpatterns.pri) diff --git a/tests/auto/q3urloperator/copy.res/.gitattributes b/tests/auto/q3urloperator/copy.res/.gitattributes new file mode 100644 index 0000000..e04709a --- /dev/null +++ b/tests/auto/q3urloperator/copy.res/.gitattributes @@ -0,0 +1 @@ +rfc3252.txt -crlf diff --git a/tests/auto/q_func_info/q_func_info.pro b/tests/auto/q_func_info/q_func_info.pro index fa60aff..b30e3fb 100644 --- a/tests/auto/q_func_info/q_func_info.pro +++ b/tests/auto/q_func_info/q_func_info.pro @@ -1,3 +1,3 @@ load(qttest_p4) SOURCES += tst_q_func_info.cpp -QT -= gui +QT = core diff --git a/tests/auto/q_func_info/tst_q_func_info.cpp b/tests/auto/q_func_info/tst_q_func_info.cpp index fa985b1..51c5dd1 100644 --- a/tests/auto/q_func_info/tst_q_func_info.cpp +++ b/tests/auto/q_func_info/tst_q_func_info.cpp @@ -41,7 +41,7 @@ #include <QString> -#include <QTest> +#include <QtTest/QtTest> #include <QtDebug> class tst_q_func_info : public QObject diff --git a/tests/auto/qabstractitemmodel/qabstractitemmodel.pro b/tests/auto/qabstractitemmodel/qabstractitemmodel.pro index 9bc660d..5ad1020 100644 --- a/tests/auto/qabstractitemmodel/qabstractitemmodel.pro +++ b/tests/auto/qabstractitemmodel/qabstractitemmodel.pro @@ -1,6 +1,3 @@ load(qttest_p4) SOURCES += tst_qabstractitemmodel.cpp - -#QT = core - - +QT = core diff --git a/tests/auto/qabstractitemview/tst_qabstractitemview.cpp b/tests/auto/qabstractitemview/tst_qabstractitemview.cpp index edbbac4..496ab45 100644 --- a/tests/auto/qabstractitemview/tst_qabstractitemview.cpp +++ b/tests/auto/qabstractitemview/tst_qabstractitemview.cpp @@ -148,8 +148,10 @@ public: inline QItemSelectionModel::SelectionFlags tst_selectionCommand(const QModelIndex &index, const QEvent *event = 0) const { return selectionCommand(index, event); } +#ifndef QT_NO_DRAGANDDROP inline void tst_startDrag(Qt::DropActions supportedActions) { startDrag(supportedActions); } +#endif inline QStyleOptionViewItem tst_viewOptions() const { return viewOptions(); } enum tst_State { @@ -267,11 +269,12 @@ void tst_QAbstractItemView::getSetCheck() // bool QAbstractItemView::dragEnabled() // void QAbstractItemView::setDragEnabled(bool) +#ifndef QT_NO_DRAGANDDROP obj1->setDragEnabled(false); QCOMPARE(false, obj1->dragEnabled()); obj1->setDragEnabled(true); QCOMPARE(true, obj1->dragEnabled()); - +#endif // bool QAbstractItemView::alternatingRowColors() // void QAbstractItemView::setAlternatingRowColors(bool) obj1->setAlternatingRowColors(false); @@ -440,6 +443,7 @@ void tst_QAbstractItemView::basic_tests(TestView *view) view->setTabKeyNavigation(true); QCOMPARE(view->tabKeyNavigation(), true); +#ifndef QT_NO_DRAGANDDROP // setDropIndicatorShown view->setDropIndicatorShown(false); QCOMPARE(view->showDropIndicator(), false); @@ -451,6 +455,7 @@ void tst_QAbstractItemView::basic_tests(TestView *view) QCOMPARE(view->dragEnabled(), false); view->setDragEnabled(true); QCOMPARE(view->dragEnabled(), true); +#endif // setAlternatingRowColors view->setAlternatingRowColors(false); @@ -545,6 +550,7 @@ void tst_QAbstractItemView::basic_tests(TestView *view) view->tst_selectionCommand(QModelIndex(), 0); +#ifndef QT_NO_DRAGANDDROP if (!view->model()) view->tst_startDrag(Qt::CopyAction); @@ -562,6 +568,7 @@ void tst_QAbstractItemView::basic_tests(TestView *view) QVERIFY(view->tst_state()==TestView::ExpandingState); view->tst_setState(TestView::CollapsingState); QVERIFY(view->tst_state()==TestView::CollapsingState); +#endif view->tst_startAutoScroll(); view->tst_stopAutoScroll(); diff --git a/tests/auto/qabstractmessagehandler/qabstractmessagehandler.pro b/tests/auto/qabstractmessagehandler/qabstractmessagehandler.pro index 4b2e7b4..5c50103 100644 --- a/tests/auto/qabstractmessagehandler/qabstractmessagehandler.pro +++ b/tests/auto/qabstractmessagehandler/qabstractmessagehandler.pro @@ -1,4 +1,5 @@ load(qttest_p4) SOURCES += tst_qabstractmessagehandler.cpp +QT = core include (../xmlpatterns.pri) diff --git a/tests/auto/qabstractnetworkcache/qabstractnetworkcache.pro b/tests/auto/qabstractnetworkcache/qabstractnetworkcache.pro index cffadb0..11e340d 100644 --- a/tests/auto/qabstractnetworkcache/qabstractnetworkcache.pro +++ b/tests/auto/qabstractnetworkcache/qabstractnetworkcache.pro @@ -2,7 +2,7 @@ load(qttest_p4) QT += network SOURCES += tst_qabstractnetworkcache.cpp -wince*: { +wince*|symbian: { testFiles.sources = tests testFiles.path = . DEPLOYMENT += testFiles diff --git a/tests/auto/qabstractnetworkcache/tst_qabstractnetworkcache.cpp b/tests/auto/qabstractnetworkcache/tst_qabstractnetworkcache.cpp index 1ac72b5..d5e9fea 100644 --- a/tests/auto/qabstractnetworkcache/tst_qabstractnetworkcache.cpp +++ b/tests/auto/qabstractnetworkcache/tst_qabstractnetworkcache.cpp @@ -81,8 +81,12 @@ public: : QNetworkDiskCache(parent) , gotData(false) { +#ifdef Q_OS_SYMBIAN + QString location = QLatin1String("./cache/"); +#else QString location = QDesktopServices::storageLocation(QDesktopServices::DataLocation) - + QLatin1String("/cache/"); + + QLatin1String("/cache/"); +#endif setCacheDirectory(location); clear(); } @@ -99,6 +103,8 @@ public: tst_QAbstractNetworkCache::tst_QAbstractNetworkCache() { + Q_SET_DEFAULT_IAP + QCoreApplication::setOrganizationName(QLatin1String("Trolltech")); QCoreApplication::setApplicationName(QLatin1String("autotest_qabstractnetworkcache")); QCoreApplication::setApplicationVersion(QLatin1String("1.0")); diff --git a/tests/auto/qabstracturiresolver/qabstracturiresolver.pro b/tests/auto/qabstracturiresolver/qabstracturiresolver.pro index de9a368..0d76208 100644 --- a/tests/auto/qabstracturiresolver/qabstracturiresolver.pro +++ b/tests/auto/qabstracturiresolver/qabstracturiresolver.pro @@ -1,5 +1,6 @@ load(qttest_p4) SOURCES += tst_qabstracturiresolver.cpp HEADERS += TestURIResolver.h +QT = core include (../xmlpatterns.pri) diff --git a/tests/auto/qabstractvideobuffer/qabstractvideobuffer.pro b/tests/auto/qabstractvideobuffer/qabstractvideobuffer.pro new file mode 100644 index 0000000..080719a --- /dev/null +++ b/tests/auto/qabstractvideobuffer/qabstractvideobuffer.pro @@ -0,0 +1,5 @@ +load(qttest_p4) +SOURCES += tst_qabstractvideobuffer.cpp + +QT += multimedia +requires(contains(QT_CONFIG, multimedia)) diff --git a/tests/auto/qabstractvideobuffer/tst_qabstractvideobuffer.cpp b/tests/auto/qabstractvideobuffer/tst_qabstractvideobuffer.cpp new file mode 100644 index 0000000..2f376d5 --- /dev/null +++ b/tests/auto/qabstractvideobuffer/tst_qabstractvideobuffer.cpp @@ -0,0 +1,132 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, 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. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QtTest/QtTest> + +#include <QtMultimedia/QAbstractVideoBuffer> + +class tst_QAbstractVideoBuffer : public QObject +{ + Q_OBJECT +public: + tst_QAbstractVideoBuffer(); + ~tst_QAbstractVideoBuffer(); + +public slots: + void initTestCase(); + void cleanupTestCase(); + void init(); + void cleanup(); + +private slots: + void handleType_data(); + void handleType(); + void handle(); +}; + +class QtTestVideoBuffer : public QAbstractVideoBuffer +{ +public: + QtTestVideoBuffer(QAbstractVideoBuffer::HandleType type) : QAbstractVideoBuffer(type) {} + + MapMode mapMode() const { return NotMapped; } + + uchar *map(MapMode, int *, int *) { return 0; } + void unmap() {} +}; + +tst_QAbstractVideoBuffer::tst_QAbstractVideoBuffer() +{ +} + +tst_QAbstractVideoBuffer::~tst_QAbstractVideoBuffer() +{ +} + +void tst_QAbstractVideoBuffer::initTestCase() +{ +} + +void tst_QAbstractVideoBuffer::cleanupTestCase() +{ +} + +void tst_QAbstractVideoBuffer::init() +{ +} + +void tst_QAbstractVideoBuffer::cleanup() +{ +} + +void tst_QAbstractVideoBuffer::handleType_data() +{ + QTest::addColumn<QAbstractVideoBuffer::HandleType>("type"); + + QTest::newRow("none") + << QAbstractVideoBuffer::NoHandle; + QTest::newRow("opengl") + << QAbstractVideoBuffer::GLTextureHandle; + QTest::newRow("user1") + << QAbstractVideoBuffer::UserHandle; + QTest::newRow("user2") + << QAbstractVideoBuffer::HandleType(QAbstractVideoBuffer::UserHandle + 1); +} + +void tst_QAbstractVideoBuffer::handleType() +{ + QFETCH(QAbstractVideoBuffer::HandleType, type); + + QtTestVideoBuffer buffer(type); + + QCOMPARE(buffer.handleType(), type); +} + +void tst_QAbstractVideoBuffer::handle() +{ + QtTestVideoBuffer buffer(QAbstractVideoBuffer::NoHandle); + + QVERIFY(buffer.handle().isNull()); +} + +QTEST_MAIN(tst_QAbstractVideoBuffer) + +#include "tst_qabstractvideobuffer.moc" diff --git a/tests/auto/qabstractvideosurface/qabstractvideosurface.pro b/tests/auto/qabstractvideosurface/qabstractvideosurface.pro new file mode 100644 index 0000000..4e14542 --- /dev/null +++ b/tests/auto/qabstractvideosurface/qabstractvideosurface.pro @@ -0,0 +1,5 @@ +load(qttest_p4) +SOURCES += tst_qabstractvideosurface.cpp + +QT += multimedia +requires(contains(QT_CONFIG, multimedia)) diff --git a/tests/auto/qabstractvideosurface/tst_qabstractvideosurface.cpp b/tests/auto/qabstractvideosurface/tst_qabstractvideosurface.cpp new file mode 100644 index 0000000..0c46ff1 --- /dev/null +++ b/tests/auto/qabstractvideosurface/tst_qabstractvideosurface.cpp @@ -0,0 +1,292 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, 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. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QtTest/QtTest> + +#include <QtMultimedia/QAbstractVideoSurface> +#include <QtMultimedia/QVideoSurfaceFormat> + +class tst_QAbstractVideoSurface : public QObject +{ + Q_OBJECT +public: + tst_QAbstractVideoSurface(); + ~tst_QAbstractVideoSurface(); + +public slots: + void initTestCase(); + void cleanupTestCase(); + void init(); + void cleanup(); + +private slots: + void setError(); + void isFormatSupported_data(); + void isFormatSupported(); + void start_data(); + void start(); +}; + +typedef QMap<QAbstractVideoBuffer::HandleType, QVideoFrame::PixelFormat> SupportedFormatMap; + +Q_DECLARE_METATYPE(SupportedFormatMap) +Q_DECLARE_METATYPE(QVideoSurfaceFormat) +Q_DECLARE_METATYPE(QAbstractVideoSurface::Error); + +class QtTestVideoSurface : public QAbstractVideoSurface +{ + Q_OBJECT +public: + explicit QtTestVideoSurface(QObject *parent = 0) : QAbstractVideoSurface(parent) {} + explicit QtTestVideoSurface(SupportedFormatMap formats, QObject *parent = 0) + : QAbstractVideoSurface(parent), supportedFormats(formats) {} + + QList<QVideoFrame::PixelFormat> supportedPixelFormats( + QAbstractVideoBuffer::HandleType handleType = QAbstractVideoBuffer::NoHandle) const + { + return supportedFormats.values(handleType); + } + + bool present(const QVideoFrame &) { return false; } + + using QAbstractVideoSurface::setError; + +private: + SupportedFormatMap supportedFormats; +}; + +tst_QAbstractVideoSurface::tst_QAbstractVideoSurface() +{ +} + +tst_QAbstractVideoSurface::~tst_QAbstractVideoSurface() +{ +} + +void tst_QAbstractVideoSurface::initTestCase() +{ +} + +void tst_QAbstractVideoSurface::cleanupTestCase() +{ +} + +void tst_QAbstractVideoSurface::init() +{ +} + +void tst_QAbstractVideoSurface::cleanup() +{ +} + +void tst_QAbstractVideoSurface::setError() +{ + qRegisterMetaType<QAbstractVideoSurface::Error>(); + + QtTestVideoSurface surface; + + QCOMPARE(surface.error(), QAbstractVideoSurface::NoError); + + surface.setError(QAbstractVideoSurface::StoppedError); + QCOMPARE(surface.error(), QAbstractVideoSurface::StoppedError); + + surface.setError(QAbstractVideoSurface::ResourceError); + QCOMPARE(surface.error(), QAbstractVideoSurface::ResourceError); + + surface.setError(QAbstractVideoSurface::NoError); + QCOMPARE(surface.error(), QAbstractVideoSurface::NoError); +} + +void tst_QAbstractVideoSurface::isFormatSupported_data() +{ + QTest::addColumn<SupportedFormatMap>("supportedFormats"); + QTest::addColumn<QVideoSurfaceFormat>("format"); + QTest::addColumn<bool>("supported"); + + SupportedFormatMap formats; + + QTest::newRow("no formats: rgb32") + << formats + << QVideoSurfaceFormat(QSize(800, 600), QVideoFrame::Format_RGB32) + << false; + QTest::newRow("no formats: yv12") + << formats + << QVideoSurfaceFormat(QSize(800, 600), QVideoFrame::Format_YV12) + << false; + QTest::newRow("no formats: rgb32 gl") + << formats + << QVideoSurfaceFormat( + QSize(800, 600), + QVideoFrame::Format_RGB32, + QAbstractVideoBuffer::GLTextureHandle) + << false; + QTest::newRow("no formats: rgb24 gl") + << formats + << QVideoSurfaceFormat( + QSize(800, 600), + QVideoFrame::Format_RGB24, + QAbstractVideoBuffer::GLTextureHandle) + << false; + + formats.insertMulti(QAbstractVideoBuffer::NoHandle, QVideoFrame::Format_RGB32); + formats.insertMulti(QAbstractVideoBuffer::NoHandle, QVideoFrame::Format_RGB24); + formats.insertMulti(QAbstractVideoBuffer::NoHandle, QVideoFrame::Format_YUV444); + formats.insertMulti(QAbstractVideoBuffer::GLTextureHandle, QVideoFrame::Format_RGB32); + + QTest::newRow("supported: rgb32") + << formats + << QVideoSurfaceFormat(QSize(800, 600), QVideoFrame::Format_RGB32) + << true; + QTest::newRow("supported: rgb24") + << formats + << QVideoSurfaceFormat(QSize(800, 600), QVideoFrame::Format_RGB24) + << true; + QTest::newRow("unsupported: yv12") + << formats + << QVideoSurfaceFormat(QSize(800, 600), QVideoFrame::Format_YV12) + << false; + QTest::newRow("supported: rgb32 gl") + << formats + << QVideoSurfaceFormat( + QSize(800, 600), + QVideoFrame::Format_RGB32, + QAbstractVideoBuffer::GLTextureHandle) + << true; + QTest::newRow("unsupported: rgb24 gl") + << formats + << QVideoSurfaceFormat( + QSize(800, 600), + QVideoFrame::Format_RGB24, + QAbstractVideoBuffer::GLTextureHandle) + << false; + QTest::newRow("unsupported: yv12 gl") + << formats + << QVideoSurfaceFormat( + QSize(800, 600), + QVideoFrame::Format_YV12, + QAbstractVideoBuffer::GLTextureHandle) + << false; + + formats.insertMulti(QAbstractVideoBuffer::NoHandle, QVideoFrame::Format_YV12); + formats.insertMulti(QAbstractVideoBuffer::GLTextureHandle, QVideoFrame::Format_RGB24); + + QTest::newRow("supported: yv12") + << formats + << QVideoSurfaceFormat(QSize(800, 600), QVideoFrame::Format_YV12) + << true; + QTest::newRow("supported: rgb24 gl") + << formats + << QVideoSurfaceFormat( + QSize(800, 600), + QVideoFrame::Format_RGB24, + QAbstractVideoBuffer::GLTextureHandle) + << true; +} + +void tst_QAbstractVideoSurface::isFormatSupported() +{ + QFETCH(SupportedFormatMap, supportedFormats); + QFETCH(QVideoSurfaceFormat, format); + QFETCH(bool, supported); + + QtTestVideoSurface surface(supportedFormats); + + QCOMPARE(surface.isFormatSupported(format), supported); +} + +void tst_QAbstractVideoSurface::start_data() +{ + QTest::addColumn<QVideoSurfaceFormat>("format"); + + QTest::newRow("rgb32") << QVideoSurfaceFormat( + QSize(800, 600), + QVideoFrame::Format_RGB32); + QTest::newRow("yv12") << QVideoSurfaceFormat( + QSize(800, 600), + QVideoFrame::Format_YV12); + QTest::newRow("rgb32 gl") << QVideoSurfaceFormat( + QSize(800, 600), + QVideoFrame::Format_RGB32, + QAbstractVideoBuffer::GLTextureHandle); +} + +void tst_QAbstractVideoSurface::start() +{ + QFETCH(QVideoSurfaceFormat, format); + + QtTestVideoSurface surface; + surface.setError(QAbstractVideoSurface::ResourceError); + + QSignalSpy formatSpy(&surface, SIGNAL(surfaceFormatChanged(QVideoSurfaceFormat))); + QSignalSpy startedSpy(&surface, SIGNAL(startedChanged(bool))); + + QVERIFY(!surface.isStarted()); + QCOMPARE(surface.surfaceFormat(), QVideoSurfaceFormat()); + + QVERIFY(surface.start(format)); + + QVERIFY(surface.isStarted()); + QCOMPARE(surface.surfaceFormat(), format); + + QCOMPARE(formatSpy.count(), 1); + QCOMPARE(qvariant_cast<QVideoSurfaceFormat>(formatSpy.at(0).at(0)), format); + + QCOMPARE(startedSpy.count(), 1); + QCOMPARE(startedSpy.at(0).at(0).toBool(), true); + + // error() is reset on a successful start. + QCOMPARE(surface.error(), QAbstractVideoSurface::NoError); + + surface.stop(); + + QVERIFY(!surface.isStarted()); + QCOMPARE(surface.surfaceFormat(), QVideoSurfaceFormat()); + + QCOMPARE(formatSpy.count(), 2); + QCOMPARE(qvariant_cast<QVideoSurfaceFormat>(formatSpy.at(1).at(0)), QVideoSurfaceFormat()); + + QCOMPARE(startedSpy.count(), 2); + QCOMPARE(startedSpy.at(1).at(0).toBool(), false); +} + +QTEST_MAIN(tst_QAbstractVideoSurface) + +#include "tst_qabstractvideosurface.moc" diff --git a/tests/auto/qabstractxmlforwarditerator/qabstractxmlforwarditerator.pro b/tests/auto/qabstractxmlforwarditerator/qabstractxmlforwarditerator.pro index f6dca8b..6bc0c59 100644 --- a/tests/auto/qabstractxmlforwarditerator/qabstractxmlforwarditerator.pro +++ b/tests/auto/qabstractxmlforwarditerator/qabstractxmlforwarditerator.pro @@ -1,4 +1,5 @@ load(qttest_p4) SOURCES += tst_qabstractxmlforwarditerator.cpp +QT = core include (../xmlpatterns.pri) diff --git a/tests/auto/qabstractxmlreceiver/qabstractxmlreceiver.pro b/tests/auto/qabstractxmlreceiver/qabstractxmlreceiver.pro index ad3f2b2..2bd2ba4 100644 --- a/tests/auto/qabstractxmlreceiver/qabstractxmlreceiver.pro +++ b/tests/auto/qabstractxmlreceiver/qabstractxmlreceiver.pro @@ -1,4 +1,5 @@ load(qttest_p4) SOURCES += tst_qabstractxmlreceiver.cpp +QT = core include (../xmlpatterns.pri) diff --git a/tests/auto/qaction/tst_qaction.cpp b/tests/auto/qaction/tst_qaction.cpp index 2c6d421..f8d7acf 100644 --- a/tests/auto/qaction/tst_qaction.cpp +++ b/tests/auto/qaction/tst_qaction.cpp @@ -240,7 +240,7 @@ void tst_QAction::setStandardKeys() QVERIFY(act.shortcut() == act.shortcuts().first()); QList<QKeySequence> expected; -#ifdef Q_WS_MAC +#if defined(Q_WS_MAC) || defined(Q_OS_SYMBIAN) expected << QKeySequence("CTRL+C"); #elif defined(Q_WS_WIN) || defined(Q_WS_QWS) expected << QKeySequence("CTRL+C") << QKeySequence("CTRL+INSERT"); diff --git a/tests/auto/qanimationgroup/qanimationgroup.pro b/tests/auto/qanimationgroup/qanimationgroup.pro index 97d33dd..31667a8 100644 --- a/tests/auto/qanimationgroup/qanimationgroup.pro +++ b/tests/auto/qanimationgroup/qanimationgroup.pro @@ -1,5 +1,5 @@ load(qttest_p4) -QT = core gui +QT = core SOURCES += tst_qanimationgroup.cpp diff --git a/tests/auto/qapplication/desktopsettingsaware/desktopsettingsaware.pro b/tests/auto/qapplication/desktopsettingsaware/desktopsettingsaware.pro index 904a62a..93a03db 100644 --- a/tests/auto/qapplication/desktopsettingsaware/desktopsettingsaware.pro +++ b/tests/auto/qapplication/desktopsettingsaware/desktopsettingsaware.pro @@ -3,13 +3,18 @@ ###################################################################### TEMPLATE = app +!symbian*: { DEPENDPATH += . INCLUDEPATH += . -wince*:TARGET = ../desktopsettingsaware +} +wince*|symbian*:TARGET = ../desktopsettingsaware + # Input SOURCES += main.cpp CONFIG += qt warn_on create_prl link_prl CONFIG -= app_bundle + +!symbian*: { OBJECTS_DIR=.obj/debug-shared MOC_DIR=.moc/debug-shared - +} diff --git a/tests/auto/qapplication/test/test.pro b/tests/auto/qapplication/test/test.pro index cda7940..7c3de3c 100644 --- a/tests/auto/qapplication/test/test.pro +++ b/tests/auto/qapplication/test/test.pro @@ -11,6 +11,14 @@ wince* { DEPLOYMENT = additional deploy someTest } +symbian*: { + additional.sources = ../desktopsettingsaware/desktopsettingsaware.exe + additional.path = desktopsettingsaware + someTest.sources = test.pro + someTest.path = test + DEPLOYMENT = additional deploy someTest +} + win32 { CONFIG(debug, debug|release) { TARGET = ../../debug/tst_qapplication diff --git a/tests/auto/qapplication/tst_qapplication.cpp b/tests/auto/qapplication/tst_qapplication.cpp index 00d676f..e37e52d 100644 --- a/tests/auto/qapplication/tst_qapplication.cpp +++ b/tests/auto/qapplication/tst_qapplication.cpp @@ -57,6 +57,21 @@ //TESTED_CLASS= //TESTED_FILES= +#if defined(Q_OS_SYMBIAN) +// In Symbian, the PluginsPath doesn't specify the only absolute path; just the dir that can be found on any drive +static void addExpectedSymbianPluginsPath(QStringList& expected) +{ + QString installPathPlugins = QDir::fromNativeSeparators(QLibraryInfo::location(QLibraryInfo::PluginsPath)); + QFileInfoList driveList = QDir::drives(); + QListIterator<QFileInfo> iter(driveList); + while (iter.hasNext()) { + QFileInfo testFi(iter.next().canonicalPath().append(installPathPlugins)); + if (testFi.exists()) + expected << testFi.canonicalFilePath(); + } +} +#endif + class tst_QApplication : public QObject { Q_OBJECT @@ -787,7 +802,13 @@ void tst_QApplication::libraryPaths() QStringList actual = QApplication::libraryPaths(); actual.sort(); +#if defined(Q_OS_SYMBIAN) + QStringList expected; + addExpectedSymbianPluginsPath(expected); + expected << appDirPath; +#else QStringList expected = QSet<QString>::fromList((QStringList() << installPathPlugins << appDirPath)).toList(); +#endif expected.sort(); QVERIFY2(isPathListIncluded(actual, expected), @@ -890,7 +911,11 @@ void tst_QApplication::libraryPaths_qt_plugin_path() void tst_QApplication::libraryPaths_qt_plugin_path_2() { -#ifdef Q_OS_UNIX +#ifdef Q_OS_SYMBIAN + QByteArray validPath = "C:\\data"; + QByteArray nonExistentPath = "Z:\\nonexistent"; + QByteArray pluginPath = validPath + ";" + nonExistentPath; +#elif defined(Q_OS_UNIX) QByteArray validPath = QDir("/tmp").canonicalPath().toLatin1(); QByteArray nonExistentPath = "/nonexistent"; QByteArray pluginPath = validPath + ":" + nonExistentPath; @@ -915,19 +940,25 @@ void tst_QApplication::libraryPaths_qt_plugin_path_2() QApplication app(argc, &argv0, QApplication::GuiServer); // library path list should contain the default plus the one valid path +#if defined(Q_OS_SYMBIAN) + // In Symbian, the PluginsPath doesn't specify the only absolute path; just the dir that can be found on any drive + QStringList expected; + addExpectedSymbianPluginsPath(expected); + expected << QDir(app.applicationDirPath()).canonicalPath() + << QDir(QDir::fromNativeSeparators(QString::fromLatin1(validPath))).canonicalPath(); +#else QStringList expected = QStringList() << QLibraryInfo::location(QLibraryInfo::PluginsPath) << QDir(app.applicationDirPath()).canonicalPath() << QDir(QDir::fromNativeSeparators(QString::fromLatin1(validPath))).canonicalPath(); -#ifdef Q_OS_WINCE +# ifdef Q_OS_WINCE expected = QSet<QString>::fromList(expected).toList(); +# endif #endif QVERIFY2(isPathListIncluded(app.libraryPaths(), expected), qPrintable("actual:\n - " + app.libraryPaths().join("\n - ") + "\nexpected:\n - " + expected.join("\n - "))); - - qputenv("QT_PLUGIN_PATH", QByteArray()); } { @@ -939,13 +970,19 @@ void tst_QApplication::libraryPaths_qt_plugin_path_2() // the environment variable here doesn't work qputenv("QT_PLUGIN_PATH", pluginPath); - // library path list should contain the default plus the one valid path + // library path list should contain the default +#if defined(Q_OS_SYMBIAN) + QStringList expected; + addExpectedSymbianPluginsPath(expected); + expected << app.applicationDirPath(); +#else QStringList expected = QStringList() << QLibraryInfo::location(QLibraryInfo::PluginsPath) << app.applicationDirPath(); -#ifdef Q_OS_WINCE +# ifdef Q_OS_WINCE expected = QSet<QString>::fromList(expected).toList(); +# endif #endif QVERIFY(isPathListIncluded(app.libraryPaths(), expected)); @@ -1393,6 +1430,13 @@ void tst_QApplication::desktopSettingsAware() testProcess.start("desktopsettingsaware/debug/desktopsettingsaware"); #elif defined(Q_OS_WIN) testProcess.start("desktopsettingsaware/release/desktopsettingsaware"); +#elif defined(Q_OS_SYMBIAN) + testProcess.start("desktopsettingsaware"); +#if defined(Q_CC_NOKIAX86) + QEXPECT_FAIL("", "QProcess on Q_CC_NOKIAX86 cannot launch another Qt application, due to DLL conflicts.", Abort); + // TODO: Remove XFAIL, as soon as we can launch Qt applications from within Qt applications on Symbian + QVERIFY(testProcess.error() != QProcess::FailedToStart); +#endif // defined(Q_CC_NOKIAX86) #else testProcess.start("desktopsettingsaware/desktopsettingsaware"); #endif diff --git a/tests/auto/qatomicint/qatomicint.pro b/tests/auto/qatomicint/qatomicint.pro index 26b5b90..4a09d5f 100644 --- a/tests/auto/qatomicint/qatomicint.pro +++ b/tests/auto/qatomicint/qatomicint.pro @@ -1,6 +1,3 @@ load(qttest_p4) - SOURCES += tst_qatomicint.cpp QT = core - - diff --git a/tests/auto/qatomicpointer/qatomicpointer.pro b/tests/auto/qatomicpointer/qatomicpointer.pro index d4e88f6..d192bad 100644 --- a/tests/auto/qatomicpointer/qatomicpointer.pro +++ b/tests/auto/qatomicpointer/qatomicpointer.pro @@ -1,5 +1,3 @@ load(qttest_p4) SOURCES += tst_qatomicpointer.cpp QT = core - - diff --git a/tests/auto/qautoptr/qautoptr.pro b/tests/auto/qautoptr/qautoptr.pro index 5058409..b0c574f 100644 --- a/tests/auto/qautoptr/qautoptr.pro +++ b/tests/auto/qautoptr/qautoptr.pro @@ -1,4 +1,4 @@ load(qttest_p4) SOURCES += tst_qautoptr.cpp -QT -= gui +QT = core include(../xmlpatterns.pri) diff --git a/tests/auto/qbitarray/qbitarray.pro b/tests/auto/qbitarray/qbitarray.pro index 182b06a..ec110c6 100644 --- a/tests/auto/qbitarray/qbitarray.pro +++ b/tests/auto/qbitarray/qbitarray.pro @@ -1,7 +1,3 @@ load(qttest_p4) SOURCES += tst_qbitarray.cpp - - QT = core - - diff --git a/tests/auto/qbitarray/tst_qbitarray.cpp b/tests/auto/qbitarray/tst_qbitarray.cpp index d48ace1..a98cc3d 100644 --- a/tests/auto/qbitarray/tst_qbitarray.cpp +++ b/tests/auto/qbitarray/tst_qbitarray.cpp @@ -43,7 +43,6 @@ #include <QtTest/QtTest> #include <QtCore/QBuffer> #include <QtCore/QDataStream> -#include <iostream> #include "qbitarray.h" @@ -109,6 +108,8 @@ private slots: void invertOnNull() const; void operator_noteq_data(); void operator_noteq(); + + void resize(); }; Q_DECLARE_METATYPE(QBitArray) @@ -629,5 +630,30 @@ void tst_QBitArray::operator_noteq() QCOMPARE(b, res); } +void tst_QBitArray::resize() +{ + // -- check that a resize handles the bits correctly + QBitArray a = QStringToQBitArray(QString("11")); + a.resize(10); + QVERIFY(a.size() == 10); + QCOMPARE( a, QStringToQBitArray(QString("1100000000")) ); + + a.setBit(9); + a.resize(9); + // now the bit in a should have been gone: + QCOMPARE( a, QStringToQBitArray(QString("110000000")) ); + + // grow the array back and check the new bit + a.resize(10); + QCOMPARE( a, QStringToQBitArray(QString("1100000000")) ); + + // other test with and + a.resize(9); + QBitArray b = QStringToQBitArray(QString("1111111111")); + b &= a; + QCOMPARE( b, QStringToQBitArray(QString("1100000000")) ); + +} + QTEST_APPLESS_MAIN(tst_QBitArray) #include "tst_qbitarray.moc" diff --git a/tests/auto/qbuffer/qbuffer.pro b/tests/auto/qbuffer/qbuffer.pro index fc5842d..ea83657 100644 --- a/tests/auto/qbuffer/qbuffer.pro +++ b/tests/auto/qbuffer/qbuffer.pro @@ -1,7 +1,3 @@ load(qttest_p4) SOURCES += tst_qbuffer.cpp - - QT = core - - diff --git a/tests/auto/qbytearray/.gitattributes b/tests/auto/qbytearray/.gitattributes new file mode 100644 index 0000000..e04709a --- /dev/null +++ b/tests/auto/qbytearray/.gitattributes @@ -0,0 +1 @@ +rfc3252.txt -crlf diff --git a/tests/auto/qbytearray/qbytearray.pro b/tests/auto/qbytearray/qbytearray.pro index f41c7ae..d14534b 100644 --- a/tests/auto/qbytearray/qbytearray.pro +++ b/tests/auto/qbytearray/qbytearray.pro @@ -4,11 +4,16 @@ SOURCES += tst_qbytearray.cpp QT = core -wince*: { +wince*|symbian: { addFile.sources = rfc3252.txt addFile.path = . DEPLOYMENT += addFile +} + +wince: { DEFINES += SRCDIR=\\\"\\\" +} symbian: { + TARGET.EPOCHEAPSIZE="0x100 0x800000" } else { DEFINES += SRCDIR=\\\"$$PWD/\\\" } diff --git a/tests/auto/qbytearray/tst_qbytearray.cpp b/tests/auto/qbytearray/tst_qbytearray.cpp index 47b0937..4ec02bc 100644 --- a/tests/auto/qbytearray/tst_qbytearray.cpp +++ b/tests/auto/qbytearray/tst_qbytearray.cpp @@ -53,6 +53,10 @@ //TESTED_CLASS= //TESTED_FILES= +#if defined(Q_OS_SYMBIAN) +#define SRCDIR "" +#endif + class tst_QByteArray : public QObject { Q_OBJECT @@ -957,7 +961,7 @@ void tst_QByteArray::toInt() QCOMPARE( number, expectednumber ); } -Q_DECLARE_METATYPE(qulonglong); +Q_DECLARE_METATYPE(qulonglong) void tst_QByteArray::toULong_data() { QTest::addColumn<QByteArray>("str"); @@ -967,8 +971,8 @@ void tst_QByteArray::toULong_data() ulong LongMaxPlusOne = (ulong)LONG_MAX + 1; QTest::newRow("LONG_MAX+1") << QString::number(LongMaxPlusOne).toLatin1() << 10 << LongMaxPlusOne << true; - QTest::newRow("default") << QByteArray() << 10 << 0UL << FALSE; - QTest::newRow("empty") << QByteArray("") << 10 << 0UL << FALSE; + QTest::newRow("default") << QByteArray() << 10 << 0UL << false; + QTest::newRow("empty") << QByteArray("") << 10 << 0UL << false; QTest::newRow("ulong1") << QByteArray("3234567890") << 10 << 3234567890UL << true; QTest::newRow("ulong2") << QByteArray("fFFfFfFf") << 16 << 0xFFFFFFFFUL << true; } @@ -993,8 +997,8 @@ void tst_QByteArray::toULongLong_data() QTest::addColumn<qulonglong>("result"); QTest::addColumn<bool>("ok"); - QTest::newRow("default") << QByteArray() << 10 << (qulonglong)0 << FALSE; - QTest::newRow("out of base bound") << QByteArray("c") << 10 << (qulonglong)0 << FALSE; + QTest::newRow("default") << QByteArray() << 10 << (qulonglong)0 << false; + QTest::newRow("out of base bound") << QByteArray("c") << 10 << (qulonglong)0 << false; } @@ -1136,12 +1140,12 @@ void tst_QByteArray::toFromHex() void tst_QByteArray::toFromPercentEncoding() { QByteArray arr("Qt is great!"); - +/* QByteArray data = arr.toPercentEncoding(); QCOMPARE(QString(data), QString("Qt%20is%20great%21")); QCOMPARE(QByteArray::fromPercentEncoding(data), arr); - - data = arr.toPercentEncoding("! ", "Qt"); +*/ + QByteArray data = arr.toPercentEncoding("! ", "Qt"); QCOMPARE(QString(data), QString("%51%74 is grea%74!")); QCOMPARE(QByteArray::fromPercentEncoding(data), arr); diff --git a/tests/auto/qcache/qcache.pro b/tests/auto/qcache/qcache.pro index d09320b..728b0b6 100644 --- a/tests/auto/qcache/qcache.pro +++ b/tests/auto/qcache/qcache.pro @@ -1,7 +1,3 @@ load(qttest_p4) SOURCES += tst_qcache.cpp - - QT = core - - diff --git a/tests/auto/qcalendarwidget/tst_qcalendarwidget.cpp b/tests/auto/qcalendarwidget/tst_qcalendarwidget.cpp index 417a7b6..0037c68 100644 --- a/tests/auto/qcalendarwidget/tst_qcalendarwidget.cpp +++ b/tests/auto/qcalendarwidget/tst_qcalendarwidget.cpp @@ -200,7 +200,7 @@ void tst_QCalendarWidget::buttonClickCheck() QTest::qWait(500); QWidget *widget = qFindChild<QWidget *>(&object, "qt_calendar_calendarview"); QTest::mouseMove(widget); - QTest::mouseClick(widget, Qt::LeftButton, 0, QPoint(), 50); + QTest::mouseClick(widget, Qt::LeftButton); QCOMPARE(2006, object.yearShown()); object.setSelectedDate(selectedDate); object.showSelectedDate(); diff --git a/tests/auto/qchar/qchar.pro b/tests/auto/qchar/qchar.pro index d8c5326..fca4ef6 100644 --- a/tests/auto/qchar/qchar.pro +++ b/tests/auto/qchar/qchar.pro @@ -3,7 +3,7 @@ SOURCES += tst_qchar.cpp QT = core -wince*: { +wince*|symbian*: { deploy.sources += NormalizationTest.txt DEPLOYMENT = deploy } diff --git a/tests/auto/qclipboard/test/test.pro b/tests/auto/qclipboard/test/test.pro index ba70cff..508eba1 100644 --- a/tests/auto/qclipboard/test/test.pro +++ b/tests/auto/qclipboard/test/test.pro @@ -10,7 +10,7 @@ win32 { } } -wince*: { +wince*|symbian*: { copier.sources = ../copier/copier.exe copier.path = copier paster.sources = ../paster/paster.exe diff --git a/tests/auto/qclipboard/tst_qclipboard.cpp b/tests/auto/qclipboard/tst_qclipboard.cpp index e87ce3a..827272b 100644 --- a/tests/auto/qclipboard/tst_qclipboard.cpp +++ b/tests/auto/qclipboard/tst_qclipboard.cpp @@ -108,7 +108,7 @@ void tst_QClipboard::modes() if (!nativeClipboardWorking()) QSKIP("Native clipboard not working in this setup", SkipAll); - const QString defaultMode = "deafult mode text;"; + const QString defaultMode = "default mode text;"; clipboard->setText(defaultMode); QCOMPARE(clipboard->text(), defaultMode); @@ -196,6 +196,8 @@ void tst_QClipboard::copy_exit_paste() #if defined Q_WS_X11 || defined Q_WS_QWS QSKIP("This test does not make sense on X11 and embedded, copied data disappears from the clipboard when the application exits ", SkipAll); // ### It's still possible to test copy/paste - just keep the apps running +#elif defined (Q_OS_SYMBIAN) && defined (Q_CC_NOKIAX86) + QSKIP("emulator cannot launch multiple processes",SkipAll); #endif if (!nativeClipboardWorking()) QSKIP("Native clipboard not working in this setup", SkipAll); @@ -240,7 +242,7 @@ void tst_QClipboard::setMimeData() QApplication::clipboard()->setMimeData(data, QClipboard::Clipboard); QApplication::clipboard()->setMimeData(data, QClipboard::Selection); QApplication::clipboard()->setMimeData(data, QClipboard::FindBuffer); - + QSignalSpy spySelection(QApplication::clipboard(), SIGNAL(selectionChanged())); QSignalSpy spyData(QApplication::clipboard(), SIGNAL(dataChanged())); QSignalSpy spyFindBuffer(QApplication::clipboard(), SIGNAL(findBufferChanged())); @@ -277,7 +279,7 @@ void tst_QClipboard::setMimeData() spySelection.clear(); spyData.clear(); spyFindBuffer.clear(); - + QApplication::clipboard()->setMimeData(newData, QClipboard::Clipboard); QApplication::clipboard()->setMimeData(newData, QClipboard::Selection); // used to crash on X11 QApplication::clipboard()->setMimeData(newData, QClipboard::FindBuffer); diff --git a/tests/auto/qcolor/tst_qcolor.cpp b/tests/auto/qcolor/tst_qcolor.cpp index bc0901a..b61c98d 100644 --- a/tests/auto/qcolor/tst_qcolor.cpp +++ b/tests/auto/qcolor/tst_qcolor.cpp @@ -109,6 +109,13 @@ private slots: void getCmyk(); void setCmyk(); + void hueHsl(); + void saturationHsl(); + void lightness(); + + void getHsl(); + void setHsl(); + void toRgb_data(); void toRgb(); void toRgbNonDestructive(); @@ -121,11 +128,16 @@ private slots: void toCmyk(); void toCmykNonDestructive(); + void toHsl_data(); + void toHsl();; + void toHslNonDestructive(); + void convertTo(); void fromRgb(); void fromHsv(); void fromCmyk(); + void fromHsl(); void light(); void dark(); @@ -556,6 +568,10 @@ void tst_QColor::spec() QColor cmyk = QColor::fromCmyk(0, 0, 0, 0); QCOMPARE(cmyk.spec(), QColor::Cmyk); + + QColor hsl = QColor::fromHsl(0, 0, 0, 0); + QCOMPARE(hsl.spec(), QColor::Hsl); + } void tst_QColor::alpha() @@ -1044,56 +1060,179 @@ void tst_QColor::setCmyk() } } +void tst_QColor::hueHsl() +{ DEPENDS_ON(setHsl()); } + +void tst_QColor::saturationHsl() +{ DEPENDS_ON(setHsl()); } + +void tst_QColor::lightness() +{ DEPENDS_ON(setHsl()); } + +void tst_QColor::getHsl() +{ DEPENDS_ON(setHsl()); } + +void tst_QColor::setHsl() +{ + QColor color; + + for (int A = 0; A <= USHRT_MAX; ++A) { + { + // 0-255 + int a = A >> 8; + color.setHsl(0, 0, 0, a); + QCOMPARE(color.alpha(), a); + + int h, s, l, a2; + color.getHsv(&h, &s, &l, &a2); + QCOMPARE(a2, a); + } + + { + // 0.0-1.0 + qreal a = A / qreal(USHRT_MAX); + color.setHslF(0.0, 0.0, 0.0, a); QCOMPARE(color.alphaF(), a); + + qreal h, s, l, a2; + color.getHslF(&h, &s, &l, &a2); + QCOMPARE(a2, a); + } + } + + for (int H = 0; H < 36000; ++H) { + { + // 0-255 + int h = H / 100; + + color.setHsl(h, 0, 0, 0); + QCOMPARE(color.hslHue(), h); + + int h2, s, l, a; + color.getHsl(&h2, &s, &l, &a); + QCOMPARE(h2, h); + } + + { + // 0.0-1.0 + qreal h = H / 36000.0; + color.setHslF(h, 0.0, 0.0, 0.0); + QCOMPARE(color.hslHueF(), h); + + qreal h2, s, l, a; + color.getHslF(&h2, &s, &l, &a); + QCOMPARE(h2, h); + } + } + + for (int S = 0; S <= USHRT_MAX; ++S) { + { + // 0-255 + int s = S >> 8; + color.setHsl(0, s, 0, 0); + QCOMPARE(color.hslSaturation(), s); + + int h, s2, l, a; + color.getHsl(&h, &s2, &l, &a); + QCOMPARE(s2, s); + } + + { + // 0.0-1.0 + qreal s = S / qreal(USHRT_MAX); + color.setHslF(0.0, s, 0.0, 0.0); + QCOMPARE(color.hslSaturationF(), s); + + qreal h, s2, l, a; + color.getHslF(&h, &s2, &l, &a); + QCOMPARE(s2, s); + } + } + + for (int L = 0; L <= USHRT_MAX; ++L) { + { + // 0-255 + int l = L >> 8; + color.setHsl(0, 0, l, 0); + QCOMPARE(color.lightness(), l); + + int h, s, l2, a; + color.getHsl(&h, &s, &l2, &a); + QCOMPARE(l2, l); + } + + { + // 0.0-1.0 + qreal l = L / qreal(USHRT_MAX); + color.setHslF(0.0, 0.0, l, 0.0); + QCOMPARE(color.lightnessF(), l); + + qreal h, s, l2, a; + color.getHslF(&h, &s, &l2, &a); + QCOMPARE(l2, l); + } + } +} + void tst_QColor::toRgb_data() { QTest::addColumn<QColor>("expectedColor"); QTest::addColumn<QColor>("hsvColor"); QTest::addColumn<QColor>("cmykColor"); + QTest::addColumn<QColor>("hslColor"); QTest::newRow("black") << QColor::fromRgbF(0.0, 0.0, 0.0) << QColor::fromHsvF(-1.0, 0.0, 0.0) - << QColor::fromCmykF(0.0, 0.0, 0.0, 1.0); + << QColor::fromCmykF(0.0, 0.0, 0.0, 1.0) + << QColor::fromHslF(-1.0, 0.0, 0.0); QTest::newRow("white") << QColor::fromRgbF(1.0, 1.0, 1.0) << QColor::fromHsvF(-1.0, 0.0, 1.0) - << QColor::fromCmykF(0.0, 0.0, 0.0, 0.0); + << QColor::fromCmykF(0.0, 0.0, 0.0, 0.0) + << QColor::fromHslF(-1.0, 0.0, 1.0); QTest::newRow("red") << QColor::fromRgbF(1.0, 0.0, 0.0) << QColor::fromHsvF(0.0, 1.0, 1.0) - << QColor::fromCmykF(0.0, 1.0, 1.0, 0.0); + << QColor::fromCmykF(0.0, 1.0, 1.0, 0.0) + << QColor::fromHslF(0.0, 1.0, 0.5, 1.0); QTest::newRow("green") << QColor::fromRgbF(0.0, 1.0, 0.0) << QColor::fromHsvF(0.33333, 1.0, 1.0) - << QColor::fromCmykF(1.0, 0.0, 1.0, 0.0); + << QColor::fromCmykF(1.0, 0.0, 1.0, 0.0) + << QColor::fromHslF(0.33333, 1.0, 0.5); QTest::newRow("blue") << QColor::fromRgbF(0.0, 0.0, 1.0) << QColor::fromHsvF(0.66667, 1.0, 1.0) - << QColor::fromCmykF(1.0, 1.0, 0.0, 0.0); + << QColor::fromCmykF(1.0, 1.0, 0.0, 0.0) + << QColor::fromHslF(0.66667, 1.0, 0.5); QTest::newRow("cyan") << QColor::fromRgbF(0.0, 1.0, 1.0) << QColor::fromHsvF(0.5, 1.0, 1.0) - << QColor::fromCmykF(1.0, 0.0, 0.0, 0.0); + << QColor::fromCmykF(1.0, 0.0, 0.0, 0.0) + << QColor::fromHslF(0.5, 1.0, 0.5); QTest::newRow("magenta") << QColor::fromRgbF(1.0, 0.0, 1.0) << QColor::fromHsvF(0.83333, 1.0, 1.0) - << QColor::fromCmykF(0.0, 1.0, 0.0, 0.0); + << QColor::fromCmykF(0.0, 1.0, 0.0, 0.0) + << QColor::fromHslF(0.83333, 1.0, 0.5); QTest::newRow("yellow") << QColor::fromRgbF(1.0, 1.0, 0.0) << QColor::fromHsvF(0.16667, 1.0, 1.0) - << QColor::fromCmykF(0.0, 0.0, 1.0, 0.0); + << QColor::fromCmykF(0.0, 0.0, 1.0, 0.0) + << QColor::fromHslF(0.16667, 1.0, 0.5); QTest::newRow("gray") << QColor::fromRgbF(0.6431375, 0.6431375, 0.6431375) << QColor::fromHsvF(-1.0, 0.0, 0.6431375) - << QColor::fromCmykF(0.0, 0.0, 0.0, 0.356863); + << QColor::fromCmykF(0.0, 0.0, 0.0, 0.356863) + << QColor::fromHslF(-1.0, 0.0, 0.6431375); // ### add colors using the 0-255 functions } @@ -1106,8 +1245,11 @@ void tst_QColor::toRgb() QFETCH(QColor, expectedColor); QFETCH(QColor, hsvColor); QFETCH(QColor, cmykColor); + QFETCH(QColor, hslColor); QCOMPARE(hsvColor.toRgb(), expectedColor); QCOMPARE(cmykColor.toRgb(), expectedColor); + QCOMPARE(hslColor.toRgb(), expectedColor); + } void tst_QColor::toHsv_data() @@ -1115,16 +1257,19 @@ void tst_QColor::toHsv_data() QTest::addColumn<QColor>("expectedColor"); QTest::addColumn<QColor>("rgbColor"); QTest::addColumn<QColor>("cmykColor"); + QTest::addColumn<QColor>("hslColor"); QTest::newRow("data0") << QColor::fromHsv(300, 255, 255) << QColor(255, 0, 255) - << QColor::fromCmyk(0, 255, 0, 0); + << QColor::fromCmyk(0, 255, 0, 0) + << QColor::fromHslF(300./360., 1., 0.5, 1.0); QTest::newRow("data1") << QColor::fromHsvF(1., 1., 1., 1.) << QColor(255, 0, 0, 255) - << QColor::fromCmykF(0., 1., 1., 0.); + << QColor::fromCmykF(0., 1., 1., 0.) + << QColor::fromHsvF(1., 1., 1., 1.); } void tst_QColor::toRgbNonDestructive() @@ -1141,8 +1286,10 @@ void tst_QColor::toHsv() QFETCH(QColor, expectedColor); QFETCH(QColor, rgbColor); QFETCH(QColor, cmykColor); + QFETCH(QColor, hslColor); QCOMPARE(rgbColor.toHsv(), expectedColor); QCOMPARE(cmykColor.toHsv(), expectedColor); + QCOMPARE(hslColor.toHsv(), expectedColor); } void tst_QColor::toHsvNonDestructive() @@ -1156,16 +1303,19 @@ void tst_QColor::toCmyk_data() QTest::addColumn<QColor>("expectedColor"); QTest::addColumn<QColor>("rgbColor"); QTest::addColumn<QColor>("hsvColor"); + QTest::addColumn<QColor>("hslColor"); QTest::newRow("data0") << QColor::fromCmykF(1.0, 0.0, 0.0, 0.0) << QColor(0, 255, 255) - << QColor::fromHsv(180, 255, 255); + << QColor::fromHsv(180, 255, 255) + << QColor::fromHslF(180./360., 1., 0.5, 1.0); QTest::newRow("data1") << QColor::fromCmyk(255, 255, 255, 255) << QColor::fromRgb(0, 0, 0) - << QColor::fromRgb(0, 0, 0).toHsv(); + << QColor::fromRgb(0, 0, 0).toHsv() + << QColor::fromRgb(0, 0, 0).toHsl(); } void tst_QColor::toCmyk() @@ -1176,8 +1326,10 @@ void tst_QColor::toCmyk() QFETCH(QColor, expectedColor); QFETCH(QColor, rgbColor); QFETCH(QColor, hsvColor); + QFETCH(QColor, hslColor); QCOMPARE(rgbColor.toHsv().toCmyk(), expectedColor); QCOMPARE(hsvColor.toCmyk(), expectedColor); + QCOMPARE(hslColor.toCmyk(), expectedColor); } void tst_QColor::toCmykNonDestructive() @@ -1186,6 +1338,51 @@ void tst_QColor::toCmykNonDestructive() QCOMPARE(aColor, aColor.toCmyk()); } +void tst_QColor::toHsl_data() +{ + QTest::addColumn<QColor>("expectedColor"); + QTest::addColumn<QColor>("hsvColor"); + QTest::addColumn<QColor>("rgbColor"); + QTest::addColumn<QColor>("cmykColor"); + + + QTest::newRow("data0") + << QColor::fromHslF(300./360., 1., 0.5, 1.0) + << QColor::fromHsv(300, 255, 255) + << QColor(255, 0, 255) + << QColor::fromCmyk(0, 255, 0, 0); + + QTest::newRow("data1") + << QColor::fromHslF(1., 1., 0.5, 1.0) + << QColor::fromHsvF(1., 1., 1., 1.) + << QColor(255, 0, 0, 255) + << QColor::fromCmykF(0., 1., 1., 0.); +} + +void tst_QColor::toHsl() +{ + // invalid should remain invalid + QVERIFY(!QColor().toHsl().isValid()); + + QFETCH(QColor, expectedColor); + QFETCH(QColor, rgbColor); + QFETCH(QColor, cmykColor); + QFETCH(QColor, hsvColor); + + QCOMPARE(rgbColor.toHsl(), expectedColor); + QCOMPARE(cmykColor.toHsl(), expectedColor); + QCOMPARE(hsvColor.toHsl(), expectedColor); + +} + + +void tst_QColor::toHslNonDestructive() +{ + QColor aColor = QColor::fromHslF(0.11, 0.22, 0.33, 0.44); + QCOMPARE(aColor, aColor.toHsl()); +} + + void tst_QColor::convertTo() { QColor color(Qt::black); @@ -1199,12 +1396,16 @@ void tst_QColor::convertTo() QColor cmyk = color.convertTo(QColor::Cmyk); QVERIFY(cmyk.spec() == QColor::Cmyk); + QColor hsl = color.convertTo(QColor::Hsl); + QVERIFY(hsl.spec() == QColor::Hsl); + QColor invalid = color.convertTo(QColor::Invalid); QVERIFY(invalid.spec() == QColor::Invalid); DEPENDS_ON(toRgb()); DEPENDS_ON(toHsv()); DEPENDS_ON(toCmyk()); + DEPENDS_ON(toHsl()); } void tst_QColor::fromRgb() @@ -1216,6 +1417,9 @@ void tst_QColor::fromHsv() void tst_QColor::fromCmyk() { DEPENDS_ON(convertTo()); } +void tst_QColor::fromHsl() +{ DEPENDS_ON(convertTo()); } + void tst_QColor::light() { QColor gray(Qt::gray); diff --git a/tests/auto/qcolumnview/tst_qcolumnview.cpp b/tests/auto/qcolumnview/tst_qcolumnview.cpp index f6fadb8..82913fb 100644 --- a/tests/auto/qcolumnview/tst_qcolumnview.cpp +++ b/tests/auto/qcolumnview/tst_qcolumnview.cpp @@ -45,7 +45,9 @@ #include <qitemdelegate.h> #include <qcolumnview.h> #include "../../../src/gui/itemviews/qcolumnviewgrip_p.h" +#ifndef Q_OS_SYMBIAN #include "../../../src/gui/dialogs/qfilesystemmodel_p.h" +#endif #include <qdirmodel.h> #include <qstringlistmodel.h> #include <qdebug.h> diff --git a/tests/auto/qcombobox/qcombobox.pro b/tests/auto/qcombobox/qcombobox.pro index 60bf1c8..f36a6fe 100644 --- a/tests/auto/qcombobox/qcombobox.pro +++ b/tests/auto/qcombobox/qcombobox.pro @@ -2,5 +2,3 @@ load(qttest_p4) SOURCES += tst_qcombobox.cpp contains(QT_CONFIG, qt3support): QT += qt3support - - diff --git a/tests/auto/qcombobox/tst_qcombobox.cpp b/tests/auto/qcombobox/tst_qcombobox.cpp index 84217a8..b568c60 100644 --- a/tests/auto/qcombobox/tst_qcombobox.cpp +++ b/tests/auto/qcombobox/tst_qcombobox.cpp @@ -1234,7 +1234,6 @@ void tst_QComboBox::insertItem() testWidget->setEditable(true); if (editable) testWidget->setEditText("FOO"); - #if defined (QT3_SUPPORT) if (testQt3Support) testWidget->insertItem(itemLabel, insertIndex); @@ -1895,10 +1894,10 @@ void tst_QComboBox::itemListPosition() //tests that the list is not out of the screen boundaries //put the QApplication layout back - qApp->setLayoutDirection(Qt::LeftToRight); + QApplication::setLayoutDirection(Qt::LeftToRight); //we test QFontComboBox because it has the specific behaviour to set a fixed size - //the the list view + //to the list view QFontComboBox combo; //the code to get the avaialbe screen space is copied from QComboBox code @@ -1915,13 +1914,17 @@ void tst_QComboBox::itemListPosition() screen = QApplication::desktop()->availableGeometry(scrNumber); #endif - combo.move(screen.width()-combo.sizeHint().width(), 0); //puts the combo the the top-right corner + combo.move(screen.width()-combo.sizeHint().width(), 0); //puts the combo to the top-right corner combo.show(); QTest::qWait(100); //wait because the window manager can move the window if there is a right panel combo.showPopup(); QTest::qWait(100); +#if defined(Q_WS_S60) + // Assuming that QtS60 style is used, here. But other ones would certainly also fail + QEXPECT_FAIL("", "QtS60Style does not yet position the combobox popup correctly", Continue); +#endif QVERIFY( combo.view()->window()->x() + combo.view()->window()->width() <= screen.x() + screen.width() ); } @@ -2257,7 +2260,11 @@ void tst_QComboBox::setItemDelegate() QComboBox comboBox; QStyledItemDelegate *itemDelegate = new QStyledItemDelegate; comboBox.setItemDelegate(itemDelegate); +#ifdef Q_CC_MWERKS + QCOMPARE(static_cast<QStyledItemDelegate *>(comboBox.itemDelegate()), itemDelegate); +#else QCOMPARE(comboBox.itemDelegate(), itemDelegate); +#endif } void tst_QComboBox::task253944_itemDelegateIsReset() @@ -2267,10 +2274,18 @@ void tst_QComboBox::task253944_itemDelegateIsReset() comboBox.setItemDelegate(itemDelegate); comboBox.setEditable(true); +#ifdef Q_CC_MWERKS + QCOMPARE(static_cast<QStyledItemDelegate *>(comboBox.itemDelegate()), itemDelegate); +#else QCOMPARE(comboBox.itemDelegate(), itemDelegate); +#endif comboBox.setStyleSheet("QComboBox { border: 1px solid gray; }"); +#ifdef Q_CC_MWERKS + QCOMPARE(static_cast<QStyledItemDelegate *>(comboBox.itemDelegate()), itemDelegate); +#else QCOMPARE(comboBox.itemDelegate(), itemDelegate); +#endif } diff --git a/tests/auto/qcompleter/tst_qcompleter.cpp b/tests/auto/qcompleter/tst_qcompleter.cpp index f3e902b..e29b64d 100644 --- a/tests/auto/qcompleter/tst_qcompleter.cpp +++ b/tests/auto/qcompleter/tst_qcompleter.cpp @@ -575,6 +575,9 @@ void tst_QCompleter::directoryModel_data() #elif defined(Q_OS_WIN) QTest::newRow("()") << "C" << "" << "C:" << "C:"; QTest::newRow("()") << "C:\\Program" << "" << "Program Files" << "C:\\Program Files"; +#elif defined(Q_OS_SYMBIAN) + QTest::newRow("()") << "C" << "" << "C:" << "C:"; + QTest::newRow("()") << "C:\\re" << "" << "resource" << "C:\\resource"; #elif defined (Q_OS_MAC) QTest::newRow("()") << "" << "" << "/" << "/"; QTest::newRow("(/a)") << "/a" << "" << "Applications" << "/Applications"; diff --git a/tests/auto/qcoreapplication/qcoreapplication.pro b/tests/auto/qcoreapplication/qcoreapplication.pro index 64a4ad4..27f5e58 100644 --- a/tests/auto/qcoreapplication/qcoreapplication.pro +++ b/tests/auto/qcoreapplication/qcoreapplication.pro @@ -1,6 +1,3 @@ load(qttest_p4) SOURCES += tst_qcoreapplication.cpp - QT = core - - diff --git a/tests/auto/qcryptographichash/qcryptographichash.pro b/tests/auto/qcryptographichash/qcryptographichash.pro index 07d8857..aa9a7c4 100644 --- a/tests/auto/qcryptographichash/qcryptographichash.pro +++ b/tests/auto/qcryptographichash/qcryptographichash.pro @@ -1,6 +1,8 @@ load(qttest_p4) - SOURCES += tst_qcryptographichash.cpp QT = core - +symbian*: { +TARGET.EPOCSTACKSIZE =0x5000 +TARGET.EPOCHEAPSIZE="0x100000 0x1000000 // Min 1Mb, max 16Mb" +} diff --git a/tests/auto/qcssparser/qcssparser.pro b/tests/auto/qcssparser/qcssparser.pro index fb1f17e..ce1281f 100644 --- a/tests/auto/qcssparser/qcssparser.pro +++ b/tests/auto/qcssparser/qcssparser.pro @@ -1,11 +1,14 @@ load(qttest_p4) SOURCES += tst_qcssparser.cpp -DEFINES += SRCDIR=\\\"$$PWD\\\" QT += xml requires(contains(QT_CONFIG,private_tests)) -wince*: { +!symbian: { + DEFINES += SRCDIR=\\\"$$PWD\\\" +} + +wince*|symbian: { addFiles.sources = testdata addFiles.path = . DEPLOYMENT += addFiles diff --git a/tests/auto/qcssparser/tst_qcssparser.cpp b/tests/auto/qcssparser/tst_qcssparser.cpp index a294059..4ec6d51 100644 --- a/tests/auto/qcssparser/tst_qcssparser.cpp +++ b/tests/auto/qcssparser/tst_qcssparser.cpp @@ -98,7 +98,7 @@ void tst_QCssParser::scanner_data() QTest::addColumn<QString>("input"); QTest::addColumn<QString>("output"); -#if !defined(Q_OS_IRIX) && !defined(Q_OS_WINCE) +#if !defined(Q_OS_IRIX) && !defined(Q_OS_WINCE) && !defined(Q_OS_SYMBIAN) QDir d(SRCDIR); #else QDir d(QDir::current()); @@ -884,7 +884,7 @@ private: QDomDocument doc; }; -Q_DECLARE_METATYPE(QDomDocument); +Q_DECLARE_METATYPE(QDomDocument) void tst_QCssParser::marginValue_data() { diff --git a/tests/auto/qdatastream/qdatastream.pro b/tests/auto/qdatastream/qdatastream.pro index 40231ea..5b90357 100644 --- a/tests/auto/qdatastream/qdatastream.pro +++ b/tests/auto/qdatastream/qdatastream.pro @@ -1,8 +1,10 @@ load(qttest_p4) SOURCES += tst_qdatastream.cpp +!symbian: { cross_compile: DEFINES += SVGFILE=\\\"tests2.svg\\\" else: DEFINES += SVGFILE=\\\"gearflowers.svg\\\" +} # for qpaintdevicemetrics.h contains(QT_CONFIG, qt3support):QT += qt3support @@ -14,7 +16,15 @@ wince*: { addFiles.path = . DEPLOYMENT += addFiles DEFINES += SRCDIR=\\\"\\\" -} else { +} else:symbian { + # SRCDIR and SVGFILE defined in code in symbian + addFiles.sources = datastream.q42 tests2.svg + addFiles.path = . + DEPLOYMENT += addFiles + TARGET.EPOCHEAPSIZE = 1000000 10000000 + TARGET.UID3 = 0xE0340001 + DEFINES += SYMBIAN_SRCDIR_UID=$$lower($$replace(TARGET.UID3,"0x","")) +}else { DEFINES += SRCDIR=\\\"$$PWD/\\\" } diff --git a/tests/auto/qdatastream/tst_qdatastream.cpp b/tests/auto/qdatastream/tst_qdatastream.cpp index 8971e01..eaae3ea 100644 --- a/tests/auto/qdatastream/tst_qdatastream.cpp +++ b/tests/auto/qdatastream/tst_qdatastream.cpp @@ -47,6 +47,13 @@ #endif #include <QtSvg/QtSvg> +#if defined(Q_OS_SYMBIAN) +# define STRINGIFY(x) #x +# define TOSTRING(x) STRINGIFY(x) +# define SRCDIR "C:/Private/" TOSTRING(SYMBIAN_SRCDIR_UID) "/" +#define SVGFILE "tests2.svg" +#endif + Q_DECLARE_METATYPE(QBitArray) Q_DECLARE_METATYPE(qint64) @@ -2056,7 +2063,7 @@ static QRegion qRegionData(int index) case 4: return QRegion(100, -100, 2048, 4096, QRegion::Rectangle); case 5: return QRegion(-100, 100, 4096, 2048, QRegion::Rectangle); case 6: return QRegion(0, 0, 0, 0, QRegion::Ellipse); -#if !defined(Q_OS_UNIX) && !defined(Q_OS_WINCE) // all our Unix platforms use X regions. +#if defined(Q_OS_SYMBIAN) || (!defined(Q_OS_UNIX) && !defined(Q_OS_WINCE)) // all our Unix platforms use X regions. case 7: return QRegion(1, 2, 300, 400, QRegion::Ellipse); case 8: return QRegion(100, 100, 1024, 768, QRegion::Ellipse); case 9: return QRegion(-100, -100, 1024, 1024, QRegion::Ellipse); @@ -2707,7 +2714,7 @@ void tst_QDataStream::status_charptr_QByteArray_data() QTest::addColumn<int>("expectedStatus"); QTest::addColumn<QByteArray>("expectedString"); -#ifndef Q_OS_WINCE +#if !defined(Q_OS_WINCE) && !defined(Q_OS_SYMBIAN) #ifdef QT3_SUPPORT QByteArray oneMbMinus1(1024 * 1024 - 1); #else @@ -2725,7 +2732,7 @@ void tst_QDataStream::status_charptr_QByteArray_data() QTest::newRow("size 3") << QByteArray("\x00\x00\x00\x03jkl", 7) << (int) QDataStream::Ok << QByteArray("jkl"); QTest::newRow("size 4") << QByteArray("\x00\x00\x00\x04jklm", 8) << (int) QDataStream::Ok << QByteArray("jklm"); QTest::newRow("size 4j") << QByteArray("\x00\x00\x00\x04jklmj", 8) << (int) QDataStream::Ok << QByteArray("jklm"); -#ifndef Q_OS_WINCE +#if !defined(Q_OS_WINCE) && !defined(Q_OS_SYMBIAN) QTest::newRow("size 1MB-1") << QByteArray("\x00\x0f\xff\xff", 4) + oneMbMinus1 + QByteArray("j") << (int) QDataStream::Ok << oneMbMinus1; QTest::newRow("size 1MB") << QByteArray("\x00\x10\x00\x00", 4) + oneMbMinus1 + QByteArray("jkl") << (int) QDataStream::Ok << oneMbMinus1 + "j"; QTest::newRow("size 1MB+1") << QByteArray("\x00\x10\x00\x01", 4) + oneMbMinus1 + QByteArray("jkl") << (int) QDataStream::Ok << oneMbMinus1 + "jk"; @@ -2745,7 +2752,7 @@ void tst_QDataStream::status_charptr_QByteArray_data() QTest::newRow("badsize 2") << QByteArray("\x00\x00\x00\x02j", 5) << (int) QDataStream::ReadPastEnd << QByteArray(); QTest::newRow("badsize 3") << QByteArray("\x00\x00\x00\x03jk", 6) << (int) QDataStream::ReadPastEnd << QByteArray(); QTest::newRow("badsize 4") << QByteArray("\x00\x00\x00\x04jkl", 7) << (int) QDataStream::ReadPastEnd << QByteArray(); -#ifndef Q_OS_WINCE +#if !defined(Q_OS_WINCE) && !defined(Q_OS_SYMBIAN) QTest::newRow("badsize 1MB") << QByteArray("\x00\x10\x00\x00", 4) + oneMbMinus1 << (int) QDataStream::ReadPastEnd << QByteArray(); QTest::newRow("badsize 1MB+1") << QByteArray("\x00\x10\x00\x01", 4) + oneMbMinus1 + QByteArray("j") << (int) QDataStream::ReadPastEnd << QByteArray(); QTest::newRow("badsize 3MB") << QByteArray("\x00\x30\x00\x00", 4) + threeMbMinus1 << (int) QDataStream::ReadPastEnd << QByteArray(); @@ -2819,7 +2826,7 @@ void tst_QDataStream::status_QString_data() QTest::addColumn<int>("expectedStatus"); QTest::addColumn<QString>("expectedString"); -#ifndef Q_OS_WINCE +#if !defined(Q_OS_WINCE) && !defined(Q_OS_SYMBIAN) QString oneMbMinus1; oneMbMinus1.resize(1024 * 1024 - 1); for (int i = 0; i < oneMbMinus1.size(); ++i) @@ -2837,7 +2844,7 @@ void tst_QDataStream::status_QString_data() QTest::newRow("size 3") << QByteArray("\x00\x00\x00\x06\x00j\x00k\x00l", 10) << (int) QDataStream::Ok << QString("jkl"); QTest::newRow("size 4") << QByteArray("\x00\x00\x00\x08\x00j\x00k\x00l\x00m", 12) << (int) QDataStream::Ok << QString("jklm"); QTest::newRow("size 4j") << QByteArray("\x00\x00\x00\x08\x00j\x00k\x00l\x00mjj", 14) << (int) QDataStream::Ok << QString("jklm"); -#ifndef Q_OS_WINCE +#if !defined(Q_OS_WINCE) && !defined(Q_OS_SYMBIAN) QTest::newRow("size 1MB-1") << QByteArray("\x00\x1f\xff\xfe", 4) + oneMbMinus1Data + QByteArray("jj") << (int) QDataStream::Ok << oneMbMinus1; QTest::newRow("size 1MB") << QByteArray("\x00\x20\x00\x00", 4) + oneMbMinus1Data + QByteArray("\x00j\x00k\x00l", 6) << (int) QDataStream::Ok << oneMbMinus1 + "j"; QTest::newRow("size 1MB+1") << QByteArray("\x00\x20\x00\x02", 4) + oneMbMinus1Data + QByteArray("\x00j\x00k\x00l", 6) << (int) QDataStream::Ok << oneMbMinus1 + "jk"; @@ -2857,7 +2864,7 @@ void tst_QDataStream::status_QString_data() QTest::newRow("badsize 2") << QByteArray("\x00\x00\x00\x04jj", 6) << (int) QDataStream::ReadPastEnd << QString(); QTest::newRow("badsize 3") << QByteArray("\x00\x00\x00\x06jjkk", 8) << (int) QDataStream::ReadPastEnd << QString(); QTest::newRow("badsize 4") << QByteArray("\x00\x00\x00\x08jjkkll", 10) << (int) QDataStream::ReadPastEnd << QString(); -#ifndef Q_OS_WINCE +#if !defined(Q_OS_WINCE) && !defined(Q_OS_SYMBIAN) QTest::newRow("badsize 1MB") << QByteArray("\x00\x20\x00\x00", 4) + oneMbMinus1Data << (int) QDataStream::ReadPastEnd << QString(); QTest::newRow("badsize 1MB+1") << QByteArray("\x00\x20\x00\x02", 4) + oneMbMinus1Data + QByteArray("j") << (int) QDataStream::ReadPastEnd << QString(); QTest::newRow("badsize 3MB") << QByteArray("\x00\x60\x00\x00", 4) + threeMbMinus1Data << (int) QDataStream::ReadPastEnd << QString(); @@ -3086,9 +3093,22 @@ void tst_QDataStream::streamToAndFromQByteArray() void tst_QDataStream::streamRealDataTypes() { -#ifdef Q_OS_WINCE +#if defined(Q_OS_WINCE) + // Note: Probably actually same 'qreal being typedeffed as float instead of double' issue as in Symbian + // instead of what CE skip message says. QSKIP("Skipped on CE as it demands too much memory and fragments", SkipAll); +#elif defined(Q_OS_SYMBIAN) + // qreal is typedeffed float in symbian instead of double like in most platforms, so reference stream + // gets corrupted. Basically this test is flawed, as one shouldn't use naked typedeffed types in + // streams that are meant to work cross-platform. + // As this test also tests other floating point using classes, we do not simply skip it, but work around + // the qreal issue by redefining qreal as double for the duration of this function. + // Note that streaming classes works because they do explicitly use double instead of qreal when + // writing/reading to/from stream. +# define qreal double + qWarning("Note: streamRealDataTypes test redefines qreal as double in symbian!!!"); #endif + // Generate QPicture from SVG. QSvgRenderer renderer(svgFile); QVERIFY(renderer.isValid()); @@ -3206,6 +3226,9 @@ void tst_QDataStream::streamRealDataTypes() QCOMPARE(cGrad, conicalBrush); QCOMPARE(pen.widthF(), qreal(1.5)); } +#if defined(Q_OS_SYMBIAN) + #undef qreal +#endif } #ifdef QT3_SUPPORT diff --git a/tests/auto/qdate/qdate.pro b/tests/auto/qdate/qdate.pro index ea61c59..6e2781b3 100644 --- a/tests/auto/qdate/qdate.pro +++ b/tests/auto/qdate/qdate.pro @@ -1,7 +1,3 @@ load(qttest_p4) SOURCES += tst_qdate.cpp - - QT = core - - diff --git a/tests/auto/qdatetime/tst_qdatetime.cpp b/tests/auto/qdatetime/tst_qdatetime.cpp index c46394b..cbd6ede 100644 --- a/tests/auto/qdatetime/tst_qdatetime.cpp +++ b/tests/auto/qdatetime/tst_qdatetime.cpp @@ -877,13 +877,13 @@ void tst_QDateTime::toTime_t_data() QTest::addColumn<QString>("dateTimeStr"); QTest::addColumn<bool>("res"); - QTest::newRow( "data1" ) << str( 1800, 1, 1, 12, 0, 0 ) << FALSE; - QTest::newRow( "data2" ) << str( 1969, 1, 1, 12, 0, 0 ) << FALSE; - QTest::newRow( "data3" ) << str( 2002, 1, 1, 12, 0, 0 ) << TRUE; - QTest::newRow( "data4" ) << str( 2002, 6, 1, 12, 0, 0 ) << TRUE; - QTest::newRow( "data5" ) << QString("INVALID") << FALSE; - QTest::newRow( "data6" ) << str( 2038, 1, 1, 12, 0, 0 ) << TRUE; - QTest::newRow( "data7" ) << str( 2063, 4, 5, 12, 0, 0 ) << TRUE; // the day of First Contact + QTest::newRow( "data1" ) << str( 1800, 1, 1, 12, 0, 0 ) << false; + QTest::newRow( "data2" ) << str( 1969, 1, 1, 12, 0, 0 ) << false; + QTest::newRow( "data3" ) << str( 2002, 1, 1, 12, 0, 0 ) << true; + QTest::newRow( "data4" ) << str( 2002, 6, 1, 12, 0, 0 ) << true; + QTest::newRow( "data5" ) << QString("INVALID") << false; + QTest::newRow( "data6" ) << str( 2038, 1, 1, 12, 0, 0 ) << true; + QTest::newRow( "data7" ) << str( 2063, 4, 5, 12, 0, 0 ) << true; // the day of First Contact QTest::newRow( "data8" ) << str( 2107, 1, 1, 12, 0, 0 ) << bool( sizeof(uint) > 32 && sizeof(time_t) > 32 ); } diff --git a/tests/auto/qdatetimeedit/tst_qdatetimeedit.cpp b/tests/auto/qdatetimeedit/tst_qdatetimeedit.cpp index a290568..3f2c63e 100644 --- a/tests/auto/qdatetimeedit/tst_qdatetimeedit.cpp +++ b/tests/auto/qdatetimeedit/tst_qdatetimeedit.cpp @@ -2213,21 +2213,16 @@ void tst_QDateTimeEdit::mousePress() testWidget->setDate(QDate(2004, 6, 23)); testWidget->setCurrentSection(QDateTimeEdit::YearSection); QCOMPARE(testWidget->currentSection(), QDateTimeEdit::YearSection); - int offset = 10; -#if defined(Q_OS_WINCE) - offset = 20; - if (qt_wince_is_pocket_pc()) { - // depending on wether the display is double-pixeld, we need - // to click at a different position - bool doubledSize = false; - int dpi = GetDeviceCaps(GetDC(0), LOGPIXELSX); - if ((dpi < 1000) && (dpi > 0)) - doubledSize = true; - offset = doubledSize ? 50 : 25; // On CE buttons are aligned horizontal - } -#endif - QTest::mouseClick(testWidget, Qt::LeftButton, 0, QPoint(testWidget->width() - offset, 5)); + + // Ask the SC_SpinBoxUp button location from style + QStyleOptionSpinBox so; + so.rect = testWidget->rect(); + QRect rectUp = testWidget->style()->subControlRect(QStyle::CC_SpinBox, &so, QStyle::SC_SpinBoxUp, testWidget); + + // Send mouseClick to center of SC_SpinBoxUp + QTest::mouseClick(testWidget, Qt::LeftButton, 0, rectUp.center()); QCOMPARE(testWidget->date().year(), 2005); + } void tst_QDateTimeEdit::stepHourAMPM_data() diff --git a/tests/auto/qdebug/qdebug.pro b/tests/auto/qdebug/qdebug.pro index 57aac48..6e75a09 100644 --- a/tests/auto/qdebug/qdebug.pro +++ b/tests/auto/qdebug/qdebug.pro @@ -1,7 +1,3 @@ load(qttest_p4) SOURCES += tst_qdebug.cpp - QT = core - - - diff --git a/tests/auto/qdesktopservices/qdesktopservices.pro b/tests/auto/qdesktopservices/qdesktopservices.pro index 05110bb..9ef557d 100644 --- a/tests/auto/qdesktopservices/qdesktopservices.pro +++ b/tests/auto/qdesktopservices/qdesktopservices.pro @@ -2,3 +2,28 @@ CONFIG += qttest_p4 SOURCES += tst_qdesktopservices.cpp TARGET = tst_qdesktopservices +symbian: { + dummy.sources = text\testfile.txt + dummy.path = . + + text.sources = text\* + text.path = \data\others\ + + image.sources = image\* + image.path = \data\images\ + + audio.sources = audio\* + audio.path = \data\sounds\ + + video.sources = video\* + video.path = \data\videos\ + + install.sources = install\* + install.path = \data\installs\ + + DEPLOYMENT += image audio video install + + # These are only needed for manual tests + #DEPLOYMENT += dummy text + } + diff --git a/tests/auto/qdesktopservices/tst_qdesktopservices.cpp b/tests/auto/qdesktopservices/tst_qdesktopservices.cpp index 0d65102..2d5a28c 100644 --- a/tests/auto/qdesktopservices/tst_qdesktopservices.cpp +++ b/tests/auto/qdesktopservices/tst_qdesktopservices.cpp @@ -45,6 +45,7 @@ #include <qdebug.h> #include <qdesktopservices.h> +//#define RUN_MANUAL_TESTS //TESTED_CLASS= //TESTED_FILES= @@ -59,6 +60,17 @@ private slots: void init(); void cleanup(); void openUrl(); +#ifdef Q_OS_SYMBIAN + // These test are manual ones, you need to check from device that + // correct system application is started with correct content + // When you want to run these test, uncomment //#define RUN_MANUAL_TESTS + void openHttpUrl_data(); + void openHttpUrl(); + void openMailtoUrl_data(); + void openMailtoUrl(); + void openFileUrl_data(); + void openFileUrl(); +#endif void handlers(); void storageLocation_data(); void storageLocation(); @@ -92,11 +104,146 @@ void tst_qdesktopservices::openUrl() // At the bare minimum check that they return false for invalid url's QCOMPARE(QDesktopServices::openUrl(QUrl()), false); #if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) - // this test is only valid on windows on other systems it might mean open a new document in the application handling .file + // this test is only valid on windows on other systems it might mean open a new document in the application handling .file QCOMPARE(QDesktopServices::openUrl(QUrl("file://invalid.file")), false); #endif } +#ifdef Q_OS_SYMBIAN +void tst_qdesktopservices::openHttpUrl_data() +{ + QTest::addColumn<QUrl>("url"); + QTest::addColumn<bool>("result"); + QTest::newRow("BasicWithHttp") << QUrl("http://www.google.fi") << true; + QTest::newRow("BasicWithoutHttp") << QUrl("www.nokia.fi") << true; + QTest::newRow("BasicWithUserAndPw") << QUrl("http://s60prereleases:oslofjord@pepper.troll.no/s60prereleases/patches/") << true; + QTest::newRow("URL with space") << QUrl("http://www.manataka.org/Contents Page.html") << true; + +} + +void tst_qdesktopservices::openHttpUrl() +{ +#ifndef RUN_MANUAL_TESTS + QSKIP("Test disabled -- only for manual purposes", SkipAll); +#endif + + QFETCH(QUrl, url); + QFETCH(bool, result); + QCOMPARE(QDesktopServices::openUrl(url), result); + QTest::qWait(30000); +} + +void tst_qdesktopservices::openMailtoUrl_data() +{ + QTest::addColumn<QUrl>("url"); + QTest::addColumn<bool>("result"); + + // http://en.wikipedia.org/wiki/E-mail_address + // RFC Valid e-mail addresses + QTest::newRow("Wiki valid email 1") << QUrl("mailto:abc@example.com") << true; + QTest::newRow("Wiki valid email 2") << QUrl("mailto:Abc@example.com") << true; + QTest::newRow("Wiki valid email 3") << QUrl("mailto:aBC@example.com") << true; + QTest::newRow("Wiki valid email 4") << QUrl("mailto:abc.123@example.com") << true; + QTest::newRow("Wiki valid email 5") << QUrl("mailto:1234567890@example.com") << true; + QTest::newRow("Wiki valid email 6") << QUrl("mailto:_______@example.com") << true; + QTest::newRow("Wiki valid email 7") << QUrl("mailto:abc+mailbox/department=shipping@example.com") << true; + // S60 email client considers the next URL invalid, even ity should be valid + QTest::newRow("Wiki valid email 8") << QUrl("mailto:!#$%&'*+-/=?^_`.{|}~@example.com") << true; // all of these characters are allowed + QTest::newRow("Wiki valid email 9") << QUrl("mailto:\"abc@def\"@example.com") << true; // anything goes inside quotation marks + QTest::newRow("Wiki valid email 10") << QUrl("mailto:\"Fred \\\"quota\\\" Bloggs\"@example.com") << true; // however, quotes need escaping + + // RFC invalid e-mail addresses + // These return true even though they are invalid, but check that user is notified about invalid URL in mail application + QTest::newRow("Wiki invalid email 1") << QUrl("mailto:Abc.example.com") << true; // character @ is missing + QTest::newRow("Wiki invalid email 2") << QUrl("mailto:Abc.@example.com") << true; // character dot(.) is last in local part + QTest::newRow("Wiki invalid email 3") << QUrl("mailto:Abc..123@example.com") << true; // character dot(.) is double + QTest::newRow("Wiki invalid email 4") << QUrl("mailto:A@b@c@example.com") << true; // only one @ is allowed outside quotations marks + QTest::newRow("Wiki invalid email 5") << QUrl("mailto:()[]\\;:,<>@example.com") << true; // none of the characters before the @ is allowed outside quotation marks + + QTest::newRow("Basic") << QUrl("mailto:test@nokia.com") << true; + QTest::newRow("BasicSeveralAddr") << QUrl("mailto:test@nokia.com,test2@nokia.com,test3@nokia.com") << true; + QTest::newRow("BasicAndSubject") << QUrl("mailto:test@nokia.com?subject=hello nokia") << true; + QTest::newRow("BasicAndTo") << QUrl("mailto:test@nokia.com?to=test2@nokia.com") << true; + + QTest::newRow("BasicAndCc") << QUrl("mailto:test@nokia.com?cc=mycc@address.com") << true; + QTest::newRow("BasicAndBcc") << QUrl("mailto:test@nokia.com?bcc=mybcc@address.com") << true; + QTest::newRow("BasicAndBody") << QUrl("mailto:test@nokia.com?body=Test email message body") << true; + + // RFC examples, these are actually invalid because there is not host defined + // Check that user is notified about invalid URL in mail application + QTest::newRow("RFC2368 Example 1") << QUrl::fromEncoded("mailto:addr1%2C%20addr2") << true; + QTest::newRow("RFC2368 Example 2") << QUrl::fromEncoded("mailto:?to=addr1%2C%20addr2") << true; + QTest::newRow("RFC2368 Example 3") << QUrl("mailto:addr1?to=addr2") << true; + + QTest::newRow("RFC2368 Example 4") << QUrl("mailto:joe@example.com?cc=bob@example.com&body=hello") << true; + QTest::newRow("RFC2368 Example 5") << QUrl("mailto:?to=joe@example.com&cc=bob@example.com&body=hello") << true; + QTest::newRow("RFC2368 Example 6") << QUrl("mailto:foobar@example.com?In-Reply-To=%3c3469A91.D10AF4C@example.com") << true; // OpaqueData + QTest::newRow("RFC2368 Example 7") << QUrl::fromEncoded("mailto:infobot@example.com?body=send%20current-issue%0D%0Asend%20index") << true; + QTest::newRow("RFC2368 Example 8") << QUrl::fromEncoded("mailto:infobot@example.com?body=send%20current-issue") << true; + QTest::newRow("RFC2368 Example 9") << QUrl("mailto:infobot@example.com?subject=current-issue") << true; + QTest::newRow("RFC2368 Example 10") << QUrl("mailto:chris@example.com") << true; + + //QTest::newRow("RFC2368 Example 11 - illegal chars") << QUrl("mailto:joe@example.com?cc=bob@example.com?body=hello") << false; + QTest::newRow("RFC2368 Example 12") << QUrl::fromEncoded("mailto:gorby%25kremvax@example.com") << true; // encoded reserved chars '%' + QTest::newRow("RFC2368 Example 13") << QUrl::fromEncoded("mailto:unlikely%3Faddress@example.com?blat=foop") << true; // encoded reserved chars `?' +} + +void tst_qdesktopservices::openMailtoUrl() +{ +#ifndef RUN_MANUAL_TESTS + QSKIP("Test disabled -- only for manual purposes", SkipAll); +#endif + + QFETCH(QUrl, url); + QFETCH(bool, result); + QCOMPARE(QDesktopServices::openUrl(url), result); +} + +void tst_qdesktopservices::openFileUrl_data() +{ + QTest::addColumn<QUrl>("url"); + QTest::addColumn<bool>("result"); + + // Text files + QTest::newRow("DOS text file") << QUrl("file:///c:/data/others/dosfile.txt") << true; + QTest::newRow("No EOF text file") << QUrl("file:///c:/data/others/noendofline.txt") << true; + QTest::newRow("text file") << QUrl("file:///c:/data/others/testfile.txt") << true; + QTest::newRow("text file with space") << QUrl("file:///c:/data/others/test file.txt") << true; + + // Images + QTest::newRow("BMP image") << QUrl("file:///c:/data/images/image.bmp") << true; + QTest::newRow("GIF image") << QUrl("file:///c:/data/images/image.gif") << true; + QTest::newRow("JPG image") << QUrl("file:///c:/data/images/image.jpg") << true; + QTest::newRow("PNG image") << QUrl("file:///c:/data/images/image.png") << true; + + // Audio + QTest::newRow("MP4 audio") << QUrl("file:///c:/data/sounds/aac-only.mp4") << true; + QTest::newRow("3GP audio") << QUrl("file:///c:/data/sounds/audio_3gpp.3gp") << true; + + // Video + QTest::newRow("MP4 video") << QUrl("file:///c:/data/videos/vid-mpeg4-22k.mp4") << true; + + // Installs + QTest::newRow("SISX") << QUrl("file:///c:/data/installs/ErrRd.sisx") << true; + + // Errors + QTest::newRow("File does not exist") << QUrl("file:///c:/thisfileneverexists.txt") << false; +} + +void tst_qdesktopservices::openFileUrl() +{ +#ifndef RUN_MANUAL_TESTS + QSKIP("Test disabled -- only for manual purposes", SkipAll); +#endif + + QFETCH(QUrl, url); + QFETCH(bool, result); + QCOMPARE(QDesktopServices::openUrl(url), result); + QTest::qWait(15000); +} +#endif + + class MyUrlHandler : public QObject { Q_OBJECT @@ -146,8 +293,64 @@ void tst_qdesktopservices::storageLocation_data() void tst_qdesktopservices::storageLocation() { QFETCH(QDesktopServices::StandardLocation, location); +#ifdef Q_OS_SYMBIAN + QString storageLocation = QDesktopServices::storageLocation(location); + QString displayName = QDesktopServices::displayName(location); + //qDebug( "displayName: %s", displayName ); + + storageLocation = storageLocation.toLower(); + displayName = displayName.toLower(); + + QString drive = QDir::currentPath().left(2).toLower(); + if( drive == "z:" ) + drive = "c:"; + + switch(location) { + case QDesktopServices::DesktopLocation: + QCOMPARE( storageLocation, drive + QString("/data") ); + break; + case QDesktopServices::DocumentsLocation: + QCOMPARE( storageLocation, drive + QString("/data") ); + break; + case QDesktopServices::FontsLocation: + // Currently point always to ROM + QCOMPARE( storageLocation, QString("z:/resource/fonts") ); + break; + case QDesktopServices::ApplicationsLocation: +#ifdef Q_CC_NOKIAX86 + QCOMPARE( storageLocation, QString("z:/sys/bin") ); +#else + QCOMPARE( storageLocation, drive + QString("/sys/bin") ); +#endif + break; + case QDesktopServices::MusicLocation: + QCOMPARE( storageLocation, drive + QString("/data/sounds") ); + break; + case QDesktopServices::MoviesLocation: + QCOMPARE( storageLocation, drive + QString("/data/videos") ); + break; + case QDesktopServices::PicturesLocation: + QCOMPARE( storageLocation, drive + QString("/data/images") ); + break; + case QDesktopServices::TempLocation: + QCOMPARE( storageLocation, QDir::tempPath().toLower()); + break; + case QDesktopServices::HomeLocation: + QCOMPARE( storageLocation, QDir::homePath().toLower()); + break; + case QDesktopServices::DataLocation: + // Just check the folder not the drive + QCOMPARE( storageLocation.mid(2), QDir::currentPath().mid(2).toLower()); + break; + default: + QCOMPARE( storageLocation, QString() ); + break; + } + +#else QDesktopServices::storageLocation(location); QDesktopServices::displayName(location); +#endif } diff --git a/tests/auto/qdir/qdir.pro b/tests/auto/qdir/qdir.pro index 404a137..0111672 100644 --- a/tests/auto/qdir/qdir.pro +++ b/tests/auto/qdir/qdir.pro @@ -8,6 +8,16 @@ wince*:{ QT = core DEFINES += SRCDIR=\\\"\\\" +} symbian:{ + DirFiles.sources = testdir testdata searchdir resources entrylist types tst_qdir.cpp + DirFiles.path = . + DEPLOYMENT += DirFiles + + QT = core + TARGET.CAPABILITY += AllFiles + + TARGET.UID3 = 0xE0340002 + DEFINES += SYMBIAN_SRCDIR_UID=$$lower($$replace(TARGET.UID3,"0x","")) } else { QT = core contains(QT_CONFIG, qt3support):QT += qt3support diff --git a/tests/auto/qdir/tst_qdir.cpp b/tests/auto/qdir/tst_qdir.cpp index a07f548..c00ca7a 100644 --- a/tests/auto/qdir/tst_qdir.cpp +++ b/tests/auto/qdir/tst_qdir.cpp @@ -48,13 +48,24 @@ #include <qfileinfo.h> #include <qregexp.h> #include <qstringlist.h> - #include "../network-settings.h" +#if defined(Q_OS_SYMBIAN) +# define STRINGIFY(x) #x +# define TOSTRING(x) STRINGIFY(x) +# define SRCDIR "C:/Private/" TOSTRING(SYMBIAN_SRCDIR_UID) "/" +#endif + #if defined(Q_OS_VXWORKS) #define Q_NO_SYMLINKS #endif +#if defined(Q_OS_SYMBIAN) +// Open C in Symbian doesn't support symbolic links to directories +#define Q_NO_SYMLINKS_TO_DIRS +#endif + + //TESTED_CLASS= //TESTED_FILES= @@ -178,11 +189,20 @@ void tst_QDir::getSetCheck() tst_QDir::tst_QDir() { +#ifdef Q_OS_SYMBIAN + // Can't deploy empty test dir, so create it here + QDir dir(SRCDIR); + dir.mkdir("testData"); +#endif } tst_QDir::~tst_QDir() { - +#ifdef Q_OS_SYMBIAN + // Remove created test dir + QDir dir(SRCDIR); + dir.rmdir("testData"); +#endif } void tst_QDir::construction() @@ -198,7 +218,7 @@ void tst_QDir::setPath_data() QTest::addColumn<QString>("dir2"); QTest::newRow("data0") << QString(".") << QString(".."); -#if defined(Q_WS_WIN) && !defined(Q_OS_WINCE) +#if (defined(Q_WS_WIN) && !defined(Q_OS_WINCE)) || defined(Q_OS_SYMBIAN) QTest::newRow("data1") << QString("c:/") << QDir::currentPath(); #endif } @@ -295,7 +315,7 @@ void tst_QDir::exists_data() QTest::newRow("simple dir") << SRCDIR "resources" << true; QTest::newRow("simple dir with slash") << SRCDIR "resources/" << true; -#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) +#if (defined(Q_OS_WIN) && !defined(Q_OS_WINCE)) QTest::newRow("unc 1") << "//" + QtNetworkSettings::winServerName() << true; QTest::newRow("unc 2") << "//" + QtNetworkSettings::winServerName() + "/" << true; QTest::newRow("unc 3") << "//" + QtNetworkSettings::winServerName() + "/testshare" << true; @@ -305,7 +325,8 @@ void tst_QDir::exists_data() QTest::newRow("unc 7") << "//" + QtNetworkSettings::winServerName() + "/testshare/adirthatshouldnotexist" << false; QTest::newRow("unc 8") << "//" + QtNetworkSettings::winServerName() + "/asharethatshouldnotexist" << false; QTest::newRow("unc 9") << "//ahostthatshouldnotexist" << false; - +#endif +#if (defined(Q_OS_WIN) && !defined(Q_OS_WINCE)) || defined(Q_OS_SYMBIAN) QTest::newRow("This drive should exist") << "C:/" << true; // find a non-existing drive and check if it does not exist QFileInfoList drives = QFSFileEngine::drives(); @@ -341,7 +362,7 @@ void tst_QDir::isRelativePath_data() QTest::addColumn<bool>("relative"); QTest::newRow("data0") << "../somedir" << true; -#if defined(Q_WS_WIN) && !defined(Q_OS_WINCE) +#if (defined(Q_WS_WIN) && !defined(Q_OS_WINCE)) || defined(Q_OS_SYMBIAN) QTest::newRow("data1") << "C:/sOmedir" << false; #endif QTest::newRow("data2") << "somedir" << true; @@ -394,20 +415,20 @@ void tst_QDir::entryList_data() QTest::addColumn<int>("sortspec"); QTest::addColumn<QStringList>("expected"); QTest::newRow("spaces1") << SRCDIR "testdir/spaces" << QStringList("*. bar") - << (int)(QDir::NoFilter) << (int)(QDir::NoSort) - << QStringList("foo. bar"); // notice how spaces5 works + << (int)(QDir::NoFilter) << (int)(QDir::NoSort) + << QStringList("foo. bar"); // notice how spaces5 works QTest::newRow("spaces2") << SRCDIR "testdir/spaces" << QStringList("*.bar") - << (int)(QDir::NoFilter) << (int)(QDir::NoSort) - << QStringList("foo.bar"); + << (int)(QDir::NoFilter) << (int)(QDir::NoSort) + << QStringList("foo.bar"); QTest::newRow("spaces3") << SRCDIR "testdir/spaces" << QStringList("foo.*") - << (int)(QDir::NoFilter) << (int)(QDir::NoSort) - << QString("foo. bar,foo.bar").split(','); + << (int)(QDir::NoFilter) << (int)(QDir::NoSort) + << QString("foo. bar,foo.bar").split(','); QTest::newRow("files1") << SRCDIR "testdir/dir" << QString("*r.cpp *.pro").split(" ") - << (int)(QDir::NoFilter) << (int)(QDir::NoSort) - << QString("qdir.pro,qrc_qdir.cpp,tst_qdir.cpp").split(','); + << (int)(QDir::NoFilter) << (int)(QDir::NoSort) + << QString("qdir.pro,qrc_qdir.cpp,tst_qdir.cpp").split(','); QTest::newRow("testdir1") << SRCDIR "testdir" << QStringList() - << (int)(QDir::AllDirs) << (int)(QDir::NoSort) - << QString(".,..,dir,spaces").split(','); + << (int)(QDir::AllDirs) << (int)(QDir::NoSort) + << QString(".,..,dir,spaces").split(','); // #### this test uses filenames that cannot be represented on all filesystems we test, in // particular HFS+ on the Mac. When checking out the files with perforce it silently ignores the // error that it cannot represent the file names stored in the repository and the test fails. That @@ -416,8 +437,8 @@ void tst_QDir::entryList_data() // ignored but git reports an error. The test only tried to prevent QDir from _hanging_ when listing // the directory. // QTest::newRow("unprintablenames") << SRCDIR "unprintablenames" << QStringList("*") -// << (int)(QDir::NoFilter) << (int)(QDir::NoSort) -// << QString(".,..").split(","); +// << (int)(QDir::NoFilter) << (int)(QDir::NoSort) +// << QString(".,..").split(","); QTest::newRow("resources1") << QString(":/tst_qdir/resources/entryList") << QStringList("*.data") << (int)(QDir::NoFilter) << (int)(QDir::NoSort) << QString("file1.data,file2.data,file3.data").split(','); @@ -553,17 +574,61 @@ void tst_QDir::entryList() QFile::remove(SRCDIR "entrylist/brokenlink.lnk"); QFile::remove(SRCDIR "entrylist/brokenlink"); - // WinCE does not have . and .. in the directory listing -#ifdef Q_OS_WINCE - expected.removeAll("."); - expected.removeAll(".."); + // WinCE/Symbian does not have . and .. in the directory listing +#if defined(Q_OS_WINCE) || defined(Q_OS_SYMBIAN) + expected.removeAll("."); + expected.removeAll(".."); #endif -#ifdef Q_OS_WIN +#if defined(Q_OS_WIN) // ### Sadly, this is a platform difference right now. QFile::link(SRCDIR "entryList/file", SRCDIR "entrylist/linktofile.lnk"); QFile::link(SRCDIR "entryList/directory", SRCDIR "entrylist/linktodirectory.lnk"); QFile::link(SRCDIR "entryList/nothing", SRCDIR "entrylist/brokenlink.lnk"); +#elif defined(Q_OS_SYMBIAN) + // Symbian doesn't support links to directories + expected.removeAll("linktodirectory.lnk"); + + // Expecting failures from a couple of OpenC bugs. Do checks only once. + static int xFailChecked = false; + static int expectedFail1 = false; + static int expectedFail2 = false; + + if (!expectedFail1) { + // Can't create link if file doesn't exist in symbian, so create file temporarily, + // But only if testing for + QFile tempFile(SRCDIR "entryList/nothing"); + tempFile.open(QIODevice::WriteOnly); + tempFile.link(SRCDIR "entryList/brokenlink.lnk"); + tempFile.remove(); + } + + if (!expectedFail2) { + QFile::link(SRCDIR "entryList/file", SRCDIR "entrylist/linktofile.lnk"); + } + + if (!xFailChecked) { + // ### Until OpenC supports stat correctly for symbolic links, expect them to fail. + expectedFail1 = QFileInfo(SRCDIR "entryList/brokenlink.lnk").exists(); + expectedFail2 = !(QFileInfo(SRCDIR "entryList/linktofile.lnk").isFile()); + + QEXPECT_FAIL("", "OpenC bug, stat for broken links returns normally, when it should return error.", Continue); + QVERIFY(!expectedFail1); + + QEXPECT_FAIL("", "OpenC bug, stat for file links doesn't indicate them as such.", Continue); + QVERIFY(!expectedFail2); + xFailChecked = true; + } + + if (expectedFail1) { + expected.removeAll("brokenlink.lnk"); + QFile::remove(SRCDIR "entrylist/brokenlink.lnk"); + } + + if (expectedFail2) { + expected.removeAll("linktofile.lnk"); + QFile::remove(SRCDIR "entrylist/linktofile.lnk"); + } #else QFile::link("file", SRCDIR "entrylist/linktofile.lnk"); QFile::link("directory", SRCDIR "entrylist/linktodirectory.lnk"); @@ -587,9 +652,8 @@ void tst_QDir::entryList() // lock up. The actual result depends on the file system. return; } - bool doContentCheck = true; -#ifdef Q_OS_UNIX +#if defined(Q_OS_UNIX) && !defined(Q_OS_SYMBIAN) if (qstrcmp(QTest::currentDataTag(), "QDir::AllEntries | QDir::Writable") == 0) { // for root, everything is writeable if (::getuid() == 0) @@ -604,6 +668,11 @@ void tst_QDir::entryList() QCOMPARE(actual.count(), expected.count()); } +#if defined(Q_OS_SYMBIAN) + // Test cleanup on device requires setting the permissions back to normal + QFile(SRCDIR "entrylist/file").setPermissions(QFile::WriteUser | QFile::ReadUser); +#endif + QFile::remove(SRCDIR "entrylist/writable"); QFile::remove(SRCDIR "entrylist/linktofile"); QFile::remove(SRCDIR "entrylist/linktodirectory"); @@ -619,7 +688,7 @@ void tst_QDir::entryListSimple_data() QTest::addColumn<int>("countMin"); QTest::newRow("data2") << "do_not_expect_this_path_to_exist/" << 0; -#if defined(Q_OS_WINCE) +#if defined(Q_OS_WINCE) || defined(Q_OS_SYMBIAN) QTest::newRow("simple dir") << SRCDIR "resources" << 0; QTest::newRow("simple dir with slash") << SRCDIR "resources/" << 0; #else @@ -653,25 +722,36 @@ void tst_QDir::entryListSimple() void tst_QDir::entryListWithSymLinks() { #ifndef Q_NO_SYMLINKS +# ifndef Q_NO_SYMLINKS_TO_DIRS QFile::remove("myLinkToDir.lnk"); +# endif QFile::remove("myLinkToFile.lnk"); QFile::remove("testfile.cpp"); QDir dir; dir.mkdir("myDir"); QFile("testfile.cpp").open(QIODevice::WriteOnly); +# ifndef Q_NO_SYMLINKS_TO_DIRS QVERIFY(QFile::link("myDir", "myLinkToDir.lnk")); +# endif QVERIFY(QFile::link("testfile.cpp", "myLinkToFile.lnk")); { QStringList entryList = QDir().entryList(); QVERIFY(entryList.contains("myDir")); +# ifndef Q_NO_SYMLINKS_TO_DIRS QVERIFY(entryList.contains("myLinkToDir.lnk")); +#endif QVERIFY(entryList.contains("myLinkToFile.lnk")); } { QStringList entryList = QDir().entryList(QDir::Dirs); QVERIFY(entryList.contains("myDir")); +# ifndef Q_NO_SYMLINKS_TO_DIRS QVERIFY(entryList.contains("myLinkToDir.lnk")); +#endif +#if defined(Q_OS_SYMBIAN) + QEXPECT_FAIL("", "OpenC stat for symlinks is buggy.", Continue); +#endif QVERIFY(!entryList.contains("myLinkToFile.lnk")); } { @@ -706,7 +786,7 @@ void tst_QDir::canonicalPath_data() } #endif - QTest::newRow("relative") << "." << appPath; + QTest::newRow("relative") << "." << appPath; QTest::newRow("relativeSubDir") << "./testData/../testData" << appPath + "/testData"; #ifndef Q_WS_WIN @@ -734,7 +814,7 @@ void tst_QDir::canonicalPath() QFETCH(QString, canonicalPath); QDir dir(path); -#ifdef Q_OS_WIN +#if defined(Q_OS_WIN) || defined(Q_OS_SYMBIAN) QCOMPARE(dir.canonicalPath().toLower(), canonicalPath.toLower()); #else QCOMPARE(dir.canonicalPath(), canonicalPath); @@ -753,10 +833,10 @@ void tst_QDir::current_data() else appPath.chop(1); // remove the ending slash #if defined Q_WS_WIN - if (appPath.endsWith("release", Qt::CaseInsensitive)) - appPath = appPath.left(appPath.length()-8); + if (appPath.endsWith("release", Qt::CaseInsensitive)) + appPath = appPath.left(appPath.length()-8); else if (appPath.endsWith("debug", Qt::CaseInsensitive)) - appPath = appPath.left(appPath.length()-6); + appPath = appPath.left(appPath.length()-6); #endif QTest::newRow("startup") << QString() << appPath; @@ -789,10 +869,10 @@ void tst_QDir::current() if (!currentDir.isEmpty()) { QDir newCurrent = QDir::current(); QDir::setCurrent(oldDir); -#ifdef Q_OS_WIN - QCOMPARE(newCurrent.absolutePath().toLower(), currentDir.toLower()); +#if defined(Q_OS_WIN) || defined(Q_OS_SYMBIAN) + QCOMPARE(newCurrent.absolutePath().toLower(), currentDir.toLower()); #else - QCOMPARE(newCurrent.absolutePath(), currentDir); + QCOMPARE(newCurrent.absolutePath(), currentDir); #endif } @@ -807,10 +887,10 @@ void tst_QDir::cd_data() QTest::addColumn<QString>("newDir"); QString appPath = QDir::currentPath(); - int index = appPath.lastIndexOf("/"); - QTest::newRow("cdUp") << QDir::currentPath() << ".." << true << appPath.left(index==0?1:index); + int index = appPath.lastIndexOf("/"); + QTest::newRow("cdUp") << QDir::currentPath() << ".." << true << appPath.left(index==0?1:index); QTest::newRow("noChange") << QDir::currentPath() << "." << true << appPath; -#ifdef Q_OS_WIN // on windows QDir::root() is usually c:/ but cd "/" will not force it to be root +#if defined(Q_OS_WIN) || defined(Q_OS_SYMBIAN) // on windows QDir::root() is usually c:/ but cd "/" will not force it to be root QTest::newRow("absolute") << QDir::currentPath() << "/" << true << "/"; #else QTest::newRow("absolute") << QDir::currentPath() << "/" << true << QDir::root().absolutePath(); @@ -850,11 +930,11 @@ void tst_QDir::setNameFilters_data() QTest::newRow("spaces1") << appPath + "testdir/spaces" << QStringList("*. bar") << QStringList("foo. bar"); QTest::newRow("spaces2") << appPath + "testdir/spaces" << QStringList("*.bar") - << QStringList("foo.bar"); + << QStringList("foo.bar"); QTest::newRow("spaces3") << appPath + "testdir/spaces" << QStringList("foo.*") - << QString("foo. bar,foo.bar").split(","); + << QString("foo. bar,foo.bar").split(","); QTest::newRow("files1") << appPath + "testdir/dir" << QString("*r.cpp *.pro").split(" ") - << QString("qdir.pro,qrc_qdir.cpp,tst_qdir.cpp").split(","); + << QString("qdir.pro,qrc_qdir.cpp,tst_qdir.cpp").split(","); QTest::newRow("resources1") << QString(":/tst_qdir/resources/entryList") << QStringList("*.data") << QString("file1.data,file2.data,file3.data").split(','); } @@ -889,7 +969,7 @@ tst_QDir::cleanPath_data() QTest::newRow("data3") << QDir::cleanPath("../.") << ".."; QTest::newRow("data4") << QDir::cleanPath("../..") << "../.."; #if !defined(Q_OS_WINCE) -#if defined Q_OS_WIN +#if defined(Q_OS_WIN) || defined(Q_OS_SYMBIAN) QTest::newRow("data5") << "d:\\a\\bc\\def\\.." << "d:/a/bc"; QTest::newRow("data6") << "d:\\a\\bc\\def\\../../.." << "d:/"; #else @@ -942,10 +1022,12 @@ void tst_QDir::absolutePath_data() QTest::addColumn<QString>("expectedPath"); QTest::newRow("0") << "/machine/share/dir1" << "/machine/share/dir1"; -#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) +#if (defined(Q_OS_WIN) && !defined(Q_OS_WINCE)) || defined(Q_OS_SYMBIAN) QTest::newRow("1") << "\\machine\\share\\dir1" << "/machine/share/dir1"; +# if !defined(Q_OS_SYMBIAN) QTest::newRow("2") << "//machine/share/dir1" << "//machine/share/dir1"; QTest::newRow("3") << "\\\\machine\\share\\dir1" << "//machine/share/dir1"; +# endif QTest::newRow("4") << "c:/machine/share/dir1" << "c:/machine/share/dir1"; QTest::newRow("5") << "c:\\machine\\share\\dir1" << "c:/machine/share/dir1"; #endif @@ -982,7 +1064,7 @@ void tst_QDir::relativeFilePath_data() QTest::newRow("11") << "" << "" << ""; -#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) +#if (defined(Q_OS_WIN) && !defined(Q_OS_WINCE)) || defined(Q_OS_SYMBIAN) QTest::newRow("12") << "C:/foo/bar" << "ding" << "ding"; QTest::newRow("13") << "C:/foo/bar" << "C:/ding/dong" << "../../ding/dong"; QTest::newRow("14") << "C:/foo/bar" << "/ding/dong" << "../../ding/dong"; @@ -1001,10 +1083,12 @@ void tst_QDir::relativeFilePath_data() QTest::newRow("22") << "C:" << "D:/" << "D:/"; QTest::newRow("23") << "C:/" << "D:" << "D:"; QTest::newRow("24") << "C:/" << "D:/" << "D:/"; +# if !defined(Q_OS_SYMBIAN) QTest::newRow("25") << "C:/foo/bar" << "//anotherHost/foo/bar" << "//anotherHost/foo/bar"; QTest::newRow("26") << "//anotherHost/foo" << "//anotherHost/foo/bar" << "bar"; QTest::newRow("27") << "//anotherHost/foo" << "bar" << "bar"; QTest::newRow("28") << "//anotherHost/foo" << "C:/foo/bar" << "C:/foo/bar"; +# endif #endif } @@ -1061,7 +1145,8 @@ void tst_QDir::rename() QVERIFY(dir.rename("rename-test-renamed", "rename-test")); #if defined(Q_OS_MAC) QVERIFY(!dir.rename("rename-test", "/etc/rename-test-renamed")); -#elif !defined(Q_OS_WIN) // on windows this is possible maybe make the test a bit better +#elif !defined(Q_OS_WIN) && !defined(Q_OS_SYMBIAN) + // on windows/symbian this is possible - maybe make the test a bit better QVERIFY(!dir.rename("rename-test", "/rename-test-renamed")); #endif QVERIFY(dir.remove("rename-test")); @@ -1110,7 +1195,7 @@ void tst_QDir::dirName_data() QTest::newRow("slash0") << "c:/winnt/system32" << "system32"; QTest::newRow("slash1") << "/winnt/system32" << "system32"; QTest::newRow("slash2") << "c:/winnt/system32/kernel32.dll" << "kernel32.dll"; -#ifdef Q_OS_WIN +#if defined(Q_OS_WIN) || defined(Q_OS_SYMBIAN) QTest::newRow("bslash0") << "c:\\winnt\\system32" << "system32"; QTest::newRow("bslash1") << "\\winnt\\system32" << "system32"; QTest::newRow("bslash2") << "c:\\winnt\\system32\\kernel32.dll" << "kernel32.dll"; @@ -1135,8 +1220,8 @@ void tst_QDir::operator_eq() void tst_QDir::dotAndDotDot() { -#ifdef Q_OS_WINCE - QSKIP("WinCE does not have . nor ..", SkipAll); +#if defined(Q_OS_WINCE) || defined(Q_OS_SYMBIAN) + QSKIP("WinCE and Symbian do not have . nor ..", SkipAll); #endif QDir dir(QString(SRCDIR "testdir/")); QStringList entryList = dir.entryList(QDir::Dirs); @@ -1216,14 +1301,14 @@ void tst_QDir::rootPath() QCOMPARE(path, dir.absolutePath()); QVERIFY(QDir::isAbsolutePath(path)); -#ifdef Q_OS_UNIX +#if defined(Q_OS_UNIX) && !defined(Q_OS_SYMBIAN) QCOMPARE(path, QString("/")); #endif } void tst_QDir::nativeSeparators() { -#ifdef Q_OS_WIN +#if defined(Q_OS_WIN) || defined(Q_OS_SYMBIAN) QCOMPARE(QDir::toNativeSeparators(QLatin1String("/")), QString("\\")); QCOMPARE(QDir::toNativeSeparators(QLatin1String("\\")), QString("\\")); QCOMPARE(QDir::fromNativeSeparators(QLatin1String("/")), QString("/")); diff --git a/tests/auto/qdiriterator/qdiriterator.pro b/tests/auto/qdiriterator/qdiriterator.pro index 2db6617..ece886c 100644 --- a/tests/auto/qdiriterator/qdiriterator.pro +++ b/tests/auto/qdiriterator/qdiriterator.pro @@ -3,7 +3,7 @@ SOURCES += tst_qdiriterator.cpp RESOURCES += qdiriterator.qrc QT = core -wince*: { +wince*|symbian*: { addFiles.sources = entrylist recursiveDirs foo addFiles.path = . DEPLOYMENT += addFiles diff --git a/tests/auto/qdiriterator/tst_qdiriterator.cpp b/tests/auto/qdiriterator/tst_qdiriterator.cpp index 6efbc77..b0f7000 100644 --- a/tests/auto/qdiriterator/tst_qdiriterator.cpp +++ b/tests/auto/qdiriterator/tst_qdiriterator.cpp @@ -52,6 +52,11 @@ #define Q_NO_SYMLINKS #endif +#if defined(Q_OS_SYMBIAN) +// Open C in Symbian doesn't support symbolic links to directories +#define Q_NO_SYMLINKS_TO_DIRS +#endif + Q_DECLARE_METATYPE(QDirIterator::IteratorFlags) Q_DECLARE_METATYPE(QDir::Filters) @@ -92,16 +97,20 @@ tst_QDirIterator::tst_QDirIterator() QFile::remove("entrylist/directory/entrylist4.lnk"); #ifndef Q_NO_SYMLINKS -#ifdef Q_OS_WIN +# if defined(Q_OS_WIN) || defined(Q_OS_SYMBIAN) // ### Sadly, this is a platform difference right now. QFile::link("entrylist/file", "entrylist/linktofile.lnk"); +# ifndef Q_NO_SYMLINKS_TO_DIRS QFile::link("entrylist/directory", "entrylist/linktodirectory.lnk"); +# endif QFile::link("entrylist/nothing", "entrylist/brokenlink.lnk"); -#else +# else QFile::link("file", "entrylist/linktofile.lnk"); +# ifndef Q_NO_SYMLINKS_TO_DIRS QFile::link("directory", "entrylist/linktodirectory.lnk"); +# endif QFile::link("nothing", "entrylist/brokenlink.lnk"); -#endif +# endif #endif QFile("entrylist/writable").open(QIODevice::ReadWrite); } @@ -136,7 +145,7 @@ void tst_QDirIterator::iterateRelativeDirectory_data() << QString("entrylist") << QDirIterator::IteratorFlags(0) << QDir::Filters(QDir::NoFilter) << QStringList("*") << QString( -#if !defined(Q_OS_WINCE) +#if !defined(Q_OS_WINCE) && !defined(Q_OS_SYMBIAN) "entrylist/.," "entrylist/..," #endif @@ -145,7 +154,7 @@ void tst_QDirIterator::iterateRelativeDirectory_data() "entrylist/linktofile.lnk," #endif "entrylist/directory," -#ifndef Q_NO_SYMLINKS +#if !defined(Q_NO_SYMLINKS) && !defined(Q_NO_SYMLINKS_TO_DIRS) "entrylist/linktodirectory.lnk," #endif "entrylist/writable").split(','); @@ -154,7 +163,7 @@ void tst_QDirIterator::iterateRelativeDirectory_data() << QString("entrylist") << QDirIterator::IteratorFlags(QDirIterator::Subdirectories | QDirIterator::FollowSymlinks) << QDir::Filters(QDir::NoFilter) << QStringList("*") << QString( -#if !defined(Q_OS_WINCE) +#if !defined(Q_OS_WINCE) && !defined(Q_OS_SYMBIAN) "entrylist/.," "entrylist/..," "entrylist/directory/.," @@ -166,7 +175,7 @@ void tst_QDirIterator::iterateRelativeDirectory_data() #endif "entrylist/directory," "entrylist/directory/dummy," -#ifndef Q_NO_SYMLINKS +#if !defined(Q_NO_SYMLINKS) && !defined(Q_NO_SYMLINKS_TO_DIRS) "entrylist/linktodirectory.lnk," #endif "entrylist/writable").split(','); diff --git a/tests/auto/qdirmodel/qdirmodel.pro b/tests/auto/qdirmodel/qdirmodel.pro index 2bf0773..19ec231 100644 --- a/tests/auto/qdirmodel/qdirmodel.pro +++ b/tests/auto/qdirmodel/qdirmodel.pro @@ -1,7 +1,7 @@ load(qttest_p4) SOURCES += tst_qdirmodel.cpp -wince*: { +wince*|symbian: { addit.sources = dirtest\test1\* addit.path = dirtest\test1 tests.sources = test\* @@ -9,8 +9,14 @@ wince*: { sourceFile.sources = tst_qdirmodel.cpp sourceFile.path = . DEPLOYMENT += addit tests sourceFile - DEFINES += SRCDIR=\\\"./\\\" +} + +wince*: { + DEFINES += SRCDIR=\\\"./\\\" +} symbian: { + TARGET.UID3 = 0xE0340003 + DEFINES += SYMBIAN_SRCDIR_UID=$$lower($$replace(TARGET.UID3,"0x","")) } else { - DEFINES += SRCDIR=\\\"$$PWD/\\\" + DEFINES += SRCDIR=\\\"$$PWD/\\\" } diff --git a/tests/auto/qdirmodel/tst_qdirmodel.cpp b/tests/auto/qdirmodel/tst_qdirmodel.cpp index 57621ac..3514147 100644 --- a/tests/auto/qdirmodel/tst_qdirmodel.cpp +++ b/tests/auto/qdirmodel/tst_qdirmodel.cpp @@ -50,6 +50,12 @@ //TESTED_CLASS= //TESTED_FILES= +#if defined(Q_OS_SYMBIAN) +# define STRINGIFY(x) #x +# define TOSTRING(x) STRINGIFY(x) +# define SRCDIR "C:/Private/" TOSTRING(SYMBIAN_SRCDIR_UID) "/" +#endif + class tst_QDirModel : public QObject { Q_OBJECT @@ -89,7 +95,7 @@ private slots: void rmdir_data(); void rmdir(); - + void filePath(); void hidden(); @@ -292,7 +298,7 @@ void tst_QDirModel::mkdir_data() QTest::newRow("nameWithSpace") << QString("ab cd") << true << 2; QTest::newRow("emptyDirName") << QString("") << false << 1; QTest::newRow("nullDirName") << QString() << false << 1; - + /* QTest::newRow("recursiveDirName") << QString("test2/test3") << false << false; QTest::newRow("singleDotDirName") << QString("./test3") << true << true; @@ -449,7 +455,7 @@ bool tst_QDirModel::rowsAboutToBeRemoved_cleanup(const QString &test_path) QString path = QDir::currentPath() + "/" + test_path; QDir dir(path, "*", QDir::SortFlags(QDir::Name|QDir::IgnoreCase), QDir::Files); QStringList files = dir.entryList(); - + for (int i = 0; i < files.count(); ++i) { if (!dir.remove(files.at(i))) { qDebug() << "failed to remove file" << files.at(i); @@ -481,14 +487,14 @@ void tst_QDirModel::rowsAboutToBeRemoved() qRegisterMetaType<QModelIndex>("QModelIndex"); - // NOTE: QDirModel will call refres() when a file is removed. refresh() will reread the entire directory, + // NOTE: QDirModel will call refresh() when a file is removed. refresh() will reread the entire directory, // and emit layoutAboutToBeChanged and layoutChange. So, instead of checking for // rowsAboutToBeRemoved/rowsRemoved we check for layoutAboutToBeChanged/layoutChanged QSignalSpy spy(&model, SIGNAL(layoutAboutToBeChanged())); QModelIndex parent = model.index(test_path); QVERIFY(parent.isValid()); - + // remove the file { QModelIndex index = model.index(remove_row, 0, parent); @@ -580,6 +586,13 @@ void tst_QDirModel::filePath() model.setResolveSymlinks(false); QModelIndex index = model.index(SRCDIR "test.lnk"); QVERIFY(index.isValid()); +#if defined(Q_OS_SYMBIAN) + // Since model will force lowercase path in Symbian, make case insensitive compare + // Note: Windows should fail this, too, if test path has any uppercase letters. + QCOMPARE(model.filePath(index).toLower(), QString(SRCDIR).toLower() + "test.lnk"); + model.setResolveSymlinks(true); + QCOMPARE(model.filePath(index).toLower(), QString(SRCDIR).toLower() + "tst_qdirmodel.cpp"); +#else #ifndef Q_OS_WINCE QString path = SRCDIR; #else @@ -588,6 +601,7 @@ void tst_QDirModel::filePath() QCOMPARE(model.filePath(index), path + QString( "test.lnk")); model.setResolveSymlinks(true); QCOMPARE(model.filePath(index), path + QString( "tst_qdirmodel.cpp")); +#endif QFile::remove(SRCDIR "test.lnk"); } @@ -596,14 +610,14 @@ void tst_QDirModel::task196768_sorting() //this task showed that the persistent model indexes got corrupted when sorting QString path = SRCDIR; - QDirModel model; + QDirModel model; QTreeView view; QPersistentModelIndex index = model.index(path); view.setModel(&model); QModelIndex index2 = model.index(path); QCOMPARE(index.data(), index2.data()); - view.setRootIndex(index); + view.setRootIndex(index); index2 = model.index(path); QCOMPARE(index.data(), index2.data()); view.setCurrentIndex(index); diff --git a/tests/auto/qdom/qdom.pro b/tests/auto/qdom/qdom.pro index 7738fb7..61914b5 100644 --- a/tests/auto/qdom/qdom.pro +++ b/tests/auto/qdom/qdom.pro @@ -4,14 +4,16 @@ SOURCES += tst_qdom.cpp QT = core xml QT -= gui -wince*: { +wince*|symbian*: { addFiles.sources = testdata doubleNamespaces.xml umlaut.xml addFiles.path = . DEPLOYMENT += addFiles DEPLOYMENT_PLUGIN += qcncodecs qjpcodecs qkrcodecs qtwcodecs - DEFINES += SRCDIR=\\\"\\\" + !symbian:DEFINES += SRCDIR=\\\"\\\" } else { DEFINES += SRCDIR=\\\"$$PWD/\\\" } + +symbian: TARGET.EPOCHEAPSIZE="0x100000 0x1000000" diff --git a/tests/auto/qdom/tst_qdom.cpp b/tests/auto/qdom/tst_qdom.cpp index 025882b..cb2a045 100644 --- a/tests/auto/qdom/tst_qdom.cpp +++ b/tests/auto/qdom/tst_qdom.cpp @@ -52,6 +52,10 @@ #include <QtXml> #include <QVariant> +#if defined(Q_OS_SYMBIAN) +# define SRCDIR "" +#endif + //TESTED_CLASS= //TESTED_FILES= diff --git a/tests/auto/qevent/qevent.pro b/tests/auto/qevent/qevent.pro index 219f97e..5c14299 100644 --- a/tests/auto/qevent/qevent.pro +++ b/tests/auto/qevent/qevent.pro @@ -1,6 +1,3 @@ load(qttest_p4) SOURCES += tst_qevent.cpp QT = core - - - diff --git a/tests/auto/qeventloop/tst_qeventloop.cpp b/tests/auto/qeventloop/tst_qeventloop.cpp index 3fec3a9..347de36 100644 --- a/tests/auto/qeventloop/tst_qeventloop.cpp +++ b/tests/auto/qeventloop/tst_qeventloop.cpp @@ -54,6 +54,11 @@ #include <QTcpServer> #include <QTcpSocket> +#ifdef Q_OS_SYMBIAN +#include <e32base.h> +#include <unistd.h> +#endif + //TESTED_CLASS= //TESTED_FILES= @@ -186,6 +191,10 @@ public slots: void init(); void cleanup(); private slots: + // This test *must* run first. See the definition for why. + void onlySymbianActiveScheduler(); + void symbianNestedActiveSchedulerLoop_data(); + void symbianNestedActiveSchedulerLoop(); void processEvents(); void exec(); void exit(); @@ -213,6 +222,101 @@ void tst_QEventLoop::init() void tst_QEventLoop::cleanup() { } +#ifdef Q_OS_SYMBIAN +class OnlySymbianActiveScheduler_helper : public QObject +{ + Q_OBJECT + +public: + OnlySymbianActiveScheduler_helper(int fd, QTimer *zeroTimer) + : fd(fd), + timerCount(0), + zeroTimer(zeroTimer), + zeroTimerCount(0), + notifierCount(0) + { + } + ~OnlySymbianActiveScheduler_helper() {} + +public slots: + void timerSlot() + { + // Let all the events occur twice so we know they reactivated after + // each occurrence. + if (++timerCount >= 2) { + // This will hopefully run last, so stop the active scheduler. + CActiveScheduler::Stop(); + } + } + void zeroTimerSlot() + { + if (++zeroTimerCount >= 2) { + zeroTimer->stop(); + } + } + void notifierSlot() + { + if (++notifierCount >= 2) { + char dummy; + ::read(fd, &dummy, 1); + } + } + +private: + int fd; + int timerCount; + QTimer *zeroTimer; + int zeroTimerCount; + int notifierCount; +}; +#endif + +void tst_QEventLoop::onlySymbianActiveScheduler() { +#ifndef Q_OS_SYMBIAN + QSKIP("This is a Symbian-only test.", SkipAll); +#else + // In here we try to use timers and sockets exclusively using the Symbian + // active scheduler and no processEvents(). + // This test should therefore be run first, so that we can verify that + // the first occurrence of processEvents does not do any initalization that + // we depend on. + + // Open up a pipe so we can test socket notifiers. + int pipeEnds[2]; + if (::pipe(pipeEnds) != 0) { + QFAIL("Could not open pipe"); + } + QSocketNotifier notifier(pipeEnds[0], QSocketNotifier::Read); + QSignalSpy notifierSpy(¬ifier, SIGNAL(activated(int))); + char dummy = 1; + ::write(pipeEnds[1], &dummy, 1); + + QTimer zeroTimer; + QSignalSpy zeroTimerSpy(&zeroTimer, SIGNAL(timeout())); + zeroTimer.setInterval(0); + zeroTimer.start(); + + QTimer timer; + QSignalSpy timerSpy(&timer, SIGNAL(timeout())); + timer.setInterval(2000); // Generous timeout or this test will fail if there is high load + timer.start(); + + OnlySymbianActiveScheduler_helper helper(pipeEnds[0], &zeroTimer); + connect(¬ifier, SIGNAL(activated(int)), &helper, SLOT(notifierSlot())); + connect(&zeroTimer, SIGNAL(timeout()), &helper, SLOT(zeroTimerSlot())); + connect(&timer, SIGNAL(timeout()), &helper, SLOT(timerSlot())); + + CActiveScheduler::Start(); + + ::close(pipeEnds[1]); + ::close(pipeEnds[0]); + + QCOMPARE(notifierSpy.count(), 2); + QCOMPARE(zeroTimerSpy.count(), 2); + QCOMPARE(timerSpy.count(), 2); +#endif +} + void tst_QEventLoop::processEvents() { QSignalSpy spy1(QAbstractEventDispatcher::instance(), SIGNAL(aboutToBlock())); @@ -265,6 +369,14 @@ void tst_QEventLoop::processEvents() killTimer(timerId); } +#if defined(Q_OS_SYMBIAN) && defined(Q_CC_NOKIAX86) +// Symbian needs bit longer timeout for emulator, as emulator startup causes additional delay +# define EXEC_TIMEOUT 1000 +#else +# define EXEC_TIMEOUT 100 +#endif + + void tst_QEventLoop::exec() { { @@ -272,15 +384,15 @@ void tst_QEventLoop::exec() EventLoopExiter exiter(&eventLoop); int returnCode; - QTimer::singleShot(100, &exiter, SLOT(exit())); + QTimer::singleShot(EXEC_TIMEOUT, &exiter, SLOT(exit())); returnCode = eventLoop.exec(); QCOMPARE(returnCode, 0); - QTimer::singleShot(100, &exiter, SLOT(exit1())); + QTimer::singleShot(EXEC_TIMEOUT, &exiter, SLOT(exit1())); returnCode = eventLoop.exec(); QCOMPARE(returnCode, 1); - QTimer::singleShot(100, &exiter, SLOT(exit2())); + QTimer::singleShot(EXEC_TIMEOUT, &exiter, SLOT(exit2())); returnCode = eventLoop.exec(); QCOMPARE(returnCode, 2); } @@ -313,16 +425,19 @@ void tst_QEventLoop::exec() QEventLoop eventLoop; EventLoopExecutor executor(&eventLoop); - QTimer::singleShot(100, &executor, SLOT(exec())); + QTimer::singleShot(EXEC_TIMEOUT, &executor, SLOT(exec())); int returnCode = eventLoop.exec(); QCOMPARE(returnCode, 0); QCOMPARE(executor.returnCode, -1); } -#if !defined(QT_NO_EXCEPTIONS) && !defined(Q_OS_WINCE_WM) +#if !defined(QT_NO_EXCEPTIONS) && !defined(Q_OS_WINCE_WM) && !defined(Q_OS_SYMBIAN) // Windows Mobile cannot handle cross library exceptions // qobject.cpp will try to rethrow the exception after handling // which causes gwes.exe to crash + + // Symbian doesn't propagate exceptions from eventloop, but converts them to + // CActiveScheduler errors instead -> this test will hang. { // QEventLoop::exec() is exception safe QEventLoop eventLoop; @@ -330,14 +445,14 @@ void tst_QEventLoop::exec() try { ExceptionThrower exceptionThrower; - QTimer::singleShot(100, &exceptionThrower, SLOT(throwException())); + QTimer::singleShot(EXEC_TIMEOUT, &exceptionThrower, SLOT(throwException())); (void) eventLoop.exec(); } catch (...) { ++caughtExceptions; } try { ExceptionThrower exceptionThrower; - QTimer::singleShot(100, &exceptionThrower, SLOT(throwException())); + QTimer::singleShot(EXEC_TIMEOUT, &exceptionThrower, SLOT(throwException())); (void) eventLoop.exec(); } catch (...) { ++caughtExceptions; @@ -512,7 +627,7 @@ void tst_QEventLoop::processEventsExcludeTimers() // normal process events will send timers eventLoop.processEvents(QEventLoop::X11ExcludeTimers); -#ifndef Q_OS_UNIX +#if !defined(Q_OS_UNIX) || defined(Q_OS_SYMBIAN) QEXPECT_FAIL("", "X11ExcludeTimers only works on UN*X", Continue); #endif QCOMPARE(timerReceiver.gotTimerEvent, -1); @@ -524,210 +639,163 @@ void tst_QEventLoop::processEventsExcludeTimers() timerReceiver.gotTimerEvent = -1; } -QTEST_MAIN(tst_QEventLoop) -#include "tst_qeventloop.moc" - - - - - - - - - - - - - - - - - - +#ifdef Q_OS_SYMBIAN +class DummyActiveObject : public CActive +{ +public: + DummyActiveObject(int levels); + ~DummyActiveObject(); + void Start(); +protected: + void DoCancel(); + void RunL(); +public: + bool succeeded; +private: + RTimer m_rTimer; + int remainingLevels; +}; +class ActiveSchedulerLoop : public QObject +{ +public: + ActiveSchedulerLoop(int levels) : succeeded(false), timerId(-1), remainingLevels(levels) {} + ~ActiveSchedulerLoop() {} + void timerEvent(QTimerEvent *e); +public: + bool succeeded; + int timerId; + int remainingLevels; +}; +DummyActiveObject::DummyActiveObject(int levels) + : CActive(CActive::EPriorityStandard), + succeeded(false), + remainingLevels(levels) +{ + m_rTimer.CreateLocal(); +} +DummyActiveObject::~DummyActiveObject() +{ + Cancel(); + m_rTimer.Close(); +} +void DummyActiveObject::DoCancel() +{ + m_rTimer.Cancel(); +} +void DummyActiveObject::RunL() +{ + if (remainingLevels - 1 <= 0) { + ActiveSchedulerLoop loop(remainingLevels - 1); + loop.timerId = loop.startTimer(0); + QCoreApplication::processEvents(); + succeeded = loop.succeeded; + } else { + succeeded = true; + } + CActiveScheduler::Stop(); +} -// previous test +void DummyActiveObject::Start() +{ + m_rTimer.After(iStatus, 100000); // 100 ms + SetActive(); +} -#if 0 +void ActiveSchedulerLoop::timerEvent(QTimerEvent *e) +{ + Q_UNUSED(e); + DummyActiveObject *dummy = new(ELeave) DummyActiveObject(remainingLevels); + CActiveScheduler::Add(dummy); -#include <qwidget.h> + dummy->Start(); -#ifdef Q_WS_WIN -#include <windows.h> -#endif + CActiveScheduler::Start(); + succeeded = dummy->succeeded; + delete dummy; -//TESTED_CLASS= -//TESTED_FILES= + killTimer(timerId); +} -class EventHandlerWidget : public QWidget +// We cannot trap panics when the test case fails, so run it in a different thread instead. +class ActiveSchedulerThread : public QThread { public: - EventHandlerWidget( QWidget* parent = 0, const char* name = 0 ) : QWidget( parent, name ) - { - installEventFilter( this ); - recievedPaintEvent = FALSE; - recievedMouseEvent = FALSE; - } - ~EventHandlerWidget() {} - - bool recievedPaintEvent; - bool recievedMouseEvent; + ActiveSchedulerThread(QEventLoop::ProcessEventsFlag flags); + ~ActiveSchedulerThread(); protected: - bool eventFilter( QObject* o, QEvent* e ) - { - if ( e->type() == QEvent::Paint ) - recievedPaintEvent = TRUE; - else if ( e->type() == QEvent::MouseButtonPress ) - recievedMouseEvent = TRUE; - return QWidget::eventFilter( o, e ); - } -}; + void run(); -class InBetweenObject : public QObject -{ - Q_OBJECT public: - InBetweenObject(QObject *parent, QObject *child) - : QObject(parent), childObject(child) - { - childObject->setParent(this); - ++instanceCounter; - } - - ~InBetweenObject() - { - --instanceCounter; - } - - static int instanceCounter; - -protected: - void childEvent(QChildEvent *e) - { - if (e->removed() && e->child() == childObject) { - deleteLater(); - } - } + volatile bool succeeded; private: - QObject *childObject; + QEventLoop::ProcessEventsFlag m_flags; }; -class ObjectContainer : public QObject -{ -public: - ObjectContainer(QObject *parent = 0) - : QObject(parent) - { - } - -protected: - void childEvent(QChildEvent *e) - { - if (e->inserted() && !::qobject_cast<InBetweenObject*>(e->child())) { - InBetweenObject *inBetween = new InBetweenObject(this, e->child()); - } - } -}; - -class tst_QEventLoop : public QObject -{ - Q_OBJECT -public: - tst_QEventLoop(); - ~tst_QEventLoop(); -public slots: - void init(); - void cleanup(); -private slots: - void processEvents(); - void eventHandlerPostsEvent(); -}; - -tst_QEventLoop::tst_QEventLoop() +ActiveSchedulerThread::ActiveSchedulerThread(QEventLoop::ProcessEventsFlag flags) + : succeeded(false), + m_flags(flags) { } -tst_QEventLoop::~tst_QEventLoop() +ActiveSchedulerThread::~ActiveSchedulerThread() { } -void tst_QEventLoop::init() +void ActiveSchedulerThread::run() { -} + ActiveSchedulerLoop loop(2); + loop.timerId = loop.startTimer(0); + // It may panic in here if the active scheduler and the Qt loop don't go together. + QCoreApplication::processEvents(m_flags); -void tst_QEventLoop::cleanup() -{ + succeeded = loop.succeeded; } +#endif // ifdef Q_OS_SYMBIAN - -void tst_QEventLoop::processEvents() +void tst_QEventLoop::symbianNestedActiveSchedulerLoop_data() { - EventHandlerWidget *mainWidget = new EventHandlerWidget( 0 ); - mainWidget->show(); - qApp->setMainWidget( mainWidget ); - -#ifdef Q_WS_WIN - QEventLoop* eventLoop = qApp->eventLoop(); - eventLoop->processEvents( QEventLoop::AllEvents ); - QVERIFY( !eventLoop->hasPendingEvents() ); + QTest::addColumn<int>("processEventFlags"); - // Make sure the flag is cleared first - mainWidget->recievedPaintEvent = FALSE; -#ifdef Q_WS_WIN - InvalidateRect( mainWidget->winId(), 0, TRUE ); -#endif - QVERIFY( !mainWidget->recievedPaintEvent ); - eventLoop->processEvents( QEventLoop::AllEvents ); - QVERIFY( mainWidget->recievedPaintEvent ); - -#ifdef Q_WS_WIN - // TODO: Hardcoded for now... - LPARAM lParam = MAKELPARAM( 10, 10 ); - PostMessage( mainWidget->winId(), WM_LBUTTONDOWN, 0, lParam ); -#endif - - mainWidget->recievedMouseEvent = FALSE; - eventLoop->processEvents( QEventLoop::ExcludeUserInput ); - QVERIFY( !mainWidget->recievedMouseEvent ); -#else - QSKIP( "QEventLoop test is not implememented on X11 yet", SkipAll); -#endif + QTest::newRow("AllEvents") << (int)QEventLoop::AllEvents; + QTest::newRow("WaitForMoreEvents") << (int)QEventLoop::WaitForMoreEvents; } -int InBetweenObject::instanceCounter = 0; - -void tst_QEventLoop::eventHandlerPostsEvent() +/* + Before you start fiddling with this test, you should have a good understanding of how + Symbian active objects work. What the test does is to try to screw up the semaphore count + in the active scheduler to cause stray signals, by running the Qt event loop and the + active scheduler inside each other. Naturally, its attempts to do this should be futile! +*/ +void tst_QEventLoop::symbianNestedActiveSchedulerLoop() { - ObjectContainer container; - - QObject *object = new QObject(&container); - qApp->processEvents(); - qApp->processEvents(); - - QCOMPARE(InBetweenObject::instanceCounter, 1); +#ifndef Q_OS_SYMBIAN + QSKIP("This is a Symbian only test.", SkipAll); +#else + QFETCH(int, processEventFlags); - object->deleteLater(); + ActiveSchedulerThread thread((QEventLoop::ProcessEventsFlag)processEventFlags); + thread.start(); + thread.wait(2000); - qApp->processEvents(); - QCOMPARE(InBetweenObject::instanceCounter, 0); -}; + QVERIFY(thread.succeeded); +#endif +} QTEST_MAIN(tst_QEventLoop) #include "tst_qeventloop.moc" - -#endif diff --git a/tests/auto/qexplicitlyshareddatapointer/qexplicitlyshareddatapointer.pro b/tests/auto/qexplicitlyshareddatapointer/qexplicitlyshareddatapointer.pro index 3a22199..8a45aa2 100644 --- a/tests/auto/qexplicitlyshareddatapointer/qexplicitlyshareddatapointer.pro +++ b/tests/auto/qexplicitlyshareddatapointer/qexplicitlyshareddatapointer.pro @@ -1,3 +1,3 @@ load(qttest_p4) SOURCES += tst_qexplicitlyshareddatapointer.cpp -QT-=gui +QT = core diff --git a/tests/auto/qfile/test/test.pro b/tests/auto/qfile/test/test.pro index 8d26f5e..80102f0 100644 --- a/tests/auto/qfile/test/test.pro +++ b/tests/auto/qfile/test/test.pro @@ -1,20 +1,26 @@ load(qttest_p4) SOURCES += ../tst_qfile.cpp +wince*|symbian:{ + QT = core gui + files.sources += ..\dosfile.txt ..\noendofline.txt ..\testfile.txt \ + ..\testlog.txt ..\two.dots.file ..\tst_qfile.cpp \ + ..\Makefile ..\forCopying.txt ..\forRenaming.txt + files.path = . + resour.sources += ..\resources\file1.ext1 + resour.path = resources + + DEPLOYMENT = files resour +} + wince*:{ -QT = core gui -files.sources += ..\dosfile.txt ..\noendofline.txt ..\testfile.txt \ - ..\testlog.txt ..\two.dots.file ..\tst_qfile.cpp \ - ..\Makefile ..\forCopying.txt ..\forRenaming.txt -files.path = . -resour.sources += ..\resources -resour.path = . - -DEPLOYMENT = files resour -DEFINES += SRCDIR=\\\"\\\" + DEFINES += SRCDIR=\\\"\\\" +} symbian: { + # don't define SRCDIR at all + TARGET.EPOCHEAPSIZE = 0x100000 0x3000000 } else { -QT = core network -DEFINES += SRCDIR=\\\"$$PWD/../\\\" + QT = core network + DEFINES += SRCDIR=\\\"$$PWD/../\\\" } RESOURCES += ../qfile.qrc ../rename-fallback.qrc ../copy-fallback.qrc @@ -22,12 +28,12 @@ RESOURCES += ../qfile.qrc ../rename-fallback.qrc ../copy-fallback.qrc TARGET = ../tst_qfile win32 { - CONFIG(debug, debug|release) { - TARGET = ../../debug/tst_qfile -} else { - TARGET = ../../release/tst_qfile - } - LIBS+=-lole32 -luuid + CONFIG(debug, debug|release) { + TARGET = ../../debug/tst_qfile + } else { + TARGET = ../../release/tst_qfile + } + LIBS+=-lole32 -luuid } diff --git a/tests/auto/qfile/tst_qfile.cpp b/tests/auto/qfile/tst_qfile.cpp index ba7252d..c4195f4 100644 --- a/tests/auto/qfile/tst_qfile.cpp +++ b/tests/auto/qfile/tst_qfile.cpp @@ -50,7 +50,7 @@ #include <QDir> #include <QFile> #include <QFileInfo> -#ifndef Q_OS_WINCE +#if !defined(Q_OS_WINCE) && !defined(Q_OS_SYMBIAN) #include <QHostInfo> #endif #include <QProcess> @@ -73,9 +73,12 @@ #endif #include <stdio.h> - #include "../network-settings.h" +#if defined(Q_OS_SYMBIAN) +# define SRCDIR "" +#endif + Q_DECLARE_METATYPE(QFile::FileError) //TESTED_CLASS= @@ -382,7 +385,10 @@ void tst_QFile::open() QFETCH( bool, ok ); -#ifdef Q_OS_UNIX +#if defined(Q_OS_SYMBIAN) + if (qstrcmp(QTest::currentDataTag(), "noreadfile") == 0) + QSKIP("Symbian does not support non-readable files", SkipSingle); +#elif defined(Q_OS_UNIX) if (::getuid() == 0) // root and Chuck Norris don't care for file permissions. Skip. QSKIP("Running this test as root doesn't make sense", SkipAll); @@ -599,8 +605,8 @@ void tst_QFile::readLineNullInLine() void tst_QFile::readAllStdin() { -#if defined(Q_OS_WINCE) - QSKIP("Currently no stdin/out supported for Windows CE", SkipAll); +#if defined(Q_OS_WINCE) || defined(Q_OS_SYMBIAN) + QSKIP("Currently no stdin/out supported for Windows CE or Symbian", SkipAll); #endif #if defined(QT_NO_PROCESS) QSKIP("Qt was compiled with QT_NO_PROCESS", SkipAll); @@ -625,8 +631,8 @@ void tst_QFile::readAllStdin() void tst_QFile::readLineStdin() { -#if defined(Q_OS_WINCE) - QSKIP("Currently no stdin/out supported for Windows CE", SkipAll); +#if defined(Q_OS_WINCE) || defined(Q_OS_SYMBIAN) + QSKIP("Currently no stdin/out supported for Windows CE or Symbian", SkipAll); #endif #if defined(QT_NO_PROCESS) QSKIP("Qt was compiled with QT_NO_PROCESS", SkipAll); @@ -668,7 +674,7 @@ void tst_QFile::readLineStdin() void tst_QFile::readLineStdin_lineByLine() { -#if defined(Q_OS_WINCE) +#if defined(Q_OS_WINCE) || defined(Q_OS_SYMBIAN) QSKIP("Currently no stdin/out supported for Windows CE", SkipAll); #endif #if defined(QT_NO_PROCESS) @@ -796,7 +802,7 @@ void tst_QFile::ungetChar() void tst_QFile::invalidFile_data() { QTest::addColumn<QString>("fileName"); -#ifndef Q_WS_WIN +#if !defined(Q_WS_WIN) && !defined(Q_OS_SYMBIAN) QTest::newRow( "x11" ) << QString( "qwe//" ); #else QTest::newRow( "colon1" ) << QString( "fail:invalid" ); @@ -866,6 +872,10 @@ void tst_QFile::permissions_data() void tst_QFile::permissions() { +#if defined(Q_OS_SYMBIAN) + if (qstrcmp(QTest::currentDataTag(), "data0") == 0) + QSKIP("Symbian does not have execution permissions", SkipSingle); +#endif QFETCH(QString, file); QFETCH(uint, perms); QFETCH(bool, expected); @@ -957,7 +967,11 @@ void tst_QFile::copyShouldntOverwrite() QFile::remove("tst_qfile.cpy"); QFile file(SRCDIR "tst_qfile.cpp"); QVERIFY(file.copy("tst_qfile.cpy")); +#if defined(Q_OS_SYMBIAN) + bool ok = QFile::setPermissions("tst_qfile.cpy", QFile::WriteUser); +#else bool ok = QFile::setPermissions("tst_qfile.cpy", QFile::WriteOther); +#endif QVERIFY(ok); QVERIFY(!file.copy("tst_qfile.cpy")); QFile::remove("tst_qfile.cpy"); @@ -1042,11 +1056,7 @@ void tst_QFile::link() QVERIFY(QFile::link("tst_qfile.cpp", "myLink.lnk")); QFileInfo info2("myLink.lnk"); QVERIFY(info2.isSymLink()); -#ifdef Q_OS_WIN // on windows links are always absolute QCOMPARE(info2.symLinkTarget(), info1.absoluteFilePath()); -#else - QCOMPARE(info2.symLinkTarget(), info1.absoluteFilePath()); -#endif #if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) QString wd = getWorkingDirectoryForLink(info2.absoluteFilePath()); @@ -1057,6 +1067,9 @@ void tst_QFile::link() void tst_QFile::linkToDir() { +#if defined(Q_OS_SYMBIAN) + QSKIP("Symbian does not support linking to directories", SkipAll); +#endif QFile::remove("myLinkToDir.lnk"); QDir dir; dir.mkdir("myDir"); @@ -1069,11 +1082,7 @@ void tst_QFile::linkToDir() // later fail... QVERIFY(info2.isSymLink()); #endif -#ifdef Q_OS_WIN // on windows links are alway absolute QCOMPARE(info2.symLinkTarget(), info1.absoluteFilePath()); -#else - QCOMPARE(info2.symLinkTarget(), info1.absoluteFilePath()); -#endif QVERIFY(QFile::remove(info2.absoluteFilePath())); QFile::remove("myLinkToDir.lnk"); dir.rmdir("myDir"); @@ -1092,8 +1101,7 @@ void tst_QFile::absolutePathLinkToRelativePath() #else QVERIFY(QFile::link("myDir/test.txt", "myDir/myLink.lnk")); #endif - - QEXPECT_FAIL("", "Symlinking using relative paths is currently different on Windows and Unix", Continue); + QEXPECT_FAIL("", "Symlinking using relative paths is currently different on Windows and Unix/Symbian", Continue); QCOMPARE(QFileInfo(QFile(QFileInfo("myDir/myLink.lnk").absoluteFilePath()).symLinkTarget()).absoluteFilePath(), QFileInfo("myDir/test.txt").absoluteFilePath()); @@ -1106,18 +1114,24 @@ void tst_QFile::readBrokenLink() { QFile::remove("myLink2.lnk"); QFileInfo info1("file12"); +#if defined(Q_OS_SYMBIAN) + // In Symbian can't link to nonexisting file directly, so create the file temporarily + QFile tempFile("file12"); + tempFile.open(QIODevice::WriteOnly); + tempFile.link("myLink2.lnk"); + tempFile.remove(); +#else QVERIFY(QFile::link("file12", "myLink2.lnk")); +#endif QFileInfo info2("myLink2.lnk"); QVERIFY(info2.isSymLink()); -#ifdef Q_OS_WIN // on windows links are alway absolute - QCOMPARE(info2.symLinkTarget(), info1.absoluteFilePath()); -#else QCOMPARE(info2.symLinkTarget(), info1.absoluteFilePath()); -#endif QVERIFY(QFile::remove(info2.absoluteFilePath())); +#if !defined(Q_OS_SYMBIAN) QVERIFY(QFile::link("ole/..", "myLink2.lnk")); QCOMPARE(QFileInfo("myLink2.lnk").symLinkTarget(), QDir::currentPath()); +#endif } void tst_QFile::readTextFile_data() @@ -1330,7 +1344,7 @@ void tst_QFile::bufferedRead() void tst_QFile::isSequential() { -#if defined (Q_OS_WIN) +#if defined (Q_OS_WIN) || defined(Q_OS_SYMBIAN) QSKIP("Unix only test.", SkipAll); #endif @@ -1639,7 +1653,7 @@ void tst_QFile::longFileName() } { QFile file(fileName); -#if defined(Q_OS_WINCE) +#if defined(Q_OS_WINCE) || defined(Q_OS_SYMBIAN) QEXPECT_FAIL("244 chars", "Full pathname must be less than 260 chars", Abort); QEXPECT_FAIL("244 chars to absolutepath", "Full pathname must be less than 260 chars", Abort); #endif @@ -1912,8 +1926,8 @@ void tst_QFile::writeLargeDataBlock() // Generate a 64MB array with well defined contents. QByteArray array; -#if defined(Q_OS_WINCE) - int resizeSize = 1024 * 1024; // WinCE does not have much space +#if defined(Q_OS_WINCE) || defined(Q_OS_SYMBIAN) + int resizeSize = 1024 * 1024; // WinCE and Symbian do not have much space #else int resizeSize = 64 * 1024 * 1024; #endif @@ -2050,7 +2064,7 @@ void tst_QFile::rename_data() QTest::newRow("a -> .") << QString("a") << QString(".") << false; QTest::newRow("renamefile -> renamefile") << QString("renamefile") << QString("renamefile") << false; QTest::newRow("renamefile -> Makefile") << QString("renamefile") << QString("Makefile") << false; -#ifdef Q_OS_UNIX +#if defined(Q_OS_UNIX) && !defined(Q_OS_SYMBIAN) QTest::newRow("renamefile -> /etc/renamefile") << QString("renamefile") << QString("/etc/renamefile") << false; #endif QTest::newRow("renamefile -> renamedfile") << QString("renamefile") << QString("renamedfile") << true; @@ -2278,7 +2292,7 @@ void tst_QFile::readEof_data() QTest::newRow("buffered") << SRCDIR "testfile.txt" << 0; QTest::newRow("unbuffered") << SRCDIR "testfile.txt" << int(QIODevice::Unbuffered); -#ifdef Q_OS_UNIX +#if defined(Q_OS_UNIX) && !defined(Q_OS_SYMBIAN) QTest::newRow("sequential,buffered") << "/dev/null" << 0; QTest::newRow("sequential,unbuffered") << "/dev/null" << int(QIODevice::Unbuffered); #endif @@ -2461,9 +2475,11 @@ void tst_QFile::map() QVERIFY(file.open(QFile::ReadWrite)); memory = file.map(offset, size); if (error != QFile::NoError) { + QVERIFY(file.error() != QFile::NoError); return; } + QCOMPARE(file.error(), error); QVERIFY(memory); memory[0] = 'Q'; @@ -2500,7 +2516,9 @@ void tst_QFile::map() file.close(); -#ifdef Q_OS_UNIX +#if defined(Q_OS_SYMBIAN) + if (false) // No permissions for user makes no sense in Symbian +#elif defined(Q_OS_UNIX) if (::getuid() != 0) // root always has permissions #endif diff --git a/tests/auto/qfiledialog/qfiledialog.pro b/tests/auto/qfiledialog/qfiledialog.pro index 28a11ba..bea7716 100644 --- a/tests/auto/qfiledialog/qfiledialog.pro +++ b/tests/auto/qfiledialog/qfiledialog.pro @@ -6,10 +6,13 @@ load(qttest_p4) SOURCES += tst_qfiledialog.cpp -wince*: { +wince*|symbian: { addFiles.sources = *.cpp addFiles.path = . filesInDir.sources = *.pro filesInDir.path = someDir DEPLOYMENT += addFiles filesInDir } + +symbian:TARGET.EPOCHEAPSIZE="0x100 0x1000000" +symbian:HEADERS += ../../../include/qtgui/private/qfileinfogatherer_p.h diff --git a/tests/auto/qfiledialog/tst_qfiledialog.cpp b/tests/auto/qfiledialog/tst_qfiledialog.cpp index a50bcfe..a6d8235 100644 --- a/tests/auto/qfiledialog/tst_qfiledialog.cpp +++ b/tests/auto/qfiledialog/tst_qfiledialog.cpp @@ -306,6 +306,7 @@ void tst_QFiledialog::filesSelectedSignal() QTest::qWait(500); QListView *listView = qFindChild<QListView*>(&fd, "listView"); QVERIFY(listView); + QModelIndex root = listView->rootIndex(); QTRY_COMPARE(listView->model()->rowCount(root) > 0, true); QModelIndex file; @@ -473,10 +474,11 @@ void tst_QFiledialog::completer() if (!tmp.exists(tempPath)) QVERIFY(tmp.mkdir("QFileDialogTestDir")); QList<QTemporaryFile*> files; + QT_TRY { for (int i = 0; i < 10; ++i) { - QTemporaryFile *file = new QTemporaryFile(tempPath + "/rXXXXXX"); + QScopedPointer<QTemporaryFile> file(new QTemporaryFile(tempPath + "/rXXXXXX")); file->open(); - files.append(file); + files.append(file.take()); } // ### flesh this out more @@ -541,14 +543,14 @@ void tst_QFiledialog::completer() if (input.startsWith("..")) input.clear(); for (int ii = 0; ii < expectedFiles.count(); ++ii) { -#ifdef Q_OS_WIN +#if defined(Q_OS_WIN) || defined(Q_OS_SYMBIAN) if (expectedFiles.at(ii).startsWith(input,Qt::CaseInsensitive)) #else if (expectedFiles.at(ii).startsWith(input)) #endif ++expected; } -#ifndef Q_OS_WIN +#if !defined(Q_OS_WIN) if (inputStartsWithRootPath) expected++; #endif @@ -563,7 +565,14 @@ void tst_QFiledialog::completer() //qDebug() << expectedFiles; } + + // ### FIXME: This will fail on Symbian on some tests and some environments until the file engine and QFileSystemModel + // are fixed to properly capitalize paths, so that some folders are not duplicated in QFileSystemModel. QTRY_COMPARE(cModel->rowCount(), expected); + } QT_CATCH(...) { + qDeleteAll(files); + QT_RETHROW; + } qDeleteAll(files); } @@ -926,8 +935,8 @@ void tst_QFiledialog::selectFiles() QVERIFY(listView); for (int i = 0; i < list.count(); ++i) { fd.selectFile(fd.directory().path() + "/" + list.at(i)); -#if defined(Q_WS_MAC) || defined(Q_WS_WIN) - QEXPECT_FAIL("", "This test does not work on Mac or Windows", Abort); +#if defined(Q_WS_MAC) || defined(Q_WS_WIN) || defined(Q_OS_SYMBIAN) + QEXPECT_FAIL("", "This test does not work on Mac, Windows, or Symbian", Abort); #endif QTRY_VERIFY(!listView->selectionModel()->selectedRows().isEmpty()); toSelect.append(listView->selectionModel()->selectedRows().last()); @@ -1232,6 +1241,9 @@ void tst_QFiledialog::clearLineEdit() fd.setDirectory(QDir::home()); QTest::qWait(1000); +#ifdef QT_KEYPAD_NAVIGATION + list->setEditFocus(true); +#endif QTest::keyClick(list, Qt::Key_Down); #ifndef Q_WS_MAC QTest::keyClick(list, Qt::Key_Return); @@ -1705,6 +1717,9 @@ void tst_QFiledialog::task233037_selectingDirectory() fd.show(); QListView *list = qFindChild<QListView*>(&fd, "listView"); QTest::qWait(3000); // Wait for sort to settle (I need a signal). +#ifdef QT_KEYPAD_NAVIGATION + list->setEditFocus(true); +#endif QTest::keyClick(list, Qt::Key_Down); QTest::qWait(100); QDialogButtonBox *buttonBox = qFindChild<QDialogButtonBox*>(&fd, "buttonBox"); diff --git a/tests/auto/qfileinfo/qfileinfo.pro b/tests/auto/qfileinfo/qfileinfo.pro index 91b630d..c3be825 100644 --- a/tests/auto/qfileinfo/qfileinfo.pro +++ b/tests/auto/qfileinfo/qfileinfo.pro @@ -6,10 +6,14 @@ QT = core RESOURCES += qfileinfo.qrc -wince*: { +wince*:|symbian*: { deploy.sources += qfileinfo.qrc tst_qfileinfo.cpp res.sources = resources\file1 resources\file1.ext1 resources\file1.ext1.ext2 res.path = resources DEPLOYMENT = deploy res } +symbian { + TARGET.CAPABILITY=AllFiles + LIBS *= -lefsrv + } diff --git a/tests/auto/qfileinfo/tst_qfileinfo.cpp b/tests/auto/qfileinfo/tst_qfileinfo.cpp index 6c94ebf..fb150e5 100644 --- a/tests/auto/qfileinfo/tst_qfileinfo.cpp +++ b/tests/auto/qfileinfo/tst_qfileinfo.cpp @@ -59,7 +59,10 @@ #endif #include <qplatformdefs.h> #include <qdebug.h> - +#ifdef Q_OS_SYMBIAN +#include <f32file.h> +#include <private/qcore_symbian_p.h> +#endif #include "../network-settings.h" #include <private/qfileinfo_p.h> @@ -139,6 +142,7 @@ private slots: void fileTimes(); void fileTimes_oldFile(); + void isSymLink_data(); void isSymLink(); void isHidden_data(); @@ -166,11 +170,20 @@ private slots: void notEqualOperator() const; }; +tst_QFileInfo::tst_QFileInfo() +{ +} + tst_QFileInfo::~tst_QFileInfo() { QFile::remove("brokenlink.lnk"); QFile::remove("link.lnk"); QFile::remove("file1"); + QFile::remove("dummyfile"); +#ifdef Q_OS_SYMBIAN + QFile::remove("hidden.txt"); + QFile::remove("nothidden.txt"); +#endif } // Testing get/set functions @@ -233,12 +246,6 @@ void tst_QFileInfo::copy() QVERIFY(privateInfo->data != privateInfo3->data); QVERIFY(privateInfo2->data != privateInfo3->data); QCOMPARE(privateInfo->data, privateInfo2->data); - - -} - -tst_QFileInfo::tst_QFileInfo() -{ } void tst_QFileInfo::isFile_data() @@ -267,6 +274,7 @@ void tst_QFileInfo::isDir_data() { // create a broken symlink QFile::remove("brokenlink.lnk"); + QFile::remove("dummyfile"); QFile file3("dummyfile"); file3.open(QIODevice::WriteOnly); if (file3.link("brokenlink.lnk")) { @@ -289,10 +297,12 @@ void tst_QFileInfo::isDir_data() QTest::newRow("broken link") << "brokenlink.lnk" << false; -#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) +#if (defined(Q_OS_WIN) && !defined(Q_OS_WINCE)) || defined(Q_OS_SYMBIAN) QTest::newRow("drive 1") << "c:" << true; QTest::newRow("drive 2") << "c:/" << true; //QTest::newRow("drive 2") << "t:s" << false; +#endif +#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) QTest::newRow("unc 1") << "//" + QtNetworkSettings::winServerName() << true; QTest::newRow("unc 2") << "//" + QtNetworkSettings::winServerName() + "/" << true; QTest::newRow("unc 3") << "//" + QtNetworkSettings::winServerName() + "/testshare" << true; @@ -316,7 +326,6 @@ void tst_QFileInfo::isRoot_data() { QTest::addColumn<QString>("path"); QTest::addColumn<bool>("expected"); - QTest::newRow("data0") << QDir::currentPath() << false; QTest::newRow("data1") << "/" << true; QTest::newRow("data2") << "*" << false; @@ -326,11 +335,13 @@ void tst_QFileInfo::isRoot_data() QTest::newRow("simple dir") << "resources" << false; QTest::newRow("simple dir with slash") << "resources/" << false; - -#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) +#if (defined(Q_OS_WIN) && !defined(Q_OS_WINCE)) || defined(Q_OS_SYMBIAN) QTest::newRow("drive 1") << "c:" << false; QTest::newRow("drive 2") << "c:/" << true; QTest::newRow("drive 3") << "p:/" << false; +#endif + +#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) QTest::newRow("unc 1") << "//" + QtNetworkSettings::winServerName() << true; QTest::newRow("unc 2") << "//" + QtNetworkSettings::winServerName() + "/" << true; QTest::newRow("unc 3") << "//" + QtNetworkSettings::winServerName() + "/testshare" << false; @@ -398,7 +409,7 @@ void tst_QFileInfo::absolutePath_data() QTest::addColumn<QString>("filename"); QString drivePrefix; -#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) +#if (defined(Q_OS_WIN) && !defined(Q_OS_WINCE)) || defined(Q_OS_SYMBIAN) drivePrefix = QDir::currentPath().left(2); #endif QTest::newRow("0") << "/machine/share/dir1/" << drivePrefix + "/machine/share/dir1" << ""; @@ -433,7 +444,7 @@ void tst_QFileInfo::absFilePath_data() QTest::newRow("relativeFile") << "tmp.txt" << QDir::currentPath() + "/tmp.txt"; QTest::newRow("relativeFileInSubDir") << "temp/tmp.txt" << QDir::currentPath() + "/" + "temp/tmp.txt"; -#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) +#if (defined(Q_OS_WIN) && !defined(Q_OS_WINCE)) || defined(Q_OS_SYMBIAN) QString curr = QDir::currentPath(); curr.remove(0, 2); // Make it a absolute path with no drive specifier: \depot\qt-4.2\tests\auto\qfileinfo QTest::newRow(".") << curr << QDir::currentPath(); @@ -485,6 +496,8 @@ void tst_QFileInfo::canonicalFilePath() QCOMPARE(info1.canonicalFilePath(), info2.canonicalFilePath()); } } +# if !defined(Q_OS_SYMBIAN) + // Symbian doesn't support links to directories { const QString link(QDir::tempPath() + QDir::separator() + "tst_qfileinfo"); QFile::remove(link); @@ -492,6 +505,9 @@ void tst_QFileInfo::canonicalFilePath() if (file.link(link)) { QFileInfo info1("tst_qfileinfo.cpp"); QFileInfo info2(link + QDir::separator() + "tst_qfileinfo.cpp"); + + QVERIFY2(info1.exists(), "If this fails, one reason might be the test system has failed to copy the files."); + QVERIFY2(info2.exists(), "If this fails, one reason might be the test system has failed to copy the files."); QCOMPARE(info1.canonicalFilePath(), info2.canonicalFilePath()); QFileInfo info3(link + QDir::separator() + "link.lnk"); @@ -513,8 +529,8 @@ void tst_QFileInfo::canonicalFilePath() QCOMPARE(info1.canonicalFilePath(), info2.canonicalFilePath()); } } +# endif #endif - } void tst_QFileInfo::fileName_data() @@ -524,7 +540,7 @@ void tst_QFileInfo::fileName_data() QTest::newRow("relativeFile") << "tmp.txt" << "tmp.txt"; QTest::newRow("relativeFileInSubDir") << "temp/tmp.txt" << "tmp.txt"; -#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) +#if (defined(Q_OS_WIN) && !defined(Q_OS_WINCE)) || defined(Q_OS_SYMBIAN) QTest::newRow("absFilePath") << "c:\\home\\andy\\tmp.txt" << "tmp.txt"; #else QTest::newRow("absFilePath") << "/home/andy/tmp.txt" << "tmp.txt"; @@ -714,7 +730,6 @@ void tst_QFileInfo::permission_data() QTest::newRow("resource1") << ":/tst_qfileinfo/resources/file1.ext1" << int(QFile::ReadUser) << true; QTest::newRow("resource2") << ":/tst_qfileinfo/resources/file1.ext1" << int(QFile::WriteUser) << false; QTest::newRow("resource3") << ":/tst_qfileinfo/resources/file1.ext1" << int(QFile::ExeUser) << false; - } void tst_QFileInfo::permission() @@ -722,8 +737,11 @@ void tst_QFileInfo::permission() QFETCH(QString, file); QFETCH(int, perms); QFETCH(bool, expected); +#ifdef Q_OS_SYMBIAN + QSKIP("No user based rights in Symbian OS - SOS needs platform security tests instead", SkipAll); +#endif QFileInfo fi(file); - QCOMPARE(fi.permission((QFile::Permissions)perms), expected); + QCOMPARE(fi.permission(QFile::Permissions(perms)), expected); } void tst_QFileInfo::size_data() @@ -773,13 +791,13 @@ void tst_QFileInfo::compare_data() << QDir::currentPath() + QString::fromLatin1("/tst_qfileinfo.cpp") << true; QTest::newRow("casesense1") << QString::fromLatin1("tst_qfileInfo.cpp") << QDir::currentPath() + QString::fromLatin1("/tst_qfileinfo.cpp") -#ifdef Q_OS_WIN +#if defined(Q_OS_WIN) || defined(Q_OS_SYMBIAN) << true; #else << false; #endif - } + void tst_QFileInfo::compare() { QFETCH(QString, file1); @@ -794,7 +812,7 @@ void tst_QFileInfo::consistent_data() QTest::addColumn<QString>("file"); QTest::addColumn<QString>("expected"); -#ifdef Q_OS_WIN +#if defined(Q_OS_WIN) || defined(Q_OS_SYMBIAN) QTest::newRow("slashes") << QString::fromLatin1("\\a\\a\\a\\a") << QString::fromLatin1("/a/a/a/a"); #endif QTest::newRow("ending slash") << QString::fromLatin1("/a/somedir/") << QString::fromLatin1("/a/somedir/"); @@ -845,6 +863,9 @@ void tst_QFileInfo::fileTimes() #if defined(Q_OS_WINCE) QEXPECT_FAIL("longfile", "No long filenames on WinCE", Abort); QEXPECT_FAIL("longfile absolutepath", "No long filenames on WinCE", Abort); +#elif defined(Q_OS_SYMBIAN) + QEXPECT_FAIL("longfile", "Maximum total filepath cannot exceed 256 characters in Symbian", Abort); + QEXPECT_FAIL("longfile absolutepath", "Maximum total filepath cannot exceed 256 characters in Symbian", Abort); #endif QVERIFY(file.open(QFile::WriteOnly | QFile::Text)); QTextStream ts(&file); @@ -888,6 +909,9 @@ void tst_QFileInfo::fileTimes() #ifdef Q_OS_WINCE QEXPECT_FAIL("simple", "WinCE only stores date of access data, not the time", Continue); #endif +#ifdef Q_OS_SYMBIAN + QEXPECT_FAIL("simple", "Symbian implementation of stat doesn't return read time right", Abort); +#endif QVERIFY(fileInfo.lastRead() > beforeRead); QVERIFY(fileInfo.lastModified() > beforeWrite); QVERIFY(fileInfo.lastModified() < beforeRead); @@ -946,28 +970,46 @@ void tst_QFileInfo::fileTimes_oldFile() #endif } -void tst_QFileInfo::isSymLink() +void tst_QFileInfo::isSymLink_data() { QFile::remove("link.lnk"); QFile::remove("brokenlink.lnk"); + QFile::remove("dummyfile"); - QFileInfo info1("tst_qfileinfo.cpp"); - QVERIFY( !info1.isSymLink() ); + QFile file1("tst_qfileinfo.cpp"); + QVERIFY(file1.link("link.lnk")); - QFile file2("tst_qfileinfo.cpp"); - if (file2.link("link.lnk")) { - QFileInfo info2("link.lnk"); - QVERIFY( info2.isSymLink() ); - } + QFile file2("dummyfile"); + file2.open(QIODevice::WriteOnly); + QVERIFY(file2.link("brokenlink.lnk")); + file2.remove(); - QFile file3("dummyfile"); - file3.open(QIODevice::WriteOnly); - if (file3.link("brokenlink.lnk")) { - file3.remove(); - QFileInfo info3("brokenlink.lnk"); - QVERIFY( info3.isSymLink() ); + QTest::addColumn<QString>("path"); + QTest::addColumn<bool>("isSymLink"); + QTest::addColumn<QString>("linkTarget"); + + QTest::newRow("existent file") << "tst_qfileinfo.cpp" << false << ""; + QTest::newRow("link") << "link.lnk" << true << QFileInfo("tst_qfileinfo.cpp").absoluteFilePath(); + QTest::newRow("broken link") << "brokenlink.lnk" << true << QFileInfo("dummyfile").absoluteFilePath(); + +#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) + if (QSysInfo::WindowsVersion & QSysInfo::WV_VISTA) { + QTest::newRow("Documents and Settings") << "C:/Documents and Settings" << true << "C:/Users"; + QTest::newRow("All Users") << "C:/Users/All Users" << true << "C:/ProgramData"; + QTest::newRow("Default User") << "C:/Users/Default User" << true << "C:/Users/Default"; } +#endif +} +void tst_QFileInfo::isSymLink() +{ + QFETCH(QString, path); + QFETCH(bool, isSymLink); + QFETCH(QString, linkTarget); + + QFileInfo fi(path); + QCOMPARE(fi.isSymLink(), isSymLink); + QCOMPARE(fi.symLinkTarget(), linkTarget); } void tst_QFileInfo::isHidden_data() @@ -983,13 +1025,13 @@ void tst_QFileInfo::isHidden_data() QTest::newRow("C:/RECYCLER/.") << QString::fromLatin1("C:/RECYCLER/.") << false; QTest::newRow("C:/RECYCLER/..") << QString::fromLatin1("C:/RECYCLER/..") << false; #endif -#if defined(Q_OS_UNIX) +#if defined(Q_OS_UNIX) && !defined(Q_OS_SYMBIAN) QTest::newRow("~/.qt") << QDir::homePath() + QString("/.qt") << true; QTest::newRow("~/.qt/.") << QDir::homePath() + QString("/.qt/.") << false; QTest::newRow("~/.qt/..") << QDir::homePath() + QString("/.qt/..") << false; #endif -#if !defined(Q_OS_WIN) +#if !defined(Q_OS_WIN) && !defined(Q_OS_SYMBIAN) QTest::newRow("/bin/") << QString::fromLatin1("/bin/") << false; #endif @@ -998,6 +1040,45 @@ void tst_QFileInfo::isHidden_data() QTest::newRow("mac_private_etc") << QString::fromLatin1("/private/etc") << false; QTest::newRow("mac_Applications") << QString::fromLatin1("/Applications") << false; #endif + +#ifdef Q_OS_SYMBIAN + // No guaranteed hidden file knows to exist in Symbian filesystem, so make one. + QString hiddenFileName("hidden.txt"); + QString notHiddenFileName("nothidden.txt"); + QTest::newRow("hidden file") << hiddenFileName << true; + QTest::newRow("non-hidden file") << notHiddenFileName << false; + + { + QFile file(hiddenFileName); + if (file.open(QIODevice::WriteOnly)) { + QTextStream t(&file); + t << "foobar"; + } else { + qWarning("Failed to create hidden file"); + } + QFile file2(notHiddenFileName); + if (file2.open(QIODevice::WriteOnly)) { + QTextStream t(&file); + t << "foobar"; + } else { + qWarning("Failed to create non-hidden file"); + } + } + + RFs rfs; + TInt err = rfs.Connect(); + if (err == KErrNone) { + HBufC* symFile = qt_QString2HBufC(hiddenFileName); + err = rfs.SetAtt(*symFile, KEntryAttHidden, 0); + rfs.Close(); + delete symFile; + if (err != KErrNone) { + qWarning("Failed to set hidden attribute for test file"); + } + } else { + qWarning("Failed to open RFs session"); + } +#endif } void tst_QFileInfo::isHidden() @@ -1117,6 +1198,10 @@ void tst_QFileInfo::brokenShortcut() void tst_QFileInfo::isWritable() { +#ifdef Q_OS_SYMBIAN + QSKIP("Currently skipped on Symbian OS, but surely there is a writeable file somewhere???", SkipAll); +#endif + QVERIFY(QFileInfo("tst_qfileinfo.cpp").isWritable()); #ifdef Q_OS_WIN #ifdef Q_OS_WINCE @@ -1137,10 +1222,17 @@ void tst_QFileInfo::isWritable() void tst_QFileInfo::isExecutable() { +#ifdef Q_OS_SYMBIAN +# if defined(Q_CC_NOKIAX86) + QSKIP("Impossible to implement reading/touching of application binaries in Symbian emulator", SkipAll); +# endif + QString appPath = "c:/sys/bin/tst_qfileinfo.exe"; +#else QString appPath = QCoreApplication::applicationDirPath(); appPath += "/tst_qfileinfo"; -#if defined(Q_OS_WIN) +# if defined(Q_OS_WIN) appPath += ".exe"; +# endif #endif QFileInfo fi(appPath); QCOMPARE(fi.isExecutable(), true); diff --git a/tests/auto/qfilesystemmodel/qfilesystemmodel.pro b/tests/auto/qfilesystemmodel/qfilesystemmodel.pro index 1daae04..eac16ee 100644 --- a/tests/auto/qfilesystemmodel/qfilesystemmodel.pro +++ b/tests/auto/qfilesystemmodel/qfilesystemmodel.pro @@ -2,7 +2,14 @@ CONFIG += qttest_p4 QT = core gui -SOURCES += tst_qfilesystemmodel.cpp +SOURCES += tst_qfilesystemmodel.cpp TARGET = tst_qfilesystemmodel +symbian: { + HEADERS += ../../../include/qtgui/private/qfileinfogatherer_p.h + # need to deploy something to create the private directory + dummyDeploy.sources = tst_qfilesystemmodel.cpp + dummyDeploy.path = . + DEPLOYMENT += dummyDeploy +} diff --git a/tests/auto/qfilesystemmodel/tst_qfilesystemmodel.cpp b/tests/auto/qfilesystemmodel/tst_qfilesystemmodel.cpp index fc67df1..796add5 100644 --- a/tests/auto/qfilesystemmodel/tst_qfilesystemmodel.cpp +++ b/tests/auto/qfilesystemmodel/tst_qfilesystemmodel.cpp @@ -48,7 +48,9 @@ #include <QTime> #include <QStyle> #include <QtGlobal> - +#if defined(Q_OS_SYMBIAN) +# include <f32file.h> +#endif //TESTED_CLASS= //TESTED_FILES= @@ -64,6 +66,23 @@ } \ } while(0) +#if defined(Q_OS_SYMBIAN) +static HBufC* qt_QString2HBufCNewL(const QString& aString) +{ + HBufC *buffer; +#ifdef QT_NO_UNICODE + TPtrC8 ptr(reinterpret_cast<const TUint8*>(aString.toLocal8Bit().constData())); + buffer = HBufC8::NewL(ptr.Length()); + buffer->Des().Copy(ptr); +#else + TPtrC16 ptr(reinterpret_cast<const TUint16*>(aString.utf16())); + buffer = HBufC16::NewL(ptr.Length()); + buffer->Des().Copy(ptr); +#endif + return buffer; +} +#endif + class tst_QFileSystemModel : public QObject { Q_OBJECT @@ -123,6 +142,9 @@ protected: private: QFileSystemModel *model; QString flatDirTestPath; +#if defined(Q_OS_SYMBIAN) + RFs rfs; +#endif }; tst_QFileSystemModel::tst_QFileSystemModel() : model(0) @@ -133,10 +155,16 @@ tst_QFileSystemModel::tst_QFileSystemModel() : model(0) qsrand(midnight.secsTo(QTime::currentTime())); // generating unique temporary directory name flatDirTestPath = QDir::temp().path() + '/' + QString("flatdirtest.") + QString::number(qrand()); +#if defined(Q_OS_SYMBIAN) + rfs.Connect(); +#endif } tst_QFileSystemModel::~tst_QFileSystemModel() { +#if defined(Q_OS_SYMBIAN) + rfs.Close(); +#endif QString tmp = flatDirTestPath; QDir dir(tmp); if (dir.exists() && !dir.rmdir(tmp)) @@ -176,7 +204,7 @@ void tst_QFileSystemModel::cleanup() void tst_QFileSystemModel::indexPath() { -#ifndef Q_OS_WIN +#if !defined(Q_OS_WIN) && !defined(Q_OS_SYMBIAN) int depth = QDir::currentPath().count('/'); model->setRootPath(QDir::currentPath()); QTest::qWait(WAITTIME); @@ -380,6 +408,12 @@ bool tst_QFileSystemModel::createFiles(const QString &test_path, const QStringLi #if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) if (initial_files.at(i)[0] == '.') QProcess::execute(QString("attrib +h %1").arg(file.fileName())); +#elif defined(Q_OS_SYMBIAN) + if (initial_files.at(i)[0] == '.') { + HBufC* buffer = qt_QString2HBufCNewL(QDir::toNativeSeparators(file.fileName())); + rfs.SetAtt(*buffer, KEntryAttHidden, 0); + delete buffer; + } #endif //qDebug() << test_path + '/' + initial_files.at(i) << (QFile::exists(test_path + '/' + initial_files.at(i))); } @@ -568,7 +602,7 @@ void tst_QFileSystemModel::filters_data() QTest::addColumn<int>("dirFilters"); QTest::addColumn<QStringList>("nameFilters"); QTest::addColumn<int>("rowCount"); -#if !defined(Q_OS_WINCE) +#if !defined(Q_OS_WINCE) && !defined(Q_OS_SYMBIAN) QTest::newRow("no dirs") << (QStringList() << "a" << "b" << "c") << QStringList() << (int)(QDir::Dirs) << QStringList() << 2; QTest::newRow("one dir - dotdot") << (QStringList() << "a" << "b" << "c") << (QStringList() << "Z") << (int)(QDir::Dirs | QDir::NoDotAndDotDot) << QStringList() << 1; QTest::newRow("one dir") << (QStringList() << "a" << "b" << "c") << (QStringList() << "Z") << (int)(QDir::Dirs) << QStringList() << 3; @@ -593,7 +627,12 @@ void tst_QFileSystemModel::filters_data() QTest::newRow("no dir + hidden") << (QStringList() << "a" << "b" << "c") << QStringList() << (int)(QDir::Dirs | QDir::Hidden) << QStringList() << 0; QTest::newRow("dir+hid+files") << (QStringList() << "a" << "b" << "c") << QStringList() << (int)(QDir::Dirs | QDir::Files | QDir::Hidden) << QStringList() << 3; +#if defined(Q_OS_SYMBIAN) + // Some symbian envs have a bug that causes "A" and ".A" to be considered same name in file system. + QTest::newRow("dir+file+hid-dot .D") << (QStringList() << "a" << "b" << "c") << (QStringList() << ".D") << +#else QTest::newRow("dir+file+hid-dot .A") << (QStringList() << "a" << "b" << "c") << (QStringList() << ".A") << +#endif (int)(QDir::Dirs | QDir::Files | QDir::Hidden | QDir::NoDotAndDotDot) << QStringList() << 4; QTest::newRow("dir+files+hid+dot A") << (QStringList() << "a" << "b" << "c") << (QStringList() << "AFolder") << (int)(QDir::Dirs | QDir::Files | QDir::Hidden | QDir::NoDotAndDotDot) << (QStringList() << "A*") << 2; @@ -910,7 +949,7 @@ void tst_QFileSystemModel::dirsBeforeFiles() #endif } } - + QTEST_MAIN(tst_QFileSystemModel) #include "tst_qfilesystemmodel.moc" diff --git a/tests/auto/qfilesystemwatcher/qfilesystemwatcher.pro b/tests/auto/qfilesystemwatcher/qfilesystemwatcher.pro index c4d1d6f..8b8616a 100644 --- a/tests/auto/qfilesystemwatcher/qfilesystemwatcher.pro +++ b/tests/auto/qfilesystemwatcher/qfilesystemwatcher.pro @@ -1,5 +1,3 @@ load(qttest_p4) SOURCES += tst_qfilesystemwatcher.cpp QT = core - - diff --git a/tests/auto/qfilesystemwatcher/tst_qfilesystemwatcher.cpp b/tests/auto/qfilesystemwatcher/tst_qfilesystemwatcher.cpp index b1e8c09..a3dab07 100644 --- a/tests/auto/qfilesystemwatcher/tst_qfilesystemwatcher.cpp +++ b/tests/auto/qfilesystemwatcher/tst_qfilesystemwatcher.cpp @@ -73,9 +73,11 @@ private slots: void removePath(); void addPaths(); void removePaths(); - void watchFileAndItsDirectory(); + void watchFileAndItsDirectory_data() { basicTest_data(); } + void watchFileAndItsDirectory(); + void cleanup(); private: QStringList do_force_engines; bool do_force_native; @@ -96,7 +98,7 @@ tst_QFileSystemWatcher::tst_QFileSystemWatcher() if (inotify_init() != -1) do_force_engines << "inotify"; #endif -#elif defined(Q_OS_WIN) || defined(Q_OS_DARWIN) || defined(Q_OS_FREEBSD) +#elif defined(Q_OS_WIN) || defined(Q_OS_DARWIN) || defined(Q_OS_FREEBSD) || defined(Q_OS_SYMBIAN) // we have native engines for win32, macosx and freebsd do_force_engines << "native"; #endif @@ -314,6 +316,9 @@ void tst_QFileSystemWatcher::watchDirectory() #ifdef Q_OS_WINCE QEXPECT_FAIL("poller", "Directory does not get updated on file removal(See #137910)", Abort); +#elif defined(Q_OS_SYMBIAN) && defined(Q_CC_RVCT) + // Since native watcher is always used in real devices, this poller issue is irrelevant + QEXPECT_FAIL("poller", "Poller doesn't detect directory removal in RVCT builds", Abort); #endif QCOMPARE(changedSpy.count(), 2); QCOMPARE(changedSpy.at(0).count(), 1); @@ -456,12 +461,22 @@ void tst_QFileSystemWatcher::watchFileAndItsDirectory() timer.start(3000); eventLoop.exec(); QVERIFY(fileChangedSpy.count() > 0); - QCOMPARE(dirChangedSpy.count(), 0); + //according to Qt 4 documentation: + //void QFileSystemWatcher::directoryChanged ( const QString & path ) [signal] + //This signal is emitted when the directory at a specified path, is modified + //(e.g., when a file is added, -->modified<-- or deleted) or removed from disk. + //Note that if there are several changes during a short period of time, some + //of the changes might not emit this signal. However, the last change in the + //sequence of changes will always generate this signal. + //Symbian behaves as documented (and can't be filtered), but the other platforms don't + //so test should not assert this + QVERIFY(dirChangedSpy.count() < 2); if (backend == "dnotify") QSKIP("dnotify is broken, skipping the rest of the test.", SkipSingle); fileChangedSpy.clear(); + dirChangedSpy.clear(); QFile secondFile(secondFileName); secondFile.open(QIODevice::WriteOnly | QIODevice::Truncate); secondFile.write("Foo"); @@ -470,6 +485,11 @@ void tst_QFileSystemWatcher::watchFileAndItsDirectory() timer.start(3000); eventLoop.exec(); QCOMPARE(fileChangedSpy.count(), 0); +#if defined(Q_OS_SYMBIAN) && defined(Q_CC_RVCT) + // Since native watcher is always used in real devices, this poller issue is irrelevant + // Symbian file system does not change modification time on a directory when a file inside is changed + QEXPECT_FAIL("poller", "Poller doesn't detect directory changes in RVCT builds", Abort); +#endif QCOMPARE(dirChangedSpy.count(), 1); dirChangedSpy.clear(); @@ -495,5 +515,15 @@ void tst_QFileSystemWatcher::watchFileAndItsDirectory() QVERIFY(QDir().rmdir("testDir")); } +void tst_QFileSystemWatcher::cleanup() +{ + QDir testDir("testDir"); + QString testFileName = testDir.filePath("testFile.txt"); + QString secondFileName = testDir.filePath("testFile2.txt"); + QFile::remove(testFileName); + QFile::remove(secondFileName); + QDir().rmdir("testDir"); +} + QTEST_MAIN(tst_QFileSystemWatcher) #include "tst_qfilesystemwatcher.moc" diff --git a/tests/auto/qflags/qflags.pro b/tests/auto/qflags/qflags.pro index 1e62db1..cd7f759 100644 --- a/tests/auto/qflags/qflags.pro +++ b/tests/auto/qflags/qflags.pro @@ -1,6 +1,3 @@ load(qttest_p4) SOURCES += tst_qflags.cpp - QT = core - - diff --git a/tests/auto/qfontdatabase/qfontdatabase.pro b/tests/auto/qfontdatabase/qfontdatabase.pro index cee6839..35811f1 100644 --- a/tests/auto/qfontdatabase/qfontdatabase.pro +++ b/tests/auto/qfontdatabase/qfontdatabase.pro @@ -1,8 +1,8 @@ load(qttest_p4) SOURCES += tst_qfontdatabase.cpp -DEFINES += SRCDIR=\\\"$$PWD\\\" +!symbian:DEFINES += SRCDIR=\\\"$$PWD\\\" -wince* { +wince*|symbian { additionalFiles.sources = FreeMono.ttf additionalFiles.path = . DEPLOYMENT += additionalFiles diff --git a/tests/auto/qfontdatabase/tst_qfontdatabase.cpp b/tests/auto/qfontdatabase/tst_qfontdatabase.cpp index 5e813f3..2358d31 100644 --- a/tests/auto/qfontdatabase/tst_qfontdatabase.cpp +++ b/tests/auto/qfontdatabase/tst_qfontdatabase.cpp @@ -45,9 +45,9 @@ #include <qfontdatabase.h> - - - +#ifdef Q_OS_SYMBIAN +#define SRCDIR "." +#endif //TESTED_CLASS= //TESTED_FILES= @@ -191,6 +191,9 @@ void tst_QFontDatabase::addAppFont_data() void tst_QFontDatabase::addAppFont() { +#ifdef Q_OS_SYMBIAN + QSKIP( "Symbian: Application fonts are not yet supported", SkipAll ); +#else QFETCH(bool, useMemoryFont); QSignalSpy fontDbChangedSpy(QApplication::instance(), SIGNAL(fontDatabaseChanged())); @@ -240,6 +243,7 @@ void tst_QFontDatabase::addAppFont() QCOMPARE(fontDbChangedSpy.count(), 2); QVERIFY(db.families() == oldFamilies); +#endif } QTEST_MAIN(tst_QFontDatabase) diff --git a/tests/auto/qfontdialog/tst_qfontdialog.cpp b/tests/auto/qfontdialog/tst_qfontdialog.cpp index 9605ab3..39b3f08 100644 --- a/tests/auto/qfontdialog/tst_qfontdialog.cpp +++ b/tests/auto/qfontdialog/tst_qfontdialog.cpp @@ -171,7 +171,7 @@ void tst_QFontDialog::task256466_wrongStyle() QModelIndex currentFamily = familyList->model()->index(i, 0); familyList->setCurrentIndex(currentFamily); const QFont current = dialog.currentFont(), - expected = fdb.font(currentFamily.data().toString(), + expected = fdb.font(currentFamily.data().toString(), styleList->currentIndex().data().toString(), sizeList->currentIndex().data().toInt()); QCOMPARE(current.family(), expected.family()); QCOMPARE(current.style(), expected.style()); diff --git a/tests/auto/qftp/.gitattributes b/tests/auto/qftp/.gitattributes index d220f58..e04709a 100644 --- a/tests/auto/qftp/.gitattributes +++ b/tests/auto/qftp/.gitattributes @@ -1 +1 @@ -rfc3252.txt -cflf Unset +rfc3252.txt -crlf diff --git a/tests/auto/qftp/qftp.pro b/tests/auto/qftp/qftp.pro index 84d8c19..c060296 100644 --- a/tests/auto/qftp/qftp.pro +++ b/tests/auto/qftp/qftp.pro @@ -9,6 +9,11 @@ wince*: { addFiles.path = . DEPLOYMENT += addFiles DEFINES += SRCDIR=\\\"\\\" +} else:symbian* { + addFiles.sources = rfc3252.txt + addFiles.path = . + DEPLOYMENT += addFiles + TARGET.EPOCHEAPSIZE="0x100 0x1000000" } else { DEFINES += SRCDIR=\\\"$$PWD/\\\" } diff --git a/tests/auto/qftp/tst_qftp.cpp b/tests/auto/qftp/tst_qftp.cpp index 7fa5601..34b42a9 100644 --- a/tests/auto/qftp/tst_qftp.cpp +++ b/tests/auto/qftp/tst_qftp.cpp @@ -51,11 +51,22 @@ #include <stdlib.h> #include <QNetworkProxy> +#ifndef TEST_QNETWORK_PROXY +#define TEST_QNETWORK_PROXY +#endif #include "../network-settings.h" //TESTED_CLASS= //TESTED_FILES= +#ifdef Q_OS_SYMBIAN +// In Symbian OS test data is located in applications private dir +// Application private dir is default serach path for files, so SRCDIR can be set to empty +#define SRCDIR "" +#endif + + + class tst_QFtp : public QObject { Q_OBJECT @@ -178,11 +189,11 @@ const int bytesDone_init = -10; tst_QFtp::tst_QFtp() { + Q_SET_DEFAULT_IAP } tst_QFtp::~tst_QFtp() { - } void tst_QFtp::initTestCase_data() @@ -191,9 +202,11 @@ void tst_QFtp::initTestCase_data() QTest::addColumn<int>("proxyType"); QTest::newRow("WithoutProxy") << false << 0; +#ifdef TEST_QNETWORK_PROXY QTest::newRow("WithSocks5Proxy") << true << int(QNetworkProxy::Socks5Proxy); //### doesn't work well yet. //QTest::newRow("WithHttpProxy") << true << int(QNetworkProxy::HttpProxy); +#endif } void tst_QFtp::initTestCase() @@ -1144,7 +1157,7 @@ QDataStream &operator>>( QDataStream &s, FtpCommand &command ) } Q_DECLARE_METATYPE(QList<FtpCommand>) - void tst_QFtp::commandSequence_data() +void tst_QFtp::commandSequence_data() { // some "constants" QStringList argConnectToHost01; @@ -1279,8 +1292,8 @@ void tst_QFtp::abort_data() QTest::newRow( "get_fluke01" ) << QtNetworkSettings::serverName() << (uint)21 << QString("qtest/bigfile") << QByteArray(); QTest::newRow( "get_fluke02" ) << QtNetworkSettings::serverName() << (uint)21 << QString("qtest/rfc3252") << QByteArray(); - // Qt/CE test environment has to less memory for this test -#if !defined(Q_OS_WINCE) + // Qt/CE and Symbian test environment has to less memory for this test +#if !defined(Q_OS_WINCE) && !defined(Q_OS_SYMBIAN) QByteArray bigData( 10*1024*1024, 0 ); bigData.fill( 'B' ); @@ -1501,7 +1514,6 @@ void tst_QFtp::proxy() void tst_QFtp::binaryAscii() { - QString file = "asciifile%1.txt"; if(file.contains('%')) @@ -1548,7 +1560,6 @@ void tst_QFtp::binaryAscii() // (and do not remove the windows line ending), the -1 below could be // deleted in the future QVERIFY(getData.size() == putData.size()-1); - ////////////////////////////////////////////////////////////////// // cleanup (i.e. remove the file) -- this also tests the remove command init(); @@ -2042,4 +2053,5 @@ void tst_QFtp::cdUpSlot(bool error) } QTEST_MAIN(tst_QFtp) + #include "tst_qftp.moc" diff --git a/tests/auto/qgetputenv/qgetputenv.pro b/tests/auto/qgetputenv/qgetputenv.pro index ed3eac9..cbde272 100644 --- a/tests/auto/qgetputenv/qgetputenv.pro +++ b/tests/auto/qgetputenv/qgetputenv.pro @@ -1,7 +1,3 @@ load(qttest_p4) SOURCES += tst_qgetputenv.cpp - QT = core - - - diff --git a/tests/auto/qglobal/qglobal.pro b/tests/auto/qglobal/qglobal.pro index 373061b..8f1e00a 100644 --- a/tests/auto/qglobal/qglobal.pro +++ b/tests/auto/qglobal/qglobal.pro @@ -1,6 +1,3 @@ load(qttest_p4) - SOURCES += tst_qglobal.cpp QT = core - - diff --git a/tests/auto/qglobal/tst_qglobal.cpp b/tests/auto/qglobal/tst_qglobal.cpp index a299b13..58c7def 100644 --- a/tests/auto/qglobal/tst_qglobal.cpp +++ b/tests/auto/qglobal/tst_qglobal.cpp @@ -50,6 +50,8 @@ private slots: void qInternalCallbacks(); void for_each(); void qassert(); + void qtry(); + void checkptr(); }; void tst_QGlobal::qIsNull() @@ -190,5 +192,75 @@ void tst_QGlobal::qassert() QVERIFY(passed); } +void tst_QGlobal::qtry() +{ + int i = 0; + QT_TRY { + i = 1; + QT_THROW(42); + i = 2; + } QT_CATCH(int) { + QCOMPARE(i, 1); + i = 7; + } +#ifdef QT_NO_EXCEPTIONS + QCOMPARE(i, 2); +#else + QCOMPARE(i, 7); +#endif + + // check propper if/else scoping + i = 0; + if (true) + QT_TRY { + i = 2; + QT_THROW(42); + i = 4; + } QT_CATCH(int) { + QCOMPARE(i, 2); + i = 4; + } + else + QCOMPARE(i, 0); + QCOMPARE(i, 4); + + i = 0; + if (false) + QT_TRY { + i = 2; + QT_THROW(42); + i = 4; + } QT_CATCH(int) { + QCOMPARE(i, 2); + i = 2; + } + else + i = 8; + QCOMPARE(i, 8); + + i = 0; + if (false) + i = 42; + else + QT_TRY { + i = 2; + QT_THROW(42); + i = 4; + } QT_CATCH(int) { + QCOMPARE(i, 2); + i = 4; + } + QCOMPARE(i, 4); +} + +void tst_QGlobal::checkptr() +{ + int i; + QCOMPARE(q_check_ptr(&i), &i); + + const char *c = "hello"; + QCOMPARE(q_check_ptr(c), c); +} + QTEST_MAIN(tst_QGlobal) #include "tst_qglobal.moc" diff --git a/tests/auto/qgraphicsanchorlayout/qgraphicsanchorlayout.pro b/tests/auto/qgraphicsanchorlayout/qgraphicsanchorlayout.pro new file mode 100644 index 0000000..4c065f4 --- /dev/null +++ b/tests/auto/qgraphicsanchorlayout/qgraphicsanchorlayout.pro @@ -0,0 +1,3 @@ +load(qttest_p4) +SOURCES += tst_qgraphicsanchorlayout.cpp + diff --git a/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp b/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp new file mode 100644 index 0000000..a579ba5 --- /dev/null +++ b/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp @@ -0,0 +1,868 @@ +#include <QtTest/QtTest> +#include <qgraphicsanchorlayout.h> +#include <qgraphicswidget.h> +#include <qgraphicsproxywidget.h> +#include <QtGui/qgraphicsview.h> + +class tst_QGraphicsAnchorLayout : public QObject { + Q_OBJECT; + +private slots: + void simple(); + void diagonal(); + void parallel(); + void parallel2(); + void snake(); + void snakeOppositeDirections(); + void fairDistribution(); + void fairDistributionOppositeDirections(); + void proportionalPreferred(); + void example(); + void setSpacing(); + +}; + +class RectWidget : public QGraphicsWidget +{ +public: + RectWidget(QGraphicsItem *parent = 0) : QGraphicsWidget(parent){} + + void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) + { + Q_UNUSED(option); + Q_UNUSED(widget); + painter->drawRoundRect(rect()); + painter->drawLine(rect().topLeft(), rect().bottomRight()); + painter->drawLine(rect().bottomLeft(), rect().topRight()); + } +}; + +static QGraphicsWidget *createItem(const QSizeF &minimum = QSizeF(100.0, 100.0), + const QSizeF &preferred = QSize(150.0, 100.0), + const QSizeF &maximum = QSizeF(200.0, 100.0), + const QString &name = QString()) +{ + QGraphicsWidget *w = new RectWidget; + w->setMinimumSize(minimum); + w->setPreferredSize(preferred); + w->setMaximumSize(maximum); + w->setData(0, name); + return w; +} + +void tst_QGraphicsAnchorLayout::simple() +{ + QGraphicsWidget *w1 = createItem(); + QGraphicsWidget *w2 = createItem(); + + QGraphicsAnchorLayout *l = new QGraphicsAnchorLayout; + l->setContentsMargins(0, 0, 0, 0); + l->addAnchor(w1, Qt::AnchorRight, w2, Qt::AnchorLeft); + + QGraphicsWidget p; + p.setLayout(l); + + QCOMPARE(l->count(), 2); +} + +void tst_QGraphicsAnchorLayout::diagonal() +{ + QSizeF min(10, 100); + QSizeF pref(70, 100); + QSizeF max(100, 100); + + QGraphicsWidget *a = createItem(min, pref, max, "A"); + QGraphicsWidget *b = createItem(min, pref, max, "B"); + QGraphicsWidget *c = createItem(min, pref, max, "C"); + QGraphicsWidget *d = createItem(min, pref, max, "D"); + QGraphicsWidget *e = createItem(min, pref, max, "E"); + + QGraphicsAnchorLayout *l = new QGraphicsAnchorLayout; + l->setContentsMargins(0, 0, 0, 0); + + // vertical + l->addAnchor(a, Qt::AnchorTop, l, Qt::AnchorTop); + l->setAnchorSpacing(a, Qt::AnchorTop, l, Qt::AnchorTop, 0); + + l->addAnchor(b, Qt::AnchorTop, l, Qt::AnchorTop); + l->setAnchorSpacing(b, Qt::AnchorTop, l, Qt::AnchorTop, 0); + + l->addAnchor(c, Qt::AnchorTop, a, Qt::AnchorBottom); + l->setAnchorSpacing(c, Qt::AnchorTop, a, Qt::AnchorBottom, 0); + l->addAnchor(c, Qt::AnchorTop, b, Qt::AnchorBottom); + l->setAnchorSpacing(c, Qt::AnchorTop, b, Qt::AnchorBottom, 0); + l->addAnchor(c, Qt::AnchorBottom, d, Qt::AnchorTop); + l->setAnchorSpacing(c, Qt::AnchorBottom, d, Qt::AnchorTop, 0); + l->addAnchor(c, Qt::AnchorBottom, e, Qt::AnchorTop); + l->setAnchorSpacing(c, Qt::AnchorBottom, e, Qt::AnchorTop, 0); + + l->addAnchor(d, Qt::AnchorBottom, l, Qt::AnchorBottom); + l->setAnchorSpacing(d, Qt::AnchorBottom, l, Qt::AnchorBottom, 0); + l->addAnchor(e, Qt::AnchorBottom, l, Qt::AnchorBottom); + l->setAnchorSpacing(e, Qt::AnchorBottom, l, Qt::AnchorBottom, 0); + + // horizontal + l->addAnchor(l, Qt::AnchorLeft, a, Qt::AnchorLeft); + l->setAnchorSpacing(l, Qt::AnchorLeft, a, Qt::AnchorLeft, 0); + l->addAnchor(l, Qt::AnchorLeft, d, Qt::AnchorLeft); + l->setAnchorSpacing(l, Qt::AnchorLeft, d, Qt::AnchorLeft, 0); + l->addAnchor(a, Qt::AnchorRight, b, Qt::AnchorLeft); + l->setAnchorSpacing(a, Qt::AnchorRight, b, Qt::AnchorLeft, 0); + + l->addAnchor(a, Qt::AnchorRight, c, Qt::AnchorLeft); + l->setAnchorSpacing(a, Qt::AnchorRight, c, Qt::AnchorLeft, 0); + l->addAnchor(c, Qt::AnchorRight, e, Qt::AnchorLeft); + l->setAnchorSpacing(c, Qt::AnchorRight, e, Qt::AnchorLeft, 0); + + l->addAnchor(b, Qt::AnchorRight, l, Qt::AnchorRight); + l->setAnchorSpacing(b, Qt::AnchorRight, l, Qt::AnchorRight, 0); + l->addAnchor(e, Qt::AnchorRight, l, Qt::AnchorRight); + l->setAnchorSpacing(e, Qt::AnchorRight, l, Qt::AnchorRight, 0); + l->addAnchor(d, Qt::AnchorRight, e, Qt::AnchorLeft); + l->setAnchorSpacing(d, Qt::AnchorRight, e, Qt::AnchorLeft, 0); + + QCOMPARE(l->count(), 5); + + QGraphicsWidget p; + p.setLayout(l); + + QSizeF layoutMinimumSize = l->effectiveSizeHint(Qt::MinimumSize); + QSizeF layoutMaximumSize = l->effectiveSizeHint(Qt::MaximumSize); + QSizeF layoutPreferredSize = l->effectiveSizeHint(Qt::PreferredSize); + + QCOMPARE(layoutMinimumSize, QSizeF(30.0, 300.0)); + QCOMPARE(layoutPreferredSize, QSizeF(170.0, 300.0)); + QCOMPARE(layoutMaximumSize, QSizeF(190.0, 300.0)); + + p.resize(layoutMinimumSize); + QCOMPARE(a->geometry(), QRectF(0.0, 0.0, 10.0, 100.0)); + QCOMPARE(b->geometry(), QRectF(10.0, 0.0, 20.0, 100.0)); + QCOMPARE(c->geometry(), QRectF(10.0, 100.0, 10.0, 100.0)); + QCOMPARE(d->geometry(), QRectF(0.0, 200.0, 20.0, 100.0)); + QCOMPARE(e->geometry(), QRectF(20.0, 200.0, 10.0, 100.0)); + QCOMPARE(p.size(), layoutMinimumSize); + + p.resize(layoutPreferredSize); + QCOMPARE(a->geometry(), QRectF(0.0, 0.0, 70.0, 100.0)); + QCOMPARE(b->geometry(), QRectF(70.0, 0.0, 100.0, 100.0)); + QCOMPARE(c->geometry(), QRectF(70.0, 100.0, 30.0, 100.0)); + QCOMPARE(d->geometry(), QRectF(0.0, 200.0, 100.0, 100.0)); + QCOMPARE(e->geometry(), QRectF(100.0, 200.0, 70.0, 100.0)); + QCOMPARE(p.size(), layoutPreferredSize); + + p.resize(layoutMaximumSize); + QCOMPARE(a->geometry(), QRectF(0.0, 0.0, 90.0, 100.0)); + QCOMPARE(b->geometry(), QRectF(90.0, 0.0, 100.0, 100.0)); + QCOMPARE(c->geometry(), QRectF(90.0, 100.0, 10.0, 100.0)); + QCOMPARE(d->geometry(), QRectF(0.0, 200.0, 100.0, 100.0)); + QCOMPARE(e->geometry(), QRectF(100.0, 200.0, 90.0, 100.0)); + QCOMPARE(p.size(), layoutMaximumSize); + + QSizeF testA(175.0, 300.0); + p.resize(testA); + QCOMPARE(a->geometry(), QRectF(0.0, 0.0, 75.0, 100.0)); + QCOMPARE(b->geometry(), QRectF(75.0, 0.0, 100.0, 100.0)); + QCOMPARE(c->geometry(), QRectF(75.0, 100.0, 25.0, 100.0)); + QCOMPARE(d->geometry(), QRectF(0.0, 200.0, 100.0, 100.0)); + QCOMPARE(e->geometry(), QRectF(100.0, 200.0, 75.0, 100.0)); + QCOMPARE(p.size(), testA); +} + +void tst_QGraphicsAnchorLayout::parallel() +{ + QGraphicsWidget *a = createItem(QSizeF(100, 100), + QSizeF(150, 100), + QSizeF(200, 100), "A"); + + QGraphicsWidget *b = createItem(QSizeF(100, 100), + QSizeF(150, 100), + QSizeF(300, 100), "B"); + + QGraphicsWidget *c = createItem(QSizeF(100, 100), + QSizeF(200, 100), + QSizeF(350, 100), "C"); + + QGraphicsWidget *d = createItem(QSizeF(100, 100), + QSizeF(170, 100), + QSizeF(200, 100), "D"); + + QGraphicsWidget *e = createItem(QSizeF(150, 100), + QSizeF(150, 100), + QSizeF(200, 100), "E"); + + QGraphicsWidget *f = createItem(QSizeF(100, 100), + QSizeF(150, 100), + QSizeF(200, 100), "F"); + + QGraphicsAnchorLayout *l = new QGraphicsAnchorLayout; + l->setContentsMargins(0, 0, 0, 0); + + l->addAnchor(l, Qt::AnchorTop, a, Qt::AnchorTop); + l->setAnchorSpacing(l, Qt::AnchorTop, a, Qt::AnchorTop, 0); + l->addAnchor(a, Qt::AnchorBottom, b, Qt::AnchorTop); + l->setAnchorSpacing(a, Qt::AnchorBottom, b, Qt::AnchorTop, 0); + l->addAnchor(b, Qt::AnchorBottom, c, Qt::AnchorTop); + l->setAnchorSpacing(b, Qt::AnchorBottom, c, Qt::AnchorTop, 0); + l->addAnchor(c, Qt::AnchorBottom, d, Qt::AnchorTop); + l->setAnchorSpacing(c, Qt::AnchorBottom, d, Qt::AnchorTop, 0); + l->addAnchor(d, Qt::AnchorBottom, e, Qt::AnchorTop); + l->setAnchorSpacing(d, Qt::AnchorBottom, e, Qt::AnchorTop, 0); + l->addAnchor(e, Qt::AnchorBottom, f, Qt::AnchorTop); + l->setAnchorSpacing(e, Qt::AnchorBottom, f, Qt::AnchorTop, 0); + l->addAnchor(f, Qt::AnchorBottom, l, Qt::AnchorBottom); + l->setAnchorSpacing(f, Qt::AnchorBottom, l, Qt::AnchorBottom, 0); + + l->addAnchor(l, Qt::AnchorLeft, a, Qt::AnchorLeft); + l->setAnchorSpacing(l, Qt::AnchorLeft, a, Qt::AnchorLeft, 0); + l->addAnchor(a, Qt::AnchorRight, b, Qt::AnchorLeft); + l->setAnchorSpacing(a, Qt::AnchorRight, b, Qt::AnchorLeft, 0); + l->addAnchor(a, Qt::AnchorRight, c, Qt::AnchorLeft); + l->setAnchorSpacing(a, Qt::AnchorRight, c, Qt::AnchorLeft, 0); + l->addAnchor(b, Qt::AnchorRight, d, Qt::AnchorLeft); + l->setAnchorSpacing(b, Qt::AnchorRight, d, Qt::AnchorLeft, 0); + l->addAnchor(b, Qt::AnchorRight, e, Qt::AnchorLeft); + l->setAnchorSpacing(b, Qt::AnchorRight, e, Qt::AnchorLeft, 0); + l->addAnchor(c, Qt::AnchorRight, f, Qt::AnchorLeft); + l->setAnchorSpacing(c, Qt::AnchorRight, f, Qt::AnchorLeft, 0); + l->addAnchor(d, Qt::AnchorRight, f, Qt::AnchorLeft); + l->setAnchorSpacing(d, Qt::AnchorRight, f, Qt::AnchorLeft, 0); + l->addAnchor(e, Qt::AnchorRight, f, Qt::AnchorLeft); + l->setAnchorSpacing(e, Qt::AnchorRight, f, Qt::AnchorLeft, 0); + l->addAnchor(f, Qt::AnchorRight, l, Qt::AnchorRight); + l->setAnchorSpacing(f, Qt::AnchorRight, l, Qt::AnchorRight, 0); + + QCOMPARE(l->count(), 6); + + QGraphicsWidget p; + p.setLayout(l); + + QSizeF layoutMinimumSize = l->effectiveSizeHint(Qt::MinimumSize); + QSizeF layoutPreferredSize = l->effectiveSizeHint(Qt::PreferredSize); + QSizeF layoutMaximumSize = l->effectiveSizeHint(Qt::MaximumSize); + + QCOMPARE(layoutMinimumSize, QSizeF(450, 600)); + QCOMPARE(layoutPreferredSize, QSizeF(620, 600)); + QCOMPARE(layoutMaximumSize, QSizeF(750, 600)); + + p.resize(layoutMinimumSize); + QCOMPARE(a->geometry(), QRectF(0, 0, 100, 100)); + QCOMPARE(b->geometry(), QRectF(100, 100, 100, 100)); + QCOMPARE(c->geometry(), QRectF(100, 200, 250, 100)); + QCOMPARE(d->geometry(), QRectF(200, 300, 150, 100)); + QCOMPARE(e->geometry(), QRectF(200, 400, 150, 100)); + QCOMPARE(f->geometry(), QRectF(350, 500, 100, 100)); + QCOMPARE(p.size(), layoutMinimumSize); + + p.resize(layoutPreferredSize); + QCOMPARE(a->geometry(), QRectF(0, 0, 150, 100)); + QCOMPARE(b->geometry(), QRectF(150, 100, 150, 100)); + QCOMPARE(c->geometry(), QRectF(150, 200, 320, 100)); + QCOMPARE(d->geometry(), QRectF(300, 300, 170, 100)); + QCOMPARE(e->geometry(), QRectF(300, 400, 170, 100)); + QCOMPARE(f->geometry(), QRectF(470, 500, 150, 100)); + QCOMPARE(p.size(), layoutPreferredSize); + + // Maximum size depends on simplification / fair distribution + // Without that, test may or may not pass, depending on the + // solution found by the solver at runtime. + p.resize(layoutMaximumSize); + QCOMPARE(a->geometry(), QRectF(0, 0, 200, 100)); + QCOMPARE(b->geometry(), QRectF(200, 100, 175, 100)); + QCOMPARE(c->geometry(), QRectF(200, 200, 350, 100)); + QCOMPARE(d->geometry(), QRectF(375, 300, 175, 100)); + QCOMPARE(e->geometry(), QRectF(375, 400, 175, 100)); + QCOMPARE(f->geometry(), QRectF(550, 500, 200, 100)); + QCOMPARE(p.size(), layoutMaximumSize); +} + +void tst_QGraphicsAnchorLayout::parallel2() +{ + QGraphicsWidget *a = createItem(QSizeF(70.0, 100.0), + QSizeF(100.0, 100.0), + QSizeF(200.0, 100.0), "A"); + + QGraphicsWidget *b = createItem(QSizeF(100.0, 100.0), + QSizeF(150.0, 100.0), + QSizeF(190.0, 100.0), "B"); + + QGraphicsAnchorLayout *l = new QGraphicsAnchorLayout; + l->setContentsMargins(0, 0, 0, 0); + + l->addAnchor(l, Qt::AnchorTop, a, Qt::AnchorTop); + l->setAnchorSpacing(l, Qt::AnchorTop, a, Qt::AnchorTop, 0); + l->addAnchor(a, Qt::AnchorBottom, b, Qt::AnchorTop); + l->setAnchorSpacing(a, Qt::AnchorBottom, b, Qt::AnchorTop, 0); + l->addAnchor(b, Qt::AnchorBottom, l, Qt::AnchorBottom); + l->setAnchorSpacing(b, Qt::AnchorBottom, l, Qt::AnchorBottom, 0); + + l->addLeftAndRightAnchors(l, a); + l->addAnchor(l, Qt::AnchorLeft, b, Qt::AnchorLeft); + l->setAnchorSpacing(l, Qt::AnchorLeft, b, Qt::AnchorLeft, 0); + l->addAnchor(b, Qt::AnchorRight, a, Qt::AnchorRight); + l->setAnchorSpacing(b, Qt::AnchorRight, a, Qt::AnchorRight, 0); + + QCOMPARE(l->count(), 2); + + QGraphicsWidget p; + p.setLayout(l); + + QSizeF layoutMinimumSize = l->effectiveSizeHint(Qt::MinimumSize); + QSizeF layoutPreferredSize = l->effectiveSizeHint(Qt::PreferredSize); + QSizeF layoutMaximumSize = l->effectiveSizeHint(Qt::MaximumSize); + + QCOMPARE(layoutMinimumSize, QSizeF(100.0, 200.0)); + QCOMPARE(layoutPreferredSize, QSizeF(150.0, 200.0)); + QCOMPARE(layoutMaximumSize, QSizeF(190.0, 200.0)); + + p.resize(layoutMinimumSize); + QCOMPARE(p.size(), layoutMinimumSize); + + p.resize(layoutPreferredSize); + QCOMPARE(p.size(), layoutPreferredSize); + + p.resize(layoutMaximumSize); + QCOMPARE(p.size(), layoutMaximumSize); +} + +void tst_QGraphicsAnchorLayout::snake() +{ + QGraphicsWidget *a = createItem(QSizeF(50.0, 100.0), + QSizeF(70.0, 100.0), + QSizeF(100.0, 100.0), "A"); + + QGraphicsWidget *b = createItem(QSizeF(10.0, 100.0), + QSizeF(20.0, 100.0), + QSizeF(40.0, 100.0), "B"); + + QGraphicsWidget *c = createItem(QSizeF(50.0, 100.0), + QSizeF(70.0, 100.0), + QSizeF(100.0, 100.0), "C"); + + QGraphicsAnchorLayout *l = new QGraphicsAnchorLayout; + l->setContentsMargins(0, 0, 0, 0); + + l->addAnchor(l, Qt::AnchorTop, a, Qt::AnchorTop); + l->setAnchorSpacing(l, Qt::AnchorTop, a, Qt::AnchorTop, 0); + l->addAnchor(a, Qt::AnchorBottom, b, Qt::AnchorTop); + l->setAnchorSpacing(a, Qt::AnchorBottom, b, Qt::AnchorTop, 0); + l->addAnchor(b, Qt::AnchorBottom, c, Qt::AnchorTop); + l->setAnchorSpacing(b, Qt::AnchorBottom, c, Qt::AnchorTop, 0); + l->addAnchor(c, Qt::AnchorBottom, l, Qt::AnchorBottom); + l->setAnchorSpacing(c, Qt::AnchorBottom, l, Qt::AnchorBottom, 0); + + l->addAnchor(l, Qt::AnchorLeft, a, Qt::AnchorLeft); + l->setAnchorSpacing(l, Qt::AnchorLeft, a, Qt::AnchorLeft, 0); + l->addAnchor(a, Qt::AnchorRight, b, Qt::AnchorRight); + l->setAnchorSpacing(a, Qt::AnchorRight, b, Qt::AnchorRight, 0); + l->addAnchor(b, Qt::AnchorLeft, c, Qt::AnchorLeft); + l->setAnchorSpacing(b, Qt::AnchorLeft, c, Qt::AnchorLeft, 0); + l->addAnchor(c, Qt::AnchorRight, l, Qt::AnchorRight); + l->setAnchorSpacing(c, Qt::AnchorRight, l, Qt::AnchorRight, 0); + + QCOMPARE(l->count(), 3); + + QGraphicsWidget p; + p.setLayout(l); + + QSizeF layoutMinimumSize = l->effectiveSizeHint(Qt::MinimumSize); + QSizeF layoutMaximumSize = l->effectiveSizeHint(Qt::MaximumSize); + QSizeF layoutPreferredSize = l->effectiveSizeHint(Qt::PreferredSize); + + QCOMPARE(layoutMinimumSize, QSizeF(60.0, 300.0)); + QCOMPARE(layoutPreferredSize, QSizeF(120.0, 300.0)); + QCOMPARE(layoutMaximumSize, QSizeF(190.0, 300.0)); + + p.resize(layoutMinimumSize); + QCOMPARE(a->geometry(), QRectF(0.0, 0.0, 50.0, 100.0)); + QCOMPARE(b->geometry(), QRectF(10.0, 100.0, 40.0, 100.0)); + QCOMPARE(c->geometry(), QRectF(10.0, 200.0, 50.0, 100.0)); + QCOMPARE(p.size(), layoutMinimumSize); + + p.resize(layoutPreferredSize); + QCOMPARE(a->geometry(), QRectF(0.0, 0.0, 70.0, 100.0)); + QCOMPARE(b->geometry(), QRectF(50.0, 100.0, 20.0, 100.0)); + QCOMPARE(c->geometry(), QRectF(50.0, 200.0, 70.0, 100.0)); + QCOMPARE(p.size(), layoutPreferredSize); + + p.resize(layoutMaximumSize); + QCOMPARE(a->geometry(), QRectF(0.0, 0.0, 100.0, 100.0)); + QCOMPARE(b->geometry(), QRectF(90.0, 100.0, 10.0, 100.0)); + QCOMPARE(c->geometry(), QRectF(90.0, 200.0, 100.0, 100.0)); + QCOMPARE(p.size(), layoutMaximumSize); +} + +void tst_QGraphicsAnchorLayout::snakeOppositeDirections() +{ + QGraphicsWidget *a = createItem(QSizeF(50.0, 100.0), + QSizeF(70.0, 100.0), + QSizeF(100.0, 100.0), "A"); + + QGraphicsWidget *b = createItem(QSizeF(10.0, 100.0), + QSizeF(20.0, 100.0), + QSizeF(40.0, 100.0), "B"); + + QGraphicsWidget *c = createItem(QSizeF(50.0, 100.0), + QSizeF(70.0, 100.0), + QSizeF(100.0, 100.0), "C"); + + QGraphicsAnchorLayout *l = new QGraphicsAnchorLayout; + l->setContentsMargins(0, 0, 0, 0); + + l->addAnchor(l, Qt::AnchorTop, a, Qt::AnchorTop); + l->setAnchorSpacing(l, Qt::AnchorTop, a, Qt::AnchorTop, 0); + l->addAnchor(a, Qt::AnchorBottom, b, Qt::AnchorTop); + l->setAnchorSpacing(a, Qt::AnchorBottom, b, Qt::AnchorTop, 0); + l->addAnchor(b, Qt::AnchorBottom, c, Qt::AnchorTop); + l->setAnchorSpacing(b, Qt::AnchorBottom, c, Qt::AnchorTop, 0); + l->addAnchor(c, Qt::AnchorBottom, l, Qt::AnchorBottom); + l->setAnchorSpacing(c, Qt::AnchorBottom, l, Qt::AnchorBottom, 0); + + l->addAnchor(l, Qt::AnchorLeft, a, Qt::AnchorLeft); + l->setAnchorSpacing(l, Qt::AnchorLeft, a, Qt::AnchorLeft, 0); + + // Both a and c are 'pointing' to b + l->addAnchor(a, Qt::AnchorRight, b, Qt::AnchorRight); + l->setAnchorSpacing(a, Qt::AnchorRight, b, Qt::AnchorRight, 0); + l->addAnchor(c, Qt::AnchorLeft, b, Qt::AnchorLeft); + l->setAnchorSpacing(c, Qt::AnchorLeft, b, Qt::AnchorLeft, 0); + + l->addAnchor(c, Qt::AnchorRight, l, Qt::AnchorRight); + l->setAnchorSpacing(c, Qt::AnchorRight, l, Qt::AnchorRight, 0); + + QCOMPARE(l->count(), 3); + + QGraphicsWidget p; + p.setLayout(l); + + QSizeF layoutMinimumSize = l->effectiveSizeHint(Qt::MinimumSize); + QSizeF layoutMaximumSize = l->effectiveSizeHint(Qt::MaximumSize); + QSizeF layoutPreferredSize = l->effectiveSizeHint(Qt::PreferredSize); + + QCOMPARE(layoutMinimumSize, QSizeF(60.0, 300.0)); + QCOMPARE(layoutPreferredSize, QSizeF(120.0, 300.0)); + QCOMPARE(layoutMaximumSize, QSizeF(190.0, 300.0)); + + p.resize(layoutMinimumSize); + QCOMPARE(a->geometry(), QRectF(0.0, 0.0, 50.0, 100.0)); + QCOMPARE(b->geometry(), QRectF(10.0, 100.0, 40.0, 100.0)); + QCOMPARE(c->geometry(), QRectF(10.0, 200.0, 50.0, 100.0)); + QCOMPARE(p.size(), layoutMinimumSize); + + p.resize(layoutPreferredSize); + QCOMPARE(a->geometry(), QRectF(0.0, 0.0, 70.0, 100.0)); + QCOMPARE(b->geometry(), QRectF(50.0, 100.0, 20.0, 100.0)); + QCOMPARE(c->geometry(), QRectF(50.0, 200.0, 70.0, 100.0)); + QCOMPARE(p.size(), layoutPreferredSize); + + p.resize(layoutMaximumSize); + QCOMPARE(a->geometry(), QRectF(0.0, 0.0, 100.0, 100.0)); + QCOMPARE(b->geometry(), QRectF(90.0, 100.0, 10.0, 100.0)); + QCOMPARE(c->geometry(), QRectF(90.0, 200.0, 100.0, 100.0)); + QCOMPARE(p.size(), layoutMaximumSize); +} + +void tst_QGraphicsAnchorLayout::fairDistribution() +{ + QGraphicsWidget *a = createItem(QSizeF(10.0, 100.0), + QSizeF(50.0, 100.0), + QSizeF(100.0, 100.0), "A"); + + QGraphicsWidget *b = createItem(QSizeF(10.0, 100.0), + QSizeF(50.0, 100.0), + QSizeF(100.0, 100.0), "B"); + + QGraphicsWidget *c = createItem(QSizeF(10.0, 100.0), + QSizeF(50.0, 100.0), + QSizeF(100.0, 100.0), "C"); + + QGraphicsWidget *d = createItem(QSizeF(60.0, 100.0), + QSizeF(165.0, 100.0), + QSizeF(600.0, 100.0), "D"); + + + QGraphicsAnchorLayout *l = new QGraphicsAnchorLayout; + l->setContentsMargins(0, 0, 0, 0); + + l->addAnchor(l, Qt::AnchorTop, a, Qt::AnchorTop); + l->setAnchorSpacing(l, Qt::AnchorTop, a, Qt::AnchorTop, 0); + l->addAnchor(a, Qt::AnchorBottom, b, Qt::AnchorTop); + l->setAnchorSpacing(a, Qt::AnchorBottom, b, Qt::AnchorTop, 0); + l->addAnchor(b, Qt::AnchorBottom, c, Qt::AnchorTop); + l->setAnchorSpacing(b, Qt::AnchorBottom, c, Qt::AnchorTop, 0); + l->addAnchor(c, Qt::AnchorBottom, d, Qt::AnchorTop); + l->setAnchorSpacing(c, Qt::AnchorBottom, d, Qt::AnchorTop, 0); + l->addAnchor(d, Qt::AnchorBottom, l, Qt::AnchorBottom); + l->setAnchorSpacing(d, Qt::AnchorBottom, l, Qt::AnchorBottom, 0); + + l->addAnchor(l, Qt::AnchorLeft, a, Qt::AnchorLeft); + l->setAnchorSpacing(l, Qt::AnchorLeft, a, Qt::AnchorLeft, 0); + l->addAnchor(a, Qt::AnchorRight, b, Qt::AnchorLeft); + l->setAnchorSpacing(a, Qt::AnchorRight, b, Qt::AnchorLeft, 0); + l->addAnchor(b, Qt::AnchorRight, c, Qt::AnchorLeft); + l->setAnchorSpacing(b, Qt::AnchorRight, c, Qt::AnchorLeft, 0); + l->addAnchor(c, Qt::AnchorRight, l, Qt::AnchorRight); + l->setAnchorSpacing(c, Qt::AnchorRight, l, Qt::AnchorRight, 0); + l->addAnchor(l, Qt::AnchorLeft, d, Qt::AnchorLeft); + l->setAnchorSpacing(l, Qt::AnchorLeft, d, Qt::AnchorLeft, 0); + l->addAnchor(d, Qt::AnchorRight, l, Qt::AnchorRight); + l->setAnchorSpacing(d, Qt::AnchorRight, l, Qt::AnchorRight, 0); + + QCOMPARE(l->count(), 4); + + QGraphicsWidget p; + p.setLayout(l); + + QSizeF layoutMinimumSize = l->effectiveSizeHint(Qt::MinimumSize); + QSizeF layoutMaximumSize = l->effectiveSizeHint(Qt::MaximumSize); + QSizeF layoutPreferredSize = l->effectiveSizeHint(Qt::PreferredSize); + + QCOMPARE(layoutMinimumSize, QSizeF(60.0, 400.0)); + QCOMPARE(layoutPreferredSize, QSizeF(165.0, 400.0)); + QCOMPARE(layoutMaximumSize, QSizeF(300.0, 400.0)); + + p.resize(layoutMinimumSize); + QCOMPARE(a->geometry(), QRectF(0.0, 0.0, 20.0, 100.0)); + QCOMPARE(b->geometry(), QRectF(20.0, 100.0, 20.0, 100.0)); + QCOMPARE(c->geometry(), QRectF(40.0, 200.0, 20.0, 100.0)); + QCOMPARE(d->geometry(), QRectF(0.0, 300.0, 60.0, 100.0)); + QCOMPARE(p.size(), layoutMinimumSize); + + p.resize(layoutPreferredSize); + QCOMPARE(a->geometry(), QRectF(0.0, 0.0, 55.0, 100.0)); + QCOMPARE(b->geometry(), QRectF(55.0, 100.0, 55.0, 100.0)); + QCOMPARE(c->geometry(), QRectF(110.0, 200.0, 55.0, 100.0)); + QCOMPARE(d->geometry(), QRectF(0.0, 300.0, 165.0, 100.0)); + QCOMPARE(p.size(), layoutPreferredSize); + + p.resize(layoutMaximumSize); + QCOMPARE(a->geometry(), QRectF(0.0, 0.0, 100.0, 100.0)); + QCOMPARE(b->geometry(), QRectF(100.0, 100.0, 100.0, 100.0)); + QCOMPARE(c->geometry(), QRectF(200.0, 200.0, 100.0, 100.0)); + QCOMPARE(d->geometry(), QRectF(0.0, 300.0, 300.0, 100.0)); + QCOMPARE(p.size(), layoutMaximumSize); +} + +void tst_QGraphicsAnchorLayout::fairDistributionOppositeDirections() +{ + QGraphicsWidget *a = createItem(QSizeF(10.0, 100.0), + QSizeF(50.0, 100.0), + QSizeF(100.0, 100.0), "A"); + + QGraphicsWidget *b = createItem(QSizeF(10.0, 100.0), + QSizeF(50.0, 100.0), + QSizeF(100.0, 100.0), "B"); + + QGraphicsWidget *c = createItem(QSizeF(10.0, 100.0), + QSizeF(50.0, 100.0), + QSizeF(100.0, 100.0), "C"); + + QGraphicsWidget *d = createItem(QSizeF(10.0, 100.0), + QSizeF(50.0, 100.0), + QSizeF(100.0, 100.0), "D"); + + QGraphicsWidget *e = createItem(QSizeF(60.0, 100.0), + QSizeF(220.0, 100.0), + QSizeF(600.0, 100.0), "E"); + + + QGraphicsAnchorLayout *l = new QGraphicsAnchorLayout; + l->setContentsMargins(0, 0, 0, 0); + + l->addAnchor(l, Qt::AnchorTop, a, Qt::AnchorTop); + l->setAnchorSpacing(l, Qt::AnchorTop, a, Qt::AnchorTop, 0); + l->addAnchor(a, Qt::AnchorBottom, b, Qt::AnchorTop); + l->setAnchorSpacing(a, Qt::AnchorBottom, b, Qt::AnchorTop, 0); + l->addAnchor(b, Qt::AnchorBottom, c, Qt::AnchorTop); + l->setAnchorSpacing(b, Qt::AnchorBottom, c, Qt::AnchorTop, 0); + l->addAnchor(c, Qt::AnchorBottom, d, Qt::AnchorTop); + l->setAnchorSpacing(c, Qt::AnchorBottom, d, Qt::AnchorTop, 0); + l->addAnchor(d, Qt::AnchorBottom, e, Qt::AnchorTop); + l->setAnchorSpacing(d, Qt::AnchorBottom, e, Qt::AnchorTop, 0); + l->addAnchor(e, Qt::AnchorBottom, l, Qt::AnchorBottom); + l->setAnchorSpacing(e, Qt::AnchorBottom, l, Qt::AnchorBottom, 0); + + l->addAnchor(a, Qt::AnchorLeft, l, Qt::AnchorLeft); + l->setAnchorSpacing(a, Qt::AnchorLeft, l, Qt::AnchorLeft, 0); + l->addAnchor(b, Qt::AnchorLeft, a, Qt::AnchorRight); + l->setAnchorSpacing(b, Qt::AnchorLeft, a, Qt::AnchorRight, 0); + l->addAnchor(c, Qt::AnchorLeft, b, Qt::AnchorRight); + l->setAnchorSpacing(c, Qt::AnchorLeft, b, Qt::AnchorRight, 0); + l->addAnchor(d, Qt::AnchorLeft, c, Qt::AnchorRight); + l->setAnchorSpacing(d, Qt::AnchorLeft, c, Qt::AnchorRight, 0); + l->addAnchor(d, Qt::AnchorRight, l, Qt::AnchorRight); + l->setAnchorSpacing(d, Qt::AnchorRight, l, Qt::AnchorRight, 0); + l->addLeftAndRightAnchors(l, e); + + QCOMPARE(l->count(), 5); + + QGraphicsWidget p; + p.setLayout(l); + + QSizeF layoutMinimumSize = l->effectiveSizeHint(Qt::MinimumSize); + QSizeF layoutMaximumSize = l->effectiveSizeHint(Qt::MaximumSize); + QSizeF layoutPreferredSize = l->effectiveSizeHint(Qt::PreferredSize); + + QCOMPARE(layoutMinimumSize, QSizeF(60.0, 500.0)); + QCOMPARE(layoutPreferredSize, QSizeF(220.0, 500.0)); + QCOMPARE(layoutMaximumSize, QSizeF(400.0, 500.0)); + + p.resize(layoutMinimumSize); + QCOMPARE(a->size(), b->size()); + QCOMPARE(a->size(), c->size()); + QCOMPARE(a->size(), d->size()); + QCOMPARE(e->size().width(), 4 * a->size().width()); + QCOMPARE(p.size(), layoutMinimumSize); + + p.resize(layoutPreferredSize); + QCOMPARE(a->size(), b->size()); + QCOMPARE(a->size(), c->size()); + QCOMPARE(a->size(), d->size()); + QCOMPARE(e->size().width(), 4 * a->size().width()); + QCOMPARE(p.size(), layoutPreferredSize); + + p.resize(layoutMaximumSize); + QCOMPARE(a->size(), b->size()); + QCOMPARE(a->size(), c->size()); + QCOMPARE(a->size(), d->size()); + QCOMPARE(e->size().width(), 4 * a->size().width()); + QCOMPARE(p.size(), layoutMaximumSize); +} + +void tst_QGraphicsAnchorLayout::proportionalPreferred() +{ + QSizeF min(0, 100); + + QGraphicsWidget *a = createItem(min, QSizeF(10, 100), QSizeF(20, 100), "A"); + QGraphicsWidget *b = createItem(min, QSizeF(20, 100), QSizeF(30, 100), "B"); + QGraphicsWidget *c = createItem(min, QSizeF(14, 100), QSizeF(20, 100), "C"); + QGraphicsWidget *d = createItem(min, QSizeF(10, 100), QSizeF(20, 100), "D"); + + QGraphicsAnchorLayout *l = new QGraphicsAnchorLayout; + l->setContentsMargins(0, 0, 0, 0); + + l->addAnchor(l, Qt::AnchorTop, a, Qt::AnchorTop); + l->setAnchorSpacing(l, Qt::AnchorTop, a, Qt::AnchorTop, 0); + l->addAnchor(a, Qt::AnchorBottom, b, Qt::AnchorTop); + l->setAnchorSpacing(a, Qt::AnchorBottom, b, Qt::AnchorTop, 0); + l->addAnchor(b, Qt::AnchorBottom, c, Qt::AnchorTop); + l->setAnchorSpacing(b, Qt::AnchorBottom, c, Qt::AnchorTop, 0); + l->addAnchor(c, Qt::AnchorBottom, d, Qt::AnchorTop); + l->setAnchorSpacing(c, Qt::AnchorBottom, d, Qt::AnchorTop, 0); + l->addAnchor(d, Qt::AnchorBottom, l, Qt::AnchorBottom); + l->setAnchorSpacing(d, Qt::AnchorBottom, l, Qt::AnchorBottom, 0); + + l->addAnchor(l, Qt::AnchorLeft, a, Qt::AnchorLeft); + l->setAnchorSpacing(l, Qt::AnchorLeft, a, Qt::AnchorLeft, 0); + l->addAnchor(l, Qt::AnchorLeft, b, Qt::AnchorLeft); + l->setAnchorSpacing(l, Qt::AnchorLeft, b, Qt::AnchorLeft, 0); + l->addAnchor(a, Qt::AnchorRight, c, Qt::AnchorLeft); + l->setAnchorSpacing(a, Qt::AnchorRight, c, Qt::AnchorLeft, 0); + l->addAnchor(a, Qt::AnchorRight, d, Qt::AnchorLeft); + l->setAnchorSpacing(a, Qt::AnchorRight, d, Qt::AnchorLeft, 0); + l->addAnchor(b, Qt::AnchorRight, l, Qt::AnchorRight); + l->setAnchorSpacing(b, Qt::AnchorRight, l, Qt::AnchorRight, 0); + l->addAnchor(c, Qt::AnchorRight, l, Qt::AnchorRight); + l->setAnchorSpacing(c, Qt::AnchorRight, l, Qt::AnchorRight, 0); + l->addAnchor(d, Qt::AnchorRight, l, Qt::AnchorRight); + l->setAnchorSpacing(d, Qt::AnchorRight, l, Qt::AnchorRight, 0); + + QCOMPARE(l->count(), 4); + + QGraphicsWidget p; + p.setLayout(l); + + QSizeF layoutMinimumSize = l->effectiveSizeHint(Qt::MinimumSize); + QSizeF layoutPreferredSize = l->effectiveSizeHint(Qt::PreferredSize); + QSizeF layoutMaximumSize = l->effectiveSizeHint(Qt::MaximumSize); + + QCOMPARE(layoutMinimumSize, QSizeF(0, 400)); + QCOMPARE(layoutPreferredSize, QSizeF(24, 400)); + QCOMPARE(layoutMaximumSize, QSizeF(30, 400)); + + p.resize(layoutMinimumSize); + QCOMPARE(p.size(), layoutMinimumSize); + + p.resize(layoutPreferredSize); + QCOMPARE(c->size().width(), d->size().width()); + QCOMPARE(p.size(), layoutPreferredSize); + + p.resize(layoutMaximumSize); + QCOMPARE(p.size(), layoutMaximumSize); + + p.resize(QSizeF(12, 400)); + + // Proportionality between size given and preferred size, this + // should be respected in this graph for (a) and (b)|(c). + qreal factor = 12.0 / 24.0; + + QCOMPARE(c->size().width(), d->size().width()); + QCOMPARE(a->size().width(), 10 * factor); + QCOMPARE(c->size().width(), 14 * factor); + QCOMPARE(p.size(), QSizeF(12, 400)); +} + +void tst_QGraphicsAnchorLayout::example() +{ + QSizeF min(30, 100); + QSizeF pref(210, 100); + QSizeF max(300, 100); + + QGraphicsWidget *a = createItem(min, pref, max, "A"); + QGraphicsWidget *b = createItem(min, pref, max, "B"); + QGraphicsWidget *c = createItem(min, pref, max, "C"); + QGraphicsWidget *d = createItem(min, pref, max, "D"); + QGraphicsWidget *e = createItem(min, pref, max, "E"); + QGraphicsWidget *f = createItem(QSizeF(30, 50), QSizeF(150, 50), max, "F"); + QGraphicsWidget *g = createItem(QSizeF(30, 50), QSizeF(30, 100), max, "G"); + + QGraphicsAnchorLayout *l = new QGraphicsAnchorLayout; + l->setContentsMargins(0, 0, 0, 0); + + // vertical + l->addAnchor(a, Qt::AnchorTop, l, Qt::AnchorTop); + l->setAnchorSpacing(a, Qt::AnchorTop, l, Qt::AnchorTop, 0); + l->addAnchor(b, Qt::AnchorTop, l, Qt::AnchorTop); + l->setAnchorSpacing(b, Qt::AnchorTop, l, Qt::AnchorTop, 0); + + l->addAnchor(c, Qt::AnchorTop, a, Qt::AnchorBottom); + l->setAnchorSpacing(c, Qt::AnchorTop, a, Qt::AnchorBottom, 0); + l->addAnchor(c, Qt::AnchorTop, b, Qt::AnchorBottom); + l->setAnchorSpacing(c, Qt::AnchorTop, b, Qt::AnchorBottom, 0); + l->addAnchor(c, Qt::AnchorBottom, d, Qt::AnchorTop); + l->setAnchorSpacing(c, Qt::AnchorBottom, d, Qt::AnchorTop, 0); + l->addAnchor(c, Qt::AnchorBottom, e, Qt::AnchorTop); + l->setAnchorSpacing(c, Qt::AnchorBottom, e, Qt::AnchorTop, 0); + + l->addAnchor(d, Qt::AnchorBottom, l, Qt::AnchorBottom); + l->setAnchorSpacing(d, Qt::AnchorBottom, l, Qt::AnchorBottom, 0); + l->addAnchor(e, Qt::AnchorBottom, l, Qt::AnchorBottom); + l->setAnchorSpacing(e, Qt::AnchorBottom, l, Qt::AnchorBottom, 0); + + l->addAnchor(c, Qt::AnchorTop, f, Qt::AnchorTop); + l->setAnchorSpacing(c, Qt::AnchorTop, f, Qt::AnchorTop, 0); + l->addAnchor(c, Qt::AnchorVerticalCenter, f, Qt::AnchorBottom); + l->setAnchorSpacing(c, Qt::AnchorVerticalCenter, f, Qt::AnchorBottom, 0); + l->addAnchor(f, Qt::AnchorBottom, g, Qt::AnchorTop); + l->setAnchorSpacing(f, Qt::AnchorBottom, g, Qt::AnchorTop, 0); + l->addAnchor(c, Qt::AnchorBottom, g, Qt::AnchorBottom); + l->setAnchorSpacing(c, Qt::AnchorBottom, g, Qt::AnchorBottom, 0); + + // horizontal + l->addAnchor(l, Qt::AnchorLeft, a, Qt::AnchorLeft); + l->setAnchorSpacing(l, Qt::AnchorLeft, a, Qt::AnchorLeft, 0); + l->addAnchor(l, Qt::AnchorLeft, d, Qt::AnchorLeft); + l->setAnchorSpacing(l, Qt::AnchorLeft, d, Qt::AnchorLeft, 0); + l->addAnchor(a, Qt::AnchorRight, b, Qt::AnchorLeft); + l->setAnchorSpacing(a, Qt::AnchorRight, b, Qt::AnchorLeft, 0); + + l->addAnchor(a, Qt::AnchorRight, c, Qt::AnchorLeft); + l->setAnchorSpacing(a, Qt::AnchorRight, c, Qt::AnchorLeft, 0); + l->addAnchor(c, Qt::AnchorRight, e, Qt::AnchorLeft); + l->setAnchorSpacing(c, Qt::AnchorRight, e, Qt::AnchorLeft, 0); + + l->addAnchor(b, Qt::AnchorRight, l, Qt::AnchorRight); + l->setAnchorSpacing(b, Qt::AnchorRight, l, Qt::AnchorRight, 0); + l->addAnchor(e, Qt::AnchorRight, l, Qt::AnchorRight); + l->setAnchorSpacing(e, Qt::AnchorRight, l, Qt::AnchorRight, 0); + l->addAnchor(d, Qt::AnchorRight, e, Qt::AnchorLeft); + l->setAnchorSpacing(d, Qt::AnchorRight, e, Qt::AnchorLeft, 0); + + l->addAnchor(l, Qt::AnchorLeft, f, Qt::AnchorLeft); + l->setAnchorSpacing(l, Qt::AnchorLeft, f, Qt::AnchorLeft, 0); + l->addAnchor(l, Qt::AnchorLeft, g, Qt::AnchorLeft); + l->setAnchorSpacing(l, Qt::AnchorLeft, g, Qt::AnchorLeft, 0); + l->addAnchor(f, Qt::AnchorRight, g, Qt::AnchorRight); + l->setAnchorSpacing(f, Qt::AnchorRight, g, Qt::AnchorRight, 0); + + QCOMPARE(l->count(), 7); + + QGraphicsWidget p; + p.setLayout(l); + + QSizeF layoutMinimumSize = l->effectiveSizeHint(Qt::MinimumSize); + QSizeF layoutMaximumSize = l->effectiveSizeHint(Qt::MaximumSize); + QSizeF layoutPreferredSize = l->effectiveSizeHint(Qt::PreferredSize); + + QCOMPARE(layoutMinimumSize, QSizeF(90.0, 300.0)); + QCOMPARE(layoutPreferredSize, QSizeF(510.0, 300.0)); + QCOMPARE(layoutMaximumSize, QSizeF(570.0, 300.0)); + + p.resize(layoutMinimumSize); + QCOMPARE(p.size(), layoutMinimumSize); + QCOMPARE(a->size(), e->size()); + QCOMPARE(b->size(), d->size()); + QCOMPARE(f->size(), g->size()); + + p.resize(layoutPreferredSize); + QCOMPARE(p.size(), layoutPreferredSize); + QCOMPARE(a->size(), e->size()); + QCOMPARE(b->size(), d->size()); + QCOMPARE(f->size(), g->size()); + + p.resize(layoutMaximumSize); + QCOMPARE(p.size(), layoutMaximumSize); + QCOMPARE(a->size(), e->size()); + QCOMPARE(b->size(), d->size()); + QCOMPARE(f->size(), g->size()); +} + +void tst_QGraphicsAnchorLayout::setSpacing() +{ + QSizeF min(10, 10); + QSizeF pref(20, 20); + QSizeF max(50, 50); + + QGraphicsWidget *a = createItem(min, pref, max); + QGraphicsWidget *b = createItem(min, pref, max); + QGraphicsWidget *c = createItem(min, pref, max); + + QGraphicsAnchorLayout *l = new QGraphicsAnchorLayout; + l->addCornerAnchors(l, Qt::TopLeftCorner, a, Qt::TopLeftCorner); + l->addCornerAnchors(b, Qt::TopRightCorner, l, Qt::TopRightCorner); + l->addAnchor(a, Qt::AnchorRight, b, Qt::AnchorLeft); + + l->addLeftAndRightAnchors(l, c); + + l->addAnchor(a, Qt::AnchorBottom, c, Qt::AnchorTop); + l->addAnchor(c, Qt::AnchorBottom, l, Qt::AnchorBottom); + + QGraphicsWidget *p = new QGraphicsWidget(0, Qt::Window); + + p->setLayout(l); + l->setSpacing(1); + + // don't let the style influence the test. + l->setContentsMargins(0, 0, 0, 0); + + QGraphicsScene scene; + scene.addItem(p); + QGraphicsView *view = new QGraphicsView(&scene); + view->show(); + p->show(); + + QApplication::processEvents(); +#ifdef Q_WS_MAC + QTest::qWait(200); +#endif + QCOMPARE(a->geometry(), QRectF(0, 0, 20, 20)); + QCOMPARE(b->geometry(), QRectF(21, 0, 20, 20)); + QCOMPARE(c->geometry(), QRectF(0, 21, 41, 20)); + + l->setHorizontalSpacing(4); + QApplication::processEvents(); + p->adjustSize(); + QCOMPARE(a->geometry(), QRectF(0, 0, 20, 20)); + QCOMPARE(b->geometry(), QRectF(24, 0, 20, 20)); + QCOMPARE(c->geometry(), QRectF(0, 21, 44, 20)); + + l->setVerticalSpacing(0); + QApplication::processEvents(); + p->adjustSize(); + QCOMPARE(a->geometry(), QRectF(0, 0, 20, 20)); + QCOMPARE(b->geometry(), QRectF(24, 0, 20, 20)); + QCOMPARE(c->geometry(), QRectF(0, 20, 44, 20)); + +} + +QTEST_MAIN(tst_QGraphicsAnchorLayout) +#include "tst_qgraphicsanchorlayout.moc" diff --git a/tests/auto/qgraphicseffect/qgraphicseffect.pro b/tests/auto/qgraphicseffect/qgraphicseffect.pro new file mode 100644 index 0000000..7effaca --- /dev/null +++ b/tests/auto/qgraphicseffect/qgraphicseffect.pro @@ -0,0 +1,3 @@ +load(qttest_p4) +SOURCES += tst_qgraphicseffect.cpp + diff --git a/tests/auto/qgraphicseffect/tst_qgraphicseffect.cpp b/tests/auto/qgraphicseffect/tst_qgraphicseffect.cpp new file mode 100644 index 0000000..cdd1b1d --- /dev/null +++ b/tests/auto/qgraphicseffect/tst_qgraphicseffect.cpp @@ -0,0 +1,347 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, 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. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + + +#include <QtTest/QtTest> +#include <QtGui/qgraphicseffect.h> +#include <QtGui/qgraphicsview.h> +#include <QtGui/qgraphicsscene.h> +#include <QtGui/qgraphicsitem.h> +#include <QtGui/qstyleoption.h> + +//TESTED_CLASS= +//TESTED_FILES= + +class tst_QGraphicsEffect : public QObject +{ + Q_OBJECT +public slots: + void initTestCase(); + +private slots: + void setEnabled(); + void source(); + void boundingRectFor(); + void boundingRect(); + void draw(); +}; + +void tst_QGraphicsEffect::initTestCase() +{} + +class CustomItem : public QGraphicsRectItem +{ +public: + CustomItem(qreal x, qreal y, qreal width, qreal height) + : QGraphicsRectItem(x, y, width, height), numRepaints(0), + m_painter(0), m_styleOption(0) + {} + + void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) + { + m_painter = painter; + m_styleOption = option; + ++numRepaints; + QGraphicsRectItem::paint(painter, option, widget); + } + + void reset() + { + numRepaints = 0; + m_painter = 0; + m_styleOption = 0; + } + + int numRepaints; + QPainter *m_painter; + const QStyleOption *m_styleOption; +}; + +class CustomEffect : public QGraphicsEffect +{ +public: + CustomEffect() + : QGraphicsEffect(), numRepaints(0), m_margin(10), + doNothingInDraw(false), m_painter(0), m_styleOption(0), m_source(0) + {} + + QRectF boundingRectFor(const QRectF &rect) const + { return rect.adjusted(-m_margin, -m_margin, m_margin, m_margin); } + + void reset() + { + numRepaints = 0; + m_sourceChangedFlags = QGraphicsEffect::ChangeFlags(); + m_painter = 0; + m_styleOption = 0; + m_source = 0; + } + + void setMargin(int margin) + { + m_margin = margin; + updateBoundingRect(); + } + + int margin() const + { return m_margin; } + + void draw(QPainter *painter, QGraphicsEffectSource *source) + { + ++numRepaints; + if (doNothingInDraw) + return; + m_source = source; + m_painter = painter; + m_styleOption = source->styleOption(); + source->draw(painter); + } + + void sourceChanged(QGraphicsEffect::ChangeFlags flags) + { m_sourceChangedFlags |= flags; } + + int numRepaints; + int m_margin; + QGraphicsEffect::ChangeFlags m_sourceChangedFlags; + bool doNothingInDraw; + QPainter *m_painter; + const QStyleOption *m_styleOption; + QGraphicsEffectSource *m_source; +}; + +void tst_QGraphicsEffect::setEnabled() +{ + CustomEffect effect; + QVERIFY(effect.isEnabled()); + + effect.setEnabled(false); + QVERIFY(!effect.isEnabled()); +} + +void tst_QGraphicsEffect::source() +{ + QPointer<CustomEffect> effect = new CustomEffect; + QVERIFY(!effect->source()); + QVERIFY(!effect->m_sourceChangedFlags); + + // Install effect on QGraphicsItem. + QGraphicsItem *item = new QGraphicsRectItem(0, 0, 10, 10); + item->setGraphicsEffect(effect); + QVERIFY(effect->source()); + QCOMPARE(effect->source()->graphicsItem(), item); + QVERIFY(effect->m_sourceChangedFlags & QGraphicsEffect::SourceAttached); + effect->reset(); + + // Make sure disabling/enabling the effect doesn't change the source. + effect->setEnabled(false); + QVERIFY(effect->source()); + QCOMPARE(effect->source()->graphicsItem(), item); + QVERIFY(!effect->m_sourceChangedFlags); + effect->reset(); + + effect->setEnabled(true); + QVERIFY(effect->source()); + QCOMPARE(effect->source()->graphicsItem(), item); + QVERIFY(!effect->m_sourceChangedFlags); + effect->reset(); + + // Uninstall effect on QGraphicsItem. + effect->reset(); + item->setGraphicsEffect(0); + QVERIFY(!effect->source()); + QVERIFY(effect->m_sourceChangedFlags & QGraphicsEffect::SourceDetached); + + // The item takes ownership and should delete the effect when destroyed. + item->setGraphicsEffect(effect); + QPointer<QGraphicsEffectSource> source = effect->source(); + QVERIFY(source); + QCOMPARE(source->graphicsItem(), item); + delete item; + QVERIFY(!effect); + QVERIFY(!source); +} + +void tst_QGraphicsEffect::boundingRectFor() +{ + CustomEffect effect; + int margin = effect.margin(); + const QRectF source(0, 0, 100, 100); + QCOMPARE(effect.boundingRectFor(source), source.adjusted(-margin, -margin, margin, margin)); + + effect.setMargin(margin = 20); + QCOMPARE(effect.boundingRectFor(source), source.adjusted(-margin, -margin, margin, margin)); +} + +void tst_QGraphicsEffect::boundingRect() +{ + // No source; empty bounding rect. + CustomEffect *effect = new CustomEffect; + QCOMPARE(effect->boundingRect(), QRectF()); + + // Install effect on QGraphicsItem. + QRectF itemRect(0, 0, 100, 100); + QGraphicsRectItem *item = new QGraphicsRectItem; + item->setRect(itemRect); + item->setGraphicsEffect(effect); + int margin = effect->margin(); + QCOMPARE(effect->boundingRect(), itemRect.adjusted(-margin, -margin, margin, margin)); + QCOMPARE(effect->boundingRect(), effect->boundingRectFor(itemRect)); + + // Make sure disabling/enabling the effect doesn't change the bounding rect. + effect->setEnabled(false); + QCOMPARE(effect->boundingRect(), itemRect.adjusted(-margin, -margin, margin, margin)); + QCOMPARE(effect->boundingRect(), effect->boundingRectFor(itemRect)); + effect->setEnabled(true); + QCOMPARE(effect->boundingRect(), itemRect.adjusted(-margin, -margin, margin, margin)); + QCOMPARE(effect->boundingRect(), effect->boundingRectFor(itemRect)); + + // Change effect margins. + effect->setMargin(margin = 20); + QCOMPARE(effect->boundingRect(), itemRect.adjusted(-margin, -margin, margin, margin)); + QCOMPARE(effect->boundingRect(), effect->boundingRectFor(itemRect)); + + // Uninstall effect on QGraphicsItem. + item->setGraphicsEffect(0); + QCOMPARE(effect->boundingRect(), QRectF()); + + delete effect; + delete item; +} + +void tst_QGraphicsEffect::draw() +{ + QGraphicsScene scene; + CustomItem *item = new CustomItem(0, 0, 100, 100); + scene.addItem(item); + + QGraphicsView view(&scene); + view.show(); +#ifdef Q_WS_X11 + qt_x11_wait_for_window_manager(&view); +#endif + QTest::qWait(100); + item->reset(); + + // Make sure installing the effect triggers a repaint. + CustomEffect *effect = new CustomEffect; + item->setGraphicsEffect(effect); + QTest::qWait(50); + QCOMPARE(effect->numRepaints, 1); + QCOMPARE(item->numRepaints, 1); + + // Make sure QPainter* and QStyleOptionGraphicsItem* stays persistent + // during QGraphicsEffect::draw/QGraphicsItem::paint. + QVERIFY(effect->m_painter); + QCOMPARE(effect->m_painter, item->m_painter); + QCOMPARE(effect->m_styleOption, item->m_styleOption); + // Make sure QGraphicsEffect::source is persistent. + QCOMPARE(effect->m_source, effect->source()); + effect->reset(); + item->reset(); + + // Make sure updating the source triggers a repaint. + item->update(); + QTest::qWait(50); + QCOMPARE(effect->numRepaints, 1); + QCOMPARE(item->numRepaints, 1); + QVERIFY(effect->m_sourceChangedFlags & QGraphicsEffect::SourceInvalidated); + effect->reset(); + item->reset(); + + // Make sure changing the effect's bounding rect triggers a repaint. + effect->setMargin(20); + QTest::qWait(50); + QCOMPARE(effect->numRepaints, 1); + QCOMPARE(item->numRepaints, 1); + effect->reset(); + item->reset(); + + // Make sure change the item's bounding rect triggers a repaint. + item->setRect(0, 0, 50, 50); + QTest::qWait(50); + QCOMPARE(effect->numRepaints, 1); + QCOMPARE(item->numRepaints, 1); + QVERIFY(effect->m_sourceChangedFlags & QGraphicsEffect::SourceBoundingRectChanged); + effect->reset(); + item->reset(); + + // Make sure the effect is the one to issue a repaint of the item. + effect->doNothingInDraw = true; + item->update(); + QTest::qWait(50); + QCOMPARE(effect->numRepaints, 1); + QCOMPARE(item->numRepaints, 0); + effect->doNothingInDraw = false; + effect->reset(); + item->reset(); + + // Make sure we update the source when disabling/enabling the effect. + effect->setEnabled(false); + QTest::qWait(50); + QCOMPARE(effect->numRepaints, 0); + QCOMPARE(item->numRepaints, 1); + effect->reset(); + item->reset(); + + effect->setEnabled(true); + QTest::qWait(50); + QCOMPARE(effect->numRepaints, 1); + QCOMPARE(item->numRepaints, 1); + effect->reset(); + item->reset(); + + // Effect is already enabled; nothing should happen. + effect->setEnabled(true); + QTest::qWait(50); + QCOMPARE(effect->numRepaints, 0); + QCOMPARE(item->numRepaints, 0); + + // Make sure uninstalling an effect triggers a repaint. + item->setGraphicsEffect(0); + QTest::qWait(50); + QCOMPARE(effect->numRepaints, 0); + QCOMPARE(item->numRepaints, 1); + delete effect; +} + +QTEST_MAIN(tst_QGraphicsEffect) +#include "tst_qgraphicseffect.moc" + diff --git a/tests/auto/qgraphicseffectsource/qgraphicseffectsource.pro b/tests/auto/qgraphicseffectsource/qgraphicseffectsource.pro new file mode 100644 index 0000000..d506c6d --- /dev/null +++ b/tests/auto/qgraphicseffectsource/qgraphicseffectsource.pro @@ -0,0 +1,3 @@ +load(qttest_p4) +SOURCES += tst_qgraphicseffectsource.cpp + diff --git a/tests/auto/qgraphicseffectsource/tst_qgraphicseffectsource.cpp b/tests/auto/qgraphicseffectsource/tst_qgraphicseffectsource.cpp new file mode 100644 index 0000000..e8af634 --- /dev/null +++ b/tests/auto/qgraphicseffectsource/tst_qgraphicseffectsource.cpp @@ -0,0 +1,323 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, 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. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QtTest/QtTest> +#include <QtGui/qgraphicseffect.h> +#include <QtGui/qgraphicsview.h> +#include <QtGui/qgraphicsscene.h> +#include <QtGui/qgraphicsitem.h> +#include <QtGui/qstyleoption.h> + +//TESTED_CLASS= +//TESTED_FILES= + +class CustomItem : public QGraphicsRectItem +{ +public: + CustomItem(qreal x, qreal y, qreal width, qreal height) + : QGraphicsRectItem(x, y, width, height), numRepaints(0), + m_painter(0), m_styleOption(0) + {} + + void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) + { + m_painter = painter; + m_styleOption = option; + ++numRepaints; + QGraphicsRectItem::paint(painter, option, widget); + } + + void reset() + { + numRepaints = 0; + m_painter = 0; + m_styleOption = 0; + } + + int numRepaints; + QPainter *m_painter; + const QStyleOption *m_styleOption; +}; + +class CustomEffect : public QGraphicsEffect +{ +public: + CustomEffect() + : QGraphicsEffect(), numRepaints(0), m_margin(10), m_sourceChanged(false), + m_sourceBoundingRectChanged(false), doNothingInDraw(false), + storeDeviceDependentStuff(false), + m_painter(0), m_styleOption(0), m_source(0) + {} + + QRectF boundingRectFor(const QRectF &rect) const + { return rect.adjusted(-m_margin, -m_margin, m_margin, m_margin); } + + void reset() + { + numRepaints = 0; + m_sourceChanged = false; + m_sourceBoundingRectChanged = false; + m_painter = 0; + m_styleOption = 0; + m_source = 0; + deviceCoordinatesPixmap = QPixmap(); + deviceRect = QRect(); + sourceDeviceBoundingRect = QRectF(); + } + + void setMargin(int margin) + { + m_margin = margin; + updateBoundingRect(); + } + + int margin() const + { return m_margin; } + + void draw(QPainter *painter, QGraphicsEffectSource *source) + { + ++numRepaints; + if (storeDeviceDependentStuff) { + deviceCoordinatesPixmap = source->pixmap(Qt::DeviceCoordinates); + deviceRect = source->deviceRect(); + sourceDeviceBoundingRect = source->boundingRect(Qt::DeviceCoordinates); + } + if (doNothingInDraw) + return; + m_source = source; + m_painter = painter; + m_styleOption = source->styleOption(); + source->draw(painter); + } + + void sourceChanged() + { m_sourceChanged = true; } + + void sourceBoundingRectChanged() + { m_sourceBoundingRectChanged = true; } + + int numRepaints; + int m_margin; + bool m_sourceChanged; + bool m_sourceBoundingRectChanged; + bool doNothingInDraw; + bool storeDeviceDependentStuff; + QPainter *m_painter; + const QStyleOption *m_styleOption; + QGraphicsEffectSource *m_source; + QPixmap deviceCoordinatesPixmap; + QRect deviceRect; + QRectF sourceDeviceBoundingRect; +}; + +class tst_QGraphicsEffectSource : public QObject +{ + Q_OBJECT +public slots: + void initTestCase(); + void cleanupTestCase(); + void init(); + +private slots: + void graphicsItem(); + void styleOption(); + void isPixmap(); + void draw(); + void update(); + void boundingRect(); + void deviceRect(); + void pixmap(); + +private: + QGraphicsView *view; + QGraphicsScene *scene; + CustomItem *item; + CustomEffect *effect; +}; + +void tst_QGraphicsEffectSource::initTestCase() +{ + scene = new QGraphicsScene; + item = new CustomItem(0, 0, 100, 100); + effect = new CustomEffect; + item->setGraphicsEffect(effect); + scene->addItem(item); + view = new QGraphicsView(scene); + view->show(); +#ifdef Q_WS_X11 + qt_x11_wait_for_window_manager(view); +#endif + QTest::qWait(200); +} + +void tst_QGraphicsEffectSource::cleanupTestCase() +{ + delete view; +} + +void tst_QGraphicsEffectSource::init() +{ + QVERIFY(effect); + QVERIFY(item); + QVERIFY(effect->source()); + effect->reset(); + effect->storeDeviceDependentStuff = false; + effect->doNothingInDraw = false; + item->reset(); +} + +void tst_QGraphicsEffectSource::graphicsItem() +{ + QVERIFY(effect->source()); + QCOMPARE(effect->source()->graphicsItem(), item); +} + +void tst_QGraphicsEffectSource::styleOption() +{ + // We don't have style options unless the source is drawing. + QVERIFY(effect->source()); + QVERIFY(!effect->source()->styleOption()); + + // Trigger an update and check that the style option in QGraphicsEffect::draw + // was the same as the one in QGraphicsItem::paint. + QCOMPARE(item->numRepaints, 0); + QCOMPARE(effect->numRepaints, 0); + item->update(); + QTest::qWait(50); + QCOMPARE(item->numRepaints, 1); + QCOMPARE(effect->numRepaints, 1); + QVERIFY(effect->m_styleOption); + QCOMPARE(effect->m_styleOption, item->m_styleOption); +} + +void tst_QGraphicsEffectSource::isPixmap() +{ + // Current source is a CustomItem (which is not a pixmap item). + QVERIFY(!effect->source()->isPixmap()); + + // Make sure isPixmap() returns true for QGraphicsPixmapItem. + QGraphicsPixmapItem *pixmapItem = new QGraphicsPixmapItem; + CustomEffect *anotherEffect = new CustomEffect; + pixmapItem->setGraphicsEffect(anotherEffect); + QVERIFY(anotherEffect->source()); + QCOMPARE(anotherEffect->source()->graphicsItem(), static_cast<QGraphicsItem *>(pixmapItem)); + QVERIFY(anotherEffect->source()->isPixmap()); + delete pixmapItem; +} + +void tst_QGraphicsEffectSource::draw() +{ + // The source can only draw as a result of QGraphicsEffect::draw. + QTest::ignoreMessage(QtWarningMsg, "QGraphicsEffectSource::draw: Can only begin as a result of QGraphicsEffect::draw"); + QPixmap dummyPixmap(10, 10); + QPainter dummyPainter(&dummyPixmap); + effect->source()->draw(&dummyPainter); +} + +void tst_QGraphicsEffectSource::update() +{ + QCOMPARE(item->numRepaints, 0); + QCOMPARE(effect->numRepaints, 0); + + effect->source()->update(); + QTest::qWait(50); + + QCOMPARE(item->numRepaints, 1); + QCOMPARE(effect->numRepaints, 1); +} + +void tst_QGraphicsEffectSource::boundingRect() +{ + QTest::ignoreMessage(QtWarningMsg, "QGraphicsEffectSource::boundingRect: Not yet implemented, lacking device context"); + QCOMPARE(effect->source()->boundingRect(Qt::DeviceCoordinates), QRectF()); + + QRectF itemBoundingRect = item->boundingRect(); + if (!item->children().isEmpty()) + itemBoundingRect |= item->childrenBoundingRect(); + + // We can at least check that the device bounding rect was correct in QGraphicsEffect::draw. + effect->storeDeviceDependentStuff = true; + effect->source()->update(); + QTest::qWait(50); + const QTransform deviceTransform = item->deviceTransform(view->viewportTransform()); + QCOMPARE(effect->sourceDeviceBoundingRect, deviceTransform.mapRect(itemBoundingRect)); + + // Bounding rect in logical coordinates is of course fine. + QCOMPARE(effect->source()->boundingRect(Qt::LogicalCoordinates), itemBoundingRect); + // Make sure default value is Qt::LogicalCoordinates. + QCOMPARE(effect->source()->boundingRect(), itemBoundingRect); +} + +void tst_QGraphicsEffectSource::deviceRect() +{ + QTest::ignoreMessage(QtWarningMsg, "QGraphicsEffectSource::deviceRect: Not yet implemented, lacking device context"); + QCOMPARE(effect->source()->deviceRect(), QRect()); + + // We can at least check that the rect was correct in QGraphicsEffect::draw. + effect->storeDeviceDependentStuff = true; + effect->source()->update(); + QTest::qWait(50); + QCOMPARE(effect->deviceRect, view->viewport()->rect()); +} + +void tst_QGraphicsEffectSource::pixmap() +{ + QTest::ignoreMessage(QtWarningMsg, "QGraphicsEffectSource::pixmap: Not yet implemented, lacking device context"); + QCOMPARE(effect->source()->pixmap(Qt::DeviceCoordinates), QPixmap()); + + // We can at least verify a valid pixmap from QGraphicsEffect::draw. + effect->storeDeviceDependentStuff = true; + effect->source()->update(); + QTest::qWait(50); + QVERIFY(!effect->deviceCoordinatesPixmap.isNull()); + + // Pixmaps in logical coordinates we can do fine. + QPixmap pixmap1 = effect->source()->pixmap(Qt::LogicalCoordinates); + QVERIFY(!pixmap1.isNull()); + + // Make sure default value is Qt::LogicalCoordinates. + QPixmap pixmap2 = effect->source()->pixmap(); + QCOMPARE(pixmap1, pixmap2); +} + +QTEST_MAIN(tst_QGraphicsEffectSource) +#include "tst_qgraphicseffectsource.moc" + diff --git a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp index 10f0e42..e9154d4 100644 --- a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp +++ b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp @@ -58,6 +58,7 @@ #include <QPainter> #include <QScrollBar> #include <QVBoxLayout> +#include <QGraphicsEffect> //TESTED_CLASS= //TESTED_FILES= @@ -160,6 +161,7 @@ public slots: void init(); private slots: + void explicitDeleteAutoFocusProxy(); void construction(); void constructionWithParent(); void destruction(); @@ -216,6 +218,7 @@ private slots: void childrenBoundingRect(); void childrenBoundingRectTransformed(); void childrenBoundingRect2(); + void childrenBoundingRect3(); void group(); void setGroup(); void nestedGroups(); @@ -276,12 +279,14 @@ private slots: void sorting(); void itemHasNoContents(); void hitTestUntransformableItem(); + void hitTestGraphicsEffectItem(); void focusProxy(); void autoDetectFocusProxy(); void subFocus(); void reverseCreateAutoFocusProxy(); void focusProxyDeletion(); void negativeZStacksBehindParent(); + void setGraphicsEffect(); // task specific tests below me void task141694_textItemEnsureVisible(); @@ -598,7 +603,7 @@ void tst_QGraphicsItem::destruction() child->setParentItem(parent); parent->setVisible(false); scene->addItem(parent); - QCOMPARE(child->parentItem(), parent); + QCOMPARE(child->parentItem(), static_cast<QGraphicsItem*>(parent)); delete scene; QCOMPARE(itemDeleted, 110); } @@ -3085,6 +3090,39 @@ void tst_QGraphicsItem::childrenBoundingRect2() QCOMPARE(box.childrenBoundingRect(), QRectF(0, 0, 100, 100)); } +void tst_QGraphicsItem::childrenBoundingRect3() +{ + QGraphicsScene scene; + + QGraphicsRectItem *rect = scene.addRect(QRectF(0, 0, 100, 100)); + QGraphicsRectItem *rect2 = scene.addRect(QRectF(0, 0, 100, 100)); + QGraphicsRectItem *rect3 = scene.addRect(QRectF(0, 0, 100, 100)); + QGraphicsRectItem *rect4 = scene.addRect(QRectF(0, 0, 100, 100)); + QGraphicsRectItem *rect5 = scene.addRect(QRectF(0, 0, 100, 100)); + rect2->setParentItem(rect); + rect3->setParentItem(rect2); + rect4->setParentItem(rect3); + rect5->setParentItem(rect4); + + rect2->setTransform(QTransform().translate(50, 50).rotate(45)); + rect2->setPos(25, 25); + rect3->setTransform(QTransform().translate(50, 50).rotate(45)); + rect3->setPos(25, 25); + rect4->setTransform(QTransform().translate(50, 50).rotate(45)); + rect4->setPos(25, 25); + rect5->setTransform(QTransform().translate(50, 50).rotate(45)); + rect5->setPos(25, 25); + + // Try to mess up the cached bounding rect. + (void)rect2->childrenBoundingRect(); + + QRectF subTreeRect = rect->childrenBoundingRect(); + QCOMPARE(subTreeRect.left(), qreal(-206.0660171779821)); + QCOMPARE(subTreeRect.top(), qreal(75.0)); + QCOMPARE(subTreeRect.width(), qreal(351.7766952966369)); + QCOMPARE(subTreeRect.height(), qreal(251.7766952966369)); +} + void tst_QGraphicsItem::group() { QGraphicsScene scene; @@ -6669,7 +6707,7 @@ public: QGraphicsRectItem::paint(painter, option, widget); painter->drawText(boundingRect(), Qt::AlignCenter, QString("%1x%2\n%3x%4").arg(p.x()).arg(p.y()).arg(sp.x()).arg(sp.y())); } - + protected: void hoverMoveEvent(QGraphicsSceneHoverEvent *event) { @@ -7020,7 +7058,7 @@ void tst_QGraphicsItem::setTransformProperties() QCOMPARE_TRANSFORM(item1->sceneTransform(), item2->sceneTransform()); - QCOMPARE_TRANSFORM(item1->itemTransform(item2), QTransform()); + QCOMPARE_TRANSFORM(item1->itemTransform(item2), QTransform()); QCOMPARE_TRANSFORM(item2->itemTransform(item1), QTransform()); } } @@ -7335,6 +7373,94 @@ void tst_QGraphicsItem::hitTestUntransformableItem() QCOMPARE(items.at(0), static_cast<QGraphicsItem*>(item3)); } +void tst_QGraphicsItem::hitTestGraphicsEffectItem() +{ + QGraphicsScene scene; + scene.setSceneRect(-100, -100, 200, 200); + + QGraphicsView view(&scene); + view.show(); +#ifdef Q_WS_X11 + qt_x11_wait_for_window_manager(&view); +#endif + QTest::qWait(100); + + // Confuse the BSP with dummy items. + QGraphicsRectItem *dummy = new QGraphicsRectItem(0, 0, 20, 20); + dummy->setPos(-100, -100); + scene.addItem(dummy); + for (int i = 0; i < 100; ++i) { + QGraphicsItem *parent = dummy; + dummy = new QGraphicsRectItem(0, 0, 20, 20); + dummy->setPos(-100 + i, -100 + i); + dummy->setParentItem(parent); + } + + const QRectF itemBoundingRect(0, 0, 20, 20); + EventTester *item1 = new EventTester; + item1->br = itemBoundingRect; + item1->setPos(-200, -200); + + EventTester *item2 = new EventTester; + item2->br = itemBoundingRect; + item2->setFlag(QGraphicsItem::ItemIgnoresTransformations); + item2->setParentItem(item1); + item2->setPos(200, 200); + + EventTester *item3 = new EventTester; + item3->br = itemBoundingRect; + item3->setParentItem(item2); + item3->setPos(80, 80); + + scene.addItem(item1); + QTest::qWait(100); + + item1->repaints = 0; + item2->repaints = 0; + item3->repaints = 0; + + // Apply shadow effect to the entire sub-tree. + QGraphicsDropShadowEffect *shadow = new QGraphicsDropShadowEffect; + shadow->setOffset(-20, -20); + item1->setGraphicsEffect(shadow); + QTest::qWait(50); + + // Make sure all items are repainted. + QCOMPARE(item1->repaints, 1); + QCOMPARE(item2->repaints, 1); + QCOMPARE(item3->repaints, 1); + + // Make sure an item doesn't respond to a click on its shadow. + QList<QGraphicsItem *> items = scene.items(QPointF(75, 75)); + QVERIFY(items.isEmpty()); + items = scene.items(QPointF(80, 80)); + QCOMPARE(items.size(), 1); + QCOMPARE(items.at(0), static_cast<EventTester *>(item3)); + + item1->repaints = 0; + item2->repaints = 0; + item3->repaints = 0; + + view.viewport()->update(75, 75, 20, 20); + QTest::qWait(50); + + // item1 is the effect source and must therefore be repainted. + // item2 intersects with the exposed region + // item3 is just another child outside the exposed region + QCOMPARE(item1->repaints, 1); + QCOMPARE(item2->repaints, 1); + QCOMPARE(item3->repaints, 0); + + scene.setItemIndexMethod(QGraphicsScene::NoIndex); + QTest::qWait(100); + + items = scene.items(QPointF(75, 75)); + QVERIFY(items.isEmpty()); + items = scene.items(QPointF(80, 80)); + QCOMPARE(items.size(), 1); + QCOMPARE(items.at(0), static_cast<EventTester *>(item3)); +} + void tst_QGraphicsItem::focusProxy() { QGraphicsScene scene; @@ -7518,6 +7644,29 @@ void tst_QGraphicsItem::reverseCreateAutoFocusProxy() QVERIFY(text2->hasFocus()); } +void tst_QGraphicsItem::explicitDeleteAutoFocusProxy() +{ + QGraphicsTextItem *text = new QGraphicsTextItem; + text->setTextInteractionFlags(Qt::TextEditorInteraction); + text->setFlag(QGraphicsItem::ItemAutoDetectsFocusProxy); + + QGraphicsTextItem *text2 = new QGraphicsTextItem; + text2->setTextInteractionFlags(Qt::TextEditorInteraction); + text2->setFocus(); + QVERIFY(!text2->hasFocus()); + QCOMPARE(text->focusProxy(), (QGraphicsItem *)0); + text2->setParentItem(text); + QCOMPARE(text->focusProxy(), (QGraphicsItem *)text2); + QCOMPARE(text->focusItem(), (QGraphicsItem *)text2); + + QGraphicsScene scene; + scene.addItem(text); + QVERIFY(text2->hasFocus()); + + delete text2; + QCOMPARE(text->focusProxy(), (QGraphicsItem *)0); +} + void tst_QGraphicsItem::focusProxyDeletion() { QGraphicsRectItem *rect = new QGraphicsRectItem; @@ -7584,5 +7733,36 @@ void tst_QGraphicsItem::negativeZStacksBehindParent() QVERIFY(rect.flags() & QGraphicsItem::ItemStacksBehindParent); } +void tst_QGraphicsItem::setGraphicsEffect() +{ + // Check that we don't have any effect by default. + QGraphicsItem *item = new QGraphicsRectItem(0, 0, 10, 10); + QVERIFY(!item->graphicsEffect()); + + // SetGet check. + QPointer<QGraphicsEffect> blurEffect = new QGraphicsBlurEffect; + item->setGraphicsEffect(blurEffect); + QCOMPARE(item->graphicsEffect(), static_cast<QGraphicsEffect *>(blurEffect)); + + // Ensure the existing effect is deleted when setting a new one. + QPointer<QGraphicsEffect> shadowEffect = new QGraphicsDropShadowEffect; + item->setGraphicsEffect(shadowEffect); + QVERIFY(!blurEffect); + QCOMPARE(item->graphicsEffect(), static_cast<QGraphicsEffect *>(shadowEffect)); + blurEffect = new QGraphicsBlurEffect; + + // Ensure the effect is uninstalled when setting it on a new target. + QGraphicsItem *anotherItem = new QGraphicsRectItem(0, 0, 10, 10); + anotherItem->setGraphicsEffect(blurEffect); + item->setGraphicsEffect(blurEffect); + QVERIFY(!anotherItem->graphicsEffect()); + QVERIFY(!shadowEffect); + + // Ensure the existing effect is deleted when deleting the item. + delete item; + QVERIFY(!blurEffect); + delete anotherItem; +} + QTEST_MAIN(tst_QGraphicsItem) #include "tst_qgraphicsitem.moc" diff --git a/tests/auto/qgraphicslayout/tst_qgraphicslayout.cpp b/tests/auto/qgraphicslayout/tst_qgraphicslayout.cpp index 9bb615e..a2fdfd7 100644 --- a/tests/auto/qgraphicslayout/tst_qgraphicslayout.cpp +++ b/tests/auto/qgraphicslayout/tst_qgraphicslayout.cpp @@ -178,7 +178,7 @@ void tst_QGraphicsLayout::automaticReparenting() QCOMPARE(w1->parentItem(), static_cast<QGraphicsItem*>(window)); QCOMPARE(w2->parentItem(), static_cast<QGraphicsItem*>(window)); - // Sublayouts + // Sublayouts QGraphicsLinearLayout *l2 = new QGraphicsLinearLayout(); QGraphicsWidget *w3 = new QGraphicsWidget(); l2->addItem(w3); @@ -212,7 +212,7 @@ void tst_QGraphicsLayout::automaticReparenting() class TestLayout : public QGraphicsLinearLayout { public: - TestLayout(QGraphicsLayoutItem *parent = 0) + TestLayout(QGraphicsLayoutItem *parent = 0) : QGraphicsLinearLayout(parent) { m_count = 0; @@ -224,7 +224,7 @@ class TestLayout : public QGraphicsLinearLayout QGraphicsLinearLayout::setGeometry(rect); } - + int m_count; }; @@ -320,9 +320,9 @@ public: } void setGeometry(const QRectF &geom); - + QSizeF sizeHint(Qt::SizeHint which, const QSizeF & constraint = QSizeF() ) const; - + inline QGraphicsRectItem *rectItem() { return static_cast<QGraphicsRectItem *>(graphicsItem()); } @@ -354,20 +354,20 @@ QSizeF AnimatedLayoutItem::sizeHint(Qt::SizeHint which, const QSizeF &constraint class AnimatedLayout : public QObject, public QGraphicsLinearLayout { Q_OBJECT public: - AnimatedLayout(QGraphicsWidget *widget) : QGraphicsLinearLayout(widget), m_timeline(500, this) + AnimatedLayout(QGraphicsWidget *widget) : QGraphicsLinearLayout(widget), m_timeline(500, this) { connect(&m_timeline, SIGNAL(valueChanged(qreal)), this, SLOT(valueChanged(qreal))); } - + void setGeometry(const QRectF &geom) { fromGeoms.clear(); toGeoms.clear(); for (int i = 0; i < count(); ++i) { fromGeoms << itemAt(i)->geometry(); } - + QGraphicsLinearLayout::setGeometry(geom); - + for (int i = 0; i < count(); ++i) { toGeoms << itemAt(i)->geometry(); } @@ -380,13 +380,13 @@ private slots: QGraphicsLayoutItem *li = itemAt(i); QRectF from = fromGeoms.at(i); QRectF to = toGeoms.at(i); - - QRectF geom(from.topLeft() + (to.topLeft() - from.topLeft()) * value, + + QRectF geom(from.topLeft() + (to.topLeft() - from.topLeft()) * value, from.size() + (to.size() - from.size()) * value); static_cast<QGraphicsRectItem*>(li->graphicsItem())->setRect(geom); } } -private: +private: QTimeLine m_timeline; QVector<QRectF> fromGeoms; QVector<QRectF> toGeoms; @@ -407,7 +407,7 @@ void tst_QGraphicsLayout::alternativeLayoutItems() QGraphicsRectItem *item1 = new QGraphicsRectItem; AnimatedLayoutItem *li1 = new AnimatedLayoutItem(item1); lout->addItem(li1); - + QGraphicsRectItem *item2 = new QGraphicsRectItem; AnimatedLayoutItem *li2 = new AnimatedLayoutItem(item2); lout->addItem(li2); @@ -417,7 +417,7 @@ void tst_QGraphicsLayout::alternativeLayoutItems() lout->addItem(li3); window->setLayout(lout); - + window->setGeometry(0, 0, 99, 99); view.setSceneRect(QRectF(-10, -10, 110, 110)); view.resize(150, 150); @@ -426,11 +426,11 @@ void tst_QGraphicsLayout::alternativeLayoutItems() QApplication::processEvents(); QTest::qWait(750); QApplication::processEvents(); - + QCOMPARE(static_cast<QGraphicsRectItem*>(li1->graphicsItem())->rect(), QRectF( 0, 0, 33, 99)); QCOMPARE(static_cast<QGraphicsRectItem*>(li2->graphicsItem())->rect(), QRectF(33, 0, 33, 99)); QCOMPARE(static_cast<QGraphicsRectItem*>(li3->graphicsItem())->rect(), QRectF(66, 0, 33, 99)); - + lout->setOrientation(Qt::Vertical); QApplication::processEvents(); @@ -439,7 +439,7 @@ void tst_QGraphicsLayout::alternativeLayoutItems() QCOMPARE(static_cast<QGraphicsRectItem*>(li1->graphicsItem())->rect(), QRectF(0, 0, 99, 33)); QCOMPARE(static_cast<QGraphicsRectItem*>(li2->graphicsItem())->rect(), QRectF(0, 33, 99, 33)); QCOMPARE(static_cast<QGraphicsRectItem*>(li3->graphicsItem())->rect(), QRectF(0, 66, 99, 33)); - + } class CustomLayoutItem : public QGraphicsLayoutItem { @@ -451,8 +451,8 @@ public: setOwnedByLayout(true); } - QSizeF sizeHint(Qt::SizeHint which, const QSizeF & constraint = QSizeF() ) const; - + QSizeF sizeHint(Qt::SizeHint which, const QSizeF & constraint = QSizeF() ) const; + ~CustomLayoutItem() { m_destructedSet->insert(this); } @@ -482,8 +482,8 @@ public: m_destructedSet = destructedSet; } - QSizeF sizeHint(Qt::SizeHint which, const QSizeF & constraint = QSizeF() ) const; - + QSizeF sizeHint(Qt::SizeHint which, const QSizeF & constraint = QSizeF() ) const; + void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget * = 0) { const QRect r = option->rect.adjusted(0, 0, -1, -1); @@ -565,7 +565,7 @@ void insertItem(int index, QGraphicsLayoutItem *item) QGraphicsWidget *widget = static_cast<QGraphicsWidget *>(item); updateParentWidget(widget); - + if (index == items.count()) { items.append(item); @@ -613,7 +613,7 @@ void tst_QGraphicsLayout::ownership() CustomLayoutItem *li3 = new CustomLayoutItem(&destructedSet); lay->addItem(li3); destructedSet.clear(); - + delete lay; QSet<QGraphicsLayoutItem*> expected; expected << li1 << li2 << li3; @@ -642,10 +642,10 @@ void tst_QGraphicsLayout::ownership() { QGraphicsWidget *window = new QGraphicsWidget(0, Qt::Window); QGraphicsLinearLayout *lay = new QGraphicsLinearLayout; - + CustomGraphicsWidget *li1 = new CustomGraphicsWidget; lay->addItem(li1); - + QGraphicsLinearLayout *li2 = new QGraphicsLinearLayout; CustomGraphicsWidget *li2_1 = new CustomGraphicsWidget; li2->addItem(li2_1); @@ -654,25 +654,25 @@ void tst_QGraphicsLayout::ownership() CustomGraphicsWidget *li2_3 = new CustomGraphicsWidget; li2->addItem(li2_3); lay->addItem(li2); - + CustomGraphicsWidget *li3 = new CustomGraphicsWidget; lay->addItem(li3); - + window->setLayout(lay); scene.addItem(window); view.resize(500, 200); view.show(); - + for (int i = li2->count(); i > 0; --i) { QCOMPARE(li2->count(), i); delete li2->itemAt(0); } - + for (int i = lay->count(); i > 0; --i) { QCOMPARE(lay->count(), i); delete lay->itemAt(0); } - + delete window; } diff --git a/tests/auto/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp b/tests/auto/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp index 5a1a83a..462dbfa 100644 --- a/tests/auto/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp +++ b/tests/auto/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp @@ -180,6 +180,7 @@ private slots: void comboboxWindowFlags(); void updateAndDelete(); void inputMethod(); + void clickFocus(); }; // Subclass that exposes the protected functions. @@ -3189,7 +3190,7 @@ void tst_QGraphicsProxyWidget::windowFlags() QVERIFY((widget->windowFlags() & widgetWFlags) == widgetWFlags); proxy.setWidget(widget); - + if (resultingProxyFlags == 0) QVERIFY(!proxy.windowFlags()); else @@ -3299,6 +3300,90 @@ void tst_QGraphicsProxyWidget::inputMethod() } } +void tst_QGraphicsProxyWidget::clickFocus() +{ + QGraphicsScene scene; + scene.setItemIndexMethod(QGraphicsScene::NoIndex); + QGraphicsProxyWidget *proxy = scene.addWidget(new QLineEdit); + + EventSpy proxySpy(proxy); + EventSpy widgetSpy(proxy->widget()); + + QGraphicsView view(&scene); + view.setFrameStyle(0); + view.resize(300, 300); + view.show(); +#ifdef Q_WS_X11 + qt_x11_wait_for_window_manager(&view); +#endif + QTest::qWait(250); + + QVERIFY(!proxy->hasFocus()); + QVERIFY(!proxy->widget()->hasFocus()); + + QCOMPARE(proxySpy.counts[QEvent::FocusIn], 0); + QCOMPARE(proxySpy.counts[QEvent::FocusOut], 0); + QCOMPARE(widgetSpy.counts[QEvent::FocusIn], 0); + QCOMPARE(widgetSpy.counts[QEvent::FocusOut], 0); + + // Spontaneous mouse click sets focus on a clickable widget. + QPointF lineEditCenter = proxy->mapToScene(proxy->boundingRect().center()); + QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, view.mapFromScene(lineEditCenter)); + QVERIFY(proxy->hasFocus()); + QVERIFY(proxy->widget()->hasFocus()); + QCOMPARE(proxySpy.counts[QEvent::FocusIn], 1); + QCOMPARE(widgetSpy.counts[QEvent::FocusIn], 1); + + scene.setFocusItem(0); + QVERIFY(!proxy->hasFocus()); + QVERIFY(!proxy->widget()->hasFocus()); + QCOMPARE(proxySpy.counts[QEvent::FocusOut], 1); + QCOMPARE(widgetSpy.counts[QEvent::FocusOut], 1); + + // Non-spontaneous mouse click sets focus if the widget has been clicked before + { + QGraphicsSceneMouseEvent event(QEvent::GraphicsSceneMousePress); + event.setScenePos(lineEditCenter); + event.setButton(Qt::LeftButton); + qApp->sendEvent(&scene, &event); + QVERIFY(proxy->hasFocus()); + QVERIFY(proxy->widget()->hasFocus()); + QCOMPARE(proxySpy.counts[QEvent::FocusIn], 2); + QCOMPARE(widgetSpy.counts[QEvent::FocusIn], 2); + } + + scene.setFocusItem(0); + proxy->setWidget(new QLineEdit); // resets focusWidget + QVERIFY(!proxy->hasFocus()); + QVERIFY(!proxy->widget()->hasFocus()); + QCOMPARE(proxySpy.counts[QEvent::FocusOut], 2); + QCOMPARE(widgetSpy.counts[QEvent::FocusOut], 2); + + // Non-spontaneous mouse click does not set focus on the embedded widget. + { + QGraphicsSceneMouseEvent event(QEvent::GraphicsSceneMousePress); + event.setScenePos(lineEditCenter); + event.setButton(Qt::LeftButton); + qApp->sendEvent(&scene, &event); + QVERIFY(!proxy->hasFocus()); + QVERIFY(!proxy->widget()->hasFocus()); + QCOMPARE(proxySpy.counts[QEvent::FocusIn], 2); + QCOMPARE(widgetSpy.counts[QEvent::FocusIn], 2); + } + + scene.setFocusItem(0); + QVERIFY(!proxy->hasFocus()); + QVERIFY(!proxy->widget()->hasFocus()); + QCOMPARE(proxySpy.counts[QEvent::FocusOut], 2); + QCOMPARE(widgetSpy.counts[QEvent::FocusOut], 2); + + // Spontaneous click on non-clickable widget does not give focus. + proxy->widget()->setFocusPolicy(Qt::NoFocus); + QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, view.mapFromScene(lineEditCenter)); + QVERIFY(!proxy->hasFocus()); + QVERIFY(!proxy->widget()->hasFocus()); +} + QTEST_MAIN(tst_QGraphicsProxyWidget) #include "tst_qgraphicsproxywidget.moc" diff --git a/tests/auto/qgraphicsscene/qgraphicsscene.pro b/tests/auto/qgraphicsscene/qgraphicsscene.pro index b8a5c8f..31bb769 100644 --- a/tests/auto/qgraphicsscene/qgraphicsscene.pro +++ b/tests/auto/qgraphicsscene/qgraphicsscene.pro @@ -3,15 +3,18 @@ SOURCES += tst_qgraphicsscene.cpp RESOURCES += images.qrc win32:!wince*: LIBS += -lUser32 -!wince*:DEFINES += SRCDIR=\\\"$$PWD\\\" +!wince*:!symbian:DEFINES += SRCDIR=\\\"$$PWD\\\" DEFINES += QT_NO_CAST_TO_ASCII -wince*: { - DEFINES += SRCDIR=\\\".\\\" +wince*|symbian*: { rootFiles.sources = Ash_European.jpg graphicsScene_selection.data rootFiles.path = . renderFiles.sources = testData\render\* renderFiles.path = testData\render DEPLOYMENT += rootFiles renderFiles } +wince*:{ + DEFINES += SRCDIR=\\\".\\\" +} +symbian:TARGET.EPOCHEAPSIZE="0x100000 0x1000000 // Min 1Mb, max 16Mb" diff --git a/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp b/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp index 147bb2b..94f215d 100644 --- a/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp +++ b/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp @@ -58,6 +58,12 @@ #define Q_CHECK_PAINTEVENTS #endif +#ifdef Q_OS_SYMBIAN +// In Symbian OS test data is located in applications private dir +// Current path (C:\private\<UID>) contains only ascii chars +#define SRCDIR QDir::currentPath().append("\\").toAscii() +#endif + //TESTED_CLASS= //TESTED_FILES= @@ -228,9 +234,11 @@ private slots: void mouseEventPropagation_focus(); void mouseEventPropagation_doubleclick(); void mouseEventPropagation_mouseMove(); +#ifndef QT_NO_DRAGANDDROP void dragAndDrop_simple(); void dragAndDrop_disabledOrInvisible(); void dragAndDrop_propagate(); +#endif void render_data(); void render(); void contextMenuEvent(); @@ -2232,6 +2240,7 @@ private: } }; +#ifndef QT_NO_DRAGANDDROP void tst_QGraphicsScene::dragAndDrop_simple() { DndTester *item = new DndTester(QRectF(-10, -10, 20, 20)); @@ -2521,6 +2530,7 @@ void tst_QGraphicsScene::dragAndDrop_propagate() QDropEvent dropEvent(QPoint(0, 0), Qt::CopyAction, &mimeData, Qt::LeftButton, 0); QApplication::sendEvent(view.viewport(), &dropEvent); } +#endif void tst_QGraphicsScene::render_data() { diff --git a/tests/auto/qgraphicsview/qgraphicsview.pro b/tests/auto/qgraphicsview/qgraphicsview.pro index 5562f19..5e7e53d 100644 --- a/tests/auto/qgraphicsview/qgraphicsview.pro +++ b/tests/auto/qgraphicsview/qgraphicsview.pro @@ -2,4 +2,4 @@ load(qttest_p4) SOURCES += tst_qgraphicsview.cpp tst_qgraphicsview_2.cpp DEFINES += QT_NO_CAST_TO_ASCII - +symbian:TARGET.EPOCHEAPSIZE = 1000000 10000000 diff --git a/tests/auto/qgraphicsview/tst_qgraphicsview.cpp b/tests/auto/qgraphicsview/tst_qgraphicsview.cpp index 2506e70..505f9a4 100644 --- a/tests/auto/qgraphicsview/tst_qgraphicsview.cpp +++ b/tests/auto/qgraphicsview/tst_qgraphicsview.cpp @@ -1362,7 +1362,7 @@ void tst_QGraphicsView::itemsInRect_cosmeticAdjust() { QFETCH(QRect, updateRect); QFETCH(int, numPaints); - + QGraphicsScene scene(-100, -100, 200, 200); CountPaintItem *rect = new CountPaintItem(QRectF(-50, -50, 100, 100)); scene.addItem(rect); @@ -2288,6 +2288,9 @@ void tst_QGraphicsView::viewportUpdateMode2() void tst_QGraphicsView::acceptDrops() { +#ifdef QT_NO_DRAGANDDROP + QSKIP("Drag'n drop disabled in this build", SkipAll); +#else QGraphicsView view; // Excepted default behavior. @@ -2321,6 +2324,7 @@ void tst_QGraphicsView::acceptDrops() // Switching the view to not accept drops. view.setAcceptDrops(false); QVERIFY(!view.viewport()->acceptDrops()); +#endif } void tst_QGraphicsView::optimizationFlags() @@ -2389,7 +2393,7 @@ void tst_QGraphicsView::optimizationFlags_dontSavePainterState() MessUpPainterItem *parent = new MessUpPainterItem(QRectF(0, 0, 100, 100)); MessUpPainterItem *child = new MessUpPainterItem(QRectF(0, 0, 100, 100)); child->setParentItem(parent); - + QGraphicsScene scene; scene.addItem(parent); @@ -2528,7 +2532,7 @@ void tst_QGraphicsView::scrollBarRanges() QSKIP("No Motif style compiled.", SkipSingle); #endif } else { -#if defined(Q_OS_WINCE) +#if defined(Q_OS_WINCE) || defined(Q_OS_SYMBIAN) view.setStyle(new QWindowsStyle); #elif !defined(QT_NO_STYLE_PLASTIQUE) view.setStyle(new QPlastiqueStyle); @@ -3261,7 +3265,9 @@ void tst_QGraphicsView::mouseTracking() QGraphicsView view(&scene); QGraphicsRectItem *item = new QGraphicsRectItem(10, 10, 10, 10); +#ifndef QT_NO_CURSOR item->setCursor(Qt::CrossCursor); +#endif scene.addItem(item); QVERIFY(view.viewport()->hasMouseTracking()); } @@ -3269,7 +3275,9 @@ void tst_QGraphicsView::mouseTracking() // Adding an item to the scene before the scene is set on the view. QGraphicsScene scene(-10000, -10000, 20000, 20000); QGraphicsRectItem *item = new QGraphicsRectItem(10, 10, 10, 10); +#ifndef QT_NO_CURSOR item->setCursor(Qt::CrossCursor); +#endif scene.addItem(item); QGraphicsView view(&scene); @@ -3284,7 +3292,9 @@ void tst_QGraphicsView::mouseTracking() QGraphicsView view3(&scene); QGraphicsRectItem *item = new QGraphicsRectItem(10, 10, 10, 10); +#ifndef QT_NO_CURSOR item->setCursor(Qt::CrossCursor); +#endif scene.addItem(item); QVERIFY(view1.viewport()->hasMouseTracking()); @@ -3334,7 +3344,7 @@ public: QGraphicsRectItem::paint(painter, option, widget); ++paints; } - + int paints; }; diff --git a/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp b/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp index 6adcdfe..effa876 100644 --- a/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp +++ b/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp @@ -156,6 +156,7 @@ private slots: void windowFlags(); void shortcutsDeletion(); void painterStateProtectionOnWindowFrame(); + void ensureClipping(); // Task fixes void task236127_bspTreeIndexFails(); @@ -2459,6 +2460,87 @@ void tst_QGraphicsWidget::task250119_shortcutContext() scene.removeItem(&w_signal); } +class ClippingAndTransformsScene : public QGraphicsScene +{ +public: + QList<QGraphicsItem *> drawnItems; +protected: + void drawItems(QPainter *painter, int numItems, QGraphicsItem *items[], + const QStyleOptionGraphicsItem options[], QWidget *widget = 0) + { + drawnItems.clear(); + for (int i = 0; i < numItems; ++i) + drawnItems << items[i]; + QGraphicsScene::drawItems(painter, numItems, items, options, widget); + } +}; + +class RectWidget : public QGraphicsWidget +{ +public: + + RectWidget(Qt::GlobalColor color, QGraphicsItem *parent=0) : QGraphicsWidget(parent), mColor(color) {} + + void paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *) + { + painter->setBrush(QBrush(mColor)); + painter->drawRect(boundingRect()); + } + + Qt::GlobalColor mColor; +}; + +class RectItem : public QGraphicsItem +{ +public: + + RectItem(Qt::GlobalColor color, QGraphicsItem *parent=0) : QGraphicsItem(parent), mColor(color) {} + + QRectF boundingRect() const + {return QRectF(10,10,50,50);} + + void paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *) + { + painter->setBrush(QBrush(mColor)); + painter->drawRect(boundingRect()); + } + + Qt::GlobalColor mColor; +}; + +void tst_QGraphicsWidget::ensureClipping() +{ + ClippingAndTransformsScene scene; + scene.setSceneRect(-50, -50, 200, 200); + + //A root that clip children + RectWidget *clipWidget = new RectWidget(Qt::black); + scene.addItem(clipWidget); + + clipWidget->setFlag(QGraphicsItem::ItemClipsChildrenToShape); + + //a child + RectWidget *childWidget = new RectWidget(Qt::red, clipWidget); + clipWidget->setGeometry(QRectF(10, 10, 100, 100)); + childWidget->setGeometry(QRectF(25, 25, 50, 50)); + + //We put a QGraphicsItem to be sure this one is also paint + RectItem *childitem = new RectItem(Qt::blue, clipWidget); + + QGraphicsView view(&scene); + view.show(); +#ifdef Q_WS_X11 + qt_x11_wait_for_window_manager(&view); +#endif + QTest::qWait(250); + + QList<QGraphicsItem *> expected; + expected << clipWidget << childWidget << childitem; + QVERIFY(scene.drawnItems.contains(clipWidget)); + QVERIFY(scene.drawnItems.contains(childWidget)); + QVERIFY(scene.drawnItems.contains(childitem)); +} + QTEST_MAIN(tst_QGraphicsWidget) #include "tst_qgraphicswidget.moc" diff --git a/tests/auto/qgroupbox/tst_qgroupbox.cpp b/tests/auto/qgroupbox/tst_qgroupbox.cpp index 632ffe1..f82fd38 100644 --- a/tests/auto/qgroupbox/tst_qgroupbox.cpp +++ b/tests/auto/qgroupbox/tst_qgroupbox.cpp @@ -119,8 +119,8 @@ void tst_QGroupBox::setCheckable_data() { QTest::addColumn<bool>("checkable"); QTest::addColumn<bool>("expectedCheckable"); - QTest::newRow( "checkable_true" ) << TRUE << TRUE; - QTest::newRow( "checkable_false" ) << FALSE << FALSE; + QTest::newRow( "checkable_true" ) << true << true; + QTest::newRow( "checkable_false" ) << false << false; } void tst_QGroupBox::setChecked_data() @@ -128,9 +128,9 @@ void tst_QGroupBox::setChecked_data() QTest::addColumn<bool>("checkable"); QTest::addColumn<bool>("checked"); QTest::addColumn<bool>("expectedChecked"); - QTest::newRow( "checkable_false_checked_true" ) << FALSE << TRUE << FALSE; - QTest::newRow( "checkable_true_checked_true" ) << TRUE << TRUE << TRUE; - QTest::newRow( "checkable_true_checked_false" ) << TRUE << FALSE << FALSE; + QTest::newRow( "checkable_false_checked_true" ) << false << true << false; + QTest::newRow( "checkable_true_checked_true" ) << true << true << true; + QTest::newRow( "checkable_true_checked_false" ) << true << false << false; } void tst_QGroupBox::setTitle() @@ -173,116 +173,116 @@ void tst_QGroupBox::setChecked() void tst_QGroupBox::enabledPropagation() { QGroupBox *testWidget = new QGroupBox(0); - testWidget->setCheckable(TRUE); - testWidget->setChecked(TRUE); + testWidget->setCheckable(true); + testWidget->setChecked(true); QWidget* childWidget = new QWidget( testWidget ); childWidget->show(); QVERIFY( testWidget->isEnabled() ); QVERIFY( childWidget->isEnabled() ); - testWidget->setEnabled( FALSE ); + testWidget->setEnabled( false ); QVERIFY( !testWidget->isEnabled() ); QVERIFY( !childWidget->isEnabled() ); - testWidget->setDisabled( FALSE ); + testWidget->setDisabled( false ); QVERIFY( testWidget->isEnabled() ); QVERIFY( childWidget->isEnabled() ); QWidget* grandChildWidget = new QWidget( childWidget ); QVERIFY( grandChildWidget->isEnabled() ); - testWidget->setDisabled( TRUE ); + testWidget->setDisabled( true ); QVERIFY( !testWidget->isEnabled() ); QVERIFY( !childWidget->isEnabled() ); QVERIFY( !grandChildWidget->isEnabled() ); - grandChildWidget->setEnabled( FALSE ); - testWidget->setEnabled( TRUE ); + grandChildWidget->setEnabled( false ); + testWidget->setEnabled( true ); QVERIFY( testWidget->isEnabled() ); QVERIFY( childWidget->isEnabled() ); QVERIFY( !grandChildWidget->isEnabled() ); - grandChildWidget->setEnabled( TRUE ); - testWidget->setEnabled( FALSE ); - childWidget->setDisabled( TRUE ); - testWidget->setEnabled( TRUE ); + grandChildWidget->setEnabled( true ); + testWidget->setEnabled( false ); + childWidget->setDisabled( true ); + testWidget->setEnabled( true ); QVERIFY( testWidget->isEnabled() ); QVERIFY( !childWidget->isEnabled() ); QVERIFY( !grandChildWidget->isEnabled() ); // Reset state - testWidget->setEnabled( TRUE ); - childWidget->setEnabled( TRUE ); - grandChildWidget->setEnabled( TRUE ); + testWidget->setEnabled( true ); + childWidget->setEnabled( true ); + grandChildWidget->setEnabled( true ); // Now check when it's disabled - testWidget->setChecked(FALSE); + testWidget->setChecked(false); QVERIFY( testWidget->isEnabled() ); QVERIFY( !childWidget->isEnabled() ); - testWidget->setEnabled( FALSE ); + testWidget->setEnabled( false ); QVERIFY( !testWidget->isEnabled() ); QVERIFY( !childWidget->isEnabled() ); - testWidget->setDisabled( FALSE ); + testWidget->setDisabled( false ); QVERIFY( testWidget->isEnabled() ); QVERIFY( !childWidget->isEnabled() ); QVERIFY( !grandChildWidget->isEnabled() ); - testWidget->setDisabled( TRUE ); + testWidget->setDisabled( true ); QVERIFY( !testWidget->isEnabled() ); QVERIFY( !childWidget->isEnabled() ); QVERIFY( !grandChildWidget->isEnabled() ); - grandChildWidget->setEnabled( FALSE ); - testWidget->setEnabled( TRUE ); + grandChildWidget->setEnabled( false ); + testWidget->setEnabled( true ); QVERIFY( testWidget->isEnabled() ); QVERIFY( !childWidget->isEnabled() ); QVERIFY( !grandChildWidget->isEnabled() ); - grandChildWidget->setEnabled( TRUE ); - testWidget->setEnabled( FALSE ); - childWidget->setDisabled( TRUE ); - testWidget->setEnabled( TRUE ); + grandChildWidget->setEnabled( true ); + testWidget->setEnabled( false ); + childWidget->setDisabled( true ); + testWidget->setEnabled( true ); QVERIFY( testWidget->isEnabled() ); QVERIFY( !childWidget->isEnabled() ); QVERIFY( !grandChildWidget->isEnabled() ); // Reset state - testWidget->setEnabled( TRUE ); - childWidget->setEnabled( TRUE ); - grandChildWidget->setEnabled( TRUE ); + testWidget->setEnabled( true ); + childWidget->setEnabled( true ); + grandChildWidget->setEnabled( true ); // Finally enable it again - testWidget->setChecked(TRUE); + testWidget->setChecked(true); QVERIFY( testWidget->isEnabled() ); QVERIFY( childWidget->isEnabled() ); - testWidget->setEnabled( FALSE ); + testWidget->setEnabled( false ); QVERIFY( !testWidget->isEnabled() ); QVERIFY( !childWidget->isEnabled() ); - testWidget->setDisabled( FALSE ); + testWidget->setDisabled( false ); QVERIFY( testWidget->isEnabled() ); QVERIFY( childWidget->isEnabled() ); QVERIFY( grandChildWidget->isEnabled() ); - testWidget->setDisabled( TRUE ); + testWidget->setDisabled( true ); QVERIFY( !testWidget->isEnabled() ); QVERIFY( !childWidget->isEnabled() ); QVERIFY( !grandChildWidget->isEnabled() ); - grandChildWidget->setEnabled( FALSE ); - testWidget->setEnabled( TRUE ); + grandChildWidget->setEnabled( false ); + testWidget->setEnabled( true ); QVERIFY( testWidget->isEnabled() ); QVERIFY( childWidget->isEnabled() ); QVERIFY( !grandChildWidget->isEnabled() ); - grandChildWidget->setEnabled( TRUE ); - testWidget->setEnabled( FALSE ); - childWidget->setDisabled( TRUE ); - testWidget->setEnabled( TRUE ); + grandChildWidget->setEnabled( true ); + testWidget->setEnabled( false ); + childWidget->setDisabled( true ); + testWidget->setEnabled( true ); QVERIFY( testWidget->isEnabled() ); QVERIFY( !childWidget->isEnabled() ); QVERIFY( !grandChildWidget->isEnabled() ); @@ -467,7 +467,7 @@ void tst_QGroupBox::propagateFocus() box.show(); box.setFocus(); QTest::qWait(250); - QCOMPARE(qApp->focusWidget(), &lineEdit); + QCOMPARE(qApp->focusWidget(), static_cast<QWidget*>(&lineEdit)); } QTEST_MAIN(tst_QGroupBox) diff --git a/tests/auto/qhash/qhash.pro b/tests/auto/qhash/qhash.pro index 1c60fc2..6fedb82 100644 --- a/tests/auto/qhash/qhash.pro +++ b/tests/auto/qhash/qhash.pro @@ -1,7 +1,8 @@ load(qttest_p4) SOURCES += tst_qhash.cpp - - QT = core - +symbian*: { +TARGET.EPOCSTACKSIZE =0x5000 +TARGET.EPOCHEAPSIZE="0x100000 0x1000000 // Min 1Mb, max 16Mb" +} diff --git a/tests/auto/qhash/tst_qhash.cpp b/tests/auto/qhash/tst_qhash.cpp index 8ec6d1d..b5db59d 100644 --- a/tests/auto/qhash/tst_qhash.cpp +++ b/tests/auto/qhash/tst_qhash.cpp @@ -692,7 +692,7 @@ void tst_QHash::operator_eq() QVERIFY(a == b); QVERIFY(!(a != b)); - + a.insert(1,1); b.insert(1,1); QVERIFY(a == b); @@ -714,7 +714,7 @@ void tst_QHash::operator_eq() b.insert(-1, -1); QVERIFY(a != b); - QVERIFY(!(a == b)); + QVERIFY(!(a == b)); } { @@ -760,7 +760,7 @@ void tst_QHash::operator_eq() b.insert("willy", 1); QVERIFY(a != b); QVERIFY(!(a == b)); - } + } } void tst_QHash::compare() @@ -974,7 +974,7 @@ void tst_QHash::rehash_isnt_quadratic() // this test should be incredibly slow if rehash() is quadratic for (int j = 0; j < 5; ++j) { QHash<int, int> testHash; -#if defined(Q_OS_WINCE) +#if defined(Q_OS_WINCE) || defined(Q_OS_SYMBIAN) // mobiles do not have infinite mem... for (int i = 0; i < 50000; ++i) #else for (int i = 0; i < 500000; ++i) diff --git a/tests/auto/qhostinfo/tst_qhostinfo.cpp b/tests/auto/qhostinfo/tst_qhostinfo.cpp index abe49df..1071f0b 100644 --- a/tests/auto/qhostinfo/tst_qhostinfo.cpp +++ b/tests/auto/qhostinfo/tst_qhostinfo.cpp @@ -87,11 +87,14 @@ # endif #endif +#include "../network-settings.h" + //TESTED_CLASS= //TESTED_FILES= const char * const lupinellaIp = "10.3.4.6"; + class tst_QHostInfo : public QObject { Q_OBJECT @@ -160,6 +163,7 @@ void tst_QHostInfo::staticInformation() tst_QHostInfo::tst_QHostInfo() { + Q_SET_DEFAULT_IAP } tst_QHostInfo::~tst_QHostInfo() @@ -212,11 +216,18 @@ void tst_QHostInfo::lookupIPv4_data() QTest::addColumn<QString>("addresses"); QTest::addColumn<int>("err"); +#ifdef Q_OS_SYMBIAN + // Test server lookup + QTest::newRow("lookup_01") << QtNetworkSettings::serverName() << QtNetworkSettings::serverIP().toString() << int(QHostInfo::NoError); + QTest::newRow("literal_ip4") << QtNetworkSettings::serverIP().toString() << QtNetworkSettings::serverIP().toString() << int(QHostInfo::NoError); + QTest::newRow("multiple_ip4") << "multi.dev.troll.no" << "1.2.3.4 1.2.3.5 10.3.3.31" << int(QHostInfo::NoError); +#else QTest::newRow("empty") << "" << "" << int(QHostInfo::HostNotFound); QTest::newRow("single_ip4") << "lupinella.troll.no" << lupinellaIp << int(QHostInfo::NoError); QTest::newRow("multiple_ip4") << "multi.dev.troll.no" << "1.2.3.4 1.2.3.5 10.3.3.31" << int(QHostInfo::NoError); QTest::newRow("literal_ip4") << lupinellaIp << lupinellaIp << int(QHostInfo::NoError); +#endif QTest::newRow("notfound") << "this-name-does-not-exist-hopefully." << "" << int(QHostInfo::HostNotFound); QTest::newRow("idn-ace") << "xn--alqualond-34a.troll.no" << "10.3.3.55" << int(QHostInfo::NoError); @@ -302,7 +313,7 @@ void tst_QHostInfo::reverseLookup_data() // ### Use internal DNS instead. Discussed with Andreas. //QTest::newRow("classical.hexago.com") << QString("2001:5c0:0:2::24") << QStringList(QString("classical.hexago.com")) << 0; - QTest::newRow("www.cisco.com") << QString("198.133.219.25") << QStringList(QString("origin-www.cisco.com")) << 0; + QTest::newRow("origin.cisco.com") << QString("12.159.148.94") << QStringList(QString("origin.cisco.com")) << 0; QTest::newRow("bogus-name") << QString("1::2::3::4") << QStringList() << 1; } @@ -380,10 +391,10 @@ protected: void tst_QHostInfo::threadSafety() { const int nattempts = 5; -#if !defined(Q_OS_WINCE) - const int runs = 100; -#else +#if defined(Q_OS_WINCE) const int runs = 10; +#else + const int runs = 100; #endif LookupThread thr[nattempts]; for (int j = 0; j < runs; ++j) { diff --git a/tests/auto/qhttp/qhttp.pro b/tests/auto/qhttp/qhttp.pro index 9c2f5cb..8678a19 100644 --- a/tests/auto/qhttp/qhttp.pro +++ b/tests/auto/qhttp/qhttp.pro @@ -13,6 +13,14 @@ wince*: { addFiles.path = . DEPLOYMENT = addFiles webFiles cgi DEFINES += SRCDIR=\\\"\\\" +} else:symbian* { + webFiles.sources = webserver/* + webFiles.path = webserver + cgi.sources = webserver/cgi-bin/* + cgi.path = webserver/cgi-bin + addFiles.sources = rfc3252.txt trolltech + addFiles.path = . + DEPLOYMENT = addFiles webFiles cgi } else:vxworks*: { DEFINES += SRCDIR=\\\"\\\" } else { diff --git a/tests/auto/qhttp/tst_qhttp.cpp b/tests/auto/qhttp/tst_qhttp.cpp index 4fcf107..fcc80ab 100644 --- a/tests/auto/qhttp/tst_qhttp.cpp +++ b/tests/auto/qhttp/tst_qhttp.cpp @@ -57,11 +57,20 @@ # include <qsslsocket.h> #endif +#ifndef TEST_QNETWORK_PROXY +#define TEST_QNETWORK_PROXY +#endif #include "../network-settings.h" //TESTED_CLASS= //TESTED_FILES= +#ifdef Q_OS_SYMBIAN +// In Symbian OS test data is located in applications private dir +// And underlying Open C have application private dir in default search path +#define SRCDIR "" +#endif + Q_DECLARE_METATYPE(QHttpResponseHeader) class tst_QHttp : public QObject @@ -140,9 +149,9 @@ private: struct RequestResult { - QHttpRequestHeader req; - QHttpResponseHeader resp; - int success; + QHttpRequestHeader req; + QHttpResponseHeader resp; + int success; }; QMap< int, RequestResult > resultMap; typedef QMap<int,RequestResult>::Iterator ResMapIt; @@ -176,6 +185,7 @@ const int bytesDone_init = -10; tst_QHttp::tst_QHttp() { + Q_SET_DEFAULT_IAP } tst_QHttp::~tst_QHttp() @@ -188,7 +198,9 @@ void tst_QHttp::initTestCase_data() QTest::addColumn<int>("proxyType"); QTest::newRow("WithoutProxy") << false << 0; +#ifdef TEST_QNETWORK_PROXY QTest::newRow("WithSocks5Proxy") << true << int(QNetworkProxy::Socks5Proxy); +#endif } void tst_QHttp::initTestCase() @@ -344,47 +356,47 @@ void tst_QHttp::get() addRequest( QHttpRequestHeader(), http->setHost( host, port ) ); if ( useIODevice ) { - buf.open( QIODevice::WriteOnly ); - getId = http->get( path, &buf ); + buf.open( QIODevice::WriteOnly ); + getId = http->get( path, &buf ); } else { - getId = http->get( path ); + getId = http->get( path ); } addRequest( QHttpRequestHeader(), getId ); QTestEventLoop::instance().enterLoop( 30 ); if ( QTestEventLoop::instance().timeout() ) - QFAIL( "Network operation timed out" ); + QFAIL( "Network operation timed out" ); ResMapIt res = resultMap.find( getId ); QVERIFY( res != resultMap.end() ); if ( res.value().success!=1 && host=="www.ietf.org" ) { - // The nightly tests fail from time to time. In order to make them more - // stable, add some debug output that might help locate the problem (I - // can't reproduce the problem in the non-nightly builds). - qDebug( "Error %d: %s", http->error(), http->errorString().toLatin1().constData() ); + // The nightly tests fail from time to time. In order to make them more + // stable, add some debug output that might help locate the problem (I + // can't reproduce the problem in the non-nightly builds). + qDebug( "Error %d: %s", http->error(), http->errorString().toLatin1().constData() ); } QTEST( res.value().success, "success" ); if ( res.value().success ) { - QTEST( res.value().resp.statusCode(), "statusCode" ); - - QFETCH( QByteArray, res ); - if ( res.count() > 0 ) { - if ( useIODevice ) { - QCOMPARE(buf_ba, res); - if ( bytesDoneRead != bytesDone_init ) - QVERIFY( (int)buf_ba.size() == bytesDoneRead ); - } else { - QCOMPARE(readyRead_ba, res); - if ( bytesDoneRead != bytesDone_init ) - QVERIFY( (int)readyRead_ba.size() == bytesDoneRead ); - } - } - QVERIFY( bytesTotalRead != bytesTotal_init ); - if ( bytesTotalRead > 0 ) - QVERIFY( bytesDoneRead == bytesTotalRead ); + QTEST( res.value().resp.statusCode(), "statusCode" ); + + QFETCH( QByteArray, res ); + if ( res.count() > 0 ) { + if ( useIODevice ) { + QCOMPARE(buf_ba, res); + if ( bytesDoneRead != bytesDone_init ) + QVERIFY( (int)buf_ba.size() == bytesDoneRead ); + } else { + QCOMPARE(readyRead_ba, res); + if ( bytesDoneRead != bytesDone_init ) + QVERIFY( (int)readyRead_ba.size() == bytesDoneRead ); + } + } + QVERIFY( bytesTotalRead != bytesTotal_init ); + if ( bytesTotalRead > 0 ) + QVERIFY( bytesDoneRead == bytesTotalRead ); } else { - QVERIFY( !res.value().resp.isValid() ); + QVERIFY( !res.value().resp.isValid() ); } } @@ -399,19 +411,22 @@ void tst_QHttp::head_data() QTest::newRow( "path_01" ) << QtNetworkSettings::serverName() << 80u << QString("/qtest/rfc3252.txt") << 1 << 200 << 25962u; + QTest::newRow( "path_02" ) << QString("www.ietf.org") << 80u << QString("/rfc/rfc3252.txt") << 1 << 200 << 25962u; QTest::newRow( "uri_01" ) << QtNetworkSettings::serverName() << 80u << QString("http://" + QtNetworkSettings::serverName() + "/qtest/rfc3252.txt") << 1 << 200 << 25962u; + QTest::newRow( "uri_02" ) << QString("www.ietf.org") << 80u - << QString("http://www.ietf.org/rfc/rfc3252.txt") << 1 << 200 << 25962u; + << QString("http://www.ietf.org/rfc/rfc3252.txt") << 1 << 200 << 25962u; QTest::newRow( "fail_01" ) << QString("this-host-will-not-exist.") << 80u - << QString("/qtest/rfc3252.txt") << 0 << 0 << 0u; + << QString("/qtest/rfc3252.txt") << 0 << 0 << 0u; QTest::newRow( "failprot_01" ) << QtNetworkSettings::serverName() << 80u << QString("/t") << 1 << 404 << 0u; + QTest::newRow( "failprot_02" ) << QtNetworkSettings::serverName() << 80u << QString("qtest/rfc3252.txt") << 1 << 400 << 0u; @@ -464,7 +479,7 @@ void tst_QHttp::head() void tst_QHttp::post_data() { - QTest::addColumn<QString>("source"); + QTest::addColumn<QString>("source"); QTest::addColumn<bool>("useIODevice"); QTest::addColumn<bool>("useProxy"); QTest::addColumn<QString>("host"); @@ -505,7 +520,7 @@ void tst_QHttp::post_data() void tst_QHttp::post() { - QFETCH(QString, source); + QFETCH(QString, source); QFETCH(bool, useIODevice); QFETCH(bool, useProxy); QFETCH(QString, host); @@ -543,7 +558,7 @@ void tst_QHttp::post() QTestEventLoop::instance().enterLoop( 30 ); if ( QTestEventLoop::instance().timeout() ) - QFAIL( "Network operation timed out" ); + QFAIL( "Network operation timed out" ); ResMapIt res = resultMap.find(postId); QVERIFY(res != resultMap.end()); @@ -602,7 +617,6 @@ void tst_QHttp::request_data() QTest::newRow("proxy-post-data") << "rfc3252.txt" << false << true << QtNetworkSettings::serverName() << 80 << "POST" << "/qtest/cgi-bin/md5sum.cgi" << md5sum; - // the following test won't work. See task 185996 /* QTest::newRow("proxy-post-device") << "rfc3252.txt" << true << true @@ -667,7 +681,7 @@ void tst_QHttp::request() QTestEventLoop::instance().enterLoop( 30 ); if ( QTestEventLoop::instance().timeout() ) - QFAIL( "Network operation timed out" ); + QFAIL( "Network operation timed out" ); ResMapIt res = resultMap.find(*theId); QVERIFY(res != resultMap.end()); @@ -777,7 +791,7 @@ void tst_QHttp::proxy() QTestEventLoop::instance().enterLoop(30); if (QTestEventLoop::instance().timeout()) - QFAIL("Network operation timed out"); + QFAIL("Network operation timed out"); ResMapIt res = resultMap.find(getId); QVERIFY(res != resultMap.end()); @@ -847,17 +861,17 @@ void tst_QHttp::proxy3() // test QHttp::currentId() and QHttp::currentRequest() #define CURRENTREQUEST_TEST \ { \ - ResMapIt res = resultMap.find( http->currentId() ); \ - QVERIFY( res != resultMap.end() ); \ - if ( http->currentId() == getId ) { \ - QCOMPARE( http->currentRequest().method(), QString("GET") ); \ - } else if ( http->currentId() == headId ) { \ - QCOMPARE( http->currentRequest().method(), QString("HEAD") ); \ + ResMapIt res = resultMap.find( http->currentId() ); \ + QVERIFY( res != resultMap.end() ); \ + if ( http->currentId() == getId ) { \ + QCOMPARE( http->currentRequest().method(), QString("GET") ); \ + } else if ( http->currentId() == headId ) { \ + QCOMPARE( http->currentRequest().method(), QString("HEAD") ); \ } else if ( http->currentId() == postId ) { \ QCOMPARE( http->currentRequest().method(), QString("POST") ); \ - } else { \ - QVERIFY( headerAreEqual( http->currentRequest(), res.value().req ) ); \ - } \ + } else { \ + QVERIFY( headerAreEqual( http->currentRequest(), res.value().req ) ); \ + } \ } void tst_QHttp::requestStarted( int id ) @@ -872,9 +886,9 @@ void tst_QHttp::requestStarted( int id ) QVERIFY( !ids.isEmpty() ); QVERIFY( ids.first() == id ); if ( ids.count() > 1 ) { - QVERIFY( http->hasPendingRequests() ); + QVERIFY( http->hasPendingRequests() ); } else { - QVERIFY( !http->hasPendingRequests() ); + QVERIFY( !http->hasPendingRequests() ); } QVERIFY( http->currentId() == id ); @@ -892,7 +906,7 @@ void tst_QHttp::requestFinished( int id, bool error ) { #if defined( DUMP_SIGNALS ) qDebug( "%d:requestFinished( %d, %d ) -- errorString: '%s'", - http->currentId(), id, (int)error, http->errorString().latin1() ); + http->currentId(), id, (int)error, http->errorString().toAscii().data() ); #endif // make sure that the requestStarted and requestFinished are nested correctly QVERIFY( current_id == id ); @@ -901,17 +915,17 @@ void tst_QHttp::requestFinished( int id, bool error ) QVERIFY( !ids.isEmpty() ); QVERIFY( ids.first() == id ); if ( ids.count() > 1 ) { - QVERIFY( http->hasPendingRequests() ); + QVERIFY( http->hasPendingRequests() ); } else { - QVERIFY( !http->hasPendingRequests() ); + QVERIFY( !http->hasPendingRequests() ); } if ( error ) { - QVERIFY( http->error() != QHttp::NoError ); - ids.clear(); + QVERIFY( http->error() != QHttp::NoError ); + ids.clear(); } else { - QVERIFY( http->error() == QHttp::NoError ); - ids.pop_front(); + QVERIFY( http->error() == QHttp::NoError ); + ids.pop_front(); } QVERIFY( http->currentId() == id ); @@ -922,9 +936,9 @@ void tst_QHttp::requestFinished( int id, bool error ) QVERIFY( res != resultMap.end() ); QVERIFY( res.value().success == -1 ); if ( error ) - res.value().success = 0; + res.value().success = 0; else - res.value().success = 1; + res.value().success = 1; } void tst_QHttp::done( bool error ) @@ -940,11 +954,11 @@ void tst_QHttp::done( bool error ) QVERIFY( done_success == -1 ); if ( error ) { - QVERIFY( http->error() != QHttp::NoError ); - done_success = 0; + QVERIFY( http->error() != QHttp::NoError ); + done_success = 0; } else { - QVERIFY( http->error() == QHttp::NoError ); - done_success = 1; + QVERIFY( http->error() == QHttp::NoError ); + done_success = 1; } QTestEventLoop::instance().exitLoop(); } @@ -956,14 +970,14 @@ void tst_QHttp::stateChanged( int state ) #endif QCOMPARE( http->currentId(), current_id ); if ( ids.count() > 0 ) - CURRENTREQUEST_TEST; + CURRENTREQUEST_TEST; QVERIFY( state != cur_state ); QVERIFY( state == http->state() ); if ( state != QHttp::Unconnected && !connectionWithAuth ) { - // make sure that the states are always emitted in the right order (for - // this, we assume an ordering on the enum values, which they have at - // the moment) + // make sure that the states are always emitted in the right order (for + // this, we assume an ordering on the enum values, which they have at + // the moment) // connections with authentication will possibly reconnect, so ignore them QVERIFY( cur_state < state ); } @@ -980,13 +994,13 @@ void tst_QHttp::stateChanged( int state ) void tst_QHttp::responseHeaderReceived( const QHttpResponseHeader &header ) { #if defined( DUMP_SIGNALS ) - qDebug( "%d: responseHeaderReceived(\n---{\n%s}---)", http->currentId(), header.toString().latin1() ); + qDebug( "%d: responseHeaderReceived(\n---{\n%s}---)", http->currentId(), header.toString().toAscii().data() ); #endif QCOMPARE( http->currentId(), current_id ); if ( ids.count() > 1 ) { - QVERIFY( http->hasPendingRequests() ); + QVERIFY( http->hasPendingRequests() ); } else { - QVERIFY( !http->hasPendingRequests() ); + QVERIFY( !http->hasPendingRequests() ); } CURRENTREQUEST_TEST; @@ -1000,25 +1014,25 @@ void tst_QHttp::readyRead( const QHttpResponseHeader & ) #endif QCOMPARE( http->currentId(), current_id ); if ( ids.count() > 1 ) { - QVERIFY( http->hasPendingRequests() ); + QVERIFY( http->hasPendingRequests() ); } else { - QVERIFY( !http->hasPendingRequests() ); + QVERIFY( !http->hasPendingRequests() ); } QVERIFY( cur_state == http->state() ); CURRENTREQUEST_TEST; if ( QTest::currentTestFunction() != QLatin1String("bytesAvailable") ) { - int oldSize = readyRead_ba.size(); - quint64 bytesAvail = http->bytesAvailable(); - QByteArray ba = http->readAll(); - QVERIFY( (quint64) ba.size() == bytesAvail ); - readyRead_ba.resize( oldSize + ba.size() ); - memcpy( readyRead_ba.data()+oldSize, ba.data(), ba.size() ); - - if ( bytesTotalRead > 0 ) { - QVERIFY( (int)readyRead_ba.size() <= bytesTotalRead ); - } - QVERIFY( (int)readyRead_ba.size() == bytesDoneRead ); + int oldSize = readyRead_ba.size(); + quint64 bytesAvail = http->bytesAvailable(); + QByteArray ba = http->readAll(); + QVERIFY( (quint64) ba.size() == bytesAvail ); + readyRead_ba.resize( oldSize + ba.size() ); + memcpy( readyRead_ba.data()+oldSize, ba.data(), ba.size() ); + + if ( bytesTotalRead > 0 ) { + QVERIFY( (int)readyRead_ba.size() <= bytesTotalRead ); + } + QVERIFY( (int)readyRead_ba.size() == bytesDoneRead ); } } @@ -1029,38 +1043,38 @@ void tst_QHttp::dataSendProgress( int done, int total ) #endif QCOMPARE( http->currentId(), current_id ); if ( ids.count() > 1 ) { - QVERIFY( http->hasPendingRequests() ); + QVERIFY( http->hasPendingRequests() ); } else { - QVERIFY( !http->hasPendingRequests() ); + QVERIFY( !http->hasPendingRequests() ); } QVERIFY( cur_state == http->state() ); CURRENTREQUEST_TEST; if ( bytesTotalSend == bytesTotal_init ) { - bytesTotalSend = total; + bytesTotalSend = total; } else { - QCOMPARE( bytesTotalSend, total ); + QCOMPARE( bytesTotalSend, total ); } QVERIFY( bytesTotalSend != bytesTotal_init ); QVERIFY( bytesDoneSend <= done ); bytesDoneSend = done; if ( bytesTotalSend > 0 ) { - QVERIFY( bytesDoneSend <= bytesTotalSend ); + QVERIFY( bytesDoneSend <= bytesTotalSend ); } if ( QTest::currentTestFunction() == QLatin1String("abort") ) { - // ### it would be nice if we could specify in our testdata when to do - // the abort - if ( done >= total/100000 ) { - if ( ids.count() != 1 ) { - // do abort only once - int tmpId = ids.first(); - ids.clear(); - ids << tmpId; - http->abort(); - } - } + // ### it would be nice if we could specify in our testdata when to do + // the abort + if ( done >= total/100000 ) { + if ( ids.count() != 1 ) { + // do abort only once + int tmpId = ids.first(); + ids.clear(); + ids << tmpId; + http->abort(); + } + } } } @@ -1071,38 +1085,38 @@ void tst_QHttp::dataReadProgress( int done, int total ) #endif QCOMPARE( http->currentId(), current_id ); if ( ids.count() > 1 ) { - QVERIFY( http->hasPendingRequests() ); + QVERIFY( http->hasPendingRequests() ); } else { - QVERIFY( !http->hasPendingRequests() ); + QVERIFY( !http->hasPendingRequests() ); } QVERIFY( cur_state == http->state() ); CURRENTREQUEST_TEST; if ( bytesTotalRead == bytesTotal_init ) - bytesTotalRead = total; + bytesTotalRead = total; else { - QVERIFY( bytesTotalRead == total ); + QVERIFY( bytesTotalRead == total ); } QVERIFY( bytesTotalRead != bytesTotal_init ); QVERIFY( bytesDoneRead <= done ); bytesDoneRead = done; if ( bytesTotalRead > 0 ) { - QVERIFY( bytesDoneRead <= bytesTotalRead ); + QVERIFY( bytesDoneRead <= bytesTotalRead ); } if ( QTest::currentTestFunction() == QLatin1String("abort") ) { - // ### it would be nice if we could specify in our testdata when to do - // the abort - if ( done >= total/100000 ) { - if ( ids.count() != 1 ) { - // do abort only once - int tmpId = ids.first(); - ids.clear(); - ids << tmpId; - http->abort(); - } - } + // ### it would be nice if we could specify in our testdata when to do + // the abort + if ( done >= total/100000 ) { + if ( ids.count() != 1 ) { + // do abort only once + int tmpId = ids.first(); + ids.clear(); + ids << tmpId; + http->abort(); + } + } } } @@ -1111,21 +1125,21 @@ QHttp *tst_QHttp::newHttp(bool withAuth) { QHttp *nHttp = new QHttp( 0 ); connect( nHttp, SIGNAL(requestStarted(int)), - SLOT(requestStarted(int)) ); + SLOT(requestStarted(int)) ); connect( nHttp, SIGNAL(requestFinished(int,bool)), - SLOT(requestFinished(int,bool)) ); + SLOT(requestFinished(int,bool)) ); connect( nHttp, SIGNAL(done(bool)), - SLOT(done(bool)) ); + SLOT(done(bool)) ); connect( nHttp, SIGNAL(stateChanged(int)), - SLOT(stateChanged(int)) ); + SLOT(stateChanged(int)) ); connect( nHttp, SIGNAL(responseHeaderReceived(const QHttpResponseHeader&)), - SLOT(responseHeaderReceived(const QHttpResponseHeader&)) ); + SLOT(responseHeaderReceived(const QHttpResponseHeader&)) ); connect( nHttp, SIGNAL(readyRead(const QHttpResponseHeader&)), - SLOT(readyRead(const QHttpResponseHeader&)) ); + SLOT(readyRead(const QHttpResponseHeader&)) ); connect( nHttp, SIGNAL(dataSendProgress(int,int)), - SLOT(dataSendProgress(int,int)) ); + SLOT(dataSendProgress(int,int)) ); connect( nHttp, SIGNAL(dataReadProgress(int,int)), - SLOT(dataReadProgress(int,int)) ); + SLOT(dataReadProgress(int,int)) ); connectionWithAuth = withAuth; return nHttp; @@ -1143,9 +1157,9 @@ void tst_QHttp::addRequest( QHttpRequestHeader header, int id ) bool tst_QHttp::headerAreEqual( const QHttpHeader &h1, const QHttpHeader &h2 ) { if ( !h1.isValid() ) - return !h2.isValid(); + return !h2.isValid(); if ( !h2.isValid() ) - return !h1.isValid(); + return !h1.isValid(); return h1.toString() == h2.toString(); } @@ -1165,13 +1179,13 @@ void tst_QHttp::reconnect() QTestEventLoop::instance().enterLoop(60); if (QTestEventLoop::instance().timeout()) - QFAIL("Network operation timed out"); + QFAIL("Network operation timed out"); QCOMPARE(reconnect_state_connect_count, 1); QTestEventLoop::instance().enterLoop(60); if (QTestEventLoop::instance().timeout()) - QFAIL("Network operation timed out"); + QFAIL("Network operation timed out"); QCOMPARE(reconnect_state_connect_count, 2); } @@ -1212,12 +1226,12 @@ private slots: socket->write("HTTP/1.1 404 Not found\r\n" "content-length: 4\r\n\r\nabcd"); socket->disconnectFromHost(); - } + }; }; void tst_QHttp::unexpectedRemoteClose() { - QFETCH_GLOBAL(int, proxyType); + QFETCH_GLOBAL(int, proxyType); if (proxyType == QNetworkProxy::Socks5Proxy) { // This test doesn't make sense for SOCKS5 return; @@ -1380,7 +1394,7 @@ void tst_QHttp::cachingProxyAndSsl() void tst_QHttp::emptyBodyInReply() { // Note: if this test starts failing, please verify the date on the file - // returned by Apache on http://fluke.troll.no/ + // returned by Apache on http://netiks.troll.no/ // It is right now hard-coded to the date below QHttp http; http.setHost(QtNetworkSettings::serverName()); @@ -1458,8 +1472,9 @@ void tst_QHttp::connectionClose() // Note: the servers might change too... // // This was added in response to bug 176822 +#ifndef Q_OS_SYMBIAN QSKIP("This test is manual - read comments in the source code", SkipAll); - +#endif QFETCH_GLOBAL(bool, setProxy); if (setProxy) return; diff --git a/tests/auto/qhttpnetworkconnection/qhttpnetworkconnection.pro b/tests/auto/qhttpnetworkconnection/qhttpnetworkconnection.pro index e19d962..5ce3a2d 100644 --- a/tests/auto/qhttpnetworkconnection/qhttpnetworkconnection.pro +++ b/tests/auto/qhttpnetworkconnection/qhttpnetworkconnection.pro @@ -1,6 +1,6 @@ load(qttest_p4) SOURCES += tst_qhttpnetworkconnection.cpp -INCLUDEPATH += $$(QTDIR)/src/3rdparty/zlib +INCLUDEPATH += $$QT_SOURCE_TREE/src/3rdparty/zlib requires(contains(QT_CONFIG,private_tests)) diff --git a/tests/auto/qhttpnetworkconnection/tst_qhttpnetworkconnection.cpp b/tests/auto/qhttpnetworkconnection/tst_qhttpnetworkconnection.cpp index c4c33d5..214ce02 100644 --- a/tests/auto/qhttpnetworkconnection/tst_qhttpnetworkconnection.cpp +++ b/tests/auto/qhttpnetworkconnection/tst_qhttpnetworkconnection.cpp @@ -50,6 +50,10 @@ class tst_QHttpNetworkConnection: public QObject { Q_OBJECT + +public: + tst_QHttpNetworkConnection(); + public Q_SLOTS: void finishedReply(); void finishedWithError(QNetworkReply::NetworkError errorCode, const QString &detail); @@ -104,6 +108,10 @@ private Q_SLOTS: void getMultipleWithPipeliningAndMultiplePriorities(); }; +tst_QHttpNetworkConnection::tst_QHttpNetworkConnection() +{ + Q_SET_DEFAULT_IAP +} void tst_QHttpNetworkConnection::initTestCase() { @@ -203,8 +211,8 @@ void tst_QHttpNetworkConnection::get_data() QTest::newRow("success-internal") << "http://" << QtNetworkSettings::serverName() << "/qtest/rfc3252.txt" << ushort(80) << false << 200 << "OK" << 25962 << 25962; QTest::newRow("success-external") << "http://" << "www.ietf.org" << "/rfc/rfc3252.txt" << ushort(80) << false << 200 << "OK" << 25962 << 25962; - QTest::newRow("failure-path") << "http://" << QtNetworkSettings::serverName() << "/t" << ushort(80) << false << 404 << "Not Found" << -1 << 1023; - QTest::newRow("failure-protocol") << "" << QtNetworkSettings::serverName() << "/qtest/rfc3252.txt" << ushort(80) << false << 400 << "Bad Request" << -1 << 956; + QTest::newRow("failure-path") << "http://" << QtNetworkSettings::serverName() << "/t" << ushort(80) << false << 404 << "Not Found" << -1 << 997 + QtNetworkSettings::serverName().size(); + QTest::newRow("failure-protocol") << "" << QtNetworkSettings::serverName() << "/qtest/rfc3252.txt" << ushort(80) << false << 400 << "Bad Request" << -1 << 930 + QtNetworkSettings::serverName().size(); } void tst_QHttpNetworkConnection::get() @@ -372,7 +380,7 @@ void tst_QHttpNetworkConnection::post_data() QTest::addColumn<int>("downloadSize"); QTest::newRow("success-internal") << "http://" << QtNetworkSettings::serverName() << "/cgi-bin/echo.cgi" << ushort(80) << false << "7 bytes" << 200 << "OK" << 7 << 7; - QTest::newRow("failure-internal") << "http://" << QtNetworkSettings::serverName() << "/t" << ushort(80) << false << "Hello World" << 404 << "Not Found" << -1 << 1023; + QTest::newRow("failure-internal") << "http://" << QtNetworkSettings::serverName() << "/t" << ushort(80) << false << "Hello World" << 404 << "Not Found" << -1 << 997 + QtNetworkSettings::serverName().size(); } void tst_QHttpNetworkConnection::post() @@ -415,7 +423,16 @@ void tst_QHttpNetworkConnection::post() QCOMPARE(reply->statusCode(), statusCode); QCOMPARE(reply->reasonPhrase(), statusString); - QCOMPARE(reply->contentLength(), qint64(contentLength)); + + qint64 cLen = reply->contentLength(); + if (cLen==-1) { + // HTTP 1.1 server may respond with chunked encoding and in that + // case contentLength is not present in reply -> verify that it is the case + QByteArray transferEnc = reply->headerField("Transfer-Encoding"); + QCOMPARE(transferEnc, QByteArray("chunked")); + } else { + QCOMPARE(cLen, qint64(contentLength)); + } stopWatch.start(); QByteArray ba; @@ -429,6 +446,7 @@ void tst_QHttpNetworkConnection::post() QVERIFY(reply->isFinished()); QCOMPARE(ba.size(), downloadSize); + delete reply; } diff --git a/tests/auto/qhttpsocketengine/tst_qhttpsocketengine.cpp b/tests/auto/qhttpsocketengine/tst_qhttpsocketengine.cpp index 7c53013..f920850 100644 --- a/tests/auto/qhttpsocketengine/tst_qhttpsocketengine.cpp +++ b/tests/auto/qhttpsocketengine/tst_qhttpsocketengine.cpp @@ -139,13 +139,14 @@ public slots: tst_QHttpSocketEngine::tst_QHttpSocketEngine() { + Q_SET_DEFAULT_IAP } tst_QHttpSocketEngine::~tst_QHttpSocketEngine() { - } + void tst_QHttpSocketEngine::init() { tmpSocket = 0; @@ -324,8 +325,8 @@ void tst_QHttpSocketEngine::simpleConnectToIMAP() QVERIFY(socketDevice.read(array.data(), array.size()) == available); // Check that the greeting is what we expect it to be - QCOMPARE(array.constData(), - "* OK [CAPABILITY IMAP4 IMAP4rev1 LITERAL+ ID STARTTLS LOGINDISABLED] qt-test-server.qt-test-net Cyrus IMAP4 v2.3.11-Mandriva-RPM-2.3.11-6mdv2008.1 server ready\r\n"); + QCOMPARE(array.constData(), QtNetworkSettings::expectedReplyIMAP().constData()); + // Write a logout message QByteArray array2 = "XXXX LOGOUT\r\n"; @@ -454,7 +455,7 @@ void tst_QHttpSocketEngine::tcpSocketBlockingTest() // Read greeting QVERIFY(socket.waitForReadyRead(5000)); QString s = socket.readLine(); - QCOMPARE(s.toLatin1().constData(), "* OK [CAPABILITY IMAP4 IMAP4rev1 LITERAL+ ID STARTTLS LOGINDISABLED] qt-test-server.qt-test-net Cyrus IMAP4 v2.3.11-Mandriva-RPM-2.3.11-6mdv2008.1 server ready\r\n"); + QCOMPARE(s.toLatin1().constData(), QtNetworkSettings::expectedReplyIMAP().constData()); // Write NOOP QCOMPARE((int) socket.write("1 NOOP\r\n", 8), 8); @@ -529,7 +530,9 @@ void tst_QHttpSocketEngine::tcpSocketNonBlockingTest() // Read greeting QVERIFY(!tcpSocketNonBlocking_data.isEmpty()); QCOMPARE(tcpSocketNonBlocking_data.at(0).toLatin1().constData(), - "* OK [CAPABILITY IMAP4 IMAP4rev1 LITERAL+ ID STARTTLS LOGINDISABLED] qt-test-server.qt-test-net Cyrus IMAP4 v2.3.11-Mandriva-RPM-2.3.11-6mdv2008.1 server ready\r\n"); + QtNetworkSettings::expectedReplyIMAP().constData()); + + tcpSocketNonBlocking_data.clear(); tcpSocketNonBlocking_totalWritten = 0; @@ -648,7 +651,7 @@ void tst_QHttpSocketEngine::downloadBigFile() QTime stopWatch; stopWatch.start(); -#if defined(Q_OS_WINCE) +#if defined(Q_OS_WINCE) || defined(Q_OS_SYMBIAN) QTestEventLoop::instance().enterLoop(240); #else QTestEventLoop::instance().enterLoop(60); @@ -709,8 +712,8 @@ void tst_QHttpSocketEngine::passwordAuth() QVERIFY(socketDevice.read(array.data(), array.size()) == available); // Check that the greeting is what we expect it to be - QCOMPARE(array.constData(), - "* OK [CAPABILITY IMAP4 IMAP4rev1 LITERAL+ ID STARTTLS LOGINDISABLED] qt-test-server.qt-test-net Cyrus IMAP4 v2.3.11-Mandriva-RPM-2.3.11-6mdv2008.1 server ready\r\n"); + QCOMPARE(array.constData(), QtNetworkSettings::expectedReplyIMAP().constData()); + // Write a logout message QByteArray array2 = "XXXX LOGOUT\r\n"; diff --git a/tests/auto/qicoimageformat/qicoimageformat.pro b/tests/auto/qicoimageformat/qicoimageformat.pro index 9a347d7..c0aa4b5 100644 --- a/tests/auto/qicoimageformat/qicoimageformat.pro +++ b/tests/auto/qicoimageformat/qicoimageformat.pro @@ -12,6 +12,14 @@ wince*: { } addPlugins.path = imageformats DEPLOYMENT += addFiles addPlugins +} else:symbian* { + addFiles.sources = icons + addFiles.path = . + addPlugins.sources = qico.dll + addPlugins.path = imageformats + DEPLOYMENT += addFiles addPlugins + TARGET.UID3 = 0xE0340004 + DEFINES += SYMBIAN_SRCDIR_UID=$$lower($$replace(TARGET.UID3,"0x","")) } else { DEFINES += SRCDIR=\\\"$$PWD\\\" } diff --git a/tests/auto/qicoimageformat/tst_qicoimageformat.cpp b/tests/auto/qicoimageformat/tst_qicoimageformat.cpp index 270a0f8..11dbaf1 100644 --- a/tests/auto/qicoimageformat/tst_qicoimageformat.cpp +++ b/tests/auto/qicoimageformat/tst_qicoimageformat.cpp @@ -42,6 +42,12 @@ #include <QtGui> #include <QtCore> +#if defined(Q_OS_SYMBIAN) +# define STRINGIFY(x) #x +# define TOSTRING(x) STRINGIFY(x) +# define SRCDIR "C:/Private/" TOSTRING(SYMBIAN_SRCDIR_UID) "/" +#endif + class tst_QIcoImageFormat : public QObject { Q_OBJECT diff --git a/tests/auto/qicon/qicon.pro b/tests/auto/qicon/qicon.pro index c8d77e8..982bc5a 100644 --- a/tests/auto/qicon/qicon.pro +++ b/tests/auto/qicon/qicon.pro @@ -11,6 +11,13 @@ wince*:{ DEPLOYMENT += addFiles DEPLOYMENT_PLUGIN += qsvg DEFINES += SRCDIR=\\\".\\\" +} else:symbian* { + QT += xml svg + addFiles.sources = *.png *.tga *.svg *.svgz + addFiles.path = . + plugins.sources = qsvgicon.dll + plugins.path = iconengines + DEPLOYMENT += addFiles plugins } else { DEFINES += SRCDIR=\\\"$$PWD\\\" } diff --git a/tests/auto/qicon/tst_qicon.cpp b/tests/auto/qicon/tst_qicon.cpp index add321d..2bb53e3 100644 --- a/tests/auto/qicon/tst_qicon.cpp +++ b/tests/auto/qicon/tst_qicon.cpp @@ -43,6 +43,10 @@ #include <QtTest/QtTest> #include <qicon.h> + +#if defined(Q_OS_SYMBIAN) +#define SRCDIR "." +#endif #include <qiconengine.h> Q_DECLARE_METATYPE(QSize) @@ -125,7 +129,6 @@ void tst_QIcon::actualSize_data() QTest::newRow("resource10") << ":/rect.png" << QSize( 25, 50) << QSize( 20, 40); const QString prefix = QLatin1String(SRCDIR) + QLatin1String("/"); - QTest::newRow("external0") << prefix + "image.png" << QSize(128, 128) << QSize(128, 128); QTest::newRow("external1") << prefix + "image.png" << QSize( 64, 64) << QSize( 64, 64); QTest::newRow("external2") << prefix + "image.png" << QSize( 32, 64) << QSize( 32, 32); @@ -180,7 +183,6 @@ void tst_QIcon::actualSize2_data() void tst_QIcon::actualSize2() { QIcon icon; - const QString prefix = QLatin1String(SRCDIR) + QLatin1String("/"); icon.addPixmap(QPixmap(prefix + "image.png")); @@ -239,7 +241,6 @@ void tst_QIcon::isNull() { QVERIFY(!iconNoFileSuffix.actualSize(QSize(32, 32)).isValid()); const QString prefix = QLatin1String(SRCDIR) + QLatin1String("/"); - // test string constructor with existing file but unsupported format QIcon iconUnsupportedFormat = QIcon(prefix + "image.tga"); QVERIFY(!iconUnsupportedFormat.isNull()); diff --git a/tests/auto/qimage/qimage.pro b/tests/auto/qimage/qimage.pro index f10a488..69d6f0f 100644 --- a/tests/auto/qimage/qimage.pro +++ b/tests/auto/qimage/qimage.pro @@ -6,6 +6,13 @@ wince*: { addImages.path = images DEPLOYMENT += addImages DEFINES += SRCDIR=\\\".\\\" +} else:symbian* { + TARGET.EPOCHEAPSIZE = 0x200000 0x800000 + addImages.sources = images/* + addImages.path = images + imagePlugins.sources = qjpeg.dll qgif.dll qmng.dll qtiff.dll qico.dll + imagePlugins.path = imageformats + DEPLOYMENT += addImages imagePlugins } else { contains(QT_CONFIG, qt3support): QT += qt3support DEFINES += SRCDIR=\\\"$$PWD\\\" diff --git a/tests/auto/qimage/tst_qimage.cpp b/tests/auto/qimage/tst_qimage.cpp index 487ae29..d443e2b 100644 --- a/tests/auto/qimage/tst_qimage.cpp +++ b/tests/auto/qimage/tst_qimage.cpp @@ -51,8 +51,12 @@ #include <qpainter.h> #include <private/qdrawhelper_p.h> + //TESTED_CLASS= //TESTED_FILES= +#if defined(Q_OS_SYMBIAN) +# define SRCDIR "" +#endif Q_DECLARE_METATYPE(QImage::Format) @@ -262,8 +266,11 @@ void tst_QImage::formatHandlersInput_data() { QTest::addColumn<QString>("testFormat"); QTest::addColumn<QString>("testFile"); - + #ifdef Q_OS_SYMBIAN + const QString prefix = QLatin1String(SRCDIR) + "images/"; + #else const QString prefix = QLatin1String(SRCDIR) + "/images/"; + #endif // add a new line here when a file is added QTest::newRow("ICO") << "ICO" << prefix + "image.ico"; @@ -285,7 +292,6 @@ void tst_QImage::formatHandlersInput() { QFETCH(QString, testFormat); QFETCH(QString, testFile); - QList<QByteArray> formats = QImageReader::supportedImageFormats(); // qDebug("Image input formats : %s", formats.join(" | ").latin1()); @@ -297,7 +303,7 @@ void tst_QImage::formatHandlersInput() } } if (formatSupported) { -// qDebug(QImage::imageFormat(testFile)); +// qDebug(QImage::imageFormat(testFile)); QCOMPARE(testFormat.toLatin1().toLower(), QImageReader::imageFormat(testFile)); } else { QString msg = "Format not supported : "; @@ -1469,10 +1475,12 @@ void tst_QImage::smoothScale3() void tst_QImage::smoothScaleBig() { -#ifndef Q_OS_WINCE - int bigValue = 200000; -#else +#if defined(Q_OS_WINCE) + int bigValue = 2000; +#elif defined(Q_OS_SYMBIAN) int bigValue = 2000; +#else + int bigValue = 200000; #endif QImage tall(4, bigValue, QImage::Format_ARGB32); tall.fill(0x0); diff --git a/tests/auto/qimagereader/qimagereader.pro b/tests/auto/qimagereader/qimagereader.pro index 2c9510e..31a9b0f 100644 --- a/tests/auto/qimagereader/qimagereader.pro +++ b/tests/auto/qimagereader/qimagereader.pro @@ -3,7 +3,7 @@ SOURCES += tst_qimagereader.cpp MOC_DIR=tmp QT += network RESOURCES += qimagereader.qrc -DEFINES += SRCDIR=\\\"$$PWD\\\" +!symbian:DEFINES += SRCDIR=\\\"$$PWD\\\" !contains(QT_CONFIG, no-gif):DEFINES += QTEST_HAVE_GIF !contains(QT_CONFIG, no-jpeg):DEFINES += QTEST_HAVE_JPEG @@ -26,3 +26,12 @@ wince*: { DEFINES += SRCDIR=\\\".\\\" } +symbian*: { + images.sources = images + images.path = . + + imagePlugins.sources = qjpeg.dll qgif.dll qmng.dll + imagePlugins.path = imageformats + + DEPLOYMENT += images imagePlugins +} diff --git a/tests/auto/qimagereader/tst_qimagereader.cpp b/tests/auto/qimagereader/tst_qimagereader.cpp index ba3d83e..1d19baa 100644 --- a/tests/auto/qimagereader/tst_qimagereader.cpp +++ b/tests/auto/qimagereader/tst_qimagereader.cpp @@ -55,6 +55,10 @@ #include <QTcpServer> #include <QTimer> +#if defined(Q_OS_SYMBIAN) +# define SRCDIR "." +#endif + typedef QMap<QString, QString> QStringMap; typedef QList<int> QIntList; Q_DECLARE_METATYPE(QImage) @@ -793,7 +797,9 @@ void tst_QImageReader::readFromDevice() { QFETCH(QString, fileName); QFETCH(QByteArray, format); - + #ifdef Q_OS_SYMBIAN + QSKIP("Symbian local sockets are not working", SkipAll); + #endif QImage expectedImage(prefix + fileName, format); QFile file(prefix + fileName); diff --git a/tests/auto/qimagewriter/qimagewriter.pro b/tests/auto/qimagewriter/qimagewriter.pro index e62c1a5..5a2c908 100644 --- a/tests/auto/qimagewriter/qimagewriter.pro +++ b/tests/auto/qimagewriter/qimagewriter.pro @@ -10,6 +10,12 @@ wince*: { addFiles.path = images DEPLOYMENT += addFiles DEFINES += SRCDIR=\\\".\\\" +} else:symbian* { + addFiles.sources = images\*.* + addFiles.path = images + imagePlugins.sources = qjpeg.dll qtiff.dll + imagePlugins.path = imageformats + DEPLOYMENT += addFiles imagePlugins } else { DEFINES += SRCDIR=\\\"$$PWD\\\" -}
\ No newline at end of file +} diff --git a/tests/auto/qimagewriter/tst_qimagewriter.cpp b/tests/auto/qimagewriter/tst_qimagewriter.cpp index 2cd65ce..19d6d0c 100644 --- a/tests/auto/qimagewriter/tst_qimagewriter.cpp +++ b/tests/auto/qimagewriter/tst_qimagewriter.cpp @@ -52,6 +52,9 @@ #include <QPainter> #include <QSet> +#if defined(Q_OS_SYMBIAN) +# define SRCDIR "" +#endif typedef QMap<QString, QString> QStringMap; typedef QList<int> QIntList; Q_DECLARE_METATYPE(QImage) @@ -106,9 +109,11 @@ private slots: void saveToTemporaryFile(); }; - +#ifdef Q_OS_SYMBIAN +static const QLatin1String prefix(SRCDIR "images/"); +#else static const QLatin1String prefix(SRCDIR "/images/"); - +#endif static void initializePadding(QImage *image) { int effectiveBytesPerLine = (image->width() * image->depth() + 7) / 8; @@ -276,7 +281,7 @@ void tst_QImageWriter::writeImage2_data() #if defined QTEST_HAVE_TIFF void tst_QImageWriter::largeTiff() { -#if !defined(Q_OS_WINCE) +#if !defined(Q_OS_WINCE) && !defined(Q_OS_SYMBIAN) QImage img(4096, 2048, QImage::Format_ARGB32); QPainter p(&img); @@ -302,6 +307,8 @@ void tst_QImageWriter::largeTiff() QVERIFY(!img2.isNull()); QCOMPARE(img, img2); +#else + QWARN("not tested on Symbian/WinCE"); #endif } #endif diff --git a/tests/auto/qinputcontext/qinputcontext.pro b/tests/auto/qinputcontext/qinputcontext.pro new file mode 100644 index 0000000..b3ea8c2 --- /dev/null +++ b/tests/auto/qinputcontext/qinputcontext.pro @@ -0,0 +1,2 @@ +load(qttest_p4) +SOURCES += tst_qinputcontext.cpp diff --git a/tests/auto/qinputcontext/tst_qinputcontext.cpp b/tests/auto/qinputcontext/tst_qinputcontext.cpp new file mode 100644 index 0000000..47675e0 --- /dev/null +++ b/tests/auto/qinputcontext/tst_qinputcontext.cpp @@ -0,0 +1,249 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, 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. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QtTest/QtTest> +#include "../../shared/util.h" + +#include <qinputcontext.h> +#include <qlineedit.h> +#include <qplaintextedit.h> +#include <qlayout.h> +#include <qradiobutton.h> +#include <qwindowsstyle.h> + +class tst_QInputContext : public QObject +{ +Q_OBJECT + +public: + tst_QInputContext() {} + virtual ~tst_QInputContext() {} + +public slots: + void initTestCase() {} + void cleanupTestCase() {} + void init() {} + void cleanup() {} +private slots: + void maximumTextLength(); + void filterMouseEvents(); + void requestSoftwareInputPanel(); + void closeSoftwareInputPanel(); + void selections(); +}; + +void tst_QInputContext::maximumTextLength() +{ + QLineEdit le; + + le.setMaxLength(15); + QVariant variant = le.inputMethodQuery(Qt::ImMaximumTextLength); + QVERIFY(variant.isValid()); + QCOMPARE(variant.toInt(), 15); + + QPlainTextEdit pte; + // For BC/historical reasons, QPlainTextEdit::inputMethodQuery is protected. + variant = static_cast<QWidget *>(&pte)->inputMethodQuery(Qt::ImMaximumTextLength); + QVERIFY(!variant.isValid()); +} + +class QFilterInputContext : public QInputContext +{ +public: + QFilterInputContext() {} + ~QFilterInputContext() {} + + QString identifierName() { return QString(); } + QString language() { return QString(); } + + void reset() {} + + bool isComposing() const { return false; } + + bool filterEvent( const QEvent *event ) + { + lastTypes.append(event->type()); + return false; + } + +public: + QList<QEvent::Type> lastTypes; +}; + +void tst_QInputContext::filterMouseEvents() +{ + QLineEdit le; + le.show(); + QApplication::setActiveWindow(&le); + + QFilterInputContext *ic = new QFilterInputContext; + le.setInputContext(ic); + QTest::mouseClick(&le, Qt::LeftButton); + + QVERIFY(ic->lastTypes.indexOf(QEvent::MouseButtonRelease) >= 0); + + le.setInputContext(0); +} + +class RequestSoftwareInputPanelStyle : public QWindowsStyle +{ +public: + RequestSoftwareInputPanelStyle() + : m_rsipBehavior(RSIP_OnMouseClickAndAlreadyFocused) + { + } + ~RequestSoftwareInputPanelStyle() + { + } + + int styleHint(StyleHint hint, const QStyleOption *opt = 0, + const QWidget *widget = 0, QStyleHintReturn* returnData = 0) const + { + if (hint == SH_RequestSoftwareInputPanel) { + return m_rsipBehavior; + } else { + return QWindowsStyle::styleHint(hint, opt, widget, returnData); + } + } + + RequestSoftwareInputPanel m_rsipBehavior; +}; + +void tst_QInputContext::requestSoftwareInputPanel() +{ + QStyle *oldStyle = qApp->style(); + oldStyle->setParent(this); // Prevent it being deleted. + RequestSoftwareInputPanelStyle *newStyle = new RequestSoftwareInputPanelStyle; + qApp->setStyle(newStyle); + + QWidget w; + QLayout *layout = new QVBoxLayout; + QLineEdit *le1, *le2; + le1 = new QLineEdit; + le2 = new QLineEdit; + layout->addWidget(le1); + layout->addWidget(le2); + w.setLayout(layout); + + QFilterInputContext *ic1, *ic2; + ic1 = new QFilterInputContext; + ic2 = new QFilterInputContext; + le1->setInputContext(ic1); + le2->setInputContext(ic2); + + w.show(); + QApplication::setActiveWindow(&w); + + // Testing single click panel activation. + newStyle->m_rsipBehavior = QStyle::RSIP_OnMouseClick; + QTest::mouseClick(le2, Qt::LeftButton, Qt::NoModifier, QPoint(5, 5)); + QVERIFY(ic2->lastTypes.indexOf(QEvent::RequestSoftwareInputPanel) >= 0); + ic2->lastTypes.clear(); + + // Testing double click panel activation. + newStyle->m_rsipBehavior = QStyle::RSIP_OnMouseClickAndAlreadyFocused; + QTest::mouseClick(le1, Qt::LeftButton, Qt::NoModifier, QPoint(5, 5)); + QVERIFY(ic1->lastTypes.indexOf(QEvent::RequestSoftwareInputPanel) < 0); + QTest::mouseClick(le1, Qt::LeftButton, Qt::NoModifier, QPoint(5, 5)); + QVERIFY(ic1->lastTypes.indexOf(QEvent::RequestSoftwareInputPanel) >= 0); + ic1->lastTypes.clear(); + + // Testing right mouse button + QTest::mouseClick(le1, Qt::RightButton, Qt::NoModifier, QPoint(5, 5)); + QVERIFY(ic1->lastTypes.indexOf(QEvent::RequestSoftwareInputPanel) < 0); + + qApp->setStyle(oldStyle); + oldStyle->setParent(qApp); +} + +void tst_QInputContext::closeSoftwareInputPanel() +{ + QWidget w; + QLayout *layout = new QVBoxLayout; + QLineEdit *le1, *le2; + QRadioButton *rb; + le1 = new QLineEdit; + le2 = new QLineEdit; + rb = new QRadioButton; + layout->addWidget(le1); + layout->addWidget(le2); + layout->addWidget(rb); + w.setLayout(layout); + + QFilterInputContext *ic1, *ic2; + ic1 = new QFilterInputContext; + ic2 = new QFilterInputContext; + le1->setInputContext(ic1); + le2->setInputContext(ic2); + + w.show(); + QApplication::setActiveWindow(&w); + + // Testing that panel doesn't close between two input methods aware widgets. + QTest::mouseClick(le1, Qt::LeftButton, Qt::NoModifier, QPoint(5, 5)); + QTest::mouseClick(le2, Qt::LeftButton, Qt::NoModifier, QPoint(5, 5)); + QVERIFY(ic2->lastTypes.indexOf(QEvent::CloseSoftwareInputPanel) < 0); + + // Testing that panel closes when focusing non-aware widget. + QTest::mouseClick(rb, Qt::LeftButton, Qt::NoModifier, QPoint(5, 5)); + QVERIFY(ic2->lastTypes.indexOf(QEvent::CloseSoftwareInputPanel) >= 0); +} + +void tst_QInputContext::selections() +{ + QLineEdit le; + le.setText("Test text"); + le.setSelection(2, 2); + QCOMPARE(le.inputMethodQuery(Qt::ImCursorPosition).toInt(), 4); + QCOMPARE(le.inputMethodQuery(Qt::ImAnchorPosition).toInt(), 2); + + QList<QInputMethodEvent::Attribute> attributes; + attributes.append(QInputMethodEvent::Attribute(QInputMethodEvent::Selection, 5, 3, QVariant())); + QInputMethodEvent event("", attributes); + QApplication::sendEvent(&le, &event); + QCOMPARE(le.cursorPosition(), 8); + QCOMPARE(le.selectionStart(), 5); + QCOMPARE(le.inputMethodQuery(Qt::ImCursorPosition).toInt(), 8); + QCOMPARE(le.inputMethodQuery(Qt::ImAnchorPosition).toInt(), 5); +} + +QTEST_MAIN(tst_QInputContext) +#include "tst_qinputcontext.moc" diff --git a/tests/auto/qiodevice/qiodevice.pro b/tests/auto/qiodevice/qiodevice.pro index e2864e8..e695bf6 100644 --- a/tests/auto/qiodevice/qiodevice.pro +++ b/tests/auto/qiodevice/qiodevice.pro @@ -9,6 +9,11 @@ wince*: { DEPLOYMENT += addFiles DEFINES += SRCDIR=\\\"\\\" !wince50standard-x86-msvc2005: DEFINES += WINCE_EMULATOR_TEST=1 +} else:symbian { + # SRCDIR defined in code in symbian + addFiles.sources = tst_qiodevice.cpp + addFiles.path = . + DEPLOYMENT += addFiles } else { DEFINES += SRCDIR=\\\"$$PWD/\\\" contains(QT_CONFIG, qt3support):QT += qt3support diff --git a/tests/auto/qiodevice/tst_qiodevice.cpp b/tests/auto/qiodevice/tst_qiodevice.cpp index 614247b..aa49854 100644 --- a/tests/auto/qiodevice/tst_qiodevice.cpp +++ b/tests/auto/qiodevice/tst_qiodevice.cpp @@ -49,6 +49,10 @@ //TESTED_CLASS= //TESTED_FILES= +#ifdef Q_OS_SYMBIAN +#define SRCDIR "" +#endif + class tst_QIODevice : public QObject { Q_OBJECT @@ -94,11 +98,11 @@ void tst_QIODevice::getSetCheck() tst_QIODevice::tst_QIODevice() { + Q_SET_DEFAULT_IAP } tst_QIODevice::~tst_QIODevice() { - } void tst_QIODevice::init() @@ -136,6 +140,7 @@ void tst_QIODevice::constructing_QTcpSocket() socket.close(); socket.connectToHost(QtNetworkSettings::serverName(), 143); QVERIFY(socket.waitForConnected(5000)); + QVERIFY(device->isOpen()); while (!device->canReadLine()) QVERIFY(device->waitForReadyRead(5000)); diff --git a/tests/auto/qitemdelegate/tst_qitemdelegate.cpp b/tests/auto/qitemdelegate/tst_qitemdelegate.cpp index 9fc23fb..75d9c8f 100644 --- a/tests/auto/qitemdelegate/tst_qitemdelegate.cpp +++ b/tests/auto/qitemdelegate/tst_qitemdelegate.cpp @@ -1055,23 +1055,31 @@ void tst_QItemDelegate::editorEvent() QCOMPARE(index.data(Qt::CheckStateRole).toInt(), expectedCheckState); } +enum WidgetType +{ + LineEdit, + TextEdit, + PlainTextEdit +}; +Q_DECLARE_METATYPE(WidgetType); + void tst_QItemDelegate::enterKey_data() { - QTest::addColumn<int>("widget"); + QTest::addColumn<WidgetType>("widget"); QTest::addColumn<int>("key"); QTest::addColumn<bool>("expectedFocus"); - QTest::newRow("lineedit enter") << 1 << int(Qt::Key_Enter) << false; - QTest::newRow("textedit enter") << 2 << int(Qt::Key_Enter) << true; - QTest::newRow("plaintextedit enter") << 3 << int(Qt::Key_Enter) << true; - QTest::newRow("plaintextedit return") << 3 << int(Qt::Key_Return) << true; - QTest::newRow("plaintextedit tab") << 3 << int(Qt::Key_Tab) << false; - QTest::newRow("lineedit tab") << 1 << int(Qt::Key_Tab) << false; + QTest::newRow("lineedit enter") << LineEdit << int(Qt::Key_Enter) << false; + QTest::newRow("textedit enter") << TextEdit << int(Qt::Key_Enter) << true; + QTest::newRow("plaintextedit enter") << PlainTextEdit << int(Qt::Key_Enter) << true; + QTest::newRow("plaintextedit return") << PlainTextEdit << int(Qt::Key_Return) << true; + QTest::newRow("plaintextedit tab") << PlainTextEdit << int(Qt::Key_Tab) << false; + QTest::newRow("lineedit tab") << LineEdit << int(Qt::Key_Tab) << false; } void tst_QItemDelegate::enterKey() { - QFETCH(int, widget); + QFETCH(WidgetType, widget); QFETCH(int, key); QFETCH(bool, expectedFocus); @@ -1087,18 +1095,18 @@ void tst_QItemDelegate::enterKey() struct TestDelegate : public QItemDelegate { - int widgetType; + WidgetType widgetType; virtual QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& /*option*/, const QModelIndex& /*index*/) const { QWidget *editor = 0; switch(widgetType) { - case 1: + case LineEdit: editor = new QLineEdit(parent); break; - case 2: + case TextEdit: editor = new QTextEdit(parent); break; - case 3: + case PlainTextEdit: editor = new QPlainTextEdit(parent); break; } @@ -1124,7 +1132,11 @@ void tst_QItemDelegate::enterKey() QTest::keyClick(editor, Qt::Key(key)); QApplication::processEvents(); - QCOMPARE(editor && editor->hasFocus(), expectedFocus); + // The line edit has already been destroyed, so avoid that case. + if (widget == TextEdit || widget == PlainTextEdit) { + QVERIFY(!editor.isNull()); + QCOMPARE(editor && editor->hasFocus(), expectedFocus); + } } void tst_QItemDelegate::task257859_finalizeEdit() diff --git a/tests/auto/qitemmodel/qitemmodel.pro b/tests/auto/qitemmodel/qitemmodel.pro index 38c615b..eb62b24 100644 --- a/tests/auto/qitemmodel/qitemmodel.pro +++ b/tests/auto/qitemmodel/qitemmodel.pro @@ -13,3 +13,12 @@ QT += sql # plugFiles.path = sqldrivers # DEPLOYMENT += plugFiles #} + +symbian { + TARGET.EPOCHEAPSIZE="0x100000 0x1000000 // Min 1Mb, max 16Mb" + contains(S60_VERSION, 3.1)|contains(S60_VERSION, 3.2)|contains(S60_VERSION, 5.0) { + sqlite.path = /sys/bin + sqlite.sources = sqlite3.dll + DEPLOYMENT += sqlite + } +} diff --git a/tests/auto/qitemselectionmodel/tst_qitemselectionmodel.cpp b/tests/auto/qitemselectionmodel/tst_qitemselectionmodel.cpp index 5806ca9..595c757 100644 --- a/tests/auto/qitemselectionmodel/tst_qitemselectionmodel.cpp +++ b/tests/auto/qitemselectionmodel/tst_qitemselectionmodel.cpp @@ -91,6 +91,7 @@ private slots: void task119433_isRowSelected(); void task252069_rowIntersectsSelection(); void task232634_childrenDeselectionSignal(); + void task260134_layoutChangedWithAllSelected(); private: QAbstractItemModel *model; @@ -2241,5 +2242,37 @@ void tst_QItemSelectionModel::task232634_childrenDeselectionSignal() QVERIFY(selectionModel.selection().contains(sel2)); } +void tst_QItemSelectionModel::task260134_layoutChangedWithAllSelected() +{ + QStringListModel model( QStringList() << "foo" << "bar" << "foo2"); + QSortFilterProxyModel proxy; + proxy.setSourceModel(&model); + QItemSelectionModel selection(&proxy); + + + QCOMPARE(model.rowCount(), 3); + QCOMPARE(proxy.rowCount(), 3); + proxy.setFilterRegExp( QRegExp("f")); + QCOMPARE(proxy.rowCount(), 2); + + QList<QPersistentModelIndex> indexList; + indexList << proxy.index(0,0) << proxy.index(1,0); + selection.select( QItemSelection(indexList.first(), indexList.last()), QItemSelectionModel::Select); + + //let's check the selection hasn't changed + QCOMPARE(selection.selectedIndexes().count(), indexList.count()); + foreach(QPersistentModelIndex index, indexList) + QVERIFY(selection.isSelected(index)); + + proxy.setFilterRegExp(QRegExp()); + QCOMPARE(proxy.rowCount(), 3); + + //let's check the selection hasn't changed + QCOMPARE(selection.selectedIndexes().count(), indexList.count()); + foreach(QPersistentModelIndex index, indexList) + QVERIFY(selection.isSelected(index)); +} + + QTEST_MAIN(tst_QItemSelectionModel) #include "tst_qitemselectionmodel.moc" diff --git a/tests/auto/qitemview/tst_qitemview.cpp b/tests/auto/qitemview/tst_qitemview.cpp index 1b06401..18a7922 100644 --- a/tests/auto/qitemview/tst_qitemview.cpp +++ b/tests/auto/qitemview/tst_qitemview.cpp @@ -254,7 +254,7 @@ void tst_QItemView::populate() { treeModel = new CheckerModel; QModelIndex parent; -#ifdef QT_ARCH_ARM +#if defined(QT_ARCH_ARM) || defined(Q_OS_SYMBIAN) const int baseInsert = 4; #else const int baseInsert = 26; @@ -352,7 +352,7 @@ void tst_QItemView::nonDestructiveBasicTest() QCOMPARE(view->tabKeyNavigation(), false); view->setTabKeyNavigation(true); QCOMPARE(view->tabKeyNavigation(), true); - +#ifndef QT_NO_DRAGANDDROP // setDropIndicatorShown view->setDropIndicatorShown(false); QCOMPARE(view->showDropIndicator(), false); @@ -364,6 +364,7 @@ void tst_QItemView::nonDestructiveBasicTest() QCOMPARE(view->dragEnabled(), false); view->setDragEnabled(true); QCOMPARE(view->dragEnabled(), true); +#endif // setAlternatingRowColors view->setAlternatingRowColors(false); @@ -457,7 +458,7 @@ void tst_QItemView::spider() view->setHorizontalScrollMode((QAbstractItemView::ScrollMode)hscroll); view->setModel(treeModel); view->show(); -#if defined(Q_OS_WINCE) +#if defined(Q_OS_WINCE) || defined(Q_OS_SYMBIAN) srandom(0); #else srandom(time(0)); diff --git a/tests/auto/qkeyevent/.gitignore b/tests/auto/qkeyevent/.gitignore deleted file mode 100644 index 8d69f55..0000000 --- a/tests/auto/qkeyevent/.gitignore +++ /dev/null @@ -1 +0,0 @@ -tst_qkeyevent diff --git a/tests/auto/qkeyevent/qkeyevent.pro b/tests/auto/qkeyevent/qkeyevent.pro deleted file mode 100644 index 8a3dc12..0000000 --- a/tests/auto/qkeyevent/qkeyevent.pro +++ /dev/null @@ -1,5 +0,0 @@ -load(qttest_p4) -HEADERS += -SOURCES += tst_qkeyevent.cpp - - diff --git a/tests/auto/qkeyevent/tst_qkeyevent.cpp b/tests/auto/qkeyevent/tst_qkeyevent.cpp deleted file mode 100644 index 54c59f7..0000000 --- a/tests/auto/qkeyevent/tst_qkeyevent.cpp +++ /dev/null @@ -1,228 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the either Technology Preview License Agreement or the -** Beta Release License Agreement. -** -** GNU Lesser General Public License Usage -** Alternatively, 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. -** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://qt.nokia.com/contact. -** $QT_END_LICENSE$ -** -****************************************************************************/ - - -#include <QtTest/QtTest> -#include <qevent.h> -#include <qapplication.h> - - -#include <qevent.h> - -//TESTED_CLASS= -//TESTED_FILES=gui/itemviews/qitemselectionmodel.h gui/itemviews/qitemselectionmodel.cpp - -class KeyEventWidget : public QWidget -{ -public: - KeyEventWidget( QWidget* parent = 0, const char* name = 0 ); - ~KeyEventWidget(); - QKeyEvent* getLastKeyPress(); - QKeyEvent* getLastKeyRelease(); - bool recievedKeyPress; - bool recievedKeyRelease; -protected: - void keyPressEvent( QKeyEvent* e ); - void keyReleaseEvent( QKeyEvent* e ); -private: - QKeyEvent* lastKeyPress; - QKeyEvent* lastKeyRelease; -}; - -class tst_QKeyEvent : public QObject -{ - Q_OBJECT -public: - tst_QKeyEvent(); - ~tst_QKeyEvent(); -public slots: - void initTestCase(); - void cleanupTestCase(); -private slots: - void sendRecieveKeyEvents_data(); - void sendRecieveKeyEvents(); - void standardKey(); -private: - KeyEventWidget* testWidget; -}; - - -KeyEventWidget::KeyEventWidget( QWidget* parent, const char* name ) - : QWidget( parent ), recievedKeyPress( FALSE ), recievedKeyRelease( FALSE ), - lastKeyPress( 0 ), lastKeyRelease( 0 ) -{ - setObjectName(name); -} - -KeyEventWidget::~KeyEventWidget() -{ -} - -QKeyEvent* KeyEventWidget::getLastKeyPress() -{ - return lastKeyPress; -} - -QKeyEvent* KeyEventWidget::getLastKeyRelease() -{ - return lastKeyRelease; -} - -void KeyEventWidget::keyPressEvent( QKeyEvent* e ) -{ - lastKeyPress = e; - recievedKeyPress = TRUE; -} - -void KeyEventWidget::keyReleaseEvent( QKeyEvent* e ) -{ - lastKeyRelease = e; - recievedKeyRelease = TRUE; -} - -tst_QKeyEvent::tst_QKeyEvent() -{ -} - -tst_QKeyEvent::~tst_QKeyEvent() -{ -} - -void tst_QKeyEvent::initTestCase() -{ - testWidget = new KeyEventWidget( 0 ); - testWidget->show(); -} - -void tst_QKeyEvent::cleanupTestCase() -{ - delete testWidget; -} - -void tst_QKeyEvent::sendRecieveKeyEvents_data() -{ - QTest::addColumn<int>("key"); - QTest::addColumn<bool>("textExpected"); - QTest::addColumn<QString>("text"); - int a; - for ( a = Qt::Key_Escape; a < Qt::Key_Direction_R; a++ ) { - if ( ( a > Qt::Key_Clear && a < Qt::Key_Home ) - || ( a > Qt::Key_PageDown && a < Qt::Key_Shift ) - || ( a > Qt::Key_ScrollLock && a < Qt::Key_F1 ) ) { - // There is no representation for these values - continue; - } - if ( a == Qt::Key_Backtab ) // Actually SHIFT+Tab - QTest::newRow( QString("key - %1").arg( a ).toLatin1() ) << int(Qt::Key_Tab) << FALSE << ""; - else - QTest::newRow( QString("key - %1").arg( a ).toLatin1() ) << a << FALSE << ""; - } - - for ( a = Qt::Key_Space; a < Qt::Key_ydiaeresis; a++ ) { - QTest::newRow( QString("key - %1").arg( a ).toLatin1() ) << a << TRUE << QString( QChar(a) ); - } -} - -void tst_QKeyEvent::standardKey() -{ - -} - -void tst_QKeyEvent::sendRecieveKeyEvents() -{ - QSKIP( "Skipped while it is being worked on", SkipAll); - QFETCH( int, key ); - QFETCH( bool, textExpected ); - QFETCH( QString, text ); - testWidget->recievedKeyPress = FALSE; - -#ifdef Q_WS_WIN - // Will be eaten by Windows system - if ( key == Qt::Key_Print ) - return; - - // This is mapped to nothing on Windows - if ( key == Qt::Key_SysReq ) - return; - - // Not supported on Windows - if ( key >= Qt::Key_F25 && key <= Qt::Key_Super_R ) - return; - if ( key >= Qt::Key_Hyper_L && key <= Qt::Key_Hyper_R ) - return; - if ( key == Qt::Key_Help ) - return; - - // Not sure on how to add support for these yet - if ( key >= Qt::Key_Direction_L && key <= Qt::Key_Direction_R ) - return; - - // Not sure on how to test these yet, since they use SHIFT etc - if ( key >= Qt::Key_Exclam && key <= Qt::Key_Slash ) - return; - if ( key >= Qt::Key_Colon && key <= Qt::Key_At ) - return; - if ( key >= Qt::Key_BracketRight && key <= Qt::Key_ydiaeresis ) - return; -#endif // Q_WS_WIN - - if ( key == Qt::Key_F1 ) - return; // Ignore for the moment - - QTest::keyPress( testWidget, (Qt::Key)key ); - while ( !testWidget->recievedKeyPress ) - qApp->processEvents(); - QKeyEvent* ke = testWidget->getLastKeyPress(); - QCOMPARE( ke->key(), key ); - if ( textExpected ) - QCOMPARE( ke->text(), text ); - testWidget->recievedKeyRelease = FALSE; - QTest::keyRelease( testWidget, (Qt::Key)key ); - while ( !testWidget->recievedKeyRelease ) - qApp->processEvents(); - ke = testWidget->getLastKeyRelease(); - QCOMPARE( ke->key(), key ); - if ( textExpected ) - QCOMPARE( ke->text(), text ); -} - -QTEST_MAIN(tst_QKeyEvent) -#include "tst_qkeyevent.moc" diff --git a/tests/auto/qkeysequence/tst_qkeysequence.cpp b/tests/auto/qkeysequence/tst_qkeysequence.cpp index 5c47da4..6deee02 100644 --- a/tests/auto/qkeysequence/tst_qkeysequence.cpp +++ b/tests/auto/qkeysequence/tst_qkeysequence.cpp @@ -311,15 +311,7 @@ void tst_QKeySequence::standardKeys_data() QTest::newRow("zoomOut") << (int)QKeySequence::ZoomOut<< QString("CTRL+-"); QTest::newRow("whatsthis") << (int)QKeySequence::WhatsThis<< QString("SHIFT+F1"); -#ifndef Q_WS_MAC - QTest::newRow("help") << (int)QKeySequence::HelpContents<< QString("F1"); - QTest::newRow("nextChild") << (int)QKeySequence::NextChild<< QString("CTRL+Tab"); - QTest::newRow("previousChild") << (int)QKeySequence::PreviousChild<< QString("CTRL+SHIFT+BACKTAB"); - QTest::newRow("forward") << (int)QKeySequence::Forward << QString("ALT+RIGHT"); - QTest::newRow("backward") << (int)QKeySequence::Back << QString("ALT+LEFT"); - QTest::newRow("MoveToEndOfBlock") << (int)QKeySequence::MoveToEndOfBlock<< QString(""); //mac only - QTest::newRow("SelectEndOfDocument") << (int)QKeySequence::SelectEndOfDocument<< QString("CTRL+SHIFT+END"); //mac only -#else +#if defined(Q_WS_MAC) QTest::newRow("help") << (int)QKeySequence::HelpContents<< QString("Ctrl+?"); QTest::newRow("nextChild") << (int)QKeySequence::NextChild << QString("CTRL+}"); QTest::newRow("previousChild") << (int)QKeySequence::PreviousChild << QString("CTRL+{"); @@ -327,6 +319,17 @@ void tst_QKeySequence::standardKeys_data() QTest::newRow("forward") << (int)QKeySequence::Forward << QString("CTRL+]"); QTest::newRow("backward") << (int)QKeySequence::Back << QString("CTRL+["); QTest::newRow("SelectEndOfDocument") << (int)QKeySequence::SelectEndOfDocument<< QString("CTRL+SHIFT+DOWN"); //mac only +#elif defined(Q_WS_S60) + QTest::newRow("help") << (int)QKeySequence::HelpContents<< QString("F2"); + QTest::newRow("SelectEndOfDocument") << (int)QKeySequence::SelectEndOfDocument<< QString("CTRL+SHIFT+END"); //mac only +#else + QTest::newRow("help") << (int)QKeySequence::HelpContents<< QString("F1"); + QTest::newRow("nextChild") << (int)QKeySequence::NextChild<< QString("CTRL+Tab"); + QTest::newRow("previousChild") << (int)QKeySequence::PreviousChild<< QString("CTRL+SHIFT+BACKTAB"); + QTest::newRow("forward") << (int)QKeySequence::Forward << QString("ALT+RIGHT"); + QTest::newRow("backward") << (int)QKeySequence::Back << QString("ALT+LEFT"); + QTest::newRow("MoveToEndOfBlock") << (int)QKeySequence::MoveToEndOfBlock<< QString(""); //mac only + QTest::newRow("SelectEndOfDocument") << (int)QKeySequence::SelectEndOfDocument<< QString("CTRL+SHIFT+END"); //mac only #endif } @@ -343,7 +346,7 @@ void tst_QKeySequence::keyBindings() { QList<QKeySequence> bindings = QKeySequence::keyBindings(QKeySequence::Copy); QList<QKeySequence> expected; -#ifdef Q_WS_MAC +#if defined(Q_WS_MAC) || defined (Q_WS_S60) expected << QKeySequence("CTRL+C"); #elif defined Q_WS_X11 expected << QKeySequence("CTRL+C") << QKeySequence("F16") << QKeySequence("CTRL+INSERT"); @@ -504,8 +507,8 @@ void tst_QKeySequence::translated() QFETCH(QString, compKey); #ifdef Q_WS_MAC QSKIP("No need to translate modifiers on Mac OS X", SkipAll); -#elif defined(Q_OS_WINCE) - QSKIP("No need to translate modifiers on WinCE", SkipAll); +#elif defined(Q_OS_WINCE) || defined(Q_OS_SYMBIAN) + QSKIP("No need to translate modifiers on WinCE or Symbian", SkipAll); #endif qApp->installTranslator(ourTranslator); diff --git a/tests/auto/qlabel/qlabel.pro b/tests/auto/qlabel/qlabel.pro index 141559e..c274b4a 100644 --- a/tests/auto/qlabel/qlabel.pro +++ b/tests/auto/qlabel/qlabel.pro @@ -3,11 +3,14 @@ SOURCES += tst_qlabel.cpp wince*:{ DEFINES += SRCDIR=\\\"\\\" +} !symbian { + DEFINES += SRCDIR=\\\"$$PWD/\\\" +} + +wince*|symbian { addFiles.sources = *.png testdata addFiles.path = . DEPLOYMENT += addFiles -} else { - DEFINES += SRCDIR=\\\"$$PWD/\\\" } diff --git a/tests/auto/qlabel/tst_qlabel.cpp b/tests/auto/qlabel/tst_qlabel.cpp index 6754688..3ff5bb4 100644 --- a/tests/auto/qlabel/tst_qlabel.cpp +++ b/tests/auto/qlabel/tst_qlabel.cpp @@ -53,6 +53,9 @@ //TESTED_CLASS= //TESTED_FILES= +#if defined(Q_OS_SYMBIAN) +# define SRCDIR "" +#endif class Widget : public QWidget { diff --git a/tests/auto/qlayout/qlayout.pro b/tests/auto/qlayout/qlayout.pro index 0c69b11..0dfe1e9 100644 --- a/tests/auto/qlayout/qlayout.pro +++ b/tests/auto/qlayout/qlayout.pro @@ -6,7 +6,7 @@ load(qttest_p4) SOURCES += tst_qlayout.cpp contains(QT_CONFIG, qt3support): QT += qt3support -wince*: { +wince*|symbian*: { addFiles.sources = baseline addFiles.path = . DEPLOYMENT += addFiles diff --git a/tests/auto/qlibrary/lib/lib.pro b/tests/auto/qlibrary/lib/lib.pro index 14b8783..25a50b5 100644 --- a/tests/auto/qlibrary/lib/lib.pro +++ b/tests/auto/qlibrary/lib/lib.pro @@ -19,7 +19,7 @@ win32: { copy /Y $(DESTDIR_TARGET) ..\system.trolltech.test.mylib.dll && \ copy /Y $(DESTDIR_TARGET) ..\mylib_noextension } -unix: { +unix:!symbian: { QMAKE_POST_LINK = cp -f $(DESTDIR)$(TARGET) ../libmylib.so2 && \ cp -f $(DESTDIR)$(TARGET) ../system.trolltech.test.mylib.so } @@ -27,4 +27,5 @@ unix: { #no special install rule for the library used by test INSTALLS = +symbian: TARGET.CAPABILITY=ALL -TCB diff --git a/tests/auto/qlibrary/lib/mylib.c b/tests/auto/qlibrary/lib/mylib.c index 1366b7c..5e98362 100644 --- a/tests/auto/qlibrary/lib/mylib.c +++ b/tests/auto/qlibrary/lib/mylib.c @@ -1,6 +1,6 @@ #include <qglobal.h> -#if defined(Q_CC_MSVC) || defined(Q_CC_MSVC_NET) || defined(Q_CC_BOR) +#if defined(Q_CC_MSVC) || defined(Q_CC_MSVC_NET) || defined(Q_CC_BOR) || defined(Q_OS_SYMBIAN) #define LIB_EXPORT __declspec(dllexport) #else #define LIB_EXPORT @@ -12,7 +12,7 @@ # define BORLAND_STDCALL #endif -LIB_EXPORT int BORLAND_STDCALL version() +LIB_EXPORT int BORLAND_STDCALL mylibversion() { return 1; } diff --git a/tests/auto/qlibrary/lib2/lib2.pro b/tests/auto/qlibrary/lib2/lib2.pro index 718c5c6..436d7ba 100644 --- a/tests/auto/qlibrary/lib2/lib2.pro +++ b/tests/auto/qlibrary/lib2/lib2.pro @@ -19,11 +19,29 @@ win32: { QMAKE_POST_LINK = copy /Y ..\mylib2.dll ..\mylib.dl2 && \ copy /Y ..\mylib2.dll ..\system.trolltech.test.mylib.dll } -unix: { + +unix:!symbian: { QMAKE_POST_LINK = cp -f $(DESTDIR)$(TARGET) ../libmylib.so2 && \ cp -f $(DESTDIR)$(TARGET) ../system.trolltech.test.mylib.so } +symbian-abld: { + TARGET.CAPABILITY=ALL -TCB + FIXEDROOT = $$replace(EPOCROOT,/,\\) + QMAKE_POST_LINK = \ + copy /Y $${FIXEDROOT}epoc32\release\\$(PLATFORM)\\$(CFG)\mylib.dll $${FIXEDROOT}epoc32\release\\$(PLATFORM)\\$(CFG)\mylib.dl2 && \ + copy /Y $${FIXEDROOT}epoc32\release\\$(PLATFORM)\\$(CFG)\mylib.dll $${FIXEDROOT}epoc32\release\\$(PLATFORM)\\$(CFG)\system.trolltech.test.mylib.dll && \ + IF NOT "$(PLATFORM)==WINSCW" copy /Y $${FIXEDROOT}epoc32\release\\$(PLATFORM)\\$(CFG)\mylib.dll ..\tst\mylib.dl2 +} + +symbian-sbsv2: { + TARGET.CAPABILITY=ALL -TCB + QMAKE_POST_LINK = \ + $(GNUCP) $${EPOCROOT}epoc32/release/$(PLATFORM_PATH)/$(CFG_PATH)/mylib.dll $${EPOCROOT}epoc32/release/$(PLATFORM_PATH)/$(CFG_PATH)/mylib.dl2 && \ + $(GNUCP) $${EPOCROOT}epoc32/release/$(PLATFORM_PATH)/$(CFG_PATH)/mylib.dll $${EPOCROOT}epoc32/release/$(PLATFORM_PATH)/$(CFG_PATH)/system.trolltech.test.mylib.dll && \ + if test $(PLATFORM) != WINSCW;then $(GNUCP) $${EPOCROOT}epoc32/release/$(PLATFORM_PATH)/$(CFG_PATH)/mylib.dll $${PWD}/../tst/mylib.dl2; fi +} + #no special install rule for the library used by test INSTALLS = diff --git a/tests/auto/qlibrary/lib2/mylib.c b/tests/auto/qlibrary/lib2/mylib.c index dd90f04..4046f1f 100644 --- a/tests/auto/qlibrary/lib2/mylib.c +++ b/tests/auto/qlibrary/lib2/mylib.c @@ -1,6 +1,6 @@ #include <qglobal.h> -#if defined(Q_CC_MSVC) || defined(Q_CC_MSVC_NET) || defined(Q_CC_BOR) +#if defined(Q_CC_MSVC) || defined(Q_CC_MSVC_NET) || defined(Q_CC_BOR)|| defined(Q_OS_SYMBIAN) #define LIB_EXPORT __declspec(dllexport) #else #define LIB_EXPORT @@ -12,7 +12,7 @@ # define BORLAND_STDCALL #endif -LIB_EXPORT int BORLAND_STDCALL version() +LIB_EXPORT int BORLAND_STDCALL mylibversion() { return 2; } diff --git a/tests/auto/qlibrary/qlibrary.pro b/tests/auto/qlibrary/qlibrary.pro index f3e646a..fd5790b 100644 --- a/tests/auto/qlibrary/qlibrary.pro +++ b/tests/auto/qlibrary/qlibrary.pro @@ -1,8 +1,16 @@ +QT -= gui TEMPLATE = subdirs CONFIG += ordered -SUBDIRS = lib \ - lib2 \ - tst + +symbian: { +# Can't build two versions of lib with same name in symbian, so just build one +SUBDIRS = lib2 \ + tst +} else { +SUBDIRS = lib \ + lib2 \ + tst +} TARGET = tst_qlibrary # no special install rule for subdir diff --git a/tests/auto/qlibrary/tst/tst.pro b/tests/auto/qlibrary/tst/tst.pro index 67437a6..e15d7ed 100644 --- a/tests/auto/qlibrary/tst/tst.pro +++ b/tests/auto/qlibrary/tst/tst.pro @@ -16,8 +16,18 @@ wince*: { addFiles.path = . DEPLOYMENT += addFiles DEFINES += SRCDIR=\\\"\\\" +}else:symbian* { + binDep.sources = \ + mylib.dll \ + system.trolltech.test.mylib.dll + binDep.path = /sys/bin +#mylib.dl2 nonstandard binary deployment will cause warning in emulator, +#but it can be safely ignored. + custBinDep.sources = mylib.dl2 + custBinDep.path = /sys/bin + + DEPLOYMENT += binDep custBinDep } else { DEFINES += SRCDIR=\\\"$$PWD/../\\\" } - diff --git a/tests/auto/qlibrary/tst_qlibrary.cpp b/tests/auto/qlibrary/tst_qlibrary.cpp index a5d5cbe..242ad86 100644 --- a/tests/auto/qlibrary/tst_qlibrary.cpp +++ b/tests/auto/qlibrary/tst_qlibrary.cpp @@ -85,7 +85,7 @@ # define SUFFIX ".a" # define PREFIX "lib" -#elif defined(Q_OS_WIN) +#elif defined(Q_OS_WIN) || defined(Q_OS_SYMBIAN) # undef dll_VALID # define dll_VALID true # define SUFFIX ".dll" @@ -100,8 +100,12 @@ static QString sys_qualifiedLibraryName(const QString &fileName) { +#if defined(Q_OS_SYMBIAN) + return PREFIX + fileName + SUFFIX; +#else QString currDir = QDir::currentPath(); return currDir + "/" + PREFIX + fileName + SUFFIX; +#endif } //TESTED_CLASS= @@ -187,13 +191,13 @@ void tst_QLibrary::version() QFETCH( int, loadversion ); QFETCH( int, resultversion ); -#if !defined(Q_OS_AIX) && !defined(Q_OS_WIN) +#if !defined(Q_OS_AIX) && !defined(Q_OS_WIN) && !defined(Q_OS_SYMBIAN) QString currDir = QDir::currentPath(); QLibrary library( currDir + QLatin1Char('/') + lib, loadversion ); bool ok = library.load(); QVERIFY(ok); - VersionFunction fnVersion = (VersionFunction)library.resolve("version"); + VersionFunction fnVersion = (VersionFunction)library.resolve("mylibversion"); QVERIFY(fnVersion); QCOMPARE(fnVersion(), resultversion); #else @@ -209,7 +213,11 @@ void tst_QLibrary::load_data() QTest::addColumn<QString>("lib"); QTest::addColumn<bool>("result"); +#if defined(Q_OS_SYMBIAN) + QString currDir; +#else QString currDir = QDir::currentPath(); +#endif QTest::newRow( "ok00" ) << currDir + "/mylib" << (bool)true; QTest::newRow( "notexist" ) << currDir + "/nolib" << (bool)false; QTest::newRow( "badlibrary" ) << currDir + "/qlibrary.pro" << (bool)false; @@ -218,7 +226,7 @@ void tst_QLibrary::load_data() QTest::newRow("ok (libmylib ver. 1)") << currDir + "/libmylib" <<(bool)true; #endif -# if defined(Q_OS_WIN32) || defined(Q_OS_WINCE) +# if defined(Q_OS_WIN32) || defined(Q_OS_WINCE) || defined(Q_OS_SYMBIAN) QTest::newRow( "ok01 (with suffix)" ) << currDir + "/mylib.dll" << (bool)true; QTest::newRow( "ok02 (with non-standard suffix)" ) << currDir + "/mylib.dl2" << (bool)true; QTest::newRow( "ok03 (with many dots)" ) << currDir + "/system.trolltech.test.mylib.dll" << (bool)true; @@ -248,7 +256,12 @@ void tst_QLibrary::unload_data() QTest::addColumn<QString>("lib"); QTest::addColumn<bool>("result"); +#if defined(Q_OS_SYMBIAN) + QString currDir; +#else QString currDir = QDir::currentPath(); +#endif + QTest::newRow( "mylib" ) << currDir + "/mylib" << (bool)TRUE; #ifdef Q_WS_MAC if (QSysInfo::MacintoshVersion <= QSysInfo::MV_10_3) @@ -274,8 +287,12 @@ void tst_QLibrary::unload() void tst_QLibrary::unload_after_implicit_load() { +#if defined(Q_OS_SYMBIAN) + QSKIP("SYMBIAN does not support symbols on non-STDDLL libraries.", SkipAll); +#endif + QLibrary library( "./mylib" ); - void *p = library.resolve("version"); + void *p = library.resolve("mylibversion"); QVERIFY(p); // Check if it was loaded QVERIFY(library.isLoaded()); QVERIFY(library.unload()); @@ -289,14 +306,23 @@ void tst_QLibrary::resolve_data() QTest::addColumn<QString>("symbol"); QTest::addColumn<bool>("goodPointer"); +#if defined(Q_OS_SYMBIAN) + QString currDir; +#else QString currDir = QDir::currentPath(); - QTest::newRow( "ok00" ) << currDir + "/mylib" << QString("version") << (bool)TRUE; +#endif + + QTest::newRow( "ok00" ) << currDir + "/mylib" << QString("mylibversion") << (bool)TRUE; QTest::newRow( "bad00" ) << currDir + "/mylib" << QString("nosym") << (bool)FALSE; QTest::newRow( "bad01" ) << currDir + "/nolib" << QString("nosym") << (bool)FALSE; } void tst_QLibrary::resolve() { +#if defined(Q_OS_SYMBIAN) + QSKIP("SYMBIAN does not support symbols on non-STDDLL libraries.", SkipAll); +#endif + typedef int (*testFunc)(); QFETCH( QString, lib ); QFETCH( QString, symbol ); @@ -347,7 +373,7 @@ void tst_QLibrary::isLibrary_data() QTest::newRow("good (libmylib.so.1.0.0)") << QString("libmylib.so.1.0.0") << true; QTest::newRow("bad (libmylib.1.0.0.foo)") << QString("libmylib.1.0.0.foo") << false; -#elif defined(Q_OS_WIN) +#elif defined(Q_OS_WIN) || defined(Q_OS_SYMBIAN) QTest::newRow("good (with many dots)" ) << "/system.trolltech.test.mylib.dll" << true; #endif } @@ -367,10 +393,15 @@ void tst_QLibrary::errorString_data() QTest::addColumn<bool>("success"); QTest::addColumn<QString>("errorString"); +#if defined(Q_OS_SYMBIAN) + QString currDir; +#else QString currDir = QDir::currentPath(); + QString srcDir = SRCDIR; if (srcDir.isEmpty()) srcDir = currDir; +#endif QTest::newRow("bad load()") << (int)Load << QString("nosuchlib") << false << QString("Cannot load library nosuchlib: .*"); QTest::newRow("call errorString() on QLibrary with no d-pointer (crashtest)") << (int)(Load | DontSetFileName) << QString() << false << QString("Unknown error"); @@ -385,6 +416,8 @@ void tst_QLibrary::errorString_data() QTest::newRow("bad load() with .dll suffix") << (int)Load << QString("nosuchlib.dll") << false << QString("Cannot load library nosuchlib.dll: The specified module could not be found."); // QTest::newRow("bad unload") << (int)Unload << QString("nosuchlib.dll") << false << QString("QLibrary::unload_sys: Cannot unload nosuchlib.dll (The specified module could not be found.)"); #elif defined Q_OS_MAC +#elif defined Q_OS_SYMBIAN + QTest::newRow("load invalid file") << (int)Load << "tst_qlibrary.exe" << false << QString("Cannot load library.*"); #else QTest::newRow("load invalid file") << (int)Load << srcDir + "/library_path/invalid.so" << false << QString("Cannot load library.*"); #endif @@ -397,6 +430,13 @@ void tst_QLibrary::errorString() QFETCH(bool, success); QFETCH(QString, errorString); +#if defined(Q_OS_SYMBIAN) + if ( success ) + { + QSKIP("SYMBIAN does not support symbols on non-STDDLL libraries.", SkipSingle ); + } +#endif + QLibrary lib; if (!(operation & DontSetFileName)) { lib.setFileName(fileName); @@ -415,7 +455,7 @@ void tst_QLibrary::errorString() ok = lib.load(); QCOMPARE(ok, true); if (success) { - ok = lib.resolve("version"); + ok = lib.resolve("mylibversion"); } else { ok = lib.resolve("nosuchsymbol"); } @@ -446,9 +486,14 @@ void tst_QLibrary::loadHints_data() } #endif +#if defined(Q_OS_SYMBIAN) + QString currDir; +#else QString currDir = QDir::currentPath(); +#endif + lh |= QLibrary::ResolveAllSymbolsHint; -# if defined(Q_OS_WIN32) || defined(Q_OS_WINCE) +# if defined(Q_OS_WIN32) || defined(Q_OS_WINCE) || defined(Q_OS_SYMBIAN) QTest::newRow( "ok01 (with suffix)" ) << currDir + "/mylib.dll" << int(lh) << (bool)TRUE; QTest::newRow( "ok02 (with non-standard suffix)" ) << currDir + "/mylib.dl2" << int(lh) << (bool)TRUE; QTest::newRow( "ok03 (with many dots)" ) << currDir + "/system.trolltech.test.mylib.dll" << int(lh) << (bool)TRUE; @@ -486,7 +531,6 @@ void tst_QLibrary::fileName_data() QTest::addColumn<QString>("libName"); QTest::addColumn<QString>("expectedFilename"); - QString currDir = QDir::currentPath(); QTest::newRow( "ok02" ) << sys_qualifiedLibraryName(QLatin1String("mylib")) << sys_qualifiedLibraryName(QLatin1String("mylib")); #ifdef Q_WS_WIN @@ -518,7 +562,12 @@ void tst_QLibrary::fileName() void tst_QLibrary::multipleInstancesForOneLibrary() { +#if defined(Q_OS_SYMBIAN) + QString lib = "/mylib"; +#else QString lib = QDir::currentPath() + "/mylib"; +#endif + QLibrary lib1(lib); QLibrary lib2(lib); QCOMPARE(lib1.isLoaded(), false); diff --git a/tests/auto/qline/qline.pro b/tests/auto/qline/qline.pro index 56718d0..1a3d7f2 100644 --- a/tests/auto/qline/qline.pro +++ b/tests/auto/qline/qline.pro @@ -1,6 +1,6 @@ load(qttest_p4) QT -= gui SOURCES += tst_qline.cpp -unix:!mac:!vxworks:LIBS+=-lm +unix:!mac:!symbian*:!vxworks:LIBS+=-lm diff --git a/tests/auto/qlineedit/tst_qlineedit.cpp b/tests/auto/qlineedit/tst_qlineedit.cpp index 3525865..1616154 100644 --- a/tests/auto/qlineedit/tst_qlineedit.cpp +++ b/tests/auto/qlineedit/tst_qlineedit.cpp @@ -220,10 +220,11 @@ private slots: void setSelection_data(); void setSelection(); +#ifndef QT_NO_CLIPBOARD void cut(); void copy(); void paste(); - +#endif void maxLengthAndInputMask(); void returnPressedKeyEvent(); @@ -2750,6 +2751,7 @@ void tst_QLineEdit::setSelection() QCOMPARE(testWidget->cursorPosition(), expectedCursor); } +#ifndef QT_NO_CLIPBOARD void tst_QLineEdit::cut() { #ifdef Q_WS_MAC @@ -2830,7 +2832,7 @@ void tst_QLineEdit::paste() { DEPENDS_ON("cut"); } - +#endif class InputMaskValidator : public QValidator { public: diff --git a/tests/auto/qlistview/tst_qlistview.cpp b/tests/auto/qlistview/tst_qlistview.cpp index 2abf198..533dff1 100644 --- a/tests/auto/qlistview/tst_qlistview.cpp +++ b/tests/auto/qlistview/tst_qlistview.cpp @@ -48,7 +48,9 @@ #include <qitemdelegate.h> #include <qstandarditemmodel.h> #include <qstringlistmodel.h> +#ifndef Q_OS_SYMBIAN #include <cmath> +#endif #include <math.h> #include <QtGui/QScrollBar> #include <QtGui/QDialog> diff --git a/tests/auto/qlistwidget/tst_qlistwidget.cpp b/tests/auto/qlistwidget/tst_qlistwidget.cpp index 0ca94bf..6cbe9ca 100644 --- a/tests/auto/qlistwidget/tst_qlistwidget.cpp +++ b/tests/auto/qlistwidget/tst_qlistwidget.cpp @@ -1437,6 +1437,10 @@ public: void tst_QListWidget::fastScroll() { + if (qstrcmp(QApplication::style()->metaObject()->className(), "QS60Style") == 0) { + QSKIP("S60 style doesn't support fast scrolling", SkipAll); + } + MyListWidget widget; for (int i = 0; i < 50; ++i) widget.addItem(QString("Item %1").arg(i)); diff --git a/tests/auto/qlocale/test/test.pro b/tests/auto/qlocale/test/test.pro index b840e2d..7bc9f59 100644 --- a/tests/auto/qlocale/test/test.pro +++ b/tests/auto/qlocale/test/test.pro @@ -29,3 +29,11 @@ wince*: { DEPLOYMENT += addFiles } +symbian:contains(S60_VERSION,3.2) { + # This test case compilation crashes on 3.2 for gcce if paging is on + MMP_RULES -= PAGED + custom_paged_rule = "$${LITERAL_HASH}ifndef GCCE"\ + "PAGED" \ + "$${LITERAL_HASH}endif" + MMP_RULES += custom_paged_rule +}
\ No newline at end of file diff --git a/tests/auto/qlocale/tst_qlocale.cpp b/tests/auto/qlocale/tst_qlocale.cpp index e920b2b..642e655 100644 --- a/tests/auto/qlocale/tst_qlocale.cpp +++ b/tests/auto/qlocale/tst_qlocale.cpp @@ -68,6 +68,11 @@ extern "C" DWORD GetThreadLocale(void) { # include <stdlib.h> #endif +#if defined(Q_OS_SYMBIAN) +# include <e32std.h> +# include <private/qcore_symbian_p.h> +#endif + Q_DECLARE_METATYPE(qlonglong) Q_DECLARE_METATYPE(QDate) Q_DECLARE_METATYPE(QLocale::FormatType) @@ -130,6 +135,9 @@ private slots: void queryDateTime(); void queryMeasureSystem_data(); void queryMeasureSystem(); +#if defined(Q_OS_SYMBIAN) + void symbianSystemLocale(); +#endif void ampm(); @@ -317,8 +325,8 @@ void tst_QLocale::ctor() void tst_QLocale::emptyCtor() { -#ifdef Q_OS_WINCE - QSKIP("Uses unsupported Windows CE QProcess functionality", SkipAll); +#if defined(Q_OS_WINCE) || defined(Q_OS_SYMBIAN) + QSKIP("Uses unsupported Windows CE / Symbian QProcess functionality (std streams, env)", SkipAll); #endif #if defined(QT_NO_PROCESS) QSKIP("Qt was compiled with QT_NO_PROCESS", SkipAll); @@ -667,7 +675,7 @@ void tst_QLocale::testInfAndNan() double nan = sqrt(-1.0); #ifdef Q_OS_WIN - // these causes INVALID floating point exception so we want to clare the status. + // these cause INVALID floating point exception so we want to clear the status. _clear87(); #endif @@ -1060,11 +1068,11 @@ void tst_QLocale::macDefaultLocale() QTime utcTime = QDateTime::currentDateTime().toUTC().time(); int diff = currentTime.hour() - utcTime.hour(); - + // Check if local time and utc time are on opposite sides of the 24-hour wrap-around. - if (diff < -12) + if (diff < -12) diff += 24; - if (diff > 12) + if (diff > 12) diff -= 24; const QString timeString = locale.toString(QTime(1,2,3), QLocale::LongFormat); @@ -1720,7 +1728,7 @@ void tst_QLocale::systemMeasurementSystems() // Theoretically, we could include HPUX in this test, but its setenv implementation // stinks. It's called putenv, and it requires you to keep the variable you pass // to it around forever. -#if defined(Q_OS_UNIX) && !defined(Q_OS_MAC) +#if defined(Q_OS_UNIX) && !defined(Q_OS_MAC) && !defined(Q_OS_SYMBIAN) QFETCH(QString, lcAllLocale); QFETCH(QString, lcMeasurementLocale); QFETCH(QString, langLocale); @@ -1744,7 +1752,7 @@ void tst_QLocale::systemMeasurementSystems() qputenv("LC_MEASUREMENT", oldLcMeasurement.toLocal8Bit()); qputenv("LANG", oldLang.toLocal8Bit()); #else - QSKIP("Test doesn't work on Mac or Windows", SkipAll); + QSKIP("Test doesn't work on Mac, Windows or Symbian", SkipAll); #endif } @@ -1842,7 +1850,7 @@ void tst_QLocale::queryMeasureSystem() // Theoretically, we could include HPUX in this test, but its setenv implementation // stinks. It's called putenv, and it requires you to keep the variable you pass // to it around forever. -#if defined(Q_OS_UNIX) && !defined(Q_OS_MAC) +#if defined(Q_OS_UNIX) && !defined(Q_OS_MAC) && !defined(Q_OS_SYMBIAN) QFETCH(QString, lcAllLocale); QFETCH(QString, lcMeasurementLocale); QFETCH(QString, langLocale); @@ -1866,7 +1874,7 @@ void tst_QLocale::queryMeasureSystem() qputenv("LC_MEASUREMENT", oldLcMeasurement.toLocal8Bit()); qputenv("LANG", oldLang.toLocal8Bit()); #else - QSKIP("Test doesn't work on Mac or Windows", SkipAll); + QSKIP("Test doesn't work on Mac, Windows or Symbian", SkipAll); #endif } #endif // QT_NO_SYSTEMLOCALE @@ -1983,5 +1991,33 @@ void tst_QLocale::standaloneMonthName() QCOMPARE(ru.standaloneMonthName(1, QLocale::NarrowFormat), QString::fromUtf8("\320\257")); } +#if defined(Q_OS_SYMBIAN) +void tst_QLocale::symbianSystemLocale() +{ +# if defined(__SERIES60_31__) + QSKIP("S60 3.1 doesn't support system format properly", SkipAll); +# else + // Simple test to verify that Symbian system locale works at all + const QSystemLocale locale; + TExtendedLocale s60Locale; + s60Locale.LoadSystemSettings(); + + TTime s60Date(_L("20090117:")); // Symbian offsets day and month from zero + QDate date(2009,2,18); + + TPtrC s60DateFormat = s60Locale.GetShortDateFormatSpec(); + QString dateFormat = locale.query(QSystemLocale::DateFormatShort, QVariant()).toString(); + + TBuf<50> s60FormattedDate; + TRAPD(err, s60Date.FormatL(s60FormattedDate, s60DateFormat)); + QVERIFY(err == KErrNone); + QString s60FinalResult = qt_TDesC2QString(s60FormattedDate); + QString finalResult = date.toString(dateFormat); + + QCOMPARE(finalResult, s60FinalResult); +# endif +} +#endif + QTEST_APPLESS_MAIN(tst_QLocale) #include "tst_qlocale.moc" diff --git a/tests/auto/qlocalsocket/lackey/lackey.pro b/tests/auto/qlocalsocket/lackey/lackey.pro index 7460d8c..7bb6bc3 100644 --- a/tests/auto/qlocalsocket/lackey/lackey.pro +++ b/tests/auto/qlocalsocket/lackey/lackey.pro @@ -12,7 +12,7 @@ mac:CONFIG -= app_bundle DEFINES += QLOCALSERVER_DEBUG DEFINES += QLOCALSOCKET_DEBUG -SOURCES += main.cpp +SOURCES += main.cpp TARGET = lackey - +symbian:TARGET.CAPABILITY = ALL -TCB
\ No newline at end of file diff --git a/tests/auto/qlocalsocket/lackey/main.cpp b/tests/auto/qlocalsocket/lackey/main.cpp index 0506793..181e6be 100644 --- a/tests/auto/qlocalsocket/lackey/main.cpp +++ b/tests/auto/qlocalsocket/lackey/main.cpp @@ -41,7 +41,7 @@ #include <qscriptengine.h> -#include <QtGui/QtGui> + #include <QFile> #include <QTest> #include <qlocalsocket.h> diff --git a/tests/auto/qlocalsocket/qlocalsocket.pro b/tests/auto/qlocalsocket/qlocalsocket.pro index 4df17de..0849453 100644 --- a/tests/auto/qlocalsocket/qlocalsocket.pro +++ b/tests/auto/qlocalsocket/qlocalsocket.pro @@ -1,3 +1,3 @@ TEMPLATE = subdirs SUBDIRS = lackey test -!wince*: SUBDIRS += example +!wince*:!symbian*: SUBDIRS += example diff --git a/tests/auto/qlocalsocket/test/test.pro b/tests/auto/qlocalsocket/test/test.pro index 7befdf9..503f769 100644 --- a/tests/auto/qlocalsocket/test/test.pro +++ b/tests/auto/qlocalsocket/test/test.pro @@ -2,11 +2,14 @@ load(qttest_p4) DEFINES += QLOCALSERVER_DEBUG DEFINES += QLOCALSOCKET_DEBUG -!wince*: { - DEFINES += SRCDIR=\\\"$$PWD/../\\\" -} else { + +symbian { + # nothing +} else:wince* { DEFINES += QT_LOCALSOCKET_TCP DEFINES += SRCDIR=\\\"../\\\" +} else { + DEFINES += SRCDIR=\\\"$$PWD/../\\\" } QT = core network @@ -27,6 +30,16 @@ CONFIG(debug_and_release) { wince* { additionalFiles.sources = ../lackey/lackey.exe additionalFiles.path = lackey +} + +symbian { + additionalFiles.sources = lackey.exe + additionalFiles.path = \sys\bin + TARGET.UID3 = 0xE0340005 + DEFINES += SYMBIAN_SRCDIR_UID=$$lower($$replace(TARGET.UID3,"0x","")) +} + +wince*|symbian { scriptFiles.sources = ../lackey/scripts/*.js scriptFiles.path = lackey/scripts DEPLOYMENT = additionalFiles scriptFiles diff --git a/tests/auto/qlocalsocket/tst_qlocalsocket.cpp b/tests/auto/qlocalsocket/tst_qlocalsocket.cpp index 98e9023..bdd2efa 100644 --- a/tests/auto/qlocalsocket/tst_qlocalsocket.cpp +++ b/tests/auto/qlocalsocket/tst_qlocalsocket.cpp @@ -47,9 +47,16 @@ #include <QtNetwork/qlocalserver.h> #include "../../shared/util.h" +#ifdef Q_OS_SYMBIAN + #include <unistd.h> +#endif //TESTED_CLASS=QLocalServer, QLocalSocket //TESTED_FILES=network/socket/qlocalserver.cpp network/socket/qlocalsocket.cpp - +#ifdef Q_OS_SYMBIAN + #define STRINGIFY(x) #x + #define TOSTRING(x) STRINGIFY(x) + #define SRCDIR "C:/Private/" TOSTRING(SYMBIAN_SRCDIR_UID) "/" +#endif Q_DECLARE_METATYPE(QLocalSocket::LocalSocketError) Q_DECLARE_METATYPE(QLocalSocket::LocalSocketState) @@ -80,8 +87,6 @@ private slots: void sendData_data(); void sendData(); - void readBufferOverflow(); - void fullPath(); void hitMaximumConnections_data(); @@ -97,17 +102,17 @@ private slots: void longPath(); void waitForDisconnect(); - void waitForDisconnectByServer(); void removeServer(); void recycleServer(); - void multiConnect(); - void writeOnlySocket(); - void debug(); +#ifdef Q_OS_SYMBIAN +private: + void unlink(QString serverName); +#endif }; tst_QLocalSocket::tst_QLocalSocket() @@ -142,13 +147,7 @@ public: LocalServer() : QLocalServer() { connect(this, SIGNAL(newConnection()), this, SLOT(slotNewConnection())); - } - - bool listen(const QString &name) - { - removeServer(name); - return QLocalServer::listen(name); - } + }; QList<int> hits; @@ -294,6 +293,9 @@ void tst_QLocalSocket::listen() QSignalSpy spyNewConnection(&server, SIGNAL(newConnection())); QFETCH(QString, name); +#ifdef Q_OS_SYMBIAN + unlink(name); +#endif QFETCH(bool, canListen); QFETCH(bool, close); QVERIFY2((server.listen(name) == canListen), server.errorString().toLatin1().constData()); @@ -344,7 +346,9 @@ void tst_QLocalSocket::listenAndConnect() QFETCH(QString, name); QFETCH(bool, canListen); - +#ifdef Q_OS_SYMBIAN + unlink(name); +#endif QCOMPARE(server.listen(name), canListen); QTest::qWait(1000); //QVERIFY(!server.errorString().isEmpty()); @@ -364,7 +368,7 @@ void tst_QLocalSocket::listenAndConnect() QSignalSpy spyReadyRead(socket, SIGNAL(readyRead())); socket->connectToServer(name); -#ifdef QT_LOCALSOCKET_TCP +#if defined(QT_LOCALSOCKET_TCP) QTest::qWait(250); #endif @@ -467,6 +471,9 @@ void tst_QLocalSocket::sendData_data() void tst_QLocalSocket::sendData() { QFETCH(QString, name); +#ifdef Q_OS_SYMBIAN + unlink(name); +#endif QFETCH(bool, canListen); LocalServer server; @@ -484,8 +491,10 @@ void tst_QLocalSocket::sendData() // test creating a connection socket.connectToServer(name); bool timedOut = true; + QCOMPARE(server.waitForNewConnection(3000, &timedOut), canListen); -#ifdef QT_LOCALSOCKET_TCP + +#if defined(QT_LOCALSOCKET_TCP) QTest::qWait(250); #endif QVERIFY(!timedOut); @@ -495,7 +504,11 @@ void tst_QLocalSocket::sendData() // test sending/receiving data if (server.hasPendingConnections()) { QString testLine = "test"; +#ifdef Q_OS_SYMBIAN + for (int i = 0; i < 25 * 1024; ++i) +#else for (int i = 0; i < 50000; ++i) +#endif testLine += "a"; QLocalSocket *serverSocket = server.nextPendingConnection(); QVERIFY(serverSocket); @@ -516,7 +529,9 @@ void tst_QLocalSocket::sendData() QCOMPARE(spyReadyRead.count(), 1); QVERIFY(testLine.startsWith(in.readLine())); + QVERIFY(wrote || serverSocket->waitForBytesWritten(1000)); + QCOMPARE(serverSocket->errorString(), QString("Unknown error")); QCOMPARE(socket.errorString(), QString("Unknown error")); } @@ -534,46 +549,14 @@ void tst_QLocalSocket::sendData() QCOMPARE(spy.count(), (canListen ? 1 : 0)); } -void tst_QLocalSocket::readBufferOverflow() -{ - const int readBufferSize = 128; - const int dataBufferSize = readBufferSize * 2; - const QString serverName = QLatin1String("myPreciousTestServer"); - LocalServer server; - server.listen(serverName); - QVERIFY(server.isListening()); - - LocalSocket client; - client.setReadBufferSize(readBufferSize); - client.connectToServer(serverName); - - bool timedOut = true; - QVERIFY(server.waitForNewConnection(3000, &timedOut)); - QVERIFY(!timedOut); - - QCOMPARE(client.state(), QLocalSocket::ConnectedState); - QVERIFY(server.hasPendingConnections()); - - QLocalSocket* serverSocket = server.nextPendingConnection(); - char buffer[dataBufferSize]; - memset(buffer, 0, dataBufferSize); - serverSocket->write(buffer, dataBufferSize); - serverSocket->flush(); - - QVERIFY(client.waitForReadyRead()); - QCOMPARE(client.read(buffer, readBufferSize), qint64(readBufferSize)); -#ifdef QT_LOCALSOCKET_TCP - QTest::qWait(250); -#endif - QCOMPARE(client.read(buffer, readBufferSize), qint64(readBufferSize)); -} - // QLocalSocket/Server can take a name or path, check that it works as expected void tst_QLocalSocket::fullPath() { - LocalServer server; + QLocalServer server; QString name = "qlocalsocket_pathtest"; -#if defined(QT_LOCALSOCKET_TCP) +#if defined(Q_OS_SYMBIAN) + QString path = ""; +#elif defined(QT_LOCALSOCKET_TCP) QString path = "QLocalServer"; #elif defined(Q_OS_WIN) QString path = "\\\\.\\pipe\\"; @@ -587,6 +570,7 @@ void tst_QLocalSocket::fullPath() LocalSocket socket; socket.connectToServer(serverName); + QCOMPARE(socket.serverName(), serverName); QCOMPARE(socket.fullServerName(), serverName); socket.disconnectFromServer(); @@ -610,6 +594,9 @@ void tst_QLocalSocket::hitMaximumConnections() QFETCH(int, max); LocalServer server; QString name = "tst_localsocket"; +#ifdef Q_OS_SYMBIAN + unlink(name); +#endif server.setMaxPendingConnections(max); QVERIFY2(server.listen(name), server.errorString().toLatin1().constData()); int connections = server.maxPendingConnections() + 1; @@ -723,20 +710,30 @@ void tst_QLocalSocket::threadedConnection_data() void tst_QLocalSocket::threadedConnection() { +#ifdef Q_OS_SYMBIAN + unlink("qlocalsocket_threadtest"); +#endif + QFETCH(int, threads); Server server; +#if defined(Q_OS_SYMBIAN) + server.setStackSize(0x14000); +#endif server.clients = threads; server.start(); QList<Client*> clients; for (int i = 0; i < threads; ++i) { clients.append(new Client()); +#if defined(Q_OS_SYMBIAN) + clients.last()->setStackSize(0x14000); +#endif clients.last()->start(); } server.wait(); while (!clients.isEmpty()) { - QVERIFY(clients.first()->wait(30000)); + QVERIFY(clients.first()->wait(3000)); Client *client =clients.takeFirst(); client->terminate(); delete client; @@ -759,7 +756,7 @@ void tst_QLocalSocket::processConnection_data() */ void tst_QLocalSocket::processConnection() { -#if defined(QT_NO_PROCESS) +#if defined(QT_NO_PROCESS) || defined(Q_CC_NOKIAX86) QSKIP("Qt was compiled with QT_NO_PROCESS", SkipAll); #else QFETCH(int, processes); @@ -814,6 +811,9 @@ void tst_QLocalSocket::longPath() void tst_QLocalSocket::waitForDisconnect() { QString name = "tst_localsocket"; +#ifdef Q_OS_SYMBIAN + unlink(name); +#endif LocalServer server; QVERIFY(server.listen(name)); LocalSocket socket; @@ -829,25 +829,6 @@ void tst_QLocalSocket::waitForDisconnect() QVERIFY(timer.elapsed() < 2000); } -void tst_QLocalSocket::waitForDisconnectByServer() -{ - QString name = "tst_localsocket"; - LocalServer server; - QVERIFY(server.listen(name)); - LocalSocket socket; - QSignalSpy spy(&socket, SIGNAL(disconnected())); - QVERIFY(spy.isValid()); - socket.connectToServer(name); - QVERIFY(socket.waitForConnected(3000)); - QVERIFY(server.waitForNewConnection(3000)); - QLocalSocket *serverSocket = server.nextPendingConnection(); - QVERIFY(serverSocket); - serverSocket->close(); - QVERIFY(serverSocket->state() == QLocalSocket::UnconnectedState); - QVERIFY(socket.waitForDisconnected(3000)); - QCOMPARE(spy.count(), 1); -} - void tst_QLocalSocket::removeServer() { // this is a hostile takeover, but recovering from a crash results in the same @@ -865,7 +846,11 @@ void tst_QLocalSocket::removeServer() void tst_QLocalSocket::recycleServer() { - LocalServer server; +#ifdef Q_OS_SYMBIAN + unlink("recycletest1"); +#endif + + QLocalServer server; QLocalSocket client; QVERIFY(server.listen("recycletest1")); @@ -885,54 +870,35 @@ void tst_QLocalSocket::recycleServer() QVERIFY(server.nextPendingConnection() != 0); } -void tst_QLocalSocket::multiConnect() +void tst_QLocalSocket::debug() { - QLocalServer server; - QLocalSocket client1; - QLocalSocket client2; - QLocalSocket client3; - - QVERIFY(server.listen("multiconnect")); - - client1.connectToServer("multiconnect"); - client2.connectToServer("multiconnect"); - client3.connectToServer("multiconnect"); - - QVERIFY(client1.waitForConnected(201)); - QVERIFY(client2.waitForConnected(202)); - QVERIFY(client3.waitForConnected(203)); - - QVERIFY(server.waitForNewConnection(201)); - QVERIFY(server.nextPendingConnection() != 0); - QVERIFY(server.waitForNewConnection(202)); - QVERIFY(server.nextPendingConnection() != 0); - QVERIFY(server.waitForNewConnection(203)); - QVERIFY(server.nextPendingConnection() != 0); + // Make sure this compiles + qDebug() << QLocalSocket::ConnectionRefusedError << QLocalSocket::UnconnectedState; } -void tst_QLocalSocket::writeOnlySocket() +#ifdef Q_OS_SYMBIAN +void tst_QLocalSocket::unlink(QString name) { - QLocalServer server; - QVERIFY(server.listen("writeOnlySocket")); - - QLocalSocket client; - client.connectToServer("writeOnlySocket", QIODevice::WriteOnly); - QVERIFY(client.waitForConnected()); + if(name.length() == 0) + return; - QVERIFY(server.waitForNewConnection()); - QLocalSocket* serverSocket = server.nextPendingConnection(); - QVERIFY(serverSocket); + QString fullName; + // determine the full server path + if (name.startsWith(QLatin1Char('/'))) { + fullName = name; + } else { + fullName = QDir::cleanPath(QDir::tempPath()); + fullName += QLatin1Char('/') + name; + fullName = QDir::toNativeSeparators(fullName); + } - QCOMPARE(client.bytesAvailable(), qint64(0)); - QCOMPARE(client.state(), QLocalSocket::ConnectedState); -} + int result = ::unlink(fullName.toUtf8().data()); -void tst_QLocalSocket::debug() -{ - // Make sure this compiles - qDebug() << QLocalSocket::ConnectionRefusedError << QLocalSocket::UnconnectedState; + if(result != 0) { + qWarning() << "Unlinking " << fullName << " failed with " << strerror(errno); + } } - +#endif QTEST_MAIN(tst_QLocalSocket) #include "tst_qlocalsocket.moc" diff --git a/tests/auto/qmainwindow/qmainwindow.pro b/tests/auto/qmainwindow/qmainwindow.pro index b1cbd16..43d73ae 100644 --- a/tests/auto/qmainwindow/qmainwindow.pro +++ b/tests/auto/qmainwindow/qmainwindow.pro @@ -1,5 +1,6 @@ load(qttest_p4) SOURCES += tst_qmainwindow.cpp - +# Symbian toolchain does not support correct include semantics +symbian:INCPATH+=..\..\..\include\QtGui\private diff --git a/tests/auto/qmap/qmap.pro b/tests/auto/qmap/qmap.pro index 5b61272..00b84d1 100644 --- a/tests/auto/qmap/qmap.pro +++ b/tests/auto/qmap/qmap.pro @@ -3,6 +3,4 @@ load(qttest_p4) QT = core SOURCES += tst_qmap.cpp - - - +QT = core diff --git a/tests/auto/qmenu/tst_qmenu.cpp b/tests/auto/qmenu/tst_qmenu.cpp index 90b9a2a..8590eac 100644 --- a/tests/auto/qmenu/tst_qmenu.cpp +++ b/tests/auto/qmenu/tst_qmenu.cpp @@ -266,6 +266,9 @@ tst_QMenu::addActionsAndClear() void tst_QMenu::mouseActivation() { +#ifdef Q_OS_WINCE_WM + QSKIP("We have a separate mouseActivation test for Windows mobile.", SkipAll); +#endif QMenu menu; menu.addAction("Menu Action"); menu.show(); @@ -425,8 +428,11 @@ void tst_QMenu::overrideMenuAction() QSKIP("On Mac, we need to create native key events to test menu action activation", SkipAll); #elif defined(Q_OS_WINCE) QSKIP("On Windows CE, we need to create native key events to test menu action activation", SkipAll); +#elif defined(Q_OS_SYMBIAN) + QSKIP("On Symbian OS, we need to create native key events to test menu action activation", SkipAll); #endif - QAction *aQuit = new QAction("Quit", &w); + + QAction *aQuit = new QAction("Quit", &w); aQuit->setShortcut(QKeySequence("Ctrl+X")); m->addAction(aQuit); @@ -443,7 +449,7 @@ void tst_QMenu::overrideMenuAction() delete aFileMenu; - //after the deletion of the override menu action, + //after the deletion of the override menu action, //the menu should have its default menu action back QCOMPARE(m->menuAction(), menuaction); @@ -472,7 +478,7 @@ void tst_QMenu::statusTip() QVERIFY(btn != NULL); - //because showMenu calls QMenu::exec, we need to use a singleshot + //because showMenu calls QMenu::exec, we need to use a singleshot //to continue the test QTimer::singleShot(200,this, SLOT(onStatusTipTimer())); btn->showMenu(); @@ -486,10 +492,10 @@ void tst_QMenu::onStatusTipTimer() QVERIFY(menu != 0); QVERIFY(menu->isVisible()); QTest::keyClick(menu, Qt::Key_Down); - + //we store the statustip to press escape in any case //otherwise, if the test fails it blocks (never gets out of QMenu::exec - const QString st=statustip; + const QString st=statustip; menu->close(); //goes out of the menu @@ -554,10 +560,10 @@ void tst_QMenu::tearOff() menu->popup(QPoint(0,0)); QTest::qWait(50); QVERIFY(!menu->isTearOffMenuVisible()); - + QTest::mouseClick(menu, Qt::LeftButton, 0, QPoint(3, 3), 10); QTest::qWait(100); - + QVERIFY(menu->isTearOffMenuVisible()); QPointer<QMenu> torn = 0; foreach (QWidget *w, QApplication::allWidgets()) { @@ -640,7 +646,11 @@ void tst_QMenu::activeSubMenuPosition() main->setActiveAction(menuAction); sub->setActiveAction(subAction); +#ifdef Q_OS_SYMBIAN + main->popup(QPoint(50,200)); +#else main->popup(QPoint(200,200)); +#endif QVERIFY(main->isVisible()); QCOMPARE(main->activeAction(), menuAction); diff --git a/tests/auto/qmenubar/qmenubar.pro b/tests/auto/qmenubar/qmenubar.pro index 51cf21d..a0a6420 100644 --- a/tests/auto/qmenubar/qmenubar.pro +++ b/tests/auto/qmenubar/qmenubar.pro @@ -2,5 +2,5 @@ load(qttest_p4) HEADERS += SOURCES += tst_qmenubar.cpp -contains(QT_CONFIG, qt3support):QT += qt3support +contains(QT_CONFIG, qt3support):!symbian*:QT += qt3support diff --git a/tests/auto/qmenubar/tst_qmenubar.cpp b/tests/auto/qmenubar/tst_qmenubar.cpp index ec8ff5f..8c77933 100644 --- a/tests/auto/qmenubar/tst_qmenubar.cpp +++ b/tests/auto/qmenubar/tst_qmenubar.cpp @@ -466,6 +466,10 @@ void tst_QMenuBar::accel_noQt3() #if defined(Q_WS_MAC) || defined(Q_OS_WINCE_WM) QSKIP("On Mac/WinCE, native key events are needed to test menu action activation", SkipAll); #endif +#ifdef Q_OS_SYMBIAN + QSKIP("On Symbian OS, native key events are needed to test menu action activation", SkipAll); +#endif + // create a popup menu with menu items set the accelerators later... initSimpleMenubar_noQt3(); // QTest::keyClick( 0, Qt::Key_A, AltKey ); diff --git a/tests/auto/qmetatype/qmetatype.pro b/tests/auto/qmetatype/qmetatype.pro index 20ec3b8..a84d238 100644 --- a/tests/auto/qmetatype/qmetatype.pro +++ b/tests/auto/qmetatype/qmetatype.pro @@ -1,6 +1,3 @@ load(qttest_p4) SOURCES += tst_qmetatype.cpp - QT = core - - diff --git a/tests/auto/qmouseevent/tst_qmouseevent.cpp b/tests/auto/qmouseevent/tst_qmouseevent.cpp index 4cfb4f5..9e9f76c 100644 --- a/tests/auto/qmouseevent/tst_qmouseevent.cpp +++ b/tests/auto/qmouseevent/tst_qmouseevent.cpp @@ -205,7 +205,7 @@ void tst_QMouseEvent::checkMousePressEvent() int buttons = button; int modifiers = keyPressed; - QTest::mousePress(testMouseWidget, (Qt::MouseButton)buttonPressed, (Qt::KeyboardModifiers)keyPressed); + QTest::mousePress(testMouseWidget, Qt::MouseButton(buttonPressed), Qt::KeyboardModifiers(keyPressed)); QVERIFY(testMouseWidget->mousePressEventRecieved); QCOMPARE(testMouseWidget->mousePressButton, button); QCOMPARE(testMouseWidget->mousePressButtons, buttons); @@ -218,7 +218,7 @@ void tst_QMouseEvent::checkMousePressEvent() QCOMPARE(testMouseWidget->mousePressStateAfter, stateAfter); #endif - QTest::mouseRelease(testMouseWidget, (Qt::MouseButton)buttonPressed, (Qt::KeyboardModifiers)keyPressed); + QTest::mouseRelease(testMouseWidget, Qt::MouseButton(buttonPressed), Qt::KeyboardModifiers(keyPressed)); } void tst_QMouseEvent::checkMouseReleaseEvent_data() @@ -251,7 +251,7 @@ void tst_QMouseEvent::checkMouseReleaseEvent() int buttons = 0; int modifiers = keyPressed; - QTest::mouseClick(testMouseWidget, (Qt::MouseButton)buttonReleased, (Qt::KeyboardModifiers)keyPressed); + QTest::mouseClick(testMouseWidget, Qt::MouseButton(buttonReleased), Qt::KeyboardModifiers(keyPressed)); QVERIFY(testMouseWidget->mouseReleaseEventRecieved); QCOMPARE(testMouseWidget->mouseReleaseButton, button); QCOMPARE(testMouseWidget->mouseReleaseButtons, buttons); diff --git a/tests/auto/qmovie/qmovie.pro b/tests/auto/qmovie/qmovie.pro index 765966e..15f0c83 100644 --- a/tests/auto/qmovie/qmovie.pro +++ b/tests/auto/qmovie/qmovie.pro @@ -12,3 +12,13 @@ wince*: { DEPLOYMENT += addFiles } + +symbian*: { + addFiles.sources = animations\* + addFiles.path = animations + DEPLOYMENT += addFiles + + imagePlugins.sources = qjpeg.dll qgif.dll qmng.dll + imagePlugins.path = imageformats + DEPLOYMENT += imagePlugins +}
\ No newline at end of file diff --git a/tests/auto/qmultiscreen/qmultiscreen.pro b/tests/auto/qmultiscreen/qmultiscreen.pro index 30666d7..4e92a65 100644 --- a/tests/auto/qmultiscreen/qmultiscreen.pro +++ b/tests/auto/qmultiscreen/qmultiscreen.pro @@ -1,5 +1,6 @@ load(qttest_p4) SOURCES += tst_qmultiscreen.cpp +QT = core requires(embedded) diff --git a/tests/auto/qmutex/qmutex.pro b/tests/auto/qmutex/qmutex.pro index e52f947..bd24dcb 100644 --- a/tests/auto/qmutex/qmutex.pro +++ b/tests/auto/qmutex/qmutex.pro @@ -1,5 +1,3 @@ load(qttest_p4) SOURCES += tst_qmutex.cpp QT = core - - diff --git a/tests/auto/qmutexlocker/qmutexlocker.pro b/tests/auto/qmutexlocker/qmutexlocker.pro index f921308..ff8a3da 100644 --- a/tests/auto/qmutexlocker/qmutexlocker.pro +++ b/tests/auto/qmutexlocker/qmutexlocker.pro @@ -1,5 +1,3 @@ load(qttest_p4) SOURCES += tst_qmutexlocker.cpp QT = core - - diff --git a/tests/auto/qnativesocketengine/tst_qnativesocketengine.cpp b/tests/auto/qnativesocketengine/tst_qnativesocketengine.cpp index 20874f3..ef285f6 100644 --- a/tests/auto/qnativesocketengine/tst_qnativesocketengine.cpp +++ b/tests/auto/qnativesocketengine/tst_qnativesocketengine.cpp @@ -102,11 +102,11 @@ private slots: tst_QNativeSocketEngine::tst_QNativeSocketEngine() { + Q_SET_DEFAULT_IAP } tst_QNativeSocketEngine::~tst_QNativeSocketEngine() { - } void tst_QNativeSocketEngine::init() @@ -173,7 +173,7 @@ void tst_QNativeSocketEngine::simpleConnectToIMAP() QVERIFY(socketDevice.read(array.data(), array.size()) == available); // Check that the greeting is what we expect it to be - QCOMPARE(array.constData(), "* OK [CAPABILITY IMAP4 IMAP4rev1 LITERAL+ ID STARTTLS LOGINDISABLED] qt-test-server.qt-test-net Cyrus IMAP4 v2.3.11-Mandriva-RPM-2.3.11-6mdv2008.1 server ready\r\n"); + QCOMPARE(array.constData(), QtNetworkSettings::expectedReplyIMAP().constData()); // Write a logout message QByteArray array2 = "ZZZ LOGOUT\r\n"; @@ -204,6 +204,9 @@ void tst_QNativeSocketEngine::simpleConnectToIMAP() //--------------------------------------------------------------------------- void tst_QNativeSocketEngine::udpLoopbackTest() { +#ifdef SYMBIAN_WINSOCK_CONNECTIVITY + QSKIP("Not working on Emulator without WinPCAP", SkipAll); +#endif QNativeSocketEngine udpSocket; // Initialize device #1 @@ -252,6 +255,9 @@ void tst_QNativeSocketEngine::udpLoopbackTest() //--------------------------------------------------------------------------- void tst_QNativeSocketEngine::udpIPv6LoopbackTest() { +#if defined(Q_OS_SYMBIAN) + QSKIP("Symbian: IPv6 is not yet supported", SkipAll); +#endif QNativeSocketEngine udpSocket; // Initialize device #1 @@ -396,6 +402,9 @@ void tst_QNativeSocketEngine::serverTest() //--------------------------------------------------------------------------- void tst_QNativeSocketEngine::udpLoopbackPerformance() { +#ifdef SYMBIAN_WINSOCK_CONNECTIVITY + QSKIP("Not working on Emulator without WinPCAP", SkipAll); +#endif QNativeSocketEngine udpSocket; // Initialize device #1 @@ -553,7 +562,7 @@ void tst_QNativeSocketEngine::tooManySockets() //--------------------------------------------------------------------------- void tst_QNativeSocketEngine::bind() { -#ifndef Q_OS_WIN +#if !defined Q_OS_WIN && !defined Q_OS_SYMBIAN QNativeSocketEngine binder; QVERIFY(binder.initialize(QAbstractSocket::TcpSocket, QAbstractSocket::IPv4Protocol)); QVERIFY(!binder.bind(QHostAddress::Any, 82)); @@ -567,7 +576,13 @@ void tst_QNativeSocketEngine::bind() QNativeSocketEngine binder3; QVERIFY(binder3.initialize(QAbstractSocket::TcpSocket, QAbstractSocket::IPv4Protocol)); QVERIFY(!binder3.bind(QHostAddress::Any, 31180)); + +#ifdef SYMBIAN_WINSOCK_CONNECTIVITY + qDebug("On Symbian Emulator (WinSock) we get EADDRNOTAVAIL instead of EADDRINUSE"); + QVERIFY(binder3.error() == QAbstractSocket::SocketAddressNotAvailableError); +#else QVERIFY(binder3.error() == QAbstractSocket::AddressInUseError); +#endif } //--------------------------------------------------------------------------- @@ -577,7 +592,7 @@ void tst_QNativeSocketEngine::networkError() QVERIFY(client.initialize(QAbstractSocket::TcpSocket, QAbstractSocket::IPv4Protocol)); - const bool isConnected = client.connectToHost(QHostAddress(QtNetworkSettings::serverIP()), 143); + const bool isConnected = client.connectToHost(QtNetworkSettings::serverIP(), 143); if (!isConnected) { QVERIFY(client.state() == QAbstractSocket::ConnectingState); QVERIFY(client.waitForWrite()); diff --git a/tests/auto/qnetworkaccessmanager_and_qprogressdialog/tst_qnetworkaccessmanager_and_qprogressdialog.cpp b/tests/auto/qnetworkaccessmanager_and_qprogressdialog/tst_qnetworkaccessmanager_and_qprogressdialog.cpp index 197651a..eb72f64 100644 --- a/tests/auto/qnetworkaccessmanager_and_qprogressdialog/tst_qnetworkaccessmanager_and_qprogressdialog.cpp +++ b/tests/auto/qnetworkaccessmanager_and_qprogressdialog/tst_qnetworkaccessmanager_and_qprogressdialog.cpp @@ -53,7 +53,9 @@ class tst_QNetworkAccessManager_And_QProgressDialog : public QObject { -Q_OBJECT + Q_OBJECT +public: + tst_QNetworkAccessManager_And_QProgressDialog(); private slots: void downloadCheck(); }; @@ -110,6 +112,11 @@ private: QNetworkAccessManager netmanager; }; +tst_QNetworkAccessManager_And_QProgressDialog::tst_QNetworkAccessManager_And_QProgressDialog() +{ + Q_SET_DEFAULT_IAP +} + void tst_QNetworkAccessManager_And_QProgressDialog::downloadCheck() { DownloadCheckWidget widget; diff --git a/tests/auto/qnetworkinterface/tst_qnetworkinterface.cpp b/tests/auto/qnetworkinterface/tst_qnetworkinterface.cpp index e69e4dc..4783a29 100644 --- a/tests/auto/qnetworkinterface/tst_qnetworkinterface.cpp +++ b/tests/auto/qnetworkinterface/tst_qnetworkinterface.cpp @@ -68,12 +68,14 @@ private slots: tst_QNetworkInterface::tst_QNetworkInterface() { + Q_SET_DEFAULT_IAP } tst_QNetworkInterface::~tst_QNetworkInterface() { } + void tst_QNetworkInterface::dump() { // This is for manual testing: @@ -125,6 +127,10 @@ void tst_QNetworkInterface::loopbackIPv4() void tst_QNetworkInterface::loopbackIPv6() { +#ifdef Q_OS_SYMBIAN + QSKIP( "Symbian: IPv6 is not yet supported", SkipAll ); +#else + QList<QHostAddress> all = QNetworkInterface::allAddresses(); bool loopbackfound = false; @@ -136,8 +142,9 @@ void tst_QNetworkInterface::loopbackIPv6() break; } else if (addr.protocol() == QAbstractSocket::IPv6Protocol) anyIPv6 = true; - + QVERIFY(!anyIPv6 || loopbackfound); +#endif } void tst_QNetworkInterface::localAddress() diff --git a/tests/auto/qnetworkreply/.gitattributes b/tests/auto/qnetworkreply/.gitattributes index f0cae99..80252cf 100644 --- a/tests/auto/qnetworkreply/.gitattributes +++ b/tests/auto/qnetworkreply/.gitattributes @@ -1,2 +1,3 @@ -rfc3252.txt -crlf -bigfile -crlf +rfc3252.txt -crlf +bigfile -crlf +resource -crlf diff --git a/tests/auto/qnetworkreply/echo/echo.pro b/tests/auto/qnetworkreply/echo/echo.pro index bf791ff..74b0bfc 100644 --- a/tests/auto/qnetworkreply/echo/echo.pro +++ b/tests/auto/qnetworkreply/echo/echo.pro @@ -3,4 +3,4 @@ QT = core CONFIG -= app_bundle debug_and_release_target CONFIG += console - +symbian:TARGET.CAPABILITY="ALL -TCB" diff --git a/tests/auto/qnetworkreply/test/test.pro b/tests/auto/qnetworkreply/test/test.pro index 71f76a2..e0df503 100644 --- a/tests/auto/qnetworkreply/test/test.pro +++ b/tests/auto/qnetworkreply/test/test.pro @@ -10,7 +10,7 @@ win32 { } } -DEFINES += SRCDIR=\\\"$$PWD/..\\\" +!symbian:DEFINES += SRCDIR=\\\"$$PWD/..\\\" QT = core network RESOURCES += ../qnetworkreply.qrc @@ -20,3 +20,15 @@ wince*: { addFiles.path = . DEPLOYMENT += addFiles } + +symbian:{ + addFiles.sources = ../empty ../rfc3252.txt ../resource ../bigfile + addFiles.path = . + DEPLOYMENT += addFiles + + # Symbian toolchain does not support correct include semantics + INCPATH+=..\..\..\..\include\QtNetwork\private + # bigfile test case requires more heap + TARGET.EPOCHEAPSIZE="0x100 0x1000000" + TARGET.CAPABILITY="ALL -TCB" +} diff --git a/tests/auto/qnetworkreply/tst_qnetworkreply.cpp b/tests/auto/qnetworkreply/tst_qnetworkreply.cpp index 7a9d016..645734e 100644 --- a/tests/auto/qnetworkreply/tst_qnetworkreply.cpp +++ b/tests/auto/qnetworkreply/tst_qnetworkreply.cpp @@ -68,8 +68,16 @@ #include "private/qnetworkaccessmanager_p.h" +#ifdef Q_OS_SYMBIAN +// In Symbian OS test data is located in applications private dir +// Current path (C:\private\<UID>) contains only ascii chars +//#define SRCDIR QDir::currentPath() +#define SRCDIR "." +#endif + #include "../network-settings.h" + Q_DECLARE_METATYPE(QNetworkReply*) Q_DECLARE_METATYPE(QAuthenticator*) Q_DECLARE_METATYPE(QNetworkProxy) @@ -119,6 +127,7 @@ class tst_QNetworkReply: public QObject public: tst_QNetworkReply(); + ~tst_QNetworkReply(); QString runSimpleRequest(QNetworkAccessManager::Operation op, const QNetworkRequest &request, QNetworkReplyPtr &reply, const QByteArray &data = QByteArray()); @@ -513,11 +522,22 @@ public: QTcpSocket *active = new QTcpSocket(this); active->connectToHost("127.0.0.1", server.serverPort()); +#ifndef Q_OS_SYMBIAN + // need more time as working with embedded + // device and testing from emualtor + // things tend to get slower + if (!active->waitForConnected(1000)) + return false; + + if (!server.waitForNewConnection(1000)) + return false; +#else if (!active->waitForConnected(100)) return false; if (!server.waitForNewConnection(100)) return false; +#endif QTcpSocket *passive = server.nextPendingConnection(); passive->setParent(this); @@ -926,6 +946,8 @@ public slots: tst_QNetworkReply::tst_QNetworkReply() { + Q_SET_DEFAULT_IAP + testFileName = QDir::currentPath() + "/testfile"; #ifndef Q_OS_WINCE uniqueExtension = QString("%1%2%3").arg((qulonglong)this).arg(rand()).arg((qulonglong)time(0)); @@ -954,6 +976,9 @@ tst_QNetworkReply::tst_QNetworkReply() } } +tst_QNetworkReply::~tst_QNetworkReply() +{ +} void tst_QNetworkReply::authenticationRequired(QNetworkReply*, QAuthenticator* auth) @@ -1121,7 +1146,7 @@ void tst_QNetworkReply::invalidProtocol() void tst_QNetworkReply::getFromData_data() { - QTest::addColumn<QString>("request"); + QTest::addColumn<QString>("request"); QTest::addColumn<QByteArray>("expected"); QTest::addColumn<QString>("mimeType"); @@ -1217,7 +1242,7 @@ void tst_QNetworkReply::getFromData() void tst_QNetworkReply::getFromFile() { - // create the file: + // create the file: QTemporaryFile file(QDir::currentPath() + "/temp-XXXXXX"); file.setAutoRemove(true); QVERIFY(file.open()); @@ -1269,7 +1294,7 @@ void tst_QNetworkReply::getFromFileSpecial_data() void tst_QNetworkReply::getFromFileSpecial() { - QFETCH(QString, fileName); + QFETCH(QString, fileName); QFETCH(QString, url); // open the resource so we can find out its size @@ -1299,7 +1324,7 @@ void tst_QNetworkReply::getFromFtp_data() void tst_QNetworkReply::getFromFtp() { - QFETCH(QString, referenceName); + QFETCH(QString, referenceName); QFETCH(QString, url); QFile reference(referenceName); @@ -1328,7 +1353,7 @@ void tst_QNetworkReply::getFromHttp_data() void tst_QNetworkReply::getFromHttp() { - QFETCH(QString, referenceName); + QFETCH(QString, referenceName); QFETCH(QString, url); QFile reference(referenceName); @@ -1366,7 +1391,7 @@ void tst_QNetworkReply::getErrors_data() << int(QNetworkReply::ContentOperationNotPermittedError) << 0 << true; QTest::newRow("file-exist") << QUrl::fromLocalFile(QDir::currentPath() + "/this-file-doesnt-exist.txt").toString() << int(QNetworkReply::ContentNotFoundError) << 0 << true; -#if !defined Q_OS_WIN +#if !defined Q_OS_WIN && !defined(Q_OS_SYMBIAN) QTest::newRow("file-is-wronly") << QUrl::fromLocalFile(wronlyFileName).toString() << int(QNetworkReply::ContentAccessDenied) << 0 << true; #endif @@ -2526,7 +2551,6 @@ void tst_QNetworkReply::ioGetWithManyProxies() connect(&manager, SIGNAL(sslErrors(QNetworkReply*,QList<QSslError>)), SLOT(sslErrors(QNetworkReply*,QList<QSslError>))); #endif - QTestEventLoop::instance().enterLoop(10); QVERIFY(!QTestEventLoop::instance().timeout()); @@ -2693,18 +2717,19 @@ void tst_QNetworkReply::ioPutToFileFromProcess_data() void tst_QNetworkReply::ioPutToFileFromProcess() { -#if defined(Q_OS_WINCE) - QSKIP("Currently no stdin/out supported for Windows CE", SkipAll); +#if defined(Q_OS_WINCE) || defined (Q_OS_SYMBIAN) + QSKIP("Currently no stdin/out supported for Windows CE / Symbian OS", SkipAll); #endif + #ifdef Q_OS_WIN if (qstrcmp(QTest::currentDataTag(), "small") == 0) QSKIP("When passing a CR-LF-LF sequence through Windows stdio, it gets converted, " "so this test fails. Disabled on Windows", SkipSingle); #endif + #if defined(QT_NO_PROCESS) QSKIP("Qt was compiled with QT_NO_PROCESS", SkipAll); #else - QFile file(testFileName); QUrl url = QUrl::fromLocalFile(file.fileName()); @@ -2934,7 +2959,11 @@ void tst_QNetworkReply::ioPostToHttpFromSocket() QSignalSpy authenticationRequiredSpy(&manager, SIGNAL(authenticationRequired(QNetworkReply*,QAuthenticator*))); QSignalSpy proxyAuthenticationRequiredSpy(&manager, SIGNAL(proxyAuthenticationRequired(QNetworkProxy,QAuthenticator*))); +#ifdef Q_OS_SYMBIAN + QTestEventLoop::instance().enterLoop(6); +#else QTestEventLoop::instance().enterLoop(3); +#endif disconnect(&manager, SIGNAL(proxyAuthenticationRequired(QNetworkProxy,QAuthenticator*)), this, SLOT(proxyAuthenticationRequired(QNetworkProxy,QAuthenticator*))); @@ -3234,7 +3263,6 @@ void tst_QNetworkReply::downloadPerformance() { // unlike the above function, this one tries to send as fast as possible // and measures how fast it was. - TimedSender sender(5000); QNetworkRequest request("debugpipe://127.0.0.1:" + QString::number(sender.serverPort()) + "/?bare=1"); QNetworkReplyPtr reply = manager.get(request); @@ -3270,7 +3298,12 @@ void tst_QNetworkReply::uploadPerformance() void tst_QNetworkReply::httpUploadPerformance() { +#ifdef Q_OS_SYMBIAN + // SHow some mercy for non-desktop platform/s + enum {UploadSize = 4*1024*1024}; // 4 MB +#else enum {UploadSize = 128*1024*1024}; // 128 MB +#endif ThreadedDataReaderHttpServer reader; FixedSizeDataGenerator generator(UploadSize); @@ -3335,8 +3368,12 @@ void tst_QNetworkReply::httpDownloadPerformance() { QFETCH(bool, serverSendsContentLength); QFETCH(bool, chunkedEncoding); - +#ifdef Q_OS_SYMBIAN + // Show some mercy to non-desktop platform/s + enum {UploadSize = 4*1024*1024}; // 4 MB +#else enum {UploadSize = 128*1024*1024}; // 128 MB +#endif HttpDownloadPerformanceServer server(UploadSize, serverSendsContentLength, chunkedEncoding); QNetworkRequest request(QUrl("http://127.0.0.1:" + QString::number(server.serverPort()) + "/?bare=1")); @@ -3361,7 +3398,14 @@ void tst_QNetworkReply::downloadProgress_data() QTest::newRow("empty") << 0; QTest::newRow("small") << 4; +#ifndef Q_OS_SYMBIAN QTest::newRow("big") << 4096; +#else + // it can run even with 4096 + // but it takes lot time + //especially on emulator + QTest::newRow("big") << 1024; +#endif } void tst_QNetworkReply::downloadProgress() @@ -3544,7 +3588,7 @@ void tst_QNetworkReply::receiveCookiesFromHttp_data() void tst_QNetworkReply::receiveCookiesFromHttp() { - QFETCH(QString, cookieString); + QFETCH(QString, cookieString); QByteArray data = cookieString.toLatin1() + '\n'; QUrl url("http://" + QtNetworkSettings::serverName() + "/qtest/cgi-bin/set-cookie.cgi"); @@ -3697,7 +3741,9 @@ void tst_QNetworkReply::httpProxyCommands() // wait for the finished signal connect(reply, SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop())); + QTestEventLoop::instance().enterLoop(1); + QVERIFY(!QTestEventLoop::instance().timeout()); //qDebug() << reply->error() << reply->errorString(); @@ -3727,7 +3773,15 @@ void tst_QNetworkReply::proxyChange() QNetworkReplyPtr reply2 = manager.get(req); connect(reply2, SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop())); +#ifdef Q_OS_SYMBIAN + // we need more time as: + // 1. running from the emulator + // 2. not perfect POSIX implementation + // 3. embedded device + QTestEventLoop::instance().enterLoop(20); +#else QTestEventLoop::instance().enterLoop(10); +#endif QVERIFY(!QTestEventLoop::instance().timeout()); if (finishedspy.count() == 0) { diff --git a/tests/auto/qnumeric/qnumeric.pro b/tests/auto/qnumeric/qnumeric.pro index 3176284..162f980 100644 --- a/tests/auto/qnumeric/qnumeric.pro +++ b/tests/auto/qnumeric/qnumeric.pro @@ -3,5 +3,4 @@ load(qttest_p4) QT = core SOURCES += tst_qnumeric.cpp - - +QT = core diff --git a/tests/auto/qobject/qobject.pro b/tests/auto/qobject/qobject.pro index 0cafdc3..b6b3f20 100644 --- a/tests/auto/qobject/qobject.pro +++ b/tests/auto/qobject/qobject.pro @@ -1,4 +1,2 @@ TEMPLATE = subdirs SUBDIRS = tst_qobject.pro signalbug.pro - - diff --git a/tests/auto/qobject/tst_qobject.cpp b/tests/auto/qobject/tst_qobject.cpp index bb00a0b..a08f620 100644 --- a/tests/auto/qobject/tst_qobject.cpp +++ b/tests/auto/qobject/tst_qobject.cpp @@ -1170,7 +1170,7 @@ Q_DECLARE_METATYPE(PropertyObject::Priority) void tst_QObject::threadSignalEmissionCrash() { -#ifdef Q_OS_WINCE +#if defined(Q_OS_WINCE) || defined(Q_OS_SYMBIAN) int loopCount = 100; #else int loopCount = 1000; @@ -1420,8 +1420,18 @@ void tst_QObject::moveToThread() MoveToThreadObject *child = new MoveToThreadObject(object); connect(object, SIGNAL(theSignal()), &thread, SLOT(quit()), Qt::DirectConnection); + +#if defined(Q_OS_SYMBIAN) + // Child timer will be registered after parent timer in the new + // thread, and 10ms is less than symbian timer resolution, so + // child->timerEventThread compare after thread.wait() will + // usually fail unless timers are farther apart. + child->startTimer(100); + object->startTimer(150); +#else child->startTimer(90); object->startTimer(100); +#endif QCOMPARE(object->thread(), currentThread); QCOMPARE(child->thread(), currentThread); @@ -2428,7 +2438,9 @@ void tst_QObject::dynamicProperties() void tst_QObject::recursiveSignalEmission() { -#ifdef QT_NO_PROCESS +#if defined(Q_OS_SYMBIAN) && defined(Q_CC_NOKIAX86) + QSKIP("Emulator builds in Symbian do not support launching processes linking to Qt", SkipAll); +#elif defined(QT_NO_PROCESS) QSKIP("Test requires QProcess", SkipAll); #else QProcess proc; diff --git a/tests/auto/qobject/tst_qobject.pro b/tests/auto/qobject/tst_qobject.pro index 0500ea2..003ee98 100644 --- a/tests/auto/qobject/tst_qobject.pro +++ b/tests/auto/qobject/tst_qobject.pro @@ -10,3 +10,8 @@ wince*: { DEPLOYMENT += addFiles } +symbian: { + addFiles.sources = signalbug.exe + addFiles.path = \sys\bin + DEPLOYMENT += addFiles +} diff --git a/tests/auto/qobjectrace/qobjectrace.pro b/tests/auto/qobjectrace/qobjectrace.pro index 581c63f..322adff 100644 --- a/tests/auto/qobjectrace/qobjectrace.pro +++ b/tests/auto/qobjectrace/qobjectrace.pro @@ -1,6 +1,5 @@ load(qttest_p4) SOURCES += tst_qobjectrace.cpp - QT = core - +TARGET.EPOCHEAPSIZE = 20000000 40000000 diff --git a/tests/auto/qobjectrace/tst_qobjectrace.cpp b/tests/auto/qobjectrace/tst_qobjectrace.cpp index 5f33649..f24bc7d 100644 --- a/tests/auto/qobjectrace/tst_qobjectrace.cpp +++ b/tests/auto/qobjectrace/tst_qobjectrace.cpp @@ -44,7 +44,10 @@ #include <QtTest/QtTest> -enum { OneMinute = 60 * 1000, TwoMinutes = OneMinute * 2 }; +enum { OneMinute = 60 * 1000, + TwoMinutes = OneMinute * 2, + TenMinutes = OneMinute * 10, + TwentyFiveMinutes = OneMinute * 25 }; class tst_QObjectRace: public QObject { @@ -136,6 +139,11 @@ private slots: void tst_QObjectRace::moveToThreadRace() { +#if defined(Q_OS_SYMBIAN) + // ### FIXME: task 257411 - remove xfail once this is fixed + QEXPECT_FAIL("", "Symbian event dispatcher can't handle this kind of race, see task: 257411", Abort); + QVERIFY(false); +#endif RaceObject *object = new RaceObject; enum { ThreadCount = 6 }; @@ -210,9 +218,25 @@ public: } }; +#if defined(Q_OS_SYMBIAN) +// Symbian needs "a bit" more time +# define EXTRA_THREAD_WAIT TenMinutes +# define MAIN_THREAD_WAIT TwentyFiveMinutes +#else +# define EXTRA_THREAD_WAIT 3000 +# define MAIN_THREAD_WAIT TwoMinutes +#endif + void tst_QObjectRace::destroyRace() { - enum { ThreadCount = 10, ObjectCountPerThread = 733, +#if defined(Q_OS_SYMBIAN) && defined(Q_CC_NOKIAX86) + // ### FIXME: task 257411 - remove xfail once this is fixed. + // Oddly enough, this seems to work properly in HW, if given enough time and memory. + QEXPECT_FAIL("", "Symbian event dispatcher can't handle this kind of race on emulator, see task: 257411", Abort); + QVERIFY(false); +#endif + + enum { ThreadCount = 10, ObjectCountPerThread = 733, ObjectCount = ThreadCount * ObjectCountPerThread }; const char *_slots[] = { SLOT(slot1()) , SLOT(slot2()) , SLOT(slot3()), @@ -244,10 +268,10 @@ void tst_QObjectRace::destroyRace() for (int i = 0; i < ThreadCount; ++i) threads[i]->start(); - QVERIFY(threads[0]->wait(TwoMinutes)); + QVERIFY(threads[0]->wait(MAIN_THREAD_WAIT)); // the other threads should finish pretty quickly now for (int i = 1; i < ThreadCount; ++i) - QVERIFY(threads[i]->wait(3000)); + QVERIFY(threads[i]->wait(EXTRA_THREAD_WAIT)); for (int i = 0; i < ThreadCount; ++i) delete threads[i]; diff --git a/tests/auto/qpainter/qpainter.pro b/tests/auto/qpainter/qpainter.pro index 277039f..1b3659d 100644 --- a/tests/auto/qpainter/qpainter.pro +++ b/tests/auto/qpainter/qpainter.pro @@ -1,12 +1,15 @@ load(qttest_p4) contains(QT_CONFIG, qt3support): QT += qt3support SOURCES += tst_qpainter.cpp -wince*: { - DEFINES += SRCDIR=\\\".\\\" +wince*|symbian*: { addFiles.sources = drawEllipse drawLine_rop_bitmap drawPixmap_rop drawPixmap_rop_bitmap task217400.png addFiles.path = . DEPLOYMENT += addFiles -} else { +} + +wince* { + DEFINES += SRCDIR=\\\".\\\" +} !symbian { DEFINES += SRCDIR=\\\"$$PWD\\\" } diff --git a/tests/auto/qpainter/tst_qpainter.cpp b/tests/auto/qpainter/tst_qpainter.cpp index 9448d38..1d0a1b4 100644 --- a/tests/auto/qpainter/tst_qpainter.cpp +++ b/tests/auto/qpainter/tst_qpainter.cpp @@ -50,7 +50,7 @@ #include <qbitmap.h> #include <qimage.h> #include <limits.h> -#if !defined(Q_OS_WINCE) +#if !defined(Q_OS_WINCE) && !defined(Q_OS_SYMBIAN) #include <qprinter.h> #include <math.h> #ifdef QT3_SUPPORT @@ -67,6 +67,10 @@ #include <qqueue.h> +#if defined(Q_OS_SYMBIAN) +# define SRCDIR "." +#endif + Q_DECLARE_METATYPE(QLine) Q_DECLARE_METATYPE(QRect) Q_DECLARE_METATYPE(QSize) @@ -528,8 +532,7 @@ void tst_QPainter::qt_format_text_boundingRect() QCOMPARE(pbr, br); } #endif - -#if !defined(Q_OS_WINCE) +#if !defined(Q_OS_WINCE) && !defined(Q_OS_SYMBIAN) { QPrinter printer(QPrinter::HighResolution); if (printer.printerName().isEmpty()) { @@ -1425,7 +1428,7 @@ void tst_QPainter::drawPath2() void tst_QPainter::drawPath3() { -#ifndef Q_OS_WINCE +#if !defined(Q_OS_WINCE) && !defined(Q_OS_SYMBIAN) QImage imgA(400, 400, QImage::Format_RGB32); #else QImage imgA(100, 100, QImage::Format_RGB32); @@ -2962,7 +2965,7 @@ void tst_QPainter::monoImages() } } -#if !defined(Q_OS_IRIX) && !defined(Q_OS_AIX) && !defined(Q_CC_MSVC) && !defined(Q_OS_SOLARIS) +#if !defined(Q_OS_IRIX) && !defined(Q_OS_AIX) && !defined(Q_CC_MSVC) && !defined(Q_OS_SOLARIS) && !defined(Q_OS_SYMBIAN) #include <fenv.h> static const QString fpeExceptionString(int exception) diff --git a/tests/auto/qpathclipper/qpathclipper.pro b/tests/auto/qpathclipper/qpathclipper.pro index dc9d60f..930a6f2 100644 --- a/tests/auto/qpathclipper/qpathclipper.pro +++ b/tests/auto/qpathclipper/qpathclipper.pro @@ -5,6 +5,6 @@ SOURCES += tst_qpathclipper.cpp paths.cpp requires(contains(QT_CONFIG,private_tests)) -unix:!mac:LIBS+=-lm +unix:!mac:!symbian*:LIBS+=-lm diff --git a/tests/auto/qpen/tst_qpen.cpp b/tests/auto/qpen/tst_qpen.cpp index 5fd2450..87f50f4 100644 --- a/tests/auto/qpen/tst_qpen.cpp +++ b/tests/auto/qpen/tst_qpen.cpp @@ -111,22 +111,22 @@ void tst_QPen::operator_eq_eq_data() QTest::newRow("differentColor") << QPen(Qt::red) << QPen(Qt::blue) - << FALSE; + << bool(FALSE); QTest::newRow("differentWidth") << QPen(Qt::red, 2) << QPen(Qt::red, 3) - << FALSE; + << bool(FALSE); QTest::newRow("differentPenStyle") << QPen(Qt::red, 2, Qt::DashLine) << QPen(Qt::red, 2, Qt::DotLine) - << FALSE; + << bool(FALSE); QTest::newRow("differentCapStyle") << QPen(Qt::red, 2, Qt::DashLine, Qt::RoundCap, Qt::BevelJoin) << QPen(Qt::red, 2, Qt::DashLine, Qt::SquareCap, Qt::BevelJoin) - << FALSE; + << bool(FALSE); QTest::newRow("differentJoinStyle") << QPen(Qt::red, 2, Qt::DashLine, Qt::RoundCap, Qt::BevelJoin) << QPen(Qt::red, 2, Qt::DashLine, Qt::RoundCap, Qt::MiterJoin) - << FALSE; + << bool(FALSE); QTest::newRow("same") << QPen(Qt::red, 2, Qt::DashLine, Qt::RoundCap, Qt::BevelJoin) << QPen(Qt::red, 2, Qt::DashLine, Qt::RoundCap, Qt::BevelJoin) - << TRUE; + << bool(TRUE); } diff --git a/tests/auto/qpixmap/qpixmap.pro b/tests/auto/qpixmap/qpixmap.pro index 70be4be..02ed3f2 100644 --- a/tests/auto/qpixmap/qpixmap.pro +++ b/tests/auto/qpixmap/qpixmap.pro @@ -1,13 +1,19 @@ load(qttest_p4) SOURCES += tst_qpixmap.cpp contains(QT_CONFIG, qt3support): QT += qt3support -wince*: { +wince*|symbian*: { task31722_0.sources = convertFromImage/task31722_0/* task31722_0.path = convertFromImage/task31722_0 task31722_1.sources = convertFromImage/task31722_1/* task31722_1.path = convertFromImage/task31722_1 DEPLOYMENT += task31722_0 task31722_1 +} + +wince*: { DEFINES += SRCDIR=\\\".\\\" +} symbian*: { + DEPLOYMENT_PLUGIN += qmng + LIBS += -lfbscli.dll -lbitgdi.dll -lgdi.dll } else { DEFINES += SRCDIR=\\\"$$PWD\\\" win32:LIBS += -lgdi32 -luser32 diff --git a/tests/auto/qpixmap/tst_qpixmap.cpp b/tests/auto/qpixmap/tst_qpixmap.cpp index 281d122..35d4cf3 100644 --- a/tests/auto/qpixmap/tst_qpixmap.cpp +++ b/tests/auto/qpixmap/tst_qpixmap.cpp @@ -60,9 +60,19 @@ #include <qscreen_qws.h> #endif +#ifdef Q_OS_SYMBIAN +#include <e32std.h> +#include <fbs.h> +#include <gdi.h> +#include <bitdev.h> +#endif + + //TESTED_CLASS= //TESTED_FILES= - +#if defined(Q_OS_SYMBIAN) +# define SRCDIR "" +#endif Q_DECLARE_METATYPE(QImage::Format) class tst_QPixmap : public QObject @@ -123,6 +133,11 @@ private slots: void fromWinHBITMAP(); #endif +#if defined(Q_WS_S60) + void fromSymbianCFbsBitmap_data(); + void fromSymbianCFbsBitmap(); +#endif + void onlyNullPixmapsOutsideGuiThread(); void refUnref(); @@ -307,8 +322,11 @@ void tst_QPixmap::convertFromImage_data() { QTest::addColumn<QImage>("img1"); QTest::addColumn<QImage>("img2"); - +#ifdef Q_OS_SYMBIAN + const QString prefix = QLatin1String(SRCDIR) + "convertFromImage"; +#else const QString prefix = QLatin1String(SRCDIR) + "/convertFromImage"; +#endif { QImage img1; QImage img2; @@ -921,6 +939,102 @@ void tst_QPixmap::fromWinHBITMAP() #endif +#if defined(Q_WS_S60) +Q_DECLARE_METATYPE(TDisplayMode) + +void tst_QPixmap::fromSymbianCFbsBitmap_data() +{ + QTest::addColumn<TDisplayMode>("format"); + QTest::addColumn<int>("width"); + QTest::addColumn<int>("height"); + QTest::addColumn<QColor>("color"); + + const int smallWidth = 20; + const int smallHeight = 20; + const int largeWidth = 240; + const int largeHeight = 320; + + // Indexed Color Formats - Disabled since images seem to be blank -> no palette? +// QTest::newRow("EGray2 small") << EGray2 << smallWidth << smallHeight << QColor(Qt::black); +// QTest::newRow("EGray2 big") << EGray2 << largeWidth << largeHeight << QColor(Qt::black); +// QTest::newRow("EGray256 small") << EGray256 << smallWidth << smallHeight << QColor(Qt::blue); +// QTest::newRow("EGray256 big") << EGray256 << largeWidth << largeHeight << QColor(Qt::blue); +// QTest::newRow("EColor256 small") << EColor256 << smallWidth << smallHeight << QColor(Qt::red); +// QTest::newRow("EColor256 big") << EColor256 << largeWidth << largeHeight << QColor(Qt::red); + + // Direct Color Formats + QTest::newRow("EColor4K small") << EColor4K << smallWidth << smallHeight << QColor(Qt::red); + QTest::newRow("EColor4K big") << EColor4K << largeWidth << largeHeight << QColor(Qt::red); + QTest::newRow("EColor64K small") << EColor64K << smallWidth << smallHeight << QColor(Qt::green); + QTest::newRow("EColor64K big") << EColor64K << largeWidth << largeHeight << QColor(Qt::green); + QTest::newRow("EColor16MU small") << EColor16MU << smallWidth << smallHeight << QColor(Qt::red); + QTest::newRow("EColor16MU big") << EColor16MU << largeWidth << largeHeight << QColor(Qt::red); + QTest::newRow("EColor16MA small opaque") << EColor16MA << smallWidth << smallHeight << QColor(255, 255, 0); + QTest::newRow("EColor16MA big opaque") << EColor16MA << largeWidth << largeHeight << QColor(255, 255, 0); + + // Semi-transparent Colors - Disabled for now, since the QCOMPARE fails, but visually confirmed to work +// QTest::newRow("EColor16MA small semi") << EColor16MA << smallWidth << smallHeight << QColor(255, 255, 0, 127); +// QTest::newRow("EColor16MA big semi") << EColor16MA << largeWidth << largeHeight << QColor(255, 255, 0, 127); +// QTest::newRow("EColor16MA small trans") << EColor16MA << smallWidth << smallHeight << QColor(255, 255, 0, 0); +// QTest::newRow("EColor16MA big trans") << EColor16MA << largeWidth << largeHeight << QColor(255, 255, 0, 0); + +#if !defined(__SERIES60_31__) && !defined(__S60_32__) + QTest::newRow("EColor16MAP small") << EColor16MAP << smallWidth << smallHeight << QColor(Qt::red); + QTest::newRow("EColor16MAP big") << EColor16MAP << largeWidth << largeHeight << QColor(Qt::red); +#endif +} + +void tst_QPixmap::fromSymbianCFbsBitmap() +{ + QFETCH(TDisplayMode, format); + QFETCH(int, width); + QFETCH(int, height); + QFETCH(QColor, color); + int expectedDepth = TDisplayModeUtils::NumDisplayModeBitsPerPixel(format); + + CFbsBitmap *nativeBitmap = 0; + CFbsBitmapDevice *bitmapDevice = 0; + CBitmapContext *bitmapContext = 0; + + nativeBitmap = new (ELeave) CFbsBitmap(); + TInt err = nativeBitmap->Create(TSize(width, height), format); + CleanupStack::PushL(nativeBitmap); + QVERIFY(err == KErrNone); + bitmapDevice = CFbsBitmapDevice::NewL(nativeBitmap); + CleanupStack::PushL(bitmapDevice); + + err = bitmapDevice->CreateBitmapContext(bitmapContext); + CleanupStack::PushL(bitmapContext); + QVERIFY(err == KErrNone); + TRgb symbianColor = TRgb(color.red(), color.green(), color.blue(), color.alpha()); + bitmapContext->SetBrushColor(symbianColor); + bitmapContext->Clear(); + + __UHEAP_MARK; + { // Test the null case + CFbsBitmap *bitmap = 0; + QPixmap pixmap = QPixmap::fromSymbianCFbsBitmap(bitmap); + QVERIFY(pixmap.isNull()); + } + __UHEAP_MARKEND; + + __UHEAP_MARK; + { // Test the normal case + QPixmap pixmap = QPixmap::fromSymbianCFbsBitmap(nativeBitmap); +// QCOMPARE(pixmap.depth(), expectedDepth); // Depth is not preserved now + QCOMPARE(pixmap.width(), width); + QCOMPARE(pixmap.height(), height); + QImage image = pixmap.toImage(); + + QColor actualColor(image.pixel(1, 1)); + QCOMPARE(actualColor, color); + } + __UHEAP_MARKEND; + + CleanupStack::PopAndDestroy(3); +} +#endif + void tst_QPixmap::onlyNullPixmapsOutsideGuiThread() { #if !defined(Q_WS_WIN) @@ -946,9 +1060,17 @@ void tst_QPixmap::onlyNullPixmapsOutsideGuiThread() } }; Thread thread; +#if defined(Q_OS_SYMBIAN) + thread.setStackSize(0x10000); +#endif thread.start(); +#if defined(Q_OS_SYMBIAN) + QVERIFY(thread.wait(10000)); +#else thread.wait(); #endif + +#endif // !defined(Q_WS_WIN) } void tst_QPixmap::refUnref() diff --git a/tests/auto/qplaintextedit/tst_qplaintextedit.cpp b/tests/auto/qplaintextedit/tst_qplaintextedit.cpp index dc9c4da..cd3a059 100644 --- a/tests/auto/qplaintextedit/tst_qplaintextedit.cpp +++ b/tests/auto/qplaintextedit/tst_qplaintextedit.cpp @@ -87,24 +87,32 @@ public slots: void cleanup(); private slots: void getSetCheck(); +#ifndef QT_NO_CLIPBOARD void clearMustNotChangeClipboard(); +#endif void clearMustNotResetRootFrameMarginToDefault(); void paragSeparatorOnPlaintextAppend(); +#ifndef QT_NO_CLIPBOARD void selectAllSetsNotSelection(); +#endif void asciiTab(); void setDocument(); void emptyAppend(); void appendOnEmptyDocumentShouldReuseInitialParagraph(); void cursorPositionChanged(); void setTextCursor(); +#ifndef QT_NO_CLIPBOARD void undoAvailableAfterPaste(); +#endif void undoRedoAvailableRepetition(); void appendShouldNotTouchTheSelection(); void backspace(); void shiftBackspace(); void undoRedo(); void preserveCharFormatInAppend(); +#ifndef QT_NO_CLIPBOARD void copyAndSelectAllInReadonly(); +#endif void ctrlAltInput(); void noPropertiesOnDefaultTextEditCharFormat(); void setPlainTextShouldEmitTextChangedOnce(); @@ -118,13 +126,17 @@ private slots: void undoRedoAfterSetContent(); void numPadKeyNavigation(); void moveCursor(); +#ifndef QT_NO_CLIPBOARD void mimeDataReimplementations(); +#endif void shiftEnterShouldInsertLineSeparator(); void selectWordsFromStringsContainingSeparators_data(); void selectWordsFromStringsContainingSeparators(); +#ifndef QT_NO_CLIPBOARD void canPaste(); void copyAvailable_data(); void copyAvailable(); +#endif void ensureCursorVisibleOnInitialShow(); void setTextInsideResizeEvent(); void colorfulAppend(); @@ -209,7 +221,7 @@ void tst_QPlainTextEdit::getSetCheck() QCOMPARE(0, obj1.tabStopWidth()); obj1.setTabStopWidth(INT_MIN); QCOMPARE(0, obj1.tabStopWidth()); // Makes no sense to set a negative tabstop value -#if defined(QT_ARCH_WINDOWSCE) +#if defined(QT_ARCH_WINDOWSCE) || defined (QT_ARCH_SYMBIAN) // due to rounding error in qRound when qreal==float // we cannot use INT_MAX for this check obj1.setTabStopWidth(SHRT_MAX*2); @@ -290,7 +302,7 @@ void tst_QPlainTextEdit::createSelection() #endif QCOMPARE(ed->textCursor().position(), 11); } - +#ifndef QT_NO_CLIPBOARD void tst_QPlainTextEdit::clearMustNotChangeClipboard() { if (!nativeClipboardWorking()) @@ -301,6 +313,7 @@ void tst_QPlainTextEdit::clearMustNotChangeClipboard() ed->clear(); QCOMPARE(QApplication::clipboard()->text(), txt); } +#endif void tst_QPlainTextEdit::clearMustNotResetRootFrameMarginToDefault() { @@ -322,6 +335,7 @@ void tst_QPlainTextEdit::paragSeparatorOnPlaintextAppend() QCOMPARE(cnt, 2); } +#ifndef QT_NO_CLIPBOARD void tst_QPlainTextEdit::selectAllSetsNotSelection() { if (!QApplication::clipboard()->supportsSelection()) { @@ -337,6 +351,7 @@ void tst_QPlainTextEdit::selectAllSetsNotSelection() QCOMPARE(QApplication::clipboard()->text(QClipboard::Selection), QString::fromAscii("foobar")); } +#endif void tst_QPlainTextEdit::asciiTab() { @@ -466,6 +481,7 @@ void tst_QPlainTextEdit::setTextCursor() QCOMPARE(spy.count(), 1); } +#ifndef QT_NO_CLIPBOARD void tst_QPlainTextEdit::undoAvailableAfterPaste() { if (!nativeClipboardWorking()) @@ -479,6 +495,7 @@ void tst_QPlainTextEdit::undoAvailableAfterPaste() QVERIFY(spy.count() >= 1); QCOMPARE(ed->toPlainText(), txt); } +#endif class UndoRedoRecorder : public QObject { @@ -657,6 +674,7 @@ void tst_QPlainTextEdit::preserveCharFormatInAppend() QCOMPARE(cursor.block().text(), QString("third para")); } +#ifndef QT_NO_CLIPBOARD void tst_QPlainTextEdit::copyAndSelectAllInReadonly() { if (!nativeClipboardWorking()) @@ -687,6 +705,7 @@ void tst_QPlainTextEdit::copyAndSelectAllInReadonly() QTest::keyClick(ed, Qt::Key_C, Qt::ControlModifier); QCOMPARE(QApplication::clipboard()->text(), QString("Hello World")); } +#endif void tst_QPlainTextEdit::ctrlAltInput() { @@ -908,6 +927,7 @@ void tst_QPlainTextEdit::implicitClear() QVERIFY(ed->toPlainText().isEmpty()); } +#ifndef QT_NO_CLIPBOARD void tst_QPlainTextEdit::copyAvailable_data() { QTest::addColumn<pairListType>("keystrokes"); @@ -1025,6 +1045,7 @@ void tst_QPlainTextEdit::copyAvailable() QVERIFY2(variantSpyCopyAvailable.toBool() == copyAvailable.at(i), QString("Spied singnal: %1").arg(i).toLatin1()); } } +#endif void tst_QPlainTextEdit::undoRedoAfterSetContent() { @@ -1090,6 +1111,7 @@ public: }; +#ifndef QT_NO_CLIPBOARD void tst_QPlainTextEdit::mimeDataReimplementations() { MyTextEdit ed; @@ -1128,6 +1150,7 @@ void tst_QPlainTextEdit::mimeDataReimplementations() QCOMPARE(ed.insertCallCount, 1); #endif } +#endif void tst_QPlainTextEdit::shiftEnterShouldInsertLineSeparator() { @@ -1167,6 +1190,7 @@ void tst_QPlainTextEdit::selectWordsFromStringsContainingSeparators() cursor.clearSelection(); } +#ifndef QT_NO_CLIPBOARD void tst_QPlainTextEdit::canPaste() { if (!nativeClipboardWorking()) @@ -1179,6 +1203,7 @@ void tst_QPlainTextEdit::canPaste() ed->setTextInteractionFlags(Qt::NoTextInteraction); QVERIFY(!ed->canPaste()); } +#endif void tst_QPlainTextEdit::ensureCursorVisibleOnInitialShow() { diff --git a/tests/auto/qplugin/debugplugin/debugplugin.pro b/tests/auto/qplugin/debugplugin/debugplugin.pro index cb2ac34..d0762fc 100644 --- a/tests/auto/qplugin/debugplugin/debugplugin.pro +++ b/tests/auto/qplugin/debugplugin/debugplugin.pro @@ -5,3 +5,7 @@ SOURCES = main.cpp QT = core DESTDIR = ../plugins +symbian: { + TARGET.EPOCALLOWDLLDATA=1 + TARGET.CAPABILITY=ALL -TCB +} diff --git a/tests/auto/qplugin/qplugin.pro b/tests/auto/qplugin/qplugin.pro index 818bb0d..aafcb36 100644 --- a/tests/auto/qplugin/qplugin.pro +++ b/tests/auto/qplugin/qplugin.pro @@ -1,3 +1,4 @@ +QT = core TEMPLATE = subdirs win32 { exists($$[QT_INSTALL_LIBS]/QtCore4.dll) { diff --git a/tests/auto/qplugin/releaseplugin/releaseplugin.pro b/tests/auto/qplugin/releaseplugin/releaseplugin.pro index 21177b8..ce66aaf 100644 --- a/tests/auto/qplugin/releaseplugin/releaseplugin.pro +++ b/tests/auto/qplugin/releaseplugin/releaseplugin.pro @@ -5,3 +5,7 @@ SOURCES = main.cpp QT = core DESTDIR = ../plugins +symbian: { + TARGET.EPOCALLOWDLLDATA=1 + TARGET.CAPABILITY=ALL -TCB +} diff --git a/tests/auto/qplugin/tst_qplugin.pro b/tests/auto/qplugin/tst_qplugin.pro index aa5842a..0d9d809 100644 --- a/tests/auto/qplugin/tst_qplugin.pro +++ b/tests/auto/qplugin/tst_qplugin.pro @@ -1,6 +1,7 @@ +load(qttest_p4) + SOURCES = tst_qplugin.cpp QT = core -CONFIG += qtestlib wince*: { plugins.sources = plugins/* @@ -8,3 +9,8 @@ wince*: { DEPLOYMENT += plugins } +symbian: { + rpDep.sources = releaseplugin.dll debugplugin.dll + rpDep.path = plugins + DEPLOYMENT += rpDep dpDep +} diff --git a/tests/auto/qpluginloader/lib/lib.pro b/tests/auto/qpluginloader/lib/lib.pro index 7e842f2..96a9732 100644 --- a/tests/auto/qpluginloader/lib/lib.pro +++ b/tests/auto/qpluginloader/lib/lib.pro @@ -12,4 +12,7 @@ win32-borland: DEFINES += WIN32_BORLAND #no special install rule for the library used by test INSTALLS = +symbian: { + TARGET.CAPABILITY=ALL -TCB +} diff --git a/tests/auto/qpluginloader/qpluginloader.pro b/tests/auto/qpluginloader/qpluginloader.pro index 50c17ed..382d6e4 100644 --- a/tests/auto/qpluginloader/qpluginloader.pro +++ b/tests/auto/qpluginloader/qpluginloader.pro @@ -1,9 +1,10 @@ +QT = core TEMPLATE = subdirs CONFIG += ordered SUBDIRS = lib \ theplugin \ tst -!win32: !macx-*: SUBDIRS += almostplugin +!win32: !macx-*: !symbian: SUBDIRS += almostplugin TARGET = tst_qpluginloader # no special install rule for subdir diff --git a/tests/auto/qpluginloader/theplugin/theplugin.pro b/tests/auto/qpluginloader/theplugin/theplugin.pro index d8d87b0..44b46b4 100644 --- a/tests/auto/qpluginloader/theplugin/theplugin.pro +++ b/tests/auto/qpluginloader/theplugin/theplugin.pro @@ -5,3 +5,7 @@ SOURCES = theplugin.cpp TARGET = $$qtLibraryTarget(theplugin) DESTDIR = ../bin +symbian: { + TARGET.EPOCALLOWDLLDATA=1 + TARGET.CAPABILITY=ALL -TCB +} diff --git a/tests/auto/qpluginloader/tst/tst.pro b/tests/auto/qpluginloader/tst/tst.pro index 28f74d4..2de0912 100644 --- a/tests/auto/qpluginloader/tst/tst.pro +++ b/tests/auto/qpluginloader/tst/tst.pro @@ -2,6 +2,7 @@ load(qttest_p4) SOURCES += ../tst_qpluginloader.cpp TARGET = ../tst_qpluginloader QT = core +HEADERS += ../theplugin/plugininterface.h win32 { CONFIG(debug, debug|release) { @@ -18,3 +19,11 @@ wince*: { DEPLOYMENT += addFiles } +symbian: { + libDep.sources = mylib.dll + libDep.path = /sys/bin + pluginDep.sources = theplugin.dll + pluginDep.path = bin + + DEPLOYMENT += libDep pluginDep +} diff --git a/tests/auto/qpluginloader/tst_qpluginloader.cpp b/tests/auto/qpluginloader/tst_qpluginloader.cpp index 1514897..4b40081 100644 --- a/tests/auto/qpluginloader/tst_qpluginloader.cpp +++ b/tests/auto/qpluginloader/tst_qpluginloader.cpp @@ -87,6 +87,12 @@ # endif # define PREFIX "" +#elif defined(Q_OS_SYMBIAN) +# undef dll_VALID +# define dll_VALID true +# define SUFFIX ".dll" +# define PREFIX "" + #else // all other Unix # undef so_VALID # define so_VALID true @@ -116,7 +122,7 @@ private slots: void errorString(); void loadHints(); void deleteinstanceOnUnload(); - + void checkingStubsFromDifferentDrives(); }; tst_QPluginLoader::tst_QPluginLoader() @@ -210,7 +216,7 @@ void tst_QPluginLoader::errorString() QVERIFY(loader.errorString() != unknown); } -#if !defined Q_OS_WIN && !defined Q_OS_MAC && !defined Q_OS_HPUX +#if !defined Q_OS_WIN && !defined Q_OS_MAC && !defined Q_OS_HPUX && !defined Q_OS_SYMBIAN { QPluginLoader loader( sys_qualifiedLibraryName("almostplugin")); //a plugin with unresolved symbols loader.setLoadHints(QLibrary::ResolveAllSymbolsHint); @@ -242,6 +248,11 @@ void tst_QPluginLoader::errorString() QVERIFY(loader.instance() != static_cast<QObject*>(0)); QCOMPARE(loader.errorString(), unknown); + // Make sure that plugin really works + PluginInterface* theplugin = qobject_cast<PluginInterface*>(loader.instance()); + QString pluginName = theplugin->pluginName(); + QCOMPARE(pluginName, QLatin1String("Plugin ok")); + QCOMPARE(loader.unload(), true); QCOMPARE(loader.errorString(), unknown); } @@ -287,6 +298,55 @@ void tst_QPluginLoader::deleteinstanceOnUnload() } } +void tst_QPluginLoader::checkingStubsFromDifferentDrives() +{ +#if defined(Q_OS_SYMBIAN) + + // This test needs C-drive + some additional drive (driveForStubs) + + const QString driveForStubs("E:/");// != "C:/" + const QString stubDir("system/temp/stubtest/"); + const QString stubName("dummyStub.qtplugin"); + const QString fullStubFileName(stubDir + stubName); + QDir dir(driveForStubs); + bool test1(false); bool test2(false); + + // initial clean up + QFile::remove(driveForStubs + fullStubFileName); + dir.rmdir(driveForStubs + stubDir); + + // create a stub dir and do stub drive check + if (!dir.mkpath(stubDir)) + QSKIP("Required drive not available for this test", SkipSingle); + + {// test without stub, should not be found + QPluginLoader loader("C:/" + fullStubFileName); + test1 = !loader.fileName().length(); + } + + // create a stub to defined drive + QFile tempFile(driveForStubs + fullStubFileName); + tempFile.open(QIODevice::ReadWrite); + QFileInfo fileInfo(tempFile); + + {// now should be found even tried to find from C: + QPluginLoader loader("C:/" + fullStubFileName); + test2 = (loader.fileName() == fileInfo.absoluteFilePath()); + } + + // clean up + tempFile.close(); + if (!QFile::remove(driveForStubs + fullStubFileName)) + QWARN("Could not remove stub file"); + if (!dir.rmdir(driveForStubs + stubDir)) + QWARN("Could not remove stub directory"); + + // test after cleanup + QVERIFY(test1); + QVERIFY(test2); + +#endif//Q_OS_SYMBIAN +} + QTEST_APPLESS_MAIN(tst_QPluginLoader) #include "tst_qpluginloader.moc" - diff --git a/tests/auto/qpoint/qpoint.pro b/tests/auto/qpoint/qpoint.pro index 734fd3c..8b006c2 100644 --- a/tests/auto/qpoint/qpoint.pro +++ b/tests/auto/qpoint/qpoint.pro @@ -3,8 +3,5 @@ ############################################################ load(qttest_p4) -QT = core - SOURCES += tst_qpoint.cpp - - +QT = core diff --git a/tests/auto/qpolygon/qpolygon.pro b/tests/auto/qpolygon/qpolygon.pro index 311958d..e832666 100644 --- a/tests/auto/qpolygon/qpolygon.pro +++ b/tests/auto/qpolygon/qpolygon.pro @@ -1,6 +1,6 @@ load(qttest_p4) SOURCES += tst_qpolygon.cpp -unix:!mac:LIBS+=-lm +unix:!mac:!symbian:LIBS+=-lm diff --git a/tests/auto/qprocess/qprocess.pro b/tests/auto/qprocess/qprocess.pro index ed59f10..047828a 100644 --- a/tests/auto/qprocess/qprocess.pro +++ b/tests/auto/qprocess/qprocess.pro @@ -1,4 +1,5 @@ TEMPLATE = subdirs + SUBDIRS = testProcessCrash \ testProcessEcho \ testProcessEcho2 \ @@ -9,10 +10,7 @@ SUBDIRS = testProcessCrash \ testProcessOutput \ testProcessDeadWhileReading \ testProcessEOF \ - testSoftExit \ testProcessSpacesArgs/nospace.pro \ - testProcessSpacesArgs/onespace.pro \ - testProcessSpacesArgs/twospaces.pro \ testExitCodes \ testSpaceInName \ testGuiProcess \ @@ -20,6 +18,11 @@ SUBDIRS = testProcessCrash \ fileWriterProcess \ testSetWorkingDirectory +!symbian: { +SUBDIRS +=testProcessSpacesArgs/onespace.pro \ + testProcessSpacesArgs/twospaces.pro \ + testSoftExit +} win32:!wince*:SUBDIRS+=testProcessEchoGui diff --git a/tests/auto/qprocess/test/test.pro b/tests/auto/qprocess/test/test.pro index 3741e3c..82f91f8 100644 --- a/tests/auto/qprocess/test/test.pro +++ b/tests/auto/qprocess/test/test.pro @@ -18,7 +18,11 @@ win32: { QT = core -QT += network + +!symbian: { + QT += network +} + embedded: QT += gui wince*: { @@ -47,3 +51,18 @@ wince*: { DEPLOYMENT += addFiles } +symbian: { + binDep.sources = \ + fileWriterProcess.exe \ + testDetached.exe \ + testExitCodes.exe \ + testProcessCrash.exe \ + testProcessEcho.exe \ + testProcessNormal.exe \ + testProcessOutput.exe \ + nospace.exe \ + testSpaceInName.exe + binDep.path = \sys\bin + + DEPLOYMENT += binDep +} diff --git a/tests/auto/qprocess/testDetached/testDetached.pro b/tests/auto/qprocess/testDetached/testDetached.pro index 6792ef4..319cfa6 100644 --- a/tests/auto/qprocess/testDetached/testDetached.pro +++ b/tests/auto/qprocess/testDetached/testDetached.pro @@ -5,3 +5,6 @@ CONFIG -= app_bundle INSTALLS = DESTDIR = ./ +symbian*: { +TARGET.EPOCSTACKSIZE =0x14000 +} diff --git a/tests/auto/qprocess/testProcessOutput/main.cpp b/tests/auto/qprocess/testProcessOutput/main.cpp index b6c132b..c90ec08 100644 --- a/tests/auto/qprocess/testProcessOutput/main.cpp +++ b/tests/auto/qprocess/testProcessOutput/main.cpp @@ -44,13 +44,23 @@ int main() { -#ifndef _WIN32_WCE - for (int i=0; i<10240; i++) { -#else //fprintf Output is very slow on Windows CE +#if defined(__SYMBIAN32__) + // Printing to stdout messes up the out.txt, so open a file and print there. + FILE* file = fopen("c:\\logs\\qprocess_output_test.txt","w+"); + for (int i=0; i<200; i++) { + fprintf(file, "%d -this is a number\n", i); + fflush(file); + } + fclose(file); +#else +# if defined(_WIN32_WCE) for (int i=0; i<240; i++) { -#endif +# else //fprintf Output is very slow on Windows CE/Symbian + for (int i=0; i<10240; i++) { +# endif fprintf(stdout, "%d -this is a number\n", i); fflush(stderr); } +#endif return 0; } diff --git a/tests/auto/qprocess/testProcessSpacesArgs/main.cpp b/tests/auto/qprocess/testProcessSpacesArgs/main.cpp index ab9ba6e..add8384 100644 --- a/tests/auto/qprocess/testProcessSpacesArgs/main.cpp +++ b/tests/auto/qprocess/testProcessSpacesArgs/main.cpp @@ -44,11 +44,21 @@ int main(int argc, char ** argv) { +#if defined(__SYMBIAN32__) + // Printing to stdout messes up the out.txt, so open a file and print there. + FILE* file = fopen("c:\\logs\\qprocess_args_test.txt","w+"); + for (int i = 0; i < argc; ++i) { + if (i) + fprintf(file, "|"); + fprintf(file, argv[i]); + } + fclose(file); +#else for (int i = 0; i < argc; ++i) { if (i) printf("|"); printf(argv[i]); } - +#endif return 0; } diff --git a/tests/auto/qprocess/tst_qprocess.cpp b/tests/auto/qprocess/tst_qprocess.cpp index b57139b..9ea5e99 100644 --- a/tests/auto/qprocess/tst_qprocess.cpp +++ b/tests/auto/qprocess/tst_qprocess.cpp @@ -47,7 +47,11 @@ #include <QtCore/QThread> #include <QtCore/QRegExp> #include <QtCore/QDebug> +#include <QtCore/QMetaType> +#if !defined(Q_OS_SYMBIAN) +// Network test unnecessary? #include <QtNetwork/QHostInfo> +#endif #include <stdlib.h> #ifdef QT_NO_PROCESS @@ -130,6 +134,8 @@ private slots: void exitCodeTest(); void setEnvironment_data(); void setEnvironment(); + void setProcessEnvironment_data(); + void setProcessEnvironment(); void systemEnvironment(); void spaceInName(); void lockupsInStartDetached(); @@ -160,7 +166,7 @@ protected slots: void restartProcess(); void waitForReadyReadInAReadyReadSlotSlot(); void waitForBytesWrittenInABytesWrittenSlotSlot(); - + private: QProcess *process; qint64 bytesAvailable; @@ -197,6 +203,12 @@ tst_QProcess::~tst_QProcess() void tst_QProcess::init() { +#ifdef Q_OS_SYMBIAN + QString dirStr = QString::fromLatin1("c:\\logs"); + QDir dir; + if (!dir.exists(dirStr)) + dir.mkpath(dirStr); +#endif } void tst_QProcess::cleanup() @@ -252,8 +264,11 @@ void tst_QProcess::simpleStart() QVERIFY(process->waitForStarted(5000)); QCOMPARE(process->state(), QProcess::Running); #if defined(Q_OS_WINCE) + // Note: This actually seems incorrect, it will only exit the while loop when finishing fails while (process->waitForFinished(5000)) { } +#elif defined(Q_OS_SYMBIAN) + QVERIFY(process->waitForFinished(5000)); #else while (process->waitForReadyRead(5000)) { } @@ -379,6 +394,9 @@ void tst_QProcess::echoTest() #ifdef Q_OS_WINCE QSKIP("Reading and writing to a process is not supported on Qt/CE", SkipAll); #endif +#if defined(Q_OS_SYMBIAN) + QSKIP("Reading and writing to a process is not supported on Qt/Symbian", SkipAll); +#endif QFETCH(QByteArray, input); @@ -437,6 +455,9 @@ void tst_QProcess::echoTest2() #ifdef Q_OS_WINCE QSKIP("Reading and writing to a process is not supported on Qt/CE", SkipAll); #endif +#if defined(Q_OS_SYMBIAN) + QSKIP("Reading and writing to a process is not supported on Qt/Symbian", SkipAll); +#endif process = new QProcess; connect(process, SIGNAL(readyRead()), this, SLOT(exitLoopSlot())); @@ -488,6 +509,9 @@ void tst_QProcess::echoTest_performance() #ifdef Q_OS_WINCE QSKIP("Reading and writing to a process is not supported on Qt/CE", SkipAll); #endif +#if defined(Q_OS_SYMBIAN) + QSKIP("Reading and writing to a process is not supported on Qt/Symbian", SkipAll); +#endif QProcess process; #ifdef Q_OS_MAC @@ -542,6 +566,9 @@ void tst_QProcess::echoTestGui() #ifdef Q_OS_WINCE QSKIP("Reading and writing to a process is not supported on Qt/CE", SkipAll); #endif +#if defined(Q_OS_SYMBIAN) + QSKIP("Reading and writing to a process is not supported on Qt/Symbian", SkipAll); +#endif QProcess process; @@ -572,11 +599,14 @@ void tst_QProcess::batFiles() #if defined(Q_OS_WINCE) QSKIP("Batch files are not supported on Windows CE", SkipAll); #endif +#if defined(Q_OS_SYMBIAN) + QSKIP("Batch files are not supported on Symbian", SkipAll); +#endif QFETCH(QString, batFile); QFETCH(QByteArray, output); QProcess proc; - + proc.start(batFile, QStringList()); QVERIFY(proc.waitForFinished(5000)); @@ -642,6 +672,9 @@ void tst_QProcess::loopBackTest() #ifdef Q_OS_WINCE QSKIP("Reading and writing to a process is not supported on Qt/CE", SkipAll); #endif +#if defined(Q_OS_SYMBIAN) + QSKIP("Reading and writing to a process is not supported on Qt/Symbian", SkipAll); +#endif process = new QProcess; #ifdef Q_OS_MAC @@ -672,6 +705,9 @@ void tst_QProcess::readTimeoutAndThenCrash() #ifdef Q_OS_WINCE QSKIP("Reading and writing to a process is not supported on Qt/CE", SkipAll); #endif +#if defined(Q_OS_SYMBIAN) + QSKIP("Reading and writing to a process is not supported on Qt/Symbian", SkipAll); +#endif process = new QProcess; #ifdef Q_OS_MAC @@ -713,18 +749,30 @@ void tst_QProcess::waitForFinished() process.start("testProcessOutput/testProcessOutput"); #endif -#ifndef Q_OS_WINCE +#if !defined(Q_OS_WINCE) && !defined(Q_OS_SYMBIAN) QVERIFY(process.waitForFinished(5000)); #else - QVERIFY(process.waitForFinished(15000)); + QVERIFY(process.waitForFinished(30000)); #endif QCOMPARE(process.exitStatus(), QProcess::NormalExit); -#if defined (Q_OS_WINCE) +#if defined(Q_OS_SYMBIAN) + // Symbian test outputs to a file, so check that + FILE* file = fopen("c:\\logs\\qprocess_output_test.txt","r"); + int retval = 0; + int count = 0; + while((int)(retval = fgetc(file) )!= EOF) + if (retval == '\n') + count++; + fclose(file); + QCOMPARE(count, 200); +#else +# if defined (Q_OS_WINCE) QEXPECT_FAIL("", "Reading and writing to a process is not supported on Qt/CE", Continue); -#endif +# endif QString output = process.readAll(); QCOMPARE(output.count("\n"), 10*1024); +#endif process.start("blurdybloop"); QVERIFY(!process.waitForFinished()); @@ -737,6 +785,9 @@ void tst_QProcess::deadWhileReading() #ifdef Q_OS_WINCE QSKIP("Reading and writing to a process is not supported on Qt/CE", SkipAll); #endif +#if defined(Q_OS_SYMBIAN) + QSKIP("Reading and writing to a process is not supported on Qt/Symbian", SkipAll); +#endif QProcess process; @@ -762,6 +813,10 @@ void tst_QProcess::restartProcessDeadlock() #ifdef Q_OS_WINCE QSKIP("Reading and writing to a process is not supported on Qt/CE", SkipAll); #endif +#if defined(Q_OS_SYMBIAN) + QSKIP("Reading and writing to a process is not supported on Qt/Symbian", SkipAll); +#endif + // The purpose of this test is to detect whether restarting a // process in the finished() connected slot causes a deadlock // because of the way QProcessManager uses its locks. @@ -799,6 +854,9 @@ void tst_QProcess::closeWriteChannel() #ifdef Q_OS_WINCE QSKIP("Reading and writing to a process is not supported on Qt/CE", SkipAll); #endif +#if defined(Q_OS_SYMBIAN) + QSKIP("Reading and writing to a process is not supported on Qt/Symbian", SkipAll); +#endif QProcess more; more.start("testProcessEOF/testProcessEOF"); @@ -828,6 +886,9 @@ void tst_QProcess::closeReadChannel() #ifdef Q_OS_WINCE QSKIP("Reading and writing to a process is not supported on Qt/CE", SkipAll); #endif +#if defined(Q_OS_SYMBIAN) + QSKIP("Reading and writing to a process is not supported on Qt/Symbian", SkipAll); +#endif for (int i = 0; i < 10; ++i) { QProcess::ProcessChannel channel1 = QProcess::StandardOutput; @@ -865,6 +926,9 @@ void tst_QProcess::openModes() #ifdef Q_OS_WINCE QSKIP("Reading and writing to a process is not supported on Qt/CE", SkipAll); #endif +#if defined(Q_OS_SYMBIAN) + QSKIP("Reading and writing to a process is not supported on Qt/Symbian", SkipAll); +#endif QProcess proc; QVERIFY(!proc.isOpen()); @@ -915,6 +979,9 @@ void tst_QProcess::emitReadyReadOnlyWhenNewDataArrives() #ifdef Q_OS_WINCE QSKIP("Reading and writing to a process is not supported on Qt/CE", SkipAll); #endif +#if defined(Q_OS_SYMBIAN) + QSKIP("Reading and writing to a process is not supported on Qt/Symbian", SkipAll); +#endif QProcess proc; connect(&proc, SIGNAL(readyRead()), this, SLOT(exitLoopSlot())); @@ -951,6 +1018,9 @@ void tst_QProcess::emitReadyReadOnlyWhenNewDataArrives() //----------------------------------------------------------------------------- void tst_QProcess::hardExit() { +#if defined(Q_OS_SYMBIAN) + QSKIP("Killing started processes is not supported on Qt/Symbian due platform security", SkipAll); +#endif QProcess proc; #if defined(Q_OS_MAC) @@ -977,6 +1047,9 @@ void tst_QProcess::hardExit() //----------------------------------------------------------------------------- void tst_QProcess::softExit() { +#if defined(Q_OS_SYMBIAN) + QSKIP("Terminating started processes is not supported on Qt/Symbian due platform security", SkipAll); +#endif QProcess proc; proc.start("testSoftExit/testSoftExit"); @@ -998,7 +1071,7 @@ class SoftExitProcess : public QProcess Q_OBJECT public: bool waitedForFinished; - + SoftExitProcess(int n) : waitedForFinished(false), n(n), killing(false) { connect(this, SIGNAL(finished(int, QProcess::ExitStatus)), @@ -1081,6 +1154,9 @@ void tst_QProcess::softExitInSlots() #ifdef Q_OS_WINCE QSKIP("Reading and writing to a process is not supported on Qt/CE", SkipAll); #endif +#if defined(Q_OS_SYMBIAN) + QSKIP("Reading and writing to a process is not supported on Qt/Symbian", SkipAll); +#endif QFETCH(QString, appName); @@ -1100,6 +1176,9 @@ void tst_QProcess::mergedChannels() #ifdef Q_OS_WINCE QSKIP("Reading and writing to a process is not supported on Qt/CE", SkipAll); #endif +#if defined(Q_OS_SYMBIAN) + QSKIP("Reading and writing to a process is not supported on Qt/Symbian", SkipAll); +#endif QProcess process; process.setReadChannelMode(QProcess::MergedChannels); @@ -1130,11 +1209,14 @@ void tst_QProcess::forwardedChannels() #ifdef Q_OS_WINCE QSKIP("Reading and writing to a process is not supported on Qt/CE", SkipAll); #endif +#if defined(Q_OS_SYMBIAN) + QSKIP("Reading and writing to a process is not supported on Qt/Symbian", SkipAll); +#endif QProcess process; process.setReadChannelMode(QProcess::ForwardedChannels); QCOMPARE(process.readChannelMode(), QProcess::ForwardedChannels); - + #ifdef Q_OS_MAC process.start("testProcessEcho2/testProcessEcho2.app"); #else @@ -1157,6 +1239,9 @@ void tst_QProcess::atEnd() #ifdef Q_OS_WINCE QSKIP("Reading and writing to a process is not supported on Qt/CE", SkipAll); #endif +#if defined(Q_OS_SYMBIAN) + QSKIP("Reading and writing to a process is not supported on Qt/Symbian", SkipAll); +#endif QProcess process; @@ -1189,6 +1274,10 @@ public: return exitCode; } +#if defined(Q_OS_SYMBIAN) + int serial; +#endif + protected: inline void run() { @@ -1200,11 +1289,21 @@ protected: #ifdef Q_OS_MAC process.start("testProcessEcho/testProcessEcho.app"); +#elif defined(Q_OS_SYMBIAN) && defined(Q_CC_NOKIAX86) + // WINSCW builds in Symbian do not allow multiple processes to load Qt libraries, + // so use just a simple process instead of testDetached. + process.start("testProcessNormal"); +#elif defined(Q_OS_SYMBIAN) + // testDetached used because it does something, but doesn't take too long. + QFile infoFile(QString("c:\\logs\\detinfo%1").arg(serial)); + QStringList args; + args << infoFile.fileName(); + process.start("testDetached", args); #else process.start("testProcessEcho/testProcessEcho"); #endif -#if !defined(Q_OS_WINCE) +#if !defined(Q_OS_WINCE) && !defined(Q_OS_SYMBIAN) QCOMPARE(process.write("abc\0", 4), qint64(4)); #endif exitCode = exec(); @@ -1219,6 +1318,15 @@ protected slots: private: int exitCode; +#ifdef Q_OS_SYMBIAN + enum + { + /** + * The maximum stack size. + */ + SymbianStackSize = 0x14000 + }; +#endif }; //----------------------------------------------------------------------------- @@ -1226,6 +1334,9 @@ void tst_QProcess::processInAThread() { for (int i = 0; i < 10; ++i) { TestThread thread; +#if defined(Q_OS_SYMBIAN) + thread.setStackSize(SymbianStackSize); +#endif thread.start(); QVERIFY(thread.wait(10000)); QCOMPARE(thread.code(), 0); @@ -1235,11 +1346,24 @@ void tst_QProcess::processInAThread() //----------------------------------------------------------------------------- void tst_QProcess::processesInMultipleThreads() { +#if defined(Q_OS_SYMBIAN) + int serialCounter = 0; +#endif + for (int i = 0; i < 10; ++i) { TestThread thread1; TestThread thread2; TestThread thread3; +#if defined(Q_OS_SYMBIAN) + thread1.serial = serialCounter++; + thread2.serial = serialCounter++; + thread3.serial = serialCounter++; + + thread1.setStackSize(SymbianStackSize); + thread2.setStackSize(SymbianStackSize); + thread3.setStackSize(SymbianStackSize); +#endif thread1.start(); thread2.start(); thread3.start(); @@ -1265,14 +1389,26 @@ void tst_QProcess::waitForFinishedWithTimeout() #ifdef Q_OS_MAC process->start("testProcessEcho/testProcessEcho.app"); +#elif defined(Q_OS_SYMBIAN) + process->start("testProcessOutput"); #else process->start("testProcessEcho/testProcessEcho"); #endif + +#if defined(Q_OS_SYMBIAN) + QVERIFY(process->waitForStarted(50)); + QVERIFY(!process->waitForFinished(1)); +#else QVERIFY(process->waitForStarted(5000)); QVERIFY(!process->waitForFinished(1)); process->write("", 1); +#endif + QVERIFY(process->waitForFinished()); + + delete process; + process = 0; } //----------------------------------------------------------------------------- @@ -1281,6 +1417,9 @@ void tst_QProcess::waitForReadyReadInAReadyReadSlot() #ifdef Q_OS_WINCE QSKIP("Reading and writing to a process is not supported on Qt/CE", SkipAll); #endif +#if defined(Q_OS_SYMBIAN) + QSKIP("Reading and writing to a process is not supported on Qt/Symbian", SkipAll); +#endif process = new QProcess(this); connect(process, SIGNAL(readyRead()), this, SLOT(waitForReadyReadInAReadyReadSlotSlot())); @@ -1300,7 +1439,7 @@ void tst_QProcess::waitForReadyReadInAReadyReadSlot() QVERIFY(!QTestEventLoop::instance().timeout()); QCOMPARE(spy.count(), 1); - + process->disconnect(); QVERIFY(process->waitForFinished(5000)); QVERIFY(process->bytesAvailable() > bytesAvailable); @@ -1314,6 +1453,9 @@ void tst_QProcess::waitForReadyReadInAReadyReadSlotSlot() #ifdef Q_OS_WINCE QSKIP("Reading and writing to a process is not supported on Qt/CE", SkipAll); #endif +#if defined(Q_OS_SYMBIAN) + QSKIP("Reading and writing to a process is not supported on Qt/Symbian", SkipAll); +#endif bytesAvailable = process->bytesAvailable(); process->write("bar", 4); @@ -1327,6 +1469,9 @@ void tst_QProcess::waitForBytesWrittenInABytesWrittenSlot() #ifdef Q_OS_WINCE QSKIP("Reading and writing to a process is not supported on Qt/CE", SkipAll); #endif +#if defined(Q_OS_SYMBIAN) + QSKIP("Reading and writing to a process is not supported on Qt/Symbian", SkipAll); +#endif process = new QProcess(this); connect(process, SIGNAL(bytesWritten(qint64)), this, SLOT(waitForBytesWrittenInABytesWrittenSlotSlot())); @@ -1359,6 +1504,9 @@ void tst_QProcess::waitForBytesWrittenInABytesWrittenSlotSlot() #ifdef Q_OS_WINCE QSKIP("Reading and writing to a process is not supported on Qt/CE", SkipAll); #endif +#if defined(Q_OS_SYMBIAN) + QSKIP("Reading and writing to a process is not supported on Qt/Symbian", SkipAll); +#endif process->write("b"); QVERIFY(process->waitForBytesWritten(5000)); @@ -1417,18 +1565,20 @@ void tst_QProcess::spaceArgsTest() QStringList programs; programs << QString::fromLatin1("testProcessSpacesArgs/nospace") +#if defined(Q_OS_SYMBIAN) + ; // Symbian toolchain doesn't like exes with spaces in the name +#else << QString::fromLatin1("testProcessSpacesArgs/one space") << QString::fromLatin1("testProcessSpacesArgs/two space s"); +#endif process = new QProcess(this); for (int i = 0; i < programs.size(); ++i) { - QString program = programs.at(i); - process->start(program, args); -#ifndef Q_OS_WINCE +#if !defined(Q_OS_WINCE) && !defined(Q_OS_SYMBIAN) QVERIFY(process->waitForStarted(5000)); QVERIFY(process->waitForFinished(5000)); #else @@ -1436,10 +1586,19 @@ void tst_QProcess::spaceArgsTest() QVERIFY(process->waitForFinished(10000)); #endif -#if !defined(Q_OS_WINCE) +#if defined(Q_OS_SYMBIAN) + // Symbian test outputs to a file, so check that + FILE* file = fopen("c:\\logs\\qprocess_args_test.txt","r"); + char buf[256]; + fgets(buf, 256, file); + fclose(file); + QStringList actual = QString::fromLatin1(buf).split("|"); +#elif !defined(Q_OS_WINCE) QStringList actual = QString::fromLatin1(process->readAll()).split("|"); +#endif +#if !defined(Q_OS_WINCE) QVERIFY(!actual.isEmpty()); - // not onterested in the program name, it might be different. + // not interested in the program name, it might be different. actual.removeFirst(); QCOMPARE(actual, args); @@ -1456,10 +1615,18 @@ void tst_QProcess::spaceArgsTest() QVERIFY(process->waitForStarted(5000)); QVERIFY(process->waitForFinished(5000)); -#if !defined(Q_OS_WINCE) +#if defined(Q_OS_SYMBIAN) + // Symbian test outputs to a file, so check that + file = fopen("c:\\logs\\qprocess_args_test.txt","r"); + fgets(buf, 256, file); + fclose(file); + actual = QString::fromLatin1(buf).split("|"); +#elif !defined(Q_OS_WINCE) actual = QString::fromLatin1(process->readAll()).split("|"); +#endif +#if !defined(Q_OS_WINCE) QVERIFY(!actual.isEmpty()); - // not onterested in the program name, it might be different. + // not interested in the program name, it might be different. actual.removeFirst(); QCOMPARE(actual, args); @@ -1473,7 +1640,13 @@ void tst_QProcess::spaceArgsTest() //----------------------------------------------------------------------------- void tst_QProcess::exitCodeTest() { +#if defined(Q_OS_SYMBIAN) + // Kernel will run out of process handles on some hw, as there is some + // delay before they are recycled, so limit the amount of processes. + for (int i = 0; i < 50; ++i) { +#else for (int i = 0; i < 255; ++i) { +#endif QProcess process; process.start("testExitCodes/testExitCodes " + QString::number(i)); QVERIFY(process.waitForFinished(5000)); @@ -1495,10 +1668,10 @@ void tst_QProcess::failToStart() QSignalSpy finishedSpy(&process, SIGNAL(finished(int))); QSignalSpy finishedSpy2(&process, SIGNAL(finished(int, QProcess::ExitStatus))); -// Mac OS X and HP-UX have a really low defualt process limit (~100), so spawning +// Mac OS X and HP-UX have a really low defualt process limit (~100), so spawning // to many processes here will cause test failures later on. #if defined Q_OS_HPUX - const int attempts = 15; + const int attempts = 15; #elif defined Q_OS_MAC const int attempts = 15; #else @@ -1536,7 +1709,7 @@ void tst_QProcess::failToStart() QCOMPARE(finishedSpy2.count(), 0); int it = j * attempts + i + 1; - + QCOMPARE(stateSpy.count(), it * 2); QCOMPARE(qVariantValue<QProcess::ProcessState>(stateSpy.at(it * 2 - 2).at(0)), QProcess::Starting); QCOMPARE(qVariantValue<QProcess::ProcessState>(stateSpy.at(it * 2 - 1).at(0)), QProcess::NotRunning); @@ -1601,6 +1774,9 @@ void tst_QProcess::removeFileWhileProcessIsRunning() #ifdef Q_OS_WINCE QSKIP("Reading and writing to a process is not supported on Qt/CE", SkipAll); #endif +#if defined(Q_OS_SYMBIAN) + QSKIP("Reading and writing to a process is not supported on Qt/Symbian", SkipAll); +#endif QFile file("removeFile.txt"); QVERIFY(file.open(QFile::WriteOnly)); @@ -1640,8 +1816,9 @@ void tst_QProcess::setEnvironment_data() void tst_QProcess::setEnvironment() { -#if !defined (Q_OS_WINCE) - // there is no concept of system variables on Windows CE as there is no console +#if defined (Q_OS_WINCE) || defined(Q_OS_SYMBIAN) + QSKIP("OS doesn't support environment variables", SkipAll); +#endif // make sure our environment variables are correct QVERIFY(qgetenv("tst_QProcess").isEmpty()); @@ -1697,16 +1874,39 @@ void tst_QProcess::setEnvironment() QCOMPARE(process.readAll(), value.toLocal8Bit()); } +#endif +} + +//----------------------------------------------------------------------------- +void tst_QProcess::setProcessEnvironment_data() +{ + setEnvironment_data(); +} + +void tst_QProcess::setProcessEnvironment() +{ +#if !defined (Q_OS_WINCE) + // there is no concept of system variables on Windows CE as there is no console + + // make sure our environment variables are correct + QVERIFY(qgetenv("tst_QProcess").isEmpty()); + QVERIFY(!qgetenv("PATH").isEmpty()); +#ifdef Q_OS_WIN + QVERIFY(!qgetenv("PROMPT").isEmpty()); +#endif + + QFETCH(QString, name); + QFETCH(QString, value); + QString executable = QDir::currentPath() + "/testProcessEnvironment/testProcessEnvironment"; - // use the hash variant now { QProcess process; - QHash<QString, QString> environment = QProcess::systemEnvironmentHash(); + QProcessEnvironment environment = QProcessEnvironment::systemEnvironment(); if (value.isNull()) environment.remove(name); else environment.insert(name, value); - process.setEnvironmentHash(environment); + process.setProcessEnvironment(environment); process.start(executable, QStringList() << name); QVERIFY(process.waitForFinished()); @@ -1717,20 +1917,19 @@ void tst_QProcess::setEnvironment() QCOMPARE(process.readAll(), value.toLocal8Bit()); } -#endif } //----------------------------------------------------------------------------- void tst_QProcess::systemEnvironment() { -#if defined (Q_OS_WINCE) +#if defined (Q_OS_WINCE) || defined(Q_OS_SYMBIAN) // there is no concept of system variables on Windows CE as there is no console QVERIFY(QProcess::systemEnvironment().isEmpty()); - QVERIFY(QProcess::systemEnvironmentHash().isEmpty()); + QVERIFY(QProcessEnvironment::systemEnvironment().isEmpty()); #else QVERIFY(!QProcess::systemEnvironment().isEmpty()); - QVERIFY(!QProcess::systemEnvironmentHash().isEmpty()); + QVERIFY(!QProcessEnvironment::systemEnvironment().isEmpty()); - QVERIFY(QProcess::systemEnvironmentHash().contains("PATH")); + QVERIFY(QProcessEnvironment::systemEnvironment().contains("PATH")); QVERIFY(!QProcess::systemEnvironment().filter(QRegExp("^PATH=", Qt::CaseInsensitive)).isEmpty()); #endif } @@ -1741,6 +1940,9 @@ void tst_QProcess::spaceInName() #ifdef Q_OS_WINCE QSKIP("Reading and writing to a process is not supported on Qt/CE", SkipAll); #endif +#if defined(Q_OS_SYMBIAN) + QSKIP("Reading and writing to a process is not supported on Qt/Symbian", SkipAll); +#endif QProcess process; process.start("test Space In Name/testSpaceInName", QStringList()); QVERIFY(process.waitForStarted()); @@ -1751,7 +1953,10 @@ void tst_QProcess::spaceInName() //----------------------------------------------------------------------------- void tst_QProcess::lockupsInStartDetached() { +#if !defined(Q_OS_SYMBIAN) + // What exactly is this call supposed to achieve anyway? QHostInfo::lookupHost(QString("something.invalid"), 0, 0); +#endif QProcess::execute("yjhbrty"); QProcess::startDetached("yjhbrty"); } @@ -1762,6 +1967,9 @@ void tst_QProcess::atEnd2() #ifdef Q_OS_WINCE QSKIP("Reading and writing to a process is not supported on Qt/CE", SkipAll); #endif +#if defined(Q_OS_SYMBIAN) + QSKIP("Reading and writing to a process is not supported on Qt/Symbian", SkipAll); +#endif QProcess process; @@ -1787,7 +1995,7 @@ void tst_QProcess::waitForReadyReadForNonexistantProcess() // Start a program that doesn't exist, process events and then try to waitForReadyRead qRegisterMetaType<QProcess::ProcessError>("QProcess::ProcessError"); qRegisterMetaType<QProcess::ExitStatus>("QProcess::ExitStatus"); - + QProcess process; QSignalSpy errorSpy(&process, SIGNAL(error(QProcess::ProcessError))); QSignalSpy finishedSpy1(&process, SIGNAL(finished(int))); @@ -1807,11 +2015,14 @@ void tst_QProcess::setStandardInputFile() #ifdef Q_OS_WINCE QSKIP("Reading and writing to a process is not supported on Qt/CE", SkipAll); #endif +#if defined(Q_OS_SYMBIAN) + QSKIP("Reading and writing to a process is not supported on Qt/Symbian", SkipAll); +#endif static const char data[] = "A bunch\1of\2data\3\4\5\6\7..."; QProcess process; QFile file("data"); - + QVERIFY(file.open(QIODevice::WriteOnly)); file.write(data, sizeof data); file.close(); @@ -1823,7 +2034,7 @@ void tst_QProcess::setStandardInputFile() process.start("testProcessEcho/testProcessEcho"); #endif - QPROCESS_VERIFY(process, waitForFinished()); + QPROCESS_VERIFY(process, waitForFinished()); QByteArray all = process.readAll(); QCOMPARE(all.size(), int(sizeof data) - 1); // testProcessEcho drops the ending \0 QVERIFY(all == data); @@ -1863,6 +2074,9 @@ void tst_QProcess::setStandardOutputFile() #ifdef Q_OS_WINCE QSKIP("Reading and writing to a process is not supported on Qt/CE", SkipAll); #endif +#if defined(Q_OS_SYMBIAN) + QSKIP("Reading and writing to a process is not supported on Qt/Symbian", SkipAll); +#endif static const char data[] = "Original data. "; static const char testdata[] = "Test data."; @@ -1894,7 +2108,7 @@ void tst_QProcess::setStandardOutputFile() process.start("testProcessEcho2/testProcessEcho2"); #endif process.write(testdata, sizeof testdata); - QPROCESS_VERIFY(process,waitForFinished()); + QPROCESS_VERIFY(process,waitForFinished()); // open the file again and verify the data QVERIFY(file.open(QIODevice::ReadOnly)); @@ -1928,10 +2142,13 @@ void tst_QProcess::setStandardOutputProcess() #ifdef Q_OS_WINCE QSKIP("Reading and writing to a process is not supported on Qt/CE", SkipAll); #endif +#if defined(Q_OS_SYMBIAN) + QSKIP("Reading and writing to a process is not supported on Qt/Symbian", SkipAll); +#endif QProcess source; QProcess sink; - + QFETCH(bool, merged); source.setReadChannelMode(merged ? QProcess::MergedChannels : QProcess::SeparateChannels); source.setStandardOutputProcess(&sink); @@ -1963,6 +2180,9 @@ void tst_QProcess::fileWriterProcess() #ifdef Q_OS_WINCE QSKIP("Reading and writing to a process is not supported on Qt/CE", SkipAll); #endif +#if defined(Q_OS_SYMBIAN) + QSKIP("Reading and writing to a process is not supported on Qt/Symbian", SkipAll); +#endif QString stdinStr; for (int i = 0; i < 5000; ++i) @@ -1989,17 +2209,30 @@ void tst_QProcess::fileWriterProcess() //----------------------------------------------------------------------------- void tst_QProcess::detachedWorkingDirectoryAndPid() { +#if defined(Q_OS_SYMBIAN) && defined(Q_CC_NOKIAX86) + // WINSCW builds in Symbian do not allow multiple processes to load Qt libraries, + // so this test must be skipped. + QSKIP("Multiple processes loading Qt are not allowed in Qt/Symbian emulator.", SkipAll); +#endif qint64 pid; #ifdef Q_OS_WINCE QTest::qSleep(1000); #endif +#if defined(Q_OS_SYMBIAN) + // Symbian has no working directory support, so use logs dir as a shared directory + QFile infoFile(QLatin1String("c:\\logs\\detachedinfo.txt")); +#else QFile infoFile(QDir::currentPath() + QLatin1String("/detachedinfo.txt")); +#endif infoFile.remove(); QString workingDir = QDir::currentPath() + "/testDetached"; + +#ifndef Q_OS_SYMBIAN QVERIFY(QFile::exists(workingDir)); +#endif QStringList args; args << infoFile.fileName(); @@ -2023,6 +2256,9 @@ void tst_QProcess::detachedWorkingDirectoryAndPid() qint64 actualPid = processIdString.toLongLong(&ok); QVERIFY(ok); +#if defined(Q_OS_SYMBIAN) + QEXPECT_FAIL("", "Working directory is not supported on Qt/symbian", Continue); +#endif QCOMPARE(actualWorkingDir, workingDir); QCOMPARE(actualPid, pid); } @@ -2033,8 +2269,11 @@ void tst_QProcess::switchReadChannels() #ifdef Q_OS_WINCE QSKIP("Reading and writing to a process is not supported on Qt/CE", SkipAll); #endif +#if defined(Q_OS_SYMBIAN) + QSKIP("Reading and writing to a process is not supported on Qt/Symbian", SkipAll); +#endif const char data[] = "ABCD"; - + QProcess process; #ifdef Q_OS_MAC @@ -2052,7 +2291,7 @@ void tst_QProcess::switchReadChannels() process.setReadChannel(QProcess::StandardError); QCOMPARE(process.read(1), QByteArray(&data[i], 1)); } - + process.ungetChar('D'); process.setReadChannel(QProcess::StandardOutput); process.ungetChar('D'); @@ -2068,6 +2307,9 @@ void tst_QProcess::setWorkingDirectory() #ifdef Q_OS_WINCE QSKIP("Windows CE does not support working directory logic", SkipAll); #endif +#if defined(Q_OS_SYMBIAN) + QSKIP("Symbian does not support working directory logic", SkipAll); +#endif process = new QProcess; process->setWorkingDirectory("test"); #ifdef Q_OS_MAC @@ -2100,13 +2342,22 @@ void tst_QProcess::startFinishStartFinish() #else process.start("testProcessOutput/testProcessOutput"); #endif -#ifndef Q_OS_WINCE +#if !defined(Q_OS_WINCE) && !defined(Q_OS_SYMBIAN) QVERIFY(process.waitForReadyRead(10000)); QCOMPARE(QString::fromLatin1(process.readLine().trimmed()), QString("0 -this is a number")); #endif if (process.state() != QProcess::NotRunning) QVERIFY(process.waitForFinished(10000)); +#if defined(Q_OS_SYMBIAN) + // Symbian test outputs to a file, so check that + FILE* file = fopen("c:\\logs\\qprocess_output_test.txt","r"); + char buf[30]; + fgets(buf, 30, file); + QCOMPARE(QString::fromLatin1(buf), + QString("0 -this is a number\n")); + fclose(file); +#endif } } diff --git a/tests/auto/qpropertyanimation/tst_qpropertyanimation.cpp b/tests/auto/qpropertyanimation/tst_qpropertyanimation.cpp index 3ff177a..04cfe1a 100644 --- a/tests/auto/qpropertyanimation/tst_qpropertyanimation.cpp +++ b/tests/auto/qpropertyanimation/tst_qpropertyanimation.cpp @@ -114,6 +114,7 @@ private slots: void updateOnSetKeyValues(); void restart(); void valueChanged(); + void twoAnimations(); }; tst_QPropertyAnimation::tst_QPropertyAnimation() @@ -1079,6 +1080,55 @@ void tst_QPropertyAnimation::valueChanged() } } +//this class will help us make sure that 2 animations started +//at the same time also end at the same time +class MySyncObject : public MyErrorObject +{ + Q_OBJECT +public: + MySyncObject() : anim(this, "ole") + { + anim.setEndValue(1000); + } +public slots: + void checkAnimationFinished() + { + QCOMPARE(anim.state(), QAbstractAnimation::Stopped); + QCOMPARE(ole(), 1000); + } + +public: + QPropertyAnimation anim; +}; + +void tst_QPropertyAnimation::twoAnimations() +{ + MySyncObject o1, o2; + o1.setOle(0); + o2.setOle(0); + + //when the animation in o1 is finished + //the animation in o2 should stop around the same time + //We use a queued connection to check just after the tick from the common timer + //the other way is true too + QObject::connect(&o1.anim, SIGNAL(finished()), + &o2, SLOT(checkAnimationFinished()), Qt::QueuedConnection); + QObject::connect(&o2.anim, SIGNAL(finished()), + &o1, SLOT(checkAnimationFinished()), Qt::QueuedConnection); + + o1.anim.start(); + o2.anim.start(); + + QTest::qWait(o1.anim.duration() + 50); + QCOMPARE(o1.anim.state(), QAbstractAnimation::Stopped); + QCOMPARE(o2.anim.state(), QAbstractAnimation::Stopped); + + QCOMPARE(o1.ole(), 1000); + QCOMPARE(o2.ole(), 1000); + +} + + QTEST_MAIN(tst_QPropertyAnimation) diff --git a/tests/auto/qqueue/qqueue.pro b/tests/auto/qqueue/qqueue.pro index f6561d3..ed489f9 100644 --- a/tests/auto/qqueue/qqueue.pro +++ b/tests/auto/qqueue/qqueue.pro @@ -3,5 +3,4 @@ load(qttest_p4) QT = core SOURCES += tst_qqueue.cpp - - +QT = core diff --git a/tests/auto/qrand/qrand.pro b/tests/auto/qrand/qrand.pro index 8f90fbc..c868ed4 100644 --- a/tests/auto/qrand/qrand.pro +++ b/tests/auto/qrand/qrand.pro @@ -1,5 +1,3 @@ load(qttest_p4) SOURCES += tst_qrand.cpp QT = core - - diff --git a/tests/auto/qreadlocker/qreadlocker.pro b/tests/auto/qreadlocker/qreadlocker.pro index 33b0987..5919102 100644 --- a/tests/auto/qreadlocker/qreadlocker.pro +++ b/tests/auto/qreadlocker/qreadlocker.pro @@ -1,5 +1,3 @@ load(qttest_p4) SOURCES += tst_qreadlocker.cpp QT = core - - diff --git a/tests/auto/qreadwritelock/qreadwritelock.pro b/tests/auto/qreadwritelock/qreadwritelock.pro index 2f75c64..4318b18 100644 --- a/tests/auto/qreadwritelock/qreadwritelock.pro +++ b/tests/auto/qreadwritelock/qreadwritelock.pro @@ -1,5 +1,3 @@ load(qttest_p4) SOURCES += tst_qreadwritelock.cpp QT = core - - diff --git a/tests/auto/qrect/qrect.pro b/tests/auto/qrect/qrect.pro index 16dd550..75940b3 100644 --- a/tests/auto/qrect/qrect.pro +++ b/tests/auto/qrect/qrect.pro @@ -1,5 +1,3 @@ load(qttest_p4) SOURCES += tst_qrect.cpp QT = core - - diff --git a/tests/auto/qrect/tst_qrect.cpp b/tests/auto/qrect/tst_qrect.cpp index 4e79126..d9fdab2 100644 --- a/tests/auto/qrect/tst_qrect.cpp +++ b/tests/auto/qrect/tst_qrect.cpp @@ -321,17 +321,17 @@ void tst_QRect::isNull_data() QTest::addColumn<QRect>("r"); QTest::addColumn<bool>("isNull"); - QTest::newRow( "InvalidQRect" ) << getQRectCase( InvalidQRect ) << TRUE; - QTest::newRow( "SmallestQRect" ) << getQRectCase( SmallestQRect ) << FALSE; - QTest::newRow( "MiddleQRect" ) << getQRectCase( MiddleQRect ) << FALSE; - QTest::newRow( "LargestQRect" ) << getQRectCase( LargestQRect ) << FALSE; - QTest::newRow( "SmallestCoordQRect" ) << getQRectCase( SmallestCoordQRect ) << FALSE; - QTest::newRow( "LargestCoordQRect" ) << getQRectCase( LargestCoordQRect ) << TRUE; // Due to overflow - QTest::newRow( "RandomQRect" ) << getQRectCase( RandomQRect ) << FALSE; - QTest::newRow( "NegativeSizeQRect" ) << getQRectCase( NegativeSizeQRect ) << FALSE; - QTest::newRow( "NegativePointQRect" ) << getQRectCase( NegativePointQRect ) << FALSE; - QTest::newRow( "NullQRect" ) << getQRectCase( NullQRect ) << TRUE; - QTest::newRow( "EmptyQRect" ) << getQRectCase( EmptyQRect ) << TRUE; + QTest::newRow( "InvalidQRect" ) << getQRectCase( InvalidQRect ) << true; + QTest::newRow( "SmallestQRect" ) << getQRectCase( SmallestQRect ) << false; + QTest::newRow( "MiddleQRect" ) << getQRectCase( MiddleQRect ) << false; + QTest::newRow( "LargestQRect" ) << getQRectCase( LargestQRect ) << false; + QTest::newRow( "SmallestCoordQRect" ) << getQRectCase( SmallestCoordQRect ) << false; + QTest::newRow( "LargestCoordQRect" ) << getQRectCase( LargestCoordQRect ) << true; // Due to overflow + QTest::newRow( "RandomQRect" ) << getQRectCase( RandomQRect ) << false; + QTest::newRow( "NegativeSizeQRect" ) << getQRectCase( NegativeSizeQRect ) << false; + QTest::newRow( "NegativePointQRect" ) << getQRectCase( NegativePointQRect ) << false; + QTest::newRow( "NullQRect" ) << getQRectCase( NullQRect ) << true; + QTest::newRow( "EmptyQRect" ) << getQRectCase( EmptyQRect ) << true; } void tst_QRect::isNull() @@ -350,17 +350,17 @@ void tst_QRect::newIsEmpty_data() QTest::addColumn<QRect>("r"); QTest::addColumn<bool>("isEmpty"); - QTest::newRow( "InvalidQRect" ) << getQRectCase( InvalidQRect ) << TRUE; - QTest::newRow( "SmallestQRect" ) << getQRectCase( SmallestQRect ) << FALSE; - QTest::newRow( "MiddleQRect" ) << getQRectCase( MiddleQRect ) << FALSE; - QTest::newRow( "LargestQRect" ) << getQRectCase( LargestQRect ) << FALSE; - QTest::newRow( "SmallestCoordQRect" ) << getQRectCase( SmallestCoordQRect ) << FALSE; - QTest::newRow( "LargestCoordQRect" ) << getQRectCase( LargestCoordQRect ) << FALSE; - QTest::newRow( "RandomQRect" ) << getQRectCase( RandomQRect ) << FALSE; - QTest::newRow( "NegativeSizeQRect" ) << getQRectCase( NegativeSizeQRect ) << TRUE; - QTest::newRow( "NegativePointQRect" ) << getQRectCase( NegativePointQRect ) << FALSE; - QTest::newRow( "NullQRect" ) << getQRectCase( NullQRect ) << TRUE; - QTest::newRow( "EmptyQRect" ) << getQRectCase( EmptyQRect ) << TRUE; + QTest::newRow( "InvalidQRect" ) << getQRectCase( InvalidQRect ) << true; + QTest::newRow( "SmallestQRect" ) << getQRectCase( SmallestQRect ) << false; + QTest::newRow( "MiddleQRect" ) << getQRectCase( MiddleQRect ) << false; + QTest::newRow( "LargestQRect" ) << getQRectCase( LargestQRect ) << false; + QTest::newRow( "SmallestCoordQRect" ) << getQRectCase( SmallestCoordQRect ) << false; + QTest::newRow( "LargestCoordQRect" ) << getQRectCase( LargestCoordQRect ) << false; + QTest::newRow( "RandomQRect" ) << getQRectCase( RandomQRect ) << false; + QTest::newRow( "NegativeSizeQRect" ) << getQRectCase( NegativeSizeQRect ) << true; + QTest::newRow( "NegativePointQRect" ) << getQRectCase( NegativePointQRect ) << false; + QTest::newRow( "NullQRect" ) << getQRectCase( NullQRect ) << true; + QTest::newRow( "EmptyQRect" ) << getQRectCase( EmptyQRect ) << true; } void tst_QRect::newIsEmpty() @@ -383,17 +383,17 @@ void tst_QRect::newIsValid_data() QTest::addColumn<QRect>("r"); QTest::addColumn<bool>("isValid"); - QTest::newRow( "InvalidQRect" ) << getQRectCase( InvalidQRect ) << FALSE; - QTest::newRow( "SmallestQRect" ) << getQRectCase( SmallestQRect ) << TRUE; - QTest::newRow( "MiddleQRect" ) << getQRectCase( MiddleQRect ) << TRUE; - QTest::newRow( "LargestQRect" ) << getQRectCase( LargestQRect ) << TRUE; - QTest::newRow( "SmallestCoordQRect" ) << getQRectCase( SmallestCoordQRect ) << TRUE; - QTest::newRow( "LargestCoordQRect" ) << getQRectCase( LargestCoordQRect ) << TRUE; - QTest::newRow( "RandomQRect" ) << getQRectCase( RandomQRect ) << TRUE; - QTest::newRow( "NegativeSizeQRect" ) << getQRectCase( NegativeSizeQRect ) << FALSE; - QTest::newRow( "NegativePointQRect" ) << getQRectCase( NegativePointQRect ) << TRUE; - QTest::newRow( "NullQRect" ) << getQRectCase( NullQRect ) << FALSE; - QTest::newRow( "EmptyQRect" ) << getQRectCase( EmptyQRect ) << FALSE; + QTest::newRow( "InvalidQRect" ) << getQRectCase( InvalidQRect ) << false; + QTest::newRow( "SmallestQRect" ) << getQRectCase( SmallestQRect ) << true; + QTest::newRow( "MiddleQRect" ) << getQRectCase( MiddleQRect ) << true; + QTest::newRow( "LargestQRect" ) << getQRectCase( LargestQRect ) << true; + QTest::newRow( "SmallestCoordQRect" ) << getQRectCase( SmallestCoordQRect ) << true; + QTest::newRow( "LargestCoordQRect" ) << getQRectCase( LargestCoordQRect ) << true; + QTest::newRow( "RandomQRect" ) << getQRectCase( RandomQRect ) << true; + QTest::newRow( "NegativeSizeQRect" ) << getQRectCase( NegativeSizeQRect ) << false; + QTest::newRow( "NegativePointQRect" ) << getQRectCase( NegativePointQRect ) << true; + QTest::newRow( "NullQRect" ) << getQRectCase( NullQRect ) << false; + QTest::newRow( "EmptyQRect" ) << getQRectCase( EmptyQRect ) << false; } void tst_QRect::newIsValid() @@ -4179,28 +4179,28 @@ void tst_QRect::intersectsRect_data() QTest::addColumn<QRect>("rect2"); QTest::addColumn<bool>("intersects"); - QTest::newRow("test 01") << QRect(0, 0, 10, 10) << QRect( 2, 2, 6, 6) << TRUE; - QTest::newRow("test 02") << QRect(0, 0, 10, 10) << QRect( 0, 0, 10, 10) << TRUE; - QTest::newRow("test 03") << QRect(0, 0, 10, 10) << QRect( 2, 2, 10, 10) << TRUE; - QTest::newRow("test 04") << QRect(0, 0, 10, 10) << QRect(20, 20, 10, 10) << FALSE; + QTest::newRow("test 01") << QRect(0, 0, 10, 10) << QRect( 2, 2, 6, 6) << true; + QTest::newRow("test 02") << QRect(0, 0, 10, 10) << QRect( 0, 0, 10, 10) << true; + QTest::newRow("test 03") << QRect(0, 0, 10, 10) << QRect( 2, 2, 10, 10) << true; + QTest::newRow("test 04") << QRect(0, 0, 10, 10) << QRect(20, 20, 10, 10) << false; - QTest::newRow("test 05") << QRect(9, 9, -8, -8) << QRect( 2, 2, 6, 6) << TRUE; - QTest::newRow("test 06") << QRect(9, 9, -8, -8) << QRect( 0, 0, 10, 10) << TRUE; - QTest::newRow("test 07") << QRect(9, 9, -8, -8) << QRect( 2, 2, 10, 10) << TRUE; - QTest::newRow("test 08") << QRect(9, 9, -8, -8) << QRect(20, 20, 10, 10) << FALSE; + QTest::newRow("test 05") << QRect(9, 9, -8, -8) << QRect( 2, 2, 6, 6) << true; + QTest::newRow("test 06") << QRect(9, 9, -8, -8) << QRect( 0, 0, 10, 10) << true; + QTest::newRow("test 07") << QRect(9, 9, -8, -8) << QRect( 2, 2, 10, 10) << true; + QTest::newRow("test 08") << QRect(9, 9, -8, -8) << QRect(20, 20, 10, 10) << false; - QTest::newRow("test 09") << QRect(0, 0, 10, 10) << QRect( 7, 7, -4, -4) << TRUE; - QTest::newRow("test 10") << QRect(0, 0, 10, 10) << QRect( 9, 9, -8, -8) << TRUE; - QTest::newRow("test 11") << QRect(0, 0, 10, 10) << QRect(11, 11, -8, -8) << TRUE; - QTest::newRow("test 12") << QRect(0, 0, 10, 10) << QRect(29, 29, -8, -8) << FALSE; + QTest::newRow("test 09") << QRect(0, 0, 10, 10) << QRect( 7, 7, -4, -4) << true; + QTest::newRow("test 10") << QRect(0, 0, 10, 10) << QRect( 9, 9, -8, -8) << true; + QTest::newRow("test 11") << QRect(0, 0, 10, 10) << QRect(11, 11, -8, -8) << true; + QTest::newRow("test 12") << QRect(0, 0, 10, 10) << QRect(29, 29, -8, -8) << false; - QTest::newRow("test 13") << QRect() << QRect(10, 10, 10, 10) << FALSE; - QTest::newRow("test 14") << QRect(10, 10, 10, 10) << QRect() << FALSE; - QTest::newRow("test 15") << QRect() << QRect() << FALSE; - QTest::newRow("test 16") << QRect(10, 10, 10, 10) << QRect(19, 15, 1, 5) << TRUE; + QTest::newRow("test 13") << QRect() << QRect(10, 10, 10, 10) << false; + QTest::newRow("test 14") << QRect(10, 10, 10, 10) << QRect() << false; + QTest::newRow("test 15") << QRect() << QRect() << false; + QTest::newRow("test 16") << QRect(10, 10, 10, 10) << QRect(19, 15, 1, 5) << true; - QTest::newRow("test 17") << QRect(10, 10, 10, 10) << QRect(15, 19, 5, 1) << TRUE; - QTest::newRow("test 18") << QRect(2, 0, 1, 652) << QRect(2, 0, 1, 652) << TRUE; + QTest::newRow("test 17") << QRect(10, 10, 10, 10) << QRect(15, 19, 5, 1) << true; + QTest::newRow("test 18") << QRect(2, 0, 1, 652) << QRect(2, 0, 1, 652) << true; } void tst_QRect::intersectsRect() @@ -4218,28 +4218,28 @@ void tst_QRect::intersectsRectF_data() QTest::addColumn<QRectF>("rect2"); QTest::addColumn<bool>("intersects"); - QTest::newRow("test 01") << QRectF(0, 0, 10, 10) << QRectF( 2, 2, 6, 6) << TRUE; - QTest::newRow("test 02") << QRectF(0, 0, 10, 10) << QRectF( 0, 0, 10, 10) << TRUE; - QTest::newRow("test 03") << QRectF(0, 0, 10, 10) << QRectF( 2, 2, 10, 10) << TRUE; - QTest::newRow("test 04") << QRectF(0, 0, 10, 10) << QRectF(20, 20, 10, 10) << FALSE; + QTest::newRow("test 01") << QRectF(0, 0, 10, 10) << QRectF( 2, 2, 6, 6) << true; + QTest::newRow("test 02") << QRectF(0, 0, 10, 10) << QRectF( 0, 0, 10, 10) << true; + QTest::newRow("test 03") << QRectF(0, 0, 10, 10) << QRectF( 2, 2, 10, 10) << true; + QTest::newRow("test 04") << QRectF(0, 0, 10, 10) << QRectF(20, 20, 10, 10) << false; - QTest::newRow("test 05") << QRectF(10, 10, -10, -10) << QRectF( 2, 2, 6, 6) << TRUE; - QTest::newRow("test 06") << QRectF(10, 10, -10, -10) << QRectF( 0, 0, 10, 10) << TRUE; - QTest::newRow("test 07") << QRectF(10, 10, -10, -10) << QRectF( 2, 2, 10, 10) << TRUE; - QTest::newRow("test 08") << QRectF(10, 10, -10, -10) << QRectF(20, 20, 10, 10) << FALSE; + QTest::newRow("test 05") << QRectF(10, 10, -10, -10) << QRectF( 2, 2, 6, 6) << true; + QTest::newRow("test 06") << QRectF(10, 10, -10, -10) << QRectF( 0, 0, 10, 10) << true; + QTest::newRow("test 07") << QRectF(10, 10, -10, -10) << QRectF( 2, 2, 10, 10) << true; + QTest::newRow("test 08") << QRectF(10, 10, -10, -10) << QRectF(20, 20, 10, 10) << false; - QTest::newRow("test 09") << QRectF(0, 0, 10, 10) << QRectF( 8, 8, -6, -6) << TRUE; - QTest::newRow("test 10") << QRectF(0, 0, 10, 10) << QRectF(10, 10, -10, -10) << TRUE; - QTest::newRow("test 11") << QRectF(0, 0, 10, 10) << QRectF(12, 12, -10, -10) << TRUE; - QTest::newRow("test 12") << QRectF(0, 0, 10, 10) << QRectF(30, 30, -10, -10) << FALSE; + QTest::newRow("test 09") << QRectF(0, 0, 10, 10) << QRectF( 8, 8, -6, -6) << true; + QTest::newRow("test 10") << QRectF(0, 0, 10, 10) << QRectF(10, 10, -10, -10) << true; + QTest::newRow("test 11") << QRectF(0, 0, 10, 10) << QRectF(12, 12, -10, -10) << true; + QTest::newRow("test 12") << QRectF(0, 0, 10, 10) << QRectF(30, 30, -10, -10) << false; - QTest::newRow("test 13") << QRectF() << QRectF(10, 10, 10, 10) << FALSE; - QTest::newRow("test 14") << QRectF(10, 10, 10, 10) << QRectF() << FALSE; - QTest::newRow("test 15") << QRectF() << QRectF() << FALSE; + QTest::newRow("test 13") << QRectF() << QRectF(10, 10, 10, 10) << false; + QTest::newRow("test 14") << QRectF(10, 10, 10, 10) << QRectF() << false; + QTest::newRow("test 15") << QRectF() << QRectF() << false; - QTest::newRow("test 16") << QRectF(0, 0, 10, 10) << QRectF(10, 10, 10, 10) << FALSE; - QTest::newRow("test 17") << QRectF(0, 0, 10, 10) << QRectF(0, 10, 10, 10) << FALSE; - QTest::newRow("test 18") << QRectF(0, 0, 10, 10) << QRectF(10, 0, 10, 10) << FALSE; + QTest::newRow("test 16") << QRectF(0, 0, 10, 10) << QRectF(10, 10, 10, 10) << false; + QTest::newRow("test 17") << QRectF(0, 0, 10, 10) << QRectF(0, 10, 10, 10) << false; + QTest::newRow("test 18") << QRectF(0, 0, 10, 10) << QRectF(10, 0, 10, 10) << false; } void tst_QRect::intersectsRectF() @@ -4257,24 +4257,24 @@ void tst_QRect::containsRect_data() QTest::addColumn<QRect>("rect2"); QTest::addColumn<bool>("contains"); - QTest::newRow("test 01") << QRect(0, 0, 10, 10) << QRect( 2, 2, 6, 6) << TRUE; - QTest::newRow("test 02") << QRect(0, 0, 10, 10) << QRect( 0, 0, 10, 10) << TRUE; - QTest::newRow("test 03") << QRect(0, 0, 10, 10) << QRect( 2, 2, 10, 10) << FALSE; - QTest::newRow("test 04") << QRect(0, 0, 10, 10) << QRect(20, 20, 10, 10) << FALSE; + QTest::newRow("test 01") << QRect(0, 0, 10, 10) << QRect( 2, 2, 6, 6) << true; + QTest::newRow("test 02") << QRect(0, 0, 10, 10) << QRect( 0, 0, 10, 10) << true; + QTest::newRow("test 03") << QRect(0, 0, 10, 10) << QRect( 2, 2, 10, 10) << false; + QTest::newRow("test 04") << QRect(0, 0, 10, 10) << QRect(20, 20, 10, 10) << false; - QTest::newRow("test 05") << QRect(9, 9, -8, -8) << QRect( 2, 2, 6, 6) << TRUE; - QTest::newRow("test 06") << QRect(9, 9, -8, -8) << QRect( 0, 0, 10, 10) << TRUE; - QTest::newRow("test 07") << QRect(9, 9, -8, -8) << QRect( 2, 2, 10, 10) << FALSE; - QTest::newRow("test 08") << QRect(9, 9, -8, -8) << QRect(20, 20, 10, 10) << FALSE; + QTest::newRow("test 05") << QRect(9, 9, -8, -8) << QRect( 2, 2, 6, 6) << true; + QTest::newRow("test 06") << QRect(9, 9, -8, -8) << QRect( 0, 0, 10, 10) << true; + QTest::newRow("test 07") << QRect(9, 9, -8, -8) << QRect( 2, 2, 10, 10) << false; + QTest::newRow("test 08") << QRect(9, 9, -8, -8) << QRect(20, 20, 10, 10) << false; - QTest::newRow("test 09") << QRect(0, 0, 10, 10) << QRect( 7, 7, -4, -4) << TRUE; - QTest::newRow("test 10") << QRect(0, 0, 10, 10) << QRect( 9, 9, -8, -8) << TRUE; - QTest::newRow("test 11") << QRect(0, 0, 10, 10) << QRect(11, 11, -8, -8) << FALSE; - QTest::newRow("test 12") << QRect(0, 0, 10, 10) << QRect(29, 29, -8, -8) << FALSE; + QTest::newRow("test 09") << QRect(0, 0, 10, 10) << QRect( 7, 7, -4, -4) << true; + QTest::newRow("test 10") << QRect(0, 0, 10, 10) << QRect( 9, 9, -8, -8) << true; + QTest::newRow("test 11") << QRect(0, 0, 10, 10) << QRect(11, 11, -8, -8) << false; + QTest::newRow("test 12") << QRect(0, 0, 10, 10) << QRect(29, 29, -8, -8) << false; - QTest::newRow("test 13") << QRect(-1, 1, 10, 10) << QRect() << FALSE; - QTest::newRow("test 14") << QRect() << QRect(0, 0, 10, 10) << FALSE; - QTest::newRow("test 15") << QRect() << QRect() << FALSE; + QTest::newRow("test 13") << QRect(-1, 1, 10, 10) << QRect() << false; + QTest::newRow("test 14") << QRect() << QRect(0, 0, 10, 10) << false; + QTest::newRow("test 15") << QRect() << QRect() << false; } void tst_QRect::containsRect() @@ -4292,24 +4292,24 @@ void tst_QRect::containsRectF_data() QTest::addColumn<QRectF>("rect2"); QTest::addColumn<bool>("contains"); - QTest::newRow("test 01") << QRectF(0, 0, 10, 10) << QRectF( 2, 2, 6, 6) << TRUE; - QTest::newRow("test 02") << QRectF(0, 0, 10, 10) << QRectF( 0, 0, 10, 10) << TRUE; - QTest::newRow("test 03") << QRectF(0, 0, 10, 10) << QRectF( 2, 2, 10, 10) << FALSE; - QTest::newRow("test 04") << QRectF(0, 0, 10, 10) << QRectF(20, 20, 10, 10) << FALSE; + QTest::newRow("test 01") << QRectF(0, 0, 10, 10) << QRectF( 2, 2, 6, 6) << true; + QTest::newRow("test 02") << QRectF(0, 0, 10, 10) << QRectF( 0, 0, 10, 10) << true; + QTest::newRow("test 03") << QRectF(0, 0, 10, 10) << QRectF( 2, 2, 10, 10) << false; + QTest::newRow("test 04") << QRectF(0, 0, 10, 10) << QRectF(20, 20, 10, 10) << false; - QTest::newRow("test 05") << QRectF(10, 10, -10, -10) << QRectF( 2, 2, 6, 6) << TRUE; - QTest::newRow("test 06") << QRectF(10, 10, -10, -10) << QRectF( 0, 0, 10, 10) << TRUE; - QTest::newRow("test 07") << QRectF(10, 10, -10, -10) << QRectF( 2, 2, 10, 10) << FALSE; - QTest::newRow("test 08") << QRectF(10, 10, -10, -10) << QRectF(20, 20, 10, 10) << FALSE; + QTest::newRow("test 05") << QRectF(10, 10, -10, -10) << QRectF( 2, 2, 6, 6) << true; + QTest::newRow("test 06") << QRectF(10, 10, -10, -10) << QRectF( 0, 0, 10, 10) << true; + QTest::newRow("test 07") << QRectF(10, 10, -10, -10) << QRectF( 2, 2, 10, 10) << false; + QTest::newRow("test 08") << QRectF(10, 10, -10, -10) << QRectF(20, 20, 10, 10) << false; - QTest::newRow("test 09") << QRectF(0, 0, 10, 10) << QRectF( 8, 8, -6, -6) << TRUE; - QTest::newRow("test 10") << QRectF(0, 0, 10, 10) << QRectF(10, 10, -10, -10) << TRUE; - QTest::newRow("test 11") << QRectF(0, 0, 10, 10) << QRectF(12, 12, -10, -10) << FALSE; - QTest::newRow("test 12") << QRectF(0, 0, 10, 10) << QRectF(30, 30, -10, -10) << FALSE; + QTest::newRow("test 09") << QRectF(0, 0, 10, 10) << QRectF( 8, 8, -6, -6) << true; + QTest::newRow("test 10") << QRectF(0, 0, 10, 10) << QRectF(10, 10, -10, -10) << true; + QTest::newRow("test 11") << QRectF(0, 0, 10, 10) << QRectF(12, 12, -10, -10) << false; + QTest::newRow("test 12") << QRectF(0, 0, 10, 10) << QRectF(30, 30, -10, -10) << false; - QTest::newRow("test 13") << QRectF(-1, 1, 10, 10) << QRectF() << FALSE; - QTest::newRow("test 14") << QRectF() << QRectF(0, 0, 10, 10) << FALSE; - QTest::newRow("test 15") << QRectF() << QRectF() << FALSE; + QTest::newRow("test 13") << QRectF(-1, 1, 10, 10) << QRectF() << false; + QTest::newRow("test 14") << QRectF() << QRectF(0, 0, 10, 10) << false; + QTest::newRow("test 15") << QRectF() << QRectF() << false; } void tst_QRect::containsRectF() @@ -4328,35 +4328,35 @@ void tst_QRect::containsPoint_data() QTest::addColumn<bool>("contains"); QTest::addColumn<bool>("containsProper"); - QTest::newRow("test 01") << QRect(0, 0, 10, 10) << QPoint( 0, 0) << TRUE << FALSE; - QTest::newRow("test 02") << QRect(0, 0, 10, 10) << QPoint( 0, 10) << FALSE << FALSE; - QTest::newRow("test 03") << QRect(0, 0, 10, 10) << QPoint(10, 0) << FALSE << FALSE; - QTest::newRow("test 04") << QRect(0, 0, 10, 10) << QPoint(10, 10) << FALSE << FALSE; - QTest::newRow("test 05") << QRect(0, 0, 10, 10) << QPoint( 0, 9) << TRUE << FALSE; - QTest::newRow("test 06") << QRect(0, 0, 10, 10) << QPoint( 9, 0) << TRUE << FALSE; - QTest::newRow("test 07") << QRect(0, 0, 10, 10) << QPoint( 9, 9) << TRUE << FALSE; - QTest::newRow("test 08") << QRect(0, 0, 10, 10) << QPoint( 1, 0) << TRUE << FALSE; - QTest::newRow("test 09") << QRect(0, 0, 10, 10) << QPoint( 9, 1) << TRUE << FALSE; - QTest::newRow("test 10") << QRect(0, 0, 10, 10) << QPoint( 1, 1) << TRUE << TRUE; - QTest::newRow("test 11") << QRect(0, 0, 10, 10) << QPoint( 1, 8) << TRUE << TRUE; - QTest::newRow("test 12") << QRect(0, 0, 10, 10) << QPoint( 8, 8) << TRUE << TRUE; - - QTest::newRow("test 13") << QRect(9, 9, -8, -8) << QPoint( 0, 0) << TRUE << FALSE; - QTest::newRow("test 14") << QRect(9, 9, -8, -8) << QPoint( 0, 10) << FALSE << FALSE; - QTest::newRow("test 15") << QRect(9, 9, -8, -8) << QPoint(10, 0) << FALSE << FALSE; - QTest::newRow("test 16") << QRect(9, 9, -8, -8) << QPoint(10, 10) << FALSE << FALSE; - QTest::newRow("test 17") << QRect(9, 9, -8, -8) << QPoint( 0, 9) << TRUE << FALSE; - QTest::newRow("test 18") << QRect(9, 9, -8, -8) << QPoint( 9, 0) << TRUE << FALSE; - QTest::newRow("test 19") << QRect(9, 9, -8, -8) << QPoint( 9, 9) << TRUE << FALSE; - QTest::newRow("test 20") << QRect(9, 9, -8, -8) << QPoint( 1, 0) << TRUE << FALSE; - QTest::newRow("test 21") << QRect(9, 9, -8, -8) << QPoint( 9, 1) << TRUE << FALSE; - QTest::newRow("test 22") << QRect(9, 9, -8, -8) << QPoint( 1, 1) << TRUE << TRUE; - QTest::newRow("test 23") << QRect(9, 9, -8, -8) << QPoint( 1, 8) << TRUE << TRUE; - QTest::newRow("test 24") << QRect(9, 9, -8, -8) << QPoint( 8, 8) << TRUE << TRUE; - - QTest::newRow("test 25") << QRect(-1, 1, 10, 10) << QPoint() << FALSE << FALSE; - QTest::newRow("test 26") << QRect() << QPoint(1, 1) << FALSE << FALSE; - QTest::newRow("test 27") << QRect() << QPoint() << FALSE << FALSE; + QTest::newRow("test 01") << QRect(0, 0, 10, 10) << QPoint( 0, 0) << true << false; + QTest::newRow("test 02") << QRect(0, 0, 10, 10) << QPoint( 0, 10) << false << false; + QTest::newRow("test 03") << QRect(0, 0, 10, 10) << QPoint(10, 0) << false << false; + QTest::newRow("test 04") << QRect(0, 0, 10, 10) << QPoint(10, 10) << false << false; + QTest::newRow("test 05") << QRect(0, 0, 10, 10) << QPoint( 0, 9) << true << false; + QTest::newRow("test 06") << QRect(0, 0, 10, 10) << QPoint( 9, 0) << true << false; + QTest::newRow("test 07") << QRect(0, 0, 10, 10) << QPoint( 9, 9) << true << false; + QTest::newRow("test 08") << QRect(0, 0, 10, 10) << QPoint( 1, 0) << true << false; + QTest::newRow("test 09") << QRect(0, 0, 10, 10) << QPoint( 9, 1) << true << false; + QTest::newRow("test 10") << QRect(0, 0, 10, 10) << QPoint( 1, 1) << true << true; + QTest::newRow("test 11") << QRect(0, 0, 10, 10) << QPoint( 1, 8) << true << true; + QTest::newRow("test 12") << QRect(0, 0, 10, 10) << QPoint( 8, 8) << true << true; + + QTest::newRow("test 13") << QRect(9, 9, -8, -8) << QPoint( 0, 0) << true << false; + QTest::newRow("test 14") << QRect(9, 9, -8, -8) << QPoint( 0, 10) << false << false; + QTest::newRow("test 15") << QRect(9, 9, -8, -8) << QPoint(10, 0) << false << false; + QTest::newRow("test 16") << QRect(9, 9, -8, -8) << QPoint(10, 10) << false << false; + QTest::newRow("test 17") << QRect(9, 9, -8, -8) << QPoint( 0, 9) << true << false; + QTest::newRow("test 18") << QRect(9, 9, -8, -8) << QPoint( 9, 0) << true << false; + QTest::newRow("test 19") << QRect(9, 9, -8, -8) << QPoint( 9, 9) << true << false; + QTest::newRow("test 20") << QRect(9, 9, -8, -8) << QPoint( 1, 0) << true << false; + QTest::newRow("test 21") << QRect(9, 9, -8, -8) << QPoint( 9, 1) << true << false; + QTest::newRow("test 22") << QRect(9, 9, -8, -8) << QPoint( 1, 1) << true << true; + QTest::newRow("test 23") << QRect(9, 9, -8, -8) << QPoint( 1, 8) << true << true; + QTest::newRow("test 24") << QRect(9, 9, -8, -8) << QPoint( 8, 8) << true << true; + + QTest::newRow("test 25") << QRect(-1, 1, 10, 10) << QPoint() << false << false; + QTest::newRow("test 26") << QRect() << QPoint(1, 1) << false << false; + QTest::newRow("test 27") << QRect() << QPoint() << false << false; } void tst_QRect::containsPoint() @@ -4367,7 +4367,7 @@ void tst_QRect::containsPoint() QFETCH(bool, containsProper); QVERIFY(rect.contains(point) == contains); - QVERIFY(rect.contains(point, TRUE) == containsProper); + QVERIFY(rect.contains(point, true) == containsProper); } void tst_QRect::containsPointF_data() @@ -4376,37 +4376,37 @@ void tst_QRect::containsPointF_data() QTest::addColumn<QPointF>("point"); QTest::addColumn<bool>("contains"); - QTest::newRow("test 27") << QRectF() << QPointF() << FALSE; - - QTest::newRow("test 01") << QRectF(0, 0, 10, 10) << QPointF( 0, 0) << TRUE; - QTest::newRow("test 02") << QRectF(0, 0, 10, 10) << QPointF( 0, 10) << TRUE; - QTest::newRow("test 03") << QRectF(0, 0, 10, 10) << QPointF(10, 0) << TRUE; - QTest::newRow("test 04") << QRectF(0, 0, 10, 10) << QPointF(10, 10) << TRUE; - QTest::newRow("test 05") << QRectF(0, 0, 10, 10) << QPointF( 0, 9) << TRUE; - QTest::newRow("test 06") << QRectF(0, 0, 10, 10) << QPointF( 9, 0) << TRUE; - QTest::newRow("test 07") << QRectF(0, 0, 10, 10) << QPointF( 9, 9) << TRUE; - QTest::newRow("test 08") << QRectF(0, 0, 10, 10) << QPointF( 1, 0) << TRUE; - QTest::newRow("test 09") << QRectF(0, 0, 10, 10) << QPointF( 9, 1) << TRUE; - QTest::newRow("test 10") << QRectF(0, 0, 10, 10) << QPointF( 1, 1) << TRUE; - QTest::newRow("test 11") << QRectF(0, 0, 10, 10) << QPointF( 1, 8) << TRUE; - QTest::newRow("test 12") << QRectF(0, 0, 10, 10) << QPointF( 8, 8) << TRUE; - - QTest::newRow("test 13") << QRectF(10, 10, -10, -10) << QPointF( 0, 0) << TRUE; - QTest::newRow("test 14") << QRectF(10, 10, -10, -10) << QPointF( 0, 10) << TRUE; - QTest::newRow("test 15") << QRectF(10, 10, -10, -10) << QPointF(10, 0) << TRUE; - QTest::newRow("test 16") << QRectF(10, 10, -10, -10) << QPointF(10, 10) << TRUE; - QTest::newRow("test 17") << QRectF(10, 10, -10, -10) << QPointF( 0, 9) << TRUE; - QTest::newRow("test 18") << QRectF(10, 10, -10, -10) << QPointF( 9, 0) << TRUE; - QTest::newRow("test 19") << QRectF(10, 10, -10, -10) << QPointF( 9, 9) << TRUE; - QTest::newRow("test 20") << QRectF(10, 10, -10, -10) << QPointF( 1, 0) << TRUE; - QTest::newRow("test 21") << QRectF(10, 10, -10, -10) << QPointF( 9, 1) << TRUE; - QTest::newRow("test 22") << QRectF(10, 10, -10, -10) << QPointF( 1, 1) << TRUE; - QTest::newRow("test 23") << QRectF(10, 10, -10, -10) << QPointF( 1, 8) << TRUE; - QTest::newRow("test 24") << QRectF(10, 10, -10, -10) << QPointF( 8, 8) << TRUE; - - QTest::newRow("test 25") << QRectF(-1, 1, 10, 10) << QPointF() << FALSE; - QTest::newRow("test 26") << QRectF() << QPointF(1, 1) << FALSE; - QTest::newRow("test 27") << QRectF() << QPointF() << FALSE; + QTest::newRow("test 27") << QRectF() << QPointF() << false; + + QTest::newRow("test 01") << QRectF(0, 0, 10, 10) << QPointF( 0, 0) << true; + QTest::newRow("test 02") << QRectF(0, 0, 10, 10) << QPointF( 0, 10) << true; + QTest::newRow("test 03") << QRectF(0, 0, 10, 10) << QPointF(10, 0) << true; + QTest::newRow("test 04") << QRectF(0, 0, 10, 10) << QPointF(10, 10) << true; + QTest::newRow("test 05") << QRectF(0, 0, 10, 10) << QPointF( 0, 9) << true; + QTest::newRow("test 06") << QRectF(0, 0, 10, 10) << QPointF( 9, 0) << true; + QTest::newRow("test 07") << QRectF(0, 0, 10, 10) << QPointF( 9, 9) << true; + QTest::newRow("test 08") << QRectF(0, 0, 10, 10) << QPointF( 1, 0) << true; + QTest::newRow("test 09") << QRectF(0, 0, 10, 10) << QPointF( 9, 1) << true; + QTest::newRow("test 10") << QRectF(0, 0, 10, 10) << QPointF( 1, 1) << true; + QTest::newRow("test 11") << QRectF(0, 0, 10, 10) << QPointF( 1, 8) << true; + QTest::newRow("test 12") << QRectF(0, 0, 10, 10) << QPointF( 8, 8) << true; + + QTest::newRow("test 13") << QRectF(10, 10, -10, -10) << QPointF( 0, 0) << true; + QTest::newRow("test 14") << QRectF(10, 10, -10, -10) << QPointF( 0, 10) << true; + QTest::newRow("test 15") << QRectF(10, 10, -10, -10) << QPointF(10, 0) << true; + QTest::newRow("test 16") << QRectF(10, 10, -10, -10) << QPointF(10, 10) << true; + QTest::newRow("test 17") << QRectF(10, 10, -10, -10) << QPointF( 0, 9) << true; + QTest::newRow("test 18") << QRectF(10, 10, -10, -10) << QPointF( 9, 0) << true; + QTest::newRow("test 19") << QRectF(10, 10, -10, -10) << QPointF( 9, 9) << true; + QTest::newRow("test 20") << QRectF(10, 10, -10, -10) << QPointF( 1, 0) << true; + QTest::newRow("test 21") << QRectF(10, 10, -10, -10) << QPointF( 9, 1) << true; + QTest::newRow("test 22") << QRectF(10, 10, -10, -10) << QPointF( 1, 1) << true; + QTest::newRow("test 23") << QRectF(10, 10, -10, -10) << QPointF( 1, 8) << true; + QTest::newRow("test 24") << QRectF(10, 10, -10, -10) << QPointF( 8, 8) << true; + + QTest::newRow("test 25") << QRectF(-1, 1, 10, 10) << QPointF() << false; + QTest::newRow("test 26") << QRectF() << QPointF(1, 1) << false; + QTest::newRow("test 27") << QRectF() << QPointF() << false; } void tst_QRect::containsPointF() diff --git a/tests/auto/qregexp/qregexp.pro b/tests/auto/qregexp/qregexp.pro index d467cda..80b6827 100644 --- a/tests/auto/qregexp/qregexp.pro +++ b/tests/auto/qregexp/qregexp.pro @@ -6,6 +6,3 @@ QT = core QT = core SOURCES += tst_qregexp.cpp -QT -= gui - - diff --git a/tests/auto/qregexp/tst_qregexp.cpp b/tests/auto/qregexp/tst_qregexp.cpp index 0ab37ca..f97b95d 100644 --- a/tests/auto/qregexp/tst_qregexp.cpp +++ b/tests/auto/qregexp/tst_qregexp.cpp @@ -969,7 +969,7 @@ void tst_QRegExp::rainersSlowRegExpCopyBug() { // this test should take an extreme amount of time if QRegExp is broken QRegExp original(email); -#if defined(Q_OS_WINCE) +#if defined(Q_OS_WINCE) || defined(Q_OS_SYMBIAN) for (int i = 0; i < 100; ++i) { #else for (int i = 0; i < 100000; ++i) { @@ -1022,7 +1022,7 @@ void Thread::run() str += "abbbdekcz"; int x; -#if defined(Q_OS_WINCE) +#if defined(Q_OS_WINCE) || defined(Q_OS_SYMBIAN) for (int j = 0; j < 100; ++j) { #else for (int j = 0; j < 10000; ++j) { diff --git a/tests/auto/qregion/tst_qregion.cpp b/tests/auto/qregion/tst_qregion.cpp index fce9234..063b024 100644 --- a/tests/auto/qregion/tst_qregion.cpp +++ b/tests/auto/qregion/tst_qregion.cpp @@ -279,7 +279,7 @@ void tst_QRegion::emptyPolygonRegion_data() QPolygon pa; - QTest::newRow("no points") << pa << TRUE << 0 << QVector<QRect>(); + QTest::newRow("no points") << pa << true << 0 << QVector<QRect>(); pa = QPolygon() << QPoint(10,10); QTest::newRow("one point") << pa << true << 0 << QVector<QRect>(); pa = QPolygon() << QPoint(10,10) << QPoint(10,20); @@ -381,7 +381,7 @@ void tst_QRegion::intersected_data() QPolygon ps2(8); ps1.putPoints(0,8, 20,20, 50,20, 50,100, 70,100, 70,20, 120,20, 120,200, 20, 200); ps2.putPoints(0,8, 100,150, 140,150, 140,160, 160,160, 160,150, 200,150, 200,180, 100,180); - QTest::newRow("task30716") << QRegion(ps1) << QRegion(ps2) << TRUE; + QTest::newRow("task30716") << QRegion(ps1) << QRegion(ps2) << true; } void tst_QRegion::intersected() @@ -965,10 +965,15 @@ void tst_QRegion::regionToPath_data() } } +#ifdef QT_BUILD_INTERNAL +QT_BEGIN_NAMESPACE +extern QPainterPath qt_regionToPath(const QRegion ®ion); +QT_END_NAMESPACE +#endif + void tst_QRegion::regionToPath() { #ifdef QT_BUILD_INTERNAL - extern QPainterPath qt_regionToPath(const QRegion ®ion); QFETCH(QPainterPath, path); diff --git a/tests/auto/qresourceengine/qresourceengine.pro b/tests/auto/qresourceengine/qresourceengine.pro index 1d53e19..3e47b52 100644 --- a/tests/auto/qresourceengine/qresourceengine.pro +++ b/tests/auto/qresourceengine/qresourceengine.pro @@ -7,26 +7,30 @@ load(resources) # Input SOURCES += tst_qresourceengine.cpp -RESOURCES += testqrc/test.qrc +RESOURCES += testqrc/test.qrc -runtime_resource.target = runtime_resource.rcc +symbian-sbsv2 { + runtime_resource.target = $$PWD/runtime_resource.rcc +} else { + runtime_resource.target = runtime_resource.rcc +} runtime_resource.depends = $$PWD/testqrc/test.qrc runtime_resource.commands = $$QMAKE_RCC -root /runtime_resource/ -binary $${runtime_resource.depends} -o $${runtime_resource.target} QMAKE_EXTRA_TARGETS = runtime_resource -ALL_DEPS += $${runtime_resource.target} +PRE_TARGETDEPS += $${runtime_resource.target} QT = core -wince*:{ +wince*|symbian*:{ deploy.sources += runtime_resource.rcc parentdir.txt - test.sources = testqrc/* + test.sources = testqrc/* test.path = testqrc alias.sources = testqrc/aliasdir/* alias.path = testqrc/aliasdir - other.sources = testqrc/otherdir/* + other.sources = testqrc/otherdir/* other.path = testqrc/otherdir - search1.sources = testqrc/searchpath1/* + search1.sources = testqrc/searchpath1/* search1.path = testqrc/searchpath1 - search2.sources = testqrc/searchpath2/* + search2.sources = testqrc/searchpath2/* search2.path = testqrc/searchpath2 sub.sources = testqrc/subdir/* sub.path = testqrc/subdir @@ -35,7 +39,7 @@ wince*:{ testsub2.sources = testqrc/test/test/* testsub2.path = testqrc/test/test DEPLOYMENT = deploy test alias other search1 search2 sub testsub testsub2 - DEFINES += SRCDIR=\\\"\\\" + !symbian:DEFINES += SRCDIR=\\\"\\\" } else { DEFINES += SRCDIR=\\\"$$PWD/\\\" } diff --git a/tests/auto/qresourceengine/tst_qresourceengine.cpp b/tests/auto/qresourceengine/tst_qresourceengine.cpp index 5d2b821..8701c51 100644 --- a/tests/auto/qresourceengine/tst_qresourceengine.cpp +++ b/tests/auto/qresourceengine/tst_qresourceengine.cpp @@ -43,6 +43,10 @@ #include <QtTest/QtTest> #include <QtCore> +#ifdef Q_OS_SYMBIAN +#define SRCDIR "." +#endif + class tst_QResourceEngine: public QObject { Q_OBJECT diff --git a/tests/auto/qscopedpointer/.gitignore b/tests/auto/qscopedpointer/.gitignore new file mode 100644 index 0000000..9f2324c --- /dev/null +++ b/tests/auto/qscopedpointer/.gitignore @@ -0,0 +1 @@ +tst_qscopedpointer diff --git a/tests/auto/qscopedpointer/qscopedpointer.pro b/tests/auto/qscopedpointer/qscopedpointer.pro new file mode 100644 index 0000000..13d8425 --- /dev/null +++ b/tests/auto/qscopedpointer/qscopedpointer.pro @@ -0,0 +1,3 @@ +load(qttest_p4) +SOURCES += tst_qscopedpointer.cpp +QT -= gui diff --git a/tests/auto/qscopedpointer/tst_qscopedpointer.cpp b/tests/auto/qscopedpointer/tst_qscopedpointer.cpp new file mode 100644 index 0000000..f206ad1 --- /dev/null +++ b/tests/auto/qscopedpointer/tst_qscopedpointer.cpp @@ -0,0 +1,343 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, 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. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QtTest/QtTest> +#include <QtCore/QScopedPointer> + +/*! + \class tst_QScopedPointer + \internal + \since 4.6 + \brief Tests class QScopedPointer. + + */ +class tst_QScopedPointer : public QObject +{ + Q_OBJECT + +private Q_SLOTS: + void defaultConstructor(); + void dataOnDefaultConstructed(); + void useSubClassInConstructor(); + void dataOnValue(); + void dataSignature(); + void reset(); + void dereferenceOperator(); + void dereferenceOperatorSignature(); + void pointerOperator(); + void pointerOperatorSignature(); + void negationOperator(); + void negationOperatorSignature(); + void operatorBool(); + void operatorBoolSignature(); + void isNull(); + void isNullSignature(); + void objectSize(); + void comparison(); + // TODO instanciate on const object +}; + +void tst_QScopedPointer::defaultConstructor() +{ + /* Check that the members, one, is correctly initialized. */ + QScopedPointer<int> p; + QCOMPARE(p.data(), static_cast<int *>(0)); +} + +void tst_QScopedPointer::dataOnDefaultConstructed() +{ + QScopedPointer<int> p; + + QCOMPARE(p.data(), static_cast<int *>(0)); +} + +class MyClass +{ +}; + +class MySubClass : public MyClass +{ +}; + +void tst_QScopedPointer::useSubClassInConstructor() +{ + /* Use a syntax which users typically would do. */ + QScopedPointer<MyClass> p(new MyClass()); +} + +void tst_QScopedPointer::dataOnValue() +{ + int *const rawPointer = new int(5); + QScopedPointer<int> p(rawPointer); + + QCOMPARE(p.data(), rawPointer); +} + +void tst_QScopedPointer::dataSignature() +{ + const QScopedPointer<int> p; + /* data() should be const. */ + p.data(); +} + +void tst_QScopedPointer::reset() +{ + /* Call reset() on a default constructed value. */ + { + QScopedPointer<int> p; + p.reset(); + QCOMPARE(p.data(), static_cast<int *>(0)); + } + + /* Call reset() on an active value. */ + { + QScopedPointer<int> p(new int(3)); + p.reset(); + QCOMPARE(p.data(), static_cast<int *>(0)); + } + + /* Call reset() with a value, on an active value. */ + { + QScopedPointer<int> p(new int(3)); + + int *const value = new int(9); + p.reset(value); + QCOMPARE(*p.data(), 9); + } + + /* Call reset() with a value, on default constructed value. */ + { + QScopedPointer<int> p; + + int *const value = new int(9); + p.reset(value); + QCOMPARE(*p.data(), 9); + } +} + +class AbstractClass +{ +public: + virtual ~AbstractClass() + { + } + + virtual int member() const = 0; +}; + +class SubClass : public AbstractClass +{ +public: + virtual int member() const + { + return 5; + } +}; + +void tst_QScopedPointer::dereferenceOperator() +{ + /* Dereference a basic value. */ + { + QScopedPointer<int> p(new int(5)); + + const int value2 = *p; + QCOMPARE(value2, 5); + } + + /* Dereference a pointer to an abstract class. This verifies + * that the operator returns a reference, when compiling + * with MSVC 2005. */ + { + QScopedPointer<AbstractClass> p(new SubClass()); + + QCOMPARE((*p).member(), 5); + } +} + +void tst_QScopedPointer::dereferenceOperatorSignature() +{ + /* The operator should be const. */ + { + const QScopedPointer<int> p(new int(5)); + *p; + } + + /* A reference should be returned, not a value. */ + { + const QScopedPointer<int> p(new int(5)); + Q_UNUSED(static_cast<int &>(*p)); + } + + /* Instantiated on a const object, the returned object is a const reference. */ + { + const QScopedPointer<const int> p(new int(5)); + Q_UNUSED(static_cast<const int &>(*p)); + } +} + +class AnyForm +{ +public: + int value; +}; + +void tst_QScopedPointer::pointerOperator() +{ + QScopedPointer<AnyForm> p(new AnyForm()); + p->value = 5; + + QCOMPARE(p->value, 5); +} + +void tst_QScopedPointer::pointerOperatorSignature() +{ + /* The operator should be const. */ + const QScopedPointer<AnyForm> p(new AnyForm); + p->value = 5; + + QVERIFY(p->value); +} + +void tst_QScopedPointer::negationOperator() +{ + /* Invoke on default constructed value. */ + { + QScopedPointer<int> p; + QVERIFY(!p); + } + + /* Invoke on a value. */ + { + QScopedPointer<int> p(new int(2)); + QCOMPARE(!p, false); + } +} + +void tst_QScopedPointer::negationOperatorSignature() +{ + /* The signature should be const. */ + const QScopedPointer<int> p; + !p; + + /* The return value should be bool. */ + static_cast<bool>(!p); +} + +void tst_QScopedPointer::operatorBool() +{ + /* Invoke on default constructed value. */ + { + QScopedPointer<int> p; + QCOMPARE(bool(p), false); + } + + /* Invoke on active value. */ + { + QScopedPointer<int> p(new int(3)); + QVERIFY(p); + } +} + +void tst_QScopedPointer::operatorBoolSignature() +{ + /* The signature should be const and return bool. */ + const QScopedPointer<int> p; + + (void)static_cast<bool>(p); +} + +void tst_QScopedPointer::isNull() +{ + /* Invoke on default constructed value. */ + { + QScopedPointer<int> p; + QVERIFY(p.isNull()); + } + + /* Invoke on a set value. */ + { + QScopedPointer<int> p(new int(69)); + QVERIFY(!p.isNull()); + } +} + +void tst_QScopedPointer::isNullSignature() +{ + const QScopedPointer<int> p(new int(69)); + + /* The signature should be const and return bool. */ + static_cast<bool>(p.isNull()); +} + +void tst_QScopedPointer::objectSize() +{ + /* The size of QScopedPointer should be the same as one pointer. */ + QCOMPARE(sizeof(QScopedPointer<int>), sizeof(void *)); +} + +void tst_QScopedPointer::comparison() +{ + int *a = new int(42); + int *b = new int(43); + + QScopedPointer<int> pa(a); + QScopedPointer<int> pa2(a); + QScopedPointer<int> pb(b); + + // test equality on equal pointers + QVERIFY(pa == pa2); + QVERIFY(pa2 == pa); + + // test unequality on equal pointers + QVERIFY(!(pa != pa2)); + QVERIFY(!(pa2 != pa)); + + // test on unequal pointers + QVERIFY(!(pa == pb)); + QVERIFY(!(pb == pa)); + QVERIFY(pb != pa); + QVERIFY(pa != pb); + + pa2.take(); +} + +QTEST_MAIN(tst_QScopedPointer) +#include "tst_qscopedpointer.moc" diff --git a/tests/auto/qscriptable/tst_qscriptable.cpp b/tests/auto/qscriptable/tst_qscriptable.cpp index ecfcc8b..af647fd 100644 --- a/tests/auto/qscriptable/tst_qscriptable.cpp +++ b/tests/auto/qscriptable/tst_qscriptable.cpp @@ -332,6 +332,7 @@ void tst_QScriptable::thisObject() { QVERIFY(!m_scriptable.oofThisObject().isValid()); m_engine.evaluate("o.oof = 123"); + QEXPECT_FAIL("", "Setter doesn't get called when it's in the prototype", Continue); QVERIFY(m_scriptable.oofThisObject().strictlyEquals(m_engine.evaluate("o"))); } { diff --git a/tests/auto/qscriptclass/tst_qscriptclass.cpp b/tests/auto/qscriptclass/tst_qscriptclass.cpp index c83cdaf..11c7f56 100644 --- a/tests/auto/qscriptclass/tst_qscriptclass.cpp +++ b/tests/auto/qscriptclass/tst_qscriptclass.cpp @@ -149,6 +149,9 @@ public: QScriptString lastPropertyFlagsName() const; uint lastPropertyFlagsId() const; + QScriptClass::Extension lastExtensionType() const; + QVariant lastExtensionArgument() const; + void clearReceivedArgs(); void setIterationEnabled(bool enable); @@ -182,6 +185,9 @@ private: QScriptString m_lastPropertyFlagsName; uint m_lastPropertyFlagsId; + QScriptClass::Extension m_lastExtensionType; + QVariant m_lastExtensionArgument; + QScriptValue m_prototype; bool m_iterationEnabled; CallableMode m_callableMode; @@ -333,6 +339,8 @@ bool TestClass::supportsExtension(Extension extension) const QVariant TestClass::extension(Extension extension, const QVariant &argument) { + m_lastExtensionType = extension; + m_lastExtensionArgument = argument; if (extension == Callable) { Q_ASSERT(m_callableMode != NotCallable); QScriptContext *ctx = qvariant_cast<QScriptContext*>(argument); @@ -354,7 +362,6 @@ QVariant TestClass::extension(Extension extension, } else if (extension == HasInstance) { Q_ASSERT(m_hasInstance); QScriptValueList args = qvariant_cast<QScriptValueList>(argument); - Q_ASSERT(args.size() == 2); QScriptValue obj = args.at(0); QScriptValue value = args.at(1); return value.property("foo").equals(obj.property("foo")); @@ -427,6 +434,16 @@ uint TestClass::lastPropertyFlagsId() const return m_lastPropertyFlagsId; } +QScriptClass::Extension TestClass::lastExtensionType() const +{ + return m_lastExtensionType; +} + +QVariant TestClass::lastExtensionArgument() const +{ + return m_lastExtensionArgument; +} + void TestClass::clearReceivedArgs() { m_lastQueryPropertyObject = QScriptValue(); @@ -445,6 +462,9 @@ void TestClass::clearReceivedArgs() m_lastPropertyFlagsObject = QScriptValue(); m_lastPropertyFlagsName = QScriptString(); m_lastPropertyFlagsId = uint(-1); + + m_lastExtensionType = static_cast<QScriptClass::Extension>(-1); + m_lastExtensionArgument = QVariant(); } void TestClass::setIterationEnabled(bool enable) @@ -558,6 +578,7 @@ void tst_QScriptClass::newInstance() QScriptValue obj1 = eng.newObject(&cls); QVERIFY(!obj1.data().isValid()); QVERIFY(obj1.prototype().strictlyEquals(cls.prototype())); + QEXPECT_FAIL("", "classname is not implemented", Continue); QCOMPARE(obj1.toString(), QString::fromLatin1("[object TestClass]")); QCOMPARE(obj1.scriptClass(), (QScriptClass*)&cls); @@ -586,7 +607,9 @@ void tst_QScriptClass::newInstance() QVERIFY(arr.isArray()); QCOMPARE(arr.scriptClass(), (QScriptClass*)0); arr.setScriptClass(&cls); + QEXPECT_FAIL("", "Changing class of arbitrary script object is not allowed (it's OK)", Continue); QCOMPARE(arr.scriptClass(), (QScriptClass*)&cls); + QEXPECT_FAIL("", "Changing class of arbitrary script object is not allowed (it's OK)", Continue); QVERIFY(!arr.isArray()); QVERIFY(arr.isObject()); } @@ -626,10 +649,12 @@ void tst_QScriptClass::getAndSetProperty() QVERIFY(cls.lastQueryPropertyName() == s); QVERIFY(!cls.lastPropertyObject().isValid()); QVERIFY(!cls.lastSetPropertyObject().isValid()); - // ### ideally, we should only test for HandlesWriteAccess in this case - QVERIFY(cls.lastQueryPropertyFlags() == (QScriptClass::HandlesReadAccess | QScriptClass::HandlesWriteAccess)); + QVERIFY(cls.lastQueryPropertyFlags() == QScriptClass::HandlesWriteAccess); // re-read property + // When a QScriptClass doesn't want to handle a property write, + // that property becomes a normal property and the QScriptClass + // shall not be queried about it again. cls.clearReceivedArgs(); QVERIFY(o.property(s).strictlyEquals(num)); QVERIFY(!cls.lastQueryPropertyObject().isValid()); @@ -720,6 +745,7 @@ void tst_QScriptClass::enumerate() for (int x = 0; x < 2; ++x) { QVERIFY(it.hasNext()); it.next(); + QEXPECT_FAIL("", "", Abort); QVERIFY(it.scriptName() == foo); QVERIFY(it.hasNext()); it.next(); @@ -746,6 +772,11 @@ void tst_QScriptClass::extension() cls.setCallableMode(TestClass::NotCallable); QVERIFY(!cls.supportsExtension(QScriptClass::Callable)); QVERIFY(!cls.supportsExtension(QScriptClass::HasInstance)); + QScriptValue obj = eng.newObject(&cls); + QVERIFY(!obj.call().isValid()); + QCOMPARE((int)cls.lastExtensionType(), -1); + QVERIFY(!obj.instanceOf(obj)); + QCOMPARE((int)cls.lastExtensionType(), -1); } // Callable { @@ -757,21 +788,31 @@ void tst_QScriptClass::extension() obj.setProperty("one", QScriptValue(&eng, 1)); obj.setProperty("two", QScriptValue(&eng, 2)); obj.setProperty("three", QScriptValue(&eng, 3)); + cls.clearReceivedArgs(); { QScriptValueList args; args << QScriptValue(&eng, 4) << QScriptValue(&eng, 5); QScriptValue ret = obj.call(obj, args); + QCOMPARE(cls.lastExtensionType(), QScriptClass::Callable); + QCOMPARE(cls.lastExtensionArgument().userType(), qMetaTypeId<QScriptContext*>()); + QVERIFY(ret.isNumber()); QCOMPARE(ret.toNumber(), qsreal(15)); } cls.setCallableMode(TestClass::CallableReturnsArgument); + cls.clearReceivedArgs(); { QScriptValue ret = obj.call(obj, QScriptValueList() << 123); + QCOMPARE(cls.lastExtensionType(), QScriptClass::Callable); + QCOMPARE(cls.lastExtensionArgument().userType(), qMetaTypeId<QScriptContext*>()); QVERIFY(ret.isNumber()); QCOMPARE(ret.toInt32(), 123); } + cls.clearReceivedArgs(); { QScriptValue ret = obj.call(obj, QScriptValueList() << true); + QCOMPARE(cls.lastExtensionType(), QScriptClass::Callable); + QCOMPARE(cls.lastExtensionArgument().userType(), qMetaTypeId<QScriptContext*>()); QVERIFY(ret.isBoolean()); QCOMPARE(ret.toBoolean(), true); } @@ -796,6 +837,15 @@ void tst_QScriptClass::extension() QScriptValue ret = obj.call(obj); QVERIFY(ret.isUndefined()); } + + // construct() + cls.clearReceivedArgs(); + { + QScriptValue ret = obj.construct(); + QCOMPARE(cls.lastExtensionType(), QScriptClass::Callable); + QCOMPARE(cls.lastExtensionArgument().userType(), qMetaTypeId<QScriptContext*>()); + QVERIFY(ret.isObject()); + } } // HasInstance { @@ -810,8 +860,15 @@ void tst_QScriptClass::extension() eng.globalObject().setProperty("HasInstanceTester", obj); eng.globalObject().setProperty("hasInstanceValue", plain); + cls.clearReceivedArgs(); { QScriptValue ret = eng.evaluate("hasInstanceValue instanceof HasInstanceTester"); + QCOMPARE(cls.lastExtensionType(), QScriptClass::HasInstance); + QCOMPARE(cls.lastExtensionArgument().userType(), qMetaTypeId<QScriptValueList>()); + QScriptValueList lst = qvariant_cast<QScriptValueList>(cls.lastExtensionArgument()); + QCOMPARE(lst.size(), 2); + QVERIFY(lst.at(0).strictlyEquals(obj)); + QVERIFY(lst.at(1).strictlyEquals(plain)); QVERIFY(ret.isBoolean()); QVERIFY(!ret.toBoolean()); } diff --git a/tests/auto/qscriptcontext/tst_qscriptcontext.cpp b/tests/auto/qscriptcontext/tst_qscriptcontext.cpp index a4050276..ef609e0 100644 --- a/tests/auto/qscriptcontext/tst_qscriptcontext.cpp +++ b/tests/auto/qscriptcontext/tst_qscriptcontext.cpp @@ -68,12 +68,17 @@ private slots: void evaluateInFunction(); void pushAndPopContext(); void lineNumber(); + void backtrace_data(); void backtrace(); void scopeChain(); void pushAndPopScope(); void getSetActivationObject(); void inheritActivationAndThisObject(); void toString(); + void calledAsConstructor(); + void argumentsObjectInNative(); + void jsActivationObject(); + void qobjectAsActivationObject(); }; tst_QScriptContext::tst_QScriptContext() @@ -150,7 +155,6 @@ void tst_QScriptContext::arguments() QVERIFY(args.isObject()); QCOMPARE(args.property("length").toInt32(), 0); } - { QScriptValue fun = eng.newFunction(get_arguments); eng.globalObject().setProperty("get_arguments", fun); @@ -198,6 +202,7 @@ void tst_QScriptContext::arguments() QCOMPARE(fun.isFunction(), true); QScriptValue result = eng.evaluate(prefix+"get_argumentsObject()"); QCOMPARE(result.isArray(), false); + QVERIFY(result.isObject()); QCOMPARE(result.property("length").toUInt32(), quint32(0)); QCOMPARE(result.propertyFlags("length"), QScriptValue::SkipInEnumeration); QCOMPARE(result.property("callee").strictlyEquals(fun), true); @@ -208,14 +213,25 @@ void tst_QScriptContext::arguments() QScriptValue replacedLength(&eng, 456); result.setProperty("length", replacedLength); QVERIFY(result.property("length").equals(replacedLength)); + result.setProperty("callee", QScriptValue()); + QVERIFY(!result.property("callee").isValid()); + result.setProperty("length", QScriptValue()); + QVERIFY(!result.property("length").isValid()); } { QScriptValue result = eng.evaluate(prefix+"get_argumentsObject(123)"); + eng.evaluate("function nestedArg(x,y,z) { var w = get_argumentsObject('ABC' , x+y+z); return w; }"); + QScriptValue result2 = eng.evaluate("nestedArg(1, 'a', 2)"); QCOMPARE(result.isArray(), false); + QVERIFY(result.isObject()); QCOMPARE(result.property("length").toUInt32(), quint32(1)); QCOMPARE(result.property("0").isNumber(), true); QCOMPARE(result.property("0").toNumber(), 123.0); + QVERIFY(result2.isObject()); + QCOMPARE(result2.property("length").toUInt32(), quint32(2)); + QCOMPARE(result2.property("0").toString(), QString::fromLatin1("ABC")); + QCOMPARE(result2.property("1").toString(), QString::fromLatin1("1a2")); } { @@ -229,6 +245,28 @@ void tst_QScriptContext::arguments() QCOMPARE(result.property("2").toBoolean(), true); QCOMPARE(result.property("3").isUndefined(), true); } + + // arguments object returned from script + { + QScriptValue result = eng.evaluate("(function() { return arguments; })(123)"); + QCOMPARE(result.isArray(), false); + QVERIFY(result.isObject()); + QCOMPARE(result.property("length").toUInt32(), quint32(1)); + QCOMPARE(result.property("0").isNumber(), true); + QCOMPARE(result.property("0").toNumber(), 123.0); + } + + { + QScriptValue result = eng.evaluate("(function() { return arguments; })('ciao', null, true, undefined)"); + QCOMPARE(result.isArray(), false); + QCOMPARE(result.property("length").toUInt32(), quint32(4)); + QCOMPARE(result.property("0").isString(), true); + QCOMPARE(result.property("0").toString(), QString("ciao")); + QCOMPARE(result.property("1").isNull(), true); + QCOMPARE(result.property("2").isBoolean(), true); + QCOMPARE(result.property("2").toBoolean(), true); + QCOMPARE(result.property("3").isUndefined(), true); + } } } @@ -272,6 +310,7 @@ void tst_QScriptContext::thisObject() void tst_QScriptContext::returnValue() { + QSKIP("Internal function not implemented in JSC-based back-end", SkipAll); QScriptEngine eng; eng.evaluate("123"); QCOMPARE(eng.currentContext()->returnValue().toNumber(), 123.0); @@ -433,6 +472,7 @@ void tst_QScriptContext::pushAndPopContext() QCOMPARE(topLevel->engine(), &eng); QScriptContext *ctx = eng.pushContext(); + QVERIFY(ctx != 0); QCOMPARE(ctx->parentContext(), topLevel); QCOMPARE(eng.currentContext(), ctx); QCOMPARE(ctx->engine(), &eng); @@ -445,6 +485,9 @@ void tst_QScriptContext::pushAndPopContext() QCOMPARE(ctx->activationObject().isObject(), true); QCOMPARE(ctx->callee().isValid(), false); QCOMPARE(ctx->thisObject().strictlyEquals(eng.globalObject()), true); + QCOMPARE(ctx->scopeChain().size(), 2); + QVERIFY(ctx->scopeChain().at(0).equals(ctx->activationObject())); + QVERIFY(ctx->scopeChain().at(1).equals(eng.globalObject())); QScriptContext *ctx2 = eng.pushContext(); QCOMPARE(ctx2->parentContext(), ctx); @@ -456,6 +499,7 @@ void tst_QScriptContext::pushAndPopContext() QCOMPARE(eng.currentContext(), topLevel); // popping the top-level context is not allowed + QTest::ignoreMessage(QtWarningMsg, "QScriptEngine::popContext() doesn't match with pushContext()"); eng.popContext(); QCOMPARE(eng.currentContext(), topLevel); @@ -497,7 +541,7 @@ void tst_QScriptContext::lineNumber() QScriptValue result = eng.evaluate("try { eval(\"foo = 123;\\n this[is{a{syntax|error@#$%@#% \"); } catch (e) { e.lineNumber; }", "foo.qs", 123); QVERIFY(!eng.hasUncaughtException()); QVERIFY(result.isNumber()); - QCOMPARE(result.toInt32(), 124); + QCOMPARE(result.toInt32(), 2); result = eng.evaluate("foo = 123;\n bar = 42\n0 = 0"); QVERIFY(eng.hasUncaughtException()); @@ -510,26 +554,187 @@ static QScriptValue getBacktrace(QScriptContext *ctx, QScriptEngine *eng) return qScriptValueFromValue(eng, ctx->backtrace()); } +static QScriptValue custom_eval(QScriptContext *ctx, QScriptEngine *eng) +{ + return eng->evaluate(ctx->argumentsObject().property(0).toString(), ctx->argumentsObject().property(1).toString()); +} + +static QScriptValue custom_call(QScriptContext *ctx, QScriptEngine *) +{ + return ctx->argumentsObject().property(0).call(QScriptValue(), QScriptValueList() << ctx->argumentsObject().property(1)); +} + +void tst_QScriptContext::backtrace_data() +{ + QTest::addColumn<QString>("code"); + QTest::addColumn<QStringList>("expectedbacktrace"); + + { + QString source( + "function foo() {\n" + " return bt(123);\n" + "}\n" + "foo('hello', { })\n" + "var r = 0;"); + + QStringList expected; + expected << "<native>(123) at -1" + << "foo('hello', [object Object]) at testfile:2" + << "<global>() at testfile:4"; + + + QTest::newRow("simple") << source << expected; + } + + { + QStringList expected; + QString source = QString( + "function foo(arg1 , arg2) {\n" + " return eval(\"%1\");\n" + "}\n" + "foo('hello', 456)\n" + "var a = 0;" + ).arg("\\n \\n bt('hey'); \\n"); + + expected << "<native>('hey') at -1" + << "<eval>() at 3" + //### line number should be 2 but the line number information is not kept for eval call + << "foo(arg1 = 'hello', arg2 = 456) at testfile:-1" + << "<global>() at testfile:4"; + + QTest::newRow("eval") << source << expected; + } + + { + QString eval_code( + "function bar(a) {\\n" + " return bt('m');\\n" + "}\\n" + "bar('b'); \\n"); + QString source = QString( + "function foo() {\n" + " return custom_eval(\"%1\", 'eval.js');\n" + "}\n" + "foo()" + ).arg(eval_code); + + QStringList expected; + expected << "<native>('m') at -1" + << "bar(a = 'b') at eval.js:2" + << "<eval>() at eval.js:4" + << QString("<native>('%1', 'eval.js') at -1").arg(eval_code.replace("\\n", "\n")) + << "foo() at testfile:2" + << "<global>() at testfile:4"; + + QTest::newRow("custom_eval") << source << expected; + } + { + QString f("function (a) {\n return bt(a); \n }"); + QString source = QString( + "function foo(f) {\n" + " return f('b');\n" + "}\n" + "foo(%1)" + ).arg(f); + + QStringList expected; + expected << "<native>('b') at -1" + << "<anonymous>(a = 'b') at testfile:5" + << QString("foo(f = %1) at testfile:2").arg(f) + << "<global>() at testfile:6"; + + QTest::newRow("closure") << source << expected; + } + + { + QStringList expected; + QString source = QString( + "var o = new Object;\n" + "o.foo = function plop() {\n" + " return eval(\"%1\");\n" + "}\n" + "o.foo('hello', 456)\n" + ).arg("\\n \\n bt('hey'); \\n"); + + expected << "<native>('hey') at -1" + << "<eval>() at 3" + //### line number should be 3 but the line number information is not kept for eval call + << "plop('hello', 456) at testfile:-1" + << "<global>() at testfile:5"; + + QTest::newRow("eval in member") << source << expected; + } + + { + QString source( + "function foo(a) {\n" + " return bt(123);\n" + "}\n" + "function bar() {\n" + " var v = foo('arg', 4);\n" + " return v;\n" + "}\n" + "bar('hello', { });\n"); + + QStringList expected; + expected << "<native>(123) at -1" + << "foo(a = 'arg', 4) at testfile:2" + << "bar('hello', [object Object]) at testfile:5" + << "<global>() at testfile:8"; + + + QTest::newRow("two function") << source << expected; + } + + { + QString func("function foo(a, b) {\n" + " return bt(a);\n" + "}"); + + QString source = func + QString::fromLatin1("\n" + "custom_call(foo, 'hello');\n" + "var a = 1\n"); + + QStringList expected; + expected << "<native>('hello') at -1" + << "foo(a = 'hello') at testfile:2" + << QString("<native>(%1, 'hello') at -1").arg(func) + << "<global>() at testfile:4"; + + QTest::newRow("call") << source << expected; + } + + { + QString source = QString::fromLatin1("\n" + "custom_call(bt, 'hello_world');\n" + "var a = 1\n"); + + QStringList expected; + expected << "<native>('hello_world') at -1" + << "<native>(function () {\n [native code]\n}, 'hello_world') at -1" + << "<global>() at testfile:2"; + + QTest::newRow("call native") << source << expected; + } +} + + void tst_QScriptContext::backtrace() { + QFETCH(QString, code); + QFETCH(QStringList, expectedbacktrace); + QScriptEngine eng; eng.globalObject().setProperty("bt", eng.newFunction(getBacktrace)); + eng.globalObject().setProperty("custom_eval", eng.newFunction(custom_eval)); + eng.globalObject().setProperty("custom_call", eng.newFunction(custom_call)); QString fileName = "testfile"; - QStringList expected; - expected << "<native>(123)@:-1" - << "foo(hello,[object Object])@testfile:2" - << "<global>()@testfile:4"; - - QScriptValue ret = eng.evaluate( - "function foo() {\n" - " return bt(123);\n" - "}\n" - "foo('hello', { })", fileName); - + QScriptValue ret = eng.evaluate(code, fileName); + QVERIFY(!eng.hasUncaughtException()); QVERIFY(ret.isArray()); QStringList slist = qscriptvalue_cast<QStringList>(ret); - QCOMPARE(slist, expected); + QCOMPARE(slist, expectedbacktrace); } static QScriptValue getScopeChain(QScriptContext *ctx, QScriptEngine *eng) @@ -542,7 +747,8 @@ void tst_QScriptContext::scopeChain() QScriptEngine eng; { QScriptValueList ret = eng.currentContext()->scopeChain(); - QCOMPARE(ret.size(), 0); // we aren't evaluating code + QCOMPARE(ret.size(), 1); + QVERIFY(ret.at(0).strictlyEquals(eng.globalObject())); } { eng.globalObject().setProperty("getScopeChain", eng.newFunction(getScopeChain)); @@ -553,6 +759,7 @@ void tst_QScriptContext::scopeChain() { eng.evaluate("function foo() { function bar() { return getScopeChain(); } return bar() }"); QScriptValueList ret = qscriptvalue_cast<QScriptValueList>(eng.evaluate("foo()")); + QEXPECT_FAIL("", "Number of items in returned scope chain is incorrect", Abort); QCOMPARE(ret.size(), 3); QVERIFY(ret.at(2).strictlyEquals(eng.globalObject())); QCOMPARE(ret.at(1).toString(), QString::fromLatin1("activation")); @@ -583,15 +790,23 @@ void tst_QScriptContext::pushAndPopScope() { QScriptEngine eng; QScriptContext *ctx = eng.currentContext(); - QVERIFY(ctx->scopeChain().isEmpty()); + QCOMPARE(ctx->scopeChain().size(), 1); + QVERIFY(ctx->scopeChain().at(0).strictlyEquals(eng.globalObject())); + + QVERIFY(ctx->popScope().strictlyEquals(eng.globalObject())); + ctx->pushScope(eng.globalObject()); + QCOMPARE(ctx->scopeChain().size(), 1); + QVERIFY(ctx->scopeChain().at(0).strictlyEquals(eng.globalObject())); QScriptValue obj = eng.newObject(); ctx->pushScope(obj); - QCOMPARE(ctx->scopeChain().size(), 1); + QCOMPARE(ctx->scopeChain().size(), 2); QVERIFY(ctx->scopeChain().at(0).strictlyEquals(obj)); + QVERIFY(ctx->scopeChain().at(1).strictlyEquals(eng.globalObject())); QVERIFY(ctx->popScope().strictlyEquals(obj)); - QVERIFY(ctx->scopeChain().isEmpty()); + QCOMPARE(ctx->scopeChain().size(), 1); + QVERIFY(ctx->scopeChain().at(0).strictlyEquals(eng.globalObject())); { QScriptValue ret = eng.evaluate("x"); @@ -632,21 +847,16 @@ void tst_QScriptContext::pushAndPopScope() QVERIFY(ctx->popScope().strictlyEquals(eng.globalObject())); QVERIFY(ctx->scopeChain().isEmpty()); + // Used to work with old back-end, doesn't with new one because JSC requires that the last object in + // a scope chain is the Global Object. + QTest::ignoreMessage(QtWarningMsg, "QScriptContext::pushScope() failed: initial object in scope chain has to be the Global Object"); ctx->pushScope(obj); - QCOMPARE(ctx->scopeChain().size(), 1); - QVERIFY(ctx->scopeChain().at(0).strictlyEquals(obj)); - QVERIFY(!obj.property("foo").isValid()); - eng.evaluate("function foo() {}"); - // function declarations should always end up in the activation object (ECMA-262, chapter 13) - QVERIFY(!obj.property("foo").isValid()); - QVERIFY(ctx->activationObject().property("foo").isFunction()); + QCOMPARE(ctx->scopeChain().size(), 0); QScriptEngine eng2; QScriptValue obj2 = eng2.newObject(); QTest::ignoreMessage(QtWarningMsg, "QScriptContext::pushScope() failed: cannot push an object created in a different engine"); ctx->pushScope(obj2); - - QVERIFY(ctx->popScope().strictlyEquals(obj)); QVERIFY(ctx->scopeChain().isEmpty()); QVERIFY(!ctx->popScope().isValid()); @@ -670,23 +880,32 @@ void tst_QScriptContext::getSetActivationObject() QScriptValue obj = eng.newObject(); ctx->setActivationObject(obj); QVERIFY(ctx->activationObject().equals(obj)); + QCOMPARE(ctx->scopeChain().size(), 1); + QVERIFY(ctx->scopeChain().at(0).equals(obj)); { QScriptEngine eng2; QScriptValue obj2 = eng2.newObject(); QTest::ignoreMessage(QtWarningMsg, "QScriptContext::setActivationObject() failed: cannot set an object created in a different engine"); + QScriptValue was = ctx->activationObject(); ctx->setActivationObject(obj2); - QVERIFY(ctx->activationObject().equals(obj)); + QVERIFY(ctx->activationObject().equals(was)); } ctx->setActivationObject(eng.globalObject()); + QVERIFY(ctx->activationObject().equals(eng.globalObject())); QScriptValue fun = eng.newFunction(get_activationObject); eng.globalObject().setProperty("get_activationObject", fun); { QScriptValue ret = eng.evaluate("get_activationObject(1, 2, 3)"); QVERIFY(ret.isObject()); - QVERIFY(ret.property("arguments").isObject()); - QCOMPARE(ret.property("arguments").property("length").toInt32(), 3); + QScriptValue arguments = ret.property("arguments"); + QEXPECT_FAIL("", "Getting arguments property of activation object doesn't work", Abort); + QVERIFY(arguments.isObject()); + QCOMPARE(arguments.property("length").toInt32(), 3); + QCOMPARE(arguments.property("0").toInt32(), 1); + QCOMPARE(arguments.property("1").toInt32(), 1); + QCOMPARE(arguments.property("2").toInt32(), 1); } } @@ -732,7 +951,164 @@ void tst_QScriptContext::toString() " return parentContextToString();\n" "}; foo(1, 2, 3)", "script.qs"); QVERIFY(ret.isString()); - QCOMPARE(ret.toString(), QString::fromLatin1("foo (first=1, second=2, third=3) at script.qs:2")); + QCOMPARE(ret.toString(), QString::fromLatin1("foo(first = 1, second = 2, third = 3) at script.qs:2")); +} + +static QScriptValue storeCalledAsConstructor(QScriptContext *ctx, QScriptEngine *eng) +{ + ctx->callee().setProperty("calledAsConstructor", ctx->isCalledAsConstructor()); + return eng->undefinedValue(); +} + +static QScriptValue storeCalledAsConstructorV2(QScriptContext *ctx, QScriptEngine *eng, void *) +{ + ctx->callee().setProperty("calledAsConstructor", ctx->isCalledAsConstructor()); + return eng->undefinedValue(); +} + +static QScriptValue storeCalledAsConstructorV3(QScriptContext *ctx, QScriptEngine *eng) +{ + ctx->callee().setProperty("calledAsConstructor", ctx->parentContext()->isCalledAsConstructor()); + return eng->undefinedValue(); +} + +void tst_QScriptContext::calledAsConstructor() +{ + QScriptEngine eng; + QScriptValue fun1 = eng.newFunction(storeCalledAsConstructor); + { + fun1.call(); + QVERIFY(!fun1.property("calledAsConstructor").toBool()); + fun1.construct(); + QVERIFY(fun1.property("calledAsConstructor").toBool()); + } + { + QScriptValue fun = eng.newFunction(storeCalledAsConstructorV2, (void*)0); + fun.call(); + QVERIFY(!fun.property("calledAsConstructor").toBool()); + fun.construct(); + QVERIFY(fun.property("calledAsConstructor").toBool()); + } + { + eng.globalObject().setProperty("fun1", fun1); + eng.evaluate("fun1();"); + QVERIFY(!fun1.property("calledAsConstructor").toBool()); + eng.evaluate("new fun1();"); + QVERIFY(fun1.property("calledAsConstructor").toBool()); + } + { + QScriptValue fun3 = eng.newFunction(storeCalledAsConstructorV3); + eng.globalObject().setProperty("fun3", fun3); + eng.evaluate("function test() { fun3() }"); + eng.evaluate("test();"); + QVERIFY(!fun3.property("calledAsConstructor").toBool()); + eng.evaluate("new test();"); + QVERIFY(fun3.property("calledAsConstructor").toBool()); + } + +} + +static QScriptValue argumentsObjectInNative_test1(QScriptContext *ctx, QScriptEngine *eng) +{ +#define VERIFY(statement) \ + do {\ + if (!QTest::qVerify((statement), #statement, "", __FILE__, __LINE__))\ + return QString::fromLatin1("Failed " #statement);\ + } while (0) + + QScriptValue obj = ctx->argumentsObject(); + VERIFY(obj.isObject()); + VERIFY(obj.property(0).toUInt32() == 123); + VERIFY(obj.property(1).toString() == QString::fromLatin1("456")); + + obj.setProperty(0, "abc"); + VERIFY(eng->evaluate("arguments[0]").toString() == QString::fromLatin1("abc") ); + + return QString::fromLatin1("success"); +#undef VERIFY +} + +void tst_QScriptContext::argumentsObjectInNative() +{ + { + QScriptEngine eng; + QScriptValue fun = eng.newFunction(argumentsObjectInNative_test1); + QScriptValueList args; + args << QScriptValue(&eng, 123.0); + args << QScriptValue(&eng, QString::fromLatin1("456")); + QScriptValue result = fun.call(eng.undefinedValue(), args); + QVERIFY(!eng.hasUncaughtException()); + QCOMPARE(result.toString(), QString::fromLatin1("success")); + } + { + QScriptEngine eng; + QScriptValue fun = eng.newFunction(argumentsObjectInNative_test1); + eng.globalObject().setProperty("func", fun); + QScriptValue result = eng.evaluate("func(123.0 , 456);"); + QVERIFY(!eng.hasUncaughtException()); + QCOMPARE(result.toString(), QString::fromLatin1("success")); + } +} + +static QScriptValue get_jsActivationObject(QScriptContext *ctx, QScriptEngine *) +{ + return ctx->parentContext()->parentContext()->activationObject(); +} + +void tst_QScriptContext::jsActivationObject() +{ + QScriptEngine eng; + eng.globalObject().setProperty("get_jsActivationObject", eng.newFunction(get_jsActivationObject)); + eng.evaluate("function f1() { var w = get_jsActivationObject('arg1'); return w; }"); + eng.evaluate("function f2(x,y,z) { var v1 = 42;\n" + // "function foo() {};\n" //this would avoid JSC to optimize + "var v2 = f1(); return v2; }"); + eng.evaluate("function f3() { var v1 = 'nothing'; return f2(1,2,3); }"); + QScriptValue result1 = eng.evaluate("f2('hello', 'useless', 'world')"); + QScriptValue result2 = eng.evaluate("f3()"); + QVERIFY(result1.isObject()); + QEXPECT_FAIL("", "JSC optimize away the activation object", Abort); + QCOMPARE(result1.property("v1").toInt32() , 42); + QCOMPARE(result1.property("arguments").property(1).toString() , QString::fromLatin1("useless")); + QVERIFY(result2.isObject()); + QCOMPARE(result2.property("v1").toInt32() , 42); + QCOMPARE(result2.property("arguments").property(1).toString() , QString::fromLatin1("2")); +} + +void tst_QScriptContext::qobjectAsActivationObject() +{ + QScriptEngine eng; + QObject object; + QScriptValue scriptObject = eng.newQObject(&object); + QScriptContext *ctx = eng.pushContext(); + ctx->setActivationObject(scriptObject); + QVERIFY(ctx->activationObject().equals(scriptObject)); + + QVERIFY(!scriptObject.property("foo").isValid()); + eng.evaluate("function foo() { return 123; }"); + { + QScriptValue val = scriptObject.property("foo"); + QVERIFY(val.isValid()); + QVERIFY(val.isFunction()); + } + QVERIFY(!eng.globalObject().property("foo").isValid()); + + QVERIFY(!scriptObject.property("bar").isValid()); + eng.evaluate("var bar = 123"); + { + QScriptValue val = scriptObject.property("bar"); + QVERIFY(val.isValid()); + QVERIFY(val.isNumber()); + QCOMPARE(val.toInt32(), 123); + } + QVERIFY(!eng.globalObject().property("bar").isValid()); + + { + QScriptValue val = eng.evaluate("delete foo"); + QVERIFY(val.isBool()); + QVERIFY(val.toBool()); + QVERIFY(!scriptObject.property("foo").isValid()); + } } QTEST_MAIN(tst_QScriptContext) diff --git a/tests/auto/qscriptcontextinfo/tst_qscriptcontextinfo.cpp b/tests/auto/qscriptcontextinfo/tst_qscriptcontextinfo.cpp index 5d26424..874e70d 100644 --- a/tests/auto/qscriptcontextinfo/tst_qscriptcontextinfo.cpp +++ b/tests/auto/qscriptcontextinfo/tst_qscriptcontextinfo.cpp @@ -91,8 +91,6 @@ private slots: void scriptFunction(); void qtFunction(); void qtPropertyFunction(); - void builtinFunctionNames_data(); - void builtinFunctionNames(); void nullContext(); void streaming(); void assignmentAndComparison(); @@ -152,6 +150,7 @@ void tst_QScriptContextInfo::nativeFunction() QVERIFY(info.scriptId() != -1); QCOMPARE(info.fileName(), fileName); QCOMPARE(info.lineNumber(), lineNumber); + QEXPECT_FAIL("", "columnNumber doesn't work", Continue); QCOMPARE(info.columnNumber(), 1); QCOMPARE(info.functionName(), QString()); QCOMPARE(info.functionEndLineNumber(), -1); @@ -183,6 +182,7 @@ void tst_QScriptContextInfo::scriptFunction() QVERIFY(info.scriptId() != -1); QCOMPARE(info.fileName(), fileName); QCOMPARE(info.lineNumber(), lineNumber + 1); + QEXPECT_FAIL("", "columnNumber doesn't work", Continue); QCOMPARE(info.columnNumber(), 2); QCOMPARE(info.functionName(), QString::fromLatin1("bar")); QCOMPARE(info.functionStartLineNumber(), lineNumber); @@ -201,6 +201,7 @@ void tst_QScriptContextInfo::scriptFunction() QVERIFY(info.scriptId() != -1); QCOMPARE(info.fileName(), fileName); QCOMPARE(info.lineNumber(), lineNumber + 3); + QEXPECT_FAIL("", "columnNumber doesn't work", Continue); QCOMPARE(info.columnNumber(), 1); QCOMPARE(info.functionName(), QString()); QCOMPARE(info.functionEndLineNumber(), -1); @@ -216,7 +217,7 @@ void tst_QScriptContextInfo::qtFunction() eng.globalObject().setProperty("getContextInfoList", eng.newFunction(getContextInfoList)); eng.globalObject().setProperty("qobj", eng.newQObject(this)); - for (int x = 0; x < 2; ++x) { + for (int x = 0; x < 2; ++x) { // twice to test overloaded slot as well QString code; const char *sig; QStringList pnames; @@ -247,8 +248,14 @@ void tst_QScriptContextInfo::qtFunction() QCOMPARE(info.functionName(), QString::fromLatin1("testSlot")); QCOMPARE(info.functionEndLineNumber(), -1); QCOMPARE(info.functionStartLineNumber(), -1); + if (x == 0) + QEXPECT_FAIL("", "QScriptContextInfo doesn't pick the correct meta-index for overloaded slots", Continue); QCOMPARE(info.functionParameterNames().size(), pnames.size()); + if (x == 0) + QEXPECT_FAIL("", "QScriptContextInfo doesn't pick the correct meta-index for overloaded slots", Continue); QCOMPARE(info.functionParameterNames(), pnames); + if (x == 0) + QEXPECT_FAIL("", "QScriptContextInfo doesn't pick the correct meta-index for overloaded slots", Continue); QCOMPARE(info.functionMetaIndex(), metaObject()->indexOfMethod(sig)); } @@ -289,201 +296,6 @@ void tst_QScriptContextInfo::qtPropertyFunction() QCOMPARE(lst.at(0).functionType(), QScriptContextInfo::NativeFunction); } -void tst_QScriptContextInfo::builtinFunctionNames_data() -{ - QTest::addColumn<QString>("expression"); - QTest::addColumn<QString>("expectedName"); - - QTest::newRow("print") << QString("print") << QString("print"); - QTest::newRow("parseInt") << QString("parseInt") << QString("parseInt"); - QTest::newRow("parseFloat") << QString("parseFloat") << QString("parseFloat"); - QTest::newRow("isNaN") << QString("isNaN") << QString("isNaN"); - QTest::newRow("isFinite") << QString("isFinite") << QString("isFinite"); - QTest::newRow("decodeURI") << QString("decodeURI") << QString("decodeURI"); - QTest::newRow("decodeURIComponent") << QString("decodeURIComponent") << QString("decodeURIComponent"); - QTest::newRow("encodeURI") << QString("encodeURI") << QString("encodeURI"); - QTest::newRow("encodeURIComponent") << QString("encodeURIComponent") << QString("encodeURIComponent"); - QTest::newRow("escape") << QString("escape") << QString("escape"); - QTest::newRow("unescape") << QString("unescape") << QString("unescape"); - QTest::newRow("version") << QString("version") << QString("version"); - QTest::newRow("gc") << QString("gc") << QString("gc"); - - QTest::newRow("Array") << QString("Array") << QString("Array"); - QTest::newRow("Array.prototype.toString") << QString("Array.prototype.toString") << QString("toString"); - QTest::newRow("Array.prototype.toLocaleString") << QString("Array.prototype.toLocaleString") << QString("toLocaleString"); - QTest::newRow("Array.prototype.concat") << QString("Array.prototype.concat") << QString("concat"); - QTest::newRow("Array.prototype.join") << QString("Array.prototype.join") << QString("join"); - QTest::newRow("Array.prototype.pop") << QString("Array.prototype.pop") << QString("pop"); - QTest::newRow("Array.prototype.push") << QString("Array.prototype.push") << QString("push"); - QTest::newRow("Array.prototype.reverse") << QString("Array.prototype.reverse") << QString("reverse"); - QTest::newRow("Array.prototype.shift") << QString("Array.prototype.shift") << QString("shift"); - QTest::newRow("Array.prototype.slice") << QString("Array.prototype.slice") << QString("slice"); - QTest::newRow("Array.prototype.sort") << QString("Array.prototype.sort") << QString("sort"); - QTest::newRow("Array.prototype.splice") << QString("Array.prototype.splice") << QString("splice"); - QTest::newRow("Array.prototype.unshift") << QString("Array.prototype.unshift") << QString("unshift"); - - QTest::newRow("Boolean") << QString("Boolean") << QString("Boolean"); - QTest::newRow("Boolean.prototype.toString") << QString("Boolean.prototype.toString") << QString("toString"); - - QTest::newRow("Date") << QString("Date") << QString("Date"); - QTest::newRow("Date.prototype.toString") << QString("Date.prototype.toString") << QString("toString"); - QTest::newRow("Date.prototype.toDateString") << QString("Date.prototype.toDateString") << QString("toDateString"); - QTest::newRow("Date.prototype.toTimeString") << QString("Date.prototype.toTimeString") << QString("toTimeString"); - QTest::newRow("Date.prototype.toLocaleString") << QString("Date.prototype.toLocaleString") << QString("toLocaleString"); - QTest::newRow("Date.prototype.toLocaleDateString") << QString("Date.prototype.toLocaleDateString") << QString("toLocaleDateString"); - QTest::newRow("Date.prototype.toLocaleTimeString") << QString("Date.prototype.toLocaleTimeString") << QString("toLocaleTimeString"); - QTest::newRow("Date.prototype.valueOf") << QString("Date.prototype.valueOf") << QString("valueOf"); - QTest::newRow("Date.prototype.getTime") << QString("Date.prototype.getTime") << QString("getTime"); - QTest::newRow("Date.prototype.getYear") << QString("Date.prototype.getYear") << QString("getYear"); - QTest::newRow("Date.prototype.getFullYear") << QString("Date.prototype.getFullYear") << QString("getFullYear"); - QTest::newRow("Date.prototype.getUTCFullYear") << QString("Date.prototype.getUTCFullYear") << QString("getUTCFullYear"); - QTest::newRow("Date.prototype.getMonth") << QString("Date.prototype.getMonth") << QString("getMonth"); - QTest::newRow("Date.prototype.getUTCMonth") << QString("Date.prototype.getUTCMonth") << QString("getUTCMonth"); - QTest::newRow("Date.prototype.getDate") << QString("Date.prototype.getDate") << QString("getDate"); - QTest::newRow("Date.prototype.getUTCDate") << QString("Date.prototype.getUTCDate") << QString("getUTCDate"); - QTest::newRow("Date.prototype.getDay") << QString("Date.prototype.getDay") << QString("getDay"); - QTest::newRow("Date.prototype.getUTCDay") << QString("Date.prototype.getUTCDay") << QString("getUTCDay"); - QTest::newRow("Date.prototype.getHours") << QString("Date.prototype.getHours") << QString("getHours"); - QTest::newRow("Date.prototype.getUTCHours") << QString("Date.prototype.getUTCHours") << QString("getUTCHours"); - QTest::newRow("Date.prototype.getMinutes") << QString("Date.prototype.getMinutes") << QString("getMinutes"); - QTest::newRow("Date.prototype.getUTCMinutes") << QString("Date.prototype.getUTCMinutes") << QString("getUTCMinutes"); - QTest::newRow("Date.prototype.getSeconds") << QString("Date.prototype.getSeconds") << QString("getSeconds"); - QTest::newRow("Date.prototype.getUTCSeconds") << QString("Date.prototype.getUTCSeconds") << QString("getUTCSeconds"); - QTest::newRow("Date.prototype.getMilliseconds") << QString("Date.prototype.getMilliseconds") << QString("getMilliseconds"); - QTest::newRow("Date.prototype.getUTCMilliseconds") << QString("Date.prototype.getUTCMilliseconds") << QString("getUTCMilliseconds"); - QTest::newRow("Date.prototype.getTimezoneOffset") << QString("Date.prototype.getTimezoneOffset") << QString("getTimezoneOffset"); - QTest::newRow("Date.prototype.setTime") << QString("Date.prototype.setTime") << QString("setTime"); - QTest::newRow("Date.prototype.setMilliseconds") << QString("Date.prototype.setMilliseconds") << QString("setMilliseconds"); - QTest::newRow("Date.prototype.setUTCMilliseconds") << QString("Date.prototype.setUTCMilliseconds") << QString("setUTCMilliseconds"); - QTest::newRow("Date.prototype.setSeconds") << QString("Date.prototype.setSeconds") << QString("setSeconds"); - QTest::newRow("Date.prototype.setUTCSeconds") << QString("Date.prototype.setUTCSeconds") << QString("setUTCSeconds"); - QTest::newRow("Date.prototype.setMinutes") << QString("Date.prototype.setMinutes") << QString("setMinutes"); - QTest::newRow("Date.prototype.setUTCMinutes") << QString("Date.prototype.setUTCMinutes") << QString("setUTCMinutes"); - QTest::newRow("Date.prototype.setHours") << QString("Date.prototype.setHours") << QString("setHours"); - QTest::newRow("Date.prototype.setUTCHours") << QString("Date.prototype.setUTCHours") << QString("setUTCHours"); - QTest::newRow("Date.prototype.setDate") << QString("Date.prototype.setDate") << QString("setDate"); - QTest::newRow("Date.prototype.setUTCDate") << QString("Date.prototype.setUTCDate") << QString("setUTCDate"); - QTest::newRow("Date.prototype.setMonth") << QString("Date.prototype.setMonth") << QString("setMonth"); - QTest::newRow("Date.prototype.setUTCMonth") << QString("Date.prototype.setUTCMonth") << QString("setUTCMonth"); - QTest::newRow("Date.prototype.setYear") << QString("Date.prototype.setYear") << QString("setYear"); - QTest::newRow("Date.prototype.setFullYear") << QString("Date.prototype.setFullYear") << QString("setFullYear"); - QTest::newRow("Date.prototype.setUTCFullYear") << QString("Date.prototype.setUTCFullYear") << QString("setUTCFullYear"); - QTest::newRow("Date.prototype.toUTCString") << QString("Date.prototype.toUTCString") << QString("toUTCString"); - QTest::newRow("Date.prototype.toGMTString") << QString("Date.prototype.toGMTString") << QString("toGMTString"); - - QTest::newRow("Error") << QString("Error") << QString("Error"); - QTest::newRow("Error.prototype.backtrace") << QString("Error.prototype.backtrace") << QString("backtrace"); - QTest::newRow("Error.prototype.toString") << QString("Error.prototype.toString") << QString("toString"); - - QTest::newRow("EvalError") << QString("EvalError") << QString("EvalError"); - QTest::newRow("RangeError") << QString("RangeError") << QString("RangeError"); - QTest::newRow("ReferenceError") << QString("ReferenceError") << QString("ReferenceError"); - QTest::newRow("SyntaxError") << QString("SyntaxError") << QString("SyntaxError"); - QTest::newRow("TypeError") << QString("TypeError") << QString("TypeError"); - QTest::newRow("URIError") << QString("URIError") << QString("URIError"); - - QTest::newRow("Function") << QString("Function") << QString("Function"); - QTest::newRow("Function.prototype.toString") << QString("Function.prototype.toString") << QString("toString"); - QTest::newRow("Function.prototype.apply") << QString("Function.prototype.apply") << QString("apply"); - QTest::newRow("Function.prototype.call") << QString("Function.prototype.call") << QString("call"); - QTest::newRow("Function.prototype.connect") << QString("Function.prototype.connect") << QString("connect"); - QTest::newRow("Function.prototype.disconnect") << QString("Function.prototype.disconnect") << QString("disconnect"); - - QTest::newRow("Math.abs") << QString("Math.abs") << QString("abs"); - QTest::newRow("Math.acos") << QString("Math.acos") << QString("acos"); - QTest::newRow("Math.asin") << QString("Math.asin") << QString("asin"); - QTest::newRow("Math.atan") << QString("Math.atan") << QString("atan"); - QTest::newRow("Math.atan2") << QString("Math.atan2") << QString("atan2"); - QTest::newRow("Math.ceil") << QString("Math.ceil") << QString("ceil"); - QTest::newRow("Math.cos") << QString("Math.cos") << QString("cos"); - QTest::newRow("Math.exp") << QString("Math.exp") << QString("exp"); - QTest::newRow("Math.floor") << QString("Math.floor") << QString("floor"); - QTest::newRow("Math.log") << QString("Math.log") << QString("log"); - QTest::newRow("Math.max") << QString("Math.max") << QString("max"); - QTest::newRow("Math.min") << QString("Math.min") << QString("min"); - QTest::newRow("Math.pow") << QString("Math.pow") << QString("pow"); - QTest::newRow("Math.random") << QString("Math.random") << QString("random"); - QTest::newRow("Math.round") << QString("Math.round") << QString("round"); - QTest::newRow("Math.sin") << QString("Math.sin") << QString("sin"); - QTest::newRow("Math.sqrt") << QString("Math.sqrt") << QString("sqrt"); - QTest::newRow("Math.tan") << QString("Math.tan") << QString("tan"); - - QTest::newRow("Number") << QString("Number") << QString("Number"); - QTest::newRow("Number.prototype.toString") << QString("Number.prototype.toString") << QString("toString"); - QTest::newRow("Number.prototype.toLocaleString") << QString("Number.prototype.toLocaleString") << QString("toLocaleString"); - QTest::newRow("Number.prototype.valueOf") << QString("Number.prototype.valueOf") << QString("valueOf"); - QTest::newRow("Number.prototype.toFixed") << QString("Number.prototype.toFixed") << QString("toFixed"); - QTest::newRow("Number.prototype.toExponential") << QString("Number.prototype.toExponential") << QString("toExponential"); - QTest::newRow("Number.prototype.toPrecision") << QString("Number.prototype.toPrecision") << QString("toPrecision"); - - QTest::newRow("Object") << QString("Object") << QString("Object"); - QTest::newRow("Object.prototype.toString") << QString("Object.prototype.toString") << QString("toString"); - QTest::newRow("Object.prototype.toLocaleString") << QString("Object.prototype.toLocaleString") << QString("toLocaleString"); - QTest::newRow("Object.prototype.valueOf") << QString("Object.prototype.valueOf") << QString("valueOf"); - QTest::newRow("Object.prototype.hasOwnProperty") << QString("Object.prototype.hasOwnProperty") << QString("hasOwnProperty"); - QTest::newRow("Object.prototype.isPrototypeOf") << QString("Object.prototype.isPrototypeOf") << QString("isPrototypeOf"); - QTest::newRow("Object.prototype.propertyIsEnumerable") << QString("Object.prototype.propertyIsEnumerable") << QString("propertyIsEnumerable"); - QTest::newRow("Object.prototype.__defineGetter__") << QString("Object.prototype.__defineGetter__") << QString("__defineGetter__"); - QTest::newRow("Object.prototype.__defineSetter__") << QString("Object.prototype.__defineSetter__") << QString("__defineSetter__"); - - QTest::newRow("RegExp") << QString("RegExp") << QString("RegExp"); - QTest::newRow("RegExp.prototype.exec") << QString("RegExp.prototype.exec") << QString("exec"); - QTest::newRow("RegExp.prototype.test") << QString("RegExp.prototype.test") << QString("test"); - QTest::newRow("RegExp.prototype.toString") << QString("RegExp.prototype.toString") << QString("toString"); - - QTest::newRow("String") << QString("String") << QString("String"); - QTest::newRow("String.prototype.toString") << QString("String.prototype.toString") << QString("toString"); - QTest::newRow("String.prototype.valueOf") << QString("String.prototype.valueOf") << QString("valueOf"); - QTest::newRow("String.prototype.charAt") << QString("String.prototype.charAt") << QString("charAt"); - QTest::newRow("String.prototype.charCodeAt") << QString("String.prototype.charCodeAt") << QString("charCodeAt"); - QTest::newRow("String.prototype.concat") << QString("String.prototype.concat") << QString("concat"); - QTest::newRow("String.prototype.indexOf") << QString("String.prototype.indexOf") << QString("indexOf"); - QTest::newRow("String.prototype.lastIndexOf") << QString("String.prototype.lastIndexOf") << QString("lastIndexOf"); - QTest::newRow("String.prototype.localeCompare") << QString("String.prototype.localeCompare") << QString("localeCompare"); - QTest::newRow("String.prototype.match") << QString("String.prototype.match") << QString("match"); - QTest::newRow("String.prototype.replace") << QString("String.prototype.replace") << QString("replace"); - QTest::newRow("String.prototype.search") << QString("String.prototype.search") << QString("search"); - QTest::newRow("String.prototype.slice") << QString("String.prototype.slice") << QString("slice"); - QTest::newRow("String.prototype.split") << QString("String.prototype.split") << QString("split"); - QTest::newRow("String.prototype.substring") << QString("String.prototype.substring") << QString("substring"); - QTest::newRow("String.prototype.toLowerCase") << QString("String.prototype.toLowerCase") << QString("toLowerCase"); - QTest::newRow("String.prototype.toLocaleLowerCase") << QString("String.prototype.toLocaleLowerCase") << QString("toLocaleLowerCase"); - QTest::newRow("String.prototype.toUpperCase") << QString("String.prototype.toUpperCase") << QString("toUpperCase"); - QTest::newRow("String.prototype.toLocaleUpperCase") << QString("String.prototype.toLocaleUpperCase") << QString("toLocaleUpperCase"); -} - -class CallSpy : public QScriptEngineAgent -{ -public: - CallSpy(QScriptEngine *engine) : QScriptEngineAgent(engine) - { engine->setAgent(this); } - - void functionEntry(qint64 scriptId) - { - if (functionName.isEmpty() && engine()->currentContext()->parentContext()) { - QScriptContextInfo info(engine()->currentContext()); - functionName = info.functionName(); - expectedScriptId = scriptId; - actualScriptId = info.scriptId(); - } - } - - qint64 expectedScriptId; - qint64 actualScriptId; - QString functionName; -}; - -void tst_QScriptContextInfo::builtinFunctionNames() -{ - QFETCH(QString, expression); - QFETCH(QString, expectedName); - QScriptEngine eng; - CallSpy *spy = new CallSpy(&eng); - (void)eng.evaluate(QString::fromLatin1("%0()").arg(expression)); - QCOMPARE(spy->functionName, expectedName); - QCOMPARE(spy->actualScriptId, spy->expectedScriptId); -} - void tst_QScriptContextInfo::nullContext() { QScriptContextInfo info((QScriptContext*)0); diff --git a/tests/auto/qscriptengine/qscriptengine.pro b/tests/auto/qscriptengine/qscriptengine.pro index 7c74b32..f72c070 100644 --- a/tests/auto/qscriptengine/qscriptengine.pro +++ b/tests/auto/qscriptengine/qscriptengine.pro @@ -1,11 +1,16 @@ load(qttest_p4) QT = core gui script SOURCES += tst_qscriptengine.cpp -DEFINES += SRCDIR=\\\"$$PWD\\\" +!symbian:DEFINES += SRCDIR=\\\"$$PWD\\\" -wince*: { +wince*|symbian*: { addFiles.sources = script addFiles.path = . DEPLOYMENT += addFiles } +symbian: { + TARGET.UID3 = 0xE0340006 + DEFINES += SYMBIAN_SRCDIR_UID=$$lower($$replace(TARGET.UID3,"0x","")) + TARGET.EPOCHEAPSIZE="0x100000 0x1000000 // Min 1Mb, max 16Mb" +} diff --git a/tests/auto/qscriptengine/tst_qscriptengine.cpp b/tests/auto/qscriptengine/tst_qscriptengine.cpp index 24db87f..df74144 100644 --- a/tests/auto/qscriptengine/tst_qscriptengine.cpp +++ b/tests/auto/qscriptengine/tst_qscriptengine.cpp @@ -55,6 +55,11 @@ Q_DECLARE_METATYPE(QObjectList) //TESTED_CLASS= //TESTED_FILES= +#if defined(Q_OS_SYMBIAN) +# define STRINGIFY(x) #x +# define TOSTRING(x) STRINGIFY(x) +# define SRCDIR "C:/Private/" TOSTRING(SYMBIAN_SRCDIR_UID) +#endif class tst_QScriptEngine : public QObject { Q_OBJECT @@ -78,6 +83,10 @@ private slots: void newQMetaObject(); void newActivationObject(); void getSetGlobalObject(); + void globalObjectProperties(); + void globalObjectGetterSetterProperty(); + void builtinFunctionNames_data(); + void builtinFunctionNames(); void checkSyntax_data(); void checkSyntax(); void canEvaluate_data(); @@ -124,6 +133,9 @@ private slots: void installTranslatorFunctions(); void functionScopes(); void nativeFunctionScopes(); + + void qRegExpInport_data(); + void qRegExpInport(); }; tst_QScriptEngine::tst_QScriptEngine() @@ -187,7 +199,9 @@ void tst_QScriptEngine::pushPopContext() eng.popContext(); eng.popContext(); + QTest::ignoreMessage(QtWarningMsg, "QScriptEngine::popContext() doesn't match with pushContext()"); eng.popContext(); // ignored + QTest::ignoreMessage(QtWarningMsg, "QScriptEngine::popContext() doesn't match with pushContext()"); eng.popContext(); // ignored } @@ -227,7 +241,7 @@ void tst_QScriptEngine::newFunction() QCOMPARE(fun.prototype().isValid(), true); QCOMPARE(fun.prototype().isFunction(), true); QCOMPARE(fun.prototype().strictlyEquals(eng.evaluate("Function.prototype")), true); - + QCOMPARE(fun.call().isNull(), true); QCOMPARE(fun.construct().isObject(), true); } @@ -249,7 +263,7 @@ void tst_QScriptEngine::newFunction() QCOMPARE(fun.prototype().isValid(), true); QCOMPARE(fun.prototype().isFunction(), true); QCOMPARE(fun.prototype().strictlyEquals(eng.evaluate("Function.prototype")), true); - + QCOMPARE(fun.call().isNull(), true); QCOMPARE(fun.construct().isObject(), true); } @@ -452,10 +466,11 @@ void tst_QScriptEngine::newRegExp() QCOMPARE(rexp.isValid(), true); QCOMPARE(rexp.isRegExp(), true); QCOMPARE(rexp.isObject(), true); - QVERIFY(!rexp.isFunction()); + QVERIFY(rexp.isFunction()); // in JSC, RegExp objects are callable // prototype should be RegExp.prototype QCOMPARE(rexp.prototype().isValid(), true); - QCOMPARE(rexp.prototype().isRegExp(), true); + QCOMPARE(rexp.prototype().isObject(), true); + QCOMPARE(rexp.prototype().isRegExp(), false); QCOMPARE(rexp.prototype().strictlyEquals(eng.evaluate("RegExp.prototype")), true); QCOMPARE(rexp.toRegExp().pattern(), QRegExp("foo").pattern()); @@ -472,7 +487,7 @@ void tst_QScriptEngine::newRegExp() QScriptValue r3 = rxCtor.call(QScriptValue(), QScriptValueList() << r << "gim"); QVERIFY(r3.isError()); - QCOMPARE(r3.toString(), QString::fromLatin1("TypeError: cannot specify flags when creating a copy of a RegExp")); + QCOMPARE(r3.toString(), QString::fromLatin1("TypeError: Cannot supply flags when constructing one RegExp from another.")); QScriptValue r4 = rxCtor.call(QScriptValue(), QScriptValueList() << "foo" << "gim"); QVERIFY(r4.isRegExp()); @@ -480,15 +495,17 @@ void tst_QScriptEngine::newRegExp() QScriptValue r5 = rxCtor.construct(QScriptValueList() << r); QVERIFY(r5.isRegExp()); QCOMPARE(r5.toString(), QString::fromLatin1("/foo/gim")); - QVERIFY(!r5.strictlyEquals(r)); + // In JSC, constructing a RegExp from another produces the same identical object. + // This is different from SpiderMonkey and old back-end. + QVERIFY(r5.strictlyEquals(r)); QScriptValue r6 = rxCtor.construct(QScriptValueList() << "foo" << "bar"); QVERIFY(r6.isError()); - QCOMPARE(r6.toString(), QString::fromLatin1("SyntaxError: invalid regular expression flag 'b'")); + QCOMPARE(r6.toString(), QString::fromLatin1("SyntaxError: Invalid regular expression: invalid regular expression flag")); QScriptValue r7 = eng.evaluate("/foo/gimp"); QVERIFY(r7.isError()); - QCOMPARE(r7.toString(), QString::fromLatin1("SyntaxError: Invalid regular expression flag 'p'")); + QCOMPARE(r7.toString(), QString::fromLatin1("SyntaxError: Invalid regular expression: invalid regular expression flag")); QScriptValue r8 = eng.evaluate("/foo/migmigmig"); QVERIFY(r8.isRegExp()); @@ -594,6 +611,8 @@ void tst_QScriptEngine::newQObject() QScriptValue v = eng.newQObject(ptr, QScriptEngine::ScriptOwnership); } eng.evaluate("gc()"); + if (ptr) + QEXPECT_FAIL("", "In the JSC-based back-end, script-owned QObjects are not always deleted immediately during GC", Continue); QVERIFY(ptr == 0); } { @@ -623,6 +642,8 @@ void tst_QScriptEngine::newQObject() } eng.evaluate("gc()"); // no parent, so it should be like ScriptOwnership + if (ptr) + QEXPECT_FAIL("", "In the JSC-based back-end, script-owned QObjects are not always deleted immediately during GC", Continue); QVERIFY(ptr == 0); } { @@ -793,9 +814,22 @@ void tst_QScriptEngine::newQMetaObject() QVERIFY(instance3.instanceOf(qclass)); args.clear(); + QPointer<QObject> qpointer1 = instance.toQObject(); + QPointer<QObject> qpointer2 = instance2.toQObject(); + QPointer<QObject> qpointer3 = instance3.toQObject(); + + QVERIFY(qpointer1); + QVERIFY(qpointer2); + QVERIFY(qpointer3); + // verify that AutoOwnership is in effect instance = QScriptValue(); eng.collectGarbage(); + + QVERIFY(!qpointer1); + QVERIFY(qpointer2); + QVERIFY(!qpointer3); // was child of instance + QVERIFY(instance.toQObject() == 0); QVERIFY(instance3.toQObject() == 0); // was child of instance QVERIFY(instance2.toQObject() != 0); @@ -846,15 +880,20 @@ void tst_QScriptEngine::newQMetaObject() void tst_QScriptEngine::newActivationObject() { + QSKIP("internal function not implemented in JSC-based back-end", SkipAll); QScriptEngine eng; QScriptValue act = eng.newActivationObject(); + QEXPECT_FAIL("", "", Continue); QCOMPARE(act.isValid(), true); + QEXPECT_FAIL("", "", Continue); QCOMPARE(act.isObject(), true); QVERIFY(!act.isFunction()); QScriptValue v(&eng, 123); act.setProperty("prop", v); + QEXPECT_FAIL("", "", Continue); QCOMPARE(act.property("prop").strictlyEquals(v), true); QCOMPARE(act.scope().isValid(), false); + QEXPECT_FAIL("", "", Continue); QVERIFY(act.prototype().isNull()); } @@ -924,6 +963,342 @@ void tst_QScriptEngine::getSetGlobalObject() } } +static QScriptValue getSetFoo(QScriptContext *ctx, QScriptEngine *) +{ + if (ctx->argumentCount() > 0) + ctx->thisObject().setProperty("foo", ctx->argument(0)); + return ctx->thisObject().property("foo"); +} + +void tst_QScriptEngine::globalObjectProperties() +{ + QScriptEngine eng; + QScriptValue global = eng.globalObject(); + + QVERIFY(global.property("NaN").isNumber()); + QVERIFY(qIsNaN(global.property("NaN").toNumber())); + QCOMPARE(global.propertyFlags("NaN"), QScriptValue::SkipInEnumeration | QScriptValue::Undeletable); + + QVERIFY(global.property("Infinity").isNumber()); + QVERIFY(qIsInf(global.property("Infinity").toNumber())); + QCOMPARE(global.propertyFlags("NaN"), QScriptValue::SkipInEnumeration | QScriptValue::Undeletable); + + QVERIFY(global.property("undefined").isUndefined()); + QCOMPARE(global.propertyFlags("undefined"), QScriptValue::SkipInEnumeration | QScriptValue::Undeletable); + + QVERIFY(global.property("eval").isFunction()); + QCOMPARE(global.propertyFlags("eval"), QScriptValue::SkipInEnumeration); + + QVERIFY(global.property("parseInt").isFunction()); + QCOMPARE(global.propertyFlags("parseInt"), QScriptValue::SkipInEnumeration); + + QVERIFY(global.property("parseFloat").isFunction()); + QCOMPARE(global.propertyFlags("parseFloat"), QScriptValue::SkipInEnumeration); + + QVERIFY(global.property("isNaN").isFunction()); + QCOMPARE(global.propertyFlags("isNaN"), QScriptValue::SkipInEnumeration); + + QVERIFY(global.property("isFinite").isFunction()); + QCOMPARE(global.propertyFlags("isFinite"), QScriptValue::SkipInEnumeration); + + QVERIFY(global.property("decodeURI").isFunction()); + QCOMPARE(global.propertyFlags("decodeURI"), QScriptValue::SkipInEnumeration); + + QVERIFY(global.property("decodeURIComponent").isFunction()); + QCOMPARE(global.propertyFlags("decodeURIComponent"), QScriptValue::SkipInEnumeration); + + QVERIFY(global.property("encodeURI").isFunction()); + QCOMPARE(global.propertyFlags("encodeURI"), QScriptValue::SkipInEnumeration); + + QVERIFY(global.property("encodeURIComponent").isFunction()); + QCOMPARE(global.propertyFlags("encodeURIComponent"), QScriptValue::SkipInEnumeration); + + QVERIFY(global.property("Object").isFunction()); + QCOMPARE(global.propertyFlags("Object"), QScriptValue::SkipInEnumeration); + QVERIFY(global.property("Function").isFunction()); + QCOMPARE(global.propertyFlags("Function"), QScriptValue::SkipInEnumeration); + QVERIFY(global.property("Array").isFunction()); + QCOMPARE(global.propertyFlags("Array"), QScriptValue::SkipInEnumeration); + QVERIFY(global.property("String").isFunction()); + QCOMPARE(global.propertyFlags("String"), QScriptValue::SkipInEnumeration); + QVERIFY(global.property("Boolean").isFunction()); + QCOMPARE(global.propertyFlags("Boolean"), QScriptValue::SkipInEnumeration); + QVERIFY(global.property("Number").isFunction()); + QCOMPARE(global.propertyFlags("Number"), QScriptValue::SkipInEnumeration); + QVERIFY(global.property("Date").isFunction()); + QCOMPARE(global.propertyFlags("Date"), QScriptValue::SkipInEnumeration); + QVERIFY(global.property("RegExp").isFunction()); + QCOMPARE(global.propertyFlags("RegExp"), QScriptValue::SkipInEnumeration); + QVERIFY(global.property("Error").isFunction()); + QCOMPARE(global.propertyFlags("Error"), QScriptValue::SkipInEnumeration); + QVERIFY(global.property("EvalError").isFunction()); + QCOMPARE(global.propertyFlags("EvalError"), QScriptValue::SkipInEnumeration); + QVERIFY(global.property("RangeError").isFunction()); + QCOMPARE(global.propertyFlags("RangeError"), QScriptValue::SkipInEnumeration); + QVERIFY(global.property("ReferenceError").isFunction()); + QCOMPARE(global.propertyFlags("ReferenceError"), QScriptValue::SkipInEnumeration); + QVERIFY(global.property("SyntaxError").isFunction()); + QCOMPARE(global.propertyFlags("SyntaxError"), QScriptValue::SkipInEnumeration); + QVERIFY(global.property("TypeError").isFunction()); + QCOMPARE(global.propertyFlags("TypeError"), QScriptValue::SkipInEnumeration); + QVERIFY(global.property("URIError").isFunction()); + QCOMPARE(global.propertyFlags("URIError"), QScriptValue::SkipInEnumeration); + QVERIFY(global.property("Math").isObject()); + QVERIFY(!global.property("Math").isFunction()); + QEXPECT_FAIL("", "[ECMA compliance] JSC sets DontDelete flag for Math object", Continue); + QCOMPARE(global.propertyFlags("Math"), QScriptValue::SkipInEnumeration); + + // enumeration + QSet<QString> expectedNames; + expectedNames + << "isNaN" + << "parseFloat" + << "String" + << "EvalError" + << "URIError" + << "Math" + << "encodeURIComponent" + << "RangeError" + << "eval" + << "isFinite" + << "ReferenceError" + << "Infinity" + << "Function" + << "RegExp" + << "Number" + << "parseInt" + << "Object" + << "decodeURI" + << "TypeError" + << "Boolean" + << "encodeURI" + << "NaN" + << "Error" + << "decodeURIComponent" + << "Date" + << "Array" + << "escape" + << "unescape" + << "SyntaxError" + << "undefined" + // non-standard + << "gc" + << "version" + << "print" + // JavaScriptCore + << "JSON" + ; + QSet<QString> actualNames; + { + QScriptValueIterator it(global); + while (it.hasNext()) { + it.next(); + actualNames.insert(it.name()); + } + } + + QSet<QString> remainingNames = actualNames; + { + QSet<QString>::const_iterator it; + for (it = expectedNames.constBegin(); it != expectedNames.constEnd(); ++it) { + QString name = *it; + QVERIFY(actualNames.contains(name)); + remainingNames.remove(name); + } + } + QVERIFY(remainingNames.isEmpty()); +} + +void tst_QScriptEngine::globalObjectGetterSetterProperty() +{ + QScriptEngine engine; + QScriptValue global = engine.globalObject(); + global.setProperty("bar", engine.newFunction(getSetFoo), + QScriptValue::PropertySetter | QScriptValue::PropertyGetter); + global.setProperty("foo", 123); + QVERIFY(global.property("bar").equals(global.property("foo"))); + QVERIFY(engine.evaluate("bar").equals(global.property("foo"))); + global.setProperty("bar", 456); + QVERIFY(global.property("bar").equals(global.property("foo"))); + + engine.evaluate("__defineGetter__('baz', function() { return 789; })"); + QVERIFY(engine.evaluate("baz").equals(789)); + QVERIFY(global.property("baz").equals(789)); +} + +void tst_QScriptEngine::builtinFunctionNames_data() +{ + QTest::addColumn<QString>("expression"); + QTest::addColumn<QString>("expectedName"); + + QTest::newRow("print") << QString("print") << QString("print"); + QTest::newRow("parseInt") << QString("parseInt") << QString("parseInt"); + QTest::newRow("parseFloat") << QString("parseFloat") << QString("parseFloat"); + QTest::newRow("isNaN") << QString("isNaN") << QString("isNaN"); + QTest::newRow("isFinite") << QString("isFinite") << QString("isFinite"); + QTest::newRow("decodeURI") << QString("decodeURI") << QString("decodeURI"); + QTest::newRow("decodeURIComponent") << QString("decodeURIComponent") << QString("decodeURIComponent"); + QTest::newRow("encodeURI") << QString("encodeURI") << QString("encodeURI"); + QTest::newRow("encodeURIComponent") << QString("encodeURIComponent") << QString("encodeURIComponent"); + QTest::newRow("escape") << QString("escape") << QString("escape"); + QTest::newRow("unescape") << QString("unescape") << QString("unescape"); + QTest::newRow("version") << QString("version") << QString("version"); + QTest::newRow("gc") << QString("gc") << QString("gc"); + + QTest::newRow("Array") << QString("Array") << QString("Array"); + QTest::newRow("Array.prototype.toString") << QString("Array.prototype.toString") << QString("toString"); + QTest::newRow("Array.prototype.toLocaleString") << QString("Array.prototype.toLocaleString") << QString("toLocaleString"); + QTest::newRow("Array.prototype.concat") << QString("Array.prototype.concat") << QString("concat"); + QTest::newRow("Array.prototype.join") << QString("Array.prototype.join") << QString("join"); + QTest::newRow("Array.prototype.pop") << QString("Array.prototype.pop") << QString("pop"); + QTest::newRow("Array.prototype.push") << QString("Array.prototype.push") << QString("push"); + QTest::newRow("Array.prototype.reverse") << QString("Array.prototype.reverse") << QString("reverse"); + QTest::newRow("Array.prototype.shift") << QString("Array.prototype.shift") << QString("shift"); + QTest::newRow("Array.prototype.slice") << QString("Array.prototype.slice") << QString("slice"); + QTest::newRow("Array.prototype.sort") << QString("Array.prototype.sort") << QString("sort"); + QTest::newRow("Array.prototype.splice") << QString("Array.prototype.splice") << QString("splice"); + QTest::newRow("Array.prototype.unshift") << QString("Array.prototype.unshift") << QString("unshift"); + + QTest::newRow("Boolean") << QString("Boolean") << QString("Boolean"); + QTest::newRow("Boolean.prototype.toString") << QString("Boolean.prototype.toString") << QString("toString"); + + QTest::newRow("Date") << QString("Date") << QString("Date"); + QTest::newRow("Date.prototype.toString") << QString("Date.prototype.toString") << QString("toString"); + QTest::newRow("Date.prototype.toDateString") << QString("Date.prototype.toDateString") << QString("toDateString"); + QTest::newRow("Date.prototype.toTimeString") << QString("Date.prototype.toTimeString") << QString("toTimeString"); + QTest::newRow("Date.prototype.toLocaleString") << QString("Date.prototype.toLocaleString") << QString("toLocaleString"); + QTest::newRow("Date.prototype.toLocaleDateString") << QString("Date.prototype.toLocaleDateString") << QString("toLocaleDateString"); + QTest::newRow("Date.prototype.toLocaleTimeString") << QString("Date.prototype.toLocaleTimeString") << QString("toLocaleTimeString"); + QTest::newRow("Date.prototype.valueOf") << QString("Date.prototype.valueOf") << QString("valueOf"); + QTest::newRow("Date.prototype.getTime") << QString("Date.prototype.getTime") << QString("getTime"); + QTest::newRow("Date.prototype.getYear") << QString("Date.prototype.getYear") << QString("getYear"); + QTest::newRow("Date.prototype.getFullYear") << QString("Date.prototype.getFullYear") << QString("getFullYear"); + QTest::newRow("Date.prototype.getUTCFullYear") << QString("Date.prototype.getUTCFullYear") << QString("getUTCFullYear"); + QTest::newRow("Date.prototype.getMonth") << QString("Date.prototype.getMonth") << QString("getMonth"); + QTest::newRow("Date.prototype.getUTCMonth") << QString("Date.prototype.getUTCMonth") << QString("getUTCMonth"); + QTest::newRow("Date.prototype.getDate") << QString("Date.prototype.getDate") << QString("getDate"); + QTest::newRow("Date.prototype.getUTCDate") << QString("Date.prototype.getUTCDate") << QString("getUTCDate"); + QTest::newRow("Date.prototype.getDay") << QString("Date.prototype.getDay") << QString("getDay"); + QTest::newRow("Date.prototype.getUTCDay") << QString("Date.prototype.getUTCDay") << QString("getUTCDay"); + QTest::newRow("Date.prototype.getHours") << QString("Date.prototype.getHours") << QString("getHours"); + QTest::newRow("Date.prototype.getUTCHours") << QString("Date.prototype.getUTCHours") << QString("getUTCHours"); + QTest::newRow("Date.prototype.getMinutes") << QString("Date.prototype.getMinutes") << QString("getMinutes"); + QTest::newRow("Date.prototype.getUTCMinutes") << QString("Date.prototype.getUTCMinutes") << QString("getUTCMinutes"); + QTest::newRow("Date.prototype.getSeconds") << QString("Date.prototype.getSeconds") << QString("getSeconds"); + QTest::newRow("Date.prototype.getUTCSeconds") << QString("Date.prototype.getUTCSeconds") << QString("getUTCSeconds"); + QTest::newRow("Date.prototype.getMilliseconds") << QString("Date.prototype.getMilliseconds") << QString("getMilliseconds"); + QTest::newRow("Date.prototype.getUTCMilliseconds") << QString("Date.prototype.getUTCMilliseconds") << QString("getUTCMilliseconds"); + QTest::newRow("Date.prototype.getTimezoneOffset") << QString("Date.prototype.getTimezoneOffset") << QString("getTimezoneOffset"); + QTest::newRow("Date.prototype.setTime") << QString("Date.prototype.setTime") << QString("setTime"); + QTest::newRow("Date.prototype.setMilliseconds") << QString("Date.prototype.setMilliseconds") << QString("setMilliseconds"); + QTest::newRow("Date.prototype.setUTCMilliseconds") << QString("Date.prototype.setUTCMilliseconds") << QString("setUTCMilliseconds"); + QTest::newRow("Date.prototype.setSeconds") << QString("Date.prototype.setSeconds") << QString("setSeconds"); + QTest::newRow("Date.prototype.setUTCSeconds") << QString("Date.prototype.setUTCSeconds") << QString("setUTCSeconds"); + QTest::newRow("Date.prototype.setMinutes") << QString("Date.prototype.setMinutes") << QString("setMinutes"); + QTest::newRow("Date.prototype.setUTCMinutes") << QString("Date.prototype.setUTCMinutes") << QString("setUTCMinutes"); + QTest::newRow("Date.prototype.setHours") << QString("Date.prototype.setHours") << QString("setHours"); + QTest::newRow("Date.prototype.setUTCHours") << QString("Date.prototype.setUTCHours") << QString("setUTCHours"); + QTest::newRow("Date.prototype.setDate") << QString("Date.prototype.setDate") << QString("setDate"); + QTest::newRow("Date.prototype.setUTCDate") << QString("Date.prototype.setUTCDate") << QString("setUTCDate"); + QTest::newRow("Date.prototype.setMonth") << QString("Date.prototype.setMonth") << QString("setMonth"); + QTest::newRow("Date.prototype.setUTCMonth") << QString("Date.prototype.setUTCMonth") << QString("setUTCMonth"); + QTest::newRow("Date.prototype.setYear") << QString("Date.prototype.setYear") << QString("setYear"); + QTest::newRow("Date.prototype.setFullYear") << QString("Date.prototype.setFullYear") << QString("setFullYear"); + QTest::newRow("Date.prototype.setUTCFullYear") << QString("Date.prototype.setUTCFullYear") << QString("setUTCFullYear"); + QTest::newRow("Date.prototype.toUTCString") << QString("Date.prototype.toUTCString") << QString("toUTCString"); + QTest::newRow("Date.prototype.toGMTString") << QString("Date.prototype.toGMTString") << QString("toGMTString"); + + QTest::newRow("Error") << QString("Error") << QString("Error"); +// QTest::newRow("Error.prototype.backtrace") << QString("Error.prototype.backtrace") << QString("backtrace"); + QTest::newRow("Error.prototype.toString") << QString("Error.prototype.toString") << QString("toString"); + + QTest::newRow("EvalError") << QString("EvalError") << QString("EvalError"); + QTest::newRow("RangeError") << QString("RangeError") << QString("RangeError"); + QTest::newRow("ReferenceError") << QString("ReferenceError") << QString("ReferenceError"); + QTest::newRow("SyntaxError") << QString("SyntaxError") << QString("SyntaxError"); + QTest::newRow("TypeError") << QString("TypeError") << QString("TypeError"); + QTest::newRow("URIError") << QString("URIError") << QString("URIError"); + + QTest::newRow("Function") << QString("Function") << QString("Function"); + QTest::newRow("Function.prototype.toString") << QString("Function.prototype.toString") << QString("toString"); + QTest::newRow("Function.prototype.apply") << QString("Function.prototype.apply") << QString("apply"); + QTest::newRow("Function.prototype.call") << QString("Function.prototype.call") << QString("call"); + QTest::newRow("Function.prototype.connect") << QString("Function.prototype.connect") << QString("connect"); + QTest::newRow("Function.prototype.disconnect") << QString("Function.prototype.disconnect") << QString("disconnect"); + + QTest::newRow("Math.abs") << QString("Math.abs") << QString("abs"); + QTest::newRow("Math.acos") << QString("Math.acos") << QString("acos"); + QTest::newRow("Math.asin") << QString("Math.asin") << QString("asin"); + QTest::newRow("Math.atan") << QString("Math.atan") << QString("atan"); + QTest::newRow("Math.atan2") << QString("Math.atan2") << QString("atan2"); + QTest::newRow("Math.ceil") << QString("Math.ceil") << QString("ceil"); + QTest::newRow("Math.cos") << QString("Math.cos") << QString("cos"); + QTest::newRow("Math.exp") << QString("Math.exp") << QString("exp"); + QTest::newRow("Math.floor") << QString("Math.floor") << QString("floor"); + QTest::newRow("Math.log") << QString("Math.log") << QString("log"); + QTest::newRow("Math.max") << QString("Math.max") << QString("max"); + QTest::newRow("Math.min") << QString("Math.min") << QString("min"); + QTest::newRow("Math.pow") << QString("Math.pow") << QString("pow"); + QTest::newRow("Math.random") << QString("Math.random") << QString("random"); + QTest::newRow("Math.round") << QString("Math.round") << QString("round"); + QTest::newRow("Math.sin") << QString("Math.sin") << QString("sin"); + QTest::newRow("Math.sqrt") << QString("Math.sqrt") << QString("sqrt"); + QTest::newRow("Math.tan") << QString("Math.tan") << QString("tan"); + + QTest::newRow("Number") << QString("Number") << QString("Number"); + QTest::newRow("Number.prototype.toString") << QString("Number.prototype.toString") << QString("toString"); + QTest::newRow("Number.prototype.toLocaleString") << QString("Number.prototype.toLocaleString") << QString("toLocaleString"); + QTest::newRow("Number.prototype.valueOf") << QString("Number.prototype.valueOf") << QString("valueOf"); + QTest::newRow("Number.prototype.toFixed") << QString("Number.prototype.toFixed") << QString("toFixed"); + QTest::newRow("Number.prototype.toExponential") << QString("Number.prototype.toExponential") << QString("toExponential"); + QTest::newRow("Number.prototype.toPrecision") << QString("Number.prototype.toPrecision") << QString("toPrecision"); + + QTest::newRow("Object") << QString("Object") << QString("Object"); + QTest::newRow("Object.prototype.toString") << QString("Object.prototype.toString") << QString("toString"); + QTest::newRow("Object.prototype.toLocaleString") << QString("Object.prototype.toLocaleString") << QString("toLocaleString"); + QTest::newRow("Object.prototype.valueOf") << QString("Object.prototype.valueOf") << QString("valueOf"); + QTest::newRow("Object.prototype.hasOwnProperty") << QString("Object.prototype.hasOwnProperty") << QString("hasOwnProperty"); + QTest::newRow("Object.prototype.isPrototypeOf") << QString("Object.prototype.isPrototypeOf") << QString("isPrototypeOf"); + QTest::newRow("Object.prototype.propertyIsEnumerable") << QString("Object.prototype.propertyIsEnumerable") << QString("propertyIsEnumerable"); + QTest::newRow("Object.prototype.__defineGetter__") << QString("Object.prototype.__defineGetter__") << QString("__defineGetter__"); + QTest::newRow("Object.prototype.__defineSetter__") << QString("Object.prototype.__defineSetter__") << QString("__defineSetter__"); + + QTest::newRow("RegExp") << QString("RegExp") << QString("RegExp"); + QTest::newRow("RegExp.prototype.exec") << QString("RegExp.prototype.exec") << QString("exec"); + QTest::newRow("RegExp.prototype.test") << QString("RegExp.prototype.test") << QString("test"); + QTest::newRow("RegExp.prototype.toString") << QString("RegExp.prototype.toString") << QString("toString"); + + QTest::newRow("String") << QString("String") << QString("String"); + QTest::newRow("String.prototype.toString") << QString("String.prototype.toString") << QString("toString"); + QTest::newRow("String.prototype.valueOf") << QString("String.prototype.valueOf") << QString("valueOf"); + QTest::newRow("String.prototype.charAt") << QString("String.prototype.charAt") << QString("charAt"); + QTest::newRow("String.prototype.charCodeAt") << QString("String.prototype.charCodeAt") << QString("charCodeAt"); + QTest::newRow("String.prototype.concat") << QString("String.prototype.concat") << QString("concat"); + QTest::newRow("String.prototype.indexOf") << QString("String.prototype.indexOf") << QString("indexOf"); + QTest::newRow("String.prototype.lastIndexOf") << QString("String.prototype.lastIndexOf") << QString("lastIndexOf"); + QTest::newRow("String.prototype.localeCompare") << QString("String.prototype.localeCompare") << QString("localeCompare"); + QTest::newRow("String.prototype.match") << QString("String.prototype.match") << QString("match"); + QTest::newRow("String.prototype.replace") << QString("String.prototype.replace") << QString("replace"); + QTest::newRow("String.prototype.search") << QString("String.prototype.search") << QString("search"); + QTest::newRow("String.prototype.slice") << QString("String.prototype.slice") << QString("slice"); + QTest::newRow("String.prototype.split") << QString("String.prototype.split") << QString("split"); + QTest::newRow("String.prototype.substring") << QString("String.prototype.substring") << QString("substring"); + QTest::newRow("String.prototype.toLowerCase") << QString("String.prototype.toLowerCase") << QString("toLowerCase"); + QTest::newRow("String.prototype.toLocaleLowerCase") << QString("String.prototype.toLocaleLowerCase") << QString("toLocaleLowerCase"); + QTest::newRow("String.prototype.toUpperCase") << QString("String.prototype.toUpperCase") << QString("toUpperCase"); + QTest::newRow("String.prototype.toLocaleUpperCase") << QString("String.prototype.toLocaleUpperCase") << QString("toLocaleUpperCase"); +} + +void tst_QScriptEngine::builtinFunctionNames() +{ + QFETCH(QString, expression); + QFETCH(QString, expectedName); + QScriptEngine eng; + QScriptValue ret = eng.evaluate(QString::fromLatin1("%0.name").arg(expression)); + QVERIFY(ret.isString()); + QCOMPARE(ret.toString(), expectedName); +} + void tst_QScriptEngine::checkSyntax_data() { QTest::addColumn<QString>("code"); @@ -1063,7 +1438,7 @@ void tst_QScriptEngine::evaluate_data() QTest::newRow("(spaces)") << QString(" ") << -1 << false << -1; QTest::newRow("(empty)") << QString("") << -1 << false << -1; QTest::newRow("0") << QString("0") << -1 << false << -1; - QTest::newRow("0=1") << QString("\n0=1\n") << -1 << true << 2; + QTest::newRow("0=1") << QString("\n0=1;\n") << -1 << true << 2; QTest::newRow("a=1") << QString("a=1\n") << -1 << false << -1; QTest::newRow("a=1;K") << QString("a=1;\nK") << -1 << true << 2; @@ -1076,7 +1451,7 @@ void tst_QScriptEngine::evaluate_data() << -1 << true << 4; QTest::newRow("0") << QString("0") << 10 << false << -1; - QTest::newRow("0=1") << QString("\n\n0=1\n") << 10 << true << 12; + QTest::newRow("0=1") << QString("\n\n0=1\n") << 10 << true << 13; QTest::newRow("a=1") << QString("a=1\n") << 10 << false << -1; QTest::newRow("a=1;K") << QString("a=1;\n\nK") << 10 << true << 12; @@ -1130,21 +1505,42 @@ void tst_QScriptEngine::evaluate() static QScriptValue eval_nested(QScriptContext *ctx, QScriptEngine *eng) { QScriptValue result = eng->newObject(); + eng->evaluate("var bar = 'local';"); result.setProperty("thisObjectIdBefore", ctx->thisObject().property("id")); QScriptValue evaluatedThisObject = eng->evaluate("this"); result.setProperty("thisObjectIdAfter", ctx->thisObject().property("id")); result.setProperty("evaluatedThisObjectId", evaluatedThisObject.property("id")); + result.setProperty("local_bar", eng->evaluate("bar")); + return result; } void tst_QScriptEngine::nestedEvaluate() { QScriptEngine eng; - eng.globalObject().setProperty("fun", eng.newFunction(eval_nested)); - QScriptValue result = eng.evaluate("o = { id:'foo'}; o.fun = fun; o.fun()"); - QCOMPARE(result.property("thisObjectIdBefore").toString(), QString("foo")); - QCOMPARE(result.property("thisObjectIdAfter").toString(), QString("foo")); - QCOMPARE(result.property("evaluatedThisObjectId").toString(), QString("foo")); + QScriptValue fun = eng.newFunction(eval_nested); + eng.globalObject().setProperty("fun", fun); + { + QScriptValue result = eng.evaluate("o = { id:'foo'}; o.fun = fun; o.fun()"); + QCOMPARE(result.property("local_bar").toString(), QString("local")); + QCOMPARE(result.property("thisObjectIdBefore").toString(), QString("foo")); + QCOMPARE(result.property("thisObjectIdAfter").toString(), QString("foo")); + QCOMPARE(result.property("evaluatedThisObjectId").toString(), QString("foo")); + QScriptValue bar = eng.evaluate("bar"); + QVERIFY(bar.isError()); + QCOMPARE(bar.toString(), QString::fromLatin1("ReferenceError: Can't find variable: bar")); + } + + { + QScriptValue result = fun.call(eng.evaluate("p = { id:'foo' }") , QScriptValueList() ); + QCOMPARE(result.property("local_bar").toString(), QString("local")); + QCOMPARE(result.property("thisObjectIdBefore").toString(), QString("foo")); + QCOMPARE(result.property("thisObjectIdAfter").toString(), QString("foo")); + QCOMPARE(result.property("evaluatedThisObjectId").toString(), QString("foo")); + QScriptValue bar = eng.evaluate("bar"); + QVERIFY(bar.isError()); + QCOMPARE(bar.toString(), QString::fromLatin1("ReferenceError: Can't find variable: bar")); + } } void tst_QScriptEngine::uncaughtException() @@ -1152,7 +1548,7 @@ void tst_QScriptEngine::uncaughtException() QScriptEngine eng; QScriptValue fun = eng.newFunction(myFunction); QScriptValue throwFun = eng.newFunction(myThrowingFunction); - for (int x = 0; x < 2; ++x) { + for (int x = -1; x < 2; ++x) { { QScriptValue ret = eng.evaluate("a = 10;\nb = 20;\n0 = 0;\n", /*fileName=*/QString(), /*lineNumber=*/x); QVERIFY(eng.hasUncaughtException()); @@ -1167,7 +1563,7 @@ void tst_QScriptEngine::uncaughtException() QVERIFY(eng.uncaughtException().strictlyEquals(ret)); eng.clearExceptions(); QVERIFY(!eng.hasUncaughtException()); - QCOMPARE(eng.uncaughtExceptionLineNumber(), x+2); + QCOMPARE(eng.uncaughtExceptionLineNumber(), -1); QVERIFY(!eng.uncaughtException().isValid()); eng.evaluate("2 = 3"); @@ -1176,7 +1572,7 @@ void tst_QScriptEngine::uncaughtException() QVERIFY(ret2.isError()); QVERIFY(eng.hasUncaughtException()); QVERIFY(eng.uncaughtException().strictlyEquals(ret2)); - QCOMPARE(eng.uncaughtExceptionLineNumber(), -1); + QCOMPARE(eng.uncaughtExceptionLineNumber(), 0); eng.clearExceptions(); QVERIFY(!eng.hasUncaughtException()); eng.evaluate("1 + 2"); @@ -1581,8 +1977,27 @@ void tst_QScriptEngine::valueConversion() QRegExp in = QRegExp("foo"); QScriptValue val = qScriptValueFromValue(&eng, in); QVERIFY(val.isRegExp()); + QRegExp out = val.toRegExp(); + QEXPECT_FAIL("", "JSC-based back-end doesn't preserve QRegExp::patternSyntax (always uses RegExp2)", Continue); + QCOMPARE(out.patternSyntax(), in.patternSyntax()); + QCOMPARE(out.pattern(), in.pattern()); + QCOMPARE(out.caseSensitivity(), in.caseSensitivity()); + QCOMPARE(out.isMinimal(), in.isMinimal()); + } + { + QRegExp in = QRegExp("foo", Qt::CaseSensitive, QRegExp::RegExp2); + QScriptValue val = qScriptValueFromValue(&eng, in); + QVERIFY(val.isRegExp()); QCOMPARE(val.toRegExp(), in); } + { + QRegExp in = QRegExp("foo"); + in.setMinimal(true); + QScriptValue val = qScriptValueFromValue(&eng, in); + QVERIFY(val.isRegExp()); + QEXPECT_FAIL("", "JSC-based back-end doesn't preserve QRegExp::minimal (always false)", Continue); + QCOMPARE(val.toRegExp().isMinimal(), in.isMinimal()); + } } static QScriptValue __import__(QScriptContext *ctx, QScriptEngine *eng) @@ -1678,9 +2093,10 @@ void tst_QScriptEngine::importExtension() QVERIFY(eng.importedExtensions().isEmpty()); QScriptValue ret = eng.importExtension("com.trolltech.syntaxerror"); QVERIFY(eng.hasUncaughtException()); + QEXPECT_FAIL("", "JSC throws syntax error eagerly", Continue); QCOMPARE(eng.uncaughtExceptionLineNumber(), 4); QVERIFY(ret.isError()); - QCOMPARE(ret.property("message").toString(), QLatin1String("invalid assignment lvalue")); + QCOMPARE(ret.property("message").toString(), QLatin1String("Parse error")); } QStringList imp = eng.importedExtensions(); QCOMPARE(imp.size(), 2); @@ -1706,26 +2122,27 @@ static QScriptValue recurse2(QScriptContext *ctx, QScriptEngine *eng) void tst_QScriptEngine::infiniteRecursion() { - QSKIP("Can cause C stack overflow (task 241294)", SkipAll); - + const QString stackOverflowError = QString::fromLatin1("RangeError: Maximum call stack size exceeded."); QScriptEngine eng; { QScriptValue ret = eng.evaluate("function foo() { foo(); }; foo();"); QCOMPARE(ret.isError(), true); - QCOMPARE(ret.toString(), QLatin1String("Error: call stack overflow")); + QCOMPARE(ret.toString(), stackOverflowError); } +#if 0 //The native C++ stack overflow before the JS stack { QScriptValue fun = eng.newFunction(recurse); QScriptValue ret = fun.call(); QCOMPARE(ret.isError(), true); - QCOMPARE(ret.toString(), QLatin1String("Error: call stack overflow")); + QCOMPARE(ret.toString(), stackOverflowError); } { QScriptValue fun = eng.newFunction(recurse2); QScriptValue ret = fun.construct(); QCOMPARE(ret.isError(), true); - QCOMPARE(ret.toString(), QLatin1String("Error: call stack overflow")); + QCOMPARE(ret.toString(), stackOverflowError); } +#endif } struct Bar { @@ -1893,6 +2310,7 @@ void tst_QScriptEngine::collectGarbage() QScriptValue v = eng.newQObject(ptr, QScriptEngine::ScriptOwnership); } eng.collectGarbage(); + QEXPECT_FAIL("","collectGarbage not working", Continue); QVERIFY(ptr == 0); } @@ -1949,7 +2367,7 @@ void tst_QScriptEngine::processEventsWhileRunning() eng.pushContext(); QString script = QString::fromLatin1( - "var end = Number(new Date()) + 1000;" + "var end = Number(new Date()) + 2000;" "var x = 0;" "while (Number(new Date()) < end) {" " ++x;" @@ -1992,6 +2410,7 @@ public: void tst_QScriptEngine::throwErrorFromProcessEvents() { + QSKIP("Not implemented", SkipAll); QScriptEngine eng; EventReceiver2 receiver(&eng); @@ -2035,6 +2454,7 @@ void tst_QScriptEngine::stacktrace() QVERIFY(eng.hasUncaughtException()); QVERIFY(result.isError()); + QEXPECT_FAIL("", "", Abort); QCOMPARE(eng.uncaughtExceptionBacktrace(), backtrace); QVERIFY(eng.hasUncaughtException()); QVERIFY(result.strictlyEquals(eng.uncaughtException())); @@ -2145,7 +2565,7 @@ void tst_QScriptEngine::automaticSemicolonInsertion() { QScriptValue ret = eng.evaluate("{ 1 2 } 3"); QVERIFY(ret.isError()); - QCOMPARE(ret.toString(), QString::fromLatin1("SyntaxError: Expected `;', `;'")); + QCOMPARE(ret.toString(), QString::fromLatin1("SyntaxError: Parse error")); } { QScriptValue ret = eng.evaluate("{ 1\n2 } 3"); @@ -2155,7 +2575,7 @@ void tst_QScriptEngine::automaticSemicolonInsertion() { QScriptValue ret = eng.evaluate("for (a; b\n)"); QVERIFY(ret.isError()); - QCOMPARE(ret.toString(), QString::fromLatin1("SyntaxError: Expected `;'")); + QCOMPARE(ret.toString(), QString::fromLatin1("SyntaxError: Parse error")); } { QScriptValue ret = eng.evaluate("(function() { return\n1 + 2 })()"); @@ -2170,7 +2590,7 @@ void tst_QScriptEngine::automaticSemicolonInsertion() { QScriptValue ret = eng.evaluate("if (a > b)\nelse c = d"); QVERIFY(ret.isError()); - QCOMPARE(ret.toString(), QString::fromLatin1("SyntaxError")); + QCOMPARE(ret.toString(), QString::fromLatin1("SyntaxError: Parse error")); } { eng.evaluate("function c() { return { foo: function() { return 5; } } }"); @@ -2182,7 +2602,7 @@ void tst_QScriptEngine::automaticSemicolonInsertion() { QScriptValue ret = eng.evaluate("throw\n1"); QVERIFY(ret.isError()); - QCOMPARE(ret.toString(), QString::fromLatin1("SyntaxError")); + QCOMPARE(ret.toString(), QString::fromLatin1("SyntaxError: Parse error")); } { QScriptValue ret = eng.evaluate("a = Number(1)\n++a"); @@ -2388,6 +2808,13 @@ void tst_QScriptEngine::abortEvaluation() eng.abortEvaluation(); QVERIFY(!eng.hasUncaughtException()); + eng.abortEvaluation(123); + { + QScriptValue ret = eng.evaluate("'ciao'"); + QVERIFY(ret.isString()); + QCOMPARE(ret.toString(), QString::fromLatin1("ciao")); + } + EventReceiver3 receiver(&eng); eng.setProcessEventsInterval(100); @@ -2552,31 +2979,46 @@ void tst_QScriptEngine::errorConstructors() QScriptEngine eng; QStringList prefixes; prefixes << "" << "Eval" << "Range" << "Reference" << "Syntax" << "Type" << "URI"; - for (int x = 0; x < 2; ++x) { + for (int x = 0; x < 3; ++x) { for (int i = 0; i < prefixes.size(); ++i) { QString name = prefixes.at(i) + QLatin1String("Error"); QString code = QString(i+1, QLatin1Char('\n')); if (x == 0) + code += QLatin1String("throw "); + else if (x == 1) code += QLatin1String("new "); code += name + QLatin1String("()"); QScriptValue ret = eng.evaluate(code); QVERIFY(ret.isError()); - QVERIFY(!eng.hasUncaughtException()); - QCOMPARE(ret.toString(), name); + QCOMPARE(eng.hasUncaughtException(), x == 0); + eng.clearExceptions(); + QVERIFY(ret.toString().startsWith(name)); + if (x != 0) + QEXPECT_FAIL("", "JSC doesn't assign lineNumber when errors are not thrown", Continue); QCOMPARE(ret.property("lineNumber").toInt32(), i+2); } } } +static QScriptValue argumentsProperty_fun(QScriptContext *, QScriptEngine *eng) +{ + eng->evaluate("var a = arguments[0];"); + eng->evaluate("arguments[0] = 200;"); + return eng->evaluate("a + arguments[0]"); +} + + void tst_QScriptEngine::argumentsProperty() { { QScriptEngine eng; + QEXPECT_FAIL("", "", Continue); QVERIFY(eng.evaluate("arguments").isUndefined()); eng.evaluate("arguments = 10"); QScriptValue ret = eng.evaluate("arguments"); QVERIFY(ret.isNumber()); QCOMPARE(ret.toInt32(), 10); + QEXPECT_FAIL("", "", Continue); QVERIFY(!eng.evaluate("delete arguments").toBoolean()); } { @@ -2591,8 +3033,18 @@ void tst_QScriptEngine::argumentsProperty() QScriptValue ret = eng.evaluate("(function() { arguments = 456; return arguments; })()"); QVERIFY(ret.isNumber()); QCOMPARE(ret.toInt32(), 456); + QEXPECT_FAIL("", "", Continue); QVERIFY(eng.evaluate("arguments").isUndefined()); } + + { + QScriptEngine eng; + QScriptValue fun = eng.newFunction(argumentsProperty_fun); + eng.globalObject().setProperty("fun", eng.newFunction(argumentsProperty_fun)); + QScriptValue result = eng.evaluate("fun(18)"); + QVERIFY(result.isNumber()); + QCOMPARE(result.toInt32(), 218); + } } void tst_QScriptEngine::numberClass() @@ -2615,7 +3067,7 @@ void tst_QScriptEngine::numberClass() QCOMPARE(ctor.propertyFlags("MIN_VALUE"), flags); QVERIFY(ctor.property("NaN").isNumber()); QCOMPARE(ctor.propertyFlags("NaN"), flags); - QVERIFY(ctor.property("NEGATIVE_INFINITY").isNumber()); + QVERIFY(ctor.property("NEGATIVE_INFINITY").isNumber()); QCOMPARE(ctor.propertyFlags("NEGATIVE_INFINITY"), flags); QVERIFY(ctor.property("POSITIVE_INFINITY").isNumber()); QCOMPARE(ctor.propertyFlags("POSITIVE_INFINITY"), flags); @@ -2690,7 +3142,7 @@ void tst_QScriptEngine::numberClass() { QScriptValue ret = eng.evaluate("new Number(123).toExponential()"); QVERIFY(ret.isString()); - QCOMPARE(ret.toString(), QString::fromLatin1("1e+02")); + QCOMPARE(ret.toString(), QString::fromLatin1("1.23e+2")); } QVERIFY(proto.property("toFixed").isFunction()); { @@ -2702,7 +3154,7 @@ void tst_QScriptEngine::numberClass() { QScriptValue ret = eng.evaluate("new Number(123).toPrecision()"); QVERIFY(ret.isString()); - QCOMPARE(ret.toString(), QString::fromLatin1("1e+02")); + QCOMPARE(ret.toString(), QString::fromLatin1("123")); } } @@ -2776,9 +3228,8 @@ void tst_QScriptEngine::forInStatement() QScriptValue ret = eng.evaluate("o = { p: 123 }; r = [];" "for (var p in o) { r[r.length] = p; o.q = 456; } r"); QStringList lst = qscriptvalue_cast<QStringList>(ret); - QCOMPARE(lst.size(), 2); + QCOMPARE(lst.size(), 1); QCOMPARE(lst.at(0), QString::fromLatin1("p")); - QCOMPARE(lst.at(1), QString::fromLatin1("q")); } // arrays @@ -2795,9 +3246,9 @@ void tst_QScriptEngine::forInStatement() "for (var p in a) r[r.length] = p; r"); QStringList lst = qscriptvalue_cast<QStringList>(ret); QCOMPARE(lst.size(), 3); - QCOMPARE(lst.at(0), QString::fromLatin1("foo")); - QCOMPARE(lst.at(1), QString::fromLatin1("0")); - QCOMPARE(lst.at(2), QString::fromLatin1("1")); + QCOMPARE(lst.at(0), QString::fromLatin1("0")); + QCOMPARE(lst.at(1), QString::fromLatin1("1")); + QCOMPARE(lst.at(2), QString::fromLatin1("foo")); } { QScriptValue ret = eng.evaluate("a = [123, 456]; a.foo = 'bar';" @@ -2806,10 +3257,11 @@ void tst_QScriptEngine::forInStatement() "for (var p in a) r[r.length] = p; r"); QStringList lst = qscriptvalue_cast<QStringList>(ret); QCOMPARE(lst.size(), 5); - QCOMPARE(lst.at(0), QString::fromLatin1("foo")); - QCOMPARE(lst.at(1), QString::fromLatin1("0")); - QCOMPARE(lst.at(2), QString::fromLatin1("1")); - QCOMPARE(lst.at(3), QString::fromLatin1("bar")); + QCOMPARE(lst.at(0), QString::fromLatin1("0")); + QCOMPARE(lst.at(1), QString::fromLatin1("1")); + QCOMPARE(lst.at(2), QString::fromLatin1("foo")); + QCOMPARE(lst.at(3), QString::fromLatin1("2")); + QCOMPARE(lst.at(4), QString::fromLatin1("bar")); } // null and undefined @@ -2838,7 +3290,7 @@ void tst_QScriptEngine::functionExpression() " else\n" " function baz() { return 'baz'; }\n" " return (arg == 'bar') ? bar : baz;\n" - "}"); + "}"); QVERIFY(!eng.globalObject().property("bar").isValid()); QVERIFY(!eng.globalObject().property("baz").isValid()); QVERIFY(eng.evaluate("foo").isFunction()); @@ -2979,23 +3431,33 @@ void tst_QScriptEngine::getterSetterThisObject() eng.evaluate("__defineSetter__('x', function() { return this; });"); { QScriptValue ret = eng.evaluate("x = 'foo'"); - QVERIFY(ret.equals(eng.globalObject())); + // SpiderMonkey says setter return value, JSC says RHS. + QVERIFY(ret.isString()); + QCOMPARE(ret.toString(), QString::fromLatin1("foo")); } { QScriptValue ret = eng.evaluate("(function() { return x = 'foo'; })()"); - QVERIFY(ret.equals(eng.globalObject())); + // SpiderMonkey says setter return value, JSC says RHS. + QVERIFY(ret.isString()); + QCOMPARE(ret.toString(), QString::fromLatin1("foo")); } { QScriptValue ret = eng.evaluate("with (this) x = 'foo'"); - QVERIFY(ret.equals(eng.globalObject())); + // SpiderMonkey says setter return value, JSC says RHS. + QVERIFY(ret.isString()); + QCOMPARE(ret.toString(), QString::fromLatin1("foo")); } { QScriptValue ret = eng.evaluate("with ({}) x = 'foo'"); - QVERIFY(ret.equals(eng.globalObject())); + // SpiderMonkey says setter return value, JSC says RHS. + QVERIFY(ret.isString()); + QCOMPARE(ret.toString(), QString::fromLatin1("foo")); } { QScriptValue ret = eng.evaluate("(function() { with ({}) return x = 'foo'; })()"); - QVERIFY(ret.equals(eng.globalObject())); + // SpiderMonkey says setter return value, JSC says RHS. + QVERIFY(ret.isString()); + QCOMPARE(ret.toString(), QString::fromLatin1("foo")); } } @@ -3011,9 +3473,10 @@ void tst_QScriptEngine::getterSetterThisObject() eng.evaluate("q = {}; with (o) with (q) x").equals(eng.evaluate("o")); // write eng.evaluate("o.__defineSetter__('x', function() { return this; });"); - QVERIFY(eng.evaluate("(o.x = 'foo') === o").toBoolean()); - QVERIFY(eng.evaluate("with (o) x = 'foo'").equals(eng.evaluate("o"))); - QVERIFY(eng.evaluate("with (o) with (q) x = 'foo'").equals(eng.evaluate("o"))); + // SpiderMonkey says setter return value, JSC says RHS. + QVERIFY(eng.evaluate("(o.x = 'foo') === 'foo'").toBoolean()); + QVERIFY(eng.evaluate("with (o) x = 'foo'").equals("foo")); + QVERIFY(eng.evaluate("with (o) with (q) x = 'foo'").equals("foo")); } // getter+setter in prototype chain @@ -3029,29 +3492,32 @@ void tst_QScriptEngine::getterSetterThisObject() eng.evaluate("with (q) with (o) x").equals(eng.evaluate("o")); // write eng.evaluate("o.__defineSetter__('x', function() { return this; });"); - QVERIFY(eng.evaluate("(o.x = 'foo') === o").toBoolean()); - QVERIFY(eng.evaluate("with (o) x = 'foo'").equals(eng.evaluate("o"))); - QVERIFY(eng.evaluate("with (o) with (q) x = 'foo'").equals(eng.evaluate("o"))); + // SpiderMonkey says setter return value, JSC says RHS. + QVERIFY(eng.evaluate("(o.x = 'foo') === 'foo'").toBoolean()); + QVERIFY(eng.evaluate("with (o) x = 'foo'").equals("foo")); + QVERIFY(eng.evaluate("with (o) with (q) x = 'foo'").equals("foo")); } // getter+setter in activation { QScriptEngine eng; QScriptContext *ctx = eng.pushContext(); + QVERIFY(ctx != 0); QScriptValue act = ctx->activationObject(); act.setProperty("act", act); // read eng.evaluate("act.__defineGetter__('x', function() { return this; })"); QVERIFY(eng.evaluate("x === act").toBoolean()); - QVERIFY(eng.evaluate("with (act) x").equals(eng.evaluate("act"))); + QEXPECT_FAIL("", "Exotic overload (don't care for now)", Continue); + QVERIFY(eng.evaluate("with (act) x").equals("foo")); QVERIFY(eng.evaluate("(function() { with (act) return x; })() === act").toBoolean()); eng.evaluate("q = {}; with (act) with (q) x").equals(eng.evaluate("act")); eng.evaluate("with (q) with (act) x").equals(eng.evaluate("act")); // write eng.evaluate("act.__defineSetter__('x', function() { return this; });"); - QVERIFY(eng.evaluate("(x = 'foo') === act").toBoolean()); - QVERIFY(eng.evaluate("with (act) x = 'foo'").equals(eng.evaluate("act"))); - QVERIFY(eng.evaluate("with (act) with (q) x = 'foo'").equals(eng.evaluate("act"))); + QVERIFY(eng.evaluate("(x = 'foo') === 'foo'").toBoolean()); + QVERIFY(eng.evaluate("with (act) x = 'foo'").equals("foo")); + QVERIFY(eng.evaluate("with (act) with (q) x = 'foo'").equals("foo")); eng.popContext(); } } @@ -3136,6 +3602,7 @@ void tst_QScriptEngine::continueInSwitch() void tst_QScriptEngine::readOnlyPrototypeProperty() { + QSKIP("JSC semantics differ from old back-end and SpiderMonkey", SkipAll); QScriptEngine eng; QCOMPARE(eng.evaluate("o = {}; o.__proto__ = parseInt; o.length").toInt32(), 2); QCOMPARE(eng.evaluate("o.length = 4; o.length").toInt32(), 2); @@ -3253,7 +3720,8 @@ void tst_QScriptEngine::reservedWords() QScriptEngine eng; QScriptValue ret = eng.evaluate(word + " = 123"); QVERIFY(ret.isError()); - QVERIFY(ret.toString().startsWith("SyntaxError")); + QString str = ret.toString(); + QVERIFY(str.startsWith("SyntaxError") || str.startsWith("ReferenceError")); } { QScriptEngine eng; @@ -3264,14 +3732,16 @@ void tst_QScriptEngine::reservedWords() { QScriptEngine eng; QScriptValue ret = eng.evaluate("o = {}; o." + word + " = 123"); - QVERIFY(!ret.isError()); - QVERIFY(ret.strictlyEquals(eng.evaluate("o." + word))); + // in the old back-end and in SpiderMonkey this is allowed, but not in JSC + QVERIFY(ret.isError()); + QVERIFY(ret.toString().startsWith("SyntaxError")); } { QScriptEngine eng; QScriptValue ret = eng.evaluate("o = { " + word + ": 123 }"); - QVERIFY(!ret.isError()); - QVERIFY(ret.property(word).isNumber()); + // in the old back-end and in SpiderMonkey this is allowed, but not in JSC + QVERIFY(ret.isError()); + QVERIFY(ret.toString().startsWith("SyntaxError")); } { // SpiderMonkey allows this, but we don't @@ -3285,66 +3755,66 @@ void tst_QScriptEngine::reservedWords() void tst_QScriptEngine::futureReservedWords_data() { QTest::addColumn<QString>("word"); - QTest::newRow("abstract") << QString("abstract"); - QTest::newRow("boolean") << QString("boolean"); - QTest::newRow("byte") << QString("byte"); - QTest::newRow("char") << QString("char"); - QTest::newRow("class") << QString("class"); - QTest::newRow("const") << QString("const"); - QTest::newRow("debugger") << QString("debugger"); - QTest::newRow("double") << QString("double"); - QTest::newRow("enum") << QString("enum"); - QTest::newRow("export") << QString("export"); - QTest::newRow("extends") << QString("extends"); - QTest::newRow("final") << QString("final"); - QTest::newRow("float") << QString("float"); - QTest::newRow("goto") << QString("goto"); - QTest::newRow("implements") << QString("implements"); - QTest::newRow("import") << QString("import"); - QTest::newRow("int") << QString("int"); - QTest::newRow("interface") << QString("interface"); - QTest::newRow("long") << QString("long"); - QTest::newRow("native") << QString("native"); - QTest::newRow("package") << QString("package"); - QTest::newRow("private") << QString("private"); - QTest::newRow("protected") << QString("protected"); - QTest::newRow("public") << QString("public"); - QTest::newRow("short") << QString("short"); - QTest::newRow("static") << QString("static"); - QTest::newRow("super") << QString("super"); - QTest::newRow("synchronized") << QString("synchronized"); - QTest::newRow("throws") << QString("throws"); - QTest::newRow("transient") << QString("transient"); - QTest::newRow("volatile") << QString("volatile"); + QTest::addColumn<bool>("allowed"); + QTest::newRow("abstract") << QString("abstract") << true; + QTest::newRow("boolean") << QString("boolean") << true; + QTest::newRow("byte") << QString("byte") << true; + QTest::newRow("char") << QString("char") << true; + QTest::newRow("class") << QString("class") << false; + QTest::newRow("const") << QString("const") << false; + QTest::newRow("debugger") << QString("debugger") << false; + QTest::newRow("double") << QString("double") << true; + QTest::newRow("enum") << QString("enum") << false; + QTest::newRow("export") << QString("export") << false; + QTest::newRow("extends") << QString("extends") << false; + QTest::newRow("final") << QString("final") << true; + QTest::newRow("float") << QString("float") << true; + QTest::newRow("goto") << QString("goto") << true; + QTest::newRow("implements") << QString("implements") << true; + QTest::newRow("import") << QString("import") << false; + QTest::newRow("int") << QString("int") << true; + QTest::newRow("interface") << QString("interface") << true; + QTest::newRow("long") << QString("long") << true; + QTest::newRow("native") << QString("native") << true; + QTest::newRow("package") << QString("package") << true; + QTest::newRow("private") << QString("private") << true; + QTest::newRow("protected") << QString("protected") << true; + QTest::newRow("public") << QString("public") << true; + QTest::newRow("short") << QString("short") << true; + QTest::newRow("static") << QString("static") << true; + QTest::newRow("super") << QString("super") << false; + QTest::newRow("synchronized") << QString("synchronized") << true; + QTest::newRow("throws") << QString("throws") << true; + QTest::newRow("transient") << QString("transient") << true; + QTest::newRow("volatile") << QString("volatile") << true; } void tst_QScriptEngine::futureReservedWords() { QFETCH(QString, word); + QFETCH(bool, allowed); { QScriptEngine eng; QScriptValue ret = eng.evaluate(word + " = 123"); - QVERIFY(ret.isError()); - QVERIFY(ret.toString().startsWith("SyntaxError")); + QCOMPARE(!ret.isError(), allowed); } { QScriptEngine eng; QScriptValue ret = eng.evaluate("var " + word + " = 123"); - QVERIFY(ret.isError()); - QVERIFY(ret.toString().startsWith("SyntaxError")); + QCOMPARE(!ret.isError(), allowed); } { // this should probably be allowed (see task 162567) QScriptEngine eng; QScriptValue ret = eng.evaluate("o = {}; o." + word + " = 123"); - QVERIFY(ret.isNumber()); + QCOMPARE(ret.isNumber(), allowed); + QCOMPARE(!ret.isError(), allowed); } { // this should probably be allowed (see task 162567) QScriptEngine eng; QScriptValue ret = eng.evaluate("o = { " + word + ": 123 }"); - QVERIFY(!ret.isError()); - QVERIFY(ret.isObject()); + QCOMPARE(!ret.isError(), allowed); } } @@ -3363,7 +3833,7 @@ void tst_QScriptEngine::throwInsideWithStatement() " bad;" "}"); QVERIFY(ret.isError()); - QCOMPARE(ret.toString(), QString::fromLatin1("ReferenceError: bad is not defined")); + QCOMPARE(ret.toString(), QString::fromLatin1("ReferenceError: Can't find variable: bad")); } { QScriptValue ret = eng.evaluate( @@ -3376,9 +3846,10 @@ void tst_QScriptEngine::throwInsideWithStatement() " bad;" "}"); QVERIFY(ret.isError()); - QCOMPARE(ret.toString(), QString::fromLatin1("ReferenceError: bad is not defined")); + QCOMPARE(ret.toString(), QString::fromLatin1("ReferenceError: Can't find variable: bad")); } { + eng.clearExceptions(); QScriptValue ret = eng.evaluate( "o = { bug : \"no bug\" };" "with (o) {" @@ -3388,10 +3859,12 @@ void tst_QScriptEngine::throwInsideWithStatement() " bug;" " }" "}"); - QVERIFY(ret.isString()); - QCOMPARE(ret.toString(), QString::fromLatin1("no bug")); + QVERIFY(ret.isNumber()); + QCOMPARE(ret.toInt32(), 123); + QVERIFY(eng.hasUncaughtException()); } { + eng.clearExceptions(); QScriptValue ret = eng.evaluate( "o = { bug : \"no bug\" };" "with (o) {" @@ -3400,7 +3873,7 @@ void tst_QScriptEngine::throwInsideWithStatement() QVERIFY(ret.isNumber()); QScriptValue ret2 = eng.evaluate("bug"); QVERIFY(ret2.isError()); - QCOMPARE(ret2.toString(), QString::fromLatin1("ReferenceError: bug is not defined")); + QCOMPARE(ret2.toString(), QString::fromLatin1("ReferenceError: Can't find variable: bug")); } } @@ -3412,13 +3885,36 @@ public: void tst_QScriptEngine::getSetAgent() { - QScriptEngine eng; - QCOMPARE(eng.agent(), (QScriptEngineAgent*)0); - TestAgent agent(&eng); - eng.setAgent(&agent); - QCOMPARE(eng.agent(), (QScriptEngineAgent*)&agent); - eng.setAgent(0); - QCOMPARE(eng.agent(), (QScriptEngineAgent*)0); + // case 1: engine deleted before agent --> agent deleted too + { + QScriptEngine *eng = new QScriptEngine; + QCOMPARE(eng->agent(), (QScriptEngineAgent*)0); + TestAgent *agent = new TestAgent(eng); + eng->setAgent(agent); + QCOMPARE(eng->agent(), (QScriptEngineAgent*)agent); + eng->setAgent(0); // the engine maintains ownership of the old agent + QCOMPARE(eng->agent(), (QScriptEngineAgent*)0); + delete eng; + } + // case 2: agent deleted before engine --> engine's agent should become 0 + { + QScriptEngine *eng = new QScriptEngine; + TestAgent *agent = new TestAgent(eng); + eng->setAgent(agent); + QCOMPARE(eng->agent(), (QScriptEngineAgent*)agent); + delete agent; + QCOMPARE(eng->agent(), (QScriptEngineAgent*)0); + eng->evaluate("(function(){ return 123; })()"); + delete eng; + } + { + QScriptEngine eng; + QScriptEngine eng2; + TestAgent *agent = new TestAgent(&eng); + QTest::ignoreMessage(QtWarningMsg, "QScriptEngine::setAgent(): cannot set agent belonging to different engine"); + eng2.setAgent(agent); + QCOMPARE(eng2.agent(), (QScriptEngineAgent*)0); + } } void tst_QScriptEngine::reentrancy() @@ -3506,42 +4002,42 @@ void tst_QScriptEngine:: incDecNonObjectProperty() { QScriptValue ret = eng.evaluate("var a; a.n++"); QVERIFY(ret.isError()); - QCOMPARE(ret.toString(), QString::fromLatin1("TypeError: not an object")); + QCOMPARE(ret.toString(), QString::fromLatin1("TypeError: Result of expression 'a' [undefined] is not an object.")); } { QScriptValue ret = eng.evaluate("var a; a.n--"); QVERIFY(ret.isError()); - QCOMPARE(ret.toString(), QString::fromLatin1("TypeError: not an object")); + QCOMPARE(ret.toString(), QString::fromLatin1("TypeError: Result of expression 'a' [undefined] is not an object.")); } { QScriptValue ret = eng.evaluate("var a = null; a.n++"); QVERIFY(ret.isError()); - QCOMPARE(ret.toString(), QString::fromLatin1("TypeError: not an object")); + QCOMPARE(ret.toString(), QString::fromLatin1("TypeError: Result of expression 'a' [null] is not an object.")); } { QScriptValue ret = eng.evaluate("var a = null; a.n--"); QVERIFY(ret.isError()); - QCOMPARE(ret.toString(), QString::fromLatin1("TypeError: not an object")); + QCOMPARE(ret.toString(), QString::fromLatin1("TypeError: Result of expression 'a' [null] is not an object.")); } { QScriptValue ret = eng.evaluate("var a; ++a.n"); QVERIFY(ret.isError()); - QCOMPARE(ret.toString(), QString::fromLatin1("TypeError: not an object")); + QCOMPARE(ret.toString(), QString::fromLatin1("TypeError: Result of expression 'a' [null] is not an object.")); } { QScriptValue ret = eng.evaluate("var a; --a.n"); QVERIFY(ret.isError()); - QCOMPARE(ret.toString(), QString::fromLatin1("TypeError: not an object")); + QCOMPARE(ret.toString(), QString::fromLatin1("TypeError: Result of expression 'a' [null] is not an object.")); } { QScriptValue ret = eng.evaluate("var a; a.n += 1"); QVERIFY(ret.isError()); - QCOMPARE(ret.toString(), QString::fromLatin1("TypeError: not an object")); + QCOMPARE(ret.toString(), QString::fromLatin1("TypeError: Result of expression 'a' [null] is not an object.")); } { QScriptValue ret = eng.evaluate("var a; a.n -= 1"); QVERIFY(ret.isError()); - QCOMPARE(ret.toString(), QString::fromLatin1("TypeError: not an object")); + QCOMPARE(ret.toString(), QString::fromLatin1("TypeError: Result of expression 'a' [null] is not an object.")); } { QScriptValue ret = eng.evaluate("var a = 'ciao'; a.length++"); @@ -3616,6 +4112,7 @@ void tst_QScriptEngine::functionScopes() // top-level functions have only the global object in their scope QScriptValue fun = eng.evaluate("(function() {})"); QVERIFY(fun.isFunction()); + QEXPECT_FAIL("", "Function scope proxying is not implemented", Abort); QVERIFY(fun.scope().isObject()); QVERIFY(fun.scope().strictlyEquals(eng.globalObject())); QVERIFY(!eng.globalObject().scope().isValid()); @@ -3684,7 +4181,7 @@ static QScriptValue counter_hybrid(QScriptContext *ctx, QScriptEngine *eng) { QScriptValue act = ctx->activationObject(); act.setProperty("count", ctx->argument(0).toInt32()); - return eng->evaluate("function() { return count++; }"); + return eng->evaluate("(function() { return count++; })"); } void tst_QScriptEngine::nativeFunctionScopes() @@ -3710,6 +4207,90 @@ void tst_QScriptEngine::nativeFunctionScopes() QCOMPARE(ret.toInt32(), 123); } } + + //from http://doc.trolltech.com/latest/qtscript.html#nested-functions-and-the-scope-chain + { + QScriptEngine eng; + eng.evaluate("function counter() { var count = 0; return function() { return count++; } }\n" + "var c1 = counter(); var c2 = counter(); "); + QCOMPARE(eng.evaluate("c1()").toString(), QString::fromLatin1("0")); + QCOMPARE(eng.evaluate("c1()").toString(), QString::fromLatin1("1")); + QCOMPARE(eng.evaluate("c2()").toString(), QString::fromLatin1("0")); + QCOMPARE(eng.evaluate("c2()").toString(), QString::fromLatin1("1")); + QVERIFY(!eng.hasUncaughtException()); + } + { + QScriptEngine eng; + eng.globalObject().setProperty("counter", eng.newFunction(counter)); + eng.evaluate("var c1 = counter(); var c2 = counter(); "); + QCOMPARE(eng.evaluate("c1()").toString(), QString::fromLatin1("0")); + QCOMPARE(eng.evaluate("c1()").toString(), QString::fromLatin1("1")); + QCOMPARE(eng.evaluate("c2()").toString(), QString::fromLatin1("0")); + QCOMPARE(eng.evaluate("c2()").toString(), QString::fromLatin1("1")); + QVERIFY(!eng.hasUncaughtException()); + } + { + QScriptEngine eng; + eng.globalObject().setProperty("counter", eng.newFunction(counter_hybrid)); + eng.evaluate("var c1 = counter(); var c2 = counter(); "); + QCOMPARE(eng.evaluate("c1()").toString(), QString::fromLatin1("0")); + QCOMPARE(eng.evaluate("c1()").toString(), QString::fromLatin1("1")); + QCOMPARE(eng.evaluate("c2()").toString(), QString::fromLatin1("0")); + QCOMPARE(eng.evaluate("c2()").toString(), QString::fromLatin1("1")); + QVERIFY(!eng.hasUncaughtException()); + } +} + +static QRegExp minimal(QRegExp r) { r.setMinimal(true); return r; } + +void tst_QScriptEngine::qRegExpInport_data() +{ + QTest::addColumn<QRegExp>("rx"); + QTest::addColumn<QString>("string"); + QTest::addColumn<QString>("matched"); + + QTest::newRow("normal") << QRegExp("(test|foo)") << "test _ foo _ test _ Foo"; + QTest::newRow("normal2") << QRegExp("(Test|Foo)") << "test _ foo _ test _ Foo"; + QTest::newRow("case insensitive)") << QRegExp("(test|foo)", Qt::CaseInsensitive) << "test _ foo _ test _ Foo"; + QTest::newRow("case insensitive2)") << QRegExp("(Test|Foo)", Qt::CaseInsensitive) << "test _ foo _ test _ Foo"; + QTest::newRow("b(a*)(b*)") << QRegExp("b(a*)(b*)", Qt::CaseInsensitive) << "aaabbBbaAabaAaababaaabbaaab"; + QTest::newRow("greedy") << QRegExp("a*(a*)", Qt::CaseInsensitive, QRegExp::RegExp2) << "aaaabaaba"; + // this one will fail because we do not support the QRegExp::RegExp in JSC + //QTest::newRow("not_greedy") << QRegExp("a*(a*)", Qt::CaseInsensitive, QRegExp::RegExp) << "aaaabaaba"; + QTest::newRow("willcard") << QRegExp("*.txt", Qt::CaseSensitive, QRegExp::Wildcard) << "file.txt"; + QTest::newRow("willcard 2") << QRegExp("a?b.txt", Qt::CaseSensitive, QRegExp::Wildcard) << "ab.txt abb.rtc acb.txt"; + QTest::newRow("slash") << QRegExp("g/.*/s", Qt::CaseInsensitive, QRegExp::RegExp2) << "string/string/string"; + QTest::newRow("slash2") << QRegExp("g / .* / s", Qt::CaseInsensitive, QRegExp::RegExp2) << "string / string / string"; + QTest::newRow("fixed") << QRegExp("a*aa.a(ba)*a\\ba", Qt::CaseInsensitive, QRegExp::FixedString) << "aa*aa.a(ba)*a\\ba"; + QTest::newRow("fixed insensitive") << QRegExp("A*A", Qt::CaseInsensitive, QRegExp::FixedString) << "a*A A*a A*A a*a"; + QTest::newRow("fixed sensitive") << QRegExp("A*A", Qt::CaseSensitive, QRegExp::FixedString) << "a*A A*a A*A a*a"; + QTest::newRow("html") << QRegExp("<b>(.*)</b>", Qt::CaseSensitive, QRegExp::RegExp2) << "<b>bold</b><i>italic</i><b>bold</b>"; + QTest::newRow("html minimal") << minimal(QRegExp("<b>(.*)</b>", Qt::CaseSensitive, QRegExp::RegExp2)) << "<b>bold</b><i>italic</i><b>bold</b>"; + QTest::newRow("aaa") << QRegExp("a{2,5}") << "aAaAaaaaaAa"; + QTest::newRow("aaa minimal") << minimal(QRegExp("a{2,5}")) << "aAaAaaaaaAa"; + QTest::newRow("minimal") << minimal(QRegExp(".*\\} [*8]")) << "}?} ?} *"; +} + +void tst_QScriptEngine::qRegExpInport() +{ + QFETCH(QRegExp, rx); + QFETCH(QString, string); + + QScriptEngine eng; + QScriptValue rexp; + rexp = eng.newRegExp(rx); + + QCOMPARE(rexp.isValid(), true); + QCOMPARE(rexp.isRegExp(), true); + QVERIFY(rexp.isFunction()); + + QScriptValue func = eng.evaluate("(function(string, regexp) { return string.match(regexp); })"); + QScriptValue result = func.call(QScriptValue(), QScriptValueList() << string << rexp); + + rx.indexIn(string); + for (int i = 0; i <= rx.numCaptures(); i++) { + QCOMPARE(result.property(i).toString(), rx.cap(i)); + } } QTEST_MAIN(tst_QScriptEngine) diff --git a/tests/auto/qscriptengineagent/tst_qscriptengineagent.cpp b/tests/auto/qscriptengineagent/tst_qscriptengineagent.cpp index 3ad9f07..886c70b 100644 --- a/tests/auto/qscriptengineagent/tst_qscriptengineagent.cpp +++ b/tests/auto/qscriptengineagent/tst_qscriptengineagent.cpp @@ -44,6 +44,7 @@ #include <QtScript/qscriptengineagent.h> #include <QtScript/qscriptengine.h> +#include <qscriptvalueiterator.h> //TESTED_CLASS= //TESTED_FILES= @@ -67,16 +68,43 @@ signals: void testSignal(double arg); private slots: + void scriptLoadAndUnload_statement(); void scriptLoadAndUnload(); + void scriptLoadAndUnload_eval(); void contextPushAndPop(); - void functionEntryAndExit(); - void positionChange(); + void functionEntryAndExit_semicolon(); + void functionEntryAndExit_expression(); + void functionEntryAndExit_functionCall(); + void functionEntryAndExit_functionCallWithoutReturn(); + void functionEntryAndExit_functionDefinition(); + void functionEntryAndExit_native(); + void functionEntryAndExit_native2(); + void functionEntryAndExit_nativeThrowing(); + void functionEntryAndExit_builtin(); + void functionEntryAndExit_objects(); + void functionEntryAndExit_slots(); + void functionEntryAndExit_property_set(); + void functionEntryAndExit_property_get(); + void functionEntryAndExit_call(); + void functionEntryAndExit_functionReturn_construct(); + void functionEntryAndExit_functionReturn_call(); + void functionEntryAndExit_objectCall(); + void positionChange_1(); + void positionChange_2(); void exceptionThrowAndCatch(); - void eventOrder(); + void eventOrder_assigment(); + void eventOrder_functionDefinition(); + void eventOrder_throwError(); + void eventOrder_throwAndCatch(); + void eventOrder_functions(); + void eventOrder_throwCatchFinally(); + void eventOrder_signalsHandling(); void recursiveObserve(); void multipleAgents(); void syntaxError(); + void extension_invoctaion(); void extension(); + void isEvaluatingInExtension(); private: double m_testProperty; @@ -94,13 +122,13 @@ struct ScriptEngineEvent { enum Type { ScriptLoad, - ScriptUnload, + ScriptUnload,//1 ContextPush, - ContextPop, - FunctionEntry, - FunctionExit, + ContextPop, //3 + FunctionEntry, //4 + FunctionExit, //5 PositionChange, - ExceptionThrow, + ExceptionThrow,//7 ExceptionCatch, DebuggerInvocationRequest }; @@ -288,7 +316,7 @@ QVariant ScriptEngineSpy::extension(Extension ext, const QVariant &arg) return QVariant(); } -void tst_QScriptEngineAgent::scriptLoadAndUnload() +void tst_QScriptEngineAgent::scriptLoadAndUnload_statement() { QScriptEngine eng; ScriptEngineSpy *spy = new ScriptEngineSpy(&eng, ~(ScriptEngineSpy::IgnoreScriptLoad @@ -331,7 +359,15 @@ void tst_QScriptEngineAgent::scriptLoadAndUnload() QCOMPARE(spy->at(1).type, ScriptEngineEvent::ScriptUnload); QCOMPARE(spy->at(1).scriptId, spy->at(0).scriptId); } + delete spy; +} +void tst_QScriptEngineAgent::scriptLoadAndUnload() +{ + QScriptEngine eng; + ScriptEngineSpy *spy = new ScriptEngineSpy(&eng, ~(ScriptEngineSpy::IgnoreScriptLoad + | ScriptEngineSpy::IgnoreScriptUnload)); + QCOMPARE(eng.agent(), (QScriptEngineAgent*)spy); { spy->clear(); QString code = "function foo() { print('ciao'); }"; @@ -383,6 +419,7 @@ void tst_QScriptEngineAgent::scriptLoadAndUnload() code = "bar = foo(); foo = null"; eng.evaluate(code); + QEXPECT_FAIL("","ScriptUnload event occur in different places than in old backend", Abort); QCOMPARE(spy->count(), 3); QCOMPARE(spy->at(1).type, ScriptEngineEvent::ScriptLoad); @@ -403,11 +440,19 @@ void tst_QScriptEngineAgent::scriptLoadAndUnload() eng.collectGarbage(); // foo() is GC'ed QCOMPARE(spy->count(), 6); } + delete spy; +} +void tst_QScriptEngineAgent::scriptLoadAndUnload_eval() +{ + QScriptEngine eng; + ScriptEngineSpy *spy = new ScriptEngineSpy(&eng, ~(ScriptEngineSpy::IgnoreScriptLoad + | ScriptEngineSpy::IgnoreScriptUnload)); { spy->clear(); eng.evaluate("eval('function foo() { print(123); }')"); + QEXPECT_FAIL("","Eval is threaded in different way that in old backend", Abort); QCOMPARE(spy->count(), 3); QCOMPARE(spy->at(0).type, ScriptEngineEvent::ScriptLoad); @@ -420,7 +465,7 @@ void tst_QScriptEngineAgent::scriptLoadAndUnload() QCOMPARE(spy->at(2).type, ScriptEngineEvent::ScriptUnload); QCOMPARE(spy->at(2).scriptId, spy->at(0).scriptId); } - + delete spy; } void tst_QScriptEngineAgent::contextPushAndPop() @@ -455,12 +500,12 @@ static QScriptValue nativeFunctionCallingArg(QScriptContext *ctx, QScriptEngine return ctx->argument(0).call(); } -void tst_QScriptEngineAgent::functionEntryAndExit() +/** check behaiviour of ';' */ +void tst_QScriptEngineAgent::functionEntryAndExit_semicolon() { QScriptEngine eng; ScriptEngineSpy *spy = new ScriptEngineSpy(&eng, ~(ScriptEngineSpy::IgnoreFunctionEntry | ScriptEngineSpy::IgnoreFunctionExit)); - { spy->clear(); eng.evaluate(";"); @@ -474,7 +519,15 @@ void tst_QScriptEngineAgent::functionEntryAndExit() QCOMPARE(spy->at(1).scriptId, spy->at(0).scriptId); QVERIFY(spy->at(1).value.isUndefined()); } + delete spy; +} +/** check behaiviour of expression */ +void tst_QScriptEngineAgent::functionEntryAndExit_expression() +{ + QScriptEngine eng; + ScriptEngineSpy *spy = new ScriptEngineSpy(&eng, ~(ScriptEngineSpy::IgnoreFunctionEntry + | ScriptEngineSpy::IgnoreFunctionExit)); { spy->clear(); eng.evaluate("1 + 2"); @@ -491,10 +544,18 @@ void tst_QScriptEngineAgent::functionEntryAndExit() QVERIFY(spy->at(1).value.isNumber()); QCOMPARE(spy->at(1).value.toNumber(), qsreal(3)); } + delete spy; +} +/** check behaiviour of standard function call */ +void tst_QScriptEngineAgent::functionEntryAndExit_functionCall() +{ + QScriptEngine eng; + ScriptEngineSpy *spy = new ScriptEngineSpy(&eng, ~(ScriptEngineSpy::IgnoreFunctionEntry + | ScriptEngineSpy::IgnoreFunctionExit)); { spy->clear(); - eng.evaluate("(function() { return 123; } )()"); + QVERIFY(eng.evaluate("(function() { return 123; } )()").toNumber()==123); QCOMPARE(spy->count(), 4); @@ -518,7 +579,46 @@ void tst_QScriptEngineAgent::functionEntryAndExit() QVERIFY(spy->at(3).value.isNumber()); QCOMPARE(spy->at(3).value.toNumber(), qsreal(123)); } + delete spy; +} + +/** check behaiviour of standard function call */ +void tst_QScriptEngineAgent::functionEntryAndExit_functionCallWithoutReturn() +{ + QScriptEngine eng; + ScriptEngineSpy *spy = new ScriptEngineSpy(&eng, ~(ScriptEngineSpy::IgnoreFunctionEntry + | ScriptEngineSpy::IgnoreFunctionExit)); + { + spy->clear(); + eng.evaluate("(function() { var a = 123; } )()"); + + QCOMPARE(spy->count(), 4); + + // evaluate() entry + QCOMPARE(spy->at(0).type, ScriptEngineEvent::FunctionEntry); + QVERIFY(spy->at(0).scriptId != -1); + + // anonymous function entry + QCOMPARE(spy->at(1).type, ScriptEngineEvent::FunctionEntry); + QCOMPARE(spy->at(1).scriptId, spy->at(0).scriptId); + + // anonymous function exit + QCOMPARE(spy->at(2).type, ScriptEngineEvent::FunctionExit); + QCOMPARE(spy->at(2).scriptId, spy->at(0).scriptId); + + // evaluate() exit + QCOMPARE(spy->at(3).type, ScriptEngineEvent::FunctionExit); + QCOMPARE(spy->at(3).scriptId, spy->at(0).scriptId); + } + delete spy; +} +/** check behaiviour of function definition */ +void tst_QScriptEngineAgent::functionEntryAndExit_functionDefinition() +{ + QScriptEngine eng; + ScriptEngineSpy *spy = new ScriptEngineSpy(&eng, ~(ScriptEngineSpy::IgnoreFunctionEntry + | ScriptEngineSpy::IgnoreFunctionExit)); { spy->clear(); eng.evaluate("function foo() { return 456; }"); @@ -556,15 +656,23 @@ void tst_QScriptEngineAgent::functionEntryAndExit() QVERIFY(spy->at(5).value.isNumber()); QCOMPARE(spy->at(5).value.toNumber(), qsreal(456)); } + delete spy; +} +/** check behaiviour of native function */ +void tst_QScriptEngineAgent::functionEntryAndExit_native() +{ + QScriptEngine eng; + ScriptEngineSpy *spy = new ScriptEngineSpy(&eng, ~(ScriptEngineSpy::IgnoreFunctionEntry + | ScriptEngineSpy::IgnoreFunctionExit)); // native functions - { QScriptValue fun = eng.newFunction(nativeFunctionReturningArg); eng.globalObject().setProperty("nativeFunctionReturningArg", fun); spy->clear(); eng.evaluate("nativeFunctionReturningArg(123)"); + QCOMPARE(spy->count(), 4); // evaluate() entry @@ -586,7 +694,15 @@ void tst_QScriptEngineAgent::functionEntryAndExit() QVERIFY(spy->at(3).value.isNumber()); QCOMPARE(spy->at(3).value.toNumber(), qsreal(123)); } + delete spy; +} +/** check behaiviour of native function */ +void tst_QScriptEngineAgent::functionEntryAndExit_native2() +{ + QScriptEngine eng; + ScriptEngineSpy *spy = new ScriptEngineSpy(&eng, ~(ScriptEngineSpy::IgnoreFunctionEntry + | ScriptEngineSpy::IgnoreFunctionExit)); { QScriptValue fun = eng.newFunction(nativeFunctionCallingArg); eng.globalObject().setProperty("nativeFunctionCallingArg", fun); @@ -622,14 +738,25 @@ void tst_QScriptEngineAgent::functionEntryAndExit() QVERIFY(spy->at(5).value.isNumber()); QCOMPARE(spy->at(5).value.toNumber(), qsreal(123)); } + delete spy; +} +/** check behaiviour of native function throwing error*/ +void tst_QScriptEngineAgent::functionEntryAndExit_nativeThrowing() +{ + /* This function was changed from old backend. JSC return more Entrys / Exits, (exactly +1) + in exception creation time */ + + QScriptEngine eng; + ScriptEngineSpy *spy = new ScriptEngineSpy(&eng, ~(ScriptEngineSpy::IgnoreFunctionEntry + | ScriptEngineSpy::IgnoreFunctionExit)); { QScriptValue fun = eng.newFunction(nativeFunctionThrowingError); eng.globalObject().setProperty("nativeFunctionThrowingError", fun); spy->clear(); eng.evaluate("nativeFunctionThrowingError('ciao')"); - QCOMPARE(spy->count(), 4); + QCOMPARE(spy->count(), 6); // evaluate() entry QCOMPARE(spy->at(0).type, ScriptEngineEvent::FunctionEntry); @@ -638,20 +765,38 @@ void tst_QScriptEngineAgent::functionEntryAndExit() QCOMPARE(spy->at(1).type, ScriptEngineEvent::FunctionEntry); QCOMPARE(spy->at(1).scriptId, qint64(-1)); - // native function exit - QCOMPARE(spy->at(2).type, ScriptEngineEvent::FunctionExit); + // Exception constructor entry + QCOMPARE(spy->at(2).type, ScriptEngineEvent::FunctionEntry); QCOMPARE(spy->at(2).scriptId, qint64(-1)); - QVERIFY(spy->at(2).value.isError()); - // evaluate() exit + // Exception constructor exit QCOMPARE(spy->at(3).type, ScriptEngineEvent::FunctionExit); - QCOMPARE(spy->at(3).scriptId, spy->at(0).scriptId); + QCOMPARE(spy->at(3).scriptId, qint64(-1)); QVERIFY(spy->at(3).value.isError()); + + // native function exit + QCOMPARE(spy->at(4).type, ScriptEngineEvent::FunctionExit); + QCOMPARE(spy->at(4).scriptId, qint64(-1)); + QVERIFY(spy->at(4).value.isError()); + + // evaluate() exit + QCOMPARE(spy->at(5).type, ScriptEngineEvent::FunctionExit); + QCOMPARE(spy->at(5).scriptId, spy->at(0).scriptId); + QVERIFY(spy->at(5).value.isError()); } + delete spy; +} +/** check behaiviour of built-in function */ +void tst_QScriptEngineAgent::functionEntryAndExit_builtin() +{ + QScriptEngine eng; + ScriptEngineSpy *spy = new ScriptEngineSpy(&eng, ~(ScriptEngineSpy::IgnoreFunctionEntry + | ScriptEngineSpy::IgnoreFunctionExit)); { spy->clear(); eng.evaluate("'ciao'.toString()"); + QCOMPARE(spy->count(), 4); // evaluate() entry @@ -673,11 +818,19 @@ void tst_QScriptEngineAgent::functionEntryAndExit() QVERIFY(spy->at(3).value.isString()); QCOMPARE(spy->at(3).value.toString(), QString("ciao")); } + delete spy; +} +/** check behaiviour of object creation*/ +void tst_QScriptEngineAgent::functionEntryAndExit_objects() +{ + QScriptEngine eng; + ScriptEngineSpy *spy = new ScriptEngineSpy(&eng, ~(ScriptEngineSpy::IgnoreFunctionEntry + | ScriptEngineSpy::IgnoreFunctionExit)); { spy->clear(); eng.evaluate("Array(); Boolean(); Date(); Function(); Number(); Object(); RegExp(); String()"); - QCOMPARE(spy->count(), 20); + QCOMPARE(spy->count(), 18); // evaluate() entry QCOMPARE(spy->at(0).type, ScriptEngineEvent::FunctionEntry); @@ -713,63 +866,62 @@ void tst_QScriptEngineAgent::functionEntryAndExit() QCOMPARE(spy->at(7).type, ScriptEngineEvent::FunctionEntry); QCOMPARE(spy->at(7).scriptId, qint64(-1)); - // evaluate() entry - QCOMPARE(spy->at(8).type, ScriptEngineEvent::FunctionEntry); - QVERIFY(spy->at(8).scriptId != -1); + // Function constructor exit + QCOMPARE(spy->at(8).type, ScriptEngineEvent::FunctionExit); + QCOMPARE(spy->at(8).scriptId, qint64(-1)); + QVERIFY(spy->at(8).value.isFunction()); - // evaluate() exit - QCOMPARE(spy->at(9).type, ScriptEngineEvent::FunctionExit); - QCOMPARE(spy->at(9).scriptId, spy->at(8).scriptId); - QVERIFY(spy->at(9).value.isFunction()); + // Number constructor entry + QCOMPARE(spy->at(9).type, ScriptEngineEvent::FunctionEntry); + QCOMPARE(spy->at(9).scriptId, qint64(-1)); - // Function constructor exit + // Number constructor exit QCOMPARE(spy->at(10).type, ScriptEngineEvent::FunctionExit); QCOMPARE(spy->at(10).scriptId, qint64(-1)); - QVERIFY(spy->at(10).value.isFunction()); + QVERIFY(spy->at(10).value.isNumber()); - // Number constructor entry + // Object constructor entry QCOMPARE(spy->at(11).type, ScriptEngineEvent::FunctionEntry); QCOMPARE(spy->at(11).scriptId, qint64(-1)); - // Number constructor exit + // Object constructor exit QCOMPARE(spy->at(12).type, ScriptEngineEvent::FunctionExit); QCOMPARE(spy->at(12).scriptId, qint64(-1)); - QVERIFY(spy->at(12).value.isNumber()); + QVERIFY(spy->at(12).value.isObject()); - // Object constructor entry + // RegExp constructor entry QCOMPARE(spy->at(13).type, ScriptEngineEvent::FunctionEntry); QCOMPARE(spy->at(13).scriptId, qint64(-1)); - // Object constructor exit + // RegExp constructor exit QCOMPARE(spy->at(14).type, ScriptEngineEvent::FunctionExit); QCOMPARE(spy->at(14).scriptId, qint64(-1)); - QVERIFY(spy->at(14).value.isObject()); + QVERIFY(spy->at(14).value.isRegExp()); - // RegExp constructor entry + // String constructor entry QCOMPARE(spy->at(15).type, ScriptEngineEvent::FunctionEntry); QCOMPARE(spy->at(15).scriptId, qint64(-1)); - // RegExp constructor exit + // String constructor exit QCOMPARE(spy->at(16).type, ScriptEngineEvent::FunctionExit); QCOMPARE(spy->at(16).scriptId, qint64(-1)); - QVERIFY(spy->at(16).value.isRegExp()); - - // String constructor entry - QCOMPARE(spy->at(17).type, ScriptEngineEvent::FunctionEntry); - QCOMPARE(spy->at(17).scriptId, qint64(-1)); - - // String constructor exit - QCOMPARE(spy->at(18).type, ScriptEngineEvent::FunctionExit); - QCOMPARE(spy->at(18).scriptId, qint64(-1)); - QVERIFY(spy->at(18).value.isString()); + QVERIFY(spy->at(16).value.isString()); // evaluate() exit - QCOMPARE(spy->at(19).type, ScriptEngineEvent::FunctionExit); - QCOMPARE(spy->at(19).scriptId, spy->at(0).scriptId); - QVERIFY(spy->at(19).value.isString()); - QCOMPARE(spy->at(19).value.toString(), QString()); + QCOMPARE(spy->at(17).type, ScriptEngineEvent::FunctionExit); + QCOMPARE(spy->at(17).scriptId, spy->at(0).scriptId); + QVERIFY(spy->at(17).value.isString()); + QCOMPARE(spy->at(17).value.toString(), QString()); } + delete spy; +} +/** check behaiviour of slots*/ +void tst_QScriptEngineAgent::functionEntryAndExit_slots() +{ + QScriptEngine eng; + ScriptEngineSpy *spy = new ScriptEngineSpy(&eng, ~(ScriptEngineSpy::IgnoreFunctionEntry + | ScriptEngineSpy::IgnoreFunctionExit)); // slots { eng.globalObject().setProperty("qobj", eng.newQObject(this)); @@ -789,7 +941,15 @@ void tst_QScriptEngineAgent::functionEntryAndExit() // evaluate() exit QCOMPARE(spy->at(3).type, ScriptEngineEvent::FunctionExit); } + delete spy; +} +/** check behaiviour of property accessors*/ +void tst_QScriptEngineAgent::functionEntryAndExit_property_set() +{ + QScriptEngine eng; + ScriptEngineSpy *spy = new ScriptEngineSpy(&eng, ~(ScriptEngineSpy::IgnoreFunctionEntry + | ScriptEngineSpy::IgnoreFunctionExit)); // property accessors { eng.globalObject().setProperty("qobj", eng.newQObject(this)); @@ -810,7 +970,21 @@ void tst_QScriptEngineAgent::functionEntryAndExit() // evaluate() exit QCOMPARE(spy->at(3).type, ScriptEngineEvent::FunctionExit); QVERIFY(spy->at(3).value.strictlyEquals(spy->at(2).value)); + } + delete spy; +} +/** check behaiviour of property accessors*/ +void tst_QScriptEngineAgent::functionEntryAndExit_property_get() +{ + QScriptEngine eng; + ScriptEngineSpy *spy = new ScriptEngineSpy(&eng, ~(ScriptEngineSpy::IgnoreFunctionEntry + | ScriptEngineSpy::IgnoreFunctionExit)); + // property accessors + { + eng.globalObject().setProperty("qobj", eng.newQObject(this)); + // set + eng.evaluate("qobj.testProperty = 456"); // get spy->clear(); eng.evaluate("qobj.testProperty"); @@ -829,7 +1003,16 @@ void tst_QScriptEngineAgent::functionEntryAndExit() QCOMPARE(spy->at(3).type, ScriptEngineEvent::FunctionExit); QVERIFY(spy->at(3).value.strictlyEquals(spy->at(2).value)); } + delete spy; +} + +/** check behaiviour of calling script functions from c++*/ +void tst_QScriptEngineAgent::functionEntryAndExit_call() +{ + QScriptEngine eng; + ScriptEngineSpy *spy = new ScriptEngineSpy(&eng, ~(ScriptEngineSpy::IgnoreFunctionEntry + | ScriptEngineSpy::IgnoreFunctionExit)); // calling script functions from C++ { @@ -850,17 +1033,22 @@ void tst_QScriptEngineAgent::functionEntryAndExit() QVERIFY(spy->at(1).value.isNumber()); QCOMPARE(spy->at(1).value.toNumber(), qsreal(123)); } + delete spy; +} - for (int x = 0; x < 2; ++x) { +/** check behaiviour of native function returnning arg*/ +void tst_QScriptEngineAgent::functionEntryAndExit_functionReturn_call() +{ + QScriptEngine eng; + ScriptEngineSpy *spy = new ScriptEngineSpy(&eng, ~(ScriptEngineSpy::IgnoreFunctionEntry + | ScriptEngineSpy::IgnoreFunctionExit)); + { QScriptValue fun = eng.newFunction(nativeFunctionReturningArg); spy->clear(); QScriptValueList args; args << QScriptValue(&eng, 123); - if (x) - fun.construct(args); - else - fun.call(QScriptValue(), args); + fun.call(QScriptValue(), args); QCOMPARE(spy->count(), 2); // entry @@ -872,10 +1060,53 @@ void tst_QScriptEngineAgent::functionEntryAndExit() QCOMPARE(spy->at(1).scriptId, spy->at(0).scriptId); QVERIFY(spy->at(1).value.strictlyEquals(args.at(0))); } + delete spy; +} +void tst_QScriptEngineAgent::functionEntryAndExit_functionReturn_construct() +{ + QScriptEngine eng; + ScriptEngineSpy *spy = new ScriptEngineSpy(&eng, ~(ScriptEngineSpy::IgnoreFunctionEntry + | ScriptEngineSpy::IgnoreFunctionExit)); + { + QScriptValue fun = eng.newFunction(nativeFunctionReturningArg); + + spy->clear(); + QScriptValueList args; + args << QScriptValue(&eng, 123); + QScriptValue obj = fun.construct(args); + + QVERIFY(args.at(0).isValid()); + QVERIFY(args.at(0).isNumber()); + QVERIFY(args.at(0).toNumber() == 123); + + QCOMPARE(spy->count(), 2); + + // entry + QCOMPARE(spy->at(0).type, ScriptEngineEvent::FunctionEntry); + QVERIFY(spy->at(0).scriptId == -1); + + // exit + QCOMPARE(spy->at(1).type, ScriptEngineEvent::FunctionExit); + QCOMPARE(spy->at(1).scriptId, spy->at(0).scriptId); + + QVERIFY(spy->at(1).value.strictlyEquals(args.at(0))); + } + + delete spy; +} + +/** check behaiviour of object creation with args (?)*/ +void tst_QScriptEngineAgent::functionEntryAndExit_objectCall() +{ + QScriptEngine eng; + ScriptEngineSpy *spy = new ScriptEngineSpy(&eng, ~(ScriptEngineSpy::IgnoreFunctionEntry + | ScriptEngineSpy::IgnoreFunctionExit)); for (int x = 0; x < 2; ++x) { QScriptValue fun = eng.evaluate("Boolean"); + QVERIFY(!fun.isError()); + spy->clear(); QScriptValueList args; args << QScriptValue(&eng, true); @@ -894,20 +1125,28 @@ void tst_QScriptEngineAgent::functionEntryAndExit() QCOMPARE(spy->at(1).scriptId, spy->at(0).scriptId); QVERIFY(spy->at(1).value.equals(args.at(0))); } + delete spy; } -void tst_QScriptEngineAgent::positionChange() +void tst_QScriptEngineAgent::positionChange_1() { QScriptEngine eng; ScriptEngineSpy *spy = new ScriptEngineSpy(&eng, ~(ScriptEngineSpy::IgnorePositionChange)); { spy->clear(); eng.evaluate(";"); + QEXPECT_FAIL("","JSC do not evaluate ';' to statemant",Continue); QCOMPARE(spy->count(), 1); - QCOMPARE(spy->at(0).type, ScriptEngineEvent::PositionChange); - QVERIFY(spy->at(0).scriptId != -1); - QCOMPARE(spy->at(0).lineNumber, 1); - QCOMPARE(spy->at(0).columnNumber, 1); + if (spy->count()) { + QEXPECT_FAIL("","JSC do not evaluate ';' to statemant",Continue); + QCOMPARE(spy->at(0).type, ScriptEngineEvent::PositionChange); + QEXPECT_FAIL("","JSC do not evaluate ';' to statemant",Continue); + QVERIFY(spy->at(0).scriptId != -1); + QEXPECT_FAIL("","JSC do not evaluate ';' to statemant",Continue); + QCOMPARE(spy->at(0).lineNumber, 1); + QEXPECT_FAIL("","JSC do not evaluate ';' to statemant",Continue); + QCOMPARE(spy->at(0).columnNumber, 1); + } } { @@ -958,7 +1197,13 @@ void tst_QScriptEngineAgent::positionChange() QCOMPARE(spy->at(2).lineNumber, lineNumber + 1); QCOMPARE(spy->at(2).columnNumber, 1); } + delete spy; +} +void tst_QScriptEngineAgent::positionChange_2() +{ + QScriptEngine eng; + ScriptEngineSpy *spy = new ScriptEngineSpy(&eng, ~(ScriptEngineSpy::IgnorePositionChange)); { spy->clear(); int lineNumber = 789; @@ -1115,42 +1360,6 @@ void tst_QScriptEngineAgent::positionChange() { spy->clear(); - eng.evaluate("for (var i in { a: 10, b: 20 }) { void(i); }"); - QCOMPARE(spy->count(), 5); - - // for - QCOMPARE(spy->at(0).type, ScriptEngineEvent::PositionChange); - QVERIFY(spy->at(0).scriptId != -1); - QCOMPARE(spy->at(0).lineNumber, 1); - QCOMPARE(spy->at(0).columnNumber, 1); - - // a: 10 - QCOMPARE(spy->at(1).type, ScriptEngineEvent::PositionChange); - QCOMPARE(spy->at(1).scriptId, spy->at(0).scriptId); - QCOMPARE(spy->at(1).lineNumber, 1); - QCOMPARE(spy->at(1).columnNumber, 20); - - // b: 20 - QCOMPARE(spy->at(2).type, ScriptEngineEvent::PositionChange); - QCOMPARE(spy->at(2).scriptId, spy->at(0).scriptId); - QCOMPARE(spy->at(2).lineNumber, 1); - QCOMPARE(spy->at(2).columnNumber, 27); - - // void(i) - QCOMPARE(spy->at(3).type, ScriptEngineEvent::PositionChange); - QCOMPARE(spy->at(3).scriptId, spy->at(0).scriptId); - QCOMPARE(spy->at(3).lineNumber, 1); - QCOMPARE(spy->at(3).columnNumber, 35); - - // void(i) - QCOMPARE(spy->at(4).type, ScriptEngineEvent::PositionChange); - QCOMPARE(spy->at(4).scriptId, spy->at(0).scriptId); - QCOMPARE(spy->at(4).lineNumber, 1); - QCOMPARE(spy->at(4).columnNumber, 35); - } - - { - spy->clear(); eng.evaluate("for ( ; ; ) { break; }"); QCOMPARE(spy->count(), 2); @@ -1271,6 +1480,30 @@ void tst_QScriptEngineAgent::positionChange() { spy->clear(); + eng.evaluate("try { throw 1; } catch(e) { i = e; } finally { i = 2; }"); + QCOMPARE(spy->count(), 3); + + // throw 1 + QCOMPARE(spy->at(0).type, ScriptEngineEvent::PositionChange); + QVERIFY(spy->at(0).scriptId != -1); + QCOMPARE(spy->at(0).lineNumber, 1); + QCOMPARE(spy->at(0).columnNumber, 7); + + // i = e + QCOMPARE(spy->at(1).type, ScriptEngineEvent::PositionChange); + QCOMPARE(spy->at(1).scriptId, spy->at(0).scriptId); + QCOMPARE(spy->at(1).lineNumber, 1); + QCOMPARE(spy->at(1).columnNumber, 29); + + // i = 2 + QCOMPARE(spy->at(2).type, ScriptEngineEvent::PositionChange); + QCOMPARE(spy->at(2).scriptId, spy->at(0).scriptId); + QCOMPARE(spy->at(2).lineNumber, 1); + QCOMPARE(spy->at(2).columnNumber, 48); + } + + { + spy->clear(); eng.evaluate("try { i = 1; } catch(e) { i = 2; } finally { i = 3; }"); QCOMPARE(spy->count(), 2); @@ -1288,28 +1521,26 @@ void tst_QScriptEngineAgent::positionChange() } { + QEXPECT_FAIL("","I believe the test is wrong. Expressions shouldn't call positionChange " + "because statement '1+2' will call it at least twice, why debugger have to " + "stop here so many times?", Abort); spy->clear(); - eng.evaluate("try { throw 1; } catch(e) { i = e; } finally { i = 2; }"); - QCOMPARE(spy->count(), 3); + eng.evaluate("c = {a: 10, b: 20}"); + QCOMPARE(spy->count(), 2); - // throw 1 + // a: 10 QCOMPARE(spy->at(0).type, ScriptEngineEvent::PositionChange); QVERIFY(spy->at(0).scriptId != -1); QCOMPARE(spy->at(0).lineNumber, 1); - QCOMPARE(spy->at(0).columnNumber, 7); + QCOMPARE(spy->at(0).columnNumber, 1); - // i = e + // b: 20 QCOMPARE(spy->at(1).type, ScriptEngineEvent::PositionChange); QCOMPARE(spy->at(1).scriptId, spy->at(0).scriptId); QCOMPARE(spy->at(1).lineNumber, 1); - QCOMPARE(spy->at(1).columnNumber, 29); - - // i = 2 - QCOMPARE(spy->at(2).type, ScriptEngineEvent::PositionChange); - QCOMPARE(spy->at(2).scriptId, spy->at(0).scriptId); - QCOMPARE(spy->at(2).lineNumber, 1); - QCOMPARE(spy->at(2).columnNumber, 48); + QCOMPARE(spy->at(1).columnNumber, 20); } + delete spy; } void tst_QScriptEngineAgent::exceptionThrowAndCatch() @@ -1359,11 +1590,10 @@ void tst_QScriptEngineAgent::exceptionThrowAndCatch() } } -void tst_QScriptEngineAgent::eventOrder() +void tst_QScriptEngineAgent::eventOrder_assigment() { QScriptEngine eng; ScriptEngineSpy *spy = new ScriptEngineSpy(&eng); - { spy->clear(); eng.evaluate("i = 3; i = 5"); @@ -1386,7 +1616,13 @@ void tst_QScriptEngineAgent::eventOrder() QCOMPARE(spy->at(5).type, ScriptEngineEvent::ScriptUnload); QCOMPARE(spy->at(5).scriptId, spy->at(0).scriptId); } + delete spy; +} +void tst_QScriptEngineAgent::eventOrder_functionDefinition() +{ + QScriptEngine eng; + ScriptEngineSpy *spy = new ScriptEngineSpy(&eng); { spy->clear(); eng.evaluate("function foo(arg) { void(arg); }"); @@ -1429,7 +1665,13 @@ void tst_QScriptEngineAgent::eventOrder() eng.evaluate("foo = null"); eng.collectGarbage(); } + delete spy; +} +void tst_QScriptEngineAgent::eventOrder_throwError() +{ + QScriptEngine eng; + ScriptEngineSpy *spy = new ScriptEngineSpy(&eng); { spy->clear(); eng.evaluate("throw new Error('ciao')"); @@ -1456,7 +1698,13 @@ void tst_QScriptEngineAgent::eventOrder() // unload QCOMPARE(spy->at(9).type, ScriptEngineEvent::ScriptUnload); } + delete spy; +} +void tst_QScriptEngineAgent::eventOrder_throwAndCatch() +{ + QScriptEngine eng; + ScriptEngineSpy *spy = new ScriptEngineSpy(&eng); { spy->clear(); eng.evaluate("try { throw new Error('ciao') } catch (e) { void(e); }"); @@ -1490,7 +1738,13 @@ void tst_QScriptEngineAgent::eventOrder() // unload QCOMPARE(spy->at(11).type, ScriptEngineEvent::ScriptUnload); } + delete spy; +} +void tst_QScriptEngineAgent::eventOrder_functions() +{ + QScriptEngine eng; + ScriptEngineSpy *spy = new ScriptEngineSpy(&eng); { spy->clear(); eng.evaluate("function foo(arg) { return bar(arg); }"); @@ -1544,6 +1798,7 @@ void tst_QScriptEngineAgent::eventOrder() // redefine bar() eng.evaluate("function bar(arg) { throw new Error(arg); }"); + eng.collectGarbage(); QCOMPARE(spy->count(), 25); QCOMPARE(spy->at(21).type, ScriptEngineEvent::ScriptLoad); QCOMPARE(spy->at(22).type, ScriptEngineEvent::FunctionEntry); @@ -1552,7 +1807,8 @@ void tst_QScriptEngineAgent::eventOrder() QCOMPARE(spy->at(24).scriptId, spy->at(3).scriptId); eng.evaluate("foo('ciao')"); - QCOMPARE(spy->count(), 45); + + //QCOMPARE(spy->count(), 45); // load QCOMPARE(spy->at(25).type, ScriptEngineEvent::ScriptLoad); @@ -1610,7 +1866,13 @@ void tst_QScriptEngineAgent::eventOrder() QCOMPARE(spy->at(44).type, ScriptEngineEvent::ScriptUnload); QCOMPARE(spy->at(44).scriptId, spy->at(25).scriptId); } + delete spy; +} +void tst_QScriptEngineAgent::eventOrder_throwCatchFinally() +{ + QScriptEngine eng; + ScriptEngineSpy *spy = new ScriptEngineSpy(&eng); { spy->clear(); eng.evaluate("try { throw 1; } catch(e) { i = e; } finally { i = 2; }"); @@ -1635,11 +1897,17 @@ void tst_QScriptEngineAgent::eventOrder() // unload QCOMPARE(spy->at(8).type, ScriptEngineEvent::ScriptUnload); } + delete spy; +} +void tst_QScriptEngineAgent::eventOrder_signalsHandling() +{ + QScriptEngine eng; + ScriptEngineSpy *spy = new ScriptEngineSpy(&eng); // signal handling { spy->clear(); - QScriptValue fun = eng.evaluate("function(arg) { throw Error(arg); }"); + QScriptValue fun = eng.evaluate("(function(arg) { throw Error(arg); })"); QVERIFY(fun.isFunction()); QCOMPARE(spy->count(), 4); QCOMPARE(spy->at(0).type, ScriptEngineEvent::ScriptLoad); @@ -1658,7 +1926,7 @@ void tst_QScriptEngineAgent::eventOrder() // anonymous function entry QCOMPARE(spy->at(5).type, ScriptEngineEvent::FunctionEntry); QCOMPARE(spy->at(5).scriptId, spy->at(0).scriptId); - // throw + // throw statement QCOMPARE(spy->at(6).type, ScriptEngineEvent::PositionChange); QCOMPARE(spy->at(6).scriptId, spy->at(0).scriptId); // new context @@ -1683,6 +1951,7 @@ void tst_QScriptEngineAgent::eventOrder() // restore context QCOMPARE(spy->at(13).type, ScriptEngineEvent::ContextPop); } + delete spy; } class DoubleAgent : public ScriptEngineSpy @@ -1707,32 +1976,45 @@ void tst_QScriptEngineAgent::recursiveObserve() eng.evaluate("3 + 4", "foo.qs", 123); QCOMPARE(spy->count(), 10); - // load "3 + 4" - QCOMPARE(spy->at(0).type, ScriptEngineEvent::ScriptLoad); + + int i = 0; + // load "3 + 4" + QCOMPARE(spy->at(i).type, ScriptEngineEvent::ScriptLoad); + i++; // evaluate() entry - QCOMPARE(spy->at(1).type, ScriptEngineEvent::FunctionEntry); + QCOMPARE(spy->at(i).type, ScriptEngineEvent::FunctionEntry); + i++; // load "1 + 2" - QCOMPARE(spy->at(2).type, ScriptEngineEvent::ScriptLoad); + QCOMPARE(spy->at(i).type, ScriptEngineEvent::ScriptLoad); + i++; // evaluate() entry - QCOMPARE(spy->at(3).type, ScriptEngineEvent::FunctionEntry); + QCOMPARE(spy->at(i).type, ScriptEngineEvent::FunctionEntry); + i++; // 1 + 2 - QCOMPARE(spy->at(4).type, ScriptEngineEvent::PositionChange); - QCOMPARE(spy->at(4).scriptId, spy->at(2).scriptId); + QCOMPARE(spy->at(i).type, ScriptEngineEvent::PositionChange); + QCOMPARE(spy->at(i).scriptId, spy->at(2).scriptId); + i++; // evaluate() exit - QCOMPARE(spy->at(5).type, ScriptEngineEvent::FunctionExit); + QCOMPARE(spy->at(i).type, ScriptEngineEvent::FunctionExit); + i++; // unload "1 + 2" - QCOMPARE(spy->at(6).type, ScriptEngineEvent::ScriptUnload); - QCOMPARE(spy->at(6).scriptId, spy->at(2).scriptId); + QCOMPARE(spy->at(i).type, ScriptEngineEvent::ScriptUnload); + QCOMPARE(spy->at(i).scriptId, spy->at(2).scriptId); + i++; // 3 + 4 - QCOMPARE(spy->at(7).type, ScriptEngineEvent::PositionChange); - QCOMPARE(spy->at(7).scriptId, spy->at(0).scriptId); + QCOMPARE(spy->at(i).type, ScriptEngineEvent::PositionChange); + QCOMPARE(spy->at(i).scriptId, spy->at(0).scriptId); + i++; // evaluate() exit - QCOMPARE(spy->at(8).type, ScriptEngineEvent::FunctionExit); + QCOMPARE(spy->at(i).type, ScriptEngineEvent::FunctionExit); + i++; // unload "3 + 4" - QCOMPARE(spy->at(9).type, ScriptEngineEvent::ScriptUnload); - QCOMPARE(spy->at(9).scriptId, spy->at(0).scriptId); + QCOMPARE(spy->at(i).type, ScriptEngineEvent::ScriptUnload); + QCOMPARE(spy->at(i).scriptId, spy->at(0).scriptId); } + +/** When second agent is attached to Engine the first one should be deatached */ void tst_QScriptEngineAgent::multipleAgents() { QScriptEngine eng; @@ -1755,31 +2037,56 @@ void tst_QScriptEngineAgent::multipleAgents() void tst_QScriptEngineAgent::syntaxError() { + /* This test was changed. Old backend didn't generate events in exception objects creation time + JSC does */ QScriptEngine eng; ScriptEngineSpy *spy = new ScriptEngineSpy(&eng); { + int i = 0; spy->clear(); eng.evaluate("{"); - QCOMPARE(spy->count(), 5); + + QCOMPARE(spy->count(), 9); - QCOMPARE(spy->at(0).type, ScriptEngineEvent::ScriptLoad); - QVERIFY(spy->at(0).scriptId != -1); - QCOMPARE(spy->at(1).type, ScriptEngineEvent::FunctionEntry); - QCOMPARE(spy->at(1).scriptId, spy->at(0).scriptId); - QCOMPARE(spy->at(2).type, ScriptEngineEvent::ExceptionThrow); - QCOMPARE(spy->at(2).scriptId, spy->at(0).scriptId); - QVERIFY(!spy->at(2).hasExceptionHandler); - QVERIFY(spy->at(2).value.isError()); - QCOMPARE(spy->at(2).value.toString(), QString("SyntaxError: Expected `}'")); - QCOMPARE(spy->at(2).scriptId, spy->at(0).scriptId); - QCOMPARE(spy->at(3).type, ScriptEngineEvent::FunctionExit); - QCOMPARE(spy->at(3).scriptId, spy->at(0).scriptId); - QCOMPARE(spy->at(4).type, ScriptEngineEvent::ScriptUnload); - QCOMPARE(spy->at(4).scriptId, spy->at(0).scriptId); + QCOMPARE(spy->at(i).type, ScriptEngineEvent::ScriptLoad); + QVERIFY(spy->at(i).scriptId != -1); + i = 1; + QCOMPARE(spy->at(i).type, ScriptEngineEvent::FunctionEntry); + QCOMPARE(spy->at(i).scriptId, spy->at(0).scriptId); + + //create exception + + i = 2; + QCOMPARE(spy->at(i).type, ScriptEngineEvent::ContextPush); + QVERIFY(spy->at(i).scriptId == -1); + i = 3; + QCOMPARE(spy->at(i).type, ScriptEngineEvent::FunctionEntry); + QVERIFY(spy->at(i).scriptId == -1); + i = 4; + QCOMPARE(spy->at(i).type, ScriptEngineEvent::FunctionExit); + QVERIFY(spy->at(i).scriptId == -1); + i = 5; + QCOMPARE(spy->at(i).type, ScriptEngineEvent::ContextPop); + QVERIFY(spy->at(i).scriptId == -1); + i = 6; + QCOMPARE(spy->at(i).type, ScriptEngineEvent::ExceptionThrow); + QCOMPARE(spy->at(i).scriptId, spy->at(0).scriptId); + QVERIFY(!spy->at(i).hasExceptionHandler); + QVERIFY(spy->at(i).value.isError()); + QEXPECT_FAIL("","There are other messages in JSC",Continue); + QCOMPARE(spy->at(i).value.toString(), QString("SyntaxError: Expected `}'")); + QCOMPARE(spy->at(i).scriptId, spy->at(0).scriptId); + i = 7; + //exit script + QCOMPARE(spy->at(i).type, ScriptEngineEvent::FunctionExit); + QCOMPARE(spy->at(i).scriptId, spy->at(0).scriptId); + i = 8; + QCOMPARE(spy->at(i).type, ScriptEngineEvent::ScriptUnload); + QCOMPARE(spy->at(i).scriptId, spy->at(0).scriptId); } } -void tst_QScriptEngineAgent::extension() +void tst_QScriptEngineAgent::extension_invoctaion() { QScriptEngine eng; ScriptEngineSpy *spy = new ScriptEngineSpy(&eng, ~(ScriptEngineSpy::IgnoreDebuggerInvocationRequest @@ -1799,9 +2106,19 @@ void tst_QScriptEngineAgent::extension() QCOMPARE(spy->at(1).lineNumber, lineNumber); QCOMPARE(spy->at(1).columnNumber, 1); + QEXPECT_FAIL("","In JSC Eval('debugger') returns undefined",Abort); QVERIFY(ret.isString()); QCOMPARE(ret.toString(), QString::fromLatin1("extension(DebuggerInvocationRequest)")); } + delete spy; +} + +void tst_QScriptEngineAgent::extension() +{ + QScriptEngine eng; + ScriptEngineSpy *spy = new ScriptEngineSpy(&eng, ~(ScriptEngineSpy::IgnoreDebuggerInvocationRequest + | ScriptEngineSpy::IgnoreScriptLoad)); + { spy->clear(); spy->enableIgnoreFlags(ScriptEngineSpy::IgnoreDebuggerInvocationRequest); @@ -1810,9 +2127,32 @@ void tst_QScriptEngineAgent::extension() QCOMPARE(spy->count(), 1); QCOMPARE(spy->at(0).type, ScriptEngineEvent::ScriptLoad); - QVERIFY(ret.isUndefined()); } + delete spy; +} + +class TestIsEvaluatingAgent : public QScriptEngineAgent +{ +public: + TestIsEvaluatingAgent(QScriptEngine *engine) + : QScriptEngineAgent(engine), wasEvaluating(false) + { engine->setAgent(this); } + bool supportsExtension(Extension ext) const + { return ext == DebuggerInvocationRequest; } + QVariant extension(Extension, const QVariant &) + { wasEvaluating = engine()->isEvaluating(); return QVariant(); } + + bool wasEvaluating; +}; + +void tst_QScriptEngineAgent::isEvaluatingInExtension() +{ + QScriptEngine eng; + TestIsEvaluatingAgent *spy = new TestIsEvaluatingAgent(&eng); + QVERIFY(!spy->wasEvaluating); + eng.evaluate("debugger"); + QVERIFY(spy->wasEvaluating); } QTEST_MAIN(tst_QScriptEngineAgent) diff --git a/tests/auto/qscriptenginedebugger/tst_qscriptenginedebugger.cpp b/tests/auto/qscriptenginedebugger/tst_qscriptenginedebugger.cpp index 356e683..5cf27d3 100644 --- a/tests/auto/qscriptenginedebugger/tst_qscriptenginedebugger.cpp +++ b/tests/auto/qscriptenginedebugger/tst_qscriptenginedebugger.cpp @@ -479,7 +479,7 @@ void tst_QScriptEngineDebugger::consoleCommands() outputEdit->clear(); executeConsoleCommand(inputEdit, outputEdit, ".backtrace"); - QCOMPARE(outputEdit->toPlainText(), QString::fromLatin1("qsdb> .backtrace\n#0 <global>()@:-1")); + QCOMPARE(outputEdit->toPlainText(), QString::fromLatin1("qsdb> .backtrace\n#0 <global>() at -1")); outputEdit->clear(); executeConsoleCommand(inputEdit, outputEdit, ".down"); @@ -491,7 +491,7 @@ void tst_QScriptEngineDebugger::consoleCommands() outputEdit->clear(); executeConsoleCommand(inputEdit, outputEdit, ".frame"); - QCOMPARE(outputEdit->toPlainText(), QString::fromLatin1("qsdb> .frame\n#0 <global>()@:-1")); + QCOMPARE(outputEdit->toPlainText(), QString::fromLatin1("qsdb> .frame\n#0 <global>() at -1")); outputEdit->clear(); executeConsoleCommand(inputEdit, outputEdit, ".break foo.qs:789"); @@ -745,6 +745,9 @@ private: void tst_QScriptEngineDebugger::multithreadedDebugging() { +#ifdef Q_OS_WINCE + QSKIP("This tests uses too much memory for Windows CE", SkipAll); +#endif ScriptEvaluator eval; QThread thread; eval.moveToThread(&thread); diff --git a/tests/auto/qscriptextqobject/qscriptextqobject.pro b/tests/auto/qscriptextqobject/qscriptextqobject.pro index 87ab1b7..9da7f47 100644 --- a/tests/auto/qscriptextqobject/qscriptextqobject.pro +++ b/tests/auto/qscriptextqobject/qscriptextqobject.pro @@ -2,4 +2,6 @@ load(qttest_p4) QT = core gui script SOURCES += tst_qscriptextqobject.cpp - +symbian: { + TARGET.EPOCHEAPSIZE="0x100000 0x1000000 // Min 1Mb, max 16Mb" +} diff --git a/tests/auto/qscriptextqobject/tst_qscriptextqobject.cpp b/tests/auto/qscriptextqobject/tst_qscriptextqobject.cpp index 58a8f9b..1a5788e 100644 --- a/tests/auto/qscriptextqobject/tst_qscriptextqobject.cpp +++ b/tests/auto/qscriptextqobject/tst_qscriptextqobject.cpp @@ -54,6 +54,10 @@ struct CustomType { +#if defined (Q_CC_NOKIAX86) + // Compiler crash workaround + CustomType() {} +#endif QString string; }; Q_DECLARE_METATYPE(CustomType) @@ -494,6 +498,7 @@ private slots: void getSetChildren(); void callQtInvokable(); void connectAndDisconnect(); + void connectAndDisconnectWithBadArgs(); void cppConnectAndDisconnect(); void classEnums(); void classConstructor(); @@ -837,14 +842,14 @@ void tst_QScriptExtQObject::getSetStaticProperty() m_engine->globalObject().setProperty("brushPointer", QScriptValue()); } - // try to install custom property getter+setter + // install custom property getter+setter { QScriptValue mobj = m_engine->globalObject().property("myObject"); - QTest::ignoreMessage(QtWarningMsg, "QScriptValue::setProperty() failed: " - "cannot set getter or setter of native property " - "`intProperty'"); mobj.setProperty("intProperty", m_engine->newFunction(getSetProperty), QScriptValue::PropertyGetter | QScriptValue::PropertySetter); + QVERIFY(mobj.property("intProperty").toInt32() != 321); + mobj.setProperty("intProperty", 321); + QCOMPARE(mobj.property("intProperty").toInt32(), 321); } // method properties are persistent @@ -853,7 +858,7 @@ void tst_QScriptExtQObject::getSetStaticProperty() QVERIFY(slot.isFunction()); QScriptValue sameSlot = m_engine->evaluate("myObject.mySlot"); QVERIFY(sameSlot.strictlyEquals(slot)); - sameSlot = m_engine->evaluate("myObject['mySlot()']"); + sameSlot = m_engine->evaluate("myObject[mySlot()]"); QEXPECT_FAIL("", "Signature-based method lookup creates new function wrapper object", Continue); QVERIFY(sameSlot.strictlyEquals(slot)); } @@ -896,6 +901,8 @@ void tst_QScriptExtQObject::getSetDynamicProperty() void tst_QScriptExtQObject::getSetChildren() { + QScriptValue mobj = m_engine->evaluate("myObject"); + // initially the object does not have the child QCOMPARE(m_engine->evaluate("myObject.hasOwnProperty('child')") .strictlyEquals(QScriptValue(m_engine, false)), true); @@ -906,7 +913,6 @@ void tst_QScriptExtQObject::getSetChildren() QCOMPARE(m_engine->evaluate("myObject.hasOwnProperty('child')") .strictlyEquals(QScriptValue(m_engine, true)), true); - QScriptValue mobj = m_engine->evaluate("myObject"); QVERIFY(mobj.propertyFlags("child") & QScriptValue::ReadOnly); QVERIFY(mobj.propertyFlags("child") & QScriptValue::Undeletable); QVERIFY(mobj.propertyFlags("child") & QScriptValue::SkipInEnumeration); @@ -1453,12 +1459,12 @@ void tst_QScriptExtQObject::callQtInvokable() m_myObject->resetQtFunctionInvoked(); QScriptValue ret = m_engine->evaluate("new myObject(123)"); QVERIFY(ret.isError()); - QCOMPARE(ret.toString(), QString::fromLatin1("TypeError: myObject is not a constructor")); + QCOMPARE(ret.toString(), QString::fromLatin1("TypeError: Result of expression 'myObject' [MyQObject(name = \"\")] is not a constructor.")); } { m_myObject->resetQtFunctionInvoked(); QScriptValue ret = m_engine->evaluate("myObject(123)"); - QCOMPARE(ret.toString(), QString::fromLatin1("TypeError: myObject is not a function")); + QCOMPARE(ret.toString(), QString::fromLatin1("TypeError: Result of expression 'myObject' [MyQObject(name = \"\")] is not a function.")); } // task 233624 @@ -1490,7 +1496,7 @@ void tst_QScriptExtQObject::connectAndDisconnect() // connect(function) QCOMPARE(m_engine->evaluate("myObject.mySignal.connect(123)").isError(), true); - m_engine->evaluate("myHandler = function() { global.gotSignal = true; global.signalArgs = arguments; global.slotThisObject = this; global.signalSender = __qt_sender__; }"); + m_engine->evaluate("myHandler = function() { global.gotSignal = true; global.signalArgs = arguments; global.slotThisObject = this; }"); m_myObject->clearConnectedSignal(); QVERIFY(m_engine->evaluate("myObject.mySignal.connect(myHandler)").isUndefined()); @@ -1500,7 +1506,6 @@ void tst_QScriptExtQObject::connectAndDisconnect() m_engine->evaluate("myObject.mySignal()"); QCOMPARE(m_engine->evaluate("gotSignal").toBoolean(), true); QCOMPARE(m_engine->evaluate("signalArgs.length").toNumber(), 0.0); - QCOMPARE(m_engine->evaluate("signalSender").toQObject(), (QObject *)m_myObject); QVERIFY(m_engine->evaluate("slotThisObject").strictlyEquals(m_engine->globalObject())); m_engine->evaluate("gotSignal = false"); @@ -1523,6 +1528,7 @@ void tst_QScriptExtQObject::connectAndDisconnect() QVERIFY(m_engine->evaluate("myObject.mySignal.disconnect(myHandler)").isError()); QVERIFY(m_engine->evaluate("myObject.mySignal2.connect(myHandler)").isUndefined()); + QVERIFY(m_engine->evaluate("myObject.mySignalWithIntArg.disconnect(myHandler)").isUndefined()); m_engine->evaluate("gotSignal = false"); m_myObject->emitMySignal2(false); @@ -1600,6 +1606,7 @@ void tst_QScriptExtQObject::connectAndDisconnect() m_myObject->emitMySignalWithVariantArg(123); QCOMPARE(m_engine->evaluate("gotSignal").toBoolean(), true); QCOMPARE(m_engine->evaluate("signalArgs.length").toNumber(), 1.0); + QVERIFY(m_engine->evaluate("signalArgs[0]").isNumber()); QCOMPARE(m_engine->evaluate("signalArgs[0]").toNumber(), 123.0); QVERIFY(m_engine->evaluate("myObject.mySignalWithVariantArg.disconnect(myHandler)").isUndefined()); @@ -1631,7 +1638,6 @@ void tst_QScriptExtQObject::connectAndDisconnect() QCOMPARE(m_engine->evaluate("gotSignal").toBoolean(), true); QCOMPARE(m_engine->evaluate("signalArgs.length").toNumber(), 0.0); QVERIFY(m_engine->evaluate("slotThisObject").strictlyEquals(m_engine->evaluate("otherObject"))); - QVERIFY(m_engine->evaluate("signalSender").strictlyEquals(m_engine->evaluate("myObject"))); QCOMPARE(m_engine->evaluate("slotThisObject").property("name").toString(), QLatin1String("foo")); QVERIFY(m_engine->evaluate("myObject.mySignal.disconnect(otherObject, myHandler)").isUndefined()); @@ -1642,7 +1648,6 @@ void tst_QScriptExtQObject::connectAndDisconnect() QCOMPARE(m_engine->evaluate("gotSignal").toBoolean(), true); QCOMPARE(m_engine->evaluate("signalArgs.length").toNumber(), 1.0); QVERIFY(m_engine->evaluate("slotThisObject").strictlyEquals(m_engine->evaluate("yetAnotherObject"))); - QVERIFY(m_engine->evaluate("signalSender").strictlyEquals(m_engine->evaluate("myObject"))); QCOMPARE(m_engine->evaluate("slotThisObject").property("name").toString(), QLatin1String("bar")); QVERIFY(m_engine->evaluate("myObject.mySignal2.disconnect(yetAnotherObject, myHandler)").isUndefined()); @@ -1652,7 +1657,6 @@ void tst_QScriptExtQObject::connectAndDisconnect() QCOMPARE(m_engine->evaluate("gotSignal").toBoolean(), true); QCOMPARE(m_engine->evaluate("signalArgs.length").toNumber(), 1.0); QCOMPARE(m_engine->evaluate("slotThisObject").toQObject(), (QObject *)m_myObject); - QVERIFY(m_engine->evaluate("signalSender").strictlyEquals(m_engine->evaluate("myObject"))); QVERIFY(m_engine->evaluate("myObject.mySignal2.disconnect(myObject, myHandler)").isUndefined()); // connect(obj, string) @@ -1712,7 +1716,20 @@ void tst_QScriptExtQObject::connectAndDisconnect() QCOMPARE(m_myObject->qtFunctionActuals().at(0).toInt(), 456); QVERIFY(m_engine->evaluate("myObject.mySignalWithIntArg.disconnect(myObject['myOverloadedSlot(int)'])").isUndefined()); - // erroneous input + // when the wrapper dies, the connection stays alive + QVERIFY(m_engine->evaluate("myObject.mySignal.connect(myObject.mySlot)").isUndefined()); + m_myObject->resetQtFunctionInvoked(); + m_myObject->emitMySignal(); + QCOMPARE(m_myObject->qtFunctionInvoked(), 20); + m_engine->evaluate("myObject = null"); + m_engine->collectGarbage(); + m_myObject->resetQtFunctionInvoked(); + m_myObject->emitMySignal(); + QCOMPARE(m_myObject->qtFunctionInvoked(), 20); +} + +void tst_QScriptExtQObject::connectAndDisconnectWithBadArgs() +{ { QScriptValue ret = m_engine->evaluate("(function() { }).connect()"); QVERIFY(ret.isError()); @@ -1796,17 +1813,6 @@ void tst_QScriptExtQObject::connectAndDisconnect() QVERIFY(ret.isError()); QCOMPARE(ret.toString(), QLatin1String("Error: Function.prototype.disconnect: failed to disconnect from MyQObject::mySignal()")); } - - // when the wrapper dies, the connection stays alive - QVERIFY(m_engine->evaluate("myObject.mySignal.connect(myObject.mySlot)").isUndefined()); - m_myObject->resetQtFunctionInvoked(); - m_myObject->emitMySignal(); - QCOMPARE(m_myObject->qtFunctionInvoked(), 20); - m_engine->evaluate("myObject = null"); - m_engine->collectGarbage(); - m_myObject->resetQtFunctionInvoked(); - m_myObject->emitMySignal(); - QCOMPARE(m_myObject->qtFunctionInvoked(), 20); } void tst_QScriptExtQObject::cppConnectAndDisconnect() @@ -1882,7 +1888,8 @@ void tst_QScriptExtQObject::cppConnectAndDisconnect() // make sure we don't crash when engine is deleted { QScriptEngine *eng2 = new QScriptEngine; - QScriptValue fun2 = eng2->evaluate("function(text) { signalObject = this; signalArg = text; }"); + QScriptValue fun2 = eng2->evaluate("(function(text) { signalObject = this; signalArg = text; })"); + QVERIFY(fun2.isFunction()); QVERIFY(qScriptConnect(&edit, SIGNAL(textChanged(const QString &)), QScriptValue(), fun2)); delete eng2; edit.setText("ciao"); @@ -1905,7 +1912,8 @@ void tst_QScriptExtQObject::cppConnectAndDisconnect() this, SLOT(onSignalHandlerException(QScriptValue))); eng.globalObject().setProperty("edit", eng.newQObject(&edit)); - QScriptValue fun = eng.evaluate("function() { nonExistingFunction(); }"); + QScriptValue fun = eng.evaluate("(function() { nonExistingFunction(); })"); + QVERIFY(fun.isFunction()); QVERIFY(qScriptConnect(&edit, SIGNAL(textChanged(const QString &)), QScriptValue(), fun)); m_signalHandlerException = QScriptValue(); @@ -2261,7 +2269,7 @@ void tst_QScriptExtQObject::findChild() QCOMPARE(result.isNull(), true); } - { + { QScriptValue result = m_engine->evaluate("myObject.findChild('myChildObject')"); QCOMPARE(result.isQObject(), true); QCOMPARE(result.toQObject(), child); @@ -2337,6 +2345,35 @@ void tst_QScriptExtQObject::findChildren() QVERIFY(count == 0); } + // matchall regexp + { + QScriptValue result = m_engine->evaluate("myObject.findChildren(/.*/)"); + QVERIFY(result.isArray()); + int count = 3; + QCOMPARE(result.property("length").toInt32(), count); + for (int i = 0; i < 3; ++i) { + QObject *o = result.property(i).toQObject(); + if (o == namelessChild || o == child || o == anotherChild) + --count; + } + QVERIFY(count == 0); + } + + // matchall regexp my* + { + QScriptValue result = m_engine->evaluate("myObject.findChildren(new RegExp(\"^my.*\"))"); + QCOMPARE(result.isArray(), true); + QCOMPARE(result.property(QLatin1String("length")).toNumber(), 2.0); + QObject *o1 = result.property(QLatin1String("0")).toQObject(); + QObject *o2 = result.property(QLatin1String("1")).toQObject(); + if (o1 != child) { + QCOMPARE(o1, anotherChild); + QCOMPARE(o2, child); + } else { + QCOMPARE(o1, child); + QCOMPARE(o2, anotherChild); + } + } delete anotherChild; delete namelessChild; delete child; @@ -2805,13 +2842,6 @@ void tst_QScriptExtQObject::objectDeleted() QVERIFY(!ret.isValid()); } - // myInvokable is stored in member table (since we've accessed it before deletion) - QVERIFY(v.property("myInvokable").isFunction()); - { - QScriptValue ret = v.property("myInvokable").call(v); - QVERIFY(ret.isError()); - QCOMPARE(ret.toString(), QLatin1String("Error: cannot call function of deleted QObject")); - } // myInvokableWithIntArg is not stored in member table (since we've not accessed it) { QScriptValue ret = v.property("myInvokableWithIntArg"); @@ -2824,7 +2854,7 @@ void tst_QScriptExtQObject::objectDeleted() { QScriptValue ret = eng.evaluate("o()"); QVERIFY(ret.isError()); - QCOMPARE(ret.toString(), QLatin1String("TypeError: o is not a function")); + QCOMPARE(ret.toString(), QLatin1String("TypeError: Result of expression 'o' [] is not a function.")); } { QScriptValue ret = eng.evaluate("o.objectName"); @@ -2834,7 +2864,7 @@ void tst_QScriptExtQObject::objectDeleted() { QScriptValue ret = eng.evaluate("o.myInvokable()"); QVERIFY(ret.isError()); - QCOMPARE(ret.toString(), QLatin1String("Error: cannot call function of deleted QObject")); + QCOMPARE(ret.toString(), QLatin1String("Error: cannot access member `myInvokable' of deleted QObject")); } { QScriptValue ret = eng.evaluate("o.myInvokableWithIntArg(10)"); diff --git a/tests/auto/qscriptjstestsuite/qscriptjstestsuite.pro b/tests/auto/qscriptjstestsuite/qscriptjstestsuite.pro index f6a6aeb..06b861e 100644 --- a/tests/auto/qscriptjstestsuite/qscriptjstestsuite.pro +++ b/tests/auto/qscriptjstestsuite/qscriptjstestsuite.pro @@ -1,9 +1,12 @@ load(qttest_p4) QT = core script SOURCES += tst_qscriptjstestsuite.cpp -DEFINES += SRCDIR=\\\"$$PWD\\\" - -wince*: { +symbian { + TARGET.EPOCHEAPSIZE = 0x020000 0xA00000 +} else { + DEFINES += SRCDIR=\\\"$$PWD\\\" +} +wince*|symbian*: { testFiles.sources = tests testFiles.path = . DEPLOYMENT += testFiles diff --git a/tests/auto/qscriptjstestsuite/tst_qscriptjstestsuite.cpp b/tests/auto/qscriptjstestsuite/tst_qscriptjstestsuite.cpp index 2e408b4..f77738f 100644 --- a/tests/auto/qscriptjstestsuite/tst_qscriptjstestsuite.cpp +++ b/tests/auto/qscriptjstestsuite/tst_qscriptjstestsuite.cpp @@ -44,6 +44,10 @@ #include <QtScript> +#if defined(Q_OS_SYMBIAN) +# define SRCDIR "" +#endif + //TESTED_CLASS= //TESTED_FILES= @@ -409,8 +413,6 @@ tst_Suite::tst_Suite() addExpectedFailure("ecma/String/15.5.4.12-4.js", "var s = new String( String.fromCharCode(1117) ); s.toUpperCase().charCodeAt(0)", fromCharCodeMessage); addExpectedFailure("ecma/String/15.5.4.12-5.js", "var s = new String( String.fromCharCode(1415) ); s.toUpperCase().charCodeAt(0)", fromCharCodeMessage); - addExpectedFailure("ecma/String/15.5.4.6-2.js", "function f() { return this; }; function g() { var h = f; return h(); }; g().toString()", willFixInNextReleaseMessage); - addExpectedFailure("ecma/TypeConversion/9.3.1-3.js", "- \"-0x123456789abcde8\"", willFixInNextReleaseMessage); addExpectedFailure("ecma/extensions/15.1.2.1-1.js", "var PROPS = ''; for ( p in eval ) { PROPS += p }; PROPS", willFixInNextReleaseMessage); @@ -424,9 +426,6 @@ tst_Suite::tst_Suite() addExpectedFailure("ecma/GlobalObject/15.1.2.6.js", "var MYPROPS=''; for ( var p in isNaN ) { MYPROPS+= p }; MYPROPS", willFixInNextReleaseMessage); addExpectedFailure("ecma/GlobalObject/15.1.2.7.js", "var MYPROPS=''; for ( p in isFinite ) { MYPROPS+= p }; MYPROPS", willFixInNextReleaseMessage); - addExpectedFailure("ecma/Statements/12.6.3-12.js", "var result=''; for ( aVar in this ) { if (aVar == 'aVar') {return a failure}; result", willFixInNextReleaseMessage); - addExpectedFailure("ecma/String/15.5.4.6-2.js", "var d = new Date(0); d.indexOf = String.prototype.indexOf; d.getTimezoneOffset()>0 ? d.indexOf('31') : d.indexOf('01')", willFixInNextReleaseMessage); - // qstrtod() has problems parsing reaaaaally big numbers -- they come out as NaN rather than Infinity or Number.MAX_VALUE addSkip("ecma/TypeConversion/9.3.1-3.js", "parseInt(s1,10) == 1.7976931348623157e+308 || parseInt(s1,10) == Infinity", brokenOnSomePlatformsMessage); addSkip("ecma/TypeConversion/9.3.1-3.js", "parseInt(s2,10) == Infinity || parseInt(s2,10) == 1.7976931348623157e+308", brokenOnSomePlatformsMessage); @@ -444,11 +443,6 @@ tst_Suite::tst_Suite() addExpectedFailure("ecma_2/RegExp/multiline-001.js", "/.*[y]$/m.exec(ivory-billed\ndowny\nhairy\nacorn\nyellow-bellied sapsucker\nnorthern flicker\npileated\n)", willFixInNextReleaseMessage); addExpectedFailure("ecma_2/RegExp/multiline-001.js", "/.*[d]$/m.exec(ivory-billed\ndowny\nhairy\nacorn\nyellow-bellied sapsucker\nnorthern flicker\npileated\n)", willFixInNextReleaseMessage); addExpectedFailure("ecma_2/String/match-002.js", "//.toString()", willFixInNextReleaseMessage); - addExpectedFailure("ecma_2/String/match-002.js", "( Boston, Mass. 02134 ).match(/([d]{5})([- ]?[d]{4})?$/)[2]", willFixInNextReleaseMessage); - addExpectedFailure("ecma_2/String/match-002.js", "( Boston, MA 02134 ).match(re = /([d]{5})([- ]?[d]{4})?$/; re.lastIndex =0)[2]", willFixInNextReleaseMessage); - addExpectedFailure("ecma_2/String/match-002.js", "( Boston, MA 02134 ).match(re = /([d]{5})([- ]?[d]{4})?$/; re.lastIndex = 16)[2]", willFixInNextReleaseMessage); - addExpectedFailure("ecma_2/String/match-002.js", "( Boston, MA 02134 ).match(re = /([d]{5})([- ]?[d]{4})?$/; re.lastIndex = 11)[2]", willFixInNextReleaseMessage); - addExpectedFailure("ecma_2/String/match-002.js", "( Boston, MA 02134 ).match(re = /([d]{5})([- ]?[d]{4})?$/; re.lastIndex = 111)[2]", willFixInNextReleaseMessage); #if defined(Q_WS_WIN) addExpectedFailure(QRegExp(), "VAR1 = 0; VAR2= Infinity; VAR1 %= VAR2;VAR1", willFixInNextReleaseMessage); @@ -477,16 +471,9 @@ tst_Suite::tst_Suite() addExpectedFailure(QRegExp(), "Math.atan2(-Infinity, -Infinity)", willFixInNextReleaseMessage); #endif - addExpectedFailure("ecma_3/Array/15.4.4.11-01.js", "Array.sort should not eat exceptions", willFixInNextReleaseMessage); - addExpectedFailure("ecma_3/Array/15.4.4.3-1.js", "Testing Array.prototype.toLocaleString() -", willFixInNextReleaseMessage); addExpectedFailure("ecma_3/Array/15.4.5.1-01.js", "15.4.5.1 - array.length coverage", willFixInNextReleaseMessage); addExpectedFailure("ecma_3/ExecutionContexts/10.1.4-1.js", "Expected to be able to delete x", willFixInNextReleaseMessage); - addExpectedFailure("ecma_3/extensions/regress-220367-002.js", "Section 1 of test - ", willFixInNextReleaseMessage); - addExpectedFailure("ecma_3/extensions/regress-220367-002.js", "Section 2 of test - ", willFixInNextReleaseMessage); - addExpectedFailure("ecma_3/extensions/regress-220367-002.js", "Section 3 of test - ", willFixInNextReleaseMessage); - addExpectedFailure("ecma_3/extensions/regress-220367-002.js", "Section 4 of test - ", willFixInNextReleaseMessage); - addExpectedFailure("ecma_3/extensions/regress-228087-002.js", "Section 1 of test - \nregexp = /{1.*}/g\n" "string = 'foo {1} foo {2} foo'\n" @@ -551,30 +538,12 @@ tst_Suite::tst_Suite() addExpectedFailure("ecma_3/extensions/regress-274152.js", "Do not ignore unicode format-control characters: 8", willFixInNextReleaseMessage); addExpectedFailure("ecma_3/extensions/regress-368516.js", "Treat unicode BOM characters as whitespace: 0", willFixInNextReleaseMessage); addExpectedFailure("ecma_3/extensions/regress-368516.js", "Treat unicode BOM characters as whitespace: 1", willFixInNextReleaseMessage); - addExpectedFailure("ecma_3/Function/arguments-001.js", "Section 3 of test - ", willFixInNextReleaseMessage); - addExpectedFailure("ecma_3/Function/regress-131964.js", "Section 3 of test - ", willFixInNextReleaseMessage); - addExpectedFailure("ecma_3/Function/regress-131964.js", "Section 4 of test - ", willFixInNextReleaseMessage); - addExpectedFailure("ecma_3/Function/regress-137181.js", "Section 2 of test - ", willFixInNextReleaseMessage); - addExpectedFailure("ecma_3/Function/regress-85880.js", "Section A of test", willFixInNextReleaseMessage); - addExpectedFailure("ecma_3/Function/regress-85880.js", "Section B of test", willFixInNextReleaseMessage); - addExpectedFailure("ecma_3/Function/regress-85880.js", "Section C of test", willFixInNextReleaseMessage); - addExpectedFailure("ecma_3/Function/regress-85880.js", "Section D of test", willFixInNextReleaseMessage); - addExpectedFailure("ecma_3/Function/regress-85880.js", "Section E of test", willFixInNextReleaseMessage); - addExpectedFailure("ecma_3/Function/regress-85880.js", "Section F of test", willFixInNextReleaseMessage); - addExpectedFailure("ecma_3/Function/regress-85880.js", "Section G of test", willFixInNextReleaseMessage); - addExpectedFailure("ecma_3/Function/regress-85880.js", "Section H of test", willFixInNextReleaseMessage); - addExpectedFailure("ecma_3/Function/regress-94506.js", "Section 3 of test", willFixInNextReleaseMessage); addExpectedFailure("ecma_3/FunExpr/fe-001-n.js", "Previous statement should have thrown a ReferenceError", willFixInNextReleaseMessage); - addExpectedFailure("ecma_3/FunExpr/fe-002.js", "Inner function statement should not have been called.", willFixInNextReleaseMessage); addExpectedFailure("ecma_3/LexicalConventions/7.9.1.js", "Automatic Semicolon insertion in postfix expressions: expr\n++", willFixInNextReleaseMessage); addExpectedFailure("ecma_3/LexicalConventions/7.9.1.js", "Automatic Semicolon insertion in postfix expressions: expr\n--", willFixInNextReleaseMessage); addExpectedFailure("ecma_3/LexicalConventions/7.9.1.js", "Automatic Semicolon insertion in postfix expressions: (x\n)-- y", willFixInNextReleaseMessage); addExpectedFailure("ecma_3/LexicalConventions/7.9.1.js", "Automatic Semicolon insertion in postfix expressions: (x)-- y", willFixInNextReleaseMessage); - addExpectedFailure("ecma_3/Number/15.7.4.2-01.js", "3.3.toString.length should be 1", willFixInNextReleaseMessage); - addExpectedFailure("ecma_3/Number/15.7.4.6-1.js", "Section A of test: no error intended!", willFixInNextReleaseMessage); - addExpectedFailure("ecma_3/Number/15.7.4.7-2.js", "num.toPrecision(undefined) should equal num.toString()", willFixInNextReleaseMessage); addExpectedFailure("ecma_3/Object/8.6.1-01.js", "In strict mode, setting a read-only property should generate a warning: Throw if STRICT and WERROR is enabled", willFixInNextReleaseMessage); - addExpectedFailure("ecma_3/Object/8.6.2.6-001.js", "Section 1 of test - ", willFixInNextReleaseMessage); addExpectedFailure("ecma_3/Operators/order-01.js", "operator evaluation order: 11.8.2 >", willFixInNextReleaseMessage); addExpectedFailure("ecma_3/Operators/order-01.js", "operator evaluation order: 11.8.4 >=", willFixInNextReleaseMessage); addExpectedFailure("ecma_3/RegExp/15.10.2-1.js", "Section 5 of test - \nregexp = /(aa|aabaac|ba|b|c)*/\nstring = 'aabaac'\nERROR !!! regexp failed to give expected match array:\nExpect: [\"aaba\", \"ba\"]\nActual: [\"aabaac\", \"aabaac\"]\n", willFixInNextReleaseMessage); @@ -585,7 +554,6 @@ tst_Suite::tst_Suite() addExpectedFailure("ecma_3/RegExp/15.10.2-1.js", "Section 11 of test - \nregexp = /(?=(a+))a*b\\1/\nstring = 'baaabac'\nERROR !!! match arrays have different lengths:\nExpect: [\"aba\", \"a\"]\nActual: [\"aaab\"]\n", willFixInNextReleaseMessage); addExpectedFailure("ecma_3/RegExp/15.10.2-1.js", "Section 12 of test - \nregexp = /(.*?)a(?!(a+)b\\2c)\\2(.*)/\nstring = 'baaabaac'\nERROR !!! regexp FAILED to match anything !!!\nExpect: baaabaac,ba,,abaac\nActual: null\n", willFixInNextReleaseMessage); addExpectedFailure("ecma_3/RegExp/15.10.2-1.js", "Section 13 of test - \nregexp = /(?=(a+))/\nstring = 'baaabac'\nERROR !!! match arrays have different lengths:\nExpect: [\"\", \"aaa\"]\nActual: [\"\"]\n", willFixInNextReleaseMessage); - addExpectedFailure("ecma_3/RegExp/15.10.2.12.js", "15.10.2.12 - CharacterClassEscape d", willFixInNextReleaseMessage); addExpectedFailure("ecma_3/RegExp/perlstress-001.js", "Section 34 of test - \nregexp = /a]/\nstring = 'a]'\nERROR !!! regexp FAILED to match anything !!!\nExpect: a]\nActual: null\n", willFixInNextReleaseMessage); addExpectedFailure("ecma_3/RegExp/perlstress-001.js", "Section 66 of test - \nregexp = /a.+?c/\nstring = 'abcabc'\nERROR !!! regexp FAILED to match anything !!!\nExpect: abc\nActual: null\n", willFixInNextReleaseMessage); addExpectedFailure("ecma_3/RegExp/perlstress-001.js", "Section 94 of test - \nregexp = /^a(bc+|b[eh])g|.h$/\nstring = 'abh'\nERROR !!! regexp failed to give expected match array:\nExpect: [\"bh\", , ]\nActual: [\"bh\", \"\"]\n", willFixInNextReleaseMessage); @@ -662,25 +630,6 @@ tst_Suite::tst_Suite() addExpectedFailure("ecma_3/RegExp/regress-165353.js", "Section 1 of test - \nregexp = /^([a-z]+)*[a-z]$/\nstring = 'a'\nERROR !!! regexp failed to give expected match array:\nExpect: [\"a\", , ]\nActual: [\"a\", \"\"]\n", willFixInNextReleaseMessage); addExpectedFailure("ecma_3/RegExp/regress-169497.js", "Section 1 of test - \nregexp = /<body.*>((.*\\n?)*?)<\\/body>/i\nstring = '<html>\\n<body onXXX=\"alert(event.type);\">\\n<p>Kibology for all</p>\\n<p>All for Kibology</p>\\n</body>\\n</html>'\nERROR !!! regexp FAILED to match anything !!!\nExpect: <body onXXX=\"alert(event.type);\">\n<p>Kibology for all</p>\n<p>All for Kibology</p>\n</body>,\n<p>Kibology for all</p>\n<p>All for Kibology</p>\n,<p>All for Kibology</p>\n\nActual: null\n", willFixInNextReleaseMessage); addExpectedFailure("ecma_3/RegExp/regress-187133.js", "Section 5 of test - \nregexp = /(?!a|b)|c/\nstring = 'bc'\nERROR !!! regexp failed to give expected match array:\nExpect: [\"\"]\nActual: [\"c\"]\n", willFixInNextReleaseMessage); - addExpectedFailure("ecma_3/RegExp/regress-188206.js", "Section 1 of test - ", willFixInNextReleaseMessage); - addExpectedFailure("ecma_3/RegExp/regress-188206.js", "Section 2 of test - ", willFixInNextReleaseMessage); - addExpectedFailure("ecma_3/RegExp/regress-188206.js", "Section 3 of test - ", willFixInNextReleaseMessage); - addExpectedFailure("ecma_3/RegExp/regress-188206.js", "Section 4 of test - ", willFixInNextReleaseMessage); - addExpectedFailure("ecma_3/RegExp/regress-188206.js", "Section 5 of test - ", willFixInNextReleaseMessage); - addExpectedFailure("ecma_3/RegExp/regress-188206.js", "Section 6 of test - ", willFixInNextReleaseMessage); - addExpectedFailure("ecma_3/RegExp/regress-188206.js", "Section 9 of test - ", willFixInNextReleaseMessage); - addExpectedFailure("ecma_3/RegExp/regress-188206.js", "Section 10 of test - ", willFixInNextReleaseMessage); - addExpectedFailure("ecma_3/RegExp/regress-188206.js", "Section 11 of test - ", willFixInNextReleaseMessage); - addExpectedFailure("ecma_3/RegExp/regress-188206.js", "Section 12 of test - ", willFixInNextReleaseMessage); - addExpectedFailure("ecma_3/RegExp/regress-188206.js", "Section 28 of test - ", willFixInNextReleaseMessage); - addExpectedFailure("ecma_3/RegExp/regress-188206.js", "Section 29 of test - ", willFixInNextReleaseMessage); - addExpectedFailure("ecma_3/RegExp/regress-188206.js", "Section 30 of test - ", willFixInNextReleaseMessage); - addExpectedFailure("ecma_3/RegExp/regress-188206.js", "Section 31 of test - ", willFixInNextReleaseMessage); - addExpectedFailure("ecma_3/RegExp/regress-188206.js", "Section 32 of test - ", willFixInNextReleaseMessage); - addExpectedFailure("ecma_3/RegExp/regress-188206.js", "Section 33 of test - ", willFixInNextReleaseMessage); - addExpectedFailure("ecma_3/RegExp/regress-188206.js", "Section 34 of test - ", willFixInNextReleaseMessage); - addExpectedFailure("ecma_3/RegExp/regress-188206.js", "Section 35 of test - ", willFixInNextReleaseMessage); - addExpectedFailure("ecma_3/RegExp/regress-188206.js", "Section 36 of test - ", willFixInNextReleaseMessage); addExpectedFailure("ecma_3/RegExp/regress-191479.js", "Section 1 of test - \nregexp = /(\\d|\\d\\s){2,}/\nstring = '12 3 45'\nERROR !!! regexp failed to give expected match array:\nExpect: [\"12\", \"2\"]\nActual: [\"12 3 45\", \"5\"]\n", willFixInNextReleaseMessage); addExpectedFailure("ecma_3/RegExp/regress-191479.js", "Section 3 of test - \nregexp = /(\\d|\\d\\s)+/\nstring = '12 3 45'\nERROR !!! regexp failed to give expected match array:\nExpect: [\"12\", \"2\"]\nActual: [\"12 3 45\", \"5\"]\n", willFixInNextReleaseMessage); addExpectedFailure("ecma_3/RegExp/regress-191479.js", "Section 8 of test - \nregexp = /(\\d|\\d\\s){2,}?/\nstring = '12 3 45'\nERROR !!! regexp FAILED to match anything !!!\nExpect: 12,2\nActual: null\n", willFixInNextReleaseMessage); @@ -698,12 +647,6 @@ tst_Suite::tst_Suite() addExpectedFailure("ecma_3/RegExp/regress-216591.js", "Section 2 of test - \nregexp = /\\{(([a-z0-9\\-_]+?\\.)+?)([a-z0-9\\-_]+?)\\}/gi\nstring = 'a {result.data.DATA} b'\nERROR !!! match arrays have different lengths:\nExpect: [\"{result.data.DATA}\"]\nActual: []\n", willFixInNextReleaseMessage); addExpectedFailure("ecma_3/RegExp/regress-220367-001.js", "Section 1 of test - \nregexp = /(a)|(b)/\nstring = 'a'\nERROR !!! regexp failed to give expected match array:\nExpect: [\"a\", \"a\", , ]\nActual: [\"a\", \"a\", \"\"]\n", willFixInNextReleaseMessage); addExpectedFailure("ecma_3/RegExp/regress-220367-001.js", "Section 2 of test - \nregexp = /(a)|(b)/\nstring = 'b'\nERROR !!! regexp failed to give expected match array:\nExpect: [\"b\", , \"b\"]\nActual: [\"b\", \"\", \"b\"]\n", willFixInNextReleaseMessage); - addExpectedFailure("ecma_3/RegExp/regress-223273.js", "Section 1 of test - ", willFixInNextReleaseMessage); - addExpectedFailure("ecma_3/RegExp/regress-223273.js", "Section 2 of test - ", willFixInNextReleaseMessage); - addExpectedFailure("ecma_3/RegExp/regress-223273.js", "Section 3 of test - ", willFixInNextReleaseMessage); - addExpectedFailure("ecma_3/RegExp/regress-223273.js", "Section 4 of test - ", willFixInNextReleaseMessage); - addExpectedFailure("ecma_3/RegExp/regress-223273.js", "Section 11 of test - ", willFixInNextReleaseMessage); - addExpectedFailure("ecma_3/RegExp/regress-223273.js", "Section 12 of test - ", willFixInNextReleaseMessage); addExpectedFailure("ecma_3/RegExp/regress-223535.js", "Section 2 of test - \nregexp = /|a/\nstring = 'a'\nERROR !!! regexp failed to give expected match array:\nExpect: [\"\"]\nActual: [\"a\"]\n", willFixInNextReleaseMessage); addExpectedFailure("ecma_3/RegExp/regress-223535.js", "Section 6 of test - \nregexp = /(|a)/\nstring = 'a'\nERROR !!! regexp failed to give expected match array:\nExpect: [\"\", \"\"]\nActual: [\"a\", \"a\"]\n", willFixInNextReleaseMessage); addExpectedFailure("ecma_3/RegExp/regress-223535.js", "Section 7 of test - \nregexp = /(|a|)/\nstring = 'a'\nERROR !!! regexp failed to give expected match array:\nExpect: [\"\", \"\"]\nActual: [\"a\", \"a\"]\n", willFixInNextReleaseMessage); @@ -714,7 +657,6 @@ tst_Suite::tst_Suite() addExpectedFailure("ecma_3/RegExp/regress-225289.js", "Section 10 of test - \nregexp = /((?:a|[^a])*)/g\nstring = 'a'\nERROR !!! match arrays have different lengths:\nExpect: [\"a\", \"\"]\nActual: [\"a\"]\n", willFixInNextReleaseMessage); addExpectedFailure("ecma_3/RegExp/regress-225289.js", "Section 11 of test - \nregexp = /((?:a|[^a])*)/g\nstring = ''\nERROR !!! match arrays have different lengths:\nExpect: [\"\"]\nActual: []\n", willFixInNextReleaseMessage); addExpectedFailure("ecma_3/RegExp/regress-225289.js", "Section 12 of test - \nregexp = /((?:a|[^a])*)/g\nstring = '()'\nERROR !!! match arrays have different lengths:\nExpect: [\"()\", \"\"]\nActual: [\"()\"]\n", willFixInNextReleaseMessage); - addExpectedFailure("ecma_3/RegExp/regress-309840.js", "Treat / in a literal regexp class as valid", willFixInNextReleaseMessage); addExpectedFailure("ecma_3/RegExp/regress-31316.js", "Section 1 of test - \nregexp = /<([^\\/<>][^<>]*[^\\/])>|<([^\\/<>])>/\nstring = '<p>Some<br />test</p>'\nERROR !!! regexp failed to give expected match array:\nExpect: [\"<p>\", , \"p\"]\nActual: [\"<p>\", \"\", \"p\"]\n", willFixInNextReleaseMessage); addExpectedFailure("ecma_3/RegExp/regress-330684.js", "Do not hang on RegExp", willFixInNextReleaseMessage); addExpectedFailure("ecma_3/RegExp/regress-375711.js", "Do not assert with /[Q-b]/i.exec(\"\"): /[q-b]/.exec(\"\")", willFixInNextReleaseMessage); @@ -738,42 +680,10 @@ tst_Suite::tst_Suite() addExpectedFailure("ecma_3/RegExp/regress-85721.js", "Section 2 of test - \nregexp = /<sql:connection id=\"([^\\r\\n]*?)\">\\s*<sql:url>\\s*([^\\r\\n]*?)\\s*<\\/sql:url>\\s*<sql:driver>\\s*([^\\r\\n]*?)\\s*<\\/sql:driver>\\s*(\\s*<sql:userId>\\s*([^\\r\\n]*?)\\s*<\\/sql:userId>\\s*)?\\s*(\\s*<sql:password>\\s*([^\\r\\n]*?)\\s*<\\/sql:password>\\s*)?\\s*<\\/sql:connection>/\nstring = '<sql:connection id=\"conn1\"> <sql:url>www.m.com</sql:url> <sql:driver>drive.class</sql:driver>\\n<sql:userId>foo</sql:userId> <sql:password>goo</sql:password> </sql:connection>'\nERROR !!! regexp FAILED to match anything !!!\nExpect: <sql:connection id=\"conn1\"> <sql:url>www.m.com</sql:url> <sql:driver>drive.class</sql:driver>\n<sql:userId>foo</sql:userId> <sql:password>goo</sql:password> </sql:connection>,conn1,www.m.com,drive.class,<sql:userId>foo</sql:userId> ,foo,<sql:password>goo</sql:password> ,goo\nActual: null\n", willFixInNextReleaseMessage); addExpectedFailure("ecma_3/RegExp/regress-87231.js", "Section 3 of test - \nregexp = /^(A)?(A.*)$/\nstring = 'A'\nERROR !!! regexp failed to give expected match array:\nExpect: [\"A\", , \"A\"]\nActual: [\"A\", \"\", \"A\"]\n", willFixInNextReleaseMessage); addExpectedFailure("ecma_3/RegExp/regress-87231.js", "Section 6 of test - \nregexp = /(A)?(A.*)/\nstring = 'zxcasd;fl\\ ^AaaAAaaaf;lrlrzs'\nERROR !!! regexp failed to give expected match array:\nExpect: [\"AaaAAaaaf;lrlrzs\", , \"AaaAAaaaf;lrlrzs\"]\nActual: [\"AaaAAaaaf;lrlrzs\", \"\", \"AaaAAaaaf;lrlrzs\"]\n", willFixInNextReleaseMessage); - addExpectedFailure("ecma_3/Statements/regress-226517.js", "Section 1 of test - ", willFixInNextReleaseMessage); - addExpectedFailure("ecma_3/String/15.5.4.11.js", "Section 14", willFixInNextReleaseMessage); - addExpectedFailure("ecma_3/String/15.5.4.11.js", "Section 20", willFixInNextReleaseMessage); addExpectedFailure("ecma_3/String/15.5.4.11.js", "Section 24", willFixInNextReleaseMessage); - addExpectedFailure("ecma_3/String/15.5.4.11.js", "Section 27", willFixInNextReleaseMessage); addExpectedFailure("ecma_3/String/15.5.4.11.js", "Section 28", willFixInNextReleaseMessage); - addExpectedFailure("ecma_3/String/15.5.4.11.js", "Section 29", willFixInNextReleaseMessage); addExpectedFailure("ecma_3/String/15.5.4.11.js", "Section 30", willFixInNextReleaseMessage); - addExpectedFailure("ecma_3/String/15.5.4.11.js", "Section 31", willFixInNextReleaseMessage); - addExpectedFailure("ecma_3/String/15.5.4.11.js", "Section 32", willFixInNextReleaseMessage); - addExpectedFailure("ecma_3/String/15.5.4.11.js", "Section 33", willFixInNextReleaseMessage); - addExpectedFailure("ecma_3/String/15.5.4.11.js", "Section 34", willFixInNextReleaseMessage); - addExpectedFailure("ecma_3/String/15.5.4.11.js", "Section 35", willFixInNextReleaseMessage); - addExpectedFailure("ecma_3/String/15.5.4.11.js", "Section 36", willFixInNextReleaseMessage); - addExpectedFailure("ecma_3/String/15.5.4.11.js", "Section 37", willFixInNextReleaseMessage); - addExpectedFailure("ecma_3/String/15.5.4.11.js", "Section 39", willFixInNextReleaseMessage); - addExpectedFailure("ecma_3/String/15.5.4.11.js", "Section 56", willFixInNextReleaseMessage); - addExpectedFailure("ecma_3/String/15.5.4.11.js", "Section 58", willFixInNextReleaseMessage); - addExpectedFailure("ecma_3/String/15.5.4.11.js", "Section 59", willFixInNextReleaseMessage); - addExpectedFailure("ecma_3/String/15.5.4.11.js", "Section 60", willFixInNextReleaseMessage); - addExpectedFailure("ecma_3/String/15.5.4.11.js", "Section 62", willFixInNextReleaseMessage); - addExpectedFailure("ecma_3/String/15.5.4.11.js", "Section 64", willFixInNextReleaseMessage); - addExpectedFailure("ecma_3/String/15.5.4.11.js", "Section 65", willFixInNextReleaseMessage); - addExpectedFailure("ecma_3/String/15.5.4.11.js", "Section 66", willFixInNextReleaseMessage); - addExpectedFailure("ecma_3/String/15.5.4.11.js", "Section 67", willFixInNextReleaseMessage); - addExpectedFailure("ecma_3/String/15.5.4.11.js", "Section 68", willFixInNextReleaseMessage); - addExpectedFailure("ecma_3/String/15.5.4.11.js", "Section 69", willFixInNextReleaseMessage); addExpectedFailure("ecma_3/String/15.5.4.14.js", "15.5.4.14 - String.prototype.split(/()/)", willFixInNextReleaseMessage); - addExpectedFailure("ecma_3/String/regress-104375.js", "Section 1 of test - ", willFixInNextReleaseMessage); - addExpectedFailure("ecma_3/String/regress-104375.js", "Section 2 of test - ", willFixInNextReleaseMessage); - addExpectedFailure("ecma_3/String/regress-304376.js", "String.prototype should be readonly and permanent", willFixInNextReleaseMessage); - addExpectedFailure("ecma_3/String/regress-392378.js", "Regular Expression Non-participating Capture Groups are inaccurate in edge cases: \"y\".split(/(x)?y/)", willFixInNextReleaseMessage); - addExpectedFailure("ecma_3/String/regress-392378.js", "Regular Expression Non-participating Capture Groups are inaccurate in edge cases: \"y\".split(/(x)?y/)", willFixInNextReleaseMessage); - addExpectedFailure("ecma_3/String/regress-392378.js", "Regular Expression Non-participating Capture Groups are inaccurate in edge cases: \"y\".replace(/(x)?\\1y/, function($0, $1){ return String($1); })", willFixInNextReleaseMessage); - addExpectedFailure("ecma_3/String/regress-392378.js", "Regular Expression Non-participating Capture Groups are inaccurate in edge cases: \"y\".replace(/(x)?y/, function($0, $1){ return String($1); })", willFixInNextReleaseMessage); - addExpectedFailure("ecma_3/String/regress-392378.js", "Regular Expression Non-participating Capture Groups are inaccurate in edge cases: \"y\".replace(/(x)?y/, function($0, $1){ return $1; })", willFixInNextReleaseMessage); addExpectedFailure("ecma_3/Unicode/regress-352044-01.js", "issues with Unicode escape sequences in JavaScript source code", willFixInNextReleaseMessage); addExpectedFailure("ecma_3/Unicode/uc-001.js", "Unicode format-control character test (Category Cf.)", willFixInNextReleaseMessage); @@ -785,6 +695,38 @@ tst_Suite::tst_Suite() addFileExclusion("regress-322135-04.js", "takes forever"); addFileExclusion("ecma_3/RegExp/regress-375715-04.js", "bug"); + // Failures due to switch to JSC as back-end + addExpectedFailure("ecma/Array/15.4.3.1-2.js", "var props = ''; for ( p in Array ) { props += p } props", willFixInNextReleaseMessage); + addExpectedFailure("ecma/Boolean/15.6.3.1-1.js", "var str='';for ( p in Boolean ) { str += p } str;", willFixInNextReleaseMessage); + addExpectedFailure("ecma/Expressions/11.4.1.js", "var abc; delete(abc)", willFixInNextReleaseMessage); + addExpectedFailure("ecma/FunctionObjects/15.3.3.1-2.js", "var str='';for (prop in Function ) str += prop; str;", willFixInNextReleaseMessage); + addExpectedFailure("ecma/ObjectObjects/15.2.3.1-1.js", "var str = '';for ( p in Object ) { str += p; }; str", willFixInNextReleaseMessage); + addExpectedFailure("ecma/Statements/12.6.3-11.js", "result = \"\"; for ( p in Number ) { result += String(p) };", willFixInNextReleaseMessage); + addExpectedFailure("ecma/Statements/12.6.3-2.js", "Boolean.prototype.foo = 34; for ( j in Boolean ) Boolean[j]", willFixInNextReleaseMessage); + addExpectedFailure("ecma/TypeConversion/9.3.1-3.js", "-\"\\u20001234\\u2001\"", willFixInNextReleaseMessage); + addExpectedFailure("ecma_2/RegExp/properties-001.js", "//.toString()", willFixInNextReleaseMessage); + addExpectedFailure("ecma_3/Date/15.9.4.3.js", "15.9.4.3 - Date.UTC edge-case arguments.: date Infinity", willFixInNextReleaseMessage); + addExpectedFailure("ecma_3/Date/15.9.4.3.js", "15.9.4.3 - Date.UTC edge-case arguments.: hours Infinity", willFixInNextReleaseMessage); + addExpectedFailure("ecma_3/Date/15.9.4.3.js", "15.9.4.3 - Date.UTC edge-case arguments.: minutes Infinity", willFixInNextReleaseMessage); + addExpectedFailure("ecma_3/Date/15.9.4.3.js", "15.9.4.3 - Date.UTC edge-case arguments.: seconds Infinity", willFixInNextReleaseMessage); + addExpectedFailure("ecma_3/Function/regress-131964.js", "Section 1 of test - ", willFixInNextReleaseMessage); + addExpectedFailure("ecma_3/Function/regress-313570.js", "length of objects whose prototype chain includes a function: immutable", willFixInNextReleaseMessage); + addExpectedFailure("ecma_3/FunExpr/fe-001.js", "Both functions were defined.", willFixInNextReleaseMessage); + addExpectedFailure("ecma_3/RegExp/15.10.2-1.js", "Section 7 of test - \nregexp = /(z)((a+)?(b+)?(c))*/\nstring = 'zaacbbbcac'\nERROR !!! regexp failed to give expected match array:\nExpect: [\"zaacbbbcac\", \"z\", \"ac\", \"a\", , \"c\"]\nActual: [\"zaacbbbcac\", \"z\", \"ac\", \"a\", \"bbb\", \"c\"]\n", willFixInNextReleaseMessage); + addExpectedFailure("ecma_3/RegExp/15.10.2-1.js", "Section 12 of test - \nregexp = /(.*?)a(?!(a+)b\\2c)\\2(.*)/\nstring = 'baaabaac'\nERROR !!! regexp failed to give expected match array:\nExpect: [\"baaabaac\", \"ba\", , \"abaac\"]\nActual: [\"baaabaac\", \"ba\", \"aa\", \"abaac\"]\n", willFixInNextReleaseMessage); + addExpectedFailure("ecma_3/RegExp/perlstress-001.js", "Section 218 of test - \nregexp = /((foo)|(bar))*/\nstring = 'foobar'\nERROR !!! regexp failed to give expected match array:\nExpect: [\"foobar\", \"bar\", , \"bar\"]\nActual: [\"foobar\", \"bar\", \"foo\", \"bar\"]\n", willFixInNextReleaseMessage); + addExpectedFailure("ecma_3/RegExp/perlstress-001.js", "Section 234 of test - \nregexp = /(?:(f)(o)(o)|(b)(a)(r))*/\nstring = 'foobar'\nERROR !!! regexp failed to give expected match array:\nExpect: [\"foobar\", , , , \"b\", \"a\", \"r\"]\nActual: [\"foobar\", \"f\", \"o\", \"o\", \"b\", \"a\", \"r\"]\n", willFixInNextReleaseMessage); + addExpectedFailure("ecma_3/RegExp/perlstress-001.js", "Section 241 of test - \nregexp = /^(?:b|a(?=(.)))*\\1/\nstring = 'abc'\nERROR !!! regexp failed to give expected match array:\nExpect: [\"ab\", , ]\nActual: [\"ab\", \"b\"]\n", willFixInNextReleaseMessage); + addExpectedFailure("ecma_3/RegExp/perlstress-001.js", "Section 412 of test - \nregexp = /^(a(b)?)+$/\nstring = 'aba'\nERROR !!! regexp failed to give expected match array:\nExpect: [\"aba\", \"a\", , ]\nActual: [\"aba\", \"a\", \"b\"]\n", willFixInNextReleaseMessage); + addExpectedFailure("ecma_3/RegExp/perlstress-001.js", "Section 413 of test - \nregexp = /^(aa(bb)?)+$/\nstring = 'aabbaa'\nERROR !!! regexp failed to give expected match array:\nExpect: [\"aabbaa\", \"aa\", , ]\nActual: [\"aabbaa\", \"aa\", \"bb\"]\n", willFixInNextReleaseMessage); + addExpectedFailure("ecma_3/RegExp/regress-209919.js", "Section 1 of test - \nregexp = /(a|b*)*/\nstring = 'a'\nERROR !!! regexp failed to give expected match array:\nExpect: [\"a\", \"a\"]\nActual: [\"a\", \"\"]\n", willFixInNextReleaseMessage); + addExpectedFailure("ecma_3/RegExp/regress-209919.js", "Section 5 of test - \nregexp = /^\\-?(\\d{1,}|\\.{0,})*(\\,\\d{1,})?$/\nstring = '100.00'\nERROR !!! regexp failed to give expected match array:\nExpect: [\"100.00\", \"00\", , ]\nActual: [\"100.00\", \"\", , ]\n", willFixInNextReleaseMessage); + addExpectedFailure("ecma_3/RegExp/regress-209919.js", "Section 6 of test - \nregexp = /^\\-?(\\d{1,}|\\.{0,})*(\\,\\d{1,})?$/\nstring = '100,00'\nERROR !!! regexp failed to give expected match array:\nExpect: [\"100,00\", \"100\", \",00\"]\nActual: [\"100,00\", \"\", \",00\"]\n", willFixInNextReleaseMessage); + addExpectedFailure("ecma_3/RegExp/regress-209919.js", "Section 7 of test - \nregexp = /^\\-?(\\d{1,}|\\.{0,})*(\\,\\d{1,})?$/\nstring = '1.000,00'\nERROR !!! regexp failed to give expected match array:\nExpect: [\"1.000,00\", \"000\", \",00\"]\nActual: [\"1.000,00\", \"\", \",00\"]\n", willFixInNextReleaseMessage); + addExpectedFailure("ecma_3/RegExp/regress-311414.js", "RegExp captured tail match should be O(N) BigO 2 < 2", willFixInNextReleaseMessage); + addExpectedFailure("ecma_3/String/15.5.4.11.js", "Section 7", willFixInNextReleaseMessage); + addExpectedFailure("ecma_3/String/15.5.4.11.js", "Section 26", willFixInNextReleaseMessage); + static const char klass[] = "tst_QScriptJsTestSuite"; QVector<uint> *data = qt_meta_data_tst_Suite(); @@ -904,7 +846,7 @@ bool tst_Suite::isExcludedFile(const QString &fileName, QString *message) const if (message) *message = fileExclusions.at(i).second; return true; - } + } } return false; } diff --git a/tests/auto/qscriptv8testsuite/qscriptv8testsuite.pro b/tests/auto/qscriptv8testsuite/qscriptv8testsuite.pro index c07ab53..3f641b5 100644 --- a/tests/auto/qscriptv8testsuite/qscriptv8testsuite.pro +++ b/tests/auto/qscriptv8testsuite/qscriptv8testsuite.pro @@ -1,12 +1,12 @@ load(qttest_p4) QT = core script SOURCES += tst_qscriptv8testsuite.cpp -DEFINES += SRCDIR=\\\"$$PWD\\\" +!symbian:DEFINES += SRCDIR=\\\"$$PWD\\\" -wince*: { +wince*|symbian: { testFiles.sources = tests testFiles.path = . DEPLOYMENT += testFiles } - +symbian:TARGET.EPOCHEAPSIZE = 0x00020000 0x02000000 diff --git a/tests/auto/qscriptv8testsuite/tst_qscriptv8testsuite.cpp b/tests/auto/qscriptv8testsuite/tst_qscriptv8testsuite.cpp index 4021662..68db92a 100644 --- a/tests/auto/qscriptv8testsuite/tst_qscriptv8testsuite.cpp +++ b/tests/auto/qscriptv8testsuite/tst_qscriptv8testsuite.cpp @@ -45,9 +45,22 @@ #include <QtScript> +#if defined(Q_OS_SYMBIAN) +# define SRCDIR "" +#endif + //TESTED_CLASS= //TESTED_FILES= +// Uncomment the following define to have the autotest generate +// addExpectedFailure() code for all the tests that fail. +// This is useful when a whole new test (sub)suite is added. +// The code is stored in addexpectedfailures.cpp. +// Paste the contents into this file after the existing +// addExpectedFailure() calls. + +//#define GENERATE_ADDEXPECTEDFAILURE_CODE + static QString readFile(const QString &filename) { QFile file(filename); @@ -106,6 +119,9 @@ private: QList<ExpectedFailure> expectedFailures; QList<QPair<QRegExp, QString> > testExclusions; QString mjsunitContents; +#ifdef GENERATE_ADDEXPECTEDFAILURE_CODE + QString generatedAddExpectedFailureCode; +#endif }; QMetaObject tst_Suite::staticMetaObject; @@ -175,6 +191,14 @@ int tst_Suite::qt_metacall(QMetaObject::Call _c, int _id, void **_a) QTest::Continue, path.toLatin1(), lineNumber); } +#ifdef GENERATE_ADDEXPECTEDFAILURE_CODE + else { + generatedAddExpectedFailureCode.append( + " addExpectedFailure(\"" + name + + "\", \"" + actual + "\", \"" + expected + + "\", willFixInNextReleaseMessage);\n"); + } +#endif QTest::qCompare(actual, expected, "actual", "expect", path.toLatin1(), lineNumber); } else { @@ -207,44 +231,18 @@ tst_Suite::tst_Suite() } } QString willFixInNextReleaseMessage = QString::fromLatin1("Will fix in next release"); - addExpectedFailure("apply", "morundefineder", "morseper", willFixInNextReleaseMessage); addExpectedFailure("arguments-enum", "2", "0", willFixInNextReleaseMessage); - addExpectedFailure("array-concat", "undefined", "baz", willFixInNextReleaseMessage); - addExpectedFailure("array-functions-prototype", "undefined", "one", willFixInNextReleaseMessage); addExpectedFailure("const-redecl", "undefined", "TypeError", willFixInNextReleaseMessage); - addExpectedFailure("const", "2", "1", willFixInNextReleaseMessage); - addExpectedFailure("declare-locally", "undefined", "42", willFixInNextReleaseMessage); - addExpectedFailure("delay-syntax-error", "false", "true", willFixInNextReleaseMessage); - addExpectedFailure("delete-vars-from-eval", "false", "true", willFixInNextReleaseMessage); - addExpectedFailure("dont-enum-array-holes", "4", "2", willFixInNextReleaseMessage); - addExpectedFailure("fun-as-prototype", "undefined", "Funky", willFixInNextReleaseMessage); - addExpectedFailure("fun_name", "function(){}", "functionanonymous(){}", willFixInNextReleaseMessage); - addExpectedFailure("function-caller", "undefined", "function f(match) {\n g(match);\n}", willFixInNextReleaseMessage); addExpectedFailure("global-const-var-conflicts", "false", "true", willFixInNextReleaseMessage); - addExpectedFailure("length", "3", "1", willFixInNextReleaseMessage); - addExpectedFailure("math-min-max", "-Infinity", "Infinity", willFixInNextReleaseMessage); - addExpectedFailure("newline-in-string", "asdf\n\nasdf\n?asdf\n\tasdf\n\\\n\n", "asdf\nasdf?asdf\tasdf\\", willFixInNextReleaseMessage); - addExpectedFailure("number-tostring", "1111111111111111081984.00000000", "1.1111111111111111e+21", willFixInNextReleaseMessage); - addExpectedFailure("parse-int-float", "false", "true", willFixInNextReleaseMessage); - addExpectedFailure("regexp-multiline-stack-trace", "false", "true", willFixInNextReleaseMessage); - addExpectedFailure("regexp-multiline", "false", "true", willFixInNextReleaseMessage); - addExpectedFailure("regexp-standalones", "0", "2", willFixInNextReleaseMessage); - addExpectedFailure("regexp-static", "undefined", "abc123.456def", willFixInNextReleaseMessage); - addExpectedFailure("sparse-array-reverse", "nopcb", "nopdcba", willFixInNextReleaseMessage); - addExpectedFailure("str-to-num", "false", "true", willFixInNextReleaseMessage); addExpectedFailure("string-lastindexof", "0", "-1", "test is wrong?"); - addExpectedFailure("string-split", "5", "13", "regular expression semantics"); -// addExpectedFailure("substr", "", "abcdefghijklmn", willFixInNextReleaseMessage); - addExpectedFailure("to-precision", "1.2345e+27", "1.23450e+27", willFixInNextReleaseMessage); - addExpectedFailure("try", "3", "4", "task 209990"); - addExpectedFailure("try_catch_scopes", "0", "1", "task 227055"); - addExpectedFailure("unusual-constructor", "false", "true", "no idea"); - addExpectedFailure("unicode-test", "13792", "13793", "test is wrong?"); - addExpectedFailure("with-leave", "false", "true", "task 233769"); addTestExclusion("debug-*", "not applicable"); addTestExclusion("mirror-*", "not applicable"); + addTestExclusion("array-concat", "Hangs on JSC backend"); + addTestExclusion("array-splice", "Hangs on JSC backend"); + addTestExclusion("sparse-array-reverse", "Hangs on JSC backend"); + addTestExclusion("string-case", "V8-specific behavior? (Doesn't pass on SpiderMonkey either)"); #ifdef Q_OS_WINCE @@ -254,6 +252,24 @@ tst_Suite::tst_Suite() addTestExclusion("mul-exhaustive", "Demands too much memory on WinCE"); #endif +#ifdef Q_OS_SYMBIAN + addTestExclusion("nested-repetition-count-overflow", "Demands too much memory on Symbian"); + addTestExclusion("unicode-test", "Demands too much memory on Symbian"); +#endif + // Failures due to switch to JSC as back-end + addExpectedFailure("date-parse", "NaN", "946713600000", willFixInNextReleaseMessage); + addExpectedFailure("delete-global-properties", "true", "false", willFixInNextReleaseMessage); + addExpectedFailure("delete", "false", "true", willFixInNextReleaseMessage); + addExpectedFailure("function-arguments-null", "false", "true", willFixInNextReleaseMessage); + addExpectedFailure("function-caller", "null", "function eval() {\n [native code]\n}", willFixInNextReleaseMessage); + addExpectedFailure("function-prototype", "prototype", "disconnectconnect", willFixInNextReleaseMessage); + addExpectedFailure("number-tostring", "0", "0.0000a7c5ac471b4788", willFixInNextReleaseMessage); + addExpectedFailure("parse-int-float", "1e+21", "1", willFixInNextReleaseMessage); + addExpectedFailure("regexp", "false", "true", willFixInNextReleaseMessage); + addExpectedFailure("smi-negative-zero", "-Infinity", "Infinity", willFixInNextReleaseMessage); + addExpectedFailure("string-split", "4", "3", willFixInNextReleaseMessage); + addExpectedFailure("substr", "abcdefghijklmn", "", willFixInNextReleaseMessage); + static const char klass[] = "tst_QScriptV8TestSuite"; QVector<uint> *data = qt_meta_data_tst_Suite(); @@ -296,6 +312,14 @@ tst_Suite::tst_Suite() tst_Suite::~tst_Suite() { +#ifdef GENERATE_ADDEXPECTEDFAILURE_CODE + if (!generatedAddExpectedFailureCode.isEmpty()) { + QFile file("addexpectedfailures.cpp"); + file.open(QFile::WriteOnly); + QTextStream ts(&file); + ts << generatedAddExpectedFailureCode; + } +#endif } void tst_Suite::addExpectedFailure(const QString &testName, const QString &actual, diff --git a/tests/auto/qscriptvalue/tst_qscriptvalue.cpp b/tests/auto/qscriptvalue/tst_qscriptvalue.cpp index 357435a..3f231f2 100644 --- a/tests/auto/qscriptvalue/tst_qscriptvalue.cpp +++ b/tests/auto/qscriptvalue/tst_qscriptvalue.cpp @@ -315,14 +315,14 @@ void tst_QScriptValue::ctor() } // 0 engine - QVERIFY(!QScriptValue(0, QScriptValue::UndefinedValue).isValid()); - QVERIFY(!QScriptValue(0, QScriptValue::NullValue).isValid()); - QVERIFY(!QScriptValue(0, false).isValid()); - QVERIFY(!QScriptValue(0, int(1)).isValid()); - QVERIFY(!QScriptValue(0, uint(1)).isValid()); - QVERIFY(!QScriptValue(0, 1.0).isValid()); - QVERIFY(!QScriptValue(0, "ciao").isValid()); - QVERIFY(!QScriptValue(0, QString("ciao")).isValid()); + QVERIFY(QScriptValue(0, QScriptValue::UndefinedValue).isUndefined()); + QVERIFY(QScriptValue(0, QScriptValue::NullValue).isNull()); + QVERIFY(QScriptValue(0, false).isBool()); + QVERIFY(QScriptValue(0, int(1)).isNumber()); + QVERIFY(QScriptValue(0, uint(1)).isNumber()); + QVERIFY(QScriptValue(0, 1.0).isNumber()); + QVERIFY(QScriptValue(0, "ciao").isString()); + QVERIFY(QScriptValue(0, QString("ciao")).isString()); } void tst_QScriptValue::engine() @@ -381,8 +381,8 @@ void tst_QScriptValue::toString() QCOMPARE(qscriptvalue_cast<QString>(object), QString("[object Object]")); QScriptValue fun = eng.newFunction(myFunction); - QCOMPARE(fun.toString(), QString("function () { [native] }")); - QCOMPARE(qscriptvalue_cast<QString>(fun), QString("function () { [native] }")); + QCOMPARE(fun.toString(), QString("function () {\n [native code]\n}")); + QCOMPARE(qscriptvalue_cast<QString>(fun), QString("function () {\n [native code]\n}")); // toString() that throws exception { @@ -435,6 +435,18 @@ void tst_QScriptValue::toString() QCOMPARE(str.toString(), QString("ciao")); QCOMPARE(qscriptvalue_cast<QString>(str), QString("ciao")); } + + // variant should use internal valueOf(), then fall back to QVariant::toString(), + // then fall back to "QVariant(typename)" + QScriptValue variant = eng.newVariant(123); + QVERIFY(variant.isVariant()); + QCOMPARE(variant.toString(), QString::fromLatin1("123")); + variant = eng.newVariant(QByteArray("hello")); + QVERIFY(variant.isVariant()); + QCOMPARE(variant.toString(), QString::fromLatin1("hello")); + variant = eng.newVariant(QVariant(QPoint(10, 20))); + QVERIFY(variant.isVariant()); + QCOMPARE(variant.toString(), QString::fromLatin1("QVariant(QPoint)")); } void tst_QScriptValue::toNumber() @@ -1273,7 +1285,7 @@ void tst_QScriptValue::toVariant() } { - QRegExp rx = QRegExp("[0-9a-z]+"); + QRegExp rx = QRegExp("[0-9a-z]+", Qt::CaseSensitive, QRegExp::RegExp2); QScriptValue rxObject = eng.newRegExp(rx); QVariant var = rxObject.toVariant(); QCOMPARE(var, QVariant(rx)); @@ -1825,30 +1837,40 @@ void tst_QScriptValue::getSetProperty() // getter() returns this.x object4.setProperty("foo", eng.newFunction(getter), QScriptValue::PropertyGetter | QScriptValue::UserRange); + QCOMPARE(object4.propertyFlags("foo") & ~QScriptValue::UserRange, + QScriptValue::PropertyGetter ); + + QEXPECT_FAIL("", "User-range flags are not retained for getter/setter properties", Continue); QCOMPARE(object4.propertyFlags("foo"), QScriptValue::PropertyGetter | QScriptValue::UserRange); object4.setProperty("x", num); QCOMPARE(object4.property("foo").strictlyEquals(num), true); - + // setter() sets this.x object4.setProperty("foo", eng.newFunction(setter), - QScriptValue::PropertySetter | QScriptValue::UserRange); + QScriptValue::PropertySetter); + QCOMPARE(object4.propertyFlags("foo") & ~QScriptValue::UserRange, + QScriptValue::PropertySetter | QScriptValue::PropertyGetter); + QCOMPARE(object4.propertyFlags("foo"), - QScriptValue::PropertySetter | QScriptValue::UserRange); + QScriptValue::PropertySetter | QScriptValue::PropertyGetter); object4.setProperty("foo", str); QCOMPARE(object4.property("x").strictlyEquals(str), true); QCOMPARE(object4.property("foo").strictlyEquals(str), true); - + // kill the getter object4.setProperty("foo", QScriptValue(), QScriptValue::PropertyGetter); - QCOMPARE(object4.property("foo").isValid(), false); - + QVERIFY(!(object4.propertyFlags("foo") & QScriptValue::PropertyGetter)); + QVERIFY(object4.propertyFlags("foo") & QScriptValue::PropertySetter); + QCOMPARE(object4.property("foo").isUndefined(), true); + // setter should still work object4.setProperty("foo", num); QCOMPARE(object4.property("x").strictlyEquals(num), true); - + // kill the setter too object4.setProperty("foo", QScriptValue(), QScriptValue::PropertySetter); + QVERIFY(!(object4.propertyFlags("foo") & QScriptValue::PropertySetter)); // now foo is just a regular property object4.setProperty("foo", str); QCOMPARE(object4.property("x").strictlyEquals(num), true); @@ -1861,21 +1883,21 @@ void tst_QScriptValue::getSetProperty() object4.setProperty("foo", eng.newFunction(setter), QScriptValue::PropertySetter); object4.setProperty("foo", str); QCOMPARE(object4.property("x").strictlyEquals(str), true); - QCOMPARE(object4.property("foo").isValid(), false); - + QCOMPARE(object4.property("foo").isUndefined(), true); + // getter() returns this.x object4.setProperty("foo", eng.newFunction(getter), QScriptValue::PropertyGetter); object4.setProperty("x", num); QCOMPARE(object4.property("foo").strictlyEquals(num), true); - + // kill the setter object4.setProperty("foo", QScriptValue(), QScriptValue::PropertySetter); QTest::ignoreMessage(QtWarningMsg, "QScriptValue::setProperty() failed: property 'foo' has a getter but no setter"); object4.setProperty("foo", str); - + // getter should still work QCOMPARE(object4.property("foo").strictlyEquals(num), true); - + // kill the getter too object4.setProperty("foo", QScriptValue(), QScriptValue::PropertyGetter); // now foo is just a regular property @@ -1887,21 +1909,16 @@ void tst_QScriptValue::getSetProperty() // use a single function as both getter and setter object4.setProperty("foo", QScriptValue()); object4.setProperty("foo", eng.newFunction(getterSetter), - QScriptValue::PropertyGetter | QScriptValue::PropertySetter - | QScriptValue::UserRange); + QScriptValue::PropertyGetter | QScriptValue::PropertySetter); QCOMPARE(object4.propertyFlags("foo"), - QScriptValue::PropertyGetter | QScriptValue::PropertySetter - | QScriptValue::UserRange); + QScriptValue::PropertyGetter | QScriptValue::PropertySetter); object4.setProperty("x", num); QCOMPARE(object4.property("foo").strictlyEquals(num), true); - // killing the getter will also kill the setter, since they are the same function + // killing the getter will preserve the setter, even though they are the same function object4.setProperty("foo", QScriptValue(), QScriptValue::PropertyGetter); - QCOMPARE(object4.property("foo").isValid(), false); - // now foo is just a regular property - object4.setProperty("foo", str); - QCOMPARE(object4.property("x").strictlyEquals(num), true); - QCOMPARE(object4.property("foo").strictlyEquals(str), true); + QVERIFY(object4.propertyFlags("foo") & QScriptValue::PropertySetter); + QCOMPARE(object4.property("foo").isUndefined(), true); // getter/setter that throws an error { @@ -1955,12 +1972,12 @@ void tst_QScriptValue::getSetProperty() { QScriptValue ret = eng.evaluate("this.globalGetterSetterProperty()"); QVERIFY(ret.isError()); - QCOMPARE(ret.toString(), QString::fromLatin1("TypeError: globalGetterSetterProperty is not a function")); + QCOMPARE(ret.toString(), QString::fromLatin1("TypeError: Result of expression 'this.globalGetterSetterProperty' [123] is not a function.")); } { QScriptValue ret = eng.evaluate("new this.globalGetterSetterProperty()"); QVERIFY(ret.isError()); - QCOMPARE(ret.toString(), QString::fromLatin1("TypeError: globalGetterSetterProperty is not a constructor")); + QCOMPARE(ret.toString(), QString::fromLatin1("TypeError: Result of expression 'this.globalGetterSetterProperty' [123] is not a constructor.")); } } @@ -2026,6 +2043,10 @@ void tst_QScriptValue::getSetProperty() "} found"); QCOMPARE(ret.strictlyEquals(QScriptValue(&eng, true)), true); } + // should still be deletable from C++ + object.setProperty("undeletableProperty", QScriptValue()); + QVERIFY(!object.property("undeletableProperty").isValid()); + QCOMPARE(object.propertyFlags("undeletableProperty"), 0); // SkipInEnumeration object.setProperty("dontEnumProperty", num, QScriptValue::SkipInEnumeration); @@ -2068,6 +2089,14 @@ void tst_QScriptValue::getSetProperty() object.setProperty("flagProperty", str, QScriptValue::UserRange); QCOMPARE(object.propertyFlags("flagProperty"), QScriptValue::UserRange); + // flags of property in the prototype + { + QScriptValue object2 = eng.newObject(); + object2.setPrototype(object); + QCOMPARE(object2.propertyFlags("flagProperty", QScriptValue::ResolveLocal), 0); + QCOMPARE(object2.propertyFlags("flagProperty"), QScriptValue::UserRange); + } + // using interned strings QScriptString foo = eng.toStringHandle("foo"); @@ -2077,17 +2106,6 @@ void tst_QScriptValue::getSetProperty() object.setProperty(foo, num); QVERIFY(object.property(foo).strictlyEquals(num)); QVERIFY(object.property("foo").strictlyEquals(num)); - - // can't set arguments and length property of function objects - { - QScriptValue fun = eng.newFunction(getterSetter, /*length=*/2); - for (int x = 0; x < 2; ++x) { - QVERIFY(fun.property("arguments").isNull()); - QVERIFY(fun.property("length").strictlyEquals(QScriptValue(&eng, 2))); - fun.setProperty("arguments", QScriptValue()); - fun.setProperty("length", QScriptValue()); - } - } } void tst_QScriptValue::getSetPrototype() @@ -2127,7 +2145,7 @@ void tst_QScriptValue::getSetPrototype() QCOMPARE(eng.hasUncaughtException(), true); QVERIFY(ret.strictlyEquals(eng.uncaughtException())); QCOMPARE(ret.isError(), true); - QCOMPARE(ret.toString(), QLatin1String("Error: cycle in prototype chain")); + QCOMPARE(ret.toString(), QLatin1String("Error: cyclic __proto__ value")); } { QScriptValue ret = eng.evaluate("p.__proto__ = { }"); @@ -2235,7 +2253,7 @@ void tst_QScriptValue::call() QScriptEngine eng; { - QScriptValue fun = eng.evaluate("function() { return 1; }"); + QScriptValue fun = eng.evaluate("(function() { return 1; })"); QVERIFY(fun.isFunction()); QScriptValue result = fun.call(); QVERIFY(result.isNumber()); @@ -2261,7 +2279,7 @@ void tst_QScriptValue::call() // test that correct "this" object is used { - QScriptValue fun = eng.evaluate("function() { return this; }"); + QScriptValue fun = eng.evaluate("(function() { return this; })"); QCOMPARE(fun.isFunction(), true); { @@ -2274,7 +2292,7 @@ void tst_QScriptValue::call() // test that correct arguments are passed { - QScriptValue fun = eng.evaluate("function() { return arguments[0]; }"); + QScriptValue fun = eng.evaluate("(function() { return arguments[0]; })"); QCOMPARE(fun.isFunction(), true); { @@ -2298,10 +2316,17 @@ void tst_QScriptValue::call() QCOMPARE(result.isNumber(), true); QCOMPARE(result.toNumber(), 123.0); } + { + QScriptValue args = eng.newArray(); + args.setProperty(0, 123); + QScriptValue result = fun.call(eng.undefinedValue(), args); + QVERIFY(result.isNumber()); + QCOMPARE(result.toNumber(), 123.0); + } } { - QScriptValue fun = eng.evaluate("function() { return arguments[1]; }"); + QScriptValue fun = eng.evaluate("(function() { return arguments[1]; })"); QCOMPARE(fun.isFunction(), true); { @@ -2311,11 +2336,20 @@ void tst_QScriptValue::call() QCOMPARE(result.isNumber(), true); QCOMPARE(result.toNumber(), 456.0); } + { + QScriptValue args = eng.newArray(); + args.setProperty(0, 123); + args.setProperty(1, 456); + QScriptValue result = fun.call(eng.undefinedValue(), args); + QVERIFY(result.isNumber()); + QCOMPARE(result.toNumber(), 456.0); + } } { - QScriptValue fun = eng.evaluate("function() { throw new Error('foo'); }"); + QScriptValue fun = eng.evaluate("(function() { throw new Error('foo'); })"); QCOMPARE(fun.isFunction(), true); + QVERIFY(!eng.hasUncaughtException()); { QScriptValue result = fun.call(); @@ -2326,11 +2360,13 @@ void tst_QScriptValue::call() } { + eng.clearExceptions(); QScriptValue fun = eng.newFunction(getArg); { QScriptValueList args; args << QScriptValue(&eng, 123.0); QScriptValue result = fun.call(eng.undefinedValue(), args); + QVERIFY(!eng.hasUncaughtException()); QCOMPARE(result.isNumber(), true); QCOMPARE(result.toNumber(), 123.0); } @@ -2342,6 +2378,13 @@ void tst_QScriptValue::call() QCOMPARE(result.isNumber(), true); QCOMPARE(result.toNumber(), 123.0); } + { + QScriptValue args = eng.newArray(); + args.setProperty(0, 123); + QScriptValue result = fun.call(eng.undefinedValue(), args); + QVERIFY(result.isNumber()); + QCOMPARE(result.toNumber(), 123.0); + } } { @@ -2350,6 +2393,7 @@ void tst_QScriptValue::call() QScriptValueList args; args << QScriptValue(&eng, 123.0); QScriptValue result = fun.call(eng.undefinedValue(), args); + QVERIFY(!eng.hasUncaughtException()); QCOMPARE(result.isNumber(), true); QCOMPARE(result.toNumber(), 123.0); } @@ -2365,6 +2409,7 @@ void tst_QScriptValue::call() QScriptValueList args; args << QScriptValue(); QScriptValue ret = fun.call(QScriptValue(), args); + QVERIFY(!eng.hasUncaughtException()); QCOMPARE(ret.isValid(), true); QCOMPARE(ret.isUndefined(), true); } @@ -2413,22 +2458,28 @@ void tst_QScriptValue::call() { QScriptEngine otherEngine; - QScriptValue fun = otherEngine.evaluate("function() { return 1; }"); + QScriptValue fun = otherEngine.evaluate("(function() { return 1; })"); + QVERIFY(fun.isFunction()); QTest::ignoreMessage(QtWarningMsg, "QScriptValue::call() failed: " "cannot call function with thisObject created in " "a different engine"); QCOMPARE(fun.call(Object).isValid(), false); - QCOMPARE(fun.call(QScriptValue(), QScriptValueList() << QScriptValue(&eng, 123)).isValid(), true); + QTest::ignoreMessage(QtWarningMsg, "QScriptValue::call() failed: " + "cannot call function with argument created in " + "a different engine"); + QCOMPARE(fun.call(QScriptValue(), QScriptValueList() << QScriptValue(&eng, 123)).isValid(), false); } { - QScriptValue fun = eng.evaluate("function() { return arguments; }"); + QScriptValue fun = eng.evaluate("(function() { return arguments; })"); + QVERIFY(fun.isFunction()); QScriptValue array = eng.newArray(3); array.setProperty(0, QScriptValue(&eng, 123.0)); array.setProperty(1, QScriptValue(&eng, 456.0)); array.setProperty(2, QScriptValue(&eng, 789.0)); // call with single array object as arguments QScriptValue ret = fun.call(QScriptValue(), array); + QVERIFY(!eng.hasUncaughtException()); QCOMPARE(ret.isError(), false); QCOMPARE(ret.property(0).strictlyEquals(array.property(0)), true); QCOMPARE(ret.property(1).strictlyEquals(array.property(1)), true); @@ -2453,6 +2504,26 @@ void tst_QScriptValue::call() QScriptValue ret5 = fun.call(QScriptValue(), QScriptValue(&eng, 123.0)); QCOMPARE(ret5.isError(), true); } + + // calling things that are not functions + QVERIFY(!QScriptValue(false).call().isValid()); + QVERIFY(!QScriptValue(123).call().isValid()); + QVERIFY(!QScriptValue(QString::fromLatin1("ciao")).call().isValid()); + QVERIFY(!QScriptValue(QScriptValue::UndefinedValue).call().isValid()); + QVERIFY(!QScriptValue(QScriptValue::NullValue).call().isValid()); +} + +static QScriptValue ctorReturningUndefined(QScriptContext *ctx, QScriptEngine *) +{ + ctx->thisObject().setProperty("foo", 123); + return QScriptValue(QScriptValue::UndefinedValue); +} + +static QScriptValue ctorReturningNewObject(QScriptContext *, QScriptEngine *eng) +{ + QScriptValue result = eng->newObject(); + result.setProperty("bar", 456); + return result; } void tst_QScriptValue::construct() @@ -2460,11 +2531,36 @@ void tst_QScriptValue::construct() QScriptEngine eng; { - QScriptValue fun = eng.evaluate("function () { }"); + QScriptValue fun = eng.evaluate("(function () { this.foo = 123; })"); QVERIFY(fun.isFunction()); QScriptValue ret = fun.construct(); QVERIFY(ret.isObject()); QVERIFY(ret.instanceOf(fun)); + QCOMPARE(ret.property("foo").toInt32(), 123); + } + // returning a different object overrides the default-constructed one + { + QScriptValue fun = eng.evaluate("(function () { return { bar: 456 }; })"); + QVERIFY(fun.isFunction()); + QScriptValue ret = fun.construct(); + QVERIFY(ret.isObject()); + QVERIFY(!ret.instanceOf(fun)); + QCOMPARE(ret.property("bar").toInt32(), 456); + } + + { + QScriptValue fun = eng.newFunction(ctorReturningUndefined); + QScriptValue ret = fun.construct(); + QVERIFY(ret.isObject()); + QVERIFY(ret.instanceOf(fun)); + QCOMPARE(ret.property("foo").toInt32(), 123); + } + { + QScriptValue fun = eng.newFunction(ctorReturningNewObject); + QScriptValue ret = fun.construct(); + QVERIFY(ret.isObject()); + QVERIFY(!ret.instanceOf(fun)); + QCOMPARE(ret.property("bar").toInt32(), 456); } QScriptValue Number = eng.evaluate("Number"); @@ -2479,7 +2575,7 @@ void tst_QScriptValue::construct() // test that internal prototype is set correctly { - QScriptValue fun = eng.evaluate("function() { return this.__proto__; }"); + QScriptValue fun = eng.evaluate("(function() { return this.__proto__; })"); QCOMPARE(fun.isFunction(), true); QCOMPARE(fun.property("prototype").isObject(), true); QScriptValue ret = fun.construct(); @@ -2488,14 +2584,14 @@ void tst_QScriptValue::construct() // test that we return the new object even if a non-object value is returned from the function { - QScriptValue fun = eng.evaluate("function() { return 123; }"); + QScriptValue fun = eng.evaluate("(function() { return 123; })"); QCOMPARE(fun.isFunction(), true); QScriptValue ret = fun.construct(); QCOMPARE(ret.isObject(), true); } { - QScriptValue fun = eng.evaluate("function() { throw new Error('foo'); }"); + QScriptValue fun = eng.evaluate("(function() { throw new Error('foo'); })"); QCOMPARE(fun.isFunction(), true); QScriptValue ret = fun.construct(); QCOMPARE(ret.isError(), true); @@ -2507,13 +2603,17 @@ void tst_QScriptValue::construct() QCOMPARE(inv.construct().isValid(), false); { - QScriptValue fun = eng.evaluate("function() { return arguments; }"); + QScriptValue fun = eng.evaluate("(function() { return arguments; })"); + QVERIFY(fun.isFunction()); QScriptValue array = eng.newArray(3); array.setProperty(0, QScriptValue(&eng, 123.0)); array.setProperty(1, QScriptValue(&eng, 456.0)); array.setProperty(2, QScriptValue(&eng, 789.0)); // construct with single array object as arguments QScriptValue ret = fun.construct(array); + QVERIFY(!eng.hasUncaughtException()); + QVERIFY(ret.isValid()); + QVERIFY(ret.isObject()); QCOMPARE(ret.property(0).strictlyEquals(array.property(0)), true); QCOMPARE(ret.property(1).strictlyEquals(array.property(1)), true); QCOMPARE(ret.property(2).strictlyEquals(array.property(2)), true); @@ -2536,6 +2636,13 @@ void tst_QScriptValue::construct() QScriptValue ret5 = fun.construct(QScriptValue(&eng, 123.0)); QCOMPARE(ret5.isError(), true); } + + // construct on things that are not functions + QVERIFY(!QScriptValue(false).construct().isValid()); + QVERIFY(!QScriptValue(123).construct().isValid()); + QVERIFY(!QScriptValue(QString::fromLatin1("ciao")).construct().isValid()); + QVERIFY(!QScriptValue(QScriptValue::UndefinedValue).construct().isValid()); + QVERIFY(!QScriptValue(QScriptValue::NullValue).construct().isValid()); } void tst_QScriptValue::lessThan() @@ -2728,10 +2835,25 @@ void tst_QScriptValue::equals() QScriptValue qobj2 = eng.newQObject(this); QVERIFY(qobj1.equals(qobj2)); // compares the QObject pointers + QScriptValue compareFun = eng.evaluate("(function(a, b) { return a == b; })"); + QVERIFY(compareFun.isFunction()); + { + QScriptValue ret = compareFun.call(QScriptValue(), QScriptValueList() << qobj1 << qobj2); + QVERIFY(ret.isBool()); + QEXPECT_FAIL("", "In JSC back-end, == on QObject wrappers doesn't work", Continue); + QVERIFY(ret.toBool()); + } + { QScriptValue var1 = eng.newVariant(QVariant(false)); QScriptValue var2 = eng.newVariant(QVariant(false)); QVERIFY(var1.equals(var2)); + { + QScriptValue ret = compareFun.call(QScriptValue(), QScriptValueList() << var1 << var2); + QVERIFY(ret.isBool()); + QEXPECT_FAIL("", "In JSC back-end, == on QVariant wrappers doesn't work", Continue); + QVERIFY(ret.toBool()); + } } { QScriptValue var1 = eng.newVariant(QVariant(false)); @@ -2951,165 +3073,165 @@ void tst_QScriptValue::prettyPrinter_data() { QTest::addColumn<QString>("function"); QTest::addColumn<QString>("expected"); - QTest::newRow("function() { }") << QString("function() { }") << QString("function() {}"); - QTest::newRow("function foo() { }") << QString("(function foo() { })") << QString("function foo() {}"); - QTest::newRow("function foo(bar) { }") << QString("(function foo(bar) { })") << QString("function foo(bar) {}"); - QTest::newRow("function foo(bar, baz) { }") << QString("(function foo(bar, baz) { })") << QString("function foo(bar, baz) {}"); - QTest::newRow("this") << QString("function() { this; }") << QString("function() {\n this;\n}"); - QTest::newRow("identifier") << QString("function(a) { a; }") << QString("function(a) {\n a;\n}"); - QTest::newRow("null") << QString("function() { null; }") << QString("function() {\n null;\n}"); - QTest::newRow("true") << QString("function() { true; }") << QString("function() {\n true;\n}"); - QTest::newRow("false") << QString("function() { false; }") << QString("function() {\n false;\n}"); - QTest::newRow("string") << QString("function() { 'test'; }") << QString("function() {\n \"test\";\n}"); - QTest::newRow("string") << QString("function() { \"test\"; }") << QString("function() {\n \"test\";\n}"); - QTest::newRow("number") << QString("function() { 123; }") << QString("function() {\n 123;\n}"); - QTest::newRow("number") << QString("function() { 123.456; }") << QString("function() {\n 123.456;\n}"); - QTest::newRow("regexp") << QString("function() { /hello/; }") << QString("function() {\n /hello/;\n}"); - QTest::newRow("regexp") << QString("function() { /hello/gim; }") << QString("function() {\n /hello/gim;\n}"); - QTest::newRow("array") << QString("function() { []; }") << QString("function() {\n [];\n}"); - QTest::newRow("array") << QString("function() { [10]; }") << QString("function() {\n [10];\n}"); - QTest::newRow("array") << QString("function() { [10, 20, 30]; }") << QString("function() {\n [10, 20, 30];\n}"); - QTest::newRow("array") << QString("function() { [10, 20, , 40]; }") << QString("function() {\n [10, 20, , 40];\n}"); - QTest::newRow("array") << QString("function() { [,]; }") << QString("function() {\n [, ];\n}"); - QTest::newRow("array") << QString("function() { [, 10]; }") << QString("function() {\n [, 10];\n}"); - QTest::newRow("array") << QString("function() { [, 10, ]; }") << QString("function() {\n [, 10];\n}"); - QTest::newRow("array") << QString("function() { [, 10, ,]; }") << QString("function() {\n [, 10, ];\n}"); - QTest::newRow("array") << QString("function() { [[10], [20]]; }") << QString("function() {\n [[10], [20]];\n}"); - QTest::newRow("member") << QString("function() { a.b; }") << QString("function() {\n a.b;\n}"); - QTest::newRow("member") << QString("function() { a.b.c; }") << QString("function() {\n a.b.c;\n}"); - QTest::newRow("call") << QString("function() { f(); }") << QString("function() {\n f();\n}"); - QTest::newRow("call") << QString("function() { f(a); }") << QString("function() {\n f(a);\n}"); - QTest::newRow("call") << QString("function() { f(a, b); }") << QString("function() {\n f(a, b);\n}"); - QTest::newRow("new") << QString("function() { new C(); }") << QString("function() {\n new C();\n}"); - QTest::newRow("new") << QString("function() { new C(a); }") << QString("function() {\n new C(a);\n}"); - QTest::newRow("new") << QString("function() { new C(a, b); }") << QString("function() {\n new C(a, b);\n}"); - QTest::newRow("++") << QString("function() { a++; }") << QString("function() {\n a++;\n}"); - QTest::newRow("++") << QString("function() { ++a; }") << QString("function() {\n ++a;\n}"); - QTest::newRow("--") << QString("function() { a--; }") << QString("function() {\n a--;\n}"); - QTest::newRow("--") << QString("function() { --a; }") << QString("function() {\n --a;\n}"); - QTest::newRow("delete") << QString("function() { delete a; }") << QString("function() {\n delete a;\n}"); - QTest::newRow("void") << QString("function() { void a; }") << QString("function() {\n void a;\n}"); - QTest::newRow("typeof") << QString("function() { typeof a; }") << QString("function() {\n typeof a;\n}"); - QTest::newRow("+") << QString("function() { +a; }") << QString("function() {\n +a;\n}"); - QTest::newRow("-") << QString("function() { -a; }") << QString("function() {\n -a;\n}"); - QTest::newRow("~") << QString("function() { ~a; }") << QString("function() {\n ~a;\n}"); - QTest::newRow("!") << QString("function() { !a; }") << QString("function() {\n !a;\n}"); - QTest::newRow("+") << QString("function() { a + b; }") << QString("function() {\n a + b;\n}"); - QTest::newRow("&&") << QString("function() { a && b; }") << QString("function() {\n a && b;\n}"); - QTest::newRow("&=") << QString("function() { a &= b; }") << QString("function() {\n a &= b;\n}"); - QTest::newRow("=") << QString("function() { a = b; }") << QString("function() {\n a = b;\n}"); - QTest::newRow("&") << QString("function() { a & b; }") << QString("function() {\n a & b;\n}"); - QTest::newRow("|") << QString("function() { a | b; }") << QString("function() {\n a | b;\n}"); - QTest::newRow("^") << QString("function() { a ^ b; }") << QString("function() {\n a ^ b;\n}"); - QTest::newRow("-=") << QString("function() { a -= b; }") << QString("function() {\n a -= b;\n}"); - QTest::newRow("/") << QString("function() { a / b; }") << QString("function() {\n a / b;\n}"); - QTest::newRow("/=") << QString("function() { a /= b; }") << QString("function() {\n a /= b;\n}"); - QTest::newRow("==") << QString("function() { a == b; }") << QString("function() {\n a == b;\n}"); - QTest::newRow(">=") << QString("function() { a >= b; }") << QString("function() {\n a >= b;\n}"); - QTest::newRow(">") << QString("function() { a > b; }") << QString("function() {\n a > b;\n}"); - QTest::newRow("in") << QString("function() { a in b; }") << QString("function() {\n a in b;\n}"); - QTest::newRow("+=") << QString("function() { a += b; }") << QString("function() {\n a += b;\n}"); - QTest::newRow("instanceof") << QString("function() { a instanceof b; }") << QString("function() {\n a instanceof b;\n}"); - QTest::newRow("<=") << QString("function() { a <= b; }") << QString("function() {\n a <= b;\n}"); - QTest::newRow("<<") << QString("function() { a << b; }") << QString("function() {\n a << b;\n}"); - QTest::newRow("<<=") << QString("function() { a <<= b; }") << QString("function() {\n a <<= b;\n}"); - QTest::newRow("<") << QString("function() { a < b; }") << QString("function() {\n a < b;\n}"); - QTest::newRow("%") << QString("function() { a % b; }") << QString("function() {\n a % b;\n}"); - QTest::newRow("%=") << QString("function() { a %= b; }") << QString("function() {\n a %= b;\n}"); - QTest::newRow("*") << QString("function() { a * b; }") << QString("function() {\n a * b;\n}"); - QTest::newRow("*=") << QString("function() { a *= b; }") << QString("function() {\n a *= b;\n}"); - QTest::newRow("!=") << QString("function() { a != b; }") << QString("function() {\n a != b;\n}"); - QTest::newRow("||") << QString("function() { a || b; }") << QString("function() {\n a || b;\n}"); - QTest::newRow("|=") << QString("function() { a |= b; }") << QString("function() {\n a |= b;\n}"); - QTest::newRow(">>") << QString("function() { a >> b; }") << QString("function() {\n a >> b;\n}"); - QTest::newRow(">>=") << QString("function() { a >>= b; }") << QString("function() {\n a >>= b;\n}"); - QTest::newRow("===") << QString("function() { a === b; }") << QString("function() {\n a === b;\n}"); - QTest::newRow("!==") << QString("function() { a !== b; }") << QString("function() {\n a !== b;\n}"); - QTest::newRow("-") << QString("function() { a - b; }") << QString("function() {\n a - b;\n}"); - QTest::newRow(">>>") << QString("function() { a >>> b; }") << QString("function() {\n a >>> b;\n}"); - QTest::newRow(">>>=") << QString("function() { a >>>= b; }") << QString("function() {\n a >>>= b;\n}"); - QTest::newRow("^=") << QString("function() { a ^= b; }") << QString("function() {\n a ^= b;\n}"); - QTest::newRow("? :") << QString("function() { a ? b : c; }") << QString("function() {\n a ? b : c;\n}"); - QTest::newRow("a; b; c") << QString("function() { a; b; c; }") << QString("function() {\n a;\n b;\n c;\n}"); - QTest::newRow("var a;") << QString("function() { var a; }") << QString("function() {\n var a;\n}"); - QTest::newRow("var a, b;") << QString("function() { var a, b; }") << QString("function() {\n var a, b;\n}"); - QTest::newRow("var a = 10;") << QString("function() { var a = 10; }") << QString("function() {\n var a = 10;\n}"); - QTest::newRow("var a, b = 20;") << QString("function() { var a, b = 20; }") << QString("function() {\n var a, b = 20;\n}"); - QTest::newRow("var a = 10, b = 20;") << QString("function() { var a = 10, b = 20; }") << QString("function() {\n var a = 10, b = 20;\n}"); - QTest::newRow("if") << QString("function() { if (a) b; }") << QString("function() {\n if (a) {\n b;\n }\n}"); - QTest::newRow("if") << QString("function() { if (a) { b; c; } }") << QString("function() {\n if (a) {\n b;\n c;\n }\n}"); - QTest::newRow("if-else") << QString("function() { if (a) b; else c; }") << QString("function() {\n if (a) {\n b;\n } else {\n c;\n }\n}"); - QTest::newRow("if-else") << QString("function() { if (a) { b; c; } else { d; e; } }") << QString("function() {\n if (a) {\n b;\n c;\n } else {\n d;\n e;\n }\n}"); - QTest::newRow("do-while") << QString("function() { do { a; } while (b); }") << QString("function() {\n do {\n a;\n } while (b);\n}"); - QTest::newRow("do-while") << QString("function() { do { a; b; c; } while (d); }") << QString("function() {\n do {\n a;\n b;\n c;\n } while (d);\n}"); - QTest::newRow("while") << QString("function() { while (a) { b; } }") << QString("function() {\n while (a) {\n b;\n }\n}"); - QTest::newRow("while") << QString("function() { while (a) { b; c; } }") << QString("function() {\n while (a) {\n b;\n c;\n }\n}"); - QTest::newRow("for") << QString("function() { for (a; b; c) { } }") << QString("function() {\n for (a; b; c) {\n \n }\n}"); - QTest::newRow("for") << QString("function() { for (; a; b) { } }") << QString("function() {\n for (; a; b) {\n \n }\n}"); - QTest::newRow("for") << QString("function() { for (; ; a) { } }") << QString("function() {\n for (; ; a) {\n \n }\n}"); - QTest::newRow("for") << QString("function() { for (; ; ) { } }") << QString("function() {\n for (; ; ) {\n \n }\n}"); - QTest::newRow("for") << QString("function() { for (var a; b; c) { } }") << QString("function() {\n for (var a; b; c) {\n \n }\n}"); - QTest::newRow("for") << QString("function() { for (var a, b, c; d; e) { } }") << QString("function() {\n for (var a, b, c; d; e) {\n \n }\n}"); - QTest::newRow("continue") << QString("function() { for (; ; ) { continue; } }") << QString("function() {\n for (; ; ) {\n continue;\n }\n}"); - QTest::newRow("continue") << QString("function() { for (; ; ) { continue label; } }") << QString("function() {\n for (; ; ) {\n continue label;\n }\n}"); - QTest::newRow("break") << QString("function() { for (; ; ) { break; } }") << QString("function() {\n for (; ; ) {\n break;\n }\n}"); - QTest::newRow("break") << QString("function() { for (; ; ) { break label; } }") << QString("function() {\n for (; ; ) {\n break label;\n }\n}"); - QTest::newRow("return") << QString("function() { return; }") << QString("function() {\n return;\n}"); - QTest::newRow("return") << QString("function() { return 10; }") << QString("function() {\n return 10;\n}"); - QTest::newRow("with") << QString("function() { with (a) { b; } }") << QString("function() {\n with (a) {\n b;\n }\n}"); - QTest::newRow("with") << QString("function() { with (a) { b; c; } }") << QString("function() {\n with (a) {\n b;\n c;\n }\n}"); - QTest::newRow("switch") << QString("function() { switch (a) { } }") << QString("function() {\n switch (a) {\n \n }\n}"); - QTest::newRow("switch") << QString("function() { switch (a) { case 1: ; } }") << QString("function() {\n switch (a) {\n case 1:\n ;\n }\n}"); - QTest::newRow("switch") << QString("function() { switch (a) { case 1: b; break; } }") << QString("function() {\n switch (a) {\n case 1:\n b;\n break;\n }\n}"); - QTest::newRow("switch") << QString("function() { switch (a) { case 1: b; break; case 2: break; } }") << QString("function() {\n switch (a) {\n case 1:\n b;\n break;\n case 2:\n break;\n }\n}"); - QTest::newRow("switch") << QString("function() { switch (a) { case 1: case 2: ; } }") << QString("function() {\n switch (a) {\n case 1:\n case 2:\n ;\n }\n}"); - QTest::newRow("switch") << QString("function() { switch (a) { case 1: default: ; } }") << QString("function() {\n switch (a) {\n case 1:\n default:\n ;\n }\n}"); - QTest::newRow("switch") << QString("function() { switch (a) { case 1: default: ; case 3: ; } }") << QString("function() {\n switch (a) {\n case 1:\n default:\n ;\n case 3:\n ;\n }\n}"); - QTest::newRow("label") << QString("function() { a: b; }") << QString("function() {\n a: b;\n}"); - QTest::newRow("throw") << QString("function() { throw a; }") << QString("function() {\n throw a;\n}"); - QTest::newRow("try-catch") << QString("function() { try { a; } catch (e) { b; } }") << QString("function() {\n try {\n a;\n } catch (e) {\n b;\n }\n}"); - QTest::newRow("try-finally") << QString("function() { try { a; } finally { b; } }") << QString("function() {\n try {\n a;\n } finally {\n b;\n }\n}"); - QTest::newRow("try-catch-finally") << QString("function() { try { a; } catch (e) { b; } finally { c; } }") << QString("function() {\n try {\n a;\n } catch (e) {\n b;\n } finally {\n c;\n }\n}"); - QTest::newRow("a + b + c + d") << QString("function() { a + b + c + d; }") << QString("function() {\n a + b + c + d;\n}"); - QTest::newRow("a + b - c") << QString("function() { a + b - c; }") << QString("function() {\n a + b - c;\n}"); - QTest::newRow("a + -b") << QString("function() { a + -b; }") << QString("function() {\n a + -b;\n}"); - QTest::newRow("a + ~b") << QString("function() { a + ~b; }") << QString("function() {\n a + ~b;\n}"); - QTest::newRow("a + !b") << QString("function() { a + !b; }") << QString("function() {\n a + !b;\n}"); - QTest::newRow("a + +b") << QString("function() { a + +b; }") << QString("function() {\n a + +b;\n}"); - QTest::newRow("(a + b) - c") << QString("function() { (a + b) - c; }") << QString("function() {\n a + b - c;\n}"); - QTest::newRow("(a - b + c") << QString("function() { a - b + c; }") << QString("function() {\n a - b + c;\n}"); - QTest::newRow("(a - (b + c)") << QString("function() { a - (b + c); }") << QString("function() {\n a - (b + c);\n}"); - QTest::newRow("a + -(b + c)") << QString("function() { a + -(b + c); }") << QString("function() {\n a + -(b + c);\n}"); - QTest::newRow("a + ~(b + c)") << QString("function() { a + ~(b + c); }") << QString("function() {\n a + ~(b + c);\n}"); - QTest::newRow("a + !(b + c)") << QString("function() { a + !(b + c); }") << QString("function() {\n a + !(b + c);\n}"); - QTest::newRow("a + +(b + c)") << QString("function() { a + +(b + c); }") << QString("function() {\n a + +(b + c);\n}"); - QTest::newRow("a + b * c") << QString("function() { a + b * c; }") << QString("function() {\n a + b * c;\n}"); - QTest::newRow("(a + b) * c") << QString("function() { (a + b) * c; }") << QString("function() {\n (a + b) * c;\n}"); - QTest::newRow("(a + b) * (c + d)") << QString("function() { (a + b) * (c + d); }") << QString("function() {\n (a + b) * (c + d);\n}"); - QTest::newRow("a + (b * c)") << QString("function() { a + (b * c); }") << QString("function() {\n a + b * c;\n}"); - QTest::newRow("a + (b / c)") << QString("function() { a + (b / c); }") << QString("function() {\n a + b / c;\n}"); - QTest::newRow("(a / b) * c") << QString("function() { (a / b) * c; }") << QString("function() {\n a / b * c;\n}"); - QTest::newRow("a / (b * c)") << QString("function() { a / (b * c); }") << QString("function() {\n a / (b * c);\n}"); - QTest::newRow("a / (b % c)") << QString("function() { a / (b % c); }") << QString("function() {\n a / (b % c);\n}"); - QTest::newRow("a && b || c") << QString("function() { a && b || c; }") << QString("function() {\n a && b || c;\n}"); - QTest::newRow("a && (b || c)") << QString("function() { a && (b || c); }") << QString("function() {\n a && (b || c);\n}"); - QTest::newRow("a & b | c") << QString("function() { a & b | c; }") << QString("function() {\n a & b | c;\n}"); - QTest::newRow("a & (b | c)") << QString("function() { a & (b | c); }") << QString("function() {\n a & (b | c);\n}"); - QTest::newRow("a & b | c ^ d") << QString("function() { a & b | c ^ d; }") << QString("function() {\n a & b | c ^ d;\n}"); - QTest::newRow("a & (b | c ^ d)") << QString("function() { a & (b | c ^ d); }") << QString("function() {\n a & (b | c ^ d);\n}"); - QTest::newRow("(a & b | c) ^ d") << QString("function() { (a & b | c) ^ d; }") << QString("function() {\n (a & b | c) ^ d;\n}"); - QTest::newRow("a << b + c") << QString("function() { a << b + c; }") << QString("function() {\n a << b + c;\n}"); - QTest::newRow("(a << b) + c") << QString("function() { (a << b) + c; }") << QString("function() {\n (a << b) + c;\n}"); - QTest::newRow("a >> b + c") << QString("function() { a >> b + c; }") << QString("function() {\n a >> b + c;\n}"); - QTest::newRow("(a >> b) + c") << QString("function() { (a >> b) + c; }") << QString("function() {\n (a >> b) + c;\n}"); - QTest::newRow("a >>> b + c") << QString("function() { a >>> b + c; }") << QString("function() {\n a >>> b + c;\n}"); - QTest::newRow("(a >>> b) + c") << QString("function() { (a >>> b) + c; }") << QString("function() {\n (a >>> b) + c;\n}"); - QTest::newRow("a == b || c != d") << QString("function() { a == b || c != d; }") << QString("function() {\n a == b || c != d;\n}"); - QTest::newRow("a == (b || c != d)") << QString("function() { a == (b || c != d); }") << QString("function() {\n a == (b || c != d);\n}"); - QTest::newRow("a === b || c !== d") << QString("function() { a === b || c !== d; }") << QString("function() {\n a === b || c !== d;\n}"); - QTest::newRow("a === (b || c !== d)") << QString("function() { a === (b || c !== d); }") << QString("function() {\n a === (b || c !== d);\n}"); - QTest::newRow("a &= b + c") << QString("function() { a &= b + c; }") << QString("function() {\n a &= b + c;\n}"); - QTest::newRow("debugger") << QString("function() { debugger }") << QString("function() {\n debugger;\n}"); + QTest::newRow("function() { }") << QString("function() { }") << QString("function () { }"); + QTest::newRow("function foo() { }") << QString("(function foo() { })") << QString("function foo() { }"); + QTest::newRow("function foo(bar) { }") << QString("(function foo(bar) { })") << QString("function foo(bar) { }"); + QTest::newRow("function foo(bar, baz) { }") << QString("(function foo(bar, baz) { })") << QString("function foo(bar, baz) { }"); + QTest::newRow("this") << QString("function() { this; }") << QString("function () { this; }"); + QTest::newRow("identifier") << QString("function(a) { a; }") << QString("function (a) { a; }"); + QTest::newRow("null") << QString("function() { null; }") << QString("function () { null; }"); + QTest::newRow("true") << QString("function() { true; }") << QString("function () { true; }"); + QTest::newRow("false") << QString("function() { false; }") << QString("function () { false; }"); + QTest::newRow("string") << QString("function() { 'test'; }") << QString("function () { \'test\'; }"); + QTest::newRow("string") << QString("function() { \"test\"; }") << QString("function () { \"test\"; }"); + QTest::newRow("number") << QString("function() { 123; }") << QString("function () { 123; }"); + QTest::newRow("number") << QString("function() { 123.456; }") << QString("function () { 123.456; }"); + QTest::newRow("regexp") << QString("function() { /hello/; }") << QString("function () { /hello/; }"); + QTest::newRow("regexp") << QString("function() { /hello/gim; }") << QString("function () { /hello/gim; }"); + QTest::newRow("array") << QString("function() { []; }") << QString("function () { []; }"); + QTest::newRow("array") << QString("function() { [10]; }") << QString("function () { [10]; }"); + QTest::newRow("array") << QString("function() { [10, 20, 30]; }") << QString("function () { [10, 20, 30]; }"); + QTest::newRow("array") << QString("function() { [10, 20, , 40]; }") << QString("function () { [10, 20, , 40]; }"); + QTest::newRow("array") << QString("function() { [,]; }") << QString("function () { [,]; }"); + QTest::newRow("array") << QString("function() { [, 10]; }") << QString("function () { [, 10]; }"); + QTest::newRow("array") << QString("function() { [, 10, ]; }") << QString("function () { [, 10, ]; }"); + QTest::newRow("array") << QString("function() { [, 10, ,]; }") << QString("function () { [, 10, ,]; }"); + QTest::newRow("array") << QString("function() { [[10], [20]]; }") << QString("function () { [[10], [20]]; }"); + QTest::newRow("member") << QString("function() { a.b; }") << QString("function () { a.b; }"); + QTest::newRow("member") << QString("function() { a.b.c; }") << QString("function () { a.b.c; }"); + QTest::newRow("call") << QString("function() { f(); }") << QString("function () { f(); }"); + QTest::newRow("call") << QString("function() { f(a); }") << QString("function () { f(a); }"); + QTest::newRow("call") << QString("function() { f(a, b); }") << QString("function () { f(a, b); }"); + QTest::newRow("new") << QString("function() { new C(); }") << QString("function () { new C(); }"); + QTest::newRow("new") << QString("function() { new C(a); }") << QString("function () { new C(a); }"); + QTest::newRow("new") << QString("function() { new C(a, b); }") << QString("function () { new C(a, b); }"); + QTest::newRow("++") << QString("function() { a++; }") << QString("function () { a++; }"); + QTest::newRow("++") << QString("function() { ++a; }") << QString("function () { ++a; }"); + QTest::newRow("--") << QString("function() { a--; }") << QString("function () { a--; }"); + QTest::newRow("--") << QString("function() { --a; }") << QString("function () { --a; }"); + QTest::newRow("delete") << QString("function() { delete a; }") << QString("function () { delete a; }"); + QTest::newRow("void") << QString("function() { void a; }") << QString("function () { void a; }"); + QTest::newRow("typeof") << QString("function() { typeof a; }") << QString("function () { typeof a; }"); + QTest::newRow("+") << QString("function() { +a; }") << QString("function () { +a; }"); + QTest::newRow("-") << QString("function() { -a; }") << QString("function () { -a; }"); + QTest::newRow("~") << QString("function() { ~a; }") << QString("function () { ~a; }"); + QTest::newRow("!") << QString("function() { !a; }") << QString("function () { !a; }"); + QTest::newRow("+") << QString("function() { a + b; }") << QString("function () { a + b; }"); + QTest::newRow("&&") << QString("function() { a && b; }") << QString("function () { a && b; }"); + QTest::newRow("&=") << QString("function() { a &= b; }") << QString("function () { a &= b; }"); + QTest::newRow("=") << QString("function() { a = b; }") << QString("function () { a = b; }"); + QTest::newRow("&") << QString("function() { a & b; }") << QString("function () { a & b; }"); + QTest::newRow("|") << QString("function() { a | b; }") << QString("function () { a | b; }"); + QTest::newRow("^") << QString("function() { a ^ b; }") << QString("function () { a ^ b; }"); + QTest::newRow("-=") << QString("function() { a -= b; }") << QString("function () { a -= b; }"); + QTest::newRow("/") << QString("function() { a / b; }") << QString("function () { a / b; }"); + QTest::newRow("/=") << QString("function() { a /= b; }") << QString("function () { a /= b; }"); + QTest::newRow("==") << QString("function() { a == b; }") << QString("function () { a == b; }"); + QTest::newRow(">=") << QString("function() { a >= b; }") << QString("function () { a >= b; }"); + QTest::newRow(">") << QString("function() { a > b; }") << QString("function () { a > b; }"); + QTest::newRow("in") << QString("function() { a in b; }") << QString("function () { a in b; }"); + QTest::newRow("+=") << QString("function() { a += b; }") << QString("function () { a += b; }"); + QTest::newRow("instanceof") << QString("function() { a instanceof b; }") << QString("function () { a instanceof b; }"); + QTest::newRow("<=") << QString("function() { a <= b; }") << QString("function () { a <= b; }"); + QTest::newRow("<<") << QString("function() { a << b; }") << QString("function () { a << b; }"); + QTest::newRow("<<=") << QString("function() { a <<= b; }") << QString("function () { a <<= b; }"); + QTest::newRow("<") << QString("function() { a < b; }") << QString("function () { a < b; }"); + QTest::newRow("%") << QString("function() { a % b; }") << QString("function () { a % b; }"); + QTest::newRow("%=") << QString("function() { a %= b; }") << QString("function () { a %= b; }"); + QTest::newRow("*") << QString("function() { a * b; }") << QString("function () { a * b; }"); + QTest::newRow("*=") << QString("function() { a *= b; }") << QString("function () { a *= b; }"); + QTest::newRow("!=") << QString("function() { a != b; }") << QString("function () { a != b; }"); + QTest::newRow("||") << QString("function() { a || b; }") << QString("function () { a || b; }"); + QTest::newRow("|=") << QString("function() { a |= b; }") << QString("function () { a |= b; }"); + QTest::newRow(">>") << QString("function() { a >> b; }") << QString("function () { a >> b; }"); + QTest::newRow(">>=") << QString("function() { a >>= b; }") << QString("function () { a >>= b; }"); + QTest::newRow("===") << QString("function() { a === b; }") << QString("function () { a === b; }"); + QTest::newRow("!==") << QString("function() { a !== b; }") << QString("function () { a !== b; }"); + QTest::newRow("-") << QString("function() { a - b; }") << QString("function () { a - b; }"); + QTest::newRow(">>>") << QString("function() { a >>> b; }") << QString("function () { a >>> b; }"); + QTest::newRow(">>>=") << QString("function() { a >>>= b; }") << QString("function () { a >>>= b; }"); + QTest::newRow("^=") << QString("function() { a ^= b; }") << QString("function () { a ^= b; }"); + QTest::newRow("? :") << QString("function() { a ? b : c; }") << QString("function () { a ? b : c; }"); + QTest::newRow("a; b; c") << QString("function() { a; b; c; }") << QString("function () { a; b; c; }"); + QTest::newRow("var a;") << QString("function() { var a; }") << QString("function () { var a; }"); + QTest::newRow("var a, b;") << QString("function() { var a, b; }") << QString("function () { var a, b; }"); + QTest::newRow("var a = 10;") << QString("function() { var a = 10; }") << QString("function () { var a = 10; }"); + QTest::newRow("var a, b = 20;") << QString("function() { var a, b = 20; }") << QString("function () { var a, b = 20; }"); + QTest::newRow("var a = 10, b = 20;") << QString("function() { var a = 10, b = 20; }") << QString("function () { var a = 10, b = 20; }"); + QTest::newRow("if") << QString("function() { if (a) b; }") << QString("function () { if (a) b; }"); + QTest::newRow("if") << QString("function() { if (a) { b; c; } }") << QString("function () { if (a) { b; c; } }"); + QTest::newRow("if-else") << QString("function() { if (a) b; else c; }") << QString("function () { if (a) b; else c; }"); + QTest::newRow("if-else") << QString("function() { if (a) { b; c; } else { d; e; } }") << QString("function () { if (a) { b; c; } else { d; e; } }"); + QTest::newRow("do-while") << QString("function() { do { a; } while (b); }") << QString("function () { do { a; } while (b); }"); + QTest::newRow("do-while") << QString("function() { do { a; b; c; } while (d); }") << QString("function () { do { a; b; c; } while (d); }"); + QTest::newRow("while") << QString("function() { while (a) { b; } }") << QString("function () { while (a) { b; } }"); + QTest::newRow("while") << QString("function() { while (a) { b; c; } }") << QString("function () { while (a) { b; c; } }"); + QTest::newRow("for") << QString("function() { for (a; b; c) { } }") << QString("function () { for (a; b; c) { } }"); + QTest::newRow("for") << QString("function() { for (; a; b) { } }") << QString("function () { for (; a; b) { } }"); + QTest::newRow("for") << QString("function() { for (; ; a) { } }") << QString("function () { for (; ; a) { } }"); + QTest::newRow("for") << QString("function() { for (; ; ) { } }") << QString("function () { for (; ; ) { } }"); + QTest::newRow("for") << QString("function() { for (var a; b; c) { } }") << QString("function () { for (var a; b; c) { } }"); + QTest::newRow("for") << QString("function() { for (var a, b, c; d; e) { } }") << QString("function () { for (var a, b, c; d; e) { } }"); + QTest::newRow("continue") << QString("function() { for (; ; ) { continue; } }") << QString("function () { for (; ; ) { continue; } }"); + QTest::newRow("continue") << QString("function() { for (; ; ) { continue label; } }") << QString("function () { for (; ; ) { continue label; } }"); + QTest::newRow("break") << QString("function() { for (; ; ) { break; } }") << QString("function () { for (; ; ) { break; } }"); + QTest::newRow("break") << QString("function() { for (; ; ) { break label; } }") << QString("function () { for (; ; ) { break label; } }"); + QTest::newRow("return") << QString("function() { return; }") << QString("function () { return; }"); + QTest::newRow("return") << QString("function() { return 10; }") << QString("function () { return 10; }"); + QTest::newRow("with") << QString("function() { with (a) { b; } }") << QString("function () { with (a) { b; } }"); + QTest::newRow("with") << QString("function() { with (a) { b; c; } }") << QString("function () { with (a) { b; c; } }"); + QTest::newRow("switch") << QString("function() { switch (a) { } }") << QString("function () { switch (a) { } }"); + QTest::newRow("switch") << QString("function() { switch (a) { case 1: ; } }") << QString("function () { switch (a) { case 1: ; } }"); + QTest::newRow("switch") << QString("function() { switch (a) { case 1: b; break; } }") << QString("function () { switch (a) { case 1: b; break; } }"); + QTest::newRow("switch") << QString("function() { switch (a) { case 1: b; break; case 2: break; } }") << QString("function () { switch (a) { case 1: b; break; case 2: break; } }"); + QTest::newRow("switch") << QString("function() { switch (a) { case 1: case 2: ; } }") << QString("function () { switch (a) { case 1: case 2: ; } }"); + QTest::newRow("switch") << QString("function() { switch (a) { case 1: default: ; } }") << QString("function () { switch (a) { case 1: default: ; } }"); + QTest::newRow("switch") << QString("function() { switch (a) { case 1: default: ; case 3: ; } }") << QString("function () { switch (a) { case 1: default: ; case 3: ; } }"); + QTest::newRow("label") << QString("function() { a: b; }") << QString("function () { a: b; }"); + QTest::newRow("throw") << QString("function() { throw a; }") << QString("function () { throw a; }"); + QTest::newRow("try-catch") << QString("function() { try { a; } catch (e) { b; } }") << QString("function () { try { a; } catch (e) { b; } }"); + QTest::newRow("try-finally") << QString("function() { try { a; } finally { b; } }") << QString("function () { try { a; } finally { b; } }"); + QTest::newRow("try-catch-finally") << QString("function() { try { a; } catch (e) { b; } finally { c; } }") << QString("function () { try { a; } catch (e) { b; } finally { c; } }"); + QTest::newRow("a + b + c + d") << QString("function() { a + b + c + d; }") << QString("function () { a + b + c + d; }"); + QTest::newRow("a + b - c") << QString("function() { a + b - c; }") << QString("function () { a + b - c; }"); + QTest::newRow("a + -b") << QString("function() { a + -b; }") << QString("function () { a + -b; }"); + QTest::newRow("a + ~b") << QString("function() { a + ~b; }") << QString("function () { a + ~b; }"); + QTest::newRow("a + !b") << QString("function() { a + !b; }") << QString("function () { a + !b; }"); + QTest::newRow("a + +b") << QString("function() { a + +b; }") << QString("function () { a + +b; }"); + QTest::newRow("(a + b) - c") << QString("function() { (a + b) - c; }") << QString("function () { (a + b) - c; }"); + QTest::newRow("(a - b + c") << QString("function() { a - b + c; }") << QString("function () { a - b + c; }"); + QTest::newRow("(a - (b + c)") << QString("function() { a - (b + c); }") << QString("function () { a - (b + c); }"); + QTest::newRow("a + -(b + c)") << QString("function() { a + -(b + c); }") << QString("function () { a + -(b + c); }"); + QTest::newRow("a + ~(b + c)") << QString("function() { a + ~(b + c); }") << QString("function () { a + ~(b + c); }"); + QTest::newRow("a + !(b + c)") << QString("function() { a + !(b + c); }") << QString("function () { a + !(b + c); }"); + QTest::newRow("a + +(b + c)") << QString("function() { a + +(b + c); }") << QString("function () { a + +(b + c); }"); + QTest::newRow("a + b * c") << QString("function() { a + b * c; }") << QString("function () { a + b * c; }"); + QTest::newRow("(a + b) * c") << QString("function() { (a + b) * c; }") << QString("function () { (a + b) * c; }"); + QTest::newRow("(a + b) * (c + d)") << QString("function() { (a + b) * (c + d); }") << QString("function () { (a + b) * (c + d); }"); + QTest::newRow("a + (b * c)") << QString("function() { a + (b * c); }") << QString("function () { a + (b * c); }"); + QTest::newRow("a + (b / c)") << QString("function() { a + (b / c); }") << QString("function () { a + (b / c); }"); + QTest::newRow("(a / b) * c") << QString("function() { (a / b) * c; }") << QString("function () { (a / b) * c; }"); + QTest::newRow("a / (b * c)") << QString("function() { a / (b * c); }") << QString("function () { a / (b * c); }"); + QTest::newRow("a / (b % c)") << QString("function() { a / (b % c); }") << QString("function () { a / (b % c); }"); + QTest::newRow("a && b || c") << QString("function() { a && b || c; }") << QString("function () { a && b || c; }"); + QTest::newRow("a && (b || c)") << QString("function() { a && (b || c); }") << QString("function () { a && (b || c); }"); + QTest::newRow("a & b | c") << QString("function() { a & b | c; }") << QString("function () { a & b | c; }"); + QTest::newRow("a & (b | c)") << QString("function() { a & (b | c); }") << QString("function () { a & (b | c); }"); + QTest::newRow("a & b | c ^ d") << QString("function() { a & b | c ^ d; }") << QString("function () { a & b | c ^ d; }"); + QTest::newRow("a & (b | c ^ d)") << QString("function() { a & (b | c ^ d); }") << QString("function () { a & (b | c ^ d); }"); + QTest::newRow("(a & b | c) ^ d") << QString("function() { (a & b | c) ^ d; }") << QString("function () { (a & b | c) ^ d; }"); + QTest::newRow("a << b + c") << QString("function() { a << b + c; }") << QString("function () { a << b + c; }"); + QTest::newRow("(a << b) + c") << QString("function() { (a << b) + c; }") << QString("function () { (a << b) + c; }"); + QTest::newRow("a >> b + c") << QString("function() { a >> b + c; }") << QString("function () { a >> b + c; }"); + QTest::newRow("(a >> b) + c") << QString("function() { (a >> b) + c; }") << QString("function () { (a >> b) + c; }"); + QTest::newRow("a >>> b + c") << QString("function() { a >>> b + c; }") << QString("function () { a >>> b + c; }"); + QTest::newRow("(a >>> b) + c") << QString("function() { (a >>> b) + c; }") << QString("function () { (a >>> b) + c; }"); + QTest::newRow("a == b || c != d") << QString("function() { a == b || c != d; }") << QString("function () { a == b || c != d; }"); + QTest::newRow("a == (b || c != d)") << QString("function() { a == (b || c != d); }") << QString("function () { a == (b || c != d); }"); + QTest::newRow("a === b || c !== d") << QString("function() { a === b || c !== d; }") << QString("function () { a === b || c !== d; }"); + QTest::newRow("a === (b || c !== d)") << QString("function() { a === (b || c !== d); }") << QString("function () { a === (b || c !== d); }"); + QTest::newRow("a &= b + c") << QString("function() { a &= b + c; }") << QString("function () { a &= b + c; }"); + QTest::newRow("debugger") << QString("function() { debugger }") << QString("function () { debugger; }"); } void tst_QScriptValue::prettyPrinter() @@ -3117,7 +3239,8 @@ void tst_QScriptValue::prettyPrinter() QFETCH(QString, function); QFETCH(QString, expected); QScriptEngine eng; - QScriptValue val = eng.evaluate(function); + QScriptValue val = eng.evaluate("(" + function + ")"); + QVERIFY(val.isFunction()); QString actual = val.toString(); int count = qMin(actual.size(), expected.size()); // qDebug() << actual << expected; @@ -3139,6 +3262,8 @@ void tst_QScriptValue::engineDeleted() QVERIFY(v3.isObject()); QScriptValue v4 = eng->newQObject(this); QVERIFY(v4.isQObject()); + QScriptValue v5 = "Hello"; + QVERIFY(v2.isString()); delete eng; @@ -3150,6 +3275,8 @@ void tst_QScriptValue::engineDeleted() QVERIFY(v3.engine() == 0); QVERIFY(!v4.isValid()); QVERIFY(v4.engine() == 0); + QVERIFY(v5.isValid()); + QVERIFY(v5.engine() == 0); } void tst_QScriptValue::valueOfWithClosure() @@ -3189,6 +3316,17 @@ void tst_QScriptValue::objectId() QVERIFY(eng.objectById(o1.objectId()).strictlyEquals(o1)); QVERIFY(eng.objectById(o2.objectId()).strictlyEquals(o2)); + + qint64 globalObjectId = -1; + { + QScriptValue global = eng.globalObject(); + globalObjectId = global.objectId(); + QVERIFY(globalObjectId != -1); + QVERIFY(eng.objectById(globalObjectId).strictlyEquals(global)); + } + QScriptValue obj = eng.objectById(globalObjectId); + QVERIFY(obj.isObject()); + QVERIFY(obj.strictlyEquals(eng.globalObject())); } QTEST_MAIN(tst_QScriptValue) diff --git a/tests/auto/qscriptvalueiterator/tst_qscriptvalueiterator.cpp b/tests/auto/qscriptvalueiterator/tst_qscriptvalueiterator.cpp index 45e7596..48fac1d 100644 --- a/tests/auto/qscriptvalueiterator/tst_qscriptvalueiterator.cpp +++ b/tests/auto/qscriptvalueiterator/tst_qscriptvalueiterator.cpp @@ -48,6 +48,8 @@ //TESTED_CLASS= //TESTED_FILES= +Q_DECLARE_METATYPE(QScriptValue); + class tst_QScriptValueIterator : public QObject { Q_OBJECT @@ -61,15 +63,14 @@ private slots: void iterateForward(); void iterateBackward_data(); void iterateBackward(); + void iterateArray_data(); void iterateArray(); void iterateBackAndForth(); void setValue(); void remove(); void iterateString(); void iterateGetterSetter(); - void iterateArgumentsObject(); void assignObjectToIterator(); - void undefinedBehavior(); }; tst_QScriptValueIterator::tst_QScriptValueIterator() @@ -207,48 +208,101 @@ void tst_QScriptValueIterator::iterateBackward() QCOMPARE(it.hasNext(), false); } +void tst_QScriptValueIterator::iterateArray_data() +{ + QTest::addColumn<QStringList>("inputPropertyNames"); + QTest::addColumn<QStringList>("inputPropertyValues"); + QTest::addColumn<QStringList>("propertyNames"); + QTest::addColumn<QStringList>("propertyValues"); + QTest::newRow("no elements") << QStringList() << QStringList() << QStringList() << QStringList(); + + + QTest::newRow("0=foo, 1=barr") + << (QStringList() << "0" << "1") + << (QStringList() << "foo" << "bar") + << (QStringList() << "0" << "1") + << (QStringList() << "foo" << "bar"); + + + QTest::newRow("0=foo, 3=barr") + << (QStringList() << "0" << "1" << "2" << "3") + << (QStringList() << "foo" << "" << "" << "bar") + << (QStringList() << "0" << "1" << "2" << "3") + << (QStringList() << "foo" << "" << "" << "bar"); +} + void tst_QScriptValueIterator::iterateArray() { + QFETCH(QStringList, inputPropertyNames); + QFETCH(QStringList, inputPropertyValues); + QFETCH(QStringList, propertyNames); + QFETCH(QStringList, propertyValues); + QScriptEngine engine; QScriptValue array = engine.newArray(); - array.setProperty("0", QScriptValue(&engine, 123)); - array.setProperty("1", QScriptValue(&engine, 456)); - array.setProperty("2", QScriptValue(&engine, 789)); + for (int i = 0; i < inputPropertyNames.size(); ++i) { + array.setProperty(inputPropertyNames.at(i), inputPropertyValues.at(i)); + } + int length = array.property("length").toInt32(); - QCOMPARE(length, 3); + QCOMPARE(length, propertyNames.size()); QScriptValueIterator it(array); for (int i = 0; i < length; ++i) { QCOMPARE(it.hasNext(), true); - QString indexStr = QScriptValue(&engine, i).toString(); it.next(); - QCOMPARE(it.name(), indexStr); - QCOMPARE(it.flags(), array.propertyFlags(indexStr)); - QCOMPARE(it.value().strictlyEquals(array.property(indexStr)), true); + QCOMPARE(it.name(), propertyNames.at(i)); + QCOMPARE(it.flags(), array.propertyFlags(propertyNames.at(i))); + QVERIFY(it.value().strictlyEquals(array.property(propertyNames.at(i)))); + QCOMPARE(it.value().toString(), propertyValues.at(i)); } QCOMPARE(it.hasNext(), false); + QCOMPARE(it.hasPrevious(), length > 0); for (int i = length - 1; i >= 0; --i) { it.previous(); - QString indexStr = QScriptValue(&engine, i).toString(); - QCOMPARE(it.name(), indexStr); - QCOMPARE(it.value().strictlyEquals(array.property(indexStr)), true); + QCOMPARE(it.name(), propertyNames.at(i)); + QCOMPARE(it.flags(), array.propertyFlags(propertyNames.at(i))); + QVERIFY(it.value().strictlyEquals(array.property(propertyNames.at(i)))); + QCOMPARE(it.value().toString(), propertyValues.at(i)); QCOMPARE(it.hasPrevious(), i > 0); } QCOMPARE(it.hasPrevious(), false); // hasNext() and hasPrevious() cache their result; verify that the result is in sync - QVERIFY(it.hasNext()); - it.next(); - QCOMPARE(it.name(), QString::fromLatin1("0")); - QVERIFY(it.hasNext()); - it.previous(); - QCOMPARE(it.name(), QString::fromLatin1("0")); - QVERIFY(!it.hasPrevious()); - it.next(); - QCOMPARE(it.name(), QString::fromLatin1("0")); - QVERIFY(it.hasPrevious()); - it.next(); - QCOMPARE(it.name(), QString::fromLatin1("1")); + if (length > 1) { + QVERIFY(it.hasNext()); + it.next(); + QCOMPARE(it.name(), QString::fromLatin1("0")); + QVERIFY(it.hasNext()); + it.previous(); + QCOMPARE(it.name(), QString::fromLatin1("0")); + QVERIFY(!it.hasPrevious()); + it.next(); + QCOMPARE(it.name(), QString::fromLatin1("0")); + QVERIFY(it.hasPrevious()); + it.next(); + QCOMPARE(it.name(), QString::fromLatin1("1")); + } + { + // same test as object: + QScriptValue originalArray = engine.newArray(); + for (int i = 0; i < inputPropertyNames.size(); ++i) { + originalArray.setProperty(inputPropertyNames.at(i), inputPropertyValues.at(i)); + } + QScriptValue array = originalArray.toObject(); + int length = array.property("length").toInt32(); + QCOMPARE(length, propertyNames.size()); + QScriptValueIterator it(array); + for (int i = 0; i < length; ++i) { + QCOMPARE(it.hasNext(), true); + it.next(); + QCOMPARE(it.name(), propertyNames.at(i)); + QCOMPARE(it.flags(), array.propertyFlags(propertyNames.at(i))); + QVERIFY(it.value().strictlyEquals(array.property(propertyNames.at(i)))); + QCOMPARE(it.value().toString(), propertyValues.at(i)); + } + QCOMPARE(it.hasNext(), false); + } } void tst_QScriptValueIterator::iterateBackAndForth() @@ -260,22 +314,31 @@ void tst_QScriptValueIterator::iterateBackAndForth() object.setProperty("rab", QScriptValue(&engine, "oof"), QScriptValue::SkipInEnumeration); // should not affect iterator QScriptValueIterator it(object); + QVERIFY(it.hasNext()); it.next(); QCOMPARE(it.name(), QLatin1String("foo")); + QVERIFY(it.hasPrevious()); it.previous(); QCOMPARE(it.name(), QLatin1String("foo")); + QVERIFY(it.hasNext()); it.next(); QCOMPARE(it.name(), QLatin1String("foo")); + QVERIFY(it.hasPrevious()); it.previous(); QCOMPARE(it.name(), QLatin1String("foo")); + QVERIFY(it.hasNext()); it.next(); QCOMPARE(it.name(), QLatin1String("foo")); + QVERIFY(it.hasNext()); it.next(); QCOMPARE(it.name(), QLatin1String("rab")); + QVERIFY(it.hasPrevious()); it.previous(); QCOMPARE(it.name(), QLatin1String("rab")); + QVERIFY(it.hasNext()); it.next(); QCOMPARE(it.name(), QLatin1String("rab")); + QVERIFY(it.hasPrevious()); it.previous(); QCOMPARE(it.name(), QLatin1String("rab")); } @@ -359,6 +422,7 @@ void tst_QScriptValueIterator::iterateString() } QCOMPARE(it.hasNext(), false); + QVERIFY(it.hasPrevious()); for (int i = length - 1; i >= 0; --i) { it.previous(); QString indexStr = QScriptValue(&engine, i).toString(); @@ -473,96 +537,6 @@ void tst_QScriptValueIterator::iterateGetterSetter() } } -static QScriptValue getArgumentsObject(QScriptContext *ctx, QScriptEngine *) -{ - return ctx->argumentsObject(); -} - -void tst_QScriptValueIterator::iterateArgumentsObject() -{ - QScriptEngine eng; - QScriptValue fun = eng.newFunction(getArgumentsObject); - QScriptValue ret = fun.call(QScriptValue(), QScriptValueList() << QScriptValue(&eng, 123) << QScriptValue(&eng, 456)); - QCOMPARE(ret.property("length").toInt32(), 2); - - QScriptValueIterator it(ret); - QVERIFY(it.hasNext()); - it.next(); - QCOMPARE(it.name(), QString::fromLatin1("callee")); - QVERIFY(it.value().isFunction()); - QVERIFY(it.value().strictlyEquals(fun)); - QVERIFY(it.hasNext()); - - it.next(); - QCOMPARE(it.name(), QString::fromLatin1("length")); - QVERIFY(it.value().isNumber()); - QCOMPARE(it.value().toInt32(), 2); - QVERIFY(it.hasNext()); - - it.next(); - QCOMPARE(it.name(), QString::fromLatin1("0")); - QVERIFY(it.value().isNumber()); - QCOMPARE(it.value().toInt32(), 123); - QVERIFY(it.hasNext()); - - it.next(); - QCOMPARE(it.name(), QString::fromLatin1("1")); - QVERIFY(it.value().isNumber()); - QCOMPARE(it.value().toInt32(), 456); - QVERIFY(!it.hasNext()); - - QVERIFY(it.hasPrevious()); - it.previous(); - QCOMPARE(it.name(), QString::fromLatin1("1")); - QVERIFY(it.value().isNumber()); - QCOMPARE(it.value().toInt32(), 456); - QVERIFY(it.hasPrevious()); - - it.previous(); - QCOMPARE(it.name(), QString::fromLatin1("0")); - QVERIFY(it.value().isNumber()); - QCOMPARE(it.value().toInt32(), 123); - QVERIFY(it.hasPrevious()); - - it.previous(); - QCOMPARE(it.name(), QString::fromLatin1("length")); - QVERIFY(it.value().isNumber()); - QCOMPARE(it.value().toInt32(), 2); - QVERIFY(it.hasPrevious()); - - it.previous(); - QCOMPARE(it.name(), QString::fromLatin1("callee")); - QVERIFY(it.value().isFunction()); - QVERIFY(it.value().strictlyEquals(fun)); - QVERIFY(!it.hasPrevious()); -} - -void tst_QScriptValueIterator::undefinedBehavior() -{ - QScriptEngine eng; - QScriptValue obj = eng.newObject(); - obj.setProperty("foo", QScriptValue(&eng, 123)); - - QScriptValueIterator it(obj); - QVERIFY(it.hasNext()); - - // delete the property - obj.setProperty("foo", QScriptValue()); - - it.next(); - QCOMPARE(it.name(), QString::fromLatin1("foo")); - QVERIFY(!it.value().isValid()); - - QVERIFY(!it.hasNext()); - // add a property - obj.setProperty("bar", QScriptValue(&eng, 123)); - QVERIFY(it.hasNext()); - - it.next(); - QCOMPARE(it.name(), QString::fromLatin1("bar")); - QVERIFY(it.value().isNumber()); -} - void tst_QScriptValueIterator::assignObjectToIterator() { QScriptEngine eng; diff --git a/tests/auto/qsequentialanimationgroup/qsequentialanimationgroup.pro b/tests/auto/qsequentialanimationgroup/qsequentialanimationgroup.pro index ad861c3..01ef68a 100644 --- a/tests/auto/qsequentialanimationgroup/qsequentialanimationgroup.pro +++ b/tests/auto/qsequentialanimationgroup/qsequentialanimationgroup.pro @@ -1,5 +1,5 @@ load(qttest_p4) -QT = core gui +QT = core SOURCES += tst_qsequentialanimationgroup.cpp diff --git a/tests/auto/qset/qset.pro b/tests/auto/qset/qset.pro index 2656daf..05ad07d 100644 --- a/tests/auto/qset/qset.pro +++ b/tests/auto/qset/qset.pro @@ -1,7 +1,8 @@ load(qttest_p4) SOURCES += tst_qset.cpp - - QT = core - +symbian*: { +TARGET.EPOCSTACKSIZE =0x5000 +TARGET.EPOCHEAPSIZE="0x100000 0x1000000 // Min 1Mb, max 16Mb" +} diff --git a/tests/auto/qsettings/.gitattributes b/tests/auto/qsettings/.gitattributes new file mode 100644 index 0000000..a4ad8d7 --- /dev/null +++ b/tests/auto/qsettings/.gitattributes @@ -0,0 +1,5 @@ +resourcefile.ini -crlf +resourcefile2.ini -crlf +resourcefile3.ini -crlf +resourcefile4.ini -crlf +resourcefile5.ini -crlf diff --git a/tests/auto/qsettings/tst_qsettings.cpp b/tests/auto/qsettings/tst_qsettings.cpp index c6cb60c..b93c807 100644 --- a/tests/auto/qsettings/tst_qsettings.cpp +++ b/tests/auto/qsettings/tst_qsettings.cpp @@ -52,7 +52,9 @@ #include <QtCore/QtDebug> #include <QtCore/QString> -#include <cctype> +#if !defined(Q_OS_SYMBIAN) +# include <cctype> +#endif #if defined(Q_OS_WIN) && defined(Q_CC_GNU) // need for unlink on mingw #include <io.h> @@ -122,7 +124,7 @@ private slots: void setPath(); void setDefaultFormat(); void dontCreateNeedlessPaths(); -#ifndef Q_OS_WIN +#if !defined(Q_OS_WIN) && !defined(Q_OS_SYMBIAN) void dontReorderIniKeysNeedlessly(); #endif @@ -209,7 +211,7 @@ void tst_QSettings::getSetCheck() Q_DECLARE_METATYPE(QSettings::Format) -#ifdef Q_OS_WINCE +#if defined(Q_OS_WINCE) || defined(Q_OS_SYMBIAN) static void removePath(const QString& _path) { QString path = _path; @@ -356,9 +358,11 @@ void tst_QSettings::init() QSettings(QSettings::SystemScope, "software.org").clear(); QSettings(QSettings::UserScope, "other.software.org").clear(); QSettings(QSettings::SystemScope, "other.software.org").clear(); +#elif defined(Q_OS_SYMBIAN) + removePath(settingsPath()); #endif -#ifndef Q_OS_WIN +#if !defined(Q_OS_WIN) && !defined(Q_OS_SYMBIAN) system(QString("chmod -R u+rw %1 2> /dev/null").arg(settingsPath()).toLatin1()); system(QString("rm -fr %1 2> /dev/null").arg(settingsPath()).toLatin1()); #endif @@ -540,13 +544,13 @@ void tst_QSettings::ctor() */ QSettings settings5(format, QSettings::UserScope, "SoftWare.ORG", "killerApp"); if (format == QSettings::NativeFormat) { -#if defined(Q_OS_WIN) || defined(Q_OS_DARWIN) +#if defined(Q_OS_WIN) || defined(Q_OS_DARWIN) || defined(Q_OS_SYMBIAN) QCOMPARE(settings5.value("key 1").toString(), QString("gurgle")); #else QVERIFY(!settings5.contains("key 1")); #endif } else { -#if defined(Q_OS_WIN) || defined(Q_OS_DARWIN) +#if defined(Q_OS_WIN) || defined(Q_OS_DARWIN) || defined(Q_OS_SYMBIAN) QCOMPARE(settings5.value("key 1").toString(), QString("gurgle")); #else QVERIFY(!settings5.contains("key 1")); @@ -716,6 +720,8 @@ void tst_QSettings::testErrorHandling() #ifdef QT_BUILD_INTERNAL #ifdef Q_OS_WIN QSKIP("Windows doesn't support most file modes, including read-only directories, so this test is moot.", SkipAll); +#elif defined(Q_OS_SYMBIAN) + QSKIP("Symbian/Open C doesn't support execute or write only file modes, or directory permissions, so this test is mostly moot.", SkipAll); #elif defined(Q_OS_UNIX) if (::getuid() == 0) QSKIP("Running this test as root doesn't work, since file perms do not bother him", SkipAll); @@ -1499,7 +1505,7 @@ void tst_QSettings::sync() // Now "some other app" will change other.software.org.ini QString userConfDir = settingsPath("__user__") + QDir::separator(); -#if !defined(Q_OS_WINCE) +#if !defined(Q_OS_WINCE) && !defined(Q_OS_SYMBIAN) unlink((userConfDir + "other.software.org.ini").toLatin1()); rename((userConfDir + "software.org.ini").toLatin1(), (userConfDir + "other.software.org.ini").toLatin1()); @@ -3679,7 +3685,7 @@ void tst_QSettings::dontCreateNeedlessPaths() QVERIFY(!fileInfo.dir().exists()); } -#ifndef Q_OS_WIN +#if !defined(Q_OS_WIN) && !defined(Q_OS_SYMBIAN) void tst_QSettings::dontReorderIniKeysNeedlessly() { #ifdef QT_QSETTINGS_ALWAYS_CASE_SENSITIVE_AND_FORGET_ORIGINAL_KEY_ORDER diff --git a/tests/auto/qsharedmemory/lackey/scripts/producer.js b/tests/auto/qsharedmemory/lackey/scripts/producer.js index 88b2b80..e02cd8b 100644 --- a/tests/auto/qsharedmemory/lackey/scripts/producer.js +++ b/tests/auto/qsharedmemory/lackey/scripts/producer.js @@ -15,6 +15,10 @@ if (!producer.create(size)) { } //print ("producer created and attached"); +QVERIFY(producer.lock()); +producer.set(0, 'Q'); +QVERIFY(producer.unlock()); + var i = 0; while(i < 5) { QVERIFY(producer.lock(), "lock"); @@ -34,3 +38,7 @@ producer.set(0, 'E'); QVERIFY(producer.unlock()); //print ("producer done"); + +// Sleep for a bit to let all consumers start, otherwise they will get stuck in the attach loop, +// because at least in Symbian the shared memory will be destroyed if there are no active handles to it. +producer.sleep(3000);
\ No newline at end of file diff --git a/tests/auto/qsharedmemory/src/qsystemlock_p.h b/tests/auto/qsharedmemory/src/qsystemlock_p.h index 66df456..e123bed 100644 --- a/tests/auto/qsharedmemory/src/qsystemlock_p.h +++ b/tests/auto/qsharedmemory/src/qsystemlock_p.h @@ -47,6 +47,7 @@ #include "qsystemlock.h" #include "private/qsharedmemory_p.h" +#include <sys/types.h> #define MAX_LOCKS 64 diff --git a/tests/auto/qsharedmemory/src/qsystemlock_unix.cpp b/tests/auto/qsharedmemory/src/qsystemlock_unix.cpp index 1f91e0c..dd7da21 100644 --- a/tests/auto/qsharedmemory/src/qsystemlock_unix.cpp +++ b/tests/auto/qsharedmemory/src/qsystemlock_unix.cpp @@ -51,6 +51,7 @@ #include <fcntl.h> #include <errno.h> #include <sys/shm.h> +#include <unistd.h> #include <sys/sem.h> // We have to define this as on some sem.h will have it @@ -62,6 +63,25 @@ union qt_semun { #define tr(x) QT_TRANSLATE_NOOP(QLatin1String("QSystemLock"), (x)) +#if defined(Q_OS_SYMBIAN) +int createUnixKeyFile(const QString &fileName) +{ + if (QFile::exists(fileName)) + return 0; + + int fd = open(QFile::encodeName(fileName).constData(), + O_EXCL | O_CREAT | O_RDWR, 0640); + if (-1 == fd) { + if (errno == EEXIST) + return 0; + return -1; + } else { + close(fd); + } + return 1; +} +#endif + QSystemLockPrivate::QSystemLockPrivate() : semaphore(-1), lockCount(0), error(QSystemLock::NoError), unix_key(-1), createdFile(false), createdSemaphore(false) @@ -105,7 +125,11 @@ key_t QSystemLockPrivate::handle() } // Create the file needed for ftok +#if defined(Q_OS_SYMBIAN) + int built = createUnixKeyFile(fileName); +#else int built = QSharedMemoryPrivate::createUnixKeyFile(fileName); +#endif if (-1 == built) return -1; createdFile = (1 == built); diff --git a/tests/auto/qsharedmemory/test/test.pro b/tests/auto/qsharedmemory/test/test.pro index e294a75..779a942 100644 --- a/tests/auto/qsharedmemory/test/test.pro +++ b/tests/auto/qsharedmemory/test/test.pro @@ -17,13 +17,19 @@ TARGET = ../tst_qsharedmemory } } -wince*: { +wince*:{ QT += gui script addFiles.sources = ../lackey/lackey.exe ../lackey/scripts addFiles.path = lackey DEPLOYMENT += addFiles DEFINES += SRCDIR=\\\"\\\" +}else:symbian*{ +QT += gui script +addFiles.sources = ../lackey/scripts +addFiles.path = /data/qsharedmemorytemp/lackey +addBin.sources = lackey.exe +addBin.path = /sys/bin +DEPLOYMENT += addFiles addBin } else { DEFINES += SRCDIR=\\\"$$PWD/../\\\" } - diff --git a/tests/auto/qsharedmemory/tst_qsharedmemory.cpp b/tests/auto/qsharedmemory/tst_qsharedmemory.cpp index 1aa1ebb..b92011e 100644 --- a/tests/auto/qsharedmemory/tst_qsharedmemory.cpp +++ b/tests/auto/qsharedmemory/tst_qsharedmemory.cpp @@ -49,8 +49,11 @@ #define EXISTING_SHARE "existing" #define EXISTING_SIZE 1024 -Q_DECLARE_METATYPE(QSharedMemory::SharedMemoryError); -Q_DECLARE_METATYPE(QSharedMemory::AccessMode); +#ifdef Q_OS_SYMBIAN +#define SRCDIR "c:/data/qsharedmemorytemp/" +#endif +Q_DECLARE_METATYPE(QSharedMemory::SharedMemoryError) +Q_DECLARE_METATYPE(QSharedMemory::AccessMode) class tst_QSharedMemory : public QObject { @@ -405,6 +408,9 @@ void tst_QSharedMemory::readOnly() #ifdef Q_OS_WIN QSKIP("This test opens a crash dialog on Windows", SkipSingle); #endif +#if defined (Q_OS_SYMBIAN) + QSKIP("Readonly shared memory is not supported in symbian", SkipAll); +#endif QString program = "./lackey/lackey"; QStringList arguments; rememberKey("readonly_segfault"); @@ -527,7 +533,9 @@ void tst_QSharedMemory::simpleProducerConsumer() char *get = (char*)consumer.data(); // On Windows CE you always have ReadWrite access. Thus // ViewMapOfFile returns the same pointer -#ifndef Q_OS_WINCE + // On Symbian, the address will always be same, as + // write protection of chunks is not currently supported by Symbian +#if !defined(Q_OS_WINCE) && !defined(Q_OS_SYMBIAN) QVERIFY(put != get); #endif for (int i = 0; i < size; ++i) { @@ -629,6 +637,11 @@ public: QVERIFY(producer.lock()); memory[0] = 'E'; QVERIFY(producer.unlock()); + +#if defined(Q_OS_SYMBIAN) + // Sleep a while to ensure that consumers start properly + QTest::qSleep(1000); +#endif } private: @@ -660,12 +673,25 @@ void tst_QSharedMemory::simpleThreadedProducerConsumer() #endif Producer p; +#if defined(Q_OS_SYMBIAN) + enum + { + /** + * The maximum stack size. + */ + SymbianStackSize = 0x14000 + }; + p.setStackSize(SymbianStackSize); +#endif if (producerIsThread) p.start(); QList<Consumer*> consumers; for (int i = 0; i < threads; ++i) { consumers.append(new Consumer()); +#if defined(Q_OS_SYMBIAN) + consumers.last()->setStackSize(SymbianStackSize); +#endif consumers.last()->start(); } @@ -697,6 +723,9 @@ void tst_QSharedMemory::simpleProcessProducerConsumer_data() */ void tst_QSharedMemory::simpleProcessProducerConsumer() { +#if defined (Q_OS_SYMBIAN) && defined(Q_CC_NOKIAX86) + QSKIP("Cannot launch multiple Qt processes in Symbian emulator", SkipAll); +#endif QFETCH(int, processes); rememberKey("market"); @@ -710,6 +739,7 @@ void tst_QSharedMemory::simpleProcessProducerConsumer() producer.setProcessChannelMode(QProcess::ForwardedChannels); producer.start("./lackey/lackey", arguments); producer.waitForStarted(); + QVERIFY(producer.error() != QProcess::FailedToStart); QList<QProcess*> consumers; for (int i = 0; i < processes; ++i) { @@ -730,7 +760,8 @@ void tst_QSharedMemory::simpleProcessProducerConsumer() while (!consumers.isEmpty()) { consumers.first()->waitForFinished(1000); - if (consumers.first()->exitStatus() != QProcess::NormalExit || + if (consumers.first()->state() == QProcess::Running || + consumers.first()->exitStatus() != QProcess::NormalExit || consumers.first()->exitCode() != 0) { consumerFailed = true; } diff --git a/tests/auto/qsharedpointer/externaltests.cpp b/tests/auto/qsharedpointer/externaltests.cpp index edf055c..f95b8b2 100644 --- a/tests/auto/qsharedpointer/externaltests.cpp +++ b/tests/auto/qsharedpointer/externaltests.cpp @@ -51,6 +51,10 @@ #include <QtCore/QDirIterator> #include <QtCore/QDateTime> +#ifdef Q_OS_SYMBIAN +#define DEFAULT_MAKESPEC "X:/STLsupport/mkspecs/symbian-abld/" +#endif + #ifndef DEFAULT_MAKESPEC # error DEFAULT_MAKESPEC not defined #endif diff --git a/tests/auto/qsharedpointer/externaltests.pri b/tests/auto/qsharedpointer/externaltests.pri index 1fdcf65..627af87 100644 --- a/tests/auto/qsharedpointer/externaltests.pri +++ b/tests/auto/qsharedpointer/externaltests.pri @@ -1,7 +1,8 @@ SOURCES += $$PWD/externaltests.cpp HEADERS += $$PWD/externaltests.h cleanedQMAKESPEC = $$replace(QMAKESPEC, \\\\, /) -DEFINES += DEFAULT_MAKESPEC=\\\"$$cleanedQMAKESPEC\\\" +!symbian:DEFINES += DEFAULT_MAKESPEC=\\\"$$cleanedQMAKESPEC\\\" embedded:DEFINES += QTEST_NO_RTTI QTEST_CROSS_COMPILED wince*:DEFINES += QTEST_CROSS_COMPILED +symbian: DEFINES += QTEST_CROSS_COMPILED diff --git a/tests/auto/qsharedpointer/qsharedpointer.pro b/tests/auto/qsharedpointer/qsharedpointer.pro index 1759323..bbd31d7 100644 --- a/tests/auto/qsharedpointer/qsharedpointer.pro +++ b/tests/auto/qsharedpointer/qsharedpointer.pro @@ -9,6 +9,6 @@ HEADERS += forwarddeclared.h \ wrapper.h QT = core -DEFINES += SRCDIR=\\\"$$PWD/\\\" +!symbian:DEFINES += SRCDIR=\\\"$$PWD/\\\" include(externaltests.pri) diff --git a/tests/auto/qsharedpointer/tst_qsharedpointer.cpp b/tests/auto/qsharedpointer/tst_qsharedpointer.cpp index b2afb9f..93f5b6e 100644 --- a/tests/auto/qsharedpointer/tst_qsharedpointer.cpp +++ b/tests/auto/qsharedpointer/tst_qsharedpointer.cpp @@ -51,9 +51,15 @@ #include <stdlib.h> #include <time.h> +QT_BEGIN_NAMESPACE namespace QtSharedPointer { Q_CORE_EXPORT void internalSafetyCheckCleanCheck(); } +QT_END_NAMESPACE + +#ifdef Q_OS_SYMBIAN +#define SRCDIR "." +#endif class tst_QSharedPointer: public QObject { diff --git a/tests/auto/qsharedpointer/wrapper.h b/tests/auto/qsharedpointer/wrapper.h index c006686..4445860 100644 --- a/tests/auto/qsharedpointer/wrapper.h +++ b/tests/auto/qsharedpointer/wrapper.h @@ -41,7 +41,10 @@ #ifndef WRAPPER_H #define WRAPPER_H +QT_BEGIN_NAMESPACE template <class T> class QSharedPointer; +QT_END_NAMESPACE + class Wrapper { public: diff --git a/tests/auto/qsharedpointer_and_qwidget/tst_qsharedpointer_and_qwidget.cpp b/tests/auto/qsharedpointer_and_qwidget/tst_qsharedpointer_and_qwidget.cpp index d03b999..744e86a 100644 --- a/tests/auto/qsharedpointer_and_qwidget/tst_qsharedpointer_and_qwidget.cpp +++ b/tests/auto/qsharedpointer_and_qwidget/tst_qsharedpointer_and_qwidget.cpp @@ -43,9 +43,11 @@ #include <QtGui/QPushButton> #include <QtTest/QtTest> +QT_BEGIN_NAMESPACE namespace QtSharedPointer { Q_CORE_EXPORT void internalSafetyCheckCleanCheck(); } +QT_END_NAMESPACE class tst_QSharedPointer_and_QWidget: public QObject { diff --git a/tests/auto/qsidebar/qsidebar.pro b/tests/auto/qsidebar/qsidebar.pro index bfcaab7..b1fba73 100644 --- a/tests/auto/qsidebar/qsidebar.pro +++ b/tests/auto/qsidebar/qsidebar.pro @@ -5,4 +5,4 @@ include(../../src/qfiledialog.pri) SOURCES += tst_qsidebar.cpp TARGET = tst_qsidebar - +symbian:HEADERS += ../../../include/qtgui/private/qfileinfogatherer_p.h diff --git a/tests/auto/qsignalspy/qsignalspy.pro b/tests/auto/qsignalspy/qsignalspy.pro index 172bdad..4bc4a7b 100644 --- a/tests/auto/qsignalspy/qsignalspy.pro +++ b/tests/auto/qsignalspy/qsignalspy.pro @@ -1,6 +1,3 @@ load(qttest_p4) SOURCES += tst_qsignalspy.cpp - QT = core - - diff --git a/tests/auto/qsize/qsize.pro b/tests/auto/qsize/qsize.pro index dddfa56..14786b8 100644 --- a/tests/auto/qsize/qsize.pro +++ b/tests/auto/qsize/qsize.pro @@ -1,5 +1,3 @@ load(qttest_p4) SOURCES += tst_qsize.cpp - - - +QT = core diff --git a/tests/auto/qsizef/qsizef.pro b/tests/auto/qsizef/qsizef.pro index c1288f6..703d721 100644 --- a/tests/auto/qsizef/qsizef.pro +++ b/tests/auto/qsizef/qsizef.pro @@ -1,4 +1,3 @@ load(qttest_p4) SOURCES += tst_qsizef.cpp - - +QT = core diff --git a/tests/auto/qsocketnotifier/tst_qsocketnotifier.cpp b/tests/auto/qsocketnotifier/tst_qsocketnotifier.cpp index e6d418d..8f9dab9 100644 --- a/tests/auto/qsocketnotifier/tst_qsocketnotifier.cpp +++ b/tests/auto/qsocketnotifier/tst_qsocketnotifier.cpp @@ -57,6 +57,7 @@ public: private slots: void unexpectedDisconnection(); + void mixingWithTimers(); }; tst_QSocketNotifier::tst_QSocketNotifier() @@ -125,24 +126,24 @@ void tst_QSocketNotifier::unexpectedDisconnection() QNativeSocketEngine readEnd1; readEnd1.initialize(QAbstractSocket::TcpSocket); - bool b = readEnd1.connectToHost(server.serverAddress(), server.serverPort()); + bool b = readEnd1.connectToHost(server.serverAddress(), server.serverPort()); QVERIFY(readEnd1.waitForWrite()); // while (!b && readEnd1.state() != QAbstractSocket::ConnectedState) // b = readEnd1.connectToHost(server.serverAddress(), server.serverPort()); QVERIFY(readEnd1.state() == QAbstractSocket::ConnectedState); - QVERIFY(server.waitForNewConnection()); + QVERIFY(server.waitForNewConnection()); QTcpSocket *writeEnd1 = server.nextPendingConnection(); QVERIFY(writeEnd1 != 0); - + QNativeSocketEngine readEnd2; readEnd2.initialize(QAbstractSocket::TcpSocket); - b = readEnd2.connectToHost(server.serverAddress(), server.serverPort()); + b = readEnd2.connectToHost(server.serverAddress(), server.serverPort()); QVERIFY(readEnd2.waitForWrite()); // while (!b) // b = readEnd2.connectToHost(server.serverAddress(), server.serverPort()); QVERIFY(readEnd2.state() == QAbstractSocket::ConnectedState); - QVERIFY(server.waitForNewConnection()); - QTcpSocket *writeEnd2 = server.nextPendingConnection(); + QVERIFY(server.waitForNewConnection()); + QTcpSocket *writeEnd2 = server.nextPendingConnection(); QVERIFY(writeEnd2 != 0); writeEnd1->write("1", 1); @@ -155,18 +156,17 @@ void tst_QSocketNotifier::unexpectedDisconnection() writeEnd2->flush(); UnexpectedDisconnectTester tester(&readEnd1, &readEnd2); - QEventLoop eventLoop; - connect(&tester, SIGNAL(finished()), &eventLoop, SLOT(quit())); - eventLoop.exec(); + + do { + // we have to wait until sequence value changes + // as any event can make us jump out processing + QCoreApplication::processEvents(QEventLoop::WaitForMoreEvents); + } while(tester.sequence <= 0); QVERIFY(readEnd1.state() == QAbstractSocket::ConnectedState); QVERIFY(readEnd2.state() == QAbstractSocket::ConnectedState); -#if defined(Q_OS_WIN) - qWarning("### Windows returns 1 activation, Unix returns 2."); - QCOMPARE(tester.sequence, 1); -#else + QCOMPARE(tester.sequence, 2); -#endif readEnd1.close(); readEnd2.close(); @@ -175,5 +175,67 @@ void tst_QSocketNotifier::unexpectedDisconnection() server.close(); } +class MixingWithTimersHelper : public QObject +{ + Q_OBJECT + +public: + MixingWithTimersHelper(QTimer *timer, QTcpServer *server); + + bool timerActivated; + bool socketActivated; + +private slots: + void timerFired(); + void socketFired(); +}; + +MixingWithTimersHelper::MixingWithTimersHelper(QTimer *timer, QTcpServer *server) +{ + timerActivated = false; + socketActivated = false; + + connect(timer, SIGNAL(timeout()), SLOT(timerFired())); + connect(server, SIGNAL(newConnection()), SLOT(socketFired())); +} + +void MixingWithTimersHelper::timerFired() +{ + timerActivated = true; +} + +void MixingWithTimersHelper::socketFired() +{ + socketActivated = true; +} + +void tst_QSocketNotifier::mixingWithTimers() +{ + QTimer timer; + timer.setInterval(0); + timer.start(); + + QTcpServer server; + QVERIFY(server.listen(QHostAddress::LocalHost, 0)); + + MixingWithTimersHelper helper(&timer, &server); + + QCoreApplication::processEvents(); + + QCOMPARE(helper.timerActivated, true); + QCOMPARE(helper.socketActivated, false); + + helper.timerActivated = false; + helper.socketActivated = false; + + QTcpSocket socket; + socket.connectToHost(server.serverAddress(), server.serverPort()); + + QCoreApplication::processEvents(); + + QCOMPARE(helper.timerActivated, true); + QCOMPARE(helper.socketActivated, true); +} + QTEST_MAIN(tst_QSocketNotifier) #include <tst_qsocketnotifier.moc> diff --git a/tests/auto/qsocks5socketengine/qsocks5socketengine.pro b/tests/auto/qsocks5socketengine/qsocks5socketengine.pro index d19b732..4a32852 100644 --- a/tests/auto/qsocks5socketengine/qsocks5socketengine.pro +++ b/tests/auto/qsocks5socketengine/qsocks5socketengine.pro @@ -9,6 +9,8 @@ MOC_DIR=tmp QT = core network +# Symbian toolchain does not support correct include semantics +symbian:INCPATH+=..\..\..\include\QtNetwork\private requires(contains(QT_CONFIG,private_tests)) diff --git a/tests/auto/qsocks5socketengine/tst_qsocks5socketengine.cpp b/tests/auto/qsocks5socketengine/tst_qsocks5socketengine.cpp index 9dd23e6..33bf315 100644 --- a/tests/auto/qsocks5socketengine/tst_qsocks5socketengine.cpp +++ b/tests/auto/qsocks5socketengine/tst_qsocks5socketengine.cpp @@ -147,11 +147,11 @@ private slots: tst_QSocks5SocketEngine::tst_QSocks5SocketEngine() { + Q_SET_DEFAULT_IAP } tst_QSocks5SocketEngine::~tst_QSocks5SocketEngine() { - } void tst_QSocks5SocketEngine::init() @@ -302,7 +302,7 @@ void tst_QSocks5SocketEngine::errorTest() connect(&socket, SIGNAL(error(QAbstractSocket::SocketError)), &QTestEventLoop::instance(), SLOT(exitLoop())); - QTestEventLoop::instance().enterLoop(5); + QTestEventLoop::instance().enterLoop(10); QVERIFY(!QTestEventLoop::instance().timeout()); QCOMPARE(int(socket.error()), expectedError); @@ -336,8 +336,7 @@ void tst_QSocks5SocketEngine::simpleConnectToIMAP() QVERIFY(socketDevice.read(array.data(), array.size()) == available); // Check that the greeting is what we expect it to be - QCOMPARE(array.constData(), - "* OK [CAPABILITY IMAP4 IMAP4rev1 LITERAL+ ID STARTTLS LOGINDISABLED] qt-test-server.qt-test-net Cyrus IMAP4 v2.3.11-Mandriva-RPM-2.3.11-6mdv2008.1 server ready\r\n"); + QCOMPARE(array.constData(), QtNetworkSettings::expectedReplyIMAP().constData()); // Write a logout message QByteArray array2 = "XXXX LOGOUT\r\n"; @@ -529,6 +528,10 @@ void tst_QSocks5SocketEngine::serverTest() //--------------------------------------------------------------------------- void tst_QSocks5SocketEngine::udpTest() { +#ifdef SYMBIAN_WINSOCK_CONNECTIVITY + QSKIP("UDP works bads on non WinPCAP emulator setting", SkipAll); +#endif + QSocks5SocketEngine udpSocket; // Initialize device #1 @@ -593,7 +596,7 @@ void tst_QSocks5SocketEngine::tcpSocketBlockingTest() // Read greeting QVERIFY(socket.waitForReadyRead(5000)); QString s = socket.readLine(); - QCOMPARE(s.toLatin1().constData(), "* OK [CAPABILITY IMAP4 IMAP4rev1 LITERAL+ ID STARTTLS LOGINDISABLED] qt-test-server.qt-test-net Cyrus IMAP4 v2.3.11-Mandriva-RPM-2.3.11-6mdv2008.1 server ready\r\n"); + QCOMPARE(s.toLatin1().constData(), QtNetworkSettings::expectedReplyIMAP().constData()); // Write NOOP QCOMPARE((int) socket.write("1 NOOP\r\n", 8), 8); @@ -668,7 +671,8 @@ void tst_QSocks5SocketEngine::tcpSocketNonBlockingTest() // Read greeting QVERIFY(!tcpSocketNonBlocking_data.isEmpty()); QCOMPARE(tcpSocketNonBlocking_data.at(0).toLatin1().constData(), - "* OK [CAPABILITY IMAP4 IMAP4rev1 LITERAL+ ID STARTTLS LOGINDISABLED] qt-test-server.qt-test-net Cyrus IMAP4 v2.3.11-Mandriva-RPM-2.3.11-6mdv2008.1 server ready\r\n"); + QtNetworkSettings::expectedReplyIMAP().constData()); + tcpSocketNonBlocking_data.clear(); tcpSocketNonBlocking_totalWritten = 0; @@ -690,7 +694,6 @@ void tst_QSocks5SocketEngine::tcpSocketNonBlockingTest() QFAIL("Timed out"); } - // Read response QVERIFY(!tcpSocketNonBlocking_data.isEmpty()); QCOMPARE(tcpSocketNonBlocking_data.at(0).toLatin1().constData(), "1 OK Completed\r\n"); @@ -787,7 +790,7 @@ void tst_QSocks5SocketEngine::downloadBigFile() QTime stopWatch; stopWatch.start(); -#if !defined(Q_OS_WINCE) +#if !defined(Q_OS_WINCE) && !defined(Q_OS_SYMBIAN) QTestEventLoop::instance().enterLoop(60); #else QTestEventLoop::instance().enterLoop(180); @@ -834,6 +837,7 @@ void tst_QSocks5SocketEngine::passwordAuth() socketDevice.setProxy(QNetworkProxy(QNetworkProxy::Socks5Proxy, QtNetworkSettings::serverName(), 1080, "qsockstest", "password")); + // Connect to imap.trolltech.com's IP QVERIFY(!socketDevice.connectToHost(QtNetworkSettings::serverIP(), 143)); QVERIFY(socketDevice.state() == QAbstractSocket::ConnectingState); QVERIFY(socketDevice.waitForWrite()); @@ -854,8 +858,7 @@ void tst_QSocks5SocketEngine::passwordAuth() QVERIFY(socketDevice.read(array.data(), array.size()) == available); // Check that the greeting is what we expect it to be - QCOMPARE(array.constData(), - "* OK [CAPABILITY IMAP4 IMAP4rev1 LITERAL+ ID STARTTLS LOGINDISABLED] qt-test-server.qt-test-net Cyrus IMAP4 v2.3.11-Mandriva-RPM-2.3.11-6mdv2008.1 server ready\r\n"); + QCOMPARE(array.constData(), QtNetworkSettings::expectedReplyIMAP().constData()); // Write a logout message QByteArray array2 = "XXXX LOGOUT\r\n"; @@ -923,8 +926,7 @@ void tst_QSocks5SocketEngine::passwordAuth2() QVERIFY(socketDevice.read(array.data(), array.size()) == available); // Check that the greeting is what we expect it to be - QCOMPARE(array.constData(), - "* OK [CAPABILITY IMAP4 IMAP4rev1 LITERAL+ ID STARTTLS LOGINDISABLED] qt-test-server.qt-test-net Cyrus IMAP4 v2.3.11-Mandriva-RPM-2.3.11-6mdv2008.1 server ready\r\n"); + QCOMPARE(array.constData(), QtNetworkSettings::expectedReplyIMAP().constData()); // Write a logout message QByteArray array2 = "XXXX LOGOUT\r\n"; diff --git a/tests/auto/qsound/qsound.pro b/tests/auto/qsound/qsound.pro index 20c6098..75da2e6 100644 --- a/tests/auto/qsound/qsound.pro +++ b/tests/auto/qsound/qsound.pro @@ -1,7 +1,7 @@ load(qttest_p4) SOURCES += tst_qsound.cpp -wince*: { +wince*|symbian*: { deploy.sources += 4.wav DEPLOYMENT = deploy }
\ No newline at end of file diff --git a/tests/auto/qsplitter/qsplitter.pro b/tests/auto/qsplitter/qsplitter.pro index a7ff0a6..5ec2b9d 100644 --- a/tests/auto/qsplitter/qsplitter.pro +++ b/tests/auto/qsplitter/qsplitter.pro @@ -4,11 +4,11 @@ SOURCES += tst_qsplitter.cpp contains(QT_CONFIG, qt3support): QT += qt3support -wince*: { +wince*|symbian*: { addFiles.sources = extradata.txt setSizes3.dat addFiles.path = . DEPLOYMENT += addFiles - DEFINES += SRCDIR=\\\"./\\\" + !symbian:DEFINES += SRCDIR=\\\"./\\\" } else { DEFINES += SRCDIR=\\\"$$PWD/\\\" } diff --git a/tests/auto/qsplitter/tst_qsplitter.cpp b/tests/auto/qsplitter/tst_qsplitter.cpp index 885716a..e9ce8dd 100644 --- a/tests/auto/qsplitter/tst_qsplitter.cpp +++ b/tests/auto/qsplitter/tst_qsplitter.cpp @@ -57,6 +57,10 @@ #include <qdebug.h> // for file error messages #include "../../shared/util.h" +#if defined(Q_OS_SYMBIAN) +# define SRCDIR "" +#endif + //TESTED_CLASS= //TESTED_FILES= diff --git a/tests/auto/qsql/qsql.pro b/tests/auto/qsql/qsql.pro index 2c0e337..167a38d 100644 --- a/tests/auto/qsql/qsql.pro +++ b/tests/auto/qsql/qsql.pro @@ -1,10 +1,18 @@ load(qttest_p4) SOURCES += tst_qsql.cpp -QT += sql +QT += sql contains(QT_CONFIG, qt3support): QT += qt3support wince*: { DEPLOYMENT_PLUGIN += qsqlite } + +symbian { + contains(S60_VERSION, 3.1)|contains(S60_VERSION, 3.2)|contains(S60_VERSION, 5.0) { + sqlite.path = /sys/bin + sqlite.sources = sqlite3.dll + DEPLOYMENT += sqlite + } +} diff --git a/tests/auto/qsqldatabase/qsqldatabase.pro b/tests/auto/qsqldatabase/qsqldatabase.pro index 3bca79a..964c8c9 100644 --- a/tests/auto/qsqldatabase/qsqldatabase.pro +++ b/tests/auto/qsqldatabase/qsqldatabase.pro @@ -19,5 +19,14 @@ wince*: { DEPLOYMENT += testData } - +symbian { + TARGET.EPOCHEAPSIZE=5000 5000000 + TARGET.EPOCSTACKSIZE=50000 + + contains(S60_VERSION, 3.1)|contains(S60_VERSION, 3.2)|contains(S60_VERSION, 5.0) { + sqlite.path = /sys/bin + sqlite.sources = sqlite3.dll + DEPLOYMENT += sqlite + } +} diff --git a/tests/auto/qsqlerror/qsqlerror.pro b/tests/auto/qsqlerror/qsqlerror.pro index 570c88e..2eb7934 100644 --- a/tests/auto/qsqlerror/qsqlerror.pro +++ b/tests/auto/qsqlerror/qsqlerror.pro @@ -7,4 +7,10 @@ QT = core sql SOURCES += tst_qsqlerror.cpp - +symbian { + contains(S60_VERSION, 3.1)|contains(S60_VERSION, 3.2)|contains(S60_VERSION, 5.0) { + sqlite.path = /sys/bin + sqlite.sources = sqlite3.dll + DEPLOYMENT += sqlite + } +} diff --git a/tests/auto/qsqlfield/qsqlfield.pro b/tests/auto/qsqlfield/qsqlfield.pro index 04875fd..6e5b461 100644 --- a/tests/auto/qsqlfield/qsqlfield.pro +++ b/tests/auto/qsqlfield/qsqlfield.pro @@ -3,5 +3,11 @@ SOURCES += tst_qsqlfield.cpp QT += sql - +symbian { + contains(S60_VERSION, 3.1)|contains(S60_VERSION, 3.2)|contains(S60_VERSION, 5.0) { + sqlite.path = /sys/bin + sqlite.sources = sqlite3.dll + DEPLOYMENT += sqlite + } +} diff --git a/tests/auto/qsqlquery/qsqlquery.pro b/tests/auto/qsqlquery/qsqlquery.pro index 7996637..494ca4c 100644 --- a/tests/auto/qsqlquery/qsqlquery.pro +++ b/tests/auto/qsqlquery/qsqlquery.pro @@ -13,3 +13,11 @@ wince*: { DEPLOYMENT += plugFiles LIBS += -lws2 } + +symbian { + contains(S60_VERSION, 3.1)|contains(S60_VERSION, 3.2)|contains(S60_VERSION, 5.0) { + sqlite.path = /sys/bin + sqlite.sources = sqlite3.dll + DEPLOYMENT += sqlite + } +} diff --git a/tests/auto/qsqlquerymodel/qsqlquerymodel.pro b/tests/auto/qsqlquerymodel/qsqlquerymodel.pro index 6004ab0..cd8586c 100644 --- a/tests/auto/qsqlquerymodel/qsqlquerymodel.pro +++ b/tests/auto/qsqlquerymodel/qsqlquerymodel.pro @@ -5,7 +5,13 @@ QT += sql wince*: { DEPLOYMENT_PLUGIN += qsqlite - LIBS += -lws2 + LIBS += -lws2 +}else:symbian { + contains(S60_VERSION, 3.1)|contains(S60_VERSION, 3.2)|contains(S60_VERSION, 5.0) { + sqlite.path = /sys/bin + sqlite.sources = sqlite3.dll + DEPLOYMENT += sqlite + } } else { win32:LIBS += -lws2_32 } diff --git a/tests/auto/qsqlrecord/qsqlrecord.pro b/tests/auto/qsqlrecord/qsqlrecord.pro index 819ae59..67e8ab9 100644 --- a/tests/auto/qsqlrecord/qsqlrecord.pro +++ b/tests/auto/qsqlrecord/qsqlrecord.pro @@ -1,6 +1,16 @@ load(qttest_p4) SOURCES += tst_qsqlrecord.cpp +symbian { +contains(S60_VERSION, 3.1)|contains(S60_VERSION, 3.2)|contains(S60_VERSION, 5.0) { + sqlite.path = /sys/bin + sqlite.sources = sqlite3.dll + DEPLOYMENT += sqlite +} + +TARGET.EPOCSTACKSIZE=50000 +TARGET.EPOCHEAPSIZE=50000 5000000 +} QT += sql diff --git a/tests/auto/qsqlrelationaltablemodel/qsqlrelationaltablemodel.pro b/tests/auto/qsqlrelationaltablemodel/qsqlrelationaltablemodel.pro index a25cb93..2fddd03 100644 --- a/tests/auto/qsqlrelationaltablemodel/qsqlrelationaltablemodel.pro +++ b/tests/auto/qsqlrelationaltablemodel/qsqlrelationaltablemodel.pro @@ -6,8 +6,14 @@ QT += sql wince*: { plugFiles.sources = ../../../plugins/sqldrivers plugFiles.path = . - DEPLOYMENT += plugFiles + DEPLOYMENT += plugFiles LIBS += -lws2 +}else:symbian { + contains(S60_VERSION, 3.1)|contains(S60_VERSION, 3.2)|contains(S60_VERSION, 5.0) { + sqlite.path = /sys/bin + sqlite.sources = sqlite3.dll + DEPLOYMENT += sqlite + } } else { win32-g++ { LIBS += -lws2_32 diff --git a/tests/auto/qsqltablemodel/qsqltablemodel.pro b/tests/auto/qsqltablemodel/qsqltablemodel.pro index 170862e..a046fb1 100644 --- a/tests/auto/qsqltablemodel/qsqltablemodel.pro +++ b/tests/auto/qsqltablemodel/qsqltablemodel.pro @@ -8,7 +8,13 @@ wince*: { plugFiles.path = . DEPLOYMENT += plugFiles LIBS += -lws2 -} else { +}else:symbian { + contains(S60_VERSION, 3.1)|contains(S60_VERSION, 3.2)|contains(S60_VERSION, 5.0) { + sqlite.path = /sys/bin + sqlite.sources = sqlite3.dll + DEPLOYMENT += sqlite + } +}else { win32:LIBS += -lws2_32 } diff --git a/tests/auto/qsqlthread/qsqlthread.pro b/tests/auto/qsqlthread/qsqlthread.pro index 9049f4c..2708f1a 100644 --- a/tests/auto/qsqlthread/qsqlthread.pro +++ b/tests/auto/qsqlthread/qsqlthread.pro @@ -9,7 +9,13 @@ wince*: { plugFiles.path = . DEPLOYMENT += plugFiles LIBS += -lws2 -} else { +}else:symbian { + contains(S60_VERSION, 3.1)|contains(S60_VERSION, 3.2)|contains(S60_VERSION, 5.0) { + sqlite.path = /sys/bin + sqlite.sources = sqlite3.dll + DEPLOYMENT += sqlite + } +}else { win32:LIBS += -lws2_32 } diff --git a/tests/auto/qsslcertificate/qsslcertificate.pro b/tests/auto/qsslcertificate/qsslcertificate.pro index f3f7adb..b237f2e 100644 --- a/tests/auto/qsslcertificate/qsslcertificate.pro +++ b/tests/auto/qsslcertificate/qsslcertificate.pro @@ -2,7 +2,7 @@ load(qttest_p4) SOURCES += tst_qsslcertificate.cpp !wince*:win32:LIBS += -lws2_32 -QT += network +QT = core network TARGET = tst_qsslcertificate @@ -14,13 +14,14 @@ win32 { } } -wince*: { +wince*|symbian: { certFiles.sources = certificates more-certificates certFiles.path = . DEPLOYMENT += certFiles +} + +wince*: { DEFINES += SRCDIR=\\\".\\\" -} else { +} else:!symbian { DEFINES += SRCDIR=\\\"$$PWD/\\\" } - - diff --git a/tests/auto/qsslcertificate/tst_qsslcertificate.cpp b/tests/auto/qsslcertificate/tst_qsslcertificate.cpp index 73d7afd..c046e38 100644 --- a/tests/auto/qsslcertificate/tst_qsslcertificate.cpp +++ b/tests/auto/qsslcertificate/tst_qsslcertificate.cpp @@ -45,6 +45,12 @@ #include <qsslkey.h> #include <qsslsocket.h> +#ifdef Q_OS_SYMBIAN +// In Symbian OS test data is located in applications private dir +// Current path (C:\private\<UID>) contains only ascii chars +#define SRCDIR "./" +#endif + class tst_QSslCertificate : public QObject { Q_OBJECT diff --git a/tests/auto/qsslcipher/qsslcipher.pro b/tests/auto/qsslcipher/qsslcipher.pro index 8a99274..6eae588 100644 --- a/tests/auto/qsslcipher/qsslcipher.pro +++ b/tests/auto/qsslcipher/qsslcipher.pro @@ -2,7 +2,7 @@ load(qttest_p4) SOURCES += tst_qsslcipher.cpp !wince*:win32:LIBS += -lws2_32 -QT += network +QT = core network TARGET = tst_qsslcipher diff --git a/tests/auto/qsslerror/qsslerror.pro b/tests/auto/qsslerror/qsslerror.pro index 1385d2e..ee5872b 100644 --- a/tests/auto/qsslerror/qsslerror.pro +++ b/tests/auto/qsslerror/qsslerror.pro @@ -2,7 +2,7 @@ load(qttest_p4) SOURCES += tst_qsslerror.cpp !wince*:win32:LIBS += -lws2_32 -QT += network +QT = core network TARGET = tst_qsslerror diff --git a/tests/auto/qsslkey/qsslkey.pro b/tests/auto/qsslkey/qsslkey.pro index 5cab3d5..32138f8 100644 --- a/tests/auto/qsslkey/qsslkey.pro +++ b/tests/auto/qsslkey/qsslkey.pro @@ -2,7 +2,7 @@ load(qttest_p4) SOURCES += tst_qsslkey.cpp !wince*:win32:LIBS += -lws2_32 -QT += network +QT = core network TARGET = tst_qsslkey @@ -14,11 +14,14 @@ win32 { } } -wince*: { +wince*|symbian: { keyFiles.sources = keys keyFiles.path = . DEPLOYMENT += keyFiles +} + +wince*: { DEFINES += SRCDIR=\\\".\\\" -} else { +} else:!symbian { DEFINES+= SRCDIR=\\\"$$PWD\\\" } diff --git a/tests/auto/qsslkey/tst_qsslkey.cpp b/tests/auto/qsslkey/tst_qsslkey.cpp index ef05614..2adac4c 100644 --- a/tests/auto/qsslkey/tst_qsslkey.cpp +++ b/tests/auto/qsslkey/tst_qsslkey.cpp @@ -47,6 +47,12 @@ #include <QtNetwork/qhostaddress.h> #include <QtNetwork/qnetworkproxy.h> +#ifdef Q_OS_SYMBIAN +// In Symbian OS test data is located in applications private dir +// Current path (C:\private\<UID>) contains only ascii chars +#define SRCDIR QDir::currentPath().toAscii() +#endif + class tst_QSslKey : public QObject { Q_OBJECT @@ -101,7 +107,7 @@ tst_QSslKey::tst_QSslKey() #ifdef Q_WS_MAC // applicationDirPath() points to a path inside the app bundle on Mac. QDir dir(qApp->applicationDirPath() + QLatin1String("/../../../keys")); -#elif defined(Q_OS_WIN) +#elif defined(Q_OS_WIN) || defined (Q_OS_SYMBIAN) QDir dir(SRCDIR + QLatin1String("/keys")); // prefer this way to avoid ifdeffery and support shadow builds? #else QDir dir(qApp->applicationDirPath() + QLatin1String("/keys")); diff --git a/tests/auto/qsslsocket/certs/aspiriniks.ca.crt b/tests/auto/qsslsocket/certs/aspiriniks.ca.crt new file mode 100644 index 0000000..36436b6 --- /dev/null +++ b/tests/auto/qsslsocket/certs/aspiriniks.ca.crt @@ -0,0 +1,22 @@ +-----BEGIN CERTIFICATE----- +MIIDnDCCAoQCCQDV3otC4hs2KTANBgkqhkiG9w0BAQUFADCBjzELMAkGA1UEBhMC +Tk8xDTALBgNVBAgTBE9zbG8xDTALBgNVBAcTBE9zbG8xDzANBgNVBAoTBlRUIEFT +QTEOMAwGA1UECxMFUVQgU1cxHDAaBgNVBAMTE2FzcGlyaW5pa3MudHJvbGwubm8x +IzAhBgkqhkiG9w0BCQEWFGFiYWJpY0B0cm9sbHRlY2guY29tMB4XDTA4MTEwMTA4 +NTcyOFoXDTA5MTEwMTA4NTcyOFowgY8xCzAJBgNVBAYTAk5PMQ0wCwYDVQQIEwRP +c2xvMQ0wCwYDVQQHEwRPc2xvMQ8wDQYDVQQKEwZUVCBBU0ExDjAMBgNVBAsTBVFU +IFNXMRwwGgYDVQQDExNhc3BpcmluaWtzLnRyb2xsLm5vMSMwIQYJKoZIhvcNAQkB +FhRhYmFiaWNAdHJvbGx0ZWNoLmNvbTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCC +AQoCggEBAMV2bMD1DN3DMgbxU3DXw2i7EWGDXcWjTDtdHvqgIb+9nHqo3MJSrzJy +qgEPoOsXqswMla9wDPZAsWv5gVAmVSqpy2lfEgfY7LaSHiGD75seF7zIy+CxREHW +DofHXpJGGJpBCZEKQt2HfHu3+yAYNPucN78tWNZAcPbUg5tfxMZeepRimAZNIxBI +93SDrl/f9Ka7hvPSzUQsnp8hfdpHlFPFznKfD6yPrjxgz2mT9efavJ4DhtyIa4m+ +paiX515CidDz4A8CFxKZbYvuqq1ilibF/si2so9VhALC77ZcAJP1IMuT8T+WUCxq +skJqiSCncl0Hgr+ba8MDGF9UQYowgjMCAwEAATANBgkqhkiG9w0BAQUFAAOCAQEA +KcJuNUHvjB8ok3cnTmQEeF0LPPkgj28Tqb5TFB8xpVfRI+wvTYsHsmGdOKCgYJ3a +7VflIsr63ojG8/rXK8H/cx2o2f2Hr3liJdi1UnoLDDRjBqGGz7JNuMreYokPvIbm +eP01mVyK4PO2iYRwHUIAw5eeB1vMWKX2z95MupD+HRLtmGyaLALg8aQxj5N84Ewl +eU2PQfhv8A1wj7aL17kfEUxDerQ1kUzlThJMV1J8Dl0l4C9N8evQkelROJU00i46 +oJikA8BW6EpgbnGyNyyj5Loy4wLPKew9nTS8MCJ5xPMQc0urbY/VzuOeUK7WQof7 +xOFSsRAVyQv+yqgmcZMCtg== +-----END CERTIFICATE----- diff --git a/tests/auto/qsslsocket/qsslsocket.pro b/tests/auto/qsslsocket/qsslsocket.pro index c29fc68..147175e 100644 --- a/tests/auto/qsslsocket/qsslsocket.pro +++ b/tests/auto/qsslsocket/qsslsocket.pro @@ -7,12 +7,6 @@ QT -= gui TARGET = tst_qsslsocket -!wince* { -DEFINES += SRCDIR=\\\"$$PWD/\\\" -} else { -DEFINES += SRCDIR=\\\"./\\\" -} - win32 { CONFIG(debug, debug|release) { DESTDIR = debug @@ -21,8 +15,20 @@ win32 { } } -wince*: { - certFiles.sources = certs ssl.tar.gz - certFiles.path = . - DEPLOYMENT += certFiles +wince* { + DEFINES += SRCDIR=\\\"./\\\" + + certFiles.sources = certs ssl.tar.gz + certFiles.path = . + DEPLOYMENT += certFiles +} else:symbian { + DEFINES += QSSLSOCKET_CERTUNTRUSTED_WORKAROUND + TARGET.EPOCHEAPSIZE="0x100 0x1000000" + TARGET.CAPABILITY="ALL -TCB" + + certFiles.sources = certs ssl.tar.gz + certFiles.path = . + DEPLOYMENT += certFiles +} else { + DEFINES += SRCDIR=\\\"$$PWD/\\\" } diff --git a/tests/auto/qsslsocket/tst_qsslsocket.cpp b/tests/auto/qsslsocket/tst_qsslsocket.cpp index 2e31499..85ecf6b 100644 --- a/tests/auto/qsslsocket/tst_qsslsocket.cpp +++ b/tests/auto/qsslsocket/tst_qsslsocket.cpp @@ -76,6 +76,10 @@ Q_DECLARE_METATYPE(QSslError) #define QSSLSOCKET_CERTUNTRUSTED_WORKAROUND #endif +#ifdef Q_OS_SYMBIAN +#define SRCDIR "" +#endif + #ifndef QT_NO_OPENSSL class QSslSocketPtr: public QSharedPointer<QSslSocket> { @@ -177,6 +181,7 @@ private slots: void ignoreSslErrorsList(); void ignoreSslErrorsListWithSlot_data(); void ignoreSslErrorsListWithSlot(); + void readFromClosedSocket(); static void exitLoop() { @@ -195,7 +200,9 @@ protected slots: } void untrustedWorkaroundSlot(const QList<QSslError> &errors) { - if (errors.size() == 1 && errors.first().error() == QSslError::CertificateUntrusted) + if (errors.size() == 1 && + (errors.first().error() == QSslError::CertificateUntrusted || + errors.first().error() == QSslError::SelfSignedCertificate)) socket->ignoreSslErrors(); } void ignoreErrorListSlot(const QList<QSslError> &errors); @@ -219,11 +226,11 @@ tst_QSslSocket::tst_QSslSocket() qRegisterMetaType<QAbstractSocket::SocketError>("QAbstractSocket::SocketError"); qRegisterMetaType<QAbstractSocket::SocketState>("QSslSocket::SslMode"); #endif + Q_SET_DEFAULT_IAP } tst_QSslSocket::~tst_QSslSocket() { - } enum ProxyTests { @@ -427,8 +434,10 @@ void tst_QSslSocket::simpleConnect() enterLoop(10); // Entered connecting state +#ifndef Q_OS_SYMBIAN QCOMPARE(socket.state(), QAbstractSocket::ConnectingState); QCOMPARE(connectedSpy.count(), 0); +#endif QCOMPARE(hostFoundSpy.count(), 1); QCOMPARE(disconnectedSpy.count(), 0); enterLoop(10); @@ -496,8 +505,7 @@ void tst_QSslSocket::simpleConnectWithIgnore() if (!socket.canReadLine()) enterLoop(10); - QCOMPARE(socket.readAll(), QByteArray("* OK [CAPABILITY IMAP4 IMAP4rev1 LITERAL+ ID AUTH=PLAIN SASL-IR] qt-test-server.qt-test-net Cyrus IMAP4 v2.3.11-Mandriva-RPM-2.3.11-6mdv2008.1 server ready\r\n")); - + QCOMPARE(socket.readAll(), QtNetworkSettings::expectedReplySSL()); socket.disconnectFromHost(); } @@ -530,8 +538,9 @@ void tst_QSslSocket::sslErrors() socket->waitForEncrypted(5000); SslErrorList output; - foreach (QSslError error, socket->sslErrors()) + foreach (QSslError error, socket->sslErrors()) { output << error.error(); + } #ifdef QSSLSOCKET_CERTUNTRUSTED_WORKAROUND if (output.last() == QSslError::CertificateUntrusted) @@ -583,16 +592,16 @@ void tst_QSslSocket::connectToHostEncrypted() QSslSocketPtr socket = newSocket(); this->socket = socket; - - QVERIFY(socket->addCaCertificates(QLatin1String(SRCDIR "certs/qt-test-server-cacert.pem"))); + QVERIFY(socket->addCaCertificates(QLatin1String("certs/qt-test-server-cacert.pem"))); #ifdef QSSLSOCKET_CERTUNTRUSTED_WORKAROUND - connect(&socket, SIGNAL(sslErrors(QList<QSslError>)), + connect(socket, SIGNAL(sslErrors(QList<QSslError>)), this, SLOT(untrustedWorkaroundSlot(QList<QSslError>))); #endif socket->connectToHostEncrypted(QtNetworkSettings::serverName(), 443); // This should pass unconditionally when using fluke's CA certificate. + // or use untrusted certificate workaround QVERIFY2(socket->waitForEncrypted(10000), qPrintable(socket->errorString())); socket->disconnectFromHost(); @@ -617,7 +626,7 @@ void tst_QSslSocket::connectToHostEncryptedWithVerificationPeerName() socket->addCaCertificates(QLatin1String(SRCDIR "certs/qt-test-server-cacert.pem")); #ifdef QSSLSOCKET_CERTUNTRUSTED_WORKAROUND - connect(&socket, SIGNAL(sslErrors(QList<QSslError>)), + connect(socket, SIGNAL(sslErrors(QList<QSslError>)), this, SLOT(untrustedWorkaroundSlot(QList<QSslError>))); #endif @@ -683,10 +692,9 @@ void tst_QSslSocket::peerCertificateChain() QList<QSslCertificate> caCertificates = QSslCertificate::fromPath(QLatin1String(SRCDIR "certs/qt-test-server-cacert.pem")); QVERIFY(caCertificates.count() == 1); - socket->addCaCertificates(caCertificates); #ifdef QSSLSOCKET_CERTUNTRUSTED_WORKAROUND - connect(&socket, SIGNAL(sslErrors(QList<QSslError>)), + connect(socket, SIGNAL(sslErrors(QList<QSslError>)), this, SLOT(untrustedWorkaroundSlot(QList<QSslError>))); #endif @@ -747,7 +755,7 @@ void tst_QSslSocket::protocol() // qDebug() << "certs:" << certs.at(0).issuerInfo(QSslCertificate::CommonName); socket->setCaCertificates(certs); #ifdef QSSLSOCKET_CERTUNTRUSTED_WORKAROUND - connect(&socket, SIGNAL(sslErrors(QList<QSslError>)), + connect(socket, SIGNAL(sslErrors(QList<QSslError>)), this, SLOT(untrustedWorkaroundSlot(QList<QSslError>))); #endif @@ -940,11 +948,24 @@ void tst_QSslSocket::waitForConnectedEncryptedReadyRead() connect(socket, SIGNAL(sslErrors(const QList<QSslError> &)), this, SLOT(ignoreErrorSlot())); socket->connectToHostEncrypted(QtNetworkSettings::serverName(), 993); +#ifdef Q_OS_SYMBIAN + QVERIFY(socket->waitForConnected(10000)); + QVERIFY(socket->waitForEncrypted(10000)); + + // dont forget to login + QCOMPARE((int) socket->write("USER ftptest\r\n"), 14); + QCOMPARE((int) socket->write("PASS ftP2Ptf\r\n"), 14); + + QVERIFY(socket->waitForReadyRead(10000)); + QVERIFY(!socket->peerCertificate().isNull()); + QVERIFY(!socket->peerCertificateChain().isEmpty()); +#else QVERIFY(socket->waitForConnected(10000)); QVERIFY(socket->waitForEncrypted(10000)); QVERIFY(socket->waitForReadyRead(10000)); QVERIFY(!socket->peerCertificate().isNull()); QVERIFY(!socket->peerCertificateChain().isEmpty()); +#endif } void tst_QSslSocket::startClientEncryption() @@ -1035,7 +1056,7 @@ void tst_QSslSocket::systemCaCertificates() void tst_QSslSocket::wildcard() { - QSKIP("TODO: solve wildcard problem", SkipAll); + QSKIP("TODO: solve wildcard problem", SkipAll); if (!QSslSocket::supportsSsl()) return; @@ -1047,7 +1068,7 @@ void tst_QSslSocket::wildcard() // responds with the wildcard, and QSslSocket should accept that as a // valid connection. This was broken in 4.3.0. QSslSocketPtr socket = newSocket(); - socket->addCaCertificates(QLatin1String(SRCDIR "certs/qt-test-server-cacert.pem")); + socket->addCaCertificates(QLatin1String("certs/aspiriniks.ca.crt")); this->socket = socket; #ifdef QSSLSOCKET_CERTUNTRUSTED_WORKAROUND connect(socket, SIGNAL(sslErrors(QList<QSslError>)), @@ -1290,7 +1311,11 @@ protected: // delayed acceptance: QTest::qSleep(100); - server.waitForNewConnection(2000); +#ifndef Q_OS_SYMBIAN + bool ret = server.waitForNewConnection(2000); +#else + bool ret = server.waitForNewConnection(20000); +#endif // delayed start of encryption QTest::qSleep(100); @@ -1478,18 +1503,22 @@ void tst_QSslSocket::disconnectFromHostWhenConnecting() // without proxy, the state will be HostLookupState; // with proxy, the state will be ConnectingState. QVERIFY(socket->state() == QAbstractSocket::HostLookupState || - socket->state() == QAbstractSocket::ConnectingState); + socket->state() == QAbstractSocket::ConnectingState); socket->disconnectFromHost(); // the state of the socket must be the same before and after calling // disconnectFromHost() QCOMPARE(state, socket->state()); QVERIFY(socket->state() == QAbstractSocket::HostLookupState || - socket->state() == QAbstractSocket::ConnectingState); + socket->state() == QAbstractSocket::ConnectingState); QVERIFY(socket->waitForDisconnected(5000)); QCOMPARE(socket->state(), QAbstractSocket::UnconnectedState); // we did not call close, so the socket must be still open QVERIFY(socket->isOpen()); QCOMPARE(socket->bytesToWrite(), qint64(0)); + + // dont forget to login + QCOMPARE((int) socket->write("USER ftptest\r\n"), 14); + } void tst_QSslSocket::disconnectFromHostWhenConnected() @@ -1497,12 +1526,27 @@ void tst_QSslSocket::disconnectFromHostWhenConnected() QSslSocketPtr socket = newSocket(); socket->connectToHostEncrypted(QtNetworkSettings::serverName(), 993); socket->ignoreSslErrors(); +#ifndef Q_OS_SYMBIAN QVERIFY(socket->waitForEncrypted(5000)); +#else + QVERIFY(socket->waitForEncrypted(10000)); +#endif socket->write("XXXX LOGOUT\r\n"); QCOMPARE(socket->state(), QAbstractSocket::ConnectedState); socket->disconnectFromHost(); QCOMPARE(socket->state(), QAbstractSocket::ClosingState); +#ifdef Q_OS_SYMBIAN + // I don't understand how socket->waitForDisconnected can work on other platforms + // since socket->write will end to: + // QMetaObject::invokeMethod(this, "_q_flushWriteBuffer", Qt::QueuedConnection); + // In order that _q_flushWriteBuffer will be called the eventloop need to run + // If we just call waitForDisconnected, which blocks the whole thread how that can happen? + connect(socket, SIGNAL(disconnected()), this, SLOT(exitLoop())); + enterLoop(5); + QVERIFY(!timeout()); +#else QVERIFY(socket->waitForDisconnected(5000)); +#endif QCOMPARE(socket->bytesToWrite(), qint64(0)); } @@ -1529,6 +1573,12 @@ void tst_QSslSocket::resetProxy() socket.connectToHostEncrypted(QtNetworkSettings::serverName(), 443); QVERIFY(! socket.waitForConnected(10000)); + // dont forget to login + QCOMPARE((int) socket.write("USER ftptest\r\n"), 14); + QCOMPARE((int) socket.write("PASS password\r\n"), 15); + + enterLoop(10); + // now the other way round: // set the nonsense proxy and make sure the connection does not work, // and then set the right proxy and make sure it works @@ -1619,6 +1669,34 @@ void tst_QSslSocket::ignoreSslErrorsListWithSlot() QCOMPARE(socket.waitForEncrypted(10000), expectEncryptionSuccess); } +// make sure a closed socket has no bytesAvailable() +// related to https://bugs.webkit.org/show_bug.cgi?id=28016 +void tst_QSslSocket::readFromClosedSocket() +{ + QSslSocketPtr socket = newSocket(); + socket->ignoreSslErrors(); + socket->connectToHostEncrypted(QtNetworkSettings::serverName(), 443); + socket->ignoreSslErrors(); + socket->waitForConnected(); + socket->waitForEncrypted(); + // provoke a response by sending a request + socket->write("GET /gif/fluke.gif HTTP/1.1\n"); + socket->write("Host: "); + socket->write(QtNetworkSettings::serverName().toLocal8Bit().constData()); + socket->write("\n"); + socket->write("\n"); + socket->waitForBytesWritten(); + socket->waitForReadyRead(); + QVERIFY(socket->state() == QAbstractSocket::ConnectedState); + QVERIFY(socket->bytesAvailable()); + socket->close(); + QVERIFY(!socket->bytesAvailable()); + QVERIFY(!socket->bytesToWrite()); + socket->waitForDisconnected(); + QVERIFY(!socket->bytesAvailable()); + QVERIFY(!socket->bytesToWrite()); +} + #endif // QT_NO_OPENSSL QTEST_MAIN(tst_QSslSocket) diff --git a/tests/auto/qstandarditem/tst_qstandarditem.cpp b/tests/auto/qstandarditem/tst_qstandarditem.cpp index d7fdace..e2a5278 100644 --- a/tests/auto/qstandarditem/tst_qstandarditem.cpp +++ b/tests/auto/qstandarditem/tst_qstandarditem.cpp @@ -291,12 +291,14 @@ void tst_QStandardItem::getSetFlags() item.setTristate(true); QVERIFY(item.isTristate()); QVERIFY(item.flags() & Qt::ItemIsTristate); +#ifndef QT_NO_DRAGANDDROP item.setDragEnabled(true); QVERIFY(item.isDragEnabled()); QVERIFY(item.flags() & Qt::ItemIsDragEnabled); item.setDropEnabled(true); QVERIFY(item.isDropEnabled()); QVERIFY(item.flags() & Qt::ItemIsDropEnabled); +#endif QVERIFY(item.isEnabled()); item.setEnabled(false); @@ -318,6 +320,7 @@ void tst_QStandardItem::getSetFlags() item.setTristate(false); QVERIFY(!item.isTristate()); QVERIFY(!(item.flags() & Qt::ItemIsTristate)); +#ifndef QT_NO_DRAGANDDROP QVERIFY(item.isDragEnabled()); item.setDragEnabled(false); QVERIFY(!item.isDragEnabled()); @@ -326,6 +329,7 @@ void tst_QStandardItem::getSetFlags() item.setDropEnabled(false); QVERIFY(!item.isDropEnabled()); QVERIFY(!(item.flags() & Qt::ItemIsDropEnabled)); +#endif item.setCheckable(false); item.setCheckState(Qt::Checked); diff --git a/tests/auto/qstandarditemmodel/tst_qstandarditemmodel.cpp b/tests/auto/qstandarditemmodel/tst_qstandarditemmodel.cpp index 60655ee..4d1bc61 100644 --- a/tests/auto/qstandarditemmodel/tst_qstandarditemmodel.cpp +++ b/tests/auto/qstandarditemmodel/tst_qstandarditemmodel.cpp @@ -1388,7 +1388,9 @@ void tst_QStandardItemModel::rootItemFlags() QCOMPARE(model.invisibleRootItem()->flags() , f); QCOMPARE(model.invisibleRootItem()->flags() , model.flags(QModelIndex())); +#ifndef QT_NO_DRAGANDDROP model.invisibleRootItem()->setDropEnabled(false); +#endif QCOMPARE(model.invisibleRootItem()->flags() , Qt::ItemIsEnabled); QCOMPARE(model.invisibleRootItem()->flags() , model.flags(QModelIndex())); } @@ -1527,7 +1529,9 @@ void tst_QStandardItemModel::treeDragAndDrop() view.setModel(&model); view.expandAll(); view.show(); +#ifndef QT_NO_DRAGANDDROP view.setDragDropMode(QAbstractItemView::InternalMove); +#endif view.setSelectionMode(QAbstractItemView::ExtendedSelection); QItemSelectionModel *selection = view.selectionModel(); diff --git a/tests/auto/qstatemachine/tst_qstatemachine.cpp b/tests/auto/qstatemachine/tst_qstatemachine.cpp index 9fd6b5d..20e69ce 100644 --- a/tests/auto/qstatemachine/tst_qstatemachine.cpp +++ b/tests/auto/qstatemachine/tst_qstatemachine.cpp @@ -129,7 +129,7 @@ private slots: void transitionToRootState(); void transitionFromRootState(); void transitionEntersParent(); - + void defaultErrorState(); void customGlobalErrorState(); void customLocalErrorStateInBrokenState(); @@ -148,16 +148,16 @@ private slots: void customErrorStateNotInGraph(); void transitionToStateNotInGraph(); void restoreProperties(); - + void defaultGlobalRestorePolicy(); void globalRestorePolicySetToRestore(); void globalRestorePolicySetToDoNotRestore(); void noInitialStateForInitialState(); - + //void restorePolicyNotInherited(); //void mixedRestoreProperties(); - //void setRestorePolicyToDoNotRestore(); + //void setRestorePolicyToDoNotRestore(); //void setGlobalRestorePolicyToGlobalRestore(); //void restorePolicyOnChildState(); @@ -186,7 +186,7 @@ private slots: // void removeDefaultAnimationForSource(); // void removeDefaultAnimationForTarget(); // void overrideDefaultAnimationWithSource(); -// void overrideDefaultAnimationWithTarget(); +// void overrideDefaultAnimationWithTarget(); // void overrideDefaultSourceAnimationWithSpecific(); // void overrideDefaultTargetAnimationWithSpecific(); // void overrideDefaultTargetAnimationWithSource(); @@ -274,7 +274,7 @@ void tst_QStateMachine::transitionToRootState() QAbstractTransition *trans = initialState->addTransition(new EventTransition(QEvent::User, &machine)); QVERIFY(trans != 0); QCOMPARE(trans->sourceState(), initialState); - QCOMPARE(trans->targetState(), &machine); + QCOMPARE(trans->targetState(), static_cast<QAbstractState *>(&machine)); machine.start(); QCoreApplication::processEvents(); @@ -295,9 +295,9 @@ void tst_QStateMachine::transitionFromRootState() QState *root = &machine; QState *s1 = new QState(root); EventTransition *trans = new EventTransition(QEvent::User, s1); - QCOMPARE(root->addTransition(trans), trans); + QCOMPARE(root->addTransition(trans), static_cast<QAbstractTransition *>(trans)); QCOMPARE(trans->sourceState(), root); - QCOMPARE(trans->targetState(), s1); + QCOMPARE(trans->targetState(), static_cast<QAbstractState *>(s1)); } void tst_QStateMachine::transitionEntersParent() @@ -393,14 +393,14 @@ void tst_QStateMachine::defaultErrorState() class CustomErrorState: public QState { public: - CustomErrorState(QStateMachine *machine, QState *parent = 0) + CustomErrorState(QStateMachine *machine, QState *parent = 0) : QState(parent), error(QStateMachine::NoError), m_machine(machine) { } void onEntry(QEvent *) { - error = m_machine->error(); + error = m_machine->error(); errorString = m_machine->errorString(); } @@ -444,7 +444,7 @@ void tst_QStateMachine::customGlobalErrorState() QVERIFY(machine.configuration().contains(initialState)); QCoreApplication::processEvents(); - + QCOMPARE(machine.isRunning(), true); QCOMPARE(machine.configuration().count(), 1); QVERIFY(machine.configuration().contains(customErrorState)); @@ -455,7 +455,7 @@ void tst_QStateMachine::customGlobalErrorState() } void tst_QStateMachine::customLocalErrorStateInBrokenState() -{ +{ QStateMachine machine; CustomErrorState *customErrorState = new CustomErrorState(&machine); machine.addState(customErrorState); @@ -467,15 +467,15 @@ void tst_QStateMachine::customLocalErrorStateInBrokenState() QState *brokenState = new QState(); brokenState->setObjectName("brokenState"); - machine.addState(brokenState); - brokenState->setErrorState(customErrorState); + machine.addState(brokenState); + brokenState->setErrorState(customErrorState); QState *childState = new QState(brokenState); childState->setObjectName("childState"); initialState->addTransition(new EventTransition(QEvent::Type(QEvent::User + 1), brokenState)); - machine.start(); + machine.start(); QCoreApplication::processEvents(); machine.postEvent(new QEvent(QEvent::Type(QEvent::User + 1))); @@ -495,15 +495,15 @@ void tst_QStateMachine::customLocalErrorStateInOtherState() QState *initialState = new QState(); initialState->setObjectName("initialState"); - QTest::ignoreMessage(QtWarningMsg, "QState::setErrorState: error state cannot belong to a different state machine"); + QTest::ignoreMessage(QtWarningMsg, "QState::setErrorState: error state cannot belong to a different state machine"); initialState->setErrorState(customErrorState); machine.addState(initialState); machine.setInitialState(initialState); QState *brokenState = new QState(); brokenState->setObjectName("brokenState"); - - machine.addState(brokenState); + + machine.addState(brokenState); QState *childState = new QState(brokenState); childState->setObjectName("childState"); @@ -534,7 +534,7 @@ void tst_QStateMachine::customLocalErrorStateInParentOfBrokenState() QState *parentOfBrokenState = new QState(); machine.addState(parentOfBrokenState); parentOfBrokenState->setObjectName("parentOfBrokenState"); - parentOfBrokenState->setErrorState(customErrorState); + parentOfBrokenState->setErrorState(customErrorState); QState *brokenState = new QState(parentOfBrokenState); brokenState->setObjectName("brokenState"); @@ -574,7 +574,7 @@ void tst_QStateMachine::customLocalErrorStateOverridesParent() machine.addState(parentOfBrokenState); parentOfBrokenState->setObjectName("parentOfBrokenState"); parentOfBrokenState->setErrorState(customErrorStateForParent); - + QState *brokenState = new QState(parentOfBrokenState); brokenState->setObjectName("brokenState"); brokenState->setErrorState(customErrorStateForBrokenState); @@ -613,10 +613,10 @@ void tst_QStateMachine::errorStateHasChildren() QState *initialState = new QState(); initialState->setObjectName("initialState"); machine.addState(initialState); - machine.setInitialState(initialState); + machine.setInitialState(initialState); QState *brokenState = new QState(); - brokenState->setObjectName("brokenState"); + brokenState->setObjectName("brokenState"); machine.addState(brokenState); QState *childState = new QState(brokenState); @@ -633,7 +633,7 @@ void tst_QStateMachine::errorStateHasChildren() QCOMPARE(machine.isRunning(), true); QCOMPARE(machine.configuration().count(), 2); QVERIFY(machine.configuration().contains(customErrorState)); - QVERIFY(machine.configuration().contains(childOfErrorState)); + QVERIFY(machine.configuration().contains(childOfErrorState)); } @@ -652,10 +652,10 @@ void tst_QStateMachine::errorStateHasErrors() QState *initialState = new QState(); initialState->setObjectName("initialState"); machine.addState(initialState); - machine.setInitialState(initialState); + machine.setInitialState(initialState); QState *brokenState = new QState(); - brokenState->setObjectName("brokenState"); + brokenState->setObjectName("brokenState"); machine.addState(brokenState); QState *childState = new QState(brokenState); @@ -684,10 +684,10 @@ void tst_QStateMachine::errorStateIsRootState() QState *initialState = new QState(); initialState->setObjectName("initialState"); machine.addState(initialState); - machine.setInitialState(initialState); - + machine.setInitialState(initialState); + QState *brokenState = new QState(); - brokenState->setObjectName("brokenState"); + brokenState->setObjectName("brokenState"); machine.addState(brokenState); QState *childState = new QState(brokenState); @@ -724,7 +724,7 @@ void tst_QStateMachine::errorStateEntersParentFirst() QState *grandParent = new QState(greatGrandParent); grandParent->setObjectName("grandParent"); - grandParent->assignProperty(entryController, "grandParentEntered", true); + grandParent->assignProperty(entryController, "grandParentEntered", true); QState *parent = new QState(grandParent); parent->setObjectName("parent"); @@ -739,7 +739,7 @@ void tst_QStateMachine::errorStateEntersParentFirst() initialStateOfGreatGrandParent->setObjectName("initialStateOfGreatGrandParent"); greatGrandParent->setInitialState(initialStateOfGreatGrandParent); - QState *brokenState = new QState(greatGrandParent); + QState *brokenState = new QState(greatGrandParent); brokenState->setObjectName("brokenState"); QState *childState = new QState(brokenState); @@ -805,9 +805,9 @@ void tst_QStateMachine::customErrorStateIsNull() void tst_QStateMachine::clearError() { - QStateMachine machine; + QStateMachine machine; machine.setErrorState(new QState(&machine)); // avoid warnings - + QState *brokenState = new QState(&machine); brokenState->setObjectName("brokenState"); machine.setInitialState(brokenState); @@ -840,10 +840,10 @@ void tst_QStateMachine::historyStateAsInitialState() QHistoryState *s2h = new QHistoryState(s2); s2->setInitialState(s2h); - + QState *s21 = new QState(s2); s2h->setDefaultState(s21); - + s1->addTransition(new EventTransition(QEvent::User, s2)); machine.start(); @@ -898,17 +898,17 @@ void tst_QStateMachine::brokenStateIsNeverEntered() entryController->setProperty("childStateEntered", false); entryController->setProperty("errorStateEntered", false); - QState *initialState = new QState(&machine); + QState *initialState = new QState(&machine); machine.setInitialState(initialState); QState *errorState = new QState(&machine); errorState->assignProperty(entryController, "errorStateEntered", true); - machine.setErrorState(errorState); + machine.setErrorState(errorState); QState *brokenState = new QState(&machine); brokenState->assignProperty(entryController, "brokenStateEntered", true); brokenState->setObjectName("brokenState"); - + QState *childState = new QState(brokenState); childState->assignProperty(entryController, "childStateEntered", true); @@ -927,7 +927,7 @@ void tst_QStateMachine::brokenStateIsNeverEntered() void tst_QStateMachine::transitionToStateNotInGraph() { - QStateMachine machine; + QStateMachine machine; QState *initialState = new QState(&machine); initialState->setObjectName("initialState"); @@ -1024,11 +1024,11 @@ void tst_QStateMachine::rootState() QCOMPARE(machine.machine(), (QStateMachine*)0); QState *s1 = new QState(&machine); - QCOMPARE(s1->parentState(), &machine); + QCOMPARE(s1->parentState(), static_cast<QState*>(&machine)); QState *s2 = new QState(); s2->setParent(&machine); - QCOMPARE(s2->parentState(), &machine); + QCOMPARE(s2->parentState(), static_cast<QState*>(&machine)); } void tst_QStateMachine::addAndRemoveState() @@ -1036,7 +1036,7 @@ void tst_QStateMachine::addAndRemoveState() #ifdef QT_BUILD_INTERNAL QStateMachine machine; QStatePrivate *root_d = QStatePrivate::get(&machine); - QCOMPARE(root_d->childStates().size(), 0); + QCOMPARE(root_d->childStates().size(), 0); QTest::ignoreMessage(QtWarningMsg, "QStateMachine::addState: cannot add null state"); machine.addState(0); @@ -1045,8 +1045,8 @@ void tst_QStateMachine::addAndRemoveState() QCOMPARE(s1->parentState(), (QState*)0); QCOMPARE(s1->machine(), (QStateMachine*)0); machine.addState(s1); - QCOMPARE(s1->machine(), &machine); - QCOMPARE(s1->parentState(), &machine); + QCOMPARE(s1->machine(), static_cast<QStateMachine*>(&machine)); + QCOMPARE(s1->parentState(), static_cast<QState*>(&machine)); QCOMPARE(root_d->childStates().size(), 1); QCOMPARE(root_d->childStates().at(0), (QAbstractState*)s1); @@ -1056,7 +1056,7 @@ void tst_QStateMachine::addAndRemoveState() QState *s2 = new QState(); QCOMPARE(s2->parentState(), (QState*)0); machine.addState(s2); - QCOMPARE(s2->parentState(), &machine); + QCOMPARE(s2->parentState(), static_cast<QState*>(&machine)); QCOMPARE(root_d->childStates().size(), 2); QCOMPARE(root_d->childStates().at(0), (QAbstractState*)s1); QCOMPARE(root_d->childStates().at(1), (QAbstractState*)s2); @@ -1520,7 +1520,7 @@ public: { setTargetState(target); } protected: - virtual bool eventTest(QEvent *e) + virtual bool eventTest(QEvent *e) { if (e->type() != QEvent::Type(QEvent::User+2)) return false; @@ -2066,7 +2066,7 @@ void tst_QStateMachine::eventTransitions() QPushButton button2; machine.start(); QCoreApplication::processEvents(); - trans->setEventObject(&button2); + trans->setEventSource(&button2); QTest::mousePress(&button2, Qt::LeftButton); QTRY_COMPARE(finishedSpy.count(), 4); } @@ -2078,16 +2078,16 @@ void tst_QStateMachine::eventTransitions() QEventTransition *trans; if (x == 0) { trans = new QEventTransition(); - QCOMPARE(trans->eventObject(), (QObject*)0); + QCOMPARE(trans->eventSource(), (QObject*)0); QCOMPARE(trans->eventType(), QEvent::None); - trans->setEventObject(&button); + trans->setEventSource(&button); trans->setEventType(QEvent::MouseButtonPress); trans->setTargetState(s1); } else if (x == 1) { trans = new QEventTransition(&button, QEvent::MouseButtonPress); trans->setTargetState(s1); } - QCOMPARE(trans->eventObject(), (QObject*)&button); + QCOMPARE(trans->eventSource(), (QObject*)&button); QCOMPARE(trans->eventType(), QEvent::MouseButtonPress); QCOMPARE(trans->targetState(), (QAbstractState*)s1); s0->addTransition(trans); @@ -2108,10 +2108,10 @@ void tst_QStateMachine::eventTransitions() QFinalState *s1 = new QFinalState(&machine); QMouseEventTransition *trans = new QMouseEventTransition(); - QCOMPARE(trans->eventObject(), (QObject*)0); + QCOMPARE(trans->eventSource(), (QObject*)0); QCOMPARE(trans->eventType(), QEvent::None); QCOMPARE(trans->button(), Qt::NoButton); - trans->setEventObject(&button); + trans->setEventSource(&button); trans->setEventType(QEvent::MouseButtonPress); trans->setButton(Qt::LeftButton); trans->setTargetState(s1); @@ -2155,10 +2155,10 @@ void tst_QStateMachine::eventTransitions() QFinalState *s1 = new QFinalState(&machine); QKeyEventTransition *trans = new QKeyEventTransition(); - QCOMPARE(trans->eventObject(), (QObject*)0); + QCOMPARE(trans->eventSource(), (QObject*)0); QCOMPARE(trans->eventType(), QEvent::None); QCOMPARE(trans->key(), 0); - trans->setEventObject(&button); + trans->setEventSource(&button); trans->setEventType(QEvent::KeyPress); trans->setKey(Qt::Key_A); trans->setTargetState(s1); @@ -2401,7 +2401,7 @@ void tst_QStateMachine::targetStateWithNoParent() machine.start(); QTest::ignoreMessage(QtWarningMsg, "Unrecoverable error detected in running state machine: No common ancestor for targets and source of transition from state 's1'"); QTRY_COMPARE(startedSpy.count(), 1); - QCOMPARE(machine.isRunning(), false); + QCOMPARE(machine.isRunning(), false); QCOMPARE(stoppedSpy.count(), 1); QCOMPARE(finishedSpy.count(), 0); QCOMPARE(machine.error(), QStateMachine::NoCommonAncestorForTransitionError); @@ -2421,7 +2421,7 @@ void tst_QStateMachine::targetStateDeleted() void tst_QStateMachine::defaultGlobalRestorePolicy() { - QStateMachine machine; + QStateMachine machine; QObject *propertyHolder = new QObject(&machine); propertyHolder->setProperty("a", 1); @@ -2441,7 +2441,7 @@ void tst_QStateMachine::defaultGlobalRestorePolicy() machine.setInitialState(s1); machine.start(); QCoreApplication::processEvents(); - + QCOMPARE(propertyHolder->property("a").toInt(), 3); QCOMPARE(propertyHolder->property("b").toInt(), 2); @@ -2455,7 +2455,7 @@ void tst_QStateMachine::defaultGlobalRestorePolicy() QCoreApplication::processEvents(); QCOMPARE(propertyHolder->property("a").toInt(), 3); - QCOMPARE(propertyHolder->property("b").toInt(), 4); + QCOMPARE(propertyHolder->property("b").toInt(), 4); } void tst_QStateMachine::noInitialStateForInitialState() @@ -2481,7 +2481,7 @@ void tst_QStateMachine::noInitialStateForInitialState() /* void tst_QStateMachine::restorePolicyNotInherited() { - QStateMachine machine; + QStateMachine machine; QObject *propertyHolder = new QObject(); propertyHolder->setProperty("a", 1); @@ -2509,7 +2509,7 @@ void tst_QStateMachine::restorePolicyNotInherited() machine.setInitialState(parentState); machine.start(); QCoreApplication::processEvents(); - + QCOMPARE(propertyHolder->property("a").toInt(), 3); QCOMPARE(propertyHolder->property("b").toInt(), 2); @@ -2523,7 +2523,7 @@ void tst_QStateMachine::restorePolicyNotInherited() QCoreApplication::processEvents(); QCOMPARE(propertyHolder->property("a").toInt(), 3); - QCOMPARE(propertyHolder->property("b").toInt(), 4); + QCOMPARE(propertyHolder->property("b").toInt(), 4); }*/ @@ -2550,7 +2550,7 @@ void tst_QStateMachine::globalRestorePolicySetToDoNotRestore() machine.setInitialState(s1); machine.start(); QCoreApplication::processEvents(); - + QCOMPARE(propertyHolder->property("a").toInt(), 3); QCOMPARE(propertyHolder->property("b").toInt(), 2); @@ -2564,7 +2564,7 @@ void tst_QStateMachine::globalRestorePolicySetToDoNotRestore() QCoreApplication::processEvents(); QCOMPARE(propertyHolder->property("a").toInt(), 3); - QCOMPARE(propertyHolder->property("b").toInt(), 4); + QCOMPARE(propertyHolder->property("b").toInt(), 4); } /* @@ -2670,7 +2670,7 @@ void tst_QStateMachine::restorePolicyOnChildState() machine.setInitialState(parentState); machine.start(); QCoreApplication::processEvents(); - + QCOMPARE(propertyHolder->property("a").toInt(), 3); QCOMPARE(propertyHolder->property("b").toInt(), 2); @@ -2684,13 +2684,13 @@ void tst_QStateMachine::restorePolicyOnChildState() QCoreApplication::processEvents(); QCOMPARE(propertyHolder->property("a").toInt(), 1); - QCOMPARE(propertyHolder->property("b").toInt(), 2); + QCOMPARE(propertyHolder->property("b").toInt(), 2); } */ void tst_QStateMachine::globalRestorePolicySetToRestore() { - QStateMachine machine; + QStateMachine machine; machine.setGlobalRestorePolicy(QStateMachine::RestoreProperties); QObject *propertyHolder = new QObject(&machine); @@ -2711,7 +2711,7 @@ void tst_QStateMachine::globalRestorePolicySetToRestore() machine.setInitialState(s1); machine.start(); QCoreApplication::processEvents(); - + QCOMPARE(propertyHolder->property("a").toInt(), 3); QCOMPARE(propertyHolder->property("b").toInt(), 2); @@ -2725,16 +2725,16 @@ void tst_QStateMachine::globalRestorePolicySetToRestore() QCoreApplication::processEvents(); QCOMPARE(propertyHolder->property("a").toInt(), 1); - QCOMPARE(propertyHolder->property("b").toInt(), 2); + QCOMPARE(propertyHolder->property("b").toInt(), 2); } /* void tst_QStateMachine::mixedRestoreProperties() { - QStateMachine machine; + QStateMachine machine; QObject *propertyHolder = new QObject(); - propertyHolder->setProperty("a", 1); + propertyHolder->setProperty("a", 1); QState *s1 = new QState(&machine); s1->setRestorePolicy(QState::RestoreProperties); @@ -2761,7 +2761,7 @@ void tst_QStateMachine::mixedRestoreProperties() machine.setInitialState(s1); machine.start(); QCoreApplication::processEvents(); - + // Enter s1, save current QCOMPARE(propertyHolder->property("a").toInt(), 3); @@ -2837,7 +2837,7 @@ void tst_QStateMachine::simpleAnimation() QCOREAPPLICATION_EXEC(5000); QVERIFY(machine.configuration().contains(s3)); - QCOMPARE(object->property("fooBar").toDouble(), 2.0); + QCOMPARE(object->property("fooBar").toDouble(), 2.0); } class SlotCalledCounter: public QObject @@ -2870,7 +2870,7 @@ void tst_QStateMachine::twoAnimations() animationBar->setDuration(900); SlotCalledCounter counter; - connect(animationFoo, SIGNAL(finished()), &counter, SLOT(slot())); + connect(animationFoo, SIGNAL(finished()), &counter, SLOT(slot())); connect(animationBar, SIGNAL(finished()), &counter, SLOT(slot())); EventTransition *et = new EventTransition(QEvent::User, s2); @@ -2892,7 +2892,7 @@ void tst_QStateMachine::twoAnimations() QVERIFY(machine.configuration().contains(s3)); QCOMPARE(object->property("foo").toDouble(), 2.0); QCOMPARE(object->property("bar").toDouble(), 10.0); - + QCOMPARE(counter.counter, 2); } @@ -3005,12 +3005,12 @@ void tst_QStateMachine::nestedTargetStateForAnimation() QState *s2Child2 = new QState(s2); s2Child2->assignProperty(object, "bar", 11.0); QAbstractTransition *at = s2Child->addTransition(new EventTransition(QEvent::User, s2Child2)); - + QPropertyAnimation *animation = new QPropertyAnimation(object, "bar", s2); animation->setDuration(2000); connect(animation, SIGNAL(finished()), &counter, SLOT(slot())); at->addAnimation(animation); - + at = s1->addTransition(new EventTransition(QEvent::User, s2)); animation = new QPropertyAnimation(object, "foo", s2); @@ -3020,7 +3020,7 @@ void tst_QStateMachine::nestedTargetStateForAnimation() animation = new QPropertyAnimation(object, "bar", s2); connect(animation, SIGNAL(finished()), &counter, SLOT(slot())); at->addAnimation(animation); - + QState *s3 = new QState(&machine); s2->addTransition(s2Child, SIGNAL(polished()), s3); @@ -3062,7 +3062,7 @@ void tst_QStateMachine::animatedGlobalRestoreProperty() QPropertyAnimation *pa = new QPropertyAnimation(object, "foo", s2); connect(pa, SIGNAL(finished()), &counter, SLOT(slot())); at->addAnimation(pa); - + at = s2->addTransition(pa, SIGNAL(finished()), s3); pa = new QPropertyAnimation(object, "foo", s3); connect(pa, SIGNAL(finished()), &counter, SLOT(slot())); @@ -3104,7 +3104,7 @@ void tst_QStateMachine::specificTargetValueOfAnimation() QState *s3 = new QState(&machine); QObject::connect(s3, SIGNAL(entered()), QCoreApplication::instance(), SLOT(quit())); - s2->addTransition(anim, SIGNAL(finished()), s3); + s2->addTransition(anim, SIGNAL(finished()), s3); machine.setInitialState(s1); machine.start(); @@ -3134,7 +3134,7 @@ void tst_QStateMachine::addDefaultAnimation() QState *s3 = new QState(&machine); QObject::connect(s3, SIGNAL(entered()), QCoreApplication::instance(), SLOT(quit())); - + s1->addTransition(new EventTransition(QEvent::User, s2)); QPropertyAnimation *pa = new QPropertyAnimation(object, "foo", &machine); @@ -3171,7 +3171,7 @@ void tst_QStateMachine::addDefaultAnimationWithUnusedAnimation() QState *s3 = new QState(&machine); QObject::connect(s3, SIGNAL(entered()), QCoreApplication::instance(), SLOT(quit())); - + s1->addTransition(new EventTransition(QEvent::User, s2)); QPropertyAnimation *pa = new QPropertyAnimation(object, "foo", &machine); @@ -3216,7 +3216,7 @@ void tst_QStateMachine::removeDefaultAnimation() QCOMPARE(machine.defaultAnimations().size(), 0); machine.addDefaultAnimation(anim); - + QPropertyAnimation *anim2 = new QPropertyAnimation(&propertyHolder, "foo"); machine.addDefaultAnimation(anim2); @@ -3255,8 +3255,8 @@ void tst_QStateMachine::overrideDefaultAnimationWithSpecific() QObject::connect(s3, SIGNAL(entered()), QCoreApplication::instance(), SLOT(quit())); QAbstractTransition *at = s1->addTransition(new EventTransition(QEvent::User, s2)); - - QPropertyAnimation *defaultAnimation = new QPropertyAnimation(object, "foo"); + + QPropertyAnimation *defaultAnimation = new QPropertyAnimation(object, "foo"); connect(defaultAnimation, SIGNAL(stateChanged(QAbstractAnimation::State, QAbstractAnimation::State)), &counter, SLOT(slot())); QPropertyAnimation *moreSpecificAnimation = new QPropertyAnimation(object, "foo"); @@ -3294,7 +3294,7 @@ void tst_QStateMachine::addDefaultAnimationForSource() QState *s3 = new QState(&machine); QObject::connect(s3, SIGNAL(entered()), QCoreApplication::instance(), SLOT(quit())); - + s1->addTransition(new EventTransition(QEvent::User, s2)); QPropertyAnimation *pa = new QPropertyAnimation(object, "foo", &machine); @@ -3326,7 +3326,7 @@ void tst_QStateMachine::addDefaultAnimationForTarget() QState *s3 = new QState(&machine); QObject::connect(s3, SIGNAL(entered()), QCoreApplication::instance(), SLOT(quit())); - + s1->addTransition(new EventTransition(QEvent::User, s2)); QPropertyAnimation *pa = new QPropertyAnimation(object, "foo", &machine); @@ -3371,7 +3371,7 @@ void tst_QStateMachine::removeDefaultAnimationForSource() QCOMPARE(machine.defaultAnimationsForSourceState(&machine).size(), 0); machine.addDefaultAnimationForSourceState(&machine, anim); - + QPropertyAnimation *anim2 = new QPropertyAnimation(this, "foo"); machine.addDefaultAnimationForSourceState(&machine, anim2); @@ -3415,7 +3415,7 @@ void tst_QStateMachine::removeDefaultAnimationForTarget() QCOMPARE(machine.defaultAnimationsForTargetState(&machine).size(), 0); machine.addDefaultAnimationForTargetState(&machine, anim); - + QPropertyAnimation *anim2 = new QPropertyAnimation(this, "foo"); machine.addDefaultAnimationForTargetState(&machine, anim2); @@ -3450,9 +3450,9 @@ void tst_QStateMachine::overrideDefaultAnimationWithSource() QState *s3 = new QState(&machine); QObject::connect(s3, SIGNAL(entered()), QCoreApplication::instance(), SLOT(quit())); - s1->addTransition(new EventTransition(QEvent::User, s2)); - - QPropertyAnimation *defaultAnimation = new QPropertyAnimation(object, "foo"); + s1->addTransition(new EventTransition(QEvent::User, s2)); + + QPropertyAnimation *defaultAnimation = new QPropertyAnimation(object, "foo"); connect(defaultAnimation, SIGNAL(stateChanged(QAbstractAnimation::State, QAbstractAnimation::State)), &counter, SLOT(slot())); QPropertyAnimation *moreSpecificAnimation = new QPropertyAnimation(object, "foo"); @@ -3490,9 +3490,9 @@ void tst_QStateMachine::overrideDefaultAnimationWithTarget() QState *s3 = new QState(&machine); QObject::connect(s3, SIGNAL(entered()), QCoreApplication::instance(), SLOT(quit())); - s1->addTransition(new EventTransition(QEvent::User, s2)); - - QPropertyAnimation *defaultAnimation = new QPropertyAnimation(object, "foo"); + s1->addTransition(new EventTransition(QEvent::User, s2)); + + QPropertyAnimation *defaultAnimation = new QPropertyAnimation(object, "foo"); connect(defaultAnimation, SIGNAL(stateChanged(QAbstractAnimation::State, QAbstractAnimation::State)), &counter, SLOT(slot())); QPropertyAnimation *moreSpecificAnimation = new QPropertyAnimation(object, "foo"); @@ -3532,8 +3532,8 @@ void tst_QStateMachine::overrideDefaultSourceAnimationWithSpecific() QObject::connect(s3, SIGNAL(entered()), QCoreApplication::instance(), SLOT(quit())); QAbstractTransition *at = s1->addTransition(new EventTransition(QEvent::User, s2)); - - QPropertyAnimation *defaultAnimation = new QPropertyAnimation(object, "foo"); + + QPropertyAnimation *defaultAnimation = new QPropertyAnimation(object, "foo"); connect(defaultAnimation, SIGNAL(stateChanged(QAbstractAnimation::State, QAbstractAnimation::State)), &counter, SLOT(slot())); QPropertyAnimation *moreSpecificAnimation = new QPropertyAnimation(object, "foo"); @@ -3572,8 +3572,8 @@ void tst_QStateMachine::overrideDefaultTargetAnimationWithSpecific() QObject::connect(s3, SIGNAL(entered()), QCoreApplication::instance(), SLOT(quit())); QAbstractTransition *at = s1->addTransition(new EventTransition(QEvent::User, s2)); - - QPropertyAnimation *defaultAnimation = new QPropertyAnimation(object, "foo"); + + QPropertyAnimation *defaultAnimation = new QPropertyAnimation(object, "foo"); connect(defaultAnimation, SIGNAL(stateChanged(QAbstractAnimation::State, QAbstractAnimation::State)), &counter, SLOT(slot())); QPropertyAnimation *moreSpecificAnimation = new QPropertyAnimation(object, "foo"); @@ -3612,8 +3612,8 @@ void tst_QStateMachine::overrideDefaultTargetAnimationWithSource() QObject::connect(s3, SIGNAL(entered()), QCoreApplication::instance(), SLOT(quit())); s1->addTransition(new EventTransition(QEvent::User, s2)); - - QPropertyAnimation *defaultAnimation = new QPropertyAnimation(object, "foo"); + + QPropertyAnimation *defaultAnimation = new QPropertyAnimation(object, "foo"); connect(defaultAnimation, SIGNAL(stateChanged(QAbstractAnimation::State, QAbstractAnimation::State)), &counter, SLOT(slot())); QPropertyAnimation *moreSpecificAnimation = new QPropertyAnimation(object, "foo"); @@ -3663,7 +3663,7 @@ void tst_QStateMachine::parallelStateAssignmentsDone() QCOMPARE(propertyHolder->property("foo").toInt(), 123); QCOMPARE(propertyHolder->property("bar").toInt(), 456); QCOMPARE(propertyHolder->property("zoot").toInt(), 789); - + machine.postEvent(new QEvent(QEvent::User)); QCoreApplication::processEvents(); @@ -3675,13 +3675,13 @@ void tst_QStateMachine::parallelStateAssignmentsDone() void tst_QStateMachine::transitionsFromParallelStateWithNoChildren() { QStateMachine machine; - + QState *parallelState = new QState(QState::ParallelStates, &machine); machine.setInitialState(parallelState); - QState *s1 = new QState(&machine); + QState *s1 = new QState(&machine); parallelState->addTransition(new EventTransition(QEvent::User, s1)); - + machine.start(); QCoreApplication::processEvents(); @@ -3712,7 +3712,7 @@ void tst_QStateMachine::parallelStateTransition() QState *s2InitialChild = new QState(s2); s2->setInitialState(s2InitialChild); - QState *s1OtherChild = new QState(s1); + QState *s1OtherChild = new QState(s1); s1->addTransition(new EventTransition(QEvent::User, s1OtherChild)); @@ -3732,12 +3732,12 @@ void tst_QStateMachine::parallelStateTransition() QVERIFY(machine.configuration().contains(parallelState)); QVERIFY(machine.configuration().contains(s1)); - + QVERIFY(machine.configuration().contains(s2)); QVERIFY(machine.configuration().contains(s1OtherChild)); QVERIFY(machine.configuration().contains(s2InitialChild)); QCOMPARE(machine.configuration().size(), 5); - + } void tst_QStateMachine::nestedRestoreProperties() @@ -3808,7 +3808,7 @@ void tst_QStateMachine::nestedRestoreProperties2() s2->assignProperty(propertyHolder, "foo", 3); QState *s21 = new QState(s2); - s21->assignProperty(propertyHolder, "bar", 4); + s21->assignProperty(propertyHolder, "bar", 4); s2->setInitialState(s21); QState *s22 = new QState(s2); diff --git a/tests/auto/qstl/qstl.pro b/tests/auto/qstl/qstl.pro index 07cc314..5c99874 100644 --- a/tests/auto/qstl/qstl.pro +++ b/tests/auto/qstl/qstl.pro @@ -1,7 +1,3 @@ load(qttest_p4) SOURCES += tst_qstl.cpp - - QT = core - - diff --git a/tests/auto/qstring/qstring.pro b/tests/auto/qstring/qstring.pro index eb52d90..ed758c6 100644 --- a/tests/auto/qstring/qstring.pro +++ b/tests/auto/qstring/qstring.pro @@ -1,9 +1,8 @@ load(qttest_p4) SOURCES += tst_qstring.cpp +symbian:LIBS += -llibm + QT = core DEFINES += QT_NO_CAST_TO_ASCII - - - diff --git a/tests/auto/qstring/tst_qstring.cpp b/tests/auto/qstring/tst_qstring.cpp index 72c0d74..6819336 100644 --- a/tests/auto/qstring/tst_qstring.cpp +++ b/tests/auto/qstring/tst_qstring.cpp @@ -446,48 +446,48 @@ void tst_QString::replace_string_data() QTest::addColumn<QString>("result" ); QTest::addColumn<bool>("bcs" ); - QTest::newRow( "rem00" ) << QString("") << QString("") << QString("") << QString("") << TRUE; - QTest::newRow( "rem01" ) << QString("A") << QString("") << QString("") << QString("A") << TRUE; - QTest::newRow( "rem02" ) << QString("A") << QString("A") << QString("") << QString("") << TRUE; - QTest::newRow( "rem03" ) << QString("A") << QString("B") << QString("") << QString("A") << TRUE; - QTest::newRow( "rem04" ) << QString("AA") << QString("A") << QString("") << QString("") << TRUE; - QTest::newRow( "rem05" ) << QString("AB") << QString("A") << QString("") << QString("B") << TRUE; - QTest::newRow( "rem06" ) << QString("AB") << QString("B") << QString("") << QString("A") << TRUE; - QTest::newRow( "rem07" ) << QString("AB") << QString("C") << QString("") << QString("AB") << TRUE; - QTest::newRow( "rem08" ) << QString("ABA") << QString("A") << QString("") << QString("B") << TRUE; - QTest::newRow( "rem09" ) << QString("ABA") << QString("B") << QString("") << QString("AA") << TRUE; - QTest::newRow( "rem10" ) << QString("ABA") << QString("C") << QString("") << QString("ABA") << TRUE; - QTest::newRow( "rem11" ) << QString("banana") << QString("an") << QString("") << QString("ba") << TRUE; - QTest::newRow( "rem12" ) << QString("") << QString("A") << QString("") << QString("") << TRUE; - QTest::newRow( "rem13" ) << QString("") << QString("A") << QString() << QString("") << TRUE; - QTest::newRow( "rem14" ) << QString() << QString("A") << QString("") << QString() << TRUE; - QTest::newRow( "rem15" ) << QString() << QString("A") << QString() << QString() << TRUE; - QTest::newRow( "rem16" ) << QString() << QString("") << QString("") << QString("") << TRUE; - QTest::newRow( "rem17" ) << QString("") << QString() << QString("") << QString("") << TRUE; - QTest::newRow( "rem18" ) << QString("a") << QString("a") << QString("") << QString("") << FALSE; - QTest::newRow( "rem19" ) << QString("A") << QString("A") << QString("") << QString("") << FALSE; - QTest::newRow( "rem20" ) << QString("a") << QString("A") << QString("") << QString("") << FALSE; - QTest::newRow( "rem21" ) << QString("A") << QString("a") << QString("") << QString("") << FALSE; - QTest::newRow( "rem22" ) << QString("Alpha beta") << QString("a") << QString("") << QString("lph bet") << FALSE; - - QTest::newRow( "rep00" ) << QString("ABC") << QString("B") << QString("-") << QString("A-C") << TRUE; - QTest::newRow( "rep01" ) << QString("$()*+.?[\\]^{|}") << QString("$()*+.?[\\]^{|}") << QString("X") << QString("X") << TRUE; - QTest::newRow( "rep02" ) << QString("ABCDEF") << QString("") << QString("X") << QString("XAXBXCXDXEXFX") << TRUE; - QTest::newRow( "rep03" ) << QString("") << QString("") << QString("X") << QString("X") << TRUE; - QTest::newRow( "rep04" ) << QString("a") << QString("a") << QString("b") << QString("b") << FALSE; - QTest::newRow( "rep05" ) << QString("A") << QString("A") << QString("b") << QString("b") << FALSE; - QTest::newRow( "rep06" ) << QString("a") << QString("A") << QString("b") << QString("b") << FALSE; - QTest::newRow( "rep07" ) << QString("A") << QString("a") << QString("b") << QString("b") << FALSE; - QTest::newRow( "rep08" ) << QString("a") << QString("a") << QString("a") << QString("a") << FALSE; - QTest::newRow( "rep09" ) << QString("A") << QString("A") << QString("a") << QString("a") << FALSE; - QTest::newRow( "rep10" ) << QString("a") << QString("A") << QString("a") << QString("a") << FALSE; - QTest::newRow( "rep11" ) << QString("A") << QString("a") << QString("a") << QString("a") << FALSE; - QTest::newRow( "rep12" ) << QString("Alpha beta") << QString("a") << QString("o") << QString("olpho beto") << FALSE; - QTest::newRow( "rep13" ) << QString() << QString("") << QString("A") << QString("A") << TRUE; - QTest::newRow( "rep14" ) << QString("") << QString() << QString("A") << QString("A") << TRUE; - QTest::newRow( "rep15" ) << QString("fooxbarxbazxblub") << QString("x") << QString("yz") << QString("fooyzbaryzbazyzblub") << TRUE; - QTest::newRow( "rep16" ) << QString("fooxbarxbazxblub") << QString("x") << QString("z") << QString("foozbarzbazzblub") << TRUE; - QTest::newRow( "rep17" ) << QString("fooxybarxybazxyblub") << QString("xy") << QString("z") << QString("foozbarzbazzblub") << TRUE; + QTest::newRow( "rem00" ) << QString("") << QString("") << QString("") << QString("") << true; + QTest::newRow( "rem01" ) << QString("A") << QString("") << QString("") << QString("A") << true; + QTest::newRow( "rem02" ) << QString("A") << QString("A") << QString("") << QString("") << true; + QTest::newRow( "rem03" ) << QString("A") << QString("B") << QString("") << QString("A") << true; + QTest::newRow( "rem04" ) << QString("AA") << QString("A") << QString("") << QString("") << true; + QTest::newRow( "rem05" ) << QString("AB") << QString("A") << QString("") << QString("B") << true; + QTest::newRow( "rem06" ) << QString("AB") << QString("B") << QString("") << QString("A") << true; + QTest::newRow( "rem07" ) << QString("AB") << QString("C") << QString("") << QString("AB") << true; + QTest::newRow( "rem08" ) << QString("ABA") << QString("A") << QString("") << QString("B") << true; + QTest::newRow( "rem09" ) << QString("ABA") << QString("B") << QString("") << QString("AA") << true; + QTest::newRow( "rem10" ) << QString("ABA") << QString("C") << QString("") << QString("ABA") << true; + QTest::newRow( "rem11" ) << QString("banana") << QString("an") << QString("") << QString("ba") << true; + QTest::newRow( "rem12" ) << QString("") << QString("A") << QString("") << QString("") << true; + QTest::newRow( "rem13" ) << QString("") << QString("A") << QString() << QString("") << true; + QTest::newRow( "rem14" ) << QString() << QString("A") << QString("") << QString() << true; + QTest::newRow( "rem15" ) << QString() << QString("A") << QString() << QString() << true; + QTest::newRow( "rem16" ) << QString() << QString("") << QString("") << QString("") << true; + QTest::newRow( "rem17" ) << QString("") << QString() << QString("") << QString("") << true; + QTest::newRow( "rem18" ) << QString("a") << QString("a") << QString("") << QString("") << false; + QTest::newRow( "rem19" ) << QString("A") << QString("A") << QString("") << QString("") << false; + QTest::newRow( "rem20" ) << QString("a") << QString("A") << QString("") << QString("") << false; + QTest::newRow( "rem21" ) << QString("A") << QString("a") << QString("") << QString("") << false; + QTest::newRow( "rem22" ) << QString("Alpha beta") << QString("a") << QString("") << QString("lph bet") << false; + + QTest::newRow( "rep00" ) << QString("ABC") << QString("B") << QString("-") << QString("A-C") << true; + QTest::newRow( "rep01" ) << QString("$()*+.?[\\]^{|}") << QString("$()*+.?[\\]^{|}") << QString("X") << QString("X") << true; + QTest::newRow( "rep02" ) << QString("ABCDEF") << QString("") << QString("X") << QString("XAXBXCXDXEXFX") << true; + QTest::newRow( "rep03" ) << QString("") << QString("") << QString("X") << QString("X") << true; + QTest::newRow( "rep04" ) << QString("a") << QString("a") << QString("b") << QString("b") << false; + QTest::newRow( "rep05" ) << QString("A") << QString("A") << QString("b") << QString("b") << false; + QTest::newRow( "rep06" ) << QString("a") << QString("A") << QString("b") << QString("b") << false; + QTest::newRow( "rep07" ) << QString("A") << QString("a") << QString("b") << QString("b") << false; + QTest::newRow( "rep08" ) << QString("a") << QString("a") << QString("a") << QString("a") << false; + QTest::newRow( "rep09" ) << QString("A") << QString("A") << QString("a") << QString("a") << false; + QTest::newRow( "rep10" ) << QString("a") << QString("A") << QString("a") << QString("a") << false; + QTest::newRow( "rep11" ) << QString("A") << QString("a") << QString("a") << QString("a") << false; + QTest::newRow( "rep12" ) << QString("Alpha beta") << QString("a") << QString("o") << QString("olpho beto") << false; + QTest::newRow( "rep13" ) << QString() << QString("") << QString("A") << QString("A") << true; + QTest::newRow( "rep14" ) << QString("") << QString() << QString("A") << QString("A") << true; + QTest::newRow( "rep15" ) << QString("fooxbarxbazxblub") << QString("x") << QString("yz") << QString("fooyzbaryzbazyzblub") << true; + QTest::newRow( "rep16" ) << QString("fooxbarxbazxblub") << QString("x") << QString("z") << QString("foozbarzbazzblub") << true; + QTest::newRow( "rep17" ) << QString("fooxybarxybazxyblub") << QString("xy") << QString("z") << QString("foozbarzbazzblub") << true; } void tst_QString::replace_regexp_data() @@ -958,68 +958,68 @@ void tst_QString::indexOf_data() QTest::addColumn<bool>("bcs" ); QTest::addColumn<int>("resultpos" ); - QTest::newRow( "data0" ) << QString("abc") << QString("a") << 0 << TRUE << 0; - QTest::newRow( "data1" ) << QString("abc") << QString("a") << 0 << FALSE << 0; - QTest::newRow( "data2" ) << QString("abc") << QString("A") << 0 << TRUE << -1; - QTest::newRow( "data3" ) << QString("abc") << QString("A") << 0 << FALSE << 0; - QTest::newRow( "data4" ) << QString("abc") << QString("a") << 1 << TRUE << -1; - QTest::newRow( "data5" ) << QString("abc") << QString("a") << 1 << FALSE << -1; - QTest::newRow( "data6" ) << QString("abc") << QString("A") << 1 << TRUE << -1; - QTest::newRow( "data7" ) << QString("abc") << QString("A") << 1 << FALSE << -1; - QTest::newRow( "data8" ) << QString("abc") << QString("b") << 0 << TRUE << 1; - QTest::newRow( "data9" ) << QString("abc") << QString("b") << 0 << FALSE << 1; - QTest::newRow( "data10" ) << QString("abc") << QString("B") << 0 << TRUE << -1; - QTest::newRow( "data11" ) << QString("abc") << QString("B") << 0 << FALSE << 1; - QTest::newRow( "data12" ) << QString("abc") << QString("b") << 1 << TRUE << 1; - QTest::newRow( "data13" ) << QString("abc") << QString("b") << 1 << FALSE << 1; - QTest::newRow( "data14" ) << QString("abc") << QString("B") << 1 << TRUE << -1; - QTest::newRow( "data15" ) << QString("abc") << QString("B") << 1 << FALSE << 1; - QTest::newRow( "data16" ) << QString("abc") << QString("b") << 2 << TRUE << -1; - QTest::newRow( "data17" ) << QString("abc") << QString("b") << 2 << FALSE << -1; - - QTest::newRow( "data20" ) << QString("ABC") << QString("A") << 0 << TRUE << 0; - QTest::newRow( "data21" ) << QString("ABC") << QString("A") << 0 << FALSE << 0; - QTest::newRow( "data22" ) << QString("ABC") << QString("a") << 0 << TRUE << -1; - QTest::newRow( "data23" ) << QString("ABC") << QString("a") << 0 << FALSE << 0; - QTest::newRow( "data24" ) << QString("ABC") << QString("A") << 1 << TRUE << -1; - QTest::newRow( "data25" ) << QString("ABC") << QString("A") << 1 << FALSE << -1; - QTest::newRow( "data26" ) << QString("ABC") << QString("a") << 1 << TRUE << -1; - QTest::newRow( "data27" ) << QString("ABC") << QString("a") << 1 << FALSE << -1; - QTest::newRow( "data28" ) << QString("ABC") << QString("B") << 0 << TRUE << 1; - QTest::newRow( "data29" ) << QString("ABC") << QString("B") << 0 << FALSE << 1; - QTest::newRow( "data30" ) << QString("ABC") << QString("b") << 0 << TRUE << -1; - QTest::newRow( "data31" ) << QString("ABC") << QString("b") << 0 << FALSE << 1; - QTest::newRow( "data32" ) << QString("ABC") << QString("B") << 1 << TRUE << 1; - QTest::newRow( "data33" ) << QString("ABC") << QString("B") << 1 << FALSE << 1; - QTest::newRow( "data34" ) << QString("ABC") << QString("b") << 1 << TRUE << -1; - QTest::newRow( "data35" ) << QString("ABC") << QString("b") << 1 << FALSE << 1; - QTest::newRow( "data36" ) << QString("ABC") << QString("B") << 2 << TRUE << -1; - QTest::newRow( "data37" ) << QString("ABC") << QString("B") << 2 << FALSE << -1; - - QTest::newRow( "data40" ) << QString("aBc") << QString("bc") << 0 << TRUE << -1; - QTest::newRow( "data41" ) << QString("aBc") << QString("Bc") << 0 << TRUE << 1; - QTest::newRow( "data42" ) << QString("aBc") << QString("bC") << 0 << TRUE << -1; - QTest::newRow( "data43" ) << QString("aBc") << QString("BC") << 0 << TRUE << -1; - QTest::newRow( "data44" ) << QString("aBc") << QString("bc") << 0 << FALSE << 1; - QTest::newRow( "data45" ) << QString("aBc") << QString("Bc") << 0 << FALSE << 1; - QTest::newRow( "data46" ) << QString("aBc") << QString("bC") << 0 << FALSE << 1; - QTest::newRow( "data47" ) << QString("aBc") << QString("BC") << 0 << FALSE << 1; - QTest::newRow( "data48" ) << QString("AbC") << QString("bc") << 0 << TRUE << -1; - QTest::newRow( "data49" ) << QString("AbC") << QString("Bc") << 0 << TRUE << -1; - QTest::newRow( "data50" ) << QString("AbC") << QString("bC") << 0 << TRUE << 1; - QTest::newRow( "data51" ) << QString("AbC") << QString("BC") << 0 << TRUE << -1; - QTest::newRow( "data52" ) << QString("AbC") << QString("bc") << 0 << FALSE << 1; - QTest::newRow( "data53" ) << QString("AbC") << QString("Bc") << 0 << FALSE << 1; - - QTest::newRow( "data54" ) << QString("AbC") << QString("bC") << 0 << FALSE << 1; - QTest::newRow( "data55" ) << QString("AbC") << QString("BC") << 0 << FALSE << 1; - QTest::newRow( "data56" ) << QString("AbC") << QString("BC") << 1 << FALSE << 1; - QTest::newRow( "data57" ) << QString("AbC") << QString("BC") << 2 << FALSE << -1; + QTest::newRow( "data0" ) << QString("abc") << QString("a") << 0 << true << 0; + QTest::newRow( "data1" ) << QString("abc") << QString("a") << 0 << false << 0; + QTest::newRow( "data2" ) << QString("abc") << QString("A") << 0 << true << -1; + QTest::newRow( "data3" ) << QString("abc") << QString("A") << 0 << false << 0; + QTest::newRow( "data4" ) << QString("abc") << QString("a") << 1 << true << -1; + QTest::newRow( "data5" ) << QString("abc") << QString("a") << 1 << false << -1; + QTest::newRow( "data6" ) << QString("abc") << QString("A") << 1 << true << -1; + QTest::newRow( "data7" ) << QString("abc") << QString("A") << 1 << false << -1; + QTest::newRow( "data8" ) << QString("abc") << QString("b") << 0 << true << 1; + QTest::newRow( "data9" ) << QString("abc") << QString("b") << 0 << false << 1; + QTest::newRow( "data10" ) << QString("abc") << QString("B") << 0 << true << -1; + QTest::newRow( "data11" ) << QString("abc") << QString("B") << 0 << false << 1; + QTest::newRow( "data12" ) << QString("abc") << QString("b") << 1 << true << 1; + QTest::newRow( "data13" ) << QString("abc") << QString("b") << 1 << false << 1; + QTest::newRow( "data14" ) << QString("abc") << QString("B") << 1 << true << -1; + QTest::newRow( "data15" ) << QString("abc") << QString("B") << 1 << false << 1; + QTest::newRow( "data16" ) << QString("abc") << QString("b") << 2 << true << -1; + QTest::newRow( "data17" ) << QString("abc") << QString("b") << 2 << false << -1; + + QTest::newRow( "data20" ) << QString("ABC") << QString("A") << 0 << true << 0; + QTest::newRow( "data21" ) << QString("ABC") << QString("A") << 0 << false << 0; + QTest::newRow( "data22" ) << QString("ABC") << QString("a") << 0 << true << -1; + QTest::newRow( "data23" ) << QString("ABC") << QString("a") << 0 << false << 0; + QTest::newRow( "data24" ) << QString("ABC") << QString("A") << 1 << true << -1; + QTest::newRow( "data25" ) << QString("ABC") << QString("A") << 1 << false << -1; + QTest::newRow( "data26" ) << QString("ABC") << QString("a") << 1 << true << -1; + QTest::newRow( "data27" ) << QString("ABC") << QString("a") << 1 << false << -1; + QTest::newRow( "data28" ) << QString("ABC") << QString("B") << 0 << true << 1; + QTest::newRow( "data29" ) << QString("ABC") << QString("B") << 0 << false << 1; + QTest::newRow( "data30" ) << QString("ABC") << QString("b") << 0 << true << -1; + QTest::newRow( "data31" ) << QString("ABC") << QString("b") << 0 << false << 1; + QTest::newRow( "data32" ) << QString("ABC") << QString("B") << 1 << true << 1; + QTest::newRow( "data33" ) << QString("ABC") << QString("B") << 1 << false << 1; + QTest::newRow( "data34" ) << QString("ABC") << QString("b") << 1 << true << -1; + QTest::newRow( "data35" ) << QString("ABC") << QString("b") << 1 << false << 1; + QTest::newRow( "data36" ) << QString("ABC") << QString("B") << 2 << true << -1; + QTest::newRow( "data37" ) << QString("ABC") << QString("B") << 2 << false << -1; + + QTest::newRow( "data40" ) << QString("aBc") << QString("bc") << 0 << true << -1; + QTest::newRow( "data41" ) << QString("aBc") << QString("Bc") << 0 << true << 1; + QTest::newRow( "data42" ) << QString("aBc") << QString("bC") << 0 << true << -1; + QTest::newRow( "data43" ) << QString("aBc") << QString("BC") << 0 << true << -1; + QTest::newRow( "data44" ) << QString("aBc") << QString("bc") << 0 << false << 1; + QTest::newRow( "data45" ) << QString("aBc") << QString("Bc") << 0 << false << 1; + QTest::newRow( "data46" ) << QString("aBc") << QString("bC") << 0 << false << 1; + QTest::newRow( "data47" ) << QString("aBc") << QString("BC") << 0 << false << 1; + QTest::newRow( "data48" ) << QString("AbC") << QString("bc") << 0 << true << -1; + QTest::newRow( "data49" ) << QString("AbC") << QString("Bc") << 0 << true << -1; + QTest::newRow( "data50" ) << QString("AbC") << QString("bC") << 0 << true << 1; + QTest::newRow( "data51" ) << QString("AbC") << QString("BC") << 0 << true << -1; + QTest::newRow( "data52" ) << QString("AbC") << QString("bc") << 0 << false << 1; + QTest::newRow( "data53" ) << QString("AbC") << QString("Bc") << 0 << false << 1; + + QTest::newRow( "data54" ) << QString("AbC") << QString("bC") << 0 << false << 1; + QTest::newRow( "data55" ) << QString("AbC") << QString("BC") << 0 << false << 1; + QTest::newRow( "data56" ) << QString("AbC") << QString("BC") << 1 << false << 1; + QTest::newRow( "data57" ) << QString("AbC") << QString("BC") << 2 << false << -1; #if 0 - QTest::newRow( "null-in-null") << QString() << QString() << 0 << FALSE << 0; - QTest::newRow( "empty-in-null") << QString() << QString("") << 0 << FALSE << 0; - QTest::newRow( "null-in-empty") << QString("") << QString() << 0 << FALSE << 0; - QTest::newRow( "empty-in-empty") << QString("") << QString("") << 0 << FALSE << 0; + QTest::newRow( "null-in-null") << QString() << QString() << 0 << false << 0; + QTest::newRow( "empty-in-null") << QString() << QString("") << 0 << false << 0; + QTest::newRow( "null-in-empty") << QString("") << QString() << 0 << false << 0; + QTest::newRow( "empty-in-empty") << QString("") << QString("") << 0 << false << 0; #endif @@ -1027,21 +1027,21 @@ void tst_QString::indexOf_data() s1 += QChar(0xb5); QString s2; s2 += QChar(0x3bc); - QTest::newRow( "data58" ) << s1 << s2 << 0 << FALSE << 3; + QTest::newRow( "data58" ) << s1 << s2 << 0 << false << 3; s2.prepend("C"); - QTest::newRow( "data59" ) << s1 << s2 << 0 << FALSE << 2; + QTest::newRow( "data59" ) << s1 << s2 << 0 << false << 2; QString veryBigHaystack(500, 'a'); veryBigHaystack += 'B'; - QTest::newRow("BoyerMooreStressTest") << veryBigHaystack << veryBigHaystack << 0 << TRUE << 0; - QTest::newRow("BoyerMooreStressTest2") << veryBigHaystack + 'c' << veryBigHaystack << 0 << TRUE << 0; - QTest::newRow("BoyerMooreStressTest3") << 'c' + veryBigHaystack << veryBigHaystack << 0 << TRUE << 1; - QTest::newRow("BoyerMooreStressTest4") << veryBigHaystack << veryBigHaystack + 'c' << 0 << TRUE << -1; - QTest::newRow("BoyerMooreStressTest5") << veryBigHaystack << 'c' + veryBigHaystack << 0 << TRUE << -1; - QTest::newRow("BoyerMooreStressTest6") << 'd' + veryBigHaystack << 'c' + veryBigHaystack << 0 << TRUE << -1; - QTest::newRow("BoyerMooreStressTest6") << veryBigHaystack + 'c' << 'c' + veryBigHaystack << 0 << TRUE << -1; + QTest::newRow("BoyerMooreStressTest") << veryBigHaystack << veryBigHaystack << 0 << true << 0; + QTest::newRow("BoyerMooreStressTest2") << veryBigHaystack + 'c' << veryBigHaystack << 0 << true << 0; + QTest::newRow("BoyerMooreStressTest3") << 'c' + veryBigHaystack << veryBigHaystack << 0 << true << 1; + QTest::newRow("BoyerMooreStressTest4") << veryBigHaystack << veryBigHaystack + 'c' << 0 << true << -1; + QTest::newRow("BoyerMooreStressTest5") << veryBigHaystack << 'c' + veryBigHaystack << 0 << true << -1; + QTest::newRow("BoyerMooreStressTest6") << 'd' + veryBigHaystack << 'c' + veryBigHaystack << 0 << true << -1; + QTest::newRow("BoyerMooreStressTest6") << veryBigHaystack + 'c' << 'c' + veryBigHaystack << 0 << true << -1; - QTest::newRow("BoyerMooreInsensitiveStressTest") << veryBigHaystack << veryBigHaystack << 0 << FALSE << 0; + QTest::newRow("BoyerMooreInsensitiveStressTest") << veryBigHaystack << veryBigHaystack << 0 << false << 0; } @@ -1470,11 +1470,11 @@ void tst_QString::leftJustified() QString n; QVERIFY(!n.leftJustified(3).isNull()); - QCOMPARE(a.leftJustified(4,' ',TRUE),(QString)"ABC "); - QCOMPARE(a.leftJustified(3,' ',TRUE),(QString)"ABC"); - QCOMPARE(a.leftJustified(2,' ',TRUE),(QString)"AB"); - QCOMPARE(a.leftJustified(1,' ',TRUE),(QString)"A"); - QCOMPARE(a.leftJustified(0,' ',TRUE),(QString)""); + QCOMPARE(a.leftJustified(4,' ',true),(QString)"ABC "); + QCOMPARE(a.leftJustified(3,' ',true),(QString)"ABC"); + QCOMPARE(a.leftJustified(2,' ',true),(QString)"AB"); + QCOMPARE(a.leftJustified(1,' ',true),(QString)"A"); + QCOMPARE(a.leftJustified(0,' ',true),(QString)""); } void tst_QString::rightJustified() @@ -1491,12 +1491,12 @@ void tst_QString::rightJustified() QString n; QVERIFY(!n.rightJustified(3).isNull()); - QCOMPARE(a.rightJustified(4,'-',TRUE),(QString)"-ABC"); - QCOMPARE(a.rightJustified(4,' ',TRUE),(QString)" ABC"); - QCOMPARE(a.rightJustified(3,' ',TRUE),(QString)"ABC"); - QCOMPARE(a.rightJustified(2,' ',TRUE),(QString)"AB"); - QCOMPARE(a.rightJustified(1,' ',TRUE),(QString)"A"); - QCOMPARE(a.rightJustified(0,' ',TRUE),(QString)""); + QCOMPARE(a.rightJustified(4,'-',true),(QString)"-ABC"); + QCOMPARE(a.rightJustified(4,' ',true),(QString)" ABC"); + QCOMPARE(a.rightJustified(3,' ',true),(QString)"ABC"); + QCOMPARE(a.rightJustified(2,' ',true),(QString)"AB"); + QCOMPARE(a.rightJustified(1,' ',true),(QString)"A"); + QCOMPARE(a.rightJustified(0,' ',true),(QString)""); QCOMPARE(a,(QString)"ABC"); } @@ -2498,10 +2498,10 @@ void tst_QString::toULong_data() QTest::addColumn<ulong>("result" ); QTest::addColumn<bool>("ok" ); - QTest::newRow( "default" ) << QString() << 10 << 0UL << FALSE; - QTest::newRow( "empty" ) << QString("") << 10 << 0UL << FALSE; - QTest::newRow( "ulong1" ) << QString("3234567890") << 10 << 3234567890UL << TRUE; - QTest::newRow( "ulong2" ) << QString("fFFfFfFf") << 16 << 0xFFFFFFFFUL << TRUE; + QTest::newRow( "default" ) << QString() << 10 << 0UL << false; + QTest::newRow( "empty" ) << QString("") << 10 << 0UL << false; + QTest::newRow( "ulong1" ) << QString("3234567890") << 10 << 3234567890UL << true; + QTest::newRow( "ulong2" ) << QString("fFFfFfFf") << 16 << 0xFFFFFFFFUL << true; } void tst_QString::toULong() @@ -2524,16 +2524,16 @@ void tst_QString::toLong_data() QTest::addColumn<long>("result" ); QTest::addColumn<bool>("ok" ); - QTest::newRow( "default" ) << QString() << 10 << 0L << FALSE; - QTest::newRow( "empty" ) << QString("") << 10 << 0L << FALSE; - QTest::newRow( "normal" ) << QString("7fFFfFFf") << 16 << 0x7fFFfFFfL << TRUE; - QTest::newRow( "long_max" ) << QString("2147483647") << 10 << 2147483647L << TRUE; + QTest::newRow( "default" ) << QString() << 10 << 0L << false; + QTest::newRow( "empty" ) << QString("") << 10 << 0L << false; + QTest::newRow( "normal" ) << QString("7fFFfFFf") << 16 << 0x7fFFfFFfL << true; + QTest::newRow( "long_max" ) << QString("2147483647") << 10 << 2147483647L << true; if (sizeof(long) == 4) { - QTest::newRow( "long_max+1" ) << QString("2147483648") << 10 << 0L << FALSE; - QTest::newRow( "long_min-1" ) << QString("-80000001") << 16 << 0L << FALSE; + QTest::newRow( "long_max+1" ) << QString("2147483648") << 10 << 0L << false; + QTest::newRow( "long_min-1" ) << QString("-80000001") << 16 << 0L << false; } - QTest::newRow( "negative" ) << QString("-7fffffff") << 16 << -0x7fffffffL << TRUE; -// QTest::newRow( "long_min" ) << QString("-80000000") << 16 << 0x80000000uL << TRUE; + QTest::newRow( "negative" ) << QString("-7fffffff") << 16 << -0x7fffffffL << true; +// QTest::newRow( "long_min" ) << QString("-80000000") << 16 << 0x80000000uL << true; } void tst_QString::toLong() @@ -2637,33 +2637,33 @@ void tst_QString::toDouble_data() QTest::addColumn<double>("result" ); QTest::addColumn<bool>("result_ok" ); - QTest::newRow( "ok00" ) << QString("0.000000000931322574615478515625") << 0.000000000931322574615478515625 << (bool)TRUE; - QTest::newRow( "ok01" ) << QString(" 123.45") << 123.45 << (bool)TRUE; + QTest::newRow( "ok00" ) << QString("0.000000000931322574615478515625") << 0.000000000931322574615478515625 << true; + QTest::newRow( "ok01" ) << QString(" 123.45") << 123.45 << true; - QTest::newRow( "ok02" ) << QString("0.1e10") << 0.1e10 << (bool)TRUE; - QTest::newRow( "ok03" ) << QString("0.1e-10") << 0.1e-10 << (bool)TRUE; + QTest::newRow( "ok02" ) << QString("0.1e10") << 0.1e10 << true; + QTest::newRow( "ok03" ) << QString("0.1e-10") << 0.1e-10 << true; - QTest::newRow( "ok04" ) << QString("1e10") << 1.0e10 << (bool)TRUE; - QTest::newRow( "ok05" ) << QString("1e+10") << 1.0e10 << (bool)TRUE; - QTest::newRow( "ok06" ) << QString("1e-10") << 1.0e-10 << (bool)TRUE; + QTest::newRow( "ok04" ) << QString("1e10") << 1.0e10 << true; + QTest::newRow( "ok05" ) << QString("1e+10") << 1.0e10 << true; + QTest::newRow( "ok06" ) << QString("1e-10") << 1.0e-10 << true; - QTest::newRow( "ok07" ) << QString(" 1e10") << 1.0e10 << (bool)TRUE; - QTest::newRow( "ok08" ) << QString(" 1e+10") << 1.0e10 << (bool)TRUE; - QTest::newRow( "ok09" ) << QString(" 1e-10") << 1.0e-10 << (bool)TRUE; + QTest::newRow( "ok07" ) << QString(" 1e10") << 1.0e10 << true; + QTest::newRow( "ok08" ) << QString(" 1e+10") << 1.0e10 << true; + QTest::newRow( "ok09" ) << QString(" 1e-10") << 1.0e-10 << true; - QTest::newRow( "ok10" ) << QString("1.") << 1.0 << (bool)TRUE; - QTest::newRow( "ok11" ) << QString(".1") << 0.1 << (bool)TRUE; + QTest::newRow( "ok10" ) << QString("1.") << 1.0 << true; + QTest::newRow( "ok11" ) << QString(".1") << 0.1 << true; - QTest::newRow( "wrong00" ) << QString("123.45 ") << 123.45 << (bool)TRUE; - QTest::newRow( "wrong01" ) << QString(" 123.45 ") << 123.45 << (bool)TRUE; + QTest::newRow( "wrong00" ) << QString("123.45 ") << 123.45 << true; + QTest::newRow( "wrong01" ) << QString(" 123.45 ") << 123.45 << true; - QTest::newRow( "wrong02" ) << QString("aa123.45aa") << 0.0 << (bool)FALSE; - QTest::newRow( "wrong03" ) << QString("123.45aa") << 0.0 << (bool)FALSE; - QTest::newRow( "wrong04" ) << QString("123erf") << 0.0 << (bool)FALSE; + QTest::newRow( "wrong02" ) << QString("aa123.45aa") << 0.0 << false; + QTest::newRow( "wrong03" ) << QString("123.45aa") << 0.0 << false; + QTest::newRow( "wrong04" ) << QString("123erf") << 0.0 << false; - QTest::newRow( "wrong05" ) << QString("abc") << 0.0 << (bool)FALSE; - QTest::newRow( "wrong06" ) << QString() << 0.0 << (bool)FALSE; - QTest::newRow( "wrong07" ) << QString("") << 0.0 << (bool)FALSE; + QTest::newRow( "wrong05" ) << QString("abc") << 0.0 << false; + QTest::newRow( "wrong06" ) << QString() << 0.0 << false; + QTest::newRow( "wrong07" ) << QString("") << 0.0 << false; } void tst_QString::toDouble() diff --git a/tests/auto/qstringlist/qstringlist.pro b/tests/auto/qstringlist/qstringlist.pro index b2ad23d..aee074b 100644 --- a/tests/auto/qstringlist/qstringlist.pro +++ b/tests/auto/qstringlist/qstringlist.pro @@ -1,7 +1,3 @@ load(qttest_p4) SOURCES += tst_qstringlist.cpp - - QT = core - - diff --git a/tests/auto/qstringlistmodel/tst_qstringlistmodel.cpp b/tests/auto/qstringlistmodel/tst_qstringlistmodel.cpp index 619a56d..dbfc983 100644 --- a/tests/auto/qstringlistmodel/tst_qstringlistmodel.cpp +++ b/tests/auto/qstringlistmodel/tst_qstringlistmodel.cpp @@ -46,7 +46,6 @@ #include <qmap.h> #include <qstringlistmodel.h> #include <qstringlist.h> -#include <iostream> #include <qlistview.h> #include "qmodellistener.h" #include <qstringlistmodel.h> diff --git a/tests/auto/qstyle/qstyle.pro b/tests/auto/qstyle/qstyle.pro index ba0908a..1ffe369 100644 --- a/tests/auto/qstyle/qstyle.pro +++ b/tests/auto/qstyle/qstyle.pro @@ -1,13 +1,12 @@ load(qttest_p4) +TARGET.EPOCHEAPSIZE = 0x200000 0x800000 SOURCES += tst_qstyle.cpp -wince*: { - DEFINES += SRCDIR=\\\".\\\" +wince*|symbian*: { + !symbian:DEFINES += SRCDIR=\\\".\\\" addPixmap.sources = task_25863.png addPixmap.path = . DEPLOYMENT += addPixmap } else { DEFINES += SRCDIR=\\\"$$PWD\\\" } - - diff --git a/tests/auto/qstyle/tst_qstyle.cpp b/tests/auto/qstyle/tst_qstyle.cpp index b24a58a..eb8f50a 100644 --- a/tests/auto/qstyle/tst_qstyle.cpp +++ b/tests/auto/qstyle/tst_qstyle.cpp @@ -71,6 +71,10 @@ #include <qlineedit.h> #include <qmdiarea.h> +#if defined(Q_OS_SYMBIAN) +#define SRCDIR "." +#endif + #include <QCleanlooksStyle> #ifdef Q_WS_MAC @@ -100,10 +104,14 @@ static bool qt_wince_is_smartphone() { } #endif +#ifdef Q_WS_S60 +#include <qs60style.h> +#endif + #include <qwidget.h> //TESTED_CLASS= -//TESTED_FILES=gui/styles/qstyle.h gui/styles/qstyle.cpp gui/styles/qplastiquestyle.cpp gui/styles/qwindowsstyle.cpp gui/styles/qwindowsxpstyle.cpp gui/styles/qwindowsvistastyle.cpp gui/styles/qmotifstyle.cpp +//TESTED_FILES=gui/styles/qstyle.h gui/styles/qstyle.cpp gui/styles/qplastiquestyle.cpp gui/styles/qwindowsstyle.cpp gui/styles/qwindowsxpstyle.cpp gui/styles/qwindowsvistastyle.cpp gui/styles/qmotifstyle.cpp gui/styles/qs60style.cpp class tst_QStyle : public QObject { @@ -131,13 +139,14 @@ private slots: void testMacStyle(); void testWindowsCEStyle(); void testWindowsMobileStyle(); + void testS60Style(); void testStyleFactory(); void testProxyStyle(); void pixelMetric(); void progressBarChangeStyle(); void defaultFont(); private: - void lineUpLayoutTest(QStyle *); + void lineUpLayoutTest(QStyle *); QWidget *testWidget; }; @@ -200,10 +209,10 @@ void tst_QStyle::testStyleFactory() QVERIFY(keys.contains("Motif")); #endif #ifdef Q_WS_WIN - if (QSysInfo::WindowsVersion >= QSysInfo::WV_XP && + if (QSysInfo::WindowsVersion >= QSysInfo::WV_XP && QSysInfo::WindowsVersion < QSysInfo::WV_NT_based) QVERIFY(keys.contains("WindowsXP")); - if (QSysInfo::WindowsVersion >= QSysInfo::WV_VISTA && + if (QSysInfo::WindowsVersion >= QSysInfo::WV_VISTA && QSysInfo::WindowsVersion < QSysInfo::WV_NT_based) QVERIFY(keys.contains("WindowsVista")); #endif @@ -270,17 +279,17 @@ void tst_QStyle::testAllFunctions(QStyle *style) opt.init(testWidget); testWidget->setStyle(style); - + //Tests styleHint with default arguments for potential crashes for ( int hint = 0 ; hint < int(QStyle::SH_Menu_Mask); ++hint) { style->styleHint(QStyle::StyleHint(hint)); style->styleHint(QStyle::StyleHint(hint), &opt, testWidget); } - + //Tests pixelMetric with default arguments for potential crashes for ( int pm = 0 ; pm < int(QStyle::PM_LayoutVerticalSpacing); ++pm) { style->pixelMetric(QStyle::PixelMetric(pm)); - style->pixelMetric(QStyle::PixelMetric(pm), &opt, testWidget); + style->pixelMetric(QStyle::PixelMetric(pm), &opt, testWidget); } //Tests drawControl with default arguments for potential crashes @@ -296,7 +305,7 @@ void tst_QStyle::testAllFunctions(QStyle *style) QPainter painter(&surface); QStyleOptionComboBox copt1; copt1.init(testWidget); - + QStyleOptionGroupBox copt2; copt2.init(testWidget); QStyleOptionSizeGrip copt3; @@ -347,7 +356,7 @@ void tst_QStyle::testAllFunctions(QStyle *style) style->itemPixmapRect(QRect(0, 0, 100, 100), Qt::AlignHCenter, QPixmap(200, 200)); style->itemTextRect(QFontMetrics(qApp->font()), QRect(0, 0, 100, 100), Qt::AlignHCenter, true, QString("Test")); - + testScrollBarSubControls(style); } @@ -362,6 +371,12 @@ void tst_QStyle::testScrollBarSubControls(QStyle* style) scrollBar.show(); const QStyleOptionSlider opt = qt_qscrollbarStyleOption(&scrollBar); foreach (int subControl, QList<int>() << 1 << 2 << 4 << 8) { + +#ifdef Q_WS_S60 +// in s60style add line and sub line have been removed. + if (subControl == QStyle::SC_ScrollBarAddLine || subControl == QStyle::SC_ScrollBarSubLine ) + continue; +#endif QRect sr = testWidget->style()->subControlRect(QStyle::CC_ScrollBar, &opt, QStyle::SubControl(subControl), &scrollBar); QVERIFY(sr.isNull() == false); @@ -446,7 +461,7 @@ void comparePixmap(const QString &filename, const QPixmap &pixmap) void tst_QStyle::testPainting(QStyle *style, const QString &platform) { //Test Menu - QString fileName = "images/" + platform + "/menu.png"; + QString fileName = "images/" + platform + "/menu.png"; QMenu menu; menu.setStyle(style); menu.show(); @@ -455,7 +470,7 @@ void tst_QStyle::testPainting(QStyle *style, const QString &platform) QPixmap pixmap = QPixmap::grabWidget(&menu); comparePixmap(fileName, pixmap); - //Push button + //Push button fileName = "images/" + platform + "/button.png"; QPushButton button("OK"); button.setStyle(style); @@ -464,7 +479,7 @@ void tst_QStyle::testPainting(QStyle *style, const QString &platform) button.hide(); comparePixmap(fileName, pixmap); - //Push button + //Push button fileName = "images/" + platform + "/radiobutton.png"; QRadioButton radiobutton("Check"); radiobutton.setStyle(style); @@ -494,7 +509,7 @@ void tst_QStyle::testPainting(QStyle *style, const QString &platform) spinbox.hide(); comparePixmap(fileName, pixmap); QLocale::setDefault(QLocale::system()); - + //Slider fileName = "images/" + platform + "/slider.png"; QSlider slider; @@ -573,6 +588,16 @@ void tst_QStyle::testWindowsMobileStyle() #endif } +void tst_QStyle::testS60Style() + { +#if defined(Q_WS_S60) + QS60Style cstyle; + testAllFunctions(&cstyle); +#else + QSKIP("No S60Style style", SkipAll); +#endif + } + // Helper class... MyWidget::MyWidget( QWidget* parent, const char* name ) @@ -657,9 +682,9 @@ void tst_QStyle::pixelMetric() void tst_QStyle::progressBarChangeStyle() { #if !defined(QT_NO_STYLE_PLASTIQUE) && !defined(QT_NO_STYLE_WINDOWS) - //test a crashing situation (task 143530) + //test a crashing situation (task 143530) //where changing the styles and deleting a progressbar would crash - + QWindowsStyle style1; QPlastiqueStyle style2; @@ -676,35 +701,55 @@ void tst_QStyle::progressBarChangeStyle() QTest::qWait(100); //before the correction, there would be a crash here +#elif !defined(QT_NO_STYLE_S60) && !defined(QT_NO_STYLE_WINDOWS) + //test a crashing situation (task 143530) + //where changing the styles and deleting a progressbar would crash + + QWindowsStyle style1; + QS60Style style2; + + QProgressBar *progress=new QProgressBar; + progress->setStyle(&style1); + + progress->show(); + + progress->setStyle(&style2); + + QTest::qWait(100); + delete progress; + + QTest::qWait(100); + + //before the correction, there would be a crash here #else - QSKIP("Either style Plastique or Windows missing", SkipAll); + QSKIP("Either style Plastique or Windows or S60 missing", SkipAll); #endif } void tst_QStyle::lineUpLayoutTest(QStyle *style) { - QWidget widget; - QHBoxLayout layout; - QFont font; - font.setPointSize(9); //Plastique is lined up for odd numbers... - widget.setFont(font); - QSpinBox spinbox(&widget); - QLineEdit lineedit(&widget); - QComboBox combo(&widget); - combo.setEditable(true); - layout.addWidget(&spinbox); - layout.addWidget(&lineedit); - layout.addWidget(&combo); - widget.setLayout(&layout); + QWidget widget; + QHBoxLayout layout; + QFont font; + font.setPointSize(9); //Plastique is lined up for odd numbers... + widget.setFont(font); + QSpinBox spinbox(&widget); + QLineEdit lineedit(&widget); + QComboBox combo(&widget); + combo.setEditable(true); + layout.addWidget(&spinbox); + layout.addWidget(&lineedit); + layout.addWidget(&combo); + widget.setLayout(&layout); widget.setStyle(style); // propagate the style. foreach (QWidget *w, qFindChildren<QWidget *>(&widget)) w->setStyle(style); - widget.show(); + widget.show(); QTest::qWait( 500 ); - QVERIFY(qAbs(spinbox.height() - lineedit.height()) <= 1); - QVERIFY(qAbs(spinbox.height() - combo.height()) <= 1); + QVERIFY(qAbs(spinbox.height() - lineedit.height()) <= 1); + QVERIFY(qAbs(spinbox.height() - combo.height()) <= 1); } void tst_QStyle::defaultFont() diff --git a/tests/auto/qstylesheetstyle/qstylesheetstyle.pro b/tests/auto/qstylesheetstyle/qstylesheetstyle.pro index f6101f4..eada969 100644 --- a/tests/auto/qstylesheetstyle/qstylesheetstyle.pro +++ b/tests/auto/qstylesheetstyle/qstylesheetstyle.pro @@ -1,14 +1,4 @@ -###################################################################### -# Automatically generated by qmake (2.01a) Wed Apr 26 13:53:24 2006 -###################################################################### - -TEMPLATE = app -TARGET = tst_qstylesheetstyle -DEPENDPATH += . -INCLUDEPATH += . .. - -CONFIG += console qtestlib -contains(QT_CONFIG, qt3support): QT += qt3support +load(qttest_p4) # Input SOURCES += tst_qstylesheetstyle.cpp diff --git a/tests/auto/qstylesheetstyle/tst_qstylesheetstyle.cpp b/tests/auto/qstylesheetstyle/tst_qstylesheetstyle.cpp index cbeaebb..60d9787 100644 --- a/tests/auto/qstylesheetstyle/tst_qstylesheetstyle.cpp +++ b/tests/auto/qstylesheetstyle/tst_qstylesheetstyle.cpp @@ -831,7 +831,7 @@ void tst_QStyleSheetStyle::hoverColors() QDialog frame; QLayout* layout = new QGridLayout; - QLineEdit* dummy = new QLineEdit; + QLineEdit* dummy = new QLineEdit; widget->setStyleSheet("*:hover { border:none; background: #e8ff66; color: #ff0084 }"); @@ -1210,6 +1210,7 @@ void tst_QStyleSheetStyle::proxyStyle() QTest::qWait(100); delete w; delete proxy; + delete newProxy; } void tst_QStyleSheetStyle::dialogButtonBox() @@ -1400,7 +1401,7 @@ void tst_QStyleSheetStyle::opaquePaintEvent() QWidget tl; QWidget cl(&tl); cl.setAttribute(Qt::WA_OpaquePaintEvent, true); - cl.setAutoFillBackground(true); + cl.setAutoFillBackground(true); cl.setStyleSheet(stylesheet); cl.ensurePolished(); QCOMPARE(cl.testAttribute(Qt::WA_OpaquePaintEvent), !transparent); @@ -1415,7 +1416,7 @@ void tst_QStyleSheetStyle::task188195_baseBackground() tree.show(); QTest::qWait(20); QImage image(tree.width(), tree.height(), QImage::Format_ARGB32); - + tree.render(&image); QVERIFY(testForColors(image, tree.palette().base().color())); QVERIFY(!testForColors(image, QColor(0xab, 0x12, 0x51))); diff --git a/tests/auto/qsvggenerator/qsvggenerator.pro b/tests/auto/qsvggenerator/qsvggenerator.pro index 1eb72b3..450bcd3 100644 --- a/tests/auto/qsvggenerator/qsvggenerator.pro +++ b/tests/auto/qsvggenerator/qsvggenerator.pro @@ -7,11 +7,14 @@ QT += svg xml SOURCES += tst_qsvggenerator.cpp -wince*: { +wince*|symbian { addFiles.sources = referenceSvgs addFiles.path = . DEPLOYMENT += addFiles +} + +wince* { DEFINES += SRCDIR=\\\"\\\" -} else { +} !symbian { DEFINES += SRCDIR=\\\"$$PWD/\\\" } diff --git a/tests/auto/qsvggenerator/tst_qsvggenerator.cpp b/tests/auto/qsvggenerator/tst_qsvggenerator.cpp index ef5d22d..3252bc1 100644 --- a/tests/auto/qsvggenerator/tst_qsvggenerator.cpp +++ b/tests/auto/qsvggenerator/tst_qsvggenerator.cpp @@ -55,6 +55,10 @@ //TESTED_CLASS= //TESTED_FILES= +#ifdef Q_OS_SYMBIAN +#define SRCDIR "" +#endif + class tst_QSvgGenerator : public QObject { Q_OBJECT diff --git a/tests/auto/qsvgrenderer/qsvgrenderer.pro b/tests/auto/qsvgrenderer/qsvgrenderer.pro index 120d9f0..8cfbcce 100644 --- a/tests/auto/qsvgrenderer/qsvgrenderer.pro +++ b/tests/auto/qsvgrenderer/qsvgrenderer.pro @@ -8,7 +8,7 @@ QT += svg SOURCES += tst_qsvgrenderer.cpp RESOURCES += resources.qrc -wince*: { +wince*|symbian { addFiles.sources = *.svg *.svgz addFiles.path = . diff --git a/tests/auto/qsvgrenderer/tst_qsvgrenderer.cpp b/tests/auto/qsvgrenderer/tst_qsvgrenderer.cpp index 73955fd..a57e793 100644 --- a/tests/auto/qsvgrenderer/tst_qsvgrenderer.cpp +++ b/tests/auto/qsvgrenderer/tst_qsvgrenderer.cpp @@ -83,6 +83,7 @@ private slots: void strokeInherit(); void testFillInheritance(); void testStopOffsetOpacity(); + void testUseElement(); #ifndef QT_NO_COMPRESS void testGzLoading(); @@ -755,7 +756,7 @@ static void opacity_drawSvgAndVerify(const QByteArray &data) void tst_QSvgRenderer::opacity() { - static const char *opacities[] = {"-1,4641", "0", "0.5", "1", "1.337"}; + static const char *opacities[] = {"-1.4641", "0", "0.5", "1", "1.337"}; static const char *firstColors[] = {"#7f7f7f", "#7f7f7f", "#402051", "blue", "#123456"}; static const char *secondColors[] = {"red", "#bad", "#bedead", "#7f7f7f", "#7f7f7f"}; @@ -795,8 +796,6 @@ void tst_QSvgRenderer::opacity() data.append("\"/></svg>"); opacity_drawSvgAndVerify(data); } - // When support for gradients on strokes has been implemented, add the code below. - /* // Stroke-opacity for (int i = 0; i < 5; ++i) { QByteArray data("<svg viewBox=\"0 0 10 10\"><defs><linearGradient id=\"grad\"><stop offset=\"0\" stop-color=\""); @@ -810,7 +809,6 @@ void tst_QSvgRenderer::opacity() data.append("\" /></svg>"); opacity_drawSvgAndVerify(data); } - */ } void tst_QSvgRenderer::paths() @@ -1205,5 +1203,106 @@ void tst_QSvgRenderer::testStopOffsetOpacity() QCOMPARE(images[0], images[3]); } +void tst_QSvgRenderer::testUseElement() +{ + static const char *svgs[] = { + //Use refering to non group node (1) + "<svg viewBox = \"0 0 200 200\">" + " <polygon points=\"20,20 50,120 100,10 40,80 50,80\"/>" + " <polygon points=\"20,80 50,180 100,70 40,140 50,140\" fill= \"red\" stroke = \"blue\" fill-opacity = \"0.7\" fill-rule = \"evenodd\" stroke-width = \"3\"/>" + "</svg>", + "<svg viewBox = \"0 0 200 200\">" + " <polygon id = \"usedPolyline\" points=\"20,20 50,120 100,10 40,80 50,80\"/>" + " <use y = \"60\" xlink:href = \"#usedPolyline\" fill= \"red\" stroke = \"blue\" fill-opacity = \"0.7\" fill-rule = \"evenodd\" stroke-width = \"3\"/>" + "</svg>", + "<svg viewBox = \"0 0 200 200\">" + " <polygon id = \"usedPolyline\" points=\"20,20 50,120 100,10 40,80 50,80\"/>" + " <g fill = \" red\" fill-opacity =\"0.2\">" + "<use y = \"60\" xlink:href = \"#usedPolyline\" stroke = \"blue\" fill-opacity = \"0.7\" fill-rule = \"evenodd\" stroke-width = \"3\"/>" + "</g>" + "</svg>", + "<svg viewBox = \"0 0 200 200\">" + " <polygon id = \"usedPolyline\" points=\"20,20 50,120 100,10 40,80 50,80\"/>" + " <g stroke-width = \"3\" stroke = \"yellow\">" + " <use y = \"60\" xlink:href = \"#usedPolyline\" fill = \" red\" stroke = \"blue\" fill-opacity = \"0.7\" fill-rule = \"evenodd\"/>" + " </g>" + "</svg>", + //Use refering to non group node (2) + "<svg viewBox = \"0 0 200 200\">" + " <polygon points=\"20,20 50,120 100,10 40,80 50,80\" fill = \"green\" fill-rule = \"nonzero\" stroke = \"purple\" stroke-width = \"4\" stroke-dasharray = \"1,1,3,1\" stroke-offset = \"3\" stroke-miterlimit = \"6\" stroke-linecap = \"butt\" stroke-linejoin = \"round\"/>" + " <polygon points=\"20,80 50,180 100,70 40,140 50,140\" fill= \"red\" stroke = \"blue\" fill-opacity = \"0.7\" fill-rule = \"evenodd\" stroke-width = \"3\" stroke-dasharray = \"1,1,1,1\" stroke-offset = \"5\" stroke-miterlimit = \"3\" stroke-linecap = \"butt\" stroke-linejoin = \"square\"/>" + "</svg>", + "<svg viewBox = \"0 0 200 200\">" + " <g fill = \"green\" fill-rule = \"nonzero\" stroke = \"purple\" stroke-width = \"4\" stroke-dasharray = \"1,1,3,1\" stroke-offset = \"3\" stroke-miterlimit = \"6\" stroke-linecap = \"butt\" stroke-linejoin = \"round\">" + " <polygon id = \"usedPolyline\" points=\"20,20 50,120 100,10 40,80 50,80\" />" + " </g>" + " <g stroke = \"blue\" stroke-width = \"3\" stroke-dasharray = \"1,1,1,1\" stroke-offset = \"5\" stroke-miterlimit = \"3\" stroke-linecap = \"butt\" stroke-linejoin = \"square\">" + " <use y = \"60\" xlink:href = \"#usedPolyline\" fill-opacity = \"0.7\" fill= \"red\" stroke = \"blue\" fill-rule = \"evenodd\"/>" + " </g>" + "</svg>", + "<svg viewBox = \"0 0 200 200\">" + " <g fill = \"green\" fill-rule = \"nonzero\" stroke = \"purple\" stroke-width = \"4\" stroke-dasharray = \"1,1,3,1\" stroke-offset = \"3\" stroke-miterlimit = \"6\" stroke-linecap = \"butt\" stroke-linejoin = \"round\">" + " <polygon id = \"usedPolyline\" points=\"20,20 50,120 100,10 40,80 50,80\" />" + " </g>" + " <g stroke-width = \"3\" stroke-dasharray = \"1,1,1,1\" stroke-offset = \"5\" stroke-miterlimit = \"3\" stroke-linecap = \"butt\" stroke-linejoin = \"square\" >" + " <use y = \"60\" xlink:href = \"#usedPolyline\" fill= \"red\" stroke = \"blue\" fill-opacity = \"0.7\" fill-rule = \"evenodd\" />" + " </g>" + "</svg>", + //Use refering to group node + "<svg viewBox = \"0 0 200 200\">" + " <g>" + " <circle cx=\"0\" cy=\"0\" r=\"100\" fill = \"red\" fill-opacity = \"0.6\"/>" + " <rect x = \"10\" y = \"10\" width = \"30\" height = \"30\" fill = \"red\" fill-opacity = \"0.5\"/>" + " <circle fill=\"#a6ce39\" cx=\"0\" cy=\"0\" r=\"33\" fill-opacity = \"0.5\"/>" + " </g>" + "</svg>", + "<svg viewBox = \"0 0 200 200\">" + " <defs>" + " <g id=\"usedG\">" + " <circle cx=\"0\" cy=\"0\" r=\"100\" fill-opacity = \"0.6\"/>" + " <rect x = \"10\" y = \"10\" width = \"30\" height = \"30\"/>" + " <circle fill=\"#a6ce39\" cx=\"0\" cy=\"0\" r=\"33\" />" + " </g>" + " </defs>" + " <use xlink:href =\"#usedG\" fill = \"red\" fill-opacity =\"0.5\"/>" + "</svg>", + "<svg viewBox = \"0 0 200 200\">" + " <defs>" + " <g fill = \"blue\" fill-opacity = \"0.3\">" + " <g id=\"usedG\">" + " <circle cx=\"0\" cy=\"0\" r=\"100\" fill-opacity = \"0.6\"/>" + " <rect x = \"10\" y = \"10\" width = \"30\" height = \"30\"/>" + " <circle fill=\"#a6ce39\" cx=\"0\" cy=\"0\" r=\"33\" />" + " </g>" + " </g>" + " </defs>" + " <g fill = \"red\" fill-opacity =\"0.5\">" + " <use xlink:href =\"#usedG\" />" + " </g>" + "</svg>" + }; + + const int COUNT = sizeof(svgs) / sizeof(svgs[0]); + QImage images[COUNT]; + QPainter p; + + for (int i = 0; i < COUNT; ++i) { + QByteArray data(svgs[i]); + QSvgRenderer renderer(data); + images[i] = QImage(200, 200, QImage::Format_ARGB32_Premultiplied); + images[i].fill(-1); + p.begin(&images[i]); + renderer.render(&p); + p.end(); + if (i < 4 && i != 0) { + QCOMPARE(images[0], images[i]); + } else if (i > 4 && i < 7) { + QCOMPARE(images[4], images[i]); + } else if (i > 7) { + QCOMPARE(images[8], images[i]); + } + } +} + QTEST_MAIN(tst_QSvgRenderer) #include "tst_qsvgrenderer.moc" diff --git a/tests/auto/qsyntaxhighlighter/tst_qsyntaxhighlighter.cpp b/tests/auto/qsyntaxhighlighter/tst_qsyntaxhighlighter.cpp index a97e172..ab979e8 100644 --- a/tests/auto/qsyntaxhighlighter/tst_qsyntaxhighlighter.cpp +++ b/tests/auto/qsyntaxhighlighter/tst_qsyntaxhighlighter.cpp @@ -147,7 +147,7 @@ public: }; QT_BEGIN_NAMESPACE -static bool operator==(const QTextLayout::FormatRange &lhs, const QTextLayout::FormatRange &rhs) +bool operator==(const QTextLayout::FormatRange &lhs, const QTextLayout::FormatRange &rhs) { return lhs.start == rhs.start && lhs.length == rhs.length diff --git a/tests/auto/qsysinfo/qsysinfo.pro b/tests/auto/qsysinfo/qsysinfo.pro index 917c281..e822fec 100644 --- a/tests/auto/qsysinfo/qsysinfo.pro +++ b/tests/auto/qsysinfo/qsysinfo.pro @@ -1,5 +1,4 @@ load(qttest_p4) - SOURCES += tst_qsysinfo.cpp QT = core diff --git a/tests/auto/qsystemsemaphore/test/test.pro b/tests/auto/qsystemsemaphore/test/test.pro index 62ea054..b8d3a4a 100644 --- a/tests/auto/qsystemsemaphore/test/test.pro +++ b/tests/auto/qsystemsemaphore/test/test.pro @@ -18,7 +18,7 @@ win32 { RESOURCES += ../files.qrc wince*: { -# this test calls lackkey, which then again depends on QtScript. +# this test calls lackey, which then again depends on QtScript. # let's add it here so that it gets deployed easily QT += script lackey.sources = ../../qsharedmemory/lackey/lackey.exe @@ -27,3 +27,12 @@ lackey.path = ../qsharedmemory/lackey DEPLOYMENT += lackey } +symbian: { +# this test calls lackey, which then again depends on QtScript. +# let's add it here so that it gets deployed easily +QT += script + +lackey.sources = ../../qsharedmemory/lackey/lackey.exe +lackey.path = /sys/bin +DEPLOYMENT += lackey +} diff --git a/tests/auto/qsystemsemaphore/tst_qsystemsemaphore.cpp b/tests/auto/qsystemsemaphore/tst_qsystemsemaphore.cpp index 1aa723c..1b8c375 100644 --- a/tests/auto/qsystemsemaphore/tst_qsystemsemaphore.cpp +++ b/tests/auto/qsystemsemaphore/tst_qsystemsemaphore.cpp @@ -185,6 +185,9 @@ void tst_QSystemSemaphore::complexacquire() void tst_QSystemSemaphore::basicProcesses() { +#if defined (Q_OS_SYMBIAN) && defined(Q_CC_NOKIAX86) + QSKIP("Cannot launch multiple Qt processes in Symbian emulator", SkipAll); +#endif QSystemSemaphore sem("store", 0, QSystemSemaphore::Create); QStringList acquireArguments = QStringList() << acquire_js(); @@ -201,6 +204,7 @@ void tst_QSystemSemaphore::basicProcesses() acquire.kill(); release.start(LACKYLOC "/lackey", releaseArguments); acquire.waitForFinished(5000); + release.waitForFinished(5000); QVERIFY(acquire.state() == QProcess::NotRunning); } @@ -216,6 +220,9 @@ void tst_QSystemSemaphore::processes_data() void tst_QSystemSemaphore::processes() { +#if defined (Q_OS_SYMBIAN) && defined(Q_CC_NOKIAX86) + QSKIP("Cannot launch multiple Qt processes in Symbian emulator", SkipAll); +#endif QSystemSemaphore sem("store", 1, QSystemSemaphore::Create); QFETCH(int, processes); @@ -242,7 +249,7 @@ void tst_QSystemSemaphore::processes() void tst_QSystemSemaphore::undo() { -#ifdef Q_OS_WIN +#if defined(Q_OS_WIN) || defined(Q_OS_SYMBIAN) QSKIP("This test only checks a unix behavior", SkipSingle); #endif @@ -264,9 +271,11 @@ void tst_QSystemSemaphore::undo() void tst_QSystemSemaphore::initialValue() { +#if defined (Q_OS_SYMBIAN) && defined(Q_CC_NOKIAX86) + QSKIP("Cannot launch multiple Qt processes in Symbian emulator", SkipAll); +#endif QSystemSemaphore sem("store", 1, QSystemSemaphore::Create); - QStringList acquireArguments = QStringList() << acquire_js(); QStringList releaseArguments = QStringList() << release_js(); QProcess acquire; @@ -286,6 +295,7 @@ void tst_QSystemSemaphore::initialValue() release.start(LACKYLOC "/lackey", releaseArguments); acquire.waitForFinished(10000); + release.waitForFinished(10000); QVERIFY(acquire.state()== QProcess::NotRunning); } QTEST_MAIN(tst_QSystemSemaphore) diff --git a/tests/auto/qtableview/qtableview.pro b/tests/auto/qtableview/qtableview.pro index 2368a56..72099d4 100644 --- a/tests/auto/qtableview/qtableview.pro +++ b/tests/auto/qtableview/qtableview.pro @@ -1,4 +1,4 @@ load(qttest_p4) +TARGET.EPOCHEAPSIZE = 0x200000 0x800000 SOURCES += tst_qtableview.cpp - diff --git a/tests/auto/qtablewidget/qtablewidget.pro b/tests/auto/qtablewidget/qtablewidget.pro index 2b2a016..d66d0ac 100644 --- a/tests/auto/qtablewidget/qtablewidget.pro +++ b/tests/auto/qtablewidget/qtablewidget.pro @@ -1,4 +1,16 @@ load(qttest_p4) SOURCES += tst_qtablewidget.cpp +# This prevents the GCCE compile failure: "elf2e32: Error 1063: Fatal Error in +# PostLinker." The paged statement is documented in the S60 docs. +symbian { + MMP_RULES -= PAGED + + custom_paged_rule = "$${LITERAL_HASH}ifndef GCCE"\ + "PAGED" \ + "$${LITERAL_HASH}endif" + MMP_RULES += custom_paged_rule +} + +symbian:MMP_RULES += "OPTION GCCE -mlong-calls" diff --git a/tests/auto/qtconcurrentfilter/tst_qtconcurrentfilter.cpp b/tests/auto/qtconcurrentfilter/tst_qtconcurrentfilter.cpp index 0e6f551..10fc306 100644 --- a/tests/auto/qtconcurrentfilter/tst_qtconcurrentfilter.cpp +++ b/tests/auto/qtconcurrentfilter/tst_qtconcurrentfilter.cpp @@ -42,7 +42,7 @@ #include <QCoreApplication> #include <QList> #include <QLinkedList> -#include <QTest> +#include <QtTest/QtTest> #include "../qtconcurrentmap/functions.h" #include "../qfuture/versioncheck.h" diff --git a/tests/auto/qtconcurrentiteratekernel/tst_qtconcurrentiteratekernel.cpp b/tests/auto/qtconcurrentiteratekernel/tst_qtconcurrentiteratekernel.cpp index 950c19e..137de6c 100644 --- a/tests/auto/qtconcurrentiteratekernel/tst_qtconcurrentiteratekernel.cpp +++ b/tests/auto/qtconcurrentiteratekernel/tst_qtconcurrentiteratekernel.cpp @@ -65,7 +65,7 @@ struct TestIterator int i; }; -#include <iterator> +#include <qiterator.h> namespace std { template <> struct iterator_traits<TestIterator> diff --git a/tests/auto/qtcpserver/crashingServer/main.cpp b/tests/auto/qtcpserver/crashingServer/main.cpp index e0ecc42..09a8180 100644 --- a/tests/auto/qtcpserver/crashingServer/main.cpp +++ b/tests/auto/qtcpserver/crashingServer/main.cpp @@ -53,15 +53,15 @@ int main(int argc, char *argv[]) return 1; } -#if !defined(Q_OS_WINCE) - printf("Listening\n"); - fflush(stdout); -#else +#if defined(Q_OS_WINCE) || defined(Q_OS_SYMBIAN) QFile file(QLatin1String("/test_signal.txt")); file.open(QIODevice::WriteOnly); file.write("Listening\n"); file.flush(); file.close(); +#else + printf("Listening\n"); + fflush(stdout); #endif server.waitForNewConnection(5000); diff --git a/tests/auto/qtcpserver/test/test.pro b/tests/auto/qtcpserver/test/test.pro index 3ca854f..bdeaa92 100644 --- a/tests/auto/qtcpserver/test/test.pro +++ b/tests/auto/qtcpserver/test/test.pro @@ -12,6 +12,12 @@ wince*: { } } +symbian { + crashApp.sources = $$QT_BUILD_TREE/examples/widgets/wiggly/$${BUILD_DIR}/crashingServer.exe + crashApp.path = . + DEPLOYMENT += crashApp +} + TARGET = ../tst_qtcpserver win32 { diff --git a/tests/auto/qtcpserver/tst_qtcpserver.cpp b/tests/auto/qtcpserver/tst_qtcpserver.cpp index 0a4aaba..bd4b13b 100644 --- a/tests/auto/qtcpserver/tst_qtcpserver.cpp +++ b/tests/auto/qtcpserver/tst_qtcpserver.cpp @@ -39,8 +39,9 @@ ** ****************************************************************************/ - -#ifdef _WIN32 +// Just to get Q_OS_SYMBIAN +#include <qglobal.h> +#if defined(_WIN32) && !defined(Q_OS_SYMBIAN) #include <winsock2.h> #else #include <sys/types.h> @@ -129,11 +130,11 @@ void tst_QTcpServer::getSetCheck() tst_QTcpServer::tst_QTcpServer() { + Q_SET_DEFAULT_IAP } tst_QTcpServer::~tst_QTcpServer() { - } void tst_QTcpServer::initTestCase_data() @@ -232,6 +233,9 @@ void tst_QTcpServer::clientServerLoop() //---------------------------------------------------------------------------------- void tst_QTcpServer::ipv6Server() { +#if defined(Q_OS_SYMBIAN) + QSKIP("Symbian: IPv6 is not yet supported", SkipAll); +#endif //### need to enter the event loop for the server to get the connection ?? ( windows) QTcpServer server; if (!server.listen(QHostAddress::LocalHostIPv6, 8944)) { @@ -309,6 +313,9 @@ void tst_QTcpServer::ipv4LoopbackPerformanceTest() //---------------------------------------------------------------------------------- void tst_QTcpServer::ipv6LoopbackPerformanceTest() { +#if defined(Q_OS_SYMBIAN) + QSKIP("Symbian: IPv6 is not yet supported", SkipAll); +#endif QTcpServer server; if (!server.listen(QHostAddress::LocalHostIPv6, 0)) { QVERIFY(server.serverError() == QAbstractSocket::UnsupportedSocketOperationError); @@ -503,6 +510,7 @@ private: //---------------------------------------------------------------------------------- void tst_QTcpServer::waitForConnectionTest() { + QFETCH_GLOBAL(bool, setProxy); if (setProxy) { #ifdef TEST_QNETWORK_PROXY @@ -514,7 +522,7 @@ void tst_QTcpServer::waitForConnectionTest() } QTcpSocket findLocalIpSocket; - findLocalIpSocket.connectToHost(QtNetworkSettings::serverName(), 21); + findLocalIpSocket.connectToHost(QtNetworkSettings::serverName(), 143); QVERIFY(findLocalIpSocket.waitForConnected(2000)); QTcpServer server; @@ -527,10 +535,10 @@ void tst_QTcpServer::waitForConnectionTest() ThreadConnector connector(findLocalIpSocket.localAddress(), server.serverPort()); connector.start(); -#if !defined(Q_OS_WINCE) - QVERIFY(server.waitForNewConnection(3000, &timeout)); -#else +#if defined(Q_OS_WINCE) || defined(Q_OS_SYMBIAN) QVERIFY(server.waitForNewConnection(9000, &timeout)); +#else + QVERIFY(server.waitForNewConnection(3000, &timeout)); #endif QVERIFY(!timeout); } @@ -590,7 +598,11 @@ protected: { // how a user woulddo it (qabstractsocketengine is not public) unsigned long arg = 0; -#ifdef Q_OS_WIN +#if defined(Q_OS_SYMBIAN) + arg = fcntl(socketDescriptor, F_GETFL, NULL); + arg &= (~O_NONBLOCK); + ok = ::fcntl(socketDescriptor, F_SETFL, arg) != -1; +#elif defined(Q_OS_WIN) ok = ::ioctlsocket(socketDescriptor, FIONBIO, &arg) == 0; ::closesocket(socketDescriptor); #else @@ -602,6 +614,10 @@ protected: void tst_QTcpServer::addressReusable() { +#if defined(Q_OS_SYMBIAN) && defined(Q_CC_NOKIAX86) + QSKIP("Symbian: Emulator does not support process launching", SkipAll ); +#endif + #if defined(QT_NO_PROCESS) QSKIP("Qt was compiled with QT_NO_PROCESS", SkipAll); #else @@ -615,7 +631,7 @@ void tst_QTcpServer::addressReusable() } #endif } -#if defined(Q_OS_WINCE) +#if defined(Q_OS_WINCE) || defined(Q_OS_SYMBIAN) QString signalName = QString::fromLatin1("/test_signal.txt"); QFile::remove(signalName); // The crashingServer process will crash once it gets a connection. @@ -663,9 +679,7 @@ void tst_QTcpServer::setNewSocketDescriptorBlocking() QTcpSocket socket; socket.connectToHost(QHostAddress::LocalHost, server.serverPort()); - QVERIFY(server.waitForNewConnection(5000)); - QVERIFY(server.ok); } @@ -678,7 +692,7 @@ void tst_QTcpServer::invalidProxy_data() QTest::addColumn<int>("expectedError"); QString fluke = QHostInfo::fromName(QtNetworkSettings::serverName()).addresses().first().toString(); - QTest::newRow("ftp-proxy") << int(QNetworkProxy::FtpCachingProxy) << fluke << 21 + QTest::newRow("ftp-proxy") << int(QNetworkProxy::FtpCachingProxy) << fluke << 143 << int(QAbstractSocket::UnsupportedSocketOperationError); QTest::newRow("http-proxy") << int(QNetworkProxy::HttpProxy) << fluke << 3128 << int(QAbstractSocket::UnsupportedSocketOperationError); diff --git a/tests/auto/qtcpsocket/qtcpsocket.pro b/tests/auto/qtcpsocket/qtcpsocket.pro index 6a96889..4bbec23 100644 --- a/tests/auto/qtcpsocket/qtcpsocket.pro +++ b/tests/auto/qtcpsocket/qtcpsocket.pro @@ -2,5 +2,4 @@ TEMPLATE = subdirs !wince*: SUBDIRS = test stressTest -wince*: SUBDIRS = test -vxworks*: SUBDIRS = test +wince*|symbian*|vxworks* : SUBDIRS = test diff --git a/tests/auto/qtcpsocket/test/test.pro b/tests/auto/qtcpsocket/test/test.pro index 696375d..0f93def 100644 --- a/tests/auto/qtcpsocket/test/test.pro +++ b/tests/auto/qtcpsocket/test/test.pro @@ -11,7 +11,9 @@ wince*: { QT += network vxworks:QT -= gui -DEFINES += TEST_QNETWORK_PROXY +symbian: TARGET.EPOCHEAPSIZE="0x100 0x1000000" + +#DEFINES += TEST_QNETWORK_PROXY TARGET = tst_qtcpsocket diff --git a/tests/auto/qtcpsocket/tst_qtcpsocket.cpp b/tests/auto/qtcpsocket/tst_qtcpsocket.cpp index 6d0dc21..81c86a2 100644 --- a/tests/auto/qtcpsocket/tst_qtcpsocket.cpp +++ b/tests/auto/qtcpsocket/tst_qtcpsocket.cpp @@ -40,7 +40,10 @@ ****************************************************************************/ -#ifdef _WIN32 +// Just to get Q_OS_SYMBIAN +#include <qglobal.h> + +#if defined(_WIN32) && !defined(Q_OS_SYMBIAN) #include <winsock2.h> #else #include <sys/types.h> @@ -82,9 +85,8 @@ #ifndef TEST_QNETWORK_PROXY #define TEST_QNETWORK_PROXY #endif -#ifdef TEST_QNETWORK_PROXY +// RVCT compiles also unused inline methods # include <QNetworkProxy> -#endif #ifdef Q_OS_LINUX #include <stdio.h> @@ -249,6 +251,7 @@ int tst_QTcpSocket::loopLevel = 0; tst_QTcpSocket::tst_QTcpSocket() { + Q_SET_DEFAULT_IAP tmpSocket = 0; } @@ -907,7 +910,11 @@ void tst_QTcpSocket::disconnectWhileConnecting() } connect(socket, SIGNAL(disconnected()), SLOT(exitLoopSlot())); +#ifndef Q_OS_SYMBIAN enterLoop(10); +#else + enterLoop(30); +#endif QVERIFY2(!timeout(), "Network timeout"); QVERIFY(socket->state() == QAbstractSocket::UnconnectedState); if (!closeDirectly) { @@ -942,7 +949,7 @@ public: : server(0), ok(false), quit(false) { } - ~ReceiverThread() { wait(); delete server; } + ~ReceiverThread() { /*delete server;*/ terminate(); wait(); } bool listen() { @@ -959,7 +966,11 @@ protected: { bool timedOut = false; while (!quit) { +#ifndef Q_OS_SYMBIAN if (server->waitForNewConnection(500, &timedOut)) +#else + if (server->waitForNewConnection(5000, &timedOut)) +#endif break; if (!timedOut) return; @@ -967,7 +978,11 @@ protected: QTcpSocket *socket = server->nextPendingConnection(); while (!quit) { +#ifndef Q_OS_SYMBIAN if (socket->waitForDisconnected(500)) +#else + if (socket->waitForDisconnected(5000)) +#endif break; if (socket->error() != QAbstractSocket::SocketTimeoutError) return; @@ -1015,7 +1030,11 @@ void tst_QTcpSocket::disconnectWhileConnectingNoEventLoop() socket->disconnectFromHost(); } +#ifndef Q_OS_SYMBIAN QVERIFY2(socket->waitForDisconnected(10000), "Network timeout"); +#else + QVERIFY2(socket->waitForDisconnected(30000), "Network timeout"); +#endif QVERIFY(socket->state() == QAbstractSocket::UnconnectedState); if (!closeDirectly) { QCOMPARE(int(socket->openMode()), int(QIODevice::ReadWrite)); @@ -1025,7 +1044,7 @@ void tst_QTcpSocket::disconnectWhileConnectingNoEventLoop() delete socket; // check if the other side received everything ok - QVERIFY(thread.wait(10000)); + QVERIFY(thread.wait(30000)); QVERIFY(thread.ok); QCOMPARE(thread.receivedData, data); } @@ -1061,7 +1080,11 @@ void tst_QTcpSocket::disconnectWhileLookingUp() // let anything queued happen QEventLoop loop; +#ifndef Q_OS_SYMBIAN QTimer::singleShot(50, &loop, SLOT(quit())); +#else + QTimer::singleShot(5000, &loop, SLOT(quit())); +#endif loop.exec(); // recheck @@ -1166,13 +1189,13 @@ void tst_QTcpSocket::readLine() QVERIFY(socket->waitForReadyRead(10000)); char buffer[1024]; - QCOMPARE(socket->readLine(buffer, sizeof(buffer)), qint64(161)); + int expectedReplySize = QtNetworkSettings::expectedReplyIMAP().size(); + Q_ASSERT(expectedReplySize >= 3); + QCOMPARE(socket->readLine(buffer, sizeof(buffer)), qint64(expectedReplySize)); - // * OK fluke Cyrus IMAP4 v2.2.12 server ready__ -// // 01234567890123456789012345678901234567890123456789 - QCOMPARE((int) buffer[159], (int) '\r'); - QCOMPARE((int) buffer[160], (int) '\n'); - QCOMPARE((int) buffer[161], (int) '\0'); + QCOMPARE((int) buffer[expectedReplySize-2], (int) '\r'); + QCOMPARE((int) buffer[expectedReplySize-1], (int) '\n'); + QCOMPARE((int) buffer[expectedReplySize], (int) '\0'); QCOMPARE(socket->write("1 NOOP\r\n"), qint64(8)); @@ -1210,7 +1233,7 @@ void tst_QTcpSocket::readLineString() QVERIFY(socket->waitForReadyRead(10000)); QByteArray arr = socket->readLine(); - QCOMPARE(arr, expected); + QCOMPARE(arr, QtNetworkSettings::expectedReplyIMAP()); delete socket; } @@ -1307,11 +1330,19 @@ void tst_QTcpSocket::dontCloseOnTimeout() QTcpSocket *socket = newSocket(); socket->connectToHost(serverAddress, server.serverPort()); +#ifndef Q_OS_SYMBIAN QVERIFY(!socket->waitForReadyRead(100)); +#else + QVERIFY(!socket->waitForReadyRead(5000)); +#endif QCOMPARE(socket->error(), QTcpSocket::SocketTimeoutError); QVERIFY(socket->isOpen()); +#ifndef Q_OS_SYMBIAN QVERIFY(!socket->waitForDisconnected(100)); +#else + QVERIFY(!socket->waitForDisconnected(5000)); +#endif QCOMPARE(socket->error(), QTcpSocket::SocketTimeoutError); QVERIFY(socket->isOpen()); @@ -1438,9 +1469,7 @@ void tst_QTcpSocket::socketInAThread() TestThread thread; thread.start(); QVERIFY(thread.wait(15000)); - QCOMPARE(thread.data(), -// QByteArray("220 (vsFTPd 2.0.4)\r\n221 Goodbye.\r\n")); - QByteArray("220 (vsFTPd 2.0.5)\r\n221 Goodbye.\r\n")); + QCOMPARE(thread.data(), QtNetworkSettings::expectedReplyFtp()); } } @@ -1460,12 +1489,9 @@ void tst_QTcpSocket::socketsInThreads() QVERIFY(thread3.wait(15000)); QVERIFY(thread1.wait(15000)); - QCOMPARE(thread1.data(), - QByteArray("220 (vsFTPd 2.0.5)\r\n221 Goodbye.\r\n")); - QCOMPARE(thread2.data(), - QByteArray("220 (vsFTPd 2.0.5)\r\n221 Goodbye.\r\n")); - QCOMPARE(thread3.data(), - QByteArray("220 (vsFTPd 2.0.5)\r\n221 Goodbye.\r\n")); + QCOMPARE(thread1.data(),QtNetworkSettings::expectedReplyFtp()); + QCOMPARE(thread2.data(),QtNetworkSettings::expectedReplyFtp()); + QCOMPARE(thread3.data(),QtNetworkSettings::expectedReplyFtp()); } } @@ -1764,7 +1790,16 @@ void tst_QTcpSocket::readyReadSignalsAfterWaitForReadyRead() QCOMPARE(readyReadSpy.count(), 1); QString s = socket->readLine(); - QCOMPARE(s.toLatin1().constData(), "* OK [CAPABILITY IMAP4 IMAP4rev1 LITERAL+ ID STARTTLS LOGINDISABLED] qt-test-server.qt-test-net Cyrus IMAP4 v2.3.11-Mandriva-RPM-2.3.11-6mdv2008.1 server ready\r\n"); +#ifdef TEST_QNETWORK_PROXY + QNetworkProxy::ProxyType proxyType = QNetworkProxy::applicationProxy().type(); + if(proxyType == QNetworkProxy::NoProxy) { + QCOMPARE(s.toLatin1().constData(), "* OK [CAPABILITY IMAP4REV1] aspiriniks Cyrus IMAP4 v2.3.11-Mandriva-RPM-2.3.11-6mdv2008.1 server ready\r\n"); + } else { + QCOMPARE(s.toLatin1().constData(), "* OK [CAPABILITY IMAP4 IMAP4rev1 LITERAL+ ID STARTTLS LOGINDISABLED] aspiriniks Cyrus IMAP4 v2.3.11-Mandriva-RPM-2.3.11-6mdv2008.1 server ready\r\n"); + } +#else + QCOMPARE(s.toLatin1().constData(), QtNetworkSettings::expectedReplyIMAP().constData()); +#endif QCOMPARE(socket->bytesAvailable(), qint64(0)); QCoreApplication::instance()->processEvents(); @@ -1982,6 +2017,8 @@ void tst_QTcpSocket::suddenRemoteDisconnect() { #if defined(Q_OS_WINCE) || defined(Q_OS_VXWORKS) QSKIP("stressTest subprocess needs Qt3Support", SkipAll); +#elif defined( Q_OS_SYMBIAN ) + QSKIP("Symbian: QProcess IO is not yet supported, fix when supported", SkipAll); #else QFETCH(QString, client); QFETCH(QString, server); @@ -2200,11 +2237,12 @@ void tst_QTcpSocket::invalidProxy_data() QTest::newRow("no-such-host-http") << int(QNetworkProxy::HttpProxy) << "this-host-will-never-exist.troll.no" << 3128 << false << int(QAbstractSocket::ProxyNotFoundError); - +#if !defined(Q_OS_SYMBIAN) QTest::newRow("http-on-socks5") << int(QNetworkProxy::HttpProxy) << fluke << 1080 << false << int(QAbstractSocket::ProxyConnectionClosedError); QTest::newRow("socks5-on-http") << int(QNetworkProxy::Socks5Proxy) << fluke << 3128 << false << int(QAbstractSocket::SocketTimeoutError); +#endif } void tst_QTcpSocket::invalidProxy() @@ -2360,5 +2398,6 @@ void tst_QTcpSocket::proxyFactory() } #endif + QTEST_MAIN(tst_QTcpSocket) #include "tst_qtcpsocket.moc" diff --git a/tests/auto/qtemporaryfile/qtemporaryfile.pro b/tests/auto/qtemporaryfile/qtemporaryfile.pro index bde990a..c93a2e5 100644 --- a/tests/auto/qtemporaryfile/qtemporaryfile.pro +++ b/tests/auto/qtemporaryfile/qtemporaryfile.pro @@ -2,4 +2,11 @@ load(qttest_p4) SOURCES += tst_qtemporaryfile.cpp QT = core -DEFINES += SRCDIR=\\\"$$PWD/\\\" + +symbian { + testData.sources = tst_qtemporaryfile.cpp + testData.path = . + DEPLOYMENT += testData +}else { + DEFINES += SRCDIR=\\\"$$PWD/\\\" +} diff --git a/tests/auto/qtemporaryfile/tst_qtemporaryfile.cpp b/tests/auto/qtemporaryfile/tst_qtemporaryfile.cpp index 8e0c871..1f09183 100644 --- a/tests/auto/qtemporaryfile/tst_qtemporaryfile.cpp +++ b/tests/auto/qtemporaryfile/tst_qtemporaryfile.cpp @@ -59,6 +59,10 @@ # include <unistd.h> // close(2) #endif +#ifdef Q_OS_SYMBIAN +#define SRCDIR "" +#endif + //TESTED_CLASS= //TESTED_FILES= @@ -186,7 +190,7 @@ void tst_QTemporaryFile::fileName() QVERIFY(QFile::exists(fileName)); // Get path to the temp file, whithout the file name. QString absoluteFilePath = QFileInfo(fileName).absolutePath(); -#ifdef Q_OS_WIN +#if defined(Q_OS_WIN) || defined(Q_OS_SYMBIAN) absoluteFilePath = absoluteFilePath.toLower(); absoluteTempPath = absoluteTempPath.toLower(); #endif @@ -341,7 +345,7 @@ void tst_QTemporaryFile::openOnRootDrives() void tst_QTemporaryFile::stressTest() { -#ifdef Q_OS_WINCE +#if defined(Q_OS_WINCE) || defined(Q_OS_SYMBIAN) // 200 is still ok, first colision happens after ~30 const int iterations = 200; #else diff --git a/tests/auto/qtextblock/tst_qtextblock.cpp b/tests/auto/qtextblock/tst_qtextblock.cpp index 740d2c8..548a568 100644 --- a/tests/auto/qtextblock/tst_qtextblock.cpp +++ b/tests/auto/qtextblock/tst_qtextblock.cpp @@ -115,7 +115,7 @@ void tst_QTextBlock::fragmentOverBlockBoundaries() QVERIFY(doc); // Block separators are always a fragment of their self. Thus: // |Hello|\b|World|\b| -#ifndef Q_WS_WIN +#if !defined(Q_WS_WIN) && !defined(Q_WS_S60) QVERIFY(doc->d_func()->fragmentMap().numNodes() == 4); #endif diff --git a/tests/auto/qtextboundaryfinder/qtextboundaryfinder.pro b/tests/auto/qtextboundaryfinder/qtextboundaryfinder.pro index 4d2ff01..cba5a74 100644 --- a/tests/auto/qtextboundaryfinder/qtextboundaryfinder.pro +++ b/tests/auto/qtextboundaryfinder/qtextboundaryfinder.pro @@ -1,9 +1,10 @@ load(qttest_p4) +QT = core HEADERS += SOURCES += tst_qtextboundaryfinder.cpp -DEFINES += SRCDIR=\\\"$$PWD\\\" +!symbian:*:DEFINES += SRCDIR=\\\"$$PWD\\\" -wince*:{ +wince*|symbian*:{ addFiles.sources = data addFiles.path = . DEPLOYMENT += addFiles diff --git a/tests/auto/qtextboundaryfinder/tst_qtextboundaryfinder.cpp b/tests/auto/qtextboundaryfinder/tst_qtextboundaryfinder.cpp index f3828ab..c6dab58 100644 --- a/tests/auto/qtextboundaryfinder/tst_qtextboundaryfinder.cpp +++ b/tests/auto/qtextboundaryfinder/tst_qtextboundaryfinder.cpp @@ -48,6 +48,9 @@ //TESTED_CLASS= //TESTED_FILES=gui/text/qtextlayout.h corelib/tools/qtextboundaryfinder.cpp +#ifdef Q_OS_SYMBIAN +#define SRCDIR "$$PWD" +#endif class tst_QTextBoundaryFinder : public QObject { diff --git a/tests/auto/qtextbrowser/qtextbrowser.pro b/tests/auto/qtextbrowser/qtextbrowser.pro index 6da3bfb..e159a3c 100644 --- a/tests/auto/qtextbrowser/qtextbrowser.pro +++ b/tests/auto/qtextbrowser/qtextbrowser.pro @@ -1,11 +1,11 @@ load(qttest_p4) SOURCES += tst_qtextbrowser.cpp -DEFINES += SRCDIR=\\\"$$PWD\\\" +!symbian*:DEFINES += SRCDIR=\\\"$$PWD\\\" contains(QT_CONFIG, qt3support): QT += qt3support -wince*: { +wince*|symbian*: { addFiles.sources = *.html addFiles.path = . addDir.sources = subdir/* diff --git a/tests/auto/qtextbrowser/tst_qtextbrowser.cpp b/tests/auto/qtextbrowser/tst_qtextbrowser.cpp index b7fefc0..8d8fee1 100644 --- a/tests/auto/qtextbrowser/tst_qtextbrowser.cpp +++ b/tests/auto/qtextbrowser/tst_qtextbrowser.cpp @@ -52,6 +52,10 @@ //TESTED_CLASS= //TESTED_FILES= +#if defined(Q_OS_SYMBIAN) +# define SRCDIR "" +#endif + class TestBrowser : public QTextBrowser { public: @@ -545,6 +549,9 @@ void tst_QTextBrowser::focusIndicator() QVERIFY(browser->textCursor().hasSelection()); QCOMPARE(browser->textCursor().selectedText(), QString("Link to second page")); +#ifdef QT_KEYPAD_NAVIGATION + browser->setEditFocus(true); +#endif QTest::keyClick(browser, Qt::Key_Enter); QVERIFY(!browser->textCursor().hasSelection()); @@ -594,6 +601,9 @@ void tst_QTextBrowser::focusHistory() QVERIFY(browser->textCursor().hasSelection()); QCOMPARE(browser->textCursor().selectedText(), QString("Link to second page")); +#ifdef QT_KEYPAD_NAVIGATION + browser->setEditFocus(true); +#endif QTest::keyClick(browser, Qt::Key_Enter); QVERIFY(!browser->textCursor().hasSelection()); @@ -650,6 +660,9 @@ void tst_QTextBrowser::urlEncoding() QSignalSpy spy(browser, SIGNAL(anchorClicked(const QUrl &))); +#ifdef QT_KEYPAD_NAVIGATION + browser->setEditFocus(true); +#endif QTest::keyClick(browser, Qt::Key_Enter); QCOMPARE(spy.count(), 1); diff --git a/tests/auto/qtextcodec/test/test.pro b/tests/auto/qtextcodec/test/test.pro index 99f94d4..afd7f5e 100644 --- a/tests/auto/qtextcodec/test/test.pro +++ b/tests/auto/qtextcodec/test/test.pro @@ -16,12 +16,17 @@ win32: { TARGET = tst_qtextcodec } -wince*: { +wince*|symbian { addFiles.sources = ../*.txt addFiles.path = . DEPLOYMENT += addFiles DEPLOYMENT_PLUGIN += qcncodecs qjpcodecs qkrcodecs qtwcodecs +} + +wince*: { DEFINES += SRCDIR=\\\"\\\" +}else:symbian { + # Symbian can't define SRCDIR meaningfully here } else { DEFINES += SRCDIR=\\\"$$PWD/../\\\" } diff --git a/tests/auto/qtextcodec/tst_qtextcodec.cpp b/tests/auto/qtextcodec/tst_qtextcodec.cpp index 7e98a99..7f2eda9 100644 --- a/tests/auto/qtextcodec/tst_qtextcodec.cpp +++ b/tests/auto/qtextcodec/tst_qtextcodec.cpp @@ -45,8 +45,14 @@ #include <qtextcodec.h> #include <qfile.h> #include <qtextdocument.h> +#include <time.h> #include <qprocess.h> +#ifdef Q_OS_SYMBIAN +#define SRCDIR "" +#endif + + class tst_QTextCodec : public QObject { Q_OBJECT @@ -278,7 +284,7 @@ void tst_QTextCodec::codecForLocale() QTextCodec *codec = QTextCodec::codecForLocale(); QVERIFY(codec != 0); -#ifdef Q_OS_UNIX +#if defined(Q_OS_UNIX) // get a time string that is locale-encoded QByteArray originalLocaleEncodedTimeString; originalLocaleEncodedTimeString.resize(1024); @@ -310,7 +316,6 @@ void tst_QTextCodec::codecForLocale() } if (!codec2) { QSKIP("Could not find a codec that is not already the codecForLocale()", SkipAll); - return; } // set it, codecForLocale() should return it now @@ -1685,6 +1690,7 @@ void tst_QTextCodec::utfHeaders_data() << (QString(QChar(0xfeff)) + QString::fromLatin1("hel")) << true; + QTest::newRow("utf32 bom be") << QByteArray("UTF-32") << 0 diff --git a/tests/auto/qtextdocumentlayout/tst_qtextdocumentlayout.cpp b/tests/auto/qtextdocumentlayout/tst_qtextdocumentlayout.cpp index d8c4f51..dbba9ef 100644 --- a/tests/auto/qtextdocumentlayout/tst_qtextdocumentlayout.cpp +++ b/tests/auto/qtextdocumentlayout/tst_qtextdocumentlayout.cpp @@ -71,6 +71,7 @@ private slots: void wrapAtWordBoundaryOrAnywhere(); void inlineImage(); void clippedTableCell(); + void floatingTablePageBreak(); private: QTextDocument *doc; @@ -250,5 +251,25 @@ void tst_QTextDocumentLayout::clippedTableCell() QCOMPARE(img, expected); } +void tst_QTextDocumentLayout::floatingTablePageBreak() +{ + doc->clear(); + + QTextCursor cursor(doc); + + QTextTableFormat tableFormat; + tableFormat.setPosition(QTextFrameFormat::FloatLeft); + QTextTable *table = cursor.insertTable(50, 1, tableFormat); + + // Make height of document 2/3 of the table, fitting the table into two pages + QSizeF documentSize = doc->size(); + documentSize.rheight() *= 2.0 / 3.0; + + doc->setPageSize(documentSize); + + QCOMPARE(doc->pageCount(), 2); +} + + QTEST_MAIN(tst_QTextDocumentLayout) #include "tst_qtextdocumentlayout.moc" diff --git a/tests/auto/qtextedit/qtextedit.pro b/tests/auto/qtextedit/qtextedit.pro index 142dd47..02f5dcb 100644 --- a/tests/auto/qtextedit/qtextedit.pro +++ b/tests/auto/qtextedit/qtextedit.pro @@ -5,12 +5,15 @@ INCLUDEPATH += ../ HEADERS += SOURCES += tst_qtextedit.cpp -wince* { - DEFINES += SRCDIR=\\\"./\\\" +wince*|symbian*: { addImages.sources = fullWidthSelection/* addImages.path = fullWidthSelection DEPLOYMENT += addImages -} else { +} + +wince* { + DEFINES += SRCDIR=\\\"./\\\" +} !symbian { DEFINES += SRCDIR=\\\"$$PWD/\\\" } diff --git a/tests/auto/qtextedit/tst_qtextedit.cpp b/tests/auto/qtextedit/tst_qtextedit.cpp index 337cc43..b89d919 100644 --- a/tests/auto/qtextedit/tst_qtextedit.cpp +++ b/tests/auto/qtextedit/tst_qtextedit.cpp @@ -73,6 +73,11 @@ Q_DECLARE_METATYPE(QList<bool>); #include <Carbon/Carbon.h> #endif +#if defined(Q_OS_SYMBIAN) +# define SRCDIR "" +#undef QT3_SUPPORT +#endif + bool nativeClipboardWorking() { @@ -110,13 +115,17 @@ private slots: void autoBulletList1(); void autoBulletList2(); void preserveCharFormatAfterNewline(); +#ifndef QT_NO_CLIPBOARD void clearMustNotChangeClipboard(); +#endif void clearMustNotResetRootFrameMarginToDefault(); void clearShouldPreserveTheCurrentCharFormat(); void clearShouldClearExtraSelections(); void paragSeparatorOnPlaintextAppend(); void layoutingLoop(); +#ifndef QT_NO_CLIPBOARD void selectAllSetsNotSelection(); +#endif void asciiTab(); void setDocument(); void setDocument_shared(); @@ -129,7 +138,9 @@ private slots: #endif void cursorPositionChanged(); void setTextCursor(); +#ifndef QT_NO_CLIPBOARD void undoAvailableAfterPaste(); +#endif void undoRedoAvailableRepetition(); void appendShouldUseCurrentFormat(); void appendShouldNotTouchTheSelection(); @@ -137,7 +148,9 @@ private slots: void shiftBackspace(); void undoRedo(); void preserveCharFormatInAppend(); +#ifndef QT_NO_CLIPBOARD void copyAndSelectAllInReadonly(); +#endif void ctrlAltInput(); void noPropertiesOnDefaultTextEditCharFormat(); void setPlainTextShouldUseCurrentCharFormat(); @@ -152,14 +165,18 @@ private slots: void undoRedoAfterSetContent(); void numPadKeyNavigation(); void moveCursor(); +#ifndef QT_NO_CLIPBOARD void mimeDataReimplementations(); +#endif void ctrlEnterShouldInsertLineSeparator_NOT(); void shiftEnterShouldInsertLineSeparator(); void selectWordsFromStringsContainingSeparators_data(); void selectWordsFromStringsContainingSeparators(); +#ifndef QT_NO_CLIPBOARD void canPaste(); void copyAvailable_data(); void copyAvailable(); +#endif void ensureCursorVisibleOnInitialShow(); void setHtmlInsideResizeEvent(); void colorfulAppend(); @@ -471,6 +488,7 @@ void tst_QTextEdit::createSelection() QCOMPARE(ed->textCursor().position(), 11); } +#ifndef QT_NO_CLIPBOARD void tst_QTextEdit::clearMustNotChangeClipboard() { if (!nativeClipboardWorking()) @@ -481,6 +499,7 @@ void tst_QTextEdit::clearMustNotChangeClipboard() ed->clear(); QCOMPARE(QApplication::clipboard()->text(), txt); } +#endif void tst_QTextEdit::clearMustNotResetRootFrameMarginToDefault() { @@ -544,6 +563,7 @@ void tst_QTextEdit::layoutingLoop() QVERIFY(callsToSetPageSize < 10); } +#ifndef QT_NO_CLIPBOARD void tst_QTextEdit::selectAllSetsNotSelection() { if (!QApplication::clipboard()->supportsSelection()) { @@ -559,7 +579,7 @@ void tst_QTextEdit::selectAllSetsNotSelection() QCOMPARE(QApplication::clipboard()->text(QClipboard::Selection), QString::fromAscii("foobar")); } - +#endif void tst_QTextEdit::asciiTab() { QTextEdit edit; @@ -569,6 +589,7 @@ void tst_QTextEdit::asciiTab() QCOMPARE(edit.toPlainText().at(0), QChar('\t')); } + void tst_QTextEdit::setDocument() { QTextDocument *document = new QTextDocument(ed); @@ -769,6 +790,7 @@ void tst_QTextEdit::setTextCursor() QCOMPARE(spy.count(), 1); } +#ifndef QT_NO_CLIPBOARD void tst_QTextEdit::undoAvailableAfterPaste() { if (!nativeClipboardWorking()) @@ -782,6 +804,7 @@ void tst_QTextEdit::undoAvailableAfterPaste() QVERIFY(spy.count() >= 1); QCOMPARE(ed->toPlainText(), txt); } +#endif class UndoRedoRecorder : public QObject { @@ -988,6 +1011,7 @@ void tst_QTextEdit::preserveCharFormatInAppend() QCOMPARE(cursor.block().text(), QString("third para")); } +#ifndef QT_NO_CLIPBOARD void tst_QTextEdit::copyAndSelectAllInReadonly() { if (!nativeClipboardWorking()) @@ -1018,6 +1042,7 @@ void tst_QTextEdit::copyAndSelectAllInReadonly() QTest::keyClick(ed, Qt::Key_C, Qt::ControlModifier); QCOMPARE(QApplication::clipboard()->text(), QString("Hello World")); } +#endif void tst_QTextEdit::ctrlAltInput() { @@ -1257,6 +1282,7 @@ void tst_QTextEdit::implicitClear() QVERIFY(ed->toPlainText().isEmpty()); } +#ifndef QT_NO_CLIPBOARD void tst_QTextEdit::copyAvailable_data() { QTest::addColumn<pairListType>("keystrokes"); @@ -1374,6 +1400,7 @@ void tst_QTextEdit::copyAvailable() QVERIFY2(variantSpyCopyAvailable.toBool() == copyAvailable.at(i), QString("Spied singnal: %1").arg(i).toLatin1()); } } +#endif void tst_QTextEdit::undoRedoAfterSetContent() { @@ -1439,6 +1466,7 @@ public: }; +#ifndef QT_NO_CLIPBOARD void tst_QTextEdit::mimeDataReimplementations() { MyTextEdit ed; @@ -1477,6 +1505,7 @@ void tst_QTextEdit::mimeDataReimplementations() QCOMPARE(ed.insertCallCount, 1); #endif } +#endif void tst_QTextEdit::ctrlEnterShouldInsertLineSeparator_NOT() { @@ -1528,6 +1557,7 @@ void tst_QTextEdit::selectWordsFromStringsContainingSeparators() cursor.clearSelection(); } +#ifndef QT_NO_CLIPBOARD void tst_QTextEdit::canPaste() { if (!nativeClipboardWorking()) @@ -1540,6 +1570,7 @@ void tst_QTextEdit::canPaste() ed->setTextInteractionFlags(Qt::NoTextInteraction); QVERIFY(!ed->canPaste()); } +#endif void tst_QTextEdit::ensureCursorVisibleOnInitialShow() { @@ -1886,7 +1917,7 @@ void tst_QTextEdit::setText() } QT_BEGIN_NAMESPACE -extern Q_GUI_EXPORT bool qt_enable_test_font; +extern void qt_setQtEnableTestFont(bool value); QT_END_NAMESPACE void tst_QTextEdit::fullWidthSelection_data() @@ -1933,7 +1964,7 @@ void tst_QTextEdit::fullWidthSelection() cursor.setBlockFormat(bf1); // use the test font so we always know where stuff will end up. - qt_enable_test_font = true; + qt_setQtEnableTestFont(true); QFont testFont; testFont.setFamily("__Qt__Box__Engine__"); testFont.setPixelSize(12); @@ -1981,7 +2012,7 @@ void tst_QTextEdit::fullWidthSelection2() QTextCursor cursor = widget.textCursor(); // use the test font so we always know where stuff will end up. - qt_enable_test_font = true; + qt_setQtEnableTestFont(true); QFont testFont; testFont.setFamily("__Qt__Box__Engine__"); testFont.setPixelSize(12); diff --git a/tests/auto/qtextlayout/qtextlayout.pro b/tests/auto/qtextlayout/qtextlayout.pro index 2da4d8a..381f09e 100644 --- a/tests/auto/qtextlayout/qtextlayout.pro +++ b/tests/auto/qtextlayout/qtextlayout.pro @@ -3,4 +3,7 @@ HEADERS += SOURCES += tst_qtextlayout.cpp INCLUDEPATH += $$QT_SOURCE_TREE/src/3rdparty/harfbuzz/src +symbian { + TARGET.EPOCHEAPSIZE = 100000 20000000 +} diff --git a/tests/auto/qtextlayout/tst_qtextlayout.cpp b/tests/auto/qtextlayout/tst_qtextlayout.cpp index 2e6b8e2..443eacc 100644 --- a/tests/auto/qtextlayout/tst_qtextlayout.cpp +++ b/tests/auto/qtextlayout/tst_qtextlayout.cpp @@ -57,8 +57,6 @@ #define TESTFONT_SIZE 12 - - //TESTED_CLASS= //TESTED_FILES= @@ -164,12 +162,12 @@ void tst_QTextLayout::getSetCheck() } QT_BEGIN_NAMESPACE -extern Q_GUI_EXPORT bool qt_enable_test_font; +extern void qt_setQtEnableTestFont(bool value); QT_END_NAMESPACE tst_QTextLayout::tst_QTextLayout() { - qt_enable_test_font = true; + qt_setQtEnableTestFont(true); } tst_QTextLayout::~tst_QTextLayout() diff --git a/tests/auto/qtextodfwriter/qtextodfwriter.pro b/tests/auto/qtextodfwriter/qtextodfwriter.pro index 3c40d67..f5e2c09 100644 --- a/tests/auto/qtextodfwriter/qtextodfwriter.pro +++ b/tests/auto/qtextodfwriter/qtextodfwriter.pro @@ -1,5 +1,5 @@ load(qttest_p4) SOURCES += tst_qtextodfwriter.cpp -DEFINES += SRCDIR=\\\"$$PWD\\\" - +!symbian:DEFINES += SRCDIR=\\\"$$PWD\\\" +symbian:INCLUDEPATH+=$$[QT_INSTALL_PREFIX]/include/QtGui/private diff --git a/tests/auto/qtextodfwriter/tst_qtextodfwriter.cpp b/tests/auto/qtextodfwriter/tst_qtextodfwriter.cpp index c7242ca..d674e70 100644 --- a/tests/auto/qtextodfwriter/tst_qtextodfwriter.cpp +++ b/tests/auto/qtextodfwriter/tst_qtextodfwriter.cpp @@ -47,6 +47,10 @@ #include <QBuffer> #include <QDebug> +#ifdef Q_OS_SYMBIAN +#define SRCDIR "." +#endif + #include <private/qtextodfwriter_p.h> class tst_QTextOdfWriter : public QObject diff --git a/tests/auto/qtextstream/test/test.pro b/tests/auto/qtextstream/test/test.pro index bae7717..9f117d5 100644 --- a/tests/auto/qtextstream/test/test.pro +++ b/tests/auto/qtextstream/test/test.pro @@ -17,15 +17,24 @@ contains(QT_CONFIG, qt3support):QT += qt3support QT = core network -wince*: { +wince*|symbian: { addFiles.sources = ../rfc3261.txt ../shift-jis.txt ../task113817.txt ../qtextstream.qrc ../tst_qtextstream.cpp addFiles.path = . res.sources = ../resources res.path = . DEPLOYMENT += addFiles - DEFINES += SRCDIR=\\\"\\\" -} else { - DEFINES += SRCDIR=\\\"$$PWD/../\\\" +} + +wince*: { + DEFINES += SRCDIR=\\\"\\\" +}else:symbian { + load(data_caging_paths) + # Symbian can't define SRCDIR meaningfully here + codecs_plugins.sources = qcncodecs.dll qjpcodecs.dll qtwcodecs.dll qkrcodecs.dll + codecs_plugins.path = $$QT_PLUGINS_BASE_DIR/codecs + DEPLOYMENT += codecs_plugins +}else { + DEFINES += SRCDIR=\\\"$$PWD/../\\\" } diff --git a/tests/auto/qtextstream/tst_qtextstream.cpp b/tests/auto/qtextstream/tst_qtextstream.cpp index 23bdd27..3c4820d 100644 --- a/tests/auto/qtextstream/tst_qtextstream.cpp +++ b/tests/auto/qtextstream/tst_qtextstream.cpp @@ -41,7 +41,7 @@ /*-*-encoding:latin1-*-*/ -#include <iostream> +//#include <iostream> //using namespace std; #include <QtTest/QtTest> @@ -76,6 +76,10 @@ QT_END_NAMESPACE //TESTED_CLASS= //TESTED_FILES= +#ifdef Q_OS_SYMBIAN +#define SRCDIR "" +#endif + class tst_QTextStream : public QObject { Q_OBJECT @@ -469,6 +473,8 @@ tst_QTextStream::tst_QTextStream() inBuffer = 0; inString = 0; file_is_empty = FALSE; + + Q_SET_DEFAULT_IAP } tst_QTextStream::~tst_QTextStream() @@ -1247,7 +1253,13 @@ void tst_QTextStream::stillOpenWhenAtEnd() #endif QTcpSocket socket; socket.connectToHost(QtNetworkSettings::serverName(), 143); +#if defined(Q_OS_SYMBIAN) + // This number is determined in an arbitrary way; whatever it takes + // to make the test pass. + QVERIFY(socket.waitForReadyRead(30000)); +#else QVERIFY(socket.waitForReadyRead(5000)); +#endif QTextStream stream2(&socket); while (!stream2.readLine().isNull()) {} @@ -1490,8 +1502,8 @@ void tst_QTextStream::pos2() // ------------------------------------------------------------------------------ void tst_QTextStream::readStdin() { -#ifdef Q_OS_WINCE - QSKIP("Qt/CE has no stdin/out", SkipAll); +#if defined(Q_OS_WINCE) || defined(Q_OS_SYMBIAN) + QSKIP("Qt/CE and Symbian have no stdin/out support for processes", SkipAll); #endif QProcess stdinProcess; stdinProcess.start("stdinProcess/stdinProcess"); @@ -1516,8 +1528,8 @@ void tst_QTextStream::readStdin() // ------------------------------------------------------------------------------ void tst_QTextStream::readAllFromStdin() { -#ifdef Q_OS_WINCE - QSKIP("Qt/CE has no stdin/out", SkipAll); +#if defined(Q_OS_WINCE) || defined(Q_OS_SYMBIAN) + QSKIP("Qt/CE and Symbian have no stdin/out support for processes", SkipAll); #endif QProcess stdinProcess; stdinProcess.start("readAllStdinProcess/readAllStdinProcess", QIODevice::ReadWrite | QIODevice::Text); @@ -1537,8 +1549,8 @@ void tst_QTextStream::readAllFromStdin() // ------------------------------------------------------------------------------ void tst_QTextStream::readLineFromStdin() { -#ifdef Q_OS_WINCE - QSKIP("Qt/CE has no stdin/out", SkipAll); +#if defined(Q_OS_WINCE) || defined(Q_OS_SYMBIAN) + QSKIP("Qt/CE and Symbian have no stdin/out support for processes", SkipAll); #endif QProcess stdinProcess; stdinProcess.start("readLineStdinProcess/readLineStdinProcess", QIODevice::ReadWrite | QIODevice::Text); @@ -4298,7 +4310,7 @@ void tst_QTextStream::int_write_with_locale() // like QTEST_APPLESS_MAIN, but initialising the locale on Unix int main(int argc, char *argv[]) { -#ifdef Q_OS_UNIX +#if defined (Q_OS_UNIX) && !defined (Q_OS_SYMBIAN) extern bool qt_locale_initialized; ::setlocale(LC_ALL, ""); qt_locale_initialized = true; diff --git a/tests/auto/qthread/qthread.pro b/tests/auto/qthread/qthread.pro index c4d4f2a..4ea8fe5 100644 --- a/tests/auto/qthread/qthread.pro +++ b/tests/auto/qthread/qthread.pro @@ -1,5 +1,4 @@ load(qttest_p4) SOURCES += tst_qthread.cpp QT = core - - +symbian*:LIBS += -llibpthread diff --git a/tests/auto/qthread/tst_qthread.cpp b/tests/auto/qthread/tst_qthread.cpp index c6a7a8b..796c7e7 100644 --- a/tests/auto/qthread/tst_qthread.cpp +++ b/tests/auto/qthread/tst_qthread.cpp @@ -892,7 +892,7 @@ void tst_QThread::stressTest() while (t.elapsed() < one_minute) { Current_Thread t; t.start(); - t.wait(); + t.wait(one_minute); } } diff --git a/tests/auto/qthreadstorage/qthreadstorage.pro b/tests/auto/qthreadstorage/qthreadstorage.pro index f4f5700..376ba65 100644 --- a/tests/auto/qthreadstorage/qthreadstorage.pro +++ b/tests/auto/qthreadstorage/qthreadstorage.pro @@ -1,5 +1,4 @@ load(qttest_p4) SOURCES += tst_qthreadstorage.cpp QT = core - - +symbian*:LIBS += -llibpthread diff --git a/tests/auto/qtime/qtime.pro b/tests/auto/qtime/qtime.pro index 93fc74c..88277a0 100644 --- a/tests/auto/qtime/qtime.pro +++ b/tests/auto/qtime/qtime.pro @@ -1,6 +1,3 @@ load(qttest_p4) - SOURCES += tst_qtime.cpp QT = core - - diff --git a/tests/auto/qtimeline/qtimeline.pro b/tests/auto/qtimeline/qtimeline.pro index 57d67a8..7820455 100644 --- a/tests/auto/qtimeline/qtimeline.pro +++ b/tests/auto/qtimeline/qtimeline.pro @@ -1,5 +1,4 @@ load(qttest_p4) QT = core SOURCES += tst_qtimeline.cpp - - +QT = core diff --git a/tests/auto/qtimer/qtimer.pro b/tests/auto/qtimer/qtimer.pro index a16035f..79ae7db 100644 --- a/tests/auto/qtimer/qtimer.pro +++ b/tests/auto/qtimer/qtimer.pro @@ -1,5 +1,4 @@ load(qttest_p4) QT = core SOURCES += tst_qtimer.cpp - - +QT = core diff --git a/tests/auto/qtimer/tst_qtimer.cpp b/tests/auto/qtimer/tst_qtimer.cpp index e3e28b5..24e617f 100644 --- a/tests/auto/qtimer/tst_qtimer.cpp +++ b/tests/auto/qtimer/tst_qtimer.cpp @@ -85,6 +85,8 @@ private slots: void deleteLaterOnQTimer(); // long name, don't want to shadow QObject::deleteLater() void moveToThread(); void restartedTimerFiresTooSoon(); + void timerFiresOnlyOncePerProcessEvents_data(); + void timerFiresOnlyOncePerProcessEvents(); }; class TimerHelper : public QObject @@ -159,6 +161,13 @@ void tst_QTimer::singleShotTimeout() QCOMPARE(helper.count, 1); } +#if defined(Q_OS_SYMBIAN) && defined(Q_CC_NOKIAX86) +// Increase wait as emulator startup can cause unexpected delays +#define TIMEOUT_TIMEOUT 2000 +#else +#define TIMEOUT_TIMEOUT 200 +#endif + void tst_QTimer::timeout() { TimerHelper helper; @@ -169,11 +178,11 @@ void tst_QTimer::timeout() QCOMPARE(helper.count, 0); - QTest::qWait(200); + QTest::qWait(TIMEOUT_TIMEOUT); QVERIFY(helper.count > 0); int oldCount = helper.count; - QTest::qWait(200); + QTest::qWait(TIMEOUT_TIMEOUT); QVERIFY(helper.count > oldCount); } @@ -263,7 +272,7 @@ void tst_QTimer::livelock() #if defined(Q_OS_MAC) QEXPECT_FAIL("zero timer", "Posted events source are handled AFTER timers", Continue); QEXPECT_FAIL("non-zero timer", "Posted events source are handled AFTER timers", Continue); -#elif defined(Q_OS_UNIX) +#elif defined(Q_OS_UNIX) && !defined(Q_OS_SYMBIAN) QEXPECT_FAIL("zero timer", "", Continue); QEXPECT_FAIL("non-zero timer", "", Continue); #elif defined(Q_OS_WIN) @@ -404,29 +413,38 @@ void tst_QTimer::deleteLaterOnQTimer() QVERIFY(pointer.isNull()); } +#if defined(Q_OS_SYMBIAN) && defined(Q_CC_NOKIAX86) +// Increase wait as emulator startup can cause unexpected delays +#define MOVETOTHREAD_TIMEOUT 200 +#define MOVETOTHREAD_WAIT 5000 +#else +#define MOVETOTHREAD_TIMEOUT 200 +#define MOVETOTHREAD_WAIT 300 +#endif + void tst_QTimer::moveToThread() { QTimer ti1; QTimer ti2; - ti1.start(200); - ti2.start(200); + ti1.start(MOVETOTHREAD_TIMEOUT); + ti2.start(MOVETOTHREAD_TIMEOUT); QVERIFY((ti1.timerId() & 0xffffff) != (ti2.timerId() & 0xffffff)); QThread tr; ti1.moveToThread(&tr); connect(&ti1,SIGNAL(timeout()), &tr, SLOT(quit())); tr.start(); QTimer ti3; - ti3.start(200); + ti3.start(MOVETOTHREAD_TIMEOUT); QVERIFY((ti3.timerId() & 0xffffff) != (ti2.timerId() & 0xffffff)); QVERIFY((ti3.timerId() & 0xffffff) != (ti1.timerId() & 0xffffff)); - QTest::qWait(300); + QTest::qWait(MOVETOTHREAD_WAIT); QVERIFY(tr.wait()); ti2.stop(); QTimer ti4; - ti4.start(200); + ti4.start(MOVETOTHREAD_TIMEOUT); ti3.stop(); - ti2.start(200); - ti3.start(200); + ti2.start(MOVETOTHREAD_TIMEOUT); + ti3.start(MOVETOTHREAD_TIMEOUT); QVERIFY((ti4.timerId() & 0xffffff) != (ti2.timerId() & 0xffffff)); QVERIFY((ti3.timerId() & 0xffffff) != (ti2.timerId() & 0xffffff)); QVERIFY((ti3.timerId() & 0xffffff) != (ti1.timerId() & 0xffffff)); @@ -495,5 +513,54 @@ void tst_QTimer::restartedTimerFiresTooSoon() QVERIFY(object.eventLoop.exec() == 0); } +class LongLastingSlotClass : public QObject +{ + Q_OBJECT + +public: + LongLastingSlotClass(QTimer *timer) : count(0), timer(timer) {} + +public slots: + void longLastingSlot() + { + // Don't use timers for this, because we are testing them. + QTime time; + time.start(); + while (time.elapsed() < 200) { + for (int c = 0; c < 100000; c++) {} // Mindless looping. + } + if (++count >= 2) { + timer->stop(); + } + } + +public: + int count; + QTimer *timer; +}; + +void tst_QTimer::timerFiresOnlyOncePerProcessEvents_data() +{ + QTest::addColumn<int>("interval"); + QTest::newRow("zero timer") << 0; + QTest::newRow("non-zero timer") << 10; +} + +void tst_QTimer::timerFiresOnlyOncePerProcessEvents() +{ + QFETCH(int, interval); + + QTimer t; + LongLastingSlotClass longSlot(&t); + t.start(interval); + connect(&t, SIGNAL(timeout()), &longSlot, SLOT(longLastingSlot())); + // Loop because there may be other events pending. + while (longSlot.count == 0) { + QCoreApplication::processEvents(QEventLoop::WaitForMoreEvents); + } + + QCOMPARE(longSlot.count, 1); +} + QTEST_MAIN(tst_QTimer) #include "tst_qtimer.moc" diff --git a/tests/auto/qtransform/qtransform.pro b/tests/auto/qtransform/qtransform.pro index 7cba3db..298feb2 100644 --- a/tests/auto/qtransform/qtransform.pro +++ b/tests/auto/qtransform/qtransform.pro @@ -2,6 +2,6 @@ load(qttest_p4) HEADERS += SOURCES += tst_qtransform.cpp -unix:!mac:LIBS+=-lm +unix:!mac:!symbian*:LIBS+=-lm diff --git a/tests/auto/qtransformedscreen/qtransformedscreen.pro b/tests/auto/qtransformedscreen/qtransformedscreen.pro index 6914054..39e3700 100644 --- a/tests/auto/qtransformedscreen/qtransformedscreen.pro +++ b/tests/auto/qtransformedscreen/qtransformedscreen.pro @@ -1,5 +1,6 @@ load(qttest_p4) SOURCES += tst_qtransformedscreen.cpp +QT = core embedded:!contains(gfx-drivers, transformed) { LIBS += ../../../plugins/gfxdrivers/libqgfxtransformed.so diff --git a/tests/auto/qtranslator/qtranslator.pro b/tests/auto/qtranslator/qtranslator.pro index 0d67f70..30ffc1c 100644 --- a/tests/auto/qtranslator/qtranslator.pro +++ b/tests/auto/qtranslator/qtranslator.pro @@ -2,7 +2,7 @@ load(qttest_p4) SOURCES += tst_qtranslator.cpp -wince*: { +wince*|symbian*: { addFiles.sources = hellotr_la.qm msgfmt_from_po.qm addFiles.path = . DEPLOYMENT += addFiles diff --git a/tests/auto/qtreeview/tst_qtreeview.cpp b/tests/auto/qtreeview/tst_qtreeview.cpp index 123ce60..d28c3c3 100644 --- a/tests/auto/qtreeview/tst_qtreeview.cpp +++ b/tests/auto/qtreeview/tst_qtreeview.cpp @@ -51,7 +51,9 @@ //TESTED_FILES= Q_DECLARE_METATYPE(QModelIndex) +#ifndef QT_NO_DRAGANDDROP Q_DECLARE_METATYPE(QAbstractItemView::DragDropMode) +#endif Q_DECLARE_METATYPE(QAbstractItemView::EditTriggers) Q_DECLARE_METATYPE(QAbstractItemView::EditTrigger) @@ -137,11 +139,13 @@ private slots: void alternatingRowColors(); void currentIndex_data(); void currentIndex(); +#ifndef QT_NO_DRAGANDDROP void dragDropMode_data(); void dragDropMode(); void dragDropModeFromDragEnabledAndAcceptDrops_data(); void dragDropModeFromDragEnabledAndAcceptDrops(); void dragDropOverwriteMode(); +#endif void editTriggers_data(); void editTriggers(); void hasAutoScroll(); @@ -468,9 +472,11 @@ void tst_QTreeView::construction() // QAbstractItemView properties QVERIFY(!view.alternatingRowColors()); QCOMPARE(view.currentIndex(), QModelIndex()); +#ifndef QT_NO_DRAGANDDROP QCOMPARE(view.dragDropMode(), QAbstractItemView::NoDragDrop); QVERIFY(!view.dragDropOverwriteMode()); QVERIFY(!view.dragEnabled()); +#endif QCOMPARE(view.editTriggers(), QAbstractItemView::EditKeyPressed | QAbstractItemView::DoubleClicked); QVERIFY(view.hasAutoScroll()); QCOMPARE(view.horizontalScrollMode(), QAbstractItemView::ScrollPerPixel); @@ -489,7 +495,9 @@ void tst_QTreeView::construction() QCOMPARE(view.selectionBehavior(), QAbstractItemView::SelectRows); QCOMPARE(view.selectionMode(), QAbstractItemView::SingleSelection); QVERIFY(!view.selectionModel()); +#ifndef QT_NO_DRAGANDDROP QVERIFY(view.showDropIndicator()); +#endif QCOMPARE(view.QAbstractItemView::sizeHintForColumn(-1), -1); // <- protected in QTreeView QCOMPARE(view.QAbstractItemView::sizeHintForColumn(0), -1); // <- protected in QTreeView QCOMPARE(view.QAbstractItemView::sizeHintForColumn(1), -1); // <- protected in QTreeView @@ -596,12 +604,13 @@ void tst_QTreeView::currentIndex() // ### Test child and grandChild indexes. } +#ifndef QT_NO_DRAGANDDROP + void tst_QTreeView::dragDropMode_data() { QTest::addColumn<QAbstractItemView::DragDropMode>("dragDropMode"); QTest::addColumn<bool>("acceptDrops"); QTest::addColumn<bool>("dragEnabled"); - QTest::newRow("NoDragDrop") << QAbstractItemView::NoDragDrop << false << false; QTest::newRow("DragOnly") << QAbstractItemView::DragOnly << false << true; QTest::newRow("DropOnly") << QAbstractItemView::DropOnly << true << false; @@ -696,6 +705,7 @@ void tst_QTreeView::dragDropOverwriteMode() // QTableWidget, from their reimplementations of dropMimeData(). Hard to // test. } +#endif void tst_QTreeView::editTriggers_data() { diff --git a/tests/auto/qtreewidgetitemiterator/tst_qtreewidgetitemiterator.cpp b/tests/auto/qtreewidgetitemiterator/tst_qtreewidgetitemiterator.cpp index 626751d..47896f6 100644 --- a/tests/auto/qtreewidgetitemiterator/tst_qtreewidgetitemiterator.cpp +++ b/tests/auto/qtreewidgetitemiterator/tst_qtreewidgetitemiterator.cpp @@ -925,7 +925,7 @@ void tst_QTreeWidgetItemIterator::iteratorflags() QFETCH(int, iteratorflags); QFETCH(QStringList, matches); - QTreeWidgetItemIterator it(testWidget, (QTreeWidgetItemIterator::IteratorFlags)iteratorflags); + QTreeWidgetItemIterator it(testWidget, QTreeWidgetItemIterator::IteratorFlags(iteratorflags)); it+=start; int iMatch = 0; while (*it && iMatch < matches.count()) { @@ -1000,7 +1000,7 @@ void tst_QTreeWidgetItemIterator::plus_eq() QFETCH(int, iteratorflags); QFETCH(QString, expecteditem); - QTreeWidgetItemIterator it(testWidget, (QTreeWidgetItemIterator::IteratorFlags)iteratorflags); + QTreeWidgetItemIterator it(testWidget, QTreeWidgetItemIterator::IteratorFlags(iteratorflags)); it+=start; it+=addition; QTreeWidgetItem *item = *it; @@ -1033,7 +1033,7 @@ void tst_QTreeWidgetItemIterator::minus_eq() QFETCH(int, iteratorflags); QFETCH(QString, expecteditem); - QTreeWidgetItemIterator it(testWidget, (QTreeWidgetItemIterator::IteratorFlags)iteratorflags); + QTreeWidgetItemIterator it(testWidget, QTreeWidgetItemIterator::IteratorFlags(iteratorflags)); it+=start; it-=subtraction; QTreeWidgetItem *item = *it; @@ -1112,10 +1112,10 @@ void tst_QTreeWidgetItemIterator::updateIfModifiedFromWidget() } } - QTreeWidgetItemIterator it(&tw, (QTreeWidgetItemIterator::IteratorFlags)iteratorflags); + QTreeWidgetItemIterator it(&tw, QTreeWidgetItemIterator::IteratorFlags(iteratorflags)); it+=expecteditemindex; QTreeWidgetItem *item = 0; - QTreeWidgetItemIterator itRemove(&tw, (QTreeWidgetItemIterator::IteratorFlags)iteratorflags); + QTreeWidgetItemIterator itRemove(&tw, QTreeWidgetItemIterator::IteratorFlags(iteratorflags)); itRemove+=removeindex; item = *itRemove; QVERIFY(item); diff --git a/tests/auto/qtwidgets/qtwidgets.pro b/tests/auto/qtwidgets/qtwidgets.pro index ad5e7ac..b762acb 100644 --- a/tests/auto/qtwidgets/qtwidgets.pro +++ b/tests/auto/qtwidgets/qtwidgets.pro @@ -1,4 +1,5 @@ load(qttest_p4) +symbian*:TARGET.EPOCHEAPSIZE=0x200000 0xa00000 SOURCES += tst_qtwidgets.cpp mainwindow.cpp HEADERS += mainwindow.h diff --git a/tests/auto/qtwidgets/tst_qtwidgets.cpp b/tests/auto/qtwidgets/tst_qtwidgets.cpp index 22240d3..9473648 100644 --- a/tests/auto/qtwidgets/tst_qtwidgets.cpp +++ b/tests/auto/qtwidgets/tst_qtwidgets.cpp @@ -47,15 +47,28 @@ #include "mainwindow.h" +#include "../network-settings.h" class tst_QtWidgets: public QObject { Q_OBJECT +public: + tst_QtWidgets(); + virtual ~tst_QtWidgets(); + private slots: void snapshot(); }; +tst_QtWidgets::tst_QtWidgets() +{ + Q_SET_DEFAULT_IAP +} + +tst_QtWidgets::~tst_QtWidgets() +{ +} void tst_QtWidgets::snapshot() { @@ -73,9 +86,9 @@ void tst_QtWidgets::snapshot() QString filename = "qtwidgets_" + QHostInfo::localHostName() + "_" + QDateTime::currentDateTime().toString("yyyy.MM.dd_hh.mm.ss") + ".png"; QFtp ftp; - ftp.connectToHost("kramer.troll.no"); - ftp.login("anonymous"); - ftp.cd("pics"); + ftp.connectToHost("qt-test-server.qt-test-net"); + ftp.login("ftptest", "password"); + ftp.cd("qtest/pics"); ftp.put(buf.data(), filename, QFtp::Binary); ftp.close(); diff --git a/tests/auto/qudpsocket/test/test.pro b/tests/auto/qudpsocket/test/test.pro index 2444dac..2e0a020 100644 --- a/tests/auto/qudpsocket/test/test.pro +++ b/tests/auto/qudpsocket/test/test.pro @@ -15,7 +15,7 @@ win32 { DESTDIR = ../ } -wince*: { +wince*|symbian*: { addApp.sources = ../clientserver/clientserver.exe addApp.path = clientserver DEPLOYMENT += addApp diff --git a/tests/auto/qudpsocket/tst_qudpsocket.cpp b/tests/auto/qudpsocket/tst_qudpsocket.cpp index 39b2845..8d09924 100644 --- a/tests/auto/qudpsocket/tst_qudpsocket.cpp +++ b/tests/auto/qudpsocket/tst_qudpsocket.cpp @@ -105,11 +105,11 @@ protected slots: tst_QUdpSocket::tst_QUdpSocket() { + Q_SET_DEFAULT_IAP } tst_QUdpSocket::~tst_QUdpSocket() { - } void tst_QUdpSocket::initTestCase_data() @@ -207,7 +207,7 @@ void tst_QUdpSocket::broadcasting() #ifdef TEST_QNETWORK_PROXY QFETCH_GLOBAL(int, proxyType); if (proxyType == QNetworkProxy::Socks5Proxy) { - QSKIP("With socks5 Broadcast is not supported.", SkipAll); + QSKIP("With socks5 Broadcast is not supported.", SkipSingle); } #endif } @@ -320,6 +320,9 @@ void tst_QUdpSocket::ipv6Loop_data() void tst_QUdpSocket::ipv6Loop() { +#if defined(Q_OS_SYMBIAN) + QSKIP("Symbian IPv6 is not yet supported", SkipAll); +#endif QFETCH(QByteArray, peterMessage); QFETCH(QByteArray, paulMessage); QFETCH(bool, success); @@ -331,17 +334,17 @@ void tst_QUdpSocket::ipv6Loop() quint16 paulPort = 28123; if (!peter.bind(QHostAddress::LocalHostIPv6, peterPort)) { - QCOMPARE(peter.error(), QUdpSocket::UnsupportedSocketOperationError); + QCOMPARE(peter.error(), QUdpSocket::UnsupportedSocketOperationError); } else { - QVERIFY(paul.bind(QHostAddress::LocalHostIPv6, paulPort)); + QVERIFY(paul.bind(QHostAddress::LocalHostIPv6, paulPort)); - QCOMPARE(peter.writeDatagram(peterMessage.data(), peterMessage.length(), QHostAddress("::1"), + QCOMPARE(peter.writeDatagram(peterMessage.data(), peterMessage.length(), QHostAddress("::1"), paulPort), qint64(peterMessage.length())); - QCOMPARE(paul.writeDatagram(paulMessage.data(), paulMessage.length(), + QCOMPARE(paul.writeDatagram(paulMessage.data(), paulMessage.length(), QHostAddress("::1"), peterPort), qint64(paulMessage.length())); - char peterBuffer[16*1024]; - char paulBuffer[16*1024]; + char peterBuffer[16*1024]; + char paulBuffer[16*1024]; #if !defined(Q_OS_WINCE) QVERIFY(peter.waitForReadyRead(5000)); QVERIFY(paul.waitForReadyRead(5000)); @@ -349,16 +352,16 @@ void tst_QUdpSocket::ipv6Loop() QVERIFY(peter.waitForReadyRead(15000)); QVERIFY(paul.waitForReadyRead(15000)); #endif - if (success) { - QCOMPARE(peter.readDatagram(peterBuffer, sizeof(peterBuffer)), qint64(paulMessage.length())); - QCOMPARE(paul.readDatagram(paulBuffer, sizeof(peterBuffer)), qint64(peterMessage.length())); - } else { - QVERIFY(peter.readDatagram(peterBuffer, sizeof(peterBuffer)) != paulMessage.length()); - QVERIFY(paul.readDatagram(paulBuffer, sizeof(peterBuffer)) != peterMessage.length()); - } - - QCOMPARE(QByteArray(peterBuffer, paulMessage.length()), paulMessage); - QCOMPARE(QByteArray(paulBuffer, peterMessage.length()), peterMessage); + if (success) { + QCOMPARE(peter.readDatagram(peterBuffer, sizeof(peterBuffer)), qint64(paulMessage.length())); + QCOMPARE(paul.readDatagram(paulBuffer, sizeof(peterBuffer)), qint64(peterMessage.length())); + } else { + QVERIFY(peter.readDatagram(peterBuffer, sizeof(peterBuffer)) != paulMessage.length()); + QVERIFY(paul.readDatagram(paulBuffer, sizeof(peterBuffer)) != peterMessage.length()); + } + + QCOMPARE(QByteArray(peterBuffer, paulMessage.length()), paulMessage); + QCOMPARE(QByteArray(paulBuffer, peterMessage.length()), peterMessage); } } @@ -479,6 +482,22 @@ void tst_QUdpSocket::writeDatagram() void tst_QUdpSocket::performance() { +#if defined(Q_OS_SYMBIAN) + // Large packets seems not to go through on Symbian + // Reason might be also fragmentation due to VPN connection etc + + QFETCH_GLOBAL(bool, setProxy); + QFETCH_GLOBAL(int, proxyType); + + int arrSize = 8192; + if (setProxy && proxyType == QNetworkProxy::Socks5Proxy) + arrSize = 1024; + + QByteArray arr(arrSize, '@'); +#else + QByteArray arr(8192, '@'); +#endif // Q_OS_SYMBIAN + QUdpSocket server; QVERIFY2(server.bind(), server.errorString().toLatin1().constData()); @@ -489,8 +508,6 @@ void tst_QUdpSocket::performance() QUdpSocket client; client.connectToHost(serverAddress, server.localPort()); - QByteArray arr(8192, '@'); - QTime stopWatch; stopWatch.start(); @@ -508,6 +525,14 @@ void tst_QUdpSocket::performance() float secs = stopWatch.elapsed() / 1000.0; qDebug("\t%.2fMB/%.2fs: %.2fMB/s", float(nbytes / (1024.0*1024.0)), secs, float(nbytes / (1024.0*1024.0)) / secs); + +#if defined(Q_OS_SYMBIAN) + if(nbytes == 0) { + qDebug("No bytes passed through local UDP socket, since UDP socket write returns EWOULDBLOCK"); + qDebug("Should try with blocking sockets, but it is not currently possible due to Open C defect"); + } +#endif + } void tst_QUdpSocket::bindMode() @@ -526,8 +551,47 @@ void tst_QUdpSocket::bindMode() QVERIFY2(socket.bind(), socket.errorString().toLatin1().constData()); QUdpSocket socket2; QVERIFY(!socket2.bind(socket.localPort())); - -#ifdef Q_OS_UNIX +#if defined(Q_OS_SYMBIAN) + if(RProcess().HasCapability(ECapabilityNetworkControl)) { + qDebug("Test executed *with* NetworkControl capability"); + // In Symbian OS ReuseAddressHint together with NetworkControl capability + // gives application *always* right to bind to port. I.e. it does not matter + // if first socket was bound with any bind flag. Since autotests in Symbian + // are currently executed with ALL -TCB rights, this path is the one executed. + QVERIFY(socket2.bind(socket.localPort(), QUdpSocket::ReuseAddressHint)); + socket.close(); + socket2.close(); + + QVERIFY2(socket.bind(0, QUdpSocket::ShareAddress), socket.errorString().toLatin1().constData()); + QVERIFY(!socket2.bind(socket.localPort())); + QVERIFY2(socket2.bind(socket.localPort(), QUdpSocket::ReuseAddressHint), socket2.errorString().toLatin1().constData()); + socket.close(); + socket2.close(); + + QVERIFY2(socket.bind(0, QUdpSocket::DontShareAddress), socket.errorString().toLatin1().constData()); + QVERIFY(!socket2.bind(socket.localPort())); + QVERIFY(socket2.bind(socket.localPort(), QUdpSocket::ReuseAddressHint)); + socket.close(); + socket2.close(); + } else { + qDebug("Test executed *without* NetworkControl capability"); + // If we don't have NetworkControl capability, attempt to bind already bound + // address will *always* fail. I.e. it does not matter if first socket was + // bound with any bind flag. + QVERIFY(!socket2.bind(socket.localPort(), QUdpSocket::ReuseAddressHint)); + socket.close(); + + QVERIFY2(socket.bind(0, QUdpSocket::ShareAddress), socket.errorString().toLatin1().constData()); + QVERIFY(!socket2.bind(socket.localPort())); + QVERIFY2(!socket2.bind(socket.localPort(), QUdpSocket::ReuseAddressHint), socket2.errorString().toLatin1().constData()); + socket.close(); + + QVERIFY2(socket.bind(0, QUdpSocket::DontShareAddress), socket.errorString().toLatin1().constData()); + QVERIFY(!socket2.bind(socket.localPort())); + QVERIFY(!socket2.bind(socket.localPort(), QUdpSocket::ReuseAddressHint)); + socket.close(); + } +#elif defined(Q_OS_UNIX) QVERIFY(!socket2.bind(socket.localPort(), QUdpSocket::ReuseAddressHint)); socket.close(); QVERIFY2(socket.bind(0, QUdpSocket::ShareAddress), socket.errorString().toLatin1().constData()); @@ -535,6 +599,7 @@ void tst_QUdpSocket::bindMode() socket2.close(); QVERIFY2(socket2.bind(socket.localPort(), QUdpSocket::ReuseAddressHint), socket2.errorString().toLatin1().constData()); #else + // Depending on the user's privileges, this or will succeed or // fail. Admins are allowed to reuse the address, but nobody else. if (!socket2.bind(socket.localPort(), QUdpSocket::ReuseAddressHint), socket2.errorString().toLatin1().constData()) @@ -554,13 +619,16 @@ void tst_QUdpSocket::writeDatagramToNonExistingPeer_data() QTest::addColumn<bool>("bind"); QTest::addColumn<QHostAddress>("peerAddress"); QHostAddress localhost(QHostAddress::LocalHost); +#if !defined(Q_OS_SYMBIAN) QHostAddress remote = QHostInfo::fromName(QtNetworkSettings::serverName()).addresses().first(); +#endif QTest::newRow("localhost-unbound") << false << localhost; QTest::newRow("localhost-bound") << true << localhost; - +#if !defined(Q_OS_SYMBIAN) QTest::newRow("remote-unbound") << false << remote; QTest::newRow("remote-bound") << true << remote; +#endif } void tst_QUdpSocket::writeDatagramToNonExistingPeer() @@ -583,11 +651,14 @@ void tst_QUdpSocket::writeToNonExistingPeer_data() { QTest::addColumn<QHostAddress>("peerAddress"); QHostAddress localhost(QHostAddress::LocalHost); +#if !defined(Q_OS_SYMBIAN) QHostAddress remote = QHostInfo::fromName(QtNetworkSettings::serverName()).addresses().first(); - +#endif // write (required to be connected) QTest::newRow("localhost") << localhost; +#if !defined(Q_OS_SYMBIAN) QTest::newRow("remote") << remote; +#endif } void tst_QUdpSocket::writeToNonExistingPeer() @@ -638,8 +709,8 @@ void tst_QUdpSocket::writeToNonExistingPeer() void tst_QUdpSocket::outOfProcessConnectedClientServerTest() { -#if defined(Q_OS_WINCE) - QSKIP("This test depends on reading data from QProcess (not supported on Qt/WinCE.", SkipAll); +#if defined(Q_OS_WINCE) || defined (Q_OS_SYMBIAN) + QSKIP("This test depends on reading data from QProcess (not supported on Qt/WinCE and Symbian).", SkipAll); #endif #if defined(QT_NO_PROCESS) QSKIP("Qt was compiled with QT_NO_PROCESS", SkipAll); @@ -698,8 +769,8 @@ void tst_QUdpSocket::outOfProcessConnectedClientServerTest() void tst_QUdpSocket::outOfProcessUnconnectedClientServerTest() { -#if defined(Q_OS_WINCE) - QSKIP("This test depends on reading data from QProcess (not supported on Qt/WinCE.", SkipAll); +#if defined(Q_OS_WINCE) || defined (Q_OS_SYMBIAN) + QSKIP("This test depends on reading data from QProcess (not supported on Qt/WinCE and Symbian).", SkipAll); #endif #if defined(QT_NO_PROCESS) QSKIP("Qt was compiled with QT_NO_PROCESS", SkipAll); diff --git a/tests/auto/qudpsocket/udpServer/udpServer.pro b/tests/auto/qudpsocket/udpServer/udpServer.pro index f04833c..7438d40 100644 --- a/tests/auto/qudpsocket/udpServer/udpServer.pro +++ b/tests/auto/qudpsocket/udpServer/udpServer.pro @@ -3,4 +3,5 @@ QT = core network CONFIG -= app_bundle CONFIG += console +symbian:TARGET.CAPABILITY="ALL -TCB" diff --git a/tests/auto/qurl/qurl.pro b/tests/auto/qurl/qurl.pro index c3b1543..72c93bc 100644 --- a/tests/auto/qurl/qurl.pro +++ b/tests/auto/qurl/qurl.pro @@ -1,6 +1,3 @@ load(qttest_p4) SOURCES += tst_qurl.cpp - -QT -= gui - - +QT = core diff --git a/tests/auto/quuid/quuid.pro b/tests/auto/quuid/quuid.pro index 6f3f9f2..f7608fa 100644 --- a/tests/auto/quuid/quuid.pro +++ b/tests/auto/quuid/quuid.pro @@ -1,6 +1,3 @@ load(qttest_p4) QT = core SOURCES += tst_quuid.cpp - - - diff --git a/tests/auto/qvariant/qvariant.pro b/tests/auto/qvariant/qvariant.pro index 747b6c3..2c9c8d7 100644 --- a/tests/auto/qvariant/qvariant.pro +++ b/tests/auto/qvariant/qvariant.pro @@ -1,6 +1,5 @@ load(qttest_p4) SOURCES += tst_qvariant.cpp - QT += network contains(QT_CONFIG, qt3support): QT += qt3support diff --git a/tests/auto/qvariant/tst_qvariant.cpp b/tests/auto/qvariant/tst_qvariant.cpp index 709cba9..fc977bc 100644 --- a/tests/auto/qvariant/tst_qvariant.cpp +++ b/tests/auto/qvariant/tst_qvariant.cpp @@ -266,6 +266,7 @@ private slots: void convertByteArrayToBool() const; void convertByteArrayToBool_data() const; void toIntFromQString() const; + void toIntFromDouble() const; void task256984_setValue(); void numericalConvert(); @@ -2622,7 +2623,7 @@ void tst_QVariant::qvariant_cast_QObject_data() { QTest::addColumn<QVariant>("data"); QTest::addColumn<bool>("success"); - QTest::newRow("from QObject") << QVariant(QMetaType::QObjectStar, new QObject) << true; + QTest::newRow("from QObject") << QVariant(QMetaType::QObjectStar, new QObject(this)) << true; QTest::newRow("from String") << QVariant(QLatin1String("1, 2, 3")) << false; QTest::newRow("from int") << QVariant((int) 123) << false; } @@ -2747,6 +2748,7 @@ void tst_QVariant::dataStar() const v2 = qVariantFromValue(p1); QVERIFY(v1 == v2); + delete p1; } void tst_QVariant::canConvertQStringList() const @@ -3052,6 +3054,31 @@ void tst_QVariant::toIntFromQString() const QVERIFY(ok); } +/*! + We verify that: + 1. Conversion from (64 bit) double to int works (no overflow). + 2. Same conversion works for QVariant::convert. + + Rationale: if 2147483630 is set in float and then converted to int, + there will be overflow and the result will be -2147483648. + + See task 250267. + */ +void tst_QVariant::toIntFromDouble() const +{ + double d = 2147483630; // max int 2147483647 + QVERIFY((int)d == 2147483630); + + QVariant var(d); + QVERIFY( var.canConvert( QVariant::Int ) ); + + bool ok; + int result = var.toInt(&ok); + + QVERIFY( ok == true ); + QCOMPARE(result, 2147483630); +} + void tst_QVariant::task256984_setValue() { QTransform t; //we just take a value so that we're sure that it will be shared diff --git a/tests/auto/qvarlengtharray/qvarlengtharray.pro b/tests/auto/qvarlengtharray/qvarlengtharray.pro index 20bf7b7..7a02790 100644 --- a/tests/auto/qvarlengtharray/qvarlengtharray.pro +++ b/tests/auto/qvarlengtharray/qvarlengtharray.pro @@ -1,5 +1,4 @@ load(qttest_p4) QT = core SOURCES += tst_qvarlengtharray.cpp - - +QT = core diff --git a/tests/auto/qvector/qvector.pro b/tests/auto/qvector/qvector.pro index df3ee2d..80311b4 100644 --- a/tests/auto/qvector/qvector.pro +++ b/tests/auto/qvector/qvector.pro @@ -1,5 +1,3 @@ load(qttest_p4) SOURCES += tst_qvector.cpp - - - +QT = core diff --git a/tests/auto/qvideoframe/qvideoframe.pro b/tests/auto/qvideoframe/qvideoframe.pro new file mode 100644 index 0000000..a735352 --- /dev/null +++ b/tests/auto/qvideoframe/qvideoframe.pro @@ -0,0 +1,5 @@ +load(qttest_p4) +SOURCES += tst_qvideoframe.cpp + +QT += multimedia +requires(contains(QT_CONFIG, multimedia)) diff --git a/tests/auto/qvideoframe/tst_qvideoframe.cpp b/tests/auto/qvideoframe/tst_qvideoframe.cpp new file mode 100644 index 0000000..4fa89ee --- /dev/null +++ b/tests/auto/qvideoframe/tst_qvideoframe.cpp @@ -0,0 +1,663 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, 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. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QtTest/QtTest> + +#include <QtMultimedia/QVideoFrame> +#include <QtGui/QImage> +#include <QtCore/QPointer> + +class tst_QVideoFrame : public QObject +{ + Q_OBJECT +public: + tst_QVideoFrame(); + ~tst_QVideoFrame(); + +public slots: + void initTestCase(); + void cleanupTestCase(); + void init(); + void cleanup(); + +private slots: + void create_data(); + void create(); + void createInvalid_data(); + void createInvalid(); + void createFromBuffer_data(); + void createFromBuffer(); + void createFromImage_data(); + void createFromImage(); + void createFromIncompatibleImage(); + void createNull(); + void destructor(); + void copy_data(); + void copy(); + void assign_data(); + void assign(); + void map_data(); + void map(); + void mapImage_data(); + void mapImage(); + void imageDetach(); +}; + +Q_DECLARE_METATYPE(QImage::Format) +Q_DECLARE_METATYPE(QVideoFrame) + +class QtTestVideoBuffer : public QObject, public QAbstractVideoBuffer +{ + Q_OBJECT +public: + QtTestVideoBuffer() + : QAbstractVideoBuffer(NoHandle) {} + explicit QtTestVideoBuffer(QAbstractVideoBuffer::HandleType type) + : QAbstractVideoBuffer(type) {} + + MapMode mapMode() const { return NotMapped; } + + uchar *map(MapMode, int *, int *) { return 0; } + void unmap() {} +}; + +tst_QVideoFrame::tst_QVideoFrame() +{ +} + +tst_QVideoFrame::~tst_QVideoFrame() +{ +} + +void tst_QVideoFrame::initTestCase() +{ +} + +void tst_QVideoFrame::cleanupTestCase() +{ +} + +void tst_QVideoFrame::init() +{ +} + +void tst_QVideoFrame::cleanup() +{ +} + +void tst_QVideoFrame::create_data() +{ + QTest::addColumn<QSize>("size"); + QTest::addColumn<QVideoFrame::PixelFormat>("pixelFormat"); + QTest::addColumn<int>("bytes"); + QTest::addColumn<int>("bytesPerLine"); + + QTest::newRow("64x64 ARGB32") + << QSize(64, 64) + << QVideoFrame::Format_ARGB32 + << 16384 + << 256; + QTest::newRow("32x256 YUV420P") + << QSize(32, 256) + << QVideoFrame::Format_YUV420P + << 13288 + << 32; +} + +void tst_QVideoFrame::create() +{ + QFETCH(QSize, size); + QFETCH(QVideoFrame::PixelFormat, pixelFormat); + QFETCH(int, bytes); + QFETCH(int, bytesPerLine); + + QVideoFrame frame(bytes, size, bytesPerLine, pixelFormat); + + QVERIFY(frame.isValid()); + QCOMPARE(frame.handleType(), QAbstractVideoBuffer::NoHandle); + QCOMPARE(frame.pixelFormat(), pixelFormat); + QCOMPARE(frame.size(), size); + QCOMPARE(frame.width(), size.width()); + QCOMPARE(frame.height(), size.height()); + QCOMPARE(frame.fieldType(), QVideoFrame::ProgressiveFrame); + QCOMPARE(frame.startTime(), qint64(-1)); + QCOMPARE(frame.endTime(), qint64(-1)); +} + +void tst_QVideoFrame::createInvalid_data() +{ + QTest::addColumn<QSize>("size"); + QTest::addColumn<QVideoFrame::PixelFormat>("pixelFormat"); + QTest::addColumn<int>("bytes"); + QTest::addColumn<int>("bytesPerLine"); + + QTest::newRow("64x64 ARGB32 0 size") + << QSize(64, 64) + << QVideoFrame::Format_ARGB32 + << 0 + << 45; + QTest::newRow("32x256 YUV420P negative size") + << QSize(32, 256) + << QVideoFrame::Format_YUV420P + << -13288 + << 32; +} + +void tst_QVideoFrame::createInvalid() +{ + QFETCH(QSize, size); + QFETCH(QVideoFrame::PixelFormat, pixelFormat); + QFETCH(int, bytes); + QFETCH(int, bytesPerLine); + + QVideoFrame frame(bytes, size, bytesPerLine, pixelFormat); + + QVERIFY(!frame.isValid()); + QCOMPARE(frame.handleType(), QAbstractVideoBuffer::NoHandle); + QCOMPARE(frame.pixelFormat(), pixelFormat); + QCOMPARE(frame.size(), size); + QCOMPARE(frame.width(), size.width()); + QCOMPARE(frame.height(), size.height()); + QCOMPARE(frame.fieldType(), QVideoFrame::ProgressiveFrame); + QCOMPARE(frame.startTime(), qint64(-1)); + QCOMPARE(frame.endTime(), qint64(-1)); +} + +void tst_QVideoFrame::createFromBuffer_data() +{ + QTest::addColumn<QAbstractVideoBuffer::HandleType>("handleType"); + QTest::addColumn<QSize>("size"); + QTest::addColumn<QVideoFrame::PixelFormat>("pixelFormat"); + + QTest::newRow("64x64 ARGB32 no handle") + << QAbstractVideoBuffer::NoHandle + << QSize(64, 64) + << QVideoFrame::Format_ARGB32; + QTest::newRow("64x64 ARGB32 gl handle") + << QAbstractVideoBuffer::GLTextureHandle + << QSize(64, 64) + << QVideoFrame::Format_ARGB32; + QTest::newRow("64x64 ARGB32 user handle") + << QAbstractVideoBuffer::UserHandle + << QSize(64, 64) + << QVideoFrame::Format_ARGB32; +} + +void tst_QVideoFrame::createFromBuffer() +{ + QFETCH(QAbstractVideoBuffer::HandleType, handleType); + QFETCH(QSize, size); + QFETCH(QVideoFrame::PixelFormat, pixelFormat); + + QVideoFrame frame(new QtTestVideoBuffer(handleType), size, pixelFormat); + + QVERIFY(frame.isValid()); + QCOMPARE(frame.handleType(), handleType); + QCOMPARE(frame.pixelFormat(), pixelFormat); + QCOMPARE(frame.size(), size); + QCOMPARE(frame.width(), size.width()); + QCOMPARE(frame.height(), size.height()); + QCOMPARE(frame.fieldType(), QVideoFrame::ProgressiveFrame); + QCOMPARE(frame.startTime(), qint64(-1)); + QCOMPARE(frame.endTime(), qint64(-1)); +} + +void tst_QVideoFrame::createFromImage_data() +{ + QTest::addColumn<QSize>("size"); + QTest::addColumn<QImage::Format>("imageFormat"); + QTest::addColumn<QVideoFrame::PixelFormat>("pixelFormat"); + + QTest::newRow("64x64 RGB32") + << QSize(64, 64) + << QImage::Format_RGB32 + << QVideoFrame::Format_RGB32; + QTest::newRow("12x45 RGB16") + << QSize(12, 45) + << QImage::Format_RGB16 + << QVideoFrame::Format_RGB565; + QTest::newRow("19x46 ARGB32_Premultiplied") + << QSize(19, 46) + << QImage::Format_ARGB32_Premultiplied + << QVideoFrame::Format_ARGB32_Premultiplied; +} + +void tst_QVideoFrame::createFromImage() +{ + QFETCH(QSize, size); + QFETCH(QImage::Format, imageFormat); + QFETCH(QVideoFrame::PixelFormat, pixelFormat); + + const QImage image(size.width(), size.height(), imageFormat); + + QVideoFrame frame(image); + + QVERIFY(frame.isValid()); + QCOMPARE(frame.handleType(), QAbstractVideoBuffer::NoHandle); + QCOMPARE(frame.pixelFormat(), pixelFormat); + QCOMPARE(frame.size(), size); + QCOMPARE(frame.width(), size.width()); + QCOMPARE(frame.height(), size.height()); + QCOMPARE(frame.fieldType(), QVideoFrame::ProgressiveFrame); + QCOMPARE(frame.startTime(), qint64(-1)); + QCOMPARE(frame.endTime(), qint64(-1)); +} + +void tst_QVideoFrame::createFromIncompatibleImage() +{ + const QImage image(64, 64, QImage::Format_Mono); + + QVideoFrame frame(image); + + QVERIFY(!frame.isValid()); + QCOMPARE(frame.handleType(), QAbstractVideoBuffer::NoHandle); + QCOMPARE(frame.pixelFormat(), QVideoFrame::Format_Invalid); + QCOMPARE(frame.size(), QSize(64, 64)); + QCOMPARE(frame.width(), 64); + QCOMPARE(frame.height(), 64); + QCOMPARE(frame.fieldType(), QVideoFrame::ProgressiveFrame); + QCOMPARE(frame.startTime(), qint64(-1)); + QCOMPARE(frame.endTime(), qint64(-1)); +} + +void tst_QVideoFrame::createNull() +{ + QVideoFrame frame; + + QVERIFY(!frame.isValid()); + QCOMPARE(frame.handleType(), QAbstractVideoBuffer::NoHandle); + QCOMPARE(frame.pixelFormat(), QVideoFrame::Format_Invalid); + QCOMPARE(frame.size(), QSize()); + QCOMPARE(frame.width(), -1); + QCOMPARE(frame.height(), -1); + QCOMPARE(frame.fieldType(), QVideoFrame::ProgressiveFrame); + QCOMPARE(frame.startTime(), qint64(-1)); + QCOMPARE(frame.endTime(), qint64(-1)); +} + +void tst_QVideoFrame::destructor() +{ + QPointer<QtTestVideoBuffer> buffer = new QtTestVideoBuffer; + + { + QVideoFrame frame(buffer, QSize(4, 1), QVideoFrame::Format_ARGB32); + } + + QVERIFY(buffer.isNull()); +} + +void tst_QVideoFrame::copy_data() +{ + QTest::addColumn<QAbstractVideoBuffer::HandleType>("handleType"); + QTest::addColumn<QSize>("size"); + QTest::addColumn<QVideoFrame::PixelFormat>("pixelFormat"); + QTest::addColumn<QVideoFrame::FieldType>("fieldType"); + QTest::addColumn<qint64>("startTime"); + QTest::addColumn<qint64>("endTime"); + + QTest::newRow("64x64 ARGB32") + << QAbstractVideoBuffer::GLTextureHandle + << QSize(64, 64) + << QVideoFrame::Format_ARGB32 + << QVideoFrame::TopField + << qint64(63641740) + << qint64(63641954); + QTest::newRow("32x256 YUV420P") + << QAbstractVideoBuffer::UserHandle + << QSize(32, 256) + << QVideoFrame::Format_YUV420P + << QVideoFrame::InterlacedFrame + << qint64(12345) + << qint64(12389); +} + +void tst_QVideoFrame::copy() +{ + QFETCH(QAbstractVideoBuffer::HandleType, handleType); + QFETCH(QSize, size); + QFETCH(QVideoFrame::PixelFormat, pixelFormat); + QFETCH(QVideoFrame::FieldType, fieldType); + QFETCH(qint64, startTime); + QFETCH(qint64, endTime); + + QPointer<QtTestVideoBuffer> buffer = new QtTestVideoBuffer(handleType); + + { + QVideoFrame frame(buffer, size, pixelFormat); + frame.setFieldType(QVideoFrame::FieldType(fieldType)); + frame.setStartTime(startTime); + frame.setEndTime(endTime); + + QVERIFY(frame.isValid()); + QCOMPARE(frame.handleType(), handleType); + QCOMPARE(frame.pixelFormat(), pixelFormat); + QCOMPARE(frame.size(), size); + QCOMPARE(frame.width(), size.width()); + QCOMPARE(frame.height(), size.height()); + QCOMPARE(frame.fieldType(), fieldType); + QCOMPARE(frame.startTime(), startTime); + QCOMPARE(frame.endTime(), endTime); + + { + QVideoFrame otherFrame(frame); + + QVERIFY(!buffer.isNull()); + + QVERIFY(otherFrame.isValid()); + QCOMPARE(otherFrame.handleType(), handleType); + QCOMPARE(otherFrame.pixelFormat(), pixelFormat); + QCOMPARE(otherFrame.size(), size); + QCOMPARE(otherFrame.width(), size.width()); + QCOMPARE(otherFrame.height(), size.height()); + QCOMPARE(otherFrame.fieldType(), fieldType); + QCOMPARE(otherFrame.startTime(), startTime); + QCOMPARE(otherFrame.endTime(), endTime); + + otherFrame.setEndTime(-1); + + QVERIFY(!buffer.isNull()); + + QVERIFY(otherFrame.isValid()); + QCOMPARE(otherFrame.handleType(), handleType); + QCOMPARE(otherFrame.pixelFormat(), pixelFormat); + QCOMPARE(otherFrame.size(), size); + QCOMPARE(otherFrame.width(), size.width()); + QCOMPARE(otherFrame.height(), size.height()); + QCOMPARE(otherFrame.fieldType(), fieldType); + QCOMPARE(otherFrame.startTime(), startTime); + QCOMPARE(otherFrame.endTime(), qint64(-1)); + } + + QVERIFY(!buffer.isNull()); + + QVERIFY(frame.isValid()); + QCOMPARE(frame.handleType(), handleType); + QCOMPARE(frame.pixelFormat(), pixelFormat); + QCOMPARE(frame.size(), size); + QCOMPARE(frame.width(), size.width()); + QCOMPARE(frame.height(), size.height()); + QCOMPARE(frame.fieldType(), fieldType); + QCOMPARE(frame.startTime(), startTime); + QCOMPARE(frame.endTime(), qint64(-1)); // Explicitly shared. + } + + QVERIFY(buffer.isNull()); +} + +void tst_QVideoFrame::assign_data() +{ + QTest::addColumn<QAbstractVideoBuffer::HandleType>("handleType"); + QTest::addColumn<QSize>("size"); + QTest::addColumn<QVideoFrame::PixelFormat>("pixelFormat"); + QTest::addColumn<QVideoFrame::FieldType>("fieldType"); + QTest::addColumn<qint64>("startTime"); + QTest::addColumn<qint64>("endTime"); + + QTest::newRow("64x64 ARGB32") + << QAbstractVideoBuffer::GLTextureHandle + << QSize(64, 64) + << QVideoFrame::Format_ARGB32 + << QVideoFrame::TopField + << qint64(63641740) + << qint64(63641954); + QTest::newRow("32x256 YUV420P") + << QAbstractVideoBuffer::UserHandle + << QSize(32, 256) + << QVideoFrame::Format_YUV420P + << QVideoFrame::InterlacedFrame + << qint64(12345) + << qint64(12389); +} + +void tst_QVideoFrame::assign() +{ + QFETCH(QAbstractVideoBuffer::HandleType, handleType); + QFETCH(QSize, size); + QFETCH(QVideoFrame::PixelFormat, pixelFormat); + QFETCH(QVideoFrame::FieldType, fieldType); + QFETCH(qint64, startTime); + QFETCH(qint64, endTime); + + QPointer<QtTestVideoBuffer> buffer = new QtTestVideoBuffer(handleType); + + QVideoFrame frame; + { + QVideoFrame otherFrame(buffer, size, pixelFormat); + otherFrame.setFieldType(fieldType); + otherFrame.setStartTime(startTime); + otherFrame.setEndTime(endTime); + + frame = otherFrame; + + QVERIFY(!buffer.isNull()); + + QVERIFY(otherFrame.isValid()); + QCOMPARE(otherFrame.handleType(), handleType); + QCOMPARE(otherFrame.pixelFormat(), pixelFormat); + QCOMPARE(otherFrame.size(), size); + QCOMPARE(otherFrame.width(), size.width()); + QCOMPARE(otherFrame.height(), size.height()); + QCOMPARE(otherFrame.fieldType(), fieldType); + QCOMPARE(otherFrame.startTime(), startTime); + QCOMPARE(otherFrame.endTime(), endTime); + + otherFrame.setStartTime(-1); + + QVERIFY(!buffer.isNull()); + + QVERIFY(otherFrame.isValid()); + QCOMPARE(otherFrame.handleType(), handleType); + QCOMPARE(otherFrame.pixelFormat(), pixelFormat); + QCOMPARE(otherFrame.size(), size); + QCOMPARE(otherFrame.width(), size.width()); + QCOMPARE(otherFrame.height(), size.height()); + QCOMPARE(otherFrame.fieldType(), fieldType); + QCOMPARE(otherFrame.startTime(), qint64(-1)); + QCOMPARE(otherFrame.endTime(), endTime); + } + + QVERIFY(!buffer.isNull()); + + QVERIFY(frame.isValid()); + QCOMPARE(frame.handleType(), handleType); + QCOMPARE(frame.pixelFormat(), pixelFormat); + QCOMPARE(frame.size(), size); + QCOMPARE(frame.width(), size.width()); + QCOMPARE(frame.height(), size.height()); + QCOMPARE(frame.fieldType(), fieldType); + QCOMPARE(frame.startTime(), qint64(-1)); + QCOMPARE(frame.endTime(), endTime); + + frame = QVideoFrame(); + + QVERIFY(buffer.isNull()); + + QVERIFY(!frame.isValid()); + QCOMPARE(frame.handleType(), QAbstractVideoBuffer::NoHandle); + QCOMPARE(frame.pixelFormat(), QVideoFrame::Format_Invalid); + QCOMPARE(frame.size(), QSize()); + QCOMPARE(frame.width(), -1); + QCOMPARE(frame.height(), -1); + QCOMPARE(frame.fieldType(), QVideoFrame::ProgressiveFrame); + QCOMPARE(frame.startTime(), qint64(-1)); + QCOMPARE(frame.endTime(), qint64(-1)); +} + +void tst_QVideoFrame::map_data() +{ + QTest::addColumn<QSize>("size"); + QTest::addColumn<int>("numBytes"); + QTest::addColumn<int>("bytesPerLine"); + QTest::addColumn<QVideoFrame::PixelFormat>("pixelFormat"); + QTest::addColumn<QAbstractVideoBuffer::MapMode>("mode"); + + QTest::newRow("read-only") + << QSize(64, 64) + << 16384 + << 256 + << QVideoFrame::Format_ARGB32 + << QAbstractVideoBuffer::ReadOnly; + + QTest::newRow("write-only") + << QSize(64, 64) + << 16384 + << 256 + << QVideoFrame::Format_ARGB32 + << QAbstractVideoBuffer::WriteOnly; + + QTest::newRow("read-write") + << QSize(64, 64) + << 16384 + << 256 + << QVideoFrame::Format_ARGB32 + << QAbstractVideoBuffer::ReadWrite; +} + +void tst_QVideoFrame::map() +{ + QFETCH(QSize, size); + QFETCH(int, numBytes); + QFETCH(int, bytesPerLine); + QFETCH(QVideoFrame::PixelFormat, pixelFormat); + QFETCH(QAbstractVideoBuffer::MapMode, mode); + + QVideoFrame frame(numBytes, size, bytesPerLine, pixelFormat); + + QVERIFY(!frame.bits()); + QCOMPARE(frame.numBytes(), 0); + QCOMPARE(frame.bytesPerLine(), 0); + QCOMPARE(frame.mapMode(), QAbstractVideoBuffer::NotMapped); + + QVERIFY(frame.map(mode)); + + QVERIFY(frame.bits()); + QCOMPARE(frame.numBytes(), numBytes); + QCOMPARE(frame.bytesPerLine(), bytesPerLine); + QCOMPARE(frame.mapMode(), mode); + + frame.unmap(); + + QVERIFY(!frame.bits()); + QCOMPARE(frame.numBytes(), 0); + QCOMPARE(frame.bytesPerLine(), 0); + QCOMPARE(frame.mapMode(), QAbstractVideoBuffer::NotMapped); +} + +void tst_QVideoFrame::mapImage_data() +{ + QTest::addColumn<QSize>("size"); + QTest::addColumn<QImage::Format>("format"); + QTest::addColumn<QAbstractVideoBuffer::MapMode>("mode"); + + QTest::newRow("read-only") + << QSize(64, 64) + << QImage::Format_ARGB32 + << QAbstractVideoBuffer::ReadOnly; + + QTest::newRow("write-only") + << QSize(15, 106) + << QImage::Format_RGB32 + << QAbstractVideoBuffer::WriteOnly; + + QTest::newRow("read-write") + << QSize(23, 111) + << QImage::Format_RGB16 + << QAbstractVideoBuffer::ReadWrite; +} + +void tst_QVideoFrame::mapImage() +{ + QFETCH(QSize, size); + QFETCH(QImage::Format, format); + QFETCH(QAbstractVideoBuffer::MapMode, mode); + + QImage image(size.width(), size.height(), format); + + QVideoFrame frame(image); + + QVERIFY(!frame.bits()); + QCOMPARE(frame.numBytes(), 0); + QCOMPARE(frame.bytesPerLine(), 0); + QCOMPARE(frame.mapMode(), QAbstractVideoBuffer::NotMapped); + + QVERIFY(frame.map(mode)); + + QVERIFY(frame.bits()); + QCOMPARE(frame.numBytes(), image.numBytes()); + QCOMPARE(frame.bytesPerLine(), image.bytesPerLine()); + QCOMPARE(frame.mapMode(), mode); + + frame.unmap(); + + QVERIFY(!frame.bits()); + QCOMPARE(frame.numBytes(), 0); + QCOMPARE(frame.bytesPerLine(), 0); + QCOMPARE(frame.mapMode(), QAbstractVideoBuffer::NotMapped); +} + +void tst_QVideoFrame::imageDetach() +{ + const uint red = qRgb(255, 0, 0); + const uint blue = qRgb(0, 0, 255); + + QImage image(8, 8, QImage::Format_RGB32); + + image.fill(red); + QCOMPARE(image.pixel(4, 4), red); + + QVideoFrame frame(image); + + QVERIFY(frame.map(QAbstractVideoBuffer::ReadWrite)); + + QImage frameImage(frame.bits(), 8, 8, frame.bytesPerLine(), QImage::Format_RGB32); + + QCOMPARE(frameImage.pixel(4, 4), red); + + frameImage.fill(blue); + QCOMPARE(frameImage.pixel(4, 4), blue); + + // Original image has detached and is therefore unchanged. + QCOMPARE(image.pixel(4, 4), red); +} + +QTEST_MAIN(tst_QVideoFrame) + +#include "tst_qvideoframe.moc" diff --git a/tests/auto/qvideosurfaceformat/qvideosurfaceformat.pro b/tests/auto/qvideosurfaceformat/qvideosurfaceformat.pro new file mode 100644 index 0000000..830b3d7 --- /dev/null +++ b/tests/auto/qvideosurfaceformat/qvideosurfaceformat.pro @@ -0,0 +1,5 @@ +load(qttest_p4) +SOURCES += tst_qvideosurfaceformat.cpp + +QT += multimedia +requires(contains(QT_CONFIG, multimedia)) diff --git a/tests/auto/qvideosurfaceformat/tst_qvideosurfaceformat.cpp b/tests/auto/qvideosurfaceformat/tst_qvideosurfaceformat.cpp new file mode 100644 index 0000000..1bab37b --- /dev/null +++ b/tests/auto/qvideosurfaceformat/tst_qvideosurfaceformat.cpp @@ -0,0 +1,745 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, 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. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QtTest/QtTest> + +#include <QtMultimedia/QVideoSurfaceFormat> + +class tst_QVideoSurfaceFormat : public QObject +{ + Q_OBJECT +public: + tst_QVideoSurfaceFormat(); + ~tst_QVideoSurfaceFormat(); + +public slots: + void initTestCase(); + void cleanupTestCase(); + void init(); + void cleanup(); + +private slots: + void constructNull(); + void construct_data(); + void construct(); + void frameSize_data(); + void frameSize(); + void viewport_data(); + void viewport(); + void scanLineDirection_data(); + void scanLineDirection(); + void frameRate_data(); + void frameRate(); + void yuvColorSpace_data(); + void yuvColorSpace(); + void pixelAspectRatio_data(); + void pixelAspectRatio(); + void sizeHint_data(); + void sizeHint(); + void staticPropertyNames(); + void dynamicProperty(); + void compare(); + void copy(); + void assign(); +}; + +Q_DECLARE_METATYPE(QVideoSurfaceFormat::ViewportMode) + + +tst_QVideoSurfaceFormat::tst_QVideoSurfaceFormat() +{ +} + +tst_QVideoSurfaceFormat::~tst_QVideoSurfaceFormat() +{ +} + +void tst_QVideoSurfaceFormat::initTestCase() +{ +} + +void tst_QVideoSurfaceFormat::cleanupTestCase() +{ +} + +void tst_QVideoSurfaceFormat::init() +{ +} + +void tst_QVideoSurfaceFormat::cleanup() +{ +} + +void tst_QVideoSurfaceFormat::constructNull() +{ + QVideoSurfaceFormat format; + + QVERIFY(!format.isValid()); + QCOMPARE(format.handleType(), QAbstractVideoBuffer::NoHandle); + QCOMPARE(format.pixelFormat(), QVideoFrame::Format_Invalid); + QCOMPARE(format.frameSize(), QSize()); + QCOMPARE(format.frameWidth(), -1); + QCOMPARE(format.frameHeight(), -1); + QCOMPARE(format.viewport(), QRect()); + QCOMPARE(format.scanLineDirection(), QVideoSurfaceFormat::TopToBottom); + QCOMPARE(format.frameRate(), QVideoSurfaceFormat::FrameRate()); + QCOMPARE(format.pixelAspectRatio(), QSize(1, 1)); + QCOMPARE(format.yuvColorSpace(), QVideoSurfaceFormat::YCbCr_Undefined); +} + +void tst_QVideoSurfaceFormat::construct_data() +{ + QTest::addColumn<QSize>("frameSize"); + QTest::addColumn<QVideoFrame::PixelFormat>("pixelFormat"); + QTest::addColumn<QAbstractVideoBuffer::HandleType>("handleType"); + + QTest::newRow("32x32 rgb32 no handle") + << QSize(32, 32) + << QVideoFrame::Format_RGB32 + << QAbstractVideoBuffer::NoHandle; + + QTest::newRow("1024x768 YUV444 GL texture") + << QSize(32, 32) + << QVideoFrame::Format_YUV444 + << QAbstractVideoBuffer::GLTextureHandle; +} + +void tst_QVideoSurfaceFormat::construct() +{ + QFETCH(QSize, frameSize); + QFETCH(QVideoFrame::PixelFormat, pixelFormat); + QFETCH(QAbstractVideoBuffer::HandleType, handleType); + + QRect viewport(QPoint(0, 0), frameSize); + + QVideoSurfaceFormat format(frameSize, pixelFormat, handleType); + + QCOMPARE(format.handleType(), handleType); + QCOMPARE(format.pixelFormat(), pixelFormat); + QCOMPARE(format.frameSize(), frameSize); + QCOMPARE(format.frameWidth(), frameSize.width()); + QCOMPARE(format.frameHeight(), frameSize.height()); + QCOMPARE(format.viewport(), viewport); + QCOMPARE(format.scanLineDirection(), QVideoSurfaceFormat::TopToBottom); + QCOMPARE(format.frameRate(), QVideoSurfaceFormat::FrameRate()); + QCOMPARE(format.pixelAspectRatio(), QSize(1, 1)); + QCOMPARE(format.yuvColorSpace(), QVideoSurfaceFormat::YCbCr_Undefined); +} + +void tst_QVideoSurfaceFormat::frameSize_data() +{ + QTest::addColumn<QSize>("initialSize"); + QTest::addColumn<QSize>("newSize"); + + QTest::newRow("grow") + << QSize(64, 64) + << QSize(1024, 1024); + QTest::newRow("shrink") + << QSize(1024, 1024) + << QSize(64, 64); + QTest::newRow("unchanged") + << QSize(512, 512) + << QSize(512, 512); +} + +void tst_QVideoSurfaceFormat::frameSize() +{ + QFETCH(QSize, initialSize); + QFETCH(QSize, newSize); + + QVideoSurfaceFormat format(initialSize, QVideoFrame::Format_RGB32); + + format.setFrameSize(newSize); + + QCOMPARE(format.frameSize(), newSize); + QCOMPARE(format.property("frameSize").toSize(), newSize); + QCOMPARE(format.frameWidth(), newSize.width()); + QCOMPARE(format.property("frameWidth").toInt(), newSize.width()); + QCOMPARE(format.frameHeight(), newSize.height()); + QCOMPARE(format.property("frameHeight").toInt(), newSize.height()); +} + +void tst_QVideoSurfaceFormat::viewport_data() +{ + QTest::addColumn<QSize>("initialSize"); + QTest::addColumn<QRect>("viewport"); + QTest::addColumn<QSize>("newSize"); + QTest::addColumn<QVideoSurfaceFormat::ViewportMode>("viewportMode"); + QTest::addColumn<QRect>("expectedViewport"); + + QTest::newRow("grow reset") + << QSize(64, 64) + << QRect(8, 8, 48, 48) + << QSize(1024, 1024) + << QVideoSurfaceFormat::ResetViewport + << QRect(0, 0, 1024, 1024); + QTest::newRow("grow keep") + << QSize(64, 64) + << QRect(8, 8, 48, 48) + << QSize(1024, 1024) + << QVideoSurfaceFormat::KeepViewport + << QRect(8, 8, 48, 48); + QTest::newRow("shrink reset") + << QSize(1024, 1024) + << QRect(8, 8, 1008, 1008) + << QSize(64, 64) + << QVideoSurfaceFormat::ResetViewport + << QRect(0, 0, 64, 64); + QTest::newRow("shrink keep") + << QSize(1024, 1024) + << QRect(8, 8, 1008, 1008) + << QSize(64, 64) + << QVideoSurfaceFormat::KeepViewport + << QRect(8, 8, 56, 56); + QTest::newRow("unchanged reset") + << QSize(512, 512) + << QRect(8, 8, 496, 496) + << QSize(512, 512) + << QVideoSurfaceFormat::ResetViewport + << QRect(0, 0, 512, 512); + QTest::newRow("unchanged keep") + << QSize(512, 512) + << QRect(8, 8, 496, 496) + << QSize(512, 512) + << QVideoSurfaceFormat::KeepViewport + << QRect(8, 8, 496, 496); +} + +void tst_QVideoSurfaceFormat::viewport() +{ + QFETCH(QSize, initialSize); + QFETCH(QRect, viewport); + QFETCH(QSize, newSize); + QFETCH(QVideoSurfaceFormat::ViewportMode, viewportMode); + QFETCH(QRect, expectedViewport); + + { + QRect initialViewport(QPoint(0, 0), initialSize); + + QVideoSurfaceFormat format(initialSize, QVideoFrame::Format_RGB32); + + format.setViewport(viewport); + + QCOMPARE(format.viewport(), viewport); + QCOMPARE(format.property("viewport").toRect(), viewport); + + format.setFrameSize(newSize, viewportMode); + + QCOMPARE(format.viewport(), expectedViewport); + QCOMPARE(format.property("viewport").toRect(), expectedViewport); + } + { + QVideoSurfaceFormat format(initialSize, QVideoFrame::Format_RGB32); + + format.setProperty("viewport", viewport); + + QCOMPARE(format.viewport(), viewport); + QCOMPARE(format.property("viewport").toRect(), viewport); + } +} + +void tst_QVideoSurfaceFormat::scanLineDirection_data() +{ + QTest::addColumn<QVideoSurfaceFormat::Direction>("direction"); + + QTest::newRow("top to bottom") + << QVideoSurfaceFormat::TopToBottom; + + QTest::newRow("bottom to top") + << QVideoSurfaceFormat::BottomToTop; +} + +void tst_QVideoSurfaceFormat::scanLineDirection() +{ + QFETCH(QVideoSurfaceFormat::Direction, direction); + + { + QVideoSurfaceFormat format(QSize(16, 16), QVideoFrame::Format_RGB32); + + format.setScanLineDirection(direction); + + QCOMPARE(format.scanLineDirection(), direction); + QCOMPARE( + qvariant_cast<QVideoSurfaceFormat::Direction>(format.property("scanLineDirection")), + direction); + } + { + QVideoSurfaceFormat format(QSize(16, 16), QVideoFrame::Format_RGB32); + + format.setProperty("scanLineDirection", qVariantFromValue(direction)); + + QCOMPARE(format.scanLineDirection(), direction); + QCOMPARE( + qvariant_cast<QVideoSurfaceFormat::Direction>(format.property("scanLineDirection")), + direction); + } +} + +void tst_QVideoSurfaceFormat::frameRate_data() +{ + QTest::addColumn<QVideoSurfaceFormat::FrameRate>("frameRate"); + + QTest::newRow("null") + << QVideoSurfaceFormat::FrameRate(0, 0); + QTest::newRow("1/1") + << QVideoSurfaceFormat::FrameRate(1, 1); + QTest::newRow("24/1") + << QVideoSurfaceFormat::FrameRate(24, 1); + QTest::newRow("15/2") + << QVideoSurfaceFormat::FrameRate(15, 2); +} + +void tst_QVideoSurfaceFormat::frameRate() +{ + QFETCH(QVideoSurfaceFormat::FrameRate, frameRate); + + { + QVideoSurfaceFormat format(QSize(64, 64), QVideoFrame::Format_RGB32); + + format.setFrameRate(frameRate); + + QCOMPARE(format.frameRate(), frameRate); + QCOMPARE(qvariant_cast<QVideoSurfaceFormat::FrameRate>(format.property("frameRate")), + frameRate); + } + { + QVideoSurfaceFormat format(QSize(64, 64), QVideoFrame::Format_RGB32); + + format.setFrameRate(frameRate.first, frameRate.second); + + QCOMPARE(format.frameRate(), frameRate); + QCOMPARE( + qvariant_cast<QVideoSurfaceFormat::FrameRate>(format.property("frameRate")), + frameRate); + } + { + QVideoSurfaceFormat format(QSize(64, 64), QVideoFrame::Format_RGB32); + + format.setFrameRate(frameRate); + format.setProperty( + "frameRate", qVariantFromValue<QVideoSurfaceFormat::FrameRate>(frameRate)); + + QCOMPARE(format.frameRate(), frameRate); + QCOMPARE(qvariant_cast<QVideoSurfaceFormat::FrameRate>(format.property("frameRate")), + frameRate); + } +} + +void tst_QVideoSurfaceFormat::yuvColorSpace_data() +{ + QTest::addColumn<QVideoSurfaceFormat::YuvColorSpace>("colorspace"); + + QTest::newRow("undefined") + << QVideoSurfaceFormat::YCbCr_Undefined; + QTest::newRow("bt709") + << QVideoSurfaceFormat::YCbCr_BT709; + QTest::newRow("xvYCC601") + << QVideoSurfaceFormat::YCbCr_xvYCC601; + QTest::newRow("JPEG") + << QVideoSurfaceFormat::YCbCr_JPEG; +} + +void tst_QVideoSurfaceFormat::yuvColorSpace() +{ + QFETCH(QVideoSurfaceFormat::YuvColorSpace, colorspace); + + { + QVideoSurfaceFormat format(QSize(64, 64), QVideoFrame::Format_RGB32); + format.setYuvColorSpace(colorspace); + + QCOMPARE(format.yuvColorSpace(), colorspace); + QCOMPARE(qvariant_cast<QVideoSurfaceFormat::YuvColorSpace>(format.property("yuvColorSpace")), + colorspace); + } + { + QVideoSurfaceFormat format(QSize(64, 64), QVideoFrame::Format_RGB32); + format.setProperty("yuvColorSpace", qVariantFromValue(colorspace)); + + QCOMPARE(format.yuvColorSpace(), colorspace); + QCOMPARE(qvariant_cast<QVideoSurfaceFormat::YuvColorSpace>(format.property("yuvColorSpace")), + colorspace); + } +} + +void tst_QVideoSurfaceFormat::pixelAspectRatio_data() +{ + QTest::addColumn<QSize>("aspectRatio"); + + QTest::newRow("1:1") + << QSize(1, 1); + QTest::newRow("4:3") + << QSize(4, 3); + QTest::newRow("16:9") + << QSize(16, 9); +} + +void tst_QVideoSurfaceFormat::pixelAspectRatio() +{ + QFETCH(QSize, aspectRatio); + + { + QVideoSurfaceFormat format(QSize(64, 64), QVideoFrame::Format_RGB32); + format.setPixelAspectRatio(aspectRatio); + + QCOMPARE(format.pixelAspectRatio(), aspectRatio); + QCOMPARE(format.property("pixelAspectRatio").toSize(), aspectRatio); + } + { + QVideoSurfaceFormat format(QSize(64, 64), QVideoFrame::Format_RGB32); + format.setPixelAspectRatio(aspectRatio.width(), aspectRatio.height()); + + QCOMPARE(format.pixelAspectRatio(), aspectRatio); + QCOMPARE(format.property("pixelAspectRatio").toSize(), aspectRatio); + } + { + QVideoSurfaceFormat format(QSize(64, 64), QVideoFrame::Format_RGB32); + format.setProperty("pixelAspectRatio", aspectRatio); + + QCOMPARE(format.pixelAspectRatio(), aspectRatio); + QCOMPARE(format.property("pixelAspectRatio").toSize(), aspectRatio); + } +} + +void tst_QVideoSurfaceFormat::sizeHint_data() +{ + QTest::addColumn<QSize>("frameSize"); + QTest::addColumn<QRect>("viewport"); + QTest::addColumn<QSize>("aspectRatio"); + QTest::addColumn<QSize>("sizeHint"); + + QTest::newRow("(0, 0, 1024x768), 1:1") + << QSize(1024, 768) + << QRect(0, 0, 1024, 768) + << QSize(1, 1) + << QSize(1024, 768); + QTest::newRow("0, 0, 1024x768), 4:3") + << QSize(1024, 768) + << QRect(0, 0, 1024, 768) + << QSize(4, 3) + << QSize(1365, 768); + QTest::newRow("(168, 84, 800x600), 1:1") + << QSize(1024, 768) + << QRect(168, 84, 800, 600) + << QSize(1, 1) + << QSize(800, 600); + QTest::newRow("(168, 84, 800x600), 4:3") + << QSize(1024, 768) + << QRect(168, 84, 800, 600) + << QSize(4, 3) + << QSize(1066, 600); +} + +void tst_QVideoSurfaceFormat::sizeHint() +{ + QFETCH(QSize, frameSize); + QFETCH(QRect, viewport); + QFETCH(QSize, aspectRatio); + QFETCH(QSize, sizeHint); + + QVideoSurfaceFormat format(frameSize, QVideoFrame::Format_RGB32); + format.setViewport(viewport); + format.setPixelAspectRatio(aspectRatio); + + QCOMPARE(format.sizeHint(), sizeHint); + QCOMPARE(format.property("sizeHint").toSize(), sizeHint); +} + +void tst_QVideoSurfaceFormat::staticPropertyNames() +{ + QVideoSurfaceFormat format(QSize(64, 64), QVideoFrame::Format_RGB32); + + QList<QByteArray> propertyNames = format.propertyNames(); + + QVERIFY(propertyNames.contains("handleType")); + QVERIFY(propertyNames.contains("pixelFormat")); + QVERIFY(propertyNames.contains("frameSize")); + QVERIFY(propertyNames.contains("frameWidth")); + QVERIFY(propertyNames.contains("viewport")); + QVERIFY(propertyNames.contains("scanLineDirection")); + QVERIFY(propertyNames.contains("frameRate")); + QVERIFY(propertyNames.contains("pixelAspectRatio")); + QVERIFY(propertyNames.contains("yuvColorSpace")); + QVERIFY(propertyNames.contains("sizeHint")); + QCOMPARE(propertyNames.count(), 10); +} + +void tst_QVideoSurfaceFormat::dynamicProperty() +{ + QVideoSurfaceFormat format(QSize(64, 64), QVideoFrame::Format_RGB32); + + QCOMPARE(format.property("integer"), QVariant()); + QCOMPARE(format.property("size"), QVariant()); + QCOMPARE(format.property("string"), QVariant()); + QCOMPARE(format.property("null"), QVariant()); + + QList<QByteArray> propertyNames = format.propertyNames(); + + QCOMPARE(propertyNames.count(QByteArray("integer")), 0); + QCOMPARE(propertyNames.count(QByteArray("string")), 0); + QCOMPARE(propertyNames.count(QByteArray("size")), 0); + QCOMPARE(propertyNames.count(QByteArray("null")), 0); + + format.setProperty("string", QString::fromLatin1("Hello")); + format.setProperty("integer", 198); + format.setProperty("size", QSize(43, 65)); + + QCOMPARE(format.property("integer").toInt(), 198); + QCOMPARE(format.property("size").toSize(), QSize(43, 65)); + QCOMPARE(format.property("string").toString(), QString::fromLatin1("Hello")); + + propertyNames = format.propertyNames(); + + QCOMPARE(propertyNames.count(QByteArray("integer")), 1); + QCOMPARE(propertyNames.count(QByteArray("string")), 1); + QCOMPARE(propertyNames.count(QByteArray("size")), 1); + + format.setProperty("integer", 125423); + format.setProperty("size", QSize(1, 986)); + + QCOMPARE(format.property("integer").toInt(), 125423); + QCOMPARE(format.property("size").toSize(), QSize(1, 986)); + QCOMPARE(format.property("string").toString(), QString::fromLatin1("Hello")); + + propertyNames = format.propertyNames(); + + QCOMPARE(propertyNames.count(QByteArray("integer")), 1); + QCOMPARE(propertyNames.count(QByteArray("string")), 1); + QCOMPARE(propertyNames.count(QByteArray("size")), 1); + + format.setProperty("string", QVariant()); + format.setProperty("size", QVariant()); + format.setProperty("null", QVariant()); + + QCOMPARE(format.property("integer").toInt(), 125423); + QCOMPARE(format.property("size"), QVariant()); + QCOMPARE(format.property("string"), QVariant()); + QCOMPARE(format.property("null"), QVariant()); + + propertyNames = format.propertyNames(); + + QCOMPARE(propertyNames.count(QByteArray("integer")), 1); + QCOMPARE(propertyNames.count(QByteArray("string")), 0); + QCOMPARE(propertyNames.count(QByteArray("size")), 0); + QCOMPARE(propertyNames.count(QByteArray("null")), 0); +} + +void tst_QVideoSurfaceFormat::compare() +{ + QVideoSurfaceFormat format1( + QSize(16, 16), QVideoFrame::Format_RGB32, QAbstractVideoBuffer::GLTextureHandle); + QVideoSurfaceFormat format2( + QSize(16, 16), QVideoFrame::Format_RGB32, QAbstractVideoBuffer::GLTextureHandle); + QVideoSurfaceFormat format3( + QSize(32, 32), QVideoFrame::Format_YUV444, QAbstractVideoBuffer::GLTextureHandle); + QVideoSurfaceFormat format4( + QSize(16, 16), QVideoFrame::Format_RGB32, QAbstractVideoBuffer::UserHandle); + + QCOMPARE(format1 == format2, true); + QCOMPARE(format1 != format2, false); + QCOMPARE(format1 == format3, false); + QCOMPARE(format1 != format3, true); + QCOMPARE(format1 == format4, false); + QCOMPARE(format1 != format4, true); + + format2.setFrameSize(1024, 768, QVideoSurfaceFormat::ResetViewport); + + // Not equal, frame size differs. + QCOMPARE(format1 == format2, false); + QCOMPARE(format1 != format2, true); + + format1.setFrameSize(1024, 768, QVideoSurfaceFormat::KeepViewport); + + // Not equal, viewport differs. + QCOMPARE(format1 == format2, false); + QCOMPARE(format1 != format2, true); + + format1.setViewport(QRect(0, 0, 1024, 768)); + + // Equal. + QCOMPARE(format1 == format2, true); + QCOMPARE(format1 != format2, false); + + format2.setScanLineDirection(QVideoSurfaceFormat::BottomToTop); + + // Not equal scan line direction differs. + QCOMPARE(format1 == format2, false); + QCOMPARE(format1 != format2, true); + + format1.setScanLineDirection(QVideoSurfaceFormat::BottomToTop); + + // Equal. + QCOMPARE(format1 == format2, true); + QCOMPARE(format1 != format2, false); + + format1.setFrameRate(QVideoSurfaceFormat::FrameRate(15, 2)); + + // Not equal frame rate differs. + QCOMPARE(format1 == format2, false); + QCOMPARE(format1 != format2, true); + + format2.setFrameRate(15, 2); + + // Equal. + QCOMPARE(format1 == format2, true); + QCOMPARE(format1 != format2, false); + + format2.setPixelAspectRatio(4, 3); + + // Not equal pixel aspect ratio differs. + QCOMPARE(format1 == format2, false); + QCOMPARE(format1 != format2, true); + + format1.setPixelAspectRatio(QSize(4, 3)); + + // Equal. + QCOMPARE(format1 == format2, true); + QCOMPARE(format1 != format2, false); + + format2.setYuvColorSpace(QVideoSurfaceFormat::YCbCr_xvYCC601); + + // Not equal yuv color space differs. + QCOMPARE(format1 == format2, false); + QCOMPARE(format1 != format2, true); + + format1.setYuvColorSpace(QVideoSurfaceFormat::YCbCr_xvYCC601); + + // Equal. + QCOMPARE(format1 == format2, true); + QCOMPARE(format1 != format2, false); + + format1.setProperty("integer", 12); + + // Not equal, property mismatch. + QCOMPARE(format1 == format2, false); + QCOMPARE(format1 != format2, true); + + format2.setProperty("integer", 45); + + // Not equal, integer differs. + QCOMPARE(format1 == format2, false); + QCOMPARE(format1 != format2, true); + + format2.setProperty("integer", 12); + + // Equal. + QCOMPARE(format1 == format2, true); + QCOMPARE(format1 != format2, false); + + format1.setProperty("string", QString::fromLatin1("Hello")); + format2.setProperty("size", QSize(12, 54)); + + // Not equal, property mismatch. + QCOMPARE(format1 == format2, false); + QCOMPARE(format1 != format2, true); + + format2.setProperty("string", QString::fromLatin1("Hello")); + format1.setProperty("size", QSize(12, 54)); + + // Equal. + QCOMPARE(format1 == format2, true); + QCOMPARE(format1 != format2, false); + + format1.setProperty("string", QVariant()); + + // Not equal, property mismatch. + QCOMPARE(format1 == format2, false); + QCOMPARE(format1 != format2, true); +} + + +void tst_QVideoSurfaceFormat::copy() +{ + QVideoSurfaceFormat original( + QSize(1024, 768), QVideoFrame::Format_ARGB32, QAbstractVideoBuffer::GLTextureHandle); + original.setScanLineDirection(QVideoSurfaceFormat::BottomToTop); + + QVideoSurfaceFormat copy(original); + + QCOMPARE(copy.handleType(), QAbstractVideoBuffer::GLTextureHandle); + QCOMPARE(copy.pixelFormat(), QVideoFrame::Format_ARGB32); + QCOMPARE(copy.frameSize(), QSize(1024, 768)); + QCOMPARE(copy.scanLineDirection(), QVideoSurfaceFormat::BottomToTop); + + QCOMPARE(original == copy, true); + QCOMPARE(original != copy, false); + + copy.setScanLineDirection(QVideoSurfaceFormat::TopToBottom); + + QCOMPARE(copy.scanLineDirection(), QVideoSurfaceFormat::TopToBottom); + + QCOMPARE(original.scanLineDirection(), QVideoSurfaceFormat::BottomToTop); + + QCOMPARE(original == copy, false); + QCOMPARE(original != copy, true); +} + +void tst_QVideoSurfaceFormat::assign() +{ + QVideoSurfaceFormat copy( + QSize(64, 64), QVideoFrame::Format_AYUV444, QAbstractVideoBuffer::UserHandle); + + QVideoSurfaceFormat original( + QSize(1024, 768), QVideoFrame::Format_ARGB32, QAbstractVideoBuffer::GLTextureHandle); + original.setScanLineDirection(QVideoSurfaceFormat::BottomToTop); + + copy = original; + + QCOMPARE(copy.handleType(), QAbstractVideoBuffer::GLTextureHandle); + QCOMPARE(copy.pixelFormat(), QVideoFrame::Format_ARGB32); + QCOMPARE(copy.frameSize(), QSize(1024, 768)); + QCOMPARE(copy.scanLineDirection(), QVideoSurfaceFormat::BottomToTop); + + QCOMPARE(original == copy, true); + QCOMPARE(original != copy, false); + + copy.setScanLineDirection(QVideoSurfaceFormat::TopToBottom); + + QCOMPARE(copy.scanLineDirection(), QVideoSurfaceFormat::TopToBottom); + + QCOMPARE(original.scanLineDirection(), QVideoSurfaceFormat::BottomToTop); + + QCOMPARE(original == copy, false); + QCOMPARE(original != copy, true); +} + +QTEST_MAIN(tst_QVideoSurfaceFormat) + +#include "tst_qvideosurfaceformat.moc" diff --git a/tests/auto/qwaitcondition/tst_qwaitcondition.cpp b/tests/auto/qwaitcondition/tst_qwaitcondition.cpp index 87a895a..7d7fb2d 100644 --- a/tests/auto/qwaitcondition/tst_qwaitcondition.cpp +++ b/tests/auto/qwaitcondition/tst_qwaitcondition.cpp @@ -47,6 +47,12 @@ #include <qthread.h> #include <qwaitcondition.h> +#if defined(Q_OS_SYMBIAN) +// Symbian Open C has a bug that causes very short waits to fail sometimes +#define COND_WAIT_TIME 50 +#else +#define COND_WAIT_TIME 1 +#endif //TESTED_CLASS= @@ -92,10 +98,10 @@ public: void run() { - mutex.lock(); - cond.wakeOne(); - cond.wait(&mutex); - mutex.unlock(); + mutex.lock(); + cond.wakeOne(); + cond.wait(&mutex); + mutex.unlock(); } }; @@ -108,15 +114,15 @@ public: QWaitCondition *cond; inline wait_QMutex_Thread_2() - : mutex(0), cond(0) + : mutex(0), cond(0) { } void run() { - mutex->lock(); - started.wakeOne(); - cond->wait(mutex); - mutex->unlock(); + mutex->lock(); + started.wakeOne(); + cond->wait(mutex); + mutex->unlock(); } }; @@ -131,10 +137,10 @@ public: void run() { - readWriteLock.lockForWrite(); - cond.wakeOne(); - cond.wait(&readWriteLock); - readWriteLock.unlock(); + readWriteLock.lockForWrite(); + cond.wakeOne(); + cond.wait(&readWriteLock); + readWriteLock.unlock(); } }; @@ -147,15 +153,15 @@ public: QWaitCondition *cond; inline wait_QReadWriteLock_Thread_2() - : readWriteLock(0), cond(0) + : readWriteLock(0), cond(0) { } void run() { - readWriteLock->lockForRead(); - started.wakeOne(); - cond->wait(readWriteLock); - readWriteLock->unlock(); + readWriteLock->lockForRead(); + started.wakeOne(); + cond->wait(readWriteLock); + readWriteLock->unlock(); } }; @@ -163,79 +169,79 @@ void tst_QWaitCondition::wait_QMutex() { int x; for (int i = 0; i < iterations; ++i) { - { - QMutex mutex; - QWaitCondition cond; - - mutex.lock(); - - cond.wakeOne(); - QVERIFY(!cond.wait(&mutex, 1)); - - cond.wakeAll(); - QVERIFY(!cond.wait(&mutex, 1)); - - mutex.unlock(); - } - - { - // test multiple threads waiting on separate wait conditions - wait_QMutex_Thread_1 thread[ThreadCount]; - - for (x = 0; x < ThreadCount; ++x) { - thread[x].mutex.lock(); - thread[x].start(); - // wait for thread to start - QVERIFY(thread[x].cond.wait(&thread[x].mutex, 1000)); - thread[x].mutex.unlock(); - } - - for (x = 0; x < ThreadCount; ++x) { - QVERIFY(thread[x].isRunning()); - QVERIFY(!thread[x].isFinished()); - } - - for (x = 0; x < ThreadCount; ++x) { - thread[x].mutex.lock(); - thread[x].cond.wakeOne(); - thread[x].mutex.unlock(); - } - - for (x = 0; x < ThreadCount; ++x) { - QVERIFY(thread[x].wait(1000)); - } - } - - { - // test multiple threads waiting on a wait condition - QMutex mutex; - QWaitCondition cond1, cond2; - wait_QMutex_Thread_2 thread[ThreadCount]; - - mutex.lock(); - for (x = 0; x < ThreadCount; ++x) { - thread[x].mutex = &mutex; - thread[x].cond = (x < ThreadCount / 2) ? &cond1 : &cond2; - thread[x].start(); - // wait for thread to start - QVERIFY(thread[x].started.wait(&mutex, 1000)); - } - mutex.unlock(); - - for (x = 0; x < ThreadCount; ++x) { - QVERIFY(thread[x].isRunning()); - QVERIFY(!thread[x].isFinished()); - } - - mutex.lock(); - cond1.wakeAll(); - cond2.wakeAll(); - mutex.unlock(); - - for (x = 0; x < ThreadCount; ++x) { - QVERIFY(thread[x].wait(1000)); - } - } + { + QMutex mutex; + QWaitCondition cond; + + mutex.lock(); + + cond.wakeOne(); + QVERIFY(!cond.wait(&mutex, 1)); + + cond.wakeAll(); + QVERIFY(!cond.wait(&mutex, 1)); + + mutex.unlock(); + } + + { + // test multiple threads waiting on separate wait conditions + wait_QMutex_Thread_1 thread[ThreadCount]; + + for (x = 0; x < ThreadCount; ++x) { + thread[x].mutex.lock(); + thread[x].start(); + // wait for thread to start + QVERIFY(thread[x].cond.wait(&thread[x].mutex, 1000)); + thread[x].mutex.unlock(); + } + + for (x = 0; x < ThreadCount; ++x) { + QVERIFY(thread[x].isRunning()); + QVERIFY(!thread[x].isFinished()); + } + + for (x = 0; x < ThreadCount; ++x) { + thread[x].mutex.lock(); + thread[x].cond.wakeOne(); + thread[x].mutex.unlock(); + } + + for (x = 0; x < ThreadCount; ++x) { + QVERIFY(thread[x].wait(1000)); + } + } + + { + // test multiple threads waiting on a wait condition + QMutex mutex; + QWaitCondition cond1, cond2; + wait_QMutex_Thread_2 thread[ThreadCount]; + + mutex.lock(); + for (x = 0; x < ThreadCount; ++x) { + thread[x].mutex = &mutex; + thread[x].cond = (x < ThreadCount / 2) ? &cond1 : &cond2; + thread[x].start(); + // wait for thread to start + QVERIFY(thread[x].started.wait(&mutex, 1000)); + } + mutex.unlock(); + + for (x = 0; x < ThreadCount; ++x) { + QVERIFY(thread[x].isRunning()); + QVERIFY(!thread[x].isFinished()); + } + + mutex.lock(); + cond1.wakeAll(); + cond2.wakeAll(); + mutex.unlock(); + + for (x = 0; x < ThreadCount; ++x) { + QVERIFY(thread[x].wait(1000)); + } + } } } @@ -282,94 +288,99 @@ void tst_QWaitCondition::wait_QReadWriteLock() int x; for (int i = 0; i < iterations; ++i) { - { - QReadWriteLock readWriteLock; - QWaitCondition waitCondition; - - readWriteLock.lockForRead(); - - waitCondition.wakeOne(); - QVERIFY(!waitCondition.wait(&readWriteLock, 1)); - - waitCondition.wakeAll(); - QVERIFY(!waitCondition.wait(&readWriteLock, 1)); - - readWriteLock.unlock(); - } - - { - QReadWriteLock readWriteLock; - QWaitCondition waitCondition; - - readWriteLock.lockForWrite(); - - waitCondition.wakeOne(); - QVERIFY(!waitCondition.wait(&readWriteLock, 1)); - - waitCondition.wakeAll(); - QVERIFY(!waitCondition.wait(&readWriteLock, 1)); - - readWriteLock.unlock(); - } - - { - // test multiple threads waiting on separate wait conditions - wait_QReadWriteLock_Thread_1 thread[ThreadCount]; - - for (x = 0; x < ThreadCount; ++x) { - thread[x].readWriteLock.lockForRead(); - thread[x].start(); - // wait for thread to start - QVERIFY(thread[x].cond.wait(&thread[x].readWriteLock, 1000)); - thread[x].readWriteLock.unlock(); - } - - for (x = 0; x < ThreadCount; ++x) { - QVERIFY(thread[x].isRunning()); - QVERIFY(!thread[x].isFinished()); - } - - for (x = 0; x < ThreadCount; ++x) { - thread[x].readWriteLock.lockForRead(); - thread[x].cond.wakeOne(); - thread[x].readWriteLock.unlock(); - } - - for (x = 0; x < ThreadCount; ++x) { - QVERIFY(thread[x].wait(1000)); - } - } - - { - // test multiple threads waiting on a wait condition - QReadWriteLock readWriteLock; - QWaitCondition cond1, cond2; - wait_QReadWriteLock_Thread_2 thread[ThreadCount]; - - readWriteLock.lockForWrite(); - for (x = 0; x < ThreadCount; ++x) { - thread[x].readWriteLock = &readWriteLock; - thread[x].cond = (x < ThreadCount / 2) ? &cond1 : &cond2; - thread[x].start(); - // wait for thread to start - QVERIFY(thread[x].started.wait(&readWriteLock, 1000)); - } - readWriteLock.unlock(); - - for (x = 0; x < ThreadCount; ++x) { - QVERIFY(thread[x].isRunning()); - QVERIFY(!thread[x].isFinished()); - } - - readWriteLock.lockForWrite(); - cond1.wakeAll(); - cond2.wakeAll(); - readWriteLock.unlock(); - - for (x = 0; x < ThreadCount; ++x) { - QVERIFY(thread[x].wait(1000)); - } - } + { + QReadWriteLock readWriteLock; + QWaitCondition waitCondition; + + readWriteLock.lockForRead(); + + waitCondition.wakeOne(); + QVERIFY(!waitCondition.wait(&readWriteLock, 1)); + + waitCondition.wakeAll(); + QVERIFY(!waitCondition.wait(&readWriteLock, 1)); + + readWriteLock.unlock(); + } + + { + QReadWriteLock readWriteLock; + QWaitCondition waitCondition; + + readWriteLock.lockForWrite(); + + waitCondition.wakeOne(); + QVERIFY(!waitCondition.wait(&readWriteLock, 1)); + + waitCondition.wakeAll(); + QVERIFY(!waitCondition.wait(&readWriteLock, 1)); + + readWriteLock.unlock(); + } + + { + // test multiple threads waiting on separate wait conditions + wait_QReadWriteLock_Thread_1 thread[ThreadCount]; + + for (x = 0; x < ThreadCount; ++x) { + thread[x].readWriteLock.lockForRead(); + thread[x].start(); + // wait for thread to start +#if defined(Q_OS_SYMBIAN) && defined(Q_CC_WINSCW) + // Symbian emulator startup simultaneously with this thread causes additional delay + QVERIFY(thread[x].cond.wait(&thread[x].readWriteLock, 10000)); +#else + QVERIFY(thread[x].cond.wait(&thread[x].readWriteLock, 1000)); +#endif + thread[x].readWriteLock.unlock(); + } + + for (x = 0; x < ThreadCount; ++x) { + QVERIFY(thread[x].isRunning()); + QVERIFY(!thread[x].isFinished()); + } + + for (x = 0; x < ThreadCount; ++x) { + thread[x].readWriteLock.lockForRead(); + thread[x].cond.wakeOne(); + thread[x].readWriteLock.unlock(); + } + + for (x = 0; x < ThreadCount; ++x) { + QVERIFY(thread[x].wait(1000)); + } + } + + { + // test multiple threads waiting on a wait condition + QReadWriteLock readWriteLock; + QWaitCondition cond1, cond2; + wait_QReadWriteLock_Thread_2 thread[ThreadCount]; + + readWriteLock.lockForWrite(); + for (x = 0; x < ThreadCount; ++x) { + thread[x].readWriteLock = &readWriteLock; + thread[x].cond = (x < ThreadCount / 2) ? &cond1 : &cond2; + thread[x].start(); + // wait for thread to start + QVERIFY(thread[x].started.wait(&readWriteLock, 1000)); + } + readWriteLock.unlock(); + + for (x = 0; x < ThreadCount; ++x) { + QVERIFY(thread[x].isRunning()); + QVERIFY(!thread[x].isFinished()); + } + + readWriteLock.lockForWrite(); + cond1.wakeAll(); + cond2.wakeAll(); + readWriteLock.unlock(); + + for (x = 0; x < ThreadCount; ++x) { + QVERIFY(thread[x].wait(1000)); + } + } } } @@ -386,7 +397,7 @@ public: QWaitCondition *cond; inline wake_Thread() - : mutex(0), cond(0) + : mutex(0), cond(0) { } static inline void sleep(ulong s) @@ -394,14 +405,14 @@ public: void run() { - mutex->lock(); - ++count; + mutex->lock(); + ++count; dummy.wakeOne(); // this wakeup should be lost - started.wakeOne(); + started.wakeOne(); dummy.wakeAll(); // this one too - cond->wait(mutex); + cond->wait(mutex); --count; - mutex->unlock(); + mutex->unlock(); } }; @@ -419,7 +430,7 @@ public: QWaitCondition *cond; inline wake_Thread_2() - : readWriteLock(0), cond(0) + : readWriteLock(0), cond(0) { } static inline void sleep(ulong s) @@ -427,14 +438,14 @@ public: void run() { - readWriteLock->lockForWrite(); - ++count; + readWriteLock->lockForWrite(); + ++count; dummy.wakeOne(); // this wakeup should be lost started.wakeOne(); dummy.wakeAll(); // this one too - cond->wait(readWriteLock); + cond->wait(readWriteLock); --count; - readWriteLock->unlock(); + readWriteLock->unlock(); } }; @@ -445,194 +456,194 @@ void tst_QWaitCondition::wakeOne() int x; // wake up threads, one at a time for (int i = 0; i < iterations; ++i) { - QMutex mutex; - QWaitCondition cond; + QMutex mutex; + QWaitCondition cond; - // QMutex - wake_Thread thread[ThreadCount]; - bool thread_exited[ThreadCount]; - - mutex.lock(); - for (x = 0; x < ThreadCount; ++x) { - thread[x].mutex = &mutex; - thread[x].cond = &cond; - thread_exited[x] = FALSE; - thread[x].start(); - // wait for thread to start - QVERIFY(thread[x].started.wait(&mutex, 1000)); - // make sure wakeups are not queued... if nothing is - // waiting at the time of the wakeup, nothing happens - QVERIFY(!thread[x].dummy.wait(&mutex, 1)); - } - mutex.unlock(); - - QCOMPARE(wake_Thread::count, ThreadCount); - - // wake up threads one at a time - for (x = 0; x < ThreadCount; ++x) { - mutex.lock(); - cond.wakeOne(); - QVERIFY(!cond.wait(&mutex, 1)); - QVERIFY(!thread[x].dummy.wait(&mutex, 1)); - mutex.unlock(); - - int exited = 0; - for (int y = 0; y < ThreadCount; ++y) { - if (thread_exited[y]) - continue; - if (thread[y].wait(exited > 0 ? 1 : 1000)) { - thread_exited[y] = TRUE; - ++exited; - } - } - - QCOMPARE(exited, 1); - QCOMPARE(wake_Thread::count, ThreadCount - (x + 1)); - } - - QCOMPARE(wake_Thread::count, 0); + // QMutex + wake_Thread thread[ThreadCount]; + bool thread_exited[ThreadCount]; + + mutex.lock(); + for (x = 0; x < ThreadCount; ++x) { + thread[x].mutex = &mutex; + thread[x].cond = &cond; + thread_exited[x] = FALSE; + thread[x].start(); + // wait for thread to start + QVERIFY(thread[x].started.wait(&mutex, 1000)); + // make sure wakeups are not queued... if nothing is + // waiting at the time of the wakeup, nothing happens + QVERIFY(!thread[x].dummy.wait(&mutex, 1)); + } + mutex.unlock(); - // QReadWriteLock - QReadWriteLock readWriteLock; - wake_Thread_2 rwthread[ThreadCount]; + QCOMPARE(wake_Thread::count, ThreadCount); + // wake up threads one at a time + for (x = 0; x < ThreadCount; ++x) { + mutex.lock(); + cond.wakeOne(); + QVERIFY(!cond.wait(&mutex, COND_WAIT_TIME)); + QVERIFY(!thread[x].dummy.wait(&mutex, 1)); + mutex.unlock(); + + int exited = 0; + for (int y = 0; y < ThreadCount; ++y) { + if (thread_exited[y]) + continue; + if (thread[y].wait(exited > 0 ? 1 : 1000)) { + thread_exited[y] = TRUE; + ++exited; + } + } + + QCOMPARE(exited, 1); + QCOMPARE(wake_Thread::count, ThreadCount - (x + 1)); + } + + QCOMPARE(wake_Thread::count, 0); + + // QReadWriteLock + QReadWriteLock readWriteLock; + wake_Thread_2 rwthread[ThreadCount]; + + readWriteLock.lockForWrite(); + for (x = 0; x < ThreadCount; ++x) { + rwthread[x].readWriteLock = &readWriteLock; + rwthread[x].cond = &cond; + thread_exited[x] = FALSE; + rwthread[x].start(); + // wait for thread to start + QVERIFY(rwthread[x].started.wait(&readWriteLock, 1000)); + // make sure wakeups are not queued... if nothing is + // waiting at the time of the wakeup, nothing happens + QVERIFY(!rwthread[x].dummy.wait(&readWriteLock, 1)); + } + readWriteLock.unlock(); + + QCOMPARE(wake_Thread_2::count, ThreadCount); + + // wake up threads one at a time + for (x = 0; x < ThreadCount; ++x) { readWriteLock.lockForWrite(); - for (x = 0; x < ThreadCount; ++x) { - rwthread[x].readWriteLock = &readWriteLock; - rwthread[x].cond = &cond; - thread_exited[x] = FALSE; - rwthread[x].start(); - // wait for thread to start - QVERIFY(rwthread[x].started.wait(&readWriteLock, 1000)); - // make sure wakeups are not queued... if nothing is - // waiting at the time of the wakeup, nothing happens - QVERIFY(!rwthread[x].dummy.wait(&readWriteLock, 1)); - } - readWriteLock.unlock(); - - QCOMPARE(wake_Thread_2::count, ThreadCount); - - // wake up threads one at a time - for (x = 0; x < ThreadCount; ++x) { - readWriteLock.lockForWrite(); - cond.wakeOne(); - QVERIFY(!cond.wait(&readWriteLock, 1)); - QVERIFY(!rwthread[x].dummy.wait(&readWriteLock, 1)); - readWriteLock.unlock(); - - int exited = 0; - for (int y = 0; y < ThreadCount; ++y) { - if (thread_exited[y]) - continue; - if (rwthread[y].wait(exited > 0 ? 1 : 1000)) { - thread_exited[y] = TRUE; - ++exited; - } - } - - QCOMPARE(exited, 1); - QCOMPARE(wake_Thread_2::count, ThreadCount - (x + 1)); - } - - QCOMPARE(wake_Thread_2::count, 0); + cond.wakeOne(); + QVERIFY(!cond.wait(&readWriteLock, COND_WAIT_TIME)); + QVERIFY(!rwthread[x].dummy.wait(&readWriteLock, 1)); + readWriteLock.unlock(); + + int exited = 0; + for (int y = 0; y < ThreadCount; ++y) { + if (thread_exited[y]) + continue; + if (rwthread[y].wait(exited > 0 ? 1 : 1000)) { + thread_exited[y] = TRUE; + ++exited; + } + } + + QCOMPARE(exited, 1); + QCOMPARE(wake_Thread_2::count, ThreadCount - (x + 1)); + } + + QCOMPARE(wake_Thread_2::count, 0); } // wake up threads, two at a time for (int i = 0; i < iterations; ++i) { - QMutex mutex; - QWaitCondition cond; + QMutex mutex; + QWaitCondition cond; // QMutex - wake_Thread thread[ThreadCount]; - bool thread_exited[ThreadCount]; - - mutex.lock(); - for (x = 0; x < ThreadCount; ++x) { - thread[x].mutex = &mutex; - thread[x].cond = &cond; - thread_exited[x] = FALSE; - thread[x].start(); - // wait for thread to start - QVERIFY(thread[x].started.wait(&mutex, 1000)); - // make sure wakeups are not queued... if nothing is - // waiting at the time of the wakeup, nothing happens - QVERIFY(!thread[x].dummy.wait(&mutex, 1)); - } - mutex.unlock(); - - QCOMPARE(wake_Thread::count, ThreadCount); - - // wake up threads one at a time - for (x = 0; x < ThreadCount; x += 2) { - mutex.lock(); - cond.wakeOne(); - cond.wakeOne(); - QVERIFY(!cond.wait(&mutex, 1)); - QVERIFY(!thread[x].dummy.wait(&mutex, 1)); - QVERIFY(!thread[x + 1].dummy.wait(&mutex, 1)); - mutex.unlock(); - - int exited = 0; - for (int y = 0; y < ThreadCount; ++y) { - if (thread_exited[y]) - continue; - if (thread[y].wait(exited > 0 ? 1 : 1000)) { - thread_exited[y] = TRUE; - ++exited; - } - } - - QCOMPARE(exited, 2); - QCOMPARE(wake_Thread::count, ThreadCount - (x + 2)); - } - - QCOMPARE(wake_Thread::count, 0); + wake_Thread thread[ThreadCount]; + bool thread_exited[ThreadCount]; + + mutex.lock(); + for (x = 0; x < ThreadCount; ++x) { + thread[x].mutex = &mutex; + thread[x].cond = &cond; + thread_exited[x] = FALSE; + thread[x].start(); + // wait for thread to start + QVERIFY(thread[x].started.wait(&mutex, 1000)); + // make sure wakeups are not queued... if nothing is + // waiting at the time of the wakeup, nothing happens + QVERIFY(!thread[x].dummy.wait(&mutex, 1)); + } + mutex.unlock(); + + QCOMPARE(wake_Thread::count, ThreadCount); + + // wake up threads one at a time + for (x = 0; x < ThreadCount; x += 2) { + mutex.lock(); + cond.wakeOne(); + cond.wakeOne(); + QVERIFY(!cond.wait(&mutex, COND_WAIT_TIME)); + QVERIFY(!thread[x].dummy.wait(&mutex, 1)); + QVERIFY(!thread[x + 1].dummy.wait(&mutex, 1)); + mutex.unlock(); + + int exited = 0; + for (int y = 0; y < ThreadCount; ++y) { + if (thread_exited[y]) + continue; + if (thread[y].wait(exited > 0 ? 1 : 1000)) { + thread_exited[y] = TRUE; + ++exited; + } + } + + QCOMPARE(exited, 2); + QCOMPARE(wake_Thread::count, ThreadCount - (x + 2)); + } + + QCOMPARE(wake_Thread::count, 0); // QReadWriteLock QReadWriteLock readWriteLock; wake_Thread_2 rwthread[ThreadCount]; - readWriteLock.lockForWrite(); - for (x = 0; x < ThreadCount; ++x) { - rwthread[x].readWriteLock = &readWriteLock; - rwthread[x].cond = &cond; - thread_exited[x] = FALSE; - rwthread[x].start(); - // wait for thread to start - QVERIFY(rwthread[x].started.wait(&readWriteLock, 1000)); - // make sure wakeups are not queued... if nothing is - // waiting at the time of the wakeup, nothing happens - QVERIFY(!rwthread[x].dummy.wait(&readWriteLock, 1)); - } - readWriteLock.unlock(); - - QCOMPARE(wake_Thread_2::count, ThreadCount); - - // wake up threads one at a time - for (x = 0; x < ThreadCount; x += 2) { - readWriteLock.lockForWrite(); - cond.wakeOne(); - cond.wakeOne(); - QVERIFY(!cond.wait(&readWriteLock, 1)); - QVERIFY(!rwthread[x].dummy.wait(&readWriteLock, 1)); - QVERIFY(!rwthread[x + 1].dummy.wait(&readWriteLock, 1)); - readWriteLock.unlock(); - - int exited = 0; - for (int y = 0; y < ThreadCount; ++y) { - if (thread_exited[y]) - continue; - if (rwthread[y].wait(exited > 0 ? 1 : 1000)) { - thread_exited[y] = TRUE; - ++exited; - } - } - - QCOMPARE(exited, 2); - QCOMPARE(wake_Thread_2::count, ThreadCount - (x + 2)); - } - - QCOMPARE(wake_Thread_2::count, 0); + readWriteLock.lockForWrite(); + for (x = 0; x < ThreadCount; ++x) { + rwthread[x].readWriteLock = &readWriteLock; + rwthread[x].cond = &cond; + thread_exited[x] = FALSE; + rwthread[x].start(); + // wait for thread to start + QVERIFY(rwthread[x].started.wait(&readWriteLock, 1000)); + // make sure wakeups are not queued... if nothing is + // waiting at the time of the wakeup, nothing happens + QVERIFY(!rwthread[x].dummy.wait(&readWriteLock, 1)); + } + readWriteLock.unlock(); + + QCOMPARE(wake_Thread_2::count, ThreadCount); + + // wake up threads one at a time + for (x = 0; x < ThreadCount; x += 2) { + readWriteLock.lockForWrite(); + cond.wakeOne(); + cond.wakeOne(); + QVERIFY(!cond.wait(&readWriteLock, COND_WAIT_TIME)); + QVERIFY(!rwthread[x].dummy.wait(&readWriteLock, 1)); + QVERIFY(!rwthread[x + 1].dummy.wait(&readWriteLock, 1)); + readWriteLock.unlock(); + + int exited = 0; + for (int y = 0; y < ThreadCount; ++y) { + if (thread_exited[y]) + continue; + if (rwthread[y].wait(exited > 0 ? 1 : 1000)) { + thread_exited[y] = TRUE; + ++exited; + } + } + + QCOMPARE(exited, 2); + QCOMPARE(wake_Thread_2::count, ThreadCount - (x + 2)); + } + + QCOMPARE(wake_Thread_2::count, 0); } } @@ -640,69 +651,69 @@ void tst_QWaitCondition::wakeAll() { int x; for (int i = 0; i < iterations; ++i) { - QMutex mutex; - QWaitCondition cond; + QMutex mutex; + QWaitCondition cond; - // QMutex - wake_Thread thread[ThreadCount]; - - mutex.lock(); - for (x = 0; x < ThreadCount; ++x) { - thread[x].mutex = &mutex; - thread[x].cond = &cond; - thread[x].start(); - // wait for thread to start - QVERIFY(thread[x].started.wait(&mutex, 1000)); - } - mutex.unlock(); - - QCOMPARE(wake_Thread::count, ThreadCount); - - // wake up all threads at once - mutex.lock(); - cond.wakeAll(); - QVERIFY(!cond.wait(&mutex, 1)); - mutex.unlock(); - - int exited = 0; - for (x = 0; x < ThreadCount; ++x) { - if (thread[x].wait(1000)) - ++exited; - } - - QCOMPARE(exited, ThreadCount); - QCOMPARE(wake_Thread::count, 0); + // QMutex + wake_Thread thread[ThreadCount]; - // QReadWriteLock - QReadWriteLock readWriteLock; - wake_Thread_2 rwthread[ThreadCount]; - - readWriteLock.lockForWrite(); - for (x = 0; x < ThreadCount; ++x) { - rwthread[x].readWriteLock = &readWriteLock; - rwthread[x].cond = &cond; - rwthread[x].start(); - // wait for thread to start - QVERIFY(rwthread[x].started.wait(&readWriteLock, 1000)); - } - readWriteLock.unlock(); - - QCOMPARE(wake_Thread_2::count, ThreadCount); - - // wake up all threads at once - readWriteLock.lockForWrite(); - cond.wakeAll(); - QVERIFY(!cond.wait(&readWriteLock, 1)); - readWriteLock.unlock(); - - exited = 0; - for (x = 0; x < ThreadCount; ++x) { - if (rwthread[x].wait(1000)) - ++exited; - } - - QCOMPARE(exited, ThreadCount); - QCOMPARE(wake_Thread_2::count, 0); + mutex.lock(); + for (x = 0; x < ThreadCount; ++x) { + thread[x].mutex = &mutex; + thread[x].cond = &cond; + thread[x].start(); + // wait for thread to start + QVERIFY(thread[x].started.wait(&mutex, 1000)); + } + mutex.unlock(); + + QCOMPARE(wake_Thread::count, ThreadCount); + + // wake up all threads at once + mutex.lock(); + cond.wakeAll(); + QVERIFY(!cond.wait(&mutex, COND_WAIT_TIME)); + mutex.unlock(); + + int exited = 0; + for (x = 0; x < ThreadCount; ++x) { + if (thread[x].wait(1000)) + ++exited; + } + + QCOMPARE(exited, ThreadCount); + QCOMPARE(wake_Thread::count, 0); + + // QReadWriteLock + QReadWriteLock readWriteLock; + wake_Thread_2 rwthread[ThreadCount]; + + readWriteLock.lockForWrite(); + for (x = 0; x < ThreadCount; ++x) { + rwthread[x].readWriteLock = &readWriteLock; + rwthread[x].cond = &cond; + rwthread[x].start(); + // wait for thread to start + QVERIFY(rwthread[x].started.wait(&readWriteLock, 1000)); + } + readWriteLock.unlock(); + + QCOMPARE(wake_Thread_2::count, ThreadCount); + + // wake up all threads at once + readWriteLock.lockForWrite(); + cond.wakeAll(); + QVERIFY(!cond.wait(&readWriteLock, COND_WAIT_TIME)); + readWriteLock.unlock(); + + exited = 0; + for (x = 0; x < ThreadCount; ++x) { + if (rwthread[x].wait(1000)) + ++exited; + } + + QCOMPARE(exited, ThreadCount); + QCOMPARE(wake_Thread_2::count, 0); } } diff --git a/tests/auto/qwidget/qwidget.pro b/tests/auto/qwidget/qwidget.pro index d394400..59c1753 100644 --- a/tests/auto/qwidget/qwidget.pro +++ b/tests/auto/qwidget/qwidget.pro @@ -14,4 +14,8 @@ LIBS += -framework Security -framework AppKit OBJECTIVE_SOURCES += tst_qwidget_mac_helpers.mm } -!wince*:win32: LIBS += -luser32 -lgdi32 +symbian { + INCLUDEPATH += $$MW_LAYER_SYSTEMINCLUDE +} + +!wince*:!symbian:win32: LIBS += -luser32 -lgdi32 diff --git a/tests/auto/qwidget/tst_qwidget.cpp b/tests/auto/qwidget/tst_qwidget.cpp index 34971a9..5c5eb8e 100644 --- a/tests/auto/qwidget/tst_qwidget.cpp +++ b/tests/auto/qwidget/tst_qwidget.cpp @@ -67,6 +67,14 @@ #include <qcalendarwidget.h> #include <qmainwindow.h> #include <QtGui/qpaintengine.h> +#include <private/qbackingstore_p.h> + +#ifdef Q_WS_S60 +#include <avkon.hrh> // EEikStatusPaneUidTitle +#include <akntitle.h> // CAknTitlePane +#include <akncontext.h> // CAknContextPane +#include <eikspane.h> // CEikStatusPane +#endif #ifdef Q_WS_QWS # include <qscreen_qws.h> @@ -355,6 +363,9 @@ private slots: void focusWidget_task254563(); void rectOutsideCoordinatesLimit_task144779(); + void setGraphicsEffect(); + + void destroyBackingStore(); private: bool ensureScreenSize(int width, int height); @@ -1079,6 +1090,9 @@ void tst_QWidget::enabledPropagation() void tst_QWidget::acceptDropsPropagation() { +#ifdef QT_NO_DRAGANDDROP + QSKIP("Drag'n drop disabled in this build", SkipAll); +#else QWidget *childWidget = new QWidget(testWidget); childWidget->show(); QVERIFY(!testWidget->acceptDrops()); @@ -1122,6 +1136,7 @@ void tst_QWidget::acceptDropsPropagation() QVERIFY(childWidget->acceptDrops()); QVERIFY(!grandChildWidget->acceptDrops()); QVERIFY(grandChildWidget->testAttribute(Qt::WA_DropSiteRegistered)); +#endif } void tst_QWidget::isEnabledTo() @@ -1409,7 +1424,7 @@ void tst_QWidget::mapFromAndTo() subWindow2->setGeometry(75, 75, 100, 100); subSubWindow->setGeometry(10, 10, 10, 10); -#ifndef Q_OS_WINCE //still no proper minimizing +#if !defined (Q_OS_WINCE) && !defined(Q_OS_SYMBIAN) //still no proper minimizing //update visibility if (windowMinimized) { if (!windowHidden) { @@ -1814,6 +1829,9 @@ void tst_QWidget::windowState() pos = QPoint(10,10); size = QSize(100,100); } +#elif defined(Q_WS_S60) + QPoint pos = QPoint(10,10); + QSize size = QSize(100,100); #else const QPoint pos(500, 500); const QSize size(200, 200); @@ -1928,7 +1946,7 @@ void tst_QWidget::showMaximized() layouted.showNormal(); QVERIFY(!(layouted.windowState() & Qt::WindowMaximized)); -#if !defined(Q_WS_QWS) && !defined(Q_OS_WINCE) +#if !defined(Q_WS_QWS) && !defined(Q_OS_WINCE) && !defined(Q_WS_S60) //embedded may choose a different size to fit on the screen. QCOMPARE(layouted.size(), layouted.sizeHint()); #endif @@ -1969,6 +1987,13 @@ void tst_QWidget::showMaximized() QVERIFY(widget.isMaximized()); } + { + QWidget widget; + widget.setGeometry(0, 0, 10, 10); + widget.showMaximized(); + QVERIFY(widget.size().width() > 20 && widget.size().height() > 20); + } + #ifdef QT3_SUPPORT #if !defined(Q_WS_QWS) //embedded respects max/min sizes by design -- maybe wrong design, but that's the way it is now. @@ -2020,7 +2045,7 @@ void tst_QWidget::showFullScreen() layouted.showNormal(); QVERIFY(!(layouted.windowState() & Qt::WindowFullScreen)); -#if !defined(Q_WS_QWS) && !defined(Q_OS_WINCE) +#if !defined(Q_WS_QWS) && !defined(Q_OS_WINCE) && !defined (Q_WS_S60) //embedded may choose a different size to fit on the screen. QCOMPARE(layouted.size(), layouted.sizeHint()); #endif @@ -2451,6 +2476,9 @@ void tst_QWidget::hideWhenFocusWidgetIsChild() actualFocusWidget.sprintf("%p %s %s", qApp->focusWidget(), qApp->focusWidget()->objectName().toLatin1().constData(), qApp->focusWidget()->metaObject()->className()); expectedFocusWidget.sprintf("%p %s %s", edit2, edit2->objectName().toLatin1().constData(), edit2->metaObject()->className()); QCOMPARE(actualFocusWidget, expectedFocusWidget); + + delete edit2; + delete parentWidget; } void tst_QWidget::normalGeometry() @@ -3354,6 +3382,9 @@ void tst_QWidget::widgetAt() #if defined(Q_OS_WINCE) QEXPECT_FAIL("", "Windows CE does only support rectangular regions", Continue); //See also task 147191 #endif +#if defined(Q_OS_SYMBIAN) + QEXPECT_FAIL("", "Symbian/S60 does only support rectangular regions", Continue); //See also task 147191 +#endif QCOMPARE(QApplication::widgetAt(100,100)->objectName(), w1->objectName()); QCOMPARE(QApplication::widgetAt(101,101)->objectName(), w2->objectName()); @@ -3369,6 +3400,9 @@ void tst_QWidget::widgetAt() #if defined(Q_OS_WINCE) QEXPECT_FAIL("", "Windows CE does only support rectangular regions", Continue); //See also task 147191 #endif +#if defined(Q_OS_SYMBIAN) + QEXPECT_FAIL("", "Symbian/S60 does only support rectangular regions", Continue); //See also task 147191 +#endif QVERIFY(QApplication::widgetAt(100,100) == w1); QVERIFY(QApplication::widgetAt(101,101) == w2); @@ -3428,6 +3462,34 @@ QString textPropertyToString(Display *display, XTextProperty& text_prop) #endif +#if defined(Q_WS_S60) +// Returns the application's status pane control, if not present returns NULL. +static CCoeControl* GetStatusPaneControl( TInt aPaneId ) +{ + const TUid paneUid = { aPaneId }; + + CEikStatusPane* statusPane = CEikonEnv::Static()->AppUiFactory()->StatusPane(); + if (statusPane && statusPane->PaneCapabilities(paneUid).IsPresent()){ + CCoeControl* control = NULL; + // ControlL shouldn't leave because the pane is present + TRAPD(err, control = statusPane->ControlL(paneUid)); + return err != KErrNone ? NULL : control; + } + return NULL; +} +// Returns the application's title pane, if not present returns NULL. +static CAknTitlePane* TitlePane() +{ + return static_cast<CAknTitlePane*>(GetStatusPaneControl(EEikStatusPaneUidTitle)); +} + +// Returns the application's title pane, if not present returns NULL. +static CAknContextPane* ContextPane() +{ + return static_cast<CAknContextPane*>(GetStatusPaneControl(EEikStatusPaneUidContext)); +} +#endif + static QString visibleWindowTitle(QWidget *window, Qt::WindowState state = Qt::WindowNoState) { QString vTitle; @@ -3490,6 +3552,13 @@ static QString visibleWindowTitle(QWidget *window, Qt::WindowState state = Qt::W if (win) vTitle = win->caption(); } +#elif defined (Q_WS_S60) + CAknTitlePane* titlePane = TitlePane(); + if(titlePane) + { + const TDesC* nTitle = titlePane->Text(); + vTitle = QString::fromUtf16(nTitle->Ptr(), nTitle->Length()); + } #endif return vTitle; @@ -3520,6 +3589,9 @@ void tst_QWidget::windowTitle() void tst_QWidget::windowIconText() { +#ifdef Q_OS_SYMBIAN + QSKIP("Symbian/S60 windows don't have window icon text", SkipAll); +#endif QWidget widget(0); widget.setWindowTitle("Application Name"); @@ -5312,7 +5384,7 @@ void tst_QWidget::moveChild() QCOMPARE(pos, child.pos()); QCOMPARE(parent.r, QRegion(oldGeometry) - child.geometry()); -#ifndef Q_WS_MAC +#if !defined(Q_WS_MAC) // should be scrolled in backingstore QCOMPARE(child.r, QRegion()); #endif @@ -6108,7 +6180,10 @@ void tst_QWidget::compatibilityChildInsertedEvents() EventRecorder::EventList() << qMakePair(&widget, QEvent::PolishRequest) << qMakePair(&widget, QEvent::Type(QEvent::User + 1)) -#if defined(Q_WS_X11) || defined(Q_WS_WIN) || defined(Q_WS_QWS) +#ifdef Q_OS_SYMBIAN + << qMakePair(&widget, QEvent::SymbianDeferredFocusChanged) +#endif +#if defined(Q_WS_X11) || defined(Q_WS_WIN) || defined(Q_WS_QWS) || defined(Q_WS_S60) << qMakePair(&widget, QEvent::UpdateRequest) #endif ; @@ -6203,7 +6278,10 @@ void tst_QWidget::compatibilityChildInsertedEvents() << qMakePair(&widget, QEvent::PolishRequest) << qMakePair(&widget, QEvent::Type(QEvent::User + 1)) << qMakePair(&widget, QEvent::Type(QEvent::User + 2)) -#if defined(Q_WS_X11) || defined(Q_WS_WIN) || defined(Q_WS_QWS) +#ifdef Q_OS_SYMBIAN + << qMakePair(&widget, QEvent::SymbianDeferredFocusChanged) +#endif +#if defined(Q_WS_X11) || defined(Q_WS_WIN) || defined(Q_WS_QWS) || defined(Q_WS_S60) << qMakePair(&widget, QEvent::UpdateRequest) #endif ; @@ -6298,7 +6376,10 @@ void tst_QWidget::compatibilityChildInsertedEvents() << qMakePair(&widget, QEvent::PolishRequest) << qMakePair(&widget, QEvent::Type(QEvent::User + 1)) << qMakePair(&widget, QEvent::Type(QEvent::User + 2)) -#if defined(Q_WS_X11) || defined(Q_WS_WIN) || defined(Q_WS_QWS) +#ifdef Q_OS_SYMBIAN + << qMakePair(&widget, QEvent::SymbianDeferredFocusChanged) +#endif +#if defined(Q_WS_X11) || defined(Q_WS_WIN) || defined(Q_WS_QWS) || defined(Q_WS_S60) << qMakePair(&widget, QEvent::UpdateRequest) #endif ; @@ -7352,7 +7433,7 @@ void tst_QWidget::repaintWhenChildDeleted() } #endif ColorWidget w(0, Qt::red); -#ifndef Q_OS_WINCE +#if !defined(Q_OS_WINCE) && !defined(Q_WS_S60) QPoint startPoint = QApplication::desktop()->availableGeometry(&w).topLeft(); startPoint.rx() += 50; startPoint.ry() += 50; @@ -7386,7 +7467,7 @@ void tst_QWidget::repaintWhenChildDeleted() void tst_QWidget::hideOpaqueChildWhileHidden() { ColorWidget w(0, Qt::red); -#ifndef Q_OS_WINCE +#if !defined(Q_OS_WINCE) && !defined(Q_WS_S60) QPoint startPoint = QApplication::desktop()->availableGeometry(&w).topLeft(); startPoint.rx() += 50; startPoint.ry() += 50; @@ -8261,7 +8342,12 @@ void tst_QWidget::customDpi() custom->logicalDpiX(); QCOMPARE(custom->metricCallCount, 1); child->logicalDpiX(); +#ifdef Q_WS_S60 + // QWidget::metric is not recursive on Symbian + QCOMPARE(custom->metricCallCount, 1); +#else QCOMPARE(custom->metricCallCount, 2); +#endif delete topLevel; } @@ -9102,8 +9188,8 @@ void tst_QWidget::toplevelLineEditFocus() #endif QTest::qWait(200); - QCOMPARE(QApplication::activeWindow(), &w); - QCOMPARE(QApplication::focusWidget(), &w); + QCOMPARE(QApplication::activeWindow(), (QWidget*)&w); + QCOMPARE(QApplication::focusWidget(), (QWidget*)&w); } void tst_QWidget::focusWidget_task254563() @@ -9121,6 +9207,32 @@ void tst_QWidget::focusWidget_task254563() QVERIFY(top.focusWidget() != widget); //dangling pointer } +void tst_QWidget::destroyBackingStore() +{ + UpdateWidget w; + w.show(); + +#ifdef Q_WS_X11 + qt_x11_wait_for_window_manager(&w); +#endif + QApplication::processEvents(); + + w.reset(); + w.update(); + delete qt_widget_private(&w)->topData()->backingStore; + qt_widget_private(&w)->topData()->backingStore = 0; + qt_widget_private(&w)->topData()->backingStore = new QWidgetBackingStore(&w); + + w.update(); + QApplication::processEvents(); + QCOMPARE(w.numPaintEvents, 1); + + // Check one more time, because the second time around does more caching. + w.update(); + QApplication::processEvents(); + QCOMPARE(w.numPaintEvents, 2); +} + void tst_QWidget::rectOutsideCoordinatesLimit_task144779() { QWidget main; @@ -9163,11 +9275,42 @@ void tst_QWidget::inputFocus_task257832() QSKIP("No input context", SkipSingle); widget->setFocus(); context->setFocusWidget(widget); - QCOMPARE(context->focusWidget(), widget); + QCOMPARE(context->focusWidget(), static_cast<QWidget*>(widget)); widget->setReadOnly(true); QVERIFY(!context->focusWidget()); delete widget; } +void tst_QWidget::setGraphicsEffect() +{ + // Check that we don't have any effect by default. + QWidget *widget = new QWidget; + QVERIFY(!widget->graphicsEffect()); + + // SetGet check. + QPointer<QGraphicsEffect> blurEffect = new QGraphicsBlurEffect; + widget->setGraphicsEffect(blurEffect); + QCOMPARE(widget->graphicsEffect(), static_cast<QGraphicsEffect *>(blurEffect)); + + // Ensure the existing effect is deleted when setting a new one. + QPointer<QGraphicsEffect> shadowEffect = new QGraphicsDropShadowEffect; + widget->setGraphicsEffect(shadowEffect); + QVERIFY(!blurEffect); + QCOMPARE(widget->graphicsEffect(), static_cast<QGraphicsEffect *>(shadowEffect)); + blurEffect = new QGraphicsBlurEffect; + + // Ensure the effect is uninstalled when setting it on a new target. + QWidget *anotherWidget = new QWidget; + anotherWidget->setGraphicsEffect(blurEffect); + widget->setGraphicsEffect(blurEffect); + QVERIFY(!anotherWidget->graphicsEffect()); + QVERIFY(!shadowEffect); + + // Ensure the existing effect is deleted when deleting the widget. + delete widget; + QVERIFY(!blurEffect); + delete anotherWidget; +} + QTEST_MAIN(tst_QWidget) #include "tst_qwidget.moc" diff --git a/tests/auto/qwindowsurface/tst_qwindowsurface.cpp b/tests/auto/qwindowsurface/tst_qwindowsurface.cpp index 85705da..00b1f17 100644 --- a/tests/auto/qwindowsurface/tst_qwindowsurface.cpp +++ b/tests/auto/qwindowsurface/tst_qwindowsurface.cpp @@ -158,6 +158,8 @@ void tst_QWindowSurface::flushOutsidePaintEvent() qt_x11_wait_for_window_manager(&w); #elif defined(Q_WS_QWS) QApplication::sendPostedEvents(); //for the glib event loop +#elif defined(Q_WS_S60) + QTest::qWait(5000); #endif VERIFY_COLOR(w.geometry(), w.color); w.reset(); diff --git a/tests/auto/qwineventnotifier/qwineventnotifier.pro b/tests/auto/qwineventnotifier/qwineventnotifier.pro index d985df6..0c8bd2b 100644 --- a/tests/auto/qwineventnotifier/qwineventnotifier.pro +++ b/tests/auto/qwineventnotifier/qwineventnotifier.pro @@ -1,6 +1,3 @@ load(qttest_p4) SOURCES += tst_qwineventnotifier.cpp - QT = core - - diff --git a/tests/auto/qwizard/qwizard.pro b/tests/auto/qwizard/qwizard.pro index 867ab9c..a22e45c 100644 --- a/tests/auto/qwizard/qwizard.pro +++ b/tests/auto/qwizard/qwizard.pro @@ -5,5 +5,6 @@ SOURCES += tst_qwizard.cpp #SOURCES += /home/jasplin/dev/research/qwizard/src/qwizard.cpp #HEADERS += /home/jasplin/dev/research/qwizard/src/qwizard.h RESOURCES = qwizard.qrc +TARGET.EPOCHEAPSIZE = 0x200000 0xF00000 diff --git a/tests/auto/qwmatrix/qwmatrix.pro b/tests/auto/qwmatrix/qwmatrix.pro index d2ecd49..58ea706 100644 --- a/tests/auto/qwmatrix/qwmatrix.pro +++ b/tests/auto/qwmatrix/qwmatrix.pro @@ -1,6 +1,6 @@ load(qttest_p4) SOURCES += tst_qwmatrix.cpp -unix:!mac:LIBS+=-lm +unix:!mac:!symbian*:LIBS+=-lm diff --git a/tests/auto/qwritelocker/qwritelocker.pro b/tests/auto/qwritelocker/qwritelocker.pro index 42cdd45..acae4ef 100644 --- a/tests/auto/qwritelocker/qwritelocker.pro +++ b/tests/auto/qwritelocker/qwritelocker.pro @@ -1,5 +1,3 @@ load(qttest_p4) SOURCES += tst_qwritelocker.cpp QT = core - - diff --git a/tests/auto/qwsembedwidget/qwsembedwidget.pro b/tests/auto/qwsembedwidget/qwsembedwidget.pro index 3ee12a3..bd3c32c 100644 --- a/tests/auto/qwsembedwidget/qwsembedwidget.pro +++ b/tests/auto/qwsembedwidget/qwsembedwidget.pro @@ -1,5 +1,3 @@ load(qttest_p4) SOURCES += tst_qwsembedwidget.cpp - - - +QT = core diff --git a/tests/auto/qwsinputmethod/qwsinputmethod.pro b/tests/auto/qwsinputmethod/qwsinputmethod.pro index 9721acc..69cce78 100644 --- a/tests/auto/qwsinputmethod/qwsinputmethod.pro +++ b/tests/auto/qwsinputmethod/qwsinputmethod.pro @@ -1,5 +1,3 @@ load(qttest_p4) SOURCES += tst_qwsinputmethod.cpp - - - +QT = core diff --git a/tests/auto/qwswindowsystem/qwswindowsystem.pro b/tests/auto/qwswindowsystem/qwswindowsystem.pro index 8276081..49466ee 100644 --- a/tests/auto/qwswindowsystem/qwswindowsystem.pro +++ b/tests/auto/qwswindowsystem/qwswindowsystem.pro @@ -1,5 +1,3 @@ load(qttest_p4) SOURCES += tst_qwswindowsystem.cpp - - - +QT = core diff --git a/tests/auto/qxml/qxml.pro b/tests/auto/qxml/qxml.pro index 6c767cb..304fc54 100644 --- a/tests/auto/qxml/qxml.pro +++ b/tests/auto/qxml/qxml.pro @@ -3,7 +3,7 @@ load(qttest_p4) SOURCES += tst_qxml.cpp QT = core xml -wince*: { +wince*|symbian*: { addFiles.sources = 0x010D.xml addFiles.path = . DEPLOYMENT += addFiles diff --git a/tests/auto/qxmlformatter/qxmlformatter.pro b/tests/auto/qxmlformatter/qxmlformatter.pro index e3d16f6..4c00d73 100644 --- a/tests/auto/qxmlformatter/qxmlformatter.pro +++ b/tests/auto/qxmlformatter/qxmlformatter.pro @@ -3,7 +3,7 @@ SOURCES += tst_qxmlformatter.cpp include (../xmlpatterns.pri) -wince*:{ +wince*|symbian*:{ addFiles.sources = baselines input addFiles.path = . DEPLOYMENT += addFiles diff --git a/tests/auto/qxmlquery/qxmlquery.pro b/tests/auto/qxmlquery/qxmlquery.pro index 3db3734..cfab564 100644 --- a/tests/auto/qxmlquery/qxmlquery.pro +++ b/tests/auto/qxmlquery/qxmlquery.pro @@ -10,15 +10,15 @@ RESOURCES = input.qrc QT += network -!wince* { -DEFINES += SRCDIR=\\\"$$PWD/\\\" -} else { -DEFINES += SRCDIR=\\\"./\\\" +wince* { + DEFINES += SRCDIR=\\\"./\\\" +} else:!symbian { + DEFINES += SRCDIR=\\\"$$PWD/\\\" } include (../xmlpatterns.pri) -wince*: { +wince*|symbian*: { addFiles.sources = pushBaselines input.xml addFiles.path = . diff --git a/tests/auto/qxmlquery/tst_qxmlquery.cpp b/tests/auto/qxmlquery/tst_qxmlquery.cpp index a7275bb..7096630 100644 --- a/tests/auto/qxmlquery/tst_qxmlquery.cpp +++ b/tests/auto/qxmlquery/tst_qxmlquery.cpp @@ -65,6 +65,10 @@ #include "TestFundament.h" #include "../network-settings.h" +#if defined(Q_OS_SYMBIAN) +#define SRCDIR "" +#endif + /*! \class tst_QXmlQuery \internal @@ -88,6 +92,7 @@ public: , m_pushTestsCount(0) , m_testNetwork(true) { + Q_SET_DEFAULT_IAP } private Q_SLOTS: diff --git a/tests/auto/qxmlsimplereader/qxmlsimplereader.pro b/tests/auto/qxmlsimplereader/qxmlsimplereader.pro index e7e8007..bfdec58 100644 --- a/tests/auto/qxmlsimplereader/qxmlsimplereader.pro +++ b/tests/auto/qxmlsimplereader/qxmlsimplereader.pro @@ -12,8 +12,8 @@ QT += network xml QT -= gui -wince*: { +wince*|symbian*: { addFiles.sources = encodings parser xmldocs addFiles.path = . DEPLOYMENT += addFiles -}
\ No newline at end of file +} diff --git a/tests/auto/qxmlsimplereader/tst_qxmlsimplereader.cpp b/tests/auto/qxmlsimplereader/tst_qxmlsimplereader.cpp index 83eb7cc..44057ec 100644 --- a/tests/auto/qxmlsimplereader/tst_qxmlsimplereader.cpp +++ b/tests/auto/qxmlsimplereader/tst_qxmlsimplereader.cpp @@ -117,7 +117,7 @@ void XmlServer::run() i += cnt; sock->flush(); QTest::qSleep(1); - + if (quit_soon) { sock->abort(); break; @@ -576,11 +576,15 @@ void tst_QXmlSimpleReader::inputFromSocket() { QFETCH(QString, file_name); +#if defined(Q_OS_SYMBIAN) + QSKIP("Symbian: Skipped due to problems in Open C and QtNetwork", SkipAll); +#endif + #if defined(Q_OS_WIN32) && (defined(Q_CC_INTEL) || defined(Q_CC_MINGW) || defined(Q_CC_MSVC_NET)) QSKIP("Regression caused by QHOstInfo change 294548, see task 202231.", SkipAll); #endif QTcpSocket sock; - sock.connectToHost("localhost", TEST_PORT); + sock.connectToHost(QHostAddress::LocalHost, TEST_PORT); const bool connectionSuccess = sock.waitForConnected(); if(!connectionSuccess) { diff --git a/tests/auto/qxmlstream/qxmlstream.pro b/tests/auto/qxmlstream/qxmlstream.pro index 46eed56..ac03d42 100644 --- a/tests/auto/qxmlstream/qxmlstream.pro +++ b/tests/auto/qxmlstream/qxmlstream.pro @@ -4,7 +4,7 @@ SOURCES += tst_qxmlstream.cpp QT = core xml network -wince*: { +wince*|symbian*: { addFiles.sources = data XML-Test-Suite addFiles.path = . DEPLOYMENT += addFiles diff --git a/tests/auto/qzip/qzip.pro b/tests/auto/qzip/qzip.pro index 17b9543..632c743 100644 --- a/tests/auto/qzip/qzip.pro +++ b/tests/auto/qzip/qzip.pro @@ -1,11 +1,11 @@ load(qttest_p4) SOURCES += tst_qzip.cpp -wince*: { +wince*|symbian: { addFiles.sources = testdata addFiles.path = . DEPLOYMENT += addFiles - DEFINES += SRCDIR=\\\".\\\" + !symbian:DEFINES += SRCDIR=\\\".\\\" } else { DEFINES += SRCDIR=\\\"$$PWD\\\" } diff --git a/tests/auto/qzip/tst_qzip.cpp b/tests/auto/qzip/tst_qzip.cpp index 152d268..c9a55f3 100644 --- a/tests/auto/qzip/tst_qzip.cpp +++ b/tests/auto/qzip/tst_qzip.cpp @@ -44,6 +44,10 @@ #include <private/qzipwriter_p.h> #include <private/qzipreader_p.h> +#ifdef Q_OS_SYMBIAN +#define SRCDIR "." +#endif + class tst_QZip : public QObject { Q_OBJECT diff --git a/tests/auto/symbian/orientationchange/orientationchange.pro b/tests/auto/symbian/orientationchange/orientationchange.pro new file mode 100644 index 0000000..08b34f9 --- /dev/null +++ b/tests/auto/symbian/orientationchange/orientationchange.pro @@ -0,0 +1,7 @@ +load(qttest_p4) +HEADERS += +SOURCES += tst_orientationchange.cpp + +symbian { + INCLUDEPATH += $$MW_LAYER_SYSTEMINCLUDE +} diff --git a/tests/auto/symbian/orientationchange/tst_orientationchange.cpp b/tests/auto/symbian/orientationchange/tst_orientationchange.cpp new file mode 100644 index 0000000..480b748 --- /dev/null +++ b/tests/auto/symbian/orientationchange/tst_orientationchange.cpp @@ -0,0 +1,165 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, 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. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QtTest/QtTest> + +#ifdef Q_OS_SYMBIAN + +#include <eikenv.h> +#include <aknappui.h> + +class tst_orientationchange : public QObject +{ + Q_OBJECT +public: + tst_orientationchange(){}; + ~tst_orientationchange(){}; + +private slots: + void resizeEventOnOrientationChange(); +}; + +class TestWidget : public QWidget +{ +public: + TestWidget(QWidget *parent = 0); + + void reset(); +public: + void resizeEvent(QResizeEvent *event); + +public: + QSize resizeEventSize; + int resizeEventCount; +}; + +TestWidget::TestWidget(QWidget *parent) +: QWidget(parent) +{ + reset(); +} + +void TestWidget::reset() +{ + resizeEventSize = QSize(); + resizeEventCount = 0; +} + +void TestWidget::resizeEvent(QResizeEvent *event) +{ + QWidget::resizeEvent(event); + + // Size delivered in first resize event is stored. + if (!resizeEventCount) + resizeEventSize = event->size(); + + resizeEventCount++; +} + +void tst_orientationchange::resizeEventOnOrientationChange() +{ + // This will test that when orientation 'changes', then + // at most one resize event is generated. + + TestWidget *normalWidget = new TestWidget(); + TestWidget *fullScreenWidget = new TestWidget(); + TestWidget *maximizedWidget = new TestWidget(); + + fullScreenWidget->showFullScreen(); + maximizedWidget->showMaximized(); + normalWidget->show(); + + QCoreApplication::sendPostedEvents(); + QCoreApplication::sendPostedEvents(); + + QCOMPARE(fullScreenWidget->resizeEventCount, 1); + QCOMPARE(fullScreenWidget->size(), fullScreenWidget->resizeEventSize); + QCOMPARE(maximizedWidget->resizeEventCount, 1); + QCOMPARE(maximizedWidget->size(), maximizedWidget->resizeEventSize); + QCOMPARE(normalWidget->resizeEventCount, 1); + QCOMPARE(normalWidget->size(), normalWidget->resizeEventSize); + + fullScreenWidget->reset(); + maximizedWidget->reset(); + normalWidget->reset(); + + // Assumes that Qt application is AVKON application. + CAknAppUi *appUi = static_cast<CAknAppUi*>(CEikonEnv::Static()->EikAppUi()); + + // Determine 'opposite' orientation to the current orientation. + + CAknAppUi::TAppUiOrientation orientation = CAknAppUi::EAppUiOrientationLandscape; + if (fullScreenWidget->size().width() > fullScreenWidget->size().height()) { + orientation = CAknAppUi::EAppUiOrientationPortrait; + } + + TRAPD(err, appUi->SetOrientationL(orientation)); + + QCoreApplication::sendPostedEvents(); + QCoreApplication::sendPostedEvents(); + + // setOrientationL is not guaranteed to change orientation + // (if emulator configured to support just portrait or landscape, then + // setOrientationL call shouldn't do anything). + // So let's ensure that we do not get resize event twice. + + QVERIFY(fullScreenWidget->resizeEventCount <= 1); + if (fullScreenWidget->resizeEventCount) { + QCOMPARE(fullScreenWidget->size(), fullScreenWidget->resizeEventSize); + } + QVERIFY(maximizedWidget->resizeEventCount <= 1); + if (fullScreenWidget->resizeEventCount) { + QCOMPARE(maximizedWidget->size(), maximizedWidget->resizeEventSize); + } + QCOMPARE(normalWidget->resizeEventCount, 0); + + TRAP(err, appUi->SetOrientationL(CAknAppUi::EAppUiOrientationUnspecified)); + + delete normalWidget; + delete fullScreenWidget; + delete maximizedWidget; +} + +QTEST_MAIN(tst_orientationchange) +#include "tst_orientationchange.moc" +#else +QTEST_NOOP_MAIN +#endif diff --git a/tests/auto/symbian/qmainexceptions/qmainexceptions.pro b/tests/auto/symbian/qmainexceptions/qmainexceptions.pro new file mode 100644 index 0000000..16111c1 --- /dev/null +++ b/tests/auto/symbian/qmainexceptions/qmainexceptions.pro @@ -0,0 +1,3 @@ +load(qttest_p4) +HEADERS += +SOURCES += tst_qmainexceptions.cpp diff --git a/tests/auto/symbian/qmainexceptions/tst_qmainexceptions.cpp b/tests/auto/symbian/qmainexceptions/tst_qmainexceptions.cpp new file mode 100644 index 0000000..ae70ce3 --- /dev/null +++ b/tests/auto/symbian/qmainexceptions/tst_qmainexceptions.cpp @@ -0,0 +1,468 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, 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. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QtTest/QtTest> +#include <e32base.h> +#include <typeinfo> +#include <stdexcept> +#include <euserhl.h> + +#ifdef Q_OS_SYMBIAN + +typedef void TLeavingFunc(); + +class tst_qmainexceptions : public QObject +{ + Q_OBJECT +public: + tst_qmainexceptions(){}; + ~tst_qmainexceptions(){}; + + void TestSchedulerCatchesError(TLeavingFunc* f, int error); + void TestSymbianRoundTrip(int leave, int trap); + void TestStdRoundTrip(const std::exception& thrown, const std::exception& caught); + + bool event(QEvent *event); + +public slots: + void initTestCase(); +private slots: + void trap(); + void cleanupstack(); + void leave(); + void testTranslateBadAlloc(); + void testTranslateBigAlloc(); + void testRoundTrip(); + void testTrap(); + void testPropagation(); + void testDtor1(); + void testDtor2(); + void testNestedExceptions(); + void testScopedPointer(); + void testHybrid(); +}; + +class CDummy : public CBase +{ +public: + CDummy(){} + ~CDummy(){} +}; + +void tst_qmainexceptions::initTestCase() +{ +} + +void tst_qmainexceptions::trap() +{ + TTrapHandler *th= User::TrapHandler(); + QVERIFY((int)th); +} + +void tst_qmainexceptions::cleanupstack() +{ + __UHEAP_MARK; + //fails if OOM + CDummy* dummy1 = new (ELeave) CDummy; + __UHEAP_CHECK(1); + CleanupStack::PushL(dummy1); + CleanupStack::PopAndDestroy(dummy1); + __UHEAP_MARKEND; +} + +void tst_qmainexceptions::leave() +{ + __UHEAP_MARK; + CDummy* dummy1 = 0; + TRAPD(err,{ + CDummy* csDummy = new (ELeave) CDummy; + CleanupStack::PushL(csDummy); + __UHEAP_FAILNEXT(1); + dummy1 = new (ELeave) CDummy; + //CleanupStack::PopAndDestroy(csDummy); not executed as previous line throws + }); + QCOMPARE(err,KErrNoMemory); + QVERIFY(!((int)dummy1)); + __UHEAP_MARKEND; +} + +class CTestActive : public CActive +{ +public: + CTestActive(TLeavingFunc* aFunc) : CActive(EPriorityStandard), iFunc(aFunc) + { + CActiveScheduler::Add(this); + } + ~CTestActive() + { + Cancel(); + } + void DoCancel() {} + void Test() + { + // complete this AO in a nested scheduler, to make it synchronous + TRequestStatus* s = &iStatus; + SetActive(); + User::RequestComplete(s, KErrNone); + CActiveScheduler::Start(); + } + void RunL() + { + (*iFunc)(); + CActiveScheduler::Stop(); // will only get here if iFunc does not leave + } + TInt RunError(TInt aError) + { + error = aError; + CActiveScheduler::Stop(); // will only get here if iFunc leaves + return KErrNone; + } +public: + TLeavingFunc* iFunc; + int error; +}; + +void tst_qmainexceptions::TestSchedulerCatchesError(TLeavingFunc* f, int error) +{ + CTestActive *act = new(ELeave) CTestActive(f); + act->Test(); + QCOMPARE(act->error, error); + delete act; +} + +void ThrowBadAlloc() +{ + throw std::bad_alloc(); +} + +void TranslateThrowBadAllocL() +{ + QT_TRYCATCH_LEAVING(ThrowBadAlloc()); +} + +void tst_qmainexceptions::testTranslateBadAlloc() +{ + // bad_alloc should give KErrNoMemory in an AO + TestSchedulerCatchesError(&TranslateThrowBadAllocL, KErrNoMemory); +} + +void BigAlloc() +{ + // allocate too much memory - it's expected that 100M ints is too much, but keep doubling if not. + int *x = 0; + int n = 100000000; + do { + x = new int[n]; + delete [] x; + n = n * 2; + } while (x); +} + +void TranslateBigAllocL() +{ + QT_TRYCATCH_LEAVING(BigAlloc()); +} + +void tst_qmainexceptions::testTranslateBigAlloc() +{ + // this test will fail if new does not throw on failure, otherwise should give KErrNoMemory in AO + TestSchedulerCatchesError(&TranslateBigAllocL, KErrNoMemory); +} + +void tst_qmainexceptions::TestSymbianRoundTrip(int leave, int trap) +{ + // check that leave converted to exception, converted to error gives expected error code + int trapped; + QT_TRYCATCH_ERROR( + trapped, + QT_TRAP_THROWING( + User::LeaveIfError(leave))); + QCOMPARE(trap, trapped); +} + +void tst_qmainexceptions::TestStdRoundTrip(const std::exception& thrown, const std::exception& caught) +{ + bool ok = false; + try { + QT_TRAP_THROWING(qt_symbian_exception2LeaveL(thrown)); + } catch (const std::exception& ex) { + const std::type_info& exType = typeid(ex); + const std::type_info& caughtType = typeid(caught); + QCOMPARE(exType, caughtType); + ok = true; + } + QCOMPARE(ok, true); +} + +void tst_qmainexceptions::testRoundTrip() +{ + for (int e=-50; e<0; e++) + TestSymbianRoundTrip(e, e); + TestSymbianRoundTrip(KErrNone, KErrNone); + // positive error codes are not errors + TestSymbianRoundTrip(1, KErrNone); + TestSymbianRoundTrip(1000000000, KErrNone); + TestStdRoundTrip(std::bad_alloc(), std::bad_alloc()); + TestStdRoundTrip(std::invalid_argument("abc"), std::invalid_argument("")); + TestStdRoundTrip(std::underflow_error("abc"), std::underflow_error("")); + TestStdRoundTrip(std::overflow_error("abc"), std::overflow_error("")); +} + +void tst_qmainexceptions::testTrap() +{ + // testing qt_exception2SymbianLeaveL + TRAPD(err, qt_symbian_exception2LeaveL(std::bad_alloc())); + QCOMPARE(err, KErrNoMemory); +} + +bool tst_qmainexceptions::event(QEvent *aEvent) +{ + if (aEvent->type() == QEvent::User+1) + throw std::bad_alloc(); + else if (aEvent->type() == QEvent::User+2) { + QEvent event(QEvent::Type(QEvent::User+1)); + QApplication::sendEvent(this, &event); + } + return QObject::event(aEvent); +} + +void tst_qmainexceptions::testPropagation() +{ + // test exception thrown from event is propagated back to sender + QEvent event(QEvent::Type(QEvent::User+1)); + bool caught = false; + try { + QApplication::sendEvent(this, &event); + } catch (const std::bad_alloc&) { + caught = true; + } + QCOMPARE(caught, true); + + // testing nested events propagate back to top level sender + caught = false; + QEvent event2(QEvent::Type(QEvent::User+2)); + try { + QApplication::sendEvent(this, &event2); + } catch (const std::bad_alloc&) { + caught = true; + } + QCOMPARE(caught, true); +} + +void tst_qmainexceptions::testDtor1() +{ + // destructors work on exception + int i = 0; + struct SAutoInc { + SAutoInc(int& aI) : i(aI) { ++i; } + ~SAutoInc() { --i; } + int &i; + } ai(i); + QCOMPARE(i, 1); + try { + SAutoInc ai2(i); + QCOMPARE(i, 2); + throw std::bad_alloc(); + QFAIL("should not get here"); + } catch (const std::bad_alloc&) { + QCOMPARE(i, 1); + } + QCOMPARE(i, 1); +} + +void tst_qmainexceptions::testDtor2() +{ + // memory is cleaned up correctly on exception + // this crashes with winscw compiler build < 481 + __UHEAP_MARK; + try { + QString str("abc"); + str += "def"; + throw std::bad_alloc(); + QFAIL("should not get here"); + } catch (const std::bad_alloc&) { } + __UHEAP_MARKEND; +} + +void tst_qmainexceptions::testNestedExceptions() +{ + // throwing exceptions while handling exceptions + struct Oops { + Oops* next; + Oops(int level) : next(level > 0 ? new Oops(level-1) : 0) {} + ~Oops() { + try { throw std::bad_alloc(); } + catch (const std::exception&) {delete next;} + } + }; + try { + Oops oops(5); + throw std::bad_alloc(); + } + catch (const std::exception&) {} +} + +class CTestRef : public CBase +{ +public: + CTestRef(int& aX) : iX(aX) { iX++; } + ~CTestRef() { iX--; } + int& iX; +}; + +void tst_qmainexceptions::testScopedPointer() +{ + int x = 0; + { + QScopedPointer<CTestRef> ptr(q_check_ptr(new CTestRef(x))); + QCOMPARE(x, 1); + } + QCOMPARE(x, 0); + try { + QScopedPointer<CTestRef> ptr(q_check_ptr(new CTestRef(x))); + QCOMPARE(x, 1); + throw 1; + } catch (int) { + QCOMPARE(x, 0); + } + QCOMPARE(x, 0); +} + +int dtorFired[20]; +int* recDtor; + +class CDtorOrder : public CBase +{ +public: + CDtorOrder(TInt aId) : iId(aId) {} + ~CDtorOrder() { *(recDtor++)=iId; } + TInt iId; +}; + +class QDtorOrder +{ +public: + QDtorOrder(int aId) : iId(aId) {} + ~QDtorOrder() { *(recDtor++)=iId; } + int iId; +}; + +class RDtorOrder : public RHandleBase +{ +public: + TInt Connect(TInt aId) {iId = aId; SetHandle(aId); return KErrNone; } + void Close() { *(recDtor++)=iId; } + TInt iId; +}; + +enum THybridAction {EHybridLeave, EHybridThrow, EHybridPass}; + +void HybridFuncLX(THybridAction aAction) +{ + recDtor = dtorFired; + QDtorOrder q1(1); + {QDtorOrder q2(2);} + CDtorOrder* c1 = new(ELeave) CDtorOrder(11); + CleanupStack::PushL(c1); + {LManagedHandle<RDtorOrder> r1; + r1->Connect(21) OR_LEAVE;} + CDtorOrder* c2 = new(ELeave) CDtorOrder(12); + CleanupStack::PushL(c2); + QDtorOrder q3(3); + LManagedHandle<RDtorOrder> r2; + r2->Connect(22) OR_LEAVE; + CDtorOrder* c3 = new(ELeave) CDtorOrder(13); + CleanupStack::PushL(c3); + CleanupStack::PopAndDestroy(c3); + QDtorOrder q4(4); + switch (aAction) + { + case EHybridLeave: + User::Leave(KErrNotFound); + break; + case EHybridThrow: + throw std::bad_alloc(); + break; + default: + break; + } + CleanupStack::PopAndDestroy(2); +} + +void tst_qmainexceptions::testHybrid() +{ + TRAPD(error, + QT_TRYCATCH_LEAVING( + HybridFuncLX(EHybridLeave); + ) ); + QCOMPARE(error, KErrNotFound); + int expected1[] = {2, 21, 13, 12, 11, 4, 22, 3, 1}; + QCOMPARE(int(sizeof(expected1)/sizeof(int)), int(recDtor - dtorFired)); + for (int i=0; i<sizeof(expected1)/sizeof(int); i++) + QCOMPARE(expected1[i], dtorFired[i]); + + TRAP(error, + QT_TRYCATCH_LEAVING( + HybridFuncLX(EHybridThrow); + ) ); + QCOMPARE(error, KErrNoMemory); + int expected2[] = {2, 21, 13, 4, 22, 3, 1, 12, 11}; + QCOMPARE(int(sizeof(expected2)/sizeof(int)), int(recDtor - dtorFired)); + for (int i=0; i<sizeof(expected2)/sizeof(int); i++) + QCOMPARE(expected2[i], dtorFired[i]); + + TRAP(error, + QT_TRYCATCH_LEAVING( + HybridFuncLX(EHybridPass); + ) ); + QCOMPARE(error, KErrNone); + int expected3[] = {2, 21, 13, 12, 11, 4, 22, 3, 1}; + QCOMPARE(int(sizeof(expected3)/sizeof(int)), int(recDtor - dtorFired)); + for (int i=0; i<sizeof(expected3)/sizeof(int); i++) + QCOMPARE(expected3[i], dtorFired[i]); +} + + +QTEST_MAIN(tst_qmainexceptions) +#include "tst_qmainexceptions.moc" +#else +QTEST_NOOP_MAIN +#endif diff --git a/tests/auto/symbian/qsymbiantests.pro b/tests/auto/symbian/qsymbiantests.pro new file mode 100644 index 0000000..648335e --- /dev/null +++ b/tests/auto/symbian/qsymbiantests.pro @@ -0,0 +1,2 @@ +TEMPLATE = subdirs +SUBDIRS = qmainexceptions orientationchange
\ No newline at end of file diff --git a/tests/auto/tests.xml b/tests/auto/tests.xml index ccfc380..f197de0 100644 --- a/tests/auto/tests.xml +++ b/tests/auto/tests.xml @@ -128,6 +128,7 @@ <Test name="qgraphicslayout" location="tests/auto/qgraphicslayout/tst_qgraphicslayout" /> <Test name="qgraphicslayoutitem" location="tests/auto/qgraphicslayoutitem/tst_qgraphicslayoutitem" /> <Test name="qgraphicslinearlayout" location="tests/auto/qgraphicslinearlayout/tst_qgraphicslinearlayout" /> + <Test name="qgraphicsanchorlayout" location="tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout" /> <Test name="qgraphicspixmapitem" location="tests/auto/qgraphicspixmapitem/tst_qgraphicspixmapitem" /> <Test name="qgraphicspolygonitem" location="tests/auto/qgraphicspolygonitem/tst_qgraphicspolygonitem" /> <Test name="qgraphicsproxywidget" location="tests/auto/qgraphicsproxywidget/tst_qgraphicsproxywidget" /> @@ -538,6 +539,7 @@ <Test id="qgraphicslayout" /> <Test id="qgraphicslayoutitem" /> <Test id="qgraphicslinearlayout" /> + <Test id="qgraphicsanchorlayout" /> <Test id="qgraphicspixmapitem" /> <Test id="qgraphicspolygonitem" /> <Test id="qgraphicsproxywidget" /> diff --git a/tests/auto/uiloader/uiloader/tst_uiloader.cpp b/tests/auto/uiloader/uiloader/tst_uiloader.cpp index 553fb9c..505ef0a 100644 --- a/tests/auto/uiloader/uiloader/tst_uiloader.cpp +++ b/tests/auto/uiloader/uiloader/tst_uiloader.cpp @@ -46,6 +46,9 @@ #include <QApplication> #include <QDir> +#ifdef Q_OS_SYMBIAN +#define SRCDIR "" +#endif class uiLoaderAutotest: public QObject { diff --git a/tests/auto/uiloader/uiloader/uiloader.pro b/tests/auto/uiloader/uiloader/uiloader.pro index 1c4da0b..d99df00 100644 --- a/tests/auto/uiloader/uiloader/uiloader.pro +++ b/tests/auto/uiloader/uiloader/uiloader.pro @@ -3,7 +3,7 @@ load(qttest_p4) TEMPLATE = app !embedded:CONFIG += uitools TARGET = ../tst_uiloader -DEFINES += SRCDIR=\\\"$$PWD\\\" +!symbian:DEFINES += SRCDIR=\\\"$$PWD\\\" win32 { CONFIG(debug, debug|release) { @@ -16,7 +16,7 @@ win32 { QT += xml svg network contains(QT_CONFIG, qt3support): QT += qt3support -wince*: { +wince*|symbian: { configuration.sources = ../*.ini configuration.path = . diff --git a/tests/auto/windowsmobile/test/testSimpleWidget_current.png b/tests/auto/windowsmobile/test/testSimpleWidget_current.png Binary files differindex 5cbc2bb..09a10a3 100644 --- a/tests/auto/windowsmobile/test/testSimpleWidget_current.png +++ b/tests/auto/windowsmobile/test/testSimpleWidget_current.png diff --git a/tests/auto/windowsmobile/test/tst_windowsmobile.cpp b/tests/auto/windowsmobile/test/tst_windowsmobile.cpp index 73ea0a6..091504c 100644 --- a/tests/auto/windowsmobile/test/tst_windowsmobile.cpp +++ b/tests/auto/windowsmobile/test/tst_windowsmobile.cpp @@ -62,14 +62,14 @@ public: #endif } -#ifdef Q_OS_WINCE_WM +#if defined(Q_OS_WINCE_WM) && defined(_WIN32_WCE) && _WIN32_WCE <= 0x501 private slots: void testMainWindowAndMenuBar(); void testSimpleWidget(); #endif }; -#ifdef Q_OS_WINCE_WM +#if defined(Q_OS_WINCE_WM) && defined(_WIN32_WCE) && _WIN32_WCE <= 0x501 bool qt_wince_is_platform(const QString &platformString) { wchar_t tszPlatform[64]; @@ -120,8 +120,6 @@ void openMenu() void compareScreenshots(const QString &image1, const QString &image2) { - if (qt_wince_is_smartphone()) - QSKIP("This test is only for Windows Mobile", SkipAll); QImage screenShot(image1); QImage original(image2); @@ -145,6 +143,9 @@ void takeScreenShot(const QString filename) void tst_WindowsMobile::testMainWindowAndMenuBar() { + if (qt_wince_is_smartphone()) + QSKIP("This test is only for Windows Mobile", SkipAll); + QProcess process; process.start("testQMenuBar.exe"); QCOMPARE(process.state(), QProcess::Running); @@ -158,6 +159,9 @@ void tst_WindowsMobile::testMainWindowAndMenuBar() void tst_WindowsMobile::testSimpleWidget() { + if (qt_wince_is_smartphone()) + QSKIP("This test is only for Windows Mobile", SkipAll); + QMenuBar menubar; menubar.show(); QWidget maximized; diff --git a/tests/auto/windowsmobile/testQMenuBar/main.cpp b/tests/auto/windowsmobile/testQMenuBar/main.cpp index 4949dbb..f615c48 100644 --- a/tests/auto/windowsmobile/testQMenuBar/main.cpp +++ b/tests/auto/windowsmobile/testQMenuBar/main.cpp @@ -48,8 +48,6 @@ int main(int argc, char * argv[]) { - int widgetNum = 20; - QList<QWidget*> widgets; QApplication app(argc, argv); diff --git a/tests/auto/xmlpatterns/tst_xmlpatterns.cpp b/tests/auto/xmlpatterns/tst_xmlpatterns.cpp index f054f57..a81b1da 100644 --- a/tests/auto/xmlpatterns/tst_xmlpatterns.cpp +++ b/tests/auto/xmlpatterns/tst_xmlpatterns.cpp @@ -102,6 +102,8 @@ tst_XmlPatterns::tst_XmlPatterns() : m_generatedTests(0) , m_command(QLatin1String("xmlpatterns")) , m_dontRun(false) { + Q_SET_DEFAULT_IAP + Q_ASSERT(m_normalizeTestName.isValid()); Q_ASSERT(m_filenameInStderr.isValid()); } |