|
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 #include "framework.h" |
|
42 |
|
43 #include <QFile> |
|
44 #include <QFileInfo> |
|
45 #include <QSettings> |
|
46 #include <QStringList> |
|
47 #include <QtDebug> |
|
48 |
|
49 Framework::Framework() |
|
50 : qsettings(0) |
|
51 { |
|
52 } |
|
53 |
|
54 Framework::Framework(const QString &file) |
|
55 : qsettings(0) |
|
56 { |
|
57 load(file); |
|
58 } |
|
59 |
|
60 Framework::~Framework() |
|
61 { |
|
62 delete qsettings; |
|
63 qsettings = 0; |
|
64 } |
|
65 |
|
66 QString Framework::basePath() const |
|
67 { |
|
68 if (!qsettings) |
|
69 return QString(); |
|
70 |
|
71 QFileInfo fi(qsettings->fileName()); |
|
72 return fi.absolutePath(); |
|
73 } |
|
74 |
|
75 |
|
76 QStringList Framework::suites() const |
|
77 { |
|
78 if (!qsettings) |
|
79 return QStringList(); |
|
80 |
|
81 QStringList tests = qsettings->childGroups(); |
|
82 qDebug()<<"here suites "<<tests; |
|
83 tests.removeAll("General"); |
|
84 tests.removeAll("Blacklist"); |
|
85 return tests; |
|
86 } |
|
87 |
|
88 |
|
89 bool Framework::isTestBlacklisted(const QString &engineName, |
|
90 const QString &testcase) const |
|
91 { |
|
92 return m_blacklist[engineName].contains(testcase); |
|
93 } |
|
94 |
|
95 bool Framework::isValid() const |
|
96 { |
|
97 return qsettings; |
|
98 } |
|
99 |
|
100 void Framework::load(const QString &file) |
|
101 { |
|
102 if (qsettings) { |
|
103 delete qsettings; |
|
104 qsettings = 0; |
|
105 } |
|
106 if (QFile::exists(file)) { |
|
107 qsettings = new QSettings(file, QSettings::IniFormat); |
|
108 qsettings->beginGroup(QString("Blacklist")); |
|
109 QStringList engines = qsettings->childKeys(); |
|
110 foreach(QString engineName, engines) { |
|
111 QStringList testcases = qsettings->value(engineName).toStringList(); |
|
112 m_blacklist.insert(engineName, testcases); |
|
113 qDebug()<<"Blacklists for "<<testcases; |
|
114 } |
|
115 qsettings->endGroup(); |
|
116 } |
|
117 } |
|
118 |
|
119 QString Framework::outputDir() const |
|
120 { |
|
121 qsettings->beginGroup("General"); |
|
122 QString outputDirName = qsettings->value("outputDir").toString(); |
|
123 qsettings->endGroup(); |
|
124 return outputDirName; |
|
125 } |
|
126 |
|
127 QSettings * Framework::settings() const |
|
128 { |
|
129 return qsettings; |
|
130 } |