qt/qwidget/smoke_qwidget.cpp
author Brendan Donegan <brendand@symbian.org>
Mon, 14 Jun 2010 12:26:38 +0100
branchSymbian3
changeset 43 14fcccfb4c0c
permissions -rw-r--r--
Cleaning up the new Qt tests, removing redundant code
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
43
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
     1
/****************************************************************************
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
     2
**
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
     3
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
     4
** All rights reserved.
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
     5
** Contact: Nokia Corporation (qt-info@nokia.com)
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
     6
**
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
     7
** This file is part of the test suite of the Qt Toolkit.
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
     8
**
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
     9
** $QT_BEGIN_LICENSE:LGPL$
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
    10
** No Commercial Usage
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
    11
** This file contains pre-release code and may not be distributed.
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
    12
** You may use this file in accordance with the terms and conditions
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
    13
** contained in the Technology Preview License Agreement accompanying
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
    14
** this package.
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
    15
**
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
    16
** GNU Lesser General Public License Usage
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
    17
** Alternatively, this file may be used under the terms of the GNU Lesser
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
    18
** General Public License version 2.1 as published by the Free Software
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
    19
** Foundation and appearing in the file LICENSE.LGPL included in the
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
    20
** packaging of this file.  Please review the following information to
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
    21
** ensure the GNU Lesser General Public License version 2.1 requirements
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
    22
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
    23
**
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
    24
** In addition, as a special exception, Nokia gives you certain additional
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
    25
** rights.  These rights are described in the Nokia Qt LGPL Exception
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
    26
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
    27
**
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
    28
** If you have questions regarding the use of this file, please contact
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
    29
** Nokia at qt-info@nokia.com.
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
    30
**
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
    31
**
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
    32
**
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
    33
**
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
    34
**
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
    35
**
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
    36
**
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
    37
**
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
    38
** $QT_END_LICENSE$
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
    39
**
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
    40
****************************************************************************/
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
    41
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
    42
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
    43
#if defined(QT3_SUPPORT)
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
    44
#include <q3hbox.h>
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
    45
#include <q3textedit.h>
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
    46
#endif
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
    47
#include <qboxlayout.h>
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
    48
#include <qapplication.h>
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
    49
#include <qbitmap.h>
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
    50
#include <qdebug.h>
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
    51
#include <qeventloop.h>
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
    52
#include <qlabel.h>
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
    53
#include <qlayout.h>
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
    54
#include <qlineedit.h>
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
    55
#include <qlistview.h>
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
    56
#include <qmessagebox.h>
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
    57
#include <qpainter.h>
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
    58
#include <qpoint.h>
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
    59
#include <qpushbutton.h>
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
    60
#include <qstyle.h>
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
    61
#include <qwidget.h>
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
    62
#include <qwindowsstyle.h>
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
    63
#include <qinputcontext.h>
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
    64
#include <qdesktopwidget.h>
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
    65
#include <private/qwidget_p.h>
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
    66
#include <private/qapplication_p.h>
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
    67
#include <qcalendarwidget.h>
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
    68
#include <qmainwindow.h>
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
    69
#include <qdockwidget.h>
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
    70
#include <qtoolbar.h>
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
    71
#include <QtGui/qpaintengine.h>
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
    72
#include <private/qbackingstore_p.h>
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
    73
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
    74
#include <QtGui/QGraphicsView>
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
    75
#include <QtGui/QGraphicsProxyWidget>
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
    76
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
    77
#include "../shared/util.h"
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
    78
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
    79
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
    80
#ifdef Q_WS_S60
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
    81
#include <avkon.hrh>                // EEikStatusPaneUidTitle
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
    82
#include <akntitle.h>               // CAknTitlePane
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
    83
#include <akncontext.h>             // CAknContextPane
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
    84
#include <eikspane.h>               // CEikStatusPane
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
    85
#include <eikbtgpc.h>               // CEikButtonGroupContainer
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
    86
#endif
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
    87
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
    88
#ifdef Q_WS_QWS
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
    89
# include <qscreen_qws.h>
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
    90
#endif
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
    91
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
    92
