qt/qapplication/smoketest_qapplication.cpp
author Brendan Donegan <brendand@symbian.org>
Fri, 11 Jun 2010 11:40:57 +0100
branchSymbian3
changeset 41 72f7e4177ac7
permissions -rw-r--r--
Smoketest for Qt: Gestures and QApplication
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
41
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
     1
/****************************************************************************
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
     2
**
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
     3
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
     4
** All rights reserved.
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
     5
** Contact: Nokia Corporation (qt-info@nokia.com)
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
     6
**
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
     7
** This file is part of the test suite of the Qt Toolkit.
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
     8
**
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
     9
** $QT_BEGIN_LICENSE:LGPL$
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
    10
** No Commercial Usage
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
    11
** This file contains pre-release code and may not be distributed.
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
    12
** You may use this file in accordance with the terms and conditions
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
    13
** contained in the Technology Preview License Agreement accompanying
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
    14
** this package.
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
    15
**
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
    16
** GNU Lesser General Public License Usage
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
    17
** Alternatively, this file may be used under the terms of the GNU Lesser
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
    18
** General Public License version 2.1 as published by the Free Software
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
    19
** Foundation and appearing in the file LICENSE.LGPL included in the
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
    20
** packaging of this file.  Please review the following information to
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
    21
** ensure the GNU Lesser General Public License version 2.1 requirements
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
    22
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
    23
**
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
    24
** In addition, as a special exception, Nokia gives you certain additional
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
    25
** rights.  These rights are described in the Nokia Qt LGPL Exception
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
    26
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
    27
**
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
    28
** If you have questions regarding the use of this file, please contact
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
    29
** Nokia at qt-info@nokia.com.
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
    30
**
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
    31
**
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
    32
**
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
    33
**
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
    34
**
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
    35
**
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
    36
**
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
    37
**
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
    38
** $QT_END_LICENSE$
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
    39
**
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
    40
****************************************************************************/
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
    41
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
    42
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
    43
//#define QT_TST_QAPP_DEBUG
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
    44
#include <qdebug.h>
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
    45
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
    46
#include <QtTest/QtTest>
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
    47
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
    48
#include "qabstracteventdispatcher.h"
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
    49
#include <QtGui>
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
    50
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
    51
#include "private/qapplication_p.h"
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
    52
#include "private/qstylesheetstyle_p.h"
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
    53
#ifdef Q_OS_WINCE
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
    54
#include <windows.h>
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
    55
#endif
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
    56
#ifdef Q_OS_SYMBIAN
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
    57
#include <aknenv.h>
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
    58
#endif
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
    59
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
    60
//TESTED_CLASS=
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
    61
//TESTED_FILES=
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
    62
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
    63
#if defined(Q_OS_SYMBIAN)
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
    64
// In Symbian, the PluginsPath doesn't specify the only absolute path; just the dir that can be found on any drive
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
    65
/*static void addExpectedSymbianPluginsPath(QStringList& expected)
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
    66
{
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
    67
    QString installPathPlugins = QDir::fromNativeSeparators(QLibraryInfo::location(QLibraryInfo::PluginsPath));
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
    68
    QFileInfoList driveList = QDir::drives();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
    69
    QListIterator<QFileInfo> iter(driveList);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
    70
    while (iter.hasNext()) {
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
    71
        QFileInfo testFi(iter.next().canonicalPath().append(installPathPlugins));
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
    72
        if (testFi.exists())
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
    73
            expected << testFi.canonicalFilePath();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
    74
    }
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
    75
}
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
    76
*/
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
    77
#endif
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
    78
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
    79
