tests/auto/qstyle/tst_qstyle.cpp
branchRCL_3
changeset 5 d3bac044e0f0
parent 4 3b1da2848fc7
equal deleted inserted replaced
4:3b1da2848fc7 5:d3bac044e0f0
    50 #include <qwidget.h>
    50 #include <qwidget.h>
    51 #include <qlabel.h>
    51 #include <qlabel.h>
    52 #include <qstyleoption.h>
    52 #include <qstyleoption.h>
    53 #include <qscrollbar.h>
    53 #include <qscrollbar.h>
    54 #include <qprogressbar.h>
    54 #include <qprogressbar.h>
       
    55 #include <qtoolbutton.h>
    55 
    56 
    56 #include <qplastiquestyle.h>
    57 #include <qplastiquestyle.h>
    57 #include <qwindowsstyle.h>
    58 #include <qwindowsstyle.h>
    58 #include <qcdestyle.h>
    59 #include <qcdestyle.h>
    59 #include <qmotifstyle.h>
    60 #include <qmotifstyle.h>
   443     QWindowsVistaStyle vistastyle;
   444     QWindowsVistaStyle vistastyle;
   444     testAllFunctions(&vistastyle);
   445     testAllFunctions(&vistastyle);
   445 
   446 
   446     if (QSysInfo::WindowsVersion == QSysInfo::WV_VISTA)
   447     if (QSysInfo::WindowsVersion == QSysInfo::WV_VISTA)
   447         testPainting(&vistastyle, "vista");
   448         testPainting(&vistastyle, "vista");
       
   449     else if (QSysInfo::WindowsVersion == QSysInfo::WV_XP)
       
   450         testPainting(&vistastyle, "xp");
   448 #endif
   451 #endif
   449 }
   452 }
   450 
   453 
   451 void comparePixmap(const QString &filename, const QPixmap &pixmap)
   454 void comparePixmap(const QString &filename, const QPixmap &pixmap)
   452 {
   455 {
   458         writeImage(filename, pixmap.toImage());
   461         writeImage(filename, pixmap.toImage());
   459 }
   462 }
   460 
   463 
   461 void tst_QStyle::testPainting(QStyle *style, const QString &platform)
   464 void tst_QStyle::testPainting(QStyle *style, const QString &platform)
   462 {
   465 {
       
   466 qDebug("TEST PAINTING");
   463     //Test Menu
   467     //Test Menu
   464     QString fileName = "images/" + platform + "/menu.png";
   468     QString fileName = "images/" + platform + "/menu.png";
   465     QMenu menu;
   469     QMenu menu;
   466     menu.setStyle(style);
   470     menu.setStyle(style);
   467     menu.show();
   471     menu.show();
   536     mdiArea.setStyle(style);
   540     mdiArea.setStyle(style);
   537     mdiArea.show();
   541     mdiArea.show();
   538     pixmap = QPixmap::grabWidget(&mdiArea);
   542     pixmap = QPixmap::grabWidget(&mdiArea);
   539     mdiArea.hide();
   543     mdiArea.hide();
   540     comparePixmap(fileName, pixmap);
   544     comparePixmap(fileName, pixmap);
       
   545 
       
   546     // QToolButton
       
   547     fileName = "images/" + platform + "/toolbutton.png";
       
   548     QToolButton tb;
       
   549     tb.setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
       
   550     tb.setText("AaQqPpXx");
       
   551     tb.setIcon(style->standardPixmap(QStyle::SP_DirHomeIcon));
       
   552     tb.setStyle(style);
       
   553     tb.show();
       
   554     pixmap = QPixmap::grabWidget(&tb);
       
   555     tb.hide();
       
   556     comparePixmap(fileName, pixmap);
       
   557 
   541 }
   558 }
   542 
   559 
   543 void tst_QStyle::testMacStyle()
   560 void tst_QStyle::testMacStyle()
   544 {
   561 {
   545 #ifdef Q_WS_MAC
   562 #ifdef Q_WS_MAC