From kde-commits Thu Nov 04 07:48:14 2010 From: Kevin Ottens Date: Thu, 04 Nov 2010 07:48:14 +0000 To: kde-commits Subject: KDE/kdelibs/kdeui/tests Message-Id: <20101104074814.228E4AC89B () svn ! kde ! org> X-MARC-Message: https://marc.info/?l=kde-commits&m=128885692604226 SVN commit 1192846 by ervin: Make the tests build and pass without using deprecated API if KDE_NO_DEPRECATED is activated. M +5 -1 CMakeLists.txt M +0 -1 kapplication_unittest.cpp M +1 -1 kcharselecttest.cpp M +30 -5 kglobalshortcuttest.cpp M +30 -0 klineedit_unittest.cpp M +14 -14 knuminputtest.cpp M +1 -1 ktabwidget_unittest.cpp M +2 -2 ktabwidgettest.cpp M +0 -2 kwidgetitemdelegatetest.cpp M +2 -0 kxerrorhandlertest.cpp --- trunk/KDE/kdelibs/kdeui/tests/CMakeLists.txt #1192845:1192846 @@ -97,7 +97,6 @@ kdebugtest_gui kdialogbuttonboxtest kdialogtest - keditlistboxtest kfontdialogtest kglobalsettingsclient # helper program for kglobalsettingstest khboxtest @@ -145,6 +144,11 @@ kpixmapsequenceoverlaypaintertest ) +if (NOT KDE_NO_DEPRECATED) +KDEUI_EXECUTABLE_TESTS( + keditlistboxtest +) +endif (NOT KDE_NO_DEPRECATED) if (Q_WS_X11) --- trunk/KDE/kdelibs/kdeui/tests/kapplication_unittest.cpp #1192845:1192846 @@ -23,7 +23,6 @@ QTEST_KDEMAIN( KApplication_UnitTest, GUI ) -#include #include #include #include --- trunk/KDE/kdelibs/kdeui/tests/kcharselecttest.cpp #1192845:1192846 @@ -11,7 +11,7 @@ KApplication app; - KCharSelect selector( 0 ); + KCharSelect selector( 0, 0 ); selector.resize( selector.sizeHint() ); selector.show(); selector.setWindowTitle( "KCharSelect Test" ); --- trunk/KDE/kdelibs/kdeui/tests/kglobalshortcuttest.cpp #1192845:1192846 @@ -62,10 +62,12 @@ // Ensure that the previous test did cleanup correctly KGlobalAccel *kga = KGlobalAccel::self(); +#ifndef KDE_NO_DEPRECATED QList components = kga->allMainComponents(); QStringList componentId; componentId << "qttest" << QString() << "KDE Test Program" << QString(); // QVERIFY(!components.contains(componentId)); +#endif m_actionA = new KAction("Text For Action A", this); m_actionA->setObjectName("Action A:" + id); @@ -106,11 +108,26 @@ // Skip this. The above testcase hasn't changed the actions setupTest("testFindActionByKey"); - QStringList actionId = KGlobalAccel::self()->findActionNameSystemwide(sequenceB); - QStringList actionIdA; actionIdA << "qttest" << "Action A:testFindActionByKey" << "KDE Test Program" << "Text For Action A"; - QCOMPARE(actionId, actionIdA); - actionId = KGlobalAccel::self()->findActionNameSystemwide(sequenceA); - QCOMPARE(actionId, actionIdA); + QList actionId = KGlobalAccel::self()->getGlobalShortcutsByKey(sequenceB); + QCOMPARE(actionId.size(), 1); + + QString actionIdAComponentUniqueName("qttest"); + QString actionIdAUniqueName("Action A:testFindActionByKey"); + QString actionIdAComponentFriendlyName("KDE Test Program"); + QString actionIdAFriendlyName("Text For Action A"); + + QCOMPARE(actionId.first().componentUniqueName(), actionIdAComponentUniqueName); + QCOMPARE(actionId.first().uniqueName(), actionIdAUniqueName); + QCOMPARE(actionId.first().componentFriendlyName(), actionIdAComponentFriendlyName); + QCOMPARE(actionId.first().friendlyName(), actionIdAFriendlyName); + + actionId = KGlobalAccel::self()->getGlobalShortcutsByKey(sequenceA); + QCOMPARE(actionId.size(), 1); + + QCOMPARE(actionId.first().componentUniqueName(), actionIdAComponentUniqueName); + QCOMPARE(actionId.first().uniqueName(), actionIdAUniqueName); + QCOMPARE(actionId.first().componentFriendlyName(), actionIdAComponentFriendlyName); + QCOMPARE(actionId.first().friendlyName(), actionIdAFriendlyName); } void KGlobalShortcutTest::testChangeShortcut() @@ -207,12 +224,15 @@ // As in kdebase/workspace/kcontrol/keys/globalshortcuts.cpp KGlobalAccel *kga = KGlobalAccel::self(); +#ifndef KDE_NO_DEPRECATED QList components = kga->allMainComponents(); //qDebug() << components; QStringList componentId; componentId << "qttest" << QString() << "KDE Test Program" << QString(); QVERIFY(components.contains(componentId)); +#endif +#ifndef KDE_NO_DEPRECATED QList actions = kga->allActionsForComponent(componentId); QVERIFY(!actions.isEmpty()); QStringList actionIdA; actionIdA << "qttest" << "Action A:testListActions" << "KDE Test Program" << "Text For Action A"; @@ -220,6 +240,7 @@ //qDebug() << actions; QVERIFY(actions.contains(actionIdA)); QVERIFY(actions.contains(actionIdB)); +#endif } void KGlobalShortcutTest::testComponentAssignment() @@ -309,6 +330,7 @@ action->forgetGlobalShortcut(); delete coll.takeAction(action); +#ifndef KDE_NO_DEPRECATED // activate overrideMainComponentData, it's not revokable currently! // overrideMainComponentData only overrides the component if the action // gets a real global shortcut! @@ -337,6 +359,7 @@ action->forgetGlobalShortcut(); // Actions that were created by the KActionCollection::addAction have the // collections as parent. Ensure action is not deleted. +#endif } void KGlobalShortcutTest::testNotification() @@ -376,10 +399,12 @@ sleep(1); KGlobalAccel *kga = KGlobalAccel::self(); +#ifndef KDE_NO_DEPRECATED QList components = kga->allMainComponents(); QStringList componentId; componentId << "qttest" << QString() << "KDE Test Program" << QString(); QVERIFY(!components.contains(componentId)); +#endif } --- trunk/KDE/kdelibs/kdeui/tests/klineedit_unittest.cpp #1192845:1192846 @@ -60,23 +60,31 @@ // setText emits textChanged and userTextChanged, but not textEdited QSignalSpy textChangedSpy(&w, SIGNAL(textChanged(QString))); QSignalSpy textEditedSpy(&w, SIGNAL(textEdited(QString))); +#ifndef KDE_NO_DEPRECATED QSignalSpy userTextChangedSpy(&w, SIGNAL(userTextChanged(QString))); +#endif w.setText("Hello worl"); +#ifndef KDE_NO_DEPRECATED QCOMPARE(userTextChangedSpy.count(), 1); QCOMPARE(userTextChangedSpy[0][0].toString(), w.text()); +#endif QCOMPARE(textChangedSpy.count(), 1); QCOMPARE(textChangedSpy[0][0].toString(), w.text()); QCOMPARE(textEditedSpy.count(), 0); QVERIFY(!w.isModified()); +#ifndef KDE_NO_DEPRECATED userTextChangedSpy.clear(); +#endif textChangedSpy.clear(); textEditedSpy.clear(); // typing emits all three signals QTest::keyClick(&w, Qt::Key_D); QCOMPARE(w.text(), QString::fromLatin1("Hello world")); +#ifndef KDE_NO_DEPRECATED QCOMPARE(userTextChangedSpy.count(), 1); QCOMPARE(userTextChangedSpy[0][0].toString(), w.text()); +#endif QCOMPARE(textChangedSpy.count(), 1); QCOMPARE(textChangedSpy[0][0].toString(), w.text()); QCOMPARE(textEditedSpy.count(), 1); @@ -84,7 +92,9 @@ QVERIFY(w.isModified()); w.setText("K"); // prepare for next test +#ifndef KDE_NO_DEPRECATED userTextChangedSpy.clear(); +#endif textChangedSpy.clear(); textEditedSpy.clear(); QVERIFY(!w.isModified()); @@ -101,12 +111,16 @@ w.doCompletion(w.text()); QCOMPARE(w.text(), items.at(0)); +#ifndef KDE_NO_DEPRECATED QCOMPARE(userTextChangedSpy.count(), 0); +#endif QCOMPARE(textChangedSpy.count(), 1); QCOMPARE(textChangedSpy[0][0].toString(), w.text()); QCOMPARE(textEditedSpy.count(), 0); QVERIFY(!w.isModified()); +#ifndef KDE_NO_DEPRECATED userTextChangedSpy.clear(); +#endif textChangedSpy.clear(); textEditedSpy.clear(); @@ -114,14 +128,18 @@ QTest::keyClick(&w, Qt::Key_Right); QCOMPARE(w.text(), items.at(0)); +#ifndef KDE_NO_DEPRECATED QCOMPARE(userTextChangedSpy.count(), 1); QCOMPARE(userTextChangedSpy[0][0].toString(), w.text()); +#endif QCOMPARE(textChangedSpy.count(), 1); QCOMPARE(textChangedSpy[0][0].toString(), w.text()); QCOMPARE(textEditedSpy.count(), 1); QCOMPARE(textEditedSpy[0][0].toString(), w.text()); QVERIFY(w.isModified()); +#ifndef KDE_NO_DEPRECATED userTextChangedSpy.clear(); +#endif textChangedSpy.clear(); textEditedSpy.clear(); @@ -129,12 +147,18 @@ w.setCompletionMode(KGlobalSettings::CompletionPopup); w.setText("KDE"); QVERIFY(!w.isModified()); +#ifndef KDE_NO_DEPRECATED userTextChangedSpy.clear(); +#endif textChangedSpy.clear(); textEditedSpy.clear(); w.doCompletion(w.text()); // popup appears QCOMPARE(w.text(), QString::fromLatin1("KDE")); +#ifndef KDE_NO_DEPRECATED QCOMPARE(textChangedSpy.count() + userTextChangedSpy.count() + textEditedSpy.count(), 0); +#else + QCOMPARE(textChangedSpy.count() + textEditedSpy.count(), 0); +#endif w.completionBox()->down(); // select 1st item QCOMPARE(w.text(), items.at(0)); QVERIFY(w.isModified()); @@ -142,10 +166,14 @@ QCOMPARE(w.text(), items.at(1)); // Selecting an item in the popup completion changes the lineedit text and emits all 3 signals +#ifndef KDE_NO_DEPRECATED QCOMPARE(userTextChangedSpy.count(), 2); +#endif QCOMPARE(textChangedSpy.count(), 2); QCOMPARE(textEditedSpy.count(), 2); +#ifndef KDE_NO_DEPRECATED userTextChangedSpy.clear(); +#endif textChangedSpy.clear(); textEditedSpy.clear(); @@ -156,7 +184,9 @@ // Nothing else happens, the text was already set in the lineedit QCOMPARE(textChangedSpy.count(), 0); QCOMPARE(textEditedSpy.count(), 0); +#ifndef KDE_NO_DEPRECATED QCOMPARE(userTextChangedSpy.count(), 0); +#endif // Now when using the mouse in the popup completion w.setText("KDE"); --- trunk/KDE/kdelibs/kdeui/tests/knuminputtest.cpp #1192845:1192846 @@ -46,7 +46,7 @@ conn(i1,int); b1->layout()->addWidget(i1); - i2 = new KIntNumInput(i1, 42,b1); + i2 = new KIntNumInput(42, b1); i2->setLabel("percentage of usage (with slider)"); i2->setRange(0, 100, 5); i2->setSuffix(" %"); @@ -54,7 +54,7 @@ conn(i2,int); b1->layout()->addWidget(i2); - i3 = new KIntNumInput(i2, 0xAF, b1,16); + i3 = new KIntNumInput(0xAF, b1, 16); i3->setLabel("Hex byte (no slider)"); i3->setRange(0, 255, 1); i3->setSliderEnabled(false); @@ -62,7 +62,7 @@ conn(i3,int); b1->layout()->addWidget(i3); - i4 = new KIntNumInput(i3, 0xfe, b1, 16); + i4 = new KIntNumInput(0xfe, b1, 16); i4->setLabel("Hex byte (with slider)"); i4->setRange(0, 255, 1); i4->setSliderEnabled(true); @@ -70,7 +70,7 @@ b1->layout()->addWidget(i4); - i5 = new KIntNumInput(i4, 10, b1,10); + i5 = new KIntNumInput(10, b1,10); i5->setLabel("Width (keeps aspect ratio):"); i5->setRange(0, 200); i5->setSliderEnabled(false); @@ -78,7 +78,7 @@ b1->layout()->addWidget(i5); - i6 = new KIntNumInput(i5, 20, b1, 10); + i6 = new KIntNumInput(20, b1, 10); i6->setLabel("Height (should be 2xWidth value):"); i6->setRange(0, 200); i6->setReferencePoint( 10 ); @@ -90,13 +90,13 @@ connect( i6, SIGNAL(relativeValueChanged(double)), i5, SLOT(setRelativeValue(double)) ); - i7 = new KIntNumInput(i6, 0, b1, 10); + i7 = new KIntNumInput(0, b1, 10); i7->setLabel("math test:", Qt::AlignVCenter|Qt::AlignLeft ); i7->setRange( 0, 200, 1 ); conn(i7,int); b1->layout()->addWidget(i7); - i8 = new KIntNumInput(i7, 0, b1, 10); + i8 = new KIntNumInput(0, b1, 10); i8->setLabel("plural test:", Qt::AlignVCenter|Qt::AlignLeft); i8->setRange(0, 100, 1); i8->setSuffix( ki18np( " suffix", " suffixes" ) ); @@ -106,21 +106,21 @@ QGroupBox* b2 = new QGroupBox("KDoubleNumInput", this); b2->setLayout(new QVBoxLayout()); - d1 = new KDoubleNumInput(0,10,4.0,1,b2,2 /*, "perc_double_no_slider"*/); + d1 = new KDoubleNumInput(10,4.0,1,b2,2 /*, "perc_double_no_slider"*/); d1->setLabel("percent of usage (no slider)", Qt::AlignTop | Qt::AlignRight); d1->setRange(0.0, 4000.0, 0.01, false); //d1->setValue(1.00000000000000000001); conn(d1,double); b2->layout()->addWidget(d1); - d2 = new KDoubleNumInput(d1, 0,20,0.422,b2,0.1,3/*, "perc_double_with_slider"*/); + d2 = new KDoubleNumInput(0,20,0.422,b2,0.1,3/*, "perc_double_with_slider"*/); d2->setLabel("percentage of usage (with slider)", Qt::AlignBottom | Qt::AlignLeft); d2->setRange(0, 0.05, 0.005); d2->setSuffix("%"); conn(d2,double); b2->layout()->addWidget(d2); - d3 = new KDoubleNumInput(d2, 0,20,16.20,b2); + d3 = new KDoubleNumInput(0,20,16.20,b2); d3->setLabel("cash: ", Qt::AlignVCenter | Qt::AlignHCenter); d3->setRange(0.10, 100, 0.1); d3->setPrefix("p"); @@ -129,7 +129,7 @@ b2->layout()->addWidget(d3); - d4 = new KDoubleNumInput(d3, 0,INT_MAX,INT_MAX/10000.0,b2,1,1); + d4 = new KDoubleNumInput(0,INT_MAX,INT_MAX/10000.0,b2,1,1); // d4->setPrecision(3); d4->setRange(double(INT_MIN+1)/1000.0, double(INT_MAX)/1000.0, 1); d4->setLabel("math test: ", Qt::AlignVCenter | Qt::AlignLeft); @@ -138,20 +138,20 @@ b2->layout()->addWidget(d4); - d5 = new KDoubleNumInput(d4, double(INT_MIN+1)/1e9, double(INT_MAX-1)/1e9, + d5 = new KDoubleNumInput(double(INT_MIN+1)/1e9, double(INT_MAX-1)/1e9, 0.1, b2,0.001, 9 /*, "d5"*/); d5->setLabel("math test 2: ", Qt::AlignVCenter|Qt::AlignLeft); conn(d5,double); b2->layout()->addWidget(d5); - d6 = new KDoubleNumInput(d5, -10, 10, 0, b2,0.001, 3 /*, "d6"*/); + d6 = new KDoubleNumInput(-10, 10, 0, b2,0.001, 3 /*, "d6"*/); d6->setLabel("aspect ratio test with a negative ratio:"); d6->setReferencePoint( 1 ); b2->layout()->addWidget(d6); - d7 = new KDoubleNumInput(d6, -30, 30, 0, b2,0.001, 3 /*, "d7"*/); + d7 = new KDoubleNumInput(-30, 30, 0, b2,0.001, 3 /*, "d7"*/); d7->setReferencePoint( -3 ); b2->layout()->addWidget(d7); --- trunk/KDE/kdelibs/kdeui/tests/ktabwidget_unittest.cpp #1192845:1192846 @@ -161,7 +161,7 @@ void KTabWidget_UnitTest::testMiddleClickTabReordering() { MyTabWidget tabWidget; - tabWidget.setTabReorderingEnabled(true); + tabWidget.setMovable(true); QWidget* w0 = new QWidget; QWidget* w1 = new QWidget; --- trunk/KDE/kdelibs/kdeui/tests/ktabwidgettest.cpp #1192845:1192846 @@ -38,7 +38,7 @@ connect( mWidget, SIGNAL( receivedDropEvent( QWidget *, QDropEvent * )), SLOT(receivedDropEvent( QWidget *, QDropEvent * ))); connect( mWidget, SIGNAL( initiateDrag( QWidget * )), SLOT(initiateDrag( QWidget * ))); connect( mWidget, SIGNAL( movedTab( int, int )), SLOT(movedTab( int, int ))); - mWidget->setTabReorderingEnabled( true ); + mWidget->setMovable( true ); QWidget * grid = new QWidget(this); QGridLayout * gridlayout = new QGridLayout( grid ); @@ -263,7 +263,7 @@ void Test::toggleCloseButtons(bool state) { - mWidget->setHoverCloseButton( state ); + mWidget->setTabsClosable( state ); } void Test::contextMenu(QWidget *w, const QPoint &p) --- trunk/KDE/kdelibs/kdeui/tests/kwidgetitemdelegatetest.cpp #1192845:1192846 @@ -165,8 +165,6 @@ } painter->restore(); - - paintWidgets(painter, option, index); } QList createItemWidgets() const --- trunk/KDE/kdelibs/kdeui/tests/kxerrorhandlertest.cpp #1192845:1192846 @@ -58,11 +58,13 @@ { KXErrorHandler handle2( dpy ); XGetWindowAttributes(dpy, w, &attr); +#ifndef KDE_NO_DEPRECATED { KXErrorHandler handle3( handler3, dpy ); XSetInputFocus( dpy, w, RevertToParent, CurrentTime ); cout << "WAS3:" << handle3.error( /*false*/ true ) << endl; } +#endif cout << "WAS2:" << handle2.error( false ) << endl; } // XSync( dpy, False );