tests/auto/qprogressdialog/tst_qprogressdialog.cpp
changeset 0 1918ee327afb
child 4 3b1da2848fc7
equal deleted inserted replaced
-1:000000000000 0:1918ee327afb
       
     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 <qcoreapplication.h>
       
    46 #include <qdebug.h>
       
    47 #include <qprogressdialog.h>
       
    48 #include <qlabel.h>
       
    49 
       
    50 
       
    51 //TESTED_CLASS=
       
    52 //TESTED_FILES=
       
    53 
       
    54 class tst_QProgressDialog : public QObject
       
    55 {
       
    56 Q_OBJECT
       
    57 
       
    58 public:
       
    59     tst_QProgressDialog();
       
    60     virtual ~tst_QProgressDialog();
       
    61 
       
    62 private slots:
       
    63     void getSetCheck();
       
    64     void task198202();
       
    65 };
       
    66 
       
    67 tst_QProgressDialog::tst_QProgressDialog()
       
    68 {
       
    69 }
       
    70 
       
    71 tst_QProgressDialog::~tst_QProgressDialog()
       
    72 {
       
    73 }
       
    74 
       
    75 // Testing get/set functions
       
    76 void tst_QProgressDialog::getSetCheck()
       
    77 {
       
    78     QProgressDialog obj1;
       
    79     // bool QProgressDialog::autoReset()
       
    80     // void QProgressDialog::setAutoReset(bool)
       
    81     obj1.setAutoReset(false);
       
    82     QCOMPARE(false, obj1.autoReset());
       
    83     obj1.setAutoReset(true);
       
    84     QCOMPARE(true, obj1.autoReset());
       
    85 
       
    86     // bool QProgressDialog::autoClose()
       
    87     // void QProgressDialog::setAutoClose(bool)
       
    88     obj1.setAutoClose(false);
       
    89     QCOMPARE(false, obj1.autoClose());
       
    90     obj1.setAutoClose(true);
       
    91     QCOMPARE(true, obj1.autoClose());
       
    92 
       
    93     // int QProgressDialog::maximum()
       
    94     // void QProgressDialog::setMaximum(int)
       
    95     obj1.setMaximum(0);
       
    96     QCOMPARE(0, obj1.maximum());
       
    97     obj1.setMaximum(INT_MIN);
       
    98     QCOMPARE(INT_MIN, obj1.maximum());
       
    99     obj1.setMaximum(INT_MAX);
       
   100     QCOMPARE(INT_MAX, obj1.maximum());
       
   101 
       
   102     // int QProgressDialog::minimum()
       
   103     // void QProgressDialog::setMinimum(int)
       
   104     obj1.setMinimum(0);
       
   105     QCOMPARE(0, obj1.minimum());
       
   106     obj1.setMinimum(INT_MIN);
       
   107     QCOMPARE(INT_MIN, obj1.minimum());
       
   108     obj1.setMinimum(INT_MAX);
       
   109     QCOMPARE(INT_MAX, obj1.minimum());
       
   110 
       
   111     // int QProgressDialog::value()
       
   112     // void QProgressDialog::setValue(int)
       
   113     obj1.setMaximum(INT_MAX);
       
   114     obj1.setMinimum(INT_MIN);
       
   115     obj1.setValue(0);
       
   116     QCOMPARE(0, obj1.value());
       
   117     obj1.setValue(INT_MIN+1);
       
   118     QCOMPARE(INT_MIN+1, obj1.value());
       
   119     obj1.setValue(INT_MIN);
       
   120     QCOMPARE(INT_MIN, obj1.value());
       
   121     obj1.setValue(INT_MAX-1);
       
   122     QCOMPARE(INT_MAX-1, obj1.value());
       
   123 
       
   124     obj1.setValue(INT_MAX);
       
   125     QCOMPARE(INT_MIN, obj1.value()); // We set autoReset, the thing is reset
       
   126 
       
   127     obj1.setAutoReset(false);
       
   128     obj1.setValue(INT_MAX);
       
   129     QCOMPARE(INT_MAX, obj1.value());
       
   130     obj1.setAutoReset(true);
       
   131 
       
   132     // int QProgressDialog::minimumDuration()
       
   133     // void QProgressDialog::setMinimumDuration(int)
       
   134     obj1.setMinimumDuration(0);
       
   135     QCOMPARE(0, obj1.minimumDuration());
       
   136     obj1.setMinimumDuration(INT_MIN);
       
   137     QCOMPARE(INT_MIN, obj1.minimumDuration());
       
   138     obj1.setMinimumDuration(INT_MAX);
       
   139     QCOMPARE(INT_MAX, obj1.minimumDuration());
       
   140 }
       
   141 
       
   142 void tst_QProgressDialog::task198202()
       
   143 {
       
   144     //should not crash
       
   145     QProgressDialog dlg(QLatin1String("test"),QLatin1String("test"),1,10);
       
   146     dlg.show();
       
   147     QTest::qWait(20);
       
   148     int futureHeight = dlg.sizeHint().height() - qFindChild<QLabel*>(&dlg)->sizeHint().height();
       
   149     dlg.setLabel(0);
       
   150     QTest::ignoreMessage(QtWarningMsg, "QProgressDialog::setBar: Cannot set a null progress bar");
       
   151     dlg.setBar(0);
       
   152     QTest::qWait(20);
       
   153     QCOMPARE(dlg.sizeHint().height(), futureHeight);
       
   154 }
       
   155 
       
   156 QTEST_MAIN(tst_QProgressDialog)
       
   157 #include "tst_qprogressdialog.moc"