qt/qapplication/smoke_qapplication.cpp
branchSymbian3
changeset 43 14fcccfb4c0c
parent 41 72f7e4177ac7
equal deleted inserted replaced
42:4f2786c97bf4 43:14fcccfb4c0c
       
     1 /****************************************************************************
       
     2 **
       
     3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
       
     4 ** All rights reserved.
       
     5 ** Contact: Nokia Corporation (qt-info@nokia.com)
       
     6 **
       
     7 ** This file is part of the test suite of the Qt Toolkit.
       
     8 **
       
     9 ** $QT_BEGIN_LICENSE:LGPL$
       
    10 ** No Commercial Usage
       
    11 ** This file contains pre-release code and may not be distributed.
       
    12 ** You may use this file in accordance with the terms and conditions
       
    13 ** contained in the Technology Preview License Agreement accompanying
       
    14 ** this package.
       
    15 **
       
    16 ** GNU Lesser General Public License Usage
       
    17 ** Alternatively, this file may be used under the terms of the GNU Lesser
       
    18 ** General Public License version 2.1 as published by the Free Software
       
    19 ** Foundation and appearing in the file LICENSE.LGPL included in the
       
    20 ** packaging of this file.  Please review the following information to
       
    21 ** ensure the GNU Lesser General Public License version 2.1 requirements
       
    22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
       
    23 **
       
    24 ** In addition, as a special exception, Nokia gives you certain additional
       
    25 ** rights.  These rights are described in the Nokia Qt LGPL Exception
       
    26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
       
    27 **
       
    28 ** If you have questions regarding the use of this file, please contact
       
    29 ** Nokia at qt-info@nokia.com.
       
    30 **
       
    31 **
       
    32 **
       
    33 **
       
    34 **
       
    35 **
       
    36 **
       
    37 **
       
    38 ** $QT_END_LICENSE$
       
    39 **
       
    40 ****************************************************************************/
       
    41 
       
    42 
       
    43 //#define QT_TST_QAPP_DEBUG
       
    44 #include <qdebug.h>
       
    45 
       
    46 #include <QtTest/QtTest>
       
    47 
       
    48 #include "qabstracteventdispatcher.h"
       
    49 #include <QtGui>
       
    50 
       
    51 #include "private/qapplication_p.h"
       
    52 #include "private/qstylesheetstyle_p.h"
       
    53 #ifdef Q_OS_WINCE
       
    54 #include <windows.h>
       
    55 #endif
       
    56 #ifdef Q_OS_SYMBIAN
       
    57 #include <aknenv.h>
       
    58 #endif
       
    59 
       
    60 //TESTED_CLASS=
       
    61 //TESTED_FILES=
       
    62 
       
    63 #if defined(Q_OS_SYMBIAN)
       
    64 // In Symbian, the PluginsPath doesn't specify the only absolute path; just the dir that can be found on any drive
       
    65 /*static void addExpectedSymbianPluginsPath(QStringList& expected)
       
    66 {
       
    67     QString installPathPlugins = QDir::fromNativeSeparators(QLibraryInfo::location(QLibraryInfo::PluginsPath));
       
    68     QFileInfoList driveList = QDir::drives();
       
    69     QListIterator<QFileInfo> iter(driveList);
       
    70     while (iter.hasNext()) {
       
    71         QFileInfo testFi(iter.next().canonicalPath().append(installPathPlugins));
       
    72         if (testFi.exists())
       
    73             expected << testFi.canonicalFilePath();
       
    74     }
       
    75 }
       
    76 */
       
    77 #endif
       
    78 
       
    79 class tst_QApplication : public QObject
       
    80 {
       
    81 Q_OBJECT
       
    82 
       
    83 public:
       
    84     tst_QApplication();
       
    85     virtual ~tst_QApplication();
       
    86 
       
    87 public slots:
       
    88     void init();
       
    89     void cleanup();
       
    90 private slots:
       
    91     void setActiveWindow();
       
    92 };
       
    93 
       
    94 static  char *argv0;
       
    95 
       
    96 tst_QApplication::tst_QApplication()
       
    97 {
       
    98 #ifdef Q_OS_WINCE
       
    99     // Clean up environment previously to launching test
       
   100     qputenv("QT_PLUGIN_PATH", QByteArray());
       
   101 #endif
       
   102 }
       
   103 
       
   104 tst_QApplication::~tst_QApplication()
       
   105 {
       
   106 
       
   107 }
       
   108 
       
   109 void tst_QApplication::init()
       
   110 {
       
   111 // TODO: Add initialization code here.
       
   112 // This will be executed immediately before each test is run.
       
   113 }
       
   114 
       
   115 void tst_QApplication::cleanup()
       
   116 {
       
   117 // TODO: Add cleanup code here.
       
   118 // This will be executed immediately after each test is run.
       
   119 }
       
   120 
       
   121 void tst_QApplication::setActiveWindow()
       
   122 {
       
   123     int argc = 0;
       
   124     QApplication MyApp(argc, 0, QApplication::GuiServer);
       
   125 
       
   126     QWidget* w = new QWidget;
       
   127     QVBoxLayout* layout = new QVBoxLayout(w);
       
   128 
       
   129     QLineEdit* pb1 = new QLineEdit("Testbutton1", w);
       
   130     QLineEdit* pb2 = new QLineEdit("Test Line Edit", w);
       
   131 
       
   132     layout->addWidget(pb1);
       
   133     layout->addWidget(pb2);
       
   134 
       
   135     pb2->setFocus();
       
   136     pb2->setParent(0);
       
   137     delete pb2;
       
   138 
       
   139     w->show();
       
   140     QApplication::setActiveWindow(w); // needs this on twm (focus follows mouse)
       
   141     QVERIFY(pb1->hasFocus());
       
   142     delete w;
       
   143 }
       
   144 
       
   145 //QTEST_APPLESS_MAIN(tst_QApplication)
       
   146 int main(int argc, char *argv[])
       
   147 {
       
   148     tst_QApplication tc;
       
   149     argv0 = argv[0];
       
   150     return QTest::qExec(&tc, argc, argv);
       
   151 }
       
   152 
       
   153 #include "smoke_qapplication.moc"