tests/auto/qapplication/tst_qapplication.cpp
branchRCL_3
changeset 4 3b1da2848fc7
parent 3 41300fa6a67c
equal deleted inserted replaced
3:41300fa6a67c 4:3b1da2848fc7
     1 /****************************************************************************
     1 /****************************************************************************
     2 **
     2 **
     3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
     3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     4 ** All rights reserved.
     4 ** All rights reserved.
     5 ** Contact: Nokia Corporation (qt-info@nokia.com)
     5 ** Contact: Nokia Corporation (qt-info@nokia.com)
     6 **
     6 **
     7 ** This file is part of the test suite of the Qt Toolkit.
     7 ** This file is part of the test suite of the Qt Toolkit.
     8 **
     8 **
    51 #include "private/qapplication_p.h"
    51 #include "private/qapplication_p.h"
    52 #include "private/qstylesheetstyle_p.h"
    52 #include "private/qstylesheetstyle_p.h"
    53 #ifdef Q_OS_WINCE
    53 #ifdef Q_OS_WINCE
    54 #include <windows.h>
    54 #include <windows.h>
    55 #endif
    55 #endif
       
    56 #ifdef Q_OS_SYMBIAN
       
    57 #include <aknenv.h>
       
    58 #endif
    56 
    59 
    57 //TESTED_CLASS=
    60 //TESTED_CLASS=
    58 //TESTED_FILES=
    61 //TESTED_FILES=
    59 
    62 
    60 #if defined(Q_OS_SYMBIAN)
    63 #if defined(Q_OS_SYMBIAN)
   135 
   138 
   136     void windowsCommandLine_data();
   139     void windowsCommandLine_data();
   137     void windowsCommandLine();
   140     void windowsCommandLine();
   138 
   141 
   139     void touchEventPropagation();
   142     void touchEventPropagation();
       
   143 
       
   144     void symbianNoApplicationPanes();
   140 
   145 
   141     void symbianNeedForTraps();
   146     void symbianNeedForTraps();
   142     void symbianLeaveThroughMain();
   147     void symbianLeaveThroughMain();
   143 };
   148 };
   144 
   149 
  2034         QVERIFY(window.seenTouchEvent);
  2039         QVERIFY(window.seenTouchEvent);
  2035         QVERIFY(!window.seenMouseEvent);
  2040         QVERIFY(!window.seenMouseEvent);
  2036     }
  2041     }
  2037 }
  2042 }
  2038 
  2043 
       
  2044 void tst_QApplication::symbianNoApplicationPanes()
       
  2045 {
       
  2046 #ifndef Q_OS_SYMBIAN
       
  2047     QSKIP("This is a Symbian only test", SkipAll);
       
  2048 #else
       
  2049     QApplication::setAttribute(Qt::AA_S60DontConstructApplicationPanes);
       
  2050 
       
  2051     // Run in a block so that QApplication is destroyed before resetting the attribute.
       
  2052     {
       
  2053         // Actually I wasn't able to get the forced orientation change to work properly,
       
  2054         // but I'll leave the code here for the future in case we manage to test that
       
  2055         // later. If someone knows how to force an orientation switch in an autotest, do
       
  2056         // feel free to fix this testcase.
       
  2057         int argc = 0;
       
  2058         QApplication app(argc, 0);
       
  2059         QWidget *w;
       
  2060 
       
  2061         w = new QWidget;
       
  2062         w->show();
       
  2063         QT_TRAP_THROWING(static_cast<CAknAppUi *>(CCoeEnv::Static()->AppUi())
       
  2064                 ->SetOrientationL(CAknAppUi::EAppUiOrientationLandscape));
       
  2065         app.processEvents();
       
  2066         delete w;
       
  2067 
       
  2068         w = new QWidget;
       
  2069         w->show();
       
  2070         QT_TRAP_THROWING(static_cast<CAknAppUi *>(CCoeEnv::Static()->AppUi())
       
  2071                 ->SetOrientationL(CAknAppUi::EAppUiOrientationPortrait));
       
  2072         app.processEvents();
       
  2073         delete w;
       
  2074 
       
  2075         w = new QWidget;
       
  2076         w->showMaximized();
       
  2077         QT_TRAP_THROWING(static_cast<CAknAppUi *>(CCoeEnv::Static()->AppUi())
       
  2078                 ->SetOrientationL(CAknAppUi::EAppUiOrientationLandscape));
       
  2079         app.processEvents();
       
  2080         delete w;
       
  2081 
       
  2082         w = new QWidget;
       
  2083         w->showMaximized();
       
  2084         QT_TRAP_THROWING(static_cast<CAknAppUi *>(CCoeEnv::Static()->AppUi())
       
  2085                 ->SetOrientationL(CAknAppUi::EAppUiOrientationPortrait));
       
  2086         app.processEvents();
       
  2087         delete w;
       
  2088 
       
  2089         w = new QWidget;
       
  2090         w->showFullScreen();
       
  2091         QT_TRAP_THROWING(static_cast<CAknAppUi *>(CCoeEnv::Static()->AppUi())
       
  2092                 ->SetOrientationL(CAknAppUi::EAppUiOrientationLandscape));
       
  2093         app.processEvents();
       
  2094         delete w;
       
  2095 
       
  2096         w = new QWidget;
       
  2097         w->showFullScreen();
       
  2098         QT_TRAP_THROWING(static_cast<CAknAppUi *>(CCoeEnv::Static()->AppUi())
       
  2099                 ->SetOrientationL(CAknAppUi::EAppUiOrientationPortrait));
       
  2100         app.processEvents();
       
  2101         delete w;
       
  2102 
       
  2103         // These will have no effect, since there is no status pane, but they shouldn't
       
  2104         // crash either.
       
  2105         w = new QWidget;
       
  2106         w->show();
       
  2107         w->setWindowTitle("Testing title");
       
  2108         app.processEvents();
       
  2109         delete w;
       
  2110 
       
  2111         w = new QWidget;
       
  2112         w->show();
       
  2113         w->setWindowIcon(QIcon(QPixmap("heart.svg")));
       
  2114         app.processEvents();
       
  2115         delete w;
       
  2116 
       
  2117         QDesktopWidget desktop;
       
  2118         QCOMPARE(desktop.availableGeometry(), desktop.screenGeometry());
       
  2119     }
       
  2120 
       
  2121     QApplication::setAttribute(Qt::AA_S60DontConstructApplicationPanes, false);
       
  2122 
       
  2123     // No other error condition. Program will crash if unsuccessful.
       
  2124 #endif
       
  2125 }
       
  2126 
  2039 #ifdef Q_OS_SYMBIAN
  2127 #ifdef Q_OS_SYMBIAN
  2040 class CBaseDummy : public CBase
  2128 class CBaseDummy : public CBase
  2041 {
  2129 {
  2042 public:
  2130 public:
  2043     CBaseDummy(int *numDestroyed) : numDestroyed(numDestroyed)
  2131     CBaseDummy(int *numDestroyed) : numDestroyed(numDestroyed)