117 void compareConstructors_data(); |
117 void compareConstructors_data(); |
118 void compareConstructors(); |
118 void compareConstructors(); |
119 void symetricConstructors_data(); |
119 void symetricConstructors_data(); |
120 void symetricConstructors(); |
120 void symetricConstructors(); |
121 void checkMultipleNames(); |
121 void checkMultipleNames(); |
|
122 void mnemonic_data(); |
122 void mnemonic(); |
123 void mnemonic(); |
123 void toString_data(); |
124 void toString_data(); |
124 void toString(); |
125 void toString(); |
125 void streamOperators_data(); |
126 void streamOperators_data(); |
126 void streamOperators(); |
127 void streamOperators(); |
297 #ifdef Q_WS_WIN |
299 #ifdef Q_WS_WIN |
298 QTest::newRow("addTab") << (int)QKeySequence::AddTab<< QString("CTRL+T"); |
300 QTest::newRow("addTab") << (int)QKeySequence::AddTab<< QString("CTRL+T"); |
299 QTest::newRow("findNext") << (int)QKeySequence::FindNext<< QString("F3"); |
301 QTest::newRow("findNext") << (int)QKeySequence::FindNext<< QString("F3"); |
300 QTest::newRow("findPrevious") << (int)QKeySequence::FindPrevious << QString("SHIFT+F3"); |
302 QTest::newRow("findPrevious") << (int)QKeySequence::FindPrevious << QString("SHIFT+F3"); |
301 QTest::newRow("close") << (int)QKeySequence::Close<< QString("CTRL+F4"); |
303 QTest::newRow("close") << (int)QKeySequence::Close<< QString("CTRL+F4"); |
302 QTest::newRow("replace") << (int)QKeySequence::Replace<< QString("CTRL+H"); |
304 QTest::newRow("replace") << (int)QKeySequence::Replace<< QString("CTRL+H"); |
303 #endif |
305 #endif |
304 QTest::newRow("bold") << (int)QKeySequence::Bold << QString("CTRL+B"); |
306 QTest::newRow("bold") << (int)QKeySequence::Bold << QString("CTRL+B"); |
305 QTest::newRow("italic") << (int)QKeySequence::Italic << QString("CTRL+I"); |
307 QTest::newRow("italic") << (int)QKeySequence::Italic << QString("CTRL+I"); |
306 QTest::newRow("underline") << (int)QKeySequence::Underline << QString("CTRL+U"); |
308 QTest::newRow("underline") << (int)QKeySequence::Underline << QString("CTRL+U"); |
307 QTest::newRow("selectall") << (int)QKeySequence::SelectAll << QString("CTRL+A"); |
309 QTest::newRow("selectall") << (int)QKeySequence::SelectAll << QString("CTRL+A"); |
355 #endif |
357 #endif |
356 QVERIFY(bindings == expected); |
358 QVERIFY(bindings == expected); |
357 } |
359 } |
358 |
360 |
359 |
361 |
|
362 |
|
363 void tst_QKeySequence::mnemonic_data() |
|
364 { |
|
365 QTest::addColumn<QString>("string"); |
|
366 QTest::addColumn<QString>("key"); |
|
367 QTest::addColumn<bool>("warning"); |
|
368 |
|
369 QTest::newRow("1") << QString::fromLatin1("&bonjour") << QString::fromLatin1("ALT+B") << false; |
|
370 QTest::newRow("2") << QString::fromLatin1("&&bonjour") << QString() << false; |
|
371 QTest::newRow("3") << QString::fromLatin1("&&bon&jour") << QString::fromLatin1("ALT+J") << false; |
|
372 QTest::newRow("4") << QString::fromLatin1("&&bon&jo&ur") << QString::fromLatin1("ALT+J") << true; |
|
373 QTest::newRow("5") << QString::fromLatin1("b&on&&jour") << QString::fromLatin1("ALT+O") << false; |
|
374 QTest::newRow("6") << QString::fromLatin1("bonjour") << QString() << false; |
|
375 QTest::newRow("7") << QString::fromLatin1("&&&bonjour") << QString::fromLatin1("ALT+B") << false; |
|
376 QTest::newRow("8") << QString::fromLatin1("bonjour&&&") << QString() << false; |
|
377 QTest::newRow("9") << QString::fromLatin1("bo&&nj&o&&u&r") << QString::fromLatin1("ALT+O") << true; |
|
378 QTest::newRow("10") << QString::fromLatin1("BON&JOUR") << QString::fromLatin1("ALT+J") << false; |
|
379 QTest::newRow("11") << QString::fromUtf8("bonjour") << QString() << false; |
|
380 } |
|
381 |
360 void tst_QKeySequence::mnemonic() |
382 void tst_QKeySequence::mnemonic() |
361 { |
383 { |
362 #ifdef Q_WS_MAC |
384 #ifdef Q_WS_MAC |
363 QSKIP("mnemonics are not used on Mac OS X", SkipAll); |
385 QSKIP("mnemonics are not used on Mac OS X", SkipAll); |
364 #endif |
386 #endif |
365 QKeySequence k = QKeySequence::mnemonic("&Foo"); |
387 QFETCH(QString, string); |
366 QVERIFY(k == QKeySequence("ALT+F")); |
388 QFETCH(QString, key); |
367 k = QKeySequence::mnemonic("&& &x"); |
389 QFETCH(bool, warning); |
368 QVERIFY(k == QKeySequence("ALT+X")); |
390 |
369 } |
391 #ifndef QT_NO_DEBUG |
|
392 if (warning) { |
|
393 QString str = QString::fromLatin1("QKeySequence::mnemonic: \"%1\" contains multiple occurences of '&'").arg(string); |
|
394 QTest::ignoreMessage(QtWarningMsg, qPrintable(str)); |
|
395 // qWarning(qPrintable(str)); |
|
396 } |
|
397 #endif |
|
398 QKeySequence seq = QKeySequence::mnemonic(string); |
|
399 QKeySequence res = QKeySequence(key); |
|
400 |
|
401 QCOMPARE(seq, res); |
|
402 } |
|
403 |
|
404 |
370 |
405 |
371 void tst_QKeySequence::toString_data() |
406 void tst_QKeySequence::toString_data() |
372 { |
407 { |
373 QTest::addColumn<QString>("strSequence"); |
408 QTest::addColumn<QString>("strSequence"); |
374 QTest::addColumn<QString>("neutralString"); |
409 QTest::addColumn<QString>("neutralString"); |