mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-14 00:07:35 -04:00
Test of signals
This commit is contained in:
parent
08d28df9c2
commit
1b09393bd7
@ -32,6 +32,7 @@ QgsScaleComboBox::QgsScaleComboBox( QWidget* parent ) : QComboBox( parent )
|
||||
setCompleter( 0 );
|
||||
connect( this, SIGNAL( currentIndexChanged( const QString & ) ), this, SLOT( fixupScale() ) );
|
||||
connect( lineEdit(), SIGNAL( editingFinished() ), this, SLOT( fixupScale() ) );
|
||||
fixupScale();
|
||||
}
|
||||
|
||||
QgsScaleComboBox::~QgsScaleComboBox()
|
||||
@ -124,8 +125,14 @@ void QgsScaleComboBox::fixupScale()
|
||||
{
|
||||
mScale = newScale;
|
||||
}
|
||||
// We set to the new string representation.
|
||||
// We set to the new string representation
|
||||
// or reset to the old
|
||||
setEditText( toString( mScale ) );
|
||||
|
||||
if ( ok )
|
||||
{
|
||||
emit scaleChanged();
|
||||
}
|
||||
}
|
||||
|
||||
QString QgsScaleComboBox::toString( double scale )
|
||||
|
@ -16,10 +16,12 @@
|
||||
***************************************************************************/
|
||||
|
||||
#include "qgsapplication.h"
|
||||
#include "qgslogger.h"
|
||||
#include "qgsscalecombobox.h"
|
||||
#include <QObject>
|
||||
#include <QLineEdit>
|
||||
#include <QComboBox>
|
||||
#include <QSignalSpy>
|
||||
#include <QtTest>
|
||||
|
||||
class TestQgsScaleComboBox: public QObject
|
||||
@ -43,6 +45,7 @@ void TestQgsScaleComboBox::initTestCase()
|
||||
|
||||
// Create a combobox, and init with predefined scales.
|
||||
s = new QgsScaleComboBox();
|
||||
QgsDebugMsg( QString( "Initial scale is %1" ).arg( s->scaleString() ) );
|
||||
};
|
||||
|
||||
void TestQgsScaleComboBox::cleanupTestCase()
|
||||
@ -90,7 +93,18 @@ void TestQgsScaleComboBox::basic()
|
||||
|
||||
void TestQgsScaleComboBox::slot_test()
|
||||
{
|
||||
QLineEdit *l = s->lineEdit();
|
||||
l->setText( "" );
|
||||
|
||||
QSignalSpy spyScaleChanged( s, SIGNAL( scaleChanged() ) );
|
||||
QSignalSpy spyFixup( l, SIGNAL( editingFinished() ) );
|
||||
|
||||
QTest::keyClicks( l, QLocale::system().toString( 0.02 ) );
|
||||
QTest::keyClick( l, Qt::Key_Return );
|
||||
QCOMPARE( spyFixup.count(), 2 ); // Qt emits twice!?
|
||||
QCOMPARE( spyScaleChanged.count(), 2 ); // Qt emits twice!?
|
||||
}
|
||||
|
||||
void TestQgsScaleComboBox::cleanup()
|
||||
{
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user