|
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 |
|
43 #include <QtTest/QtTest> |
|
44 |
|
45 #include <qapplication.h> |
|
46 #include <qdebug.h> |
|
47 #include <q3filedialog.h> |
|
48 #include <qlabel.h> |
|
49 |
|
50 //TESTED_CLASS= |
|
51 //TESTED_FILES= |
|
52 |
|
53 class tst_Q3FileDialog : public QObject |
|
54 { |
|
55 Q_OBJECT |
|
56 |
|
57 public: |
|
58 tst_Q3FileDialog(); |
|
59 virtual ~tst_Q3FileDialog(); |
|
60 |
|
61 private slots: |
|
62 void getSetCheck(); |
|
63 }; |
|
64 |
|
65 tst_Q3FileDialog::tst_Q3FileDialog() |
|
66 { |
|
67 } |
|
68 |
|
69 tst_Q3FileDialog::~tst_Q3FileDialog() |
|
70 { |
|
71 } |
|
72 |
|
73 class Preview : public QLabel, public Q3FilePreview |
|
74 { |
|
75 public: |
|
76 Preview(QWidget *parent=0) : QLabel(parent) {} |
|
77 |
|
78 void previewUrl(const Q3Url &u) |
|
79 { |
|
80 QString path = u.path(); |
|
81 QPixmap pix(path); |
|
82 if (pix.isNull()) |
|
83 setText("This is not a pixmap"); |
|
84 else |
|
85 setText("This is a pixmap"); |
|
86 } |
|
87 }; |
|
88 |
|
89 |
|
90 // Testing get/set functions |
|
91 void tst_Q3FileDialog::getSetCheck() |
|
92 { |
|
93 Q3FileDialog obj1; |
|
94 // bool Q3FileDialog::showHiddenFiles() |
|
95 // void Q3FileDialog::setShowHiddenFiles(bool) |
|
96 obj1.setShowHiddenFiles(false); |
|
97 QCOMPARE(false, obj1.showHiddenFiles()); |
|
98 obj1.setShowHiddenFiles(true); |
|
99 QCOMPARE(true, obj1.showHiddenFiles()); |
|
100 |
|
101 // ViewMode Q3FileDialog::viewMode() |
|
102 // void Q3FileDialog::setViewMode(ViewMode) |
|
103 obj1.setViewMode(Q3FileDialog::ViewMode(Q3FileDialog::Detail)); |
|
104 QCOMPARE(obj1.viewMode(), Q3FileDialog::ViewMode(Q3FileDialog::Detail)); |
|
105 obj1.setViewMode(Q3FileDialog::ViewMode(Q3FileDialog::List)); |
|
106 QCOMPARE(obj1.viewMode(), Q3FileDialog::ViewMode(Q3FileDialog::List)); |
|
107 |
|
108 Preview* p = new Preview; |
|
109 obj1.setContentsPreviewEnabled(true); |
|
110 obj1.setContentsPreview(p, p); |
|
111 obj1.setInfoPreviewEnabled(true); |
|
112 obj1.setInfoPreview(p, p); |
|
113 // PreviewMode Q3FileDialog::previewMode() |
|
114 // void Q3FileDialog::setPreviewMode(PreviewMode) |
|
115 obj1.setPreviewMode(Q3FileDialog::PreviewMode(Q3FileDialog::NoPreview)); |
|
116 QCOMPARE(obj1.previewMode(), Q3FileDialog::PreviewMode(Q3FileDialog::NoPreview)); |
|
117 |
|
118 obj1.setContentsPreviewEnabled(true); |
|
119 obj1.setInfoPreviewEnabled(false); |
|
120 obj1.setPreviewMode(Q3FileDialog::PreviewMode(Q3FileDialog::Contents)); |
|
121 QCOMPARE(obj1.previewMode(), Q3FileDialog::PreviewMode(Q3FileDialog::Contents)); |
|
122 |
|
123 obj1.setInfoPreviewEnabled(true); |
|
124 obj1.setContentsPreviewEnabled(false); |
|
125 obj1.setPreviewMode(Q3FileDialog::PreviewMode(Q3FileDialog::Info)); |
|
126 QCOMPARE(obj1.previewMode(), Q3FileDialog::PreviewMode(Q3FileDialog::Info)); |
|
127 } |
|
128 |
|
129 QTEST_MAIN(tst_Q3FileDialog) |
|
130 #include "tst_q3filedialog.moc" |