|
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 examples 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 |
|
43 #include <QThread> |
|
44 #include "ftpserver.h" |
|
45 #include "ftpwindow.h" |
|
46 #include "autotest.h" |
|
47 |
|
48 |
|
49 class serverThread : public QThread |
|
50 { |
|
51 public: |
|
52 void run(); |
|
53 }; |
|
54 |
|
55 void serverThread::run() |
|
56 { |
|
57 ftpServer testServer; |
|
58 |
|
59 while ( testServer.isDone() ) |
|
60 { |
|
61 QTest::qWait(1000); |
|
62 } |
|
63 } |
|
64 |
|
65 void autoTest::initTestCase() |
|
66 { |
|
67 } |
|
68 |
|
69 void autoTest::testDefaults() |
|
70 { |
|
71 FtpWindow fw; |
|
72 |
|
73 fw.show(); |
|
74 |
|
75 // Test default values for widget properties |
|
76 // QCOMPARE( fw.acceptDrops(), false ); |
|
77 // QCOMPARE( fw.hasEditFocus(), false ); |
|
78 QCOMPARE( fw.hasFocus(), false ); |
|
79 QCOMPARE( fw.hasMouseTracking(), false ); |
|
80 /* |
|
81 QCOMPARE( fw.isActiveWindow(), true ); |
|
82 QCOMPARE( fw.isEnabled(), true ); |
|
83 QCOMPARE( fw.isFullScreen(), false ); |
|
84 QCOMPARE( fw.isHidden(), false ); |
|
85 QCOMPARE( fw.isMaximized(), false ); |
|
86 QCOMPARE( fw.isMinimized(), false ); |
|
87 QCOMPARE( fw.isModal(), false ); |
|
88 QCOMPARE( fw.isVisible(), true ); |
|
89 QCOMPARE( fw.isWindow(), true ); |
|
90 QCOMPARE( fw.isWindowModified(), false ); |
|
91 QCOMPARE( fw.underMouse(), false ); |
|
92 QCOMPARE( fw.updatesEnabled(), true ); |
|
93 */ |
|
94 |
|
95 fw.hide(); |
|
96 } |
|
97 |
|
98 void autoTest::testFtpWindow() |
|
99 { |
|
100 FtpWindow fw; |
|
101 |
|
102 fw.show(); |
|
103 |
|
104 // what to test here |
|
105 serverThread testThread; |
|
106 testThread.start(); |
|
107 |
|
108 QPushButton * connectButton; |
|
109 QList<QPushButton *> allPButtons = fw.findChildren<QPushButton *>(); |
|
110 QVERIFY( allPButtons.count() > 0 ); |
|
111 |
|
112 for ( int i = 0; i < allPButtons.count(); i++) |
|
113 { |
|
114 if ( allPButtons.at(i)->text() == QString("Connect") ) |
|
115 { |
|
116 connectButton = allPButtons.at(i); |
|
117 } |
|
118 else |
|
119 { |
|
120 // Other buttons than connect ignored so far... |
|
121 } |
|
122 } |
|
123 QVERIFY(connectButton); |
|
124 |
|
125 QLineEdit * addressLine; |
|
126 QList<QLineEdit *> allLineEds = fw.findChildren<QLineEdit *>(); |
|
127 QVERIFY( allLineEds.count() == 1 ); |
|
128 |
|
129 addressLine = allLineEds.at(0); |
|
130 |
|
131 while ( !addressLine->text().isEmpty() ) |
|
132 { |
|
133 QTest::keyClick ( addressLine, Qt::Key_Backspace, Qt::NoModifier, 100 ); |
|
134 } |
|
135 |
|
136 QTest::qWait(2000); |
|
137 QTest::keyClicks( addressLine, "127.0.0.1" ); |
|
138 |
|
139 QTest::qWait(2000); |
|
140 connectButton->click(); |
|
141 |
|
142 QLabel * statusLabel; |
|
143 QList<QLabel *> allLabels = fw.findChildren<QLabel *>(); |
|
144 QVERIFY( allLabels.count() > 0 ); |
|
145 |
|
146 for ( int i = 0; i < allLabels.count(); i++) |
|
147 { |
|
148 if ( allLabels.at(i)->text() == QString("Logged onto 127.0.0.1.") ) |
|
149 { |
|
150 statusLabel = allLabels.at(i); |
|
151 } |
|
152 else |
|
153 { |
|
154 // Other buttons than connect ignored so far... |
|
155 } |
|
156 } |
|
157 QVERIFY(statusLabel); |
|
158 |
|
159 QTest::qWait(2000); |
|
160 |
|
161 fw.hide(); |
|
162 } |
|
163 |
|
164 |
|
165 |