Changeset View
Changeset View
Standalone View
Standalone View
autotests/ktexttohtmltest.cpp
Show First 20 Lines • Show All 433 Lines • ▼ Show 20 Line(s) | 432 | QTest::newRow("two url with space") << "http://www.kde.org/standards/kcfg/1.0 http://www.kde.org/" | |||
---|---|---|---|---|---|
434 | << "<a href=\"http://www.kde.org/standards/kcfg/1.0\">http://www.kde.org/standards/kcfg/1.0</a> <a href=\"http://www.kde.org/\">http://www.kde.org/</a>"; | 434 | << "<a href=\"http://www.kde.org/standards/kcfg/1.0\">http://www.kde.org/standards/kcfg/1.0</a> <a href=\"http://www.kde.org/\">http://www.kde.org/</a>"; | ||
435 | 435 | | |||
436 | 436 | | |||
437 | //Bug kmail | 437 | //Bug kmail | ||
438 | QTest::newRow("two url with space-2") << "@@ -55,6 +55,10 @@ xsi:schemaLocation=\"http://www.kde.org/standards/kcfg/1.0 http://www.kde.org/" | 438 | QTest::newRow("two url with space-2") << "@@ -55,6 +55,10 @@ xsi:schemaLocation=\"http://www.kde.org/standards/kcfg/1.0 http://www.kde.org/" | ||
439 | << KTextToHTML::Options(KTextToHTML::PreserveSpaces) | 439 | << KTextToHTML::Options(KTextToHTML::PreserveSpaces) | ||
440 | << "@@ -55,6 +55,10 @@ xsi:schemaLocation="<a href=\"http://www.kde.org/standards/kcfg/1.0\">http://www.kde.org/standards/kcfg/1.0</a> <a href=\"http://www.kde.org/\">http://www.kde.org/</a>"; | 440 | << "@@ -55,6 +55,10 @@ xsi:schemaLocation="<a href=\"http://www.kde.org/standards/kcfg/1.0\">http://www.kde.org/standards/kcfg/1.0</a> <a href=\"http://www.kde.org/\">http://www.kde.org/</a>"; | ||
441 | 441 | | |||
442 | const auto opt = KTextToHTML::PreserveSpaces | KTextToHTML::ConvertPhoneNumbers; | ||||
443 | // tel: urls | ||||
444 | QTest::newRow("tel url compact") << "bla bla <tel:+491234567890> bla bla" << opt | ||||
445 | << "bla bla <<a href=\"tel:+491234567890\">tel:+491234567890</a>> bla bla"; | ||||
446 | QTest::newRow("tel url fancy") << "bla bla tel:+49-321-123456 bla bla" << opt | ||||
447 | << "bla bla <a href=\"tel:+49-321-123456\">tel:+49-321-123456</a> bla bla"; | ||||
448 | | ||||
449 | // negative tel: url tests | ||||
450 | QTest::newRow("empty tel url") << "bla tel: blub" << opt | ||||
451 | << "bla tel: blub"; | ||||
452 | | ||||
453 | // phone numbers | ||||
454 | QTest::newRow("tel compact international") << "call +49123456789, then hang up" << opt | ||||
455 | << "call <a href=\"tel:+49123456789\">+49123456789</a>, then hang up"; | ||||
456 | QTest::newRow("tel parenthesis/spaces international") << "phone:+33 (01) 12 34 56 78 blub" << opt | ||||
457 | << "phone:<a href=\"tel:+330112345678\">+33 (01) 12 34 56 78</a> blub"; | ||||
458 | QTest::newRow("tel dashes international") << "bla +44-321-1-234-567" << opt | ||||
459 | << "bla <a href=\"tel:+443211234567\">+44-321-1-234-567</a>"; | ||||
460 | QTest::newRow("tel dashes/spaces international") << "+1 123-456-7000 blub" << opt | ||||
461 | << "<a href=\"tel:+11234567000\">+1 123-456-7000</a> blub"; | ||||
462 | QTest::newRow("tel spaces international") << "bla +32 1 234 5678 blub" << opt | ||||
463 | << "bla <a href=\"tel:+3212345678\">+32 1 234 5678</a> blub"; | ||||
464 | QTest::newRow("tel slash domestic") << "bla 030/12345678 blub" << opt | ||||
465 | << "bla <a href=\"tel:03012345678\">030/12345678</a> blub"; | ||||
466 | QTest::newRow("tel slash/space domestic") << "Tel.: 089 / 12 34 56 78" << opt | ||||
467 | << "Tel.: <a href=\"tel:08912345678\">089 / 12 34 56 78</a>"; | ||||
468 | QTest::newRow("tel follow by parenthesis") << "Telefon: 0 18 05 / 12 23 46 (14 Cent/Min.*)" << opt | ||||
469 | << "Telefon: <a href=\"tel:01805122346\">0 18 05 / 12 23 46</a> (14 Cent/Min.*)"; | ||||
470 | QTest::newRow("tel space single digit at end") << "0123/123 456 7" << opt | ||||
471 | << "<a href=\"tel:01231234567\">0123/123 456 7</a>"; | ||||
472 | QTest::newRow("tel space around dash") << "bla +49 (0) 12 23 - 45 6000 blub" << opt | ||||
473 | << "bla <a href=\"tel:+4901223456000\">+49 (0) 12 23 - 45 6000</a> blub"; | ||||
474 | QTest::newRow("tel two numbers speparated by dash") << "bla +49 (0) 12 23 46 78 - +49 0123/123 456 78 blub" << opt | ||||
475 | << "bla <a href=\"tel:+49012234678\">+49 (0) 12 23 46 78</a> - <a href=\"tel:+49012312345678\">+49 0123/123 456 78</a> blub"; | ||||
476 | | ||||
477 | // negative tests for phone numbers | ||||
478 | QTest::newRow("non-tel number") << "please send 1200 cakes" << opt | ||||
479 | << "please send 1200 cakes"; | ||||
480 | QTest::newRow("non-tel alpha-numeric") << "bla 1-123-456-ABCD blub" << opt | ||||
481 | << "bla 1-123-456-ABCD blub"; | ||||
482 | QTest::newRow("non-tel alpha prefix") << "ABCD0123-456-789" << opt | ||||
483 | << "ABCD0123-456-789"; | ||||
484 | QTest::newRow("non-tel date") << "bla 02/03/2019 blub" << opt | ||||
485 | << "bla 02/03/2019 blub"; | ||||
486 | QTest::newRow("non-tel too long") << "bla +012-4567890123456 blub" << opt | ||||
487 | << "bla +012-4567890123456 blub"; | ||||
488 | QTest::newRow("non-tel unbalanced") << "bla +012-456789(01 blub" << opt | ||||
489 | << "bla +012-456789(01 blub"; | ||||
490 | QTest::newRow("non-tel nested") << "bla +012-4(56(78)90)1 blub" << opt | ||||
491 | << "bla +012-4(56(78)90)1 blub"; | ||||
492 | QTest::newRow("tel extraction disabled") << "call +49123456789 now" | ||||
493 | << KTextToHTML::Options(KTextToHTML::PreserveSpaces) | ||||
494 | << "call +49123456789 now"; | ||||
442 | } | 495 | } | ||
443 | 496 | | |||
444 | 497 | | |||
445 | void KTextToHTMLTest::testHtmlConvert() | 498 | void KTextToHTMLTest::testHtmlConvert() | ||
446 | { | 499 | { | ||
447 | QFETCH(QString, plainText); | 500 | QFETCH(QString, plainText); | ||
448 | QFETCH(KTextToHTML::Options, flags); | 501 | QFETCH(KTextToHTML::Options, flags); | ||
449 | QFETCH(QString, htmlText); | 502 | QFETCH(QString, htmlText); | ||
Show All 32 Lines |