author | Eckhart Koeppen <eckhart.koppen@nokia.com> |
Thu, 22 Apr 2010 16:15:11 +0300 | |
branch | RCL_3 |
changeset 14 | 8c4229025c0b |
parent 4 | 3b1da2848fc7 |
permissions | -rw-r--r-- |
0 | 1 |
/**************************************************************************** |
2 |
** |
|
4
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3 |
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). |
0 | 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 <QtTest/QtTest> |
|
42 |
#include <QErrorMessage> |
|
43 |
#include <QDebug> |
|
44 |
#include <QCheckBox> |
|
45 |
||
46 |
class tst_QErrorMessage : public QObject |
|
47 |
{ |
|
48 |
Q_OBJECT |
|
49 |
||
50 |
private slots: |
|
51 |
void dontShowAgain(); |
|
52 |
void dontShowCategoryAgain(); |
|
53 |
||
54 |
}; |
|
55 |
||
56 |
void tst_QErrorMessage::dontShowAgain() |
|
57 |
{ |
|
58 |
QString plainString = QLatin1String("foo"); |
|
59 |
QString htmlString = QLatin1String("foo<br>bar"); |
|
60 |
QCheckBox *checkBox = 0; |
|
61 |
||
62 |
QErrorMessage errorMessageDialog(0); |
|
63 |
||
64 |
// show an error with plain string |
|
65 |
errorMessageDialog.showMessage(plainString); |
|
66 |
QVERIFY(errorMessageDialog.isVisible()); |
|
67 |
checkBox = qFindChild<QCheckBox*>(&errorMessageDialog); |
|
68 |
QVERIFY(checkBox); |
|
69 |
QVERIFY(checkBox->isChecked()); |
|
70 |
errorMessageDialog.close(); |
|
71 |
||
72 |
errorMessageDialog.showMessage(plainString); |
|
73 |
QVERIFY(errorMessageDialog.isVisible()); |
|
74 |
checkBox = qFindChild<QCheckBox*>(&errorMessageDialog); |
|
75 |
QVERIFY(checkBox); |
|
76 |
QVERIFY(checkBox->isChecked()); |
|
77 |
checkBox->setChecked(false); |
|
78 |
errorMessageDialog.close(); |
|
79 |
||
80 |
errorMessageDialog.showMessage(plainString); |
|
81 |
QVERIFY(!errorMessageDialog.isVisible()); |
|
82 |
||
83 |
// show an error with an html string |
|
84 |
errorMessageDialog.showMessage(htmlString); |
|
85 |
QVERIFY(errorMessageDialog.isVisible()); |
|
86 |
checkBox = qFindChild<QCheckBox*>(&errorMessageDialog); |
|
87 |
QVERIFY(checkBox); |
|
88 |
QVERIFY(!checkBox->isChecked()); |
|
89 |
checkBox->setChecked(true); |
|
90 |
errorMessageDialog.close(); |
|
91 |
||
92 |
errorMessageDialog.showMessage(htmlString); |
|
93 |
QVERIFY(errorMessageDialog.isVisible()); |
|
94 |
checkBox = qFindChild<QCheckBox*>(&errorMessageDialog); |
|
95 |
QVERIFY(checkBox); |
|
96 |
QVERIFY(checkBox->isChecked()); |
|
97 |
checkBox->setChecked(false); |
|
98 |
errorMessageDialog.close(); |
|
99 |
||
100 |
errorMessageDialog.showMessage(htmlString); |
|
101 |
QVERIFY(!errorMessageDialog.isVisible()); |
|
102 |
} |
|
103 |
||
104 |
void tst_QErrorMessage::dontShowCategoryAgain() |
|
105 |
{ |
|
106 |
QString htmlString = QLatin1String("foo<br>bar"); |
|
107 |
QString htmlString2 = QLatin1String("foo2<br>bar2"); |
|
108 |
QCheckBox *checkBox = 0; |
|
109 |
||
110 |
QErrorMessage errorMessageDialog(0); |
|
111 |
||
112 |
errorMessageDialog.showMessage(htmlString,"Cat 1"); |
|
113 |
QVERIFY(errorMessageDialog.isVisible()); |
|
114 |
checkBox = qFindChild<QCheckBox*>(&errorMessageDialog); |
|
115 |
QVERIFY(checkBox); |
|
116 |
QVERIFY(checkBox->isChecked()); |
|
117 |
checkBox->setChecked(true); |
|
118 |
errorMessageDialog.close(); |
|
119 |
||
120 |
errorMessageDialog.showMessage(htmlString,"Cat 1"); |
|
121 |
QVERIFY(errorMessageDialog.isVisible()); |
|
122 |
checkBox = qFindChild<QCheckBox*>(&errorMessageDialog); |
|
123 |
QVERIFY(checkBox); |
|
124 |
QVERIFY(checkBox->isChecked()); |
|
125 |
checkBox->setChecked(true); |
|
126 |
errorMessageDialog.close(); |
|
127 |
||
128 |
errorMessageDialog.showMessage(htmlString2,"Cat 1"); |
|
129 |
QVERIFY(errorMessageDialog.isVisible()); |
|
130 |
checkBox = qFindChild<QCheckBox*>(&errorMessageDialog); |
|
131 |
QVERIFY(checkBox); |
|
132 |
QVERIFY(checkBox->isChecked()); |
|
133 |
checkBox->setChecked(true); |
|
134 |
errorMessageDialog.close(); |
|
135 |
||
136 |
errorMessageDialog.showMessage(htmlString,"Cat 1"); |
|
137 |
QVERIFY(errorMessageDialog.isVisible()); |
|
138 |
checkBox = qFindChild<QCheckBox*>(&errorMessageDialog); |
|
139 |
QVERIFY(checkBox); |
|
140 |
QVERIFY(checkBox->isChecked()); |
|
141 |
checkBox->setChecked(false); |
|
142 |
errorMessageDialog.close(); |
|
143 |
||
144 |
errorMessageDialog.showMessage(htmlString2,"Cat 1"); |
|
145 |
QVERIFY(!errorMessageDialog.isVisible()); |
|
146 |
||
147 |
errorMessageDialog.showMessage(htmlString,"Cat 1"); |
|
148 |
QVERIFY(!errorMessageDialog.isVisible()); |
|
149 |
||
150 |
errorMessageDialog.showMessage(htmlString); |
|
151 |
QVERIFY(errorMessageDialog.isVisible()); |
|
152 |
||
153 |
errorMessageDialog.showMessage(htmlString,"Cat 2"); |
|
154 |
QVERIFY(errorMessageDialog.isVisible()); |
|
155 |
} |
|
156 |
||
157 |
QTEST_MAIN(tst_QErrorMessage) |
|
158 |
#include "tst_qerrormessage.moc" |