diff options
Diffstat (limited to 'tests/auto/widgets/widgets')
6 files changed, 113 insertions, 3 deletions
diff --git a/tests/auto/widgets/widgets/qdatetimeedit/tst_qdatetimeedit.cpp b/tests/auto/widgets/widgets/qdatetimeedit/tst_qdatetimeedit.cpp index bfffa357a8..ded3e55283 100644 --- a/tests/auto/widgets/widgets/qdatetimeedit/tst_qdatetimeedit.cpp +++ b/tests/auto/widgets/widgets/qdatetimeedit/tst_qdatetimeedit.cpp @@ -346,7 +346,7 @@ void tst_QDateTimeEdit::cleanupTestCase() void tst_QDateTimeEdit::init() { QLocale::setDefault(QLocale(QLocale::C)); -#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) +#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT) SetThreadLocale(MAKELCID(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), SORT_DEFAULT)); #endif testWidget->setDisplayFormat("dd/MM/yyyy"); // Nice default to have diff --git a/tests/auto/widgets/widgets/qdoublespinbox/tst_qdoublespinbox.cpp b/tests/auto/widgets/widgets/qdoublespinbox/tst_qdoublespinbox.cpp index b880ebe078..49f058862d 100644 --- a/tests/auto/widgets/widgets/qdoublespinbox/tst_qdoublespinbox.cpp +++ b/tests/auto/widgets/widgets/qdoublespinbox/tst_qdoublespinbox.cpp @@ -145,6 +145,9 @@ private slots: void taskQTBUG_6670_selectAllWithPrefix(); void taskQTBUG_6496_fiddlingWithPrecision(); + void setGroupSeparatorShown_data(); + void setGroupSeparatorShown(); + public slots: void valueChangedHelper(const QString &); void valueChangedHelper(double); @@ -156,6 +159,9 @@ private: typedef QList<double> DoubleList; +Q_DECLARE_METATYPE(QLocale::Language) +Q_DECLARE_METATYPE(QLocale::Country) + tst_QDoubleSpinBox::tst_QDoubleSpinBox() { @@ -1099,5 +1105,45 @@ void tst_QDoubleSpinBox::taskQTBUG_6496_fiddlingWithPrecision() QCOMPARE(dsb.maximum(), 0.991); } +void tst_QDoubleSpinBox::setGroupSeparatorShown_data() +{ + QTest::addColumn<QLocale::Language>("lang"); + QTest::addColumn<QLocale::Country>("country"); + + QTest::newRow("data0") << QLocale::English << QLocale::UnitedStates; + QTest::newRow("data1") << QLocale::Swedish << QLocale::Sweden; + QTest::newRow("data2") << QLocale::German << QLocale::Germany; + QTest::newRow("data3") << QLocale::Georgian << QLocale::Georgia; + QTest::newRow("data3") << QLocale::Macedonian << QLocale::Macedonia; +} + +void tst_QDoubleSpinBox::setGroupSeparatorShown() +{ + QFETCH(QLocale::Language, lang); + QFETCH(QLocale::Country, country); + + QLocale loc(lang, country); + QLocale::setDefault(loc); + DoubleSpinBox spinBox; + spinBox.setMaximum(99999999); + spinBox.setValue(1300000.00); + spinBox.setGroupSeparatorShown(true); + QCOMPARE(spinBox.lineEdit()->text(), spinBox.locale().toString(1300000.00, 'f', 2)); + QCOMPARE(spinBox.isGroupSeparatorShown(), true); + QCOMPARE(spinBox.textFromValue(23421),spinBox.locale().toString(23421.00, 'f', 2)); + + spinBox.setGroupSeparatorShown(false); + QCOMPARE(spinBox.lineEdit()->text(), spinBox.locale().toString(1300000.00, 'f', 2).remove( + spinBox.locale().groupSeparator())); + QCOMPARE(spinBox.isGroupSeparatorShown(), false); + + spinBox.setMaximum(72000); + spinBox.lineEdit()->setText(spinBox.locale().toString(32000.64, 'f', 2)); + QCOMPARE(spinBox.value()+1000, 33000.64); + + spinBox.lineEdit()->setText(spinBox.locale().toString(32000.44, 'f', 2)); + QCOMPARE(spinBox.value()+1000, 33000.44); +} + QTEST_MAIN(tst_QDoubleSpinBox) #include "tst_qdoublespinbox.moc" diff --git a/tests/auto/widgets/widgets/qspinbox/tst_qspinbox.cpp b/tests/auto/widgets/widgets/qspinbox/tst_qspinbox.cpp index 004fdda5ef..1c97686668 100644 --- a/tests/auto/widgets/widgets/qspinbox/tst_qspinbox.cpp +++ b/tests/auto/widgets/widgets/qspinbox/tst_qspinbox.cpp @@ -142,6 +142,10 @@ private slots: void taskQTBUG_5008_textFromValueAndValidate(); void lineEditReturnPressed(); + + void setGroupSeparatorShown_data(); + void setGroupSeparatorShown(); + public slots: void valueChangedHelper(const QString &); void valueChangedHelper(int); @@ -152,6 +156,9 @@ private: typedef QList<int> IntList; +Q_DECLARE_METATYPE(QLocale::Language) +Q_DECLARE_METATYPE(QLocale::Country) + // Testing get/set functions void tst_QSpinBox::getSetCheck() { @@ -1111,5 +1118,47 @@ void tst_QSpinBox::lineEditReturnPressed() QCOMPARE(spyCurrentChanged.count(), 1); } +void tst_QSpinBox::setGroupSeparatorShown_data() +{ + QTest::addColumn<QLocale::Language>("lang"); + QTest::addColumn<QLocale::Country>("country"); + + QTest::newRow("data0") << QLocale::English << QLocale::UnitedStates; + QTest::newRow("data1") << QLocale::Swedish << QLocale::Sweden; + QTest::newRow("data2") << QLocale::German << QLocale::Germany; + QTest::newRow("data3") << QLocale::Georgian << QLocale::Georgia; + QTest::newRow("data3") << QLocale::Macedonian << QLocale::Macedonia; +} + +void tst_QSpinBox::setGroupSeparatorShown() +{ + QFETCH(QLocale::Language, lang); + QFETCH(QLocale::Country, country); + + QLocale loc(lang, country); + QLocale::setDefault(loc); + SpinBox spinBox; + spinBox.setMaximum(99999); + spinBox.setValue(13000); + spinBox.setGroupSeparatorShown(true); + QCOMPARE(spinBox.lineEdit()->text(), spinBox.locale().toString(13000)); + QCOMPARE(spinBox.isGroupSeparatorShown(), true); + QCOMPARE(spinBox.textFromValue(23421),spinBox.locale().toString(23421)); + + spinBox.setGroupSeparatorShown(false); + QCOMPARE(spinBox.lineEdit()->text(), QStringLiteral("13000")); + QCOMPARE(spinBox.isGroupSeparatorShown(), false); + + spinBox.setMaximum(72000); + spinBox.lineEdit()->setText(spinBox.locale().toString(32000)); + QCOMPARE(spinBox.value()+1000, 33000); + + spinBox.lineEdit()->setText(QStringLiteral("32000")); + QCOMPARE(spinBox.value()+1000, 33000); + + spinBox.lineEdit()->setText(QStringLiteral("32,000")); + QCOMPARE(spinBox.value()+1000, 33000); +} + QTEST_MAIN(tst_QSpinBox) #include "tst_qspinbox.moc" diff --git a/tests/auto/widgets/widgets/qtabwidget/qtabwidget.pro b/tests/auto/widgets/widgets/qtabwidget/qtabwidget.pro index 72956a6867..c367959cbc 100644 --- a/tests/auto/widgets/widgets/qtabwidget/qtabwidget.pro +++ b/tests/auto/widgets/widgets/qtabwidget/qtabwidget.pro @@ -8,4 +8,4 @@ INCLUDEPATH += ../ HEADERS += SOURCES += tst_qtabwidget.cpp -win32:!wince*:LIBS += -luser32 +win32:!wince*:!winrt:LIBS += -luser32 diff --git a/tests/auto/widgets/widgets/qtabwidget/tst_qtabwidget.cpp b/tests/auto/widgets/widgets/qtabwidget/tst_qtabwidget.cpp index fa518e6afd..e55438f3d3 100644 --- a/tests/auto/widgets/widgets/qtabwidget/tst_qtabwidget.cpp +++ b/tests/auto/widgets/widgets/qtabwidget/tst_qtabwidget.cpp @@ -48,7 +48,7 @@ #include <qlabel.h> #include <QtWidgets/qboxlayout.h> -#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) +#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT) # include <qt_windows.h> #define Q_CHECK_PAINTEVENTS \ if (::SwitchDesktop(::GetThreadDesktop(::GetCurrentThreadId())) == 0) \ diff --git a/tests/auto/widgets/widgets/qtextedit/tst_qtextedit.cpp b/tests/auto/widgets/widgets/qtextedit/tst_qtextedit.cpp index 11bb5c88a1..d06807eedb 100644 --- a/tests/auto/widgets/widgets/qtextedit/tst_qtextedit.cpp +++ b/tests/auto/widgets/widgets/qtextedit/tst_qtextedit.cpp @@ -203,6 +203,8 @@ private slots: void highlightLongLine(); + void countTextChangedOnRemove(); + private: void createSelection(); int blockCount() const; @@ -2499,6 +2501,19 @@ void tst_QTextEdit::highlightLongLine() QVERIFY(true); } +//check for bug 15003, are there multiple textChanged() signals on remove? +void tst_QTextEdit::countTextChangedOnRemove() +{ + QTextEdit edit; + edit.insertPlainText("Hello"); + + QSignalSpy spy(&edit, SIGNAL(textChanged())); + + QKeyEvent event(QEvent::KeyPress, Qt::Key_Backspace, Qt::NoModifier); + QCoreApplication::instance()->notify(&edit, &event); + + QCOMPARE(spy.count(), 1); +} QTEST_MAIN(tst_QTextEdit) #include "tst_qtextedit.moc" |