1 /****************************************************************************
3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
4 ** All rights reserved.
5 ** Contact: Nokia Corporation (qt-info@nokia.com)
7 ** This file is part of the test suite of the Qt Toolkit.
9 ** $QT_BEGIN_LICENSE:LGPL$
10 ** GNU Lesser General Public License Usage
11 ** This file may be used under the terms of the GNU Lesser General Public
12 ** License version 2.1 as published by the Free Software Foundation and
13 ** appearing in the file LICENSE.LGPL included in the packaging of this
14 ** file. Please review the following information to ensure the GNU Lesser
15 ** General Public License version 2.1 requirements will be met:
16 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
18 ** In addition, as a special exception, Nokia gives you certain additional
19 ** rights. These rights are described in the Nokia Qt LGPL Exception
20 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
22 ** GNU General Public License Usage
23 ** Alternatively, this file may be used under the terms of the GNU General
24 ** Public License version 3.0 as published by the Free Software Foundation
25 ** and appearing in the file LICENSE.GPL included in the packaging of this
26 ** file. Please review the following information to ensure the GNU General
27 ** Public License version 3.0 requirements will be met:
28 ** http://www.gnu.org/copyleft/gpl.html.
31 ** Alternatively, this file may be used in accordance with the terms and
32 ** conditions contained in a signed written agreement between you and Nokia.
40 ****************************************************************************/
45 #include "UserTestCase.h"
46 #include "ui_ui_BaseLinePage.h"
48 #include "TestCaseView.h"
50 using namespace QPatternistSDK;
53 * Removes all tabs in @p widget, and deletes its page widgets.
55 static void clearTabWidget(QTabWidget *const widget)
59 /* Very annoying, we can't cache count(). */
60 /* Idea: QTabWidget::clear(bool deletePageWidgets = false); */
61 while(widget->count() != 0)
63 delete widget->widget(0);
67 Q_ASSERT(widget->count() == 0);
70 TestCaseView::TestCaseView(QWidget *const p) : QDockWidget(QLatin1String("Test Case View"), p)
72 setObjectName(QLatin1String("TestCaseView"));
73 setWidget(new QWidget());
76 clearTabWidget(baselinesTabs);
79 void TestCaseView::displayNone()
81 stackedWidget->setCurrentIndex(1);
84 void TestCaseView::displayTestCase(TestCase *const tc)
92 name->setText(tc->title());
93 description->setText(tc->description());
94 isXPath->setText(tc->isXPath() ? QLatin1String("yes") : QLatin1String("no"));
95 author->setText(tc->creator());
96 type->setText(TestCase::displayName(tc->scenario()));
97 if(tc->lastModified().isNull())
98 lastModified->setText(QLatin1String("Not specified."));
100 lastModified->setText(tc->lastModified().toString());
102 if(tc->contextItemSource().isValid())
103 focusDocument->setText(tc->contextItemSource().toLocalFile());
108 const QString sourceCode(tc->sourceCode(ok));
110 if(sourceCode.isEmpty())
111 sourceEdit->setPlainText(QLatin1String("No source code available."));
113 sourceEdit->setPlainText(sourceCode);
115 stackedWidget->setCurrentIndex(0);
117 displayBaseLines(tc);
120 void TestCaseView::displayBaseLines(const TestCase *const tc)
122 clearTabWidget(baselinesTabs);
124 const TestBaseLine::List bs(tc->baseLines());
125 const TestBaseLine::List::const_iterator end(bs.constEnd());
126 TestBaseLine::List::const_iterator it(bs.constBegin());
128 for(; it != end; ++it)
130 const TestBaseLine *const bl = *it;
132 const TestBaseLine::Type t = bl->type();
134 QString title(TestBaseLine::displayName(t));
135 const QString details(bl->details());
137 QWidget *const currPage = new QWidget();
138 Ui::BaseLinePage setupPage;
139 setupPage.setupUi(currPage);
141 /* Make this title a bit better: "ExpectedError: XPTY0004", for example. */
144 case TestBaseLine::ExpectedError:
146 title += (QLatin1String(": ") + details);
149 case TestBaseLine::Ignore:
151 setupPage.contentEdit->setEnabled(false);
156 setupPage.contentEdit->setPlainText(details);
161 baselinesTabs->addTab(currPage, title);
164 int tabIndex = baselinesTabs->count(); /* The tab we're about to add. */
165 baselinesTabs->addTab(new QWidget(), QLatin1String("AST Baseline"));
166 baselinesTabs->setTabToolTip(tabIndex,
167 QLatin1String("Expected AST baselines are not yet implemented."));
168 baselinesTabs->setTabEnabled(tabIndex, false);
170 ++tabIndex; /* Again, the tab we're about to add. */
171 baselinesTabs->addTab(new QWidget(), QLatin1String("Message Baseline"));
172 baselinesTabs->setTabToolTip(tabIndex,
173 QLatin1String("Expected Message baselines are not yet implemented."));
174 baselinesTabs->setTabEnabled(tabIndex, false);
176 baselinesTabs->setCurrentIndex(0);
179 // vim: et:ts=4:sw=4:sts=4