summaryrefslogtreecommitdiffstats
path: root/tests/auto/widgets/widgets
diff options
context:
space:
mode:
authorJo Asplin <jo.asplin@nokia.com>2011-10-20 13:17:26 +0200
committerQt by Nokia <qt-info@nokia.com>2011-10-20 19:45:41 +0200
commit9f1aa866bda7678261f2f441d4cfd5bb524c2411 (patch)
tree5028f578122e7feb9200d571405494c73d96db89 /tests/auto/widgets/widgets
parent78d02e93aca5325fc5be9bfd275862795207abaa (diff)
Moved tests into integrationtests/ and widgets/
Task-number: QTBUG-19013 Change-Id: Ibb776f5967c0645ce6d22ef7afdc40657c575461 Reviewed-by: Holger Ihrig <holger.ihrig@nokia.com>
Diffstat (limited to 'tests/auto/widgets/widgets')
-rw-r--r--tests/auto/widgets/widgets/qabstractbutton/.gitignore1
-rw-r--r--tests/auto/widgets/widgets/qabstractbutton/qabstractbutton.pro5
-rw-r--r--tests/auto/widgets/widgets/qabstractbutton/tst_qabstractbutton.cpp650
-rw-r--r--tests/auto/widgets/widgets/qabstractscrollarea/.gitignore1
-rw-r--r--tests/auto/widgets/widgets/qabstractscrollarea/qabstractscrollarea.pro9
-rw-r--r--tests/auto/widgets/widgets/qabstractscrollarea/tst_qabstractscrollarea.cpp390
-rw-r--r--tests/auto/widgets/widgets/qabstractslider/.gitignore1
-rw-r--r--tests/auto/widgets/widgets/qabstractslider/qabstractslider.pro5
-rw-r--r--tests/auto/widgets/widgets/qabstractslider/tst_qabstractslider.cpp1247
-rw-r--r--tests/auto/widgets/widgets/qabstractspinbox/.gitignore1
-rw-r--r--tests/auto/widgets/widgets/qabstractspinbox/qabstractspinbox.pro9
-rw-r--r--tests/auto/widgets/widgets/qabstractspinbox/tst_qabstractspinbox.cpp163
-rw-r--r--tests/auto/widgets/widgets/qbuttongroup/.gitignore1
-rw-r--r--tests/auto/widgets/widgets/qbuttongroup/qbuttongroup.pro6
-rw-r--r--tests/auto/widgets/widgets/qbuttongroup/tst_qbuttongroup.cpp525
-rw-r--r--tests/auto/widgets/widgets/qcalendarwidget/.gitignore1
-rw-r--r--tests/auto/widgets/widgets/qcalendarwidget/qcalendarwidget.pro5
-rw-r--r--tests/auto/widgets/widgets/qcalendarwidget/tst_qcalendarwidget.cpp368
-rw-r--r--tests/auto/widgets/widgets/qcheckbox/.gitignore1
-rw-r--r--tests/auto/widgets/widgets/qcheckbox/qcheckbox.pro6
-rw-r--r--tests/auto/widgets/widgets/qcheckbox/tst_qcheckbox.cpp358
-rw-r--r--tests/auto/widgets/widgets/qcombobox/.gitignore1
-rw-r--r--tests/auto/widgets/widgets/qcombobox/qcombobox.pro3
-rw-r--r--tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp2579
-rw-r--r--tests/auto/widgets/widgets/qcommandlinkbutton/.gitignore1
-rw-r--r--tests/auto/widgets/widgets/qcommandlinkbutton/qcommandlinkbutton.pro6
-rw-r--r--tests/auto/widgets/widgets/qcommandlinkbutton/tst_qcommandlinkbutton.cpp590
-rw-r--r--tests/auto/widgets/widgets/qdatetimeedit/.gitignore1
-rw-r--r--tests/auto/widgets/widgets/qdatetimeedit/qdatetimeedit.pro8
-rw-r--r--tests/auto/widgets/widgets/qdatetimeedit/tst_qdatetimeedit.cpp3458
-rw-r--r--tests/auto/widgets/widgets/qdial/.gitignore1
-rw-r--r--tests/auto/widgets/widgets/qdial/qdial.pro5
-rw-r--r--tests/auto/widgets/widgets/qdial/tst_qdial.cpp211
-rw-r--r--tests/auto/widgets/widgets/qdialogbuttonbox/.gitignore1
-rw-r--r--tests/auto/widgets/widgets/qdialogbuttonbox/qdialogbuttonbox.pro7
-rw-r--r--tests/auto/widgets/widgets/qdialogbuttonbox/tst_qdialogbuttonbox.cpp810
-rw-r--r--tests/auto/widgets/widgets/qdockwidget/.gitignore1
-rw-r--r--tests/auto/widgets/widgets/qdockwidget/qdockwidget.pro7
-rw-r--r--tests/auto/widgets/widgets/qdockwidget/tst_qdockwidget.cpp877
-rw-r--r--tests/auto/widgets/widgets/qdoublespinbox/.gitignore1
-rw-r--r--tests/auto/widgets/widgets/qdoublespinbox/qdoublespinbox.pro5
-rw-r--r--tests/auto/widgets/widgets/qdoublespinbox/tst_qdoublespinbox.cpp1111
-rw-r--r--tests/auto/widgets/widgets/qdoublevalidator/.gitignore1
-rw-r--r--tests/auto/widgets/widgets/qdoublevalidator/qdoublevalidator.pro5
-rw-r--r--tests/auto/widgets/widgets/qdoublevalidator/tst_qdoublevalidator.cpp387
-rw-r--r--tests/auto/widgets/widgets/qfocusframe/.gitignore1
-rw-r--r--tests/auto/widgets/widgets/qfocusframe/qfocusframe.pro9
-rw-r--r--tests/auto/widgets/widgets/qfocusframe/tst_qfocusframe.cpp89
-rw-r--r--tests/auto/widgets/widgets/qfontcombobox/.gitignore1
-rw-r--r--tests/auto/widgets/widgets/qfontcombobox/qfontcombobox.pro5
-rw-r--r--tests/auto/widgets/widgets/qfontcombobox/tst_qfontcombobox.cpp303
-rw-r--r--tests/auto/widgets/widgets/qgroupbox/.gitignore1
-rw-r--r--tests/auto/widgets/widgets/qgroupbox/qgroupbox.pro6
-rw-r--r--tests/auto/widgets/widgets/qgroupbox/tst_qgroupbox.cpp475
-rw-r--r--tests/auto/widgets/widgets/qintvalidator/.gitignore1
-rw-r--r--tests/auto/widgets/widgets/qintvalidator/qintvalidator.pro4
-rw-r--r--tests/auto/widgets/widgets/qintvalidator/tst_qintvalidator.cpp255
-rw-r--r--tests/auto/widgets/widgets/qlabel/.gitignore1
-rw-r--r--tests/auto/widgets/widgets/qlabel/green.pngbin0 -> 97 bytes
-rw-r--r--tests/auto/widgets/widgets/qlabel/qlabel.pro15
-rw-r--r--tests/auto/widgets/widgets/qlabel/red.pngbin0 -> 105 bytes
-rw-r--r--tests/auto/widgets/widgets/qlabel/testdata/acc_01/res_Windows_data0.qsnapbin0 -> 328 bytes
-rw-r--r--tests/auto/widgets/widgets/qlabel/testdata/acc_01/res_Windows_win32_data0.qsnapbin0 -> 330 bytes
-rw-r--r--tests/auto/widgets/widgets/qlabel/testdata/setAlignment/alignRes_Motif_data0.qsnapbin0 -> 322 bytes
-rw-r--r--tests/auto/widgets/widgets/qlabel/testdata/setAlignment/alignRes_Motif_data1.qsnapbin0 -> 328 bytes
-rw-r--r--tests/auto/widgets/widgets/qlabel/testdata/setAlignment/alignRes_Motif_data10.qsnapbin0 -> 330 bytes
-rw-r--r--tests/auto/widgets/widgets/qlabel/testdata/setAlignment/alignRes_Motif_data2.qsnapbin0 -> 324 bytes
-rw-r--r--tests/auto/widgets/widgets/qlabel/testdata/setAlignment/alignRes_Motif_data3.qsnapbin0 -> 320 bytes
-rw-r--r--tests/auto/widgets/widgets/qlabel/testdata/setAlignment/alignRes_Motif_data4.qsnapbin0 -> 322 bytes
-rw-r--r--tests/auto/widgets/widgets/qlabel/testdata/setAlignment/alignRes_Motif_data5.qsnapbin0 -> 328 bytes
-rw-r--r--tests/auto/widgets/widgets/qlabel/testdata/setAlignment/alignRes_Motif_data6.qsnapbin0 -> 330 bytes
-rw-r--r--tests/auto/widgets/widgets/qlabel/testdata/setAlignment/alignRes_Motif_data7.qsnapbin0 -> 318 bytes
-rw-r--r--tests/auto/widgets/widgets/qlabel/testdata/setAlignment/alignRes_Motif_data8.qsnapbin0 -> 324 bytes
-rw-r--r--tests/auto/widgets/widgets/qlabel/testdata/setAlignment/alignRes_Motif_data9.qsnapbin0 -> 332 bytes
-rw-r--r--tests/auto/widgets/widgets/qlabel/testdata/setAlignment/alignRes_Windows_data0.qsnapbin0 -> 316 bytes
-rw-r--r--tests/auto/widgets/widgets/qlabel/testdata/setAlignment/alignRes_Windows_data1.qsnapbin0 -> 322 bytes
-rw-r--r--tests/auto/widgets/widgets/qlabel/testdata/setAlignment/alignRes_Windows_data10.qsnapbin0 -> 324 bytes
-rw-r--r--tests/auto/widgets/widgets/qlabel/testdata/setAlignment/alignRes_Windows_data2.qsnapbin0 -> 318 bytes
-rw-r--r--tests/auto/widgets/widgets/qlabel/testdata/setAlignment/alignRes_Windows_data3.qsnapbin0 -> 314 bytes
-rw-r--r--tests/auto/widgets/widgets/qlabel/testdata/setAlignment/alignRes_Windows_data4.qsnapbin0 -> 316 bytes
-rw-r--r--tests/auto/widgets/widgets/qlabel/testdata/setAlignment/alignRes_Windows_data5.qsnapbin0 -> 322 bytes
-rw-r--r--tests/auto/widgets/widgets/qlabel/testdata/setAlignment/alignRes_Windows_data6.qsnapbin0 -> 324 bytes
-rw-r--r--tests/auto/widgets/widgets/qlabel/testdata/setAlignment/alignRes_Windows_data7.qsnapbin0 -> 312 bytes
-rw-r--r--tests/auto/widgets/widgets/qlabel/testdata/setAlignment/alignRes_Windows_data8.qsnapbin0 -> 318 bytes
-rw-r--r--tests/auto/widgets/widgets/qlabel/testdata/setAlignment/alignRes_Windows_data9.qsnapbin0 -> 326 bytes
-rw-r--r--tests/auto/widgets/widgets/qlabel/testdata/setAlignment/alignRes_Windows_win32_data0.qsnapbin0 -> 318 bytes
-rw-r--r--tests/auto/widgets/widgets/qlabel/testdata/setAlignment/alignRes_Windows_win32_data1.qsnapbin0 -> 324 bytes
-rw-r--r--tests/auto/widgets/widgets/qlabel/testdata/setAlignment/alignRes_Windows_win32_data10.qsnapbin0 -> 326 bytes
-rw-r--r--tests/auto/widgets/widgets/qlabel/testdata/setAlignment/alignRes_Windows_win32_data2.qsnapbin0 -> 320 bytes
-rw-r--r--tests/auto/widgets/widgets/qlabel/testdata/setAlignment/alignRes_Windows_win32_data3.qsnapbin0 -> 316 bytes
-rw-r--r--tests/auto/widgets/widgets/qlabel/testdata/setAlignment/alignRes_Windows_win32_data4.qsnapbin0 -> 318 bytes
-rw-r--r--tests/auto/widgets/widgets/qlabel/testdata/setAlignment/alignRes_Windows_win32_data5.qsnapbin0 -> 324 bytes
-rw-r--r--tests/auto/widgets/widgets/qlabel/testdata/setAlignment/alignRes_Windows_win32_data6.qsnapbin0 -> 326 bytes
-rw-r--r--tests/auto/widgets/widgets/qlabel/testdata/setAlignment/alignRes_Windows_win32_data7.qsnapbin0 -> 314 bytes
-rw-r--r--tests/auto/widgets/widgets/qlabel/testdata/setAlignment/alignRes_Windows_win32_data8.qsnapbin0 -> 320 bytes
-rw-r--r--tests/auto/widgets/widgets/qlabel/testdata/setAlignment/alignRes_Windows_win32_data9.qsnapbin0 -> 328 bytes
-rw-r--r--tests/auto/widgets/widgets/qlabel/testdata/setIndent/indentRes_Motif_data0.qsnapbin0 -> 344 bytes
-rw-r--r--tests/auto/widgets/widgets/qlabel/testdata/setIndent/indentRes_Motif_data1.qsnapbin0 -> 346 bytes
-rw-r--r--tests/auto/widgets/widgets/qlabel/testdata/setIndent/indentRes_Motif_data2.qsnapbin0 -> 346 bytes
-rw-r--r--tests/auto/widgets/widgets/qlabel/testdata/setIndent/indentRes_Windows_data0.qsnapbin0 -> 338 bytes
-rw-r--r--tests/auto/widgets/widgets/qlabel/testdata/setIndent/indentRes_Windows_data1.qsnapbin0 -> 340 bytes
-rw-r--r--tests/auto/widgets/widgets/qlabel/testdata/setIndent/indentRes_Windows_data2.qsnapbin0 -> 340 bytes
-rw-r--r--tests/auto/widgets/widgets/qlabel/testdata/setIndent/indentRes_Windows_win32_data0.qsnapbin0 -> 340 bytes
-rw-r--r--tests/auto/widgets/widgets/qlabel/testdata/setIndent/indentRes_Windows_win32_data1.qsnapbin0 -> 342 bytes
-rw-r--r--tests/auto/widgets/widgets/qlabel/testdata/setIndent/indentRes_Windows_win32_data2.qsnapbin0 -> 342 bytes
-rw-r--r--tests/auto/widgets/widgets/qlabel/testdata/setPixmap/Vpix_Motif_data0.qsnapbin0 -> 405 bytes
-rw-r--r--tests/auto/widgets/widgets/qlabel/testdata/setPixmap/Vpix_Windows_data0.qsnapbin0 -> 399 bytes
-rw-r--r--tests/auto/widgets/widgets/qlabel/testdata/setPixmap/Vpix_Windows_win32_data0.qsnapbin0 -> 397 bytes
-rw-r--r--tests/auto/widgets/widgets/qlabel/testdata/setPixmap/empty_Motif_data0.qsnapbin0 -> 257 bytes
-rw-r--r--tests/auto/widgets/widgets/qlabel/testdata/setPixmap/empty_Windows_data0.qsnapbin0 -> 251 bytes
-rw-r--r--tests/auto/widgets/widgets/qlabel/testdata/setPixmap/empty_Windows_win32_data0.qsnapbin0 -> 249 bytes
-rw-r--r--tests/auto/widgets/widgets/qlabel/testdata/setPixmap/scaledVpix_Motif_data0.qsnapbin0 -> 1040 bytes
-rw-r--r--tests/auto/widgets/widgets/qlabel/testdata/setPixmap/scaledVpix_Windows_data0.qsnapbin0 -> 1034 bytes
-rw-r--r--tests/auto/widgets/widgets/qlabel/testdata/setPixmap/scaledVpix_Windows_win32_data0.qsnapbin0 -> 984 bytes
-rw-r--r--tests/auto/widgets/widgets/qlabel/testdata/setText/res_Motif_data0.qsnapbin0 -> 352 bytes
-rw-r--r--tests/auto/widgets/widgets/qlabel/testdata/setText/res_Motif_data1.qsnapbin0 -> 398 bytes
-rw-r--r--tests/auto/widgets/widgets/qlabel/testdata/setText/res_Motif_data2.qsnapbin0 -> 448 bytes
-rw-r--r--tests/auto/widgets/widgets/qlabel/testdata/setText/res_Motif_data3.qsnapbin0 -> 744 bytes
-rw-r--r--tests/auto/widgets/widgets/qlabel/testdata/setText/res_Windows_data0.qsnapbin0 -> 346 bytes
-rw-r--r--tests/auto/widgets/widgets/qlabel/testdata/setText/res_Windows_data1.qsnapbin0 -> 392 bytes
-rw-r--r--tests/auto/widgets/widgets/qlabel/testdata/setText/res_Windows_data2.qsnapbin0 -> 442 bytes
-rw-r--r--tests/auto/widgets/widgets/qlabel/testdata/setText/res_Windows_data3.qsnapbin0 -> 738 bytes
-rw-r--r--tests/auto/widgets/widgets/qlabel/testdata/setText/res_Windows_win32_data0.qsnapbin0 -> 344 bytes
-rw-r--r--tests/auto/widgets/widgets/qlabel/testdata/setText/res_Windows_win32_data1.qsnapbin0 -> 390 bytes
-rw-r--r--tests/auto/widgets/widgets/qlabel/testdata/setText/res_Windows_win32_data2.qsnapbin0 -> 440 bytes
-rw-r--r--tests/auto/widgets/widgets/qlabel/testdata/setText/res_Windows_win32_data3.qsnapbin0 -> 736 bytes
-rw-r--r--tests/auto/widgets/widgets/qlabel/tst_qlabel.cpp581
-rw-r--r--tests/auto/widgets/widgets/qlcdnumber/.gitignore1
-rw-r--r--tests/auto/widgets/widgets/qlcdnumber/qlcdnumber.pro9
-rw-r--r--tests/auto/widgets/widgets/qlcdnumber/tst_qlcdnumber.cpp88
-rw-r--r--tests/auto/widgets/widgets/qlineedit/.gitignore1
-rw-r--r--tests/auto/widgets/widgets/qlineedit/qlineedit.pro5
-rw-r--r--tests/auto/widgets/widgets/qlineedit/testdata/frame/noFrame_Motif-32x96x96_win.pngbin0 -> 30154 bytes
-rw-r--r--tests/auto/widgets/widgets/qlineedit/testdata/frame/noFrame_Windows-32x96x96_win.pngbin0 -> 30154 bytes
-rw-r--r--tests/auto/widgets/widgets/qlineedit/testdata/frame/useFrame_Motif-32x96x96_win.pngbin0 -> 30154 bytes
-rw-r--r--tests/auto/widgets/widgets/qlineedit/testdata/frame/useFrame_Windows-32x96x96_win.pngbin0 -> 30154 bytes
-rw-r--r--tests/auto/widgets/widgets/qlineedit/testdata/setAlignment/auto_Motif-32x96x96_win.pngbin0 -> 30154 bytes
-rw-r--r--tests/auto/widgets/widgets/qlineedit/testdata/setAlignment/auto_Windows-32x96x96_win.pngbin0 -> 30154 bytes
-rw-r--r--tests/auto/widgets/widgets/qlineedit/testdata/setAlignment/hcenter_Motif-32x96x96_win.pngbin0 -> 30154 bytes
-rw-r--r--tests/auto/widgets/widgets/qlineedit/testdata/setAlignment/hcenter_Windows-32x96x96_win.pngbin0 -> 30154 bytes
-rw-r--r--tests/auto/widgets/widgets/qlineedit/testdata/setAlignment/left_Motif-32x96x96_win.pngbin0 -> 30154 bytes
-rw-r--r--tests/auto/widgets/widgets/qlineedit/testdata/setAlignment/left_Windows-32x96x96_win.pngbin0 -> 30154 bytes
-rw-r--r--tests/auto/widgets/widgets/qlineedit/testdata/setAlignment/right_Motif-32x96x96_win.pngbin0 -> 30154 bytes
-rw-r--r--tests/auto/widgets/widgets/qlineedit/testdata/setAlignment/right_Windows-32x96x96_win.pngbin0 -> 30154 bytes
-rw-r--r--tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp3835
-rw-r--r--tests/auto/widgets/widgets/qmainwindow/.gitignore1
-rw-r--r--tests/auto/widgets/widgets/qmainwindow/qmainwindow.pro3
-rw-r--r--tests/auto/widgets/widgets/qmainwindow/tst_qmainwindow.cpp1742
-rw-r--r--tests/auto/widgets/widgets/qmdiarea/.gitignore1
-rw-r--r--tests/auto/widgets/widgets/qmdiarea/qmdiarea.pro14
-rw-r--r--tests/auto/widgets/widgets/qmdiarea/tst_qmdiarea.cpp2773
-rw-r--r--tests/auto/widgets/widgets/qmdisubwindow/.gitignore1
-rw-r--r--tests/auto/widgets/widgets/qmdisubwindow/qmdisubwindow.pro8
-rw-r--r--tests/auto/widgets/widgets/qmdisubwindow/tst_qmdisubwindow.cpp2032
-rw-r--r--tests/auto/widgets/widgets/qmenu/.gitignore1
-rw-r--r--tests/auto/widgets/widgets/qmenu/qmenu.pro5
-rw-r--r--tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp943
-rw-r--r--tests/auto/widgets/widgets/qmenubar/.gitignore1
-rw-r--r--tests/auto/widgets/widgets/qmenubar/qmenubar.pro3
-rw-r--r--tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp1291
-rw-r--r--tests/auto/widgets/widgets/qplaintextedit/.gitignore1
-rw-r--r--tests/auto/widgets/widgets/qplaintextedit/qplaintextedit.pro10
-rw-r--r--tests/auto/widgets/widgets/qplaintextedit/tst_qplaintextedit.cpp1524
-rw-r--r--tests/auto/widgets/widgets/qprogressbar/.gitignore1
-rw-r--r--tests/auto/widgets/widgets/qprogressbar/qprogressbar.pro6
-rw-r--r--tests/auto/widgets/widgets/qprogressbar/tst_qprogressbar.cpp295
-rw-r--r--tests/auto/widgets/widgets/qpushbutton/.gitignore1
-rw-r--r--tests/auto/widgets/widgets/qpushbutton/qpushbutton.pro6
-rw-r--r--tests/auto/widgets/widgets/qpushbutton/testdata/setEnabled/disabled_Windows_win32_data0.qsnapbin0 -> 890 bytes
-rw-r--r--tests/auto/widgets/widgets/qpushbutton/testdata/setEnabled/enabled_Motif_data0.qsnapbin0 -> 758 bytes
-rw-r--r--tests/auto/widgets/widgets/qpushbutton/testdata/setEnabled/enabled_Windows_data0.qsnapbin0 -> 725 bytes
-rw-r--r--tests/auto/widgets/widgets/qpushbutton/testdata/setEnabled/enabled_Windows_win32_data0.qsnapbin0 -> 735 bytes
-rw-r--r--tests/auto/widgets/widgets/qpushbutton/testdata/setPixmap/Vpix_Motif_data0.qsnapbin0 -> 829 bytes
-rw-r--r--tests/auto/widgets/widgets/qpushbutton/testdata/setPixmap/Vpix_Windows_data0.qsnapbin0 -> 796 bytes
-rw-r--r--tests/auto/widgets/widgets/qpushbutton/testdata/setPixmap/Vpix_Windows_win32_data0.qsnapbin0 -> 796 bytes
-rw-r--r--tests/auto/widgets/widgets/qpushbutton/testdata/setText/simple_Motif_data0.qsnapbin0 -> 742 bytes
-rw-r--r--tests/auto/widgets/widgets/qpushbutton/testdata/setText/simple_Windows_data0.qsnapbin0 -> 709 bytes
-rw-r--r--tests/auto/widgets/widgets/qpushbutton/testdata/setText/simple_Windows_win32_data0.qsnapbin0 -> 719 bytes
-rw-r--r--tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp637
-rw-r--r--tests/auto/widgets/widgets/qradiobutton/.gitignore1
-rw-r--r--tests/auto/widgets/widgets/qradiobutton/qradiobutton.pro6
-rw-r--r--tests/auto/widgets/widgets/qradiobutton/tst_qradiobutton.cpp108
-rw-r--r--tests/auto/widgets/widgets/qregexpvalidator/.gitignore1
-rw-r--r--tests/auto/widgets/widgets/qregexpvalidator/qregexpvalidator.pro4
-rw-r--r--tests/auto/widgets/widgets/qregexpvalidator/tst_qregexpvalidator.cpp127
-rw-r--r--tests/auto/widgets/widgets/qscrollarea/.gitignore1
-rw-r--r--tests/auto/widgets/widgets/qscrollarea/qscrollarea.pro9
-rw-r--r--tests/auto/widgets/widgets/qscrollarea/tst_qscrollarea.cpp185
-rw-r--r--tests/auto/widgets/widgets/qscrollbar/.gitignore1
-rw-r--r--tests/auto/widgets/widgets/qscrollbar/qscrollbar.pro6
-rw-r--r--tests/auto/widgets/widgets/qscrollbar/tst_qscrollbar.cpp147
-rw-r--r--tests/auto/widgets/widgets/qsizegrip/.gitignore1
-rw-r--r--tests/auto/widgets/widgets/qsizegrip/qsizegrip.pro6
-rw-r--r--tests/auto/widgets/widgets/qsizegrip/tst_qsizegrip.cpp201
-rw-r--r--tests/auto/widgets/widgets/qslider/.gitignore1
-rw-r--r--tests/auto/widgets/widgets/qslider/qslider.pro9
-rw-r--r--tests/auto/widgets/widgets/qslider/tst_qslider.cpp98
-rw-r--r--tests/auto/widgets/widgets/qspinbox/.gitignore1
-rw-r--r--tests/auto/widgets/widgets/qspinbox/qspinbox.pro3
-rw-r--r--tests/auto/widgets/widgets/qspinbox/tst_qspinbox.cpp1049
-rw-r--r--tests/auto/widgets/widgets/qsplitter/.gitignore1
-rw-r--r--tests/auto/widgets/widgets/qsplitter/extradata.txt10067
-rw-r--r--tests/auto/widgets/widgets/qsplitter/qsplitter.pro12
-rw-r--r--tests/auto/widgets/widgets/qsplitter/setSizes3.dat2250
-rw-r--r--tests/auto/widgets/widgets/qsplitter/tst_qsplitter.cpp777
-rw-r--r--tests/auto/widgets/widgets/qstackedwidget/.gitignore1
-rw-r--r--tests/auto/widgets/widgets/qstackedwidget/qstackedwidget.pro9
-rw-r--r--tests/auto/widgets/widgets/qstackedwidget/tst_qstackedwidget.cpp124
-rw-r--r--tests/auto/widgets/widgets/qstatusbar/.gitignore1
-rw-r--r--tests/auto/widgets/widgets/qstatusbar/qstatusbar.pro6
-rw-r--r--tests/auto/widgets/widgets/qstatusbar/tst_qstatusbar.cpp279
-rw-r--r--tests/auto/widgets/widgets/qtabbar/.gitignore1
-rw-r--r--tests/auto/widgets/widgets/qtabbar/qtabbar.pro6
-rw-r--r--tests/auto/widgets/widgets/qtabbar/tst_qtabbar.cpp655
-rw-r--r--tests/auto/widgets/widgets/qtabwidget/.gitignore1
-rw-r--r--tests/auto/widgets/widgets/qtabwidget/qtabwidget.pro12
-rw-r--r--tests/auto/widgets/widgets/qtabwidget/tst_qtabwidget.cpp680
-rw-r--r--tests/auto/widgets/widgets/qtextbrowser/.gitignore1
-rw-r--r--tests/auto/widgets/widgets/qtextbrowser/anchor.html11
-rw-r--r--tests/auto/widgets/widgets/qtextbrowser/bigpage.html934
-rw-r--r--tests/auto/widgets/widgets/qtextbrowser/firstpage.html2
-rw-r--r--tests/auto/widgets/widgets/qtextbrowser/pagewithbg.html1
-rw-r--r--tests/auto/widgets/widgets/qtextbrowser/pagewithimage.html1
-rw-r--r--tests/auto/widgets/widgets/qtextbrowser/pagewithoutbg.html1
-rw-r--r--tests/auto/widgets/widgets/qtextbrowser/qtextbrowser.pro15
-rw-r--r--tests/auto/widgets/widgets/qtextbrowser/secondpage.html1
-rw-r--r--tests/auto/widgets/widgets/qtextbrowser/subdir/index.html1
-rw-r--r--tests/auto/widgets/widgets/qtextbrowser/thirdpage.html1
-rw-r--r--tests/auto/widgets/widgets/qtextbrowser/tst_qtextbrowser.cpp672
-rw-r--r--tests/auto/widgets/widgets/qtextedit/.gitignore2
-rw-r--r--tests/auto/widgets/widgets/qtextedit/fullWidthSelection/centered-fully-selected.pngbin0 -> 1232 bytes
-rw-r--r--tests/auto/widgets/widgets/qtextedit/fullWidthSelection/centered-partly-selected.pngbin0 -> 1231 bytes
-rw-r--r--tests/auto/widgets/widgets/qtextedit/fullWidthSelection/last-char-on-line.pngbin0 -> 1226 bytes
-rw-r--r--tests/auto/widgets/widgets/qtextedit/fullWidthSelection/last-char-on-parag.pngbin0 -> 1223 bytes
-rw-r--r--tests/auto/widgets/widgets/qtextedit/fullWidthSelection/multiple-full-width-lines.pngbin0 -> 1236 bytes
-rw-r--r--tests/auto/widgets/widgets/qtextedit/fullWidthSelection/nowrap_long.pngbin0 -> 1199 bytes
-rw-r--r--tests/auto/widgets/widgets/qtextedit/fullWidthSelection/single-full-width-line.pngbin0 -> 1225 bytes
-rw-r--r--tests/auto/widgets/widgets/qtextedit/qtextedit.pro18
-rw-r--r--tests/auto/widgets/widgets/qtextedit/tst_qtextedit.cpp2391
-rw-r--r--tests/auto/widgets/widgets/qtoolbar/.gitignore1
-rw-r--r--tests/auto/widgets/widgets/qtoolbar/qtoolbar.pro7
-rw-r--r--tests/auto/widgets/widgets/qtoolbar/tst_qtoolbar.cpp1101
-rw-r--r--tests/auto/widgets/widgets/qtoolbox/.gitignore1
-rw-r--r--tests/auto/widgets/widgets/qtoolbox/qtoolbox.pro6
-rw-r--r--tests/auto/widgets/widgets/qtoolbox/tst_qtoolbox.cpp338
-rw-r--r--tests/auto/widgets/widgets/qtoolbutton/.gitignore1
-rw-r--r--tests/auto/widgets/widgets/qtoolbutton/qtoolbutton.pro3
-rw-r--r--tests/auto/widgets/widgets/qtoolbutton/tst_qtoolbutton.cpp231
-rw-r--r--tests/auto/widgets/widgets/qworkspace/.gitignore1
-rw-r--r--tests/auto/widgets/widgets/qworkspace/qworkspace.pro3
-rw-r--r--tests/auto/widgets/widgets/qworkspace/tst_qworkspace.cpp679
-rw-r--r--tests/auto/widgets/widgets/widgets.pro57
252 files changed, 54144 insertions, 0 deletions
diff --git a/tests/auto/widgets/widgets/qabstractbutton/.gitignore b/tests/auto/widgets/widgets/qabstractbutton/.gitignore
new file mode 100644
index 0000000000..82f669574c
--- /dev/null
+++ b/tests/auto/widgets/widgets/qabstractbutton/.gitignore
@@ -0,0 +1 @@
+tst_qabstractbutton
diff --git a/tests/auto/widgets/widgets/qabstractbutton/qabstractbutton.pro b/tests/auto/widgets/widgets/qabstractbutton/qabstractbutton.pro
new file mode 100644
index 0000000000..15d90ed4e1
--- /dev/null
+++ b/tests/auto/widgets/widgets/qabstractbutton/qabstractbutton.pro
@@ -0,0 +1,5 @@
+load(qttest_p4)
+QT += widgets
+SOURCES += tst_qabstractbutton.cpp
+
+
diff --git a/tests/auto/widgets/widgets/qabstractbutton/tst_qabstractbutton.cpp b/tests/auto/widgets/widgets/qabstractbutton/tst_qabstractbutton.cpp
new file mode 100644
index 0000000000..f5f60c8fd3
--- /dev/null
+++ b/tests/auto/widgets/widgets/qabstractbutton/tst_qabstractbutton.cpp
@@ -0,0 +1,650 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#include <QtTest/QtTest>
+
+
+
+#include <qapplication.h>
+#include <qpainter.h>
+#include <qstyleoption.h>
+#include <qkeysequence.h>
+#include <qevent.h>
+#include <qgridlayout.h>
+
+
+
+#include <qabstractbutton.h>
+
+//TESTED_CLASS=
+//TESTED_FILES=
+
+class tst_QAbstractButton : public QObject
+{
+ Q_OBJECT
+
+public:
+ tst_QAbstractButton();
+ virtual ~tst_QAbstractButton();
+
+
+public slots:
+ void initTestCase();
+ void cleanupTestCase();
+ void init();
+ void cleanup();
+private slots:
+ void setAutoRepeat_data();
+ void setAutoRepeat();
+
+ void pressed();
+ void released();
+ void setText();
+ void setIcon();
+
+ void setShortcut();
+
+ void animateClick();
+
+ void isCheckable();
+ void setDown();
+ void isChecked();
+ void toggled();
+ void setEnabled();
+ void shortcutEvents();
+ void stopRepeatTimer();
+
+ void keyNavigation();
+
+protected slots:
+ void onClicked();
+ void onToggled( bool on );
+ void onPressed();
+ void onReleased();
+ void resetValues();
+
+private:
+ uint click_count;
+ uint toggle_count;
+ uint press_count;
+ uint release_count;
+
+ QAbstractButton *testWidget;
+};
+
+// QAbstractButton is an abstract class in 4.0
+class MyButton : public QAbstractButton
+{
+public:
+ MyButton(QWidget *p = 0) : QAbstractButton(p) {}
+ void paintEvent(QPaintEvent *)
+ {
+ QPainter p(this);
+ QRect r = rect();
+ p.fillRect(r, isDown() ? Qt::black : (isChecked() ? Qt::lightGray : Qt::white));
+ p.setPen(isDown() ? Qt::white : Qt::black);
+ p.drawRect(r);
+ p.drawText(r, Qt::AlignCenter | Qt::TextShowMnemonic, text());
+ if (hasFocus()) {
+ r.adjust(2, 2, -2, -2);
+ QStyleOptionFocusRect opt;
+ opt.rect = r;
+ opt.palette = palette();
+ opt.state = QStyle::State_None;
+ style()->drawPrimitive(QStyle::PE_FrameFocusRect, &opt, &p, this);
+#ifdef Q_WS_MAC
+ p.setPen(Qt::red);
+ p.drawRect(r);
+#endif
+ }
+ }
+ QSize sizeHint() const
+ {
+ QSize sh(8, 8);
+ if (!text().isEmpty())
+ sh += fontMetrics().boundingRect(text()).size();
+ return sh;
+ }
+
+ void resetTimerEvents() { timerEvents = 0; }
+ int timerEventCount() const { return timerEvents; }
+
+private:
+
+ int timerEvents;
+
+ void timerEvent(QTimerEvent *event)
+ {
+ ++timerEvents;
+ QAbstractButton::timerEvent(event);
+ }
+};
+
+tst_QAbstractButton::tst_QAbstractButton()
+{
+}
+
+tst_QAbstractButton::~tst_QAbstractButton()
+{
+}
+
+void tst_QAbstractButton::initTestCase()
+{
+ testWidget = new MyButton(0);
+ testWidget->setObjectName("testObject");
+ testWidget->resize( 200, 200 );
+ testWidget->show();
+
+ connect( testWidget, SIGNAL(clicked()), this, SLOT(onClicked()) );
+ connect( testWidget, SIGNAL(pressed()), this, SLOT(onPressed()) );
+ connect( testWidget, SIGNAL(released()), this, SLOT(onReleased()) );
+ connect( testWidget, SIGNAL(toggled(bool)), this, SLOT(onToggled(bool)) );
+}
+
+void tst_QAbstractButton::cleanupTestCase()
+{
+ delete testWidget;
+}
+
+void tst_QAbstractButton::init()
+{
+ testWidget->setText("Test");
+ testWidget->setEnabled( TRUE );
+ testWidget->setDown( FALSE );
+ testWidget->setAutoRepeat( FALSE );
+ QKeySequence seq;
+ testWidget->setShortcut( seq );
+
+ toggle_count = 0;
+ press_count = 0;
+ release_count = 0;
+ click_count = 0;
+}
+
+void tst_QAbstractButton::cleanup()
+{
+}
+
+void tst_QAbstractButton::resetValues()
+{
+ toggle_count = 0;
+ press_count = 0;
+ release_count = 0;
+ click_count = 0;
+}
+
+void tst_QAbstractButton::onClicked()
+{
+ click_count++;
+}
+
+void tst_QAbstractButton::onToggled( bool /*on*/ )
+{
+ toggle_count++;
+}
+
+void tst_QAbstractButton::onPressed()
+{
+ press_count++;
+}
+
+void tst_QAbstractButton::onReleased()
+{
+ release_count++;
+}
+
+void tst_QAbstractButton::setAutoRepeat_data()
+{
+ QTest::addColumn<int>("mode");
+ QTest::newRow( "" ) << 0;
+ QTest::newRow( "" ) << 1;
+ QTest::newRow( "" ) << 2;
+ QTest::newRow( "" ) << 3;
+ QTest::newRow( "" ) << 4;
+ QTest::newRow( "" ) << 5;
+ QTest::newRow( "" ) << 6;
+}
+
+#define REPEAT_DELAY 1000
+
+int test_count = 0;
+int last_mode = 0;
+
+void tst_QAbstractButton::setAutoRepeat()
+{
+ QFETCH( int, mode );
+
+ //FIXME: temp code to check that the test fails consistenly
+ //retest( 3 );
+
+ switch (mode)
+ {
+ case 0:
+ QVERIFY( !testWidget->isCheckable() );
+ break;
+ case 1:
+ // check if we can toggle the mode
+ testWidget->setAutoRepeat( TRUE );
+ QVERIFY( testWidget->autoRepeat() );
+
+ testWidget->setAutoRepeat( FALSE );
+ QVERIFY( !testWidget->autoRepeat() );
+ break;
+ case 2:
+ // check that the button is down if we press space and not in autorepeat
+ testWidget->setDown( FALSE );
+ testWidget->setAutoRepeat( FALSE );
+ QTest::keyPress( testWidget, Qt::Key_Space );
+
+ QTest::qWait( REPEAT_DELAY );
+
+ QVERIFY( release_count == 0 );
+ QVERIFY( testWidget->isDown() );
+ QVERIFY( toggle_count == 0 );
+ QVERIFY( press_count == 1 );
+ QVERIFY( click_count == 0 );
+
+ QTest::keyRelease( testWidget, Qt::Key_Space );
+ QVERIFY( click_count == 1 );
+ QVERIFY( release_count == 1 );
+ break;
+ case 3:
+ // check that the button is down if we press space while in autorepeat
+ testWidget->setDown(false);
+ testWidget->setAutoRepeat(true);
+ QTest::keyPress(testWidget, Qt::Key_Space);
+ QTest::qWait(REPEAT_DELAY);
+ QVERIFY(testWidget->isDown());
+ QTest::keyRelease(testWidget, Qt::Key_Space);
+ QVERIFY(release_count == press_count);
+ QVERIFY(toggle_count == 0);
+ QVERIFY(press_count == click_count);
+ QVERIFY(click_count > 1);
+ break;
+ case 4:
+ // check that pressing ENTER has no effect when autorepeat is FALSE
+ testWidget->setDown( FALSE );
+ testWidget->setAutoRepeat( FALSE );
+ QTest::keyPress( testWidget, Qt::Key_Enter );
+
+ QTest::qWait( REPEAT_DELAY );
+
+ QVERIFY( !testWidget->isDown() );
+ QVERIFY( toggle_count == 0 );
+ QVERIFY( press_count == 0 );
+ QVERIFY( release_count == 0 );
+ QVERIFY( click_count == 0 );
+ QTest::keyRelease( testWidget, Qt::Key_Enter );
+
+ QVERIFY( click_count == 0 );
+ break;
+ case 5:
+ // check that pressing ENTER has no effect when autorepeat is TRUE
+ testWidget->setDown( FALSE );
+ testWidget->setAutoRepeat( TRUE );
+ QTest::keyPress( testWidget, Qt::Key_Enter );
+
+ QTest::qWait( REPEAT_DELAY );
+
+ QVERIFY( !testWidget->isDown() );
+ QVERIFY( toggle_count == 0 );
+ QVERIFY( press_count == 0 );
+ QVERIFY( release_count == 0 );
+ QVERIFY( click_count == 0 );
+
+ QTest::keyRelease( testWidget, Qt::Key_Enter );
+
+ QVERIFY( click_count == 0 );
+ break;
+ case 6:
+ // verify autorepeat is off by default.
+ MyButton tmp( 0);
+ tmp.setObjectName("tmp" );
+ QVERIFY( !tmp.autoRepeat() );
+ break;
+ }
+}
+
+void tst_QAbstractButton::pressed()
+{
+ // pressed/released signals expected for a QAbstractButton
+ QTest::keyPress( testWidget, ' ' );
+ QCOMPARE( press_count, (uint)1 );
+}
+
+void tst_QAbstractButton::released()
+{
+ // pressed/released signals expected for a QAbstractButton
+ QTest::keyPress( testWidget, ' ' );
+ QTest::keyRelease( testWidget, ' ' );
+ QCOMPARE( release_count, (uint)1 );
+}
+
+void tst_QAbstractButton::setText()
+{
+ testWidget->setText("");
+ QCOMPARE( testWidget->text(), QString("") );
+ testWidget->setText("simple");
+ QCOMPARE( testWidget->text(), QString("simple") );
+ testWidget->setText("&ampersand");
+ QCOMPARE( testWidget->text(), QString("&ampersand") );
+#ifndef Q_WS_MAC // no mneonics on Mac.
+ QCOMPARE( testWidget->shortcut(), QKeySequence("ALT+A"));
+#endif
+ testWidget->setText("te&st");
+ QCOMPARE( testWidget->text(), QString("te&st") );
+#ifndef Q_WS_MAC // no mneonics on Mac.
+ QCOMPARE( testWidget->shortcut(), QKeySequence("ALT+S"));
+#endif
+ testWidget->setText("foo");
+ QCOMPARE( testWidget->text(), QString("foo") );
+#ifndef Q_WS_MAC // no mneonics on Mac.
+ QCOMPARE( testWidget->shortcut(), QKeySequence());
+#endif
+}
+
+void tst_QAbstractButton::setIcon()
+{
+ const char *test1_xpm[] = {
+ "12 8 2 1",
+ ". c None",
+ "c c #ff0000",
+ ".........ccc",
+ "........ccc.",
+ ".......ccc..",
+ "ccc...ccc...",
+ ".ccc.ccc....",
+ "..ccccc.....",
+ "...ccc......",
+ "....c.......",
+ };
+
+ QPixmap p(test1_xpm);
+ testWidget->setIcon( p );
+ QCOMPARE( testWidget->icon().pixmap(12, 8), p );
+
+ // Test for #14793
+
+ const char *test2_xpm[] = {
+ "12 8 2 1",
+ ". c None",
+ "c c #ff0000",
+ "ccc......ccc",
+ ".ccc....ccc.",
+ "..ccc..ccc..",
+ "....cc.cc...",
+ ".....ccc....",
+ "....cc.cc...",
+ "...ccc.ccc..",
+ "..ccc...ccc.",
+ };
+
+ int currentHeight = testWidget->height();
+ int currentWidth = testWidget->width();
+
+ QPixmap p2( test2_xpm );
+ for ( int a = 0; a<5; a++ )
+ testWidget->setIcon( p2 );
+
+ QCOMPARE( testWidget->icon().pixmap(12, 8), p2 );
+
+ QCOMPARE( testWidget->height(), currentHeight );
+ QCOMPARE( testWidget->width(), currentWidth );
+}
+
+void tst_QAbstractButton::setEnabled()
+{
+ testWidget->setEnabled( FALSE );
+ QVERIFY( !testWidget->isEnabled() );
+// QTEST( testWidget, "disabled" );
+
+ testWidget->setEnabled( TRUE );
+ QVERIFY( testWidget->isEnabled() );
+// QTEST( testWidget, "enabled" );
+}
+
+void tst_QAbstractButton::isCheckable()
+{
+ QVERIFY( !testWidget->isCheckable() );
+}
+
+void tst_QAbstractButton::setDown()
+{
+ testWidget->setDown( FALSE );
+ QVERIFY( !testWidget->isDown() );
+
+ testWidget->setDown( TRUE );
+ QTest::qWait(300);
+ QVERIFY( testWidget->isDown() );
+
+ testWidget->setDown( TRUE );
+
+ // add some debugging stuff
+ QWidget *grab = QWidget::keyboardGrabber();
+ if (grab != 0 && grab != testWidget)
+ qDebug( "testWidget != keyboardGrabber" );
+ grab = qApp->focusWidget();
+ if (grab != 0 && grab != testWidget)
+ qDebug( "testWidget != focusWidget" );
+
+ QTest::keyClick( testWidget, Qt::Key_Escape );
+ QVERIFY( !testWidget->isDown() );
+}
+
+void tst_QAbstractButton::isChecked()
+{
+ testWidget->setDown( FALSE );
+ QVERIFY( !testWidget->isChecked() );
+
+ testWidget->setDown( TRUE );
+ QVERIFY( !testWidget->isChecked() );
+
+ testWidget->setDown( FALSE );
+ testWidget->toggle();
+ QVERIFY( testWidget->isChecked() == testWidget->isCheckable() );
+}
+
+void tst_QAbstractButton::toggled()
+{
+ testWidget->toggle();
+ QVERIFY( toggle_count == 0 );
+
+ QTest::mousePress( testWidget, Qt::LeftButton );
+ QVERIFY( toggle_count == 0 );
+ QVERIFY( click_count == 0 );
+
+ QTest::mouseRelease( testWidget, Qt::LeftButton );
+ QVERIFY( click_count == 1 );
+}
+
+void tst_QAbstractButton::setShortcut()
+{
+ QKeySequence seq( Qt::Key_A );
+ testWidget->setShortcut( seq );
+ QApplication::setActiveWindow(testWidget);
+
+ // must be active to get shortcuts
+ for (int i = 0; !testWidget->isActiveWindow() && i < 100; ++i) {
+ testWidget->activateWindow();
+ QApplication::instance()->processEvents();
+ QTest::qWait(100);
+ }
+ QVERIFY(testWidget->isActiveWindow());
+
+ QTest::keyClick( testWidget, 'A' );
+ QTest::qWait(300); // Animate click takes time
+ QCOMPARE(click_count, (uint)1);
+ QCOMPARE(press_count, (uint)1); // Press is part of a click
+ QCOMPARE(release_count,(uint)1); // Release is part of a click
+
+ QVERIFY( toggle_count == 0 );
+
+// resetValues();
+// QTest::keyPress( testWidget, 'A' );
+// QTest::qWait(10000);
+// QTest::keyRelease( testWidget, 'A' );
+// QCOMPARE(click_count, (uint)1);
+// QCOMPARE(press_count, (uint)1);
+// QCOMPARE(release_count,(uint)1);
+
+// qDebug() << click_count;
+
+}
+
+void tst_QAbstractButton::animateClick()
+{
+ testWidget->animateClick();
+ QVERIFY( testWidget->isDown() );
+ qApp->processEvents();
+ QVERIFY( testWidget->isDown() );
+ QTest::qWait(200);
+ qApp->processEvents();
+ QVERIFY( !testWidget->isDown() );
+}
+
+void tst_QAbstractButton::shortcutEvents()
+{
+ MyButton button;
+ QSignalSpy pressedSpy(&button, SIGNAL(pressed()));
+ QSignalSpy releasedSpy(&button, SIGNAL(released()));
+ QSignalSpy clickedSpy(&button, SIGNAL(clicked(bool)));
+
+ for (int i = 0; i < 4; ++i) {
+ QKeySequence sequence;
+ QShortcutEvent event(sequence, false);
+ QApplication::sendEvent(&button, &event);
+ if (i < 2)
+ QTest::qWait(500);
+ }
+
+ QTest::qWait(1000); // ensure animate timer is expired
+
+ QCOMPARE(pressedSpy.count(), 3);
+ QCOMPARE(releasedSpy.count(), 3);
+ QCOMPARE(clickedSpy.count(), 3);
+}
+
+void tst_QAbstractButton::stopRepeatTimer()
+{
+ MyButton button;
+ button.setAutoRepeat(true);
+
+ // Mouse trigger case:
+ button.resetTimerEvents();
+ QTest::mousePress(&button, Qt::LeftButton);
+ QTest::qWait(1000);
+ QVERIFY(button.timerEventCount() > 0);
+
+ QTest::mouseRelease(&button, Qt::LeftButton);
+ button.resetTimerEvents();
+ QTest::qWait(1000);
+ QCOMPARE(button.timerEventCount(), 0);
+
+ // Key trigger case:
+ button.resetTimerEvents();
+ QTest::keyPress(&button, Qt::Key_Space);
+ QTest::qWait(1000);
+ QVERIFY(button.timerEventCount() > 0);
+
+ QTest::keyRelease(&button, Qt::Key_Space);
+ button.resetTimerEvents();
+ QTest::qWait(1000);
+ QCOMPARE(button.timerEventCount(), 0);
+}
+
+void tst_QAbstractButton::keyNavigation()
+{
+ QSKIP("Key navigation in QAbstractButton will be fixed/improved as part of task 194373", SkipSingle);
+
+ QWidget widget;
+ QGridLayout *layout = new QGridLayout(&widget);
+ QAbstractButton *buttons[3][3];
+ for(int y = 0; y < 3; y++) {
+ for(int x = 0; x < 3; x++) {
+ buttons[y][x] = new MyButton(&widget);
+ buttons[y][x]->setFocusPolicy(Qt::StrongFocus);
+ layout->addWidget(buttons[y][x], y, x);
+ }
+ }
+
+ widget.show();
+ qApp->setActiveWindow(&widget);
+ widget.activateWindow();
+ QTest::qWait(30);
+
+ buttons[1][1]->setFocus();
+ QTest::qWait(400);
+ QVERIFY(buttons[1][1]->hasFocus());
+ QTest::keyPress(buttons[1][1], Qt::Key_Up);
+ QTest::qWait(100);
+ QVERIFY(buttons[0][1]->hasFocus());
+ QTest::keyPress(buttons[0][1], Qt::Key_Down);
+ QTest::qWait(100);
+ QVERIFY(buttons[1][1]->hasFocus());
+ QTest::keyPress(buttons[1][1], Qt::Key_Left);
+ QTest::qWait(100);
+ QVERIFY(buttons[1][0]->hasFocus());
+ QTest::keyPress(buttons[1][0], Qt::Key_Down);
+ QTest::qWait(100);
+ QVERIFY(buttons[2][0]->hasFocus());
+ QTest::keyPress(buttons[2][0], Qt::Key_Right);
+ QTest::qWait(100);
+ QVERIFY(buttons[2][1]->hasFocus());
+ QTest::keyPress(buttons[2][1], Qt::Key_Right);
+ QTest::qWait(100);
+ QVERIFY(buttons[2][2]->hasFocus());
+ QTest::keyPress(buttons[2][2], Qt::Key_Up);
+ QTest::qWait(100);
+ QVERIFY(buttons[1][2]->hasFocus());
+ QTest::keyPress(buttons[1][2], Qt::Key_Up);
+ QTest::qWait(100);
+ QVERIFY(buttons[0][2]->hasFocus());
+ buttons[0][1]->hide();
+ QTest::keyPress(buttons[0][2], Qt::Key_Left);
+ QTest::qWait(100);
+ QVERIFY(buttons[0][0]->hasFocus());
+
+
+}
+
+QTEST_MAIN(tst_QAbstractButton)
+#include "tst_qabstractbutton.moc"
diff --git a/tests/auto/widgets/widgets/qabstractscrollarea/.gitignore b/tests/auto/widgets/widgets/qabstractscrollarea/.gitignore
new file mode 100644
index 0000000000..ab753b8a0a
--- /dev/null
+++ b/tests/auto/widgets/widgets/qabstractscrollarea/.gitignore
@@ -0,0 +1 @@
+tst_qabstractscrollarea
diff --git a/tests/auto/widgets/widgets/qabstractscrollarea/qabstractscrollarea.pro b/tests/auto/widgets/widgets/qabstractscrollarea/qabstractscrollarea.pro
new file mode 100644
index 0000000000..e4bc3f6495
--- /dev/null
+++ b/tests/auto/widgets/widgets/qabstractscrollarea/qabstractscrollarea.pro
@@ -0,0 +1,9 @@
+############################################################
+# Project file for autotest for file qabstractscrollarea.h
+############################################################
+
+load(qttest_p4)
+QT += widgets
+SOURCES += tst_qabstractscrollarea.cpp
+
+
diff --git a/tests/auto/widgets/widgets/qabstractscrollarea/tst_qabstractscrollarea.cpp b/tests/auto/widgets/widgets/qabstractscrollarea/tst_qabstractscrollarea.cpp
new file mode 100644
index 0000000000..5c9a33cdc6
--- /dev/null
+++ b/tests/auto/widgets/widgets/qabstractscrollarea/tst_qabstractscrollarea.cpp
@@ -0,0 +1,390 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#include <QtTest/QtTest>
+
+#include <qcoreapplication.h>
+#include <qdebug.h>
+#include <qabstractscrollarea.h>
+#include <qscrollarea.h>
+#include <qscrollbar.h>
+#include <qlabel.h>
+#include <qwidget.h>
+#include <qdialog.h>
+
+//TESTED_CLASS=
+//TESTED_FILES=
+
+class tst_QAbstractScrollArea : public QObject
+{
+Q_OBJECT
+
+public:
+ tst_QAbstractScrollArea();
+ virtual ~tst_QAbstractScrollArea();
+private slots:
+ void scrollBarWidgets();
+ void setScrollBars();
+ void setScrollBars2();
+ void objectNaming();
+ void patternBackground();
+
+ void viewportCrash();
+ void task214488_layoutDirection_data();
+ void task214488_layoutDirection();
+};
+
+tst_QAbstractScrollArea::tst_QAbstractScrollArea()
+{
+}
+
+tst_QAbstractScrollArea::~tst_QAbstractScrollArea()
+{
+}
+
+void tst_QAbstractScrollArea::scrollBarWidgets()
+{
+ QWidget *w1 = new QWidget(0);
+ QWidget *w2 = new QWidget(0);
+ QWidget *w3 = new QWidget(0);
+
+ Qt::Alignment all = Qt::AlignLeft | Qt::AlignRight | Qt::AlignTop | Qt::AlignBottom;
+
+ QWidgetList w1List = QWidgetList() << w1;
+ QWidgetList w2List = QWidgetList() << w2;
+ QWidgetList w3List = QWidgetList() << w3;
+
+ QWidgetList w1w2List = w1List + w2List;
+ QWidgetList allList = w1List + w2List + w3List;
+
+ QAbstractScrollArea area;
+ area.show();
+ QCOMPARE(area.scrollBarWidgets(all), QWidgetList());
+
+ area.addScrollBarWidget(w1, Qt::AlignLeft);
+ QCOMPARE(area.scrollBarWidgets(all), w1List);
+ QCOMPARE(area.scrollBarWidgets(Qt::AlignLeft), w1List);
+ QCOMPARE(area.scrollBarWidgets(Qt::AlignRight), QWidgetList());
+ QCOMPARE(area.scrollBarWidgets(Qt::AlignTop), QWidgetList());
+ QCOMPARE(area.scrollBarWidgets(Qt::AlignBottom), QWidgetList());
+
+ area.addScrollBarWidget(w2, Qt::AlignBottom);
+ QCOMPARE(area.scrollBarWidgets(all), w1w2List);
+ QCOMPARE(area.scrollBarWidgets(Qt::AlignLeft), w1List);
+ QCOMPARE(area.scrollBarWidgets(Qt::AlignRight), QWidgetList());
+ QCOMPARE(area.scrollBarWidgets(Qt::AlignTop), QWidgetList());
+ QCOMPARE(area.scrollBarWidgets(Qt::AlignBottom), w2List);
+
+ // duplicate add
+ area.addScrollBarWidget(w2, Qt::AlignBottom);
+ QCOMPARE(area.scrollBarWidgets(all), w1w2List);
+ QCOMPARE(area.scrollBarWidgets(Qt::AlignLeft), w1List);
+ QCOMPARE(area.scrollBarWidgets(Qt::AlignRight), QWidgetList());
+ QCOMPARE(area.scrollBarWidgets(Qt::AlignTop), QWidgetList());
+ QCOMPARE(area.scrollBarWidgets(Qt::AlignBottom), w2List);
+
+ //reparent
+ w2->setParent(w1);
+ QCOMPARE(area.scrollBarWidgets(all), w1List);
+ QCOMPARE(area.scrollBarWidgets(Qt::AlignLeft), w1List);
+ QCOMPARE(area.scrollBarWidgets(Qt::AlignRight), QWidgetList());
+ QCOMPARE(area.scrollBarWidgets(Qt::AlignTop), QWidgetList());
+ QCOMPARE(area.scrollBarWidgets(Qt::AlignBottom), QWidgetList());
+
+ // add after reparent
+ area.addScrollBarWidget(w2, Qt::AlignBottom);
+ QCOMPARE(area.scrollBarWidgets(all), w1w2List);
+ QCOMPARE(area.scrollBarWidgets(Qt::AlignLeft), w1List);
+ QCOMPARE(area.scrollBarWidgets(Qt::AlignRight), QWidgetList());
+ QCOMPARE(area.scrollBarWidgets(Qt::AlignTop), QWidgetList());
+ QCOMPARE(area.scrollBarWidgets(Qt::AlignBottom), w2List);
+
+ // two widgets at Bottom.
+ area.addScrollBarWidget(w3, Qt::AlignBottom);
+ QCOMPARE(area.scrollBarWidgets(all).toSet(), allList.toSet());
+ QCOMPARE(area.scrollBarWidgets(Qt::AlignLeft), w1List);
+ QCOMPARE(area.scrollBarWidgets(Qt::AlignRight), QWidgetList());
+ QCOMPARE(area.scrollBarWidgets(Qt::AlignTop), QWidgetList());
+ QCOMPARE(area.scrollBarWidgets(Qt::AlignBottom).toSet(), (w2List + w3List).toSet());
+
+ //delete
+ delete w1;
+ delete w2;
+ delete w3;
+
+ QCOMPARE(area.scrollBarWidgets(all), QWidgetList());
+ QCOMPARE(area.scrollBarWidgets(Qt::AlignLeft), QWidgetList());
+ QCOMPARE(area.scrollBarWidgets(Qt::AlignRight), QWidgetList());
+ QCOMPARE(area.scrollBarWidgets(Qt::AlignTop), QWidgetList());
+ QCOMPARE(area.scrollBarWidgets(Qt::AlignBottom), QWidgetList());
+}
+
+void tst_QAbstractScrollArea::setScrollBars()
+{
+ QScrollArea scrollArea;
+ scrollArea.resize(300, 300);
+ scrollArea.show();
+
+ QPointer<QScrollBar> vbar = scrollArea.verticalScrollBar();
+ QPointer<QScrollBar> hbar = scrollArea.horizontalScrollBar();
+
+ // Now set properties on the scroll bars
+ scrollArea.verticalScrollBar()->setInvertedAppearance(true);
+ scrollArea.verticalScrollBar()->setInvertedControls(true);
+ scrollArea.verticalScrollBar()->setTracking(true);
+ scrollArea.verticalScrollBar()->setRange(-100, 100);
+ scrollArea.verticalScrollBar()->setPageStep(42);
+ scrollArea.verticalScrollBar()->setSingleStep(3);
+ scrollArea.verticalScrollBar()->setValue(43);
+ scrollArea.horizontalScrollBar()->setInvertedAppearance(true);
+ scrollArea.horizontalScrollBar()->setInvertedControls(true);
+ scrollArea.horizontalScrollBar()->setTracking(true);
+ scrollArea.horizontalScrollBar()->setRange(-100, 100);
+ scrollArea.horizontalScrollBar()->setPageStep(42);
+ scrollArea.horizontalScrollBar()->setSingleStep(3);
+ scrollArea.horizontalScrollBar()->setValue(43);
+
+ qApp->processEvents();
+
+ // Then replace the scroll bars
+ scrollArea.setVerticalScrollBar(new QScrollBar);
+ scrollArea.setHorizontalScrollBar(new QScrollBar);
+
+ // Check that the old ones were deleted
+ QVERIFY(!vbar);
+ QVERIFY(!hbar);
+
+ qApp->processEvents();
+
+ // Check that all properties have been populated
+ QVERIFY(scrollArea.verticalScrollBar()->invertedAppearance());
+ QVERIFY(scrollArea.verticalScrollBar()->invertedControls());
+ QVERIFY(scrollArea.verticalScrollBar()->hasTracking());
+ QVERIFY(scrollArea.verticalScrollBar()->isVisible());
+ QCOMPARE(scrollArea.verticalScrollBar()->minimum(), -100);
+ QCOMPARE(scrollArea.verticalScrollBar()->maximum(), 100);
+ QCOMPARE(scrollArea.verticalScrollBar()->pageStep(), 42);
+ QCOMPARE(scrollArea.verticalScrollBar()->singleStep(), 3);
+ QCOMPARE(scrollArea.verticalScrollBar()->value(), 43);
+ QVERIFY(scrollArea.horizontalScrollBar()->invertedAppearance());
+ QVERIFY(scrollArea.horizontalScrollBar()->invertedControls());
+ QVERIFY(scrollArea.horizontalScrollBar()->hasTracking());
+ QVERIFY(scrollArea.horizontalScrollBar()->isVisible());
+ QCOMPARE(scrollArea.horizontalScrollBar()->minimum(), -100);
+ QCOMPARE(scrollArea.horizontalScrollBar()->maximum(), 100);
+ QCOMPARE(scrollArea.horizontalScrollBar()->pageStep(), 42);
+ QCOMPARE(scrollArea.horizontalScrollBar()->singleStep(), 3);
+ QCOMPARE(scrollArea.horizontalScrollBar()->value(), 43);
+}
+
+void tst_QAbstractScrollArea::setScrollBars2()
+{
+ QAbstractScrollArea scrollArea;
+ scrollArea.resize(300, 300);
+
+ QScrollBar *hbar = new QScrollBar;
+ scrollArea.setHorizontalScrollBar(hbar);
+ qApp->processEvents();
+ QCOMPARE(scrollArea.horizontalScrollBar(), hbar);
+
+ QScrollBar *vbar = new QScrollBar;
+ scrollArea.setVerticalScrollBar(vbar);
+ qApp->processEvents();
+ QCOMPARE(scrollArea.verticalScrollBar(), vbar);
+
+ scrollArea.horizontalScrollBar()->setRange(0, 100);
+ scrollArea.verticalScrollBar()->setRange(0, 100);
+ scrollArea.show();
+
+ // Make sure scroll bars are not explicitly hidden by QAbstractScrollArea itself.
+ QVERIFY(hbar->isVisible());
+ QVERIFY(vbar->isVisible());
+
+ // Hide the OLD scroll bar and ensure that the NEW one is hidden.
+ hbar->hide();
+ scrollArea.setHorizontalScrollBar(new QScrollBar);
+ qApp->processEvents();
+ QVERIFY(!scrollArea.horizontalScrollBar()->isVisible());
+
+ vbar->hide();
+ scrollArea.setVerticalScrollBar(new QScrollBar);
+ qApp->processEvents();
+ QVERIFY(!scrollArea.verticalScrollBar()->isVisible());
+
+ scrollArea.verticalScrollBar()->show();
+ scrollArea.horizontalScrollBar()->show();
+
+ // Hide the NEW scroll bar and ensure that it's visible
+ // (because the OLD one is visible).
+ hbar = new QScrollBar;
+ hbar->hide();
+ scrollArea.setHorizontalScrollBar(hbar);
+ qApp->processEvents();
+ QVERIFY(hbar->isVisible());
+
+ vbar = new QScrollBar;
+ vbar->hide();
+ scrollArea.setVerticalScrollBar(vbar);
+ qApp->processEvents();
+ QVERIFY(vbar->isVisible());
+
+ vbar->setRange(0, 0);
+ qApp->processEvents();
+ QVERIFY(!vbar->isVisible());
+
+ hbar->setRange(0, 0);
+ qApp->processEvents();
+ QVERIFY(!hbar->isVisible());
+}
+
+// we need to make sure the viewport internal widget is named
+// qt_scrollarea_viewport, otherwise we're going to confuse Squish
+// and friends.
+void tst_QAbstractScrollArea::objectNaming()
+{
+ QScrollArea area;
+ QCOMPARE(area.viewport()->objectName(), QString("qt_scrollarea_viewport"));
+}
+
+class ViewportCrashWidget : public QDialog
+{
+public:
+ ViewportCrashWidget()
+ {
+ // temprorary set PaintOnScreen to set the nativeChildrenForced flag.
+ setAttribute(Qt::WA_PaintOnScreen, true);
+ setAttribute(Qt::WA_PaintOnScreen, false);
+
+ setAttribute(Qt::WA_DropSiteRegistered, true);
+
+ startTimer(2000);
+ }
+
+ void timerEvent(QTimerEvent * /* event */)
+ {
+ // should not crash.
+ (void)new QScrollArea(this);
+ accept();
+ }
+};
+
+void tst_QAbstractScrollArea::viewportCrash()
+{
+ ViewportCrashWidget w;
+ // should not crash
+ w.exec();
+}
+
+Q_DECLARE_METATYPE(Qt::LayoutDirection);
+Q_DECLARE_METATYPE(Qt::Key);
+
+void tst_QAbstractScrollArea::task214488_layoutDirection_data()
+{
+ QTest::addColumn<Qt::LayoutDirection>("dir");
+ QTest::addColumn<Qt::Key>("key");
+ QTest::addColumn<bool>("lessThan");
+
+ QTest::newRow("LTR left") << Qt::LeftToRight << Qt::Key_Left << true;
+ QTest::newRow("LTR right") << Qt::LeftToRight << Qt::Key_Right << false;
+ QTest::newRow("RTL left") << Qt::RightToLeft << Qt::Key_Left << false;
+ QTest::newRow("RTL right") << Qt::RightToLeft << Qt::Key_Right << true;
+}
+
+void tst_QAbstractScrollArea::task214488_layoutDirection()
+{
+ QScrollArea scrollArea;
+ scrollArea.resize(200, 200);
+ QWidget widget;
+ widget.resize(600, 600);
+ scrollArea.setWidget(&widget);
+ scrollArea.show();
+ QScrollBar *hbar = scrollArea.horizontalScrollBar();
+ hbar->setValue((hbar->minimum() + hbar->maximum()) / 2);
+
+ QFETCH(Qt::LayoutDirection, dir);
+ QFETCH(Qt::Key, key);
+ QFETCH(bool, lessThan);
+
+ scrollArea.setLayoutDirection(dir);
+
+ int refValue = hbar->value();
+ qApp->sendEvent(&scrollArea, new QKeyEvent(QEvent::KeyPress, key, Qt::NoModifier));
+ QVERIFY(lessThan ? (hbar->value() < refValue) : (hbar->value() > refValue));
+}
+
+void tst_QAbstractScrollArea::patternBackground()
+{
+ QWidget topLevel;
+ QScrollArea scrollArea(&topLevel);
+ scrollArea.resize(200, 200);
+ QWidget widget;
+ widget.resize(600, 600);
+ scrollArea.setWidget(&widget);
+ topLevel.show();
+
+ QLinearGradient linearGrad(QPointF(250, 250), QPointF(300, 300));
+ linearGrad.setColorAt(0, Qt::yellow);
+ linearGrad.setColorAt(1, Qt::red);
+ QBrush bg(linearGrad);
+ scrollArea.viewport()->setPalette(QPalette(Qt::black, bg, bg, bg, bg, bg, bg, bg, bg));
+ widget.setPalette(Qt::transparent);
+
+ QTest::qWait(50);
+
+ QImage image(200, 200, QImage::Format_ARGB32);
+ scrollArea.render(&image);
+
+ QCOMPARE(image.pixel(QPoint(20,20)) , QColor(Qt::yellow).rgb());
+
+ QScrollBar *hbar = scrollArea.horizontalScrollBar();
+ hbar->setValue(hbar->maximum());
+ QScrollBar *vbar = scrollArea.verticalScrollBar();
+ vbar->setValue(vbar->maximum());
+
+ QTest::qWait(50);
+
+ scrollArea.render(&image);
+ QCOMPARE(image.pixel(QPoint(20,20)) , QColor(Qt::red).rgb());
+}
+
+QTEST_MAIN(tst_QAbstractScrollArea)
+#include "tst_qabstractscrollarea.moc"
diff --git a/tests/auto/widgets/widgets/qabstractslider/.gitignore b/tests/auto/widgets/widgets/qabstractslider/.gitignore
new file mode 100644
index 0000000000..cdbb891214
--- /dev/null
+++ b/tests/auto/widgets/widgets/qabstractslider/.gitignore
@@ -0,0 +1 @@
+tst_qabstractslider
diff --git a/tests/auto/widgets/widgets/qabstractslider/qabstractslider.pro b/tests/auto/widgets/widgets/qabstractslider/qabstractslider.pro
new file mode 100644
index 0000000000..4507859ace
--- /dev/null
+++ b/tests/auto/widgets/widgets/qabstractslider/qabstractslider.pro
@@ -0,0 +1,5 @@
+load(qttest_p4)
+QT += widgets
+SOURCES += tst_qabstractslider.cpp
+
+
diff --git a/tests/auto/widgets/widgets/qabstractslider/tst_qabstractslider.cpp b/tests/auto/widgets/widgets/qabstractslider/tst_qabstractslider.cpp
new file mode 100644
index 0000000000..e78844524e
--- /dev/null
+++ b/tests/auto/widgets/widgets/qabstractslider/tst_qabstractslider.cpp
@@ -0,0 +1,1247 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#include <QtTest/QtTest>
+#include <QAbstractSlider>
+#include <QScrollBar>
+#include <QSlider>
+#include <QStyle>
+#include <QStyleOption>
+#include <QTime>
+#include <QDebug>
+
+// defined to be 120 by the wheel mouse vendors according to the docs
+#define WHEEL_DELTA 120
+
+class Slider : public QAbstractSlider
+{
+ public:
+ Slider(QWidget *parent)
+ : QAbstractSlider(parent) {}
+ using QAbstractSlider::setRepeatAction;
+ using QAbstractSlider::repeatAction;
+};
+
+class tst_QAbstractSlider: public QObject
+{
+ Q_OBJECT
+public slots:
+ void initTestCase();
+ void cleanupTestCase();
+ void actionTriggered(int action);
+ void rangeChanged(int min, int max);
+ void valueChanged(int value);
+ void sliderMoved(int value);
+
+private slots:
+ void triggerAction_data();
+ void triggerAction();
+ void minimum_maximum_data();
+ void minimum_maximum();
+ void keyPressed_data();
+ void keyPressed();
+ void wheelEvent_data();
+ void wheelEvent();
+ void sliderPressedReleased_data();
+ void sliderPressedReleased();
+ void setOrientation();
+ void sliderMoved_data();
+ void sliderMoved();
+ void rangeChanged_data();
+ void rangeChanged();
+ void setSliderPosition_data();
+ void setSliderPosition();
+ void setValue_data();
+ void setValue();
+ void setRepeatAction();
+
+private:
+ void waitUntilTimeElapsed(const QTime& t, int ms);
+
+ QWidget *topLevel;
+ Slider *slider;
+ int previousAction;
+ int reportedMinimum;
+ int reportedMaximum;
+ int reportedValue;
+ int reportedSliderPosition;
+ qint64 timeStamp;
+ qint64 actionTriggeredTimeStamp;
+ qint64 valueChangedTimeStamp;
+ qint64 rangeChangedTimeStamp;
+ qint64 sliderMovedTimeStamp;
+};
+
+Q_DECLARE_METATYPE(QList<Qt::Key>)
+Q_DECLARE_METATYPE(QPoint)
+
+void tst_QAbstractSlider::initTestCase()
+{
+ topLevel = new QWidget;
+ slider = new Slider(topLevel);
+ slider->setObjectName("testWidget");
+ slider->resize(100,100);
+ slider->show();
+
+ previousAction = QAbstractSlider::SliderNoAction;
+ timeStamp = 0;
+
+ connect(slider,SIGNAL(actionTriggered(int)),this,SLOT(actionTriggered(int)));
+ connect(slider,SIGNAL(rangeChanged(int,int)),this,SLOT(rangeChanged(int,int)));
+ connect(slider,SIGNAL(valueChanged(int)),this,SLOT(valueChanged(int)));
+ connect(slider,SIGNAL(sliderMoved(int)),this,SLOT(sliderMoved(int)));
+}
+
+void tst_QAbstractSlider::cleanupTestCase()
+{
+ delete topLevel;
+}
+
+void tst_QAbstractSlider::actionTriggered(int action)
+{
+ previousAction = action;
+ actionTriggeredTimeStamp = timeStamp++;
+}
+
+void tst_QAbstractSlider::rangeChanged(int min,int max)
+{
+ reportedMinimum = min;
+ reportedMaximum = max;
+ rangeChangedTimeStamp = timeStamp++;
+}
+
+void tst_QAbstractSlider::valueChanged(int value)
+{
+ reportedValue = value;
+ valueChangedTimeStamp = timeStamp++;
+}
+
+void tst_QAbstractSlider::sliderMoved(int value)
+{
+ reportedSliderPosition = value;
+ sliderMovedTimeStamp = timeStamp++;
+}
+
+void tst_QAbstractSlider::triggerAction_data()
+{
+ QTest::addColumn<int>("sliderAction");
+ QTest::addColumn<int>("maximum");
+ QTest::addColumn<int>("minimum");
+ QTest::addColumn<int>("initialSliderPosition");
+ QTest::addColumn<int>("singleStep");
+ QTest::addColumn<int>("pageStep");
+ QTest::addColumn<int>("expectedSliderPosition");
+
+ QTest::newRow("No action") << int(QAbstractSlider::SliderNoAction) // sliderAction
+ << 1000 // max
+ << 900 // min
+ << 987 // initial position
+ << 237 // single step size
+ << 234 // page step size
+ << 987; // expected position after
+
+ QTest::newRow("Move action") << int(QAbstractSlider::SliderMove) // sliderAction
+ << 1000 // max
+ << 900 // min
+ << 988 // initial position
+ << 237 // single step size
+ << 234 // page step size
+ << 988; // expected position after
+
+ QTest::newRow("Empty step add") << int(QAbstractSlider::SliderSingleStepAdd) // sliderAction
+ << 1000 // max
+ << 900 // min
+ << 988 // initial position
+ << 0 // single step size
+ << 234 // page step size
+ << 988; // expected position after
+
+ QTest::newRow("Empty step sub") << int(QAbstractSlider::SliderSingleStepSub) // sliderAction
+ << 1000 // max
+ << 900 // min
+ << 987 // initial position
+ << 0 // single step size
+ << 234 // page step size
+ << 987; // expected position after
+
+ QTest::newRow("Empty page add") << int(QAbstractSlider::SliderPageStepAdd) // sliderAction
+ << 1000 // max
+ << 900 // min
+ << 988 // initial position
+ << 234 // single step size
+ << 0 // page step size
+ << 988; // expected position after
+
+ QTest::newRow("Empty page sub") << int(QAbstractSlider::SliderPageStepSub) // sliderAction
+ << 1000 // max
+ << 900 // min
+ << 987 // initial position
+ << 234 // single step size
+ << 0 // page step size
+ << 987; // expected position after
+
+ QTest::newRow("Legal step add") << int(QAbstractSlider::SliderSingleStepAdd) // sliderAction
+ << 1000 // max
+ << 900 // min
+ << 988 // initial position
+ << 5 // single step size
+ << 234 // page step size
+ << 993; // expected position after
+
+ QTest::newRow("Legal step sub") << int(QAbstractSlider::SliderSingleStepSub) // sliderAction
+ << 1000 // max
+ << 900 // min
+ << 987 // initial position
+ << 5 // single step size
+ << 234 // page step size
+ << 982; // expected position after
+
+ QTest::newRow("Legal page add") << int(QAbstractSlider::SliderPageStepAdd) // sliderAction
+ << 1000 // max
+ << 900 // min
+ << 988 // initial position
+ << 234 // single step size
+ << 5 // page step size
+ << 993; // expected position after
+
+ QTest::newRow("Legal page sub") << int(QAbstractSlider::SliderPageStepSub) // sliderAction
+ << 1000 // max
+ << 900 // min
+ << 987 // initial position
+ << 234 // single step size
+ << 5 // page step size
+ << 982; // expected position after
+
+ QTest::newRow("Illegal step add") << int(QAbstractSlider::SliderSingleStepAdd) // sliderAction
+ << 1000 // max
+ << 900 // min
+ << 988 // initial position
+ << 500 // single step size
+ << 234 // page step size
+ << 1000; // expected position after
+
+ QTest::newRow("Illegal step sub") << int(QAbstractSlider::SliderSingleStepSub) // sliderAction
+ << 1000 // max
+ << 900 // min
+ << 987 // initial position
+ << 500 // single step size
+ << 234 // page step size
+ << 900; // expected position after
+
+ QTest::newRow("Illegal page add") << int(QAbstractSlider::SliderPageStepAdd) // sliderAction
+ << 1000 // max
+ << 900 // min
+ << 988 // initial position
+ << 234 // single step size
+ << 500 // page step size
+ << 1000; // expected position after
+
+ QTest::newRow("Illegal page sub") << int(QAbstractSlider::SliderPageStepSub) // sliderAction
+ << 1000 // max
+ << 900 // min
+ << 987 // initial position
+ << 234 // single step size
+ << 500 // page step size
+ << 900; // expected position after
+
+ // Negative steps will also be abs()'d so, check that case.
+ QTest::newRow("Negative step add") << int(QAbstractSlider::SliderSingleStepAdd) // sliderAction
+ << 1000 // max
+ << 900 // min
+ << 988 // initial position
+ << -1 // single step size
+ << 234 // page step size
+ << 989; // expected position after
+
+ QTest::newRow("Negative step sub") << int(QAbstractSlider::SliderSingleStepSub) // sliderAction
+ << 1000 // max
+ << 900 // min
+ << 987 // initial position
+ << -1 // single step size
+ << 234 // page step size
+ << 986; // expected position after
+
+ QTest::newRow("Negative page add") << int(QAbstractSlider::SliderPageStepAdd) // sliderAction
+ << 1000 // max
+ << 900 // min
+ << 988 // initial position
+ << 234 // single step size
+ << -1 // page step size
+ << 989; // expected position after
+
+ QTest::newRow("Negative page sub") << int(QAbstractSlider::SliderPageStepSub) // sliderAction
+ << 1000 // max
+ << 900 // min
+ << 987 // initial position
+ << 234 // single step size
+ << -1 // page step size
+ << 986; // expected position after
+
+ QTest::newRow("Illegal negative step add") << int(QAbstractSlider::SliderSingleStepAdd) // sliderAction
+ << 1000 // max
+ << 900 // min
+ << 988 // initial position
+ << -500 // single step size
+ << 234 // page step size
+ << 1000; // expected position after
+
+
+ QTest::newRow("Illegal negative step sub") << int(QAbstractSlider::SliderSingleStepSub) // sliderAction
+ << 1000 // max
+ << 900 // min
+ << 988 // initial position
+ << -500 // single step size
+ << 234 // page step size
+ << 900; // expected position after
+
+ QTest::newRow("Illegal negative page add") << int(QAbstractSlider::SliderPageStepAdd) // sliderAction
+ << 1000 // max
+ << 900 // min
+ << 988 // initial position
+ << 234 // single step size
+ << -500 // page step size
+ << 1000; // expected position after
+
+ QTest::newRow("Illegal negative page sub") << int(QAbstractSlider::SliderPageStepSub) // sliderAction
+ << 1000 // max
+ << 900 // min
+ << 988 // initial position
+ << 245 // single step size
+ << -500 // page step size
+ << 900; // expected position after
+
+ QTest::newRow("Slider to minimum") << int(QAbstractSlider::SliderToMinimum) // sliderAction
+ << 1000 // max
+ << 900 // min
+ << 988 // initial position
+ << 245 // single step size
+ << 1 // page step size
+ << 900; // expected position after
+
+ QTest::newRow("Slider to maximum") << int(QAbstractSlider::SliderToMaximum) // sliderAction
+ << 1000 // max
+ << 900 // min
+ << 988 // initial position
+ << 245 // single step size
+ << 1 // page step size
+ << 1000; // expected position after
+
+}
+
+void tst_QAbstractSlider::triggerAction()
+{
+ QFETCH(int,sliderAction);
+ QFETCH(int,maximum);
+ QFETCH(int,minimum);
+ QFETCH(int,initialSliderPosition);
+ QFETCH(int,singleStep);
+ QFETCH(int,pageStep);
+ QFETCH(int,expectedSliderPosition);
+
+ slider->setTracking(true);
+ slider->setRange(minimum,maximum);
+ slider->setSingleStep(singleStep);
+ slider->setPageStep(pageStep);
+ QCOMPARE(slider->singleStep(), qAbs(singleStep));
+ QCOMPARE(slider->pageStep(), qAbs(pageStep));
+
+ int oldPosition = slider->sliderPosition();
+ slider->setSliderPosition(initialSliderPosition);
+
+ QVERIFY( (oldPosition == initialSliderPosition && previousAction == int(QAbstractSlider::SliderNoAction)) ||
+ (oldPosition != initialSliderPosition && previousAction == int(QAbstractSlider::SliderMove)));
+ previousAction = int(QAbstractSlider::SliderNoAction);
+
+ QAbstractSlider::SliderAction *action = reinterpret_cast<QAbstractSlider::SliderAction*>(&sliderAction);
+ QVERIFY(action != 0);
+
+ slider->triggerAction(*action);
+ QCOMPARE(previousAction,sliderAction); // previousAction set in the actionTriggered() slot
+ QCOMPARE(slider->sliderPosition(),expectedSliderPosition);
+ QCOMPARE(slider->value(),expectedSliderPosition);
+ QCOMPARE(reportedValue,expectedSliderPosition);
+ previousAction = int(QAbstractSlider::SliderNoAction);
+ if (initialSliderPosition != expectedSliderPosition)
+ QVERIFY(actionTriggeredTimeStamp < valueChangedTimeStamp);
+}
+
+void tst_QAbstractSlider::minimum_maximum_data()
+{
+ QTest::addColumn<int>("minimum");
+ QTest::addColumn<int>("maximum");
+ QTest::addColumn<int>("expectedMinimum");
+ QTest::addColumn<int>("expectedMaximum");
+
+ QTest::newRow("Normal range") << 100 << 200 << 100 << 200;
+ QTest::newRow("Minimum higher") << 100 << 0 << 100 << 100;
+ QTest::newRow("Negative minimum") << -100 << 100 << -100 << 100;
+ QTest::newRow("Negative range") << -100 << -50 << -100 << -50;
+}
+
+void tst_QAbstractSlider::minimum_maximum()
+{
+ QFETCH(int, minimum);
+ QFETCH(int, maximum);
+ QFETCH(int, expectedMinimum);
+ QFETCH(int, expectedMaximum);
+
+ slider->setRange(minimum,maximum);
+ QCOMPARE(slider->minimum(),expectedMinimum);
+ QCOMPARE(slider->maximum(),expectedMaximum);
+ QCOMPARE(reportedMinimum,expectedMinimum);
+ QCOMPARE(reportedMaximum,expectedMaximum);
+
+ slider->setRange(minimum,maximum);
+ slider->setMaximum(slider->minimum() - 1);
+ QCOMPARE(slider->maximum(),slider->minimum());
+ QCOMPARE(reportedMinimum,slider->minimum());
+ QCOMPARE(reportedMaximum,slider->maximum());
+
+ slider->setRange(minimum,maximum);
+ slider->setMinimum(slider->maximum() + 1);
+ QCOMPARE(slider->minimum(),slider->maximum());
+ QCOMPARE(reportedMinimum,slider->minimum());
+ QCOMPARE(reportedMaximum,slider->maximum());
+
+ slider->setRange(minimum,maximum);
+ slider->setSliderPosition(slider->maximum() + 1);
+ QCOMPARE(slider->sliderPosition(), slider->maximum());
+ QCOMPARE(slider->value(), slider->maximum());
+ QCOMPARE(reportedValue, slider->maximum());
+
+ slider->setRange(minimum,maximum);
+ slider->setSliderPosition(slider->minimum() - 1);
+ QCOMPARE(slider->sliderPosition(), slider->minimum());
+ QCOMPARE(slider->value(), slider->minimum());
+ QCOMPARE(reportedValue, slider->minimum());
+
+ slider->setRange(minimum,maximum);
+ int oldPosition = slider->sliderPosition();
+ slider->setMaximum(oldPosition - 1);
+ QCOMPARE(slider->sliderPosition(),oldPosition - 1);
+
+ slider->setRange(minimum,maximum);
+ oldPosition = slider->sliderPosition();
+ slider->setMinimum(oldPosition + 1);
+ QCOMPARE(slider->sliderPosition(), oldPosition + 1);
+}
+
+void tst_QAbstractSlider::keyPressed_data()
+{
+ QTest::addColumn<int>("initialSliderPosition");
+ QTest::addColumn<int>("minimum");
+ QTest::addColumn<int>("maximum");
+ QTest::addColumn<int>("stepSize");
+ QTest::addColumn<int>("pageSize");
+ QTest::addColumn<QList<Qt::Key> >("keySequence");
+ QTest::addColumn<int>("expectedSliderPositionHorizontal");
+ QTest::addColumn<int>("expectedSliderPositionVertical");
+ QTest::addColumn<int>("expectedSliderPositionHorizontalInverted"); // :)
+ QTest::addColumn<int>("expectedSliderPositionVerticalInverted");
+
+
+ QList<Qt::Key> list;
+
+ list << Qt::Key_Down;
+ QTest::newRow("Step down once") << 10 // initial position
+ << 0 // minimum
+ << 100 // maximum
+ << 3 // single step size
+ << 0 // page step size
+ << list // key sequence
+ << 7 // result in case of horizontal slider
+ << 7 // result in case of vertical slider
+ << 13 // result in case of inverted horiz. slider
+ << 13; // result in case of inverted vertical slider
+
+ list = QList<Qt::Key>();
+ list << Qt::Key_Up;
+ QTest::newRow("Step down once") << 10 // initial position
+ << 0 // minimum
+ << 100 // maximum
+ << 3 // single step size
+ << 0 // page step size
+ << list // key sequence
+ << 13 // result in case of horizontal slider
+ << 13 // result in case of vertical slider
+ << 7 // result in case of inverted horiz. slider
+ << 7; // result in case of inverted vertical slider
+
+
+ list = QList<Qt::Key>();
+ list << Qt::Key_Left;
+ QTest::newRow("Step left once") << 10 // initial position
+ << 0 // minimum
+ << 100 // maximum
+ << 3 // single step size
+ << 0 // page step size
+ << list // key sequence
+ << 7 // result in case of horizontal slider
+ << 7 // result in case of vertical slider
+ << 13 // result in case of inverted horiz. slider
+ << 13; // result in case of inverted vertical slider
+
+ list = QList<Qt::Key>();
+ list << Qt::Key_Right;
+ QTest::newRow("Step right once") << 10 // initial position
+ << 0 // minimum
+ << 100 // maximum
+ << 3 // single step size
+ << 0 // page step size
+ << list // key sequence
+ << 13 // result in case of horizontal slider
+ << 13 // result in case of vertical slider
+ << 7 // result in case of inverted horiz. slider
+ << 7; // result in case of inverted vertical slider
+
+ list = QList<Qt::Key>();
+ list << Qt::Key_PageDown;
+ QTest::newRow("Page down once") << 10 // initial position
+ << 0 // minimum
+ << 100 // maximum
+ << 0 // single step size
+ << 3 // page step size
+ << list // key sequence
+ << 7 // result in case of horizontal slider
+ << 7 // result in case of vertical slider
+ << 13 // result in case of inverted horiz. slider
+ << 13; // result in case of inverted vertical slider
+
+ list = QList<Qt::Key>();
+ list << Qt::Key_PageUp;
+ QTest::newRow("Page up once") << 10 // initial position
+ << 0 // minimum
+ << 100 // maximum
+ << 0 // single step size
+ << 3 // page step size
+ << list // key sequence
+ << 13 // result in case of horizontal slider
+ << 13 // result in case of vertical slider
+ << 7 // result in case of inverted horiz. slider
+ << 7; // result in case of inverted vertical slider
+
+ list = QList<Qt::Key>();
+ list << Qt::Key_Up << Qt::Key_Up << Qt::Key_PageDown << Qt::Key_PageDown << Qt::Key_Left << Qt::Key_Left
+ << Qt::Key_Right << Qt::Key_Down << Qt::Key_PageUp << Qt::Key_PageUp << Qt::Key_Down << Qt::Key_Right;
+ QTest::newRow("Symmetric seq") << 50 // initial position
+ << 0 // minimum
+ << 100 // maximum
+ << 3 // single step size
+ << 3 // page step size
+ << list // key sequence
+ << 50 // result in case of horizontal slider
+ << 50 // result in case of vertical slider
+ << 50 // result in case of inverted horiz. slider
+ << 50; // result in case of inverted vertical slider
+
+
+ list = QList<Qt::Key>();
+ list << Qt::Key_Home;
+ QTest::newRow("Home") << 10 // initial position
+ << 0 // minimum
+ << 100 // maximum
+ << 0 // single step size
+ << 3 // page step size
+ << list // key sequence
+ << 0 // result in case of horizontal slider
+ << 0 // result in case of vertical slider
+ << 0 // result in case of inverted horiz. slider
+ << 0; // result in case of inverted vertical slider
+
+ list = QList<Qt::Key>();
+ list << Qt::Key_End;
+ QTest::newRow("End") << 10 // initial position
+ << 0 // minimum
+ << 100 // maximum
+ << 0 // single step size
+ << 3 // page step size
+ << list // key sequence
+ << 100 // result in case of horizontal slider
+ << 100 // result in case of vertical slider
+ << 100 // result in case of inverted horiz. slider
+ << 100; // result in case of inverted vertical slider
+
+ list = QList<Qt::Key>();
+ list << Qt::Key_End << Qt::Key_Up;
+ QTest::newRow("Past end")<< 10 // initial position
+ << 0 // minimum
+ << 100 // maximum
+ << 3 // single step size
+ << 3 // page step size
+ << list // key sequence
+ << 100 // result in case of horizontal slider
+ << 100 // result in case of vertical slider
+ << 97 // result in case of inverted horiz. slider
+ << 97; // result in case of inverted vertical slider
+
+ list = QList<Qt::Key>();
+ list << Qt::Key_Home << Qt::Key_Down;
+ QTest::newRow("Past home")<< 10 // initial position
+ << 0 // minimum
+ << 100 // maximum
+ << 3 // single step size
+ << 3 // page step size
+ << list // key sequence
+ << 0 // result in case of horizontal slider
+ << 0 // result in case of vertical slider
+ << 3 // result in case of inverted horiz. slider
+ << 3; // result in case of inverted vertical slider
+
+}
+
+void tst_QAbstractSlider::keyPressed()
+{
+ QFETCH(int, initialSliderPosition);
+ QFETCH(int, minimum);
+ QFETCH(int, maximum);
+ QFETCH(int, stepSize);
+ QFETCH(int, pageSize);
+ QFETCH(QList<Qt::Key>, keySequence);
+ QFETCH(int, expectedSliderPositionHorizontal);
+ QFETCH(int, expectedSliderPositionVertical);
+ QFETCH(int, expectedSliderPositionHorizontalInverted);
+ QFETCH(int, expectedSliderPositionVerticalInverted);
+
+ // Horizontal non-inverted
+ slider->setRange(minimum,maximum);
+ slider->setSliderPosition(initialSliderPosition);
+ slider->setSingleStep(stepSize);
+ slider->setPageStep(pageSize);
+ slider->setOrientation(Qt::Horizontal);
+ slider->setInvertedAppearance(false);
+ slider->setInvertedControls(false);
+ for (int i=0;i<keySequence.count();i++) {
+ QTest::keyClick(slider, keySequence.at(i));
+ }
+ QCOMPARE(slider->sliderPosition(), expectedSliderPositionHorizontal);
+
+ // Horizontal inverted
+ slider->setRange(minimum,maximum);
+ slider->setSliderPosition(initialSliderPosition);
+ slider->setSingleStep(stepSize);
+ slider->setPageStep(pageSize);
+ slider->setOrientation(Qt::Horizontal);
+ slider->setInvertedAppearance(true);
+ slider->setInvertedControls(true);
+ for (int i=0;i<keySequence.count();i++)
+ QTest::keyPress(slider, keySequence.at(i));
+ QCOMPARE(slider->sliderPosition(), expectedSliderPositionHorizontalInverted);
+
+ // Vertical non-inverted
+ slider->setRange(minimum,maximum);
+ slider->setSliderPosition(initialSliderPosition);
+ slider->setSingleStep(stepSize);
+ slider->setPageStep(pageSize);
+ slider->setOrientation(Qt::Vertical);
+ slider->setInvertedAppearance(false);
+ slider->setInvertedControls(false);
+ for (int i=0;i<keySequence.count();i++)
+ QTest::keyPress(slider, keySequence.at(i));
+ QCOMPARE(slider->sliderPosition(), expectedSliderPositionVertical);
+
+ // Vertical inverted
+ slider->setRange(minimum,maximum);
+ slider->setSliderPosition(initialSliderPosition);
+ slider->setSingleStep(stepSize);
+ slider->setPageStep(pageSize);
+ slider->setOrientation(Qt::Vertical);
+ slider->setInvertedAppearance(true);
+ slider->setInvertedControls(true);
+ for (int i=0;i<keySequence.count();i++)
+ QTest::keyPress(slider, keySequence.at(i));
+ QCOMPARE(slider->sliderPosition(), expectedSliderPositionVerticalInverted);
+}
+
+void tst_QAbstractSlider::wheelEvent_data()
+{
+ QTest::addColumn<int>("initialSliderPosition");
+ QTest::addColumn<int>("minimum");
+ QTest::addColumn<int>("maximum");
+ QTest::addColumn<int>("singleStep");
+ QTest::addColumn<int>("pageStep");
+ QTest::addColumn<bool>("invertedControls");
+ QTest::addColumn<int>("wheelScrollLines");
+ QTest::addColumn<bool>("withModifiers"); // use keyboard modifiers while scrolling? (CTRL and SHIFT)
+ QTest::addColumn<int>("deltaMultiple"); // multiples of WHEEL_DELTA
+ QTest::addColumn<int>("sliderOrientation");
+ QTest::addColumn<int>("wheelOrientation");
+ QTest::addColumn<int>("expectedSliderPosition");
+ QTest::addColumn<QPoint>("distanceFromBottomRight"); // mpointer's distance from bottom-right corner of widget
+
+ QTest::newRow("Normal data step") << 0 // initial position
+ << 0 // minimum
+ << 100 // maximum
+ << 1 // single step
+ << 100 // page step
+ << false // inverted controls
+ << 20 // wheel scroll lines
+ << false // with modifiers
+ << 1 // delta
+ << int(Qt::Vertical) // orientation of slider
+ << int(Qt::Vertical) // orientation of wheel
+ << 20 // expected position after
+ << QPoint(0,0);
+
+ QTest::newRow("Normal data page") << 0 // initial position
+ << 0 // minimum
+ << 100 // maximum
+ << 100 // single step
+ << 1 // page step
+ << false // inverted controls
+ << 20 // wheel scroll lines
+ << false // with modifiers
+ << 1 // delta
+ << int(Qt::Vertical) // orientation of slider
+ << int(Qt::Vertical) // orientation of wheel
+#ifndef Q_WS_MAC
+ << 1 // expected position after
+#else
+ // We don't restrict scrolling to pageStep on Mac
+ << 100 // expected position after
+#endif
+ << QPoint(1,1);
+ QTest::newRow("Different orientation") << 0 // initial position
+ << 0 // minimum
+ << 100 // maximum
+ << 100 // single step
+ << 1 // page step
+ << false // inverted controls
+ << 20 // wheel scroll lines
+ << false // with modifiers
+ << 1 // delta
+ << int(Qt::Horizontal) // orientation of slider
+ << int(Qt::Vertical) // orientation of wheel
+#ifndef Q_WS_MAC
+ << 1 // expected position after
+#else
+ // We don't restrict scrolling to pageStep on Mac
+ << 100 // expected position after
+#endif
+ << QPoint(1,1);
+
+ QTest::newRow("Different orientation2")<< 0 // initial position
+ << 0 // minimum
+ << 100 // maximum
+ << 100 // single step
+ << 1 // page step
+ << false // inverted controls
+ << 20 // wheel scroll lines
+ << false // with modifiers
+ << 1 // delta
+ << int(Qt::Horizontal) // orientation of slider
+ << int(Qt::Vertical) // orientation of wheel
+#ifndef Q_WS_MAC
+ << 1 // expected position after
+#else
+ // We don't restrict scrolling to pageStep on Mac
+ << 100 // expected position after
+#endif
+ << QPoint(0,0);
+
+ QTest::newRow("Inverted controls") << 50 // initial position
+ << 0 // minimum
+ << 100 // maximum
+ << 1 // single step
+ << 100 // page step
+ << true // inverted controls
+ << 20 // wheel scroll lines
+ << false // with modifiers
+ << -1 // delta
+ << int(Qt::Horizontal) // orientation of slider
+ << int(Qt::Horizontal) // orientation of wheel
+ << 30 // expected position after
+ << QPoint(1,1);
+
+ QTest::newRow("Past end") << 50 // initial position
+ << 0 // minimum
+ << 100 // maximum
+ << 26 // single step
+ << 100 // page step
+ << false // inverted controls
+ << 1 // wheel scroll lines
+ << false // with modifiers
+ << -2 // delta
+ << int(Qt::Horizontal) // orientation of slider
+ << int(Qt::Horizontal) // orientation of wheel
+ << 100 // expected position after
+ << QPoint(0,0);
+
+ QTest::newRow("Past start") << 50 // initial position
+ << 0 // minimum
+ << 100 // maximum
+ << 26 // single step
+ << 100 // page step
+ << false // inverted controls
+ << 1 // wheel scroll lines
+ << false // with modifiers
+ << 2 // delta
+ << int(Qt::Horizontal) // orientation of slider
+ << int(Qt::Horizontal) // orientation of wheel
+ << 0 // expected position after
+ << QPoint(0,0);
+
+ QTest::newRow("With modifiers") << 50 // initial position
+ << 0 // minimum
+ << 100 // maximum
+ << 1 // single step
+ << 40 // page step
+ << false // inverted controls
+ << 20 // wheel scroll lines
+ << true // with modifiers
+ << -1 // delta
+ << int(Qt::Horizontal) // orientation of slider
+ << int(Qt::Horizontal) // orientation of wheel
+ << 90 // expected position after
+ << QPoint(0,0);
+
+}
+
+void tst_QAbstractSlider::wheelEvent()
+{
+ QFETCH(int,initialSliderPosition);
+ QFETCH(int,minimum);
+ QFETCH(int,maximum);
+ QFETCH(int,singleStep);
+ QFETCH(int,pageStep);
+ QFETCH(bool,invertedControls);
+ QFETCH(int,wheelScrollLines);
+ QFETCH(bool,withModifiers);
+ QFETCH(int,deltaMultiple);
+ QFETCH(int,sliderOrientation);
+ QFETCH(int,wheelOrientation);
+ QFETCH(int,expectedSliderPosition);
+ QFETCH(QPoint,distanceFromBottomRight);
+
+ QCoreApplication *applicationInstance = QCoreApplication::instance();
+ QVERIFY(applicationInstance != 0);
+ QApplication::setWheelScrollLines(wheelScrollLines);
+
+ Qt::Orientation orientation = *reinterpret_cast<Qt::Orientation*>(&sliderOrientation);
+ slider->setRange(minimum,maximum);
+ slider->setSliderPosition(initialSliderPosition);
+ slider->setSingleStep(singleStep);
+ slider->setPageStep(pageStep);
+ slider->setInvertedControls(invertedControls);
+ slider->setOrientation(orientation);
+
+ Qt::KeyboardModifier k = withModifiers ? Qt::ControlModifier : Qt::NoModifier;
+ orientation = *reinterpret_cast<Qt::Orientation*>(&wheelOrientation);
+ QWheelEvent event(slider->rect().bottomRight() + distanceFromBottomRight, WHEEL_DELTA * deltaMultiple,
+ Qt::NoButton, k, orientation);
+ QVERIFY(applicationInstance->sendEvent(slider,&event));
+ QCOMPARE(slider->sliderPosition(),expectedSliderPosition);
+
+ slider->setSliderPosition(initialSliderPosition);
+ k = withModifiers ? Qt::ShiftModifier : Qt::NoModifier;
+ event = QWheelEvent(slider->rect().bottomRight() + distanceFromBottomRight, WHEEL_DELTA * deltaMultiple,
+ Qt::NoButton, k, orientation);
+ QSignalSpy spy1(slider, SIGNAL(actionTriggered(int)));
+ QSignalSpy spy2(slider, SIGNAL(valueChanged(int)));
+ QVERIFY(applicationInstance->sendEvent(slider,&event));
+ QCOMPARE(slider->sliderPosition(),expectedSliderPosition);
+ int expectedSignalCount = (initialSliderPosition == expectedSliderPosition) ? 0 : 1;
+ QCOMPARE(spy1.count(), expectedSignalCount);
+ QCOMPARE(spy2.count(), expectedSignalCount);
+ if (expectedSignalCount)
+ QVERIFY(actionTriggeredTimeStamp < valueChangedTimeStamp);
+}
+
+void tst_QAbstractSlider::sliderPressedReleased_data()
+{
+ QTest::addColumn<int>("control");
+ QTest::addColumn<int>("minimum");
+ QTest::addColumn<int>("maximum");
+ QTest::addColumn<uint>("subControl");
+ QTest::addColumn<int>("expectedCount");
+
+ QTest::newRow("slider on the handle") << int(QStyle::CC_Slider)
+ << 0
+ << 20
+ << uint(QStyle::SC_SliderHandle)
+ << 1;
+
+ QTest::newRow("slider on the groove") << int(QStyle::CC_Slider)
+ << 0
+ << 20
+ << uint(QStyle::SC_SliderGroove)
+ << ((qApp->style()->styleHint(QStyle::SH_Slider_AbsoluteSetButtons) & Qt::LeftButton) ? 1 : 0);
+
+ QTest::newRow("scrollbar on the handle") << int(QStyle::CC_ScrollBar)
+ << 0
+ << 20
+ << uint(QStyle::SC_ScrollBarSlider)
+ << 1;
+
+ QTest::newRow("scrollbar on the groove") << int(QStyle::CC_ScrollBar)
+ << 0
+ << 20
+ << uint(QStyle::SC_ScrollBarGroove)
+ << 0;
+}
+
+void tst_QAbstractSlider::sliderPressedReleased()
+{
+ QFETCH(int, control);
+ QFETCH(int, minimum);
+ QFETCH(int, maximum);
+ QFETCH(uint, subControl);
+ QFETCH(int, expectedCount);
+
+ QWidget topLevel;
+ QAbstractSlider *slider;
+ switch (control) {
+ default:
+ qWarning("Bad input into test, leaving");
+ return;
+ break;
+ case QStyle::CC_Slider:
+ slider = new QSlider(&topLevel);
+ slider->setLayoutDirection(Qt::LeftToRight); // Makes "upside down" much easier to compute
+ break;
+ case QStyle::CC_ScrollBar:
+ slider = new QScrollBar(&topLevel);
+ break;
+ }
+
+
+ slider->setMinimum(minimum);
+ slider->setMaximum(maximum);
+ slider->setValue(0);
+ slider->setOrientation(Qt::Vertical);
+ slider->resize(slider->sizeHint().width(), slider->sizeHint().height() + 100);
+ QSignalSpy spy1(slider, SIGNAL(sliderPressed()));
+ QSignalSpy spy2(slider, SIGNAL(sliderReleased()));
+
+ // Mac Style requires the control to be active to get the correct values...
+ topLevel.show();
+ slider->activateWindow();
+
+ QStyleOptionSlider option;
+ option.init(slider);
+ option.upsideDown = control == QStyle::CC_Slider ? !slider->invertedAppearance()
+ : slider->invertedAppearance();
+ option.subControls = QStyle::SC_None;
+ option.activeSubControls = QStyle::SC_None;
+ option.orientation = slider->orientation();
+ option.maximum = maximum;
+ option.minimum = minimum;
+ option.sliderPosition = slider->value();
+ option.sliderValue = slider->value();
+ option.singleStep = slider->singleStep();
+ option.pageStep = slider->pageStep();
+ QRect rect = slider->style()->subControlRect(QStyle::ComplexControl(control), &option,
+ QStyle::SubControl(subControl), slider);
+
+ QTest::mousePress(slider, Qt::LeftButton, 0, QPoint(rect.center().x() + 2, rect.center().y() + 2));
+ QCOMPARE(spy1.count(), expectedCount);
+ QTest::mouseRelease(slider, Qt::LeftButton, 0, rect.center());
+ QCOMPARE(spy2.count(), expectedCount);
+
+ delete slider;
+}
+
+void tst_QAbstractSlider::sliderMoved_data()
+{
+ QTest::addColumn<int>("control");
+ QTest::addColumn<int>("minimum");
+ QTest::addColumn<int>("maximum");
+ QTest::addColumn<int>("position");
+ QTest::addColumn<bool>("sliderDown");
+ QTest::addColumn<int>("expectedCount");
+
+ QTest::newRow("slider pressed") << int(QStyle::CC_Slider)
+ << 0
+ << 20
+ << 10
+ << true
+ << 1;
+
+ QTest::newRow("slider not pressed") << int(QStyle::CC_Slider)
+ << 0
+ << 20
+ << 10
+ << false
+ << 0;
+
+ QTest::newRow("scrollbar pressed") << int(QStyle::CC_ScrollBar)
+ << 0
+ << 20
+ << 10
+ << true
+ << 1;
+
+ QTest::newRow("scrollbar not pressed") << int(QStyle::CC_ScrollBar)
+ << 0
+ << 20
+ << 10
+ << false
+ << 0;
+}
+
+void tst_QAbstractSlider::sliderMoved()
+{
+ QFETCH(int, control);
+ QFETCH(int, minimum);
+ QFETCH(int, maximum);
+ QFETCH(int, position);
+ QFETCH(bool, sliderDown);
+ QFETCH(int, expectedCount);
+ QAbstractSlider *slider;
+ switch (control) {
+ default:
+ slider = 0;
+ break;
+ case QStyle::CC_Slider:
+ slider = new QSlider;
+ break;
+ case QStyle::CC_ScrollBar:
+ slider = new QScrollBar;
+ break;
+ }
+ QSignalSpy spy(slider, SIGNAL(sliderMoved(int)));
+
+ slider->setMinimum(minimum);
+ slider->setMaximum(maximum);
+ slider->setSliderDown(sliderDown);
+ slider->setSliderPosition(position);
+ QCOMPARE(spy.count(), expectedCount);
+
+ delete slider;
+}
+
+void tst_QAbstractSlider::setOrientation()
+{
+ QSlider slider(0);
+
+ QSizePolicy sp = slider.sizePolicy();
+ slider.setOrientation(slider.orientation());
+ QSizePolicy sp2 = slider.sizePolicy();
+ QCOMPARE(sp, sp2);
+
+ slider.setOrientation(Qt::Horizontal);
+ sp = slider.sizePolicy();
+ slider.setOrientation(Qt::Vertical);
+ sp2 = slider.sizePolicy();
+
+ QVERIFY(sp != sp2);
+ sp2.transpose();
+ QCOMPARE(sp, sp2);
+}
+
+
+void tst_QAbstractSlider::rangeChanged_data()
+{
+ QTest::addColumn<int>("minimum");
+ QTest::addColumn<int>("maximum");
+ QTest::addColumn<int>("newMin");
+ QTest::addColumn<int>("newMax");
+ QTest::addColumn<int>("expectedCount");
+
+ QTest::newRow("no change")
+ << 0
+ << 20
+ << 0
+ << 20
+ << 0;
+
+ QTest::newRow("min change")
+ << 0
+ << 20
+ << 10
+ << 20
+ << 1;
+ QTest::newRow("max change")
+ << 0
+ << 20
+ << 0
+ << 30
+ << 1;
+
+ QTest::newRow("both change")
+ << 0
+ << 20
+ << 10
+ << 30
+ << 1;
+}
+
+void tst_QAbstractSlider::rangeChanged()
+{
+ QFETCH(int, minimum);
+ QFETCH(int, maximum);
+ QFETCH(int, newMin);
+ QFETCH(int, newMax);
+ QFETCH(int, expectedCount);
+ QSlider slider;
+ slider.setRange(minimum, maximum);
+ QSignalSpy spy(&slider, SIGNAL(rangeChanged(int, int)));
+ slider.setRange(newMin, newMax);
+ QCOMPARE(spy.count(), expectedCount);
+}
+
+void tst_QAbstractSlider::setSliderPosition_data()
+{
+ QTest::addColumn<bool>("tracking");
+ QTest::addColumn<bool>("down");
+
+ QTest::newRow("tracking, slider down")
+ << true
+ << true;
+ QTest::newRow("tracking, slider not down")
+ << true
+ << false;
+ QTest::newRow("no tracking, slider down")
+ << false
+ << true;
+ QTest::newRow("no tracking, slider not down")
+ << false
+ << false;
+}
+
+void tst_QAbstractSlider::setSliderPosition()
+{
+ QFETCH(bool, tracking);
+ QFETCH(bool, down);
+ const int minimum = 0;
+ const int maximum = 100;
+ const int initialValue = 50;
+ const int targetPosition = 75;
+ slider->setRange(minimum, maximum);
+ slider->setTracking(tracking);
+ slider->setSliderDown(down);
+ slider->setValue(initialValue);
+ QCOMPARE(slider->sliderPosition(), initialValue);
+ QSignalSpy spy1(slider, SIGNAL(sliderMoved(int)));
+ QSignalSpy spy2(slider, SIGNAL(valueChanged(int)));
+ slider->setSliderPosition(targetPosition);
+ QCOMPARE(slider->sliderPosition(), targetPosition);
+ QCOMPARE(spy1.count(), down ? 1 : 0);
+ QCOMPARE(spy2.count(), tracking ? 1 : 0);
+ QCOMPARE(slider->value(), tracking ? targetPosition : initialValue);
+ if (tracking && down)
+ QVERIFY(sliderMovedTimeStamp < valueChangedTimeStamp);
+}
+
+void tst_QAbstractSlider::setValue_data()
+{
+ QTest::addColumn<bool>("down");
+
+ QTest::newRow("slider down")
+ << true;
+ QTest::newRow("slider not down")
+ << false;
+}
+
+void tst_QAbstractSlider::setValue()
+{
+ QFETCH(bool, down);
+ const int minimum = 0;
+ const int maximum = 100;
+ slider->setRange(minimum, maximum);
+ slider->setSliderDown(down);
+ slider->setValue(49); // to force a valueChanged() below
+ QSignalSpy spy1(slider, SIGNAL(sliderMoved(int)));
+ QSignalSpy spy2(slider, SIGNAL(valueChanged(int)));
+ QSignalSpy spy3(slider, SIGNAL(actionTriggered(int)));
+ slider->setValue(50);
+ QCOMPARE(spy1.count(), down ? 1 : 0);
+ QCOMPARE(spy2.count(), 1);
+ QCOMPARE(spy3.count(), 0);
+ QCOMPARE(slider->value(), reportedValue);
+ QCOMPARE(slider->sliderPosition(), reportedSliderPosition);
+ if (down)
+ QVERIFY(sliderMovedTimeStamp < valueChangedTimeStamp);
+}
+
+void tst_QAbstractSlider::waitUntilTimeElapsed(const QTime& t, int ms)
+{
+ const int eps = 80;
+ while (t.elapsed() < ms + eps)
+ QTest::qWait(qMax(ms - t.elapsed() + eps, 25));
+}
+
+void tst_QAbstractSlider::setRepeatAction()
+{
+ slider->setRange(0, 1000);
+ slider->setValue(55);
+ slider->setPageStep(10);
+ QSignalSpy spy(slider, SIGNAL(actionTriggered(int)));
+
+ // Start repeat action with initial delay of 500 ms, and then repeating
+ // every 250 ms.
+ slider->setRepeatAction(QAbstractSlider::SliderPageStepAdd, 500, 250);
+ QCOMPARE(spy.count(), 0);
+ QCOMPARE(slider->value(), 55);
+
+ QTime t;
+ t.start();
+ QTest::qWait(300);
+ QCOMPARE(spy.count(), 0);
+ QCOMPARE(slider->value(), 55);
+
+ waitUntilTimeElapsed(t, 550);
+ QCOMPARE(spy.count(), 1);
+ QCOMPARE(slider->value(), 65);
+ QCOMPARE(spy.at(0).at(0).toUInt(), (uint)QAbstractSlider::SliderPageStepAdd);
+
+ waitUntilTimeElapsed(t, 790);
+ QCOMPARE(spy.count(), 2);
+ QCOMPARE(slider->value(), 75);
+ QCOMPARE(spy.at(1).at(0).toUInt(), (uint)QAbstractSlider::SliderPageStepAdd);
+
+ waitUntilTimeElapsed(t, 1790);
+ QCOMPARE(spy.count(), 6);
+ QCOMPARE(slider->value(), 115);
+ QCOMPARE(spy.at(4).at(0).toUInt(), (uint)QAbstractSlider::SliderPageStepAdd);
+ QCOMPARE(spy.at(5).at(0).toUInt(), (uint)QAbstractSlider::SliderPageStepAdd);
+
+ slider->setRepeatAction(QAbstractSlider::SliderNoAction);
+ QCOMPARE(spy.count(), 6);
+ QCOMPARE(slider->value(), 115);
+
+ QTest::qWait(300);
+ QCOMPARE(spy.count(), 6);
+ QCOMPARE(slider->value(), 115);
+}
+
+QTEST_MAIN(tst_QAbstractSlider)
+#include "tst_qabstractslider.moc"
diff --git a/tests/auto/widgets/widgets/qabstractspinbox/.gitignore b/tests/auto/widgets/widgets/qabstractspinbox/.gitignore
new file mode 100644
index 0000000000..07d1d652ee
--- /dev/null
+++ b/tests/auto/widgets/widgets/qabstractspinbox/.gitignore
@@ -0,0 +1 @@
+tst_qabstractspinbox
diff --git a/tests/auto/widgets/widgets/qabstractspinbox/qabstractspinbox.pro b/tests/auto/widgets/widgets/qabstractspinbox/qabstractspinbox.pro
new file mode 100644
index 0000000000..e156b2493d
--- /dev/null
+++ b/tests/auto/widgets/widgets/qabstractspinbox/qabstractspinbox.pro
@@ -0,0 +1,9 @@
+############################################################
+# Project file for autotest for file qabstractspinbox.h
+############################################################
+
+load(qttest_p4)
+QT += widgets
+SOURCES += tst_qabstractspinbox.cpp
+
+
diff --git a/tests/auto/widgets/widgets/qabstractspinbox/tst_qabstractspinbox.cpp b/tests/auto/widgets/widgets/qabstractspinbox/tst_qabstractspinbox.cpp
new file mode 100644
index 0000000000..d14c75bbac
--- /dev/null
+++ b/tests/auto/widgets/widgets/qabstractspinbox/tst_qabstractspinbox.cpp
@@ -0,0 +1,163 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#include <QtTest/QtTest>
+
+#include <qcoreapplication.h>
+#include <qdebug.h>
+#include <qabstractspinbox.h>
+#include <qlineedit.h>
+#include <qspinbox.h>
+
+
+//TESTED_CLASS=
+//TESTED_FILES=
+
+class tst_QAbstractSpinBox : public QObject
+{
+Q_OBJECT
+
+public:
+ tst_QAbstractSpinBox();
+ virtual ~tst_QAbstractSpinBox();
+
+private slots:
+ void getSetCheck();
+
+ // task-specific tests below me:
+ void task183108_clear();
+ void task228728_cssselector();
+};
+
+tst_QAbstractSpinBox::tst_QAbstractSpinBox()
+{
+}
+
+tst_QAbstractSpinBox::~tst_QAbstractSpinBox()
+{
+}
+
+class MyAbstractSpinBox : public QAbstractSpinBox
+{
+public:
+ MyAbstractSpinBox() : QAbstractSpinBox() {}
+ QLineEdit *lineEdit() { return QAbstractSpinBox::lineEdit(); }
+ void setLineEdit(QLineEdit *le) { QAbstractSpinBox::setLineEdit(le); }
+};
+
+// Testing get/set functions
+void tst_QAbstractSpinBox::getSetCheck()
+{
+ MyAbstractSpinBox obj1;
+ // ButtonSymbols QAbstractSpinBox::buttonSymbols()
+ // void QAbstractSpinBox::setButtonSymbols(ButtonSymbols)
+ obj1.setButtonSymbols(QAbstractSpinBox::ButtonSymbols(QAbstractSpinBox::UpDownArrows));
+ QCOMPARE(QAbstractSpinBox::ButtonSymbols(QAbstractSpinBox::UpDownArrows), obj1.buttonSymbols());
+ obj1.setButtonSymbols(QAbstractSpinBox::ButtonSymbols(QAbstractSpinBox::PlusMinus));
+ QCOMPARE(QAbstractSpinBox::ButtonSymbols(QAbstractSpinBox::PlusMinus), obj1.buttonSymbols());
+
+ // bool QAbstractSpinBox::wrapping()
+ // void QAbstractSpinBox::setWrapping(bool)
+ obj1.setWrapping(false);
+ QCOMPARE(false, obj1.wrapping());
+ obj1.setWrapping(true);
+ QCOMPARE(true, obj1.wrapping());
+
+ // QLineEdit * QAbstractSpinBox::lineEdit()
+ // void QAbstractSpinBox::setLineEdit(QLineEdit *)
+ QLineEdit *var3 = new QLineEdit(0);
+ obj1.setLineEdit(var3);
+ QCOMPARE(var3, obj1.lineEdit());
+#ifndef QT_DEBUG
+ obj1.setLineEdit((QLineEdit *)0); // Will assert in debug, so only test in release
+ QCOMPARE(var3, obj1.lineEdit()); // Setting 0 should keep the current editor
+#endif
+ // delete var3; // No delete, since QAbstractSpinBox takes ownership
+}
+
+void tst_QAbstractSpinBox::task183108_clear()
+{
+ QAbstractSpinBox *sbox;
+
+ sbox = new QSpinBox;
+ sbox->clear();
+ sbox->show();
+ qApp->processEvents();
+ QVERIFY(sbox->text().isEmpty());
+
+ delete sbox;
+ sbox = new QSpinBox;
+ sbox->clear();
+ sbox->show();
+ sbox->hide();
+ qApp->processEvents();
+ QCOMPARE(sbox->text(), QString());
+
+ delete sbox;
+ sbox = new QSpinBox;
+ sbox->show();
+ sbox->clear();
+ qApp->processEvents();
+ QCOMPARE(sbox->text(), QString());
+
+ delete sbox;
+ sbox = new QSpinBox;
+ sbox->show();
+ sbox->clear();
+ sbox->hide();
+ qApp->processEvents();
+ QCOMPARE(sbox->text(), QString());
+
+ delete sbox;
+}
+
+void tst_QAbstractSpinBox::task228728_cssselector()
+{
+ //QAbstractSpinBox does some call to stylehint into his constructor.
+ //so while the stylesheet want to access property, it should not crash
+ qApp->setStyleSheet("[alignement=\"1\"], [text=\"foo\"] { color:black; }" );
+ QSpinBox box;
+}
+
+
+QTEST_MAIN(tst_QAbstractSpinBox)
+#include "tst_qabstractspinbox.moc"
diff --git a/tests/auto/widgets/widgets/qbuttongroup/.gitignore b/tests/auto/widgets/widgets/qbuttongroup/.gitignore
new file mode 100644
index 0000000000..898b2276b0
--- /dev/null
+++ b/tests/auto/widgets/widgets/qbuttongroup/.gitignore
@@ -0,0 +1 @@
+tst_qbuttongroup
diff --git a/tests/auto/widgets/widgets/qbuttongroup/qbuttongroup.pro b/tests/auto/widgets/widgets/qbuttongroup/qbuttongroup.pro
new file mode 100644
index 0000000000..6f506e8f06
--- /dev/null
+++ b/tests/auto/widgets/widgets/qbuttongroup/qbuttongroup.pro
@@ -0,0 +1,6 @@
+load(qttest_p4)
+QT += widgets
+SOURCES += tst_qbuttongroup.cpp
+
+
+
diff --git a/tests/auto/widgets/widgets/qbuttongroup/tst_qbuttongroup.cpp b/tests/auto/widgets/widgets/qbuttongroup/tst_qbuttongroup.cpp
new file mode 100644
index 0000000000..f9f6ec0a54
--- /dev/null
+++ b/tests/auto/widgets/widgets/qbuttongroup/tst_qbuttongroup.cpp
@@ -0,0 +1,525 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#include <QtTest/QtTest>
+
+
+#include "qbuttongroup.h"
+#include <qaction.h>
+#include <qapplication.h>
+#include <qdialog.h>
+#include <qlayout.h>
+#include <qgroupbox.h>
+#include <qradiobutton.h>
+#include <qpushbutton.h>
+#include <qlineedit.h>
+#include <qtoolbutton.h>
+#ifdef Q_WS_MAC
+#include <qsettings.h>
+#endif
+
+class SpecialRadioButton: public QRadioButton
+{
+public:
+ SpecialRadioButton(QWidget *parent) : QRadioButton(parent)
+ { }
+
+protected:
+ void focusInEvent(QFocusEvent *)
+ {
+ QCoreApplication::postEvent(this, new QKeyEvent(QEvent::KeyPress,
+ Qt::Key_Down, Qt::NoModifier));
+ }
+};
+
+#include <qbuttongroup.h>
+
+//TESTED_CLASS=
+//TESTED_FILES=
+
+class tst_QButtonGroup : public QObject
+{
+Q_OBJECT
+public:
+ tst_QButtonGroup();
+
+public slots:
+ void initTestCase();
+ void cleanupTestCase();
+ void init();
+ void cleanup();
+private slots:
+ void arrowKeyNavigation();
+ void exclusive();
+ void exclusiveWithActions();
+ void testSignals();
+ void checkedButton();
+
+ void task106609();
+
+ void autoIncrementId();
+
+ void task209485_removeFromGroupInEventHandler_data();
+ void task209485_removeFromGroupInEventHandler();
+};
+
+tst_QButtonGroup::tst_QButtonGroup()
+{
+}
+
+
+void tst_QButtonGroup::initTestCase()
+{
+}
+
+void tst_QButtonGroup::cleanupTestCase()
+{
+}
+
+void tst_QButtonGroup::init()
+{
+}
+
+void tst_QButtonGroup::cleanup()
+{
+}
+
+QT_BEGIN_NAMESPACE
+extern bool Q_GUI_EXPORT qt_tab_all_widgets;
+QT_END_NAMESPACE
+
+
+void tst_QButtonGroup::arrowKeyNavigation()
+{
+ if (!qt_tab_all_widgets)
+ QSKIP("This test requires full keyboard control to be enabled.", SkipAll);
+
+ QDialog dlg(0);
+ QHBoxLayout layout(&dlg);
+ QGroupBox g1("1", &dlg);
+ QHBoxLayout g1layout(&g1);
+ QRadioButton bt1("Radio1", &g1);
+ QPushButton pb("PB", &g1);
+ QLineEdit le(&g1);
+ QRadioButton bt2("Radio2", &g1);
+ g1layout.addWidget(&bt1);
+ g1layout.addWidget(&pb);
+ g1layout.addWidget(&le);
+ g1layout.addWidget(&bt2);
+
+ // create a mixed button group with radion buttons and push
+ // buttons. Not very useful, but it tests borderline cases wrt
+ // focus handling.
+ QButtonGroup bgrp1(&g1);
+ bgrp1.addButton(&bt1);
+ bgrp1.addButton(&pb);
+ bgrp1.addButton(&bt2);
+
+ QGroupBox g2("2", &dlg);
+ QVBoxLayout g2layout(&g2);
+ // we don't need a button group here, because radio buttons are
+ // auto exclusive, i.e. they group themselves in he same parent
+ // widget.
+ QRadioButton bt3("Radio3", &g2);
+ QRadioButton bt4("Radio4", &g2);
+ g2layout.addWidget(&bt3);
+ g2layout.addWidget(&bt4);
+
+ layout.addWidget(&g1);
+ layout.addWidget(&g2);
+
+ dlg.show();
+ qApp->setActiveWindow(&dlg);
+ QTest::qWaitForWindowShown(&dlg);
+
+ bt1.setFocus();
+
+ QTRY_VERIFY(bt1.hasFocus());
+
+ QTest::keyClick(&bt1, Qt::Key_Right);
+ QVERIFY(pb.hasFocus());
+ QTest::keyClick(&pb, Qt::Key_Right);
+ QVERIFY(bt2.hasFocus());
+ QTest::keyClick(&bt2, Qt::Key_Right);
+ QVERIFY(bt2.hasFocus());
+ QTest::keyClick(&bt2, Qt::Key_Left);
+ QVERIFY(pb.hasFocus());
+ QTest::keyClick(&pb, Qt::Key_Left);
+ QVERIFY(bt1.hasFocus());
+
+ QTest::keyClick(&bt1, Qt::Key_Tab);
+ QVERIFY(pb.hasFocus());
+ QTest::keyClick(&pb, Qt::Key_Tab);
+
+ QVERIFY(le.hasFocus());
+ QCOMPARE(le.selectedText(), le.text());
+ QTest::keyClick(&le, Qt::Key_Tab);
+
+ QVERIFY(bt2.hasFocus());
+ QTest::keyClick(&bt2, Qt::Key_Tab);
+ QVERIFY(bt3.hasFocus());
+
+ QTest::keyClick(&bt3, Qt::Key_Down);
+ QVERIFY(bt4.hasFocus());
+ QTest::keyClick(&bt4, Qt::Key_Down);
+ QVERIFY(bt4.hasFocus());
+
+ QTest::keyClick(&bt4, Qt::Key_Up);
+ QVERIFY(bt3.hasFocus());
+ QTest::keyClick(&bt3, Qt::Key_Up);
+ QVERIFY(bt3.hasFocus());
+}
+
+void tst_QButtonGroup::exclusiveWithActions()
+{
+ QDialog dlg(0);
+ QHBoxLayout layout(&dlg);
+ QAction *action1 = new QAction("Action 1", &dlg);
+ action1->setCheckable(true);
+ QAction *action2 = new QAction("Action 2", &dlg);
+ action2->setCheckable(true);
+ QAction *action3 = new QAction("Action 3", &dlg);
+ action3->setCheckable(true);
+ QToolButton *toolButton1 = new QToolButton(&dlg);
+ QToolButton *toolButton2 = new QToolButton(&dlg);
+ QToolButton *toolButton3 = new QToolButton(&dlg);
+ toolButton1->setDefaultAction(action1);
+ toolButton2->setDefaultAction(action2);
+ toolButton3->setDefaultAction(action3);
+ layout.addWidget(toolButton1);
+ layout.addWidget(toolButton2);
+ layout.addWidget(toolButton3);
+ QButtonGroup *buttonGroup = new QButtonGroup( &dlg );
+ buttonGroup->setExclusive(true);
+ buttonGroup->addButton(toolButton1, 1);
+ buttonGroup->addButton(toolButton2, 2);
+ buttonGroup->addButton(toolButton3, 3);
+ dlg.show();
+
+ QTest::mouseClick(toolButton1, Qt::LeftButton);
+ QVERIFY(toolButton1->isChecked());
+ QVERIFY(action1->isChecked());
+ QVERIFY(!toolButton2->isChecked());
+ QVERIFY(!toolButton3->isChecked());
+ QVERIFY(!action2->isChecked());
+ QVERIFY(!action3->isChecked());
+
+ QTest::mouseClick(toolButton2, Qt::LeftButton);
+ QVERIFY(toolButton2->isChecked());
+ QVERIFY(action2->isChecked());
+ QVERIFY(!toolButton1->isChecked());
+ QVERIFY(!toolButton3->isChecked());
+ QVERIFY(!action1->isChecked());
+ QVERIFY(!action3->isChecked());
+
+ QTest::mouseClick(toolButton3, Qt::LeftButton);
+ QVERIFY(toolButton3->isChecked());
+ QVERIFY(action3->isChecked());
+ QVERIFY(!toolButton1->isChecked());
+ QVERIFY(!toolButton2->isChecked());
+ QVERIFY(!action1->isChecked());
+ QVERIFY(!action2->isChecked());
+
+ QTest::mouseClick(toolButton2, Qt::LeftButton);
+ QVERIFY(toolButton2->isChecked());
+ QVERIFY(action2->isChecked());
+ QVERIFY(!toolButton1->isChecked());
+ QVERIFY(!toolButton3->isChecked());
+ QVERIFY(!action1->isChecked());
+ QVERIFY(!action3->isChecked());
+}
+
+void tst_QButtonGroup::exclusive()
+{
+ QDialog dlg(0);
+ QHBoxLayout layout(&dlg);
+ QPushButton *pushButton1 = new QPushButton(&dlg);
+ QPushButton *pushButton2 = new QPushButton(&dlg);
+ QPushButton *pushButton3 = new QPushButton(&dlg);
+ pushButton1->setCheckable(true);
+ pushButton2->setCheckable(true);
+ pushButton3->setCheckable(true);
+ layout.addWidget(pushButton1);
+ layout.addWidget(pushButton2);
+ layout.addWidget(pushButton3);
+ QButtonGroup *buttonGroup = new QButtonGroup( &dlg );
+ buttonGroup->setExclusive(true);
+ buttonGroup->addButton(pushButton1, 1);
+ buttonGroup->addButton(pushButton2, 2);
+ buttonGroup->addButton(pushButton3, 3);
+ dlg.show();
+
+ QTest::mouseClick(pushButton1, Qt::LeftButton);
+ QVERIFY(pushButton1->isChecked());
+ QVERIFY(!pushButton2->isChecked());
+ QVERIFY(!pushButton3->isChecked());
+
+ QTest::mouseClick(pushButton2, Qt::LeftButton);
+ QVERIFY(pushButton2->isChecked());
+ QVERIFY(!pushButton1->isChecked());
+ QVERIFY(!pushButton3->isChecked());
+
+ QTest::mouseClick(pushButton3, Qt::LeftButton);
+ QVERIFY(pushButton3->isChecked());
+ QVERIFY(!pushButton1->isChecked());
+ QVERIFY(!pushButton2->isChecked());
+
+ QTest::mouseClick(pushButton2, Qt::LeftButton);
+ QVERIFY(pushButton2->isChecked());
+ QVERIFY(!pushButton1->isChecked());
+ QVERIFY(!pushButton3->isChecked());
+}
+
+void tst_QButtonGroup::testSignals()
+{
+ QButtonGroup buttons;
+ QPushButton pb1;
+ QPushButton pb2;
+ QPushButton pb3;
+ buttons.addButton(&pb1);
+ buttons.addButton(&pb2, 23);
+ buttons.addButton(&pb3);
+
+ qRegisterMetaType<QAbstractButton *>("QAbstractButton *");
+ QSignalSpy clickedSpy(&buttons, SIGNAL(buttonClicked(QAbstractButton *)));
+ QSignalSpy clickedIdSpy(&buttons, SIGNAL(buttonClicked(int)));
+ QSignalSpy pressedSpy(&buttons, SIGNAL(buttonPressed(QAbstractButton *)));
+ QSignalSpy pressedIdSpy(&buttons, SIGNAL(buttonPressed(int)));
+ QSignalSpy releasedSpy(&buttons, SIGNAL(buttonReleased(QAbstractButton *)));
+ QSignalSpy releasedIdSpy(&buttons, SIGNAL(buttonReleased(int)));
+
+ pb1.animateClick();
+ QTestEventLoop::instance().enterLoop(1);
+
+ QCOMPARE(clickedSpy.count(), 1);
+ QCOMPARE(clickedIdSpy.count(), 1);
+
+ int expectedId = -2;
+
+ QVERIFY(clickedIdSpy.takeFirst().at(0).toInt() == expectedId);
+ QCOMPARE(pressedSpy.count(), 1);
+ QCOMPARE(pressedIdSpy.count(), 1);
+ QVERIFY(pressedIdSpy.takeFirst().at(0).toInt() == expectedId);
+ QCOMPARE(releasedSpy.count(), 1);
+ QCOMPARE(releasedIdSpy.count(), 1);
+ QVERIFY(releasedIdSpy.takeFirst().at(0).toInt() == expectedId);
+
+ clickedSpy.clear();
+ clickedIdSpy.clear();
+ pressedSpy.clear();
+ pressedIdSpy.clear();
+ releasedSpy.clear();
+ releasedIdSpy.clear();
+
+ pb2.animateClick();
+ QTestEventLoop::instance().enterLoop(1);
+
+ QCOMPARE(clickedSpy.count(), 1);
+ QCOMPARE(clickedIdSpy.count(), 1);
+ QVERIFY(clickedIdSpy.takeFirst().at(0).toInt() == 23);
+ QCOMPARE(pressedSpy.count(), 1);
+ QCOMPARE(pressedIdSpy.count(), 1);
+ QVERIFY(pressedIdSpy.takeFirst().at(0).toInt() == 23);
+ QCOMPARE(releasedSpy.count(), 1);
+ QCOMPARE(releasedIdSpy.count(), 1);
+ QVERIFY(releasedIdSpy.takeFirst().at(0).toInt() == 23);
+}
+
+void tst_QButtonGroup::task106609()
+{
+ // task is:
+ // sometimes, only one of the two signals in QButtonGroup get emitted
+ // they get emitted when using the mouse, but when using the keyboard, only one is
+ //
+
+ QDialog dlg(0);
+ QButtonGroup *buttons = new QButtonGroup(&dlg);
+ QVBoxLayout *vbox = new QVBoxLayout(&dlg);
+
+ SpecialRadioButton *radio1 = new SpecialRadioButton(&dlg);
+ radio1->setText("radio1");
+ SpecialRadioButton *radio2 = new SpecialRadioButton(&dlg);
+ radio2->setText("radio2");
+ QRadioButton *radio3 = new QRadioButton(&dlg);
+ radio3->setText("radio3");
+
+ buttons->addButton(radio1, 1);
+ vbox->addWidget(radio1);
+ buttons->addButton(radio2, 2);
+ vbox->addWidget(radio2);
+ buttons->addButton(radio3, 3);
+ vbox->addWidget(radio3);
+ dlg.show();
+ QTest::qWaitForWindowShown(&dlg);
+
+ qRegisterMetaType<QAbstractButton*>("QAbstractButton*");
+ QSignalSpy spy1(buttons, SIGNAL(buttonClicked(QAbstractButton*)));
+ QSignalSpy spy2(buttons, SIGNAL(buttonClicked(int)));
+
+ QApplication::setActiveWindow(&dlg);
+ QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget*>(&dlg));
+
+ radio1->setFocus();
+ radio1->setChecked(true);
+ QTestEventLoop::instance().enterLoop(1);
+
+ //qDebug() << "int:" << spy2.count() << "QAbstractButton*:" << spy1.count();
+ QCOMPARE(spy2.count(), 2);
+ QCOMPARE(spy1.count(), 2);
+}
+
+void tst_QButtonGroup::checkedButton()
+{
+ QButtonGroup buttons;
+ buttons.setExclusive(false);
+ QPushButton pb1;
+ pb1.setCheckable(true);
+ QPushButton pb2;
+ pb2.setCheckable(true);
+ buttons.addButton(&pb1);
+ buttons.addButton(&pb2, 23);
+
+ QVERIFY(buttons.checkedButton() == 0);
+ pb1.setChecked(true);
+ QVERIFY(buttons.checkedButton() == &pb1);
+ pb2.setChecked(true);
+ QVERIFY(buttons.checkedButton() == &pb2);
+ pb2.setChecked(false);
+ QVERIFY(buttons.checkedButton() == &pb1);
+ pb1.setChecked(false);
+ QVERIFY(buttons.checkedButton() == 0);
+
+ buttons.setExclusive(true);
+ QVERIFY(buttons.checkedButton() == 0);
+ pb1.setChecked(true);
+ QVERIFY(buttons.checkedButton() == &pb1);
+ pb2.setChecked(true);
+ QVERIFY(buttons.checkedButton() == &pb2);
+ // checked button cannot be unchecked
+ pb2.setChecked(false);
+ QVERIFY(buttons.checkedButton() == &pb2);
+}
+
+class task209485_ButtonDeleter : public QObject
+{
+ Q_OBJECT
+
+public:
+ task209485_ButtonDeleter(QButtonGroup *group, bool deleteButton)
+ : group(group)
+ , deleteButton(deleteButton)
+ {
+ connect(group, SIGNAL(buttonClicked(int)), SLOT(buttonClicked(int)));
+ }
+
+private slots:
+ void buttonClicked(int)
+ {
+ if (deleteButton)
+ group->removeButton(group->buttons().first());
+ }
+
+private:
+ QButtonGroup *group;
+ bool deleteButton;
+};
+
+void tst_QButtonGroup::task209485_removeFromGroupInEventHandler_data()
+{
+ QTest::addColumn<bool>("deleteButton");
+ QTest::addColumn<int>("signalCount");
+ QTest::newRow("buttonPress 1") << true << 1;
+ QTest::newRow("buttonPress 2") << false << 2;
+}
+
+void tst_QButtonGroup::task209485_removeFromGroupInEventHandler()
+{
+ QFETCH(bool, deleteButton);
+ QFETCH(int, signalCount);
+ qRegisterMetaType<QAbstractButton *>("QAbstractButton *");
+
+ QPushButton *button = new QPushButton;
+ QButtonGroup group;
+ group.addButton(button);
+
+ task209485_ButtonDeleter buttonDeleter(&group, deleteButton);
+
+ QSignalSpy spy1(&group, SIGNAL(buttonClicked(QAbstractButton *)));
+ QSignalSpy spy2(&group, SIGNAL(buttonClicked(int)));
+
+ // NOTE: Reintroducing the bug of this task will cause the following line to crash:
+ QTest::mouseClick(button, Qt::LeftButton);
+
+ QCOMPARE(spy1.count() + spy2.count(), signalCount);
+}
+
+void tst_QButtonGroup::autoIncrementId()
+{
+ QDialog dlg(0);
+ QButtonGroup *buttons = new QButtonGroup(&dlg);
+ QVBoxLayout *vbox = new QVBoxLayout(&dlg);
+
+ QRadioButton *radio1 = new QRadioButton(&dlg);
+ radio1->setText("radio1");
+ QRadioButton *radio2 = new QRadioButton(&dlg);
+ radio2->setText("radio2");
+ QRadioButton *radio3 = new QRadioButton(&dlg);
+ radio3->setText("radio3");
+
+ buttons->addButton(radio1);
+ vbox->addWidget(radio1);
+ buttons->addButton(radio2);
+ vbox->addWidget(radio2);
+ buttons->addButton(radio3);
+ vbox->addWidget(radio3);
+
+ radio1->setChecked(true);
+
+ QVERIFY(buttons->id(radio1) == -2);
+ QVERIFY(buttons->id(radio2) == -3);
+ QVERIFY(buttons->id(radio3) == -4);
+
+ dlg.show();
+}
+
+QTEST_MAIN(tst_QButtonGroup)
+#include "tst_qbuttongroup.moc"
diff --git a/tests/auto/widgets/widgets/qcalendarwidget/.gitignore b/tests/auto/widgets/widgets/qcalendarwidget/.gitignore
new file mode 100644
index 0000000000..db8a381e0d
--- /dev/null
+++ b/tests/auto/widgets/widgets/qcalendarwidget/.gitignore
@@ -0,0 +1 @@
+tst_qcalendarwidget
diff --git a/tests/auto/widgets/widgets/qcalendarwidget/qcalendarwidget.pro b/tests/auto/widgets/widgets/qcalendarwidget/qcalendarwidget.pro
new file mode 100644
index 0000000000..d250b83537
--- /dev/null
+++ b/tests/auto/widgets/widgets/qcalendarwidget/qcalendarwidget.pro
@@ -0,0 +1,5 @@
+load(qttest_p4)
+QT += widgets
+SOURCES += tst_qcalendarwidget.cpp
+
+
diff --git a/tests/auto/widgets/widgets/qcalendarwidget/tst_qcalendarwidget.cpp b/tests/auto/widgets/widgets/qcalendarwidget/tst_qcalendarwidget.cpp
new file mode 100644
index 0000000000..50dc6a1d1c
--- /dev/null
+++ b/tests/auto/widgets/widgets/qcalendarwidget/tst_qcalendarwidget.cpp
@@ -0,0 +1,368 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#include <QtTest/QtTest>
+
+#include <qcalendarwidget.h>
+#include <qtoolbutton.h>
+#include <qspinbox.h>
+#include <qmenu.h>
+#include <qdebug.h>
+#include <qdatetime.h>
+#include <qtextformat.h>
+
+
+//TESTED_CLASS=
+//TESTED_FILES=
+
+class tst_QCalendarWidget : public QObject
+{
+ Q_OBJECT
+
+public:
+ tst_QCalendarWidget();
+ virtual ~tst_QCalendarWidget();
+public slots:
+ void initTestCase();
+ void cleanupTestCase();
+ void init();
+ void cleanup();
+
+private slots:
+ void getSetCheck();
+ void buttonClickCheck();
+
+ void setTextFormat();
+ void resetTextFormat();
+
+ void setWeekdayFormat();
+ void showPrevNext_data();
+ void showPrevNext();
+};
+
+// Testing get/set functions
+void tst_QCalendarWidget::getSetCheck()
+{
+ QWidget topLevel;
+ QCalendarWidget object(&topLevel);
+
+ //horizontal header formats
+ object.setHorizontalHeaderFormat(QCalendarWidget::NoHorizontalHeader);
+ QCOMPARE(QCalendarWidget::NoHorizontalHeader, object.horizontalHeaderFormat());
+ object.setHorizontalHeaderFormat(QCalendarWidget::SingleLetterDayNames);
+ QCOMPARE(QCalendarWidget::SingleLetterDayNames, object.horizontalHeaderFormat());
+ object.setHorizontalHeaderFormat(QCalendarWidget::ShortDayNames);
+ QCOMPARE(QCalendarWidget::ShortDayNames, object.horizontalHeaderFormat());
+ object.setHorizontalHeaderFormat(QCalendarWidget::LongDayNames);
+ QCOMPARE(QCalendarWidget::LongDayNames, object.horizontalHeaderFormat());
+ //vertical header formats
+ object.setVerticalHeaderFormat(QCalendarWidget::ISOWeekNumbers);
+ QCOMPARE(QCalendarWidget::ISOWeekNumbers, object.verticalHeaderFormat());
+ object.setVerticalHeaderFormat(QCalendarWidget::NoVerticalHeader);
+ QCOMPARE(QCalendarWidget::NoVerticalHeader, object.verticalHeaderFormat());
+ //maximum Date
+ QDate maxDate(2006, 7, 3);
+ object.setMaximumDate(maxDate);
+ QCOMPARE(maxDate, object.maximumDate());
+ //minimum date
+ QDate minDate(2004, 7, 3);
+ object.setMinimumDate(minDate);
+ QCOMPARE(minDate, object.minimumDate());
+ //day of week
+ object.setFirstDayOfWeek(Qt::Thursday);
+ QCOMPARE(Qt::Thursday, object.firstDayOfWeek());
+ //grid visible
+ object.setGridVisible(true);
+ QVERIFY(object.isGridVisible());
+ object.setGridVisible(false);
+ QVERIFY(!object.isGridVisible());
+ //header visible
+ object.setNavigationBarVisible(true);
+ QVERIFY(object.isNavigationBarVisible());
+ object.setNavigationBarVisible(false);
+ QVERIFY(!object.isNavigationBarVisible());
+ //selection mode
+ QCOMPARE(QCalendarWidget::SingleSelection, object.selectionMode());
+ object.setSelectionMode(QCalendarWidget::NoSelection);
+ QCOMPARE(QCalendarWidget::NoSelection, object.selectionMode());
+ object.setSelectionMode(QCalendarWidget::SingleSelection);
+ QCOMPARE(QCalendarWidget::SingleSelection, object.selectionMode());
+ //selected date
+ QDate selectedDate(2005, 7, 3);
+ QSignalSpy spy(&object, SIGNAL(selectionChanged()));
+ object.setSelectedDate(selectedDate);
+ QCOMPARE(spy.count(), 1);
+ QCOMPARE(selectedDate, object.selectedDate());
+ //month and year
+ object.setCurrentPage(2004, 1);
+ QCOMPARE(1, object.monthShown());
+ QCOMPARE(2004, object.yearShown());
+ object.showNextMonth();
+ QCOMPARE(2, object.monthShown());
+ object.showPreviousMonth();
+ QCOMPARE(1, object.monthShown());
+ object.showNextYear();
+ QCOMPARE(2005, object.yearShown());
+ object.showPreviousYear();
+ QCOMPARE(2004, object.yearShown());
+ //date range
+ minDate = QDate(2006,1,1);
+ maxDate = QDate(2010,12,31);
+ object.setDateRange(minDate, maxDate);
+ QCOMPARE(maxDate, object.maximumDate());
+ QCOMPARE(minDate, object.minimumDate());
+
+ //date should not go beyond the minimum.
+ selectedDate = minDate.addDays(-10);
+ object.setSelectedDate(selectedDate);
+ QCOMPARE(minDate, object.selectedDate());
+ QVERIFY(selectedDate != object.selectedDate());
+ //date should not go beyond the maximum.
+ selectedDate = maxDate.addDays(10);
+ object.setSelectedDate(selectedDate);
+ QCOMPARE(maxDate, object.selectedDate());
+ QVERIFY(selectedDate != object.selectedDate());
+ //show today
+ QDate today = QDate::currentDate();
+ object.showToday();
+ QCOMPARE(today.month(), object.monthShown());
+ QCOMPARE(today.year(), object.yearShown());
+ //slect a different date and move.
+ object.setSelectedDate(minDate);
+ object.showSelectedDate();
+ QCOMPARE(minDate.month(), object.monthShown());
+ QCOMPARE(minDate.year(), object.yearShown());
+}
+
+void tst_QCalendarWidget::buttonClickCheck()
+{
+ QCalendarWidget object;
+ QSize size = object.sizeHint();
+ object.setGeometry(0,0,size.width(), size.height());
+ object.show();
+
+ QRect rect = object.geometry();
+ QDate selectedDate(2005, 1, 1);
+ //click on the month buttons
+ int month = object.monthShown();
+ QToolButton *button = qFindChild<QToolButton *>(&object, "qt_calendar_prevmonth");
+ QTest::mouseClick(button, Qt::LeftButton);
+ QCOMPARE(month > 1 ? month-1 : 12, object.monthShown());
+ button = qFindChild<QToolButton *>(&object, "qt_calendar_nextmonth");
+ QTest::mouseClick(button, Qt::LeftButton);
+ QCOMPARE(month, object.monthShown());
+
+ button = qFindChild<QToolButton *>(&object, "qt_calendar_yearbutton");
+ QTest::mouseClick(button, Qt::LeftButton, Qt::NoModifier, button->rect().center(), 2);
+ QVERIFY(!button->isVisible());
+ QSpinBox *spinbox = qFindChild<QSpinBox *>(&object, "qt_calendar_yearedit");
+ QTest::qWait(500);
+ QTest::keyClick(spinbox, '2');
+ QTest::keyClick(spinbox, '0');
+ QTest::keyClick(spinbox, '0');
+ QTest::keyClick(spinbox, '6');
+ QTest::qWait(500);
+ QWidget *widget = qFindChild<QWidget *>(&object, "qt_calendar_calendarview");
+ QTest::mouseMove(widget);
+ QTest::mouseClick(widget, Qt::LeftButton);
+ QCOMPARE(2006, object.yearShown());
+ object.setSelectedDate(selectedDate);
+ object.showSelectedDate();
+ QTest::keyClick(widget, Qt::Key_Down);
+ QVERIFY(selectedDate != object.selectedDate());
+
+ object.setDateRange(QDate(2006,1,1), QDate(2006,2,28));
+ object.setSelectedDate(QDate(2006,1,1));
+ object.showSelectedDate();
+ button = qFindChild<QToolButton *>(&object, "qt_calendar_prevmonth");
+ QTest::mouseClick(button, Qt::LeftButton);
+ QCOMPARE(1, object.monthShown());
+
+ button = qFindChild<QToolButton *>(&object, "qt_calendar_nextmonth");
+ QTest::mouseClick(button, Qt::LeftButton);
+ QCOMPARE(2, object.monthShown());
+ QTest::mouseClick(button, Qt::LeftButton);
+ QCOMPARE(2, object.monthShown());
+
+}
+
+void tst_QCalendarWidget::setTextFormat()
+{
+ QCalendarWidget calendar;
+ QTextCharFormat format;
+ format.setFontItalic(true);
+ format.setForeground(Qt::green);
+
+ const QDate date(1984, 10, 20);
+ calendar.setDateTextFormat(date, format);
+ QCOMPARE(calendar.dateTextFormat(date), format);
+}
+
+void tst_QCalendarWidget::resetTextFormat()
+{
+ QCalendarWidget calendar;
+ QTextCharFormat format;
+ format.setFontItalic(true);
+ format.setForeground(Qt::green);
+
+ const QDate date(1984, 10, 20);
+ calendar.setDateTextFormat(date, format);
+
+ calendar.setDateTextFormat(QDate(), QTextCharFormat());
+ QCOMPARE(calendar.dateTextFormat(date), QTextCharFormat());
+}
+
+void tst_QCalendarWidget::setWeekdayFormat()
+{
+ QCalendarWidget calendar;
+
+ QTextCharFormat format;
+ format.setFontItalic(true);
+ format.setForeground(Qt::green);
+
+ calendar.setWeekdayTextFormat(Qt::Wednesday, format);
+
+ // check the format of the a given month
+ for (int i = 1; i <= 31; ++i) {
+ const QDate date(1984, 10, i);
+ const Qt::DayOfWeek dayOfWeek = static_cast<Qt::DayOfWeek>(date.dayOfWeek());
+ if (dayOfWeek == Qt::Wednesday)
+ QCOMPARE(calendar.weekdayTextFormat(dayOfWeek), format);
+ else
+ QVERIFY(calendar.weekdayTextFormat(dayOfWeek) != format);
+ }
+}
+
+tst_QCalendarWidget::tst_QCalendarWidget()
+{
+}
+
+tst_QCalendarWidget::~tst_QCalendarWidget()
+{
+}
+
+void tst_QCalendarWidget::initTestCase()
+{
+}
+
+void tst_QCalendarWidget::cleanupTestCase()
+{
+}
+
+void tst_QCalendarWidget::init()
+{
+}
+
+void tst_QCalendarWidget::cleanup()
+{
+}
+
+
+typedef void (QCalendarWidget::*ShowFunc)();
+Q_DECLARE_METATYPE(ShowFunc)
+
+void tst_QCalendarWidget::showPrevNext_data()
+{
+ QTest::addColumn<ShowFunc>("function");
+ QTest::addColumn<QDate>("dateOrigin");
+ QTest::addColumn<QDate>("expectedDate");
+
+ QTest::newRow("showNextMonth") << &QCalendarWidget::showNextMonth << QDate(1984,7,30) << QDate(1984,8,30);
+ QTest::newRow("showPrevMonth") << &QCalendarWidget::showPreviousMonth << QDate(1984,7,30) << QDate(1984,6,30);
+ QTest::newRow("showNextYear") << &QCalendarWidget::showNextYear << QDate(1984,7,30) << QDate(1985,7,30);
+ QTest::newRow("showPrevYear") << &QCalendarWidget::showPreviousYear << QDate(1984,7,30) << QDate(1983,7,30);
+
+ QTest::newRow("showNextMonth limit") << &QCalendarWidget::showNextMonth << QDate(2007,12,4) << QDate(2008,1,4);
+ QTest::newRow("showPreviousMonth limit") << &QCalendarWidget::showPreviousMonth << QDate(2006,1,23) << QDate(2005,12,23);
+
+ QTest::newRow("showNextMonth now") << &QCalendarWidget::showNextMonth << QDate() << QDate::currentDate().addMonths(1);
+ QTest::newRow("showNextYear now") << &QCalendarWidget::showNextYear << QDate() << QDate::currentDate().addYears(1);
+ QTest::newRow("showPrevieousMonth now") << &QCalendarWidget::showPreviousMonth << QDate() << QDate::currentDate().addMonths(-1);
+ QTest::newRow("showPreviousYear now") << &QCalendarWidget::showPreviousYear << QDate() << QDate::currentDate().addYears(-1);
+
+ QTest::newRow("showToday now") << &QCalendarWidget::showToday << QDate(2000,1,31) << QDate::currentDate();
+ QTest::newRow("showNextMonth 31") << &QCalendarWidget::showNextMonth << QDate(2000,1,31) << QDate(2000,2,28);
+ QTest::newRow("selectedDate") << &QCalendarWidget::showSelectedDate << QDate(2008,2,29) << QDate(2008,2,29);
+
+}
+
+void tst_QCalendarWidget::showPrevNext()
+{
+ QFETCH(ShowFunc, function);
+ QFETCH(QDate, dateOrigin);
+ QFETCH(QDate, expectedDate);
+
+ QCalendarWidget calWidget;
+ calWidget.show();
+ QTest::qWaitForWindowShown(&calWidget);
+ if(!dateOrigin.isNull()) {
+ calWidget.setSelectedDate(dateOrigin);
+ calWidget.setCurrentPage(dateOrigin.year(), dateOrigin.month());
+
+ QCOMPARE(calWidget.yearShown(), dateOrigin.year());
+ QCOMPARE(calWidget.monthShown(), dateOrigin.month());
+ } else {
+ QCOMPARE(calWidget.yearShown(), QDate::currentDate().year());
+ QCOMPARE(calWidget.monthShown(), QDate::currentDate().month());
+ }
+
+ (calWidget.*function)();
+
+ QCOMPARE(calWidget.yearShown(), expectedDate.year());
+ QCOMPARE(calWidget.monthShown(), expectedDate.month());
+
+ // QTBUG-4058
+ QTest::qWait(20);
+ QToolButton *button = qFindChild<QToolButton *>(&calWidget, "qt_calendar_prevmonth");
+ QTest::mouseClick(button, Qt::LeftButton);
+ expectedDate = expectedDate.addMonths(-1);
+ QCOMPARE(calWidget.yearShown(), expectedDate.year());
+ QCOMPARE(calWidget.monthShown(), expectedDate.month());
+
+ if(!dateOrigin.isNull()) {
+ //the selectedDate should not have changed
+ QCOMPARE(calWidget.selectedDate(), dateOrigin);
+ }
+}
+
+QTEST_MAIN(tst_QCalendarWidget)
+#include "tst_qcalendarwidget.moc"
diff --git a/tests/auto/widgets/widgets/qcheckbox/.gitignore b/tests/auto/widgets/widgets/qcheckbox/.gitignore
new file mode 100644
index 0000000000..b838802077
--- /dev/null
+++ b/tests/auto/widgets/widgets/qcheckbox/.gitignore
@@ -0,0 +1 @@
+tst_qcheckbox
diff --git a/tests/auto/widgets/widgets/qcheckbox/qcheckbox.pro b/tests/auto/widgets/widgets/qcheckbox/qcheckbox.pro
new file mode 100644
index 0000000000..aa1f35b3c9
--- /dev/null
+++ b/tests/auto/widgets/widgets/qcheckbox/qcheckbox.pro
@@ -0,0 +1,6 @@
+load(qttest_p4)
+QT += widgets
+SOURCES += tst_qcheckbox.cpp
+
+
+
diff --git a/tests/auto/widgets/widgets/qcheckbox/tst_qcheckbox.cpp b/tests/auto/widgets/widgets/qcheckbox/tst_qcheckbox.cpp
new file mode 100644
index 0000000000..33f5af4d0b
--- /dev/null
+++ b/tests/auto/widgets/widgets/qcheckbox/tst_qcheckbox.cpp
@@ -0,0 +1,358 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#include <QtTest/QtTest>
+
+
+#include "qcheckbox.h"
+#include <qapplication.h>
+#include <qpixmap.h>
+#include <qdatetime.h>
+#include <qcheckbox.h>
+
+//TESTED_CLASS=
+//TESTED_FILES=
+
+class tst_QCheckBox : public QObject
+{
+Q_OBJECT
+
+public:
+ tst_QCheckBox();
+ virtual ~tst_QCheckBox();
+
+public slots:
+ void initTestCase();
+ void cleanupTestCase();
+ void init();
+ void cleanup();
+
+private slots:
+ void setChecked();
+ void setTriState();
+ void setText_data();
+ void setText();
+ void isToggleButton();
+ void setDown();
+ void setAutoRepeat();
+ void toggle();
+ void pressed();
+ void toggled();
+ void stateChanged();
+ void foregroundRole();
+ void minimumSizeHint();
+
+protected slots:
+ void onClicked();
+ void onToggled( bool on );
+ void onPressed();
+ void onReleased();
+ void onStateChanged( int state );
+
+private:
+ uint click_count;
+ uint toggle_count;
+ uint press_count;
+ uint release_count;
+ int cur_state;
+ uint tmp;
+ QCheckBox *testWidget;
+ uint tmp2;
+};
+
+tst_QCheckBox::tst_QCheckBox()
+{
+}
+
+tst_QCheckBox::~tst_QCheckBox()
+{
+}
+
+void tst_QCheckBox::initTestCase()
+{
+ // Create the test class
+ testWidget = new QCheckBox(0);
+ testWidget->setObjectName("testObject");
+ testWidget->resize( 200, 200 );
+ testWidget->show();
+}
+
+void tst_QCheckBox::cleanupTestCase()
+{
+ delete testWidget;
+ testWidget = 0;
+}
+
+void tst_QCheckBox::init()
+{
+ testWidget->setTristate( FALSE );
+ testWidget->setChecked( FALSE );
+ testWidget->setAutoRepeat( FALSE );
+}
+
+void tst_QCheckBox::cleanup()
+{
+ disconnect(testWidget, SIGNAL(pressed()), this, SLOT(onPressed()));
+ disconnect(testWidget, SIGNAL(released()), this, SLOT(onReleased()));
+ disconnect(testWidget, SIGNAL(clicked()), this, SLOT(onClicked()));
+ disconnect(testWidget, SIGNAL(toggled(bool)), this, SLOT(onToggled(bool)));
+}
+
+void tst_QCheckBox::onClicked()
+{
+ click_count++;
+}
+
+void tst_QCheckBox::onPressed()
+{
+ press_count++;
+}
+
+void tst_QCheckBox::onReleased()
+{
+ release_count++;
+}
+
+void tst_QCheckBox::onToggled( bool /*on*/ )
+{
+ toggle_count++;
+}
+
+// ***************************************************
+
+void tst_QCheckBox::setChecked()
+{
+ testWidget->setChecked( TRUE );
+ QVERIFY( testWidget->isChecked() );
+ QVERIFY( testWidget->isChecked() );
+ QVERIFY( testWidget->checkState() == Qt::Checked );
+
+ testWidget->setChecked( FALSE );
+ QVERIFY( !testWidget->isChecked() );
+ QVERIFY( !testWidget->isChecked() );
+ QVERIFY( testWidget->checkState() == Qt::Unchecked );
+
+ testWidget->setChecked( FALSE );
+ QTest::keyClick( testWidget, ' ' );
+ QVERIFY( testWidget->isChecked() );
+
+ QTest::keyClick( testWidget, ' ' );
+ QVERIFY( !testWidget->isChecked() );
+}
+
+void tst_QCheckBox::setTriState()
+{
+ testWidget->setTristate( TRUE );
+ QVERIFY( testWidget->isTristate() );
+ QVERIFY( testWidget->checkState() == Qt::Unchecked );
+
+ testWidget->setCheckState(Qt::PartiallyChecked);
+ QVERIFY( testWidget->checkState() == Qt::PartiallyChecked );
+
+ testWidget->setChecked( TRUE );
+ QVERIFY( testWidget->isChecked() );
+ QVERIFY( testWidget->checkState() == Qt::Checked );
+
+ testWidget->setChecked( FALSE );
+ QVERIFY( !testWidget->isChecked() );
+ QVERIFY( testWidget->checkState() == Qt::Unchecked );
+
+ testWidget->setCheckState(Qt::PartiallyChecked);
+ QVERIFY( testWidget->checkState() == Qt::PartiallyChecked );
+
+ testWidget->setTristate( FALSE );
+ QVERIFY( !testWidget->isTristate() );
+
+ testWidget->setCheckState(Qt::PartiallyChecked);
+ QVERIFY( testWidget->checkState() == Qt::PartiallyChecked );
+
+ testWidget->setChecked( TRUE );
+ QVERIFY( testWidget->checkState() == Qt::Checked );
+
+ testWidget->setChecked( FALSE );
+ QVERIFY( testWidget->checkState() == Qt::Unchecked );
+}
+
+void tst_QCheckBox::setText_data()
+{
+ QTest::addColumn<QString>("s1");
+
+#ifdef Q_OS_WIN32
+ QTest::newRow( "win32_data0" ) << QString("This is a text");
+ QTest::newRow( "win32_data1" ) << QString("A");
+ QTest::newRow( "win32_data2" ) << QString("ABCDEFG ");
+ QTest::newRow( "win32_data3" ) << QString("Text\nwith a cr-lf");
+ QTest::newRow( "win32_data4" ) << QString("");
+#else
+ QTest::newRow( "data0" ) << QString("This is a text");
+ QTest::newRow( "data1" ) << QString("A");
+ QTest::newRow( "data2" ) << QString("ABCDEFG ");
+ QTest::newRow( "data3" ) << QString("Text\nwith a cr-lf");
+ QTest::newRow( "data4" ) << QString("");
+#endif
+}
+
+void tst_QCheckBox::setText()
+{
+ QFETCH( QString, s1 );
+ testWidget->setText( s1 );
+ QCOMPARE( testWidget->text(), s1 );
+}
+
+void tst_QCheckBox::setDown()
+{
+ testWidget->setDown( TRUE );
+ QVERIFY( testWidget->isDown() );
+
+ testWidget->setDown( FALSE );
+ QVERIFY( !testWidget->isDown() );
+}
+
+void tst_QCheckBox::setAutoRepeat()
+{
+ // setAutoRepeat has no effect on toggle buttons
+ QVERIFY( testWidget->isCheckable() );
+}
+
+void tst_QCheckBox::toggle()
+{
+ bool cur_state;
+ cur_state = testWidget->isChecked();
+ testWidget->toggle();
+ QVERIFY( cur_state != testWidget->isChecked() );
+
+ cur_state = testWidget->isChecked();
+ testWidget->toggle();
+ QVERIFY( cur_state != testWidget->isChecked() );
+
+ cur_state = testWidget->isChecked();
+ testWidget->toggle();
+ QVERIFY( cur_state != testWidget->isChecked() );
+}
+
+void tst_QCheckBox::pressed()
+{
+ connect(testWidget, SIGNAL(pressed()), this, SLOT(onPressed()));
+ connect(testWidget, SIGNAL(released()), this, SLOT(onReleased()));
+ press_count = 0;
+ release_count = 0;
+ testWidget->setDown(FALSE);
+ QVERIFY( !testWidget->isChecked() );
+
+ QTest::keyPress( testWidget, Qt::Key_Space );
+ QTest::qWait(100);
+ QVERIFY( press_count == 1 );
+ QVERIFY( release_count == 0 );
+ QVERIFY( !testWidget->isChecked() );
+
+ QTest::keyRelease( testWidget, Qt::Key_Space );
+ QTest::qWait(100);
+ QVERIFY( press_count == 1 );
+ QVERIFY( release_count == 1 );
+ QVERIFY( testWidget->isChecked() );
+}
+
+void tst_QCheckBox::toggled()
+{
+ connect(testWidget, SIGNAL(toggled(bool)), this, SLOT(onToggled(bool)));
+ click_count = 0;
+ toggle_count = 0;
+ testWidget->toggle();
+ QCOMPARE( toggle_count, (uint)1 );
+
+ testWidget->toggle();
+ QCOMPARE( toggle_count, (uint)2 );
+
+ testWidget->toggle();
+ QCOMPARE( toggle_count, (uint)3 );
+
+ QCOMPARE( click_count, (uint)0 );
+}
+
+void tst_QCheckBox::onStateChanged( int state )
+{
+ cur_state = state;
+}
+
+void tst_QCheckBox::stateChanged()
+{
+ QSignalSpy stateChangedSpy(testWidget, SIGNAL(stateChanged(int)));
+ connect(testWidget, SIGNAL(stateChanged(int)), this, SLOT(onStateChanged(int)));
+ cur_state = -1;
+ testWidget->setChecked( TRUE );
+ qApp->processEvents();
+ QCOMPARE( cur_state, (int)2 );
+
+ cur_state = -1;
+ testWidget->setChecked( FALSE );
+ qApp->processEvents();
+ QCOMPARE( cur_state, (int)0 );
+
+ cur_state = -1;
+ testWidget->setCheckState(Qt::PartiallyChecked);
+ qApp->processEvents();
+ QCOMPARE( cur_state, (int)1 );
+
+ QCOMPARE(stateChangedSpy.count(), 3);
+ testWidget->setCheckState(Qt::PartiallyChecked);
+ qApp->processEvents();
+ QCOMPARE(stateChangedSpy.count(), 3);
+}
+
+void tst_QCheckBox::isToggleButton()
+{
+ QVERIFY( testWidget->isCheckable() );
+}
+
+void tst_QCheckBox::foregroundRole()
+{
+ QVERIFY(testWidget->foregroundRole() == QPalette::WindowText);
+}
+
+void tst_QCheckBox::minimumSizeHint()
+{
+ QCheckBox box(tr("CheckBox's sizeHint is the same as it's minimumSizeHint"));
+ QCOMPARE(box.sizeHint(), box.minimumSizeHint());
+}
+
+QTEST_MAIN(tst_QCheckBox)
+#include "tst_qcheckbox.moc"
diff --git a/tests/auto/widgets/widgets/qcombobox/.gitignore b/tests/auto/widgets/widgets/qcombobox/.gitignore
new file mode 100644
index 0000000000..0db112206b
--- /dev/null
+++ b/tests/auto/widgets/widgets/qcombobox/.gitignore
@@ -0,0 +1 @@
+tst_qcombobox
diff --git a/tests/auto/widgets/widgets/qcombobox/qcombobox.pro b/tests/auto/widgets/widgets/qcombobox/qcombobox.pro
new file mode 100644
index 0000000000..7f5b57c237
--- /dev/null
+++ b/tests/auto/widgets/widgets/qcombobox/qcombobox.pro
@@ -0,0 +1,3 @@
+load(qttest_p4)
+QT += widgets widgets-private gui-private core-private
+SOURCES += tst_qcombobox.cpp
diff --git a/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp b/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp
new file mode 100644
index 0000000000..cb4468f6f4
--- /dev/null
+++ b/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp
@@ -0,0 +1,2579 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtTest/QtTest>
+
+#include "qcombobox.h"
+#include <private/qcombobox_p.h>
+
+#include <qfontcombobox.h>
+#include <qdesktopwidget.h>
+#include <qapplication.h>
+#include <qpushbutton.h>
+#include <qdialog.h>
+#include <qevent.h>
+#include <qlineedit.h>
+#include <qlistview.h>
+#include <qheaderview.h>
+#include <qlistwidget.h>
+#include <qtreewidget.h>
+#include <qtablewidget.h>
+#include <qscrollbar.h>
+#include <qboxlayout.h>
+#ifdef Q_WS_MAC
+#include <qmacstyle_mac.h>
+#elif defined Q_WS_X11
+#include <private/qt_x11_p.h>
+#endif
+
+#include <qstandarditemmodel.h>
+#include <qstringlistmodel.h>
+#include <qcombobox.h>
+#include <qpushbutton.h>
+#include <qdialog.h>
+#include <qstringlist.h>
+#include <qvalidator.h>
+#include <qcompleter.h>
+#ifndef QT_NO_STYLE_CLEANLOOKS
+#include <qcleanlooksstyle.h>
+#endif
+#include <qabstractitemview.h>
+#include <qstyleditemdelegate.h>
+#ifndef QT_NO_STYLE_WINDOWS
+#include <qwindowsstyle.h>
+#endif
+
+//TESTED_CLASS=
+//TESTED_FILES=
+
+class tst_QComboBox : public QObject
+{
+ Q_OBJECT
+
+public:
+ tst_QComboBox();
+ ~tst_QComboBox();
+
+public slots:
+ void initTestCase();
+ void cleanupTestCase();
+ void init();
+ void cleanup();
+
+private slots:
+ void getSetCheck();
+ void ensureReturnIsIgnored();
+ void setEditable();
+ void setPalette();
+ void sizeAdjustPolicy();
+ void clear();
+ void insertPolicy_data();
+ void insertPolicy();
+ void virtualAutocompletion();
+ void autoCompletionCaseSensitivity();
+ void hide();
+ void currentIndex_data();
+ void currentIndex();
+ void insertItems_data();
+ void insertItems();
+ void insertItem_data();
+ void insertItem();
+ void insertOnCurrentIndex();
+ void textpixmapdata_data();
+ void textpixmapdata();
+ void editTextChanged();
+ void setModel();
+ void modelDeleted();
+ void setMaxCount();
+ void setCurrentIndex();
+ void convenienceViews();
+ void findText_data();
+ void findText();
+ void flaggedItems_data();
+ void flaggedItems();
+ void pixmapIcon();
+ void mouseWheel_data();
+ void mouseWheel();
+ void layoutDirection();
+ void itemListPosition();
+ void separatorItem_data();
+ void separatorItem();
+#ifndef QT_NO_STYLE_CLEANLOOKS
+ void task190351_layout();
+ void task191329_size();
+#endif
+ void task166349_setEditableOnReturn();
+ void task190205_setModelAdjustToContents();
+ void task248169_popupWithMinimalSize();
+ void task247863_keyBoardSelection();
+ void task220195_keyBoardSelection2();
+ void setModelColumn();
+ void noScrollbar_data();
+ void noScrollbar();
+ void setItemDelegate();
+ void task253944_itemDelegateIsReset();
+ void subControlRectsWithOffset_data();
+ void subControlRectsWithOffset();
+#ifndef QT_NO_STYLE_WINDOWS
+ void task260974_menuItemRectangleForComboBoxPopup();
+#endif
+ void removeItem();
+ void resetModel();
+ void keyBoardNavigationWithMouse();
+ void task_QTBUG_1071_changingFocusEmitsActivated();
+ void maxVisibleItems();
+ void task_QTBUG_10491_currentIndexAndModelColumn();
+
+protected slots:
+ void onEditTextChanged( const QString &newString );
+
+private:
+ QComboBox *testWidget;
+ QWidget *parent;
+ QPushButton* ok;
+ int editTextCount;
+ QString editText;
+};
+
+class MyAbstractItemDelegate : public QAbstractItemDelegate
+{
+public:
+ MyAbstractItemDelegate() : QAbstractItemDelegate() {};
+ void paint(QPainter *, const QStyleOptionViewItem &, const QModelIndex &) const {}
+ QSize sizeHint(const QStyleOptionViewItem &, const QModelIndex &) const { return QSize(); }
+};
+
+class MyAbstractItemModel: public QAbstractItemModel
+{
+public:
+ MyAbstractItemModel() : QAbstractItemModel() {};
+ QModelIndex index(int, int, const QModelIndex &) const { return QModelIndex(); }
+ QModelIndex parent(const QModelIndex &) const { return QModelIndex(); }
+ int rowCount(const QModelIndex &) const { return 0; }
+ int columnCount(const QModelIndex &) const { return 0; }
+ bool hasChildren(const QModelIndex &) const { return false; }
+ QVariant data(const QModelIndex &, int) const { return QVariant(); }
+ bool setData(const QModelIndex &, const QVariant &, int) { return false; }
+ bool insertRows(int, int, const QModelIndex &) { return false; }
+ bool insertColumns(int, int, const QModelIndex &) { return false; }
+ void setPersistent(const QModelIndex &, const QModelIndex &) {}
+ bool removeRows (int, int, const QModelIndex &) { return false; }
+ bool removeColumns(int, int, const QModelIndex &) { return false; }
+ void reset() {}
+};
+
+class MyAbstractItemView : public QAbstractItemView
+{
+public:
+ MyAbstractItemView() : QAbstractItemView() {}
+ QRect visualRect(const QModelIndex &) const { return QRect(); }
+ void scrollTo(const QModelIndex &, ScrollHint) {}
+ QModelIndex indexAt(const QPoint &) const { return QModelIndex(); }
+protected:
+ QModelIndex moveCursor(CursorAction, Qt::KeyboardModifiers) { return QModelIndex(); }
+ int horizontalOffset() const { return 0; }
+ int verticalOffset() const { return 0; }
+ bool isIndexHidden(const QModelIndex &) const { return false; }
+ void setSelection(const QRect &, QItemSelectionModel::SelectionFlags) {}
+ QRegion visualRegionForSelection(const QItemSelection &) const { return QRegion(); }
+};
+
+// Testing get/set functions
+void tst_QComboBox::getSetCheck()
+{
+ QComboBox obj1;
+ // int QComboBox::maxVisibleItems()
+ // void QComboBox::setMaxVisibleItems(int)
+ obj1.setMaxVisibleItems(100);
+ QCOMPARE(100, obj1.maxVisibleItems());
+ obj1.setMaxVisibleItems(0);
+ QCOMPARE(obj1.maxVisibleItems(), 0);
+ QTest::ignoreMessage(QtWarningMsg, "QComboBox::setMaxVisibleItems: "
+ "Invalid max visible items (-2147483648) must be >= 0");
+ obj1.setMaxVisibleItems(INT_MIN);
+ QCOMPARE(obj1.maxVisibleItems(), 0); // Cannot be set to something negative => old value
+ obj1.setMaxVisibleItems(INT_MAX);
+ QCOMPARE(INT_MAX, obj1.maxVisibleItems());
+
+ // int QComboBox::maxCount()
+ // void QComboBox::setMaxCount(int)
+ obj1.setMaxCount(0);
+ QCOMPARE(0, obj1.maxCount());
+#ifndef QT_DEBUG
+ QTest::ignoreMessage(QtWarningMsg, "QComboBox::setMaxCount: Invalid count (-2147483648) must be >= 0");
+ obj1.setMaxCount(INT_MIN);
+ QCOMPARE(0, obj1.maxCount()); // Setting a value below 0 makes no sense, and shouldn't be allowed
+#endif
+ obj1.setMaxCount(INT_MAX);
+ QCOMPARE(INT_MAX, obj1.maxCount());
+
+ // bool QComboBox::autoCompletion()
+ // void QComboBox::setAutoCompletion(bool)
+ obj1.setAutoCompletion(false);
+ QCOMPARE(false, obj1.autoCompletion());
+ obj1.setAutoCompletion(true);
+ QCOMPARE(true, obj1.autoCompletion());
+
+ // bool QComboBox::duplicatesEnabled()
+ // void QComboBox::setDuplicatesEnabled(bool)
+ obj1.setDuplicatesEnabled(false);
+ QCOMPARE(false, obj1.duplicatesEnabled());
+ obj1.setDuplicatesEnabled(true);
+ QCOMPARE(true, obj1.duplicatesEnabled());
+
+ // InsertPolicy QComboBox::insertPolicy()
+ // void QComboBox::setInsertPolicy(InsertPolicy)
+ obj1.setInsertPolicy(QComboBox::InsertPolicy(QComboBox::NoInsert));
+ QCOMPARE(QComboBox::InsertPolicy(QComboBox::NoInsert), obj1.insertPolicy());
+ obj1.setInsertPolicy(QComboBox::InsertPolicy(QComboBox::InsertAtTop));
+ QCOMPARE(QComboBox::InsertPolicy(QComboBox::InsertAtTop), obj1.insertPolicy());
+ obj1.setInsertPolicy(QComboBox::InsertPolicy(QComboBox::InsertAtCurrent));
+ QCOMPARE(QComboBox::InsertPolicy(QComboBox::InsertAtCurrent), obj1.insertPolicy());
+ obj1.setInsertPolicy(QComboBox::InsertPolicy(QComboBox::InsertAtBottom));
+ QCOMPARE(QComboBox::InsertPolicy(QComboBox::InsertAtBottom), obj1.insertPolicy());
+ obj1.setInsertPolicy(QComboBox::InsertPolicy(QComboBox::InsertAfterCurrent));
+ QCOMPARE(QComboBox::InsertPolicy(QComboBox::InsertAfterCurrent), obj1.insertPolicy());
+ obj1.setInsertPolicy(QComboBox::InsertPolicy(QComboBox::InsertBeforeCurrent));
+ QCOMPARE(QComboBox::InsertPolicy(QComboBox::InsertBeforeCurrent), obj1.insertPolicy());
+ obj1.setInsertPolicy(QComboBox::InsertPolicy(QComboBox::InsertAlphabetically));
+ QCOMPARE(QComboBox::InsertPolicy(QComboBox::InsertAlphabetically), obj1.insertPolicy());
+
+ // SizeAdjustPolicy QComboBox::sizeAdjustPolicy()
+ // void QComboBox::setSizeAdjustPolicy(SizeAdjustPolicy)
+ obj1.setSizeAdjustPolicy(QComboBox::SizeAdjustPolicy(QComboBox::AdjustToContents));
+ QCOMPARE(QComboBox::SizeAdjustPolicy(QComboBox::AdjustToContents), obj1.sizeAdjustPolicy());
+ obj1.setSizeAdjustPolicy(QComboBox::SizeAdjustPolicy(QComboBox::AdjustToContentsOnFirstShow));
+ QCOMPARE(QComboBox::SizeAdjustPolicy(QComboBox::AdjustToContentsOnFirstShow), obj1.sizeAdjustPolicy());
+ obj1.setSizeAdjustPolicy(QComboBox::SizeAdjustPolicy(QComboBox::AdjustToMinimumContentsLength));
+ QCOMPARE(QComboBox::SizeAdjustPolicy(QComboBox::AdjustToMinimumContentsLength), obj1.sizeAdjustPolicy());
+ obj1.setSizeAdjustPolicy(QComboBox::SizeAdjustPolicy(QComboBox::AdjustToMinimumContentsLengthWithIcon));
+ QCOMPARE(QComboBox::SizeAdjustPolicy(QComboBox::AdjustToMinimumContentsLengthWithIcon), obj1.sizeAdjustPolicy());
+
+ // int QComboBox::minimumContentsLength()
+ // void QComboBox::setMinimumContentsLength(int)
+ obj1.setMinimumContentsLength(0);
+ QCOMPARE(0, obj1.minimumContentsLength());
+ obj1.setMinimumContentsLength(100);
+ QCOMPARE(100, obj1.minimumContentsLength());
+ obj1.setMinimumContentsLength(INT_MIN);
+ QCOMPARE(100, obj1.minimumContentsLength()); // Cannot be set to something negative => old value
+ obj1.setMinimumContentsLength(INT_MAX);
+ QCOMPARE(INT_MAX, obj1.minimumContentsLength());
+
+ // QLineEdit * QComboBox::lineEdit()
+ // void QComboBox::setLineEdit(QLineEdit *)
+ QLineEdit *var8 = new QLineEdit(0);
+ obj1.setLineEdit(var8);
+ QCOMPARE(var8, obj1.lineEdit());
+ QTest::ignoreMessage(QtWarningMsg, "QComboBox::setLineEdit: cannot set a 0 line edit");
+ obj1.setLineEdit((QLineEdit *)0);
+ QCOMPARE(var8, obj1.lineEdit());
+ // delete var8; // No delete, since QComboBox takes ownership
+
+ // const QValidator * QComboBox::validator()
+ // void QComboBox::setValidator(const QValidator *)
+ QIntValidator *var9 = new QIntValidator(0);
+ obj1.setValidator(var9);
+ QCOMPARE(obj1.validator(), (const QValidator *)var9);
+ obj1.setValidator((QValidator *)0);
+ QCOMPARE(obj1.validator(), (const QValidator *)0);
+ delete var9;
+
+ // QAbstractItemDelegate * QComboBox::itemDelegate()
+ // void QComboBox::setItemDelegate(QAbstractItemDelegate *)
+ MyAbstractItemDelegate *var10 = new MyAbstractItemDelegate;
+ obj1.setItemDelegate(var10);
+ QCOMPARE(obj1.itemDelegate(), (QAbstractItemDelegate *)var10);
+ QTest::ignoreMessage(QtWarningMsg, "QComboBox::setItemDelegate: cannot set a 0 delegate");
+ obj1.setItemDelegate((QAbstractItemDelegate *)0);
+ QCOMPARE(obj1.itemDelegate(), (QAbstractItemDelegate *)var10);
+ // delete var10; // No delete, since QComboBox takes ownership
+
+ // QAbstractItemModel * QComboBox::model()
+ // void QComboBox::setModel(QAbstractItemModel *)
+ MyAbstractItemModel *var11 = new MyAbstractItemModel;
+ obj1.setModel(var11);
+ QCOMPARE(obj1.model(), (QAbstractItemModel *)var11);
+ QTest::ignoreMessage(QtWarningMsg, "QComboBox::setModel: cannot set a 0 model");
+ obj1.setModel((QAbstractItemModel *)0);
+ QCOMPARE(obj1.model(), (QAbstractItemModel *)var11);
+ delete var11;
+ obj1.model();
+
+ // int QComboBox::modelColumn()
+ // void QComboBox::setModelColumn(int)
+ obj1.setModelColumn(0);
+ QCOMPARE(0, obj1.modelColumn());
+ obj1.setModelColumn(INT_MIN);
+// QCOMPARE(0, obj1.modelColumn()); // Cannot be set to something negative => column 0
+ obj1.setModelColumn(INT_MAX);
+ QCOMPARE(INT_MAX, obj1.modelColumn());
+ obj1.setModelColumn(0); // back to normal
+
+ // QAbstractItemView * QComboBox::view()
+ // void QComboBox::setView(QAbstractItemView *)
+ MyAbstractItemView *var13 = new MyAbstractItemView;
+ obj1.setView(var13);
+ QCOMPARE(obj1.view(), (QAbstractItemView *)var13);
+ QTest::ignoreMessage(QtWarningMsg, "QComboBox::setView: cannot set a 0 view");
+ obj1.setView((QAbstractItemView *)0);
+ QCOMPARE(obj1.view(), (QAbstractItemView *)var13);
+ delete var13;
+
+ // int QComboBox::currentIndex()
+ // void QComboBox::setCurrentIndex(int)
+ obj1.setEditable(false);
+ obj1.setCurrentIndex(0);
+ QCOMPARE(-1, obj1.currentIndex());
+ obj1.setCurrentIndex(INT_MIN);
+ QCOMPARE(-1, obj1.currentIndex());
+ obj1.setCurrentIndex(INT_MAX);
+ QCOMPARE(-1, obj1.currentIndex());
+ obj1.addItems(QStringList() << "1" << "2" << "3" << "4" << "5");
+ obj1.setCurrentIndex(0);
+ QCOMPARE(0, obj1.currentIndex()); // Valid
+ obj1.setCurrentIndex(INT_MIN);
+ QCOMPARE(-1, obj1.currentIndex()); // Invalid => -1
+ obj1.setCurrentIndex(4);
+ QCOMPARE(4, obj1.currentIndex()); // Valid
+ obj1.setCurrentIndex(INT_MAX);
+ QCOMPARE(-1, obj1.currentIndex()); // Invalid => -1
+}
+
+typedef QList<QVariant> VariantList;
+typedef QList<QIcon> IconList;
+
+Q_DECLARE_METATYPE(VariantList)
+Q_DECLARE_METATYPE(IconList)
+Q_DECLARE_METATYPE(QComboBox::InsertPolicy)
+
+tst_QComboBox::tst_QComboBox()
+{
+ qRegisterMetaType<QModelIndex>("QModelIndex");
+ parent = 0;
+}
+
+tst_QComboBox::~tst_QComboBox()
+{
+}
+
+
+void tst_QComboBox::initTestCase()
+{
+ // Create the test class
+ parent = new QWidget(0, Qt::Window);
+ parent->setObjectName("parent");
+ parent->resize(400, 400);
+ testWidget = new QComboBox(parent);
+ testWidget->setObjectName("testObject");
+ testWidget->setGeometry(0, 0, 100, 100);
+ editTextCount = 0;
+ editText.clear();
+ connect(testWidget, SIGNAL(editTextChanged(const QString&)),
+ this, SLOT(onEditTextChanged(const QString&)));
+ parent->show();
+}
+
+void tst_QComboBox::cleanupTestCase()
+{
+ delete parent;
+ parent = 0;
+}
+
+
+void tst_QComboBox::init()
+{
+ // all tests starts with a clean non-editable combobox
+ testWidget->setEditable(false);
+ testWidget->clear();
+#ifdef Q_OS_WINCE //disable magic for WindowsCE
+ qApp->setAutoMaximizeThreshold(-1);
+#endif
+}
+
+void tst_QComboBox::cleanup()
+{
+ //nothing
+}
+
+
+void tst_QComboBox::setEditable()
+{
+ // make sure we have no lineedit
+ QVERIFY(!testWidget->lineEdit());
+ // test setEditable(true)
+ testWidget->setEditable(true);
+ QVERIFY(testWidget->lineEdit());
+ testWidget->addItem("foo");
+ QCOMPARE(testWidget->lineEdit()->text(), QString("foo"));
+ // test setEditable(false)
+
+ QLineEdit *lineEdit = testWidget->lineEdit();
+ // line edit is visible when combobox is editable
+ QVERIFY(lineEdit->isVisible());
+ testWidget->setEditable(false);
+ QVERIFY(!testWidget->lineEdit());
+ // line edit should have been explicitly hidden when editable was turned off
+ QVERIFY(!lineEdit->isVisible());
+}
+
+
+void tst_QComboBox::setPalette()
+{
+#ifdef Q_WS_MAC
+ if (qobject_cast<QMacStyle *>(testWidget->style())) {
+ QSKIP("This test doesn't make sense for pixmap-based styles", SkipAll);
+ }
+#endif
+ QPalette pal = testWidget->palette();
+ pal.setColor(QPalette::Base, Qt::red);
+ testWidget->setPalette(pal);
+ testWidget->setEditable(!testWidget->isEditable());
+
+ pal.setColor(QPalette::Base, Qt::blue);
+ testWidget->setPalette(pal);
+
+ const QObjectList comboChildren = testWidget->children();
+ for (int i = 0; i < comboChildren.size(); ++i) {
+ QObject *o = comboChildren.at(i);
+ if (o->isWidgetType()) {
+ QVERIFY(((QWidget*)o)->palette() == pal);
+ }
+ }
+
+ testWidget->setEditable(true);
+ pal.setColor(QPalette::Base, Qt::red);
+ //Setting it on the lineedit should be separate form the combo
+ testWidget->lineEdit()->setPalette(pal);
+ QVERIFY(testWidget->palette() != pal);
+ QVERIFY(testWidget->lineEdit()->palette() == pal);
+ pal.setColor(QPalette::Base, Qt::green);
+ //Setting it on the combo directly should override lineedit
+ testWidget->setPalette(pal);
+ QVERIFY(testWidget->palette() == pal);
+ QVERIFY(testWidget->lineEdit()->palette() == pal);
+}
+
+void tst_QComboBox::sizeAdjustPolicy()
+{
+ // test that adding new items will not change the sizehint for AdjustToContentsOnFirstShow
+ QVERIFY(!testWidget->count());
+ QVERIFY(testWidget->sizeAdjustPolicy() == QComboBox::AdjustToContentsOnFirstShow);
+ QVERIFY(testWidget->isVisible());
+ QSize firstShow = testWidget->sizeHint();
+ testWidget->addItem("normal item");
+ QCOMPARE(testWidget->sizeHint(), firstShow);
+
+ // check that with minimumContentsLength/AdjustToMinimumContentsLength sizehint changes
+ testWidget->setMinimumContentsLength(30);
+ QCOMPARE(testWidget->sizeHint(), firstShow);
+ testWidget->setSizeAdjustPolicy(QComboBox::AdjustToMinimumContentsLength);
+ QSize minimumContentsLength = testWidget->sizeHint();
+ QVERIFY(minimumContentsLength.width() > firstShow.width());
+ testWidget->setMinimumContentsLength(60);
+ QVERIFY(minimumContentsLength.width() < testWidget->sizeHint().width());
+
+ // check that with minimumContentsLength/AdjustToMinimumContentsLengthWithIcon sizehint changes
+ testWidget->setSizeAdjustPolicy(QComboBox::AdjustToMinimumContentsLengthWithIcon);
+ testWidget->setMinimumContentsLength(30);
+ minimumContentsLength = testWidget->sizeHint();
+ QVERIFY(minimumContentsLength.width() > firstShow.width());
+ testWidget->setMinimumContentsLength(60);
+ QVERIFY(minimumContentsLength.width() < testWidget->sizeHint().width());
+ minimumContentsLength = testWidget->sizeHint();
+ testWidget->setIconSize(QSize(128,128));
+ QVERIFY(minimumContentsLength.width() < testWidget->sizeHint().width());
+
+ // check AdjustToContents changes with content
+ testWidget->setSizeAdjustPolicy(QComboBox::AdjustToContents);
+ QSize content = testWidget->sizeHint();
+ testWidget->addItem("small");
+ QCOMPARE(testWidget->sizeHint(), content);
+ testWidget->addItem("looooooooooooooooooooooong item");
+ // minimumContentsLength() > sizeof("looooooooooooooooooooooong item"), so the sizeHint()
+ // stays the same
+ QCOMPARE(testWidget->sizeHint(), content);
+ // over 60 characters (cf. setMinimumContentsLength() call above)
+ testWidget->addItem("loooooooooooooooooooooooooooooooooooooooooooooo"
+ "ooooooooooooooooooooooooooooooooooooooooooooooo"
+ "ooooooooooooooooooooooooooooong item");
+ QVERIFY(testWidget->sizeHint().width() > content.width());
+
+ // check AdjustToContents also shrinks when item changes
+ content = testWidget->sizeHint();
+ for (int i=0; i<testWidget->count(); ++i)
+ testWidget->setItemText(i, "XXXXXXXXXX");
+ QVERIFY(testWidget->sizeHint().width() < content.width());
+
+ // check AdjustToContents shrinks when items are removed
+ content = testWidget->sizeHint();
+ while (testWidget->count())
+ testWidget->removeItem(0);
+ QCOMPARE(testWidget->sizeHint(), content);
+ testWidget->setMinimumContentsLength(0);
+ QVERIFY(testWidget->sizeHint().width() < content.width());
+}
+
+void tst_QComboBox::clear()
+{
+ // first non editable combobox
+ testWidget->addItem("foo");
+ testWidget->addItem("bar");
+ QVERIFY(testWidget->count() > 0);
+ QCOMPARE(testWidget->currentIndex(), 0);
+
+ testWidget->clear();
+ QCOMPARE(testWidget->count(), 0);
+ QCOMPARE(testWidget->currentIndex(), -1);
+ QVERIFY(testWidget->currentText().isEmpty());
+
+ // then editable combobox
+ testWidget->clear();
+ testWidget->setEditable(true);
+ testWidget->addItem("foo");
+ testWidget->addItem("bar");
+ QVERIFY(testWidget->count() > 0);
+ QCOMPARE(testWidget->currentIndex(), 0);
+ QVERIFY(testWidget->lineEdit());
+ QVERIFY(!testWidget->lineEdit()->text().isEmpty());
+ testWidget->clear();
+ QCOMPARE(testWidget->count(), 0);
+ QCOMPARE(testWidget->currentIndex(), -1);
+ QVERIFY(testWidget->currentText().isEmpty());
+ QVERIFY(testWidget->lineEdit()->text().isEmpty());
+}
+
+void tst_QComboBox::insertPolicy_data()
+{
+ QTest::addColumn<QStringList>("initialEntries");
+ QTest::addColumn<QComboBox::InsertPolicy>("insertPolicy");
+ QTest::addColumn<int>("currentIndex");
+ QTest::addColumn<QString>("userInput");
+ QTest::addColumn<QStringList>("result");
+
+ /* Each insertPolicy should test at least:
+ no initial entries
+ one initial entry
+ five initial entries, current is first item
+ five initial entries, current is third item
+ five initial entries, current is last item
+ */
+
+ /* QComboBox::NoInsert - the string will not be inserted into the combobox.
+ QComboBox::InsertAtTop - insert the string as the first item in the combobox.
+ QComboBox::InsertAtCurrent - replace the previously selected item with the string the user has entered.
+ QComboBox::InsertAtBottom - insert the string as the last item in the combobox.
+ QComboBox::InsertAfterCurrent - insert the string after the previously selected item.
+ QComboBox::InsertBeforeCurrent - insert the string before the previously selected item.
+ QComboBox::InsertAlphabetically - insert the string at the alphabetic position.
+ */
+ QStringList initial;
+ QStringList oneEntry("One");
+ QStringList fiveEntries;
+ fiveEntries << "One" << "Two" << "Three" << "Four" << "Five";
+ QString input("insert");
+
+ {
+ QTest::newRow("NoInsert-NoInitial") << initial << QComboBox::NoInsert << 0 << input << initial;
+ QTest::newRow("NoInsert-OneInitial") << oneEntry << QComboBox::NoInsert << 0 << input << oneEntry;
+ QTest::newRow("NoInsert-FiveInitial-FirstCurrent") << fiveEntries << QComboBox::NoInsert << 0 << input << fiveEntries;
+ QTest::newRow("NoInsert-FiveInitial-ThirdCurrent") << fiveEntries << QComboBox::NoInsert << 2 << input << fiveEntries;
+ QTest::newRow("NoInsert-FiveInitial-LastCurrent") << fiveEntries << QComboBox::NoInsert << 4 << input << fiveEntries;
+ }
+
+ {
+ QStringList initialAtTop("insert");
+ QStringList oneAtTop;
+ oneAtTop << "insert" << "One";
+ QStringList fiveAtTop;
+ fiveAtTop << "insert" << "One" << "Two" << "Three" << "Four" << "Five";
+
+ QTest::newRow("AtTop-NoInitial") << initial << QComboBox::InsertAtTop << 0 << input << initialAtTop;
+ QTest::newRow("AtTop-OneInitial") << oneEntry << QComboBox::InsertAtTop << 0 << input << oneAtTop;
+ QTest::newRow("AtTop-FiveInitial-FirstCurrent") << fiveEntries << QComboBox::InsertAtTop << 0 << input << fiveAtTop;
+ QTest::newRow("AtTop-FiveInitial-ThirdCurrent") << fiveEntries << QComboBox::InsertAtTop << 2 << input << fiveAtTop;
+ QTest::newRow("AtTop-FiveInitial-LastCurrent") << fiveEntries << QComboBox::InsertAtTop << 4 << input << fiveAtTop;
+ }
+
+ {
+ QStringList initialAtCurrent("insert");
+ QStringList oneAtCurrent("insert");
+ QStringList fiveAtCurrentFirst;
+ fiveAtCurrentFirst << "insert" << "Two" << "Three" << "Four" << "Five";
+ QStringList fiveAtCurrentThird;
+ fiveAtCurrentThird << "One" << "Two" << "insert" << "Four" << "Five";
+ QStringList fiveAtCurrentLast;
+ fiveAtCurrentLast << "One" << "Two" << "Three" << "Four" << "insert";
+
+ QTest::newRow("AtCurrent-NoInitial") << initial << QComboBox::InsertAtCurrent << 0 << input << initialAtCurrent;
+ QTest::newRow("AtCurrent-OneInitial") << oneEntry << QComboBox::InsertAtCurrent << 0 << input << oneAtCurrent;
+ QTest::newRow("AtCurrent-FiveInitial-FirstCurrent") << fiveEntries << QComboBox::InsertAtCurrent << 0 << input << fiveAtCurrentFirst;
+ QTest::newRow("AtCurrent-FiveInitial-ThirdCurrent") << fiveEntries << QComboBox::InsertAtCurrent << 2 << input << fiveAtCurrentThird;
+ QTest::newRow("AtCurrent-FiveInitial-LastCurrent") << fiveEntries << QComboBox::InsertAtCurrent << 4 << input << fiveAtCurrentLast;
+ }
+
+ {
+ QStringList initialAtBottom("insert");
+ QStringList oneAtBottom;
+ oneAtBottom << "One" << "insert";
+ QStringList fiveAtBottom;
+ fiveAtBottom << "One" << "Two" << "Three" << "Four" << "Five" << "insert";
+
+ QTest::newRow("AtBottom-NoInitial") << initial << QComboBox::InsertAtBottom << 0 << input << initialAtBottom;
+ QTest::newRow("AtBottom-OneInitial") << oneEntry << QComboBox::InsertAtBottom << 0 << input << oneAtBottom;
+ QTest::newRow("AtBottom-FiveInitial-FirstCurrent") << fiveEntries << QComboBox::InsertAtBottom << 0 << input << fiveAtBottom;
+ QTest::newRow("AtBottom-FiveInitial-ThirdCurrent") << fiveEntries << QComboBox::InsertAtBottom << 2 << input << fiveAtBottom;
+ QTest::newRow("AtBottom-FiveInitial-LastCurrent") << fiveEntries << QComboBox::InsertAtBottom << 4 << input << fiveAtBottom;
+ }
+
+ {
+ QStringList initialAfterCurrent("insert");
+ QStringList oneAfterCurrent;
+ oneAfterCurrent << "One" << "insert";
+ QStringList fiveAfterCurrentFirst;
+ fiveAfterCurrentFirst << "One" << "insert" << "Two" << "Three" << "Four" << "Five";
+ QStringList fiveAfterCurrentThird;
+ fiveAfterCurrentThird << "One" << "Two" << "Three" << "insert" << "Four" << "Five";
+ QStringList fiveAfterCurrentLast;
+ fiveAfterCurrentLast << "One" << "Two" << "Three" << "Four" << "Five" << "insert";
+
+ QTest::newRow("AfterCurrent-NoInitial") << initial << QComboBox::InsertAfterCurrent << 0 << input << initialAfterCurrent;
+ QTest::newRow("AfterCurrent-OneInitial") << oneEntry << QComboBox::InsertAfterCurrent << 0 << input << oneAfterCurrent;
+ QTest::newRow("AfterCurrent-FiveInitial-FirstCurrent") << fiveEntries << QComboBox::InsertAfterCurrent << 0 << input << fiveAfterCurrentFirst;
+ QTest::newRow("AfterCurrent-FiveInitial-ThirdCurrent") << fiveEntries << QComboBox::InsertAfterCurrent << 2 << input << fiveAfterCurrentThird;
+ QTest::newRow("AfterCurrent-FiveInitial-LastCurrent") << fiveEntries << QComboBox::InsertAfterCurrent << 4 << input << fiveAfterCurrentLast;
+ }
+
+ {
+ QStringList initialBeforeCurrent("insert");
+ QStringList oneBeforeCurrent;
+ oneBeforeCurrent << "insert" << "One";
+ QStringList fiveBeforeCurrentFirst;
+ fiveBeforeCurrentFirst << "insert" << "One" << "Two" << "Three" << "Four" << "Five";
+ QStringList fiveBeforeCurrentThird;
+ fiveBeforeCurrentThird << "One" << "Two" << "insert" << "Three" << "Four" << "Five";
+ QStringList fiveBeforeCurrentLast;
+ fiveBeforeCurrentLast << "One" << "Two" << "Three" << "Four" << "insert" << "Five";
+
+ QTest::newRow("BeforeCurrent-NoInitial") << initial << QComboBox::InsertBeforeCurrent << 0 << input << initialBeforeCurrent;
+ QTest::newRow("BeforeCurrent-OneInitial") << oneEntry << QComboBox::InsertBeforeCurrent << 0 << input << oneBeforeCurrent;
+ QTest::newRow("BeforeCurrent-FiveInitial-FirstCurrent") << fiveEntries << QComboBox::InsertBeforeCurrent << 0 << input << fiveBeforeCurrentFirst;
+ QTest::newRow("BeforeCurrent-FiveInitial-ThirdCurrent") << fiveEntries << QComboBox::InsertBeforeCurrent << 2 << input << fiveBeforeCurrentThird;
+ QTest::newRow("BeforeCurrent-FiveInitial-LastCurrent") << fiveEntries << QComboBox::InsertBeforeCurrent << 4 << input << fiveBeforeCurrentLast;
+ }
+
+ {
+ oneEntry.clear();
+ oneEntry << "foobar";
+ fiveEntries.clear();
+ fiveEntries << "bar" << "foo" << "initial" << "Item" << "stamp";
+
+ QStringList initialAlphabetically("insert");
+ QStringList oneAlphabetically;
+ oneAlphabetically << "foobar" << "insert";
+ QStringList fiveAlphabetically;
+ fiveAlphabetically << "bar" << "foo" << "initial" << "insert" << "Item" << "stamp";
+
+ QTest::newRow("Alphabetically-NoInitial") << initial << QComboBox::InsertAlphabetically << 0 << input << initialAlphabetically;
+ QTest::newRow("Alphabetically-OneInitial") << oneEntry << QComboBox::InsertAlphabetically << 0 << input << oneAlphabetically;
+ QTest::newRow("Alphabetically-FiveInitial-FirstCurrent") << fiveEntries << QComboBox::InsertAlphabetically << 0 << input << fiveAlphabetically;
+ QTest::newRow("Alphabetically-FiveInitial-ThirdCurrent") << fiveEntries << QComboBox::InsertAlphabetically << 2 << input << fiveAlphabetically;
+ QTest::newRow("Alphabetically-FiveInitial-LastCurrent") << fiveEntries << QComboBox::InsertAlphabetically << 4 << input << fiveAlphabetically;
+ }
+}
+
+void tst_QComboBox::insertPolicy()
+{
+ QFETCH(QStringList, initialEntries);
+ QFETCH(QComboBox::InsertPolicy, insertPolicy);
+ QFETCH(int, currentIndex);
+ QFETCH(QString, userInput);
+ QFETCH(QStringList, result);
+
+ testWidget->clear();
+ testWidget->setInsertPolicy(insertPolicy);
+ testWidget->addItems(initialEntries);
+ testWidget->setEditable(true);
+ if (initialEntries.count() > 0)
+ testWidget->setCurrentIndex(currentIndex);
+
+ // clear
+ QTest::mouseDClick(testWidget->lineEdit(), Qt::LeftButton);
+ QTest::keyClick(testWidget->lineEdit(), Qt::Key_Delete);
+
+ QTest::keyClicks(testWidget->lineEdit(), userInput);
+ QTest::keyClick(testWidget->lineEdit(), Qt::Key_Return);
+
+ // First check that there is the right number of entries, or
+ // we may unwittingly pass
+ QVERIFY((int)result.count() == testWidget->count());
+
+ // No need to compare if there are no strings to compare
+ if (result.count() > 0) {
+ for (int i=0; i<testWidget->count(); ++i) {
+ QCOMPARE(testWidget->itemText(i), result.at(i));
+ }
+ }
+}
+
+// Apps running with valgrind are not fast enough.
+void tst_QComboBox::virtualAutocompletion()
+{
+ testWidget->clear();
+ testWidget->setAutoCompletion(true);
+ testWidget->addItem("Foo");
+ testWidget->addItem("Bar");
+ testWidget->addItem("Boat");
+ testWidget->addItem("Boost");
+ testWidget->clearEditText();
+
+ // We need to set the keyboard input interval to a higher value
+ // as the processEvent() call takes too much time, so it restarts
+ // the keyboard search then
+#if defined(QT_ARCH_ARM) || defined(QT_ARCH_MIPS)
+ int oldInterval = QApplication::keyboardInputInterval();
+ QApplication::setKeyboardInputInterval(1500);
+#endif
+
+ // NOTE:
+ // Cannot use keyClick for this test, as it simulates keyclicks too well
+ // The virtual keyboards we're trying to catch here, do not perform that
+ // well, and send a keypress & keyrelease right after each other.
+ // This provokes the actual error, as there's no events in between to do
+ // the text completion.
+ QKeyEvent kp1(QEvent::KeyPress, Qt::Key_B, 0, "b");
+ QKeyEvent kr1(QEvent::KeyRelease, Qt::Key_B, 0, "b");
+ QApplication::sendEvent(testWidget, &kp1);
+ QApplication::sendEvent(testWidget, &kr1);
+
+ qApp->processEvents(); // Process events to trigger autocompletion
+ QTRY_VERIFY(testWidget->currentIndex() == 1);
+
+ QKeyEvent kp2(QEvent::KeyPress, Qt::Key_O, 0, "o");
+ QKeyEvent kr2(QEvent::KeyRelease, Qt::Key_O, 0, "o");
+
+ QApplication::sendEvent(testWidget, &kp2);
+ QApplication::sendEvent(testWidget, &kr2);
+
+ qApp->processEvents(); // Process events to trigger autocompletion
+ QTRY_COMPARE(testWidget->currentIndex(), 2);
+
+ QApplication::sendEvent(testWidget, &kp2);
+ QApplication::sendEvent(testWidget, &kr2);
+ qApp->processEvents(); // Process events to trigger autocompletion
+ QTRY_COMPARE(testWidget->currentIndex(), 3);
+#if defined(QT_ARCH_ARM) || defined(QT_ARCH_MIPS)
+ QApplication::setKeyboardInputInterval(oldInterval);
+#endif
+}
+
+void tst_QComboBox::autoCompletionCaseSensitivity()
+{
+ //we have put the focus because the completer
+ //is only used when the widget actually has the focus
+ testWidget->setFocus();
+ qApp->setActiveWindow(testWidget);
+ QTRY_COMPARE(qApp->focusWidget(), (QWidget *)testWidget);
+
+ testWidget->clear();
+ testWidget->setAutoCompletion(true);
+ testWidget->addItem("Cow");
+ testWidget->addItem("irrelevant1");
+ testWidget->addItem("aww");
+ testWidget->addItem("A*");
+ testWidget->addItem("irrelevant2");
+ testWidget->addItem("aBCDEF");
+ testWidget->addItem("irrelevant3");
+ testWidget->addItem("abcdef");
+ testWidget->addItem("abCdef");
+ testWidget->setEditable(true);
+
+ // case insensitive
+ testWidget->clearEditText();
+ QSignalSpy spyReturn(testWidget, SIGNAL(activated(int)));
+ testWidget->setAutoCompletionCaseSensitivity(Qt::CaseInsensitive);
+ QVERIFY(testWidget->autoCompletionCaseSensitivity() == Qt::CaseInsensitive);
+
+ QTest::keyClick(testWidget->lineEdit(), Qt::Key_A);
+ qApp->processEvents();
+ QCOMPARE(testWidget->currentText(), QString("aww"));
+ QCOMPARE(spyReturn.count(), 0);
+
+ QTest::keyClick(testWidget->lineEdit(), Qt::Key_B);
+ qApp->processEvents();
+ // autocompletions preserve userkey-case from 4.2
+ QCOMPARE(testWidget->currentText(), QString("abCDEF"));
+ QCOMPARE(spyReturn.count(), 0);
+
+ QTest::keyClick(testWidget->lineEdit(), Qt::Key_Enter);
+ qApp->processEvents();
+ QCOMPARE(testWidget->currentText(), QString("aBCDEF")); // case restored to item's case
+ QCOMPARE(spyReturn.count(), 1);
+
+ testWidget->clearEditText();
+ QTest::keyClick(testWidget->lineEdit(), 'c');
+ QCOMPARE(testWidget->currentText(), QString("cow"));
+ QTest::keyClick(testWidget->lineEdit(), Qt::Key_Enter);
+ QCOMPARE(testWidget->currentText(), QString("Cow")); // case restored to item's case
+
+ testWidget->clearEditText();
+ QTest::keyClick(testWidget->lineEdit(), 'a');
+ QTest::keyClick(testWidget->lineEdit(), '*');
+ QCOMPARE(testWidget->currentText(), QString("a*"));
+ QTest::keyClick(testWidget->lineEdit(), Qt::Key_Enter);
+ QCOMPARE(testWidget->currentText(), QString("A*"));
+
+ // case sensitive
+ testWidget->clearEditText();
+ testWidget->setAutoCompletionCaseSensitivity(Qt::CaseSensitive);
+ QVERIFY(testWidget->autoCompletionCaseSensitivity() == Qt::CaseSensitive);
+ QTest::keyClick(testWidget->lineEdit(), Qt::Key_A);
+ qApp->processEvents();
+ QCOMPARE(testWidget->currentText(), QString("aww"));
+ QTest::keyClick(testWidget->lineEdit(), Qt::Key_B);
+ qApp->processEvents();
+ QCOMPARE(testWidget->currentText(), QString("abcdef"));
+
+ testWidget->setCurrentIndex(0); // to reset the completion's "start"
+ testWidget->clearEditText();
+ QTest::keyClick(testWidget->lineEdit(), 'a');
+ QTest::keyClick(testWidget->lineEdit(), 'b');
+ QCOMPARE(testWidget->currentText(), QString("abcdef"));
+ QTest::keyClick(testWidget->lineEdit(), 'C');
+ qApp->processEvents();
+ QCOMPARE(testWidget->currentText(), QString("abCdef"));
+ QTest::keyClick(testWidget->lineEdit(), Qt::Key_Enter);
+ qApp->processEvents();
+ QCOMPARE(testWidget->currentText(), QString("abCdef")); // case restored to item's case
+
+ testWidget->clearEditText();
+ QTest::keyClick(testWidget->lineEdit(), 'c');
+ QCOMPARE(testWidget->currentText(), QString("c"));
+ QTest::keyClick(testWidget->lineEdit(), Qt::Key_Backspace);
+ QTest::keyClick(testWidget->lineEdit(), 'C');
+ QCOMPARE(testWidget->currentText(), QString("Cow"));
+ QTest::keyClick(testWidget->lineEdit(), Qt::Key_Enter);
+ QCOMPARE(testWidget->currentText(), QString("Cow"));
+
+ testWidget->clearEditText();
+ QTest::keyClick(testWidget->lineEdit(), 'a');
+ QTest::keyClick(testWidget->lineEdit(), '*');
+ QCOMPARE(testWidget->currentText(), QString("a*"));
+ QTest::keyClick(testWidget->lineEdit(), Qt::Key_Enter);
+ QCOMPARE(testWidget->currentText(), QString("a*")); // A* not matched
+}
+
+void tst_QComboBox::hide()
+{
+ testWidget->addItem("foo");
+ testWidget->showPopup();
+ //allow combobox effect to complete
+ QTRY_VERIFY(testWidget->view());
+ QTRY_VERIFY(testWidget->view()->isVisible());
+ testWidget->hidePopup();
+ //allow combobox effect to complete
+ QTRY_VERIFY(!testWidget->view()->isVisible());
+ testWidget->hide();
+ QVERIFY(!testWidget->isVisible());
+}
+
+
+
+void tst_QComboBox::currentIndex_data()
+{
+ QTest::addColumn<QStringList>("initialItems");
+ QTest::addColumn<int>("setCurrentIndex");
+ QTest::addColumn<int>("removeIndex");
+ QTest::addColumn<int>("insertIndex");
+ QTest::addColumn<QString>("insertText");
+ QTest::addColumn<int>("expectedCurrentIndex");
+ QTest::addColumn<QString>("expectedCurrentText");
+ QTest::addColumn<int>("expectedSignalCount");
+
+ QStringList initialItems;
+ int setCurrentIndex;
+ int removeIndex;
+ int insertIndex;
+ QString insertText;
+ int expectedCurrentIndex;
+ QString expectedCurrentText;
+ int expectedSignalCount;
+
+ {
+ initialItems.clear();
+ initialItems << "foo" << "bar";
+ setCurrentIndex = -2;
+ removeIndex = -1;
+ insertIndex = -1;
+ insertText = "";
+ expectedCurrentIndex = 0;
+ expectedCurrentText = "foo";
+ expectedSignalCount = 1;
+ QTest::newRow("first added item is set to current if there is no current")
+ << initialItems << setCurrentIndex << removeIndex
+ << insertIndex << insertText << expectedCurrentIndex << expectedCurrentText
+ << expectedSignalCount;
+ }
+ {
+ initialItems.clear();
+ initialItems << "foo" << "bar";
+ setCurrentIndex = 1;
+ removeIndex = -1;
+ insertIndex = -1;
+ insertText = "";
+ expectedCurrentIndex = 1;
+ expectedCurrentText = "bar";
+ expectedSignalCount = 2;
+ QTest::newRow("check that setting the index works")
+ << initialItems << setCurrentIndex << removeIndex
+ << insertIndex << insertText << expectedCurrentIndex << expectedCurrentText
+ << expectedSignalCount;
+
+ }
+ {
+ initialItems.clear();
+ initialItems << "foo" << "bar";
+ setCurrentIndex = -1; // will invalidate the currentIndex
+ removeIndex = -1;
+ insertIndex = -1;
+ insertText = "";
+ expectedCurrentIndex = -1;
+ expectedCurrentText = "";
+ expectedSignalCount = 2;
+ QTest::newRow("check that isetting the index to -1 works")
+ << initialItems << setCurrentIndex << removeIndex
+ << insertIndex << insertText << expectedCurrentIndex << expectedCurrentText
+ << expectedSignalCount;
+
+ }
+ {
+ initialItems.clear();
+ initialItems << "foo";
+ setCurrentIndex = 0;
+ removeIndex = 0;
+ insertIndex = -1;
+ insertText = "";
+ expectedCurrentIndex = -1;
+ expectedCurrentText = "";
+ expectedSignalCount = 2;
+ QTest::newRow("check that current index is invalid when removing the only item")
+ << initialItems << setCurrentIndex << removeIndex
+ << insertIndex << insertText << expectedCurrentIndex << expectedCurrentText
+ << expectedSignalCount;
+ }
+ {
+ initialItems.clear();
+ initialItems << "foo" << "bar";
+ setCurrentIndex = 1;
+ removeIndex = 0;
+ insertIndex = -1;
+ insertText = "";
+ expectedCurrentIndex = 0;
+ expectedCurrentText = "bar";
+ expectedSignalCount = 3;
+ QTest::newRow("check that the current index follows the item when removing an item above")
+ << initialItems << setCurrentIndex << removeIndex
+ << insertIndex << insertText << expectedCurrentIndex << expectedCurrentText
+ << expectedSignalCount;
+
+ }
+ {
+ initialItems.clear();
+ initialItems << "foo" << "bar" << "baz";
+ setCurrentIndex = 1;
+ removeIndex = 1;
+ insertIndex = -1;
+ insertText = "";
+ expectedCurrentIndex = 1;
+ expectedCurrentText = "baz";
+ expectedSignalCount = 3;
+ QTest::newRow("check that the current index uses the next item if current is removed")
+ << initialItems << setCurrentIndex << removeIndex
+ << insertIndex << insertText << expectedCurrentIndex << expectedCurrentText
+ << expectedSignalCount;
+ }
+ {
+ initialItems.clear();
+ initialItems << "foo" << "bar" << "baz";
+ setCurrentIndex = 2;
+ removeIndex = 2;
+ insertIndex = -1;
+ insertText = "";
+ expectedCurrentIndex = 1;
+ expectedCurrentText = "bar";
+ expectedSignalCount = 3;
+ QTest::newRow("check that the current index is moved to the one before if current is removed")
+ << initialItems << setCurrentIndex << removeIndex
+ << insertIndex << insertText << expectedCurrentIndex << expectedCurrentText
+ << expectedSignalCount;
+ }
+ {
+ initialItems.clear();
+ initialItems << "foo" << "bar" << "baz";
+ setCurrentIndex = 1;
+ removeIndex = 2;
+ insertIndex = -1;
+ insertText = "";
+ expectedCurrentIndex = 1;
+ expectedCurrentText = "bar";
+ expectedSignalCount = 2;
+ QTest::newRow("check that the current index is unchanged if you remove an item after")
+ << initialItems << setCurrentIndex << removeIndex
+ << insertIndex << insertText << expectedCurrentIndex << expectedCurrentText
+ << expectedSignalCount;
+ }
+ {
+ initialItems.clear();
+ initialItems << "foo" << "bar";
+ setCurrentIndex = 1;
+ removeIndex = -1;
+ insertIndex = 0;
+ insertText = "baz";
+ expectedCurrentIndex = 2;
+ expectedCurrentText = "bar";
+ expectedSignalCount = 3;
+ QTest::newRow("check that the current index follows the item if you insert before current")
+ << initialItems << setCurrentIndex << removeIndex
+ << insertIndex << insertText << expectedCurrentIndex << expectedCurrentText
+ << expectedSignalCount;
+ }
+ {
+ initialItems.clear();
+ initialItems << "foo";
+ setCurrentIndex = 0;
+ removeIndex = -1;
+ insertIndex = 0;
+ insertText = "bar";
+ expectedCurrentIndex = 1;
+ expectedCurrentText = "foo";
+ expectedSignalCount = 2;
+ QTest::newRow("check that the current index follows the item if you insert on the current")
+ << initialItems << setCurrentIndex << removeIndex
+ << insertIndex << insertText << expectedCurrentIndex << expectedCurrentText
+ << expectedSignalCount;
+ }
+ {
+ initialItems.clear();
+ initialItems << "foo";
+ setCurrentIndex = 0;
+ removeIndex = -1;
+ insertIndex = 1;
+ insertText = "bar";
+ expectedCurrentIndex = 0;
+ expectedCurrentText = "foo";
+ expectedSignalCount = 1;
+ QTest::newRow("check that the current index stays the same if you insert after the current")
+ << initialItems << setCurrentIndex << removeIndex
+ << insertIndex << insertText << expectedCurrentIndex << expectedCurrentText
+ << expectedSignalCount;
+ }
+}
+
+void tst_QComboBox::currentIndex()
+{
+ QFETCH(QStringList, initialItems);
+ QFETCH(int, setCurrentIndex);
+ QFETCH(int, removeIndex);
+ QFETCH(int, insertIndex);
+ QFETCH(QString, insertText);
+ QFETCH(int, expectedCurrentIndex);
+ QFETCH(QString, expectedCurrentText);
+ QFETCH(int, expectedSignalCount);
+
+ // test both editable/non-editable combobox
+ for (int edit = 0; edit < 2; ++edit) {
+ testWidget->clear();
+ testWidget->setEditable(edit ? true : false);
+ if (edit)
+ QVERIFY(testWidget->lineEdit());
+
+ // verify it is empty, has no current index and no current text
+ QCOMPARE(testWidget->count(), 0);
+ QCOMPARE(testWidget->currentIndex(), -1);
+ QVERIFY(testWidget->currentText().isEmpty());
+
+ // spy on currentIndexChanged
+ QSignalSpy indexChangedInt(testWidget, SIGNAL(currentIndexChanged(int)));
+ QSignalSpy indexChangedString(testWidget, SIGNAL(currentIndexChanged(const QString&)));
+
+ // stuff items into it
+ foreach(QString text, initialItems) {
+ testWidget->addItem(text);
+ }
+ QCOMPARE(testWidget->count(), initialItems.count());
+
+ // set current index, remove and/or insert
+ if (setCurrentIndex >= -1) {
+ testWidget->setCurrentIndex(setCurrentIndex);
+ QCOMPARE(testWidget->currentIndex(), setCurrentIndex);
+ }
+
+ if (removeIndex >= 0)
+ testWidget->removeItem(removeIndex);
+ if (insertIndex >= 0)
+ testWidget->insertItem(insertIndex, insertText);
+
+ // compare with expected index and text
+ QCOMPARE(testWidget->currentIndex(), expectedCurrentIndex);
+ QCOMPARE(testWidget->currentText(), expectedCurrentText);
+
+ // check that signal count is correct
+ QCOMPARE(indexChangedInt.count(), expectedSignalCount);
+ QCOMPARE(indexChangedString.count(), expectedSignalCount);
+
+ // compare with last sent signal values
+ if (indexChangedInt.count())
+ QCOMPARE(indexChangedInt.at(indexChangedInt.count() - 1).at(0).toInt(),
+ testWidget->currentIndex());
+ if (indexChangedString.count())
+ QCOMPARE(indexChangedString.at(indexChangedString.count() - 1).at(0).toString(),
+ testWidget->currentText());
+
+ if (edit) {
+ testWidget->setCurrentIndex(-1);
+ testWidget->setInsertPolicy(QComboBox::InsertAtBottom);
+ QTest::keyPress(testWidget, 'a');
+ QTest::keyPress(testWidget, 'b');
+ QCOMPARE(testWidget->currentText(), QString("ab"));
+ QCOMPARE(testWidget->currentIndex(), -1);
+ int numItems = testWidget->count();
+ QTest::keyPress(testWidget, Qt::Key_Return);
+ QCOMPARE(testWidget->count(), numItems + 1);
+ QCOMPARE(testWidget->currentIndex(), numItems);
+ testWidget->setCurrentIndex(-1);
+ QTest::keyPress(testWidget, 'a');
+ QTest::keyPress(testWidget, 'b');
+ QCOMPARE(testWidget->currentIndex(), -1);
+ }
+ }
+}
+
+void tst_QComboBox::insertItems_data()
+{
+ QTest::addColumn<QStringList>("initialItems");
+ QTest::addColumn<QStringList>("insertedItems");
+ QTest::addColumn<int>("insertIndex");
+ QTest::addColumn<int>("expectedIndex");
+
+ QStringList initialItems;
+ QStringList insertedItems;
+
+ initialItems << "foo" << "bar";
+ insertedItems << "mongo";
+
+ QTest::newRow("prepend") << initialItems << insertedItems << 0 << 0;
+ QTest::newRow("prepend with negative value") << initialItems << insertedItems << -1 << 0;
+ QTest::newRow("append") << initialItems << insertedItems << initialItems.count() << initialItems.count();
+ QTest::newRow("append with too high value") << initialItems << insertedItems << 999 << initialItems.count();
+ QTest::newRow("insert") << initialItems << insertedItems << 1 << 1;
+}
+
+void tst_QComboBox::insertItems()
+{
+ QFETCH(QStringList, initialItems);
+ QFETCH(QStringList, insertedItems);
+ QFETCH(int, insertIndex);
+ QFETCH(int, expectedIndex);
+
+ testWidget->insertItems(0, initialItems);
+ QCOMPARE(testWidget->count(), initialItems.count());
+
+ testWidget->insertItems(insertIndex, insertedItems);
+
+ QCOMPARE(testWidget->count(), initialItems.count() + insertedItems.count());
+ for (int i=0; i<insertedItems.count(); ++i)
+ QCOMPARE(testWidget->itemText(expectedIndex + i), insertedItems.at(i));
+}
+
+void tst_QComboBox::insertItem_data()
+{
+ QTest::addColumn<QStringList>("initialItems");
+ QTest::addColumn<int>("insertIndex");
+ QTest::addColumn<QString>("itemLabel");
+ QTest::addColumn<int>("expectedIndex");
+ QTest::addColumn<bool>("editable");
+
+ QStringList initialItems;
+ initialItems << "foo" << "bar";
+ for(int e = 0 ; e<2 ; e++) {
+ bool editable = (e==0);
+ QTest::newRow("Insert less then 0") << initialItems << -1 << "inserted" << 0 << editable;
+ QTest::newRow("Insert at 0") << initialItems << 0 << "inserted" << 0 << editable;
+ QTest::newRow("Insert beyond count") << initialItems << 3 << "inserted" << 2 << editable;
+ QTest::newRow("Insert at count") << initialItems << 2 << "inserted" << 2 << editable;
+ QTest::newRow("Insert in the middle") << initialItems << 1 << "inserted" << 1 << editable;
+ }
+}
+
+void tst_QComboBox::insertItem()
+{
+ QFETCH(QStringList, initialItems);
+ QFETCH(int, insertIndex);
+ QFETCH(QString, itemLabel);
+ QFETCH(int, expectedIndex);
+ QFETCH(bool, editable);
+
+ testWidget->insertItems(0, initialItems);
+ QCOMPARE(testWidget->count(), initialItems.count());
+
+ testWidget->setEditable(true);
+ if (editable)
+ testWidget->setEditText("FOO");
+ testWidget->insertItem(insertIndex, itemLabel);
+
+ QCOMPARE(testWidget->count(), initialItems.count() + 1);
+ QCOMPARE(testWidget->itemText(expectedIndex), itemLabel);
+
+ if (editable)
+ QCOMPARE(testWidget->currentText(), QString("FOO"));
+}
+
+void tst_QComboBox::insertOnCurrentIndex()
+{
+ testWidget->setEditable(true);
+ testWidget->addItem("first item");
+ testWidget->setCurrentIndex(0);
+ testWidget->insertItem(0, "second item");
+ QCOMPARE(testWidget->lineEdit()->text(), QString::fromAscii("first item"));
+}
+
+void tst_QComboBox::textpixmapdata_data()
+{
+ QTest::addColumn<QStringList>("text");
+ QTest::addColumn<IconList>("icons");
+ QTest::addColumn<VariantList>("variant");
+
+ QStringList text;
+ IconList icon;
+ VariantList variant;
+
+ {
+ text.clear(); icon.clear(); variant.clear();
+ text << "foo" << "bar";
+ icon << QIcon() << QIcon();
+ variant << QVariant() << QVariant();
+ QTest::newRow("just text") << text << icon << variant;
+ }
+ {
+ text.clear(); icon.clear(); variant.clear();
+ text << QString() << QString();
+ icon << QIcon(QPixmap("qtlogo.png")) << QIcon(QPixmap("qtlogoinverted.png"));
+ variant << QVariant() << QVariant();
+ QTest::newRow("just icons") << text << icon << variant;
+ }
+ {
+ text.clear(); icon.clear(); variant.clear();
+ text << QString() << QString();
+ icon << QIcon() << QIcon();
+ variant << 12 << "bingo";
+ QTest::newRow("just user data") << text << icon << variant;
+ }
+ {
+ text.clear(); icon.clear(); variant.clear();
+ text << "foo" << "bar";
+ icon << QIcon(QPixmap("qtlogo.png")) << QIcon(QPixmap("qtlogoinverted.png"));
+ variant << 12 << "bingo";
+ QTest::newRow("text, icons and user data") << text << icon << variant;
+ }
+}
+
+void tst_QComboBox::textpixmapdata()
+{
+ QFETCH(QStringList, text);
+ QFETCH(IconList, icons);
+ QFETCH(VariantList, variant);
+
+ QVERIFY(text.count() == icons.count() && text.count() == variant.count());
+
+ for (int i = 0; i<text.count(); ++i) {
+ testWidget->insertItem(i, text.at(i));
+ testWidget->setItemIcon(i, icons.at(i));
+ testWidget->setItemData(i, variant.at(i), Qt::UserRole);
+ }
+
+ QCOMPARE(testWidget->count(), text.count());
+
+ for (int i = 0; i<text.count(); ++i) {
+ QIcon icon = testWidget->itemIcon(i);
+ QVERIFY(icon.serialNumber() == icons.at(i).serialNumber());
+ QPixmap original = icons.at(i).pixmap(1024);
+ QPixmap pixmap = icon.pixmap(1024);
+ QVERIFY(pixmap.toImage() == original.toImage());
+ }
+
+ for (int i = 0; i<text.count(); ++i) {
+ QCOMPARE(testWidget->itemText(i), text.at(i));
+ // ### we should test icons/pixmap as well, but I need to fix the api mismatch first
+ QCOMPARE(testWidget->itemData(i, Qt::UserRole), variant.at(i));
+ }
+}
+
+void tst_QComboBox::setCurrentIndex()
+{
+ QCOMPARE(testWidget->count(), 0);
+ testWidget->addItem("foo");
+ testWidget->addItem("bar");
+ QCOMPARE(testWidget->count(), 2);
+
+ QCOMPARE(testWidget->currentIndex(), 0);
+ testWidget->setCurrentIndex(0);
+ QCOMPARE(testWidget->currentText(), QString("foo"));
+
+ testWidget->setCurrentIndex(1);
+ QCOMPARE(testWidget->currentText(), QString("bar"));
+
+ testWidget->setCurrentIndex(0);
+ QCOMPARE(testWidget->currentText(), QString("foo"));
+}
+
+void tst_QComboBox::editTextChanged()
+{
+ QCOMPARE(testWidget->count(), 0);
+ testWidget->addItem("foo");
+ testWidget->addItem("bar");
+ QCOMPARE(testWidget->count(), 2);
+
+ // first we test non editable
+ testWidget->setEditable(false);
+ QCOMPARE(testWidget->isEditable(), false);
+
+ // no signal should be sent when current is set to the same
+ QCOMPARE(testWidget->currentIndex(), 0);
+ editTextCount = 0;
+ editText.clear();
+ testWidget->setCurrentIndex(0);
+ QCOMPARE(testWidget->currentIndex(), 0);
+ QCOMPARE(editTextCount, 0);
+ QCOMPARE(editText.isEmpty(), true);
+
+ // no signal should be sent when changing to other index because we are not editable
+ QCOMPARE(testWidget->currentIndex(), 0);
+ editTextCount = 0;
+ editText.clear();
+ testWidget->setCurrentIndex(1);
+ QCOMPARE(testWidget->currentIndex(), 1);
+ QCOMPARE(editTextCount, 0);
+ QCOMPARE(editText.isEmpty(), true);
+
+ // now set to editable and reset current index
+ testWidget->setEditable(true);
+ QCOMPARE(testWidget->isEditable(), true);
+ testWidget->setCurrentIndex(0);
+
+ // no signal should be sent when current is set to the same
+ QCOMPARE(testWidget->currentIndex(), 0);
+ editTextCount = 0;
+ editText.clear();
+ testWidget->setCurrentIndex(0);
+ QCOMPARE(testWidget->currentIndex(), 0);
+ QCOMPARE(editTextCount, 0);
+ QCOMPARE(editText.isEmpty(), true);
+
+ // signal should be sent when changing to other index
+ QCOMPARE(testWidget->currentIndex(), 0);
+ editTextCount = 0;
+ editText.clear();
+ testWidget->setCurrentIndex(1);
+ QCOMPARE(testWidget->currentIndex(), 1);
+ QCOMPARE(editTextCount, 1);
+ QCOMPARE(editText, QString("bar"));
+
+ // insert some keys and notice they are all signaled
+ editTextCount = 0;
+ editText.clear();
+ QTest::keyClicks(testWidget, "bingo");
+ QCOMPARE(editTextCount, 5);
+ QCOMPARE(editText, QString("barbingo"));
+}
+
+void tst_QComboBox::onEditTextChanged(const QString &text)
+{
+ editTextCount++;
+ editText = text;
+}
+
+void tst_QComboBox::setModel()
+{
+ QComboBox box;
+ QCOMPARE(box.currentIndex(), -1);
+ box.addItems((QStringList() << "foo" << "bar"));
+ QCOMPARE(box.currentIndex(), 0);
+ box.setCurrentIndex(1);
+ QCOMPARE(box.currentIndex(), 1);
+
+ // check that currentIndex is set to invalid
+ QAbstractItemModel *oldModel = box.model();
+ box.setModel(new QStandardItemModel(&box));
+ QCOMPARE(box.currentIndex(), -1);
+ QVERIFY(box.model() != oldModel);
+
+ // check that currentIndex is set to first item
+ oldModel = box.model();
+ box.setModel(new QStandardItemModel(2,1, &box));
+ QCOMPARE(box.currentIndex(), 0);
+ QVERIFY(box.model() != oldModel);
+}
+
+void tst_QComboBox::modelDeleted()
+{
+ QComboBox box;
+ QStandardItemModel *model = new QStandardItemModel;
+ box.setModel(model);
+ QCOMPARE(box.model(), static_cast<QAbstractItemModel *>(model));
+ delete model;
+ QVERIFY(box.model());
+ QCOMPARE(box.findText("bubu"), -1);
+
+ delete box.model();
+ QVERIFY(box.model());
+ delete box.model();
+ QVERIFY(box.model());
+}
+
+void tst_QComboBox::setMaxCount()
+{
+ QStringList items;
+ items << "1" << "2" << "3" << "4" << "5";
+
+ QComboBox box;
+ box.addItems(items);
+ QCOMPARE(box.count(), 5);
+
+ box.setMaxCount(4);
+ QCOMPARE(box.count(), 4);
+ QCOMPARE(box.itemText(0), QString("1"));
+ QCOMPARE(box.itemText(1), QString("2"));
+ QCOMPARE(box.itemText(2), QString("3"));
+ QCOMPARE(box.itemText(3), QString("4"));
+
+ // appending should do nothing
+ box.addItem("foo");
+ QCOMPARE(box.count(), 4);
+ QCOMPARE(box.findText("foo"), -1);
+
+ // inserting one item at top should remove the last
+ box.insertItem(0, "0");
+ QCOMPARE(box.count(), 4);
+ QCOMPARE(box.itemText(0), QString("0"));
+ QCOMPARE(box.itemText(1), QString("1"));
+ QCOMPARE(box.itemText(2), QString("2"));
+ QCOMPARE(box.itemText(3), QString("3"));
+
+ // insert 5 items in a box with maxCount 4
+ box.insertItems(0, items);
+ QCOMPARE(box.count(), 4);
+ QCOMPARE(box.itemText(0), QString("1"));
+ QCOMPARE(box.itemText(1), QString("2"));
+ QCOMPARE(box.itemText(2), QString("3"));
+ QCOMPARE(box.itemText(3), QString("4"));
+
+ // insert 5 items at pos 2. Make sure only two get inserted
+ QSignalSpy spy(box.model(), SIGNAL(rowsInserted(QModelIndex,int,int)));
+ box.insertItems(2, items);
+ QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.at(0).at(1).toInt(), 2);
+ QCOMPARE(spy.at(0).at(2).toInt(), 3);
+
+ QCOMPARE(box.count(), 4);
+ QCOMPARE(box.itemText(0), QString("1"));
+ QCOMPARE(box.itemText(1), QString("2"));
+ QCOMPARE(box.itemText(2), QString("1"));
+ QCOMPARE(box.itemText(3), QString("2"));
+
+ box.insertItems(0, QStringList());
+ QCOMPARE(box.count(), 4);
+
+ box.setMaxCount(0);
+ QCOMPARE(box.count(), 0);
+ box.addItem("foo");
+ QCOMPARE(box.count(), 0);
+ box.addItems(items);
+ QCOMPARE(box.count(), 0);
+}
+
+void tst_QComboBox::convenienceViews()
+{
+ // QListWidget
+ QComboBox listCombo;
+ QListWidget *list = new QListWidget();
+ listCombo.setModel(list->model());
+ listCombo.setView(list);
+ // add items
+ list->addItem("list0");
+ listCombo.addItem("list1");
+ QCOMPARE(listCombo.count(), 2);
+ QCOMPARE(listCombo.itemText(0), QString("list0"));
+ QCOMPARE(listCombo.itemText(1), QString("list1"));
+
+ // QTreeWidget
+ QComboBox treeCombo;
+ QTreeWidget *tree = new QTreeWidget();
+ tree->setColumnCount(1);
+ tree->header()->hide();
+ treeCombo.setModel(tree->model());
+ treeCombo.setView(tree);
+ // add items
+ tree->addTopLevelItem(new QTreeWidgetItem(QStringList("tree0")));
+ treeCombo.addItem("tree1");
+ QCOMPARE(treeCombo.count(), 2);
+ QCOMPARE(treeCombo.itemText(0), QString("tree0"));
+ QCOMPARE(treeCombo.itemText(1), QString("tree1"));
+
+ // QTableWidget
+ QComboBox tableCombo;
+ QTableWidget *table = new QTableWidget(0,1);
+ table->verticalHeader()->hide();
+ table->horizontalHeader()->hide();
+ tableCombo.setModel(table->model());
+ tableCombo.setView(table);
+ // add items
+ table->setRowCount(table->rowCount() + 1);
+ table->setItem(0, table->rowCount() - 1, new QTableWidgetItem("table0"));
+ tableCombo.addItem("table1");
+ QCOMPARE(tableCombo.count(), 2);
+ QCOMPARE(tableCombo.itemText(0), QString("table0"));
+ QCOMPARE(tableCombo.itemText(1), QString("table1"));
+}
+
+class ReturnClass : public QWidget
+{
+ Q_OBJECT
+public:
+ ReturnClass(QWidget *parent = 0)
+ : QWidget(parent), received(false)
+ {
+ QComboBox *box = new QComboBox(this);
+ box->setEditable(true);
+ edit = box->lineEdit();
+ box->setGeometry(rect());
+ }
+
+ void keyPressEvent(QKeyEvent *e)
+ {
+ received = (e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter);
+ }
+
+ QLineEdit *edit;
+
+ bool received;
+
+};
+
+
+
+void tst_QComboBox::ensureReturnIsIgnored()
+{
+ ReturnClass r;
+ r.show();
+
+ QTest::keyClick(r.edit, Qt::Key_Return);
+ QVERIFY(r.received);
+ r.received = false;
+ QTest::keyClick(r.edit, Qt::Key_Enter);
+ QVERIFY(r.received);
+}
+
+
+void tst_QComboBox::findText_data()
+{
+ QTest::addColumn<QStringList>("items");
+ QTest::addColumn<int>("matchflags");
+ QTest::addColumn<QString>("search");
+ QTest::addColumn<int>("result");
+
+ QStringList list;
+ list << "One" << "Two" << "Three" << "Four" << "Five" << "Six" << "one";
+ QTest::newRow("CaseSensitive_1") << list << (int)(Qt::MatchExactly|Qt::MatchCaseSensitive)
+ << QString("Two") << 1;
+ QTest::newRow("CaseSensitive_2") << list << (int)(Qt::MatchExactly|Qt::MatchCaseSensitive)
+ << QString("two") << -1;
+ QTest::newRow("CaseSensitive_3") << list << (int)(Qt::MatchExactly|Qt::MatchCaseSensitive)
+ << QString("One") << 0;
+ QTest::newRow("CaseSensitive_4") << list << (int)(Qt::MatchExactly|Qt::MatchCaseSensitive)
+ << QString("one") << 6;
+ QTest::newRow("CaseInsensitive_1") << list << (int)(Qt::MatchExactly) << QString("Two") << 1;
+ QTest::newRow("CaseInsensitive_2") << list << (int)(Qt::MatchExactly) << QString("two") << -1;
+ QTest::newRow("CaseInsensitive_3") << list << (int)(Qt::MatchExactly) << QString("One") << 0;
+ QTest::newRow("CaseInsensitive_4") << list << (int)(Qt::MatchExactly) << QString("one") << 6;
+}
+void tst_QComboBox::findText()
+{
+ QFETCH(QStringList, items);
+ QFETCH(int, matchflags);
+ QFETCH(QString, search);
+ QFETCH(int, result);
+
+ testWidget->clear();
+ testWidget->addItems(items);
+
+ QCOMPARE(testWidget->findText(search, (Qt::MatchFlags)matchflags), result);
+}
+
+typedef QList<int> IntList;
+typedef QList<Qt::Key> KeyList;
+Q_DECLARE_METATYPE(IntList)
+Q_DECLARE_METATYPE(KeyList)
+
+void tst_QComboBox::flaggedItems_data()
+{
+ QTest::addColumn<QStringList>("itemList");
+ QTest::addColumn<IntList>("deselectFlagList");
+ QTest::addColumn<IntList>("disableFlagList");
+ QTest::addColumn<KeyList>("keyMovementList");
+ QTest::addColumn<bool>("editable");
+ QTest::addColumn<int>("expectedIndex");
+
+ for (int editable=0;editable<2;editable++) {
+ QString testCase = editable ? "editable:" : "non-editable:";
+ QStringList itemList;
+ itemList << "One" << "Two" << "Three" << "Four" << "Five" << "Six" << "Seven" << "Eight";
+ IntList deselectFlagList;
+ IntList disableFlagList;
+ KeyList keyMovementList;
+
+ keyMovementList << Qt::Key_Down << Qt::Key_Down << Qt::Key_Down << Qt::Key_Down;
+ QTest::newRow(testCase.toAscii() + "normal") << itemList << deselectFlagList << disableFlagList << keyMovementList << bool(editable) << 4;
+
+ deselectFlagList.clear();
+ disableFlagList.clear();
+ deselectFlagList << 1 << 3;
+ QTest::newRow(testCase.toAscii() + "non-selectable") << itemList << deselectFlagList << disableFlagList << keyMovementList << bool(editable) << 4;
+
+ deselectFlagList.clear();
+ disableFlagList.clear();
+ disableFlagList << 2;
+ QTest::newRow(testCase.toAscii() + "disabled") << itemList << deselectFlagList << disableFlagList << keyMovementList << bool(editable) << 5;
+
+ deselectFlagList.clear();
+ disableFlagList.clear();
+ deselectFlagList << 1 << 3;
+ disableFlagList << 2 << 3;
+ QTest::newRow(testCase.toAscii() + "mixed") << itemList << deselectFlagList << disableFlagList << keyMovementList << bool(editable) << 6;
+ deselectFlagList.clear();
+ disableFlagList.clear();
+ disableFlagList << 0 << 1 << 2 << 3 << 4 << 5 << 6;
+ QTest::newRow(testCase.toAscii() + "nearly-empty") << itemList << deselectFlagList << disableFlagList << keyMovementList << bool(editable) << 7;
+
+ deselectFlagList.clear();
+ disableFlagList.clear();
+ disableFlagList << 0 << 1 << 2 << 3 << 5 << 6 << 7;
+ keyMovementList.clear();
+ QTest::newRow(testCase.toAscii() + "only one enabled") << itemList << deselectFlagList << disableFlagList << keyMovementList << bool(editable) << 4;
+
+ if (!editable) {
+ deselectFlagList.clear();
+ disableFlagList.clear();
+ keyMovementList.clear();
+ disableFlagList << 0 << 2 << 3;
+ keyMovementList << Qt::Key_Down << Qt::Key_Home;
+ QTest::newRow(testCase.toAscii() + "home-disabled") << itemList << deselectFlagList << disableFlagList << keyMovementList << bool(editable) << 1;
+
+ keyMovementList.clear();
+ keyMovementList << Qt::Key_End;
+ QTest::newRow(testCase.toAscii() + "end-key") << itemList << deselectFlagList << disableFlagList << keyMovementList << bool(editable) << 7;
+
+ disableFlagList.clear();
+ disableFlagList << 1 ;
+ keyMovementList << Qt::Key_T;
+ QTest::newRow(testCase.toAscii() + "keyboard-search") << itemList << deselectFlagList << disableFlagList << keyMovementList << bool(editable) << 2;
+
+ itemList << "nine" << "ten";
+ keyMovementList << Qt::Key_T;
+ QTest::newRow(testCase.toAscii() + "search same start letter") << itemList << deselectFlagList << disableFlagList << keyMovementList << bool(editable) << 9;
+
+ keyMovementList.clear();
+ keyMovementList << Qt::Key_T << Qt::Key_H;
+ QTest::newRow(testCase.toAscii() + "keyboard search item") << itemList << deselectFlagList << disableFlagList << keyMovementList << bool(editable) << 2;
+
+ disableFlagList.clear();
+ disableFlagList << 1 << 3 << 5 << 7 << 9;
+ keyMovementList.clear();
+ keyMovementList << Qt::Key_End << Qt::Key_Up << Qt::Key_Up << Qt::Key_PageDown << Qt::Key_PageUp << Qt::Key_PageUp << Qt::Key_Down;
+ QTest::newRow(testCase.toAscii() + "all key combinations") << itemList << deselectFlagList << disableFlagList << keyMovementList << bool(editable) << 4;
+ } else {
+ deselectFlagList.clear();
+ disableFlagList.clear();
+ disableFlagList << 1;
+ keyMovementList.clear();
+ keyMovementList << Qt::Key_T << Qt::Key_Enter;
+ QTest::newRow(testCase.toAscii() + "disabled") << itemList << deselectFlagList << disableFlagList << keyMovementList << bool(editable) << 2;
+ QTest::newRow(testCase.toAscii() + "broken autocompletion") << itemList << deselectFlagList << disableFlagList << keyMovementList << bool(editable) << 2;
+ }
+ }
+}
+
+void tst_QComboBox::flaggedItems()
+{
+ QFETCH(QStringList, itemList);
+ QFETCH(IntList, deselectFlagList);
+ QFETCH(IntList, disableFlagList);
+ QFETCH(KeyList, keyMovementList);
+ QFETCH(bool, editable);
+ QFETCH(int, expectedIndex);
+
+ QComboBox comboBox;
+ QListWidget listWidget;
+ listWidget.addItems(itemList);
+
+ comboBox.setEditable(editable);
+ foreach (int index, deselectFlagList)
+ listWidget.item(index)->setFlags(listWidget.item(index)->flags() & ~Qt::ItemIsSelectable);
+
+ foreach (int index, disableFlagList)
+ listWidget.item(index)->setFlags(listWidget.item(index)->flags() & ~Qt::ItemIsEnabled);
+
+ comboBox.setModel(listWidget.model());
+ comboBox.setView(&listWidget);
+ comboBox.show();
+ QApplication::setActiveWindow(&comboBox);
+ comboBox.activateWindow();
+ comboBox.setFocus();
+ QTRY_VERIFY(comboBox.isVisible());
+ QTRY_VERIFY(comboBox.hasFocus());
+
+ if (editable)
+ comboBox.lineEdit()->selectAll();
+
+ QSignalSpy indexChangedInt(&comboBox, SIGNAL(currentIndexChanged(int)));
+ for (int i = 0; i < keyMovementList.count(); ++i) {
+ Qt::Key key = keyMovementList[i];
+ QTest::keyClick(&comboBox, key);
+ if (indexChangedInt.count() != i + 1) {
+ QTest::qWait(400);
+ }
+ }
+
+ QCOMPARE(comboBox.currentIndex() , expectedIndex);
+}
+
+void tst_QComboBox::pixmapIcon()
+{
+ QComboBox box;
+ QStandardItemModel *model = new QStandardItemModel(2, 1, &box);
+
+ QPixmap pix(10, 10);
+ pix.fill(Qt::red);
+ model->setData(model->index(0, 0), "Element 1");
+ model->setData(model->index(0, 0), pix, Qt::DecorationRole);
+
+ QIcon icon(pix);
+ model->setData(model->index(1, 0), "Element 2");
+ model->setData(model->index(1, 0), icon, Qt::DecorationRole);
+
+ box.setModel(model);
+
+ QCOMPARE( box.itemIcon(0).isNull(), false );
+ QCOMPARE( box.itemIcon(1).isNull(), false );
+}
+
+// defined to be 120 by the wheel mouse vendors according to the docs
+#define WHEEL_DELTA 120
+
+void tst_QComboBox::mouseWheel_data()
+{
+ QTest::addColumn<IntList>("disabledItems");
+ QTest::addColumn<int>("startIndex");
+ QTest::addColumn<int>("wheelDirection");
+ QTest::addColumn<int>("expectedIndex");
+
+ IntList disabled;
+ disabled << 0 << 1 << 2 << 4;
+ int start = 3;
+ int wheel = 1;
+ int expected = 3;
+ QTest::newRow("upper locked") << disabled << start << wheel << expected;
+
+ wheel = -1;
+ expected = 5;
+ QTest::newRow("jump over") << disabled << start << wheel << expected;
+
+ disabled.clear();
+ disabled << 1 << 2 << 3 << 4 << 5 << 6 << 7 << 8 << 9;
+ start = 0;
+ wheel = -1;
+ expected = 0;
+ QTest::newRow("single Item enabled") << disabled << start << wheel << expected;
+}
+
+void tst_QComboBox::mouseWheel()
+{
+ QFETCH(IntList, disabledItems);
+ QFETCH(int, startIndex);
+ QFETCH(int, wheelDirection);
+ QFETCH(int, expectedIndex);
+
+ QCoreApplication *applicationInstance = QCoreApplication::instance();
+ QVERIFY(applicationInstance != 0);
+
+ QComboBox box;
+ QStringList list;
+ list << "one" << "two" << "three" << "four" << "five" << "six" << "seven" << "eight" << "nine" << "ten";
+
+ QListWidget listWidget;
+ listWidget.addItems(list);
+
+ foreach (int index, disabledItems)
+ listWidget.item(index)->setFlags(listWidget.item(index)->flags() & ~Qt::ItemIsEnabled);
+
+ box.setModel(listWidget.model());
+ box.setView(&listWidget);
+ for (int i=0; i < 2; ++i) {
+ box.setEditable(i==0?false:true);
+ box.setCurrentIndex(startIndex);
+
+ QWheelEvent event = QWheelEvent(box.rect().bottomRight() , WHEEL_DELTA * wheelDirection, Qt::NoButton, Qt::NoModifier);
+ QVERIFY(applicationInstance->sendEvent(&box,&event));
+
+ QCOMPARE(box.currentIndex(), expectedIndex);
+ }
+}
+
+void tst_QComboBox::layoutDirection()
+{
+ QComboBox box;
+ Qt::LayoutDirection dir;
+ QLineEdit *lineEdit;
+
+ // RTL
+ box.setLayoutDirection(Qt::RightToLeft);
+ QStyleOptionComboBox opt;
+ opt.direction = Qt::RightToLeft;
+ dir = (Qt::LayoutDirection)box.style()->styleHint(QStyle::SH_ComboBox_LayoutDirection, &opt, &box);
+
+ QCOMPARE(box.view()->layoutDirection(), dir);
+ box.setEditable(true);
+ QCOMPARE(box.lineEdit()->layoutDirection(), dir);
+ lineEdit = new QLineEdit;
+ QCOMPARE(lineEdit->layoutDirection(), qApp->layoutDirection());
+ box.setLineEdit(lineEdit);
+ QCOMPARE(lineEdit->layoutDirection(), dir);
+
+ // LTR
+ box.setLayoutDirection(Qt::LeftToRight);
+ qApp->setLayoutDirection(Qt::RightToLeft);
+
+ opt.direction = Qt::LeftToRight;
+ dir = (Qt::LayoutDirection)box.style()->styleHint(QStyle::SH_ComboBox_LayoutDirection, &opt, &box);
+
+ QCOMPARE(box.view()->layoutDirection(), dir);
+ box.setEditable(true);
+ QCOMPARE(box.lineEdit()->layoutDirection(), dir);
+ lineEdit = new QLineEdit;
+ QCOMPARE(lineEdit->layoutDirection(), qApp->layoutDirection());
+ box.setLineEdit(lineEdit);
+ QCOMPARE(lineEdit->layoutDirection(), dir);
+
+}
+
+void tst_QComboBox::itemListPosition()
+{
+ //tests that the list is not out of the screen boundaries
+
+ //put the QApplication layout back
+ QApplication::setLayoutDirection(Qt::LeftToRight);
+
+ //we test QFontComboBox because it has the specific behaviour to set a fixed size
+ //to the list view
+ QWidget topLevel;
+ QFontComboBox combo(&topLevel);
+
+ //the code to get the avaialbe screen space is copied from QComboBox code
+ const int scrNumber = QApplication::desktop()->screenNumber(&combo);
+ QRect screen;
+#ifdef Q_WS_WIN
+ screen = QApplication::desktop()->screenGeometry(scrNumber);
+#elif defined Q_WS_X11
+ if (X11->desktopEnvironment == DE_KDE)
+ screen = QApplication::desktop()->screenGeometry(scrNumber);
+ else
+ screen = QApplication::desktop()->availableGeometry(scrNumber);
+#else
+ screen = QApplication::desktop()->availableGeometry(scrNumber);
+#endif
+
+ combo.move(screen.width()-combo.sizeHint().width(), 0); //puts the combo to the top-right corner
+
+ topLevel.show();
+ //wait because the window manager can move the window if there is a right panel
+ QTRY_VERIFY(combo.isVisible());
+ combo.showPopup();
+ QTRY_VERIFY(combo.view());
+ QTRY_VERIFY(combo.view()->isVisible());
+ QVERIFY( combo.view()->window()->x() + combo.view()->window()->width() <= screen.x() + screen.width() );
+}
+
+void tst_QComboBox::separatorItem_data()
+{
+ QTest::addColumn<QStringList>("items");
+ QTest::addColumn<IntList>("separators");
+
+ QTest::newRow("test") << (QStringList() << "one" << "two" << "three" << "other...")
+ << (IntList() << 4);
+}
+
+void tst_QComboBox::separatorItem()
+{
+ QFETCH(QStringList, items);
+ QFETCH(IntList, separators);
+
+ QComboBox box;
+ box.addItems(items);
+ foreach(int index, separators)
+ box.insertSeparator(index);
+ QCOMPARE(box.count(), (items.count() + separators.count()));
+ for (int i = 0, s = 0; i < box.count(); ++i) {
+ if (i == separators.at(s)) {
+ QCOMPARE(box.itemText(i), QString());
+ ++s;
+ } else {
+ QCOMPARE(box.itemText(i), items.at(i - s));
+ }
+ }
+}
+
+// This test requires the Cleanlooks style
+#ifndef QT_NO_STYLE_CLEANLOOKS
+void tst_QComboBox::task190351_layout()
+{
+ const QString oldStyle = QApplication::style()->objectName();
+ QApplication::setStyle(new QCleanlooksStyle);
+
+ QComboBox listCombo;
+ QListWidget *list = new QListWidget();
+ listCombo.setModel(list->model());
+ listCombo.setView(list);
+ for(int i = 1; i < 150; i++)
+ list->addItem(QLatin1String("list") + QString::number(i));
+
+ listCombo.show();
+ QTest::qWaitForWindowShown(&listCombo);
+ QTRY_VERIFY(listCombo.isVisible());
+ listCombo.setCurrentIndex(70);
+ listCombo.showPopup();
+ QTRY_VERIFY(listCombo.view());
+ QTest::qWaitForWindowShown(listCombo.view());
+ QTRY_VERIFY(listCombo.view()->isVisible());
+ QApplication::processEvents();
+
+#ifdef QT_BUILD_INTERNAL
+ QFrame *container = qFindChild<QComboBoxPrivateContainer *>(&listCombo);
+ QVERIFY(container);
+ QCOMPARE(static_cast<QAbstractItemView *>(list), qFindChild<QAbstractItemView *>(container));
+ QWidget *top = qFindChild<QComboBoxPrivateScroller *>(container);
+ QVERIFY(top);
+ QVERIFY(top->isVisible());
+ QCOMPARE(top->mapToGlobal(QPoint(0, top->height())).y(), list->mapToGlobal(QPoint()).y());
+#endif
+
+ QApplication::setStyle(oldStyle);
+}
+#endif
+
+class task166349_ComboBox : public QComboBox
+{
+ Q_OBJECT
+public:
+ task166349_ComboBox(QWidget *parent = 0) : QComboBox(parent)
+ {
+ QStringList list;
+ list << "one" << "two";
+ connect(this, SIGNAL(currentIndexChanged(int)), this, SLOT(onCurrentIndexChanged(int)));
+ addItems(list);
+ }
+public slots:
+ void onCurrentIndexChanged(int index)
+ {
+ setEditable(index % 2 == 1);
+ }
+};
+
+void tst_QComboBox::task166349_setEditableOnReturn()
+{
+ task166349_ComboBox comboBox;
+ QTest::keyClick(&comboBox, Qt::Key_Down);
+ QTest::keyClick(&comboBox, Qt::Key_1);
+ QTest::keyClick(&comboBox, Qt::Key_Enter);
+ QCOMPARE(QLatin1String("two1"), comboBox.itemText(comboBox.count() - 1));
+}
+
+// This test requires the Cleanlooks style.
+#ifndef QT_NO_STYLE_CLEANLOOKS
+void tst_QComboBox::task191329_size()
+{
+ const QString oldStyle = QApplication::style()->objectName();
+ QApplication::setStyle(new QCleanlooksStyle);
+
+ QComboBox tableCombo;
+ int rows;
+ if (QApplication::desktop()->screenGeometry().height() < 480)
+ rows = 8;
+ else
+ rows = 15;
+
+ QStandardItemModel model(rows, 2);
+ for (int row = 0; row < model.rowCount(); ++row) {
+ for (int column = 0; column < model.columnCount(); ++column) {
+ QStandardItem *item = new QStandardItem(QString("row %0, column %1").arg(row).arg(column));
+ model.setItem(row, column, item);
+ }
+ }
+ QTableView *table = new QTableView();
+ table->verticalHeader()->hide();
+ table->horizontalHeader()->hide();
+ tableCombo.setView(table);
+ tableCombo.setModel(&model);
+
+ tableCombo.show();
+ QTRY_VERIFY(tableCombo.isVisible());
+ tableCombo.showPopup();
+ QTRY_VERIFY(tableCombo.view());
+ QTRY_VERIFY(tableCombo.view()->isVisible());
+
+#ifdef QT_BUILD_INTERNAL
+ QFrame *container = qFindChild<QComboBoxPrivateContainer *>(&tableCombo);
+ QVERIFY(container);
+ QCOMPARE(static_cast<QAbstractItemView *>(table), qFindChild<QAbstractItemView *>(container));
+ foreach (QWidget *button, qFindChildren<QComboBoxPrivateScroller *>(container)) {
+ //the popup should be large enough to contains everithing so the top and left button are hidden
+ QVERIFY(!button->isVisible());
+ }
+#endif
+
+ QApplication::setStyle(oldStyle);
+}
+#endif
+
+void tst_QComboBox::task190205_setModelAdjustToContents()
+{
+ QStringList initialContent;
+ QStringList finalContent;
+ initialContent << "foo" << "bar";
+ finalContent << "bar" << "foooooooobar";
+
+ QComboBox box;
+ box.setSizeAdjustPolicy(QComboBox::AdjustToContents);
+ box.addItems(initialContent);
+ box.show();
+
+ //wait needed in order to get the combo initial size
+ QTRY_VERIFY(box.isVisible());
+
+ box.setModel(new QStringListModel(finalContent));
+
+ QComboBox correctBox;
+ correctBox.addItems(finalContent);
+ correctBox.show();
+
+ QCoreApplication::processEvents();
+#ifdef Q_WS_X11
+ qt_x11_wait_for_window_manager(&box);
+ qt_x11_wait_for_window_manager(&correctBox);
+#endif
+
+ // box should be resized to the same size as correctBox
+ QTRY_COMPARE(box.size(), correctBox.size());
+}
+
+void tst_QComboBox::task248169_popupWithMinimalSize()
+{
+ QStringList initialContent;
+ initialContent << "foo" << "bar" << "foobar";
+
+ QComboBox comboBox;
+ comboBox.addItems(initialContent);
+ QDesktopWidget desktop;
+ QRect desktopSize = desktop.availableGeometry();
+ comboBox.view()->setMinimumWidth(desktopSize.width() / 2);
+
+ comboBox.setGeometry(desktopSize.width() - (desktopSize.width() / 4), (desktopSize.width() / 4), (desktopSize.width() / 2), (desktopSize.width() / 4));
+
+ comboBox.show();
+ QTest::qWaitForWindowShown(&comboBox);
+ QTRY_VERIFY(comboBox.isVisible());
+ comboBox.showPopup();
+ QTRY_VERIFY(comboBox.view());
+ QTest::qWaitForWindowShown(comboBox.view());
+ QTRY_VERIFY(comboBox.view()->isVisible());
+
+#ifdef QT_BUILD_INTERNAL
+ QFrame *container = qFindChild<QComboBoxPrivateContainer *>(&comboBox);
+ QVERIFY(container);
+ QTRY_VERIFY(desktop.screenGeometry(container).contains(container->geometry()));
+#endif
+}
+
+void tst_QComboBox::task247863_keyBoardSelection()
+{
+ QComboBox combo;
+ combo.setEditable(false);
+ combo.addItem( QLatin1String("111"));
+ combo.addItem( QLatin1String("222"));
+ combo.show();
+ QApplication::setActiveWindow(&combo);
+ QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget *>(&combo));
+
+ QSignalSpy spy(&combo, SIGNAL(activated(const QString &)));
+ qApp->setEffectEnabled(Qt::UI_AnimateCombo, false);
+ QTest::keyClick(&combo, Qt::Key_Space);
+ qApp->setEffectEnabled(Qt::UI_AnimateCombo, true);
+ QTest::keyClick(static_cast<QWidget *>(0), Qt::Key_Down);
+ QTest::keyClick(static_cast<QWidget *>(0), Qt::Key_Enter);
+ QCOMPARE(combo.currentText(), QLatin1String("222"));
+ QCOMPARE(spy.count(), 1);
+}
+
+void tst_QComboBox::task220195_keyBoardSelection2()
+{
+ QComboBox combo;
+ combo.setEditable(false);
+ combo.addItem( QLatin1String("foo1"));
+ combo.addItem( QLatin1String("foo2"));
+ combo.addItem( QLatin1String("foo3"));
+ combo.show();
+ QApplication::setActiveWindow(&combo);
+ QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget *>(&combo));
+
+ combo.setCurrentIndex(-1);
+ QVERIFY(combo.currentText().isNull());
+
+ QTest::keyClick(&combo, 'f');
+ QCOMPARE(combo.currentText(), QLatin1String("foo1"));
+ QTest::qWait(QApplication::keyboardInputInterval() + 30);
+ QTest::keyClick(&combo, 'f');
+ QCOMPARE(combo.currentText(), QLatin1String("foo2"));
+ QTest::qWait(QApplication::keyboardInputInterval() + 30);
+ QTest::keyClick(&combo, 'f');
+ QCOMPARE(combo.currentText(), QLatin1String("foo3"));
+ QTest::qWait(QApplication::keyboardInputInterval() + 30);
+ QTest::keyClick(&combo, 'f');
+ QCOMPARE(combo.currentText(), QLatin1String("foo1"));
+ QTest::qWait(QApplication::keyboardInputInterval() + 30);
+
+ combo.setCurrentIndex(1);
+ QCOMPARE(combo.currentText(), QLatin1String("foo2"));
+ QTest::keyClick(&combo, 'f');
+ QCOMPARE(combo.currentText(), QLatin1String("foo3"));
+}
+
+
+void tst_QComboBox::setModelColumn()
+{
+ QStandardItemModel model(5,3);
+ model.setItem(0,0, new QStandardItem("0"));
+ model.setItem(1,0, new QStandardItem("1"));
+ model.setItem(2,0, new QStandardItem("2"));
+ model.setItem(3,0, new QStandardItem("3"));
+ model.setItem(4,0, new QStandardItem("4"));
+ model.setItem(0,1, new QStandardItem("zero"));
+ model.setItem(1,1, new QStandardItem("un"));
+ model.setItem(2,1, new QStandardItem("deux"));
+ model.setItem(3,1, new QStandardItem("trois"));
+ model.setItem(4,1, new QStandardItem("quatre"));
+ model.setItem(0,2, new QStandardItem("a"));
+ model.setItem(1,2, new QStandardItem("b"));
+ model.setItem(2,2, new QStandardItem("c"));
+ model.setItem(3,2, new QStandardItem("d"));
+ model.setItem(4,2, new QStandardItem("e"));
+
+ QComboBox box;
+ box.setModel(&model);
+ QCOMPARE(box.currentText(), QString("0"));
+ box.setModelColumn(1);
+ QCOMPARE(box.currentText(), QString("zero"));
+}
+
+void tst_QComboBox::noScrollbar_data()
+{
+ QTest::addColumn<QString>("stylesheet");
+
+ QTest::newRow("normal") << QString();
+ QTest::newRow("border") << QString::fromLatin1("QAbstractItemView { border: 12px solid blue;}");
+ QTest::newRow("margin") << QString::fromLatin1("QAbstractItemView { margin: 12px 15px 13px 10px; }");
+ QTest::newRow("padding") << QString::fromLatin1("QAbstractItemView { padding: 12px 15px 13px 10px;}");
+ QTest::newRow("everything") << QString::fromLatin1("QAbstractItemView { border: 12px solid blue; "
+ " padding: 12px 15px 13px 10px; margin: 12px 15px 13px 10px; }");
+ QTest::newRow("everything and more") << QString::fromLatin1("QAbstractItemView { border: 1px 3px 5px 1px solid blue; "
+ " padding: 2px 5px 3px 1px; margin: 2px 5px 3px 1px; } "
+ " QAbstractItemView::item { border: 2px solid green; "
+ " padding: 1px 1px 2px 2px; margin: 1px; } " );
+}
+
+void tst_QComboBox::noScrollbar()
+{
+ QStringList initialContent;
+ initialContent << "foo" << "bar" << "foobar" << "moo";
+ QFETCH(QString, stylesheet);
+ QString oldCss = qApp->styleSheet();
+ qApp->setStyleSheet(stylesheet);
+
+ {
+ QWidget topLevel;
+ QComboBox comboBox(&topLevel);
+ comboBox.addItems(initialContent);
+ topLevel.show();
+ comboBox.resize(200, comboBox.height());
+ QTRY_VERIFY(comboBox.isVisible());
+ comboBox.showPopup();
+ QTRY_VERIFY(comboBox.view());
+ QTRY_VERIFY(comboBox.view()->isVisible());
+
+ QVERIFY(!comboBox.view()->horizontalScrollBar()->isVisible());
+ QVERIFY(!comboBox.view()->verticalScrollBar()->isVisible());
+ }
+
+ {
+ QTableWidget *table = new QTableWidget(2,2);
+ QComboBox comboBox;
+ comboBox.setModel(table->model());
+ comboBox.setView(table);
+ comboBox.show();
+ QTRY_VERIFY(comboBox.isVisible());
+ comboBox.resize(200, comboBox.height());
+ comboBox.showPopup();
+ QTRY_VERIFY(comboBox.view());
+ QTRY_VERIFY(comboBox.view()->isVisible());
+
+ QVERIFY(!comboBox.view()->horizontalScrollBar()->isVisible());
+ QVERIFY(!comboBox.view()->verticalScrollBar()->isVisible());
+ }
+
+ qApp->setStyleSheet(oldCss);
+}
+
+void tst_QComboBox::setItemDelegate()
+{
+ QComboBox comboBox;
+ QStyledItemDelegate *itemDelegate = new QStyledItemDelegate;
+ comboBox.setItemDelegate(itemDelegate);
+ // the cast is a workaround for the XLC and Metrowerks compilers
+ QCOMPARE(static_cast<QStyledItemDelegate *>(comboBox.itemDelegate()), itemDelegate);
+}
+
+void tst_QComboBox::task253944_itemDelegateIsReset()
+{
+ QComboBox comboBox;
+ QStyledItemDelegate *itemDelegate = new QStyledItemDelegate;
+ comboBox.setItemDelegate(itemDelegate);
+
+ // the casts are workarounds for the XLC and Metrowerks compilers
+
+ comboBox.setEditable(true);
+ QCOMPARE(static_cast<QStyledItemDelegate *>(comboBox.itemDelegate()), itemDelegate);
+
+ comboBox.setStyleSheet("QComboBox { border: 1px solid gray; }");
+ QCOMPARE(static_cast<QStyledItemDelegate *>(comboBox.itemDelegate()), itemDelegate);
+}
+
+
+void tst_QComboBox::subControlRectsWithOffset_data()
+{
+ QTest::addColumn<bool>("editable");
+
+ QTest::newRow("editable = true") << true;
+ QTest::newRow("editable = false") << false;
+}
+
+void tst_QComboBox::subControlRectsWithOffset()
+{
+ // The sub control rect relative position should not depends
+ // on the position of the combobox
+
+ class FriendlyCombo : public QComboBox {
+ public:
+ void styleOption(QStyleOptionComboBox *optCombo) {
+ initStyleOption(optCombo);
+ }
+ } combo;
+ QStyleOptionComboBox optCombo;
+ combo.styleOption(&optCombo);
+
+
+ const QRect rectAtOrigin(0, 0, 80, 30);
+ const QPoint offset(25, 50);
+ const QRect rectWithOffset = rectAtOrigin.translated(offset);
+
+ QStyle *style = combo.style();
+
+ QFETCH(bool, editable);
+ optCombo.editable = editable;
+
+ optCombo.rect = rectAtOrigin;
+ QRect editFieldRect = style->subControlRect(QStyle::CC_ComboBox, &optCombo, QStyle::SC_ComboBoxEditField, 0);
+ QRect arrowRect = style->subControlRect(QStyle::CC_ComboBox, &optCombo, QStyle::SC_ComboBoxArrow, 0);
+ QRect listboxRect = style->subControlRect(QStyle::CC_ComboBox, &optCombo, QStyle::SC_ComboBoxListBoxPopup, 0);
+
+ optCombo.rect = rectWithOffset;
+ QRect editFieldRectWithOffset = style->subControlRect(QStyle::CC_ComboBox, &optCombo, QStyle::SC_ComboBoxEditField, 0);
+ QRect arrowRectWithOffset = style->subControlRect(QStyle::CC_ComboBox, &optCombo, QStyle::SC_ComboBoxArrow, 0);
+ QRect listboxRectWithOffset = style->subControlRect(QStyle::CC_ComboBox, &optCombo, QStyle::SC_ComboBoxListBoxPopup, 0);
+
+ QCOMPARE(editFieldRect, editFieldRectWithOffset.translated(-offset));
+ QCOMPARE(arrowRect, arrowRectWithOffset.translated(-offset));
+ QCOMPARE(listboxRect, listboxRectWithOffset.translated(-offset));
+
+}
+
+// This test depends on Windows style.
+#ifndef QT_NO_STYLE_WINDOWS
+void tst_QComboBox::task260974_menuItemRectangleForComboBoxPopup()
+{
+ class TestStyle: public QWindowsStyle
+ {
+ public:
+ int styleHint(StyleHint hint, const QStyleOption *option, const QWidget *widget, QStyleHintReturn *ret) const
+ {
+ if (hint == SH_ComboBox_Popup) return 1;
+ else return QCommonStyle::styleHint(hint, option, widget, ret);
+ }
+
+ void drawControl(ControlElement element, const QStyleOption *option, QPainter *, const QWidget *) const
+ {
+ if (element == CE_MenuItem)
+ discoveredRect = option->rect;
+ }
+
+ mutable QRect discoveredRect;
+ } style;
+
+
+ {
+ QComboBox comboBox;
+ comboBox.setStyle(&style);
+ comboBox.addItem("Item 1");
+
+ comboBox.show();
+ QTRY_VERIFY(comboBox.isVisible());
+ comboBox.showPopup();
+ QTRY_VERIFY(comboBox.view());
+ QTRY_VERIFY(comboBox.view()->isVisible());
+
+ QTRY_VERIFY(style.discoveredRect.width() <= comboBox.width());
+ }
+}
+#endif
+
+void tst_QComboBox::removeItem()
+{
+ QComboBox cb;
+ cb.removeItem(-1);
+ cb.removeItem(1);
+ cb.removeItem(0);
+ QCOMPARE(cb.count(), 0);
+
+ cb.addItem("foo");
+ cb.removeItem(-1);
+ QCOMPARE(cb.count(), 1);
+ cb.removeItem(1);
+ QCOMPARE(cb.count(), 1);
+ cb.removeItem(0);
+ QCOMPARE(cb.count(), 0);
+}
+
+void tst_QComboBox::resetModel()
+{
+ class StringListModel : public QStringListModel
+ {
+ public:
+ StringListModel(const QStringList &list) : QStringListModel(list)
+ {
+ }
+
+ void reset()
+ {
+ QStringListModel::reset();
+ }
+ };
+ QComboBox cb;
+ StringListModel model( QStringList() << "1" << "2");
+ QSignalSpy spy(&cb, SIGNAL(currentIndexChanged(int)));
+ QCOMPARE(spy.count(), 0);
+ QCOMPARE(cb.currentIndex(), -1); //no selection
+
+ cb.setModel(&model);
+
+ QCOMPARE(spy.count(), 1);
+ QCOMPARE(cb.currentIndex(), 0); //first item selected
+
+ model.reset();
+ QCOMPARE(spy.count(), 2);
+ QCOMPARE(cb.currentIndex(), -1); //no selection
+
+}
+
+void tst_QComboBox::keyBoardNavigationWithMouse()
+{
+ QComboBox combo;
+ combo.setEditable(false);
+ for (int i = 0; i < 80; i++)
+ combo.addItem( QString::number(i));
+ combo.show();
+ QApplication::setActiveWindow(&combo);
+ QTest::qWaitForWindowShown(&combo);
+ QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget *>(&combo));
+
+ QCOMPARE(combo.currentText(), QLatin1String("0"));
+
+ combo.setFocus();
+ QTRY_VERIFY(combo.hasFocus());
+
+ QTest::keyClick(testWidget->lineEdit(), Qt::Key_Space);
+ QTest::qWait(30);
+ QTRY_VERIFY(combo.view());
+ QTRY_VERIFY(combo.view()->isVisible());
+ QTest::qWait(130);
+
+ QCOMPARE(combo.currentText(), QLatin1String("0"));
+
+ // When calling cursor function, Windows CE responds with: This function is not supported on this system.
+#ifndef Q_OS_WINCE
+ // Force cursor movement to prevent QCursor::setPos() from returning prematurely on QPA:
+ const QPoint target(combo.view()->mapToGlobal(combo.view()->rect().center()));
+ QCursor::setPos(QPoint(target.x() + 1, target.y()));
+ QCursor::setPos(target);
+
+ QTest::qWait(200);
+
+#define GET_SELECTION(SEL) \
+ QCOMPARE(combo.view()->selectionModel()->selection().count(), 1); \
+ QCOMPARE(combo.view()->selectionModel()->selection().indexes().count(), 1); \
+ SEL = combo.view()->selectionModel()->selection().indexes().first().row()
+
+ int selection;
+ GET_SELECTION(selection);
+
+ //since we moved the mouse is in the middle it should even be around 5;
+ QVERIFY(selection > 3);
+
+ static const int final = 40;
+ for (int i = selection + 1; i <= final; i++)
+ {
+ QTest::keyClick(combo.view(), Qt::Key_Down);
+ QTest::qWait(20);
+ GET_SELECTION(selection);
+ QCOMPARE(selection, i);
+ }
+
+ QTest::keyClick(combo.view(), Qt::Key_Enter);
+ QTRY_COMPARE(combo.currentText(), QString::number(final));
+#endif
+}
+
+void tst_QComboBox::task_QTBUG_1071_changingFocusEmitsActivated()
+{
+ QWidget w;
+ QVBoxLayout layout(&w);
+ QComboBox cb;
+ cb.setEditable(true);
+ QSignalSpy spy(&cb, SIGNAL(activated(int)));
+ cb.addItem("0");
+ cb.addItem("1");
+ cb.addItem("2");
+ QLineEdit edit;
+ layout.addWidget(&cb);
+ layout.addWidget(&edit);
+
+ w.show();
+ QApplication::setActiveWindow(&w);
+ QTest::qWaitForWindowShown(&w);
+ cb.clearEditText();
+ cb.setFocus();
+ QApplication::processEvents();
+ QTRY_VERIFY(cb.hasFocus());
+ QTest::keyClick(static_cast<QWidget *>(0), '1');
+ QCOMPARE(spy.count(), 0);
+ edit.setFocus();
+ QTRY_VERIFY(edit.hasFocus());
+ QTRY_COMPARE(spy.count(), 1);
+}
+
+void tst_QComboBox::maxVisibleItems()
+{
+ QComboBox comboBox;
+ QCOMPARE(comboBox.maxVisibleItems(), 10); //default value.
+
+ QStringList content;
+ for(int i = 1; i < 50; i++)
+ content += QString::number(i);
+
+ comboBox.addItems(content);
+ comboBox.show();
+ comboBox.resize(200, comboBox.height());
+ QTRY_VERIFY(comboBox.isVisible());
+
+ comboBox.setMaxVisibleItems(5);
+ QCOMPARE(comboBox.maxVisibleItems(), 5);
+
+ comboBox.showPopup();
+ QTRY_VERIFY(comboBox.view());
+ QTRY_VERIFY(comboBox.view()->isVisible());
+
+ QAbstractItemView *v = comboBox.view();
+ int itemHeight = v->visualRect(v->model()->index(0,0)).height();
+ QListView *lv = qobject_cast<QListView*>(v);
+ if (lv)
+ itemHeight += lv->spacing();
+ QStyleOptionComboBox opt;
+ opt.initFrom(&comboBox);
+ if (!comboBox.style()->styleHint(QStyle::SH_ComboBox_Popup, &opt))
+ QCOMPARE(v->viewport()->height(), itemHeight * comboBox.maxVisibleItems());
+}
+
+void tst_QComboBox::task_QTBUG_10491_currentIndexAndModelColumn()
+{
+ QComboBox comboBox;
+
+ QStandardItemModel model(4, 4, &comboBox);
+ for (int i = 0; i < 4; i++){
+ model.setItem(i, 0, new QStandardItem(QString("Employee Nr %1").arg(i)));
+ model.setItem(i, 1, new QStandardItem(QString("Street Nr %1").arg(i)));
+ model.setItem(i, 2, new QStandardItem(QString("Town Nr %1").arg(i)));
+ model.setItem(i, 3, new QStandardItem(QString("Phone Nr %1").arg(i)));
+ }
+ comboBox.setModel(&model);
+ comboBox.setModelColumn(0);
+
+ QComboBoxPrivate *d = static_cast<QComboBoxPrivate *>(QComboBoxPrivate::get(&comboBox));
+ d->setCurrentIndex(model.index(2, 2));
+ QCOMPARE(QModelIndex(d->currentIndex), model.index(2, comboBox.modelColumn()));
+}
+
+QTEST_MAIN(tst_QComboBox)
+#include "tst_qcombobox.moc"
diff --git a/tests/auto/widgets/widgets/qcommandlinkbutton/.gitignore b/tests/auto/widgets/widgets/qcommandlinkbutton/.gitignore
new file mode 100644
index 0000000000..878121e2e6
--- /dev/null
+++ b/tests/auto/widgets/widgets/qcommandlinkbutton/.gitignore
@@ -0,0 +1 @@
+tst_qcommandlinkbutton
diff --git a/tests/auto/widgets/widgets/qcommandlinkbutton/qcommandlinkbutton.pro b/tests/auto/widgets/widgets/qcommandlinkbutton/qcommandlinkbutton.pro
new file mode 100644
index 0000000000..497b8298a2
--- /dev/null
+++ b/tests/auto/widgets/widgets/qcommandlinkbutton/qcommandlinkbutton.pro
@@ -0,0 +1,6 @@
+load(qttest_p4)
+QT += widgets
+SOURCES += tst_qcommandlinkbutton.cpp
+
+
+
diff --git a/tests/auto/widgets/widgets/qcommandlinkbutton/tst_qcommandlinkbutton.cpp b/tests/auto/widgets/widgets/qcommandlinkbutton/tst_qcommandlinkbutton.cpp
new file mode 100644
index 0000000000..6a51bf4bba
--- /dev/null
+++ b/tests/auto/widgets/widgets/qcommandlinkbutton/tst_qcommandlinkbutton.cpp
@@ -0,0 +1,590 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#include <QtTest/QtTest>
+
+
+#include "qcommandlinkbutton.h"
+#include <qapplication.h>
+
+#include <qcommandlinkbutton.h>
+#include <qmenu.h>
+#include <qtimer.h>
+#include <QDialog>
+#include <QGridLayout>
+#include <QPainter>
+
+Q_DECLARE_METATYPE(QCommandLinkButton*)
+
+//TESTED_CLASS=
+//TESTED_FILES=
+
+class tst_QCommandLinkButton : public QObject
+{
+Q_OBJECT
+public:
+ tst_QCommandLinkButton();
+ virtual ~tst_QCommandLinkButton();
+
+
+public slots:
+ void initTestCase();
+ void cleanupTestCase();
+ void init();
+ void cleanup();
+private slots:
+ void getSetCheck();
+ void pressed();
+ void setAccel();
+ void isCheckable();
+ void setDown();
+ void popupCrash();
+ void isChecked();
+ void animateClick();
+ void toggle();
+ void clicked();
+ void toggled();
+ void defaultAndAutoDefault();
+ void setAutoRepeat();
+ void heightForWithWithIcon();
+
+protected slots:
+ void resetCounters();
+ void onClicked();
+ void onToggled( bool on );
+ void onPressed();
+ void onReleased();
+ void helperSlotDelete();
+
+private:
+ uint click_count;
+ uint toggle_count;
+ uint press_count;
+ uint release_count;
+
+ QCommandLinkButton *testWidget;
+};
+
+// Testing get/set functions
+void tst_QCommandLinkButton::getSetCheck()
+{
+ QCommandLinkButton obj1;
+
+ QString text("mytext");
+ QVERIFY(obj1.description().isEmpty());
+ obj1.setDescription(text);
+ QVERIFY(obj1.description() == text);
+
+ QVERIFY(obj1.text().isEmpty());
+ obj1.setText(text);
+ QVERIFY(obj1.text() == text);
+
+
+ QMenu *var1 = new QMenu;
+ obj1.setMenu(var1);
+ QCOMPARE(var1, obj1.menu());
+ obj1.setMenu((QMenu *)0);
+ QCOMPARE((QMenu *)0, obj1.menu());
+ delete var1;
+}
+
+tst_QCommandLinkButton::tst_QCommandLinkButton()
+{
+}
+
+tst_QCommandLinkButton::~tst_QCommandLinkButton()
+{
+}
+
+void tst_QCommandLinkButton::initTestCase()
+{
+ // Create the test class
+ testWidget = new QCommandLinkButton( "&Start", 0 );
+ testWidget->setObjectName("testWidget");
+ testWidget->resize( 200, 200 );
+ testWidget->show();
+
+ connect( testWidget, SIGNAL(clicked()), this, SLOT(onClicked()) );
+ connect( testWidget, SIGNAL(pressed()), this, SLOT(onPressed()) );
+ connect( testWidget, SIGNAL(released()), this, SLOT(onReleased()) );
+ connect( testWidget, SIGNAL(toggled(bool)), this, SLOT(onToggled(bool)) );
+}
+
+void tst_QCommandLinkButton::cleanupTestCase()
+{
+ delete testWidget;
+ testWidget = 0;
+}
+
+void tst_QCommandLinkButton::init()
+{
+ testWidget->setAutoRepeat( FALSE );
+ testWidget->setDown( FALSE );
+ testWidget->setText("Test");
+ testWidget->setDescription("Description text.");
+ testWidget->setEnabled( TRUE );
+ QKeySequence seq;
+ testWidget->setShortcut( seq );
+
+ resetCounters();
+}
+
+void tst_QCommandLinkButton::cleanup()
+{
+}
+
+
+void tst_QCommandLinkButton::resetCounters()
+{
+ toggle_count = 0;
+ press_count = 0;
+ release_count = 0;
+ click_count = 0;
+}
+
+void tst_QCommandLinkButton::onClicked()
+{
+ click_count++;
+}
+
+void tst_QCommandLinkButton::onToggled( bool /*on*/ )
+{
+ toggle_count++;
+}
+
+void tst_QCommandLinkButton::onPressed()
+{
+ press_count++;
+}
+
+void tst_QCommandLinkButton::onReleased()
+{
+ release_count++;
+}
+
+void tst_QCommandLinkButton::setAutoRepeat()
+{
+ // Give the last tests time to finish - i.e., wait for the window close
+ // and deactivate to avoid a race condition here. We can't add this to the
+ // end of the defaultAndAutoDefault test, since any failure in that test
+ // will return out of that function.
+ QTest::qWait( 1000 );
+
+ // If this changes, this test must be completely revised.
+ QVERIFY( !testWidget->isCheckable() );
+
+ // verify autorepeat is off by default.
+ QCommandLinkButton tmp( 0 );
+ tmp.setObjectName("tmp");
+ QVERIFY( !tmp.autoRepeat() );
+
+ // check if we can toggle the mode
+ testWidget->setAutoRepeat( TRUE );
+ QVERIFY( testWidget->autoRepeat() );
+
+ testWidget->setAutoRepeat( FALSE );
+ QVERIFY( !testWidget->autoRepeat() );
+
+ resetCounters();
+
+ // check that the button is down if we press space and not in autorepeat
+ testWidget->setDown( FALSE );
+ testWidget->setAutoRepeat( FALSE );
+ QTest::keyPress( testWidget, Qt::Key_Space );
+
+ QTest::qWait( 300 );
+
+ QVERIFY( testWidget->isDown() );
+ QVERIFY( toggle_count == 0 );
+ QVERIFY( press_count == 1 );
+ QVERIFY( release_count == 0 );
+ QVERIFY( click_count == 0 );
+
+ QTest::keyRelease( testWidget, Qt::Key_Space );
+ resetCounters();
+
+ // check that the button is down if we press space while in autorepeat
+ // we can't actually confirm how many times it is fired, more than 1 is enough.
+
+ testWidget->setDown( FALSE );
+ testWidget->setAutoRepeat( TRUE );
+ QTest::keyPress( testWidget, Qt::Key_Space );
+ QTest::qWait(900);
+ QVERIFY( testWidget->isDown() );
+ QVERIFY( toggle_count == 0 );
+ QTest::keyRelease( testWidget, Qt::Key_Space );
+ QVERIFY(press_count == release_count);
+ QVERIFY(release_count == click_count);
+ QVERIFY(press_count > 1);
+
+ // #### shouldn't I check here to see if multiple signals have been fired???
+
+ // check that pressing ENTER has no effect
+ resetCounters();
+ testWidget->setDown( FALSE );
+ testWidget->setAutoRepeat( FALSE );
+ QTest::keyPress( testWidget, Qt::Key_Enter );
+
+ QTest::qWait( 300 );
+
+ QVERIFY( !testWidget->isDown() );
+ QVERIFY( toggle_count == 0 );
+ QVERIFY( press_count == 0 );
+ QVERIFY( release_count == 0 );
+ QVERIFY( click_count == 0 );
+ QTest::keyRelease( testWidget, Qt::Key_Enter );
+
+ // check that pressing ENTER has no effect
+ resetCounters();
+ testWidget->setDown( FALSE );
+ testWidget->setAutoRepeat( TRUE );
+ QTest::keyClick( testWidget, Qt::Key_Enter );
+ QTest::qWait( 300 );
+ QVERIFY( !testWidget->isDown() );
+ QVERIFY( toggle_count == 0 );
+ QVERIFY( press_count == 0 );
+ QVERIFY( release_count == 0 );
+ QVERIFY( click_count == 0 );
+}
+
+void tst_QCommandLinkButton::pressed()
+{
+ QTest::keyPress( testWidget, ' ' );
+// QTest::qWait( 300 );
+ QCOMPARE( press_count, (uint)1 );
+ QCOMPARE( release_count, (uint)0 );
+
+ QTest::keyRelease( testWidget, ' ' );
+// QTest::qWait( 300 );
+ QCOMPARE( press_count, (uint)1 );
+ QCOMPARE( release_count, (uint)1 );
+
+ QTest::keyPress( testWidget,Qt::Key_Enter );
+// QTest::qWait( 300 );
+ QCOMPARE( press_count, (uint)1 );
+ QCOMPARE( release_count, (uint)1 );
+
+ testWidget->setAutoDefault(true);
+ QTest::keyPress( testWidget,Qt::Key_Enter );
+// QTest::qWait( 300 );
+ QCOMPARE( press_count, (uint)2 );
+ QCOMPARE( release_count, (uint)2 );
+ testWidget->setAutoDefault(false);
+
+}
+
+
+
+void tst_QCommandLinkButton::isCheckable()
+{
+ QVERIFY( !testWidget->isCheckable() );
+}
+
+void tst_QCommandLinkButton::setDown()
+{
+ testWidget->setDown( FALSE );
+ QVERIFY( !testWidget->isDown() );
+
+ testWidget->setDown( TRUE );
+ QVERIFY( testWidget->isDown() );
+
+ testWidget->setDown( TRUE );
+ QTest::keyClick( testWidget, Qt::Key_Escape );
+ QVERIFY( !testWidget->isDown() );
+}
+
+void tst_QCommandLinkButton::isChecked()
+{
+ testWidget->setDown( FALSE );
+ QVERIFY( !testWidget->isChecked() );
+
+ testWidget->setDown( TRUE );
+ QVERIFY( !testWidget->isChecked() );
+
+ testWidget->setDown( FALSE );
+ testWidget->toggle();
+ QVERIFY( testWidget->isChecked() == testWidget->isCheckable() );
+}
+
+void tst_QCommandLinkButton::toggle()
+{
+ // the pushbutton shouldn't toggle the button.
+ testWidget->toggle();
+ QVERIFY( testWidget->isChecked() == FALSE );
+}
+
+void tst_QCommandLinkButton::toggled()
+{
+ // the pushbutton shouldn't send a toggled signal when we call the toggle slot.
+ QVERIFY( !testWidget->isCheckable() );
+
+ testWidget->toggle();
+ QVERIFY( toggle_count == 0 );
+
+ // do it again, just to be sure
+ resetCounters();
+ testWidget->toggle();
+ QVERIFY( toggle_count == 0 );
+
+ // finally check that we can toggle using the mouse
+ resetCounters();
+ QTest::mousePress( testWidget, Qt::LeftButton );
+ QVERIFY( toggle_count == 0 );
+ QVERIFY( click_count == 0 );
+
+ QTest::mouseRelease( testWidget, Qt::LeftButton );
+ QVERIFY( click_count == 1 );
+}
+
+/*
+ If we press an accelerator key we ONLY get a pressed signal and
+ NOT a released or clicked signal.
+*/
+
+void tst_QCommandLinkButton::setAccel()
+{
+ testWidget->setText("&AccelTest");
+ QKeySequence seq( Qt::ALT + Qt::Key_A );
+ testWidget->setShortcut( seq );
+
+ // The shortcut will not be activated unless the button is in a active
+ // window and has focus
+ testWidget->setFocus();
+ for (int i = 0; !testWidget->isActiveWindow() && i < 1000; ++i) {
+ testWidget->activateWindow();
+ QApplication::instance()->processEvents();
+ QTest::qWait(100);
+ }
+
+ QVERIFY(testWidget->isActiveWindow());
+
+ QTest::keyClick( testWidget, 'A', Qt::AltModifier );
+ QTest::qWait( 500 );
+ QVERIFY( click_count == 1 );
+ QVERIFY( press_count == 1 );
+ QVERIFY( release_count == 1 );
+ QVERIFY( toggle_count == 0 );
+
+ // wait 200 ms because setAccel uses animateClick.
+ // if we don't wait this may screw up a next test.
+ QTest::qWait(200);
+}
+
+void tst_QCommandLinkButton::animateClick()
+{
+ QVERIFY( !testWidget->isDown() );
+ testWidget->animateClick();
+ QVERIFY( testWidget->isDown() );
+ QTest::qWait( 200 );
+ QVERIFY( !testWidget->isDown() );
+
+ QVERIFY( click_count == 1 );
+ QVERIFY( press_count == 1 );
+ QVERIFY( release_count == 1 );
+ QVERIFY( toggle_count == 0 );
+}
+
+void tst_QCommandLinkButton::clicked()
+{
+ QTest::mousePress( testWidget, Qt::LeftButton );
+ QVERIFY( press_count == 1 );
+ QVERIFY( release_count == 0 );
+
+ QTest::mouseRelease( testWidget, Qt::LeftButton );
+ QCOMPARE( press_count, (uint)1 );
+ QCOMPARE( release_count, (uint)1 );
+
+ press_count = 0;
+ release_count = 0;
+ testWidget->setDown(FALSE);
+ for (uint i=0; i<10; i++)
+ QTest::mouseClick( testWidget, Qt::LeftButton );
+ QCOMPARE( press_count, (uint)10 );
+ QCOMPARE( release_count, (uint)10 );
+}
+
+QCommandLinkButton *pb = 0;
+void tst_QCommandLinkButton::helperSlotDelete()
+{
+ delete pb;
+ pb = 0;
+}
+
+void tst_QCommandLinkButton::popupCrash()
+{
+ pb = new QCommandLinkButton("foo", "description");
+ QMenu *menu = new QMenu("bar", pb);
+ pb->setMenu(menu);
+ QTimer::singleShot(1000, this, SLOT(helperSlotDelete()));
+ pb->show();
+ pb->click();
+}
+
+void tst_QCommandLinkButton::defaultAndAutoDefault()
+{
+ {
+ // Adding buttons directly to QDialog
+ QDialog dialog;
+
+ QCommandLinkButton button1(&dialog);
+ QVERIFY(button1.autoDefault());
+ QVERIFY(!button1.isDefault());
+
+ QCommandLinkButton button2(&dialog);
+ QVERIFY(button2.autoDefault());
+ QVERIFY(!button2.isDefault());
+
+ button1.setDefault(true);
+ QVERIFY(button1.autoDefault());
+ QVERIFY(button1.isDefault());
+ QVERIFY(button2.autoDefault());
+ QVERIFY(!button2.isDefault());
+
+ dialog.show();
+ QVERIFY(dialog.isVisible());
+
+ QObject::connect(&button1, SIGNAL(clicked()), &dialog, SLOT(hide()));
+ QKeyEvent event(QEvent::KeyPress, Qt::Key_Return, Qt::NoModifier);
+ QApplication::sendEvent(&dialog, &event);
+ QVERIFY(!dialog.isVisible());
+ }
+
+ {
+ // Adding buttons to QDialog through a layout
+ QDialog dialog;
+
+ QCommandLinkButton button3;
+ button3.setAutoDefault(false);
+
+ QCommandLinkButton button1;
+ QVERIFY(!button1.autoDefault());
+ QVERIFY(!button1.isDefault());
+
+ QCommandLinkButton button2;
+ QVERIFY(!button2.autoDefault());
+ QVERIFY(!button2.isDefault());
+
+ button1.setDefault(true);
+ QVERIFY(!button1.autoDefault());
+ QVERIFY(button1.isDefault());
+ QVERIFY(!button2.autoDefault());
+ QVERIFY(!button2.isDefault());
+
+ QGridLayout layout;
+ layout.addWidget(&button3, 0, 3);
+ layout.addWidget(&button2, 0, 2);
+ layout.addWidget(&button1, 0, 1);
+ dialog.setLayout(&layout);
+ button3.setFocus();
+ QVERIFY(button1.autoDefault());
+ QVERIFY(button1.isDefault());
+ QVERIFY(button2.autoDefault());
+ QVERIFY(!button2.isDefault());
+
+ dialog.show();
+ QVERIFY(dialog.isVisible());
+
+ QObject::connect(&button1, SIGNAL(clicked()), &dialog, SLOT(hide()));
+ QKeyEvent event(QEvent::KeyPress, Qt::Key_Return, Qt::NoModifier);
+ QApplication::sendEvent(&dialog, &event);
+ QVERIFY(!dialog.isVisible());
+ }
+
+ {
+ // autoDefault behavior.
+ QDialog dialog;
+ QCommandLinkButton button2(&dialog);
+ QCommandLinkButton button1(&dialog);
+ dialog.show();
+ QVERIFY(dialog.isVisible());
+
+ // No default button is set, and button2 is the first autoDefault button
+ // that is next in the tab order
+ QObject::connect(&button2, SIGNAL(clicked()), &dialog, SLOT(hide()));
+ QKeyEvent event(QEvent::KeyPress, Qt::Key_Return, Qt::NoModifier);
+ QApplication::sendEvent(&dialog, &event);
+ QVERIFY(!dialog.isVisible());
+
+ // Reparenting
+ QVERIFY(button2.autoDefault());
+ button2.setParent(0);
+ QVERIFY(!button2.autoDefault());
+ button2.setAutoDefault(false);
+ button2.setParent(&dialog);
+ QVERIFY(!button2.autoDefault());
+
+ button1.setAutoDefault(true);
+ button1.setParent(0);
+ QVERIFY(button1.autoDefault());
+ }
+}
+
+void tst_QCommandLinkButton::heightForWithWithIcon()
+{
+ QWidget mainWin;
+
+ QPixmap pixmap(64, 64);
+ {
+ pixmap.fill(Qt::white);
+ QPainter painter(&pixmap);
+ painter.setBrush(Qt::black);
+ painter.drawEllipse(0, 0, 63, 63);
+ }
+
+ QCommandLinkButton *largeIconButton = new QCommandLinkButton(QString("Large Icon"),
+ QString("Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Mauris nibh lectus, adipiscing eu."),
+ &mainWin);
+ largeIconButton->setIconSize(QSize(64, 64));
+ largeIconButton->setIcon(pixmap);
+
+ QVBoxLayout *layout = new QVBoxLayout();
+ layout->addWidget(largeIconButton);
+ layout->addStretch();
+ mainWin.setLayout(layout);
+ mainWin.showMaximized();
+ QTest::qWaitForWindowShown(&mainWin);
+ QVERIFY(largeIconButton->height() > 68); //enough room for the icon
+
+}
+
+QTEST_MAIN(tst_QCommandLinkButton)
+#include "tst_qcommandlinkbutton.moc"
diff --git a/tests/auto/widgets/widgets/qdatetimeedit/.gitignore b/tests/auto/widgets/widgets/qdatetimeedit/.gitignore
new file mode 100644
index 0000000000..a68e3269d2
--- /dev/null
+++ b/tests/auto/widgets/widgets/qdatetimeedit/.gitignore
@@ -0,0 +1 @@
+tst_qdatetimeedit
diff --git a/tests/auto/widgets/widgets/qdatetimeedit/qdatetimeedit.pro b/tests/auto/widgets/widgets/qdatetimeedit/qdatetimeedit.pro
new file mode 100644
index 0000000000..47356d448c
--- /dev/null
+++ b/tests/auto/widgets/widgets/qdatetimeedit/qdatetimeedit.pro
@@ -0,0 +1,8 @@
+load(qttest_p4)
+QT += widgets
+SOURCES += tst_qdatetimeedit.cpp
+
+wincewm50smart-msvc2005: DEFINES += WINCE_NO_MODIFIER_KEYS
+
+
+
diff --git a/tests/auto/widgets/widgets/qdatetimeedit/tst_qdatetimeedit.cpp b/tests/auto/widgets/widgets/qdatetimeedit/tst_qdatetimeedit.cpp
new file mode 100644
index 0000000000..c64c9e7019
--- /dev/null
+++ b/tests/auto/widgets/widgets/qdatetimeedit/tst_qdatetimeedit.cpp
@@ -0,0 +1,3458 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#include <QtTest/QtTest>
+#include <qapplication.h>
+#include <qgroupbox.h>
+#include <qlineedit.h>
+#include <qwindowsstyle.h>
+
+
+
+#include <qdatetimeedit.h>
+#include <qlocale.h>
+#include <qlayout.h>
+#include <qeventloop.h>
+#include <qstyle.h>
+#include <qstyle.h>
+#include <QStyleOptionSpinBox>
+#include <QDate>
+#include <QDateTime>
+#include <QTime>
+#include <QList>
+#include <QDateTimeEdit>
+#include <QCalendarWidget>
+#include <QWidget>
+#include <QLineEdit>
+#include <QObject>
+#include <QLocale>
+#include <QString>
+#include <QVariantList>
+#include <QVariant>
+#include <QApplication>
+#include <QPoint>
+#include <QVBoxLayout>
+#include <QRect>
+#include <QCursor>
+#include <QEventLoop>
+#include <QStyle>
+#include <QStyleOptionComboBox>
+#include <QTimeEdit>
+#include <QMetaType>
+#include <QDebug>
+#include <QWheelEvent>
+#include <QTest>
+#include <QSignalSpy>
+#include <QTestEventList>
+#include <QDateEdit>
+
+#ifdef Q_OS_WIN
+# include <windows.h>
+# undef min
+# undef max
+#endif
+
+
+Q_DECLARE_METATYPE(QDate);
+Q_DECLARE_METATYPE(Qt::Key);
+Q_DECLARE_METATYPE(Qt::KeyboardModifiers);
+Q_DECLARE_METATYPE(Qt::KeyboardModifier);
+Q_DECLARE_METATYPE(QDateTime);
+Q_DECLARE_METATYPE(QTime);
+Q_DECLARE_METATYPE(QList<int>);
+
+#if defined(Q_OS_WINCE)
+bool qt_wince_is_platform(const QString &platformString) {
+ wchar_t tszPlatform[64];
+ if (SystemParametersInfo(SPI_GETPLATFORMTYPE,
+ sizeof(tszPlatform)/sizeof(*tszPlatform),tszPlatform,0))
+ if (0 == _tcsicmp(reinterpret_cast<const wchar_t *> (platformString.utf16()), tszPlatform))
+ return true;
+ return false;
+}
+bool qt_wince_is_pocket_pc() {
+ return qt_wince_is_platform(QString::fromLatin1("PocketPC"));
+}
+bool qt_wince_is_smartphone() {
+ return qt_wince_is_platform(QString::fromLatin1("Smartphone"));
+}
+bool qt_wince_is_mobile() {
+ return (qt_wince_is_smartphone() || qt_wince_is_pocket_pc());
+}
+#endif
+
+
+//TESTED_CLASS=
+//TESTED_FILES=
+
+class EditorDateEdit : public QDateTimeEdit
+{
+ Q_OBJECT
+public:
+ EditorDateEdit(QWidget *parent = 0) : QDateTimeEdit(parent) {}
+ QLineEdit *lineEdit() { return QDateTimeEdit::lineEdit(); }
+ friend class tst_QDateTimeEdit;
+};
+
+class tst_QDateTimeEdit : public QObject
+{
+ Q_OBJECT
+public:
+ tst_QDateTimeEdit();
+ virtual ~tst_QDateTimeEdit();
+public slots:
+ void initTestCase();
+ void init();
+ void cleanup();
+ void cleanupTestCase();
+private slots:
+ void cachedDayTest();
+ void getSetCheck();
+ void constructor_qwidget();
+ void constructor_qdatetime_data();
+ void constructor_qdatetime();
+ void constructor_qdate_data();
+ void constructor_qdate();
+ void constructor_qtime_data();
+ void constructor_qtime();
+
+ void sectionText_data();
+ void sectionText();
+ void dateTimeSignalChecking_data();
+ void dateTimeSignalChecking();
+ void mousePress();
+ void stepHourAMPM_data();
+
+ void stepHourAMPM();
+ void displayedSections_data();
+ void displayedSections();
+ void currentSection_data();
+ void currentSection();
+
+ void setCurrentSection();
+ void setCurrentSection_data();
+
+ void minimumDate_data();
+ void minimumDate();
+ void maximumDate_data();
+ void maximumDate();
+ void clearMinimumDate_data();
+ void clearMinimumDate();
+ void clearMaximumDate_data();
+ void clearMaximumDate();
+
+ void minimumDateTime_data();
+ void minimumDateTime();
+ void maximumDateTime_data();
+ void maximumDateTime();
+
+ void clearMinimumDateTime_data();
+ void clearMinimumDateTime();
+ void clearMaximumDateTime_data();
+ void clearMaximumDateTime();
+
+ void displayFormat_data();
+ void displayFormat();
+
+ void specialValueText();
+ void setRange_data();
+ void setRange();
+
+ void selectAndScrollWithKeys();
+ void backspaceKey();
+ void deleteKey();
+ void tabKeyNavigation();
+ void tabKeyNavigationWithPrefix();
+ void tabKeyNavigationWithSuffix();
+ void enterKey();
+
+ void readOnly();
+
+ void wrappingDate_data();
+ void wrappingDate();
+
+ void dateSignalChecking_data();
+ void dateSignalChecking();
+
+ void wrappingTime_data();
+ void wrappingTime();
+
+ void userKeyPress_Time_data();
+ void userKeyPress_Time();
+
+ void timeSignalChecking_data();
+ void timeSignalChecking();
+
+ void weirdCase();
+ void newCase();
+ void newCase2();
+ void newCase3();
+ void newCase4();
+ void newCase5();
+ void newCase6();
+
+ void task98554();
+ void task149097();
+
+ void cursorPos();
+ void calendarPopup();
+
+ void hour12Test();
+ void yyTest();
+ void task108572();
+
+ void task148725();
+ void task148522();
+
+ void setSelectedSection();
+ void reverseTest();
+
+ void ddMMMMyyyy();
+ void wheelEvent();
+
+ void specialValueCornerCase();
+ void cursorPositionOnInit();
+
+ void task118867();
+
+ void nextPrevSection_data();
+ void nextPrevSection();
+
+ void dateEditTimeEditFormats();
+ void timeSpec_data();
+ void timeSpec();
+ void timeSpecBug();
+
+ void monthEdgeCase();
+ void setLocale();
+
+ void potentialYYValueBug();
+ void textSectionAtEnd();
+
+ void keypadAutoAdvance_data();
+ void keypadAutoAdvance();
+
+ void task196924();
+ void focusNextPrevChild();
+
+ void taskQTBUG_12384_timeSpecShowTimeOnly();
+
+ void deleteCalendarWidget();
+
+private:
+ EditorDateEdit* testWidget;
+ QWidget *testFocusWidget;
+};
+
+typedef QList<QTime> TimeList;
+typedef QList<Qt::Key> KeyList;
+
+Q_DECLARE_METATYPE(TimeList)
+Q_DECLARE_METATYPE(KeyList)
+
+// Testing get/set functions
+void tst_QDateTimeEdit::getSetCheck()
+{
+ QDateTimeEdit obj1;
+ obj1.setDisplayFormat("dd/MM/yyyy hh:mm:ss.zzz d/M/yy h:m:s.z AP");
+ // Section QDateTimeEdit::currentSection()
+ // void QDateTimeEdit::setCurrentSection(Section)
+ obj1.setCurrentSection(QDateTimeEdit::NoSection);
+ QVERIFY(obj1.currentSection() != QDateTimeEdit::NoSection);
+ obj1.setCurrentSection(QDateTimeEdit::AmPmSection);
+ QCOMPARE(QDateTimeEdit::AmPmSection, obj1.currentSection());
+ obj1.setCurrentSection(QDateTimeEdit::MSecSection);
+ QCOMPARE(QDateTimeEdit::MSecSection, obj1.currentSection());
+ obj1.setCurrentSection(QDateTimeEdit::SecondSection);
+ QCOMPARE(QDateTimeEdit::SecondSection, obj1.currentSection());
+ obj1.setCurrentSection(QDateTimeEdit::MinuteSection);
+ QCOMPARE(QDateTimeEdit::MinuteSection, obj1.currentSection());
+ obj1.setCurrentSection(QDateTimeEdit::HourSection);
+ QCOMPARE(QDateTimeEdit::HourSection, obj1.currentSection());
+ obj1.setCurrentSection(QDateTimeEdit::DaySection);
+ QCOMPARE(QDateTimeEdit::DaySection, obj1.currentSection());
+ obj1.setCurrentSection(QDateTimeEdit::MonthSection);
+ QCOMPARE(QDateTimeEdit::MonthSection, obj1.currentSection());
+ obj1.setCurrentSection(QDateTimeEdit::YearSection);
+ QCOMPARE(QDateTimeEdit::YearSection, obj1.currentSection());
+}
+
+tst_QDateTimeEdit::tst_QDateTimeEdit()
+{
+ qRegisterMetaType<QDate>("QDate");
+ qRegisterMetaType<QTime>("QTime");
+ qRegisterMetaType<QDateTime>("QDateTime");
+ qRegisterMetaType<QList<int> >("QList<int>");
+}
+
+tst_QDateTimeEdit::~tst_QDateTimeEdit()
+{
+
+}
+
+void tst_QDateTimeEdit::initTestCase()
+{
+ QLocale system = QLocale::system();
+ if (system.language() != QLocale::C && system.language() != QLocale::English)
+ qWarning("Running under locale %s/%s -- this test may generate failures due to language differences",
+ qPrintable(QLocale::languageToString(system.language())),
+ qPrintable(QLocale::countryToString(system.country())));
+ testWidget = new EditorDateEdit(0);
+ testFocusWidget = new QWidget(0);
+ testFocusWidget->resize(200, 100);
+ testFocusWidget->show();
+}
+
+void tst_QDateTimeEdit::cleanupTestCase()
+{
+ delete testFocusWidget;
+ testFocusWidget = 0;
+ delete testWidget;
+ testWidget = 0;
+}
+
+
+void tst_QDateTimeEdit::init()
+{
+ QLocale::setDefault(QLocale(QLocale::C));
+#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE)
+ SetThreadLocale(MAKELCID(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), SORT_DEFAULT));
+#endif
+ testWidget->setDisplayFormat("dd/MM/yyyy"); // Nice default to have
+ testWidget->setDateTime(QDateTime(QDate(2000, 1, 1), QTime(0, 0)));
+ testWidget->show();
+ testFocusWidget->move(-1000, -1000);
+}
+
+void tst_QDateTimeEdit::cleanup()
+{
+ testWidget->clearMinimumDateTime();
+ testWidget->clearMaximumDateTime();
+ testWidget->setTimeSpec(Qt::LocalTime);
+ testWidget->setSpecialValueText(QString());
+ testWidget->setWrapping(false);
+}
+
+void tst_QDateTimeEdit::constructor_qwidget()
+{
+ testWidget->hide();
+ QDateTimeEdit dte(0);
+ dte.show();
+ QCOMPARE(dte.dateTime(), QDateTime(QDate(2000, 1, 1), QTime(0, 0, 0, 0)));
+ QCOMPARE(dte.minimumDate(), QDate(1752, 9, 14));
+ QCOMPARE(dte.minimumTime(), QTime(0, 0, 0, 0));
+ QCOMPARE(dte.maximumDate(), QDate(7999, 12, 31));
+ QCOMPARE(dte.maximumTime(), QTime(23, 59, 59, 999));
+}
+
+void tst_QDateTimeEdit::constructor_qdatetime_data()
+{
+ QTest::addColumn<QDateTime>("parameter");
+ QTest::addColumn<QDateTime>("displayDateTime");
+ QTest::addColumn<QDate>("minimumDate");
+ QTest::addColumn<QTime>("minimumTime");
+ QTest::addColumn<QDate>("maximumDate");
+ QTest::addColumn<QTime>("maximumTime");
+
+ QTest::newRow("normal") << QDateTime(QDate(2004, 6, 16), QTime(13, 46, 32, 764))
+ << QDateTime(QDate(2004, 6, 16), QTime(13, 46, 32, 764))
+ << QDate(1752, 9, 14) << QTime(0, 0, 0, 0)
+ << QDate(7999, 12, 31) << QTime(23, 59, 59, 999);
+
+ QTest::newRow("invalid") << QDateTime(QDate(9999, 99, 99), QTime(13, 46, 32, 764))
+ << QDateTime(QDate(2000, 1, 1), QTime(0, 0, 0, 0))
+ << QDate(1752, 9, 14) << QTime(0, 0, 0, 0)
+ << QDate(7999, 12, 31) << QTime(23, 59, 59, 999);
+}
+
+
+
+void tst_QDateTimeEdit::constructor_qdatetime()
+{
+ QFETCH(QDateTime, parameter);
+ QFETCH(QDateTime, displayDateTime);
+ QFETCH(QDate, minimumDate);
+ QFETCH(QTime, minimumTime);
+ QFETCH(QDate, maximumDate);
+ QFETCH(QTime, maximumTime);
+
+ testWidget->hide();
+
+ QDateTimeEdit dte(parameter);
+ dte.show();
+ QCOMPARE(dte.dateTime(), displayDateTime);
+ QCOMPARE(dte.minimumDate(), minimumDate);
+ QCOMPARE(dte.minimumTime(), minimumTime);
+ QCOMPARE(dte.maximumDate(), maximumDate);
+ QCOMPARE(dte.maximumTime(), maximumTime);
+}
+
+void tst_QDateTimeEdit::constructor_qdate_data()
+{
+ QTest::addColumn<QDate>("parameter");
+ QTest::addColumn<QDateTime>("displayDateTime");
+ QTest::addColumn<QDate>("minimumDate");
+ QTest::addColumn<QTime>("minimumTime");
+ QTest::addColumn<QDate>("maximumDate");
+ QTest::addColumn<QTime>("maximumTime");
+
+ QTest::newRow("normal") << QDate(2004, 6, 16)
+ << QDateTime(QDate(2004, 6, 16), QTime(0, 0, 0, 0))
+ << QDate(1752, 9, 14) << QTime(0, 0, 0, 0)
+ << QDate(7999, 12, 31) << QTime(23, 59, 59, 999);
+
+ QTest::newRow("invalid") << QDate(9999, 99, 99)
+ << QDateTime(QDate(2000, 1, 1), QTime(0, 0, 0, 0))
+ << QDate(1752, 9, 14) << QTime(0, 0, 0, 0)
+ << QDate(7999, 12, 31) << QTime(23, 59, 59, 999);
+}
+
+
+
+void tst_QDateTimeEdit::constructor_qdate()
+{
+ QFETCH(QDate, parameter);
+ QFETCH(QDateTime, displayDateTime);
+ QFETCH(QDate, minimumDate);
+ QFETCH(QTime, minimumTime);
+ QFETCH(QDate, maximumDate);
+ QFETCH(QTime, maximumTime);
+
+ testWidget->hide();
+
+ QDateTimeEdit dte(parameter);
+ dte.show();
+ QCOMPARE(dte.dateTime(), displayDateTime);
+ QCOMPARE(dte.minimumDate(), minimumDate);
+ QCOMPARE(dte.minimumTime(), minimumTime);
+ QCOMPARE(dte.maximumDate(), maximumDate);
+ QCOMPARE(dte.maximumTime(), maximumTime);
+}
+
+void tst_QDateTimeEdit::constructor_qtime_data()
+{
+ QTest::addColumn<QTime>("parameter");
+ QTest::addColumn<QDateTime>("displayDateTime");
+ QTest::addColumn<QDate>("minimumDate");
+ QTest::addColumn<QTime>("minimumTime");
+ QTest::addColumn<QDate>("maximumDate");
+ QTest::addColumn<QTime>("maximumTime");
+
+ QTest::newRow("normal") << QTime(13, 46, 32, 764)
+ << QDateTime(QDate(2000, 1, 1), QTime(13, 46, 32, 764))
+ << QDate(2000, 1, 1) << QTime(0, 0, 0, 0)
+ << QDate(2000, 1, 1) << QTime(23, 59, 59, 999);
+
+ QTest::newRow("invalid") << QTime(99, 99, 99, 5000)
+ << QDateTime(QDate(2000, 1, 1), QTime(0, 0, 0, 0))
+ << QDate(2000, 1, 1) << QTime(0, 0, 0, 0)
+ << QDate(2000, 1, 1) << QTime(23, 59, 59, 999);
+}
+
+
+
+void tst_QDateTimeEdit::constructor_qtime()
+{
+ QFETCH(QTime, parameter);
+ QFETCH(QDateTime, displayDateTime);
+ QFETCH(QDate, minimumDate);
+ QFETCH(QTime, minimumTime);
+ QFETCH(QDate, maximumDate);
+ QFETCH(QTime, maximumTime);
+
+ testWidget->hide();
+
+ QDateTimeEdit dte(parameter);
+ dte.show();
+ QCOMPARE(dte.dateTime(), displayDateTime);
+ QCOMPARE(dte.minimumDate(), minimumDate);
+ QCOMPARE(dte.minimumTime(), minimumTime);
+ QCOMPARE(dte.maximumDate(), maximumDate);
+ QCOMPARE(dte.maximumTime(), maximumTime);
+}
+
+void tst_QDateTimeEdit::minimumDate_data()
+{
+ QTest::addColumn<QDate>("minimumDate");
+ QTest::addColumn<QDate>("expectedMinDate");
+
+ QTest::newRow("normal-0") << QDate(2004, 5, 10) << QDate(2004, 5, 10);
+ QTest::newRow("normal-1") << QDate(2002, 3, 15) << QDate(2002, 3, 15);
+ QTest::newRow("normal-2") << QDate(7999, 12, 31) << QDate(7999, 12, 31);
+ QTest::newRow("normal-3") << QDate(1753, 1, 1) << QDate(1753, 1, 1);
+ QTest::newRow("invalid-0") << QDate(0, 0, 0) << QDate(1752, 9, 14);
+ QTest::newRow("old") << QDate(1492, 8, 3) << QDate(1492, 8, 3);
+}
+
+void tst_QDateTimeEdit::minimumDate()
+{
+ QFETCH(QDate, minimumDate);
+ QFETCH(QDate, expectedMinDate);
+
+ testWidget->setMinimumDate(minimumDate);
+ QCOMPARE(testWidget->minimumDate(), expectedMinDate);
+}
+
+void tst_QDateTimeEdit::minimumDateTime_data()
+{
+ QTest::addColumn<QDateTime>("minimumDateTime");
+ QTest::addColumn<QDateTime>("expectedMinDateTime");
+
+ QTest::newRow("normal-0") << QDateTime(QDate(2004, 5, 10), QTime(2, 3, 14))
+ << QDateTime(QDate(2004, 5, 10), QTime(2, 3, 14));
+
+ QTest::newRow("normal-1") << QDateTime(QDate(2005, 5, 10), QTime(22, 33, 1))
+ << QDateTime(QDate(2005, 5, 10), QTime(22, 33, 1));
+ QTest::newRow("normal-2") << QDateTime(QDate(2006, 5, 10), QTime(13, 31, 23))
+ << QDateTime(QDate(2006, 5, 10), QTime(13, 31, 23));
+ QTest::newRow("normal-3") << QDateTime(QDate(2007, 5, 10), QTime(22, 23, 23))
+ << QDateTime(QDate(2007, 5, 10), QTime(22, 23, 23));
+ QTest::newRow("normal-4") << QDateTime(QDate(2008, 5, 10), QTime(2, 3, 1))
+ << QDateTime(QDate(2008, 5, 10), QTime(2, 3, 1));
+ QTest::newRow("invalid-0") << QDateTime() << QDateTime(QDate(1752, 9, 14), QTime(0, 0, 0));
+ QTest::newRow("old") << QDateTime(QDate(1492, 8, 3), QTime(2, 3, 1))
+ << QDateTime(QDate(1492, 8, 3), QTime(2, 3, 1));
+}
+
+void tst_QDateTimeEdit::minimumDateTime()
+{
+ QFETCH(QDateTime, minimumDateTime);
+ QFETCH(QDateTime, expectedMinDateTime);
+
+ testWidget->setMinimumDateTime(minimumDateTime);
+ QCOMPARE(testWidget->minimumDateTime(), expectedMinDateTime);
+}
+
+
+void tst_QDateTimeEdit::maximumDateTime_data()
+{
+ QTest::addColumn<QDateTime>("maximumDateTime");
+ QTest::addColumn<QDateTime>("expectedMinDateTime");
+
+ QTest::newRow("normal-0") << QDateTime(QDate(2004, 5, 10), QTime(2, 3, 14))
+ << QDateTime(QDate(2004, 5, 10), QTime(2, 3, 14));
+
+ QTest::newRow("normal-1") << QDateTime(QDate(2005, 5, 10), QTime(22, 33, 1))
+ << QDateTime(QDate(2005, 5, 10), QTime(22, 33, 1));
+ QTest::newRow("normal-2") << QDateTime(QDate(2006, 5, 10), QTime(13, 31, 23))
+ << QDateTime(QDate(2006, 5, 10), QTime(13, 31, 23));
+ QTest::newRow("normal-3") << QDateTime(QDate(2007, 5, 10), QTime(22, 23, 23))
+ << QDateTime(QDate(2007, 5, 10), QTime(22, 23, 23));
+ QTest::newRow("normal-4") << QDateTime(QDate(2008, 5, 10), QTime(2, 3, 1))
+ << QDateTime(QDate(2008, 5, 10), QTime(2, 3, 1));
+ QTest::newRow("invalid-0") << QDateTime() << QDateTime(QDate(7999, 12, 31), QTime(23, 59, 59, 999));
+}
+
+void tst_QDateTimeEdit::maximumDateTime()
+{
+ QFETCH(QDateTime, maximumDateTime);
+ QFETCH(QDateTime, expectedMinDateTime);
+
+ testWidget->setMaximumDateTime(maximumDateTime);
+ QCOMPARE(testWidget->maximumDateTime(), expectedMinDateTime);
+}
+
+void tst_QDateTimeEdit::maximumDate_data()
+{
+ QTest::addColumn<QDate>("maximumDate");
+ QTest::addColumn<QDate>("expectedMaxDate");
+
+ QTest::newRow("normal-0") << QDate(2004, 05, 10) << QDate(2004, 5, 10);
+ QTest::newRow("normal-1") << QDate(2002, 03, 15) << QDate(2002, 3, 15);
+ QTest::newRow("normal-2") << QDate(7999, 12, 31) << QDate(7999, 12, 31);
+ QTest::newRow("normal-3") << QDate(1753, 1, 1) << QDate(1753, 1, 1);
+ QTest::newRow("invalid-0") << QDate(0, 0, 0) << QDate(7999, 12, 31);
+}
+
+void tst_QDateTimeEdit::maximumDate()
+{
+ QFETCH(QDate, maximumDate);
+ QFETCH(QDate, expectedMaxDate);
+
+ testWidget->setMaximumDate(maximumDate);
+ QCOMPARE(testWidget->maximumDate(), expectedMaxDate);
+}
+
+void tst_QDateTimeEdit::clearMinimumDate_data()
+{
+ QTest::addColumn<QDate>("minimumDate");
+ QTest::addColumn<bool>("valid");
+ QTest::addColumn<QDate>("expectedMinDateAfterClear");
+
+ QTest::newRow("normal-0") << QDate(2004, 05, 10) << true << QDate(1752, 9, 14);
+ QTest::newRow("normal-1") << QDate(2002, 3, 15) << true << QDate(1752, 9, 14);
+ QTest::newRow("normal-2") << QDate(7999, 12, 31) << true << QDate(1752, 9, 14);
+ QTest::newRow("normal-3") << QDate(1753, 1, 1) << true << QDate(1752, 9, 14);
+ QTest::newRow("invalid-0") << QDate(0, 0, 0) << false << QDate(1752, 9, 14);
+}
+
+void tst_QDateTimeEdit::clearMinimumDate()
+{
+ QFETCH(QDate, minimumDate);
+ QFETCH(bool, valid);
+ QFETCH(QDate, expectedMinDateAfterClear);
+
+ testWidget->setMinimumDate(minimumDate);
+ if (valid) {
+ QCOMPARE(testWidget->minimumDate(), minimumDate);
+ }
+ testWidget->clearMinimumDate();
+ QCOMPARE(testWidget->minimumDate(), expectedMinDateAfterClear);
+}
+
+void tst_QDateTimeEdit::clearMinimumDateTime_data()
+{
+ QTest::addColumn<QDateTime>("minimumDateTime");
+ QTest::addColumn<bool>("valid");
+ QTest::addColumn<QDateTime>("expectedMinDateTimeAfterClear");
+
+ QTest::newRow("normal-0") << QDateTime(QDate(2004, 05, 10), QTime(12, 12, 12))
+ << true << QDateTime(QDate(1752, 9, 14), QTime(0, 0));
+ QTest::newRow("normal-1") << QDateTime(QDate(2002, 3, 15), QTime(13, 13, 13))
+ << true << QDateTime(QDate(1752, 9, 14), QTime(0, 0));
+ QTest::newRow("normal-2") << QDateTime(QDate(7999, 12, 31), QTime(14, 14, 14))
+ << true << QDateTime(QDate(1752, 9, 14), QTime(0, 0));
+ QTest::newRow("normal-3") << QDateTime(QDate(1753, 1, 1), QTime(15, 15, 15))
+ << true << QDateTime(QDate(1752, 9, 14), QTime(0, 0));
+ QTest::newRow("invalid-0") << QDateTime() << false << QDateTime(QDate(1752, 9, 14), QTime(0, 0));
+ QTest::newRow("old") << QDateTime(QDate(1492, 8, 3), QTime(2, 3, 1)) << true
+ << QDateTime(QDate(1752, 9, 14), QTime(0, 0));
+
+}
+
+void tst_QDateTimeEdit::clearMinimumDateTime()
+{
+ QFETCH(QDateTime, minimumDateTime);
+ QFETCH(bool, valid);
+ QFETCH(QDateTime, expectedMinDateTimeAfterClear);
+
+ testWidget->setMinimumDateTime(minimumDateTime);
+ if (valid) {
+ QCOMPARE(testWidget->minimumDateTime(), minimumDateTime);
+ }
+ testWidget->clearMinimumDateTime();
+ QCOMPARE(testWidget->minimumDateTime(), expectedMinDateTimeAfterClear);
+}
+
+
+void tst_QDateTimeEdit::clearMaximumDateTime_data()
+{
+ QTest::addColumn<QDateTime>("maximumDateTime");
+ QTest::addColumn<bool>("valid");
+ QTest::addColumn<QDateTime>("expectedMinDateTimeAfterClear");
+
+ QTest::newRow("normal-0") << QDateTime(QDate(2004, 05, 10), QTime(12, 12, 12))
+ << true << QDateTime(QDate(7999, 12, 31), QTime(23, 59, 59, 999));
+ QTest::newRow("normal-1") << QDateTime(QDate(2002, 3, 15), QTime(13, 13, 13))
+ << true << QDateTime(QDate(7999, 12, 31), QTime(23, 59, 59, 999));
+ QTest::newRow("normal-2") << QDateTime(QDate(7999, 12, 31), QTime(14, 14, 14))
+ << true << QDateTime(QDate(7999, 12, 31), QTime(23, 59, 59, 999));
+ QTest::newRow("normal-3") << QDateTime(QDate(1753, 1, 1), QTime(15, 15, 15))
+ << true << QDateTime(QDate(7999, 12, 31), QTime(23, 59, 59, 999));
+ QTest::newRow("invalid-0") << QDateTime()
+ << false << QDateTime(QDate(7999, 12, 31), QTime(23, 59, 59, 999));
+}
+
+void tst_QDateTimeEdit::clearMaximumDateTime()
+{
+ QFETCH(QDateTime, maximumDateTime);
+ QFETCH(bool, valid);
+ QFETCH(QDateTime, expectedMinDateTimeAfterClear);
+
+ testWidget->setMaximumDateTime(maximumDateTime);
+ if (valid) {
+ QCOMPARE(testWidget->maximumDateTime(), maximumDateTime);
+ }
+ testWidget->clearMaximumDateTime();
+ QCOMPARE(testWidget->maximumDateTime(), expectedMinDateTimeAfterClear);
+}
+
+
+void tst_QDateTimeEdit::clearMaximumDate_data()
+{
+ QTest::addColumn<QDate>("maximumDate");
+ QTest::addColumn<bool>("valid");
+ QTest::addColumn<QDate>("expectedMaxDateAfterClear");
+
+ QTest::newRow("normal-0") << QDate(2004, 05, 10) << true << QDate(7999, 12, 31);
+ QTest::newRow("normal-1") << QDate(2002, 03, 15) << true << QDate(7999, 12, 31);
+ QTest::newRow("normal-2") << QDate(7999, 12, 31) << true << QDate(7999, 12, 31);
+ QTest::newRow("normal-3") << QDate(2000, 1, 1) << true << QDate(7999, 12, 31);
+ QTest::newRow("invalid-0") << QDate(0, 0, 0) << false << QDate(7999, 12, 31);
+}
+
+void tst_QDateTimeEdit::clearMaximumDate()
+{
+ QFETCH(QDate, maximumDate);
+ QFETCH(bool, valid);
+ QFETCH(QDate, expectedMaxDateAfterClear);
+
+ testWidget->setMaximumDate(maximumDate);
+ if (valid) {
+ QCOMPARE(testWidget->maximumDate(), maximumDate);
+ }
+ testWidget->clearMaximumDate();
+ QCOMPARE(testWidget->maximumDate(), expectedMaxDateAfterClear);
+}
+
+void tst_QDateTimeEdit::displayFormat_data()
+{
+ QTest::addColumn<QString>("format");
+ QTest::addColumn<bool>("valid");
+ QTest::addColumn<QString>("text");
+ QTest::addColumn<QDateTime>("date");
+
+ const QDateTime dt(QDate(2999, 12, 31), QTime(3, 59, 59, 999));
+
+ QTest::newRow("valid-0") << QString("yyyy MM dd") << true << QString("2999 12 31") << dt;
+ QTest::newRow("valid-1") << QString("dd MM yyyy::ss:mm:hh") << true
+ << QString("31 12 2999::59:59:03") << dt;
+ QTest::newRow("valid-2") << QString("hh-dd-mm-MM-yy") << true << QString("03-31-59-12-99") << dt;
+ QTest::newRow("valid-3") << QString("ddd MM d yyyy::ss:mm:hh") << true
+ << QDate::shortDayName(2) + " 12 31 2999::59:59:03" << dt;
+ QTest::newRow("valid-4") << QString("hh-dd-mm-MM-yyyy") << true << QString("03-31-59-12-2999") << dt;
+ QTest::newRow("invalid-0") << QString("yyyy.MM.yy") << true << QString("2999.12.99") << dt;
+ QTest::newRow("invalid-1") << QString("y") << false << QString() << dt;
+ QTest::newRow("invalid-2") << QString("") << false << QString() << dt;
+ QTest::newRow("quoted-1") << QString("'Midday is at:' dd") << true << QString("Midday is at: 31") << dt;
+ QTest::newRow("leading1") << QString("h:hh:hhh") << true << QString("3:03:033") << dt;
+ QTest::newRow("H1") << QString("HH:hh:ap") << true << QString("03:03:am") << dt;
+ QTest::newRow("H2") << QString("HH:hh:ap") << true << QString("23:11:pm")
+ << QDateTime(dt.date(), QTime(23, 0, 0));
+}
+
+void tst_QDateTimeEdit::displayFormat()
+{
+ QFETCH(QString, format);
+ QFETCH(bool, valid);
+ QFETCH(QString, text);
+ QFETCH(QDateTime, date);
+
+ testWidget->setDateTime(date);
+
+ QString compareFormat = format;
+ if (!valid)
+ compareFormat = testWidget->displayFormat();
+ testWidget->setDisplayFormat(format);
+ QCOMPARE(testWidget->displayFormat(), compareFormat);
+ if (valid)
+ QCOMPARE(testWidget->text(), text);
+}
+
+void tst_QDateTimeEdit::selectAndScrollWithKeys()
+{
+ qApp->setActiveWindow(testWidget);
+ testWidget->setDate(QDate(2004, 05, 11));
+ testWidget->setDisplayFormat("dd/MM/yyyy");
+ testWidget->show();
+#ifdef Q_WS_MAC
+ QTest::keyClick(testWidget, Qt::Key_Left, Qt::ControlModifier);
+#else
+ QTest::keyClick(testWidget, Qt::Key_Home);
+#endif
+ QTest::keyClick(testWidget, Qt::Key_Right, Qt::ShiftModifier);
+ QCOMPARE(testWidget->lineEdit()->selectedText(), QString("1"));
+ QTest::keyClick(testWidget, Qt::Key_Right, Qt::ShiftModifier);
+ QCOMPARE(testWidget->lineEdit()->selectedText(), QString("11"));
+ QTest::keyClick(testWidget, Qt::Key_Right, Qt::ShiftModifier);
+ QCOMPARE(testWidget->lineEdit()->selectedText(), QString("11/"));
+ QTest::keyClick(testWidget, Qt::Key_Right, Qt::ShiftModifier);
+ QCOMPARE(testWidget->lineEdit()->selectedText(), QString("11/0"));
+ QTest::keyClick(testWidget, Qt::Key_Right, Qt::ShiftModifier);
+ QCOMPARE(testWidget->lineEdit()->selectedText(), QString("11/05"));
+ QTest::keyClick(testWidget, Qt::Key_Right, Qt::ShiftModifier);
+ QCOMPARE(testWidget->lineEdit()->selectedText(), QString("11/05/"));
+ QTest::keyClick(testWidget, Qt::Key_Right, Qt::ShiftModifier);
+ QCOMPARE(testWidget->lineEdit()->selectedText(), QString("11/05/2"));
+ QTest::keyClick(testWidget, Qt::Key_Right, Qt::ShiftModifier);
+ QCOMPARE(testWidget->lineEdit()->selectedText(), QString("11/05/20"));
+ QTest::keyClick(testWidget, Qt::Key_Right, Qt::ShiftModifier);
+ QCOMPARE(testWidget->lineEdit()->selectedText(), QString("11/05/200"));
+ QTest::keyClick(testWidget, Qt::Key_Right, Qt::ShiftModifier);
+ QCOMPARE(testWidget->lineEdit()->selectedText(), QString("11/05/2004"));
+ QTest::keyClick(testWidget, Qt::Key_Right, Qt::ShiftModifier);
+ QCOMPARE(testWidget->lineEdit()->selectedText(), QString("11/05/2004"));
+
+ // Now the year part should be selected
+ QTest::keyClick(testWidget, Qt::Key_Up);
+ QCOMPARE(testWidget->date(), QDate(2005, 5, 11));
+ QCOMPARE(testWidget->currentSection(), QDateTimeEdit::YearSection);
+ QCOMPARE(testWidget->lineEdit()->selectedText(), QString("2005"));
+ QTest::keyClick(testWidget, Qt::Key_Down);
+ QCOMPARE(testWidget->date(), QDate(2004, 5, 11));
+ QCOMPARE(testWidget->currentSection(), QDateTimeEdit::YearSection);
+ QCOMPARE(testWidget->lineEdit()->selectedText(), QString("2004"));
+
+
+#ifdef Q_WS_MAC
+ QTest::keyClick(testWidget, Qt::Key_Right, Qt::ControlModifier);
+#else
+ QTest::keyClick(testWidget, Qt::Key_End);
+#endif
+ QTest::keyClick(testWidget, Qt::Key_Left, Qt::ShiftModifier);
+ QCOMPARE(testWidget->lineEdit()->selectedText(), QString("4"));
+ QTest::keyClick(testWidget, Qt::Key_Left, Qt::ShiftModifier);
+ QCOMPARE(testWidget->lineEdit()->selectedText(), QString("04"));
+ QTest::keyClick(testWidget, Qt::Key_Left, Qt::ShiftModifier);
+ QCOMPARE(testWidget->lineEdit()->selectedText(), QString("004"));
+ QTest::keyClick(testWidget, Qt::Key_Left, Qt::ShiftModifier);
+ QCOMPARE(testWidget->lineEdit()->selectedText(), QString("2004"));
+ QTest::keyClick(testWidget, Qt::Key_Left, Qt::ShiftModifier);
+ QCOMPARE(testWidget->lineEdit()->selectedText(), QString("/2004"));
+ QTest::keyClick(testWidget, Qt::Key_Left, Qt::ShiftModifier);
+ QCOMPARE(testWidget->lineEdit()->selectedText(), QString("5/2004"));
+ QTest::keyClick(testWidget, Qt::Key_Left, Qt::ShiftModifier);
+ QCOMPARE(testWidget->lineEdit()->selectedText(), QString("05/2004"));
+ QTest::keyClick(testWidget, Qt::Key_Left, Qt::ShiftModifier);
+ QCOMPARE(testWidget->lineEdit()->selectedText(), QString("/05/2004"));
+ QTest::keyClick(testWidget, Qt::Key_Left, Qt::ShiftModifier);
+ QCOMPARE(testWidget->lineEdit()->selectedText(), QString("1/05/2004"));
+ QTest::keyClick(testWidget, Qt::Key_Left, Qt::ShiftModifier);
+ QCOMPARE(testWidget->lineEdit()->selectedText(), QString("11/05/2004"));
+ QTest::keyClick(testWidget, Qt::Key_Left, Qt::ShiftModifier);
+ QCOMPARE(testWidget->lineEdit()->selectedText(), QString("11/05/2004"));
+#ifdef Q_WS_MAC
+ QTest::keyClick(testWidget, Qt::Key_Left, Qt::ControlModifier);
+#else
+ QTest::keyClick(testWidget, Qt::Key_Home);
+#endif
+
+ // Now the day part should be selected
+ QTest::keyClick(testWidget, Qt::Key_Up);
+ QCOMPARE(testWidget->date(), QDate(2004, 5, 12));
+ QCOMPARE(testWidget->currentSection(), QDateTimeEdit::DaySection);
+ QCOMPARE(testWidget->lineEdit()->selectedText(), QString("12"));
+ QTest::keyClick(testWidget, Qt::Key_Down);
+ QCOMPARE(testWidget->date(), QDate(2004, 5, 11));
+ QCOMPARE(testWidget->currentSection(), QDateTimeEdit::DaySection);
+ QCOMPARE(testWidget->lineEdit()->selectedText(), QString("11"));
+
+#ifdef Q_WS_MAC
+ QTest::keyClick(testWidget, Qt::Key_Left, Qt::ControlModifier);
+#else
+ QTest::keyClick(testWidget, Qt::Key_Home);
+#endif
+
+ QTest::keyClick(testWidget, Qt::Key_Right, Qt::ShiftModifier);
+ QTest::keyClick(testWidget, Qt::Key_Right, Qt::ShiftModifier);
+ QCOMPARE(testWidget->lineEdit()->selectedText(), QString("11"));
+ // Now the day part should be selected
+ QTest::keyClick(testWidget, Qt::Key_Up);
+ QCOMPARE(testWidget->date(), QDate(2004, 05, 12));
+}
+
+void tst_QDateTimeEdit::backspaceKey()
+{
+ qApp->setActiveWindow(testWidget);
+ testWidget->setDate(QDate(2004, 05, 11));
+ testWidget->setDisplayFormat("d/MM/yyyy");
+ testWidget->show();
+#ifdef Q_WS_MAC
+ QTest::keyClick(testWidget, Qt::Key_Right, Qt::ControlModifier);
+#else
+ QTest::keyClick(testWidget, Qt::Key_End);
+#endif
+ QCOMPARE(testWidget->text(), QString("11/05/2004"));
+ QTest::keyClick(testWidget, Qt::Key_Backspace);
+ QCOMPARE(testWidget->text(), QString("11/05/200"));
+ QTest::keyClick(testWidget, Qt::Key_Backspace);
+ QCOMPARE(testWidget->text(), QString("11/05/20"));
+ // Check that moving into another field reverts it
+ for (int i=0;i<3;i++)
+ QTest::keyClick(testWidget, Qt::Key_Left);
+ QCOMPARE(testWidget->text(), QString("11/05/2004"));
+#ifdef Q_WS_MAC
+ QTest::keyClick(testWidget, Qt::Key_Right, Qt::ControlModifier);
+#else
+ QTest::keyClick(testWidget, Qt::Key_End);
+#endif
+ for (int i=0;i<4;i++) {
+ QTest::keyClick(testWidget, Qt::Key_Left, Qt::ShiftModifier);
+ }
+
+ QTest::keyClick(testWidget, Qt::Key_Backspace);
+ QCOMPARE(testWidget->text(), QString("11/05/"));
+ QTest::keyClick(testWidget, Qt::Key_Left);
+ QTest::keyClick(testWidget, Qt::Key_Backspace);
+ QCOMPARE(testWidget->text(), QString("11/0/2004"));
+ testWidget->interpretText();
+#ifdef Q_WS_MAC
+ QTest::keyClick(testWidget, Qt::Key_Right, Qt::ControlModifier);
+#else
+ QTest::keyClick(testWidget, Qt::Key_End);
+#endif
+ QTest::keyClick(testWidget, Qt::Key_Backspace);
+ QCOMPARE(testWidget->text(), QString("11/05/200"));
+ QTest::keyClick(testWidget, Qt::Key_Backspace);
+ QCOMPARE(testWidget->text(), QString("11/05/20"));
+ QTest::keyClick(testWidget, Qt::Key_Backspace);
+ QCOMPARE(testWidget->text(), QString("11/05/2"));
+ QTest::keyClick(testWidget, Qt::Key_Backspace);
+ QCOMPARE(testWidget->text(), QString("11/05/"));
+ QTest::keyClick(testWidget, Qt::Key_Left);
+ QTest::keyClick(testWidget, Qt::Key_Backspace);
+ QCOMPARE(testWidget->text(), QString("11/0/2004"));
+ QTest::keyClick(testWidget, Qt::Key_Backspace);
+ QCOMPARE(testWidget->text(), QString("11//2004"));
+ QTest::keyClick(testWidget, Qt::Key_Left);
+ QTest::keyClick(testWidget, Qt::Key_Backspace);
+ QCOMPARE(testWidget->text(), QString("1/05/2004"));
+ QTest::keyClick(testWidget, Qt::Key_Backspace);
+ QCOMPARE(testWidget->text(), QString("/05/2004"));
+ QTest::keyClick(testWidget, Qt::Key_Backspace);
+ QCOMPARE(testWidget->text(), QString("/05/2004"));
+ QTest::keyClick(testWidget, Qt::Key_Enter);
+ QCOMPARE(testWidget->text(), QString("1/05/2004"));
+}
+
+void tst_QDateTimeEdit::deleteKey()
+{
+ qApp->setActiveWindow(testWidget);
+ testWidget->setDate(QDate(2004, 05, 11));
+ testWidget->setDisplayFormat("d/MM/yyyy");
+#ifdef Q_WS_MAC
+ QTest::keyClick(testWidget, Qt::Key_Left, Qt::ControlModifier);
+#else
+ QTest::keyClick(testWidget, Qt::Key_Home);
+#endif
+ QTest::keyClick(testWidget, Qt::Key_Delete);
+ QCOMPARE(testWidget->text(), QString("1/05/2004"));
+ QTest::keyClick(testWidget, Qt::Key_Delete);
+ QCOMPARE(testWidget->text(), QString("/05/2004"));
+ QTest::keyClick(testWidget, Qt::Key_Right);
+ QTest::keyClick(testWidget, Qt::Key_Right);
+ QCOMPARE(testWidget->text(), QString("1/05/2004"));
+}
+
+void tst_QDateTimeEdit::tabKeyNavigation()
+{
+ qApp->setActiveWindow(testWidget);
+ testWidget->setDate(QDate(2004, 05, 11));
+ testWidget->setDisplayFormat("dd/MM/yyyy");
+ testWidget->show();
+ testWidget->setCurrentSection(QDateTimeEdit::DaySection);
+
+ QTest::keyClick(testWidget, Qt::Key_Tab);
+ QCOMPARE(testWidget->lineEdit()->selectedText(), QString("05"));
+ QTest::keyClick(testWidget, Qt::Key_Tab);
+ QCOMPARE(testWidget->lineEdit()->selectedText(), QString("2004"));
+ QTest::keyClick(testWidget, Qt::Key_Tab, Qt::ShiftModifier);
+ QCOMPARE(testWidget->lineEdit()->selectedText(), QString("05"));
+ QTest::keyClick(testWidget, Qt::Key_Tab, Qt::ShiftModifier);
+ QCOMPARE(testWidget->lineEdit()->selectedText(), QString("11"));
+}
+
+void tst_QDateTimeEdit::tabKeyNavigationWithPrefix()
+{
+ qApp->setActiveWindow(testWidget);
+ testWidget->setDate(QDate(2004, 05, 11));
+ testWidget->setDisplayFormat("prefix dd/MM/yyyy");
+
+ QTest::keyClick(testWidget, Qt::Key_Tab);
+ QCOMPARE(testWidget->lineEdit()->selectedText(), QString("11"));
+ QTest::keyClick(testWidget, Qt::Key_Tab);
+ QCOMPARE(testWidget->lineEdit()->selectedText(), QString("05"));
+ QTest::keyClick(testWidget, Qt::Key_Tab);
+ QCOMPARE(testWidget->lineEdit()->selectedText(), QString("2004"));
+ QTest::keyClick(testWidget, Qt::Key_Tab, Qt::ShiftModifier);
+ QCOMPARE(testWidget->lineEdit()->selectedText(), QString("05"));
+ QTest::keyClick(testWidget, Qt::Key_Tab, Qt::ShiftModifier);
+ QCOMPARE(testWidget->lineEdit()->selectedText(), QString("11"));
+}
+
+void tst_QDateTimeEdit::tabKeyNavigationWithSuffix()
+{
+ qApp->setActiveWindow(testWidget);
+ testWidget->setDate(QDate(2004, 05, 11));
+ testWidget->setDisplayFormat("dd/MM/yyyy 'suffix'");
+
+ QTest::keyClick(testWidget, Qt::Key_Tab);
+ QCOMPARE(testWidget->lineEdit()->selectedText(), QString("05"));
+ QTest::keyClick(testWidget, Qt::Key_Tab);
+ QCOMPARE(testWidget->lineEdit()->selectedText(), QString("2004"));
+ QTest::keyClick(testWidget, Qt::Key_Tab, Qt::ShiftModifier);
+ QCOMPARE(testWidget->lineEdit()->selectedText(), QString("05"));
+ QTest::keyClick(testWidget, Qt::Key_Tab, Qt::ShiftModifier);
+ QCOMPARE(testWidget->lineEdit()->selectedText(), QString("11"));
+}
+
+
+void tst_QDateTimeEdit::enterKey()
+{
+ qApp->setActiveWindow(testWidget);
+ testWidget->setDate(QDate(2004, 5, 11));
+ testWidget->setDisplayFormat("prefix d/MM/yyyy 'suffix'");
+ testWidget->lineEdit()->setFocus();
+
+#ifdef Q_WS_MAC
+ QTest::keyClick(testWidget, Qt::Key_Left, Qt::ControlModifier);
+#else
+ QTest::keyClick(testWidget, Qt::Key_Home);
+#endif
+ QTest::keyClick(testWidget, Qt::Key_Enter);
+ QVERIFY(!testWidget->lineEdit()->hasSelectedText());
+#ifdef Q_WS_MAC
+ QTest::keyClick(testWidget, Qt::Key_Right, Qt::ControlModifier);
+#else
+ QTest::keyClick(testWidget, Qt::Key_End);
+#endif
+ QTest::keyClick(testWidget, Qt::Key_Enter);
+ QVERIFY(!testWidget->lineEdit()->hasSelectedText());
+#ifdef Q_WS_MAC
+ QTest::keyClick(testWidget, Qt::Key_Left, Qt::ControlModifier);
+#else
+ QTest::keyClick(testWidget, Qt::Key_Home);
+#endif
+ QTest::keyClick(testWidget, Qt::Key_Tab);
+ QTest::keyClick(testWidget, Qt::Key_Enter);
+ QCOMPARE(testWidget->lineEdit()->selectedText(), QString("11"));
+ QTest::keyClick(testWidget, Qt::Key_1);
+ QTest::keyClick(testWidget, Qt::Key_5);
+
+ QTest::keyClick(testWidget, Qt::Key_Left);
+ QTest::keyClick(testWidget, Qt::Key_Left);
+
+ QTest::keyClick(testWidget, Qt::Key_Enter);
+ QCOMPARE(testWidget->lineEdit()->selectedText(), QString("15"));
+ QCOMPARE(testWidget->date(), QDate(2004, 5, 15));
+
+ QTest::keyClick(testWidget, Qt::Key_9);
+ QTest::keyClick(testWidget, Qt::Key_Tab, Qt::ShiftModifier);
+ QTest::keyClick(testWidget, Qt::Key_Enter);
+ QCOMPARE(testWidget->lineEdit()->selectedText(), QString("9"));
+ QCOMPARE(testWidget->date(), QDate(2004, 5, 9));
+
+ QTest::keyClick(testWidget, Qt::Key_0);
+ QTest::keyClick(testWidget, Qt::Key_0);
+ QTest::keyClick(testWidget, Qt::Key_Enter);
+ QCOMPARE(testWidget->lineEdit()->selectedText(), QString("9"));
+ QCOMPARE(testWidget->date(), QDate(2004, 5, 9));
+
+ QSignalSpy enterSpy(testWidget, SIGNAL(dateChanged(const QDate &)));
+ QTest::keyClick(testWidget, Qt::Key_Enter);
+ QCOMPARE(enterSpy.count(), 1);
+
+#if 0
+ QVariantList list = enterSpy.takeFirst();
+ QCOMPARE(list.at(0).toDate(), QDate(2004, 9, 15));
+#endif
+
+}
+
+void tst_QDateTimeEdit::specialValueText()
+{
+ testWidget->setDisplayFormat("dd/MM/yyyy");
+ testWidget->setDateRange(QDate(2000, 1, 1), QDate(2001, 1, 1));
+ testWidget->setDate(QDate(2000, 1, 2));
+ testWidget->setSpecialValueText("fOo");
+ testWidget->setCurrentSection(QDateTimeEdit::DaySection);
+ QCOMPARE(testWidget->date(), QDate(2000, 1, 2));
+ QCOMPARE(testWidget->text(), QString("02/01/2000"));
+ QTest::keyClick(testWidget, Qt::Key_Down);
+ QCOMPARE(testWidget->date(), QDate(2000, 1, 1));
+ QCOMPARE(testWidget->text(), QString("fOo"));
+ QTest::keyClick(testWidget, Qt::Key_Down);
+ QCOMPARE(testWidget->date(), QDate(2000, 1, 1));
+ QCOMPARE(testWidget->text(), QString("fOo"));
+ QTest::keyClick(testWidget, Qt::Key_Up);
+ QCOMPARE(testWidget->date(), QDate(2000, 1, 2));
+ QCOMPARE(testWidget->text(), QString("02/01/2000"));
+ QTest::keyClick(testWidget, Qt::Key_Down);
+ QCOMPARE(testWidget->date(), QDate(2000, 1, 1));
+ QCOMPARE(testWidget->text(), QString("fOo"));
+
+#ifdef Q_WS_MAC
+ QTest::keyClick(testWidget, Qt::Key_Right, Qt::ControlModifier);
+#else
+ QTest::keyClick(testWidget, Qt::Key_End);
+#endif
+ QTest::keyClick(testWidget, Qt::Key_Up);
+ QCOMPARE(testWidget->date(), QDate(2000, 1, 2));
+ QCOMPARE(testWidget->text(), QString("02/01/2000"));
+ QTest::keyClick(testWidget, Qt::Key_Down);
+ QCOMPARE(testWidget->text(), QString("fOo"));
+
+#ifdef Q_WS_MAC
+ QTest::keyClick(testWidget, Qt::Key_Right, Qt::ControlModifier);
+#else
+ QTest::keyClick(testWidget, Qt::Key_End);
+#endif
+ QTest::keyClick(testWidget, Qt::Key_Backspace);
+ QCOMPARE(testWidget->text(), QString("fO"));
+ QTest::keyClick(testWidget, Qt::Key_Backspace);
+ QCOMPARE(testWidget->text(), QString("f"));
+ QTest::keyClick(testWidget, Qt::Key_Backspace);
+ QCOMPARE(testWidget->text(), QString());
+ QTest::keyClick(testWidget, Qt::Key_F);
+ QCOMPARE(testWidget->text(), QString("f"));
+ QTest::keyClick(testWidget, Qt::Key_O); // will automatically uppercase
+ QCOMPARE(testWidget->text(), QString("fO"));
+ QTest::keyClick(testWidget, Qt::Key_O);
+ QCOMPARE(testWidget->text(), QString("fOo"));
+}
+
+
+void tst_QDateTimeEdit::setRange_data()
+{
+ QTest::addColumn<QTime>("minTime");
+ QTest::addColumn<QTime>("maxTime");
+ QTest::addColumn<QDate>("minDate");
+ QTest::addColumn<QDate>("maxDate");
+ QTest::addColumn<QDateTime>("expectedMin");
+ QTest::addColumn<QDateTime>("expectedMax");
+
+ const QDate cdt = QDate::currentDate();
+
+ QTest::newRow("data0") << QTime(0, 0) << QTime(14, 12, 0)
+ << cdt << cdt
+ << QDateTime(cdt, QTime(0, 0))
+ << QDateTime(cdt, QTime(14, 12, 0));
+
+ QTest::newRow("data1") << QTime(10, 0) << QTime(1, 12, 0) << cdt.addDays(-1)
+ << cdt
+ << QDateTime(cdt.addDays(-1), QTime(10, 0))
+ << QDateTime(cdt, QTime(1, 12, 0));
+}
+
+void tst_QDateTimeEdit::setRange()
+{
+ QFETCH(QTime, minTime);
+ QFETCH(QTime, maxTime);
+ QFETCH(QDate, minDate);
+ QFETCH(QDate, maxDate);
+ QFETCH(QDateTime, expectedMin);
+ QFETCH(QDateTime, expectedMax);
+ testWidget->hide();
+
+ {
+ QDateTimeEdit dte(0);
+ dte.setTimeRange(minTime, maxTime);
+ QCOMPARE(dte.minimumTime(), expectedMin.time());
+ QCOMPARE(dte.maximumTime(), expectedMax.time());
+ dte.setDateRange(minDate, maxDate);
+ QCOMPARE(dte.minimumDate(), expectedMin.date());
+ QCOMPARE(dte.minimumDateTime(), expectedMin);
+ QCOMPARE(dte.maximumDate(), expectedMax.date());
+ QCOMPARE(dte.maximumDateTime(), expectedMax);
+ QCOMPARE(dte.minimumTime(), expectedMin.time());
+ QCOMPARE(dte.maximumTime(), expectedMax.time());
+ dte.setDateTimeRange(QDateTime(minDate, minTime), QDateTime(maxDate, maxTime));
+ QCOMPARE(dte.minimumDate(), expectedMin.date());
+ QCOMPARE(dte.minimumDateTime(), expectedMin);
+ QCOMPARE(dte.maximumDate(), expectedMax.date());
+ QCOMPARE(dte.maximumDateTime(), expectedMax);
+ QCOMPARE(dte.minimumTime(), expectedMin.time());
+ QCOMPARE(dte.maximumTime(), expectedMax.time());
+ }
+ {
+
+ QDateTimeEdit dte2(0);
+ dte2.setDateRange(minDate, maxDate);
+ dte2.setTimeRange(minTime, maxTime);
+
+ QCOMPARE(dte2.minimumDate(), expectedMin.date());
+ QCOMPARE(dte2.maximumDate(), expectedMax.date());
+ QCOMPARE(dte2.minimumTime(), expectedMin.time());
+ QCOMPARE(dte2.maximumTime(), expectedMax.time());
+ }
+
+ {
+ QDateTimeEdit dte3(0);
+ dte3.setMinimumTime(minTime);
+ dte3.setMaximumTime(maxTime);
+ dte3.setMinimumDate(minDate);
+ dte3.setMaximumDate(maxDate);
+
+ QCOMPARE(dte3.minimumDate(), expectedMin.date());
+ QCOMPARE(dte3.maximumDate(), expectedMax.date());
+ QCOMPARE(dte3.minimumTime(), expectedMin.time());
+ QCOMPARE(dte3.maximumTime(), expectedMax.time());
+ }
+
+ {
+ QDateTimeEdit dte4(0);
+ dte4.setMinimumDate(minDate);
+ dte4.setMaximumDate(maxDate);
+ dte4.setMinimumTime(minTime);
+ dte4.setMaximumTime(maxTime);
+
+ QCOMPARE(dte4.minimumDate(), expectedMin.date());
+ QCOMPARE(dte4.maximumDate(), expectedMax.date());
+ QCOMPARE(dte4.minimumTime(), expectedMin.time());
+ QCOMPARE(dte4.maximumTime(), expectedMax.time());
+ }
+}
+
+void tst_QDateTimeEdit::wrappingTime_data()
+{
+ QTest::addColumn<bool>("startWithMin");
+ QTest::addColumn<QTime>("minimumTime");
+ QTest::addColumn<QTime>("maximumTime");
+ QTest::addColumn<uint>("section");
+ QTest::addColumn<QTime>("newTime");
+
+ QTest::newRow("data0") << false << QTime(0,0,0) << QTime(2,2,2) << (uint)QDateTimeEdit::HourSection
+ << QTime(0,2,2);
+ QTest::newRow("data1") << true << QTime(0,0,0) << QTime(2,2,2) << (uint)QDateTimeEdit::HourSection
+ << QTime(2,0,0);
+ QTest::newRow("data2") << false << QTime(0,0,0) << QTime(2,2,2) << (uint)QDateTimeEdit::MinuteSection
+ << QTime(2,0,2);
+ QTest::newRow("data3") << true << QTime(0,0,0) << QTime(2,2,2) << (uint)QDateTimeEdit::MinuteSection
+ << QTime(0,59,0);
+ QTest::newRow("data4") << false << QTime(0,0,0) << QTime(2,2,2) << (uint)QDateTimeEdit::SecondSection
+ << QTime(2,2,0);
+ QTest::newRow("data5") << true << QTime(0,0,0) << QTime(2,2,2) << (uint)QDateTimeEdit::SecondSection
+ << QTime(0,0,59);
+ QTest::newRow("data6") << false << QTime(1,1,1) << QTime(22,22,22) << (uint)QDateTimeEdit::HourSection
+ << QTime(1,22,22);
+ QTest::newRow("data7") << true << QTime(1,1,1) << QTime(22,22,22) << (uint)QDateTimeEdit::HourSection
+ << QTime(22,1,1);
+ QTest::newRow("data8") << false << QTime(1,1,1) << QTime(22,22,22) << (uint)QDateTimeEdit::MinuteSection
+ << QTime(22,0,22);
+ QTest::newRow("data9") << true << QTime(1,1,1) << QTime(22,22,22) << (uint)QDateTimeEdit::MinuteSection
+ << QTime(1,59,1);
+ QTest::newRow("data10") << false << QTime(1,1,1) << QTime(22,22,22) << (uint)QDateTimeEdit::SecondSection
+ << QTime(22,22,0);
+ QTest::newRow("data11") << true << QTime(1,1,1) << QTime(22,22,22) << (uint)QDateTimeEdit::SecondSection
+ << QTime(1,1,59);
+ QTest::newRow("data12") << false << QTime(1,1,1) << QTime(1,2,1) << (uint)QDateTimeEdit::HourSection
+ << QTime(1,2,1);
+ QTest::newRow("data13") << true << QTime(1,1,1) << QTime(1,2,1) << (uint)QDateTimeEdit::HourSection
+ << QTime(1,1,1);
+ QTest::newRow("data14") << false << QTime(1,1,1) << QTime(1,2,1) << (uint)QDateTimeEdit::MinuteSection
+ << QTime(1,1,1);
+ QTest::newRow("data15") << true << QTime(1,1,1) << QTime(1,2,1) << (uint)QDateTimeEdit::MinuteSection
+ << QTime(1,2,1);
+ QTest::newRow("data16") << false << QTime(1,1,1) << QTime(1,2,1) << (uint)QDateTimeEdit::SecondSection
+ << QTime(1,2,0);
+ QTest::newRow("data17") << true << QTime(1,1,1) << QTime(1,2,1) << (uint)QDateTimeEdit::SecondSection
+ << QTime(1,1,59);
+}
+
+
+void tst_QDateTimeEdit::wrappingTime()
+{
+ QFETCH(bool, startWithMin);
+ QFETCH(QTime, minimumTime);
+ QFETCH(QTime, maximumTime);
+ QFETCH(uint, section);
+ QFETCH(QTime, newTime);
+
+ testWidget->setDisplayFormat("hh:mm:ss");
+ testWidget->setMinimumTime(minimumTime);
+ testWidget->setMaximumTime(maximumTime);
+ testWidget->setWrapping(true);
+ testWidget->setCurrentSection((QDateTimeEdit::Section)section);
+ if (startWithMin) {
+ testWidget->setTime(minimumTime);
+ QTest::keyClick(testWidget, Qt::Key_Down);
+ } else {
+ testWidget->setTime(maximumTime);
+ QTest::keyClick(testWidget, Qt::Key_Up);
+ }
+ QTest::keyClick(testWidget, Qt::Key_Enter);
+ QCOMPARE(testWidget->time(), newTime);
+}
+
+void tst_QDateTimeEdit::userKeyPress_Time_data()
+{
+ QTest::addColumn<bool>("ampm");
+ QTest::addColumn<QTestEventList>("keys");
+ QTest::addColumn<QTime>("expected_time");
+
+ // ***************** test the hours ***************
+
+ // use up/down keys to change hour in 12 h mode
+ {
+ QTestEventList keys;
+ keys.addKeyClick( Qt::Key_Down );
+ QTime expected( 10, 0, 0 );
+ QTest::newRow( "data0" ) << bool(true) << keys << expected;
+ }
+ {
+ QTestEventList keys;
+ for (uint i=0; i<5; i++)
+ keys.addKeyClick( Qt::Key_Down );
+ QTime expected( 6, 0, 0 );
+ QTest::newRow( "data1" ) << bool(true) << keys << expected;
+ }
+ {
+ QTestEventList keys;
+ for (uint i=0; i<10; i++)
+ keys.addKeyClick( Qt::Key_Down );
+ QTime expected( 1, 0, 0 );
+ QTest::newRow( "data2" ) << bool(true) << keys << expected;
+ }
+ {
+ QTestEventList keys;
+ for (uint i=0; i<12; i++)
+ keys.addKeyClick( Qt::Key_Down );
+ QTime expected( 23, 0, 0 );
+ QTest::newRow( "data3" ) << bool(true) << keys << expected;
+ }
+ {
+ QTestEventList keys;
+ keys.addKeyClick( Qt::Key_Up );
+ QTime expected( 12, 0, 0 );
+ QTest::newRow( "data4" ) << bool(true) << keys << expected;
+ }
+ {
+ QTestEventList keys;
+ for (uint i=0; i<2; i++)
+ keys.addKeyClick( Qt::Key_Up );
+ QTime expected( 13, 0, 0 );
+ QTest::newRow( "data5" ) << bool(true) << keys << expected;
+ }
+
+ // use up/down keys to change hour in 24 h mode
+ {
+ QTestEventList keys;
+ keys.addKeyClick( Qt::Key_Down );
+ QTime expected( 10, 0, 0 );
+ QTest::newRow( "data6" ) << bool(false) << keys << expected;
+ }
+ {
+ QTestEventList keys;
+ for (uint i=0; i<5; i++)
+ keys.addKeyClick( Qt::Key_Down );
+ QTime expected( 6, 0, 0 );
+ QTest::newRow( "data7" ) << bool(false) << keys << expected;
+ }
+ {
+ QTestEventList keys;
+ for (uint i=0; i<10; i++)
+ keys.addKeyClick( Qt::Key_Down );
+ QTime expected( 1, 0, 0 );
+ QTest::newRow( "data8" ) << bool(false) << keys << expected;
+ }
+ {
+ QTestEventList keys;
+ for (uint i=0; i<12; i++)
+ keys.addKeyClick( Qt::Key_Down );
+ QTime expected( 23, 0, 0 );
+ QTest::newRow( "data9" ) << bool(false) << keys << expected;
+ }
+ {
+ QTestEventList keys;
+ keys.addKeyClick( Qt::Key_Up );
+ QTime expected( 12, 0, 0 );
+ QTest::newRow( "data10" ) << bool(false) << keys << expected;
+ }
+ {
+ QTestEventList keys;
+ for (uint i=0; i<2; i++)
+ keys.addKeyClick( Qt::Key_Up );
+ QTime expected( 13, 0, 0 );
+ QTest::newRow( "data11" ) << bool(false) << keys << expected;
+ }
+
+ // enter a one digit valid hour
+ {
+ QTestEventList keys;
+ keys.addKeyClick( '5' );
+ QTime expected( 5, 0, 0 );
+ QTest::newRow( "data12" ) << bool(true) << keys << expected;
+ }
+
+ // entering a two digit valid hour
+ {
+ QTestEventList keys;
+ keys.addKeyClick( '1' );
+ keys.addKeyClick( '1' );
+ QTime expected( 11, 0, 0 );
+ QTest::newRow( "data13" ) << bool(true) << keys << expected;
+ }
+
+ // entering an invalid hour
+ {
+ QTestEventList keys;
+ keys.addKeyClick( '2' );
+ // the '5' creates an invalid hour (25) so it must be ignored
+ keys.addKeyClick( '5' );
+ QTime expected( 2, 0, 0 );
+ QTest::newRow( "data14" ) << bool(true) << keys << expected;
+ }
+
+ // enter a value, in hour which causes a field change
+ {
+ QTestEventList keys;
+ keys.addKeyClick( '0' );
+ keys.addKeyClick( '2' );
+ keys.addKeyClick( '1' );
+ QTime expected( 2, 1, 0 );
+ QTest::newRow( "data15" ) << bool(true) << keys << expected;
+ }
+
+ // enter a one digit valid hour in 24 h mode
+ {
+ QTestEventList keys;
+ keys.addKeyClick( '5' );
+ QTime expected( 5, 0, 0 );
+ QTest::newRow( "data16" ) << bool(false) << keys << expected;
+ }
+
+ // enter a two digit valid hour in 24 h mode
+ {
+ QTestEventList keys;
+ keys.addKeyClick( '1' );
+ keys.addKeyClick( '1' );
+ QTime expected( 11, 0, 0 );
+ QTest::newRow( "data17" ) << bool(false) << keys << expected;
+ }
+
+ // enter a two digit valid hour (>12) in 24 h mode
+ {
+ QTestEventList keys;
+ keys.addKeyClick( '1' );
+ keys.addKeyClick( '5' );
+ QTime expected( 15, 0, 0 );
+ QTest::newRow( "data18" ) << bool(false) << keys << expected;
+ }
+
+ // enter a two digit valid hour (>20) in 24 h mode
+ {
+ QTestEventList keys;
+ keys.addKeyClick( '2' );
+ keys.addKeyClick( '1' );
+ QTime expected( 21, 0, 0 );
+ QTest::newRow( "data19" ) << bool(false) << keys << expected;
+ }
+
+ // enter a two digit invalid hour (>23) in 24 h mode
+ {
+ QTestEventList keys;
+ keys.addKeyClick( '2' );
+ keys.addKeyClick( '4' );
+ QTime expected( 2, 0, 0 );
+ QTest::newRow( "data20" ) << bool(false) << keys << expected;
+ }
+
+ // ***************** test the minutes ***************
+
+ // use up/down keys to change the minutes in 12 hour mode
+ { // test a valid value
+ QTestEventList keys;
+ keys.addKeyClick( Qt::Key_Tab );
+ for (uint i=0; i<2; i++)
+ keys.addKeyClick( Qt::Key_Up );
+ QTime expected( 11, 2, 0 );
+ QTest::newRow( "data21" ) << bool(true) << keys << expected;
+ }
+ { // test a valid value
+ QTestEventList keys;
+ keys.addKeyClick( Qt::Key_Tab );
+ for (uint i=0; i<16; i++)
+ keys.addKeyClick( Qt::Key_Up );
+ QTime expected( 11, 16, 0 );
+ QTest::newRow( "data22" ) << bool(true) << keys << expected;
+ }
+ { // test maximum value
+ QTestEventList keys;
+ keys.addKeyClick( Qt::Key_Tab );
+ for (uint i=0; i<59; i++)
+ keys.addKeyClick( Qt::Key_Up );
+ QTime expected( 11, 59, 0 );
+ QTest::newRow( "data23" ) << bool(true) << keys << expected;
+ }
+ { // test 'overflow'
+ QTestEventList keys;
+ keys.addKeyClick( Qt::Key_Tab );
+ for (uint i=0; i<60; i++)
+ keys.addKeyClick( Qt::Key_Up );
+ QTime expected( 11, 0, 0 );
+ QTest::newRow( "data24" ) << bool(true) << keys << expected;
+ }
+ { // test 'underflow'
+ QTestEventList keys;
+ keys.addKeyClick( Qt::Key_Tab );
+ keys.addKeyClick( Qt::Key_Down );
+ QTime expected( 11, 59, 0 );
+ QTest::newRow( "data25" ) << bool(true) << keys << expected;
+ }
+ { // test valid value
+ QTestEventList keys;
+ keys.addKeyClick( Qt::Key_Tab );
+ for (uint i=0; i<2; i++)
+ keys.addKeyClick( Qt::Key_Down );
+ QTime expected( 11, 58, 0 );
+ QTest::newRow( "data26" ) << bool(true) << keys << expected;
+ }
+
+ // use up/down keys to change the minutes in 24 hour mode
+
+ { // test a valid value
+ QTestEventList keys;
+ keys.addKeyClick( Qt::Key_Tab );
+ for (uint i=0; i<2; i++)
+ keys.addKeyClick( Qt::Key_Up );
+ QTime expected( 11, 2, 0 );
+ QTest::newRow( "data27" ) << bool(false) << keys << expected;
+ }
+ { // test a valid value
+ QTestEventList keys;
+ keys.addKeyClick( Qt::Key_Tab );
+ for (uint i=0; i<16; i++)
+ keys.addKeyClick( Qt::Key_Up );
+ QTime expected( 11, 16, 0 );
+ QTest::newRow( "data28" ) << bool(false) << keys << expected;
+ }
+ { // test maximum value
+ QTestEventList keys;
+ keys.addKeyClick( Qt::Key_Tab );
+ for (uint i=0; i<59; i++)
+ keys.addKeyClick( Qt::Key_Up );
+ QTime expected( 11, 59, 0 );
+ QTest::newRow( "data29" ) << bool(false) << keys << expected;
+ }
+ { // test 'overflow'
+ QTestEventList keys;
+ keys.addKeyClick( Qt::Key_Tab );
+ for (uint i=0; i<60; i++)
+ keys.addKeyClick( Qt::Key_Up );
+ QTime expected( 11, 0, 0 );
+ QTest::newRow( "data30" ) << bool(false) << keys << expected;
+ }
+ { // test 'underflow'
+ QTestEventList keys;
+ keys.addKeyClick( Qt::Key_Tab );
+ keys.addKeyClick( Qt::Key_Down );
+ QTime expected( 11, 59, 0 );
+ QTest::newRow( "data31" ) << bool(false) << keys << expected;
+ }
+ { // test valid value
+ QTestEventList keys;
+ keys.addKeyClick( Qt::Key_Tab );
+ for (uint i=0; i<2; i++)
+ keys.addKeyClick( Qt::Key_Down );
+ QTime expected( 11, 58, 0 );
+ QTest::newRow( "data32" ) << bool(false) << keys << expected;
+ }
+
+ // enter a valid one digit minute in 12 h mode
+ {
+ QTestEventList keys;
+ keys.addKeyClick(Qt::Key_Tab);
+ keys.addKeyClick( '2' );
+ QTime expected( 11, 2, 0 );
+ QTest::newRow( "data33" ) << bool(true) << keys << expected;
+ }
+
+ // enter a valid two digit minutes in 12 h mode
+ {
+ QTestEventList keys;
+ keys.addKeyClick(Qt::Key_Tab);
+ keys.addKeyClick( '2' );
+ keys.addKeyClick( '4' );
+ QTime expected( 11, 24, 0 );
+ QTest::newRow( "data34" ) << bool(true) << keys << expected;
+ }
+
+ // check the lower limit of the minutes in 12 h mode
+ {
+ QTestEventList keys;
+ keys.addKeyClick(Qt::Key_Tab);
+ keys.addKeyClick( '0' );
+ QTime expected( 11, 0, 0 );
+ QTest::newRow( "data35" ) << bool(true) << keys << expected;
+ }
+
+ // check the upper limit of the minutes in 12 h mode
+ {
+ QTestEventList keys;
+ keys.addKeyClick(Qt::Key_Tab);
+ keys.addKeyClick( '5' );
+ keys.addKeyClick( '9' );
+ QTime expected( 11, 59, 0 );
+ QTest::newRow( "data36" ) << bool(true) << keys << expected;
+ }
+
+ // enter an invalid two digit minutes in 12 h mode
+ {
+ QTestEventList keys;
+ keys.addKeyClick( Qt::Key_Tab );
+ keys.addKeyClick( '6' );
+ keys.addKeyClick( '0' );
+ QTime expected( 11, 6, 0 );
+ QTest::newRow( "data37" ) << bool(true) << keys << expected;
+ }
+
+ // test minutes in 24 hour motestWidget-> Behaviour should be exactly the same
+
+ // enter a valid one digit minute in 24 h mode
+ {
+ QTestEventList keys;
+ keys.addKeyClick( Qt::Key_Tab );
+ keys.addKeyClick( '2' );
+ QTime expected( 11, 2, 0 );
+ QTest::newRow( "data38" ) << bool(false) << keys << expected;
+ }
+
+ // enter a valid two digit minutes in 24 h mode
+ {
+ QTestEventList keys;
+ keys.addKeyClick( Qt::Key_Tab );
+ keys.addKeyClick( '2' );
+ keys.addKeyClick( '4' );
+ QTime expected( 11, 24, 0 );
+ QTest::newRow( "data39" ) << bool(false) << keys << expected;
+ }
+
+ // check the lower limit of the minutes in 24 h mode
+ {
+ QTestEventList keys;
+ keys.addKeyClick( Qt::Key_Tab );
+ keys.addKeyClick( '0' );
+ QTime expected( 11, 0, 0 );
+ QTest::newRow( "data40" ) << bool(false) << keys << expected;
+ }
+
+ // check the upper limit of the minutes in 24 h mode
+ {
+ QTestEventList keys;
+ keys.addKeyClick( Qt::Key_Tab );
+ keys.addKeyClick( '5' );
+ keys.addKeyClick( '9' );
+ QTime expected( 11, 59, 0 );
+ QTest::newRow( "data41" ) << bool(false) << keys << expected;
+ }
+
+ // enter an invalid two digit minutes in 24 h mode
+ {
+ QTestEventList keys;
+ keys.addKeyClick( Qt::Key_Tab );
+ keys.addKeyClick( '6' );
+ keys.addKeyClick( '0' );
+ QTime expected( 11, 6, 0 );
+ QTest::newRow( "data42" ) << bool(false) << keys << expected;
+ }
+
+ // ***************** test the seconds ***************
+
+ // use up/down to edit the seconds...
+
+ // use up/down keys to change the seconds in 12 hour mode
+ { // test a valid value
+ QTestEventList keys;
+ keys.addKeyClick( Qt::Key_Tab );
+ keys.addKeyClick( Qt::Key_Tab );
+ for (uint i=0; i<2; i++)
+ keys.addKeyClick( Qt::Key_Up );
+ QTime expected( 11, 0, 2 );
+ QTest::newRow( "data43" ) << bool(true) << keys << expected;
+ }
+ { // test a valid value
+ QTestEventList keys;
+ keys.addKeyClick( Qt::Key_Tab );
+ keys.addKeyClick( Qt::Key_Tab );
+ for (uint i=0; i<16; i++)
+ keys.addKeyClick( Qt::Key_Up );
+ QTime expected( 11, 0, 16 );
+ QTest::newRow( "data44" ) << bool(true) << keys << expected;
+ }
+ { // test maximum value
+ QTestEventList keys;
+ keys.addKeyClick( Qt::Key_Tab );
+ keys.addKeyClick( Qt::Key_Tab );
+ for (uint i=0; i<59; i++)
+ keys.addKeyClick( Qt::Key_Up );
+ QTime expected( 11, 0, 59 );
+ QTest::newRow( "data45" ) << bool(true) << keys << expected;
+ }
+ { // test 'overflow'
+ QTestEventList keys;
+ keys.addKeyClick( Qt::Key_Tab );
+ keys.addKeyClick( Qt::Key_Tab );
+ for (uint i=0; i<60; i++)
+ keys.addKeyClick( Qt::Key_Up );
+ QTime expected( 11, 0, 0 );
+ QTest::newRow( "data46" ) << bool(true) << keys << expected;
+ }
+ { // test 'underflow'
+ QTestEventList keys;
+ keys.addKeyClick( Qt::Key_Tab );
+ keys.addKeyClick( Qt::Key_Tab );
+ keys.addKeyClick( Qt::Key_Down );
+ QTime expected( 11, 0, 59 );
+ QTest::newRow( "data47" ) << bool(true) << keys << expected;
+ }
+ { // test valid value
+ QTestEventList keys;
+ keys.addKeyClick( Qt::Key_Tab );
+ keys.addKeyClick( Qt::Key_Tab );
+ for (uint i=0; i<2; i++)
+ keys.addKeyClick( Qt::Key_Down );
+ QTime expected( 11, 0, 58 );
+ QTest::newRow( "data48" ) << bool(true) << keys << expected;
+ }
+
+ // use up/down keys to change the seconds in 24 hour mode
+
+ { // test a valid value
+ QTestEventList keys;
+ keys.addKeyClick( Qt::Key_Tab );
+ keys.addKeyClick( Qt::Key_Tab );
+ for (uint i=0; i<2; i++)
+ keys.addKeyClick( Qt::Key_Up );
+ QTime expected( 11, 0, 2 );
+ QTest::newRow( "data49" ) << bool(false) << keys << expected;
+ }
+ { // test a valid value
+ QTestEventList keys;
+ keys.addKeyClick( Qt::Key_Tab );
+ keys.addKeyClick( Qt::Key_Tab );
+ for (uint i=0; i<16; i++)
+ keys.addKeyClick( Qt::Key_Up );
+ QTime expected( 11, 0, 16 );
+ QTest::newRow( "data50" ) << bool(false) << keys << expected;
+ }
+ { // test maximum value
+ QTestEventList keys;
+ keys.addKeyClick( Qt::Key_Tab );
+ keys.addKeyClick( Qt::Key_Tab );
+ for (uint i=0; i<59; i++)
+ keys.addKeyClick( Qt::Key_Up );
+ QTime expected( 11, 0, 59 );
+ QTest::newRow( "data51" ) << bool(false) << keys << expected;
+ }
+ { // test 'overflow'
+ QTestEventList keys;
+ keys.addKeyClick( Qt::Key_Tab );
+ keys.addKeyClick( Qt::Key_Tab );
+ for (uint i=0; i<60; i++)
+ keys.addKeyClick( Qt::Key_Up );
+ QTime expected( 11, 0, 0 );
+ QTest::newRow( "data52" ) << bool(false) << keys << expected;
+ }
+ { // test 'underflow'
+ QTestEventList keys;
+ keys.addKeyClick( Qt::Key_Tab );
+ keys.addKeyClick( Qt::Key_Tab );
+ keys.addKeyClick( Qt::Key_Down );
+ QTime expected( 11, 0, 59 );
+ QTest::newRow( "data53" ) << bool(false) << keys << expected;
+ }
+ { // test valid value
+ QTestEventList keys;
+ keys.addKeyClick( Qt::Key_Tab );
+ keys.addKeyClick( Qt::Key_Tab );
+ for (uint i=0; i<2; i++)
+ keys.addKeyClick( Qt::Key_Down );
+ QTime expected( 11, 0, 58 );
+ QTest::newRow( "data54" ) << bool(false) << keys << expected;
+ }
+
+ // enter a valid one digit second in 12 h mode
+ {
+ QTestEventList keys;
+ keys.addKeyClick( Qt::Key_Tab );
+ keys.addKeyClick( Qt::Key_Tab );
+ keys.addKeyClick( '2' );
+ QTime expected( 11, 0, 2 );
+ QTest::newRow( "data55" ) << bool(true) << keys << expected;
+ }
+
+ // enter a valid two digit seconds in 12 h mode
+ {
+ QTestEventList keys;
+ keys.addKeyClick( Qt::Key_Tab );
+ keys.addKeyClick( Qt::Key_Tab );
+ keys.addKeyClick( '2' );
+ keys.addKeyClick( '4' );
+ QTime expected( 11, 0, 24 );
+ QTest::newRow( "data56" ) << bool(true) << keys << expected;
+ }
+
+ // check the lower limit of the seconds in 12 h mode
+ {
+ QTestEventList keys;
+ keys.addKeyClick( Qt::Key_Tab );
+ keys.addKeyClick( Qt::Key_Tab );
+ keys.addKeyClick( '0' );
+ QTime expected( 11, 0, 0 );
+ QTest::newRow( "data57" ) << bool(true) << keys << expected;
+ }
+
+ // check the upper limit of the seconds in 12 h mode
+ {
+ QTestEventList keys;
+ keys.addKeyClick( Qt::Key_Tab );
+ keys.addKeyClick( Qt::Key_Tab );
+ keys.addKeyClick( '5' );
+ keys.addKeyClick( '9' );
+ QTime expected( 11, 0, 59 );
+ QTest::newRow( "data58" ) << bool(true) << keys << expected;
+ }
+
+ // enter an invalid two digit seconds in 12 h mode
+ {
+ QTestEventList keys;
+ keys.addKeyClick( Qt::Key_Tab );
+ keys.addKeyClick( Qt::Key_Tab );
+ keys.addKeyClick( '6' );
+ keys.addKeyClick( '0' );
+ QTime expected( 11, 0, 6 );
+ QTest::newRow( "data59" ) << bool(true) << keys << expected;
+ }
+
+ // test seconds in 24 hour mode. Behaviour should be exactly the same
+
+ // enter a valid one digit minute in 24 h mode
+ {
+ QTestEventList keys;
+ keys.addKeyClick( Qt::Key_Tab );
+ keys.addKeyClick( Qt::Key_Tab );
+ keys.addKeyClick( '2' );
+ QTime expected( 11, 0, 2 );
+ QTest::newRow( "data60" ) << bool(false) << keys << expected;
+ }
+
+ // enter a valid two digit seconds in 24 h mode
+ {
+ QTestEventList keys;
+ keys.addKeyClick( Qt::Key_Tab );
+ keys.addKeyClick( Qt::Key_Tab );
+ keys.addKeyClick( '2' );
+ keys.addKeyClick( '4' );
+ QTime expected( 11, 0, 24 );
+ QTest::newRow( "data61" ) << bool(false) << keys << expected;
+ }
+
+ // check the lower limit of the seconds in 24 h mode
+ {
+ QTestEventList keys;
+ keys.addKeyClick( Qt::Key_Tab );
+ keys.addKeyClick( Qt::Key_Tab );
+ keys.addKeyClick( '0' );
+ QTime expected( 11, 0, 0 );
+ QTest::newRow( "data62" ) << bool(false) << keys << expected;
+ }
+
+ // check the upper limit of the seconds in 24 h mode
+ {
+ QTestEventList keys;
+ keys.addKeyClick( Qt::Key_Tab );
+ keys.addKeyClick( Qt::Key_Tab );
+ keys.addKeyClick( '5' );
+ keys.addKeyClick( '9' );
+ QTime expected( 11, 0, 59 );
+ QTest::newRow( "data63" ) << bool(false) << keys << expected;
+ }
+
+ // enter an invalid two digit seconds in 24 h mode
+ {
+ QTestEventList keys;
+ keys.addKeyClick( Qt::Key_Tab );
+ keys.addKeyClick( Qt::Key_Tab );
+ keys.addKeyClick( '6' );
+ keys.addKeyClick( '0' );
+ QTime expected( 11, 0, 6 );
+ QTest::newRow( "data64" ) << bool(false) << keys << expected;
+ }
+
+ // Test the AMPM indicator
+ {
+ QTestEventList keys;
+ keys.addKeyClick( Qt::Key_Tab );
+ keys.addKeyClick( Qt::Key_Tab );
+ keys.addKeyClick( Qt::Key_Tab );
+ keys.addKeyClick( Qt::Key_Up );
+ QTime expected( 23, 0, 0 );
+ QTest::newRow( "data65" ) << bool(true) << keys << expected;
+ }
+ // Test the AMPM indicator
+ {
+ QTestEventList keys;
+ keys.addKeyClick( Qt::Key_Tab );
+ keys.addKeyClick( Qt::Key_Tab );
+ keys.addKeyClick( Qt::Key_Tab );
+ keys.addKeyClick( Qt::Key_Down );
+ QTime expected( 23, 0, 0 );
+ QTest::newRow( "data66" ) << bool(true) << keys << expected;
+ }
+ // Test the AMPM indicator
+ {
+ QTestEventList keys;
+ keys.addKeyClick( Qt::Key_Tab );
+ keys.addKeyClick( Qt::Key_Tab );
+ keys.addKeyClick( Qt::Key_Tab );
+ keys.addKeyClick( Qt::Key_Down );
+ keys.addKeyClick( Qt::Key_Down );
+ QTime expected( 11, 0, 0 );
+ QTest::newRow( "data67" ) << bool(true) << keys << expected;
+ }
+ // Test the AMPM indicator
+ {
+ QTestEventList keys;
+ keys.addKeyClick( Qt::Key_Tab );
+ keys.addKeyClick( Qt::Key_Tab );
+ keys.addKeyClick( Qt::Key_Tab );
+ keys.addKeyClick( Qt::Key_Up );
+ keys.addKeyClick( Qt::Key_Down );
+ QTime expected( 11, 0, 0 );
+ QTest::newRow( "data68" ) << bool(true) << keys << expected;
+ }
+}
+
+void tst_QDateTimeEdit::userKeyPress_Time()
+{
+ QFETCH(bool, ampm);
+ QFETCH(QTestEventList, keys);
+ QFETCH(QTime, expected_time);
+
+ if (ampm)
+ testWidget->setDisplayFormat("hh:mm:ss ap");
+ else
+ testWidget->setDisplayFormat("hh:mm:ss");
+
+ testWidget->setTime(QTime(11, 0, 0));
+ testWidget->setFocus();
+
+ testWidget->setWrapping(true);
+
+ QTest::keyClick(testWidget, Qt::Key_Enter); // Make sure the first section is now focused
+ QCOMPARE(testWidget->lineEdit()->selectedText(), QString("11"));
+ keys.simulate(testWidget);
+ QTest::keyClick(testWidget, Qt::Key_Enter);
+
+ QCOMPARE(testWidget->time(), expected_time);
+}
+
+void tst_QDateTimeEdit::wrappingDate_data()
+{
+ QTest::addColumn<bool>("startWithMin");
+ QTest::addColumn<QDate>("minimumDate");
+ QTest::addColumn<QDate>("maximumDate");
+ QTest::addColumn<uint>("section");
+ QTest::addColumn<QDate>("newDate");
+
+ QTest::newRow("data0") << false << QDate(1999, 1, 1) << QDate(1999, 1, 31) << (uint)QDateTimeEdit::DaySection
+ << QDate(1999, 1, 1);
+ QTest::newRow("data1") << true << QDate(1999, 1, 1) << QDate(1999, 1, 31) << (uint)QDateTimeEdit::DaySection
+ << QDate(1999, 1, 31);
+ QTest::newRow("data2") << false << QDate(1999, 1, 1) << QDate(1999, 1, 31) << (uint)QDateTimeEdit::MonthSection
+ << QDate(1999, 1, 31);
+ QTest::newRow("data3") << true << QDate(1999, 1, 1) << QDate(1999, 1, 31) << (uint)QDateTimeEdit::MonthSection
+ << QDate(1999, 1, 1);
+ QTest::newRow("data4") << false << QDate(1999, 1, 1) << QDate(1999, 1, 31) << (uint)QDateTimeEdit::YearSection
+ << QDate(1999, 1, 31);
+ QTest::newRow("data5") << true << QDate(1999, 1, 1) << QDate(1999, 1, 31) << (uint)QDateTimeEdit::YearSection
+ << QDate(1999, 1, 1);
+ QTest::newRow("data6") << false << QDate(1999, 1, 1) << QDate(2000, 1, 31) << (uint)QDateTimeEdit::DaySection
+ << QDate(2000, 1, 1);
+ QTest::newRow("data7") << true << QDate(1999, 1, 1) << QDate(2000, 1, 31) << (uint)QDateTimeEdit::DaySection
+ << QDate(1999, 1, 31);
+ QTest::newRow("data8") << false << QDate(1999, 1, 1) << QDate(2000, 1, 31) << (uint)QDateTimeEdit::MonthSection
+ << QDate(2000, 1, 31);
+ QTest::newRow("data9") << true << QDate(1999, 1, 1) << QDate(2000, 1, 31) << (uint)QDateTimeEdit::MonthSection
+ << QDate(1999, 12, 1);
+ QTest::newRow("data10") << false << QDate(1999, 1, 1) << QDate(2000, 1, 31) << (uint)QDateTimeEdit::YearSection
+ << QDate(1999, 1, 31);
+ QTest::newRow("data11") << true << QDate(1999, 1, 1) << QDate(2000, 1, 31) << (uint)QDateTimeEdit::YearSection
+ << QDate(2000, 1, 1);
+}
+
+
+void tst_QDateTimeEdit::wrappingDate()
+{
+ QFETCH(bool, startWithMin);
+ QFETCH(QDate, minimumDate);
+ QFETCH(QDate, maximumDate);
+ QFETCH(uint, section);
+ QFETCH(QDate, newDate);
+
+ testWidget->setDisplayFormat("dd/MM/yyyy");
+ testWidget->setMinimumDate(minimumDate);
+ testWidget->setMaximumDate(maximumDate);
+ testWidget->setWrapping(true);
+ testWidget->setCurrentSection((QDateTimeEdit::Section)section);
+
+ if (startWithMin) {
+ testWidget->setDate(minimumDate);
+ QTest::keyClick(testWidget, Qt::Key_Down);
+ } else {
+ testWidget->setDate(maximumDate);
+ QTest::keyClick(testWidget, Qt::Key_Up);
+ }
+ if (testWidget->currentSection() == QDateTimeEdit::MonthSection)
+ QCOMPARE(testWidget->date(), newDate);
+}
+
+void tst_QDateTimeEdit::dateSignalChecking_data()
+{
+ QTest::addColumn<QDate>("originalDate");
+ QTest::addColumn<QDate>("newDate");
+ QTest::addColumn<int>("timesEmitted");
+
+ QTest::newRow("data0") << QDate(2004, 06, 22) << QDate(2004, 07, 23) << 1;
+ QTest::newRow("data1") << QDate(2004, 06, 22) << QDate(2004, 06, 22) << 0;
+}
+
+void tst_QDateTimeEdit::dateSignalChecking()
+{
+ QFETCH(QDate, originalDate);
+ QFETCH(QDate, newDate);
+ QFETCH(int, timesEmitted);
+
+ testWidget->setDate(originalDate);
+
+ QSignalSpy dateSpy(testWidget, SIGNAL(dateChanged(const QDate &)));
+ QSignalSpy dateTimeSpy(testWidget, SIGNAL(dateTimeChanged(const QDateTime &)));
+ QSignalSpy timeSpy(testWidget, SIGNAL(timeChanged(const QTime &)));
+
+ testWidget->setDate(newDate);
+ QCOMPARE(dateSpy.count(), timesEmitted);
+
+ if (timesEmitted > 0) {
+ QList<QVariant> list = dateSpy.takeFirst();
+ QDate d;
+ d = qVariantValue<QDate>(list.at(0));
+ QCOMPARE(d, newDate);
+ }
+ QCOMPARE(dateTimeSpy.count(), timesEmitted);
+ QCOMPARE(timeSpy.count(), 0);
+}
+
+void tst_QDateTimeEdit::timeSignalChecking_data()
+{
+ QTest::addColumn<QTime>("originalTime");
+ QTest::addColumn<QTime>("newTime");
+ QTest::addColumn<int>("timesEmitted");
+
+ QTest::newRow("data0") << QTime(15, 55, 00) << QTime(15, 17, 12) << 1;
+ QTest::newRow("data1") << QTime(15, 55, 00) << QTime(15, 55, 00) << 0;
+}
+
+void tst_QDateTimeEdit::timeSignalChecking()
+{
+ QFETCH(QTime, originalTime);
+ QFETCH(QTime, newTime);
+ QFETCH(int, timesEmitted);
+
+ testWidget->setTime(originalTime);
+
+ testWidget->setDisplayFormat("hh:mm:ss");
+ QSignalSpy dateSpy(testWidget, SIGNAL(dateChanged(const QDate &)));
+ QSignalSpy dateTimeSpy(testWidget, SIGNAL(dateTimeChanged(const QDateTime &)));
+ QSignalSpy timeSpy(testWidget, SIGNAL(timeChanged(const QTime &)));
+
+ testWidget->setTime(newTime);
+ QCOMPARE(timeSpy.count(), timesEmitted);
+
+ if (timesEmitted > 0) {
+ QList<QVariant> list = timeSpy.takeFirst();
+ QTime t;
+ t = qVariantValue<QTime>(list.at(0));
+ QCOMPARE(t, newTime);
+ }
+ QCOMPARE(dateTimeSpy.count(), timesEmitted);
+ QCOMPARE(dateSpy.count(), 0);
+}
+
+void tst_QDateTimeEdit::dateTimeSignalChecking_data()
+{
+ QTest::addColumn<QDateTime>("originalDateTime");
+ QTest::addColumn<QDateTime>("newDateTime");
+ QTest::addColumn<int>("timesDateEmitted");
+ QTest::addColumn<int>("timesTimeEmitted");
+ QTest::addColumn<int>("timesDateTimeEmitted");
+
+ QTest::newRow("data0") << QDateTime(QDate(2004, 6, 22), QTime(15, 55, 0))
+ << QDateTime(QDate(2004, 7, 23), QTime(15, 17, 12))
+ << 1 << 1 << 1;
+ QTest::newRow("data1") << QDateTime(QDate(2004, 6, 22), QTime(15, 55, 0))
+ << QDateTime(QDate(2004, 6, 22), QTime(15, 17, 12))
+ << 0 << 1 << 1;
+ QTest::newRow("data2") << QDateTime(QDate(2004, 6, 22), QTime(15, 55, 0))
+ << QDateTime(QDate(2004, 7, 23), QTime(15, 55, 0))
+ << 1 << 0 << 1;
+ QTest::newRow("data3") << QDateTime(QDate(2004, 6, 22), QTime(15, 55, 0))
+ << QDateTime(QDate(2004, 6, 22), QTime(15, 55, 0))
+ << 0 << 0 << 0;
+}
+
+void tst_QDateTimeEdit::dateTimeSignalChecking()
+{
+ QFETCH(QDateTime, originalDateTime);
+ QFETCH(QDateTime, newDateTime);
+ QFETCH(int, timesDateEmitted);
+ QFETCH(int, timesTimeEmitted);
+ QFETCH(int, timesDateTimeEmitted);
+
+ testWidget->setDisplayFormat("dd/MM/yyyy hh:mm:ss");
+ testWidget->setDateTime(originalDateTime);
+
+ QSignalSpy dateSpy(testWidget, SIGNAL(dateChanged(const QDate &)));
+ QSignalSpy timeSpy(testWidget, SIGNAL(timeChanged(const QTime &)));
+ QSignalSpy dateTimeSpy(testWidget, SIGNAL(dateTimeChanged(const QDateTime &)));
+
+ testWidget->setDateTime(newDateTime);
+ QCOMPARE(dateSpy.count(), timesDateEmitted);
+ if (timesDateEmitted > 0) {
+ QCOMPARE(timesDateEmitted, 1);
+ QList<QVariant> list = dateSpy.takeFirst();
+ QDate d;
+ d = qVariantValue<QDate>(list.at(0));
+ QCOMPARE(d, newDateTime.date());
+ }
+ QCOMPARE(timeSpy.count(), timesTimeEmitted);
+ if (timesTimeEmitted > 0) {
+ QList<QVariant> list = timeSpy.takeFirst();
+ QTime t;
+ t = qVariantValue<QTime>(list.at(0));
+ QCOMPARE(t, newDateTime.time());
+ }
+ QCOMPARE(dateTimeSpy.count(), timesDateTimeEmitted);
+ if (timesDateTimeEmitted > 0) {
+ QList<QVariant> list = dateTimeSpy.takeFirst();
+ QDateTime dt;
+ dt = qVariantValue<QDateTime>(list.at(0));
+ QCOMPARE(dt, newDateTime);
+ }
+}
+
+
+void tst_QDateTimeEdit::sectionText_data()
+{
+ QTest::addColumn<QString>("format");
+ QTest::addColumn<QDateTime>("dateTime");
+ QTest::addColumn<uint>("section");
+ QTest::addColumn<QString>("sectionText");
+
+ QTest::newRow("data0") << QString("dd/MM/yyyy hh:mm:ss zzz ap")
+ << QDateTime(QDate(2004, 6, 22), QTime(15, 55, 3, 789))
+ << (uint)QDateTimeEdit::NoSection << QString();
+ QTest::newRow("data1") << QString("dd/MM/yyyy hh:mm:ss zzz ap")
+ << QDateTime(QDate(2004, 6, 22), QTime(15, 55, 3, 789))
+ << (uint)QDateTimeEdit::AmPmSection << QString("pm");
+ QTest::newRow("data2") << QString("dd/MM/yyyy hh:mm:ss zzz ap")
+ << QDateTime(QDate(2004, 6, 22), QTime(15, 55, 3, 789))
+ << (uint)QDateTimeEdit::MSecSection << QString("789");
+ QTest::newRow("data3") << QString("dd/MM/yyyy hh:mm:ss zzz ap")
+ << QDateTime(QDate(2004, 6, 22), QTime(15, 55, 3, 789))
+ << (uint)QDateTimeEdit::SecondSection << QString("03");
+ QTest::newRow("data4") << QString("dd/MM/yyyy hh:mm:ss zzz ap")
+ << QDateTime(QDate(2004, 6, 22), QTime(15, 55, 3, 789))
+ << (uint)QDateTimeEdit::MinuteSection << QString("55");
+ QTest::newRow("data5") << QString("dd/MM/yyyy hh:mm:ss zzz ap")
+ << QDateTime(QDate(2004, 6, 22), QTime(15, 55, 3, 789))
+ << (uint)QDateTimeEdit::HourSection << QString("03");
+ QTest::newRow("data6") << QString("dd/MM/yyyy hh:mm:ss zzz")
+ << QDateTime(QDate(2004, 6, 22), QTime(15, 55, 3, 789))
+ << (uint)QDateTimeEdit::HourSection << QString("15");
+ QTest::newRow("data7") << QString("dd/MM/yyyy hh:mm:ss zzz ap")
+ << QDateTime(QDate(2004, 6, 22), QTime(15, 55, 3, 789))
+ << (uint)QDateTimeEdit::DaySection << QString("22");
+ QTest::newRow("data8") << QString("dd/MM/yyyy hh:mm:ss zzz ap")
+ << QDateTime(QDate(2004, 6, 22), QTime(15, 55, 3, 789))
+ << (uint)QDateTimeEdit::MonthSection << QString("06");
+ QTest::newRow("data9") << QString("dd/MM/yyyy hh:mm:ss zzz ap")
+ << QDateTime(QDate(2004, 6, 22), QTime(15, 55, 3, 789))
+ << (uint)QDateTimeEdit::YearSection << QString("2004");
+ QTest::newRow("data10") << QString("dd/MM/yyyy hh:mm:ss zzz AP")
+ << QDateTime(QDate(2004, 6, 22), QTime(15, 55, 3, 789))
+ << (uint)QDateTimeEdit::AmPmSection << QString("PM");
+ QTest::newRow("data11") << QString("dd/MM/yyyy hh:mm:ss ap")
+ << QDateTime(QDate(2004, 6, 22), QTime(15, 55, 3, 789))
+ << (uint)QDateTimeEdit::MSecSection << QString();
+}
+
+void tst_QDateTimeEdit::sectionText()
+{
+ QFETCH(QString, format);
+ QFETCH(QDateTime, dateTime);
+ QFETCH(uint, section);
+ QFETCH(QString, sectionText);
+
+ testWidget->setDisplayFormat(format);
+ testWidget->setDateTime(dateTime);
+ QCOMPARE(testWidget->sectionText((QDateTimeEdit::Section)section), sectionText);
+// QApplication::setLayoutDirection(Qt::RightToLeft);
+// testWidget->setDisplayFormat(format);
+// QCOMPARE(format, testWidget->displayFormat());
+// testWidget->setDateTime(dateTime);
+// QCOMPARE(testWidget->sectionText((QDateTimeEdit::Section)section), sectionText);
+// QApplication::setLayoutDirection(Qt::LeftToRight);
+}
+
+void tst_QDateTimeEdit::mousePress()
+{
+ testWidget->setDate(QDate(2004, 6, 23));
+ testWidget->setCurrentSection(QDateTimeEdit::YearSection);
+ QCOMPARE(testWidget->currentSection(), QDateTimeEdit::YearSection);
+
+ // Ask the SC_SpinBoxUp button location from style
+ QStyleOptionSpinBox so;
+ so.rect = testWidget->rect();
+ QRect rectUp = testWidget->style()->subControlRect(QStyle::CC_SpinBox, &so, QStyle::SC_SpinBoxUp, testWidget);
+
+ // Send mouseClick to center of SC_SpinBoxUp
+ QTest::mouseClick(testWidget, Qt::LeftButton, 0, rectUp.center());
+ QCOMPARE(testWidget->date().year(), 2005);
+
+}
+
+void tst_QDateTimeEdit::stepHourAMPM_data()
+{
+ QTest::addColumn<QString>("format");
+ QTest::addColumn<KeyList>("keys");
+ QTest::addColumn<TimeList>("expected");
+ QTest::addColumn<QTime>("start");
+ QTest::addColumn<QTime>("min");
+ QTest::addColumn<QTime>("max");
+
+ {
+ KeyList keys;
+ TimeList expected;
+ keys << Qt::Key_Up;
+ expected << QTime(1, 0, 0);
+ keys << Qt::Key_Up;
+ expected << QTime(2, 0, 0);
+ keys << Qt::Key_Up;
+ expected << QTime(3, 0, 0);
+ keys << Qt::Key_Up;
+ expected << QTime(4, 0, 0);
+ keys << Qt::Key_Up;
+ expected << QTime(5, 0, 0);
+ keys << Qt::Key_Up;
+ expected << QTime(6, 0, 0);
+ keys << Qt::Key_Up;
+ expected << QTime(7, 0, 0);
+ keys << Qt::Key_Up;
+ expected << QTime(8, 0, 0);
+ keys << Qt::Key_Up;
+ expected << QTime(9, 0, 0);
+ keys << Qt::Key_Up;
+ expected << QTime(10, 0, 0);
+ keys << Qt::Key_Up;
+ expected << QTime(11, 0, 0);
+ keys << Qt::Key_Up;
+ expected << QTime(12, 0, 0);
+ keys << Qt::Key_Up;
+ expected << QTime(13, 0, 0);
+ keys << Qt::Key_Up;
+ expected << QTime(14, 0, 0);
+ keys << Qt::Key_Up;
+ expected << QTime(15, 0, 0);
+ keys << Qt::Key_Up;
+ expected << QTime(16, 0, 0);
+ keys << Qt::Key_Up;
+ expected << QTime(17, 0, 0);
+ keys << Qt::Key_Up;
+ expected << QTime(18, 0, 0);
+ keys << Qt::Key_Up;
+ expected << QTime(19, 0, 0);
+ keys << Qt::Key_Up;
+ expected << QTime(20, 0, 0);
+ keys << Qt::Key_Up;
+ expected << QTime(21, 0, 0);
+ keys << Qt::Key_Up;
+ expected << QTime(22, 0, 0);
+ keys << Qt::Key_Up;
+ expected << QTime(23, 0, 0);
+ keys << Qt::Key_Down;
+ expected << QTime(22, 0, 0);
+ keys << Qt::Key_Down;
+ expected << QTime(21, 0, 0);
+ keys << Qt::Key_Down;
+ expected << QTime(20, 0, 0);
+ keys << Qt::Key_Down;
+ expected << QTime(19, 0, 0);
+ keys << Qt::Key_Down;
+ expected << QTime(18, 0, 0);
+ keys << Qt::Key_Down;
+ expected << QTime(17, 0, 0);
+ keys << Qt::Key_Down;
+ expected << QTime(16, 0, 0);
+ keys << Qt::Key_Down;
+ expected << QTime(15, 0, 0);
+ keys << Qt::Key_Down;
+ expected << QTime(14, 0, 0);
+ keys << Qt::Key_Down;
+ expected << QTime(13, 0, 0);
+ keys << Qt::Key_Down;
+ expected << QTime(12, 0, 0);
+ keys << Qt::Key_Down;
+ expected << QTime(11, 0, 0);
+ keys << Qt::Key_Down;
+ expected << QTime(10, 0, 0);
+ keys << Qt::Key_Down;
+ expected << QTime(9, 0, 0);
+ keys << Qt::Key_Down;
+ expected << QTime(8, 0, 0);
+ keys << Qt::Key_Down;
+ expected << QTime(7, 0, 0);
+ keys << Qt::Key_Down;
+ expected << QTime(6, 0, 0);
+ keys << Qt::Key_Down;
+ expected << QTime(5, 0, 0);
+ keys << Qt::Key_Down;
+ expected << QTime(4, 0, 0);
+ keys << Qt::Key_Down;
+ expected << QTime(3, 0, 0);
+ keys << Qt::Key_Down;
+ expected << QTime(2, 0, 0);
+ keys << Qt::Key_Down;
+ expected << QTime(1, 0, 0);
+ keys << Qt::Key_Down;
+ expected << QTime(0, 0, 0);
+
+ QTest::newRow("hh 1") << QString("hh") << keys << expected << QTime(0, 0)
+ << QTime(0, 0) << QTime(23, 59, 59);
+ QTest::newRow("hh:ap 1") << QString("hh:ap") << keys << expected
+ << QTime(0, 0) << QTime(0, 0)
+ << QTime(23, 59, 59);
+
+ QTest::newRow("HH:ap 2") << QString("HH:ap") << keys << expected
+ << QTime(0, 0) << QTime(0, 0)
+ << QTime(23, 59, 59);
+
+ }
+ {
+ KeyList keys;
+ TimeList expected;
+ keys << Qt::Key_Down;
+ expected << QTime(2, 0, 0);
+ QTest::newRow("hh 2") << QString("hh") << keys << expected << QTime(0, 0) << QTime(2, 0, 0) << QTime(23, 59, 59);
+ QTest::newRow("hh:ap 2") << QString("hh:ap") << keys << expected << QTime(0, 0) << QTime(2, 0, 0) << QTime(23, 59, 59);
+ }
+ {
+ KeyList keys;
+ TimeList expected;
+ keys << Qt::Key_Up;
+ expected << QTime(23, 0, 0);
+ keys << Qt::Key_Up;
+ expected << QTime(23, 0, 0);
+ QTest::newRow("hh 3") << QString("hh") << keys << expected << QTime(0, 0) << QTime(22, 0, 0)
+ << QTime(23, 59, 59);
+ QTest::newRow("hh:ap 3") << QString("hh:ap") << keys << expected << QTime(0, 0)
+ << QTime(22, 0, 0) << QTime(23, 59, 59);
+ }
+ {
+ KeyList keys;
+ TimeList expected;
+ keys << Qt::Key_Up;
+ expected << QTime(15, 31, 0);
+ QTest::newRow("hh:mm:ap 3") << QString("hh:mm:ap") << keys << expected << QTime(15, 31, 0)
+ << QTime(9, 0, 0) << QTime(16, 0, 0);
+ QTest::newRow("hh:mm 3") << QString("hh:mm") << keys << expected << QTime(15, 31, 0)
+ << QTime(9, 0, 0) << QTime(16, 0, 0);
+ }
+}
+
+void tst_QDateTimeEdit::stepHourAMPM()
+{
+ QFETCH(QString, format);
+ QFETCH(KeyList, keys);
+ QFETCH(TimeList, expected);
+ QFETCH(QTime, start);
+ QFETCH(QTime, min);
+ QFETCH(QTime, max);
+
+
+ testWidget->setDisplayFormat(format);
+ testWidget->setTime(start);
+ testWidget->setMinimumTime(min);
+ testWidget->setMaximumTime(max);
+ if (keys.size() != expected.size()) {
+ qWarning("%s:%d Test broken", __FILE__, __LINE__);
+ QCOMPARE(keys.size(), expected.size());
+ }
+
+ for (int i=0; i<keys.size(); ++i) {
+ QTest::keyClick(testWidget, keys.at(i));
+ QCOMPARE(testWidget->time(), expected.at(i));
+ }
+}
+
+
+void tst_QDateTimeEdit::displayedSections_data()
+{
+ QTest::addColumn<QString>("format");
+ QTest::addColumn<uint>("section");
+
+ QTest::newRow("data0") << QString("dd/MM/yyyy hh:mm:ss zzz ap")
+ << (uint)(QDateTimeEdit::DaySection | QDateTimeEdit::MonthSection
+ | QDateTimeEdit::YearSection | QDateTimeEdit::HourSection
+ | QDateTimeEdit::MinuteSection | QDateTimeEdit::SecondSection
+ | QDateTimeEdit::MSecSection | QDateTimeEdit::AmPmSection);
+ QTest::newRow("data1") << QString("dd/yyyy hh:mm:ss zzz ap")
+ << (uint)(QDateTimeEdit::DaySection
+ | QDateTimeEdit::YearSection | QDateTimeEdit::HourSection
+ | QDateTimeEdit::MinuteSection | QDateTimeEdit::SecondSection
+ | QDateTimeEdit::MSecSection | QDateTimeEdit::AmPmSection);
+ QTest::newRow("data2") << QString("dd/MM/yyyy mm zzz ap")
+ << (uint)(QDateTimeEdit::DaySection | QDateTimeEdit::MonthSection
+ | QDateTimeEdit::YearSection
+ | QDateTimeEdit::MinuteSection
+ | QDateTimeEdit::MSecSection | QDateTimeEdit::AmPmSection);
+ QTest::newRow("data3") << QString("dd/MM/yyyy")
+ << (uint)(QDateTimeEdit::DaySection | QDateTimeEdit::MonthSection
+ | QDateTimeEdit::YearSection);
+ QTest::newRow("data4") << QString("hh:mm:ss zzz ap")
+ << (uint)(QDateTimeEdit::HourSection
+ | QDateTimeEdit::MinuteSection | QDateTimeEdit::SecondSection
+ | QDateTimeEdit::MSecSection | QDateTimeEdit::AmPmSection);
+ QTest::newRow("data5") << QString("dd ap")
+ << (uint)(QDateTimeEdit::DaySection | QDateTimeEdit::AmPmSection);
+ QTest::newRow("data6") << QString("zzz")
+ << (uint)QDateTimeEdit::MSecSection;
+}
+
+void tst_QDateTimeEdit::displayedSections()
+{
+ QFETCH(QString, format);
+ QFETCH(uint, section);
+
+ testWidget->setDisplayFormat(format);
+ QVERIFY((QDateTimeEdit::Section)section == testWidget->displayedSections());
+}
+
+void tst_QDateTimeEdit::currentSection_data()
+{
+ QTest::addColumn<QString>("format");
+ QTest::addColumn<uint>("section");
+ QTest::addColumn<uint>("currentSection");
+
+ // First is deliberate, this way we can make sure that it is not reset by specifying no section.
+ QTest::newRow("data0") << QString("dd/MM/yyyy hh:mm:ss zzz ap")
+ << (uint)QDateTimeEdit::NoSection << (uint)QDateTimeEdit::YearSection;
+ QTest::newRow("data1") << QString("dd/MM/yyyy hh:mm:ss zzz ap")
+ << (uint)QDateTimeEdit::AmPmSection << (uint)QDateTimeEdit::AmPmSection;
+ QTest::newRow("data2") << QString("dd/MM/yyyy hh:mm:ss zzz ap")
+ << (uint)QDateTimeEdit::MSecSection << (uint)QDateTimeEdit::MSecSection;
+ QTest::newRow("data3") << QString("dd/MM/yyyy hh:mm:ss zzz ap")
+ << (uint)QDateTimeEdit::SecondSection << (uint)QDateTimeEdit::SecondSection;
+ QTest::newRow("data4") << QString("dd/MM/yyyy hh:mm:ss zzz ap")
+ << (uint)QDateTimeEdit::MinuteSection << (uint)QDateTimeEdit::MinuteSection;
+ QTest::newRow("data5") << QString("dd/MM/yyyy hh:mm:ss zzz ap")
+ << (uint)QDateTimeEdit::HourSection << (uint)QDateTimeEdit::HourSection;
+ QTest::newRow("data6") << QString("dd/MM/yyyy hh:mm:ss zzz ap")
+ << (uint)QDateTimeEdit::DaySection << (uint)QDateTimeEdit::DaySection;
+ QTest::newRow("data7") << QString("dd/MM/yyyy hh:mm:ss zzz ap")
+ << (uint)QDateTimeEdit::MonthSection << (uint)QDateTimeEdit::MonthSection;
+ QTest::newRow("data8") << QString("dd/MM/yyyy hh:mm:ss zzz ap")
+ << (uint)QDateTimeEdit::YearSection << (uint)QDateTimeEdit::YearSection;
+ QTest::newRow("data9") << QString("dd/MM/yyyy hh:mm:ss zzz AP")
+ << (uint)QDateTimeEdit::AmPmSection << (uint)QDateTimeEdit::AmPmSection;
+ QTest::newRow("data10") << QString("dd/MM/yyyy hh:mm:ss ap")
+ << (uint)QDateTimeEdit::MSecSection << (uint)QDateTimeEdit::DaySection;
+}
+
+void tst_QDateTimeEdit::currentSection()
+{
+ QFETCH(QString, format);
+ QFETCH(uint, section);
+ QFETCH(uint, currentSection);
+
+ testWidget->setDisplayFormat(format);
+ if ((QDateTimeEdit::Section)section == QDateTimeEdit::NoSection)
+ testWidget->setCurrentSection(QDateTimeEdit::YearSection); // Ensure it's not reset (see above)
+ testWidget->setCurrentSection((QDateTimeEdit::Section)section);
+ QVERIFY((QDateTimeEdit::Section)currentSection == testWidget->currentSection());
+}
+
+void tst_QDateTimeEdit::readOnly()
+{
+ testWidget->hide();
+ QDateTimeEdit dt(QDate(2000, 2, 1));
+ dt.setDisplayFormat("yyyy.MM.dd");
+ dt.show();
+ dt.setCurrentSection(QDateTimeEdit::DaySection);
+ QTest::keyClick(&dt, Qt::Key_Up);
+ QCOMPARE(dt.date(), QDate(2000, 2, 2));
+ dt.setReadOnly(true);
+ QTest::keyClick(&dt, Qt::Key_Up);
+ QCOMPARE(dt.date(), QDate(2000, 2, 2));
+ dt.stepBy(1); // stepBy should still work
+ QCOMPARE(dt.date(), QDate(2000, 2, 3));
+ dt.setReadOnly(false);
+ QTest::keyClick(&dt, Qt::Key_Up);
+ QCOMPARE(dt.date(), QDate(2000, 2, 4));
+}
+
+void tst_QDateTimeEdit::weirdCase()
+{
+ testWidget->lineEdit()->setCursorPosition(0);
+ testWidget->setDateRange(QDate(2005, 1, 1), QDate(2010, 12, 31));
+ testWidget->setDisplayFormat("dd//MM//yyyy");
+ testWidget->setDate(testWidget->minimumDate());
+ QTest::keyClick(testWidget, Qt::Key_Left);
+ QVERIFY(!testWidget->lineEdit()->hasSelectedText());
+ QCOMPARE(testWidget->lineEdit()->cursorPosition(), 0);
+ QTest::keyClick(testWidget, Qt::Key_Right);
+ QTest::keyClick(testWidget, Qt::Key_Right);
+ QTest::keyClick(testWidget, Qt::Key_Right);
+ QTest::keyClick(testWidget, Qt::Key_Right);
+ QTest::keyClick(testWidget, Qt::Key_Right);
+ QTest::keyClick(testWidget, Qt::Key_Right);
+ QVERIFY(!testWidget->lineEdit()->hasSelectedText());
+ QCOMPARE(testWidget->lineEdit()->cursorPosition(), 8);
+
+ QTest::keyClick(testWidget, Qt::Key_Delete);
+ QCOMPARE(testWidget->text(), QString("01//01//005"));
+ QTest::keyClick(testWidget, Qt::Key_4);
+ QCOMPARE(testWidget->text(), QString("01//01//005"));
+}
+
+void tst_QDateTimeEdit::newCase()
+{
+ if (QDate::shortMonthName(6) != "Jun" || QDate::shortMonthName(7) != "Jul" ||
+ QDate::longMonthName(6) != "June" || QDate::longMonthName(7) != "July")
+ QSKIP("This test only works in English", SkipAll);
+
+ testWidget->setDisplayFormat("MMMM'a'MbMMMcMM");
+ testWidget->setDate(QDate(2005, 6, 1));
+ QCOMPARE(testWidget->text(), QString("Junea6bJunc06"));
+#ifdef Q_WS_MAC
+ QTest::keyClick(testWidget, Qt::Key_Left, Qt::ControlModifier);
+#else
+ QTest::keyClick(testWidget, Qt::Key_Home);
+#endif
+ QTest::keyClick(testWidget, Qt::Key_Up);
+ QCOMPARE(testWidget->text(), QString("Julya7bJulc07"));
+ QCOMPARE(testWidget->lineEdit()->selectedText(), QString("July"));
+#ifdef Q_WS_MAC
+ QTest::keyClick(testWidget, Qt::Key_Left, Qt::ControlModifier);
+#else
+ QTest::keyClick(testWidget, Qt::Key_Home);
+#endif
+ QCOMPARE(testWidget->lineEdit()->selectedText(), QString());
+ QTest::keyClick(testWidget, Qt::Key_Right);
+ QTest::keyClick(testWidget, Qt::Key_Right);
+ QTest::keyClick(testWidget, Qt::Key_Right);
+ QTest::keyClick(testWidget, Qt::Key_Delete);
+ QTest::keyClick(testWidget, Qt::Key_Left);
+
+
+ QCOMPARE(testWidget->text(), QString("Jula7bJulc07"));
+ QTest::keyClick(testWidget, Qt::Key_Delete);
+ QCOMPARE(testWidget->text(), QString("Jua7bJulc07"));
+ QTest::keyClick(testWidget, Qt::Key_N);
+ QCOMPARE(testWidget->text(), QString("Juna7bJulc07"));
+ QTest::keyClick(testWidget, Qt::Key_E);
+ QCOMPARE(testWidget->text(), QString("Junea6bJunc06"));
+}
+
+void tst_QDateTimeEdit::newCase2()
+{
+ testWidget->setDisplayFormat("MMMM yyyy-MM-dd MMMM");
+ testWidget->setDate(QDate(2005, 8, 8));
+ QTest::keyClick(testWidget, Qt::Key_Return);
+ QTest::keyClick(testWidget, Qt::Key_Backspace);
+ QCOMPARE(testWidget->text(), QString(" 2005-08-08 ") + QDate::longMonthName(8));
+}
+
+void tst_QDateTimeEdit::newCase3()
+{
+ if (!QDate::longMonthName(1).startsWith("Januar"))
+ QSKIP("This test does not work in this locale", SkipAll);
+
+ testWidget->setDisplayFormat("dd MMMM yyyy");
+ testWidget->setDate(QDate(2000, 1, 1));
+ testWidget->setGeometry(QRect(QPoint(0, 0), testWidget->sizeHint()));
+ testWidget->setCurrentSection(QDateTimeEdit::MonthSection);
+ QTest::keyClick(testWidget, Qt::Key_Return);
+ QTest::keyClick(testWidget, Qt::Key_J);
+ QCOMPARE(testWidget->lineEdit()->displayText(), QString("01 J 2000"));
+ QCOMPARE(testWidget->lineEdit()->cursorPosition(), 4);
+ QTest::keyClick(testWidget, Qt::Key_A);
+ QTest::keyClick(testWidget, Qt::Key_N);
+ QTest::keyClick(testWidget, Qt::Key_U);
+ QTest::keyClick(testWidget, Qt::Key_A);
+ QTest::keyClick(testWidget, Qt::Key_R);
+}
+
+
+void tst_QDateTimeEdit::cursorPos()
+{
+ if (QDate::longMonthName(1) != "January")
+ QSKIP("This test only works in English", SkipAll);
+
+ testWidget->setDisplayFormat("dd MMMM yyyy");
+ //testWidget->setGeometry(0, 0, 200, 200);
+ testWidget->setCurrentSection(QDateTimeEdit::MonthSection);
+ QTest::keyClick(testWidget, Qt::Key_Return);
+ QCOMPARE(testWidget->lineEdit()->cursorPosition(), 10);
+ QTest::keyClick(testWidget, Qt::Key_J);
+ QTest::keyClick(testWidget, Qt::Key_A);
+ QTest::keyClick(testWidget, Qt::Key_N);
+ QTest::keyClick(testWidget, Qt::Key_U);
+ QTest::keyClick(testWidget, Qt::Key_A);
+ QTest::keyClick(testWidget, Qt::Key_R);
+ //QCursor::setPos(20, 20);
+ //QEventLoop l;
+ //l.exec();
+ QTest::keyClick(testWidget, Qt::Key_Y);
+ QCOMPARE(testWidget->lineEdit()->cursorPosition(), 11);
+#ifdef Q_WS_MAC
+ QTest::keyClick(testWidget, Qt::Key_Left, Qt::ControlModifier);
+#else
+ QTest::keyClick(testWidget, Qt::Key_Home);
+#endif
+ QTest::keyClick(testWidget, Qt::Key_Return);
+ QTest::keyClick(testWidget, Qt::Key_3);
+ QTest::keyClick(testWidget, Qt::Key_1);
+ QCOMPARE(testWidget->lineEdit()->cursorPosition(), 3);
+}
+
+void tst_QDateTimeEdit::newCase4()
+{
+ testWidget->setDisplayFormat("hh:mm");
+ testWidget->setMinimumTime(QTime(3, 3, 0));
+ QTest::keyClick(testWidget, Qt::Key_Return);
+ QTest::keyClick(testWidget, Qt::Key_0);
+ QCOMPARE(testWidget->lineEdit()->displayText(), QString("0:03"));
+ QTest::keyClick(testWidget, Qt::Key_2);
+ QCOMPARE(testWidget->lineEdit()->displayText(), QString("0:03"));
+ QTest::keyClick(testWidget, Qt::Key_4);
+ QCOMPARE(testWidget->lineEdit()->displayText(), QString("04:03"));
+}
+
+void tst_QDateTimeEdit::newCase5()
+{
+ testWidget->setDisplayFormat("yyyy-MM-dd hh:mm:ss zzz 'ms'");
+ testWidget->setDateTime(QDateTime(QDate(2005, 10, 7), QTime(17, 44, 13, 100)));
+ testWidget->show();
+ QCOMPARE(testWidget->lineEdit()->displayText(), QString("2005-10-07 17:44:13 100 ms"));
+#ifdef Q_WS_MAC
+ QTest::keyClick(testWidget, Qt::Key_Right, Qt::ControlModifier);
+#else
+ QTest::keyClick(testWidget, Qt::Key_End);
+#endif
+ QTest::keyClick(testWidget, Qt::Key_Backtab, Qt::ShiftModifier);
+
+ QTest::keyClick(testWidget, Qt::Key_Return);
+ QTest::keyClick(testWidget, Qt::Key_1);
+ QTest::keyClick(testWidget, Qt::Key_2);
+ QTest::keyClick(testWidget, Qt::Key_4);
+ QCOMPARE(testWidget->lineEdit()->displayText(), QString("2005-10-07 17:44:13 124 ms"));
+
+ QTest::keyClick(testWidget, Qt::Key_Backspace);
+ QCOMPARE(testWidget->lineEdit()->displayText(), QString("2005-10-07 17:44:13 12 ms"));
+}
+
+void tst_QDateTimeEdit::newCase6()
+{
+ testWidget->setDisplayFormat("d-yyyy-MM-dd");
+ testWidget->setDate(QDate(2005, 10, 7));
+ testWidget->show();
+ QCOMPARE(testWidget->lineEdit()->displayText(), QString("7-2005-10-07"));
+#ifdef Q_WS_MAC
+ QTest::keyClick(testWidget, Qt::Key_Left, Qt::ControlModifier);
+#else
+ QTest::keyClick(testWidget, Qt::Key_Home);
+#endif
+ QTest::keyClick(testWidget, Qt::Key_Return);
+ QTest::keyClick(testWidget, Qt::Key_1);
+ QTest::keyClick(testWidget, Qt::Key_2);
+ QCOMPARE(testWidget->lineEdit()->displayText(), QString("12-2005-10-12"));
+}
+
+
+void tst_QDateTimeEdit::task98554()
+{
+ testWidget->setDisplayFormat("mm.ss.zzz(ms)");
+ testWidget->setTime(QTime(0, 0, 9));
+ testWidget->setCurrentSection(QDateTimeEdit::SecondSection);
+ testWidget->show();
+ QCOMPARE(testWidget->lineEdit()->displayText(), QString("00.09.000(09)"));
+ QCOMPARE(testWidget->time(), QTime(0, 0, 9, 0));
+ QTest::keyClick(testWidget, Qt::Key_Up);
+ QCOMPARE(testWidget->lineEdit()->displayText(), QString("00.10.000(010)"));
+ QCOMPARE(testWidget->time(), QTime(0, 0, 10, 0));
+}
+
+static QList<int> makeList(int val1, int val2, int val3)
+{
+ QList<int> ret;
+ ret << val1 << val2 << val3;
+ return ret;
+}
+
+
+void tst_QDateTimeEdit::setCurrentSection_data()
+{
+ QTest::addColumn<QString>("format");
+ QTest::addColumn<QDateTime>("dateTime");
+ QTest::addColumn<QList<int> >("setCurrentSections");
+ QTest::addColumn<QList<int> >("expectedCursorPositions");
+
+ QTest::newRow("Day") << QString("dd/MM/yyyy hh:mm:ss.zzz d/M/yy h:m:s.z") << QDateTime(QDate(2001, 1, 1), QTime(1, 2, 3, 4))
+ << makeList(QDateTimeEdit::DaySection, QDateTimeEdit::DaySection, QDateTimeEdit::DaySection)
+ << makeList(24, 0, 24);
+ QTest::newRow("Month") << QString("dd/MM/yyyy hh:mm:ss.zzz d/M/yy h:m:s.z") << QDateTime(QDate(2001, 1, 1), QTime(1, 2, 3, 4))
+ << makeList(QDateTimeEdit::MonthSection, QDateTimeEdit::MonthSection, QDateTimeEdit::MonthSection)
+ << makeList(3, 26, 3);
+ QTest::newRow("Year") << QString("dd/MM/yyyy hh:mm:ss.zzz d/M/yy h:m:s.z") << QDateTime(QDate(2001, 1, 1), QTime(1, 2, 3, 4))
+ << makeList(QDateTimeEdit::YearSection, QDateTimeEdit::YearSection, QDateTimeEdit::YearSection)
+ << makeList(6, 28, 6);
+ QTest::newRow("Hour") << QString("dd/MM/yyyy hh:mm:ss.zzz d/M/yy h:m:s.z") << QDateTime(QDate(2001, 1, 1), QTime(1, 2, 3, 4))
+ << makeList(QDateTimeEdit::HourSection, QDateTimeEdit::HourSection, QDateTimeEdit::HourSection)
+ << makeList(11, 31, 11);
+ QTest::newRow("Minute") << QString("dd/MM/yyyy hh:mm:ss.zzz d/M/yy h:m:s.z") << QDateTime(QDate(2001, 1, 1), QTime(1, 2, 3, 4))
+ << makeList(QDateTimeEdit::MinuteSection, QDateTimeEdit::MinuteSection, QDateTimeEdit::MinuteSection)
+ << makeList(14, 33, 14);
+ QTest::newRow("Second") << QString("dd/MM/yyyy hh:mm:ss.zzz d/M/yy h:m:s.z") << QDateTime(QDate(2001, 1, 1), QTime(1, 2, 3, 4))
+ << makeList(QDateTimeEdit::SecondSection, QDateTimeEdit::SecondSection, QDateTimeEdit::SecondSection)
+ << makeList(17, 35, 17);
+ QTest::newRow("MSec") << QString("dd/MM/yyyy hh:mm:ss.zzz d/M/yy h:m:s.z") << QDateTime(QDate(2001, 1, 1), QTime(1, 2, 3, 4))
+ << makeList(QDateTimeEdit::MSecSection, QDateTimeEdit::MSecSection, QDateTimeEdit::MSecSection)
+ << makeList(20, 37, 20);
+}
+
+void tst_QDateTimeEdit::setCurrentSection()
+{
+ QFETCH(QString, format);
+ QFETCH(QDateTime, dateTime);
+ QFETCH(QList<int>, setCurrentSections);
+ QFETCH(QList<int>, expectedCursorPositions);
+
+ QCOMPARE(setCurrentSections.size(), expectedCursorPositions.size());
+ testWidget->setDisplayFormat(format);
+ testWidget->setDateTime(dateTime);
+#ifdef Q_WS_MAC
+ QTest::keyClick(testWidget, Qt::Key_Left, Qt::ControlModifier);
+#else
+ QTest::keyClick(testWidget, Qt::Key_Home);
+#endif
+
+ testWidget->resize(400, 100);
+ for (int i=0; i<setCurrentSections.size(); ++i) {
+ testWidget->setCurrentSection((QDateTimeEdit::Section)setCurrentSections.at(i));
+ QCOMPARE(testWidget->currentSection(), (QDateTimeEdit::Section)setCurrentSections.at(i));
+ QCOMPARE(testWidget->lineEdit()->cursorPosition(), expectedCursorPositions.at(i));
+ }
+}
+
+
+void tst_QDateTimeEdit::setSelectedSection()
+{
+ testWidget->setDisplayFormat("mm.ss.zzz('ms') m");
+ testWidget->setTime(QTime(0, 0, 9));
+ testWidget->show();
+#ifdef Q_WS_MAC
+ QTest::keyClick(testWidget, Qt::Key_Left, Qt::ControlModifier);
+#else
+ QTest::keyClick(testWidget, Qt::Key_Home);
+#endif
+ QVERIFY(!testWidget->lineEdit()->hasSelectedText());
+ testWidget->setSelectedSection(QDateTimeEdit::MinuteSection);
+ QCOMPARE(testWidget->lineEdit()->selectedText(), QString("00"));
+ testWidget->setCurrentSection(QDateTimeEdit::MinuteSection);
+ testWidget->setSelectedSection(QDateTimeEdit::MinuteSection);
+ QCOMPARE(testWidget->lineEdit()->selectedText(), QString("0"));
+ testWidget->setSelectedSection(QDateTimeEdit::SecondSection);
+ QCOMPARE(testWidget->lineEdit()->selectedText(), QString("09"));
+ testWidget->setSelectedSection(QDateTimeEdit::NoSection);
+ QVERIFY(!testWidget->lineEdit()->hasSelectedText());
+}
+
+void tst_QDateTimeEdit::calendarPopup()
+{
+ {
+ QDateEdit edit;
+ QVERIFY(!edit.calendarWidget());
+ edit.setCalendarPopup(true);
+ QVERIFY(edit.calendarWidget());
+ }
+
+ {
+ QTimeEdit edit;
+ QVERIFY(!edit.calendarWidget());
+ edit.setCalendarPopup(true);
+ QVERIFY(!edit.calendarWidget());
+ }
+
+ {
+ QDateEdit edit;
+ QVERIFY(!edit.calendarWidget());
+ QCalendarWidget *cw = new QCalendarWidget;
+ edit.setCalendarWidget(cw);
+ QVERIFY(!edit.calendarWidget());
+ edit.setCalendarPopup(true);
+ edit.setCalendarWidget(cw);
+ QCOMPARE(edit.calendarWidget(), cw);
+ edit.setDateRange(QDate(1980, 1, 5), QDate(1980, 2, 11));
+ QCOMPARE(cw->minimumDate(), edit.minimumDate());
+ QCOMPARE(cw->maximumDate(), edit.maximumDate());
+ edit.setDate(QDate(1980, 1, 31));
+ QCOMPARE(edit.date(), cw->selectedDate());
+ cw->setSelectedDate(QDate(1980, 1, 30));
+ QCOMPARE(edit.date(), cw->selectedDate());
+ }
+
+ testWidget->setDisplayFormat("dd/MM/yyyy");
+ testWidget->setDateTime(QDateTime(QDate(2000, 1, 1), QTime(0, 0)));
+ testWidget->show();
+ testWidget->setCalendarPopup(true);
+ QCOMPARE(testWidget->calendarPopup(), true);
+ QStyle *style = testWidget->style();
+ QStyleOptionComboBox opt;
+ opt.initFrom(testWidget);
+ opt.editable = true;
+ opt.subControls = QStyle::SC_ComboBoxArrow;
+ QRect rect = style->subControlRect(QStyle::CC_ComboBox, &opt, QStyle::SC_ComboBoxArrow, testWidget);
+ QTest::mouseClick(testWidget, Qt::LeftButton, 0, QPoint(rect.left()+rect.width()/2, rect.top()+rect.height()/2));
+ QWidget *wid = qFindChild<QWidget *>(testWidget, "qt_datetimedit_calendar");
+ QVERIFY(wid != 0);
+ testWidget->hide();
+
+ QTimeEdit timeEdit;
+ timeEdit.setCalendarPopup(true);
+ timeEdit.show();
+
+ opt.initFrom(&timeEdit);
+ opt.subControls = QStyle::SC_ComboBoxArrow;
+ rect = style->subControlRect(QStyle::CC_ComboBox, &opt, QStyle::SC_ComboBoxArrow, &timeEdit);
+ QTest::mouseClick(&timeEdit, Qt::LeftButton, 0, QPoint(rect.left()+rect.width()/2, rect.top()+rect.height()/2));
+ QWidget *wid2 = qFindChild<QWidget *>(&timeEdit, "qt_datetimedit_calendar");
+ QVERIFY(wid2 == 0);
+ timeEdit.hide();
+
+
+ QDateEdit dateEdit;
+ dateEdit.setCalendarPopup(true);
+ dateEdit.setReadOnly(true);
+ dateEdit.show();
+
+ opt.initFrom(&dateEdit);
+ opt.subControls = QStyle::SC_ComboBoxArrow;
+ rect = style->subControlRect(QStyle::CC_ComboBox, &opt, QStyle::SC_ComboBoxArrow, &dateEdit);
+ QTest::mouseClick(&dateEdit, Qt::LeftButton, 0, QPoint(rect.left()+rect.width()/2, rect.top()+rect.height()/2));
+ QWidget *wid3 = qFindChild<QWidget *>(&dateEdit, "qt_datetimedit_calendar");
+ QVERIFY(wid3 == 0);
+ dateEdit.hide();
+
+}
+
+class RestoreLayoutDirectioner
+{
+public:
+ RestoreLayoutDirectioner(Qt::LayoutDirection was)
+ : old(was)
+ {}
+
+ ~RestoreLayoutDirectioner()
+ {
+ QApplication::setLayoutDirection(old);
+ }
+private:
+ const Qt::LayoutDirection old;
+};
+
+void tst_QDateTimeEdit::reverseTest()
+{
+ const RestoreLayoutDirectioner restorer(QApplication::layoutDirection());
+ QApplication::setLayoutDirection(Qt::RightToLeft);
+ testWidget->setDisplayFormat("dd/MM/yyyy");
+ testWidget->setDate(QDate(2001, 3, 30));
+ QCOMPARE(testWidget->lineEdit()->displayText(), QString("2001/03/30"));
+#ifdef Q_WS_MAC
+ QTest::keyClick(testWidget, Qt::Key_Right, Qt::ControlModifier);
+#else
+ QTest::keyClick(testWidget, Qt::Key_End);
+#endif
+ QCOMPARE(testWidget->currentSection(), QDateTimeEdit::DaySection);
+ QTest::keyClick(testWidget, Qt::Key_Up);
+ QCOMPARE(testWidget->date(), QDate(2001, 3, 31));
+ QCOMPARE(testWidget->lineEdit()->displayText(), QString("2001/03/31"));
+}
+
+
+void tst_QDateTimeEdit::hour12Test()
+{
+ testWidget->setDisplayFormat("hh a");
+ testWidget->setTime(QTime(0, 0, 0));
+ QCOMPARE(testWidget->lineEdit()->displayText(), QString("12 am"));
+ for (int i=0; i<11; ++i) {
+ QTest::keyClick(testWidget, Qt::Key_Up);
+ }
+ QCOMPARE(testWidget->lineEdit()->displayText(), QString("11 am"));
+ QTest::keyClick(testWidget, Qt::Key_Up);
+ QCOMPARE(testWidget->lineEdit()->displayText(), QString("12 pm"));
+ for (int i=0; i<11; ++i) {
+ QTest::keyClick(testWidget, Qt::Key_Up);
+ }
+ QCOMPARE(testWidget->lineEdit()->displayText(), QString("11 pm"));
+ QTest::keyClick(testWidget, Qt::Key_Up);
+ QCOMPARE(testWidget->lineEdit()->displayText(), QString("11 pm"));
+ for (int i=0; i<12; ++i) {
+ QTest::keyClick(testWidget, Qt::Key_Down);
+ }
+ QCOMPARE(testWidget->lineEdit()->displayText(), QString("11 am"));
+ QTest::keyClick(testWidget, Qt::Key_1);
+ QCOMPARE(testWidget->lineEdit()->displayText(), QString("1 am"));
+ QTest::keyClick(testWidget, Qt::Key_3);
+ QCOMPARE(testWidget->lineEdit()->displayText(), QString("1 am"));
+}
+
+void tst_QDateTimeEdit::yyTest()
+{
+ testWidget->setDisplayFormat("dd-MMM-yy");
+ testWidget->setTime(QTime(0, 0, 0));
+ testWidget->setDateRange(QDate(2005, 1, 1), QDate(2010, 12, 31));
+ testWidget->setDate(testWidget->minimumDate());
+ testWidget->setCurrentSection(QDateTimeEdit::YearSection);
+
+ QString jan = QDate::shortMonthName(1);
+ QCOMPARE(testWidget->lineEdit()->displayText(), "01-" + jan + "-05");
+ QTest::keyClick(testWidget, Qt::Key_Up);
+ QCOMPARE(testWidget->lineEdit()->displayText(), "01-" + jan + "-06");
+ QTest::keyClick(testWidget, Qt::Key_Up);
+ QCOMPARE(testWidget->lineEdit()->displayText(), "01-" + jan + "-07");
+ QTest::keyClick(testWidget, Qt::Key_Up);
+ QCOMPARE(testWidget->lineEdit()->displayText(), "01-" + jan + "-08");
+ QTest::keyClick(testWidget, Qt::Key_Up);
+ QCOMPARE(testWidget->lineEdit()->displayText(), "01-" + jan + "-09");
+ QTest::keyClick(testWidget, Qt::Key_Up);
+ QCOMPARE(testWidget->lineEdit()->displayText(), "01-" + jan + "-10");
+ QTest::keyClick(testWidget, Qt::Key_Up);
+ QCOMPARE(testWidget->lineEdit()->displayText(), "01-" + jan + "-10");
+ testWidget->setWrapping(true);
+ QTest::keyClick(testWidget, Qt::Key_Up);
+ QCOMPARE(testWidget->lineEdit()->displayText(), "01-" + jan + "-05");
+
+ testWidget->setDateRange(QDate(100, 1, 1), QDate(8000, 12, 31));
+ testWidget->setDate(QDate(2000, 1, 1));
+ testWidget->setCurrentSection(QDateTimeEdit::YearSection);
+ testWidget->setWrapping(false);
+ for (int i=0; i<10; ++i) {
+ for (int j=0; j<50; ++j) {
+ testWidget->stepBy(-1);
+ }
+ testWidget->stepBy(-50);
+ QCOMPARE(testWidget->sectionText(QDateTimeEdit::YearSection), QString("00"));
+ QCOMPARE(testWidget->date(), QDate(2000 - ((i + 1) * 100), 1, 1));
+ }
+}
+
+void tst_QDateTimeEdit::task108572()
+{
+ testWidget->setDisplayFormat("hh:mm:ss.zzz");
+ testWidget->setTime(QTime(0, 1, 2, 0));
+ QCOMPARE(testWidget->lineEdit()->displayText(), QString("00:01:02.000"));
+
+ testWidget->setCurrentSection(QDateTimeEdit::MSecSection);
+ QTest::keyClick(testWidget, Qt::Key_Return);
+ QCOMPARE(testWidget->lineEdit()->selectedText(), QString("000"));
+ QTest::keyClick(testWidget, Qt::Key_2);
+ QCOMPARE(testWidget->lineEdit()->displayText(), QString("00:01:02.2"));
+ QTest::keyClick(testWidget, Qt::Key_Return);
+ QCOMPARE(testWidget->lineEdit()->displayText(), QString("00:01:02.200"));
+ QCOMPARE(testWidget->lineEdit()->selectedText(), QString("200"));
+ QCOMPARE(testWidget->time(), QTime(0, 1, 2, 200));
+}
+
+void tst_QDateTimeEdit::task149097()
+{
+ QSignalSpy dtSpy(testWidget, SIGNAL(dateTimeChanged(const QDateTime &)));
+ QSignalSpy dSpy(testWidget, SIGNAL(dateChanged(const QDate &)));
+ QSignalSpy tSpy(testWidget, SIGNAL(timeChanged(const QTime &)));
+
+ testWidget->setDisplayFormat("yyyy/MM/dd hh:mm:ss");
+ testWidget->setDateTime(QDateTime(QDate(2001, 02, 03), QTime(5, 1, 2)));
+// QTest::keyClick(testWidget, Qt::Key_Enter);
+ QCOMPARE(dtSpy.count(), 1);
+ QCOMPARE(dSpy.count(), 1);
+ QCOMPARE(tSpy.count(), 1);
+ testWidget->setCurrentSection(QDateTimeEdit::YearSection);
+ testWidget->stepBy(1);
+
+ QCOMPARE(dtSpy.count(), 2);
+ QCOMPARE(dSpy.count(), 2);
+ QCOMPARE(tSpy.count(), 1);
+
+ testWidget->setCurrentSection(QDateTimeEdit::MinuteSection);
+ testWidget->stepBy(1);
+
+ QCOMPARE(dtSpy.count(), 3);
+ QCOMPARE(dSpy.count(), 2);
+ QCOMPARE(tSpy.count(), 2);
+}
+
+void tst_QDateTimeEdit::task148725()
+{
+ testWidget->setDisplayFormat("dd/MM");
+ testWidget->setDate(QDate(2001, 2, 27));
+ testWidget->stepBy(1);
+ QCOMPARE(testWidget->date(), QDate(2001, 2, 28));
+ testWidget->stepBy(1);
+ QCOMPARE(testWidget->date(), QDate(2001, 2, 28));
+ testWidget->setWrapping(true);
+ testWidget->stepBy(1);
+ QCOMPARE(testWidget->date(), QDate(2001, 2, 1));
+}
+
+void tst_QDateTimeEdit::task148522()
+{
+ QTimeEdit edit;
+ const QDateTime dt(QDate(2000, 12, 12), QTime(12, 13, 14, 15));
+ edit.setDateTime(dt);
+ QCOMPARE(edit.dateTime(), dt);
+}
+
+void tst_QDateTimeEdit::ddMMMMyyyy()
+{
+ testWidget->setDisplayFormat("dd.MMMM.yyyy");
+ testWidget->setDate(QDate(2000, 1, 1));
+ testWidget->setCurrentSection(QDateTimeEdit::YearSection);
+ QTest::keyClick(testWidget, Qt::Key_Enter);
+ QCOMPARE(testWidget->lineEdit()->selectedText(), QString("2000"));
+#ifdef Q_WS_MAC
+ QTest::keyClick(testWidget, Qt::Key_Right, Qt::ControlModifier);
+#else
+ QTest::keyClick(testWidget, Qt::Key_End);
+#endif
+ QTest::keyClick(testWidget, Qt::Key_Backspace);
+ QCOMPARE(testWidget->lineEdit()->text(), "01." + QDate::longMonthName(1) + ".200");
+}
+
+void tst_QDateTimeEdit::wheelEvent()
+{
+ testWidget->setDisplayFormat("dddd/MM");
+ testWidget->setDate(QDate(2000, 2, 21));
+ testWidget->setCurrentSection(QDateTimeEdit::DaySection);
+ QWheelEvent w(testWidget->lineEdit()->geometry().center(), 120, 0, 0);
+ qApp->sendEvent(testWidget, &w);
+ QCOMPARE(testWidget->date(), QDate(2000, 2, 22));
+ testWidget->setCurrentSection(QDateTimeEdit::MonthSection);
+ qApp->sendEvent(testWidget, &w);
+ QCOMPARE(testWidget->date(), QDate(2000, 3, 22));
+}
+
+void tst_QDateTimeEdit::specialValueCornerCase()
+{
+ // if you set minimum to value it won't update since value won't
+ // be bounded to anything. If you have a specialValueText it needs
+ // to call updateEdit to make sure the text is changed
+
+ QDateTimeEdit edit;
+ edit.setSpecialValueText("foobar");
+ edit.setMinimumDate(edit.date());
+ QCOMPARE(edit.minimumDate(), edit.date());
+ QCOMPARE(edit.text(), QString("foobar"));
+}
+
+void tst_QDateTimeEdit::cursorPositionOnInit()
+{
+ {
+ EditorDateEdit edit;
+ edit.setDisplayFormat("dd/MM");
+ edit.show();
+ QCOMPARE(edit.lineEdit()->cursorPosition(), 0);
+ }
+
+ {
+ EditorDateEdit edit;
+ edit.setDisplayFormat("dd/MM");
+ edit.setSpecialValueText("special");
+ edit.setMinimumDate(edit.date());
+ edit.show();
+ QCOMPARE(edit.lineEdit()->cursorPosition(), 7);
+ // ### legacy behavior. Keep it like this rather than changing
+ // ### but add a test none-the-less
+ }
+}
+
+void tst_QDateTimeEdit::task118867()
+{
+ EditorDateEdit edit;
+ edit.setDisplayFormat("hh:mm");
+ edit.setMinimumTime(QTime(5, 30));
+ edit.setMaximumTime(QTime(6, 30));
+ QCOMPARE(edit.text(), QString("05:30"));
+ edit.lineEdit()->setCursorPosition(5);
+ QTest::keyClick(&edit, Qt::Key_Backspace);
+ QCOMPARE(edit.text(), QString("05:3"));
+ QTest::keyClick(&edit, Qt::Key_Backspace);
+ QCOMPARE(edit.text(), QString("05:"));
+ QTest::keyClick(&edit, Qt::Key_1);
+ QCOMPARE(edit.text(), QString("05:"));
+ QTest::keyClick(&edit, Qt::Key_2);
+ QCOMPARE(edit.text(), QString("05:"));
+ QTest::keyClick(&edit, Qt::Key_3);
+ QCOMPARE(edit.text(), QString("05:3"));
+ QTest::keyClick(&edit, Qt::Key_3);
+ QCOMPARE(edit.text(), QString("05:33"));
+}
+
+void tst_QDateTimeEdit::nextPrevSection_data()
+{
+ QTest::addColumn<Qt::Key>("key");
+ QTest::addColumn<Qt::KeyboardModifiers>("modifiers");
+ QTest::addColumn<QString>("selectedText");
+
+ QTest::newRow("tab") << Qt::Key_Tab << (Qt::KeyboardModifiers)Qt::NoModifier << QString("56");
+ QTest::newRow("backtab") << Qt::Key_Backtab << (Qt::KeyboardModifiers)Qt::NoModifier << QString("12");
+ QTest::newRow("shift-tab") << Qt::Key_Tab << (Qt::KeyboardModifiers)Qt::ShiftModifier << QString("12");
+ QTest::newRow("/") << Qt::Key_Slash << (Qt::KeyboardModifiers)Qt::NoModifier << QString("56");
+ QTest::newRow("b") << Qt::Key_B << (Qt::KeyboardModifiers)Qt::NoModifier << QString("56");
+ QTest::newRow("c") << Qt::Key_C << (Qt::KeyboardModifiers)Qt::NoModifier << QString("56");
+
+ // 1. mac doesn't do these,
+ // 2. some WinCE devices do not have modifiers
+#if !defined(Q_OS_MAC) && !defined(WINCE_NO_MODIFIER_KEYS)
+ QTest::newRow("ctrl-right") << Qt::Key_Right << (Qt::KeyboardModifiers)Qt::ControlModifier << QString("56");
+ QTest::newRow("ctrl-left") << Qt::Key_Left << (Qt::KeyboardModifiers)Qt::ControlModifier << QString("12");
+#endif
+}
+
+
+void tst_QDateTimeEdit::nextPrevSection()
+{
+ QFETCH(Qt::Key, key);
+ QFETCH(Qt::KeyboardModifiers, modifiers);
+ QFETCH(QString, selectedText);
+
+ EditorDateEdit edit;
+ edit.setDisplayFormat("hh/mm/bc9ss");
+ edit.setTime(QTime(12, 34, 56));
+ edit.show();
+ edit.setSelectedSection(QDateTimeEdit::MinuteSection);
+ QCOMPARE(edit.lineEdit()->selectedText(), QString("34")); // selftest
+ QTest::keyClick(&edit, key, modifiers);
+ QCOMPARE(edit.lineEdit()->selectedText(), selectedText);
+}
+
+void tst_QDateTimeEdit::dateEditTimeEditFormats()
+{
+ QTimeEdit t;
+ t.setDisplayFormat("hh yyyy");
+ QCOMPARE(t.displayedSections(), QDateTimeEdit::HourSection);
+
+ QDateEdit d;
+ d.setDisplayFormat("hh yyyy");
+ QCOMPARE(d.displayedSections(), QDateTimeEdit::YearSection);
+}
+
+
+void tst_QDateTimeEdit::timeSpec_data()
+{
+ QTest::addColumn<bool>("useSetProperty");
+ QTest::newRow("setProperty") << true;
+ QTest::newRow("setTimeSpec") << false;
+}
+
+
+void tst_QDateTimeEdit::timeSpec()
+{
+ QFETCH(bool, useSetProperty);
+
+ QDateTimeEdit edit;
+ QCOMPARE(edit.dateTime().timeSpec(), edit.timeSpec());
+ QCOMPARE(edit.minimumDateTime().timeSpec(), edit.timeSpec());
+ QCOMPARE(edit.maximumDateTime().timeSpec(), edit.timeSpec());
+ if (useSetProperty) {
+ edit.setProperty("timeSpec", Qt::UTC);
+ } else {
+ edit.setTimeSpec(Qt::UTC);
+ }
+ QCOMPARE(edit.minimumDateTime().timeSpec(), edit.timeSpec());
+ QCOMPARE(edit.maximumDateTime().timeSpec(), edit.timeSpec());
+ QCOMPARE(edit.dateTime().timeSpec(), edit.timeSpec());
+ if (useSetProperty) {
+ edit.setProperty("timeSpec", Qt::LocalTime);
+ } else {
+ edit.setTimeSpec(Qt::LocalTime);
+ }
+ const QDateTime dt = edit.dateTime();
+ QCOMPARE(edit.timeSpec(), Qt::LocalTime);
+ const QDateTime utc = dt.toUTC();
+ if (dt.time() != utc.time()) {
+ const QDateTime min(QDate(1999, 1, 1), QTime(1, 0, 0), Qt::LocalTime);
+ edit.setMinimumDateTime(min);
+ QCOMPARE(edit.minimumTime(), min.time());
+ if (useSetProperty) {
+ edit.setProperty("timeSpec", Qt::UTC);
+ } else {
+ edit.setTimeSpec(Qt::UTC);
+ }
+ QVERIFY(edit.minimumTime() != min.time());
+ QVERIFY(edit.minimumDateTime().timeSpec() != min.timeSpec());
+ QCOMPARE(edit.minimumDateTime().toTime_t(), min.toTime_t());
+ } else {
+ QSKIP("Not tested in the GMT timezone", SkipAll);
+ }
+}
+
+void tst_QDateTimeEdit::timeSpecBug()
+{
+ testWidget->setTimeSpec(Qt::UTC);
+ testWidget->setDisplayFormat("hh:mm");
+ testWidget->setTime(QTime(2, 2));
+ const QString oldText = testWidget->text();
+ const QDateTime oldDateTime = testWidget->dateTime();
+ QTest::keyClick(testWidget, Qt::Key_Tab);
+ QCOMPARE(oldDateTime, testWidget->dateTime());
+ QCOMPARE(oldText, testWidget->text());
+}
+
+
+void tst_QDateTimeEdit::cachedDayTest()
+{
+ testWidget->setDisplayFormat("MM/dd");
+ testWidget->setDate(QDate(2007, 1, 30));
+ testWidget->setCurrentSection(QDateTimeEdit::DaySection);
+ //QTest::keyClick(testWidget->lineEdit(), Qt::Key_Up); // this doesn't work
+ //on Mac. QTestLib bug? ###
+ QTest::keyClick(testWidget, Qt::Key_Up);
+ testWidget->setCurrentSection(QDateTimeEdit::MonthSection);
+ QTest::keyClick(testWidget, Qt::Key_Up);
+ QCOMPARE(testWidget->date(), QDate(2007, 2, 28));
+ QTest::keyClick(testWidget, Qt::Key_Up);
+ QCOMPARE(testWidget->date(), QDate(2007, 3, 31));
+ QTest::keyClick(testWidget, Qt::Key_Down);
+ QCOMPARE(testWidget->date(), QDate(2007, 2, 28));
+ QTest::keyClick(testWidget, Qt::Key_Down);
+ QCOMPARE(testWidget->date(), QDate(2007, 1, 31));
+
+ testWidget->setCurrentSection(QDateTimeEdit::DaySection);
+ QTest::keyClick(testWidget, Qt::Key_Down);
+ QCOMPARE(testWidget->date(), QDate(2007, 1, 30));
+ testWidget->setCurrentSection(QDateTimeEdit::MonthSection);
+ QTest::keyClick(testWidget, Qt::Key_Up);
+ QCOMPARE(testWidget->date(), QDate(2007, 2, 28));
+ testWidget->setCurrentSection(QDateTimeEdit::MonthSection);
+ QTest::keyClick(testWidget, Qt::Key_Up);
+ QCOMPARE(testWidget->date(), QDate(2007, 3, 30));
+
+}
+
+void tst_QDateTimeEdit::monthEdgeCase()
+{
+ EditorDateEdit edit;
+ edit.setLocale(QLocale("fr_FR"));
+ edit.setDisplayFormat("MMM d");
+ edit.setDate(QDate(2000, 1, 1));
+ QCOMPARE(edit.text(), QString("janv. 1"));
+ edit.lineEdit()->setCursorPosition(5);
+ QTest::keyClick(&edit, Qt::Key_Backspace);
+ QCOMPARE(edit.text(), QString("janv 1"));
+}
+
+class RestoreLocaler
+{
+public:
+ RestoreLocaler()
+ : old(QLocale())
+ {}
+
+ ~RestoreLocaler()
+ {
+ QLocale::setDefault(old);
+ }
+private:
+ const QLocale old;
+};
+
+
+
+
+void tst_QDateTimeEdit::setLocale()
+{
+ RestoreLocaler r;
+ QLocale::setDefault(QLocale("en_US"));
+ {
+ EditorDateEdit edit;
+ edit.setDisplayFormat("MMMM d");
+ edit.setDate(QDate(2000, 1, 1));
+ QCOMPARE(edit.text(), QString("January 1"));
+ }
+ QLocale::setDefault(QLocale("no_NO"));
+ {
+ EditorDateEdit edit;
+ edit.setDisplayFormat("MMMM d");
+ edit.setDate(QDate(2000, 1, 1));
+ QCOMPARE(edit.text().toLower(), QString("januar 1"));
+ // I get Januar on Mac and januar on linux
+ }
+ QLocale::setDefault(QLocale("en_US"));
+ {
+ EditorDateEdit edit;
+ edit.setDisplayFormat("MMMM d");
+ edit.setDate(QDate(2000, 1, 1));
+ QCOMPARE(edit.text(), QString("January 1"));
+ edit.setLocale(QLocale("no_NO"));
+ QCOMPARE(edit.text().toLower(), QString("januar 1"));
+ edit.setLocale(QLocale("no_NO"));
+ }
+}
+
+
+void tst_QDateTimeEdit::potentialYYValueBug()
+{
+ EditorDateEdit edit;
+ edit.setDisplayFormat("dd/MM/yy");
+ QCOMPARE(edit.minimumDate(), QDate(1752, 9, 14));
+ edit.setDate(edit.minimumDate());
+ edit.lineEdit()->setFocus();
+
+#ifdef Q_WS_MAC
+ QTest::keyClick(&edit, Qt::Key_Right, Qt::ControlModifier);
+#else
+ QTest::keyClick(&edit, Qt::Key_End);
+#endif
+ QTest::keyClick(&edit, Qt::Key_Backspace);
+ QCOMPARE(edit.text(), QString("14/09/5"));
+}
+
+void tst_QDateTimeEdit::textSectionAtEnd()
+{
+ EditorDateEdit edit;
+ edit.setDisplayFormat("MMMM");
+ edit.setDate(QDate(2000, 1, 1));
+ edit.lineEdit()->setFocus();
+#ifdef Q_WS_MAC
+ QTest::keyClick(&edit, Qt::Key_Right, Qt::ControlModifier);
+#else
+ QTest::keyClick(&edit, Qt::Key_End);
+#endif
+ QTest::keyClick(&edit, Qt::Key_Backspace);
+ QCOMPARE(edit.text(), QString("Januar"));
+}
+
+void tst_QDateTimeEdit::keypadAutoAdvance_data()
+{
+ QTest::addColumn<Qt::KeyboardModifiers>("modifiers");
+ QTest::newRow("None") << (Qt::KeyboardModifiers)Qt::NoModifier;
+ QTest::newRow("Keypad") << (Qt::KeyboardModifiers)Qt::KeypadModifier;
+ // QTBUG-7842: Using KeyPad with shift (numlock off)
+ QTest::newRow("Keypad+Shift") << (Qt::KeyboardModifiers)(Qt::KeypadModifier|Qt::ShiftModifier);
+}
+
+
+void tst_QDateTimeEdit::keypadAutoAdvance()
+{
+ QFETCH(Qt::KeyboardModifiers, modifiers);
+
+ EditorDateEdit edit;
+ edit.setDate(QDate(2000, 2, 1));
+ edit.setDisplayFormat("dd/MM");
+#ifdef Q_WS_MAC
+ QTest::keyClick(&edit, Qt::Key_Left, Qt::ControlModifier);
+#else
+ QTest::keyClick(&edit, Qt::Key_Home);
+#endif
+ QTest::keyClick(&edit, Qt::Key_Return);
+ QCOMPARE(edit.lineEdit()->selectedText(), QString("01"));
+ QTest::keyClick(&edit, Qt::Key_1, modifiers);
+ QTest::keyClick(&edit, Qt::Key_2, modifiers);
+ QCOMPARE(edit.lineEdit()->selectedText(), QString("02"));
+}
+
+
+void tst_QDateTimeEdit::task196924()
+{
+ EditorDateEdit edit;
+ edit.setDisplayFormat("dd/M/yyyy");
+ edit.setDate(QDate(2345, 6, 17));
+ QCOMPARE(edit.text(), QString("17/6/2345"));
+ QTest::keyClick(&edit, Qt::Key_Tab);
+ QCOMPARE(edit.lineEdit()->selectedText(), QString("6"));
+ QTest::keyClick(&edit, Qt::Key_3);
+ QCOMPARE(edit.lineEdit()->selectedText(), QString("2345"));
+ QCOMPARE(edit.text(), QString("17/3/2345"));
+
+ edit.setDisplayFormat("dd/MM/yyyy");
+ edit.setDate(QDate(2345, 6, 17));
+ edit.lineEdit()->setCursorPosition(0);
+ QCOMPARE(edit.text(), QString("17/06/2345"));
+ QTest::keyClick(&edit, Qt::Key_Tab);
+ QCOMPARE(edit.lineEdit()->selectedText(), QString("06"));
+ QTest::keyClick(&edit, Qt::Key_3);
+ QCOMPARE(edit.lineEdit()->selectedText(), QString("2345"));
+ QCOMPARE(edit.text(), QString("17/03/2345"));
+
+}
+
+void tst_QDateTimeEdit::focusNextPrevChild()
+{
+ EditorDateEdit edit;
+ edit.setDisplayFormat("dd/MM/yyyy");
+
+ edit.show();
+ edit.setFocus();
+ edit.setCurrentSection(QDateTimeEdit::DaySection);
+
+ QCOMPARE(edit.currentSection(), QDateTimeEdit::DaySection);
+ edit.focusNextPrevChild(true);
+ QCOMPARE(edit.currentSection(), QDateTimeEdit::MonthSection);
+}
+
+void tst_QDateTimeEdit::taskQTBUG_12384_timeSpecShowTimeOnly()
+{
+ QDateTime time = QDateTime::fromString("20100723 04:02:40", "yyyyMMdd hh:mm:ss");
+ time.setTimeSpec(Qt::UTC);
+
+ EditorDateEdit edit;
+ edit.setDisplayFormat("hh:mm:ss");
+ edit.setTimeSpec(Qt::UTC);
+ edit.setDateTime(time);
+
+ QCOMPARE(edit.minimumTime(), QTime(0, 0, 0, 0));
+ QCOMPARE(edit.maximumTime(), QTime(23, 59, 59, 999));
+ QCOMPARE(edit.time(), time.time());
+}
+
+void tst_QDateTimeEdit::deleteCalendarWidget()
+{
+ {
+ // setup
+ QCalendarWidget *cw = 0;
+ QDateEdit edit;
+ QVERIFY(!edit.calendarWidget());
+ edit.setCalendarPopup(true);
+ QVERIFY(edit.calendarWidget());
+ edit.calendarWidget()->setObjectName("cw1");;
+
+ // delete
+ cw = edit.calendarWidget();
+ delete cw;
+
+ // it should create a new widget
+ QVERIFY(edit.calendarWidget());
+ QVERIFY(edit.calendarWidget()->objectName() != "cw1");
+ }
+}
+
+QTEST_MAIN(tst_QDateTimeEdit)
+#include "tst_qdatetimeedit.moc"
diff --git a/tests/auto/widgets/widgets/qdial/.gitignore b/tests/auto/widgets/widgets/qdial/.gitignore
new file mode 100644
index 0000000000..3a640cf1a1
--- /dev/null
+++ b/tests/auto/widgets/widgets/qdial/.gitignore
@@ -0,0 +1 @@
+tst_qdial
diff --git a/tests/auto/widgets/widgets/qdial/qdial.pro b/tests/auto/widgets/widgets/qdial/qdial.pro
new file mode 100644
index 0000000000..acf66de430
--- /dev/null
+++ b/tests/auto/widgets/widgets/qdial/qdial.pro
@@ -0,0 +1,5 @@
+load(qttest_p4)
+QT += widgets
+SOURCES += tst_qdial.cpp
+
+
diff --git a/tests/auto/widgets/widgets/qdial/tst_qdial.cpp b/tests/auto/widgets/widgets/qdial/tst_qdial.cpp
new file mode 100644
index 0000000000..568b82d28b
--- /dev/null
+++ b/tests/auto/widgets/widgets/qdial/tst_qdial.cpp
@@ -0,0 +1,211 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#include <QtTest/QtTest>
+
+#include <QDial>
+
+class tst_QDial : public QObject
+{
+ Q_OBJECT
+public:
+ tst_QDial();
+
+private slots:
+ void getSetCheck();
+ void valueChanged();
+ void sliderMoved();
+ void wrappingCheck();
+};
+
+// Testing get/set functions
+void tst_QDial::getSetCheck()
+{
+ QDial obj1;
+ // bool QDial::notchesVisible()
+ // void QDial::setNotchesVisible(bool)
+ obj1.setNotchesVisible(false);
+ QCOMPARE(false, obj1.notchesVisible());
+ obj1.setNotchesVisible(true);
+ QCOMPARE(true, obj1.notchesVisible());
+
+ // bool QDial::wrapping()
+ // void QDial::setWrapping(bool)
+ obj1.setWrapping(false);
+ QCOMPARE(false, obj1.wrapping());
+ obj1.setWrapping(true);
+ QCOMPARE(true, obj1.wrapping());
+}
+
+tst_QDial::tst_QDial()
+{
+}
+
+void tst_QDial::valueChanged()
+{
+ QDial dial;
+ dial.setMinimum(0);
+ dial.setMaximum(100);
+ QSignalSpy spy(&dial, SIGNAL(valueChanged(int)));
+ dial.setValue(50);
+ QCOMPARE(spy.count(), 1);
+ spy.clear();
+ dial.setValue(25);
+ QCOMPARE(spy.count(), 1);
+ spy.clear();
+ // repeat!
+ dial.setValue(25);
+ QCOMPARE(spy.count(), 0);
+}
+
+void tst_QDial::sliderMoved()
+{
+ //this tests that when dragging the arrow that the sliderMoved signal is emitted
+ //even if tracking is set to false
+ QDial dial;
+ dial.setTracking(false);
+ dial.setMinimum(0);
+ dial.setMaximum(100);
+
+ dial.show();
+
+ QPoint init(dial.width()/4, dial.height()/2);
+
+ QMouseEvent pressevent(QEvent::MouseButtonPress, init,
+ Qt::LeftButton, Qt::LeftButton, 0);
+ qApp->sendEvent(&dial, &pressevent);
+
+ QSignalSpy sliderspy(&dial, SIGNAL(sliderMoved(int)));
+ QSignalSpy valuespy(&dial, SIGNAL(valueChanged(int)));
+
+
+ { //move on top of the slider
+ init = QPoint(dial.width()/2, dial.height()/4);
+ QMouseEvent moveevent(QEvent::MouseMove, init,
+ Qt::LeftButton, Qt::LeftButton, 0);
+ qApp->sendEvent(&dial, &moveevent);
+ QCOMPARE( sliderspy.count(), 1);
+ QCOMPARE( valuespy.count(), 0);
+ }
+
+
+ { //move on the right of the slider
+ init = QPoint(dial.width()*3/4, dial.height()/2);
+ QMouseEvent moveevent(QEvent::MouseMove, init,
+ Qt::LeftButton, Qt::LeftButton, 0);
+ qApp->sendEvent(&dial, &moveevent);
+ QCOMPARE( sliderspy.count(), 2);
+ QCOMPARE( valuespy.count(), 0);
+ }
+
+ QMouseEvent releaseevent(QEvent::MouseButtonRelease, init,
+ Qt::LeftButton, Qt::LeftButton, 0);
+ qApp->sendEvent(&dial, &releaseevent);
+ QCOMPARE( valuespy.count(), 1); // valuechanged signal should be called at this point
+
+}
+
+void tst_QDial::wrappingCheck()
+{
+ //This tests if dial will wrap past the maximum value back to the minimum
+ //and vice versa when changing the value with a keypress
+ QDial dial;
+ dial.setMinimum(0);
+ dial.setMaximum(100);
+ dial.setSingleStep(1);
+ dial.setWrapping(true);
+ dial.setValue(99);
+ dial.show();
+
+ { //set value to maximum but do not wrap
+ QTest::keyPress(&dial, Qt::Key_Up);
+ QCOMPARE( dial.value(), 100);
+ }
+
+ { //step up once more and wrap clockwise to minimum + 1
+ QTest::keyPress(&dial, Qt::Key_Up);
+ QCOMPARE( dial.value(), 1);
+ }
+
+ { //step down once, and wrap anti-clockwise to minimum, then again to maximum - 1
+ QTest::keyPress(&dial, Qt::Key_Down);
+ QCOMPARE( dial.value(), 0);
+
+ QTest::keyPress(&dial, Qt::Key_Down);
+ QCOMPARE( dial.value(), 99);
+ }
+
+ { //when wrapping property is false no wrapping will occur
+ dial.setWrapping(false);
+ dial.setValue(100);
+
+ QTest::keyPress(&dial, Qt::Key_Up);
+ QCOMPARE( dial.value(), 100);
+
+ dial.setValue(0);
+ QTest::keyPress(&dial, Qt::Key_Down);
+ QCOMPARE( dial.value(), 0);
+ }
+
+ { //When the step is really big or small, wrapping should still behave
+ dial.setWrapping(true);
+ dial.setValue(dial.minimum());
+ dial.setSingleStep(305);
+
+ QTest::keyPress(&dial, Qt::Key_Up);
+ QCOMPARE( dial.value(), 5);
+
+ dial.setValue(dial.minimum());
+ QTest::keyPress(&dial, Qt::Key_Down);
+ QCOMPARE( dial.value(), 95);
+
+ dial.setMinimum(-30);
+ dial.setMaximum(-4);
+ dial.setSingleStep(200);
+ dial.setValue(dial.minimum());
+ QTest::keyPress(&dial, Qt::Key_Down);
+ QCOMPARE( dial.value(), -22);
+ }
+}
+
+QTEST_MAIN(tst_QDial)
+#include "tst_qdial.moc"
diff --git a/tests/auto/widgets/widgets/qdialogbuttonbox/.gitignore b/tests/auto/widgets/widgets/qdialogbuttonbox/.gitignore
new file mode 100644
index 0000000000..edf08554d4
--- /dev/null
+++ b/tests/auto/widgets/widgets/qdialogbuttonbox/.gitignore
@@ -0,0 +1 @@
+tst_qdialogbuttonbox
diff --git a/tests/auto/widgets/widgets/qdialogbuttonbox/qdialogbuttonbox.pro b/tests/auto/widgets/widgets/qdialogbuttonbox/qdialogbuttonbox.pro
new file mode 100644
index 0000000000..efbeca0c1b
--- /dev/null
+++ b/tests/auto/widgets/widgets/qdialogbuttonbox/qdialogbuttonbox.pro
@@ -0,0 +1,7 @@
+load(qttest_p4)
+QT += widgets
+SOURCES += tst_qdialogbuttonbox.cpp
+
+TARGET = tst_qdialogbuttonbox
+
+
diff --git a/tests/auto/widgets/widgets/qdialogbuttonbox/tst_qdialogbuttonbox.cpp b/tests/auto/widgets/widgets/qdialogbuttonbox/tst_qdialogbuttonbox.cpp
new file mode 100644
index 0000000000..449cc5e44d
--- /dev/null
+++ b/tests/auto/widgets/widgets/qdialogbuttonbox/tst_qdialogbuttonbox.cpp
@@ -0,0 +1,810 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <QtTest/QtTest>
+#include <QtWidgets/QPushButton>
+#include <QtWidgets/QStyle>
+#include <QtWidgets/QLayout>
+#include <QtWidgets/QDialog>
+#include <QtWidgets/QAction>
+#include <qdialogbuttonbox.h>
+#include <limits.h>
+
+//TESTED_CLASS=
+//TESTED_FILES=
+
+Q_DECLARE_METATYPE(QList<int>)
+Q_DECLARE_METATYPE(QDialogButtonBox::ButtonRole)
+Q_DECLARE_METATYPE(QDialogButtonBox::StandardButton)
+Q_DECLARE_METATYPE(QDialogButtonBox::StandardButtons)
+Q_DECLARE_METATYPE(QAbstractButton*)
+
+class tst_QDialogButtonBox : public QObject
+{
+ Q_OBJECT
+public:
+ tst_QDialogButtonBox();
+ ~tst_QDialogButtonBox();
+
+
+public slots:
+ void buttonClicked1(QAbstractButton *);
+ void acceptClicked();
+ void rejectClicked();
+ void helpRequestedClicked();
+
+private slots:
+ void standardButtons();
+ void testConstructor1();
+ void testConstrurtor2();
+ void testConstrurtor2_data();
+ void testConstructor3();
+ void testConstructor3_data();
+ void setOrientation_data();
+ void setOrientation();
+ void addButton1_data();
+ void addButton1();
+ void addButton2_data();
+ void addButton2();
+ void addButton3_data();
+ void addButton3();
+ void clear_data();
+ void clear();
+ void removeButton_data();
+ void removeButton();
+ void buttonRole_data();
+ void buttonRole();
+ void setStandardButtons_data();
+ void setStandardButtons();
+ void layoutReuse();
+
+
+ // Skip these tests, buttons is used in every test thus far.
+// void buttons_data();
+// void buttons();
+
+ void testDelete();
+ void testRemove();
+ void testMultipleAdd();
+ void testStandardButtonMapping_data();
+ void testStandardButtonMapping();
+ void testSignals_data();
+ void testSignals();
+ void testSignalOrder();
+ void testDefaultButton_data();
+ void testDefaultButton();
+#ifdef QT_SOFTKEYS_ENABLED
+ void testSoftKeyReparenting();
+#endif
+
+ void task191642_default();
+private:
+ qint64 timeStamp;
+ qint64 buttonClicked1TimeStamp;
+ qint64 acceptTimeStamp;
+ qint64 rejectTimeStamp;
+ qint64 helpRequestedTimeStamp;
+};
+
+tst_QDialogButtonBox::tst_QDialogButtonBox()
+{
+}
+
+tst_QDialogButtonBox::~tst_QDialogButtonBox()
+{
+}
+
+void tst_QDialogButtonBox::testConstructor1()
+{
+ QDialogButtonBox buttonbox;
+ QCOMPARE(buttonbox.orientation(), Qt::Horizontal);
+
+ QCOMPARE(buttonbox.buttons().count(), 0);
+}
+
+void tst_QDialogButtonBox::layoutReuse()
+{
+ QDialogButtonBox *box = new QDialogButtonBox(QDialogButtonBox::Ok);
+ QPointer<QLayout> layout = box->layout();
+ box->setCenterButtons(!box->centerButtons());
+ QVERIFY(layout == box->layout());
+ QEvent event(QEvent::StyleChange);
+ QApplication::sendEvent(box, &event);
+ QVERIFY(layout == box->layout());
+ box->setOrientation(box->orientation() == Qt::Horizontal ? Qt::Vertical : Qt::Horizontal);
+ QVERIFY(layout == 0);
+ QVERIFY(layout != box->layout());
+ delete box;
+}
+
+void tst_QDialogButtonBox::testConstrurtor2_data()
+{
+ QTest::addColumn<int>("orientation");
+
+ QTest::newRow("horizontal") << int(Qt::Horizontal);
+ QTest::newRow("vertical") << int(Qt::Vertical);
+}
+
+void tst_QDialogButtonBox::testConstrurtor2()
+{
+ QFETCH(int, orientation);
+ Qt::Orientation orient = Qt::Orientation(orientation);
+ QDialogButtonBox buttonBox(orient);
+
+ QCOMPARE(buttonBox.orientation(), orient);
+ QCOMPARE(buttonBox.buttons().count(), 0);
+}
+
+void tst_QDialogButtonBox::testConstructor3_data()
+{
+ QTest::addColumn<int>("orientation");
+ QTest::addColumn<QDialogButtonBox::StandardButtons>("buttons");
+ QTest::addColumn<int>("buttonCount");
+
+ QTest::newRow("nothing") << int(Qt::Horizontal) << (QDialogButtonBox::StandardButtons)0 << 0;
+ QTest::newRow("only 1") << int(Qt::Horizontal) << QDialogButtonBox::StandardButtons(QDialogButtonBox::Ok) << 1;
+ QTest::newRow("only 1.. twice") << int(Qt::Horizontal)
+ << (QDialogButtonBox::Ok | QDialogButtonBox::Ok)
+ << 1;
+ QTest::newRow("only 2") << int(Qt::Horizontal)
+ << (QDialogButtonBox::Ok | QDialogButtonBox::Cancel)
+ << 2;
+ QTest::newRow("two different things") << int(Qt::Horizontal)
+ << (QDialogButtonBox::Save | QDialogButtonBox::Close)
+ << 2;
+ QTest::newRow("three") << int(Qt::Horizontal)
+ << (QDialogButtonBox::Ok
+ | QDialogButtonBox::Cancel
+ | QDialogButtonBox::Help)
+ << 3;
+ QTest::newRow("everything") << int(Qt::Vertical)
+ << (QDialogButtonBox::StandardButtons)UINT_MAX
+ << 18;
+}
+
+void tst_QDialogButtonBox::testConstructor3()
+{
+ QFETCH(int, orientation);
+ QFETCH(QDialogButtonBox::StandardButtons, buttons);
+
+ QDialogButtonBox buttonBox(buttons, (Qt::Orientation)orientation);
+ QCOMPARE(int(buttonBox.orientation()), orientation);
+ QTEST(buttonBox.buttons().count(), "buttonCount");
+}
+
+void tst_QDialogButtonBox::setOrientation_data()
+{
+ QTest::addColumn<int>("orientation");
+
+ QTest::newRow("Horizontal") << int(Qt::Horizontal);
+ QTest::newRow("Vertical") << int(Qt::Vertical);
+}
+
+void tst_QDialogButtonBox::setOrientation()
+{
+ QFETCH(int, orientation);
+ QDialogButtonBox buttonBox;
+ QCOMPARE(int(buttonBox.orientation()), int(Qt::Horizontal));
+
+ buttonBox.setOrientation(Qt::Orientation(orientation));
+ QCOMPARE(int(buttonBox.orientation()), orientation);
+}
+
+/*
+void tst_QDialogButtonBox::setLayoutPolicy_data()
+{
+ QTest::addColumn<int>("layoutPolicy");
+
+ QTest::newRow("win") << int(QDialogButtonBox::WinLayout);
+ QTest::newRow("mac") << int(QDialogButtonBox::MacLayout);
+ QTest::newRow("kde") << int(QDialogButtonBox::KdeLayout);
+ QTest::newRow("gnome") << int(QDialogButtonBox::GnomeLayout);
+
+}
+
+void tst_QDialogButtonBox::setLayoutPolicy()
+{
+ QFETCH(int, layoutPolicy);
+
+ QDialogButtonBox buttonBox;
+ QCOMPARE(int(buttonBox.layoutPolicy()),
+ int(buttonBox.style()->styleHint(QStyle::SH_DialogButtonLayout)));
+ buttonBox.setLayoutPolicy(QDialogButtonBox::ButtonLayout(layoutPolicy));
+ QCOMPARE(int(buttonBox.layoutPolicy()), layoutPolicy);
+}
+*/
+
+void tst_QDialogButtonBox::addButton1_data()
+{
+ QTest::addColumn<QDialogButtonBox::ButtonRole>("role");
+ QTest::addColumn<int>("totalCount");
+
+ QTest::newRow("InvalidRole") << QDialogButtonBox::InvalidRole << 0;
+ QTest::newRow("AcceptRole") << QDialogButtonBox::AcceptRole << 1;
+ QTest::newRow("RejectRole") << QDialogButtonBox::RejectRole << 1;
+ QTest::newRow("DestructiveRole") << QDialogButtonBox::DestructiveRole << 1;
+ QTest::newRow("ActionRole") << QDialogButtonBox::ActionRole << 1;
+ QTest::newRow("HelpRole") << QDialogButtonBox::HelpRole << 1;
+ QTest::newRow("WackyValue") << (QDialogButtonBox::ButtonRole)-1 << 0;
+}
+
+void tst_QDialogButtonBox::addButton1()
+{
+ QFETCH(QDialogButtonBox::ButtonRole, role);
+ QDialogButtonBox buttonBox;
+ QCOMPARE(buttonBox.buttons().count(), 0);
+ QPushButton *button = new QPushButton();
+ buttonBox.addButton(button, role);
+ QTEST(buttonBox.buttons().count(), "totalCount");
+ QList<QAbstractButton *> children = qFindChildren<QAbstractButton *>(&buttonBox);
+ QTEST(children.count(), "totalCount");
+ delete button;
+}
+
+void tst_QDialogButtonBox::addButton2_data()
+{
+ QTest::addColumn<QString>("text");
+ QTest::addColumn<QDialogButtonBox::ButtonRole>("role");
+ QTest::addColumn<int>("totalCount");
+ QTest::newRow("InvalidRole") << QString("foo") << QDialogButtonBox::InvalidRole << 0;
+ QTest::newRow("AcceptRole") << QString("foo") << QDialogButtonBox::AcceptRole << 1;
+ QTest::newRow("RejectRole") << QString("foo") << QDialogButtonBox::RejectRole << 1;
+ QTest::newRow("DestructiveRole") << QString("foo") << QDialogButtonBox::DestructiveRole << 1;
+ QTest::newRow("ActionRole") << QString("foo") << QDialogButtonBox::ActionRole << 1;
+ QTest::newRow("HelpRole") << QString("foo") << QDialogButtonBox::HelpRole << 1;
+ QTest::newRow("WackyValue") << QString("foo") << (QDialogButtonBox::ButtonRole)-1 << 0;
+}
+
+void tst_QDialogButtonBox::addButton2()
+{
+ QFETCH(QString, text);
+ QFETCH(QDialogButtonBox::ButtonRole, role);
+ QDialogButtonBox buttonBox;
+ QCOMPARE(buttonBox.buttons().count(), 0);
+ buttonBox.addButton(text, role);
+ QTEST(buttonBox.buttons().count(), "totalCount");
+ QList<QAbstractButton *> children = qFindChildren<QAbstractButton *>(&buttonBox);
+ QTEST(children.count(), "totalCount");
+}
+
+void tst_QDialogButtonBox::addButton3_data()
+{
+ QTest::addColumn<QDialogButtonBox::StandardButton>("button");
+ QTest::addColumn<int>("totalCount");
+ QTest::newRow("Ok") << QDialogButtonBox::Ok << 1;
+ QTest::newRow("Open") << QDialogButtonBox::Open << 1;
+ QTest::newRow("Save") << QDialogButtonBox::Save << 1;
+ QTest::newRow("Cancel") << QDialogButtonBox::Cancel << 1;
+ QTest::newRow("Close") << QDialogButtonBox::Close << 1;
+ QTest::newRow("Discard") << QDialogButtonBox::Discard << 1;
+ QTest::newRow("Apply") << QDialogButtonBox::Apply << 1;
+ QTest::newRow("Reset") << QDialogButtonBox::Reset << 1;
+ QTest::newRow("Help") << QDialogButtonBox::Help << 1;
+ QTest::newRow("noButton") << (QDialogButtonBox::StandardButton)0 << 0;
+}
+
+void tst_QDialogButtonBox::addButton3()
+{
+ QFETCH(QDialogButtonBox::StandardButton, button);
+ QDialogButtonBox buttonBox;
+ QCOMPARE(buttonBox.buttons().count(), 0);
+ buttonBox.addButton(button);
+ QTEST(buttonBox.buttons().count(), "totalCount");
+ QList<QAbstractButton *> children = qFindChildren<QAbstractButton *>(&buttonBox);
+ QTEST(children.count(), "totalCount");
+}
+
+void tst_QDialogButtonBox::clear_data()
+{
+ QTest::addColumn<int>("rolesToAdd");
+
+ QTest::newRow("nothing") << 0;
+ QTest::newRow("one") << 1;
+ QTest::newRow("all") << int(QDialogButtonBox::NRoles);
+}
+
+void tst_QDialogButtonBox::clear()
+{
+ QFETCH(int, rolesToAdd);
+
+ QDialogButtonBox buttonBox;
+ for (int i = 1; i < rolesToAdd; ++i)
+ buttonBox.addButton("Happy", QDialogButtonBox::ButtonRole(i));
+ buttonBox.clear();
+ QCOMPARE(buttonBox.buttons().count(), 0);
+ QList<QAbstractButton *> children = qFindChildren<QAbstractButton *>(&buttonBox);
+ QCOMPARE(children.count(), 0);
+}
+
+void tst_QDialogButtonBox::removeButton_data()
+{
+ QTest::addColumn<QDialogButtonBox::ButtonRole>("roleToAdd");
+ QTest::addColumn<int>("expectedCount");
+ QTest::newRow("no button added") << QDialogButtonBox::InvalidRole << 0;
+ QTest::newRow("a button") << QDialogButtonBox::AcceptRole << 1;
+}
+
+void tst_QDialogButtonBox::removeButton()
+{
+ QFETCH(QDialogButtonBox::ButtonRole, roleToAdd);
+
+ QDialogButtonBox buttonBox;
+ QCOMPARE(buttonBox.buttons().count(), 0);
+ QPushButton *button = new QPushButton("RemoveButton test");
+ buttonBox.addButton(button, roleToAdd);
+ QTEST(buttonBox.buttons().count(), "expectedCount");
+
+ buttonBox.removeButton(button);
+ QCOMPARE(buttonBox.buttons().count(), 0);
+ delete button;
+}
+
+void tst_QDialogButtonBox::testDelete()
+{
+ QDialogButtonBox buttonBox;
+ QCOMPARE(buttonBox.buttons().count(), 0);
+
+ QPushButton *deleteMe = new QPushButton("Happy");
+ buttonBox.addButton(deleteMe, QDialogButtonBox::HelpRole);
+ QCOMPARE(buttonBox.buttons().count(), 1);
+ QList<QAbstractButton *> children = qFindChildren<QAbstractButton *>(&buttonBox);
+ QCOMPARE(children.count(), 1);
+
+ delete deleteMe;
+ children = qFindChildren<QAbstractButton *>(&buttonBox);
+ QCOMPARE(children.count(), 0);
+ QCOMPARE(buttonBox.buttons().count(), 0);
+}
+
+void tst_QDialogButtonBox::testMultipleAdd()
+{
+ // Add a button into the thing multiple times.
+ QDialogButtonBox buttonBox;
+ QCOMPARE(buttonBox.buttons().count(), 0);
+
+ QPushButton *button = new QPushButton("Foo away");
+ buttonBox.addButton(button, QDialogButtonBox::AcceptRole);
+ QCOMPARE(buttonBox.buttons().count(), 1);
+ QCOMPARE(buttonBox.buttonRole(button), QDialogButtonBox::AcceptRole);
+ buttonBox.addButton(button, QDialogButtonBox::AcceptRole);
+ QCOMPARE(buttonBox.buttons().count(), 1);
+ QCOMPARE(buttonBox.buttonRole(button), QDialogButtonBox::AcceptRole);
+
+ // Add it again with a different role
+ buttonBox.addButton(button, QDialogButtonBox::RejectRole);
+ QCOMPARE(buttonBox.buttons().count(), 1);
+ QCOMPARE(buttonBox.buttonRole(button), QDialogButtonBox::RejectRole);
+
+ // Add it as an "invalid" role
+ buttonBox.addButton(button, QDialogButtonBox::InvalidRole);
+ QCOMPARE(buttonBox.buttons().count(), 1);
+ QCOMPARE(buttonBox.buttonRole(button), QDialogButtonBox::RejectRole);
+}
+
+void tst_QDialogButtonBox::buttonRole_data()
+{
+ QTest::addColumn<QDialogButtonBox::ButtonRole>("roleToAdd");
+ QTest::addColumn<QDialogButtonBox::ButtonRole>("expectedRole");
+
+ QTest::newRow("AcceptRole stuff") << QDialogButtonBox::AcceptRole
+ << QDialogButtonBox::AcceptRole;
+ QTest::newRow("Nothing") << QDialogButtonBox::InvalidRole << QDialogButtonBox::InvalidRole;
+ QTest::newRow("bad stuff") << (QDialogButtonBox::ButtonRole)-1 << QDialogButtonBox::InvalidRole;
+}
+
+void tst_QDialogButtonBox::buttonRole()
+{
+ QFETCH(QDialogButtonBox::ButtonRole, roleToAdd);
+ QDialogButtonBox buttonBox;
+ QAbstractButton *button = buttonBox.addButton("Here's a button", roleToAdd);
+ QTEST(buttonBox.buttonRole(button), "expectedRole");
+}
+
+void tst_QDialogButtonBox::testStandardButtonMapping_data()
+{
+ QTest::addColumn<QDialogButtonBox::StandardButton>("button");
+ QTest::addColumn<QDialogButtonBox::ButtonRole>("expectedRole");
+ QTest::addColumn<QString>("expectedText");
+
+ int layoutPolicy = qApp->style()->styleHint(QStyle::SH_DialogButtonLayout);
+
+ QTest::newRow("QDialogButtonBox::Ok") << QDialogButtonBox::Ok
+ << QDialogButtonBox::AcceptRole
+ << QDialogButtonBox::tr("OK");
+ QTest::newRow("QDialogButtonBox::Open") << QDialogButtonBox::Open
+ << QDialogButtonBox::AcceptRole
+ << QDialogButtonBox::tr("Open");
+ QTest::newRow("QDialogButtonBox::Save") << QDialogButtonBox::Save
+ << QDialogButtonBox::AcceptRole
+ << QDialogButtonBox::tr("Save");
+ QTest::newRow("QDialogButtonBox::Cancel") << QDialogButtonBox::Cancel
+ << QDialogButtonBox::RejectRole
+ << QDialogButtonBox::tr("Cancel");
+ QTest::newRow("QDialogButtonBox::Close") << QDialogButtonBox::Close
+ << QDialogButtonBox::RejectRole
+ << QDialogButtonBox::tr("Close");
+ if (layoutPolicy == QDialogButtonBox::MacLayout) {
+ QTest::newRow("QDialogButtonBox::Discard") << QDialogButtonBox::Discard
+ << QDialogButtonBox::DestructiveRole
+ << QDialogButtonBox::tr("Don't Save");
+ } else if (layoutPolicy == QDialogButtonBox::GnomeLayout) {
+ QTest::newRow("QDialogButtonBox::Discard")
+ << QDialogButtonBox::Discard
+ << QDialogButtonBox::DestructiveRole
+ << QDialogButtonBox::tr("Close without Saving");
+ } else {
+ QTest::newRow("QDialogButtonBox::Discard") << QDialogButtonBox::Discard
+ << QDialogButtonBox::DestructiveRole
+ << QDialogButtonBox::tr("Discard");
+ }
+ QTest::newRow("QDialogButtonBox::Apply") << QDialogButtonBox::Apply
+ << QDialogButtonBox::ApplyRole
+ << QDialogButtonBox::tr("Apply");
+ QTest::newRow("QDialogButtonBox::Reset") << QDialogButtonBox::Reset
+ << QDialogButtonBox::ResetRole
+ << QDialogButtonBox::tr("Reset");
+ QTest::newRow("QDialogButtonBox::Help") << QDialogButtonBox::Help
+ << QDialogButtonBox::HelpRole
+ << QDialogButtonBox::tr("Help");
+}
+
+void tst_QDialogButtonBox::testStandardButtonMapping()
+{
+ QFETCH(QDialogButtonBox::StandardButton, button);
+ QDialogButtonBox buttonBox;
+
+ QAbstractButton *theButton = buttonBox.addButton(button);
+ QTEST(buttonBox.buttonRole(theButton), "expectedRole");
+ QString textWithoutMnemonic = theButton->text().remove("&");
+ QTEST(textWithoutMnemonic, "expectedText");
+}
+
+void tst_QDialogButtonBox::testSignals_data()
+{
+ QTest::addColumn<QDialogButtonBox::ButtonRole>("buttonToClick");
+ QTest::addColumn<int>("clicked2Count");
+ QTest::addColumn<int>("acceptCount");
+ QTest::addColumn<int>("rejectCount");
+ QTest::addColumn<int>("helpRequestedCount");
+
+ QTest::newRow("nothing") << QDialogButtonBox::InvalidRole << 0 << 0 << 0 << 0;
+ QTest::newRow("accept") << QDialogButtonBox::AcceptRole << 1 << 1 << 0 << 0;
+ QTest::newRow("reject") << QDialogButtonBox::RejectRole << 1 << 0 << 1 << 0;
+ QTest::newRow("destructive") << QDialogButtonBox::DestructiveRole << 1 << 0 << 0 << 0;
+ QTest::newRow("Action") << QDialogButtonBox::ActionRole << 1 << 0 << 0 << 0;
+ QTest::newRow("Help") << QDialogButtonBox::HelpRole << 1 << 0 << 0 << 1;
+}
+
+void tst_QDialogButtonBox::testSignals()
+{
+ QFETCH(QDialogButtonBox::ButtonRole, buttonToClick);
+ QDialogButtonBox buttonBox;
+ qRegisterMetaType<QAbstractButton *>("QAbstractButton*");
+ QSignalSpy clicked2(&buttonBox, SIGNAL(clicked(QAbstractButton*)));
+ QSignalSpy accept(&buttonBox, SIGNAL(accepted()));
+ QSignalSpy reject(&buttonBox, SIGNAL(rejected()));
+ QSignalSpy helpRequested(&buttonBox, SIGNAL(helpRequested()));
+
+ QPushButton *clickMe = 0;
+ for (int i = QDialogButtonBox::AcceptRole; i < QDialogButtonBox::NRoles; ++i) {
+ QPushButton *button = buttonBox.addButton(QString::number(i),
+ QDialogButtonBox::ButtonRole(i));
+
+ if (i == buttonToClick)
+ clickMe = button;
+ }
+ if (clickMe) {
+ clickMe->animateClick(0);
+ QTest::qWait(100);
+ }
+
+ QTEST(clicked2.count(), "clicked2Count");
+ if (clicked2.count() > 0)
+ QCOMPARE(qvariant_cast<QAbstractButton *>(clicked2.at(0).at(0)), (QAbstractButton *)clickMe);
+
+ QTEST(accept.count(), "acceptCount");
+ QTEST(reject.count(), "rejectCount");
+ QTEST(helpRequested.count(), "helpRequestedCount");
+}
+
+void tst_QDialogButtonBox::testSignalOrder()
+{
+ const qint64 longLongZero = 0;
+ buttonClicked1TimeStamp = acceptTimeStamp
+ = rejectTimeStamp = helpRequestedTimeStamp = timeStamp = 0;
+ QDialogButtonBox buttonBox;
+ connect(&buttonBox, SIGNAL(clicked(QAbstractButton *)),
+ this, SLOT(buttonClicked1(QAbstractButton *)));
+ connect(&buttonBox, SIGNAL(accepted()), this, SLOT(acceptClicked()));
+ connect(&buttonBox, SIGNAL(rejected()), this, SLOT(rejectClicked()));
+ connect(&buttonBox, SIGNAL(helpRequested()), this, SLOT(helpRequestedClicked()));
+
+ QPushButton *acceptButton = buttonBox.addButton("OK", QDialogButtonBox::AcceptRole);
+ QPushButton *rejectButton = buttonBox.addButton("Cancel", QDialogButtonBox::RejectRole);
+ QPushButton *actionButton = buttonBox.addButton("Action This", QDialogButtonBox::ActionRole);
+ QPushButton *helpButton = buttonBox.addButton("Help Me!", QDialogButtonBox::HelpRole);
+
+ // Try accept
+ acceptButton->animateClick(0);
+ QTest::qWait(100);
+ QCOMPARE(rejectTimeStamp, longLongZero);
+ QCOMPARE(helpRequestedTimeStamp, longLongZero);
+
+ QVERIFY(buttonClicked1TimeStamp < acceptTimeStamp);
+ acceptTimeStamp = 0;
+
+ rejectButton->animateClick(0);
+ QTest::qWait(100);
+ QCOMPARE(acceptTimeStamp, longLongZero);
+ QCOMPARE(helpRequestedTimeStamp, longLongZero);
+ QVERIFY(buttonClicked1TimeStamp < rejectTimeStamp);
+
+ rejectTimeStamp = 0;
+ actionButton->animateClick(0);
+ QTest::qWait(100);
+ QCOMPARE(acceptTimeStamp, longLongZero);
+ QCOMPARE(rejectTimeStamp, longLongZero);
+ QCOMPARE(helpRequestedTimeStamp, longLongZero);
+
+ helpButton->animateClick(0);
+ QTest::qWait(100);
+ QCOMPARE(acceptTimeStamp, longLongZero);
+ QCOMPARE(rejectTimeStamp, longLongZero);
+ QVERIFY(buttonClicked1TimeStamp < helpRequestedTimeStamp);
+}
+
+void tst_QDialogButtonBox::buttonClicked1(QAbstractButton *)
+{
+ buttonClicked1TimeStamp = ++timeStamp;
+}
+
+void tst_QDialogButtonBox::acceptClicked()
+{
+ acceptTimeStamp = ++timeStamp;
+}
+
+void tst_QDialogButtonBox::rejectClicked()
+{
+ rejectTimeStamp = ++timeStamp;
+}
+
+void tst_QDialogButtonBox::helpRequestedClicked()
+{
+ helpRequestedTimeStamp = ++timeStamp;
+}
+
+void tst_QDialogButtonBox::setStandardButtons_data()
+{
+ QTest::addColumn<QDialogButtonBox::StandardButtons>("buttonsToAdd");
+ QTest::addColumn<QDialogButtonBox::StandardButtons>("expectedResult");
+
+ QTest::newRow("Nothing") << QDialogButtonBox::StandardButtons(QDialogButtonBox::NoButton)
+ << QDialogButtonBox::StandardButtons(QDialogButtonBox::NoButton);
+ QTest::newRow("Everything") << (QDialogButtonBox::StandardButtons)0xffffffff
+ << (QDialogButtonBox::Ok
+ | QDialogButtonBox::Open
+ | QDialogButtonBox::Save
+ | QDialogButtonBox::Cancel
+ | QDialogButtonBox::Close
+ | QDialogButtonBox::Discard
+ | QDialogButtonBox::Apply
+ | QDialogButtonBox::Reset
+ | QDialogButtonBox::Help
+ | QDialogButtonBox::Yes
+ | QDialogButtonBox::YesToAll
+ | QDialogButtonBox::No
+ | QDialogButtonBox::NoToAll
+ | QDialogButtonBox::SaveAll
+ | QDialogButtonBox::Abort
+ | QDialogButtonBox::Retry
+ | QDialogButtonBox::Ignore
+ | QDialogButtonBox::RestoreDefaults
+ );
+ QTest::newRow("Simple thing") << QDialogButtonBox::StandardButtons(QDialogButtonBox::Help)
+ << QDialogButtonBox::StandardButtons(QDialogButtonBox::Help);
+ QTest::newRow("Standard thing") << (QDialogButtonBox::Ok | QDialogButtonBox::Cancel)
+ << (QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
+}
+
+void tst_QDialogButtonBox::setStandardButtons()
+{
+ QFETCH(QDialogButtonBox::StandardButtons, buttonsToAdd);
+ QDialogButtonBox buttonBox;
+ buttonBox.setStandardButtons(buttonsToAdd);
+ QTEST(buttonBox.standardButtons(), "expectedResult");
+}
+
+void tst_QDialogButtonBox::standardButtons()
+{
+ // Test various cases of setting StandardButtons
+ QDialogButtonBox buttonBox;
+
+ QCOMPARE(buttonBox.standardButtons(),
+ QDialogButtonBox::StandardButtons(QDialogButtonBox::NoButton));
+
+ // Set some buttons
+ buttonBox.setStandardButtons(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
+ QCOMPARE(buttonBox.standardButtons(), QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
+
+ // Now add a button
+ buttonBox.addButton(QDialogButtonBox::Apply);
+ QCOMPARE(buttonBox.standardButtons(),
+ QDialogButtonBox::Ok | QDialogButtonBox::Cancel | QDialogButtonBox::Apply);
+
+ // Set the standard buttons to other things
+ buttonBox.setStandardButtons(QDialogButtonBox::Save | QDialogButtonBox::Cancel
+ | QDialogButtonBox::Discard);
+ QCOMPARE(buttonBox.standardButtons(), QDialogButtonBox::Save | QDialogButtonBox::Cancel
+ | QDialogButtonBox::Discard);
+ QCOMPARE(buttonBox.buttons().size(), 3);
+
+ // Add another button (not a standard one)
+ buttonBox.addButton(QLatin1String("Help"), QDialogButtonBox::HelpRole);
+ QCOMPARE(buttonBox.standardButtons(), QDialogButtonBox::Save | QDialogButtonBox::Cancel
+ | QDialogButtonBox::Discard);
+ QCOMPARE(buttonBox.buttons().size(), 4);
+
+ // Finally, check if we construct with standard buttons that they show up.
+ QDialogButtonBox buttonBox2(QDialogButtonBox::Open | QDialogButtonBox::Reset);
+ QCOMPARE(buttonBox2.standardButtons(), QDialogButtonBox::Open | QDialogButtonBox::Reset);
+}
+
+void tst_QDialogButtonBox::testRemove()
+{
+ // Make sure that removing a button and clicking it, doesn't trigger any latent signals
+ QDialogButtonBox buttonBox;
+ QSignalSpy clicked(&buttonBox, SIGNAL(clicked(QAbstractButton*)));
+
+ QAbstractButton *button = buttonBox.addButton(QDialogButtonBox::Ok);
+
+ buttonBox.removeButton(button);
+
+ button->animateClick(0);
+ QTest::qWait(100);
+ QCOMPARE(clicked.count(), 0);
+ delete button;
+}
+
+void tst_QDialogButtonBox::testDefaultButton_data()
+{
+ QTest::addColumn<int>("whenToSetDefault"); // -1 Do nothing, 0 after accept, 1 before accept
+ QTest::addColumn<int>("buttonToBeDefault");
+ QTest::addColumn<int>("indexThatIsDefault");
+
+ QTest::newRow("do nothing First Accept implicit") << -1 << -1 << 0;
+ QTest::newRow("First accept explicit before add") << 1 << 0 << 0;
+ QTest::newRow("First accept explicit after add") << 0 << 0 << 0;
+ QTest::newRow("second accept explicit before add") << 1 << 1 << 1;
+ QTest::newRow("second accept explicit after add") << 0 << 1 << 1;
+ QTest::newRow("third accept explicit befare add") << 1 << 2 << 2;
+ QTest::newRow("third accept explicit after add") << 0 << 2 << 2;
+}
+
+static int softKeyCount(QWidget *widget)
+{
+ int softkeyCount = 0;
+#ifndef QT_NO_ACTION
+ QList<QAction *> actions = widget->actions();
+ foreach (QAction *action, actions) {
+ if (action->softKeyRole() != QAction::NoSoftKey)
+ softkeyCount++;
+ }
+#endif
+ return softkeyCount;
+}
+
+#ifdef QT_SOFTKEYS_ENABLED
+void tst_QDialogButtonBox::testSoftKeyReparenting()
+{
+ QDialog dialog;
+ QDialogButtonBox *buttonBox = new QDialogButtonBox;
+ buttonBox->addButton(QDialogButtonBox::Ok);
+ buttonBox->addButton(QDialogButtonBox::Cancel);
+
+#ifndef QT_NO_ACTION
+ QCOMPARE(softKeyCount(&dialog), 0);
+ QCOMPARE(softKeyCount(buttonBox), 2);
+#endif
+
+ // Were the softkeys re-parented correctly?
+ dialog.setLayout(new QVBoxLayout);
+ dialog.layout()->addWidget(buttonBox);
+#ifndef QT_NO_ACTION
+ QCOMPARE(softKeyCount(&dialog), 2);
+ QCOMPARE(softKeyCount(buttonBox), 0);
+#endif
+
+ // Softkeys are only added to QDialog, not QWidget
+ QWidget *nested = new QWidget;
+ nested->setLayout(new QVBoxLayout);
+ nested->layout()->addWidget(buttonBox);
+#ifndef QT_NO_ACTION
+ QCOMPARE(softKeyCount(nested), 0);
+ QCOMPARE(softKeyCount(buttonBox), 2);
+#endif
+}
+#endif
+
+void tst_QDialogButtonBox::testDefaultButton()
+{
+ QFETCH(int, whenToSetDefault);
+ QFETCH(int, buttonToBeDefault);
+ QFETCH(int, indexThatIsDefault);
+ QDialogButtonBox buttonBox;
+ QPushButton *buttonArray[] = { new QPushButton("Foo"), new QPushButton("Bar"), new QPushButton("Baz") };
+
+ for (int i = 0; i < 3; ++i) {
+ if (whenToSetDefault == 1 && i == buttonToBeDefault)
+ buttonArray[i]->setDefault(true);
+ buttonBox.addButton(buttonArray[i], QDialogButtonBox::AcceptRole);
+ if (whenToSetDefault == 0 && i == buttonToBeDefault)
+ buttonArray[i]->setDefault(true);
+ }
+ buttonBox.show();
+
+ for (int i = 0; i < 3; ++i) {
+ if (i == indexThatIsDefault)
+ QVERIFY(buttonArray[i]->isDefault());
+ else
+ QVERIFY(!buttonArray[i]->isDefault());
+ }
+}
+
+void tst_QDialogButtonBox::task191642_default()
+{
+ QDialog dlg;
+ QPushButton *def = new QPushButton(&dlg);
+ QSignalSpy clicked(def, SIGNAL(clicked(bool)));
+ def->setDefault(true);
+ QDialogButtonBox *bb = new QDialogButtonBox(&dlg);
+ bb->addButton(QDialogButtonBox::Ok);
+ bb->addButton(QDialogButtonBox::Cancel);
+ bb->addButton(QDialogButtonBox::Help);
+
+ dlg.show();
+ QTest::qWait(10);
+ QVERIFY(def->isDefault());
+ QTest::keyPress( &dlg, Qt::Key_Enter );
+ QTest::qWait(100);
+ QCOMPARE(clicked.count(), 1);
+}
+
+QTEST_MAIN(tst_QDialogButtonBox)
+#include "tst_qdialogbuttonbox.moc"
diff --git a/tests/auto/widgets/widgets/qdockwidget/.gitignore b/tests/auto/widgets/widgets/qdockwidget/.gitignore
new file mode 100644
index 0000000000..7c79145a67
--- /dev/null
+++ b/tests/auto/widgets/widgets/qdockwidget/.gitignore
@@ -0,0 +1 @@
+tst_qdockwidget
diff --git a/tests/auto/widgets/widgets/qdockwidget/qdockwidget.pro b/tests/auto/widgets/widgets/qdockwidget/qdockwidget.pro
new file mode 100644
index 0000000000..e59728207f
--- /dev/null
+++ b/tests/auto/widgets/widgets/qdockwidget/qdockwidget.pro
@@ -0,0 +1,7 @@
+load(qttest_p4)
+QT += widgets widgets-private
+QT += core-private gui-private
+
+SOURCES += tst_qdockwidget.cpp
+
+CONFIG += insignificant_test # QTBUG-21402
diff --git a/tests/auto/widgets/widgets/qdockwidget/tst_qdockwidget.cpp b/tests/auto/widgets/widgets/qdockwidget/tst_qdockwidget.cpp
new file mode 100644
index 0000000000..2c1f7c0954
--- /dev/null
+++ b/tests/auto/widgets/widgets/qdockwidget/tst_qdockwidget.cpp
@@ -0,0 +1,877 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+
+#include <QtTest/QtTest>
+
+
+#include <qaction.h>
+#include <qdockwidget.h>
+#include <qmainwindow.h>
+#include <qlineedit.h>
+#include <QDesktopWidget>
+#include <QtGui/QPainter>
+#include "private/qdockwidget_p.h"
+
+bool hasFeature(QDockWidget *dockwidget, QDockWidget::DockWidgetFeature feature)
+{ return (dockwidget->features() & feature) == feature; }
+
+void setFeature(QDockWidget *dockwidget, QDockWidget::DockWidgetFeature feature, bool on = true)
+{
+ const QDockWidget::DockWidgetFeatures features = dockwidget->features();
+ dockwidget->setFeatures(on ? features | feature : features & ~feature);
+}
+
+//TESTED_FILES=
+
+class tst_QDockWidget : public QObject
+{
+ Q_OBJECT
+
+public:
+ tst_QDockWidget();
+
+private slots:
+ void getSetCheck();
+ void widget();
+ void features();
+ void setFloating();
+ void allowedAreas();
+ void toggleViewAction();
+ void visibilityChanged();
+ void dockLocationChanged();
+ void setTitleBarWidget();
+ void titleBarDoubleClick();
+ void restoreStateOfFloating();
+ // task specific tests:
+ void task165177_deleteFocusWidget();
+ void task169808_setFloating();
+ void task237438_setFloatingCrash();
+ void task248604_infiniteResize();
+ void task258459_visibilityChanged();
+ void taskQTBUG_1665_closableChanged();
+ void taskQTBUG_9758_undockedGeometry();
+};
+
+// Testing get/set functions
+void tst_QDockWidget::getSetCheck()
+{
+ QDockWidget obj1;
+ // QWidget * QDockWidget::widget()
+ // void QDockWidget::setWidget(QWidget *)
+ QWidget *var1 = new QWidget();
+ obj1.setWidget(var1);
+ QCOMPARE(var1, obj1.widget());
+ obj1.setWidget((QWidget *)0);
+ QCOMPARE((QWidget *)0, obj1.widget());
+ delete var1;
+
+ // DockWidgetFeatures QDockWidget::features()
+ // void QDockWidget::setFeatures(DockWidgetFeatures)
+ obj1.setFeatures(QDockWidget::DockWidgetFeatures(QDockWidget::DockWidgetClosable));
+ QCOMPARE(QDockWidget::DockWidgetFeatures(QDockWidget::DockWidgetClosable), obj1.features());
+ obj1.setFeatures(QDockWidget::DockWidgetFeatures(QDockWidget::DockWidgetMovable));
+ QCOMPARE(QDockWidget::DockWidgetFeatures(QDockWidget::DockWidgetMovable), obj1.features());
+ obj1.setFeatures(QDockWidget::DockWidgetFeatures(QDockWidget::DockWidgetFloatable));
+ QCOMPARE(QDockWidget::DockWidgetFeatures(QDockWidget::DockWidgetFloatable), obj1.features());
+ obj1.setFeatures(QDockWidget::DockWidgetFeatures(QDockWidget::AllDockWidgetFeatures));
+ QCOMPARE(QDockWidget::DockWidgetFeatures(QDockWidget::AllDockWidgetFeatures), obj1.features());
+ obj1.setFeatures(QDockWidget::DockWidgetFeatures(QDockWidget::NoDockWidgetFeatures));
+ QCOMPARE(QDockWidget::DockWidgetFeatures(QDockWidget::NoDockWidgetFeatures), obj1.features());
+}
+
+tst_QDockWidget::tst_QDockWidget()
+{
+ qRegisterMetaType<QDockWidget::DockWidgetFeatures>("QDockWidget::DockWidgetFeatures");
+ qRegisterMetaType<Qt::DockWidgetAreas>("Qt::DockWidgetAreas");
+}
+
+void tst_QDockWidget::widget()
+{
+ {
+ QDockWidget dw;
+ QVERIFY(dw.widget() == 0);
+ }
+
+ {
+ QDockWidget dw;
+ QWidget *w1 = new QWidget;
+ QWidget *w2 = new QWidget;
+
+ dw.setWidget(w1);
+ QVERIFY(dw.widget() != 0);
+ QVERIFY(dw.widget() == w1);
+ QCOMPARE(w1->parentWidget(), (QWidget*)&dw);
+
+ dw.setWidget(0);
+ QVERIFY(dw.widget() == 0);
+
+ dw.setWidget(w2);
+ QVERIFY(dw.widget() != 0);
+ QVERIFY(dw.widget() == w2);
+ QCOMPARE(w2->parentWidget(), (QWidget*)&dw);
+
+ dw.setWidget(0);
+ QVERIFY(dw.widget() == 0);
+
+ dw.setWidget(w1);
+ QVERIFY(dw.widget() != 0);
+ QVERIFY(dw.widget() == w1);
+ QCOMPARE(w1->parentWidget(), (QWidget*)&dw);
+
+ dw.setWidget(w2);
+ QVERIFY(dw.widget() != 0);
+ QVERIFY(dw.widget() == w2);
+ QCOMPARE(w2->parentWidget(), (QWidget*)&dw);
+
+ dw.setWidget(0);
+ QVERIFY(dw.widget() == 0);
+ }
+
+ {
+ QDockWidget dw;
+ QWidget *w1 = new QWidget;
+ QWidget *w2 = new QWidget;
+
+ dw.setWidget(w1);
+ QVERIFY(dw.widget() != 0);
+ QVERIFY(dw.widget() == w1);
+ QCOMPARE(w1->parentWidget(), (QWidget*)&dw);
+
+ w1->setParent(0);
+ QVERIFY(dw.widget() == 0);
+
+ dw.setWidget(w2);
+ QVERIFY(dw.widget() != 0);
+ QVERIFY(dw.widget() == w2);
+ QCOMPARE(w2->parentWidget(), (QWidget*)&dw);
+
+ w2->setParent(0);
+ QVERIFY(dw.widget() == 0);
+
+ dw.setWidget(w1);
+ QVERIFY(dw.widget() != 0);
+ QVERIFY(dw.widget() == w1);
+ QCOMPARE(w1->parentWidget(), (QWidget*)&dw);
+
+ dw.setWidget(w2);
+ QVERIFY(dw.widget() != 0);
+ QVERIFY(dw.widget() == w2);
+ QCOMPARE(w2->parentWidget(), (QWidget*)&dw);
+
+ w1->setParent(0);
+ QVERIFY(dw.widget() != 0);
+ QVERIFY(dw.widget() == w2);
+ QCOMPARE(w2->parentWidget(), (QWidget*)&dw);
+
+ w2->setParent(0);
+ QVERIFY(dw.widget() == 0);
+ delete w1;
+ delete w2;
+ }
+}
+
+void tst_QDockWidget::features()
+{
+ QDockWidget dw;
+
+ QSignalSpy spy(&dw, SIGNAL(featuresChanged(QDockWidget::DockWidgetFeatures)));
+
+ // default features for dock widgets
+ int allDockWidgetFeatures = QDockWidget::DockWidgetClosable |
+ QDockWidget::DockWidgetMovable |
+ QDockWidget::DockWidgetFloatable;
+
+ // defaults
+ QCOMPARE(dw.features(), allDockWidgetFeatures);
+ QVERIFY(hasFeature(&dw, QDockWidget::DockWidgetClosable));
+ QVERIFY(hasFeature(&dw, QDockWidget::DockWidgetMovable));
+ QVERIFY(hasFeature(&dw, QDockWidget::DockWidgetFloatable));
+
+ // test individual setting
+ setFeature(&dw, QDockWidget::DockWidgetClosable, false);
+ QCOMPARE(dw.features(), QDockWidget::DockWidgetMovable | QDockWidget::DockWidgetFloatable);
+ QVERIFY(!hasFeature(&dw, QDockWidget::DockWidgetClosable));
+ QVERIFY(hasFeature(&dw, QDockWidget::DockWidgetMovable));
+ QVERIFY(hasFeature(&dw, QDockWidget::DockWidgetFloatable));
+ QCOMPARE(spy.count(), 1);
+ QCOMPARE((int)*(static_cast<const QDockWidget::DockWidgetFeature *>(spy.at(0).value(0).constData())),
+ (int)dw.features());
+ spy.clear();
+ dw.setFeatures(dw.features());
+ QCOMPARE(spy.count(), 0);
+ spy.clear();
+
+ setFeature(&dw, QDockWidget::DockWidgetClosable);
+ QCOMPARE(dw.features(), allDockWidgetFeatures);
+ QVERIFY(hasFeature(&dw, QDockWidget::DockWidgetClosable));
+ QVERIFY(hasFeature(&dw, QDockWidget::DockWidgetMovable));
+ QVERIFY(hasFeature(&dw, QDockWidget::DockWidgetFloatable));
+ QCOMPARE(spy.count(), 1);
+ QCOMPARE((int)*static_cast<const QDockWidget::DockWidgetFeature *>(spy.at(0).value(0).constData()),
+ (int)dw.features());
+ spy.clear();
+ dw.setFeatures(dw.features());
+ QCOMPARE(spy.count(), 0);
+ spy.clear();
+
+ setFeature(&dw, QDockWidget::DockWidgetMovable, false);
+ QCOMPARE(dw.features(), QDockWidget::DockWidgetClosable | QDockWidget::DockWidgetFloatable);
+ QVERIFY(hasFeature(&dw, QDockWidget::DockWidgetClosable));
+ QVERIFY(!hasFeature(&dw, QDockWidget::DockWidgetMovable));
+ QVERIFY(hasFeature(&dw, QDockWidget::DockWidgetFloatable));
+ QCOMPARE(spy.count(), 1);
+ QCOMPARE((int)*static_cast<const QDockWidget::DockWidgetFeature *>(spy.at(0).value(0).constData()),
+ (int)dw.features());
+ spy.clear();
+ dw.setFeatures(dw.features());
+ QCOMPARE(spy.count(), 0);
+ spy.clear();
+
+ setFeature(&dw, QDockWidget::DockWidgetMovable);
+ QCOMPARE(dw.features(), allDockWidgetFeatures);
+ QVERIFY(hasFeature(&dw, QDockWidget::DockWidgetClosable));
+ QVERIFY(hasFeature(&dw, QDockWidget::DockWidgetMovable));
+ QVERIFY(hasFeature(&dw, QDockWidget::DockWidgetFloatable));
+ QCOMPARE(spy.count(), 1);
+ QCOMPARE((int)*static_cast<const QDockWidget::DockWidgetFeature *>(spy.at(0).value(0).constData()),
+ (int)dw.features());
+ spy.clear();
+ dw.setFeatures(dw.features());
+ QCOMPARE(spy.count(), 0);
+ spy.clear();
+
+ setFeature(&dw, QDockWidget::DockWidgetFloatable, false);
+ QCOMPARE(dw.features(), QDockWidget::DockWidgetClosable | QDockWidget::DockWidgetMovable);
+ QVERIFY(hasFeature(&dw, QDockWidget::DockWidgetClosable));
+ QVERIFY(hasFeature(&dw, QDockWidget::DockWidgetMovable));
+ QVERIFY(!hasFeature(&dw, QDockWidget::DockWidgetFloatable));
+ QCOMPARE(spy.count(), 1);
+ QCOMPARE((int)*static_cast<const QDockWidget::DockWidgetFeature *>(spy.at(0).value(0).constData()),
+ (int)dw.features());
+ spy.clear();
+ dw.setFeatures(dw.features());
+ QCOMPARE(spy.count(), 0);
+ spy.clear();
+
+ setFeature(&dw, QDockWidget::DockWidgetFloatable);
+ QCOMPARE(dw.features(), allDockWidgetFeatures);
+ QVERIFY(hasFeature(&dw, QDockWidget::DockWidgetClosable));
+ QVERIFY(hasFeature(&dw, QDockWidget::DockWidgetMovable));
+ QVERIFY(hasFeature(&dw, QDockWidget::DockWidgetFloatable));
+ QCOMPARE(spy.count(), 1);
+ QCOMPARE((int)*static_cast<const QDockWidget::DockWidgetFeature *>(spy.at(0).value(0).constData()),
+ (int)dw.features());
+ spy.clear();
+ dw.setFeatures(dw.features());
+ QCOMPARE(spy.count(), 0);
+ spy.clear();
+
+ // set all at once
+ dw.setFeatures(QDockWidget::DockWidgetClosable | QDockWidget::DockWidgetMovable);
+ QCOMPARE(dw.features(), QDockWidget::DockWidgetClosable | QDockWidget::DockWidgetMovable);
+ QVERIFY(hasFeature(&dw, QDockWidget::DockWidgetClosable));
+ QVERIFY(hasFeature(&dw, QDockWidget::DockWidgetMovable));
+ QVERIFY(!hasFeature(&dw, QDockWidget::DockWidgetFloatable));
+ QCOMPARE(spy.count(), 1);
+ QCOMPARE((int)*static_cast<const QDockWidget::DockWidgetFeature *>(spy.at(0).value(0).constData()),
+ (int)dw.features());
+ spy.clear();
+ dw.setFeatures(dw.features());
+ QCOMPARE(spy.count(), 0);
+ spy.clear();
+
+ dw.setFeatures(QDockWidget::DockWidgetClosable);
+ QCOMPARE(dw.features(), QDockWidget::DockWidgetClosable);
+ QVERIFY(hasFeature(&dw, QDockWidget::DockWidgetClosable));
+ QVERIFY(!hasFeature(&dw, QDockWidget::DockWidgetMovable));
+ QVERIFY(!hasFeature(&dw, QDockWidget::DockWidgetFloatable));
+ QCOMPARE(spy.count(), 1);
+ QCOMPARE((int)*static_cast<const QDockWidget::DockWidgetFeature *>(spy.at(0).value(0).constData()),
+ (int)dw.features());
+ spy.clear();
+ dw.setFeatures(dw.features());
+ QCOMPARE(spy.count(), 0);
+ spy.clear();
+
+ dw.setFeatures(QDockWidget::AllDockWidgetFeatures);
+ QCOMPARE(dw.features(), QDockWidget::AllDockWidgetFeatures);
+ QVERIFY(hasFeature(&dw, QDockWidget::DockWidgetClosable));
+ QVERIFY(hasFeature(&dw, QDockWidget::DockWidgetMovable));
+ QVERIFY(hasFeature(&dw, QDockWidget::DockWidgetFloatable));
+ QCOMPARE(spy.count(), 1);
+ QCOMPARE((int)*static_cast<const QDockWidget::DockWidgetFeature *>(spy.at(0).value(0).constData()),
+ (int)dw.features());
+ spy.clear();
+ dw.setFeatures(dw.features());
+ QCOMPARE(spy.count(), 0);
+ spy.clear();
+}
+
+void tst_QDockWidget::setFloating()
+{
+ QMainWindow mw;
+ QDockWidget dw;
+ mw.addDockWidget(Qt::LeftDockWidgetArea, &dw);
+
+ mw.show();
+#ifdef Q_WS_X11
+ qt_x11_wait_for_window_manager(&mw);
+#endif
+
+ QVERIFY(!dw.isFloating());
+
+ QSignalSpy spy(&dw, SIGNAL(topLevelChanged(bool)));
+
+ dw.setFloating(true);
+ QVERIFY(dw.isFloating());
+ QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.at(0).value(0).toBool(), dw.isFloating());
+ spy.clear();
+ dw.setFloating(dw.isFloating());
+ QCOMPARE(spy.count(), 0);
+ spy.clear();
+
+ dw.setFloating(false);
+ QVERIFY(!dw.isFloating());
+ QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.at(0).value(0).toBool(), dw.isFloating());
+ spy.clear();
+ dw.setFloating(dw.isFloating());
+ QCOMPARE(spy.count(), 0);
+ spy.clear();
+}
+
+void tst_QDockWidget::allowedAreas()
+{
+ QDockWidget dw;
+
+ QSignalSpy spy(&dw, SIGNAL(allowedAreasChanged(Qt::DockWidgetAreas)));
+
+ // default
+ QCOMPARE(dw.allowedAreas(), Qt::AllDockWidgetAreas);
+ QVERIFY(dw.isAreaAllowed(Qt::LeftDockWidgetArea));
+ QVERIFY(dw.isAreaAllowed(Qt::RightDockWidgetArea));
+ QVERIFY(dw.isAreaAllowed(Qt::TopDockWidgetArea));
+ QVERIFY(dw.isAreaAllowed(Qt::BottomDockWidgetArea));
+
+ // a single dock window area
+ dw.setAllowedAreas(Qt::LeftDockWidgetArea);
+ QCOMPARE(dw.allowedAreas(), Qt::LeftDockWidgetArea);
+ QVERIFY(dw.isAreaAllowed(Qt::LeftDockWidgetArea));
+ QVERIFY(!dw.isAreaAllowed(Qt::RightDockWidgetArea));
+ QVERIFY(!dw.isAreaAllowed(Qt::TopDockWidgetArea));
+ QVERIFY(!dw.isAreaAllowed(Qt::BottomDockWidgetArea));
+ QCOMPARE(spy.count(), 1);
+ QCOMPARE(*static_cast<const Qt::DockWidgetAreas *>(spy.at(0).value(0).constData()),
+ dw.allowedAreas());
+ spy.clear();
+ dw.setAllowedAreas(dw.allowedAreas());
+ QCOMPARE(spy.count(), 0);
+
+ dw.setAllowedAreas(Qt::RightDockWidgetArea);
+ QCOMPARE(dw.allowedAreas(), Qt::RightDockWidgetArea);
+ QVERIFY(!dw.isAreaAllowed(Qt::LeftDockWidgetArea));
+ QVERIFY(dw.isAreaAllowed(Qt::RightDockWidgetArea));
+ QVERIFY(!dw.isAreaAllowed(Qt::TopDockWidgetArea));
+ QVERIFY(!dw.isAreaAllowed(Qt::BottomDockWidgetArea));
+ QCOMPARE(spy.count(), 1);
+ QCOMPARE(*static_cast<const Qt::DockWidgetAreas *>(spy.at(0).value(0).constData()),
+ dw.allowedAreas());
+ spy.clear();
+ dw.setAllowedAreas(dw.allowedAreas());
+ QCOMPARE(spy.count(), 0);
+
+ dw.setAllowedAreas(Qt::TopDockWidgetArea);
+ QCOMPARE(dw.allowedAreas(), Qt::TopDockWidgetArea);
+ QVERIFY(!dw.isAreaAllowed(Qt::LeftDockWidgetArea));
+ QVERIFY(!dw.isAreaAllowed(Qt::RightDockWidgetArea));
+ QVERIFY(dw.isAreaAllowed(Qt::TopDockWidgetArea));
+ QVERIFY(!dw.isAreaAllowed(Qt::BottomDockWidgetArea));
+ QCOMPARE(spy.count(), 1);
+ QCOMPARE(*static_cast<const Qt::DockWidgetAreas *>(spy.at(0).value(0).constData()),
+ dw.allowedAreas());
+ spy.clear();
+ dw.setAllowedAreas(dw.allowedAreas());
+ QCOMPARE(spy.count(), 0);
+
+ dw.setAllowedAreas(Qt::BottomDockWidgetArea);
+ QCOMPARE(dw.allowedAreas(), Qt::BottomDockWidgetArea);
+ QVERIFY(!dw.isAreaAllowed(Qt::LeftDockWidgetArea));
+ QVERIFY(!dw.isAreaAllowed(Qt::RightDockWidgetArea));
+ QVERIFY(!dw.isAreaAllowed(Qt::TopDockWidgetArea));
+ QVERIFY(dw.isAreaAllowed(Qt::BottomDockWidgetArea));
+ QCOMPARE(spy.count(), 1);
+ QCOMPARE(*static_cast<const Qt::DockWidgetAreas *>(spy.at(0).value(0).constData()),
+ dw.allowedAreas());
+ spy.clear();
+ dw.setAllowedAreas(dw.allowedAreas());
+ QCOMPARE(spy.count(), 0);
+
+ // multiple dock window areas
+ dw.setAllowedAreas(Qt::TopDockWidgetArea | Qt::BottomDockWidgetArea);
+ QCOMPARE(dw.allowedAreas(), Qt::TopDockWidgetArea | Qt::BottomDockWidgetArea);
+ QVERIFY(!dw.isAreaAllowed(Qt::LeftDockWidgetArea));
+ QVERIFY(!dw.isAreaAllowed(Qt::RightDockWidgetArea));
+ QVERIFY(dw.isAreaAllowed(Qt::TopDockWidgetArea));
+ QVERIFY(dw.isAreaAllowed(Qt::BottomDockWidgetArea));
+ QCOMPARE(spy.count(), 1);
+ QCOMPARE(*static_cast<const Qt::DockWidgetAreas *>(spy.at(0).value(0).constData()),
+ dw.allowedAreas());
+ spy.clear();
+ dw.setAllowedAreas(dw.allowedAreas());
+ QCOMPARE(spy.count(), 0);
+
+ dw.setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
+ QCOMPARE(dw.allowedAreas(), Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
+ QVERIFY(dw.isAreaAllowed(Qt::LeftDockWidgetArea));
+ QVERIFY(dw.isAreaAllowed(Qt::RightDockWidgetArea));
+ QVERIFY(!dw.isAreaAllowed(Qt::TopDockWidgetArea));
+ QVERIFY(!dw.isAreaAllowed(Qt::BottomDockWidgetArea));
+ QCOMPARE(spy.count(), 1);
+ QCOMPARE(*static_cast<const Qt::DockWidgetAreas *>(spy.at(0).value(0).constData()),
+ dw.allowedAreas());
+ spy.clear();
+ dw.setAllowedAreas(dw.allowedAreas());
+ QCOMPARE(spy.count(), 0);
+
+ dw.setAllowedAreas(Qt::TopDockWidgetArea | Qt::LeftDockWidgetArea);
+ QCOMPARE(dw.allowedAreas(), Qt::TopDockWidgetArea | Qt::LeftDockWidgetArea);
+ QVERIFY(dw.isAreaAllowed(Qt::LeftDockWidgetArea));
+ QVERIFY(!dw.isAreaAllowed(Qt::RightDockWidgetArea));
+ QVERIFY(dw.isAreaAllowed(Qt::TopDockWidgetArea));
+ QVERIFY(!dw.isAreaAllowed(Qt::BottomDockWidgetArea));
+ QCOMPARE(spy.count(), 1);
+ QCOMPARE(*static_cast<const Qt::DockWidgetAreas *>(spy.at(0).value(0).constData()),
+ dw.allowedAreas());
+ spy.clear();
+ dw.setAllowedAreas(dw.allowedAreas());
+ QCOMPARE(spy.count(), 0);
+
+ dw.setAllowedAreas(Qt::BottomDockWidgetArea | Qt::RightDockWidgetArea);
+ QCOMPARE(dw.allowedAreas(), Qt::BottomDockWidgetArea | Qt::RightDockWidgetArea);
+ QVERIFY(!dw.isAreaAllowed(Qt::LeftDockWidgetArea));
+ QVERIFY(dw.isAreaAllowed(Qt::RightDockWidgetArea));
+ QVERIFY(!dw.isAreaAllowed(Qt::TopDockWidgetArea));
+ QVERIFY(dw.isAreaAllowed(Qt::BottomDockWidgetArea));
+ QCOMPARE(spy.count(), 1);
+ QCOMPARE(*static_cast<const Qt::DockWidgetAreas *>(spy.at(0).value(0).constData()),
+ dw.allowedAreas());
+ spy.clear();
+ dw.setAllowedAreas(dw.allowedAreas());
+ QCOMPARE(spy.count(), 0);
+}
+
+void tst_QDockWidget::toggleViewAction()
+{
+ QMainWindow mw;
+ QDockWidget dw(&mw);
+ mw.addDockWidget(Qt::LeftDockWidgetArea, &dw);
+ mw.show();
+ QAction *toggleViewAction = dw.toggleViewAction();
+ QVERIFY(!dw.isHidden());
+ toggleViewAction->trigger();
+ QVERIFY(dw.isHidden());
+ toggleViewAction->trigger();
+ QVERIFY(!dw.isHidden());
+ toggleViewAction->trigger();
+ QVERIFY(dw.isHidden());
+}
+
+void tst_QDockWidget::visibilityChanged()
+{
+ QMainWindow mw;
+ QDockWidget dw;
+ QSignalSpy spy(&dw, SIGNAL(visibilityChanged(bool)));
+
+ mw.addDockWidget(Qt::LeftDockWidgetArea, &dw);
+ mw.show();
+
+ QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.at(0).at(0).toBool(), true);
+ spy.clear();
+
+ dw.hide();
+ QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.at(0).at(0).toBool(), false);
+ spy.clear();
+
+ dw.hide();
+ QCOMPARE(spy.count(), 0);
+
+ dw.show();
+ QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.at(0).at(0).toBool(), true);
+ spy.clear();
+
+ dw.show();
+ QCOMPARE(spy.count(), 0);
+
+ QDockWidget dw2;
+ mw.tabifyDockWidget(&dw, &dw2);
+ dw2.show();
+ dw2.raise();
+ QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.at(0).at(0).toBool(), false);
+ spy.clear();
+
+ dw2.hide();
+ qApp->processEvents();
+ QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.at(0).at(0).toBool(), true);
+ spy.clear();
+
+ dw2.show();
+ dw2.raise();
+ qApp->processEvents();
+ QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.at(0).at(0).toBool(), false);
+ spy.clear();
+
+ dw.raise();
+ QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.at(0).at(0).toBool(), true);
+ spy.clear();
+
+ dw.raise();
+ QCOMPARE(spy.count(), 0);
+
+ dw2.raise();
+ QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.at(0).at(0).toBool(), false);
+ spy.clear();
+
+ dw2.raise();
+ QCOMPARE(spy.count(), 0);
+
+ mw.addDockWidget(Qt::RightDockWidgetArea, &dw2);
+ QTest::qWait(200);
+ QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.at(0).at(0).toBool(), true);
+}
+
+Q_DECLARE_METATYPE(Qt::DockWidgetArea)
+
+void tst_QDockWidget::dockLocationChanged()
+{
+ qRegisterMetaType<Qt::DockWidgetArea>("Qt::DockWidgetArea");
+
+ QMainWindow mw;
+ QDockWidget dw;
+ dw.setObjectName("dock1");
+ QSignalSpy spy(&dw, SIGNAL(dockLocationChanged(Qt::DockWidgetArea)));
+
+ mw.addDockWidget(Qt::LeftDockWidgetArea, &dw);
+ QCOMPARE(spy.count(), 1);
+ QCOMPARE(qvariant_cast<Qt::DockWidgetArea>(spy.at(0).at(0)),
+ Qt::LeftDockWidgetArea);
+ spy.clear();
+
+ mw.addDockWidget(Qt::LeftDockWidgetArea, &dw);
+ QCOMPARE(spy.count(), 1);
+ QCOMPARE(qvariant_cast<Qt::DockWidgetArea>(spy.at(0).at(0)),
+ Qt::LeftDockWidgetArea);
+ spy.clear();
+
+ mw.addDockWidget(Qt::RightDockWidgetArea, &dw);
+ QCOMPARE(spy.count(), 1);
+ QCOMPARE(qvariant_cast<Qt::DockWidgetArea>(spy.at(0).at(0)),
+ Qt::RightDockWidgetArea);
+ spy.clear();
+
+ mw.removeDockWidget(&dw);
+ QCOMPARE(spy.count(), 0);
+
+ QDockWidget dw2;
+ dw2.setObjectName("dock2");
+ mw.addDockWidget(Qt::TopDockWidgetArea, &dw2);
+ mw.tabifyDockWidget(&dw2, &dw);
+ QCOMPARE(spy.count(), 1);
+ QCOMPARE(qvariant_cast<Qt::DockWidgetArea>(spy.at(0).at(0)),
+ Qt::TopDockWidgetArea);
+ spy.clear();
+
+ mw.splitDockWidget(&dw2, &dw, Qt::Horizontal);
+ QCOMPARE(spy.count(), 1);
+ QCOMPARE(qvariant_cast<Qt::DockWidgetArea>(spy.at(0).at(0)),
+ Qt::TopDockWidgetArea);
+ spy.clear();
+
+ dw.setFloating(true);
+ QTest::qWait(100);
+ dw.setFloating(false);
+ QTest::qWait(100);
+ QCOMPARE(spy.count(), 1);
+ QCOMPARE(qvariant_cast<Qt::DockWidgetArea>(spy.at(0).at(0)),
+ Qt::TopDockWidgetArea);
+ spy.clear();
+
+ QByteArray ba = mw.saveState();
+ mw.restoreState(ba);
+ QCOMPARE(spy.count(), 1);
+ QCOMPARE(qvariant_cast<Qt::DockWidgetArea>(spy.at(0).at(0)),
+ Qt::TopDockWidgetArea);
+}
+
+void tst_QDockWidget::setTitleBarWidget()
+{
+ //test the successive usage of setTitleBarWidget
+
+ QDockWidget dock;
+ QWidget w, w2;
+
+ dock.show();
+ qApp->processEvents();
+
+ dock.setTitleBarWidget(&w);
+ qApp->processEvents();
+ QCOMPARE(w.isVisible(), true);
+
+ //set another widget as the titlebar widget
+ dock.setTitleBarWidget(&w2); // this used to crash (task 184668)
+ qApp->processEvents();
+ QCOMPARE(w.isVisible(), false);
+ QCOMPARE(w2.isVisible(), true);
+
+ //tries to reset the titlebarwidget to none
+ dock.setTitleBarWidget(0);
+ qApp->processEvents();
+ QCOMPARE(w.isVisible(), false);
+ QCOMPARE(w2.isVisible(), false);
+}
+
+void tst_QDockWidget::titleBarDoubleClick()
+{
+ QMainWindow win;
+ QDockWidget dock(&win);
+ win.show();
+ dock.setFloating(true);
+
+ QEvent e(QEvent::NonClientAreaMouseButtonDblClick);
+ QApplication::sendEvent(&dock, &e);
+ QVERIFY(dock.isFloating());
+ QCOMPARE(win.dockWidgetArea(&dock), Qt::NoDockWidgetArea);
+
+ win.addDockWidget(Qt::TopDockWidgetArea, &dock);
+ dock.setFloating(true);
+ QApplication::sendEvent(&dock, &e);
+ QVERIFY(!dock.isFloating());
+ QCOMPARE(win.dockWidgetArea(&dock), Qt::TopDockWidgetArea);
+}
+
+void tst_QDockWidget::restoreStateOfFloating()
+{
+ QMainWindow mw;
+ QDockWidget dock;
+ dock.setObjectName("dock1");
+ mw.addDockWidget(Qt::TopDockWidgetArea, &dock);
+ QVERIFY(!dock.isFloating());
+ QByteArray ba = mw.saveState();
+ dock.setFloating(true);
+ QVERIFY(dock.isFloating());
+ QVERIFY(mw.restoreState(ba));
+ QVERIFY(!dock.isFloating());
+}
+
+
+void tst_QDockWidget::task165177_deleteFocusWidget()
+{
+ QMainWindow mw;
+ QDockWidget *dw = new QDockWidget(&mw);
+ mw.addDockWidget(Qt::LeftDockWidgetArea, dw);
+ QLineEdit *ledit = new QLineEdit;
+ dw->setWidget(ledit);
+ mw.show();
+#ifdef Q_WS_X11
+ qt_x11_wait_for_window_manager(&mw);
+#endif
+ qApp->processEvents();
+ dw->setFloating(true);
+ delete ledit;
+ QCOMPARE(mw.focusWidget(), (QWidget *)0);
+ QCOMPARE(dw->focusWidget(), (QWidget *)0);
+}
+
+void tst_QDockWidget::task169808_setFloating()
+{
+ //we try to test if the sizeHint of the dock widget widget is taken into account
+
+ class MyWidget : public QWidget
+ {
+ public:
+ QSize sizeHint() const
+ {
+ const QRect& deskRect = qApp->desktop()->availableGeometry();
+ return QSize(qMin(300, deskRect.width()), 300);
+ }
+
+ QSize minimumSizeHint() const
+ {
+ return QSize(20,20);
+ }
+
+ void paintEvent(QPaintEvent *)
+ {
+ QPainter p(this);
+ p.fillRect(rect(), Qt::red);
+ }
+ };
+ QMainWindow mw;
+ mw.setCentralWidget(new MyWidget);
+ QDockWidget *dw = new QDockWidget("my dock");
+ dw->setWidget(new MyWidget);
+ mw.addDockWidget(Qt::LeftDockWidgetArea, dw);
+ dw->setFloating(true);
+ mw.show();
+#ifdef Q_WS_X11
+ qt_x11_wait_for_window_manager(&mw);
+#endif
+
+ QCOMPARE(dw->widget()->size(), dw->widget()->sizeHint());
+
+ //and now we try to test if the contents margin is taken into account
+ dw->widget()->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
+ dw->setFloating(false);
+#ifdef Q_WS_X11
+ qt_x11_wait_for_window_manager(&mw);
+#endif
+ QTest::qWait(100); //leave time processing events
+
+
+ const QSize oldSize = dw->size();
+ const int margin = 20;
+
+ dw->setContentsMargins(margin, margin, margin, margin);
+
+#ifdef Q_WS_X11
+ qt_x11_wait_for_window_manager(&mw);
+#endif
+ QTest::qWait(100); //leave time processing events
+
+ //widget size shouldn't have changed
+ QCOMPARE(dw->widget()->size(), dw->widget()->sizeHint());
+ //dockwidget should be bigger
+ QCOMPARE(dw->size(), oldSize + QSize(margin * 2, margin * 2));
+
+
+}
+
+void tst_QDockWidget::task237438_setFloatingCrash()
+{
+ //should not crash
+ QDockWidget pqdwDock;
+ pqdwDock.setFloating(false);
+ pqdwDock.show();
+}
+
+void tst_QDockWidget::task248604_infiniteResize()
+{
+ QDockWidget d;
+ QTabWidget *t = new QTabWidget;
+ t->addTab(new QWidget, "Foo");
+ d.setWidget(t);
+ d.setContentsMargins(2, 2, 2, 2);
+ d.setMinimumSize(320, 240);
+ d.show();
+ QTest::qWait(400);
+ QCOMPARE(d.size(), QSize(320, 240));
+}
+
+
+void tst_QDockWidget::task258459_visibilityChanged()
+{
+ QMainWindow win;
+ QDockWidget dock1, dock2;
+ win.addDockWidget(Qt::RightDockWidgetArea, &dock1);
+ win.tabifyDockWidget(&dock1, &dock2);
+ QSignalSpy spy1(&dock1, SIGNAL(visibilityChanged(bool)));
+ QSignalSpy spy2(&dock2, SIGNAL(visibilityChanged(bool)));
+ win.show();
+ QTest::qWait(200);
+ QCOMPARE(spy1.count(), 1);
+ QCOMPARE(spy1.first().first().toBool(), false); //dock1 is invisible
+ QCOMPARE(spy2.count(), 1);
+ QCOMPARE(spy2.first().first().toBool(), true); //dock1 is visible
+}
+
+void tst_QDockWidget::taskQTBUG_1665_closableChanged()
+{
+ QDockWidget dock;
+ dock.show();
+ QTest::qWaitForWindowShown(&dock);
+
+ QDockWidgetLayout *l = qobject_cast<QDockWidgetLayout*>(dock.layout());
+
+ if (l && !l->nativeWindowDeco())
+ QSKIP("this machine doesn't support native dock widget", SkipAll);
+
+ QVERIFY(dock.windowFlags() & Qt::WindowCloseButtonHint);
+
+ //now let's remove the closable attribute
+ dock.setFeatures(dock.features() ^ QDockWidget::DockWidgetClosable);
+ QVERIFY(!(dock.windowFlags() & Qt::WindowCloseButtonHint));
+}
+
+void tst_QDockWidget::taskQTBUG_9758_undockedGeometry()
+{
+ QMainWindow window;
+ QDockWidget dock1(&window);
+ QDockWidget dock2(&window);
+ window.addDockWidget(Qt::RightDockWidgetArea, &dock1);
+ window.addDockWidget(Qt::RightDockWidgetArea, &dock2);
+ window.tabifyDockWidget(&dock1, &dock2);
+ dock1.hide();
+ dock2.hide();
+ window.show();
+ QTest::qWaitForWindowShown(&window);
+ dock1.setFloating(true);
+ dock1.show();
+ QTest::qWaitForWindowShown(&dock1);
+
+ QVERIFY(dock1.x() >= 0);
+ QVERIFY(dock1.y() >= 0);
+}
+
+
+
+QTEST_MAIN(tst_QDockWidget)
+#include "tst_qdockwidget.moc"
diff --git a/tests/auto/widgets/widgets/qdoublespinbox/.gitignore b/tests/auto/widgets/widgets/qdoublespinbox/.gitignore
new file mode 100644
index 0000000000..7704132e98
--- /dev/null
+++ b/tests/auto/widgets/widgets/qdoublespinbox/.gitignore
@@ -0,0 +1 @@
+tst_qdoublespinbox
diff --git a/tests/auto/widgets/widgets/qdoublespinbox/qdoublespinbox.pro b/tests/auto/widgets/widgets/qdoublespinbox/qdoublespinbox.pro
new file mode 100644
index 0000000000..ff0eb2edae
--- /dev/null
+++ b/tests/auto/widgets/widgets/qdoublespinbox/qdoublespinbox.pro
@@ -0,0 +1,5 @@
+load(qttest_p4)
+QT += widgets
+SOURCES += tst_qdoublespinbox.cpp
+
+CONFIG += insignificant_test # QTBUG-21402
diff --git a/tests/auto/widgets/widgets/qdoublespinbox/tst_qdoublespinbox.cpp b/tests/auto/widgets/widgets/qdoublespinbox/tst_qdoublespinbox.cpp
new file mode 100644
index 0000000000..15f38e3334
--- /dev/null
+++ b/tests/auto/widgets/widgets/qdoublespinbox/tst_qdoublespinbox.cpp
@@ -0,0 +1,1111 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#include <QtTest/QtTest>
+#include <qapplication.h>
+#include <limits.h>
+
+#include <float.h>
+
+#include <qspinbox.h>
+#include <qlocale.h>
+#include <qlayout.h>
+
+#include <qlineedit.h>
+#include <qdebug.h>
+
+//TESTED_CLASS=
+//TESTED_FILES=gui/widgets/qspinbox.h gui/widgets/qspinbox.cpp gui/widgets/qabstractspinbox.cpp gui/widgets/qabstractspinbox_p.h gui/widgets/qabstractspinbox.h
+
+
+class DoubleSpinBox : public QDoubleSpinBox
+{
+ Q_OBJECT
+public:
+ DoubleSpinBox(QWidget *parent = 0)
+ : QDoubleSpinBox(parent)
+ { /*connect(this, SIGNAL(valueChanged(double)), this, SLOT(foo(double)));*/ }
+ QString textFromValue(double v) const
+ {
+ return QDoubleSpinBox::textFromValue(v);
+ }
+ QValidator::State validate(QString &text, int &pos) const
+ {
+ return QDoubleSpinBox::validate(text, pos);
+ }
+ double valueFromText(const QString &text) const
+ {
+ return QDoubleSpinBox::valueFromText(text);
+ }
+
+ QLineEdit* lineEdit() const { return QDoubleSpinBox::lineEdit(); }
+public slots:
+ void foo(double vla)
+ {
+ qDebug() << vla;
+ }
+};
+
+
+class tst_QDoubleSpinBox : public QObject
+{
+ Q_OBJECT
+public:
+ tst_QDoubleSpinBox();
+ virtual ~tst_QDoubleSpinBox();
+public slots:
+ void initTestCase();
+ void cleanupTestCase();
+ void init();
+
+private slots:
+ void germanTest();
+
+ void task54433();
+
+ void setValue_data();
+ void setValue();
+
+ void setPrefixSuffix_data();
+ void setPrefixSuffix();
+
+ void setTracking_data();
+ void setTracking();
+
+ void setWrapping_data();
+ void setWrapping();
+
+ void setSpecialValueText_data();
+ void setSpecialValueText();
+
+ void setSingleStep_data();
+ void setSingleStep();
+
+ void setMinMax_data();
+ void setMinMax();
+
+ void setDecimals_data();
+ void setDecimals();
+
+ void doubleDot();
+
+ void undoRedo();
+
+ void valueFromTextAndValidate_data();
+ void valueFromTextAndValidate();
+
+ void setReadOnly();
+
+ void editingFinished();
+
+ void removeAll();
+
+ void task199226_stateAfterEnter();
+ void task224497_fltMax();
+
+ void task221221();
+ void task255471_decimalsValidation();
+
+ void taskQTBUG_5008_textFromValueAndValidate();
+ void taskQTBUG_6670_selectAllWithPrefix();
+ void taskQTBUG_6496_fiddlingWithPrecision();
+
+public slots:
+ void valueChangedHelper(const QString &);
+ void valueChangedHelper(double);
+private:
+ QStringList actualTexts;
+ QList<double> actualValues;
+ QWidget *testFocusWidget;
+};
+
+typedef QList<double> DoubleList;
+Q_DECLARE_METATYPE(DoubleList)
+
+tst_QDoubleSpinBox::tst_QDoubleSpinBox()
+
+{
+}
+
+tst_QDoubleSpinBox::~tst_QDoubleSpinBox()
+{
+
+}
+
+void tst_QDoubleSpinBox::initTestCase()
+{
+ testFocusWidget = new QWidget(0);
+ testFocusWidget->resize(200, 100);
+ testFocusWidget->show();
+}
+
+void tst_QDoubleSpinBox::cleanupTestCase()
+{
+ delete testFocusWidget;
+ testFocusWidget = 0;
+}
+
+void tst_QDoubleSpinBox::init()
+{
+ QLocale::setDefault(QLocale(QLocale::C));
+}
+
+void tst_QDoubleSpinBox::setValue_data()
+{
+ QTest::addColumn<double>("val");
+
+ QTest::newRow("data0") << 0.0;
+ QTest::newRow("data1") << 100.5;
+ QTest::newRow("data2") << -100.5;
+ QTest::newRow("data3") << -DBL_MAX;
+ QTest::newRow("data4") << DBL_MAX;
+}
+
+void tst_QDoubleSpinBox::setValue()
+{
+ QFETCH(double, val);
+ QDoubleSpinBox spin(0);
+ spin.setRange(-DBL_MAX, DBL_MAX);
+ spin.setValue(val);
+ QCOMPARE(spin.value(), val);
+}
+
+void tst_QDoubleSpinBox::setPrefixSuffix_data()
+{
+ QTest::addColumn<QString>("prefix");
+ QTest::addColumn<QString>("suffix");
+ QTest::addColumn<double>("value");
+ QTest::addColumn<int>("decimals");
+ QTest::addColumn<QString>("expectedText");
+ QTest::addColumn<QString>("expectedCleanText");
+ QTest::addColumn<bool>("show");
+
+ QTest::newRow("data0") << QString() << QString() << 10.5 << 1 << "10.5" << "10.5" << false;
+ QTest::newRow("data1") << QString() << "cm" << 10.5 << 2 << "10.50cm" << "10.50" << false;
+ QTest::newRow("data2") << "cm: " << QString() << 10.5 << 0 << "cm: 10" << "10" << false;
+ QTest::newRow("data3") << "length: " << "cm" << 10.5 << 3 << "length: 10.500cm" << "10.500" << false;
+
+ QTest::newRow("data4") << QString() << QString() << 10.5 << 1 << "10.5" << "10.5" << true;
+ QTest::newRow("data5") << QString() << "cm" << 10.5 << 2 << "10.50cm" << "10.50" << true;
+ QTest::newRow("data6") << "cm: " << QString() << 10.5 << 0 << "cm: 10" << "10" << true;
+ QTest::newRow("data7") << "length: " << "cm" << 10.5 << 3 << "length: 10.500cm" << "10.500" << true;
+}
+
+void tst_QDoubleSpinBox::setPrefixSuffix()
+{
+ QFETCH(QString, prefix);
+ QFETCH(QString, suffix);
+ QFETCH(double, value);
+ QFETCH(int, decimals);
+ QFETCH(QString, expectedText);
+ QFETCH(QString, expectedCleanText);
+ QFETCH(bool, show);
+
+ QDoubleSpinBox spin(0);
+ spin.setDecimals(decimals);
+ spin.setPrefix(prefix);
+ spin.setSuffix(suffix);
+ spin.setValue(value);
+ if (show)
+ spin.show();
+
+ QCOMPARE(spin.text(), expectedText);
+ QCOMPARE(spin.cleanText(), expectedCleanText);
+}
+
+void tst_QDoubleSpinBox::valueChangedHelper(const QString &text)
+{
+ actualTexts << text;
+}
+
+void tst_QDoubleSpinBox::valueChangedHelper(double value)
+{
+ actualValues << value;
+}
+
+void tst_QDoubleSpinBox::setTracking_data()
+{
+ QTest::addColumn<int>("decimals");
+ QTest::addColumn<QTestEventList>("keys");
+ QTest::addColumn<QStringList>("texts");
+ QTest::addColumn<bool>("tracking");
+
+ QTestEventList keys;
+ QStringList texts1;
+ QStringList texts2;
+#ifdef Q_WS_MAC
+ keys.addKeyClick(Qt::Key_Right, Qt::ControlModifier);
+#else
+ keys.addKeyClick(Qt::Key_End);
+#endif
+ keys.addKeyClick(Qt::Key_Backspace);
+ keys.addKeyClick(Qt::Key_Backspace);
+ keys.addKeyClick(Qt::Key_Backspace);
+ keys.addKeyClick(Qt::Key_Backspace);
+ keys.addKeyClick(Qt::Key_Backspace);
+ keys.addKeyClick(Qt::Key_Backspace);
+ keys.addKeyClick(Qt::Key_Backspace);
+ keys.addKeyClick(Qt::Key_Backspace);
+ keys.addKeyClick('7');
+ keys.addKeyClick('.');
+ keys.addKeyClick('9');
+ keys.addKeyClick(Qt::Key_Backspace);
+ keys.addKeyClick('2');
+ keys.addKeyClick(Qt::Key_Enter);
+ keys.addKeyClick(Qt::Key_Enter);
+ keys.addKeyClick(Qt::Key_Enter);
+ texts1 << "7" << "7.9" << "7." << "7.2" << "7.200" << "7.200" << "7.200";
+ texts2 << "7.200";
+ QTest::newRow("data1") << 3 << keys << texts1 << true;
+ QTest::newRow("data2") << 3 << keys << texts2 << false;
+
+}
+
+void tst_QDoubleSpinBox::setTracking()
+{
+ QLocale::setDefault(QLocale(QLocale::C));
+
+ actualTexts.clear();
+ QFETCH(int, decimals);
+ QFETCH(QTestEventList, keys);
+ QFETCH(QStringList, texts);
+ QFETCH(bool, tracking);
+
+ QDoubleSpinBox spin(0);
+ spin.setKeyboardTracking(tracking);
+ spin.setDecimals(decimals);
+ spin.show();
+
+ connect(&spin, SIGNAL(valueChanged(QString)), this, SLOT(valueChangedHelper(const QString &)));
+
+ keys.simulate(&spin);
+ QCOMPARE(actualTexts, texts);
+}
+
+void tst_QDoubleSpinBox::setWrapping_data()
+{
+ QTest::addColumn<bool>("wrapping");
+ QTest::addColumn<double>("minimum");
+ QTest::addColumn<double>("maximum");
+ QTest::addColumn<double>("startValue");
+ QTest::addColumn<QTestEventList>("keys");
+ QTest::addColumn<DoubleList>("expected");
+
+ QTestEventList keys;
+ DoubleList values;
+ keys.addKeyClick(Qt::Key_Up);
+ values << 10;
+ keys.addKeyClick(Qt::Key_Up);
+ QTest::newRow("data0") << false << 0.0 << 10.0 << 9.0 << keys << values;
+
+ keys.clear();
+ values.clear();
+ keys.addKeyClick(Qt::Key_Up);
+ values << 10;
+ keys.addKeyClick(Qt::Key_Up);
+ values << 0;
+ QTest::newRow("data1") << true << 0.0 << 10.0 << 9.0 << keys << values;
+
+ keys.clear();
+ values.clear();
+#ifdef Q_WS_MAC
+ keys.addKeyClick(Qt::Key_Right, Qt::ControlModifier);
+#else
+ keys.addKeyClick(Qt::Key_End);
+#endif
+ keys.addKeyClick(Qt::Key_Backspace);
+ keys.addKeyClick('1');
+ keys.addKeyClick(Qt::Key_Down);
+ keys.addKeyClick(Qt::Key_Down);
+ keys.addKeyClick(Qt::Key_PageDown);
+ values << 9.01 << 8.01 << 7.01 << 0.0;
+ QTest::newRow("data2") << false << 0.0 << 10.0 << 9.0 << keys << values;
+
+ keys.clear();
+ values.clear();
+#ifdef Q_WS_MAC
+ keys.addKeyClick(Qt::Key_Left, Qt::ControlModifier);
+#else
+ keys.addKeyClick(Qt::Key_Home);
+#endif
+ keys.addKeyClick(Qt::Key_Delete);
+ keys.addKeyClick(Qt::Key_Delete);
+ keys.addKeyClick(Qt::Key_Delete);
+ keys.addKeyClick(Qt::Key_Delete);
+ keys.addKeyClick(Qt::Key_Delete);
+ keys.addKeyClick(Qt::Key_Delete);
+ keys.addKeyClick(Qt::Key_Delete);
+ keys.addKeyClick('1');
+ keys.addKeyClick(Qt::Key_Down);
+ keys.addKeyClick(Qt::Key_Down);
+ values << 0 << 1 << 0 << 10;
+ QTest::newRow("data3") << true << 0.0 << 10.0 << 9.0 << keys << values;
+
+ keys.clear();
+ values.clear();
+ keys.addKeyClick(Qt::Key_PageDown);
+ keys.addKeyClick(Qt::Key_Down);
+ values << 0;
+ QTest::newRow("data4") << false << 0.0 << 10.0 << 6.0 << keys << values;
+
+ keys.clear();
+ values.clear();
+ keys.addKeyClick(Qt::Key_PageDown);
+ keys.addKeyClick(Qt::Key_Down);
+ values << 0 << 10;
+ QTest::newRow("data5") << true << 0.0 << 10.0 << 6.0 << keys << values;
+
+ keys.clear();
+ values.clear();
+ keys.addKeyClick(Qt::Key_PageUp);
+ keys.addKeyClick(Qt::Key_PageDown);
+ keys.addKeyClick(Qt::Key_Down);
+ keys.addKeyClick(Qt::Key_Up);
+ keys.addKeyClick(Qt::Key_PageDown);
+ keys.addKeyClick(Qt::Key_PageDown);
+ values << 10 << 0 << 10 << 0 << 10 << 0;
+ QTest::newRow("data6") << true << 0.0 << 10.0 << 6.0 << keys << values;
+
+}
+
+
+void tst_QDoubleSpinBox::setWrapping()
+{
+ QLocale::setDefault(QLocale(QLocale::C));
+ QFETCH(bool, wrapping);
+ QFETCH(double, minimum);
+ QFETCH(double, maximum);
+ QFETCH(double, startValue);
+ QFETCH(QTestEventList, keys);
+ QFETCH(DoubleList, expected);
+
+ QDoubleSpinBox spin(0);
+ spin.setMinimum(minimum);
+ spin.setMaximum(maximum);
+ spin.setValue(startValue);
+ spin.setWrapping(wrapping);
+ spin.show();
+ actualValues.clear();
+ connect(&spin, SIGNAL(valueChanged(double)), this, SLOT(valueChangedHelper(double)));
+
+ keys.simulate(&spin);
+
+ QCOMPARE(actualValues.size(), expected.size());
+ for (int i=0; i<qMin(actualValues.size(), expected.size()); ++i) {
+ QCOMPARE(actualValues.at(i), expected.at(i));
+ }
+}
+
+void tst_QDoubleSpinBox::setSpecialValueText_data()
+{
+ QTest::addColumn<QString>("specialValueText");
+ QTest::addColumn<double>("minimum");
+ QTest::addColumn<double>("maximum");
+ QTest::addColumn<double>("value");
+ QTest::addColumn<int>("decimals");
+ QTest::addColumn<QString>("expected");
+ QTest::addColumn<bool>("show");
+
+ QTest::newRow("data0") << QString() << 0.0 << 10.0 << 1.0 << 4 << "1.0000" << false;
+ QTest::newRow("data1") << QString() << 0.0 << 10.0 << 1.0 << 4 << "1.0000" << true;
+ QTest::newRow("data2") << "foo" << 0.0 << 10.0 << 0.0 << 2 << "foo" << false;
+ QTest::newRow("data3") << "foo" << 0.0 << 10.0 << 0.0 << 2 << "foo" << true;
+}
+
+void tst_QDoubleSpinBox::setSpecialValueText()
+{
+ QFETCH(QString, specialValueText);
+ QFETCH(double, minimum);
+ QFETCH(double, maximum);
+ QFETCH(double, value);
+ QFETCH(int, decimals);
+ QFETCH(QString, expected);
+ QFETCH(bool, show);
+
+ QDoubleSpinBox spin(0);
+ spin.setSpecialValueText(specialValueText);
+ spin.setMinimum(minimum);
+ spin.setMaximum(maximum);
+ spin.setValue(value);
+ spin.setDecimals(decimals);
+ if (show)
+ spin.show();
+
+ QCOMPARE(spin.text(), expected);
+}
+
+void tst_QDoubleSpinBox::setSingleStep_data()
+{
+ QTest::addColumn<double>("singleStep");
+ QTest::addColumn<double>("startValue");
+ QTest::addColumn<QTestEventList>("keys");
+ QTest::addColumn<DoubleList>("expected");
+ QTest::addColumn<bool>("show");
+
+ QTestEventList keys;
+ DoubleList values;
+ keys.addKeyClick(Qt::Key_Up);
+ keys.addKeyClick(Qt::Key_Down);
+ keys.addKeyClick(Qt::Key_Up);
+ values << 11 << 10 << 11;
+ QTest::newRow("data0") << 1.0 << 10.0 << keys << values << false;
+ QTest::newRow("data1") << 1.0 << 10.0 << keys << values << true;
+
+ keys.clear();
+ values.clear();
+ keys.addKeyClick(Qt::Key_Up);
+ keys.addKeyClick(Qt::Key_Down);
+ keys.addKeyClick(Qt::Key_Up);
+ values << 12.5 << 10.0 << 12.5;
+ QTest::newRow("data2") << 2.5 << 10.0 << keys << values << false;
+ QTest::newRow("data3") << 2.5 << 10.0 << keys << values << true;
+}
+
+void tst_QDoubleSpinBox::setSingleStep()
+{
+ QFETCH(double, singleStep);
+ QFETCH(double, startValue);
+ QFETCH(QTestEventList, keys);
+ QFETCH(DoubleList, expected);
+ QFETCH(bool, show);
+
+ QDoubleSpinBox spin(0);
+ actualValues.clear();
+ spin.setSingleStep(singleStep);
+ spin.setValue(startValue);
+ if (show)
+ spin.show();
+ connect(&spin, SIGNAL(valueChanged(double)), this, SLOT(valueChangedHelper(double)));
+
+ QCOMPARE(actualValues.size(), 0);
+ keys.simulate(&spin);
+ QCOMPARE(actualValues.size(), expected.size());
+ for (int i=0; i<qMin(actualValues.size(), expected.size()); ++i) {
+ QCOMPARE(actualValues.at(i), expected.at(i));
+ }
+}
+
+void tst_QDoubleSpinBox::setMinMax_data()
+{
+ QTest::addColumn<double>("startValue");
+ QTest::addColumn<double>("minimum");
+ QTest::addColumn<double>("maximum");
+ QTest::addColumn<QTestEventList>("keys");
+ QTest::addColumn<double>("expected");
+ QTest::addColumn<bool>("show");
+
+ QTestEventList keys;
+ keys.addKeyClick(Qt::Key_Up);
+ keys.addKeyClick(Qt::Key_Up);
+ keys.addKeyClick(Qt::Key_Up);
+ keys.addKeyClick(Qt::Key_Up);
+ keys.addKeyClick(Qt::Key_Up);
+ QTest::newRow("data0") << 1.0 << -DBL_MAX << 2.0 << keys << 2.0 << false;
+ QTest::newRow("data1") << 1.0 << -DBL_MAX << 2.0 << keys << 2.0 << true;
+ QTest::newRow("data2") << -20000.0 << -15000.0 << -13000.0 << keys << -14995.0 << false;
+ QTest::newRow("data3") << -20000.0 << -15000.0 << -13000.0 << keys << -14995.0 << true;
+ QTest::newRow("data4") << 20.0 << -101.2 << -102.0 << QTestEventList() << -102.0 << false;
+ QTest::newRow("data5") << 20.0 << -101.2 << -102.0 << QTestEventList() << -102.0 << true;
+}
+
+void tst_QDoubleSpinBox::setMinMax()
+{
+ QFETCH(double, startValue);
+ QFETCH(double, minimum);
+ QFETCH(double, maximum);
+ QFETCH(QTestEventList, keys);
+ QFETCH(double, expected);
+ QFETCH(bool, show);
+
+ {
+ QDoubleSpinBox spin(0);
+ spin.setMinimum(minimum);
+ spin.setMaximum(maximum);
+ spin.setValue(startValue);
+
+ if (show)
+ spin.show();
+ keys.simulate(&spin);
+ QCOMPARE(spin.value(), expected);
+ }
+
+ {
+ QDoubleSpinBox spin(0);
+ spin.setMaximum(maximum);
+ spin.setMinimum(minimum);
+ spin.setValue(startValue);
+
+ if (show)
+ spin.show();
+ keys.simulate(&spin);
+ }
+
+ {
+ QDoubleSpinBox spin(0);
+ spin.setRange(minimum, maximum);
+ spin.setValue(startValue);
+
+ if (show)
+ spin.show();
+ keys.simulate(&spin);
+ }
+
+
+}
+
+void tst_QDoubleSpinBox::setDecimals_data()
+{
+ QTest::addColumn<int>("decimals");
+ QTest::addColumn<int>("expectedDecimals");
+ QTest::addColumn<double>("startValue");
+ QTest::addColumn<QString>("expected");
+
+ QTest::newRow("data0") << 4 << 4 << 1.0 << "1.0000";
+ QTest::newRow("data1") << 1 << 1 << 1.243443 << "1.2";
+ QTest::newRow("data2") << 6 << 6 << 1.29 << "1.290000";
+ QTest::newRow("data3") << 8 << 8 << 9.1234567809 << "9.12345678";
+ QTest::newRow("data4") << 13 << 13 << 0.12345678901237 << "0.1234567890124";
+ QTest::newRow("data5") << 13 << 13 << -0.12345678901237 << "-0.1234567890124";
+ QTest::newRow("data6") << 13 << 13 << -0.12345678901237 << "-0.1234567890124";
+ QTest::newRow("data7") << -1 << 0 << 0.1 << "0";
+ QTest::newRow("data8") << 120 << 120 << -0.12345678901237 << "-0.123456789012370005131913330842508003115653991699218750000000000000000000000000000000000000000000000000000000000000000000";
+
+}
+
+void tst_QDoubleSpinBox::setDecimals()
+{
+ QFETCH(int, decimals);
+ QFETCH(int, expectedDecimals);
+ QFETCH(double, startValue);
+ QFETCH(QString, expected);
+
+ QDoubleSpinBox spin(0);
+ spin.setRange(-DBL_MAX, DBL_MAX);
+ spin.setDecimals(decimals);
+ spin.setValue(startValue);
+ QCOMPARE(spin.decimals(), expectedDecimals);
+ if (sizeof(qreal) == sizeof(float))
+ QCOMPARE(spin.text().left(17), expected.left(17));
+ else
+ QCOMPARE(spin.text(), expected);
+
+ if (spin.decimals() > 0) {
+#ifdef Q_WS_MAC
+ QTest::keyClick(&spin, Qt::Key_Right, Qt::ControlModifier);
+#else
+ QTest::keyClick(&spin, Qt::Key_End);
+#endif
+ QTest::keyClick(&spin, Qt::Key_1); // just make sure we can't input more decimals than what is specified
+ QTest::keyClick(&spin, Qt::Key_1);
+ QTest::keyClick(&spin, Qt::Key_1);
+ QTest::keyClick(&spin, Qt::Key_1);
+ QTest::keyClick(&spin, Qt::Key_1);
+ if (sizeof(qreal) == sizeof(float))
+ QCOMPARE(spin.text().left(17), expected.left(17));
+ else
+ QCOMPARE(spin.text(), expected);
+ }
+}
+
+static QString stateName(int state)
+{
+ switch (state) {
+ case QValidator::Acceptable: return QString("Acceptable");
+ case QValidator::Intermediate: return QString("Intermediate");
+ case QValidator::Invalid: return QString("Invalid");
+ default: break;
+ }
+ qWarning("%s %d: this should never happen", __FILE__, __LINE__);
+ return QString();
+}
+
+void tst_QDoubleSpinBox::valueFromTextAndValidate_data()
+{
+ const int Intermediate = QValidator::Intermediate;
+ const int Invalid = QValidator::Invalid;
+ const int Acceptable = QValidator::Acceptable;
+
+ QTest::addColumn<QString>("txt");
+ QTest::addColumn<int>("state");
+ QTest::addColumn<double>("mini");
+ QTest::addColumn<double>("maxi");
+ QTest::addColumn<int>("language");
+ QTest::addColumn<QString>("expectedText"); // if empty we don't check
+
+ QTest::newRow("data0") << QString("2.2") << Intermediate << 3.0 << 5.0 << (int)QLocale::C << QString();
+ QTest::newRow("data1") << QString() << Intermediate << 0.0 << 100.0 << (int)QLocale::C << QString();
+ QTest::newRow("data2") << QString("asd") << Invalid << 0.0 << 100.0 << (int)QLocale::C << QString();
+ QTest::newRow("data3") << QString("2.2") << Acceptable << 0.0 << 100.0 << (int)QLocale::C << QString();
+ QTest::newRow("data4") << QString(" ") << Intermediate << 0.0 << 100.0 << (int)QLocale::Norwegian << QString();
+ QTest::newRow("data5") << QString(" ") << Intermediate << 0.0 << 100.0 << (int)QLocale::C << QString();
+ QTest::newRow("data6") << QString(",") << Intermediate << 0.0 << 100.0 << (int)QLocale::Norwegian << QString();
+ QTest::newRow("data7") << QString(",") << Invalid << 0.0 << 100.0 << (int)QLocale::C << QString();
+ QTest::newRow("data8") << QString("1 ") << Acceptable << 0.0 << 1000.0 << (int)QLocale::Norwegian << QString("1");
+ QTest::newRow("data9") << QString("1 ") << Acceptable << 0.0 << 100.0 << (int)QLocale::C << QString("1");
+ QTest::newRow("data10") << QString(" 1") << Acceptable << 0.0 << 100.0 << (int)QLocale::Norwegian << QString("1");
+ QTest::newRow("data11") << QString(" 1") << Acceptable << 0.0 << 100.0 << (int)QLocale::C << QString("1");
+ QTest::newRow("data12") << QString("1,") << Acceptable << 0.0 << 100.0 << (int)QLocale::Norwegian << QString();
+ QTest::newRow("data13") << QString("1,") << Acceptable << 0.0 << 1000.0 << (int)QLocale::C << QString();
+ QTest::newRow("data14") << QString("1, ") << Acceptable << 0.0 << 100.0 << (int)QLocale::Norwegian << QString("1,");
+ QTest::newRow("data15") << QString("1, ") << Invalid << 0.0 << 100.0 << (int)QLocale::C << QString();
+ QTest::newRow("data16") << QString("2") << Intermediate << 100.0 << 102.0 << (int)QLocale::C << QString();
+ QTest::newRow("data17") << QString("22.0") << Intermediate << 100.0 << 102.0 << (int)QLocale::C << QString();
+ QTest::newRow("data18") << QString("12.0") << Intermediate << 100.0 << 102.0 << (int)QLocale::C << QString();
+ QTest::newRow("data19") << QString("12.2") << Intermediate << 100. << 102.0 << (int)QLocale::C << QString();
+ QTest::newRow("data20") << QString("21.") << Intermediate << 100.0 << 102.0 << (int)QLocale::C << QString();
+ QTest::newRow("data21") << QString("-21.") << Intermediate << -102.0 << -100.0 << (int)QLocale::C << QString();
+ QTest::newRow("data22") << QString("-12.") << Intermediate << -102.0 << -100.0 << (int)QLocale::C << QString();
+ QTest::newRow("data23") << QString("-11.11") << Intermediate << -102.0 << -101.2 << (int)QLocale::C << QString();
+ QTest::newRow("data24") << QString("-11.4") << Intermediate << -102.0 << -101.3 << (int)QLocale::C << QString();
+ QTest::newRow("data25") << QString("11.400") << Invalid << 0.0 << 100.0 << (int)QLocale::C << QString();
+ QTest::newRow("data26") << QString(".4") << Intermediate << 0.45 << 0.5 << (int)QLocale::C << QString();
+ QTest::newRow("data27") << QString("+.4") << Intermediate << 0.45 << 0.5 << (int)QLocale::C << QString();
+ QTest::newRow("data28") << QString("-.4") << Intermediate << -0.5 << -0.45 << (int)QLocale::C << QString();
+ QTest::newRow("data29") << QString(".4") << Intermediate << 1.0 << 2.4 << (int)QLocale::C << QString();
+ QTest::newRow("data30") << QString("-.4") << Intermediate << -2.3 << -1.9 << (int)QLocale::C << QString();
+ QTest::newRow("data31") << QString("-42") << Invalid << -2.43 << -1.0 << (int)QLocale::C << QString();
+ QTest::newRow("data32") << QString("-4") << Invalid << -1.4 << -1.0 << (int)QLocale::C << QString();
+ QTest::newRow("data33") << QString("-42") << Invalid << -1.4 << -1.0 << (int)QLocale::C << QString();
+ QTest::newRow("data34") << QString("1000000000000") << Invalid << -140.0 << -120.2 << (int)QLocale::C << QString();
+ QTest::newRow("data35") << QString("+.12") << Invalid << -5.0 << -3.2 << (int)QLocale::C << QString();
+ QTest::newRow("data36") << QString("-.12") << Invalid << 5.0 << 33.2 << (int)QLocale::C << QString();
+ QTest::newRow("data37") << QString("12.2") << Intermediate << 100. << 103.0 << (int)QLocale::C << QString();
+ QTest::newRow("data38") << QString("12.2") << Intermediate << 100. << 102.3 << (int)QLocale::C << QString();
+ QTest::newRow("data39") << QString("-12.") << Acceptable << -102.0 << 102.0 << (int)QLocale::C << QString();
+ QTest::newRow("data40") << QString("12.") << Invalid << -102.0 << 11.0 << (int)QLocale::C << QString();
+ QTest::newRow("data41") << QString("103.") << Invalid << -102.0 << 11.0 << (int)QLocale::C << QString();
+ QTest::newRow("data42") << QString("122") << Invalid << 10.0 << 12.2 << (int)QLocale::C << QString();
+ QTest::newRow("data43") << QString("-2.2") << Intermediate << -12.2 << -3.2 << (int)QLocale::C << QString();
+ QTest::newRow("data44") << QString("-2.20") << Intermediate << -12.1 << -3.2 << (int)QLocale::C << QString();
+ QTest::newRow("data45") << QString("200,2") << Invalid << 0.0 << 1000.0 << (int)QLocale::C << QString();
+ QTest::newRow("data46") << QString("200,2") << Acceptable << 0.0 << 1000.0 << (int)QLocale::German << QString();
+ QTest::newRow("data47") << QString("2.2") << Acceptable << 0.0 << 1000.0 << (int)QLocale::C << QString();
+ QTest::newRow("data48") << QString("2.2") << Acceptable << 0.0 << 1000.0 << (int)QLocale::German << QString();
+ QTest::newRow("data49") << QString("2.2,00") << Acceptable << 0.0 << 1000.0 << (int)QLocale::German << QString();
+ QTest::newRow("data50") << QString("2.2") << Acceptable << 0.0 << 1000.0 << (int)QLocale::C << QString();
+ QTest::newRow("data51") << QString("2.2,00") << Invalid << 0.0 << 1000.0 << (int)QLocale::C << QString();
+ QTest::newRow("data52") << QString("2..2,00") << Invalid << 0.0 << 1000.0 << (int)QLocale::German << QString();
+ QTest::newRow("data53") << QString("2.2") << Invalid << 0.0 << 1000.0 << (int)QLocale::Norwegian << QString();
+ QTest::newRow("data54") << QString(" 2.2") << Acceptable << 0.0 << 1000.0 << (int)QLocale::C << QString();
+ QTest::newRow("data55") << QString("2.2 ") << Acceptable << 0.0 << 1000.0 << (int)QLocale::C << QString("2.2");
+ QTest::newRow("data56") << QString(" 2.2 ") << Acceptable << 0.0 << 1000.0 << (int)QLocale::C << QString("2.2");
+ QTest::newRow("data57") << QString("2 2") << Invalid << 0.0 << 1000.0 << (int)QLocale::C << QString();
+}
+
+void tst_QDoubleSpinBox::valueFromTextAndValidate()
+{
+ QFETCH(QString, txt);
+ QFETCH(int, state);
+ QFETCH(double, mini);
+ QFETCH(double, maxi);
+ QFETCH(int, language);
+ QFETCH(QString, expectedText);
+ QLocale::setDefault(QLocale((QLocale::Language)language));
+
+ DoubleSpinBox sb(0);
+ sb.show();
+ sb.setRange(mini, maxi);
+
+ int unused = 0;
+ QCOMPARE(stateName(sb.validate(txt, unused)), stateName(state));
+ if (!expectedText.isEmpty())
+ QCOMPARE(txt, expectedText);
+}
+
+void tst_QDoubleSpinBox::setReadOnly()
+{
+ QDoubleSpinBox spin(0);
+ spin.setValue(0.2);
+ spin.show();
+ QCOMPARE(spin.value(), 0.2);
+ QTest::keyClick(&spin, Qt::Key_Up);
+ QCOMPARE(spin.value(), 1.2);
+ spin.setReadOnly(true);
+ QTest::keyClick(&spin, Qt::Key_Up);
+ QCOMPARE(spin.value(), 1.2);
+ spin.stepBy(1);
+ QCOMPARE(spin.value(), 2.2);
+ spin.setReadOnly(false);
+ QTest::keyClick(&spin, Qt::Key_Up);
+ QCOMPARE(spin.value(), 3.2);
+}
+
+void tst_QDoubleSpinBox::editingFinished()
+{
+ QVBoxLayout *layout = new QVBoxLayout(testFocusWidget);
+ QDoubleSpinBox *box = new QDoubleSpinBox(testFocusWidget);
+ layout->addWidget(box);
+ QDoubleSpinBox *box2 = new QDoubleSpinBox(testFocusWidget);
+ layout->addWidget(box2);
+
+ testFocusWidget->show();
+ QApplication::setActiveWindow(testFocusWidget);
+ QTest::qWait(10);
+ QTRY_VERIFY(testFocusWidget->isActiveWindow());
+ box->setFocus();
+ QTRY_VERIFY(box->hasFocus());
+
+ QSignalSpy editingFinishedSpy1(box, SIGNAL(editingFinished()));
+ QSignalSpy editingFinishedSpy2(box2, SIGNAL(editingFinished()));
+
+ box->setFocus();
+ QTest::keyClick(box, Qt::Key_Up);
+ QTest::keyClick(box, Qt::Key_Up);
+
+
+ QCOMPARE(editingFinishedSpy1.count(), 0);
+ QCOMPARE(editingFinishedSpy2.count(), 0);
+
+ QTest::keyClick(box2, Qt::Key_Up);
+ QTest::keyClick(box2, Qt::Key_Up);
+ box2->setFocus();
+ QCOMPARE(editingFinishedSpy1.count(), 1);
+ box->setFocus();
+ QCOMPARE(editingFinishedSpy1.count(), 1);
+ QCOMPARE(editingFinishedSpy2.count(), 1);
+ QTest::keyClick(box, Qt::Key_Up);
+ QCOMPARE(editingFinishedSpy1.count(), 1);
+ QCOMPARE(editingFinishedSpy2.count(), 1);
+ QTest::keyClick(box, Qt::Key_Enter);
+ QCOMPARE(editingFinishedSpy1.count(), 2);
+ QCOMPARE(editingFinishedSpy2.count(), 1);
+ QTest::keyClick(box, Qt::Key_Return);
+ QCOMPARE(editingFinishedSpy1.count(), 3);
+ QCOMPARE(editingFinishedSpy2.count(), 1);
+ box2->setFocus();
+ QCOMPARE(editingFinishedSpy1.count(), 4);
+ QCOMPARE(editingFinishedSpy2.count(), 1);
+ QTest::keyClick(box2, Qt::Key_Enter);
+ QCOMPARE(editingFinishedSpy1.count(), 4);
+ QCOMPARE(editingFinishedSpy2.count(), 2);
+ QTest::keyClick(box2, Qt::Key_Return);
+ QCOMPARE(editingFinishedSpy1.count(), 4);
+ QCOMPARE(editingFinishedSpy2.count(), 3);
+ testFocusWidget->hide();
+ QCOMPARE(editingFinishedSpy1.count(), 4);
+ QCOMPARE(editingFinishedSpy2.count(), 4);
+
+}
+
+void tst_QDoubleSpinBox::removeAll()
+{
+ DoubleSpinBox spin(0);
+ spin.setPrefix("foo");
+ spin.setSuffix("bar");
+ spin.setValue(0.2);
+ spin.setDecimals(1);
+ spin.show();
+#ifdef Q_WS_MAC
+ QTest::keyClick(&spin, Qt::Key_Left, Qt::ControlModifier);
+#else
+ QTest::keyClick(&spin, Qt::Key_Home);
+#endif
+
+#ifdef Q_WS_MAC
+ QTest::keyClick(&spin, Qt::Key_Right, Qt::ControlModifier|Qt::ShiftModifier);
+#else
+ QTest::keyClick(&spin, Qt::Key_End, Qt::ShiftModifier);
+#endif
+
+ QCOMPARE(spin.lineEdit()->selectedText(), QString("foo0.2bar"));
+ QTest::keyClick(&spin, Qt::Key_1);
+ QCOMPARE(spin.text(), QString("foo1bar"));
+}
+
+void tst_QDoubleSpinBox::task54433()
+{
+ DoubleSpinBox priceSpinBox;
+ priceSpinBox.show();
+ priceSpinBox.setRange(0.0, 999.99);
+ priceSpinBox.setDecimals(2);
+ priceSpinBox.setValue(999.99);
+ QCOMPARE(priceSpinBox.text(), QString("999.99"));
+ QCOMPARE(priceSpinBox.value(), 999.99);
+ QCOMPARE(priceSpinBox.maximum(), 999.99);
+ priceSpinBox.setDecimals(1);
+ QCOMPARE(priceSpinBox.value(), 1000.0);
+ QCOMPARE(priceSpinBox.maximum(), 1000.0);
+ QCOMPARE(priceSpinBox.text(), QString("1000.0"));
+
+ priceSpinBox.setDecimals(2);
+ priceSpinBox.setRange(-999.99, 0.0);
+ priceSpinBox.setValue(-999.99);
+ QCOMPARE(priceSpinBox.text(), QString("-999.99"));
+ QCOMPARE(priceSpinBox.value(), -999.99);
+ QCOMPARE(priceSpinBox.minimum(), -999.99);
+ priceSpinBox.setDecimals(1);
+ QCOMPARE(priceSpinBox.value(), -1000.0);
+ QCOMPARE(priceSpinBox.minimum(), -1000.0);
+ QCOMPARE(priceSpinBox.text(), QString("-1000.0"));
+}
+
+
+
+void tst_QDoubleSpinBox::germanTest()
+{
+ QLocale::setDefault(QLocale(QLocale::German));
+ DoubleSpinBox spin;
+ spin.show();
+ spin.setValue(2.12);
+#ifdef Q_WS_MAC
+ QTest::keyClick(&spin, Qt::Key_Right, Qt::ControlModifier);
+#else
+ QTest::keyClick(&spin, Qt::Key_End);
+#endif
+ QTest::keyClick(&spin, Qt::Key_Backspace);
+ QCOMPARE(spin.text(), QString("2,1"));
+ QTest::keyClick(&spin, Qt::Key_Enter);
+ QCOMPARE(spin.text(), QString("2,10"));
+}
+
+void tst_QDoubleSpinBox::doubleDot()
+{
+ DoubleSpinBox spin;
+ spin.show();
+ spin.setValue(2.12);
+ QTest::keyClick(&spin, Qt::Key_Backspace);
+ QCOMPARE(spin.text(), QString("2.12"));
+#ifdef Q_WS_MAC
+ QTest::keyClick(&spin, Qt::Key_Left, Qt::ControlModifier);
+#else
+ QTest::keyClick(&spin, Qt::Key_Home);
+#endif
+ QTest::keyClick(&spin, Qt::Key_Right, Qt::ShiftModifier);
+ QCOMPARE(spin.lineEdit()->selectedText(), QString("2"));
+ QTest::keyClick(&spin, Qt::Key_1);
+ QCOMPARE(spin.text(), QString("1.12"));
+ QCOMPARE(spin.lineEdit()->cursorPosition(), 1);
+ QTest::keyClick(&spin, Qt::Key_Period);
+ QCOMPARE(spin.text(), QString("1.12"));
+ QCOMPARE(spin.lineEdit()->cursorPosition(), 2);
+}
+
+void tst_QDoubleSpinBox::undoRedo()
+{
+ //test undo/redo feature (in conjunction with the "undoRedoEnabled" property)
+ DoubleSpinBox spin(0);
+ spin.show();
+
+ //the undo/redo is disabled by default
+
+ QCOMPARE(spin.value(), 0.0); //this is the default value
+ QVERIFY(!spin.lineEdit()->isUndoAvailable());
+ QVERIFY(!spin.lineEdit()->isRedoAvailable());
+
+ spin.lineEdit()->selectAll(); //ensures everything is selected and will be cleared by typing a key
+ QTest::keyClick(&spin, Qt::Key_1); //we put 1 into the spinbox
+ QCOMPARE(spin.value(), 1.0);
+ QVERIFY(spin.lineEdit()->isUndoAvailable());
+
+ //testing CTRL+Z (undo)
+ int val = QKeySequence(QKeySequence::Undo)[0];
+ if (val != 0) {
+ Qt::KeyboardModifiers mods = (Qt::KeyboardModifiers)(val & Qt::KeyboardModifierMask);
+ QTest::keyClick(&spin, val & ~mods, mods);
+ QCOMPARE(spin.value(), 0.0);
+ QVERIFY(!spin.lineEdit()->isUndoAvailable());
+ QVERIFY(spin.lineEdit()->isRedoAvailable());
+ } else {
+ QWARN("Undo not tested because no key sequence associated to QKeySequence::Redo");
+ }
+
+
+ //testing CTRL+Y (redo)
+ val = QKeySequence(QKeySequence::Redo)[0];
+ if (val != 0) {
+ Qt::KeyboardModifiers mods = (Qt::KeyboardModifiers)(val & Qt::KeyboardModifierMask);
+ QTest::keyClick(&spin, val & ~mods, mods);
+ QCOMPARE(spin.value(), 1.0);
+ QVERIFY(!spin.lineEdit()->isRedoAvailable());
+ QVERIFY(spin.lineEdit()->isUndoAvailable());
+ } else {
+ QWARN("Redo not tested because no key sequence associated to QKeySequence::Redo");
+ }
+
+
+ spin.setValue(55.0);
+ QVERIFY(!spin.lineEdit()->isUndoAvailable());
+ QVERIFY(!spin.lineEdit()->isRedoAvailable());
+}
+
+struct task199226_DoubleSpinBox : public QDoubleSpinBox
+{
+ task199226_DoubleSpinBox(QWidget *parent = 0) : QDoubleSpinBox(parent) {}
+ QLineEdit *lineEdit() { return QAbstractSpinBox::lineEdit(); }
+};
+
+void tst_QDoubleSpinBox::task199226_stateAfterEnter()
+{
+ task199226_DoubleSpinBox spin;
+ spin.setMinimum(0);
+ spin.setMaximum(10);
+ spin.setDecimals(0);
+ spin.show();
+ QTest::mouseDClick(spin.lineEdit(), Qt::LeftButton);
+ QTest::keyClick(spin.lineEdit(), Qt::Key_3);
+ QVERIFY(spin.lineEdit()->isModified());
+ QVERIFY(spin.lineEdit()->isUndoAvailable());
+ QTest::keyClick(spin.lineEdit(), Qt::Key_Enter);
+ QVERIFY(!spin.lineEdit()->isModified());
+ QVERIFY(!spin.lineEdit()->isUndoAvailable());
+}
+
+class task224497_fltMax_DoubleSpinBox : public QDoubleSpinBox
+{
+public:
+ QLineEdit * lineEdit () const { return QDoubleSpinBox::lineEdit(); }
+};
+
+void tst_QDoubleSpinBox::task224497_fltMax()
+{
+ task224497_fltMax_DoubleSpinBox *dspin = new task224497_fltMax_DoubleSpinBox;
+ dspin->setMinimum(3);
+ dspin->setMaximum(FLT_MAX);
+ dspin->show();
+ QTest::qWait(1000);
+ dspin->lineEdit()->selectAll();
+ QTest::keyClick(dspin->lineEdit(), Qt::Key_Delete);
+ QTest::keyClick(dspin->lineEdit(), Qt::Key_1);
+ QCOMPARE(dspin->cleanText(), QLatin1String("1"));
+}
+
+void tst_QDoubleSpinBox::task221221()
+{
+ QDoubleSpinBox spin;
+ QTest::keyClick(&spin, Qt::Key_1);
+ QCOMPARE(spin.text(), QLatin1String("1"));
+ spin.show();
+#ifdef Q_WS_X11
+ qt_x11_wait_for_window_manager(&spin);
+#endif
+ QVERIFY(spin.isVisible());
+ QCOMPARE(spin.text(), QLatin1String("1"));
+}
+
+void tst_QDoubleSpinBox::task255471_decimalsValidation()
+{
+ // QDoubleSpinBox shouldn't crash with large numbers of decimals. Even if
+ // the results are useless ;-)
+ for (int i = 0; i < 32; ++i)
+ {
+ QDoubleSpinBox spinBox;
+ spinBox.setDecimals(i);
+ spinBox.setMinimum(0.3);
+ spinBox.setMaximum(12);
+
+ spinBox.show();
+ QTRY_VERIFY(spinBox.isVisible());
+ spinBox.setFocus();
+ QTRY_VERIFY(spinBox.hasFocus());
+
+ QTest::keyPress(&spinBox, Qt::Key_Right);
+ QTest::keyPress(&spinBox, Qt::Key_Right);
+ QTest::keyPress(&spinBox, Qt::Key_Delete);
+
+ // Don't crash!
+ QTest::keyPress(&spinBox, Qt::Key_2);
+ }
+}
+
+void tst_QDoubleSpinBox::taskQTBUG_5008_textFromValueAndValidate()
+{
+ class DecoratedSpinBox : public QDoubleSpinBox
+ {
+ public:
+ DecoratedSpinBox()
+ {
+ setLocale(QLocale::French);
+ setMaximum(100000000);
+ setValue(1000);
+ }
+
+ QLineEdit *lineEdit() const
+ {
+ return QDoubleSpinBox::lineEdit();
+ }
+
+ //we use the French delimiters here
+ QString textFromValue (double value) const
+ {
+ return locale().toString(value);
+ }
+ } spinbox;
+ spinbox.show();
+ spinbox.activateWindow();
+ spinbox.setFocus();
+ QApplication::setActiveWindow(&spinbox);
+ QTest::qWaitForWindowShown(&spinbox);
+ QTRY_VERIFY(spinbox.hasFocus());
+ QTRY_COMPARE(static_cast<QWidget *>(&spinbox), QApplication::activeWindow());
+ QCOMPARE(spinbox.text(), spinbox.locale().toString(spinbox.value()));
+ spinbox.lineEdit()->setCursorPosition(2); //just after the first thousand separator
+ QTest::keyClick(static_cast<QWidget *>(0), Qt::Key_0); // let's insert a 0
+ QCOMPARE(spinbox.value(), 10000.);
+ spinbox.clearFocus(); //make sure the value is correctly formatted
+ QCOMPARE(spinbox.text(), spinbox.locale().toString(spinbox.value()));
+}
+
+void tst_QDoubleSpinBox::taskQTBUG_6670_selectAllWithPrefix()
+{
+ DoubleSpinBox spin;
+ spin.setPrefix("$ ");
+ spin.lineEdit()->selectAll();
+ QTest::keyClick(spin.lineEdit(), Qt::Key_1);
+ QCOMPARE(spin.value(), 1.);
+ QTest::keyClick(spin.lineEdit(), Qt::Key_2);
+ QCOMPARE(spin.value(), 12.);
+}
+
+void tst_QDoubleSpinBox::taskQTBUG_6496_fiddlingWithPrecision()
+{
+ QDoubleSpinBox dsb;
+ dsb.setRange(0, 0.991);
+ dsb.setDecimals(1);
+ QCOMPARE(dsb.maximum(), 1.0);
+ dsb.setDecimals(2);
+ QCOMPARE(dsb.maximum(), 0.99);
+ dsb.setDecimals(3);
+ QCOMPARE(dsb.maximum(), 0.991);
+}
+
+QTEST_MAIN(tst_QDoubleSpinBox)
+#include "tst_qdoublespinbox.moc"
diff --git a/tests/auto/widgets/widgets/qdoublevalidator/.gitignore b/tests/auto/widgets/widgets/qdoublevalidator/.gitignore
new file mode 100644
index 0000000000..95c97bbc30
--- /dev/null
+++ b/tests/auto/widgets/widgets/qdoublevalidator/.gitignore
@@ -0,0 +1 @@
+tst_qdoublevalidator
diff --git a/tests/auto/widgets/widgets/qdoublevalidator/qdoublevalidator.pro b/tests/auto/widgets/widgets/qdoublevalidator/qdoublevalidator.pro
new file mode 100644
index 0000000000..7fbb72bb7f
--- /dev/null
+++ b/tests/auto/widgets/widgets/qdoublevalidator/qdoublevalidator.pro
@@ -0,0 +1,5 @@
+load(qttest_p4)
+QT += widgets
+SOURCES += tst_qdoublevalidator.cpp
+
+
diff --git a/tests/auto/widgets/widgets/qdoublevalidator/tst_qdoublevalidator.cpp b/tests/auto/widgets/widgets/qdoublevalidator/tst_qdoublevalidator.cpp
new file mode 100644
index 0000000000..6014ce5165
--- /dev/null
+++ b/tests/auto/widgets/widgets/qdoublevalidator/tst_qdoublevalidator.cpp
@@ -0,0 +1,387 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#include <QtTest/QtTest>
+
+
+#include <qvalidator.h>
+
+class tst_QDoubleValidator : public QObject
+{
+ Q_OBJECT
+private slots:
+ void validate_data();
+ void validate();
+ void validateThouSep_data();
+ void validateThouSep();
+ void validateIntEquiv_data();
+ void validateIntEquiv();
+ void notifySignals();
+};
+
+Q_DECLARE_METATYPE(QValidator::State);
+#define INV QValidator::Invalid
+#define ITM QValidator::Intermediate
+#define ACC QValidator::Acceptable
+
+void tst_QDoubleValidator::validateThouSep_data()
+{
+ QTest::addColumn<QString>("localeName");
+ QTest::addColumn<QString>("value");
+ QTest::addColumn<QValidator::State>("result");
+
+ QTest::newRow("1,000C") << "C" << QString("1,000") << ACC;
+ QTest::newRow("1.000C") << "C" << QString("1.000") << ACC;
+
+ QTest::newRow("1,000de") << "de" << QString("1,000") << ACC;
+ QTest::newRow("1.000de") << "de" << QString("1.000") << ACC;
+
+ QTest::newRow(".C") << "C" << QString(".") << ITM;
+ QTest::newRow(".de") << "de" << QString(".") << ITM;
+ QTest::newRow(",C") << "C" << QString(",") << INV;
+ QTest::newRow(",de") << "de" << QString(",") << ITM;
+}
+
+void tst_QDoubleValidator::validateThouSep()
+{
+ QFETCH(QString, localeName);
+ QFETCH(QString, value);
+ QFETCH(QValidator::State, result);
+ int dummy = 0;
+
+ QDoubleValidator iv(-10000, 10000, 3, 0);
+ iv.setNotation(QDoubleValidator::ScientificNotation);
+ iv.setLocale(QLocale(localeName));
+
+ QCOMPARE(iv.validate(value, dummy), result);
+}
+
+void tst_QDoubleValidator::validate_data()
+{
+ QTest::addColumn<QString>("localeName");
+ QTest::addColumn<double>("minimum");
+ QTest::addColumn<double>("maximum");
+ QTest::addColumn<int>("decimals");
+ QTest::addColumn<QString>("value");
+ QTest::addColumn<QValidator::State>("scientific_state");
+ QTest::addColumn<QValidator::State>("standard_state");
+
+ QTest::newRow("data0") << "C" << 0.0 << 100.0 << 1 << QString("50.0") << ACC << ACC;
+ QTest::newRow("data1") << "C" << 00.0 << 100.0 << 1 << QString("500.0") << ITM << ITM;
+ QTest::newRow("data1a") << "C" << 00.0 << 100.0 << 1 << QString("5001.0") << ITM << INV;
+ QTest::newRow("data2") << "C" << 00.0 << 100.0 << 1 << QString("-35.0") << INV << INV;
+ QTest::newRow("data3") << "C" << 00.0 << 100.0 << 1 << QString("a") << INV << INV;
+ QTest::newRow("data4") << "C" << 0.0 << 100.0 << 1 << QString("-") << INV << INV;
+ QTest::newRow("data5") << "C" << 0.0 << 100.0 << 1 << QString("100.0") << ACC << ACC;
+ QTest::newRow("data6") << "C" << -100.0 << 100.0 << 1 << QString("-") << ITM << ITM;
+ QTest::newRow("data7") << "C" << -100.0 << 100.0 << 1 << QString("-500.0") << ITM << ITM;
+ QTest::newRow("data8") << "C" << -100.0 << 100.0 << 1 << QString("-100") << ACC << ACC;
+ QTest::newRow("data9") << "C" << -100.0 << -10.0 << 1 << QString("10") << ITM << ITM;
+ QTest::newRow("data10") << "C" << 0.3 << 0.5 << 5 << QString("0.34567") << ACC << ACC;
+ QTest::newRow("data11") << "C" << -0.3 << -0.5 << 5 << QString("-0.345678") << INV << INV;
+ QTest::newRow("data12") << "C" << -0.32 << 0.32 << 1 << QString("0") << ACC << ACC;
+ QTest::newRow("data13") << "C" << 0.0 << 100.0 << 1 << QString("3456a") << INV << INV;
+ QTest::newRow("data14") << "C" << -100.0 << 100.0 << 1 << QString("-3456a") << INV << INV;
+ QTest::newRow("data15") << "C" << -100.0 << 100.0 << 1 << QString("a-3456") << INV << INV;
+ QTest::newRow("data16") << "C" << -100.0 << 100.0 << 1 << QString("a-3456a") << INV << INV;
+ QTest::newRow("data17") << "C" << 1229.0 << 1231.0 << 0 << QString("123e") << ITM << INV;
+ QTest::newRow("data18") << "C" << 1229.0 << 1231.0 << 0 << QString("123e+") << ITM << INV;
+ QTest::newRow("data19") << "C" << 1229.0 << 1231.0 << 0 << QString("123e+1") << ACC << INV;
+ QTest::newRow("data20") << "C" << 12290.0 << 12310.0 << 0 << QString("123e+2") << ACC << INV;
+ QTest::newRow("data21") << "C" << 12.290 << 12.310 << 2 << QString("123e-") << ITM << INV;
+ QTest::newRow("data22") << "C" << 12.290 << 12.310 << 2 << QString("123e-1") << ACC << INV;
+ QTest::newRow("data23") << "C" << 1.2290 << 1.2310 << 3 << QString("123e-2") << ACC << INV;
+ QTest::newRow("data24") << "C" << 1229.0 << 1231.0 << 0 << QString("123E") << ITM << INV;
+ QTest::newRow("data25") << "C" << 1229.0 << 1231.0 << 0 << QString("123E+") << ITM << INV;
+ QTest::newRow("data26") << "C" << 1229.0 << 1231.0 << 0 << QString("123E+1") << ACC << INV;
+ QTest::newRow("data27") << "C" << 12290.0 << 12310.0 << 0 << QString("123E+2") << ACC << INV;
+ QTest::newRow("data28") << "C" << 12.290 << 12.310 << 2 << QString("123E-") << ITM << INV;
+ QTest::newRow("data29") << "C" << 12.290 << 12.310 << 2 << QString("123E-1") << ACC << INV;
+ QTest::newRow("data30") << "C" << 1.2290 << 1.2310 << 3 << QString("123E-2") << ACC << INV;
+ QTest::newRow("data31") << "C" << 1.2290 << 1.2310 << 3 << QString("e") << ITM << INV;
+ QTest::newRow("data32") << "C" << 1.2290 << 1.2310 << 3 << QString("e+") << ITM << INV;
+ QTest::newRow("data33") << "C" << 1.2290 << 1.2310 << 3 << QString("e+1") << ITM << INV;
+ QTest::newRow("data34") << "C" << 1.2290 << 1.2310 << 3 << QString("e-") << ITM << INV;
+ QTest::newRow("data35") << "C" << 1.2290 << 1.2310 << 3 << QString("e-1") << ITM << INV;
+ QTest::newRow("data36") << "C" << 1.2290 << 1.2310 << 3 << QString("E") << ITM << INV;
+ QTest::newRow("data37") << "C" << 1.2290 << 1.2310 << 3 << QString("E+") << ITM << INV;
+ QTest::newRow("data38") << "C" << 1.2290 << 1.2310 << 3 << QString("E+1") << ITM << INV;
+ QTest::newRow("data39") << "C" << 1.2290 << 1.2310 << 3 << QString("E-") << ITM << INV;
+ QTest::newRow("data40") << "C" << 1.2290 << 1.2310 << 3 << QString("E-1") << ITM << INV;
+ QTest::newRow("data41") << "C" << -100.0 << 100.0 << 0 << QString("10e") << ITM << INV;
+ QTest::newRow("data42") << "C" << -100.0 << 100.0 << 0 << QString("10e+") << ITM << INV;
+ QTest::newRow("data43") << "C" << 0.01 << 0.09 << 2 << QString("0") << ITM << ITM;
+ QTest::newRow("data44") << "C" << 0.0 << 10.0 << 1 << QString("11") << ITM << ITM;
+ QTest::newRow("data45") << "C" << 0.0 << 10.0 << 2 << QString("11") << ITM << ITM;
+ QTest::newRow("data46") << "C" << 0.0 << 100.0 << 0 << QString("0.") << ACC << ACC;
+ QTest::newRow("data47") << "C" << 0.0 << 100.0 << 0 << QString("0.0") << INV << INV;
+ QTest::newRow("data48") << "C" << 0.0 << 100.0 << 1 << QString("0.0") << ACC << ACC;
+ QTest::newRow("data49") << "C" << 0.0 << 100.0 << 0 << QString(".") << ITM << ITM;
+ QTest::newRow("data50") << "C" << 0.0 << 100.0 << 1 << QString(".") << ITM << ITM;
+
+ QTest::newRow("data_de0") << "de" << 0.0 << 100.0 << 1 << QString("50,0") << ACC << ACC;
+ QTest::newRow("data_de1") << "de" << 00.0 << 100.0 << 1 << QString("500,0") << ITM << ITM;
+ QTest::newRow("data_de1a") << "de" << 00.0 << 100.0 << 1 << QString("5001,0") << ITM << INV;
+ QTest::newRow("data_de0C") << "de" << 0.0 << 100.0 << 1 << QString("50,0") << ACC << ACC;
+ QTest::newRow("data_de1C") << "de" << 00.0 << 100.0 << 1 << QString("500,0") << ITM << ITM;
+ QTest::newRow("data_de1aC") << "de" << 00.0 << 100.0 << 1 << QString("5001,0") << ITM << INV;
+ QTest::newRow("data_de2") << "de" << 00.0 << 100.0 << 1 << QString("-35,0") << INV << INV;
+ QTest::newRow("data_de3") << "de" << 00.0 << 100.0 << 1 << QString("a") << INV << INV;
+ QTest::newRow("data_de4") << "de" << 0.0 << 100.0 << 1 << QString("-") << INV << INV;
+ QTest::newRow("data_de5") << "de" << 0.0 << 100.0 << 1 << QString("100,0") << ACC << ACC;
+ QTest::newRow("data_de6") << "de" << -100.0 << 100.0 << 1 << QString("-") << ITM << ITM;
+ QTest::newRow("data_de7") << "de" << -100.0 << 100.0 << 1 << QString("-500,0") << ITM << ITM;
+ QTest::newRow("data_de8") << "de" << -100.0 << 100.0 << 1 << QString("-100") << ACC << ACC;
+ QTest::newRow("data_de9") << "de" << -100.0 << -10.0 << 1 << QString("10") << ITM << ITM;
+ QTest::newRow("data_de10") << "de" << 0.3 << 0.5 << 5 << QString("0,34567") << ACC << ACC;
+ QTest::newRow("data_de11") << "de" << -0.3 << -0.5 << 5 << QString("-0,345678") << ITM << INV;
+ QTest::newRow("data_de12") << "de" << -0.32 << 0.32 << 1 << QString("0") << ACC << ACC;
+ QTest::newRow("data_de13") << "de" << 0.0 << 100.0 << 1 << QString("3456a") << INV << INV;
+ QTest::newRow("data_de14") << "de" << -100.0 << 100.0 << 1 << QString("-3456a") << INV << INV;
+ QTest::newRow("data_de15") << "de" << -100.0 << 100.0 << 1 << QString("a-3456") << INV << INV;
+ QTest::newRow("data_de16") << "de" << -100.0 << 100.0 << 1 << QString("a-3456a") << INV << INV;
+ QTest::newRow("data_de17") << "de" << 1229.0 << 1231.0 << 0 << QString("123e") << ITM << INV;
+ QTest::newRow("data_de18") << "de" << 1229.0 << 1231.0 << 0 << QString("123e+") << ITM << INV;
+ QTest::newRow("data_de19") << "de" << 1229.0 << 1231.0 << 0 << QString("123e+1") << ACC << INV;
+ QTest::newRow("data_de20") << "de" << 12290.0 << 12310.0 << 0 << QString("123e+2") << ACC << INV;
+ QTest::newRow("data_de21") << "de" << 12.290 << 12.310 << 2 << QString("123e-") << ITM << INV;
+ QTest::newRow("data_de22") << "de" << 12.290 << 12.310 << 2 << QString("123e-1") << ACC << INV;
+ QTest::newRow("data_de23") << "de" << 1.2290 << 1.2310 << 3 << QString("123e-2") << ACC << INV;
+ QTest::newRow("data_de24") << "de" << 1229.0 << 1231.0 << 0 << QString("123E") << ITM << INV;
+ QTest::newRow("data_de25") << "de" << 1229.0 << 1231.0 << 0 << QString("123E+") << ITM << INV;
+ QTest::newRow("data_de26") << "de" << 1229.0 << 1231.0 << 0 << QString("123E+1") << ACC << INV;
+ QTest::newRow("data_de27") << "de" << 12290.0 << 12310.0 << 0 << QString("123E+2") << ACC << INV;
+ QTest::newRow("data_de28") << "de" << 12.290 << 12.310 << 2 << QString("123E-") << ITM << INV;
+ QTest::newRow("data_de29") << "de" << 12.290 << 12.310 << 2 << QString("123E-1") << ACC << INV;
+ QTest::newRow("data_de30") << "de" << 1.2290 << 1.2310 << 3 << QString("123E-2") << ACC << INV;
+ QTest::newRow("data_de31") << "de" << 1.2290 << 1.2310 << 3 << QString("e") << ITM << INV;
+ QTest::newRow("data_de32") << "de" << 1.2290 << 1.2310 << 3 << QString("e+") << ITM << INV;
+ QTest::newRow("data_de33") << "de" << 1.2290 << 1.2310 << 3 << QString("e+1") << ITM << INV;
+ QTest::newRow("data_de34") << "de" << 1.2290 << 1.2310 << 3 << QString("e-") << ITM << INV;
+ QTest::newRow("data_de35") << "de" << 1.2290 << 1.2310 << 3 << QString("e-1") << ITM << INV;
+ QTest::newRow("data_de36") << "de" << 1.2290 << 1.2310 << 3 << QString("E") << ITM << INV;
+ QTest::newRow("data_de37") << "de" << 1.2290 << 1.2310 << 3 << QString("E+") << ITM << INV;
+ QTest::newRow("data_de38") << "de" << 1.2290 << 1.2310 << 3 << QString("E+1") << ITM << INV;
+ QTest::newRow("data_de39") << "de" << 1.2290 << 1.2310 << 3 << QString("E-") << ITM << INV;
+ QTest::newRow("data_de40") << "de" << 1.2290 << 1.2310 << 3 << QString("E-1") << ITM << INV;
+ QTest::newRow("data_de41") << "de" << -100.0 << 100.0 << 0 << QString("10e") << ITM << INV;
+ QTest::newRow("data_de42") << "de" << -100.0 << 100.0 << 0 << QString("10e+") << ITM << INV;
+ QTest::newRow("data_de43") << "de" << 0.01 << 0.09 << 2 << QString("0") << ITM << ITM;
+ QTest::newRow("data_de44") << "de" << 0.0 << 10.0 << 1 << QString("11") << ITM << ITM;
+ QTest::newRow("data_de45") << "de" << 0.0 << 10.0 << 2 << QString("11") << ITM << ITM;
+
+ QString arabicNum;
+ arabicNum += QChar(1633); // "18.4" in arabic
+ arabicNum += QChar(1640);
+ arabicNum += QChar(1643);
+ arabicNum += QChar(1636);
+ QTest::newRow("arabic") << "ar" << 0.0 << 20.0 << 2 << arabicNum << ACC << ACC;
+
+ QTest::newRow("data_QTBUG_14935-1") << "de" << 0.0 << 1.0 << 5 << QString("0.31") << ACC << ACC;
+ QTest::newRow("data_QTBUG_14935-2") << "de" << 0.0 << 1000000.0 << 5 << QString("3.123") << ACC << ACC;
+ QTest::newRow("data_QTBUG_14935-3") << "de" << 0.0 << 1000000.0 << 5 << QString("123,345.678") << ACC << ACC;
+
+ QTest::newRow("data_de_problem-1") << "de" << 0.0 << 10.0 << 0 << QString("1.0") << ITM << ITM;
+ QTest::newRow("data_de_problem-2") << "de" << 0.0 << 10.0 << 0 << QString("0.1") << INV << INV;
+}
+
+void tst_QDoubleValidator::validate()
+{
+ QFETCH(QString, localeName);
+ QFETCH(double, minimum);
+ QFETCH(double, maximum);
+ QFETCH(int, decimals);
+ QFETCH(QString, value);
+ QFETCH(QValidator::State, scientific_state);
+ QFETCH(QValidator::State, standard_state);
+
+ QEXPECT_FAIL("data_de_problem-1", "To be fixed. See QTBUG-15210.", Abort);
+ QEXPECT_FAIL("data_de_problem-2", "To be fixed. See QTBUG-15210.", Abort);
+
+ QLocale::setDefault(QLocale(localeName));
+
+ QDoubleValidator dv(minimum, maximum, decimals, 0);
+ int dummy;
+ QCOMPARE((int)dv.validate(value, dummy), (int)scientific_state);
+ dv.setNotation(QDoubleValidator::StandardNotation);
+ QCOMPARE((int)dv.validate(value, dummy), (int)standard_state);
+}
+void tst_QDoubleValidator::notifySignals()
+{
+ QDoubleValidator dv(0.1, 0.9, 10, 0);
+ QSignalSpy topSpy(&dv, SIGNAL(topChanged(double)));
+ QSignalSpy bottomSpy(&dv, SIGNAL(bottomChanged(double)));
+ QSignalSpy decSpy(&dv, SIGNAL(decimalsChanged(int)));
+
+ qRegisterMetaType<QDoubleValidator::Notation>("QDoubleValidator::Notation");
+ QSignalSpy notSpy(&dv, SIGNAL(notationChanged(QDoubleValidator::Notation)));
+
+ dv.setTop(0.8);
+ QCOMPARE(topSpy.count(), 1);
+ QVERIFY(dv.top() == 0.8);
+ dv.setBottom(0.2);
+ QCOMPARE(bottomSpy.count(), 1);
+ QVERIFY(dv.bottom() == 0.2);
+
+ dv.setRange(0.2, 0.7);
+ QCOMPARE(topSpy.count(), 2);
+ QCOMPARE(bottomSpy.count(), 1);
+ QCOMPARE(decSpy.count(), 1);
+ QVERIFY(dv.bottom() == 0.2);
+ QVERIFY(dv.top() == 0.7);
+ QVERIFY(dv.decimals() == 0.);
+
+ dv.setRange(0.3, 0.7);
+ QCOMPARE(topSpy.count(), 2);
+ QCOMPARE(bottomSpy.count(), 2);
+ QVERIFY(dv.bottom() == 0.3);
+ QVERIFY(dv.top() == 0.7);
+ QVERIFY(dv.decimals() == 0.);
+
+ dv.setRange(0.4, 0.6);
+ QCOMPARE(topSpy.count(), 3);
+ QCOMPARE(bottomSpy.count(), 3);
+ QVERIFY(dv.bottom() == 0.4);
+ QVERIFY(dv.top() == 0.6);
+ QVERIFY(dv.decimals() == 0.);
+
+ dv.setDecimals(10);
+ QCOMPARE(decSpy.count(), 2);
+ QVERIFY(dv.decimals() == 10.);
+
+
+ dv.setRange(0.4, 0.6, 100);
+ QCOMPARE(topSpy.count(), 3);
+ QCOMPARE(bottomSpy.count(), 3);
+ QCOMPARE(decSpy.count(), 3);
+ QVERIFY(dv.bottom() == 0.4);
+ QVERIFY(dv.top() == 0.6);
+ QVERIFY(dv.decimals() == 100.);
+
+ dv.setNotation(QDoubleValidator::StandardNotation);
+ QCOMPARE(notSpy.count(), 1);
+ QVERIFY(dv.notation() == QDoubleValidator::StandardNotation);
+}
+
+void tst_QDoubleValidator::validateIntEquiv_data()
+{
+ QTest::addColumn<double>("minimum");
+ QTest::addColumn<double>("maximum");
+ QTest::addColumn<QString>("input");
+ QTest::addColumn<QValidator::State>("state");
+
+ QTest::newRow("1.1") << 0.0 << 10.0 << QString("") << ITM;
+ QTest::newRow("1.2") << 10.0 << 0.0 << QString("") << ITM;
+
+ QTest::newRow("2.1") << 0.0 << 10.0 << QString("-") << INV;
+ QTest::newRow("2.2") << 0.0 << 10.0 << QString("-0") << INV;
+ QTest::newRow("2.3") << -10.0 << -1.0 << QString("+") << INV;
+ QTest::newRow("2.4") << -10.0 << 10.0 << QString("-") << ITM;
+ QTest::newRow("2.5") << -10.0 << 10.0 << QString("+") << ITM;
+ QTest::newRow("2.5a") << -10.0 << -9.0 << QString("+") << INV;
+ QTest::newRow("2.6") << -10.0 << 10.0 << QString("+0") << ACC;
+ QTest::newRow("2.7") << -10.0 << 10.0 << QString("+1") << ACC;
+ QTest::newRow("2.8") << -10.0 << 10.0 << QString("+-") << INV;
+ QTest::newRow("2.9") << -10.0 << 10.0 << QString("-+") << INV;
+
+ QTest::newRow("3.1") << 0.0 << 10.0 << QString("12345678901234567890") << INV;
+ QTest::newRow("3.2") << 0.0 << 10.0 << QString("-12345678901234567890") << INV;
+ QTest::newRow("3.3") << 0.0 << 10.0 << QString("000000000000000000000") << ACC;
+ QTest::newRow("3.4") << 1.0 << 10.0 << QString("000000000000000000000") << ITM;
+ QTest::newRow("3.5") << 0.0 << 10.0 << QString("-000000000000000000000") << INV;
+ QTest::newRow("3.6") << -10.0 << -1.0 << QString("-000000000000000000000") << ITM;
+ QTest::newRow("3.7") << -10.0 << -1.0 << QString("-0000000000000000000001") << ACC;
+
+ QTest::newRow("4.1") << 0.0 << 10.0 << QString(" ") << INV;
+ QTest::newRow("4.2") << 0.0 << 10.0 << QString(" 1") << INV;
+ QTest::newRow("4.3") << 0.0 << 10.0 << QString("1 ") << INV;
+ QTest::newRow("4.4") << 0.0 << 10.0 << QString("1.0") << INV;
+ QTest::newRow("4.5") << 0.0 << 10.0 << QString("0.1") << INV;
+ QTest::newRow("4.6") << 0.0 << 10.0 << QString(".1") << INV;
+ QTest::newRow("4.7") << 0.0 << 10.0 << QString("-1.0") << INV;
+
+ QTest::newRow("5.1") << 6.0 << 8.0 << QString("5") << ITM;
+ QTest::newRow("5.1") << 6.0 << 8.0 << QString("56") << INV;
+ QTest::newRow("5.2") << 6.0 << 8.0 << QString("7") << ACC;
+ QTest::newRow("5.3") << 6.0 << 8.0 << QString("9") << ITM;
+ QTest::newRow("5.3") << 6.0 << 8.0 << QString("-") << INV;
+ QTest::newRow("5.4a") << -8.0 << -6.0 << QString("+") << INV;
+ QTest::newRow("5.4b") << -8.0 << -6.0 << QString("+5") << INV;
+ QTest::newRow("5.4c") << -8.0 << -6.0 << QString("-5") << ITM;
+ QTest::newRow("5.5") << -8.0 << -6.0 << QString("-7") << ACC;
+ QTest::newRow("5.6") << -8.0 << -6.0 << QString("-9") << ITM;
+ QTest::newRow("5.7") << -8.0 << -6.0 << QString("5") << ITM;
+ QTest::newRow("5.8") << -8.0 << -6.0 << QString("7") << ITM;
+ QTest::newRow("5.9") << -8.0 << -6.0 << QString("9") << ITM;
+ QTest::newRow("5.10") << -6.0 << 8.0 << QString("-5") << ACC;
+ QTest::newRow("5.11") << -6.0 << 8.0 << QString("5") << ACC;
+ QTest::newRow("5.12") << -6.0 << 8.0 << QString("-7") << ITM;
+ QTest::newRow("5.13") << -6.0 << 8.0 << QString("7") << ACC;
+ QTest::newRow("5.14") << -6.0 << 8.0 << QString("-9") << ITM;
+ QTest::newRow("5.15") << -6.0 << 8.0 << QString("9") << ITM;
+
+ QTest::newRow("6.1") << 100.0 << 102.0 << QString("11") << ITM;
+ QTest::newRow("6.2") << 100.0 << 102.0 << QString("-11") << INV;
+
+ QTest::newRow("7.1") << 0.0 << 10.0 << QString("100") << INV;
+ QTest::newRow("7.2") << 0.0 << -10.0 << QString("100") << INV;
+ QTest::newRow("7.3") << 0.0 << -10.0 << QString("-100") << INV;
+ QTest::newRow("7.4") << -100.0 << 10.0 << QString("100") << ITM;
+}
+
+void tst_QDoubleValidator::validateIntEquiv()
+{
+ QFETCH(double, minimum);
+ QFETCH(double, maximum);
+ QFETCH(QString, input);
+ QFETCH(QValidator::State, state);
+
+ QLocale::setDefault(QLocale("C"));
+
+ QDoubleValidator dv(minimum, maximum, 0, 0);
+ dv.setNotation(QDoubleValidator::StandardNotation);
+ int dummy;
+ QCOMPARE(dv.validate(input, dummy), state);
+}
+
+QTEST_APPLESS_MAIN(tst_QDoubleValidator)
+#include "tst_qdoublevalidator.moc"
diff --git a/tests/auto/widgets/widgets/qfocusframe/.gitignore b/tests/auto/widgets/widgets/qfocusframe/.gitignore
new file mode 100644
index 0000000000..7a6e000227
--- /dev/null
+++ b/tests/auto/widgets/widgets/qfocusframe/.gitignore
@@ -0,0 +1 @@
+tst_qfocusframe
diff --git a/tests/auto/widgets/widgets/qfocusframe/qfocusframe.pro b/tests/auto/widgets/widgets/qfocusframe/qfocusframe.pro
new file mode 100644
index 0000000000..0fcc9bf23d
--- /dev/null
+++ b/tests/auto/widgets/widgets/qfocusframe/qfocusframe.pro
@@ -0,0 +1,9 @@
+############################################################
+# Project file for autotest for file qfocusframe.h
+############################################################
+
+load(qttest_p4)
+QT += widgets
+SOURCES += tst_qfocusframe.cpp
+
+
diff --git a/tests/auto/widgets/widgets/qfocusframe/tst_qfocusframe.cpp b/tests/auto/widgets/widgets/qfocusframe/tst_qfocusframe.cpp
new file mode 100644
index 0000000000..1658cf3fe5
--- /dev/null
+++ b/tests/auto/widgets/widgets/qfocusframe/tst_qfocusframe.cpp
@@ -0,0 +1,89 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#include <QtTest/QtTest>
+
+#include <qcoreapplication.h>
+#include <qdebug.h>
+#include <qfocusframe.h>
+
+
+//TESTED_CLASS=
+//TESTED_FILES=
+
+class tst_QFocusFrame : public QObject
+{
+Q_OBJECT
+
+public:
+ tst_QFocusFrame();
+ virtual ~tst_QFocusFrame();
+
+private slots:
+ void getSetCheck();
+};
+
+tst_QFocusFrame::tst_QFocusFrame()
+{
+}
+
+tst_QFocusFrame::~tst_QFocusFrame()
+{
+}
+
+// Testing get/set functions
+void tst_QFocusFrame::getSetCheck()
+{
+ QFocusFrame *obj1 = new QFocusFrame();
+ // QWidget * QFocusFrame::widget()
+ // void QFocusFrame::setWidget(QWidget *)
+ QWidget var1;
+ QWidget *var2 = new QWidget(&var1);
+ obj1->setWidget(var2);
+ QCOMPARE(var2, obj1->widget());
+ obj1->setWidget((QWidget *)0);
+ QCOMPARE((QWidget *)0, obj1->widget());
+ delete obj1;
+}
+
+QTEST_MAIN(tst_QFocusFrame)
+#include "tst_qfocusframe.moc"
diff --git a/tests/auto/widgets/widgets/qfontcombobox/.gitignore b/tests/auto/widgets/widgets/qfontcombobox/.gitignore
new file mode 100644
index 0000000000..acc19de07e
--- /dev/null
+++ b/tests/auto/widgets/widgets/qfontcombobox/.gitignore
@@ -0,0 +1 @@
+tst_qfontcombobox
diff --git a/tests/auto/widgets/widgets/qfontcombobox/qfontcombobox.pro b/tests/auto/widgets/widgets/qfontcombobox/qfontcombobox.pro
new file mode 100644
index 0000000000..7faa0e36bd
--- /dev/null
+++ b/tests/auto/widgets/widgets/qfontcombobox/qfontcombobox.pro
@@ -0,0 +1,5 @@
+load(qttest_p4)
+QT += widgets
+SOURCES += tst_qfontcombobox.cpp
+
+CONFIG += insignificant_test # QTBUG-21402
diff --git a/tests/auto/widgets/widgets/qfontcombobox/tst_qfontcombobox.cpp b/tests/auto/widgets/widgets/qfontcombobox/tst_qfontcombobox.cpp
new file mode 100644
index 0000000000..72b3dfe8ca
--- /dev/null
+++ b/tests/auto/widgets/widgets/qfontcombobox/tst_qfontcombobox.cpp
@@ -0,0 +1,303 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#include <QtTest/QtTest>
+#include <qfontcombobox.h>
+
+class tst_QFontComboBox : public QObject
+{
+ Q_OBJECT
+
+public slots:
+ void initTestCase();
+ void cleanupTestCase();
+ void init();
+ void cleanup();
+
+private slots:
+ void qfontcombobox_data();
+ void qfontcombobox();
+ void currentFont_data();
+ void currentFont();
+ void fontFilters_data();
+ void fontFilters();
+ void sizeHint();
+ void writingSystem_data();
+ void writingSystem();
+ void currentFontChanged();
+};
+
+// Subclass that exposes the protected functions.
+class SubQFontComboBox : public QFontComboBox
+{
+public:
+ void call_currentFontChanged(QFont const& f)
+ { return SubQFontComboBox::currentFontChanged(f); }
+
+ bool call_event(QEvent* e)
+ { return SubQFontComboBox::event(e); }
+};
+
+// This will be called before the first test function is executed.
+// It is only called once.
+void tst_QFontComboBox::initTestCase()
+{
+}
+
+// This will be called after the last test function is executed.
+// It is only called once.
+void tst_QFontComboBox::cleanupTestCase()
+{
+}
+
+// This will be called before each test function is executed.
+void tst_QFontComboBox::init()
+{
+}
+
+// This will be called after every test function.
+void tst_QFontComboBox::cleanup()
+{
+}
+
+void tst_QFontComboBox::qfontcombobox_data()
+{
+}
+
+void tst_QFontComboBox::qfontcombobox()
+{
+ SubQFontComboBox box;
+ QCOMPARE(box.currentFont(), QFont());
+ QCOMPARE(box.fontFilters(), QFontComboBox::AllFonts);
+ box.setCurrentFont(QFont());
+ box.setFontFilters(QFontComboBox::AllFonts);
+ box.setWritingSystem(QFontDatabase::Any);
+ QVERIFY(box.sizeHint() != QSize());
+ QCOMPARE(box.writingSystem(), QFontDatabase::Any);
+ box.call_currentFontChanged(QFont());
+ QEvent event(QEvent::None);
+ QCOMPARE(box.call_event(&event), false);
+}
+
+void tst_QFontComboBox::currentFont_data()
+{
+ QTest::addColumn<QFont>("currentFont");
+ // Normalize the names
+ QFont defaultFont;
+ QFontInfo fi(defaultFont);
+ defaultFont = QFont(fi.family()); // make sure we have a real font name and not something like 'Sans Serif'.
+ QTest::newRow("default") << defaultFont;
+ defaultFont.setPointSize(defaultFont.pointSize() + 10);
+ QTest::newRow("default2") << defaultFont;
+ QFontDatabase db;
+ QStringList list = db.families();
+ for (int i = 0; i < list.count(); ++i) {
+ QFont f = QFont(QFontInfo(QFont(list.at(i))).family());
+ QTest::newRow(qPrintable(list.at(i))) << f;
+ }
+}
+
+// public QFont currentFont() const
+void tst_QFontComboBox::currentFont()
+{
+ QFETCH(QFont, currentFont);
+
+ SubQFontComboBox box;
+ QSignalSpy spy0(&box, SIGNAL(currentFontChanged(QFont const&)));
+ QFont oldCurrentFont = box.currentFont();
+
+ box.setCurrentFont(currentFont);
+ QRegExp foundry(" \\[.*\\]");
+ if (!box.currentFont().family().contains(foundry)) {
+ QCOMPARE(box.currentFont(), currentFont);
+ }
+ QString boxFontFamily = QFontInfo(box.currentFont()).family();
+ if (!currentFont.family().contains(foundry))
+ boxFontFamily.remove(foundry);
+ QCOMPARE(boxFontFamily, currentFont.family());
+
+ if (oldCurrentFont != box.currentFont()) {
+ //the signal may be emit twice if there is a foundry into brackets
+ QCOMPARE(spy0.count(),1);
+ }
+}
+
+Q_DECLARE_METATYPE(QFontComboBox::FontFilters)
+void tst_QFontComboBox::fontFilters_data()
+{
+ QTest::addColumn<QFontComboBox::FontFilters>("fontFilters");
+ QTest::newRow("AllFonts")
+ << QFontComboBox::FontFilters(QFontComboBox::AllFonts);
+ QTest::newRow("ScalableFonts")
+ << QFontComboBox::FontFilters(QFontComboBox::ScalableFonts);
+ QTest::newRow("NonScalableFonts")
+ << QFontComboBox::FontFilters(QFontComboBox::NonScalableFonts);
+ QTest::newRow("MonospacedFonts")
+ << QFontComboBox::FontFilters(QFontComboBox::MonospacedFonts);
+ QTest::newRow("ProportionalFonts")
+ << QFontComboBox::FontFilters(QFontComboBox::ProportionalFonts);
+
+ // combine two
+ QTest::newRow("ProportionalFonts | NonScalableFonts")
+ << QFontComboBox::FontFilters(QFontComboBox::ProportionalFonts | QFontComboBox::NonScalableFonts);
+
+ // i.e. all
+ QTest::newRow("ScalableFonts | NonScalableFonts")
+ << QFontComboBox::FontFilters(QFontComboBox::ScalableFonts | QFontComboBox::NonScalableFonts);
+
+}
+
+// public QFontComboBox::FontFilters fontFilters() const
+void tst_QFontComboBox::fontFilters()
+{
+ QFETCH(QFontComboBox::FontFilters, fontFilters);
+
+ SubQFontComboBox box;
+ QSignalSpy spy0(&box, SIGNAL(currentFontChanged(QFont const&)));
+ QFont currentFont = box.currentFont();
+
+ box.setFontFilters(fontFilters);
+ QCOMPARE(box.fontFilters(), fontFilters);
+
+ QFontDatabase db;
+ QStringList list = db.families();
+ int c = 0;
+ const int scalableMask = (QFontComboBox::ScalableFonts | QFontComboBox::NonScalableFonts);
+ const int spacingMask = (QFontComboBox::ProportionalFonts | QFontComboBox::MonospacedFonts);
+ if((fontFilters & scalableMask) == scalableMask)
+ fontFilters &= ~scalableMask;
+ if((fontFilters & spacingMask) == spacingMask)
+ fontFilters &= ~spacingMask;
+
+ for (int i = 0; i < list.count(); ++i) {
+ if (fontFilters & QFontComboBox::ScalableFonts) {
+ if (!db.isSmoothlyScalable(list[i]))
+ continue;
+ } else if (fontFilters & QFontComboBox::NonScalableFonts) {
+ if (db.isSmoothlyScalable(list[i]))
+ continue;
+ }
+ if (fontFilters & QFontComboBox::MonospacedFonts) {
+ if (!db.isFixedPitch(list[i]))
+ continue;
+ } else if (fontFilters & QFontComboBox::ProportionalFonts) {
+ if (db.isFixedPitch(list[i]))
+ continue;
+ }
+ c++;
+ }
+
+ QCOMPARE(box.model()->rowCount(), c);
+
+ if (c == 0)
+ QCOMPARE(box.currentFont(), QFont());
+
+ QCOMPARE(spy0.count(), (currentFont != box.currentFont()) ? 1 : 0);
+}
+
+// public QSize sizeHint() const
+void tst_QFontComboBox::sizeHint()
+{
+ SubQFontComboBox box;
+ QSize sizeHint = box.QComboBox::sizeHint();
+ QFontMetrics fm(box.font());
+ sizeHint.setWidth(qMax(sizeHint.width(), fm.width(QLatin1Char('m'))*14));
+ QCOMPARE(box.sizeHint(), sizeHint);
+}
+
+Q_DECLARE_METATYPE(QFontDatabase::WritingSystem)
+void tst_QFontComboBox::writingSystem_data()
+{
+ QTest::addColumn<QFontDatabase::WritingSystem>("writingSystem");
+ QTest::newRow("Any") << QFontDatabase::Any;
+ QTest::newRow("Latin") << QFontDatabase::Latin;
+ QTest::newRow("Lao") << QFontDatabase::Lao;
+ QTest::newRow("TraditionalChinese") << QFontDatabase::TraditionalChinese;
+ QTest::newRow("Ogham") << QFontDatabase::Ogham;
+ QTest::newRow("Runic") << QFontDatabase::Runic;
+
+ for (int i = 0; i < 31; ++i)
+ QTest::newRow("enum") << (QFontDatabase::WritingSystem)i;
+}
+
+// public QFontDatabase::WritingSystem writingSystem() const
+void tst_QFontComboBox::writingSystem()
+{
+ QFETCH(QFontDatabase::WritingSystem, writingSystem);
+
+ SubQFontComboBox box;
+ QSignalSpy spy0(&box, SIGNAL(currentFontChanged(QFont const&)));
+ QFont currentFont = box.currentFont();
+
+ box.setWritingSystem(writingSystem);
+ QCOMPARE(box.writingSystem(), writingSystem);
+
+ QFontDatabase db;
+ QStringList list = db.families(writingSystem);
+ QCOMPARE(box.model()->rowCount(), list.count());
+
+ if (list.count() == 0)
+ QCOMPARE(box.currentFont(), QFont());
+
+ QCOMPARE(spy0.count(), (currentFont != box.currentFont()) ? 1 : 0);
+}
+
+// protected void currentFontChanged(QFont const& f)
+void tst_QFontComboBox::currentFontChanged()
+{
+ SubQFontComboBox box;
+ QSignalSpy spy0(&box, SIGNAL(currentFontChanged(QFont const&)));
+
+ if (box.model()->rowCount() > 2) {
+ QTest::keyPress(&box, Qt::Key_Down);
+ QCOMPARE(spy0.count(), 1);
+
+ QFont f( "Sans Serif" );
+ box.setCurrentFont(f);
+ QCOMPARE(spy0.count(), 2);
+ } else
+ qWarning("Not enough fonts installed on test system. Consider adding some");
+}
+
+QTEST_MAIN(tst_QFontComboBox)
+#include "tst_qfontcombobox.moc"
+
diff --git a/tests/auto/widgets/widgets/qgroupbox/.gitignore b/tests/auto/widgets/widgets/qgroupbox/.gitignore
new file mode 100644
index 0000000000..16dc39494e
--- /dev/null
+++ b/tests/auto/widgets/widgets/qgroupbox/.gitignore
@@ -0,0 +1 @@
+tst_qgroupbox
diff --git a/tests/auto/widgets/widgets/qgroupbox/qgroupbox.pro b/tests/auto/widgets/widgets/qgroupbox/qgroupbox.pro
new file mode 100644
index 0000000000..f4181a33ed
--- /dev/null
+++ b/tests/auto/widgets/widgets/qgroupbox/qgroupbox.pro
@@ -0,0 +1,6 @@
+load(qttest_p4)
+QT += widgets
+SOURCES += tst_qgroupbox.cpp
+
+
+
diff --git a/tests/auto/widgets/widgets/qgroupbox/tst_qgroupbox.cpp b/tests/auto/widgets/widgets/qgroupbox/tst_qgroupbox.cpp
new file mode 100644
index 0000000000..8568ef01d1
--- /dev/null
+++ b/tests/auto/widgets/widgets/qgroupbox/tst_qgroupbox.cpp
@@ -0,0 +1,475 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#include <QtTest/QtTest>
+#include <QLineEdit>
+#include <QStyle>
+#include <QStyleOptionGroupBox>
+#include <QVBoxLayout>
+#include <QRadioButton>
+
+#include "qgroupbox.h"
+
+//TESTED_CLASS=
+//TESTED_FILES=
+
+class tst_QGroupBox : public QObject
+{
+ Q_OBJECT
+
+public:
+ tst_QGroupBox();
+ virtual ~tst_QGroupBox();
+
+public slots:
+ void toggledHelperSlot(bool on);
+ void init();
+ void clickTimestampSlot();
+ void toggleTimestampSlot();
+
+private slots:
+ void setTitle_data();
+ void setTitle();
+ void setCheckable_data();
+ void setCheckable();
+ void setChecked_data();
+ void setChecked();
+ void enabledPropagation();
+ void sizeHint();
+ void toggled();
+ void clicked_data();
+ void clicked();
+ void toggledVsClicked();
+ void childrenAreDisabled();
+ void propagateFocus();
+
+private:
+ bool checked;
+ qint64 timeStamp;
+ qint64 clickTimeStamp;
+ qint64 toggleTimeStamp;
+
+};
+
+tst_QGroupBox::tst_QGroupBox()
+{
+ checked = true;
+}
+
+tst_QGroupBox::~tst_QGroupBox()
+{
+
+}
+
+void tst_QGroupBox::init()
+{
+ checked = true;
+}
+
+void tst_QGroupBox::setTitle_data()
+{
+ QTest::addColumn<QString>("title");
+ QTest::addColumn<QString>("expectedTitle");
+ QTest::newRow( "empty_title" ) << QString("") << QString("");
+ QTest::newRow( "normal_title" ) << QString("Whatisthematrix") << QString("Whatisthematrix");
+ QTest::newRow( "special_chars_title" ) << QString("<>%&#/()=") << QString("<>%&#/()=");
+ QTest::newRow( "spaces_title" ) << QString(" Hello ") << QString(" Hello ");
+}
+
+void tst_QGroupBox::setCheckable_data()
+{
+ QTest::addColumn<bool>("checkable");
+ QTest::addColumn<bool>("expectedCheckable");
+ QTest::newRow( "checkable_true" ) << true << true;
+ QTest::newRow( "checkable_false" ) << false << false;
+}
+
+void tst_QGroupBox::setChecked_data()
+{
+ QTest::addColumn<bool>("checkable");
+ QTest::addColumn<bool>("checked");
+ QTest::addColumn<bool>("expectedChecked");
+ QTest::newRow( "checkable_false_checked_true" ) << false << true << false;
+ QTest::newRow( "checkable_true_checked_true" ) << true << true << true;
+ QTest::newRow( "checkable_true_checked_false" ) << true << false << false;
+}
+
+void tst_QGroupBox::setTitle()
+{
+ QFETCH( QString, title );
+ QFETCH( QString, expectedTitle );
+
+ QGroupBox groupBox;
+
+ groupBox.setTitle( title );
+
+ QCOMPARE( groupBox.title() , expectedTitle );
+}
+
+void tst_QGroupBox::setCheckable()
+{
+ QFETCH( bool, checkable );
+ QFETCH( bool, expectedCheckable );
+
+ QGroupBox groupBox;
+
+ groupBox.setCheckable( checkable );
+ QCOMPARE( groupBox.isCheckable() , expectedCheckable );
+}
+
+
+void tst_QGroupBox::setChecked()
+{
+ QFETCH( bool, checkable );
+ QFETCH( bool, checked );
+ QFETCH( bool, expectedChecked );
+
+ QGroupBox groupBox;
+
+ groupBox.setCheckable( checkable );
+ groupBox.setChecked( checked );
+ QCOMPARE( groupBox.isChecked(), expectedChecked );
+}
+
+void tst_QGroupBox::enabledPropagation()
+{
+ QGroupBox *testWidget = new QGroupBox(0);
+ testWidget->setCheckable(true);
+ testWidget->setChecked(true);
+ QWidget* childWidget = new QWidget( testWidget );
+ childWidget->show();
+ QVERIFY( testWidget->isEnabled() );
+ QVERIFY( childWidget->isEnabled() );
+
+ testWidget->setEnabled( false );
+ QVERIFY( !testWidget->isEnabled() );
+ QVERIFY( !childWidget->isEnabled() );
+
+ testWidget->setDisabled( false );
+ QVERIFY( testWidget->isEnabled() );
+ QVERIFY( childWidget->isEnabled() );
+
+ QWidget* grandChildWidget = new QWidget( childWidget );
+ QVERIFY( grandChildWidget->isEnabled() );
+
+ testWidget->setDisabled( true );
+ QVERIFY( !testWidget->isEnabled() );
+ QVERIFY( !childWidget->isEnabled() );
+ QVERIFY( !grandChildWidget->isEnabled() );
+
+ grandChildWidget->setEnabled( false );
+ testWidget->setEnabled( true );
+ QVERIFY( testWidget->isEnabled() );
+ QVERIFY( childWidget->isEnabled() );
+ QVERIFY( !grandChildWidget->isEnabled() );
+
+ grandChildWidget->setEnabled( true );
+ testWidget->setEnabled( false );
+ childWidget->setDisabled( true );
+ testWidget->setEnabled( true );
+ QVERIFY( testWidget->isEnabled() );
+ QVERIFY( !childWidget->isEnabled() );
+ QVERIFY( !grandChildWidget->isEnabled() );
+
+ // Reset state
+ testWidget->setEnabled( true );
+ childWidget->setEnabled( true );
+ grandChildWidget->setEnabled( true );
+
+ // Now check when it's disabled
+ testWidget->setChecked(false);
+ QVERIFY( testWidget->isEnabled() );
+ QVERIFY( !childWidget->isEnabled() );
+
+ testWidget->setEnabled( false );
+ QVERIFY( !testWidget->isEnabled() );
+ QVERIFY( !childWidget->isEnabled() );
+
+ testWidget->setDisabled( false );
+ QVERIFY( testWidget->isEnabled() );
+ QVERIFY( !childWidget->isEnabled() );
+
+ QVERIFY( !grandChildWidget->isEnabled() );
+
+ testWidget->setDisabled( true );
+ QVERIFY( !testWidget->isEnabled() );
+ QVERIFY( !childWidget->isEnabled() );
+ QVERIFY( !grandChildWidget->isEnabled() );
+
+ grandChildWidget->setEnabled( false );
+ testWidget->setEnabled( true );
+ QVERIFY( testWidget->isEnabled() );
+ QVERIFY( !childWidget->isEnabled() );
+ QVERIFY( !grandChildWidget->isEnabled() );
+
+ grandChildWidget->setEnabled( true );
+ testWidget->setEnabled( false );
+ childWidget->setDisabled( true );
+ testWidget->setEnabled( true );
+ QVERIFY( testWidget->isEnabled() );
+ QVERIFY( !childWidget->isEnabled() );
+ QVERIFY( !grandChildWidget->isEnabled() );
+
+ // Reset state
+ testWidget->setEnabled( true );
+ childWidget->setEnabled( true );
+ grandChildWidget->setEnabled( true );
+
+ // Finally enable it again
+ testWidget->setChecked(true);
+ QVERIFY( testWidget->isEnabled() );
+ QVERIFY( childWidget->isEnabled() );
+
+ testWidget->setEnabled( false );
+ QVERIFY( !testWidget->isEnabled() );
+ QVERIFY( !childWidget->isEnabled() );
+
+ testWidget->setDisabled( false );
+ QVERIFY( testWidget->isEnabled() );
+ QVERIFY( childWidget->isEnabled() );
+ QVERIFY( grandChildWidget->isEnabled() );
+
+ testWidget->setDisabled( true );
+ QVERIFY( !testWidget->isEnabled() );
+ QVERIFY( !childWidget->isEnabled() );
+ QVERIFY( !grandChildWidget->isEnabled() );
+
+ grandChildWidget->setEnabled( false );
+ testWidget->setEnabled( true );
+ QVERIFY( testWidget->isEnabled() );
+ QVERIFY( childWidget->isEnabled() );
+ QVERIFY( !grandChildWidget->isEnabled() );
+
+ grandChildWidget->setEnabled( true );
+ testWidget->setEnabled( false );
+ childWidget->setDisabled( true );
+ testWidget->setEnabled( true );
+ QVERIFY( testWidget->isEnabled() );
+ QVERIFY( !childWidget->isEnabled() );
+ QVERIFY( !grandChildWidget->isEnabled() );
+
+ delete testWidget;
+}
+
+
+void tst_QGroupBox::sizeHint()
+{
+ QGroupBox testWidget1(0);
+ testWidget1.setTitle("&0&0&0&0&0&0&0&0&0&0");
+
+ QGroupBox testWidget2(0);
+ testWidget2.setTitle("0000000000");
+
+ QCOMPARE(testWidget1.sizeHint().width(), testWidget2.sizeHint().width());
+
+ // if the above fails one should maybe test to see like underneath.
+ // QVERIFY((QABS(testWidget1->sizeHint().width() - testWidget2->sizeHint().width()) < 10));
+}
+
+void tst_QGroupBox::toggledHelperSlot(bool on)
+{
+ checked = on;
+}
+
+
+void tst_QGroupBox::toggled()
+{
+ QGroupBox testWidget1(0);
+ testWidget1.setCheckable(true);
+ connect(&testWidget1, SIGNAL(toggled(bool)), this, SLOT(toggledHelperSlot(bool)));
+ QLineEdit *edit = new QLineEdit(&testWidget1);
+ QVERIFY(checked);
+ testWidget1.setChecked(true);
+ QVERIFY(checked);
+ QVERIFY(edit->isEnabled());
+ testWidget1.setChecked(false);
+ QVERIFY(!checked);
+ QVERIFY(!edit->isEnabled());
+}
+
+void tst_QGroupBox::clicked_data()
+{
+ QTest::addColumn<bool>("checkable");
+ QTest::addColumn<bool>("initialCheck");
+ QTest::addColumn<int>("areaToHit");
+ QTest::addColumn<int>("clickedCount");
+ QTest::addColumn<bool>("finalCheck");
+
+ QTest::newRow("hit nothing, not checkable") << false << false << int(QStyle::SC_None) << 0 << false;
+ QTest::newRow("hit frame, not checkable") << false << false << int(QStyle::SC_GroupBoxFrame) << 0 << false;
+ QTest::newRow("hit content, not checkable") << false << false << int(QStyle::SC_GroupBoxContents) << 0 << false;
+ QTest::newRow("hit label, not checkable") << false << false << int(QStyle::SC_GroupBoxLabel) << 0 << false;
+ QTest::newRow("hit checkbox, not checkable") << false << false << int(QStyle::SC_GroupBoxCheckBox) << 0 << false;
+
+ QTest::newRow("hit nothing, checkable") << true << true << int(QStyle::SC_None) << 0 << true;
+ QTest::newRow("hit frame, checkable") << true << true << int(QStyle::SC_GroupBoxFrame) << 0 << true;
+ QTest::newRow("hit content, checkable") << true << true << int(QStyle::SC_GroupBoxContents) << 0 << true;
+ QTest::newRow("hit label, checkable") << true << true << int(QStyle::SC_GroupBoxLabel) << 1 << false;
+ QTest::newRow("hit checkbox, checkable") << true << true << int(QStyle::SC_GroupBoxCheckBox) << 1 << false;
+
+ QTest::newRow("hit nothing, checkable, but unchecked") << true << false << int(QStyle::SC_None) << 0 << false;
+ QTest::newRow("hit frame, checkable, but unchecked") << true << false << int(QStyle::SC_GroupBoxFrame) << 0 << false;
+ QTest::newRow("hit content, checkable, but unchecked") << true << false << int(QStyle::SC_GroupBoxContents) << 0 << false;
+ QTest::newRow("hit label, checkable, but unchecked") << true << false << int(QStyle::SC_GroupBoxLabel) << 1 << true;
+ QTest::newRow("hit checkbox, checkable, but unchecked") << true << false << int(QStyle::SC_GroupBoxCheckBox) << 1 << true;
+}
+
+void tst_QGroupBox::clicked()
+{
+ QFETCH(bool, checkable);
+ QFETCH(bool, initialCheck);
+ QFETCH(int, areaToHit);
+ QGroupBox testWidget(QLatin1String("Testing Clicked"));
+ testWidget.setCheckable(checkable);
+ testWidget.setChecked(initialCheck);
+ QCOMPARE(testWidget.isChecked(), initialCheck);
+ testWidget.resize(200, 200);
+ QSignalSpy spy(&testWidget, SIGNAL(clicked(bool)));
+
+ QStyleOptionGroupBox option;
+ option.initFrom(&testWidget);
+ option.subControls = checkable ? QStyle::SubControls(QStyle::SC_All) : QStyle::SubControls(QStyle::SC_All & ~QStyle::SC_GroupBoxCheckBox);
+ option.text = testWidget.title();
+ option.textAlignment = testWidget.alignment();
+
+ QRect rect = testWidget.style()->subControlRect(QStyle::CC_GroupBox, &option,
+ QStyle::SubControl(areaToHit), &testWidget);
+
+ if (rect.isValid())
+ QTest::mouseClick(&testWidget, Qt::LeftButton, 0, rect.center());
+ else
+ QTest::mouseClick(&testWidget, Qt::LeftButton);
+
+ QTEST(spy.count(), "clickedCount");
+ if (spy.count() > 0)
+ QTEST(spy.at(0).at(0).toBool(), "finalCheck");
+ QTEST(testWidget.isChecked(), "finalCheck");
+}
+
+void tst_QGroupBox::toggledVsClicked()
+{
+ timeStamp = clickTimeStamp = toggleTimeStamp = 0;
+ QGroupBox groupBox;
+ groupBox.setCheckable(true);
+ QSignalSpy toggleSpy(&groupBox, SIGNAL(toggled(bool)));
+ QSignalSpy clickSpy(&groupBox, SIGNAL(clicked(bool)));
+
+ groupBox.setChecked(!groupBox.isChecked());
+ QCOMPARE(clickSpy.count(), 0);
+ QCOMPARE(toggleSpy.count(), 1);
+ if (toggleSpy.count() > 0)
+ QCOMPARE(toggleSpy.at(0).at(0).toBool(), groupBox.isChecked());
+
+ connect(&groupBox, SIGNAL(clicked(bool)), this, SLOT(clickTimestampSlot()));
+ connect(&groupBox, SIGNAL(toggled(bool)), this, SLOT(toggleTimestampSlot()));
+
+ QStyleOptionGroupBox option;
+ option.initFrom(&groupBox);
+ option.subControls = QStyle::SubControls(QStyle::SC_All);
+ QRect rect = groupBox.style()->subControlRect(QStyle::CC_GroupBox, &option,
+ QStyle::SC_GroupBoxCheckBox, &groupBox);
+
+ QTest::mouseClick(&groupBox, Qt::LeftButton, 0, rect.center());
+ QCOMPARE(clickSpy.count(), 1);
+ QCOMPARE(toggleSpy.count(), 2);
+ QVERIFY(toggleTimeStamp < clickTimeStamp);
+}
+
+void tst_QGroupBox::clickTimestampSlot()
+{
+ clickTimeStamp = ++timeStamp;
+}
+
+void tst_QGroupBox::toggleTimestampSlot()
+{
+ toggleTimeStamp = ++timeStamp;
+}
+
+void tst_QGroupBox::childrenAreDisabled()
+{
+ QGroupBox box;
+ box.setCheckable(true);
+ box.setChecked(false);
+
+ QVBoxLayout *layout = new QVBoxLayout;
+ layout->addWidget(new QRadioButton);
+ layout->addWidget(new QRadioButton);
+ layout->addWidget(new QRadioButton);
+ box.setLayout(layout);
+
+ foreach (QObject *object, box.children()) {
+ if (QWidget *widget = qobject_cast<QWidget *>(object)) {
+ QVERIFY(!widget->isEnabled());
+ QVERIFY(!widget->testAttribute(Qt::WA_ForceDisabled));
+ }
+ }
+
+ box.setChecked(true);
+ foreach (QObject *object, box.children()) {
+ if (QWidget *widget = qobject_cast<QWidget *>(object)) {
+ QVERIFY(widget->isEnabled());
+ QVERIFY(!widget->testAttribute(Qt::WA_ForceDisabled));
+ }
+ }
+
+ box.setChecked(false);
+ foreach (QObject *object, box.children()) {
+ if (QWidget *widget = qobject_cast<QWidget *>(object)) {
+ QVERIFY(!widget->isEnabled());
+ QVERIFY(!widget->testAttribute(Qt::WA_ForceDisabled));
+ }
+ }
+}
+
+void tst_QGroupBox::propagateFocus()
+{
+ QGroupBox box;
+ QLineEdit lineEdit(&box);
+ box.show();
+ QApplication::setActiveWindow(&box);
+ box.setFocus();
+ QTest::qWait(250);
+ QTRY_COMPARE(qApp->focusWidget(), static_cast<QWidget*>(&lineEdit));
+}
+
+QTEST_MAIN(tst_QGroupBox)
+#include "tst_qgroupbox.moc"
diff --git a/tests/auto/widgets/widgets/qintvalidator/.gitignore b/tests/auto/widgets/widgets/qintvalidator/.gitignore
new file mode 100644
index 0000000000..c6d5c989f0
--- /dev/null
+++ b/tests/auto/widgets/widgets/qintvalidator/.gitignore
@@ -0,0 +1 @@
+tst_qintvalidator
diff --git a/tests/auto/widgets/widgets/qintvalidator/qintvalidator.pro b/tests/auto/widgets/widgets/qintvalidator/qintvalidator.pro
new file mode 100644
index 0000000000..576621a08b
--- /dev/null
+++ b/tests/auto/widgets/widgets/qintvalidator/qintvalidator.pro
@@ -0,0 +1,4 @@
+load(qttest_p4)
+SOURCES += tst_qintvalidator.cpp
+
+
diff --git a/tests/auto/widgets/widgets/qintvalidator/tst_qintvalidator.cpp b/tests/auto/widgets/widgets/qintvalidator/tst_qintvalidator.cpp
new file mode 100644
index 0000000000..369e3254e8
--- /dev/null
+++ b/tests/auto/widgets/widgets/qintvalidator/tst_qintvalidator.cpp
@@ -0,0 +1,255 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#include <QtTest/QtTest>
+#include <qvalidator.h>
+
+class tst_QIntValidator : public QObject
+{
+ Q_OBJECT
+private slots:
+ void validate_data();
+ void validate();
+ void validateArabic();
+ void validateFrench();
+ void notifySignals();
+};
+
+Q_DECLARE_METATYPE(QValidator::State);
+#define INV QValidator::Invalid
+#define INT QValidator::Intermediate
+#define ACC QValidator::Acceptable
+
+void tst_QIntValidator::validate_data()
+{
+ QTest::addColumn<int>("minimum");
+ QTest::addColumn<int>("maximum");
+ QTest::addColumn<QString>("value");
+ QTest::addColumn<QValidator::State>("state");
+
+ QTest::newRow("data0") << 0 << 100 << QString("50") << ACC;
+ QTest::newRow("data1") << 0 << 100 << QString("500") << INV;
+ QTest::newRow("data1a") << 0 << 100 << QString("5000") << INV;
+ QTest::newRow("data1b") << -100 << 0 << QString("50") << INT;
+ QTest::newRow("data1b") << -100 << 0 << QString("500") << INV;
+ QTest::newRow("data1c") << -100 << 0 << QString("5000") << INV;
+ QTest::newRow("data2") << 0 << 100 << QString("-35") << INV;
+ QTest::newRow("data3") << 0 << 100 << QString("a") << INV;
+ QTest::newRow("data4") << 0 << 100 << QString("-") << INV;
+ QTest::newRow("data5") << 0 << 100 << QString("100") << ACC;
+ QTest::newRow("data6") << -100 << 100 << QString("-") << INT;
+ QTest::newRow("data7") << -100 << 100 << QString("-500") << INV;
+ QTest::newRow("data8") << -100 << 100 << QString("-100") << ACC;
+ QTest::newRow("data9") << -100 << -10 << QString("10") << INT;
+
+ QTest::newRow("data10") << 100 << 999 << QString("") << INT;
+ QTest::newRow("data11") << 100 << 999 << QString("5") << INT;
+ QTest::newRow("data12") << 100 << 999 << QString("50") << INT;
+ QTest::newRow("data13") << 100 << 999 << QString("99") << INT;
+ QTest::newRow("data14") << 100 << 999 << QString("100") << ACC;
+ QTest::newRow("data15") << 100 << 999 << QString("101") << ACC;
+ QTest::newRow("data16") << 100 << 999 << QString("998") << ACC;
+ QTest::newRow("data17") << 100 << 999 << QString("999") << ACC;
+ QTest::newRow("data18") << 100 << 999 << QString("1000") << INV;
+ QTest::newRow("data19") << 100 << 999 << QString("-10") << INV;
+
+ QTest::newRow("data20") << -999 << -100 << QString("50") << INT;
+ QTest::newRow("data21") << -999 << -100 << QString("-") << INT;
+ QTest::newRow("data22") << -999 << -100 << QString("-1") << INT;
+ QTest::newRow("data23") << -999 << -100 << QString("-10") << INT;
+ QTest::newRow("data24") << -999 << -100 << QString("-100") << ACC;
+ QTest::newRow("data25") << -999 << -100 << QString("-500") << ACC;
+ QTest::newRow("data26") << -999 << -100 << QString("-998") << ACC;
+ QTest::newRow("data27") << -999 << -100 << QString("-999") << ACC;
+ QTest::newRow("data28") << -999 << -100 << QString("-1000") << INV;
+ QTest::newRow("data29") << -999 << -100 << QString("-2000") << INV;
+
+ QTest::newRow("1.1") << 0 << 10 << QString("") << INT;
+ QTest::newRow("1.2") << 10 << 0 << QString("") << INT;
+
+ QTest::newRow("2.1") << 0 << 10 << QString("-") << INV;
+ QTest::newRow("2.2") << 0 << 10 << QString("-0") << INV;
+ QTest::newRow("2.3") << -10 << -1 << QString("+") << INV;
+ QTest::newRow("2.4") << -10 << 10 << QString("-") << INT;
+ QTest::newRow("2.5") << -10 << 10 << QString("+") << INT;
+ QTest::newRow("2.6") << -10 << 10 << QString("+0") << ACC;
+ QTest::newRow("2.7") << -10 << 10 << QString("+1") << ACC;
+ QTest::newRow("2.8") << -10 << 10 << QString("+-") << INV;
+ QTest::newRow("2.9") << -10 << 10 << QString("-+") << INV;
+
+ QTest::newRow("3.1") << 0 << 10 << QString("12345678901234567890") << INV;
+ QTest::newRow("3.2") << 0 << 10 << QString("-12345678901234567890") << INV;
+ QTest::newRow("3.3") << 0 << 10 << QString("000000000000000000000") << ACC;
+ QTest::newRow("3.4") << 1 << 10 << QString("000000000000000000000") << INT;
+ QTest::newRow("3.5") << 0 << 10 << QString("-000000000000000000000") << INV;
+ QTest::newRow("3.6") << -10 << -1 << QString("-000000000000000000000") << INT;
+ QTest::newRow("3.7") << -10 << -1 << QString("-0000000000000000000001") << ACC;
+
+ QTest::newRow("4.1") << 0 << 10 << QString(" ") << INV;
+ QTest::newRow("4.2") << 0 << 10 << QString(" 1") << INV;
+ QTest::newRow("4.3") << 0 << 10 << QString("1 ") << INV;
+ QTest::newRow("4.4") << 0 << 10 << QString("1.0") << INV;
+ QTest::newRow("4.5") << 0 << 10 << QString("0.1") << INV;
+ QTest::newRow("4.6") << 0 << 10 << QString(".1") << INV;
+ QTest::newRow("4.7") << 0 << 10 << QString("-1.0") << INV;
+
+ QTest::newRow("5.1") << 6 << 8 << QString("5") << INT;
+ QTest::newRow("5.2") << 6 << 8 << QString("7") << ACC;
+ QTest::newRow("5.3") << 6 << 8 << QString("9") << INV;
+ QTest::newRow("5.3a") << 6 << 8 << QString("19") << INV;
+ QTest::newRow("5.4") << -8 << -6 << QString("-5") << INT;
+ QTest::newRow("5.5") << -8 << -6 << QString("-7") << ACC;
+ QTest::newRow("5.6") << -8 << -6 << QString("-9") << INV;
+ QTest::newRow("5.6a") << -8 << -6 << QString("-19") << INV;
+ QTest::newRow("5.7") << -8 << -6 << QString("5") << INT;
+ QTest::newRow("5.8") << -8 << -6 << QString("7") << INT;
+ QTest::newRow("5.9") << -8 << -6 << QString("9") << INV;
+ QTest::newRow("5.10") << -6 << 8 << QString("-5") << ACC;
+ QTest::newRow("5.11") << -6 << 8 << QString("5") << ACC;
+ QTest::newRow("5.12") << -6 << 8 << QString("-7") << INV;
+ QTest::newRow("5.13") << -6 << 8 << QString("7") << ACC;
+ QTest::newRow("5.14") << -6 << 8 << QString("-9") << INV;
+ QTest::newRow("5.15") << -6 << 8 << QString("9") << INV;
+
+ QTest::newRow("6.1") << 100 << 102 << QString("11") << INT;
+ QTest::newRow("6.2") << 100 << 102 << QString("-11") << INV;
+
+ QTest::newRow("7.1") << 0 << 10 << QString("100") << INV;
+ QTest::newRow("7.2") << 0 << -10 << QString("100") << INV;
+ QTest::newRow("7.3") << 0 << -10 << QString("-100") << INV;
+ QTest::newRow("7.4") << -100 << 10 << QString("100") << INT;
+
+ QTest::newRow("8.1") << -100 << -10 << QString("+") << INV;
+ QTest::newRow("8.2") << -100 << -10 << QString("+50") << INV;
+ QTest::newRow("8.3") << -100 << -10 << QString("50") << INT;
+ QTest::newRow("8.4") << 10 << 100 << QString("-") << INV;
+ QTest::newRow("8.5") << 10 << 100 << QString("-50") << INV;
+ QTest::newRow("8.6") << 10 << 100 << QString("5") << INT;
+ QTest::newRow("8.7") << -1 << 100 << QString("-") << INT;
+ QTest::newRow("8.8") << -1 << 100 << QString("-50") << INV;
+ QTest::newRow("8.9") << -1 << 100 << QString("5") << ACC;
+ QTest::newRow("8.10") << -1 << 100 << QString("+") << INT;
+ QTest::newRow("8.11") << -1 << 100 << QString("+50") << ACC;
+}
+
+void tst_QIntValidator::validateArabic()
+{
+ QString arabicNum;
+ arabicNum += QChar(1633); // "18" in arabic
+ arabicNum += QChar(1640);
+
+ QIntValidator validator(-20, 20, 0);
+ validator.setLocale(QLocale(QLocale::Arabic, QLocale::SaudiArabia));
+ int i;
+ QCOMPARE(validator.validate(arabicNum, i), QValidator::Acceptable);
+
+}
+
+
+void tst_QIntValidator::validateFrench()
+{
+ QIntValidator validator(-2000, 2000, 0);
+ validator.setLocale(QLocale::French);
+ int i;
+ QString s = QLatin1String("1 ");
+ QCOMPARE(validator.validate(s, i), QValidator::Acceptable);
+ validator.fixup(s);
+ QCOMPARE(s, s);
+
+ s = QLatin1String("1 000");
+ QCOMPARE(validator.validate(s, i), QValidator::Acceptable);
+ validator.fixup(s);
+ QCOMPARE(s, s);
+
+
+ s = QLatin1String("1 0 00");
+ QCOMPARE(validator.validate(s, i), QValidator::Intermediate);
+ validator.fixup(s);
+ QCOMPARE(s, validator.locale().toString(1000));
+}
+
+void tst_QIntValidator::validate()
+{
+ QFETCH(int, minimum);
+ QFETCH(int, maximum);
+ QFETCH(QString, value);
+ QFETCH(QValidator::State, state);
+
+ QIntValidator iv(minimum, maximum, 0);
+ iv.setLocale(QLocale::C);
+ int dummy;
+ QCOMPARE((int)iv.validate(value, dummy), (int)state);
+}
+
+void tst_QIntValidator::notifySignals()
+{
+ QIntValidator iv(0, 10, 0);
+ QSignalSpy topSpy(&iv, SIGNAL(topChanged(int)));
+ QSignalSpy bottomSpy(&iv, SIGNAL(bottomChanged(int)));
+ iv.setTop(9);
+ QCOMPARE(topSpy.count(), 1);
+ QVERIFY(iv.top() == 9);
+ iv.setBottom(1);
+ QCOMPARE(bottomSpy.count(), 1);
+ QVERIFY(iv.bottom() == 1);
+
+ iv.setRange(1, 8);
+ QCOMPARE(topSpy.count(), 2);
+ QCOMPARE(bottomSpy.count(), 1);
+ QVERIFY(iv.top() == 8);
+ QVERIFY(iv.bottom() == 1);
+
+ iv.setRange(2, 8);
+ QCOMPARE(topSpy.count(), 2);
+ QCOMPARE(bottomSpy.count(), 2);
+ QVERIFY(iv.top() == 8);
+ QVERIFY(iv.bottom() == 2);
+
+ iv.setRange(3, 7);
+ QCOMPARE(topSpy.count(), 3);
+ QCOMPARE(bottomSpy.count(), 3);
+ QVERIFY(iv.top() == 7);
+ QVERIFY(iv.bottom() == 3);
+}
+
+QTEST_MAIN(tst_QIntValidator)
+#include "tst_qintvalidator.moc"
diff --git a/tests/auto/widgets/widgets/qlabel/.gitignore b/tests/auto/widgets/widgets/qlabel/.gitignore
new file mode 100644
index 0000000000..e050d7ab5e
--- /dev/null
+++ b/tests/auto/widgets/widgets/qlabel/.gitignore
@@ -0,0 +1 @@
+tst_qlabel
diff --git a/tests/auto/widgets/widgets/qlabel/green.png b/tests/auto/widgets/widgets/qlabel/green.png
new file mode 100644
index 0000000000..dfc95d4f37
--- /dev/null
+++ b/tests/auto/widgets/widgets/qlabel/green.png
Binary files differ
diff --git a/tests/auto/widgets/widgets/qlabel/qlabel.pro b/tests/auto/widgets/widgets/qlabel/qlabel.pro
new file mode 100644
index 0000000000..0e0c3a43c4
--- /dev/null
+++ b/tests/auto/widgets/widgets/qlabel/qlabel.pro
@@ -0,0 +1,15 @@
+load(qttest_p4)
+
+QT += widgets widgets-private
+QT += core-private gui-private
+
+SOURCES += tst_qlabel.cpp
+wince*::DEFINES += SRCDIR=\\\"\\\"
+else:DEFINES += SRCDIR=\\\"$$PWD/\\\"
+wince* {
+ addFiles.files = *.png \
+ testdata
+ addFiles.path = .
+ DEPLOYMENT += addFiles
+}
+
diff --git a/tests/auto/widgets/widgets/qlabel/red.png b/tests/auto/widgets/widgets/qlabel/red.png
new file mode 100644
index 0000000000..4a843e744f
--- /dev/null
+++ b/tests/auto/widgets/widgets/qlabel/red.png
Binary files differ
diff --git a/tests/auto/widgets/widgets/qlabel/testdata/acc_01/res_Windows_data0.qsnap b/tests/auto/widgets/widgets/qlabel/testdata/acc_01/res_Windows_data0.qsnap
new file mode 100644
index 0000000000..522c173ac4
--- /dev/null
+++ b/tests/auto/widgets/widgets/qlabel/testdata/acc_01/res_Windows_data0.qsnap
Binary files differ
diff --git a/tests/auto/widgets/widgets/qlabel/testdata/acc_01/res_Windows_win32_data0.qsnap b/tests/auto/widgets/widgets/qlabel/testdata/acc_01/res_Windows_win32_data0.qsnap
new file mode 100644
index 0000000000..acd881d29a
--- /dev/null
+++ b/tests/auto/widgets/widgets/qlabel/testdata/acc_01/res_Windows_win32_data0.qsnap
Binary files differ
diff --git a/tests/auto/widgets/widgets/qlabel/testdata/setAlignment/alignRes_Motif_data0.qsnap b/tests/auto/widgets/widgets/qlabel/testdata/setAlignment/alignRes_Motif_data0.qsnap
new file mode 100644
index 0000000000..9e2c1764d3
--- /dev/null
+++ b/tests/auto/widgets/widgets/qlabel/testdata/setAlignment/alignRes_Motif_data0.qsnap
Binary files differ
diff --git a/tests/auto/widgets/widgets/qlabel/testdata/setAlignment/alignRes_Motif_data1.qsnap b/tests/auto/widgets/widgets/qlabel/testdata/setAlignment/alignRes_Motif_data1.qsnap
new file mode 100644
index 0000000000..dcd708fdbf
--- /dev/null
+++ b/tests/auto/widgets/widgets/qlabel/testdata/setAlignment/alignRes_Motif_data1.qsnap
Binary files differ
diff --git a/tests/auto/widgets/widgets/qlabel/testdata/setAlignment/alignRes_Motif_data10.qsnap b/tests/auto/widgets/widgets/qlabel/testdata/setAlignment/alignRes_Motif_data10.qsnap
new file mode 100644
index 0000000000..2131f59fe9
--- /dev/null
+++ b/tests/auto/widgets/widgets/qlabel/testdata/setAlignment/alignRes_Motif_data10.qsnap
Binary files differ
diff --git a/tests/auto/widgets/widgets/qlabel/testdata/setAlignment/alignRes_Motif_data2.qsnap b/tests/auto/widgets/widgets/qlabel/testdata/setAlignment/alignRes_Motif_data2.qsnap
new file mode 100644
index 0000000000..2edd976830
--- /dev/null
+++ b/tests/auto/widgets/widgets/qlabel/testdata/setAlignment/alignRes_Motif_data2.qsnap
Binary files differ
diff --git a/tests/auto/widgets/widgets/qlabel/testdata/setAlignment/alignRes_Motif_data3.qsnap b/tests/auto/widgets/widgets/qlabel/testdata/setAlignment/alignRes_Motif_data3.qsnap
new file mode 100644
index 0000000000..2ce28d9816
--- /dev/null
+++ b/tests/auto/widgets/widgets/qlabel/testdata/setAlignment/alignRes_Motif_data3.qsnap
Binary files differ
diff --git a/tests/auto/widgets/widgets/qlabel/testdata/setAlignment/alignRes_Motif_data4.qsnap b/tests/auto/widgets/widgets/qlabel/testdata/setAlignment/alignRes_Motif_data4.qsnap
new file mode 100644
index 0000000000..6476f6c26b
--- /dev/null
+++ b/tests/auto/widgets/widgets/qlabel/testdata/setAlignment/alignRes_Motif_data4.qsnap
Binary files differ
diff --git a/tests/auto/widgets/widgets/qlabel/testdata/setAlignment/alignRes_Motif_data5.qsnap b/tests/auto/widgets/widgets/qlabel/testdata/setAlignment/alignRes_Motif_data5.qsnap
new file mode 100644
index 0000000000..6039742962
--- /dev/null
+++ b/tests/auto/widgets/widgets/qlabel/testdata/setAlignment/alignRes_Motif_data5.qsnap
Binary files differ
diff --git a/tests/auto/widgets/widgets/qlabel/testdata/setAlignment/alignRes_Motif_data6.qsnap b/tests/auto/widgets/widgets/qlabel/testdata/setAlignment/alignRes_Motif_data6.qsnap
new file mode 100644
index 0000000000..477d203960
--- /dev/null
+++ b/tests/auto/widgets/widgets/qlabel/testdata/setAlignment/alignRes_Motif_data6.qsnap
Binary files differ
diff --git a/tests/auto/widgets/widgets/qlabel/testdata/setAlignment/alignRes_Motif_data7.qsnap b/tests/auto/widgets/widgets/qlabel/testdata/setAlignment/alignRes_Motif_data7.qsnap
new file mode 100644
index 0000000000..c673f4099e
--- /dev/null
+++ b/tests/auto/widgets/widgets/qlabel/testdata/setAlignment/alignRes_Motif_data7.qsnap
Binary files differ
diff --git a/tests/auto/widgets/widgets/qlabel/testdata/setAlignment/alignRes_Motif_data8.qsnap b/tests/auto/widgets/widgets/qlabel/testdata/setAlignment/alignRes_Motif_data8.qsnap
new file mode 100644
index 0000000000..a490f77118
--- /dev/null
+++ b/tests/auto/widgets/widgets/qlabel/testdata/setAlignment/alignRes_Motif_data8.qsnap
Binary files differ
diff --git a/tests/auto/widgets/widgets/qlabel/testdata/setAlignment/alignRes_Motif_data9.qsnap b/tests/auto/widgets/widgets/qlabel/testdata/setAlignment/alignRes_Motif_data9.qsnap
new file mode 100644
index 0000000000..33342d3616
--- /dev/null
+++ b/tests/auto/widgets/widgets/qlabel/testdata/setAlignment/alignRes_Motif_data9.qsnap
Binary files differ
diff --git a/tests/auto/widgets/widgets/qlabel/testdata/setAlignment/alignRes_Windows_data0.qsnap b/tests/auto/widgets/widgets/qlabel/testdata/setAlignment/alignRes_Windows_data0.qsnap
new file mode 100644
index 0000000000..3fe9a82c2f
--- /dev/null
+++ b/tests/auto/widgets/widgets/qlabel/testdata/setAlignment/alignRes_Windows_data0.qsnap
Binary files differ
diff --git a/tests/auto/widgets/widgets/qlabel/testdata/setAlignment/alignRes_Windows_data1.qsnap b/tests/auto/widgets/widgets/qlabel/testdata/setAlignment/alignRes_Windows_data1.qsnap
new file mode 100644
index 0000000000..175235dc38
--- /dev/null
+++ b/tests/auto/widgets/widgets/qlabel/testdata/setAlignment/alignRes_Windows_data1.qsnap
Binary files differ
diff --git a/tests/auto/widgets/widgets/qlabel/testdata/setAlignment/alignRes_Windows_data10.qsnap b/tests/auto/widgets/widgets/qlabel/testdata/setAlignment/alignRes_Windows_data10.qsnap
new file mode 100644
index 0000000000..b1ac74b531
--- /dev/null
+++ b/tests/auto/widgets/widgets/qlabel/testdata/setAlignment/alignRes_Windows_data10.qsnap
Binary files differ
diff --git a/tests/auto/widgets/widgets/qlabel/testdata/setAlignment/alignRes_Windows_data2.qsnap b/tests/auto/widgets/widgets/qlabel/testdata/setAlignment/alignRes_Windows_data2.qsnap
new file mode 100644
index 0000000000..fdd3c7c701
--- /dev/null
+++ b/tests/auto/widgets/widgets/qlabel/testdata/setAlignment/alignRes_Windows_data2.qsnap
Binary files differ
diff --git a/tests/auto/widgets/widgets/qlabel/testdata/setAlignment/alignRes_Windows_data3.qsnap b/tests/auto/widgets/widgets/qlabel/testdata/setAlignment/alignRes_Windows_data3.qsnap
new file mode 100644
index 0000000000..caa47f7292
--- /dev/null
+++ b/tests/auto/widgets/widgets/qlabel/testdata/setAlignment/alignRes_Windows_data3.qsnap
Binary files differ
diff --git a/tests/auto/widgets/widgets/qlabel/testdata/setAlignment/alignRes_Windows_data4.qsnap b/tests/auto/widgets/widgets/qlabel/testdata/setAlignment/alignRes_Windows_data4.qsnap
new file mode 100644
index 0000000000..a0d2498e76
--- /dev/null
+++ b/tests/auto/widgets/widgets/qlabel/testdata/setAlignment/alignRes_Windows_data4.qsnap
Binary files differ
diff --git a/tests/auto/widgets/widgets/qlabel/testdata/setAlignment/alignRes_Windows_data5.qsnap b/tests/auto/widgets/widgets/qlabel/testdata/setAlignment/alignRes_Windows_data5.qsnap
new file mode 100644
index 0000000000..756d9fe827
--- /dev/null
+++ b/tests/auto/widgets/widgets/qlabel/testdata/setAlignment/alignRes_Windows_data5.qsnap
Binary files differ
diff --git a/tests/auto/widgets/widgets/qlabel/testdata/setAlignment/alignRes_Windows_data6.qsnap b/tests/auto/widgets/widgets/qlabel/testdata/setAlignment/alignRes_Windows_data6.qsnap
new file mode 100644
index 0000000000..f973d14c38
--- /dev/null
+++ b/tests/auto/widgets/widgets/qlabel/testdata/setAlignment/alignRes_Windows_data6.qsnap
Binary files differ
diff --git a/tests/auto/widgets/widgets/qlabel/testdata/setAlignment/alignRes_Windows_data7.qsnap b/tests/auto/widgets/widgets/qlabel/testdata/setAlignment/alignRes_Windows_data7.qsnap
new file mode 100644
index 0000000000..720d807db2
--- /dev/null
+++ b/tests/auto/widgets/widgets/qlabel/testdata/setAlignment/alignRes_Windows_data7.qsnap
Binary files differ
diff --git a/tests/auto/widgets/widgets/qlabel/testdata/setAlignment/alignRes_Windows_data8.qsnap b/tests/auto/widgets/widgets/qlabel/testdata/setAlignment/alignRes_Windows_data8.qsnap
new file mode 100644
index 0000000000..20fd48e7cc
--- /dev/null
+++ b/tests/auto/widgets/widgets/qlabel/testdata/setAlignment/alignRes_Windows_data8.qsnap
Binary files differ
diff --git a/tests/auto/widgets/widgets/qlabel/testdata/setAlignment/alignRes_Windows_data9.qsnap b/tests/auto/widgets/widgets/qlabel/testdata/setAlignment/alignRes_Windows_data9.qsnap
new file mode 100644
index 0000000000..7db7c97a14
--- /dev/null
+++ b/tests/auto/widgets/widgets/qlabel/testdata/setAlignment/alignRes_Windows_data9.qsnap
Binary files differ
diff --git a/tests/auto/widgets/widgets/qlabel/testdata/setAlignment/alignRes_Windows_win32_data0.qsnap b/tests/auto/widgets/widgets/qlabel/testdata/setAlignment/alignRes_Windows_win32_data0.qsnap
new file mode 100644
index 0000000000..d9912d8c92
--- /dev/null
+++ b/tests/auto/widgets/widgets/qlabel/testdata/setAlignment/alignRes_Windows_win32_data0.qsnap
Binary files differ
diff --git a/tests/auto/widgets/widgets/qlabel/testdata/setAlignment/alignRes_Windows_win32_data1.qsnap b/tests/auto/widgets/widgets/qlabel/testdata/setAlignment/alignRes_Windows_win32_data1.qsnap
new file mode 100644
index 0000000000..bfc3a6488e
--- /dev/null
+++ b/tests/auto/widgets/widgets/qlabel/testdata/setAlignment/alignRes_Windows_win32_data1.qsnap
Binary files differ
diff --git a/tests/auto/widgets/widgets/qlabel/testdata/setAlignment/alignRes_Windows_win32_data10.qsnap b/tests/auto/widgets/widgets/qlabel/testdata/setAlignment/alignRes_Windows_win32_data10.qsnap
new file mode 100644
index 0000000000..09a35ef761
--- /dev/null
+++ b/tests/auto/widgets/widgets/qlabel/testdata/setAlignment/alignRes_Windows_win32_data10.qsnap
Binary files differ
diff --git a/tests/auto/widgets/widgets/qlabel/testdata/setAlignment/alignRes_Windows_win32_data2.qsnap b/tests/auto/widgets/widgets/qlabel/testdata/setAlignment/alignRes_Windows_win32_data2.qsnap
new file mode 100644
index 0000000000..14e11232f0
--- /dev/null
+++ b/tests/auto/widgets/widgets/qlabel/testdata/setAlignment/alignRes_Windows_win32_data2.qsnap
Binary files differ
diff --git a/tests/auto/widgets/widgets/qlabel/testdata/setAlignment/alignRes_Windows_win32_data3.qsnap b/tests/auto/widgets/widgets/qlabel/testdata/setAlignment/alignRes_Windows_win32_data3.qsnap
new file mode 100644
index 0000000000..6ef864e635
--- /dev/null
+++ b/tests/auto/widgets/widgets/qlabel/testdata/setAlignment/alignRes_Windows_win32_data3.qsnap
Binary files differ
diff --git a/tests/auto/widgets/widgets/qlabel/testdata/setAlignment/alignRes_Windows_win32_data4.qsnap b/tests/auto/widgets/widgets/qlabel/testdata/setAlignment/alignRes_Windows_win32_data4.qsnap
new file mode 100644
index 0000000000..eb029008e3
--- /dev/null
+++ b/tests/auto/widgets/widgets/qlabel/testdata/setAlignment/alignRes_Windows_win32_data4.qsnap
Binary files differ
diff --git a/tests/auto/widgets/widgets/qlabel/testdata/setAlignment/alignRes_Windows_win32_data5.qsnap b/tests/auto/widgets/widgets/qlabel/testdata/setAlignment/alignRes_Windows_win32_data5.qsnap
new file mode 100644
index 0000000000..439e196b57
--- /dev/null
+++ b/tests/auto/widgets/widgets/qlabel/testdata/setAlignment/alignRes_Windows_win32_data5.qsnap
Binary files differ
diff --git a/tests/auto/widgets/widgets/qlabel/testdata/setAlignment/alignRes_Windows_win32_data6.qsnap b/tests/auto/widgets/widgets/qlabel/testdata/setAlignment/alignRes_Windows_win32_data6.qsnap
new file mode 100644
index 0000000000..9637d1741a
--- /dev/null
+++ b/tests/auto/widgets/widgets/qlabel/testdata/setAlignment/alignRes_Windows_win32_data6.qsnap
Binary files differ
diff --git a/tests/auto/widgets/widgets/qlabel/testdata/setAlignment/alignRes_Windows_win32_data7.qsnap b/tests/auto/widgets/widgets/qlabel/testdata/setAlignment/alignRes_Windows_win32_data7.qsnap
new file mode 100644
index 0000000000..9a553465c3
--- /dev/null
+++ b/tests/auto/widgets/widgets/qlabel/testdata/setAlignment/alignRes_Windows_win32_data7.qsnap
Binary files differ
diff --git a/tests/auto/widgets/widgets/qlabel/testdata/setAlignment/alignRes_Windows_win32_data8.qsnap b/tests/auto/widgets/widgets/qlabel/testdata/setAlignment/alignRes_Windows_win32_data8.qsnap
new file mode 100644
index 0000000000..0d9184c316
--- /dev/null
+++ b/tests/auto/widgets/widgets/qlabel/testdata/setAlignment/alignRes_Windows_win32_data8.qsnap
Binary files differ
diff --git a/tests/auto/widgets/widgets/qlabel/testdata/setAlignment/alignRes_Windows_win32_data9.qsnap b/tests/auto/widgets/widgets/qlabel/testdata/setAlignment/alignRes_Windows_win32_data9.qsnap
new file mode 100644
index 0000000000..f2873b1c78
--- /dev/null
+++ b/tests/auto/widgets/widgets/qlabel/testdata/setAlignment/alignRes_Windows_win32_data9.qsnap
Binary files differ
diff --git a/tests/auto/widgets/widgets/qlabel/testdata/setIndent/indentRes_Motif_data0.qsnap b/tests/auto/widgets/widgets/qlabel/testdata/setIndent/indentRes_Motif_data0.qsnap
new file mode 100644
index 0000000000..1385a50d38
--- /dev/null
+++ b/tests/auto/widgets/widgets/qlabel/testdata/setIndent/indentRes_Motif_data0.qsnap
Binary files differ
diff --git a/tests/auto/widgets/widgets/qlabel/testdata/setIndent/indentRes_Motif_data1.qsnap b/tests/auto/widgets/widgets/qlabel/testdata/setIndent/indentRes_Motif_data1.qsnap
new file mode 100644
index 0000000000..38223cfba2
--- /dev/null
+++ b/tests/auto/widgets/widgets/qlabel/testdata/setIndent/indentRes_Motif_data1.qsnap
Binary files differ
diff --git a/tests/auto/widgets/widgets/qlabel/testdata/setIndent/indentRes_Motif_data2.qsnap b/tests/auto/widgets/widgets/qlabel/testdata/setIndent/indentRes_Motif_data2.qsnap
new file mode 100644
index 0000000000..0b946a4968
--- /dev/null
+++ b/tests/auto/widgets/widgets/qlabel/testdata/setIndent/indentRes_Motif_data2.qsnap
Binary files differ
diff --git a/tests/auto/widgets/widgets/qlabel/testdata/setIndent/indentRes_Windows_data0.qsnap b/tests/auto/widgets/widgets/qlabel/testdata/setIndent/indentRes_Windows_data0.qsnap
new file mode 100644
index 0000000000..e1d2c41d88
--- /dev/null
+++ b/tests/auto/widgets/widgets/qlabel/testdata/setIndent/indentRes_Windows_data0.qsnap
Binary files differ
diff --git a/tests/auto/widgets/widgets/qlabel/testdata/setIndent/indentRes_Windows_data1.qsnap b/tests/auto/widgets/widgets/qlabel/testdata/setIndent/indentRes_Windows_data1.qsnap
new file mode 100644
index 0000000000..b7bdee551b
--- /dev/null
+++ b/tests/auto/widgets/widgets/qlabel/testdata/setIndent/indentRes_Windows_data1.qsnap
Binary files differ
diff --git a/tests/auto/widgets/widgets/qlabel/testdata/setIndent/indentRes_Windows_data2.qsnap b/tests/auto/widgets/widgets/qlabel/testdata/setIndent/indentRes_Windows_data2.qsnap
new file mode 100644
index 0000000000..a20492ee70
--- /dev/null
+++ b/tests/auto/widgets/widgets/qlabel/testdata/setIndent/indentRes_Windows_data2.qsnap
Binary files differ
diff --git a/tests/auto/widgets/widgets/qlabel/testdata/setIndent/indentRes_Windows_win32_data0.qsnap b/tests/auto/widgets/widgets/qlabel/testdata/setIndent/indentRes_Windows_win32_data0.qsnap
new file mode 100644
index 0000000000..85e3306d0c
--- /dev/null
+++ b/tests/auto/widgets/widgets/qlabel/testdata/setIndent/indentRes_Windows_win32_data0.qsnap
Binary files differ
diff --git a/tests/auto/widgets/widgets/qlabel/testdata/setIndent/indentRes_Windows_win32_data1.qsnap b/tests/auto/widgets/widgets/qlabel/testdata/setIndent/indentRes_Windows_win32_data1.qsnap
new file mode 100644
index 0000000000..3bf991f674
--- /dev/null
+++ b/tests/auto/widgets/widgets/qlabel/testdata/setIndent/indentRes_Windows_win32_data1.qsnap
Binary files differ
diff --git a/tests/auto/widgets/widgets/qlabel/testdata/setIndent/indentRes_Windows_win32_data2.qsnap b/tests/auto/widgets/widgets/qlabel/testdata/setIndent/indentRes_Windows_win32_data2.qsnap
new file mode 100644
index 0000000000..f05a9dcebd
--- /dev/null
+++ b/tests/auto/widgets/widgets/qlabel/testdata/setIndent/indentRes_Windows_win32_data2.qsnap
Binary files differ
diff --git a/tests/auto/widgets/widgets/qlabel/testdata/setPixmap/Vpix_Motif_data0.qsnap b/tests/auto/widgets/widgets/qlabel/testdata/setPixmap/Vpix_Motif_data0.qsnap
new file mode 100644
index 0000000000..d7428df5ef
--- /dev/null
+++ b/tests/auto/widgets/widgets/qlabel/testdata/setPixmap/Vpix_Motif_data0.qsnap
Binary files differ
diff --git a/tests/auto/widgets/widgets/qlabel/testdata/setPixmap/Vpix_Windows_data0.qsnap b/tests/auto/widgets/widgets/qlabel/testdata/setPixmap/Vpix_Windows_data0.qsnap
new file mode 100644
index 0000000000..905acd1283
--- /dev/null
+++ b/tests/auto/widgets/widgets/qlabel/testdata/setPixmap/Vpix_Windows_data0.qsnap
Binary files differ
diff --git a/tests/auto/widgets/widgets/qlabel/testdata/setPixmap/Vpix_Windows_win32_data0.qsnap b/tests/auto/widgets/widgets/qlabel/testdata/setPixmap/Vpix_Windows_win32_data0.qsnap
new file mode 100644
index 0000000000..e1dea4b76b
--- /dev/null
+++ b/tests/auto/widgets/widgets/qlabel/testdata/setPixmap/Vpix_Windows_win32_data0.qsnap
Binary files differ
diff --git a/tests/auto/widgets/widgets/qlabel/testdata/setPixmap/empty_Motif_data0.qsnap b/tests/auto/widgets/widgets/qlabel/testdata/setPixmap/empty_Motif_data0.qsnap
new file mode 100644
index 0000000000..055ccda47e
--- /dev/null
+++ b/tests/auto/widgets/widgets/qlabel/testdata/setPixmap/empty_Motif_data0.qsnap
Binary files differ
diff --git a/tests/auto/widgets/widgets/qlabel/testdata/setPixmap/empty_Windows_data0.qsnap b/tests/auto/widgets/widgets/qlabel/testdata/setPixmap/empty_Windows_data0.qsnap
new file mode 100644
index 0000000000..64b70763d4
--- /dev/null
+++ b/tests/auto/widgets/widgets/qlabel/testdata/setPixmap/empty_Windows_data0.qsnap
Binary files differ
diff --git a/tests/auto/widgets/widgets/qlabel/testdata/setPixmap/empty_Windows_win32_data0.qsnap b/tests/auto/widgets/widgets/qlabel/testdata/setPixmap/empty_Windows_win32_data0.qsnap
new file mode 100644
index 0000000000..fb0ea227ad
--- /dev/null
+++ b/tests/auto/widgets/widgets/qlabel/testdata/setPixmap/empty_Windows_win32_data0.qsnap
Binary files differ
diff --git a/tests/auto/widgets/widgets/qlabel/testdata/setPixmap/scaledVpix_Motif_data0.qsnap b/tests/auto/widgets/widgets/qlabel/testdata/setPixmap/scaledVpix_Motif_data0.qsnap
new file mode 100644
index 0000000000..ae9cda541f
--- /dev/null
+++ b/tests/auto/widgets/widgets/qlabel/testdata/setPixmap/scaledVpix_Motif_data0.qsnap
Binary files differ
diff --git a/tests/auto/widgets/widgets/qlabel/testdata/setPixmap/scaledVpix_Windows_data0.qsnap b/tests/auto/widgets/widgets/qlabel/testdata/setPixmap/scaledVpix_Windows_data0.qsnap
new file mode 100644
index 0000000000..e21af3223a
--- /dev/null
+++ b/tests/auto/widgets/widgets/qlabel/testdata/setPixmap/scaledVpix_Windows_data0.qsnap
Binary files differ
diff --git a/tests/auto/widgets/widgets/qlabel/testdata/setPixmap/scaledVpix_Windows_win32_data0.qsnap b/tests/auto/widgets/widgets/qlabel/testdata/setPixmap/scaledVpix_Windows_win32_data0.qsnap
new file mode 100644
index 0000000000..32cc40652b
--- /dev/null
+++ b/tests/auto/widgets/widgets/qlabel/testdata/setPixmap/scaledVpix_Windows_win32_data0.qsnap
Binary files differ
diff --git a/tests/auto/widgets/widgets/qlabel/testdata/setText/res_Motif_data0.qsnap b/tests/auto/widgets/widgets/qlabel/testdata/setText/res_Motif_data0.qsnap
new file mode 100644
index 0000000000..7191b517d2
--- /dev/null
+++ b/tests/auto/widgets/widgets/qlabel/testdata/setText/res_Motif_data0.qsnap
Binary files differ
diff --git a/tests/auto/widgets/widgets/qlabel/testdata/setText/res_Motif_data1.qsnap b/tests/auto/widgets/widgets/qlabel/testdata/setText/res_Motif_data1.qsnap
new file mode 100644
index 0000000000..d943ce960a
--- /dev/null
+++ b/tests/auto/widgets/widgets/qlabel/testdata/setText/res_Motif_data1.qsnap
Binary files differ
diff --git a/tests/auto/widgets/widgets/qlabel/testdata/setText/res_Motif_data2.qsnap b/tests/auto/widgets/widgets/qlabel/testdata/setText/res_Motif_data2.qsnap
new file mode 100644
index 0000000000..946432e66d
--- /dev/null
+++ b/tests/auto/widgets/widgets/qlabel/testdata/setText/res_Motif_data2.qsnap
Binary files differ
diff --git a/tests/auto/widgets/widgets/qlabel/testdata/setText/res_Motif_data3.qsnap b/tests/auto/widgets/widgets/qlabel/testdata/setText/res_Motif_data3.qsnap
new file mode 100644
index 0000000000..dc5ac0c56d
--- /dev/null
+++ b/tests/auto/widgets/widgets/qlabel/testdata/setText/res_Motif_data3.qsnap
Binary files differ
diff --git a/tests/auto/widgets/widgets/qlabel/testdata/setText/res_Windows_data0.qsnap b/tests/auto/widgets/widgets/qlabel/testdata/setText/res_Windows_data0.qsnap
new file mode 100644
index 0000000000..2ab392e50e
--- /dev/null
+++ b/tests/auto/widgets/widgets/qlabel/testdata/setText/res_Windows_data0.qsnap
Binary files differ
diff --git a/tests/auto/widgets/widgets/qlabel/testdata/setText/res_Windows_data1.qsnap b/tests/auto/widgets/widgets/qlabel/testdata/setText/res_Windows_data1.qsnap
new file mode 100644
index 0000000000..5769459ab6
--- /dev/null
+++ b/tests/auto/widgets/widgets/qlabel/testdata/setText/res_Windows_data1.qsnap
Binary files differ
diff --git a/tests/auto/widgets/widgets/qlabel/testdata/setText/res_Windows_data2.qsnap b/tests/auto/widgets/widgets/qlabel/testdata/setText/res_Windows_data2.qsnap
new file mode 100644
index 0000000000..b4206c2a57
--- /dev/null
+++ b/tests/auto/widgets/widgets/qlabel/testdata/setText/res_Windows_data2.qsnap
Binary files differ
diff --git a/tests/auto/widgets/widgets/qlabel/testdata/setText/res_Windows_data3.qsnap b/tests/auto/widgets/widgets/qlabel/testdata/setText/res_Windows_data3.qsnap
new file mode 100644
index 0000000000..f120ac2e76
--- /dev/null
+++ b/tests/auto/widgets/widgets/qlabel/testdata/setText/res_Windows_data3.qsnap
Binary files differ
diff --git a/tests/auto/widgets/widgets/qlabel/testdata/setText/res_Windows_win32_data0.qsnap b/tests/auto/widgets/widgets/qlabel/testdata/setText/res_Windows_win32_data0.qsnap
new file mode 100644
index 0000000000..7644f53726
--- /dev/null
+++ b/tests/auto/widgets/widgets/qlabel/testdata/setText/res_Windows_win32_data0.qsnap
Binary files differ
diff --git a/tests/auto/widgets/widgets/qlabel/testdata/setText/res_Windows_win32_data1.qsnap b/tests/auto/widgets/widgets/qlabel/testdata/setText/res_Windows_win32_data1.qsnap
new file mode 100644
index 0000000000..7902b1b087
--- /dev/null
+++ b/tests/auto/widgets/widgets/qlabel/testdata/setText/res_Windows_win32_data1.qsnap
Binary files differ
diff --git a/tests/auto/widgets/widgets/qlabel/testdata/setText/res_Windows_win32_data2.qsnap b/tests/auto/widgets/widgets/qlabel/testdata/setText/res_Windows_win32_data2.qsnap
new file mode 100644
index 0000000000..60bd075c78
--- /dev/null
+++ b/tests/auto/widgets/widgets/qlabel/testdata/setText/res_Windows_win32_data2.qsnap
Binary files differ
diff --git a/tests/auto/widgets/widgets/qlabel/testdata/setText/res_Windows_win32_data3.qsnap b/tests/auto/widgets/widgets/qlabel/testdata/setText/res_Windows_win32_data3.qsnap
new file mode 100644
index 0000000000..c1dcb272b3
--- /dev/null
+++ b/tests/auto/widgets/widgets/qlabel/testdata/setText/res_Windows_win32_data3.qsnap
Binary files differ
diff --git a/tests/auto/widgets/widgets/qlabel/tst_qlabel.cpp b/tests/auto/widgets/widgets/qlabel/tst_qlabel.cpp
new file mode 100644
index 0000000000..9cab8b328d
--- /dev/null
+++ b/tests/auto/widgets/widgets/qlabel/tst_qlabel.cpp
@@ -0,0 +1,581 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#include <QtTest/QtTest>
+
+
+#include "qlabel.h"
+#include <qapplication.h>
+#include <qboxlayout.h>
+#include <qlabel.h>
+#include <qlineedit.h>
+#include <qmovie.h>
+#include <qpicture.h>
+#include <qmessagebox.h>
+#include <private/qlabel_p.h>
+
+//TESTED_CLASS=
+//TESTED_FILES=
+
+class Widget : public QWidget
+{
+public:
+ Widget() { }
+
+ QList<QEvent::Type> events;
+
+protected:
+ bool event(QEvent *ev) {
+ events.append(ev->type());
+ return QWidget::event(ev);
+ }
+
+};
+
+class tst_QLabel : public QObject
+{
+Q_OBJECT
+
+public:
+ tst_QLabel();
+ virtual ~tst_QLabel();
+
+
+public slots:
+ void initTestCase();
+ void cleanupTestCase();
+ void init();
+ void cleanup();
+private slots:
+ void getSetCheck();
+ void setText_data();
+ void setText();
+ void setTextFormat();
+#ifndef Q_WS_MAC
+ void setBuddy();
+#endif
+ void setNum();
+ void clear();
+ void wordWrap();
+ void eventPropagation_data();
+ void eventPropagation();
+ void focusPolicy();
+
+ void task190318_sizes();
+
+ void sizeHint();
+
+ void task226479_movieResize();
+ void emptyPixmap();
+
+ void unicodeText_data();
+ void unicodeText();
+
+ void mnemonic_data();
+ void mnemonic();
+ void selection();
+
+#ifndef QT_NO_CONTEXTMENU
+ void taskQTBUG_7902_contextMenuCrash();
+#endif
+
+private:
+ QLabel *testWidget;
+ QPointer<Widget> test_box;
+ QPointer<QLabel> test_label;
+ QLineEdit *test_edit;
+};
+
+// Testing get/set functions
+void tst_QLabel::getSetCheck()
+{
+ QLabel obj1;
+ // bool QLabel::wordWrap()
+ // void QLabel::setWordWrap(bool)
+ obj1.setWordWrap(false);
+ QCOMPARE(false, obj1.wordWrap());
+ obj1.setWordWrap(true);
+ QCOMPARE(true, obj1.wordWrap());
+
+ // QWidget * QLabel::buddy()
+ // void QLabel::setBuddy(QWidget *)
+ QWidget *var2 = new QWidget();
+ obj1.setBuddy(var2);
+ QCOMPARE(var2, obj1.buddy());
+ obj1.setBuddy((QWidget *)0);
+ QCOMPARE((QWidget *)0, obj1.buddy());
+ delete var2;
+
+ // QMovie * QLabel::movie()
+ // void QLabel::setMovie(QMovie *)
+ QMovie *var3 = new QMovie;
+ obj1.setMovie(var3);
+ QCOMPARE(var3, obj1.movie());
+ obj1.setMovie((QMovie *)0);
+ QCOMPARE((QMovie *)0, obj1.movie());
+ delete var3;
+}
+
+
+tst_QLabel::tst_QLabel(): test_box(0)
+{
+}
+
+tst_QLabel::~tst_QLabel()
+{
+}
+
+void tst_QLabel::initTestCase()
+{
+ // Create the test class
+ testWidget = new QLabel(0);
+ testWidget->resize( 200, 200 );
+ testWidget->show();
+}
+
+void tst_QLabel::cleanupTestCase()
+{
+ delete testWidget;
+ testWidget = 0;
+ if (test_box)
+ delete test_box;
+}
+
+void tst_QLabel::init()
+{
+ testWidget->setTextFormat( Qt::AutoText );
+ testWidget->setBuddy( 0 );
+ testWidget->setIndent( 0 );
+ testWidget->setAlignment( Qt::AlignLeft | Qt::AlignVCenter );
+ testWidget->setScaledContents( FALSE );
+}
+
+void tst_QLabel::cleanup()
+{
+ if (QTest::currentTestFunction() == QLatin1String("setBuddy")) {
+ testWidget->show();
+
+ delete test_box; // this should delete tst_labl and test_edit as well.
+ }
+}
+
+// Set buddy doesn't make much sense on Mac OS X.
+#ifndef Q_WS_MAC
+void tst_QLabel::setBuddy()
+{
+ testWidget->hide();
+
+ test_box = new Widget;
+ test_label= new QLabel( test_box );
+ test_label->setText( "&Test with a buddy" );
+ test_edit = new QLineEdit( test_box );
+ QVBoxLayout *layout = new QVBoxLayout(test_box);
+ layout->addWidget(test_label);
+ layout->addWidget(test_edit);
+ test_box->show();
+ qApp->setActiveWindow(test_box);
+ QVERIFY(test_box->isActiveWindow());
+
+ test_label->setBuddy( test_edit );
+ test_label->setFocus();
+ QVERIFY( !test_edit->hasFocus() );
+ QTest::keyClick( test_box, 't', Qt::AltModifier );
+ QVERIFY( test_edit->hasFocus() );
+ delete test_box;
+}
+#endif
+
+void tst_QLabel::setText_data()
+{
+ QTest::addColumn<QString>("txt");
+ QTest::addColumn<QString>("font");
+
+ QString prefix = "";
+#ifdef Q_OS_WIN32
+ prefix = "win32_";
+#endif
+
+ QTest::newRow( QString(prefix + "data0").toLatin1() ) << QString("This is a single line") << QString("Helvetica");
+ QTest::newRow( QString(prefix + "data1").toLatin1() ) << QString("This is the first line\nThis is the second line") << QString("Courier");
+ QTest::newRow( QString(prefix + "data2").toLatin1() ) << QString("This is the first line\nThis is the second line\nThis is the third line") << QString("Helvetica");
+ QTest::newRow( QString(prefix + "data3").toLatin1() ) << QString("This is <b>bold</b> richtext") << QString("Courier");
+ QTest::newRow( QString(prefix + "data4").toLatin1() ) << QString("I Have a &shortcut") << QString("Helvetica");
+}
+
+void tst_QLabel::setText()
+{
+ QFETCH( QString, txt );
+ QFETCH( QString, font );
+ QFont f( font, 8 );
+ testWidget->setFont( f );
+ testWidget->setText( txt );
+ QCOMPARE( testWidget->text(), txt );
+}
+
+void tst_QLabel::setTextFormat()
+{
+ // lets' start with the simple stuff...
+ testWidget->setTextFormat( Qt::PlainText );
+ QVERIFY( testWidget->textFormat() == Qt::PlainText );
+
+ testWidget->setTextFormat( Qt::RichText );
+ QVERIFY( testWidget->textFormat() == Qt::RichText );
+
+ testWidget->setTextFormat( Qt::LogText );
+ QVERIFY( testWidget->textFormat() == Qt::LogText );
+
+ testWidget->setTextFormat( Qt::AutoText );
+ QVERIFY( testWidget->textFormat() == Qt::AutoText );
+}
+
+void tst_QLabel::setNum()
+{
+ testWidget->setText( "This is a text" );
+ testWidget->setNum( 12 );
+ QCOMPARE( testWidget->text(), QString("12") );
+ testWidget->setNum( 12.345 );
+ QCOMPARE( testWidget->text(), QString("12.345") );
+}
+
+void tst_QLabel::clear()
+{
+ const QString TEXT = "blah blah";
+ testWidget->setText(TEXT);
+ QCOMPARE(testWidget->text(), TEXT);
+ testWidget->clear();
+ QVERIFY(testWidget->text().isEmpty());
+}
+
+void tst_QLabel::wordWrap()
+{
+ QLabel label;
+
+ QVERIFY(!label.wordWrap());
+
+ label.setText("Plain Text");
+ QVERIFY(!label.wordWrap());
+
+ label.setText("<b>rich text</b>");
+ QVERIFY(!label.wordWrap());
+
+ label.setWordWrap(false);
+ label.setText("<b>rich text</b>");
+ QVERIFY(!label.wordWrap());
+}
+
+void tst_QLabel::eventPropagation_data()
+{
+ QTest::addColumn<QString>("text");
+ QTest::addColumn<int>("textInteractionFlags");
+ QTest::addColumn<int>("focusPolicy");
+ QTest::addColumn<bool>("propagation");
+
+ QTest::newRow("plain text1") << QString("plain text") << int(Qt::LinksAccessibleByMouse) << int(Qt::NoFocus) << true;
+ QTest::newRow("plain text2") << QString("plain text") << (int)Qt::TextSelectableByKeyboard << (int)Qt::ClickFocus << true;
+ QTest::newRow("plain text3") << QString("plain text") << (int)Qt::TextSelectableByMouse << (int)Qt::ClickFocus << false;
+ QTest::newRow("plain text4") << QString("plain text") << (int)Qt::NoTextInteraction << (int)Qt::NoFocus << true;
+ QTest::newRow("rich text1") << QString("<b>rich text</b>") << (int)Qt::LinksAccessibleByMouse << (int)Qt::NoFocus << true;
+ QTest::newRow("rich text2") << QString("<b>rich text</b>") << (int)Qt::TextSelectableByKeyboard << (int)Qt::ClickFocus << true;
+ QTest::newRow("rich text3") << QString("<b>rich text</b>") << (int)Qt::TextSelectableByMouse << (int)Qt::ClickFocus << false;
+ QTest::newRow("rich text4") << QString("<b>rich text</b>") << (int)Qt::NoTextInteraction << (int)Qt::NoFocus << true;
+ QTest::newRow("rich text4") << QString("<b>rich text</b>") << (int)Qt::LinksAccessibleByKeyboard << (int)Qt::StrongFocus << true;
+
+ if (!test_box)
+ test_box = new Widget;
+ if (!test_label)
+ test_label = new QLabel(test_box);
+}
+
+void tst_QLabel::eventPropagation()
+{
+ QFETCH(QString, text);
+ QFETCH(int, textInteractionFlags);
+ QFETCH(int, focusPolicy);
+ QFETCH(bool, propagation);
+
+ // plain text (accepts mouse event _only_ when label selectable by mouse)
+ test_label->setText(text);
+ test_box->events.clear();
+ test_label->setTextInteractionFlags(Qt::TextInteractionFlags(textInteractionFlags));
+ QVERIFY(int(test_label->focusPolicy()) == focusPolicy);
+ QTest::mousePress(test_label, Qt::LeftButton);
+ QVERIFY(test_box->events.contains(QEvent::MouseButtonPress) == propagation); // should have propagated!
+}
+
+void tst_QLabel::focusPolicy()
+{
+ delete test_label;
+ test_label = new QLabel;
+ QCOMPARE(test_label->focusPolicy(), Qt::NoFocus); // default
+ test_label->setFocusPolicy(Qt::StrongFocus);
+ test_label->setText("Whatever"); // setting text should not change the focus policy
+ QCOMPARE(test_label->focusPolicy(), Qt::StrongFocus);
+ test_label->setTextInteractionFlags(Qt::TextSelectableByKeyboard); // this should
+ QCOMPARE(test_label->focusPolicy(), Qt::ClickFocus);
+ test_label->setFocusPolicy(Qt::StrongFocus);
+ test_label->setText("Whatever"); // setting text should not change the focus policy
+ QCOMPARE(test_label->focusPolicy(), Qt::StrongFocus);
+ test_label->setTextInteractionFlags(Qt::NoTextInteraction);
+ QCOMPARE(test_label->focusPolicy(), Qt::NoFocus);
+ test_label->setFocusPolicy(Qt::StrongFocus);
+ test_label->setTextInteractionFlags(Qt::NoTextInteraction);
+ QCOMPARE(test_label->focusPolicy(), Qt::StrongFocus); // is not touched since value didn't change
+ delete test_label;
+}
+
+void tst_QLabel::task190318_sizes()
+{
+ QLabel label(" ");
+ QSize ms(500,600);
+ label.setMinimumSize(ms);
+ QCOMPARE(label.minimumSize(), ms);
+ QCOMPARE(label.sizeHint(), ms);
+ QCOMPARE(label.minimumSizeHint(), ms);
+}
+
+void tst_QLabel::sizeHint()
+{
+ QLabel label(QLatin1String("Test"));
+ label.setIndent(0);
+ label.setMargin(0);
+ label.setContentsMargins(0, 0, 0, 0);
+ label.setAlignment(Qt::AlignVCenter);
+ int h = label.sizeHint().height();
+
+ QLabel l1(QLatin1String("Test"));
+ l1.setIndent(0);
+ l1.setMargin(0);
+ l1.setContentsMargins(0, 0, 0, 0);
+ l1.setAlignment(Qt::AlignVCenter);
+ l1.setTextInteractionFlags(Qt::TextSelectableByMouse); // will now use qtextcontrol
+ int h1 = l1.sizeHint().height();
+ QCOMPARE(h1, h);
+
+}
+
+void tst_QLabel::task226479_movieResize()
+{
+ class Label : public QLabel {
+ protected:
+ void paintEvent(QPaintEvent *e)
+ {
+ paintedRegion += e->region();
+ QLabel::paintEvent(e);
+ }
+
+ public:
+ QRegion paintedRegion;
+ };
+
+ Label label;
+ label.resize(350,350);
+ label.show();
+ QMovie *movie = new QMovie( &label );
+ label.setMovie(movie);
+ QTest::qWaitForWindowShown(&label);
+ movie->setFileName(SRCDIR "red.png");
+ movie->start();
+ QTest::qWait(50);
+ movie->stop();
+ label.paintedRegion = QRegion();
+ movie->setFileName(SRCDIR "green.png");
+ movie->start();
+ QTest::qWait(50);
+
+ QTRY_COMPARE(label.paintedRegion , QRegion(label.rect()) );
+}
+
+void tst_QLabel::emptyPixmap()
+{
+ //task 197919
+ QLabel label1, label2, label3, label4;
+ label2.setPixmap(QPixmap("/tmp/idonotexist"));
+ QMovie movie;
+ label3.setMovie(&movie);
+ label4.setPicture(QPicture());
+ QCOMPARE(label1.sizeHint(), label2.sizeHint());
+ QCOMPARE(label1.sizeHint(), label3.sizeHint());
+ QCOMPARE(label1.sizeHint(), label4.sizeHint());
+}
+
+/**
+ Test for QTBUG-4848 - unicode data corrupting QLabel display
+*/
+void tst_QLabel::unicodeText_data()
+{
+ QTest::addColumn<QString>("text");
+ QTest::addColumn<QString>("languageName");
+
+ /*
+ The "glass" phrase in Thai was the initial report for bug QTBUG-4848, was
+ originally found on http://www.columbia.edu/kermit/utf8.html.
+
+ The phrase is from an internet tradition regarding a striking phrase
+ that is translated into many different languages. The utf8 strings
+ below were generated by using http://translate.google.com.
+
+ The glass phrase in Thai contains the ้ว character which manifests bug
+ QTBUG-4848
+
+ The last long phrase is an excerpt from Churchills "on the beaches"
+ speech, also translated using http://translate.google.com.
+ */
+
+ QTest::newRow("english") << QString::fromUtf8("I can eat glass and it doesn't hurt me.") << QString("english");
+ QTest::newRow("thai") << QString::fromUtf8("ฉันจะกินแก้วและไม่เจ็บฉัน") << QString("thai");
+ QTest::newRow("chinese") << QString::fromUtf8("我可以吃玻璃,并没有伤害我。") << QString("chinese");
+ QTest::newRow("arabic") << QString::fromUtf8("أستطيع أكل الزجاج ، وأنه لا يؤذيني.") << QString("arabic");
+ QTest::newRow("russian") << QString::fromUtf8("Я могу есть стекло, и не больно.") << QString("russian");
+ QTest::newRow("korean") << QString::fromUtf8("유리를 먹을 수있는, 그리고 그게 날 다치게하지 않습니다.") << QString("korean");
+ QTest::newRow("greek") << QString::fromUtf8("Μπορώ να φάτε γυαλί και δεν μου κάνει κακό.") << QString("greek");
+ QTest::newRow("german") << QString::fromUtf8("Ich kann Glas essen und es macht mich nicht heiß.") << QString("german");
+
+ QTest::newRow("thai_long") << QString::fromUtf8("เราจะต่อสู้ในทะเลและมหาสมุทร. เราจะต่อสู้ด้วยความมั่นใจเติบโตและความเจริญเติบโตในอากาศเราจะปกป้องเกาะของเราค่าใช้จ่ายใดๆอาจ."
+ "เราจะต่อสู้บนชายหาดเราจะต่อสู้ในบริเวณเชื่อมโยงไปถึงเราจะต่อสู้ในช่องและในถนนที่เราจะต่อสู้ในภูเขานั้นเราจะไม่ยอม.")
+ << QString("thai_long");
+}
+
+void tst_QLabel::unicodeText()
+{
+ const QString testDataPath("testdata/unicodeText");
+ QFETCH(QString, text);
+ QFETCH(QString, languageName);
+ QFrame frame;
+ QVBoxLayout *layout = new QVBoxLayout();
+ QLabel *label = new QLabel(text, &frame);
+ layout->addWidget(label);
+ layout->setMargin(8);
+ frame.setLayout(layout);
+ frame.show();
+ QTest::qWaitForWindowShown(&frame);
+ QVERIFY(frame.isVisible()); // was successfully sized and shown
+ testWidget->show();
+}
+
+void tst_QLabel::mnemonic_data()
+{
+ QTest::addColumn<QString>("text");
+ QTest::addColumn<QString>("expectedDocText");
+ QTest::addColumn<QString>("expectedShortcutCursor");
+
+ QTest::newRow("1") << QString("Normal") << QString("Normal") << QString();
+ QTest::newRow("2") << QString("&Simple") << QString("Simple") << QString("S");
+ QTest::newRow("3") << QString("Also &simple") << QString("Also simple") << QString("s");
+ QTest::newRow("4") << QString("&&With &Double &&amp;") << QString("&With Double &amp;") << QString("D");
+ QTest::newRow("5") << QString("Hep&&Hop") << QString("Hep&Hop") << QString("");
+ QTest::newRow("6") << QString("Hep&&&Hop") << QString("Hep&Hop") << QString("H");
+}
+
+
+void tst_QLabel::mnemonic()
+{
+ // this test that the mnemonics appears correctly when the label has a text control.
+
+ QFETCH(QString, text);
+ QFETCH(QString, expectedDocText);
+ QFETCH(QString, expectedShortcutCursor);
+
+ QWidget w;
+ QHBoxLayout *hbox = new QHBoxLayout;
+ QLabel *lab = new QLabel(text);
+ //lab->setText("plop &plop");
+ QLineEdit *lineedit = new QLineEdit;
+ lab->setBuddy(lineedit);
+ lab->setTextInteractionFlags(Qt::TextSelectableByMouse);
+
+ hbox->addWidget(lab);
+ hbox->addWidget(lineedit);
+ hbox->addWidget(new QLineEdit);
+ w.setLayout(hbox);
+ w.show();
+ QTest::qWaitForWindowShown(&w);
+
+ QLabelPrivate *d = static_cast<QLabelPrivate *>(QObjectPrivate::get(lab));
+ QVERIFY(d->control);
+ QCOMPARE(d->control->document()->toPlainText(), expectedDocText);
+ QCOMPARE(d->shortcutCursor.selectedText(), expectedShortcutCursor);
+}
+
+void tst_QLabel::selection()
+{
+ QLabel label;
+ label.setText("Hello world");
+
+ label.setTextInteractionFlags(Qt::TextSelectableByMouse);
+
+ QVERIFY(!label.hasSelectedText());
+ QCOMPARE(label.selectedText(), QString());
+ QCOMPARE(label.selectionStart(), -1);
+
+ label.setSelection(0, 4);
+ QVERIFY(label.hasSelectedText());
+ QCOMPARE(label.selectedText(), QString::fromLatin1("Hell"));
+ QCOMPARE(label.selectionStart(), 0);
+
+ label.setSelection(6, 5);
+ QVERIFY(label.hasSelectedText());
+ QCOMPARE(label.selectedText(), QString::fromLatin1("world"));
+ QCOMPARE(label.selectionStart(), 6);
+}
+
+#ifndef QT_NO_CONTEXTMENU
+void tst_QLabel::taskQTBUG_7902_contextMenuCrash()
+{
+ QLabel *w = new QLabel("Test or crash?");
+ w->setTextInteractionFlags(Qt::TextSelectableByMouse);
+ w->show();
+ QTest::qWaitForWindowShown(w);
+
+ QTimer ti;
+ w->connect(&ti, SIGNAL(timeout()), w, SLOT(deleteLater()));
+ ti.start(300);
+
+ QContextMenuEvent *cme = new QContextMenuEvent(QContextMenuEvent::Mouse, w->rect().center());
+ qApp->postEvent(w, cme);
+
+ QTest::qWait(350);
+ // No crash, it's allright.
+}
+#endif
+
+QTEST_MAIN(tst_QLabel)
+#include "tst_qlabel.moc"
diff --git a/tests/auto/widgets/widgets/qlcdnumber/.gitignore b/tests/auto/widgets/widgets/qlcdnumber/.gitignore
new file mode 100644
index 0000000000..cbf08a078d
--- /dev/null
+++ b/tests/auto/widgets/widgets/qlcdnumber/.gitignore
@@ -0,0 +1 @@
+tst_qlcdnumber
diff --git a/tests/auto/widgets/widgets/qlcdnumber/qlcdnumber.pro b/tests/auto/widgets/widgets/qlcdnumber/qlcdnumber.pro
new file mode 100644
index 0000000000..cd909de5be
--- /dev/null
+++ b/tests/auto/widgets/widgets/qlcdnumber/qlcdnumber.pro
@@ -0,0 +1,9 @@
+############################################################
+# Project file for autotest for file qlcdnumber.h
+############################################################
+
+load(qttest_p4)
+QT += widgets
+SOURCES += tst_qlcdnumber.cpp
+
+
diff --git a/tests/auto/widgets/widgets/qlcdnumber/tst_qlcdnumber.cpp b/tests/auto/widgets/widgets/qlcdnumber/tst_qlcdnumber.cpp
new file mode 100644
index 0000000000..0976f3f619
--- /dev/null
+++ b/tests/auto/widgets/widgets/qlcdnumber/tst_qlcdnumber.cpp
@@ -0,0 +1,88 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#include <QtTest/QtTest>
+
+#include <qcoreapplication.h>
+#include <qdebug.h>
+#include <qlcdnumber.h>
+
+
+//TESTED_CLASS=
+//TESTED_FILES=
+
+class tst_QLCDNumber : public QObject
+{
+Q_OBJECT
+
+public:
+ tst_QLCDNumber();
+ virtual ~tst_QLCDNumber();
+
+private slots:
+ void getSetCheck();
+};
+
+tst_QLCDNumber::tst_QLCDNumber()
+{
+}
+
+tst_QLCDNumber::~tst_QLCDNumber()
+{
+}
+
+// Testing get/set functions
+void tst_QLCDNumber::getSetCheck()
+{
+ QLCDNumber obj1;
+ // int QLCDNumber::digitCount()
+ // void QLCDNumber::setDigitCount(int)
+ obj1.setDigitCount(0);
+ QCOMPARE(0, obj1.digitCount());
+ obj1.setDigitCount(INT_MIN);
+ QCOMPARE(0, obj1.digitCount()); // Range<0, 99>
+ obj1.setDigitCount(INT_MAX);
+ QCOMPARE(99, obj1.digitCount()); // Range<0, 99>
+}
+
+QTEST_MAIN(tst_QLCDNumber)
+#include "tst_qlcdnumber.moc"
diff --git a/tests/auto/widgets/widgets/qlineedit/.gitignore b/tests/auto/widgets/widgets/qlineedit/.gitignore
new file mode 100644
index 0000000000..7fcade47c9
--- /dev/null
+++ b/tests/auto/widgets/widgets/qlineedit/.gitignore
@@ -0,0 +1 @@
+tst_qlineedit
diff --git a/tests/auto/widgets/widgets/qlineedit/qlineedit.pro b/tests/auto/widgets/widgets/qlineedit/qlineedit.pro
new file mode 100644
index 0000000000..077b7c919e
--- /dev/null
+++ b/tests/auto/widgets/widgets/qlineedit/qlineedit.pro
@@ -0,0 +1,5 @@
+load(qttest_p4)
+QT += widgets
+SOURCES += tst_qlineedit.cpp
+
+CONFIG += insignificant_test # QTBUG-21402
diff --git a/tests/auto/widgets/widgets/qlineedit/testdata/frame/noFrame_Motif-32x96x96_win.png b/tests/auto/widgets/widgets/qlineedit/testdata/frame/noFrame_Motif-32x96x96_win.png
new file mode 100644
index 0000000000..81a3e3de4d
--- /dev/null
+++ b/tests/auto/widgets/widgets/qlineedit/testdata/frame/noFrame_Motif-32x96x96_win.png
Binary files differ
diff --git a/tests/auto/widgets/widgets/qlineedit/testdata/frame/noFrame_Windows-32x96x96_win.png b/tests/auto/widgets/widgets/qlineedit/testdata/frame/noFrame_Windows-32x96x96_win.png
new file mode 100644
index 0000000000..81a3e3de4d
--- /dev/null
+++ b/tests/auto/widgets/widgets/qlineedit/testdata/frame/noFrame_Windows-32x96x96_win.png
Binary files differ
diff --git a/tests/auto/widgets/widgets/qlineedit/testdata/frame/useFrame_Motif-32x96x96_win.png b/tests/auto/widgets/widgets/qlineedit/testdata/frame/useFrame_Motif-32x96x96_win.png
new file mode 100644
index 0000000000..ed3810c2e7
--- /dev/null
+++ b/tests/auto/widgets/widgets/qlineedit/testdata/frame/useFrame_Motif-32x96x96_win.png
Binary files differ
diff --git a/tests/auto/widgets/widgets/qlineedit/testdata/frame/useFrame_Windows-32x96x96_win.png b/tests/auto/widgets/widgets/qlineedit/testdata/frame/useFrame_Windows-32x96x96_win.png
new file mode 100644
index 0000000000..fe4456ffbf
--- /dev/null
+++ b/tests/auto/widgets/widgets/qlineedit/testdata/frame/useFrame_Windows-32x96x96_win.png
Binary files differ
diff --git a/tests/auto/widgets/widgets/qlineedit/testdata/setAlignment/auto_Motif-32x96x96_win.png b/tests/auto/widgets/widgets/qlineedit/testdata/setAlignment/auto_Motif-32x96x96_win.png
new file mode 100644
index 0000000000..7ab7ffd4da
--- /dev/null
+++ b/tests/auto/widgets/widgets/qlineedit/testdata/setAlignment/auto_Motif-32x96x96_win.png
Binary files differ
diff --git a/tests/auto/widgets/widgets/qlineedit/testdata/setAlignment/auto_Windows-32x96x96_win.png b/tests/auto/widgets/widgets/qlineedit/testdata/setAlignment/auto_Windows-32x96x96_win.png
new file mode 100644
index 0000000000..5918bb93f1
--- /dev/null
+++ b/tests/auto/widgets/widgets/qlineedit/testdata/setAlignment/auto_Windows-32x96x96_win.png
Binary files differ
diff --git a/tests/auto/widgets/widgets/qlineedit/testdata/setAlignment/hcenter_Motif-32x96x96_win.png b/tests/auto/widgets/widgets/qlineedit/testdata/setAlignment/hcenter_Motif-32x96x96_win.png
new file mode 100644
index 0000000000..66119386a3
--- /dev/null
+++ b/tests/auto/widgets/widgets/qlineedit/testdata/setAlignment/hcenter_Motif-32x96x96_win.png
Binary files differ
diff --git a/tests/auto/widgets/widgets/qlineedit/testdata/setAlignment/hcenter_Windows-32x96x96_win.png b/tests/auto/widgets/widgets/qlineedit/testdata/setAlignment/hcenter_Windows-32x96x96_win.png
new file mode 100644
index 0000000000..89e81db837
--- /dev/null
+++ b/tests/auto/widgets/widgets/qlineedit/testdata/setAlignment/hcenter_Windows-32x96x96_win.png
Binary files differ
diff --git a/tests/auto/widgets/widgets/qlineedit/testdata/setAlignment/left_Motif-32x96x96_win.png b/tests/auto/widgets/widgets/qlineedit/testdata/setAlignment/left_Motif-32x96x96_win.png
new file mode 100644
index 0000000000..2cf5c7a9cf
--- /dev/null
+++ b/tests/auto/widgets/widgets/qlineedit/testdata/setAlignment/left_Motif-32x96x96_win.png
Binary files differ
diff --git a/tests/auto/widgets/widgets/qlineedit/testdata/setAlignment/left_Windows-32x96x96_win.png b/tests/auto/widgets/widgets/qlineedit/testdata/setAlignment/left_Windows-32x96x96_win.png
new file mode 100644
index 0000000000..70ec6530b8
--- /dev/null
+++ b/tests/auto/widgets/widgets/qlineedit/testdata/setAlignment/left_Windows-32x96x96_win.png
Binary files differ
diff --git a/tests/auto/widgets/widgets/qlineedit/testdata/setAlignment/right_Motif-32x96x96_win.png b/tests/auto/widgets/widgets/qlineedit/testdata/setAlignment/right_Motif-32x96x96_win.png
new file mode 100644
index 0000000000..d6708bcd12
--- /dev/null
+++ b/tests/auto/widgets/widgets/qlineedit/testdata/setAlignment/right_Motif-32x96x96_win.png
Binary files differ
diff --git a/tests/auto/widgets/widgets/qlineedit/testdata/setAlignment/right_Windows-32x96x96_win.png b/tests/auto/widgets/widgets/qlineedit/testdata/setAlignment/right_Windows-32x96x96_win.png
new file mode 100644
index 0000000000..9000dfc4cf
--- /dev/null
+++ b/tests/auto/widgets/widgets/qlineedit/testdata/setAlignment/right_Windows-32x96x96_win.png
Binary files differ
diff --git a/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp b/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp
new file mode 100644
index 0000000000..6e4726e5b5
--- /dev/null
+++ b/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp
@@ -0,0 +1,3835 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#include <QtTest/QtTest>
+#include "qlineedit.h"
+#include "qapplication.h"
+#include "qstringlist.h"
+#include "qstyle.h"
+#include "qvalidator.h"
+#include "qcompleter.h"
+#include "qstandarditemmodel.h"
+
+#ifndef QT_NO_CLIPBOARD
+#include "qclipboard.h"
+#endif
+
+#ifdef Q_WS_MAC
+#include <Carbon/Carbon.h> // For the random function.
+#include <cstdlib> // For the random function.
+#endif
+
+#include <qlineedit.h>
+#include <qmenu.h>
+#include <qlayout.h>
+#include <qspinbox.h>
+#include <qdebug.h>
+
+//TESTED_CLASS=
+//TESTED_FILES=
+
+#include "qcommonstyle.h"
+#include "qstyleoption.h"
+
+#include "qplatformdefs.h"
+
+QT_BEGIN_NAMESPACE
+class QPainter;
+QT_END_NAMESPACE
+
+class StyleOptionTestStyle : public QCommonStyle
+{
+private:
+ bool readOnly;
+
+public:
+ inline StyleOptionTestStyle() : QCommonStyle(), readOnly(false)
+ {
+ }
+
+ inline void setReadOnly(bool readOnly)
+ {
+ this->readOnly = readOnly;
+ }
+
+ inline void drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPainter *,
+ const QWidget *) const
+ {
+ switch (pe) {
+ case PE_PanelLineEdit:
+ if (readOnly)
+ QVERIFY(opt->state & QStyle::State_ReadOnly);
+ else
+ QVERIFY(!(opt->state & QStyle::State_ReadOnly));
+ break;
+
+ default:
+ break;
+ }
+ }
+};
+
+class tst_QLineEdit : public QObject
+{
+Q_OBJECT
+
+public:
+ enum EventStates { Press, Release, Click };
+
+ tst_QLineEdit();
+ virtual ~tst_QLineEdit();
+
+public slots:
+ void initTestCase();
+ void cleanupTestCase();
+ void init();
+ void cleanup();
+private slots:
+ void getSetCheck();
+ void experimental();
+
+ void upperAndLowercase();
+
+ void setInputMask_data();
+ void setInputMask();
+
+ void inputMask_data();
+ void inputMask();
+
+ void clearInputMask();
+
+ void keypress_inputMask_data();
+ void keypress_inputMask();
+
+ void inputMaskAndValidator_data();
+ void inputMaskAndValidator();
+
+ void hasAcceptableInputMask_data();
+ void hasAcceptableInputMask();
+
+ void hasAcceptableInputValidator();
+
+
+ void redo_data();
+ void redo();
+
+ void undo_data();
+ void undo();
+
+ void undo_keypressevents_data();
+ void undo_keypressevents();
+
+#ifndef QT_NO_CLIPBOARD
+ void QTBUG5786_undoPaste();
+#endif
+
+ void clear();
+
+ void text_data();
+ void text();
+ void textMask_data();
+ void textMask();
+ void maskCharacter();
+ void maskCharacter_data();
+ void setText();
+
+ void displayText_data();
+ void displayText();
+ void passwordEchoOnEdit();
+
+#ifdef QT_GUI_PASSWORD_ECHO_DELAY
+ void passwordEchoDelay();
+#endif
+
+ void maxLength_mask_data();
+ void maxLength_mask();
+
+ void maxLength_data();
+ void maxLength();
+
+ void isReadOnly();
+
+ void cursorPosition();
+
+ void cursorPositionChanged_data();
+ void cursorPositionChanged();
+
+ void selectedText();
+ void deleteSelectedText();
+
+ void textChangedAndTextEdited();
+ void returnPressed();
+ void returnPressed_maskvalidator_data();
+ void returnPressed_maskvalidator();
+
+ void setValidator();
+ void setValidator_QIntValidator_data();
+ void setValidator_QIntValidator();
+
+ void frame_data();
+ void frame();
+
+ void leftKeyOnSelectedText();
+
+ void setAlignment_data();
+ void setAlignment();
+
+ void isModified();
+ void edited();
+
+ void insert();
+ void setSelection_data();
+ void setSelection();
+
+#ifndef QT_NO_CLIPBOARD
+ void cut();
+#endif
+ void maxLengthAndInputMask();
+ void returnPressedKeyEvent();
+
+ void keepSelectionOnTabFocusIn();
+
+ void readOnlyStyleOption();
+
+ void validateOnFocusOut();
+
+ void editInvalidText();
+
+ void charWithAltOrCtrlModifier();
+
+ void inlineCompletion();
+
+ void noTextEditedOnClear();
+
+#ifndef QT_NO_CURSOR
+ void cursor();
+#endif
+
+ void textMargin_data();
+ void textMargin();
+
+ // task-specific tests:
+ void task180999_focus();
+ void task174640_editingFinished();
+#ifndef QT_NO_COMPLETER
+ void task198789_currentCompletion();
+ void task210502_caseInsensitiveInlineCompletion();
+#endif
+ void task229938_dontEmitChangedWhenTextIsNotChanged();
+ void task233101_cursorPosAfterInputMethod_data();
+ void task233101_cursorPosAfterInputMethod();
+ void task241436_passwordEchoOnEditRestoreEchoMode();
+ void task248948_redoRemovedSelection();
+ void taskQTBUG_4401_enterKeyClearsPassword();
+ void taskQTBUG_4679_moveToStartEndOfBlock();
+ void taskQTBUG_4679_selectToStartEndOfBlock();
+#ifndef QT_NO_CONTEXTMENU
+ void taskQTBUG_7902_contextMenuCrash();
+#endif
+ void taskQTBUG_7395_readOnlyShortcut();
+#ifdef Q_WS_X11
+ void QTBUG697_paletteCurrentColorGroup();
+#endif
+ void QTBUG13520_textNotVisible();
+
+ void bidiVisualMovement_data();
+ void bidiVisualMovement();
+
+ void bidiLogicalMovement_data();
+ void bidiLogicalMovement();
+
+ void selectAndCursorPosition();
+ void inputMethodSelection();
+
+protected slots:
+ void editingFinished();
+
+ void onTextChanged( const QString &newString );
+ void onTextEdited( const QString &newString );
+ void onReturnPressed();
+ void onSelectionChanged();
+ void onCursorPositionChanged(int oldpos, int newpos);
+
+private:
+ // keyClicks(..) is moved to QtTestCase
+ void psKeyClick(QWidget *target, Qt::Key key, Qt::KeyboardModifiers pressState = 0);
+ void psKeyClick(QTestEventList &keys, Qt::Key key, Qt::KeyboardModifiers pressState = 0);
+
+ bool validInput;
+ QString changed_string;
+ int changed_count;
+ int edited_count;
+ int return_count;
+ int selection_count;
+ int lastCursorPos;
+ int newCursorPos;
+ QLineEdit *testWidget;
+};
+
+typedef QList<int> IntList;
+Q_DECLARE_METATYPE(IntList)
+Q_DECLARE_METATYPE(QLineEdit::EchoMode)
+
+// Testing get/set functions
+void tst_QLineEdit::getSetCheck()
+{
+ QLineEdit obj1;
+ // const QValidator * QLineEdit::validator()
+ // void QLineEdit::setValidator(const QValidator *)
+ QIntValidator *var1 = new QIntValidator(0);
+ obj1.setValidator(var1);
+ QCOMPARE((const QValidator *)var1, obj1.validator());
+ obj1.setValidator((QValidator *)0);
+ QCOMPARE((const QValidator *)0, obj1.validator());
+ delete var1;
+
+ // bool QLineEdit::dragEnabled()
+ // void QLineEdit::setDragEnabled(bool)
+ obj1.setDragEnabled(false);
+ QCOMPARE(false, obj1.dragEnabled());
+ obj1.setDragEnabled(true);
+ QCOMPARE(true, obj1.dragEnabled());
+}
+
+tst_QLineEdit::tst_QLineEdit()
+{
+ validInput = false;
+}
+
+tst_QLineEdit::~tst_QLineEdit()
+{
+}
+
+void tst_QLineEdit::initTestCase()
+{
+ testWidget = new QLineEdit(0);
+ testWidget->setObjectName("testWidget");
+ connect(testWidget, SIGNAL(cursorPositionChanged(int, int)), this, SLOT(onCursorPositionChanged(int, int)));
+ connect(testWidget, SIGNAL(textChanged(const QString&)), this, SLOT(onTextChanged(const QString&)));
+ connect(testWidget, SIGNAL(textEdited(const QString&)), this, SLOT(onTextEdited(const QString&)));
+ connect(testWidget, SIGNAL(returnPressed()), this, SLOT(onReturnPressed()));
+ connect(testWidget, SIGNAL(selectionChanged()), this, SLOT(onSelectionChanged()));
+ connect(testWidget, SIGNAL(editingFinished()), this, SLOT(editingFinished()));
+
+ testWidget->resize(200,50);
+ testWidget->show();
+ QApplication::setActiveWindow(testWidget);
+#ifdef Q_WS_X11
+ // to be safe and avoid failing setFocus with window managers
+ qt_x11_wait_for_window_manager(testWidget);
+#endif
+ QTRY_VERIFY(testWidget->hasFocus());
+
+ changed_count = 0;
+ edited_count = 0;
+ selection_count = 0;
+}
+
+void tst_QLineEdit::cleanupTestCase()
+{
+ delete testWidget;
+}
+
+void tst_QLineEdit::init()
+{
+ return_count = 0;
+ testWidget->clear();
+ testWidget->setEchoMode(QLineEdit::Normal);
+ testWidget->setMaxLength(32767);
+ testWidget->setReadOnly(false);
+ testWidget->setText("");
+ testWidget->setInputMask("");
+ testWidget->setFrame(true);
+ testWidget->setValidator(0);
+ testWidget->setDragEnabled(true);
+}
+
+void tst_QLineEdit::cleanup()
+{
+}
+
+void tst_QLineEdit::experimental()
+{
+ QIntValidator intValidator(3, 7, 0);
+ testWidget->setValidator(&intValidator);
+ testWidget->setText("");
+
+
+ // test the order of setting these
+ testWidget->setInputMask("");
+ testWidget->setText("abc123");
+ testWidget->setInputMask("000.000.000.000");
+ QCOMPARE(testWidget->text(), QString("123..."));
+ testWidget->setText("");
+
+
+}
+
+void tst_QLineEdit::upperAndLowercase()
+{
+ testWidget->setInputMask("");
+ testWidget->setText("");
+
+ QTest::keyClicks(testWidget, "aAzZ`1234567890-=~!@#$%^&*()_+[]{}\\|;:'\",.<>/?");
+ qApp->processEvents();
+ QCOMPARE(testWidget->text(), QString("aAzZ`1234567890-=~!@#$%^&*()_+[]{}\\|;:'\",.<>/?"));
+}
+
+void tst_QLineEdit::setInputMask_data()
+{
+ QTest::addColumn<QString>("mask");
+ QTest::addColumn<QString>("input");
+ QTest::addColumn<QString>("expectedText");
+ QTest::addColumn<QString>("expectedDisplay");
+ QTest::addColumn<bool>("insert_text");
+
+ // both keyboard and insert()
+ for (int i=0; i<2; i++) {
+ bool insert_text = i==0 ? false : true;
+ QString insert_mode = "keys ";
+ if (insert_text)
+ insert_mode = "insert ";
+
+ QTest::newRow(QString(insert_mode + "ip_localhost").toLatin1())
+ << QString("000.000.000.000")
+ << QString("127.0.0.1")
+ << QString("127.0.0.1")
+ << QString("127.0 .0 .1 ")
+ << bool(insert_text);
+ QTest::newRow(QString(insert_mode + "mac").toLatin1())
+ << QString("HH:HH:HH:HH:HH:HH;#")
+ << QString("00:E0:81:21:9E:8E")
+ << QString("00:E0:81:21:9E:8E")
+ << QString("00:E0:81:21:9E:8E")
+ << bool(insert_text);
+ QTest::newRow(QString(insert_mode + "mac2").toLatin1())
+ << QString("<HH:>HH:!HH:HH:HH:HH;#")
+ << QString("AAe081219E8E")
+ << QString("aa:E0:81:21:9E:8E")
+ << QString("aa:E0:81:21:9E:8E")
+ << bool(insert_text);
+ QTest::newRow(QString(insert_mode + "byte").toLatin1())
+ << QString("BBBBBBBB;0")
+ << QString("11011001")
+ << QString("11111")
+ << QString("11011001")
+ << bool(insert_text);
+ QTest::newRow(QString(insert_mode + "halfbytes").toLatin1())
+ << QString("bbbb.bbbb;-")
+ << QString("110. 0001")
+ << QString("110.0001")
+ << QString("110-.0001")
+ << bool(insert_text);
+ QTest::newRow(QString(insert_mode + "blank char same type as content").toLatin1())
+ << QString("000.000.000.000;0")
+ << QString("127.0.0.1")
+ << QString("127...1")
+ << QString("127.000.000.100")
+ << bool(insert_text);
+ QTest::newRow(QString(insert_mode + "parts of ip_localhost").toLatin1())
+ << QString("000.000.000.000")
+ << QString(".0.0.1")
+ << QString(".0.0.1")
+ << QString(" .0 .0 .1 ")
+ << bool(insert_text);
+ QTest::newRow(QString(insert_mode + "ip_null").toLatin1())
+ << QString("000.000.000.000")
+ << QString()
+ << QString("...")
+ << QString(" . . . ")
+ << bool(insert_text);
+ QTest::newRow(QString(insert_mode + "ip_null_hash").toLatin1())
+ << QString("000.000.000.000;#")
+ << QString()
+ << QString("...")
+ << QString("###.###.###.###")
+ << bool(insert_text);
+ QTest::newRow(QString(insert_mode + "ip_overflow").toLatin1())
+ << QString("000.000.000.000")
+ << QString("1234123412341234")
+ << QString("123.412.341.234")
+ << QString("123.412.341.234")
+ << bool(insert_text);
+ QTest::newRow(QString(insert_mode + "uppercase").toLatin1())
+ << QString(">AAAA")
+ << QString("AbCd")
+ << QString("ABCD")
+ << QString("ABCD")
+ << bool(insert_text);
+ QTest::newRow(QString(insert_mode + "lowercase").toLatin1())
+ << QString("<AAAA")
+ << QString("AbCd")
+ << QString("abcd")
+ << QString("abcd")
+ << bool(insert_text);
+
+ QTest::newRow(QString(insert_mode + "nocase").toLatin1())
+ << QString("!AAAA")
+ << QString("AbCd")
+ << QString("AbCd")
+ << QString("AbCd")
+ << bool(insert_text);
+ QTest::newRow(QString(insert_mode + "nocase1").toLatin1())
+ << QString("!A!A!A!A")
+ << QString("AbCd")
+ << QString("AbCd")
+ << QString("AbCd")
+ << bool(insert_text);
+ QTest::newRow(QString(insert_mode + "nocase2").toLatin1())
+ << QString("AAAA")
+ << QString("AbCd")
+ << QString("AbCd")
+ << QString("AbCd")
+ << bool(insert_text);
+
+ QTest::newRow(QString(insert_mode + "reserved").toLatin1())
+ << QString("{n}[0]")
+ << QString("A9")
+ << QString("A9")
+ << QString("A9")
+ << bool(insert_text);
+ QTest::newRow(QString(insert_mode + "escape01").toLatin1())
+ << QString("\\N\\n00")
+ << QString("9")
+ << QString("Nn9")
+ << QString("Nn9 ")
+ << bool(insert_text);
+ QTest::newRow(QString(insert_mode + "escape02").toLatin1())
+ << QString("\\\\00")
+ << QString("0")
+ << QString("\\0")
+ << QString("\\0 ")
+ << bool(insert_text);
+ QTest::newRow(QString(insert_mode + "escape03").toLatin1())
+ << QString("\\(00\\)")
+ << QString("0")
+ << QString("(0)")
+ << QString("(0 )")
+ << bool(insert_text);
+
+ QTest::newRow(QString(insert_mode + "upper_lower_nocase1").toLatin1())
+ << QString(">AAAA<AAAA!AAAA")
+ << QString("AbCdEfGhIjKl")
+ << QString("ABCDefghIjKl")
+ << QString("ABCDefghIjKl")
+ << bool(insert_text);
+ QTest::newRow(QString(insert_mode + "upper_lower_nocase2").toLatin1())
+ << QString(">aaaa<aaaa!aaaa")
+ << QString("AbCdEfGhIjKl")
+ << QString("ABCDefghIjKl")
+ << QString("ABCDefghIjKl")
+ << bool(insert_text);
+
+ QTest::newRow(QString(insert_mode + "exact_case1").toLatin1())
+ << QString(">A<A<A>A>A<A!A!A")
+ << QString("AbCdEFGH")
+ << QString("AbcDEfGH")
+ << QString("AbcDEfGH")
+ << bool(insert_text);
+ QTest::newRow(QString(insert_mode + "exact_case2").toLatin1())
+ << QString(">A<A<A>A>A<A!A!A")
+ << QString("aBcDefgh")
+ << QString("AbcDEfgh")
+ << QString("AbcDEfgh")
+ << bool(insert_text);
+ QTest::newRow(QString(insert_mode + "exact_case3").toLatin1())
+ << QString(">a<a<a>a>a<a!a!a")
+ << QString("AbCdEFGH")
+ << QString("AbcDEfGH")
+ << QString("AbcDEfGH")
+ << bool(insert_text);
+ QTest::newRow(QString(insert_mode + "exact_case4").toLatin1())
+ << QString(">a<a<a>a>a<a!a!a")
+ << QString("aBcDefgh")
+ << QString("AbcDEfgh")
+ << QString("AbcDEfgh")
+ << bool(insert_text);
+ QTest::newRow(QString(insert_mode + "exact_case5").toLatin1())
+ << QString(">H<H<H>H>H<H!H!H")
+ << QString("aBcDef01")
+ << QString("AbcDEf01")
+ << QString("AbcDEf01")
+ << bool(insert_text);
+ QTest::newRow(QString(insert_mode + "exact_case6").toLatin1())
+ << QString(">h<h<h>h>h<h!h!h")
+ << QString("aBcDef92")
+ << QString("AbcDEf92")
+ << QString("AbcDEf92")
+ << bool(insert_text);
+
+ QTest::newRow(QString(insert_mode + "illegal_keys1").toLatin1())
+ << QString("AAAAAAAA")
+ << QString("A2#a;.0!")
+ << QString("Aa")
+ << QString("Aa ")
+ << bool(insert_text);
+ QTest::newRow(QString(insert_mode + "illegal_keys2").toLatin1())
+ << QString("AAAA")
+ << QString("f4f4f4f4")
+ << QString("ffff")
+ << QString("ffff")
+ << bool(insert_text);
+ QTest::newRow(QString(insert_mode + "blank=input").toLatin1())
+ << QString("9999;0")
+ << QString("2004")
+ << QString("2004")
+ << QString("2004")
+ << bool(insert_text);
+ }
+}
+
+void tst_QLineEdit::setInputMask()
+{
+ QFETCH(QString, mask);
+ QFETCH(QString, input);
+ QFETCH(QString, expectedText);
+ QFETCH(QString, expectedDisplay);
+ QFETCH(bool, insert_text);
+
+ QEXPECT_FAIL( "keys blank=input", "To eat blanks or not? Known issue. Task 43172", Abort);
+ QEXPECT_FAIL( "insert blank=input", "To eat blanks or not? Known issue. Task 43172", Abort);
+
+ // First set the input mask
+ testWidget->setInputMask(mask);
+
+ // then either insert using insert() or keyboard
+ if (insert_text) {
+ testWidget->insert(input);
+ } else {
+ psKeyClick(testWidget, Qt::Key_Home);
+ for (int i=0; i<input.length(); i++)
+ QTest::keyClick(testWidget, input.at(i).toLatin1());
+ }
+
+ QCOMPARE(testWidget->text(), expectedText);
+ QCOMPARE(testWidget->displayText(), expectedDisplay);
+}
+
+void tst_QLineEdit::inputMask_data()
+{
+ QTest::addColumn<QString>("mask");
+ QTest::addColumn<QString>("expectedMask");
+
+ // if no mask is set a nul string should be returned
+ QTest::newRow("") << QString("") << QString();
+ QTest::newRow("") << QString() << QString();
+
+ // try different masks
+ QTest::newRow("") << QString("000.000.000.000") << QString("000.000.000.000; ");
+ QTest::newRow("") << QString("000.000.000.000;#") << QString("000.000.000.000;#");
+ QTest::newRow("") << QString("AAA.aa.999.###;") << QString("AAA.aa.999.###; ");
+ QTest::newRow("") << QString(">abcdef<GHIJK") << QString(">abcdef<GHIJK; ");
+// QTest::newRow("") << QString() << QString();
+
+ // set an invalid input mask...
+ // the current behaviour is that this exact (faulty) string is returned.
+ QTest::newRow("") << QString("ABCDEFGHIKLMNOP;") << QString("ABCDEFGHIKLMNOP; ");
+
+ // verify that we can unset the mask again
+ QTest::newRow("") << QString("") << QString();
+}
+
+void tst_QLineEdit::inputMask()
+{
+ QFETCH(QString, mask);
+ QFETCH(QString, expectedMask);
+
+ testWidget->setInputMask(mask);
+ QCOMPARE(testWidget->inputMask(), expectedMask);
+}
+
+void tst_QLineEdit::clearInputMask()
+{
+ testWidget->setInputMask("000.000.000.000");
+ QVERIFY(testWidget->inputMask() != QString::null);
+ testWidget->setInputMask(QString::null);
+ QCOMPARE(testWidget->inputMask(), QString());
+}
+
+void tst_QLineEdit::keypress_inputMask_data()
+{
+ QTest::addColumn<QString>("mask");
+ QTest::addColumn<QTestEventList>("keys");
+ QTest::addColumn<QString>("expectedText");
+ QTest::addColumn<QString>("expectedDisplayText");
+
+ {
+ QTestEventList keys;
+ // inserting 'A1.2B'
+ keys.addKeyClick(Qt::Key_Home);
+ keys.addKeyClick(Qt::Key_A);
+ keys.addKeyClick(Qt::Key_1);
+ keys.addKeyClick(Qt::Key_Period);
+ keys.addKeyClick(Qt::Key_2);
+ keys.addKeyClick(Qt::Key_B);
+ QTest::newRow("jumping on period(separator)") << QString("000.000;_") << keys << QString("1.2") << QString("1__.2__");
+ }
+ {
+ QTestEventList keys;
+ // inserting 'A1.2B'
+ keys.addKeyClick(Qt::Key_Home);
+ keys.addKeyClick(Qt::Key_0);
+ keys.addKeyClick(Qt::Key_Exclam);
+ keys.addKeyClick('P');
+ keys.addKeyClick(Qt::Key_3);
+ QTest::newRow("jumping on input") << QString("D0.AA.XX.AA.00;_") << keys << QString("0..!P..3") << QString("_0.__.!P.__.3_");
+ }
+ {
+ QTestEventList keys;
+ // pressing delete
+ keys.addKeyClick(Qt::Key_Home);
+ keys.addKeyClick(Qt::Key_Delete);
+ QTest::newRow("delete") << QString("000.000;_") << keys << QString(".") << QString("___.___");
+ }
+ {
+ QTestEventList keys;
+ // selecting all and delete
+ keys.addKeyClick(Qt::Key_Home);
+ keys.addKeyClick(Qt::Key_End, Qt::ShiftModifier);
+ keys.addKeyClick(Qt::Key_Delete);
+ QTest::newRow("deleting all") << QString("000.000;_") << keys << QString(".") << QString("___.___");
+ }
+ {
+ QTestEventList keys;
+ // inserting '12.12' then two backspaces
+ keys.addKeyClick(Qt::Key_Home);
+ keys.addKeyClick(Qt::Key_1);
+ keys.addKeyClick(Qt::Key_2);
+ keys.addKeyClick(Qt::Key_Period);
+ keys.addKeyClick(Qt::Key_1);
+ keys.addKeyClick(Qt::Key_2);
+ keys.addKeyClick(Qt::Key_Backspace);
+ keys.addKeyClick(Qt::Key_Backspace);
+ QTest::newRow("backspace") << QString("000.000;_") << keys << QString("12.") << QString("12_.___");
+ }
+ {
+ QTestEventList keys;
+ // inserting '12ab'
+ keys.addKeyClick(Qt::Key_Home);
+ keys.addKeyClick(Qt::Key_1);
+ keys.addKeyClick(Qt::Key_2);
+ keys.addKeyClick(Qt::Key_A);
+ keys.addKeyClick(Qt::Key_B);
+ QTest::newRow("uppercase") << QString("9999 >AA;_") << keys << QString("12 AB") << QString("12__ AB");
+ }
+}
+
+void tst_QLineEdit::keypress_inputMask()
+{
+ QFETCH(QString, mask);
+ QFETCH(QTestEventList, keys);
+ QFETCH(QString, expectedText);
+ QFETCH(QString, expectedDisplayText);
+
+ testWidget->setInputMask(mask);
+ keys.simulate(testWidget);
+
+ QCOMPARE(testWidget->text(), expectedText);
+ QCOMPARE(testWidget->displayText(), expectedDisplayText);
+}
+
+
+void tst_QLineEdit::hasAcceptableInputMask_data()
+{
+ QTest::addColumn<QString>("optionalMask");
+ QTest::addColumn<QString>("requiredMask");
+ QTest::addColumn<QString>("invalid");
+ QTest::addColumn<QString>("valid");
+
+ QTest::newRow("Alphabetic optional and required")
+ << QString("aaaa") << QString("AAAA") << QString("ab") << QString("abcd");
+ QTest::newRow("Alphanumeric optional and require")
+ << QString("nnnn") << QString("NNNN") << QString("R2") << QString("R2D2");
+ QTest::newRow("Any optional and required")
+ << QString("xxxx") << QString("XXXX") << QString("+-") << QString("+-*/");
+ QTest::newRow("Numeric (0-9) required")
+ << QString("0000") << QString("9999") << QString("11") << QString("1138");
+ QTest::newRow("Numeric (1-9) optional and required")
+ << QString("dddd") << QString("DDDD") << QString("12") << QString("1234");
+}
+
+void tst_QLineEdit::hasAcceptableInputMask()
+{
+ QFocusEvent lostFocus(QEvent::FocusOut);
+ QFETCH(QString, optionalMask);
+ QFETCH(QString, requiredMask);
+ QFETCH(QString, invalid);
+ QFETCH(QString, valid);
+
+ // test that invalid input (for required) work for optionalMask
+ testWidget->setInputMask(optionalMask);
+ validInput = false;
+ testWidget->setText(invalid);
+ qApp->sendEvent(testWidget, &lostFocus);
+ QVERIFY(validInput);
+
+ // at the moment we don't strip the blank character if it is valid input, this makes the test between x vs X useless
+ QEXPECT_FAIL( "Any optional and required", "To eat blanks or not? Known issue. Task 43172", Abort);
+
+ // test requiredMask
+ testWidget->setInputMask(requiredMask);
+ validInput = true;
+ testWidget->setText(invalid);
+ validInput = testWidget->hasAcceptableInput();
+ QVERIFY(!validInput);
+
+ validInput = false;
+ testWidget->setText(valid);
+ qApp->sendEvent(testWidget, &lostFocus);
+ QVERIFY(validInput);
+}
+
+static const int chars = 8;
+class ValidatorWithFixup : public QValidator
+{
+public:
+ ValidatorWithFixup(QWidget *parent = 0)
+ : QValidator(parent)
+ {}
+
+ QValidator::State validate(QString &str, int &) const
+ {
+ const int s = str.size();
+ if (s < chars) {
+ return Intermediate;
+ } else if (s > chars) {
+ return Invalid;
+ }
+ return Acceptable;
+ }
+
+ void fixup(QString &str) const
+ {
+ str = str.leftJustified(chars, 'X', true);
+ }
+};
+
+
+
+void tst_QLineEdit::hasAcceptableInputValidator()
+{
+ QFocusEvent lostFocus(QEvent::FocusOut);
+ ValidatorWithFixup val;
+ testWidget->setValidator(&val);
+ testWidget->setText("foobar");
+ qApp->sendEvent(testWidget, &lostFocus);
+ QVERIFY(testWidget->hasAcceptableInput());
+}
+
+
+
+void tst_QLineEdit::maskCharacter_data()
+{
+ QTest::addColumn<QString>("mask");
+ QTest::addColumn<QString>("input");
+ QTest::addColumn<bool>("expectedValid");
+
+ QTest::newRow("Hex") << QString("H")
+ << QString("0123456789abcdefABCDEF") << true;
+ QTest::newRow("hex") << QString("h")
+ << QString("0123456789abcdefABCDEF") << true;
+ QTest::newRow("HexInvalid") << QString("H")
+ << QString("ghijklmnopqrstuvwxyzGHIJKLMNOPQRSTUVWXYZ")
+ << false;
+ QTest::newRow("hexInvalid") << QString("h")
+ << QString("ghijklmnopqrstuvwxyzGHIJKLMNOPQRSTUVWXYZ")
+ << false;
+ QTest::newRow("Bin") << QString("B")
+ << QString("01") << true;
+ QTest::newRow("bin") << QString("b")
+ << QString("01") << true;
+ QTest::newRow("BinInvalid") << QString("B")
+ << QString("23456789qwertyuiopasdfghjklzxcvbnm")
+ << false;
+ QTest::newRow("binInvalid") << QString("b")
+ << QString("23456789qwertyuiopasdfghjklzxcvbnm")
+ << false;
+}
+
+void tst_QLineEdit::maskCharacter()
+{
+ QFETCH(QString, mask);
+ QFETCH(QString, input);
+ QFETCH(bool, expectedValid);
+
+ QFocusEvent lostFocus(QEvent::FocusOut);
+
+ testWidget->setInputMask(mask);
+ for (int i = 0; i < input.size(); ++i) {
+ QString in = QString(input.at(i));
+ QString expected = expectedValid ? in : QString();
+ testWidget->setText(QString(input.at(i)));
+ qApp->sendEvent(testWidget, &lostFocus);
+ QCOMPARE(testWidget->text(), expected);
+ }
+}
+
+#define NORMAL 0
+#define REPLACE_UNTIL_END 1
+
+void tst_QLineEdit::undo_data()
+{
+ QTest::addColumn<QStringList>("insertString");
+ QTest::addColumn<IntList>("insertIndex");
+ QTest::addColumn<IntList>("insertMode");
+ QTest::addColumn<QStringList>("expectedString");
+ QTest::addColumn<bool>("use_keys");
+
+ for (int i=0; i<2; i++) {
+ QString keys_str = "keyboard";
+ bool use_keys = true;
+ if (i==0) {
+ keys_str = "insert";
+ use_keys = false;
+ }
+
+ {
+ IntList insertIndex;
+ IntList insertMode;
+ QStringList insertString;
+ QStringList expectedString;
+
+ insertIndex << -1;
+ insertMode << NORMAL;
+ insertString << "1";
+
+ insertIndex << -1;
+ insertMode << NORMAL;
+ insertString << "5";
+
+ insertIndex << 1;
+ insertMode << NORMAL;
+ insertString << "3";
+
+ insertIndex << 1;
+ insertMode << NORMAL;
+ insertString << "2";
+
+ insertIndex << 3;
+ insertMode << NORMAL;
+ insertString << "4";
+
+ expectedString << "12345";
+ expectedString << "1235";
+ expectedString << "135";
+ expectedString << "15";
+ expectedString << "";
+
+ QTest::newRow(QString(keys_str + "_numbers").toLatin1()) <<
+ insertString <<
+ insertIndex <<
+ insertMode <<
+ expectedString <<
+ bool(use_keys);
+ }
+ {
+ IntList insertIndex;
+ IntList insertMode;
+ QStringList insertString;
+ QStringList expectedString;
+
+ insertIndex << -1;
+ insertMode << NORMAL;
+ insertString << "World"; // World
+
+ insertIndex << 0;
+ insertMode << NORMAL;
+ insertString << "Hello"; // HelloWorld
+
+ insertIndex << 0;
+ insertMode << NORMAL;
+ insertString << "Well"; // WellHelloWorld
+
+ insertIndex << 9;
+ insertMode << NORMAL;
+ insertString << "There"; // WellHelloThereWorld;
+
+ expectedString << "WellHelloThereWorld";
+ expectedString << "WellHelloWorld";
+ expectedString << "HelloWorld";
+ expectedString << "World";
+ expectedString << "";
+
+ QTest::newRow(QString(keys_str + "_helloworld").toLatin1()) <<
+ insertString <<
+ insertIndex <<
+ insertMode <<
+ expectedString <<
+ bool(use_keys);
+ }
+ {
+ IntList insertIndex;
+ IntList insertMode;
+ QStringList insertString;
+ QStringList expectedString;
+
+ insertIndex << -1;
+ insertMode << NORMAL;
+ insertString << "Ensuring";
+
+ insertIndex << -1;
+ insertMode << NORMAL;
+ insertString << " instan";
+
+ insertIndex << 9;
+ insertMode << NORMAL;
+ insertString << "an ";
+
+ insertIndex << 10;
+ insertMode << REPLACE_UNTIL_END;
+ insertString << " unique instance.";
+
+ expectedString << "Ensuring a unique instance.";
+ expectedString << "Ensuring an instan";
+ expectedString << "Ensuring instan";
+ expectedString << "";
+
+ QTest::newRow(QString(keys_str + "_patterns").toLatin1()) <<
+ insertString <<
+ insertIndex <<
+ insertMode <<
+ expectedString <<
+ bool(use_keys);
+ }
+ }
+}
+
+void tst_QLineEdit::undo()
+{
+ QFETCH(QStringList, insertString);
+ QFETCH(IntList, insertIndex);
+ QFETCH(IntList, insertMode);
+ QFETCH(QStringList, expectedString);
+ QFETCH(bool, use_keys);
+
+ QVERIFY(!testWidget->isUndoAvailable());
+
+ int i;
+
+// STEP 1: First build up an undo history by inserting or typing some strings...
+ for (i=0; i<insertString.size(); ++i) {
+ if (insertIndex[i] > -1)
+ testWidget->setCursorPosition(insertIndex[i]);
+
+ // experimental stuff
+ if (insertMode[i] == REPLACE_UNTIL_END) {
+ testWidget->setSelection(insertIndex[i], 8);
+
+ // This is what I actually want...
+ // QTest::keyClick(testWidget, Qt::Key_End, Qt::ShiftModifier);
+ }
+
+ if (use_keys)
+ QTest::keyClicks(testWidget, insertString[i]);
+ else
+ testWidget->insert(insertString[i]);
+ }
+
+// STEP 2: Next call undo several times and see if we can restore to the previous state
+ for (i=0; i<expectedString.size()-1; ++i) {
+ QCOMPARE(testWidget->text(), expectedString[i]);
+ QVERIFY(testWidget->isUndoAvailable());
+ testWidget->undo();
+ }
+
+// STEP 3: Verify that we have undone everything
+ QVERIFY(!testWidget->isUndoAvailable());
+ QVERIFY(testWidget->text().isEmpty());
+
+#ifdef Q_WS_WIN
+ // Repeat the test using shortcut instead of undo()
+ for (i=0; i<insertString.size(); ++i) {
+ if (insertIndex[i] > -1)
+ testWidget->setCursorPosition(insertIndex[i]);
+ if (insertMode[i] == REPLACE_UNTIL_END) {
+ testWidget->setSelection(insertIndex[i], 8);
+ }
+ if (use_keys)
+ QTest::keyClicks(testWidget, insertString[i]);
+ else
+ testWidget->insert(insertString[i]);
+ }
+ for (i=0; i<expectedString.size()-1; ++i) {
+ QCOMPARE(testWidget->text(), expectedString[i]);
+ QVERIFY(testWidget->isUndoAvailable());
+ QTest::keyClick(testWidget, Qt::Key_Backspace, Qt::AltModifier);
+ }
+#endif
+}
+
+void tst_QLineEdit::redo_data()
+{
+ QTest::addColumn<QStringList>("insertString");
+ QTest::addColumn<IntList>("insertIndex");
+ QTest::addColumn<QStringList>("expectedString");
+
+ {
+ IntList insertIndex;
+ QStringList insertString;
+ QStringList expectedString;
+
+ insertIndex << -1;
+ insertString << "World"; // World
+ insertIndex << 0;
+ insertString << "Hello"; // HelloWorld
+ insertIndex << 0;
+ insertString << "Well"; // WellHelloWorld
+ insertIndex << 9;
+ insertString << "There"; // WellHelloThereWorld;
+
+ expectedString << "World";
+ expectedString << "HelloWorld";
+ expectedString << "WellHelloWorld";
+ expectedString << "WellHelloThereWorld";
+
+ QTest::newRow("Inserts and setting cursor") << insertString << insertIndex << expectedString;
+ }
+}
+
+void tst_QLineEdit::redo()
+{
+ QFETCH(QStringList, insertString);
+ QFETCH(IntList, insertIndex);
+ QFETCH(QStringList, expectedString);
+
+ QVERIFY(!testWidget->isUndoAvailable());
+ QVERIFY(!testWidget->isRedoAvailable());
+
+ int i;
+ // inserts the diff strings at diff positions
+ for (i=0; i<insertString.size(); ++i) {
+ if (insertIndex[i] > -1)
+ testWidget->setCursorPosition(insertIndex[i]);
+ testWidget->insert(insertString[i]);
+ }
+
+ QVERIFY(!testWidget->isRedoAvailable());
+
+ // undo everything
+ while (!testWidget->text().isEmpty())
+ testWidget->undo();
+
+ for (i=0; i<expectedString.size(); ++i) {
+ QVERIFY(testWidget->isRedoAvailable());
+ testWidget->redo();
+ QCOMPARE(testWidget->text() , expectedString[i]);
+ }
+
+ QVERIFY(!testWidget->isRedoAvailable());
+
+#ifdef Q_WS_WIN
+ // repeat test, this time using shortcuts instead of undo()/redo()
+
+ while (!testWidget->text().isEmpty())
+ QTest::keyClick(testWidget, Qt::Key_Backspace, Qt::AltModifier);
+
+ for (i = 0; i < expectedString.size(); ++i) {
+ QVERIFY(testWidget->isRedoAvailable());
+ QTest::keyClick(testWidget, Qt::Key_Backspace,
+ Qt::ShiftModifier | Qt::AltModifier);
+ QCOMPARE(testWidget->text() , expectedString[i]);
+ }
+
+ QVERIFY(!testWidget->isRedoAvailable());
+#endif
+}
+
+void tst_QLineEdit::undo_keypressevents_data()
+{
+ QTest::addColumn<QTestEventList>("keys");
+ QTest::addColumn<QStringList>("expectedString");
+
+ {
+ QTestEventList keys;
+ QStringList expectedString;
+
+ keys.addKeyClick('A');
+ keys.addKeyClick('F');
+ keys.addKeyClick('R');
+ keys.addKeyClick('A');
+ keys.addKeyClick('I');
+ keys.addKeyClick('D');
+ psKeyClick(keys, Qt::Key_Home);
+
+ keys.addKeyClick('V');
+ keys.addKeyClick('E');
+ keys.addKeyClick('R');
+ keys.addKeyClick('Y');
+
+ keys.addKeyClick(Qt::Key_Left);
+ keys.addKeyClick(Qt::Key_Left);
+ keys.addKeyClick(Qt::Key_Left);
+ keys.addKeyClick(Qt::Key_Left);
+
+ keys.addKeyClick('B');
+ keys.addKeyClick('E');
+ psKeyClick(keys, Qt::Key_End);
+
+ keys.addKeyClick(Qt::Key_Exclam);
+
+ expectedString << "BEVERYAFRAID!";
+ expectedString << "BEVERYAFRAID";
+ expectedString << "VERYAFRAID";
+ expectedString << "AFRAID";
+
+ QTest::newRow("Inserts and moving cursor") << keys << expectedString;
+ }
+
+ {
+ QTestEventList keys;
+ QStringList expectedString;
+
+ // inserting '1234'
+ keys.addKeyClick(Qt::Key_1);
+ keys.addKeyClick(Qt::Key_2);
+ keys.addKeyClick(Qt::Key_3);
+ keys.addKeyClick(Qt::Key_4);
+ psKeyClick(keys, Qt::Key_Home);
+
+ // skipping '12'
+ keys.addKeyClick(Qt::Key_Right);
+ keys.addKeyClick(Qt::Key_Right);
+
+ // selecting '34'
+ keys.addKeyClick(Qt::Key_Right, Qt::ShiftModifier);
+ keys.addKeyClick(Qt::Key_Right, Qt::ShiftModifier);
+
+ // deleting '34'
+ keys.addKeyClick(Qt::Key_Delete);
+
+ expectedString << "12";
+ expectedString << "1234";
+
+ QTest::newRow("Inserts,moving,selection and delete") << keys << expectedString;
+ }
+
+ {
+ QTestEventList keys;
+ QStringList expectedString;
+
+ // inserting 'AB12'
+ keys.addKeyClick('A');
+ keys.addKeyClick('B');
+
+ keys.addKeyClick(Qt::Key_1);
+ keys.addKeyClick(Qt::Key_2);
+
+ psKeyClick(keys, Qt::Key_Home);
+
+ // selecting 'AB'
+ keys.addKeyClick(Qt::Key_Right, Qt::ShiftModifier);
+ keys.addKeyClick(Qt::Key_Right, Qt::ShiftModifier);
+
+ // deleting 'AB'
+ keys.addKeyClick(Qt::Key_Delete);
+
+ // undoing deletion of 'AB'
+ keys.addKeyClick(Qt::Key_Z, Qt::ControlModifier);
+
+ // unselect any current selection
+ keys.addKeyClick(Qt::Key_Right);
+#ifdef Q_WS_WIN //Mac has a specialcase to handle jumping to the end of a selection
+ keys.addKeyClick(Qt::Key_Left);
+#endif
+
+ // selecting '12'
+ keys.addKeyClick(Qt::Key_Right, Qt::ShiftModifier);
+ keys.addKeyClick(Qt::Key_Right, Qt::ShiftModifier);
+
+ // deleting '12'
+ keys.addKeyClick(Qt::Key_Delete);
+
+ expectedString << "AB";
+ expectedString << "AB12";
+
+ QTest::newRow("Inserts,moving,selection, delete and undo") << keys << expectedString;
+ }
+
+ {
+ QTestEventList keys;
+ QStringList expectedString;
+
+ // inserting 'ABCD'
+ keys.addKeyClick(Qt::Key_A);
+ keys.addKeyClick(Qt::Key_B);
+ keys.addKeyClick(Qt::Key_C);
+ keys.addKeyClick(Qt::Key_D);
+
+ //move left two
+ keys.addKeyClick(Qt::Key_Left);
+ keys.addKeyClick(Qt::Key_Left);
+
+ // inserting '1234'
+ keys.addKeyClick(Qt::Key_1);
+ keys.addKeyClick(Qt::Key_2);
+ keys.addKeyClick(Qt::Key_3);
+ keys.addKeyClick(Qt::Key_4);
+
+ // selecting '1234'
+ keys.addKeyClick(Qt::Key_Left, Qt::ShiftModifier);
+ keys.addKeyClick(Qt::Key_Left, Qt::ShiftModifier);
+ keys.addKeyClick(Qt::Key_Left, Qt::ShiftModifier);
+ keys.addKeyClick(Qt::Key_Left, Qt::ShiftModifier);
+
+ // overwriting '1234' with '5'
+ keys.addKeyClick(Qt::Key_5);
+
+ // undoing deletion of 'AB'
+ keys.addKeyClick(Qt::Key_Z, Qt::ControlModifier);
+
+ // overwriting '1234' with '6'
+ keys.addKeyClick(Qt::Key_6);
+
+ expectedString << "ab6cd";
+ // for versions previous to 3.2 we overwrite needed two undo operations
+ expectedString << "ab1234cd";
+ expectedString << "abcd";
+
+ QTest::newRow("Inserts,moving,selection and undo, removing selection") << keys << expectedString;
+ }
+
+ {
+ QTestEventList keys;
+ QStringList expectedString;
+
+ // inserting 'ABC'
+ keys.addKeyClick('A');
+ keys.addKeyClick('B');
+ keys.addKeyClick('C');
+
+ // removes 'C'
+ keys.addKeyClick(Qt::Key_Backspace);
+
+ expectedString << "AB";
+ expectedString << "ABC";
+
+ QTest::newRow("Inserts,backspace") << keys << expectedString;
+ }
+
+ {
+ QTestEventList keys;
+ QStringList expectedString;
+
+ // inserting 'ABC'
+ keys.addKeyClick('A');
+ keys.addKeyClick('B');
+ keys.addKeyClick('C');
+
+ // removes 'C'
+ keys.addKeyClick(Qt::Key_Backspace);
+
+ // inserting 'Z'
+ keys.addKeyClick('Z');
+
+ expectedString << "ABZ";
+ expectedString << "AB";
+ expectedString << "ABC";
+
+ QTest::newRow("Inserts,backspace,inserts") << keys << expectedString;
+ }
+
+
+ {
+ QTestEventList keys;
+ QStringList expectedString;
+
+ // inserting '123'
+ keys.addKeyClick(Qt::Key_1);
+ keys.addKeyClick(Qt::Key_2);
+ keys.addKeyClick(Qt::Key_3);
+ psKeyClick(keys, Qt::Key_Home);
+
+ // selecting '123'
+ psKeyClick(keys, Qt::Key_End, Qt::ShiftModifier);
+
+ // overwriting '123' with 'ABC'
+ keys.addKeyClick('A');
+ keys.addKeyClick('B');
+ keys.addKeyClick('C');
+
+ expectedString << "ABC";
+ // for versions previous to 3.2 we overwrite needed two undo operations
+ expectedString << "123";
+
+ QTest::newRow("Inserts,moving,selection and overwriting") << keys << expectedString;
+ }
+}
+
+void tst_QLineEdit::undo_keypressevents()
+{
+ QFETCH(QTestEventList, keys);
+ QFETCH(QStringList, expectedString);
+
+ keys.simulate(testWidget);
+
+ for (int i=0; i<expectedString.size(); ++i) {
+ QCOMPARE(testWidget->text() , expectedString[i]);
+ testWidget->undo();
+ }
+ QVERIFY(testWidget->text().isEmpty());
+}
+
+#ifndef QT_NO_CLIPBOARD
+static bool nativeClipboardWorking()
+{
+#ifdef Q_WS_MAC
+ PasteboardRef pasteboard;
+ OSStatus status = PasteboardCreate(0, &pasteboard);
+ if (status == noErr)
+ CFRelease(pasteboard);
+ return status == noErr;
+#endif
+ return true;
+}
+
+void tst_QLineEdit::QTBUG5786_undoPaste()
+{
+ if (!nativeClipboardWorking())
+ QSKIP("this machine doesn't support the clipboard", SkipAll);
+ QString initial("initial");
+ QString string("test");
+ QString additional("add");
+ QApplication::clipboard()->setText(string);
+ QLineEdit edit(initial);
+ QCOMPARE(edit.text(), initial);
+ edit.paste();
+ QCOMPARE(edit.text(), initial + string);
+ edit.paste();
+ QCOMPARE(edit.text(), initial + string + string);
+ edit.insert(additional);
+ QCOMPARE(edit.text(), initial + string + string + additional);
+ edit.undo();
+ QCOMPARE(edit.text(), initial + string + string);
+ edit.undo();
+ QCOMPARE(edit.text(), initial + string);
+ edit.undo();
+ QCOMPARE(edit.text(), initial);
+ edit.selectAll();
+ QApplication::clipboard()->setText(QString());
+ edit.paste();
+ QVERIFY(edit.text().isEmpty());
+
+}
+#endif
+
+
+void tst_QLineEdit::clear()
+{
+ // checking that clear of empty/nullstring doesn't add to undo history
+ int max = 5000;
+ while (max > 0 && testWidget->isUndoAvailable()) {
+ max--;
+ testWidget->undo();
+ }
+
+ testWidget->clear();
+// QVERIFY(!testWidget->isUndoAvailable());
+
+ // checks that clear actually clears
+ testWidget->insert("I am Legend");
+ testWidget->clear();
+ QVERIFY(testWidget->text().isEmpty());
+
+ // checks that clears can be undone
+ testWidget->undo();
+ QCOMPARE(testWidget->text(), QString("I am Legend"));
+}
+
+void tst_QLineEdit::editingFinished()
+{
+ if (testWidget->hasAcceptableInput())
+ validInput = true;
+ else
+ validInput = false;
+}
+
+void tst_QLineEdit::text_data()
+{
+ QTest::addColumn<QString>("insertString");
+
+ QTest::newRow("Plain text0") << QString("Hello World");
+ QTest::newRow("Plain text1") << QString("");
+ QTest::newRow("Plain text2") << QString("A");
+ QTest::newRow("Plain text3") << QString("ryyryryryryryryryryryryryryryryryryryryryryryryryryryrryryryryryryryryryryryryryryryryryryryryryryryryryryryryryryryryryrryryryryryryryryryryryryry");
+ QTest::newRow("Plain text4") << QString("abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890`~!@#$%^&*()_-+={[}]|\\:;'?/>.<,\"");
+ QTest::newRow("Newlines") << QString("A\nB\nC\n");
+ QTest::newRow("Text with nbsp") << QString("Hello") + QChar(0xa0) + "World";
+}
+
+void tst_QLineEdit::text()
+{
+ QFETCH(QString, insertString);
+ testWidget->setText(insertString);
+ QCOMPARE(testWidget->text(), insertString);
+}
+
+void tst_QLineEdit::textMask_data()
+{
+ QTest::addColumn<QString>("insertString");
+
+ QTest::newRow( "Plain text1" ) << QString( "" );
+}
+
+void tst_QLineEdit::textMask()
+{
+ QFETCH( QString, insertString );
+ testWidget->setInputMask( "#" );
+ testWidget->setText( insertString );
+ QCOMPARE( testWidget->text(), insertString );
+}
+
+void tst_QLineEdit::setText()
+{
+ QSignalSpy editedSpy(testWidget, SIGNAL(textEdited(QString)));
+ QSignalSpy changedSpy(testWidget, SIGNAL(textChanged(QString)));
+ testWidget->setText("hello");
+ QCOMPARE(editedSpy.count(), 0);
+ QCOMPARE(changedSpy.value(0).value(0).toString(), QString("hello"));
+}
+
+void tst_QLineEdit::displayText_data()
+{
+ QTest::addColumn<QString>("insertString");
+ QTest::addColumn<QString>("expectedString");
+ QTest::addColumn<QLineEdit::EchoMode>("mode");
+ QTest::addColumn<bool>("use_setText");
+
+ QString s;
+ QLineEdit::EchoMode m;
+
+ for (int i=0; i<2; i++) {
+ QString key_mode_str;
+ bool use_setText;
+ if (i==0) {
+ key_mode_str = "setText_";
+ use_setText = true;
+ } else {
+ key_mode_str = "useKeys_";
+ use_setText = false;
+ }
+ s = key_mode_str + "Normal";
+ m = QLineEdit::Normal;
+ QTest::newRow(QString(s + " text0").toLatin1()) << QString("Hello World") <<
+ QString("Hello World") <<
+ m << bool(use_setText);
+ QTest::newRow(QString(s + " text1").toLatin1()) << QString("") <<
+ QString("") <<
+ m << bool(use_setText);
+ QTest::newRow(QString(s + " text2").toLatin1()) << QString("A") <<
+ QString("A") <<
+ m << bool(use_setText);
+ QTest::newRow(QString(s + " text3").toLatin1()) << QString("ryyryryryryryryryryryryryryryryryryryryryryryryryryryrryryryryryryryryryryryryryryryryryryryryryryryryryryryryryryryryryrryryryryryryryryryryryryry") <<
+ QString("ryyryryryryryryryryryryryryryryryryryryryryryryryryryrryryryryryryryryryryryryryryryryryryryryryryryryryryryryryryryryryrryryryryryryryryryryryryry") <<
+ m << bool(use_setText);
+ QTest::newRow(QString(s + " text4").toLatin1()) << QString("abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890`~!@#$%^&*()_-+={[}]|\\:;'?/>.<,\"") <<
+ QString("abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890`~!@#$%^&*()_-+={[}]|\\:;'?/>.<,\"") <<
+ m << bool(use_setText);
+ QTest::newRow(QString(s + " text with nbsp").toLatin1()) << QString("Hello") + QChar(0xa0) + "World" <<
+ QString("Hello") + QChar(0xa0) + "World" <<
+ m << bool(use_setText);
+ s = key_mode_str + "NoEcho";
+ m = QLineEdit::NoEcho;
+ QTest::newRow(QString(s + " text0").toLatin1()) << QString("Hello World") <<
+ QString("") <<
+ m << bool(use_setText);
+ QTest::newRow(QString(s + " text1").toLatin1()) << QString("") <<
+ QString("") <<
+ m << bool(use_setText);
+ QTest::newRow(QString(s + " text2").toLatin1()) << QString("A") <<
+ QString("") <<
+ m << bool(use_setText);
+ QTest::newRow(QString(s + " text3").toLatin1()) << QString("ryyryryryryryryryryryryryryryryryryryryryryryryryryryrryryryryryryryryryryryryryryryryryryryryryryryryryryryryryryryryryrryryryryryryryryryryryryry") <<
+ QString("") <<
+ m << bool(use_setText);
+ QTest::newRow(QString(s + " text4").toLatin1()) << QString("abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890`~!@#$%^&*()_-+={[}]|\\:;'?/>.<,\"") <<
+ QString("") <<
+ m << bool(use_setText);
+ QTest::newRow(QString(s + " text with nbsp").toLatin1()) << QString("Hello") + QChar(0xa0) + "World" <<
+ QString("") <<
+ m << bool(use_setText);
+ s = key_mode_str + "Password";
+ m = QLineEdit::Password;
+ QChar passChar = qApp->style()->styleHint(QStyle::SH_LineEdit_PasswordCharacter, 0, testWidget);
+ QString input;
+ QString pass;
+ input = "Hello World";
+ pass.resize(input.length());
+ pass.fill(passChar);
+ QTest::newRow(QString(s + " text0").toLatin1()) << input << pass << m << bool(use_setText);
+ QTest::newRow(QString(s + " text1").toLatin1()) << QString("") <<
+ QString("") <<
+ m << bool(use_setText);
+ QTest::newRow(QString(s + " text2").toLatin1()) << QString("A") << QString(passChar) << m << bool(use_setText);
+ input = QString("ryyryryryryryryryryryryryryryryryryryryryryryryryryryrryryryryryryryryryryryryryryryryryryryryryryryryryryryryryryryryryrryryryryryryryryryryryryry");
+ pass.resize(input.length());
+ pass.fill(passChar);
+ QTest::newRow(QString(s + " text3").toLatin1()) << input << pass << m << bool(use_setText);
+ input = QString("abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890`~!@#$%^&*()_-+={[}]|\\:;'?/>.<,\"");
+ pass.fill(passChar, input.length());
+ QTest::newRow(QString(s + " text4").toLatin1()) << input << pass << m << bool(use_setText);
+ input = QString("Hello") + QChar(0xa0) + "World";
+ pass.resize(input.length());
+ pass.fill(passChar);
+ QTest::newRow(QString(s + " text with nbsp").toLatin1()) << input << pass << m << bool(use_setText);
+ }
+}
+
+void tst_QLineEdit::displayText()
+{
+ QFETCH(QString, insertString);
+ QFETCH(QString, expectedString);
+ QFETCH(QLineEdit::EchoMode, mode);
+ //QFETCH(bool, use_setText); Currently unused.
+
+ testWidget->setEchoMode(mode);
+ testWidget->setText(insertString);
+ QCOMPARE(testWidget->displayText(), expectedString);
+ QVERIFY(testWidget->echoMode() == mode);
+}
+
+void tst_QLineEdit::passwordEchoOnEdit()
+{
+ QStyleOptionFrameV2 opt;
+ QChar fillChar = testWidget->style()->styleHint(QStyle::SH_LineEdit_PasswordCharacter, &opt, testWidget);
+
+ testWidget->setEchoMode(QLineEdit::PasswordEchoOnEdit);
+ testWidget->setFocus();
+ testWidget->raise();
+ QTRY_VERIFY(testWidget->hasFocus());
+
+ QTest::keyPress(testWidget, '0');
+ QTest::keyPress(testWidget, '1');
+ QTest::keyPress(testWidget, '2');
+ QTest::keyPress(testWidget, '3');
+ QTest::keyPress(testWidget, '4');
+ QCOMPARE(testWidget->displayText(), QString("01234"));
+ testWidget->clearFocus();
+ QVERIFY(!testWidget->hasFocus());
+ QCOMPARE(testWidget->displayText(), QString(5, fillChar));
+ testWidget->setFocus();
+ QTRY_VERIFY(testWidget->hasFocus());
+
+ QCOMPARE(testWidget->displayText(), QString(5, fillChar));
+ QTest::keyPress(testWidget, '0');
+ QCOMPARE(testWidget->displayText(), QString("0"));
+
+ // restore clean state
+ testWidget->setEchoMode(QLineEdit::Normal);
+}
+
+#ifdef QT_GUI_PASSWORD_ECHO_DELAY
+void tst_QLineEdit::passwordEchoDelay()
+{
+ QStyleOptionFrameV2 opt;
+ QChar fillChar = testWidget->style()->styleHint(QStyle::SH_LineEdit_PasswordCharacter, &opt, testWidget);
+
+ testWidget->setEchoMode(QLineEdit::Password);
+ testWidget->setFocus();
+ testWidget->raise();
+ QTRY_VERIFY(testWidget->hasFocus());
+
+ QTest::keyPress(testWidget, '0');
+ QTest::keyPress(testWidget, '1');
+ QTest::keyPress(testWidget, '2');
+ QCOMPARE(testWidget->displayText(), QString(2, fillChar) + QLatin1Char('2'));
+ QTest::keyPress(testWidget, '3');
+ QTest::keyPress(testWidget, '4');
+ QCOMPARE(testWidget->displayText(), QString(4, fillChar) + QLatin1Char('4'));
+ QTest::keyPress(testWidget, Qt::Key_Backspace);
+ QCOMPARE(testWidget->displayText(), QString(4, fillChar));
+ QTest::keyPress(testWidget, '4');
+ QCOMPARE(testWidget->displayText(), QString(4, fillChar) + QLatin1Char('4'));
+ QTest::qWait(QT_GUI_PASSWORD_ECHO_DELAY);
+ QTRY_COMPARE(testWidget->displayText(), QString(5, fillChar));
+ QTest::keyPress(testWidget, '5');
+ QCOMPARE(testWidget->displayText(), QString(5, fillChar) + QLatin1Char('5'));
+ testWidget->clearFocus();
+ QVERIFY(!testWidget->hasFocus());
+ QCOMPARE(testWidget->displayText(), QString(6, fillChar));
+ testWidget->setFocus();
+ QTRY_VERIFY(testWidget->hasFocus());
+ QCOMPARE(testWidget->displayText(), QString(6, fillChar));
+ QTest::keyPress(testWidget, '6');
+ QCOMPARE(testWidget->displayText(), QString(6, fillChar) + QLatin1Char('6'));
+
+ QInputMethodEvent ev;
+ ev.setCommitString(QLatin1String("7"));
+ QApplication::sendEvent(testWidget, &ev);
+ QCOMPARE(testWidget->displayText(), QString(7, fillChar) + QLatin1Char('7'));
+
+ testWidget->setCursorPosition(3);
+ QCOMPARE(testWidget->displayText(), QString(7, fillChar) + QLatin1Char('7'));
+ QTest::keyPress(testWidget, 'a');
+ QCOMPARE(testWidget->displayText(), QString(3, fillChar) + QLatin1Char('a') + QString(5, fillChar));
+ QTest::keyPress(testWidget, Qt::Key_Backspace);
+ QCOMPARE(testWidget->displayText(), QString(8, fillChar));
+
+ // restore clean state
+ testWidget->setEchoMode(QLineEdit::Normal);
+}
+#endif
+
+void tst_QLineEdit::maxLength_mask_data()
+{
+ QTest::addColumn<QString>("mask");
+ QTest::addColumn<int>("expectedLength");
+
+ QTest::newRow("mask_case") << QString(">000<>00<000") << 8;
+ QTest::newRow("mask_nocase") << QString("00000000") << 8;
+ QTest::newRow("mask_null") << QString() << 32767;
+ QTest::newRow("mask_escape") << QString("\\A\\aAA") << 4;
+}
+
+void tst_QLineEdit::maxLength_mask()
+{
+ QFETCH(QString, mask);
+ QFETCH(int, expectedLength);
+
+ testWidget->setInputMask(mask);
+
+ QCOMPARE(testWidget->maxLength(), expectedLength);
+}
+
+void tst_QLineEdit::maxLength_data()
+{
+ QTest::addColumn<QString>("insertString");
+ QTest::addColumn<QString>("expectedString");
+ QTest::addColumn<int>("length");
+ QTest::addColumn<bool>("insertBeforeSettingMaxLength");
+ QTest::addColumn<bool>("use_setText");
+
+ QTest::newRow("keyclick before0") << QString("this is a test.") << QString("this is a test.") << 20 << bool(true) << bool(false);
+ QTest::newRow("keyclick before1") << QString("this is a test.") << QString("this is a ") << 10 << bool(true) << bool(false);
+ QTest::newRow("keyclick after0") << QString("this is a test.") << QString("this is a test.") << 20 << bool(false) << bool(false);
+ QTest::newRow("keyclick after1") << QString("this is a test.") << QString("this is a ") << 10 << bool(false) << bool(false);
+ QTest::newRow("settext before0") << QString("this is a test.") << QString("this is a test.") << 20 << bool(true) << bool(true);
+ QTest::newRow("settext before1") << QString("this is a test.") << QString("this is a ") << 10 << bool(true) << bool(true);
+ QTest::newRow("settext after0") << QString("this is a test.") << QString("this is a test.") << 20 << bool(false) << bool(true);
+ QTest::newRow("settext after1") << QString("this is a test.") << QString("this is a ") << 10 << bool(false) << bool(true);
+}
+
+void tst_QLineEdit::maxLength()
+{
+ QFETCH(QString, insertString);
+ QFETCH(QString, expectedString);
+ QFETCH(int, length);
+ QFETCH(bool, insertBeforeSettingMaxLength);
+ QFETCH(bool, use_setText);
+
+ // in some cases we set the maxLength _before_ entering the text.
+ if (!insertBeforeSettingMaxLength)
+ testWidget->setMaxLength(length);
+
+ // I expect MaxLength to work BOTH with entering live characters AND with setting the text.
+ if (use_setText) {
+ // Enter insertString using setText.
+ testWidget->setText(insertString);
+ } else {
+ // Enter insertString as a sequence of keyClicks
+ QTest::keyClicks(testWidget, insertString);
+ }
+
+ // in all other cases we set the maxLength _after_ entering the text.
+ if (insertBeforeSettingMaxLength) {
+ changed_count = 0;
+ testWidget->setMaxLength(length);
+
+ // Make sure that the textChanged is not emitted unless the text is actually changed
+ if (insertString == expectedString) {
+ QVERIFY(changed_count == 0);
+ } else {
+ QVERIFY(changed_count == 1);
+ }
+ }
+
+ // and check if we get the expected string back
+ QCOMPARE(testWidget->text(), expectedString);
+}
+
+void tst_QLineEdit::isReadOnly()
+{
+ QVERIFY(!testWidget->isReadOnly());
+
+ // start with a basic text
+ QTest::keyClicks(testWidget, "the quick brown fox");
+ QCOMPARE(testWidget->text(), QString("the quick brown fox"));
+
+ // do a quick check to verify that we can indeed edit the text
+ testWidget->home(false);
+ testWidget->cursorForward(false, 10);
+ QTest::keyClicks(testWidget, "dark ");
+ QCOMPARE(testWidget->text(), QString("the quick dark brown fox"));
+
+ testWidget->setReadOnly(true);
+ QVERIFY(testWidget->isReadOnly());
+
+ // verify that we cannot edit the text anymore
+ testWidget->home(false);
+ testWidget->cursorForward(false, 10);
+ QTest::keyClick(testWidget, Qt::Key_Delete);
+ QCOMPARE(testWidget->text(), QString("the quick dark brown fox"));
+ testWidget->cursorForward(false, 10);
+ QTest::keyClicks(testWidget, "this should not have any effect!! ");
+ QCOMPARE(testWidget->text(), QString("the quick dark brown fox"));
+}
+
+static void figureOutProperKey(Qt::Key &key, Qt::KeyboardModifiers &pressState)
+{
+#ifdef Q_WS_MAC
+ static bool tst_lineedit_randomized = false;
+ // Mac has 3 different ways of accomplishing this (same for moving to the back)
+ // So I guess we should just randomly do this for now. Which may get people mad, but if
+ // we fail at one point, it's just a matter of setting roll to the correct value
+ // instead of random.
+
+ if (!tst_lineedit_randomized) {
+ tst_lineedit_randomized = true;
+ ::srandom(ulong(time(0)));
+ }
+ long roll = ::random() % 3;
+ switch (roll) {
+ case 0:
+ key = key == Qt::Key_Home ? Qt::Key_Up : Qt::Key_Down;
+ break;
+ case 1:
+ case 2:
+ key = key == Qt::Key_Home ? Qt::Key_Left : Qt::Key_Right;
+ pressState |= (roll == 1) ? Qt::ControlModifier : Qt::MetaModifier;
+ break;
+ }
+#else
+ // Naively kill the warning.
+ key = key;
+ pressState = pressState;
+#endif
+}
+
+// Platform specific move. Home and End do nothing on the Mac,
+// so do something a bit smarter than tons of #ifdefs
+void tst_QLineEdit::psKeyClick(QWidget *target, Qt::Key key, Qt::KeyboardModifiers pressState)
+{
+ figureOutProperKey(key, pressState);
+ QTest::keyClick(target, key, pressState);
+}
+
+void tst_QLineEdit::psKeyClick(QTestEventList &keys, Qt::Key key, Qt::KeyboardModifiers pressState)
+{
+ figureOutProperKey(key, pressState);
+ keys.addKeyClick(key, pressState);
+}
+
+void tst_QLineEdit::cursorPosition()
+{
+ QVERIFY(testWidget->cursorPosition() == 0);
+
+ // start with a basic text
+ QTest::keyClicks(testWidget, "The");
+ QCOMPARE(testWidget->cursorPosition(), 3);
+ QTest::keyClicks(testWidget, " quick");
+ QCOMPARE(testWidget->cursorPosition(), 9);
+ QTest::keyClicks(testWidget, " brown fox jumps over the lazy dog");
+ QCOMPARE(testWidget->cursorPosition(), 43);
+
+ // The text we have now is:
+ // 1 2 3 4 5
+ // 012345678901234567890123456789012345678901234567890
+ // The quick brown fox jumps over the lazy dog
+
+ // next we will check some of the cursor movement functions
+ testWidget->end(false);
+ QCOMPARE(testWidget->cursorPosition() , 43);
+ testWidget->cursorForward(false, -1);
+ QCOMPARE(testWidget->cursorPosition() , 42);
+ testWidget->cursorBackward(false, 1);
+ QCOMPARE(testWidget->cursorPosition() , 41);
+ testWidget->home(false);
+ QCOMPARE(testWidget->cursorPosition() , 0);
+ testWidget->cursorForward(false, 1);
+ QCOMPARE(testWidget->cursorPosition() , 1);
+ testWidget->cursorForward(false, 9);
+ QCOMPARE(testWidget->cursorPosition() , 10);
+ testWidget->cursorWordForward(false); // 'fox'
+ QCOMPARE(testWidget->cursorPosition(), 16);
+ testWidget->cursorWordForward(false); // 'jumps'
+ QCOMPARE(testWidget->cursorPosition(), 20);
+ testWidget->cursorWordBackward(false); // 'fox'
+ QCOMPARE(testWidget->cursorPosition(), 16);
+ testWidget->cursorWordBackward(false); // 'brown'
+ testWidget->cursorWordBackward(false); // 'quick'
+ testWidget->cursorWordBackward(false); // 'The'
+ QCOMPARE(testWidget->cursorPosition(), 0);
+ testWidget->cursorWordBackward(false); // 'The'
+ QCOMPARE(testWidget->cursorPosition(), 0);
+
+ // Cursor position should be 0 here!
+ int i;
+ for (i=0; i<5; i++)
+ QTest::keyClick(testWidget, Qt::Key_Right);
+ QCOMPARE(testWidget->cursorPosition(), 5);
+ psKeyClick(testWidget, Qt::Key_End);
+ QCOMPARE(testWidget->cursorPosition(), 43);
+ QTest::keyClick(testWidget, Qt::Key_Left);
+ QCOMPARE(testWidget->cursorPosition(), 42);
+ QTest::keyClick(testWidget, Qt::Key_Left);
+ QCOMPARE(testWidget->cursorPosition(), 41);
+ psKeyClick(testWidget, Qt::Key_Home);
+ QCOMPARE(testWidget->cursorPosition(), 0);
+
+ // cursorposition when maxlength is set
+ int maxLength = 9;
+ testWidget->clear();
+ testWidget->setMaxLength(maxLength);
+ QCOMPARE(testWidget->cursorPosition() , 0);
+ QTest::keyClicks(testWidget, "123ABC123");
+ QCOMPARE(testWidget->cursorPosition() , maxLength);
+ psKeyClick(testWidget, Qt::Key_Home);
+ QCOMPARE(testWidget->cursorPosition() , 0);
+ psKeyClick(testWidget, Qt::Key_End);
+ QCOMPARE(testWidget->cursorPosition() , maxLength);
+}
+
+/* // tested in cursorPosition
+void tst_QLineEdit::cursorLeft()
+void tst_QLineEdit::cursorRight()
+void tst_QLineEdit::cursorForward()
+void tst_QLineEdit::cursorBackward()
+void tst_QLineEdit::cursorWordForward()
+void tst_QLineEdit::cursorWordBackward()
+void tst_QLineEdit::home()
+void tst_QLineEdit::end()
+*/
+
+void tst_QLineEdit::cursorPositionChanged_data()
+{
+ QTest::addColumn<QTestEventList>("input");
+ QTest::addColumn<int>("lastPos");
+ QTest::addColumn<int>("newPos");
+
+ QTestEventList keys;
+ keys.addKeyClick(Qt::Key_A);
+ QTest::newRow("a") << keys << 0 << 1;
+ keys.clear();
+
+ keys.addKeyClick(Qt::Key_A);
+ keys.addKeyClick(Qt::Key_B);
+ keys.addKeyClick(Qt::Key_C);
+ psKeyClick(keys, Qt::Key_Home);
+ QTest::newRow("abc<home>") << keys << 3 << 0;
+ keys.clear();
+
+ keys.addKeyClick(Qt::Key_A);
+ keys.addKeyClick(Qt::Key_B);
+ keys.addKeyClick(Qt::Key_C);
+ keys.addKeyClick(Qt::Key_Left);
+ QTest::newRow("abc<left>") << keys << 3 << 2;
+ keys.clear();
+
+ keys.addKeyClick(Qt::Key_A);
+ keys.addKeyClick(Qt::Key_B);
+ keys.addKeyClick(Qt::Key_C);
+ keys.addKeyClick(Qt::Key_Right);
+ QTest::newRow("abc<right>") << keys << 2 << 3;
+ keys.clear();
+
+ keys.addKeyClick(Qt::Key_A);
+ keys.addKeyClick(Qt::Key_B);
+ keys.addKeyClick(Qt::Key_C);
+ psKeyClick(keys, Qt::Key_Home);
+ keys.addKeyClick(Qt::Key_Right);
+ QTest::newRow("abc<home><right>") << keys << 0 << 1;
+ keys.clear();
+
+ keys.addKeyClick(Qt::Key_A);
+ keys.addKeyClick(Qt::Key_B);
+ keys.addKeyClick(Qt::Key_C);
+ keys.addKeyClick(Qt::Key_Backspace);
+ QTest::newRow("abc<backspace>") << keys << 3 << 2;
+ keys.clear();
+
+ keys.addKeyClick(Qt::Key_A);
+ keys.addKeyClick(Qt::Key_B);
+ keys.addKeyClick(Qt::Key_C);
+ keys.addKeyClick(Qt::Key_Delete);
+ QTest::newRow("abc<delete>") << keys << 2 << 3;
+ keys.clear();
+
+ keys.addKeyClick(Qt::Key_A);
+ keys.addKeyClick(Qt::Key_B);
+ keys.addKeyClick(Qt::Key_C);
+ keys.addKeyClick(Qt::Key_Left);
+ keys.addKeyClick(Qt::Key_Delete);
+ QTest::newRow("abc<left><delete>") << keys << 3 << 2;
+ keys.clear();
+
+ keys.addKeyClick(Qt::Key_A);
+ keys.addKeyClick(Qt::Key_B);
+ keys.addKeyClick(Qt::Key_C);
+ psKeyClick(keys, Qt::Key_Home);
+ psKeyClick(keys, Qt::Key_End);
+ QTest::newRow("abc<home><end>") << keys << 0 << 3;
+ keys.clear();
+
+ keys.addKeyClick(Qt::Key_A);
+ keys.addKeyClick(Qt::Key_B);
+ keys.addKeyClick(Qt::Key_C);
+ keys.addKeyClick(Qt::Key_Space);
+ keys.addKeyClick(Qt::Key_D);
+ keys.addKeyClick(Qt::Key_E);
+ keys.addKeyClick(Qt::Key_F);
+ keys.addKeyClick(Qt::Key_Home);
+ keys.addKeyClick(Qt::Key_Right, Qt::ControlModifier);
+ QTest::newRow("abc efg<home><ctrl-right>") << keys
+#ifndef Q_WS_MAC
+ << 0 << 4;
+#else
+ << 6 << 7;
+#endif
+ keys.clear();
+
+#ifdef Q_WS_MAC
+ keys.addKeyClick(Qt::Key_A);
+ keys.addKeyClick(Qt::Key_B);
+ keys.addKeyClick(Qt::Key_C);
+ keys.addKeyClick(Qt::Key_Space);
+ keys.addKeyClick(Qt::Key_D);
+ keys.addKeyClick(Qt::Key_E);
+ keys.addKeyClick(Qt::Key_F);
+ keys.addKeyClick(Qt::Key_Up);
+ keys.addKeyClick(Qt::Key_Right, Qt::AltModifier);
+ QTest::newRow("mac equivalent abc efg<up><option-right>") << keys << 0 << 4;
+ keys.clear();
+#endif
+
+ keys.addKeyClick(Qt::Key_A);
+ keys.addKeyClick(Qt::Key_B);
+ keys.addKeyClick(Qt::Key_C);
+ keys.addKeyClick(Qt::Key_Space);
+ keys.addKeyClick(Qt::Key_D);
+ keys.addKeyClick(Qt::Key_E);
+ keys.addKeyClick(Qt::Key_F);
+ keys.addKeyClick(Qt::Key_Left, Qt::ControlModifier);
+ QTest::newRow("abc efg<ctrl-left>") << keys << 7
+#ifndef Q_WS_MAC
+ << 4;
+#else
+ << 0;
+#endif
+ keys.clear();
+#ifdef Q_WS_MAC
+ keys.addKeyClick(Qt::Key_A);
+ keys.addKeyClick(Qt::Key_B);
+ keys.addKeyClick(Qt::Key_C);
+ keys.addKeyClick(Qt::Key_Space);
+ keys.addKeyClick(Qt::Key_D);
+ keys.addKeyClick(Qt::Key_E);
+ keys.addKeyClick(Qt::Key_F);
+ keys.addKeyClick(Qt::Key_Left, Qt::AltModifier);
+ QTest::newRow("mac equivalent abc efg<option-left>") << keys << 7 << 4;
+ keys.clear();
+#endif
+}
+
+
+void tst_QLineEdit::cursorPositionChanged()
+{
+ QFETCH(QTestEventList, input);
+ QFETCH(int, lastPos);
+ QFETCH(int, newPos);
+
+ lastCursorPos = 0;
+ newCursorPos = 0;
+ input.simulate(testWidget);
+ QCOMPARE(lastCursorPos, lastPos);
+ QCOMPARE(newCursorPos, newPos);
+}
+
+void tst_QLineEdit::selectedText()
+{
+ QString testString = "Abc defg hijklmno, p 'qrst' uvw xyz";
+
+ // start with a basic text
+ testWidget->setText(testString);
+ selection_count = 0;
+
+ // The text we have now is:
+ // 1 2 3 4 5
+ // 012345678901234567890123456789012345678901234567890
+ // Abc defg hijklmno, p 'qrst' uvw xyz
+
+ testWidget->home(false);
+ QVERIFY(!testWidget->hasSelectedText());
+ QCOMPARE(testWidget->selectedText(), QString());
+
+ // play a bit with the cursorForward, cursorBackward(), etc
+ testWidget->cursorForward(true, 9);
+ QVERIFY(testWidget->hasSelectedText());
+ QCOMPARE(testWidget->selectedText(), QString("Abc defg "));
+ QVERIFY(selection_count == 1);
+
+ // reset selection
+ testWidget->home(false);
+ QVERIFY(!testWidget->hasSelectedText());
+ QCOMPARE(testWidget->selectedText(), QString());
+ selection_count = 0;
+}
+
+/* // tested in selectedText
+void tst_QLineEdit::backspace()
+void tst_QLineEdit::del()
+void tst_QLineEdit::selectionChanged()
+void tst_QLineEdit::selectAll()
+void tst_QLineEdit::deselect()
+*/
+
+void tst_QLineEdit::onSelectionChanged()
+{
+ selection_count++;
+}
+
+void tst_QLineEdit::deleteSelectedText()
+{
+ const QString text = QString::fromLatin1("bar");
+ QLineEdit edit( text );
+ QCOMPARE(edit.text(), text);
+
+ edit.selectAll();
+
+ QTest::keyClick(&edit, Qt::Key_Delete, 0);
+ QVERIFY(edit.text().isEmpty());
+
+ edit.setText(text);
+ edit.selectAll();
+
+ QMenu *menu = edit.createStandardContextMenu();
+ for (int i = 0; i < menu->actions().count(); ++i) {
+ QAction *current = menu->actions().at(i);
+ if (current->text() == QLineEdit::tr("Delete")) {
+ current->trigger(); //this will delete the whole text selected
+ QVERIFY(edit.text().isEmpty());
+ }
+ }
+
+}
+
+
+void tst_QLineEdit::textChangedAndTextEdited()
+{
+ changed_count = 0;
+ edited_count = 0;
+
+ QTest::keyClick(testWidget, Qt::Key_A);
+ QCOMPARE(changed_count, 1);
+ QVERIFY(edited_count == changed_count);
+ QTest::keyClick(testWidget, 'b');
+ QCOMPARE(changed_count, 2);
+ QVERIFY(edited_count == changed_count);
+ QTest::keyClick(testWidget, 'c');
+ QCOMPARE(changed_count, 3);
+ QVERIFY(edited_count == changed_count);
+ QTest::keyClick(testWidget, ' ');
+ QCOMPARE(changed_count, 4);
+ QVERIFY(edited_count == changed_count);
+ QTest::keyClick(testWidget, 'd');
+ QCOMPARE(changed_count, 5);
+ QVERIFY(edited_count == changed_count);
+
+ changed_count = 0;
+ edited_count = 0;
+ changed_string = QString::null;
+
+ testWidget->setText("foo");
+ QCOMPARE(changed_count, 1);
+ QCOMPARE(edited_count, 0);
+ QCOMPARE(changed_string, QString("foo"));
+
+ changed_count = 0;
+ edited_count = 0;
+ changed_string = QString::null;
+
+ testWidget->setText("");
+ QCOMPARE(changed_count, 1);
+ QCOMPARE(edited_count, 0);
+ QVERIFY(changed_string.isEmpty());
+ QVERIFY(!changed_string.isNull());
+}
+
+void tst_QLineEdit::onTextChanged(const QString &text)
+{
+ changed_count++;
+ changed_string = text;
+}
+
+void tst_QLineEdit::onTextEdited(const QString &/*text*/)
+{
+ edited_count++;
+}
+
+
+void tst_QLineEdit::onCursorPositionChanged(int oldPos, int newPos)
+{
+ lastCursorPos = oldPos;
+ newCursorPos = newPos;
+}
+
+void tst_QLineEdit::returnPressed()
+{
+ return_count = 0;
+
+ QTest::keyClick(testWidget, Qt::Key_Return);
+ QVERIFY(return_count == 1);
+ return_count = 0;
+
+ QTest::keyClick(testWidget, 'A');
+ QVERIFY(return_count == 0);
+ QTest::keyClick(testWidget, 'b');
+ QVERIFY(return_count == 0);
+ QTest::keyClick(testWidget, 'c');
+ QVERIFY(return_count == 0);
+ QTest::keyClick(testWidget, ' ');
+ QVERIFY(return_count == 0);
+ QTest::keyClick(testWidget, 'd');
+ QVERIFY(return_count == 0);
+ psKeyClick(testWidget, Qt::Key_Home);
+ QVERIFY(return_count == 0);
+ psKeyClick(testWidget, Qt::Key_End);
+ QVERIFY(return_count == 0);
+ QTest::keyClick(testWidget, Qt::Key_Escape);
+ QVERIFY(return_count == 0);
+ QTest::keyClick(testWidget, Qt::Key_Return);
+ QVERIFY(return_count == 1);
+}
+
+// int validator that fixes all !isNumber to '0'
+class QIntFixValidator : public QIntValidator {
+public:
+ QIntFixValidator(int min, int max, QObject *parent) : QIntValidator(min, max, parent) {}
+ void fixup (QString &input) const {
+ for (int i=0; i<input.length(); ++i)
+ if (!input.at(i).isNumber()) {
+ input[(int)i] = QChar('0');
+ }
+ }
+};
+
+void tst_QLineEdit::returnPressed_maskvalidator_data() {
+ QTest::addColumn<QString>("inputMask");
+ QTest::addColumn<bool>("hasValidator");
+ QTest::addColumn<QTestEventList>("input");
+ QTest::addColumn<QString>("expectedText");
+ QTest::addColumn<bool>("returnPressed");
+
+ {
+ QTestEventList keys;
+ keys.addKeyClick(Qt::Key_Home);
+ keys.addKeyClick(Qt::Key_1);
+ keys.addKeyClick(Qt::Key_2);
+ keys.addKeyClick(Qt::Key_3);
+ keys.addKeyClick(Qt::Key_Return);
+ QTest::newRow("no mask, no validator, input '123<cr>'")
+ << QString()
+ << false
+ << keys
+ << QString("123")
+ << true;
+ }
+ {
+ QTestEventList keys;
+ keys.addKeyClick(Qt::Key_Home);
+ keys.addKeyClick(Qt::Key_1);
+ keys.addKeyClick(Qt::Key_2);
+ keys.addKeyClick(Qt::Key_Return);
+ QTest::newRow("mask '999', no validator, input '12<cr>'")
+ << QString("999")
+ << false
+ << keys
+ << QString("12")
+ << false;
+ }
+ {
+ QTestEventList keys;
+ keys.addKeyClick(Qt::Key_Home);
+ keys.addKeyClick(Qt::Key_1);
+ keys.addKeyClick(Qt::Key_2);
+ keys.addKeyClick(Qt::Key_3);
+ keys.addKeyClick(Qt::Key_Return);
+ QTest::newRow("mask '999', no validator, input '123<cr>'")
+ << QString("999")
+ << false
+ << keys
+ << QString("123")
+ << true;
+ }
+ {
+ QTestEventList keys;
+ keys.addKeyClick(Qt::Key_Home);
+ keys.addKeyClick(Qt::Key_1);
+ keys.addKeyClick(Qt::Key_2);
+ keys.addKeyClick(Qt::Key_3);
+ keys.addKeyClick(Qt::Key_Return);
+ QTest::newRow("no mask, intfix validator(0,999), input '123<cr>'")
+ << QString()
+ << true
+ << keys
+ << QString("123")
+ << true;
+ }
+ {
+ QTestEventList keys;
+ keys.addKeyClick(Qt::Key_Home);
+ keys.addKeyClick(Qt::Key_7);
+ keys.addKeyClick(Qt::Key_7);
+ keys.addKeyClick(Qt::Key_7);
+ keys.addKeyClick(Qt::Key_7);
+ keys.addKeyClick(Qt::Key_Return);
+ QTest::newRow("no mask, intfix validator(0,999), input '7777<cr>'")
+ << QString()
+ << true
+ << keys
+ << QString("777")
+ << true;
+ }
+ {
+ QTestEventList keys;
+ keys.addKeyClick(Qt::Key_Home);
+ keys.addKeyClick(Qt::Key_1);
+ keys.addKeyClick(Qt::Key_2);
+ keys.addKeyClick(Qt::Key_Return);
+ QTest::newRow("mask '999', intfix validator(0,999), input '12<cr>'")
+ << QString("999")
+ << true
+ << keys
+ << QString("12")
+ << false;
+ }
+ {
+ QTestEventList keys;
+ keys.addKeyClick(Qt::Key_Home);
+ keys.addKeyClick(Qt::Key_Return);
+ QTest::newRow("mask '999', intfix validator(0,999), input '<cr>'")
+ << QString("999")
+ << true
+ << keys
+ << QString("000")
+ << true;
+ }
+}
+
+void tst_QLineEdit::returnPressed_maskvalidator()
+{
+ QFETCH(QString, inputMask);
+ QFETCH(bool, hasValidator);
+ QFETCH(QTestEventList, input);
+ QFETCH(QString, expectedText);
+ QFETCH(bool, returnPressed);
+
+ QEXPECT_FAIL("mask '999', intfix validator(0,999), input '12<cr>'", "QIntValidator has changed behaviour. Does not accept spaces. Task 43082.", Abort);
+
+ testWidget->setInputMask(inputMask);
+ if (hasValidator)
+ testWidget->setValidator(new QIntFixValidator(0, 999, testWidget));
+
+ return_count = 0;
+ input.simulate(testWidget);
+
+ QCOMPARE(testWidget->text(), expectedText);
+ QCOMPARE(return_count , returnPressed ? 1 : 0);
+}
+
+void tst_QLineEdit::onReturnPressed()
+{
+ return_count++;
+}
+
+void tst_QLineEdit::setValidator()
+{
+ // Verify that we can set and re-set a validator.
+ QVERIFY(!testWidget->validator());
+
+ QIntValidator iv1(0);
+ testWidget->setValidator(&iv1);
+ QCOMPARE(testWidget->validator(), static_cast<const QValidator*>(&iv1));
+
+ testWidget->setValidator(0);
+ QVERIFY(testWidget->validator() == 0);
+
+ QIntValidator iv2(0, 99, 0);
+ testWidget->setValidator(&iv2);
+ QCOMPARE(testWidget->validator(), static_cast<const QValidator *>(&iv2));
+
+ testWidget->setValidator(0);
+ QVERIFY(testWidget->validator() == 0);
+}
+
+void tst_QLineEdit::setValidator_QIntValidator_data()
+{
+ QTest::addColumn<int>("mini");
+ QTest::addColumn<int>("maxi");
+ QTest::addColumn<QString>("input");
+ QTest::addColumn<QString>("expectedText");
+ QTest::addColumn<bool>("useKeys");
+ QTest::addColumn<bool>("is_valid");
+
+ for (int i=0; i<2; i++) {
+ bool useKeys = false;
+ QString inputMode = "insert ";
+ if (i!=0) {
+ inputMode = "useKeys ";
+ useKeys = true;
+ }
+
+ // valid data
+ QTest::newRow(QString(inputMode + "range [0,9] valid '1'").toLatin1())
+ << 0
+ << 9
+ << QString("1")
+ << QString("1")
+ << bool(useKeys)
+ << bool(true);
+
+ QTest::newRow(QString(inputMode + "range [3,7] valid '3'").toLatin1())
+ << 3
+ << 7
+ << QString("3")
+ << QString("3")
+ << bool(useKeys)
+ << bool(true);
+
+ QTest::newRow(QString(inputMode + "range [3,7] valid '7'").toLatin1())
+ << 3
+ << 7
+ << QString("7")
+ << QString("7")
+ << bool(useKeys)
+ << bool(true);
+
+ QTest::newRow(QString(inputMode + "range [0,100] valid '9'").toLatin1())
+ << 0
+ << 100
+ << QString("9")
+ << QString("9")
+ << bool(useKeys)
+ << bool(true);
+
+ QTest::newRow(QString(inputMode + "range [0,100] valid '12'").toLatin1())
+ << 0
+ << 100
+ << QString("12")
+ << QString("12")
+ << bool(useKeys)
+ << bool(true);
+
+ QTest::newRow(QString(inputMode + "range [-100,100] valid '-12'").toLatin1())
+ << -100
+ << 100
+ << QString("-12")
+ << QString("-12")
+ << bool(useKeys)
+ << bool(true);
+
+ // invalid data
+ // characters not allowed in QIntValidator
+ QTest::newRow(QString(inputMode + "range [0,9] inv 'a-a'").toLatin1())
+ << 0
+ << 9
+ << QString("a")
+ << QString("")
+ << bool(useKeys)
+ << bool(false);
+
+ QTest::newRow(QString(inputMode + "range [0,9] inv 'A'").toLatin1())
+ << 0
+ << 9
+ << QString("A")
+ << QString("")
+ << bool(useKeys)
+ << bool(false);
+ // minus sign only allowed with a range on the negative side
+ QTest::newRow(QString(inputMode + "range [0,100] inv '-'").toLatin1())
+ << 0
+ << 100
+ << QString("-")
+ << QString("")
+ << bool(useKeys)
+ << bool(false);
+ QTest::newRow(QString(inputMode + "range [0,100] int '153'").toLatin1())
+ << 0
+ << 100
+ << QString("153")
+ << QString(useKeys ? "15" : "")
+ << bool(useKeys)
+ << bool(useKeys ? true : false);
+ QTest::newRow(QString(inputMode + "range [-100,100] int '-153'").toLatin1())
+ << -100
+ << 100
+ << QString("-153")
+ << QString(useKeys ? "-15" : "")
+ << bool(useKeys)
+ << bool(useKeys ? true : false);
+ QTest::newRow(QString(inputMode + "range [3,7] int '2'").toLatin1())
+ << 3
+ << 7
+ << QString("2")
+ << QString("2")
+ << bool(useKeys)
+ << bool(false);
+
+ QTest::newRow(QString(inputMode + "range [3,7] int '8'").toLatin1())
+ << 3
+ << 7
+ << QString("8")
+ << QString("")
+ << bool(useKeys)
+ << bool(false);
+ }
+}
+
+void tst_QLineEdit::setValidator_QIntValidator()
+{
+ QFETCH(int, mini);
+ QFETCH(int, maxi);
+ QFETCH(QString, input);
+ QFETCH(QString, expectedText);
+ QFETCH(bool, useKeys);
+ QFETCH(bool, is_valid);
+
+ QIntValidator intValidator(mini, maxi, 0);
+ testWidget->setValidator(&intValidator);
+ QVERIFY(testWidget->text().isEmpty());
+//qDebug("1 input: '" + input + "' Exp: '" + expectedText + "'");
+
+ // tests valid input
+ if (!useKeys) {
+ testWidget->insert(input);
+ } else {
+ QTest::keyClicks(testWidget, input);
+ return_count = 0;
+ QTest::keyClick(testWidget, Qt::Key_Return);
+ QCOMPARE(return_count, int(is_valid)); // assuming that is_valid = true equals 1
+ }
+//qDebug("2 input: '" + input + "' Exp: '" + expectedText + "'");
+// QCOMPARE(testWidget->displayText(), expectedText);
+ QCOMPARE(testWidget->text(), expectedText);
+}
+
+#define NO_PIXMAP_TESTS
+
+void tst_QLineEdit::frame_data()
+{
+#ifndef NO_PIXMAP_TESTS
+#if defined Q_WS_WIN
+ QTest::addColumn<QPixmap>("noFrame");
+ QTest::addColumn<QPixmap>("useFrame");
+
+ QTest::newRow("win");
+//#else
+// QTest::newRow("x11");
+#endif
+#endif
+}
+
+void tst_QLineEdit::frame()
+{
+ testWidget->setFrame(false);
+ // verify that the editor is shown without a frame
+#ifndef NO_PIXMAP_TESTS
+#if defined Q_WS_WIN
+ QTEST(testWidget, "noFrame");
+#endif
+#endif
+ QVERIFY(!testWidget->hasFrame());
+
+ testWidget->setFrame(true);
+ // verify that the editor is shown with a frame
+#ifndef NO_PIXMAP_TESTS
+#if defined Q_WS_WIN
+ QTEST(testWidget, "useFrame");
+#endif
+#endif
+ QVERIFY(testWidget->hasFrame());
+}
+
+void tst_QLineEdit::setAlignment_data()
+{
+#ifndef NO_PIXMAP_TESTS
+#if defined Q_WS_WIN
+ QTest::addColumn<QPixmap>("left");
+ QTest::addColumn<QPixmap>("right");
+ QTest::addColumn<QPixmap>("hcenter");
+ QTest::addColumn<QPixmap>("auto");
+
+ QTest::newRow("win");
+//#else
+// QTest::newRow("x11");
+#endif
+#endif
+}
+
+void tst_QLineEdit::setAlignment()
+{
+ testWidget->setText("left");
+ testWidget->setAlignment(Qt::AlignLeft);
+#ifndef NO_PIXMAP_TESTS
+#if defined Q_WS_WIN
+ QTEST(testWidget, "left");
+#endif
+#endif
+ QVERIFY(testWidget->alignment() == Qt::AlignLeft);
+
+ testWidget->setText("hcenter");
+ testWidget->setAlignment(Qt::AlignHCenter);
+#ifndef NO_PIXMAP_TESTS
+#if defined Q_WS_WIN
+ QTEST(testWidget, "hcenter");
+#endif
+#endif
+ QVERIFY(testWidget->alignment() == Qt::AlignHCenter);
+
+ testWidget->setText("right");
+ testWidget->setAlignment(Qt::AlignRight);
+#ifndef NO_PIXMAP_TESTS
+#if defined Q_WS_WIN
+ QTEST(testWidget, "right");
+#endif
+#endif
+ QVERIFY(testWidget->alignment() == Qt::AlignRight);
+
+ testWidget->setAlignment(Qt::AlignTop);
+ QVERIFY(testWidget->alignment() == Qt::AlignTop);
+
+ testWidget->setAlignment(Qt::AlignBottom);
+ QVERIFY(testWidget->alignment() == Qt::AlignBottom);
+
+ testWidget->setAlignment(Qt::AlignCenter);
+ QVERIFY(testWidget->alignment() == Qt::AlignCenter);
+}
+
+void tst_QLineEdit::isModified()
+{
+ QVERIFY(!testWidget->isModified());
+ testWidget->setText("bla");
+ QVERIFY(!testWidget->isModified());
+
+ psKeyClick(testWidget, Qt::Key_Home);
+ QVERIFY(!testWidget->isModified());
+ QTest::keyClick(testWidget, Qt::Key_Right);
+ QVERIFY(!testWidget->isModified());
+ QTest::keyClick(testWidget, Qt::Key_Right);
+ QVERIFY(!testWidget->isModified());
+ QTest::keyClick(testWidget, Qt::Key_Right);
+ QVERIFY(!testWidget->isModified());
+ QTest::keyClick(testWidget, Qt::Key_Left);
+ QVERIFY(!testWidget->isModified());
+ psKeyClick(testWidget, Qt::Key_End);
+ QVERIFY(!testWidget->isModified());
+
+ QTest::keyClicks(testWidget, "T");
+ QVERIFY(testWidget->isModified());
+ QTest::keyClicks(testWidget, "his is a string");
+ QVERIFY(testWidget->isModified());
+
+ testWidget->setText("");
+ QVERIFY(!testWidget->isModified());
+ testWidget->setText("foo");
+ QVERIFY(!testWidget->isModified());
+}
+
+/*
+ Obsolete function but as long as we provide it, it needs to work.
+*/
+
+void tst_QLineEdit::edited()
+{
+ QVERIFY(!testWidget->isModified());
+ testWidget->setText("bla");
+ QVERIFY(!testWidget->isModified());
+
+ psKeyClick(testWidget, Qt::Key_Home);
+ QVERIFY(!testWidget->isModified());
+ QTest::keyClick(testWidget, Qt::Key_Right);
+ QVERIFY(!testWidget->isModified());
+ QTest::keyClick(testWidget, Qt::Key_Right);
+ QVERIFY(!testWidget->isModified());
+ QTest::keyClick(testWidget, Qt::Key_Right);
+ QVERIFY(!testWidget->isModified());
+ QTest::keyClick(testWidget, Qt::Key_Left);
+ QVERIFY(!testWidget->isModified());
+ psKeyClick(testWidget, Qt::Key_End);
+ QVERIFY(!testWidget->isModified());
+
+ QTest::keyClicks(testWidget, "T");
+ QVERIFY(testWidget->isModified());
+ QTest::keyClicks(testWidget, "his is a string");
+ QVERIFY(testWidget->isModified());
+
+ testWidget->setModified(false);
+ QVERIFY(!testWidget->isModified());
+
+ testWidget->setModified(true);
+ QVERIFY(testWidget->isModified());
+}
+
+void tst_QLineEdit::insert()
+{
+ testWidget->insert("This");
+ testWidget->insert(" is");
+ testWidget->insert(" a");
+ testWidget->insert(" test");
+
+ QCOMPARE(testWidget->text(), QString("This is a test"));
+
+ testWidget->cursorWordBackward(false);
+ testWidget->cursorBackward(false, 1);
+ testWidget->insert(" nice");
+ QCOMPARE(testWidget->text(), QString("This is a nice test"));
+
+ testWidget->setCursorPosition(-1);
+ testWidget->insert("No Crash! ");
+ QCOMPARE(testWidget->text(), QString("No Crash! This is a nice test"));
+}
+
+void tst_QLineEdit::setSelection_data()
+{
+ QTest::addColumn<QString>("text");
+ QTest::addColumn<int>("start");
+ QTest::addColumn<int>("length");
+ QTest::addColumn<int>("expectedCursor");
+ QTest::addColumn<QString>("expectedText");
+ QTest::addColumn<bool>("expectedHasSelectedText");
+
+ QString text = "Abc defg hijklmno, p 'qrst' uvw xyz";
+ int start, length, pos;
+
+ start = 0; length = 1; pos = 1;
+ QTest::newRow(QString("selection start: %1 length: %2").arg(start).arg(length).toLatin1())
+ << text << start << length << pos << QString("A") << true;
+
+ start = 0; length = 2; pos = 2;
+ QTest::newRow(QString("selection start: %1 length: %2").arg(start).arg(length).toLatin1())
+ << text << start << length << pos << QString("Ab") << true;
+
+ start = 0; length = 4; pos = 4;
+ QTest::newRow(QString("selection start: %1 length: %2").arg(start).arg(length).toLatin1())
+ << text << start << length << pos << QString("Abc ") << true;
+
+ start = -1; length = 0; pos = text.length();
+ QTest::newRow(QString("selection start: %1 length: %2").arg(start).arg(length).toLatin1())
+ << text << start << length << pos << QString() << false;
+
+ start = 34; length = 1; pos = 35;
+ QTest::newRow(QString("selection start: %1 length: %2").arg(start).arg(length).toLatin1())
+ << text << start << length << pos << QString("z") << true;
+
+ start = 34; length = 2; pos = 35;
+ QTest::newRow(QString("selection start: %1 length: %2").arg(start).arg(length).toLatin1())
+ << text << start << length << pos << QString("z") << true;
+
+ start = 34; length = -1; pos = 33;
+ QTest::newRow(QString("selection start: %1 length: %2").arg(start).arg(length).toLatin1())
+ << text << start << length << pos << QString("y") << true;
+
+ start = 1; length = -2; pos = 0;
+ QTest::newRow(QString("selection start: %1 length: %2").arg(start).arg(length).toLatin1())
+ << text << start << length << pos << QString("A") << true;
+
+ start = -1; length = -1; pos = text.length();
+ QTest::newRow(QString("selection start: %1 length: %2").arg(start).arg(length).toLatin1())
+ << text << start << length << pos << QString() << false;
+}
+
+
+void tst_QLineEdit::setSelection()
+{
+ QFETCH(QString, text);
+ QFETCH(int, start);
+ QFETCH(int, length);
+ QFETCH(int, expectedCursor);
+ QFETCH(QString, expectedText);
+ QFETCH(bool, expectedHasSelectedText);
+
+ testWidget->setText(text);
+ testWidget->setSelection(start, length);
+ QCOMPARE(testWidget->hasSelectedText(), expectedHasSelectedText);
+ QCOMPARE(testWidget->selectedText(), expectedText);
+ if (expectedCursor >= 0)
+ QCOMPARE(testWidget->cursorPosition(), expectedCursor);
+}
+
+#ifndef QT_NO_CLIPBOARD
+void tst_QLineEdit::cut()
+{
+#ifdef Q_WS_MAC
+ {
+ PasteboardRef pasteboard;
+ OSStatus status = PasteboardCreate(0, &pasteboard);
+ if (status == noErr)
+ CFRelease(pasteboard);
+ else
+ QSKIP("Autotests run from cron and pasteboard don't get along quite ATM", SkipAll);
+ }
+#endif
+ // test newlines in cut'n'paste
+ testWidget->setText("A\nB\nC\n");
+ testWidget->setSelection(0, 6);
+ testWidget->cut();
+ psKeyClick(testWidget, Qt::Key_Home);
+ testWidget->paste();
+ QCOMPARE(testWidget->text(), QString("A\nB\nC\n"));
+ // 1 2 3 4
+ // 01234567890123456789012345678901234567890
+ testWidget->setText("Abc defg hijklmno");
+
+ testWidget->setSelection(0, 3);
+ testWidget->cut();
+ QCOMPARE(testWidget->text(), QString(" defg hijklmno"));
+
+ psKeyClick(testWidget, Qt::Key_End);
+ testWidget->paste();
+ QCOMPARE(testWidget->text(), QString(" defg hijklmnoAbc"));
+
+ psKeyClick(testWidget, Qt::Key_Home);
+ testWidget->del();
+ QCOMPARE(testWidget->text(), QString("defg hijklmnoAbc"));
+
+ testWidget->setSelection(0, 4);
+ testWidget->copy();
+ psKeyClick(testWidget, Qt::Key_End);
+ testWidget->paste();
+ QCOMPARE(testWidget->text(), QString("defg hijklmnoAbcdefg"));
+
+ QTest::keyClick(testWidget, Qt::Key_Left);
+ QTest::keyClick(testWidget, Qt::Key_Left);
+ QTest::keyClick(testWidget, Qt::Key_Left);
+ QTest::keyClick(testWidget, Qt::Key_Left);
+ QTest::keyClick(testWidget, Qt::Key_Left);
+ QTest::keyClick(testWidget, Qt::Key_Left);
+ QTest::keyClick(testWidget, Qt::Key_Left);
+ QTest::keyClick(testWidget, ' ');
+ QCOMPARE(testWidget->text(), QString("defg hijklmno Abcdefg"));
+
+ testWidget->setSelection(0, 5);
+ testWidget->del();
+ QCOMPARE(testWidget->text(), QString("hijklmno Abcdefg"));
+
+ testWidget->end(false);
+ QTest::keyClick(testWidget, ' ');
+ testWidget->paste();
+ QCOMPARE(testWidget->text(), QString("hijklmno Abcdefg defg"));
+
+ testWidget->home(false);
+ testWidget->cursorWordForward(true);
+ testWidget->cut();
+ testWidget->end(false);
+ QTest::keyClick(testWidget, ' ');
+ testWidget->paste();
+ testWidget->cursorBackward(true, 1);
+ testWidget->cut();
+ QCOMPARE(testWidget->text(), QString("Abcdefg defg hijklmno"));
+}
+#endif
+
+class InputMaskValidator : public QValidator
+{
+public:
+ InputMaskValidator(QObject *parent, const char *name = 0) : QValidator(parent) { setObjectName(name); }
+ State validate(QString &text, int &pos) const
+ {
+ InputMaskValidator *that = (InputMaskValidator *)this;
+ that->validateText = text;
+ that->validatePos = pos;
+ return Acceptable;
+ }
+ QString validateText;
+ int validatePos;
+};
+
+void tst_QLineEdit::inputMaskAndValidator_data()
+{
+ QTest::addColumn<QString>("inputMask");
+ QTest::addColumn<QTestEventList>("keys");
+ QTest::addColumn<QString>("validateText");
+ QTest::addColumn<int>("validatePos");
+
+ QTestEventList inputKeys;
+ inputKeys.addKeyClick(Qt::Key_1);
+ inputKeys.addKeyClick(Qt::Key_2);
+
+ QTest::newRow("task28291") << "000;_" << inputKeys << "12_" << 2;
+}
+
+void tst_QLineEdit::inputMaskAndValidator()
+{
+ QFETCH(QString, inputMask);
+ QFETCH(QTestEventList, keys);
+ QFETCH(QString, validateText);
+ QFETCH(int, validatePos);
+
+ InputMaskValidator imv(testWidget);
+ testWidget->setValidator(&imv);
+
+ testWidget->setInputMask(inputMask);
+ keys.simulate(testWidget);
+
+ QCOMPARE(imv.validateText, validateText);
+ QCOMPARE(imv.validatePos, validatePos);
+}
+
+void tst_QLineEdit::maxLengthAndInputMask()
+{
+ // Really a test for #30447
+ QVERIFY(testWidget->inputMask().isNull());
+ testWidget->setMaxLength(10);
+ QVERIFY(testWidget->maxLength() == 10);
+ testWidget->setInputMask(QString::null);
+ QVERIFY(testWidget->inputMask().isNull());
+ QVERIFY(testWidget->maxLength() == 10);
+}
+
+
+class LineEdit : public QLineEdit
+{
+public:
+ LineEdit() { state = Other; }
+
+ void keyPressEvent(QKeyEvent *e)
+ {
+ QLineEdit::keyPressEvent(e);
+ if (e->key() == Qt::Key_Enter) {
+ state = e->isAccepted() ? Accepted : Ignored;
+ } else {
+ state = Other;
+ }
+
+ }
+ enum State {
+ Accepted,
+ Ignored,
+ Other
+ };
+
+ State state;
+
+ friend class tst_QLineEdit;
+};
+
+Q_DECLARE_METATYPE(LineEdit::State);
+void tst_QLineEdit::returnPressedKeyEvent()
+{
+ LineEdit lineedit;
+ lineedit.show();
+ QCOMPARE((int)lineedit.state, (int)LineEdit::Other);
+ QTest::keyClick(&lineedit, Qt::Key_Enter);
+ QCOMPARE((int)lineedit.state, (int)LineEdit::Ignored);
+ connect(&lineedit, SIGNAL(returnPressed()), this, SLOT(onReturnPressed()));
+ QTest::keyClick(&lineedit, Qt::Key_Enter);
+ QCOMPARE((int)lineedit.state, (int)LineEdit::Ignored);
+ disconnect(&lineedit, SIGNAL(returnPressed()), this, SLOT(onReturnPressed()));
+ QTest::keyClick(&lineedit, Qt::Key_Enter);
+ QCOMPARE((int)lineedit.state, (int)LineEdit::Ignored);
+ QTest::keyClick(&lineedit, Qt::Key_1);
+ QCOMPARE((int)lineedit.state, (int)LineEdit::Other);
+}
+
+void tst_QLineEdit::keepSelectionOnTabFocusIn()
+{
+ testWidget->setText("hello world");
+ {
+ QFocusEvent e(QEvent::FocusIn, Qt::TabFocusReason);
+ QApplication::sendEvent(testWidget, &e);
+ }
+ QCOMPARE(testWidget->selectedText(), QString("hello world"));
+ testWidget->setSelection(0, 5);
+ QCOMPARE(testWidget->selectedText(), QString("hello"));
+ {
+ QFocusEvent e(QEvent::FocusIn, Qt::TabFocusReason);
+ QApplication::sendEvent(testWidget, &e);
+ }
+ QCOMPARE(testWidget->selectedText(), QString("hello"));
+}
+
+void tst_QLineEdit::readOnlyStyleOption()
+{
+ bool wasReadOnly = testWidget->isReadOnly();
+ QStyle *oldStyle = testWidget->style();
+
+ StyleOptionTestStyle myStyle;
+ testWidget->setStyle(&myStyle);
+
+ myStyle.setReadOnly(true);
+ testWidget->setReadOnly(true);
+ testWidget->repaint();
+ qApp->processEvents();
+
+ testWidget->setReadOnly(false);
+ myStyle.setReadOnly(false);
+ testWidget->repaint();
+ qApp->processEvents();
+
+ testWidget->setReadOnly(wasReadOnly);
+ testWidget->setStyle(oldStyle);
+}
+
+void tst_QLineEdit::validateOnFocusOut()
+{
+ QSignalSpy editingFinishedSpy(testWidget, SIGNAL(editingFinished()));
+ testWidget->setValidator(new QIntValidator(100, 999, 0));
+ QTest::keyPress(testWidget, '1');
+ QTest::keyPress(testWidget, '0');
+ QCOMPARE(testWidget->text(), QString("10"));
+ testWidget->clearFocus();
+ QCOMPARE(editingFinishedSpy.count(), 0);
+
+ testWidget->setFocus();
+ testWidget->activateWindow();
+ QTRY_VERIFY(testWidget->hasFocus());
+
+ QTest::keyPress(testWidget, '0');
+ QTRY_COMPARE(testWidget->text(), QString("100"));
+
+ testWidget->clearFocus();
+ QCOMPARE(editingFinishedSpy.count(), 1);
+}
+
+void tst_QLineEdit::editInvalidText()
+{
+ testWidget->clear();
+ testWidget->setValidator(new QIntValidator(0, 120, 0));
+ testWidget->setText("1234");
+
+ QVERIFY(!testWidget->hasAcceptableInput());
+ QTest::keyPress(testWidget, Qt::Key_Backspace);
+ QTest::keyPress(testWidget, Qt::Key_Backspace);
+ QTest::keyPress(testWidget, Qt::Key_A);
+ QTest::keyPress(testWidget, Qt::Key_B);
+ QTest::keyPress(testWidget, Qt::Key_C);
+ QTest::keyPress(testWidget, Qt::Key_1);
+ QVERIFY(testWidget->hasAcceptableInput());
+ QCOMPARE(testWidget->text(), QString("12"));
+ testWidget->cursorBackward(false);
+ testWidget->cursorBackward(true, 2);
+ QTest::keyPress(testWidget, Qt::Key_Delete);
+ QVERIFY(testWidget->hasAcceptableInput());
+ QCOMPARE(testWidget->text(), QString("2"));
+ QTest::keyPress(testWidget, Qt::Key_1);
+ QVERIFY(testWidget->hasAcceptableInput());
+ QCOMPARE(testWidget->text(), QString("12"));
+
+ testWidget->setValidator(0);
+}
+
+void tst_QLineEdit::charWithAltOrCtrlModifier()
+{
+ testWidget->clear();
+ QCOMPARE(testWidget->text(), QString(""));
+ QTest::keyPress(testWidget, Qt::Key_Plus);
+ QCOMPARE(testWidget->text(), QString("+"));
+ QTest::keyPress(testWidget, Qt::Key_Plus, Qt::ControlModifier);
+ QCOMPARE(testWidget->text(), QString("++"));
+ QTest::keyPress(testWidget, Qt::Key_Plus, Qt::AltModifier);
+ QCOMPARE(testWidget->text(), QString("+++"));
+ QTest::keyPress(testWidget, Qt::Key_Plus, Qt::AltModifier | Qt::ControlModifier);
+ QCOMPARE(testWidget->text(), QString("++++"));
+}
+
+void tst_QLineEdit::leftKeyOnSelectedText()
+{
+ testWidget->clear();
+ testWidget->setText("0123");
+ testWidget->setCursorPosition(4);
+ QTest::keyClick(testWidget, Qt::Key_Left, Qt::ShiftModifier);
+ QCOMPARE(testWidget->cursorPosition(), 3);
+ QCOMPARE(testWidget->selectedText(), QString("3"));
+ QTest::keyClick(testWidget, Qt::Key_Left, Qt::ShiftModifier);
+ QCOMPARE(testWidget->cursorPosition(), 2);
+ QCOMPARE(testWidget->selectedText(), QString("23"));
+ QTest::keyClick(testWidget, Qt::Key_Left);
+#ifdef Q_OS_WIN
+ QCOMPARE(testWidget->cursorPosition(), 1);
+#else
+ // X11 used to behave like window prior to 4.2. Changes caused by QKeySequence
+ // resulted in an inadvertant change in behavior
+ QCOMPARE(testWidget->cursorPosition(), 2);
+#endif
+}
+
+void tst_QLineEdit::inlineCompletion()
+{
+ testWidget->clear();
+ QStandardItemModel *model = new QStandardItemModel;
+ QStandardItem *root = model->invisibleRootItem();
+ QStandardItem *items[5];
+ for (int i = 0; i < 5; i++) {
+ items[i] = new QStandardItem(QString("item%1").arg(i));
+ if ((i+2)%2 == 0) { // disable 0,2,4
+ items[i]->setFlags(items[i]->flags() & ~Qt::ItemIsEnabled);
+ }
+ root->appendRow(items[i]);
+ }
+ QCompleter *completer = new QCompleter(model);
+ completer->setCompletionMode(QCompleter::InlineCompletion);
+ completer->setCaseSensitivity(Qt::CaseInsensitive);
+ testWidget->setFocus();
+ QTRY_COMPARE(qApp->activeWindow(), (QWidget*)testWidget);
+ testWidget->setCompleter(completer);
+
+ // sanity
+ QTest::keyClick(testWidget, Qt::Key_X);
+ QCOMPARE(testWidget->selectedText(), QString());
+ QCOMPARE(testWidget->text(), QString("x"));
+ QTest::keyClick(testWidget, Qt::Key_Down, Qt::ControlModifier);
+ QCOMPARE(testWidget->selectedText(), QString());
+ QCOMPARE(testWidget->text(), QString("x"));
+ QTest::keyClick(testWidget, Qt::Key_Up, Qt::ControlModifier);
+ QCOMPARE(testWidget->selectedText(), QString());
+ QCOMPARE(testWidget->text(), QString("x"));
+
+ testWidget->clear();
+ QTest::keyClick(testWidget, Qt::Key_I);
+ QCOMPARE(testWidget->selectedText(), QString("tem1"));
+
+ Qt::KeyboardModifiers keyboardModifiers = Qt::ControlModifier;
+#ifdef Q_WS_MAC
+ keyboardModifiers |= Qt::AltModifier;
+#endif
+ QTest::keyClick(testWidget, Qt::Key_Down, keyboardModifiers);
+ QCOMPARE(testWidget->selectedText(), QString("tem3"));
+
+ // wraps around (Default)
+ QTest::keyClick(testWidget, Qt::Key_Down, keyboardModifiers);
+ QCOMPARE(testWidget->selectedText(), QString("tem1"));
+
+ QTest::keyClick(testWidget, Qt::Key_Up, keyboardModifiers);
+ QCOMPARE(testWidget->selectedText(), QString("tem3"));
+
+ // should not wrap
+ completer->setWrapAround(false);
+ QTest::keyClick(testWidget, Qt::Key_Down, keyboardModifiers);
+ QCOMPARE(testWidget->selectedText(), QString("tem3"));
+ QTest::keyClick(testWidget, Qt::Key_Up, keyboardModifiers); // item1
+ QTest::keyClick(testWidget, Qt::Key_Up, keyboardModifiers); // item1
+ QCOMPARE(testWidget->selectedText(), QString("tem1"));
+
+ // trivia :)
+ root->appendRow(new QStandardItem("item11"));
+ root->appendRow(new QStandardItem("item12"));
+ testWidget->clear();
+ QTest::keyClick(testWidget, Qt::Key_I);
+ QCOMPARE(testWidget->selectedText(), QString("tem1"));
+ QTest::keyClick(testWidget, Qt::Key_Delete);
+ QCOMPARE(testWidget->selectedText(), QString());
+ QTest::keyClick(testWidget, Qt::Key_Down, keyboardModifiers);
+ QCOMPARE(testWidget->selectedText(), QString("tem1")); // neato
+ testWidget->setText("item1");
+ testWidget->setSelection(1, 2);
+ QTest::keyClick(testWidget, Qt::Key_Down, keyboardModifiers);
+ testWidget->end(false);
+ QCOMPARE(testWidget->text(), QString("item1")); // no effect for selection in "middle"
+ QTest::keyClick(testWidget, Qt::Key_Down, keyboardModifiers); // item1
+ QTest::keyClick(testWidget, Qt::Key_Down, keyboardModifiers); // item11
+ QCOMPARE(testWidget->text(), QString("item11"));
+
+ delete model;
+ delete completer;
+}
+
+void tst_QLineEdit::noTextEditedOnClear()
+{
+ testWidget->setText("Test");
+ QSignalSpy textEditedSpy(testWidget, SIGNAL(textEdited(const QString &)));
+ testWidget->clear();
+ QCOMPARE(textEditedSpy.count(), 0);
+}
+
+void tst_QLineEdit::textMargin_data()
+{
+ QTest::addColumn<int>("left");
+ QTest::addColumn<int>("top");
+ QTest::addColumn<int>("right");
+ QTest::addColumn<int>("bottom");
+
+ QTest::addColumn<QPoint>("mousePressPos");
+ QTest::addColumn<int>("cursorPosition");
+
+ QLineEdit testWidget;
+ QFontMetrics metrics(testWidget.font());
+ const QString s = QLatin1String("MMM MMM MMM");
+
+ // Different styles generate different offsets, so
+ // calculate the width rather than hardcode it.
+ const int pixelWidthOfM = metrics.width(s, 1);
+ const int pixelWidthOfMMM_MM = metrics.width(s, 6);
+
+ QTest::newRow("default-0") << 0 << 0 << 0 << 0 << QPoint(pixelWidthOfMMM_MM, 0) << 6;
+ QTest::newRow("default-1") << 0 << 0 << 0 << 0 << QPoint(1, 1) << 0;
+ QTest::newRow("default-2") << -1 << 0 << -1 << 0 << QPoint(pixelWidthOfMMM_MM, 0) << 6;
+ QTest::newRow("default-3") << 0 << 0 << 0 << 0 << QPoint(pixelWidthOfM, 1) << 1;
+
+ QTest::newRow("hor-0") << 10 << 0 << 10 << 0 << QPoint(1, 1) << 0;
+ QTest::newRow("hor-1") << 10 << 0 << 10 << 0 << QPoint(10, 1) << 0;
+ QTest::newRow("hor-2") << 20 << 0 << 10 << 0 << QPoint(20, 1) << 0;
+
+ if (!qApp->style()->inherits("QMacStyle")) { //MacStyle doesn't support verticals margins.
+ QTest::newRow("default-2-ver") << -1 << -1 << -1 << -1 << QPoint(pixelWidthOfMMM_MM, 0) << 6;
+ QTest::newRow("ver") << 0 << 10 << 0 << 10 << QPoint(1, 1) << 0;
+ }
+}
+
+void tst_QLineEdit::textMargin()
+{
+ QFETCH(int, left);
+ QFETCH(int, top);
+ QFETCH(int, right);
+ QFETCH(int, bottom);
+ QFETCH(QPoint, mousePressPos);
+ QFETCH(int, cursorPosition);
+
+ // Put the line edit into a toplevel window to avoid
+ // resizing by the window system.
+ QWidget tlw;
+ QLineEdit testWidget(&tlw);
+ testWidget.setGeometry(100, 100, 100, 30);
+ testWidget.setText("MMM MMM MMM");
+ testWidget.setCursorPosition(6);
+
+ QSize sizeHint = testWidget.sizeHint();
+ testWidget.setTextMargins(left, top, right, bottom);
+ sizeHint.setWidth(sizeHint.width() + left + right);
+ sizeHint.setHeight(sizeHint.height() + top +bottom);
+ QCOMPARE(testWidget.sizeHint(), sizeHint);
+ testWidget.setFrame(false);
+ tlw.show();
+
+ int l;
+ int t;
+ int r;
+ int b;
+ testWidget.getTextMargins(&l, &t, &r, &b);
+ QCOMPARE(left, l);
+ QCOMPARE(top, t);
+ QCOMPARE(right, r);
+ QCOMPARE(bottom, b);
+
+ QTest::mouseClick(&testWidget, Qt::LeftButton, 0, mousePressPos);
+ QTRY_COMPARE(testWidget.cursorPosition(), cursorPosition);
+}
+
+#ifndef QT_NO_CURSOR
+void tst_QLineEdit::cursor()
+{
+ testWidget->setReadOnly(false);
+ QCOMPARE(testWidget->cursor().shape(), Qt::IBeamCursor);
+ testWidget->setReadOnly(true);
+ QCOMPARE(testWidget->cursor().shape(), Qt::ArrowCursor);
+ testWidget->setReadOnly(false);
+ QCOMPARE(testWidget->cursor().shape(), Qt::IBeamCursor);
+}
+#endif
+
+class task180999_Widget : public QWidget
+{
+public:
+ task180999_Widget(QWidget *parent = 0) : QWidget(parent)
+ {
+ QHBoxLayout *layout = new QHBoxLayout(this);
+ lineEdit1.setText("some text 1 ...");
+ lineEdit2.setText("some text 2 ...");
+ layout->addWidget(&lineEdit1);
+ layout->addWidget(&lineEdit2);
+ }
+
+ QLineEdit lineEdit1;
+ QLineEdit lineEdit2;
+};
+
+void tst_QLineEdit::task180999_focus()
+{
+ task180999_Widget widget;
+
+ widget.lineEdit1.setFocus();
+ widget.show();
+
+ widget.lineEdit2.setFocus();
+ widget.lineEdit2.selectAll();
+ widget.hide();
+
+ widget.lineEdit1.setFocus();
+ widget.show();
+ QTest::qWait(200);
+ widget.activateWindow();
+
+ QTRY_VERIFY(!widget.lineEdit2.hasSelectedText());
+}
+
+void tst_QLineEdit::task174640_editingFinished()
+{
+ QWidget mw;
+ QVBoxLayout *layout = new QVBoxLayout(&mw);
+ QLineEdit *le1 = new QLineEdit(&mw);
+ QLineEdit *le2 = new QLineEdit(&mw);
+ layout->addWidget(le1);
+ layout->addWidget(le2);
+
+ mw.show();
+ QApplication::setActiveWindow(&mw);
+ mw.activateWindow();
+ QTest::qWaitForWindowShown(&mw);
+ QTRY_COMPARE(&mw, QApplication::activeWindow());
+
+ QSignalSpy editingFinishedSpy(le1, SIGNAL(editingFinished()));
+
+ le1->setFocus();
+ QTest::qWait(20);
+ QTRY_VERIFY(le1->hasFocus());
+ QCOMPARE(editingFinishedSpy.count(), 0);
+
+ le2->setFocus();
+ QTest::qWait(20);
+ QTRY_VERIFY(le2->hasFocus());
+ QCOMPARE(editingFinishedSpy.count(), 1);
+ editingFinishedSpy.clear();
+
+ le1->setFocus();
+ QTest::qWait(20);
+ QTRY_VERIFY(le1->hasFocus());
+
+ QMenu *testMenu1 = new QMenu(le1);
+ testMenu1->addAction("foo");
+ testMenu1->addAction("bar");
+ testMenu1->show();
+ QTest::qWaitForWindowShown(testMenu1);
+ QTest::qWait(20);
+ mw.activateWindow();
+
+ delete testMenu1;
+ QCOMPARE(editingFinishedSpy.count(), 0);
+ QTRY_VERIFY(le1->hasFocus());
+
+ QMenu *testMenu2 = new QMenu(le2);
+ testMenu2->addAction("foo2");
+ testMenu2->addAction("bar2");
+ testMenu2->show();
+ QTest::qWaitForWindowShown(testMenu2);
+ QTest::qWait(20);
+ mw.activateWindow();
+ delete testMenu2;
+ QCOMPARE(editingFinishedSpy.count(), 1);
+}
+
+#ifndef QT_NO_COMPLETER
+class task198789_Widget : public QWidget
+{
+ Q_OBJECT
+public:
+ task198789_Widget(QWidget *parent = 0) : QWidget(parent)
+ {
+ QStringList wordList;
+ wordList << "alpha" << "omega" << "omicron" << "zeta";
+
+ lineEdit = new QLineEdit(this);
+ completer = new QCompleter(wordList, this);
+ lineEdit->setCompleter(completer);
+
+ connect(lineEdit, SIGNAL(textChanged(QString)), this, SLOT(textChanged(QString)));
+ }
+
+ QLineEdit *lineEdit;
+ QCompleter *completer;
+ QString currentCompletion;
+
+private slots:
+ void textChanged(const QString &)
+ {
+ currentCompletion = completer->currentCompletion();
+ }
+};
+
+void tst_QLineEdit::task198789_currentCompletion()
+{
+ task198789_Widget widget;
+ widget.show();
+ qApp->processEvents();
+ QTest::keyPress(widget.lineEdit, 'o');
+ QTest::keyPress(widget.lineEdit, 'm');
+ QTest::keyPress(widget.lineEdit, 'i');
+ QCOMPARE(widget.currentCompletion, QLatin1String("omicron"));
+}
+
+void tst_QLineEdit::task210502_caseInsensitiveInlineCompletion()
+{
+ QString completion("ABCD");
+ QStringList completions;
+ completions << completion;
+ QLineEdit lineEdit;
+ QCompleter completer(completions);
+ completer.setCaseSensitivity(Qt::CaseInsensitive);
+ completer.setCompletionMode(QCompleter::InlineCompletion);
+ lineEdit.setCompleter(&completer);
+ lineEdit.show();
+ QTest::qWaitForWindowShown(&lineEdit);
+ QApplication::setActiveWindow(&lineEdit);
+ lineEdit.setFocus();
+ QTRY_VERIFY(lineEdit.hasFocus());
+ QTest::keyPress(&lineEdit, 'a');
+ QTest::keyPress(&lineEdit, Qt::Key_Return);
+ QCOMPARE(lineEdit.text(), completion);
+}
+
+#endif // QT_NO_COMPLETER
+
+
+void tst_QLineEdit::task229938_dontEmitChangedWhenTextIsNotChanged()
+{
+ QLineEdit lineEdit;
+ lineEdit.setMaxLength(5);
+ lineEdit.show();
+#ifdef Q_WS_X11
+ // to be safe and avoid failing setFocus with window managers
+ qt_x11_wait_for_window_manager(&lineEdit);
+#endif
+ lineEdit.setFocus();
+ QSignalSpy changedSpy(&lineEdit, SIGNAL(textChanged(QString)));
+ QTest::qWait(200);
+ QTest::keyPress(&lineEdit, 'a');
+ QTest::keyPress(&lineEdit, 'b');
+ QTest::keyPress(&lineEdit, 'c');
+ QTest::keyPress(&lineEdit, 'd');
+ QTest::keyPress(&lineEdit, 'e');
+ QTest::keyPress(&lineEdit, 'f');
+ QCOMPARE(changedSpy.count(), 5);
+}
+
+void tst_QLineEdit::task233101_cursorPosAfterInputMethod_data()
+{
+ QTest::addColumn<int>("maxLength");
+ QTest::addColumn<int>("cursorPos");
+ QTest::addColumn<int>("replacementStart");
+ QTest::addColumn<int>("replacementLength");
+ QTest::addColumn<QString>("commitString");
+
+ QTest::newRow("") << 4 << 4 << 0 << 0 << QString("");
+ QTest::newRow("") << 4 << 4 << 0 << 0 << QString("x");
+ QTest::newRow("") << 4 << 4 << 0 << 0 << QString("xxxxxxxxxxxxxxxx");
+ QTest::newRow("") << 4 << 3 << 0 << 0 << QString("");
+ QTest::newRow("") << 4 << 3 << 0 << 0 << QString("x");
+ QTest::newRow("") << 4 << 3 << 0 << 0 << QString("xxxxxxxxxxxxxxxx");
+ QTest::newRow("") << 4 << 0 << 0 << 0 << QString("");
+ QTest::newRow("") << 4 << 0 << 0 << 0 << QString("x");
+ QTest::newRow("") << 4 << 0 << 0 << 0 << QString("xxxxxxxxxxxxxxxx");
+
+ QTest::newRow("") << 4 << 4 << -4 << 4 << QString("");
+ QTest::newRow("") << 4 << 4 << -4 << 4 << QString("x");
+ QTest::newRow("") << 4 << 4 << -4 << 4 << QString("xxxxxxxxxxxxxxxx");
+ QTest::newRow("") << 4 << 3 << -3 << 4 << QString("");
+ QTest::newRow("") << 4 << 3 << -3 << 4 << QString("x");
+ QTest::newRow("") << 4 << 3 << -3 << 4 << QString("xxxxxxxxxxxxxxxx");
+ QTest::newRow("") << 4 << 0 << 0 << 4 << QString("");
+ QTest::newRow("") << 4 << 0 << 0 << 4 << QString("x");
+ QTest::newRow("") << 4 << 0 << 0 << 4 << QString("xxxxxxxxxxxxxxxx");
+
+ QTest::newRow("") << 4 << 4 << -4 << 0 << QString("");
+ QTest::newRow("") << 4 << 4 << -4 << 0 << QString("x");
+ QTest::newRow("") << 4 << 4 << -4 << 0 << QString("xxxxxxxxxxxxxxxx");
+ QTest::newRow("") << 4 << 3 << -3 << 0 << QString("");
+ QTest::newRow("") << 4 << 3 << -3 << 0 << QString("x");
+ QTest::newRow("") << 4 << 3 << -3 << 0 << QString("xxxxxxxxxxxxxxxx");
+}
+
+void tst_QLineEdit::task233101_cursorPosAfterInputMethod()
+{
+ QFETCH(int, maxLength);
+ QFETCH(int, cursorPos);
+ QFETCH(int, replacementStart);
+ QFETCH(int, replacementLength);
+ QFETCH(QString, commitString);
+
+ QLineEdit lineEdit;
+ lineEdit.setMaxLength(maxLength);
+ lineEdit.insert(QString().fill(QLatin1Char('a'), cursorPos));
+ QCOMPARE(lineEdit.cursorPosition(), cursorPos);
+
+ QInputMethodEvent event;
+ event.setCommitString(QLatin1String("x"), replacementStart, replacementLength);
+ qApp->sendEvent(&lineEdit, &event);
+ QVERIFY(lineEdit.cursorPosition() >= 0);
+ QVERIFY(lineEdit.cursorPosition() <= lineEdit.text().size());
+ QVERIFY(lineEdit.text().size() <= lineEdit.maxLength());
+}
+
+void tst_QLineEdit::task241436_passwordEchoOnEditRestoreEchoMode()
+{
+ QStyleOptionFrameV2 opt;
+ QChar fillChar = testWidget->style()->styleHint(QStyle::SH_LineEdit_PasswordCharacter, &opt, testWidget);
+
+ testWidget->setEchoMode(QLineEdit::PasswordEchoOnEdit);
+ testWidget->setFocus();
+ QApplication::setActiveWindow(testWidget);
+ QTRY_VERIFY(testWidget->hasFocus());
+
+ QTest::keyPress(testWidget, '0');
+ QCOMPARE(testWidget->displayText(), QString("0"));
+ testWidget->setEchoMode(QLineEdit::Normal);
+ testWidget->clearFocus();
+ QCOMPARE(testWidget->displayText(), QString("0"));
+
+ testWidget->activateWindow();
+ testWidget->setFocus();
+ testWidget->setEchoMode(QLineEdit::PasswordEchoOnEdit);
+ QTest::keyPress(testWidget, '0');
+ QCOMPARE(testWidget->displayText(), QString("0"));
+ testWidget->setEchoMode(QLineEdit::PasswordEchoOnEdit);
+ QCOMPARE(testWidget->displayText(), QString("0"));
+ testWidget->clearFocus();
+ QCOMPARE(testWidget->displayText(), QString(fillChar));
+
+ // restore clean state
+ testWidget->setEchoMode(QLineEdit::Normal);
+}
+
+void tst_QLineEdit::task248948_redoRemovedSelection()
+{
+ testWidget->setText("a");
+ testWidget->selectAll();
+ QTest::keyPress(testWidget, Qt::Key_Delete);
+ testWidget->undo();
+ testWidget->redo();
+ QTest::keyPress(testWidget, 'a');
+ QTest::keyPress(testWidget, 'b');
+ QCOMPARE(testWidget->text(), QLatin1String("ab"));
+}
+
+void tst_QLineEdit::taskQTBUG_4401_enterKeyClearsPassword()
+{
+ QString password("Wanna guess?");
+
+ testWidget->setText(password);
+ testWidget->setEchoMode(QLineEdit::PasswordEchoOnEdit);
+ testWidget->setFocus();
+ testWidget->selectAll();
+ QApplication::setActiveWindow(testWidget);
+ QTRY_VERIFY(testWidget->hasFocus());
+
+ QTest::keyPress(testWidget, Qt::Key_Enter);
+ QTRY_COMPARE(testWidget->text(), password);
+}
+
+void tst_QLineEdit::taskQTBUG_4679_moveToStartEndOfBlock()
+{
+#ifdef Q_OS_MAC
+ const QString text("there are no blocks for lineEdit");
+ testWidget->setText(text);
+ testWidget->setCursorPosition(5);
+ QCOMPARE(testWidget->cursorPosition(), 5);
+ testWidget->setFocus();
+ QTest::keyPress(testWidget, Qt::Key_A, Qt::MetaModifier);
+ QCOMPARE(testWidget->cursorPosition(), 0);
+ QTest::keyPress(testWidget, Qt::Key_E, Qt::MetaModifier);
+ QCOMPARE(testWidget->cursorPosition(), text.size());
+#endif // Q_OS_MAC
+}
+
+void tst_QLineEdit::taskQTBUG_4679_selectToStartEndOfBlock()
+{
+#ifdef Q_OS_MAC
+ const QString text("there are no blocks for lineEdit, select all");
+ testWidget->setText(text);
+ testWidget->setCursorPosition(5);
+ QCOMPARE(testWidget->cursorPosition(), 5);
+ testWidget->setFocus();
+ QTest::keyPress(testWidget, Qt::Key_A, Qt::MetaModifier | Qt::ShiftModifier);
+ QCOMPARE(testWidget->cursorPosition(), 0);
+ QVERIFY(testWidget->hasSelectedText());
+ QCOMPARE(testWidget->selectedText(), text.mid(0, 5));
+
+ QTest::keyPress(testWidget, Qt::Key_E, Qt::MetaModifier | Qt::ShiftModifier);
+ QCOMPARE(testWidget->cursorPosition(), text.size());
+ QVERIFY(testWidget->hasSelectedText());
+ QCOMPARE(testWidget->selectedText(), text.mid(5));
+#endif // Q_OS_MAC
+}
+
+#ifndef QT_NO_CONTEXTMENU
+void tst_QLineEdit::taskQTBUG_7902_contextMenuCrash()
+{
+ // Would pass before the associated commit, but left as a guard.
+ QLineEdit *w = new QLineEdit;
+ w->show();
+ QTest::qWaitForWindowShown(w);
+
+ QTimer ti;
+ w->connect(&ti, SIGNAL(timeout()), w, SLOT(deleteLater()));
+ ti.start(200);
+
+ QContextMenuEvent *cme = new QContextMenuEvent(QContextMenuEvent::Mouse, w->rect().center());
+ qApp->postEvent(w, cme);
+
+ QTest::qWait(300);
+ // No crash, it's allright.
+}
+#endif
+
+void tst_QLineEdit::taskQTBUG_7395_readOnlyShortcut()
+{
+ //ReadOnly QLineEdit should not intercept shortcut.
+ QLineEdit le;
+ le.setReadOnly(true);
+
+ QAction action(QString::fromLatin1("hello"), &le);
+ action.setShortcut(QString::fromLatin1("p"));
+ QSignalSpy spy(&action, SIGNAL(triggered()));
+ le.addAction(&action);
+
+ le.show();
+ QTest::qWaitForWindowShown(&le);
+ QApplication::setActiveWindow(&le);
+ le.setFocus();
+ QTRY_VERIFY(le.hasFocus());
+
+ QTest::keyClick(static_cast<QWidget *>(0), Qt::Key_P);
+ QCOMPARE(spy.count(), 1);
+}
+
+#ifdef Q_WS_X11
+void tst_QLineEdit::QTBUG697_paletteCurrentColorGroup()
+{
+ QLineEdit le;
+ le.setText(" ");
+ QPalette p = le.palette();
+ p.setBrush(QPalette::Active, QPalette::Highlight, Qt::green);
+ p.setBrush(QPalette::Inactive, QPalette::Highlight, Qt::red);
+ le.setPalette(p);
+
+ le.show();
+ QApplication::setActiveWindow(&le);
+ QTest::qWaitForWindowShown(&le);
+ le.setFocus();
+ QTRY_VERIFY(le.hasFocus());
+ le.selectAll();
+
+ QImage img(le.size(),QImage::Format_ARGB32 );
+ le.render(&img);
+ QCOMPARE(img.pixel(10, le.height()/2), QColor(Qt::green).rgb());
+ QApplication::setActiveWindow(0);
+ le.render(&img);
+ QCOMPARE(img.pixel(10, le.height()/2), QColor(Qt::red).rgb());
+}
+#endif
+
+void tst_QLineEdit::QTBUG13520_textNotVisible()
+{
+ LineEdit le;
+ le.setAlignment( Qt::AlignRight | Qt::AlignVCenter);
+ le.show();
+ QTest::qWaitForWindowShown(&le);
+ le.setText("01-ST16-01SIL-MPL001wfgsdfgsdgsdfgsdfgsdfgsdfgsdfg");
+ le.setCursorPosition(0);
+ QTest::qWait(100); //just make sure we get he lineedit correcly painted
+
+ QVERIFY(le.cursorRect().center().x() < le.width() / 2);
+
+
+}
+
+
+void tst_QLineEdit::bidiVisualMovement_data()
+{
+ QTest::addColumn<QString>("logical");
+ QTest::addColumn<int>("basicDir");
+ QTest::addColumn<IntList>("positionList");
+
+ QTest::newRow("Latin text")
+ << QString::fromUtf8("abc")
+ << (int) QChar::DirL
+ << (IntList() << 0 << 1 << 2 << 3);
+ QTest::newRow("Hebrew text, one item")
+ << QString::fromUtf8("\327\220\327\221\327\222")
+ << (int) QChar::DirR
+ << (QList<int>() << 0 << 1 << 2 << 3);
+ QTest::newRow("Hebrew text after Latin text")
+ << QString::fromUtf8("abc\327\220\327\221\327\222")
+ << (int) QChar::DirL
+ << (QList<int>() << 0 << 1 << 2 << 6 << 5 << 4 << 3);
+ QTest::newRow("Latin text after Hebrew text")
+ << QString::fromUtf8("\327\220\327\221\327\222abc")
+ << (int) QChar::DirR
+ << (QList<int>() << 0 << 1 << 2 << 6 << 5 << 4 << 3);
+ QTest::newRow("LTR, 3 items")
+ << QString::fromUtf8("abc\327\220\327\221\327\222abc")
+ << (int) QChar::DirL
+ << (QList<int>() << 0 << 1 << 2 << 5 << 4 << 3 << 6 << 7 << 8 << 9);
+ QTest::newRow("RTL, 3 items")
+ << QString::fromUtf8("\327\220\327\221\327\222abc\327\220\327\221\327\222")
+ << (int) QChar::DirR
+ << (QList<int>() << 0 << 1 << 2 << 5 << 4 << 3 << 6 << 7 << 8 << 9);
+ QTest::newRow("LTR, 4 items")
+ << QString::fromUtf8("abc\327\220\327\221\327\222abc\327\220\327\221\327\222")
+ << (int) QChar::DirL
+ << (QList<int>() << 0 << 1 << 2 << 5 << 4 << 3 << 6 << 7 << 8 << 12 << 11 << 10 << 9);
+ QTest::newRow("RTL, 4 items")
+ << QString::fromUtf8("\327\220\327\221\327\222abc\327\220\327\221\327\222abc")
+ << (int) QChar::DirR
+ << (QList<int>() << 0 << 1 << 2 << 5 << 4 << 3 << 6 << 7 << 8 << 12 << 11 << 10 << 9);
+}
+
+void tst_QLineEdit::bidiVisualMovement()
+{
+ QFETCH(QString, logical);
+ QFETCH(int, basicDir);
+ QFETCH(IntList, positionList);
+
+ QLineEdit le;
+ le.setText(logical);
+
+ le.setCursorMoveStyle(Qt::VisualMoveStyle);
+ le.setCursorPosition(0);
+
+ bool moved;
+ int i = 0, oldPos, newPos = 0;
+
+ do {
+ oldPos = newPos;
+ QVERIFY(oldPos == positionList[i]);
+ if (basicDir == QChar::DirL) {
+ QTest::keyClick(&le, Qt::Key_Right);
+ } else
+ QTest::keyClick(&le, Qt::Key_Left);
+ newPos = le.cursorPosition();
+ moved = (oldPos != newPos);
+ i++;
+ } while (moved);
+
+ QVERIFY(i == positionList.size());
+
+ do {
+ i--;
+ oldPos = newPos;
+ QVERIFY(oldPos == positionList[i]);
+ if (basicDir == QChar::DirL) {
+ QTest::keyClick(&le, Qt::Key_Left);
+ } else
+ {
+ QTest::keyClick(&le, Qt::Key_Right);
+ }
+ newPos = le.cursorPosition();
+ moved = (oldPos != newPos);
+ } while (moved && i >= 0);
+}
+
+void tst_QLineEdit::bidiLogicalMovement_data()
+{
+ bidiVisualMovement_data();
+}
+
+void tst_QLineEdit::bidiLogicalMovement()
+{
+ QFETCH(QString, logical);
+ QFETCH(int, basicDir);
+
+ QLineEdit le;
+ le.setText(logical);
+
+ le.setCursorMoveStyle(Qt::LogicalMoveStyle);
+ le.setCursorPosition(0);
+
+ bool moved;
+ int i = 0, oldPos, newPos = 0;
+
+ do {
+ oldPos = newPos;
+ QVERIFY(oldPos == i);
+ if (basicDir == QChar::DirL) {
+ QTest::keyClick(&le, Qt::Key_Right);
+ } else
+ QTest::keyClick(&le, Qt::Key_Left);
+ newPos = le.cursorPosition();
+ moved = (oldPos != newPos);
+ i++;
+ } while (moved);
+
+ do {
+ i--;
+ oldPos = newPos;
+ QVERIFY(oldPos == i);
+ if (basicDir == QChar::DirL) {
+ QTest::keyClick(&le, Qt::Key_Left);
+ } else
+ {
+ QTest::keyClick(&le, Qt::Key_Right);
+ }
+ newPos = le.cursorPosition();
+ moved = (oldPos != newPos);
+ } while (moved && i >= 0);
+}
+
+void tst_QLineEdit::selectAndCursorPosition()
+{
+ testWidget->setText("This is a long piece of text");
+
+ testWidget->setSelection(0, 5);
+ QCOMPARE(testWidget->cursorPosition(), 5);
+ testWidget->setSelection(5, -5);
+ QCOMPARE(testWidget->cursorPosition(), 0);
+}
+
+void tst_QLineEdit::inputMethodSelection()
+{
+ testWidget->setText("Lorem ipsum dolor sit amet, consectetur adipiscing elit.");
+ testWidget->setSelection(0,0);
+ QSignalSpy selectionSpy(testWidget, SIGNAL(selectionChanged()));
+
+ QCOMPARE(selectionSpy.count(), 0);
+ QCOMPARE(testWidget->selectionStart(), -1);
+
+ testWidget->setSelection(0,5);
+
+ QCOMPARE(selectionSpy.count(), 1);
+ QCOMPARE(testWidget->selectionStart(), 0);
+
+ QList<QInputMethodEvent::Attribute> attributes;
+ attributes << QInputMethodEvent::Attribute(QInputMethodEvent::Selection, 12, 5, QVariant());
+ QInputMethodEvent event("", attributes);
+ QApplication::sendEvent(testWidget, &event);
+
+ QCOMPARE(selectionSpy.count(), 2);
+ QCOMPARE(testWidget->selectionStart(), 12);
+}
+
+QTEST_MAIN(tst_QLineEdit)
+#include "tst_qlineedit.moc"
diff --git a/tests/auto/widgets/widgets/qmainwindow/.gitignore b/tests/auto/widgets/widgets/qmainwindow/.gitignore
new file mode 100644
index 0000000000..7550c7063f
--- /dev/null
+++ b/tests/auto/widgets/widgets/qmainwindow/.gitignore
@@ -0,0 +1 @@
+tst_qmainwindow
diff --git a/tests/auto/widgets/widgets/qmainwindow/qmainwindow.pro b/tests/auto/widgets/widgets/qmainwindow/qmainwindow.pro
new file mode 100644
index 0000000000..c140f76c89
--- /dev/null
+++ b/tests/auto/widgets/widgets/qmainwindow/qmainwindow.pro
@@ -0,0 +1,3 @@
+load(qttest_p4)
+QT += widgets widgets-private
+SOURCES += tst_qmainwindow.cpp
diff --git a/tests/auto/widgets/widgets/qmainwindow/tst_qmainwindow.cpp b/tests/auto/widgets/widgets/qmainwindow/tst_qmainwindow.cpp
new file mode 100644
index 0000000000..9722a3194b
--- /dev/null
+++ b/tests/auto/widgets/widgets/qmainwindow/tst_qmainwindow.cpp
@@ -0,0 +1,1742 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#include <QtTest/QtTest>
+
+
+#include <qdockwidget.h>
+#include <qlayout.h>
+#include <qmainwindow.h>
+#include <qmenubar.h>
+#include <qstatusbar.h>
+#include <qstyle.h>
+#include <qtoolbar.h>
+#include <qpushbutton.h>
+#include <qlabel.h>
+#include <qtextedit.h>
+#include <private/qmainwindowlayout_p.h>
+#include <private/qdockarealayout_p.h>
+#include "../../../platformquirks.h"
+
+//TESTED_FILES=
+
+static uchar restoreData41[] = { 0x0, 0x0, 0x0, 0xff, 0x0, 0x0, 0x0, 0x0, 0xfc, 0x0, 0x0, 0x0, 0x0, 0xfd, 0x0, 0x0, 0x0, 0x4, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x64, 0x0, 0x0, 0x1, 0x19, 0xfc, 0x2, 0x0, 0x0, 0x0, 0x4, 0xfb, 0x0, 0x0, 0x0, 0xc, 0x0, 0x64, 0x0, 0x6f, 0x0, 0x63, 0x0, 0x6b, 0x0, 0x20, 0x0, 0x30, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x45, 0x0, 0x0, 0x0, 0x0, 0x0, 0xff, 0xff, 0xff, 0xfb, 0x0, 0x0, 0x0, 0xc, 0x0, 0x64, 0x0, 0x6f, 0x0, 0x63, 0x0, 0x6b, 0x0, 0x20, 0x0, 0x34, 0x1, 0x0, 0x0, 0x0, 0x49, 0x0, 0x0, 0x0, 0x40, 0x0, 0x0, 0x0, 0x0, 0x0, 0xff, 0xff, 0xff, 0xfb, 0x0, 0x0, 0x0, 0xc, 0x0, 0x64, 0x0, 0x6f, 0x0, 0x63, 0x0, 0x6b, 0x0, 0x20, 0x0, 0x38, 0x1, 0x0, 0x0, 0x0, 0x8d, 0x0, 0x0, 0x0, 0x43, 0x0, 0x0, 0x0, 0x0, 0x0, 0xff, 0xff, 0xff, 0xfb, 0x0, 0x0, 0x0, 0xe, 0x0, 0x64, 0x0, 0x6f, 0x0, 0x63, 0x0, 0x6b, 0x0, 0x20, 0x0, 0x31, 0x0, 0x32, 0x1, 0x0, 0x0, 0x0, 0xd4, 0x0, 0x0, 0x0, 0x45, 0x0, 0x0, 0x0, 0x0, 0x0, 0xff, 0xff, 0xff, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x64, 0x0, 0x0, 0x1, 0x19, 0xfc, 0x2, 0x0, 0x0, 0x0, 0x4, 0xfb, 0x0, 0x0, 0x0, 0xc, 0x0, 0x64, 0x0, 0x6f, 0x0, 0x63, 0x0, 0x6b, 0x0, 0x20, 0x0, 0x31, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x45, 0x0, 0x0, 0x0, 0x0, 0x0, 0xff, 0xff, 0xff, 0xfb, 0x0, 0x0, 0x0, 0xc, 0x0, 0x64, 0x0, 0x6f, 0x0, 0x63, 0x0, 0x6b, 0x0, 0x20, 0x0, 0x35, 0x1, 0x0, 0x0, 0x0, 0x49, 0x0, 0x0, 0x0, 0x40, 0x0, 0x0, 0x0, 0x0, 0x0, 0xff, 0xff, 0xff, 0xfb, 0x0, 0x0, 0x0, 0xc, 0x0, 0x64, 0x0, 0x6f, 0x0, 0x63, 0x0, 0x6b, 0x0, 0x20, 0x0, 0x39, 0x1, 0x0, 0x0, 0x0, 0x8d, 0x0, 0x0, 0x0, 0x43, 0x0, 0x0, 0x0, 0x0, 0x0, 0xff, 0xff, 0xff, 0xfb, 0x0, 0x0, 0x0, 0xe, 0x0, 0x64, 0x0, 0x6f, 0x0, 0x63, 0x0, 0x6b, 0x0, 0x20, 0x0, 0x31, 0x0, 0x33, 0x1, 0x0, 0x0, 0x0, 0xd4, 0x0, 0x0, 0x0, 0x45, 0x0, 0x0, 0x0, 0x0, 0x0, 0xff, 0xff, 0xff, 0x0, 0x0, 0x0, 0x2, 0x0, 0x0, 0x1, 0x89, 0x0, 0x0, 0x0, 0xe, 0xfc, 0x1, 0x0, 0x0, 0x0, 0x4, 0xfb, 0x0, 0x0, 0x0, 0xc, 0x0, 0x64, 0x0, 0x6f, 0x0, 0x63, 0x0, 0x6b, 0x0, 0x20, 0x0, 0x32, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x5f, 0x0, 0x0, 0x0, 0x0, 0x0, 0xff, 0xff, 0xff, 0xfb, 0x0, 0x0, 0x0, 0xc, 0x0, 0x64, 0x0, 0x6f, 0x0, 0x63, 0x0, 0x6b, 0x0, 0x20, 0x0, 0x36, 0x1, 0x0, 0x0, 0x0, 0x63, 0x0, 0x0, 0x0, 0x61, 0x0, 0x0, 0x0, 0x0, 0x0, 0xff, 0xff, 0xff, 0xfb, 0x0, 0x0, 0x0, 0xe, 0x0, 0x64, 0x0, 0x6f, 0x0, 0x63, 0x0, 0x6b, 0x0, 0x20, 0x0, 0x31, 0x0, 0x30, 0x1, 0x0, 0x0, 0x0, 0xc8, 0x0, 0x0, 0x0, 0x5e, 0x0, 0x0, 0x0, 0x0, 0x0, 0xff, 0xff, 0xff, 0xfb, 0x0, 0x0, 0x0, 0xe, 0x0, 0x64, 0x0, 0x6f, 0x0, 0x63, 0x0, 0x6b, 0x0, 0x20, 0x0, 0x31, 0x0, 0x34, 0x1, 0x0, 0x0, 0x1, 0x2a, 0x0, 0x0, 0x0, 0x5f, 0x0, 0x0, 0x0, 0x0, 0x0, 0xff, 0xff, 0xff, 0x0, 0x0, 0x0, 0x3, 0x0, 0x0, 0x1, 0x89, 0x0, 0x0, 0x0, 0xe, 0xfc, 0x1, 0x0, 0x0, 0x0, 0x4, 0xfb, 0x0, 0x0, 0x0, 0xc, 0x0, 0x64, 0x0, 0x6f, 0x0, 0x63, 0x0, 0x6b, 0x0, 0x20, 0x0, 0x33, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x5f, 0x0, 0x0, 0x0, 0x0, 0x0, 0xff, 0xff, 0xff, 0xfb, 0x0, 0x0, 0x0, 0xc, 0x0, 0x64, 0x0, 0x6f, 0x0, 0x63, 0x0, 0x6b, 0x0, 0x20, 0x0, 0x37, 0x1, 0x0, 0x0, 0x0, 0x63, 0x0, 0x0, 0x0, 0x61, 0x0, 0x0, 0x0, 0x0, 0x0, 0xff, 0xff, 0xff, 0xfb, 0x0, 0x0, 0x0, 0xe, 0x0, 0x64, 0x0, 0x6f, 0x0, 0x63, 0x0, 0x6b, 0x0, 0x20, 0x0, 0x31, 0x0, 0x31, 0x1, 0x0, 0x0, 0x0, 0xc8, 0x0, 0x0, 0x0, 0x5e, 0x0, 0x0, 0x0, 0x0, 0x0, 0xff, 0xff, 0xff, 0xfb, 0x0, 0x0, 0x0, 0xe, 0x0, 0x64, 0x0, 0x6f, 0x0, 0x63, 0x0, 0x6b, 0x0, 0x20, 0x0, 0x31, 0x0, 0x35, 0x1, 0x0, 0x0, 0x1, 0x2a, 0x0, 0x0, 0x0, 0x5f, 0x0, 0x0, 0x0, 0x0, 0x0, 0xff, 0xff, 0xff, 0x0, 0x0, 0x0, 0xc1, 0x0, 0x0, 0x1, 0x19};
+static uchar restoreData42[] = { 0x0, 0x0, 0x0, 0xff, 0x0, 0x0, 0x0, 0x0, 0xfc, 0x0, 0x0, 0x0, 0x0, 0xfd, 0x0, 0x0, 0x0, 0x4, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x24, 0x0, 0x0, 0x2, 0x2b, 0xfc, 0x2, 0x0, 0x0, 0x0, 0x4, 0xfb, 0x0, 0x0, 0x0, 0xc, 0x0, 0x64, 0x0, 0x6f, 0x0, 0x63, 0x0, 0x6b, 0x0, 0x20, 0x0, 0x30, 0x1, 0x0, 0x0, 0x0, 0x2a, 0x0, 0x0, 0x0, 0x88, 0x0, 0x0, 0x0, 0x21, 0x0, 0xff, 0xff, 0xff, 0xfb, 0x0, 0x0, 0x0, 0xc, 0x0, 0x64, 0x0, 0x6f, 0x0, 0x63, 0x0, 0x6b, 0x0, 0x20, 0x0, 0x34, 0x1, 0x0, 0x0, 0x0, 0xb6, 0x0, 0x0, 0x0, 0x88, 0x0, 0x0, 0x0, 0x21, 0x0, 0xff, 0xff, 0xff, 0xfb, 0x0, 0x0, 0x0, 0xc, 0x0, 0x64, 0x0, 0x6f, 0x0, 0x63, 0x0, 0x6b, 0x0, 0x20, 0x0, 0x38, 0x1, 0x0, 0x0, 0x1, 0x42, 0x0, 0x0, 0x0, 0x87, 0x0, 0x0, 0x0, 0x21, 0x0, 0xff, 0xff, 0xff, 0xfb, 0x0, 0x0, 0x0, 0xe, 0x0, 0x64, 0x0, 0x6f, 0x0, 0x63, 0x0, 0x6b, 0x0, 0x20, 0x0, 0x31, 0x0, 0x32, 0x1, 0x0, 0x0, 0x1, 0xcd, 0x0, 0x0, 0x0, 0x88, 0x0, 0x0, 0x0, 0x21, 0x0, 0xff, 0xff, 0xff, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x98, 0x0, 0x0, 0x2, 0x2b, 0xfc, 0x2, 0x0, 0x0, 0x0, 0x4, 0xfb, 0x0, 0x0, 0x0, 0xc, 0x0, 0x64, 0x0, 0x6f, 0x0, 0x63, 0x0, 0x6b, 0x0, 0x20, 0x0, 0x31, 0x1, 0x0, 0x0, 0x0, 0x2a, 0x0, 0x0, 0x0, 0x88, 0x0, 0x0, 0x0, 0x21, 0x0, 0xff, 0xff, 0xff, 0xfb, 0x0, 0x0, 0x0, 0xc, 0x0, 0x64, 0x0, 0x6f, 0x0, 0x63, 0x0, 0x6b, 0x0, 0x20, 0x0, 0x35, 0x1, 0x0, 0x0, 0x0, 0xb6, 0x0, 0x0, 0x0, 0x88, 0x0, 0x0, 0x0, 0x21, 0x0, 0xff, 0xff, 0xff, 0xfb, 0x0, 0x0, 0x0, 0xc, 0x0, 0x64, 0x0, 0x6f, 0x0, 0x63, 0x0, 0x6b, 0x0, 0x20, 0x0, 0x39, 0x1, 0x0, 0x0, 0x1, 0x42, 0x0, 0x0, 0x0, 0x87, 0x0, 0x0, 0x0, 0x21, 0x0, 0xff, 0xff, 0xff, 0xfb, 0x0, 0x0, 0x0, 0xe, 0x0, 0x64, 0x0, 0x6f, 0x0, 0x63, 0x0, 0x6b, 0x0, 0x20, 0x0, 0x31, 0x0, 0x33, 0x1, 0x0, 0x0, 0x1, 0xcd, 0x0, 0x0, 0x0, 0x88, 0x0, 0x0, 0x0, 0x21, 0x0, 0xff, 0xff, 0xff, 0x0, 0x0, 0x0, 0x2, 0x0, 0x0, 0x4, 0x4e, 0x0, 0x0, 0x0, 0x26, 0xfc, 0x1, 0x0, 0x0, 0x0, 0x4, 0xfb, 0x0, 0x0, 0x0, 0xc, 0x0, 0x64, 0x0, 0x6f, 0x0, 0x63, 0x0, 0x6b, 0x0, 0x20, 0x0, 0x32, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x12, 0x0, 0x0, 0x0, 0xa, 0x0, 0xff, 0xff, 0xff, 0xfb, 0x0, 0x0, 0x0, 0xc, 0x0, 0x64, 0x0, 0x6f, 0x0, 0x63, 0x0, 0x6b, 0x0, 0x20, 0x0, 0x36, 0x1, 0x0, 0x0, 0x1, 0x16, 0x0, 0x0, 0x1, 0xe, 0x0, 0x0, 0x0, 0xa, 0x0, 0xff, 0xff, 0xff, 0xfb, 0x0, 0x0, 0x0, 0xe, 0x0, 0x64, 0x0, 0x6f, 0x0, 0x63, 0x0, 0x6b, 0x0, 0x20, 0x0, 0x31, 0x0, 0x30, 0x1, 0x0, 0x0, 0x2, 0x28, 0x0, 0x0, 0x1, 0x14, 0x0, 0x0, 0x0, 0xa, 0x0, 0xff, 0xff, 0xff, 0xfb, 0x0, 0x0, 0x0, 0xe, 0x0, 0x64, 0x0, 0x6f, 0x0, 0x63, 0x0, 0x6b, 0x0, 0x20, 0x0, 0x31, 0x0, 0x34, 0x1, 0x0, 0x0, 0x3, 0x40, 0x0, 0x0, 0x1, 0xe, 0x0, 0x0, 0x0, 0xa, 0x0, 0xff, 0xff, 0xff, 0x0, 0x0, 0x0, 0x3, 0x0, 0x0, 0x4, 0x4e, 0x0, 0x0, 0x0, 0x26, 0xfc, 0x1, 0x0, 0x0, 0x0, 0x4, 0xfb, 0x0, 0x0, 0x0, 0xc, 0x0, 0x64, 0x0, 0x6f, 0x0, 0x63, 0x0, 0x6b, 0x0, 0x20, 0x0, 0x33, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x12, 0x0, 0x0, 0x0, 0xa, 0x0, 0xff, 0xff, 0xff, 0xfb, 0x0, 0x0, 0x0, 0xc, 0x0, 0x64, 0x0, 0x6f, 0x0, 0x63, 0x0, 0x6b, 0x0, 0x20, 0x0, 0x37, 0x1, 0x0, 0x0, 0x1, 0x16, 0x0, 0x0, 0x1, 0xe, 0x0, 0x0, 0x0, 0xa, 0x0, 0xff, 0xff, 0xff, 0xfb, 0x0, 0x0, 0x0, 0xe, 0x0, 0x64, 0x0, 0x6f, 0x0, 0x63, 0x0, 0x6b, 0x0, 0x20, 0x0, 0x31, 0x0, 0x31, 0x1, 0x0, 0x0, 0x2, 0x28, 0x0, 0x0, 0x1, 0x14, 0x0, 0x0, 0x0, 0xa, 0x0, 0xff, 0xff, 0xff, 0xfb, 0x0, 0x0, 0x0, 0xe, 0x0, 0x64, 0x0, 0x6f, 0x0, 0x63, 0x0, 0x6b, 0x0, 0x20, 0x0, 0x31, 0x0, 0x35, 0x1, 0x0, 0x0, 0x3, 0x40, 0x0, 0x0, 0x1, 0xe, 0x0, 0x0, 0x0, 0xa, 0x0, 0xff, 0xff, 0xff, 0x0, 0x0, 0x3, 0x8a, 0x0, 0x0, 0x2, 0x2b, 0x0, 0x0, 0x0, 0x4, 0x0, 0x0, 0x0, 0x4, 0x0, 0x0, 0x0, 0x8, 0x0, 0x0, 0x0, 0x8};
+static uchar restoreData43[] = { 0x0, 0x0, 0x0, 0xff, 0x0, 0x0, 0x0, 0x0, 0xfd, 0x0, 0x0, 0x0, 0x4, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x50, 0x0, 0x0, 0x0, 0xa0, 0xfc, 0x2, 0x0, 0x0, 0x0, 0x4, 0xfb, 0x0, 0x0, 0x0, 0xc, 0x0, 0x64, 0x0, 0x6f, 0x0, 0x63, 0x0, 0x6b, 0x0, 0x20, 0x0, 0x30, 0x1, 0x0, 0x0, 0x0, 0x2a, 0x0, 0x0, 0x0, 0x25, 0x0, 0x0, 0x0, 0x16, 0x0, 0xff, 0xff, 0xff, 0xfb, 0x0, 0x0, 0x0, 0xc, 0x0, 0x64, 0x0, 0x6f, 0x0, 0x63, 0x0, 0x6b, 0x0, 0x20, 0x0, 0x34, 0x1, 0x0, 0x0, 0x0, 0x53, 0x0, 0x0, 0x0, 0x25, 0x0, 0x0, 0x0, 0x16, 0x0, 0xff, 0xff, 0xff, 0xfb, 0x0, 0x0, 0x0, 0xc, 0x0, 0x64, 0x0, 0x6f, 0x0, 0x63, 0x0, 0x6b, 0x0, 0x20, 0x0, 0x38, 0x1, 0x0, 0x0, 0x0, 0x7c, 0x0, 0x0, 0x0, 0x25, 0x0, 0x0, 0x0, 0x16, 0x0, 0xff, 0xff, 0xff, 0xfb, 0x0, 0x0, 0x0, 0xe, 0x0, 0x64, 0x0, 0x6f, 0x0, 0x63, 0x0, 0x6b, 0x0, 0x20, 0x0, 0x31, 0x0, 0x32, 0x1, 0x0, 0x0, 0x0, 0xa5, 0x0, 0x0, 0x0, 0x25, 0x0, 0x0, 0x0, 0x16, 0x0, 0xff, 0xff, 0xff, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x98, 0x0, 0x0, 0x0, 0xa0, 0xfc, 0x2, 0x0, 0x0, 0x0, 0x4, 0xfb, 0x0, 0x0, 0x0, 0xc, 0x0, 0x64, 0x0, 0x6f, 0x0, 0x63, 0x0, 0x6b, 0x0, 0x20, 0x0, 0x31, 0x1, 0x0, 0x0, 0x0, 0x2a, 0x0, 0x0, 0x0, 0x25, 0x0, 0x0, 0x0, 0x16, 0x0, 0xff, 0xff, 0xff, 0xfb, 0x0, 0x0, 0x0, 0xc, 0x0, 0x64, 0x0, 0x6f, 0x0, 0x63, 0x0, 0x6b, 0x0, 0x20, 0x0, 0x35, 0x1, 0x0, 0x0, 0x0, 0x53, 0x0, 0x0, 0x0, 0x25, 0x0, 0x0, 0x0, 0x16, 0x0, 0xff, 0xff, 0xff, 0xfb, 0x0, 0x0, 0x0, 0xc, 0x0, 0x64, 0x0, 0x6f, 0x0, 0x63, 0x0, 0x6b, 0x0, 0x20, 0x0, 0x39, 0x1, 0x0, 0x0, 0x0, 0x7c, 0x0, 0x0, 0x0, 0x25, 0x0, 0x0, 0x0, 0x16, 0x0, 0xff, 0xff, 0xff, 0xfb, 0x0, 0x0, 0x0, 0xe, 0x0, 0x64, 0x0, 0x6f, 0x0, 0x63, 0x0, 0x6b, 0x0, 0x20, 0x0, 0x31, 0x0, 0x33, 0x1, 0x0, 0x0, 0x0, 0xa5, 0x0, 0x0, 0x0, 0x25, 0x0, 0x0, 0x0, 0x16, 0x0, 0xff, 0xff, 0xff, 0x0, 0x0, 0x0, 0x2, 0x0, 0x0, 0x1, 0xa8, 0x0, 0x0, 0x0, 0x26, 0xfc, 0x1, 0x0, 0x0, 0x0, 0x4, 0xfb, 0x0, 0x0, 0x0, 0xc, 0x0, 0x64, 0x0, 0x6f, 0x0, 0x63, 0x0, 0x6b, 0x0, 0x20, 0x0, 0x32, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x68, 0x0, 0x0, 0x0, 0x50, 0x0, 0xff, 0xff, 0xff, 0xfb, 0x0, 0x0, 0x0, 0xc, 0x0, 0x64, 0x0, 0x6f, 0x0, 0x63, 0x0, 0x6b, 0x0, 0x20, 0x0, 0x36, 0x1, 0x0, 0x0, 0x0, 0x6c, 0x0, 0x0, 0x0, 0x66, 0x0, 0x0, 0x0, 0x50, 0x0, 0xff, 0xff, 0xff, 0xfb, 0x0, 0x0, 0x0, 0xe, 0x0, 0x64, 0x0, 0x6f, 0x0, 0x63, 0x0, 0x6b, 0x0, 0x20, 0x0, 0x31, 0x0, 0x30, 0x1, 0x0, 0x0, 0x0, 0xd6, 0x0, 0x0, 0x0, 0x68, 0x0, 0x0, 0x0, 0x50, 0x0, 0xff, 0xff, 0xff, 0xfb, 0x0, 0x0, 0x0, 0xe, 0x0, 0x64, 0x0, 0x6f, 0x0, 0x63, 0x0, 0x6b, 0x0, 0x20, 0x0, 0x31, 0x0, 0x34, 0x1, 0x0, 0x0, 0x1, 0x42, 0x0, 0x0, 0x0, 0x66, 0x0, 0x0, 0x0, 0x50, 0x0, 0xff, 0xff, 0xff, 0x0, 0x0, 0x0, 0x3, 0x0, 0x0, 0x1, 0xa8, 0x0, 0x0, 0x0, 0x26, 0xfc, 0x1, 0x0, 0x0, 0x0, 0x4, 0xfb, 0x0, 0x0, 0x0, 0xc, 0x0, 0x64, 0x0, 0x6f, 0x0, 0x63, 0x0, 0x6b, 0x0, 0x20, 0x0, 0x33, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x68, 0x0, 0x0, 0x0, 0x50, 0x0, 0xff, 0xff, 0xff, 0xfb, 0x0, 0x0, 0x0, 0xc, 0x0, 0x64, 0x0, 0x6f, 0x0, 0x63, 0x0, 0x6b, 0x0, 0x20, 0x0, 0x37, 0x1, 0x0, 0x0, 0x0, 0x6c, 0x0, 0x0, 0x0, 0x66, 0x0, 0x0, 0x0, 0x50, 0x0, 0xff, 0xff, 0xff, 0xfb, 0x0, 0x0, 0x0, 0xe, 0x0, 0x64, 0x0, 0x6f, 0x0, 0x63, 0x0, 0x6b, 0x0, 0x20, 0x0, 0x31, 0x0, 0x31, 0x1, 0x0, 0x0, 0x0, 0xd6, 0x0, 0x0, 0x0, 0x68, 0x0, 0x0, 0x0, 0x50, 0x0, 0xff, 0xff, 0xff, 0xfb, 0x0, 0x0, 0x0, 0xe, 0x0, 0x64, 0x0, 0x6f, 0x0, 0x63, 0x0, 0x6b, 0x0, 0x20, 0x0, 0x31, 0x0, 0x35, 0x1, 0x0, 0x0, 0x1, 0x42, 0x0, 0x0, 0x0, 0x66, 0x0, 0x0, 0x0, 0x50, 0x0, 0xff, 0xff, 0xff, 0x0, 0x0, 0x0, 0xb8, 0x0, 0x0, 0x0, 0xa0, 0x0, 0x0, 0x0, 0x4, 0x0, 0x0, 0x0, 0x4, 0x0, 0x0, 0x0, 0x8, 0x0, 0x0, 0x0, 0x8, 0xfc, 0x0, 0x0, 0x0, 0x0};
+
+class tst_QMainWindow : public QObject
+{
+ Q_OBJECT
+
+public:
+ tst_QMainWindow();
+
+private slots:
+ void getSetCheck();
+ void constructor();
+ void iconSize();
+ void toolButtonStyle();
+#ifndef Q_WS_WINCE_WM
+ void menuBar();
+#endif
+ void statusBar();
+ void centralWidget();
+ void corner();
+ void addToolBarBreak();
+ void insertToolBarBreak();
+ void addToolBar();
+ void insertToolBar();
+ void removeToolBar();
+ void toolBarArea();
+ void addDockWidget();
+ void splitDockWidget();
+ void removeDockWidget();
+ void dockWidgetArea();
+ void restoreState();
+ void restoreStateFromPreviousVersion();
+ void createPopupMenu();
+ void hideBeforeLayout();
+ void saveRestore();
+ void saveRestore_data();
+ void isSeparator();
+#ifndef QT_NO_CURSOR
+ void setCursor();
+#endif
+ void addToolbarAfterShow();
+ void centralWidgetSize();
+ void dockWidgetSize();
+ void QTBUG2774_stylechange();
+#ifdef Q_OS_MAC
+ void toggleUnifiedTitleAndToolBarOnMac();
+#endif
+};
+
+// Testing get/set functions
+void tst_QMainWindow::getSetCheck()
+{
+ QMainWindow obj1;
+ // QMenuBar * QMainWindow::menuBar()
+ // void QMainWindow::setMenuBar(QMenuBar *)
+ QPointer<QMenuBar> var1 = new QMenuBar;
+ obj1.setMenuBar(var1);
+ QCOMPARE(static_cast<QMenuBar *>(var1), obj1.menuBar());
+ obj1.setMenuBar((QMenuBar *)0);
+ QVERIFY(obj1.menuBar());
+ //we now call deleteLater on the previous menubar
+ QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
+ QVERIFY(!var1);
+ // delete var1; // No delete, since QMainWindow takes ownership
+
+ // QStatusBar * QMainWindow::statusBar()
+ // void QMainWindow::setStatusBar(QStatusBar *)
+ QPointer<QStatusBar> var2 = new QStatusBar;
+ obj1.setStatusBar(var2);
+ QCOMPARE(static_cast<QStatusBar *>(var2), obj1.statusBar());
+ obj1.setStatusBar((QStatusBar *)0);
+ QVERIFY(obj1.statusBar());
+ //we now call deleteLater on the previous menubar
+ QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
+ QVERIFY(!var2);
+ // delete var2; // No delete, since QMainWindow takes ownership
+
+ // QWidget * QMainWindow::centralWidget()
+ // void QMainWindow::setCentralWidget(QWidget *)
+ QWidget *var3 = new QWidget;
+ obj1.setCentralWidget(var3);
+ QCOMPARE(var3, obj1.centralWidget());
+ obj1.setCentralWidget((QWidget *)0);
+ QCOMPARE((QWidget *)0, obj1.centralWidget());
+ // delete var3; // No delete, since QMainWindow takes ownership
+}
+
+tst_QMainWindow::tst_QMainWindow()
+{
+ qRegisterMetaType<QSize>("QSize");
+ qRegisterMetaType<Qt::ToolButtonStyle>("Qt::ToolButtonStyle");
+}
+
+void tst_QMainWindow::constructor()
+{
+ QMainWindow mw;
+ QVERIFY(mw.parentWidget() == 0);
+ QVERIFY(mw.isWindow());
+
+ QMainWindow mw2(&mw);
+ QVERIFY(mw2.parentWidget() == &mw);
+ QVERIFY(mw2.isWindow());
+
+ QMainWindow mw3(&mw, Qt::FramelessWindowHint);
+ QVERIFY(mw3.parentWidget() == &mw);
+ QVERIFY(mw3.isWindow());
+}
+
+void tst_QMainWindow::iconSize()
+{
+ {
+ QMainWindow mw;
+ QSignalSpy spy(&mw, SIGNAL(iconSizeChanged(QSize)));
+
+ // the default is determined by the style
+ const int metric = mw.style()->pixelMetric(QStyle::PM_ToolBarIconSize);
+ const QSize defaultIconSize = QSize(metric, metric);
+ const QSize smallIconSize = QSize(metric / 2, metric / 2);
+ const QSize largeIconSize = QSize(metric * 2, metric * 2);
+
+ // no-op
+ QCOMPARE(mw.iconSize(), defaultIconSize);
+ mw.setIconSize(defaultIconSize);
+ QCOMPARE(mw.iconSize(), defaultIconSize);
+ QCOMPARE(spy.size(), 0);
+
+ mw.setIconSize(largeIconSize);
+ QCOMPARE(mw.iconSize(), largeIconSize);
+ QCOMPARE(spy.size(), 1);
+ QCOMPARE(spy.first().first().toSize(), largeIconSize);
+ spy.clear();
+
+ // no-op
+ QCOMPARE(mw.iconSize(), largeIconSize);
+ mw.setIconSize(largeIconSize);
+ QCOMPARE(mw.iconSize(), largeIconSize);
+ QCOMPARE(spy.size(), 0);
+
+ mw.setIconSize(smallIconSize);
+ QCOMPARE(mw.iconSize(), smallIconSize);
+ QCOMPARE(spy.size(), 1);
+ QCOMPARE(spy.first().first().toSize(), smallIconSize);
+ spy.clear();
+
+ // no-op
+ QCOMPARE(mw.iconSize(), smallIconSize);
+ mw.setIconSize(smallIconSize);
+ QCOMPARE(mw.iconSize(), smallIconSize);
+ QCOMPARE(spy.size(), 0);
+
+ // setting the icon size to an invalid QSize will reset the
+ // iconSize property to the default
+ mw.setIconSize(QSize());
+ QCOMPARE(mw.iconSize(), defaultIconSize);
+ QCOMPARE(spy.size(), 1);
+ QCOMPARE(spy.first().first().toSize(), defaultIconSize);
+ spy.clear();
+ }
+
+ {
+ // toolbars should follow the mainwindow's icon size
+ QMainWindow mw;
+ QToolBar tb;
+ mw.addToolBar(&tb);
+
+ QSignalSpy mwSpy(&mw, SIGNAL(iconSizeChanged(QSize)));
+ QSignalSpy tbSpy(&tb, SIGNAL(iconSizeChanged(QSize)));
+
+ // the default is determined by the style
+ const int metric = mw.style()->pixelMetric(QStyle::PM_ToolBarIconSize);
+ const QSize defaultIconSize = QSize(metric, metric);
+ const QSize smallIconSize = QSize(metric / 2, metric / 2);
+ const QSize largeIconSize = QSize(metric * 2, metric * 2);
+
+ // no-op
+ QCOMPARE(mw.iconSize(), defaultIconSize);
+ mw.setIconSize(defaultIconSize);
+ QCOMPARE(mw.iconSize(), defaultIconSize);
+ QCOMPARE(tb.iconSize(), defaultIconSize);
+ QCOMPARE(mwSpy.size(), 0);
+ QCOMPARE(tbSpy.size(), 0);
+
+ mw.setIconSize(largeIconSize);
+ QCOMPARE(mw.iconSize(), largeIconSize);
+ QCOMPARE(tb.iconSize(), largeIconSize);
+ QCOMPARE(mwSpy.size(), 1);
+ QCOMPARE(mwSpy.first().first().toSize(), largeIconSize);
+ QCOMPARE(tbSpy.size(), 1);
+ QCOMPARE(tbSpy.first().first().toSize(), largeIconSize);
+ mwSpy.clear();
+ tbSpy.clear();
+
+ // no-op
+ QCOMPARE(mw.iconSize(), largeIconSize);
+ mw.setIconSize(largeIconSize);
+ QCOMPARE(mw.iconSize(), largeIconSize);
+ QCOMPARE(tb.iconSize(), largeIconSize);
+ QCOMPARE(mwSpy.size(), 0);
+ QCOMPARE(tbSpy.size(), 0);
+
+ mw.setIconSize(smallIconSize);
+ QCOMPARE(mw.iconSize(), smallIconSize);
+ QCOMPARE(tb.iconSize(), smallIconSize);
+ QCOMPARE(mwSpy.size(), 1);
+ QCOMPARE(mwSpy.first().first().toSize(), smallIconSize);
+ QCOMPARE(tbSpy.size(), 1);
+ QCOMPARE(tbSpy.first().first().toSize(), smallIconSize);
+ mwSpy.clear();
+ tbSpy.clear();
+
+ // no-op
+ QCOMPARE(mw.iconSize(), smallIconSize);
+ mw.setIconSize(smallIconSize);
+ QCOMPARE(mw.iconSize(), smallIconSize);
+ QCOMPARE(tb.iconSize(), smallIconSize);
+ QCOMPARE(mwSpy.size(), 0);
+ QCOMPARE(tbSpy.size(), 0);
+
+ // setting the icon size to an invalid QSize will reset the
+ // iconSize property to the default
+ mw.setIconSize(QSize());
+ QCOMPARE(mw.iconSize(), defaultIconSize);
+ QCOMPARE(tb.iconSize(), defaultIconSize);
+ QCOMPARE(mwSpy.size(), 1);
+ QCOMPARE(mwSpy.first().first().toSize(), defaultIconSize);
+ QCOMPARE(tbSpy.size(), 1);
+ QCOMPARE(tbSpy.first().first().toSize(), defaultIconSize);
+ mwSpy.clear();
+ tbSpy.clear();
+ }
+
+ {
+ QMainWindow mw;
+ QSignalSpy mwSpy(&mw, SIGNAL(iconSizeChanged(QSize)));
+
+ // the default is determined by the style
+ const int metric = mw.style()->pixelMetric(QStyle::PM_ToolBarIconSize);
+ const QSize defaultIconSize = QSize(metric, metric);
+ const QSize smallIconSize = QSize(metric / 2, metric / 2);
+ const QSize largeIconSize = QSize(metric * 2, metric * 2);
+
+ mw.setIconSize(smallIconSize);
+ QCOMPARE(mw.iconSize(), smallIconSize);
+ QCOMPARE(mwSpy.size(), 1);
+ QCOMPARE(mwSpy.first().first().toSize(), smallIconSize);
+ mwSpy.clear();
+
+ QToolBar tb;
+ QSignalSpy tbSpy(&tb, SIGNAL(iconSizeChanged(QSize)));
+
+ mw.addToolBar(&tb);
+
+ // newly added toolbars should also automatically pick up any
+ // size set on the main window
+ QCOMPARE(tb.iconSize(), smallIconSize);
+ QCOMPARE(tbSpy.size(), 1);
+ QCOMPARE(tbSpy.first().first().toSize(), smallIconSize);
+ tbSpy.clear();
+
+ mw.removeToolBar(&tb);
+
+ // removed toolbars should keep their existing size and ignore
+ // mainwindow icon size changes
+ mw.setIconSize(largeIconSize);
+ QCOMPARE(mw.iconSize(), largeIconSize);
+ QCOMPARE(tb.iconSize(), smallIconSize);
+ QCOMPARE(mwSpy.size(), 1);
+ QCOMPARE(mwSpy.first().first().toSize(), largeIconSize);
+ QCOMPARE(tbSpy.size(), 0);
+ mwSpy.clear();
+ }
+}
+
+void tst_QMainWindow::toolButtonStyle()
+{
+ {
+ QMainWindow mw;
+
+ QSignalSpy spy(&mw, SIGNAL(toolButtonStyleChanged(Qt::ToolButtonStyle)));
+
+ // no-op
+ QCOMPARE(mw.toolButtonStyle(), Qt::ToolButtonIconOnly);
+ mw.setToolButtonStyle(Qt::ToolButtonIconOnly);
+ QCOMPARE(mw.toolButtonStyle(), Qt::ToolButtonIconOnly);
+ QCOMPARE(spy.size(), 0);
+
+ mw.setToolButtonStyle(Qt::ToolButtonTextOnly);
+ QCOMPARE(mw.toolButtonStyle(), Qt::ToolButtonTextOnly);
+ QCOMPARE(spy.size(), 1);
+ QCOMPARE(*static_cast<const Qt::ToolButtonStyle *>(spy.first().first().constData()),
+ Qt::ToolButtonTextOnly);
+ spy.clear();
+
+ // no-op
+ mw.setToolButtonStyle(Qt::ToolButtonTextOnly);
+ QCOMPARE(mw.toolButtonStyle(), Qt::ToolButtonTextOnly);
+ QCOMPARE(spy.size(), 0);
+
+ mw.setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
+ QCOMPARE(mw.toolButtonStyle(), Qt::ToolButtonTextBesideIcon);
+ QCOMPARE(spy.size(), 1);
+ QCOMPARE(*static_cast<const Qt::ToolButtonStyle *>(spy.first().first().constData()),
+ Qt::ToolButtonTextBesideIcon);
+ spy.clear();
+
+ // no-op
+ mw.setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
+ QCOMPARE(mw.toolButtonStyle(), Qt::ToolButtonTextBesideIcon);
+ QCOMPARE(spy.size(), 0);
+
+ mw.setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
+ QCOMPARE(mw.toolButtonStyle(), Qt::ToolButtonTextUnderIcon);
+ QCOMPARE(spy.size(), 1);
+ QCOMPARE(*static_cast<const Qt::ToolButtonStyle *>(spy.first().first().constData()),
+ Qt::ToolButtonTextUnderIcon);
+ spy.clear();
+
+ // no-op
+ mw.setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
+ QCOMPARE(mw.toolButtonStyle(), Qt::ToolButtonTextUnderIcon);
+ QCOMPARE(spy.size(), 0);
+
+ mw.setToolButtonStyle(Qt::ToolButtonIconOnly);
+ QCOMPARE(mw.toolButtonStyle(), Qt::ToolButtonIconOnly);
+ QCOMPARE(spy.size(), 1);
+ QCOMPARE(*static_cast<const Qt::ToolButtonStyle *>(spy.first().first().constData()),
+ Qt::ToolButtonIconOnly);
+ spy.clear();
+
+ // no-op
+ mw.setToolButtonStyle(Qt::ToolButtonIconOnly);
+ QCOMPARE(mw.toolButtonStyle(), Qt::ToolButtonIconOnly);
+ QCOMPARE(spy.size(), 0);
+ }
+
+ {
+ // toolbars should follow the mainwindow's tool button style
+ QMainWindow mw;
+ QToolBar tb;
+ mw.addToolBar(&tb);
+
+ QSignalSpy mwSpy(&mw, SIGNAL(toolButtonStyleChanged(Qt::ToolButtonStyle)));
+ QSignalSpy tbSpy(&tb, SIGNAL(toolButtonStyleChanged(Qt::ToolButtonStyle)));
+
+ // no-op
+ QCOMPARE(mw.toolButtonStyle(), Qt::ToolButtonIconOnly);
+ QCOMPARE(tb.toolButtonStyle(), Qt::ToolButtonIconOnly);
+ mw.setToolButtonStyle(Qt::ToolButtonIconOnly);
+ QCOMPARE(mw.toolButtonStyle(), Qt::ToolButtonIconOnly);
+ QCOMPARE(tb.toolButtonStyle(), Qt::ToolButtonIconOnly);
+ QCOMPARE(mwSpy.size(), 0);
+ QCOMPARE(tbSpy.size(), 0);
+
+ mw.setToolButtonStyle(Qt::ToolButtonTextOnly);
+ QCOMPARE(mw.toolButtonStyle(), Qt::ToolButtonTextOnly);
+ QCOMPARE(tb.toolButtonStyle(), Qt::ToolButtonTextOnly);
+ QCOMPARE(mwSpy.size(), 1);
+ QCOMPARE(tbSpy.size(), 1);
+ QCOMPARE(*static_cast<const Qt::ToolButtonStyle *>(mwSpy.first().first().constData()),
+ Qt::ToolButtonTextOnly);
+ QCOMPARE(*static_cast<const Qt::ToolButtonStyle *>(tbSpy.first().first().constData()),
+ Qt::ToolButtonTextOnly);
+ mwSpy.clear();
+ tbSpy.clear();
+
+ // no-op
+ mw.setToolButtonStyle(Qt::ToolButtonTextOnly);
+ QCOMPARE(mw.toolButtonStyle(), Qt::ToolButtonTextOnly);
+ QCOMPARE(tb.toolButtonStyle(), Qt::ToolButtonTextOnly);
+ QCOMPARE(mwSpy.size(), 0);
+ QCOMPARE(tbSpy.size(), 0);
+
+ mw.setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
+ QCOMPARE(mw.toolButtonStyle(), Qt::ToolButtonTextBesideIcon);
+ QCOMPARE(tb.toolButtonStyle(), Qt::ToolButtonTextBesideIcon);
+ QCOMPARE(mwSpy.size(), 1);
+ QCOMPARE(tbSpy.size(), 1);
+ QCOMPARE(*static_cast<const Qt::ToolButtonStyle *>(mwSpy.first().first().constData()),
+ Qt::ToolButtonTextBesideIcon);
+ QCOMPARE(*static_cast<const Qt::ToolButtonStyle *>(tbSpy.first().first().constData()),
+ Qt::ToolButtonTextBesideIcon);
+ mwSpy.clear();
+ tbSpy.clear();
+
+ // no-op
+ mw.setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
+ QCOMPARE(mw.toolButtonStyle(), Qt::ToolButtonTextBesideIcon);
+ QCOMPARE(tb.toolButtonStyle(), Qt::ToolButtonTextBesideIcon);
+ QCOMPARE(mwSpy.size(), 0);
+ QCOMPARE(tbSpy.size(), 0);
+
+ mw.setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
+ QCOMPARE(mw.toolButtonStyle(), Qt::ToolButtonTextUnderIcon);
+ QCOMPARE(tb.toolButtonStyle(), Qt::ToolButtonTextUnderIcon);
+ QCOMPARE(mwSpy.size(), 1);
+ QCOMPARE(tbSpy.size(), 1);
+ QCOMPARE(*static_cast<const Qt::ToolButtonStyle *>(mwSpy.first().first().constData()),
+ Qt::ToolButtonTextUnderIcon);
+ QCOMPARE(*static_cast<const Qt::ToolButtonStyle *>(tbSpy.first().first().constData()),
+ Qt::ToolButtonTextUnderIcon);
+ mwSpy.clear();
+ tbSpy.clear();
+
+ // no-op
+ mw.setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
+ QCOMPARE(mw.toolButtonStyle(), Qt::ToolButtonTextUnderIcon);
+ QCOMPARE(tb.toolButtonStyle(), Qt::ToolButtonTextUnderIcon);
+ QCOMPARE(mwSpy.size(), 0);
+ QCOMPARE(tbSpy.size(), 0);
+
+ mw.setToolButtonStyle(Qt::ToolButtonIconOnly);
+ QCOMPARE(mw.toolButtonStyle(), Qt::ToolButtonIconOnly);
+ QCOMPARE(tb.toolButtonStyle(), Qt::ToolButtonIconOnly);
+ QCOMPARE(mwSpy.size(), 1);
+ QCOMPARE(tbSpy.size(), 1);
+ QCOMPARE(*static_cast<const Qt::ToolButtonStyle *>(mwSpy.first().first().constData()),
+ Qt::ToolButtonIconOnly);
+ QCOMPARE(*static_cast<const Qt::ToolButtonStyle *>(tbSpy.first().first().constData()),
+ Qt::ToolButtonIconOnly);
+ mwSpy.clear();
+ tbSpy.clear();
+
+ // no-op
+ mw.setToolButtonStyle(Qt::ToolButtonIconOnly);
+ QCOMPARE(mw.toolButtonStyle(), Qt::ToolButtonIconOnly);
+ QCOMPARE(tb.toolButtonStyle(), Qt::ToolButtonIconOnly);
+ QCOMPARE(mwSpy.size(), 0);
+ QCOMPARE(tbSpy.size(), 0);
+ }
+
+ {
+ QMainWindow mw;
+ QSignalSpy mwSpy(&mw, SIGNAL(toolButtonStyleChanged(Qt::ToolButtonStyle)));
+
+ mw.setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
+ QCOMPARE(mw.toolButtonStyle(), Qt::ToolButtonTextBesideIcon);
+ QCOMPARE(mwSpy.size(), 1);
+ QCOMPARE(*static_cast<const Qt::ToolButtonStyle *>(mwSpy.first().first().constData()),
+ Qt::ToolButtonTextBesideIcon);
+ mwSpy.clear();
+
+ QToolBar tb;
+ QSignalSpy tbSpy(&tb, SIGNAL(toolButtonStyleChanged(Qt::ToolButtonStyle)));
+
+ mw.addToolBar(&tb);
+
+ // newly added toolbars should also automatically pick up any
+ // size set on the main window
+ QCOMPARE(tb.toolButtonStyle(), Qt::ToolButtonTextBesideIcon);
+ QCOMPARE(tbSpy.size(), 1);
+ QCOMPARE(*static_cast<const Qt::ToolButtonStyle *>(tbSpy.first().first().constData()),
+ Qt::ToolButtonTextBesideIcon);
+ tbSpy.clear();
+
+ mw.removeToolBar(&tb);
+
+ // removed toolbars should keep their existing size and ignore
+ // mainwindow icon size changes
+ mw.setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
+ QCOMPARE(mw.toolButtonStyle(), Qt::ToolButtonTextUnderIcon);
+ QCOMPARE(tb.toolButtonStyle(), Qt::ToolButtonTextBesideIcon);
+ QCOMPARE(mwSpy.size(), 1);
+ QCOMPARE(*static_cast<const Qt::ToolButtonStyle *>(mwSpy.first().first().constData()),
+ Qt::ToolButtonTextUnderIcon);
+ QCOMPARE(tbSpy.size(), 0);
+ mwSpy.clear();
+ }
+}
+
+// With native menubar integration on Windows Mobile the menubar is not a child
+#ifndef Q_WS_WINCE_WM
+void tst_QMainWindow::menuBar()
+{
+ {
+ QMainWindow mw;
+ QVERIFY(mw.menuBar() != 0);
+ }
+
+ {
+ QMainWindow mw;
+ QPointer<QMenuBar> mb1 = new QMenuBar;
+ QPointer<QMenuBar> mb2 = new QMenuBar;
+
+ mw.setMenuBar(mb1);
+ QVERIFY(mw.menuBar() != 0);
+ QCOMPARE(mw.menuBar(), (QMenuBar *)mb1);
+ QCOMPARE(mb1->parentWidget(), (QWidget *)&mw);
+
+ mw.setMenuBar(0);
+ QVERIFY(mw.menuBar() != 0);
+ //we now call deleteLater on the previous menubar
+ QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
+ QVERIFY(mb1 == 0);
+
+ mw.setMenuBar(mb2);
+ QVERIFY(mw.menuBar() != 0);
+ QCOMPARE(mw.menuBar(), (QMenuBar *)mb2);
+ QCOMPARE(mb2->parentWidget(), (QWidget *)&mw);
+
+ mw.setMenuBar(0);
+ QVERIFY(mw.menuBar() != 0);
+ //we now call deleteLater on the previous menubar
+ QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
+ QVERIFY(mb2 == 0);
+
+ mb1 = new QMenuBar;
+ mw.setMenuBar(mb1);
+ QVERIFY(mw.menuBar() != 0);
+ QCOMPARE(mw.menuBar(), (QMenuBar *)mb1);
+
+ mb2 = new QMenuBar;
+ mw.setMenuBar(mb2);
+ QVERIFY(mw.menuBar() != 0);
+ QCOMPARE(mw.menuBar(), (QMenuBar *)mb2);
+ //we now call deleteLater on the previous menubar
+ QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
+ QVERIFY(mb1 == 0);
+
+ mb1 = new QMenuBar;
+ mw.setMenuBar(mb1);
+ QVERIFY(mw.menuBar() != 0);
+ QCOMPARE(mw.menuBar(), (QMenuBar *)mb1);
+ //we now call deleteLater on the previous menubar
+ QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
+ QVERIFY(mb2 == 0);
+
+ QPointer<QWidget> topLeftCornerWidget = new QWidget;
+ mb1->setCornerWidget(topLeftCornerWidget, Qt::TopLeftCorner);
+ QPointer<QWidget> topRightCornerWidget = new QWidget;
+ mb1->setCornerWidget(topRightCornerWidget, Qt::TopRightCorner);
+
+ mb2 = new QMenuBar;
+ mw.setMenuBar(mb2);
+ QVERIFY(mw.menuBar() != 0);
+ QCOMPARE(mw.menuBar(), (QMenuBar *)mb2);
+ //we now call deleteLater on the previous menubar
+ QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
+ QVERIFY(mb1 == 0);
+
+ QVERIFY(topLeftCornerWidget);
+ QCOMPARE(mb2->cornerWidget(Qt::TopLeftCorner), static_cast<QWidget *>(topLeftCornerWidget));
+ QVERIFY(topRightCornerWidget);
+ QCOMPARE(mb2->cornerWidget(Qt::TopRightCorner), static_cast<QWidget *>(topRightCornerWidget));
+
+ mw.setMenuBar(0);
+ QVERIFY(mw.menuBar() != 0);
+ //we now call deleteLater on the previous menubar
+ QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
+ QVERIFY(mb2 == 0);
+
+ QVERIFY(!topLeftCornerWidget);
+ QVERIFY(!topRightCornerWidget);
+ }
+}
+#endif
+
+void tst_QMainWindow::statusBar()
+{
+ {
+ QMainWindow mw;
+ QVERIFY(mw.statusBar() != 0);
+ }
+
+ {
+ QMainWindow mw;
+ QPointer<QStatusBar> sb1 = new QStatusBar;
+ QPointer<QStatusBar> sb2 = new QStatusBar;
+
+ mw.setStatusBar(sb1);
+ QVERIFY(mw.statusBar() != 0);
+ QCOMPARE(mw.statusBar(), (QStatusBar *)sb1);
+ QCOMPARE(sb1->parentWidget(), (QWidget *)&mw);
+
+ mw.setStatusBar(0);
+ QVERIFY(mw.statusBar() != 0);
+ //we now call deleteLater on the previous statusbar
+ QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
+ QVERIFY(sb1 == 0);
+
+ mw.setStatusBar(sb2);
+ QVERIFY(mw.statusBar() != 0);
+ QCOMPARE(mw.statusBar(), (QStatusBar *)sb2);
+ QCOMPARE(sb2->parentWidget(), (QWidget *)&mw);
+
+ mw.setStatusBar(0);
+ QVERIFY(mw.statusBar() != 0);
+ //we now call deleteLater on the previous statusbar
+ QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
+ QVERIFY(sb2 == 0);
+
+ sb1 = new QStatusBar;
+ mw.setStatusBar(sb1);
+ QVERIFY(mw.statusBar() != 0);
+ QCOMPARE(mw.statusBar(), (QStatusBar *)sb1);
+ QCOMPARE(sb1->parentWidget(), (QWidget *)&mw);
+
+ sb2 = new QStatusBar;
+ mw.setStatusBar(sb2);
+ QVERIFY(mw.statusBar() != 0);
+ QCOMPARE(mw.statusBar(), (QStatusBar *)sb2);
+ QCOMPARE(sb2->parentWidget(), (QWidget *)&mw);
+ //we now call deleteLater on the previous statusbar
+ QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
+ QVERIFY(sb1 == 0);
+
+ sb1 = new QStatusBar;
+ mw.setStatusBar(sb1);
+ QVERIFY(mw.statusBar() != 0);
+ QCOMPARE(mw.statusBar(), (QStatusBar *)sb1);
+ QCOMPARE(sb1->parentWidget(), (QWidget *)&mw);
+ //we now call deleteLater on the previous statusbar
+ QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
+ QVERIFY(sb2 == 0);
+
+ sb2 = new QStatusBar;
+ mw.setStatusBar(sb2);
+ QVERIFY(mw.statusBar() != 0);
+ QCOMPARE(mw.statusBar(), (QStatusBar *)sb2);
+ QCOMPARE(sb2->parentWidget(), (QWidget *)&mw);
+ //we now call deleteLater on the previous statusbar
+ QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
+ QVERIFY(sb1 == 0);
+ }
+
+ {
+ // deleting the status bar should remove it from the main window
+ QMainWindow mw;
+ QStatusBar *sb = mw.statusBar();
+ QMainWindowLayout *l = qFindChild<QMainWindowLayout *>(&mw);
+ QVERIFY(l);
+ int indexOfSb = l->indexOf(sb);
+ QVERIFY(indexOfSb != -1);
+ delete sb;
+ indexOfSb = l->indexOf(sb);
+ QVERIFY(indexOfSb == -1);
+ }
+}
+
+void tst_QMainWindow::centralWidget()
+{
+ {
+ QMainWindow mw;
+ QVERIFY(mw.centralWidget() == 0);
+ }
+
+ {
+ QMainWindow mw;
+ QPointer<QWidget> w1 = new QWidget;
+ QPointer<QWidget> w2 = new QWidget;
+
+ QVERIFY(mw.centralWidget() == 0);
+
+ mw.setCentralWidget(w1);
+ QVERIFY(mw.centralWidget() != 0);
+ QCOMPARE(mw.centralWidget(), (QWidget *)w1);
+ QCOMPARE(w1->parentWidget(), (QWidget *)&mw);
+
+ mw.setCentralWidget(w2);
+ QVERIFY(mw.centralWidget() != 0);
+ QCOMPARE(mw.centralWidget(), (QWidget *)w2);
+ QCOMPARE(w2->parentWidget(), (QWidget *)&mw);
+
+ mw.setCentralWidget(0);
+ QVERIFY(mw.centralWidget() == 0);
+
+ //we now call deleteLater on the previous central widgets
+ QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
+ QVERIFY(w1 == 0);
+ QVERIFY(w2 == 0);
+ }
+
+ {
+ // do it again, this time with the mainwindow shown, since
+ // this tends will activate the layout when setting the new
+ // central widget
+
+ QMainWindow mw;
+ mw.show();
+
+ QPointer<QWidget> w1 = new QWidget;
+ QPointer<QWidget> w2 = new QWidget;
+
+ QVERIFY(mw.centralWidget() == 0);
+
+ mw.setCentralWidget(w1);
+ QVERIFY(mw.centralWidget() != 0);
+ QCOMPARE(mw.centralWidget(), (QWidget *)w1);
+ QCOMPARE(w1->parentWidget(), (QWidget *)&mw);
+
+ mw.setCentralWidget(w2);
+ QVERIFY(mw.centralWidget() != 0);
+ QCOMPARE(mw.centralWidget(), (QWidget *)w2);
+ QCOMPARE(w2->parentWidget(), (QWidget *)&mw);
+
+ mw.setCentralWidget(0);
+ QVERIFY(mw.centralWidget() == 0);
+
+ //we now call deleteLater on the previous central widgets
+ QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
+ QVERIFY(w1 == 0);
+ QVERIFY(w2 == 0);
+ }
+}
+
+void tst_QMainWindow::corner()
+{
+ {
+ QMainWindow mw;
+
+ QCOMPARE(mw.corner(Qt::TopLeftCorner), Qt::TopDockWidgetArea);
+ QCOMPARE(mw.corner(Qt::TopRightCorner), Qt::TopDockWidgetArea);
+ QCOMPARE(mw.corner(Qt::BottomLeftCorner), Qt::BottomDockWidgetArea);
+ QCOMPARE(mw.corner(Qt::BottomRightCorner), Qt::BottomDockWidgetArea);
+ }
+
+ {
+ QMainWindow mw;
+
+ mw.setCorner(Qt::TopLeftCorner, Qt::LeftDockWidgetArea);
+ QCOMPARE(mw.corner(Qt::TopLeftCorner), Qt::LeftDockWidgetArea);
+ mw.setCorner(Qt::TopLeftCorner, Qt::TopDockWidgetArea);
+ QCOMPARE(mw.corner(Qt::TopLeftCorner), Qt::TopDockWidgetArea);
+
+ mw.setCorner(Qt::TopRightCorner, Qt::RightDockWidgetArea);
+ QCOMPARE(mw.corner(Qt::TopRightCorner), Qt::RightDockWidgetArea);
+ mw.setCorner(Qt::TopRightCorner, Qt::TopDockWidgetArea);
+ QCOMPARE(mw.corner(Qt::TopRightCorner), Qt::TopDockWidgetArea);
+
+ mw.setCorner(Qt::BottomLeftCorner, Qt::LeftDockWidgetArea);
+ QCOMPARE(mw.corner(Qt::BottomLeftCorner), Qt::LeftDockWidgetArea);
+ mw.setCorner(Qt::BottomLeftCorner, Qt::BottomDockWidgetArea);
+ QCOMPARE(mw.corner(Qt::BottomLeftCorner), Qt::BottomDockWidgetArea);
+
+ mw.setCorner(Qt::BottomRightCorner, Qt::RightDockWidgetArea);
+ QCOMPARE(mw.corner(Qt::BottomRightCorner), Qt::RightDockWidgetArea);
+ mw.setCorner(Qt::BottomRightCorner, Qt::BottomDockWidgetArea);
+ QCOMPARE(mw.corner(Qt::BottomRightCorner), Qt::BottomDockWidgetArea);
+ }
+}
+
+void tst_QMainWindow::addToolBarBreak()
+{
+ {
+ QMainWindow mw;
+ QToolBar tb1(&mw);
+ mw.addToolBar(Qt::TopToolBarArea, &tb1);
+ mw.addToolBarBreak(Qt::TopToolBarArea);
+ QToolBar tb2(&mw);
+ mw.addToolBar(Qt::TopToolBarArea, &tb2);
+ mw.addToolBarBreak(Qt::TopToolBarArea);
+ QToolBar tb3(&mw);
+ mw.addToolBar(Qt::TopToolBarArea, &tb3);
+ mw.addToolBarBreak(Qt::TopToolBarArea);
+ QToolBar tb4(&mw);
+ mw.addToolBar(Qt::TopToolBarArea, &tb4);
+
+ mw.layout()->invalidate();
+ mw.layout()->activate();
+
+ QCOMPARE(tb1.x(), 0);
+ QCOMPARE(tb1.y(), 0);
+ QCOMPARE(tb2.x(), 0);
+ QVERIFY(tb1.y() != tb2.y());
+ QCOMPARE(tb3.x(), 0);
+ QVERIFY(tb2.y() != tb3.y());
+ QCOMPARE(tb4.x(), 0);
+ QVERIFY(tb3.y() != tb4.y());
+ }
+
+ {
+ QMainWindow mw;
+ // should not crash, should get a warning instead
+ QTest::ignoreMessage(QtWarningMsg, "QMainWindow::addToolBarBreak: invalid 'area' argument");
+ mw.addToolBarBreak(Qt::NoToolBarArea);
+ }
+}
+
+void tst_QMainWindow::insertToolBarBreak()
+{
+ QMainWindow mw;
+ QToolBar tb1(&mw);
+ mw.addToolBar(Qt::TopToolBarArea, &tb1);
+ QToolBar tb2(&mw);
+ mw.addToolBar(Qt::TopToolBarArea, &tb2);
+ QToolBar tb3(&mw);
+ mw.addToolBar(Qt::TopToolBarArea, &tb3);
+ QToolBar tb4(&mw);
+ mw.addToolBar(Qt::TopToolBarArea, &tb4);
+
+ mw.insertToolBarBreak(&tb2);
+ mw.insertToolBarBreak(&tb3);
+ mw.insertToolBarBreak(&tb4);
+
+ mw.layout()->invalidate();
+ mw.layout()->activate();
+
+ QCOMPARE(tb1.x(), 0);
+ QCOMPARE(tb1.y(), 0);
+ QCOMPARE(tb2.x(), 0);
+ QVERIFY(tb1.y() != tb2.y());
+ QCOMPARE(tb3.x(), 0);
+ QVERIFY(tb2.y() != tb3.y());
+ QCOMPARE(tb4.x(), 0);
+ QVERIFY(tb3.y() != tb4.y());
+
+ QVERIFY(!mw.toolBarBreak(&tb1));
+ QVERIFY(mw.toolBarBreak(&tb4));
+ mw.removeToolBarBreak(&tb4);
+ QVERIFY(!mw.toolBarBreak(&tb4));
+
+}
+
+static bool findWidgetRecursively(QLayoutItem *li, QWidget *w)
+{
+ QLayout *lay = li->layout();
+ if (!lay)
+ return false;
+ int i = 0;
+ QLayoutItem *child;
+ while ((child = lay->itemAt(i))) {
+ if (child->widget() == w) {
+ return true;
+ } else if (findWidgetRecursively(child, w)) {
+ return true;
+ } else {
+ ++i;
+ }
+ }
+ return false;
+}
+
+void tst_QMainWindow::addToolBar()
+{
+ Qt::ToolBarArea areas[] = {
+ Qt::LeftToolBarArea,
+ Qt::RightToolBarArea,
+ Qt::TopToolBarArea,
+ Qt::BottomToolBarArea
+ };
+ const int areaCount = sizeof(areas) / sizeof(Qt::ToolBarArea);
+
+ for (int i = 0; i < areaCount; ++i) {
+ Qt::ToolBarArea area = areas[i];
+
+ QMainWindow mw;
+ QToolBar tb(&mw);
+ QVERIFY(!findWidgetRecursively(mw.layout(), &tb));
+ mw.addToolBar(area, &tb);
+ QVERIFY(findWidgetRecursively(mw.layout(), &tb));
+ }
+
+ {
+ // addToolBar() with no area, equivalent to top
+ QMainWindow mw;
+ QToolBar tb(&mw);
+ QVERIFY(!findWidgetRecursively(mw.layout(), &tb));
+ mw.addToolBar(&tb);
+ QVERIFY(findWidgetRecursively(mw.layout(), &tb));
+ }
+
+ {
+ QMainWindow mw;
+ QToolBar tb(&mw);
+ // should not crash, should get a warning instead
+ QTest::ignoreMessage(QtWarningMsg, "QMainWindow::addToolBar: invalid 'area' argument");
+ mw.addToolBar(Qt::NoToolBarArea, &tb);
+ }
+}
+
+void tst_QMainWindow::insertToolBar()
+{
+ Qt::ToolBarArea areas[] = {
+ Qt::LeftToolBarArea,
+ Qt::RightToolBarArea,
+ Qt::TopToolBarArea,
+ Qt::BottomToolBarArea
+ };
+ const int areaCount = sizeof(areas) / sizeof(Qt::ToolBarArea);
+
+ for (int i = 0; i < areaCount; ++i) {
+ Qt::ToolBarArea area = areas[i];
+
+ QMainWindow mw;
+ QToolBar tb1(&mw);
+ mw.addToolBar(area, &tb1);
+ QToolBar tb2(&mw);
+ mw.insertToolBar(&tb1, &tb2);
+ QVERIFY(findWidgetRecursively(mw.layout(), &tb1));
+ QVERIFY(findWidgetRecursively(mw.layout(), &tb2));
+ }
+
+ {
+ QMainWindow window;
+ QToolBar *bar1 = new QToolBar(QObject::tr("bar1"), &window);
+ bar1->addWidget(new QPushButton(QObject::tr("bar1")));
+ QToolBar *bar2 = new QToolBar(QLatin1String("bar2"));
+ bar2->addWidget(new QPushButton(QLatin1String("bar2")));
+ QToolBar *bar3 = new QToolBar(QLatin1String("bar3"));
+ bar3->addWidget(new QPushButton(QLatin1String("bar3")));
+
+ window.addToolBar(bar1);
+ window.addToolBar(bar3);
+ window.insertToolBar(bar1,bar2);
+ window.insertToolBar(bar1, bar3);
+
+ QVERIFY(!window.isVisible());
+ QVERIFY(!bar1->isVisible());
+ QVERIFY(!bar2->isVisible());
+ QVERIFY(!bar3->isVisible());
+
+ window.show();
+
+ QVERIFY(window.isVisible());
+ QVERIFY(bar1->isVisible());
+ QVERIFY(bar2->isVisible());
+ QVERIFY(bar3->isVisible());
+ }
+}
+
+void tst_QMainWindow::removeToolBar()
+{
+ Qt::ToolBarArea areas[] = {
+ Qt::LeftToolBarArea,
+ Qt::RightToolBarArea,
+ Qt::TopToolBarArea,
+ Qt::BottomToolBarArea
+ };
+ const int areaCount = sizeof(areas) / sizeof(Qt::ToolBarArea);
+
+ for (int i = 0; i < areaCount; ++i) {
+ Qt::ToolBarArea area = areas[i];
+
+ QMainWindow mw;
+ QToolBar tb1(&mw);
+ mw.addToolBar(area, &tb1);
+ QToolBar tb2(&mw);
+ mw.insertToolBar(&tb1, &tb2);
+ QVERIFY(findWidgetRecursively(mw.layout(), &tb1));
+ QVERIFY(findWidgetRecursively(mw.layout(), &tb2));
+
+ mw.removeToolBar(&tb1);
+ QVERIFY(!findWidgetRecursively(mw.layout(), &tb1));
+ QVERIFY(findWidgetRecursively(mw.layout(), &tb2));
+
+ mw.removeToolBar(&tb2);
+ QVERIFY(!findWidgetRecursively(mw.layout(), &tb1));
+ QVERIFY(!findWidgetRecursively(mw.layout(), &tb2));
+ }
+}
+
+void tst_QMainWindow::toolBarArea()
+{
+ Qt::ToolBarArea areas[] = {
+ Qt::LeftToolBarArea,
+ Qt::RightToolBarArea,
+ Qt::TopToolBarArea,
+ Qt::BottomToolBarArea
+ };
+ const int areaCount = sizeof(areas) / sizeof(Qt::ToolBarArea);
+
+ for (int i = 0; i < areaCount; ++i) {
+ Qt::ToolBarArea area = areas[i];
+
+ QMainWindow mw;
+ QToolBar tb(&mw);
+
+ for (int j = 0; j < areaCount; ++j) {
+ Qt::ToolBarArea otherArea = areas[j];
+
+ mw.addToolBar(area, &tb);
+ QCOMPARE(mw.toolBarArea(&tb), area);
+ mw.addToolBar(otherArea, &tb);
+ QCOMPARE(mw.toolBarArea(&tb), otherArea);
+ }
+ }
+
+ {
+ // addToolBar() with no area, equivalent to top
+ QMainWindow mw;
+ QToolBar tb(&mw);
+
+ for (int j = 0; j < areaCount; ++j) {
+ Qt::ToolBarArea otherArea = areas[j];
+
+ mw.addToolBar(&tb);
+ QCOMPARE(mw.toolBarArea(&tb), Qt::TopToolBarArea);
+ mw.addToolBar(otherArea, &tb);
+ QCOMPARE(mw.toolBarArea(&tb), otherArea);
+ }
+ }
+}
+
+void tst_QMainWindow::addDockWidget()
+{
+ Qt::DockWidgetArea areas[] = {
+ Qt::LeftDockWidgetArea,
+ Qt::RightDockWidgetArea,
+ Qt::TopDockWidgetArea,
+ Qt::BottomDockWidgetArea
+ };
+ const int areaCount = sizeof(areas) / sizeof(Qt::DockWidgetArea);
+
+ for (int i = 0; i < areaCount; ++i) {
+ Qt::DockWidgetArea area = areas[i];
+
+ QMainWindow mw;
+ QDockWidget dw(&mw);
+ QVERIFY(!findWidgetRecursively(mw.layout(), &dw));
+ mw.addDockWidget(area, &dw);
+ QVERIFY(findWidgetRecursively(mw.layout(), &dw));
+ }
+
+ for (int i = 0; i < areaCount; ++i) {
+ Qt::DockWidgetArea area = areas[i];
+
+ {
+ QMainWindow mw;
+ QDockWidget dw(&mw);
+ QVERIFY(!findWidgetRecursively(mw.layout(), &dw));
+ mw.addDockWidget(area, &dw, Qt::Horizontal);
+ QVERIFY(findWidgetRecursively(mw.layout(), &dw));
+ }
+
+ {
+ QMainWindow mw;
+ QDockWidget dw(&mw);
+ QVERIFY(!findWidgetRecursively(mw.layout(), &dw));
+ mw.addDockWidget(area, &dw, Qt::Vertical);
+ QVERIFY(findWidgetRecursively(mw.layout(), &dw));
+ }
+ }
+
+ {
+ QMainWindow mw;
+ QDockWidget dw(&mw);
+ // should not crash, should get a warning instead
+ QTest::ignoreMessage(QtWarningMsg, "QMainWindow::addDockWidget: invalid 'area' argument");
+ mw.addDockWidget(Qt::NoDockWidgetArea, &dw);
+ }
+}
+
+void tst_QMainWindow::splitDockWidget()
+{
+ Qt::DockWidgetArea areas[] = {
+ Qt::LeftDockWidgetArea,
+ Qt::RightDockWidgetArea,
+ Qt::TopDockWidgetArea,
+ Qt::BottomDockWidgetArea
+ };
+ const int areaCount = sizeof(areas) / sizeof(Qt::DockWidgetArea);
+
+ for (int i = 0; i < areaCount; ++i) {
+ Qt::DockWidgetArea area = areas[i];
+
+ {
+ QMainWindow mw;
+ QDockWidget dw1(&mw);
+ QVERIFY(!findWidgetRecursively(mw.layout(), &dw1));
+ mw.addDockWidget(area, &dw1);
+ QVERIFY(findWidgetRecursively(mw.layout(), &dw1));
+ QDockWidget dw2(&mw);
+ QVERIFY(!findWidgetRecursively(mw.layout(), &dw2));
+ mw.splitDockWidget(&dw1, &dw2, Qt::Horizontal);
+ QVERIFY(findWidgetRecursively(mw.layout(), &dw2));
+ }
+
+ {
+ QMainWindow mw;
+ QDockWidget dw1(&mw);
+ QVERIFY(!findWidgetRecursively(mw.layout(), &dw1));
+ mw.addDockWidget(area, &dw1);
+ QVERIFY(findWidgetRecursively(mw.layout(), &dw1));
+ QDockWidget dw2(&mw);
+ QVERIFY(!findWidgetRecursively(mw.layout(), &dw2));
+ mw.splitDockWidget(&dw1, &dw2, Qt::Horizontal);
+ QVERIFY(findWidgetRecursively(mw.layout(), &dw2));
+ }
+ }
+}
+
+void tst_QMainWindow::removeDockWidget()
+{
+ Qt::DockWidgetArea areas[] = {
+ Qt::LeftDockWidgetArea,
+ Qt::RightDockWidgetArea,
+ Qt::TopDockWidgetArea,
+ Qt::BottomDockWidgetArea
+ };
+ const int areaCount = sizeof(areas) / sizeof(Qt::DockWidgetArea);
+
+ for (int i = 0; i < areaCount; ++i) {
+ Qt::DockWidgetArea area = areas[i];
+
+ QMainWindow mw;
+ QDockWidget dw1(&mw);
+ mw.addDockWidget(area, &dw1);
+ QDockWidget dw2(&mw);
+ mw.addDockWidget(area, &dw2);
+ QVERIFY(findWidgetRecursively(mw.layout(), &dw1));
+ QVERIFY(findWidgetRecursively(mw.layout(), &dw2));
+
+ mw.removeDockWidget(&dw1);
+ QVERIFY(!findWidgetRecursively(mw.layout(), &dw1));
+ QVERIFY(findWidgetRecursively(mw.layout(), &dw2));
+
+ mw.removeDockWidget(&dw2);
+ QVERIFY(!findWidgetRecursively(mw.layout(), &dw1));
+ QVERIFY(!findWidgetRecursively(mw.layout(), &dw2));
+ }
+}
+
+void tst_QMainWindow::dockWidgetArea()
+{
+ Qt::DockWidgetArea areas[] = {
+ Qt::LeftDockWidgetArea,
+ Qt::RightDockWidgetArea,
+ Qt::TopDockWidgetArea,
+ Qt::BottomDockWidgetArea
+ };
+ const int areaCount = sizeof(areas) / sizeof(Qt::DockWidgetArea);
+
+ for (int i = 0; i < areaCount; ++i) {
+ Qt::DockWidgetArea area = areas[i];
+
+ QMainWindow mw;
+ QDockWidget dw(&mw);
+
+ for (int j = 0; j < areaCount; ++j) {
+ Qt::DockWidgetArea otherArea = areas[i];
+
+ mw.addDockWidget(area, &dw);
+ QCOMPARE(mw.dockWidgetArea(&dw), area);
+ mw.addDockWidget(otherArea, &dw);
+ QCOMPARE(mw.dockWidgetArea(&dw), otherArea);
+ }
+ }
+}
+
+void tst_QMainWindow::restoreState()
+{
+ QMainWindow mw;
+ QToolBar tb(&mw);
+ mw.addToolBar(Qt::TopToolBarArea, &tb);
+ QDockWidget dw(&mw);
+ mw.addDockWidget(Qt::LeftDockWidgetArea, &dw);
+
+ QByteArray state;
+
+ state = mw.saveState();
+ QVERIFY(mw.restoreState(state));
+
+ state = mw.saveState(1);
+ QVERIFY(!mw.restoreState(state));
+ QVERIFY(mw.restoreState(state, 1));
+}
+
+//tests the restoration of the previous versions of window settings
+void tst_QMainWindow::restoreStateFromPreviousVersion()
+{
+ QList<QByteArray> restoreData;
+ restoreData << QByteArray((char*)restoreData41, sizeof(restoreData41))
+ << QByteArray((char*)restoreData42, sizeof(restoreData42))
+ << QByteArray((char*)restoreData43, sizeof(restoreData43));
+
+ foreach(QByteArray ba, restoreData) {
+
+ QMainWindow win;
+ win.setCentralWidget(new QTextEdit);
+ QVector<QDockWidget*> docks;
+
+ for(int i = 0; i < 16; ++i) {
+ const QString name = QString::fromLatin1("dock %1").arg(i);
+ QDockWidget *dock = new QDockWidget(name);
+ docks += dock;
+ dock->setObjectName(name);
+ win.addDockWidget(Qt::TopDockWidgetArea, dock);
+ }
+ win.show();
+ QCOMPARE(win.restoreState(ba), true);
+
+ for( int i = 0; i < docks.size(); ++i) {
+ QCOMPARE( win.dockWidgetArea(docks[i]), Qt::DockWidgetArea(1 << i%4));
+ }
+ }
+
+}
+
+
+void tst_QMainWindow::createPopupMenu()
+{
+ {
+ QMainWindow mainwindow;
+ QVERIFY(!mainwindow.createPopupMenu());
+
+ QToolBar toolbar1(&mainwindow);
+ toolbar1.setWindowTitle("toolbar1");
+ QToolBar toolbar2(&mainwindow);
+ toolbar2.setWindowTitle("toolbar2");
+
+ mainwindow.addToolBar(&toolbar1);
+ mainwindow.addToolBar(&toolbar2);
+
+ QDockWidget dockwidget1(&mainwindow);
+ dockwidget1.setWindowTitle("dockwidget1");
+ QDockWidget dockwidget2(&mainwindow);
+ dockwidget2.setWindowTitle("dockwidget2");
+ QDockWidget dockwidget3(&mainwindow);
+ dockwidget3.setWindowTitle("dockwidget3");
+ QDockWidget dockwidget4(&mainwindow);
+ dockwidget4.setWindowTitle("dockwidget4");
+
+ mainwindow.addDockWidget(Qt::LeftDockWidgetArea, &dockwidget1);
+ mainwindow.addDockWidget(Qt::LeftDockWidgetArea, &dockwidget2);
+ mainwindow.addDockWidget(Qt::LeftDockWidgetArea, &dockwidget3);
+ mainwindow.addDockWidget(Qt::LeftDockWidgetArea, &dockwidget4);
+
+
+#ifdef QT_SOFTKEYS_ENABLED
+ // Softkeys add extra "Select" and "Back" actions to menu by default.
+ // Two first actions will be Select and Back when softkeys are enabled
+ int numSoftkeyActions = 2;
+#else
+ int numSoftkeyActions = 0;
+#endif
+
+ QMenu *menu = mainwindow.createPopupMenu();
+ QVERIFY(menu != 0);
+ QList<QAction *> actions = menu->actions();
+ QCOMPARE(actions.size(), 7 + numSoftkeyActions);
+
+ QCOMPARE(actions.at(0 + numSoftkeyActions), dockwidget1.toggleViewAction());
+ QCOMPARE(actions.at(1 + numSoftkeyActions), dockwidget2.toggleViewAction());
+ QCOMPARE(actions.at(2 + numSoftkeyActions), dockwidget3.toggleViewAction());
+ QCOMPARE(actions.at(3 + numSoftkeyActions), dockwidget4.toggleViewAction());
+ QVERIFY(actions.at(4 + numSoftkeyActions)->isSeparator());
+ QCOMPARE(actions.at(5 + numSoftkeyActions), toolbar1.toggleViewAction());
+ QCOMPARE(actions.at(6 + numSoftkeyActions), toolbar2.toggleViewAction());
+
+ delete menu;
+
+ mainwindow.removeToolBar(&toolbar1);
+ mainwindow.removeDockWidget(&dockwidget1);
+ mainwindow.removeDockWidget(&dockwidget4);
+
+ menu = mainwindow.createPopupMenu();
+ QVERIFY(menu != 0);
+ actions = menu->actions();
+ QCOMPARE(actions.size(), 4 + numSoftkeyActions);
+
+ QCOMPARE(actions.at(0 + numSoftkeyActions), dockwidget2.toggleViewAction());
+ QCOMPARE(actions.at(1 + numSoftkeyActions), dockwidget3.toggleViewAction());
+ QVERIFY(actions.at(2 + numSoftkeyActions)->isSeparator());
+ QCOMPARE(actions.at(3 + numSoftkeyActions), toolbar2.toggleViewAction());
+
+ delete menu;
+ }
+}
+
+class MyDockWidget : public QDockWidget
+{
+public:
+ MyDockWidget(QWidget * = 0) {
+ create(); // otherwise hide() doesn't result in a hide event
+ }
+};
+
+class MyWidget : public QWidget
+{
+public:
+ MyWidget(QWidget *parent = 0) : QWidget(parent)
+ {
+ }
+
+ QSize sizeHint() const
+ {
+ return QSize(200, 200);
+ }
+};
+
+void tst_QMainWindow::hideBeforeLayout()
+{
+ QMainWindow win;
+ QDockWidget *dock = new MyDockWidget(&win);
+ dock->setWidget(new QLabel("hello"));
+ win.addDockWidget(Qt::LeftDockWidgetArea, dock);
+ dock->hide();
+ win.resize(300, 300);
+ win.show();
+ dock->show();
+ QVERIFY(dock->geometry().bottomRight().x() >= 0);
+}
+
+struct AddDockWidget
+{
+ enum Mode { AddMode, SplitMode, TabMode };
+
+ AddDockWidget() {}
+ AddDockWidget(const QString &_name, Qt::DockWidgetArea _a)
+ : name(_name), mode(AddMode), a(_a) {}
+ AddDockWidget(const QString &_name, const QString &_other, Qt::Orientation _o)
+ : name(_name), mode(SplitMode), o(_o), other(_other) {}
+ AddDockWidget(const QString &_name, const QString &_other)
+ : name(_name), mode(TabMode), other(_other) {}
+
+ QString name;
+ Mode mode;
+
+ Qt::Orientation o;
+ Qt::DockWidgetArea a;
+ QString other;
+
+ void apply(QMainWindow *mw) const;
+};
+
+typedef QList<AddDockWidget> AddList;
+Q_DECLARE_METATYPE(AddList)
+
+void AddDockWidget::apply(QMainWindow *mw) const
+{
+ QDockWidget *dw = new QDockWidget();
+ QWidget *w = new QWidget();
+ w->setMinimumSize(100, 50);
+ dw->setWidget(w);
+
+ dw->setObjectName(name);
+ dw->setWindowTitle(name);
+
+ QDockWidget *other = 0;
+ if (mode == SplitMode || mode == TabMode) {
+ other = qFindChild<QDockWidget*>(mw, this->other);
+ QVERIFY(other != 0);
+ }
+
+ switch (mode) {
+ case AddMode:
+ mw->addDockWidget(a, dw);
+ break;
+ case SplitMode:
+ mw->splitDockWidget(other, dw, o);
+ break;
+ case TabMode:
+ mw->tabifyDockWidget(other, dw);
+ break;
+ }
+}
+
+#ifdef QT_BUILD_INTERNAL
+struct MoveSeparator
+{
+ MoveSeparator() {}
+ MoveSeparator(int _delta, const QString &_name)
+ : delta(_delta), name(_name) {}
+ MoveSeparator(int _delta, int _area)
+ : delta(_delta), area(_area) {}
+
+ int delta;
+ int area;
+ QString name;
+
+ void apply(QMainWindow *mw) const;
+};
+
+typedef QList<MoveSeparator> MoveList;
+Q_DECLARE_METATYPE(MoveList)
+
+void MoveSeparator::apply(QMainWindow *mw) const
+{
+ QMainWindowLayout *l = qFindChild<QMainWindowLayout *>(mw);
+ QVERIFY(l);
+
+ QList<int> path;
+ if (name.isEmpty()) {
+ path << area;
+ } else {
+ QDockWidget *dw = qFindChild<QDockWidget*>(mw, name);
+ QVERIFY(dw != 0);
+ path = l->layoutState.dockAreaLayout.indexOf(dw);
+ }
+ QVERIFY(!path.isEmpty());
+
+ l->layoutState.dockAreaLayout.separatorMove(path, QPoint(0, 0), QPoint(delta, delta));
+}
+#endif
+
+QMap<QString, QRect> dockWidgetGeometries(QMainWindow *mw)
+{
+ QMap<QString, QRect> result;
+ QList<QDockWidget*> dockWidgets = qFindChildren<QDockWidget*>(mw);
+ foreach (QDockWidget *dw, dockWidgets)
+ result.insert(dw->objectName(), dw->geometry());
+ return result;
+}
+
+#define COMPARE_DOCK_WIDGET_GEOS(_oldGeos, _newGeos) \
+{ \
+ QMap<QString, QRect> __oldGeos = _oldGeos; \
+ QMap<QString, QRect> __newGeos = _newGeos; \
+ QCOMPARE(__newGeos.keys(), __oldGeos.keys()); \
+ QStringList __keys = __newGeos.keys(); \
+ foreach (const QString &key, __keys) { \
+ QRect __r1 = __oldGeos[key]; \
+ QRect __r2 = __newGeos[key]; \
+ if (__r1 != __r2) \
+ qWarning() << key << __r1 << __r2; \
+ } \
+ QCOMPARE(__newGeos, __oldGeos); \
+}
+
+void tst_QMainWindow::saveRestore_data()
+{
+#ifdef QT_BUILD_INTERNAL
+ QTest::addColumn<AddList >("addList");
+ QTest::addColumn<MoveList >("moveList");
+
+ QTest::newRow("1") << (AddList()
+ << AddDockWidget("left", Qt::LeftDockWidgetArea))
+ << (MoveList()
+ << MoveSeparator(100, QInternal::LeftDock));
+
+ QTest::newRow("2") << (AddList()
+ << AddDockWidget("left", Qt::LeftDockWidgetArea)
+ << AddDockWidget("right", Qt::RightDockWidgetArea))
+ << (MoveList()
+ << MoveSeparator(70, QInternal::LeftDock)
+ << MoveSeparator(-40, QInternal::RightDock));
+ QTest::newRow("3") << (AddList()
+ << AddDockWidget("left", Qt::LeftDockWidgetArea)
+ << AddDockWidget("right1", Qt::RightDockWidgetArea)
+ << AddDockWidget("right2", Qt::RightDockWidgetArea))
+ << (MoveList()
+ << MoveSeparator(70, QInternal::LeftDock)
+ << MoveSeparator(-40, QInternal::RightDock));
+
+ QTest::newRow("4") << (AddList()
+ << AddDockWidget("left", Qt::LeftDockWidgetArea)
+ << AddDockWidget("right1", Qt::RightDockWidgetArea)
+ << AddDockWidget("right2a", Qt::RightDockWidgetArea)
+ << AddDockWidget("right2b", "right2a", Qt::Horizontal)
+ )
+ << (MoveList()
+ << MoveSeparator(70, QInternal::LeftDock)
+ << MoveSeparator(-40, QInternal::RightDock)
+ << MoveSeparator(-30, "right1")
+ << MoveSeparator(30, "right2a")
+ );
+#endif
+}
+
+void tst_QMainWindow::saveRestore()
+{
+#ifdef QT_BUILD_INTERNAL
+ QFETCH(AddList, addList);
+ QFETCH(MoveList, moveList);
+
+ QByteArray stateData;
+ QMap<QString, QRect> dockWidgetGeos;
+ QSize size;
+
+ {
+ QMainWindow mainWindow;
+ mainWindow.setDockNestingEnabled(true);
+ QTextEdit centralWidget("The rain in Spain falls mainly on the plains");
+ mainWindow.setCentralWidget(&centralWidget);
+
+ foreach (const AddDockWidget &adw, addList)
+ adw.apply(&mainWindow);
+
+ mainWindow.show();
+
+ foreach (const MoveSeparator &ms, moveList)
+ ms.apply(&mainWindow);
+
+ dockWidgetGeos = dockWidgetGeometries(&mainWindow);
+ size = mainWindow.size();
+ stateData = mainWindow.saveState();
+
+ mainWindow.layout()->setGeometry(mainWindow.rect());
+ COMPARE_DOCK_WIDGET_GEOS(dockWidgetGeos, dockWidgetGeometries(&mainWindow));
+
+#if 0
+ QEventLoop eventLoop;
+ QPushButton quitButton("Quit", &centralWidget);
+ quitButton.setGeometry(0, 0, 100, 40);
+ connect(&quitButton, SIGNAL(clicked()), &eventLoop, SLOT(quit()));
+ quitButton.show();
+ eventLoop.exec();
+#endif
+ }
+
+ // restoreState() after show
+ {
+ QMainWindow mainWindow;
+ mainWindow.setDockNestingEnabled(true);
+ QTextEdit centralWidget("The rain in Spain falls mainly on the plains");
+ mainWindow.setCentralWidget(&centralWidget);
+
+ foreach (const AddDockWidget &adw, addList)
+ adw.apply(&mainWindow);
+
+ mainWindow.show();
+ mainWindow.restoreState(stateData);
+
+ COMPARE_DOCK_WIDGET_GEOS(dockWidgetGeos, dockWidgetGeometries(&mainWindow));
+ }
+
+ // restoreState() before show
+ {
+ QMainWindow mainWindow;
+ mainWindow.setDockNestingEnabled(true);
+ QTextEdit centralWidget("The rain in Spain falls mainly on the plains");
+ mainWindow.setCentralWidget(&centralWidget);
+
+ foreach (const AddDockWidget &adw, addList)
+ adw.apply(&mainWindow);
+ mainWindow.resize(size);
+ mainWindow.restoreState(stateData);
+
+ mainWindow.show();
+ COMPARE_DOCK_WIDGET_GEOS(dockWidgetGeos, dockWidgetGeometries(&mainWindow));
+ }
+#endif
+}
+
+void tst_QMainWindow::isSeparator()
+{
+ QMainWindow mw;
+ QDockWidget *dockw = new QDockWidget();
+ mw.addDockWidget(Qt::LeftDockWidgetArea, dockw);
+ mw.addDockWidget(Qt::LeftDockWidgetArea, new QDockWidget());
+ dockw->resize(10,10);
+ mw.show();
+
+ //In case the separator size is 1, we increase it to 3 inside the QMainWindow class
+ const int margin = mw.style()->pixelMetric(QStyle::PM_DockWidgetSeparatorExtent, 0, &mw) == 1 ? 2 : 0;
+ QVERIFY(!mw.isSeparator(QPoint(4, dockw->pos().y())));
+ QVERIFY(!mw.isSeparator(QPoint(4, dockw->pos().y() + dockw->size().height() - 1 - margin)));
+ QVERIFY( mw.isSeparator(QPoint(4, dockw->pos().y() + dockw->size().height())));
+ QVERIFY( mw.isSeparator(QPoint(4, dockw->pos().y() + dockw->size().height() + margin)));
+ QVERIFY(!mw.isSeparator(QPoint(4, dockw->pos().y() + dockw->size().height() + 15)));
+
+}
+
+class MainWindow : public QMainWindow {
+ public:
+ using QMainWindow::event;
+};
+
+#ifndef QT_NO_CURSOR
+void tst_QMainWindow::setCursor()
+{
+ MainWindow mw;
+ QCursor cur = Qt::WaitCursor;
+ mw.setCursor(cur);
+ QCOMPARE(cur.shape(), mw.cursor().shape());
+ mw.resize(200,200);
+ mw.show();
+ QTest::qWait(50);
+ QCOMPARE(cur.shape(), mw.cursor().shape());
+
+ QHoverEvent enterE(QEvent::HoverEnter, QPoint(10,10), QPoint());
+ mw.event(&enterE);
+ QTest::qWait(50);
+ QCOMPARE(cur.shape(), mw.cursor().shape());
+
+ QHoverEvent leaveE(QEvent::HoverLeave, QPoint(), QPoint());
+ mw.event(&leaveE);
+ QTest::qWait(50);
+ QCOMPARE(cur.shape(), mw.cursor().shape());
+}
+#endif
+
+void tst_QMainWindow::addToolbarAfterShow()
+{
+ //this is for task 243119
+ QMainWindow mainWindow;
+ mainWindow.show();
+
+ QToolBar toolBar;
+ mainWindow.addToolBar(&toolBar);
+ QTest::qWait(100);
+
+ QVERIFY(!toolBar.isHidden());
+}
+
+void tst_QMainWindow::centralWidgetSize()
+{
+ if(PlatformQuirks::isAutoMaximizing())
+ QSKIP("The platform is auto maximizing, so the test makes no sense", SkipAll);;
+
+ QMainWindow mainWindow;
+ mainWindow.menuBar()->addMenu("menu");
+
+ MyWidget widget;
+ mainWindow.setCentralWidget(&widget);
+
+ mainWindow.show();
+ QTest::qWait(100);
+ QCOMPARE(widget.size(), widget.sizeHint());
+}
+
+void tst_QMainWindow::dockWidgetSize()
+{
+ QMainWindow mainWindow;
+ mainWindow.menuBar()->addMenu("menu");
+
+ MyWidget widget;
+ mainWindow.setCentralWidget(&widget);
+
+ QDockWidget dock;
+ dock.setWidget(new MyWidget);
+ mainWindow.addDockWidget(Qt::TopDockWidgetArea, &dock);
+
+ mainWindow.show();
+ QTest::qWait(100);
+ if (mainWindow.size() == mainWindow.sizeHint()) {
+ QCOMPARE(widget.size(), widget.sizeHint());
+ QCOMPARE(dock.widget()->size(), dock.widget()->sizeHint());
+ } else {
+ //otherwise the screen is too small and the size are irrelevant
+ }
+}
+
+void tst_QMainWindow::QTBUG2774_stylechange()
+{
+
+ QMainWindow mw;
+ QDockWidget *dockw = new QDockWidget();
+ mw.addDockWidget(Qt::LeftDockWidgetArea, dockw);
+ mw.addDockWidget(Qt::LeftDockWidgetArea, new QDockWidget());
+ QTextEdit *central = new QTextEdit(&mw);
+ mw.setCentralWidget(central);
+ dockw->resize(10,10);
+ mw.show();
+ QTest::qWaitForWindowShown(&mw);
+ int centralOriginalWidth = central->width();
+
+ QVERIFY(!mw.isSeparator(QPoint(4, dockw->pos().y() + dockw->size().height() - 3)));
+ QVERIFY( mw.isSeparator(QPoint(4, dockw->pos().y() + dockw->size().height())));
+ QVERIFY(!mw.isSeparator(QPoint(4, dockw->pos().y() + dockw->size().height() + 30)));
+
+
+ {
+ QTest::qWait(1000);
+ mw.setStyleSheet("QMainWindow::separator { width: 50px; height:50px; }");
+ QTest::qWait(5000);
+ QApplication::processEvents();
+ QVERIFY(central->width() < centralOriginalWidth);
+ QVERIFY( mw.isSeparator(QPoint(4, dockw->pos().y() + dockw->size().height())));
+ QVERIFY( mw.isSeparator(QPoint(4, dockw->pos().y() + dockw->size().height() + 49)));
+ }
+
+ {
+ mw.setStyleSheet("QMainWindow::separator { width: 0px; height: 0px; }");
+ QApplication::processEvents();
+ QVERIFY(central->width() > centralOriginalWidth);
+ QVERIFY(!mw.isSeparator(QPoint(4, dockw->pos().y() + dockw->size().height())));
+ QVERIFY(!mw.isSeparator(QPoint(4, dockw->pos().y() + dockw->size().height() + 1)));
+ }
+}
+
+#ifdef Q_OS_MAC
+void tst_QMainWindow::toggleUnifiedTitleAndToolBarOnMac()
+{
+ QMainWindow mw;
+ QToolBar *tb = new QToolBar;
+ tb->addAction("Test");
+ mw.addToolBar(tb);
+ mw.setUnifiedTitleAndToolBarOnMac(true);
+ mw.show();
+ QRect frameGeometry = mw.frameGeometry();
+ mw.setUnifiedTitleAndToolBarOnMac(false);
+ QVERIFY(frameGeometry.topLeft() == mw.frameGeometry().topLeft());
+ mw.setUnifiedTitleAndToolBarOnMac(true);
+ QVERIFY(frameGeometry.topLeft() == mw.frameGeometry().topLeft());
+}
+#endif
+
+QTEST_MAIN(tst_QMainWindow)
+#include "tst_qmainwindow.moc"
diff --git a/tests/auto/widgets/widgets/qmdiarea/.gitignore b/tests/auto/widgets/widgets/qmdiarea/.gitignore
new file mode 100644
index 0000000000..2632dbea40
--- /dev/null
+++ b/tests/auto/widgets/widgets/qmdiarea/.gitignore
@@ -0,0 +1 @@
+tst_qmdiarea
diff --git a/tests/auto/widgets/widgets/qmdiarea/qmdiarea.pro b/tests/auto/widgets/widgets/qmdiarea/qmdiarea.pro
new file mode 100644
index 0000000000..6a12152fcc
--- /dev/null
+++ b/tests/auto/widgets/widgets/qmdiarea/qmdiarea.pro
@@ -0,0 +1,14 @@
+load(qttest_p4)
+
+QT += gui-private widgets
+
+INCLUDEPATH += .
+SOURCES += tst_qmdiarea.cpp
+DEFINES += QT_NO_CAST_TO_ASCII QT_NO_CAST_FROM_ASCII
+contains(QT_CONFIG, opengl):QT += opengl
+
+mac {
+ LIBS += -framework Security
+}
+
+CONFIG+=insignificant_test
diff --git a/tests/auto/widgets/widgets/qmdiarea/tst_qmdiarea.cpp b/tests/auto/widgets/widgets/qmdiarea/tst_qmdiarea.cpp
new file mode 100644
index 0000000000..a4ce94cc3d
--- /dev/null
+++ b/tests/auto/widgets/widgets/qmdiarea/tst_qmdiarea.cpp
@@ -0,0 +1,2773 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#include <QtTest/QtTest>
+
+#include <QMdiSubWindow>
+#include <QMdiArea>
+
+#include <QApplication>
+#include <QMainWindow>
+#include <QMenuBar>
+#include <QPushButton>
+#include <QStyle>
+#include <QStyleOption>
+#include <QVBoxLayout>
+#include <QLineEdit>
+#include <QDesktopWidget>
+#include <QDockWidget>
+#include <QScrollBar>
+#include <QTextEdit>
+#ifndef QT_NO_OPENGL
+#include <QtOpenGL>
+#endif
+#include <QMacStyle>
+
+#include "../../../platformquirks.h"
+
+static const Qt::WindowFlags DefaultWindowFlags
+ = Qt::SubWindow | Qt::WindowSystemMenuHint
+ | Qt::WindowTitleHint | Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint;
+
+Q_DECLARE_METATYPE(QMdiArea::WindowOrder)
+Q_DECLARE_METATYPE(QMdiSubWindow *)
+Q_DECLARE_METATYPE(QList<int>)
+Q_DECLARE_METATYPE(QTabWidget::TabPosition)
+
+//TESTED_CLASS=
+//TESTED_FILES=
+
+static bool tabBetweenSubWindowsIn(QMdiArea *mdiArea, int tabCount = -1, bool reverse = false)
+{
+ if (!mdiArea) {
+ qWarning("Null pointer to mdi area");
+ return false;
+ }
+
+ QList<QMdiSubWindow *> subWindows = mdiArea->subWindowList();
+ const bool walkThrough = tabCount == -1;
+
+ if (walkThrough) {
+ QMdiSubWindow *active = reverse ? subWindows.front() : subWindows.back();
+ mdiArea->setActiveSubWindow(active);
+ if (mdiArea->activeSubWindow() != active) {
+ qWarning("Failed to set active sub window");
+ return false;
+ }
+ tabCount = subWindows.size();
+ }
+
+ QWidget *focusWidget = qApp->focusWidget();
+ if (!focusWidget) {
+ qWarning("No focus widget");
+ return false;
+ }
+
+ Qt::KeyboardModifiers modifiers = reverse ? Qt::ShiftModifier : Qt::NoModifier;
+ Qt::Key key;
+#ifdef Q_WS_MAC
+ key = Qt::Key_Meta;
+ modifiers |= Qt::MetaModifier;
+#else
+ key = Qt::Key_Control;
+ modifiers |= Qt::ControlModifier;
+#endif
+
+ QTest::keyPress(focusWidget, key, modifiers);
+ for (int i = 0; i < tabCount; ++i) {
+ QTest::keyPress(focusWidget, reverse ? Qt::Key_Backtab : Qt::Key_Tab, modifiers);
+ if (tabCount > 1)
+ QTest::qWait(500);
+ if (walkThrough) {
+ QRubberBand *rubberBand = qFindChild<QRubberBand *>(mdiArea->viewport());
+ if (!rubberBand) {
+ qWarning("No rubber band");
+ return false;
+ }
+ QMdiSubWindow *subWindow = subWindows.at(reverse ? subWindows.size() -1 - i : i);
+ if (rubberBand->geometry() != subWindow->geometry()) {
+ qWarning("Rubber band has different geometry");
+ return false;
+ }
+ }
+ qApp->processEvents();
+ }
+ QTest::keyRelease(focusWidget, key);
+
+ return true;
+}
+
+static inline QTabBar::Shape tabBarShapeFrom(QTabWidget::TabShape shape, QTabWidget::TabPosition position)
+{
+ const bool rounded = (shape == QTabWidget::Rounded);
+ if (position == QTabWidget::North)
+ return rounded ? QTabBar::RoundedNorth : QTabBar::TriangularNorth;
+ if (position == QTabWidget::South)
+ return rounded ? QTabBar::RoundedSouth : QTabBar::TriangularSouth;
+ if (position == QTabWidget::East)
+ return rounded ? QTabBar::RoundedEast : QTabBar::TriangularEast;
+ if (position == QTabWidget::West)
+ return rounded ? QTabBar::RoundedWest : QTabBar::TriangularWest;
+ return QTabBar::RoundedNorth;
+}
+
+enum Arrangement {
+ Tiled,
+ Cascaded
+};
+
+static bool verifyArrangement(QMdiArea *mdiArea, Arrangement arrangement, const QList<int> &expectedIndices)
+{
+ if (!mdiArea || expectedIndices.isEmpty() || mdiArea->subWindowList().isEmpty())
+ return false;
+
+ const QList<QMdiSubWindow *> subWindows = mdiArea->subWindowList();
+ const QMdiSubWindow *const firstSubWindow = subWindows.at(0);
+
+ switch (arrangement) {
+ case Tiled:
+ {
+ // Calculate the number of rows and columns.
+ const int n = subWindows.count();
+ const int numColumns = qMax(qCeil(qSqrt(qreal(n))), 1);
+ const int numRows = qMax((n % numColumns) ? (n / numColumns + 1) : (n / numColumns), 1);
+
+ // Ensure that the geometry of all the subwindows are as expected by using
+ // QWidget::childAt starting from the middle of the topleft cell and subsequently
+ // adding rowWidth and rowHeight (going from left to right).
+ const int columnWidth = mdiArea->viewport()->width() / numColumns;
+ const int rowHeight = mdiArea->viewport()->height() / numRows;
+ QPoint subWindowPos(columnWidth / 2, rowHeight / 2);
+ for (int i = 0; i < numRows; ++i) {
+ for (int j = 0; j < numColumns; ++j) {
+ const int index = expectedIndices.at(i * numColumns + j);
+ QWidget *actual = mdiArea->viewport()->childAt(subWindowPos);
+ QMdiSubWindow *expected = subWindows.at(index);
+ if (actual != expected && !expected->isAncestorOf(actual))
+ return false;
+ subWindowPos.rx() += columnWidth;
+ }
+ subWindowPos.rx() = columnWidth / 2;
+ subWindowPos.ry() += rowHeight;
+ }
+ break;
+ }
+ case Cascaded:
+ {
+ // Calculate the delta (dx, dy) between two cascaded subwindows.
+ QStyleOptionTitleBar options;
+ options.initFrom(firstSubWindow);
+ int titleBarHeight = firstSubWindow->style()->pixelMetric(QStyle::PM_TitleBarHeight, &options);
+#ifdef Q_WS_MAC
+ // ### Remove this after the mac style has been fixed
+ if (qobject_cast<QMacStyle *>(firstSubWindow->style()))
+ titleBarHeight -= 4;
+#endif
+ const QFontMetrics fontMetrics = QFontMetrics(QApplication::font("QWorkspaceTitleBar"));
+ const int dy = qMax(titleBarHeight - (titleBarHeight - fontMetrics.height()) / 2, 1);
+ const int dx = 10;
+
+ // Current activation/stacking order.
+ const QList<QMdiSubWindow *> activationOrderList = mdiArea->subWindowList(QMdiArea::ActivationHistoryOrder);
+
+ // Ensure that the geometry of all the subwindows are as expected by using
+ // QWidget::childAt with the position of the first one and subsequently adding
+ // dx and dy.
+ QPoint subWindowPos(20, 5);
+ foreach (int expectedIndex, expectedIndices) {
+ QMdiSubWindow *expected = subWindows.at(expectedIndex);
+ expected->raise();
+ if (mdiArea->viewport()->childAt(subWindowPos) != expected)
+ return false;
+ expected->lower();
+ subWindowPos.rx() += dx;
+ subWindowPos.ry() += dy;
+ }
+
+ // Restore stacking order.
+ foreach (QMdiSubWindow *subWindow, activationOrderList) {
+ mdiArea->setActiveSubWindow(subWindow);
+ qApp->processEvents();
+ }
+ break;
+ }
+ default:
+ return false;
+ }
+ return true;
+}
+
+class tst_QMdiArea : public QObject
+{
+ Q_OBJECT
+public:
+ tst_QMdiArea();
+public slots:
+ void initTestCase();
+protected slots:
+ void activeChanged(QMdiSubWindow *child);
+
+private slots:
+ // Tests from QWorkspace
+ void subWindowActivated_data();
+ void subWindowActivated();
+ void subWindowActivated2();
+ void subWindowActivatedWithMinimize();
+ void showWindows();
+ void changeWindowTitle();
+ void changeModified();
+ void childSize();
+ void fixedSize();
+ // New tests
+ void minimumSizeHint();
+ void sizeHint();
+ void setActiveSubWindow();
+ void activeSubWindow();
+ void currentSubWindow();
+ void addAndRemoveWindows();
+ void addAndRemoveWindowsWithReparenting();
+ void removeSubWindow_2();
+ void closeWindows();
+ void activateNextAndPreviousWindow();
+ void subWindowList_data();
+ void subWindowList();
+ void setBackground();
+ void setViewport();
+ void tileSubWindows();
+ void cascadeAndTileSubWindows();
+ void resizeMaximizedChildWindows_data();
+ void resizeMaximizedChildWindows();
+ void focusWidgetAfterAddSubWindow();
+ void dontMaximizeSubWindowOnActivation();
+ void delayedPlacement();
+ void iconGeometryInMenuBar();
+ void resizeTimer();
+ void updateScrollBars();
+ void setActivationOrder_data();
+ void setActivationOrder();
+ void tabBetweenSubWindows();
+ void setViewMode();
+ void setTabsClosable();
+ void setTabsMovable();
+ void setTabShape();
+ void setTabPosition_data();
+ void setTabPosition();
+#if defined(Q_WS_WIN) || defined(Q_WS_X11)
+ void nativeSubWindows();
+#endif
+ void task_209615();
+ void task_236750();
+
+private:
+ QMdiSubWindow *activeWindow;
+ bool accelPressed;
+};
+
+tst_QMdiArea::tst_QMdiArea()
+ : activeWindow(0)
+{
+ qRegisterMetaType<QMdiSubWindow *>();
+}
+
+void tst_QMdiArea::initTestCase()
+{
+#ifdef Q_OS_WINCE //disable magic for WindowsCE
+ qApp->setAutoMaximizeThreshold(-1);
+#endif
+}
+
+// Old QWorkspace tests
+void tst_QMdiArea::activeChanged(QMdiSubWindow *child)
+{
+ activeWindow = child;
+}
+
+void tst_QMdiArea::subWindowActivated_data()
+{
+ // define the test elements we're going to use
+ QTest::addColumn<int>("count");
+
+ // create a first testdata instance and fill it with data
+ QTest::newRow( "data0" ) << 0;
+ QTest::newRow( "data1" ) << 1;
+ QTest::newRow( "data2" ) << 2;
+}
+
+void tst_QMdiArea::subWindowActivated()
+{
+ QMainWindow mw(0) ;
+ mw.menuBar();
+ QMdiArea *workspace = new QMdiArea(&mw);
+ workspace->setObjectName(QLatin1String("testWidget"));
+ mw.setCentralWidget(workspace);
+ QSignalSpy spy(workspace, SIGNAL(subWindowActivated(QMdiSubWindow *)));
+ connect( workspace, SIGNAL(subWindowActivated(QMdiSubWindow *)), this, SLOT(activeChanged(QMdiSubWindow *)));
+ mw.show();
+ qApp->setActiveWindow(&mw);
+
+ QFETCH( int, count );
+ int i;
+
+ for ( i = 0; i < count; ++i ) {
+ QWidget *widget = new QWidget(workspace, 0);
+ widget->setAttribute(Qt::WA_DeleteOnClose);
+ workspace->addSubWindow(widget)->show();
+ widget->show();
+ qApp->processEvents();
+ QVERIFY( activeWindow == workspace->activeSubWindow() );
+ QCOMPARE(spy.count(), 1);
+ spy.clear();
+ }
+
+ QList<QMdiSubWindow *> windows = workspace->subWindowList();
+ QCOMPARE( (int)windows.count(), count );
+
+ for ( i = 0; i < count; ++i ) {
+ QMdiSubWindow *window = windows.at(i);
+ window->showMinimized();
+ qApp->processEvents();
+ QVERIFY( activeWindow == workspace->activeSubWindow() );
+ if ( i == 1 )
+ QVERIFY( activeWindow == window );
+ }
+
+ for ( i = 0; i < count; ++i ) {
+ QMdiSubWindow *window = windows.at(i);
+ window->showNormal();
+ qApp->processEvents();
+ QVERIFY( window == activeWindow );
+ QVERIFY( activeWindow == workspace->activeSubWindow() );
+ }
+ spy.clear();
+
+ while (workspace->activeSubWindow() ) {
+ workspace->activeSubWindow()->close();
+ qApp->processEvents();
+ QVERIFY(activeWindow == workspace->activeSubWindow());
+ QCOMPARE(spy.count(), 1);
+ spy.clear();
+ }
+
+ QVERIFY(activeWindow == 0);
+ QVERIFY(workspace->activeSubWindow() == 0);
+ QCOMPARE(workspace->subWindowList().count(), 0);
+
+ {
+ workspace->hide();
+ QWidget *widget = new QWidget(workspace);
+ widget->setAttribute(Qt::WA_DeleteOnClose);
+ QMdiSubWindow *window = workspace->addSubWindow(widget);
+ widget->show();
+ QCOMPARE(spy.count(), 0);
+ workspace->show();
+ QCOMPARE(spy.count(), 1);
+ spy.clear();
+ QVERIFY( activeWindow == window );
+ window->close();
+ qApp->processEvents();
+ QCOMPARE(spy.count(), 1);
+ spy.clear();
+ QVERIFY( activeWindow == 0 );
+ }
+
+ {
+ workspace->hide();
+ QWidget *widget = new QWidget(workspace);
+ widget->setAttribute(Qt::WA_DeleteOnClose);
+ QMdiSubWindow *window = workspace->addSubWindow(widget);
+ widget->showMaximized();
+ qApp->sendPostedEvents();
+ QCOMPARE(spy.count(), 0);
+ spy.clear();
+ workspace->show();
+ QCOMPARE(spy.count(), 1);
+ spy.clear();
+ QVERIFY( activeWindow == window );
+ window->close();
+ qApp->processEvents();
+ QCOMPARE(spy.count(), 1);
+ spy.clear();
+ QVERIFY( activeWindow == 0 );
+ }
+
+ {
+ QWidget *widget = new QWidget(workspace);
+ widget->setAttribute(Qt::WA_DeleteOnClose);
+ QMdiSubWindow *window = workspace->addSubWindow(widget);
+ widget->showMinimized();
+ QCOMPARE(spy.count(), 1);
+ spy.clear();
+ QVERIFY( activeWindow == window );
+ QVERIFY(workspace->activeSubWindow() == window);
+ window->close();
+ qApp->processEvents();
+ QCOMPARE(spy.count(), 1);
+ spy.clear();
+ QVERIFY(workspace->activeSubWindow() == 0);
+ QVERIFY( activeWindow == 0 );
+ }
+}
+
+#ifdef Q_WS_MAC
+#include <Security/AuthSession.h>
+bool macHasAccessToWindowsServer()
+{
+ SecuritySessionId mySession;
+ SessionAttributeBits sessionInfo;
+ SessionGetInfo(callerSecuritySession, &mySession, &sessionInfo);
+ return (sessionInfo & sessionHasGraphicAccess);
+}
+#endif
+
+
+void tst_QMdiArea::subWindowActivated2()
+{
+ QMdiArea mdiArea;
+ QSignalSpy spy(&mdiArea, SIGNAL(subWindowActivated(QMdiSubWindow *)));
+ for (int i = 0; i < 5; ++i)
+ mdiArea.addSubWindow(new QWidget);
+ QCOMPARE(spy.count(), 0);
+ mdiArea.show();
+#ifdef Q_WS_X11
+ qt_x11_wait_for_window_manager(&mdiArea);
+#endif
+ QTest::qWaitForWindowShown(&mdiArea);
+ mdiArea.activateWindow();
+ QTest::qWait(100);
+
+ QTRY_COMPARE(spy.count(), 5);
+ QCOMPARE(mdiArea.activeSubWindow(), mdiArea.subWindowList().back());
+ spy.clear();
+
+ // Just to make sure another widget is on top wrt. stacking order.
+ // This will typically become the active window if things are broken.
+ QMdiSubWindow *staysOnTopWindow = mdiArea.subWindowList().at(3);
+ staysOnTopWindow->setWindowFlags(Qt::WindowStaysOnTopHint);
+ mdiArea.setActiveSubWindow(staysOnTopWindow);
+ QCOMPARE(spy.count(), 1);
+ QCOMPARE(mdiArea.activeSubWindow(), staysOnTopWindow);
+ spy.clear();
+
+ QMdiSubWindow *activeSubWindow = mdiArea.subWindowList().at(2);
+ mdiArea.setActiveSubWindow(activeSubWindow);
+ QCOMPARE(spy.count(), 1);
+ QCOMPARE(mdiArea.activeSubWindow(), activeSubWindow);
+ spy.clear();
+
+ // Check that we only emit _one_ signal and the active window
+ // is unchanged after hide/show.
+ mdiArea.hide();
+#ifdef Q_WS_X11
+ qt_x11_wait_for_window_manager(&mdiArea);
+#endif
+ QTest::qWait(100);
+ QTRY_COMPARE(spy.count(), 1);
+ QVERIFY(!mdiArea.activeSubWindow());
+ QCOMPARE(mdiArea.currentSubWindow(), activeSubWindow);
+ spy.clear();
+
+ mdiArea.show();
+#ifdef Q_WS_X11
+ qt_x11_wait_for_window_manager(&mdiArea);
+#endif
+ QTest::qWait(100);
+ QTRY_COMPARE(spy.count(), 1);
+ QCOMPARE(mdiArea.activeSubWindow(), activeSubWindow);
+ spy.clear();
+
+ if (PlatformQuirks::isAutoMaximizing())
+ QSKIP("Platform is auto maximizing, so no showMinimized()", SkipAll);
+
+ // Check that we only emit _one_ signal and the active window
+ // is unchanged after showMinimized/showNormal.
+ mdiArea.showMinimized();
+#ifdef Q_WS_X11
+ qt_x11_wait_for_window_manager(&mdiArea);
+#elif defined (Q_WS_MAC)
+ if (!macHasAccessToWindowsServer())
+ QEXPECT_FAIL("", "showMinimized doesn't really minimize if you don't have access to the server", Abort);
+#endif
+ QTest::qWait(10);
+#if defined(Q_WS_QWS)
+ QEXPECT_FAIL("", "task 168682", Abort);
+#endif
+#ifdef Q_OS_WINCE
+ QSKIP("Not fixed yet. See Task 197453", SkipAll);
+#endif
+ QTRY_COMPARE(spy.count(), 1);
+ QVERIFY(!mdiArea.activeSubWindow());
+ QCOMPARE(mdiArea.currentSubWindow(), activeSubWindow);
+ spy.clear();
+
+ mdiArea.showNormal();
+#ifdef Q_WS_X11
+ qt_x11_wait_for_window_manager(&mdiArea);
+#endif
+ QTest::qWait(100);
+ QTRY_COMPARE(spy.count(), 1);
+ QCOMPARE(mdiArea.activeSubWindow(), activeSubWindow);
+ spy.clear();
+}
+
+void tst_QMdiArea::subWindowActivatedWithMinimize()
+{
+ QMainWindow mw(0) ;
+ mw.menuBar();
+ QMdiArea *workspace = new QMdiArea(&mw);
+ workspace->setObjectName(QLatin1String("testWidget"));
+ mw.setCentralWidget(workspace);
+ QSignalSpy spy(workspace, SIGNAL(subWindowActivated(QMdiSubWindow *)));
+ connect( workspace, SIGNAL(subWindowActivated(QMdiSubWindow *)), this, SLOT(activeChanged(QMdiSubWindow *)) );
+ mw.show();
+ qApp->setActiveWindow(&mw);
+ QWidget *widget = new QWidget(workspace);
+ widget->setAttribute(Qt::WA_DeleteOnClose);
+ QMdiSubWindow *window1 = workspace->addSubWindow(widget);
+ QWidget *widget2 = new QWidget(workspace);
+ widget2->setAttribute(Qt::WA_DeleteOnClose);
+ QMdiSubWindow *window2 = workspace->addSubWindow(widget2);
+
+ widget->showMinimized();
+ QVERIFY( activeWindow == window1 );
+ widget2->showMinimized();
+ QVERIFY( activeWindow == window2 );
+
+ window2->close();
+ qApp->processEvents();
+ QVERIFY( activeWindow == window1 );
+
+ window1->close();
+ qApp->processEvents();
+ QVERIFY(workspace->activeSubWindow() == 0);
+ QVERIFY( activeWindow == 0 );
+
+ QVERIFY( workspace->subWindowList().count() == 0 );
+}
+
+void tst_QMdiArea::showWindows()
+{
+ QMdiArea *ws = new QMdiArea( 0 );
+
+ QWidget *widget = 0;
+ ws->show();
+
+ widget = new QWidget(ws);
+ widget->show();
+ QVERIFY( widget->isVisible() );
+
+ widget = new QWidget(ws);
+ widget->showMaximized();
+ QVERIFY( widget->isMaximized() );
+ widget->showNormal();
+ QVERIFY( !widget->isMaximized() );
+
+ widget = new QWidget(ws);
+ widget->showMinimized();
+ QVERIFY( widget->isMinimized() );
+ widget->showNormal();
+ QVERIFY( !widget->isMinimized() );
+
+ ws->hide();
+
+ widget = new QWidget(ws);
+ ws->show();
+ QVERIFY( widget->isVisible() );
+
+ ws->hide();
+
+ widget = new QWidget(ws);
+ widget->showMaximized();
+ QVERIFY( widget->isMaximized() );
+ ws->show();
+ QVERIFY( widget->isVisible() );
+ QVERIFY( widget->isMaximized() );
+ ws->hide();
+
+ widget = new QWidget(ws);
+ widget->showMinimized();
+ ws->show();
+ QVERIFY( widget->isMinimized() );
+ ws->hide();
+
+ delete ws;
+}
+
+
+//#define USE_SHOW
+
+void tst_QMdiArea::changeWindowTitle()
+{
+ const QString mwc = QString::fromLatin1("MainWindow's Caption");
+ const QString mwc2 = QString::fromLatin1("MainWindow's New Caption");
+ const QString wc = QString::fromLatin1("Widget's Caption");
+ const QString wc2 = QString::fromLatin1("Widget's New Caption");
+
+ QMainWindow *mw = new QMainWindow;
+ mw->setWindowTitle( mwc );
+ QMdiArea *ws = new QMdiArea( mw );
+ mw->setCentralWidget( ws );
+ mw->menuBar();
+ mw->show();
+ QTest::qWaitForWindowShown(mw);
+
+ QWidget *widget = new QWidget( ws );
+ widget->setWindowTitle( wc );
+ ws->addSubWindow(widget);
+
+ QCOMPARE( mw->windowTitle(), mwc );
+
+#ifdef USE_SHOW
+ widget->showMaximized();
+#else
+ widget->setWindowState(Qt::WindowMaximized);
+#endif
+#if !defined(Q_WS_MAC) && !defined(Q_OS_WINCE)
+ QTRY_COMPARE( mw->windowTitle(), QString::fromLatin1("%1 - [%2]").arg(mwc).arg(wc) );
+#endif
+
+ mw->hide();
+ qApp->processEvents();
+ mw->show();
+ qApp->processEvents();
+ QTest::qWaitForWindowShown(mw);
+
+#if !defined(Q_WS_MAC) && !defined(Q_OS_WINCE)
+ QTRY_COMPARE( mw->windowTitle(), QString::fromLatin1("%1 - [%2]").arg(mwc).arg(wc) );
+#endif
+
+#ifdef USE_SHOW
+ widget->showNormal();
+#else
+ widget->setWindowState(Qt::WindowNoState);
+#endif
+ qApp->processEvents();
+ QCOMPARE( mw->windowTitle(), mwc );
+
+#ifdef USE_SHOW
+ widget->showMaximized();
+#else
+ widget->setWindowState(Qt::WindowMaximized);
+#endif
+ qApp->processEvents();
+#if !defined(Q_WS_MAC) && !defined(Q_OS_WINCE)
+ QTRY_COMPARE( mw->windowTitle(), QString::fromLatin1("%1 - [%2]").arg(mwc).arg(wc) );
+ widget->setWindowTitle( wc2 );
+ QCOMPARE( mw->windowTitle(), QString::fromLatin1("%1 - [%2]").arg(mwc).arg(wc2) );
+ mw->setWindowTitle( mwc2 );
+ QCOMPARE( mw->windowTitle(), QString::fromLatin1("%1 - [%2]").arg(mwc2).arg(wc2) );
+#endif
+
+ mw->show();
+ qApp->setActiveWindow(mw);
+
+#ifdef USE_SHOW
+ mw->showFullScreen();
+#else
+ mw->setWindowState(Qt::WindowFullScreen);
+#endif
+
+ qApp->processEvents();
+#if !defined(Q_WS_MAC) && !defined(Q_OS_WINCE)
+ QCOMPARE( mw->windowTitle(), QString::fromLatin1("%1 - [%2]").arg(mwc2).arg(wc2) );
+#endif
+#ifdef USE_SHOW
+ widget->showNormal();
+#else
+ widget->setWindowState(Qt::WindowNoState);
+#endif
+ qApp->processEvents();
+#if defined(Q_WS_MAC) || defined(Q_OS_WINCE)
+ QCOMPARE(mw->windowTitle(), mwc);
+#else
+ QCOMPARE( mw->windowTitle(), mwc2 );
+#endif
+
+#ifdef USE_SHOW
+ widget->showMaximized();
+#else
+ widget->setWindowState(Qt::WindowMaximized);
+#endif
+ qApp->processEvents();
+#if !defined(Q_WS_MAC) && !defined(Q_OS_WINCE)
+ QCOMPARE( mw->windowTitle(), QString::fromLatin1("%1 - [%2]").arg(mwc2).arg(wc2) );
+#endif
+
+#ifdef USE_SHOW
+ mw->showNormal();
+#else
+ mw->setWindowState(Qt::WindowNoState);
+#endif
+ qApp->processEvents();
+#ifdef USE_SHOW
+ widget->showNormal();
+#else
+ widget->setWindowState(Qt::WindowNoState);
+#endif
+
+ delete mw;
+}
+
+void tst_QMdiArea::changeModified()
+{
+ const QString mwc = QString::fromLatin1("MainWindow's Caption");
+ const QString wc = QString::fromLatin1("Widget's Caption[*]");
+
+ QMainWindow *mw = new QMainWindow(0);
+ mw->setWindowTitle( mwc );
+ QMdiArea *ws = new QMdiArea( mw );
+ mw->setCentralWidget( ws );
+ mw->menuBar();
+ mw->show();
+
+ QWidget *widget = new QWidget( ws );
+ widget->setWindowTitle( wc );
+ ws->addSubWindow(widget);
+
+ QCOMPARE( mw->isWindowModified(), false);
+ QCOMPARE( widget->isWindowModified(), false);
+ widget->setWindowState(Qt::WindowMaximized);
+ QCOMPARE( mw->isWindowModified(), false);
+ QCOMPARE( widget->isWindowModified(), false);
+
+ widget->setWindowState(Qt::WindowNoState);
+ QCOMPARE( mw->isWindowModified(), false);
+ QCOMPARE( widget->isWindowModified(), false);
+
+ widget->setWindowModified(true);
+ QCOMPARE( mw->isWindowModified(), false);
+ QCOMPARE( widget->isWindowModified(), true);
+ widget->setWindowState(Qt::WindowMaximized);
+#if !defined(Q_WS_MAC) && !defined(Q_OS_WINCE)
+ QCOMPARE( mw->isWindowModified(), true);
+#endif
+ QCOMPARE( widget->isWindowModified(), true);
+
+ widget->setWindowState(Qt::WindowNoState);
+ QCOMPARE( mw->isWindowModified(), false);
+ QCOMPARE( widget->isWindowModified(), true);
+
+ widget->setWindowState(Qt::WindowMaximized);
+#if !defined(Q_WS_MAC) && !defined(Q_OS_WINCE)
+ QCOMPARE( mw->isWindowModified(), true);
+#endif
+ QCOMPARE( widget->isWindowModified(), true);
+
+ widget->setWindowModified(false);
+ QCOMPARE( mw->isWindowModified(), false);
+ QCOMPARE( widget->isWindowModified(), false);
+
+ widget->setWindowModified(true);
+#if !defined(Q_WS_MAC) && !defined(Q_OS_WINCE)
+ QCOMPARE( mw->isWindowModified(), true);
+#endif
+ QCOMPARE( widget->isWindowModified(), true);
+
+ widget->setWindowState(Qt::WindowNoState);
+ QCOMPARE( mw->isWindowModified(), false);
+ QCOMPARE( widget->isWindowModified(), true);
+
+ delete mw;
+}
+
+class MyChild : public QWidget
+{
+public:
+ MyChild(QWidget *parent = 0) : QWidget(parent) {}
+ QSize sizeHint() const { return QSize(234, 123); }
+};
+
+void tst_QMdiArea::childSize()
+{
+ QMdiArea ws;
+
+ MyChild *child = new MyChild(&ws);
+ child->show();
+ QCOMPARE(child->size(), child->sizeHint());
+ delete child;
+
+ child = new MyChild(&ws);
+ child->setFixedSize(200, 200);
+ child->show();
+ QCOMPARE(child->size(), child->minimumSize());
+ delete child;
+
+ child = new MyChild(&ws);
+ child->resize(150, 150);
+ child->show();
+ QCOMPARE(child->size(), QSize(150,150));
+ delete child;
+}
+
+void tst_QMdiArea::fixedSize()
+{
+ QMdiArea *ws = new QMdiArea;
+ int i;
+
+ ws->resize(500, 500);
+// ws->show();
+
+ QSize fixed(300, 300);
+ for (i = 0; i < 4; ++i) {
+ QWidget *child = new QWidget(ws);
+ child->setFixedSize(fixed);
+ child->show();
+ }
+
+ QList<QMdiSubWindow *> windows = ws->subWindowList();
+ for (i = 0; i < (int)windows.count(); ++i) {
+ QMdiSubWindow *child = windows.at(i);
+ QCOMPARE(child->size(), fixed);
+ }
+
+ ws->cascadeSubWindows();
+ ws->resize(800, 800);
+ for (i = 0; i < (int)windows.count(); ++i) {
+ QMdiSubWindow *child = windows.at(i);
+ QCOMPARE(child->size(), fixed);
+ }
+ ws->resize(500, 500);
+
+ ws->tileSubWindows();
+ ws->resize(800, 800);
+ for (i = 0; i < (int)windows.count(); ++i) {
+ QMdiSubWindow *child = windows.at(i);
+ QCOMPARE(child->size(), fixed);
+ }
+ ws->resize(500, 500);
+
+ for (i = 0; i < (int)windows.count(); ++i) {
+ QMdiSubWindow *child = windows.at(i);
+ delete child;
+ }
+
+ delete ws;
+}
+
+class LargeWidget : public QWidget
+{
+public:
+ LargeWidget(QWidget *parent = 0) : QWidget(parent) {}
+ QSize sizeHint() const { return QSize(1280, 1024); }
+ QSize minimumSizeHint() const { return QSize(300, 300); }
+};
+
+// New tests
+void tst_QMdiArea::minimumSizeHint()
+{
+ QMdiArea workspace;
+ workspace.show();
+ QSize expectedSize(workspace.style()->pixelMetric(QStyle::PM_MDIMinimizedWidth),
+ workspace.style()->pixelMetric(QStyle::PM_TitleBarHeight));
+ qApp->processEvents();
+ QAbstractScrollArea dummyScrollArea;
+ dummyScrollArea.setFrameStyle(QFrame::NoFrame);
+ expectedSize = expectedSize.expandedTo(dummyScrollArea.minimumSizeHint());
+ QCOMPARE(workspace.minimumSizeHint(), expectedSize.expandedTo(qApp->globalStrut()));
+
+ QWidget *window = workspace.addSubWindow(new QWidget);
+ qApp->processEvents();
+ window->show();
+ QCOMPARE(workspace.minimumSizeHint(), expectedSize.expandedTo(window->minimumSizeHint()));
+
+ QMdiSubWindow *subWindow = workspace.addSubWindow(new LargeWidget);
+ subWindow->show();
+ QCOMPARE(workspace.minimumSizeHint(), expectedSize.expandedTo(subWindow->minimumSizeHint()));
+
+ workspace.setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded);
+ workspace.setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
+ QCOMPARE(workspace.minimumSizeHint(), expectedSize);
+}
+
+void tst_QMdiArea::sizeHint()
+{
+ QMdiArea workspace;
+ workspace.show();
+ QSize desktopSize = QApplication::desktop()->size();
+ QSize expectedSize(desktopSize.width() * 2/3, desktopSize.height() * 2/3);
+ QCOMPARE(workspace.sizeHint(), expectedSize.expandedTo(qApp->globalStrut()));
+
+ QWidget *window = workspace.addSubWindow(new QWidget);
+ qApp->processEvents();
+ window->show();
+ QCOMPARE(workspace.sizeHint(), expectedSize.expandedTo(window->sizeHint()));
+
+ QMdiSubWindow *nested = workspace.addSubWindow(new QMdiArea);
+ expectedSize = QSize(desktopSize.width() * 2/6, desktopSize.height() * 2/6);
+ QCOMPARE(nested->widget()->sizeHint(), expectedSize);
+}
+
+void tst_QMdiArea::setActiveSubWindow()
+{
+ QMdiArea workspace;
+ workspace.show();
+
+ QSignalSpy spy(&workspace, SIGNAL(subWindowActivated(QMdiSubWindow *)));
+ connect(&workspace, SIGNAL(subWindowActivated(QMdiSubWindow *)), this, SLOT(activeChanged(QMdiSubWindow *)));
+ qApp->setActiveWindow(&workspace);
+
+ // Activate hidden windows
+ const int windowCount = 10;
+ QMdiSubWindow *windows[windowCount];
+ for (int i = 0; i < windowCount; ++i) {
+ windows[i] = qobject_cast<QMdiSubWindow *>(workspace.addSubWindow(new QWidget));
+ qApp->processEvents();
+ QVERIFY(windows[i]->isHidden());
+ workspace.setActiveSubWindow(windows[i]);
+ }
+ QCOMPARE(spy.count(), 0);
+ QVERIFY(!activeWindow);
+ spy.clear();
+
+ // Activate visible windows
+ for (int i = 0; i < windowCount; ++i) {
+ windows[i]->show();
+ QVERIFY(!windows[i]->isHidden());
+ workspace.setActiveSubWindow(windows[i]);
+ qApp->processEvents();
+ QCOMPARE(spy.count(), 1);
+ QCOMPARE(activeWindow, windows[i]);
+ spy.clear();
+ }
+
+ // Deactivate active window
+ QCOMPARE(workspace.activeSubWindow(), windows[windowCount - 1]);
+ workspace.setActiveSubWindow(0);
+ QCOMPARE(spy.count(), 1);
+ QVERIFY(!activeWindow);
+ QVERIFY(!workspace.activeSubWindow());
+
+ // Activate widget which is not child of any window inside workspace
+ QMdiSubWindow fakeWindow;
+ QTest::ignoreMessage(QtWarningMsg, "QMdiArea::setActiveSubWindow: window is not inside workspace");
+ workspace.setActiveSubWindow(&fakeWindow);
+
+}
+
+void tst_QMdiArea::activeSubWindow()
+{
+ QMainWindow mainWindow;
+
+ QMdiArea *mdiArea = new QMdiArea;
+ QLineEdit *subWindowLineEdit = new QLineEdit;
+ QMdiSubWindow *subWindow = mdiArea->addSubWindow(subWindowLineEdit);
+ mainWindow.setCentralWidget(mdiArea);
+
+ QDockWidget *dockWidget = new QDockWidget(QLatin1String("Dock Widget"), &mainWindow);
+ dockWidget->setAllowedAreas(Qt::LeftDockWidgetArea);
+ QLineEdit *dockWidgetLineEdit = new QLineEdit;
+ dockWidget->setWidget(dockWidgetLineEdit);
+ mainWindow.addDockWidget(Qt::LeftDockWidgetArea, dockWidget);
+
+ mainWindow.show();
+#ifdef Q_WS_X11
+ qt_x11_wait_for_window_manager(&mainWindow);
+#endif
+
+ qApp->setActiveWindow(&mainWindow);
+ QCOMPARE(mdiArea->activeSubWindow(), subWindow);
+ QCOMPARE(qApp->focusWidget(), (QWidget *)subWindowLineEdit);
+
+ dockWidgetLineEdit->setFocus();
+ QCOMPARE(qApp->focusWidget(), (QWidget *)dockWidgetLineEdit);
+ QCOMPARE(mdiArea->activeSubWindow(), subWindow);
+
+ QEvent deactivateEvent(QEvent::WindowDeactivate);
+ qApp->sendEvent(subWindow, &deactivateEvent);
+ QVERIFY(!mdiArea->activeSubWindow());
+ QCOMPARE(qApp->focusWidget(), (QWidget *)dockWidgetLineEdit);
+
+ QEvent activateEvent(QEvent::WindowActivate);
+ qApp->sendEvent(subWindow, &activateEvent);
+ QCOMPARE(mdiArea->activeSubWindow(), subWindow);
+ QCOMPARE(qApp->focusWidget(), (QWidget *)subWindowLineEdit);
+
+ QLineEdit dummyTopLevel;
+ dummyTopLevel.show();
+#ifdef Q_WS_X11
+ qt_x11_wait_for_window_manager(&dummyTopLevel);
+#endif
+
+ qApp->setActiveWindow(&dummyTopLevel);
+ QCOMPARE(mdiArea->activeSubWindow(), subWindow);
+
+ qApp->setActiveWindow(&mainWindow);
+ QCOMPARE(mdiArea->activeSubWindow(), subWindow);
+
+#if !defined(Q_WS_MAC) && !defined(Q_WS_WIN)
+ qApp->setActiveWindow(0);
+ QVERIFY(!mdiArea->activeSubWindow());
+#endif
+
+ //task 202657
+ dockWidgetLineEdit->setFocus();
+ qApp->setActiveWindow(&mainWindow);
+ QVERIFY(dockWidgetLineEdit->hasFocus());
+}
+
+void tst_QMdiArea::currentSubWindow()
+{
+ QMdiArea mdiArea;
+ mdiArea.show();
+#ifdef Q_WS_X11
+ qt_x11_wait_for_window_manager(&mdiArea);
+#endif
+
+ for (int i = 0; i < 5; ++i)
+ mdiArea.addSubWindow(new QLineEdit)->show();
+
+ qApp->setActiveWindow(&mdiArea);
+ QCOMPARE(qApp->activeWindow(), (QWidget *)&mdiArea);
+
+ // Check that the last added window is the active and the current.
+ QMdiSubWindow *active = mdiArea.activeSubWindow();
+ QVERIFY(active);
+ QCOMPARE(mdiArea.subWindowList().back(), active);
+ QCOMPARE(mdiArea.currentSubWindow(), active);
+
+ QLineEdit dummyTopLevel;
+ dummyTopLevel.show();
+#ifdef Q_WS_X11
+ qt_x11_wait_for_window_manager(&dummyTopLevel);
+#endif
+
+ // Move focus to another top-level and check that we still
+ // have an active window.
+ qApp->setActiveWindow(&dummyTopLevel);
+ QCOMPARE(qApp->activeWindow(), (QWidget *)&dummyTopLevel);
+ QVERIFY(mdiArea.activeSubWindow());
+
+ delete active;
+ active = 0;
+
+ // We just deleted the current sub-window -> current should then
+ // be the next in list (which in this case is the first sub-window).
+ QVERIFY(mdiArea.currentSubWindow());
+ QCOMPARE(mdiArea.currentSubWindow(), mdiArea.subWindowList().front());
+
+ // Activate mdi area and check that active == current.
+ qApp->setActiveWindow(&mdiArea);
+ active = mdiArea.activeSubWindow();
+ QVERIFY(active);
+ QCOMPARE(mdiArea.activeSubWindow(), mdiArea.subWindowList().front());
+
+ active->hide();
+ QCOMPARE(mdiArea.activeSubWindow(), active);
+ QCOMPARE(mdiArea.currentSubWindow(), active);
+
+ qApp->setActiveWindow(&dummyTopLevel);
+ QVERIFY(mdiArea.activeSubWindow());
+ QCOMPARE(mdiArea.currentSubWindow(), active);
+
+ qApp->setActiveWindow(&mdiArea);
+ active->show();
+ QCOMPARE(mdiArea.activeSubWindow(), active);
+
+ mdiArea.setActiveSubWindow(0);
+ QVERIFY(!mdiArea.activeSubWindow());
+ QVERIFY(!mdiArea.currentSubWindow());
+
+ mdiArea.setActiveSubWindow(active);
+ QCOMPARE(mdiArea.activeSubWindow(), active);
+ QEvent windowDeactivate(QEvent::WindowDeactivate);
+ qApp->sendEvent(active, &windowDeactivate);
+ QVERIFY(!mdiArea.activeSubWindow());
+ QVERIFY(!mdiArea.currentSubWindow());
+
+ QEvent windowActivate(QEvent::WindowActivate);
+ qApp->sendEvent(active, &windowActivate);
+ QVERIFY(mdiArea.activeSubWindow());
+ QVERIFY(mdiArea.currentSubWindow());
+
+#if !defined(Q_WS_MAC) && !defined(Q_WS_WIN)
+ qApp->setActiveWindow(0);
+ QVERIFY(!mdiArea.activeSubWindow());
+ QVERIFY(mdiArea.currentSubWindow());
+#endif
+}
+
+void tst_QMdiArea::addAndRemoveWindows()
+{
+ QWidget topLevel;
+ QMdiArea workspace(&topLevel);
+ workspace.resize(800, 600);
+ topLevel.show();
+#ifdef Q_WS_X11
+ qt_x11_wait_for_window_manager(&workspace);
+#endif
+
+ { // addSubWindow with large widget
+ QCOMPARE(workspace.subWindowList().count(), 0);
+ QWidget *window = workspace.addSubWindow(new LargeWidget);
+ QVERIFY(window);
+ qApp->processEvents();
+ QCOMPARE(workspace.subWindowList().count(), 1);
+ QVERIFY(window->windowFlags() == DefaultWindowFlags);
+ QCOMPARE(window->size(), workspace.viewport()->size());
+ }
+
+ { // addSubWindow, minimumSize set.
+ QMdiSubWindow *window = new QMdiSubWindow;
+ window->setMinimumSize(900, 900);
+ workspace.addSubWindow(window);
+ QVERIFY(window);
+ qApp->processEvents();
+ QCOMPARE(workspace.subWindowList().count(), 2);
+ QVERIFY(window->windowFlags() == DefaultWindowFlags);
+ QCOMPARE(window->size(), window->minimumSize());
+ }
+
+ { // addSubWindow, resized
+ QMdiSubWindow *window = new QMdiSubWindow;
+ window->setWidget(new QWidget);
+ window->resize(1500, 1500);
+ workspace.addSubWindow(window);
+ QVERIFY(window);
+ qApp->processEvents();
+ QCOMPARE(workspace.subWindowList().count(), 3);
+ QVERIFY(window->windowFlags() == DefaultWindowFlags);
+ QCOMPARE(window->size(), QSize(1500, 1500));
+ }
+
+ { // addSubWindow with 0 pointer
+ QTest::ignoreMessage(QtWarningMsg, "QMdiArea::addSubWindow: null pointer to widget");
+ QWidget *window = workspace.addSubWindow(0);
+ QVERIFY(!window);
+ QCOMPARE(workspace.subWindowList().count(), 3);
+ }
+
+ { // addChildWindow
+ QMdiSubWindow *window = new QMdiSubWindow;
+ workspace.addSubWindow(window);
+ qApp->processEvents();
+ QVERIFY(window->windowFlags() == DefaultWindowFlags);
+ window->setWidget(new QWidget);
+ QCOMPARE(workspace.subWindowList().count(), 4);
+ QTest::ignoreMessage(QtWarningMsg, "QMdiArea::addSubWindow: window is already added");
+ workspace.addSubWindow(window);
+ }
+
+ { // addChildWindow with 0 pointer
+ QTest::ignoreMessage(QtWarningMsg, "QMdiArea::addSubWindow: null pointer to widget");
+ workspace.addSubWindow(0);
+ QCOMPARE(workspace.subWindowList().count(), 4);
+ }
+
+ // removeSubWindow
+ foreach (QWidget *window, workspace.subWindowList()) {
+ workspace.removeSubWindow(window);
+ delete window;
+ }
+ QCOMPARE(workspace.subWindowList().count(), 0);
+
+ // removeSubWindow with 0 pointer
+ QTest::ignoreMessage(QtWarningMsg, "QMdiArea::removeSubWindow: null pointer to widget");
+ workspace.removeSubWindow(0);
+
+ workspace.addSubWindow(new QPushButton(QLatin1String("Dummy to make workspace non-empty")));
+ qApp->processEvents();
+ QCOMPARE(workspace.subWindowList().count(), 1);
+
+ // removeSubWindow with window not inside workspace
+ QTest::ignoreMessage(QtWarningMsg,"QMdiArea::removeSubWindow: window is not inside workspace");
+ QMdiSubWindow *fakeWindow = new QMdiSubWindow;
+ workspace.removeSubWindow(fakeWindow);
+ delete fakeWindow;
+
+ // Check that newly added windows don't occupy maximized windows'
+ // restore space.
+ workspace.closeAllSubWindows();
+ workspace.setOption(QMdiArea::DontMaximizeSubWindowOnActivation);
+ workspace.show();
+ QMdiSubWindow *window1 = workspace.addSubWindow(new QWidget);
+ window1->show();
+ const QRect window1RestoreGeometry = window1->geometry();
+ QCOMPARE(window1RestoreGeometry.topLeft(), QPoint(0, 0));
+
+ window1->showMinimized();
+
+ // Occupy space.
+ QMdiSubWindow *window2 = workspace.addSubWindow(new QWidget);
+ window2->show();
+ const QRect window2RestoreGeometry = window2->geometry();
+ QCOMPARE(window2RestoreGeometry.topLeft(), QPoint(0, 0));
+
+ window2->showMaximized();
+
+ // Don't occupy space.
+ QMdiSubWindow *window3 = workspace.addSubWindow(new QWidget);
+ window3->show();
+ QCOMPARE(window3->geometry().topLeft(), QPoint(window2RestoreGeometry.right() + 1, 0));
+}
+
+void tst_QMdiArea::addAndRemoveWindowsWithReparenting()
+{
+ QMdiArea workspace;
+ QMdiSubWindow window(&workspace);
+ QVERIFY(window.windowFlags() == DefaultWindowFlags);
+
+ // 0 because the window list contains widgets and not actual
+ // windows. Silly, but that's the behavior.
+ QCOMPARE(workspace.subWindowList().count(), 0);
+ window.setWidget(new QWidget);
+ qApp->processEvents();
+
+ QCOMPARE(workspace.subWindowList().count(), 1);
+ window.setParent(0); // Will also reset window flags
+ QCOMPARE(workspace.subWindowList().count(), 0);
+ window.setParent(&workspace);
+ QCOMPARE(workspace.subWindowList().count(), 1);
+ QVERIFY(window.windowFlags() == DefaultWindowFlags);
+
+ QTest::ignoreMessage(QtWarningMsg, "QMdiArea::addSubWindow: window is already added");
+ workspace.addSubWindow(&window);
+ QCOMPARE(workspace.subWindowList().count(), 1);
+}
+
+class MySubWindow : public QMdiSubWindow
+{
+public:
+ using QObject::receivers;
+};
+
+static int numberOfConnectedSignals(MySubWindow *subWindow)
+{
+ if (!subWindow)
+ return 0;
+
+ int numConnectedSignals = 0;
+ for (int i = 0; i < subWindow->metaObject()->methodCount(); ++i) {
+ QMetaMethod method = subWindow->metaObject()->method(i);
+ if (method.methodType() == QMetaMethod::Signal) {
+ QString signature(QLatin1String("2"));
+ signature += QLatin1String(method.signature());
+ numConnectedSignals += subWindow->receivers(signature.toLatin1());
+ }
+ }
+ return numConnectedSignals;
+}
+
+void tst_QMdiArea::removeSubWindow_2()
+{
+ QMdiArea mdiArea;
+ MySubWindow *subWindow = new MySubWindow;
+ QCOMPARE(numberOfConnectedSignals(subWindow), 0);
+
+ // Connected to aboutToActivate() and windowStateChanged().
+ mdiArea.addSubWindow(subWindow);
+ QVERIFY(numberOfConnectedSignals(subWindow) >= 2);
+
+ // Ensure we disconnect from all signals.
+ mdiArea.removeSubWindow(subWindow);
+ QCOMPARE(numberOfConnectedSignals(subWindow), 0);
+
+ mdiArea.addSubWindow(subWindow);
+ QVERIFY(numberOfConnectedSignals(subWindow) >= 2);
+ subWindow->setParent(0);
+ QCOMPARE(numberOfConnectedSignals(subWindow), 0);
+}
+
+void tst_QMdiArea::closeWindows()
+{
+ QMdiArea workspace;
+ workspace.show();
+ qApp->setActiveWindow(&workspace);
+
+ // Close widget
+ QWidget *widget = new QWidget;
+ QMdiSubWindow *subWindow = workspace.addSubWindow(widget);
+ qApp->processEvents();
+ QCOMPARE(workspace.subWindowList().count(), 1);
+ subWindow->close();
+ QCOMPARE(workspace.subWindowList().count(), 0);
+
+ // Close window
+ QWidget *window = workspace.addSubWindow(new QWidget);
+ qApp->processEvents();
+ QCOMPARE(workspace.subWindowList().count(), 1);
+ window->close();
+ qApp->processEvents();
+ QCOMPARE(workspace.subWindowList().count(), 0);
+
+ const int windowCount = 10;
+
+ // Close active window
+ for (int i = 0; i < windowCount; ++i)
+ workspace.addSubWindow(new QWidget)->show();
+ qApp->processEvents();
+ QCOMPARE(workspace.subWindowList().count(), windowCount);
+ int activeSubWindowCount = 0;
+ while (workspace.activeSubWindow()) {
+ workspace.activeSubWindow()->close();
+ qApp->processEvents();
+ ++activeSubWindowCount;
+ }
+ QCOMPARE(activeSubWindowCount, windowCount);
+ QCOMPARE(workspace.subWindowList().count(), 0);
+
+ // Close all windows
+ for (int i = 0; i < windowCount; ++i)
+ workspace.addSubWindow(new QWidget)->show();
+ qApp->processEvents();
+ QCOMPARE(workspace.subWindowList().count(), windowCount);
+ QSignalSpy spy(&workspace, SIGNAL(subWindowActivated(QMdiSubWindow *)));
+ connect(&workspace, SIGNAL(subWindowActivated(QMdiSubWindow *)), this, SLOT(activeChanged(QMdiSubWindow *)));
+ workspace.closeAllSubWindows();
+ qApp->processEvents();
+ QCOMPARE(workspace.subWindowList().count(), 0);
+ QCOMPARE(spy.count(), 1);
+ QVERIFY(!activeWindow);
+}
+
+void tst_QMdiArea::activateNextAndPreviousWindow()
+{
+ QMdiArea workspace;
+ workspace.show();
+ qApp->setActiveWindow(&workspace);
+
+ const int windowCount = 10;
+ QMdiSubWindow *windows[windowCount];
+ for (int i = 0; i < windowCount; ++i) {
+ windows[i] = qobject_cast<QMdiSubWindow *>(workspace.addSubWindow(new QWidget));
+ windows[i]->show();
+ qApp->processEvents();
+ }
+
+ QSignalSpy spy(&workspace, SIGNAL(subWindowActivated(QMdiSubWindow *)));
+ connect(&workspace, SIGNAL(subWindowActivated(QMdiSubWindow *)), this, SLOT(activeChanged(QMdiSubWindow *)));
+
+ // activateNextSubWindow
+ for (int i = 0; i < windowCount; ++i) {
+ workspace.activateNextSubWindow();
+ qApp->processEvents();
+ QCOMPARE(workspace.activeSubWindow(), windows[i]);
+ QCOMPARE(spy.count(), 1);
+ spy.clear();
+ }
+ QVERIFY(activeWindow);
+ QCOMPARE(workspace.activeSubWindow(), windows[windowCount - 1]);
+ QCOMPARE(workspace.activeSubWindow(), activeWindow);
+
+ // activatePreviousSubWindow
+ for (int i = windowCount - 2; i >= 0; --i) {
+ workspace.activatePreviousSubWindow();
+ qApp->processEvents();
+ QCOMPARE(workspace.activeSubWindow(), windows[i]);
+ QCOMPARE(spy.count(), 1);
+ spy.clear();
+ if (i % 2 == 0)
+ windows[i]->hide(); // 10, 8, 6, 4, 2, 0
+ }
+ QVERIFY(activeWindow);
+ QCOMPARE(workspace.activeSubWindow(), windows[0]);
+ QCOMPARE(workspace.activeSubWindow(), activeWindow);
+
+ // activateNextSubWindow with every 2nd window hidden
+ for (int i = 0; i < windowCount / 2; ++i) {
+ workspace.activateNextSubWindow(); // 1, 3, 5, 7, 9
+ QCOMPARE(spy.count(), 1);
+ spy.clear();
+ }
+ QCOMPARE(workspace.activeSubWindow(), windows[windowCount - 1]);
+
+ // activatePreviousSubWindow with every 2nd window hidden
+ for (int i = 0; i < windowCount / 2; ++i) {
+ workspace.activatePreviousSubWindow(); // 7, 5, 3, 1, 9
+ QCOMPARE(spy.count(), 1);
+ spy.clear();
+ }
+ QCOMPARE(workspace.activeSubWindow(), windows[windowCount - 1]);
+
+ workspace.setActiveSubWindow(0);
+ QVERIFY(!activeWindow);
+}
+
+void tst_QMdiArea::subWindowList_data()
+{
+ QTest::addColumn<QMdiArea::WindowOrder>("windowOrder");
+ QTest::addColumn<int>("windowCount");
+ QTest::addColumn<int>("activeSubWindow");
+ QTest::addColumn<int>("staysOnTop1");
+ QTest::addColumn<int>("staysOnTop2");
+
+ QTest::newRow("CreationOrder") << QMdiArea::CreationOrder << 10 << 4 << 8 << 5;
+ QTest::newRow("StackingOrder") << QMdiArea::StackingOrder << 10 << 6 << 3 << 9;
+ QTest::newRow("ActivationHistoryOrder") << QMdiArea::ActivationHistoryOrder << 10 << 7 << 2 << 1;
+}
+void tst_QMdiArea::subWindowList()
+{
+ QFETCH(QMdiArea::WindowOrder, windowOrder);
+ QFETCH(int, windowCount);
+ QFETCH(int, activeSubWindow);
+ QFETCH(int, staysOnTop1);
+ QFETCH(int, staysOnTop2);
+
+ QMdiArea workspace;
+ workspace.show();
+ qApp->setActiveWindow(&workspace);
+
+ QList<QMdiSubWindow *> activationOrder;
+ QVector<QMdiSubWindow *> windows;
+ for (int i = 0; i < windowCount; ++i) {
+ windows.append(qobject_cast<QMdiSubWindow *>(workspace.addSubWindow(new QWidget)));
+ windows[i]->show();
+ activationOrder.append(windows[i]);
+ }
+
+ {
+ QList<QMdiSubWindow *> widgets = workspace.subWindowList(windowOrder);
+ QCOMPARE(widgets.count(), windowCount);
+ for (int i = 0; i < widgets.count(); ++i)
+ QCOMPARE(widgets.at(i), windows[i]);
+ }
+
+ windows[staysOnTop1]->setWindowFlags(windows[staysOnTop1]->windowFlags() | Qt::WindowStaysOnTopHint);
+ workspace.setActiveSubWindow(windows[activeSubWindow]);
+ qApp->processEvents();
+ QCOMPARE(workspace.activeSubWindow(), windows[activeSubWindow]);
+ activationOrder.move(activationOrder.indexOf(windows[activeSubWindow]), windowCount - 1);
+
+ QList<QMdiSubWindow *> subWindows = workspace.subWindowList(windowOrder);
+ if (windowOrder == QMdiArea::CreationOrder) {
+ QCOMPARE(subWindows.at(activeSubWindow), windows[activeSubWindow]);
+ QCOMPARE(subWindows.at(staysOnTop1), windows[staysOnTop1]);
+ for (int i = 0; i < windowCount; ++i)
+ QCOMPARE(subWindows.at(i), windows[i]);
+ return;
+ }
+
+ if (windowOrder == QMdiArea::StackingOrder) {
+ QCOMPARE(subWindows.at(subWindows.count() - 1), windows[staysOnTop1]);
+ QCOMPARE(subWindows.at(subWindows.count() - 2), windows[activeSubWindow]);
+ QCOMPARE(subWindows.count(), windowCount);
+ } else { // ActivationHistoryOrder
+ QCOMPARE(subWindows, activationOrder);
+ }
+
+ windows[staysOnTop2]->setWindowFlags(windows[staysOnTop2]->windowFlags() | Qt::WindowStaysOnTopHint);
+ workspace.setActiveSubWindow(windows[staysOnTop2]);
+ qApp->processEvents();
+ QCOMPARE(workspace.activeSubWindow(), windows[staysOnTop2]);
+ activationOrder.move(activationOrder.indexOf(windows[staysOnTop2]), windowCount - 1);
+
+ workspace.setActiveSubWindow(windows[activeSubWindow]);
+ qApp->processEvents();
+ QCOMPARE(workspace.activeSubWindow(), windows[activeSubWindow]);
+ activationOrder.move(activationOrder.indexOf(windows[activeSubWindow]), windowCount - 1);
+
+ QList<QMdiSubWindow *> widgets = workspace.subWindowList(windowOrder);
+ QCOMPARE(widgets.count(), windowCount);
+ if (windowOrder == QMdiArea::StackingOrder) {
+ QCOMPARE(widgets.at(widgets.count() - 1), windows[staysOnTop2]);
+ QCOMPARE(widgets.at(widgets.count() - 2), windows[staysOnTop1]);
+ QCOMPARE(widgets.at(widgets.count() - 3), windows[activeSubWindow]);
+ } else { // ActivationHistory
+ QCOMPARE(widgets, activationOrder);
+ }
+
+ windows[activeSubWindow]->raise();
+ windows[staysOnTop2]->lower();
+
+ widgets = workspace.subWindowList(windowOrder);
+ if (windowOrder == QMdiArea::StackingOrder) {
+ QCOMPARE(widgets.at(widgets.count() - 1), windows[activeSubWindow]);
+ QCOMPARE(widgets.at(widgets.count() - 2), windows[staysOnTop1]);
+ QCOMPARE(widgets.at(0), windows[staysOnTop2]);
+ } else { // ActivationHistoryOrder
+ QCOMPARE(widgets, activationOrder);
+ }
+
+ windows[activeSubWindow]->stackUnder(windows[staysOnTop1]);
+ windows[staysOnTop2]->raise();
+
+ widgets = workspace.subWindowList(windowOrder);
+ if (windowOrder == QMdiArea::StackingOrder) {
+ QCOMPARE(widgets.at(widgets.count() - 1), windows[staysOnTop2]);
+ QCOMPARE(widgets.at(widgets.count() - 2), windows[staysOnTop1]);
+ QCOMPARE(widgets.at(widgets.count() - 3), windows[activeSubWindow]);
+ } else { // ActivationHistoryOrder
+ QCOMPARE(widgets, activationOrder);
+ }
+
+ workspace.setActiveSubWindow(windows[staysOnTop1]);
+ activationOrder.move(activationOrder.indexOf(windows[staysOnTop1]), windowCount - 1);
+
+ widgets = workspace.subWindowList(windowOrder);
+ if (windowOrder == QMdiArea::StackingOrder) {
+ QCOMPARE(widgets.at(widgets.count() - 1), windows[staysOnTop1]);
+ QCOMPARE(widgets.at(widgets.count() - 2), windows[staysOnTop2]);
+ QCOMPARE(widgets.at(widgets.count() - 3), windows[activeSubWindow]);
+ } else { // ActivationHistoryOrder
+ QCOMPARE(widgets, activationOrder);
+ }
+}
+
+void tst_QMdiArea::setBackground()
+{
+ QMdiArea workspace;
+ QCOMPARE(workspace.background(), workspace.palette().brush(QPalette::Dark));
+ workspace.setBackground(QBrush(Qt::green));
+ QCOMPARE(workspace.background(), QBrush(Qt::green));
+}
+
+void tst_QMdiArea::setViewport()
+{
+ QMdiArea workspace;
+ workspace.show();
+
+ QWidget *firstViewport = workspace.viewport();
+ QVERIFY(firstViewport);
+
+ const int windowCount = 10;
+ for (int i = 0; i < windowCount; ++i) {
+ QMdiSubWindow *window = workspace.addSubWindow(new QWidget);
+ window->show();
+ if (i % 2 == 0) {
+ window->showMinimized();
+ QVERIFY(window->isMinimized());
+ } else {
+ window->showMaximized();
+ QVERIFY(window->isMaximized());
+ }
+ }
+
+ qApp->processEvents();
+ QList<QMdiSubWindow *> windowsBeforeViewportChange = workspace.subWindowList();
+ QCOMPARE(windowsBeforeViewportChange.count(), windowCount);
+
+ workspace.setViewport(new QWidget);
+ qApp->processEvents();
+ QVERIFY(workspace.viewport() != firstViewport);
+
+ QList<QMdiSubWindow *> windowsAfterViewportChange = workspace.subWindowList();
+ QCOMPARE(windowsAfterViewportChange.count(), windowCount);
+ QCOMPARE(windowsAfterViewportChange, windowsBeforeViewportChange);
+
+ // for (int i = 0; i < windowCount; ++i) {
+ // QMdiSubWindow *window = windowsAfterViewportChange.at(i);
+ // if (i % 2 == 0)
+ // QVERIFY(!window->isMinimized());
+ //else
+ // QVERIFY(!window->isMaximized());
+ // }
+
+ QTest::ignoreMessage(QtWarningMsg, "QMdiArea: Deleting the view port is undefined, "
+ "use setViewport instead.");
+ delete workspace.viewport();
+ qApp->processEvents();
+
+ QCOMPARE(workspace.subWindowList().count(), 0);
+ QVERIFY(!workspace.activeSubWindow());
+}
+
+void tst_QMdiArea::tileSubWindows()
+{
+ QMdiArea workspace;
+ workspace.resize(600,480);
+ if (PlatformQuirks::isAutoMaximizing())
+ workspace.setWindowFlags(workspace.windowFlags() | Qt::X11BypassWindowManagerHint);
+ workspace.show();
+#ifdef Q_WS_X11
+ qt_x11_wait_for_window_manager(&workspace);
+#endif
+
+ const int windowCount = 10;
+ for (int i = 0; i < windowCount; ++i) {
+ QMdiSubWindow *subWindow = workspace.addSubWindow(new QWidget);
+ subWindow->setMinimumSize(50, 30);
+ subWindow->show();
+ }
+ workspace.tileSubWindows();
+ workspace.setActiveSubWindow(0);
+ QCOMPARE(workspace.viewport()->childrenRect(), workspace.viewport()->rect());
+
+ QList<QMdiSubWindow *> windows = workspace.subWindowList();
+ for (int i = 0; i < windowCount; ++i) {
+ QMdiSubWindow *window = windows.at(i);
+ for (int j = 0; j < windowCount; ++j) {
+ if (i == j)
+ continue;
+ QVERIFY(!window->geometry().intersects(windows.at(j)->geometry()));
+ }
+ }
+
+ // Keep the views tiled through any subsequent resize events.
+ for (int i = 0; i < 5; ++i) {
+ workspace.resize(workspace.size() - QSize(10, 10));
+ qApp->processEvents();
+ }
+ workspace.setActiveSubWindow(0);
+#ifndef Q_OS_WINCE //See Task 197453 ToDo
+ QCOMPARE(workspace.viewport()->childrenRect(), workspace.viewport()->rect());
+#endif
+
+ QMdiSubWindow *window = windows.at(0);
+
+ // Change the geometry of one of the children and verify
+ // that the views are not tiled anymore.
+ window->move(window->x() + 1, window->y());
+ workspace.resize(workspace.size() - QSize(10, 10));
+ workspace.setActiveSubWindow(0);
+ QVERIFY(workspace.viewport()->childrenRect() != workspace.viewport()->rect());
+ qApp->processEvents();
+
+ // Re-tile.
+ workspace.tileSubWindows();
+ workspace.setActiveSubWindow(0);
+ QCOMPARE(workspace.viewport()->childrenRect(), workspace.viewport()->rect());
+
+ // Close one of the children and verify that the views
+ // are not tiled anymore.
+ window->close();
+ workspace.resize(workspace.size() - QSize(10, 10));
+ workspace.setActiveSubWindow(0);
+ QVERIFY(workspace.viewport()->childrenRect() != workspace.viewport()->rect());
+ qApp->processEvents();
+
+ // Re-tile.
+ workspace.tileSubWindows();
+ workspace.setActiveSubWindow(0);
+ QCOMPARE(workspace.viewport()->childrenRect(), workspace.viewport()->rect());
+
+ window = windows.at(1);
+
+ // Maximize one of the children and verify that the views
+ // are not tiled anymore.
+ workspace.tileSubWindows();
+ window->showMaximized();
+ workspace.resize(workspace.size() - QSize(10, 10));
+ workspace.setActiveSubWindow(0);
+ QVERIFY(workspace.viewport()->childrenRect() != workspace.viewport()->rect());
+ qApp->processEvents();
+
+ // Re-tile.
+ workspace.tileSubWindows();
+ workspace.setActiveSubWindow(0);
+ QCOMPARE(workspace.viewport()->childrenRect(), workspace.viewport()->rect());
+
+ // Minimize one of the children and verify that the views
+ // are not tiled anymore.
+ workspace.tileSubWindows();
+ window->showMinimized();
+ workspace.resize(workspace.size() - QSize(10, 10));
+ workspace.setActiveSubWindow(0);
+ QVERIFY(workspace.viewport()->childrenRect() != workspace.viewport()->rect());
+ qApp->processEvents();
+
+ // Re-tile.
+ workspace.tileSubWindows();
+ workspace.setActiveSubWindow(0);
+ QCOMPARE(workspace.viewport()->childrenRect(), workspace.viewport()->rect());
+
+ // Active/deactivate windows and verify that the views are tiled.
+ workspace.setActiveSubWindow(windows.at(5));
+ workspace.resize(workspace.size() - QSize(10, 10));
+ workspace.setActiveSubWindow(0);
+ QTest::qWait(250); // delayed re-arrange of minimized windows
+ QTRY_COMPARE(workspace.viewport()->childrenRect(), workspace.viewport()->rect());
+
+ // Add another window and verify that the views are not tiled anymore.
+ workspace.addSubWindow(new QPushButton(QLatin1String("I'd like to mess up tiled views")))->show();
+ workspace.resize(workspace.size() - QSize(10, 10));
+ workspace.setActiveSubWindow(0);
+ QVERIFY(workspace.viewport()->childrenRect() != workspace.viewport()->rect());
+
+ // Re-tile.
+ workspace.tileSubWindows();
+ workspace.setActiveSubWindow(0);
+ QCOMPARE(workspace.viewport()->childrenRect(), workspace.viewport()->rect());
+
+ // Cascade and verify that the views are not tiled anymore.
+ workspace.cascadeSubWindows();
+ workspace.resize(workspace.size() - QSize(10, 10));
+ workspace.setActiveSubWindow(0);
+ QVERIFY(workspace.viewport()->childrenRect() != workspace.viewport()->rect());
+
+ // Make sure the active window is placed in top left corner regardless
+ // of whether we have any windows with staysOnTopHint or not.
+ windows.at(3)->setWindowFlags(windows.at(3)->windowFlags() | Qt::WindowStaysOnTopHint);
+ QMdiSubWindow *activeSubWindow = windows.at(6);
+ workspace.setActiveSubWindow(activeSubWindow);
+ QCOMPARE(workspace.activeSubWindow(), activeSubWindow);
+ workspace.tileSubWindows();
+ QCOMPARE(activeSubWindow->geometry().topLeft(), QPoint(0, 0));
+
+ // Verify that we try to resize the area such that all sub-windows are visible.
+ // It's important that tiled windows are NOT overlapping.
+ workspace.resize(350, 150);
+ qApp->processEvents();
+ QTRY_COMPARE(workspace.size(), QSize(350, 150));
+
+ const QSize minSize(300, 100);
+ foreach (QMdiSubWindow *subWindow, workspace.subWindowList())
+ subWindow->setMinimumSize(minSize);
+
+ QCOMPARE(workspace.size(), QSize(350, 150));
+ workspace.tileSubWindows();
+ // The sub-windows are now tiled like this:
+ // | win 1 || win 2 || win 3 |
+ // +-------++-------++-------+
+ // +-------++-------++-------+
+ // | win 4 || win 5 || win 6 |
+ // +-------++-------++-------+
+ // +-------++-------++-------+
+ // | win 7 || win 8 || win 9 |
+ workspace.setActiveSubWindow(0);
+ int frameWidth = 0;
+ if (workspace.style()->styleHint(QStyle::SH_ScrollView_FrameOnlyAroundContents, 0, &workspace))
+ frameWidth = workspace.style()->pixelMetric(QStyle::PM_DefaultFrameWidth);
+ const int spacing = 2 * frameWidth + 2;
+ const QSize expectedViewportSize(3 * minSize.width() + spacing, 3 * minSize.height() + spacing);
+#ifdef Q_OS_WINCE
+ QSKIP("Not fixed yet! See task 197453", SkipAll);
+#endif
+ QTRY_COMPARE(workspace.viewport()->rect().size(), expectedViewportSize);
+
+ // Not enough space for all sub-windows to be visible -> provide scroll bars.
+ workspace.resize(150, 150);
+ qApp->processEvents();
+ QTRY_COMPARE(workspace.size(), QSize(150, 150));
+
+ // Horizontal scroll bar.
+ QScrollBar *hBar = workspace.horizontalScrollBar();
+ QCOMPARE(workspace.horizontalScrollBarPolicy(), Qt::ScrollBarAsNeeded);
+ QTRY_VERIFY(hBar->isVisible());
+ QCOMPARE(hBar->value(), 0);
+ QCOMPARE(hBar->minimum(), 0);
+
+ // Vertical scroll bar.
+ QScrollBar *vBar = workspace.verticalScrollBar();
+ QCOMPARE(workspace.verticalScrollBarPolicy(), Qt::ScrollBarAsNeeded);
+ QVERIFY(vBar->isVisible());
+ QCOMPARE(vBar->value(), 0);
+ QCOMPARE(vBar->minimum(), 0);
+
+ workspace.tileSubWindows();
+#ifdef Q_WS_X11
+ qt_x11_wait_for_window_manager(&workspace);
+#endif
+ qApp->processEvents();
+
+ QTRY_VERIFY(workspace.size() != QSize(150, 150));
+ QTRY_VERIFY(!vBar->isVisible());
+ QTRY_VERIFY(!hBar->isVisible());
+}
+
+void tst_QMdiArea::cascadeAndTileSubWindows()
+{
+ QMdiArea workspace;
+ workspace.resize(400, 400);
+ workspace.show();
+#ifdef Q_WS_X11
+ qt_x11_wait_for_window_manager(&workspace);
+#endif
+
+ const int windowCount = 10;
+ QList<QMdiSubWindow *> windows;
+ for (int i = 0; i < windowCount; ++i) {
+ QMdiSubWindow *window = workspace.addSubWindow(new MyChild);
+ if (i % 3 == 0) {
+ window->showMinimized();
+ QVERIFY(window->isMinimized());
+ } else {
+ window->showMaximized();
+ QVERIFY(window->isMaximized());
+ }
+ windows.append(window);
+ }
+
+ // cascadeSubWindows
+ qApp->processEvents();
+ workspace.cascadeSubWindows();
+ qApp->processEvents();
+
+ // Check dy between two cascaded windows
+ QStyleOptionTitleBar options;
+ options.initFrom(windows.at(1));
+ int titleBarHeight = windows.at(1)->style()->pixelMetric(QStyle::PM_TitleBarHeight, &options);
+ // ### Remove this after the mac style has been fixed
+ if (windows.at(1)->style()->inherits("QMacStyle"))
+ titleBarHeight -= 4;
+ const QFontMetrics fontMetrics = QFontMetrics(QApplication::font("QWorkspaceTitleBar"));
+ const int dy = qMax(titleBarHeight - (titleBarHeight - fontMetrics.height()) / 2, 1);
+ QCOMPARE(windows.at(2)->geometry().top() - windows.at(1)->geometry().top(), dy);
+
+ for (int i = 0; i < windows.count(); ++i) {
+ QMdiSubWindow *window = windows.at(i);
+ if (i % 3 == 0) {
+ QVERIFY(window->isMinimized());
+ } else {
+ QVERIFY(!window->isMaximized());
+ QCOMPARE(window->size(), window->sizeHint());
+ window->showMaximized();
+ QVERIFY(window->isMaximized());
+ }
+ }
+}
+
+void tst_QMdiArea::resizeMaximizedChildWindows_data()
+{
+ QTest::addColumn<int>("startSize");
+ QTest::addColumn<int>("increment");
+ QTest::addColumn<int>("windowCount");
+
+ QTest::newRow("multiple children") << 400 << 20 << 10;
+}
+
+void tst_QMdiArea::resizeMaximizedChildWindows()
+{
+ QFETCH(int, startSize);
+ QFETCH(int, increment);
+ QFETCH(int, windowCount);
+
+ QWidget topLevel;
+ QMdiArea workspace(&topLevel);
+ topLevel.show();
+#if defined(Q_WS_X11)
+ qt_x11_wait_for_window_manager(&workspace);
+#endif
+ QTest::qWait(100);
+ workspace.resize(startSize, startSize);
+ workspace.setOption(QMdiArea::DontMaximizeSubWindowOnActivation);
+ QSize workspaceSize = workspace.size();
+ QVERIFY(workspaceSize.isValid());
+ QCOMPARE(workspaceSize, QSize(startSize, startSize));
+
+ QList<QMdiSubWindow *> windows;
+ for (int i = 0; i < windowCount; ++i) {
+ QMdiSubWindow *window = workspace.addSubWindow(new QWidget);
+ windows.append(window);
+ qApp->processEvents();
+ window->showMaximized();
+ QTest::qWait(100);
+ QVERIFY(window->isMaximized());
+ QSize windowSize = window->size();
+ QVERIFY(windowSize.isValid());
+ QCOMPARE(window->rect(), workspace.contentsRect());
+
+ workspace.resize(workspaceSize + QSize(increment, increment));
+ QTest::qWait(100);
+ qApp->processEvents();
+ QTRY_COMPARE(workspace.size(), workspaceSize + QSize(increment, increment));
+ QTRY_COMPARE(window->size(), windowSize + QSize(increment, increment));
+ workspaceSize = workspace.size();
+ }
+
+ int newSize = startSize + increment * windowCount;
+ QCOMPARE(workspaceSize, QSize(newSize, newSize));
+ foreach (QWidget *window, windows)
+ QCOMPARE(window->rect(), workspace.contentsRect());
+}
+
+// QWidget::setParent clears focusWidget so make sure
+// we restore it after QMdiArea::addSubWindow.
+void tst_QMdiArea::focusWidgetAfterAddSubWindow()
+{
+ QWidget *view = new QWidget;
+ view->setLayout(new QVBoxLayout);
+
+ QLineEdit *lineEdit1 = new QLineEdit;
+ QLineEdit *lineEdit2 = new QLineEdit;
+ view->layout()->addWidget(lineEdit1);
+ view->layout()->addWidget(lineEdit2);
+
+ lineEdit2->setFocus();
+ QCOMPARE(view->focusWidget(), static_cast<QWidget *>(lineEdit2));
+
+ QMdiArea mdiArea;
+ mdiArea.addSubWindow(view);
+ QCOMPARE(view->focusWidget(), static_cast<QWidget *>(lineEdit2));
+
+ mdiArea.show();
+ view->show();
+ qApp->setActiveWindow(&mdiArea);
+ QCOMPARE(qApp->focusWidget(), static_cast<QWidget *>(lineEdit2));
+}
+
+void tst_QMdiArea::dontMaximizeSubWindowOnActivation()
+{
+ QMdiArea mdiArea;
+ mdiArea.show();
+#ifdef Q_WS_X11
+ qt_x11_wait_for_window_manager(&mdiArea);
+#endif
+ qApp->setActiveWindow(&mdiArea);
+
+ // Add one maximized window.
+ mdiArea.addSubWindow(new QWidget)->showMaximized();
+ QVERIFY(mdiArea.activeSubWindow());
+ QVERIFY(mdiArea.activeSubWindow()->isMaximized());
+
+ // Add few more windows and verify that they are maximized.
+ for (int i = 0; i < 5; ++i) {
+ QMdiSubWindow *window = mdiArea.addSubWindow(new QWidget);
+ window->show();
+ QVERIFY(window->isMaximized());
+ qApp->processEvents();
+ }
+
+ // Verify that activated windows still are maximized on activation.
+ QList<QMdiSubWindow *> subWindows = mdiArea.subWindowList();
+ for (int i = 0; i < subWindows.count(); ++i) {
+ mdiArea.activateNextSubWindow();
+ QMdiSubWindow *window = subWindows.at(i);
+ QCOMPARE(mdiArea.activeSubWindow(), window);
+ QVERIFY(window->isMaximized());
+ qApp->processEvents();
+ }
+
+ // Restore active window and verify that other windows aren't
+ // maximized on activation.
+ mdiArea.activeSubWindow()->showNormal();
+ for (int i = 0; i < subWindows.count(); ++i) {
+ mdiArea.activateNextSubWindow();
+ QMdiSubWindow *window = subWindows.at(i);
+ QCOMPARE(mdiArea.activeSubWindow(), window);
+ QVERIFY(!window->isMaximized());
+ qApp->processEvents();
+ }
+
+ // Enable 'DontMaximizedSubWindowOnActivation' and maximize the active window.
+ mdiArea.setOption(QMdiArea::DontMaximizeSubWindowOnActivation);
+ mdiArea.activeSubWindow()->showMaximized();
+ int indexOfMaximized = subWindows.indexOf(mdiArea.activeSubWindow());
+
+ // Verify that windows are not maximized on activation.
+ for (int i = 0; i < subWindows.count(); ++i) {
+ mdiArea.activateNextSubWindow();
+ QMdiSubWindow *window = subWindows.at(i);
+ QCOMPARE(mdiArea.activeSubWindow(), window);
+ if (indexOfMaximized != i)
+ QVERIFY(!window->isMaximized());
+ qApp->processEvents();
+ }
+ QVERIFY(mdiArea.activeSubWindow()->isMaximized());
+
+ // Minimize all windows.
+ foreach (QMdiSubWindow *window, subWindows) {
+ window->showMinimized();
+ QVERIFY(window->isMinimized());
+ qApp->processEvents();
+ }
+
+ // Disable 'DontMaximizedSubWindowOnActivation' and maximize the active window.
+ mdiArea.setOption(QMdiArea::DontMaximizeSubWindowOnActivation, false);
+ mdiArea.activeSubWindow()->showMaximized();
+
+ // Verify that minimized windows are maximized on activation.
+ for (int i = 0; i < subWindows.count(); ++i) {
+ mdiArea.activateNextSubWindow();
+ QMdiSubWindow *window = subWindows.at(i);
+ QCOMPARE(mdiArea.activeSubWindow(), window);
+ QVERIFY(window->isMaximized());
+ qApp->processEvents();
+ }
+
+ // Verify that activated windows are maximized after closing
+ // the active window
+ for (int i = 0; i < subWindows.count(); ++i) {
+ QVERIFY(mdiArea.activeSubWindow());
+ QVERIFY(mdiArea.activeSubWindow()->isMaximized());
+ mdiArea.activeSubWindow()->close();
+ qApp->processEvents();
+ }
+
+ QVERIFY(!mdiArea.activeSubWindow());
+ QCOMPARE(mdiArea.subWindowList().size(), 0);
+
+ // Verify that new windows are not maximized.
+ mdiArea.addSubWindow(new QWidget)->show();
+ QVERIFY(mdiArea.activeSubWindow());
+ QVERIFY(!mdiArea.activeSubWindow()->isMaximized());
+}
+
+void tst_QMdiArea::delayedPlacement()
+{
+ QMdiArea mdiArea;
+
+ QMdiSubWindow *window1 = mdiArea.addSubWindow(new QWidget);
+ QCOMPARE(window1->geometry().topLeft(), QPoint(0, 0));
+
+ QMdiSubWindow *window2 = mdiArea.addSubWindow(new QWidget);
+ QCOMPARE(window2->geometry().topLeft(), QPoint(0, 0));
+
+ QMdiSubWindow *window3 = mdiArea.addSubWindow(new QWidget);
+ QCOMPARE(window3->geometry().topLeft(), QPoint(0, 0));
+
+ mdiArea.resize(window3->minimumSizeHint().width() * 3, 400);
+ mdiArea.show();
+#ifdef Q_WS_X11
+ qt_x11_wait_for_window_manager(&mdiArea);
+#endif
+
+ QCOMPARE(window1->geometry().topLeft(), QPoint(0, 0));
+ QCOMPARE(window2->geometry().topLeft(), window1->geometry().topRight() + QPoint(1, 0));
+ QCOMPARE(window3->geometry().topLeft(), window2->geometry().topRight() + QPoint(1, 0));
+}
+
+void tst_QMdiArea::iconGeometryInMenuBar()
+{
+#if !defined (Q_WS_MAC) && !defined(Q_OS_WINCE)
+ QMainWindow mainWindow;
+ QMenuBar *menuBar = mainWindow.menuBar();
+ QMdiArea *mdiArea = new QMdiArea;
+ QMdiSubWindow *subWindow = mdiArea->addSubWindow(new QWidget);
+ mainWindow.setCentralWidget(mdiArea);
+ mainWindow.show();
+#ifdef Q_WS_X11
+ qt_x11_wait_for_window_manager(&mainWindow);
+#endif
+
+ subWindow->showMaximized();
+ QVERIFY(subWindow->isMaximized());
+
+ QWidget *leftCornerWidget = menuBar->cornerWidget(Qt::TopLeftCorner);
+ QVERIFY(leftCornerWidget);
+ int topMargin = (menuBar->height() - leftCornerWidget->height()) / 2;
+ int leftMargin = qApp->style()->pixelMetric(QStyle::PM_MenuBarHMargin)
+ + qApp->style()->pixelMetric(QStyle::PM_MenuBarPanelWidth);
+ QPoint pos(leftMargin, topMargin);
+ QRect geometry = QStyle::visualRect(qApp->layoutDirection(), menuBar->rect(),
+ QRect(pos, leftCornerWidget->size()));
+ QCOMPARE(leftCornerWidget->geometry(), geometry);
+#endif
+}
+
+class EventSpy : public QObject
+{
+public:
+ EventSpy(QObject *object, QEvent::Type event)
+ : eventToSpy(event), _count(0)
+ {
+ if (object)
+ object->installEventFilter(this);
+ }
+
+ int count() const { return _count; }
+ void clear() { _count = 0; }
+
+protected:
+ bool eventFilter(QObject *object, QEvent *event)
+ {
+ if (event->type() == eventToSpy)
+ ++_count;
+ return QObject::eventFilter(object, event);
+ }
+
+private:
+ QEvent::Type eventToSpy;
+ int _count;
+};
+
+void tst_QMdiArea::resizeTimer()
+{
+ QMdiArea mdiArea;
+ QMdiSubWindow *subWindow = mdiArea.addSubWindow(new QWidget);
+ mdiArea.show();
+#ifdef Q_WS_X11
+ qt_x11_wait_for_window_manager(&mdiArea);
+#endif
+ QTest::qWaitForWindowShown(&mdiArea);
+
+#ifndef Q_OS_WINCE
+ int time = 250;
+#else
+ int time = 1000;
+#endif
+
+ QTest::qWait(time);
+
+ EventSpy timerEventSpy(subWindow, QEvent::Timer);
+ QCOMPARE(timerEventSpy.count(), 0);
+
+ mdiArea.tileSubWindows();
+ QTest::qWait(time); // Wait for timer events to occur.
+ QCOMPARE(timerEventSpy.count(), 1);
+ timerEventSpy.clear();
+
+ mdiArea.resize(mdiArea.size() + QSize(2, 2));
+ QTest::qWait(time); // Wait for timer events to occur.
+ QCOMPARE(timerEventSpy.count(), 1);
+ timerEventSpy.clear();
+
+ // Check that timers are killed.
+ QTest::qWait(time); // Wait for timer events to occur.
+ QCOMPARE(timerEventSpy.count(), 0);
+}
+
+void tst_QMdiArea::updateScrollBars()
+{
+ QMdiArea mdiArea;
+ mdiArea.setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded);
+ mdiArea.setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
+
+ QMdiSubWindow *subWindow1 = mdiArea.addSubWindow(new QWidget);
+ QMdiSubWindow *subWindow2 = mdiArea.addSubWindow(new QWidget);
+
+ mdiArea.show();
+#ifdef Q_WS_X11
+ qt_x11_wait_for_window_manager(&mdiArea);
+#endif
+ qApp->processEvents();
+
+ QScrollBar *hbar = mdiArea.horizontalScrollBar();
+ QVERIFY(hbar);
+ QVERIFY(!hbar->isVisible());
+
+ QScrollBar *vbar = mdiArea.verticalScrollBar();
+ QVERIFY(vbar);
+ QVERIFY(!vbar->isVisible());
+
+ // Move sub-window 2 away.
+ subWindow2->move(10000, 10000);
+ qApp->processEvents();
+ QVERIFY(hbar->isVisible());
+ QVERIFY(vbar->isVisible());
+
+ for (int i = 0; i < 2; ++i) {
+ // Maximize sub-window 1 and make sure we don't have any scroll bars.
+ subWindow1->showMaximized();
+ qApp->processEvents();
+ QVERIFY(subWindow1->isMaximized());
+ QVERIFY(!hbar->isVisible());
+ QVERIFY(!vbar->isVisible());
+
+ // We still shouldn't get any scroll bars.
+ mdiArea.resize(mdiArea.size() - QSize(20, 20));
+#ifdef Q_WS_X11
+ qt_x11_wait_for_window_manager(&mdiArea);
+#endif
+ qApp->processEvents();
+ QVERIFY(subWindow1->isMaximized());
+ QVERIFY(!hbar->isVisible());
+ QVERIFY(!vbar->isVisible());
+
+ // Restore sub-window 1 and make sure we have scroll bars again.
+ subWindow1->showNormal();
+ qApp->processEvents();
+ QVERIFY(!subWindow1->isMaximized());
+ QVERIFY(hbar->isVisible());
+ QVERIFY(vbar->isVisible());
+ if (i == 0) {
+ // Now, do the same when the viewport is scrolled.
+ hbar->setValue(1000);
+ vbar->setValue(1000);
+ }
+ }
+}
+
+void tst_QMdiArea::setActivationOrder_data()
+{
+ QTest::addColumn<QMdiArea::WindowOrder>("activationOrder");
+ QTest::addColumn<int>("subWindowCount");
+ QTest::addColumn<int>("staysOnTopIndex");
+ QTest::addColumn<int>("firstActiveIndex");
+ QTest::addColumn<QList<int> >("expectedActivationIndices");
+ // The order of expectedCascadeIndices:
+ // window 1 -> (index 0)
+ // window 2 -> (index 1)
+ // window 3 -> (index 2)
+ // ....
+ QTest::addColumn<QList<int> >("expectedCascadeIndices");
+
+ // The order of expectedTileIndices (the same as reading a book LTR).
+ // +--------------------+--------------------+--------------------+
+ // | window 1 (index 0) | window 2 (index 1) | window 3 (index 2) |
+ // | +--------------------+--------------------+
+ // | (index 3) | window 4 (index 4) | window 5 (index 5) |
+ // +--------------------------------------------------------------+
+ QTest::addColumn<QList<int> >("expectedTileIndices");
+
+ QList<int> list;
+ QList<int> list2;
+ QList<int> list3;
+
+ list << 2 << 1 << 0 << 1 << 2 << 3 << 4;
+ list2 << 0 << 1 << 2 << 3 << 4;
+ list3 << 1 << 4 << 3 << 1 << 2 << 0;
+ QTest::newRow("CreationOrder") << QMdiArea::CreationOrder << 5 << 3 << 1 << list << list2 << list3;
+
+ list = QList<int>();
+ list << 3 << 1 << 4 << 3 << 1 << 2 << 0;
+ list2 = QList<int>();
+ list2 << 0 << 2 << 4 << 1 << 3;
+ list3 = QList<int>();
+ list3 << 1 << 3 << 4 << 1 << 2 << 0;
+ QTest::newRow("StackingOrder") << QMdiArea::StackingOrder << 5 << 3 << 1 << list << list2 << list3;
+
+ list = QList<int>();
+ list << 0 << 1 << 0 << 1 << 4 << 3 << 2;
+ list2 = QList<int>();
+ list2 << 0 << 2 << 3 << 4 << 1;
+ list3 = QList<int>();
+ list3 << 1 << 4 << 3 << 1 << 2 << 0;
+ QTest::newRow("ActivationHistoryOrder") << QMdiArea::ActivationHistoryOrder << 5 << 3 << 1 << list << list2 << list3;
+}
+
+void tst_QMdiArea::setActivationOrder()
+{
+ QFETCH(QMdiArea::WindowOrder, activationOrder);
+ QFETCH(int, subWindowCount);
+ QFETCH(int, staysOnTopIndex);
+ QFETCH(int, firstActiveIndex);
+ QFETCH(QList<int>, expectedActivationIndices);
+ QFETCH(QList<int>, expectedCascadeIndices);
+ QFETCH(QList<int>, expectedTileIndices);
+
+ // Default order.
+ QMdiArea mdiArea;
+ QCOMPARE(mdiArea.activationOrder(), QMdiArea::CreationOrder);
+
+ // New order.
+ mdiArea.setActivationOrder(activationOrder);
+ QCOMPARE(mdiArea.activationOrder(), activationOrder);
+
+ QList<QMdiSubWindow *> subWindows;
+ for (int i = 0; i < subWindowCount; ++i)
+ subWindows << mdiArea.addSubWindow(new QPushButton(tr("%1").arg(i)));
+ QCOMPARE(mdiArea.subWindowList(activationOrder), subWindows);
+
+ mdiArea.show();
+#ifdef Q_WS_X11
+ qt_x11_wait_for_window_manager(&mdiArea);
+#endif
+
+ for (int i = 0; i < subWindows.count(); ++i) {
+ mdiArea.activateNextSubWindow();
+ QCOMPARE(mdiArea.activeSubWindow(), subWindows.at(i));
+ qApp->processEvents();
+ }
+
+ QMdiSubWindow *staysOnTop = subWindows.at(staysOnTopIndex);
+ staysOnTop->setWindowFlags(staysOnTop->windowFlags() | Qt::WindowStaysOnTopHint);
+ staysOnTop->raise();
+
+ mdiArea.setActiveSubWindow(subWindows.at(firstActiveIndex));
+ QCOMPARE(mdiArea.activeSubWindow(), subWindows.at(firstActiveIndex));
+
+ // Verify the actual arrangement/geometry.
+ mdiArea.tileSubWindows();
+ QTest::qWait(100);
+ QVERIFY(verifyArrangement(&mdiArea, Tiled, expectedTileIndices));
+
+ mdiArea.cascadeSubWindows();
+ QVERIFY(verifyArrangement(&mdiArea, Cascaded, expectedCascadeIndices));
+ QTest::qWait(100);
+
+ mdiArea.activateNextSubWindow();
+ QCOMPARE(mdiArea.activeSubWindow(), subWindows.at(expectedActivationIndices.takeFirst()));
+
+ mdiArea.activatePreviousSubWindow();
+ QCOMPARE(mdiArea.activeSubWindow(), subWindows.at(expectedActivationIndices.takeFirst()));
+
+ mdiArea.activatePreviousSubWindow();
+ QCOMPARE(mdiArea.activeSubWindow(), subWindows.at(expectedActivationIndices.takeFirst()));
+
+ for (int i = 0; i < subWindowCount; ++i) {
+ mdiArea.closeActiveSubWindow();
+ qApp->processEvents();
+ if (i == subWindowCount - 1) { // Last window closed.
+ QVERIFY(!mdiArea.activeSubWindow());
+ break;
+ }
+ QVERIFY(mdiArea.activeSubWindow());
+ QCOMPARE(mdiArea.activeSubWindow(), subWindows.at(expectedActivationIndices.takeFirst()));
+ }
+
+ QVERIFY(mdiArea.subWindowList(activationOrder).isEmpty());
+ QVERIFY(expectedActivationIndices.isEmpty());
+}
+
+void tst_QMdiArea::tabBetweenSubWindows()
+{
+ QMdiArea mdiArea;
+ QList<QMdiSubWindow *> subWindows;
+ for (int i = 0; i < 5; ++i)
+ subWindows << mdiArea.addSubWindow(new QLineEdit);
+
+ mdiArea.show();
+#ifdef Q_WS_X11
+ qt_x11_wait_for_window_manager(&mdiArea);
+#endif
+
+ qApp->setActiveWindow(&mdiArea);
+ QWidget *focusWidget = subWindows.back()->widget();
+ QCOMPARE(qApp->focusWidget(), focusWidget);
+
+ QSignalSpy spy(&mdiArea, SIGNAL(subWindowActivated(QMdiSubWindow *)));
+ QCOMPARE(spy.count(), 0);
+
+ // Walk through the entire list of sub windows.
+ QVERIFY(tabBetweenSubWindowsIn(&mdiArea));
+ QCOMPARE(mdiArea.activeSubWindow(), subWindows.back());
+ QCOMPARE(spy.count(), 0);
+
+ mdiArea.setActiveSubWindow(subWindows.front());
+ QCOMPARE(mdiArea.activeSubWindow(), subWindows.front());
+ spy.clear();
+
+ // Walk through the entire list of sub windows in the opposite direction (Ctrl-Shift-Tab).
+ QVERIFY(tabBetweenSubWindowsIn(&mdiArea, -1, true));
+ QCOMPARE(mdiArea.activeSubWindow(), subWindows.front());
+ QCOMPARE(spy.count(), 0);
+
+ // Ctrl-Tab-Tab-Tab
+ QVERIFY(tabBetweenSubWindowsIn(&mdiArea, 3));
+ QCOMPARE(mdiArea.activeSubWindow(), subWindows.at(3));
+ QCOMPARE(spy.count(), 1);
+
+ mdiArea.setActiveSubWindow(subWindows.at(1));
+ QCOMPARE(mdiArea.activeSubWindow(), subWindows.at(1));
+ spy.clear();
+
+ // Quick switch (Ctrl-Tab once) -> switch back to the previously active sub-window.
+ QVERIFY(tabBetweenSubWindowsIn(&mdiArea, 1));
+ QCOMPARE(mdiArea.activeSubWindow(), subWindows.at(3));
+ QCOMPARE(spy.count(), 1);
+}
+
+void tst_QMdiArea::setViewMode()
+{
+ QMdiArea mdiArea;
+
+ QPixmap iconPixmap(16, 16);
+ iconPixmap.fill(Qt::red);
+ for (int i = 0; i < 5; ++i) {
+ QMdiSubWindow *subWindow = mdiArea.addSubWindow(new QWidget);
+ subWindow->setWindowTitle(QString(QLatin1String("Title %1")).arg(i));
+ subWindow->setWindowIcon(iconPixmap);
+ }
+
+ mdiArea.show();
+#ifdef Q_WS_X11
+ qt_x11_wait_for_window_manager(&mdiArea);
+#endif
+
+ QMdiSubWindow *activeSubWindow = mdiArea.activeSubWindow();
+ const QList<QMdiSubWindow *> subWindows = mdiArea.subWindowList();
+
+ // Default.
+ QVERIFY(!activeSubWindow->isMaximized());
+ QTabBar *tabBar = qFindChild<QTabBar *>(&mdiArea);
+ QVERIFY(!tabBar);
+ QCOMPARE(mdiArea.viewMode(), QMdiArea::SubWindowView);
+
+ // Tabbed view.
+ mdiArea.setViewMode(QMdiArea::TabbedView);
+ QCOMPARE(mdiArea.viewMode(), QMdiArea::TabbedView);
+ tabBar = qFindChild<QTabBar *>(&mdiArea);
+ QVERIFY(tabBar);
+ QVERIFY(tabBar->isVisible());
+
+ QCOMPARE(tabBar->count(), subWindows.count());
+ QVERIFY(activeSubWindow->isMaximized());
+ QCOMPARE(tabBar->currentIndex(), subWindows.indexOf(activeSubWindow));
+
+ // Check that tabIcon and tabText are set properly.
+ for (int i = 0; i < subWindows.size(); ++i) {
+ QMdiSubWindow *subWindow = subWindows.at(i);
+ QCOMPARE(tabBar->tabText(i), subWindow->windowTitle());
+ QCOMPARE(tabBar->tabIcon(i), subWindow->windowIcon());
+ }
+
+ // Check that tabText and tabIcon are updated.
+ activeSubWindow->setWindowTitle(QLatin1String("Dude, I want another window title"));
+ QCOMPARE(tabBar->tabText(tabBar->currentIndex()), activeSubWindow->windowTitle());
+ iconPixmap.fill(Qt::green);
+ activeSubWindow->setWindowIcon(iconPixmap);
+ QCOMPARE(tabBar->tabIcon(tabBar->currentIndex()), activeSubWindow->windowIcon());
+
+ // If there's an empty window title, tabText should return "(Untitled)" (as in firefox).
+ activeSubWindow->setWindowTitle(QString());
+ QCOMPARE(tabBar->tabText(tabBar->currentIndex()), QLatin1String("(Untitled)"));
+
+ // If there's no window icon, tabIcon should return ... an empty icon :)
+ activeSubWindow->setWindowIcon(QIcon());
+ QCOMPARE(tabBar->tabIcon(tabBar->currentIndex()), QIcon());
+
+ // Check that the current tab changes when activating another sub-window.
+ for (int i = 0; i < subWindows.size(); ++i) {
+ mdiArea.activateNextSubWindow();
+ activeSubWindow = mdiArea.activeSubWindow();
+ QCOMPARE(tabBar->currentIndex(), subWindows.indexOf(activeSubWindow));
+ }
+
+ activeSubWindow = mdiArea.activeSubWindow();
+ const int tabIndex = tabBar->currentIndex();
+
+ // The current tab should not change when the sub-window is hidden.
+ activeSubWindow->hide();
+ QCOMPARE(tabBar->currentIndex(), tabIndex);
+ activeSubWindow->show();
+ QCOMPARE(tabBar->currentIndex(), tabIndex);
+
+ // Disable the tab when the sub-window is hidden and another sub-window is activated.
+ activeSubWindow->hide();
+ mdiArea.activateNextSubWindow();
+ QVERIFY(tabBar->currentIndex() != tabIndex);
+ QVERIFY(!tabBar->isTabEnabled(tabIndex));
+
+ // Enable it again.
+ activeSubWindow->show();
+ QCOMPARE(tabBar->currentIndex(), tabIndex);
+ QVERIFY(tabBar->isTabEnabled(tabIndex));
+
+ // Remove sub-windows and make sure the tab is removed.
+ foreach (QMdiSubWindow *subWindow, subWindows) {
+ if (subWindow != activeSubWindow)
+ mdiArea.removeSubWindow(subWindow);
+ }
+ QCOMPARE(tabBar->count(), 1);
+
+ // Go back to default (QMdiArea::SubWindowView).
+ mdiArea.setViewMode(QMdiArea::SubWindowView);
+ QVERIFY(!activeSubWindow->isMaximized());
+ tabBar = qFindChild<QTabBar *>(&mdiArea);
+ QVERIFY(!tabBar);
+ QCOMPARE(mdiArea.viewMode(), QMdiArea::SubWindowView);
+}
+
+void tst_QMdiArea::setTabsClosable()
+{
+ QMdiArea mdiArea;
+ mdiArea.addSubWindow(new QWidget);
+
+ // test default
+ QCOMPARE(mdiArea.tabsClosable(), false);
+
+ // change value before tab bar exists
+ QTabBar *tabBar = qFindChild<QTabBar *>(&mdiArea);
+ QVERIFY(!tabBar);
+ mdiArea.setTabsClosable(true);
+ QCOMPARE(mdiArea.tabsClosable(), true);
+
+ // force tab bar creation
+ mdiArea.setViewMode(QMdiArea::TabbedView);
+ tabBar = qFindChild<QTabBar *>(&mdiArea);
+ QVERIFY(tabBar);
+
+ // value must've been propagated
+ QCOMPARE(tabBar->tabsClosable(), true);
+
+ // change value when tab bar exists
+ mdiArea.setTabsClosable(false);
+ QCOMPARE(mdiArea.tabsClosable(), false);
+ QCOMPARE(tabBar->tabsClosable(), false);
+}
+
+void tst_QMdiArea::setTabsMovable()
+{
+ QMdiArea mdiArea;
+ QMdiSubWindow *subWindow1 = mdiArea.addSubWindow(new QWidget);
+ QMdiSubWindow *subWindow2 = mdiArea.addSubWindow(new QWidget);
+ QMdiSubWindow *subWindow3 = mdiArea.addSubWindow(new QWidget);
+
+ // test default
+ QCOMPARE(mdiArea.tabsMovable(), false);
+
+ // change value before tab bar exists
+ QTabBar *tabBar = qFindChild<QTabBar *>(&mdiArea);
+ QVERIFY(!tabBar);
+ mdiArea.setTabsMovable(true);
+ QCOMPARE(mdiArea.tabsMovable(), true);
+
+ // force tab bar creation
+ mdiArea.setViewMode(QMdiArea::TabbedView);
+ tabBar = qFindChild<QTabBar *>(&mdiArea);
+ QVERIFY(tabBar);
+
+ // value must've been propagated
+ QCOMPARE(tabBar->isMovable(), true);
+
+ // test tab moving
+ QList<QMdiSubWindow *> subWindows;
+ subWindows << subWindow1 << subWindow2 << subWindow3;
+ QCOMPARE(mdiArea.subWindowList(QMdiArea::CreationOrder), subWindows);
+ tabBar->moveTab(1, 2); // 1,3,2
+ subWindows.clear();
+ subWindows << subWindow1 << subWindow3 << subWindow2;
+ QCOMPARE(mdiArea.subWindowList(QMdiArea::CreationOrder), subWindows);
+ tabBar->moveTab(0, 2); // 3,2,1
+ subWindows.clear();
+ subWindows << subWindow3 << subWindow2 << subWindow1;
+ QCOMPARE(mdiArea.subWindowList(QMdiArea::CreationOrder), subWindows);
+
+ // change value when tab bar exists
+ mdiArea.setTabsMovable(false);
+ QCOMPARE(mdiArea.tabsMovable(), false);
+ QCOMPARE(tabBar->isMovable(), false);
+}
+
+void tst_QMdiArea::setTabShape()
+{
+ QMdiArea mdiArea;
+ mdiArea.addSubWindow(new QWidget);
+ mdiArea.show();
+#ifdef Q_WS_X11
+ qt_x11_wait_for_window_manager(&mdiArea);
+#endif
+
+ // Default.
+ QCOMPARE(mdiArea.tabShape(), QTabWidget::Rounded);
+
+ // Triangular.
+ mdiArea.setTabShape(QTabWidget::Triangular);
+ QCOMPARE(mdiArea.tabShape(), QTabWidget::Triangular);
+
+ mdiArea.setViewMode(QMdiArea::TabbedView);
+
+ QTabBar *tabBar = qFindChild<QTabBar *>(&mdiArea);
+ QVERIFY(tabBar);
+ QCOMPARE(tabBar->shape(), QTabBar::TriangularNorth);
+
+ // Back to default (Rounded).
+ mdiArea.setTabShape(QTabWidget::Rounded);
+ QCOMPARE(mdiArea.tabShape(), QTabWidget::Rounded);
+ QCOMPARE(tabBar->shape(), QTabBar::RoundedNorth);
+}
+
+void tst_QMdiArea::setTabPosition_data()
+{
+ QTest::addColumn<QTabWidget::TabPosition>("tabPosition");
+ QTest::addColumn<bool>("hasLeftMargin");
+ QTest::addColumn<bool>("hasTopMargin");
+ QTest::addColumn<bool>("hasRightMargin");
+ QTest::addColumn<bool>("hasBottomMargin");
+
+ QTest::newRow("North") << QTabWidget::North << false << true << false << false;
+ QTest::newRow("South") << QTabWidget::South << false << false << false << true;
+ QTest::newRow("East") << QTabWidget::East << false << false << true << false;
+ QTest::newRow("West") << QTabWidget::West << true << false << false << false;
+}
+
+void tst_QMdiArea::setTabPosition()
+{
+ QFETCH(QTabWidget::TabPosition, tabPosition);
+ QFETCH(bool, hasLeftMargin);
+ QFETCH(bool, hasTopMargin);
+ QFETCH(bool, hasRightMargin);
+ QFETCH(bool, hasBottomMargin);
+
+ QMdiArea mdiArea;
+ mdiArea.addSubWindow(new QWidget);
+ mdiArea.show();
+#ifdef Q_WS_X11
+ qt_x11_wait_for_window_manager(&mdiArea);
+#endif
+
+ // Make sure there are no margins.
+ mdiArea.setContentsMargins(0, 0, 0, 0);
+
+ // Default.
+ QCOMPARE(mdiArea.tabPosition(), QTabWidget::North);
+ mdiArea.setViewMode(QMdiArea::TabbedView);
+ QTabBar *tabBar = qFindChild<QTabBar *>(&mdiArea);
+ QVERIFY(tabBar);
+ QCOMPARE(tabBar->shape(), QTabBar::RoundedNorth);
+
+ // New position.
+ mdiArea.setTabPosition(tabPosition);
+ QCOMPARE(mdiArea.tabPosition(), tabPosition);
+ QCOMPARE(tabBar->shape(), tabBarShapeFrom(QTabWidget::Rounded, tabPosition));
+
+ const Qt::LayoutDirection originalLayoutDirection = qApp->layoutDirection();
+
+ // Check that we have correct geometry in both RightToLeft and LeftToRight.
+ for (int i = 0; i < 2; ++i) {
+ // Check viewportMargins.
+ const QRect viewportGeometry = mdiArea.viewport()->geometry();
+ const int left = viewportGeometry.left();
+ const int top = viewportGeometry.y();
+ const int right = mdiArea.width() - viewportGeometry.width();
+ const int bottom = mdiArea.height() - viewportGeometry.height();
+
+ const QSize sizeHint = tabBar->sizeHint();
+
+ if (hasLeftMargin)
+ QCOMPARE(qApp->isLeftToRight() ? left : right, sizeHint.width());
+ if (hasRightMargin)
+ QCOMPARE(qApp->isLeftToRight() ? right : left, sizeHint.width());
+ if (hasTopMargin || hasBottomMargin)
+ QCOMPARE(hasTopMargin ? top : bottom, sizeHint.height());
+
+ // Check actual tab bar geometry.
+ const QRegion expectedTabBarGeometry = QRegion(mdiArea.rect()).subtracted(viewportGeometry);
+ QVERIFY(!expectedTabBarGeometry.isEmpty());
+ QCOMPARE(QRegion(tabBar->geometry()), expectedTabBarGeometry);
+
+ if (i == 0)
+ qApp->setLayoutDirection(originalLayoutDirection == Qt::LeftToRight ? Qt::RightToLeft : Qt::LeftToRight);
+ qApp->processEvents();
+ }
+
+ qApp->setLayoutDirection(originalLayoutDirection);
+}
+
+#if defined(Q_WS_WIN) || defined(Q_WS_X11)
+void tst_QMdiArea::nativeSubWindows()
+{
+ { // Add native widgets after show.
+ QMdiArea mdiArea;
+ mdiArea.addSubWindow(new QWidget);
+ mdiArea.addSubWindow(new QWidget);
+ mdiArea.show();
+#ifdef Q_WS_X11
+ qt_x11_wait_for_window_manager(&mdiArea);
+#endif
+
+ // No native widgets.
+ QVERIFY(!mdiArea.viewport()->internalWinId());
+ foreach (QMdiSubWindow *subWindow, mdiArea.subWindowList())
+ QVERIFY(!subWindow->internalWinId());
+
+ QWidget *nativeWidget = new QWidget;
+ QVERIFY(nativeWidget->winId()); // enforce native window.
+ mdiArea.addSubWindow(nativeWidget);
+
+ // The viewport and all the sub-windows must be native.
+ QVERIFY(mdiArea.viewport()->internalWinId());
+ foreach (QMdiSubWindow *subWindow, mdiArea.subWindowList())
+ QVERIFY(subWindow->internalWinId());
+
+ // Add a non-native widget. This should become native.
+ QMdiSubWindow *subWindow = new QMdiSubWindow;
+ subWindow->setWidget(new QWidget);
+ QVERIFY(!subWindow->internalWinId());
+ mdiArea.addSubWindow(subWindow);
+ QVERIFY(subWindow->internalWinId());
+ }
+
+ { // Add native widgets before show.
+ QMdiArea mdiArea;
+ mdiArea.addSubWindow(new QWidget);
+ QWidget *nativeWidget = new QWidget;
+ (void)nativeWidget->winId();
+ mdiArea.addSubWindow(nativeWidget);
+ mdiArea.show();
+#ifdef Q_WS_X11
+ qt_x11_wait_for_window_manager(&mdiArea);
+#endif
+
+ // The viewport and all the sub-windows must be native.
+ QVERIFY(mdiArea.viewport()->internalWinId());
+ foreach (QMdiSubWindow *subWindow, mdiArea.subWindowList())
+ QVERIFY(subWindow->internalWinId());
+ }
+
+ { // Make a sub-window native *after* it's added to the area.
+ QMdiArea mdiArea;
+ mdiArea.addSubWindow(new QWidget);
+ mdiArea.addSubWindow(new QWidget);
+ mdiArea.show();
+#ifdef Q_WS_X11
+ qt_x11_wait_for_window_manager(&mdiArea);
+#endif
+
+ QMdiSubWindow *nativeSubWindow = mdiArea.subWindowList().last();
+ QVERIFY(!nativeSubWindow->internalWinId());
+ (void)nativeSubWindow->winId();
+
+ // All the sub-windows should be native at this point
+ QVERIFY(mdiArea.viewport()->internalWinId());
+ foreach (QMdiSubWindow *subWindow, mdiArea.subWindowList())
+ QVERIFY(subWindow->internalWinId());
+ }
+
+#ifndef QT_NO_OPENGL
+ {
+ if (!QGLFormat::hasOpenGL())
+ QSKIP("QGL not supported on this platform", SkipAll);
+
+ QMdiArea mdiArea;
+ QGLWidget *glViewport = new QGLWidget;
+ mdiArea.setViewport(glViewport);
+ mdiArea.addSubWindow(new QWidget);
+ mdiArea.addSubWindow(new QWidget);
+ mdiArea.show();
+#ifdef Q_WS_X11
+ qt_x11_wait_for_window_manager(&mdiArea);
+#endif
+
+ const QGLContext *context = glViewport->context();
+ if (!context || !context->isValid())
+ QSKIP("QGL is broken, cannot continue test", SkipAll);
+
+ // The viewport and all the sub-windows must be native.
+ QVERIFY(mdiArea.viewport()->internalWinId());
+ foreach (QMdiSubWindow *subWindow, mdiArea.subWindowList())
+ QVERIFY(subWindow->internalWinId());
+ }
+#endif
+}
+#endif
+
+void tst_QMdiArea::task_209615()
+{
+ QTabWidget tabWidget;
+ QMdiArea *mdiArea1 = new QMdiArea;
+ QMdiArea *mdiArea2 = new QMdiArea;
+ QMdiSubWindow *subWindow = mdiArea1->addSubWindow(new QLineEdit);
+
+ tabWidget.addTab(mdiArea1, QLatin1String("1"));
+ tabWidget.addTab(mdiArea2, QLatin1String("2"));
+ tabWidget.show();
+
+ mdiArea1->removeSubWindow(subWindow);
+ mdiArea2->addSubWindow(subWindow);
+
+ // Please do not assert/crash.
+ tabWidget.setCurrentIndex(1);
+}
+
+void tst_QMdiArea::task_236750()
+{
+ QMdiArea mdiArea;
+ QMdiSubWindow *subWindow = mdiArea.addSubWindow(new QTextEdit);
+ mdiArea.show();
+
+ subWindow->setWindowFlags(subWindow->windowFlags() | Qt::FramelessWindowHint);
+ // Please do not crash (floating point exception).
+ subWindow->showMinimized();
+}
+
+QTEST_MAIN(tst_QMdiArea)
+#include "tst_qmdiarea.moc"
+
diff --git a/tests/auto/widgets/widgets/qmdisubwindow/.gitignore b/tests/auto/widgets/widgets/qmdisubwindow/.gitignore
new file mode 100644
index 0000000000..f83a9b0895
--- /dev/null
+++ b/tests/auto/widgets/widgets/qmdisubwindow/.gitignore
@@ -0,0 +1 @@
+tst_qmdisubwindow
diff --git a/tests/auto/widgets/widgets/qmdisubwindow/qmdisubwindow.pro b/tests/auto/widgets/widgets/qmdisubwindow/qmdisubwindow.pro
new file mode 100644
index 0000000000..5c5bd525df
--- /dev/null
+++ b/tests/auto/widgets/widgets/qmdisubwindow/qmdisubwindow.pro
@@ -0,0 +1,8 @@
+load(qttest_p4)
+QT += widgets
+INCLUDEPATH += .
+SOURCES += tst_qmdisubwindow.cpp
+DEFINES += QT_NO_CAST_TO_ASCII QT_NO_CAST_FROM_ASCII
+
+
+mac*:CONFIG+=insignificant_test
diff --git a/tests/auto/widgets/widgets/qmdisubwindow/tst_qmdisubwindow.cpp b/tests/auto/widgets/widgets/qmdisubwindow/tst_qmdisubwindow.cpp
new file mode 100644
index 0000000000..f7593336e1
--- /dev/null
+++ b/tests/auto/widgets/widgets/qmdisubwindow/tst_qmdisubwindow.cpp
@@ -0,0 +1,2032 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#include <QtTest/QtTest>
+
+#include "qmdisubwindow.h"
+#include "qmdiarea.h"
+
+#include <QLayout>
+#include <QLineEdit>
+#include <QMainWindow>
+#include <QMenuBar>
+#include <QMenu>
+#include <QGroupBox>
+#include <QTextEdit>
+#include <QLayout>
+#include <QHBoxLayout>
+#include <QByteArray>
+#include <QStyle>
+#include <QStyleOptionTitleBar>
+#include <QPushButton>
+#include <QSizeGrip>
+#if defined(Q_WS_MAC) && !defined(QT_NO_STYLE_MAC)
+#include <QMacStyle>
+#endif
+
+QT_BEGIN_NAMESPACE
+#if defined(Q_WS_X11)
+extern void qt_x11_wait_for_window_manager(QWidget *w);
+#endif
+#if !defined(Q_WS_WIN)
+extern bool qt_tab_all_widgets;
+#endif
+QT_END_NAMESPACE
+
+static inline bool tabAllWidgets()
+{
+#if !defined(Q_OS_WIN)
+ if (qApp->style()->inherits("QMacStyle"))
+ return qt_tab_all_widgets;
+#endif
+ return true;
+}
+
+static inline void triggerSignal(QMdiSubWindow *window, QMdiArea *workspace,
+ const QByteArray &signal)
+{
+ if (signal == SIGNAL(windowMaximized())) {
+ window->showMaximized();
+ qApp->processEvents();
+ if (window->parent())
+ QVERIFY(window->isMaximized());
+ } else if (signal == SIGNAL(windowMinimized())) {
+ window->showMinimized();
+ qApp->processEvents();
+ if (window->parent())
+ QVERIFY(window->isMinimized());
+ } else if (signal == SIGNAL(windowRestored())) {
+ window->showMaximized();
+ qApp->processEvents();
+ window->showNormal();
+ qApp->processEvents();
+ QVERIFY(!window->isMinimized());
+ QVERIFY(!window->isMaximized());
+ QVERIFY(!window->isShaded());
+ } else if (signal == SIGNAL(aboutToActivate())) {
+ if (window->parent()) {
+ workspace->setActiveSubWindow(window);
+ qApp->processEvents();
+ }
+ } else if (signal == SIGNAL(windowActivated())) {
+ if (window->parent()) {
+ workspace->setActiveSubWindow(window);
+ qApp->processEvents();
+ }
+ } else if (signal == SIGNAL(windowDeactivated())) {
+ if (!window->parent())
+ return;
+ workspace->setActiveSubWindow(window);
+ qApp->processEvents();
+ workspace->setActiveSubWindow(0);
+ qApp->processEvents();
+ }
+}
+
+// --- from tst_qgraphicsview.cpp ---
+static void sendMousePress(QWidget *widget, const QPoint &point, Qt::MouseButton button = Qt::LeftButton)
+{
+ QMouseEvent event(QEvent::MouseButtonPress, point, widget->mapToGlobal(point), button, 0, 0);
+ QApplication::sendEvent(widget, &event);
+}
+
+static void sendMouseMove(QWidget *widget, const QPoint &point, Qt::MouseButton button = Qt::LeftButton)
+{
+ QMouseEvent event(QEvent::MouseMove, point, widget->mapToGlobal(point), button, button, 0);
+ QApplication::sendEvent(widget, &event);
+}
+
+static void sendMouseRelease(QWidget *widget, const QPoint &point, Qt::MouseButton button = Qt::LeftButton)
+{
+ QMouseEvent event(QEvent::MouseButtonRelease, point, widget->mapToGlobal(point), button, 0, 0);
+ QApplication::sendEvent(widget, &event);
+}
+// ---
+
+static void sendMouseDoubleClick(QWidget *widget, const QPoint &point, Qt::MouseButton button = Qt::LeftButton)
+{
+ sendMousePress(widget, point, button);
+ sendMouseRelease(widget, point, button);
+ QMouseEvent event(QEvent::MouseButtonDblClick, point, widget->mapToGlobal(point), button, 0, 0);
+ QApplication::sendEvent(widget, &event);
+}
+
+static const Qt::WindowFlags StandardWindowFlags
+ = Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::WindowMinMaxButtonsHint;
+static const Qt::WindowFlags DialogWindowFlags
+ = Qt::WindowTitleHint | Qt::WindowSystemMenuHint;
+
+Q_DECLARE_METATYPE(Qt::WindowState);
+Q_DECLARE_METATYPE(Qt::WindowStates);
+Q_DECLARE_METATYPE(Qt::WindowType);
+Q_DECLARE_METATYPE(Qt::WindowFlags);
+
+//TESTED_CLASS=
+//TESTED_FILES=
+
+class tst_QMdiSubWindow : public QObject
+{
+ Q_OBJECT
+private slots:
+ void initTestCase();
+ void sizeHint();
+ void minimumSizeHint();
+ void minimumSize();
+ void setWidget();
+ void setWindowState_data();
+ void setWindowState();
+ void mainWindowSupport();
+ void emittingOfSignals_data();
+ void emittingOfSignals();
+ void showShaded();
+ void showNormal_data();
+ void showNormal();
+#if !defined(QT_NO_CURSOR) && !defined(Q_OS_WINCE_WM)
+ void setOpaqueResizeAndMove_data();
+ void setOpaqueResizeAndMove();
+#endif
+ void setWindowFlags_data();
+ void setWindowFlags();
+ void mouseDoubleClick();
+ void setSystemMenu();
+ void restoreFocus();
+ void changeFocusWithTab();
+ void closeEvent();
+ void setWindowTitle();
+ void resizeEvents_data();
+ void resizeEvents();
+#if defined(Q_WS_MAC)
+ void defaultSizeGrip();
+#endif
+ void hideAndShow();
+ void keepWindowMaximizedState();
+ void explicitlyHiddenWidget();
+ void resizeTimer();
+ void fixedMinMaxSize();
+#if !defined (Q_WS_MAC) && !defined (Q_OS_WINCE)
+ void replaceMenuBarWhileMaximized();
+ void closeOnDoubleClick();
+#endif
+ void setFont();
+ void task_188849();
+ void mdiArea();
+ void task_182852();
+ void task_233197();
+ void task_226929();
+};
+
+void tst_QMdiSubWindow::initTestCase()
+{
+ qRegisterMetaType<Qt::WindowStates>("Qt::WindowStates");
+}
+
+void tst_QMdiSubWindow::sizeHint()
+{
+ QMdiSubWindow *window = new QMdiSubWindow;
+ QCOMPARE(window->sizeHint(), window->minimumSizeHint());
+ window->show();
+ QCOMPARE(window->sizeHint(), window->minimumSizeHint());
+ QMdiArea workspace;
+ workspace.addSubWindow(window);
+ QCOMPARE(window->sizeHint(), window->minimumSizeHint());
+}
+
+void tst_QMdiSubWindow::minimumSizeHint()
+{
+ QMdiSubWindow window;
+ window.show();
+
+ QCOMPARE(window.minimumSizeHint(), qApp->globalStrut());
+
+ window.setWidget(new QWidget);
+ QCOMPARE(window.minimumSizeHint(), window.layout()->minimumSize()
+ .expandedTo(qApp->globalStrut()));
+
+ delete window.widget();
+ delete window.layout();
+ window.setWidget(new QWidget);
+ QCOMPARE(window.minimumSizeHint(), qApp->globalStrut());
+
+ window.widget()->show();
+ QCOMPARE(window.minimumSizeHint(), window.widget()->minimumSizeHint()
+ .expandedTo(qApp->globalStrut()));
+}
+
+void tst_QMdiSubWindow::minimumSize()
+{
+ QMdiArea mdiArea;
+ mdiArea.resize(200, 200);
+
+ // Check that we respect the minimum size set on the sub-window itself.
+ QMdiSubWindow *subWindow1 = mdiArea.addSubWindow(new QWidget);
+ subWindow1->setMinimumSize(1000, 1000);
+ mdiArea.show();
+#if defined(Q_WS_X11)
+ qt_x11_wait_for_window_manager(&mdiArea);
+#endif
+ QCOMPARE(subWindow1->size(), QSize(1000, 1000));
+
+ // Check that we respect the minimum size set on the internal widget.
+ QWidget *widget = new QWidget;
+ widget->setMinimumSize(1000, 1000);
+ QMdiSubWindow *subWindow2 = mdiArea.addSubWindow(widget);
+ QVERIFY(subWindow2->size() != mdiArea.viewport()->size());
+ QCOMPARE(subWindow2->size(), subWindow2->minimumSizeHint());
+}
+
+void tst_QMdiSubWindow::setWidget()
+{
+ QMdiSubWindow window;
+ window.show();
+ QVERIFY(window.layout());
+ QVERIFY(!window.widget());
+
+ // QPointer so we can check if the widget is deleted
+ QPointer<QWidget> widget = new QWidget;
+ widget->setWindowTitle(QString::fromLatin1("DummyTitle"));
+ QCOMPARE(widget->windowTitle(), QString::fromLatin1("DummyTitle"));
+ window.setWidget(widget);
+ QCOMPARE(window.windowTitle(), window.widget()->windowTitle());
+ QCOMPARE(widget->parentWidget(), static_cast<QWidget *>(&window));
+ QVERIFY(!widget->isVisible());
+ QCOMPARE(window.layout()->count(), 1);
+
+ QTest::ignoreMessage(QtWarningMsg,"QMdiSubWindow::setWidget: widget is already set");
+ window.setWidget(widget);
+ QCOMPARE(window.widget(), static_cast<QWidget *>(widget));
+ QCOMPARE(widget->parentWidget(), static_cast<QWidget *>(&window));
+
+ window.setWidget(0);
+ QVERIFY(widget);
+ QVERIFY(!widget->parent());
+ QVERIFY(!window.widget());
+ QCOMPARE(window.layout()->count(), 0);
+
+ window.setWidget(widget);
+ delete window.layout();
+ QVERIFY(!window.layout());
+ QVERIFY(window.widget());
+ QCOMPARE(window.widget()->parentWidget(), static_cast<QWidget *>(&window));
+
+ delete window.widget();
+ QVERIFY(!widget);
+ QVERIFY(!window.widget());
+}
+
+void tst_QMdiSubWindow::setWindowState_data()
+{
+ QTest::addColumn<Qt::WindowState>("windowState");
+
+ QTest::newRow("maximized") << Qt::WindowMaximized;
+ QTest::newRow("minimized") << Qt::WindowMinimized;
+ QTest::newRow("normalized") << Qt::WindowNoState;
+}
+
+void tst_QMdiSubWindow::setWindowState()
+{
+ QFETCH(Qt::WindowState, windowState);
+ QMdiArea workspace;
+ QMdiSubWindow *window = qobject_cast<QMdiSubWindow *>(workspace.addSubWindow(new QLineEdit));
+ window->show();
+ workspace.show();
+#if defined(Q_WS_X11)
+ qt_x11_wait_for_window_manager(&workspace);
+#endif
+
+ QWidget *testWidget = 0;
+ for (int iteration = 0; iteration < 2; ++iteration) {
+ if (iteration == 0)
+ testWidget = window;
+ else
+ testWidget = window->widget();
+
+ testWidget->setWindowState(windowState);
+
+ Qt::WindowStates windowStateWindow = window->windowState();
+ windowStateWindow &= ~Qt::WindowActive;
+ Qt::WindowStates windowStateWidget = window->widget()->windowState();
+ windowStateWidget &= ~Qt::WindowActive;
+ QCOMPARE(windowStateWindow, windowStateWidget);
+
+ switch (windowState) {
+ case Qt::WindowNoState:
+ QVERIFY(!window->widget()->isMinimized());
+ QVERIFY(!window->widget()->isMaximized());
+ QVERIFY(!window->isMinimized());
+ QVERIFY(!window->isMaximized());
+ break;
+ case Qt::WindowMinimized:
+ QVERIFY(window->widget()->isMinimized());
+ QVERIFY(window->isMinimized());
+ break;
+ case Qt::WindowMaximized:
+ QVERIFY(window->widget()->isMaximized());
+ QVERIFY(window->isMaximized());
+ break;
+ default:
+ break;
+ }
+ }
+}
+
+void tst_QMdiSubWindow::mainWindowSupport()
+{
+ QList<QMdiSubWindow *> windows;
+ QMdiArea *workspace = new QMdiArea;
+ QMainWindow mainWindow;
+ mainWindow.setCentralWidget(workspace);
+ mainWindow.show();
+ mainWindow.menuBar()->setVisible(true);
+ qApp->setActiveWindow(&mainWindow);
+
+ // QMainWindow's window title is empty
+#if !defined(Q_WS_MAC) && !defined(Q_OS_WINCE)
+ {
+ QCOMPARE(mainWindow.windowTitle(), QString());
+ QMdiSubWindow *window = workspace->addSubWindow(new QPushButton(QLatin1String("Test")));
+ QString expectedTitle = QLatin1String("MainWindow's title is empty");
+ window->setWindowTitle(expectedTitle);
+ QCOMPARE(window->windowTitle(), expectedTitle);
+ window->showMaximized();
+ QVERIFY(window->isMaximized());
+ QCOMPARE(window->windowTitle(), expectedTitle);
+ QCOMPARE(mainWindow.windowTitle(), expectedTitle);
+ window->showNormal();
+ QCOMPARE(window->windowTitle(), expectedTitle);
+ QCOMPARE(mainWindow.windowTitle(), QString());
+ window->close();
+ }
+#endif
+
+ QString originalWindowTitle = QString::fromLatin1("MainWindow");
+ mainWindow.setWindowTitle(originalWindowTitle);
+
+ for (int i = 0; i < 5; ++i) {
+ mainWindow.menuBar()->setVisible(false);
+
+ QMdiSubWindow *window = new QMdiSubWindow;
+ windows.append(window);
+ QVERIFY(!window->maximizedButtonsWidget());
+ QVERIFY(!window->maximizedSystemMenuIconWidget());
+
+ QMdiArea *nestedWorkspace = new QMdiArea; // :-)
+ window->setWidget(nestedWorkspace);
+ window->widget()->setWindowTitle(QString::fromLatin1("Window %1").arg(i));
+
+ workspace->addSubWindow(window);
+ QVERIFY(!window->maximizedButtonsWidget());
+ QVERIFY(!window->maximizedSystemMenuIconWidget());
+ window->show();
+
+ // mainWindow.menuBar() is not visible
+ window->showMaximized();
+ qApp->processEvents();
+ QVERIFY(window->isMaximized());
+ QVERIFY(!window->maximizedButtonsWidget());
+ QVERIFY(!window->maximizedSystemMenuIconWidget());
+ window->showNormal();
+
+ // Now it is
+ mainWindow.menuBar()->setVisible(true);
+
+ window->showMaximized();
+ qApp->processEvents();
+ QVERIFY(window->isMaximized());
+#if !defined(Q_WS_MAC) && !defined(Q_OS_WINCE)
+ QVERIFY(window->maximizedButtonsWidget());
+ QCOMPARE(window->maximizedButtonsWidget(), mainWindow.menuBar()->cornerWidget(Qt::TopRightCorner));
+ QVERIFY(window->maximizedSystemMenuIconWidget());
+ QCOMPARE(window->maximizedSystemMenuIconWidget(), qobject_cast<QWidget *>(mainWindow.menuBar()
+ ->cornerWidget(Qt::TopLeftCorner)));
+ QCOMPARE(mainWindow.windowTitle(), QString::fromLatin1("%1 - [%2]")
+ .arg(originalWindowTitle, window->widget()->windowTitle()));
+#endif
+
+ // Check that nested child windows don't set window title
+ nestedWorkspace->show();
+ QMdiSubWindow *nestedWindow = new QMdiSubWindow;
+ nestedWindow->setWidget(new QWidget);
+ nestedWorkspace->addSubWindow(nestedWindow);
+ nestedWindow->widget()->setWindowTitle(QString::fromLatin1("NestedWindow %1").arg(i));
+ nestedWindow->showMaximized();
+ qApp->processEvents();
+ QVERIFY(nestedWindow->isMaximized());
+ QVERIFY(!nestedWindow->maximizedButtonsWidget());
+ QVERIFY(!nestedWindow->maximizedSystemMenuIconWidget());
+
+#if !defined(Q_WS_MAC) && !defined(Q_OS_WINCE)
+ QCOMPARE(mainWindow.windowTitle(), QString::fromLatin1("%1 - [%2]")
+ .arg(originalWindowTitle, window->widget()->windowTitle()));
+#endif
+ }
+
+#if defined(Q_WS_MAC) || defined(Q_OS_WINCE)
+ return;
+#endif
+
+ workspace->activateNextSubWindow();
+ qApp->processEvents();
+ foreach (QMdiSubWindow *window, windows) {
+ QCOMPARE(workspace->activeSubWindow(), window);
+ QVERIFY(window->isMaximized());
+ QVERIFY(window->maximizedButtonsWidget());
+ QCOMPARE(window->maximizedButtonsWidget(), mainWindow.menuBar()->cornerWidget(Qt::TopRightCorner));
+ QVERIFY(window->maximizedSystemMenuIconWidget());
+ QCOMPARE(window->maximizedSystemMenuIconWidget(), qobject_cast<QWidget *>(mainWindow.menuBar()
+ ->cornerWidget(Qt::TopLeftCorner)));
+ QCOMPARE(mainWindow.windowTitle(), QString::fromLatin1("%1 - [%2]")
+ .arg(originalWindowTitle, window->widget()->windowTitle()));
+ workspace->activateNextSubWindow();
+ qApp->processEvents();
+ }
+}
+
+// This test was written when QMdiSubWindow emitted separate signals
+void tst_QMdiSubWindow::emittingOfSignals_data()
+{
+ QTest::addColumn<QByteArray>("signal");
+ QTest::addColumn<Qt::WindowState>("watchedState");
+
+ QTest::newRow("windowMaximized") << QByteArray(SIGNAL(windowMaximized())) << Qt::WindowMaximized;
+ QTest::newRow("windowMinimized") << QByteArray(SIGNAL(windowMinimized())) << Qt::WindowMinimized;
+ QTest::newRow("windowRestored") << QByteArray(SIGNAL(windowRestored())) << Qt::WindowNoState;
+ QTest::newRow("aboutToActivate") << QByteArray(SIGNAL(aboutToActivate())) << Qt::WindowNoState;
+ QTest::newRow("windowActivated") << QByteArray(SIGNAL(windowActivated())) << Qt::WindowActive;
+ QTest::newRow("windowDeactivated") << QByteArray(SIGNAL(windowDeactivated())) << Qt::WindowActive;
+}
+
+void tst_QMdiSubWindow::emittingOfSignals()
+{
+ QFETCH(QByteArray, signal);
+ QFETCH(Qt::WindowState, watchedState);
+ QMdiArea workspace;
+ workspace.show();
+ qApp->processEvents();
+ qApp->setActiveWindow(&workspace);
+ QMdiSubWindow *window = qobject_cast<QMdiSubWindow *>(workspace.addSubWindow(new QWidget));
+ qApp->processEvents();
+ window->show();
+ if (signal != SIGNAL(windowRestored()))
+ workspace.setActiveSubWindow(0);
+ qApp->processEvents();
+
+ QSignalSpy spy(window, signal == SIGNAL(aboutToActivate())
+ ? signal.data()
+ : SIGNAL(windowStateChanged(Qt::WindowStates, Qt::WindowStates)));
+ QVERIFY(spy.isEmpty());
+ triggerSignal(window, &workspace, signal);
+ // Unless the signal is windowRestored or windowDeactivated,
+ // we're already in correct state and nothing should happen.
+ if (signal != SIGNAL(windowRestored()) && signal != SIGNAL(windowDeactivated()))
+ triggerSignal(window, &workspace, signal);
+
+ int count = 0;
+ if (signal == SIGNAL(aboutToActivate())) {
+ count += spy.count();
+ } else {
+ for (int i = 0; i < spy.count(); ++i) {
+ Qt::WindowStates oldState = qvariant_cast<Qt::WindowStates>(spy.at(i).at(0));
+ Qt::WindowStates newState = qvariant_cast<Qt::WindowStates>(spy.at(i).at(1));
+ if (watchedState != Qt::WindowNoState) {
+ if (!(oldState & watchedState) && (newState & watchedState))
+ ++count;
+ } else {
+ if ((oldState & (Qt::WindowMinimized | Qt::WindowMaximized))
+ && (newState & (watchedState | Qt::WindowActive))) {
+ ++count;
+ }
+ }
+ }
+ }
+ QCOMPARE(count, 1);
+
+ window->setParent(0);
+ window->showNormal();
+#if defined(Q_WS_X11)
+ qt_x11_wait_for_window_manager(window);
+#endif
+ qApp->processEvents();
+
+ spy.clear();
+ triggerSignal(window, &workspace, signal);
+ QCOMPARE(spy.count(), 0);
+
+ delete window;
+ window = 0;
+}
+
+void tst_QMdiSubWindow::showShaded()
+{
+ QMdiArea workspace;
+ QMdiSubWindow *window = workspace.addSubWindow(new QLineEdit);
+ window->resize(300, 300);
+ qApp->processEvents();
+ workspace.show();
+#ifdef Q_WS_X11
+ qt_x11_wait_for_window_manager(&workspace);
+#endif
+
+ QVERIFY(!window->isShaded());
+ QVERIFY(!window->isMaximized());
+
+ QCOMPARE(window->size(), QSize(300, 300));
+ QRect restoreGeometry = window->geometry();
+ window->showShaded();
+ QVERIFY(window->isShaded());
+ QVERIFY(window->isMinimized());
+
+ window->showNormal();
+ QVERIFY(!window->isShaded());
+ QVERIFY(!window->isMinimized());
+ QCOMPARE(window->geometry(), restoreGeometry);
+ window->showShaded();
+
+ window->showNormal();
+ QVERIFY(!window->isShaded());
+ QVERIFY(!window->isMinimized());
+ QCOMPARE(window->geometry(), restoreGeometry);
+ window->showMinimized();
+ window->showMaximized();
+ window->showShaded();
+ QCOMPARE(window->width(), workspace.contentsRect().width());
+ window->showNormal();
+ QCOMPARE(window->geometry(), workspace.contentsRect());
+
+ window->resize(300, 300);
+ QCOMPARE(window->size(), QSize(300, 300));
+ window->showShaded();
+ window->showNormal();
+ QTest::qWait(250);
+
+#ifdef Q_OS_WINCE
+ QSKIP("Until we have a QEvent::WindowFlagsChange event, this will skip", SkipAll);
+#endif
+
+ const QSize minimumSizeHint = window->minimumSizeHint();
+ QVERIFY(minimumSizeHint.height() < 300);
+ const int maxHeightDiff = 300 - minimumSizeHint.height();
+
+ // Calculate mouse position for bottom right corner and simulate a
+ // vertical resize with the mouse.
+ int offset = window->style()->pixelMetric(QStyle::PM_MDIFrameWidth) / 2;
+ QPoint mousePosition(window->width() - qMax(offset, 2), window->height() - qMax(offset, 2));
+ QWidget *mouseReceiver = 0;
+#ifdef Q_WS_MAC
+ if (qobject_cast<QMacStyle*>(window->style()))
+ mouseReceiver = qFindChild<QSizeGrip *>(window);
+ else
+#endif
+ mouseReceiver = window;
+ QVERIFY(mouseReceiver);
+ sendMouseMove(mouseReceiver, mousePosition, Qt::NoButton);
+ sendMousePress(mouseReceiver, mousePosition);
+
+ for (int i = 0; i < maxHeightDiff + 20; ++i) {
+ --mousePosition.ry();
+ sendMouseMove(mouseReceiver, mousePosition);
+ }
+
+ sendMouseRelease(mouseReceiver, mousePosition);
+ // Make sure we respect the minimumSizeHint!
+ QCOMPARE(window->height(), minimumSizeHint.height());
+
+ window->showShaded();
+ window->setParent(0);
+ window->show();
+ QVERIFY(!window->isShaded());
+
+ delete window;
+}
+
+void tst_QMdiSubWindow::showNormal_data()
+{
+ QTest::addColumn<QByteArray>("slot");
+
+ QTest::newRow("showMinimized") << QByteArray("showMinimized");
+ QTest::newRow("showMaximized") << QByteArray("showMaximized");
+ QTest::newRow("showShaded") << QByteArray("showShaded");
+}
+
+void tst_QMdiSubWindow::showNormal()
+{
+ QFETCH(QByteArray, slot);
+
+ QMdiArea workspace;
+ QWidget *window = workspace.addSubWindow(new QWidget);
+ qApp->processEvents();
+ workspace.show();
+ window->show();
+#if defined(Q_WS_X11)
+ qt_x11_wait_for_window_manager(&workspace);
+#endif
+
+ QRect originalGeometry = window->geometry();
+ QVERIFY(QMetaObject::invokeMethod(window, slot.data()));
+ qApp->processEvents();
+ window->showNormal();
+ qApp->processEvents();
+ QCOMPARE(window->geometry(), originalGeometry);
+}
+
+class EventSpy : public QObject
+{
+public:
+ EventSpy(QObject *object, QEvent::Type event)
+ : eventToSpy(event), _count(0)
+ {
+ if (object)
+ object->installEventFilter(this);
+ }
+
+ int count() const { return _count; }
+ void clear() { _count = 0; }
+
+protected:
+ bool eventFilter(QObject *object, QEvent *event)
+ {
+ if (event->type() == eventToSpy)
+ ++_count;
+ return QObject::eventFilter(object, event);
+ }
+
+private:
+ QEvent::Type eventToSpy;
+ int _count;
+};
+
+// This test requires cursor support, which is absent on WinCE
+#if !defined(QT_NO_CURSOR) && !defined(Q_OS_WINCE_WM)
+void tst_QMdiSubWindow::setOpaqueResizeAndMove_data()
+{
+ QTest::addColumn<bool>("opaqueMode");
+ QTest::addColumn<int>("geometryCount");
+ QTest::addColumn<int>("expectedGeometryCount");
+ QTest::addColumn<QSize>("workspaceSize");
+ QTest::addColumn<QSize>("windowSize");
+
+ QTest::newRow("normal mode") << true<< 20 << 20 << QSize(400, 400) << QSize(200, 200);
+ QTest::newRow("rubberband mode") << false << 20 << 1 << QSize(400, 400) << QSize(200, 200);
+}
+
+void tst_QMdiSubWindow::setOpaqueResizeAndMove()
+{
+ QFETCH(bool, opaqueMode);
+ QFETCH(int, geometryCount);
+ QFETCH(int, expectedGeometryCount);
+ QFETCH(QSize, workspaceSize);
+ QFETCH(QSize, windowSize);
+
+ QMdiArea workspace;
+ QMdiSubWindow *window = qobject_cast<QMdiSubWindow *>(workspace.addSubWindow(new QWidget));
+ qApp->processEvents();
+ workspace.resize(workspaceSize);
+ workspace.show();
+#ifdef Q_WS_X11
+ qt_x11_wait_for_window_manager(&workspace);
+#endif
+
+ QWidget *mouseReceiver = 0;
+ if (window->style()->inherits("QMacStyle"))
+ mouseReceiver = qFindChild<QSizeGrip *>(window);
+ else
+ mouseReceiver = window;
+ QVERIFY(mouseReceiver);
+
+ // ----------------------------- resize -----------------------------
+ {
+ // setOpaqueResize
+ window->setOption(QMdiSubWindow::RubberBandResize, !opaqueMode);
+ QCOMPARE(window->testOption(QMdiSubWindow::RubberBandResize), !opaqueMode);
+
+ // Check that the event spy actually works
+ EventSpy resizeSpy(window, QEvent::Resize);
+ QCOMPARE(resizeSpy.count(), 0);
+ window->resize(windowSize);
+ QCOMPARE(window->size(), windowSize);
+ QCOMPARE(resizeSpy.count(), 1);
+ resizeSpy.clear();
+ QCOMPARE(resizeSpy.count(), 0);
+
+ QTest::qWait(250); // delayed update of dirty regions
+
+ // Enter resize mode.
+ int offset = window->style()->pixelMetric(QStyle::PM_MDIFrameWidth) / 2;
+ QPoint mousePosition(mouseReceiver->width() - qMax(offset, 2), mouseReceiver->height() - qMax(offset, 2));
+ sendMouseMove(mouseReceiver, mousePosition, Qt::NoButton);
+ sendMousePress(mouseReceiver, mousePosition);
+
+ // The window itself is the grabber in rubberband mode
+ if (!opaqueMode) {
+ mouseReceiver = window;
+ mousePosition = QPoint(window->width() - qMax(offset, 2), window->height() - qMax(offset, 2));
+ }
+
+ // Trigger resize events
+ for (int i = 0; i < geometryCount; ++i) {
+ if (mouseReceiver == window) {
+ ++mousePosition.rx();
+ ++mousePosition.ry();
+ sendMouseMove(mouseReceiver, mousePosition);
+ } else {
+ sendMouseMove(mouseReceiver, mousePosition + QPoint(1, 1));
+ }
+ }
+
+ // Leave resize mode
+ sendMouseRelease(mouseReceiver, mousePosition);
+ QCOMPARE(resizeSpy.count(), expectedGeometryCount);
+ QCOMPARE(window->size(), windowSize + QSize(geometryCount, geometryCount));
+ }
+
+ // ------------------------------ move ------------------------------
+ {
+ // setOpaqueMove
+ window->setOption(QMdiSubWindow::RubberBandMove, !opaqueMode);
+ QCOMPARE(window->testOption(QMdiSubWindow::RubberBandMove), !opaqueMode);
+
+ EventSpy moveSpy(window, QEvent::Move);
+ QCOMPARE(moveSpy.count(), 0);
+ window->move(30, 30);
+ QCOMPARE(moveSpy.count(), 1);
+ moveSpy.clear();
+
+ // Enter move mode
+ QStyleOptionTitleBar options;
+ options.initFrom(window);
+ int height = window->style()->pixelMetric(QStyle::PM_TitleBarHeight, &options);
+#if defined(Q_WS_MAC)
+ // ### Remove this after mac style has been fixed
+ height -= 4;
+#endif
+ QPoint mousePosition(window->width() / 2, height - 1);
+ sendMouseMove(window, mousePosition, Qt::NoButton);
+ sendMousePress(window, mousePosition);
+
+ // Trigger move events
+ for (int i = 0; i < geometryCount; ++i) {
+ ++mousePosition.rx();
+ ++mousePosition.ry();
+ sendMouseMove(window, mousePosition);
+ }
+
+ // Leave move mode
+ sendMouseRelease(window, mousePosition);
+ QCOMPARE(moveSpy.count(), expectedGeometryCount);
+ QCOMPARE(window->size(), windowSize + QSize(geometryCount, geometryCount));
+ }
+}
+#endif
+
+void tst_QMdiSubWindow::setWindowFlags_data()
+{
+ QTest::addColumn<Qt::WindowType>("windowType");
+ QTest::addColumn<Qt::WindowType>("expectedWindowType");
+ QTest::addColumn<Qt::WindowFlags>("customFlags");
+ QTest::addColumn<Qt::WindowFlags>("expectedCustomFlags");
+
+ // NB! If 'expectedCustomFlags' is set to 'Qt::WindowFlags(0)'
+ // and nothing else, it means we're expecting the same as customFlags.
+
+ // Standard window types with no custom flags set.
+ QTest::newRow("Qt::Widget") << Qt::Widget << Qt::SubWindow
+ << Qt::WindowFlags(0) << StandardWindowFlags;
+ QTest::newRow("Qt::Window") << Qt::Window << Qt::SubWindow
+ << Qt::WindowFlags(0) << StandardWindowFlags;
+ QTest::newRow("Qt::Dialog") << Qt::Dialog << Qt::SubWindow
+ << Qt::WindowFlags(0) << DialogWindowFlags;
+ QTest::newRow("Qt::Sheet") << Qt::Sheet << Qt::SubWindow
+ << Qt::WindowFlags(0) << StandardWindowFlags;
+ QTest::newRow("Qt::Drawer") << Qt::Drawer << Qt::SubWindow
+ << Qt::WindowFlags(0) << StandardWindowFlags;
+ QTest::newRow("Qt::Popup") << Qt::Popup << Qt::SubWindow
+ << Qt::WindowFlags(0) << StandardWindowFlags;
+ QTest::newRow("Qt::Tool") << Qt::Tool << Qt::SubWindow
+ << Qt::WindowFlags(0) << StandardWindowFlags;
+ QTest::newRow("Qt::ToolTip") << Qt::ToolTip << Qt::SubWindow
+ << Qt::WindowFlags(0) << StandardWindowFlags;
+ QTest::newRow("Qt::SplashScreen") << Qt::SplashScreen << Qt::SubWindow
+ << Qt::WindowFlags(0) << StandardWindowFlags;
+ QTest::newRow("Qt::Desktop") << Qt::Desktop << Qt::SubWindow
+ << Qt::WindowFlags(0) << StandardWindowFlags;
+ QTest::newRow("Qt::SubWindow") << Qt::SubWindow << Qt::SubWindow
+ << Qt::WindowFlags(0) << StandardWindowFlags;
+
+ // Custom flags
+ QTest::newRow("Title") << Qt::SubWindow << Qt::SubWindow
+ << (Qt::WindowTitleHint | Qt::WindowFlags(0))
+ << Qt::WindowFlags(0);
+ QTest::newRow("TitleAndMin") << Qt::SubWindow << Qt::SubWindow
+ << (Qt::WindowTitleHint | Qt::WindowMinimizeButtonHint)
+ << Qt::WindowFlags(0);
+ QTest::newRow("TitleAndMax") << Qt::SubWindow << Qt::SubWindow
+ << (Qt::WindowTitleHint | Qt::WindowMaximizeButtonHint)
+ << Qt::WindowFlags(0);
+ QTest::newRow("TitleAndMinMax") << Qt::SubWindow << Qt::SubWindow
+ << (Qt::WindowTitleHint | Qt::WindowMinMaxButtonsHint)
+ << Qt::WindowFlags(0);
+ QTest::newRow("Standard") << Qt::SubWindow << Qt::SubWindow
+ << StandardWindowFlags
+ << Qt::WindowFlags(0);
+ QTest::newRow("StandardAndShade") << Qt::SubWindow << Qt::SubWindow
+ << (StandardWindowFlags | Qt::WindowShadeButtonHint)
+ << Qt::WindowFlags(0);
+ QTest::newRow("StandardAndContext") << Qt::SubWindow << Qt::SubWindow
+ << (StandardWindowFlags | Qt::WindowContextHelpButtonHint)
+ << Qt::WindowFlags(0);
+ QTest::newRow("StandardAndStaysOnTop") << Qt::SubWindow << Qt::SubWindow
+ << (StandardWindowFlags | Qt::WindowStaysOnTopHint)
+ << Qt::WindowFlags(0);
+ QTest::newRow("StandardAndFrameless") << Qt::SubWindow << Qt::SubWindow
+ << (StandardWindowFlags | Qt::FramelessWindowHint)
+ << (Qt::FramelessWindowHint | Qt::WindowFlags(0));
+ QTest::newRow("StandardAndFramelessAndStaysOnTop") << Qt::SubWindow << Qt::SubWindow
+ << (StandardWindowFlags | Qt::FramelessWindowHint
+ | Qt::WindowStaysOnTopHint)
+ << (Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint);
+ QTest::newRow("Shade") << Qt::SubWindow << Qt::SubWindow
+ << (Qt::WindowShadeButtonHint | Qt::WindowFlags(0))
+ << (StandardWindowFlags | Qt::WindowShadeButtonHint);
+ QTest::newRow("ShadeAndCustomize") << Qt::SubWindow << Qt::SubWindow
+ << (Qt::WindowShadeButtonHint | Qt::CustomizeWindowHint)
+ << Qt::WindowFlags(0);
+ QTest::newRow("Context") << Qt::SubWindow << Qt::SubWindow
+ << (Qt::WindowContextHelpButtonHint | Qt::WindowFlags(0))
+ << (StandardWindowFlags | Qt::WindowContextHelpButtonHint);
+ QTest::newRow("ContextAndCustomize") << Qt::SubWindow << Qt::SubWindow
+ << (Qt::WindowContextHelpButtonHint | Qt::CustomizeWindowHint)
+ << Qt::WindowFlags(0);
+ QTest::newRow("ShadeAndContext") << Qt::SubWindow << Qt::SubWindow
+ << (Qt::WindowShadeButtonHint | Qt::WindowContextHelpButtonHint)
+ << (StandardWindowFlags | Qt::WindowShadeButtonHint | Qt::WindowContextHelpButtonHint);
+ QTest::newRow("ShadeAndContextAndCustomize") << Qt::SubWindow << Qt::SubWindow
+ << (Qt::WindowShadeButtonHint | Qt::WindowContextHelpButtonHint | Qt::CustomizeWindowHint)
+ << Qt::WindowFlags(0);
+ QTest::newRow("OnlyCustomize") << Qt::SubWindow << Qt::SubWindow
+ << (Qt::CustomizeWindowHint | Qt::WindowFlags(0))
+ << Qt::WindowFlags(0);
+}
+
+void tst_QMdiSubWindow::setWindowFlags()
+{
+ QSKIP("Until we have a QEvent::WindowFlagsChange event, this will skip", SkipAll);
+ QFETCH(Qt::WindowType, windowType);
+ QFETCH(Qt::WindowType, expectedWindowType);
+ QFETCH(Qt::WindowFlags, customFlags);
+ QFETCH(Qt::WindowFlags, expectedCustomFlags);
+
+ QMdiArea workspace;
+ QMdiSubWindow *window = qobject_cast<QMdiSubWindow *>(workspace.addSubWindow(new QWidget));
+ qApp->processEvents();
+ workspace.show();
+ window->show();
+#if defined(Q_WS_X11)
+ qt_x11_wait_for_window_manager(&workspace);
+#endif
+
+ window->setWindowFlags(windowType | customFlags);
+ QCOMPARE(window->windowType(), expectedWindowType);
+ if (!expectedCustomFlags) // We expect the same as 'customFlags'
+ QCOMPARE(window->windowFlags() & ~expectedWindowType, customFlags);
+ else
+ QCOMPARE(window->windowFlags() & ~expectedWindowType, expectedCustomFlags);
+
+}
+
+void tst_QMdiSubWindow::mouseDoubleClick()
+{
+ QMdiArea workspace;
+ QMdiSubWindow *window = qobject_cast<QMdiSubWindow *>(workspace.addSubWindow(new QWidget));
+ qApp->processEvents();
+ workspace.show();
+ window->show();
+
+ QVERIFY(!window->isMaximized());
+ QVERIFY(!window->isShaded());
+
+ QRect originalGeometry = window->geometry();
+
+ // Calculate mouse position
+ QStyleOptionTitleBar options;
+ options.initFrom(window);
+ int height = window->style()->pixelMetric(QStyle::PM_TitleBarHeight, &options);
+ // ### Remove this after mac style has been fixed
+ if (window->style()->inherits("QMacStyle"))
+ height -= 4;
+ // has border
+ if (!window->style()->styleHint(QStyle::SH_TitleBar_NoBorder, &options, window))
+ height += window->isMinimized() ? 8 : 4;
+ QPoint mousePosition(window->width() / 2, height - 1);
+ sendMouseMove(window, mousePosition, Qt::NoButton);
+
+ // Without Qt::WindowShadeButtonHint flag set
+ sendMouseDoubleClick(window, mousePosition);
+ qApp->processEvents();
+ QVERIFY(window->isMaximized());
+
+ sendMouseDoubleClick(window, mousePosition);
+ qApp->processEvents();
+ QVERIFY(!window->isMaximized());
+ QCOMPARE(window->geometry(), originalGeometry);
+
+ // With Qt::WindowShadeButtonHint flag set
+ QSKIP("Until we have a QEvent::WindowFlagsChange event, this will skip", SkipAll);
+ window->setWindowFlags(window->windowFlags() | Qt::WindowShadeButtonHint);
+ QVERIFY(window->windowFlags() & Qt::WindowShadeButtonHint);
+ originalGeometry = window->geometry();
+ sendMouseDoubleClick(window, mousePosition);
+ qApp->processEvents();
+ QVERIFY(window->isShaded());
+
+ sendMouseDoubleClick(window, mousePosition);
+ qApp->processEvents();
+ QVERIFY(!window->isShaded());
+ QCOMPARE(window->geometry(), originalGeometry);
+
+ window->showMinimized();
+ QVERIFY(window->isMinimized());
+ sendMouseDoubleClick(window, mousePosition);
+ QVERIFY(!window->isMinimized());
+ QCOMPARE(window->geometry(), originalGeometry);
+}
+
+void tst_QMdiSubWindow::setSystemMenu()
+{
+ QMdiSubWindow *subWindow = new QMdiSubWindow;
+ subWindow->resize(200, 50);
+ QPointer<QMenu>systemMenu = subWindow->systemMenu();
+ QVERIFY(systemMenu);
+ QCOMPARE(subWindow->actions(), systemMenu->actions());
+
+ QMainWindow mainWindow;
+ QMdiArea *mdiArea = new QMdiArea;
+ mdiArea->addSubWindow(subWindow);
+ mainWindow.setCentralWidget(mdiArea);
+ mainWindow.menuBar();
+ mainWindow.show();
+ QTest::qWaitForWindowShown(&mainWindow);
+ QTest::qWait(60);
+
+
+ QTRY_VERIFY(subWindow->isVisible());
+ QPoint globalPopupPos;
+
+ // Show system menu
+ QVERIFY(!qApp->activePopupWidget());
+ subWindow->showSystemMenu();
+ QTest::qWait(25);
+ QTRY_COMPARE(qApp->activePopupWidget(), qobject_cast<QWidget *>(systemMenu));
+ QTRY_COMPARE(systemMenu->mapToGlobal(QPoint(0, 0)),
+ (globalPopupPos = subWindow->mapToGlobal(subWindow->contentsRect().topLeft())) );
+
+ systemMenu->hide();
+ QVERIFY(!qApp->activePopupWidget());
+
+ QTest::ignoreMessage(QtWarningMsg, "QMdiSubWindow::setSystemMenu: system menu is already set");
+ subWindow->setSystemMenu(systemMenu);
+
+ subWindow->setSystemMenu(0);
+ QVERIFY(!systemMenu); // systemMenu is QPointer
+
+ systemMenu = new QMenu(subWindow);
+ systemMenu->addAction(QIcon(subWindow->style()->standardIcon(QStyle::SP_TitleBarCloseButton)),
+ QObject::tr("&Close"), subWindow, SLOT(close()));
+ subWindow->setSystemMenu(systemMenu);
+ QCOMPARE(subWindow->systemMenu(), qobject_cast<QMenu *>(systemMenu));
+ QCOMPARE(subWindow->systemMenu()->parentWidget(), static_cast<QWidget *>(subWindow));
+ QCOMPARE(subWindow->systemMenu()->actions().count(), 1);
+
+ // Show the new system menu
+ QVERIFY(!qApp->activePopupWidget());
+ subWindow->showSystemMenu();
+ QTest::qWait(25);
+ QTRY_COMPARE(qApp->activePopupWidget(), qobject_cast<QWidget *>(systemMenu));
+ QTRY_COMPARE(systemMenu->mapToGlobal(QPoint(0, 0)), globalPopupPos);
+
+ systemMenu->hide();
+ QVERIFY(!qApp->activePopupWidget());
+
+#if !defined (Q_WS_MAC) && !defined (Q_OS_WINCE)
+ // System menu in menu bar.
+ subWindow->showMaximized();
+ QVERIFY(subWindow->isMaximized());
+ QWidget *menuLabel = subWindow->maximizedSystemMenuIconWidget();
+ QVERIFY(menuLabel);
+ subWindow->showSystemMenu();
+ QTest::qWait(25);
+ QTRY_COMPARE(qApp->activePopupWidget(), qobject_cast<QWidget *>(systemMenu));
+ QCOMPARE(systemMenu->mapToGlobal(QPoint(0, 0)),
+ (globalPopupPos = menuLabel->mapToGlobal(QPoint(0, menuLabel->y() + menuLabel->height()))));
+ systemMenu->hide();
+ QTRY_VERIFY(!qApp->activePopupWidget());
+ subWindow->showNormal();
+#endif
+
+ // Reverse
+ qApp->setLayoutDirection(Qt::RightToLeft);
+ qApp->processEvents();
+ mainWindow.updateGeometry();
+ QTest::qWait(150);
+
+ subWindow->showSystemMenu();
+ QTest::qWait(250);
+ QTRY_COMPARE(qApp->activePopupWidget(), qobject_cast<QWidget *>(systemMenu));
+ // + QPoint(1, 0) because topRight() == QPoint(left() + width() -1, top())
+ globalPopupPos = subWindow->mapToGlobal(subWindow->contentsRect().topRight()) + QPoint(1, 0);
+ globalPopupPos -= QPoint(systemMenu->sizeHint().width(), 0);
+ QTRY_COMPARE(systemMenu->mapToGlobal(QPoint(0, 0)), globalPopupPos);
+
+ systemMenu->hide();
+ QVERIFY(!qApp->activePopupWidget());
+
+#if !defined (Q_WS_MAC) && !defined (Q_OS_WINCE)
+ // System menu in menu bar in reverse mode.
+ subWindow->showMaximized();
+ QVERIFY(subWindow->isMaximized());
+ menuLabel = subWindow->maximizedSystemMenuIconWidget();
+ QVERIFY(menuLabel);
+ subWindow->showSystemMenu();
+ QTest::qWait(250);
+ QTRY_COMPARE(qApp->activePopupWidget(), qobject_cast<QWidget *>(systemMenu));
+ globalPopupPos = menuLabel->mapToGlobal(QPoint(menuLabel->width(), menuLabel->y() + menuLabel->height()));
+ globalPopupPos -= QPoint(systemMenu->sizeHint().width(), 0);
+ QTRY_COMPARE(systemMenu->mapToGlobal(QPoint(0, 0)), globalPopupPos);
+#endif
+
+ delete systemMenu;
+ QVERIFY(!qApp->activePopupWidget());
+ QVERIFY(!subWindow->systemMenu());
+
+ // Restore layout direction.
+ qApp->setLayoutDirection(Qt::LeftToRight);
+}
+
+void tst_QMdiSubWindow::restoreFocus()
+{
+ // Create complex layout.
+ QGroupBox *box = new QGroupBox(tr("GroupBox"));
+ box->setCheckable(true);
+
+ QGroupBox *box1 = new QGroupBox(tr("&TopLeft"));
+ box1->setLayout(new QHBoxLayout);
+ box1->layout()->addWidget(new QTextEdit);
+
+ QGroupBox *box2 = new QGroupBox(tr("&TopRight"));
+ box2->setLayout(new QHBoxLayout);
+ box2->layout()->addWidget(new QTextEdit);
+
+ QGroupBox *box3 = new QGroupBox(tr("&BottomLeft"));
+ box3->setLayout(new QHBoxLayout);
+ box3->layout()->addWidget(new QTextEdit);
+
+ QGroupBox *box4 = new QGroupBox(tr("&BottomRight"));
+ box4->setLayout(new QHBoxLayout);
+ QMdiArea *nestedWorkspace = new QMdiArea;
+ for (int i = 0; i < 4; ++i)
+ nestedWorkspace->addSubWindow(new QTextEdit)->show();
+ qApp->processEvents();
+ nestedWorkspace->setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded);
+ nestedWorkspace->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
+ box4->layout()->addWidget(nestedWorkspace);
+
+ QGridLayout *layout = new QGridLayout;
+ layout->addWidget(box1, 0, 0);
+ layout->addWidget(box2, 0, 1);
+ layout->addWidget(box3, 1, 0);
+ layout->addWidget(box4, 1, 1);
+
+ box->setLayout(layout);
+
+ // Add complex widget to workspace.
+ QMdiArea topArea;
+ QMdiSubWindow *complexWindow = topArea.addSubWindow(box);
+ topArea.show();
+ box->show();
+
+ qApp->setActiveWindow(&topArea);
+ QMdiSubWindow *expectedFocusWindow = nestedWorkspace->subWindowList().last();
+ QVERIFY(expectedFocusWindow);
+ QVERIFY(expectedFocusWindow->widget());
+ QCOMPARE(qApp->focusWidget(), expectedFocusWindow->widget());
+
+ // Normal -> minimized
+ expectedFocusWindow->showMinimized();
+ qApp->processEvents();
+ QVERIFY(expectedFocusWindow->isMinimized());
+ QCOMPARE(qApp->focusWidget(), static_cast<QWidget *>(expectedFocusWindow));
+
+ // Minimized -> normal
+ expectedFocusWindow->showNormal();
+ qApp->processEvents();
+ QVERIFY(!expectedFocusWindow->isMinimized());
+ QCOMPARE(qApp->focusWidget(), expectedFocusWindow->widget());
+
+ // Normal -> maximized
+ expectedFocusWindow->showMaximized();
+ qApp->processEvents();
+ QVERIFY(expectedFocusWindow->isMaximized());
+ QCOMPARE(qApp->focusWidget(), expectedFocusWindow->widget());
+
+ // Maximized -> normal
+ expectedFocusWindow->showNormal();
+ qApp->processEvents();
+ QVERIFY(!expectedFocusWindow->isMaximized());
+ QCOMPARE(qApp->focusWidget(), expectedFocusWindow->widget());
+
+ // Minimized -> maximized
+ expectedFocusWindow->showMinimized();
+ qApp->processEvents();
+ QVERIFY(expectedFocusWindow->isMinimized());
+ expectedFocusWindow->showMaximized();
+ qApp->processEvents();
+ QVERIFY(expectedFocusWindow->isMaximized());
+ QCOMPARE(qApp->focusWidget(), expectedFocusWindow->widget());
+
+ // Maximized -> minimized
+ expectedFocusWindow->showNormal();
+ qApp->processEvents();
+ QVERIFY(!expectedFocusWindow->isMaximized());
+ expectedFocusWindow->showMaximized();
+ qApp->processEvents();
+ QVERIFY(expectedFocusWindow->isMaximized());
+ expectedFocusWindow->showMinimized();
+ qApp->processEvents();
+ QVERIFY(expectedFocusWindow->isMinimized());
+ QCOMPARE(qApp->focusWidget(), static_cast<QWidget *>(expectedFocusWindow));
+
+ complexWindow->showMinimized();
+ qApp->processEvents();
+ QVERIFY(complexWindow->isMinimized());
+ QCOMPARE(qApp->focusWidget(), static_cast<QWidget *>(complexWindow));
+
+ complexWindow->showNormal();
+ qApp->processEvents();
+ QVERIFY(!complexWindow->isMinimized());
+ QCOMPARE(qApp->focusWidget(), static_cast<QWidget *>(expectedFocusWindow));
+}
+
+void tst_QMdiSubWindow::changeFocusWithTab()
+{
+ QWidget *widget = new QWidget;
+ widget->setLayout(new QVBoxLayout);
+
+ QLineEdit *firstLineEdit = new QLineEdit;
+ widget->layout()->addWidget(firstLineEdit);
+ QLineEdit *secondLineEdit = new QLineEdit;
+ widget->layout()->addWidget(secondLineEdit);
+ QLineEdit *thirdLineEdit = new QLineEdit;
+ widget->layout()->addWidget(thirdLineEdit);
+
+ QMdiArea mdiArea;
+ mdiArea.addSubWindow(widget);
+ mdiArea.show();
+ QCOMPARE(mdiArea.subWindowList().count(), 1);
+
+ qApp->setActiveWindow(&mdiArea);
+ QCOMPARE(qApp->focusWidget(), static_cast<QWidget *>(firstLineEdit));
+
+ // Next
+ QTest::keyPress(widget, Qt::Key_Tab);
+ QCOMPARE(qApp->focusWidget(), static_cast<QWidget *>(secondLineEdit));
+
+ // Next
+ QTest::keyPress(widget, Qt::Key_Tab);
+ QCOMPARE(qApp->focusWidget(), static_cast<QWidget *>(thirdLineEdit));
+
+ // Previous
+ QTest::keyPress(widget, Qt::Key_Backtab);
+ QCOMPARE(qApp->focusWidget(), static_cast<QWidget *>(secondLineEdit));
+
+ // Previous
+ QTest::keyPress(widget, Qt::Key_Backtab);
+ QCOMPARE(qApp->focusWidget(), static_cast<QWidget *>(firstLineEdit));
+
+ QMdiSubWindow *window = mdiArea.addSubWindow(new QPushButton);
+ window->show();
+ QCOMPARE(mdiArea.activeSubWindow(), window);
+
+ // Check that we don't give away focus to another window by
+ // just hitting tab if the child widget does not accept
+ // focus (which is the case for a QPushButton).
+ QTest::keyPress(window, Qt::Key_Tab);
+ QCOMPARE(mdiArea.activeSubWindow(), window);
+ QCOMPARE(qApp->focusWidget(), tabAllWidgets() ? window->widget() : window);
+ QTest::keyPress(window, Qt::Key_Tab);
+ QCOMPARE(mdiArea.activeSubWindow(), window);
+ QCOMPARE(qApp->focusWidget(), tabAllWidgets() ? window->widget() : window);
+}
+
+class MyTextEdit : public QTextEdit
+{
+public:
+ MyTextEdit(QWidget *parent = 0) : QTextEdit(parent), acceptClose(false) {}
+ void setAcceptClose(bool enable = true) { acceptClose = enable; }
+protected:
+ void closeEvent(QCloseEvent *closeEvent)
+ {
+ if (!acceptClose)
+ closeEvent->ignore();
+ }
+
+private:
+ bool acceptClose;
+};
+
+void tst_QMdiSubWindow::closeEvent()
+{
+ QMdiArea mdiArea;
+ mdiArea.show();
+
+ MyTextEdit *textEdit = new MyTextEdit;
+ textEdit->setAcceptClose(false);
+ QMdiSubWindow *window = mdiArea.addSubWindow(textEdit);
+ EventSpy closeSpy(window->widget(), QEvent::Close);
+ window->show();
+
+ QCOMPARE(closeSpy.count(), 0);
+ QVERIFY(window->isVisible());
+ QVERIFY(textEdit->isVisible());
+
+ QVERIFY(!window->close());
+ QCOMPARE(closeSpy.count(), 1);
+ QVERIFY(window->isVisible());
+ QVERIFY(textEdit->isVisible());
+
+ QVERIFY(!textEdit->close());
+ QCOMPARE(closeSpy.count(), 2);
+ QVERIFY(window->isVisible());
+ QVERIFY(textEdit->isVisible());
+
+ textEdit->setAcceptClose(true);
+
+ QVERIFY(window->close());
+ QCOMPARE(closeSpy.count(), 3);
+ QCOMPARE(mdiArea.subWindowList().count(), 0);
+}
+
+// There exists more tests in QMdiArea which covers window title support
+// related to QMainWindow. This test is specific for QMdiSubWindow and its
+// widget.
+void tst_QMdiSubWindow::setWindowTitle()
+{
+ QString expectedWindowTitle = QLatin1String("This is teh shit[*]");
+ QTextEdit *textEdit = new QTextEdit;
+ textEdit->setWindowTitle(expectedWindowTitle);
+ QCOMPARE(textEdit->windowTitle(), expectedWindowTitle);
+ textEdit->setWindowModified(true);
+ QCOMPARE(textEdit->isWindowModified(), true);
+
+ QMdiArea mdiArea;
+ QMdiSubWindow *window = new QMdiSubWindow;
+ mdiArea.addSubWindow(window);
+ QCOMPARE(window->windowTitle(), QString());
+ QVERIFY(!window->isWindowModified());
+
+ window->setWidget(textEdit);
+ QVERIFY(window->isWindowModified());
+ QCOMPARE(textEdit->windowTitle(), expectedWindowTitle);
+ QCOMPARE(window->windowTitle(), window->widget()->windowTitle());
+
+ textEdit->setWindowModified(false);
+ QVERIFY(!textEdit->isWindowModified());
+ QVERIFY(!window->isWindowModified());
+ // This will return the title including the astrix, but the
+ // actual window title does not contain the astrix. This behavior
+ // seems a bit odd, but is equal to e.g. QTextEdit (and probably all
+ // other widgets which are not real top-level widgets).
+ QCOMPARE(window->windowTitle(), expectedWindowTitle);
+
+ textEdit->setWindowModified(true);;
+ expectedWindowTitle = QLatin1String("Override child title");
+ window->setWindowTitle(expectedWindowTitle);
+ QVERIFY(window->isWindowModified());
+ QCOMPARE(window->windowTitle(), expectedWindowTitle);
+
+ textEdit->setWindowTitle(QLatin1String("My parent overrides me"));
+ QCOMPARE(window->windowTitle(), expectedWindowTitle);
+
+ textEdit->setWindowModified(false);
+ QVERIFY(window->isWindowModified());
+ QCOMPARE(window->windowTitle(), expectedWindowTitle);
+
+ window->setWindowModified(false);
+ QVERIFY(!window->isWindowModified());
+ window->setWindowTitle(QString());
+ QCOMPARE(window->windowTitle(), QString());
+
+ expectedWindowTitle = QLatin1String("My parent doesn't have any title so now I can set one[*]");
+ textEdit->setWindowTitle(expectedWindowTitle);
+ QCOMPARE(window->windowTitle(), expectedWindowTitle);
+ textEdit->setWindowModified(true);
+ QVERIFY(window->isWindowModified());
+
+ window->setWidget(0);
+ QCOMPARE(window->windowTitle(), QString());
+ QVERIFY(!window->isWindowModified());
+ delete textEdit;
+}
+
+void tst_QMdiSubWindow::resizeEvents_data()
+{
+ QTest::addColumn<Qt::WindowState>("windowState");
+ QTest::addColumn<int>("expectedWindowResizeEvents");
+ QTest::addColumn<int>("expectedWidgetResizeEvents");
+ QTest::addColumn<bool>("isShadeMode");
+
+ QTest::newRow("minimized") << Qt::WindowMinimized << 1 << 0 << false;
+ QTest::newRow("maximized") << Qt::WindowMaximized << 1 << 1 << false;
+ QTest::newRow("shaded") << Qt::WindowMinimized << 1 << 0 << true;
+}
+
+void tst_QMdiSubWindow::resizeEvents()
+{
+ QFETCH(Qt::WindowState, windowState);
+ QFETCH(int, expectedWindowResizeEvents);
+ QFETCH(int, expectedWidgetResizeEvents);
+ QFETCH(bool, isShadeMode);
+
+ QMainWindow mainWindow;
+ QMdiArea *mdiArea = new QMdiArea;
+ mainWindow.setCentralWidget(mdiArea);
+ mainWindow.show();
+#if defined(Q_WS_X11)
+ qt_x11_wait_for_window_manager(&mainWindow);
+#endif
+
+ QMdiSubWindow *window = mdiArea->addSubWindow(new QTextEdit);
+ window->show();
+
+ EventSpy windowResizeEventSpy(window, QEvent::Resize);
+ QCOMPARE(windowResizeEventSpy.count(), 0);
+ EventSpy widgetResizeEventSpy(window->widget(), QEvent::Resize);
+ QCOMPARE(widgetResizeEventSpy.count(), 0);
+
+ // Set the window state.
+ if (!isShadeMode)
+ window->setWindowState(windowState);
+ else
+ window->showShaded();
+
+ // Check that the window state is correct.
+ QCOMPARE(window->windowState(), windowState | Qt::WindowActive);
+ QCOMPARE(window->widget()->windowState(), windowState);
+
+ // Make sure we got as many resize events as expected.
+ QCOMPARE(windowResizeEventSpy.count(), expectedWindowResizeEvents);
+ QCOMPARE(widgetResizeEventSpy.count(), expectedWidgetResizeEvents);
+ windowResizeEventSpy.clear();
+ widgetResizeEventSpy.clear();
+
+ // Normalize.
+ window->showNormal();
+
+ // Check that the window state is correct.
+ QCOMPARE(window->windowState(), Qt::WindowNoState | Qt::WindowActive);
+ QCOMPARE(window->widget()->windowState(), Qt::WindowNoState);
+
+ // Make sure we got as many resize events as expected.
+ QCOMPARE(windowResizeEventSpy.count(), expectedWindowResizeEvents);
+ QCOMPARE(widgetResizeEventSpy.count(), expectedWidgetResizeEvents);
+}
+
+#if defined(Q_WS_MAC)
+void tst_QMdiSubWindow::defaultSizeGrip()
+{
+ if (!qApp->style()->inherits("QMacStyle"))
+ return;
+ QMdiArea mdiArea;
+ mdiArea.show();
+
+ // QSizeGrip on windows with decoration.
+ QMdiSubWindow *windowWithDecoration = mdiArea.addSubWindow(new QWidget);
+ windowWithDecoration->show();
+ QVERIFY(qFindChild<QSizeGrip *>(windowWithDecoration));
+
+ // ...but not on windows without decoration (Qt::FramelessWindowHint).
+ QMdiSubWindow *windowWithoutDecoration = mdiArea.addSubWindow(new QWidget, Qt::FramelessWindowHint);
+ windowWithoutDecoration->show();
+ QVERIFY(!qFindChild<QSizeGrip *>(windowWithoutDecoration));
+}
+#endif
+
+void tst_QMdiSubWindow::hideAndShow()
+{
+ // Create a QTabWidget with two tabs; QMdiArea and QTextEdit.
+ QTabWidget *tabWidget = new QTabWidget;
+ QMdiArea *mdiArea = new QMdiArea;
+ tabWidget->addTab(mdiArea, QLatin1String("QMdiArea"));
+ tabWidget->addTab(new QTextEdit, QLatin1String("Dummy"));
+
+ // Set the tab widget as the central widget in QMainWindow.
+ QMainWindow mainWindow;
+ mainWindow.setGeometry(0, 0, 640, 480);
+ QMenuBar *menuBar = mainWindow.menuBar();
+ mainWindow.setCentralWidget(tabWidget);
+ mainWindow.show();
+#ifdef Q_WS_X11
+ qt_x11_wait_for_window_manager(&mainWindow);
+#endif
+
+ QVERIFY(!menuBar->cornerWidget(Qt::TopRightCorner));
+ QMdiSubWindow *subWindow = mdiArea->addSubWindow(new QTextEdit);
+ subWindow->showMaximized();
+#if !defined (Q_WS_MAC) && !defined (Q_OS_WINCE)
+ QVERIFY(menuBar->cornerWidget(Qt::TopRightCorner));
+ QCOMPARE(menuBar->cornerWidget(Qt::TopRightCorner), subWindow->maximizedButtonsWidget());
+#endif
+
+ // Hide QMdiArea.
+ tabWidget->setCurrentIndex(1);
+
+ QVERIFY(!menuBar->cornerWidget(Qt::TopRightCorner));
+ QVERIFY(!subWindow->maximizedButtonsWidget());
+ QVERIFY(!subWindow->maximizedSystemMenuIconWidget());
+
+ // Show QMdiArea.
+ tabWidget->setCurrentIndex(0);
+
+#if !defined (Q_WS_MAC) && !defined (Q_OS_WINCE)
+ QVERIFY(menuBar->cornerWidget(Qt::TopRightCorner));
+ QVERIFY(subWindow->maximizedButtonsWidget());
+ QVERIFY(subWindow->maximizedSystemMenuIconWidget());
+ QCOMPARE(menuBar->cornerWidget(Qt::TopRightCorner), subWindow->maximizedButtonsWidget());
+#endif
+
+ // Hide QMdiArea.
+ tabWidget->setCurrentIndex(1);
+
+ // Add few more windows.
+ for (int i = 0; i < 5; ++i)
+ mdiArea->addSubWindow(new QTextEdit);
+
+ // Show QMdiArea.
+ tabWidget->setCurrentIndex(0);
+ qApp->processEvents();
+
+ subWindow = mdiArea->subWindowList().back();
+ QVERIFY(subWindow);
+ QCOMPARE(mdiArea->activeSubWindow(), subWindow);
+
+#if !defined (Q_WS_MAC) && !defined (Q_OS_WINCE)
+ QVERIFY(menuBar->cornerWidget(Qt::TopRightCorner));
+ QVERIFY(subWindow->maximizedButtonsWidget());
+ QVERIFY(subWindow->maximizedSystemMenuIconWidget());
+ QCOMPARE(menuBar->cornerWidget(Qt::TopRightCorner), subWindow->maximizedButtonsWidget());
+#endif
+
+ subWindow->showNormal();
+ QVERIFY(!menuBar->cornerWidget(Qt::TopRightCorner));
+
+ // Check that newly added windows got right sizes.
+ foreach (QMdiSubWindow *window, mdiArea->subWindowList())
+ QCOMPARE(window->size(), window->sizeHint());
+
+ subWindow->showMaximized();
+#ifndef Q_WS_MAC
+ QCOMPARE(menuBar->cornerWidget(Qt::TopRightCorner), subWindow->maximizedButtonsWidget());
+#endif
+
+ subWindow->hide();
+ QVERIFY(!subWindow->maximizedButtonsWidget());
+ QVERIFY(!subWindow->maximizedSystemMenuIconWidget());
+ QVERIFY(!menuBar->cornerWidget(Qt::TopRightCorner));
+
+ subWindow->show();
+#if !defined (Q_WS_MAC) && !defined (Q_OS_WINCE)
+ QVERIFY(subWindow->maximizedButtonsWidget());
+ QVERIFY(subWindow->maximizedSystemMenuIconWidget());
+ QCOMPARE(menuBar->cornerWidget(Qt::TopRightCorner), subWindow->maximizedButtonsWidget());
+#endif
+
+ // Hide QMainWindow.
+ mainWindow.hide();
+ QVERIFY(!subWindow->maximizedButtonsWidget());
+ QVERIFY(!subWindow->maximizedSystemMenuIconWidget());
+ QVERIFY(!menuBar->cornerWidget(Qt::TopRightCorner));
+
+ // Show QMainWindow.
+ mainWindow.show();
+#if !defined (Q_WS_MAC) && !defined (Q_OS_WINCE)
+ QVERIFY(subWindow->maximizedButtonsWidget());
+ QVERIFY(subWindow->maximizedSystemMenuIconWidget());
+ QCOMPARE(menuBar->cornerWidget(Qt::TopRightCorner), subWindow->maximizedButtonsWidget());
+#endif
+}
+
+void tst_QMdiSubWindow::keepWindowMaximizedState()
+{
+ QMdiArea mdiArea;
+ QMdiSubWindow *subWindow = mdiArea.addSubWindow(new QTextEdit);
+ mdiArea.show();
+#ifdef Q_WS_X11
+ qt_x11_wait_for_window_manager(&mdiArea);
+#endif
+
+ subWindow->showMaximized();
+ QVERIFY(subWindow->isMaximized());
+
+ // move
+ const QPoint newPosition = subWindow->pos() + QPoint(10, 10);
+ subWindow->move(newPosition);
+ QCOMPARE(subWindow->pos(), newPosition);
+ QVERIFY(subWindow->isMaximized());
+
+ // resize
+ const QSize newSize = subWindow->size() - QSize(10, 10);
+ subWindow->resize(newSize);
+ QCOMPARE(subWindow->size(), newSize);
+ QVERIFY(subWindow->isMaximized());
+
+ // setGeometry
+ const QRect newGeometry = QRect(newPosition - QPoint(10, 10), newSize + QSize(10, 10));
+ subWindow->setGeometry(newGeometry);
+ QCOMPARE(subWindow->geometry(), newGeometry);
+ QVERIFY(subWindow->isMaximized());
+
+ subWindow->showNormal();
+
+ // Verify that we don't force Qt::WindowMaximized.
+ QVERIFY(!subWindow->isMaximized());
+ subWindow->setGeometry(QRect(newPosition, newSize));
+ QCOMPARE(subWindow->geometry(), QRect(newPosition, newSize));
+ QVERIFY(!subWindow->isMaximized());
+}
+
+void tst_QMdiSubWindow::explicitlyHiddenWidget()
+{
+ QMdiArea mdiArea;
+ QTextEdit *textEdit = new QTextEdit;
+ textEdit->hide();
+ QMdiSubWindow *subWindow = mdiArea.addSubWindow(textEdit);
+ mdiArea.show();
+#ifdef Q_WS_X11
+ qt_x11_wait_for_window_manager(&mdiArea);
+#endif
+
+ QVERIFY(subWindow->isVisible());
+ QVERIFY(!textEdit->isVisible());
+
+ textEdit->show();
+ QVERIFY(textEdit->isVisible());
+
+ // normal -> minimized
+ subWindow->showMinimized();
+ QVERIFY(subWindow->isVisible());
+ QVERIFY(!textEdit->isVisible());
+
+ // minimized -> normal
+ subWindow->showNormal();
+ QVERIFY(subWindow->isVisible());
+ QVERIFY(textEdit->isVisible());
+
+ // minimized -> maximized
+ subWindow->showMinimized();
+ subWindow->showMaximized();
+ QVERIFY(subWindow->isVisible());
+ QVERIFY(textEdit->isVisible());
+
+ textEdit->hide();
+
+ // maximized -> normal
+ subWindow->showNormal();
+ QVERIFY(subWindow->isVisible());
+ QVERIFY(!textEdit->isVisible());
+
+ textEdit->show();
+
+ subWindow->showMinimized();
+ subWindow->setWidget(0);
+ delete textEdit;
+ textEdit = new QTextEdit;
+ textEdit->hide();
+ subWindow->setWidget(textEdit);
+ subWindow->showNormal();
+ QVERIFY(subWindow->isVisible());
+ QVERIFY(!textEdit->isVisible());
+}
+
+void tst_QMdiSubWindow::resizeTimer()
+{
+ QMdiArea mdiArea;
+ QMdiSubWindow *subWindow = mdiArea.addSubWindow(new QWidget);
+ mdiArea.show();
+ QTest::qWaitForWindowShown(&mdiArea);
+ QTest::qWait(300);
+
+
+ EventSpy timerEventSpy(subWindow, QEvent::Timer);
+ QCOMPARE(timerEventSpy.count(), 0);
+
+ for (int i = 0; i < 20; ++i) {
+ subWindow->resize(subWindow->size() + QSize(2, 2));
+ qApp->processEvents();
+ }
+
+ QTest::qWait(500); // Wait for timer events to occur.
+
+ QTRY_VERIFY(timerEventSpy.count() > 0);
+}
+
+void tst_QMdiSubWindow::fixedMinMaxSize()
+{
+ QMdiArea mdiArea;
+ mdiArea.setGeometry(0, 0, 640, 480);
+ mdiArea.show();
+#ifdef Q_WS_X11
+ qt_x11_wait_for_window_manager(&mdiArea);
+#endif
+
+ const QSize minimumSize = QSize(250, 150);
+ const QSize maximumSize = QSize(300, 200);
+
+ // Add the sub window to QMdiArea and set min/max size.
+ QMdiSubWindow *subWindow = new QMdiSubWindow;
+ subWindow->setMinimumSize(minimumSize);
+ QCOMPARE(subWindow->minimumSize(), minimumSize);
+ subWindow->setMaximumSize(maximumSize);
+ QCOMPARE(subWindow->maximumSize(), maximumSize);
+ mdiArea.addSubWindow(subWindow);
+ subWindow->show();
+ QCOMPARE(subWindow->size(), minimumSize);
+
+ // Calculate the size of a minimized sub window.
+ QStyleOptionTitleBar options;
+ options.initFrom(subWindow);
+ int minimizedHeight = subWindow->style()->pixelMetric(QStyle::PM_TitleBarHeight, &options);
+#if defined(Q_WS_MAC) && !defined(QT_NO_STYLE_MAC)
+ // ### Remove this after mac style has been fixed
+ if (qobject_cast<QMacStyle *>(subWindow->style()))
+ minimizedHeight -= 4;
+#endif
+ if (!subWindow->style()->styleHint(QStyle::SH_TitleBar_NoBorder, &options, subWindow))
+ minimizedHeight += 8;
+ int minimizedWidth = subWindow->style()->pixelMetric(QStyle::PM_MDIMinimizedWidth, &options);
+ const QSize minimizedSize = QSize(minimizedWidth, minimizedHeight);
+
+ // Even though the sub window has a minimum size set, it should be possible
+ // to minimize the window.
+ subWindow->showMinimized();
+ QVERIFY(subWindow->isMinimized());
+ QCOMPARE(subWindow->size(), minimizedSize);
+ QCOMPARE(subWindow->minimumSize(), minimizedSize);
+
+ // Restore minimum size.
+ subWindow->showNormal();
+ QVERIFY(!subWindow->isMinimized());
+ QCOMPARE(subWindow->size(), minimumSize);
+ QCOMPARE(subWindow->minimumSize(), minimumSize);
+
+ // Well, the logic here is of course broken (calling showMaximized on a window with
+ // maximum size set), but we should handle it :)
+ subWindow->showMaximized();
+ QVERIFY(subWindow->isMaximized());
+ QCOMPARE(subWindow->size(), maximumSize);
+
+ subWindow->showNormal();
+ QVERIFY(!subWindow->isMaximized());
+ QCOMPARE(subWindow->size(), minimumSize);
+}
+
+#if !defined( Q_WS_MAC) && !defined( Q_OS_WINCE)
+void tst_QMdiSubWindow::replaceMenuBarWhileMaximized()
+{
+
+ QMainWindow mainWindow;
+
+ QMdiArea *mdiArea = new QMdiArea;
+ QMdiSubWindow *subWindow = mdiArea->addSubWindow(new QTextEdit);
+ subWindow->showMaximized();
+
+ mainWindow.setCentralWidget(mdiArea);
+ QMenuBar *menuBar = mainWindow.menuBar();
+ mainWindow.show();
+#ifdef Q_WS_X11
+ qt_x11_wait_for_window_manager(&mainWindow);
+#endif
+
+ qApp->processEvents();
+
+ QVERIFY(subWindow->maximizedButtonsWidget());
+ QVERIFY(subWindow->maximizedSystemMenuIconWidget());
+ QCOMPARE(menuBar->cornerWidget(Qt::TopLeftCorner), subWindow->maximizedSystemMenuIconWidget());
+ QCOMPARE(menuBar->cornerWidget(Qt::TopRightCorner), subWindow->maximizedButtonsWidget());
+
+ // Replace.
+ mainWindow.setMenuBar(new QMenuBar);
+ menuBar = mainWindow.menuBar();
+ qApp->processEvents();
+
+ QVERIFY(subWindow->maximizedButtonsWidget());
+ QVERIFY(subWindow->maximizedSystemMenuIconWidget());
+ QCOMPARE(menuBar->cornerWidget(Qt::TopLeftCorner), subWindow->maximizedSystemMenuIconWidget());
+ QCOMPARE(menuBar->cornerWidget(Qt::TopRightCorner), subWindow->maximizedButtonsWidget());
+
+ subWindow->showNormal();
+ QVERIFY(!subWindow->maximizedButtonsWidget());
+ QVERIFY(!subWindow->maximizedSystemMenuIconWidget());
+ QVERIFY(!menuBar->cornerWidget(Qt::TopLeftCorner));
+ QVERIFY(!menuBar->cornerWidget(Qt::TopRightCorner));
+
+ // Delete and replace.
+ subWindow->showMaximized();
+ delete menuBar;
+ mainWindow.setMenuBar(new QMenuBar);
+ qApp->processEvents();
+
+ QVERIFY(!subWindow->maximizedButtonsWidget());
+ QVERIFY(!subWindow->maximizedSystemMenuIconWidget());
+
+ subWindow->showNormal();
+ QVERIFY(!subWindow->maximizedButtonsWidget());
+ QVERIFY(!subWindow->maximizedSystemMenuIconWidget());
+
+ // Delete.
+ subWindow->showMaximized();
+ mainWindow.setMenuBar(0);
+ qApp->processEvents();
+ QVERIFY(!mainWindow.menuWidget());
+
+ QVERIFY(!subWindow->maximizedButtonsWidget());
+ QVERIFY(!subWindow->maximizedSystemMenuIconWidget());
+
+ subWindow->showNormal();
+ QVERIFY(!subWindow->maximizedButtonsWidget());
+ QVERIFY(!subWindow->maximizedSystemMenuIconWidget());
+}
+
+void tst_QMdiSubWindow::closeOnDoubleClick()
+{
+ QMdiArea mdiArea;
+ QPointer<QMdiSubWindow> subWindow = mdiArea.addSubWindow(new QWidget);
+ mdiArea.show();
+#ifdef Q_WS_X11
+ qt_x11_wait_for_window_manager(&mdiArea);
+#endif
+
+ subWindow->showSystemMenu();
+ QTest::qWait(200);
+
+ QPointer<QMenu> systemMenu = subWindow->systemMenu();
+ QVERIFY(systemMenu);
+ QVERIFY(systemMenu->isVisible());
+
+ sendMouseDoubleClick(systemMenu, QPoint(10, 10));
+ if (qApp->activePopupWidget() == static_cast<QWidget *>(systemMenu))
+ systemMenu->hide();
+ qApp->processEvents();
+ QVERIFY(!subWindow || !subWindow->isVisible());
+ QVERIFY(!systemMenu || !systemMenu->isVisible());
+}
+#endif
+
+void tst_QMdiSubWindow::setFont()
+{
+ QMdiArea mdiArea;
+ QMdiSubWindow *subWindow = mdiArea.addSubWindow(new QPushButton(QLatin1String("test")));
+ subWindow->resize(300, 100);
+ subWindow->setWindowTitle(QLatin1String("Window title"));
+ mdiArea.show();
+#ifdef Q_WS_X11
+ qt_x11_wait_for_window_manager(&mdiArea);
+#endif
+
+ const QFont originalFont = QApplication::font("QWorkspaceTitleBar");
+ QStyleOptionTitleBar opt;
+ opt.initFrom(subWindow);
+ const int titleBarHeight = subWindow->style()->pixelMetric(QStyle::PM_TitleBarHeight, &opt);
+ const QRect titleBarRect = QRect(0, 0, subWindow->width(), titleBarHeight);
+ const QImage originalTitleBar = QPixmap::grabWidget(subWindow, titleBarRect).toImage();
+
+ QFont newFont(QLatin1String("Helvetica"), 16);
+ newFont.setBold(true);
+ subWindow->setFont(newFont);
+ qApp->processEvents();
+ const QFont &swFont = subWindow->font();
+ QCOMPARE(swFont.family(), newFont.family());
+ QCOMPARE(swFont.pointSize(), newFont.pointSize());
+ QCOMPARE(swFont.weight(), newFont.weight());
+ QImage newTitleBar = QPixmap::grabWidget(subWindow, titleBarRect).toImage();
+ QVERIFY(newTitleBar != originalTitleBar);
+
+ subWindow->setFont(originalFont);
+ qApp->processEvents();
+ QCOMPARE(subWindow->font(), originalFont);
+ newTitleBar = QPixmap::grabWidget(subWindow, titleBarRect).toImage();
+ QCOMPARE(newTitleBar, originalTitleBar);
+}
+
+void tst_QMdiSubWindow::task_188849()
+{
+ QMainWindow mainWindow;
+ // Sets a regular QWidget (and NOT a QMenuBar) as the menu bar.
+ mainWindow.setMenuWidget(new QWidget);
+
+ QMdiArea *mdiArea = new QMdiArea;
+ QMdiSubWindow *subWindow = mdiArea->addSubWindow(new QWidget);
+ mainWindow.setCentralWidget(mdiArea);
+ mainWindow.show();
+#if defined(Q_WS_X11)
+ qt_x11_wait_for_window_manager(&mainWindow);
+#endif
+
+ // QMdiSubWindow will now try to show its buttons in the menu bar.
+ // Without checking that the menu bar is actually a QMenuBar
+ // and not a regular QWidget, this will crash.
+ subWindow->showMaximized();
+}
+
+void tst_QMdiSubWindow::mdiArea()
+{
+ QMdiArea mdiArea;
+ QMdiSubWindow *subWindow = mdiArea.addSubWindow(new QWidget);
+ QCOMPARE(subWindow->mdiArea(), &mdiArea);
+
+ subWindow->setParent(0);
+ QVERIFY(!subWindow->mdiArea());
+
+ // Child of the area's corner widget.
+ mdiArea.setCornerWidget(new QWidget);
+ subWindow->setParent(mdiArea.cornerWidget());
+ QVERIFY(!subWindow->mdiArea());
+
+ // Nested mdi area.
+ QMdiArea *nestedArea = new QMdiArea;
+ mdiArea.addSubWindow(nestedArea);
+ nestedArea->addSubWindow(subWindow);
+ QCOMPARE(subWindow->mdiArea(), nestedArea);
+ nestedArea->setViewport(new QWidget);
+ QCOMPARE(subWindow->mdiArea(), nestedArea);
+}
+
+void tst_QMdiSubWindow::task_182852()
+{
+#if !defined(Q_WS_MAC) && !defined(Q_OS_WINCE)
+
+ QMdiArea *workspace = new QMdiArea;
+ QMainWindow mainWindow;
+ mainWindow.setCentralWidget(workspace);
+ mainWindow.show();
+ mainWindow.menuBar()->setVisible(true);
+ qApp->setActiveWindow(&mainWindow);
+
+ QString originalWindowTitle = QString::fromLatin1("MainWindow - [foo]");
+ mainWindow.setWindowTitle(originalWindowTitle);
+
+ QMdiSubWindow *window = new QMdiSubWindow;
+
+ QMdiArea *nestedWorkspace = new QMdiArea; // :-)
+ window->setWidget(nestedWorkspace);
+ window->widget()->setWindowTitle(QString::fromLatin1("Window"));
+
+ workspace->addSubWindow(window);
+
+ window->showMaximized();
+ qApp->processEvents();
+ QVERIFY(window->isMaximized());
+
+ QCOMPARE(mainWindow.windowTitle(), QString::fromLatin1("%1 - [%2]")
+ .arg(originalWindowTitle, window->widget()->windowTitle()));
+
+ window->showNormal();
+ QCOMPARE(mainWindow.windowTitle(), originalWindowTitle);
+
+ window->widget()->setWindowTitle(QString::fromLatin1("foo"));
+ window->showMaximized();
+
+ QCOMPARE(mainWindow.windowTitle(), originalWindowTitle);
+
+ window->showNormal();
+ QCOMPARE(mainWindow.windowTitle(), originalWindowTitle);
+
+ window->widget()->setWindowTitle(QString::fromLatin1("bar"));
+ window->showMaximized();
+
+ QCOMPARE(mainWindow.windowTitle(), QString::fromLatin1("%1 - [%2]")
+ .arg(originalWindowTitle, window->widget()->windowTitle()));
+
+
+#endif
+}
+
+void tst_QMdiSubWindow::task_233197()
+{
+ QMainWindow *mainWindow = new QMainWindow;
+ mainWindow->setAttribute(Qt::WA_DeleteOnClose);
+ mainWindow->resize(500, 200);
+ mainWindow->show();
+
+ QMdiArea *mdiArea = new QMdiArea(mainWindow);
+ mdiArea->setOption(QMdiArea::DontMaximizeSubWindowOnActivation, true);
+ mainWindow->setCentralWidget(mdiArea);
+
+ QMdiSubWindow *subWindow1 = new QMdiSubWindow();
+ mdiArea->addSubWindow(subWindow1);
+ subWindow1->showMaximized();
+
+ QMdiSubWindow *subWindow2 = new QMdiSubWindow();
+ mdiArea->addSubWindow(subWindow2);
+ subWindow2->showMaximized();
+
+ QMdiSubWindow *subWindow3 = new QMdiSubWindow();
+ mdiArea->addSubWindow(subWindow3);
+ subWindow3->showMaximized();
+
+ QMenuBar *menuBar = mainWindow->menuBar(); // force creation of a menubar
+ Q_UNUSED(menuBar);
+
+ QPushButton *focus1 = new QPushButton(QLatin1String("Focus 1"), mainWindow);
+ QObject::connect(focus1, SIGNAL(clicked()), subWindow1, SLOT(setFocus()));
+ focus1->move(5, 30);
+ focus1->show();
+
+ QPushButton *focus2 = new QPushButton(QLatin1String("Focus 2"), mainWindow);
+ QObject::connect(focus2, SIGNAL(clicked()), subWindow2, SLOT(setFocus()));
+ focus2->move(5, 60);
+ focus2->show();
+
+ QPushButton *close = new QPushButton(QLatin1String("Close"), mainWindow);
+ QObject::connect(close, SIGNAL(clicked()), mainWindow, SLOT(close()));
+ close->move(5, 90);
+ close->show();
+
+ QTest::qWait(200);
+
+ sendMousePress(focus2, QPoint());
+ sendMouseRelease(focus2, QPoint());
+
+ sendMousePress(focus1, QPoint());
+ sendMouseRelease(focus1, QPoint());
+
+ sendMousePress(focus2, QPoint());
+ sendMouseRelease(focus2, QPoint());
+
+ sendMousePress(close, QPoint());
+ sendMouseRelease(close, QPoint());
+
+ QTest::qWait(200);
+}
+
+void tst_QMdiSubWindow::task_226929()
+{
+ QMdiArea mdiArea;
+ mdiArea.show();
+#ifdef Q_WS_X11
+ qt_x11_wait_for_window_manager(&mdiArea);
+#endif
+
+ QMdiSubWindow *sub1 = mdiArea.addSubWindow(new QTextEdit);
+ sub1->showMinimized();
+
+ QMdiSubWindow *sub2 = mdiArea.addSubWindow(new QTextEdit);
+ sub2->showMaximized();
+
+ QTest::qWait(100);
+
+ // Do not assert.
+ // This window will now be activated and automatically maximized
+ // (if not QMdiArea::DontMaximizeSubWindowOnActionvation is set).
+ sub1->showNormal();
+ QVERIFY(sub1->isMaximized());
+}
+
+QTEST_MAIN(tst_QMdiSubWindow)
+#include "tst_qmdisubwindow.moc"
+
diff --git a/tests/auto/widgets/widgets/qmenu/.gitignore b/tests/auto/widgets/widgets/qmenu/.gitignore
new file mode 100644
index 0000000000..775539a653
--- /dev/null
+++ b/tests/auto/widgets/widgets/qmenu/.gitignore
@@ -0,0 +1 @@
+tst_qmenu
diff --git a/tests/auto/widgets/widgets/qmenu/qmenu.pro b/tests/auto/widgets/widgets/qmenu/qmenu.pro
new file mode 100644
index 0000000000..1fc1a7ff9d
--- /dev/null
+++ b/tests/auto/widgets/widgets/qmenu/qmenu.pro
@@ -0,0 +1,5 @@
+load(qttest_p4)
+QT += widgets
+SOURCES += tst_qmenu.cpp
+
+qpa:contains(QT_CONFIG,xcb):CONFIG+=insignificant_test # QTBUG-21100, unstably fails
diff --git a/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp b/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp
new file mode 100644
index 0000000000..d115da865b
--- /dev/null
+++ b/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp
@@ -0,0 +1,943 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtTest/QtTest>
+#include <qapplication.h>
+#include <QPushButton>
+#include <QMainWindow>
+#include <QMenuBar>
+#include <QToolBar>
+#include <QToolButton>
+#include <QStatusBar>
+#include <QListWidget>
+#include <QWidgetAction>
+#include <QDesktopWidget>
+#include <qdialog.h>
+
+#include <qmenu.h>
+#include <qstyle.h>
+#include <qdebug.h>
+
+//TESTED_CLASS=
+//TESTED_FILES=
+
+class tst_QMenu : public QObject
+{
+ Q_OBJECT
+
+public:
+ tst_QMenu();
+
+public slots:
+ void initTestCase();
+ void cleanupTestCase();
+ void init();
+private slots:
+ void getSetCheck();
+ void addActionsAndClear();
+
+ void keyboardNavigation_data();
+ void keyboardNavigation();
+ void focus();
+ void overrideMenuAction();
+ void statusTip();
+ void widgetActionFocus();
+#ifndef Q_OS_WINCE_WM
+ void mouseActivation();
+#endif
+ void tearOff();
+ void layoutDirection();
+
+ void task208001_stylesheet();
+ void activeSubMenuPosition();
+ void task242454_sizeHint();
+ void task176201_clear();
+ void task250673_activeMultiColumnSubMenuPosition();
+ void task256918_setFont();
+ void menuSizeHint();
+#ifndef Q_OS_WINCE_WM
+ void task258920_mouseBorder();
+#endif
+ void setFixedWidth();
+ void deleteActionInTriggered();
+ void pushButtonPopulateOnAboutToShow();
+ void QTBUG7907_submenus_autoselect();
+ void QTBUG7411_submenus_activate();
+ void QTBUG_10735_crashWithDialog();
+protected slots:
+ void onActivated(QAction*);
+ void onHighlighted(QAction*);
+ void onStatusMessageChanged(const QString &);
+ void onStatusTipTimer();
+ void deleteAction(QAction *a) { delete a; }
+ void populateMenu();
+private:
+ void createActions();
+ QMenu *menus[2], *lastMenu;
+ enum { num_builtins = 10 };
+ QAction *activated, *highlighted, *builtins[num_builtins];
+ QString statustip;
+};
+
+// Testing get/set functions
+void tst_QMenu::getSetCheck()
+{
+ QMenu obj1;
+ // QAction * QMenu::defaultAction()
+ // void QMenu::setDefaultAction(QAction *)
+ QAction *var1 = new QAction(0);
+ obj1.setDefaultAction(var1);
+ QCOMPARE(var1, obj1.defaultAction());
+ obj1.setDefaultAction((QAction *)0);
+ QCOMPARE((QAction *)0, obj1.defaultAction());
+ delete var1;
+
+ // QAction * QMenu::activeAction()
+ // void QMenu::setActiveAction(QAction *)
+ QAction *var2 = new QAction(0);
+ obj1.setActiveAction(var2);
+ QCOMPARE(var2, obj1.activeAction());
+ obj1.setActiveAction((QAction *)0);
+ QCOMPARE((QAction *)0, obj1.activeAction());
+ delete var2;
+}
+
+tst_QMenu::tst_QMenu()
+{
+ QApplication::setEffectEnabled(Qt::UI_AnimateMenu, false);
+}
+
+void tst_QMenu::initTestCase()
+{
+ for (int i = 0; i < num_builtins; i++)
+ builtins[i] = 0;
+ for (int i = 0; i < 2; i++) {
+ menus[i] = new QMenu;
+ QObject::connect(menus[i], SIGNAL(triggered(QAction*)), this, SLOT(onActivated(QAction*)));
+ QObject::connect(menus[i], SIGNAL(hovered(QAction*)), this, SLOT(onHighlighted(QAction*)));
+ }
+}
+
+void tst_QMenu::cleanupTestCase()
+{
+ for (int i = 0; i < 2; i++)
+ menus[i]->clear();
+ for (int i = 0; i < num_builtins; i++) {
+ bool menuAction = false;
+ for (int j = 0; j < 2; ++j)
+ if (menus[j]->menuAction() == builtins[i])
+ menuAction = true;
+ if (!menuAction)
+ delete builtins[i];
+ }
+ delete menus[0];
+ delete menus[1];
+}
+
+void tst_QMenu::init()
+{
+ activated = highlighted = 0;
+ lastMenu = 0;
+}
+
+void tst_QMenu::createActions()
+{
+ if (!builtins[0])
+ builtins[0] = new QAction("New", 0);
+ menus[0]->addAction(builtins[0]);
+
+ if (!builtins[1]) {
+ builtins[1] = new QAction(0);
+ builtins[1]->setSeparator(true);
+ }
+ menus[0]->addAction(builtins[1]);
+
+ if (!builtins[2]) {
+ builtins[2] = menus[1]->menuAction();
+ builtins[2]->setText("&Open..");
+ builtins[8] = new QAction("Close", 0);
+ menus[1]->addAction(builtins[8]);
+ builtins[9] = new QAction("Quit", 0);
+ menus[1]->addAction(builtins[9]);
+ }
+ menus[0]->addAction(builtins[2]);
+
+ if (!builtins[3])
+ builtins[3] = new QAction("Open &as..", 0);
+ menus[0]->addAction(builtins[3]);
+
+ if (!builtins[4]) {
+ builtins[4] = new QAction("Save", 0);
+ builtins[4]->setEnabled(false);
+ }
+ menus[0]->addAction(builtins[4]);
+
+ if (!builtins[5])
+ builtins[5] = new QAction("Sa&ve as..", 0);
+ menus[0]->addAction(builtins[5]);
+
+ if (!builtins[6]) {
+ builtins[6] = new QAction(0);
+ builtins[6]->setSeparator(true);
+ }
+ menus[0]->addAction(builtins[6]);
+
+ if (!builtins[7])
+ builtins[7] = new QAction("Prin&t", 0);
+ menus[0]->addAction(builtins[7]);
+}
+
+void tst_QMenu::onHighlighted(QAction *action)
+{
+ highlighted = action;
+ lastMenu = qobject_cast<QMenu*>(sender());
+}
+
+void tst_QMenu::onActivated(QAction *action)
+{
+ activated = action;
+ lastMenu = qobject_cast<QMenu*>(sender());
+}
+
+void tst_QMenu::onStatusMessageChanged(const QString &s)
+{
+ statustip=s;
+}
+
+void tst_QMenu::populateMenu()
+{
+ //just adds 3 dummy actions and a separator.
+ lastMenu->addAction("Foo");
+ lastMenu->addAction("Bar");
+ lastMenu->addAction("FooBar");
+ lastMenu->addSeparator();
+}
+
+void tst_QMenu::addActionsAndClear()
+{
+#ifdef QT_SOFTKEYS_ENABLED
+ // Softkeys add extra "Select" and "Back" actions to menu by default.
+ // Two first actions will be Select and Back when softkeys are enabled
+ int numSoftkeyActions = 2;
+#else
+ int numSoftkeyActions = 0;
+#endif
+
+ QCOMPARE(menus[0]->actions().count(), 0 + numSoftkeyActions);
+ createActions();
+ QCOMPARE(menus[0]->actions().count(), 8 + numSoftkeyActions);
+ menus[0]->clear();
+ QCOMPARE(menus[0]->actions().count(), 0);
+}
+
+// We have a separate mouseActivation test for Windows mobile.
+#ifndef Q_OS_WINCE_WM
+void tst_QMenu::mouseActivation()
+{
+ QWidget topLevel;
+ QMenu menu(&topLevel);
+ topLevel.show();
+ menu.addAction("Menu Action");
+ menu.show();
+ QTest::mouseClick(&menu, Qt::LeftButton, 0, menu.rect().center(), 300);
+ QVERIFY(!menu.isVisible());
+
+ //context menus can always be accessed with right click except on windows
+ menu.show();
+ QTest::mouseClick(&menu, Qt::RightButton, 0, menu.rect().center(), 300);
+ QVERIFY(!menu.isVisible());
+
+#ifdef Q_OS_WIN
+ //on windows normal mainwindow menus Can only be accessed with left mouse button
+ QMenuBar menubar;
+ QMenu submenu("Menu");
+ submenu.addAction("action");
+ QAction *action = menubar.addMenu(&submenu);
+ menubar.show();
+
+ QTest::mouseClick(&menubar, Qt::LeftButton, 0, menubar.actionGeometry(action).center(), 300);
+ QVERIFY(submenu.isVisible());
+ QTest::mouseClick(&submenu, Qt::LeftButton, 0, QPoint(5, 5), 300);
+ QVERIFY(!submenu.isVisible());
+
+ QTest::mouseClick(&menubar, Qt::LeftButton, 0, menubar.actionGeometry(action).center(), 300);
+ QVERIFY(submenu.isVisible());
+ QTest::mouseClick(&submenu, Qt::RightButton, 0, QPoint(5, 5), 300);
+ QVERIFY(submenu.isVisible());
+#endif
+}
+#endif
+
+void tst_QMenu::keyboardNavigation_data()
+{
+ QTest::addColumn<int>("key");
+ QTest::addColumn<int>("expected_action");
+ QTest::addColumn<int>("expected_menu");
+ QTest::addColumn<bool>("init");
+ QTest::addColumn<bool>("expected_activated");
+ QTest::addColumn<bool>("expected_highlighted");
+
+ //test up and down (order is important here)
+ QTest::newRow("data0") << int(Qt::Key_Down) << 0 << 0 << true << false << true;
+ QTest::newRow("data1") << int(Qt::Key_Down) << 2 << 0 << false << false << true; //skips the separator
+ QTest::newRow("data2") << int(Qt::Key_Down) << 3 << 0 << false << false << true;
+
+ if (QApplication::style()->styleHint(QStyle::SH_Menu_AllowActiveAndDisabled))
+ QTest::newRow("data3_noMac") << int(Qt::Key_Down) << 4 << 0 << false << false << true;
+ else
+ QTest::newRow("data3_Mac") << int(Qt::Key_Down) << 5 << 0 << false << false << true;
+ QTest::newRow("data4") << int(Qt::Key_Up) << 3 << 0 << false << false << true;
+ QTest::newRow("data5") << int(Qt::Key_Up) << 2 << 0 << false << false << true;
+ QTest::newRow("data6") << int(Qt::Key_Right) << 8 << 1 << false << false << true;
+ QTest::newRow("data7") << int(Qt::Key_Down) << 9 << 1 << false << false << true;
+ QTest::newRow("data8") << int(Qt::Key_Escape) << 2 << 0 << false << false << false;
+ QTest::newRow("data9") << int(Qt::Key_Down) << 3 << 0 << false << false<< true;
+ QTest::newRow("data10") << int(Qt::Key_Return) << 3 << 0 << false << true << false;
+
+ //test shortcuts
+#if 0
+ QTest::newRow("shortcut0") << (Qt::ALT | Qt::Key_A) << 2 << 0 << true << true << false;
+#endif
+}
+
+void tst_QMenu::keyboardNavigation()
+{
+ QFETCH(int, key);
+ QFETCH(int, expected_action);
+ QFETCH(int, expected_menu);
+ QFETCH(bool, init);
+ QFETCH(bool, expected_activated);
+ QFETCH(bool, expected_highlighted);
+
+ if (init) {
+ lastMenu = menus[0];
+ lastMenu->clear();
+ createActions();
+ lastMenu->popup(QPoint(0, 0));
+ }
+
+ QTest::keyClick(lastMenu, (Qt::Key)key);
+ if (expected_activated) {
+ QCOMPARE(activated, builtins[expected_action]);
+ QCOMPARE(menus[expected_menu]->activeAction(), (QAction *)0);
+ } else {
+ QCOMPARE(menus[expected_menu]->activeAction(), builtins[expected_action]);
+ if (expected_highlighted)
+ QCOMPARE(menus[expected_menu]->activeAction(), highlighted);
+ }
+}
+
+#ifdef Q_WS_MAC
+QT_BEGIN_NAMESPACE
+ extern bool qt_tab_all_widgets; // from qapplication.cpp
+QT_END_NAMESPACE
+#endif
+
+void tst_QMenu::focus()
+{
+ QMenu menu;
+ menu.addAction("One");
+ menu.addAction("Two");
+ menu.addAction("Three");
+
+#ifdef Q_WS_MAC
+ if (!qt_tab_all_widgets)
+ QSKIP("Computer is currently set up to NOT tab to all widgets,"
+ " this test assumes you can tab to all widgets", SkipAll);
+#endif
+
+ QWidget window;
+ QPushButton button("Push me", &window);
+ window.show();
+ qApp->setActiveWindow(&window);
+
+ QVERIFY(button.hasFocus());
+ QCOMPARE(QApplication::focusWidget(), (QWidget *)&button);
+ QCOMPARE(QApplication::activeWindow(), &window);
+ menu.show();
+ QVERIFY(button.hasFocus());
+ QCOMPARE(QApplication::focusWidget(), (QWidget *)&button);
+ QCOMPARE(QApplication::activeWindow(), &window);
+ menu.hide();
+ QVERIFY(button.hasFocus());
+ QCOMPARE(QApplication::focusWidget(), (QWidget *)&button);
+ QCOMPARE(QApplication::activeWindow(), &window);
+}
+
+void tst_QMenu::overrideMenuAction()
+{
+ //test the override menu action by first creating an action to which we set its menu
+ QMainWindow w;
+
+ QAction *aFileMenu = new QAction("&File", &w);
+ w.menuBar()->addAction(aFileMenu);
+
+ QMenu *m = new QMenu(&w);
+ QAction *menuaction = m->menuAction();
+ connect(m, SIGNAL(triggered(QAction*)), SLOT(onActivated(QAction*)));
+ aFileMenu->setMenu(m); //this sets the override menu action for the QMenu
+ QCOMPARE(m->menuAction(), aFileMenu);
+
+ // On Mac and Windows CE, we need to create native key events to test menu
+ // action activation, so skip this part of the test.
+#if !defined(Q_WS_MAC) && !defined(Q_OS_WINCE)
+ QAction *aQuit = new QAction("Quit", &w);
+ aQuit->setShortcut(QKeySequence("Ctrl+X"));
+ m->addAction(aQuit);
+
+ w.show();
+ QTest::qWaitForWindowShown(&w);
+ QApplication::setActiveWindow(&w);
+ w.setFocus();
+ QTRY_VERIFY(w.hasFocus());
+
+ //test of the action inside the menu
+ QTest::keyClick(&w, Qt::Key_X, Qt::ControlModifier);
+ QTRY_COMPARE(activated, aQuit);
+
+ //test if the menu still pops out
+ QTest::keyClick(&w, Qt::Key_F, Qt::AltModifier);
+ QTRY_VERIFY(m->isVisible());
+#endif
+
+ delete aFileMenu;
+
+ //after the deletion of the override menu action,
+ //the menu should have its default menu action back
+ QCOMPARE(m->menuAction(), menuaction);
+}
+
+void tst_QMenu::statusTip()
+{
+ //check that the statustip of actions inserted into the menu are displayed
+ QMainWindow w;
+ connect(w.statusBar(), SIGNAL(messageChanged(const QString &)), SLOT(onStatusMessageChanged(const QString &)));; //creates the status bar
+ QToolBar tb;
+ QAction a("main action", &tb);
+ a.setStatusTip("main action");
+ QMenu m(&tb);
+ QAction subact("sub action", &m);
+ subact.setStatusTip("sub action");
+ m.addAction(&subact);
+ a.setMenu(&m);
+ tb.addAction(&a);
+
+ w.addToolBar(&tb);
+ w.show();
+ QTest::qWaitForWindowShown(&w);
+
+ QRect rect1 = tb.actionGeometry(&a);
+ QToolButton *btn = qobject_cast<QToolButton*>(tb.childAt(rect1.center()));
+
+ QVERIFY(btn != NULL);
+
+ //because showMenu calls QMenu::exec, we need to use a singleshot
+ //to continue the test
+ QTimer::singleShot(200,this, SLOT(onStatusTipTimer()));
+ btn->showMenu();
+ QVERIFY(statustip.isEmpty());
+}
+
+//2nd part of the test
+void tst_QMenu::onStatusTipTimer()
+{
+ QMenu *menu = qobject_cast<QMenu*>(QApplication::activePopupWidget());
+ QVERIFY(menu != 0);
+ QVERIFY(menu->isVisible());
+ QTest::keyClick(menu, Qt::Key_Down);
+
+ //we store the statustip to press escape in any case
+ //otherwise, if the test fails it blocks (never gets out of QMenu::exec
+ const QString st=statustip;
+
+ menu->close(); //goes out of the menu
+
+ QCOMPARE(st, QString("sub action"));
+ QVERIFY(menu->isVisible() == false);
+}
+
+void tst_QMenu::widgetActionFocus()
+{
+ //test if the focus is correctly handled with a QWidgetAction
+ QMenu m;
+ QListWidget *l = new QListWidget(&m);
+ for (int i = 1; i<3 ; i++)
+ l->addItem(QString("item%1").arg(i));
+ QWidgetAction *wa = new QWidgetAction(&m);
+ wa->setDefaultWidget(l);
+ m.addAction(wa);
+ m.setActiveAction(wa);
+ l->setFocus(); //to ensure it has primarily the focus
+ QAction *menuitem1=m.addAction("menuitem1");
+ QAction *menuitem2=m.addAction("menuitem2");
+
+ m.popup(QPoint());
+
+ QVERIFY(m.isVisible());
+ QVERIFY(l->hasFocus());
+ QVERIFY(l->currentItem());
+ QCOMPARE(l->currentItem()->text(), QString("item1"));
+
+ QTest::keyClick(QApplication::focusWidget(), Qt::Key_Down);
+ QVERIFY(l->currentItem());
+ QCOMPARE(l->currentItem()->text(), QString("item2"));
+
+ QTest::keyClick(QApplication::focusWidget(), Qt::Key_Down);
+ QVERIFY(m.hasFocus());
+ QCOMPARE(m.activeAction(), menuitem1);
+
+ QTest::keyClick(QApplication::focusWidget(), Qt::Key_Down);
+ QVERIFY(m.hasFocus());
+ QCOMPARE(m.activeAction(), menuitem2);
+
+ QTest::keyClick(QApplication::focusWidget(), Qt::Key_Up);
+ QVERIFY(m.hasFocus());
+ QCOMPARE(m.activeAction(), menuitem1);
+
+ QTest::keyClick(QApplication::focusWidget(), Qt::Key_Up);
+ QVERIFY(l->hasFocus());
+ QCOMPARE(m.activeAction(), (QAction *)wa);
+}
+
+void tst_QMenu::tearOff()
+{
+ QWidget widget;
+ QMenu *menu = new QMenu(&widget);
+ QVERIFY(!menu->isTearOffEnabled()); //default value
+ menu->setTearOffEnabled(true);
+ menu->addAction("aaa");
+ menu->addAction("bbb");
+ QVERIFY(menu->isTearOffEnabled());
+
+ widget.show();
+ QTest::qWaitForWindowShown(&widget);
+ widget.activateWindow();
+ menu->popup(QPoint(0,0));
+ QTest::qWait(50);
+ QVERIFY(!menu->isTearOffMenuVisible());
+
+ QTest::mouseClick(menu, Qt::LeftButton, 0, QPoint(3, 3), 10);
+ QTest::qWait(100);
+
+ QVERIFY(menu->isTearOffMenuVisible());
+ QPointer<QMenu> torn = 0;
+ foreach (QWidget *w, QApplication::allWidgets()) {
+ if (w->inherits("QTornOffMenu")) {
+ torn = static_cast<QMenu *>(w);
+ break;
+ }
+ }
+ QVERIFY(torn);
+ QVERIFY(torn->isVisible());
+
+ menu->hideTearOffMenu();
+ QVERIFY(!menu->isTearOffMenuVisible());
+ QVERIFY(!torn->isVisible());
+}
+
+void tst_QMenu::layoutDirection()
+{
+ QMainWindow win;
+ win.setLayoutDirection(Qt::RightToLeft);
+
+ QMenu menu(&win);
+ menu.show();
+ QTest::qWaitForWindowShown(&menu);
+ QCOMPARE(menu.layoutDirection(), Qt::RightToLeft);
+ menu.close();
+
+ menu.setParent(0);
+ menu.show();
+ QTest::qWaitForWindowShown(&menu);
+ QCOMPARE(menu.layoutDirection(), QApplication::layoutDirection());
+ menu.close();
+
+ //now the menubar
+ QAction *action = win.menuBar()->addMenu(&menu);
+ win.menuBar()->setActiveAction(action);
+ QTest::qWaitForWindowShown(&menu);
+ QCOMPARE(menu.layoutDirection(), Qt::RightToLeft);
+}
+
+void tst_QMenu::task208001_stylesheet()
+{
+ //test if it crash
+ QMainWindow main;
+ main.setStyleSheet("QMenu [title =\"File\"] { color: red;}");
+ main.menuBar()->addMenu("File");
+}
+
+void tst_QMenu::activeSubMenuPosition()
+{
+ QPushButton lab("subMenuPosition test");
+
+ QMenu *sub = new QMenu("Submenu", &lab);
+ sub->addAction("Sub-Item1");
+ QAction *subAction = sub->addAction("Sub-Item2");
+
+ QMenu *main = new QMenu("Menu-Title", &lab);
+ (void)main->addAction("Item 1");
+ QAction *menuAction = main->addMenu(sub);
+ (void)main->addAction("Item 3");
+ (void)main->addAction("Item 4");
+
+ main->setActiveAction(menuAction);
+ sub->setActiveAction(subAction);
+ main->popup(QPoint(200,200));
+
+ QVERIFY(main->isVisible());
+ QCOMPARE(main->activeAction(), menuAction);
+ QVERIFY(sub->isVisible());
+ QVERIFY(sub->pos() != QPoint(0,0));
+ // well, it's enough to check the pos is not (0,0) but it's more safe
+ // to check that submenu is to the right of the main menu too.
+#ifndef Q_OS_WINCE_WM
+ QVERIFY(sub->pos().x() > main->pos().x());
+ QCOMPARE(sub->activeAction(), subAction);
+#endif
+}
+
+void tst_QMenu::task242454_sizeHint()
+{
+ QMenu menu;
+ QString s = QLatin1String("foo\nfoo\nfoo\nfoo");
+ menu.addAction(s);
+ QVERIFY(menu.sizeHint().width() > menu.fontMetrics().boundingRect(QRect(), Qt::TextSingleLine, s).width());
+}
+
+class Menu : public QMenu
+{
+ Q_OBJECT
+public slots:
+ void clear()
+ {
+ QMenu::clear();
+ }
+};
+
+void tst_QMenu::task176201_clear()
+{
+ //this test used to crash
+ Menu menu;
+ QAction *action = menu.addAction("test");
+ menu.connect(action, SIGNAL(triggered()), SLOT(clear()));
+ menu.popup(QPoint());
+ QTest::mouseClick(&menu, Qt::LeftButton, 0, menu.rect().center());
+}
+
+void tst_QMenu::task250673_activeMultiColumnSubMenuPosition()
+{
+ class MyMenu : public QMenu
+ {
+ public:
+ int columnCount() const { return QMenu::columnCount(); }
+ };
+
+ QMenu sub;
+
+ if (sub.style()->styleHint(QStyle::SH_Menu_Scrollable, 0, &sub)) {
+ //the style prevents the menus from getting columns
+ QSKIP("the style doesn't support multiple columns, it makes the menu scrollable", SkipSingle);
+ }
+
+ sub.addAction("Sub-Item1");
+ QAction *subAction = sub.addAction("Sub-Item2");
+
+ MyMenu main;
+ main.addAction("Item 1");
+ QAction *menuAction = main.addMenu(&sub);
+ main.popup(QPoint(200,200));
+
+ uint i = 2;
+ while (main.columnCount() < 2) {
+ main.addAction(QString("Item %1").arg(i));
+ ++i;
+ QVERIFY(i<1000);
+ }
+ main.setActiveAction(menuAction);
+ sub.setActiveAction(subAction);
+
+ QVERIFY(main.isVisible());
+ QCOMPARE(main.activeAction(), menuAction);
+ QVERIFY(sub.isVisible());
+ QVERIFY(sub.pos().x() > main.pos().x());
+
+ const int subMenuOffset = main.style()->pixelMetric(QStyle::PM_SubMenuOverlap, 0, &main);
+ QVERIFY((sub.geometry().left() - subMenuOffset + 5) < main.geometry().right());
+}
+
+void tst_QMenu::task256918_setFont()
+{
+ QMenu menu;
+ QAction *action = menu.addAction("foo");
+ QFont f;
+ f.setPointSize(30);
+ action->setFont(f);
+ menu.show(); //ensures that the actiongeometry are calculated
+ QVERIFY(menu.actionGeometry(action).height() > f.pointSize());
+}
+
+void tst_QMenu::menuSizeHint()
+{
+ QMenu menu;
+ //this is a list of arbitrary strings so that we check the geometry
+ QStringList list = QStringList() << "trer" << "ezrfgtgvqd" << "sdgzgzerzerzer" << "eerzertz" << "er";
+ foreach (QString str, list)
+ menu.addAction(str);
+
+ int left, top, right, bottom;
+ menu.getContentsMargins(&left, &top, &right, &bottom);
+ const int panelWidth = menu.style()->pixelMetric(QStyle::PM_MenuPanelWidth, 0, &menu);
+ const int hmargin = menu.style()->pixelMetric(QStyle::PM_MenuHMargin, 0, &menu),
+ vmargin = menu.style()->pixelMetric(QStyle::PM_MenuVMargin, 0, &menu);
+
+ int maxWidth =0;
+ QRect result;
+ foreach (QAction *action, menu.actions()) {
+#ifdef QT_SOFTKEYS_ENABLED
+ // Softkey actions are not widgets and have no geometry.
+ if (menu.actionGeometry(action).topLeft() == QPoint(0,0))
+ continue;
+#endif
+ maxWidth = qMax(maxWidth, menu.actionGeometry(action).width());
+ result |= menu.actionGeometry(action);
+ QCOMPARE(result.x(), left + hmargin + panelWidth);
+ QCOMPARE(result.y(), top + vmargin + panelWidth);
+ }
+
+ QStyleOption opt(0);
+ opt.rect = menu.rect();
+ opt.state = QStyle::State_None;
+
+ QSize resSize = QSize(result.x(), result.y()) + result.size() + QSize(hmargin + right + panelWidth, vmargin + top + panelWidth);
+
+ resSize = menu.style()->sizeFromContents(QStyle::CT_Menu, &opt,
+ resSize.expandedTo(QApplication::globalStrut()), &menu);
+
+ QCOMPARE(resSize, menu.sizeHint());
+}
+
+class Menu258920 : public QMenu
+{
+ Q_OBJECT
+public slots:
+ void paintEvent(QPaintEvent *e)
+ {
+ QMenu::paintEvent(e);
+ painted = true;
+ }
+
+public:
+ bool painted;
+};
+
+// Mouse move related signals for Windows Mobile unavailable.
+#ifndef Q_OS_WINCE_WM
+void tst_QMenu::task258920_mouseBorder()
+{
+#ifdef Q_WS_QPA
+ QSKIP("QTBUG-20753 QCursor::setPos() / QTest::mouseMove() doesn't work on qpa", SkipAll);
+#endif
+ Menu258920 menu;
+ // For styles which inherit from QWindowsStyle, styleHint(QStyle::SH_Menu_MouseTracking) is true.
+ menu.setMouseTracking(true);
+ QAction *action = menu.addAction("test");
+
+ menu.popup(QApplication::desktop()->availableGeometry().center());
+ QTest::qWaitForWindowShown(&menu);
+ QTest::qWait(100);
+ QRect actionRect = menu.actionGeometry(action);
+ QTest::mouseMove(&menu, actionRect.center());
+ QTest::qWait(30);
+ QTest::mouseMove(&menu, actionRect.center() + QPoint(10, 0));
+ QTest::qWait(30);
+ QCOMPARE(action, menu.activeAction());
+ menu.painted = false;
+ QTest::mouseMove(&menu, QPoint(actionRect.center().x(), actionRect.bottom() + 1));
+ QTest::qWait(30);
+ QCOMPARE(static_cast<QAction*>(0), menu.activeAction());
+ QVERIFY(menu.painted);
+}
+#endif
+
+void tst_QMenu::setFixedWidth()
+{
+ QMenu menu;
+ menu.addAction("action");
+ menu.setFixedWidth(300);
+ //the sizehint should reflect the minimumwidth because the action will try to
+ //get as much space as possible
+ QCOMPARE(menu.sizeHint().width(), menu.minimumWidth());
+}
+
+void tst_QMenu::deleteActionInTriggered()
+{
+ // should not crash
+ QMenu m;
+ QObject::connect(&m, SIGNAL(triggered(QAction*)), this, SLOT(deleteAction(QAction*)));
+ QWeakPointer<QAction> a = m.addAction("action");
+ a.data()->trigger();
+ QVERIFY(!a);
+}
+
+void tst_QMenu::pushButtonPopulateOnAboutToShow()
+{
+ QPushButton b("Test PushButton");
+ b.setWindowFlags(Qt::FramelessWindowHint | Qt::X11BypassWindowManagerHint);
+ lastMenu = new QMenu;
+ b.setMenu(lastMenu);
+ const int scrNumber = QApplication::desktop()->screenNumber(&b);
+ connect(lastMenu, SIGNAL(aboutToShow()), this, SLOT(populateMenu()));
+ b.show();
+ const QRect screen = QApplication::desktop()->screenGeometry(scrNumber);
+
+ QRect desiredGeometry = b.geometry();
+ desiredGeometry.moveTopLeft(QPoint(10, screen.bottom()-b.height()-5));
+
+ b.setGeometry(desiredGeometry);
+ QTest::qWaitForWindowShown(&b);
+
+ if (b.geometry() != desiredGeometry) {
+ // We are trying to put the button very close to the edge of the screen,
+ // explicitly to test behavior when the popup menu goes off the screen.
+ // However a modern window manager is quite likely to reject this requested geometry
+ // (kwin in kde4 does, for example, since the button would probably appear behind
+ // or partially behind the taskbar).
+ // Your best bet is to run this test _without_ a WM.
+ QSKIP("Your window manager won't allow a window against the bottom of the screen", SkipAll);
+ }
+
+ QTimer::singleShot(300,lastMenu, SLOT(hide()));
+ QTest::mouseClick(&b, Qt::LeftButton, Qt::NoModifier, b.rect().center());
+ QVERIFY(!lastMenu->geometry().intersects(b.geometry()));
+
+ // note: we're assuming that, if we previously got the desired geometry, we'll get it here too
+ b.move(10, screen.bottom()-lastMenu->height()-5);
+ QTimer::singleShot(300,lastMenu, SLOT(hide()));
+ QTest::mouseClick(&b, Qt::LeftButton, Qt::NoModifier, b.rect().center());
+ QVERIFY(!lastMenu->geometry().intersects(b.geometry()));
+
+}
+void tst_QMenu::QTBUG7907_submenus_autoselect()
+{
+ QMenu menu("Test Menu");
+ QMenu set1("Setting1");
+ QMenu set2("Setting2");
+ QMenu subset("Subsetting");
+ subset.addAction("Values");
+ set1.addMenu(&subset);
+ menu.addMenu(&set1);
+ menu.addMenu(&set2);
+ menu.show();
+ QTest::qWaitForWindowShown(&menu);
+ QTest::mouseClick(&menu, Qt::LeftButton, Qt::NoModifier, QPoint(5,5) );
+ QTest::qWait(500);
+ QVERIFY(!subset.isVisible());
+}
+
+void tst_QMenu::QTBUG7411_submenus_activate()
+{
+ QMenu menu("Test Menu");
+ QAction *act = menu.addAction("foo");
+ QMenu sub1("&sub1");
+ sub1.addAction("foo");
+ sub1.setTitle("&sub1");
+ QAction *act1 = menu.addMenu(&sub1);
+ menu.show();
+ QTest::qWaitForWindowShown(&menu);
+ menu.setActiveAction(act);
+ QTest::keyPress(&menu, Qt::Key_Down);
+ QCOMPARE(menu.activeAction(), act1);
+ QVERIFY(!sub1.isVisible());
+ QTest::keyPress(&menu, Qt::Key_S);
+ QTRY_VERIFY(sub1.isVisible());
+}
+
+class MyMenu : public QMenu
+{
+ Q_OBJECT
+public:
+ MyMenu() : m_currentIndex(0)
+ {
+ for (int i = 0; i < 2; ++i)
+ dialogActions[i] = addAction( QString("dialog %1").arg(i), dialogs + i, SLOT(exec()));
+ }
+
+ void activateAction(int index)
+ {
+ m_currentIndex = index;
+ popup(QPoint());
+ QTest::qWaitForWindowShown(this);
+ setActiveAction(dialogActions[index]);
+ QTimer::singleShot(500, this, SLOT(checkVisibility()));
+ QTest::keyClick(this, Qt::Key_Enter); //activation
+ }
+
+public slots:
+ void activateLastAction()
+ {
+ activateAction(1);
+ }
+
+ void checkVisibility()
+ {
+ QTRY_VERIFY(dialogs[m_currentIndex].isVisible());
+ if (m_currentIndex == 1) {
+ QApplication::closeAllWindows(); //this is the end of the test
+ }
+ }
+
+private:
+ QAction *dialogActions[2];
+ QDialog dialogs[2];
+ int m_currentIndex;
+};
+
+void tst_QMenu::QTBUG_10735_crashWithDialog()
+{
+ MyMenu menu;
+
+ QTimer::singleShot(1000, &menu, SLOT(activateLastAction()));
+ menu.activateAction(0);
+}
+
+QTEST_MAIN(tst_QMenu)
+#include "tst_qmenu.moc"
diff --git a/tests/auto/widgets/widgets/qmenubar/.gitignore b/tests/auto/widgets/widgets/qmenubar/.gitignore
new file mode 100644
index 0000000000..b72cc79d94
--- /dev/null
+++ b/tests/auto/widgets/widgets/qmenubar/.gitignore
@@ -0,0 +1 @@
+tst_qmenubar
diff --git a/tests/auto/widgets/widgets/qmenubar/qmenubar.pro b/tests/auto/widgets/widgets/qmenubar/qmenubar.pro
new file mode 100644
index 0000000000..73c2545710
--- /dev/null
+++ b/tests/auto/widgets/widgets/qmenubar/qmenubar.pro
@@ -0,0 +1,3 @@
+load(qttest_p4)
+QT += widgets
+SOURCES += tst_qmenubar.cpp
diff --git a/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp b/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp
new file mode 100644
index 0000000000..dc3b81920d
--- /dev/null
+++ b/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp
@@ -0,0 +1,1291 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#include <QtTest/QtTest>
+#include <qapplication.h>
+#include <qmainwindow.h>
+#include <qmenubar.h>
+#include <qstyle.h>
+#include <qwindowsstyle.h>
+#include <qdesktopwidget.h>
+#include <qaction.h>
+#include <qstyleoption.h>
+
+#ifdef Q_WS_WIN
+#include <windows.h>
+#endif
+
+#include <qobject.h>
+
+QT_FORWARD_DECLARE_CLASS(QMainWindow)
+
+#include <qmenubar.h>
+
+//TESTED_CLASS=
+//TESTED_FILES=
+
+class QtTestSlot : public QObject
+{
+ Q_OBJECT
+
+public:
+ QtTestSlot( QObject* parent = 0 ): QObject( parent ) { clear(); };
+ virtual ~QtTestSlot() {};
+
+ void clear() { sel_count = 0; };
+ uint selCount() { return sel_count; };
+
+public slots:
+ void selected() { sel_count++; };
+
+private:
+ uint sel_count;
+};
+
+class Menu : public QMenu
+{
+ Q_OBJECT
+ public slots:
+ void addActions()
+ {
+ //this will change the geometry of the menu
+ addAction("action1");
+ addAction("action2");
+ }
+};
+
+class tst_QMenuBar : public QObject
+{
+ Q_OBJECT
+public:
+ tst_QMenuBar();
+ virtual ~tst_QMenuBar();
+
+ void initSimpleMenubar();
+ void initComplexMenubar();
+
+public slots:
+ void initTestCase();
+ void cleanupTestCase();
+ void init();
+private slots:
+ void getSetCheck();
+
+ void clear();
+ void removeItemAt();
+ void removeItemAt_data();
+ void removeItem_data();
+ void removeItem();
+ void count();
+ void insertItem_QString_QObject();
+#if !defined(Q_WS_MAC) && !defined(Q_OS_WINCE_WM)
+ void accel();
+ void activatedCount();
+#endif
+ void allowActiveAndDisabled();
+
+#if !defined(Q_WS_MAC) && !defined(Q_OS_WINCE_WM)
+ void check_accelKeys();
+ void check_cursorKeys1();
+ void check_cursorKeys2();
+ void check_cursorKeys3();
+#endif
+
+ void check_homeKey();
+ void check_endKey();
+#if !defined(Q_WS_MAC) && !defined(Q_OS_WINCE_WM)
+ void check_escKey();
+#endif
+
+// void check_mouse1_data();
+// void check_mouse1();
+// void check_mouse2_data();
+// void check_mouse2();
+
+ void check_altPress();
+#if !defined(Q_WS_MAC) && !defined(Q_OS_WINCE_WM)
+ void check_shortcutPress();
+ void check_menuPosition();
+#endif
+ void task223138_triggered();
+ void task256322_highlight();
+ void menubarSizeHint();
+#ifndef Q_WS_MAC
+ void taskQTBUG4965_escapeEaten();
+#endif
+ void taskQTBUG11823_crashwithInvisibleActions();
+
+protected slots:
+ void onActivated( QAction*);
+
+private:
+ QtTestSlot *menu1;
+ QtTestSlot *menu2;
+ QtTestSlot *menu3;
+ QtTestSlot *menu4;
+
+ QtTestSlot *item1_A;
+ QtTestSlot *item1_B;
+ QtTestSlot *item2_C;
+ QtTestSlot *item2_D;
+ QtTestSlot *item2_E;
+ QtTestSlot *item2_F;
+ QtTestSlot *item2_G;
+ QtTestSlot *item2_H;
+
+ void resetSlots();
+ void resetCount();
+
+ void reset() { resetSlots(); resetCount(); };
+
+ QAction* last_accel_id;
+ int activated_count;
+
+ QAction *action;
+ QAction *action1;
+ QMainWindow *mw;
+ QMenuBar *mb;
+ QMenu *pm1;
+ QMenu *pm2;
+};
+
+// Testing get/set functions
+void tst_QMenuBar::getSetCheck()
+{
+ QMenuBar obj1;
+ // QAction * QMenuBar::activeAction()
+ // void QMenuBar::setActiveAction(QAction *)
+ QAction *var1 = new QAction(0);
+ obj1.setActiveAction(var1);
+ QCOMPARE(var1, obj1.activeAction());
+ obj1.setActiveAction((QAction *)0);
+ QCOMPARE((QAction *)0, obj1.activeAction());
+ delete var1;
+}
+
+#include <qcursor.h>
+
+const int RESET = 0;
+
+/*!
+ Test plan:
+ insertItem (all flavors and combinations)
+ removing menu items
+ clearing the menu
+
+ check the common behaviour + emitted signals for:
+ accelerator keys
+ navigating tru the menu and then pressing ENTER
+ mouse clicks
+ mouse drags
+ combinations of key + mouse (if possible)
+ checked / unckecked state of menu options
+ active / inactive state
+
+ Can't test these without pixmap comparison...
+ show and hide
+ icons in a menu
+ pixmaps in a menu
+
+*/
+
+tst_QMenuBar::tst_QMenuBar()
+
+{
+ QApplication::setEffectEnabled(Qt::UI_AnimateMenu, false);
+
+
+ activated_count = 0;
+ mb = 0;
+ pm1 = 0;
+ pm2 = 0;
+ last_accel_id = 0;
+}
+
+tst_QMenuBar::~tst_QMenuBar()
+{
+ //delete mw; //#### cannot do that AFTER qapplication was destroyed!
+ mw = 0;
+}
+
+void tst_QMenuBar::initTestCase()
+{
+ // create a default mainwindow
+ // If you run a widget test, this will be replaced in the testcase by the
+ // widget under test
+ mw = new QMainWindow(0, Qt::X11BypassWindowManagerHint);
+ mb = new QMenuBar( mw );
+ connect( mb, SIGNAL(triggered(QAction *)), this, SLOT(onActivated(QAction *)) );
+
+ initSimpleMenubar();
+ mw->show();
+ QTest::qWaitForWindowShown(mw);
+ mw->activateWindow();
+
+ menu1 = new QtTestSlot( mw );
+ menu2 = new QtTestSlot( mw );
+ menu3 = new QtTestSlot( mw );
+ menu4 = new QtTestSlot( mw );
+ item1_A = new QtTestSlot( mw );
+ item1_B = new QtTestSlot( mw );
+ item2_C = new QtTestSlot( mw );
+ item2_D = new QtTestSlot( mw );
+ item2_E = new QtTestSlot( mw );
+ item2_F = new QtTestSlot( mw );
+ item2_G = new QtTestSlot( mw );
+ item2_H = new QtTestSlot( mw );
+}
+
+
+void tst_QMenuBar::cleanupTestCase()
+{
+ delete mw;
+}
+
+void tst_QMenuBar::initSimpleMenubar()
+{
+ mb->hide();
+ mb->clear();
+
+ delete pm1;
+ pm1 = mb->addMenu("&accel");
+ action = pm1->addAction( "menu1" );
+ action->setShortcut(QKeySequence("ALT+A"));
+ action->setShortcut(QKeySequence("CTRL+A"));
+
+ connect( pm1, SIGNAL(triggered(QAction*)), this, SLOT(onActivated(QAction*)));
+
+ delete pm2;
+ pm2 = mb->addMenu("accel1");
+
+ action1 = pm2->addAction( "&Open..." );
+ action1->setShortcut(Qt::Key_O);
+ connect(pm2, SIGNAL(triggered(QAction*)), this, SLOT(onActivated(QAction*)));
+
+ mb->show();
+ qApp->syncX();
+ qApp->processEvents();
+}
+
+void tst_QMenuBar::init()
+{
+ resetSlots();
+ resetCount();
+}
+
+void tst_QMenuBar::resetSlots()
+{
+ menu1->clear();
+ menu2->clear();
+ menu3->clear();
+ menu4->clear();
+ item1_A->clear();
+ item1_B->clear();
+ item2_C->clear();
+ item2_D->clear();
+ item2_E->clear();
+ item2_F->clear();
+ item2_G->clear();
+ item2_H->clear();
+}
+
+void tst_QMenuBar::resetCount()
+{
+ last_accel_id = 0;
+ activated_count = 0;
+}
+
+void tst_QMenuBar::onActivated( QAction* action )
+{
+ last_accel_id = action;
+ activated_count++;
+// printf( QString("acceleratorId: %1, count: %1\n").arg( i ).arg(activated_count) );
+}
+
+// On Mac/WinCE, native key events are needed to test menu action activation.
+#if !defined(Q_WS_MAC) && !defined(Q_OS_WINCE_WM)
+void tst_QMenuBar::accel()
+{
+ // create a popup menu with menu items set the accelerators later...
+ initSimpleMenubar();
+
+ // shortcuts won't work unless the window is active
+ QTRY_VERIFY( QApplication::activeWindow() );
+// QTest::keyClick(static_cast<QWidget *>(0), Qt::Key_A, AltKey );
+ QTest::keyClick(static_cast<QWidget *>(0), Qt::Key_A, Qt::ControlModifier );
+ QTest::qWait(300);
+
+ QCOMPARE( last_accel_id, action );
+}
+#endif
+
+// On Mac/WinCE, native key events are needed to test menu action activation.
+#if !defined(Q_WS_MAC) && !defined(Q_OS_WINCE_WM)
+void tst_QMenuBar::activatedCount()
+{
+ // create a popup menu with menu items set the accelerators later...
+ initSimpleMenubar();
+
+ QTest::keyClick(static_cast<QWidget *>(0), Qt::Key_A, Qt::ControlModifier );
+//wait(5000);
+ QCOMPARE( activated_count, 2 ); //1 from the popupmenu and 1 from the menubar
+}
+#endif
+
+void tst_QMenuBar::clear()
+{
+ mb->clear();
+ QVERIFY( (uint) mb->actions().size() == 0 );
+
+ mb->clear();
+ for (uint i=0; i<10; i++) {
+ QMenu *menu = mb->addMenu( QString("Menu %1"));
+ for (uint k=0; k<i; k++)
+ menu->addAction( QString("Item %1"));
+ QCOMPARE( (uint) mb->actions().size(), (uint)i+1 );
+ }
+ QCOMPARE( (uint) mb->actions().size(), 10u );
+
+ mb->clear();
+ QVERIFY( (uint) mb->actions().size() == 0 );
+}
+
+void tst_QMenuBar::count()
+{
+ mb->clear();
+ QVERIFY( mb->actions().size() == 0 );
+
+ for (uint i=0; i<10; i++) {
+ mb->addAction( QString("Menu %1"));
+ QCOMPARE( (uint) mb->actions().size(), (uint) i+1 );
+ }
+}
+
+void tst_QMenuBar::removeItem_data()
+{
+ QTest::addColumn<int>("removeIndex");
+ QTest::newRow( "first" ) << 0;
+ QTest::newRow( "middle" ) << 1;
+ QTest::newRow( "last" ) << 2;
+}
+
+// Basically the same test as removeItemAt, except that we remember and remove id's.
+void tst_QMenuBar::removeItem()
+{
+ mb->clear();
+
+ QMenu *pm;
+ pm = new QMenu( "stuff", mb );
+ pm->setTitle("Menu 1");
+ pm->addAction( QString("Item 10") );
+ QAction* action1 = mb->addMenu( pm );
+
+ pm = new QMenu( mb );
+ pm->setTitle("Menu 2");
+ pm->addAction( QString("Item 20") );
+ pm->addAction( QString("Item 21") );
+ QAction *action2 = mb->addMenu( pm );
+
+ pm = new QMenu( "Menu 3", mb );
+ pm->addAction( QString("Item 30") );
+ pm->addAction( QString("Item 31") );
+ pm->addAction( QString("Item 32") );
+ QAction *action3 = mb->addMenu( pm );
+
+ QList<QAction *> menuBarActions = mb->actions();
+
+ QCOMPARE( action1->text(), QString("Menu 1") );
+ QCOMPARE( action2->text(), QString("Menu 2") );
+ QCOMPARE( action3->text(), QString("Menu 3") );
+
+ QVERIFY( menuBarActions.at(0) == action1 );
+ QVERIFY( menuBarActions.at(1) == action2 );
+ QVERIFY( menuBarActions.at(2) == action3 );
+
+ // Ok, now that we know we have created the menu we expect, lets remove an item...
+ QFETCH( int, removeIndex );
+ switch (removeIndex )
+ {
+ case 0: {
+ mb->removeAction(action1);
+ QList<QAction *> menuBarActions2 = mb->actions();
+ QCOMPARE( menuBarActions2.at(0)->text(), QString("Menu 2") );
+ QCOMPARE( menuBarActions2.at(1)->text(), QString("Menu 3") );
+ }
+ break;
+ case 1: {
+ mb->removeAction(action2);
+ QList<QAction *> menuBarActions2 = mb->actions();
+ QCOMPARE( menuBarActions2.at(0)->text(), QString("Menu 1") );
+ QCOMPARE( menuBarActions2.at(1)->text(), QString("Menu 3") );
+ }
+ break;
+ case 2: {
+ mb->removeAction(action3);
+ QList<QAction *> menuBarActions2 = mb->actions();
+ QCOMPARE( menuBarActions2.at(0)->text(), QString("Menu 1") );
+ QCOMPARE( menuBarActions2.at(1)->text(), QString("Menu 2") );
+ }
+ break;
+ }
+ QList<QAction *> menuBarActions2 = mb->actions();
+ QVERIFY( menuBarActions2.size() == 2 );
+}
+
+void tst_QMenuBar::removeItemAt_data()
+{
+ QTest::addColumn<int>("removeIndex");
+ QTest::newRow( "first" ) << 0;
+ QTest::newRow( "middle" ) << 1;
+ QTest::newRow( "last" ) << 2;
+}
+
+void tst_QMenuBar::removeItemAt()
+{
+ mb->clear();
+
+ QMenu *pm;
+ pm = new QMenu("Menu 1", mb);
+ pm->addAction( QString("Item 10") );
+ mb->addMenu( pm );
+
+ pm = new QMenu( "Menu 2", mb );
+ pm->addAction( QString("Item 20") );
+ pm->addAction( QString("Item 21") );
+ mb->addMenu( pm );
+
+ pm = new QMenu( "Menu 3", mb );
+ pm->addAction( QString("Item 30") );
+ pm->addAction( QString("Item 31") );
+ pm->addAction( QString("Item 32") );
+ mb->addMenu( pm );
+
+ QList<QAction *> menuBarActions = mb->actions();
+
+ QCOMPARE( menuBarActions.at(0)->text(), QString("Menu 1") );
+ QCOMPARE( menuBarActions.at(1)->text(), QString("Menu 2") );
+ QCOMPARE( menuBarActions.at(2)->text(), QString("Menu 3") );
+
+ // Ok, now that we know we have created the menu we expect, lets remove an item...
+ QFETCH( int, removeIndex );
+ mb->removeAction(menuBarActions.at(removeIndex));
+ QList<QAction *> menuBarActions2 = mb->actions();
+ switch (removeIndex )
+ {
+ case 0:
+ QCOMPARE( menuBarActions2.at(0)->text(), QString("Menu 2") );
+ QCOMPARE( menuBarActions2.at(1)->text(), QString("Menu 3") );
+ break;
+ case 1:
+ QCOMPARE( menuBarActions2.at(0)->text(), QString("Menu 1") );
+ QCOMPARE( menuBarActions2.at(1)->text(), QString("Menu 3") );
+ break;
+ case 2:
+ QCOMPARE( menuBarActions2.at(0)->text(), QString("Menu 1") );
+ QCOMPARE( menuBarActions2.at(1)->text(), QString("Menu 2") );
+ break;
+ }
+
+ QVERIFY( menuBarActions2.size() == 2 );
+}
+
+void tst_QMenuBar::initComplexMenubar() // well, complex....
+{
+ mb->hide();
+ mb->clear();
+
+ delete pm1;
+ pm1 = mb->addMenu("Menu &1");
+ pm1->addAction( QString("Item A"), item1_A, SLOT(selected()), Qt::CTRL+Qt::Key_A );
+ pm1->addAction( QString("Item B"), item1_B, SLOT(selected()), Qt::CTRL+Qt::Key_B );
+
+ delete pm2;
+ pm2 = mb->addMenu("Menu &2");
+ pm2->addAction( QString("Item C"), item2_C, SLOT(selected()), Qt::CTRL+Qt::Key_C );
+ pm2->addAction( QString("Item D"), item2_D, SLOT(selected()), Qt::CTRL+Qt::Key_D );
+ pm2->addAction( QString("Item E"), item2_E, SLOT(selected()), Qt::CTRL+Qt::Key_E );
+ pm2->addAction( QString("Item F"), item2_F, SLOT(selected()), Qt::CTRL+Qt::Key_F );
+ pm2->addSeparator();
+ pm2->addAction( QString("Item G"), item2_G, SLOT(selected()), Qt::CTRL+Qt::Key_G );
+ pm2->addAction( QString("Item H"), item2_H, SLOT(selected()), Qt::CTRL+Qt::Key_H );
+
+ QAction *ac = mb->addAction( QString("M&enu 3"), menu3, SLOT(selected()));
+ ac->setShortcut(Qt::ALT+Qt::Key_J);
+ mb->show();
+}
+
+
+/*
+ Check the insert functions that create menu items.
+ For the moment i only check the strings and pixmaps. The rest are special cases which are
+ used less frequently.
+*/
+
+void tst_QMenuBar::insertItem_QString_QObject()
+{
+ initComplexMenubar();
+
+ QList<QAction *> actions = mb->actions();
+
+ QCOMPARE(actions.at(0)->text(), QString("Menu &1") );
+ QCOMPARE(actions.at(1)->text(), QString("Menu &2") );
+ QCOMPARE(actions.at(2)->text(), QString("M&enu 3") );
+ QVERIFY(actions.size() < 4); // there is no menu 4!
+}
+
+// On Mac/WinCE, native key events are needed to test menu action activation.
+#if !defined(Q_WS_MAC) && !defined(Q_OS_WINCE_WM)
+void tst_QMenuBar::check_accelKeys()
+{
+ initComplexMenubar();
+
+ // start with a bogus key that shouldn't trigger anything
+ QTest::keyClick(static_cast<QWidget *>(0), Qt::Key_I, Qt::ControlModifier);
+ QCOMPARE(menu1->selCount(), 0u);
+ QCOMPARE(menu2->selCount(), 0u);
+ QCOMPARE(menu3->selCount(), 0u);
+ QCOMPARE(menu4->selCount(), 0u);
+ QCOMPARE(item1_A->selCount(), 0u);
+ QCOMPARE(item1_B->selCount(), 0u);
+ QCOMPARE(item2_C->selCount(), 0u);
+ QCOMPARE(item2_D->selCount(), 0u);
+
+ QTest::keyClick(static_cast<QWidget *>(0), Qt::Key_A, Qt::ControlModifier);
+ QCOMPARE(menu1->selCount(), 0u);
+ QCOMPARE(menu2->selCount(), 0u);
+ QCOMPARE(menu3->selCount(), 0u);
+ QCOMPARE(menu4->selCount(), 0u);
+ QCOMPARE(item1_A->selCount(), 1u);
+ QCOMPARE(item1_B->selCount(), 0u);
+ QCOMPARE(item2_C->selCount(), 0u);
+ QCOMPARE(item2_D->selCount(), 0u);
+
+ QTest::keyClick(static_cast<QWidget *>(0), Qt::Key_C, Qt::ControlModifier);
+ QCOMPARE(menu1->selCount(), 0u);
+ QCOMPARE(menu2->selCount(), 0u);
+ QCOMPARE(menu3->selCount(), 0u);
+ QCOMPARE(menu4->selCount(), 0u);
+ QCOMPARE(item1_A->selCount(), 1u);
+ QCOMPARE(item1_B->selCount(), 0u);
+ QCOMPARE(item2_C->selCount(), 1u);
+ QCOMPARE(item2_D->selCount(), 0u);
+
+ QTest::keyClick(static_cast<QWidget *>(0), Qt::Key_B, Qt::ControlModifier);
+ QCOMPARE(menu1->selCount(), 0u);
+ QCOMPARE(menu2->selCount(), 0u);
+ QCOMPARE(menu3->selCount(), 0u);
+ QCOMPARE(menu4->selCount(), 0u);
+ QCOMPARE(item1_A->selCount(), 1u);
+ QCOMPARE(item1_B->selCount(), 1u);
+ QCOMPARE(item2_C->selCount(), 1u);
+ QCOMPARE(item2_D->selCount(), 0u);
+
+ QTest::keyClick(static_cast<QWidget *>(0), Qt::Key_D, Qt::ControlModifier);
+ QCOMPARE(menu1->selCount(), 0u);
+ QCOMPARE(menu2->selCount(), 0u);
+ QCOMPARE(menu3->selCount(), 0u);
+ QCOMPARE(menu4->selCount(), 0u);
+ QCOMPARE(item1_A->selCount(), 1u);
+ QCOMPARE(item1_B->selCount(), 1u);
+ QCOMPARE(item2_C->selCount(), 1u);
+ QCOMPARE(item2_D->selCount(), 1u);
+
+ QTest::keyClick(static_cast<QWidget *>(0), Qt::Key_J, Qt::AltModifier);
+ QCOMPARE(menu1->selCount(), 0u);
+ QCOMPARE(menu2->selCount(), 0u);
+ QCOMPARE(menu3->selCount(), 1u);
+ QCOMPARE(menu4->selCount(), 0u);
+ QCOMPARE(item1_A->selCount(), 1u);
+ QCOMPARE(item1_B->selCount(), 1u);
+ QCOMPARE(item2_C->selCount(), 1u);
+ QCOMPARE(item2_D->selCount(), 1u);
+}
+#endif
+
+// Qt/Mac,WinCE does not use the native popups/menubar.
+#if !defined(Q_WS_MAC) && !defined(Q_OS_WINCE_WM)
+void tst_QMenuBar::check_cursorKeys1()
+{
+ initComplexMenubar();
+
+ // start with a ALT + 1 that activates the first popupmenu
+ QTest::keyClick(static_cast<QWidget *>(0), Qt::Key_1, Qt::AltModifier );
+ // the Popupmenu should be visible now
+ QCOMPARE(menu3->selCount(), 0u);
+ QCOMPARE(menu4->selCount(), 0u);
+ QCOMPARE(item1_A->selCount(), 0u);
+ QCOMPARE(item1_B->selCount(), 0u);
+ QCOMPARE(item2_C->selCount(), 0u);
+ QCOMPARE(item2_D->selCount(), 0u);
+
+ // Simulate a cursor key down click
+ QTest::keyClick(static_cast<QWidget *>(0), Qt::Key_Down );
+ // and an Enter key
+ QTest::keyClick(static_cast<QWidget *>(0), Qt::Key_Enter );
+ // Let's see if the correct slot is called...
+ QCOMPARE(menu3->selCount(), 0u);
+ QCOMPARE(menu4->selCount(), 0u);
+ QCOMPARE(item1_A->selCount(), 0u); // this shouldn't have been called
+ QCOMPARE(item1_B->selCount(), 1u); // and this should have been called by a signal now
+ QCOMPARE(item2_C->selCount(), 0u);
+ QCOMPARE(item2_D->selCount(), 0u);
+}
+#endif
+
+// Qt/Mac,WinCE does not use the native popups/menubar.
+#if !defined(Q_WS_MAC) && !defined(Q_OS_WINCE_WM)
+void tst_QMenuBar::check_cursorKeys2()
+{
+ initComplexMenubar();
+
+ // select popupmenu2
+ QTest::keyClick(static_cast<QWidget *>(0), Qt::Key_2, Qt::AltModifier );
+
+ // Simulate some cursor keys
+ QTest::keyClick(static_cast<QWidget *>(0), Qt::Key_Left );
+ QTest::keyClick(static_cast<QWidget *>(0), Qt::Key_Down );
+ QTest::keyClick(static_cast<QWidget *>(0), Qt::Key_Right );
+ QTest::keyClick(static_cast<QWidget *>(0), Qt::Key_Down );
+ // and an Enter key
+ QTest::keyClick(static_cast<QWidget *>(0), Qt::Key_Enter );
+ // Let's see if the correct slot is called...
+ QCOMPARE(menu3->selCount(), 0u);
+ QCOMPARE(menu4->selCount(), 0u);
+ QCOMPARE(item1_A->selCount(), 0u); // this shouldn't have been caled
+ QCOMPARE(item1_B->selCount(), 0u); // and this should have been called by a signal ow
+ QCOMPARE(item2_C->selCount(), 0u);
+ QCOMPARE(item2_D->selCount(), 1u);
+}
+#endif
+
+/*!
+ If a popupmenu is active you can use Left to move to the menu to the left of it.
+ Qt/Mac,WinCE does not use the native popups/menubar.
+*/
+#if !defined(Q_WS_MAC) && !defined(Q_OS_WINCE_WM)
+void tst_QMenuBar::check_cursorKeys3()
+{
+ initComplexMenubar();
+
+ // select Popupmenu 2
+ QTest::keyClick(static_cast<QWidget *>(0), Qt::Key_2, Qt::AltModifier );
+
+ // Simulate some keys
+ QTest::keyClick(static_cast<QWidget *>(0), Qt::Key_Left );
+ QTest::keyClick(static_cast<QWidget *>(0), Qt::Key_Down );
+ // and press ENTER
+ QTest::keyClick(static_cast<QWidget *>(0), Qt::Key_Enter );
+ // Let's see if the correct slot is called...
+ QCOMPARE(menu3->selCount(), 0u);
+ QCOMPARE(menu4->selCount(), 0u);
+ QCOMPARE(item1_A->selCount(), 0u); // this shouldn't have been called
+ QCOMPARE(item1_B->selCount(), 1u); // and this should have been called by a signal now
+ QCOMPARE(item2_C->selCount(), 0u);
+ QCOMPARE(item2_D->selCount(), 0u);
+}
+#endif
+
+/*!
+ If a popupmenu is active you can use home to go quickly to the first item in the menu.
+*/
+void tst_QMenuBar::check_homeKey()
+{
+ // I'm temporarily shutting up this testcase.
+ // Seems like the behaviour i'm expecting isn't ok.
+ QVERIFY( TRUE );
+ return;
+
+ QEXPECT_FAIL( "0", "Popupmenu should respond to a Home key", Abort );
+
+ initComplexMenubar();
+
+ // select Popupmenu 2
+ QTest::keyClick(static_cast<QWidget *>(0), Qt::Key_2, Qt::AltModifier );
+
+ // Simulate some keys
+ QTest::keyClick(static_cast<QWidget *>(0), Qt::Key_Down );
+ QTest::keyClick(static_cast<QWidget *>(0), Qt::Key_Down );
+ QTest::keyClick(static_cast<QWidget *>(0), Qt::Key_Down );
+ QTest::keyClick(static_cast<QWidget *>(0), Qt::Key_Home );
+ // and press ENTER
+ QTest::keyClick(static_cast<QWidget *>(0), Qt::Key_Enter );
+ // Let's see if the correct slot is called...
+// QVERIFY2( item2_C->selCount() == 1, "Popupmenu should respond to a Home key" );
+ QCOMPARE(item2_C->selCount(), 1u);
+ QCOMPARE(menu3->selCount(), 0u);
+ QCOMPARE(menu4->selCount(), 0u);
+ QCOMPARE(item1_A->selCount(), 0u);
+ QCOMPARE(item1_B->selCount(), 0u);
+ QCOMPARE(item2_D->selCount(), 0u);
+ QCOMPARE(item2_E->selCount(), 0u);
+ QCOMPARE(item2_F->selCount(), 0u);
+ QCOMPARE(item2_G->selCount(), 0u);
+ QCOMPARE(item2_H->selCount(), 0u);
+}
+
+/*!
+ If a popupmenu is active you can use end to go quickly to the last item in the menu.
+*/
+void tst_QMenuBar::check_endKey()
+{
+ // I'm temporarily silenting this testcase.
+ // Seems like the behaviour i'm expecting isn't ok.
+ QVERIFY( TRUE );
+ return;
+
+ QEXPECT_FAIL( "0", "Popupmenu should respond to an End key", Abort );
+
+ initComplexMenubar();
+
+ // select Popupmenu 2
+ QTest::keyClick(static_cast<QWidget *>(0), Qt::Key_2, Qt::AltModifier );
+
+ // Simulate some keys
+ QTest::keyClick(static_cast<QWidget *>(0), Qt::Key_End );
+ // and press ENTER
+ QTest::keyClick(static_cast<QWidget *>(0), Qt::Key_Enter );
+ // Let's see if the correct slot is called...
+// QVERIFY2( item2_H->selCount() == 1, "Popupmenu should respond to an End key" );
+ QCOMPARE(item2_H->selCount(), 1u);//, "Popupmenu should respond to an End key");
+ QCOMPARE(menu3->selCount(), 0u);
+ QCOMPARE(menu4->selCount(), 0u);
+ QCOMPARE(item1_A->selCount(), 0u);
+ QCOMPARE(item1_B->selCount(), 0u);
+ QCOMPARE(item2_C->selCount(), 0u);
+ QCOMPARE(item2_D->selCount(), 0u);
+ QCOMPARE(item2_E->selCount(), 0u);
+ QCOMPARE(item2_F->selCount(), 0u);
+ QCOMPARE(item2_G->selCount(), 0u);
+}
+
+/*!
+ If a popupmenu is active you can use esc to hide the menu and then the
+ menubar should become active.
+ If Down is pressed next the popup is activated again.
+*/
+
+// Qt/Mac,WinCE does not use the native popups/menubar.
+#if !defined(Q_WS_MAC) && !defined(Q_OS_WINCE_WM)
+void tst_QMenuBar::check_escKey()
+{
+ initComplexMenubar();
+
+ QVERIFY( !pm1->isActiveWindow() );
+ QVERIFY( !pm2->isActiveWindow() );
+
+ // select Popupmenu 2
+ QTest::keyClick(static_cast<QWidget *>(0), Qt::Key_2, Qt::AltModifier );
+ QVERIFY( !pm1->isActiveWindow() );
+ QVERIFY( pm2->isActiveWindow() );
+
+ // If we press ESC, the popup should disappear
+ QTest::keyClick(static_cast<QWidget *>(0), Qt::Key_Escape );
+ QVERIFY( !pm1->isActiveWindow() );
+ QVERIFY( !pm2->isActiveWindow() );
+
+ if (!QApplication::style()->inherits("QWindowsStyle"))
+ return;
+
+ // If we press Down the popupmenu should be active again
+ QTest::keyClick(static_cast<QWidget *>(0), Qt::Key_Down );
+ QVERIFY( !pm1->isActiveWindow() );
+ QVERIFY( pm2->isActiveWindow() );
+
+ // and press ENTER
+ QTest::keyClick( pm2, Qt::Key_Enter );
+ // Let's see if the correct slot is called...
+ QVERIFY2( item2_C->selCount() == 1, "Expected item 2C to be selected" );
+}
+#endif
+
+// void tst_QMenuBar::check_mouse1_data()
+// {
+// QTest::addColumn<QString>("popup_item");
+// QTest::addColumn<int>("itemA_count");
+// QTest::addColumn<int>("itemB_count");
+
+// QTest::newRow( "A" ) << QString( "Item A Ctrl+A" ) << 1 << 0;
+// QTest::newRow( "B" ) << QString( "Item B Ctrl+B" ) << 0 << 1;
+// }
+
+// /*!
+// Check if the correct signals are emitted if we select a popupmenu.
+// */
+// void tst_QMenuBar::check_mouse1()
+// {
+// if (QSystem::curStyle() == "Motif")
+// QSKIP("This fails in Motif due to a bug in the testing framework", SkipAll);
+// QFETCH( QString, popup_item );
+// QFETCH( int, itemA_count );
+// QFETCH( int, itemB_count );
+
+// initComplexMenubar();
+// QVERIFY( !pm1->isActiveWindow() );
+// QVERIFY( !pm2->isActiveWindow() );
+
+// QTest::qWait(1000);
+// QtTestMouse mouse;
+// mouse.mouseEvent( QtTestMouse::MouseClick, mb, "Menu &1", Qt::LeftButton );
+
+// QVERIFY( pm1->isActiveWindow() );
+// QVERIFY( !pm2->isActiveWindow() );
+
+// QTest::qWait(1000);
+// mouse.mouseEvent( QtTestMouse::MouseClick, pm1, popup_item, Qt::LeftButton );
+
+// QCOMPARE(menu3->selCount(), 0u);
+// QCOMPARE(menu4->selCount(), 0u);
+// QCOMPARE(item1_A->selCount(), (uint)itemA_count); // this option should have fired
+// QCOMPARE(item1_B->selCount(), (uint)itemB_count);
+// QCOMPARE(item2_C->selCount(), 0u);
+// QCOMPARE(item2_D->selCount(), 0u);
+// QCOMPARE(item2_E->selCount(), 0u);
+// QCOMPARE(item2_F->selCount(), 0u);
+// QCOMPARE(item2_G->selCount(), 0u);
+// }
+
+// void tst_QMenuBar::check_mouse2_data()
+// {
+// QTest::addColumn<QString>("label");
+// QTest::addColumn<int>("itemA_count");
+// QTest::addColumn<int>("itemB_count");
+// QTest::addColumn<int>("itemC_count");
+// QTest::addColumn<int>("itemD_count");
+// QTest::addColumn<int>("itemE_count");
+// QTest::addColumn<int>("itemF_count");
+// QTest::addColumn<int>("itemG_count");
+// QTest::addColumn<int>("itemH_count");
+// QTest::addColumn<int>("menu3_count");
+
+// QTest::newRow( "A" ) << QString( "Menu &1/Item A Ctrl+A" ) << 1 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0;
+// QTest::newRow( "B" ) << QString( "Menu &1/Item B Ctrl+B" ) << 0 << 1 << 0 << 0 << 0 << 0 << 0 << 0 << 0;
+// QTest::newRow( "C" ) << QString( "Menu &2/Item C Ctrl+C" ) << 0 << 0 << 1 << 0 << 0 << 0 << 0 << 0 << 0;
+// QTest::newRow( "D" ) << QString( "Menu &2/Item D Ctrl+D" ) << 0 << 0 << 0 << 1 << 0 << 0 << 0 << 0 << 0;
+// QTest::newRow( "E" ) << QString( "Menu &2/Item E Ctrl+E" ) << 0 << 0 << 0 << 0 << 1 << 0 << 0 << 0 << 0;
+// QTest::newRow( "F" ) << QString( "Menu &2/Item F Ctrl+F" ) << 0 << 0 << 0 << 0 << 0 << 1 << 0 << 0 << 0;
+// QTest::newRow( "G" ) << QString( "Menu &2/Item G Ctrl+G" ) << 0 << 0 << 0 << 0 << 0 << 0 << 1 << 0 << 0;
+// QTest::newRow( "H" ) << QString( "Menu &2/Item H Ctrl+H" ) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 1 << 0;
+// QTest::newRow( "menu 3" ) << QString( "M&enu 3" ) << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 1;
+// }
+
+// /*!
+// Check if the correct signals are emitted if we select a popupmenu.
+// This time, we use a little bit more magic from the testframework.
+// */
+// void tst_QMenuBar::check_mouse2()
+// {
+// if (QSystem::curStyle() == "Motif")
+// QSKIP("This fails in Motif due to a bug in the testing framework", SkipAll);
+// QFETCH( QString, label );
+// QFETCH( int, itemA_count );
+// QFETCH( int, itemB_count );
+// QFETCH( int, itemC_count );
+// QFETCH( int, itemD_count );
+// QFETCH( int, itemE_count );
+// QFETCH( int, itemF_count );
+// QFETCH( int, itemG_count );
+// QFETCH( int, itemH_count );
+// QFETCH( int, menu3_count );
+
+// initComplexMenubar();
+// QtTestMouse mouse;
+// mouse.click( QtTestMouse::Menu, label, Qt::LeftButton );
+
+// // check if the correct signals have fired
+// QCOMPARE(menu3->selCount(), (uint)menu3_count);
+// QCOMPARE(menu4->selCount(), 0u);
+// QCOMPARE(item1_A->selCount(), (uint)itemA_count);
+// QCOMPARE(item1_B->selCount(), (uint)itemB_count);
+// QCOMPARE(item2_C->selCount(), (uint)itemC_count);
+// QCOMPARE(item2_D->selCount(), (uint)itemD_count);
+// QCOMPARE(item2_E->selCount(), (uint)itemE_count);
+// QCOMPARE(item2_F->selCount(), (uint)itemF_count);
+// QCOMPARE(item2_G->selCount(), (uint)itemG_count);
+// QCOMPARE(item2_H->selCount(), (uint)itemH_count);
+// }
+
+void
+tst_QMenuBar::allowActiveAndDisabled()
+{
+#if !defined(Q_WS_MAC) && !defined(Q_OS_WINCE_WM)
+ mb->hide();
+ mb->clear();
+
+ // Task 241043 : check that second menu is activated if only
+ // disabled menu items are added
+
+ QMenu fileMenu("&File");
+ // Task 241043 : check that second menu is activated
+ // if all items are disabled
+ QAction *act = fileMenu.addAction("Disabled");
+ act->setEnabled(false);
+
+ mb->addMenu(&fileMenu);
+ QMenu disabledMenu("Disabled");
+ disabledMenu.setEnabled(false);
+ QMenu activeMenu("Active");
+ mb->addMenu(&disabledMenu);
+ mb->addMenu(&activeMenu);
+ mb->show();
+
+
+ // Here we verify that AllowActiveAndDisabled correctly skips
+ // the disabled menu entry
+ QTest::keyClick(mb, Qt::Key_F, Qt::AltModifier );
+ QTest::keyClick(&fileMenu, (Qt::Key_Right));
+ if (qApp->style()->styleHint(QStyle::SH_Menu_AllowActiveAndDisabled))
+ QCOMPARE(mb->activeAction()->text(), disabledMenu.title());
+ else
+ QCOMPARE(mb->activeAction()->text(), activeMenu.title());
+
+ QTest::keyClick(mb, (Qt::Key_Left));
+ if (qApp->style()->styleHint(QStyle::SH_Menu_AllowActiveAndDisabled))
+ QCOMPARE(mb->activeAction()->text(), fileMenu.title());
+ else
+ QCOMPARE(mb->activeAction()->text(), fileMenu.title());
+
+ mb->hide();
+#endif //Q_WS_MAC
+}
+
+void tst_QMenuBar::check_altPress()
+{
+ if ( !qApp->style()->styleHint(QStyle::SH_MenuBar_AltKeyNavigation) ) {
+ QSKIP( QString( "this is not supposed to work in the %1 style. Skipping." ).
+ arg( qApp->style()->objectName() ).toAscii(), SkipAll );
+ }
+
+ initSimpleMenubar();
+
+ qApp->setActiveWindow(mw);
+ mw->setFocus();
+
+ QTest::keyClick( mw, Qt::Key_Alt );
+
+ QVERIFY( ::qobject_cast<QMenuBar *>(qApp->focusWidget()) );
+}
+
+// Qt/Mac,WinCE does not use the native popups/menubar.
+#if !defined(Q_WS_MAC) && !defined(Q_OS_WINCE_WM)
+void tst_QMenuBar::check_shortcutPress()
+{
+ initComplexMenubar();
+
+ qApp->setActiveWindow(mw);
+ QCOMPARE(menu3->selCount(), 0u);
+ QTest::keyClick(mw, Qt::Key_E, Qt::AltModifier);
+ QTest::qWait(200);
+ QCOMPARE(menu3->selCount(), 1u);
+ QVERIFY(!mb->activeAction());
+
+ QTest::keyClick(mw, Qt::Key_1, Qt::AltModifier );
+ QVERIFY(pm1->isActiveWindow());
+ QTest::keyClick(mb, Qt::Key_2);
+ QVERIFY(pm1->isActiveWindow());
+}
+#endif
+
+// Qt/Mac does not use the native popups/menubar.
+// Qt/CE uses native menubar.
+#if !defined(Q_WS_MAC) && !defined(Q_OS_WINCE_WM)
+void tst_QMenuBar::check_menuPosition()
+{
+ Menu menu;
+ initComplexMenubar();
+ menu.setTitle("&menu");
+ QRect availRect = QApplication::desktop()->availableGeometry(mw);
+ QRect screenRect = QApplication::desktop()->screenGeometry(mw);
+
+ while(menu.sizeHint().height() < (screenRect.height()*2/3)) {
+ menu.addAction("item");
+ }
+
+ QAction *menu_action = mw->menuBar()->addMenu(&menu);
+
+ qApp->setActiveWindow(mw);
+ qApp->processEvents();
+
+ //the menu should be below the menubar item
+ {
+ mw->move(availRect.topLeft());
+ QRect mbItemRect = mw->menuBar()->actionGeometry(menu_action);
+ mbItemRect.moveTo(mw->menuBar()->mapToGlobal(mbItemRect.topLeft()));
+ QTest::keyClick(mw, Qt::Key_M, Qt::AltModifier );
+ QVERIFY(menu.isActiveWindow());
+ QCOMPARE(menu.pos(), QPoint(mbItemRect.x(), mbItemRect.bottom() + 1));
+ menu.close();
+ }
+
+ //the menu should be above the menubar item
+ {
+ mw->move(0,screenRect.bottom() - screenRect.height()/4); //just leave some place for the menubar
+ QRect mbItemRect = mw->menuBar()->actionGeometry(menu_action);
+ mbItemRect.moveTo(mw->menuBar()->mapToGlobal(mbItemRect.topLeft()));
+ QTest::keyClick(mw, Qt::Key_M, Qt::AltModifier );
+ QVERIFY(menu.isActiveWindow());
+ QCOMPARE(menu.pos(), QPoint(mbItemRect.x(), mbItemRect.top() - menu.height()));
+ menu.close();
+ }
+
+ //the menu should be on the side of the menubar item and should be "stuck" to the bottom of the screen
+ {
+ mw->move(0,screenRect.y() + screenRect.height()/2); //put it in the middle
+ QRect mbItemRect = mw->menuBar()->actionGeometry(menu_action);
+ mbItemRect.moveTo(mw->menuBar()->mapToGlobal(mbItemRect.topLeft()));
+ QTest::keyClick(mw, Qt::Key_M, Qt::AltModifier );
+ QVERIFY(menu.isActiveWindow());
+ QPoint firstPoint = QPoint(mbItemRect.right()+1, screenRect.bottom() - menu.height() + 1);
+ QPoint secondPoint = QPoint(mbItemRect.right()+1, availRect.bottom() - menu.height() + 1);
+ QVERIFY(menu.pos() == firstPoint || menu.pos() == secondPoint);
+ menu.close();
+ }
+
+ //in RTL, the menu should be stuck at the right of the action geometry
+ {
+ Qt::LayoutDirection dir = qApp->layoutDirection();
+ qApp->setLayoutDirection(Qt::RightToLeft);
+ menu.clear();
+ QObject::connect(&menu, SIGNAL(aboutToShow()), &menu, SLOT(addActions()));
+ QRect mbItemRect = mw->menuBar()->actionGeometry(menu_action);
+ mbItemRect.moveTo(mw->menuBar()->mapToGlobal(mbItemRect.topLeft()));
+ QTest::keyClick(mw, Qt::Key_M, Qt::AltModifier );
+ QVERIFY(menu.isActiveWindow());
+ QCOMPARE(menu.geometry().right(), mbItemRect.right());
+ menu.close();
+ qApp->setLayoutDirection(dir);
+ }
+}
+#endif
+
+void tst_QMenuBar::task223138_triggered()
+{
+ qRegisterMetaType<QAction *>("QAction *");
+ //we create a window with submenus and we check that both menubar and menus get the triggered signal
+ QMainWindow win;
+ QMenu *menu = win.menuBar()->addMenu("test");
+ QAction *top = menu->addAction("toplevelaction");
+ QMenu *submenu = menu->addMenu("nested menu");
+ QAction *action = submenu->addAction("nested action");
+
+ QSignalSpy menubarSpy(win.menuBar(), SIGNAL(triggered(QAction*)));
+ QSignalSpy menuSpy(menu, SIGNAL(triggered(QAction*)));
+ QSignalSpy submenuSpy(submenu, SIGNAL(triggered(QAction*)));
+
+ //let's trigger the first action
+ top->trigger();
+
+ QCOMPARE(menubarSpy.count(), 1);
+ QCOMPARE(menuSpy.count(), 1);
+ QCOMPARE(submenuSpy.count(), 0);
+
+ menubarSpy.clear();
+ menuSpy.clear();
+ submenuSpy.clear();
+
+ //let's trigger the sub action
+ action->trigger();
+ QCOMPARE(menubarSpy.count(), 1);
+ QCOMPARE(menuSpy.count(), 1);
+ QCOMPARE(submenuSpy.count(), 1);
+}
+
+void tst_QMenuBar::task256322_highlight()
+{
+ QMainWindow win;
+ win.menuBar()->setNativeMenuBar(false); //we can't check the geometry of native menubars
+ QMenu menu;
+ QAction *file = win.menuBar()->addMenu(&menu);
+ file->setText("file");
+ QMenu menu2;
+ QAction *file2 = win.menuBar()->addMenu(&menu2);
+ file2->setText("file2");
+ QAction *nothing = win.menuBar()->addAction("nothing");
+
+ win.show();
+ QTest::qWait(200);
+
+ QTest::mousePress(win.menuBar(), Qt::LeftButton, 0, win.menuBar()->actionGeometry(file).center());
+ QTest::mouseMove(win.menuBar(), win.menuBar()->actionGeometry(file).center());
+ QTest::mouseRelease(win.menuBar(), Qt::LeftButton, 0, win.menuBar()->actionGeometry(file).center());
+ QTRY_VERIFY(menu.isVisible());
+ QVERIFY(!menu2.isVisible());
+ QCOMPARE(win.menuBar()->activeAction(), file);
+
+ QTest::mousePress(win.menuBar(), Qt::LeftButton, 0, win.menuBar()->actionGeometry(file2).center());
+ QTest::mouseMove(win.menuBar(), win.menuBar()->actionGeometry(file2).center());
+ QTRY_VERIFY(!menu.isVisible());
+ QVERIFY(menu2.isVisible());
+ QCOMPARE(win.menuBar()->activeAction(), file2);
+ QTest::mouseRelease(win.menuBar(), Qt::LeftButton, 0, win.menuBar()->actionGeometry(file2).center());
+
+ QPoint nothingCenter = win.menuBar()->actionGeometry(nothing).center();
+ QTest::mousePress(win.menuBar(), Qt::LeftButton, 0, nothingCenter);
+ QTest::mouseMove(win.menuBar(), nothingCenter);
+ QTRY_VERIFY(!menu2.isVisible());
+ QVERIFY(!menu.isVisible());
+ QCOMPARE(win.menuBar()->activeAction(), nothing);
+ QTest::mouseRelease(win.menuBar(), Qt::LeftButton, 0, nothingCenter);
+}
+
+void tst_QMenuBar::menubarSizeHint()
+{
+ struct MyStyle : public QWindowsStyle
+ {
+ virtual int pixelMetric(PixelMetric metric, const QStyleOption * option = 0, const QWidget * widget = 0 ) const
+ {
+ // I chose strange values (prime numbers to be more sure that the size of the menubar is correct)
+ switch (metric)
+ {
+ case QStyle::PM_MenuBarItemSpacing:
+ return 7;
+ case PM_MenuBarHMargin:
+ return 13;
+ case PM_MenuBarVMargin:
+ return 11;
+ case PM_MenuBarPanelWidth:
+ return 1;
+ default:
+ return QWindowsStyle::pixelMetric(metric, option, widget);
+ }
+ }
+ } style;
+
+ QMenuBar mb;
+ mb.setNativeMenuBar(false); //we can't check the geometry of native menubars
+
+ mb.setStyle(&style);
+ //this is a list of arbitrary strings so that we check the geometry
+ QStringList list = QStringList() << "trer" << "ezrfgtgvqd" << "sdgzgzerzerzer" << "eerzertz" << "er";
+ foreach(QString str, list)
+ mb.addAction(str);
+
+ const int panelWidth = style.pixelMetric(QStyle::PM_MenuBarPanelWidth);
+ const int hmargin = style.pixelMetric(QStyle::PM_MenuBarHMargin);
+ const int vmargin = style.pixelMetric(QStyle::PM_MenuBarVMargin);
+ const int spacing = style.pixelMetric(QStyle::PM_MenuBarItemSpacing);
+
+ mb.show();
+ QRect result;
+ foreach(QAction *action, mb.actions()) {
+ const QRect actionRect = mb.actionGeometry(action);
+ if (!result.isNull()) //this is the first item
+ QCOMPARE(actionRect.left() - result.right() - 1, spacing);
+ result |= actionRect;
+ QCOMPARE(result.x(), panelWidth + hmargin + spacing);
+ QCOMPARE(result.y(), panelWidth + vmargin);
+ }
+
+ //this code is copied from QMenuBar
+ //there is no public member that allows to initialize a styleoption instance
+ QStyleOptionMenuItem opt;
+ opt.rect = mb.rect();
+ opt.menuRect = mb.rect();
+ opt.state = QStyle::State_None;
+ opt.menuItemType = QStyleOptionMenuItem::Normal;
+ opt.checkType = QStyleOptionMenuItem::NotCheckable;
+ opt.palette = mb.palette();
+
+ QSize resSize = QSize(result.x(), result.y()) + result.size()
+ + QSize(panelWidth + hmargin, panelWidth + vmargin);
+
+
+ resSize = style.sizeFromContents(QStyle::CT_MenuBar, &opt,
+ resSize.expandedTo(QApplication::globalStrut()),
+ &mb);
+
+ QCOMPARE(resSize, mb.sizeHint());
+}
+
+// On Mac, do not test the menubar with escape key.
+#ifndef Q_WS_MAC
+void tst_QMenuBar::taskQTBUG4965_escapeEaten()
+{
+ QMenuBar menubar;
+ QMenu menu("menu1");
+ QAction *first = menubar.addMenu(&menu);
+ menu.addAction("quit", &menubar, SLOT(close()), QKeySequence("ESC"));
+ menubar.show();
+ QApplication::setActiveWindow(&menubar);
+ QTest::qWaitForWindowShown(&menubar);
+ menubar.setActiveAction(first);
+ QTRY_VERIFY(menu.isVisible());
+ QCOMPARE(menubar.activeAction(), first);
+ QTest::keyClick(static_cast<QWidget *>(0), Qt::Key_Escape);
+ QVERIFY(!menu.isVisible());
+ QTRY_VERIFY(menubar.hasFocus());
+ QCOMPARE(menubar.activeAction(), first);
+ QTest::keyClick(static_cast<QWidget *>(0), Qt::Key_Escape);
+ QVERIFY(!menubar.activeAction());
+ QTest::keyClick(static_cast<QWidget *>(0), Qt::Key_Escape); //now the action should be triggered
+ QTRY_VERIFY(!menubar.isVisible());
+}
+#endif
+
+void tst_QMenuBar::taskQTBUG11823_crashwithInvisibleActions()
+{
+ QMenuBar menubar;
+ menubar.setNativeMenuBar(false); //we can't check the geometry of native menubars
+
+ QAction * m = menubar.addAction( "&m" );
+ QAction * a = menubar.addAction( "&a" );
+
+ menubar.show();
+ QTest::qWaitForWindowShown(&menubar);
+ QApplication::setActiveWindow(&menubar);
+ menubar.setActiveAction(m);
+ QCOMPARE(menubar.activeAction(), m);
+ QTest::keyClick(static_cast<QWidget *>(0), Qt::Key_Right);
+ QCOMPARE(menubar.activeAction(), a);
+ QTest::keyClick(static_cast<QWidget *>(0), Qt::Key_Right);
+ QCOMPARE(menubar.activeAction(), m);
+ a->setVisible(false);
+
+ menubar.setActiveAction(m);
+ QCOMPARE(menubar.activeAction(), m); //the active action shouldn't have changed
+
+ //it used to crash here because the action is invisible
+ QTest::keyClick(static_cast<QWidget *>(0), Qt::Key_Right);
+ QCOMPARE(menubar.activeAction(), m); //the active action shouldn't have changed
+}
+
+QTEST_MAIN(tst_QMenuBar)
+#include "tst_qmenubar.moc"
diff --git a/tests/auto/widgets/widgets/qplaintextedit/.gitignore b/tests/auto/widgets/widgets/qplaintextedit/.gitignore
new file mode 100644
index 0000000000..5d47310409
--- /dev/null
+++ b/tests/auto/widgets/widgets/qplaintextedit/.gitignore
@@ -0,0 +1 @@
+tst_qplaintextedit
diff --git a/tests/auto/widgets/widgets/qplaintextedit/qplaintextedit.pro b/tests/auto/widgets/widgets/qplaintextedit/qplaintextedit.pro
new file mode 100644
index 0000000000..feac5e3f43
--- /dev/null
+++ b/tests/auto/widgets/widgets/qplaintextedit/qplaintextedit.pro
@@ -0,0 +1,10 @@
+load(qttest_p4)
+
+QT += widgets widgets-private
+QT += gui-private
+
+INCLUDEPATH += ../
+
+HEADERS +=
+SOURCES += tst_qplaintextedit.cpp
+
diff --git a/tests/auto/widgets/widgets/qplaintextedit/tst_qplaintextedit.cpp b/tests/auto/widgets/widgets/qplaintextedit/tst_qplaintextedit.cpp
new file mode 100644
index 0000000000..d847f295e0
--- /dev/null
+++ b/tests/auto/widgets/widgets/qplaintextedit/tst_qplaintextedit.cpp
@@ -0,0 +1,1524 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#include <QtTest/QtTest>
+
+
+#include <qtextedit.h>
+#include <qtextcursor.h>
+#include <qtextlist.h>
+#include <qdebug.h>
+#include <qapplication.h>
+#include <qclipboard.h>
+#include <qtextbrowser.h>
+#include <private/qwidgettextcontrol_p.h>
+#include <qscrollbar.h>
+#include <qtextobject.h>
+
+#include <qabstracttextdocumentlayout.h>
+#include <qtextdocumentfragment.h>
+
+#include "qplaintextedit.h"
+
+//Used in copyAvailable
+typedef QPair<Qt::Key, Qt::KeyboardModifier> keyPairType;
+typedef QList<keyPairType> pairListType;
+Q_DECLARE_METATYPE(pairListType);
+Q_DECLARE_METATYPE(keyPairType);
+Q_DECLARE_METATYPE(QList<bool>);
+
+#ifdef Q_WS_MAC
+#include <Carbon/Carbon.h>
+#endif
+
+QT_FORWARD_DECLARE_CLASS(QPlainTextEdit)
+
+//TESTED_CLASS=
+//TESTED_FILES=gui/widgets/qtextedit.h gui/widgets/qtextedit.cpp
+
+class tst_QPlainTextEdit : public QObject
+{
+ Q_OBJECT
+public:
+ tst_QPlainTextEdit();
+
+public slots:
+ void initTestCase();
+ void init();
+ void cleanup();
+private slots:
+ void getSetCheck();
+#ifndef QT_NO_CLIPBOARD
+ void clearMustNotChangeClipboard();
+#endif
+ void clearMustNotResetRootFrameMarginToDefault();
+ void paragSeparatorOnPlaintextAppend();
+#ifndef QT_NO_CLIPBOARD
+ void selectAllSetsNotSelection();
+#endif
+ void asciiTab();
+ void setDocument();
+ void emptyAppend();
+ void appendOnEmptyDocumentShouldReuseInitialParagraph();
+ void cursorPositionChanged();
+ void setTextCursor();
+#ifndef QT_NO_CLIPBOARD
+ void undoAvailableAfterPaste();
+#endif
+ void undoRedoAvailableRepetition();
+ void appendShouldNotTouchTheSelection();
+ void backspace();
+ void shiftBackspace();
+ void undoRedo();
+ void preserveCharFormatInAppend();
+#ifndef QT_NO_CLIPBOARD
+ void copyAndSelectAllInReadonly();
+#endif
+ void ctrlAltInput();
+ void noPropertiesOnDefaultTextEditCharFormat();
+ void setPlainTextShouldEmitTextChangedOnce();
+ void overwriteMode();
+ void shiftDownInLineLastShouldSelectToEnd_data();
+ void shiftDownInLineLastShouldSelectToEnd();
+ void undoRedoShouldRepositionTextEditCursor();
+ void lineWrapModes();
+ void mouseCursorShape();
+ void implicitClear();
+ void undoRedoAfterSetContent();
+ void numPadKeyNavigation();
+ void moveCursor();
+#ifndef QT_NO_CLIPBOARD
+ void mimeDataReimplementations();
+#endif
+ void shiftEnterShouldInsertLineSeparator();
+ void selectWordsFromStringsContainingSeparators_data();
+ void selectWordsFromStringsContainingSeparators();
+#ifndef QT_NO_CLIPBOARD
+ void canPaste();
+ void copyAvailable_data();
+ void copyAvailable();
+#endif
+ void ensureCursorVisibleOnInitialShow();
+ void setTextInsideResizeEvent();
+ void colorfulAppend();
+ void ensureVisibleWithRtl();
+ void preserveCharFormatAfterSetPlainText();
+ void extraSelections();
+ void adjustScrollbars();
+ void textObscuredByScrollbars();
+ void setTextPreservesUndoRedoEnabled();
+ void wordWrapProperty();
+ void lineWrapProperty();
+ void selectionChanged();
+ void blockCountChanged();
+ void insertAndScrollToBottom();
+
+private:
+ void createSelection();
+ int blockCount() const;
+ int lineCount() const;
+ bool nativeClipboardWorking();
+
+ QPlainTextEdit *ed;
+ qreal rootFrameMargin;
+};
+
+bool tst_QPlainTextEdit::nativeClipboardWorking()
+{
+#ifdef Q_WS_MAC
+ PasteboardRef pasteboard;
+ OSStatus status = PasteboardCreate(0, &pasteboard);
+ if (status == noErr)
+ CFRelease(pasteboard);
+ return status == noErr;
+#endif
+ return true;
+}
+
+// Testing get/set functions
+void tst_QPlainTextEdit::getSetCheck()
+{
+ QPlainTextEdit obj1;
+ // QTextDocument * QPlainTextEdit::document()
+ // void QPlainTextEdit::setDocument(QTextDocument *)
+ QTextDocument *var1 = new QTextDocument;
+ var1->setDocumentLayout(new QPlainTextDocumentLayout(var1));
+ obj1.setDocument(var1);
+ QCOMPARE(var1, obj1.document());
+ obj1.setDocument((QTextDocument *)0);
+ QVERIFY(var1 != obj1.document()); // QPlainTextEdit creates a new document when setting 0
+ QVERIFY((QTextDocument *)0 != obj1.document());
+ delete var1;
+
+
+ // bool QPlainTextEdit::tabChangesFocus()
+ // void QPlainTextEdit::setTabChangesFocus(bool)
+ obj1.setTabChangesFocus(false);
+ QCOMPARE(false, obj1.tabChangesFocus());
+ obj1.setTabChangesFocus(true);
+ QCOMPARE(true, obj1.tabChangesFocus());
+
+ // LineWrapMode QPlainTextEdit::lineWrapMode()
+ // void QPlainTextEdit::setLineWrapMode(LineWrapMode)
+ obj1.setLineWrapMode(QPlainTextEdit::LineWrapMode(QPlainTextEdit::NoWrap));
+ QCOMPARE(QPlainTextEdit::LineWrapMode(QPlainTextEdit::NoWrap), obj1.lineWrapMode());
+ obj1.setLineWrapMode(QPlainTextEdit::LineWrapMode(QPlainTextEdit::WidgetWidth));
+ QCOMPARE(QPlainTextEdit::LineWrapMode(QPlainTextEdit::WidgetWidth), obj1.lineWrapMode());
+// obj1.setLineWrapMode(QPlainTextEdit::LineWrapMode(QPlainTextEdit::FixedPixelWidth));
+// QCOMPARE(QPlainTextEdit::LineWrapMode(QPlainTextEdit::FixedPixelWidth), obj1.lineWrapMode());
+// obj1.setLineWrapMode(QPlainTextEdit::LineWrapMode(QPlainTextEdit::FixedColumnWidth));
+// QCOMPARE(QPlainTextEdit::LineWrapMode(QPlainTextEdit::FixedColumnWidth), obj1.lineWrapMode());
+
+
+ // bool QPlainTextEdit::overwriteMode()
+ // void QPlainTextEdit::setOverwriteMode(bool)
+ obj1.setOverwriteMode(false);
+ QCOMPARE(false, obj1.overwriteMode());
+ obj1.setOverwriteMode(true);
+ QCOMPARE(true, obj1.overwriteMode());
+
+ // int QPlainTextEdit::tabStopWidth()
+ // void QPlainTextEdit::setTabStopWidth(int)
+ obj1.setTabStopWidth(0);
+ QCOMPARE(0, obj1.tabStopWidth());
+ obj1.setTabStopWidth(INT_MIN);
+ QCOMPARE(0, obj1.tabStopWidth()); // Makes no sense to set a negative tabstop value
+#if defined(QT_ARCH_WINDOWSCE)
+ // due to rounding error in qRound when qreal==float
+ // we cannot use INT_MAX for this check
+ obj1.setTabStopWidth(SHRT_MAX*2);
+ QCOMPARE(SHRT_MAX*2, obj1.tabStopWidth());
+#else
+ obj1.setTabStopWidth(INT_MAX);
+ QCOMPARE(INT_MAX, obj1.tabStopWidth());
+#endif
+
+}
+
+class QtTestDocumentLayout : public QAbstractTextDocumentLayout
+{
+ Q_OBJECT
+public:
+ inline QtTestDocumentLayout(QPlainTextEdit *edit, QTextDocument *doc, int &itCount)
+ : QAbstractTextDocumentLayout(doc), useBiggerSize(false), ed(edit), iterationCounter(itCount) {}
+
+ virtual void draw(QPainter *, const QAbstractTextDocumentLayout::PaintContext &) {}
+
+ virtual int hitTest(const QPointF &, Qt::HitTestAccuracy ) const { return 0; }
+
+ virtual void documentChanged(int, int, int) {}
+
+ virtual int pageCount() const { return 1; }
+
+ virtual QSizeF documentSize() const { return usedSize; }
+
+ virtual QRectF frameBoundingRect(QTextFrame *) const { return QRectF(); }
+ virtual QRectF blockBoundingRect(const QTextBlock &) const { return QRectF(); }
+
+ bool useBiggerSize;
+ QSize usedSize;
+
+ QPlainTextEdit *ed;
+
+ int &iterationCounter;
+};
+
+tst_QPlainTextEdit::tst_QPlainTextEdit()
+{}
+
+void tst_QPlainTextEdit::initTestCase()
+{
+#ifdef Q_OS_WINCE //disable magic for WindowsCE
+ qApp->setAutoMaximizeThreshold(-1);
+#endif
+}
+
+void tst_QPlainTextEdit::init()
+{
+ ed = new QPlainTextEdit(0);
+ rootFrameMargin = ed->document()->documentMargin();
+}
+
+void tst_QPlainTextEdit::cleanup()
+{
+ delete ed;
+ ed = 0;
+}
+
+
+void tst_QPlainTextEdit::createSelection()
+{
+ QTest::keyClicks(ed, "Hello World");
+ /* go to start */
+#ifndef Q_WS_MAC
+ QTest::keyClick(ed, Qt::Key_Home, Qt::ControlModifier);
+#else
+ QTest::keyClick(ed, Qt::Key_Home);
+#endif
+ QCOMPARE(ed->textCursor().position(), 0);
+ /* select until end of text */
+#ifndef Q_WS_MAC
+ QTest::keyClick(ed, Qt::Key_End, Qt::ControlModifier | Qt::ShiftModifier);
+#else
+ QTest::keyClick(ed, Qt::Key_End, Qt::ShiftModifier);
+#endif
+ QCOMPARE(ed->textCursor().position(), 11);
+}
+#ifndef QT_NO_CLIPBOARD
+void tst_QPlainTextEdit::clearMustNotChangeClipboard()
+{
+ if (!nativeClipboardWorking())
+ QSKIP("Clipboard not working with cron-started unit tests", SkipAll);
+ ed->textCursor().insertText("Hello World");
+ QString txt("This is different text");
+ QApplication::clipboard()->setText(txt);
+ ed->clear();
+ QCOMPARE(QApplication::clipboard()->text(), txt);
+}
+#endif
+
+void tst_QPlainTextEdit::clearMustNotResetRootFrameMarginToDefault()
+{
+ QCOMPARE(ed->document()->rootFrame()->frameFormat().margin(), rootFrameMargin);
+ ed->clear();
+ QCOMPARE(ed->document()->rootFrame()->frameFormat().margin(), rootFrameMargin);
+}
+
+
+void tst_QPlainTextEdit::paragSeparatorOnPlaintextAppend()
+{
+ ed->appendPlainText("Hello\nWorld");
+ int cnt = 0;
+ QTextBlock blk = ed->document()->begin();
+ while (blk.isValid()) {
+ ++cnt;
+ blk = blk.next();
+ }
+ QCOMPARE(cnt, 2);
+}
+
+#ifndef QT_NO_CLIPBOARD
+void tst_QPlainTextEdit::selectAllSetsNotSelection()
+{
+ if (!QApplication::clipboard()->supportsSelection())
+ QSKIP("Test only relevant for systems with selection", SkipAll);
+
+ QApplication::clipboard()->setText(QString("foobar"), QClipboard::Selection);
+ QVERIFY(QApplication::clipboard()->text(QClipboard::Selection) == QString("foobar"));
+
+ ed->insertPlainText("Hello World");
+ ed->selectAll();
+
+ QCOMPARE(QApplication::clipboard()->text(QClipboard::Selection), QString::fromAscii("foobar"));
+}
+#endif
+
+void tst_QPlainTextEdit::asciiTab()
+{
+ QPlainTextEdit edit;
+ edit.setPlainText("\t");
+ edit.show();
+ qApp->processEvents();
+ QCOMPARE(edit.toPlainText().at(0), QChar('\t'));
+}
+
+void tst_QPlainTextEdit::setDocument()
+{
+ QTextDocument *document = new QTextDocument(ed);
+ document->setDocumentLayout(new QPlainTextDocumentLayout(document));
+ QTextCursor(document).insertText("Test");
+ ed->setDocument(document);
+ QCOMPARE(ed->toPlainText(), QString("Test"));
+}
+
+
+int tst_QPlainTextEdit::blockCount() const
+{
+ int blocks = 0;
+ for (QTextBlock block = ed->document()->begin(); block.isValid(); block = block.next())
+ ++blocks;
+ return blocks;
+}
+
+int tst_QPlainTextEdit::lineCount() const
+{
+ int lines = 0;
+ for (QTextBlock block = ed->document()->begin(); block.isValid(); block = block.next()) {
+ ed->document()->documentLayout()->blockBoundingRect(block);
+ lines += block.layout()->lineCount();
+ }
+ return lines;
+}
+
+// Supporter issue #56783
+void tst_QPlainTextEdit::emptyAppend()
+{
+ ed->appendPlainText("Blah");
+ QCOMPARE(blockCount(), 1);
+ ed->appendPlainText(QString::null);
+ QCOMPARE(blockCount(), 2);
+ ed->appendPlainText(QString(" "));
+ QCOMPARE(blockCount(), 3);
+}
+
+void tst_QPlainTextEdit::appendOnEmptyDocumentShouldReuseInitialParagraph()
+{
+ QCOMPARE(blockCount(), 1);
+ ed->appendPlainText("Blah");
+ QCOMPARE(blockCount(), 1);
+}
+
+
+class CursorPositionChangedRecorder : public QObject
+{
+ Q_OBJECT
+public:
+ inline CursorPositionChangedRecorder(QPlainTextEdit *ed)
+ : editor(ed)
+ {
+ connect(editor, SIGNAL(cursorPositionChanged()), this, SLOT(recordCursorPos()));
+ }
+
+ QList<int> cursorPositions;
+
+private slots:
+ void recordCursorPos()
+ {
+ cursorPositions.append(editor->textCursor().position());
+ }
+
+private:
+ QPlainTextEdit *editor;
+};
+
+void tst_QPlainTextEdit::cursorPositionChanged()
+{
+ QSignalSpy spy(ed, SIGNAL(cursorPositionChanged()));
+
+ spy.clear();
+ QTest::keyClick(ed, Qt::Key_A);
+ QCOMPARE(spy.count(), 1);
+
+ QTextCursor cursor = ed->textCursor();
+ cursor.movePosition(QTextCursor::Start);
+ ed->setTextCursor(cursor);
+ cursor.movePosition(QTextCursor::End);
+ spy.clear();
+ cursor.insertText("Test");
+ QCOMPARE(spy.count(), 0);
+
+ cursor.movePosition(QTextCursor::End);
+ ed->setTextCursor(cursor);
+ cursor.movePosition(QTextCursor::Start);
+ spy.clear();
+ cursor.insertText("Test");
+ QCOMPARE(spy.count(), 1);
+
+ spy.clear();
+ QTest::keyClick(ed, Qt::Key_Left);
+ QCOMPARE(spy.count(), 1);
+
+ CursorPositionChangedRecorder spy2(ed);
+ QVERIFY(ed->textCursor().position() > 0);
+ ed->setPlainText("Hello World");
+ QCOMPARE(spy2.cursorPositions.count(), 1);
+ QCOMPARE(spy2.cursorPositions.at(0), 0);
+ QCOMPARE(ed->textCursor().position(), 0);
+}
+
+void tst_QPlainTextEdit::setTextCursor()
+{
+ QSignalSpy spy(ed, SIGNAL(cursorPositionChanged()));
+
+ ed->setPlainText("Test");
+ QTextCursor cursor = ed->textCursor();
+ cursor.movePosition(QTextCursor::Start);
+ cursor.movePosition(QTextCursor::NextCharacter);
+
+ spy.clear();
+
+ ed->setTextCursor(cursor);
+ QCOMPARE(spy.count(), 1);
+}
+
+#ifndef QT_NO_CLIPBOARD
+void tst_QPlainTextEdit::undoAvailableAfterPaste()
+{
+ if (!nativeClipboardWorking())
+ QSKIP("Clipboard not working with cron-started unit tests", SkipAll);
+
+ QSignalSpy spy(ed->document(), SIGNAL(undoAvailable(bool)));
+
+ const QString txt("Test");
+ QApplication::clipboard()->setText(txt);
+ ed->paste();
+ QVERIFY(spy.count() >= 1);
+ QCOMPARE(ed->toPlainText(), txt);
+}
+#endif
+
+class UndoRedoRecorder : public QObject
+{
+ Q_OBJECT
+public:
+ UndoRedoRecorder(QTextDocument *doc)
+ : undoRepetitions(false)
+ , redoRepetitions(false)
+ , undoCount(0)
+ , redoCount(0)
+ {
+ connect(doc, SIGNAL(undoAvailable(bool)), this, SLOT(undoAvailable(bool)));
+ connect(doc, SIGNAL(redoAvailable(bool)), this, SLOT(redoAvailable(bool)));
+ }
+
+ bool undoRepetitions;
+ bool redoRepetitions;
+
+private slots:
+ void undoAvailable(bool enabled) {
+ if (undoCount > 0 && enabled == lastUndoEnabled)
+ undoRepetitions = true;
+
+ ++undoCount;
+ lastUndoEnabled = enabled;
+ }
+
+ void redoAvailable(bool enabled) {
+ if (redoCount > 0 && enabled == lastRedoEnabled)
+ redoRepetitions = true;
+
+ ++redoCount;
+ lastRedoEnabled = enabled;
+ }
+
+private:
+ bool lastUndoEnabled;
+ bool lastRedoEnabled;
+
+ int undoCount;
+ int redoCount;
+};
+
+void tst_QPlainTextEdit::undoRedoAvailableRepetition()
+{
+ UndoRedoRecorder spy(ed->document());
+
+ ed->textCursor().insertText("ABC\n\nDEF\n\nGHI\n");
+ ed->textCursor().insertText("foo\n");
+ ed->textCursor().insertText("bar\n");
+ ed->undo(); ed->undo(); ed->undo();
+ ed->redo(); ed->redo(); ed->redo();
+
+ QVERIFY(!spy.undoRepetitions);
+ QVERIFY(!spy.redoRepetitions);
+}
+
+void tst_QPlainTextEdit::appendShouldNotTouchTheSelection()
+{
+ QTextCursor cursor(ed->document());
+ QTextCharFormat fmt;
+ fmt.setForeground(Qt::blue);
+ cursor.insertText("H", fmt);
+ fmt.setForeground(Qt::red);
+ cursor.insertText("ey", fmt);
+
+ cursor.insertText("some random text inbetween");
+
+ cursor.movePosition(QTextCursor::Start);
+ cursor.movePosition(QTextCursor::NextCharacter, QTextCursor::KeepAnchor);
+ QCOMPARE(cursor.charFormat().foreground().color(), QColor(Qt::blue));
+ cursor.movePosition(QTextCursor::NextCharacter, QTextCursor::KeepAnchor);
+ QCOMPARE(cursor.charFormat().foreground().color(), QColor(Qt::red));
+ cursor.movePosition(QTextCursor::NextCharacter, QTextCursor::KeepAnchor);
+ QCOMPARE(cursor.charFormat().foreground().color(), QColor(Qt::red));
+ QCOMPARE(cursor.selectedText(), QString("Hey"));
+
+ ed->setTextCursor(cursor);
+ QVERIFY(ed->textCursor().hasSelection());
+
+ ed->appendHtml("<b>Some Bold Text</b>");
+ cursor.movePosition(QTextCursor::Start);
+ cursor.movePosition(QTextCursor::NextCharacter);
+ QCOMPARE(cursor.charFormat().foreground().color(), QColor(Qt::blue));
+}
+
+void tst_QPlainTextEdit::backspace()
+{
+ QTextCursor cursor = ed->textCursor();
+
+ QTextListFormat listFmt;
+ listFmt.setStyle(QTextListFormat::ListDisc);
+ listFmt.setIndent(1);
+ cursor.insertList(listFmt);
+ cursor.insertText("A");
+
+ ed->setTextCursor(cursor);
+
+ // delete 'A'
+ QTest::keyClick(ed, Qt::Key_Backspace);
+ QVERIFY(ed->textCursor().currentList());
+ // delete list
+ QTest::keyClick(ed, Qt::Key_Backspace);
+ QVERIFY(!ed->textCursor().currentList());
+ QCOMPARE(ed->textCursor().blockFormat().indent(), 1);
+ // outdent paragraph
+ QTest::keyClick(ed, Qt::Key_Backspace);
+ QCOMPARE(ed->textCursor().blockFormat().indent(), 0);
+}
+
+void tst_QPlainTextEdit::shiftBackspace()
+{
+ QTextCursor cursor = ed->textCursor();
+
+ QTextListFormat listFmt;
+ listFmt.setStyle(QTextListFormat::ListDisc);
+ listFmt.setIndent(1);
+ cursor.insertList(listFmt);
+ cursor.insertText("A");
+
+ ed->setTextCursor(cursor);
+
+ // delete 'A'
+ QTest::keyClick(ed, Qt::Key_Backspace, Qt::ShiftModifier);
+ QVERIFY(ed->textCursor().currentList());
+ // delete list
+ QTest::keyClick(ed, Qt::Key_Backspace, Qt::ShiftModifier);
+ QVERIFY(!ed->textCursor().currentList());
+ QCOMPARE(ed->textCursor().blockFormat().indent(), 1);
+ // outdent paragraph
+ QTest::keyClick(ed, Qt::Key_Backspace, Qt::ShiftModifier);
+ QCOMPARE(ed->textCursor().blockFormat().indent(), 0);
+}
+
+void tst_QPlainTextEdit::undoRedo()
+{
+ ed->clear();
+ QTest::keyClicks(ed, "abc d");
+ QCOMPARE(ed->toPlainText(), QString("abc d"));
+ ed->undo();
+ QCOMPARE(ed->toPlainText(), QString());
+ ed->redo();
+ QCOMPARE(ed->toPlainText(), QString("abc d"));
+#ifdef Q_WS_WIN
+ // shortcut for undo
+ QTest::keyClick(ed, Qt::Key_Backspace, Qt::AltModifier);
+ QCOMPARE(ed->toPlainText(), QString());
+ // shortcut for redo
+ QTest::keyClick(ed, Qt::Key_Backspace, Qt::ShiftModifier|Qt::AltModifier);
+ QCOMPARE(ed->toPlainText(), QString("abc d"));
+#endif
+}
+
+// Task #70465
+void tst_QPlainTextEdit::preserveCharFormatInAppend()
+{
+ ed->appendHtml("First para");
+ ed->appendHtml("<b>Second para</b>");
+ ed->appendHtml("third para");
+
+ QTextCursor cursor(ed->textCursor());
+
+ cursor.movePosition(QTextCursor::Start);
+ cursor.movePosition(QTextCursor::NextCharacter);
+ QCOMPARE(cursor.charFormat().fontWeight(), (int)QFont::Normal);
+ QCOMPARE(cursor.block().text(), QString("First para"));
+
+ cursor.movePosition(QTextCursor::NextBlock);
+ cursor.movePosition(QTextCursor::NextCharacter);
+ QCOMPARE(cursor.charFormat().fontWeight(), (int)QFont::Bold);
+ QCOMPARE(cursor.block().text(), QString("Second para"));
+
+ cursor.movePosition(QTextCursor::NextBlock);
+ cursor.movePosition(QTextCursor::NextCharacter);
+ QCOMPARE(cursor.charFormat().fontWeight(), (int)QFont::Normal);
+ QCOMPARE(cursor.block().text(), QString("third para"));
+}
+
+#ifndef QT_NO_CLIPBOARD
+void tst_QPlainTextEdit::copyAndSelectAllInReadonly()
+{
+ if (!nativeClipboardWorking())
+ QSKIP("Clipboard not working with cron-started unit tests", SkipAll);
+
+ ed->setReadOnly(true);
+ ed->setPlainText("Hello World");
+
+ QTextCursor cursor = ed->textCursor();
+ cursor.clearSelection();
+ ed->setTextCursor(cursor);
+ QVERIFY(!ed->textCursor().hasSelection());
+
+ QCOMPARE(ed->toPlainText(), QString("Hello World"));
+
+ // shouldn't do anything
+ QTest::keyClick(ed, Qt::Key_A);
+
+ QCOMPARE(ed->toPlainText(), QString("Hello World"));
+
+ QTest::keyClick(ed, Qt::Key_A, Qt::ControlModifier);
+
+ QVERIFY(ed->textCursor().hasSelection());
+
+ QApplication::clipboard()->setText(QString());
+ QVERIFY(QApplication::clipboard()->text().isEmpty());
+
+ QTest::keyClick(ed, Qt::Key_C, Qt::ControlModifier);
+ QCOMPARE(QApplication::clipboard()->text(), QString("Hello World"));
+}
+#endif
+
+void tst_QPlainTextEdit::ctrlAltInput()
+{
+ QTest::keyClick(ed, Qt::Key_At, Qt::ControlModifier | Qt::AltModifier);
+ QCOMPARE(ed->toPlainText(), QString("@"));
+}
+
+void tst_QPlainTextEdit::noPropertiesOnDefaultTextEditCharFormat()
+{
+ // there should be no properties set on the default/initial char format
+ // on a text edit. Font properties instead should be taken from the
+ // widget's font (in sync with defaultFont property in document) and the
+ // foreground color should be taken from the palette.
+ QCOMPARE(ed->textCursor().charFormat().properties().count(), 0);
+}
+
+void tst_QPlainTextEdit::setPlainTextShouldEmitTextChangedOnce()
+{
+ QSignalSpy spy(ed, SIGNAL(textChanged()));
+ ed->setPlainText("Yankee Doodle");
+ QCOMPARE(spy.count(), 1);
+ ed->setPlainText("");
+ QCOMPARE(spy.count(), 2);
+}
+
+void tst_QPlainTextEdit::overwriteMode()
+{
+ QVERIFY(!ed->overwriteMode());
+ QTest::keyClicks(ed, "Some first text");
+
+ QCOMPARE(ed->toPlainText(), QString("Some first text"));
+
+ ed->setOverwriteMode(true);
+
+ QTextCursor cursor = ed->textCursor();
+ cursor.setPosition(5);
+ ed->setTextCursor(cursor);
+
+ QTest::keyClicks(ed, "shiny");
+ QCOMPARE(ed->toPlainText(), QString("Some shiny text"));
+
+ cursor.movePosition(QTextCursor::End);
+ ed->setTextCursor(cursor);
+
+ QTest::keyClick(ed, Qt::Key_Enter);
+
+ ed->setOverwriteMode(false);
+ QTest::keyClicks(ed, "Second paragraph");
+
+ QCOMPARE(blockCount(), 2);
+
+ cursor.movePosition(QTextCursor::Start);
+ cursor.movePosition(QTextCursor::EndOfBlock);
+
+ QCOMPARE(cursor.position(), 15);
+ ed->setTextCursor(cursor);
+
+ ed->setOverwriteMode(true);
+
+ QTest::keyClicks(ed, " blah");
+
+ QCOMPARE(blockCount(), 2);
+
+ QTextBlock block = ed->document()->begin();
+ QCOMPARE(block.text(), QString("Some shiny text blah"));
+ block = block.next();
+ QCOMPARE(block.text(), QString("Second paragraph"));
+}
+
+void tst_QPlainTextEdit::shiftDownInLineLastShouldSelectToEnd_data()
+{
+ // shift cursor-down in the last line should select to the end of the document
+
+ QTest::addColumn<QString>("input");
+ QTest::addColumn<int>("totalLineCount");
+
+ QTest::newRow("1") << QString("Foo\nBar") << 2;
+ QTest::newRow("2") << QString("Foo\nBar") + QChar(QChar::LineSeparator) + QString("Baz") << 3;
+}
+
+void tst_QPlainTextEdit::shiftDownInLineLastShouldSelectToEnd()
+{
+ QFETCH(QString, input);
+ QFETCH(int, totalLineCount);
+
+ ed->setPlainText(input);
+ ed->show();
+
+ // ensure we're layouted
+ for (QTextBlock block = ed->document()->begin(); block.isValid(); block = block.next())
+ ed->document()->documentLayout()->blockBoundingRect(block);
+
+ QCOMPARE(blockCount(), 2);
+
+ int lineCount = 0;
+ for (QTextBlock block = ed->document()->begin(); block.isValid(); block = block.next())
+ lineCount += block.layout()->lineCount();
+ QCOMPARE(lineCount, totalLineCount);
+
+ QTextCursor cursor = ed->textCursor();
+ cursor.movePosition(QTextCursor::Start);
+ ed->setTextCursor(cursor);
+
+ for (int i = 0; i < lineCount; ++i) {
+ QTest::keyClick(ed, Qt::Key_Down, Qt::ShiftModifier);
+ }
+
+ input.replace(QLatin1Char('\n'), QChar(QChar::ParagraphSeparator));
+ QCOMPARE(ed->textCursor().selectedText(), input);
+ QVERIFY(ed->textCursor().atEnd());
+
+ // also test that without shift modifier the cursor does not move to the end
+ // for Key_Down in the last line
+ cursor.movePosition(QTextCursor::Start);
+ ed->setTextCursor(cursor);
+ for (int i = 0; i < lineCount; ++i) {
+ QTest::keyClick(ed, Qt::Key_Down);
+ }
+ QVERIFY(!ed->textCursor().atEnd());
+}
+
+void tst_QPlainTextEdit::undoRedoShouldRepositionTextEditCursor()
+{
+ ed->setPlainText("five\nlines\nin\nthis\ntextedit");
+ QTextCursor cursor = ed->textCursor();
+ cursor.movePosition(QTextCursor::Start);
+
+ ed->setUndoRedoEnabled(false);
+ ed->setUndoRedoEnabled(true);
+
+ QVERIFY(!ed->document()->isUndoAvailable());
+ QVERIFY(!ed->document()->isRedoAvailable());
+
+ cursor.insertText("Blah");
+
+ QVERIFY(ed->document()->isUndoAvailable());
+ QVERIFY(!ed->document()->isRedoAvailable());
+
+ cursor.movePosition(QTextCursor::End);
+ ed->setTextCursor(cursor);
+
+ QVERIFY(QMetaObject::invokeMethod(ed, "undo"));
+
+ QVERIFY(!ed->document()->isUndoAvailable());
+ QVERIFY(ed->document()->isRedoAvailable());
+
+ QCOMPARE(ed->textCursor().position(), 0);
+
+ cursor.movePosition(QTextCursor::End);
+ ed->setTextCursor(cursor);
+
+ QVERIFY(QMetaObject::invokeMethod(ed, "redo"));
+
+ QVERIFY(ed->document()->isUndoAvailable());
+ QVERIFY(!ed->document()->isRedoAvailable());
+
+ QCOMPARE(ed->textCursor().position(), 4);
+}
+
+void tst_QPlainTextEdit::lineWrapModes()
+{
+ QWidget *window = new QWidget;
+ ed->setParent(window);
+ window->show();
+ ed->show();
+ ed->setPlainText("a b c d e f g h i j k l m n o p q r s t u v w x y z");
+ ed->setLineWrapMode(QPlainTextEdit::NoWrap);
+ QCOMPARE(lineCount(), 1);
+ ed->setLineWrapMode(QPlainTextEdit::WidgetWidth);
+
+ // QPlainTextEdit does lazy line layout on resize, only for the visible blocks.
+ // We thus need to make it wide enough to show something visible.
+ int minimumWidth = 2 * ed->document()->documentMargin();
+ minimumWidth += ed->fontMetrics().width(QLatin1Char('a'));
+ minimumWidth += ed->frameWidth();
+ ed->resize(minimumWidth, 1000);
+ QCOMPARE(lineCount(), 26);
+ ed->setParent(0);
+ delete window;
+}
+
+void tst_QPlainTextEdit::mouseCursorShape()
+{
+#ifndef QT_NO_CURSOR
+ // always show an IBeamCursor, see change 170146
+ QVERIFY(!ed->isReadOnly());
+ QVERIFY(ed->viewport()->cursor().shape() == Qt::IBeamCursor);
+
+ ed->setReadOnly(true);
+ QVERIFY(ed->viewport()->cursor().shape() == Qt::IBeamCursor);
+
+ ed->setPlainText("Foo");
+ QVERIFY(ed->viewport()->cursor().shape() == Qt::IBeamCursor);
+#endif
+}
+
+void tst_QPlainTextEdit::implicitClear()
+{
+ // test that QPlainTextEdit::setHtml, etc. avoid calling clear() but instead call
+ // QTextDocument::setHtml/etc. instead, which also clear the contents and
+ // cached resource but preserve manually added resources. setHtml on a textedit
+ // should behave the same as on a document with respect to that.
+ // see also clearResources() autotest in qtextdocument
+
+ // regular resource for QTextDocument
+ QUrl testUrl(":/foobar");
+ QVariant testResource("hello world");
+
+ ed->document()->addResource(QTextDocument::ImageResource, testUrl, testResource);
+ QVERIFY(ed->document()->resource(QTextDocument::ImageResource, testUrl) == testResource);
+
+ ed->setPlainText("Blah");
+ QVERIFY(ed->document()->resource(QTextDocument::ImageResource, testUrl) == testResource);
+
+ ed->setPlainText("<b>Blah</b>");
+ QVERIFY(ed->document()->resource(QTextDocument::ImageResource, testUrl) == testResource);
+
+ ed->clear();
+ QVERIFY(!ed->document()->resource(QTextDocument::ImageResource, testUrl).isValid());
+ QVERIFY(ed->toPlainText().isEmpty());
+}
+
+#ifndef QT_NO_CLIPBOARD
+void tst_QPlainTextEdit::copyAvailable_data()
+{
+ QTest::addColumn<pairListType>("keystrokes");
+ QTest::addColumn<QList<bool> >("copyAvailable");
+ QTest::addColumn<QString>("function");
+
+ pairListType keystrokes;
+ QList<bool> copyAvailable;
+
+ keystrokes << qMakePair(Qt::Key_B, Qt::NoModifier) << qMakePair(Qt::Key_B, Qt::NoModifier)
+ << qMakePair(Qt::Key_Left, Qt::ShiftModifier);
+ copyAvailable << true ;
+ QTest::newRow(QString("Case1 B,B, <- + shift | signals: true").toLatin1())
+ << keystrokes << copyAvailable << QString();
+
+ keystrokes.clear();
+ copyAvailable.clear();
+
+ keystrokes << qMakePair(Qt::Key_T, Qt::NoModifier) << qMakePair(Qt::Key_A, Qt::NoModifier)
+ << qMakePair(Qt::Key_A, Qt::NoModifier) << qMakePair(Qt::Key_Left, Qt::ShiftModifier);
+ copyAvailable << true << false;
+ QTest::newRow(QString("Case2 T,A,A, <- + shift, cut() | signals: true, false").toLatin1())
+ << keystrokes << copyAvailable << QString("cut");
+
+ keystrokes.clear();
+ copyAvailable.clear();
+
+ keystrokes << qMakePair(Qt::Key_T, Qt::NoModifier) << qMakePair(Qt::Key_A, Qt::NoModifier)
+ << qMakePair(Qt::Key_A, Qt::NoModifier) << qMakePair(Qt::Key_Left, Qt::ShiftModifier)
+ << qMakePair(Qt::Key_Left, Qt::ShiftModifier) << qMakePair(Qt::Key_Left, Qt::ShiftModifier);
+ copyAvailable << true;
+ QTest::newRow(QString("Case3 T,A,A, <- + shift, <- + shift, <- + shift, copy() | signals: true").toLatin1())
+ << keystrokes << copyAvailable << QString("copy");
+
+ keystrokes.clear();
+ copyAvailable.clear();
+
+ keystrokes << qMakePair(Qt::Key_T, Qt::NoModifier) << qMakePair(Qt::Key_A, Qt::NoModifier)
+ << qMakePair(Qt::Key_A, Qt::NoModifier) << qMakePair(Qt::Key_Left, Qt::ShiftModifier)
+ << qMakePair(Qt::Key_Left, Qt::ShiftModifier) << qMakePair(Qt::Key_Left, Qt::ShiftModifier)
+ << qMakePair(Qt::Key_X, Qt::ControlModifier);
+ copyAvailable << true << false;
+ QTest::newRow(QString("Case4 T,A,A, <- + shift, <- + shift, <- + shift, ctrl + x, paste() | signals: true, false").toLatin1())
+ << keystrokes << copyAvailable << QString("paste");
+
+ keystrokes.clear();
+ copyAvailable.clear();
+
+ keystrokes << qMakePair(Qt::Key_B, Qt::NoModifier) << qMakePair(Qt::Key_B, Qt::NoModifier)
+ << qMakePair(Qt::Key_Left, Qt::ShiftModifier) << qMakePair(Qt::Key_Left, Qt::NoModifier);
+ copyAvailable << true << false;
+ QTest::newRow(QString("Case5 B,B, <- + shift, <- | signals: true, false").toLatin1())
+ << keystrokes << copyAvailable << QString();
+
+ keystrokes.clear();
+ copyAvailable.clear();
+
+ keystrokes << qMakePair(Qt::Key_B, Qt::NoModifier) << qMakePair(Qt::Key_A, Qt::NoModifier)
+ << qMakePair(Qt::Key_Left, Qt::ShiftModifier) << qMakePair(Qt::Key_Left, Qt::NoModifier)
+ << qMakePair(Qt::Key_Right, Qt::ShiftModifier);
+ copyAvailable << true << false << true << false;
+ QTest::newRow(QString("Case6 B,A, <- + shift, ->, <- + shift | signals: true, false, true, false").toLatin1())
+ << keystrokes << copyAvailable << QString("cut");
+
+ keystrokes.clear();
+ copyAvailable.clear();
+
+ keystrokes << qMakePair(Qt::Key_T, Qt::NoModifier) << qMakePair(Qt::Key_A, Qt::NoModifier)
+ << qMakePair(Qt::Key_A, Qt::NoModifier) << qMakePair(Qt::Key_Left, Qt::ShiftModifier)
+ << qMakePair(Qt::Key_Left, Qt::ShiftModifier) << qMakePair(Qt::Key_Left, Qt::ShiftModifier)
+ << qMakePair(Qt::Key_X, Qt::ControlModifier);
+ copyAvailable << true << false << true;
+ QTest::newRow(QString("Case7 T,A,A, <- + shift, <- + shift, <- + shift, ctrl + x, undo() | signals: true, false, true").toLatin1())
+ << keystrokes << copyAvailable << QString("undo");
+}
+
+//Tests the copyAvailable slot for several cases
+void tst_QPlainTextEdit::copyAvailable()
+{
+ QFETCH(pairListType,keystrokes);
+ QFETCH(QList<bool>, copyAvailable);
+ QFETCH(QString, function);
+
+#ifdef Q_WS_MAC
+ QSKIP("copyAvailable has never passed on Mac, task to fix is 132482", SkipAll);
+#endif
+ ed->clear();
+ QApplication::clipboard()->clear();
+ QVERIFY(!ed->canPaste());
+ QSignalSpy spyCopyAvailabe(ed, SIGNAL(copyAvailable(bool)));
+
+ //Execute Keystrokes
+ foreach(keyPairType keyPair, keystrokes) {
+ QTest::keyClick(ed, keyPair.first, keyPair.second );
+ }
+
+ //Execute ed->"function"
+ if (function == "cut")
+ ed->cut();
+ else if (function == "copy")
+ ed->copy();
+ else if (function == "paste")
+ ed->paste();
+ else if (function == "undo")
+ ed->paste();
+ else if (function == "redo")
+ ed->paste();
+
+ //Compare spied signals
+ QEXPECT_FAIL("Case7 T,A,A, <- + shift, <- + shift, <- + shift, ctrl + x, undo() | signals: true, false, true",
+ "Wrong undo selection behaviour. Should be fixed in some future release. (See task: 132482)", Abort);
+ QCOMPARE(spyCopyAvailabe.count(), copyAvailable.count());
+ for (int i=0;i<spyCopyAvailabe.count(); i++) {
+ QVariant variantSpyCopyAvailable = spyCopyAvailabe.at(i).at(0);
+ QVERIFY2(variantSpyCopyAvailable.toBool() == copyAvailable.at(i), QString("Spied singnal: %1").arg(i).toLatin1());
+ }
+}
+#endif
+
+void tst_QPlainTextEdit::undoRedoAfterSetContent()
+{
+ QVERIFY(!ed->document()->isUndoAvailable());
+ QVERIFY(!ed->document()->isRedoAvailable());
+ ed->setPlainText("Foobar");
+ QVERIFY(!ed->document()->isUndoAvailable());
+ QVERIFY(!ed->document()->isRedoAvailable());
+ ed->setPlainText("<p>bleh</p>");
+ QVERIFY(!ed->document()->isUndoAvailable());
+ QVERIFY(!ed->document()->isRedoAvailable());
+}
+
+void tst_QPlainTextEdit::numPadKeyNavigation()
+{
+ ed->setPlainText("Hello World");
+ QCOMPARE(ed->textCursor().position(), 0);
+ QTest::keyClick(ed, Qt::Key_Right, Qt::KeypadModifier);
+ QCOMPARE(ed->textCursor().position(), 1);
+}
+
+void tst_QPlainTextEdit::moveCursor()
+{
+ ed->setPlainText("Test");
+
+ QSignalSpy cursorMovedSpy(ed, SIGNAL(cursorPositionChanged()));
+
+ QCOMPARE(ed->textCursor().position(), 0);
+ ed->moveCursor(QTextCursor::NextCharacter);
+ QCOMPARE(ed->textCursor().position(), 1);
+ QCOMPARE(cursorMovedSpy.count(), 1);
+ ed->moveCursor(QTextCursor::NextCharacter, QTextCursor::KeepAnchor);
+ QCOMPARE(ed->textCursor().position(), 2);
+ QCOMPARE(cursorMovedSpy.count(), 2);
+ QCOMPARE(ed->textCursor().selectedText(), QString("e"));
+}
+
+class MyTextEdit : public QPlainTextEdit
+{
+public:
+ inline MyTextEdit()
+ : createMimeDataCallCount(0),
+ canInsertCallCount(0),
+ insertCallCount(0)
+ {}
+
+ mutable int createMimeDataCallCount;
+ mutable int canInsertCallCount;
+ mutable int insertCallCount;
+
+ virtual QMimeData *createMimeDataFromSelection() const {
+ createMimeDataCallCount++;
+ return QPlainTextEdit::createMimeDataFromSelection();
+ }
+ virtual bool canInsertFromMimeData(const QMimeData *source) const {
+ canInsertCallCount++;
+ return QPlainTextEdit::canInsertFromMimeData(source);
+ }
+ virtual void insertFromMimeData(const QMimeData *source) {
+ insertCallCount++;
+ QPlainTextEdit::insertFromMimeData(source);
+ }
+
+};
+
+#ifndef QT_NO_CLIPBOARD
+void tst_QPlainTextEdit::mimeDataReimplementations()
+{
+ MyTextEdit ed;
+ ed.setPlainText("Hello World");
+
+ QCOMPARE(ed.createMimeDataCallCount, 0);
+ QCOMPARE(ed.canInsertCallCount, 0);
+ QCOMPARE(ed.insertCallCount, 0);
+
+ ed.selectAll();
+
+ QCOMPARE(ed.createMimeDataCallCount, 0);
+ QCOMPARE(ed.canInsertCallCount, 0);
+ QCOMPARE(ed.insertCallCount, 0);
+
+ ed.copy();
+
+ QCOMPARE(ed.createMimeDataCallCount, 1);
+ QCOMPARE(ed.canInsertCallCount, 0);
+ QCOMPARE(ed.insertCallCount, 0);
+
+#ifdef QT_BUILD_INTERNAL
+ QWidgetTextControl *control = qFindChild<QWidgetTextControl *>(&ed);
+ QVERIFY(control);
+
+ control->canInsertFromMimeData(QApplication::clipboard()->mimeData());
+
+ QCOMPARE(ed.createMimeDataCallCount, 1);
+ QCOMPARE(ed.canInsertCallCount, 1);
+ QCOMPARE(ed.insertCallCount, 0);
+
+ ed.paste();
+
+ QCOMPARE(ed.createMimeDataCallCount, 1);
+ QCOMPARE(ed.canInsertCallCount, 1);
+ QCOMPARE(ed.insertCallCount, 1);
+#endif
+}
+#endif
+
+void tst_QPlainTextEdit::shiftEnterShouldInsertLineSeparator()
+{
+ QTest::keyClick(ed, Qt::Key_A);
+ QTest::keyClick(ed, Qt::Key_Enter, Qt::ShiftModifier);
+ QTest::keyClick(ed, Qt::Key_B);
+ QString expected;
+ expected += 'a';
+ expected += QChar::LineSeparator;
+ expected += 'b';
+ QCOMPARE(ed->textCursor().block().text(), expected);
+}
+
+void tst_QPlainTextEdit::selectWordsFromStringsContainingSeparators_data()
+{
+ QTest::addColumn<QString>("testString");
+ QTest::addColumn<QString>("selectedWord");
+
+ QStringList wordSeparators;
+ wordSeparators << "." << "," << "?" << "!" << ":" << ";" << "-" << "<" << ">" << "["
+ << "]" << "(" << ")" << "{" << "}" << "=" << "\t"<< QString(QChar::Nbsp);
+
+ foreach (QString s, wordSeparators)
+ QTest::newRow(QString("separator: " + s).toLocal8Bit()) << QString("foo") + s + QString("bar") << QString("foo");
+}
+
+void tst_QPlainTextEdit::selectWordsFromStringsContainingSeparators()
+{
+ QFETCH(QString, testString);
+ QFETCH(QString, selectedWord);
+ ed->setPlainText(testString);
+ QTextCursor cursor = ed->textCursor();
+ cursor.movePosition(QTextCursor::StartOfLine);
+ cursor.select(QTextCursor::WordUnderCursor);
+ QVERIFY(cursor.hasSelection());
+ QCOMPARE(cursor.selection().toPlainText(), selectedWord);
+ cursor.clearSelection();
+}
+
+#ifndef QT_NO_CLIPBOARD
+void tst_QPlainTextEdit::canPaste()
+{
+ if (!nativeClipboardWorking())
+ QSKIP("Clipboard not working with cron-started unit tests", SkipAll);
+
+ QApplication::clipboard()->setText(QString());
+ QVERIFY(!ed->canPaste());
+ QApplication::clipboard()->setText("Test");
+ QVERIFY(ed->canPaste());
+ ed->setTextInteractionFlags(Qt::NoTextInteraction);
+ QVERIFY(!ed->canPaste());
+}
+#endif
+
+void tst_QPlainTextEdit::ensureCursorVisibleOnInitialShow()
+{
+ QString manyPagesOfPlainText;
+ for (int i = 0; i < 800; ++i)
+ manyPagesOfPlainText += QLatin1String("Blah blah blah blah blah blah\n");
+
+ ed->setPlainText(manyPagesOfPlainText);
+ QCOMPARE(ed->textCursor().position(), 0);
+
+ ed->moveCursor(QTextCursor::End);
+ ed->show();
+ QVERIFY(ed->verticalScrollBar()->value() > 10);
+
+ ed->moveCursor(QTextCursor::Start);
+ QVERIFY(ed->verticalScrollBar()->value() < 10);
+ ed->hide();
+ ed->verticalScrollBar()->setValue(ed->verticalScrollBar()->maximum());
+ ed->show();
+ QCOMPARE(ed->verticalScrollBar()->value(), ed->verticalScrollBar()->maximum());
+}
+
+class TestEdit : public QPlainTextEdit
+{
+public:
+ TestEdit() : resizeEventCalled(false) {}
+
+ bool resizeEventCalled;
+
+protected:
+ virtual void resizeEvent(QResizeEvent *e)
+ {
+ QPlainTextEdit::resizeEvent(e);
+ setPlainText("<img src=qtextbrowser-resizeevent.png width=" + QString::number(size().width()) + "><br>Size is " + QString::number(size().width()) + " x " + QString::number(size().height()));
+ resizeEventCalled = true;
+ }
+};
+
+void tst_QPlainTextEdit::setTextInsideResizeEvent()
+{
+ TestEdit edit;
+ edit.show();
+ edit.resize(800, 600);
+ QVERIFY(edit.resizeEventCalled);
+}
+
+void tst_QPlainTextEdit::colorfulAppend()
+{
+ QTextCharFormat fmt;
+
+ fmt.setForeground(QBrush(Qt::red));
+ ed->mergeCurrentCharFormat(fmt);
+ ed->appendPlainText("Red");
+ fmt.setForeground(QBrush(Qt::blue));
+ ed->mergeCurrentCharFormat(fmt);
+ ed->appendPlainText("Blue");
+ fmt.setForeground(QBrush(Qt::green));
+ ed->mergeCurrentCharFormat(fmt);
+ ed->appendPlainText("Green");
+
+ QCOMPARE(ed->document()->blockCount(), 3);
+ QTextBlock block = ed->document()->begin();
+ QCOMPARE(block.begin().fragment().text(), QString("Red"));
+ QVERIFY(block.begin().fragment().charFormat().foreground().color() == Qt::red);
+ block = block.next();
+ QCOMPARE(block.begin().fragment().text(), QString("Blue"));
+ QVERIFY(block.begin().fragment().charFormat().foreground().color() == Qt::blue);
+ block = block.next();
+ QCOMPARE(block.begin().fragment().text(), QString("Green"));
+ QVERIFY(block.begin().fragment().charFormat().foreground().color() == Qt::green);
+}
+
+void tst_QPlainTextEdit::ensureVisibleWithRtl()
+{
+ ed->setLayoutDirection(Qt::RightToLeft);
+ ed->setLineWrapMode(QPlainTextEdit::NoWrap);
+ QString txt(500, QChar(QLatin1Char('a')));
+ QCOMPARE(txt.length(), 500);
+ ed->setPlainText(txt);
+ ed->resize(100, 100);
+ ed->show();
+
+ qApp->processEvents();
+
+ QVERIFY(ed->horizontalScrollBar()->maximum() > 0);
+
+ ed->moveCursor(QTextCursor::Start);
+ QCOMPARE(ed->horizontalScrollBar()->value(), ed->horizontalScrollBar()->maximum());
+ ed->moveCursor(QTextCursor::End);
+ QCOMPARE(ed->horizontalScrollBar()->value(), 0);
+ ed->moveCursor(QTextCursor::Start);
+ QCOMPARE(ed->horizontalScrollBar()->value(), ed->horizontalScrollBar()->maximum());
+ ed->moveCursor(QTextCursor::End);
+ QCOMPARE(ed->horizontalScrollBar()->value(), 0);
+}
+
+void tst_QPlainTextEdit::preserveCharFormatAfterSetPlainText()
+{
+ QTextCharFormat fmt;
+ fmt.setForeground(QBrush(Qt::blue));
+ ed->mergeCurrentCharFormat(fmt);
+ ed->setPlainText("This is blue");
+ ed->appendPlainText("This should still be blue");
+ QTextBlock block = ed->document()->begin();
+ block = block.next();
+ QCOMPARE(block.text(), QString("This should still be blue"));
+ QVERIFY(block.begin().fragment().charFormat().foreground().color() == QColor(Qt::blue));
+}
+
+void tst_QPlainTextEdit::extraSelections()
+{
+ ed->setPlainText("Hello World");
+
+ QTextCursor c = ed->textCursor();
+ c.movePosition(QTextCursor::Start);
+ c.movePosition(QTextCursor::End, QTextCursor::KeepAnchor);
+ const int endPos = c.position();
+
+ QTextEdit::ExtraSelection sel;
+ sel.cursor = c;
+ ed->setExtraSelections(QList<QTextEdit::ExtraSelection>() << sel);
+
+ c.movePosition(QTextCursor::Start);
+ c.movePosition(QTextCursor::NextWord);
+ const int wordPos = c.position();
+ c.movePosition(QTextCursor::End, QTextCursor::KeepAnchor);
+ sel.cursor = c;
+ ed->setExtraSelections(QList<QTextEdit::ExtraSelection>() << sel);
+
+ QList<QTextEdit::ExtraSelection> selections = ed->extraSelections();
+ QCOMPARE(selections.count(), 1);
+ QCOMPARE(selections.at(0).cursor.position(), endPos);
+ QCOMPARE(selections.at(0).cursor.anchor(), wordPos);
+}
+
+void tst_QPlainTextEdit::adjustScrollbars()
+{
+// For some reason ff is defined to be << on Mac Panther / gcc 3.3
+#undef ff
+ QFont ff(ed->font());
+ ff.setFamily("Tahoma");
+ ff.setPointSize(11);
+ ed->setFont(ff);
+ ed->setMinimumSize(140, 100);
+ ed->setMaximumSize(140, 100);
+ ed->show();
+ QLatin1String txt("\nabc def ghi jkl mno pqr stu vwx");
+ ed->setPlainText(txt + txt + txt + txt);
+
+ QVERIFY(ed->verticalScrollBar()->maximum() > 0);
+
+ ed->moveCursor(QTextCursor::End);
+ int oldMaximum = ed->verticalScrollBar()->maximum();
+ QTextCursor cursor = ed->textCursor();
+ cursor.insertText(QLatin1String("\n"));
+ cursor.deletePreviousChar();
+ QCOMPARE(ed->verticalScrollBar()->maximum(), oldMaximum);
+}
+
+class SignalReceiver : public QObject
+{
+ Q_OBJECT
+public:
+ SignalReceiver() : received(0) {}
+
+ int receivedSignals() const { return received; }
+ QTextCharFormat charFormat() const { return format; }
+
+public slots:
+ void charFormatChanged(const QTextCharFormat &tcf) { ++received; format = tcf; }
+
+private:
+ QTextCharFormat format;
+ int received;
+};
+
+void tst_QPlainTextEdit::textObscuredByScrollbars()
+{
+ ed->textCursor().insertText(
+ "ab cab cab c abca kjsdf lka sjd lfk jsal df j kasdf abc ab abc "
+ "a b c d e f g h i j k l m n o p q r s t u v w x y z "
+ "abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc "
+ "ab ab ab ab ab ab ab ab ab ab ab ab ab ab ab ab ab ab ab ab ab"
+ "abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc "
+ "ab ab ab ab ab ab ab ab ab ab ab ab ab ab ab ab ab ab ab ab ab"
+ "abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc "
+ "ab ab ab ab ab ab ab ab ab ab ab ab ab ab ab ab ab ab ab ab ab"
+ "abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc "
+ "ab ab ab ab ab ab ab ab ab ab ab ab ab ab ab ab ab ab ab ab ab"
+ "abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc "
+ "ab ab ab ab ab ab ab ab ab ab ab ab ab ab ab ab ab ab ab ab ab"
+ );
+ ed->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
+ ed->show();
+
+ QSize documentSize = ed->document()->documentLayout()->documentSize().toSize();
+ QSize viewportSize = ed->viewport()->size();
+
+ QVERIFY(documentSize.width() <= viewportSize.width());
+}
+
+void tst_QPlainTextEdit::setTextPreservesUndoRedoEnabled()
+{
+ QVERIFY(ed->isUndoRedoEnabled());
+
+ ed->setPlainText("Test");
+
+ QVERIFY(ed->isUndoRedoEnabled());
+
+ ed->setUndoRedoEnabled(false);
+ QVERIFY(!ed->isUndoRedoEnabled());
+ ed->setPlainText("Test2");
+ QVERIFY(!ed->isUndoRedoEnabled());
+
+ ed->setPlainText("<p>hello");
+ QVERIFY(!ed->isUndoRedoEnabled());
+}
+
+void tst_QPlainTextEdit::wordWrapProperty()
+{
+ {
+ QPlainTextEdit edit;
+ QTextDocument *doc = new QTextDocument(&edit);
+ doc->setDocumentLayout(new QPlainTextDocumentLayout(doc));
+ edit.setDocument(doc);
+ edit.setWordWrapMode(QTextOption::NoWrap);
+ QVERIFY(doc->defaultTextOption().wrapMode() == QTextOption::NoWrap);
+ }
+ {
+ QPlainTextEdit edit;
+ QTextDocument *doc = new QTextDocument(&edit);
+ doc->setDocumentLayout(new QPlainTextDocumentLayout(doc));
+ edit.setWordWrapMode(QTextOption::NoWrap);
+ edit.setDocument(doc);
+ QVERIFY(doc->defaultTextOption().wrapMode() == QTextOption::NoWrap);
+ }
+}
+
+void tst_QPlainTextEdit::lineWrapProperty()
+{
+ QVERIFY(ed->wordWrapMode() == QTextOption::WrapAtWordBoundaryOrAnywhere);
+ QVERIFY(ed->lineWrapMode() == QPlainTextEdit::WidgetWidth);
+ ed->setLineWrapMode(QPlainTextEdit::NoWrap);
+ QVERIFY(ed->lineWrapMode() == QPlainTextEdit::NoWrap);
+ QVERIFY(ed->wordWrapMode() == QTextOption::WrapAtWordBoundaryOrAnywhere);
+ QVERIFY(ed->document()->defaultTextOption().wrapMode() == QTextOption::NoWrap);
+}
+
+void tst_QPlainTextEdit::selectionChanged()
+{
+ ed->setPlainText("Hello World");
+
+ ed->moveCursor(QTextCursor::Start);
+
+ QSignalSpy selectionChangedSpy(ed, SIGNAL(selectionChanged()));
+
+ QTest::keyClick(ed, Qt::Key_Right);
+ QCOMPARE(ed->textCursor().position(), 1);
+ QCOMPARE(selectionChangedSpy.count(), 0);
+
+ QTest::keyClick(ed, Qt::Key_Right, Qt::ShiftModifier);
+ QCOMPARE(ed->textCursor().position(), 2);
+ QCOMPARE(selectionChangedSpy.count(), 1);
+
+ QTest::keyClick(ed, Qt::Key_Right, Qt::ShiftModifier);
+ QCOMPARE(ed->textCursor().position(), 3);
+ QCOMPARE(selectionChangedSpy.count(), 2);
+
+ QTest::keyClick(ed, Qt::Key_Right, Qt::ShiftModifier);
+ QCOMPARE(ed->textCursor().position(), 4);
+ QCOMPARE(selectionChangedSpy.count(), 3);
+
+ QTest::keyClick(ed, Qt::Key_Right);
+ QCOMPARE(ed->textCursor().position(), 5);
+ QCOMPARE(selectionChangedSpy.count(), 4);
+
+ QTest::keyClick(ed, Qt::Key_Right);
+ QCOMPARE(ed->textCursor().position(), 6);
+ QCOMPARE(selectionChangedSpy.count(), 4);
+}
+
+void tst_QPlainTextEdit::blockCountChanged()
+{
+ QSignalSpy blockCountCpangedSpy(ed, SIGNAL(blockCountChanged(int)));
+ ed->setPlainText("Hello");
+ QCOMPARE(blockCountCpangedSpy.count(), 0);
+ ed->setPlainText("Hello World");
+ QCOMPARE(blockCountCpangedSpy.count(), 0);
+ ed->setPlainText("Hello \n World \n this \n has \n more \n blocks \n than \n just \n one");
+ QCOMPARE(blockCountCpangedSpy.count(), 1);
+ ed->setPlainText("One");
+ QCOMPARE(blockCountCpangedSpy.count(), 2);
+ ed->setPlainText("One \n Two");
+ QCOMPARE(blockCountCpangedSpy.count(), 3);
+ ed->setPlainText("Three \n Four");
+ QCOMPARE(blockCountCpangedSpy.count(), 3);
+}
+
+
+void tst_QPlainTextEdit::insertAndScrollToBottom()
+{
+ ed->setPlainText("First Line");
+ ed->show();
+ QString text;
+ for(int i = 0; i < 2000; ++i) {
+ text += QLatin1String("this is another line of text to be appended. It is quite long and will probably wrap around, meaning the number of lines is larger than the number of blocks in the text.\n");
+ }
+ QTextCursor cursor = ed->textCursor();
+ cursor.beginEditBlock();
+ cursor.insertText(text);
+ cursor.endEditBlock();
+ ed->verticalScrollBar()->setValue(ed->verticalScrollBar()->maximum());
+ QCOMPARE(ed->verticalScrollBar()->value(), ed->verticalScrollBar()->maximum());
+}
+
+
+QTEST_MAIN(tst_QPlainTextEdit)
+#include "tst_qplaintextedit.moc"
diff --git a/tests/auto/widgets/widgets/qprogressbar/.gitignore b/tests/auto/widgets/widgets/qprogressbar/.gitignore
new file mode 100644
index 0000000000..3cb22a2560
--- /dev/null
+++ b/tests/auto/widgets/widgets/qprogressbar/.gitignore
@@ -0,0 +1 @@
+tst_qprogressbar
diff --git a/tests/auto/widgets/widgets/qprogressbar/qprogressbar.pro b/tests/auto/widgets/widgets/qprogressbar/qprogressbar.pro
new file mode 100644
index 0000000000..70d8c9111f
--- /dev/null
+++ b/tests/auto/widgets/widgets/qprogressbar/qprogressbar.pro
@@ -0,0 +1,6 @@
+load(qttest_p4)
+QT += widgets
+SOURCES += tst_qprogressbar.cpp
+
+
+
diff --git a/tests/auto/widgets/widgets/qprogressbar/tst_qprogressbar.cpp b/tests/auto/widgets/widgets/qprogressbar/tst_qprogressbar.cpp
new file mode 100644
index 0000000000..55285b42ff
--- /dev/null
+++ b/tests/auto/widgets/widgets/qprogressbar/tst_qprogressbar.cpp
@@ -0,0 +1,295 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#include <QtTest/QtTest>
+#include "qprogressbar.h"
+#include <qapplication.h>
+#include <qstyleoption.h>
+#include <qdebug.h>
+#include <qtimer.h>
+#include <QStyleFactory>
+
+//TESTED_CLASS=
+//TESTED_FILES=
+
+class tst_QProgressBar : public QObject
+{
+Q_OBJECT
+private slots:
+ void getSetCheck();
+ void minMaxSameValue();
+ void destroyIndeterminate();
+ void text();
+ void format();
+ void setValueRepaint();
+ void sizeHint();
+ void formatedText_data();
+ void formatedText();
+
+ void task245201_testChangeStyleAndDelete_data();
+ void task245201_testChangeStyleAndDelete();
+};
+
+// Testing get/set functions
+void tst_QProgressBar::getSetCheck()
+{
+ QProgressBar obj1;
+ // bool QProgressBar::invertedAppearance()
+ // void QProgressBar::setInvertedAppearance(bool)
+ obj1.setInvertedAppearance(false);
+ QCOMPARE(false, obj1.invertedAppearance());
+ obj1.setInvertedAppearance(true);
+ QCOMPARE(true, obj1.invertedAppearance());
+
+ // int QProgressBar::minimum()
+ // void QProgressBar::setMinimum(int)
+ obj1.setMinimum(0);
+ QCOMPARE(0, obj1.minimum());
+ obj1.setMinimum(INT_MAX);
+ QCOMPARE(INT_MAX, obj1.minimum());
+ obj1.setMinimum(INT_MIN);
+ QCOMPARE(INT_MIN, obj1.minimum());
+
+ // int QProgressBar::maximum()
+ // void QProgressBar::setMaximum(int)
+ obj1.setMaximum(0);
+ QCOMPARE(0, obj1.maximum());
+ obj1.setMaximum(INT_MIN);
+ QCOMPARE(INT_MIN, obj1.maximum());
+ obj1.setMaximum(INT_MAX);
+ QCOMPARE(INT_MAX, obj1.maximum());
+
+ // int QProgressBar::value()
+ // void QProgressBar::setValue(int)
+ obj1.setValue(0);
+ QCOMPARE(0, obj1.value());
+ obj1.setValue(INT_MIN);
+ QCOMPARE(INT_MIN, obj1.value());
+ obj1.setValue(INT_MAX);
+ QCOMPARE(INT_MAX, obj1.value());
+}
+
+void tst_QProgressBar::minMaxSameValue()
+{
+ QProgressBar bar;
+ bar.setRange(10, 10);
+ bar.setValue(10);
+ bar.show();
+}
+
+void tst_QProgressBar::destroyIndeterminate()
+{
+ // This test crashes on styles that animate indeterminate / busy
+ // progressbars, and forget to remove the bars from internal logics when
+ // it's deleted.
+ QPointer<QProgressBar> bar = new QProgressBar;
+ bar->setMaximum(0);
+ bar->show();
+
+ QEventLoop loop;
+ QTimer::singleShot(500, bar, SLOT(deleteLater()));
+ QTimer::singleShot(3000, &loop, SLOT(quit()));
+ loop.exec();
+
+ QVERIFY(!bar);
+}
+
+void tst_QProgressBar::text()
+{
+ QProgressBar bar;
+ bar.setRange(10, 10);
+ bar.setValue(10);
+ QCOMPARE(bar.text(), QString("100%"));
+ bar.setRange(0, 10);
+ QCOMPARE(bar.text(), QString("100%"));
+ bar.setValue(5);
+ QCOMPARE(bar.text(), QString("50%"));
+ bar.setRange(0, 5);
+ bar.setValue(0);
+ bar.setRange(5, 5);
+ QCOMPARE(bar.text(), QString());
+}
+
+class ProgressBar : public QProgressBar
+{
+ void paintEvent(QPaintEvent *event)
+ {
+ repainted = true;
+ QProgressBar::paintEvent(event);
+ }
+public:
+ bool repainted;
+ using QProgressBar::initStyleOption;
+};
+
+void tst_QProgressBar::format()
+{
+ ProgressBar bar;
+ bar.setRange(0, 10);
+ bar.setValue(1);
+ bar.show();
+ QTest::qWaitForWindowShown(&bar);
+
+ QTest::qWait(20);
+ bar.repainted = false;
+ bar.setFormat("%v of %m (%p%)");
+ QTest::qWait(20);
+ QTRY_VERIFY(bar.repainted);
+ bar.repainted = false;
+ bar.setFormat("%v of %m (%p%)");
+ qApp->processEvents();
+
+#ifndef Q_WS_MAC
+ // Animated scroll bars get paint events all the time
+#ifdef Q_OS_WIN
+ if (QSysInfo::WindowsVersion < QSysInfo::WV_VISTA)
+#endif
+ QVERIFY(!bar.repainted);
+#endif
+
+ QCOMPARE(bar.text(), QString("1 of 10 (10%)"));
+ bar.setRange(5, 5);
+ bar.setValue(5);
+ QCOMPARE(bar.text(), QString("5 of 0 (100%)"));
+ bar.setRange(0, 5);
+ bar.setValue(0);
+ bar.setRange(5, 5);
+ QCOMPARE(bar.text(), QString());
+}
+
+void tst_QProgressBar::setValueRepaint()
+{
+ ProgressBar pbar;
+ pbar.setMinimum(0);
+ pbar.setMaximum(10);
+ pbar.setFormat("%v");
+ pbar.show();
+ QTest::qWaitForWindowShown(&pbar);
+
+ QApplication::processEvents();
+ for (int i = pbar.minimum(); i < pbar.maximum(); ++i) {
+ pbar.repainted = false;
+ pbar.setValue(i);
+ QTest::qWait(50);
+ QTRY_VERIFY(pbar.repainted);
+ }
+}
+
+void tst_QProgressBar::sizeHint()
+{
+ ProgressBar bar;
+ bar.setMinimum(0);
+ bar.setMaximum(10);
+ bar.setValue(5);
+
+ //test if the sizeHint is big enough
+ QFontMetrics fm = bar.fontMetrics();
+ QStyleOptionProgressBarV2 opt;
+ bar.initStyleOption(&opt);
+ QSize size = QSize(9 * 7 + fm.width(QLatin1Char('0')) * 4, fm.height() + 8);
+ size= bar.style()->sizeFromContents(QStyle::CT_ProgressBar, &opt, size, &bar);
+ QSize barSize = bar.sizeHint();
+ QVERIFY(barSize.width() >= size.width());
+ QCOMPARE(barSize.height(), size.height());
+}
+
+void tst_QProgressBar::formatedText_data()
+{
+ QTest::addColumn<int>("minimum");
+ QTest::addColumn<int>("maximum");
+ QTest::addColumn<int>("value");
+ QTest::addColumn<QString>("format");
+ QTest::addColumn<QString>("text");
+
+ QTest::newRow("1") << -100 << 100 << 0 << QString::fromLatin1(" %p - %v - %m ") << QString::fromLatin1(" 50 - 0 - 200 ");
+ QTest::newRow("2") << -100 << 0 << -25 << QString::fromLatin1(" %p - %v - %m ") << QString::fromLatin1(" 75 - -25 - 100 ");
+ QTest::newRow("3") << 10 << 10 << 10 << QString::fromLatin1(" %p - %v - %m ") << QString::fromLatin1(" 100 - 10 - 0 ");
+ QTest::newRow("task152227") << INT_MIN << INT_MAX << 42 << QString::fromLatin1(" %p - %v - %m ") << QString::fromLatin1(" 50 - 42 - 4294967295 ");
+}
+
+void tst_QProgressBar::formatedText()
+{
+ QFETCH(int, minimum);
+ QFETCH(int, maximum);
+ QFETCH(int, value);
+ QFETCH(QString, format);
+ QFETCH(QString, text);
+ QProgressBar bar;
+ bar.setRange(minimum, maximum);
+ bar.setValue(value);
+ bar.setFormat(format);
+ QCOMPARE(bar.text(), text);
+}
+
+void tst_QProgressBar::task245201_testChangeStyleAndDelete_data()
+{
+ QTest::addColumn<QString>("style1_str");
+ QTest::addColumn<QString>("style2_str");
+
+ QTest::newRow("plastique-windows") << QString::fromLatin1("plastique") << QString::fromLatin1("windows");
+ QTest::newRow("mlotif-windows") << QString::fromLatin1("motif") << QString::fromLatin1("windows");
+ QTest::newRow("cleanlooks-cde") << QString::fromLatin1("cleanlooks") << QString::fromLatin1("cde");
+ QTest::newRow("gtk-plastique") << QString::fromLatin1("gtk") << QString::fromLatin1("plastique");
+}
+
+void tst_QProgressBar::task245201_testChangeStyleAndDelete()
+{
+ QFETCH(QString, style1_str);
+ QFETCH(QString, style2_str);
+
+ QProgressBar *bar = new QProgressBar;
+
+ QStyle *style = QStyleFactory::create(style1_str);
+ bar->setStyle(style);
+ bar->show();
+ QStyle *style2 = QStyleFactory::create(style2_str);
+ bar->setStyle(style2);
+ QTest::qWait(10);
+
+ delete bar;
+ QTest::qWait(100); //should not crash
+ delete style;
+ delete style2;
+}
+
+QTEST_MAIN(tst_QProgressBar)
+#include "tst_qprogressbar.moc"
diff --git a/tests/auto/widgets/widgets/qpushbutton/.gitignore b/tests/auto/widgets/widgets/qpushbutton/.gitignore
new file mode 100644
index 0000000000..ac5b16970b
--- /dev/null
+++ b/tests/auto/widgets/widgets/qpushbutton/.gitignore
@@ -0,0 +1 @@
+tst_qpushbutton
diff --git a/tests/auto/widgets/widgets/qpushbutton/qpushbutton.pro b/tests/auto/widgets/widgets/qpushbutton/qpushbutton.pro
new file mode 100644
index 0000000000..e2fd455951
--- /dev/null
+++ b/tests/auto/widgets/widgets/qpushbutton/qpushbutton.pro
@@ -0,0 +1,6 @@
+load(qttest_p4)
+QT += widgets
+SOURCES += tst_qpushbutton.cpp
+
+
+
diff --git a/tests/auto/widgets/widgets/qpushbutton/testdata/setEnabled/disabled_Windows_win32_data0.qsnap b/tests/auto/widgets/widgets/qpushbutton/testdata/setEnabled/disabled_Windows_win32_data0.qsnap
new file mode 100644
index 0000000000..8c2c08aee9
--- /dev/null
+++ b/tests/auto/widgets/widgets/qpushbutton/testdata/setEnabled/disabled_Windows_win32_data0.qsnap
Binary files differ
diff --git a/tests/auto/widgets/widgets/qpushbutton/testdata/setEnabled/enabled_Motif_data0.qsnap b/tests/auto/widgets/widgets/qpushbutton/testdata/setEnabled/enabled_Motif_data0.qsnap
new file mode 100644
index 0000000000..3c455887da
--- /dev/null
+++ b/tests/auto/widgets/widgets/qpushbutton/testdata/setEnabled/enabled_Motif_data0.qsnap
Binary files differ
diff --git a/tests/auto/widgets/widgets/qpushbutton/testdata/setEnabled/enabled_Windows_data0.qsnap b/tests/auto/widgets/widgets/qpushbutton/testdata/setEnabled/enabled_Windows_data0.qsnap
new file mode 100644
index 0000000000..e655b09d29
--- /dev/null
+++ b/tests/auto/widgets/widgets/qpushbutton/testdata/setEnabled/enabled_Windows_data0.qsnap
Binary files differ
diff --git a/tests/auto/widgets/widgets/qpushbutton/testdata/setEnabled/enabled_Windows_win32_data0.qsnap b/tests/auto/widgets/widgets/qpushbutton/testdata/setEnabled/enabled_Windows_win32_data0.qsnap
new file mode 100644
index 0000000000..8f59499d72
--- /dev/null
+++ b/tests/auto/widgets/widgets/qpushbutton/testdata/setEnabled/enabled_Windows_win32_data0.qsnap
Binary files differ
diff --git a/tests/auto/widgets/widgets/qpushbutton/testdata/setPixmap/Vpix_Motif_data0.qsnap b/tests/auto/widgets/widgets/qpushbutton/testdata/setPixmap/Vpix_Motif_data0.qsnap
new file mode 100644
index 0000000000..a6967a17f7
--- /dev/null
+++ b/tests/auto/widgets/widgets/qpushbutton/testdata/setPixmap/Vpix_Motif_data0.qsnap
Binary files differ
diff --git a/tests/auto/widgets/widgets/qpushbutton/testdata/setPixmap/Vpix_Windows_data0.qsnap b/tests/auto/widgets/widgets/qpushbutton/testdata/setPixmap/Vpix_Windows_data0.qsnap
new file mode 100644
index 0000000000..d7c721c960
--- /dev/null
+++ b/tests/auto/widgets/widgets/qpushbutton/testdata/setPixmap/Vpix_Windows_data0.qsnap
Binary files differ
diff --git a/tests/auto/widgets/widgets/qpushbutton/testdata/setPixmap/Vpix_Windows_win32_data0.qsnap b/tests/auto/widgets/widgets/qpushbutton/testdata/setPixmap/Vpix_Windows_win32_data0.qsnap
new file mode 100644
index 0000000000..ae0261a22c
--- /dev/null
+++ b/tests/auto/widgets/widgets/qpushbutton/testdata/setPixmap/Vpix_Windows_win32_data0.qsnap
Binary files differ
diff --git a/tests/auto/widgets/widgets/qpushbutton/testdata/setText/simple_Motif_data0.qsnap b/tests/auto/widgets/widgets/qpushbutton/testdata/setText/simple_Motif_data0.qsnap
new file mode 100644
index 0000000000..039bdce748
--- /dev/null
+++ b/tests/auto/widgets/widgets/qpushbutton/testdata/setText/simple_Motif_data0.qsnap
Binary files differ
diff --git a/tests/auto/widgets/widgets/qpushbutton/testdata/setText/simple_Windows_data0.qsnap b/tests/auto/widgets/widgets/qpushbutton/testdata/setText/simple_Windows_data0.qsnap
new file mode 100644
index 0000000000..db40dc4726
--- /dev/null
+++ b/tests/auto/widgets/widgets/qpushbutton/testdata/setText/simple_Windows_data0.qsnap
Binary files differ
diff --git a/tests/auto/widgets/widgets/qpushbutton/testdata/setText/simple_Windows_win32_data0.qsnap b/tests/auto/widgets/widgets/qpushbutton/testdata/setText/simple_Windows_win32_data0.qsnap
new file mode 100644
index 0000000000..c0e1279f46
--- /dev/null
+++ b/tests/auto/widgets/widgets/qpushbutton/testdata/setText/simple_Windows_win32_data0.qsnap
Binary files differ
diff --git a/tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp b/tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp
new file mode 100644
index 0000000000..e5083553e2
--- /dev/null
+++ b/tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp
@@ -0,0 +1,637 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#include <QtTest/QtTest>
+
+
+#include "qpushbutton.h"
+#include <qapplication.h>
+
+#include <qpushbutton.h>
+#include <qmenu.h>
+#include <qtimer.h>
+#include <QDialog>
+#include <QGridLayout>
+#include <QStyleFactory>
+#include <QTabWidget>
+
+Q_DECLARE_METATYPE(QPushButton*)
+
+//TESTED_CLASS=
+//TESTED_FILES=
+
+class tst_QPushButton : public QObject
+{
+Q_OBJECT
+public:
+ tst_QPushButton();
+ virtual ~tst_QPushButton();
+
+
+public slots:
+ void initTestCase();
+ void cleanupTestCase();
+ void init();
+ void cleanup();
+private slots:
+ void getSetCheck();
+ void autoRepeat();
+ void pressed();
+ void setAccel();
+ void isCheckable();
+ void setDown();
+ void popupCrash();
+ void isChecked();
+ void animateClick();
+ void toggle();
+ void clicked();
+ void toggled();
+ void defaultAndAutoDefault();
+ void sizeHint_data();
+ void sizeHint();
+/*
+ void state();
+ void group();
+ void stateChanged();
+*/
+
+protected slots:
+ void resetCounters();
+ void onClicked();
+ void onToggled( bool on );
+ void onPressed();
+ void onReleased();
+ void helperSlotDelete();
+
+private:
+ uint click_count;
+ uint toggle_count;
+ uint press_count;
+ uint release_count;
+
+ QPushButton *testWidget;
+};
+
+// Testing get/set functions
+void tst_QPushButton::getSetCheck()
+{
+ QPushButton obj1;
+ // QMenu* QPushButton::menu()
+ // void QPushButton::setMenu(QMenu*)
+ QMenu *var1 = new QMenu;
+ obj1.setMenu(var1);
+ QCOMPARE(var1, obj1.menu());
+ obj1.setMenu((QMenu *)0);
+ QCOMPARE((QMenu *)0, obj1.menu());
+ delete var1;
+}
+
+tst_QPushButton::tst_QPushButton()
+{
+}
+
+tst_QPushButton::~tst_QPushButton()
+{
+}
+
+void tst_QPushButton::initTestCase()
+{
+ // Create the test class
+ testWidget = new QPushButton( "&Start", 0 );
+ testWidget->setObjectName("testWidget");
+ testWidget->resize( 200, 200 );
+ testWidget->show();
+
+ connect( testWidget, SIGNAL(clicked()), this, SLOT(onClicked()) );
+ connect( testWidget, SIGNAL(pressed()), this, SLOT(onPressed()) );
+ connect( testWidget, SIGNAL(released()), this, SLOT(onReleased()) );
+ connect( testWidget, SIGNAL(toggled(bool)), this, SLOT(onToggled(bool)) );
+}
+
+void tst_QPushButton::cleanupTestCase()
+{
+ delete testWidget;
+ testWidget = 0;
+}
+
+void tst_QPushButton::init()
+{
+ testWidget->setAutoRepeat( FALSE );
+ testWidget->setDown( FALSE );
+ testWidget->setText("Test");
+ testWidget->setEnabled( TRUE );
+ QKeySequence seq;
+ testWidget->setShortcut( seq );
+
+ resetCounters();
+}
+
+void tst_QPushButton::cleanup()
+{
+}
+
+
+void tst_QPushButton::resetCounters()
+{
+ toggle_count = 0;
+ press_count = 0;
+ release_count = 0;
+ click_count = 0;
+}
+
+void tst_QPushButton::onClicked()
+{
+ click_count++;
+}
+
+void tst_QPushButton::onToggled( bool /*on*/ )
+{
+ toggle_count++;
+}
+
+void tst_QPushButton::onPressed()
+{
+ press_count++;
+}
+
+void tst_QPushButton::onReleased()
+{
+ release_count++;
+}
+
+void tst_QPushButton::autoRepeat()
+{
+ // If this changes, this test must be completely revised.
+ QVERIFY( !testWidget->isCheckable() );
+
+ // verify autorepeat is off by default.
+ QPushButton tmp( 0 );
+ tmp.setObjectName("tmp");
+ QVERIFY( !tmp.autoRepeat() );
+
+ // check if we can toggle the mode
+ testWidget->setAutoRepeat( TRUE );
+ QVERIFY( testWidget->autoRepeat() );
+
+ testWidget->setAutoRepeat( FALSE );
+ QVERIFY( !testWidget->autoRepeat() );
+
+ resetCounters();
+
+ // check that the button is down if we press space and not in autorepeat
+ testWidget->setDown( FALSE );
+ testWidget->setAutoRepeat( FALSE );
+ QTest::keyPress( testWidget, Qt::Key_Space );
+
+ QTest::qWait( 300 );
+
+ QVERIFY( testWidget->isDown() );
+ QVERIFY( toggle_count == 0 );
+ QVERIFY( press_count == 1 );
+ QVERIFY( release_count == 0 );
+ QVERIFY( click_count == 0 );
+
+ QTest::keyRelease( testWidget, Qt::Key_Space );
+ resetCounters();
+
+ // check that the button is down if we press space while in autorepeat
+ // we can't actually confirm how many times it is fired, more than 1 is enough.
+
+ testWidget->setDown( FALSE );
+ testWidget->setAutoRepeat( TRUE );
+ QTest::keyPress( testWidget, Qt::Key_Space );
+ QTest::qWait(900);
+ QVERIFY( testWidget->isDown() );
+ QVERIFY( toggle_count == 0 );
+ QTest::keyRelease( testWidget, Qt::Key_Space );
+ QVERIFY(press_count == release_count);
+ QVERIFY(release_count == click_count);
+ QVERIFY(press_count > 1);
+
+ // #### shouldn't I check here to see if multiple signals have been fired???
+
+ // check that pressing ENTER has no effect
+ resetCounters();
+ testWidget->setDown( FALSE );
+ testWidget->setAutoRepeat( FALSE );
+ QTest::keyPress( testWidget, Qt::Key_Enter );
+
+ QTest::qWait( 300 );
+
+ QVERIFY( !testWidget->isDown() );
+ QVERIFY( toggle_count == 0 );
+ QVERIFY( press_count == 0 );
+ QVERIFY( release_count == 0 );
+ QVERIFY( click_count == 0 );
+ QTest::keyRelease( testWidget, Qt::Key_Enter );
+
+ // check that pressing ENTER has no effect
+ resetCounters();
+ testWidget->setDown( FALSE );
+ testWidget->setAutoRepeat( TRUE );
+ QTest::keyClick( testWidget, Qt::Key_Enter );
+ QTest::qWait( 300 );
+ QVERIFY( !testWidget->isDown() );
+ QVERIFY( toggle_count == 0 );
+ QVERIFY( press_count == 0 );
+ QVERIFY( release_count == 0 );
+ QVERIFY( click_count == 0 );
+}
+
+void tst_QPushButton::pressed()
+{
+ QTest::keyPress( testWidget, ' ' );
+// QTest::qWait( 300 );
+ QCOMPARE( press_count, (uint)1 );
+ QCOMPARE( release_count, (uint)0 );
+
+ QTest::keyRelease( testWidget, ' ' );
+// QTest::qWait( 300 );
+ QCOMPARE( press_count, (uint)1 );
+ QCOMPARE( release_count, (uint)1 );
+
+ QTest::keyPress( testWidget,Qt::Key_Enter );
+// QTest::qWait( 300 );
+ QCOMPARE( press_count, (uint)1 );
+ QCOMPARE( release_count, (uint)1 );
+
+ testWidget->setAutoDefault(true);
+ QTest::keyPress( testWidget,Qt::Key_Enter );
+// QTest::qWait( 300 );
+ QCOMPARE( press_count, (uint)2 );
+ QCOMPARE( release_count, (uint)2 );
+ testWidget->setAutoDefault(false);
+
+}
+
+void tst_QPushButton::isCheckable()
+{
+ QVERIFY( !testWidget->isCheckable() );
+}
+
+void tst_QPushButton::setDown()
+{
+ testWidget->setDown( FALSE );
+ QVERIFY( !testWidget->isDown() );
+
+ testWidget->setDown( TRUE );
+ QVERIFY( testWidget->isDown() );
+
+ testWidget->setDown( TRUE );
+ QTest::keyClick( testWidget, Qt::Key_Escape );
+ QVERIFY( !testWidget->isDown() );
+}
+
+void tst_QPushButton::isChecked()
+{
+ testWidget->setDown( FALSE );
+ QVERIFY( !testWidget->isChecked() );
+
+ testWidget->setDown( TRUE );
+ QVERIFY( !testWidget->isChecked() );
+
+ testWidget->setDown( FALSE );
+ testWidget->toggle();
+ QVERIFY( testWidget->isChecked() == testWidget->isCheckable() );
+}
+
+void tst_QPushButton::toggle()
+{
+ // the pushbutton shouldn't toggle the button.
+ testWidget->toggle();
+ QVERIFY( testWidget->isChecked() == FALSE );
+}
+
+void tst_QPushButton::toggled()
+{
+ // the pushbutton shouldn't send a toggled signal when we call the toggle slot.
+ QVERIFY( !testWidget->isCheckable() );
+
+ testWidget->toggle();
+ QVERIFY( toggle_count == 0 );
+
+ // do it again, just to be sure
+ resetCounters();
+ testWidget->toggle();
+ QVERIFY( toggle_count == 0 );
+
+ // finally check that we can toggle using the mouse
+ resetCounters();
+ QTest::mousePress( testWidget, Qt::LeftButton );
+ QVERIFY( toggle_count == 0 );
+ QVERIFY( click_count == 0 );
+
+ QTest::mouseRelease( testWidget, Qt::LeftButton );
+ QVERIFY( click_count == 1 );
+}
+
+/*
+ If we press an accelerator key we ONLY get a pressed signal and
+ NOT a released or clicked signal.
+*/
+
+void tst_QPushButton::setAccel()
+{
+ testWidget->setText("&AccelTest");
+ QKeySequence seq( Qt::ALT + Qt::Key_A );
+ testWidget->setShortcut( seq );
+
+ // The shortcut will not be activated unless the button is in a active
+ // window and has focus
+ QApplication::setActiveWindow(testWidget);
+ testWidget->setFocus();
+ for (int i = 0; !testWidget->isActiveWindow() && i < 1000; ++i) {
+ testWidget->activateWindow();
+ QApplication::instance()->processEvents();
+ QTest::qWait(100);
+ }
+ QVERIFY(testWidget->isActiveWindow());
+ QTest::keyClick( testWidget, 'A', Qt::AltModifier );
+ QTest::qWait( 50 );
+ QTRY_VERIFY( click_count == 1 );
+ QVERIFY( press_count == 1 );
+ QVERIFY( release_count == 1 );
+ QVERIFY( toggle_count == 0 );
+
+ // wait 200 ms because setAccel uses animateClick.
+ // if we don't wait this may screw up a next test.
+ QTest::qWait(200);
+ QTRY_VERIFY( !testWidget->isDown() );
+}
+
+void tst_QPushButton::animateClick()
+{
+ QVERIFY( !testWidget->isDown() );
+ testWidget->animateClick();
+ QVERIFY( testWidget->isDown() );
+ QTest::qWait( 200 );
+ QVERIFY( !testWidget->isDown() );
+
+ QVERIFY( click_count == 1 );
+ QVERIFY( press_count == 1 );
+ QVERIFY( release_count == 1 );
+ QVERIFY( toggle_count == 0 );
+}
+
+void tst_QPushButton::clicked()
+{
+ QTest::mousePress( testWidget, Qt::LeftButton );
+ QVERIFY( press_count == 1 );
+ QVERIFY( release_count == 0 );
+
+ QTest::mouseRelease( testWidget, Qt::LeftButton );
+ QCOMPARE( press_count, (uint)1 );
+ QCOMPARE( release_count, (uint)1 );
+
+ press_count = 0;
+ release_count = 0;
+ testWidget->setDown(FALSE);
+ for (uint i=0; i<10; i++)
+ QTest::mouseClick( testWidget, Qt::LeftButton );
+ QCOMPARE( press_count, (uint)10 );
+ QCOMPARE( release_count, (uint)10 );
+}
+
+/*
+void tst_QPushButton::group()
+{
+}
+
+void tst_QPushButton::state()
+{
+}
+
+void tst_QPushButton::stateChanged()
+{
+}
+*/
+QPushButton *pb = 0;
+void tst_QPushButton::helperSlotDelete()
+{
+ delete pb;
+ pb = 0;
+}
+
+void tst_QPushButton::popupCrash()
+{
+ pb = new QPushButton("foo");
+ QMenu *menu = new QMenu("bar", pb);
+ pb->setMenu(menu);
+ QTimer::singleShot(1000, this, SLOT(helperSlotDelete()));
+ pb->show();
+ pb->click();
+}
+
+void tst_QPushButton::defaultAndAutoDefault()
+{
+ {
+ // Adding buttons directly to QDialog
+ QDialog dialog;
+
+ QPushButton button1(&dialog);
+ QVERIFY(button1.autoDefault());
+ QVERIFY(!button1.isDefault());
+
+ QPushButton button2(&dialog);
+ QVERIFY(button2.autoDefault());
+ QVERIFY(!button2.isDefault());
+
+ button1.setDefault(true);
+ QVERIFY(button1.autoDefault());
+ QVERIFY(button1.isDefault());
+ QVERIFY(button2.autoDefault());
+ QVERIFY(!button2.isDefault());
+
+ dialog.show();
+ QVERIFY(dialog.isVisible());
+
+ QObject::connect(&button1, SIGNAL(clicked()), &dialog, SLOT(hide()));
+ QKeyEvent event(QEvent::KeyPress, Qt::Key_Return, Qt::NoModifier);
+ QApplication::sendEvent(&dialog, &event);
+ QVERIFY(!dialog.isVisible());
+ }
+
+ {
+ // Adding buttons to QDialog through a layout
+ QDialog dialog;
+
+ QPushButton button3;
+ button3.setAutoDefault(false);
+
+ QPushButton button1;
+ QVERIFY(!button1.autoDefault());
+ QVERIFY(!button1.isDefault());
+
+ QPushButton button2;
+ QVERIFY(!button2.autoDefault());
+ QVERIFY(!button2.isDefault());
+
+ button1.setDefault(true);
+ QVERIFY(!button1.autoDefault());
+ QVERIFY(button1.isDefault());
+ QVERIFY(!button2.autoDefault());
+ QVERIFY(!button2.isDefault());
+
+ QGridLayout layout;
+ layout.addWidget(&button3, 0, 3);
+ layout.addWidget(&button2, 0, 2);
+ layout.addWidget(&button1, 0, 1);
+ dialog.setLayout(&layout);
+ button3.setFocus();
+ QVERIFY(button1.autoDefault());
+ QVERIFY(button1.isDefault());
+ QVERIFY(button2.autoDefault());
+ QVERIFY(!button2.isDefault());
+
+ dialog.show();
+ QVERIFY(dialog.isVisible());
+
+ QObject::connect(&button1, SIGNAL(clicked()), &dialog, SLOT(hide()));
+ QKeyEvent event(QEvent::KeyPress, Qt::Key_Return, Qt::NoModifier);
+ QApplication::sendEvent(&dialog, &event);
+ QVERIFY(!dialog.isVisible());
+ }
+
+ {
+ // autoDefault behavior.
+ QDialog dialog;
+ QPushButton button2(&dialog);
+ QPushButton button1(&dialog);
+ dialog.show();
+ QVERIFY(dialog.isVisible());
+
+ // No default button is set, and button2 is the first autoDefault button
+ // that is next in the tab order
+ QObject::connect(&button2, SIGNAL(clicked()), &dialog, SLOT(hide()));
+ QKeyEvent event(QEvent::KeyPress, Qt::Key_Return, Qt::NoModifier);
+ QApplication::sendEvent(&dialog, &event);
+ QVERIFY(!dialog.isVisible());
+
+ // Reparenting
+ QVERIFY(button2.autoDefault());
+ button2.setParent(0);
+ QVERIFY(!button2.autoDefault());
+ button2.setAutoDefault(false);
+ button2.setParent(&dialog);
+ QVERIFY(!button2.autoDefault());
+
+ button1.setAutoDefault(true);
+ button1.setParent(0);
+ QVERIFY(button1.autoDefault());
+ }
+}
+
+void tst_QPushButton::sizeHint_data()
+{
+ QTest::addColumn<QString>("stylename");
+ QTest::newRow("motif") << QString::fromAscii("motif");
+ QTest::newRow("cde") << QString::fromAscii("cde");
+ QTest::newRow("windows") << QString::fromAscii("windows");
+ QTest::newRow("cleanlooks") << QString::fromAscii("cleanlooks");
+ QTest::newRow("gtk") << QString::fromAscii("gtk");
+ QTest::newRow("mac") << QString::fromAscii("mac");
+ QTest::newRow("plastique") << QString::fromAscii("plastique");
+ QTest::newRow("windowsxp") << QString::fromAscii("windowsxp");
+ QTest::newRow("windowsvista") << QString::fromAscii("windowsvista");
+}
+
+void tst_QPushButton::sizeHint()
+{
+ QFETCH(QString, stylename);
+
+ QStyle *style = QStyleFactory::create(stylename);
+ if (!style)
+ QSKIP(qPrintable(QString::fromLatin1("Qt has been compiled without style: %1")
+ .arg(stylename)), SkipSingle);
+ QApplication::setStyle(style);
+
+// Test 1
+ {
+ QPushButton *button = new QPushButton("123");
+ QSize initSizeHint = button->sizeHint();
+
+ QDialog *dialog = new QDialog;
+ QWidget *widget = new QWidget(dialog);
+ button->setParent(widget);
+ button->sizeHint();
+
+ widget->setParent(0);
+ delete dialog;
+ button->setDefault(false);
+ QCOMPARE(button->sizeHint(), initSizeHint);
+ delete button;
+ }
+
+// Test 2
+ {
+ QWidget *tab1 = new QWidget;
+ QHBoxLayout *layout1 = new QHBoxLayout(tab1);
+ QPushButton *button1_1 = new QPushButton("123");
+ QPushButton *button1_2 = new QPushButton("123");
+ layout1->addWidget(button1_1);
+ layout1->addWidget(button1_2);
+
+ QWidget *tab2 = new QWidget;
+ QHBoxLayout *layout2 = new QHBoxLayout(tab2);
+ QPushButton *button2_1 = new QPushButton("123");
+ QPushButton *button2_2 = new QPushButton("123");
+ layout2->addWidget(button2_1);
+ layout2->addWidget(button2_2);
+
+ QDialog *dialog = new QDialog;
+ QTabWidget *tabWidget = new QTabWidget;
+ tabWidget->addTab(tab1, "1");
+ tabWidget->addTab(tab2, "2");
+ QVBoxLayout *mainLayout = new QVBoxLayout(dialog);
+ mainLayout->addWidget(tabWidget);
+ dialog->show();
+ tabWidget->setCurrentWidget(tab2);
+ tabWidget->setCurrentWidget(tab1);
+ QTest::qWait(100);
+ QApplication::processEvents();
+
+ QCOMPARE(button1_2->size(), button2_2->size());
+ }
+}
+
+QTEST_MAIN(tst_QPushButton)
+#include "tst_qpushbutton.moc"
diff --git a/tests/auto/widgets/widgets/qradiobutton/.gitignore b/tests/auto/widgets/widgets/qradiobutton/.gitignore
new file mode 100644
index 0000000000..ac5e20c562
--- /dev/null
+++ b/tests/auto/widgets/widgets/qradiobutton/.gitignore
@@ -0,0 +1 @@
+tst_qradiobutton
diff --git a/tests/auto/widgets/widgets/qradiobutton/qradiobutton.pro b/tests/auto/widgets/widgets/qradiobutton/qradiobutton.pro
new file mode 100644
index 0000000000..82b2ff20a8
--- /dev/null
+++ b/tests/auto/widgets/widgets/qradiobutton/qradiobutton.pro
@@ -0,0 +1,6 @@
+load(qttest_p4)
+QT += widgets
+SOURCES += tst_qradiobutton.cpp
+
+
+
diff --git a/tests/auto/widgets/widgets/qradiobutton/tst_qradiobutton.cpp b/tests/auto/widgets/widgets/qradiobutton/tst_qradiobutton.cpp
new file mode 100644
index 0000000000..79d3c8ef9a
--- /dev/null
+++ b/tests/auto/widgets/widgets/qradiobutton/tst_qradiobutton.cpp
@@ -0,0 +1,108 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#include <QtTest/QtTest>
+
+
+#include <QRadioButton>
+#include <QPushButton>
+#include <QVBoxLayout>
+#include <QLineEdit>
+
+
+class tst_QRadioButton : public QObject
+{
+Q_OBJECT
+public:
+ tst_QRadioButton(){};
+ virtual ~tst_QRadioButton(){};
+
+private slots:
+ void task190739_focus();
+ void minimumSizeHint();
+
+private:
+};
+
+void tst_QRadioButton::task190739_focus()
+{
+ QWidget widget;
+ QPushButton button1(&widget);
+ button1.setText("button1");
+ QLineEdit edit(&widget);
+ edit.setFocus();
+
+ QRadioButton radio1(&widget);
+ radio1.setText("radio1");
+ radio1.setFocusPolicy(Qt::TabFocus);
+ radio1.setShortcut(QKeySequence("Ctrl+O"));
+
+ QVBoxLayout layout(&widget);
+ layout.addWidget(&button1);
+ layout.addWidget(&edit);
+ layout.addWidget(&radio1);
+
+ widget.show();
+ widget.activateWindow();
+ QApplication::setActiveWindow(&widget);
+ QTest::qWait(100);
+
+ QVERIFY(edit.hasFocus());
+ QVERIFY(!radio1.isChecked());
+
+ QTest::keyClick(&edit, Qt::Key_O, Qt::ControlModifier, 20);
+ QTest::qWait(200);
+ QVERIFY(radio1.isChecked());
+ QVERIFY(edit.hasFocus());
+ QVERIFY(!radio1.hasFocus());
+}
+
+
+void tst_QRadioButton::minimumSizeHint()
+{
+ QRadioButton button(tr("QRadioButtons sizeHint is the same as it's minimumSizeHint"));
+ QCOMPARE(button.sizeHint(), button.minimumSizeHint());
+}
+
+
+QTEST_MAIN(tst_QRadioButton)
+#include "tst_qradiobutton.moc"
diff --git a/tests/auto/widgets/widgets/qregexpvalidator/.gitignore b/tests/auto/widgets/widgets/qregexpvalidator/.gitignore
new file mode 100644
index 0000000000..cff9b076b2
--- /dev/null
+++ b/tests/auto/widgets/widgets/qregexpvalidator/.gitignore
@@ -0,0 +1 @@
+tst_qregexpvalidator
diff --git a/tests/auto/widgets/widgets/qregexpvalidator/qregexpvalidator.pro b/tests/auto/widgets/widgets/qregexpvalidator/qregexpvalidator.pro
new file mode 100644
index 0000000000..68e5c51677
--- /dev/null
+++ b/tests/auto/widgets/widgets/qregexpvalidator/qregexpvalidator.pro
@@ -0,0 +1,4 @@
+load(qttest_p4)
+SOURCES += tst_qregexpvalidator.cpp
+
+
diff --git a/tests/auto/widgets/widgets/qregexpvalidator/tst_qregexpvalidator.cpp b/tests/auto/widgets/widgets/qregexpvalidator/tst_qregexpvalidator.cpp
new file mode 100644
index 0000000000..23cd5b1ef1
--- /dev/null
+++ b/tests/auto/widgets/widgets/qregexpvalidator/tst_qregexpvalidator.cpp
@@ -0,0 +1,127 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#include <QtTest/QtTest>
+#include <qregexp.h>
+
+
+#include <qvalidator.h>
+
+//TESTED_CLASS=
+//TESTED_FILES=corelib/tools/qregexp.h corelib/tools/qregexp.cpp
+
+class tst_QRegExpValidator : public QObject
+{
+ Q_OBJECT
+
+public:
+ tst_QRegExpValidator();
+ virtual ~tst_QRegExpValidator();
+
+
+ // I can think of no other way to do this for the moment
+ enum State { Invalid=0, Intermediate=1, Acceptable=2 };
+public slots:
+ void init();
+ void cleanup();
+private slots:
+ void validate_data();
+ void validate();
+};
+
+tst_QRegExpValidator::tst_QRegExpValidator()
+{
+}
+
+tst_QRegExpValidator::~tst_QRegExpValidator()
+{
+
+}
+
+void tst_QRegExpValidator::init()
+{
+}
+
+void tst_QRegExpValidator::cleanup()
+{
+}
+
+void tst_QRegExpValidator::validate_data()
+{
+
+ QTest::addColumn<QString>("rx");
+ QTest::addColumn<QString>("value");
+ QTest::addColumn<int>("state");
+
+ QTest::newRow( "data0" ) << QString("[1-9]\\d{0,3}") << QString("0") << 0;
+ QTest::newRow( "data1" ) << QString("[1-9]\\d{0,3}") << QString("12345") << 0;
+ QTest::newRow( "data2" ) << QString("[1-9]\\d{0,3}") << QString("1") << 2;
+
+ QTest::newRow( "data3" ) << QString("\\S+") << QString("myfile.txt") << 2;
+ QTest::newRow( "data4" ) << QString("\\S+") << QString("my file.txt") << 0;
+
+ QTest::newRow( "data5" ) << QString("[A-C]\\d{5}[W-Z]") << QString("a12345Z") << 0;
+ QTest::newRow( "data6" ) << QString("[A-C]\\d{5}[W-Z]") << QString("A12345Z") << 2;
+ QTest::newRow( "data7" ) << QString("[A-C]\\d{5}[W-Z]") << QString("B12") << 1;
+
+ QTest::newRow( "data8" ) << QString("read\\S?me(\\.(txt|asc|1st))?") << QString("readme") << 2;
+ QTest::newRow( "data9" ) << QString("read\\S?me(\\.(txt|asc|1st))?") << QString("read me.txt") << 0;
+ QTest::newRow( "data10" ) << QString("read\\S?me(\\.(txt|asc|1st))?") << QString("readm") << 1;
+}
+
+void tst_QRegExpValidator::validate()
+{
+ QFETCH( QString, rx );
+ QFETCH( QString, value );
+ QFETCH( int, state );
+
+ QRegExpValidator rv( 0 );
+ QSignalSpy spy(&rv, SIGNAL(regExpChanged(const QRegExp&)));
+
+ rv.setRegExp( QRegExp( rx ) );
+ int dummy;
+ QCOMPARE( (int)rv.validate( value, dummy ), state );
+ QCOMPARE(spy.count(), 1);
+}
+
+QTEST_MAIN(tst_QRegExpValidator)
+#include "tst_qregexpvalidator.moc"
diff --git a/tests/auto/widgets/widgets/qscrollarea/.gitignore b/tests/auto/widgets/widgets/qscrollarea/.gitignore
new file mode 100644
index 0000000000..aace58e9b1
--- /dev/null
+++ b/tests/auto/widgets/widgets/qscrollarea/.gitignore
@@ -0,0 +1 @@
+tst_qscrollarea
diff --git a/tests/auto/widgets/widgets/qscrollarea/qscrollarea.pro b/tests/auto/widgets/widgets/qscrollarea/qscrollarea.pro
new file mode 100644
index 0000000000..5b2602bbdb
--- /dev/null
+++ b/tests/auto/widgets/widgets/qscrollarea/qscrollarea.pro
@@ -0,0 +1,9 @@
+############################################################
+# Project file for autotest for file qscrollarea.h
+############################################################
+
+load(qttest_p4)
+QT += widgets
+SOURCES += tst_qscrollarea.cpp
+
+
diff --git a/tests/auto/widgets/widgets/qscrollarea/tst_qscrollarea.cpp b/tests/auto/widgets/widgets/qscrollarea/tst_qscrollarea.cpp
new file mode 100644
index 0000000000..8dcfb079d2
--- /dev/null
+++ b/tests/auto/widgets/widgets/qscrollarea/tst_qscrollarea.cpp
@@ -0,0 +1,185 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#include <QtTest/QtTest>
+
+#include <qcoreapplication.h>
+#include <qdebug.h>
+#include <qscrollarea.h>
+#include <qlayout.h>
+
+//TESTED_CLASS=
+//TESTED_FILES=
+
+class tst_QScrollArea : public QObject
+{
+Q_OBJECT
+
+public:
+ tst_QScrollArea();
+ virtual ~tst_QScrollArea();
+
+private slots:
+ void getSetCheck();
+ void ensureMicroFocusVisible_Task_167838();
+ void checkHFW_Task_197736();
+};
+
+tst_QScrollArea::tst_QScrollArea()
+{
+}
+
+tst_QScrollArea::~tst_QScrollArea()
+{
+}
+
+// Testing get/set functions
+void tst_QScrollArea::getSetCheck()
+{
+ QScrollArea obj1;
+ // QWidget * QScrollArea::widget()
+ // void QScrollArea::setWidget(QWidget *)
+ QWidget *var1 = new QWidget();
+ obj1.setWidget(var1);
+ QCOMPARE(var1, obj1.widget());
+ obj1.setWidget((QWidget *)0);
+ QCOMPARE(var1, obj1.widget()); // Cannot set a 0-widget. Old widget returned
+ // delete var1; // No delete, since QScrollArea takes ownership
+
+ // bool QScrollArea::widgetResizable()
+ // void QScrollArea::setWidgetResizable(bool)
+ obj1.setWidgetResizable(false);
+ QCOMPARE(false, obj1.widgetResizable());
+ obj1.setWidgetResizable(true);
+ QCOMPARE(true, obj1.widgetResizable());
+}
+
+class WidgetWithMicroFocus : public QWidget
+{
+public:
+ WidgetWithMicroFocus(QWidget *parent = 0) : QWidget(parent)
+ {
+ setBackgroundRole(QPalette::Dark);
+ }
+protected:
+ QVariant inputMethodQuery(Qt::InputMethodQuery query) const
+ {
+ if (query == Qt::ImMicroFocus)
+ return QRect(width() / 2, height() / 2, 5, 5);
+ return QWidget::inputMethodQuery(query);
+ }
+// void paintEvent(QPaintEvent *event)
+// {
+// QPainter painter(this);
+// painter.fillRect(rect(), QBrush(Qt::red));
+// }
+};
+
+void tst_QScrollArea::ensureMicroFocusVisible_Task_167838()
+{
+ QScrollArea scrollArea;
+ scrollArea.resize(100, 100);
+ scrollArea.show();
+ QWidget *parent = new QWidget;
+ parent->setLayout(new QVBoxLayout);
+ QWidget *child = new WidgetWithMicroFocus;
+ parent->layout()->addWidget(child);
+ parent->resize(300, 300);
+ scrollArea.setWidget(parent);
+ scrollArea.ensureWidgetVisible(child, 10, 10);
+ QRect microFocus = child->inputMethodQuery(Qt::ImMicroFocus).toRect();
+ QPoint p = child->mapTo(scrollArea.viewport(), microFocus.topLeft());
+ microFocus.translate(p - microFocus.topLeft());
+ QVERIFY(scrollArea.viewport()->rect().contains(microFocus));
+}
+
+class HFWWidget : public QWidget
+{
+ public:
+ HFWWidget();
+ int heightForWidth(int w) const;
+};
+
+HFWWidget::HFWWidget()
+ : QWidget()
+{
+ setMinimumSize(QSize(100,50));
+ QSizePolicy s = sizePolicy();
+ s.setHeightForWidth(true);
+ setSizePolicy(s);
+}
+
+int HFWWidget::heightForWidth(int w) const
+{
+ // Mimic a label - the narrower we are, the taller we have to be
+ if (w > 0)
+ return 40000 / w;
+ else
+ return 40000;
+}
+
+void tst_QScrollArea::checkHFW_Task_197736()
+{
+ QScrollArea scrollArea;
+ HFWWidget *w = new HFWWidget;
+ scrollArea.resize(200,100);
+ scrollArea.show();
+ scrollArea.setWidgetResizable(true);
+ scrollArea.setWidget(w);
+
+ // at 200x100px, we expect HFW to be 200px tall, not 100px
+ QVERIFY(w->height() >= 200);
+
+ // at 200x300px, we expect HFW to be 300px tall (the heightForWidth is a min, not prescribed)
+ scrollArea.resize(QSize(200, 300));
+ QVERIFY(w->height() >= 250); // 50px for a fudge factor (size of frame margins/scrollbars etc)
+
+ // make sure this only happens with widget resizable
+ scrollArea.setWidgetResizable(false);
+ scrollArea.resize(QSize(100,100));
+ w->resize(QSize(200,200));
+ QVERIFY(w->width() == 200);
+ QVERIFY(w->height() == 200);
+}
+
+QTEST_MAIN(tst_QScrollArea)
+#include "tst_qscrollarea.moc"
diff --git a/tests/auto/widgets/widgets/qscrollbar/.gitignore b/tests/auto/widgets/widgets/qscrollbar/.gitignore
new file mode 100644
index 0000000000..ae4ffe1e02
--- /dev/null
+++ b/tests/auto/widgets/widgets/qscrollbar/.gitignore
@@ -0,0 +1 @@
+tst_qscrollbar
diff --git a/tests/auto/widgets/widgets/qscrollbar/qscrollbar.pro b/tests/auto/widgets/widgets/qscrollbar/qscrollbar.pro
new file mode 100644
index 0000000000..262855452f
--- /dev/null
+++ b/tests/auto/widgets/widgets/qscrollbar/qscrollbar.pro
@@ -0,0 +1,6 @@
+load(qttest_p4)
+QT += widgets
+SOURCES += tst_qscrollbar.cpp
+
+mac*:CONFIG+=insignificant_test
+CONFIG += insignificant_test # QTBUG-21402
diff --git a/tests/auto/widgets/widgets/qscrollbar/tst_qscrollbar.cpp b/tests/auto/widgets/widgets/qscrollbar/tst_qscrollbar.cpp
new file mode 100644
index 0000000000..c4b64f3f1e
--- /dev/null
+++ b/tests/auto/widgets/widgets/qscrollbar/tst_qscrollbar.cpp
@@ -0,0 +1,147 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#include <QtTest/QtTest>
+#include <QScrollBar>
+#include <QStyleOptionSlider>
+#include <QScrollArea>
+
+class tst_QScrollBar : public QObject
+{
+ Q_OBJECT
+public slots:
+ void initTestCase();
+ void cleanupTestCase();
+ void hideAndShow(int action);
+
+private slots:
+ void scrollSingleStep();
+ void task_209492();
+
+private:
+ QScrollBar *testWidget;
+};
+
+void tst_QScrollBar::initTestCase()
+{
+ testWidget = new QScrollBar(Qt::Horizontal);
+ testWidget->resize(100, testWidget->height());
+ testWidget->show();
+}
+
+void tst_QScrollBar::cleanupTestCase()
+{
+ delete testWidget;
+ testWidget = 0;
+}
+
+void tst_QScrollBar::hideAndShow(int)
+{
+ testWidget->hide();
+ testWidget->show();
+}
+
+// Check that the scrollbar doesn't scroll after calling hide and show
+// from a slot connected to the scrollbar's actionTriggered signal.
+void tst_QScrollBar::scrollSingleStep()
+{
+ testWidget->setValue(testWidget->minimum());
+ QCOMPARE(testWidget->value(), testWidget->minimum());
+ connect(testWidget, SIGNAL(actionTriggered(int)), this, SLOT(hideAndShow(int)));
+
+ // Get rect for the area to click on
+ const QStyleOptionSlider opt = qt_qscrollbarStyleOption(testWidget);
+ QRect sr = testWidget->style()->subControlRect(QStyle::CC_ScrollBar, &opt,
+ QStyle::SC_ScrollBarAddLine, testWidget);
+
+ if (!sr.isValid())
+ QSKIP("SC_ScrollBarAddLine not valid", SkipAll);
+
+ QTest::mouseClick(testWidget, Qt::LeftButton, Qt::NoModifier, QPoint(sr.x(), sr.y()));
+ QTest::qWait(510); // initial delay is 500 for setRepeatAction
+ disconnect(testWidget, SIGNAL(actionTriggered(int)), 0, 0);
+ QCOMPARE(testWidget->value(), testWidget->singleStep());
+}
+
+void tst_QScrollBar::task_209492()
+{
+ class MyScrollArea : public QScrollArea
+ {
+ public:
+ int scrollCount;
+ MyScrollArea(QWidget *parent = 0) : QScrollArea(parent), scrollCount(0) {}
+ protected:
+ void paintEvent(QPaintEvent *) { QTest::qSleep(600); }
+ void scrollContentsBy(int, int) { ++scrollCount; viewport()->update(); }
+ };
+
+ MyScrollArea scrollArea;
+ QScrollBar *verticalScrollBar = scrollArea.verticalScrollBar();
+ verticalScrollBar->setRange(0, 1000);
+ scrollArea.show();
+ QTest::qWait(300);
+
+ QSignalSpy spy(verticalScrollBar, SIGNAL(actionTriggered(int)));
+ QCOMPARE(scrollArea.scrollCount, 0);
+ QCOMPARE(spy.count(), 0);
+
+ // Simulate a mouse click on the "scroll down button".
+ const QPoint pressPoint(verticalScrollBar->width() / 2, verticalScrollBar->height() - 10);
+ const QPoint globalPressPoint = verticalScrollBar->mapToGlobal(globalPressPoint);
+ QMouseEvent mousePressEvent(QEvent::MouseButtonPress, pressPoint, globalPressPoint,
+ Qt::LeftButton, Qt::LeftButton, 0);
+ QApplication::sendEvent(verticalScrollBar, &mousePressEvent);
+ QTest::qWait(1);
+ QMouseEvent mouseReleaseEvent(QEvent::MouseButtonRelease, pressPoint, globalPressPoint,
+ Qt::LeftButton, Qt::LeftButton, 0);
+ QApplication::sendEvent(verticalScrollBar, &mouseReleaseEvent);
+
+ // Check that the action was triggered once.
+#ifdef Q_WS_MAC
+ QEXPECT_FAIL("", "Fix does does not work on Mac due to paint architechure differences.", Abort);
+#endif
+ QCOMPARE(scrollArea.scrollCount, 1);
+ QCOMPARE(spy.count(), 1);
+}
+
+QTEST_MAIN(tst_QScrollBar)
+#include "tst_qscrollbar.moc"
diff --git a/tests/auto/widgets/widgets/qsizegrip/.gitignore b/tests/auto/widgets/widgets/qsizegrip/.gitignore
new file mode 100644
index 0000000000..ec480bcbad
--- /dev/null
+++ b/tests/auto/widgets/widgets/qsizegrip/.gitignore
@@ -0,0 +1 @@
+tst_qsizegrip
diff --git a/tests/auto/widgets/widgets/qsizegrip/qsizegrip.pro b/tests/auto/widgets/widgets/qsizegrip/qsizegrip.pro
new file mode 100644
index 0000000000..da6dd5af49
--- /dev/null
+++ b/tests/auto/widgets/widgets/qsizegrip/qsizegrip.pro
@@ -0,0 +1,6 @@
+load(qttest_p4)
+INCLUDEPATH += .
+QT += widgets
+SOURCES += tst_qsizegrip.cpp
+
+
diff --git a/tests/auto/widgets/widgets/qsizegrip/tst_qsizegrip.cpp b/tests/auto/widgets/widgets/qsizegrip/tst_qsizegrip.cpp
new file mode 100644
index 0000000000..cc0710a65a
--- /dev/null
+++ b/tests/auto/widgets/widgets/qsizegrip/tst_qsizegrip.cpp
@@ -0,0 +1,201 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#include <QtTest/QtTest>
+#include <QSizeGrip>
+#include <QEvent>
+#include <QLineEdit>
+#include <QVBoxLayout>
+#include <QLabel>
+
+static inline Qt::Corner sizeGripCorner(QWidget *parent, QSizeGrip *sizeGrip)
+{
+ if (!parent || !sizeGrip)
+ return Qt::TopLeftCorner;
+
+ const QPoint sizeGripPos = sizeGrip->mapTo(parent, QPoint(0, 0));
+ bool isAtBottom = sizeGripPos.y() >= parent->height() / 2;
+ bool isAtLeft = sizeGripPos.x() <= parent->width() / 2;
+ if (isAtLeft)
+ return isAtBottom ? Qt::BottomLeftCorner : Qt::TopLeftCorner;
+ else
+ return isAtBottom ? Qt::BottomRightCorner : Qt::TopRightCorner;
+
+}
+
+//TESTED_CLASS=
+//TESTED_FILES=
+
+Q_DECLARE_METATYPE(Qt::WindowType);
+
+class tst_QSizeGrip : public QObject
+{
+ Q_OBJECT
+public slots:
+ void initTestCase();
+ void cleanupTestCase();
+
+private slots:
+ void hideAndShowOnWindowStateChange_data();
+ void hideAndShowOnWindowStateChange();
+ void orientation();
+
+private:
+ QLineEdit *dummyWidget;
+};
+
+class TestWidget : public QWidget
+{
+public:
+ TestWidget(QWidget *parent = 0, Qt::WindowFlags flags = 0) : QWidget(parent, flags) {}
+ QSize sizeHint() const { return QSize(300, 200); }
+ void changeEvent(QEvent *event)
+ {
+ QWidget::changeEvent(event);
+ if (isWindow() && event->type() == QEvent::WindowStateChange) {
+#ifdef Q_WS_X11
+ qt_x11_wait_for_window_manager(this);
+#endif
+ }
+ }
+};
+
+void tst_QSizeGrip::initTestCase()
+{
+ dummyWidget = new QLineEdit;
+ dummyWidget->show();
+}
+
+void tst_QSizeGrip::cleanupTestCase()
+{
+ delete dummyWidget;
+ dummyWidget = 0;
+}
+
+void tst_QSizeGrip::hideAndShowOnWindowStateChange_data()
+{
+ QTest::addColumn<Qt::WindowType>("windowType");
+ QTest::newRow("Qt::Window") << Qt::Window;
+ QTest::newRow("Qt::SubWindow") << Qt::SubWindow;
+}
+
+void tst_QSizeGrip::hideAndShowOnWindowStateChange()
+{
+ QFETCH(Qt::WindowType, windowType);
+
+ QWidget *parentWidget = windowType == Qt::Window ? 0 : new QWidget;
+ TestWidget *widget = new TestWidget(parentWidget, Qt::WindowFlags(windowType));
+ QSizeGrip *sizeGrip = new QSizeGrip(widget);
+
+ // Normal.
+ if (parentWidget)
+ parentWidget->show();
+ else
+ widget->show();
+ QVERIFY(sizeGrip->isVisible());
+
+ widget->showFullScreen();
+ QVERIFY(!sizeGrip->isVisible());
+
+ widget->showNormal();
+ QVERIFY(sizeGrip->isVisible());
+
+ widget->showMaximized();
+#ifndef Q_WS_MAC
+ QVERIFY(!sizeGrip->isVisible());
+#else
+ QVERIFY(sizeGrip->isVisible());
+#endif
+
+ widget->showNormal();
+ QVERIFY(sizeGrip->isVisible());
+
+ sizeGrip->hide();
+ QVERIFY(!sizeGrip->isVisible());
+
+ widget->showFullScreen();
+ widget->showNormal();
+ QVERIFY(!sizeGrip->isVisible());
+ widget->showMaximized();
+ widget->showNormal();
+ QVERIFY(!sizeGrip->isVisible());
+
+ delete widget;
+ delete parentWidget;
+}
+
+void tst_QSizeGrip::orientation()
+{
+ TestWidget widget;
+ widget.setLayout(new QVBoxLayout);
+ QSizeGrip *sizeGrip = new QSizeGrip(&widget);
+ sizeGrip->setFixedSize(sizeGrip->sizeHint());
+ widget.layout()->addWidget(sizeGrip);
+ widget.layout()->setAlignment(sizeGrip, Qt::AlignBottom | Qt::AlignRight);
+
+ widget.show();
+ QCOMPARE(sizeGripCorner(&widget, sizeGrip), Qt::BottomRightCorner);
+
+ widget.setLayoutDirection(Qt::RightToLeft);
+ qApp->processEvents();
+ QCOMPARE(sizeGripCorner(&widget, sizeGrip), Qt::BottomLeftCorner);
+
+ widget.unsetLayoutDirection();
+ qApp->processEvents();
+ QCOMPARE(sizeGripCorner(&widget, sizeGrip), Qt::BottomRightCorner);
+
+ widget.layout()->setAlignment(sizeGrip, Qt::AlignTop | Qt::AlignRight);
+ qApp->processEvents();
+ QCOMPARE(sizeGripCorner(&widget, sizeGrip), Qt::TopRightCorner);
+
+ widget.setLayoutDirection(Qt::RightToLeft);
+ qApp->processEvents();
+ QCOMPARE(sizeGripCorner(&widget, sizeGrip), Qt::TopLeftCorner);
+
+ widget.unsetLayoutDirection();
+ qApp->processEvents();
+ QCOMPARE(sizeGripCorner(&widget, sizeGrip), Qt::TopRightCorner);
+}
+
+QTEST_MAIN(tst_QSizeGrip)
+#include "tst_qsizegrip.moc"
+
diff --git a/tests/auto/widgets/widgets/qslider/.gitignore b/tests/auto/widgets/widgets/qslider/.gitignore
new file mode 100644
index 0000000000..f8d833e8b4
--- /dev/null
+++ b/tests/auto/widgets/widgets/qslider/.gitignore
@@ -0,0 +1 @@
+tst_qslider
diff --git a/tests/auto/widgets/widgets/qslider/qslider.pro b/tests/auto/widgets/widgets/qslider/qslider.pro
new file mode 100644
index 0000000000..41f011649d
--- /dev/null
+++ b/tests/auto/widgets/widgets/qslider/qslider.pro
@@ -0,0 +1,9 @@
+############################################################
+# Project file for autotest for file qslider.h
+############################################################
+
+load(qttest_p4)
+QT += widgets
+SOURCES += tst_qslider.cpp
+
+
diff --git a/tests/auto/widgets/widgets/qslider/tst_qslider.cpp b/tests/auto/widgets/widgets/qslider/tst_qslider.cpp
new file mode 100644
index 0000000000..50ee9e6a63
--- /dev/null
+++ b/tests/auto/widgets/widgets/qslider/tst_qslider.cpp
@@ -0,0 +1,98 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#include <QtTest/QtTest>
+
+#include <qcoreapplication.h>
+#include <qdebug.h>
+#include <qslider.h>
+
+//TESTED_CLASS=
+//TESTED_FILES=
+
+class tst_QSlider : public QObject
+{
+Q_OBJECT
+
+public:
+ tst_QSlider();
+ virtual ~tst_QSlider();
+
+private slots:
+ void getSetCheck();
+};
+
+tst_QSlider::tst_QSlider()
+{
+}
+
+tst_QSlider::~tst_QSlider()
+{
+}
+
+// Testing get/set functions
+void tst_QSlider::getSetCheck()
+{
+ QSlider obj1;
+ // TickPosition QSlider::tickPosition()
+ // void QSlider::setTickPosition(TickPosition)
+ obj1.setTickPosition(QSlider::TickPosition(QSlider::NoTicks));
+ QCOMPARE(QSlider::TickPosition(QSlider::NoTicks), obj1.tickPosition());
+ obj1.setTickPosition(QSlider::TickPosition(QSlider::TicksAbove));
+ QCOMPARE(QSlider::TickPosition(QSlider::TicksAbove), obj1.tickPosition());
+ obj1.setTickPosition(QSlider::TickPosition(QSlider::TicksBelow));
+ QCOMPARE(QSlider::TickPosition(QSlider::TicksBelow), obj1.tickPosition());
+ obj1.setTickPosition(QSlider::TickPosition(QSlider::TicksBothSides));
+ QCOMPARE(QSlider::TickPosition(QSlider::TicksBothSides), obj1.tickPosition());
+
+ // int QSlider::tickInterval()
+ // void QSlider::setTickInterval(int)
+ obj1.setTickInterval(0);
+ QCOMPARE(0, obj1.tickInterval());
+ obj1.setTickInterval(INT_MIN);
+ QCOMPARE(0, obj1.tickInterval()); // Can't have a negative interval
+ obj1.setTickInterval(INT_MAX);
+ QCOMPARE(INT_MAX, obj1.tickInterval());
+}
+
+QTEST_MAIN(tst_QSlider)
+#include "tst_qslider.moc"
diff --git a/tests/auto/widgets/widgets/qspinbox/.gitignore b/tests/auto/widgets/widgets/qspinbox/.gitignore
new file mode 100644
index 0000000000..84599cf955
--- /dev/null
+++ b/tests/auto/widgets/widgets/qspinbox/.gitignore
@@ -0,0 +1 @@
+tst_qspinbox
diff --git a/tests/auto/widgets/widgets/qspinbox/qspinbox.pro b/tests/auto/widgets/widgets/qspinbox/qspinbox.pro
new file mode 100644
index 0000000000..c88dc0ee8f
--- /dev/null
+++ b/tests/auto/widgets/widgets/qspinbox/qspinbox.pro
@@ -0,0 +1,3 @@
+load(qttest_p4)
+QT += widgets
+SOURCES += tst_qspinbox.cpp
diff --git a/tests/auto/widgets/widgets/qspinbox/tst_qspinbox.cpp b/tests/auto/widgets/widgets/qspinbox/tst_qspinbox.cpp
new file mode 100644
index 0000000000..608dcd6705
--- /dev/null
+++ b/tests/auto/widgets/widgets/qspinbox/tst_qspinbox.cpp
@@ -0,0 +1,1049 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#include <QtTest/QtTest>
+#include <qdebug.h>
+#include <qapplication.h>
+#include <limits.h>
+
+#ifdef Q_WS_X11
+#include <unistd.h>
+#endif
+
+#include <qspinbox.h>
+#include <qlocale.h>
+#include <qlineedit.h>
+#include <qlayout.h>
+#include <QSpinBox>
+#include <QWidget>
+#include <QString>
+#include <QValidator>
+#include <QLineEdit>
+#include <QObject>
+#include <QStringList>
+#include <QList>
+#include <QLocale>
+#include <QDoubleSpinBox>
+#include <QVBoxLayout>
+#include <QKeySequence>
+#include <QStackedWidget>
+#include <QDebug>
+
+//TESTED_CLASS=
+//TESTED_FILES=
+
+class SpinBox : public QSpinBox
+{
+public:
+ SpinBox(QWidget *parent = 0)
+ : QSpinBox(parent)
+ {}
+ QString textFromValue(int v) const
+ {
+ return QSpinBox::textFromValue(v);
+ }
+ QValidator::State validate(QString &text, int &pos) const
+ {
+ return QSpinBox::validate(text, pos);
+ }
+ int valueFromText(const QString &text) const
+ {
+ return QSpinBox::valueFromText(text);
+ }
+
+ QLineEdit *lineEdit() const { return QSpinBox::lineEdit(); }
+};
+
+class tst_QSpinBox : public QObject
+{
+ Q_OBJECT
+public:
+ tst_QSpinBox();
+ virtual ~tst_QSpinBox();
+public slots:
+ void initTestCase();
+ void init();
+ void cleanupTestCase();
+private slots:
+ void getSetCheck();
+ void setValue_data();
+ void setValue();
+
+ void setPrefixSuffix_data();
+ void setPrefixSuffix();
+
+ void setReadOnly();
+
+ void setTracking_data();
+ void setTracking();
+
+ void locale_data();
+ void locale();
+
+ void setWrapping_data();
+ void setWrapping();
+
+ void setSpecialValueText_data();
+ void setSpecialValueText();
+
+ void setSingleStep_data();
+ void setSingleStep();
+
+ void setMinMax_data();
+ void setMinMax();
+
+ void editingFinished();
+
+ void valueFromTextAndValidate_data();
+ void valueFromTextAndValidate();
+
+ void removeAll();
+ void startWithDash();
+ void undoRedo();
+
+ void specialValue();
+ void textFromValue();
+
+ void sizeHint();
+
+ void taskQTBUG_5008_textFromValueAndValidate();
+
+public slots:
+ void valueChangedHelper(const QString &);
+ void valueChangedHelper(int);
+private:
+ QStringList actualTexts;
+ QList<int> actualValues;
+ QWidget *testFocusWidget;
+};
+
+typedef QList<int> IntList;
+Q_DECLARE_METATYPE(IntList)
+Q_DECLARE_METATYPE(QLocale)
+
+// Testing get/set functions
+void tst_QSpinBox::getSetCheck()
+{
+ QSpinBox obj1;
+ // int QSpinBox::singleStep()
+ // void QSpinBox::setSingleStep(int)
+ obj1.setSingleStep(0);
+ QCOMPARE(0, obj1.singleStep());
+ obj1.setSingleStep(INT_MIN);
+ QCOMPARE(0, obj1.singleStep()); // Can't have negative steps => keep old value
+ obj1.setSingleStep(INT_MAX);
+ QCOMPARE(INT_MAX, obj1.singleStep());
+
+ // int QSpinBox::minimum()
+ // void QSpinBox::setMinimum(int)
+ obj1.setMinimum(0);
+ QCOMPARE(0, obj1.minimum());
+ obj1.setMinimum(INT_MIN);
+ QCOMPARE(INT_MIN, obj1.minimum());
+ obj1.setMinimum(INT_MAX);
+ QCOMPARE(INT_MAX, obj1.minimum());
+
+ // int QSpinBox::maximum()
+ // void QSpinBox::setMaximum(int)
+ obj1.setMaximum(0);
+ QCOMPARE(0, obj1.maximum());
+ obj1.setMaximum(INT_MIN);
+ QCOMPARE(INT_MIN, obj1.maximum());
+ obj1.setMaximum(INT_MAX);
+ QCOMPARE(INT_MAX, obj1.maximum());
+
+ // int QSpinBox::value()
+ // void QSpinBox::setValue(int)
+ obj1.setValue(0);
+ QCOMPARE(0, obj1.value());
+ obj1.setValue(INT_MIN);
+ QCOMPARE(INT_MIN, obj1.value());
+ obj1.setValue(INT_MAX);
+ QCOMPARE(INT_MAX, obj1.value());
+
+ QDoubleSpinBox obj2;
+ // double QDoubleSpinBox::singleStep()
+ // void QDoubleSpinBox::setSingleStep(double)
+ obj2.setSingleStep(0.0);
+ QCOMPARE(0.0, obj2.singleStep());
+ obj2.setSingleStep(1.0);
+ QCOMPARE(1.0, obj2.singleStep());
+
+ // double QDoubleSpinBox::minimum()
+ // void QDoubleSpinBox::setMinimum(double)
+ obj2.setMinimum(1.0);
+ QCOMPARE(1.0, obj2.minimum());
+ obj2.setMinimum(0.0);
+ QCOMPARE(0.0, obj2.minimum());
+ obj2.setMinimum(-1.0);
+ QCOMPARE(-1.0, obj2.minimum());
+
+ // double QDoubleSpinBox::maximum()
+ // void QDoubleSpinBox::setMaximum(double)
+ obj2.setMaximum(-1.0);
+ QCOMPARE(-1.0, obj2.maximum());
+ obj2.setMaximum(0.0);
+ QCOMPARE(0.0, obj2.maximum());
+ obj2.setMaximum(1.0);
+ QCOMPARE(1.0, obj2.maximum());
+
+ // int QDoubleSpinBox::decimals()
+ // void QDoubleSpinBox::setDecimals(int)
+ obj2.setDecimals(0);
+ QCOMPARE(0, obj2.decimals());
+ obj2.setDecimals(INT_MIN);
+ QCOMPARE(0, obj2.decimals()); // Range<0, 13>
+
+ //obj2.setDecimals(INT_MAX);
+ //QCOMPARE(13, obj2.decimals()); // Range<0, 13>
+ obj2.setDecimals(128);
+ QCOMPARE(obj2.decimals(), 128); // Range<0, 128>
+
+ // double QDoubleSpinBox::value()
+ // void QDoubleSpinBox::setValue(double)
+ obj2.setValue(-1.0);
+ QCOMPARE(-1.0, obj2.value());
+ obj2.setValue(0.0);
+ QCOMPARE(0.0, obj2.value());
+ obj2.setValue(1.0);
+ QCOMPARE(1.0, obj2.value());
+
+ // Make sure we update line edit geometry when updating
+ // buttons - see task 235747
+ QRect oldEditGeometry = obj1.childrenRect();
+ obj1.setButtonSymbols(QAbstractSpinBox::NoButtons);
+ QVERIFY(obj1.childrenRect() != oldEditGeometry);
+}
+
+tst_QSpinBox::tst_QSpinBox()
+{
+
+}
+
+tst_QSpinBox::~tst_QSpinBox()
+{
+
+}
+
+void tst_QSpinBox::initTestCase()
+{
+ testFocusWidget = new QWidget(0);
+ testFocusWidget->resize(200, 100);
+ testFocusWidget->show();
+}
+
+void tst_QSpinBox::init()
+{
+ QLocale::setDefault(QLocale(QLocale::C));
+}
+
+void tst_QSpinBox::cleanupTestCase()
+{
+ delete testFocusWidget;
+ testFocusWidget = 0;
+}
+
+void tst_QSpinBox::setValue_data()
+{
+ QTest::addColumn<int>("set");
+ QTest::addColumn<int>("expected");
+
+ QTest::newRow("data0") << 0 << 0;
+ QTest::newRow("data1") << 100 << 100;
+ QTest::newRow("data2") << -100 << -100;
+ QTest::newRow("data3") << INT_MIN << INT_MIN;
+ QTest::newRow("data4") << INT_MAX << INT_MAX;
+}
+
+void tst_QSpinBox::setValue()
+{
+ QFETCH(int, set);
+ QFETCH(int, expected);
+ QSpinBox spin(0);
+ spin.setRange(INT_MIN, INT_MAX);
+ spin.setValue(set);
+ QCOMPARE(spin.value(), expected);
+}
+
+void tst_QSpinBox::setPrefixSuffix_data()
+{
+ QTest::addColumn<QString>("prefix");
+ QTest::addColumn<QString>("suffix");
+ QTest::addColumn<int>("value");
+ QTest::addColumn<QString>("expectedText");
+ QTest::addColumn<QString>("expectedCleanText");
+ QTest::addColumn<bool>("show");
+
+ QTest::newRow("data0") << QString() << QString() << 10 << "10" << "10" << false;
+ QTest::newRow("data1") << QString() << "cm" << 10 << "10cm" << "10" << false;
+ QTest::newRow("data2") << "cm: " << QString() << 10 << "cm: 10" << "10" << false;
+ QTest::newRow("data3") << "length: " << "cm" << 10 << "length: 10cm" << "10" << false;
+
+ QTest::newRow("data4") << QString() << QString() << 10 << "10" << "10" << true;
+ QTest::newRow("data5") << QString() << "cm" << 10 << "10cm" << "10" << true;
+ QTest::newRow("data6") << "cm: " << QString() << 10 << "cm: 10" << "10" << true;
+ QTest::newRow("data7") << "length: " << "cm" << 10 << "length: 10cm" << "10" << true;
+}
+
+void tst_QSpinBox::setPrefixSuffix()
+{
+ QFETCH(QString, prefix);
+ QFETCH(QString, suffix);
+ QFETCH(int, value);
+ QFETCH(QString, expectedText);
+ QFETCH(QString, expectedCleanText);
+ QFETCH(bool, show);
+
+ QSpinBox spin(0);
+ spin.setPrefix(prefix);
+ spin.setSuffix(suffix);
+ spin.setValue(value);
+ if (show)
+ spin.show();
+
+ QCOMPARE(spin.prefix(), prefix);
+ QCOMPARE(spin.suffix(), suffix);
+ QCOMPARE(spin.text(), expectedText);
+ QCOMPARE(spin.cleanText(), expectedCleanText);
+}
+
+void tst_QSpinBox::valueChangedHelper(const QString &text)
+{
+ actualTexts << text;
+}
+
+void tst_QSpinBox::valueChangedHelper(int value)
+{
+ actualValues << value;
+}
+
+void tst_QSpinBox::setReadOnly()
+{
+ QSpinBox spin(0);
+ spin.show();
+ QTest::keyClick(&spin, Qt::Key_Up);
+ QCOMPARE(spin.value(), 1);
+ spin.setReadOnly(true);
+ QTest::keyClick(&spin, Qt::Key_Up);
+ QCOMPARE(spin.value(), 1);
+ spin.stepBy(1);
+ QCOMPARE(spin.value(), 2);
+ spin.setReadOnly(false);
+ QTest::keyClick(&spin, Qt::Key_Up);
+ QCOMPARE(spin.value(), 3);
+}
+void tst_QSpinBox::setTracking_data()
+{
+ QTest::addColumn<QTestEventList>("keys");
+ QTest::addColumn<QStringList>("texts");
+ QTest::addColumn<bool>("tracking");
+
+ QTestEventList keys;
+ QStringList texts1;
+ QStringList texts2;
+
+#ifdef Q_WS_MAC
+ keys.addKeyClick(Qt::Key_Right, Qt::ControlModifier);
+#else
+ keys.addKeyClick(Qt::Key_End);
+#endif
+ keys.addKeyClick('7');
+ keys.addKeyClick('9');
+ keys.addKeyClick(Qt::Key_Enter);
+ keys.addKeyClick(Qt::Key_Enter);
+ keys.addKeyClick(Qt::Key_Enter);
+ texts1 << "07" << "079" << "79" << "79" << "79";
+ texts2 << "79";
+ QTest::newRow("data1") << keys << texts1 << true;
+ QTest::newRow("data2") << keys << texts2 << false;
+}
+
+void tst_QSpinBox::setTracking()
+{
+ actualTexts.clear();
+ QFETCH(QTestEventList, keys);
+ QFETCH(QStringList, texts);
+ QFETCH(bool, tracking);
+
+ QSpinBox spin(0);
+ spin.setKeyboardTracking(tracking);
+ spin.show();
+ connect(&spin, SIGNAL(valueChanged(QString)), this, SLOT(valueChangedHelper(const QString &)));
+
+ keys.simulate(&spin);
+ QCOMPARE(actualTexts, texts);
+}
+
+void tst_QSpinBox::setWrapping_data()
+{
+ QTest::addColumn<bool>("wrapping");
+ QTest::addColumn<int>("minimum");
+ QTest::addColumn<int>("maximum");
+ QTest::addColumn<int>("startValue");
+ QTest::addColumn<QTestEventList>("keys");
+ QTest::addColumn<IntList>("expected");
+
+ QTestEventList keys;
+ IntList values;
+ keys.addKeyClick(Qt::Key_Up);
+ values << 10;
+ keys.addKeyClick(Qt::Key_Up);
+ QTest::newRow("data0") << false << 0 << 10 << 9 << keys << values;
+
+ keys.clear();
+ values.clear();
+ keys.addKeyClick(Qt::Key_Up);
+ values << 10;
+ keys.addKeyClick(Qt::Key_Up);
+ values << 0;
+ QTest::newRow("data1") << true << 0 << 10 << 9 << keys << values;
+
+ keys.clear();
+ values.clear();
+ keys.addKeyClick(Qt::Key_Delete); // doesn't emit because lineedit is empty so intermediate
+ keys.addKeyClick('1');
+ keys.addKeyClick(Qt::Key_Down);
+ keys.addKeyClick(Qt::Key_Down);
+ values << 1 << 0;
+ QTest::newRow("data2") << false << 0 << 10 << 9 << keys << values;
+
+ keys.clear();
+ values.clear();
+ keys.addKeyClick(Qt::Key_Delete);
+ keys.addKeyClick('1');
+ keys.addKeyClick(Qt::Key_Down);
+ keys.addKeyClick(Qt::Key_Down);
+ values << 1 << 0 << 10;
+ QTest::newRow("data3") << true << 0 << 10 << 9 << keys << values;
+
+ keys.clear();
+ values.clear();
+ keys.addKeyClick(Qt::Key_PageDown);
+ keys.addKeyClick(Qt::Key_Down);
+ values << 0;
+ QTest::newRow("data4") << false << 0 << 10 << 6 << keys << values;
+
+ keys.clear();
+ values.clear();
+ keys.addKeyClick(Qt::Key_PageDown);
+ keys.addKeyClick(Qt::Key_Down);
+ values << 0 << 10;
+ QTest::newRow("data5") << true << 0 << 10 << 6 << keys << values;
+
+ keys.clear();
+ values.clear();
+ keys.addKeyClick(Qt::Key_PageUp);
+ keys.addKeyClick(Qt::Key_PageDown);
+ keys.addKeyClick(Qt::Key_Down);
+ keys.addKeyClick(Qt::Key_Up);
+ keys.addKeyClick(Qt::Key_PageDown);
+ keys.addKeyClick(Qt::Key_PageDown);
+ values << 10 << 0 << 10 << 0 << 10 << 0;
+ QTest::newRow("data6") << true << 0 << 10 << 6 << keys << values;
+
+}
+
+
+void tst_QSpinBox::setWrapping()
+{
+ QFETCH(bool, wrapping);
+ QFETCH(int, minimum);
+ QFETCH(int, maximum);
+ QFETCH(int, startValue);
+ QFETCH(QTestEventList, keys);
+ QFETCH(IntList, expected);
+
+ QSpinBox spin(0);
+ QVERIFY(!spin.wrapping());
+ spin.setMinimum(minimum);
+ spin.setMaximum(maximum);
+ spin.setValue(startValue);
+ spin.setWrapping(wrapping);
+ spin.show();
+ actualValues.clear();
+ connect(&spin, SIGNAL(valueChanged(int)), this, SLOT(valueChangedHelper(int)));
+
+ keys.simulate(&spin);
+
+ QCOMPARE(actualValues.size(), expected.size());
+ for (int i=0; i<qMin(actualValues.size(), expected.size()); ++i) {
+ QCOMPARE(actualValues.at(i), expected.at(i));
+ }
+}
+
+void tst_QSpinBox::setSpecialValueText_data()
+{
+ QTest::addColumn<QString>("specialValueText");
+ QTest::addColumn<int>("minimum");
+ QTest::addColumn<int>("maximum");
+ QTest::addColumn<int>("value");
+ QTest::addColumn<QString>("expected");
+ QTest::addColumn<bool>("show");
+
+ QTest::newRow("data0") << QString() << 0 << 10 << 1 << "1" << false;
+ QTest::newRow("data1") << QString() << 0 << 10 << 1 << "1" << true;
+ QTest::newRow("data2") << "foo" << 0 << 10 << 0 << "foo" << false;
+ QTest::newRow("data3") << "foo" << 0 << 10 << 0 << "foo" << true;
+}
+
+void tst_QSpinBox::setSpecialValueText()
+{
+ QFETCH(QString, specialValueText);
+ QFETCH(int, minimum);
+ QFETCH(int, maximum);
+ QFETCH(int, value);
+ QFETCH(QString, expected);
+ QFETCH(bool, show);
+
+ QSpinBox spin(0);
+ spin.setSpecialValueText(specialValueText);
+ QCOMPARE(spin.specialValueText(), specialValueText);
+ spin.setMinimum(minimum);
+ spin.setMaximum(maximum);
+ spin.setValue(value);
+ if (show)
+ spin.show();
+
+ QCOMPARE(spin.text(), expected);
+}
+
+void tst_QSpinBox::setSingleStep_data()
+{
+ QTest::addColumn<int>("singleStep");
+ QTest::addColumn<int>("startValue");
+ QTest::addColumn<QTestEventList>("keys");
+ QTest::addColumn<IntList>("expected");
+ QTest::addColumn<bool>("show");
+
+ QTestEventList keys;
+ IntList values;
+ keys.addKeyClick(Qt::Key_Up);
+ keys.addKeyClick(Qt::Key_Down);
+ keys.addKeyClick(Qt::Key_Up);
+ values << 11 << 10 << 11;
+ QTest::newRow("data0") << 1 << 10 << keys << values << false;
+ QTest::newRow("data1") << 1 << 10 << keys << values << true;
+
+ keys.clear();
+ values.clear();
+ keys.addKeyClick(Qt::Key_Up);
+ keys.addKeyClick(Qt::Key_Down);
+ keys.addKeyClick(Qt::Key_Up);
+ values << 12 << 10 << 12;
+ QTest::newRow("data2") << 2 << 10 << keys << values << false;
+ QTest::newRow("data3") << 2 << 10 << keys << values << true;
+}
+
+void tst_QSpinBox::setSingleStep()
+{
+ QFETCH(int, singleStep);
+ QFETCH(int, startValue);
+ QFETCH(QTestEventList, keys);
+ QFETCH(IntList, expected);
+ QFETCH(bool, show);
+
+ QSpinBox spin(0);
+ actualValues.clear();
+ spin.setSingleStep(singleStep);
+ QCOMPARE(spin.singleStep(), singleStep);
+ spin.setValue(startValue);
+ if (show)
+ spin.show();
+ connect(&spin, SIGNAL(valueChanged(int)), this, SLOT(valueChangedHelper(int)));
+
+ QCOMPARE(actualValues.size(), 0);
+ keys.simulate(&spin);
+ QCOMPARE(actualValues.size(), expected.size());
+ for (int i=0; i<qMin(actualValues.size(), expected.size()); ++i) {
+ QCOMPARE(actualValues.at(i), expected.at(i));
+ }
+}
+
+void tst_QSpinBox::setMinMax_data()
+{
+ QTest::addColumn<int>("startValue");
+ QTest::addColumn<int>("mini");
+ QTest::addColumn<int>("maxi");
+ QTest::addColumn<QTestEventList>("keys");
+ QTest::addColumn<int>("expected");
+ QTest::addColumn<bool>("show");
+
+ QTestEventList keys;
+ keys.addKeyClick(Qt::Key_Up);
+ keys.addKeyClick(Qt::Key_Up);
+ keys.addKeyClick(Qt::Key_Up);
+ keys.addKeyClick(Qt::Key_Up);
+ keys.addKeyClick(Qt::Key_Up);
+ QTest::newRow("data0") << 1 << INT_MIN << 2 << keys << 2 << false;
+ QTest::newRow("data1") << 1 << INT_MIN << 2 << keys << 2 << true;
+
+ keys.clear();
+ QTest::newRow("data2") << 2 << INT_MAX - 2 << INT_MAX << keys << INT_MAX - 2 << false;
+ QTest::newRow("data3") << 2 << INT_MAX - 2 << INT_MAX << keys << INT_MAX - 2 << true;
+}
+
+void tst_QSpinBox::setMinMax()
+{
+ QFETCH(int, startValue);
+ QFETCH(int, mini);
+ QFETCH(int, maxi);
+ QFETCH(QTestEventList, keys);
+ QFETCH(int, expected);
+ QFETCH(bool, show);
+
+ QSpinBox spin(0);
+ spin.setValue(startValue);
+ spin.setMinimum(mini);
+ spin.setMaximum(maxi);
+ QCOMPARE(spin.minimum(), mini);
+ QCOMPARE(spin.maximum(), maxi);
+ if (show)
+ spin.show();
+ keys.simulate(&spin);
+ QCOMPARE(spin.value(), expected);
+}
+
+void tst_QSpinBox::valueFromTextAndValidate_data()
+{
+ const int Intermediate = QValidator::Intermediate;
+ const int Invalid = QValidator::Invalid;
+ const int Acceptable = QValidator::Acceptable;
+
+ QTest::addColumn<QString>("txt");
+ QTest::addColumn<int>("state");
+ QTest::addColumn<int>("mini");
+ QTest::addColumn<int>("maxi");
+ QTest::addColumn<QString>("expectedText"); // if empty we don't check
+
+ QTest::newRow("data0") << QString("2") << Intermediate << 3 << 5 << QString();
+ QTest::newRow("data1") << QString() << Intermediate << 0 << 100 << QString();
+ QTest::newRow("data2") << QString("asd") << Invalid << 0 << 100 << QString();
+ QTest::newRow("data3") << QString("2") << Acceptable << 0 << 100 << QString();
+ QTest::newRow("data4") << QString() << Intermediate << 0 << 1 << QString();
+ QTest::newRow("data5") << QString() << Invalid << 0 << 0 << QString();
+ QTest::newRow("data5") << QString("5") << Intermediate << 2004 << 2005 << QString();
+ QTest::newRow("data6") << QString("50") << Intermediate << 2004 << 2005 << QString();
+ QTest::newRow("data7") << QString("205") << Intermediate << 2004 << 2005 << QString();
+ QTest::newRow("data8") << QString("2005") << Acceptable << 2004 << 2005 << QString();
+ QTest::newRow("data9") << QString("3") << Intermediate << 2004 << 2005 << QString();
+ QTest::newRow("data10") << QString("-") << Intermediate << -20 << -10 << QString();
+ QTest::newRow("data11") << QString("-1") << Intermediate << -20 << -10 << QString();
+ QTest::newRow("data12") << QString("-5") << Intermediate << -20 << -10 << QString();
+ QTest::newRow("data13") << QString("-5") << Intermediate << -20 << -16 << QString();
+ QTest::newRow("data14") << QString("-2") << Intermediate << -20 << -16 << QString();
+ QTest::newRow("data15") << QString("2") << Invalid << -20 << -16 << QString();
+ QTest::newRow("data16") << QString() << Intermediate << -20 << -16 << QString();
+ QTest::newRow("data17") << QString(" 22") << Acceptable << 0 << 1000 << QString("22");
+ QTest::newRow("data18") << QString("22 ") << Acceptable << 0 << 1000 << QString("22");
+ QTest::newRow("data19") << QString(" 22 ") << Acceptable << 0 << 1000 << QString("22");
+ QTest::newRow("data20") << QString("2 2") << Invalid << 0 << 1000 << QString();
+}
+
+static QString stateName(int state)
+{
+ switch (state) {
+ case QValidator::Acceptable: return QString("Acceptable");
+ case QValidator::Intermediate: return QString("Intermediate");
+ case QValidator::Invalid: return QString("Invalid");
+ default: break;
+ }
+ qWarning("%s %d: this should never happen", __FILE__, __LINE__);
+ return QString();
+}
+
+void tst_QSpinBox::valueFromTextAndValidate()
+{
+ QFETCH(QString, txt);
+ QFETCH(int, state);
+ QFETCH(int, mini);
+ QFETCH(int, maxi);
+ QFETCH(QString, expectedText);
+
+ SpinBox sb(0);
+ sb.show();
+ sb.setRange(mini, maxi);
+ int unused = 0;
+ QCOMPARE(stateName(sb.validate(txt, unused)), stateName(state));
+ if (!expectedText.isEmpty())
+ QCOMPARE(txt, expectedText);
+}
+
+void tst_QSpinBox::locale_data()
+{
+ QTest::addColumn<QLocale>("loc");
+ QTest::addColumn<int>("value");
+ QTest::addColumn<QString>("textFromVal");
+ QTest::addColumn<QString>("text");
+ QTest::addColumn<int>("valFromText");
+
+ QTest::newRow("data0") << QLocale(QLocale::Norwegian, QLocale::Norway) << 1234 << QString("1234") << QString("2345") << 2345;
+ QTest::newRow("data1") << QLocale(QLocale::German, QLocale::Germany) << 1234 << QString("1234") << QString("2345") << 2345;
+}
+
+void tst_QSpinBox::locale()
+{
+ QFETCH(QLocale, loc);
+ QFETCH(int, value);
+ QFETCH(QString, textFromVal);
+ QFETCH(QString, text);
+ QFETCH(int, valFromText);
+
+ QLocale old;
+
+ QLocale::setDefault(loc);
+ SpinBox box;
+ box.setMaximum(100000);
+ box.setValue(value);
+ QCOMPARE(box.cleanText(), textFromVal);
+
+ box.lineEdit()->setText(text);
+ QCOMPARE(box.cleanText(), text);
+ box.interpretText();
+
+ QCOMPARE(box.value(), valFromText);
+}
+
+
+void tst_QSpinBox::editingFinished()
+{
+ QVBoxLayout *layout = new QVBoxLayout(testFocusWidget);
+ QSpinBox *box = new QSpinBox(testFocusWidget);
+ layout->addWidget(box);
+ QSpinBox *box2 = new QSpinBox(testFocusWidget);
+ layout->addWidget(box2);
+
+ testFocusWidget->show();
+ QApplication::setActiveWindow(testFocusWidget);
+ QTest::qWaitForWindowShown(testFocusWidget);
+ box->activateWindow();
+ box->setFocus();
+
+ QTRY_COMPARE(qApp->focusWidget(), (QWidget *)box);
+
+ QSignalSpy editingFinishedSpy1(box, SIGNAL(editingFinished()));
+ QSignalSpy editingFinishedSpy2(box2, SIGNAL(editingFinished()));
+
+ box->setFocus();
+ QTest::keyClick(box, Qt::Key_Up);
+ QTest::keyClick(box, Qt::Key_Up);
+
+ QCOMPARE(editingFinishedSpy1.count(), 0);
+ QCOMPARE(editingFinishedSpy2.count(), 0);
+
+ QTest::keyClick(box2, Qt::Key_Up);
+ QTest::keyClick(box2, Qt::Key_Up);
+ box2->setFocus();
+ QCOMPARE(editingFinishedSpy1.count(), 1);
+ box->setFocus();
+ QCOMPARE(editingFinishedSpy1.count(), 1);
+ QCOMPARE(editingFinishedSpy2.count(), 1);
+ QTest::keyClick(box, Qt::Key_Up);
+ QCOMPARE(editingFinishedSpy1.count(), 1);
+ QCOMPARE(editingFinishedSpy2.count(), 1);
+ QTest::keyClick(box, Qt::Key_Enter);
+ QCOMPARE(editingFinishedSpy1.count(), 2);
+ QCOMPARE(editingFinishedSpy2.count(), 1);
+ QTest::keyClick(box, Qt::Key_Return);
+ QCOMPARE(editingFinishedSpy1.count(), 3);
+ QCOMPARE(editingFinishedSpy2.count(), 1);
+ box2->setFocus();
+ QCOMPARE(editingFinishedSpy1.count(), 4);
+ QCOMPARE(editingFinishedSpy2.count(), 1);
+ QTest::keyClick(box2, Qt::Key_Enter);
+ QCOMPARE(editingFinishedSpy1.count(), 4);
+ QCOMPARE(editingFinishedSpy2.count(), 2);
+ QTest::keyClick(box2, Qt::Key_Return);
+ QCOMPARE(editingFinishedSpy1.count(), 4);
+ QCOMPARE(editingFinishedSpy2.count(), 3);
+
+ testFocusWidget->hide();
+ QCOMPARE(editingFinishedSpy1.count(), 4);
+ QCOMPARE(editingFinishedSpy2.count(), 4);
+ QTest::qWait(100);
+
+ //task203285
+ editingFinishedSpy1.clear();
+ testFocusWidget->show();
+ QTest::qWait(100);
+ box->setKeyboardTracking(false);
+ qApp->setActiveWindow(testFocusWidget);
+ testFocusWidget->activateWindow();
+ box->setFocus();
+ QTRY_VERIFY(box->hasFocus());
+ box->setValue(0);
+ QTest::keyClick(box, '2');
+ QCOMPARE(box->text(), QLatin1String("20"));
+ box2->setFocus();
+ QTRY_VERIFY(qApp->focusWidget() != box);
+ QCOMPARE(box->text(), QLatin1String("20"));
+ QCOMPARE(editingFinishedSpy1.count(), 1);
+
+ testFocusWidget->hide();
+}
+
+void tst_QSpinBox::removeAll()
+{
+ SpinBox spin(0);
+ spin.setPrefix("foo");
+ spin.setSuffix("bar");
+ spin.setValue(2);
+ spin.show();
+#ifdef Q_WS_MAC
+ QTest::keyClick(&spin, Qt::Key_Left, Qt::ControlModifier);
+#else
+ QTest::keyClick(&spin, Qt::Key_Home);
+#endif
+
+#ifdef Q_WS_MAC
+ QTest::keyClick(&spin, Qt::Key_Right, Qt::ControlModifier|Qt::ShiftModifier);
+#else
+ QTest::keyClick(&spin, Qt::Key_End, Qt::ShiftModifier);
+#endif
+
+ QCOMPARE(spin.lineEdit()->selectedText(), QString("foo2bar"));
+ QTest::keyClick(&spin, Qt::Key_1);
+ QCOMPARE(spin.text(), QString("foo1bar"));
+}
+
+void tst_QSpinBox::startWithDash()
+{
+ SpinBox spin(0);
+ spin.show();
+#ifdef Q_WS_MAC
+ QTest::keyClick(&spin, Qt::Key_Left, Qt::ControlModifier);
+#else
+ QTest::keyClick(&spin, Qt::Key_Home);
+#endif
+ QCOMPARE(spin.text(), QString("0"));
+ QTest::keyClick(&spin, Qt::Key_Minus);
+ QCOMPARE(spin.text(), QString("0"));
+}
+
+void tst_QSpinBox::undoRedo()
+{
+ //test undo/redo feature (in conjunction with the "undoRedoEnabled" property)
+ SpinBox spin(0);
+ spin.show();
+
+ //the undo/redo is disabled by default
+
+ QCOMPARE(spin.value(), 0); //this is the default value
+ QVERIFY(!spin.lineEdit()->isUndoAvailable());
+ QVERIFY(!spin.lineEdit()->isRedoAvailable());
+
+ spin.lineEdit()->selectAll(); //ensures everything is selected and will be cleared by typing a key
+ QTest::keyClick(&spin, Qt::Key_1); //we put 1 into the spinbox
+ QCOMPARE(spin.value(), 1);
+ QVERIFY(spin.lineEdit()->isUndoAvailable());
+
+ //testing CTRL+Z (undo)
+ int val = QKeySequence(QKeySequence::Undo)[0];
+ Qt::KeyboardModifiers mods = (Qt::KeyboardModifiers)(val & Qt::KeyboardModifierMask);
+ QTest::keyClick(&spin, val & ~mods, mods);
+
+ QCOMPARE(spin.value(), 0);
+ QVERIFY(!spin.lineEdit()->isUndoAvailable());
+ QVERIFY(spin.lineEdit()->isRedoAvailable());
+
+ //testing CTRL+Y (redo)
+ val = QKeySequence(QKeySequence::Redo)[0];
+ mods = (Qt::KeyboardModifiers)(val & Qt::KeyboardModifierMask);
+ QTest::keyClick(&spin, val & ~mods, mods);
+ QCOMPARE(spin.value(), 1);
+ QVERIFY(!spin.lineEdit()->isRedoAvailable());
+ QVERIFY(spin.lineEdit()->isUndoAvailable());
+
+ spin.setValue(55);
+ QVERIFY(!spin.lineEdit()->isUndoAvailable());
+ QVERIFY(!spin.lineEdit()->isRedoAvailable());
+
+ QTest::keyClick(&spin, Qt::Key_Return);
+ QTest::keyClick(&spin, '1');
+ QVERIFY(spin.lineEdit()->isUndoAvailable());
+ QVERIFY(!spin.lineEdit()->isRedoAvailable());
+ spin.lineEdit()->undo();
+ QCOMPARE(spin.value(), 55);
+ QVERIFY(!spin.lineEdit()->isUndoAvailable());
+ QVERIFY(spin.lineEdit()->isRedoAvailable());
+ spin.lineEdit()->redo();
+ QCOMPARE(spin.value(), 1);
+ QVERIFY(spin.lineEdit()->isUndoAvailable());
+ QVERIFY(!spin.lineEdit()->isRedoAvailable());
+}
+
+void tst_QSpinBox::specialValue()
+{
+ QString specialText="foo";
+
+ QWidget topWidget;
+ QVBoxLayout layout(&topWidget);
+ SpinBox spin(&topWidget);
+ layout.addWidget(&spin);
+ SpinBox box2(&topWidget);
+ layout.addWidget(&box2);
+
+ spin.setSpecialValueText(specialText);
+ spin.setMinimum(0);
+ spin.setMaximum(100);
+ spin.setValue(50);
+ topWidget.show();
+#ifdef Q_WS_X11
+ qt_x11_wait_for_window_manager(&topWidget);
+#endif
+ QTest::qWait(100);
+ //make sure we have the focus (even if editingFinished fails)
+ qApp->setActiveWindow(&topWidget);
+ topWidget.activateWindow();
+ spin.setFocus();
+
+ QTest::keyClick(&spin, Qt::Key_Return);
+ QTest::keyClick(&spin, '0');
+ QCOMPARE(spin.text(), QString("0"));
+ QTest::keyClick(&spin, Qt::Key_Return);
+ QCOMPARE(spin.text(), specialText);
+
+ spin.setValue(50);
+ QTest::keyClick(&spin, Qt::Key_Return);
+ QTest::keyClick(&spin, '0');
+ QCOMPARE(spin.text(), QString("0"));
+ QTest::keyClick(spin.lineEdit(), Qt::Key_Tab);
+ QCOMPARE(spin.text(), specialText);
+
+ spin.setValue(50);
+ spin.setFocus();
+ QTest::keyClick(&spin, Qt::Key_Return);
+ QTest::keyClick(&spin, '0');
+ QCOMPARE(spin.text(), QString("0"));
+ box2.setFocus();
+ QCOMPARE(spin.text(), specialText);
+}
+
+void tst_QSpinBox::textFromValue()
+{
+ SpinBox spinBox;
+ QCOMPARE(spinBox.textFromValue(INT_MIN), QString::number(INT_MIN));
+}
+
+class sizeHint_SpinBox : public QSpinBox
+{
+public:
+ QSize sizeHint() const
+ {
+ ++sizeHintRequests;
+ return QSpinBox::sizeHint();
+ }
+ mutable int sizeHintRequests;
+};
+
+void tst_QSpinBox::sizeHint()
+{
+ QWidget *widget = new QWidget;
+ QHBoxLayout *layout = new QHBoxLayout(widget);
+ sizeHint_SpinBox *spinBox = new sizeHint_SpinBox;
+ layout->addWidget(spinBox);
+ widget->show();
+ QTest::qWaitForWindowShown(widget);
+
+ // Prefix
+ spinBox->sizeHintRequests = 0;
+ spinBox->setPrefix(QLatin1String("abcdefghij"));
+ qApp->processEvents();
+ QTRY_VERIFY(spinBox->sizeHintRequests > 0);
+
+ // Suffix
+ spinBox->sizeHintRequests = 0;
+ spinBox->setSuffix(QLatin1String("abcdefghij"));
+ qApp->processEvents();
+ QTRY_VERIFY(spinBox->sizeHintRequests > 0);
+
+ // Range
+ spinBox->sizeHintRequests = 0;
+ spinBox->setRange(0, 1234567890);
+ spinBox->setValue(spinBox->maximum());
+ qApp->processEvents();
+ QTRY_VERIFY(spinBox->sizeHintRequests > 0);
+
+ delete widget;
+}
+
+void tst_QSpinBox::taskQTBUG_5008_textFromValueAndValidate()
+{
+ class DecoratedSpinBox : public QSpinBox
+ {
+ public:
+ DecoratedSpinBox()
+ {
+ setLocale(QLocale::French);
+ setMaximum(100000000);
+ setValue(1000000);
+ }
+
+ QLineEdit *lineEdit() const
+ {
+ return QSpinBox::lineEdit();
+ }
+
+ //we use the French delimiters here
+ QString textFromValue (int value) const
+ {
+ return locale().toString(value);
+ }
+
+ } spinbox;
+ spinbox.show();
+ spinbox.activateWindow();
+ spinbox.setFocus();
+ QApplication::setActiveWindow(&spinbox);
+ QTest::qWaitForWindowShown(&spinbox);
+ QTRY_VERIFY(spinbox.hasFocus());
+ QTRY_COMPARE(static_cast<QWidget *>(&spinbox), QApplication::activeWindow());
+ QCOMPARE(spinbox.text(), spinbox.locale().toString(spinbox.value()));
+ spinbox.lineEdit()->setCursorPosition(2); //just after the first thousand separator
+ QTest::keyClick(static_cast<QWidget *>(0), Qt::Key_0); // let's insert a 0
+ QCOMPARE(spinbox.value(), 10000000); //it's been multiplied by 10
+ spinbox.clearFocus(); //make sure the value is correctly formatted
+ QCOMPARE(spinbox.text(), spinbox.locale().toString(spinbox.value()));
+}
+
+
+QTEST_MAIN(tst_QSpinBox)
+#include "tst_qspinbox.moc"
diff --git a/tests/auto/widgets/widgets/qsplitter/.gitignore b/tests/auto/widgets/widgets/qsplitter/.gitignore
new file mode 100644
index 0000000000..311db65ff0
--- /dev/null
+++ b/tests/auto/widgets/widgets/qsplitter/.gitignore
@@ -0,0 +1 @@
+tst_qsplitter
diff --git a/tests/auto/widgets/widgets/qsplitter/extradata.txt b/tests/auto/widgets/widgets/qsplitter/extradata.txt
new file mode 100644
index 0000000000..ceb46d4a82
--- /dev/null
+++ b/tests/auto/widgets/widgets/qsplitter/extradata.txt
@@ -0,0 +1,10067 @@
+// This is a bunch of extra data that really needs to be converted over. However, the execpted values (line 3 in the data) have not been computed.
+#if 0
+
+ *t.newData("ok000000000573") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 0 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << true;
+
+ *t.newData("ok000000000574") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 0 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << true;
+
+ *t.newData("ok000000000575") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 0 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << true;
+
+ *t.newData("ok000000000576") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 0 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << true;
+
+ *t.newData("ok000000000577") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 0 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << true;
+
+
+ *t.newData("ok000000000600") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 50 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << true;
+
+ *t.newData("ok000000000601") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 50 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << true;
+
+ *t.newData("ok000000000602") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 50 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << true;
+
+ *t.newData("ok000000000603") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 50 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << true;
+
+ *t.newData("ok000000000604") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 50 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << true;
+
+
+ *t.newData("ok000000000605") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 100 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << true;
+
+ *t.newData("ok000000000606") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 100 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << true;
+
+ *t.newData("ok000000000607") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 100 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << true;
+
+ *t.newData("ok000000000610") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 100 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << true;
+
+ *t.newData("ok000000000611") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 100 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << true;
+
+
+ *t.newData("ok000000000612") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 200 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << true;
+
+ *t.newData("ok000000000613") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 200 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << true;
+
+ *t.newData("ok000000000614") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 200 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << true;
+
+ *t.newData("ok000000000615") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 200 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << true;
+
+ *t.newData("ok000000000616") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 200 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << true;
+
+
+ *t.newData("ok000000000617") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 500 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << true;
+
+ *t.newData("ok000000000620") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 500 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << true;
+
+ *t.newData("ok000000000621") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 500 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << true;
+
+ *t.newData("ok000000000622") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 500 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << true;
+
+ *t.newData("ok000000000623") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 500 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << true;
+
+
+ *t.newData("ok000000000624") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 0 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << true;
+
+ *t.newData("ok000000000625") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 0 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << true;
+
+ *t.newData("ok000000000626") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 0 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << true;
+
+ *t.newData("ok000000000627") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 0 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << true;
+
+ *t.newData("ok000000000630") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 0 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << true;
+
+
+ *t.newData("ok000000000631") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 50 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << true;
+
+ *t.newData("ok000000000632") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 50 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << true;
+
+ *t.newData("ok000000000633") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 50 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << true;
+
+ *t.newData("ok000000000634") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 50 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << true;
+
+ *t.newData("ok000000000635") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 50 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << true;
+
+
+ *t.newData("ok000000000636") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 100 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << true;
+
+ *t.newData("ok000000000637") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 100 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << true;
+
+ *t.newData("ok000000000640") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 100 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << true;
+
+ *t.newData("ok000000000641") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 100 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << true;
+
+ *t.newData("ok000000000642") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 100 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << true;
+
+
+ *t.newData("ok000000000643") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 200 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << true;
+
+ *t.newData("ok000000000644") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 200 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << true;
+
+ *t.newData("ok000000000645") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 200 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << true;
+
+ *t.newData("ok000000000646") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 200 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << true;
+
+ *t.newData("ok000000000647") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 200 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << true;
+
+
+ *t.newData("ok000000000650") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 500 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << true;
+
+ *t.newData("ok000000000651") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 500 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << true;
+
+ *t.newData("ok000000000652") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 500 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << true;
+
+ *t.newData("ok000000000653") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 500 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << true;
+
+ *t.newData("ok000000000654") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 500 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << true;
+
+
+ *t.newData("ok000000000655") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 0 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << true;
+
+ *t.newData("ok000000000656") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 0 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << true;
+
+ *t.newData("ok000000000657") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 0 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << true;
+
+ *t.newData("ok000000000660") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 0 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << true;
+
+ *t.newData("ok000000000661") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 0 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << true;
+
+
+ *t.newData("ok000000000662") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 50 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << true;
+
+ *t.newData("ok000000000663") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 50 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << true;
+
+ *t.newData("ok000000000664") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 50 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << true;
+
+ *t.newData("ok000000000665") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 50 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << true;
+
+ *t.newData("ok000000000666") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 50 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << true;
+
+
+ *t.newData("ok000000000667") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 100 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << true;
+
+ *t.newData("ok000000000670") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 100 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << true;
+
+ *t.newData("ok000000000671") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << true;
+
+ *t.newData("ok000000000672") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 100 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << true;
+
+ *t.newData("ok000000000673") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 100 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << true;
+
+
+ *t.newData("ok000000000674") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 200 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << true;
+
+ *t.newData("ok000000000675") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 200 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << true;
+
+ *t.newData("ok000000000676") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 200 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << true;
+
+ *t.newData("ok000000000677") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 200 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << true;
+
+ *t.newData("ok000000000700") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 200 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << true;
+
+
+ *t.newData("ok000000000701") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 500 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << true;
+
+ *t.newData("ok000000000702") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 500 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << true;
+
+ *t.newData("ok000000000703") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 500 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << true;
+
+ *t.newData("ok000000000704") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 500 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << true;
+
+ *t.newData("ok000000000705") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 500 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << true;
+
+
+ *t.newData("ok000000000706") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 0 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << true;
+
+ *t.newData("ok000000000707") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 0 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << true;
+
+ *t.newData("ok000000000710") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 0 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << true;
+
+ *t.newData("ok000000000711") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 0 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << true;
+
+ *t.newData("ok000000000712") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 0 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << true;
+
+
+ *t.newData("ok000000000713") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 50 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << true;
+
+ *t.newData("ok000000000714") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 50 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << true;
+
+ *t.newData("ok000000000715") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 50 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << true;
+
+ *t.newData("ok000000000716") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 50 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << true;
+
+ *t.newData("ok000000000717") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 50 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << true;
+
+
+ *t.newData("ok000000000720") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 100 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << true;
+
+ *t.newData("ok000000000721") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 100 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << true;
+
+ *t.newData("ok000000000722") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 100 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << true;
+
+ *t.newData("ok000000000723") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 100 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << true;
+
+ *t.newData("ok000000000724") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 100 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << true;
+
+
+ *t.newData("ok000000000725") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 200 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << true;
+
+ *t.newData("ok000000000726") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 200 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << true;
+
+ *t.newData("ok000000000727") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 200 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << true;
+
+ *t.newData("ok000000000730") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 200 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << true;
+
+ *t.newData("ok000000000731") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 200 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << true;
+
+
+ *t.newData("ok000000000732") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 500 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << true;
+
+ *t.newData("ok000000000733") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 500 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << true;
+
+ *t.newData("ok000000000734") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 500 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << true;
+
+ *t.newData("ok000000000735") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 500 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << true;
+
+ *t.newData("ok000000000736") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 500 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << true;
+
+
+ *t.newData("ok000000000737") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 0 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << true;
+
+ *t.newData("ok000000000740") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 0 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << true;
+
+ *t.newData("ok000000000741") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 0 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << true;
+
+ *t.newData("ok000000000742") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 0 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << true;
+
+ *t.newData("ok000000000743") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 0 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << true;
+
+
+ *t.newData("ok000000000744") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 50 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << true;
+
+ *t.newData("ok000000000745") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 50 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << true;
+
+ *t.newData("ok000000000746") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 50 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << true;
+
+ *t.newData("ok000000000747") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 50 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << true;
+
+ *t.newData("ok000000000750") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 50 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << true;
+
+
+ *t.newData("ok000000000751") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 100 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << true;
+
+ *t.newData("ok000000000752") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 100 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << true;
+
+ *t.newData("ok000000000753") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 100 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << true;
+
+ *t.newData("ok000000000754") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 100 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << true;
+
+ *t.newData("ok000000000755") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 100 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << true;
+
+
+ *t.newData("ok000000000757") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 200 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << true;
+
+ *t.newData("ok000000000760") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 200 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << true;
+
+ *t.newData("ok000000000761") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 200 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << true;
+
+ *t.newData("ok000000000762") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 200 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << true;
+
+ *t.newData("ok000000000763") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 200 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << true;
+
+
+ *t.newData("ok000000000764") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 500 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << true;
+
+ *t.newData("ok000000000765") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 500 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << true;
+
+ *t.newData("ok000000000766") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 500 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << true;
+
+ *t.newData("ok000000000767") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 500 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << true;
+
+ *t.newData("ok000000000770") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 500 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << true;
+
+ *t.newData("ok000000000771") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 0 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << true;
+
+ *t.newData("ok000000000772") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 0 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << true;
+
+ *t.newData("ok000000000773") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 0 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << true;
+
+ *t.newData("ok000000000774") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 0 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << true;
+
+ *t.newData("ok000000000775") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 0 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << true;
+
+
+ *t.newData("ok000000000776") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 50 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << true;
+
+ *t.newData("ok000000000777") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 50 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << true;
+
+ *t.newData("ok000000001000") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 50 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << true;
+
+ *t.newData("ok000000001001") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 50 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << true;
+
+ *t.newData("ok000000001002") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 50 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << true;
+
+
+ *t.newData("ok000000000013") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 504 << 100 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << true;
+
+ *t.newData("ok000000001004") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 100 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << true;
+
+ *t.newData("ok000000001005") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 100 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << true;
+
+ *t.newData("ok000000001006") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 100 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << true;
+
+ *t.newData("ok000000001007") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 100 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << true;
+
+
+ *t.newData("ok000000000020") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 504 << 200 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << true;
+
+ *t.newData("ok000000001011") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 200 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << true;
+
+ *t.newData("ok000000001012") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 200 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << true;
+
+ *t.newData("ok000000001013") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 200 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << true;
+
+ *t.newData("ok000000001014") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 200 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << true;
+
+
+ *t.newData("ok000000000025") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 504 << 500 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << true;
+
+ *t.newData("ok000000001016") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 500 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << true;
+
+ *t.newData("ok000000001017") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 500 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << true;
+
+ *t.newData("ok000000001020") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 500 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << true;
+
+ *t.newData("ok000000001021") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 500 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << true;
+
+
+ *t.newData("ok000000000032") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 554 << 0 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << true;
+
+ *t.newData("ok000000001023") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 0 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << true;
+
+ *t.newData("ok000000001024") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 0 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << true;
+
+ *t.newData("ok000000001025") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 0 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << true;
+
+ *t.newData("ok000000001026") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 0 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << true;
+
+
+ *t.newData("ok000000000037") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 554 << 50 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << true;
+
+ *t.newData("ok000000001030") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 50 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << true;
+
+ *t.newData("ok000000001031") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 50 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << true;
+
+ *t.newData("ok000000001032") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 50 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << true;
+
+ *t.newData("ok000000001033") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 50 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << true;
+
+
+ *t.newData("ok000000000044") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 554 << 100 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << true;
+
+ *t.newData("ok000000001035") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 100 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << true;
+
+ *t.newData("ok000000001036") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 100 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << true;
+
+ *t.newData("ok000000001037") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 100 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << true;
+
+ *t.newData("ok000000001040") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 100 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << true;
+
+
+ *t.newData("ok000000000051") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 554 << 200 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << true;
+
+ *t.newData("ok000000001042") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 200 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << true;
+
+ *t.newData("ok000000001043") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 200 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << true;
+
+ *t.newData("ok000000001044") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 200 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << true;
+
+ *t.newData("ok000000001045") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 200 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << true;
+
+
+ *t.newData("ok000000000056") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 554 << 500 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << true;
+
+ *t.newData("ok000000001047") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 500 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << true;
+
+ *t.newData("ok000000001050") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 500 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << true;
+
+ *t.newData("ok000000001051") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 500 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << true;
+
+ *t.newData("ok000000001052") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 500 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << true;
+
+
+ *t.newData("ok000000000063") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 604 << 0 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << true;
+
+ *t.newData("ok000000001054") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 0 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << true;
+
+ *t.newData("ok000000001055") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 0 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << true;
+
+ *t.newData("ok000000001056") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 0 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << true;
+
+ *t.newData("ok000000001057") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 0 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << true;
+
+
+ *t.newData("ok000000000070") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 604 << 50 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << true;
+
+ *t.newData("ok000000001061") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 50 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << true;
+
+ *t.newData("ok000000001062") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 50 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << true;
+
+ *t.newData("ok000000001063") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 50 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << true;
+
+ *t.newData("ok000000001064") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 50 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << true;
+
+
+ *t.newData("ok000000000075") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 604 << 100 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << true;
+
+ *t.newData("ok000000001066") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 100 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << true;
+
+ *t.newData("ok000000001067") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << true;
+
+ *t.newData("ok000000001070") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 100 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << true;
+
+ *t.newData("ok000000001071") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 100 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << true;
+
+
+ *t.newData("ok000000000102") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 604 << 200 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << true;
+
+ *t.newData("ok000000001073") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 200 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << true;
+
+ *t.newData("ok000000001074") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 200 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << true;
+
+ *t.newData("ok000000001075") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 200 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << true;
+
+ *t.newData("ok000000001076") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 200 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << true;
+
+
+ *t.newData("ok000000000107") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 604 << 500 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << true;
+
+ *t.newData("ok000000001100") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 500 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << true;
+
+ *t.newData("ok000000001101") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 500 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << true;
+
+ *t.newData("ok000000001102") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 500 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << true;
+
+ *t.newData("ok000000001103") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 500 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << true;
+
+
+ *t.newData("ok000000000114") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 704 << 0 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << true;
+
+ *t.newData("ok000000001105") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 0 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << true;
+
+ *t.newData("ok000000001106") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 0 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << true;
+
+ *t.newData("ok000000001107") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 0 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << true;
+
+ *t.newData("ok000000001110") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 0 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << true;
+
+
+ *t.newData("ok000000000121") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 704 << 50 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << true;
+
+ *t.newData("ok000000001112") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 50 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << true;
+
+ *t.newData("ok000000001113") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 50 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << true;
+
+ *t.newData("ok000000001114") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 50 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << true;
+
+ *t.newData("ok000000001115") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 50 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << true;
+
+
+ *t.newData("ok000000000126") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 704 << 100 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << true;
+
+ *t.newData("ok000000001117") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 100 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << true;
+
+ *t.newData("ok000000001120") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 100 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << true;
+
+ *t.newData("ok000000001121") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 100 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << true;
+
+ *t.newData("ok000000001122") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 100 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << true;
+
+
+ *t.newData("ok000000000133") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 704 << 200 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << true;
+
+ *t.newData("ok000000001124") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 200 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << true;
+
+ *t.newData("ok000000001125") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 200 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << true;
+
+ *t.newData("ok000000001126") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 200 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << true;
+
+ *t.newData("ok000000001127") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 200 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << true;
+
+
+ *t.newData("ok000000000140") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 704 << 500 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << true;
+
+ *t.newData("ok000000001131") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 500 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << true;
+
+ *t.newData("ok000000001132") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 500 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << true;
+
+ *t.newData("ok000000001133") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 500 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << true;
+
+ *t.newData("ok000000001134") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 500 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << true;
+
+
+ *t.newData("ok000000000145") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 1004 << 0 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << true;
+
+ *t.newData("ok000000001136") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 0 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << true;
+
+ *t.newData("ok000000001137") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 0 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << true;
+
+ *t.newData("ok000000001140") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 0 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << true;
+
+ *t.newData("ok000000001141") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 0 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << true;
+
+
+ *t.newData("ok000000000152") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 1004 << 50 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << true;
+
+ *t.newData("ok000000001143") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 50 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << true;
+
+ *t.newData("ok000000001144") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 50 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << true;
+
+ *t.newData("ok000000001145") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 50 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << true;
+
+ *t.newData("ok000000001146") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 50 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << true;
+
+
+ *t.newData("ok000000000157") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 1004 << 100 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << true;
+
+ *t.newData("ok000000001150") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 100 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << true;
+
+ *t.newData("ok000000001151") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 100 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << true;
+
+ *t.newData("ok000000001152") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 100 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << true;
+
+ *t.newData("ok000000001153") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 100 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << true;
+
+
+ *t.newData("ok000000000165") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 1004 << 200 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << true;
+
+ *t.newData("ok000000001156") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 200 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << true;
+
+ *t.newData("ok000000001157") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 200 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << true;
+
+ *t.newData("ok000000001160") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 200 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << true;
+
+ *t.newData("ok000000001161") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 200 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << true;
+
+
+ *t.newData("ok000000000172") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 1004 << 500 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << true;
+
+ *t.newData("ok000000001163") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 500 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << true;
+
+ *t.newData("ok000000001164") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 500 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << true;
+
+ *t.newData("ok000000001165") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 500 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << true;
+
+ *t.newData("ok000000001166") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 500 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << true;
+
+ *t.newData("ok000000001167") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 0 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << true;
+
+ *t.newData("ok000000001170") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 0 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << true;
+
+ *t.newData("ok000000001171") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 0 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << true;
+
+ *t.newData("ok000000001172") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 0 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << true;
+
+ *t.newData("ok000000001173") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 0 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << true;
+
+
+ *t.newData("ok000000001174") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 50 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << true;
+
+ *t.newData("ok000000001175") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 50 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << true;
+
+ *t.newData("ok000000001176") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 50 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << true;
+
+ *t.newData("ok000000001177") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 50 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << true;
+
+ *t.newData("ok000000001200") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 50 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << true;
+
+
+ *t.newData("ok000000000013") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 630 << 100 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << true;
+
+ *t.newData("ok000000001202") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 100 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << true;
+
+ *t.newData("ok000000001203") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 100 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << true;
+
+ *t.newData("ok000000001204") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 100 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << true;
+
+ *t.newData("ok000000001205") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 100 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << true;
+
+
+ *t.newData("ok000000000020") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 630 << 200 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << true;
+
+ *t.newData("ok000000001207") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 200 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << true;
+
+ *t.newData("ok000000001210") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 200 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << true;
+
+ *t.newData("ok000000001211") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 200 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << true;
+
+ *t.newData("ok000000001212") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 200 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << true;
+
+
+ *t.newData("ok000000000025") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 630 << 500 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << true;
+
+ *t.newData("ok000000001214") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 500 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << true;
+
+ *t.newData("ok000000001215") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 500 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << true;
+
+ *t.newData("ok000000001216") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 500 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << true;
+
+ *t.newData("ok000000001217") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 500 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << true;
+
+
+ *t.newData("ok000000000032") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 680 << 0 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << true;
+
+ *t.newData("ok000000001221") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 0 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << true;
+
+ *t.newData("ok000000001222") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 0 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << true;
+
+ *t.newData("ok000000001223") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 0 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << true;
+
+ *t.newData("ok000000001224") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 0 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << true;
+
+
+ *t.newData("ok000000000037") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 680 << 50 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << true;
+
+ *t.newData("ok000000001226") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 50 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << true;
+
+ *t.newData("ok000000001227") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 50 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << true;
+
+ *t.newData("ok000000001230") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 50 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << true;
+
+ *t.newData("ok000000001231") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 50 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << true;
+
+
+ *t.newData("ok000000000044") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 680 << 100 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << true;
+
+ *t.newData("ok000000001233") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 100 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << true;
+
+ *t.newData("ok000000001234") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 100 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << true;
+
+ *t.newData("ok000000001235") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 100 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << true;
+
+ *t.newData("ok000000001236") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 100 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << true;
+
+
+ *t.newData("ok000000000051") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 680 << 200 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << true;
+
+ *t.newData("ok000000001240") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 200 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << true;
+
+ *t.newData("ok000000001241") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 200 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << true;
+
+ *t.newData("ok000000001242") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 200 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << true;
+
+ *t.newData("ok000000001243") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 200 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << true;
+
+
+ *t.newData("ok000000000056") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 680 << 500 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << true;
+
+ *t.newData("ok000000001245") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 500 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << true;
+
+ *t.newData("ok000000001246") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 500 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << true;
+
+ *t.newData("ok000000001247") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 500 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << true;
+
+ *t.newData("ok000000001250") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 500 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << true;
+
+
+ *t.newData("ok000000000063") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 730 << 0 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << true;
+
+ *t.newData("ok000000001252") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 0 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << true;
+
+ *t.newData("ok000000001253") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 0 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << true;
+
+ *t.newData("ok000000001254") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 0 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << true;
+
+ *t.newData("ok000000001255") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 0 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << true;
+
+
+ *t.newData("ok000000000070") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 730 << 50 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << true;
+
+ *t.newData("ok000000001257") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 50 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << true;
+
+ *t.newData("ok000000001260") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 50 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << true;
+
+ *t.newData("ok000000001261") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 50 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << true;
+
+ *t.newData("ok000000001262") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 50 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << true;
+
+
+ *t.newData("ok000000000075") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 730 << 100 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << true;
+
+ *t.newData("ok000000001264") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 100 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << true;
+
+ *t.newData("ok000000001265") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << true;
+
+ *t.newData("ok000000001266") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 100 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << true;
+
+ *t.newData("ok000000001267") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 100 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << true;
+
+
+ *t.newData("ok000000000102") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 730 << 200 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << true;
+
+ *t.newData("ok000000001271") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 200 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << true;
+
+ *t.newData("ok000000001272") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 200 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << true;
+
+ *t.newData("ok000000001273") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 200 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << true;
+
+ *t.newData("ok000000001274") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 200 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << true;
+
+
+ *t.newData("ok000000000107") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 730 << 500 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << true;
+
+ *t.newData("ok000000001276") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 500 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << true;
+
+ *t.newData("ok000000001277") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 500 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << true;
+
+ *t.newData("ok000000001300") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 500 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << true;
+
+ *t.newData("ok000000001301") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 500 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << true;
+
+
+ *t.newData("ok000000000114") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 830 << 0 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << true;
+
+ *t.newData("ok000000001303") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 0 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << true;
+
+ *t.newData("ok000000001304") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 0 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << true;
+
+ *t.newData("ok000000001305") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 0 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << true;
+
+ *t.newData("ok000000001306") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 0 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << true;
+
+
+ *t.newData("ok000000000121") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 830 << 50 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << true;
+
+ *t.newData("ok000000001310") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 50 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << true;
+
+ *t.newData("ok000000001311") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 50 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << true;
+
+ *t.newData("ok000000001312") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 50 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << true;
+
+ *t.newData("ok000000001313") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 50 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << true;
+
+
+ *t.newData("ok000000000126") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 830 << 100 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << true;
+
+ *t.newData("ok000000001315") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 100 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << true;
+
+ *t.newData("ok000000001316") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 100 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << true;
+
+ *t.newData("ok000000001317") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 100 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << true;
+
+ *t.newData("ok000000001320") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 100 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << true;
+
+
+ *t.newData("ok000000000133") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 830 << 200 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << true;
+
+ *t.newData("ok000000001322") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 200 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << true;
+
+ *t.newData("ok000000001323") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 200 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << true;
+
+ *t.newData("ok000000001324") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 200 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << true;
+
+ *t.newData("ok000000001325") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 200 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << true;
+
+
+ *t.newData("ok000000000140") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 830 << 500 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << true;
+
+ *t.newData("ok000000001327") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 500 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << true;
+
+ *t.newData("ok000000001330") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 500 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << true;
+
+ *t.newData("ok000000001331") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 500 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << true;
+
+ *t.newData("ok000000001332") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 500 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << true;
+
+
+ *t.newData("ok000000000145") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 1130 << 0 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << true;
+
+ *t.newData("ok000000001334") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 0 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << true;
+
+ *t.newData("ok000000001335") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 0 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << true;
+
+ *t.newData("ok000000001336") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 0 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << true;
+
+ *t.newData("ok000000001337") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 0 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << true;
+
+
+ *t.newData("ok000000000152") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 1130 << 50 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << true;
+
+ *t.newData("ok000000001341") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 50 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << true;
+
+ *t.newData("ok000000001342") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 50 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << true;
+
+ *t.newData("ok000000001343") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 50 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << true;
+
+ *t.newData("ok000000001344") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 50 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << true;
+
+
+ *t.newData("ok000000000157") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 1130 << 100 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << true;
+
+ *t.newData("ok000000001346") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 100 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << true;
+
+ *t.newData("ok000000001347") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 100 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << true;
+
+ *t.newData("ok000000001350") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 100 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << true;
+
+ *t.newData("ok000000001351") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 100 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << true;
+
+
+ *t.newData("ok000000000165") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 1130 << 200 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << true;
+
+ *t.newData("ok000000001354") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 200 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << true;
+
+ *t.newData("ok000000001355") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 200 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << true;
+
+ *t.newData("ok000000001356") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 200 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << true;
+
+ *t.newData("ok000000001357") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 200 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << true;
+
+
+ *t.newData("ok000000000172") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 1130 << 500 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << true;
+
+ *t.newData("ok000000001361") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 500 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << true;
+
+ *t.newData("ok000000001362") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 500 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << true;
+
+ *t.newData("ok000000001363") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 500 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << true;
+
+ *t.newData("ok000000001364") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 500 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << true;
+
+ *t.newData("ok000000001365") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 0 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << true;
+
+ *t.newData("ok000000001366") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 0 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << true;
+
+ *t.newData("ok000000001367") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 0 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << true;
+
+ *t.newData("ok000000001370") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 0 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << true;
+
+ *t.newData("ok000000001371") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 0 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << true;
+
+
+ *t.newData("ok000000001372") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 50 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << true;
+
+ *t.newData("ok000000001373") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 50 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << true;
+
+ *t.newData("ok000000001374") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 50 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << true;
+
+ *t.newData("ok000000001375") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 50 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << true;
+
+ *t.newData("ok000000001376") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 50 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << true;
+
+
+ *t.newData("ok000000000013") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 756 << 100 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << true;
+
+ *t.newData("ok000000001400") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 100 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << true;
+
+ *t.newData("ok000000001401") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 100 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << true;
+
+ *t.newData("ok000000001402") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 100 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << true;
+
+ *t.newData("ok000000001403") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 100 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << true;
+
+
+ *t.newData("ok000000000020") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 756 << 200 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << true;
+
+ *t.newData("ok000000001405") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 200 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << true;
+
+ *t.newData("ok000000001406") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 200 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << true;
+
+ *t.newData("ok000000001407") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 200 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << true;
+
+ *t.newData("ok000000001410") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 200 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << true;
+
+
+ *t.newData("ok000000000025") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 756 << 500 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << true;
+
+ *t.newData("ok000000001412") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 500 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << true;
+
+ *t.newData("ok000000001413") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 500 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << true;
+
+ *t.newData("ok000000001414") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 500 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << true;
+
+ *t.newData("ok000000001415") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 500 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << true;
+
+
+ *t.newData("ok000000000032") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 806 << 0 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << true;
+
+ *t.newData("ok000000001417") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 0 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << true;
+
+ *t.newData("ok000000001420") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 0 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << true;
+
+ *t.newData("ok000000001421") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 0 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << true;
+
+ *t.newData("ok000000001422") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 0 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << true;
+
+
+ *t.newData("ok000000000037") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 806 << 50 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << true;
+
+ *t.newData("ok000000001424") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 50 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << true;
+
+ *t.newData("ok000000001425") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 50 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << true;
+
+ *t.newData("ok000000001426") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 50 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << true;
+
+ *t.newData("ok000000001427") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 50 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << true;
+
+
+ *t.newData("ok000000000044") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 806 << 100 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << true;
+
+ *t.newData("ok000000001431") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 100 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << true;
+
+ *t.newData("ok000000001432") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 100 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << true;
+
+ *t.newData("ok000000001433") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 100 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << true;
+
+ *t.newData("ok000000001434") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 100 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << true;
+
+
+ *t.newData("ok000000000051") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 806 << 200 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << true;
+
+ *t.newData("ok000000001436") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 200 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << true;
+
+ *t.newData("ok000000001437") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 200 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << true;
+
+ *t.newData("ok000000001440") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 200 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << true;
+
+ *t.newData("ok000000001441") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 200 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << true;
+
+
+ *t.newData("ok000000001456") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 806 << 500 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << true;
+
+ *t.newData("ok000000001443") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 500 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << true;
+
+ *t.newData("ok000000001444") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 500 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << true;
+
+ *t.newData("ok000000001445") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 500 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << true;
+
+ *t.newData("ok000000001446") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 500 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << true;
+
+
+ *t.newData("ok000000000063") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 856 << 0 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << true;
+
+ *t.newData("ok000000001450") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 0 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << true;
+
+ *t.newData("ok000000001451") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 0 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << true;
+
+ *t.newData("ok000000001452") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 0 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << true;
+
+ *t.newData("ok000000001453") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 0 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << true;
+
+
+ *t.newData("ok000000001454") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 856 << 50 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << true;
+
+ *t.newData("ok000000001455") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 50 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << true;
+
+ *t.newData("ok000000001456") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 50 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << true;
+
+ *t.newData("ok000000001457") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 50 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << true;
+
+ *t.newData("ok000000001460") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 50 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << true;
+
+
+ *t.newData("ok000000000075") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 856 << 100 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << true;
+
+ *t.newData("ok000000001462") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 100 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << true;
+
+ *t.newData("ok000000001463") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << true;
+
+ *t.newData("ok000000001464") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 100 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << true;
+
+ *t.newData("ok000000001465") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 100 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << true;
+
+
+ *t.newData("ok000000000102") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 856 << 200 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << true;
+
+ *t.newData("ok000000001467") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 200 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << true;
+
+ *t.newData("ok000000001470") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 200 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << true;
+
+ *t.newData("ok000000001471") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 200 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << true;
+
+ *t.newData("ok000000001472") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 200 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << true;
+
+
+ *t.newData("ok000000000107") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 856 << 500 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << true;
+
+ *t.newData("ok000000001474") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 500 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << true;
+
+ *t.newData("ok000000001475") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 500 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << true;
+
+ *t.newData("ok000000001476") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 500 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << true;
+
+ *t.newData("ok000000001477") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 500 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << true;
+
+
+ *t.newData("ok000000000114") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 956 << 0 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << true;
+
+ *t.newData("ok000000001501") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 0 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << true;
+
+ *t.newData("ok000000001502") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 0 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << true;
+
+ *t.newData("ok000000001503") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 0 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << true;
+
+ *t.newData("ok000000001504") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 0 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << true;
+
+
+ *t.newData("ok000000000121") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 956 << 50 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << true;
+
+ *t.newData("ok000000001506") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 50 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << true;
+
+ *t.newData("ok000000001507") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 50 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << true;
+
+ *t.newData("ok000000001510") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 50 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << true;
+
+ *t.newData("ok000000001511") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 50 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << true;
+
+
+ *t.newData("ok000000000126") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 956 << 100 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << true;
+
+ *t.newData("ok000000001513") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 100 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << true;
+
+ *t.newData("ok000000001514") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 100 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << true;
+
+ *t.newData("ok000000001515") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 100 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << true;
+
+ *t.newData("ok000000001516") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 100 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << true;
+
+
+ *t.newData("ok000000000133") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 956 << 200 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << true;
+
+ *t.newData("ok000000001520") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 200 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << true;
+
+ *t.newData("ok000000001521") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 200 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << true;
+
+ *t.newData("ok000000001522") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 200 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << true;
+
+ *t.newData("ok000000001523") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 200 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << true;
+
+
+ *t.newData("ok000000000140") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 956 << 500 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << true;
+
+ *t.newData("ok000000001525") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 500 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << true;
+
+ *t.newData("ok000000001526") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 500 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << true;
+
+ *t.newData("ok000000001527") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 500 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << true;
+
+ *t.newData("ok000000001530") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 500 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << true;
+
+
+ *t.newData("ok000000000145") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 1256 << 0 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << true;
+
+ *t.newData("ok000000001532") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 0 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << true;
+
+ *t.newData("ok000000001533") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 0 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << true;
+
+ *t.newData("ok000000001534") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 0 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << true;
+
+ *t.newData("ok000000001535") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 0 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << true;
+
+
+ *t.newData("ok000000000152") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 1256 << 50 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << true;
+
+ *t.newData("ok000000001537") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 50 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << true;
+
+ *t.newData("ok000000001540") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 50 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << true;
+
+ *t.newData("ok000000001541") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 50 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << true;
+
+ *t.newData("ok000000001542") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 50 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << true;
+
+
+ *t.newData("ok000000000157") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 1256 << 100 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << true;
+
+ *t.newData("ok000000001544") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 100 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << true;
+
+ *t.newData("ok000000001545") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 100 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << true;
+
+ *t.newData("ok000000001546") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 100 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << true;
+
+ *t.newData("ok000000001547") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 100 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << true;
+
+
+ *t.newData("ok000000000165") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 1256 << 200 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << true;
+
+ *t.newData("ok000000001552") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 200 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << true;
+
+ *t.newData("ok000000001553") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 200 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << true;
+
+ *t.newData("ok000000001554") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 200 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << true;
+
+ *t.newData("ok000000001555") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 200 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << true;
+
+
+ *t.newData("ok000000000172") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 1256 << 500 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << true;
+
+ *t.newData("ok000000001557") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 500 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << true;
+
+ *t.newData("ok000000001560") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 500 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << true;
+
+ *t.newData("ok000000001561") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 500 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << true;
+
+ *t.newData("ok000000001562") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 500 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << true;
+
+
+ *t.newData("ok000000001563") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 0 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << true;
+
+ *t.newData("ok000000001564") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 0 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << true;
+
+ *t.newData("ok000000001565") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 0 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << true;
+
+ *t.newData("ok000000001566") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 0 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << true;
+
+ *t.newData("ok000000001567") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 0 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << true;
+
+
+ *t.newData("ok000000001570") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 50 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << true;
+
+ *t.newData("ok000000001571") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 50 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << true;
+
+ *t.newData("ok000000001572") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 50 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << true;
+
+ *t.newData("ok000000001573") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 50 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << true;
+
+ *t.newData("ok000000001574") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 50 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << true;
+
+
+ *t.newData("ok000000000013") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 882 << 100 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << true;
+
+ *t.newData("ok000000001576") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 100 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << true;
+
+ *t.newData("ok000000001577") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 100 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << true;
+
+ *t.newData("ok000000001600") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 100 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << true;
+
+ *t.newData("ok000000001601") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 100 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << true;
+
+
+ *t.newData("ok000000000020") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 882 << 200 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << true;
+
+ *t.newData("ok000000001603") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 200 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << true;
+
+ *t.newData("ok000000001604") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 200 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << true;
+
+ *t.newData("ok000000001605") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 200 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << true;
+
+ *t.newData("ok000000001606") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 200 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << true;
+
+
+ *t.newData("ok000000000025") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 882 << 500 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << true;
+
+ *t.newData("ok000000001610") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 500 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << true;
+
+ *t.newData("ok000000001611") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 500 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << true;
+
+ *t.newData("ok000000001612") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 500 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << true;
+
+ *t.newData("ok000000001613") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 500 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << true;
+
+
+ *t.newData("ok000000000032") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 932 << 0 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << true;
+
+ *t.newData("ok000000001615") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 0 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << true;
+
+ *t.newData("ok000000001616") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 0 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << true;
+
+ *t.newData("ok000000001617") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 0 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << true;
+
+ *t.newData("ok000000001620") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 0 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << true;
+
+
+ *t.newData("ok000000000037") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 932 << 50 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << true;
+
+ *t.newData("ok000000001622") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 50 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << true;
+
+ *t.newData("ok000000001623") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 50 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << true;
+
+ *t.newData("ok000000001624") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 50 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << true;
+
+ *t.newData("ok000000001625") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 50 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << true;
+
+
+ *t.newData("ok000000000044") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 932 << 100 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << true;
+
+ *t.newData("ok000000001627") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 100 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << true;
+
+ *t.newData("ok000000001630") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 100 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << true;
+
+ *t.newData("ok000000001631") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 100 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << true;
+
+ *t.newData("ok000000001632") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 100 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << true;
+
+
+ *t.newData("ok000000000051") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 932 << 200 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << true;
+
+ *t.newData("ok000000001634") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 200 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << true;
+
+ *t.newData("ok000000001635") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 200 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << true;
+
+ *t.newData("ok000000001636") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 200 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << true;
+
+ *t.newData("ok000000001637") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 200 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << true;
+
+
+ *t.newData("ok000000000056") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 932 << 500 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << true;
+
+ *t.newData("ok000000001641") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 500 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << true;
+
+ *t.newData("ok000000001642") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 500 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << true;
+
+ *t.newData("ok000000001643") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 500 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << true;
+
+ *t.newData("ok000000001644") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 500 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << true;
+
+
+ *t.newData("ok000000000063") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 982 << 0 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << true;
+
+ *t.newData("ok000000001646") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 0 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << true;
+
+ *t.newData("ok000000001647") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 0 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << true;
+
+ *t.newData("ok000000001650") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 0 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << true;
+
+ *t.newData("ok000000001651") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 0 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << true;
+
+
+ *t.newData("ok000000000070") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 982 << 50 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << true;
+
+ *t.newData("ok000000001653") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 50 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << true;
+
+ *t.newData("ok000000001654") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 50 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << true;
+
+ *t.newData("ok000000001655") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 50 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << true;
+
+ *t.newData("ok000000001656") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 50 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << true;
+
+
+ *t.newData("ok000000000075") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 982 << 100 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << true;
+
+ *t.newData("ok000000001660") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 100 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << true;
+
+ *t.newData("ok000000001661") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << true;
+
+ *t.newData("ok000000001662") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 100 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << true;
+
+ *t.newData("ok000000001663") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 100 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << true;
+
+
+ *t.newData("ok000000000102") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 982 << 200 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << true;
+
+ *t.newData("ok000000001665") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 200 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << true;
+
+ *t.newData("ok000000001666") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 200 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << true;
+
+ *t.newData("ok000000001667") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 200 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << true;
+
+ *t.newData("ok000000001670") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 200 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << true;
+
+
+ *t.newData("ok000000000107") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 982 << 500 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << true;
+
+ *t.newData("ok000000001672") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 500 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << true;
+
+ *t.newData("ok000000001673") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 500 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << true;
+
+ *t.newData("ok000000001674") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 500 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << true;
+
+ *t.newData("ok000000001675") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 500 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << true;
+
+
+ *t.newData("ok000000000114") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 1082 << 0 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << true;
+
+ *t.newData("ok000000001677") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 0 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << true;
+
+ *t.newData("ok000000001700") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 0 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << true;
+
+ *t.newData("ok000000001701") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 0 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << true;
+
+ *t.newData("ok000000001702") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 0 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << true;
+
+
+ *t.newData("ok000000000121") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 1082 << 50 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << true;
+
+ *t.newData("ok000000001704") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 50 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << true;
+
+ *t.newData("ok000000001705") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 50 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << true;
+
+ *t.newData("ok000000001706") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 50 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << true;
+
+ *t.newData("ok000000001707") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 50 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << true;
+
+
+ *t.newData("ok000000000126") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 1082 << 100 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << true;
+
+ *t.newData("ok000000001711") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 100 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << true;
+
+ *t.newData("ok000000001712") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 100 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << true;
+
+ *t.newData("ok000000001713") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 100 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << true;
+
+ *t.newData("ok000000001714") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 100 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << true;
+
+
+ *t.newData("ok000000000133") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 1082 << 200 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << true;
+
+ *t.newData("ok000000001716") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 200 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << true;
+
+ *t.newData("ok000000001717") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 200 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << true;
+
+ *t.newData("ok000000001720") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 200 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << true;
+
+ *t.newData("ok000000001721") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 200 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << true;
+
+
+ *t.newData("ok000000000140") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 1082 << 500 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << true;
+
+ *t.newData("ok000000001723") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 500 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << true;
+
+ *t.newData("ok000000001724") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 500 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << true;
+
+ *t.newData("ok000000001725") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 500 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << true;
+
+ *t.newData("ok000000001726") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 500 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << true;
+
+
+ *t.newData("ok000000000145") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 1382 << 0 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << true;
+
+ *t.newData("ok000000001730") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 0 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << true;
+
+ *t.newData("ok000000001731") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 0 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << true;
+
+ *t.newData("ok000000001732") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 0 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << true;
+
+ *t.newData("ok000000001733") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 0 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << true;
+
+
+ *t.newData("ok000000000152") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 1382 << 50 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << true;
+
+ *t.newData("ok000000001735") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 50 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << true;
+
+ *t.newData("ok000000001736") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 50 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << true;
+
+ *t.newData("ok000000001737") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 50 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << true;
+
+ *t.newData("ok000000001740") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 50 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << true;
+
+
+ *t.newData("ok000000000157") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 1382 << 100 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << true;
+
+ *t.newData("ok000000001742") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 100 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << true;
+
+ *t.newData("ok000000001743") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 100 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << true;
+
+ *t.newData("ok000000001744") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 100 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << true;
+
+ *t.newData("ok000000001745") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 100 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << true;
+
+
+ *t.newData("ok000000000165") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 1382 << 200 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << true;
+
+ *t.newData("ok000000001750") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 200 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << true;
+
+ *t.newData("ok000000001751") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 200 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << true;
+
+ *t.newData("ok000000001752") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 200 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << true;
+
+ *t.newData("ok000000001753") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 200 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << true;
+
+
+ *t.newData("ok000000000172") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 1382 << 500 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << true;
+
+ *t.newData("ok000000001755") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 500 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << true;
+
+ *t.newData("ok000000001756") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 500 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << true;
+
+ *t.newData("ok000000001757") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 500 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << true;
+
+ *t.newData("ok000000001760") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 500 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << true;
+ *t.newData("ok000000001761") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 0 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << true)
+ << false;
+
+ *t.newData("ok000000001762") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 0 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << true)
+ << false;
+
+ *t.newData("ok000000001763") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 0 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << true)
+ << false;
+
+ *t.newData("ok000000001764") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 0 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << true)
+ << false;
+
+ *t.newData("ok000000001765") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 0 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << true)
+ << false;
+
+
+ *t.newData("ok000000001766") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 50 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << true)
+ << false;
+
+ *t.newData("ok000000001767") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 50 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << true)
+ << false;
+
+ *t.newData("ok000000001770") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 50 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << true)
+ << false;
+
+ *t.newData("ok000000001771") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 50 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << true)
+ << false;
+
+ *t.newData("ok000000001772") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 50 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << true)
+ << false;
+
+
+ *t.newData("ok000000001773") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 100 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << true)
+ << false;
+
+ *t.newData("ok000000001774") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 100 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << true)
+ << false;
+
+ *t.newData("ok000000001775") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 100 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << true)
+ << false;
+
+ *t.newData("ok000000001776") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 100 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << true)
+ << false;
+
+ *t.newData("ok000000001777") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 100 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << true)
+ << false;
+
+
+ *t.newData("ok000000002000") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 200 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << true)
+ << false;
+
+ *t.newData("ok000000002001") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 200 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << true)
+ << false;
+
+ *t.newData("ok000000002002") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 200 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << true)
+ << false;
+
+ *t.newData("ok000000002003") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 200 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << true)
+ << false;
+
+ *t.newData("ok000000002004") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 200 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << true)
+ << false;
+
+
+ *t.newData("ok000000002005") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 500 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << true)
+ << false;
+
+ *t.newData("ok000000002006") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 500 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << true)
+ << false;
+
+ *t.newData("ok000000002007") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 500 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << true)
+ << false;
+
+ *t.newData("ok000000002010") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 500 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << true)
+ << false;
+
+ *t.newData("ok000000002011") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 500 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << true)
+ << false;
+
+
+ *t.newData("ok000000002012") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 0 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << true)
+ << false;
+
+ *t.newData("ok000000002013") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 0 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << true)
+ << false;
+
+ *t.newData("ok000000002014") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 0 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << true)
+ << false;
+
+ *t.newData("ok000000002015") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 0 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << true)
+ << false;
+
+ *t.newData("ok000000002016") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 0 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << true)
+ << false;
+
+
+ *t.newData("ok000000002017") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 50 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << true)
+ << false;
+
+ *t.newData("ok000000002020") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 50 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << true)
+ << false;
+
+ *t.newData("ok000000002021") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 50 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << true)
+ << false;
+
+ *t.newData("ok000000002022") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 50 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << true)
+ << false;
+
+ *t.newData("ok000000002023") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 50 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << true)
+ << false;
+
+
+ *t.newData("ok000000002024") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 100 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << true)
+ << false;
+
+ *t.newData("ok000000002025") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 100 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << true)
+ << false;
+
+ *t.newData("ok000000002026") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 100 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << true)
+ << false;
+
+ *t.newData("ok000000002027") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 100 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << true)
+ << false;
+
+ *t.newData("ok000000002030") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 100 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << true)
+ << false;
+
+
+ *t.newData("ok000000002031") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 200 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << true)
+ << false;
+
+ *t.newData("ok000000002032") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 200 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << true)
+ << false;
+
+ *t.newData("ok000000002033") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 200 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << true)
+ << false;
+
+ *t.newData("ok000000002034") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 200 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << true)
+ << false;
+
+ *t.newData("ok000000002035") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 200 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << true)
+ << false;
+
+
+ *t.newData("ok000000002036") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 500 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << true)
+ << false;
+
+ *t.newData("ok000000002037") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 500 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << true)
+ << false;
+
+ *t.newData("ok000000002040") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 500 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << true)
+ << false;
+
+ *t.newData("ok000000002041") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 500 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << true)
+ << false;
+
+ *t.newData("ok000000002042") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 500 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << true)
+ << false;
+
+
+ *t.newData("ok000000002043") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 0 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << true)
+ << false;
+
+ *t.newData("ok000000002044") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 0 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << true)
+ << false;
+
+ *t.newData("ok000000002045") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 0 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << true)
+ << false;
+
+ *t.newData("ok000000002046") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 0 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << true)
+ << false;
+
+ *t.newData("ok000000002047") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 0 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << true)
+ << false;
+
+
+ *t.newData("ok000000002050") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 50 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << true)
+ << false;
+
+ *t.newData("ok000000002051") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 50 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << true)
+ << false;
+
+ *t.newData("ok000000002052") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 50 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << true)
+ << false;
+
+ *t.newData("ok000000002053") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 50 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << true)
+ << false;
+
+ *t.newData("ok000000002054") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 50 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << true)
+ << false;
+
+
+ *t.newData("ok000000002055") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 100 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << true)
+ << false;
+
+ *t.newData("ok000000002056") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 100 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << true)
+ << false;
+
+ *t.newData("ok000000002057") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << true)
+ << false;
+
+ *t.newData("ok000000002060") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 100 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << true)
+ << false;
+
+ *t.newData("ok000000002061") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 100 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << true)
+ << false;
+
+
+ *t.newData("ok000000002062") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 200 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << true)
+ << false;
+
+ *t.newData("ok000000002063") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 200 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << true)
+ << false;
+
+ *t.newData("ok000000002064") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 200 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << true)
+ << false;
+
+ *t.newData("ok000000002065") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 200 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << true)
+ << false;
+
+ *t.newData("ok000000002066") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 200 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << true)
+ << false;
+
+
+ *t.newData("ok000000002067") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 500 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << true)
+ << false;
+
+ *t.newData("ok000000002070") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 500 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << true)
+ << false;
+
+ *t.newData("ok000000002071") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 500 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << true)
+ << false;
+
+ *t.newData("ok000000002072") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 500 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << true)
+ << false;
+
+ *t.newData("ok000000002073") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 500 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << true)
+ << false;
+
+
+ *t.newData("ok000000002074") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 0 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << true)
+ << false;
+
+ *t.newData("ok000000002075") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 0 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << true)
+ << false;
+
+ *t.newData("ok000000002076") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 0 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << true)
+ << false;
+
+ *t.newData("ok000000002077") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 0 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << true)
+ << false;
+
+ *t.newData("ok000000002100") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 0 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << true)
+ << false;
+
+
+ *t.newData("ok000000002101") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 50 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << true)
+ << false;
+
+ *t.newData("ok000000002102") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 50 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << true)
+ << false;
+
+ *t.newData("ok000000002103") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 50 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << true)
+ << false;
+
+ *t.newData("ok000000002104") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 50 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << true)
+ << false;
+
+ *t.newData("ok000000002105") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 50 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << true)
+ << false;
+
+
+ *t.newData("ok000000002106") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 100 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << true)
+ << false;
+
+ *t.newData("ok000000002107") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 100 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << true)
+ << false;
+
+ *t.newData("ok000000002110") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 100 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << true)
+ << false;
+
+ *t.newData("ok000000002111") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 100 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << true)
+ << false;
+
+ *t.newData("ok000000002112") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 100 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << true)
+ << false;
+
+
+ *t.newData("ok000000002113") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 200 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << true)
+ << false;
+
+ *t.newData("ok000000002114") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 200 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << true)
+ << false;
+
+ *t.newData("ok000000002115") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 200 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << true)
+ << false;
+
+ *t.newData("ok000000002116") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 200 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << true)
+ << false;
+
+ *t.newData("ok000000002117") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 200 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << true)
+ << false;
+
+
+ *t.newData("ok000000002120") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 500 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << true)
+ << false;
+
+ *t.newData("ok000000002121") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 500 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << true)
+ << false;
+
+ *t.newData("ok000000002122") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 500 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << true)
+ << false;
+
+ *t.newData("ok000000002123") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 500 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << true)
+ << false;
+
+ *t.newData("ok000000002124") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 500 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << true)
+ << false;
+
+
+ *t.newData("ok000000002125") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 0 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << true)
+ << false;
+
+ *t.newData("ok000000002126") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 0 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << true)
+ << false;
+
+ *t.newData("ok000000002127") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 0 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << true)
+ << false;
+
+ *t.newData("ok000000002130") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 0 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << true)
+ << false;
+
+ *t.newData("ok000000002131") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 0 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << true)
+ << false;
+
+
+ *t.newData("ok000000002132") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 50 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << true)
+ << false;
+
+ *t.newData("ok000000002133") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 50 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << true)
+ << false;
+
+ *t.newData("ok000000002134") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 50 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << true)
+ << false;
+
+ *t.newData("ok000000002135") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 50 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << true)
+ << false;
+
+ *t.newData("ok000000002136") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 50 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << true)
+ << false;
+
+
+ *t.newData("ok000000002137") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 100 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << true)
+ << false;
+
+ *t.newData("ok000000002140") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 100 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << true)
+ << false;
+
+ *t.newData("ok000000002141") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 100 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << true)
+ << false;
+
+ *t.newData("ok000000002142") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 100 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << true)
+ << false;
+
+ *t.newData("ok000000002143") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 100 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << true)
+ << false;
+
+
+ *t.newData("ok000000002145") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 200 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << true)
+ << false;
+
+ *t.newData("ok000000002146") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 200 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << true)
+ << false;
+
+ *t.newData("ok000000002147") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 200 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << true)
+ << false;
+
+ *t.newData("ok000000002150") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 200 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << true)
+ << false;
+
+ *t.newData("ok000000002151") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 200 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << true)
+ << false;
+
+
+ *t.newData("ok000000002152") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 500 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << true)
+ << false;
+
+ *t.newData("ok000000002153") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 500 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << true)
+ << false;
+
+ *t.newData("ok000000002154") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 500 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << true)
+ << false;
+
+ *t.newData("ok000000002155") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 500 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << true)
+ << false;
+
+ *t.newData("ok000000002156") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 500 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << true)
+ << false;
+
+
+ *t.newData("ok000000002157") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 0 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << false)
+ << false;
+
+ *t.newData("ok000000002160") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 0 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << false)
+ << false;
+
+ *t.newData("ok000000002161") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 0 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << false)
+ << false;
+
+ *t.newData("ok000000002162") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 0 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << false)
+ << false;
+
+ *t.newData("ok000000002163") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 0 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << false)
+ << false;
+
+
+ *t.newData("ok000000002164") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 50 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << false)
+ << false;
+
+ *t.newData("ok000000002165") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 50 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << false)
+ << false;
+
+ *t.newData("ok000000002166") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 50 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << false)
+ << false;
+
+ *t.newData("ok000000002167") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 50 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << false)
+ << false;
+
+ *t.newData("ok000000002170") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 50 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << false)
+ << false;
+
+
+ *t.newData("ok000000002171") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 100 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << false)
+ << false;
+
+ *t.newData("ok000000002172") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 100 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << false)
+ << false;
+
+ *t.newData("ok000000002173") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 100 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << false)
+ << false;
+
+ *t.newData("ok000000002174") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 100 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << false)
+ << false;
+
+ *t.newData("ok000000002175") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 100 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << false)
+ << false;
+
+
+ *t.newData("ok000000002176") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 200 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << false)
+ << false;
+
+ *t.newData("ok000000002177") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 200 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << false)
+ << false;
+
+ *t.newData("ok000000002200") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 200 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << false)
+ << false;
+
+ *t.newData("ok000000002201") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 200 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << false)
+ << false;
+
+ *t.newData("ok000000002202") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 200 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << false)
+ << false;
+
+
+ *t.newData("ok000000002203") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 500 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << false)
+ << false;
+
+ *t.newData("ok000000002204") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 500 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << false)
+ << false;
+
+ *t.newData("ok000000002205") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 500 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << false)
+ << false;
+
+ *t.newData("ok000000002206") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 500 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << false)
+ << false;
+
+ *t.newData("ok000000002207") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 500 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << false)
+ << false;
+
+
+ *t.newData("ok000000002210") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 0 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << false)
+ << false;
+
+ *t.newData("ok000000002211") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 0 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << false)
+ << false;
+
+ *t.newData("ok000000002212") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 0 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << false)
+ << false;
+
+ *t.newData("ok000000002213") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 0 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << false)
+ << false;
+
+ *t.newData("ok000000002214") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 0 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << false)
+ << false;
+
+
+ *t.newData("ok000000002215") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 50 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << false)
+ << false;
+
+ *t.newData("ok000000002216") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 50 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << false)
+ << false;
+
+ *t.newData("ok000000002217") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 50 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << false)
+ << false;
+
+ *t.newData("ok000000002220") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 50 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << false)
+ << false;
+
+ *t.newData("ok000000002221") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 50 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << false)
+ << false;
+
+
+ *t.newData("ok000000002222") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 100 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << false)
+ << false;
+
+ *t.newData("ok000000002223") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 100 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << false)
+ << false;
+
+ *t.newData("ok000000002224") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 100 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << false)
+ << false;
+
+ *t.newData("ok000000002225") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 100 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << false)
+ << false;
+
+ *t.newData("ok000000002226") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 100 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << false)
+ << false;
+
+
+ *t.newData("ok000000002227") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 200 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << false)
+ << false;
+
+ *t.newData("ok000000002230") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 200 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << false)
+ << false;
+
+ *t.newData("ok000000002231") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 200 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << false)
+ << false;
+
+ *t.newData("ok000000002232") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 200 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << false)
+ << false;
+
+ *t.newData("ok000000002233") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 200 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << false)
+ << false;
+
+
+ *t.newData("ok000000002234") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 500 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << false)
+ << false;
+
+ *t.newData("ok000000002235") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 500 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << false)
+ << false;
+
+ *t.newData("ok000000002236") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 500 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << false)
+ << false;
+
+ *t.newData("ok000000002237") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 500 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << false)
+ << false;
+
+ *t.newData("ok000000002240") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 500 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << false)
+ << false;
+
+
+ *t.newData("ok000000002241") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 0 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << false)
+ << false;
+
+ *t.newData("ok000000002242") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 0 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << false)
+ << false;
+
+ *t.newData("ok000000002243") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 0 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << false)
+ << false;
+
+ *t.newData("ok000000002244") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 0 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << false)
+ << false;
+
+ *t.newData("ok000000002245") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 0 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << false)
+ << false;
+
+
+ *t.newData("ok000000002246") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 50 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << false)
+ << false;
+
+ *t.newData("ok000000002247") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 50 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << false)
+ << false;
+
+ *t.newData("ok000000002250") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 50 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << false)
+ << false;
+
+ *t.newData("ok000000002251") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 50 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << false)
+ << false;
+
+ *t.newData("ok000000002252") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 50 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << false)
+ << false;
+
+
+ *t.newData("ok000000002253") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 100 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << false)
+ << false;
+
+ *t.newData("ok000000002254") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 100 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << false)
+ << false;
+
+ *t.newData("ok000000002255") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << false)
+ << false;
+
+ *t.newData("ok000000002256") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 100 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << false)
+ << false;
+
+ *t.newData("ok000000002257") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 100 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << false)
+ << false;
+
+
+ *t.newData("ok000000002260") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 200 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << false)
+ << false;
+
+ *t.newData("ok000000002261") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 200 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << false)
+ << false;
+
+ *t.newData("ok000000002262") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 200 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << false)
+ << false;
+
+ *t.newData("ok000000002263") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 200 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << false)
+ << false;
+
+ *t.newData("ok000000002264") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 200 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << false)
+ << false;
+
+
+ *t.newData("ok000000002265") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 500 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << false)
+ << false;
+
+ *t.newData("ok000000002266") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 500 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << false)
+ << false;
+
+ *t.newData("ok000000002267") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 500 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << false)
+ << false;
+
+ *t.newData("ok000000002270") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 500 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << false)
+ << false;
+
+ *t.newData("ok000000002271") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 500 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << false)
+ << false;
+
+
+ *t.newData("ok000000002272") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 0 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << false)
+ << false;
+
+ *t.newData("ok000000002273") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 0 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << false)
+ << false;
+
+ *t.newData("ok000000002274") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 0 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << false)
+ << false;
+
+ *t.newData("ok000000002275") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 0 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << false)
+ << false;
+
+ *t.newData("ok000000002276") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 0 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << false)
+ << false;
+
+
+ *t.newData("ok000000002277") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 50 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << false)
+ << false;
+
+ *t.newData("ok000000002300") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 50 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << false)
+ << false;
+
+ *t.newData("ok000000002301") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 50 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << false)
+ << false;
+
+ *t.newData("ok000000002302") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 50 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << false)
+ << false;
+
+ *t.newData("ok000000002303") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 50 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << false)
+ << false;
+
+
+ *t.newData("ok000000002304") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 100 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << false)
+ << false;
+
+ *t.newData("ok000000002305") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 100 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << false)
+ << false;
+
+ *t.newData("ok000000002306") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 100 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << false)
+ << false;
+
+ *t.newData("ok000000002307") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 100 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << false)
+ << false;
+
+ *t.newData("ok000000002310") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 100 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << false)
+ << false;
+
+
+ *t.newData("ok000000002311") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 200 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << false)
+ << false;
+
+ *t.newData("ok000000002312") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 200 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << false)
+ << false;
+
+ *t.newData("ok000000002313") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 200 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << false)
+ << false;
+
+ *t.newData("ok000000002314") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 200 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << false)
+ << false;
+
+ *t.newData("ok000000002315") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 200 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << false)
+ << false;
+
+
+ *t.newData("ok000000002316") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 500 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << false)
+ << false;
+
+ *t.newData("ok000000002317") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 500 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << false)
+ << false;
+
+ *t.newData("ok000000002320") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 500 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << false)
+ << false;
+
+ *t.newData("ok000000002321") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 500 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << false)
+ << false;
+
+ *t.newData("ok000000002322") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 500 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << false)
+ << false;
+
+
+ *t.newData("ok000000002323") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 0 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << false)
+ << false;
+
+ *t.newData("ok000000002324") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 0 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << false)
+ << false;
+
+ *t.newData("ok000000002325") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 0 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << false)
+ << false;
+
+ *t.newData("ok000000002326") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 0 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << false)
+ << false;
+
+ *t.newData("ok000000002327") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 0 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << false)
+ << false;
+
+
+ *t.newData("ok000000002330") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 50 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << false)
+ << false;
+
+ *t.newData("ok000000002331") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 50 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << false)
+ << false;
+
+ *t.newData("ok000000002332") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 50 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << false)
+ << false;
+
+ *t.newData("ok000000002333") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 50 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << false)
+ << false;
+
+ *t.newData("ok000000002334") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 50 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << false)
+ << false;
+
+
+ *t.newData("ok000000002335") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 100 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << false)
+ << false;
+
+ *t.newData("ok000000002336") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 100 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << false)
+ << false;
+
+ *t.newData("ok000000002337") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 100 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << false)
+ << false;
+
+ *t.newData("ok000000002340") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 100 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << false)
+ << false;
+
+ *t.newData("ok000000002341") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 100 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << false)
+ << false;
+
+
+ *t.newData("ok000000002343") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 200 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << false)
+ << false;
+
+ *t.newData("ok000000002344") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 200 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << false)
+ << false;
+
+ *t.newData("ok000000002345") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 200 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << false)
+ << false;
+
+ *t.newData("ok000000002346") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 200 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << false)
+ << false;
+
+ *t.newData("ok000000002347") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 200 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << false)
+ << false;
+
+
+ *t.newData("ok000000002350") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 500 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << false)
+ << false;
+
+ *t.newData("ok000000002351") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 500 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << false)
+ << false;
+
+ *t.newData("ok000000002352") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 500 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << false)
+ << false;
+
+ *t.newData("ok000000002353") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 500 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << false)
+ << false;
+
+ *t.newData("ok000000002354") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 500 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << true << false)
+ << false;
+
+ *t.newData("ok000000002355") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 0 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << true)
+ << false;
+
+ *t.newData("ok000000002356") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 0 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << true)
+ << false;
+
+ *t.newData("ok000000002357") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 0 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << true)
+ << false;
+
+ *t.newData("ok000000002360") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 0 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << true)
+ << false;
+
+ *t.newData("ok000000002361") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 0 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << true)
+ << false;
+
+
+ *t.newData("ok000000002362") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 50 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << true)
+ << false;
+
+ *t.newData("ok000000002363") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 50 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << true)
+ << false;
+
+ *t.newData("ok000000002364") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 50 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << true)
+ << false;
+
+ *t.newData("ok000000002365") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 50 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << true)
+ << false;
+
+ *t.newData("ok000000002366") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 50 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << true)
+ << false;
+
+
+ *t.newData("ok000000002367") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 100 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << true)
+ << false;
+
+ *t.newData("ok000000002370") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 100 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << true)
+ << false;
+
+ *t.newData("ok000000002371") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 100 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << true)
+ << false;
+
+ *t.newData("ok000000002372") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 100 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << true)
+ << false;
+
+ *t.newData("ok000000002373") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 100 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << true)
+ << false;
+
+
+ *t.newData("ok000000002374") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 200 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << true)
+ << false;
+
+ *t.newData("ok000000002375") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 200 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << true)
+ << false;
+
+ *t.newData("ok000000002376") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 200 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << true)
+ << false;
+
+ *t.newData("ok000000002377") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 200 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << true)
+ << false;
+
+ *t.newData("ok000000002400") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 200 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << true)
+ << false;
+
+
+ *t.newData("ok000000002401") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 500 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << true)
+ << false;
+
+ *t.newData("ok000000002402") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 500 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << true)
+ << false;
+
+ *t.newData("ok000000002403") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 500 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << true)
+ << false;
+
+ *t.newData("ok000000002404") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 500 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << true)
+ << false;
+
+ *t.newData("ok000000002405") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 500 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << true)
+ << false;
+
+
+ *t.newData("ok000000002406") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 0 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << true)
+ << false;
+
+ *t.newData("ok000000002407") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 0 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << true)
+ << false;
+
+ *t.newData("ok000000002410") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 0 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << true)
+ << false;
+
+ *t.newData("ok000000002411") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 0 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << true)
+ << false;
+
+ *t.newData("ok000000002412") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 0 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << true)
+ << false;
+
+
+ *t.newData("ok000000002413") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 50 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << true)
+ << false;
+
+ *t.newData("ok000000002414") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 50 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << true)
+ << false;
+
+ *t.newData("ok000000002415") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 50 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << true)
+ << false;
+
+ *t.newData("ok000000002416") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 50 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << true)
+ << false;
+
+ *t.newData("ok000000002417") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 50 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << true)
+ << false;
+
+
+ *t.newData("ok000000002420") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 100 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << true)
+ << false;
+
+ *t.newData("ok000000002421") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 100 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << true)
+ << false;
+
+ *t.newData("ok000000002422") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 100 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << true)
+ << false;
+
+ *t.newData("ok000000002423") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 100 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << true)
+ << false;
+
+ *t.newData("ok000000002424") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 100 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << true)
+ << false;
+
+
+ *t.newData("ok000000002425") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 200 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << true)
+ << false;
+
+ *t.newData("ok000000002426") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 200 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << true)
+ << false;
+
+ *t.newData("ok000000002427") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 200 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << true)
+ << false;
+
+ *t.newData("ok000000002430") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 200 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << true)
+ << false;
+
+ *t.newData("ok000000002431") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 200 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << true)
+ << false;
+
+
+ *t.newData("ok000000002432") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 500 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << true)
+ << false;
+
+ *t.newData("ok000000002433") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 500 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << true)
+ << false;
+
+ *t.newData("ok000000002434") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 500 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << true)
+ << false;
+
+ *t.newData("ok000000002435") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 500 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << true)
+ << false;
+
+ *t.newData("ok000000002436") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 500 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << true)
+ << false;
+
+
+ *t.newData("ok000000002437") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 0 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << true)
+ << false;
+
+ *t.newData("ok000000002440") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 0 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << true)
+ << false;
+
+ *t.newData("ok000000002441") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 0 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << true)
+ << false;
+
+ *t.newData("ok000000002442") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 0 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << true)
+ << false;
+
+ *t.newData("ok000000002443") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 0 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << true)
+ << false;
+
+
+ *t.newData("ok000000002444") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 50 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << true)
+ << false;
+
+ *t.newData("ok000000002445") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 50 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << true)
+ << false;
+
+ *t.newData("ok000000002446") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 50 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << true)
+ << false;
+
+ *t.newData("ok000000002447") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 50 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << true)
+ << false;
+
+ *t.newData("ok000000002450") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 50 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << true)
+ << false;
+
+
+ *t.newData("ok000000002451") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 100 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << true)
+ << false;
+
+ *t.newData("ok000000002452") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 100 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << true)
+ << false;
+
+ *t.newData("ok000000002453") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << true)
+ << false;
+
+ *t.newData("ok000000002454") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 100 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << true)
+ << false;
+
+ *t.newData("ok000000002455") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 100 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << true)
+ << false;
+
+
+ *t.newData("ok000000002456") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 200 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << true)
+ << false;
+
+ *t.newData("ok000000002457") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 200 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << true)
+ << false;
+
+ *t.newData("ok000000002460") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 200 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << true)
+ << false;
+
+ *t.newData("ok000000002461") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 200 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << true)
+ << false;
+
+ *t.newData("ok000000002462") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 200 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << true)
+ << false;
+
+
+ *t.newData("ok000000002463") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 500 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << true)
+ << false;
+
+ *t.newData("ok000000002464") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 500 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << true)
+ << false;
+
+ *t.newData("ok000000002465") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 500 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << true)
+ << false;
+
+ *t.newData("ok000000002466") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 500 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << true)
+ << false;
+
+ *t.newData("ok000000002467") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 500 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << true)
+ << false;
+
+
+ *t.newData("ok000000002470") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 0 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << true)
+ << false;
+
+ *t.newData("ok000000002471") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 0 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << true)
+ << false;
+
+ *t.newData("ok000000002472") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 0 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << true)
+ << false;
+
+ *t.newData("ok000000002473") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 0 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << true)
+ << false;
+
+ *t.newData("ok000000002474") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 0 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << true)
+ << false;
+
+
+ *t.newData("ok000000002475") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 50 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << true)
+ << false;
+
+ *t.newData("ok000000002476") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 50 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << true)
+ << false;
+
+ *t.newData("ok000000002477") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 50 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << true)
+ << false;
+
+ *t.newData("ok000000002500") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 50 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << true)
+ << false;
+
+ *t.newData("ok000000002501") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 50 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << true)
+ << false;
+
+
+ *t.newData("ok000000002502") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 100 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << true)
+ << false;
+
+ *t.newData("ok000000002503") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 100 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << true)
+ << false;
+
+ *t.newData("ok000000002504") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 100 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << true)
+ << false;
+
+ *t.newData("ok000000002505") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 100 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << true)
+ << false;
+
+ *t.newData("ok000000002506") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 100 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << true)
+ << false;
+
+
+ *t.newData("ok000000002507") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 200 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << true)
+ << false;
+
+ *t.newData("ok000000002510") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 200 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << true)
+ << false;
+
+ *t.newData("ok000000002511") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 200 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << true)
+ << false;
+
+ *t.newData("ok000000002512") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 200 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << true)
+ << false;
+
+ *t.newData("ok000000002513") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 200 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << true)
+ << false;
+
+
+ *t.newData("ok000000002514") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 500 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << true)
+ << false;
+
+ *t.newData("ok000000002515") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 500 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << true)
+ << false;
+
+ *t.newData("ok000000002516") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 500 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << true)
+ << false;
+
+ *t.newData("ok000000002517") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 500 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << true)
+ << false;
+
+ *t.newData("ok000000002520") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 500 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << true)
+ << false;
+
+
+ *t.newData("ok000000002521") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 0 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << true)
+ << false;
+
+ *t.newData("ok000000002522") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 0 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << true)
+ << false;
+
+ *t.newData("ok000000002523") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 0 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << true)
+ << false;
+
+ *t.newData("ok000000002524") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 0 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << true)
+ << false;
+
+ *t.newData("ok000000002525") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 0 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << true)
+ << false;
+
+
+ *t.newData("ok000000002526") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 50 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << true)
+ << false;
+
+ *t.newData("ok000000002527") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 50 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << true)
+ << false;
+
+ *t.newData("ok000000002530") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 50 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << true)
+ << false;
+
+ *t.newData("ok000000002531") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 50 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << true)
+ << false;
+
+ *t.newData("ok000000002532") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 50 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << true)
+ << false;
+
+
+ *t.newData("ok000000002533") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 100 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << true)
+ << false;
+
+ *t.newData("ok000000002534") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 100 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << true)
+ << false;
+
+ *t.newData("ok000000002535") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 100 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << true)
+ << false;
+
+ *t.newData("ok000000002536") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 100 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << true)
+ << false;
+
+ *t.newData("ok000000002537") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 100 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << true)
+ << false;
+
+
+ *t.newData("ok000000002541") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 200 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << true)
+ << false;
+
+ *t.newData("ok000000002542") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 200 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << true)
+ << false;
+
+ *t.newData("ok000000002543") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 200 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << true)
+ << false;
+
+ *t.newData("ok000000002544") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 200 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << true)
+ << false;
+
+ *t.newData("ok000000002545") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 200 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << true)
+ << false;
+
+
+ *t.newData("ok000000002546") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 500 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << true)
+ << false;
+
+ *t.newData("ok000000002547") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 500 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << true)
+ << false;
+
+ *t.newData("ok000000002550") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 500 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << true)
+ << false;
+
+ *t.newData("ok000000002551") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 500 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << true)
+ << false;
+
+ *t.newData("ok000000002552") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 500 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << true)
+ << false;
+
+ *t.newData("ok000000002553") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 0 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << false;
+
+ *t.newData("ok000000002554") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 0 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << false;
+
+ *t.newData("ok000000002555") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 0 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << false;
+
+ *t.newData("ok000000002556") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 0 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << false;
+
+ *t.newData("ok000000002557") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 0 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << false;
+
+
+ *t.newData("ok000000002560") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 50 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << false;
+
+ *t.newData("ok000000002561") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 50 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << false;
+
+ *t.newData("ok000000002562") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 50 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << false;
+
+ *t.newData("ok000000002563") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 50 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << false;
+
+ *t.newData("ok000000002564") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 50 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << false;
+
+
+ *t.newData("ok000000002565") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 100 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << false;
+
+ *t.newData("ok000000002566") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 100 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << false;
+
+ *t.newData("ok000000002567") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 100 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << false;
+
+ *t.newData("ok000000002570") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 100 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << false;
+
+ *t.newData("ok000000002571") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 100 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << false;
+
+
+ *t.newData("ok000000002572") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 200 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << false;
+
+ *t.newData("ok000000002573") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 200 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << false;
+
+ *t.newData("ok000000002574") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 200 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << false;
+
+ *t.newData("ok000000002575") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 200 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << false;
+
+ *t.newData("ok000000002576") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 200 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << false;
+
+
+ *t.newData("ok000000002577") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 500 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << false;
+
+ *t.newData("ok000000002600") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 500 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << false;
+
+ *t.newData("ok000000002601") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 500 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << false;
+
+ *t.newData("ok000000002602") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 500 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << false;
+
+ *t.newData("ok000000002603") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 500 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << false;
+
+
+ *t.newData("ok000000002604") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 0 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << false;
+
+ *t.newData("ok000000002605") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 0 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << false;
+
+ *t.newData("ok000000002606") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 0 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << false;
+
+ *t.newData("ok000000002607") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 0 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << false;
+
+ *t.newData("ok000000002610") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 0 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << false;
+
+
+ *t.newData("ok000000002611") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 50 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << false;
+
+ *t.newData("ok000000002612") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 50 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << false;
+
+ *t.newData("ok000000002613") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 50 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << false;
+
+ *t.newData("ok000000002614") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 50 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << false;
+
+ *t.newData("ok000000002615") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 50 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << false;
+
+
+ *t.newData("ok000000002616") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 100 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << false;
+
+ *t.newData("ok000000002617") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 100 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << false;
+
+ *t.newData("ok000000002620") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 100 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << false;
+
+ *t.newData("ok000000002621") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 100 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << false;
+
+ *t.newData("ok000000002622") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 100 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << false;
+
+
+ *t.newData("ok000000002623") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 200 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << false;
+
+ *t.newData("ok000000002624") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 200 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << false;
+
+ *t.newData("ok000000002625") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 200 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << false;
+
+ *t.newData("ok000000002626") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 200 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << false;
+
+ *t.newData("ok000000002627") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 200 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << false;
+
+
+ *t.newData("ok000000002630") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 500 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << false;
+
+ *t.newData("ok000000002631") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 500 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << false;
+
+ *t.newData("ok000000002632") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 500 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << false;
+
+ *t.newData("ok000000002633") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 500 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << false;
+
+ *t.newData("ok000000002634") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 500 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << false;
+
+
+ *t.newData("ok000000002635") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 0 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << false;
+
+ *t.newData("ok000000002636") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 0 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << false;
+
+ *t.newData("ok000000002637") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 0 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << false;
+
+ *t.newData("ok000000002640") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 0 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << false;
+
+ *t.newData("ok000000002641") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 0 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << false;
+
+
+ *t.newData("ok000000002642") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 50 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << false;
+
+ *t.newData("ok000000002643") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 50 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << false;
+
+ *t.newData("ok000000002644") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 50 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << false;
+
+ *t.newData("ok000000002645") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 50 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << false;
+
+ *t.newData("ok000000002646") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 50 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << false;
+
+
+ *t.newData("ok000000002647") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 100 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << false;
+
+ *t.newData("ok000000002650") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 100 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << false;
+
+ *t.newData("ok000000002651") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << false;
+
+ *t.newData("ok000000002652") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 100 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << false;
+
+ *t.newData("ok000000002653") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 100 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << false;
+
+
+ *t.newData("ok000000002654") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 200 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << false;
+
+ *t.newData("ok000000002655") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 200 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << false;
+
+ *t.newData("ok000000002656") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 200 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << false;
+
+ *t.newData("ok000000002657") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 200 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << false;
+
+ *t.newData("ok000000002660") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 200 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << false;
+
+
+ *t.newData("ok000000002661") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 500 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << false;
+
+ *t.newData("ok000000002662") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 500 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << false;
+
+ *t.newData("ok000000002663") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 500 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << false;
+
+ *t.newData("ok000000002664") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 500 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << false;
+
+ *t.newData("ok000000002665") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 500 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << false;
+
+
+ *t.newData("ok000000002666") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 0 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << false;
+
+ *t.newData("ok000000002667") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 0 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << false;
+
+ *t.newData("ok000000002670") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 0 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << false;
+
+ *t.newData("ok000000002671") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 0 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << false;
+
+ *t.newData("ok000000002672") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 0 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << false;
+
+
+ *t.newData("ok000000002673") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 50 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << false;
+
+ *t.newData("ok000000002674") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 50 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << false;
+
+ *t.newData("ok000000002675") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 50 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << false;
+
+ *t.newData("ok000000002676") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 50 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << false;
+
+ *t.newData("ok000000002677") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 50 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << false;
+
+
+ *t.newData("ok000000002700") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 100 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << false;
+
+ *t.newData("ok000000002701") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 100 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << false;
+
+ *t.newData("ok000000002702") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 100 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << false;
+
+ *t.newData("ok000000002703") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 100 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << false;
+
+ *t.newData("ok000000002704") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 100 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << false;
+
+
+ *t.newData("ok000000002705") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 200 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << false;
+
+ *t.newData("ok000000002706") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 200 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << false;
+
+ *t.newData("ok000000002707") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 200 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << false;
+
+ *t.newData("ok000000002710") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 200 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << false;
+
+ *t.newData("ok000000002711") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 200 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << false;
+
+
+ *t.newData("ok000000002712") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 500 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << false;
+
+ *t.newData("ok000000002713") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 500 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << false;
+
+ *t.newData("ok000000002714") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 500 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << false;
+
+ *t.newData("ok000000002715") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 500 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << false;
+
+ *t.newData("ok000000002716") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 500 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << false;
+
+
+ *t.newData("ok000000002717") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 0 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << false;
+
+ *t.newData("ok000000002720") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 0 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << false;
+
+ *t.newData("ok000000002721") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 0 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << false;
+
+ *t.newData("ok000000002722") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 0 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << false;
+
+ *t.newData("ok000000002723") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 0 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << false;
+
+
+ *t.newData("ok000000002724") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 50 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << false;
+
+ *t.newData("ok000000002725") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 50 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << false;
+
+ *t.newData("ok000000002726") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 50 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << false;
+
+ *t.newData("ok000000002727") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 50 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << false;
+
+ *t.newData("ok000000002730") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 50 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << false;
+
+
+ *t.newData("ok000000002731") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 100 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << false;
+
+ *t.newData("ok000000002732") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 100 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << false;
+
+ *t.newData("ok000000002733") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 100 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << false;
+
+ *t.newData("ok000000002734") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 100 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << false;
+
+ *t.newData("ok000000002735") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 100 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << false;
+
+
+ *t.newData("ok000000002737") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 200 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << false;
+
+ *t.newData("ok000000002740") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 200 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << false;
+
+ *t.newData("ok000000002741") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 200 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << false;
+
+ *t.newData("ok000000002742") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 200 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << false;
+
+ *t.newData("ok000000002743") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 200 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << false;
+
+
+ *t.newData("ok000000002744") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 500 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << false;
+
+ *t.newData("ok000000002745") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 500 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << false;
+
+ *t.newData("ok000000002746") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 500 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << false;
+
+ *t.newData("ok000000002747") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 500 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << false;
+
+ *t.newData("ok000000002750") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 500 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << true << false << false)
+ << false;
+
+ *t.newData("ok000000002751") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 0 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << false;
+
+ *t.newData("ok000000002752") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 0 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << false;
+
+ *t.newData("ok000000002753") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 0 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << false;
+
+ *t.newData("ok000000002754") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 0 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << false;
+
+ *t.newData("ok000000002755") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 0 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << false;
+
+
+ *t.newData("ok000000002756") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 50 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << false;
+
+ *t.newData("ok000000002757") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 50 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << false;
+
+ *t.newData("ok000000002760") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 50 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << false;
+
+ *t.newData("ok000000002761") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 50 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << false;
+
+ *t.newData("ok000000002762") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 50 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << false;
+
+
+ *t.newData("ok000000001773") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 504 << 100 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << false;
+
+ *t.newData("ok000000002764") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 100 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << false;
+
+ *t.newData("ok000000002765") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 100 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << false;
+
+ *t.newData("ok000000002766") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 100 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << false;
+
+ *t.newData("ok000000002767") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 100 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << false;
+
+
+ *t.newData("ok000000002000") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 504 << 200 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << false;
+
+ *t.newData("ok000000002771") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 200 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << false;
+
+ *t.newData("ok000000002772") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 200 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << false;
+
+ *t.newData("ok000000002773") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 200 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << false;
+
+ *t.newData("ok000000002774") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 200 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << false;
+
+
+ *t.newData("ok000000002005") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 504 << 500 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << false;
+
+ *t.newData("ok000000002776") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 500 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << false;
+
+ *t.newData("ok000000002777") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 500 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << false;
+
+ *t.newData("ok000000003000") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 500 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << false;
+
+ *t.newData("ok000000003001") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 500 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << false;
+
+
+ *t.newData("ok000000002012") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 554 << 0 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << false;
+
+ *t.newData("ok000000003003") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 0 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << false;
+
+ *t.newData("ok000000003004") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 0 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << false;
+
+ *t.newData("ok000000003005") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 0 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << false;
+
+ *t.newData("ok000000003006") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 0 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << false;
+
+
+ *t.newData("ok000000002017") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 554 << 50 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << false;
+
+ *t.newData("ok000000003010") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 50 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << false;
+
+ *t.newData("ok000000003011") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 50 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << false;
+
+ *t.newData("ok000000003012") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 50 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << false;
+
+ *t.newData("ok000000003013") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 50 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << false;
+
+
+ *t.newData("ok000000002024") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 554 << 100 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << false;
+
+ *t.newData("ok000000003015") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 100 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << false;
+
+ *t.newData("ok000000003016") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 100 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << false;
+
+ *t.newData("ok000000003017") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 100 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << false;
+
+ *t.newData("ok000000003020") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 100 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << false;
+
+
+ *t.newData("ok000000002031") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 554 << 200 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << false;
+
+ *t.newData("ok000000003022") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 200 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << false;
+
+ *t.newData("ok000000003023") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 200 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << false;
+
+ *t.newData("ok000000003024") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 200 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << false;
+
+ *t.newData("ok000000003025") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 200 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << false;
+
+
+ *t.newData("ok000000002036") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 554 << 500 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << false;
+
+ *t.newData("ok000000003027") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 500 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << false;
+
+ *t.newData("ok000000003030") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 500 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << false;
+
+ *t.newData("ok000000003031") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 500 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << false;
+
+ *t.newData("ok000000003032") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 500 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << false;
+
+
+ *t.newData("ok000000002043") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 604 << 0 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << false;
+
+ *t.newData("ok000000003034") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 0 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << false;
+
+ *t.newData("ok000000003035") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 0 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << false;
+
+ *t.newData("ok000000003036") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 0 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << false;
+
+ *t.newData("ok000000003037") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 0 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << false;
+
+
+ *t.newData("ok000000002050") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 604 << 50 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << false;
+
+ *t.newData("ok000000003041") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 50 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << false;
+
+ *t.newData("ok000000003042") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 50 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << false;
+
+ *t.newData("ok000000003043") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 50 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << false;
+
+ *t.newData("ok000000003044") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 50 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << false;
+
+
+ *t.newData("ok000000002055") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 604 << 100 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << false;
+
+ *t.newData("ok000000003046") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 100 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << false;
+
+ *t.newData("ok000000003047") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << false;
+
+ *t.newData("ok000000003050") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 100 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << false;
+
+ *t.newData("ok000000003051") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 100 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << false;
+
+
+ *t.newData("ok000000002062") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 604 << 200 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << false;
+
+ *t.newData("ok000000003053") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 200 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << false;
+
+ *t.newData("ok000000003054") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 200 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << false;
+
+ *t.newData("ok000000003055") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 200 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << false;
+
+ *t.newData("ok000000003056") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 200 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << false;
+
+
+ *t.newData("ok000000002067") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 604 << 500 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << false;
+
+ *t.newData("ok000000003060") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 500 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << false;
+
+ *t.newData("ok000000003061") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 500 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << false;
+
+ *t.newData("ok000000003062") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 500 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << false;
+
+ *t.newData("ok000000003063") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 500 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << false;
+
+
+ *t.newData("ok000000002074") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 704 << 0 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << false;
+
+ *t.newData("ok000000003065") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 0 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << false;
+
+ *t.newData("ok000000003066") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 0 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << false;
+
+ *t.newData("ok000000003067") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 0 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << false;
+
+ *t.newData("ok000000003070") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 0 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << false;
+
+
+ *t.newData("ok000000002101") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 704 << 50 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << false;
+
+ *t.newData("ok000000003072") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 50 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << false;
+
+ *t.newData("ok000000003073") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 50 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << false;
+
+ *t.newData("ok000000003074") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 50 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << false;
+
+ *t.newData("ok000000003075") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 50 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << false;
+
+
+ *t.newData("ok000000002106") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 704 << 100 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << false;
+
+ *t.newData("ok000000003077") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 100 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << false;
+
+ *t.newData("ok000000003100") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 100 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << false;
+
+ *t.newData("ok000000003101") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 100 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << false;
+
+ *t.newData("ok000000003102") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 100 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << false;
+
+
+ *t.newData("ok000000002113") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 704 << 200 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << false;
+
+ *t.newData("ok000000003104") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 200 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << false;
+
+ *t.newData("ok000000003105") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 200 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << false;
+
+ *t.newData("ok000000003106") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 200 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << false;
+
+ *t.newData("ok000000003107") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 200 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << false;
+
+
+ *t.newData("ok000000002120") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 704 << 500 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << false;
+
+ *t.newData("ok000000003111") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 500 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << false;
+
+ *t.newData("ok000000003112") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 500 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << false;
+
+ *t.newData("ok000000003113") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 500 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << false;
+
+ *t.newData("ok000000003114") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 500 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << false;
+
+
+ *t.newData("ok000000002125") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 1004 << 0 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << false;
+
+ *t.newData("ok000000003116") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 0 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << false;
+
+ *t.newData("ok000000003117") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 0 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << false;
+
+ *t.newData("ok000000003120") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 0 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << false;
+
+ *t.newData("ok000000003121") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 0 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << false;
+
+
+ *t.newData("ok000000002132") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 1004 << 50 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << false;
+
+ *t.newData("ok000000003123") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 50 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << false;
+
+ *t.newData("ok000000003124") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 50 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << false;
+
+ *t.newData("ok000000003125") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 50 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << false;
+
+ *t.newData("ok000000003126") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 50 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << false;
+
+
+ *t.newData("ok000000002137") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 1004 << 100 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << false;
+
+ *t.newData("ok000000003130") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 100 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << false;
+
+ *t.newData("ok000000003131") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 100 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << false;
+
+ *t.newData("ok000000003132") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 100 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << false;
+
+ *t.newData("ok000000003133") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 100 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << false;
+
+
+ *t.newData("ok000000002145") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 1004 << 200 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << false;
+
+ *t.newData("ok000000003136") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 200 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << false;
+
+ *t.newData("ok000000003137") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 200 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << false;
+
+ *t.newData("ok000000003140") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 200 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << false;
+
+ *t.newData("ok000000003141") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 200 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << false;
+
+
+ *t.newData("ok000000002152") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 1004 << 500 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << false;
+
+ *t.newData("ok000000003143") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 500 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << false;
+
+ *t.newData("ok000000003144") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 500 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << false;
+
+ *t.newData("ok000000003145") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 500 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << false;
+
+ *t.newData("ok000000003146") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 500 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << true)
+ << false;
+
+ *t.newData("ok000000003147") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 0 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << false;
+
+ *t.newData("ok000000003150") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 0 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << false;
+
+ *t.newData("ok000000003151") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 0 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << false;
+
+ *t.newData("ok000000003152") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 0 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << false;
+
+ *t.newData("ok000000003153") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 0 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << false;
+
+
+ *t.newData("ok000000003154") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 50 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << false;
+
+ *t.newData("ok000000003155") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 50 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << false;
+
+ *t.newData("ok000000003156") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 50 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << false;
+
+ *t.newData("ok000000003157") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 50 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << false;
+
+ *t.newData("ok000000003160") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 50 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << false;
+
+
+ *t.newData("ok000000001773") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 630 << 100 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << false;
+
+ *t.newData("ok000000003162") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 100 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << false;
+
+ *t.newData("ok000000003163") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 100 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << false;
+
+ *t.newData("ok000000003164") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 100 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << false;
+
+ *t.newData("ok000000003165") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 100 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << false;
+
+
+ *t.newData("ok000000002000") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 630 << 200 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << false;
+
+ *t.newData("ok000000003167") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 200 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << false;
+
+ *t.newData("ok000000003170") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 200 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << false;
+
+ *t.newData("ok000000003171") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 200 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << false;
+
+ *t.newData("ok000000003172") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 200 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << false;
+
+
+ *t.newData("ok000000002005") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 630 << 500 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << false;
+
+ *t.newData("ok000000003174") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 500 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << false;
+
+ *t.newData("ok000000003175") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 500 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << false;
+
+ *t.newData("ok000000003176") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 500 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << false;
+
+ *t.newData("ok000000003177") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 500 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << false;
+
+
+ *t.newData("ok000000002012") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 680 << 0 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << false;
+
+ *t.newData("ok000000003201") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 0 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << false;
+
+ *t.newData("ok000000003202") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 0 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << false;
+
+ *t.newData("ok000000003203") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 0 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << false;
+
+ *t.newData("ok000000003204") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 0 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << false;
+
+
+ *t.newData("ok000000002017") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 680 << 50 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << false;
+
+ *t.newData("ok000000003206") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 50 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << false;
+
+ *t.newData("ok000000003207") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 50 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << false;
+
+ *t.newData("ok000000003210") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 50 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << false;
+
+ *t.newData("ok000000003211") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 50 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << false;
+
+
+ *t.newData("ok000000002024") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 680 << 100 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << false;
+
+ *t.newData("ok000000003213") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 100 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << false;
+
+ *t.newData("ok000000003214") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 100 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << false;
+
+ *t.newData("ok000000003215") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 100 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << false;
+
+ *t.newData("ok000000003216") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 100 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << false;
+
+
+ *t.newData("ok000000002031") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 680 << 200 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << false;
+
+ *t.newData("ok000000003220") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 200 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << false;
+
+ *t.newData("ok000000003221") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 200 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << false;
+
+ *t.newData("ok000000003222") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 200 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << false;
+
+ *t.newData("ok000000003223") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 200 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << false;
+
+
+ *t.newData("ok000000002036") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 680 << 500 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << false;
+
+ *t.newData("ok000000003225") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 500 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << false;
+
+ *t.newData("ok000000003226") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 500 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << false;
+
+ *t.newData("ok000000003227") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 500 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << false;
+
+ *t.newData("ok000000003230") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 500 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << false;
+
+
+ *t.newData("ok000000002043") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 730 << 0 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << false;
+
+ *t.newData("ok000000003232") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 0 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << false;
+
+ *t.newData("ok000000003233") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 0 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << false;
+
+ *t.newData("ok000000003234") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 0 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << false;
+
+ *t.newData("ok000000003235") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 0 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << false;
+
+
+ *t.newData("ok000000002050") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 730 << 50 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << false;
+
+ *t.newData("ok000000003237") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 50 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << false;
+
+ *t.newData("ok000000003240") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 50 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << false;
+
+ *t.newData("ok000000003241") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 50 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << false;
+
+ *t.newData("ok000000003242") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 50 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << false;
+
+
+ *t.newData("ok000000002055") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 730 << 100 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << false;
+
+ *t.newData("ok000000003244") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 100 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << false;
+
+ *t.newData("ok000000003245") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << false;
+
+ *t.newData("ok000000003246") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 100 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << false;
+
+ *t.newData("ok000000003247") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 100 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << false;
+
+
+ *t.newData("ok000000002062") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 730 << 200 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << false;
+
+ *t.newData("ok000000003251") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 200 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << false;
+
+ *t.newData("ok000000003252") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 200 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << false;
+
+ *t.newData("ok000000003253") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 200 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << false;
+
+ *t.newData("ok000000003254") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 200 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << false;
+
+
+ *t.newData("ok000000002067") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 730 << 500 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << false;
+
+ *t.newData("ok000000003256") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 500 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << false;
+
+ *t.newData("ok000000003257") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 500 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << false;
+
+ *t.newData("ok000000003260") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 500 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << false;
+
+ *t.newData("ok000000003261") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 500 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << false;
+
+
+ *t.newData("ok000000002074") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 830 << 0 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << false;
+
+ *t.newData("ok000000003263") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 0 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << false;
+
+ *t.newData("ok000000003264") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 0 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << false;
+
+ *t.newData("ok000000003265") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 0 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << false;
+
+ *t.newData("ok000000003266") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 0 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << false;
+
+
+ *t.newData("ok000000002101") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 830 << 50 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << false;
+
+ *t.newData("ok000000003270") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 50 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << false;
+
+ *t.newData("ok000000003271") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 50 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << false;
+
+ *t.newData("ok000000003272") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 50 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << false;
+
+ *t.newData("ok000000003273") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 50 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << false;
+
+
+ *t.newData("ok000000002106") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 830 << 100 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << false;
+
+ *t.newData("ok000000003275") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 100 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << false;
+
+ *t.newData("ok000000003276") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 100 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << false;
+
+ *t.newData("ok000000003277") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 100 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << false;
+
+ *t.newData("ok000000003300") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 100 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << false;
+
+
+ *t.newData("ok000000002113") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 830 << 200 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << false;
+
+ *t.newData("ok000000003302") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 200 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << false;
+
+ *t.newData("ok000000003303") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 200 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << false;
+
+ *t.newData("ok000000003304") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 200 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << false;
+
+ *t.newData("ok000000003305") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 200 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << false;
+
+
+ *t.newData("ok000000002120") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 830 << 500 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << false;
+
+ *t.newData("ok000000003307") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 500 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << false;
+
+ *t.newData("ok000000003310") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 500 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << false;
+
+ *t.newData("ok000000003311") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 500 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << false;
+
+ *t.newData("ok000000003312") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 500 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << false;
+
+
+ *t.newData("ok000000002125") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 1130 << 0 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << false;
+
+ *t.newData("ok000000003314") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 0 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << false;
+
+ *t.newData("ok000000003315") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 0 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << false;
+
+ *t.newData("ok000000003316") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 0 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << false;
+
+ *t.newData("ok000000003317") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 0 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << false;
+
+
+ *t.newData("ok000000002132") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 1130 << 50 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << false;
+
+ *t.newData("ok000000003321") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 50 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << false;
+
+ *t.newData("ok000000003322") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 50 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << false;
+
+ *t.newData("ok000000003323") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 50 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << false;
+
+ *t.newData("ok000000003324") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 50 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << false;
+
+
+ *t.newData("ok000000002137") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 1130 << 100 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << false;
+
+ *t.newData("ok000000003326") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 100 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << false;
+
+ *t.newData("ok000000003327") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 100 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << false;
+
+ *t.newData("ok000000003330") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 100 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << false;
+
+ *t.newData("ok000000003331") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 100 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << false;
+
+
+ *t.newData("ok000000002145") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 1130 << 200 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << false;
+
+ *t.newData("ok000000003334") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 200 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << false;
+
+ *t.newData("ok000000003335") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 200 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << false;
+
+ *t.newData("ok000000003336") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 200 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << false;
+
+ *t.newData("ok000000003337") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 200 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << false;
+
+
+ *t.newData("ok000000002152") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 1130 << 500 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << false;
+
+ *t.newData("ok000000003341") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 500 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << false;
+
+ *t.newData("ok000000003342") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 500 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << false;
+
+ *t.newData("ok000000003343") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 500 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << false;
+
+ *t.newData("ok000000003344") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 500 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << true << false)
+ << false;
+
+ *t.newData("ok000000003345") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 0 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << false;
+
+ *t.newData("ok000000003346") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 0 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << false;
+
+ *t.newData("ok000000003347") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 0 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << false;
+
+ *t.newData("ok000000003350") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 0 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << false;
+
+ *t.newData("ok000000003351") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 0 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << false;
+
+
+ *t.newData("ok000000003352") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 50 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << false;
+
+ *t.newData("ok000000003353") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 50 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << false;
+
+ *t.newData("ok000000003354") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 50 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << false;
+
+ *t.newData("ok000000003355") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 50 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << false;
+
+ *t.newData("ok000000003356") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 50 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << false;
+
+
+ *t.newData("ok000000001773") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 756 << 100 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << false;
+
+ *t.newData("ok000000003360") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 100 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << false;
+
+ *t.newData("ok000000003361") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 100 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << false;
+
+ *t.newData("ok000000003362") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 100 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << false;
+
+ *t.newData("ok000000003363") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 100 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << false;
+
+
+ *t.newData("ok000000002000") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 756 << 200 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << false;
+
+ *t.newData("ok000000003365") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 200 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << false;
+
+ *t.newData("ok000000003366") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 200 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << false;
+
+ *t.newData("ok000000003367") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 200 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << false;
+
+ *t.newData("ok000000003370") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 200 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << false;
+
+
+ *t.newData("ok000000002005") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 756 << 500 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << false;
+
+ *t.newData("ok000000003372") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 500 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << false;
+
+ *t.newData("ok000000003373") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 500 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << false;
+
+ *t.newData("ok000000003374") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 500 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << false;
+
+ *t.newData("ok000000003375") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 500 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << false;
+
+
+ *t.newData("ok000000002012") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 806 << 0 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << false;
+
+ *t.newData("ok000000003377") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 0 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << false;
+
+ *t.newData("ok000000003400") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 0 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << false;
+
+ *t.newData("ok000000003401") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 0 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << false;
+
+ *t.newData("ok000000003402") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 0 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << false;
+
+
+ *t.newData("ok000000002017") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 806 << 50 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << false;
+
+ *t.newData("ok000000003404") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 50 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << false;
+
+ *t.newData("ok000000003405") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 50 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << false;
+
+ *t.newData("ok000000003406") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 50 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << false;
+
+ *t.newData("ok000000003407") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 50 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << false;
+
+
+ *t.newData("ok000000002024") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 806 << 100 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << false;
+
+ *t.newData("ok000000003411") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 100 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << false;
+
+ *t.newData("ok000000003412") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 100 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << false;
+
+ *t.newData("ok000000003413") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 100 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << false;
+
+ *t.newData("ok000000003414") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 100 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << false;
+
+
+ *t.newData("ok000000002031") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 806 << 200 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << false;
+
+ *t.newData("ok000000003416") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 200 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << false;
+
+ *t.newData("ok000000003417") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 200 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << false;
+
+ *t.newData("ok000000003420") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 200 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << false;
+
+ *t.newData("ok000000003421") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 200 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << false;
+
+
+ *t.newData("ok000000002036") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 806 << 500 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << false;
+
+ *t.newData("ok000000003423") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 500 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << false;
+
+ *t.newData("ok000000003424") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 500 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << false;
+
+ *t.newData("ok000000003425") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 500 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << false;
+
+ *t.newData("ok000000003426") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 500 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << false;
+
+
+ *t.newData("ok000000002043") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 856 << 0 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << false;
+
+ *t.newData("ok000000003430") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 0 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << false;
+
+ *t.newData("ok000000003431") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 0 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << false;
+
+ *t.newData("ok000000003432") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 0 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << false;
+
+ *t.newData("ok000000003433") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 0 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << false;
+
+
+ *t.newData("ok000000002050") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 856 << 50 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << false;
+
+ *t.newData("ok000000003435") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 50 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << false;
+
+ *t.newData("ok000000003436") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 50 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << false;
+
+ *t.newData("ok000000003437") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 50 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << false;
+
+ *t.newData("ok000000003440") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 50 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << false;
+
+
+ *t.newData("ok000000002055") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 856 << 100 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << false;
+
+ *t.newData("ok000000003442") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 100 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << false;
+
+ *t.newData("ok000000003443") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << false;
+
+ *t.newData("ok000000003444") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 100 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << false;
+
+ *t.newData("ok000000003445") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 100 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << false;
+
+
+ *t.newData("ok000000002062") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 856 << 200 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << false;
+
+ *t.newData("ok000000003447") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 200 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << false;
+
+ *t.newData("ok000000003450") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 200 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << false;
+
+ *t.newData("ok000000003451") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 200 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << false;
+
+ *t.newData("ok000000003452") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 200 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << false;
+
+
+ *t.newData("ok000000002067") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 856 << 500 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << false;
+
+ *t.newData("ok000000003454") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 500 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << false;
+
+ *t.newData("ok000000003455") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 500 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << false;
+
+ *t.newData("ok000000003456") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 500 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << false;
+
+ *t.newData("ok000000003457") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 500 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << false;
+
+
+ *t.newData("ok000000002074") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 956 << 0 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << false;
+
+ *t.newData("ok000000003461") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 0 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << false;
+
+ *t.newData("ok000000003462") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 0 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << false;
+
+ *t.newData("ok000000003463") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 0 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << false;
+
+ *t.newData("ok000000003464") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 0 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << false;
+
+
+ *t.newData("ok000000002101") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 956 << 50 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << false;
+
+ *t.newData("ok000000003466") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 50 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << false;
+
+ *t.newData("ok000000003467") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 50 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << false;
+
+ *t.newData("ok000000003470") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 50 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << false;
+
+ *t.newData("ok000000003471") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 50 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << false;
+
+
+ *t.newData("ok000000002106") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 956 << 100 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << false;
+
+ *t.newData("ok000000003473") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 100 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << false;
+
+ *t.newData("ok000000003474") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 100 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << false;
+
+ *t.newData("ok000000003475") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 100 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << false;
+
+ *t.newData("ok000000003476") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 100 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << false;
+
+
+ *t.newData("ok000000002113") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 956 << 200 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << false;
+
+ *t.newData("ok000000003500") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 200 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << false;
+
+ *t.newData("ok000000003501") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 200 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << false;
+
+ *t.newData("ok000000003502") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 200 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << false;
+
+ *t.newData("ok000000003503") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 200 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << false;
+
+
+ *t.newData("ok000000002120") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 956 << 500 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << false;
+
+ *t.newData("ok000000003505") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 500 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << false;
+
+ *t.newData("ok000000003506") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 500 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << false;
+
+ *t.newData("ok000000003507") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 500 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << false;
+
+ *t.newData("ok000000003510") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 500 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << false;
+
+
+ *t.newData("ok000000002125") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 1256 << 0 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << false;
+
+ *t.newData("ok000000003512") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 0 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << false;
+
+ *t.newData("ok000000003513") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 0 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << false;
+
+ *t.newData("ok000000003514") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 0 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << false;
+
+ *t.newData("ok000000003515") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 0 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << false;
+
+
+ *t.newData("ok000000002132") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 1256 << 50 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << false;
+
+ *t.newData("ok000000003517") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 50 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << false;
+
+ *t.newData("ok000000003520") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 50 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << false;
+
+ *t.newData("ok000000003521") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 50 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << false;
+
+ *t.newData("ok000000003522") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 50 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << false;
+
+
+ *t.newData("ok000000002137") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 1256 << 100 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << false;
+
+ *t.newData("ok000000003524") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 100 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << false;
+
+ *t.newData("ok000000003525") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 100 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << false;
+
+ *t.newData("ok000000003526") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 100 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << false;
+
+ *t.newData("ok000000003527") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 100 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << false;
+
+
+ *t.newData("ok000000002145") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 1256 << 200 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << false;
+
+ *t.newData("ok000000003532") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 200 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << false;
+
+ *t.newData("ok000000003533") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 200 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << false;
+
+ *t.newData("ok000000003534") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 200 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << false;
+
+ *t.newData("ok000000003535") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 200 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << false;
+
+
+ *t.newData("ok000000002152") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 1256 << 500 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << false;
+
+ *t.newData("ok000000003537") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 500 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << false;
+
+ *t.newData("ok000000003540") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 500 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << false;
+
+ *t.newData("ok000000003541") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 500 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << false;
+
+ *t.newData("ok000000003542") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 500 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << true)
+ << false;
+
+
+ *t.newData("ok000000003543") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 0 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << false;
+
+ *t.newData("ok000000003544") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 0 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << false;
+
+ *t.newData("ok000000003545") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 0 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << false;
+
+ *t.newData("ok000000003546") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 0 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << false;
+
+ *t.newData("ok000000003547") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 0 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << false;
+
+
+ *t.newData("ok000000003550") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 50 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << false;
+
+ *t.newData("ok000000003551") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 50 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << false;
+
+ *t.newData("ok000000003552") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 50 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << false;
+
+ *t.newData("ok000000003553") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 50 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << false;
+
+ *t.newData("ok000000003554") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 50 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << false;
+
+
+ *t.newData("ok000000001773") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 882 << 100 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << false;
+
+ *t.newData("ok000000003556") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 100 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << false;
+
+ *t.newData("ok000000003557") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 100 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << false;
+
+ *t.newData("ok000000003560") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 100 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << false;
+
+ *t.newData("ok000000003561") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 100 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << false;
+
+
+ *t.newData("ok000000002000") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 882 << 200 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << false;
+
+ *t.newData("ok000000003563") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 200 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << false;
+
+ *t.newData("ok000000003564") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 200 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << false;
+
+ *t.newData("ok000000003565") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 200 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << false;
+
+ *t.newData("ok000000003566") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 200 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << false;
+
+
+ *t.newData("ok000000002005") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 882 << 500 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << false;
+
+ *t.newData("ok000000003570") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 500 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << false;
+
+ *t.newData("ok000000003571") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 500 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << false;
+
+ *t.newData("ok000000003572") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 500 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << false;
+
+ *t.newData("ok000000003573") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 500 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << false;
+
+
+ *t.newData("ok000000002012") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 932 << 0 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << false;
+
+ *t.newData("ok000000003575") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 0 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << false;
+
+ *t.newData("ok000000003576") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 0 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << false;
+
+ *t.newData("ok000000003577") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 0 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << false;
+
+ *t.newData("ok000000003600") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 0 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << false;
+
+
+ *t.newData("ok000000002017") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 932 << 50 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << false;
+
+ *t.newData("ok000000003602") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 50 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << false;
+
+ *t.newData("ok000000003603") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 50 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << false;
+
+ *t.newData("ok000000003604") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 50 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << false;
+
+ *t.newData("ok000000003605") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 50 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << false;
+
+
+ *t.newData("ok000000002024") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 932 << 100 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << false;
+
+ *t.newData("ok000000003607") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 100 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << false;
+
+ *t.newData("ok000000003610") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 100 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << false;
+
+ *t.newData("ok000000003611") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 100 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << false;
+
+ *t.newData("ok000000003612") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 100 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << false;
+
+
+ *t.newData("ok000000002031") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 932 << 200 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << false;
+
+ *t.newData("ok000000003614") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 200 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << false;
+
+ *t.newData("ok000000003615") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 200 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << false;
+
+ *t.newData("ok000000003616") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 200 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << false;
+
+ *t.newData("ok000000003617") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 200 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << false;
+
+
+ *t.newData("ok000000002036") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 932 << 500 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << false;
+
+ *t.newData("ok000000003621") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 500 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << false;
+
+ *t.newData("ok000000003622") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 500 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << false;
+
+ *t.newData("ok000000003623") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 500 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << false;
+
+ *t.newData("ok000000003624") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 50 << 500 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << false;
+
+
+ *t.newData("ok000000002043") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 982 << 0 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << false;
+
+ *t.newData("ok000000003626") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 0 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << false;
+
+ *t.newData("ok000000003627") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 0 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << false;
+
+ *t.newData("ok000000003630") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 0 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << false;
+
+ *t.newData("ok000000003631") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 0 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << false;
+
+
+ *t.newData("ok000000002050") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 982 << 50 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << false;
+
+ *t.newData("ok000000003633") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 50 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << false;
+
+ *t.newData("ok000000003634") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 50 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << false;
+
+ *t.newData("ok000000003635") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 50 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << false;
+
+ *t.newData("ok000000003636") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 50 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << false;
+
+
+ *t.newData("ok000000002055") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 982 << 100 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << false;
+
+ *t.newData("ok000000003640") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 100 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << false;
+
+ *t.newData("ok000000003641") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 100 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << false;
+
+ *t.newData("ok000000003642") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 100 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << false;
+
+ *t.newData("ok000000003643") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 100 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << false;
+
+
+ *t.newData("ok000000002062") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 982 << 200 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << false;
+
+ *t.newData("ok000000003645") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 200 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << false;
+
+ *t.newData("ok000000003646") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 200 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << false;
+
+ *t.newData("ok000000003647") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 200 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << false;
+
+ *t.newData("ok000000003650") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 200 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << false;
+
+
+ *t.newData("ok000000002067") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 982 << 500 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << false;
+
+ *t.newData("ok000000003652") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 500 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << false;
+
+ *t.newData("ok000000003653") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 500 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << false;
+
+ *t.newData("ok000000003654") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 500 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << false;
+
+ *t.newData("ok000000003655") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 100 << 500 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << false;
+
+
+ *t.newData("ok000000002074") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 1082 << 0 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << false;
+
+ *t.newData("ok000000003657") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 0 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << false;
+
+ *t.newData("ok000000003660") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 0 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << false;
+
+ *t.newData("ok000000003661") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 0 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << false;
+
+ *t.newData("ok000000003662") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 0 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << false;
+
+
+ *t.newData("ok000000002101") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 1082 << 50 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << false;
+
+ *t.newData("ok000000003664") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 50 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << false;
+
+ *t.newData("ok000000003665") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 50 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << false;
+
+ *t.newData("ok000000003666") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 50 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << false;
+
+ *t.newData("ok000000003667") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 50 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << false;
+
+
+ *t.newData("ok000000002106") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 1082 << 100 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << false;
+
+ *t.newData("ok000000003671") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 100 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << false;
+
+ *t.newData("ok000000003672") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 100 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << false;
+
+ *t.newData("ok000000003673") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 100 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << false;
+
+ *t.newData("ok000000003674") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 100 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << false;
+
+
+ *t.newData("ok000000002113") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 1082 << 200 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << false;
+
+ *t.newData("ok000000003676") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 200 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << false;
+
+ *t.newData("ok000000003677") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 200 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << false;
+
+ *t.newData("ok000000003700") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 200 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << false;
+
+ *t.newData("ok000000003701") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 200 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << false;
+
+
+ *t.newData("ok000000002120") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 1082 << 500 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << false;
+
+ *t.newData("ok000000003703") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 500 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << false;
+
+ *t.newData("ok000000003704") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 500 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << false;
+
+ *t.newData("ok000000003705") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 500 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << false;
+
+ *t.newData("ok000000003706") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 200 << 500 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << false;
+
+
+ *t.newData("ok000000002125") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 1382 << 0 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << false;
+
+ *t.newData("ok000000003710") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 0 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << false;
+
+ *t.newData("ok000000003711") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 0 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << false;
+
+ *t.newData("ok000000003712") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 0 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << false;
+
+ *t.newData("ok000000003713") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 0 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << false;
+
+
+ *t.newData("ok000000002132") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 1382 << 50 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << false;
+
+ *t.newData("ok000000003715") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 50 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << false;
+
+ *t.newData("ok000000003716") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 50 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << false;
+
+ *t.newData("ok000000003717") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 50 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << false;
+
+ *t.newData("ok000000003720") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 50 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << false;
+
+
+ *t.newData("ok000000002137") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 1382 << 100 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << false;
+
+ *t.newData("ok000000003722") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 100 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << false;
+
+ *t.newData("ok000000003723") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 100 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << false;
+
+ *t.newData("ok000000003724") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 100 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << false;
+
+ *t.newData("ok000000003725") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 100 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << false;
+
+
+ *t.newData("ok000000002145") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 1382 << 200 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << false;
+
+ *t.newData("ok000000003730") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 200 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << false;
+
+ *t.newData("ok000000003731") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 200 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << false;
+
+ *t.newData("ok000000003732") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 200 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << false;
+
+ *t.newData("ok000000003733") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 200 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << false;
+
+
+ *t.newData("ok000000002152") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 1382 << 500 << 0)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << false;
+
+ *t.newData("ok000000003735") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 500 << 50)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << false;
+
+ *t.newData("ok000000003736") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 500 << 100)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << false;
+
+ *t.newData("ok000000003737") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 500 << 200)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << false;
+
+ *t.newData("ok000000003740") << (IntList() << 100 << 100 << 100)
+ << (IntList() << 500 << 500 << 500)
+ << (IntList() << 0 << 0 << 1000)
+ << (IntList() << false << false << false)
+ << false;
+#endif
diff --git a/tests/auto/widgets/widgets/qsplitter/qsplitter.pro b/tests/auto/widgets/widgets/qsplitter/qsplitter.pro
new file mode 100644
index 0000000000..9942c899ca
--- /dev/null
+++ b/tests/auto/widgets/widgets/qsplitter/qsplitter.pro
@@ -0,0 +1,12 @@
+load(qttest_p4)
+QT += widgets
+SOURCES += tst_qsplitter.cpp
+
+wince* {
+ addFiles.files = extradata.txt setSizes3.dat
+ addFiles.path = .
+ DEPLOYMENT += addFiles
+ DEFINES += SRCDIR=\\\"./\\\"
+} else {
+ DEFINES += SRCDIR=\\\"$$PWD/\\\"
+}
diff --git a/tests/auto/widgets/widgets/qsplitter/setSizes3.dat b/tests/auto/widgets/widgets/qsplitter/setSizes3.dat
new file mode 100644
index 0000000000..5d8a73d6f9
--- /dev/null
+++ b/tests/auto/widgets/widgets/qsplitter/setSizes3.dat
@@ -0,0 +1,2250 @@
+ok000000000001
+100 100 100
+0 0 0
+0 0 0
+1 1 1
+1
+ok000000000002
+100 100 100
+0 0 50
+0 0 600
+1 1 1
+1
+ok000000000003
+100 100 100
+0 0 100
+0 0 600
+1 1 1
+1
+ok000000000004
+100 100 100
+0 0 200
+0 0 600
+1 1 1
+1
+ok000000000005
+100 100 100
+0 0 500
+0 0 600
+1 1 1
+1
+ok000000000006
+100 100 100
+0 50 0
+0 600 0
+1 1 1
+1
+ok000000000007
+100 100 100
+0 50 50
+0 300 300
+1 1 1
+1
+ok000000000010
+100 100 100
+0 50 100
+0 300 300
+1 1 1
+1
+ok000000000011
+100 100 100
+0 50 200
+0 200 400
+1 1 1
+1
+ok000000000012
+100 100 100
+0 50 500
+0 100 500
+1 1 1
+1
+ok000000000013
+100 100 100
+0 100 0
+0 600 0
+1 1 1
+1
+ok000000000014
+100 100 100
+0 100 50
+0 300 300
+1 1 1
+1
+ok000000000015
+100 100 100
+0 100 100
+0 300 300
+1 1 1
+1
+ok000000000016
+100 100 100
+0 100 200
+0 200 400
+1 1 1
+1
+ok000000000017
+100 100 100
+0 100 500
+0 100 500
+1 1 1
+1
+ok000000000020
+100 100 100
+0 200 0
+0 600 0
+1 1 1
+1
+ok000000000021
+100 100 100
+0 200 50
+0 400 200
+1 1 1
+1
+ok000000000022
+100 100 100
+0 200 100
+0 400 200
+1 1 1
+1
+ok000000000023
+100 100 100
+0 200 200
+0 300 300
+1 1 1
+1
+ok000000000024
+100 100 100
+0 200 500
+0 171 429
+1 1 1
+1
+ok000000000025
+100 100 100
+0 500 0
+0 600 0
+1 1 1
+1
+ok000000000026
+100 100 100
+0 500 50
+0 500 100
+1 1 1
+1
+ok000000000027
+100 100 100
+0 500 100
+0 500 100
+1 1 1
+1
+ok000000000030
+100 100 100
+0 500 200
+0 429 171
+1 1 1
+1
+ok000000000031
+100 100 100
+0 500 500
+0 300 300
+1 1 1
+1
+ok000000000032
+100 100 100
+50 0 0
+600 0 0
+1 1 1
+1
+ok000000000033
+100 100 100
+50 0 50
+300 0 300
+1 1 1
+1
+ok000000000034
+100 100 100
+50 0 100
+300 0 300
+1 1 1
+1
+ok000000000035
+100 100 100
+50 0 200
+200 0 400
+1 1 1
+1
+ok000000000036
+100 100 100
+50 0 500
+100 0 500
+1 1 1
+1
+ok000000000037
+100 100 100
+50 50 0
+300 300 0
+1 1 1
+1
+ok000000000040
+100 100 100
+50 50 50
+200 200 200
+1 1 1
+1
+ok000000000041
+100 100 100
+50 50 100
+200 200 200
+1 1 1
+1
+ok000000000042
+100 100 100
+50 50 200
+150 150 300
+1 1 1
+1
+ok000000000043
+100 100 100
+50 50 500
+100 100 400
+1 1 1
+1
+ok000000000044
+100 100 100
+50 100 0
+300 300 0
+1 1 1
+1
+ok000000000045
+100 100 100
+50 100 50
+200 200 200
+1 1 1
+1
+ok000000000046
+100 100 100
+50 100 100
+200 200 200
+1 1 1
+1
+ok000000000047
+100 100 100
+50 100 200
+150 150 300
+1 1 1
+1
+ok000000000050
+100 100 100
+50 100 500
+100 100 400
+1 1 1
+1
+ok000000000051
+100 100 100
+50 200 0
+200 400 0
+1 1 1
+1
+ok000000000052
+100 100 100
+50 200 50
+150 300 150
+1 1 1
+1
+ok000000000053
+100 100 100
+50 200 100
+150 300 150
+1 1 1
+1
+ok000000000054
+100 100 100
+50 200 200
+120 240 240
+1 1 1
+1
+ok000000000055
+100 100 100
+50 200 500
+100 143 357
+1 1 1
+1
+ok000000000056
+100 100 100
+50 500 0
+100 500 0
+1 1 1
+1
+ok000000000057
+100 100 100
+50 500 50
+100 400 100
+1 1 1
+1
+ok000000000060
+100 100 100
+50 500 100
+100 400 100
+1 1 1
+1
+ok000000000061
+100 100 100
+50 500 200
+100 357 143
+1 1 1
+1
+ok000000000062
+100 100 100
+50 500 500
+100 250 250
+1 1 1
+1
+ok000000000063
+100 100 100
+100 0 0
+600 0 0
+1 1 1
+1
+ok000000000064
+100 100 100
+100 0 50
+300 0 300
+1 1 1
+1
+ok000000000065
+100 100 100
+100 0 100
+300 0 300
+1 1 1
+1
+ok000000000066
+100 100 100
+100 0 200
+200 0 400
+1 1 1
+1
+ok000000000067
+100 100 100
+100 0 500
+100 0 500
+1 1 1
+1
+ok000000000070
+100 100 100
+100 50 0
+300 300 0
+1 1 1
+1
+ok000000000071
+100 100 100
+100 50 50
+200 200 200
+1 1 1
+1
+ok000000000072
+100 100 100
+100 50 100
+200 200 200
+1 1 1
+1
+ok000000000073
+100 100 100
+100 50 200
+150 150 300
+1 1 1
+1
+ok000000000074
+100 100 100
+100 50 500
+100 100 400
+1 1 1
+1
+ok000000000075
+100 100 100
+100 100 0
+300 300 0
+1 1 1
+1
+ok000000000076
+100 100 100
+100 100 50
+200 200 200
+1 1 1
+1
+ok000000000077
+100 100 100
+100 100 100
+200 200 200
+1 1 1
+1
+ok000000000100
+100 100 100
+100 100 200
+150 150 300
+1 1 1
+1
+ok000000000101
+100 100 100
+100 100 500
+100 100 400
+1 1 1
+1
+ok000000000102
+100 100 100
+100 200 0
+200 400 0
+1 1 1
+1
+ok000000000103
+100 100 100
+100 200 50
+150 300 150
+1 1 1
+1
+ok000000000104
+100 100 100
+100 200 100
+150 300 150
+1 1 1
+1
+ok000000000105
+100 100 100
+100 200 200
+120 240 240
+1 1 1
+1
+ok000000000106
+100 100 100
+100 200 500
+100 143 357
+1 1 1
+1
+ok000000000107
+100 100 100
+100 500 0
+100 500 0
+1 1 1
+1
+ok000000000110
+100 100 100
+100 500 50
+100 400 100
+1 1 1
+1
+ok000000000111
+100 100 100
+100 500 100
+100 400 100
+1 1 1
+1
+ok000000000112
+100 100 100
+100 500 200
+100 357 143
+1 1 1
+1
+ok000000000113
+100 100 100
+100 500 500
+100 250 250
+1 1 1
+1
+ok000000000114
+100 100 100
+200 0 0
+600 0 0
+1 1 1
+1
+ok000000000115
+100 100 100
+200 0 50
+400 0 200
+1 1 1
+1
+ok000000000116
+100 100 100
+200 0 100
+400 0 200
+1 1 1
+1
+ok000000000117
+100 100 100
+200 0 200
+300 0 300
+1 1 1
+1
+ok000000000120
+100 100 100
+200 0 500
+171 0 429
+1 1 1
+1
+ok000000000121
+100 100 100
+200 50 0
+400 200 0
+1 1 1
+1
+ok000000000122
+100 100 100
+200 50 50
+300 150 150
+1 1 1
+1
+ok000000000123
+100 100 100
+200 50 100
+300 150 150
+1 1 1
+1
+ok000000000124
+100 100 100
+200 50 200
+240 120 240
+1 1 1
+1
+ok000000000125
+100 100 100
+200 50 500
+143 100 357
+1 1 1
+1
+ok000000000126
+100 100 100
+200 100 0
+400 200 0
+1 1 1
+1
+ok000000000127
+100 100 100
+200 100 50
+300 150 150
+1 1 1
+1
+ok000000000130
+100 100 100
+200 100 100
+300 150 150
+1 1 1
+1
+ok000000000131
+100 100 100
+200 100 200
+240 120 240
+1 1 1
+1
+ok000000000132
+100 100 100
+200 100 500
+143 100 357
+1 1 1
+1
+ok000000000133
+100 100 100
+200 200 0
+300 300 0
+1 1 1
+1
+ok000000000134
+100 100 100
+200 200 50
+240 240 120
+1 1 1
+1
+ok000000000135
+100 100 100
+200 200 100
+240 240 120
+1 1 1
+1
+ok000000000136
+100 100 100
+200 200 200
+200 200 200
+1 1 1
+1
+ok000000000137
+100 100 100
+200 200 500
+133 134 333
+1 1 1
+1
+ok000000000140
+100 100 100
+200 500 0
+171 429 0
+1 1 1
+1
+ok000000000141
+100 100 100
+200 500 50
+143 357 100
+1 1 1
+1
+ok000000000142
+100 100 100
+200 500 100
+143 357 100
+1 1 1
+1
+ok000000000143
+100 100 100
+200 500 200
+133 334 133
+1 1 1
+1
+ok000000000144
+100 100 100
+200 500 500
+100 250 250
+1 1 1
+1
+ok000000000145
+100 100 100
+500 0 0
+600 0 0
+1 1 1
+1
+ok000000000146
+100 100 100
+500 0 50
+500 0 100
+1 1 1
+1
+ok000000000147
+100 100 100
+500 0 100
+500 0 100
+1 1 1
+1
+ok000000000150
+100 100 100
+500 0 200
+429 0 171
+1 1 1
+1
+ok000000000151
+100 100 100
+500 0 500
+300 0 300
+1 1 1
+1
+ok000000000152
+100 100 100
+500 50 0
+500 100 0
+1 1 1
+1
+ok000000000153
+100 100 100
+500 50 50
+400 100 100
+1 1 1
+1
+ok000000000154
+100 100 100
+500 50 100
+400 100 100
+1 1 1
+1
+ok000000000155
+100 100 100
+500 50 200
+357 100 143
+1 1 1
+1
+ok000000000156
+100 100 100
+500 50 500
+250 100 250
+1 1 1
+1
+ok000000000157
+100 100 100
+500 100 0
+500 100 0
+1 1 1
+1
+ok000000000160
+100 100 100
+500 100 50
+400 100 100
+1 1 1
+1
+ok000000000161
+100 100 100
+500 100 100
+400 100 100
+1 1 1
+1
+ok000000000162
+100 100 100
+500 100 200
+357 100 143
+1 1 1
+1
+ok000000000163
+100 100 100
+500 100 500
+250 100 250
+1 1 1
+1
+ok000000000165
+100 100 100
+500 200 0
+429 171 0
+1 1 1
+1
+ok000000000166
+100 100 100
+500 200 50
+357 143 100
+1 1 1
+1
+ok000000000167
+100 100 100
+500 200 100
+357 143 100
+1 1 1
+1
+ok000000000170
+100 100 100
+500 200 200
+333 134 133
+1 1 1
+1
+ok000000000171
+100 100 100
+500 200 500
+250 100 250
+1 1 1
+1
+ok000000000172
+100 100 100
+500 500 0
+300 300 0
+1 1 1
+1
+ok000000000173
+100 100 100
+500 500 50
+250 250 100
+1 1 1
+1
+ok000000000174
+100 100 100
+500 500 100
+250 250 100
+1 1 1
+1
+ok000000000175
+100 100 100
+500 500 200
+250 250 100
+1 1 1
+1
+ok000000000176
+100 100 100
+500 500 500
+200 200 200
+1 1 1
+1
+ok000000000177
+100 100 100
+0 0 0
+0 0 600
+1 1 0
+1
+ok000000000200
+100 100 100
+0 0 50
+0 0 600
+1 1 0
+1
+ok000000000201
+100 100 100
+0 0 100
+0 0 600
+1 1 0
+1
+ok000000000202
+100 100 100
+0 0 200
+0 0 600
+1 1 0
+1
+ok000000000203
+100 100 100
+0 0 500
+0 0 600
+1 1 0
+1
+ok000000000204
+100 100 100
+0 50 0
+0 300 300
+1 1 0
+1
+ok000000000205
+100 100 100
+0 50 50
+0 300 300
+1 1 0
+1
+ok000000000206
+100 100 100
+0 50 100
+0 300 300
+1 1 0
+1
+ok000000000207
+100 100 100
+0 50 200
+0 200 400
+1 1 0
+1
+ok000000000210
+100 100 100
+0 50 500
+0 100 500
+1 1 0
+1
+ok000000000211
+100 100 100
+0 100 0
+0 300 300
+1 1 0
+1
+ok000000000212
+100 100 100
+0 100 50
+0 300 300
+1 1 0
+1
+ok000000000213
+100 100 100
+0 100 100
+0 300 300
+1 1 0
+1
+ok000000000214
+100 100 100
+0 100 200
+0 200 400
+1 1 0
+1
+ok000000000215
+100 100 100
+0 100 500
+0 100 500
+1 1 0
+1
+ok000000000216
+100 100 100
+0 200 0
+0 400 200
+1 1 0
+1
+ok000000000217
+100 100 100
+0 200 50
+0 400 200
+1 1 0
+1
+ok000000000220
+100 100 100
+0 200 100
+0 400 200
+1 1 0
+1
+ok000000000221
+100 100 100
+0 200 200
+0 300 300
+1 1 0
+1
+ok000000000222
+100 100 100
+0 200 500
+0 171 429
+1 1 0
+1
+ok000000000223
+100 100 100
+0 500 0
+0 500 100
+1 1 0
+1
+ok000000000224
+100 100 100
+0 500 50
+0 500 100
+1 1 0
+1
+ok000000000225
+100 100 100
+0 500 100
+0 500 100
+1 1 0
+1
+ok000000000226
+100 100 100
+0 500 200
+0 429 171
+1 1 0
+1
+ok000000000227
+100 100 100
+0 500 500
+0 300 300
+1 1 0
+1
+ok000000000230
+100 100 100
+50 0 0
+300 0 300
+1 1 0
+1
+ok000000000231
+100 100 100
+50 0 50
+300 0 300
+1 1 0
+1
+ok000000000232
+100 100 100
+50 0 100
+300 0 300
+1 1 0
+1
+ok000000000233
+100 100 100
+50 0 200
+200 0 400
+1 1 0
+1
+ok000000000234
+100 100 100
+50 0 500
+100 0 500
+1 1 0
+1
+ok000000000235
+100 100 100
+50 50 0
+200 200 200
+1 1 0
+1
+ok000000000236
+100 100 100
+50 50 50
+200 200 200
+1 1 0
+1
+ok000000000237
+100 100 100
+50 50 100
+200 200 200
+1 1 0
+1
+ok000000000240
+100 100 100
+50 50 200
+150 150 300
+1 1 0
+1
+ok000000000241
+100 100 100
+50 50 500
+100 100 400
+1 1 0
+1
+ok000000000242
+100 100 100
+50 100 0
+200 200 200
+1 1 0
+1
+ok000000000243
+100 100 100
+50 100 50
+200 200 200
+1 1 0
+1
+ok000000000244
+100 100 100
+50 100 100
+200 200 200
+1 1 0
+1
+ok000000000245
+100 100 100
+50 100 200
+150 150 300
+1 1 0
+1
+ok000000000246
+100 100 100
+50 100 500
+100 100 400
+1 1 0
+1
+ok000000000247
+100 100 100
+50 200 0
+150 300 150
+1 1 0
+1
+ok000000000250
+100 100 100
+50 200 50
+150 300 150
+1 1 0
+1
+ok000000000251
+100 100 100
+50 200 100
+150 300 150
+1 1 0
+1
+ok000000000252
+100 100 100
+50 200 200
+120 240 240
+1 1 0
+1
+ok000000000253
+100 100 100
+50 200 500
+100 143 357
+1 1 0
+1
+ok000000000254
+100 100 100
+50 500 0
+100 400 100
+1 1 0
+1
+ok000000000255
+100 100 100
+50 500 50
+100 400 100
+1 1 0
+1
+ok000000000256
+100 100 100
+50 500 100
+100 400 100
+1 1 0
+1
+ok000000000257
+100 100 100
+50 500 200
+100 357 143
+1 1 0
+1
+ok000000000260
+100 100 100
+50 500 500
+100 250 250
+1 1 0
+1
+ok000000000261
+100 100 100
+100 0 0
+300 0 300
+1 1 0
+1
+ok000000000262
+100 100 100
+100 0 50
+300 0 300
+1 1 0
+1
+ok000000000263
+100 100 100
+100 0 100
+300 0 300
+1 1 0
+1
+ok000000000264
+100 100 100
+100 0 200
+200 0 400
+1 1 0
+1
+ok000000000265
+100 100 100
+100 0 500
+100 0 500
+1 1 0
+1
+ok000000000266
+100 100 100
+100 50 0
+200 200 200
+1 1 0
+1
+ok000000000267
+100 100 100
+100 50 50
+200 200 200
+1 1 0
+1
+ok000000000270
+100 100 100
+100 50 100
+200 200 200
+1 1 0
+1
+ok000000000271
+100 100 100
+100 50 200
+150 150 300
+1 1 0
+1
+ok000000000272
+100 100 100
+100 50 500
+100 100 400
+1 1 0
+1
+ok000000000273
+100 100 100
+100 100 0
+200 200 200
+1 1 0
+1
+ok000000000274
+100 100 100
+100 100 50
+200 200 200
+1 1 0
+1
+ok000000000275
+100 100 100
+100 100 100
+200 200 200
+1 1 0
+1
+ok000000000276
+100 100 100
+100 100 200
+150 150 300
+1 1 0
+1
+ok000000000277
+100 100 100
+100 100 500
+100 100 400
+1 1 0
+1
+ok000000000300
+100 100 100
+100 200 0
+150 300 150
+1 1 0
+1
+ok000000000301
+100 100 100
+100 200 50
+150 300 150
+1 1 0
+1
+ok000000000302
+100 100 100
+100 200 100
+150 300 150
+1 1 0
+1
+ok000000000303
+100 100 100
+100 200 200
+120 240 240
+1 1 0
+1
+ok000000000304
+100 100 100
+100 200 500
+100 143 357
+1 1 0
+1
+ok000000000305
+100 100 100
+100 500 0
+100 400 100
+1 1 0
+1
+ok000000000306
+100 100 100
+100 500 50
+100 400 100
+1 1 0
+1
+ok000000000307
+100 100 100
+100 500 100
+100 400 100
+1 1 0
+1
+ok000000000310
+100 100 100
+100 500 200
+100 357 143
+1 1 0
+1
+ok000000000311
+100 100 100
+100 500 500
+100 250 250
+1 1 0
+1
+ok000000000312
+100 100 100
+200 0 0
+400 0 200
+1 1 0
+1
+ok000000000313
+100 100 100
+200 0 50
+400 0 200
+1 1 0
+1
+ok000000000314
+100 100 100
+200 0 100
+400 0 200
+1 1 0
+1
+ok000000000315
+100 100 100
+200 0 200
+300 0 300
+1 1 0
+1
+ok000000000316
+100 100 100
+200 0 500
+171 0 429
+1 1 0
+1
+ok000000000317
+100 100 100
+200 50 0
+300 150 150
+1 1 0
+1
+ok000000000320
+100 100 100
+200 50 50
+300 150 150
+1 1 0
+1
+ok000000000321
+100 100 100
+200 50 100
+300 150 150
+1 1 0
+1
+ok000000000322
+100 100 100
+200 50 200
+240 120 240
+1 1 0
+1
+ok000000000323
+100 100 100
+200 50 500
+143 100 357
+1 1 0
+1
+ok000000000324
+100 100 100
+200 100 0
+300 150 150
+1 1 0
+1
+ok000000000325
+100 100 100
+200 100 50
+300 150 150
+1 1 0
+1
+ok000000000326
+100 100 100
+200 100 100
+300 150 150
+1 1 0
+1
+ok000000000327
+100 100 100
+200 100 200
+240 120 240
+1 1 0
+1
+ok000000000330
+100 100 100
+200 100 500
+143 100 357
+1 1 0
+1
+ok000000000331
+100 100 100
+200 200 0
+240 240 120
+1 1 0
+1
+ok000000000332
+100 100 100
+200 200 50
+240 240 120
+1 1 0
+1
+ok000000000333
+100 100 100
+200 200 100
+240 240 120
+1 1 0
+1
+ok000000000334
+100 100 100
+200 200 200
+200 200 200
+1 1 0
+1
+ok000000000335
+100 100 100
+200 200 500
+133 134 333
+1 1 0
+1
+ok000000000336
+100 100 100
+200 500 0
+143 357 100
+1 1 0
+1
+ok000000000337
+100 100 100
+200 500 50
+143 357 100
+1 1 0
+1
+ok000000000340
+100 100 100
+200 500 100
+143 357 100
+1 1 0
+1
+ok000000000341
+100 100 100
+200 500 200
+133 334 133
+1 1 0
+1
+ok000000000342
+100 100 100
+200 500 500
+100 250 250
+1 1 0
+1
+ok000000000343
+100 100 100
+500 0 0
+500 0 100
+1 1 0
+1
+ok000000000344
+100 100 100
+500 0 50
+500 0 100
+1 1 0
+1
+ok000000000345
+100 100 100
+500 0 100
+500 0 100
+1 1 0
+1
+ok000000000346
+100 100 100
+500 0 200
+429 0 171
+1 1 0
+1
+ok000000000347
+100 100 100
+500 0 500
+300 0 300
+1 1 0
+1
+ok000000000350
+100 100 100
+500 50 0
+400 100 100
+1 1 0
+1
+ok000000000351
+100 100 100
+500 50 50
+400 100 100
+1 1 0
+1
+ok000000000352
+100 100 100
+500 50 100
+400 100 100
+1 1 0
+1
+ok000000000353
+100 100 100
+500 50 200
+357 100 143
+1 1 0
+1
+ok000000000354
+100 100 100
+500 50 500
+250 100 250
+1 1 0
+1
+ok000000000355
+100 100 100
+500 100 0
+400 100 100
+1 1 0
+1
+ok000000000356
+100 100 100
+500 100 50
+400 100 100
+1 1 0
+1
+ok000000000357
+100 100 100
+500 100 100
+400 100 100
+1 1 0
+1
+ok000000000360
+100 100 100
+500 100 200
+357 100 143
+1 1 0
+1
+ok000000000361
+100 100 100
+500 100 500
+250 100 250
+1 1 0
+1
+ok000000000363
+100 100 100
+500 200 0
+357 143 100
+1 1 0
+1
+ok000000000364
+100 100 100
+500 200 50
+357 143 100
+1 1 0
+1
+ok000000000365
+100 100 100
+500 200 100
+357 143 100
+1 1 0
+1
+ok000000000366
+100 100 100
+500 200 200
+333 134 133
+1 1 0
+1
+ok000000000367
+100 100 100
+500 200 500
+250 100 250
+1 1 0
+1
+ok000000000370
+100 100 100
+500 500 0
+250 250 100
+1 1 0
+1
+ok000000000371
+100 100 100
+500 500 50
+250 250 100
+1 1 0
+1
+ok000000000372
+100 100 100
+500 500 100
+250 250 100
+1 1 0
+1
+ok000000000373
+100 100 100
+500 500 200
+250 250 100
+1 1 0
+1
+ok000000000374
+100 100 100
+500 500 500
+200 200 200
+1 1 0
+1
+ok000000000375
+100 100 100
+0 0 0
+0 600 0
+1 0 1
+1
+ok000000000376
+100 100 100
+0 0 50
+0 300 300
+1 0 1
+1
+ok000000000377
+100 100 100
+0 0 100
+0 300 300
+1 0 1
+1
+ok000000000400
+100 100 100
+0 0 200
+0 200 400
+1 0 1
+1
+ok000000000401
+100 100 100
+0 0 500
+0 100 500
+1 0 1
+1
+ok000000000402
+100 100 100
+0 50 0
+0 600 0
+1 0 1
+1
+ok000000000403
+100 100 100
+0 50 50
+0 300 300
+1 0 1
+1
+ok000000000404
+100 100 100
+0 50 100
+0 300 300
+1 0 1
+1
+ok000000000405
+100 100 100
+0 50 200
+0 200 400
+1 0 1
+1
+ok000000000406
+100 100 100
+0 50 500
+0 100 500
+1 0 1
+1
+ok000000000407
+100 100 100
+0 100 0
+0 600 0
+1 0 1
+1
+ok000000000410
+100 100 100
+0 100 50
+0 300 300
+1 0 1
+1
+ok000000000411
+100 100 100
+0 100 100
+0 300 300
+1 0 1
+1
+ok000000000412
+100 100 100
+0 100 200
+0 200 400
+1 0 1
+1
+ok000000000413
+100 100 100
+0 100 500
+0 100 500
+1 0 1
+1
+ok000000000414
+100 100 100
+0 200 0
+0 600 0
+1 0 1
+1
+ok000000000415
+100 100 100
+0 200 50
+0 400 200
+1 0 1
+1
+ok000000000416
+100 100 100
+0 200 100
+0 400 200
+1 0 1
+1
+ok000000000417
+100 100 100
+0 200 200
+0 300 300
+1 0 1
+1
+ok000000000420
+100 100 100
+0 200 500
+0 171 429
+1 0 1
+1
+ok000000000421
+100 100 100
+0 500 0
+0 600 0
+1 0 1
+1
+ok000000000422
+100 100 100
+0 500 50
+0 500 100
+1 0 1
+1
+ok000000000423
+100 100 100
+0 500 100
+0 500 100
+1 0 1
+1
+ok000000000424
+100 100 100
+0 500 200
+0 429 171
+1 0 1
+1
+ok000000000425
+100 100 100
+0 500 500
+0 300 300
+1 0 1
+1
+ok000000000426
+100 100 100
+50 0 0
+300 300 0
+1 0 1
+1
+ok000000000427
+100 100 100
+50 0 50
+200 200 200
+1 0 1
+1
+ok000000000430
+100 100 100
+50 0 100
+200 200 200
+1 0 1
+1
+ok000000000431
+100 100 100
+50 0 200
+150 150 300
+1 0 1
+1
+ok000000000432
+100 100 100
+50 0 500
+100 100 400
+1 0 1
+1
+ok000000000433
+100 100 100
+50 50 0
+300 300 0
+1 0 1
+1
+ok000000000434
+100 100 100
+50 50 50
+200 200 200
+1 0 1
+1
+ok000000000435
+100 100 100
+50 50 100
+200 200 200
+1 0 1
+1
+ok000000000436
+100 100 100
+50 50 200
+150 150 300
+1 0 1
+1
+ok000000000437
+100 100 100
+50 50 500
+100 100 400
+1 0 1
+1
+ok000000000440
+100 100 100
+50 100 0
+300 300 0
+1 0 1
+1
+ok000000000441
+100 100 100
+50 100 50
+200 200 200
+1 0 1
+1
+ok000000000442
+100 100 100
+50 100 100
+200 200 200
+1 0 1
+1
+ok000000000443
+100 100 100
+50 100 200
+150 150 300
+1 0 1
+1
+ok000000000444
+100 100 100
+50 100 500
+100 100 400
+1 0 1
+1
+ok000000000445
+100 100 100
+50 200 0
+200 400 0
+1 0 1
+1
+ok000000000446
+100 100 100
+50 200 50
+150 300 150
+1 0 1
+1
+ok000000000447
+100 100 100
+50 200 100
+150 300 150
+1 0 1
+1
+ok000000000450
+100 100 100
+50 200 200
+120 240 240
+1 0 1
+1
+ok000000000451
+100 100 100
+50 200 500
+100 143 357
+1 0 1
+1
+ok000000000452
+100 100 100
+50 500 0
+100 500 0
+1 0 1
+1
+ok000000000453
+100 100 100
+50 500 50
+100 400 100
+1 0 1
+1
+ok000000000454
+100 100 100
+50 500 100
+100 400 100
+1 0 1
+1
+ok000000000455
+100 100 100
+50 500 200
+100 357 143
+1 0 1
+1
+ok000000000456
+100 100 100
+50 500 500
+100 250 250
+1 0 1
+1
+ok000000000457
+100 100 100
+100 0 0
+300 300 0
+1 0 1
+1
+ok000000000460
+100 100 100
+100 0 50
+200 200 200
+1 0 1
+1
+ok000000000461
+100 100 100
+100 0 100
+200 200 200
+1 0 1
+1
+ok000000000462
+100 100 100
+100 0 200
+150 150 300
+1 0 1
+1
+ok000000000463
+100 100 100
+100 0 500
+100 100 400
+1 0 1
+1
+ok000000000464
+100 100 100
+100 50 0
+300 300 0
+1 0 1
+1
+ok000000000465
+100 100 100
+100 50 50
+200 200 200
+1 0 1
+1
+ok000000000466
+100 100 100
+100 50 100
+200 200 200
+1 0 1
+1
+ok000000000467
+100 100 100
+100 50 200
+150 150 300
+1 0 1
+1
+ok000000000470
+100 100 100
+100 50 500
+100 100 400
+1 0 1
+1
+ok000000000471
+100 100 100
+100 100 0
+300 300 0
+1 0 1
+1
+ok000000000472
+100 100 100
+100 100 50
+200 200 200
+1 0 1
+1
+ok000000000473
+100 100 100
+100 100 100
+200 200 200
+1 0 1
+1
+ok000000000474
+100 100 100
+100 100 200
+150 150 300
+1 0 1
+1
+ok000000000475
+100 100 100
+100 100 500
+100 100 400
+1 0 1
+1
+ok000000000476
+100 100 100
+100 200 0
+200 400 0
+1 0 1
+1
+ok000000000477
+100 100 100
+100 200 50
+150 300 150
+1 0 1
+1
+ok000000000500
+100 100 100
+100 200 100
+150 300 150
+1 0 1
+1
+ok000000000501
+100 100 100
+100 200 200
+120 240 240
+1 0 1
+1
+ok000000000502
+100 100 100
+100 200 500
+100 143 357
+1 0 1
+1
+ok000000000503
+100 100 100
+100 500 0
+100 500 0
+1 0 1
+1
+ok000000000504
+100 100 100
+100 500 50
+100 400 100
+1 0 1
+1
+ok000000000505
+100 100 100
+100 500 100
+100 400 100
+1 0 1
+1
+ok000000000506
+100 100 100
+100 500 200
+100 357 143
+1 0 1
+1
+ok000000000507
+100 100 100
+100 500 500
+100 250 250
+1 0 1
+1
+ok000000000510
+100 100 100
+200 0 0
+400 200 0
+1 0 1
+1
+ok000000000511
+100 100 100
+200 0 50
+300 150 150
+1 0 1
+1
+ok000000000512
+100 100 100
+200 0 100
+300 150 150
+1 0 1
+1
+ok000000000513
+100 100 100
+200 0 200
+240 120 240
+1 0 1
+1
+ok000000000514
+100 100 100
+200 0 500
+143 100 357
+1 0 1
+1
+ok000000000515
+100 100 100
+200 50 0
+400 200 0
+1 0 1
+1
+ok000000000516
+100 100 100
+200 50 50
+300 150 150
+1 0 1
+1
+ok000000000517
+100 100 100
+200 50 100
+300 150 150
+1 0 1
+1
+ok000000000520
+100 100 100
+200 50 200
+240 120 240
+1 0 1
+1
+ok000000000521
+100 100 100
+200 50 500
+143 100 357
+1 0 1
+1
+ok000000000522
+100 100 100
+200 100 0
+400 200 0
+1 0 1
+1
+ok000000000523
+100 100 100
+200 100 50
+300 150 150
+1 0 1
+1
+ok000000000524
+100 100 100
+200 100 100
+300 150 150
+1 0 1
+1
+ok000000000525
+100 100 100
+200 100 200
+240 120 240
+1 0 1
+1
+ok000000000526
+100 100 100
+200 100 500
+143 100 357
+1 0 1
+1
+ok000000000527
+100 100 100
+200 200 0
+300 300 0
+1 0 1
+1
+ok000000000530
+100 100 100
+200 200 50
+240 240 120
+1 0 1
+1
+ok000000000531
+100 100 100
+200 200 100
+240 240 120
+1 0 1
+1
+ok000000000532
+100 100 100
+200 200 200
+200 200 200
+1 0 1
+1
+ok000000000533
+100 100 100
+200 200 500
+133 134 333
+1 0 1
+1
+ok000000000534
+100 100 100
+200 500 0
+171 429 0
+1 0 1
+1
+ok000000000535
+100 100 100
+200 500 50
+143 357 100
+1 0 1
+1
+ok000000000536
+100 100 100
+200 500 100
+143 357 100
+1 0 1
+1
+ok000000000537
+100 100 100
+200 500 200
+133 334 133
+1 0 1
+1
+ok000000000540
+100 100 100
+200 500 500
+100 250 250
+1 0 1
+1
+ok000000000541
+100 100 100
+500 0 0
+500 100 0
+1 0 1
+1
+ok000000000542
+100 100 100
+500 0 50
+400 100 100
+1 0 1
+1
+ok000000000543
+100 100 100
+500 0 100
+400 100 100
+1 0 1
+1
+ok000000000544
+100 100 100
+500 0 200
+357 100 143
+1 0 1
+1
+ok000000000545
+100 100 100
+500 0 500
+250 100 250
+1 0 1
+1
+ok000000000546
+100 100 100
+500 50 0
+500 100 0
+1 0 1
+1
+ok000000000547
+100 100 100
+500 50 50
+400 100 100
+1 0 1
+1
+ok000000000550
+100 100 100
+500 50 100
+400 100 100
+1 0 1
+1
+ok000000000551
+100 100 100
+500 50 200
+357 100 143
+1 0 1
+1
+ok000000000552
+100 100 100
+500 50 500
+250 100 250
+1 0 1
+1
+ok000000000553
+100 100 100
+500 100 0
+500 100 0
+1 0 1
+1
+ok000000000554
+100 100 100
+500 100 50
+400 100 100
+1 0 1
+1
+ok000000000555
+100 100 100
+500 100 100
+400 100 100
+1 0 1
+1
+ok000000000556
+100 100 100
+500 100 200
+357 100 143
+1 0 1
+1
+ok000000000557
+100 100 100
+500 100 500
+250 100 250
+1 0 1
+1
+ok000000000561
+100 100 100
+500 200 0
+429 171 0
+1 0 1
+1
+ok000000000562
+100 100 100
+500 200 50
+357 143 100
+1 0 1
+1
+ok000000000563
+100 100 100
+500 200 100
+357 143 100
+1 0 1
+1
+ok000000000564
+100 100 100
+500 200 200
+333 134 133
+1 0 1
+1
+ok000000000565
+100 100 100
+500 200 500
+250 100 250
+1 0 1
+1
+ok000000000566
+100 100 100
+500 500 0
+300 300 0
+1 0 1
+1
+ok000000000567
+100 100 100
+500 500 50
+250 250 100
+1 0 1
+1
+ok000000000570
+100 100 100
+500 500 100
+250 250 100
+1 0 1
+1
+ok000000000571
+100 100 100
+500 500 200
+250 250 100
+1 0 1
+1
+ok000000000572
+100 100 100
+500 500 500
+200 200 200
+1 0 1
+1
diff --git a/tests/auto/widgets/widgets/qsplitter/tst_qsplitter.cpp b/tests/auto/widgets/widgets/qsplitter/tst_qsplitter.cpp
new file mode 100644
index 0000000000..836286e8ae
--- /dev/null
+++ b/tests/auto/widgets/widgets/qsplitter/tst_qsplitter.cpp
@@ -0,0 +1,777 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#include <QtTest/QtTest>
+#include <qapplication.h>
+#include <qsplitter.h>
+#include <qstyle.h>
+#include <qfile.h>
+#include <qtextstream.h>
+#include <qlayout.h>
+#include <qabstractscrollarea.h>
+#include <qgraphicsview.h>
+#include <qmdiarea.h>
+#include <qscrollarea.h>
+#include <qtextedit.h>
+#include <qtreeview.h>
+#include <qlabel.h>
+#include <qdebug.h> // for file error messages
+
+//TESTED_CLASS=
+//TESTED_FILES=
+
+QT_FORWARD_DECLARE_CLASS(QSplitter)
+QT_FORWARD_DECLARE_CLASS(QWidget)
+class tst_QSplitter : public QObject
+{
+ Q_OBJECT
+
+public:
+ tst_QSplitter();
+ virtual ~tst_QSplitter();
+
+public slots:
+ void initTestCase();
+ void cleanupTestCase();
+ void init();
+private slots:
+ void getSetCheck();
+ void setSizes();
+ void setSizes_data();
+ void saveAndRestoreState();
+ void saveAndRestoreState_data();
+ void saveState_data();
+ void addWidget();
+ void insertWidget();
+ void setStretchFactor_data();
+ void setStretchFactor();
+ void testShowHide_data();
+ void testShowHide();
+ void testRemoval();
+ void rubberBandNotInSplitter();
+ void saveAndRestoreStateOfNotYetShownSplitter();
+
+ // task-specific tests below me:
+ void task187373_addAbstractScrollAreas();
+ void task187373_addAbstractScrollAreas_data();
+ void task169702_sizes();
+ void taskQTBUG_4101_ensureOneNonCollapsedWidget_data();
+ void taskQTBUG_4101_ensureOneNonCollapsedWidget();
+
+private:
+ void removeThirdWidget();
+ void addThirdWidget();
+ QSplitter *splitter;
+ QWidget *w1;
+ QWidget *w2;
+ QWidget *w3;
+};
+
+// Testing get/set functions
+void tst_QSplitter::getSetCheck()
+{
+ QSplitter obj1;
+ // bool QSplitter::opaqueResize()
+ // void QSplitter::setOpaqueResize(bool)
+ obj1.setOpaqueResize(false);
+ QCOMPARE(false, obj1.opaqueResize());
+ obj1.setOpaqueResize(true);
+ QCOMPARE(true, obj1.opaqueResize());
+}
+
+tst_QSplitter::tst_QSplitter()
+ : w1(0), w2(0), w3(0)
+{
+}
+
+tst_QSplitter::~tst_QSplitter()
+{
+}
+
+void tst_QSplitter::initTestCase()
+{
+ splitter = new QSplitter(Qt::Horizontal);
+ w1 = new QWidget;
+ w2 = new QWidget;
+ splitter->addWidget(w1);
+ splitter->addWidget(w2);
+}
+
+void tst_QSplitter::init()
+{
+ removeThirdWidget();
+ w1->show();
+ w2->show();
+ w1->setMinimumSize(0, 0);
+ w2->setMinimumSize(0, 0);
+ splitter->setSizes(QList<int>() << 200 << 200);
+ qApp->sendPostedEvents();
+}
+
+void tst_QSplitter::removeThirdWidget()
+{
+ delete w3;
+ w3 = 0;
+ int handleWidth = splitter->style()->pixelMetric(QStyle::PM_SplitterWidth);
+ splitter->setFixedSize(400 + handleWidth, 400);
+}
+
+void tst_QSplitter::addThirdWidget()
+{
+ if (!w3) {
+ w3 = new QWidget;
+ splitter->addWidget(w3);
+ int handleWidth = splitter->style()->pixelMetric(QStyle::PM_SplitterWidth);
+ splitter->setFixedSize(600 + 2 * handleWidth, 400);
+ }
+}
+
+void tst_QSplitter::cleanupTestCase()
+{
+}
+
+
+typedef QList<int> IntList;
+Q_DECLARE_METATYPE(IntList)
+
+void tst_QSplitter::setSizes()
+{
+ QFETCH(IntList, minimumSizes);
+ QFETCH(IntList, splitterSizes);
+ QFETCH(IntList, collapsibleStates);
+ QFETCH(bool, childrenCollapse);
+
+ QCOMPARE(minimumSizes.size(), splitterSizes.size());
+ if (minimumSizes.size() > 2)
+ addThirdWidget();
+ for (int i = 0; i < minimumSizes.size(); ++i) {
+ QWidget *w = splitter->widget(i);
+ w->setMinimumWidth(minimumSizes.at(i));
+ splitter->setCollapsible(splitter->indexOf(w), collapsibleStates.at(i));
+ }
+ splitter->setChildrenCollapsible(childrenCollapse);
+ splitter->setSizes(splitterSizes);
+ QTEST(splitter->sizes(), "expectedSizes");
+}
+
+void tst_QSplitter::setSizes_data()
+{
+ QTest::addColumn<IntList>("minimumSizes");
+ QTest::addColumn<IntList>("splitterSizes");
+ QTest::addColumn<IntList>("expectedSizes");
+ QTest::addColumn<IntList>("collapsibleStates");
+ QTest::addColumn<bool>("childrenCollapse");
+
+ QFile file(SRCDIR "setSizes3.dat");
+ if (!file.open(QIODevice::ReadOnly)) {
+ qDebug() << "Can't open file, reason:" << file.errorString();
+ return;
+ }
+ QTextStream ts(&file);
+ ts.setIntegerBase(10);
+
+ QString dataName;
+ IntList minimumSizes;
+ IntList splitterSizes;
+ IntList expectedSizes;
+ IntList collapsibleStates;
+ int childrenCollapse;
+ while (!ts.atEnd()) {
+ int i1, i2, i3;
+ minimumSizes.clear();
+ splitterSizes.clear();
+ expectedSizes.clear();
+ collapsibleStates.clear();
+ ts >> dataName;
+ ts >> i1 >> i2 >> i3;
+ minimumSizes << i1 << i2 << i3;
+ ts >> i1 >> i2 >> i3;
+ splitterSizes << i1 << i2 << i3;
+ ts >> i1 >> i2 >> i3;
+ expectedSizes << i1 << i2 << i3;
+ ts >> i1 >> i2 >> i3;
+ collapsibleStates << i1 << i2 << i3;
+ ts >> childrenCollapse;
+ QTest::newRow(dataName.toLocal8Bit()) << minimumSizes << splitterSizes << expectedSizes << collapsibleStates << bool(childrenCollapse);
+ ts.skipWhiteSpace();
+ }
+}
+
+void tst_QSplitter::saveAndRestoreState_data()
+{
+ saveState_data();
+}
+
+void tst_QSplitter::saveAndRestoreState()
+{
+ QFETCH(IntList, initialSizes);
+ splitter->setSizes(initialSizes);
+ QApplication::instance()->sendPostedEvents();
+
+ QSplitter *splitter2 = new QSplitter(splitter->orientation() == Qt::Horizontal ?
+ Qt::Vertical : Qt::Horizontal);
+ for (int i = 0; i < splitter->count(); ++i) {
+ splitter2->addWidget(new QWidget());
+ }
+ splitter2->resize(splitter->size());
+ splitter2->setChildrenCollapsible(!splitter->childrenCollapsible());
+ splitter2->setOpaqueResize(!splitter->opaqueResize());
+ splitter2->setHandleWidth(splitter->handleWidth()+3);
+
+ QByteArray ba = splitter->saveState();
+ QVERIFY(splitter2->restoreState(ba));
+
+ QCOMPARE(splitter2->orientation(), splitter->orientation());
+ QCOMPARE(splitter2->handleWidth(), splitter->handleWidth());
+ QCOMPARE(splitter2->opaqueResize(), splitter->opaqueResize());
+ QCOMPARE(splitter2->childrenCollapsible(), splitter->childrenCollapsible());
+
+ QList<int> l1 = splitter->sizes();
+ QList<int> l2 = splitter2->sizes();
+ QCOMPARE(l1.size(), l2.size());
+ for (int i = 0; i < splitter->sizes().size(); ++i) {
+ QCOMPARE(l2.at(i), l1.at(i));
+ }
+
+ // destroy version and magic number
+ for (int i = 0; i < ba.size(); ++i)
+ ba[i] = ~ba.at(i);
+ QVERIFY(!splitter2->restoreState(ba));
+
+ delete splitter2;
+}
+
+void tst_QSplitter::saveAndRestoreStateOfNotYetShownSplitter()
+{
+ QSplitter *spl = new QSplitter;
+ QLabel *l1 = new QLabel;
+ QLabel *l2 = new QLabel;
+ spl->addWidget(l1);
+ spl->addWidget(l2);
+
+ QByteArray ba = spl->saveState();
+ spl->restoreState(ba);
+ spl->show();
+ QTest::qWait(500);
+
+ QCOMPARE(l1->geometry().isValid(), true);
+ QCOMPARE(l2->geometry().isValid(), true);
+
+ delete spl;
+}
+
+void tst_QSplitter::saveState_data()
+{
+ QTest::addColumn<IntList>("initialSizes");
+ QTest::addColumn<bool>("hideWidget1");
+ QTest::addColumn<bool>("hideWidget2");
+ QTest::addColumn<QByteArray>("finalBa");
+
+ QTest::newRow("ok0") << (IntList() << 200 << 200) << bool(false) << bool(false) << QByteArray("[200,200]");
+ QTest::newRow("ok1") << (IntList() << 300 << 100) << bool(false) << bool(false) << QByteArray("[300,100]");
+ QTest::newRow("ok2") << (IntList() << 100 << 300) << bool(false) << bool(false) << QByteArray("[100,300]");
+ QTest::newRow("ok3") << (IntList() << 200 << 200) << bool(false) << bool(true) << QByteArray("[200,H]");
+ QTest::newRow("ok4") << (IntList() << 200 << 200) << bool(true) << bool(false) << QByteArray("[H,200]");
+ QTest::newRow("ok5") << (IntList() << 200 << 200) << bool(false) << bool(false) << QByteArray("[200,200]");
+ QTest::newRow("ok6") << (IntList() << 200 << 200) << bool(false) << bool(false) << QByteArray("[200,200]");
+ QTest::newRow("ok7") << (IntList() << 200 << 200) << bool(false) << bool(false) << QByteArray("[200,200]");
+ QTest::newRow("ok8") << (IntList() << 200 << 200) << bool(true) << bool(true) << QByteArray("[H,H]");
+}
+
+void tst_QSplitter::addWidget()
+{
+ QSplitter split;
+
+ // Simple case
+ QWidget *widget1 = new QWidget;
+ QWidget *widget2 = new QWidget;
+ split.addWidget(widget1);
+ split.addWidget(widget2);
+ QCOMPARE(split.count(), 2);
+ QCOMPARE(split.indexOf(widget1), 0);
+ QCOMPARE(split.indexOf(widget2), 1);
+ QCOMPARE(split.widget(0), widget1);
+ QCOMPARE(split.widget(1), widget2);
+
+
+ // Implicit Add
+ QWidget *widget3 = new QWidget(&split);
+ QCOMPARE(split.count(), 3);
+ QCOMPARE(split.indexOf(widget3), 2);
+ QCOMPARE(split.widget(2), widget3);
+
+ // Try and add it again
+ split.addWidget(widget3);
+ QCOMPARE(split.count(), 3);
+ QCOMPARE(split.indexOf(widget3), 2);
+ QCOMPARE(split.widget(2), widget3);
+
+ // Add a widget that is already in the splitter
+ split.addWidget(widget1);
+ QCOMPARE(split.count(), 3);
+ QCOMPARE(split.indexOf(widget1), 2);
+ QCOMPARE(split.widget(0), widget2);
+ QCOMPARE(split.widget(1), widget3);
+ QCOMPARE(split.widget(2), widget1);
+
+ // Change a widget's parent
+ widget2->setParent(0);
+ QCOMPARE(split.count(), 2);
+ QCOMPARE(split.indexOf(widget2), -1);
+
+
+ // Add the widget in again.
+ split.addWidget(widget2);
+ QCOMPARE(split.count(), 3);
+ QCOMPARE(split.indexOf(widget2), 2);
+ QCOMPARE(split.widget(0), widget3);
+ QCOMPARE(split.widget(1), widget1);
+ QCOMPARE(split.widget(2), widget2);
+
+ // Delete a widget
+ delete widget1;
+ QCOMPARE(split.count(), 2);
+ QCOMPARE(split.indexOf(widget1), -1); // Nasty
+ QCOMPARE(split.widget(0), widget3);
+ QCOMPARE(split.widget(1), widget2);
+
+ delete widget2;
+}
+
+void tst_QSplitter::insertWidget()
+{
+ QSplitter split;
+ QWidget *widget1 = new QWidget;
+ QWidget *widget2 = new QWidget;
+ QWidget *widget3 = new QWidget;
+
+ split.insertWidget(0, widget1);
+ QCOMPARE(split.count(), 1);
+ QCOMPARE(split.indexOf(widget1), 0);
+ QCOMPARE(split.widget(0), widget1);
+
+ split.insertWidget(0, widget2);
+ QCOMPARE(split.count(), 2);
+ QCOMPARE(split.indexOf(widget1), 1);
+ QCOMPARE(split.indexOf(widget2), 0);
+ QCOMPARE(split.widget(0), widget2);
+ QCOMPARE(split.widget(1), widget1);
+
+ split.insertWidget(1, widget3);
+ QCOMPARE(split.count(), 3);
+ QCOMPARE(split.indexOf(widget1), 2);
+ QCOMPARE(split.indexOf(widget2), 0);
+ QCOMPARE(split.indexOf(widget3), 1);
+ QCOMPARE(split.widget(0), widget2);
+ QCOMPARE(split.widget(1), widget3);
+ QCOMPARE(split.widget(2), widget1);
+
+ delete widget3;
+ QCOMPARE(split.count(), 2);
+ QCOMPARE(split.indexOf(widget1), 1);
+ QCOMPARE(split.indexOf(widget2), 0);
+ QCOMPARE(split.widget(0), widget2);
+ QCOMPARE(split.widget(1), widget1);
+
+ widget3 = new QWidget;
+ split.insertWidget(split.count() + 1, widget3);
+ QCOMPARE(split.count(), 3);
+ QCOMPARE(split.indexOf(widget1), 1);
+ QCOMPARE(split.indexOf(widget2), 0);
+ QCOMPARE(split.indexOf(widget3), 2);
+ QCOMPARE(split.widget(0), widget2);
+ QCOMPARE(split.widget(1), widget1);
+ QCOMPARE(split.widget(2), widget3);
+
+
+ // Try it again,
+ split.insertWidget(split.count() + 1, widget3);
+ QCOMPARE(split.count(), 3);
+ QCOMPARE(split.indexOf(widget1), 1);
+ QCOMPARE(split.indexOf(widget2), 0);
+ QCOMPARE(split.indexOf(widget3), 2);
+ QCOMPARE(split.widget(0), widget2);
+ QCOMPARE(split.widget(1), widget1);
+ QCOMPARE(split.widget(2), widget3);
+
+ // Try to move widget2 to a bad place
+ split.insertWidget(-1, widget2);
+ QCOMPARE(split.count(), 3);
+ QCOMPARE(split.indexOf(widget1), 0);
+ QCOMPARE(split.indexOf(widget2), 2);
+ QCOMPARE(split.indexOf(widget3), 1);
+ QCOMPARE(split.widget(0), widget1);
+ QCOMPARE(split.widget(1), widget3);
+ QCOMPARE(split.widget(2), widget2);
+
+ QWidget *widget4 = new QWidget(&split);
+ QCOMPARE(split.count(), 4);
+ QCOMPARE(split.indexOf(widget1), 0);
+ QCOMPARE(split.indexOf(widget2), 2);
+ QCOMPARE(split.indexOf(widget3), 1);
+ QCOMPARE(split.indexOf(widget4), 3);
+ QCOMPARE(split.widget(0), widget1);
+ QCOMPARE(split.widget(1), widget3);
+ QCOMPARE(split.widget(2), widget2);
+ QCOMPARE(split.widget(3), widget4);
+
+ QWidget *widget5 = new QWidget(&split);
+ QCOMPARE(split.count(), 5);
+ QCOMPARE(split.indexOf(widget1), 0);
+ QCOMPARE(split.indexOf(widget2), 2);
+ QCOMPARE(split.indexOf(widget3), 1);
+ QCOMPARE(split.indexOf(widget4), 3);
+ QCOMPARE(split.indexOf(widget5), 4);
+ QCOMPARE(split.widget(0), widget1);
+ QCOMPARE(split.widget(1), widget3);
+ QCOMPARE(split.widget(2), widget2);
+ QCOMPARE(split.widget(3), widget4);
+ QCOMPARE(split.widget(4), widget5);
+
+ split.insertWidget(2, widget4);
+ QCOMPARE(split.count(), 5);
+ QCOMPARE(split.indexOf(widget1), 0);
+ QCOMPARE(split.indexOf(widget2), 3);
+ QCOMPARE(split.indexOf(widget3), 1);
+ QCOMPARE(split.indexOf(widget4), 2);
+ QCOMPARE(split.indexOf(widget5), 4);
+ QCOMPARE(split.widget(0), widget1);
+ QCOMPARE(split.widget(1), widget3);
+ QCOMPARE(split.widget(2), widget4);
+ QCOMPARE(split.widget(3), widget2);
+ QCOMPARE(split.widget(4), widget5);
+
+ split.insertWidget(1, widget5);
+ QCOMPARE(split.count(), 5);
+ QCOMPARE(split.indexOf(widget1), 0);
+ QCOMPARE(split.indexOf(widget2), 4);
+ QCOMPARE(split.indexOf(widget3), 2);
+ QCOMPARE(split.indexOf(widget4), 3);
+ QCOMPARE(split.indexOf(widget5), 1);
+ QCOMPARE(split.widget(0), widget1);
+ QCOMPARE(split.widget(1), widget5);
+ QCOMPARE(split.widget(2), widget3);
+ QCOMPARE(split.widget(3), widget4);
+ QCOMPARE(split.widget(4), widget2);
+}
+
+void tst_QSplitter::setStretchFactor_data()
+{
+ QTest::addColumn<int>("orientation");
+ QTest::addColumn<int>("widgetIndex");
+ QTest::addColumn<int>("stretchFactor");
+ QTest::addColumn<int>("expectedHStretch");
+ QTest::addColumn<int>("expectedVStretch");
+
+ QTest::newRow("ok01") << int(Qt::Horizontal) << 1 << 2 << 2 << 2;
+ QTest::newRow("ok02") << int(Qt::Horizontal) << 2 << 0 << 0 << 0;
+ QTest::newRow("ok03") << int(Qt::Horizontal) << 3 << 1 << 1 << 1;
+ QTest::newRow("ok04") << int(Qt::Horizontal) << 0 << 7 << 7 << 7;
+ QTest::newRow("ok05") << int(Qt::Vertical) << 0 << 0 << 0 << 0;
+ QTest::newRow("ok06") << int(Qt::Vertical) << 1 << 1 << 1 << 1;
+ QTest::newRow("ok07") << int(Qt::Vertical) << 2 << 2 << 2 << 2;
+ QTest::newRow("ok08") << int(Qt::Vertical) << 3 << 5 << 5 << 5;
+ QTest::newRow("ok08") << int(Qt::Vertical) << -1 << 5 << 0 << 0;
+}
+
+void tst_QSplitter::setStretchFactor()
+{
+ QFETCH(int, orientation);
+ Qt::Orientation orient = Qt::Orientation(orientation);
+ QSplitter split(orient);
+ QWidget *w = new QWidget;
+ split.addWidget(w);
+ w = new QWidget;
+ split.addWidget(w);
+ w = new QWidget;
+ split.addWidget(w);
+ w = new QWidget;
+ split.addWidget(w);
+
+ QFETCH(int, widgetIndex);
+ QFETCH(int, stretchFactor);
+ w = split.widget(widgetIndex);
+ QSizePolicy sp;
+ if (w) {
+ QCOMPARE(sp.horizontalStretch(), 0);
+ QCOMPARE(sp.verticalStretch(), 0);
+ }
+ split.setStretchFactor(widgetIndex, stretchFactor);
+ if (w)
+ sp = w->sizePolicy();
+ QTEST(sp.horizontalStretch(), "expectedHStretch");
+ QTEST(sp.verticalStretch(), "expectedVStretch");
+}
+
+void tst_QSplitter::testShowHide_data()
+{
+ QTest::addColumn<bool>("hideWidget1");
+ QTest::addColumn<bool>("hideWidget2");
+ QTest::addColumn<QList<int> >("finalValues");
+ QTest::addColumn<bool>("handleVisible");
+
+ QSplitter *split = new QSplitter(Qt::Horizontal);
+ QTest::newRow("hideNone") << false << false << (QList<int>() << 200 << 200) << true;
+ QTest::newRow("hide2") << false << true << (QList<int>() << 400 + split->handleWidth() << 0) << false;
+ QTest::newRow("hide1") << true << false << (QList<int>() << 0 << 400 + split->handleWidth()) << false;
+ QTest::newRow("hideall") << true << true << (QList<int>() << 0 << 0) << false;
+ delete split;
+}
+
+void tst_QSplitter::testShowHide()
+{
+ QFETCH(bool, hideWidget1);
+ QFETCH(bool, hideWidget2);
+
+ QSplitter *split = new QSplitter(Qt::Horizontal);
+
+ QWidget topLevel;
+ QWidget widget(&topLevel);
+ widget.resize(400 + split->handleWidth(), 200);
+ QVBoxLayout *lay=new QVBoxLayout(&widget);
+ lay->setMargin(0);
+ lay->setSpacing(0);
+ split->addWidget(new QWidget);
+ split->addWidget(new QWidget);
+ split->setSizes(QList<int>() << 200 << 200);
+ lay->addWidget(split);
+ widget.setLayout(lay);
+ topLevel.show();
+
+ QTest::qWait(100);
+
+ widget.hide();
+ split->widget(0)->setHidden(hideWidget1);
+ split->widget(1)->setHidden(hideWidget2);
+ widget.show();
+ QTest::qWait(100);
+
+ QTEST(split->sizes(), "finalValues");
+ QTEST(split->handle(1)->isVisible(), "handleVisible");
+}
+
+void tst_QSplitter::testRemoval()
+{
+
+ // This test relies on the internal structure of QSplitter That is, that
+ // there is a handle before every splitter, but sometimes that handle is
+ // hidden. But definiately when something is removed the front handle
+ // should not be visible.
+
+ QSplitter split;
+ split.addWidget(new QWidget);
+ split.addWidget(new QWidget);
+ split.show();
+ QTest::qWait(100);
+
+ QCOMPARE(split.handle(0)->isVisible(), false);
+ QSplitterHandle *handle = split.handle(1);
+ QCOMPARE(handle->isVisible(), true);
+
+ delete split.widget(0);
+ QSplitterHandle *sameHandle = split.handle(0);
+ QCOMPARE(handle, sameHandle);
+ QCOMPARE(sameHandle->isVisible(), false);
+}
+
+class MyFriendlySplitter : public QSplitter
+{
+public:
+ MyFriendlySplitter(QWidget *parent = 0) : QSplitter(parent) {}
+ void setRubberBand(int pos) { QSplitter::setRubberBand(pos); }
+
+ friend class tst_QSplitter;
+};
+
+void tst_QSplitter::rubberBandNotInSplitter()
+{
+ MyFriendlySplitter split;
+ split.addWidget(new QWidget);
+ split.addWidget(new QWidget);
+ split.setOpaqueResize(false);
+ QCOMPARE(split.count(), 2);
+ split.setRubberBand(2);
+ QCOMPARE(split.count(), 2);
+}
+
+void tst_QSplitter::task187373_addAbstractScrollAreas_data()
+{
+ QTest::addColumn<QString>("className");
+ QTest::addColumn<bool>("addInConstructor");
+ QTest::addColumn<bool>("addOutsideConstructor");
+
+ QStringList classNames;
+ classNames << QLatin1String("QGraphicsView");
+ classNames << QLatin1String("QMdiArea");
+ classNames << QLatin1String("QScrollArea");
+ classNames << QLatin1String("QTextEdit");
+ classNames << QLatin1String("QTreeView");
+
+ foreach (QString className, classNames) {
+ QTest::newRow(qPrintable(QString("%1 1").arg(className))) << className << false << true;
+ QTest::newRow(qPrintable(QString("%1 2").arg(className))) << className << true << false;
+ QTest::newRow(qPrintable(QString("%1 3").arg(className))) << className << true << true;
+ }
+}
+
+static QAbstractScrollArea *task187373_createScrollArea(
+ QSplitter *splitter, const QString &className, bool addInConstructor)
+{
+ if (className == QLatin1String("QGraphicsView"))
+ return new QGraphicsView(addInConstructor ? splitter : 0);
+ if (className == QLatin1String("QMdiArea"))
+ return new QMdiArea(addInConstructor ? splitter : 0);
+ if (className == QLatin1String("QScrollArea"))
+ return new QScrollArea(addInConstructor ? splitter : 0);
+ if (className == QLatin1String("QTextEdit"))
+ return new QTextEdit(addInConstructor ? splitter : 0);
+ if (className == QLatin1String("QTreeView"))
+ return new QTreeView(addInConstructor ? splitter : 0);
+ return 0;
+}
+
+void tst_QSplitter::task187373_addAbstractScrollAreas()
+{
+ QFETCH(QString, className);
+ QFETCH(bool, addInConstructor);
+ QFETCH(bool, addOutsideConstructor);
+ QVERIFY(addInConstructor || addOutsideConstructor);
+
+ QSplitter *splitter = new QSplitter;
+ splitter->show();
+ QVERIFY(splitter->isVisible());
+
+ QAbstractScrollArea *w = task187373_createScrollArea(splitter, className, addInConstructor);
+ QVERIFY(w);
+ if (addOutsideConstructor)
+ splitter->addWidget(w);
+
+ QTRY_VERIFY(w->isVisible());
+ QVERIFY(!w->isHidden());
+ QVERIFY(w->viewport()->isVisible());
+ QVERIFY(!w->viewport()->isHidden());
+}
+
+//! A simple QTextEdit which can switch between two different size states
+class MyTextEdit : public QTextEdit
+{
+ public:
+ MyTextEdit(const QString & text, QWidget* parent = NULL)
+ : QTextEdit(text, parent) , m_iFactor(1)
+ {
+ setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum);
+ }
+ virtual QSize minimumSizeHint () const
+ {
+ return QSize(200, 200) * m_iFactor;
+ }
+ virtual QSize sizeHint() const
+ {
+ return QSize(390, 390) * m_iFactor;
+ }
+ int m_iFactor;
+};
+
+void tst_QSplitter::task169702_sizes()
+{
+ QWidget topLevel;
+ // Create two nested (non-collapsible) splitters
+ QSplitter* outerSplitter = new QSplitter(Qt::Vertical, &topLevel);
+ outerSplitter->setChildrenCollapsible(false);
+ QSplitter* splitter = new QSplitter(Qt::Horizontal, outerSplitter);
+ splitter->setChildrenCollapsible(false);
+
+ // populate the outer splitter
+ outerSplitter->addWidget(new QTextEdit("Foo"));
+ outerSplitter->addWidget(splitter);
+ outerSplitter->setStretchFactor(0, 1);
+ outerSplitter->setStretchFactor(1, 0);
+
+ // populate the inner splitter
+ MyTextEdit* testW = new MyTextEdit("TextEdit with size restriction");
+ splitter->addWidget(testW);
+ splitter->addWidget(new QTextEdit("Bar"));
+
+ outerSplitter->setGeometry(100, 100, 500, 500);
+ topLevel.show();
+
+ QTest::qWait(100);
+ testW->m_iFactor++;
+ testW->updateGeometry();
+ QTest::qWait(500);//100 is too fast for Maemo
+
+ //Make sure the minimimSizeHint is respected
+ QCOMPARE(testW->size().height(), testW->minimumSizeHint().height());
+}
+
+void tst_QSplitter::taskQTBUG_4101_ensureOneNonCollapsedWidget_data()
+{
+ QTest::addColumn<bool>("testingHide");
+
+ QTest::newRow("last non collapsed hidden") << true;
+ QTest::newRow("last non collapsed deleted") << false;
+}
+
+void tst_QSplitter::taskQTBUG_4101_ensureOneNonCollapsedWidget()
+{
+ QFETCH(bool, testingHide);
+
+ MyFriendlySplitter s;
+ QLabel *l;
+ for (int i = 0; i < 5; ++i) {
+ l = new QLabel(QString("Label ") + QChar('A' + i));
+ l->setAlignment(Qt::AlignCenter);
+ s.addWidget(l);
+ s.moveSplitter(0, i); // Collapse all the labels except the last one.
+ }
+
+ s.show();
+ if (testingHide)
+ l->hide();
+ else
+ delete l;
+ QTest::qWait(100);
+ QVERIFY(s.sizes().at(0) > 0);
+}
+
+QTEST_MAIN(tst_QSplitter)
+#include "tst_qsplitter.moc"
diff --git a/tests/auto/widgets/widgets/qstackedwidget/.gitignore b/tests/auto/widgets/widgets/qstackedwidget/.gitignore
new file mode 100644
index 0000000000..172554eedb
--- /dev/null
+++ b/tests/auto/widgets/widgets/qstackedwidget/.gitignore
@@ -0,0 +1 @@
+tst_qstackedwidget
diff --git a/tests/auto/widgets/widgets/qstackedwidget/qstackedwidget.pro b/tests/auto/widgets/widgets/qstackedwidget/qstackedwidget.pro
new file mode 100644
index 0000000000..c9436c6a86
--- /dev/null
+++ b/tests/auto/widgets/widgets/qstackedwidget/qstackedwidget.pro
@@ -0,0 +1,9 @@
+############################################################
+# Project file for autotest for file qstackedwidget.h
+############################################################
+
+load(qttest_p4)
+QT += widgets
+SOURCES += tst_qstackedwidget.cpp
+
+
diff --git a/tests/auto/widgets/widgets/qstackedwidget/tst_qstackedwidget.cpp b/tests/auto/widgets/widgets/qstackedwidget/tst_qstackedwidget.cpp
new file mode 100644
index 0000000000..a4e71eca51
--- /dev/null
+++ b/tests/auto/widgets/widgets/qstackedwidget/tst_qstackedwidget.cpp
@@ -0,0 +1,124 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#include <QtTest/QtTest>
+
+#include <qcoreapplication.h>
+#include <qdebug.h>
+#include <qstackedwidget.h>
+#include <qpushbutton.h>
+#include <QHBoxLayout>
+
+//TESTED_CLASS=
+//TESTED_FILES=
+
+class tst_QStackedWidget : public QObject
+{
+Q_OBJECT
+
+public:
+ tst_QStackedWidget();
+ virtual ~tst_QStackedWidget();
+
+private slots:
+ void getSetCheck();
+ void testMinimumSize();
+};
+
+tst_QStackedWidget::tst_QStackedWidget()
+{
+}
+
+tst_QStackedWidget::~tst_QStackedWidget()
+{
+}
+
+// Testing that stackedwidget respect the minimum size of it's contents (task 95319)
+void tst_QStackedWidget::testMinimumSize()
+{
+ QWidget w;
+ QStackedWidget sw(&w);
+ QPushButton button("Text", &sw);
+ sw.addWidget(&button);
+ QHBoxLayout hboxLayout;
+ hboxLayout.addWidget(&sw);
+ w.setLayout(&hboxLayout);
+ w.show();
+ QVERIFY(w.minimumSize() != QSize(0, 0));
+}
+
+// Testing get/set functions
+void tst_QStackedWidget::getSetCheck()
+{
+ QStackedWidget obj1;
+ // int QStackedWidget::currentIndex()
+ // void QStackedWidget::setCurrentIndex(int)
+ obj1.setCurrentIndex(0);
+ QCOMPARE(-1, obj1.currentIndex());
+ obj1.setCurrentIndex(INT_MIN);
+ QCOMPARE(-1, obj1.currentIndex());
+ obj1.setCurrentIndex(INT_MAX);
+ QCOMPARE(-1, obj1.currentIndex());
+
+ // QWidget * QStackedWidget::currentWidget()
+ // void QStackedWidget::setCurrentWidget(QWidget *)
+ QWidget *var2 = new QWidget();
+ obj1.addWidget(var2);
+ obj1.setCurrentWidget(var2);
+ QCOMPARE(var2, obj1.currentWidget());
+
+// Disabled, task to fix is 128939.
+#if 0
+ // Layouts assert on any unknown widgets here, 0-pointers included.
+ // This seems wrong behavior, since the setCurrentIndex(int), which
+ // is really a convenience function for setCurrentWidget(QWidget*),
+ // has no problem handling out-of-bounds indices.
+ // ("convenience function" => "just another way of achieving the
+ // same goal")
+ obj1.setCurrentWidget((QWidget *)0);
+ QCOMPARE(obj1.currentWidget(), var2);
+#endif
+ delete var2;
+}
+
+QTEST_MAIN(tst_QStackedWidget)
+#include "tst_qstackedwidget.moc"
diff --git a/tests/auto/widgets/widgets/qstatusbar/.gitignore b/tests/auto/widgets/widgets/qstatusbar/.gitignore
new file mode 100644
index 0000000000..14454b0693
--- /dev/null
+++ b/tests/auto/widgets/widgets/qstatusbar/.gitignore
@@ -0,0 +1 @@
+tst_qstatusbar
diff --git a/tests/auto/widgets/widgets/qstatusbar/qstatusbar.pro b/tests/auto/widgets/widgets/qstatusbar/qstatusbar.pro
new file mode 100644
index 0000000000..51ec0e9cdb
--- /dev/null
+++ b/tests/auto/widgets/widgets/qstatusbar/qstatusbar.pro
@@ -0,0 +1,6 @@
+load(qttest_p4)
+QT += widgets
+SOURCES += tst_qstatusbar.cpp
+
+
+
diff --git a/tests/auto/widgets/widgets/qstatusbar/tst_qstatusbar.cpp b/tests/auto/widgets/widgets/qstatusbar/tst_qstatusbar.cpp
new file mode 100644
index 0000000000..a4a232951a
--- /dev/null
+++ b/tests/auto/widgets/widgets/qstatusbar/tst_qstatusbar.cpp
@@ -0,0 +1,279 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#include <QtTest/QtTest>
+
+
+#include <qstatusbar.h>
+#include <QLabel>
+#include <QMainWindow>
+#include <QSizeGrip>
+
+//TESTED_CLASS=
+//TESTED_FILES=
+
+class tst_QStatusBar: public QObject
+{
+ Q_OBJECT
+
+public:
+ tst_QStatusBar();
+ virtual ~tst_QStatusBar();
+
+
+protected slots:
+ void messageChanged(const QString&);
+
+public slots:
+ void initTestCase();
+ void cleanupTestCase();
+ void init();
+ void cleanup();
+
+private slots:
+ void tempMessage();
+ void insertWidget();
+ void insertPermanentWidget();
+ void setSizeGripEnabled();
+ void task194017_hiddenWidget();
+ void QTBUG4334_hiddenOnMaximizedWindow();
+
+private:
+ QStatusBar *testWidget;
+ QString currentMessage;
+};
+
+tst_QStatusBar::tst_QStatusBar()
+{
+}
+
+tst_QStatusBar::~tst_QStatusBar()
+{
+}
+
+void tst_QStatusBar::init()
+{
+ testWidget = new QStatusBar;
+ connect(testWidget, SIGNAL(messageChanged(QString)), this, SLOT(messageChanged(QString)));
+
+ QWidget *item1 = new QWidget(testWidget);
+ testWidget->addWidget(item1);
+}
+
+void tst_QStatusBar::cleanup()
+{
+ delete testWidget;
+}
+
+void tst_QStatusBar::initTestCase()
+{
+}
+
+void tst_QStatusBar::cleanupTestCase()
+{
+}
+
+void tst_QStatusBar::messageChanged(const QString &m)
+{
+ currentMessage = m;
+}
+
+void tst_QStatusBar::tempMessage()
+{
+ QVERIFY(testWidget->currentMessage().isNull());
+ QVERIFY(currentMessage.isNull());
+
+ testWidget->showMessage("Ready", 500);
+ QCOMPARE(testWidget->currentMessage(), QString("Ready"));
+ QCOMPARE(testWidget->currentMessage(), currentMessage);
+
+ QTest::qWait(1000);
+
+ QVERIFY(testWidget->currentMessage().isNull());
+ QVERIFY(currentMessage.isNull());
+
+ testWidget->showMessage("Ready again", 500);
+ QCOMPARE(testWidget->currentMessage(), QString("Ready again"));
+ QCOMPARE(testWidget->currentMessage(), currentMessage);
+
+ testWidget->clearMessage();
+ QVERIFY(testWidget->currentMessage().isNull());
+ QVERIFY(currentMessage.isNull());
+}
+
+void tst_QStatusBar::insertWidget()
+{
+ QStatusBar sb;
+ sb.addPermanentWidget(new QLabel("foo"));
+ QTest::ignoreMessage(QtWarningMsg, "QStatusBar::insertWidget: Index out of range (-1), appending widget");
+ QCOMPARE(sb.insertWidget(-1, new QLabel("foo")), 0);
+ QTest::ignoreMessage(QtWarningMsg, "QStatusBar::insertWidget: Index out of range (2), appending widget");
+ QCOMPARE(sb.insertWidget(2, new QLabel("foo")), 1);
+ QCOMPARE(sb.insertWidget(0, new QLabel("foo")), 0);
+ QCOMPARE(sb.insertWidget(3, new QLabel("foo")), 3);
+}
+
+void tst_QStatusBar::insertPermanentWidget()
+{
+ QStatusBar sb;
+ sb.addWidget(new QLabel("foo"));
+ QTest::ignoreMessage(QtWarningMsg, "QStatusBar::insertPermanentWidget: Index out of range (-1), appending widget");
+ QCOMPARE(sb.insertPermanentWidget(-1, new QLabel("foo")), 1);
+ QTest::ignoreMessage(QtWarningMsg, "QStatusBar::insertPermanentWidget: Index out of range (0), appending widget");
+ QCOMPARE(sb.insertPermanentWidget(0, new QLabel("foo")), 2);
+ QCOMPARE(sb.insertPermanentWidget(2, new QLabel("foo")), 2);
+ QTest::ignoreMessage(QtWarningMsg, "QStatusBar::insertPermanentWidget: Index out of range (5), appending widget");
+ QCOMPARE(sb.insertPermanentWidget(5, new QLabel("foo")), 4);
+ QCOMPARE(sb.insertWidget(1, new QLabel("foo")), 1);
+ QTest::ignoreMessage(QtWarningMsg, "QStatusBar::insertPermanentWidget: Index out of range (1), appending widget");
+ QCOMPARE(sb.insertPermanentWidget(1, new QLabel("foo")), 6);
+}
+
+void tst_QStatusBar::setSizeGripEnabled()
+{
+ QMainWindow mainWindow;
+ QPointer<QStatusBar> statusBar = mainWindow.statusBar();
+ QVERIFY(statusBar);
+ mainWindow.show();
+#ifdef Q_WS_X11
+ qt_x11_wait_for_window_manager(&mainWindow);
+#endif
+
+ QTRY_VERIFY(statusBar->isVisible());
+ QPointer<QSizeGrip> sizeGrip = qFindChild<QSizeGrip *>(statusBar);
+ QVERIFY(sizeGrip);
+ QVERIFY(sizeGrip->isVisible());
+
+ statusBar->setSizeGripEnabled(true);
+ QVERIFY(sizeGrip);
+ QVERIFY(sizeGrip->isVisible());
+
+ statusBar->hide();
+ QVERIFY(!sizeGrip->isVisible());
+ statusBar->show();
+ QVERIFY(sizeGrip->isVisible());
+
+ sizeGrip->setVisible(false);
+ QVERIFY(!sizeGrip->isVisible());
+ statusBar->hide();
+ statusBar->show();
+ QVERIFY(!sizeGrip->isVisible());
+
+ statusBar->setSizeGripEnabled(false);
+ QVERIFY(!sizeGrip);
+
+ qApp->processEvents();
+ mainWindow.showFullScreen();
+#ifdef Q_WS_X11
+ qt_x11_wait_for_window_manager(&mainWindow);
+#endif
+ qApp->processEvents();
+
+ mainWindow.setStatusBar(new QStatusBar(&mainWindow));
+ //we now call deleteLater on the previous statusbar
+ QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
+ QVERIFY(!statusBar);
+ statusBar = mainWindow.statusBar();
+ QVERIFY(statusBar);
+
+ sizeGrip = qFindChild<QSizeGrip *>(statusBar);
+ QVERIFY(sizeGrip);
+ QVERIFY(!sizeGrip->isVisible());
+
+ statusBar->setSizeGripEnabled(true);
+ QVERIFY(!sizeGrip->isVisible());
+
+ qApp->processEvents();
+ mainWindow.showNormal();
+ qApp->processEvents();
+ QTRY_VERIFY(sizeGrip->isVisible());
+}
+
+void tst_QStatusBar::task194017_hiddenWidget()
+{
+ QStatusBar sb;
+
+ QWidget *label= new QLabel("bar",&sb);
+ sb.addWidget(label);
+ sb.show();
+ QVERIFY(label->isVisible());
+ sb.showMessage("messssage");
+ QVERIFY(!label->isVisible());
+ sb.hide();
+ QVERIFY(!label->isVisible());
+ sb.show();
+ QVERIFY(!label->isVisible());
+ sb.clearMessage();
+ QVERIFY(label->isVisible());
+ label->hide();
+ QVERIFY(!label->isVisible());
+ sb.showMessage("messssage");
+ QVERIFY(!label->isVisible());
+ sb.clearMessage();
+ QVERIFY(!label->isVisible());
+ sb.hide();
+ QVERIFY(!label->isVisible());
+ sb.show();
+ QVERIFY(!label->isVisible());
+}
+
+void tst_QStatusBar::QTBUG4334_hiddenOnMaximizedWindow()
+{
+ QMainWindow main;
+ QStatusBar statusbar;
+ statusbar.setSizeGripEnabled(true);
+ main.setStatusBar(&statusbar);
+ main.showMaximized();
+ QTest::qWaitForWindowShown(&main);
+#ifndef Q_WS_MAC
+ QVERIFY(!statusbar.findChild<QSizeGrip*>()->isVisible());
+#endif
+ main.showNormal();
+ QTest::qWaitForWindowShown(&main);
+ QVERIFY(statusbar.findChild<QSizeGrip*>()->isVisible());
+ main.showFullScreen();
+ QTest::qWaitForWindowShown(&main);
+ QVERIFY(!statusbar.findChild<QSizeGrip*>()->isVisible());
+}
+
+QTEST_MAIN(tst_QStatusBar)
+#include "tst_qstatusbar.moc"
diff --git a/tests/auto/widgets/widgets/qtabbar/.gitignore b/tests/auto/widgets/widgets/qtabbar/.gitignore
new file mode 100644
index 0000000000..3f8338e1fe
--- /dev/null
+++ b/tests/auto/widgets/widgets/qtabbar/.gitignore
@@ -0,0 +1 @@
+tst_qtabbar
diff --git a/tests/auto/widgets/widgets/qtabbar/qtabbar.pro b/tests/auto/widgets/widgets/qtabbar/qtabbar.pro
new file mode 100644
index 0000000000..befe5704ba
--- /dev/null
+++ b/tests/auto/widgets/widgets/qtabbar/qtabbar.pro
@@ -0,0 +1,6 @@
+load(qttest_p4)
+QT += widgets
+SOURCES += tst_qtabbar.cpp
+
+
+
diff --git a/tests/auto/widgets/widgets/qtabbar/tst_qtabbar.cpp b/tests/auto/widgets/widgets/qtabbar/tst_qtabbar.cpp
new file mode 100644
index 0000000000..a1a8f3b0aa
--- /dev/null
+++ b/tests/auto/widgets/widgets/qtabbar/tst_qtabbar.cpp
@@ -0,0 +1,655 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#include <QtTest/QtTest>
+#include <qapplication.h>
+#include <qtabbar.h>
+
+#include <qpushbutton.h>
+#include <qstyle.h>
+
+class tst_QTabBar : public QObject
+{
+ Q_OBJECT
+
+public:
+ tst_QTabBar();
+ virtual ~tst_QTabBar();
+
+public slots:
+ void initTestCase();
+ void cleanupTestCase();
+ void init();
+
+private slots:
+ void getSetCheck();
+ void setIconSize();
+ void setIconSize_data();
+
+ void testCurrentChanged_data();
+ void testCurrentChanged();
+
+ void insertAtCurrentIndex();
+
+ void removeTab_data();
+ void removeTab();
+
+ void setElideMode_data();
+ void setElideMode();
+ void sizeHints();
+
+ void setUsesScrollButtons_data();
+ void setUsesScrollButtons();
+
+ void removeLastTab();
+
+ void closeButton();
+
+ void tabButton_data();
+ void tabButton();
+
+ void selectionBehaviorOnRemove_data();
+ void selectionBehaviorOnRemove();
+
+ void moveTab_data();
+ void moveTab();
+
+ void task251184_removeTab();
+ void changeTitleWhileDoubleClickingTab();
+
+ void taskQTBUG_10052_widgetLayoutWhenMoving();
+};
+
+// Testing get/set functions
+void tst_QTabBar::getSetCheck()
+{
+ QTabBar obj1;
+ obj1.addTab("Tab1");
+ obj1.addTab("Tab2");
+ obj1.addTab("Tab3");
+ obj1.addTab("Tab4");
+ obj1.addTab("Tab5");
+ // Shape QTabBar::shape()
+ // void QTabBar::setShape(Shape)
+ obj1.setShape(QTabBar::Shape(QTabBar::RoundedNorth));
+ QCOMPARE(QTabBar::Shape(QTabBar::RoundedNorth), obj1.shape());
+ obj1.setShape(QTabBar::Shape(QTabBar::RoundedSouth));
+ QCOMPARE(QTabBar::Shape(QTabBar::RoundedSouth), obj1.shape());
+ obj1.setShape(QTabBar::Shape(QTabBar::RoundedWest));
+ QCOMPARE(QTabBar::Shape(QTabBar::RoundedWest), obj1.shape());
+ obj1.setShape(QTabBar::Shape(QTabBar::RoundedEast));
+ QCOMPARE(QTabBar::Shape(QTabBar::RoundedEast), obj1.shape());
+ obj1.setShape(QTabBar::Shape(QTabBar::TriangularNorth));
+ QCOMPARE(QTabBar::Shape(QTabBar::TriangularNorth), obj1.shape());
+ obj1.setShape(QTabBar::Shape(QTabBar::TriangularSouth));
+ QCOMPARE(QTabBar::Shape(QTabBar::TriangularSouth), obj1.shape());
+ obj1.setShape(QTabBar::Shape(QTabBar::TriangularWest));
+ QCOMPARE(QTabBar::Shape(QTabBar::TriangularWest), obj1.shape());
+ obj1.setShape(QTabBar::Shape(QTabBar::TriangularEast));
+ QCOMPARE(QTabBar::Shape(QTabBar::TriangularEast), obj1.shape());
+
+ // bool QTabBar::drawBase()
+ // void QTabBar::setDrawBase(bool)
+ obj1.setDrawBase(false);
+ QCOMPARE(false, obj1.drawBase());
+ obj1.setDrawBase(true);
+ QCOMPARE(true, obj1.drawBase());
+
+ // int QTabBar::currentIndex()
+ // void QTabBar::setCurrentIndex(int)
+ obj1.setCurrentIndex(0);
+ QCOMPARE(0, obj1.currentIndex());
+ obj1.setCurrentIndex(INT_MIN);
+ QCOMPARE(0, obj1.currentIndex());
+ obj1.setCurrentIndex(INT_MAX);
+ QCOMPARE(0, obj1.currentIndex());
+ obj1.setCurrentIndex(4);
+ QCOMPARE(4, obj1.currentIndex());
+}
+
+tst_QTabBar::tst_QTabBar()
+{
+}
+
+tst_QTabBar::~tst_QTabBar()
+{
+}
+
+void tst_QTabBar::initTestCase()
+{
+}
+
+void tst_QTabBar::cleanupTestCase()
+{
+}
+
+void tst_QTabBar::init()
+{
+}
+
+void tst_QTabBar::setIconSize_data()
+{
+ QTest::addColumn<int>("sizeToSet");
+ QTest::addColumn<int>("expectedWidth");
+
+ const int iconDefault = qApp->style()->pixelMetric(QStyle::PM_TabBarIconSize);
+ const int smallIconSize = qApp->style()->pixelMetric(QStyle::PM_SmallIconSize);
+ const int largeIconSize = qApp->style()->pixelMetric(QStyle::PM_LargeIconSize);
+ QTest::newRow("default") << -1 << iconDefault;
+ QTest::newRow("zero") << 0 << 0;
+ QTest::newRow("same as default") << iconDefault << iconDefault;
+ QTest::newRow("large") << largeIconSize << largeIconSize;
+ QTest::newRow("small") << smallIconSize << smallIconSize;
+}
+
+void tst_QTabBar::setIconSize()
+{
+ QFETCH(int, sizeToSet);
+ QFETCH(int, expectedWidth);
+ QTabBar tabBar;
+ tabBar.setIconSize(QSize(sizeToSet, sizeToSet));
+ QCOMPARE(tabBar.iconSize().width(), expectedWidth);
+}
+
+void tst_QTabBar::testCurrentChanged_data()
+{
+ QTest::addColumn<int>("tabToSet");
+ QTest::addColumn<int>("expectedCount");
+
+ QTest::newRow("pressAntotherTab") << 1 << 2;
+ QTest::newRow("pressTheSameTab") << 0 << 1;
+}
+
+void tst_QTabBar::testCurrentChanged()
+{
+ QFETCH(int, tabToSet);
+ QFETCH(int, expectedCount);
+ QTabBar tabBar;
+ QSignalSpy spy(&tabBar, SIGNAL(currentChanged(int)));
+ tabBar.addTab("Tab1");
+ tabBar.addTab("Tab2");
+ QCOMPARE(tabBar.currentIndex(), 0);
+ tabBar.setCurrentIndex(tabToSet);
+ QCOMPARE(tabBar.currentIndex(), tabToSet);
+ QCOMPARE(spy.count(), expectedCount);
+}
+
+void tst_QTabBar::insertAtCurrentIndex()
+{
+ QTabBar tabBar;
+ tabBar.addTab("Tab1");
+ QCOMPARE(tabBar.currentIndex(), 0);
+ tabBar.insertTab(0, "Tab2");
+ QCOMPARE(tabBar.currentIndex(), 1);
+ tabBar.insertTab(0, "Tab3");
+ QCOMPARE(tabBar.currentIndex(), 2);
+ tabBar.insertTab(2, "Tab4");
+ QCOMPARE(tabBar.currentIndex(), 3);
+}
+
+void tst_QTabBar::removeTab_data()
+{
+ QTest::addColumn<int>("currentIndex");
+ QTest::addColumn<int>("deleteIndex");
+ QTest::addColumn<int>("spyCount");
+ QTest::addColumn<int>("finalIndex");
+
+ QTest::newRow("deleteEnd") << 0 << 2 << 0 << 0;
+ QTest::newRow("deleteEndWithIndexOnEnd") << 2 << 2 << 1 << 1;
+ QTest::newRow("deleteMiddle") << 2 << 1 << 1 << 1;
+ QTest::newRow("deleteMiddleOnMiddle") << 1 << 1 << 1 << 1;
+}
+void tst_QTabBar::removeTab()
+{
+ QTabBar tabbar;
+
+ QFETCH(int, currentIndex);
+ QFETCH(int, deleteIndex);
+ tabbar.addTab("foo");
+ tabbar.addTab("bar");
+ tabbar.addTab("baz");
+ tabbar.setCurrentIndex(currentIndex);
+ QSignalSpy spy(&tabbar, SIGNAL(currentChanged(int)));
+ tabbar.removeTab(deleteIndex);
+ QTEST(spy.count(), "spyCount");
+ QTEST(tabbar.currentIndex(), "finalIndex");
+}
+
+void tst_QTabBar::setElideMode_data()
+{
+ QTest::addColumn<int>("tabElideMode");
+ QTest::addColumn<int>("expectedMode");
+
+ QTest::newRow("default") << -128 << qApp->style()->styleHint(QStyle::SH_TabBar_ElideMode);
+ QTest::newRow("explicit default") << qApp->style()->styleHint(QStyle::SH_TabBar_ElideMode)
+ << qApp->style()->styleHint(QStyle::SH_TabBar_ElideMode);
+ QTest::newRow("None") << int(Qt::ElideNone) << int(Qt::ElideNone);
+ QTest::newRow("Left") << int(Qt::ElideLeft) << int(Qt::ElideLeft);
+ QTest::newRow("Center") << int(Qt::ElideMiddle) << int(Qt::ElideMiddle);
+ QTest::newRow("Right") << int(Qt::ElideRight) << int(Qt::ElideRight);
+}
+
+void tst_QTabBar::setElideMode()
+{
+ QFETCH(int, tabElideMode);
+ QTabBar tabBar;
+ if (tabElideMode != -128)
+ tabBar.setElideMode(Qt::TextElideMode(tabElideMode));
+ QTEST(int(tabBar.elideMode()), "expectedMode");
+ // Make sure style sheet does not override user set mode
+ tabBar.setStyleSheet("QWidget { background-color: #ABA8A6;}");
+ QTEST(int(tabBar.elideMode()), "expectedMode");
+}
+
+void tst_QTabBar::sizeHints()
+{
+ QTabBar tabBar;
+ QSKIP("To be fixed on Mac (font size below not large enough) and Linux QWS (probably too large for the screen).", SkipSingle);
+ tabBar.setFont(QFont("Arial", 10));
+ tabBar.addTab("tab 01");
+ tabBar.addTab("tab 02");
+ tabBar.addTab("tab 03");
+ tabBar.addTab("tab 04");
+ tabBar.addTab("tab 05");
+ tabBar.addTab("tab 06");
+ tabBar.addTab("This is tab7");
+ tabBar.addTab("This is tab8");
+ tabBar.addTab("This is tab9 with a very long title");
+
+ // No eliding and no scrolling -> tabbar becomes very wide
+ tabBar.setUsesScrollButtons(false);
+ tabBar.setElideMode(Qt::ElideNone);
+// qDebug() << tabBar.minimumSizeHint() << tabBar.sizeHint();
+ QVERIFY(tabBar.minimumSizeHint().width() > 700);
+ QVERIFY(tabBar.sizeHint().width() > 700);
+
+ // Scrolling enabled -> no reason to become very wide
+ tabBar.setUsesScrollButtons(true);
+ // qDebug() << tabBar.minimumSizeHint() << tabBar.sizeHint();
+ QVERIFY(tabBar.minimumSizeHint().width() < 200);
+ QVERIFY(tabBar.sizeHint().width() > 700); // unchanged
+
+ // Eliding enabled -> no reason to become very wide
+ tabBar.setUsesScrollButtons(false);
+ tabBar.setElideMode(Qt::ElideRight);
+// qDebug() << tabBar.minimumSizeHint() << tabBar.sizeHint();
+ QVERIFY(tabBar.minimumSizeHint().width() < 500);
+ QVERIFY(tabBar.sizeHint().width() > 700); // unchanged
+
+ tabBar.addTab("This is tab10 with a very long title");
+ QVERIFY(tabBar.minimumSizeHint().width() < 600);
+ QVERIFY(tabBar.sizeHint().width() > 700); // unchanged
+}
+
+void tst_QTabBar::setUsesScrollButtons_data()
+{
+ QTest::addColumn<int>("usesArrows");
+ QTest::addColumn<bool>("expectedArrows");
+
+ QTest::newRow("default") << -128 << !qApp->style()->styleHint(QStyle::SH_TabBar_PreferNoArrows);
+ QTest::newRow("explicit default")
+ << int(!qApp->style()->styleHint(QStyle::SH_TabBar_PreferNoArrows))
+ << !qApp->style()->styleHint(QStyle::SH_TabBar_PreferNoArrows);
+ QTest::newRow("No") << int(false) << false;
+ QTest::newRow("Yes") << int(true) << true;
+}
+
+void tst_QTabBar::setUsesScrollButtons()
+{
+ QFETCH(int, usesArrows);
+ QTabBar tabBar;
+ if (usesArrows != -128)
+ tabBar.setUsesScrollButtons(usesArrows);
+ QTEST(tabBar.usesScrollButtons(), "expectedArrows");
+
+ // Make sure style sheet does not override user set mode
+ tabBar.setStyleSheet("QWidget { background-color: #ABA8A6;}");
+ QTEST(tabBar.usesScrollButtons(), "expectedArrows");
+}
+
+void tst_QTabBar::removeLastTab()
+{
+ QTabBar tabbar;
+ QSignalSpy spy(&tabbar, SIGNAL(currentChanged(int)));
+ int index = tabbar.addTab("foo");
+ QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.at(0).at(0).toInt(), index);
+ spy.clear();
+
+ tabbar.removeTab(index);
+ QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.at(0).at(0).toInt(), -1);
+ spy.clear();
+}
+
+void tst_QTabBar::closeButton()
+{
+ QTabBar tabbar;
+ QCOMPARE(tabbar.tabsClosable(), false);
+ tabbar.setTabsClosable(true);
+ QCOMPARE(tabbar.tabsClosable(), true);
+ tabbar.addTab("foo");
+
+ QTabBar::ButtonPosition closeSide = (QTabBar::ButtonPosition)tabbar.style()->styleHint(QStyle::SH_TabBar_CloseButtonPosition, 0, &tabbar);
+ QTabBar::ButtonPosition otherSide = (closeSide == QTabBar::LeftSide ? QTabBar::RightSide : QTabBar::LeftSide);
+ QVERIFY(tabbar.tabButton(0, otherSide) == 0);
+ QVERIFY(tabbar.tabButton(0, closeSide) != 0);
+
+ QAbstractButton *button = static_cast<QAbstractButton*>(tabbar.tabButton(0, closeSide));
+ QVERIFY(button);
+ QSignalSpy spy(&tabbar, SIGNAL(tabCloseRequested(int)));
+ button->click();
+ QCOMPARE(tabbar.count(), 1);
+ QCOMPARE(spy.count(), 1);
+}
+
+Q_DECLARE_METATYPE(QTabBar::ButtonPosition)
+void tst_QTabBar::tabButton_data()
+{
+ QTest::addColumn<QTabBar::ButtonPosition>("position");
+
+ QTest::newRow("left") << QTabBar::LeftSide;
+ QTest::newRow("right") << QTabBar::RightSide;
+}
+
+// QTabBar::setTabButton(index, closeSide, closeButton);
+void tst_QTabBar::tabButton()
+{
+ QFETCH(QTabBar::ButtonPosition, position);
+ QTabBar::ButtonPosition otherSide = (position == QTabBar::LeftSide ? QTabBar::RightSide : QTabBar::LeftSide);
+
+ QTabBar tabbar;
+ tabbar.resize(500, 200);
+ tabbar.show();
+ QTRY_VERIFY(tabbar.isVisible());
+
+ tabbar.setTabButton(-1, position, 0);
+ QVERIFY(tabbar.tabButton(-1, position) == 0);
+ QVERIFY(tabbar.tabButton(0, position) == 0);
+
+ tabbar.addTab("foo");
+ QCOMPARE(tabbar.count(), 1);
+ tabbar.setTabButton(0, position, 0);
+ QVERIFY(tabbar.tabButton(0, position) == 0);
+
+ QPushButton *button = new QPushButton;
+ button->show();
+ button->setText("hi");
+ button->resize(10, 10);
+ QTRY_VERIFY(button->isVisible());
+ QTRY_VERIFY(button->isVisible());
+
+ tabbar.setTabButton(0, position, button);
+
+ QCOMPARE(tabbar.tabButton(0, position), static_cast<QWidget *>(button));
+ QTRY_VERIFY(!button->isHidden());
+ QVERIFY(tabbar.tabButton(0, otherSide) == 0);
+ QCOMPARE(button->parent(), static_cast<QObject *>(&tabbar));
+ QVERIFY(button->pos() != QPoint(0, 0));
+
+ QPushButton *button2 = new QPushButton;
+ tabbar.setTabButton(0, position, button2);
+ QVERIFY(button->isHidden());
+}
+
+typedef QList<int> IntList;
+Q_DECLARE_METATYPE(QTabBar::SelectionBehavior)
+Q_DECLARE_METATYPE(IntList)
+#define ONE(x) (IntList() << x)
+void tst_QTabBar::selectionBehaviorOnRemove_data()
+{
+ QTest::addColumn<QTabBar::SelectionBehavior>("selectionBehavior");
+ QTest::addColumn<int>("tabs");
+ QTest::addColumn<IntList>("select");
+ QTest::addColumn<IntList>("remove");
+ QTest::addColumn<int>("expected");
+
+ // Count select remove current
+ QTest::newRow("left-1") << QTabBar::SelectLeftTab << 3 << (IntList() << 0) << ONE(0) << 0;
+
+ QTest::newRow("left-2") << QTabBar::SelectLeftTab << 3 << (IntList() << 0) << ONE(1) << 0; // not removing current
+ QTest::newRow("left-3") << QTabBar::SelectLeftTab << 3 << (IntList() << 0) << ONE(2) << 0; // not removing current
+ QTest::newRow("left-4") << QTabBar::SelectLeftTab << 3 << (IntList() << 1) << ONE(0) << 0; // not removing current
+ QTest::newRow("left-5") << QTabBar::SelectLeftTab << 3 << (IntList() << 1) << ONE(1) << 0;
+ QTest::newRow("left-6") << QTabBar::SelectLeftTab << 3 << (IntList() << 1) << ONE(2) << 1;
+ QTest::newRow("left-7") << QTabBar::SelectLeftTab << 3 << (IntList() << 2) << ONE(0) << 1; // not removing current
+ QTest::newRow("left-8") << QTabBar::SelectLeftTab << 3 << (IntList() << 2) << ONE(1) << 1; // not removing current
+ QTest::newRow("left-9") << QTabBar::SelectLeftTab << 3 << (IntList() << 2) << ONE(2) << 1;
+
+ QTest::newRow("right-1") << QTabBar::SelectRightTab << 3 << (IntList() << 0) << ONE(0) << 0;
+ QTest::newRow("right-2") << QTabBar::SelectRightTab << 3 << (IntList() << 0) << ONE(1) << 0; // not removing current
+ QTest::newRow("right-3") << QTabBar::SelectRightTab << 3 << (IntList() << 0) << ONE(2) << 0; // not removing current
+ QTest::newRow("right-4") << QTabBar::SelectRightTab << 3 << (IntList() << 1) << ONE(0) << 0; // not removing current
+ QTest::newRow("right-5") << QTabBar::SelectRightTab << 3 << (IntList() << 1) << ONE(1) << 1;
+ QTest::newRow("right-6") << QTabBar::SelectRightTab << 3 << (IntList() << 1) << ONE(2) << 1; // not removing current
+ QTest::newRow("right-7") << QTabBar::SelectRightTab << 3 << (IntList() << 2) << ONE(0) << 1; // not removing current
+ QTest::newRow("right-8") << QTabBar::SelectRightTab << 3 << (IntList() << 2) << ONE(1) << 1; // not removing current
+ QTest::newRow("right-9") << QTabBar::SelectRightTab << 3 << (IntList() << 2) << ONE(2) << 1;
+
+ QTest::newRow("previous-0") << QTabBar::SelectPreviousTab << 3 << (IntList()) << ONE(0) << 0;
+ QTest::newRow("previous-1") << QTabBar::SelectPreviousTab << 3 << (IntList()) << ONE(1) << 0; // not removing current
+ QTest::newRow("previous-2") << QTabBar::SelectPreviousTab << 3 << (IntList()) << ONE(2) << 0; // not removing current
+
+ QTest::newRow("previous-3") << QTabBar::SelectPreviousTab << 3 << (IntList() << 2) << ONE(0) << 1; // not removing current
+ QTest::newRow("previous-4") << QTabBar::SelectPreviousTab << 3 << (IntList() << 2) << ONE(1) << 1; // not removing current
+ QTest::newRow("previous-5") << QTabBar::SelectPreviousTab << 3 << (IntList() << 2) << ONE(2) << 0;
+
+ // go back one
+ QTest::newRow("previous-6") << QTabBar::SelectPreviousTab << 4 << (IntList() << 0 << 2 << 3 << 1) << (IntList() << 1) << 2;
+ // go back two
+ QTest::newRow("previous-7") << QTabBar::SelectPreviousTab << 4 << (IntList() << 0 << 2 << 3 << 1) << (IntList() << 1 << 2) << 1;
+ // go back three
+ QTest::newRow("previous-8") << QTabBar::SelectPreviousTab << 4 << (IntList() << 0 << 2 << 3 << 1) << (IntList() << 1 << 2 << 1) << 0;
+
+ // pick from the middle
+ QTest::newRow("previous-9") << QTabBar::SelectPreviousTab << 4 << (IntList() << 0 << 2 << 3 << 1) << (IntList() << 2 << 1) << 1;
+
+ // every other one
+ QTest::newRow("previous-10") << QTabBar::SelectPreviousTab << 7 << (IntList() << 0 << 2 << 4 << 6) << (IntList() << 6 << 4) << 2;
+
+
+}
+
+void tst_QTabBar::selectionBehaviorOnRemove()
+{
+ QFETCH(QTabBar::SelectionBehavior, selectionBehavior);
+ QFETCH(int, tabs);
+ QFETCH(IntList, select);
+ QFETCH(IntList, remove);
+ QFETCH(int, expected);
+
+ QTabBar tabbar;
+ tabbar.setSelectionBehaviorOnRemove(selectionBehavior);
+ while(--tabs >= 0)
+ tabbar.addTab(QString::number(tabs));
+ QCOMPARE(tabbar.currentIndex(), 0);
+ while(!select.isEmpty())
+ tabbar.setCurrentIndex(select.takeFirst());
+ while(!remove.isEmpty())
+ tabbar.removeTab(remove.takeFirst());
+ QVERIFY(tabbar.count() > 0);
+ QCOMPARE(tabbar.currentIndex(), expected);
+}
+
+class TabBar : public QTabBar
+{
+ Q_OBJECT
+public:
+ void callMoveTab(int from, int to){ moveTab(from, to); }
+};
+
+
+Q_DECLARE_METATYPE(QTabBar::Shape)
+void tst_QTabBar::moveTab_data()
+{
+ QTest::addColumn<QTabBar::Shape>("shape");
+ QTest::addColumn<int>("tabs");
+ QTest::addColumn<int>("from");
+ QTest::addColumn<int>("to");
+
+ QTest::newRow("null-0") << QTabBar::RoundedNorth << 0 << -1 << -1;
+ QTest::newRow("null-1") << QTabBar::RoundedEast << 0 << -1 << -1;
+ QTest::newRow("null-2") << QTabBar::RoundedEast << 1 << 0 << 0;
+
+ QTest::newRow("two-0") << QTabBar::RoundedNorth << 2 << 0 << 1;
+ QTest::newRow("two-1") << QTabBar::RoundedNorth << 2 << 1 << 0;
+
+ QTest::newRow("five-0") << QTabBar::RoundedNorth << 5 << 1 << 3; // forward
+ QTest::newRow("five-1") << QTabBar::RoundedNorth << 5 << 3 << 1; // reverse
+
+ QTest::newRow("five-2") << QTabBar::RoundedNorth << 5 << 0 << 4; // forward
+ QTest::newRow("five-3") << QTabBar::RoundedNorth << 5 << 1 << 4; // forward
+ QTest::newRow("five-4") << QTabBar::RoundedNorth << 5 << 3 << 4; // forward
+}
+
+void tst_QTabBar::moveTab()
+{
+ QFETCH(QTabBar::Shape, shape);
+ QFETCH(int, tabs);
+ QFETCH(int, from);
+ QFETCH(int, to);
+
+ TabBar bar;
+ bar.setShape(shape);
+ while(--tabs >= 0)
+ bar.addTab(QString::number(tabs));
+ bar.callMoveTab(from, to);
+}
+
+
+class MyTabBar : public QTabBar
+{
+ Q_OBJECT
+public slots:
+ void onCurrentChanged()
+ {
+ //we just want this to be done once
+ disconnect(this, SIGNAL(currentChanged(int)), this, SLOT(onCurrentChanged()));
+ removeTab(0);
+ }
+};
+
+void tst_QTabBar::task251184_removeTab()
+{
+ MyTabBar bar;
+ bar.addTab("bar1");
+ bar.addTab("bar2");
+ QCOMPARE(bar.count(), 2);
+ QCOMPARE(bar.currentIndex(), 0);
+
+ bar.connect(&bar, SIGNAL(currentChanged(int)), SLOT(onCurrentChanged()));
+ bar.setCurrentIndex(1);
+
+ QCOMPARE(bar.count(), 1);
+ QCOMPARE(bar.currentIndex(), 0);
+ QCOMPARE(bar.tabText(bar.currentIndex()), QString("bar2"));
+}
+
+
+class TitleChangeTabBar : public QTabBar
+{
+ Q_OBJECT
+
+ QTimer timer;
+ int count;
+
+public:
+ TitleChangeTabBar(QWidget * parent = 0) : QTabBar(parent), count(0)
+ {
+ setMovable(true);
+ addTab("0");
+ connect(&timer, SIGNAL(timeout()), this, SLOT(updateTabText()));
+ timer.start(1);
+ }
+
+public slots:
+ void updateTabText()
+ {
+ count++;
+ setTabText(0, QString("%1").arg(count));
+ }
+};
+
+void tst_QTabBar::changeTitleWhileDoubleClickingTab()
+{
+ TitleChangeTabBar bar;
+ QPoint tabPos = bar.tabRect(0).center();
+
+ for(int i=0; i < 10; i++)
+ QTest::mouseDClick(&bar, Qt::LeftButton, 0, tabPos);
+}
+
+class Widget10052 : public QWidget
+{
+public:
+ Widget10052(QWidget *parent) : QWidget(parent), moved(false)
+ { }
+
+ void moveEvent(QMoveEvent *e)
+ {
+ moved = e->oldPos() != e->pos();
+ QWidget::moveEvent(e);
+ }
+
+ bool moved;
+};
+
+void tst_QTabBar::taskQTBUG_10052_widgetLayoutWhenMoving()
+{
+ QTabBar tabBar;
+ tabBar.insertTab(0, "My first tab");
+ Widget10052 w1(&tabBar);
+ tabBar.setTabButton(0, QTabBar::RightSide, &w1);
+ tabBar.insertTab(1, "My other tab");
+ Widget10052 w2(&tabBar);
+ tabBar.setTabButton(1, QTabBar::RightSide, &w2);
+
+ tabBar.show();
+ QTest::qWaitForWindowShown(&tabBar);
+ w1.moved = w2.moved = false;
+ tabBar.moveTab(0, 1);
+ QTRY_VERIFY(w1.moved);
+ QVERIFY(w2.moved);
+}
+
+QTEST_MAIN(tst_QTabBar)
+#include "tst_qtabbar.moc"
diff --git a/tests/auto/widgets/widgets/qtabwidget/.gitignore b/tests/auto/widgets/widgets/qtabwidget/.gitignore
new file mode 100644
index 0000000000..d8f924a3df
--- /dev/null
+++ b/tests/auto/widgets/widgets/qtabwidget/.gitignore
@@ -0,0 +1 @@
+tst_qtabwidget
diff --git a/tests/auto/widgets/widgets/qtabwidget/qtabwidget.pro b/tests/auto/widgets/widgets/qtabwidget/qtabwidget.pro
new file mode 100644
index 0000000000..d551c66500
--- /dev/null
+++ b/tests/auto/widgets/widgets/qtabwidget/qtabwidget.pro
@@ -0,0 +1,12 @@
+load(qttest_p4)
+
+QT += widgets widgets-private
+
+INCLUDEPATH += ../
+
+HEADERS +=
+SOURCES += tst_qtabwidget.cpp
+
+win32:!wince*:LIBS += -luser32
+
+CONFIG+=insignificant_test
diff --git a/tests/auto/widgets/widgets/qtabwidget/tst_qtabwidget.cpp b/tests/auto/widgets/widgets/qtabwidget/tst_qtabwidget.cpp
new file mode 100644
index 0000000000..6d356dee9b
--- /dev/null
+++ b/tests/auto/widgets/widgets/qtabwidget/tst_qtabwidget.cpp
@@ -0,0 +1,680 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#include <QtTest/QtTest>
+#include <qtabwidget.h>
+#include <qdebug.h>
+#include <qapplication.h>
+#include <qlabel.h>
+#include <QtWidgets/qboxlayout.h>
+
+//TESTED_CLASS=
+//TESTED_FILES=
+
+#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE)
+# include <qt_windows.h>
+#define Q_CHECK_PAINTEVENTS \
+ if (::SwitchDesktop(::GetThreadDesktop(::GetCurrentThreadId())) == 0) \
+ QSKIP("desktop is not visible, this test would fail", SkipSingle);
+#else
+#define Q_CHECK_PAINTEVENTS
+#endif
+#if defined(Q_WS_X11)
+# include <private/qt_x11_p.h>
+# include <qx11info_x11.h>
+#elif defined(Q_WS_QWS)
+# include <qwindowsystem_qws.h>
+#endif
+
+class QTabWidgetChild:public QTabWidget {
+ public:
+ QTabWidgetChild():tabCount(0) {
+ QVERIFY(tabBar() != NULL);
+ QWidget *w = new QWidget;
+ int index = addTab(w, "test");
+ QCOMPARE(tabCount, 1);
+ removeTab(index);
+ QCOMPARE(tabCount, 0);
+
+ // Test bad arguments
+ // This will assert, so don't do it :)
+ //setTabBar(NULL);
+ };
+
+ protected:
+ virtual void tabInserted(int /*index */ ) {
+ tabCount++;
+ };
+ virtual void tabRemoved(int /*index */ ) {
+ tabCount--;
+ };
+ int tabCount;
+};
+
+class tst_QTabWidget:public QObject {
+ Q_OBJECT
+ public:
+ tst_QTabWidget();
+
+ public slots:
+ void init();
+ void cleanup();
+ private slots:
+ void getSetCheck();
+ void testChild();
+ void addRemoveTab();
+ void tabPosition();
+ void tabEnabled();
+ void tabText();
+ void tabShape();
+ void tabTooltip();
+ void tabIcon();
+ void indexOf();
+ void currentWidget();
+ void currentIndex();
+ void cornerWidget();
+ void removeTab();
+ void clear();
+ void keyboardNavigation();
+ void paintEventCount();
+ void minimumSizeHint();
+ void heightForWidth_data();
+ void heightForWidth();
+
+ private:
+ int addPage();
+ void removePage(int index);
+ QTabWidget *tw;
+};
+
+// Testing get/set functions
+void tst_QTabWidget::getSetCheck()
+{
+ QTabWidget obj1;
+ QWidget *w1 = new QWidget;
+ QWidget *w2 = new QWidget;
+ QWidget *w3 = new QWidget;
+ QWidget *w4 = new QWidget;
+ QWidget *w5 = new QWidget;
+
+ obj1.addTab(w1, "Page 1");
+ obj1.addTab(w2, "Page 2");
+ obj1.addTab(w3, "Page 3");
+ obj1.addTab(w4, "Page 4");
+ obj1.addTab(w5, "Page 5");
+
+ // TabShape QTabWidget::tabShape()
+ // void QTabWidget::setTabShape(TabShape)
+ obj1.setTabShape(QTabWidget::TabShape(QTabWidget::Rounded));
+ QCOMPARE(QTabWidget::TabShape(QTabWidget::Rounded), obj1.tabShape());
+ obj1.setTabShape(QTabWidget::TabShape(QTabWidget::Triangular));
+ QCOMPARE(QTabWidget::TabShape(QTabWidget::Triangular), obj1.tabShape());
+
+ // int QTabWidget::currentIndex()
+ // void QTabWidget::setCurrentIndex(int)
+ obj1.setCurrentIndex(0);
+ QCOMPARE(0, obj1.currentIndex());
+ obj1.setCurrentIndex(INT_MIN);
+ QCOMPARE(0, obj1.currentIndex());
+ obj1.setCurrentIndex(INT_MAX);
+ QCOMPARE(0, obj1.currentIndex());
+ obj1.setCurrentIndex(4);
+ QCOMPARE(4, obj1.currentIndex());
+
+ // QWidget * QTabWidget::currentWidget()
+ // void QTabWidget::setCurrentWidget(QWidget *)
+ obj1.setCurrentWidget(w1);
+ QCOMPARE(w1, obj1.currentWidget());
+ obj1.setCurrentWidget(w5);
+ QCOMPARE(w5, obj1.currentWidget());
+ obj1.setCurrentWidget((QWidget *)0);
+ QCOMPARE(w5, obj1.currentWidget()); // current not changed
+}
+
+tst_QTabWidget::tst_QTabWidget()
+{
+}
+
+void tst_QTabWidget::init()
+{
+ tw = new QTabWidget(0);
+ QCOMPARE(tw->count(), 0);
+ QCOMPARE(tw->currentIndex(), -1);
+ QVERIFY(tw->currentWidget() == NULL);
+}
+
+void tst_QTabWidget::cleanup()
+{
+ delete tw;
+ tw = 0;
+}
+
+void tst_QTabWidget::testChild()
+{
+ QTabWidgetChild t;
+}
+
+#define LABEL "TEST"
+#define TIP "TIP"
+int tst_QTabWidget::addPage()
+{
+ QWidget *w = new QWidget();
+ return tw->addTab(w, LABEL);
+}
+
+void tst_QTabWidget::removePage(int index)
+{
+ QWidget *w = tw->widget(index);
+ tw->removeTab(index);
+ delete w;
+}
+
+/**
+ * Tests:
+ * addTab(...) which really calls -> insertTab(...)
+ * widget(...)
+ * removeTab(...);
+ * If this fails then many others probably will too.
+ */
+void tst_QTabWidget::addRemoveTab()
+{
+ // Test bad arguments
+ tw->addTab(NULL, LABEL);
+ QCOMPARE(tw->count(), 0);
+ tw->removeTab(-1);
+ QCOMPARE(tw->count(), 0);
+ QVERIFY(tw->widget(-1) == 0);
+
+ QWidget *w = new QWidget();
+ int index = tw->addTab(w, LABEL);
+ // return value
+ QCOMPARE(tw->indexOf(w), index);
+
+ QCOMPARE(tw->count(), 1);
+ QVERIFY(tw->widget(index) == w);
+ QCOMPARE(tw->tabText(index), QString(LABEL));
+
+ removePage(index);
+ QCOMPARE(tw->count(), 0);
+}
+
+void tst_QTabWidget::tabPosition()
+{
+ tw->setTabPosition(QTabWidget::North);
+ QCOMPARE(tw->tabPosition(), QTabWidget::North);
+ tw->setTabPosition(QTabWidget::South);
+ QCOMPARE(tw->tabPosition(), QTabWidget::South);
+ tw->setTabPosition(QTabWidget::East);
+ QCOMPARE(tw->tabPosition(), QTabWidget::East);
+ tw->setTabPosition(QTabWidget::West);
+ QCOMPARE(tw->tabPosition(), QTabWidget::West);
+}
+
+void tst_QTabWidget::tabEnabled()
+{
+ // Test bad arguments
+ QVERIFY(tw->isTabEnabled(-1) == false);
+ tw->setTabEnabled(-1, false);
+
+ int index = addPage();
+
+ tw->setTabEnabled(index, true);
+ QVERIFY(tw->isTabEnabled(index));
+ QVERIFY(tw->widget(index)->isEnabled());
+ tw->setTabEnabled(index, false);
+ QVERIFY(!tw->isTabEnabled(index));
+ QVERIFY(!tw->widget(index)->isEnabled());
+ tw->setTabEnabled(index, true);
+ QVERIFY(tw->isTabEnabled(index));
+ QVERIFY(tw->widget(index)->isEnabled());
+
+ removePage(index);
+}
+
+void tst_QTabWidget::tabText()
+{
+ // Test bad arguments
+ QCOMPARE(tw->tabText(-1), QString(""));
+ tw->setTabText(-1, LABEL);
+
+ int index = addPage();
+
+ tw->setTabText(index, "new");
+ QCOMPARE(tw->tabText(index), QString("new"));
+ tw->setTabText(index, LABEL);
+ QCOMPARE(tw->tabText(index), QString(LABEL));
+
+ removePage(index);
+}
+
+void tst_QTabWidget::tabShape()
+{
+ int index = addPage();
+
+ tw->setTabShape(QTabWidget::Rounded);
+ QCOMPARE(tw->tabShape(), QTabWidget::Rounded);
+ tw->setTabShape(QTabWidget::Triangular);
+ QCOMPARE(tw->tabShape(), QTabWidget::Triangular);
+ tw->setTabShape(QTabWidget::Rounded);
+ QCOMPARE(tw->tabShape(), QTabWidget::Rounded);
+
+ removePage(index);
+}
+
+void tst_QTabWidget::tabTooltip()
+{
+ // Test bad arguments
+ QCOMPARE(tw->tabToolTip(-1), QString(""));
+ tw->setTabText(-1, TIP);
+
+ int index = addPage();
+
+ tw->setTabToolTip(index, "tip");
+ QCOMPARE(tw->tabToolTip(index), QString("tip"));
+ tw->setTabToolTip(index, TIP);
+ QCOMPARE(tw->tabToolTip(index), QString(TIP));
+
+ removePage(index);
+}
+
+void tst_QTabWidget::tabIcon()
+{
+ // Test bad arguments
+ QVERIFY(tw->tabToolTip(-1).isNull());
+ tw->setTabIcon(-1, QIcon());
+
+ int index = addPage();
+
+ QIcon icon;
+ tw->setTabIcon(index, icon);
+ QVERIFY(tw->tabIcon(index).isNull());
+
+ removePage(index);
+}
+
+void tst_QTabWidget::indexOf()
+{
+ // Test bad arguments
+ QCOMPARE(tw->indexOf(NULL), -1);
+
+ int index = addPage();
+ QWidget *w = tw->widget(index);
+ QCOMPARE(tw->indexOf(w), index);
+
+ removePage(index);
+}
+
+void tst_QTabWidget::currentWidget()
+{
+ // Test bad arguments
+ tw->setCurrentWidget(NULL);
+ QVERIFY(tw->currentWidget() == NULL);
+
+ int index = addPage();
+ QWidget *w = tw->widget(index);
+ QVERIFY(tw->currentWidget() == w);
+ QCOMPARE(tw->currentIndex(), index);
+
+ tw->setCurrentWidget(NULL);
+ QVERIFY(tw->currentWidget() == w);
+ QCOMPARE(tw->currentIndex(), index);
+
+ int index2 = addPage();
+ QWidget *w2 = tw->widget(index2);
+ Q_UNUSED(w2);
+ QVERIFY(tw->currentWidget() == w);
+ QCOMPARE(tw->currentIndex(), index);
+
+ removePage(index2);
+ removePage(index);
+}
+
+/**
+ * setCurrentWidget(..) calls setCurrentIndex(..)
+ * currentChanged(..) SIGNAL
+ */
+void tst_QTabWidget::currentIndex()
+{
+ // Test bad arguments
+ QSignalSpy spy(tw, SIGNAL(currentChanged(int)));
+ QCOMPARE(tw->currentIndex(), -1);
+ tw->setCurrentIndex(-1);
+ QCOMPARE(tw->currentIndex(), -1);
+ QCOMPARE(spy.count(), 0);
+
+ int firstIndex = addPage();
+ tw->setCurrentIndex(firstIndex);
+ QCOMPARE(tw->currentIndex(), firstIndex);
+ QCOMPARE(spy.count(), 1);
+ QList<QVariant> arguments = spy.takeFirst();
+ QVERIFY(arguments.at(0).toInt() == firstIndex);
+
+ int index = addPage();
+ QCOMPARE(tw->currentIndex(), firstIndex);
+ tw->setCurrentIndex(index);
+ QCOMPARE(tw->currentIndex(), index);
+ QCOMPARE(spy.count(), 1);
+ arguments = spy.takeFirst();
+ QVERIFY(arguments.at(0).toInt() == index);
+
+ removePage(index);
+ QCOMPARE(tw->currentIndex(), firstIndex);
+ QCOMPARE(spy.count(), 1);
+ arguments = spy.takeFirst();
+ QVERIFY(arguments.at(0).toInt() == firstIndex);
+
+ removePage(firstIndex);
+ QCOMPARE(tw->currentIndex(), -1);
+ QCOMPARE(spy.count(), 1);
+ arguments = spy.takeFirst();
+ QVERIFY(arguments.at(0).toInt() == -1);
+}
+
+void tst_QTabWidget::cornerWidget()
+{
+ // Test bad arguments
+ tw->setCornerWidget(NULL, Qt::TopRightCorner);
+
+ QVERIFY(tw->cornerWidget(Qt::TopLeftCorner) == 0);
+ QVERIFY(tw->cornerWidget(Qt::TopRightCorner) == 0);
+ QVERIFY(tw->cornerWidget(Qt::BottomLeftCorner) == 0);
+ QVERIFY(tw->cornerWidget(Qt::BottomRightCorner) == 0);
+
+ QWidget *w = new QWidget(0);
+ tw->setCornerWidget(w, Qt::TopLeftCorner);
+ QCOMPARE(w->parent(), (QObject *)tw);
+ QVERIFY(tw->cornerWidget(Qt::TopLeftCorner) == w);
+ tw->setCornerWidget(w, Qt::TopRightCorner);
+ QVERIFY(tw->cornerWidget(Qt::TopRightCorner) == w);
+ tw->setCornerWidget(w, Qt::BottomLeftCorner);
+ QVERIFY(tw->cornerWidget(Qt::BottomLeftCorner) == w);
+ tw->setCornerWidget(w, Qt::BottomRightCorner);
+ QVERIFY(tw->cornerWidget(Qt::BottomRightCorner) == w);
+
+ tw->setCornerWidget(0, Qt::TopRightCorner);
+ QVERIFY(tw->cornerWidget(Qt::TopRightCorner) == 0);
+ QCOMPARE(w->isHidden(), true);
+}
+
+//test that the QTabWidget::count() is correct at the moment the currentChanged signal is emit
+class RemoveTabObject : public QObject
+{
+ Q_OBJECT
+ public:
+ RemoveTabObject(QTabWidget *_tw) : tw(_tw), count(-1) {
+ connect(tw, SIGNAL(currentChanged(int)), this, SLOT(currentChanged()));
+ }
+
+ QTabWidget *tw;
+ int count;
+ public slots:
+ void currentChanged() { count = tw->count(); }
+};
+
+void tst_QTabWidget::removeTab()
+{
+ tw->show();
+ QCOMPARE(tw->count(), 0);
+ RemoveTabObject ob(tw);
+ tw->addTab(new QLabel("1"), "1");
+ QCOMPARE(ob.count, 1);
+ tw->addTab(new QLabel("2"), "2");
+ tw->addTab(new QLabel("3"), "3");
+ tw->addTab(new QLabel("4"), "4");
+ tw->addTab(new QLabel("5"), "5");
+ QCOMPARE(ob.count, 1);
+ QCOMPARE(tw->count(), 5);
+
+ tw->setCurrentIndex(4);
+ QCOMPARE(ob.count,5);
+ tw->removeTab(4);
+ QCOMPARE(ob.count, 4);
+ QCOMPARE(tw->count(), 4);
+ QCOMPARE(tw->currentIndex(), 3);
+
+ tw->setCurrentIndex(1);
+ tw->removeTab(1);
+ QCOMPARE(ob.count, 3);
+ QCOMPARE(tw->count(), 3);
+ QCOMPARE(tw->currentIndex(), 1);
+
+ delete tw->widget(1);
+ QCOMPARE(tw->count(), 2);
+ QCOMPARE(ob.count, 2);
+ QCOMPARE(tw->currentIndex(), 1);
+ delete tw->widget(1);
+ QCOMPARE(tw->count(), 1);
+ QCOMPARE(ob.count, 1);
+ tw->removeTab(0);
+ QCOMPARE(tw->count(), 0);
+ QCOMPARE(ob.count, 0);
+}
+
+void tst_QTabWidget::clear()
+{
+ tw->addTab(new QWidget, "1");
+ tw->addTab(new QWidget, "2");
+ tw->addTab(new QWidget, "3");
+ tw->addTab(new QWidget, "4");
+ tw->addTab(new QWidget, "5");
+ tw->setCurrentIndex(4);
+ tw->clear();
+ QCOMPARE(tw->count(), 0);
+ QCOMPARE(tw->currentIndex(), -1);
+}
+
+void tst_QTabWidget::keyboardNavigation()
+{
+ int firstIndex = addPage();
+ addPage();
+ addPage();
+ tw->setCurrentIndex(firstIndex);
+ QCOMPARE(tw->currentIndex(), firstIndex);
+
+ QTest::keyClick(tw, Qt::Key_Tab, Qt::ControlModifier);
+ QCOMPARE(tw->currentIndex(), 1);
+ QTest::keyClick(tw, Qt::Key_Tab, Qt::ControlModifier);
+ QCOMPARE(tw->currentIndex(), 2);
+ QTest::keyClick(tw, Qt::Key_Tab, Qt::ControlModifier);
+ QCOMPARE(tw->currentIndex(), 0);
+ tw->setTabEnabled(1, false);
+ QTest::keyClick(tw, Qt::Key_Tab, Qt::ControlModifier);
+ QCOMPARE(tw->currentIndex(), 2);
+
+ QTest::keyClick(tw, Qt::Key_Tab, Qt::ControlModifier | Qt::ShiftModifier);
+ QCOMPARE(tw->currentIndex(), 0);
+ QTest::keyClick(tw, Qt::Key_Tab, Qt::ControlModifier | Qt::ShiftModifier);
+ QCOMPARE(tw->currentIndex(), 2);
+ tw->setTabEnabled(1, true);
+ QTest::keyClick(tw, Qt::Key_Tab, Qt::ControlModifier | Qt::ShiftModifier);
+ QCOMPARE(tw->currentIndex(), 1);
+ QTest::keyClick(tw, Qt::Key_Tab, Qt::ControlModifier | Qt::ShiftModifier);
+ QCOMPARE(tw->currentIndex(), 0);
+ QTest::keyClick(tw, Qt::Key_Tab, Qt::ControlModifier | Qt::ShiftModifier);
+ QCOMPARE(tw->currentIndex(), 2);
+ QTest::keyClick(tw, Qt::Key_Tab, Qt::ControlModifier);
+ QCOMPARE(tw->currentIndex(), 0);
+
+ // Disable all and try to go to the next. It should not move anywhere, and more importantly
+ // it should not loop forever. (a naive "search for the first enabled tabbar") implementation
+ // might do that)
+ tw->setTabEnabled(0, false);
+ tw->setTabEnabled(1, false);
+ tw->setTabEnabled(2, false);
+ QTest::keyClick(tw, Qt::Key_Tab, Qt::ControlModifier);
+ // TODO: Disabling the current tab will move current tab to the next,
+ // but what if next tab is also disabled. We should look into this.
+ QVERIFY(tw->currentIndex() < 3 && tw->currentIndex() >= 0);
+}
+
+class PaintCounter : public QWidget
+{
+public:
+ PaintCounter() :count(0) { setAttribute(Qt::WA_OpaquePaintEvent); }
+ int count;
+protected:
+ void paintEvent(QPaintEvent*) {
+ ++count;
+ }
+};
+
+
+void tst_QTabWidget::paintEventCount()
+{
+ Q_CHECK_PAINTEVENTS
+
+ PaintCounter *tab1 = new PaintCounter;
+ PaintCounter *tab2 = new PaintCounter;
+
+ tw->addTab(tab1, "one");
+ tw->addTab(tab2, "two");
+
+ QCOMPARE(tab1->count, 0);
+ QCOMPARE(tab2->count, 0);
+ QCOMPARE(tw->currentIndex(), 0);
+
+ tw->show();
+
+ QTest::qWait(1000);
+
+ // Mac, Windows and Windows CE get multiple repaints on the first show, so use those as a starting point.
+ static const int MaxInitialPaintCount =
+#if defined(Q_OS_WINCE)
+ 4;
+#elif defined(Q_WS_WIN)
+ 2;
+#elif defined(Q_WS_MAC)
+ 5;
+#else
+ 2;
+#endif
+ QVERIFY(tab1->count <= MaxInitialPaintCount);
+ QCOMPARE(tab2->count, 0);
+
+ const int initalPaintCount = tab1->count;
+
+ tw->setCurrentIndex(1);
+
+ QTest::qWait(100);
+
+ QCOMPARE(tab1->count, initalPaintCount);
+ QCOMPARE(tab2->count, 1);
+
+ tw->setCurrentIndex(0);
+
+ QTest::qWait(100);
+
+ QCOMPARE(tab1->count, initalPaintCount + 1);
+ QCOMPARE(tab2->count, 1);
+}
+
+void tst_QTabWidget::minimumSizeHint()
+{
+ QTabWidget tw;
+ QWidget *page = new QWidget;
+ QVBoxLayout *lay = new QVBoxLayout;
+
+ QLabel *label = new QLabel(QLatin1String("XXgypq lorem ipsum must be long, must be long. lorem ipsumMMMW"));
+ lay->addWidget(label);
+
+ page->setLayout(lay);
+
+ tw.addTab(page, QLatin1String("page1"));
+
+ tw.show();
+ QTest::qWaitForWindowShown(&tw);
+ tw.resize(tw.minimumSizeHint());
+
+ QSize minSize = label->minimumSizeHint();
+ QSize actSize = label->geometry().size();
+ QVERIFY(minSize.width() <= actSize.width());
+ QVERIFY(minSize.height() <= actSize.height());
+}
+
+void tst_QTabWidget::heightForWidth_data()
+{
+ QTest::addColumn<int>("tabPosition");
+ QTest::newRow("West") << int(QTabWidget::West);
+ QTest::newRow("North") << int(QTabWidget::North);
+ QTest::newRow("East") << int(QTabWidget::East);
+ QTest::newRow("South") << int(QTabWidget::South);
+}
+
+void tst_QTabWidget::heightForWidth()
+{
+ QFETCH(int, tabPosition);
+
+ QWidget *window = new QWidget;
+ QVBoxLayout *lay = new QVBoxLayout(window);
+ lay->setMargin(0);
+ lay->setSpacing(0);
+ QTabWidget *tabWid = new QTabWidget(window);
+ QWidget *w = new QWidget;
+ tabWid->addTab(w, QLatin1String("HFW page"));
+ tabWid->setTabPosition(QTabWidget::TabPosition(tabPosition));
+ QVBoxLayout *lay2 = new QVBoxLayout(w);
+ QLabel *label = new QLabel("Label with wordwrap turned on makes it trade height for width."
+ " Make it a really long text so that it spans on several lines"
+ " when the label is on its narrowest."
+ " I don't like to repeat myself."
+ " I don't like to repeat myself."
+ " I don't like to repeat myself."
+ " I don't like to repeat myself."
+ );
+ label->setWordWrap(true);
+ lay2->addWidget(label);
+ lay2->setMargin(0);
+
+ lay->addWidget(tabWid);
+ int h = window->heightForWidth(160);
+ window->resize(160, h);
+ window->show();
+
+ QTest::qWaitForWindowShown(window);
+ QVERIFY(label->height() >= label->heightForWidth(label->width()));
+
+ delete window;
+}
+
+
+QTEST_MAIN(tst_QTabWidget)
+#include "tst_qtabwidget.moc"
diff --git a/tests/auto/widgets/widgets/qtextbrowser/.gitignore b/tests/auto/widgets/widgets/qtextbrowser/.gitignore
new file mode 100644
index 0000000000..1ec6f00de1
--- /dev/null
+++ b/tests/auto/widgets/widgets/qtextbrowser/.gitignore
@@ -0,0 +1 @@
+tst_qtextbrowser
diff --git a/tests/auto/widgets/widgets/qtextbrowser/anchor.html b/tests/auto/widgets/widgets/qtextbrowser/anchor.html
new file mode 100644
index 0000000000..e347a2bb4c
--- /dev/null
+++ b/tests/auto/widgets/widgets/qtextbrowser/anchor.html
@@ -0,0 +1,11 @@
+<html>
+<head>
+<title>Sample Anchor</title>
+</head>
+<body>
+<p><a href="file.html#anchor">Click Me!</a></p>
+<p>
+<a name="jumphere"></a>Here's a destination to jump to.
+</p>
+</body>
+</html>
diff --git a/tests/auto/widgets/widgets/qtextbrowser/bigpage.html b/tests/auto/widgets/widgets/qtextbrowser/bigpage.html
new file mode 100644
index 0000000000..125c7a096e
--- /dev/null
+++ b/tests/auto/widgets/widgets/qtextbrowser/bigpage.html
@@ -0,0 +1,934 @@
+<html><body>
+<p>
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+Blah blah blah blah blah blah blah blah blah
+</p>
+<p id="id-anchor">Paragraph with id</p>
+<a name="bottom"></a>Here's the bottom of the page.
+</body></html>
diff --git a/tests/auto/widgets/widgets/qtextbrowser/firstpage.html b/tests/auto/widgets/widgets/qtextbrowser/firstpage.html
new file mode 100644
index 0000000000..fa35fce92c
--- /dev/null
+++ b/tests/auto/widgets/widgets/qtextbrowser/firstpage.html
@@ -0,0 +1,2 @@
+<p> Blah blah <a href="secondpage.html">Link to second page</a> blah
+<p> Another link here: <a href="thirdpage.html">Link to third page</a>
diff --git a/tests/auto/widgets/widgets/qtextbrowser/pagewithbg.html b/tests/auto/widgets/widgets/qtextbrowser/pagewithbg.html
new file mode 100644
index 0000000000..07609a2b06
--- /dev/null
+++ b/tests/auto/widgets/widgets/qtextbrowser/pagewithbg.html
@@ -0,0 +1 @@
+<html><title>Page With BG</title><body bgcolor="blue">This page has a blue background</body></html>
diff --git a/tests/auto/widgets/widgets/qtextbrowser/pagewithimage.html b/tests/auto/widgets/widgets/qtextbrowser/pagewithimage.html
new file mode 100644
index 0000000000..49060d3792
--- /dev/null
+++ b/tests/auto/widgets/widgets/qtextbrowser/pagewithimage.html
@@ -0,0 +1 @@
+<p><img src="foobar.png"/></p>
diff --git a/tests/auto/widgets/widgets/qtextbrowser/pagewithoutbg.html b/tests/auto/widgets/widgets/qtextbrowser/pagewithoutbg.html
new file mode 100644
index 0000000000..5a7f9f592b
--- /dev/null
+++ b/tests/auto/widgets/widgets/qtextbrowser/pagewithoutbg.html
@@ -0,0 +1 @@
+<html><body>This page has no background color</body></html>
diff --git a/tests/auto/widgets/widgets/qtextbrowser/qtextbrowser.pro b/tests/auto/widgets/widgets/qtextbrowser/qtextbrowser.pro
new file mode 100644
index 0000000000..ae5177686b
--- /dev/null
+++ b/tests/auto/widgets/widgets/qtextbrowser/qtextbrowser.pro
@@ -0,0 +1,15 @@
+load(qttest_p4)
+SOURCES += tst_qtextbrowser.cpp
+DEFINES += SRCDIR=\\\"$$PWD\\\"
+
+QT += widgets
+
+wince* {
+ addFiles.files = *.html
+ addFiles.path = .
+ addDir.files = subdir/*
+ addDir.path = subdir
+ DEPLOYMENT += addFiles addDir
+}
+
+CONFIG+=insignificant_test
diff --git a/tests/auto/widgets/widgets/qtextbrowser/secondpage.html b/tests/auto/widgets/widgets/qtextbrowser/secondpage.html
new file mode 100644
index 0000000000..39018a71b2
--- /dev/null
+++ b/tests/auto/widgets/widgets/qtextbrowser/secondpage.html
@@ -0,0 +1 @@
+<p>blub blub <a href="thirdpage.html">Link to third page from second page</a>
diff --git a/tests/auto/widgets/widgets/qtextbrowser/subdir/index.html b/tests/auto/widgets/widgets/qtextbrowser/subdir/index.html
new file mode 100644
index 0000000000..95593cc925
--- /dev/null
+++ b/tests/auto/widgets/widgets/qtextbrowser/subdir/index.html
@@ -0,0 +1 @@
+This is a dummy, do not remove me!
diff --git a/tests/auto/widgets/widgets/qtextbrowser/thirdpage.html b/tests/auto/widgets/widgets/qtextbrowser/thirdpage.html
new file mode 100644
index 0000000000..215dc08aa0
--- /dev/null
+++ b/tests/auto/widgets/widgets/qtextbrowser/thirdpage.html
@@ -0,0 +1 @@
+<p>this is the third page...
diff --git a/tests/auto/widgets/widgets/qtextbrowser/tst_qtextbrowser.cpp b/tests/auto/widgets/widgets/qtextbrowser/tst_qtextbrowser.cpp
new file mode 100644
index 0000000000..a1592e5e2b
--- /dev/null
+++ b/tests/auto/widgets/widgets/qtextbrowser/tst_qtextbrowser.cpp
@@ -0,0 +1,672 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#include <QtTest/QtTest>
+#include <qtextbrowser.h>
+#include <qdatetime.h>
+#include <qapplication.h>
+#include <qscrollbar.h>
+
+#include <qtextbrowser.h>
+#include <qtextobject.h>
+
+//TESTED_CLASS=
+//TESTED_FILES=
+
+class TestBrowser : public QTextBrowser
+{
+public:
+ inline TestBrowser() : htmlLoadAttempts(0) {
+ show();
+ QApplication::setActiveWindow(this);
+ QTest::qWaitForWindowShown(this);
+ activateWindow();
+ setFocus();
+ QTest::qWait(50);
+ QTRY_VERIFY(hasFocus());
+ }
+
+ virtual QVariant loadResource(int type, const QUrl &name);
+
+ int htmlLoadAttempts;
+ QUrl lastResource;
+ QUrl sourceInsideLoadResource;
+};
+
+QVariant TestBrowser::loadResource(int type, const QUrl &name)
+{
+ if (type == QTextDocument::HtmlResource)
+ htmlLoadAttempts++;
+ lastResource = name;
+ sourceInsideLoadResource = source();
+ return QTextBrowser::loadResource(type, name);
+}
+
+class tst_QTextBrowser : public QObject
+{
+ Q_OBJECT
+public:
+ tst_QTextBrowser();
+ virtual ~tst_QTextBrowser();
+
+public slots:
+ void init();
+ void cleanup();
+
+private slots:
+ void noReloadOnAnchorJump();
+ void bgColorOnSourceChange();
+ void forwardButton();
+ void viewportPositionInHistory();
+ void relativeLinks();
+ void anchors();
+ void resourceAutoDetection();
+ void forwardBackwardAvailable();
+ void clearHistory();
+ void sourceInsideLoadResource();
+ void textInteractionFlags_vs_readOnly();
+ void anchorsWithSelfBuiltHtml();
+ void relativeNonLocalUrls();
+ void adjacentAnchors();
+ void loadResourceOnRelativeLocalFiles();
+ void focusIndicator();
+ void focusHistory();
+ void urlEncoding();
+
+private:
+ TestBrowser *browser;
+};
+
+tst_QTextBrowser::tst_QTextBrowser()
+{
+}
+
+tst_QTextBrowser::~tst_QTextBrowser()
+{
+}
+void tst_QTextBrowser::init()
+{
+#if !defined(Q_OS_IRIX) && !defined(Q_OS_WINCE)
+ QDir::setCurrent(SRCDIR);
+#endif
+ browser = new TestBrowser;
+ browser->show();
+}
+
+void tst_QTextBrowser::cleanup()
+{
+ delete browser;
+ browser = 0;
+}
+
+void tst_QTextBrowser::noReloadOnAnchorJump()
+{
+ QUrl url("anchor.html");
+
+ browser->htmlLoadAttempts = 0;
+ browser->setSource(url);
+ QCOMPARE(browser->htmlLoadAttempts, 1);
+ QVERIFY(!browser->toPlainText().isEmpty());
+
+ url.setFragment("jumphere"); // anchor.html#jumphere
+ browser->setSource(url);
+ QCOMPARE(browser->htmlLoadAttempts, 1);
+ QVERIFY(!browser->toPlainText().isEmpty());
+ QVERIFY(browser->source() == url);
+}
+
+void tst_QTextBrowser::bgColorOnSourceChange()
+{
+ browser->setSource(QUrl("pagewithbg.html"));
+ QVERIFY(browser->document()->rootFrame()->frameFormat().hasProperty(QTextFormat::BackgroundBrush));
+ QVERIFY(browser->document()->rootFrame()->frameFormat().background().color() == Qt::blue);
+
+ browser->setSource(QUrl("pagewithoutbg.html"));
+ QVERIFY(!browser->document()->rootFrame()->frameFormat().hasProperty(QTextFormat::BackgroundBrush));
+}
+
+void tst_QTextBrowser::forwardButton()
+{
+ QSignalSpy forwardEmissions(browser, SIGNAL(forwardAvailable(bool)));
+ QSignalSpy backwardEmissions(browser, SIGNAL(backwardAvailable(bool)));
+
+ QVERIFY(browser->historyTitle(-1).isEmpty());
+ QVERIFY(browser->historyTitle(0).isEmpty());
+ QVERIFY(browser->historyTitle(1).isEmpty());
+
+ browser->setSource(QUrl("pagewithbg.html"));
+
+ QVERIFY(!forwardEmissions.isEmpty());
+ QVariant val = forwardEmissions.takeLast()[0];
+ QVERIFY(val.type() == QVariant::Bool);
+ QVERIFY(val.toBool() == false);
+
+ QVERIFY(!backwardEmissions.isEmpty());
+ val = backwardEmissions.takeLast()[0];
+ QVERIFY(val.type() == QVariant::Bool);
+ QVERIFY(val.toBool() == false);
+
+ QVERIFY(browser->historyTitle(-1).isEmpty());
+ QCOMPARE(browser->historyUrl(0), QUrl("pagewithbg.html"));
+ QCOMPARE(browser->documentTitle(), QString("Page With BG"));
+ QCOMPARE(browser->historyTitle(0), QString("Page With BG"));
+ QVERIFY(browser->historyTitle(1).isEmpty());
+
+ browser->setSource(QUrl("anchor.html"));
+
+ QVERIFY(!forwardEmissions.isEmpty());
+ val = forwardEmissions.takeLast()[0];
+ QVERIFY(val.type() == QVariant::Bool);
+ QVERIFY(val.toBool() == false);
+
+ QVERIFY(!backwardEmissions.isEmpty());
+ val = backwardEmissions.takeLast()[0];
+ QVERIFY(val.type() == QVariant::Bool);
+ QVERIFY(val.toBool() == true);
+
+ QCOMPARE(browser->historyTitle(-1), QString("Page With BG"));
+ QCOMPARE(browser->historyTitle(0), QString("Sample Anchor"));
+ QVERIFY(browser->historyTitle(1).isEmpty());
+
+ browser->backward();
+
+ QVERIFY(!forwardEmissions.isEmpty());
+ val = forwardEmissions.takeLast()[0];
+ QVERIFY(val.type() == QVariant::Bool);
+ QVERIFY(val.toBool() == true);
+
+ QVERIFY(!backwardEmissions.isEmpty());
+ val = backwardEmissions.takeLast()[0];
+ QVERIFY(val.type() == QVariant::Bool);
+ QVERIFY(val.toBool() == false);
+
+ QVERIFY(browser->historyTitle(-1).isEmpty());
+ QCOMPARE(browser->historyTitle(0), QString("Page With BG"));
+ QCOMPARE(browser->historyTitle(1), QString("Sample Anchor"));
+
+ browser->setSource(QUrl("pagewithoutbg.html"));
+
+ QVERIFY(!forwardEmissions.isEmpty());
+ val = forwardEmissions.takeLast()[0];
+ QVERIFY(val.type() == QVariant::Bool);
+ QVERIFY(val.toBool() == false);
+
+ QVERIFY(!backwardEmissions.isEmpty());
+ val = backwardEmissions.takeLast()[0];
+ QVERIFY(val.type() == QVariant::Bool);
+ QVERIFY(val.toBool() == true);
+}
+
+void tst_QTextBrowser::viewportPositionInHistory()
+{
+ browser->setSource(QUrl("bigpage.html"));
+ browser->scrollToAnchor("bottom");
+ QVERIFY(browser->verticalScrollBar()->value() > 0);
+
+ browser->setSource(QUrl("pagewithbg.html"));
+ QCOMPARE(browser->verticalScrollBar()->value(), 0);
+
+ browser->backward();
+ QVERIFY(browser->verticalScrollBar()->value() > 0);
+}
+
+void tst_QTextBrowser::relativeLinks()
+{
+ qRegisterMetaType<QUrl>("QUrl");
+ QSignalSpy sourceChangedSpy(browser, SIGNAL(sourceChanged(const QUrl &)));
+ browser->setSource(QUrl("../qtextbrowser.html"));
+ QVERIFY(sourceChangedSpy.count() == 1);
+ QCOMPARE(sourceChangedSpy.takeFirst()[0].toUrl(), QUrl("../qtextbrowser.html"));
+ browser->setSource(QUrl("qtextbrowser/subdir/index.html"));
+ QVERIFY(sourceChangedSpy.count() == 1);
+ QCOMPARE(sourceChangedSpy.takeFirst()[0].toUrl(), QUrl("qtextbrowser/subdir/index.html"));
+ browser->setSource(QUrl("../anchor.html"));
+ QVERIFY(sourceChangedSpy.count() == 1);
+ QCOMPARE(sourceChangedSpy.takeFirst()[0].toUrl(), QUrl("../anchor.html"));
+ browser->setSource(QUrl("subdir/index.html"));
+ QVERIFY(sourceChangedSpy.count() == 1);
+ QCOMPARE(sourceChangedSpy.takeFirst()[0].toUrl(), QUrl("subdir/index.html"));
+
+ // using QUrl::fromLocalFile()
+ browser->setSource(QUrl::fromLocalFile("anchor.html"));
+ QVERIFY(sourceChangedSpy.count() == 1);
+ QCOMPARE(sourceChangedSpy.takeFirst()[0].toUrl(), QUrl("file:anchor.html"));
+ browser->setSource(QUrl("../qtextbrowser.html"));
+ QVERIFY(sourceChangedSpy.count() == 1);
+ QCOMPARE(sourceChangedSpy.takeFirst()[0].toUrl(), QUrl("../qtextbrowser.html"));
+}
+
+void tst_QTextBrowser::anchors()
+{
+ browser->setSource(QUrl("bigpage.html"));
+ browser->setSource(QUrl("#bottom"));
+ QVERIFY(browser->verticalScrollBar()->value() > 0);
+
+ browser->setSource(QUrl("bigpage.html"));
+ browser->setSource(QUrl("#id-anchor"));
+ QVERIFY(browser->verticalScrollBar()->value() > 0);
+}
+
+void tst_QTextBrowser::resourceAutoDetection()
+{
+ browser->setHtml("<img src=\":/some/resource\"/>");
+ QCOMPARE(browser->lastResource.toString(), QString("qrc:/some/resource"));
+}
+
+void tst_QTextBrowser::forwardBackwardAvailable()
+{
+ QSignalSpy backwardSpy(browser, SIGNAL(backwardAvailable(bool)));
+ QSignalSpy forwardSpy(browser, SIGNAL(forwardAvailable(bool)));
+
+ QVERIFY(!browser->isBackwardAvailable());
+ QVERIFY(!browser->isForwardAvailable());
+
+ browser->setSource(QUrl("anchor.html"));
+ QVERIFY(!browser->isBackwardAvailable());
+ QVERIFY(!browser->isForwardAvailable());
+ QCOMPARE(backwardSpy.count(), 1);
+ QVERIFY(!backwardSpy.at(0).at(0).toBool());
+ QCOMPARE(forwardSpy.count(), 1);
+ QVERIFY(!forwardSpy.at(0).at(0).toBool());
+
+ backwardSpy.clear();
+ forwardSpy.clear();
+
+ browser->setSource(QUrl("bigpage.html"));
+ QVERIFY(browser->isBackwardAvailable());
+ QVERIFY(!browser->isForwardAvailable());
+ QCOMPARE(backwardSpy.count(), 1);
+ QVERIFY(backwardSpy.at(0).at(0).toBool());
+ QCOMPARE(forwardSpy.count(), 1);
+ QVERIFY(!forwardSpy.at(0).at(0).toBool());
+
+ backwardSpy.clear();
+ forwardSpy.clear();
+
+ browser->setSource(QUrl("pagewithbg.html"));
+ QVERIFY(browser->isBackwardAvailable());
+ QVERIFY(!browser->isForwardAvailable());
+ QCOMPARE(backwardSpy.count(), 1);
+ QVERIFY(backwardSpy.at(0).at(0).toBool());
+ QCOMPARE(forwardSpy.count(), 1);
+ QVERIFY(!forwardSpy.at(0).at(0).toBool());
+
+ backwardSpy.clear();
+ forwardSpy.clear();
+
+ browser->backward();
+ QVERIFY(browser->isBackwardAvailable());
+ QVERIFY(browser->isForwardAvailable());
+ QCOMPARE(backwardSpy.count(), 1);
+ QVERIFY(backwardSpy.at(0).at(0).toBool());
+ QCOMPARE(forwardSpy.count(), 1);
+ QVERIFY(forwardSpy.at(0).at(0).toBool());
+
+ backwardSpy.clear();
+ forwardSpy.clear();
+
+ browser->backward();
+ QVERIFY(!browser->isBackwardAvailable());
+ QVERIFY(browser->isForwardAvailable());
+ QCOMPARE(backwardSpy.count(), 1);
+ QVERIFY(!backwardSpy.at(0).at(0).toBool());
+ QCOMPARE(forwardSpy.count(), 1);
+ QVERIFY(forwardSpy.at(0).at(0).toBool());
+
+ backwardSpy.clear();
+ forwardSpy.clear();
+
+ browser->forward();
+ QVERIFY(browser->isBackwardAvailable());
+ QVERIFY(browser->isForwardAvailable());
+ QCOMPARE(backwardSpy.count(), 1);
+ QVERIFY(backwardSpy.at(0).at(0).toBool());
+ QCOMPARE(forwardSpy.count(), 1);
+ QVERIFY(forwardSpy.at(0).at(0).toBool());
+
+ backwardSpy.clear();
+ forwardSpy.clear();
+
+ browser->forward();
+ QVERIFY(browser->isBackwardAvailable());
+ QVERIFY(!browser->isForwardAvailable());
+ QCOMPARE(backwardSpy.count(), 1);
+ QVERIFY(backwardSpy.at(0).at(0).toBool());
+ QCOMPARE(forwardSpy.count(), 1);
+ QVERIFY(!forwardSpy.at(0).at(0).toBool());
+
+ backwardSpy.clear();
+ forwardSpy.clear();
+}
+
+void tst_QTextBrowser::clearHistory()
+{
+ QSignalSpy backwardSpy(browser, SIGNAL(backwardAvailable(bool)));
+ QSignalSpy forwardSpy(browser, SIGNAL(forwardAvailable(bool)));
+
+ QVERIFY(!browser->isBackwardAvailable());
+ QVERIFY(!browser->isForwardAvailable());
+
+ browser->clearHistory();
+ QVERIFY(!browser->isBackwardAvailable());
+ QVERIFY(!browser->isForwardAvailable());
+ QCOMPARE(backwardSpy.count(), 1);
+ QVERIFY(!backwardSpy.at(0).at(0).toBool());
+ QCOMPARE(forwardSpy.count(), 1);
+ QVERIFY(!forwardSpy.at(0).at(0).toBool());
+ QVERIFY(browser->historyTitle(-1).isEmpty());
+ QVERIFY(browser->historyTitle(0).isEmpty());
+ QVERIFY(browser->historyTitle(1).isEmpty());
+
+ backwardSpy.clear();
+ forwardSpy.clear();
+
+ browser->setSource(QUrl("anchor.html"));
+ QVERIFY(!browser->isBackwardAvailable());
+ QVERIFY(!browser->isForwardAvailable());
+ QCOMPARE(backwardSpy.count(), 1);
+ QVERIFY(!backwardSpy.at(0).at(0).toBool());
+ QCOMPARE(forwardSpy.count(), 1);
+ QVERIFY(!forwardSpy.at(0).at(0).toBool());
+
+ backwardSpy.clear();
+ forwardSpy.clear();
+
+ browser->setSource(QUrl("bigpage.html"));
+ QVERIFY(browser->isBackwardAvailable());
+ QVERIFY(!browser->isForwardAvailable());
+ QCOMPARE(backwardSpy.count(), 1);
+ QVERIFY(backwardSpy.at(0).at(0).toBool());
+ QCOMPARE(forwardSpy.count(), 1);
+ QVERIFY(!forwardSpy.at(0).at(0).toBool());
+
+ backwardSpy.clear();
+ forwardSpy.clear();
+
+ browser->clearHistory();
+ QVERIFY(!browser->isBackwardAvailable());
+ QVERIFY(!browser->isForwardAvailable());
+ QCOMPARE(backwardSpy.count(), 1);
+ QVERIFY(!backwardSpy.at(0).at(0).toBool());
+ QCOMPARE(forwardSpy.count(), 1);
+ QVERIFY(!forwardSpy.at(0).at(0).toBool());
+ QVERIFY(browser->historyTitle(-1).isEmpty());
+ QVERIFY(browser->historyTitle(1).isEmpty());
+
+ QCOMPARE(browser->source(), QUrl("bigpage.html"));
+ browser->backward();
+ QCOMPARE(browser->source(), QUrl("bigpage.html"));
+ browser->home();
+ QCOMPARE(browser->source(), QUrl("bigpage.html"));
+}
+
+void tst_QTextBrowser::sourceInsideLoadResource()
+{
+ QUrl url("pagewithimage.html");
+ browser->setSource(url);
+ QCOMPARE(browser->lastResource.toString(), QUrl::fromLocalFile(QDir::current().filePath("foobar.png")).toString());
+ QEXPECT_FAIL("", "This is currently not supported", Continue);
+ QCOMPARE(browser->sourceInsideLoadResource.toString(), url.toString());
+}
+
+void tst_QTextBrowser::textInteractionFlags_vs_readOnly()
+{
+ QVERIFY(browser->isReadOnly());
+ QVERIFY(browser->textInteractionFlags() == Qt::TextBrowserInteraction);
+ browser->setReadOnly(true);
+ QVERIFY(browser->textInteractionFlags() == Qt::TextBrowserInteraction);
+ browser->setReadOnly(false);
+ QVERIFY(browser->textInteractionFlags() == Qt::TextEditorInteraction);
+ browser->setReadOnly(true);
+ QVERIFY(browser->textInteractionFlags() == Qt::TextBrowserInteraction);
+}
+
+void tst_QTextBrowser::anchorsWithSelfBuiltHtml()
+{
+ browser->setHtml("<p>Hello <a href=\"#anchor\">Link</a>"
+ "<p><a name=\"anchor\"/>Blah</p>");
+ QVERIFY(browser->document()->blockCount() > 1);
+ browser->setSource(QUrl("#anchor"));
+ QVERIFY(browser->document()->blockCount() > 1);
+}
+
+class HelpBrowser : public QTextBrowser
+{
+public:
+ virtual QVariant loadResource(int /*type*/, const QUrl &name) {
+ QString url = name.toString();
+ if(url == "qhelp://docs/index.html") {
+ return "index";
+ } else if (url == "qhelp://docs/classes.html") {
+ return "classes";
+ } else if (url == "qhelp://docs/someclass.html") {
+ return "someclass";
+ }
+ return QVariant();
+ }
+};
+
+void tst_QTextBrowser::relativeNonLocalUrls()
+{
+ HelpBrowser browser;
+ browser.setSource(QUrl("qhelp://docs/index.html"));
+ QCOMPARE(browser.toPlainText(), QString("index"));
+ browser.setSource(QUrl("classes.html"));
+ QCOMPARE(browser.toPlainText(), QString("classes"));
+ browser.setSource(QUrl("someclass.html"));
+ QCOMPARE(browser.toPlainText(), QString("someclass"));
+}
+
+class HackBrowser : public TestBrowser
+{
+public:
+ inline bool focusTheNextChild() { return QTextBrowser::focusNextChild(); }
+ inline bool focusThePreviousChild() { return QTextBrowser::focusPreviousChild(); }
+};
+
+void tst_QTextBrowser::adjacentAnchors()
+{
+ HackBrowser *browser = new HackBrowser;
+ browser->setHtml("<a href=\"#foo\">foo</a><a href=\"#bar\">bar</a>");
+ QVERIFY(browser->focusTheNextChild());
+ QCOMPARE(browser->textCursor().selectedText(), QString("foo"));
+
+ QVERIFY(browser->focusTheNextChild());
+ QCOMPARE(browser->textCursor().selectedText(), QString("bar"));
+
+ QVERIFY(!browser->focusTheNextChild());
+
+ browser->moveCursor(QTextCursor::End);
+ QVERIFY(browser->focusThePreviousChild());
+ QCOMPARE(browser->textCursor().selectedText(), QString("bar"));
+ QVERIFY(browser->focusThePreviousChild());
+ QCOMPARE(browser->textCursor().selectedText(), QString("foo"));
+
+ delete browser;
+}
+
+void tst_QTextBrowser::loadResourceOnRelativeLocalFiles()
+{
+ browser->setSource(QUrl("subdir/index.html"));
+ QVERIFY(!browser->toPlainText().isEmpty());
+ QVariant v = browser->loadResource(QTextDocument::HtmlResource, QUrl("../anchor.html"));
+ QVERIFY(v.isValid());
+ QVERIFY(v.type() == QVariant::ByteArray);
+ QVERIFY(!v.toByteArray().isEmpty());
+}
+
+void tst_QTextBrowser::focusIndicator()
+{
+ HackBrowser *browser = new HackBrowser;
+ browser->setSource(QUrl("firstpage.html"));
+ QVERIFY(!browser->textCursor().hasSelection());
+
+ browser->focusTheNextChild();
+
+ QVERIFY(browser->textCursor().hasSelection());
+ QCOMPARE(browser->textCursor().selectedText(), QString("Link to second page"));
+
+#ifdef QT_KEYPAD_NAVIGATION
+ browser->setEditFocus(true);
+#endif
+ QTest::keyClick(browser, Qt::Key_Enter);
+ QVERIFY(!browser->textCursor().hasSelection());
+
+ browser->focusTheNextChild();
+
+ QVERIFY(browser->textCursor().hasSelection());
+ QCOMPARE(browser->textCursor().selectedText(), QString("Link to third page from second page"));
+
+ QTest::keyClick(browser, Qt::Key_Enter);
+ QVERIFY(!browser->textCursor().hasSelection());
+
+ browser->backward();
+
+ QVERIFY(browser->textCursor().hasSelection());
+ QCOMPARE(browser->textCursor().selectedText(), QString("Link to third page from second page"));
+
+ browser->backward();
+
+ QVERIFY(browser->textCursor().hasSelection());
+ QCOMPARE(browser->textCursor().selectedText(), QString("Link to second page"));
+
+ browser->forward();
+
+ QVERIFY(browser->textCursor().hasSelection());
+ QCOMPARE(browser->textCursor().selectedText(), QString("Link to third page from second page"));
+
+ browser->backward();
+ browser->backward();
+
+ QVERIFY(browser->textCursor().hasSelection());
+ QCOMPARE(browser->textCursor().selectedText(), QString("Link to second page"));
+
+ QTest::keyClick(browser, Qt::Key_Enter);
+ QVERIFY(!browser->textCursor().hasSelection());
+
+ delete browser;
+}
+
+void tst_QTextBrowser::focusHistory()
+{
+ HackBrowser *browser = new HackBrowser;
+ browser->setSource(QUrl("firstpage.html"));
+ QVERIFY(!browser->textCursor().hasSelection());
+
+ browser->focusTheNextChild();
+
+ QVERIFY(browser->textCursor().hasSelection());
+ QCOMPARE(browser->textCursor().selectedText(), QString("Link to second page"));
+
+#ifdef QT_KEYPAD_NAVIGATION
+ browser->setEditFocus(true);
+#endif
+ QTest::keyClick(browser, Qt::Key_Enter);
+ QVERIFY(!browser->textCursor().hasSelection());
+
+ browser->focusTheNextChild();
+
+ QVERIFY(browser->textCursor().hasSelection());
+ QCOMPARE(browser->textCursor().selectedText(), QString("Link to third page from second page"));
+
+ browser->backward();
+
+ QVERIFY(browser->textCursor().hasSelection());
+ QCOMPARE(browser->textCursor().selectedText(), QString("Link to second page"));
+
+ browser->focusTheNextChild();
+
+ QVERIFY(browser->textCursor().hasSelection());
+ QCOMPARE(browser->textCursor().selectedText(), QString("Link to third page"));
+
+ // Despite the third page link being highlighted, going forward should go to second,
+ // and going back after that should still highlight the third link
+ browser->forward();
+
+ QVERIFY(browser->textCursor().hasSelection());
+ QCOMPARE(browser->textCursor().selectedText(), QString("Link to third page from second page"));
+
+ browser->backward();
+
+ QVERIFY(browser->textCursor().hasSelection());
+ QCOMPARE(browser->textCursor().selectedText(), QString("Link to third page"));
+
+ browser->forward();
+
+ QVERIFY(browser->textCursor().hasSelection());
+ QCOMPARE(browser->textCursor().selectedText(), QString("Link to third page from second page"));
+
+ QTest::keyClick(browser, Qt::Key_Enter);
+ QVERIFY(!browser->textCursor().hasSelection());
+
+ browser->backward();
+ browser->backward();
+
+ QVERIFY(browser->textCursor().hasSelection());
+ QCOMPARE(browser->textCursor().selectedText(), QString("Link to third page"));
+
+ delete browser;
+}
+
+void tst_QTextBrowser::urlEncoding()
+{
+ HackBrowser *browser = new HackBrowser;
+ browser->setOpenLinks(false);
+ browser->setHtml("<a href=\"http://www.google.com/q=%22\">link</a>");
+ browser->focusTheNextChild();
+
+ QSignalSpy spy(browser, SIGNAL(anchorClicked(const QUrl &)));
+
+#ifdef QT_KEYPAD_NAVIGATION
+ browser->setEditFocus(true);
+#endif
+ QTest::keyClick(browser, Qt::Key_Enter);
+ QCOMPARE(spy.count(), 1);
+
+ QUrl url = spy.at(0).at(0).toUrl();
+ QVERIFY(url.toEncoded() == QByteArray("http://www.google.com/q=%22"));
+
+ delete browser;
+}
+
+QTEST_MAIN(tst_QTextBrowser)
+#include "tst_qtextbrowser.moc"
diff --git a/tests/auto/widgets/widgets/qtextedit/.gitignore b/tests/auto/widgets/widgets/qtextedit/.gitignore
new file mode 100644
index 0000000000..8665a3a3d3
--- /dev/null
+++ b/tests/auto/widgets/widgets/qtextedit/.gitignore
@@ -0,0 +1,2 @@
+tst_qtextedit
+foo.png
diff --git a/tests/auto/widgets/widgets/qtextedit/fullWidthSelection/centered-fully-selected.png b/tests/auto/widgets/widgets/qtextedit/fullWidthSelection/centered-fully-selected.png
new file mode 100644
index 0000000000..ced6eb6e5b
--- /dev/null
+++ b/tests/auto/widgets/widgets/qtextedit/fullWidthSelection/centered-fully-selected.png
Binary files differ
diff --git a/tests/auto/widgets/widgets/qtextedit/fullWidthSelection/centered-partly-selected.png b/tests/auto/widgets/widgets/qtextedit/fullWidthSelection/centered-partly-selected.png
new file mode 100644
index 0000000000..481b99c7fc
--- /dev/null
+++ b/tests/auto/widgets/widgets/qtextedit/fullWidthSelection/centered-partly-selected.png
Binary files differ
diff --git a/tests/auto/widgets/widgets/qtextedit/fullWidthSelection/last-char-on-line.png b/tests/auto/widgets/widgets/qtextedit/fullWidthSelection/last-char-on-line.png
new file mode 100644
index 0000000000..292d3f9d4c
--- /dev/null
+++ b/tests/auto/widgets/widgets/qtextedit/fullWidthSelection/last-char-on-line.png
Binary files differ
diff --git a/tests/auto/widgets/widgets/qtextedit/fullWidthSelection/last-char-on-parag.png b/tests/auto/widgets/widgets/qtextedit/fullWidthSelection/last-char-on-parag.png
new file mode 100644
index 0000000000..69b72ede09
--- /dev/null
+++ b/tests/auto/widgets/widgets/qtextedit/fullWidthSelection/last-char-on-parag.png
Binary files differ
diff --git a/tests/auto/widgets/widgets/qtextedit/fullWidthSelection/multiple-full-width-lines.png b/tests/auto/widgets/widgets/qtextedit/fullWidthSelection/multiple-full-width-lines.png
new file mode 100644
index 0000000000..467b91e6e0
--- /dev/null
+++ b/tests/auto/widgets/widgets/qtextedit/fullWidthSelection/multiple-full-width-lines.png
Binary files differ
diff --git a/tests/auto/widgets/widgets/qtextedit/fullWidthSelection/nowrap_long.png b/tests/auto/widgets/widgets/qtextedit/fullWidthSelection/nowrap_long.png
new file mode 100644
index 0000000000..cce921b0cc
--- /dev/null
+++ b/tests/auto/widgets/widgets/qtextedit/fullWidthSelection/nowrap_long.png
Binary files differ
diff --git a/tests/auto/widgets/widgets/qtextedit/fullWidthSelection/single-full-width-line.png b/tests/auto/widgets/widgets/qtextedit/fullWidthSelection/single-full-width-line.png
new file mode 100644
index 0000000000..937494ac3c
--- /dev/null
+++ b/tests/auto/widgets/widgets/qtextedit/fullWidthSelection/single-full-width-line.png
Binary files differ
diff --git a/tests/auto/widgets/widgets/qtextedit/qtextedit.pro b/tests/auto/widgets/widgets/qtextedit/qtextedit.pro
new file mode 100644
index 0000000000..f29a2d2850
--- /dev/null
+++ b/tests/auto/widgets/widgets/qtextedit/qtextedit.pro
@@ -0,0 +1,18 @@
+load(qttest_p4)
+
+QT += widgets widgets-private gui-private
+INCLUDEPATH += ../
+
+HEADERS +=
+SOURCES += tst_qtextedit.cpp
+
+wince* {
+ addImages.files = fullWidthSelection/*
+ addImages.path = fullWidthSelection
+ DEPLOYMENT += addImages
+ DEFINES += SRCDIR=\\\"./\\\"
+} else {
+ DEFINES += SRCDIR=\\\"$$PWD/\\\"
+}
+
+contains(QT_CONFIG,xcb):qpa:CONFIG+=insignificant_test # QTBUG-20756 crashes on qpa, xcb
diff --git a/tests/auto/widgets/widgets/qtextedit/tst_qtextedit.cpp b/tests/auto/widgets/widgets/qtextedit/tst_qtextedit.cpp
new file mode 100644
index 0000000000..481bda962a
--- /dev/null
+++ b/tests/auto/widgets/widgets/qtextedit/tst_qtextedit.cpp
@@ -0,0 +1,2391 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#include <QtTest/QtTest>
+
+#include <qtextedit.h>
+#include <qtextcursor.h>
+#include <qtextlist.h>
+#include <qdebug.h>
+#include <qapplication.h>
+#include <qclipboard.h>
+#include <qtextbrowser.h>
+#include <private/qwidgettextcontrol_p.h>
+#include <qscrollbar.h>
+#include <qtextobject.h>
+#include <qtexttable.h>
+#include <qpainter.h>
+#include <qimagereader.h>
+#include <qimagewriter.h>
+#include <qcommonstyle.h>
+#include <qlayout.h>
+
+#include <qabstracttextdocumentlayout.h>
+#include <qtextdocumentfragment.h>
+
+//Used in copyAvailable
+typedef QPair<Qt::Key, Qt::KeyboardModifier> keyPairType;
+typedef QList<keyPairType> pairListType;
+Q_DECLARE_METATYPE(pairListType);
+Q_DECLARE_METATYPE(keyPairType);
+Q_DECLARE_METATYPE(QList<bool>);
+Q_DECLARE_METATYPE(QList<int>);
+
+#ifdef Q_WS_MAC
+#include <Carbon/Carbon.h>
+#endif
+
+bool nativeClipboardWorking()
+{
+#ifdef Q_WS_MAC
+ PasteboardRef pasteboard;
+ OSStatus status = PasteboardCreate(0, &pasteboard);
+ if (status == noErr)
+ CFRelease(pasteboard);
+ return status == noErr;
+#endif
+ return true;
+}
+
+
+QT_FORWARD_DECLARE_CLASS(QTextEdit)
+
+//TESTED_CLASS=
+//TESTED_FILES=
+
+class tst_QTextEdit : public QObject
+{
+ Q_OBJECT
+public:
+ tst_QTextEdit();
+
+public slots:
+ void init();
+ void cleanup();
+private slots:
+ void getSetCheck();
+ void inlineAttributesOnInsert();
+ void inlineAttributesOnSelection();
+ void inlineAttributeSymmetry();
+ void inlineAttributeSymmetryWithSelection();
+ void autoBulletList1();
+ void autoBulletList2();
+ void preserveCharFormatAfterNewline();
+#ifndef QT_NO_CLIPBOARD
+ void clearMustNotChangeClipboard();
+#endif
+ void clearMustNotResetRootFrameMarginToDefault();
+ void clearShouldPreserveTheCurrentCharFormat();
+ void clearShouldClearExtraSelections();
+ void paragSeparatorOnPlaintextAppend();
+ void layoutingLoop();
+#ifndef QT_NO_CLIPBOARD
+ void selectAllSetsNotSelection();
+#endif
+ void asciiTab();
+ void setDocument();
+ void setDocument_shared();
+ void mergeCurrentCharFormat();
+ void mergeCurrentBlockCharFormat();
+ void emptyAppend();
+ void appendOnEmptyDocumentShouldReuseInitialParagraph();
+ void cursorPositionChanged();
+ void setTextCursor();
+#ifndef QT_NO_CLIPBOARD
+ void undoAvailableAfterPaste();
+#endif
+ void undoRedoAvailableRepetition();
+ void appendShouldUseCurrentFormat();
+ void appendShouldNotTouchTheSelection();
+ void backspace();
+ void shiftBackspace();
+ void undoRedo();
+ void preserveCharFormatInAppend();
+#ifndef QT_NO_CLIPBOARD
+ void copyAndSelectAllInReadonly();
+#endif
+ void ctrlAltInput();
+ void noPropertiesOnDefaultTextEditCharFormat();
+ void setPlainTextShouldUseCurrentCharFormat();
+ void setPlainTextShouldEmitTextChangedOnce();
+ void overwriteMode();
+ void shiftDownInLineLastShouldSelectToEnd_data();
+ void shiftDownInLineLastShouldSelectToEnd();
+ void undoRedoShouldRepositionTextEditCursor();
+ void lineWrapModes();
+ void mouseCursorShape();
+ void implicitClear();
+ void undoRedoAfterSetContent();
+ void numPadKeyNavigation();
+ void moveCursor();
+#ifndef QT_NO_CLIPBOARD
+ void mimeDataReimplementations();
+#endif
+ void ctrlEnterShouldInsertLineSeparator_NOT();
+ void shiftEnterShouldInsertLineSeparator();
+ void selectWordsFromStringsContainingSeparators_data();
+ void selectWordsFromStringsContainingSeparators();
+#ifndef QT_NO_CLIPBOARD
+ void canPaste();
+ void copyAvailable_data();
+ void copyAvailable();
+#endif
+ void ensureCursorVisibleOnInitialShow();
+ void setHtmlInsideResizeEvent();
+ void colorfulAppend();
+ void ensureVisibleWithRtl();
+ void preserveCharFormatAfterSetPlainText();
+ void extraSelections();
+ void adjustScrollbars();
+ void currentCharFormatChanged();
+ void textObscuredByScrollbars();
+ void setTextPreservesUndoRedoEnabled();
+ void wordWrapProperty();
+ void lineWrapProperty();
+ void selectionChanged();
+ void copyPasteBackgroundImage();
+ void setText();
+ void fullWidthSelection_data();
+ void fullWidthSelection();
+ void fullWidthSelection2();
+ void cursorRect();
+ void setDocumentPreservesPalette();
+ void pasteFromQt3RichText();
+ void noWrapBackgrounds();
+ void preserveCharFormatAfterUnchangingSetPosition();
+ void twoSameInputMethodEvents();
+#ifndef QT_NO_CONTEXTMENU
+ void taskQTBUG_7902_contextMenuCrash();
+#endif
+ void bidiVisualMovement_data();
+ void bidiVisualMovement();
+
+ void bidiLogicalMovement_data();
+ void bidiLogicalMovement();
+
+ void inputMethodSelection();
+
+private:
+ void createSelection();
+ int blockCount() const;
+ bool nativeClipboardWorking();
+ void compareWidgetAndImage(QTextEdit &widget, const QString &imageFileName);
+
+ QTextEdit *ed;
+ qreal rootFrameMargin;
+};
+
+bool tst_QTextEdit::nativeClipboardWorking()
+{
+#ifdef Q_WS_MAC
+ PasteboardRef pasteboard;
+ OSStatus status = PasteboardCreate(0, &pasteboard);
+ if (status == noErr)
+ CFRelease(pasteboard);
+ return status == noErr;
+#endif
+ return true;
+}
+
+// Testing get/set functions
+void tst_QTextEdit::getSetCheck()
+{
+ QTextEdit obj1;
+ // QTextDocument * QTextEdit::document()
+ // void QTextEdit::setDocument(QTextDocument *)
+ QTextDocument *var1 = new QTextDocument;
+ obj1.setDocument(var1);
+ QCOMPARE(var1, obj1.document());
+ obj1.setDocument((QTextDocument *)0);
+ QVERIFY(var1 != obj1.document()); // QTextEdit creates a new document when setting 0
+ QVERIFY((QTextDocument *)0 != obj1.document());
+ delete var1;
+
+ // AutoFormatting QTextEdit::autoFormatting()
+ // void QTextEdit::setAutoFormatting(AutoFormatting)
+ obj1.setAutoFormatting(QTextEdit::AutoFormatting(QTextEdit::AutoNone));
+ QCOMPARE(QTextEdit::AutoFormatting(QTextEdit::AutoNone), obj1.autoFormatting());
+ obj1.setAutoFormatting(QTextEdit::AutoFormatting(QTextEdit::AutoBulletList));
+ QCOMPARE(QTextEdit::AutoFormatting(QTextEdit::AutoBulletList), obj1.autoFormatting());
+ obj1.setAutoFormatting(QTextEdit::AutoFormatting(QTextEdit::AutoAll));
+ QCOMPARE(QTextEdit::AutoFormatting(QTextEdit::AutoAll), obj1.autoFormatting());
+
+ // bool QTextEdit::tabChangesFocus()
+ // void QTextEdit::setTabChangesFocus(bool)
+ obj1.setTabChangesFocus(false);
+ QCOMPARE(false, obj1.tabChangesFocus());
+ obj1.setTabChangesFocus(true);
+ QCOMPARE(true, obj1.tabChangesFocus());
+
+ // LineWrapMode QTextEdit::lineWrapMode()
+ // void QTextEdit::setLineWrapMode(LineWrapMode)
+ obj1.setLineWrapMode(QTextEdit::LineWrapMode(QTextEdit::NoWrap));
+ QCOMPARE(QTextEdit::LineWrapMode(QTextEdit::NoWrap), obj1.lineWrapMode());
+ obj1.setLineWrapMode(QTextEdit::LineWrapMode(QTextEdit::WidgetWidth));
+ QCOMPARE(QTextEdit::LineWrapMode(QTextEdit::WidgetWidth), obj1.lineWrapMode());
+ obj1.setLineWrapMode(QTextEdit::LineWrapMode(QTextEdit::FixedPixelWidth));
+ QCOMPARE(QTextEdit::LineWrapMode(QTextEdit::FixedPixelWidth), obj1.lineWrapMode());
+ obj1.setLineWrapMode(QTextEdit::LineWrapMode(QTextEdit::FixedColumnWidth));
+ QCOMPARE(QTextEdit::LineWrapMode(QTextEdit::FixedColumnWidth), obj1.lineWrapMode());
+
+ // int QTextEdit::lineWrapColumnOrWidth()
+ // void QTextEdit::setLineWrapColumnOrWidth(int)
+ obj1.setLineWrapColumnOrWidth(0);
+ QCOMPARE(0, obj1.lineWrapColumnOrWidth());
+ obj1.setLineWrapColumnOrWidth(INT_MIN);
+ QCOMPARE(INT_MIN, obj1.lineWrapColumnOrWidth());
+ obj1.setLineWrapColumnOrWidth(INT_MAX);
+ QCOMPARE(INT_MAX, obj1.lineWrapColumnOrWidth());
+
+ // bool QTextEdit::overwriteMode()
+ // void QTextEdit::setOverwriteMode(bool)
+ obj1.setOverwriteMode(false);
+ QCOMPARE(false, obj1.overwriteMode());
+ obj1.setOverwriteMode(true);
+ QCOMPARE(true, obj1.overwriteMode());
+
+ // int QTextEdit::tabStopWidth()
+ // void QTextEdit::setTabStopWidth(int)
+ obj1.setTabStopWidth(0);
+ QCOMPARE(0, obj1.tabStopWidth());
+ obj1.setTabStopWidth(INT_MIN);
+ QCOMPARE(0, obj1.tabStopWidth()); // Makes no sense to set a negative tabstop value
+#if defined(QT_ARCH_WINDOWSCE)
+ // due to rounding error in qRound when qreal==float
+ // we cannot use INT_MAX for this check
+ obj1.setTabStopWidth(SHRT_MAX*2);
+ QCOMPARE(SHRT_MAX*2, obj1.tabStopWidth());
+#else
+ obj1.setTabStopWidth(INT_MAX);
+ QCOMPARE(INT_MAX, obj1.tabStopWidth());
+#endif
+
+ // bool QTextEdit::acceptRichText()
+ // void QTextEdit::setAcceptRichText(bool)
+ obj1.setAcceptRichText(false);
+ QCOMPARE(false, obj1.acceptRichText());
+ obj1.setAcceptRichText(true);
+ QCOMPARE(true, obj1.acceptRichText());
+
+ // qreal QTextEdit::fontPointSize()
+ // void QTextEdit::setFontPointSize(qreal)
+ obj1.setFontPointSize(qreal(1.1));
+ QCOMPARE(qreal(1.1), obj1.fontPointSize());
+ // we currently assert in QFont::setPointSizeF for that
+ //obj1.setFontPointSize(0.0);
+ //QCOMPARE(1.1, obj1.fontPointSize()); // Should not accept 0.0 => keep old
+
+ // int QTextEdit::fontWeight()
+ // void QTextEdit::setFontWeight(int)
+ obj1.setFontWeight(1);
+ QCOMPARE(1, obj1.fontWeight()); // Range<1, 99>
+ obj1.setFontWeight(99);
+ QCOMPARE(99, obj1.fontWeight()); // Range<1, 99>
+ /* assertion in qfont.cpp
+ obj1.setFontWeight(INT_MIN);
+ QCOMPARE(1, obj1.fontWeight()); // Range<1, 99>
+ obj1.setFontWeight(INT_MAX);
+ QCOMPARE(99, obj1.fontWeight()); // Range<1, 99>
+ */
+
+ // bool QTextEdit::fontUnderline()
+ // void QTextEdit::setFontUnderline(bool)
+ obj1.setFontUnderline(false);
+ QCOMPARE(false, obj1.fontUnderline());
+ obj1.setFontUnderline(true);
+ QCOMPARE(true, obj1.fontUnderline());
+
+ // bool QTextEdit::fontItalic()
+ // void QTextEdit::setFontItalic(bool)
+ obj1.setFontItalic(false);
+ QCOMPARE(false, obj1.fontItalic());
+ obj1.setFontItalic(true);
+ QCOMPARE(true, obj1.fontItalic());
+}
+
+class QtTestDocumentLayout : public QAbstractTextDocumentLayout
+{
+ Q_OBJECT
+public:
+ inline QtTestDocumentLayout(QTextEdit *edit, QTextDocument *doc, int &itCount)
+ : QAbstractTextDocumentLayout(doc), useBiggerSize(false), ed(edit), iterationCounter(itCount) {}
+
+ virtual void draw(QPainter *, const QAbstractTextDocumentLayout::PaintContext &) {}
+
+ virtual int hitTest(const QPointF &, Qt::HitTestAccuracy ) const { return 0; }
+
+ virtual void documentChanged(int, int, int) {}
+
+ virtual int pageCount() const { return 1; }
+
+ virtual QSizeF documentSize() const { return usedSize; }
+
+ virtual QRectF frameBoundingRect(QTextFrame *) const { return QRectF(); }
+ virtual QRectF blockBoundingRect(const QTextBlock &) const { return QRectF(); }
+
+ bool useBiggerSize;
+ QSize usedSize;
+
+ QTextEdit *ed;
+
+ int &iterationCounter;
+};
+
+tst_QTextEdit::tst_QTextEdit()
+{}
+
+void tst_QTextEdit::init()
+{
+#ifdef Q_OS_WINCE //disable magic for WindowsCE
+ qApp->setAutoMaximizeThreshold(-1);
+#endif
+
+ ed = new QTextEdit(0);
+ rootFrameMargin = ed->document()->documentMargin();
+}
+
+void tst_QTextEdit::cleanup()
+{
+ delete ed;
+ ed = 0;
+}
+
+void tst_QTextEdit::inlineAttributesOnInsert()
+{
+ QVERIFY(ed->textCursor().charFormat().foreground().color() != Qt::blue);
+
+ ed->setTextColor(Qt::blue);
+ QTest::keyClick(ed, Qt::Key_A);
+
+ QVERIFY(ed->textCursor().charFormat().foreground().color() == Qt::blue);
+}
+
+void tst_QTextEdit::inlineAttributesOnSelection()
+{
+ createSelection();
+
+ ed->setFontItalic(true);
+
+ QVERIFY(ed->textCursor().charFormat().fontItalic());
+}
+
+void tst_QTextEdit::inlineAttributeSymmetry()
+{
+ ed->setFontPointSize(42.0);
+ QCOMPARE(double(ed->fontPointSize()), 42.0);
+
+ ed->setFontFamily("Test");
+ QCOMPARE(ed->fontFamily(), QString("Test"));
+
+ ed->setFontWeight(QFont::Bold);
+ QCOMPARE((int)ed->fontWeight(), (int)QFont::Bold);
+
+ ed->setFontUnderline(true);
+ QCOMPARE(ed->fontUnderline(), true);
+
+ ed->setFontItalic(true);
+ QCOMPARE(ed->fontItalic(), true);
+
+ ed->setTextColor(Qt::blue);
+ QCOMPARE(ed->textColor(), QColor(Qt::blue));
+
+ ed->setTextBackgroundColor(Qt::red);
+ QCOMPARE(ed->textBackgroundColor(), QColor(Qt::red));
+
+ ed->setAlignment(Qt::AlignRight);
+ QCOMPARE((int)ed->alignment(), (int)Qt::AlignRight);
+}
+
+void tst_QTextEdit::inlineAttributeSymmetryWithSelection()
+{
+ createSelection();
+
+ inlineAttributeSymmetry();
+}
+
+void tst_QTextEdit::autoBulletList1()
+{
+ ed->setAutoFormatting(QTextEdit::AutoBulletList);
+
+ QTest::keyClick(ed, Qt::Key_Return);
+ QTest::keyClicks(ed, "*This should become a list");
+
+ QVERIFY(ed->textCursor().currentList());
+ QVERIFY(ed->textCursor().currentList()->format().style() == QTextListFormat::ListDisc);
+}
+
+void tst_QTextEdit::autoBulletList2()
+{
+ ed->setAutoFormatting(QTextEdit::AutoNone);
+ QTest::keyClick(ed, Qt::Key_Return);
+ QTest::keyClicks(ed, "*This should NOT become a list");
+
+ QVERIFY(!ed->textCursor().currentList());
+}
+
+void tst_QTextEdit::preserveCharFormatAfterNewline()
+{
+ ed->setTextColor(Qt::blue);
+ QTest::keyClicks(ed, "Hello");
+
+ QTest::keyClick(ed, Qt::Key_Return);
+
+ QCOMPARE(ed->textColor(), QColor(Qt::blue));
+}
+
+void tst_QTextEdit::createSelection()
+{
+ QTest::keyClicks(ed, "Hello World");
+ /* go to start */
+#ifndef Q_WS_MAC
+ QTest::keyClick(ed, Qt::Key_Home, Qt::ControlModifier);
+#else
+ QTest::keyClick(ed, Qt::Key_Home);
+#endif
+ QCOMPARE(ed->textCursor().position(), 0);
+ /* select until end of text */
+#ifndef Q_WS_MAC
+ QTest::keyClick(ed, Qt::Key_End, Qt::ControlModifier | Qt::ShiftModifier);
+#else
+ QTest::keyClick(ed, Qt::Key_End, Qt::ShiftModifier);
+#endif
+ QCOMPARE(ed->textCursor().position(), 11);
+}
+
+#ifndef QT_NO_CLIPBOARD
+void tst_QTextEdit::clearMustNotChangeClipboard()
+{
+ if (!nativeClipboardWorking())
+ QSKIP("Clipboard not working with cron-started unit tests", SkipAll);
+ ed->textCursor().insertText("Hello World");
+ QString txt("This is different text");
+ QApplication::clipboard()->setText(txt);
+ ed->clear();
+ QCOMPARE(QApplication::clipboard()->text(), txt);
+}
+#endif
+
+void tst_QTextEdit::clearMustNotResetRootFrameMarginToDefault()
+{
+ QCOMPARE(ed->document()->rootFrame()->frameFormat().margin(), rootFrameMargin);
+ ed->clear();
+ QCOMPARE(ed->document()->rootFrame()->frameFormat().margin(), rootFrameMargin);
+}
+
+void tst_QTextEdit::clearShouldPreserveTheCurrentCharFormat()
+{
+ ed->setFontUnderline(true);
+ QVERIFY(ed->fontUnderline());
+ ed->clear();
+ QVERIFY(ed->fontUnderline());
+}
+
+void tst_QTextEdit::clearShouldClearExtraSelections()
+{
+ QTextEdit::ExtraSelection sel;
+ sel.cursor = ed->textCursor();
+ sel.format.setProperty(QTextFormat::FullWidthSelection, true);
+ ed->setExtraSelections(QList<QTextEdit::ExtraSelection>() << sel);
+ QCOMPARE(ed->extraSelections().count(), 1);
+ ed->clear();
+ QCOMPARE(ed->extraSelections().count(), 0);
+}
+
+void tst_QTextEdit::paragSeparatorOnPlaintextAppend()
+{
+ ed->append("Hello\nWorld");
+ int cnt = 0;
+ QTextBlock blk = ed->document()->begin();
+ while (blk.isValid()) {
+ ++cnt;
+ blk = blk.next();
+ }
+ QCOMPARE(cnt, 2);
+}
+
+void tst_QTextEdit::layoutingLoop()
+{
+ QPointer<QTextEdit> ed = new QTextEdit(0);
+ // this is a testcase for an ugly layouting problem, causing an infinite loop.
+ // QTextEdit's resizeEvent has a long comment about what and why it can happen.
+
+ int callsToSetPageSize = 0;
+
+ QTextDocument *doc = new QTextDocument;
+ QtTestDocumentLayout *lout = new QtTestDocumentLayout(ed, doc, callsToSetPageSize);
+ doc->setDocumentLayout(lout);
+ ed->setDocument(doc);
+
+ ed->show();
+ ed->resize(100, 100);
+
+ qApp->processEvents();
+ delete doc;
+ delete ed;
+
+ // ###### should need less!
+ QVERIFY(callsToSetPageSize < 10);
+}
+
+#ifndef QT_NO_CLIPBOARD
+void tst_QTextEdit::selectAllSetsNotSelection()
+{
+ if (!QApplication::clipboard()->supportsSelection()) {
+ QSKIP("Test only relevant for systems with selection", SkipAll);
+ return;
+ }
+
+ QApplication::clipboard()->setText(QString("foobar"), QClipboard::Selection);
+ QVERIFY(QApplication::clipboard()->text(QClipboard::Selection) == QString("foobar"));
+
+ ed->insertPlainText("Hello World");
+ ed->selectAll();
+
+ QCOMPARE(QApplication::clipboard()->text(QClipboard::Selection), QString::fromAscii("foobar"));
+}
+#endif
+void tst_QTextEdit::asciiTab()
+{
+ QTextEdit edit;
+ edit.setPlainText("\t");
+ edit.show();
+ qApp->processEvents();
+ QCOMPARE(edit.toPlainText().at(0), QChar('\t'));
+}
+
+
+void tst_QTextEdit::setDocument()
+{
+ QTextDocument *document = new QTextDocument(ed);
+ QCOMPARE(document->isModified(), false);
+ QCOMPARE(document->isUndoAvailable(), false);
+ QTextCursor(document).insertText("Test");
+ QCOMPARE(document->isUndoAvailable(), true);
+ QCOMPARE(document->isModified(), true);
+ ed->setDocument(document);
+ QCOMPARE(ed->toPlainText(), QString("Test"));
+ QCOMPARE(document->isUndoAvailable(), true);
+ QCOMPARE(document->isModified(), true);
+}
+
+void tst_QTextEdit::setDocument_shared()
+{
+ QTextDocument *document = new QTextDocument(ed);
+ QCOMPARE(document->isModified(), false);
+ QCOMPARE(document->isUndoAvailable(), false);
+ QTextCursor(document).insertText("Test");
+ QCOMPARE(document->isUndoAvailable(), true);
+ document->setModified(false);
+ ed->setDocument(document);
+ QCOMPARE(ed->toPlainText(), QString("Test"));
+ QCOMPARE(document->isUndoAvailable(), true);
+ QCOMPARE(document->isModified(), false);
+ QTextCursor(document).insertText("Test2");
+ QCOMPARE(document->isModified(), true);
+ QTextEdit editor2;
+ editor2.setDocument(document);
+ QCOMPARE(document->isUndoAvailable(), true);
+ QCOMPARE(document->isModified(), true);
+}
+
+void tst_QTextEdit::mergeCurrentCharFormat()
+{
+ ed->setPlainText("Hello Test World");
+ QTextCursor cursor = ed->textCursor();
+ cursor.setPosition(7);
+ ed->setTextCursor(cursor);
+
+ QTextCharFormat mod;
+ mod.setFontItalic(true);
+ mod.setForeground(Qt::red);
+ ed->mergeCurrentCharFormat(mod);
+
+ cursor.movePosition(QTextCursor::Right);
+ cursor.movePosition(QTextCursor::Right);
+ // do NOT select the current word under the cursor, /JUST/
+ // call mergeCharFormat on the cursor
+ QVERIFY(!cursor.charFormat().fontItalic());
+ QVERIFY(cursor.charFormat().foreground().color() != Qt::red);
+}
+
+void tst_QTextEdit::mergeCurrentBlockCharFormat()
+{
+ ed->setPlainText("FirstLine\n\nThirdLine");
+ QTextCursor cursor = ed->textCursor();
+ cursor.movePosition(QTextCursor::Start);
+ cursor.movePosition(QTextCursor::Down);
+
+ // make sure we're in the empty second line
+ QVERIFY(cursor.atBlockStart());
+ QVERIFY(cursor.atBlockEnd());
+
+ ed->setTextCursor(cursor);
+
+ QTextCharFormat mod;
+ mod.setForeground(Qt::red);
+ ed->mergeCurrentCharFormat(mod);
+
+ QVERIFY(cursor.blockCharFormat().foreground().color() != Qt::red);
+ cursor.movePosition(QTextCursor::Up);
+ QVERIFY(cursor.blockCharFormat().foreground().color() != Qt::red);
+ cursor.movePosition(QTextCursor::Down);
+ cursor.movePosition(QTextCursor::Down);
+ QVERIFY(cursor.blockCharFormat().foreground().color() != Qt::red);
+}
+
+int tst_QTextEdit::blockCount() const
+{
+ int blocks = 0;
+ for (QTextBlock block = ed->document()->begin(); block.isValid(); block = block.next())
+ ++blocks;
+ return blocks;
+}
+
+// Supporter issue #56783
+void tst_QTextEdit::emptyAppend()
+{
+ ed->append("Blah");
+ QCOMPARE(blockCount(), 1);
+ ed->append(QString::null);
+ QCOMPARE(blockCount(), 2);
+ ed->append(QString(" "));
+ QCOMPARE(blockCount(), 3);
+}
+
+void tst_QTextEdit::appendOnEmptyDocumentShouldReuseInitialParagraph()
+{
+ QCOMPARE(blockCount(), 1);
+ ed->append("Blah");
+ QCOMPARE(blockCount(), 1);
+}
+
+class CursorPositionChangedRecorder : public QObject
+{
+ Q_OBJECT
+public:
+ inline CursorPositionChangedRecorder(QTextEdit *ed)
+ : editor(ed)
+ {
+ connect(editor, SIGNAL(cursorPositionChanged()), this, SLOT(recordCursorPos()));
+ }
+
+ QList<int> cursorPositions;
+
+private slots:
+ void recordCursorPos()
+ {
+ cursorPositions.append(editor->textCursor().position());
+ }
+
+private:
+ QTextEdit *editor;
+};
+
+void tst_QTextEdit::cursorPositionChanged()
+{
+ QSignalSpy spy(ed, SIGNAL(cursorPositionChanged()));
+ ed->show();
+
+ spy.clear();
+ QTest::keyClick(ed, Qt::Key_A);
+ QCOMPARE(spy.count(), 1);
+
+ QTextCursor cursor = ed->textCursor();
+ cursor.movePosition(QTextCursor::Start);
+ ed->setTextCursor(cursor);
+ cursor.movePosition(QTextCursor::End);
+ spy.clear();
+ cursor.insertText("Test");
+ QCOMPARE(spy.count(), 0);
+
+ cursor.movePosition(QTextCursor::End);
+ ed->setTextCursor(cursor);
+ cursor.movePosition(QTextCursor::Start);
+ spy.clear();
+ cursor.insertText("Test");
+ QCOMPARE(spy.count(), 1);
+
+ spy.clear();
+ QTest::keyClick(ed, Qt::Key_Left);
+ QCOMPARE(spy.count(), 1);
+
+ cursor.movePosition(QTextCursor::Start);
+ ed->setTextCursor(cursor);
+ spy.clear();
+ QVERIFY(!ed->textCursor().hasSelection());
+ QTest::mouseDClick(ed->viewport(), Qt::LeftButton, 0, ed->cursorRect().center());
+ QVERIFY(ed->textCursor().hasSelection());
+
+ QCOMPARE(spy.count(), 1);
+
+ CursorPositionChangedRecorder spy2(ed);
+ QVERIFY(ed->textCursor().position() > 0);
+ ed->setPlainText("Hello World");
+ QCOMPARE(spy2.cursorPositions.count(), 1);
+ QCOMPARE(spy2.cursorPositions.at(0), 0);
+ QCOMPARE(ed->textCursor().position(), 0);
+}
+
+void tst_QTextEdit::setTextCursor()
+{
+ QSignalSpy spy(ed, SIGNAL(cursorPositionChanged()));
+
+ ed->setPlainText("Test");
+ QTextCursor cursor = ed->textCursor();
+ cursor.movePosition(QTextCursor::Start);
+ cursor.movePosition(QTextCursor::NextCharacter);
+
+ spy.clear();
+
+ ed->setTextCursor(cursor);
+ QCOMPARE(spy.count(), 1);
+}
+
+#ifndef QT_NO_CLIPBOARD
+void tst_QTextEdit::undoAvailableAfterPaste()
+{
+ if (!nativeClipboardWorking())
+ QSKIP("Clipboard not working with cron-started unit tests", SkipAll);
+
+ QSignalSpy spy(ed->document(), SIGNAL(undoAvailable(bool)));
+
+ const QString txt("Test");
+ QApplication::clipboard()->setText(txt);
+ ed->paste();
+ QVERIFY(spy.count() >= 1);
+ QCOMPARE(ed->toPlainText(), txt);
+}
+#endif
+
+class UndoRedoRecorder : public QObject
+{
+ Q_OBJECT
+public:
+ UndoRedoRecorder(QTextDocument *doc)
+ : undoRepetitions(false)
+ , redoRepetitions(false)
+ , undoCount(0)
+ , redoCount(0)
+ {
+ connect(doc, SIGNAL(undoAvailable(bool)), this, SLOT(undoAvailable(bool)));
+ connect(doc, SIGNAL(redoAvailable(bool)), this, SLOT(redoAvailable(bool)));
+ }
+
+ bool undoRepetitions;
+ bool redoRepetitions;
+
+private slots:
+ void undoAvailable(bool enabled) {
+ if (undoCount > 0 && enabled == lastUndoEnabled)
+ undoRepetitions = true;
+
+ ++undoCount;
+ lastUndoEnabled = enabled;
+ }
+
+ void redoAvailable(bool enabled) {
+ if (redoCount > 0 && enabled == lastRedoEnabled)
+ redoRepetitions = true;
+
+ ++redoCount;
+ lastRedoEnabled = enabled;
+ }
+
+private:
+ bool lastUndoEnabled;
+ bool lastRedoEnabled;
+
+ int undoCount;
+ int redoCount;
+};
+
+void tst_QTextEdit::undoRedoAvailableRepetition()
+{
+ UndoRedoRecorder spy(ed->document());
+
+ ed->textCursor().insertText("ABC\n\nDEF\n\nGHI\n");
+ ed->textCursor().insertText("foo\n");
+ ed->textCursor().insertText("bar\n");
+ ed->undo(); ed->undo(); ed->undo();
+ ed->redo(); ed->redo(); ed->redo();
+
+ QVERIFY(!spy.undoRepetitions);
+ QVERIFY(!spy.redoRepetitions);
+}
+
+void tst_QTextEdit::appendShouldUseCurrentFormat()
+{
+ ed->textCursor().insertText("A");
+ QTextCharFormat fmt;
+ fmt.setForeground(Qt::blue);
+ fmt.setFontItalic(true);
+ ed->setCurrentCharFormat(fmt);
+ ed->append("Hello");
+
+ QTextCursor cursor(ed->document());
+
+ QVERIFY(cursor.movePosition(QTextCursor::NextCharacter));
+ QVERIFY(cursor.charFormat().foreground().color() != Qt::blue);
+ QVERIFY(!cursor.charFormat().fontItalic());
+
+ QVERIFY(cursor.movePosition(QTextCursor::NextBlock));
+
+ {
+ QTextCursor tmp = cursor;
+ tmp.movePosition(QTextCursor::End, QTextCursor::KeepAnchor);
+ QCOMPARE(tmp.selectedText(), QString::fromLatin1("Hello"));
+ }
+
+ QVERIFY(cursor.movePosition(QTextCursor::NextCharacter));
+ QVERIFY(cursor.charFormat().foreground().color() == Qt::blue);
+ QVERIFY(cursor.charFormat().fontItalic());
+}
+
+void tst_QTextEdit::appendShouldNotTouchTheSelection()
+{
+ QTextCursor cursor(ed->document());
+ QTextCharFormat fmt;
+ fmt.setForeground(Qt::blue);
+ cursor.insertText("H", fmt);
+ fmt.setForeground(Qt::red);
+ cursor.insertText("ey", fmt);
+
+ cursor.insertText("some random text inbetween");
+
+ cursor.movePosition(QTextCursor::Start);
+ cursor.movePosition(QTextCursor::NextCharacter, QTextCursor::KeepAnchor);
+ QCOMPARE(cursor.charFormat().foreground().color(), QColor(Qt::blue));
+ cursor.movePosition(QTextCursor::NextCharacter, QTextCursor::KeepAnchor);
+ QCOMPARE(cursor.charFormat().foreground().color(), QColor(Qt::red));
+ cursor.movePosition(QTextCursor::NextCharacter, QTextCursor::KeepAnchor);
+ QCOMPARE(cursor.charFormat().foreground().color(), QColor(Qt::red));
+ QCOMPARE(cursor.selectedText(), QString("Hey"));
+
+ ed->setTextCursor(cursor);
+ QVERIFY(ed->textCursor().hasSelection());
+
+ ed->append("<b>Some Bold Text</b>");
+ cursor.movePosition(QTextCursor::Start);
+ cursor.movePosition(QTextCursor::NextCharacter);
+ QCOMPARE(cursor.charFormat().foreground().color(), QColor(Qt::blue));
+}
+
+void tst_QTextEdit::backspace()
+{
+ QTextCursor cursor = ed->textCursor();
+
+ QTextListFormat listFmt;
+ listFmt.setStyle(QTextListFormat::ListDisc);
+ listFmt.setIndent(1);
+ cursor.insertList(listFmt);
+ cursor.insertText("A");
+
+ ed->setTextCursor(cursor);
+
+ // delete 'A'
+ QTest::keyClick(ed, Qt::Key_Backspace);
+ QVERIFY(ed->textCursor().currentList());
+ // delete list
+ QTest::keyClick(ed, Qt::Key_Backspace);
+ QVERIFY(!ed->textCursor().currentList());
+ QCOMPARE(ed->textCursor().blockFormat().indent(), 1);
+ // outdent paragraph
+ QTest::keyClick(ed, Qt::Key_Backspace);
+ QCOMPARE(ed->textCursor().blockFormat().indent(), 0);
+}
+
+void tst_QTextEdit::shiftBackspace()
+{
+ QTextCursor cursor = ed->textCursor();
+
+ QTextListFormat listFmt;
+ listFmt.setStyle(QTextListFormat::ListDisc);
+ listFmt.setIndent(1);
+ cursor.insertList(listFmt);
+ cursor.insertText("A");
+
+ ed->setTextCursor(cursor);
+
+ // delete 'A'
+ QTest::keyClick(ed, Qt::Key_Backspace, Qt::ShiftModifier);
+ QVERIFY(ed->textCursor().currentList());
+ // delete list
+ QTest::keyClick(ed, Qt::Key_Backspace, Qt::ShiftModifier);
+ QVERIFY(!ed->textCursor().currentList());
+ QCOMPARE(ed->textCursor().blockFormat().indent(), 1);
+ // outdent paragraph
+ QTest::keyClick(ed, Qt::Key_Backspace, Qt::ShiftModifier);
+ QCOMPARE(ed->textCursor().blockFormat().indent(), 0);
+}
+
+void tst_QTextEdit::undoRedo()
+{
+ ed->clear();
+ QTest::keyClicks(ed, "abc d");
+ QCOMPARE(ed->toPlainText(), QString("abc d"));
+ ed->undo();
+ QCOMPARE(ed->toPlainText(), QString());
+ ed->redo();
+ QCOMPARE(ed->toPlainText(), QString("abc d"));
+#ifdef Q_WS_WIN
+ // shortcut for undo
+ QTest::keyClick(ed, Qt::Key_Backspace, Qt::AltModifier);
+ QCOMPARE(ed->toPlainText(), QString());
+ // shortcut for redo
+ QTest::keyClick(ed, Qt::Key_Backspace, Qt::ShiftModifier|Qt::AltModifier);
+ QCOMPARE(ed->toPlainText(), QString("abc d"));
+#endif
+}
+
+// Task #70465
+void tst_QTextEdit::preserveCharFormatInAppend()
+{
+ ed->append("First para");
+ ed->append("<b>Second para</b>");
+ ed->append("third para");
+
+ QTextCursor cursor(ed->textCursor());
+
+ cursor.movePosition(QTextCursor::Start);
+ cursor.movePosition(QTextCursor::NextCharacter);
+ QCOMPARE(cursor.charFormat().fontWeight(), (int)QFont::Normal);
+ QCOMPARE(cursor.block().text(), QString("First para"));
+
+ cursor.movePosition(QTextCursor::NextBlock);
+ cursor.movePosition(QTextCursor::NextCharacter);
+ QCOMPARE(cursor.charFormat().fontWeight(), (int)QFont::Bold);
+ QCOMPARE(cursor.block().text(), QString("Second para"));
+
+ cursor.movePosition(QTextCursor::NextBlock);
+ cursor.movePosition(QTextCursor::NextCharacter);
+ QCOMPARE(cursor.charFormat().fontWeight(), (int)QFont::Normal);
+ QCOMPARE(cursor.block().text(), QString("third para"));
+}
+
+#ifndef QT_NO_CLIPBOARD
+void tst_QTextEdit::copyAndSelectAllInReadonly()
+{
+ if (!nativeClipboardWorking())
+ QSKIP("Clipboard not working with cron-started unit tests", SkipAll);
+
+ ed->setReadOnly(true);
+ ed->setPlainText("Hello World");
+
+ QTextCursor cursor = ed->textCursor();
+ cursor.clearSelection();
+ ed->setTextCursor(cursor);
+ QVERIFY(!ed->textCursor().hasSelection());
+
+ QCOMPARE(ed->toPlainText(), QString("Hello World"));
+
+ // shouldn't do anything
+ QTest::keyClick(ed, Qt::Key_A);
+
+ QCOMPARE(ed->toPlainText(), QString("Hello World"));
+
+ QTest::keyClick(ed, Qt::Key_A, Qt::ControlModifier);
+
+ QVERIFY(ed->textCursor().hasSelection());
+
+ QApplication::clipboard()->setText(QString());
+ QVERIFY(QApplication::clipboard()->text().isEmpty());
+
+ QTest::keyClick(ed, Qt::Key_C, Qt::ControlModifier);
+ QCOMPARE(QApplication::clipboard()->text(), QString("Hello World"));
+}
+#endif
+
+void tst_QTextEdit::ctrlAltInput()
+{
+ QTest::keyClick(ed, Qt::Key_At, Qt::ControlModifier | Qt::AltModifier);
+ QCOMPARE(ed->toPlainText(), QString("@"));
+}
+
+void tst_QTextEdit::noPropertiesOnDefaultTextEditCharFormat()
+{
+ // there should be no properties set on the default/initial char format
+ // on a text edit. Font properties instead should be taken from the
+ // widget's font (in sync with defaultFont property in document) and the
+ // foreground color should be taken from the palette.
+ QCOMPARE(ed->currentCharFormat().properties().count(), 0);
+}
+
+void tst_QTextEdit::setPlainTextShouldUseCurrentCharFormat()
+{
+ ed->setFontUnderline(true);
+ ed->setPlainText("Hello World");
+ QTextCursor cursor(ed->document());
+ cursor.movePosition(QTextCursor::NextCharacter);
+ QCOMPARE(cursor.charFormat().fontUnderline(), true);
+
+ ed->setHtml("<p style=\"color:blue\">Foo</p>");
+ ed->setPlainText("Hello World");
+ cursor = QTextCursor(ed->document());
+ cursor.movePosition(QTextCursor::NextCharacter);
+ QCOMPARE(cursor.charFormat().fontUnderline(), true);
+}
+
+void tst_QTextEdit::setPlainTextShouldEmitTextChangedOnce()
+{
+ QSignalSpy spy(ed, SIGNAL(textChanged()));
+ ed->setPlainText("Yankee Doodle");
+ QCOMPARE(spy.count(), 1);
+ ed->setPlainText("");
+ QCOMPARE(spy.count(), 2);
+}
+
+void tst_QTextEdit::overwriteMode()
+{
+ QVERIFY(!ed->overwriteMode());
+ QTest::keyClicks(ed, "Some first text");
+
+ QCOMPARE(ed->toPlainText(), QString("Some first text"));
+
+ ed->setOverwriteMode(true);
+
+ QTextCursor cursor = ed->textCursor();
+ cursor.setPosition(5);
+ ed->setTextCursor(cursor);
+
+ QTest::keyClicks(ed, "shiny");
+ QCOMPARE(ed->toPlainText(), QString("Some shiny text"));
+
+ cursor.movePosition(QTextCursor::End);
+ ed->setTextCursor(cursor);
+
+ QTest::keyClick(ed, Qt::Key_Enter);
+
+ ed->setOverwriteMode(false);
+ QTest::keyClicks(ed, "Second paragraph");
+
+ QCOMPARE(blockCount(), 2);
+
+ cursor.movePosition(QTextCursor::Start);
+ cursor.movePosition(QTextCursor::EndOfBlock);
+
+ QCOMPARE(cursor.position(), 15);
+ ed->setTextCursor(cursor);
+
+ ed->setOverwriteMode(true);
+
+ QTest::keyClicks(ed, " blah");
+
+ QCOMPARE(blockCount(), 2);
+
+ QTextBlock block = ed->document()->begin();
+ QCOMPARE(block.text(), QString("Some shiny text blah"));
+ block = block.next();
+ QCOMPARE(block.text(), QString("Second paragraph"));
+}
+
+void tst_QTextEdit::shiftDownInLineLastShouldSelectToEnd_data()
+{
+ // shift cursor-down in the last line should select to the end of the document
+
+ QTest::addColumn<QString>("input");
+ QTest::addColumn<int>("totalLineCount");
+
+ QTest::newRow("1") << QString("Foo\nBar") << 2;
+ QTest::newRow("2") << QString("Foo\nBar") + QChar(QChar::LineSeparator) + QString("Baz") << 3;
+}
+
+void tst_QTextEdit::shiftDownInLineLastShouldSelectToEnd()
+{
+ QFETCH(QString, input);
+ QFETCH(int, totalLineCount);
+
+ ed->setPlainText(input);
+ ed->show();
+
+ // ensure we're layouted
+ ed->document()->documentLayout()->documentSize();
+
+ QCOMPARE(blockCount(), 2);
+
+ int lineCount = 0;
+ for (QTextBlock block = ed->document()->begin(); block.isValid(); block = block.next())
+ lineCount += block.layout()->lineCount();
+ QCOMPARE(lineCount, totalLineCount);
+
+ QTextCursor cursor = ed->textCursor();
+ cursor.movePosition(QTextCursor::Start);
+ ed->setTextCursor(cursor);
+
+ for (int i = 0; i < lineCount; ++i) {
+ QTest::keyClick(ed, Qt::Key_Down, Qt::ShiftModifier);
+ }
+
+ input.replace(QLatin1Char('\n'), QChar(QChar::ParagraphSeparator));
+ QCOMPARE(ed->textCursor().selectedText(), input);
+ QVERIFY(ed->textCursor().atEnd());
+
+ // also test that without shift modifier the cursor does not move to the end
+ // for Key_Down in the last line
+ cursor.movePosition(QTextCursor::Start);
+ ed->setTextCursor(cursor);
+ for (int i = 0; i < lineCount; ++i) {
+ QTest::keyClick(ed, Qt::Key_Down);
+ }
+ QVERIFY(!ed->textCursor().atEnd());
+}
+
+void tst_QTextEdit::undoRedoShouldRepositionTextEditCursor()
+{
+ ed->setPlainText("five\nlines\nin\nthis\ntextedit");
+ QTextCursor cursor = ed->textCursor();
+ cursor.movePosition(QTextCursor::Start);
+
+ ed->setUndoRedoEnabled(false);
+ ed->setUndoRedoEnabled(true);
+
+ QVERIFY(!ed->document()->isUndoAvailable());
+ QVERIFY(!ed->document()->isRedoAvailable());
+
+ cursor.insertText("Blah");
+
+ QVERIFY(ed->document()->isUndoAvailable());
+ QVERIFY(!ed->document()->isRedoAvailable());
+
+ cursor.movePosition(QTextCursor::End);
+ ed->setTextCursor(cursor);
+
+ QVERIFY(QMetaObject::invokeMethod(ed, "undo"));
+
+ QVERIFY(!ed->document()->isUndoAvailable());
+ QVERIFY(ed->document()->isRedoAvailable());
+
+ QCOMPARE(ed->textCursor().position(), 0);
+
+ cursor.movePosition(QTextCursor::End);
+ ed->setTextCursor(cursor);
+
+ QVERIFY(QMetaObject::invokeMethod(ed, "redo"));
+
+ QVERIFY(ed->document()->isUndoAvailable());
+ QVERIFY(!ed->document()->isRedoAvailable());
+
+ QCOMPARE(ed->textCursor().position(), 4);
+}
+
+void tst_QTextEdit::lineWrapModes()
+{
+ ed->setLineWrapMode(QTextEdit::NoWrap);
+ // NoWrap at the same time as having all lines that are all left aligned means we optimize to only layout once. The effect is that the width is always 0
+ QVERIFY(ed->document()->pageSize().width() == qreal(0));
+
+ QTextCursor cursor = QTextCursor(ed->document());
+ cursor.insertText(QString("A simple line"));
+ cursor.insertBlock();
+ QTextBlockFormat fmt;
+ fmt.setAlignment(Qt::AlignRight);
+ cursor.mergeBlockFormat(fmt);
+ cursor.insertText(QString("Another line"));
+ ed->show(); // relayout;
+ QVERIFY(ed->document()->pageSize().width() > qreal(0));
+
+ ed->setLineWrapColumnOrWidth(10);
+ ed->setLineWrapMode(QTextEdit::FixedColumnWidth);
+ QVERIFY(!qIsNull(ed->document()->pageSize().width()));
+
+ ed->setLineWrapColumnOrWidth(1000);
+ ed->setLineWrapMode(QTextEdit::FixedPixelWidth);
+ QCOMPARE(ed->document()->pageSize().width(), qreal(1000));
+}
+
+void tst_QTextEdit::mouseCursorShape()
+{
+#ifndef QT_NO_CURSOR
+ // always show an IBeamCursor, see change 170146
+ QVERIFY(!ed->isReadOnly());
+ QVERIFY(ed->viewport()->cursor().shape() == Qt::IBeamCursor);
+
+ ed->setReadOnly(true);
+ QVERIFY(ed->viewport()->cursor().shape() == Qt::IBeamCursor);
+
+ ed->setPlainText("Foo");
+ QVERIFY(ed->viewport()->cursor().shape() == Qt::IBeamCursor);
+#endif
+}
+
+void tst_QTextEdit::implicitClear()
+{
+ // test that QTextEdit::setHtml, etc. avoid calling clear() but instead call
+ // QTextDocument::setHtml/etc. instead, which also clear the contents and
+ // cached resource but preserve manually added resources. setHtml on a textedit
+ // should behave the same as on a document with respect to that.
+ // see also clearResources() autotest in qtextdocument
+
+ // regular resource for QTextDocument
+ QUrl testUrl(":/foobar");
+ QVariant testResource("hello world");
+
+ ed->document()->addResource(QTextDocument::ImageResource, testUrl, testResource);
+ QVERIFY(ed->document()->resource(QTextDocument::ImageResource, testUrl) == testResource);
+
+ ed->setPlainText("Blah");
+ QVERIFY(ed->document()->resource(QTextDocument::ImageResource, testUrl) == testResource);
+
+ ed->setPlainText("<b>Blah</b>");
+ QVERIFY(ed->document()->resource(QTextDocument::ImageResource, testUrl) == testResource);
+
+ ed->clear();
+ QVERIFY(!ed->document()->resource(QTextDocument::ImageResource, testUrl).isValid());
+ QVERIFY(ed->toPlainText().isEmpty());
+}
+
+#ifndef QT_NO_CLIPBOARD
+void tst_QTextEdit::copyAvailable_data()
+{
+ QTest::addColumn<pairListType>("keystrokes");
+ QTest::addColumn<QList<bool> >("copyAvailable");
+ QTest::addColumn<QString>("function");
+
+ pairListType keystrokes;
+ QList<bool> copyAvailable;
+
+ keystrokes << qMakePair(Qt::Key_B, Qt::NoModifier) << qMakePair(Qt::Key_B, Qt::NoModifier)
+ << qMakePair(Qt::Key_Left, Qt::ShiftModifier);
+ copyAvailable << true ;
+ QTest::newRow(QString("Case1 B,B, <- + shift | signals: true").toLatin1())
+ << keystrokes << copyAvailable << QString();
+
+ keystrokes.clear();
+ copyAvailable.clear();
+
+ keystrokes << qMakePair(Qt::Key_T, Qt::NoModifier) << qMakePair(Qt::Key_A, Qt::NoModifier)
+ << qMakePair(Qt::Key_A, Qt::NoModifier) << qMakePair(Qt::Key_Left, Qt::ShiftModifier);
+ copyAvailable << true << false;
+ QTest::newRow(QString("Case2 T,A,A, <- + shift, cut() | signals: true, false").toLatin1())
+ << keystrokes << copyAvailable << QString("cut");
+
+ keystrokes.clear();
+ copyAvailable.clear();
+
+ keystrokes << qMakePair(Qt::Key_T, Qt::NoModifier) << qMakePair(Qt::Key_A, Qt::NoModifier)
+ << qMakePair(Qt::Key_A, Qt::NoModifier) << qMakePair(Qt::Key_Left, Qt::ShiftModifier)
+ << qMakePair(Qt::Key_Left, Qt::ShiftModifier) << qMakePair(Qt::Key_Left, Qt::ShiftModifier);
+ copyAvailable << true;
+ QTest::newRow(QString("Case3 T,A,A, <- + shift, <- + shift, <- + shift, copy() | signals: true").toLatin1())
+ << keystrokes << copyAvailable << QString("copy");
+
+ keystrokes.clear();
+ copyAvailable.clear();
+
+ keystrokes << qMakePair(Qt::Key_T, Qt::NoModifier) << qMakePair(Qt::Key_A, Qt::NoModifier)
+ << qMakePair(Qt::Key_A, Qt::NoModifier) << qMakePair(Qt::Key_Left, Qt::ShiftModifier)
+ << qMakePair(Qt::Key_Left, Qt::ShiftModifier) << qMakePair(Qt::Key_Left, Qt::ShiftModifier)
+ << qMakePair(Qt::Key_X, Qt::ControlModifier);
+ copyAvailable << true << false;
+ QTest::newRow(QString("Case4 T,A,A, <- + shift, <- + shift, <- + shift, ctrl + x, paste() | signals: true, false").toLatin1())
+ << keystrokes << copyAvailable << QString("paste");
+
+ keystrokes.clear();
+ copyAvailable.clear();
+
+ keystrokes << qMakePair(Qt::Key_B, Qt::NoModifier) << qMakePair(Qt::Key_B, Qt::NoModifier)
+ << qMakePair(Qt::Key_Left, Qt::ShiftModifier) << qMakePair(Qt::Key_Left, Qt::NoModifier);
+ copyAvailable << true << false;
+ QTest::newRow(QString("Case5 B,B, <- + shift, <- | signals: true, false").toLatin1())
+ << keystrokes << copyAvailable << QString();
+
+ keystrokes.clear();
+ copyAvailable.clear();
+
+ keystrokes << qMakePair(Qt::Key_B, Qt::NoModifier) << qMakePair(Qt::Key_A, Qt::NoModifier)
+ << qMakePair(Qt::Key_Left, Qt::ShiftModifier) << qMakePair(Qt::Key_Left, Qt::NoModifier)
+ << qMakePair(Qt::Key_Right, Qt::ShiftModifier);
+ copyAvailable << true << false << true << false;
+ QTest::newRow(QString("Case6 B,A, <- + shift, ->, <- + shift | signals: true, false, true, false").toLatin1())
+ << keystrokes << copyAvailable << QString("cut");
+
+ keystrokes.clear();
+ copyAvailable.clear();
+
+ keystrokes << qMakePair(Qt::Key_T, Qt::NoModifier) << qMakePair(Qt::Key_A, Qt::NoModifier)
+ << qMakePair(Qt::Key_A, Qt::NoModifier) << qMakePair(Qt::Key_Left, Qt::ShiftModifier)
+ << qMakePair(Qt::Key_Left, Qt::ShiftModifier) << qMakePair(Qt::Key_Left, Qt::ShiftModifier)
+ << qMakePair(Qt::Key_X, Qt::ControlModifier);
+ copyAvailable << true << false << true;
+ QTest::newRow(QString("Case7 T,A,A, <- + shift, <- + shift, <- + shift, ctrl + x, undo() | signals: true, false, true").toLatin1())
+ << keystrokes << copyAvailable << QString("undo");
+}
+
+//Tests the copyAvailable slot for several cases
+void tst_QTextEdit::copyAvailable()
+{
+ QFETCH(pairListType,keystrokes);
+ QFETCH(QList<bool>, copyAvailable);
+ QFETCH(QString, function);
+
+#ifdef Q_WS_MAC
+ QSKIP("copyAvailable has never passed on Mac, task to fix is 132482", SkipAll);
+#endif
+ ed->clear();
+ QApplication::clipboard()->clear();
+ QVERIFY(!ed->canPaste());
+ QSignalSpy spyCopyAvailabe(ed, SIGNAL(copyAvailable(bool)));
+
+ //Execute Keystrokes
+ foreach(keyPairType keyPair, keystrokes) {
+ QTest::keyClick(ed, keyPair.first, keyPair.second );
+ }
+
+ //Execute ed->"function"
+ if (function == "cut")
+ ed->cut();
+ else if (function == "copy")
+ ed->copy();
+ else if (function == "paste")
+ ed->paste();
+ else if (function == "undo")
+ ed->paste();
+ else if (function == "redo")
+ ed->paste();
+
+ //Compare spied signals
+ QEXPECT_FAIL("Case7 T,A,A, <- + shift, <- + shift, <- + shift, ctrl + x, undo() | signals: true, false, true",
+ "Wrong undo selection behaviour. Should be fixed in some future release. (See task: 132482)", Abort);
+ QCOMPARE(spyCopyAvailabe.count(), copyAvailable.count());
+ for (int i=0;i<spyCopyAvailabe.count(); i++) {
+ QVariant variantSpyCopyAvailable = spyCopyAvailabe.at(i).at(0);
+ QVERIFY2(variantSpyCopyAvailable.toBool() == copyAvailable.at(i), QString("Spied singnal: %1").arg(i).toLatin1());
+ }
+}
+#endif
+
+void tst_QTextEdit::undoRedoAfterSetContent()
+{
+ QVERIFY(!ed->document()->isUndoAvailable());
+ QVERIFY(!ed->document()->isRedoAvailable());
+ ed->setPlainText("Foobar");
+ QVERIFY(!ed->document()->isUndoAvailable());
+ QVERIFY(!ed->document()->isRedoAvailable());
+ ed->setHtml("<p>bleh</p>");
+ QVERIFY(!ed->document()->isUndoAvailable());
+ QVERIFY(!ed->document()->isRedoAvailable());
+}
+
+void tst_QTextEdit::numPadKeyNavigation()
+{
+ ed->setText("Hello World");
+ QCOMPARE(ed->textCursor().position(), 0);
+ QTest::keyClick(ed, Qt::Key_Right, Qt::KeypadModifier);
+ QCOMPARE(ed->textCursor().position(), 1);
+}
+
+void tst_QTextEdit::moveCursor()
+{
+ ed->setText("Test");
+
+ QSignalSpy cursorMovedSpy(ed, SIGNAL(cursorPositionChanged()));
+
+ QCOMPARE(ed->textCursor().position(), 0);
+ ed->moveCursor(QTextCursor::NextCharacter);
+ QCOMPARE(ed->textCursor().position(), 1);
+ QCOMPARE(cursorMovedSpy.count(), 1);
+ ed->moveCursor(QTextCursor::NextCharacter, QTextCursor::KeepAnchor);
+ QCOMPARE(ed->textCursor().position(), 2);
+ QCOMPARE(cursorMovedSpy.count(), 2);
+ QCOMPARE(ed->textCursor().selectedText(), QString("e"));
+}
+
+class MyTextEdit : public QTextEdit
+{
+public:
+ inline MyTextEdit()
+ : createMimeDataCallCount(0),
+ canInsertCallCount(0),
+ insertCallCount(0)
+ {}
+
+ mutable int createMimeDataCallCount;
+ mutable int canInsertCallCount;
+ mutable int insertCallCount;
+
+ virtual QMimeData *createMimeDataFromSelection() const {
+ createMimeDataCallCount++;
+ return QTextEdit::createMimeDataFromSelection();
+ }
+ virtual bool canInsertFromMimeData(const QMimeData *source) const {
+ canInsertCallCount++;
+ return QTextEdit::canInsertFromMimeData(source);
+ }
+ virtual void insertFromMimeData(const QMimeData *source) {
+ insertCallCount++;
+ QTextEdit::insertFromMimeData(source);
+ }
+
+};
+
+#ifndef QT_NO_CLIPBOARD
+void tst_QTextEdit::mimeDataReimplementations()
+{
+ MyTextEdit ed;
+ ed.setPlainText("Hello World");
+
+ QCOMPARE(ed.createMimeDataCallCount, 0);
+ QCOMPARE(ed.canInsertCallCount, 0);
+ QCOMPARE(ed.insertCallCount, 0);
+
+ ed.selectAll();
+
+ QCOMPARE(ed.createMimeDataCallCount, 0);
+ QCOMPARE(ed.canInsertCallCount, 0);
+ QCOMPARE(ed.insertCallCount, 0);
+
+ ed.copy();
+
+ QCOMPARE(ed.createMimeDataCallCount, 1);
+ QCOMPARE(ed.canInsertCallCount, 0);
+ QCOMPARE(ed.insertCallCount, 0);
+
+#ifdef QT_BUILD_INTERNAL
+ QWidgetTextControl *control = qFindChild<QWidgetTextControl *>(&ed);
+ QVERIFY(control);
+
+ control->canInsertFromMimeData(QApplication::clipboard()->mimeData());
+
+ QCOMPARE(ed.createMimeDataCallCount, 1);
+ QCOMPARE(ed.canInsertCallCount, 1);
+ QCOMPARE(ed.insertCallCount, 0);
+
+ ed.paste();
+
+ QCOMPARE(ed.createMimeDataCallCount, 1);
+ QCOMPARE(ed.canInsertCallCount, 1);
+ QCOMPARE(ed.insertCallCount, 1);
+#endif
+}
+#endif
+
+void tst_QTextEdit::ctrlEnterShouldInsertLineSeparator_NOT()
+{
+ QTest::keyClick(ed, Qt::Key_A);
+ QTest::keyClick(ed, Qt::Key_Enter, Qt::ControlModifier);
+ QTest::keyClick(ed, Qt::Key_B);
+ QString expected;
+ expected += 'a';
+// expected += QChar::LineSeparator; // do NOT insert
+ expected += 'b';
+ QCOMPARE(ed->textCursor().block().text(), expected);
+}
+
+void tst_QTextEdit::shiftEnterShouldInsertLineSeparator()
+{
+ QTest::keyClick(ed, Qt::Key_A);
+ QTest::keyClick(ed, Qt::Key_Enter, Qt::ShiftModifier);
+ QTest::keyClick(ed, Qt::Key_B);
+ QString expected;
+ expected += 'a';
+ expected += QChar::LineSeparator;
+ expected += 'b';
+ QCOMPARE(ed->textCursor().block().text(), expected);
+}
+
+void tst_QTextEdit::selectWordsFromStringsContainingSeparators_data()
+{
+ QTest::addColumn<QString>("testString");
+ QTest::addColumn<QString>("selectedWord");
+
+ QStringList wordSeparators;
+ wordSeparators << "." << "," << "?" << "!" << ":" << ";" << "-" << "<" << ">" << "["
+ << "]" << "(" << ")" << "{" << "}" << "=" << "\t"<< QString(QChar::Nbsp);
+
+ foreach (QString s, wordSeparators)
+ QTest::newRow(QString("separator: " + s).toLocal8Bit()) << QString("foo") + s + QString("bar") << QString("foo");
+}
+
+void tst_QTextEdit::selectWordsFromStringsContainingSeparators()
+{
+ QFETCH(QString, testString);
+ QFETCH(QString, selectedWord);
+ ed->setText(testString);
+ QTextCursor cursor = ed->textCursor();
+ cursor.movePosition(QTextCursor::StartOfLine);
+ cursor.select(QTextCursor::WordUnderCursor);
+ QVERIFY(cursor.hasSelection());
+ QCOMPARE(cursor.selection().toPlainText(), selectedWord);
+ cursor.clearSelection();
+}
+
+#ifndef QT_NO_CLIPBOARD
+void tst_QTextEdit::canPaste()
+{
+ if (!nativeClipboardWorking())
+ QSKIP("Clipboard not working with cron-started unit tests", SkipAll);
+
+ QApplication::clipboard()->setText(QString());
+ QVERIFY(!ed->canPaste());
+ QApplication::clipboard()->setText("Test");
+ QVERIFY(ed->canPaste());
+ ed->setTextInteractionFlags(Qt::NoTextInteraction);
+ QVERIFY(!ed->canPaste());
+}
+#endif
+
+void tst_QTextEdit::ensureCursorVisibleOnInitialShow()
+{
+ QString manyPagesOfPlainText;
+ for (int i = 0; i < 800; ++i)
+ manyPagesOfPlainText += QLatin1String("Blah blah blah blah blah blah\n");
+
+ ed->setPlainText(manyPagesOfPlainText);
+ QCOMPARE(ed->textCursor().position(), 0);
+
+ ed->moveCursor(QTextCursor::End);
+ ed->show();
+ QVERIFY(ed->verticalScrollBar()->value() > 10);
+
+ ed->moveCursor(QTextCursor::Start);
+ QVERIFY(ed->verticalScrollBar()->value() < 10);
+ ed->hide();
+ ed->verticalScrollBar()->setValue(ed->verticalScrollBar()->maximum());
+ ed->show();
+ QCOMPARE(ed->verticalScrollBar()->value(), ed->verticalScrollBar()->maximum());
+}
+
+class TestEdit : public QTextEdit
+{
+public:
+ TestEdit() : resizeEventCalled(false) {}
+
+ bool resizeEventCalled;
+
+protected:
+ virtual void resizeEvent(QResizeEvent *e)
+ {
+ QTextEdit::resizeEvent(e);
+ setHtml("<img src=qtextbrowser-resizeevent.png width=" + QString::number(size().width()) + "><br>Size is " + QString::number(size().width()) + " x " + QString::number(size().height()));
+ resizeEventCalled = true;
+ }
+};
+
+void tst_QTextEdit::setHtmlInsideResizeEvent()
+{
+ TestEdit edit;
+ edit.show();
+ edit.resize(800, 600);
+ QVERIFY(edit.resizeEventCalled);
+}
+
+void tst_QTextEdit::colorfulAppend()
+{
+ ed->setTextColor(Qt::red);
+ ed->append("Red");
+ ed->setTextColor(Qt::blue);
+ ed->append("Blue");
+ ed->setTextColor(Qt::green);
+ ed->append("Green");
+
+ QCOMPARE(ed->document()->blockCount(), 3);
+ QTextBlock block = ed->document()->begin();
+ QCOMPARE(block.begin().fragment().text(), QString("Red"));
+ QVERIFY(block.begin().fragment().charFormat().foreground().color() == Qt::red);
+ block = block.next();
+ QCOMPARE(block.begin().fragment().text(), QString("Blue"));
+ QVERIFY(block.begin().fragment().charFormat().foreground().color() == Qt::blue);
+ block = block.next();
+ QCOMPARE(block.begin().fragment().text(), QString("Green"));
+ QVERIFY(block.begin().fragment().charFormat().foreground().color() == Qt::green);
+}
+
+void tst_QTextEdit::ensureVisibleWithRtl()
+{
+ ed->setLayoutDirection(Qt::RightToLeft);
+ ed->setLineWrapMode(QTextEdit::NoWrap);
+ QString txt(500, QChar(QLatin1Char('a')));
+ QCOMPARE(txt.length(), 500);
+ ed->setPlainText(txt);
+ ed->resize(100, 100);
+ ed->show();
+
+ qApp->processEvents();
+
+ QVERIFY(ed->horizontalScrollBar()->maximum() > 0);
+
+ ed->moveCursor(QTextCursor::Start);
+ QCOMPARE(ed->horizontalScrollBar()->value(), ed->horizontalScrollBar()->maximum());
+ ed->moveCursor(QTextCursor::End);
+ QCOMPARE(ed->horizontalScrollBar()->value(), 0);
+ ed->moveCursor(QTextCursor::Start);
+ QCOMPARE(ed->horizontalScrollBar()->value(), ed->horizontalScrollBar()->maximum());
+ ed->moveCursor(QTextCursor::End);
+ QCOMPARE(ed->horizontalScrollBar()->value(), 0);
+}
+
+void tst_QTextEdit::preserveCharFormatAfterSetPlainText()
+{
+ ed->setTextColor(Qt::blue);
+ ed->setPlainText("This is blue");
+ ed->append("This should still be blue");
+ QTextBlock block = ed->document()->begin();
+ block = block.next();
+ QCOMPARE(block.text(), QString("This should still be blue"));
+ QVERIFY(block.begin().fragment().charFormat().foreground().color() == QColor(Qt::blue));
+}
+
+void tst_QTextEdit::extraSelections()
+{
+ ed->setPlainText("Hello World");
+
+ QTextCursor c = ed->textCursor();
+ c.movePosition(QTextCursor::Start);
+ c.movePosition(QTextCursor::End, QTextCursor::KeepAnchor);
+ const int endPos = c.position();
+
+ QTextEdit::ExtraSelection sel;
+ sel.cursor = c;
+ ed->setExtraSelections(QList<QTextEdit::ExtraSelection>() << sel);
+
+ c.movePosition(QTextCursor::Start);
+ c.movePosition(QTextCursor::NextWord);
+ const int wordPos = c.position();
+ c.movePosition(QTextCursor::End, QTextCursor::KeepAnchor);
+ sel.cursor = c;
+ ed->setExtraSelections(QList<QTextEdit::ExtraSelection>() << sel);
+
+ QList<QTextEdit::ExtraSelection> selections = ed->extraSelections();
+ QCOMPARE(selections.count(), 1);
+ QCOMPARE(selections.at(0).cursor.position(), endPos);
+ QCOMPARE(selections.at(0).cursor.anchor(), wordPos);
+}
+
+void tst_QTextEdit::adjustScrollbars()
+{
+// For some reason ff is defined to be << on Mac Panther / gcc 3.3
+#undef ff
+ QFont ff(ed->font());
+ ff.setFamily("Tahoma");
+ ff.setPointSize(11);
+ ed->setFont(ff);
+ ed->setMinimumSize(140, 100);
+ ed->setMaximumSize(140, 100);
+ ed->show();
+ QLatin1String txt("\nabc def ghi jkl mno pqr stu vwx");
+ ed->setText(txt + txt + txt + txt);
+
+ QVERIFY(ed->verticalScrollBar()->maximum() > 0);
+
+ ed->moveCursor(QTextCursor::End);
+ int oldMaximum = ed->verticalScrollBar()->maximum();
+ QTextCursor cursor = ed->textCursor();
+ cursor.insertText(QLatin1String("\n"));
+ cursor.deletePreviousChar();
+ QCOMPARE(ed->verticalScrollBar()->maximum(), oldMaximum);
+}
+
+class SignalReceiver : public QObject
+{
+ Q_OBJECT
+public:
+ SignalReceiver() : received(0) {}
+
+ int receivedSignals() const { return received; }
+ QTextCharFormat charFormat() const { return format; }
+
+public slots:
+ void charFormatChanged(const QTextCharFormat &tcf) { ++received; format = tcf; }
+
+private:
+ QTextCharFormat format;
+ int received;
+};
+
+void tst_QTextEdit::currentCharFormatChanged()
+{
+ QFont ff(ed->font());
+ ff.setFamily("Tahoma");
+ ff.setPointSize(11);
+
+ SignalReceiver receiver;
+ QObject::connect(ed, SIGNAL(currentCharFormatChanged(const QTextCharFormat &)) , &receiver, SLOT(charFormatChanged(const QTextCharFormat &)));
+
+ ed->show();
+ ed->setCurrentFont(ff);
+
+ QVERIFY(receiver.receivedSignals() > 0);
+ QCOMPARE(receiver.charFormat().font(), ff);
+}
+
+void tst_QTextEdit::textObscuredByScrollbars()
+{
+ ed->textCursor().insertText(
+ "ab cab cab c abca kjsdf lka sjd lfk jsal df j kasdf abc ab abc "
+ "a b c d e f g h i j k l m n o p q r s t u v w x y z "
+ "abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc "
+ "ab ab ab ab ab ab ab ab ab ab ab ab ab ab ab ab ab ab ab ab ab"
+ "abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc "
+ "ab ab ab ab ab ab ab ab ab ab ab ab ab ab ab ab ab ab ab ab ab"
+ "abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc "
+ "ab ab ab ab ab ab ab ab ab ab ab ab ab ab ab ab ab ab ab ab ab"
+ "abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc "
+ "ab ab ab ab ab ab ab ab ab ab ab ab ab ab ab ab ab ab ab ab ab"
+ "abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc "
+ "ab ab ab ab ab ab ab ab ab ab ab ab ab ab ab ab ab ab ab ab ab"
+ );
+ ed->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
+ ed->show();
+
+ QSize documentSize = ed->document()->documentLayout()->documentSize().toSize();
+ QSize viewportSize = ed->viewport()->size();
+
+ QVERIFY(documentSize.width() <= viewportSize.width());
+}
+
+void tst_QTextEdit::setTextPreservesUndoRedoEnabled()
+{
+ QVERIFY(ed->isUndoRedoEnabled());
+
+ ed->setPlainText("Test");
+
+ QVERIFY(ed->isUndoRedoEnabled());
+
+ ed->setUndoRedoEnabled(false);
+ QVERIFY(!ed->isUndoRedoEnabled());
+ ed->setPlainText("Test2");
+ QVERIFY(!ed->isUndoRedoEnabled());
+
+ ed->setHtml("<p>hello");
+ QVERIFY(!ed->isUndoRedoEnabled());
+}
+
+void tst_QTextEdit::wordWrapProperty()
+{
+ {
+ QTextEdit edit;
+ QTextDocument *doc = new QTextDocument(&edit);
+ edit.setDocument(doc);
+ edit.setWordWrapMode(QTextOption::NoWrap);
+ QVERIFY(doc->defaultTextOption().wrapMode() == QTextOption::NoWrap);
+ }
+ {
+ QTextEdit edit;
+ QTextDocument *doc = new QTextDocument(&edit);
+ edit.setWordWrapMode(QTextOption::NoWrap);
+ edit.setDocument(doc);
+ QVERIFY(doc->defaultTextOption().wrapMode() == QTextOption::NoWrap);
+ }
+}
+
+void tst_QTextEdit::lineWrapProperty()
+{
+ QVERIFY(ed->wordWrapMode() == QTextOption::WrapAtWordBoundaryOrAnywhere);
+ QVERIFY(ed->lineWrapMode() == QTextEdit::WidgetWidth);
+ ed->setLineWrapMode(QTextEdit::NoWrap);
+ QVERIFY(ed->lineWrapMode() == QTextEdit::NoWrap);
+ QVERIFY(ed->wordWrapMode() == QTextOption::WrapAtWordBoundaryOrAnywhere);
+ QVERIFY(ed->document()->defaultTextOption().wrapMode() == QTextOption::NoWrap);
+}
+
+void tst_QTextEdit::selectionChanged()
+{
+ ed->setPlainText("Hello World");
+
+ ed->moveCursor(QTextCursor::Start);
+
+ QSignalSpy selectionChangedSpy(ed, SIGNAL(selectionChanged()));
+
+ QTest::keyClick(ed, Qt::Key_Right);
+ QCOMPARE(ed->textCursor().position(), 1);
+ QCOMPARE(selectionChangedSpy.count(), 0);
+
+ QTest::keyClick(ed, Qt::Key_Right, Qt::ShiftModifier);
+ QCOMPARE(ed->textCursor().position(), 2);
+ QCOMPARE(selectionChangedSpy.count(), 1);
+
+ QTest::keyClick(ed, Qt::Key_Right, Qt::ShiftModifier);
+ QCOMPARE(ed->textCursor().position(), 3);
+ QCOMPARE(selectionChangedSpy.count(), 2);
+
+ QTest::keyClick(ed, Qt::Key_Right, Qt::ShiftModifier);
+ QCOMPARE(ed->textCursor().position(), 4);
+ QCOMPARE(selectionChangedSpy.count(), 3);
+
+ QTest::keyClick(ed, Qt::Key_Right);
+ QCOMPARE(ed->textCursor().position(), 5);
+ QCOMPARE(selectionChangedSpy.count(), 4);
+
+ QTest::keyClick(ed, Qt::Key_Right);
+ QCOMPARE(ed->textCursor().position(), 6);
+ QCOMPARE(selectionChangedSpy.count(), 4);
+}
+
+void tst_QTextEdit::copyPasteBackgroundImage()
+{
+#ifndef QT_NO_CLIPBOARD
+ if (!nativeClipboardWorking())
+ QSKIP("Native clipboard not working in this setup", SkipAll);
+
+ QImage foo(16, 16, QImage::Format_ARGB32_Premultiplied);
+ foo.save("foo.png");
+ ed->setHtml("<body><table><tr><td background=\"foo.png\">Foo</td></tr></table></body>");
+
+ ed->moveCursor(QTextCursor::Start);
+ ed->moveCursor(QTextCursor::End, QTextCursor::KeepAnchor);
+
+ ed->copy();
+
+ ed->moveCursor(QTextCursor::End, QTextCursor::MoveAnchor);
+ ed->paste();
+
+ ed->moveCursor(QTextCursor::Start);
+
+ ed->moveCursor(QTextCursor::NextBlock);
+ QTextTable *a = ed->textCursor().currentTable();
+
+ ed->moveCursor(QTextCursor::End);
+ ed->moveCursor(QTextCursor::PreviousBlock);
+ QTextTable *b = ed->textCursor().currentTable();
+
+ QVERIFY(a);
+ QVERIFY(b);
+ QVERIFY(a != b);
+
+ QBrush ba = a->cellAt(0, 0).format().background();
+ QBrush bb = b->cellAt(0, 0).format().background();
+
+ QCOMPARE(ba.style(), Qt::TexturePattern);
+ QCOMPARE(ba.style(), bb.style());
+
+ // we don't want a copy/paste of the background image to cause
+ // a new image/pixmap to be created, it should use the cached resource
+ // already in the document
+ QVERIFY(ba.textureImage().cacheKey() == bb.textureImage().cacheKey() ||
+ ba.texture().cacheKey() == bb.texture().cacheKey());
+ QFile::remove(QLatin1String("foo.png"));
+#endif
+}
+
+void tst_QTextEdit::setText()
+{
+ QTextEdit browser;
+ browser.setText(QLatin1String("hello"));
+ QCOMPARE(browser.toPlainText(), QLatin1String("hello"));
+ browser.setText(QLatin1String("<b>bold bold</b>"));
+ QCOMPARE(browser.toPlainText(), QLatin1String("bold bold"));
+ browser.setText(QLatin1String("with space"));
+ QCOMPARE(browser.toPlainText(), QLatin1String("with space"));
+}
+
+QT_BEGIN_NAMESPACE
+extern void qt_setQtEnableTestFont(bool value);
+QT_END_NAMESPACE
+
+void tst_QTextEdit::fullWidthSelection_data()
+{
+ QTest::addColumn<int>("cursorFrom");
+ QTest::addColumn<int>("cursorTo");
+ QTest::addColumn<QString>("imageFileName");
+
+ QTest::newRow("centered fully selected") << 0 << 15 << QString("fullWidthSelection/centered-fully-selected.png");
+ QTest::newRow("centered partly selected") << 2 << 15 << QString("fullWidthSelection/centered-partly-selected.png");
+ QTest::newRow("last char on line") << 42 << 44 << QString("fullWidthSelection/last-char-on-line.png");
+ QTest::newRow("last char on parag") << 545 << 548 << QString("fullWidthSelection/last-char-on-parag.png");
+ QTest::newRow("multiple full width lines") << 20 << 60 << QString("fullWidthSelection/multiple-full-width-lines.png");
+ QTest::newRow("single full width line") << 20 << 30 << QString("fullWidthSelection/single-full-width-line.png");
+}
+
+void tst_QTextEdit::fullWidthSelection()
+{
+ QFETCH(int, cursorFrom);
+ QFETCH(int, cursorTo);
+ QFETCH(QString, imageFileName);
+
+ // enable full-width-selection for our test widget.
+ class FullWidthStyle : public QCommonStyle {
+ int styleHint(StyleHint stylehint, const QStyleOption *opt, const QWidget *widget, QStyleHintReturn *returnData) const {
+ if (stylehint == QStyle::SH_RichText_FullWidthSelection)
+ return 1;
+ return QCommonStyle::styleHint(stylehint, opt, widget, returnData);
+ };
+ };
+ FullWidthStyle myStyle;
+
+ QPalette myPalette = myStyle.standardPalette();
+ myPalette.setColor(QPalette::All, QPalette::HighlightedText, QColor(0,0,0,0));
+ myPalette.setColor(QPalette::All, QPalette::Highlight, QColor(239,221,85));
+
+ QTextEdit widget;
+ widget.document()->setDocumentMargin(2);
+ widget.setPalette(myPalette);
+ widget.setStyle(&myStyle);
+ QTextCursor cursor = widget.textCursor();
+ QTextBlockFormat bf1;
+ bf1.setAlignment(Qt::AlignCenter);
+ cursor.setBlockFormat(bf1);
+
+ // use the test font so we always know where stuff will end up.
+ qt_setQtEnableTestFont(true);
+ QFont testFont;
+ testFont.setFamily("__Qt__Box__Engine__");
+ testFont.setPixelSize(11);
+ testFont.setWeight(QFont::Normal);
+ QTextCharFormat cf;
+ cf.setFont(testFont);
+ cf.setForeground(QColor(0,0,0,0)); // tricky bit, this :)
+ cursor.setCharFormat(cf);
+
+ // populate with some demo text.
+ cursor.insertText("centered");
+ QTextBlockFormat bf;
+ cursor.insertBlock(bf, cf);
+ cursor.insertText("Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi. Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo cons.\nfoo\n");
+
+ // Usecase 1 for full-width-selections; the 'show-cursor-position' one.
+ QList<QTextEdit::ExtraSelection> selections;
+ QTextCursor cursor2(widget.document());
+ QTextEdit::ExtraSelection es;
+ cursor2.setPosition(300);
+ es.cursor = cursor2;
+ es.format.setProperty( QTextFormat::FullWidthSelection, true );
+ es.format.setBackground(QColor(255, 0, 0));
+ selections.append(es);
+ widget.setExtraSelections(selections);
+
+ // Usecase 2; show it based on the style.
+ // Select part of the centered text and part of the next; which means we should show the part right of the centered text.
+ cursor.setPosition(cursorFrom);
+ cursor.setPosition(cursorTo, QTextCursor::KeepAnchor);
+ widget.setTextCursor(cursor);
+
+ compareWidgetAndImage(widget, imageFileName);
+}
+
+void tst_QTextEdit::fullWidthSelection2()
+{
+ QPalette myPalette;
+ myPalette.setColor(QPalette::All, QPalette::HighlightedText, QColor(0,0,0,0));
+ myPalette.setColor(QPalette::All, QPalette::Highlight, QColor(239,221,85));
+
+ QTextEdit widget;
+ widget.setPalette(myPalette);
+ widget.setLineWrapMode(QTextEdit::NoWrap);
+ QTextCursor cursor = widget.textCursor();
+
+ // use the test font so we always know where stuff will end up.
+ qt_setQtEnableTestFont(true);
+ QFont testFont;
+ testFont.setFamily("__Qt__Box__Engine__");
+ testFont.setPixelSize(11);
+ testFont.setWeight(QFont::Normal);
+ QTextCharFormat cf;
+ cf.setFont(testFont);
+ cf.setForeground(QColor(0,0,0,0)); // tricky bit, this :)
+ cursor.setCharFormat(cf);
+ cursor.insertText("foo");
+
+ QList<QTextEdit::ExtraSelection> selections;
+ QTextCursor cursor2(widget.document());
+ QTextEdit::ExtraSelection es;
+ cursor2.setPosition(1);
+ es.cursor = cursor2;
+ es.format.setProperty( QTextFormat::FullWidthSelection, true );
+ es.format.setBackground(QColor(255, 0, 0));
+ selections.append(es);
+ widget.setExtraSelections(selections);
+
+ compareWidgetAndImage(widget, "fullWidthSelection/nowrap_long.png");
+
+ QTextLine line = widget.document()->begin().layout()->lineAt(0);
+ // qDebug() << line.width();
+}
+
+void tst_QTextEdit::compareWidgetAndImage(QTextEdit &widget, const QString &imageFileName)
+{
+ widget.setGeometry(0, 0, 300, 390);
+ widget.setFrameShape(QFrame::NoFrame);
+
+ QImage image(300, 390, QImage::Format_RGB32);
+ QPainter painter(&image);
+ widget.viewport()->render(&painter);
+ painter.end();
+ // qDebug() << "file: " << QString(SRCDIR) + imageFileName;
+ QImageReader reader(QString(SRCDIR) + imageFileName, "PNG");
+ QImage original = reader.read();
+
+ QCOMPARE(original.isNull(), false);
+ QCOMPARE(original.size(), image.size());
+ QCOMPARE(image.depth(), 32);
+ QCOMPARE(original.depth(), image.depth());
+
+ const int bytesPerLine = image.bytesPerLine();
+ const int width = image.width();
+ const int height = image.height();
+
+ for (int y = 0; y < height; ++y) {
+ const QRgb * const firstLine = reinterpret_cast<const QRgb *>(image.scanLine(y));
+ const QRgb * const secondLine = reinterpret_cast<const QRgb *>(original.scanLine(y));
+
+ if (memcmp(firstLine, secondLine, bytesPerLine) != 0) {
+ for (int x = 0; x < width; ++x) {
+ const QRgb a = firstLine[x];
+ const QRgb b = secondLine[x];
+ const bool same = qAbs(qRed(a) - qRed(b)) <= 20
+ && qAbs(qGreen(a) - qGreen(b)) <= 20
+ && qAbs(qBlue(a) - qBlue(b)) <= 20;
+ if (!same) {
+ QString fileName = imageFileName;
+ QImageWriter writer("failed_"+ fileName.replace('/','_'), "PNG");
+ writer.write(image);
+ }
+ QVERIFY(same);
+ }
+ }
+ }
+}
+
+void tst_QTextEdit::cursorRect()
+{
+ ed->show();
+ ed->setPlainText("Hello Test World");
+ ed->setCursorWidth(1);
+ QCOMPARE(ed->cursorRect().width(), 1);
+ ed->setCursorWidth(2);
+ QCOMPARE(ed->cursorRect().width(), 2);
+ ed->setCursorWidth(4);
+ QCOMPARE(ed->cursorRect().width(), 4);
+ ed->setCursorWidth(10);
+ QCOMPARE(ed->cursorRect().width(), 10);
+}
+
+void tst_QTextEdit::setDocumentPreservesPalette()
+{
+#ifdef QT_BUILD_INTERNAL
+ QWidgetTextControl *control = qFindChild<QWidgetTextControl *>(ed);
+ QVERIFY(control);
+
+ QPalette defaultPal = ed->palette();
+ QPalette whitePal = ed->palette();
+ whitePal.setColor(QPalette::Active, QPalette::Text, "white");
+
+
+ QVERIFY(whitePal != ed->palette());
+ ed->setPalette(whitePal);
+ QVERIFY(whitePal.color(QPalette::Active, QPalette::Text)
+ == ed->palette().color(QPalette::Active, QPalette::Text));
+ QVERIFY(whitePal.color(QPalette::Active, QPalette::Text)
+ == control->palette().color(QPalette::Active, QPalette::Text));
+
+ QTextDocument *newDoc = new QTextDocument(ed);
+ ed->setDocument(newDoc);
+ QVERIFY(control->document() == newDoc);
+ QVERIFY(whitePal.color(QPalette::Active, QPalette::Text)
+ == control->palette().color(QPalette::Active, QPalette::Text));
+#endif
+}
+
+class PublicTextEdit : public QTextEdit
+{
+public:
+ void publicInsertFromMimeData(const QMimeData *source)
+ { insertFromMimeData(source); }
+};
+
+void tst_QTextEdit::pasteFromQt3RichText()
+{
+ QByteArray richtext("<!--StartFragment--><p> QTextEdit is an ");
+
+ QMimeData mimeData;
+ mimeData.setData("application/x-qrichtext", richtext);
+
+ static_cast<PublicTextEdit *>(ed)->publicInsertFromMimeData(&mimeData);
+
+ QCOMPARE(ed->toPlainText(), QString::fromLatin1(" QTextEdit is an "));
+ ed->clear();
+
+ richtext = "<!--StartFragment--> QTextEdit is an ";
+ mimeData.setData("application/x-qrichtext", richtext);
+
+ static_cast<PublicTextEdit *>(ed)->publicInsertFromMimeData(&mimeData);
+
+ QCOMPARE(ed->toPlainText(), QString::fromLatin1(" QTextEdit is an "));
+}
+
+void tst_QTextEdit::noWrapBackgrounds()
+{
+ QWidget topLevel;
+ QVBoxLayout *layout = new QVBoxLayout(&topLevel);
+
+ QTextEdit edit;
+ edit.setLineWrapMode(QTextEdit::NoWrap);
+
+ // hide the cursor in order to make the image comparison below reliable
+ edit.setCursorWidth(0);
+
+ QTextFrame *root = edit.document()->rootFrame();
+ QTextFrameFormat frameFormat = root->frameFormat();
+ frameFormat.setLeftMargin(2);
+ frameFormat.setRightMargin(2);
+ root->setFrameFormat(frameFormat);
+
+ QTextBlockFormat format;
+ format.setBackground(Qt::red);
+ edit.textCursor().setBlockFormat(format);
+ edit.insertPlainText(QLatin1String(" \n \n \n \n"));
+ edit.setFixedSize(100, 200);
+
+ layout->addWidget(&edit);
+ topLevel.show();
+
+ QImage img = QPixmap::grabWidget(edit.viewport()).toImage();
+ QCOMPARE(img, img.mirrored(true, false));
+}
+
+void tst_QTextEdit::preserveCharFormatAfterUnchangingSetPosition()
+{
+ QColor color(Qt::yellow);
+ QTextEdit edit;
+ edit.setTextColor(color);
+
+ QTextCursor c = edit.textCursor();
+ c.setPosition(c.position());
+ edit.setTextCursor(c);
+
+ QCOMPARE(edit.textColor(), color);
+}
+
+// Regression test for QTBUG-4696
+void tst_QTextEdit::twoSameInputMethodEvents()
+{
+ ed->setText("testLine");
+ ed->show();
+ QList<QInputMethodEvent::Attribute> attributes;
+ attributes.append(QInputMethodEvent::Attribute(QInputMethodEvent::Cursor,
+ ed->textCursor().position(),
+ 0,
+ QVariant()));
+
+ QInputMethodEvent event("PreEditText", attributes);
+ QApplication::sendEvent(ed, &event);
+ QCOMPARE(ed->document()->firstBlock().layout()->lineCount(), 1);
+ QApplication::sendEvent(ed, &event);
+ QCOMPARE(ed->document()->firstBlock().layout()->lineCount(), 1);
+}
+
+#ifndef QT_NO_CONTEXTMENU
+void tst_QTextEdit::taskQTBUG_7902_contextMenuCrash()
+{
+ QTextEdit *w = new QTextEdit;
+ w->show();
+ QTest::qWaitForWindowShown(w);
+
+ QTimer ti;
+ w->connect(&ti, SIGNAL(timeout()), w, SLOT(deleteLater()));
+ ti.start(200);
+
+ QContextMenuEvent *cme = new QContextMenuEvent(QContextMenuEvent::Mouse, w->rect().center());
+ qApp->postEvent(w->viewport(), cme);
+
+ QTest::qWait(300);
+ // No crash, it's allright.
+}
+#endif
+
+void tst_QTextEdit::bidiVisualMovement_data()
+{
+ QTest::addColumn<QString>("logical");
+ QTest::addColumn<int>("basicDir");
+ QTest::addColumn<QList<int> >("positionList");
+
+ QTest::newRow("Latin text")
+ << QString::fromUtf8("abc")
+ << (int) QChar::DirL
+ << (QList<int>() << 0 << 1 << 2 << 3);
+ QTest::newRow("Hebrew text, one item")
+ << QString::fromUtf8("\327\220\327\221\327\222")
+ << (int) QChar::DirR
+ << (QList<int>() << 0 << 1 << 2 << 3);
+ QTest::newRow("Hebrew text after Latin text")
+ << QString::fromUtf8("abc\327\220\327\221\327\222")
+ << (int) QChar::DirL
+ << (QList<int>() << 0 << 1 << 2 << 6 << 5 << 4 << 3);
+ QTest::newRow("Latin text after Hebrew text")
+ << QString::fromUtf8("\327\220\327\221\327\222abc")
+ << (int) QChar::DirR
+ << (QList<int>() << 0 << 1 << 2 << 6 << 5 << 4 << 3);
+ QTest::newRow("LTR, 3 items")
+ << QString::fromUtf8("abc\327\220\327\221\327\222abc")
+ << (int) QChar::DirL
+ << (QList<int>() << 0 << 1 << 2 << 5 << 4 << 3 << 6 << 7 << 8 << 9);
+ QTest::newRow("RTL, 3 items")
+ << QString::fromUtf8("\327\220\327\221\327\222abc\327\220\327\221\327\222")
+ << (int) QChar::DirR
+ << (QList<int>() << 0 << 1 << 2 << 5 << 4 << 3 << 6 << 7 << 8 << 9);
+ QTest::newRow("LTR, 4 items")
+ << QString::fromUtf8("abc\327\220\327\221\327\222abc\327\220\327\221\327\222")
+ << (int) QChar::DirL
+ << (QList<int>() << 0 << 1 << 2 << 5 << 4 << 3 << 6 << 7 << 8 << 12 << 11 << 10 << 9);
+ QTest::newRow("RTL, 4 items")
+ << QString::fromUtf8("\327\220\327\221\327\222abc\327\220\327\221\327\222abc")
+ << (int) QChar::DirR
+ << (QList<int>() << 0 << 1 << 2 << 5 << 4 << 3 << 6 << 7 << 8 << 12 << 11 << 10 << 9);
+}
+
+void tst_QTextEdit::bidiVisualMovement()
+{
+ QFETCH(QString, logical);
+ QFETCH(int, basicDir);
+ QFETCH(QList<int>, positionList);
+
+ ed->setText(logical);
+
+ QTextOption option = ed->document()->defaultTextOption();
+ option.setTextDirection(basicDir == QChar::DirL ? Qt::LeftToRight : Qt::RightToLeft);
+ ed->document()->setDefaultTextOption(option);
+
+ ed->document()->setDefaultCursorMoveStyle(Qt::VisualMoveStyle);
+ ed->moveCursor(QTextCursor::Start);
+ ed->show();
+
+ bool moved;
+ int i = 0, oldPos, newPos = 0;
+
+ do {
+ oldPos = newPos;
+ QVERIFY(oldPos == positionList[i]);
+ if (basicDir == QChar::DirL) {
+ ed->moveCursor(QTextCursor::Right);
+ } else
+ {
+ ed->moveCursor(QTextCursor::Left);
+ }
+ newPos = ed->textCursor().position();
+ moved = (oldPos != newPos);
+ i++;
+ } while (moved);
+
+ QVERIFY(i == positionList.size());
+
+ do {
+ i--;
+ oldPos = newPos;
+ QVERIFY(oldPos == positionList[i]);
+ if (basicDir == QChar::DirL) {
+ ed->moveCursor(QTextCursor::Left);
+ } else
+ {
+ ed->moveCursor(QTextCursor::Right);
+ }
+ newPos = ed->textCursor().position();
+ moved = (oldPos != newPos);
+ } while (moved && i >= 0);
+}
+
+void tst_QTextEdit::bidiLogicalMovement_data()
+{
+ bidiVisualMovement_data();
+}
+
+void tst_QTextEdit::bidiLogicalMovement()
+{
+ QFETCH(QString, logical);
+ QFETCH(int, basicDir);
+
+ ed->setText(logical);
+
+ QTextOption option = ed->document()->defaultTextOption();
+ option.setTextDirection(basicDir == QChar::DirL ? Qt::LeftToRight : Qt::RightToLeft);
+ ed->document()->setDefaultTextOption(option);
+
+ ed->document()->setDefaultCursorMoveStyle(Qt::LogicalMoveStyle);
+ ed->moveCursor(QTextCursor::Start);
+ ed->show();
+
+ bool moved;
+ int i = 0, oldPos, newPos = 0;
+
+ do {
+ oldPos = newPos;
+ QVERIFY(oldPos == i);
+ if (basicDir == QChar::DirL) {
+ ed->moveCursor(QTextCursor::Right);
+ } else
+ {
+ ed->moveCursor(QTextCursor::Left);
+ }
+ newPos = ed->textCursor().position();
+ moved = (oldPos != newPos);
+ i++;
+ } while (moved);
+
+ do {
+ i--;
+ oldPos = newPos;
+ QVERIFY(oldPos == i);
+ if (basicDir == QChar::DirL) {
+ ed->moveCursor(QTextCursor::Left);
+ } else
+ {
+ ed->moveCursor(QTextCursor::Right);
+ }
+ newPos = ed->textCursor().position();
+ moved = (oldPos != newPos);
+ } while (moved && i >= 0);
+}
+
+void tst_QTextEdit::inputMethodSelection()
+{
+ ed->setText("Lorem ipsum dolor sit amet, consectetur adipiscing elit.");
+
+ QSignalSpy selectionSpy(ed, SIGNAL(selectionChanged()));
+ QTextCursor cursor = ed->textCursor();
+ cursor.setPosition(0);
+ cursor.setPosition(5, QTextCursor::KeepAnchor);
+ ed->setTextCursor(cursor);
+
+ QCOMPARE(selectionSpy.count(), 1);
+ QCOMPARE(ed->textCursor().selectionStart(), 0);
+ QCOMPARE(ed->textCursor().selectionEnd(), 5);
+
+ QList<QInputMethodEvent::Attribute> attributes;
+ attributes << QInputMethodEvent::Attribute(QInputMethodEvent::Selection, 12, 5, QVariant());
+ QInputMethodEvent event("", attributes);
+ QApplication::sendEvent(ed, &event);
+
+ QCOMPARE(selectionSpy.count(), 2);
+ QCOMPARE(ed->textCursor().selectionStart(), 12);
+ QCOMPARE(ed->textCursor().selectionEnd(), 17);
+}
+
+
+QTEST_MAIN(tst_QTextEdit)
+#include "tst_qtextedit.moc"
diff --git a/tests/auto/widgets/widgets/qtoolbar/.gitignore b/tests/auto/widgets/widgets/qtoolbar/.gitignore
new file mode 100644
index 0000000000..971c9f9dfe
--- /dev/null
+++ b/tests/auto/widgets/widgets/qtoolbar/.gitignore
@@ -0,0 +1 @@
+tst_qtoolbar
diff --git a/tests/auto/widgets/widgets/qtoolbar/qtoolbar.pro b/tests/auto/widgets/widgets/qtoolbar/qtoolbar.pro
new file mode 100644
index 0000000000..b340097d81
--- /dev/null
+++ b/tests/auto/widgets/widgets/qtoolbar/qtoolbar.pro
@@ -0,0 +1,7 @@
+load(qttest_p4)
+QT += widgets widgets-private
+QT += gui-private
+SOURCES += tst_qtoolbar.cpp
+
+
+
diff --git a/tests/auto/widgets/widgets/qtoolbar/tst_qtoolbar.cpp b/tests/auto/widgets/widgets/qtoolbar/tst_qtoolbar.cpp
new file mode 100644
index 0000000000..eb043aced8
--- /dev/null
+++ b/tests/auto/widgets/widgets/qtoolbar/tst_qtoolbar.cpp
@@ -0,0 +1,1101 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#include <QtTest/QtTest>
+
+
+#include <qabstractbutton.h>
+#include <qaction.h>
+#include <qlayout.h>
+#include <qmainwindow.h>
+#include <qpixmap.h>
+#include <qstyle.h>
+#include <qtoolbar.h>
+#include <qwidgetaction.h>
+#include <qtoolbutton.h>
+#include <qlineedit.h>
+#include <qkeysequence.h>
+#include <qmenu.h>
+#include <private/qtoolbarextension_p.h>
+
+//TESTED_FILES=
+
+QT_FORWARD_DECLARE_CLASS(QAction)
+
+class tst_QToolBar : public QObject
+{
+ Q_OBJECT
+
+public:
+ tst_QToolBar();
+
+public slots:
+ void slot();
+ void slot(QAction *action);
+
+private slots:
+ void isMovable();
+ void allowedAreas();
+ void orientation();
+ void addAction();
+ void insertAction();
+ void addSeparator();
+ void insertSeparator();
+ void addWidget();
+ void insertWidget();
+ void actionGeometry();
+ void toggleViewAction();
+ void iconSize();
+ void toolButtonStyle();
+ void actionTriggered();
+ void visibilityChanged();
+ void actionOwnership();
+ void widgetAction();
+ void accel();
+
+ void task191727_layout();
+ void task197996_visibility();
+};
+
+
+QAction *triggered = 0;
+
+tst_QToolBar::tst_QToolBar()
+{
+ qRegisterMetaType<QSize>("QSize");
+ qRegisterMetaType<Qt::Orientation>("Qt::Orientation");
+ qRegisterMetaType<Qt::ToolBarAreas>("Qt::ToolBarAreas");
+ qRegisterMetaType<Qt::ToolButtonStyle>("Qt::ToolButtonStyle");
+}
+
+void tst_QToolBar::slot()
+{ }
+
+void tst_QToolBar::slot(QAction *action)
+{ ::triggered = action; }
+
+void tst_QToolBar::isMovable()
+{
+#define DO_TEST \
+ do { \
+ QVERIFY(tb.isMovable()); \
+ tb.setMovable(false); \
+ QVERIFY(!tb.isMovable()); \
+ QCOMPARE(spy.count(), 1); \
+ QCOMPARE(spy.at(0).value(0).toBool(), tb.isMovable()); \
+ spy.clear(); \
+ tb.setMovable(tb.isMovable()); \
+ QCOMPARE(spy.count(), 0); \
+ spy.clear(); \
+ tb.setMovable(true); \
+ QVERIFY(tb.isMovable()); \
+ QCOMPARE(spy.count(), 1); \
+ QCOMPARE(spy.at(0).value(0).toBool(), tb.isMovable()); \
+ spy.clear(); \
+ tb.setMovable(tb.isMovable()); \
+ QCOMPARE(spy.count(), 0); \
+ spy.clear(); \
+ } while (false)
+
+ QMainWindow mw;
+ QToolBar tb;
+
+ QCOMPARE(tb.isMovable(), (bool)qApp->style()->styleHint(QStyle::SH_ToolBar_Movable));
+ if (!tb.isMovable())
+ tb.setMovable(true);
+
+ QSignalSpy spy(&tb, SIGNAL(movableChanged(bool)));
+
+ DO_TEST;
+ mw.addToolBar(&tb);
+ DO_TEST;
+ mw.removeToolBar(&tb);
+ DO_TEST;
+}
+
+void tst_QToolBar::allowedAreas()
+{
+ QToolBar tb;
+
+ QSignalSpy spy(&tb, SIGNAL(allowedAreasChanged(Qt::ToolBarAreas)));
+
+ // default
+ QCOMPARE((int)tb.allowedAreas(), (int)Qt::AllToolBarAreas);
+ QVERIFY(tb.isAreaAllowed(Qt::LeftToolBarArea));
+ QVERIFY(tb.isAreaAllowed(Qt::RightToolBarArea));
+ QVERIFY(tb.isAreaAllowed(Qt::TopToolBarArea));
+ QVERIFY(tb.isAreaAllowed(Qt::BottomToolBarArea));
+
+ // a single dock window area
+ tb.setAllowedAreas(Qt::LeftToolBarArea);
+ QCOMPARE((int)tb.allowedAreas(), (int)Qt::LeftToolBarArea);
+ QVERIFY(tb.isAreaAllowed(Qt::LeftToolBarArea));
+ QVERIFY(!tb.isAreaAllowed(Qt::RightToolBarArea));
+ QVERIFY(!tb.isAreaAllowed(Qt::TopToolBarArea));
+ QVERIFY(!tb.isAreaAllowed(Qt::BottomToolBarArea));
+ QCOMPARE(spy.count(), 1);
+ QCOMPARE(*static_cast<const Qt::ToolBarAreas *>(spy.at(0).value(0).constData()),
+ tb.allowedAreas());
+ spy.clear();
+ tb.setAllowedAreas(tb.allowedAreas());
+ QCOMPARE(spy.count(), 0);
+
+ tb.setAllowedAreas(Qt::RightToolBarArea);
+ QCOMPARE((int)tb.allowedAreas(), (int)Qt::RightToolBarArea);
+ QVERIFY(!tb.isAreaAllowed(Qt::LeftToolBarArea));
+ QVERIFY(tb.isAreaAllowed(Qt::RightToolBarArea));
+ QVERIFY(!tb.isAreaAllowed(Qt::TopToolBarArea));
+ QVERIFY(!tb.isAreaAllowed(Qt::BottomToolBarArea));
+ QCOMPARE(spy.count(), 1);
+ QCOMPARE(*static_cast<const Qt::ToolBarAreas *>(spy.at(0).value(0).constData()),
+ tb.allowedAreas());
+ spy.clear();
+ tb.setAllowedAreas(tb.allowedAreas());
+ QCOMPARE(spy.count(), 0);
+
+ tb.setAllowedAreas(Qt::TopToolBarArea);
+ QCOMPARE((int)tb.allowedAreas(), (int)Qt::TopToolBarArea);
+ QVERIFY(!tb.isAreaAllowed(Qt::LeftToolBarArea));
+ QVERIFY(!tb.isAreaAllowed(Qt::RightToolBarArea));
+ QVERIFY(tb.isAreaAllowed(Qt::TopToolBarArea));
+ QVERIFY(!tb.isAreaAllowed(Qt::BottomToolBarArea));
+ QCOMPARE(spy.count(), 1);
+ QCOMPARE(*static_cast<const Qt::ToolBarAreas *>(spy.at(0).value(0).constData()),
+ tb.allowedAreas());
+ spy.clear();
+ tb.setAllowedAreas(tb.allowedAreas());
+ QCOMPARE(spy.count(), 0);
+
+ tb.setAllowedAreas(Qt::BottomToolBarArea);
+ QCOMPARE((int)tb.allowedAreas(), (int)Qt::BottomToolBarArea);
+ QVERIFY(!tb.isAreaAllowed(Qt::LeftToolBarArea));
+ QVERIFY(!tb.isAreaAllowed(Qt::RightToolBarArea));
+ QVERIFY(!tb.isAreaAllowed(Qt::TopToolBarArea));
+ QVERIFY(tb.isAreaAllowed(Qt::BottomToolBarArea));
+ QCOMPARE(spy.count(), 1);
+ QCOMPARE(*static_cast<const Qt::ToolBarAreas *>(spy.at(0).value(0).constData()),
+ tb.allowedAreas());
+ spy.clear();
+ tb.setAllowedAreas(tb.allowedAreas());
+ QCOMPARE(spy.count(), 0);
+
+ // multiple dock window areas
+ tb.setAllowedAreas(Qt::TopToolBarArea | Qt::BottomToolBarArea);
+ QCOMPARE(tb.allowedAreas(), Qt::TopToolBarArea | Qt::BottomToolBarArea);
+ QVERIFY(!tb.isAreaAllowed(Qt::LeftToolBarArea));
+ QVERIFY(!tb.isAreaAllowed(Qt::RightToolBarArea));
+ QVERIFY(tb.isAreaAllowed(Qt::TopToolBarArea));
+ QVERIFY(tb.isAreaAllowed(Qt::BottomToolBarArea));
+ QCOMPARE(spy.count(), 1);
+ QCOMPARE(*static_cast<const Qt::ToolBarAreas *>(spy.at(0).value(0).constData()),
+ tb.allowedAreas());
+ spy.clear();
+ tb.setAllowedAreas(tb.allowedAreas());
+ QCOMPARE(spy.count(), 0);
+
+ tb.setAllowedAreas(Qt::LeftToolBarArea | Qt::RightToolBarArea);
+ QCOMPARE(tb.allowedAreas(), Qt::LeftToolBarArea | Qt::RightToolBarArea);
+ QVERIFY(tb.isAreaAllowed(Qt::LeftToolBarArea));
+ QVERIFY(tb.isAreaAllowed(Qt::RightToolBarArea));
+ QVERIFY(!tb.isAreaAllowed(Qt::TopToolBarArea));
+ QVERIFY(!tb.isAreaAllowed(Qt::BottomToolBarArea));
+ QCOMPARE(spy.count(), 1);
+ QCOMPARE(*static_cast<const Qt::ToolBarAreas *>(spy.at(0).value(0).constData()),
+ tb.allowedAreas());
+ spy.clear();
+ tb.setAllowedAreas(tb.allowedAreas());
+ QCOMPARE(spy.count(), 0);
+
+ tb.setAllowedAreas(Qt::TopToolBarArea | Qt::LeftToolBarArea);
+ QCOMPARE(tb.allowedAreas(), Qt::TopToolBarArea | Qt::LeftToolBarArea);
+ QVERIFY(tb.isAreaAllowed(Qt::LeftToolBarArea));
+ QVERIFY(!tb.isAreaAllowed(Qt::RightToolBarArea));
+ QVERIFY(tb.isAreaAllowed(Qt::TopToolBarArea));
+ QVERIFY(!tb.isAreaAllowed(Qt::BottomToolBarArea));
+ QCOMPARE(spy.count(), 1);
+ QCOMPARE(*static_cast<const Qt::ToolBarAreas *>(spy.at(0).value(0).constData()),
+ tb.allowedAreas());
+ spy.clear();
+ tb.setAllowedAreas(tb.allowedAreas());
+ QCOMPARE(spy.count(), 0);
+
+ tb.setAllowedAreas(Qt::BottomToolBarArea | Qt::RightToolBarArea);
+ QCOMPARE(tb.allowedAreas(), Qt::BottomToolBarArea | Qt::RightToolBarArea);
+ QVERIFY(!tb.isAreaAllowed(Qt::LeftToolBarArea));
+ QVERIFY(tb.isAreaAllowed(Qt::RightToolBarArea));
+ QVERIFY(!tb.isAreaAllowed(Qt::TopToolBarArea));
+ QVERIFY(tb.isAreaAllowed(Qt::BottomToolBarArea));
+ QCOMPARE(spy.count(), 1);
+ QCOMPARE(*static_cast<const Qt::ToolBarAreas *>(spy.at(0).value(0).constData()),
+ tb.allowedAreas());
+ spy.clear();
+ tb.setAllowedAreas(tb.allowedAreas());
+ QCOMPARE(spy.count(), 0);
+}
+
+void tst_QToolBar::orientation()
+{
+ QToolBar tb;
+ QCOMPARE(tb.orientation(), Qt::Horizontal);
+
+ QSignalSpy spy(&tb, SIGNAL(orientationChanged(Qt::Orientation)));
+
+ tb.setOrientation(Qt::Vertical);
+ QCOMPARE(tb.orientation(), Qt::Vertical);
+ QCOMPARE(spy.count(), 1);
+ QCOMPARE(*static_cast<const Qt::Orientation *>(spy.at(0).value(0).constData()),
+ tb.orientation());
+ spy.clear();
+ tb.setOrientation(tb.orientation());
+ QCOMPARE(spy.count(), 0);
+
+ tb.setOrientation(Qt::Horizontal);
+ QCOMPARE(tb.orientation(), Qt::Horizontal);
+ QCOMPARE(spy.count(), 1);
+ QCOMPARE(*static_cast<const Qt::Orientation *>(spy.at(0).value(0).constData()),
+ tb.orientation());
+ spy.clear();
+ tb.setOrientation(tb.orientation());
+ QCOMPARE(spy.count(), 0);
+
+ tb.setOrientation(Qt::Vertical);
+ QCOMPARE(tb.orientation(), Qt::Vertical);
+ QCOMPARE(spy.count(), 1);
+ QCOMPARE(*static_cast<const Qt::Orientation *>(spy.at(0).value(0).constData()),
+ tb.orientation());
+ spy.clear();
+ tb.setOrientation(tb.orientation());
+ QCOMPARE(spy.count(), 0);
+
+ tb.setOrientation(Qt::Horizontal);
+ QCOMPARE(tb.orientation(), Qt::Horizontal);
+ QCOMPARE(spy.count(), 1);
+ QCOMPARE(*static_cast<const Qt::Orientation *>(spy.at(0).value(0).constData()),
+ tb.orientation());
+ spy.clear();
+ tb.setOrientation(tb.orientation());
+ QCOMPARE(spy.count(), 0);
+
+ tb.setOrientation(Qt::Vertical);
+ QCOMPARE(tb.orientation(), Qt::Vertical);
+ QCOMPARE(spy.count(), 1);
+ QCOMPARE(*static_cast<const Qt::Orientation *>(spy.at(0).value(0).constData()),
+ tb.orientation());
+ spy.clear();
+ tb.setOrientation(tb.orientation());
+ QCOMPARE(spy.count(), 0);
+}
+
+void tst_QToolBar::addAction()
+{
+ QToolBar tb;
+
+ {
+ QAction action(0);
+
+ QCOMPARE(tb.actions().count(), 0);
+ tb.addAction(&action);
+ QCOMPARE(tb.actions().count(), 1);
+ QCOMPARE(tb.actions()[0], &action);
+
+ tb.clear();
+ QCOMPARE(tb.actions().count(), 0);
+ }
+
+ {
+ QString text = "text";
+ QPixmap pm(32, 32);
+ pm.fill(Qt::blue);
+ QIcon icon = pm;
+
+ QAction *action1 = tb.addAction(text);
+ QCOMPARE(text, action1->text());
+
+ QAction *action2 = tb.addAction(icon, text);
+ QCOMPARE(icon, action2->icon());
+ QCOMPARE(text, action2->text());
+
+ QAction *action3 = tb.addAction(text, this, SLOT(slot()));
+ QCOMPARE(text, action3->text());
+
+ QAction *action4 = tb.addAction(icon, text, this, SLOT(slot()));
+ QCOMPARE(icon, action4->icon());
+ QCOMPARE(text, action4->text());
+
+ QCOMPARE(tb.actions().count(), 4);
+ QCOMPARE(tb.actions()[0], action1);
+ QCOMPARE(tb.actions()[1], action2);
+ QCOMPARE(tb.actions()[2], action3);
+ QCOMPARE(tb.actions()[3], action4);
+
+ tb.clear();
+ QCOMPARE(tb.actions().count(), 0);
+ }
+}
+
+void tst_QToolBar::insertAction()
+{
+ QToolBar tb;
+ QAction action1(0);
+ QAction action2(0);
+ QAction action3(0);
+ QAction action4(0);
+
+ QCOMPARE(tb.actions().count(), 0);
+ tb.insertAction(0, &action1);
+ tb.insertAction(&action1, &action2);
+ tb.insertAction(&action2, &action3);
+ tb.insertAction(&action3, &action4);
+ QCOMPARE(tb.actions().count(), 4);
+ QCOMPARE(tb.actions()[0], &action4);
+ QCOMPARE(tb.actions()[1], &action3);
+ QCOMPARE(tb.actions()[2], &action2);
+ QCOMPARE(tb.actions()[3], &action1);
+
+ tb.clear();
+ QCOMPARE(tb.actions().count(), 0);
+}
+
+void tst_QToolBar::addSeparator()
+{
+ QToolBar tb;
+
+ QAction action1(0);
+ QAction action2(0);
+
+ tb.addAction(&action1);
+ QAction *sep = tb.addSeparator();
+ tb.addAction(&action2);
+
+ QCOMPARE(tb.actions().count(), 3);
+ QCOMPARE(tb.actions()[0], &action1);
+ QCOMPARE(tb.actions()[1], sep);
+ QCOMPARE(tb.actions()[2], &action2);
+
+ tb.clear();
+ QCOMPARE(tb.actions().count(), 0);
+}
+
+void tst_QToolBar::insertSeparator()
+{
+ QToolBar tb;
+
+ QAction action1(0);
+ QAction action2(0);
+
+ tb.addAction(&action1);
+ tb.addAction(&action2);
+ QAction *sep = tb.insertSeparator(&action2);
+
+ QCOMPARE(tb.actions().count(), 3);
+ QCOMPARE(tb.actions()[0], &action1);
+ QCOMPARE(tb.actions()[1], sep);
+ QCOMPARE(tb.actions()[2], &action2);
+
+ tb.clear();
+ QCOMPARE(tb.actions().count(), 0);
+}
+
+void tst_QToolBar::addWidget()
+{
+ QToolBar tb;
+ QWidget w(&tb);
+
+ QAction action1(0);
+ QAction action2(0);
+
+ tb.addAction(&action1);
+ QAction *widget = tb.addWidget(&w);
+ tb.addAction(&action2);
+
+ QCOMPARE(tb.actions().count(), 3);
+ QCOMPARE(tb.actions()[0], &action1);
+ QCOMPARE(tb.actions()[1], widget);
+ QCOMPARE(tb.actions()[2], &action2);
+
+ // it should be possible to reuse the action returned by
+ // addWidget() to place the widget somewhere else in the toolbar
+ tb.removeAction(widget);
+ QCOMPARE(tb.actions().count(), 2);
+ QCOMPARE(tb.actions()[0], &action1);
+ QCOMPARE(tb.actions()[1], &action2);
+
+ tb.addAction(widget);
+ QCOMPARE(tb.actions().count(), 3);
+ QCOMPARE(tb.actions()[0], &action1);
+ QCOMPARE(tb.actions()[1], &action2);
+ QCOMPARE(tb.actions()[2], widget);
+
+ tb.clear();
+ QCOMPARE(tb.actions().count(), 0);
+}
+
+void tst_QToolBar::insertWidget()
+{
+ QToolBar tb;
+ QWidget w(&tb);
+
+ QAction action1(0);
+ QAction action2(0);
+
+ tb.addAction(&action1);
+ tb.addAction(&action2);
+ QAction *widget = tb.insertWidget(&action2, &w);
+
+ QCOMPARE(tb.actions().count(), 3);
+ QCOMPARE(tb.actions()[0], &action1);
+ QCOMPARE(tb.actions()[1], widget);
+ QCOMPARE(tb.actions()[2], &action2);
+
+ // it should be possible to reuse the action returned by
+ // addWidget() to place the widget somewhere else in the toolbar
+ tb.removeAction(widget);
+ QCOMPARE(tb.actions().count(), 2);
+ QCOMPARE(tb.actions()[0], &action1);
+ QCOMPARE(tb.actions()[1], &action2);
+
+ tb.insertAction(&action1, widget);
+ QCOMPARE(tb.actions().count(), 3);
+ QCOMPARE(tb.actions()[0], widget);
+ QCOMPARE(tb.actions()[1], &action1);
+ QCOMPARE(tb.actions()[2], &action2);
+
+ tb.clear();
+ QCOMPARE(tb.actions().count(), 0);
+
+ {
+ QToolBar tb;
+ QPointer<QWidget> widget = new QWidget;
+ QAction *action = tb.addWidget(widget);
+ QVERIFY(action->parent() == &tb);
+
+ QToolBar tb2;
+ tb.removeAction(action);
+ tb2.addAction(action);
+ QVERIFY(widget && widget->parent() == &tb2);
+ QVERIFY(action->parent() == &tb2);
+ }
+}
+
+void tst_QToolBar::actionGeometry()
+{
+ QToolBar tb;
+
+ QAction action1(0);
+ QAction action2(0);
+ QAction action3(0);
+ QAction action4(0);
+
+ tb.addAction(&action1);
+ tb.addAction(&action2);
+ tb.addAction(&action3);
+ tb.addAction(&action4);
+
+ tb.show();
+#ifdef Q_WS_X11
+ qt_x11_wait_for_window_manager(&tb);
+#endif
+
+ QList<QToolBarExtension *> extensions = tb.findChildren<QToolBarExtension *>();
+
+ QRect rect01;
+ QRect rect02;
+ QRect rect03;
+ QRect rect04;
+ QMenu *popupMenu;
+
+ if (extensions.size() != 0)
+ {
+ QToolBarExtension *extension = extensions.at(0);
+ if (extension->isVisible()) {
+ QRect rect0 = extension->geometry();
+ QTest::mouseClick( extension, Qt::LeftButton, 0, rect0.center(), -1 );
+ QApplication::processEvents();
+ popupMenu = qobject_cast<QMenu *>(extension->menu());
+ rect01 = popupMenu->actionGeometry(&action1);
+ rect02 = popupMenu->actionGeometry(&action2);
+ rect03 = popupMenu->actionGeometry(&action3);
+ rect04 = popupMenu->actionGeometry(&action4);
+ }
+ }
+
+ QRect rect1 = tb.actionGeometry(&action1);
+ QRect rect2 = tb.actionGeometry(&action2);
+ QRect rect3 = tb.actionGeometry(&action3);
+ QRect rect4 = tb.actionGeometry(&action4);
+
+ QVERIFY(rect1.isValid());
+ QVERIFY(!rect1.isNull());
+ QVERIFY(!rect1.isEmpty());
+
+ QVERIFY(rect2.isValid());
+ QVERIFY(!rect2.isNull());
+ QVERIFY(!rect2.isEmpty());
+
+ QVERIFY(rect3.isValid());
+ QVERIFY(!rect3.isNull());
+ QVERIFY(!rect3.isEmpty());
+
+ QVERIFY(rect4.isValid());
+ QVERIFY(!rect4.isNull());
+ QVERIFY(!rect4.isEmpty());
+
+ if (rect01.isValid())
+ QCOMPARE(popupMenu->actionAt(rect01.center()), &action1);
+ else
+ QCOMPARE(tb.actionAt(rect1.center()), &action1);
+
+ if (rect02.isValid())
+ QCOMPARE(popupMenu->actionAt(rect02.center()), &action2);
+ else
+ QCOMPARE(tb.actionAt(rect2.center()), &action2);
+
+ if (rect03.isValid())
+ QCOMPARE(popupMenu->actionAt(rect03.center()), &action3);
+ else
+ QCOMPARE(tb.actionAt(rect3.center()), &action3);
+
+ if (rect04.isValid())
+ QCOMPARE(popupMenu->actionAt(rect04.center()), &action4);
+ else
+ QCOMPARE(tb.actionAt(rect4.center()), &action4);
+}
+
+void tst_QToolBar::toggleViewAction()
+{
+ {
+ QToolBar tb;
+ QAction *toggleViewAction = tb.toggleViewAction();
+ QVERIFY(tb.isHidden());
+ toggleViewAction->trigger();
+ QVERIFY(!tb.isHidden());
+ toggleViewAction->trigger();
+ QVERIFY(tb.isHidden());
+ }
+
+ {
+ QMainWindow mw;
+ QToolBar tb(&mw);
+ mw.addToolBar(&tb);
+ mw.show();
+ QAction *toggleViewAction = tb.toggleViewAction();
+ QVERIFY(!tb.isHidden());
+ toggleViewAction->trigger();
+ QVERIFY(tb.isHidden());
+ toggleViewAction->trigger();
+ QVERIFY(!tb.isHidden());
+ toggleViewAction->trigger();
+ QVERIFY(tb.isHidden());
+ }
+}
+
+void tst_QToolBar::iconSize()
+{
+ {
+ QToolBar tb;
+
+ QSignalSpy spy(&tb, SIGNAL(iconSizeChanged(QSize)));
+
+ // the default is determined by the style
+ const int metric = tb.style()->pixelMetric(QStyle::PM_ToolBarIconSize);
+ const QSize defaultIconSize = QSize(metric, metric);
+ const QSize smallIconSize = QSize(metric / 2, metric / 2);
+ const QSize largeIconSize = QSize(metric * 2, metric * 2);
+
+ QCOMPARE(tb.iconSize(), defaultIconSize);
+ tb.setIconSize(defaultIconSize);
+ QCOMPARE(tb.iconSize(), defaultIconSize);
+ QCOMPARE(spy.count(), 0);
+
+ spy.clear();
+ tb.setIconSize(largeIconSize);
+ QCOMPARE(tb.iconSize(), largeIconSize);
+ QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.first().first().toSize(), largeIconSize);
+
+ // no-op
+ spy.clear();
+ tb.setIconSize(largeIconSize);
+ QCOMPARE(tb.iconSize(), largeIconSize);
+ QCOMPARE(spy.count(), 0);
+
+ spy.clear();
+ tb.setIconSize(defaultIconSize);
+ QCOMPARE(tb.iconSize(), defaultIconSize);
+ QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.first().first().toSize(), defaultIconSize);
+
+ // no-op
+ spy.clear();
+ tb.setIconSize(defaultIconSize);
+ QCOMPARE(tb.iconSize(), defaultIconSize);
+ QCOMPARE(spy.count(), 0);
+
+ spy.clear();
+ tb.setIconSize(smallIconSize);
+ QCOMPARE(tb.iconSize(), smallIconSize);
+ QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.first().first().toSize(), smallIconSize);
+
+ // no-op
+ spy.clear();
+ tb.setIconSize(smallIconSize);
+ QCOMPARE(tb.iconSize(), smallIconSize);
+ QCOMPARE(spy.count(), 0);
+
+ // setting the icon size to an invalid QSize will reset the
+ // iconSize property to the default
+ tb.setIconSize(QSize());
+ QCOMPARE(tb.iconSize(), defaultIconSize);
+ QCOMPARE(spy.size(), 1);
+ QCOMPARE(spy.first().first().toSize(), defaultIconSize);
+ spy.clear();
+ }
+
+ {
+ QMainWindow mw;
+ QToolBar tb;
+ QSignalSpy mwSpy(&mw, SIGNAL(iconSizeChanged(QSize)));
+ QSignalSpy tbSpy(&tb, SIGNAL(iconSizeChanged(QSize)));
+
+ // the default is determined by the style
+ const int metric = tb.style()->pixelMetric(QStyle::PM_ToolBarIconSize);
+ const QSize defaultIconSize = QSize(metric, metric);
+ const QSize smallIconSize = QSize(metric / 2, metric / 2);
+ const QSize largeIconSize = QSize(metric * 2, metric * 2);
+
+ mw.setIconSize(smallIconSize);
+
+ // explicitly set it to the default
+ tb.setIconSize(defaultIconSize);
+ QCOMPARE(tb.iconSize(), defaultIconSize);
+ QCOMPARE(tbSpy.count(), 0);
+
+ mw.addToolBar(&tb);
+
+ // tb icon size should not change since it has been explicitly set
+ QCOMPARE(tb.iconSize(), defaultIconSize);
+ QCOMPARE(tbSpy.count(), 0);
+
+ mw.setIconSize(largeIconSize);
+
+ QCOMPARE(tb.iconSize(), defaultIconSize);
+ QCOMPARE(tbSpy.count(), 0);
+
+ mw.setIconSize(defaultIconSize);
+
+ QCOMPARE(tb.iconSize(), defaultIconSize);
+ QCOMPARE(tbSpy.count(), 0);
+
+ mw.setIconSize(smallIconSize);
+
+ QCOMPARE(tb.iconSize(), defaultIconSize);
+ QCOMPARE(tbSpy.count(), 0);
+
+ // resetting to the default should cause the toolbar to take
+ // on the mainwindow's icon size
+ tb.setIconSize(QSize());
+ QCOMPARE(tb.iconSize(), smallIconSize);
+ QCOMPARE(tbSpy.size(), 1);
+ QCOMPARE(tbSpy.first().first().toSize(), smallIconSize);
+ tbSpy.clear();
+ }
+}
+
+void tst_QToolBar::toolButtonStyle()
+{
+ {
+ QToolBar tb;
+
+ QSignalSpy spy(&tb, SIGNAL(toolButtonStyleChanged(Qt::ToolButtonStyle)));
+
+ // no-op
+ QCOMPARE(tb.toolButtonStyle(), Qt::ToolButtonIconOnly);
+ tb.setToolButtonStyle(Qt::ToolButtonIconOnly);
+ QCOMPARE(tb.toolButtonStyle(), Qt::ToolButtonIconOnly);
+ QCOMPARE(spy.count(), 0);
+
+ tb.setToolButtonStyle(Qt::ToolButtonTextOnly);
+ QCOMPARE(tb.toolButtonStyle(), Qt::ToolButtonTextOnly);
+ QCOMPARE(spy.count(), 1);
+ spy.clear();
+
+ // no-op
+ tb.setToolButtonStyle(Qt::ToolButtonTextOnly);
+ QCOMPARE(tb.toolButtonStyle(), Qt::ToolButtonTextOnly);
+ QCOMPARE(spy.count(), 0);
+
+ tb.setToolButtonStyle(Qt::ToolButtonIconOnly);
+ QCOMPARE(tb.toolButtonStyle(), Qt::ToolButtonIconOnly);
+ QCOMPARE(spy.count(), 1);
+ spy.clear();
+
+ // no-op
+ tb.setToolButtonStyle(Qt::ToolButtonIconOnly);
+ QCOMPARE(tb.toolButtonStyle(), Qt::ToolButtonIconOnly);
+ QCOMPARE(spy.count(), 0);
+
+ tb.setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
+ QCOMPARE(tb.toolButtonStyle(), Qt::ToolButtonTextBesideIcon);
+ QCOMPARE(spy.count(), 1);
+ spy.clear();
+
+ // no-op
+ tb.setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
+ QCOMPARE(tb.toolButtonStyle(), Qt::ToolButtonTextBesideIcon);
+ QCOMPARE(spy.count(), 0);
+
+ tb.setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
+ QCOMPARE(tb.toolButtonStyle(), Qt::ToolButtonTextUnderIcon);
+ QCOMPARE(spy.count(), 1);
+ spy.clear();
+
+ // no-op
+ tb.setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
+ QCOMPARE(tb.toolButtonStyle(), Qt::ToolButtonTextUnderIcon);
+ QCOMPARE(spy.count(), 0);
+
+ tb.setToolButtonStyle(Qt::ToolButtonFollowStyle);
+ QCOMPARE(tb.toolButtonStyle(), Qt::ToolButtonFollowStyle);
+ QCOMPARE(spy.count(), 1);
+ }
+
+ {
+ QMainWindow mw;
+ QToolBar tb;
+ QSignalSpy mwSpy(&mw, SIGNAL(toolButtonStyleChanged(Qt::ToolButtonStyle)));
+ QSignalSpy tbSpy(&tb, SIGNAL(toolButtonStyleChanged(Qt::ToolButtonStyle)));
+
+ mw.setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
+
+ // explicitly set the tb to the default
+ tb.setToolButtonStyle(Qt::ToolButtonIconOnly);
+ QCOMPARE(tb.toolButtonStyle(), Qt::ToolButtonIconOnly);
+ QCOMPARE(tbSpy.count(), 0);
+
+ mw.addToolBar(&tb);
+
+ // tb icon size should not change since it has been explicitly set
+ QCOMPARE(tb.toolButtonStyle(), Qt::ToolButtonIconOnly);
+ QCOMPARE(tbSpy.count(), 0);
+
+ mw.setToolButtonStyle(Qt::ToolButtonIconOnly);
+
+ QCOMPARE(tb.toolButtonStyle(), Qt::ToolButtonIconOnly);
+ QCOMPARE(tbSpy.count(), 0);
+
+ mw.setToolButtonStyle(Qt::ToolButtonTextOnly);
+
+ QCOMPARE(tb.toolButtonStyle(), Qt::ToolButtonIconOnly);
+ QCOMPARE(tbSpy.count(), 0);
+
+ mw.setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
+
+ QCOMPARE(tb.toolButtonStyle(), Qt::ToolButtonIconOnly);
+ QCOMPARE(tbSpy.count(), 0);
+
+ // note: there is no way to clear the explicitly set tool
+ // button style... once you explicitly set it, the toolbar
+ // will never follow the mainwindow again
+ }
+}
+
+void tst_QToolBar::actionTriggered()
+{
+ QToolBar tb;
+ connect(&tb, SIGNAL(actionTriggered(QAction *)), SLOT(slot(QAction *)));
+
+ QAction action1(0);
+ QAction action2(0);
+ QAction action3(0);
+ QAction action4(0);
+
+ tb.addAction(&action1);
+ tb.addAction(&action2);
+ tb.addAction(&action3);
+ tb.addAction(&action4);
+
+ tb.show();
+#ifdef Q_WS_X11
+ qt_x11_wait_for_window_manager(&tb);
+#endif
+
+ QList<QToolBarExtension *> extensions = tb.findChildren<QToolBarExtension *>();
+
+ QRect rect01;
+ QRect rect02;
+ QRect rect03;
+ QRect rect04;
+ QMenu *popupMenu;
+
+ if (extensions.size() != 0)
+ {
+ QToolBarExtension *extension = extensions.at(0);
+ if (extension->isVisible()) {
+ QRect rect0 = extension->geometry();
+ QTest::mouseClick( extension, Qt::LeftButton, 0, rect0.center(), -1 );
+ QApplication::processEvents();
+ popupMenu = qobject_cast<QMenu *>(extension->menu());
+ rect01 = popupMenu->actionGeometry(&action1);
+ rect02 = popupMenu->actionGeometry(&action2);
+ rect03 = popupMenu->actionGeometry(&action3);
+ rect04 = popupMenu->actionGeometry(&action4);
+ }
+ }
+
+ QRect rect1 = tb.actionGeometry(&action1);
+ QRect rect2 = tb.actionGeometry(&action2);
+ QRect rect3 = tb.actionGeometry(&action3);
+ QRect rect4 = tb.actionGeometry(&action4);
+
+ QAbstractButton *button1;
+ QAbstractButton *button2;
+ QAbstractButton *button3;
+ QAbstractButton *button4;
+
+ if (!rect01.isValid()) {
+ button1 = qobject_cast<QAbstractButton *>(tb.childAt(rect1.center()));
+ QVERIFY(button1 != 0);
+ }
+ if (!rect02.isValid()) {
+ button2 = qobject_cast<QAbstractButton *>(tb.childAt(rect2.center()));
+ QVERIFY(button2 != 0);
+ }
+ if (!rect03.isValid()) {
+ button3 = qobject_cast<QAbstractButton *>(tb.childAt(rect3.center()));
+ QVERIFY(button3 != 0);
+ }
+ if (!rect04.isValid()) {
+ button4 = qobject_cast<QAbstractButton *>(tb.childAt(rect4.center()));
+ QVERIFY(button4 != 0);
+ }
+
+ ::triggered = 0;
+ if (!rect01.isValid())
+ QTest::mouseClick(button1, Qt::LeftButton);
+ else
+ QTest::mouseClick(popupMenu, Qt::LeftButton, 0, rect01.center(), -1 );
+ QCOMPARE(::triggered, &action1);
+
+ ::triggered = 0;
+ if (!rect02.isValid())
+ QTest::mouseClick(button2, Qt::LeftButton);
+ else
+ QTest::mouseClick(popupMenu, Qt::LeftButton, 0, rect02.center(), -1 );
+ QCOMPARE(::triggered, &action2);
+
+ ::triggered = 0;
+ if (!rect03.isValid())
+ QTest::mouseClick(button3, Qt::LeftButton);
+ else
+ QTest::mouseClick(popupMenu, Qt::LeftButton, 0, rect03.center(), -1 );
+ QCOMPARE(::triggered, &action3);
+
+ ::triggered = 0;
+ if (!rect04.isValid())
+ QTest::mouseClick(button4, Qt::LeftButton);
+ else
+ QTest::mouseClick(popupMenu, Qt::LeftButton, 0, rect04.center(), -1 );
+ QCOMPARE(::triggered, &action4);
+}
+
+void tst_QToolBar::visibilityChanged()
+{
+ QMainWindow mw;
+ QToolBar tb;
+ QSignalSpy spy(&tb, SIGNAL(visibilityChanged(bool)));
+
+ mw.addToolBar(&tb);
+ mw.show();
+
+ QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.at(0).at(0).toBool(), true);
+ spy.clear();
+
+ tb.hide();
+ QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.at(0).at(0).toBool(), false);
+ spy.clear();
+
+ tb.hide();
+ QCOMPARE(spy.count(), 0);
+
+ tb.show();
+ QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.at(0).at(0).toBool(), true);
+ spy.clear();
+
+ tb.show();
+ QCOMPARE(spy.count(), 0);
+}
+
+void tst_QToolBar::actionOwnership()
+{
+ {
+ QToolBar *tb1 = new QToolBar;
+ QToolBar *tb2 = new QToolBar;
+
+ QPointer<QAction> action = tb1->addAction("test");
+ QVERIFY(action->parent() == tb1);
+
+ tb2->addAction(action);
+ QVERIFY(action->parent() == tb1);
+
+ delete tb1;
+ QVERIFY(!action);
+ delete tb2;
+ }
+ {
+ QToolBar *tb1 = new QToolBar;
+ QToolBar *tb2 = new QToolBar;
+
+ QPointer<QAction> action = tb1->addAction("test");
+ QVERIFY(action->parent() == tb1);
+
+ tb1->removeAction(action);
+ QVERIFY(action->parent() == tb1);
+
+ tb2->addAction(action);
+ QVERIFY(action->parent() == tb1);
+
+ delete tb1;
+ QVERIFY(!action);
+ delete tb2;
+ }
+}
+
+void tst_QToolBar::widgetAction()
+{
+ // ensure that a QWidgetAction without widget behaves like a normal action
+ QToolBar tb;
+ QWidgetAction *a = new QWidgetAction(0);
+ a->setIconText("Blah");
+
+ tb.addAction(a);
+ QWidget *w = tb.widgetForAction(a);
+ QVERIFY(w);
+ QToolButton *button = qobject_cast<QToolButton *>(w);
+ QVERIFY(button);
+ QCOMPARE(a->iconText(), button->text());
+
+ delete a;
+}
+
+void tst_QToolBar::accel()
+{
+#ifdef Q_WS_MAC
+ extern void qt_set_sequence_auto_mnemonic(bool b);
+ qt_set_sequence_auto_mnemonic(true);
+#endif
+ QMainWindow mw;
+ QToolBar *toolBar = mw.addToolBar("test");
+ QAction *action = toolBar->addAction("&test");
+ action->setIconText(action->text()); // we really want that mnemonic in the button!
+
+ QSignalSpy spy(action, SIGNAL(triggered(bool)));
+
+ mw.show();
+ QApplication::setActiveWindow(&mw);
+ QTest::qWait(100);
+ QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget *>(&mw));
+
+ QTest::keyClick(&mw, Qt::Key_T, Qt::AltModifier);
+ QTest::qWait(300);
+
+ QTRY_COMPARE(spy.count(), 1);
+#ifdef Q_WS_MAC
+ qt_set_sequence_auto_mnemonic(false);
+#endif
+}
+
+void tst_QToolBar::task191727_layout()
+{
+ QMainWindow mw;
+ QToolBar *toolBar = mw.addToolBar("test");
+ toolBar->addAction("one");
+ QAction *action = toolBar->addAction("two");
+
+ QLineEdit *lineedit = new QLineEdit;
+ lineedit->setMaximumWidth(50);
+ toolBar->addWidget(lineedit);
+
+ mw.resize(400, 400);
+ mw.show();
+
+ QWidget *actionwidget = toolBar->widgetForAction(action);
+ QVERIFY(qAbs(lineedit->pos().x() - (actionwidget->geometry().right() + 1 + toolBar->layout()->spacing())) < 2);
+}
+
+void tst_QToolBar::task197996_visibility()
+{
+ QMainWindow mw;
+ QToolBar *toolBar = new QToolBar(&mw);
+
+ mw.addToolBar(toolBar);
+ toolBar->addAction(new QAction("Foo", &mw));
+ QAction *pAction = new QAction("Test", &mw);
+ toolBar->addAction(pAction);
+
+ pAction->setVisible(false);
+ toolBar->setVisible(false);
+
+ toolBar->setVisible(true);
+ pAction->setVisible(true);
+
+ mw.show();
+
+ QVERIFY(toolBar->widgetForAction(pAction)->isVisible());
+
+ toolBar->setVisible(false);
+ pAction->setVisible(false);
+
+ toolBar->setVisible(true);
+ pAction->setVisible(true);
+
+ QTest::qWait(100);
+
+ QVERIFY(toolBar->widgetForAction(pAction)->isVisible());
+
+}
+
+QTEST_MAIN(tst_QToolBar)
+#include "tst_qtoolbar.moc"
diff --git a/tests/auto/widgets/widgets/qtoolbox/.gitignore b/tests/auto/widgets/widgets/qtoolbox/.gitignore
new file mode 100644
index 0000000000..f586175dcb
--- /dev/null
+++ b/tests/auto/widgets/widgets/qtoolbox/.gitignore
@@ -0,0 +1 @@
+tst_qtoolbox
diff --git a/tests/auto/widgets/widgets/qtoolbox/qtoolbox.pro b/tests/auto/widgets/widgets/qtoolbox/qtoolbox.pro
new file mode 100644
index 0000000000..24f3ea6cb9
--- /dev/null
+++ b/tests/auto/widgets/widgets/qtoolbox/qtoolbox.pro
@@ -0,0 +1,6 @@
+load(qttest_p4)
+QT += widgets
+SOURCES += tst_qtoolbox.cpp
+
+
+
diff --git a/tests/auto/widgets/widgets/qtoolbox/tst_qtoolbox.cpp b/tests/auto/widgets/widgets/qtoolbox/tst_qtoolbox.cpp
new file mode 100644
index 0000000000..2288eee5f4
--- /dev/null
+++ b/tests/auto/widgets/widgets/qtoolbox/tst_qtoolbox.cpp
@@ -0,0 +1,338 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#include <QtTest/QtTest>
+
+#include <qtoolbox.h>
+
+
+//TESTED_CLASS=
+//TESTED_FILES=
+
+QT_FORWARD_DECLARE_CLASS(QToolBox)
+
+class tst_QToolBoxPrivate;
+
+class tst_QToolBox : public QObject
+{
+ Q_OBJECT
+
+public:
+ tst_QToolBox();
+ virtual ~tst_QToolBox();
+
+protected slots:
+ void currentChanged(int);
+
+public slots:
+ void initTestCase();
+ void cleanupTestCase();
+ void init();
+ void cleanup();
+private slots:
+ void getSetCheck();
+ void populate();
+ void change();
+ void clear();
+
+private:
+ QToolBox *testWidget;
+ int currentIndex;
+
+ tst_QToolBoxPrivate *d;
+};
+
+// Testing get/set functions
+void tst_QToolBox::getSetCheck()
+{
+ QToolBox obj1;
+ QWidget *w1 = new QWidget;
+ QWidget *w2 = new QWidget;
+ QWidget *w3 = new QWidget;
+ QWidget *w4 = new QWidget;
+ QWidget *w5 = new QWidget;
+ obj1.addItem(w1, "Page1");
+ obj1.addItem(w2, "Page2");
+ obj1.addItem(w3, "Page3");
+ obj1.addItem(w4, "Page4");
+ obj1.addItem(w5, "Page5");
+
+ // int QToolBox::currentIndex()
+ // void QToolBox::setCurrentIndex(int)
+ obj1.setCurrentIndex(3);
+ QCOMPARE(3, obj1.currentIndex());
+ obj1.setCurrentIndex(INT_MIN);
+ QCOMPARE(3, obj1.currentIndex());
+ obj1.setCurrentIndex(INT_MAX);
+ QCOMPARE(3, obj1.currentIndex());
+ obj1.setCurrentIndex(4);
+ QCOMPARE(4, obj1.currentIndex());
+
+ // QWidget * QToolBox::currentWidget()
+ // void QToolBox::setCurrentWidget(QWidget *)
+ obj1.setCurrentWidget(w1);
+ QCOMPARE(w1, obj1.currentWidget());
+ obj1.setCurrentWidget(w3);
+ QCOMPARE(w3, obj1.currentWidget());
+
+ obj1.setCurrentWidget((QWidget *)0);
+ QCOMPARE(w3, obj1.currentWidget());
+}
+
+tst_QToolBox::tst_QToolBox()
+{
+}
+
+tst_QToolBox::~tst_QToolBox()
+{
+}
+
+class tst_QToolBoxPrivate
+{
+public:
+ int count0, count1, count2, count3, count4;
+ int idx1, idx2, idx3, idx32;
+ int i0, i1, i2, i3, i4;
+ int ci0, ci1, ci2, ci3, ci4;
+ bool ci_correct;
+
+ int manual_count;
+};
+
+void tst_QToolBox::init()
+{
+ currentIndex = -1;
+ testWidget = new QToolBox;
+ connect(testWidget, SIGNAL(currentChanged(int)), this, SLOT(currentChanged(int)));
+
+ d = new tst_QToolBoxPrivate;
+
+
+ d->count0 = testWidget->count();
+ d->ci0 = currentIndex;
+
+ QWidget *item1 = new QWidget( testWidget );
+ testWidget->addItem( item1, "Item1" );
+
+ d->count1 = testWidget->count();
+ d->idx1 = testWidget->indexOf(item1);
+ d->ci1 = currentIndex;
+ d->ci_correct = testWidget->widget(testWidget->currentIndex()) == item1;
+
+ currentIndex = -1; // reset to make sure signal doesn't fire
+
+ QWidget *item3 = new QWidget( testWidget );
+ testWidget->addItem( item3, "Item3" );
+
+ d->count2 = testWidget->count();
+ d->idx3 = testWidget->indexOf(item3);
+ d->ci2 = currentIndex;
+
+
+ QWidget *item2 = new QWidget( testWidget );
+ testWidget->insertItem( 1, item2, "Item2");
+
+ d->count3 = testWidget->count();
+ d->idx2 = testWidget->indexOf(item2);
+ d->idx32 = testWidget->indexOf(item3);
+ d->ci3 = currentIndex;
+
+ QWidget *item0 = new QWidget( testWidget );
+ testWidget->insertItem( 0, item0, "Item0");
+
+ d->count4 = testWidget->count();
+ d->i0 = testWidget->indexOf(item0);
+ d->i1 = testWidget->indexOf(item1);
+ d->i2 = testWidget->indexOf(item2);
+ d->i3 = testWidget->indexOf(item3);
+ d->ci4 = currentIndex;
+
+ d->manual_count = 4;
+}
+
+void tst_QToolBox::cleanup()
+{
+ delete testWidget;
+ delete d;
+}
+
+void tst_QToolBox::initTestCase()
+{
+}
+
+void tst_QToolBox::cleanupTestCase()
+{
+}
+
+void tst_QToolBox::currentChanged(int index)
+{
+ currentIndex = index;
+}
+
+void tst_QToolBox::populate()
+{
+ // verify preconditions
+ QCOMPARE( d->count0, 0 );
+ QCOMPARE( d->ci0, -1 );
+ QVERIFY( d->ci_correct );
+
+ QCOMPARE( d->count1, 1 );
+ QCOMPARE( d->idx1, 0 );
+ QCOMPARE( d->ci1, 0 );
+
+ QCOMPARE( d->count2, 2 );
+ QCOMPARE( d->idx3, 1 );
+ QCOMPARE( d->ci2, -1 );
+
+ QCOMPARE( d->count3, 3 );
+ QCOMPARE( d->idx2, 1 );
+ QCOMPARE( d->idx32, 2 );
+ QCOMPARE( d->ci3, -1 );
+
+
+ QCOMPARE( d->count4, 4 );
+ QCOMPARE( d->i0, 0 );
+ QCOMPARE( d->i1, 1 );
+ QCOMPARE( d->i2, 2 );
+ QCOMPARE( d->i3, 3 );
+ QCOMPARE( d->ci4, 1 );
+
+ QCOMPARE (testWidget->count(), d->manual_count);
+ int oldcount = testWidget->count();
+
+ QWidget *item = new QWidget( testWidget );
+ testWidget->addItem( item, "Item");
+ d->manual_count++;
+
+ QCOMPARE( testWidget->count(), oldcount+1 );
+ QCOMPARE( testWidget->indexOf(item), oldcount );
+ QCOMPARE( testWidget->widget(oldcount), item );
+}
+
+void tst_QToolBox::change()
+{
+ QWidget *lastItem = testWidget->widget(testWidget->count());
+ QVERIFY( !lastItem );
+ lastItem = testWidget->widget(testWidget->count() - 1);
+ QVERIFY( lastItem );
+
+ for ( int c = 0; c < testWidget->count(); ++c ) {
+ QString label = "Item " + QString::number(c);
+ testWidget->setItemText(c, label);
+ QCOMPARE( testWidget->itemText(c), label );
+ }
+
+ testWidget->setCurrentIndex( 0 );
+ QCOMPARE( currentIndex, 0 );
+
+ currentIndex = -1; // reset to make sure signal doesn't fire
+ testWidget->setCurrentIndex( 0 );
+ QCOMPARE( currentIndex, -1 );
+ QCOMPARE( testWidget->currentIndex(), 0 );
+
+ testWidget->setCurrentIndex( testWidget->count() );
+ QCOMPARE( currentIndex, -1 );
+ QCOMPARE( testWidget->currentIndex(), 0 );
+
+ testWidget->setCurrentIndex( 1 );
+ QCOMPARE( currentIndex, 1 );
+ QCOMPARE( testWidget->currentIndex(), 1 );
+
+ testWidget->setItemEnabled( testWidget->currentIndex(), FALSE );
+ QCOMPARE( currentIndex, 2 );
+ QCOMPARE( testWidget->currentIndex(), 2 );
+
+ currentIndex = -1;
+ testWidget->setItemEnabled( testWidget->indexOf(lastItem), FALSE );
+ QCOMPARE( currentIndex, -1 );
+ QCOMPARE( testWidget->currentIndex(), 2 );
+
+ testWidget->setItemEnabled( testWidget->currentIndex(), FALSE );
+ QCOMPARE( currentIndex, 0 );
+
+ currentIndex = -1;
+ testWidget->setItemEnabled( testWidget->currentIndex(), FALSE );
+ QCOMPARE( currentIndex, -1 );
+
+ testWidget->setItemEnabled( 1, TRUE );
+}
+
+void tst_QToolBox::clear()
+{
+ // precondition: only item(1) is enabled
+ QCOMPARE( testWidget->count(), 4 );
+ testWidget->setCurrentIndex(0);
+ currentIndex = -1;
+
+ // delete current item(0)
+ QPointer<QWidget> item = testWidget->widget(testWidget->currentIndex());
+ testWidget->removeItem(testWidget->indexOf(item));
+ QVERIFY(item);
+ QCOMPARE( testWidget->count(), 3 );
+ QCOMPARE( testWidget->indexOf(item), -1 );
+ QCOMPARE( testWidget->currentIndex(), 0 );
+ QCOMPARE(currentIndex, 0 );
+
+ currentIndex = -1;
+
+ item = testWidget->widget(1);
+ testWidget->removeItem(testWidget->indexOf(item));
+ QVERIFY( item );
+ QCOMPARE( currentIndex, -1 );
+ QCOMPARE( testWidget->currentIndex(), 0 );
+ QCOMPARE( testWidget->count(), 2 );
+ QCOMPARE( testWidget->indexOf(item), -1 );
+
+ item = testWidget->widget(1);
+ delete item;
+ QCOMPARE( testWidget->count(), 1 );
+ QCOMPARE( currentIndex, -1 );
+ currentIndex = testWidget->currentIndex();
+
+ item = testWidget->widget(0);
+ testWidget->removeItem(testWidget->indexOf(item));
+ QCOMPARE( testWidget->count(), 0 );
+ QCOMPARE( currentIndex, -1 );
+}
+
+QTEST_MAIN(tst_QToolBox)
+#include "tst_qtoolbox.moc"
diff --git a/tests/auto/widgets/widgets/qtoolbutton/.gitignore b/tests/auto/widgets/widgets/qtoolbutton/.gitignore
new file mode 100644
index 0000000000..91e11101e1
--- /dev/null
+++ b/tests/auto/widgets/widgets/qtoolbutton/.gitignore
@@ -0,0 +1 @@
+tst_qtoolbutton
diff --git a/tests/auto/widgets/widgets/qtoolbutton/qtoolbutton.pro b/tests/auto/widgets/widgets/qtoolbutton/qtoolbutton.pro
new file mode 100644
index 0000000000..5f082682ad
--- /dev/null
+++ b/tests/auto/widgets/widgets/qtoolbutton/qtoolbutton.pro
@@ -0,0 +1,3 @@
+load(qttest_p4)
+QT += widgets
+SOURCES += tst_qtoolbutton.cpp
diff --git a/tests/auto/widgets/widgets/qtoolbutton/tst_qtoolbutton.cpp b/tests/auto/widgets/widgets/qtoolbutton/tst_qtoolbutton.cpp
new file mode 100644
index 0000000000..0e21ea6611
--- /dev/null
+++ b/tests/auto/widgets/widgets/qtoolbutton/tst_qtoolbutton.cpp
@@ -0,0 +1,231 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#include <QtTest/QtTest>
+
+#include <qcoreapplication.h>
+#include <qdebug.h>
+#include <qtoolbutton.h>
+#include <qmenu.h>
+#include <qaction.h>
+#include <qwindowsstyle.h>
+#include <qstyleoption.h>
+
+//TESTED_CLASS=
+//TESTED_FILES=
+
+class tst_QToolButton : public QObject
+{
+Q_OBJECT
+
+public:
+ tst_QToolButton();
+ virtual ~tst_QToolButton();
+
+private slots:
+ void getSetCheck();
+ void triggered();
+ void collapseTextOnPriority();
+ void task230994_iconSize();
+ void task176137_autoRepeatOfAction();
+
+protected slots:
+ void sendMouseClick();
+private:
+ QWidget *w;
+};
+
+tst_QToolButton::tst_QToolButton()
+{
+}
+
+tst_QToolButton::~tst_QToolButton()
+{
+}
+
+// Testing get/set functions
+void tst_QToolButton::getSetCheck()
+{
+ QToolButton obj1;
+ // QMenu* QToolButton::menu()
+ // void QToolButton::setMenu(QMenu*)
+ QMenu *var1 = new QMenu;
+ obj1.setMenu(var1);
+ QCOMPARE(var1, obj1.menu());
+ obj1.setMenu((QMenu *)0);
+ QCOMPARE((QMenu *)0, obj1.menu());
+ delete var1;
+
+ // ToolButtonPopupMode QToolButton::popupMode()
+ // void QToolButton::setPopupMode(ToolButtonPopupMode)
+ obj1.setPopupMode(QToolButton::ToolButtonPopupMode(QToolButton::DelayedPopup));
+ QCOMPARE(QToolButton::ToolButtonPopupMode(QToolButton::DelayedPopup), obj1.popupMode());
+ obj1.setPopupMode(QToolButton::ToolButtonPopupMode(QToolButton::MenuButtonPopup));
+ QCOMPARE(QToolButton::ToolButtonPopupMode(QToolButton::MenuButtonPopup), obj1.popupMode());
+ obj1.setPopupMode(QToolButton::ToolButtonPopupMode(QToolButton::InstantPopup));
+ QCOMPARE(QToolButton::ToolButtonPopupMode(QToolButton::InstantPopup), obj1.popupMode());
+
+ // bool QToolButton::autoRaise()
+ // void QToolButton::setAutoRaise(bool)
+ obj1.setAutoRaise(false);
+ QCOMPARE(false, obj1.autoRaise());
+ obj1.setAutoRaise(true);
+ QCOMPARE(true, obj1.autoRaise());
+
+ // QAction * QToolButton::defaultAction()
+ // void QToolButton::setDefaultAction(QAction *)
+ QAction *var4 = new QAction(0);
+ obj1.setDefaultAction(var4);
+ QCOMPARE(var4, obj1.defaultAction());
+ obj1.setDefaultAction((QAction *)0);
+ QCOMPARE((QAction *)0, obj1.defaultAction());
+ delete var4;
+}
+
+Q_DECLARE_METATYPE(QAction*)
+
+void tst_QToolButton::triggered()
+{
+ qRegisterMetaType<QAction *>("QAction *");
+ QToolButton tb;
+ tb.show();
+ QSignalSpy spy(&tb,SIGNAL(triggered(QAction*)));
+ QMenu *menu = new QMenu("Menu");
+ QAction *one = menu->addAction("one");
+ menu->addAction("two");
+ QAction *def = new QAction("def", this);
+
+ tb.setMenu(menu);
+ tb.setDefaultAction(def);
+
+#ifdef Q_WS_QWS
+ QApplication::processEvents(); //wait for the window system to show the tool button
+#endif
+
+ def->trigger();
+ QCOMPARE(spy.count(),1);
+ QCOMPARE(qvariant_cast<QAction *>(spy.at(0).at(0)), def);
+
+ w = menu;
+ QTimer::singleShot(30, this, SLOT(sendMouseClick()));
+ tb.showMenu();
+ QTest::qWait(20);
+ QCOMPARE(spy.count(),2);
+ QCOMPARE(qvariant_cast<QAction *>(spy.at(1).at(0)), one);
+ delete menu;
+}
+
+void tst_QToolButton::collapseTextOnPriority()
+{
+ class MyToolButton : public QToolButton
+ {
+ friend class tst_QToolButton;
+ public:
+ void initStyleOption(QStyleOptionToolButton *option)
+ {
+ QToolButton::initStyleOption(option);
+ }
+ };
+
+ MyToolButton button;
+ button.setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
+ QAction action(button.style()->standardIcon(QStyle::SP_ArrowBack), "test", 0);
+ button.setDefaultAction(&action);
+
+ QStyleOptionToolButton option;
+ button.initStyleOption(&option);
+ QVERIFY(option.toolButtonStyle == Qt::ToolButtonTextBesideIcon);
+ action.setPriority(QAction::LowPriority);
+ button.initStyleOption(&option);
+ QVERIFY(option.toolButtonStyle == Qt::ToolButtonIconOnly);
+}
+
+
+void tst_QToolButton::task230994_iconSize()
+{
+ //we check that the iconsize returned bu initStyleOption is valid
+ //when the toolbutton has no parent
+ class MyToolButton : public QToolButton
+ {
+ friend class tst_QToolButton;
+ public:
+ void initStyleOption(QStyleOptionToolButton *option)
+ {
+ QToolButton::initStyleOption(option);
+ }
+ };
+
+ MyToolButton button;
+ QStyleOptionToolButton option;
+ button.initStyleOption(&option);
+ QVERIFY(option.iconSize.isValid());
+}
+
+void tst_QToolButton::task176137_autoRepeatOfAction()
+{
+ QAction action(0);
+ QToolButton tb;
+ tb.setDefaultAction (&action);
+ tb.show();
+ QSignalSpy spy(&action,SIGNAL(triggered()));
+ QTest::mousePress ( &tb, Qt::LeftButton);
+ QTest::mouseRelease ( &tb, Qt::LeftButton, 0, QPoint (), 2000);
+ QCOMPARE(spy.count(),1);
+
+ // try again with auto repeat
+ tb.setAutoRepeat (true);
+ QSignalSpy repeatSpy(&action,SIGNAL(triggered())); // new spy
+ QTest::mousePress ( &tb, Qt::LeftButton);
+ QTest::mouseRelease ( &tb, Qt::LeftButton, 0, QPoint (), 3000);
+ qreal expected = (3000 - tb.autoRepeatDelay()) / tb.autoRepeatInterval() + 1;
+ //we check that the difference is less than 10% (on some systems timers are not super accurate)
+ QVERIFY ( qAbs( (expected - repeatSpy.count()) / expected) < 0.1);
+}
+
+
+void tst_QToolButton::sendMouseClick()
+{
+ QTest::mouseClick(w, Qt::LeftButton, 0, QPoint(7,7));
+}
+
+QTEST_MAIN(tst_QToolButton)
+#include "tst_qtoolbutton.moc"
diff --git a/tests/auto/widgets/widgets/qworkspace/.gitignore b/tests/auto/widgets/widgets/qworkspace/.gitignore
new file mode 100644
index 0000000000..73facc366e
--- /dev/null
+++ b/tests/auto/widgets/widgets/qworkspace/.gitignore
@@ -0,0 +1 @@
+tst_qworkspace
diff --git a/tests/auto/widgets/widgets/qworkspace/qworkspace.pro b/tests/auto/widgets/widgets/qworkspace/qworkspace.pro
new file mode 100644
index 0000000000..0b8a604fe8
--- /dev/null
+++ b/tests/auto/widgets/widgets/qworkspace/qworkspace.pro
@@ -0,0 +1,3 @@
+load(qttest_p4)
+QT += widgets
+SOURCES += tst_qworkspace.cpp
diff --git a/tests/auto/widgets/widgets/qworkspace/tst_qworkspace.cpp b/tests/auto/widgets/widgets/qworkspace/tst_qworkspace.cpp
new file mode 100644
index 0000000000..a996c38438
--- /dev/null
+++ b/tests/auto/widgets/widgets/qworkspace/tst_qworkspace.cpp
@@ -0,0 +1,679 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#include <QtTest/QtTest>
+#include <qapplication.h>
+#include <qmainwindow.h>
+#include <qmenubar.h>
+#include <qworkspace.h>
+
+//TESTED_CLASS=
+//TESTED_FILES=
+
+class tst_QWorkspace : public QObject
+{
+ Q_OBJECT
+
+public:
+ tst_QWorkspace();
+ virtual ~tst_QWorkspace();
+
+
+protected slots:
+ void activeChanged( QWidget *w );
+ void accelActivated();
+
+public slots:
+ void initTestCase();
+ void cleanupTestCase();
+ void init();
+ void cleanup();
+private slots:
+ void getSetCheck();
+ void windowActivated_data();
+ void windowActivated();
+ void windowActivatedWithMinimize();
+ void showWindows();
+ void changeWindowTitle();
+ void changeModified();
+ void childSize();
+ void fixedSize();
+#if defined(Q_WS_WIN) || defined(Q_WS_X11)
+ void nativeSubWindows();
+#endif
+ void task206368();
+
+private:
+ QWidget *activeWidget;
+ bool accelPressed;
+};
+
+// Testing get/set functions
+void tst_QWorkspace::getSetCheck()
+{
+ QWorkspace obj1;
+ // bool QWorkspace::scrollBarsEnabled()
+ // void QWorkspace::setScrollBarsEnabled(bool)
+ obj1.setScrollBarsEnabled(false);
+ QCOMPARE(false, obj1.scrollBarsEnabled());
+ obj1.setScrollBarsEnabled(true);
+ QCOMPARE(true, obj1.scrollBarsEnabled());
+}
+
+tst_QWorkspace::tst_QWorkspace()
+ : activeWidget( 0 )
+{
+}
+
+tst_QWorkspace::~tst_QWorkspace()
+{
+
+}
+
+// initTestCase will be executed once before the first testfunction is executed.
+void tst_QWorkspace::initTestCase()
+{
+
+}
+
+// cleanupTestCase will be executed once after the last testfunction is executed.
+void tst_QWorkspace::cleanupTestCase()
+{
+}
+
+// init() will be executed immediately before each testfunction is run.
+void tst_QWorkspace::init()
+{
+// TODO: Add testfunction specific initialization code here.
+}
+
+// cleanup() will be executed immediately after each testfunction is run.
+void tst_QWorkspace::cleanup()
+{
+// TODO: Add testfunction specific cleanup code here.
+}
+
+void tst_QWorkspace::activeChanged( QWidget *w )
+{
+ activeWidget = w;
+}
+
+void tst_QWorkspace::windowActivated_data()
+{
+ // define the test elements we're going to use
+ QTest::addColumn<int>("count");
+
+ // create a first testdata instance and fill it with data
+ QTest::newRow( "data0" ) << 0;
+ QTest::newRow( "data1" ) << 1;
+ QTest::newRow( "data2" ) << 2;
+}
+
+void tst_QWorkspace::windowActivated()
+{
+ QMainWindow mw(0, Qt::X11BypassWindowManagerHint);
+ mw.menuBar();
+ QWorkspace *workspace = new QWorkspace(&mw);
+ workspace->setObjectName("testWidget");
+ mw.setCentralWidget(workspace);
+ QSignalSpy spy(workspace, SIGNAL(windowActivated(QWidget*)));
+ connect( workspace, SIGNAL(windowActivated(QWidget*)), this, SLOT(activeChanged(QWidget*)) );
+ mw.show();
+ qApp->setActiveWindow(&mw);
+
+ QFETCH( int, count );
+ int i;
+
+ for ( i = 0; i < count; ++i ) {
+ QWidget *widget = new QWidget(workspace, 0);
+ widget->setAttribute(Qt::WA_DeleteOnClose);
+ workspace->addWindow(widget);
+ widget->show();
+ qApp->processEvents();
+ QVERIFY( activeWidget == workspace->activeWindow() );
+ QCOMPARE(spy.count(), 1);
+ spy.clear();
+ }
+
+ QWidgetList windows = workspace->windowList();
+ QCOMPARE( (int)windows.count(), count );
+
+ for ( i = 0; i < count; ++i ) {
+ QWidget *window = windows.at(i);
+ window->showMinimized();
+ qApp->processEvents();
+ QVERIFY( activeWidget == workspace->activeWindow() );
+ if ( i == 1 )
+ QVERIFY( activeWidget == window );
+ }
+
+ for ( i = 0; i < count; ++i ) {
+ QWidget *window = windows.at(i);
+ window->showNormal();
+ qApp->processEvents();
+ QVERIFY( window == activeWidget );
+ QVERIFY( activeWidget == workspace->activeWindow() );
+ }
+ spy.clear();
+
+ while ( workspace->activeWindow() ) {
+ workspace->activeWindow()->close();
+ qApp->processEvents();
+ QVERIFY( activeWidget == workspace->activeWindow() );
+ QCOMPARE(spy.count(), 1);
+ spy.clear();
+ }
+ QVERIFY(activeWidget == 0);
+ QVERIFY(workspace->activeWindow() == 0);
+ QVERIFY(workspace->windowList().count() == 0);
+
+ {
+ workspace->hide();
+ QWidget *widget = new QWidget(workspace);
+ widget->setObjectName("normal");
+ widget->setAttribute(Qt::WA_DeleteOnClose);
+ workspace->addWindow(widget);
+ widget->show();
+ QCOMPARE(spy.count(), 0);
+ workspace->show();
+ QCOMPARE(spy.count(), 1);
+ spy.clear();
+ QVERIFY( activeWidget == widget );
+ widget->close();
+ qApp->processEvents();
+ QCOMPARE(spy.count(), 1);
+ spy.clear();
+ QVERIFY( activeWidget == 0 );
+ }
+
+ {
+ workspace->hide();
+ QWidget *widget = new QWidget(workspace);
+ widget->setObjectName("maximized");
+ widget->setAttribute(Qt::WA_DeleteOnClose);
+ workspace->addWindow(widget);
+ widget->showMaximized();
+ qApp->sendPostedEvents();
+#ifdef Q_WS_MAC
+ QEXPECT_FAIL("", "This test has never passed on Mac. QWorkspace is obsoleted -> won't fix", Abort);
+#endif
+ QCOMPARE(spy.count(), 0);
+ spy.clear();
+ workspace->show();
+ QCOMPARE(spy.count(), 1);
+ spy.clear();
+ QVERIFY( activeWidget == widget );
+ widget->close();
+ qApp->processEvents();
+ QCOMPARE(spy.count(), 1);
+ spy.clear();
+ QVERIFY( activeWidget == 0 );
+ }
+
+ {
+ QWidget *widget = new QWidget(workspace);
+ widget->setObjectName("minimized");
+ widget->setAttribute(Qt::WA_DeleteOnClose);
+ workspace->addWindow(widget);
+ widget->showMinimized();
+ QCOMPARE(spy.count(), 1);
+ spy.clear();
+ QVERIFY( activeWidget == widget );
+ QVERIFY(workspace->activeWindow() == widget);
+ widget->close();
+ qApp->processEvents();
+ QCOMPARE(spy.count(), 1);
+ spy.clear();
+ QVERIFY(workspace->activeWindow() == 0);
+ QVERIFY( activeWidget == 0 );
+ }
+}
+void tst_QWorkspace::windowActivatedWithMinimize()
+{
+ QMainWindow mw(0, Qt::X11BypassWindowManagerHint) ;
+ mw.menuBar();
+ QWorkspace *workspace = new QWorkspace(&mw);
+ workspace->setObjectName("testWidget");
+ mw.setCentralWidget(workspace);
+ QSignalSpy spy(workspace, SIGNAL(windowActivated(QWidget*)));
+ connect( workspace, SIGNAL(windowActivated(QWidget*)), this, SLOT(activeChanged(QWidget*)) );
+ mw.show();
+ qApp->setActiveWindow(&mw);
+ QWidget *widget = new QWidget(workspace);
+ widget->setObjectName("minimized1");
+ widget->setAttribute(Qt::WA_DeleteOnClose);
+ workspace->addWindow(widget);
+ QWidget *widget2 = new QWidget(workspace);
+ widget2->setObjectName("minimized2");
+ widget2->setAttribute(Qt::WA_DeleteOnClose);
+ workspace->addWindow(widget2);
+
+ widget->showMinimized();
+ QVERIFY( activeWidget == widget );
+ widget2->showMinimized();
+ QVERIFY( activeWidget == widget2 );
+
+ widget2->close();
+ qApp->processEvents();
+ QVERIFY( activeWidget == widget );
+
+ widget->close();
+ qApp->processEvents();
+ QVERIFY(workspace->activeWindow() == 0);
+ QVERIFY( activeWidget == 0 );
+
+ QVERIFY( workspace->windowList().count() == 0 );
+}
+
+void tst_QWorkspace::accelActivated()
+{
+ accelPressed = TRUE;
+}
+
+void tst_QWorkspace::showWindows()
+{
+ QWorkspace *ws = new QWorkspace( 0 );
+
+ QWidget *widget = 0;
+ ws->show();
+
+ widget = new QWidget(ws);
+ widget->setObjectName("plain1");
+ widget->show();
+ QVERIFY( widget->isVisible() );
+
+ widget = new QWidget(ws);
+ widget->setObjectName("maximized1");
+ widget->showMaximized();
+ QVERIFY( widget->isMaximized() );
+ widget->showNormal();
+ QVERIFY( !widget->isMaximized() );
+
+ widget = new QWidget(ws);
+ widget->setObjectName("minimized1");
+ widget->showMinimized();
+ QVERIFY( widget->isMinimized() );
+ widget->showNormal();
+ QVERIFY( !widget->isMinimized() );
+
+ ws->hide();
+
+ widget = new QWidget(ws);
+ widget->setObjectName("plain2");
+ ws->show();
+ QVERIFY( widget->isVisible() );
+
+ ws->hide();
+
+ widget = new QWidget(ws);
+ widget->setObjectName("maximized2");
+ widget->showMaximized();
+ QVERIFY( widget->isMaximized() );
+ ws->show();
+ QVERIFY( widget->isVisible() );
+ QVERIFY( widget->isMaximized() );
+ ws->hide();
+
+ widget = new QWidget(ws);
+ widget->setObjectName("minimized2");
+ widget->showMinimized();
+ ws->show();
+ QVERIFY( widget->isMinimized() );
+ ws->hide();
+
+ delete ws;
+}
+
+
+//#define USE_SHOW
+
+void tst_QWorkspace::changeWindowTitle()
+{
+#ifdef Q_OS_WINCE
+ QSKIP( "Test fails on Windows CE due to QWorkspace state handling", SkipAll);
+#endif
+ const QString mwc( "MainWindow's Caption" );
+ const QString mwc2( "MainWindow's New Caption" );
+ const QString wc( "Widget's Caption" );
+ const QString wc2( "Widget's New Caption" );
+
+ QMainWindow *mw = new QMainWindow(0, Qt::X11BypassWindowManagerHint);
+ mw->setWindowTitle( mwc );
+ QWorkspace *ws = new QWorkspace( mw );
+ mw->setCentralWidget( ws );
+
+
+ QWidget *widget = new QWidget( ws );
+ widget->setWindowTitle( wc );
+ ws->addWindow(widget);
+
+ QCOMPARE( mw->windowTitle(), mwc );
+
+
+#ifdef USE_SHOW
+ widget->showMaximized();
+#else
+ widget->setWindowState(Qt::WindowMaximized);
+#endif
+ QCOMPARE( mw->windowTitle(), QString("%1 - [%2]").arg(mwc).arg(wc) );
+
+#ifdef USE_SHOW
+ widget->showNormal();
+#else
+ widget->setWindowState(Qt::WindowNoState);
+#endif
+ qApp->processEvents();
+ QCOMPARE( mw->windowTitle(), mwc );
+
+#ifdef USE_SHOW
+ widget->showMaximized();
+#else
+ widget->setWindowState(Qt::WindowMaximized);
+#endif
+ qApp->processEvents();
+ QCOMPARE( mw->windowTitle(), QString("%1 - [%2]").arg(mwc).arg(wc) );
+ widget->setWindowTitle( wc2 );
+ QCOMPARE( mw->windowTitle(), QString("%1 - [%2]").arg(mwc).arg(wc2) );
+ mw->setWindowTitle( mwc2 );
+ QCOMPARE( mw->windowTitle(), QString("%1 - [%2]").arg(mwc2).arg(wc2) );
+
+ mw->show();
+ qApp->setActiveWindow(mw);
+
+#ifdef USE_SHOW
+ mw->showFullScreen();
+#else
+ mw->setWindowState(Qt::WindowFullScreen);
+#endif
+
+ qApp->processEvents();
+ QCOMPARE( mw->windowTitle(), QString("%1 - [%2]").arg(mwc2).arg(wc2) );
+#ifdef USE_SHOW
+ widget->showNormal();
+#else
+ widget->setWindowState(Qt::WindowNoState);
+#endif
+ qApp->processEvents();
+ QCOMPARE( mw->windowTitle(), mwc2 );
+#ifdef USE_SHOW
+ widget->showMaximized();
+#else
+ widget->setWindowState(Qt::WindowMaximized);
+#endif
+ qApp->processEvents();
+ QCOMPARE( mw->windowTitle(), QString("%1 - [%2]").arg(mwc2).arg(wc2) );
+
+#ifdef USE_SHOW
+ mw->showNormal();
+#else
+ mw->setWindowState(Qt::WindowNoState);
+#endif
+ qApp->processEvents();
+ QCOMPARE( mw->windowTitle(), QString("%1 - [%2]").arg(mwc2).arg(wc2) );
+#ifdef USE_SHOW
+ widget->showNormal();
+#else
+ widget->setWindowState(Qt::WindowNoState);
+#endif
+ QCOMPARE( mw->windowTitle(), mwc2 );
+
+ delete mw;
+}
+
+void tst_QWorkspace::changeModified()
+{
+ const QString mwc( "MainWindow's Caption" );
+ const QString wc( "Widget's Caption[*]" );
+
+ QMainWindow *mw = new QMainWindow(0, Qt::X11BypassWindowManagerHint);
+ mw->setWindowTitle( mwc );
+ QWorkspace *ws = new QWorkspace( mw );
+ mw->setCentralWidget( ws );
+
+ QWidget *widget = new QWidget( ws );
+ widget->setWindowTitle( wc );
+ ws->addWindow(widget);
+
+ QCOMPARE( mw->isWindowModified(), false);
+ QCOMPARE( widget->isWindowModified(), false);
+ widget->setWindowState(Qt::WindowMaximized);
+ QCOMPARE( mw->isWindowModified(), false);
+ QCOMPARE( widget->isWindowModified(), false);
+
+ widget->setWindowState(Qt::WindowNoState);
+ QCOMPARE( mw->isWindowModified(), false);
+ QCOMPARE( widget->isWindowModified(), false);
+
+ widget->setWindowModified(true);
+ QCOMPARE( mw->isWindowModified(), false);
+ QCOMPARE( widget->isWindowModified(), true);
+ widget->setWindowState(Qt::WindowMaximized);
+ QCOMPARE( mw->isWindowModified(), true);
+ QCOMPARE( widget->isWindowModified(), true);
+
+ widget->setWindowState(Qt::WindowNoState);
+ QCOMPARE( mw->isWindowModified(), false);
+ QCOMPARE( widget->isWindowModified(), true);
+
+ widget->setWindowState(Qt::WindowMaximized);
+ QCOMPARE( mw->isWindowModified(), true);
+ QCOMPARE( widget->isWindowModified(), true);
+
+ widget->setWindowModified(false);
+ QCOMPARE( mw->isWindowModified(), false);
+ QCOMPARE( widget->isWindowModified(), false);
+
+ widget->setWindowModified(true);
+ QCOMPARE( mw->isWindowModified(), true);
+ QCOMPARE( widget->isWindowModified(), true);
+
+ widget->setWindowState(Qt::WindowNoState);
+ QCOMPARE( mw->isWindowModified(), false);
+ QCOMPARE( widget->isWindowModified(), true);
+
+ delete mw;
+}
+
+class MyChild : public QWidget
+{
+public:
+ MyChild(QWidget *parent = 0, Qt::WFlags f = 0)
+ : QWidget(parent, f)
+ {
+ }
+
+ QSize sizeHint() const
+ {
+ return QSize(234, 123);
+ }
+};
+
+void tst_QWorkspace::childSize()
+{
+ QWorkspace ws;
+
+ MyChild *child = new MyChild(&ws);
+ child->show();
+ QCOMPARE(child->size(), child->sizeHint());
+ delete child;
+
+ child = new MyChild(&ws);
+ child->setFixedSize(200, 200);
+ child->show();
+ QCOMPARE(child->size(), child->minimumSize());
+ delete child;
+
+ child = new MyChild(&ws);
+ child->resize(150, 150);
+ child->show();
+ QCOMPARE(child->size(), QSize(150,150));
+ delete child;
+}
+
+void tst_QWorkspace::fixedSize()
+{
+ QWorkspace *ws = new QWorkspace;
+ int i;
+
+ ws->resize(500, 500);
+// ws->show();
+
+ QSize fixed(300, 300);
+ for (i = 0; i < 4; ++i) {
+ QWidget *child = new QWidget(ws);
+ child->setFixedSize(fixed);
+ child->show();
+ }
+
+ QWidgetList windows = ws->windowList();
+ for (i = 0; i < (int)windows.count(); ++i) {
+ QWidget *child = windows.at(i);
+ QCOMPARE(child->size(), fixed);
+ QCOMPARE(child->visibleRegion().boundingRect().size(), fixed);
+ }
+
+ ws->cascade();
+ ws->resize(800, 800);
+ for (i = 0; i < (int)windows.count(); ++i) {
+ QWidget *child = windows.at(i);
+ QCOMPARE(child->size(), fixed);
+ QCOMPARE(child->visibleRegion().boundingRect().size(), fixed);
+ }
+ ws->resize(500, 500);
+
+ ws->tile();
+ ws->resize(800, 800);
+ for (i = 0; i < (int)windows.count(); ++i) {
+ QWidget *child = windows.at(i);
+ QCOMPARE(child->size(), fixed);
+ QCOMPARE(child->visibleRegion().boundingRect().size(), fixed);
+ }
+ ws->resize(500, 500);
+
+ for (i = 0; i < (int)windows.count(); ++i) {
+ QWidget *child = windows.at(i);
+ delete child;
+ }
+
+ delete ws;
+}
+
+#if defined(Q_WS_WIN) || defined(Q_WS_X11)
+void tst_QWorkspace::nativeSubWindows()
+{
+ { // Add native widgets after show.
+ QWorkspace workspace;
+ workspace.addWindow(new QWidget);
+ workspace.addWindow(new QWidget);
+ workspace.show();
+#ifdef Q_WS_X11
+ qt_x11_wait_for_window_manager(&workspace);
+#endif
+
+ // No native widgets.
+ foreach (QWidget *subWindow, workspace.windowList())
+ QVERIFY(!subWindow->parentWidget()->internalWinId());
+
+ QWidget *nativeWidget = new QWidget;
+ QVERIFY(nativeWidget->winId()); // enforce native window.
+ workspace.addWindow(nativeWidget);
+
+ // All the sub-windows must be native.
+ foreach (QWidget *subWindow, workspace.windowList())
+ QVERIFY(subWindow->parentWidget()->internalWinId());
+
+ // Add a non-native widget. This should become native.
+ QWidget *subWindow = workspace.addWindow(new QWidget);
+ QVERIFY(subWindow->parentWidget()->internalWinId());
+ }
+
+ { // Add native widgets before show.
+ QWorkspace workspace;
+ workspace.addWindow(new QWidget);
+ QWidget *nativeWidget = new QWidget;
+ (void)nativeWidget->winId();
+ workspace.addWindow(nativeWidget);
+ workspace.show();
+#ifdef Q_WS_X11
+ qt_x11_wait_for_window_manager(&workspace);
+#endif
+
+ // All the sub-windows must be native.
+ foreach (QWidget *subWindow, workspace.windowList())
+ QVERIFY(subWindow->parentWidget()->internalWinId());
+ }
+
+ { // Make a sub-window native *after* it's added to the area.
+ QWorkspace workspace;
+ workspace.addWindow(new QWidget);
+ workspace.addWindow(new QWidget);
+ workspace.show();
+#ifdef Q_WS_X11
+ qt_x11_wait_for_window_manager(&workspace);
+#endif
+
+ QWidget *nativeSubWindow = workspace.windowList().last()->parentWidget();
+ QVERIFY(!nativeSubWindow->internalWinId());
+ (void)nativeSubWindow->winId();
+
+ // All the sub-windows should be native at this point.
+ foreach (QWidget *subWindow, workspace.windowList())
+ QVERIFY(subWindow->parentWidget()->internalWinId());
+ }
+}
+#endif
+
+void tst_QWorkspace::task206368()
+{
+ // Make sure the internal list of iconified windows doesn't contain dangling pointers.
+ QWorkspace workspace;
+ QWidget *child = new QWidget;
+ QWidget *window = workspace.addWindow(child);
+ workspace.show();
+ child->showMinimized();
+ delete window;
+ // This shouldn't crash.
+ workspace.arrangeIcons();
+}
+
+QTEST_MAIN(tst_QWorkspace)
+#include "tst_qworkspace.moc"
diff --git a/tests/auto/widgets/widgets/widgets.pro b/tests/auto/widgets/widgets/widgets.pro
new file mode 100644
index 0000000000..e77c311cde
--- /dev/null
+++ b/tests/auto/widgets/widgets/widgets.pro
@@ -0,0 +1,57 @@
+TEMPLATE=subdirs
+SUBDIRS=\
+ qabstractbutton \
+ qabstractscrollarea \
+ qabstractslider \
+ qabstractspinbox \
+ qbuttongroup \
+ qcalendarwidget \
+ qcheckbox \
+ qcombobox \
+ qcommandlinkbutton \
+ qdatetimeedit \
+ qdial \
+ qdialogbuttonbox \
+ qdockwidget \
+ qdoublespinbox \
+ qdoublevalidator \
+ qfocusframe \
+ qfontcombobox \
+ qgroupbox \
+ qintvalidator \
+ qlabel \
+ qlcdnumber \
+ qlineedit \
+ qmainwindow \
+ qmdiarea \
+ qmdisubwindow \
+ qmenu \
+ qmenubar \
+ qplaintextedit \
+ qprogressbar \
+ qpushbutton \
+ qradiobutton \
+ qregexpvalidator \
+ qscrollarea \
+ qscrollbar \
+ qsizegrip \
+ qslider \
+ qspinbox \
+ qsplitter \
+ qstackedwidget \
+ qstatusbar \
+ qtabbar \
+ qtabwidget \
+ qtextbrowser \
+ qtextedit \
+ qtoolbar \
+ qtoolbox \
+ qtoolbutton \
+ qworkspace \
+
+# The following tests depend on private API:
+!contains(QT_CONFIG, private_tests): SUBDIRS -= \
+ qcombobox \
+ qmainwindow \
+ qtextedit \
+ qtoolbar \