// I *MUST* have QtTest afterwards or this test won't work with newer headers
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
    93
#if defined(Q_WS_MAC)
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
    94
# include <private/qt_mac_p.h>
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
    95
#undef verify
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
    96
#include "tst_qwidget_mac_helpers.h"  // Abstract the ObjC stuff out so not everyone must run an ObjC++ compile.
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
    97
#endif
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
    98
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
    99
#include <QtTest/QtTest>
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   100
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   101
#if defined(Q_WS_WIN)
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   102
#  include <qt_windows.h>
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   103
#  if !defined(Q_OS_WINCE)
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   104
#define Q_CHECK_PAINTEVENTS \
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   105
    if (::SwitchDesktop(::GetThreadDesktop(::GetCurrentThreadId())) == 0) \
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   106
        QSKIP("desktop is not visible, this test would fail", SkipSingle);
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   107
#  else
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   108
#    define Q_CHECK_PAINTEVENTS
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   109
#  endif
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   110
#elif defined(Q_WS_X11)
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   111
#  include <private/qt_x11_p.h>
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   112
#  include <qx11info_x11.h>
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   113
#elif defined(Q_WS_QWS)
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   114
# include <qwindowsystem_qws.h>
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   115
#endif
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   116
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   117
#if !defined(Q_WS_WIN)
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   118
#define Q_CHECK_PAINTEVENTS
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   119
#endif
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   120
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   121
#if defined(Bool)
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   122
#undef Bool
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   123
#endif
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   124
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   125
// Will try to wait for the condition while allowing event processing
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   126
// for a maximum of 2 seconds.
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   127
#define WAIT_FOR_CONDITION(expr, expected) \
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   128
    do { \
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   129
        const int step = 100; \
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   130
        for (int i = 0; i < 2000 && expr != expected; i+=step) { \
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   131
            QTest::qWait(step); \
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   132
        } \
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   133
    } while(0)
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   134
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   135
//TESTED_CLASS=
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   136
//TESTED_FILES=
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   137
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   138
class tst_QWidget : public QObject
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   139
{
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   140
    Q_OBJECT
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   141
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   142
public:
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   143
    tst_QWidget();
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   144
    virtual ~tst_QWidget();
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   145
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   146
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   147
public slots:
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   148
    void initTestCase();
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   149
    void cleanupTestCase();
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   150
    void init();
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   151
    void cleanup();
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   152
private slots:
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   153
    void showFullScreen();
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   154
	
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   155
private:
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   156
    bool ensureScreenSize(int width, int height);
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   157
    QWidget *testWidget;
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   158
};
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   159
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   160
tst_QWidget::tst_QWidget()
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   161
{
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   162
    QFont font;
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   163
    font.setBold(true);
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   164
    font.setPointSize(42);
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   165
    qApp->setFont(font, "QPropagationTestWidget");
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   166
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   167
    QPalette palette;
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   168
    palette.setColor(QPalette::ToolTipBase, QColor(12, 13, 14));
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   169
    palette.setColor(QPalette::Text, QColor(21, 22, 23));
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   170
    qApp->setPalette(palette, "QPropagationTestWidget");
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   171
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   172
    testWidget = 0;
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   173
}
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   174
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   175
tst_QWidget::~tst_QWidget()
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   176
{
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   177
}
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   178
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   179
class BezierViewer : public QWidget {
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   180
public:
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   181
    BezierViewer( QWidget* parent=0, const char* name=0 );
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   182
    void paintEvent( QPaintEvent* );
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   183
    void setPoints( const QPolygonF& poly );
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   184
private:
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   185
    QPolygonF points;
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   186
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   187
};
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   188
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   189
void tst_QWidget::initTestCase()
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   190
{
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   191
  // Create the test class
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   192
    testWidget = new BezierViewer( 0, "testObject");
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   193
    testWidget->resize(200,200);
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   194
#ifdef QT3_SUPPORT
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   195
    qApp->setMainWidget(testWidget);
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   196
#endif
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   197
    testWidget->show();
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   198
    QTest::qWaitForWindowShown(testWidget);
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   199
    QTest::qWait(50);
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   200
}
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   201
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   202
void tst_QWidget::cleanupTestCase()
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   203
{
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   204
    delete testWidget;
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   205
    testWidget = 0;
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   206
}
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   207
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   208
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   209
void tst_QWidget::init()
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   210
{
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   211
// TODO: Add initialization code here.
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   212
// This will be executed immediately before each test is run.
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   213
    testWidget->setFont(QFont());
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   214
    testWidget->setPalette(QPalette());
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   215
}
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   216
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   217
void tst_QWidget::cleanup()
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   218
{
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   219
}
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   220
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   221
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   222
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   223
// Helper class...
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   224
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   225
BezierViewer::BezierViewer( QWidget* parent, const char* name )
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   226
	: QWidget( parent )
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   227
{
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   228
    setObjectName(name);
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   229
    QPalette pal;
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   230
    pal.setColor(backgroundRole(), Qt::white);
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   231
    setPalette(pal);
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   232
}
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   233
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   234
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   235
void BezierViewer::setPoints( const QPolygonF& a )
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   236
{
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   237
    points = a;
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   238
}
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   239
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   240
#include "private/qbezier_p.h"
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   241
void BezierViewer::paintEvent( QPaintEvent* )
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   242
{
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   243
    if ( points.size() != 4 ) {
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   244
#if defined(QT_CHECK_RANGE)
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   245
	qWarning( "QPolygon::bezier: The array must have 4 control points" );
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   246
#endif
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   247
	return;
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   248
    }
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   249
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   250
    // Calculate Bezier curve
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   251
    QPolygonF bezier = QBezier::fromPoints(points.at(0),points.at(1),points.at(2),points.at(3)).toPolygon();
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   252
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   253
    QPainter painter( this );
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   254
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   255
    // Calculate scale to fit in window
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   256
    QRectF br = bezier.boundingRect() | points.boundingRect();
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   257
    QRectF pr = rect();
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   258
    int scl = qMax( qMin(pr.width()/br.width(), pr.height()/br.height()), qreal(1.) );
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   259
    int border = scl-1;
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   260
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   261
    // Scale Bezier curve vertices
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   262
    for ( QPolygonF::Iterator it = bezier.begin(); it != bezier.end(); ++it ) {
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   263
	it->setX( (it->x()-br.x()) * scl + border );
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   264
	it->setY( (it->y()-br.y()) * scl + border );
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   265
    }
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   266
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   267
    // Draw grid
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   268
    painter.setPen( Qt::lightGray );
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   269
	int i;
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   270
	for ( i = border; i <= pr.width(); i += scl ) {
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   271
		painter.drawLine( i, 0, i, pr.height() );
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   272
    }
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   273
    for ( int j = border; j <= pr.height(); j += scl ) {
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   274
	painter.drawLine( 0, j, pr.width(), j );
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   275
    }
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   276
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   277
    // Write number of vertices
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   278
    painter.setPen( Qt::red );
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   279
    painter.setFont( QFont("Helvetica", 14, QFont::DemiBold, TRUE ) );
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   280
    QString caption;
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   281
    caption.setNum( bezier.size() );
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   282
    caption += QString::fromLatin1( " vertices" );
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   283
    painter.drawText( 10, pr.height()-10, caption );
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   284
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   285
    // Draw Bezier curve
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   286
    painter.setPen( Qt::black );
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   287
    painter.drawPolyline( bezier );
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   288
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   289
    // Scale and draw control points
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   290
    painter.setPen( Qt::darkGreen );
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   291
    for ( QPolygonF::Iterator p1 = points.begin(); p1 != points.end(); ++p1 ) {
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   292
	int x = (p1->x()-br.x()) * scl + border;
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   293
	int y = (p1->y()-br.y()) * scl + border;
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   294
	painter.drawLine( x-4, y-4, x+4, y+4 );
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   295
	painter.drawLine( x+4, y-4, x-4, y+4 );
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   296
    }
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   297
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   298
    // Draw vertices
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   299
    painter.setPen( Qt::red );
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   300
    painter.setBrush( Qt::red );
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   301
    for ( QPolygonF::Iterator p2 = bezier.begin(); p2 != bezier.end(); ++p2 )
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   302
	painter.drawEllipse( p2->x()-1, p2->y()-1, 3, 3 );
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   303
}
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   304
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   305
void tst_QWidget::showFullScreen()
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   306
{
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   307
    QWidget plain;
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   308
    QHBoxLayout *layout;
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   309
    QWidget layouted;
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   310
    QLineEdit le;
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   311
    QLineEdit le2;
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   312
    QLineEdit le3;
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   313
    layout = new QHBoxLayout;
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   314
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   315
    layout->addWidget(&le);
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   316
    layout->addWidget(&le2);
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   317
    layout->addWidget(&le3);
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   318
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   319
    layouted.setLayout(layout);
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   320
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   321
    plain.showFullScreen();
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   322
    QVERIFY(plain.windowState() & Qt::WindowFullScreen);
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   323
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   324
    plain.showNormal();
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   325
    QVERIFY(!(plain.windowState() & Qt::WindowFullScreen));
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   326
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   327
    layouted.showFullScreen();
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   328
    QVERIFY(layouted.windowState() & Qt::WindowFullScreen);
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   329
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   330
    layouted.showNormal();
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   331
    QVERIFY(!(layouted.windowState() & Qt::WindowFullScreen));
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   332
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   333
#if !defined(Q_WS_QWS) && !defined(Q_OS_WINCE) && !defined (Q_WS_S60)
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   334
//embedded may choose a different size to fit on the screen.
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   335
    QCOMPARE(layouted.size(), layouted.sizeHint());
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   336
#endif
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   337
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   338
    layouted.showFullScreen();
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   339
    QVERIFY(layouted.isFullScreen());
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   340
    QVERIFY(layouted.isVisible());
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   341
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   342
    layouted.hide();
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   343
    QVERIFY(layouted.isFullScreen());
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   344
    QVERIFY(!layouted.isVisible());
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   345
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   346
    layouted.showFullScreen();
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   347
    QVERIFY(layouted.isFullScreen());
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   348
    QVERIFY(layouted.isVisible());
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   349
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   350
    layouted.showMinimized();
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   351
    QVERIFY(layouted.isMinimized());
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   352
    QVERIFY(layouted.isFullScreen());
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   353
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   354
    layouted.showFullScreen();
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   355
    QVERIFY(!layouted.isMinimized());
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   356
    QVERIFY(layouted.isFullScreen());
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   357
    QVERIFY(layouted.isVisible());
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   358
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   359
    layouted.showMinimized();
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   360
    QVERIFY(layouted.isMinimized());
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   361
    QVERIFY(layouted.isFullScreen());
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   362
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   363
    layouted.showFullScreen();
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   364
    QVERIFY(!layouted.isMinimized());
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   365
    QVERIFY(layouted.isFullScreen());
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   366
    QVERIFY(layouted.isVisible());
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   367
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   368
    {
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   369
        QWidget frame;
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   370
        QWidget widget(&frame);
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   371
        widget.showFullScreen();
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   372
        QVERIFY(widget.isFullScreen());
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   373
    }
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   374
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   375
#ifdef QT3_SUPPORT
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   376
#if !defined(Q_WS_QWS)
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   377
//embedded respects max/min sizes by design -- maybe wrong design, but that's the way it is now.
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   378
    {
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   379
        Q3HBox box;
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   380
        QWidget widget(&box);
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   381
        widget.setMinimumSize(500, 500);
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   382
        box.showFullScreen();
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   383
        QVERIFY(box.isFullScreen());
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   384
    }
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   385
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   386
    {
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   387
        Q3HBox box;
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   388
        QWidget widget(&box);
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   389
        widget.setMaximumSize(500, 500);
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   390
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   391
        box.showFullScreen();
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   392
        QVERIFY(box.isFullScreen());
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   393
    }
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   394
#endif
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   395
#endif // QT3_SUPPORT
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   396
}
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   397
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   398
QTEST_MAIN(tst_QWidget)
14fcccfb4c0c Cleaning up the new Qt tests, removing redundant code
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   399
#include "smoke_qwidget.moc"