0
|
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 |
|
|
42 |
#include <QHeaderView>
|
|
43 |
|
|
44 |
#include "ASTItem.h"
|
|
45 |
#include "ErrorItem.h"
|
|
46 |
#include "TestCase.h"
|
|
47 |
#include "TestResult.h"
|
|
48 |
#include "TreeModel.h"
|
|
49 |
#include "XDTItemItem.h"
|
|
50 |
|
|
51 |
#include "TestResultView.h"
|
|
52 |
|
|
53 |
using namespace QPatternistSDK;
|
|
54 |
|
|
55 |
TestResultView::TestResultView(QWidget *const p) : QDockWidget(QLatin1String("Test Result View"), p)
|
|
56 |
{
|
|
57 |
Q_ASSERT(p);
|
|
58 |
setObjectName(QLatin1String("TestResultView"));
|
|
59 |
setWidget(new QWidget());
|
|
60 |
setupUi(widget());
|
|
61 |
|
|
62 |
QStringList astColumns;
|
|
63 |
astColumns << QLatin1String("Node Name")
|
|
64 |
<< QLatin1String("Details")
|
|
65 |
<< QLatin1String("Static Type")
|
|
66 |
<< QLatin1String("Required Type");
|
|
67 |
astView->setModel(new TreeModel(astColumns, this));
|
|
68 |
|
|
69 |
QStringList itemColumns;
|
|
70 |
itemColumns << QLatin1String("#")
|
|
71 |
<< QLatin1String("Value")
|
|
72 |
<< QLatin1String("Type");
|
|
73 |
itemListResult->setModel(new TreeModel(itemColumns, this));
|
|
74 |
|
|
75 |
QStringList errColumns;
|
|
76 |
errColumns << QLatin1String("Severity")
|
|
77 |
<< QLatin1String("Error Code")
|
|
78 |
<< QLatin1String("Message");
|
|
79 |
messageOutput->setModel(new TreeModel(errColumns, this));
|
|
80 |
messageOutput->horizontalHeader()->setStretchLastSection(true);
|
|
81 |
}
|
|
82 |
|
|
83 |
void TestResultView::displayTestResult(const TestResult *const result)
|
|
84 |
{
|
|
85 |
if(!result)
|
|
86 |
{
|
|
87 |
displayNone();
|
|
88 |
return;
|
|
89 |
}
|
|
90 |
|
|
91 |
/* ------- the Test Status Label --------- */
|
|
92 |
resultStatus->setText(result->status() ? TestResult::displayName(result->status())
|
|
93 |
: QLatin1String("Not Applicable"));
|
|
94 |
/* --------------------------------------- */
|
|
95 |
|
|
96 |
/* ------------ the AST View ------------- */
|
|
97 |
ASTItem *astTree = result->astTree();
|
|
98 |
static_cast<TreeModel *>(astView->model())->setRoot(astTree);
|
|
99 |
/* --------------------------------------- */
|
|
100 |
|
|
101 |
/* ------- the Error code/msg View ------- */
|
|
102 |
ErrorItem *msgRoot = new ErrorItem(ErrorHandler::Message(), 0);
|
|
103 |
|
|
104 |
const ErrorHandler::Message::List msgs(result->messages());
|
|
105 |
ErrorHandler::Message::List::const_iterator it(msgs.constBegin());
|
|
106 |
const ErrorHandler::Message::List::const_iterator end(msgs.constEnd());
|
|
107 |
|
|
108 |
for(; it != end; ++it)
|
|
109 |
msgRoot->appendChild(new ErrorItem(*it, msgRoot));
|
|
110 |
|
|
111 |
TreeModel *etm = static_cast<TreeModel *>(messageOutput->model());
|
|
112 |
etm->setRoot(msgRoot);
|
|
113 |
/* --------------------------------------- */
|
|
114 |
|
|
115 |
const QPatternist::Item::List items(result->items());
|
|
116 |
/* ----- the Serialized Output View ------ */
|
|
117 |
serializedResult->setPlainText(result->asSerialized());
|
|
118 |
/* --------------------------------------- */
|
|
119 |
|
|
120 |
/* ------ the Item List Output View ------ */
|
|
121 |
XDTItemItem *itemRoot = new XDTItemItem(QPatternist::Item(), 0);
|
|
122 |
QPatternist::Item item;
|
|
123 |
|
|
124 |
QPatternist::Item::List::const_iterator itemIt(items.constBegin());
|
|
125 |
const QPatternist::Item::List::const_iterator itemsEnd(items.constEnd());
|
|
126 |
|
|
127 |
for(; itemIt != itemsEnd; ++itemIt)
|
|
128 |
itemRoot->appendChild(new XDTItemItem(*itemIt, itemRoot));
|
|
129 |
|
|
130 |
TreeModel *itm = static_cast<TreeModel *>(itemListResult->model());
|
|
131 |
itm->setRoot(itemRoot);
|
|
132 |
/* --------------------------------------- */
|
|
133 |
}
|
|
134 |
|
|
135 |
void TestResultView::displayTestResult(TestCase *const tc)
|
|
136 |
{
|
|
137 |
if(tc)
|
|
138 |
displayTestResult(tc->testResult());
|
|
139 |
else
|
|
140 |
displayNone();
|
|
141 |
}
|
|
142 |
|
|
143 |
void TestResultView::displayNone()
|
|
144 |
{
|
|
145 |
TreeModel *tm;
|
|
146 |
|
|
147 |
tm = static_cast<TreeModel *>(astView->model());
|
|
148 |
Q_ASSERT(tm);
|
|
149 |
tm->setRoot(0);
|
|
150 |
|
|
151 |
tm = static_cast<TreeModel *>(messageOutput->model());
|
|
152 |
Q_ASSERT(tm);
|
|
153 |
tm->setRoot(0);
|
|
154 |
|
|
155 |
tm = static_cast<TreeModel *>(itemListResult->model());
|
|
156 |
Q_ASSERT(tm);
|
|
157 |
tm->setRoot(0);
|
|
158 |
|
|
159 |
serializedResult->clear();
|
|
160 |
resultStatus->clear();
|
|
161 |
}
|
|
162 |
|
|
163 |
// vim: et:ts=4:sw=4:sts=4
|