tests/arthur/common/xmldata.h
changeset 0 1918ee327afb
child 4 3b1da2848fc7
equal deleted inserted replaced
-1:000000000000 0:1918ee327afb
       
     1 /****************************************************************************
       
     2 **
       
     3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     4 ** All rights reserved.
       
     5 ** Contact: Nokia Corporation (qt-info@nokia.com)
       
     6 **
       
     7 ** This file is part of the test suite of the Qt Toolkit.
       
     8 **
       
     9 ** $QT_BEGIN_LICENSE:LGPL$
       
    10 ** No Commercial Usage
       
    11 ** This file contains pre-release code and may not be distributed.
       
    12 ** You may use this file in accordance with the terms and conditions
       
    13 ** contained in the Technology Preview License Agreement accompanying
       
    14 ** this package.
       
    15 **
       
    16 ** GNU Lesser General Public License Usage
       
    17 ** Alternatively, this file may be used under the terms of the GNU Lesser
       
    18 ** General Public License version 2.1 as published by the Free Software
       
    19 ** Foundation and appearing in the file LICENSE.LGPL included in the
       
    20 ** packaging of this file.  Please review the following information to
       
    21 ** ensure the GNU Lesser General Public License version 2.1 requirements
       
    22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
       
    23 **
       
    24 ** In addition, as a special exception, Nokia gives you certain additional
       
    25 ** rights.  These rights are described in the Nokia Qt LGPL Exception
       
    26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
       
    27 **
       
    28 ** If you have questions regarding the use of this file, please contact
       
    29 ** Nokia at qt-info@nokia.com.
       
    30 **
       
    31 **
       
    32 **
       
    33 **
       
    34 **
       
    35 **
       
    36 **
       
    37 **
       
    38 ** $QT_END_LICENSE$
       
    39 **
       
    40 ****************************************************************************/
       
    41 #ifndef XMLDATA_H
       
    42 #define XMLDATA_H
       
    43 
       
    44 #include <QtXml>
       
    45 
       
    46 #include <QMap>
       
    47 #include <QDateTime>
       
    48 
       
    49 enum GeneratorFlag {
       
    50     Normal      = 0x1 << 0,
       
    51     Default     = 0x1 << 1,
       
    52     Foreign     = 0x1 << 2,
       
    53     Reference   = 0x1 << 3
       
    54 };
       
    55 Q_DECLARE_FLAGS(GeneratorFlags, GeneratorFlag);
       
    56 
       
    57 struct XMLData
       
    58 {
       
    59     XMLData()
       
    60         : date(QDateTime::currentDateTime()),
       
    61           timeToRender(0), iterations(0), maxElapsed(0),
       
    62           minElapsed(0)
       
    63     {}
       
    64     XMLData(const QDateTime &dt, int ttr, int itrs = 1)
       
    65         : date(dt), timeToRender(ttr),
       
    66           iterations(itrs), maxElapsed(0), minElapsed(0)
       
    67     {}
       
    68     XMLData(const QString &dt, int ttr, int itrs = 1)
       
    69         : timeToRender(ttr), iterations(itrs),
       
    70           maxElapsed(0), minElapsed(0)
       
    71     {
       
    72         date = QDateTime::fromString(dt);
       
    73     }
       
    74     QDateTime date;
       
    75     int timeToRender;
       
    76     int iterations;
       
    77     QString details;
       
    78     int maxElapsed;
       
    79     int minElapsed;
       
    80 };
       
    81 
       
    82 struct XMLFile
       
    83 {
       
    84     XMLFile()
       
    85     {}
       
    86     XMLFile(const QString &testcase)
       
    87         : name(testcase)
       
    88     {}
       
    89     XMLFile(const QString &testcase, const QString &img)
       
    90         : name(testcase), output(img)
       
    91     {}
       
    92 
       
    93     QString name;
       
    94     QString output;
       
    95     QList<XMLData> data;
       
    96 };
       
    97 
       
    98 struct XMLSuite
       
    99 {
       
   100     XMLSuite()
       
   101     {}
       
   102     XMLSuite(const QString &n)
       
   103         : name(n)
       
   104     {}
       
   105 
       
   106     QString name;
       
   107     QMap<QString, XMLFile*> files;
       
   108 };
       
   109 
       
   110 struct XMLEngine
       
   111 {
       
   112     XMLEngine()
       
   113         : defaultEngine(false), foreignEngine(false),
       
   114           referenceEngine(false)
       
   115     {}
       
   116     XMLEngine(const QString &engine, bool def)
       
   117         : name(engine), defaultEngine(def), foreignEngine(false),
       
   118           referenceEngine(false)
       
   119     {}
       
   120 
       
   121     QString name;
       
   122     bool defaultEngine;
       
   123     bool foreignEngine;
       
   124     bool referenceEngine;
       
   125     QMap<QString, XMLSuite*> suites;
       
   126     QDateTime generationDate;
       
   127 };
       
   128 
       
   129 
       
   130 
       
   131 class XMLReader : public QXmlDefaultHandler
       
   132 {
       
   133 public:
       
   134     XMLEngine *xmlEngine() const
       
   135     {
       
   136         return engine;
       
   137     }
       
   138 
       
   139     bool startElement(const QString &namespaceURI,
       
   140                       const QString &localName,
       
   141                       const QString &qName,
       
   142                       const QXmlAttributes &attributes);
       
   143     bool endElement(const QString &namespaceURI,
       
   144                     const QString &localName,
       
   145                     const QString &qName);
       
   146     bool fatalError(const QXmlParseException &exception);
       
   147 private:
       
   148     XMLEngine *engine;
       
   149     XMLSuite  *suite;
       
   150     XMLFile   *file;
       
   151 };
       
   152 
       
   153 #endif