1
/****************************************************************************
2
**
3
** Copyright (C) 2011 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
** 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.
17
**
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.
21
**
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.
29
**
30
** Other Usage
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.
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
#ifndef QT_MAC_USE_COCOA
63
    void getSetCheck();
64
#endif
65
};
66
67
tst_Q3FileDialog::tst_Q3FileDialog()
68
{
69
}
70
71
tst_Q3FileDialog::~tst_Q3FileDialog()
72
{
73
}
74
75
#ifndef QT_MAC_USE_COCOA
76
  class Preview : public QLabel, public Q3FilePreview
77
  {
78
  public:
79
      Preview(QWidget *parent=0) : QLabel(parent) {}
80
81
      void previewUrl(const Q3Url &u)
82
      {
83
          QString path = u.path();
84
          QPixmap pix(path);
85
          if (pix.isNull())
86
              setText("This is not a pixmap");
87
          else
88
              setText("This is a pixmap");
89
      }
90
  };
91
92
93
// Testing get/set functions
94
void tst_Q3FileDialog::getSetCheck()
95
{
96
    Q3FileDialog obj1;
97
    // bool Q3FileDialog::showHiddenFiles()
98
    // void Q3FileDialog::setShowHiddenFiles(bool)
99
    obj1.setShowHiddenFiles(false);
100
    QCOMPARE(false, obj1.showHiddenFiles());
101
    obj1.setShowHiddenFiles(true);
102
    QCOMPARE(true, obj1.showHiddenFiles());
103
104
    // ViewMode Q3FileDialog::viewMode()
105
    // void Q3FileDialog::setViewMode(ViewMode)
106
    obj1.setViewMode(Q3FileDialog::ViewMode(Q3FileDialog::Detail));
107
    QCOMPARE(obj1.viewMode(), Q3FileDialog::ViewMode(Q3FileDialog::Detail));
108
    obj1.setViewMode(Q3FileDialog::ViewMode(Q3FileDialog::List));
109
    QCOMPARE(obj1.viewMode(), Q3FileDialog::ViewMode(Q3FileDialog::List));
110
111
    Preview* p = new Preview;
112
    obj1.setContentsPreviewEnabled(true);
113
    obj1.setContentsPreview(p, p);
114
    obj1.setInfoPreviewEnabled(true);
115
    obj1.setInfoPreview(p, p);
116
    // PreviewMode Q3FileDialog::previewMode()
117
    // void Q3FileDialog::setPreviewMode(PreviewMode)
118
    obj1.setPreviewMode(Q3FileDialog::PreviewMode(Q3FileDialog::NoPreview));
119
    QCOMPARE(obj1.previewMode(), Q3FileDialog::PreviewMode(Q3FileDialog::NoPreview));
120
121
    obj1.setContentsPreviewEnabled(true);
122
    obj1.setInfoPreviewEnabled(false);
123
    obj1.setPreviewMode(Q3FileDialog::PreviewMode(Q3FileDialog::Contents));
124
    QCOMPARE(obj1.previewMode(), Q3FileDialog::PreviewMode(Q3FileDialog::Contents));
125
126
    obj1.setInfoPreviewEnabled(true);
127
    obj1.setContentsPreviewEnabled(false);
128
    obj1.setPreviewMode(Q3FileDialog::PreviewMode(Q3FileDialog::Info));
129
    QCOMPARE(obj1.previewMode(), Q3FileDialog::PreviewMode(Q3FileDialog::Info));
130
}
131
#endif
132
133
QTEST_MAIN(tst_Q3FileDialog)
134
#include "tst_q3filedialog.moc"