[556] | 1 | /****************************************************************************
|
---|
| 2 | **
|
---|
[846] | 3 | ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
---|
[556] | 4 | ** All rights reserved.
|
---|
| 5 | ** Contact: Nokia Corporation ([email protected])
|
---|
| 6 | **
|
---|
| 7 | ** This file is part of the QtTest module of the Qt Toolkit.
|
---|
| 8 | **
|
---|
| 9 | ** $QT_BEGIN_LICENSE:LGPL$
|
---|
| 10 | ** Commercial Usage
|
---|
| 11 | ** Licensees holding valid Qt Commercial licenses may use this file in
|
---|
| 12 | ** accordance with the Qt Commercial License Agreement provided with the
|
---|
| 13 | ** Software or, alternatively, in accordance with the terms contained in
|
---|
| 14 | ** a written agreement between you and Nokia.
|
---|
| 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 | ** GNU General Public License Usage
|
---|
| 29 | ** Alternatively, this file may be used under the terms of the GNU
|
---|
| 30 | ** General Public License version 3.0 as published by the Free Software
|
---|
| 31 | ** Foundation and appearing in the file LICENSE.GPL included in the
|
---|
| 32 | ** packaging of this file. Please review the following information to
|
---|
| 33 | ** ensure the GNU General Public License version 3.0 requirements will be
|
---|
| 34 | ** met: http://www.gnu.org/copyleft/gpl.html.
|
---|
| 35 | **
|
---|
| 36 | ** If you have questions regarding the use of this file, please contact
|
---|
| 37 | ** Nokia at [email protected].
|
---|
| 38 | ** $QT_END_LICENSE$
|
---|
| 39 | **
|
---|
| 40 | ****************************************************************************/
|
---|
| 41 |
|
---|
| 42 | #include "qtestelementattribute.h"
|
---|
| 43 | #include <QtCore/qbytearray.h>
|
---|
| 44 | #include <string.h>
|
---|
| 45 | #include <stdlib.h>
|
---|
| 46 |
|
---|
| 47 | QT_BEGIN_NAMESPACE
|
---|
| 48 |
|
---|
| 49 | /*! \enum QTest::AttributeIndex
|
---|
| 50 | This enum numbers the different tests.
|
---|
| 51 |
|
---|
| 52 | \value AI_Undefined
|
---|
| 53 |
|
---|
| 54 | \value AI_Name
|
---|
| 55 |
|
---|
| 56 | \value AI_Result
|
---|
| 57 |
|
---|
| 58 | \value AI_Tests
|
---|
| 59 |
|
---|
| 60 | \value AI_Failures
|
---|
| 61 |
|
---|
| 62 | \value AI_Errors
|
---|
| 63 |
|
---|
| 64 | \value AI_Type
|
---|
| 65 |
|
---|
| 66 | \value AI_Description
|
---|
| 67 |
|
---|
| 68 | \value AI_PropertyValue
|
---|
| 69 |
|
---|
| 70 | \value AI_QTestVersion
|
---|
| 71 |
|
---|
| 72 | \value AI_QtVersion
|
---|
| 73 |
|
---|
| 74 | \value AI_File
|
---|
| 75 |
|
---|
| 76 | \value AI_Line
|
---|
| 77 |
|
---|
| 78 | \value AI_Metric
|
---|
| 79 |
|
---|
| 80 | \value AI_Tag
|
---|
| 81 |
|
---|
| 82 | \value AI_Value
|
---|
| 83 |
|
---|
| 84 | \value AI_Iterations
|
---|
| 85 | */
|
---|
| 86 |
|
---|
| 87 | /*! \enum QTest::LogElementType
|
---|
| 88 | The enum specifies the kinds of test log messages.
|
---|
| 89 |
|
---|
| 90 | \value LET_Undefined
|
---|
| 91 |
|
---|
| 92 | \value LET_Property
|
---|
| 93 |
|
---|
| 94 | \value LET_Properties
|
---|
| 95 |
|
---|
| 96 | \value LET_Failure
|
---|
| 97 |
|
---|
| 98 | \value LET_Error
|
---|
| 99 |
|
---|
| 100 | \value LET_TestCase
|
---|
| 101 |
|
---|
| 102 | \value LET_TestSuite
|
---|
| 103 |
|
---|
| 104 | \value LET_Benchmark
|
---|
| 105 |
|
---|
| 106 | \value LET_SystemError
|
---|
| 107 | */
|
---|
| 108 |
|
---|
| 109 | QTestElementAttribute::QTestElementAttribute()
|
---|
| 110 | :attributeValue(0),
|
---|
| 111 | attributeIndex(QTest::AI_Undefined)
|
---|
| 112 | {
|
---|
| 113 | }
|
---|
| 114 |
|
---|
| 115 | QTestElementAttribute::~QTestElementAttribute()
|
---|
| 116 | {
|
---|
| 117 | delete[] attributeValue;
|
---|
| 118 | }
|
---|
| 119 |
|
---|
| 120 | const char *QTestElementAttribute::value() const
|
---|
| 121 | {
|
---|
| 122 | return attributeValue;
|
---|
| 123 | }
|
---|
| 124 |
|
---|
| 125 | const char *QTestElementAttribute::name() const
|
---|
| 126 | {
|
---|
| 127 | const char *AttributeNames[] =
|
---|
| 128 | {
|
---|
| 129 | "name",
|
---|
| 130 | "result",
|
---|
| 131 | "tests",
|
---|
| 132 | "failures",
|
---|
| 133 | "errors",
|
---|
| 134 | "type",
|
---|
| 135 | "description",
|
---|
| 136 | "value",
|
---|
| 137 | "qtestversion",
|
---|
| 138 | "qtversion",
|
---|
| 139 | "file",
|
---|
| 140 | "line",
|
---|
| 141 | "metric",
|
---|
| 142 | "tag",
|
---|
| 143 | "value",
|
---|
| 144 | "iterations"
|
---|
| 145 | };
|
---|
| 146 |
|
---|
| 147 | if(attributeIndex != QTest::AI_Undefined)
|
---|
| 148 | return AttributeNames[attributeIndex];
|
---|
| 149 |
|
---|
| 150 | return 0;
|
---|
| 151 | }
|
---|
| 152 |
|
---|
| 153 | QTest::AttributeIndex QTestElementAttribute::index() const
|
---|
| 154 | {
|
---|
| 155 | return attributeIndex;
|
---|
| 156 | }
|
---|
| 157 |
|
---|
| 158 | bool QTestElementAttribute::isNull() const
|
---|
| 159 | {
|
---|
| 160 | return attributeIndex == QTest::AI_Undefined;
|
---|
| 161 | }
|
---|
| 162 |
|
---|
| 163 | bool QTestElementAttribute::setPair(QTest::AttributeIndex index, const char *value)
|
---|
| 164 | {
|
---|
| 165 | if(!value)
|
---|
| 166 | return false;
|
---|
| 167 |
|
---|
| 168 | delete[] attributeValue;
|
---|
| 169 |
|
---|
| 170 | attributeIndex = index;
|
---|
| 171 | attributeValue = qstrdup(value);
|
---|
| 172 |
|
---|
| 173 | return (attributeValue!=0) ? true:false;
|
---|
| 174 | }
|
---|
| 175 |
|
---|
| 176 | QT_END_NAMESPACE
|
---|
| 177 |
|
---|