summaryrefslogtreecommitdiffstats
path: root/tests/auto/other
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/other')
-rw-r--r--tests/auto/other/atwrapper/.gitignore1
-rw-r--r--tests/auto/other/atwrapper/TODO17
-rw-r--r--tests/auto/other/atwrapper/atWrapper.cpp648
-rw-r--r--tests/auto/other/atwrapper/atWrapper.h93
-rw-r--r--tests/auto/other/atwrapper/atWrapper.pro24
-rw-r--r--tests/auto/other/atwrapper/atWrapperAutotest.cpp78
-rw-r--r--tests/auto/other/atwrapper/desert.ini14
-rw-r--r--tests/auto/other/atwrapper/ephron.ini14
-rw-r--r--tests/auto/other/atwrapper/gullgubben.ini12
-rw-r--r--tests/auto/other/atwrapper/honshu.ini16
-rw-r--r--tests/auto/other/atwrapper/kramer.ini12
-rw-r--r--tests/auto/other/atwrapper/scruffy.ini15
-rw-r--r--tests/auto/other/atwrapper/spareribs.ini14
-rw-r--r--tests/auto/other/atwrapper/titan.ini13
-rw-r--r--tests/auto/other/baselineexample/baselineexample.pro18
-rw-r--r--tests/auto/other/baselineexample/tst_baselineexample.cpp146
-rw-r--r--tests/auto/other/compiler/.gitignore1
-rw-r--r--tests/auto/other/compiler/baseclass.cpp51
-rw-r--r--tests/auto/other/compiler/baseclass.h60
-rw-r--r--tests/auto/other/compiler/compiler.pro7
-rw-r--r--tests/auto/other/compiler/derivedclass.cpp48
-rw-r--r--tests/auto/other/compiler/derivedclass.h52
-rw-r--r--tests/auto/other/compiler/tst_compiler.cpp656
-rw-r--r--tests/auto/other/headersclean/headersclean.pro7
-rw-r--r--tests/auto/other/headersclean/tst_headersclean.cpp75
-rw-r--r--tests/auto/other/maketestselftest/checktest/checktest.pro7
-rw-r--r--tests/auto/other/maketestselftest/checktest/main.cpp99
-rw-r--r--tests/auto/other/maketestselftest/features/dump_subdirs.prf4
-rw-r--r--tests/auto/other/maketestselftest/maketestselftest.pro6
-rw-r--r--tests/auto/other/maketestselftest/test/test.pro18
-rw-r--r--tests/auto/other/maketestselftest/tst_maketestselftest.cpp561
-rw-r--r--tests/auto/other/other.pro11
-rw-r--r--tests/auto/other/qtmd5/.gitignore1
-rw-r--r--tests/auto/other/qtmd5/qtmd5.pro15
-rw-r--r--tests/auto/other/qtmd5/tst_qtmd5.cpp84
-rw-r--r--tests/auto/other/qtokenautomaton/.gitignore4
-rwxr-xr-xtests/auto/other/qtokenautomaton/generateTokenizers.sh50
-rw-r--r--tests/auto/other/qtokenautomaton/qtokenautomaton.pro18
-rw-r--r--tests/auto/other/qtokenautomaton/tokenizers/basic/basic.cpp480
-rw-r--r--tests/auto/other/qtokenautomaton/tokenizers/basic/basic.h101
-rw-r--r--tests/auto/other/qtokenautomaton/tokenizers/basic/basic.xml25
-rw-r--r--tests/auto/other/qtokenautomaton/tokenizers/basicNamespace/basicNamespace.cpp386
-rw-r--r--tests/auto/other/qtokenautomaton/tokenizers/basicNamespace/basicNamespace.h99
-rw-r--r--tests/auto/other/qtokenautomaton/tokenizers/basicNamespace/basicNamespace.xml23
-rw-r--r--tests/auto/other/qtokenautomaton/tokenizers/boilerplate/boilerplate.cpp386
-rw-r--r--tests/auto/other/qtokenautomaton/tokenizers/boilerplate/boilerplate.h98
-rw-r--r--tests/auto/other/qtokenautomaton/tokenizers/boilerplate/boilerplate.xml67
-rw-r--r--tests/auto/other/qtokenautomaton/tokenizers/noNamespace/noNamespace.cpp449
-rw-r--r--tests/auto/other/qtokenautomaton/tokenizers/noNamespace/noNamespace.h99
-rw-r--r--tests/auto/other/qtokenautomaton/tokenizers/noNamespace/noNamespace.xml24
-rw-r--r--tests/auto/other/qtokenautomaton/tokenizers/noToString/noToString.cpp251
-rw-r--r--tests/auto/other/qtokenautomaton/tokenizers/noToString/noToString.h98
-rw-r--r--tests/auto/other/qtokenautomaton/tokenizers/noToString/noToString.xml23
-rw-r--r--tests/auto/other/qtokenautomaton/tokenizers/withNamespace/withNamespace.cpp451
-rw-r--r--tests/auto/other/qtokenautomaton/tokenizers/withNamespace/withNamespace.h102
-rw-r--r--tests/auto/other/qtokenautomaton/tokenizers/withNamespace/withNamespace.xml25
-rw-r--r--tests/auto/other/qtokenautomaton/tst_qtokenautomaton.cpp134
57 files changed, 6291 insertions, 0 deletions
diff --git a/tests/auto/other/atwrapper/.gitignore b/tests/auto/other/atwrapper/.gitignore
new file mode 100644
index 0000000000..162ad53af6
--- /dev/null
+++ b/tests/auto/other/atwrapper/.gitignore
@@ -0,0 +1 @@
+tst_atwrapper
diff --git a/tests/auto/other/atwrapper/TODO b/tests/auto/other/atwrapper/TODO
new file mode 100644
index 0000000000..23a70c3c9e
--- /dev/null
+++ b/tests/auto/other/atwrapper/TODO
@@ -0,0 +1,17 @@
+* Get rid of "Keep baseline" on test failure page (Lars) !! DONE !!
+* Make to autotest (Simon) !! DONE !!
+* Add visual diff (Everyone ;)) !! DONE !!
+* Add flicker (Simon/Jesper) !! DONE !!
+* Add third image -- base-baseline (Lars) !! DONE !!
+* Add "view baselines" gallery, including the "base base line" (Lars) !! DONE !!
+* Add PS printer driver engine test thingy (Eskil) !! DONE !!
+* Add platform by platform comparison perl script. (Morton)
+* Fix the QDateTime.fromString() weirdness on win32 in xmldata.cpp (Jesper)
+* Have one result per page view (Lars) !! DONE !!
+* Have "platform - hostname" on test overview (Lars) !! DONE !!
+* Have the links on the overview page only show failures for that host.(All)!! DONE !!
+* "onion skin" diff. (Jesper)
+* Promote all to baseline
+* Switch all to flicker/onion/whatever
+* Add javascript confirmation for "make baseline"
+* Make "single view" more stable
diff --git a/tests/auto/other/atwrapper/atWrapper.cpp b/tests/auto/other/atwrapper/atWrapper.cpp
new file mode 100644
index 0000000000..81d1965bbb
--- /dev/null
+++ b/tests/auto/other/atwrapper/atWrapper.cpp
@@ -0,0 +1,648 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.1, 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.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#include <atWrapper.h>
+#include <datagenerator/datagenerator.h>
+
+#include <QString>
+#include <QHash>
+#include <QFile>
+#include <QFtp>
+#include <QObject>
+#include <QHostInfo>
+#include <QWidget>
+#include <QImage>
+#include <QtTest/QSignalSpy>
+#include <QLibraryInfo>
+
+static const char *ArthurDir = "../../arthur";
+
+#include <string.h>
+
+atWrapper::atWrapper()
+{
+
+ // initTests();
+
+}
+
+bool atWrapper::initTests(bool *haveBaseline)
+{
+ qDebug() << "Running test on buildkey:" << QLibraryInfo::buildKey() << " qt version:" << qVersion();
+
+ qDebug( "Initializing tests..." );
+
+ if (!loadConfig( QHostInfo::localHostName().split( "." ).first() + ".ini" ))
+ return false;
+
+ //Reset the FTP environment where the results are stored
+ *haveBaseline = setupFTP();
+
+ // Retrieve the latest test result baseline from the FTP server.
+ downloadBaseline();
+ return true;
+}
+
+void atWrapper::downloadBaseline()
+{
+
+ qDebug() << "Now downloading baseline...";
+
+ QFtp ftp;
+
+ QObject::connect( &ftp, SIGNAL( listInfo( const QUrlInfo & ) ), this, SLOT( ftpMgetAddToList(const QUrlInfo & ) ) );
+
+ //Making sure that the needed local directories exist.
+
+ QHashIterator<QString, QString> j(enginesToTest);
+
+ while ( j.hasNext() )
+ {
+ j.next();
+
+ QDir dir( output );
+
+ if ( !dir.cd( j.key() + ".baseline" ) )
+ dir.mkdir( j.key() + ".baseline" );
+
+ }
+
+ //FTP to the host specified in the config file, and retrieve the test result baseline.
+ ftp.connectToHost( ftpHost );
+ ftp.login( ftpUser, ftpPass );
+
+ ftp.cd( ftpBaseDir );
+
+ QHashIterator<QString, QString> i(enginesToTest);
+ while ( i.hasNext() )
+ {
+ i.next();
+ mgetDirList.clear();
+ mgetDirList << i.key() + ".baseline";
+ ftp.cd( i.key() + ".baseline" );
+ ftp.list();
+ ftp.cd( ".." );
+
+ while ( ftp.hasPendingCommands() )
+ QCoreApplication::instance()->processEvents();
+
+ ftpMgetDone( true );
+ }
+
+ ftp.close();
+ ftp.close();
+
+ while ( ftp.hasPendingCommands() )
+ QCoreApplication::instance()->processEvents();
+
+}
+
+void atWrapper::ftpMgetAddToList( const QUrlInfo &urlInfo )
+{
+ //Simply adding to the list of files to download.
+ mgetDirList << urlInfo.name();
+
+}
+
+void atWrapper::ftpMgetDone( bool error)
+{
+ Q_UNUSED( error );
+
+ //Downloading the files listed in mgetDirList...
+ QFtp ftp;
+ ftp.connectToHost( ftpHost );
+ ftp.login( ftpUser, ftpPass );
+
+ QFile* file;
+
+ if ( mgetDirList.size() > 1 )
+ for ( int i = 1; i < mgetDirList.size(); ++i )
+ {
+ file = new QFile( QString( output ) + "/" + mgetDirList.at( 0 ) + "/" + mgetDirList.at( i ) );
+ if (file->open(QIODevice::WriteOnly)) {
+ ftp.get( ftpBaseDir + "/" + mgetDirList.at( 0 ) + "/" + mgetDirList.at( i ), file );
+ ftp.list(); //Only there to fill up a slot in the pendingCommands queue.
+ while ( ftp.hasPendingCommands() )
+ QCoreApplication::instance()->processEvents();
+ file->close();
+ } else {
+ qDebug() << "Couldn't open file for writing: " << file->fileName();
+ }
+ }
+
+
+ while ( ftp.hasPendingCommands() )
+ QCoreApplication::instance()->processEvents();
+}
+
+void atWrapper::uploadFailed( QString dir, QString filename, QByteArray filedata )
+{
+ //Upload a failed test case image to the FTP server.
+ QFtp ftp;
+ ftp.connectToHost( ftpHost );
+ ftp.login( ftpUser, ftpPass );
+
+ ftp.cd( ftpBaseDir );
+ ftp.cd( dir );
+
+ ftp.put( filedata, filename, QFtp::Binary );
+
+ ftp.close();
+
+ while ( ftp.hasPendingCommands() )
+ QCoreApplication::instance()->processEvents();
+}
+
+// returns false if no baseline exists
+bool atWrapper::setupFTP()
+{
+ qDebug( "Setting up FTP environment" );
+
+ QString dir = "";
+ ftpMkDir( ftpBaseDir );
+
+ ftpBaseDir += "/" + QLibraryInfo::buildKey();
+
+ ftpMkDir( ftpBaseDir );
+
+ ftpBaseDir += "/" + QString( qVersion() );
+
+ ftpMkDir( ftpBaseDir );
+
+ QHashIterator<QString, QString> i(enginesToTest);
+ QHashIterator<QString, QString> j(enginesToTest);
+
+ bool haveBaseline = true;
+ //Creating the baseline directories for each engine
+ while ( i.hasNext() )
+ {
+ i.next();
+ //qDebug() << "Creating dir with key:" << i.key();
+ ftpMkDir( ftpBaseDir + "/" + QString( i.key() ) + ".failed" );
+ ftpMkDir( ftpBaseDir + "/" + QString( i.key() ) + ".diff" );
+ if (!ftpMkDir( ftpBaseDir + "/" + QString( i.key() ) + ".baseline" ))
+ haveBaseline = false;
+ }
+
+
+ QFtp ftp;
+ ftp.connectToHost( ftpHost );
+ ftp.login( ftpUser, ftpPass );
+
+ ftp.cd( ftpBaseDir );
+ //Deleting previous failed directory and all the files in it, then recreating it.
+ while ( j.hasNext() )
+ {
+ j.next();
+ rmDirList.clear();
+ rmDirList << ftpBaseDir + "/" + j.key() + ".failed" + "/";
+ ftpRmDir( j.key() + ".failed" );
+ ftp.rmdir( j.key() + ".failed" );
+ ftp.mkdir( j.key() + ".failed" );
+ ftp.list();
+
+ while ( ftp.hasPendingCommands() )
+ QCoreApplication::instance()->processEvents();
+
+ rmDirList.clear();
+ rmDirList << ftpBaseDir + "/" + j.key() + ".diff" + "/";
+ ftpRmDir( j.key() + ".diff" );
+ ftp.rmdir( j.key() + ".diff" );
+ ftp.mkdir( j.key() + ".diff" );
+ ftp.list();
+
+ while ( ftp.hasPendingCommands() )
+ QCoreApplication::instance()->processEvents();
+
+ }
+
+ ftp.close();
+
+ while ( ftp.hasPendingCommands() )
+ QCoreApplication::instance()->processEvents();
+
+ return haveBaseline;
+}
+
+void atWrapper::ftpRmDir( QString dir )
+{
+ //Hack to remove a populated directory. (caveat: containing only files and empty dirs, not recursive!)
+ qDebug() << "Now removing directory: " << dir;
+ QFtp ftp;
+ QObject::connect( &ftp, SIGNAL( listInfo( const QUrlInfo & ) ), this, SLOT( ftpRmDirAddToList(const QUrlInfo & ) ) );
+ QObject::connect( &ftp, SIGNAL( done( bool ) ), this, SLOT( ftpRmDirDone( bool ) ) );
+
+ ftp.connectToHost( ftpHost );
+ ftp.login( ftpUser, ftpPass );
+
+ ftp.list( ftpBaseDir + "/" + dir );
+ ftp.close();
+ ftp.close();
+
+ while ( ftp.hasPendingCommands() )
+ QCoreApplication::instance()->processEvents();
+}
+
+void atWrapper::ftpRmDirDone( bool error )
+{
+ //Deleting each file in the directory listning, rmDirList.
+ Q_UNUSED( error );
+
+ QFtp ftp;
+ ftp.connectToHost( ftpHost );
+ ftp.login( ftpUser, ftpPass );
+
+ if ( rmDirList.size() > 1 )
+ for (int i = 1; i < rmDirList.size(); ++i)
+ ftp.remove( rmDirList.at(0) + rmDirList.at( i ) );
+
+ ftp.close();
+
+ while ( ftp.hasPendingCommands() )
+ QCoreApplication::instance()->processEvents();
+}
+
+// returns false if the directory already exists
+bool atWrapper::ftpMkDir( QString dir )
+{
+ //Simply used to avoid QFTP from bailing out and loosing a queue of commands.
+ // IE: conveniance.
+ QFtp ftp;
+
+ QSignalSpy commandSpy(&ftp, SIGNAL(commandFinished(int, bool)));
+
+ ftp.connectToHost( ftpHost );
+ ftp.login( ftpUser, ftpPass );
+ const int command = ftp.mkdir( dir );
+ ftp.close();
+
+ while ( ftp.hasPendingCommands() )
+ QCoreApplication::instance()->processEvents();
+
+ for (int i = 0; i < commandSpy.count(); ++i)
+ if (commandSpy.at(i).at(0) == command)
+ return commandSpy.at(i).at(1).toBool();
+
+ return false;
+}
+
+
+void atWrapper::ftpRmDirAddToList( const QUrlInfo &urlInfo )
+{
+ //Just adding the file to the list for deletion
+ rmDirList << urlInfo.name();
+}
+
+
+bool atWrapper::executeTests()
+{
+ qDebug("Executing the tests...");
+
+ QHashIterator<QString, QString> i(enginesToTest);
+
+ DataGenerator generator;
+
+ //Running datagenerator against all the frameworks specified in the config file.
+ while ( i.hasNext() )
+ {
+
+ i.next();
+
+ qDebug( "Now testing: " + i.key().toLatin1() );
+
+ char* params[13];
+ //./bin/datagenerator -framework data/framework.ini -engine OpenGL -suite 1.1 -output outtest
+
+
+ QByteArray eng = i.key().toLatin1();
+ QByteArray fwk = framework.toLatin1();
+ QByteArray sut = suite.toLatin1();
+ QByteArray out = output.toLatin1();
+ QByteArray siz = size.toLatin1();
+ QByteArray fill = fillColor.toLatin1();
+
+ params[1] = "-framework";
+ params[2] = fwk.data();
+ params[3] = "-engine";
+ params[4] = eng.data();
+ params[5] = "-suite";
+ params[6] = sut.data();
+ params[7] = "-output";
+ params[8] = out.data();
+ params[9] = "-size";
+ params[10] = siz.data();
+ params[11] = "-fill";
+ params[12] = fill.data();
+
+ generator.run( 13, params );
+ }
+
+ return true;
+}
+
+void atWrapper::createBaseline()
+{
+ qDebug( "Now uploading a baseline of only the latest test values" );
+
+ QHashIterator<QString, QString> i(enginesToTest);
+
+ QDir dir( output );
+ QFtp ftp;
+ ftp.connectToHost( ftpHost );
+ ftp.login( ftpUser, ftpPass );
+ ftp.cd( ftpBaseDir );
+ //Upload all the latest test results to the FTP server's baseline directory.
+ while ( i.hasNext() )
+ {
+
+ i.next();
+ dir.cd( i.key() );
+ ftp.cd( i.key() + ".baseline" );
+ dir.setFilter(QDir::Files | QDir::Hidden | QDir::NoSymLinks);
+ dir.setNameFilters( QStringList() << "*.png" );
+ QFileInfoList list = dir.entryInfoList();
+ dir.cd( ".." );
+ for (int n = 0; n < list.size(); n++)
+ {
+ QFileInfo fileInfo = list.at( n );
+ QFile file( QString( output ) + "/" + i.key() + "/" + fileInfo.fileName() );
+ file.open( QIODevice::ReadOnly );
+ QByteArray fileData = file.readAll();
+ //qDebug() << "Sending up:" << fileInfo.fileName() << "with file size" << fileData.size();
+ file.close();
+ ftp.put( fileData, fileInfo.fileName(), QFtp::Binary );
+ }
+
+ ftp.cd( ".." );
+ }
+
+ ftp.close();
+
+ while ( ftp.hasPendingCommands() )
+ QCoreApplication::instance()->processEvents();
+}
+
+bool atWrapper::compare()
+{
+ qDebug( "Now comparing the results to the baseline" );
+
+ QHashIterator<QString, QString> i(enginesToTest);
+
+ while ( i.hasNext() )
+ {
+ i.next();
+
+ compareDirs( output , i.key() );
+
+ }
+
+ return true;
+}
+
+void atWrapper::compareDirs( QString basedir, QString target )
+{
+
+ QDir dir( basedir );
+
+ /* The following should be redundant now.
+
+ if ( !dir.cd( target + ".failed" ) )
+ dir.mkdir( target + ".failed" );
+ else
+ dir.cdUp();
+
+ */
+
+ if ( !dir.cd( target + ".diff" ) )
+ dir.mkdir( target + ".diff" );
+ else
+ dir.cdUp();
+
+
+
+ //Perform comparisons between the two directories.
+
+ dir.setFilter(QDir::Files | QDir::Hidden | QDir::NoSymLinks);
+ dir.setNameFilters( QStringList() << "*.png" );
+ dir.cd( target + ".baseline" );
+ QFileInfoList list = dir.entryInfoList();
+
+ for (int i = 0; i < list.size(); ++i)
+ {
+ QFileInfo fileInfo = list.at(i);
+ diff ( basedir, target, fileInfo.fileName() );
+ }
+}
+
+bool atWrapper::diff( QString basedir, QString dir, QString target )
+{
+ //Comparing the two specified files, and then uploading them to
+ //the ftp server if they differ
+
+ basedir += "/" + dir;
+ QString one = basedir + ".baseline/" + target;
+ QString two = basedir + "/" + target;
+
+ QFile file( one );
+
+ file.open( QIODevice::ReadOnly );
+ QByteArray contentsOfOne = file.readAll();
+ file.close();
+
+ file.setFileName( two );
+
+ file.open( QIODevice::ReadOnly );
+ QByteArray contentsOfTwo = file.readAll();
+ file.close();
+
+ if ( contentsOfTwo.size() == 0 )
+ {
+ qDebug() << "No test result found for baseline: " << one;
+ file.setFileName( one );
+ file.open( QIODevice::ReadOnly );
+ file.copy( basedir + ".failed/" + target + "_missing" );
+ uploadFailed( dir + ".failed", target + "_missing", contentsOfTwo );
+ return false;
+ }
+
+
+ if ( ( memcmp( contentsOfOne, contentsOfTwo, contentsOfOne.size() ) ) == 0 )
+ return true;
+ else
+ {
+ qDebug() << "Sorry, the result did not match: " << one;
+ file.setFileName( two );
+ file.open( QIODevice::ReadOnly );
+ file.copy( basedir + ".failed/" + target );
+ file.close();
+ uploadFailed( dir + ".failed", target, contentsOfTwo );
+ uploadDiff( basedir, dir, target );
+ return false;
+ }
+}
+
+void atWrapper::uploadDiff( QString basedir, QString dir, QString filename )
+{
+
+ qDebug() << basedir;
+ QImage im1( basedir + ".baseline/" + filename );
+ QImage im2( basedir + "/" + filename );
+
+ QImage im3(im1.size(), QImage::Format_ARGB32);
+
+ im1 = im1.convertToFormat(QImage::Format_ARGB32);
+ im2 = im2.convertToFormat(QImage::Format_ARGB32);
+
+ for ( int y=0; y<im1.height(); ++y )
+ {
+ uint *s = (uint *) im1.scanLine(y);
+ uint *d = (uint *) im2.scanLine(y);
+ uint *w = (uint *) im3.scanLine(y);
+
+ for ( int x=0; x<im1.width(); ++x )
+ {
+ if (*s != *d)
+ *w = 0xff000000;
+ else
+ *w = 0xffffffff;
+ w++;
+ s++;
+ d++;
+ }
+ }
+
+ im3.save( basedir + ".diff/" + filename ,"PNG");
+
+ QFile file( basedir + ".diff/" + filename );
+ file.open( QIODevice::ReadOnly );
+ QByteArray contents = file.readAll();
+ file.close();
+
+ uploadFailed( dir + ".diff", filename, contents );
+
+}
+
+bool atWrapper::loadConfig( QString path )
+{
+ qDebug() << "Loading config file from ... " << path;
+ configPath = path;
+ //If there is no config file, dont proceed;
+ if ( !QFile::exists( path ) )
+ {
+ return false;
+ }
+
+
+ QSettings settings( path, QSettings::IniFormat, this );
+
+
+ //FIXME: Switch to QStringList or something, hash is not needed!
+ int numEngines = settings.beginReadArray("engines");
+
+ for ( int i = 0; i < numEngines; ++i )
+ {
+ settings.setArrayIndex(i);
+ enginesToTest.insert( settings.value( "engine" ).toString(), "Info here please :p" );
+ }
+
+ settings.endArray();
+
+ framework = QString(ArthurDir) + QDir::separator() + settings.value( "framework" ).toString();
+ suite = settings.value( "suite" ).toString();
+ output = settings.value( "output" ).toString();
+ size = settings.value( "size", "480,360" ).toString();
+ fillColor = settings.value( "fill", "white" ).toString();
+ ftpUser = settings.value( "ftpUser" ).toString();
+ ftpPass = settings.value( "ftpPass" ).toString();
+ ftpHost = settings.value( "ftpHost" ).toString();
+ ftpBaseDir = settings.value( "ftpBaseDir" ).toString();
+
+
+ QDir::current().mkdir( output );
+
+ output += "/" + QLibraryInfo::buildKey();
+
+ QDir::current().mkdir( output );
+
+ output += "/" + QString( qVersion() );
+
+ QDir::current().mkdir( output );
+
+
+ ftpBaseDir += "/" + QHostInfo::localHostName().split( "." ).first();
+
+
+/*
+ framework = "data/framework.ini";
+ suite = "1.1";
+ output = "testresults";
+ ftpUser = "anonymous";
+ ftpPass = "anonymouspass";
+ ftpHost = "kramer.troll.no";
+ ftpBaseDir = "/arthurtest";
+*/
+ return true;
+}
+
+bool atWrapper::runAutoTests()
+{
+ //SVG needs this widget...
+ QWidget dummy;
+
+ bool haveBaseline = false;
+
+ if (!initTests(&haveBaseline))
+ return false;
+ executeTests();
+
+ if ( !haveBaseline )
+ {
+ qDebug( " First run! Creating baseline..." );
+ createBaseline();
+ }
+ else
+ {
+ qDebug( " Comparing results..." );
+ compare();
+ }
+ return true;
+}
diff --git a/tests/auto/other/atwrapper/atWrapper.h b/tests/auto/other/atwrapper/atWrapper.h
new file mode 100644
index 0000000000..e325c087d8
--- /dev/null
+++ b/tests/auto/other/atwrapper/atWrapper.h
@@ -0,0 +1,93 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.1, 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.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef ATWRAPPER_H
+#define ATWRAPPER_H
+
+#include <QHash>
+#include <QString>
+#include <QUrlInfo>
+#include <QColor>
+
+class atWrapper : public QObject
+{
+ Q_OBJECT
+
+ public:
+ atWrapper();
+ bool runAutoTests();
+
+ private:
+ bool executeTests();
+ bool initTests(bool *haveBaseline);
+ bool compare();
+ void createBaseline();
+ bool loadConfig( QString );
+ void compareDirs( QString, QString );
+ bool diff( QString, QString, QString );
+ void downloadBaseline();
+ void uploadFailed( QString, QString, QByteArray );
+ bool ftpMkDir( QString );
+ void ftpRmDir( QString );
+ bool setupFTP();
+ void uploadDiff( QString, QString, QString );
+
+ QHash<QString, QString> enginesToTest;
+ QString framework;
+ QString suite;
+ QString output;
+ QString size;
+ QString ftpUser;
+ QString ftpPass;
+ QString ftpHost;
+ QString ftpBaseDir;
+ QList<QString> rmDirList;
+ QList<QString> mgetDirList;
+ QString configPath;
+ QString fillColor;
+
+ private slots:
+ void ftpRmDirAddToList( const QUrlInfo &urlInfo );
+ void ftpRmDirDone( bool );
+ void ftpMgetAddToList( const QUrlInfo &urlInfo );
+ void ftpMgetDone( bool );
+};
+
+#endif
diff --git a/tests/auto/other/atwrapper/atWrapper.pro b/tests/auto/other/atwrapper/atWrapper.pro
new file mode 100644
index 0000000000..323ca1bf5f
--- /dev/null
+++ b/tests/auto/other/atwrapper/atWrapper.pro
@@ -0,0 +1,24 @@
+# -*- Mode: makefile -*-
+
+ARTHUR=$$QT_SOURCE_TREE/tests/arthur
+COMMON_FOLDER = $$ARTHUR/common
+include($$ARTHUR/arthurtester.pri)
+TEMPLATE = app
+INCLUDEPATH += $$ARTHUR
+DEFINES += SRCDIR=\\\"$$PWD\\\"
+
+QT += xml svg network
+
+contains(QT_CONFIG, opengl):QT += opengl
+
+include($$ARTHUR/datagenerator/datagenerator.pri)
+
+load(qttest_p4)
+
+# Input
+HEADERS += atWrapper.h
+SOURCES += atWrapperAutotest.cpp atWrapper.cpp
+
+TARGET = tst_atwrapper
+
+#include($$COMMON_FOLDER/common.pri)
diff --git a/tests/auto/other/atwrapper/atWrapperAutotest.cpp b/tests/auto/other/atwrapper/atWrapperAutotest.cpp
new file mode 100644
index 0000000000..ebea316d44
--- /dev/null
+++ b/tests/auto/other/atwrapper/atWrapperAutotest.cpp
@@ -0,0 +1,78 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.1, 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.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#include <QtTest/QtTest>
+#include "atWrapper.h"
+#include <QApplication>
+
+class atWrapperAutotest: public QObject
+{
+
+Q_OBJECT
+
+public slots:
+ void init();
+
+private slots:
+ void runTest();
+};
+
+void atWrapperAutotest::init()
+{
+#ifndef Q_OS_IRIX
+ QDir::setCurrent(SRCDIR);
+#endif
+}
+
+void atWrapperAutotest::runTest()
+{
+
+ //QApplication app(argc, argv);
+
+ atWrapper wrapper;
+ if (!wrapper.runAutoTests())
+ QSKIP("Arthur not tested on this machine", SkipAll);
+ QVERIFY(true);
+}
+
+QTEST_MAIN(atWrapperAutotest)
+#include "atWrapperAutotest.moc"
diff --git a/tests/auto/other/atwrapper/desert.ini b/tests/auto/other/atwrapper/desert.ini
new file mode 100644
index 0000000000..6d8605252d
--- /dev/null
+++ b/tests/auto/other/atwrapper/desert.ini
@@ -0,0 +1,14 @@
+[General]
+framework=data/framework.ini
+ftpBaseDir=/arthurtest
+ftpHost=kramer.troll.no
+ftpPass=anonymouspass
+ftpUser=anonymous
+output=testresults
+suite=1.1
+
+[engines]
+1\engine=NativeXRender
+2\engine=PDF
+3\engine=Raster
+size=3
diff --git a/tests/auto/other/atwrapper/ephron.ini b/tests/auto/other/atwrapper/ephron.ini
new file mode 100644
index 0000000000..eeccb3b6ef
--- /dev/null
+++ b/tests/auto/other/atwrapper/ephron.ini
@@ -0,0 +1,14 @@
+[General]
+framework=data/framework.ini
+ftpBaseDir=/arthurtest
+ftpHost=kramer.troll.no
+ftpPass=anonymouspass
+ftpUser=anonymous
+output=testresults
+suite=oxygen
+size=256
+fill=transparent
+
+[engines]
+1\engine=Raster
+size=1
diff --git a/tests/auto/other/atwrapper/gullgubben.ini b/tests/auto/other/atwrapper/gullgubben.ini
new file mode 100644
index 0000000000..3a664dddd5
--- /dev/null
+++ b/tests/auto/other/atwrapper/gullgubben.ini
@@ -0,0 +1,12 @@
+[General]
+framework=data/framework.ini
+ftpBaseDir=/arthurtest
+ftpHost=kramer.troll.no
+ftpPass=anonymouspass
+ftpUser=anonymous
+output=testresults
+suite=1.1
+
+[engines]
+1\engine=OpenGL
+size=1
diff --git a/tests/auto/other/atwrapper/honshu.ini b/tests/auto/other/atwrapper/honshu.ini
new file mode 100644
index 0000000000..3b7751a128
--- /dev/null
+++ b/tests/auto/other/atwrapper/honshu.ini
@@ -0,0 +1,16 @@
+[General]
+framework=data/framework.ini
+ftpBaseDir=/arthurtest
+ftpHost=kramer.troll.no
+ftpPass=anonymouspass
+ftpUser=anonymous
+output=testresults
+suite=1.1
+
+[engines]
+1\engine=NativeWin32
+2\engine=PDF
+3\engine=Raster
+4\engine=OpenGL
+5\engine=WinPrint
+size=5
diff --git a/tests/auto/other/atwrapper/kramer.ini b/tests/auto/other/atwrapper/kramer.ini
new file mode 100644
index 0000000000..289d8a8b7e
--- /dev/null
+++ b/tests/auto/other/atwrapper/kramer.ini
@@ -0,0 +1,12 @@
+[General]
+framework=data/framework.ini
+ftpBaseDir=/arthurtest
+ftpHost=kramer.troll.no
+ftpPass=anonymouspass
+ftpUser=anonymous
+output=testresults
+suite=1.1
+
+[engines]
+1\engine=Raster
+size=1
diff --git a/tests/auto/other/atwrapper/scruffy.ini b/tests/auto/other/atwrapper/scruffy.ini
new file mode 100644
index 0000000000..329f537e6f
--- /dev/null
+++ b/tests/auto/other/atwrapper/scruffy.ini
@@ -0,0 +1,15 @@
+[General]
+framework=data/framework.ini
+ftpBaseDir=/arthurtest
+ftpHost=kramer.nokia.troll.no
+ftpPass=anonymouspass
+ftpUser=anonymous
+output=testresults
+suite=1.1
+
+[engines]
+1\engine=NativeMac
+2\engine=PDF
+3\engine=Raster
+4\engine=OpenGL
+size=4
diff --git a/tests/auto/other/atwrapper/spareribs.ini b/tests/auto/other/atwrapper/spareribs.ini
new file mode 100644
index 0000000000..78ff9e985f
--- /dev/null
+++ b/tests/auto/other/atwrapper/spareribs.ini
@@ -0,0 +1,14 @@
+[General]
+framework=data/framework.ini
+ftpBaseDir=/arthurtest
+ftpHost=kramer.troll.no
+ftpPass=anonymouspass
+ftpUser=anonymous
+output=testresults
+suite=1.1
+
+[engines]
+1\engine=NativeWin32
+2\engine=PDF
+3\engine=Raster
+size=3
diff --git a/tests/auto/other/atwrapper/titan.ini b/tests/auto/other/atwrapper/titan.ini
new file mode 100644
index 0000000000..3a0b0dfd31
--- /dev/null
+++ b/tests/auto/other/atwrapper/titan.ini
@@ -0,0 +1,13 @@
+[General]
+framework=data/framework.ini
+ftpBaseDir=/arthurtest
+ftpHost=kramer.troll.no
+ftpPass=anonymouspass
+ftpUser=anonymous
+output=testresults
+suite=1.1
+
+[engines]
+1\engine=NativeXRender
+2\engine=OpenGL
+size=2
diff --git a/tests/auto/other/baselineexample/baselineexample.pro b/tests/auto/other/baselineexample/baselineexample.pro
new file mode 100644
index 0000000000..cc310aec3a
--- /dev/null
+++ b/tests/auto/other/baselineexample/baselineexample.pro
@@ -0,0 +1,18 @@
+#-------------------------------------------------
+#
+# Project created by QtCreator 2010-12-09T14:55:13
+#
+#-------------------------------------------------
+
+QT += testlib widgets
+
+TARGET = tst_baselineexample
+CONFIG += console
+CONFIG -= app_bundle
+
+TEMPLATE = app
+
+SOURCES += tst_baselineexample.cpp
+DEFINES += SRCDIR=\\\"$$PWD/\\\"
+
+include($$PWD/../../../baselineserver/shared/qbaselinetest.pri)
diff --git a/tests/auto/other/baselineexample/tst_baselineexample.cpp b/tests/auto/other/baselineexample/tst_baselineexample.cpp
new file mode 100644
index 0000000000..73657bdf6d
--- /dev/null
+++ b/tests/auto/other/baselineexample/tst_baselineexample.cpp
@@ -0,0 +1,146 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.1, 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.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <qbaselinetest.h>
+#include <QPushButton>
+
+class tst_BaselineExample : public QObject
+{
+ Q_OBJECT
+
+public:
+ tst_BaselineExample();
+
+private Q_SLOTS:
+ void testBasicUsage();
+ void testMultipleImages();
+ void testDataDriven_data();
+ void testDataDriven();
+ void testDataDrivenChecksum_data();
+ void testDataDrivenChecksum();
+};
+
+
+tst_BaselineExample::tst_BaselineExample()
+{
+}
+
+
+void tst_BaselineExample::testBasicUsage()
+{
+ // Generate an image:
+ QPushButton b("Press me!");
+ b.resize(100, 50);
+ b.show();
+ QTest::qWaitForWindowShown(&b);
+ QImage img1 = QPixmap::grabWidget(&b).toImage();
+ QVERIFY(!img1.isNull());
+
+ // Compare it to baseline on server:
+ QBASELINE_CHECK(img1, "button");
+}
+
+
+void tst_BaselineExample::testMultipleImages()
+{
+ QPushButton b("Press me!");
+ b.resize(100, 50);
+ b.show();
+ QTest::qWaitForWindowShown(&b);
+ QBASELINE_CHECK(QPixmap::grabWidget(&b).toImage(), "text1");
+
+ b.setText("Kick me!");
+ QTest::qWait(50);
+ QBASELINE_CHECK(QPixmap::grabWidget(&b).toImage(), "text2");
+}
+
+
+void tst_BaselineExample::testDataDriven_data()
+{
+ QTest::addColumn<QString>("label");
+ QBaselineTest::newRow("short") << "Ok!";
+ QBaselineTest::newRow("long") << "A really long button text that just does not seem to end";
+ QBaselineTest::newRow("empty") << "";
+ QBaselineTest::newRow("signs") << "!@#$%^&*()_";
+ QBaselineTest::newRow("html") << "<b>BOLD</b>";
+}
+
+
+void tst_BaselineExample::testDataDriven()
+{
+ QFETCH(QString, label);
+ QPushButton b(label);
+ b.resize(100, 50);
+ b.show();
+ QTest::qWaitForWindowShown(&b);
+ QBASELINE_TEST(QPixmap::grabWidget(&b).toImage());
+}
+
+
+void tst_BaselineExample::testDataDrivenChecksum_data()
+{
+ QTest::addColumn<QString>("label");
+
+ const int numItems = 5;
+ const char *tags[numItems] = {"short", "long", "empty", "signs", "html"};
+ const char *labels[numItems] = {"Ok!", "A really long button text that just does not seem to end", "", "!@#$%^&*()_", "<b>BOLD</b>"};
+
+ for (int i = 0; i<numItems; i++) {
+ quint16 checksum = qChecksum(labels[i], qstrlen(labels[i]));
+ QBaselineTest::newRow(tags[i], checksum) << labels[i];
+ }
+}
+
+
+void tst_BaselineExample::testDataDrivenChecksum()
+{
+ QFETCH(QString, label);
+ QPushButton b(label);
+ b.resize(100, 50);
+ b.show();
+ QTest::qWaitForWindowShown(&b);
+ QBASELINE_TEST(QPixmap::grabWidget(&b).toImage());
+}
+
+
+QTEST_MAIN(tst_BaselineExample);
+
+#include "tst_baselineexample.moc"
diff --git a/tests/auto/other/compiler/.gitignore b/tests/auto/other/compiler/.gitignore
new file mode 100644
index 0000000000..bdcee467b6
--- /dev/null
+++ b/tests/auto/other/compiler/.gitignore
@@ -0,0 +1 @@
+tst_compile
diff --git a/tests/auto/other/compiler/baseclass.cpp b/tests/auto/other/compiler/baseclass.cpp
new file mode 100644
index 0000000000..22ccba8f78
--- /dev/null
+++ b/tests/auto/other/compiler/baseclass.cpp
@@ -0,0 +1,51 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.1, 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.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#define BASECLASS_NOT_ABSTRACT
+#include "baseclass.h"
+
+BaseClass::~BaseClass()
+{
+}
+
+void BaseClass::wasAPureVirtualFunction()
+{
+ qDebug("BaseClass::wasAPureVirtualFunction()");
+}
diff --git a/tests/auto/other/compiler/baseclass.h b/tests/auto/other/compiler/baseclass.h
new file mode 100644
index 0000000000..e510112f2f
--- /dev/null
+++ b/tests/auto/other/compiler/baseclass.h
@@ -0,0 +1,60 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.1, 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.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef BASECLASS_H
+#define BASECLASS_H
+
+#include <QtGlobal>
+
+QT_USE_NAMESPACE
+
+class BaseClass
+{
+public:
+ virtual ~BaseClass();
+
+#ifdef BASECLASS_NOT_ABSTRACT
+ virtual void wasAPureVirtualFunction();
+#else
+ virtual void wasAPureVirtualFunction() = 0;
+#endif
+};
+
+#endif
diff --git a/tests/auto/other/compiler/compiler.pro b/tests/auto/other/compiler/compiler.pro
new file mode 100644
index 0000000000..c444c63af6
--- /dev/null
+++ b/tests/auto/other/compiler/compiler.pro
@@ -0,0 +1,7 @@
+load(qttest_p4)
+SOURCES += tst_compiler.cpp baseclass.cpp derivedclass.cpp
+HEADERS += baseclass.h derivedclass.h
+QT = core
+
+
+
diff --git a/tests/auto/other/compiler/derivedclass.cpp b/tests/auto/other/compiler/derivedclass.cpp
new file mode 100644
index 0000000000..45ef6df3ee
--- /dev/null
+++ b/tests/auto/other/compiler/derivedclass.cpp
@@ -0,0 +1,48 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.1, 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.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include "derivedclass.h"
+
+#include <QtGlobal>
+
+void DerivedClass::wasAPureVirtualFunction()
+{
+ qDebug("DerivedClass::wasAPureVirtualFunction()");
+}
diff --git a/tests/auto/other/compiler/derivedclass.h b/tests/auto/other/compiler/derivedclass.h
new file mode 100644
index 0000000000..c5fb61f46e
--- /dev/null
+++ b/tests/auto/other/compiler/derivedclass.h
@@ -0,0 +1,52 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.1, 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.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef DERIVEDCLASS_H
+#define DERIVEDCLASS_H
+
+#include "baseclass.h"
+
+class DerivedClass : public BaseClass
+{
+public:
+ void wasAPureVirtualFunction();
+};
+
+#endif
diff --git a/tests/auto/other/compiler/tst_compiler.cpp b/tests/auto/other/compiler/tst_compiler.cpp
new file mode 100644
index 0000000000..cd037793bd
--- /dev/null
+++ b/tests/auto/other/compiler/tst_compiler.cpp
@@ -0,0 +1,656 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.1, 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.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#include <QtCore/QtCore>
+#include <QtTest/QtTest>
+
+#include <algorithm>
+
+#define BASECLASS_NOT_ABSTRACT
+#include "baseclass.h"
+#include "derivedclass.h"
+
+QT_USE_NAMESPACE
+
+class tst_Compiler : public QObject
+{
+Q_OBJECT
+
+private slots:
+ void template_methods();
+ void template_constructors();
+ void template_subclasses();
+ void methodSpecialization();
+ void constructorSpecialization();
+ void staticTemplateMethods();
+ void staticTemplateMethodSpecialization();
+ void detectDataStream();
+ void detectEnums();
+ void overrideCFunction();
+ void stdSortQList();
+ void stdSortQVector();
+ void templateCallOrder();
+ void virtualFunctionNoLongerPureVirtual();
+ void charSignedness() const;
+ void privateStaticTemplateMember() const;
+ void staticConstUnionWithInitializerList() const;
+};
+
+#if defined(Q_CC_MSVC) && _MSC_VER < 1300
+#define MSVC6
+#endif
+
+#if defined(Q_CC_MSVC) && _MSC_VER == 1300
+#define MSVC2002
+#endif
+
+#if defined(MSVC6)
+# define DONT_TEST_TEMPLATE_METHODS
+# define DONT_TEST_TEMPLATE_CONSTRUCTORS
+# define DONT_TEST_METHOD_SPECIALIZATION
+# define DONT_TEST_CONSTRUCTOR_SPECIALIZATION
+# define DONT_TEST_STATIC_TEMPLATE_METHODS
+# define DONT_TEST_STATIC_TEMPLATE_METHOD_SPECIALIZATION
+# define DONT_TEST_STL_SORTING
+# define DONT_TEST_SIGNEDNESS
+#endif
+
+#if defined(MSVC2002)
+# define DONT_TEST_TEMPLATE_METHODS
+# define DONT_TEST_DETECT_ENUMS
+# define DONT_TEST_METHOD_SPECIALIZATION
+# define DONT_TEST_CONSTRUCTOR_SPECIALIZATION
+# define DONT_TEST_STATIC_TEMPLATE_METHOD_SPECIALIZATION
+# define DONT_TEST_STL_SORTING
+#endif
+
+#if defined(Q_CC_HPACC)
+# define DONT_TEST_TEMPLATE_CONSTRUCTORS
+# define DONT_TEST_CONSTRUCTOR_SPECIALIZATION
+# define DONT_TEST_DATASTREAM_DETECTION
+#endif
+
+#if defined(Q_CC_SUN)
+# define DONT_TEST_STL_SORTING
+#endif
+
+#ifndef DONT_TEST_TEMPLATE_METHODS
+class TemplateMethodClass
+{
+public:
+ template <class T>
+ T foo() { return 42; }
+};
+
+void tst_Compiler::template_methods()
+{
+ TemplateMethodClass t;
+
+ QCOMPARE(t.foo<int>(), 42);
+ QCOMPARE(t.foo<long>(), 42l);
+ QCOMPARE(t.foo<double>(), 42.0);
+}
+#else
+void tst_Compiler::template_methods()
+{ QSKIP("Compiler doesn't do template methods", SkipAll); }
+#endif
+
+#ifndef DONT_TEST_TEMPLATE_CONSTRUCTORS
+class TemplateConstructorClass
+{
+public:
+ template <class T>
+ TemplateConstructorClass(const T& t) { i = int(t); }
+
+ int i;
+};
+
+void tst_Compiler::template_constructors()
+{
+ TemplateConstructorClass t1(42);
+ TemplateConstructorClass t2(42l);
+ TemplateConstructorClass t3(42.0);
+
+ QCOMPARE(t1.i, 42);
+ QCOMPARE(t2.i, 42);
+ QCOMPARE(t3.i, 42);
+}
+#else
+void tst_Compiler::template_constructors()
+{ QSKIP("Compiler doesn't do template constructors", SkipAll); }
+#endif
+
+template <typename T>
+struct OuterClass
+{
+ template <typename U>
+ struct InnerClass
+ {
+ U convert(const T &t) { return static_cast<U>(t); }
+ };
+};
+
+void tst_Compiler::template_subclasses()
+{
+ OuterClass<char>::InnerClass<int> c1;
+ QCOMPARE(c1.convert('a'), int('a'));
+
+ OuterClass<QRect>::InnerClass<QRectF> c2;
+ QCOMPARE(c2.convert(QRect(1, 2, 3, 4)), QRectF(QRect(1, 2, 3, 4)));
+}
+
+#ifndef DONT_TEST_METHOD_SPECIALIZATION
+class TemplateMethodClass2
+{
+public:
+ template <class T>
+ T foo() { return 42; }
+};
+
+template<>
+int TemplateMethodClass2::foo<int>()
+{ return 43; }
+
+void tst_Compiler::methodSpecialization()
+{
+ TemplateMethodClass2 t;
+
+ QCOMPARE(t.foo<int>(), 43);
+ QCOMPARE(t.foo<long>(), 42l);
+ QCOMPARE(t.foo<double>(), 42.0);
+}
+#else
+void tst_Compiler::methodSpecialization()
+{ QSKIP("Compiler doesn't do template specialization", SkipAll); }
+#endif
+
+#ifndef DONT_TEST_CONSTRUCTOR_SPECIALIZATION
+class TemplateConstructorClass2
+{
+public:
+ template <class T>
+ TemplateConstructorClass2(const T &t) { i = int(t); }
+
+ int i;
+};
+
+template<>
+TemplateConstructorClass2::TemplateConstructorClass2(const int &t) { i = t + 1; }
+
+void tst_Compiler::constructorSpecialization()
+{
+ TemplateConstructorClass2 t1(42);
+ TemplateConstructorClass2 t2(42l);
+ TemplateConstructorClass2 t3(42.0);
+
+ QCOMPARE(t1.i, 43);
+ QCOMPARE(t2.i, 42);
+ QCOMPARE(t3.i, 42);
+}
+#else
+void tst_Compiler::constructorSpecialization()
+{ QSKIP("Compiler doesn't do constructor specialization", SkipAll); }
+#endif
+
+#ifndef DONT_TEST_STATIC_TEMPLATE_METHODS
+class StaticTemplateClass
+{
+public:
+ template <class T>
+ static T foo() { return 42; }
+};
+
+void tst_Compiler::staticTemplateMethods()
+{
+ QCOMPARE(StaticTemplateClass::foo<int>(), 42);
+ QCOMPARE(StaticTemplateClass::foo<uint>(), 42u);
+}
+#else
+void tst_Compiler::staticTemplateMethods()
+{ QSKIP("Compiler doesn't do static template methods", SkipAll); }
+#endif
+
+#ifndef DONT_TEST_STATIC_TEMPLATE_METHOD_SPECIALIZATION
+class StaticTemplateClass2
+{
+public:
+ template <class T>
+ static T foo() { return 42; }
+};
+
+template<>
+double StaticTemplateClass2::foo<double>() { return 18.5; }
+
+void tst_Compiler::staticTemplateMethodSpecialization()
+{
+ QCOMPARE(StaticTemplateClass2::foo<int>(), 42);
+ QCOMPARE(StaticTemplateClass2::foo<uint>(), 42u);
+ QCOMPARE(StaticTemplateClass2::foo<double>(), 18.5);
+}
+#else
+void tst_Compiler::staticTemplateMethodSpecialization()
+{ QSKIP("Compiler doesn't do static template method specialization", SkipAll); }
+#endif
+
+#ifndef DONT_TEST_DATASTREAM_DETECTION
+/******* DataStream tester *********/
+namespace QtTestInternal
+{
+ struct EmptyStruct {};
+ struct LowPreferenceStruct { LowPreferenceStruct(...); };
+
+ EmptyStruct operator<<(QDataStream &, const LowPreferenceStruct &);
+ EmptyStruct operator>>(QDataStream &, const LowPreferenceStruct &);
+
+ template<typename T>
+ struct DataStreamChecker
+ {
+ static EmptyStruct hasStreamHelper(const EmptyStruct &);
+ static QDataStream hasStreamHelper(const QDataStream &);
+ static QDataStream &dsDummy();
+ static T &dummy();
+
+#ifdef BROKEN_COMPILER
+ static const bool HasDataStream =
+ sizeof(hasStreamHelper(dsDummy() << dummy())) == sizeof(QDataStream)
+ && sizeof(hasStreamHelper(dsDummy() >> dummy())) == sizeof(QDataStream);
+#else
+ enum {
+ HasOutDataStream = sizeof(hasStreamHelper(dsDummy() >> dummy())) == sizeof(QDataStream),
+ HasInDataStream = sizeof(hasStreamHelper(dsDummy() << dummy())) == sizeof(QDataStream),
+ HasDataStream = HasOutDataStream & HasInDataStream
+ };
+#endif
+ };
+
+ template<bool>
+ struct DataStreamOpHelper
+ {
+ template <typename T>
+ struct Getter {
+ static QMetaType::SaveOperator saveOp() { return 0; }
+ };
+ };
+
+ template<>
+ struct DataStreamOpHelper<true>
+ {
+ template <typename T>
+ struct Getter {
+ static QMetaType::SaveOperator saveOp()
+ {
+ typedef void(*SavePtr)(QDataStream &, const T *);
+ SavePtr op = ::qMetaTypeSaveHelper<T>;
+ return reinterpret_cast<QMetaType::SaveOperator>(op);
+ }
+ };
+
+ };
+
+ template<typename T>
+ inline QMetaType::SaveOperator getSaveOperator(T * = 0)
+ {
+ typedef typename DataStreamOpHelper<DataStreamChecker<T>::HasDataStream>::template Getter<T> GetterHelper;
+ return GetterHelper::saveOp();
+ }
+};
+
+struct MyString: public QString {};
+struct Qxxx {};
+
+void tst_Compiler::detectDataStream()
+{
+ QVERIFY(QtTestInternal::DataStreamChecker<int>::HasDataStream == true);
+ QVERIFY(QtTestInternal::DataStreamChecker<uint>::HasDataStream == true);
+ QVERIFY(QtTestInternal::DataStreamChecker<char *>::HasDataStream == true);
+ QVERIFY(QtTestInternal::DataStreamChecker<const int>::HasInDataStream == true);
+ QVERIFY(QtTestInternal::DataStreamChecker<const int>::HasOutDataStream == false);
+ QVERIFY(QtTestInternal::DataStreamChecker<const int>::HasDataStream == false);
+ QVERIFY(QtTestInternal::DataStreamChecker<double>::HasDataStream == true);
+
+ QVERIFY(QtTestInternal::DataStreamChecker<QString>::HasDataStream == true);
+ QVERIFY(QtTestInternal::DataStreamChecker<MyString>::HasDataStream == true);
+ QVERIFY(QtTestInternal::DataStreamChecker<Qxxx>::HasDataStream == false);
+
+ QVERIFY(QtTestInternal::getSaveOperator<int>() != 0);
+ QVERIFY(QtTestInternal::getSaveOperator<uint>() != 0);
+ QVERIFY(QtTestInternal::getSaveOperator<char *>() != 0);
+ QVERIFY(QtTestInternal::getSaveOperator<double>() != 0);
+ QVERIFY(QtTestInternal::getSaveOperator<QString>() != 0);
+ QVERIFY(QtTestInternal::getSaveOperator<MyString>() != 0);
+ QVERIFY(QtTestInternal::getSaveOperator<Qxxx>() == 0);
+}
+#else
+void tst_Compiler::detectDataStream()
+{ QSKIP("Compiler doesn't evaluate templates correctly", SkipAll); }
+#endif
+
+#ifndef DONT_TEST_DETECT_ENUMS
+enum Enum1 { Foo = 0, Bar = 1 };
+enum Enum2 {};
+enum Enum3 { Something = 1 };
+
+template <typename T> char QTypeInfoEnumHelper(T);
+template <typename T> void *QTypeInfoEnumHelper(...);
+
+#if defined(MSVC6)
+
+template <int>
+struct QTestTypeInfoHelper
+{
+ enum { IsE = 0 };
+};
+
+template <>
+struct QTestTypeInfoHelper<sizeof(void *)>
+{
+ enum { IsE = 1 };
+};
+
+
+template <typename T>
+struct QTestTypeInfo
+{
+ typedef typename QTestTypeInfoHelper<sizeof(QTypeInfoEnumHelper<T>(0))> TIHelper;
+ enum { IsEnum = TIHelper::IsE };
+};
+#else
+template <typename T>
+struct QTestTypeInfo
+{
+ enum { IsEnum = sizeof(QTypeInfoEnumHelper<T>(0)) == sizeof(void*) };
+};
+#endif
+
+void tst_Compiler::detectEnums()
+{
+ QVERIFY(QTestTypeInfo<Enum1>::IsEnum);
+ QVERIFY(QTestTypeInfo<Enum2>::IsEnum);
+ QVERIFY(QTestTypeInfo<Enum3>::IsEnum);
+ QVERIFY(!QTestTypeInfo<int>::IsEnum);
+ QVERIFY(!QTestTypeInfo<char>::IsEnum);
+ QVERIFY(!QTestTypeInfo<uint>::IsEnum);
+ QVERIFY(!QTestTypeInfo<short>::IsEnum);
+ QVERIFY(!QTestTypeInfo<ushort>::IsEnum);
+ QVERIFY(!QTestTypeInfo<void*>::IsEnum);
+ QVERIFY(!QTestTypeInfo<QString>::IsEnum);
+ QVERIFY(QTestTypeInfo<Qt::Key>::IsEnum);
+ QVERIFY(QTestTypeInfo<Qt::ToolBarArea>::IsEnum);
+ QVERIFY(!QTestTypeInfo<Qt::ToolBarAreas>::IsEnum);
+ QVERIFY(QTestTypeInfo<Qt::MatchFlag>::IsEnum);
+ QVERIFY(!QTestTypeInfo<Qt::MatchFlags>::IsEnum);
+}
+#else
+void tst_Compiler::detectEnums()
+{ QSKIP("Compiler doesn't evaluate templates correctly", SkipAll); }
+#endif
+
+static int indicator = 0;
+
+
+// this is a silly C function
+extern "C" {
+ void someCFunc(void *) { indicator = 42; }
+}
+
+// this is the catch-template that will be called if the C function doesn't exist
+template <typename T>
+void someCFunc(T *) { indicator = 10; }
+
+void tst_Compiler::overrideCFunction()
+{
+ someCFunc((void*)0);
+ QCOMPARE(indicator, 42);
+}
+
+#ifndef DONT_TEST_STL_SORTING
+void tst_Compiler::stdSortQList()
+{
+ QList<int> list;
+ list << 4 << 2;
+ std::sort(list.begin(), list.end());
+ QCOMPARE(list.value(0), 2);
+ QCOMPARE(list.value(1), 4);
+
+ QList<QString> slist;
+ slist << "b" << "a";
+ std::sort(slist.begin(), slist.end());
+ QCOMPARE(slist.value(0), QString("a"));
+ QCOMPARE(slist.value(1), QString("b"));
+}
+
+void tst_Compiler::stdSortQVector()
+{
+ QVector<int> vector;
+ vector << 4 << 2;
+ std::sort(vector.begin(), vector.end());
+ QCOMPARE(vector.value(0), 2);
+ QCOMPARE(vector.value(1), 4);
+
+ QVector<QString> strvec;
+ strvec << "b" << "a";
+ std::sort(strvec.begin(), strvec.end());
+ QCOMPARE(strvec.value(0), QString("a"));
+ QCOMPARE(strvec.value(1), QString("b"));
+}
+#else
+void tst_Compiler::stdSortQList()
+{ QSKIP("Compiler's STL broken", SkipAll); }
+void tst_Compiler::stdSortQVector()
+{ QSKIP("Compiler's STL broken", SkipAll); }
+#endif
+
+// the C func will set it to 1, the template to 2
+static int whatWasCalled = 0;
+
+void callOrderFunc(void *)
+{
+ whatWasCalled = 1;
+}
+
+template <typename T>
+void callOrderFunc(T *)
+{
+ whatWasCalled = 2;
+}
+
+template <typename T>
+void callOrderNoCFunc(T *)
+{
+ whatWasCalled = 3;
+}
+
+/*
+ This test will check what will get precendence - the C function
+ or the template.
+
+ It also makes sure this template "override" will compile on all systems
+ and not result in ambiguities.
+*/
+void tst_Compiler::templateCallOrder()
+{
+ QCOMPARE(whatWasCalled, 0);
+
+ // call it with a void *
+ void *f = 0;
+ callOrderFunc(f);
+ QCOMPARE(whatWasCalled, 1);
+ whatWasCalled = 0;
+
+ char *c = 0;
+ /* call it with a char * - AMBIGOUS, fails on several compilers
+ callOrderFunc(c);
+ QCOMPARE(whatWasCalled, 1);
+ whatWasCalled = 0;
+ */
+
+ // now try the case when there is no C function
+ callOrderNoCFunc(f);
+ QCOMPARE(whatWasCalled, 3);
+ whatWasCalled = 0;
+
+ callOrderNoCFunc(c);
+ QCOMPARE(whatWasCalled, 3);
+ whatWasCalled = 0;
+}
+
+// test to see if removing =0 from a pure virtual function is BC
+void tst_Compiler::virtualFunctionNoLongerPureVirtual()
+{
+#ifdef BASECLASS_NOT_ABSTRACT
+ // has a single virtual function, not pure virtual, can call it
+ BaseClass baseClass;
+ QTest::ignoreMessage(QtDebugMsg, "BaseClass::wasAPureVirtualFunction()");
+ baseClass.wasAPureVirtualFunction();
+#endif
+
+ // DerivedClass inherits from BaseClass, and function is declared
+ // pure virtual, make sure we can still call it
+ DerivedClass derivedClass;
+ QTest::ignoreMessage(QtDebugMsg, "DerivedClass::wasAPureVirtualFunction()");
+ derivedClass.wasAPureVirtualFunction();
+}
+
+template<typename T> const char *resolveCharSignedness();
+
+template<>
+const char *resolveCharSignedness<char>()
+{
+ return "char";
+}
+
+template<>
+const char *resolveCharSignedness<unsigned char>()
+{
+ return "unsigned char";
+}
+
+template<>
+const char *resolveCharSignedness<signed char>()
+{
+ return "signed char";
+}
+
+void tst_Compiler::charSignedness() const
+{
+#ifdef DONT_TEST_SIGNEDNESS
+ QSKIP("MS VC 6.0 instantiates the char function for type unsigned char.", SkipSingle);
+#else
+ QCOMPARE("char", resolveCharSignedness<char>());
+ QCOMPARE("unsigned char", resolveCharSignedness<unsigned char>());
+ QCOMPARE("signed char", resolveCharSignedness<signed char>());
+#endif
+}
+
+class PrivateStaticTemplateMember
+{
+public:
+ long regularMember()
+ {
+ return helper<long, int>(3);
+ }
+
+private:
+ template<typename A, typename B>
+ static A helper(const B b)
+ {
+ return A(b);
+ }
+};
+
+void tst_Compiler::privateStaticTemplateMember() const
+{
+ PrivateStaticTemplateMember v;
+
+ QCOMPARE(long(3), v.regularMember());
+}
+
+
+#if !defined(Q_CC_MIPS)
+
+// make sure we can use a static initializer with a union and then use
+// the second member of the union
+static const union { unsigned char c[8]; double d; } qt_be_inf_bytes = { { 0x7f, 0xf0, 0, 0, 0, 0, 0, 0 } };
+static const union { unsigned char c[8]; double d; } qt_le_inf_bytes = { { 0, 0, 0, 0, 0, 0, 0xf0, 0x7f } };
+static const union { unsigned char c[8]; double d; } qt_armfpa_inf_bytes = { { 0, 0, 0xf0, 0x7f, 0, 0, 0, 0 } };
+static inline double qt_inf()
+{
+#ifdef QT_ARMFPA
+ return qt_armfpa_inf_bytes.d;
+#else
+ return (QSysInfo::ByteOrder == QSysInfo::BigEndian
+ ? qt_be_inf_bytes.d
+ : qt_le_inf_bytes.d);
+#endif
+}
+
+#else
+
+static const unsigned char qt_be_inf_bytes[] = { 0x7f, 0xf0, 0, 0, 0, 0, 0, 0 };
+static const unsigned char qt_le_inf_bytes[] = { 0, 0, 0, 0, 0, 0, 0xf0, 0x7f };
+static const unsigned char qt_armfpa_inf_bytes[] = { 0, 0, 0xf0, 0x7f, 0, 0, 0, 0 };
+static inline double qt_inf()
+{
+ const uchar *bytes;
+#ifdef QT_ARMFPA
+ bytes = qt_armfpa_inf_bytes;
+#else
+ bytes = (QSysInfo::ByteOrder == QSysInfo::BigEndian
+ ? qt_be_inf_bytes
+ : qt_le_inf_bytes);
+#endif
+
+ union { uchar c[8]; double d; } returnValue;
+ memcpy(returnValue.c, bytes, sizeof(returnValue.c));
+ return returnValue.d;
+}
+
+#endif
+
+void tst_Compiler::staticConstUnionWithInitializerList() const
+{
+ double d = qt_inf();
+ QVERIFY(qIsInf(d));
+}
+
+QTEST_MAIN(tst_Compiler)
+#include "tst_compiler.moc"
diff --git a/tests/auto/other/headersclean/headersclean.pro b/tests/auto/other/headersclean/headersclean.pro
new file mode 100644
index 0000000000..d18dc1c0a2
--- /dev/null
+++ b/tests/auto/other/headersclean/headersclean.pro
@@ -0,0 +1,7 @@
+load(qttest_p4)
+SOURCES += tst_headersclean.cpp
+QT = core network xml sql
+CONFIG += uitools
+
+contains(QT_CONFIG,dbus): QT += dbus
+contains(QT_CONFIG,opengl): QT += opengl
diff --git a/tests/auto/other/headersclean/tst_headersclean.cpp b/tests/auto/other/headersclean/tst_headersclean.cpp
new file mode 100644
index 0000000000..831e7fe50a
--- /dev/null
+++ b/tests/auto/other/headersclean/tst_headersclean.cpp
@@ -0,0 +1,75 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.1, 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.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#define QT_NO_KEYWORDS
+#define signals int
+#define slots int
+#define emit public:;
+#define foreach public:;
+#define forever public:;
+
+#include <QtCore/QtCore>
+#include <QtTest/QtTest>
+
+#include <QtNetwork/QtNetwork>
+#include <QtXml/QtXml>
+#include <QtSql/QtSql>
+#include <QtGui/QtGui>
+
+#include <QtUiTools/QtUiTools>
+
+#ifndef QT_NO_OPENGL
+#include <QtOpenGL/QtOpenGL>
+#endif
+
+#if !defined(QT_NO_DBUS) && defined(Q_OS_UNIX)
+#include <QtDBus/QtDBus>
+#endif
+
+class tst_HeadersClean: public QObject
+{
+ Q_OBJECT
+public:
+ tst_HeadersClean() {}
+};
+
+QTEST_MAIN(tst_HeadersClean)
+#include "tst_headersclean.moc" \ No newline at end of file
diff --git a/tests/auto/other/maketestselftest/checktest/checktest.pro b/tests/auto/other/maketestselftest/checktest/checktest.pro
new file mode 100644
index 0000000000..79c5ca55e2
--- /dev/null
+++ b/tests/auto/other/maketestselftest/checktest/checktest.pro
@@ -0,0 +1,7 @@
+TEMPLATE = app
+TARGET = checktest
+CONFIG += console
+CONFIG -= app_bundle
+DESTDIR = ./
+QT = core
+SOURCES += main.cpp
diff --git a/tests/auto/other/maketestselftest/checktest/main.cpp b/tests/auto/other/maketestselftest/checktest/main.cpp
new file mode 100644
index 0000000000..b2f3cad894
--- /dev/null
+++ b/tests/auto/other/maketestselftest/checktest/main.cpp
@@ -0,0 +1,99 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.1, 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.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QCoreApplication>
+#include <QDir>
+#include <QFile>
+#include <QFileInfo>
+#include <QStringList>
+
+#include <stdio.h>
+#include <stdlib.h>
+
+void fail(QString const& message)
+{
+ printf("CHECKTEST FAIL: %s\n", qPrintable(message));
+ exit(0);
+}
+
+void pass(QString const& message)
+{
+ printf("CHECKTEST PASS: %s\n", qPrintable(message));
+ exit(0);
+}
+
+int main(int argc, char** argv)
+{
+ QCoreApplication app(argc, argv);
+
+ QStringList args = app.arguments();
+ args.removeFirst(); // ourself
+
+ QString args_quoted = QString("'%1'").arg(args.join("','"));
+
+#ifdef Q_WS_QWS
+ {
+ // for QWS we expect tests to be run as the QWS server
+ QString qws = args.takeLast();
+ if (qws != "-qws") {
+ fail(QString("Expected test to be run with `-qws', but it wasn't; args: %1").arg(args_quoted));
+ }
+ }
+#endif
+
+ if (args.count() != 1) {
+ fail(QString("These arguments are not what I expected: %1").arg(args_quoted));
+ }
+
+ QString test = args.at(0);
+
+ QFileInfo testfile(test);
+ if (!testfile.exists()) {
+ fail(QString("File %1 does not exist (my working directory is: %2, my args are: %3)")
+ .arg(test)
+ .arg(QDir::currentPath())
+ .arg(args_quoted)
+ );
+ }
+
+ pass(args_quoted);
+}
+
diff --git a/tests/auto/other/maketestselftest/features/dump_subdirs.prf b/tests/auto/other/maketestselftest/features/dump_subdirs.prf
new file mode 100644
index 0000000000..2547f58d5b
--- /dev/null
+++ b/tests/auto/other/maketestselftest/features/dump_subdirs.prf
@@ -0,0 +1,4 @@
+for(dir, SUBDIRS) {
+ message(subdir: $$dir)
+}
+
diff --git a/tests/auto/other/maketestselftest/maketestselftest.pro b/tests/auto/other/maketestselftest/maketestselftest.pro
new file mode 100644
index 0000000000..a27d5d7934
--- /dev/null
+++ b/tests/auto/other/maketestselftest/maketestselftest.pro
@@ -0,0 +1,6 @@
+TEMPLATE = subdirs
+SUBDIRS = checktest test
+test.depends = checktest
+
+requires(!cross_compile)
+
diff --git a/tests/auto/other/maketestselftest/test/test.pro b/tests/auto/other/maketestselftest/test/test.pro
new file mode 100644
index 0000000000..d9de51e1a3
--- /dev/null
+++ b/tests/auto/other/maketestselftest/test/test.pro
@@ -0,0 +1,18 @@
+load(qttest_p4)
+
+TARGET = ../tst_maketestselftest
+SOURCES += ../tst_maketestselftest.cpp
+QT = core
+
+DEFINES += SRCDIR=\\\"$$PWD/..\\\"
+
+requires(!cross_compile)
+
+win32 {
+ CONFIG(debug, debug|release) {
+ TARGET = ../../debug/tst_maketestselftest
+} else {
+ TARGET = ../../release/tst_maketestselftest
+ }
+}
+
diff --git a/tests/auto/other/maketestselftest/tst_maketestselftest.cpp b/tests/auto/other/maketestselftest/tst_maketestselftest.cpp
new file mode 100644
index 0000000000..59dd43cb40
--- /dev/null
+++ b/tests/auto/other/maketestselftest/tst_maketestselftest.cpp
@@ -0,0 +1,561 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.1, 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.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QDir>
+#include <QFile>
+#include <QRegExp>
+#include <QStringList>
+#include <QTest>
+#include <QSet>
+#include <QProcess>
+#include <QDebug>
+
+enum FindSubdirsMode {
+ Flat = 0,
+ Recursive
+};
+
+class tst_MakeTestSelfTest: public QObject
+{
+ Q_OBJECT
+
+private slots:
+ void tests_pro_files();
+ void tests_pro_files_data();
+
+ void naming_convention();
+ void naming_convention_data();
+
+ void make_check();
+
+private:
+ QStringList find_subdirs(QString const&, FindSubdirsMode, QString const& = QString());
+
+ QSet<QString> all_test_classes;
+};
+
+bool looks_like_testcase(QString const&,QString*);
+bool looks_like_subdirs(QString const&);
+QStringList find_test_class(QString const&);
+
+/* Verify that all tests are listed somewhere in one of the autotest .pro files */
+void tst_MakeTestSelfTest::tests_pro_files()
+{
+ static QStringList lines;
+
+ if (lines.isEmpty()) {
+ QDir dir(SRCDIR "/..");
+ QStringList proFiles = dir.entryList(QStringList() << "*.pro");
+ foreach (QString const& proFile, proFiles) {
+ QString filename = QString("%1/../%2").arg(SRCDIR).arg(proFile);
+ QFile file(filename);
+ if (!file.open(QIODevice::ReadOnly)) {
+ QFAIL(qPrintable(QString("open %1: %2").arg(filename).arg(file.errorString())));
+ }
+ while (!file.atEnd()) {
+ lines << file.readLine().trimmed();
+ }
+ }
+ }
+
+ QFETCH(QString, subdir);
+ QRegExp re(QString("( |=|^|#)%1( |\\\\|$)").arg(QRegExp::escape(subdir)));
+ foreach (const QString& line, lines) {
+ if (re.indexIn(line) != -1) {
+ return;
+ }
+ }
+
+
+
+ QFAIL(qPrintable(QString(
+ "Subdir `%1' is missing from tests/auto/*.pro\n"
+ "This means the test won't be compiled or run on any platform.\n"
+ "If this is intentional, please put the test name in a comment in one of the .pro files.").arg(subdir))
+ );
+
+}
+
+void tst_MakeTestSelfTest::tests_pro_files_data()
+{
+ QTest::addColumn<QString>("subdir");
+ QDir dir(SRCDIR "/..");
+ QStringList subdirs = dir.entryList(QDir::AllDirs|QDir::NoDotAndDotDot);
+
+ foreach (const QString& subdir, subdirs) {
+ if (subdir == QString::fromLatin1("tmp")
+ || subdir.startsWith(".")
+ || !dir.exists(subdir + "/" + subdir + ".pro"))
+ {
+ continue;
+ }
+ QTest::newRow(qPrintable(subdir)) << subdir;
+ }
+}
+
+QString format_list(QStringList const& list)
+{
+ if (list.count() == 1) {
+ return list.at(0);
+ }
+ return QString("one of (%1)").arg(list.join(", "));
+}
+
+void tst_MakeTestSelfTest::naming_convention()
+{
+ QFETCH(QString, subdir);
+ QFETCH(QString, target);
+
+ QDir dir(SRCDIR "/../" + subdir);
+
+ QStringList cppfiles = dir.entryList(QStringList() << "*.h" << "*.cpp");
+ if (cppfiles.isEmpty()) {
+ // Common convention is to have test/test.pro and source files in parent dir
+ if (dir.dirName() == "test") {
+ dir.cdUp();
+ cppfiles = dir.entryList(QStringList() << "*.h" << "*.cpp");
+ }
+
+ if (cppfiles.isEmpty()) {
+ QSKIP("Couldn't locate source files for test", SkipSingle);
+ }
+ }
+
+ QStringList possible_test_classes;
+ foreach (QString const& file, cppfiles) {
+ possible_test_classes << find_test_class(dir.path() + "/" + file);
+ }
+
+ if (possible_test_classes.isEmpty()) {
+ QSKIP(qPrintable(QString("Couldn't locate test class in %1").arg(format_list(cppfiles))), SkipSingle);
+ }
+
+ QVERIFY2(possible_test_classes.contains(target), qPrintable(QString(
+ "TARGET is %1, while test class appears to be %2.\n"
+ "TARGET and test class _must_ match so that all testcase names can be accurately "
+ "determined even if a test fails to compile or run.")
+ .arg(target)
+ .arg(format_list(possible_test_classes))
+ ));
+
+ QVERIFY2(!all_test_classes.contains(target), qPrintable(QString(
+ "It looks like there are multiple tests named %1.\n"
+ "This makes it impossible to separate results for these tests.\n"
+ "Please ensure all tests are uniquely named.")
+ .arg(target)
+ ));
+
+ all_test_classes << target;
+}
+
+void tst_MakeTestSelfTest::naming_convention_data()
+{
+ QTest::addColumn<QString>("subdir");
+ QTest::addColumn<QString>("target");
+
+ foreach (const QString& subdir, find_subdirs(SRCDIR "/../auto.pro", Recursive)) {
+ if (QFileInfo(SRCDIR "/../" + subdir).isDir()) {
+ QString target;
+ if (looks_like_testcase(SRCDIR "/../" + subdir + "/" + QFileInfo(subdir).baseName() + ".pro", &target)) {
+ QTest::newRow(qPrintable(subdir)) << subdir << target.toLower();
+ }
+ }
+ }
+}
+
+/*
+ Returns true if a .pro file seems to be for an autotest.
+ Running qmake to figure this out takes too long.
+*/
+bool looks_like_testcase(QString const& pro_file, QString* target)
+{
+ QFile file(pro_file);
+ if (!file.open(QIODevice::ReadOnly)) {
+ return false;
+ }
+
+ *target = QString();
+
+ bool loaded_qttest = false;
+
+ do {
+ QByteArray line = file.readLine();
+ if (line.isEmpty()) {
+ break;
+ }
+
+ line = line.trimmed();
+ line.replace(' ', "");
+
+ if (line == "load(qttest_p4)") {
+ loaded_qttest = true;
+ }
+
+ if (line.startsWith("TARGET=")) {
+ *target = QString::fromLatin1(line.mid(sizeof("TARGET=")-1));
+ if (target->contains('/')) {
+ *target = target->right(target->lastIndexOf('/')+1);
+ }
+ }
+
+ if (loaded_qttest && !target->isEmpty()) {
+ break;
+ }
+ } while(1);
+
+ if (!loaded_qttest) {
+ return false;
+ }
+
+ if (!target->isEmpty() && !target->startsWith("tst_")) {
+ return false;
+ }
+
+ // If no target was set, default to tst_<dirname>
+ if (target->isEmpty()) {
+ *target = "tst_" + QFileInfo(pro_file).baseName();
+ }
+
+ return true;
+}
+
+/*
+ Returns true if a .pro file seems to be a subdirs project.
+ Running qmake to figure this out takes too long.
+*/
+bool looks_like_subdirs(QString const& pro_file)
+{
+ QFile file(pro_file);
+ if (!file.open(QIODevice::ReadOnly)) {
+ return false;
+ }
+
+ do {
+ QByteArray line = file.readLine();
+ if (line.isEmpty()) {
+ break;
+ }
+
+ line = line.trimmed();
+ line.replace(' ', "");
+
+ if (line == "TEMPLATE=subdirs") {
+ return true;
+ }
+ } while(1);
+
+ return false;
+}
+
+/*
+ Returns a list of all subdirs in a given .pro file
+*/
+QStringList tst_MakeTestSelfTest::find_subdirs(QString const& pro_file, FindSubdirsMode mode, QString const& prefix)
+{
+ QStringList out;
+
+ QByteArray features = qgetenv("QMAKEFEATURES");
+
+ if (features.isEmpty()) {
+ features = SRCDIR "/features";
+ }
+ else {
+ features.prepend(SRCDIR "/features"
+#ifdef Q_OS_WIN32
+ ";"
+#else
+ ":"
+#endif
+ );
+ }
+
+ QStringList args;
+ args << pro_file << "-o" << SRCDIR "/dummy_output" << "CONFIG+=dump_subdirs";
+
+ /* Turn on every option there is, to ensure we process every single directory */
+ args
+ << "QT_CONFIG+=dbus"
+ << "QT_CONFIG+=declarative"
+ << "QT_CONFIG+=egl"
+ << "QT_CONFIG+=multimedia"
+ << "QT_CONFIG+=OdfWriter"
+ << "QT_CONFIG+=opengl"
+ << "QT_CONFIG+=openvg"
+ << "QT_CONFIG+=phonon"
+ << "QT_CONFIG+=private_tests"
+ << "QT_CONFIG+=pulseaudio"
+ << "QT_CONFIG+=script"
+ << "QT_CONFIG+=svg"
+ << "QT_CONFIG+=webkit"
+ << "QT_CONFIG+=xmlpatterns"
+ << "CONFIG+=mac"
+ << "CONFIG+=embedded"
+ << "CONFIG+=symbian"
+ ;
+
+
+
+ QString cmd_with_args = QString("qmake %1").arg(args.join(" "));
+
+ QProcess proc;
+
+ proc.setProcessChannelMode(QProcess::MergedChannels);
+
+ QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
+ env.insert("QMAKEFEATURES", features);
+ proc.setProcessEnvironment(env);
+
+ proc.start("qmake", args);
+ if (!proc.waitForStarted(10000)) {
+ QTest::qFail(qPrintable(QString("Failed to run qmake: %1\nCommand: %2")
+ .arg(proc.errorString())
+ .arg(cmd_with_args)),
+ __FILE__, __LINE__
+ );
+ return out;
+ }
+ if (!proc.waitForFinished(30000)) {
+ QTest::qFail(qPrintable(QString("qmake did not finish within 30 seconds\nCommand: %1\nOutput: %2")
+ .arg(proc.errorString())
+ .arg(cmd_with_args)
+ .arg(QString::fromLocal8Bit(proc.readAll()))),
+ __FILE__, __LINE__
+ );
+ return out;
+ }
+
+ if (proc.exitStatus() != QProcess::NormalExit) {
+ QTest::qFail(qPrintable(QString("qmake crashed\nCommand: %1\nOutput: %2")
+ .arg(cmd_with_args)
+ .arg(QString::fromLocal8Bit(proc.readAll()))),
+ __FILE__, __LINE__
+ );
+ return out;
+ }
+
+ if (proc.exitCode() != 0) {
+ QTest::qFail(qPrintable(QString("qmake exited with code %1\nCommand: %2\nOutput: %3")
+ .arg(proc.exitCode())
+ .arg(cmd_with_args)
+ .arg(QString::fromLocal8Bit(proc.readAll()))),
+ __FILE__, __LINE__
+ );
+ return out;
+ }
+
+ QList<QByteArray> lines = proc.readAll().split('\n');
+ if (!lines.count()) {
+ QTest::qFail(qPrintable(QString("qmake seems to have not output anything\nCommand: %1\n")
+ .arg(cmd_with_args)),
+ __FILE__, __LINE__
+ );
+ return out;
+ }
+
+ foreach (QByteArray const& line, lines) {
+ static const QByteArray marker = "Project MESSAGE: subdir: ";
+ if (line.startsWith(marker)) {
+ QString subdir = QString::fromLocal8Bit(line.mid(marker.size()).trimmed());
+ out << prefix + subdir;
+
+ if (mode == Flat) {
+ continue;
+ }
+
+ // Need full path to subdir
+ QString subdir_filepath = subdir;
+ subdir_filepath.prepend(QFileInfo(pro_file).path() + "/");
+
+ // Add subdirs recursively
+ if (subdir.endsWith(".pro") && looks_like_subdirs(subdir_filepath)) {
+ // Need full path to .pro file
+ out << find_subdirs(subdir_filepath, mode, prefix);
+ }
+
+ if (QFileInfo(subdir_filepath).isDir()) {
+ subdir_filepath += "/" + subdir + ".pro";
+ if (looks_like_subdirs(subdir_filepath)) {
+ out << find_subdirs(subdir_filepath, mode, prefix + subdir + "/");
+ }
+ }
+ }
+ }
+
+ return out;
+}
+
+void tst_MakeTestSelfTest::make_check()
+{
+ /*
+ Run `make check' over the whole tests tree with a custom TESTRUNNER,
+ to verify that the TESTRUNNER mechanism works right.
+ */
+ QString testsDir(SRCDIR "/..");
+ QString checktest(SRCDIR "/checktest/checktest");
+
+#if defined(Q_OS_WIN32) || defined(Q_OS_MAC)
+ if (qgetenv("RUN_SLOW_TESTS").isEmpty()) {
+ QSKIP("This test is too slow to run by default on this OS. Set RUN_SLOW_TESTS=1 to run it.", SkipAll);
+ }
+#endif
+
+#ifdef Q_OS_WIN32
+ checktest.replace("/", "\\");
+ checktest += ".exe";
+#endif
+
+ QProcess make;
+ make.setWorkingDirectory(testsDir);
+
+ QStringList arguments;
+ arguments << "-k";
+ arguments << "check";
+ arguments << QString("TESTRUNNER=%1").arg(checktest);
+
+ // find the right make; from externaltests.cpp
+ static const char makes[] =
+ "nmake.exe\0"
+ "mingw32-make.exe\0"
+ "gmake\0"
+ "make\0"
+ ;
+
+ bool ok = false;
+ for (const char *p = makes; *p; p += strlen(p) + 1) {
+ make.start(p, arguments);
+ if (make.waitForStarted()) {
+ ok = true;
+ break;
+ }
+ }
+
+ if (!ok) {
+ QFAIL("Could not find the right make tool in PATH");
+ }
+
+ QVERIFY(make.waitForFinished(1000 * 60 * 10));
+ QCOMPARE(make.exitStatus(), QProcess::NormalExit);
+
+ int pass = 0;
+ QList<QByteArray> out = make.readAllStandardOutput().split('\n');
+ QStringList fails;
+ foreach (QByteArray line, out) {
+ while (line.endsWith("\r")) {
+ line.chop(1);
+ }
+ if (line.startsWith("CHECKTEST FAIL")) {
+ fails << QString::fromLocal8Bit(line);
+ }
+ if (line.startsWith("CHECKTEST PASS")) {
+ ++pass;
+ }
+ }
+
+ // We can't check that the exit code of make is 0, because some tests
+ // may have failed to compile, but that doesn't mean `make check' is broken.
+ // We do assume there are at least this many unbroken tests, though.
+ QVERIFY2(fails.count() == 0,
+ qPrintable(QString("`make check' doesn't work for %1 tests:\n%2")
+ .arg(fails.count()).arg(fails.join("\n")))
+ );
+ QVERIFY(pass > 50);
+}
+
+QStringList find_test_class(QString const& filename)
+{
+ QStringList out;
+
+ QFile file(filename);
+ if (!file.open(QIODevice::ReadOnly)) {
+ return out;
+ }
+
+ static char const* klass_indicators[] = {
+ "QTEST_MAIN(",
+ "QTEST_APPLESS_MAIN(",
+ "class",
+ "staticconstcharklass[]=\"", /* hax0r tests which define their own metaobject */
+ 0
+ };
+
+ do {
+ QByteArray line = file.readLine();
+ if (line.isEmpty()) {
+ break;
+ }
+
+ line = line.trimmed();
+ line.replace(' ', "");
+
+ for (int i = 0; klass_indicators[i]; ++i) {
+ char const* prefix = klass_indicators[i];
+ if (!line.startsWith(prefix)) {
+ continue;
+ }
+ QByteArray klass = line.mid(strlen(prefix));
+ if (!klass.startsWith("tst_")) {
+ continue;
+ }
+ for (int j = 0; j < klass.size(); ++j) {
+ char c = klass[j];
+ if (c == '_'
+ || (c >= '0' && c <= '9')
+ || (c >= 'A' && c <= 'Z')
+ || (c >= 'a' && c <= 'z')) {
+ continue;
+ }
+ else {
+ klass.truncate(j);
+ break;
+ }
+ }
+ QString klass_str = QString::fromLocal8Bit(klass).toLower();
+ if (!out.contains(klass_str))
+ out << klass_str;
+ break;
+ }
+ } while(1);
+
+ return out;
+}
+
+QTEST_MAIN(tst_MakeTestSelfTest)
+#include "tst_maketestselftest.moc"
diff --git a/tests/auto/other/other.pro b/tests/auto/other/other.pro
new file mode 100644
index 0000000000..30d153156c
--- /dev/null
+++ b/tests/auto/other/other.pro
@@ -0,0 +1,11 @@
+TEMPLATE=subdirs
+SUBDIRS=\
+ qtmd5 \
+ qtokenautomaton \
+ baselineexample \
+
+!cross_compile: SUBDIRS += \
+ compiler \
+ headersclean \
+ maketestselftest \
+ # atwrapper \ # QTBUG-19452
diff --git a/tests/auto/other/qtmd5/.gitignore b/tests/auto/other/qtmd5/.gitignore
new file mode 100644
index 0000000000..6028bec654
--- /dev/null
+++ b/tests/auto/other/qtmd5/.gitignore
@@ -0,0 +1 @@
+tst_qtmd5
diff --git a/tests/auto/other/qtmd5/qtmd5.pro b/tests/auto/other/qtmd5/qtmd5.pro
new file mode 100644
index 0000000000..6973c9e5be
--- /dev/null
+++ b/tests/auto/other/qtmd5/qtmd5.pro
@@ -0,0 +1,15 @@
+include(../../solutions.pri)
+
+!contains(DEFINES, QT_NO_SOLUTIONS) {
+ include($${SOLUTIONBASEDIR}/utils/qtmd5/src/qtmd5.pri)
+}
+
+load(qttest_p4)
+
+SOURCES += tst_qtmd5.cpp
+
+
+QT = core
+
+
+CONFIG += parallel_test
diff --git a/tests/auto/other/qtmd5/tst_qtmd5.cpp b/tests/auto/other/qtmd5/tst_qtmd5.cpp
new file mode 100644
index 0000000000..8c87ba74e9
--- /dev/null
+++ b/tests/auto/other/qtmd5/tst_qtmd5.cpp
@@ -0,0 +1,84 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.1, 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.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#include <QtTest/QtTest>
+
+#ifdef QT_NO_SOLUTIONS
+QTEST_NOOP_MAIN
+#else
+
+#include "qtmd5.h"
+
+class tst_QtMD5: public QObject
+{
+ Q_OBJECT
+
+private slots:
+ void computeMD5_data();
+ void computeMD5();
+};
+
+void tst_QtMD5::computeMD5_data()
+{
+ QTest::addColumn<QByteArray>("data");
+ QTest::addColumn<QString>("expected");
+
+ QTest::newRow("data0") << QByteArray("") << QString("d41d8cd98f00b204e9800998ecf8427e");
+ QTest::newRow("data1") << QByteArray("a") << QString("0cc175b9c0f1b6a831c399e269772661");
+ QTest::newRow("data2") << QByteArray("abc") << QString("900150983cd24fb0d6963f7d28e17f72");
+ QTest::newRow("data3") << QByteArray("message digest") << QString("f96b697d7cb7938d525a2f31aaf161d0");
+ QTest::newRow("data4") << QByteArray("abcdefghijklmnopqrstuvwxyz") << QString("c3fcd3d76192e4007dfb496cca67e13b");
+ QTest::newRow("data5") << QByteArray("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789") << QString("d174ab98d277d9f5a5611c2c9f419d9f");
+ QTest::newRow("data6") << QByteArray("12345678901234567890123456789012345678901234567890123456789012345678901234567890") << QString("57edf4a22be3c955ac49da2e2107b67a");
+}
+
+void tst_QtMD5::computeMD5()
+{
+ QFETCH(QByteArray, data);
+ QFETCH(QString, expected);
+
+ QCOMPARE(qtMD5(data), expected);
+}
+
+QTEST_MAIN(tst_QtMD5)
+#include "tst_qtmd5.moc"
+#endif
diff --git a/tests/auto/other/qtokenautomaton/.gitignore b/tests/auto/other/qtokenautomaton/.gitignore
new file mode 100644
index 0000000000..3ec2df3434
--- /dev/null
+++ b/tests/auto/other/qtokenautomaton/.gitignore
@@ -0,0 +1,4 @@
+Makefile
+tmp/
+tst_qtokenautomaton
+tst_qtokenautomaton
diff --git a/tests/auto/other/qtokenautomaton/generateTokenizers.sh b/tests/auto/other/qtokenautomaton/generateTokenizers.sh
new file mode 100755
index 0000000000..0fb602aae4
--- /dev/null
+++ b/tests/auto/other/qtokenautomaton/generateTokenizers.sh
@@ -0,0 +1,50 @@
+#!/bin/bash
+#############################################################################
+##
+## Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+## All rights reserved.
+## Contact: Nokia Corporation (qt-info@nokia.com)
+##
+## This file is the build configuration utility of the Qt Toolkit.
+##
+## $QT_BEGIN_LICENSE:LGPL$
+## GNU Lesser General Public License Usage
+## 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.1, 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.
+##
+## Other Usage
+## Alternatively, this file may be used in accordance with the terms and
+## conditions contained in a signed written agreement between you and Nokia.
+##
+##
+##
+##
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+tokenizers=`find tokenizers/* -type d`
+for tokenizer in $tokenizers; do
+ pushd $tokenizer
+ basename=`basename $tokenizer`
+ xmllint --noout --schema ../../../../../src/xmlpatterns/qtokenautomaton/qtokenautomaton.xsd $basename.xml
+ java net.sf.saxon.Transform -xsl:../../../../../src/xmlpatterns/qtokenautomaton/qautomaton2cpp.xsl $basename.xml
+ popd
+done
diff --git a/tests/auto/other/qtokenautomaton/qtokenautomaton.pro b/tests/auto/other/qtokenautomaton/qtokenautomaton.pro
new file mode 100644
index 0000000000..5e2e590a4b
--- /dev/null
+++ b/tests/auto/other/qtokenautomaton/qtokenautomaton.pro
@@ -0,0 +1,18 @@
+load(qttest_p4)
+SOURCES += tst_qtokenautomaton.cpp \
+ tokenizers/basic/basic.cpp \
+ tokenizers/basicNamespace/basicNamespace.cpp \
+ tokenizers/boilerplate/boilerplate.cpp \
+ tokenizers/noNamespace/noNamespace.cpp \
+ tokenizers/noToString/noToString.cpp \
+ tokenizers/withNamespace/withNamespace.cpp
+
+HEADERS += tokenizers/basic/basic.h \
+ tokenizers/basicNamespace/basicNamespace.h \
+ tokenizers/boilerplate/boilerplate.h \
+ tokenizers/noNamespace/noNamespace.h \
+ tokenizers/noToString/noToString.h \
+ tokenizers/withNamespace/withNamespace.h
+
+QT -= gui
+CONFIG += parallel_test
diff --git a/tests/auto/other/qtokenautomaton/tokenizers/basic/basic.cpp b/tests/auto/other/qtokenautomaton/tokenizers/basic/basic.cpp
new file mode 100644
index 0000000000..7f96e41894
--- /dev/null
+++ b/tests/auto/other/qtokenautomaton/tokenizers/basic/basic.cpp
@@ -0,0 +1,480 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.1, 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.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+/* NOTE: This file is AUTO GENERATED by qtokenautomaton2cpp.xsl. */
+
+#include "basic.h"
+
+QT_BEGIN_NAMESPACE
+
+Basic::Token Basic::classifier3(const QChar *data)
+
+ {
+ if (data[0] == 100)
+
+
+ {
+
+ static const unsigned short string[] =
+ {
+ 101, 102
+ };
+ if(memcmp(&data[1], &string, sizeof(QChar) * 2) == 0)
+
+
+ return _111;
+
+ }
+
+ else if (data[0] == 97)
+
+
+ {
+
+ static const unsigned short string[] =
+ {
+ 98, 99
+ };
+ if(memcmp(&data[1], &string, sizeof(QChar) * 2) == 0)
+
+
+ return _;
+
+ }
+
+ else if (data[0] == 103)
+
+
+ {
+
+ static const unsigned short string[] =
+ {
+ 104, 105
+ };
+ if(memcmp(&data[1], &string, sizeof(QChar) * 2) == 0)
+
+
+ return wobbly;
+
+ }
+
+
+
+ return NoKeyword;
+ }
+ Basic::Token Basic::classifier4(const QChar *data)
+
+ {
+ if (data[0] == 70)
+
+
+ {
+ if (data[1] == 70)
+
+
+ {
+ if (data[2] == 70)
+
+
+ {
+ if (data[3] == 70)
+
+
+ {
+
+
+ return FFFF;
+
+ }
+
+ else if (data[3] == 71)
+
+
+ {
+
+
+ return FFFG;
+
+ }
+
+
+ }
+
+ else if (data[2] == 71)
+
+
+ {
+ if (data[3] == 70)
+
+
+ {
+
+
+ return FFGF;
+
+ }
+
+ else if (data[3] == 71)
+
+
+ {
+
+
+ return FFGG;
+
+ }
+
+
+ }
+
+ else if (data[2] == 76)
+
+
+ {
+
+ if(data[3] == 77)
+
+
+ return FFLM;
+
+ }
+
+
+ }
+
+
+ }
+
+
+
+ return NoKeyword;
+ }
+ Basic::Token Basic::classifier9(const QChar *data)
+
+ {
+
+ static const unsigned short string[] =
+ {
+ 111, 110, 101, 58, 99, 111, 108, 111, 110
+ };
+ if(memcmp(&data[0], &string, sizeof(QChar) * 9) == 0)
+
+
+ return OneColon;
+
+
+ return NoKeyword;
+ }
+ Basic::Token Basic::classifier14(const QChar *data)
+
+ {
+ if (data[0] == 119)
+
+
+ {
+
+ static const unsigned short string[] =
+ {
+ 101, 45, 104, 97, 118, 101, 45, 100, 97, 115, 104, 101, 115
+ };
+ if(memcmp(&data[1], &string, sizeof(QChar) * 13) == 0)
+
+
+ return WeHaveDashes;
+
+ }
+
+ else if (data[0] == 99)
+
+
+ {
+
+ static const unsigned short string[] =
+ {
+ 111, 108, 111, 110, 58, 105, 110, 58, 110, 97, 109, 101, 58
+ };
+ if(memcmp(&data[1], &string, sizeof(QChar) * 13) == 0)
+
+
+ return ColonInName;
+
+ }
+
+
+
+ return NoKeyword;
+ }
+ Basic::Token Basic::classifier15(const QChar *data)
+
+ {
+
+ static const unsigned short string[] =
+ {
+ 119, 101, 45, 104, 97, 118, 101, 45, 100, 97, 115, 104, 101, 115, 45
+ };
+ if(memcmp(&data[0], &string, sizeof(QChar) * 15) == 0)
+
+
+ return WeHaveDashes2;
+
+
+ return NoKeyword;
+ }
+ Basic::Token Basic::classifier44(const QChar *data)
+
+ {
+
+ static const unsigned short string[] =
+ {
+ 97, 82, 101, 97, 108, 108, 121, 76, 111, 110, 103, 84, 111, 107, 101, 110, 73, 70, 114, 101, 97, 107, 105, 110, 77, 101, 97, 110, 73, 116, 85, 75, 110, 111, 119, 85, 75, 110, 111, 119, 75, 110, 111, 119
+ };
+ if(memcmp(&data[0], &string, sizeof(QChar) * 44) == 0)
+
+
+ return AReallyLongTokenIFreakinMeanItUKnowUKnowKnow;
+
+
+ return NoKeyword;
+ }
+ Basic::Token Basic::toToken(const QChar *data, int length)
+ {
+ switch(length)
+ {
+
+ case 3:
+ return classifier3(data);
+
+
+ case 4:
+ return classifier4(data);
+
+
+ case 9:
+ return classifier9(data);
+
+
+ case 14:
+ return classifier14(data);
+
+
+ case 15:
+ return classifier15(data);
+
+
+ case 44:
+ return classifier44(data);
+
+
+ default:
+ return NoKeyword;
+ }
+ }
+
+
+ QString Basic::toString(Token token)
+ {
+ const unsigned short *data = 0;
+ int length = 0;
+
+ switch(token)
+ {
+
+ case AReallyLongTokenIFreakinMeanItUKnowUKnowKnow:
+ {
+ static const unsigned short staticallyStoredAReallyLongTokenIFreakinMeanItUKnowUKnowKnow[] =
+ {
+ 97, 82, 101, 97, 108, 108, 121, 76, 111, 110, 103, 84, 111, 107, 101, 110, 73, 70, 114, 101, 97, 107, 105, 110, 77, 101, 97, 110, 73, 116, 85, 75, 110, 111, 119, 85, 75, 110, 111, 119, 75, 110, 111, 119, 0
+ };
+ data = staticallyStoredAReallyLongTokenIFreakinMeanItUKnowUKnowKnow;
+ length = 44;
+ break;
+ }
+
+ case ColonInName:
+ {
+ static const unsigned short staticallyStoredColonInName[] =
+ {
+ 99, 111, 108, 111, 110, 58, 105, 110, 58, 110, 97, 109, 101, 58, 0
+ };
+ data = staticallyStoredColonInName;
+ length = 14;
+ break;
+ }
+
+ case FFFF:
+ {
+ static const unsigned short staticallyStoredFFFF[] =
+ {
+ 70, 70, 70, 70, 0
+ };
+ data = staticallyStoredFFFF;
+ length = 4;
+ break;
+ }
+
+ case FFFG:
+ {
+ static const unsigned short staticallyStoredFFFG[] =
+ {
+ 70, 70, 70, 71, 0
+ };
+ data = staticallyStoredFFFG;
+ length = 4;
+ break;
+ }
+
+ case FFGF:
+ {
+ static const unsigned short staticallyStoredFFGF[] =
+ {
+ 70, 70, 71, 70, 0
+ };
+ data = staticallyStoredFFGF;
+ length = 4;
+ break;
+ }
+
+ case FFGG:
+ {
+ static const unsigned short staticallyStoredFFGG[] =
+ {
+ 70, 70, 71, 71, 0
+ };
+ data = staticallyStoredFFGG;
+ length = 4;
+ break;
+ }
+
+ case FFLM:
+ {
+ static const unsigned short staticallyStoredFFLM[] =
+ {
+ 70, 70, 76, 77, 0
+ };
+ data = staticallyStoredFFLM;
+ length = 4;
+ break;
+ }
+
+ case OneColon:
+ {
+ static const unsigned short staticallyStoredOneColon[] =
+ {
+ 111, 110, 101, 58, 99, 111, 108, 111, 110, 0
+ };
+ data = staticallyStoredOneColon;
+ length = 9;
+ break;
+ }
+
+ case WeHaveDashes:
+ {
+ static const unsigned short staticallyStoredWeHaveDashes[] =
+ {
+ 119, 101, 45, 104, 97, 118, 101, 45, 100, 97, 115, 104, 101, 115, 0
+ };
+ data = staticallyStoredWeHaveDashes;
+ length = 14;
+ break;
+ }
+
+ case WeHaveDashes2:
+ {
+ static const unsigned short staticallyStoredWeHaveDashes2[] =
+ {
+ 119, 101, 45, 104, 97, 118, 101, 45, 100, 97, 115, 104, 101, 115, 45, 0
+ };
+ data = staticallyStoredWeHaveDashes2;
+ length = 15;
+ break;
+ }
+
+ case _:
+ {
+ static const unsigned short staticallyStored_[] =
+ {
+ 97, 98, 99, 0
+ };
+ data = staticallyStored_;
+ length = 3;
+ break;
+ }
+
+ case _111:
+ {
+ static const unsigned short staticallyStored_111[] =
+ {
+ 100, 101, 102, 0
+ };
+ data = staticallyStored_111;
+ length = 3;
+ break;
+ }
+
+ case wobbly:
+ {
+ static const unsigned short staticallyStoredwobbly[] =
+ {
+ 103, 104, 105, 0
+ };
+ data = staticallyStoredwobbly;
+ length = 3;
+ break;
+ }
+
+ default:
+ /* It's either the default token, or an undefined enum
+ * value. We silence a compiler warning, and return the
+ * empty string. */
+ ;
+ }
+
+ union
+ {
+ const unsigned short *data;
+ const QChar *asQChar;
+ } converter;
+ converter.data = data;
+
+ return QString::fromRawData(converter.asQChar, length);
+ }
+
+QT_END_NAMESPACE
+
diff --git a/tests/auto/other/qtokenautomaton/tokenizers/basic/basic.h b/tests/auto/other/qtokenautomaton/tokenizers/basic/basic.h
new file mode 100644
index 0000000000..2f0efa1ffc
--- /dev/null
+++ b/tests/auto/other/qtokenautomaton/tokenizers/basic/basic.h
@@ -0,0 +1,101 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.1, 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.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+/* NOTE: This file is AUTO GENERATED by qtokenautomaton2cpp.xsl. */
+
+#ifndef q_Basic_h
+#define q_Basic_h
+
+#include <QtCore/QString>
+
+QT_BEGIN_NAMESPACE
+
+class Basic
+ {
+ public:
+ enum Token
+
+ {
+ NoKeyword,
+AReallyLongTokenIFreakinMeanItUKnowUKnowKnow,
+ColonInName,
+FFFF,
+FFFG,
+FFGF,
+FFGG,
+FFLM,
+OneColon,
+WeHaveDashes,
+WeHaveDashes2,
+_,
+_111,
+wobbly
+ };
+
+ static inline Token toToken(const QString &value);
+static inline Token toToken(const QStringRef &value);
+static Token toToken(const QChar *data, int length);
+static QString toString(Token token);
+
+
+ private:
+ static inline Token classifier3(const QChar *data);
+static inline Token classifier4(const QChar *data);
+static inline Token classifier9(const QChar *data);
+static inline Token classifier14(const QChar *data);
+static inline Token classifier15(const QChar *data);
+static inline Token classifier44(const QChar *data);
+
+ };
+
+ inline Basic::Token Basic::toToken(const QString &value)
+ {
+ return toToken(value.constData(), value.length());
+ }
+
+ inline Basic::Token Basic::toToken(const QStringRef &value)
+ {
+ return toToken(value.constData(), value.length());
+ }
+
+
+QT_END_NAMESPACE
+
+#endif
diff --git a/tests/auto/other/qtokenautomaton/tokenizers/basic/basic.xml b/tests/auto/other/qtokenautomaton/tokenizers/basic/basic.xml
new file mode 100644
index 0000000000..3d7ac868eb
--- /dev/null
+++ b/tests/auto/other/qtokenautomaton/tokenizers/basic/basic.xml
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<tokenAutomaton scope="public"
+ className="Basic"
+ headerFile="basic.h"
+ sourceFile="basic.cpp"
+ defaultToken="NoKeyword"
+ tokenEnum="Token"
+ hasToString="true"
+ includeGuardName="q_Basic_h">
+ <tokens>
+ <token>aReallyLongTokenIFreakinMeanItUKnowUKnowKnow</token>
+ <token>FFFF</token>
+ <token>FFFG</token>
+ <token>FFGF</token>
+ <token>FFGG</token>
+ <token>FFLM</token>
+ <token name="_111">def</token>
+ <token name="_">abc</token>
+ <token name="wobbly">ghi</token>
+ <token>we-have-dashes</token>
+ <token name="WeHaveDashes2">we-have-dashes-</token>
+ <token>colon:in:name:</token>
+ <token>one:colon</token>
+ </tokens>
+</tokenAutomaton>
diff --git a/tests/auto/other/qtokenautomaton/tokenizers/basicNamespace/basicNamespace.cpp b/tests/auto/other/qtokenautomaton/tokenizers/basicNamespace/basicNamespace.cpp
new file mode 100644
index 0000000000..3874777d74
--- /dev/null
+++ b/tests/auto/other/qtokenautomaton/tokenizers/basicNamespace/basicNamespace.cpp
@@ -0,0 +1,386 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.1, 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.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+/* NOTE: This file is AUTO GENERATED by qtokenautomaton2cpp.xsl. */
+
+#include "basicNamespace.h"
+
+QT_BEGIN_NAMESPACE
+
+using namespace BasicNamespace;
+
+Basic::Token Basic::classifier3(const QChar *data)
+
+ {
+ if (data[0] == 100)
+
+
+ {
+
+ static const unsigned short string[] =
+ {
+ 101, 102
+ };
+ if(memcmp(&data[1], &string, sizeof(QChar) * 2) == 0)
+
+
+ return _111;
+
+ }
+
+ else if (data[0] == 97)
+
+
+ {
+
+ static const unsigned short string[] =
+ {
+ 98, 99
+ };
+ if(memcmp(&data[1], &string, sizeof(QChar) * 2) == 0)
+
+
+ return _;
+
+ }
+
+ else if (data[0] == 103)
+
+
+ {
+
+ static const unsigned short string[] =
+ {
+ 104, 105
+ };
+ if(memcmp(&data[1], &string, sizeof(QChar) * 2) == 0)
+
+
+ return wobbly;
+
+ }
+
+
+
+ return NoKeyword;
+ }
+ Basic::Token Basic::classifier4(const QChar *data)
+
+ {
+ if (data[0] == 70)
+
+
+ {
+ if (data[1] == 70)
+
+
+ {
+ if (data[2] == 70)
+
+
+ {
+ if (data[3] == 70)
+
+
+ {
+
+
+ return FFFF;
+
+ }
+
+ else if (data[3] == 71)
+
+
+ {
+
+
+ return FFFG;
+
+ }
+
+
+ }
+
+ else if (data[2] == 71)
+
+
+ {
+ if (data[3] == 70)
+
+
+ {
+
+
+ return FFGF;
+
+ }
+
+ else if (data[3] == 71)
+
+
+ {
+
+
+ return FFGG;
+
+ }
+
+
+ }
+
+ else if (data[2] == 76)
+
+
+ {
+
+ if(data[3] == 77)
+
+
+ return FFLM;
+
+ }
+
+
+ }
+
+
+ }
+
+
+
+ return NoKeyword;
+ }
+ Basic::Token Basic::classifier14(const QChar *data)
+
+ {
+
+ static const unsigned short string[] =
+ {
+ 99, 111, 108, 111, 110, 58, 105, 110, 58, 110, 97, 109, 101, 58
+ };
+ if(memcmp(&data[0], &string, sizeof(QChar) * 14) == 0)
+
+
+ return ColonInName;
+
+
+ return NoKeyword;
+ }
+ Basic::Token Basic::classifier44(const QChar *data)
+
+ {
+
+ static const unsigned short string[] =
+ {
+ 97, 82, 101, 97, 108, 108, 121, 76, 111, 110, 103, 84, 111, 107, 101, 110, 73, 70, 114, 101, 97, 107, 105, 110, 77, 101, 97, 110, 73, 116, 85, 75, 110, 111, 119, 85, 75, 110, 111, 119, 75, 110, 111, 119
+ };
+ if(memcmp(&data[0], &string, sizeof(QChar) * 44) == 0)
+
+
+ return AReallyLongTokenIFreakinMeanItUKnowUKnowKnow;
+
+
+ return NoKeyword;
+ }
+ Basic::Token Basic::toToken(const QChar *data, int length)
+ {
+ switch(length)
+ {
+
+ case 3:
+ return classifier3(data);
+
+
+ case 4:
+ return classifier4(data);
+
+
+ case 14:
+ return classifier14(data);
+
+
+ case 44:
+ return classifier44(data);
+
+
+ default:
+ return NoKeyword;
+ }
+ }
+
+
+ QString Basic::toString(Token token)
+ {
+ const unsigned short *data = 0;
+ int length = 0;
+
+ switch(token)
+ {
+
+ case AReallyLongTokenIFreakinMeanItUKnowUKnowKnow:
+ {
+ static const unsigned short staticallyStoredAReallyLongTokenIFreakinMeanItUKnowUKnowKnow[] =
+ {
+ 97, 82, 101, 97, 108, 108, 121, 76, 111, 110, 103, 84, 111, 107, 101, 110, 73, 70, 114, 101, 97, 107, 105, 110, 77, 101, 97, 110, 73, 116, 85, 75, 110, 111, 119, 85, 75, 110, 111, 119, 75, 110, 111, 119, 0
+ };
+ data = staticallyStoredAReallyLongTokenIFreakinMeanItUKnowUKnowKnow;
+ length = 44;
+ break;
+ }
+
+ case ColonInName:
+ {
+ static const unsigned short staticallyStoredColonInName[] =
+ {
+ 99, 111, 108, 111, 110, 58, 105, 110, 58, 110, 97, 109, 101, 58, 0
+ };
+ data = staticallyStoredColonInName;
+ length = 14;
+ break;
+ }
+
+ case FFFF:
+ {
+ static const unsigned short staticallyStoredFFFF[] =
+ {
+ 70, 70, 70, 70, 0
+ };
+ data = staticallyStoredFFFF;
+ length = 4;
+ break;
+ }
+
+ case FFFG:
+ {
+ static const unsigned short staticallyStoredFFFG[] =
+ {
+ 70, 70, 70, 71, 0
+ };
+ data = staticallyStoredFFFG;
+ length = 4;
+ break;
+ }
+
+ case FFGF:
+ {
+ static const unsigned short staticallyStoredFFGF[] =
+ {
+ 70, 70, 71, 70, 0
+ };
+ data = staticallyStoredFFGF;
+ length = 4;
+ break;
+ }
+
+ case FFGG:
+ {
+ static const unsigned short staticallyStoredFFGG[] =
+ {
+ 70, 70, 71, 71, 0
+ };
+ data = staticallyStoredFFGG;
+ length = 4;
+ break;
+ }
+
+ case FFLM:
+ {
+ static const unsigned short staticallyStoredFFLM[] =
+ {
+ 70, 70, 76, 77, 0
+ };
+ data = staticallyStoredFFLM;
+ length = 4;
+ break;
+ }
+
+ case _:
+ {
+ static const unsigned short staticallyStored_[] =
+ {
+ 97, 98, 99, 0
+ };
+ data = staticallyStored_;
+ length = 3;
+ break;
+ }
+
+ case _111:
+ {
+ static const unsigned short staticallyStored_111[] =
+ {
+ 100, 101, 102, 0
+ };
+ data = staticallyStored_111;
+ length = 3;
+ break;
+ }
+
+ case wobbly:
+ {
+ static const unsigned short staticallyStoredwobbly[] =
+ {
+ 103, 104, 105, 0
+ };
+ data = staticallyStoredwobbly;
+ length = 3;
+ break;
+ }
+
+ default:
+ /* It's either the default token, or an undefined enum
+ * value. We silence a compiler warning, and return the
+ * empty string. */
+ ;
+ }
+
+ union
+ {
+ const unsigned short *data;
+ const QChar *asQChar;
+ } converter;
+ converter.data = data;
+
+ return QString::fromRawData(converter.asQChar, length);
+ }
+
+QT_END_NAMESPACE
+
diff --git a/tests/auto/other/qtokenautomaton/tokenizers/basicNamespace/basicNamespace.h b/tests/auto/other/qtokenautomaton/tokenizers/basicNamespace/basicNamespace.h
new file mode 100644
index 0000000000..074bb304ba
--- /dev/null
+++ b/tests/auto/other/qtokenautomaton/tokenizers/basicNamespace/basicNamespace.h
@@ -0,0 +1,99 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.1, 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.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+/* NOTE: This file is AUTO GENERATED by qtokenautomaton2cpp.xsl. */
+
+#ifndef q_BasicNamespace_h
+#define q_BasicNamespace_h
+
+#include <QtCore/QString>
+
+QT_BEGIN_NAMESPACE
+
+namespace BasicNamespace
+ {
+ class Basic
+ {
+ public:
+ enum Token
+
+ {
+ NoKeyword,
+AReallyLongTokenIFreakinMeanItUKnowUKnowKnow,
+ColonInName,
+FFFF,
+FFFG,
+FFGF,
+FFGG,
+FFLM,
+_,
+_111,
+wobbly
+ };
+
+ static inline Token toToken(const QString &value);
+static inline Token toToken(const QStringRef &value);
+static Token toToken(const QChar *data, int length);
+static QString toString(Token token);
+
+
+ private:
+ static inline Token classifier3(const QChar *data);
+static inline Token classifier4(const QChar *data);
+static inline Token classifier14(const QChar *data);
+static inline Token classifier44(const QChar *data);
+
+ };
+
+ inline Basic::Token Basic::toToken(const QString &value)
+ {
+ return toToken(value.constData(), value.length());
+ }
+
+ inline Basic::Token Basic::toToken(const QStringRef &value)
+ {
+ return toToken(value.constData(), value.length());
+ }
+
+ }
+
+QT_END_NAMESPACE
+
+#endif
diff --git a/tests/auto/other/qtokenautomaton/tokenizers/basicNamespace/basicNamespace.xml b/tests/auto/other/qtokenautomaton/tokenizers/basicNamespace/basicNamespace.xml
new file mode 100644
index 0000000000..282ffc292d
--- /dev/null
+++ b/tests/auto/other/qtokenautomaton/tokenizers/basicNamespace/basicNamespace.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<tokenAutomaton scope="public"
+ namespace="BasicNamespace"
+ className="Basic"
+ headerFile="basicNamespace.h"
+ sourceFile="basicNamespace.cpp"
+ hasToString="true"
+ tokenEnum="Token"
+ defaultToken="NoKeyword"
+ includeGuardName="q_BasicNamespace_h">
+ <tokens>
+ <token>aReallyLongTokenIFreakinMeanItUKnowUKnowKnow</token>
+ <token>FFFF</token>
+ <token>FFFG</token>
+ <token>FFGF</token>
+ <token>FFGG</token>
+ <token>FFLM</token>
+ <token name="_111">def</token>
+ <token name="_">abc</token>
+ <token name="wobbly">ghi</token>
+ <token>colon:in:name:</token>
+ </tokens>
+</tokenAutomaton>
diff --git a/tests/auto/other/qtokenautomaton/tokenizers/boilerplate/boilerplate.cpp b/tests/auto/other/qtokenautomaton/tokenizers/boilerplate/boilerplate.cpp
new file mode 100644
index 0000000000..5f374030bb
--- /dev/null
+++ b/tests/auto/other/qtokenautomaton/tokenizers/boilerplate/boilerplate.cpp
@@ -0,0 +1,386 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.1, 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.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+/* NOTE: This file is AUTO GENERATED by qtokenautomaton2cpp.xsl. */
+
+#include "boilerplate.h"
+
+QT_BEGIN_NAMESPACE
+
+Boilerplate::Token Boilerplate::classifier3(const QChar *data)
+
+ {
+ if (data[0] == 100)
+
+
+ {
+
+ static const unsigned short string[] =
+ {
+ 101, 102
+ };
+ if(memcmp(&data[1], &string, sizeof(QChar) * 2) == 0)
+
+
+ return _111;
+
+ }
+
+ else if (data[0] == 97)
+
+
+ {
+
+ static const unsigned short string[] =
+ {
+ 98, 99
+ };
+ if(memcmp(&data[1], &string, sizeof(QChar) * 2) == 0)
+
+
+ return _;
+
+ }
+
+ else if (data[0] == 103)
+
+
+ {
+
+ static const unsigned short string[] =
+ {
+ 104, 105
+ };
+ if(memcmp(&data[1], &string, sizeof(QChar) * 2) == 0)
+
+
+ return wobbly;
+
+ }
+
+
+
+ return NoKeyword;
+ }
+ Boilerplate::Token Boilerplate::classifier4(const QChar *data)
+
+ {
+ if (data[0] == 70)
+
+
+ {
+ if (data[1] == 70)
+
+
+ {
+ if (data[2] == 70)
+
+
+ {
+ if (data[3] == 70)
+
+
+ {
+
+
+ return FFFF;
+
+ }
+
+ else if (data[3] == 71)
+
+
+ {
+
+
+ return FFFG;
+
+ }
+
+
+ }
+
+ else if (data[2] == 71)
+
+
+ {
+ if (data[3] == 70)
+
+
+ {
+
+
+ return FFGF;
+
+ }
+
+ else if (data[3] == 71)
+
+
+ {
+
+
+ return FFGG;
+
+ }
+
+
+ }
+
+ else if (data[2] == 76)
+
+
+ {
+
+ if(data[3] == 77)
+
+
+ return FFLM;
+
+ }
+
+
+ }
+
+
+ }
+
+
+
+ return NoKeyword;
+ }
+ Boilerplate::Token Boilerplate::classifier14(const QChar *data)
+
+ {
+
+ static const unsigned short string[] =
+ {
+ 99, 111, 108, 111, 110, 58, 105, 110, 58, 110, 97, 109, 101, 58
+ };
+ if(memcmp(&data[0], &string, sizeof(QChar) * 14) == 0)
+
+
+ return ColonInName;
+
+
+ return NoKeyword;
+ }
+ Boilerplate::Token Boilerplate::classifier44(const QChar *data)
+
+ {
+
+ static const unsigned short string[] =
+ {
+ 97, 82, 101, 97, 108, 108, 121, 76, 111, 110, 103, 84, 111, 107, 101, 110, 73, 70, 114, 101, 97, 107, 105, 110, 77, 101, 97, 110, 73, 116, 85, 75, 110, 111, 119, 85, 75, 110, 111, 119, 75, 110, 111, 119
+ };
+ if(memcmp(&data[0], &string, sizeof(QChar) * 44) == 0)
+
+
+ return AReallyLongTokenIFreakinMeanItUKnowUKnowKnow;
+
+
+ return NoKeyword;
+ }
+ Boilerplate::Token Boilerplate::toToken(const QChar *data, int length)
+ {
+ switch(length)
+ {
+
+ case 3:
+ return classifier3(data);
+
+
+ case 4:
+ return classifier4(data);
+
+
+ case 14:
+ return classifier14(data);
+
+
+ case 44:
+ return classifier44(data);
+
+
+ default:
+ return NoKeyword;
+ }
+ }
+
+
+ QString Boilerplate::toString(Token token)
+ {
+ const unsigned short *data = 0;
+ int length = 0;
+
+ switch(token)
+ {
+
+ case AReallyLongTokenIFreakinMeanItUKnowUKnowKnow:
+ {
+ static const unsigned short staticallyStoredAReallyLongTokenIFreakinMeanItUKnowUKnowKnow[] =
+ {
+ 97, 82, 101, 97, 108, 108, 121, 76, 111, 110, 103, 84, 111, 107, 101, 110, 73, 70, 114, 101, 97, 107, 105, 110, 77, 101, 97, 110, 73, 116, 85, 75, 110, 111, 119, 85, 75, 110, 111, 119, 75, 110, 111, 119, 0
+ };
+ data = staticallyStoredAReallyLongTokenIFreakinMeanItUKnowUKnowKnow;
+ length = 44;
+ break;
+ }
+
+ case ColonInName:
+ {
+ static const unsigned short staticallyStoredColonInName[] =
+ {
+ 99, 111, 108, 111, 110, 58, 105, 110, 58, 110, 97, 109, 101, 58, 0
+ };
+ data = staticallyStoredColonInName;
+ length = 14;
+ break;
+ }
+
+ case FFFF:
+ {
+ static const unsigned short staticallyStoredFFFF[] =
+ {
+ 70, 70, 70, 70, 0
+ };
+ data = staticallyStoredFFFF;
+ length = 4;
+ break;
+ }
+
+ case FFFG:
+ {
+ static const unsigned short staticallyStoredFFFG[] =
+ {
+ 70, 70, 70, 71, 0
+ };
+ data = staticallyStoredFFFG;
+ length = 4;
+ break;
+ }
+
+ case FFGF:
+ {
+ static const unsigned short staticallyStoredFFGF[] =
+ {
+ 70, 70, 71, 70, 0
+ };
+ data = staticallyStoredFFGF;
+ length = 4;
+ break;
+ }
+
+ case FFGG:
+ {
+ static const unsigned short staticallyStoredFFGG[] =
+ {
+ 70, 70, 71, 71, 0
+ };
+ data = staticallyStoredFFGG;
+ length = 4;
+ break;
+ }
+
+ case FFLM:
+ {
+ static const unsigned short staticallyStoredFFLM[] =
+ {
+ 70, 70, 76, 77, 0
+ };
+ data = staticallyStoredFFLM;
+ length = 4;
+ break;
+ }
+
+ case _:
+ {
+ static const unsigned short staticallyStored_[] =
+ {
+ 97, 98, 99, 0
+ };
+ data = staticallyStored_;
+ length = 3;
+ break;
+ }
+
+ case _111:
+ {
+ static const unsigned short staticallyStored_111[] =
+ {
+ 100, 101, 102, 0
+ };
+ data = staticallyStored_111;
+ length = 3;
+ break;
+ }
+
+ case wobbly:
+ {
+ static const unsigned short staticallyStoredwobbly[] =
+ {
+ 103, 104, 105, 0
+ };
+ data = staticallyStoredwobbly;
+ length = 3;
+ break;
+ }
+
+ default:
+ /* It's either the default token, or an undefined enum
+ * value. We silence a compiler warning, and return the
+ * empty string. */
+ ;
+ }
+
+ union
+ {
+ const unsigned short *data;
+ const QChar *asQChar;
+ } converter;
+ converter.data = data;
+
+ return QString::fromRawData(converter.asQChar, length);
+ }
+
+QT_END_NAMESPACE
+
diff --git a/tests/auto/other/qtokenautomaton/tokenizers/boilerplate/boilerplate.h b/tests/auto/other/qtokenautomaton/tokenizers/boilerplate/boilerplate.h
new file mode 100644
index 0000000000..735ca68e18
--- /dev/null
+++ b/tests/auto/other/qtokenautomaton/tokenizers/boilerplate/boilerplate.h
@@ -0,0 +1,98 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.1, 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.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+/* NOTE: This file is AUTO GENERATED by qtokenautomaton2cpp.xsl. */
+
+#ifndef q_Basic_h
+#define q_Basic_h
+
+#include <QtCore/QString>
+
+QT_BEGIN_NAMESPACE
+
+class Boilerplate
+ {
+ public:
+ enum Token
+
+ {
+ NoKeyword,
+AReallyLongTokenIFreakinMeanItUKnowUKnowKnow,
+ColonInName,
+FFFF,
+FFFG,
+FFGF,
+FFGG,
+FFLM,
+_,
+_111,
+wobbly
+ };
+
+ static inline Token toToken(const QString &value);
+static inline Token toToken(const QStringRef &value);
+static Token toToken(const QChar *data, int length);
+static QString toString(Token token);
+
+
+ private:
+ static inline Token classifier3(const QChar *data);
+static inline Token classifier4(const QChar *data);
+static inline Token classifier14(const QChar *data);
+static inline Token classifier44(const QChar *data);
+
+ };
+
+ inline Boilerplate::Token Boilerplate::toToken(const QString &value)
+ {
+ return toToken(value.constData(), value.length());
+ }
+
+ inline Boilerplate::Token Boilerplate::toToken(const QStringRef &value)
+ {
+ return toToken(value.constData(), value.length());
+ }
+
+
+QT_END_NAMESPACE
+
+#endif
diff --git a/tests/auto/other/qtokenautomaton/tokenizers/boilerplate/boilerplate.xml b/tests/auto/other/qtokenautomaton/tokenizers/boilerplate/boilerplate.xml
new file mode 100644
index 0000000000..604c147c43
--- /dev/null
+++ b/tests/auto/other/qtokenautomaton/tokenizers/boilerplate/boilerplate.xml
@@ -0,0 +1,67 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<tokenAutomaton scope="public"
+ className="Boilerplate"
+ headerFile="boilerplate.h"
+ sourceFile="boilerplate.cpp"
+ defaultToken="NoKeyword"
+ tokenEnum="Token"
+ hasToString="true"
+ includeGuardName="q_Basic_h">
+ <tokens>
+ <token>aReallyLongTokenIFreakinMeanItUKnowUKnowKnow</token>
+ <token>FFFF</token>
+ <token>FFFG</token>
+ <token>FFGF</token>
+ <token>FFGG</token>
+ <token>FFLM</token>
+ <token name="_111">def</token>
+ <token name="_">abc</token>
+ <token name="wobbly">ghi</token>
+ <token>colon:in:name:</token>
+ </tokens>
+
+ <boilerplate>
+ <prolog>/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.1, 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.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+</prolog>
+ </boilerplate>
+</tokenAutomaton>
diff --git a/tests/auto/other/qtokenautomaton/tokenizers/noNamespace/noNamespace.cpp b/tests/auto/other/qtokenautomaton/tokenizers/noNamespace/noNamespace.cpp
new file mode 100644
index 0000000000..2d349ad637
--- /dev/null
+++ b/tests/auto/other/qtokenautomaton/tokenizers/noNamespace/noNamespace.cpp
@@ -0,0 +1,449 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.1, 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.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+/* NOTE: This file is AUTO GENERATED by qtokenautomaton2cpp.xsl. */
+
+#include "noNamespace.h"
+
+QT_BEGIN_NAMESPACE
+
+NoNamespace::Token NoNamespace::classifier3(const QChar *data)
+
+ {
+ if (data[0] == 100)
+
+
+ {
+
+ static const unsigned short string[] =
+ {
+ 101, 102
+ };
+ if(memcmp(&data[1], &string, sizeof(QChar) * 2) == 0)
+
+
+ return _111;
+
+ }
+
+ else if (data[0] == 97)
+
+
+ {
+
+ static const unsigned short string[] =
+ {
+ 98, 99
+ };
+ if(memcmp(&data[1], &string, sizeof(QChar) * 2) == 0)
+
+
+ return _;
+
+ }
+
+ else if (data[0] == 103)
+
+
+ {
+
+ static const unsigned short string[] =
+ {
+ 104, 105
+ };
+ if(memcmp(&data[1], &string, sizeof(QChar) * 2) == 0)
+
+
+ return wobbly;
+
+ }
+
+
+
+ return NoKeyword;
+ }
+ NoNamespace::Token NoNamespace::classifier4(const QChar *data)
+
+ {
+ if (data[0] == 70)
+
+
+ {
+ if (data[1] == 70)
+
+
+ {
+ if (data[2] == 70)
+
+
+ {
+ if (data[3] == 70)
+
+
+ {
+
+
+ return FFFF;
+
+ }
+
+ else if (data[3] == 71)
+
+
+ {
+
+
+ return FFFG;
+
+ }
+
+
+ }
+
+ else if (data[2] == 71)
+
+
+ {
+ if (data[3] == 70)
+
+
+ {
+
+
+ return FFGF;
+
+ }
+
+ else if (data[3] == 71)
+
+
+ {
+
+
+ return FFGG;
+
+ }
+
+
+ }
+
+ else if (data[2] == 76)
+
+
+ {
+
+ if(data[3] == 77)
+
+
+ return FFLM;
+
+ }
+
+
+ }
+
+
+ }
+
+
+
+ return NoKeyword;
+ }
+ NoNamespace::Token NoNamespace::classifier14(const QChar *data)
+
+ {
+ if (data[0] == 119)
+
+
+ {
+
+ static const unsigned short string[] =
+ {
+ 101, 45, 104, 97, 118, 101, 45, 100, 97, 115, 104, 101, 115
+ };
+ if(memcmp(&data[1], &string, sizeof(QChar) * 13) == 0)
+
+
+ return WeHaveDashes;
+
+ }
+
+ else if (data[0] == 99)
+
+
+ {
+
+ static const unsigned short string[] =
+ {
+ 111, 108, 111, 110, 58, 105, 110, 58, 110, 97, 109, 101, 58
+ };
+ if(memcmp(&data[1], &string, sizeof(QChar) * 13) == 0)
+
+
+ return ColonInName;
+
+ }
+
+
+
+ return NoKeyword;
+ }
+ NoNamespace::Token NoNamespace::classifier15(const QChar *data)
+
+ {
+
+ static const unsigned short string[] =
+ {
+ 119, 101, 45, 104, 97, 118, 101, 45, 100, 97, 115, 104, 101, 115, 45
+ };
+ if(memcmp(&data[0], &string, sizeof(QChar) * 15) == 0)
+
+
+ return WeHaveDashes2;
+
+
+ return NoKeyword;
+ }
+ NoNamespace::Token NoNamespace::classifier44(const QChar *data)
+
+ {
+
+ static const unsigned short string[] =
+ {
+ 97, 82, 101, 97, 108, 108, 121, 76, 111, 110, 103, 84, 111, 107, 101, 110, 73, 70, 114, 101, 97, 107, 105, 110, 77, 101, 97, 110, 73, 116, 85, 75, 110, 111, 119, 85, 75, 110, 111, 119, 75, 110, 111, 119
+ };
+ if(memcmp(&data[0], &string, sizeof(QChar) * 44) == 0)
+
+
+ return AReallyLongTokenIFreakinMeanItUKnowUKnowKnow;
+
+
+ return NoKeyword;
+ }
+ NoNamespace::Token NoNamespace::toToken(const QChar *data, int length)
+ {
+ switch(length)
+ {
+
+ case 3:
+ return classifier3(data);
+
+
+ case 4:
+ return classifier4(data);
+
+
+ case 14:
+ return classifier14(data);
+
+
+ case 15:
+ return classifier15(data);
+
+
+ case 44:
+ return classifier44(data);
+
+
+ default:
+ return NoKeyword;
+ }
+ }
+
+
+ QString NoNamespace::toString(Token token)
+ {
+ const unsigned short *data = 0;
+ int length = 0;
+
+ switch(token)
+ {
+
+ case AReallyLongTokenIFreakinMeanItUKnowUKnowKnow:
+ {
+ static const unsigned short staticallyStoredAReallyLongTokenIFreakinMeanItUKnowUKnowKnow[] =
+ {
+ 97, 82, 101, 97, 108, 108, 121, 76, 111, 110, 103, 84, 111, 107, 101, 110, 73, 70, 114, 101, 97, 107, 105, 110, 77, 101, 97, 110, 73, 116, 85, 75, 110, 111, 119, 85, 75, 110, 111, 119, 75, 110, 111, 119, 0
+ };
+ data = staticallyStoredAReallyLongTokenIFreakinMeanItUKnowUKnowKnow;
+ length = 44;
+ break;
+ }
+
+ case ColonInName:
+ {
+ static const unsigned short staticallyStoredColonInName[] =
+ {
+ 99, 111, 108, 111, 110, 58, 105, 110, 58, 110, 97, 109, 101, 58, 0
+ };
+ data = staticallyStoredColonInName;
+ length = 14;
+ break;
+ }
+
+ case FFFF:
+ {
+ static const unsigned short staticallyStoredFFFF[] =
+ {
+ 70, 70, 70, 70, 0
+ };
+ data = staticallyStoredFFFF;
+ length = 4;
+ break;
+ }
+
+ case FFFG:
+ {
+ static const unsigned short staticallyStoredFFFG[] =
+ {
+ 70, 70, 70, 71, 0
+ };
+ data = staticallyStoredFFFG;
+ length = 4;
+ break;
+ }
+
+ case FFGF:
+ {
+ static const unsigned short staticallyStoredFFGF[] =
+ {
+ 70, 70, 71, 70, 0
+ };
+ data = staticallyStoredFFGF;
+ length = 4;
+ break;
+ }
+
+ case FFGG:
+ {
+ static const unsigned short staticallyStoredFFGG[] =
+ {
+ 70, 70, 71, 71, 0
+ };
+ data = staticallyStoredFFGG;
+ length = 4;
+ break;
+ }
+
+ case FFLM:
+ {
+ static const unsigned short staticallyStoredFFLM[] =
+ {
+ 70, 70, 76, 77, 0
+ };
+ data = staticallyStoredFFLM;
+ length = 4;
+ break;
+ }
+
+ case WeHaveDashes:
+ {
+ static const unsigned short staticallyStoredWeHaveDashes[] =
+ {
+ 119, 101, 45, 104, 97, 118, 101, 45, 100, 97, 115, 104, 101, 115, 0
+ };
+ data = staticallyStoredWeHaveDashes;
+ length = 14;
+ break;
+ }
+
+ case WeHaveDashes2:
+ {
+ static const unsigned short staticallyStoredWeHaveDashes2[] =
+ {
+ 119, 101, 45, 104, 97, 118, 101, 45, 100, 97, 115, 104, 101, 115, 45, 0
+ };
+ data = staticallyStoredWeHaveDashes2;
+ length = 15;
+ break;
+ }
+
+ case _:
+ {
+ static const unsigned short staticallyStored_[] =
+ {
+ 97, 98, 99, 0
+ };
+ data = staticallyStored_;
+ length = 3;
+ break;
+ }
+
+ case _111:
+ {
+ static const unsigned short staticallyStored_111[] =
+ {
+ 100, 101, 102, 0
+ };
+ data = staticallyStored_111;
+ length = 3;
+ break;
+ }
+
+ case wobbly:
+ {
+ static const unsigned short staticallyStoredwobbly[] =
+ {
+ 103, 104, 105, 0
+ };
+ data = staticallyStoredwobbly;
+ length = 3;
+ break;
+ }
+
+ default:
+ /* It's either the default token, or an undefined enum
+ * value. We silence a compiler warning, and return the
+ * empty string. */
+ ;
+ }
+
+ union
+ {
+ const unsigned short *data;
+ const QChar *asQChar;
+ } converter;
+ converter.data = data;
+
+ return QString::fromRawData(converter.asQChar, length);
+ }
+
+QT_END_NAMESPACE
+
diff --git a/tests/auto/other/qtokenautomaton/tokenizers/noNamespace/noNamespace.h b/tests/auto/other/qtokenautomaton/tokenizers/noNamespace/noNamespace.h
new file mode 100644
index 0000000000..f922dfcb50
--- /dev/null
+++ b/tests/auto/other/qtokenautomaton/tokenizers/noNamespace/noNamespace.h
@@ -0,0 +1,99 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.1, 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.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+/* NOTE: This file is AUTO GENERATED by qtokenautomaton2cpp.xsl. */
+
+#ifndef q_noNamespace_h
+#define q_noNamespace_h
+
+#include <QtCore/QString>
+
+QT_BEGIN_NAMESPACE
+
+class NoNamespace
+ {
+ public:
+ enum Token
+
+ {
+ NoKeyword,
+AReallyLongTokenIFreakinMeanItUKnowUKnowKnow,
+ColonInName,
+FFFF,
+FFFG,
+FFGF,
+FFGG,
+FFLM,
+WeHaveDashes,
+WeHaveDashes2,
+_,
+_111,
+wobbly
+ };
+
+ static inline Token toToken(const QString &value);
+static inline Token toToken(const QStringRef &value);
+static Token toToken(const QChar *data, int length);
+static QString toString(Token token);
+
+
+ private:
+ static inline Token classifier3(const QChar *data);
+static inline Token classifier4(const QChar *data);
+static inline Token classifier14(const QChar *data);
+static inline Token classifier15(const QChar *data);
+static inline Token classifier44(const QChar *data);
+
+ };
+
+ inline NoNamespace::Token NoNamespace::toToken(const QString &value)
+ {
+ return toToken(value.constData(), value.length());
+ }
+
+ inline NoNamespace::Token NoNamespace::toToken(const QStringRef &value)
+ {
+ return toToken(value.constData(), value.length());
+ }
+
+
+QT_END_NAMESPACE
+
+#endif
diff --git a/tests/auto/other/qtokenautomaton/tokenizers/noNamespace/noNamespace.xml b/tests/auto/other/qtokenautomaton/tokenizers/noNamespace/noNamespace.xml
new file mode 100644
index 0000000000..67738cd3bd
--- /dev/null
+++ b/tests/auto/other/qtokenautomaton/tokenizers/noNamespace/noNamespace.xml
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<tokenAutomaton scope="public"
+ className="NoNamespace"
+ headerFile="noNamespace.h"
+ sourceFile="noNamespace.cpp"
+ defaultToken="NoKeyword"
+ tokenEnum="Token"
+ hasToString="true"
+ includeGuardName="q_noNamespace_h">
+ <tokens>
+ <token>aReallyLongTokenIFreakinMeanItUKnowUKnowKnow</token>
+ <token>FFFF</token>
+ <token>FFFG</token>
+ <token>FFGF</token>
+ <token>FFGG</token>
+ <token>FFLM</token>
+ <token name="_111">def</token>
+ <token name="_">abc</token>
+ <token name="wobbly">ghi</token>
+ <token>we-have-dashes</token>
+ <token name="WeHaveDashes2">we-have-dashes-</token>
+ <token>colon:in:name:</token>
+ </tokens>
+</tokenAutomaton>
diff --git a/tests/auto/other/qtokenautomaton/tokenizers/noToString/noToString.cpp b/tests/auto/other/qtokenautomaton/tokenizers/noToString/noToString.cpp
new file mode 100644
index 0000000000..d45c7302cd
--- /dev/null
+++ b/tests/auto/other/qtokenautomaton/tokenizers/noToString/noToString.cpp
@@ -0,0 +1,251 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.1, 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.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+/* NOTE: This file is AUTO GENERATED by qtokenautomaton2cpp.xsl. */
+
+#include "noToString.h"
+
+QT_BEGIN_NAMESPACE
+
+using namespace NoToStringNS;
+
+NoToString::Token NoToString::classifier3(const QChar *data)
+
+ {
+ if (data[0] == 100)
+
+
+ {
+
+ static const unsigned short string[] =
+ {
+ 101, 102
+ };
+ if(memcmp(&data[1], &string, sizeof(QChar) * 2) == 0)
+
+
+ return _111;
+
+ }
+
+ else if (data[0] == 97)
+
+
+ {
+
+ static const unsigned short string[] =
+ {
+ 98, 99
+ };
+ if(memcmp(&data[1], &string, sizeof(QChar) * 2) == 0)
+
+
+ return _;
+
+ }
+
+ else if (data[0] == 103)
+
+
+ {
+
+ static const unsigned short string[] =
+ {
+ 104, 105
+ };
+ if(memcmp(&data[1], &string, sizeof(QChar) * 2) == 0)
+
+
+ return wobbly;
+
+ }
+
+
+
+ return NoKeyword;
+ }
+ NoToString::Token NoToString::classifier4(const QChar *data)
+
+ {
+ if (data[0] == 70)
+
+
+ {
+ if (data[1] == 70)
+
+
+ {
+ if (data[2] == 70)
+
+
+ {
+ if (data[3] == 70)
+
+
+ {
+
+
+ return FFFF;
+
+ }
+
+ else if (data[3] == 71)
+
+
+ {
+
+
+ return FFFG;
+
+ }
+
+
+ }
+
+ else if (data[2] == 71)
+
+
+ {
+ if (data[3] == 70)
+
+
+ {
+
+
+ return FFGF;
+
+ }
+
+ else if (data[3] == 71)
+
+
+ {
+
+
+ return FFGG;
+
+ }
+
+
+ }
+
+ else if (data[2] == 76)
+
+
+ {
+
+ if(data[3] == 77)
+
+
+ return FFLM;
+
+ }
+
+
+ }
+
+
+ }
+
+
+
+ return NoKeyword;
+ }
+ NoToString::Token NoToString::classifier14(const QChar *data)
+
+ {
+
+ static const unsigned short string[] =
+ {
+ 99, 111, 108, 111, 110, 58, 105, 110, 58, 110, 97, 109, 101, 58
+ };
+ if(memcmp(&data[0], &string, sizeof(QChar) * 14) == 0)
+
+
+ return ColonInName;
+
+
+ return NoKeyword;
+ }
+ NoToString::Token NoToString::classifier44(const QChar *data)
+
+ {
+
+ static const unsigned short string[] =
+ {
+ 97, 82, 101, 97, 108, 108, 121, 76, 111, 110, 103, 84, 111, 107, 101, 110, 73, 70, 114, 101, 97, 107, 105, 110, 77, 101, 97, 110, 73, 116, 85, 75, 110, 111, 119, 85, 75, 110, 111, 119, 75, 110, 111, 119
+ };
+ if(memcmp(&data[0], &string, sizeof(QChar) * 44) == 0)
+
+
+ return AReallyLongTokenIFreakinMeanItUKnowUKnowKnow;
+
+
+ return NoKeyword;
+ }
+ NoToString::Token NoToString::toToken(const QChar *data, int length)
+ {
+ switch(length)
+ {
+
+ case 3:
+ return classifier3(data);
+
+
+ case 4:
+ return classifier4(data);
+
+
+ case 14:
+ return classifier14(data);
+
+
+ case 44:
+ return classifier44(data);
+
+
+ default:
+ return NoKeyword;
+ }
+ }
+
+
+QT_END_NAMESPACE
+
diff --git a/tests/auto/other/qtokenautomaton/tokenizers/noToString/noToString.h b/tests/auto/other/qtokenautomaton/tokenizers/noToString/noToString.h
new file mode 100644
index 0000000000..12142bc4f0
--- /dev/null
+++ b/tests/auto/other/qtokenautomaton/tokenizers/noToString/noToString.h
@@ -0,0 +1,98 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.1, 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.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+/* NOTE: This file is AUTO GENERATED by qtokenautomaton2cpp.xsl. */
+
+#ifndef q_NoToStringNS_h
+#define q_NoToStringNS_h
+
+#include <QtCore/QString>
+
+QT_BEGIN_NAMESPACE
+
+namespace NoToStringNS
+ {
+ class NoToString
+ {
+ public:
+ enum Token
+
+ {
+ NoKeyword,
+AReallyLongTokenIFreakinMeanItUKnowUKnowKnow,
+ColonInName,
+FFFF,
+FFFG,
+FFGF,
+FFGG,
+FFLM,
+_,
+_111,
+wobbly
+ };
+
+ static inline Token toToken(const QString &value);
+static inline Token toToken(const QStringRef &value);
+static Token toToken(const QChar *data, int length);
+
+
+ private:
+ static inline Token classifier3(const QChar *data);
+static inline Token classifier4(const QChar *data);
+static inline Token classifier14(const QChar *data);
+static inline Token classifier44(const QChar *data);
+
+ };
+
+ inline NoToString::Token NoToString::toToken(const QString &value)
+ {
+ return toToken(value.constData(), value.length());
+ }
+
+ inline NoToString::Token NoToString::toToken(const QStringRef &value)
+ {
+ return toToken(value.constData(), value.length());
+ }
+
+ }
+
+QT_END_NAMESPACE
+
+#endif
diff --git a/tests/auto/other/qtokenautomaton/tokenizers/noToString/noToString.xml b/tests/auto/other/qtokenautomaton/tokenizers/noToString/noToString.xml
new file mode 100644
index 0000000000..99e1644d87
--- /dev/null
+++ b/tests/auto/other/qtokenautomaton/tokenizers/noToString/noToString.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<tokenAutomaton scope="public"
+ namespace="NoToStringNS"
+ className="NoToString"
+ headerFile="noToString.h"
+ sourceFile="noToString.cpp"
+ hasToString="false"
+ tokenEnum="Token"
+ defaultToken="NoKeyword"
+ includeGuardName="q_NoToStringNS_h">
+ <tokens>
+ <token>aReallyLongTokenIFreakinMeanItUKnowUKnowKnow</token>
+ <token>FFFF</token>
+ <token>FFFG</token>
+ <token>FFGF</token>
+ <token>FFGG</token>
+ <token>FFLM</token>
+ <token name="_111">def</token>
+ <token name="_">abc</token>
+ <token name="wobbly">ghi</token>
+ <token>colon:in:name:</token>
+ </tokens>
+</tokenAutomaton>
diff --git a/tests/auto/other/qtokenautomaton/tokenizers/withNamespace/withNamespace.cpp b/tests/auto/other/qtokenautomaton/tokenizers/withNamespace/withNamespace.cpp
new file mode 100644
index 0000000000..235bd60501
--- /dev/null
+++ b/tests/auto/other/qtokenautomaton/tokenizers/withNamespace/withNamespace.cpp
@@ -0,0 +1,451 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.1, 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.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+/* NOTE: This file is AUTO GENERATED by qtokenautomaton2cpp.xsl. */
+
+#include "withNamespace.h"
+
+QT_BEGIN_NAMESPACE
+
+using namespace TheNamespace;
+
+WithNamespace::Token WithNamespace::classifier3(const QChar *data)
+
+ {
+ if (data[0] == 100)
+
+
+ {
+
+ static const unsigned short string[] =
+ {
+ 101, 102
+ };
+ if(memcmp(&data[1], &string, sizeof(QChar) * 2) == 0)
+
+
+ return _111;
+
+ }
+
+ else if (data[0] == 97)
+
+
+ {
+
+ static const unsigned short string[] =
+ {
+ 98, 99
+ };
+ if(memcmp(&data[1], &string, sizeof(QChar) * 2) == 0)
+
+
+ return _;
+
+ }
+
+ else if (data[0] == 103)
+
+
+ {
+
+ static const unsigned short string[] =
+ {
+ 104, 105
+ };
+ if(memcmp(&data[1], &string, sizeof(QChar) * 2) == 0)
+
+
+ return wobbly;
+
+ }
+
+
+
+ return NoKeyword;
+ }
+ WithNamespace::Token WithNamespace::classifier4(const QChar *data)
+
+ {
+ if (data[0] == 70)
+
+
+ {
+ if (data[1] == 70)
+
+
+ {
+ if (data[2] == 70)
+
+
+ {
+ if (data[3] == 70)
+
+
+ {
+
+
+ return FFFF;
+
+ }
+
+ else if (data[3] == 71)
+
+
+ {
+
+
+ return FFFG;
+
+ }
+
+
+ }
+
+ else if (data[2] == 71)
+
+
+ {
+ if (data[3] == 70)
+
+
+ {
+
+
+ return FFGF;
+
+ }
+
+ else if (data[3] == 71)
+
+
+ {
+
+
+ return FFGG;
+
+ }
+
+
+ }
+
+ else if (data[2] == 76)
+
+
+ {
+
+ if(data[3] == 77)
+
+
+ return FFLM;
+
+ }
+
+
+ }
+
+
+ }
+
+
+
+ return NoKeyword;
+ }
+ WithNamespace::Token WithNamespace::classifier14(const QChar *data)
+
+ {
+ if (data[0] == 119)
+
+
+ {
+
+ static const unsigned short string[] =
+ {
+ 101, 45, 104, 97, 118, 101, 45, 100, 97, 115, 104, 101, 115
+ };
+ if(memcmp(&data[1], &string, sizeof(QChar) * 13) == 0)
+
+
+ return WeHaveDashes;
+
+ }
+
+ else if (data[0] == 99)
+
+
+ {
+
+ static const unsigned short string[] =
+ {
+ 111, 108, 111, 110, 58, 105, 110, 58, 110, 97, 109, 101, 58
+ };
+ if(memcmp(&data[1], &string, sizeof(QChar) * 13) == 0)
+
+
+ return ColonInName;
+
+ }
+
+
+
+ return NoKeyword;
+ }
+ WithNamespace::Token WithNamespace::classifier15(const QChar *data)
+
+ {
+
+ static const unsigned short string[] =
+ {
+ 119, 101, 45, 104, 97, 118, 101, 45, 100, 97, 115, 104, 101, 115, 45
+ };
+ if(memcmp(&data[0], &string, sizeof(QChar) * 15) == 0)
+
+
+ return WeHaveDashes2;
+
+
+ return NoKeyword;
+ }
+ WithNamespace::Token WithNamespace::classifier44(const QChar *data)
+
+ {
+
+ static const unsigned short string[] =
+ {
+ 97, 82, 101, 97, 108, 108, 121, 76, 111, 110, 103, 84, 111, 107, 101, 110, 73, 70, 114, 101, 97, 107, 105, 110, 77, 101, 97, 110, 73, 116, 85, 75, 110, 111, 119, 85, 75, 110, 111, 119, 75, 110, 111, 119
+ };
+ if(memcmp(&data[0], &string, sizeof(QChar) * 44) == 0)
+
+
+ return AReallyLongTokenIFreakinMeanItUKnowUKnowKnow;
+
+
+ return NoKeyword;
+ }
+ WithNamespace::Token WithNamespace::toToken(const QChar *data, int length)
+ {
+ switch(length)
+ {
+
+ case 3:
+ return classifier3(data);
+
+
+ case 4:
+ return classifier4(data);
+
+
+ case 14:
+ return classifier14(data);
+
+
+ case 15:
+ return classifier15(data);
+
+
+ case 44:
+ return classifier44(data);
+
+
+ default:
+ return NoKeyword;
+ }
+ }
+
+
+ QString WithNamespace::toString(Token token)
+ {
+ const unsigned short *data = 0;
+ int length = 0;
+
+ switch(token)
+ {
+
+ case AReallyLongTokenIFreakinMeanItUKnowUKnowKnow:
+ {
+ static const unsigned short staticallyStoredAReallyLongTokenIFreakinMeanItUKnowUKnowKnow[] =
+ {
+ 97, 82, 101, 97, 108, 108, 121, 76, 111, 110, 103, 84, 111, 107, 101, 110, 73, 70, 114, 101, 97, 107, 105, 110, 77, 101, 97, 110, 73, 116, 85, 75, 110, 111, 119, 85, 75, 110, 111, 119, 75, 110, 111, 119, 0
+ };
+ data = staticallyStoredAReallyLongTokenIFreakinMeanItUKnowUKnowKnow;
+ length = 44;
+ break;
+ }
+
+ case ColonInName:
+ {
+ static const unsigned short staticallyStoredColonInName[] =
+ {
+ 99, 111, 108, 111, 110, 58, 105, 110, 58, 110, 97, 109, 101, 58, 0
+ };
+ data = staticallyStoredColonInName;
+ length = 14;
+ break;
+ }
+
+ case FFFF:
+ {
+ static const unsigned short staticallyStoredFFFF[] =
+ {
+ 70, 70, 70, 70, 0
+ };
+ data = staticallyStoredFFFF;
+ length = 4;
+ break;
+ }
+
+ case FFFG:
+ {
+ static const unsigned short staticallyStoredFFFG[] =
+ {
+ 70, 70, 70, 71, 0
+ };
+ data = staticallyStoredFFFG;
+ length = 4;
+ break;
+ }
+
+ case FFGF:
+ {
+ static const unsigned short staticallyStoredFFGF[] =
+ {
+ 70, 70, 71, 70, 0
+ };
+ data = staticallyStoredFFGF;
+ length = 4;
+ break;
+ }
+
+ case FFGG:
+ {
+ static const unsigned short staticallyStoredFFGG[] =
+ {
+ 70, 70, 71, 71, 0
+ };
+ data = staticallyStoredFFGG;
+ length = 4;
+ break;
+ }
+
+ case FFLM:
+ {
+ static const unsigned short staticallyStoredFFLM[] =
+ {
+ 70, 70, 76, 77, 0
+ };
+ data = staticallyStoredFFLM;
+ length = 4;
+ break;
+ }
+
+ case WeHaveDashes:
+ {
+ static const unsigned short staticallyStoredWeHaveDashes[] =
+ {
+ 119, 101, 45, 104, 97, 118, 101, 45, 100, 97, 115, 104, 101, 115, 0
+ };
+ data = staticallyStoredWeHaveDashes;
+ length = 14;
+ break;
+ }
+
+ case WeHaveDashes2:
+ {
+ static const unsigned short staticallyStoredWeHaveDashes2[] =
+ {
+ 119, 101, 45, 104, 97, 118, 101, 45, 100, 97, 115, 104, 101, 115, 45, 0
+ };
+ data = staticallyStoredWeHaveDashes2;
+ length = 15;
+ break;
+ }
+
+ case _:
+ {
+ static const unsigned short staticallyStored_[] =
+ {
+ 97, 98, 99, 0
+ };
+ data = staticallyStored_;
+ length = 3;
+ break;
+ }
+
+ case _111:
+ {
+ static const unsigned short staticallyStored_111[] =
+ {
+ 100, 101, 102, 0
+ };
+ data = staticallyStored_111;
+ length = 3;
+ break;
+ }
+
+ case wobbly:
+ {
+ static const unsigned short staticallyStoredwobbly[] =
+ {
+ 103, 104, 105, 0
+ };
+ data = staticallyStoredwobbly;
+ length = 3;
+ break;
+ }
+
+ default:
+ /* It's either the default token, or an undefined enum
+ * value. We silence a compiler warning, and return the
+ * empty string. */
+ ;
+ }
+
+ union
+ {
+ const unsigned short *data;
+ const QChar *asQChar;
+ } converter;
+ converter.data = data;
+
+ return QString::fromRawData(converter.asQChar, length);
+ }
+
+QT_END_NAMESPACE
+
diff --git a/tests/auto/other/qtokenautomaton/tokenizers/withNamespace/withNamespace.h b/tests/auto/other/qtokenautomaton/tokenizers/withNamespace/withNamespace.h
new file mode 100644
index 0000000000..678b3a7903
--- /dev/null
+++ b/tests/auto/other/qtokenautomaton/tokenizers/withNamespace/withNamespace.h
@@ -0,0 +1,102 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.1, 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.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+/* NOTE: This file is AUTO GENERATED by qtokenautomaton2cpp.xsl. */
+
+#ifndef q_withNamespace_h
+#define q_withNamespace_h
+
+#include <QtCore/QString>
+
+QT_BEGIN_NAMESPACE
+
+namespace TheNamespace
+ {
+ class WithNamespace
+ {
+ public:
+ enum Token
+
+ {
+ NoKeyword,
+AReallyLongTokenIFreakinMeanItUKnowUKnowKnow,
+ColonInName,
+FFFF,
+FFFG,
+FFGF,
+FFGG,
+FFLM,
+WeHaveDashes,
+WeHaveDashes2,
+_,
+_111,
+wobbly
+ };
+
+ static inline Token toToken(const QString &value);
+static inline Token toToken(const QStringRef &value);
+static Token toToken(const QChar *data, int length);
+static QString toString(Token token);
+
+
+ private:
+ static inline Token classifier3(const QChar *data);
+static inline Token classifier4(const QChar *data);
+static inline Token classifier14(const QChar *data);
+static inline Token classifier15(const QChar *data);
+static inline Token classifier44(const QChar *data);
+
+ };
+
+ inline WithNamespace::Token WithNamespace::toToken(const QString &value)
+ {
+ return toToken(value.constData(), value.length());
+ }
+
+ inline WithNamespace::Token WithNamespace::toToken(const QStringRef &value)
+ {
+ return toToken(value.constData(), value.length());
+ }
+
+ }
+
+QT_END_NAMESPACE
+
+#endif
diff --git a/tests/auto/other/qtokenautomaton/tokenizers/withNamespace/withNamespace.xml b/tests/auto/other/qtokenautomaton/tokenizers/withNamespace/withNamespace.xml
new file mode 100644
index 0000000000..533eed85b7
--- /dev/null
+++ b/tests/auto/other/qtokenautomaton/tokenizers/withNamespace/withNamespace.xml
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<tokenAutomaton scope="public"
+ className="WithNamespace"
+ headerFile="withNamespace.h"
+ sourceFile="withNamespace.cpp"
+ defaultToken="NoKeyword"
+ tokenEnum="Token"
+ hasToString="true"
+ namespace="TheNamespace"
+ includeGuardName="q_withNamespace_h">
+ <tokens>
+ <token>aReallyLongTokenIFreakinMeanItUKnowUKnowKnow</token>
+ <token>FFFF</token>
+ <token>FFFG</token>
+ <token>FFGF</token>
+ <token>FFGG</token>
+ <token>FFLM</token>
+ <token name="_111">def</token>
+ <token name="_">abc</token>
+ <token name="wobbly">ghi</token>
+ <token>we-have-dashes</token>
+ <token name="WeHaveDashes2">we-have-dashes-</token>
+ <token>colon:in:name:</token>
+ </tokens>
+</tokenAutomaton>
diff --git a/tests/auto/other/qtokenautomaton/tst_qtokenautomaton.cpp b/tests/auto/other/qtokenautomaton/tst_qtokenautomaton.cpp
new file mode 100644
index 0000000000..cbbf5a2a0d
--- /dev/null
+++ b/tests/auto/other/qtokenautomaton/tst_qtokenautomaton.cpp
@@ -0,0 +1,134 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.1, 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.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#include <QtTest/QtTest>
+
+#include "tokenizers/basic/basic.h"
+#include "tokenizers/basicNamespace/basicNamespace.h"
+#include "tokenizers/boilerplate/boilerplate.h"
+#include "tokenizers/noToString/noToString.h"
+
+/*!
+ \class tst_QTokenAutomaton
+ \internal
+ \brief Tests the QTokenAutomaton generator.
+
+TODO:
+ - Verify high Unicode codepoints
+ - Verify that signatures are static.
+ */
+class tst_QTokenAutomaton : public QObject
+{
+ Q_OBJECT
+
+private Q_SLOTS:
+ void tokenizerBasic() const;
+};
+
+void tst_QTokenAutomaton::tokenizerBasic() const
+{
+ typedef QPair<Basic::Token, QString> TokenPair;
+ typedef QList<TokenPair> TokenPairList;
+
+ /* Tokenizer basic. */
+ {
+ /* All the tokens matching tokens. */
+ {
+ TokenPairList tokens;
+ tokens.append(qMakePair(Basic::_, QString::fromLatin1("abc")));
+ tokens.append(qMakePair(Basic::_111, QString::fromLatin1("def")));
+ tokens.append(qMakePair(Basic::wobbly, QString::fromLatin1("ghi")));
+ tokens.append(qMakePair(Basic::FFFF, QString::fromLatin1("FFFF")));
+ tokens.append(qMakePair(Basic::FFFG, QString::fromLatin1("FFFG")));
+ tokens.append(qMakePair(Basic::FFGG, QString::fromLatin1("FFGG")));
+ tokens.append(qMakePair(Basic::FFGF, QString::fromLatin1("FFGF")));
+ tokens.append(qMakePair(Basic::FFLM, QString::fromLatin1("FFLM")));
+ tokens.append(qMakePair(Basic::AReallyLongTokenIFreakinMeanItUKnowUKnowKnow, QString::fromLatin1("aReallyLongTokenIFreakinMeanItUKnowUKnowKnow")));
+ tokens.append(qMakePair(Basic::WeHaveDashes, QString::fromLatin1("we-have-dashes")));
+ tokens.append(qMakePair(Basic::WeHaveDashes2, QString::fromLatin1("we-have-dashes-")));
+
+ /* toToken(). */
+ for(int i = 0; i < tokens.count(); ++i)
+ {
+ const TokenPair &at = tokens.at(i);
+ /* QString. */
+ QCOMPARE(Basic::toToken(at.second), at.first);
+
+ /* const QChar *, int. */
+ QCOMPARE(Basic::toToken(at.second.constData(), at.second.length()), at.first);
+
+ /* QStringRef. */
+ const QStringRef ref(&at.second);
+ QCOMPARE(Basic::toToken(ref), at.first);
+ }
+
+ /* toString(). */
+ for(int i = 0; i < tokens.count(); ++i)
+ {
+ const TokenPair &at = tokens.at(i);
+ QCOMPARE(Basic::toString(at.first), at.second);
+ }
+ }
+
+ /* Tokens that we don't recognize. */
+ {
+ QStringList tokens;
+ tokens.append(QLatin1String("NO-MATCH"));
+ tokens.append(QLatin1String("NoKeyword"));
+ tokens.append(QString());
+
+ for(int i = 0; i < tokens.count(); ++i)
+ QCOMPARE(Basic::toToken(tokens.at(i)), Basic::NoKeyword);
+ }
+
+ /* Weird values for toToken(). */
+ {
+ QCOMPARE(Basic::toString(Basic::Token(5000)), QString());
+ QCOMPARE(Basic::toString(Basic::NoKeyword), QString());
+ }
+
+ }
+}
+
+QTEST_MAIN(tst_QTokenAutomaton)
+
+#include "tst_qtokenautomaton.moc"