class tst_QApplication : public QObject
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
    80
{
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
    81
Q_OBJECT
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
    82
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
    83
public:
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
    84
    tst_QApplication();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
    85
    virtual ~tst_QApplication();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
    86
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
    87
public slots:
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
    88
    void init();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
    89
    void cleanup();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
    90
private slots:
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
    91
    /*void sendEventsOnProcessEvents(); // this must be the first test
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
    92
    void getSetCheck();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
    93
    void staticSetup();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
    94
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
    95
    void alert();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
    96
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
    97
    void multiple_data();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
    98
    void multiple();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
    99
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   100
    void nonGui();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   101
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   102
    void setFont_data();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   103
    void setFont();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   104
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   105
    void args_data();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   106
    void args();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   107
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   108
    void lastWindowClosed();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   109
    void quitOnLastWindowClosed();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   110
    void testDeleteLater();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   111
    void testDeleteLaterProcessEvents();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   112
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   113
    void libraryPaths();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   114
    void libraryPaths_qt_plugin_path();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   115
    void libraryPaths_qt_plugin_path_2();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   116
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   117
    void sendPostedEvents();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   118
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   119
    void thread();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   120
    void desktopSettingsAware();*/
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   121
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   122
    void setActiveWindow();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   123
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   124
    /*void focusChanged();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   125
    void focusOut();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   126
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   127
    void execAfterExit();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   128
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   129
    void wheelScrollLines();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   130
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   131
    void task109149();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   132
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   133
    void style();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   134
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   135
    void allWidgets();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   136
    void topLevelWidgets();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   137
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   138
    void setAttribute();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   139
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   140
    void windowsCommandLine_data();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   141
    void windowsCommandLine();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   142
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   143
    void touchEventPropagation();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   144
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   145
    void symbianNoApplicationPanes();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   146
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   147
    void symbianNeedForTraps();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   148
    void symbianLeaveThroughMain();*/
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   149
};
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   150
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   151
/*class EventSpy : public QObject
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   152
{
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   153
   Q_OBJECT
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   154
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   155
public:
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   156
    QList<int> recordedEvents;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   157
    bool eventFilter(QObject *, QEvent *event)
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   158
    {
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   159
        recordedEvents.append(event->type());
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   160
        return false;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   161
    }
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   162
};
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   163
*/
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   164
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   165
/*
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   166
void tst_QApplication::sendEventsOnProcessEvents()
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   167
{
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   168
    int argc = 0;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   169
    QApplication app(argc, 0, QApplication::GuiServer);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   170
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   171
    EventSpy spy;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   172
    app.installEventFilter(&spy);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   173
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   174
    QCoreApplication::postEvent(&app,  new QEvent(QEvent::Type(QEvent::User + 1)));
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   175
    QCoreApplication::processEvents();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   176
    QVERIFY(spy.recordedEvents.contains(QEvent::User + 1));
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   177
}
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   178
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   179
class MyInputContext : public QInputContext
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   180
{
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   181
public:
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   182
    MyInputContext() : QInputContext() {}
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   183
    QString identifierName() { return QString("NoName"); }
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   184
    QString language() { return QString("NoLanguage"); }
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   185
    void reset() {}
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   186
    bool isComposing() const { return false; }
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   187
};
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   188
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   189
// Testing get/set functions
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   190
void tst_QApplication::getSetCheck()
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   191
{
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   192
    int argc = 0;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   193
    QApplication obj1(argc, 0, QApplication::GuiServer);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   194
    // QInputContext * QApplication::inputContext()
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   195
    // void QApplication::setInputContext(QInputContext *)
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   196
    MyInputContext *var1 = new MyInputContext;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   197
    obj1.setInputContext(var1);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   198
    QCOMPARE((QInputContext *)var1, obj1.inputContext());
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   199
    QTest::ignoreMessage(QtWarningMsg, "QApplication::setInputContext: called with 0 input context");
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   200
    obj1.setInputContext((QInputContext *)0);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   201
    QCOMPARE((QInputContext *)var1, obj1.inputContext());
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   202
    // delete var1; // No delete, since QApplication takes ownership
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   203
}
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   204
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   205
class CloseEventTestWindow : public QWidget
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   206
{
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   207
public:
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   208
    CloseEventTestWindow(QWidget *parent = 0)
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   209
        : QWidget(parent)
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   210
    {
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   211
    }
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   212
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   213
    void closeEvent(QCloseEvent *event)
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   214
    {
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   215
        QWidget dialog;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   216
        dialog.show();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   217
        dialog.close();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   218
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   219
        hide();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   220
        event->ignore();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   221
    }
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   222
};
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   223
*/
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   224
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   225
static  char *argv0;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   226
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   227
tst_QApplication::tst_QApplication()
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   228
{
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   229
#ifdef Q_OS_WINCE
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   230
    // Clean up environment previously to launching test
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   231
    qputenv("QT_PLUGIN_PATH", QByteArray());
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   232
#endif
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   233
}
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   234
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   235
tst_QApplication::~tst_QApplication()
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   236
{
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   237
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   238
}
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   239
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   240
void tst_QApplication::init()
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   241
{
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   242
// TODO: Add initialization code here.
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   243
// This will be executed immediately before each test is run.
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   244
}
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   245
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   246
void tst_QApplication::cleanup()
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   247
{
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   248
// TODO: Add cleanup code here.
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   249
// This will be executed immediately after each test is run.
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   250
}
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   251
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   252
/*
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   253
void tst_QApplication::staticSetup()
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   254
{
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   255
    QVERIFY(!qApp);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   256
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   257
    QStyle *style = QStyleFactory::create(QLatin1String("Windows"));
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   258
    QVERIFY(style);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   259
    QApplication::setStyle(style);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   260
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   261
    QPalette pal;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   262
    QApplication::setPalette(pal);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   263
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   264
    //QFont font;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   265
    //QApplication::setFont(font);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   266
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   267
    int argc = 0;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   268
    QApplication app(argc, 0, QApplication::GuiServer);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   269
}
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   270
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   271
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   272
// QApp subclass that exits the event loop after 150ms
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   273
class TestApplication : public QApplication
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   274
{
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   275
public:
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   276
    TestApplication( int &argc, char **argv )
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   277
	: QApplication( argc, argv, QApplication::GuiServer )
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   278
    {
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   279
	startTimer( 150 );
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   280
    }
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   281
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   282
    void timerEvent( QTimerEvent * )
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   283
    {
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   284
        quit();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   285
    }
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   286
};
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   287
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   288
void tst_QApplication::alert()
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   289
{
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   290
    int argc = 0;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   291
    QApplication app(argc, 0, QApplication::GuiServer);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   292
    app.alert(0, 0);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   293
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   294
    QWidget widget;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   295
    QWidget widget2;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   296
    app.alert(&widget, 100);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   297
    widget.show();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   298
    widget2.show();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   299
#ifdef Q_WS_X11
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   300
    qt_x11_wait_for_window_manager(&widget);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   301
    qt_x11_wait_for_window_manager(&widget2);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   302
#endif
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   303
    QTest::qWait(100);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   304
    app.alert(&widget, -1);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   305
    app.alert(&widget, 250);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   306
    widget2.activateWindow();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   307
    QApplication::setActiveWindow(&widget2);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   308
    app.alert(&widget, 0);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   309
    widget.activateWindow();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   310
    QApplication::setActiveWindow(&widget);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   311
    app.alert(&widget, 200);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   312
    app.syncX();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   313
}
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   314
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   315
void tst_QApplication::multiple_data()
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   316
{
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   317
    QTest::addColumn<QStringList>("features");
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   318
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   319
    // return a list of things to try
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   320
    QTest::newRow( "data0" ) << QStringList( "" );
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   321
    QTest::newRow( "data1" ) << QStringList( "QFont" );
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   322
    QTest::newRow( "data2" ) << QStringList( "QPixmap" );
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   323
    QTest::newRow( "data3" ) << QStringList( "QWidget" );
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   324
}
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   325
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   326
void tst_QApplication::multiple()
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   327
{
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   328
    QFETCH(QStringList,features);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   329
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   330
    int i = 0;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   331
    int argc = 0;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   332
    while ( i++ < 5 ) {
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   333
	TestApplication app( argc, 0 );
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   334
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   335
	if ( features.contains( "QFont" ) ) {
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   336
	    // create font and force loading
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   337
	    QFont font( "Arial", 12 );
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   338
	    QFontInfo finfo( font );
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   339
	    finfo.exactMatch();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   340
	}
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   341
	if ( features.contains( "QPixmap" ) ) {
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   342
	    QPixmap pix( 100, 100 );
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   343
	    pix.fill( Qt::black );
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   344
	}
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   345
	if ( features.contains( "QWidget" ) ) {
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   346
	    QWidget widget;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   347
	}
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   348
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   349
	QVERIFY(!app.exec());
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   350
    }
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   351
}
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   352
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   353
void tst_QApplication::nonGui()
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   354
{
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   355
#ifdef Q_OS_HPUX
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   356
    // ### This is only to allow us to generate a test report for now.
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   357
    QSKIP("This test shuts down the window manager on HP-UX.", SkipAll);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   358
#endif
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   359
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   360
    int argc = 0;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   361
    QApplication app(argc, 0, false);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   362
    QCOMPARE(qApp, &app);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   363
}
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   364
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   365
void tst_QApplication::setFont_data()
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   366
{
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   367
    QTest::addColumn<QString>("family");
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   368
    QTest::addColumn<int>("pointsize");
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   369
    QTest::addColumn<bool>("beforeAppConstructor");
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   370
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   371
    int argc = 0;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   372
    QApplication app(argc, 0, QApplication::GuiServer); // Needed for QFontDatabase
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   373
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   374
    int cnt = 0;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   375
    QFontDatabase fdb;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   376
    QStringList families = fdb.families();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   377
    for (QStringList::const_iterator itr = families.begin();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   378
	 itr != families.end();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   379
	 ++itr) {
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   380
	if (cnt < 3) {
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   381
	    QString family = *itr;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   382
	    QStringList styles = fdb.styles(family);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   383
	    if (styles.size() > 0) {
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   384
		QString style = styles.first();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   385
		QList<int> sizes = fdb.pointSizes(family, style);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   386
		if (!sizes.size())
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   387
		    sizes = fdb.standardSizes();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   388
		if (sizes.size() > 0) {
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   389
		    QTest::newRow(QString("data%1a").arg(cnt).toLatin1().constData())
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   390
			<< family
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   391
			<< sizes.first()
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   392
                        << false;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   393
		    QTest::newRow(QString("data%1b").arg(cnt).toLatin1().constData())
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   394
			<< family
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   395
			<< sizes.first()
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   396
                        << true;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   397
                }
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   398
	    }
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   399
	}
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   400
	++cnt;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   401
    }
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   402
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   403
    QTest::newRow("nonexistingfont") << "nosuchfont_probably_quiteunlikely"
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   404
        << 0 << false;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   405
    QTest::newRow("nonexistingfont") << "nosuchfont_probably_quiteunlikely"
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   406
        << 0 << true;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   407
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   408
    QTest::newRow("largescaleable") << "smoothtimes" << 100 << false;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   409
    QTest::newRow("largescaleable") << "smoothtimes" << 100 << true;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   410
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   411
    QTest::newRow("largeunscaleale") << "helvetica" << 100 << false;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   412
    QTest::newRow("largeunscaleale") << "helvetica" << 100 << true;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   413
}
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   414
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   415
void tst_QApplication::setFont()
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   416
{
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   417
    QFETCH( QString, family );
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   418
    QFETCH( int, pointsize );
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   419
    QFETCH( bool, beforeAppConstructor );
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   420
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   421
    QFont font( family, pointsize );
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   422
    if (beforeAppConstructor) {
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   423
        QApplication::setFont( font );
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   424
        QCOMPARE(QApplication::font(), font);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   425
    }
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   426
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   427
    int argc = 0;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   428
    QApplication app( argc, 0, QApplication::GuiServer );
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   429
    if (!beforeAppConstructor)
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   430
        QApplication::setFont( font );
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   431
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   432
    QCOMPARE( app.font(), font );
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   433
}
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   434
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   435
void tst_QApplication::args_data()
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   436
{
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   437
    QTest::addColumn<int>("argc_in");
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   438
    QTest::addColumn<QString>("args_in");
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   439
    QTest::addColumn<int>("argc_out");
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   440
    QTest::addColumn<QString>("args_out");
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   441
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   442
    QTest::newRow( "App name" ) << 1 << "/usr/bin/appname" << 1 << "/usr/bin/appname";
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   443
    QTest::newRow( "No arguments" ) << 0 << QString() << 0 << QString();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   444
    QTest::newRow( "App name, style" ) << 3 << "/usr/bin/appname -style motif" << 1 << "/usr/bin/appname";
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   445
    QTest::newRow( "App name, style, arbitrary, reverse" ) << 5 << "/usr/bin/appname -style motif -arbitrary -reverse"
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   446
							<< 2 << "/usr/bin/appname -arbitrary";
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   447
}
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   448
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   449
void tst_QApplication::task109149()
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   450
{
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   451
    int argc = 0;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   452
    QApplication app(argc, 0, QApplication::GuiServer);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   453
    QApplication::setFont(QFont("helvetica", 100));
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   454
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   455
    QWidget w;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   456
    w.setWindowTitle("hello");
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   457
    w.show();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   458
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   459
    app.processEvents();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   460
}
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   461
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   462
static char ** QString2cstrings( const QString &args )
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   463
{
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   464
    static QList<QByteArray> cache;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   465
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   466
    int i;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   467
    char **argarray = 0;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   468
    QStringList list = args.split(' ');;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   469
    argarray = new char*[list.count()+1];
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   470
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   471
    for (i = 0; i < (int)list.count(); ++i ) {
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   472
        QByteArray l1 = list[i].toLatin1();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   473
        argarray[i] = l1.data();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   474
        cache.append(l1);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   475
    }
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   476
    argarray[i] = 0;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   477
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   478
    return argarray;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   479
}
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   480
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   481
static QString cstrings2QString( char **args )
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   482
{
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   483
    QString string;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   484
    if ( !args )
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   485
	return string;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   486
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   487
    int i = 0;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   488
    while ( args[i] ) {
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   489
	string += args[i];
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   490
	if ( args[i+1] )
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   491
	    string += " ";
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   492
	++i;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   493
    }
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   494
    return string;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   495
}
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   496
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   497
void tst_QApplication::args()
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   498
{
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   499
    QFETCH( int, argc_in );
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   500
    QFETCH( QString, args_in );
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   501
    QFETCH( int, argc_out );
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   502
    QFETCH( QString, args_out );
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   503
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   504
    char **argv = QString2cstrings( args_in );
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   505
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   506
    QApplication app( argc_in, argv, QApplication::GuiServer );
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   507
    QString argv_out = cstrings2QString(argv);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   508
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   509
    QCOMPARE( argc_in, argc_out );
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   510
    QCOMPARE( argv_out, args_out );
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   511
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   512
    delete [] argv;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   513
}
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   514
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   515
class CloseWidget : public QWidget
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   516
{
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   517
    Q_OBJECT
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   518
public:
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   519
    CloseWidget()
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   520
    {
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   521
        startTimer(500);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   522
    }
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   523
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   524
protected:
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   525
    void timerEvent(QTimerEvent *)
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   526
    {
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   527
        close();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   528
    }
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   529
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   530
};
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   531
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   532
void tst_QApplication::lastWindowClosed()
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   533
{
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   534
    int argc = 0;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   535
    QApplication app(argc, 0, QApplication::GuiServer);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   536
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   537
    QSignalSpy spy(&app, SIGNAL(lastWindowClosed()));
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   538
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   539
    QPointer<QDialog> dialog = new QDialog;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   540
    QVERIFY(dialog->testAttribute(Qt::WA_QuitOnClose));
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   541
    QTimer::singleShot(1000, dialog, SLOT(accept()));
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   542
    dialog->exec();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   543
    QVERIFY(dialog);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   544
    QCOMPARE(spy.count(), 0);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   545
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   546
    QPointer<CloseWidget>widget = new CloseWidget;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   547
    QVERIFY(widget->testAttribute(Qt::WA_QuitOnClose));
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   548
    QObject::connect(&app, SIGNAL(lastWindowClosed()), widget, SLOT(deleteLater()));
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   549
    app.exec();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   550
    QVERIFY(!widget);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   551
    QCOMPARE(spy.count(), 1);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   552
    spy.clear();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   553
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   554
#if 0
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   555
    // everything is closed, so doing this should not emit lastWindowClosed() again
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   556
    QMetaObject::invokeMethod(dialog, "close", Qt::QueuedConnection);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   557
    QTimer::singleShot(1000, &app, SLOT(quit()));
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   558
    app.exec();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   559
    QCOMPARE(spy.count(), 0);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   560
#endif
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   561
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   562
    delete dialog;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   563
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   564
    // show 3 windows, close them, should only get lastWindowClosed once
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   565
    QWidget w1;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   566
    QWidget w2;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   567
    QWidget w3;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   568
    w1.show();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   569
    w2.show();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   570
    w3.show();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   571
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   572
    QTimer::singleShot(1000, &app, SLOT(closeAllWindows()));
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   573
    app.exec();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   574
    QCOMPARE(spy.count(), 1);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   575
}
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   576
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   577
class QuitOnLastWindowClosedDialog : public QDialog
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   578
{
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   579
    Q_OBJECT
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   580
public:
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   581
    QPushButton *okButton;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   582
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   583
    QuitOnLastWindowClosedDialog()
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   584
    {
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   585
        QHBoxLayout *hbox = new QHBoxLayout(this);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   586
        okButton = new QPushButton("&ok", this);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   587
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   588
        hbox->addWidget(okButton);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   589
        connect(okButton, SIGNAL(clicked()), this, SLOT(accept()));
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   590
        connect(okButton, SIGNAL(clicked()), this, SLOT(ok_clicked()));
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   591
    }
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   592
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   593
public slots:
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   594
    void ok_clicked()
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   595
    {
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   596
        QDialog other;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   597
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   598
        QTimer timer;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   599
        connect(&timer, SIGNAL(timeout()), &other, SLOT(accept()));
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   600
        QSignalSpy spy(&timer, SIGNAL(timeout()));
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   601
        QSignalSpy appSpy(qApp, SIGNAL(lastWindowClosed()));
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   602
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   603
        timer.start(1000);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   604
        other.exec();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   605
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   606
        // verify that the eventloop ran and let the timer fire
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   607
        QCOMPARE(spy.count(), 1);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   608
        QCOMPARE(appSpy.count(), 1);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   609
    }
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   610
};
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   611
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   612
class QuitOnLastWindowClosedWindow : public QWidget
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   613
{
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   614
    Q_OBJECT
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   615
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   616
public:
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   617
    QuitOnLastWindowClosedWindow()
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   618
    { }
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   619
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   620
public slots:
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   621
    void execDialogThenShow()
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   622
    {
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   623
        QDialog dialog;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   624
        QTimer timer1;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   625
        connect(&timer1, SIGNAL(timeout()), &dialog, SLOT(accept()));
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   626
        QSignalSpy spy1(&timer1, SIGNAL(timeout()));
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   627
        timer1.setSingleShot(true);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   628
        timer1.start(1000);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   629
        dialog.exec();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   630
        QCOMPARE(spy1.count(), 1);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   631
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   632
        show();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   633
    }
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   634
};
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   635
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   636
void tst_QApplication::quitOnLastWindowClosed()
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   637
{
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   638
    {
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   639
        int argc = 0;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   640
        QApplication app(argc, 0, QApplication::GuiServer);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   641
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   642
        QuitOnLastWindowClosedDialog d;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   643
        d.show();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   644
        QTimer::singleShot(1000, d.okButton, SLOT(animateClick()));
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   645
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   646
        QSignalSpy appSpy(&app, SIGNAL(lastWindowClosed()));
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   647
        app.exec();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   648
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   649
        // lastWindowClosed() signal should only be sent after the last dialog is closed
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   650
        QCOMPARE(appSpy.count(), 2);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   651
    }
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   652
    {
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   653
        int argc = 0;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   654
        QApplication app(argc, 0, QApplication::GuiServer);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   655
        QSignalSpy appSpy(&app, SIGNAL(lastWindowClosed()));
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   656
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   657
        QDialog dialog;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   658
        QTimer timer1;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   659
        connect(&timer1, SIGNAL(timeout()), &dialog, SLOT(accept()));
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   660
        QSignalSpy spy1(&timer1, SIGNAL(timeout()));
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   661
        timer1.setSingleShot(true);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   662
        timer1.start(1000);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   663
        dialog.exec();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   664
        QCOMPARE(spy1.count(), 1);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   665
        QCOMPARE(appSpy.count(), 0);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   666
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   667
        QTimer timer2;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   668
        connect(&timer2, SIGNAL(timeout()), &app, SLOT(quit()));
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   669
        QSignalSpy spy2(&timer2, SIGNAL(timeout()));
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   670
        timer2.setSingleShot(true);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   671
        timer2.start(1000);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   672
        int returnValue = app.exec();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   673
        QCOMPARE(returnValue, 0);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   674
        QCOMPARE(spy2.count(), 1);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   675
        QCOMPARE(appSpy.count(), 0);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   676
    }
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   677
    {
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   678
        int argc = 0;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   679
        QApplication app(argc, 0, QApplication::GuiServer);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   680
        QTimer timer;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   681
        timer.setInterval(100);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   682
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   683
        QSignalSpy spy(&app, SIGNAL(aboutToQuit()));
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   684
        QSignalSpy spy2(&timer, SIGNAL(timeout()));
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   685
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   686
        QPointer<QMainWindow> mainWindow = new QMainWindow;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   687
        QPointer<QDialog> dialog = new QDialog(mainWindow);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   688
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   689
        QVERIFY(app.quitOnLastWindowClosed());
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   690
        QVERIFY(mainWindow->testAttribute(Qt::WA_QuitOnClose));
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   691
        QVERIFY(dialog->testAttribute(Qt::WA_QuitOnClose));
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   692
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   693
        mainWindow->show();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   694
        dialog->show();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   695
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   696
        timer.start();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   697
        QTimer::singleShot(1000, mainWindow, SLOT(close())); // This should quit the application
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   698
        QTimer::singleShot(2000, &app, SLOT(quit()));        // This makes sure we quit even if it didn't
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   699
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   700
        app.exec();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   701
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   702
        QCOMPARE(spy.count(), 1);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   703
        QVERIFY(spy2.count() < 15);      // Should be around 10 if closing caused the quit
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   704
    }
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   705
    {
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   706
        int argc = 0;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   707
        QApplication app(argc, 0, QApplication::GuiServer);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   708
        QTimer timer;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   709
        timer.setInterval(100);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   710
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   711
        QSignalSpy spy(&app, SIGNAL(aboutToQuit()));
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   712
        QSignalSpy spy2(&timer, SIGNAL(timeout()));
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   713
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   714
        QPointer<QMainWindow> mainWindow = new QMainWindow;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   715
        QPointer<QWidget> invisibleTopLevelWidget = new QWidget;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   716
        invisibleTopLevelWidget->setAttribute(Qt::WA_DontShowOnScreen);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   717
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   718
        QVERIFY(app.quitOnLastWindowClosed());
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   719
        QVERIFY(mainWindow->testAttribute(Qt::WA_QuitOnClose));
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   720
        QVERIFY(invisibleTopLevelWidget->testAttribute(Qt::WA_QuitOnClose));
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   721
        QVERIFY(invisibleTopLevelWidget->testAttribute(Qt::WA_DontShowOnScreen));
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   722
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   723
        mainWindow->show();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   724
        invisibleTopLevelWidget->show();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   725
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   726
        timer.start();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   727
        QTimer::singleShot(1000, mainWindow, SLOT(close())); // This should quit the application
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   728
        QTimer::singleShot(2000, &app, SLOT(quit()));        // This makes sure we quit even if it didn't
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   729
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   730
        app.exec();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   731
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   732
        QCOMPARE(spy.count(), 1);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   733
        QVERIFY(spy2.count() < 15);      // Should be around 10 if closing caused the quit
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   734
    }
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   735
    {
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   736
        int argc = 0;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   737
        QApplication app(argc, 0, QApplication::GuiServer);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   738
        QTimer timer;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   739
        timer.setInterval(100);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   740
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   741
        QSignalSpy spy(&app, SIGNAL(aboutToQuit()));
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   742
        QSignalSpy spy2(&timer, SIGNAL(timeout()));
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   743
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   744
        QPointer<CloseEventTestWindow> mainWindow = new CloseEventTestWindow;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   745
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   746
        QVERIFY(app.quitOnLastWindowClosed());
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   747
        QVERIFY(mainWindow->testAttribute(Qt::WA_QuitOnClose));
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   748
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   749
        mainWindow->show();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   750
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   751
        timer.start();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   752
        QTimer::singleShot(1000, mainWindow, SLOT(close())); // This should quit the application
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   753
        QTimer::singleShot(2000, &app, SLOT(quit()));        // This makes sure we quit even if it didn't
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   754
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   755
        app.exec();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   756
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   757
        QCOMPARE(spy.count(), 1);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   758
        QVERIFY(spy2.count() > 15);      // Should be around 20 if closing did not caused the quit
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   759
    }
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   760
    {
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   761
        int argc = 0;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   762
        QApplication app(argc, 0, QApplication::GuiServer);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   763
        QSignalSpy appSpy(&app, SIGNAL(lastWindowClosed()));
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   764
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   765
        // exec a dialog for 1 second, then show the window
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   766
        QuitOnLastWindowClosedWindow window;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   767
        QTimer::singleShot(0, &window, SLOT(execDialogThenShow()));
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   768
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   769
        QTimer timer;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   770
        QSignalSpy timerSpy(&timer, SIGNAL(timeout()));
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   771
        connect(&timer, SIGNAL(timeout()), &window, SLOT(close()));
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   772
        timer.setSingleShot(true);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   773
        timer.start(2000);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   774
        int returnValue = app.exec();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   775
        QCOMPARE(returnValue, 0);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   776
        // failure here means the timer above didn't fire, and the
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   777
        // quit was caused the the dialog being closed (not the window)
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   778
        QCOMPARE(timerSpy.count(), 1);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   779
        QCOMPARE(appSpy.count(), 2);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   780
    }
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   781
}
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   782
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   783
bool isPathListIncluded(const QStringList &l, const QStringList &r)
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   784
{
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   785
    int size = r.count();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   786
    if (size > l.count())
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   787
        return false;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   788
#if defined (Q_OS_WIN)
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   789
    Qt::CaseSensitivity cs = Qt::CaseInsensitive;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   790
#else
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   791
    Qt::CaseSensitivity cs = Qt::CaseSensitive;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   792
#endif
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   793
    int i = 0, j = 0;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   794
    for ( ; i < l.count() && j < r.count(); ++i) {
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   795
        if (QDir::toNativeSeparators(l[i]).compare(QDir::toNativeSeparators(r[j]), cs) == 0) {
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   796
            ++j;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   797
            i = -1;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   798
        }
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   799
    }
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   800
    return j == r.count();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   801
}
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   802
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   803
#define QT_TST_QAPP_DEBUG
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   804
void tst_QApplication::libraryPaths()
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   805
{
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   806
    {
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   807
#ifndef Q_OS_WINCE
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   808
        QString testDir = QDir::current().canonicalPath() + "/test";
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   809
#else
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   810
        // On Windows CE we need QApplication object to have valid
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   811
        // current Path. Therefore we need to identify it ourselves
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   812
        // here for the test.
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   813
        QFileInfo filePath;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   814
        wchar_t module_name[MAX_PATH];
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   815
        GetModuleFileName(0, module_name, MAX_PATH);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   816
        filePath = QString::fromWCharArray(module_name);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   817
        QString testDir = filePath.path() + "/test";
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   818
#endif
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   819
        QApplication::setLibraryPaths(QStringList() << testDir);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   820
        QCOMPARE(QApplication::libraryPaths(), (QStringList() << testDir));
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   821
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   822
        // creating QApplication adds the applicationDirPath to the libraryPath
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   823
        int argc = 1;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   824
        QApplication app(argc, &argv0, QApplication::GuiServer);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   825
        QString appDirPath = QDir(app.applicationDirPath()).canonicalPath();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   826
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   827
        QStringList actual = QApplication::libraryPaths();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   828
        actual.sort();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   829
        QStringList expected = QSet<QString>::fromList((QStringList() << testDir << appDirPath)).toList();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   830
        expected.sort();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   831
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   832
        QVERIFY2(isPathListIncluded(actual, expected),
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   833
                 qPrintable("actual:\n - " + actual.join("\n - ") +
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   834
                            "\nexpected:\n - " + expected.join("\n - ")));
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   835
    }
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   836
    {
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   837
        // creating QApplication adds the applicationDirPath and plugin install path to the libraryPath
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   838
        int argc = 1;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   839
        QApplication app(argc, &argv0, QApplication::GuiServer);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   840
        QString appDirPath = app.applicationDirPath();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   841
        QString installPathPlugins =  QLibraryInfo::location(QLibraryInfo::PluginsPath);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   842
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   843
        QStringList actual = QApplication::libraryPaths();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   844
        actual.sort();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   845
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   846
#if defined(Q_OS_SYMBIAN)
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   847
        QStringList expected;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   848
        addExpectedSymbianPluginsPath(expected);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   849
        expected << appDirPath;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   850
#else
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   851
        QStringList expected = QSet<QString>::fromList((QStringList() << installPathPlugins << appDirPath)).toList();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   852
#endif
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   853
        expected.sort();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   854
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   855
        QVERIFY2(isPathListIncluded(actual, expected),
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   856
                 qPrintable("actual:\n - " + actual.join("\n - ") +
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   857
                            "\nexpected:\n - " + expected.join("\n - ")));
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   858
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   859
        // setting the library paths overrides everything
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   860
        QString testDir = QDir::currentPath() + "/test";
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   861
        QApplication::setLibraryPaths(QStringList() << testDir);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   862
        QVERIFY2(isPathListIncluded(QApplication::libraryPaths(), (QStringList() << testDir)),
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   863
                 qPrintable("actual:\n - " + QApplication::libraryPaths().join("\n - ") +
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   864
                            "\nexpected:\n - " + testDir));
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   865
    }
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   866
    {
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   867
#ifdef QT_TST_QAPP_DEBUG
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   868
        qDebug() << "Initial library path:" << QApplication::libraryPaths();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   869
#endif
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   870
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   871
        int count = QApplication::libraryPaths().count();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   872
#if 0
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   873
        // this test doesn't work if KDE 4 is installed
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   874
        QCOMPARE(count, 1); // before creating QApplication, only the PluginsPath is in the libraryPaths()
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   875
#endif
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   876
        QString installPathPlugins =  QLibraryInfo::location(QLibraryInfo::PluginsPath);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   877
        QApplication::addLibraryPath(installPathPlugins);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   878
#ifdef QT_TST_QAPP_DEBUG
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   879
        qDebug() << "installPathPlugins" << installPathPlugins;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   880
        qDebug() << "After adding plugins path:" << QApplication::libraryPaths();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   881
#endif
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   882
        QCOMPARE(QApplication::libraryPaths().count(), count);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   883
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   884
        QApplication::addLibraryPath(QDir::currentPath() + "/test");
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   885
        QCOMPARE(QApplication::libraryPaths().count(), count + 1);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   886
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   887
        // creating QApplication adds the applicationDirPath to the libraryPath
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   888
        int argc = 1;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   889
        QApplication app(argc, &argv0, QApplication::GuiServer);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   890
        QString appDirPath = app.applicationDirPath();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   891
        qDebug() << QApplication::libraryPaths();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   892
        // On Windows CE these are identical and might also be the case for other
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   893
        // systems too
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   894
        if (appDirPath != installPathPlugins)
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   895
            QCOMPARE(QApplication::libraryPaths().count(), count + 2);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   896
    }
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   897
    {
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   898
        int argc = 1;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   899
        QApplication app(argc, &argv0, QApplication::GuiServer);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   900
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   901
#ifdef QT_TST_QAPP_DEBUG
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   902
        qDebug() << "Initial library path:" << app.libraryPaths();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   903
#endif
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   904
        int count = app.libraryPaths().count();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   905
        QString installPathPlugins =  QLibraryInfo::location(QLibraryInfo::PluginsPath);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   906
        app.addLibraryPath(installPathPlugins);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   907
#ifdef QT_TST_QAPP_DEBUG
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   908
        qDebug() << "installPathPlugins" << installPathPlugins;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   909
        qDebug() << "After adding plugins path:" << app.libraryPaths();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   910
#endif
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   911
        QCOMPARE(app.libraryPaths().count(), count);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   912
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   913
        QString appDirPath = app.applicationDirPath();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   914
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   915
        app.addLibraryPath(appDirPath);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   916
#ifdef Q_OS_WINCE
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   917
        app.addLibraryPath(appDirPath + "/../..");
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   918
#else
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   919
        app.addLibraryPath(appDirPath + "/..");
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   920
#endif
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   921
#ifdef QT_TST_QAPP_DEBUG
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   922
        qDebug() << "appDirPath" << appDirPath;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   923
        qDebug() << "After adding appDirPath && appDirPath + /..:" << app.libraryPaths();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   924
#endif
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   925
        QCOMPARE(app.libraryPaths().count(), count + 1);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   926
#ifdef Q_OS_MAC
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   927
        app.addLibraryPath(appDirPath + "/../MacOS");
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   928
#else
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   929
        app.addLibraryPath(appDirPath + "/tmp/..");
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   930
#endif
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   931
#ifdef QT_TST_QAPP_DEBUG
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   932
        qDebug() << "After adding appDirPath + /tmp/..:" << app.libraryPaths();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   933
#endif
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   934
        QCOMPARE(app.libraryPaths().count(), count + 1);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   935
    }
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   936
}
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   937
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   938
void tst_QApplication::libraryPaths_qt_plugin_path()
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   939
{
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   940
    int argc = 1;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   941
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   942
    QApplication app(argc, &argv0, QApplication::GuiServer);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   943
    QString appDirPath = app.applicationDirPath();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   944
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   945
    // Our hook into libraryPaths() initialization: Set the QT_PLUGIN_PATH environment variable
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   946
    QString installPathPluginsDeCanon = appDirPath + QString::fromLatin1("/tmp/..");
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   947
    QByteArray ascii = installPathPluginsDeCanon.toAscii();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   948
    qputenv("QT_PLUGIN_PATH", ascii);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   949
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   950
    QVERIFY(!app.libraryPaths().contains(appDirPath + QString::fromLatin1("/tmp/..")));
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   951
}
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   952
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   953
void tst_QApplication::libraryPaths_qt_plugin_path_2()
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   954
{
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   955
#ifdef Q_OS_SYMBIAN
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   956
    QByteArray validPath = "C:\\data";
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   957
    QByteArray nonExistentPath = "Z:\\nonexistent";
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   958
    QByteArray pluginPath = validPath + ";" + nonExistentPath;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   959
#elif defined(Q_OS_UNIX)
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   960
    QByteArray validPath = QDir("/tmp").canonicalPath().toLatin1();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   961
    QByteArray nonExistentPath = "/nonexistent";
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   962
    QByteArray pluginPath = validPath + ":" + nonExistentPath;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   963
#elif defined(Q_OS_WIN)
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   964
# ifdef Q_OS_WINCE
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   965
    QByteArray validPath = "/Temp";
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   966
    QByteArray nonExistentPath = "/nonexistent";
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   967
    QByteArray pluginPath = validPath + ";" + nonExistentPath;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   968
# else
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   969
    QByteArray validPath = "C:\\windows";
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   970
    QByteArray nonExistentPath = "Z:\\nonexistent";
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   971
    QByteArray pluginPath = validPath + ";" + nonExistentPath;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   972
# endif
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   973
#endif
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   974
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   975
    {
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   976
        // Our hook into libraryPaths() initialization: Set the QT_PLUGIN_PATH environment variable
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   977
        qputenv("QT_PLUGIN_PATH", pluginPath);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   978
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   979
        int argc = 1;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   980
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   981
        QApplication app(argc, &argv0, QApplication::GuiServer);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   982
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   983
        // library path list should contain the default plus the one valid path
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   984
#if defined(Q_OS_SYMBIAN)
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   985
        // In Symbian, the PluginsPath doesn't specify the only absolute path; just the dir that can be found on any drive
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   986
        QStringList expected;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   987
        addExpectedSymbianPluginsPath(expected);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   988
        expected << QDir(app.applicationDirPath()).canonicalPath()
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   989
            << QDir(QDir::fromNativeSeparators(QString::fromLatin1(validPath))).canonicalPath();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   990
#else
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   991
        QStringList expected =
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   992
            QStringList()
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   993
            << QLibraryInfo::location(QLibraryInfo::PluginsPath)
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   994
            << QDir(app.applicationDirPath()).canonicalPath()
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   995
            << QDir(QDir::fromNativeSeparators(QString::fromLatin1(validPath))).canonicalPath();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   996
# ifdef Q_OS_WINCE
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   997
        expected = QSet<QString>::fromList(expected).toList();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   998
# endif
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
   999
#endif
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1000
        QVERIFY2(isPathListIncluded(app.libraryPaths(), expected),
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1001
                 qPrintable("actual:\n - " + app.libraryPaths().join("\n - ") +
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1002
                            "\nexpected:\n - " + expected.join("\n - ")));
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1003
    }
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1004
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1005
    {
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1006
        int argc = 1;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1007
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1008
        QApplication app(argc, &argv0, QApplication::GuiServer);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1009
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1010
        // library paths are initialized by the QApplication, setting
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1011
        // the environment variable here doesn't work
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1012
        qputenv("QT_PLUGIN_PATH", pluginPath);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1013
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1014
        // library path list should contain the default
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1015
#if defined(Q_OS_SYMBIAN)
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1016
        QStringList expected;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1017
        addExpectedSymbianPluginsPath(expected);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1018
        expected << app.applicationDirPath();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1019
#else
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1020
        QStringList expected =
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1021
            QStringList()
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1022
            << QLibraryInfo::location(QLibraryInfo::PluginsPath)
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1023
            << app.applicationDirPath();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1024
# ifdef Q_OS_WINCE
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1025
        expected = QSet<QString>::fromList(expected).toList();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1026
# endif
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1027
#endif
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1028
        QVERIFY(isPathListIncluded(app.libraryPaths(), expected));
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1029
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1030
        qputenv("QT_PLUGIN_PATH", QByteArray());
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1031
    }
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1032
}
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1033
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1034
class SendPostedEventsTester : public QObject
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1035
{
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1036
    Q_OBJECT
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1037
public:
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1038
    QList<int> eventSpy;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1039
    bool event(QEvent *e);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1040
private slots:
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1041
    void doTest();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1042
};
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1043
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1044
bool SendPostedEventsTester::event(QEvent *e)
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1045
{
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1046
    eventSpy.append(e->type());
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1047
    return QObject::event(e);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1048
}
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1049
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1050
void SendPostedEventsTester::doTest()
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1051
{
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1052
    QPointer<SendPostedEventsTester> p = this;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1053
    QApplication::postEvent(this, new QEvent(QEvent::User));
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1054
    // DeferredDelete should not be delivered until returning from this function
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1055
    QApplication::postEvent(this, new QEvent(QEvent::DeferredDelete));
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1056
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1057
    QEventLoop eventLoop;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1058
    QMetaObject::invokeMethod(&eventLoop, "quit", Qt::QueuedConnection);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1059
    eventLoop.exec();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1060
    QVERIFY(p != 0);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1061
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1062
    QCOMPARE(eventSpy.count(), 2);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1063
    QCOMPARE(eventSpy.at(0), int(QEvent::MetaCall));
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1064
    QCOMPARE(eventSpy.at(1), int(QEvent::User));
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1065
    eventSpy.clear();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1066
}
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1067
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1068
void tst_QApplication::sendPostedEvents()
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1069
{
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1070
    int argc = 0;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1071
    QApplication app(argc, 0, QApplication::GuiServer);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1072
    SendPostedEventsTester *tester = new SendPostedEventsTester;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1073
    QMetaObject::invokeMethod(tester, "doTest", Qt::QueuedConnection);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1074
    QMetaObject::invokeMethod(&app, "quit", Qt::QueuedConnection);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1075
    QPointer<SendPostedEventsTester> p = tester;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1076
    (void) app.exec();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1077
    QVERIFY(p == 0);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1078
}
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1079
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1080
void tst_QApplication::thread()
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1081
{
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1082
    QThread *currentThread = QThread::currentThread();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1083
    // no app, but still have a valid thread
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1084
    QVERIFY(currentThread != 0);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1085
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1086
    // the thread should be running and not finished
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1087
    QVERIFY(currentThread->isRunning());
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1088
    QVERIFY(!currentThread->isFinished());
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1089
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1090
    // this should probably be in the tst_QObject::thread() test, but
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1091
    // we put it here since we want to make sure that objects created
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1092
    // *before* the QApplication has a thread
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1093
    QObject object;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1094
    QObject child(&object);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1095
    QVERIFY(object.thread() == currentThread);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1096
    QVERIFY(child.thread() == currentThread);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1097
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1098
    {
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1099
        int argc = 0;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1100
        QApplication app(argc, 0, QApplication::GuiServer);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1101
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1102
        // current thread still valid
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1103
        QVERIFY(QThread::currentThread() != 0);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1104
        // thread should be the same as before
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1105
        QCOMPARE(QThread::currentThread(), currentThread);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1106
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1107
        // app's thread should be the current thread
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1108
        QCOMPARE(app.thread(), currentThread);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1109
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1110
        // the thread should still be running and not finished
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1111
        QVERIFY(currentThread->isRunning());
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1112
        QVERIFY(!currentThread->isFinished());
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1113
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1114
        QTestEventLoop::instance().enterLoop(1);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1115
    }
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1116
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1117
    // app dead, current thread still valid
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1118
    QVERIFY(QThread::currentThread() != 0);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1119
    QCOMPARE(QThread::currentThread(), currentThread);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1120
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1121
    // the thread should still be running and not finished
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1122
    QVERIFY(currentThread->isRunning());
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1123
    QVERIFY(!currentThread->isFinished());
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1124
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1125
    // should still have a thread
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1126
    QVERIFY(object.thread() == currentThread);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1127
    QVERIFY(child.thread() == currentThread);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1128
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1129
    // do the test again, making sure that the thread is the same as
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1130
    // before
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1131
    {
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1132
        int argc = 0;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1133
        QApplication app(argc, 0, QApplication::GuiServer);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1134
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1135
        // current thread still valid
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1136
        QVERIFY(QThread::currentThread() != 0);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1137
        // thread should be the same as before
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1138
        QCOMPARE(QThread::currentThread(), currentThread);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1139
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1140
        // app's thread should be the current thread
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1141
        QCOMPARE(app.thread(), currentThread);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1142
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1143
        // the thread should be running and not finished
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1144
        QVERIFY(currentThread->isRunning());
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1145
        QVERIFY(!currentThread->isFinished());
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1146
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1147
        // should still have a thread
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1148
        QVERIFY(object.thread() == currentThread);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1149
        QVERIFY(child.thread() == currentThread);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1150
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1151
        QTestEventLoop::instance().enterLoop(1);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1152
    }
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1153
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1154
    // app dead, current thread still valid
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1155
    QVERIFY(QThread::currentThread() != 0);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1156
    QCOMPARE(QThread::currentThread(), currentThread);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1157
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1158
    // the thread should still be running and not finished
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1159
    QVERIFY(currentThread->isRunning());
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1160
    QVERIFY(!currentThread->isFinished());
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1161
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1162
    // should still have a thread
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1163
    QVERIFY(object.thread() == currentThread);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1164
    QVERIFY(child.thread() == currentThread);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1165
}
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1166
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1167
class DeleteLaterWidget : public QWidget
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1168
{
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1169
    Q_OBJECT
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1170
public:
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1171
    DeleteLaterWidget(QApplication *_app, QWidget *parent = 0)
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1172
        : QWidget(parent) { app = _app; child_deleted = false; }
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1173
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1174
    bool child_deleted;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1175
    QApplication *app;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1176
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1177
public slots:
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1178
    void runTest();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1179
    void checkDeleteLater();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1180
    void childDeleted() { child_deleted = true; }
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1181
};
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1182
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1183
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1184
void DeleteLaterWidget::runTest()
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1185
{
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1186
    QObject *stillAlive = qFindChild<QObject*>(this, "deleteLater");
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1187
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1188
    QWidget *w = new QWidget(this);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1189
    connect(w, SIGNAL(destroyed()), this, SLOT(childDeleted()));
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1190
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1191
    w->deleteLater();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1192
    QVERIFY(!child_deleted);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1193
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1194
    QDialog dlg;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1195
    QTimer::singleShot(500, &dlg, SLOT(reject()));
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1196
    dlg.exec();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1197
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1198
    QVERIFY(!child_deleted);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1199
    app->processEvents();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1200
    QVERIFY(!child_deleted);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1201
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1202
    QTimer::singleShot(500, this, SLOT(checkDeleteLater()));
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1203
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1204
    app->processEvents();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1205
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1206
    QVERIFY(!stillAlive); // verify at the end to make test terminate
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1207
}
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1208
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1209
void DeleteLaterWidget::checkDeleteLater()
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1210
{
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1211
    QVERIFY(child_deleted);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1212
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1213
    close();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1214
}
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1215
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1216
void tst_QApplication::testDeleteLater()
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1217
{
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1218
    int argc = 0;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1219
    QApplication app(argc, 0, QApplication::GuiServer);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1220
    connect(&app, SIGNAL(lastWindowClosed()), &app, SLOT(quit()));
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1221
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1222
    DeleteLaterWidget *wgt = new DeleteLaterWidget(&app);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1223
    QTimer::singleShot(500, wgt, SLOT(runTest()));
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1224
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1225
    QObject *object = new QObject(wgt);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1226
    object->setObjectName("deleteLater");
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1227
    object->deleteLater();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1228
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1229
    QObject *stillAlive = qFindChild<QObject*>(wgt, "deleteLater");
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1230
    QVERIFY(stillAlive);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1231
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1232
    app.exec();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1233
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1234
    delete wgt;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1235
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1236
}
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1237
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1238
class EventLoopNester : public QObject
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1239
{
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1240
    Q_OBJECT
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1241
public slots:
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1242
    void deleteLaterAndEnterLoop()
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1243
    {
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1244
        QEventLoop eventLoop;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1245
        QPointer<QObject> p(this);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1246
        deleteLater();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1247
        
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1248
        // DeferredDelete events are compressed, meaning this second
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1249
        // deleteLater() will *not* delete the object in the nested
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1250
        // event loop
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1251
        QMetaObject::invokeMethod(this, "deleteLater", Qt::QueuedConnection);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1252
        QTimer::singleShot(1000, &eventLoop, SLOT(quit()));
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1253
        eventLoop.exec();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1254
        QVERIFY(p);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1255
    }
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1256
    void deleteLaterAndExitLoop()
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1257
    {
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1258
        // Check that 'p' is not deleted before exec returns, since the call
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1259
        // to QEventLoop::quit() should stop 'eventLoop' from processing
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1260
        // any more events (that is, delete later) until we return to the
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1261
        // _current_ event loop:
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1262
        QEventLoop eventLoop;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1263
        QPointer<QObject> p(this);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1264
        QMetaObject::invokeMethod(this, "deleteLater", Qt::QueuedConnection);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1265
        QMetaObject::invokeMethod(&eventLoop, "quit", Qt::QueuedConnection);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1266
        eventLoop.exec();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1267
        QVERIFY(p); // not dead yet
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1268
    }
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1269
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1270
    void processEventsOnly()
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1271
    {
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1272
        QApplication::processEvents();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1273
    }
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1274
    void processEventsWithDeferredDeletion()
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1275
    {
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1276
        QApplication::processEvents(QEventLoop::DeferredDeletion);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1277
    }
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1278
    void sendPostedEventsWithDeferredDelete()
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1279
    {
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1280
        QApplication::sendPostedEvents(0, QEvent::DeferredDelete);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1281
    }
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1282
    void deleteLaterAndProcessEvents1()
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1283
    {
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1284
        QEventLoop eventLoop;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1285
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1286
        QPointer<QObject> p = this;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1287
        deleteLater();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1288
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1289
        // trying to delete this object in a deeper eventloop just won't work
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1290
        QMetaObject::invokeMethod(this,
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1291
                                  "processEventsOnly",
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1292
                                  Qt::QueuedConnection);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1293
        QMetaObject::invokeMethod(&eventLoop, "quit", Qt::QueuedConnection);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1294
        eventLoop.exec();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1295
        QVERIFY(p);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1296
        QMetaObject::invokeMethod(this,
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1297
                                  "processEventsWithDeferredDeletion",
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1298
                                  Qt::QueuedConnection);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1299
        QMetaObject::invokeMethod(&eventLoop, "quit", Qt::QueuedConnection);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1300
        eventLoop.exec();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1301
        QVERIFY(p);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1302
        QMetaObject::invokeMethod(this,
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1303
                                  "sendPostedEventsWithDeferredDelete",
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1304
                                  Qt::QueuedConnection);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1305
        QMetaObject::invokeMethod(&eventLoop, "quit", Qt::QueuedConnection);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1306
        eventLoop.exec();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1307
        QVERIFY(p);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1308
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1309
        // trying to delete it from this eventloop still doesn't work
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1310
        QApplication::processEvents();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1311
        QVERIFY(p);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1312
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1313
        // however, it *will* work with this magic incantation
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1314
        QApplication::processEvents(QEventLoop::DeferredDeletion);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1315
        QVERIFY(!p);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1316
    }
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1317
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1318
    void deleteLaterAndProcessEvents2()
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1319
    {
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1320
        QEventLoop eventLoop;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1321
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1322
        QPointer<QObject> p = this;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1323
        deleteLater();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1324
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1325
        // trying to delete this object in a deeper eventloop just won't work
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1326
        QMetaObject::invokeMethod(this,
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1327
                                  "processEventsOnly",
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1328
                                  Qt::QueuedConnection);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1329
        QMetaObject::invokeMethod(&eventLoop, "quit", Qt::QueuedConnection);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1330
        eventLoop.exec();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1331
        QVERIFY(p);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1332
        QMetaObject::invokeMethod(this,
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1333
                                  "processEventsWithDeferredDeletion",
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1334
                                  Qt::QueuedConnection);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1335
        QMetaObject::invokeMethod(&eventLoop, "quit", Qt::QueuedConnection);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1336
        eventLoop.exec();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1337
        QVERIFY(p);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1338
        QMetaObject::invokeMethod(this,
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1339
                                  "sendPostedEventsWithDeferredDelete",
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1340
                                  Qt::QueuedConnection);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1341
        QMetaObject::invokeMethod(&eventLoop, "quit", Qt::QueuedConnection);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1342
        eventLoop.exec();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1343
        QVERIFY(p);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1344
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1345
        // trying to delete it from this eventloop still doesn't work
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1346
        QApplication::processEvents();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1347
        QVERIFY(p);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1348
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1349
        // however, it *will* work with this magic incantation
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1350
        QApplication::sendPostedEvents(0, QEvent::DeferredDelete);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1351
        QVERIFY(!p);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1352
    }
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1353
};
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1354
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1355
void tst_QApplication::testDeleteLaterProcessEvents()
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1356
{
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1357
    int argc = 0;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1358
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1359
    // Calling processEvents() with no event dispatcher does nothing.
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1360
    QObject *object = new QObject;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1361
    QPointer<QObject> p(object);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1362
    object->deleteLater();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1363
    QApplication::processEvents();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1364
    QVERIFY(p);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1365
    delete object;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1366
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1367
    {
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1368
        QApplication app(argc, 0, QApplication::GuiServer);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1369
        // If you call processEvents() with an event dispatcher present, but
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1370
        // outside any event loops, deferred deletes are not processed unless
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1371
        // QEventLoop::DeferredDeletion is passed.
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1372
        object = new QObject;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1373
        p = object;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1374
        object->deleteLater();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1375
        app.processEvents();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1376
        QVERIFY(p);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1377
        app.processEvents(QEventLoop::ProcessEventsFlag(0x10)); // 0x10 == QEventLoop::DeferredDeletion
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1378
        QVERIFY(!p);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1379
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1380
        // sendPostedEvents(0, DeferredDelete); also works
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1381
        object = new QObject;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1382
        p = object;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1383
        object->deleteLater();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1384
        app.processEvents();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1385
        QVERIFY(p);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1386
        QApplication::sendPostedEvents(0, QEvent::DeferredDelete);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1387
        QVERIFY(!p);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1388
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1389
        // If you call deleteLater() on an object when there is no parent
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1390
        // event loop, and then enter an event loop, the object will get
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1391
        // deleted.
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1392
        object = new QObject;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1393
        p = object;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1394
        object->deleteLater();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1395
        QEventLoop loop;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1396
        QTimer::singleShot(1000, &loop, SLOT(quit()));
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1397
        loop.exec();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1398
        QVERIFY(!p);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1399
    }
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1400
    {
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1401
        // When an object is in an event loop, then calls deleteLater() and enters
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1402
        // an event loop recursively, it should not die until the parent event
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1403
        // loop continues.
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1404
        QApplication app(argc, 0, QApplication::GuiServer);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1405
        QEventLoop loop;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1406
        EventLoopNester *nester = new EventLoopNester;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1407
        p = nester;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1408
        QTimer::singleShot(3000, &loop, SLOT(quit()));
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1409
        QTimer::singleShot(0, nester, SLOT(deleteLaterAndEnterLoop()));
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1410
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1411
        loop.exec();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1412
        QVERIFY(!p);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1413
    }
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1414
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1415
    {
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1416
        // When the event loop that calls deleteLater() is exited
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1417
        // immediately, the object should die when returning to the
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1418
        // parent event loop
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1419
        QApplication app(argc, 0, QApplication::GuiServer);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1420
        QEventLoop loop;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1421
        EventLoopNester *nester = new EventLoopNester;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1422
        p = nester;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1423
        QTimer::singleShot(3000, &loop, SLOT(quit()));
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1424
        QTimer::singleShot(0, nester, SLOT(deleteLaterAndExitLoop()));
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1425
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1426
        loop.exec();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1427
        QVERIFY(!p);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1428
    }
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1429
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1430
    {
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1431
        // when the event loop that calls deleteLater() also calls
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1432
        // processEvents() immediately afterwards, the object should
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1433
        // not die until the parent loop continues
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1434
        QApplication app(argc, 0, QApplication::GuiServer);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1435
        QEventLoop loop;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1436
        EventLoopNester *nester = new EventLoopNester();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1437
        p = nester;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1438
        QTimer::singleShot(3000, &loop, SLOT(quit()));
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1439
        QTimer::singleShot(0, nester, SLOT(deleteLaterAndProcessEvents1()));
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1440
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1441
        loop.exec();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1442
        QVERIFY(!p);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1443
    }
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1444
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1445
    {
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1446
        // when the event loop that calls deleteLater() also calls
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1447
        // processEvents() immediately afterwards, the object should
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1448
        // not die until the parent loop continues
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1449
        QApplication app(argc, 0, QApplication::GuiServer);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1450
        QEventLoop loop;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1451
        EventLoopNester *nester = new EventLoopNester();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1452
        p = nester;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1453
        QTimer::singleShot(3000, &loop, SLOT(quit()));
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1454
        QTimer::singleShot(0, nester, SLOT(deleteLaterAndProcessEvents2()));
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1455
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1456
        loop.exec();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1457
        QVERIFY(!p);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1458
    }
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1459
}
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1460
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1461
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1462
//    Test for crash whith QApplication::setDesktopSettingsAware(false).
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1463
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1464
void tst_QApplication::desktopSettingsAware()
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1465
{
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1466
#ifndef QT_NO_PROCESS
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1467
    QProcess testProcess;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1468
#ifdef Q_OS_WINCE
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1469
    int argc = 0;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1470
    QApplication tmpApp(argc, 0, QApplication::GuiServer);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1471
    testProcess.start("desktopsettingsaware/desktopsettingsaware");
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1472
#else
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1473
#if defined(Q_OS_WIN) && defined(QT_DEBUG)
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1474
    testProcess.start("desktopsettingsaware/debug/desktopsettingsaware");
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1475
#elif defined(Q_OS_WIN)
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1476
    testProcess.start("desktopsettingsaware/release/desktopsettingsaware");
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1477
#elif defined(Q_OS_SYMBIAN)
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1478
    testProcess.start("desktopsettingsaware");
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1479
#if defined(Q_CC_NOKIAX86)
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1480
    QEXPECT_FAIL("", "QProcess on Q_CC_NOKIAX86 cannot launch another Qt application, due to DLL conflicts.", Abort);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1481
    // TODO: Remove XFAIL, as soon as we can launch Qt applications from within Qt applications on Symbian
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1482
    QVERIFY(testProcess.error() != QProcess::FailedToStart);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1483
#endif // defined(Q_CC_NOKIAX86)
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1484
#else
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1485
    testProcess.start("desktopsettingsaware/desktopsettingsaware");
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1486
#endif
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1487
#endif
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1488
    QVERIFY(testProcess.waitForFinished(10000));
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1489
    QCOMPARE(int(testProcess.state()), int(QProcess::NotRunning));
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1490
    QVERIFY(int(testProcess.error()) != int(QProcess::Crashed));
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1491
#endif
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1492
}
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1493
*/
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1494
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1495
void tst_QApplication::setActiveWindow()
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1496
{
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1497
    int argc = 0;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1498
    QApplication MyApp(argc, 0, QApplication::GuiServer);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1499
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1500
    QWidget* w = new QWidget;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1501
    QVBoxLayout* layout = new QVBoxLayout(w);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1502
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1503
    QLineEdit* pb1 = new QLineEdit("Testbutton1", w);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1504
    QLineEdit* pb2 = new QLineEdit("Test Line Edit", w);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1505
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1506
    layout->addWidget(pb1);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1507
    layout->addWidget(pb2);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1508
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1509
    pb2->setFocus();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1510
    pb2->setParent(0);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1511
    delete pb2;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1512
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1513
    w->show();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1514
    QApplication::setActiveWindow(w); // needs this on twm (focus follows mouse)
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1515
    QVERIFY(pb1->hasFocus());
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1516
    delete w;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1517
}
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1518
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1519
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1520
/* This might fail on some X11 window managers? */
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1521
/*
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1522
void tst_QApplication::focusChanged()
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1523
{
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1524
    int argc = 0;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1525
    QApplication app(argc, 0, QApplication::GuiServer);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1526
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1527
    QSignalSpy spy(&app, SIGNAL(focusChanged(QWidget *, QWidget *)));
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1528
    QWidget *now = 0;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1529
    QWidget *old = 0;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1530
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1531
    QWidget parent1;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1532
    QHBoxLayout hbox1(&parent1);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1533
    QLabel lb1(&parent1);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1534
    QLineEdit le1(&parent1);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1535
    QPushButton pb1(&parent1);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1536
    hbox1.addWidget(&lb1);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1537
    hbox1.addWidget(&le1);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1538
    hbox1.addWidget(&pb1);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1539
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1540
    QCOMPARE(spy.count(), 0);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1541
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1542
    parent1.show();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1543
    QApplication::setActiveWindow(&parent1); // needs this on twm (focus follows mouse)
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1544
    QCOMPARE(spy.count(), 1);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1545
    QCOMPARE(spy.at(0).count(), 2);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1546
    old = qVariantValue<QWidget*>(spy.at(0).at(0));
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1547
    now = qVariantValue<QWidget*>(spy.at(0).at(1));
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1548
    QVERIFY(now == &le1);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1549
    QVERIFY(now == QApplication::focusWidget());
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1550
    QVERIFY(old == 0);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1551
    spy.clear();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1552
    QCOMPARE(spy.count(), 0);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1553
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1554
    pb1.setFocus();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1555
    QCOMPARE(spy.count(), 1);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1556
    old = qVariantValue<QWidget*>(spy.at(0).at(0));
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1557
    now = qVariantValue<QWidget*>(spy.at(0).at(1));
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1558
    QVERIFY(now == &pb1);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1559
    QVERIFY(now == QApplication::focusWidget());
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1560
    QVERIFY(old == &le1);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1561
    spy.clear();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1562
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1563
    lb1.setFocus();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1564
    QCOMPARE(spy.count(), 1);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1565
    old = qVariantValue<QWidget*>(spy.at(0).at(0));
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1566
    now = qVariantValue<QWidget*>(spy.at(0).at(1));
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1567
    QVERIFY(now == &lb1);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1568
    QVERIFY(now == QApplication::focusWidget());
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1569
    QVERIFY(old == &pb1);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1570
    spy.clear();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1571
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1572
    lb1.clearFocus();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1573
    QCOMPARE(spy.count(), 1);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1574
    old = qVariantValue<QWidget*>(spy.at(0).at(0));
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1575
    now = qVariantValue<QWidget*>(spy.at(0).at(1));
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1576
    QVERIFY(now == 0);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1577
    QVERIFY(now == QApplication::focusWidget());
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1578
    QVERIFY(old == &lb1);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1579
    spy.clear();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1580
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1581
    QWidget parent2;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1582
    QHBoxLayout hbox2(&parent2);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1583
    QLabel lb2(&parent2);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1584
    QLineEdit le2(&parent2);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1585
    QPushButton pb2(&parent2);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1586
    hbox2.addWidget(&lb2);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1587
    hbox2.addWidget(&le2);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1588
    hbox2.addWidget(&pb2);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1589
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1590
    parent2.show();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1591
    QApplication::setActiveWindow(&parent2); // needs this on twm (focus follows mouse)
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1592
    QVERIFY(spy.count() > 0); // one for deactivation, one for activation on Windows
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1593
    old = qVariantValue<QWidget*>(spy.at(spy.count()-1).at(0));
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1594
    now = qVariantValue<QWidget*>(spy.at(spy.count()-1).at(1));
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1595
    QVERIFY(now == &le2);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1596
    QVERIFY(now == QApplication::focusWidget());
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1597
    QVERIFY(old == 0);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1598
    spy.clear();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1599
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1600
    QTestKeyEvent tab(QTest::Press, Qt::Key_Tab, 0, 0);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1601
    QTestKeyEvent backtab(QTest::Press, Qt::Key_Backtab, 0, 0);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1602
    QTestMouseEvent click(QTest::MouseClick, Qt::LeftButton, 0, QPoint(5, 5), 0);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1603
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1604
    bool tabAllControls = true;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1605
#ifdef Q_WS_MAC
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1606
    // Mac has two modes, one where you tab to everything, one where you can
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1607
    // only tab to input controls, here's what we get. Determine which ones we
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1608
    // should get.
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1609
    QSettings appleSettings(QLatin1String("apple.com"));
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1610
    QVariant appleValue = appleSettings.value(QLatin1String("AppleKeyboardUIMode"), 0);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1611
    tabAllControls = (appleValue.toInt() & 0x2);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1612
#endif
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1613
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1614
    tab.simulate(now);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1615
    if (!tabAllControls) {
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1616
        QVERIFY(spy.count() == 0);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1617
        QVERIFY(now == QApplication::focusWidget());
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1618
    } else {
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1619
        QVERIFY(spy.count() > 0);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1620
        old = qVariantValue<QWidget*>(spy.at(0).at(0));
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1621
        now = qVariantValue<QWidget*>(spy.at(0).at(1));
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1622
        QVERIFY(now == &pb2);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1623
        QVERIFY(now == QApplication::focusWidget());
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1624
        QVERIFY(old == &le2);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1625
        spy.clear();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1626
    }
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1627
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1628
    if (!tabAllControls) {
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1629
        QVERIFY(spy.count() == 0);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1630
        QVERIFY(now == QApplication::focusWidget());
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1631
    } else {
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1632
        tab.simulate(now);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1633
        QVERIFY(spy.count() > 0);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1634
        old = qVariantValue<QWidget*>(spy.at(0).at(0));
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1635
        now = qVariantValue<QWidget*>(spy.at(0).at(1));
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1636
        QVERIFY(now == &le2);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1637
        QVERIFY(now == QApplication::focusWidget());
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1638
        QVERIFY(old == &pb2);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1639
        spy.clear();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1640
    }
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1641
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1642
    if (!tabAllControls) {
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1643
        QVERIFY(spy.count() == 0);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1644
        QVERIFY(now == QApplication::focusWidget());
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1645
    } else {
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1646
        backtab.simulate(now);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1647
        QVERIFY(spy.count() > 0);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1648
        old = qVariantValue<QWidget*>(spy.at(0).at(0));
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1649
        now = qVariantValue<QWidget*>(spy.at(0).at(1));
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1650
        QVERIFY(now == &pb2);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1651
        QVERIFY(now == QApplication::focusWidget());
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1652
        QVERIFY(old == &le2);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1653
        spy.clear();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1654
    }
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1655
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1656
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1657
    if (!tabAllControls) {
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1658
        QVERIFY(spy.count() == 0);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1659
        QVERIFY(now == QApplication::focusWidget());
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1660
        old = &pb2;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1661
    } else {
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1662
        backtab.simulate(now);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1663
        QVERIFY(spy.count() > 0);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1664
        old = qVariantValue<QWidget*>(spy.at(0).at(0));
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1665
        now = qVariantValue<QWidget*>(spy.at(0).at(1));
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1666
        QVERIFY(now == &le2);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1667
        QVERIFY(now == QApplication::focusWidget());
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1668
        QVERIFY(old == &pb2);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1669
        spy.clear();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1670
    }
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1671
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1672
    click.simulate(old);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1673
    if (!(pb2.focusPolicy() & Qt::ClickFocus)) {
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1674
        QVERIFY(spy.count() == 0);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1675
        QVERIFY(now == QApplication::focusWidget());
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1676
    } else {
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1677
        QVERIFY(spy.count() > 0);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1678
        old = qVariantValue<QWidget*>(spy.at(0).at(0));
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1679
        now = qVariantValue<QWidget*>(spy.at(0).at(1));
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1680
        QVERIFY(now == &pb2);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1681
        QVERIFY(now == QApplication::focusWidget());
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1682
        QVERIFY(old == &le2);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1683
        spy.clear();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1684
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1685
        click.simulate(old);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1686
        QVERIFY(spy.count() > 0);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1687
        old = qVariantValue<QWidget*>(spy.at(0).at(0));
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1688
        now = qVariantValue<QWidget*>(spy.at(0).at(1));
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1689
        QVERIFY(now == &le2);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1690
        QVERIFY(now == QApplication::focusWidget());
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1691
        QVERIFY(old == &pb2);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1692
        spy.clear();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1693
    }
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1694
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1695
    parent1.activateWindow();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1696
    QApplication::setActiveWindow(&parent1); // needs this on twm (focus follows mouse)
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1697
    QVERIFY(spy.count() == 1 || spy.count() == 2); // one for deactivation, one for activation on Windows
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1698
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1699
    //on windows, the change of focus is made in 2 steps
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1700
    //(the focusChanged SIGNAL is emitted twice)
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1701
    if (spy.count()==1)
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1702
        old = qVariantValue<QWidget*>(spy.at(spy.count()-1).at(0));
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1703
    else
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1704
        old = qVariantValue<QWidget*>(spy.at(spy.count()-2).at(0));
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1705
    now = qVariantValue<QWidget*>(spy.at(spy.count()-1).at(1));
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1706
    QVERIFY(now == &le1);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1707
    QVERIFY(now == QApplication::focusWidget());
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1708
    QVERIFY(old == &le2);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1709
    spy.clear();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1710
}
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1711
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1712
class LineEdit : public QLineEdit
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1713
{
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1714
public:
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1715
    LineEdit(QWidget *parent = 0) : QLineEdit(parent) { }
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1716
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1717
protected:
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1718
    void focusOutEvent(QFocusEvent *e) {
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1719
        QLineEdit::focusOutEvent(e);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1720
        if (objectName() == "le1")
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1721
            setStyleSheet("");
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1722
    }
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1723
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1724
    void focusInEvent(QFocusEvent *e) {
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1725
        QLineEdit::focusInEvent(e);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1726
        if (objectName() == "le2")
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1727
            setStyleSheet("");
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1728
    }
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1729
};
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1730
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1731
void tst_QApplication::focusOut()
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1732
{
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1733
    int argc = 1;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1734
    QApplication app(argc, &argv0, QApplication::GuiServer);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1735
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1736
    // Tests the case where the style pointer changes when on focus in/out
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1737
    // (the above is the case when the stylesheet changes)
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1738
    QWidget w;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1739
    QLineEdit *le1 = new LineEdit(&w);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1740
    le1->setObjectName("le1");
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1741
    le1->setStyleSheet("background: #fee");
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1742
    le1->setFocus();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1743
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1744
    QLineEdit *le2 = new LineEdit(&w);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1745
    le2->setObjectName("le2");
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1746
    le2->setStyleSheet("background: #fee");
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1747
    le2->move(100, 100);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1748
    w.show();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1749
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1750
    QTest::qWait(2000);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1751
    le2->setFocus();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1752
    QTest::qWait(2000);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1753
}
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1754
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1755
void tst_QApplication::execAfterExit()
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1756
{
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1757
    int argc = 1;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1758
    QApplication app(argc, &argv0, QApplication::GuiServer);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1759
    QMetaObject::invokeMethod(&app, "quit", Qt::QueuedConnection);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1760
    // this should be ignored, as exec() will reset the exitCode
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1761
    QApplication::exit(1);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1762
    int exitCode = app.exec();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1763
    QCOMPARE(exitCode, 0);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1764
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1765
    // the quitNow flag should have been reset, so we can spin an
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1766
    // eventloop after QApplication::exec() returns
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1767
    QEventLoop eventLoop;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1768
    QMetaObject::invokeMethod(&eventLoop, "quit", Qt::QueuedConnection);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1769
    exitCode = eventLoop.exec();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1770
    QCOMPARE(exitCode, 0);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1771
}
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1772
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1773
void tst_QApplication::wheelScrollLines()
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1774
{
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1775
    int argc = 1;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1776
    QApplication app(argc, &argv0, QApplication::GuiServer);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1777
    // If wheelScrollLines returns 0, the mose wheel will be disabled.
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1778
    QVERIFY(app.wheelScrollLines() > 0);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1779
}
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1780
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1781
void tst_QApplication::style()
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1782
{
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1783
    int argc = 1;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1784
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1785
    {
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1786
        QApplication app(argc, &argv0, QApplication::GuiServer);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1787
        QPointer<QStyle> style = app.style();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1788
        app.setStyle(new QWindowsStyle);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1789
        QVERIFY(style.isNull());
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1790
    }
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1791
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1792
    QApplication app(argc, &argv0, QApplication::GuiServer);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1793
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1794
    // qApp style can never be 0
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1795
    QVERIFY(QApplication::style() != 0);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1796
}
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1797
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1798
void tst_QApplication::allWidgets()
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1799
{
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1800
    int argc = 1;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1801
    QApplication app(argc, &argv0, QApplication::GuiServer);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1802
    QWidget *w = new QWidget;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1803
    QVERIFY(app.allWidgets().contains(w)); // uncreate widget test
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1804
    QVERIFY(app.allWidgets().contains(w)); // created widget test
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1805
    delete w;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1806
    w = 0;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1807
    QVERIFY(!app.allWidgets().contains(w)); // removal test
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1808
}
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1809
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1810
void tst_QApplication::topLevelWidgets()
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1811
{
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1812
    int argc = 1;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1813
    QApplication app(argc, &argv0, QApplication::GuiServer);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1814
    QWidget *w = new QWidget;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1815
    w->show();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1816
#ifndef QT_NO_CLIPBOARD
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1817
    QClipboard *clipboard = QApplication::clipboard();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1818
    QString originalText = clipboard->text();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1819
    clipboard->setText(QString("newText"));
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1820
#endif
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1821
    app.processEvents();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1822
    QVERIFY(QApplication::topLevelWidgets().contains(w));
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1823
    QCOMPARE(QApplication::topLevelWidgets().count(), 1);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1824
    delete w;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1825
    w = 0;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1826
    app.processEvents();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1827
    QCOMPARE(QApplication::topLevelWidgets().count(), 0);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1828
}
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1829
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1830
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1831
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1832
void tst_QApplication::setAttribute()
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1833
{
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1834
    int argc = 1;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1835
    QApplication app(argc, &argv0, QApplication::GuiServer);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1836
    QVERIFY(!QApplication::testAttribute(Qt::AA_ImmediateWidgetCreation));
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1837
    QWidget  *w = new QWidget;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1838
    QVERIFY(!w->testAttribute(Qt::WA_WState_Created));
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1839
    delete w;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1840
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1841
    QApplication::setAttribute(Qt::AA_ImmediateWidgetCreation);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1842
    QVERIFY(QApplication::testAttribute(Qt::AA_ImmediateWidgetCreation));
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1843
    w = new QWidget;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1844
    QVERIFY(w->testAttribute(Qt::WA_WState_Created));
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1845
    QWidget *w2 = new QWidget(w);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1846
    w2->setParent(0);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1847
    QVERIFY(w2->testAttribute(Qt::WA_WState_Created));
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1848
    delete w;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1849
    delete w2;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1850
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1851
    QApplication::setAttribute(Qt::AA_ImmediateWidgetCreation, false);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1852
    QVERIFY(!QApplication::testAttribute(Qt::AA_ImmediateWidgetCreation));
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1853
    w = new QWidget;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1854
    QVERIFY(!w->testAttribute(Qt::WA_WState_Created));
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1855
    delete w;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1856
}
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1857
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1858
void tst_QApplication::windowsCommandLine_data()
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1859
{
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1860
#if defined(Q_OS_WIN)
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1861
    QTest::addColumn<QString>("args");
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1862
    QTest::addColumn<QString>("expected");
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1863
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1864
    QTest::newRow("hello world")
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1865
        << QString("Hello \"World\"")
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1866
        << QString("Hello \"World\"");
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1867
    QTest::newRow("sql")
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1868
        << QString("SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = 'PNR' AND TABLE_TYPE = 'VIEW' ORDER BY TABLE_NAME")
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1869
        << QString("SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = 'PNR' AND TABLE_TYPE = 'VIEW' ORDER BY TABLE_NAME");
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1870
#endif
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1871
}
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1872
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1873
void tst_QApplication::windowsCommandLine()
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1874
{
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1875
#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE)
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1876
    QFETCH(QString, args);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1877
    QFETCH(QString, expected);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1878
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1879
    QProcess testProcess;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1880
#if defined(QT_DEBUG)
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1881
    testProcess.start("wincmdline/debug/wincmdline", QStringList(args));
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1882
#else
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1883
    testProcess.start("wincmdline/release/wincmdline", QStringList(args));
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1884
#endif
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1885
    QVERIFY(testProcess.waitForFinished(10000));
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1886
    QByteArray error = testProcess.readAllStandardError();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1887
    QString procError(error);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1888
    QCOMPARE(procError, expected);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1889
#endif
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1890
}
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1891
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1892
class TouchEventPropagationTestWidget : public QWidget
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1893
{
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1894
    Q_OBJECT
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1895
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1896
public:
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1897
    bool seenTouchEvent, acceptTouchEvent, seenMouseEvent, acceptMouseEvent;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1898
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1899
    TouchEventPropagationTestWidget(QWidget *parent = 0)
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1900
        : QWidget(parent), seenTouchEvent(false), acceptTouchEvent(false), seenMouseEvent(false), acceptMouseEvent(false)
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1901
    { }
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1902
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1903
    void reset()
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1904
    {
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1905
        seenTouchEvent = acceptTouchEvent = seenMouseEvent = acceptMouseEvent = false;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1906
    }
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1907
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1908
    bool event(QEvent *event)
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1909
    {
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1910
        switch (event->type()) {
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1911
        case QEvent::MouseButtonPress:
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1912
        case QEvent::MouseMove:
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1913
        case QEvent::MouseButtonRelease:
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1914
            // qDebug() << objectName() << "seenMouseEvent = true";
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1915
            seenMouseEvent = true;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1916
            event->setAccepted(acceptMouseEvent);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1917
            break;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1918
        case QEvent::TouchBegin:
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1919
        case QEvent::TouchUpdate:
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1920
        case QEvent::TouchEnd:
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1921
            // qDebug() << objectName() << "seenTouchEvent = true";
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1922
            seenTouchEvent = true;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1923
            event->setAccepted(acceptTouchEvent);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1924
            break;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1925
        default:
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1926
            return QWidget::event(event);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1927
        }
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1928
        return true;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1929
    }
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1930
};
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1931
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1932
void tst_QApplication::touchEventPropagation()
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1933
{
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1934
    int argc = 1;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1935
    QApplication app(argc, &argv0, QApplication::GuiServer);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1936
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1937
    QList<QTouchEvent::TouchPoint> pressedTouchPoints;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1938
    QTouchEvent::TouchPoint press(0);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1939
    press.setState(Qt::TouchPointPressed);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1940
    pressedTouchPoints << press;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1941
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1942
    QList<QTouchEvent::TouchPoint> releasedTouchPoints;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1943
    QTouchEvent::TouchPoint release(0);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1944
    release.setState(Qt::TouchPointReleased);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1945
    releasedTouchPoints << release;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1946
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1947
    {
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1948
        // touch event behavior on a window
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1949
        TouchEventPropagationTestWidget window;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1950
        window.setObjectName("1. window");
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1951
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1952
        qt_translateRawTouchEvent(&window, QTouchEvent::TouchScreen, pressedTouchPoints);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1953
        qt_translateRawTouchEvent(&window, QTouchEvent::TouchScreen, releasedTouchPoints);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1954
        QVERIFY(!window.seenTouchEvent);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1955
        QVERIFY(!window.seenMouseEvent);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1956
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1957
        window.reset();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1958
        window.setAttribute(Qt::WA_AcceptTouchEvents);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1959
        qt_translateRawTouchEvent(&window, QTouchEvent::TouchScreen, pressedTouchPoints);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1960
        qt_translateRawTouchEvent(&window, QTouchEvent::TouchScreen, releasedTouchPoints);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1961
        QVERIFY(window.seenTouchEvent);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1962
        QVERIFY(!window.seenMouseEvent);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1963
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1964
        window.reset();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1965
        window.acceptTouchEvent = true;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1966
        qt_translateRawTouchEvent(&window, QTouchEvent::TouchScreen, pressedTouchPoints);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1967
        qt_translateRawTouchEvent(&window, QTouchEvent::TouchScreen, releasedTouchPoints);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1968
        QVERIFY(window.seenTouchEvent);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1969
        QVERIFY(!window.seenMouseEvent);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1970
    }
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1971
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1972
    {
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1973
        // touch event behavior on a window with a child widget
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1974
        TouchEventPropagationTestWidget window;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1975
        window.setObjectName("2. window");
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1976
        TouchEventPropagationTestWidget widget(&window);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1977
        widget.setObjectName("2. widget");
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1978
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1979
        qt_translateRawTouchEvent(&window, QTouchEvent::TouchScreen, pressedTouchPoints);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1980
        qt_translateRawTouchEvent(&window, QTouchEvent::TouchScreen, releasedTouchPoints);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1981
        QVERIFY(!widget.seenTouchEvent);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1982
        QVERIFY(!widget.seenMouseEvent);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1983
        QVERIFY(!window.seenTouchEvent);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1984
        QVERIFY(!window.seenMouseEvent);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1985
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1986
        window.reset();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1987
        widget.reset();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1988
        widget.setAttribute(Qt::WA_AcceptTouchEvents);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1989
        qt_translateRawTouchEvent(&window, QTouchEvent::TouchScreen, pressedTouchPoints);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1990
        qt_translateRawTouchEvent(&window, QTouchEvent::TouchScreen, releasedTouchPoints);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1991
        QVERIFY(widget.seenTouchEvent);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1992
        QVERIFY(!widget.seenMouseEvent);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1993
        QVERIFY(!window.seenTouchEvent);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1994
        QVERIFY(!window.seenMouseEvent);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1995
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1996
        window.reset();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1997
        widget.reset();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1998
        widget.acceptMouseEvent = true;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  1999
        qt_translateRawTouchEvent(&window, QTouchEvent::TouchScreen, pressedTouchPoints);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2000
        qt_translateRawTouchEvent(&window, QTouchEvent::TouchScreen, releasedTouchPoints);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2001
        QVERIFY(widget.seenTouchEvent);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2002
        QVERIFY(!widget.seenMouseEvent);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2003
        QVERIFY(!window.seenTouchEvent);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2004
        QVERIFY(!window.seenMouseEvent);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2005
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2006
        window.reset();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2007
        widget.reset();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2008
        widget.acceptTouchEvent = true;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2009
        qt_translateRawTouchEvent(&window, QTouchEvent::TouchScreen, pressedTouchPoints);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2010
        qt_translateRawTouchEvent(&window, QTouchEvent::TouchScreen, releasedTouchPoints);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2011
        QVERIFY(widget.seenTouchEvent);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2012
        QVERIFY(!widget.seenMouseEvent);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2013
        QVERIFY(!window.seenTouchEvent);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2014
        QVERIFY(!window.seenMouseEvent);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2015
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2016
        window.reset();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2017
        widget.reset();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2018
        widget.setAttribute(Qt::WA_AcceptTouchEvents, false);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2019
        window.setAttribute(Qt::WA_AcceptTouchEvents);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2020
        qt_translateRawTouchEvent(&window, QTouchEvent::TouchScreen, pressedTouchPoints);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2021
        qt_translateRawTouchEvent(&window, QTouchEvent::TouchScreen, releasedTouchPoints);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2022
        QVERIFY(!widget.seenTouchEvent);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2023
        QVERIFY(!widget.seenMouseEvent);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2024
        QVERIFY(window.seenTouchEvent);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2025
        QVERIFY(!window.seenMouseEvent);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2026
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2027
        window.reset();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2028
        widget.reset();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2029
        window.acceptTouchEvent = true;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2030
        qt_translateRawTouchEvent(&window, QTouchEvent::TouchScreen, pressedTouchPoints);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2031
        qt_translateRawTouchEvent(&window, QTouchEvent::TouchScreen, releasedTouchPoints);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2032
        QVERIFY(!widget.seenTouchEvent);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2033
        QVERIFY(!widget.seenMouseEvent);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2034
        QVERIFY(window.seenTouchEvent);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2035
        QVERIFY(!window.seenMouseEvent);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2036
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2037
        window.reset();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2038
        widget.reset();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2039
        widget.acceptMouseEvent = true; // doesn't matter, touch events are propagated first
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2040
        window.acceptTouchEvent = true;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2041
        qt_translateRawTouchEvent(&window, QTouchEvent::TouchScreen, pressedTouchPoints);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2042
        qt_translateRawTouchEvent(&window, QTouchEvent::TouchScreen, releasedTouchPoints);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2043
        QVERIFY(!widget.seenTouchEvent);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2044
        QVERIFY(!widget.seenMouseEvent);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2045
        QVERIFY(window.seenTouchEvent);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2046
        QVERIFY(!window.seenMouseEvent);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2047
    }
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2048
}
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2049
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2050
void tst_QApplication::symbianNoApplicationPanes()
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2051
{
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2052
#ifndef Q_OS_SYMBIAN
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2053
    QSKIP("This is a Symbian only test", SkipAll);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2054
#else
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2055
    QApplication::setAttribute(Qt::AA_S60DontConstructApplicationPanes);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2056
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2057
    // Run in a block so that QApplication is destroyed before resetting the attribute.
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2058
    {
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2059
        // Actually I wasn't able to get the forced orientation change to work properly,
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2060
        // but I'll leave the code here for the future in case we manage to test that
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2061
        // later. If someone knows how to force an orientation switch in an autotest, do
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2062
        // feel free to fix this testcase.
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2063
        int argc = 0;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2064
        QApplication app(argc, 0);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2065
        QWidget *w;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2066
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2067
        w = new QWidget;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2068
        w->show();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2069
        QT_TRAP_THROWING(static_cast<CAknAppUi *>(CCoeEnv::Static()->AppUi())
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2070
                ->SetOrientationL(CAknAppUi::EAppUiOrientationLandscape));
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2071
        app.processEvents();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2072
        delete w;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2073
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2074
        w = new QWidget;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2075
        w->show();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2076
        QT_TRAP_THROWING(static_cast<CAknAppUi *>(CCoeEnv::Static()->AppUi())
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2077
                ->SetOrientationL(CAknAppUi::EAppUiOrientationPortrait));
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2078
        app.processEvents();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2079
        delete w;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2080
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2081
        w = new QWidget;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2082
        w->showMaximized();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2083
        QT_TRAP_THROWING(static_cast<CAknAppUi *>(CCoeEnv::Static()->AppUi())
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2084
                ->SetOrientationL(CAknAppUi::EAppUiOrientationLandscape));
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2085
        app.processEvents();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2086
        delete w;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2087
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2088
        w = new QWidget;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2089
        w->showMaximized();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2090
        QT_TRAP_THROWING(static_cast<CAknAppUi *>(CCoeEnv::Static()->AppUi())
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2091
                ->SetOrientationL(CAknAppUi::EAppUiOrientationPortrait));
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2092
        app.processEvents();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2093
        delete w;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2094
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2095
        w = new QWidget;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2096
        w->showFullScreen();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2097
        QT_TRAP_THROWING(static_cast<CAknAppUi *>(CCoeEnv::Static()->AppUi())
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2098
                ->SetOrientationL(CAknAppUi::EAppUiOrientationLandscape));
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2099
        app.processEvents();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2100
        delete w;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2101
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2102
        w = new QWidget;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2103
        w->showFullScreen();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2104
        QT_TRAP_THROWING(static_cast<CAknAppUi *>(CCoeEnv::Static()->AppUi())
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2105
                ->SetOrientationL(CAknAppUi::EAppUiOrientationPortrait));
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2106
        app.processEvents();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2107
        delete w;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2108
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2109
        // These will have no effect, since there is no status pane, but they shouldn't
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2110
        // crash either.
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2111
        w = new QWidget;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2112
        w->show();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2113
        w->setWindowTitle("Testing title");
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2114
        app.processEvents();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2115
        delete w;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2116
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2117
        w = new QWidget;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2118
        w->show();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2119
        w->setWindowIcon(QIcon(QPixmap("heart.svg")));
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2120
        app.processEvents();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2121
        delete w;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2122
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2123
        QDesktopWidget desktop;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2124
        QCOMPARE(desktop.availableGeometry(), desktop.screenGeometry());
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2125
    }
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2126
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2127
    QApplication::setAttribute(Qt::AA_S60DontConstructApplicationPanes, false);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2128
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2129
    // No other error condition. Program will crash if unsuccessful.
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2130
#endif
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2131
}
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2132
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2133
#ifdef Q_OS_SYMBIAN
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2134
class CBaseDummy : public CBase
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2135
{
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2136
public:
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2137
    CBaseDummy(int *numDestroyed) : numDestroyed(numDestroyed)
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2138
    {
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2139
    }
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2140
    ~CBaseDummy()
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2141
    {
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2142
        (*numDestroyed)++;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2143
    }
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2144
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2145
private:
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2146
    int *numDestroyed;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2147
};
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2148
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2149
static void fakeMain(int *numDestroyed)
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2150
{
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2151
    // Push a few objects, just so that the cleanup stack has something to clean up.
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2152
    CleanupStack::PushL(new (ELeave) CBaseDummy(numDestroyed));
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2153
    int argc = 0;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2154
    QApplication app(argc, 0);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2155
    CleanupStack::PushL(new (ELeave) CBaseDummy(numDestroyed));
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2156
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2157
    User::Leave(KErrGeneral); // Fake error
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2158
}
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2159
#endif
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2160
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2161
void tst_QApplication::symbianNeedForTraps()
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2162
{
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2163
#ifndef Q_OS_SYMBIAN
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2164
    QSKIP("This is a Symbian-only test", SkipAll);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2165
#else
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2166
    int argc = 0;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2167
    QApplication app(argc, 0);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2168
    int numDestroyed = 0;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2169
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2170
    // This next part should not require a trap. If it does, the test will crash.
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2171
    CleanupStack::PushL(new (ELeave) CBaseDummy(&numDestroyed));
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2172
    CleanupStack::PopAndDestroy();
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2173
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2174
    QCOMPARE(numDestroyed, 1);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2175
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2176
    // No other failure condition. The program will crash if it does not pass.
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2177
#endif
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2178
}
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2179
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2180
void tst_QApplication::symbianLeaveThroughMain()
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2181
{
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2182
#ifndef Q_OS_SYMBIAN
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2183
    QSKIP("This is a Symbian-only test", SkipAll);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2184
#else
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2185
    int numDestroyed = 0;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2186
    TInt err;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2187
    TRAP(err, fakeMain(&numDestroyed));
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2188
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2189
    QCOMPARE(numDestroyed, 2);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2190
#endif
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2191
}
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2192
*/
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2193
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2194
//QTEST_APPLESS_MAIN(tst_QApplication)
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2195
int main(int argc, char *argv[])
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2196
{
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2197
    tst_QApplication tc;
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2198
    argv0 = argv[0];
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2199
    return QTest::qExec(&tc, argc, argv);
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2200
}
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2201
72f7e4177ac7 Smoketest for Qt: Gestures and QApplication
Brendan Donegan <brendand@symbian.org>
parents:
diff changeset
  2202
#include "smoketest_qapplication.moc"