|
| 1 | +/*************************************************************************** |
| 2 | + testqgssqlcomposerdialog.cpp |
| 3 | + -------------------------------------- |
| 4 | + Date : April 2016 |
| 5 | + Copyright : (C) 2016 Even Rouault |
| 6 | + Email : even.rouault at spatialys.com |
| 7 | + *************************************************************************** |
| 8 | + * * |
| 9 | + * This program is free software; you can redistribute it and/or modify * |
| 10 | + * it under the terms of the GNU General Public License as published by * |
| 11 | + * the Free Software Foundation; either version 2 of the License, or * |
| 12 | + * (at your option) any later version. * |
| 13 | + * * |
| 14 | + ***************************************************************************/ |
| 15 | + |
| 16 | + |
| 17 | +#include <QtTest/QtTest> |
| 18 | + |
| 19 | +#include <qgslogger.h> |
| 20 | +#include <qgssqlcomposerdialog.h> |
| 21 | + |
| 22 | +class TestQgsSQLComposerDialog: public QObject |
| 23 | +{ |
| 24 | + Q_OBJECT |
| 25 | + private slots: |
| 26 | + void testReciprocalEditorsUpdate(); |
| 27 | + void testSelectTable(); |
| 28 | + void testSelectColumn(); |
| 29 | + void testSelectFunction(); |
| 30 | + void testSelectSpatialPredicate(); |
| 31 | + void testSelectOperator(); |
| 32 | + void testJoins(); |
| 33 | + private: |
| 34 | + bool runTest(); |
| 35 | +}; |
| 36 | + |
| 37 | +bool TestQgsSQLComposerDialog::runTest() |
| 38 | +{ |
| 39 | + // Those tests are fragile because may depend on focus works without |
| 40 | + // widget being displayed. Or shortcuts to go to end of line |
| 41 | + //const char* travis = getenv( "TRAVIS_OS_NAME" ); |
| 42 | + //if ( travis && strcmp( travis, "osx" ) == 0 ) |
| 43 | + //{ |
| 44 | + // QgsDebugMsg( "Test disabled" ); |
| 45 | + // return false; |
| 46 | + //} |
| 47 | + return true; |
| 48 | +} |
| 49 | + |
| 50 | +static QWidget* getQueryEdit( QgsSQLComposerDialog& d ) |
| 51 | +{ |
| 52 | + QWidget* widget = d.findChild<QWidget*>( "mQueryEdit" ); |
| 53 | + Q_ASSERT( widget ); |
| 54 | + return widget; |
| 55 | +} |
| 56 | + |
| 57 | +static QWidget* getColumnsEditor( QgsSQLComposerDialog& d ) |
| 58 | +{ |
| 59 | + QWidget* widget = d.findChild<QWidget*>( "mColumnsEditor" ); |
| 60 | + Q_ASSERT( widget ); |
| 61 | + return widget; |
| 62 | +} |
| 63 | + |
| 64 | +static QWidget* getTablesEditor( QgsSQLComposerDialog& d ) |
| 65 | +{ |
| 66 | + QWidget* widget = d.findChild<QWidget*>( "mTablesEditor" ); |
| 67 | + Q_ASSERT( widget ); |
| 68 | + return widget; |
| 69 | +} |
| 70 | + |
| 71 | +static QWidget* getWhereEditor( QgsSQLComposerDialog& d ) |
| 72 | +{ |
| 73 | + QWidget* widget = d.findChild<QWidget*>( "mWhereEditor" ); |
| 74 | + Q_ASSERT( widget ); |
| 75 | + return widget; |
| 76 | +} |
| 77 | + |
| 78 | +static QWidget* getOrderEditor( QgsSQLComposerDialog& d ) |
| 79 | +{ |
| 80 | + QWidget* widget = d.findChild<QWidget*>( "mOrderEditor" ); |
| 81 | + Q_ASSERT( widget ); |
| 82 | + return widget; |
| 83 | +} |
| 84 | + |
| 85 | +static QComboBox* getTablesCombo( QgsSQLComposerDialog& d ) |
| 86 | +{ |
| 87 | + QComboBox* widget = d.findChild<QComboBox*>( "mTablesCombo" ); |
| 88 | + Q_ASSERT( widget ); |
| 89 | + return widget; |
| 90 | +} |
| 91 | + |
| 92 | +static QComboBox* getColumnsCombo( QgsSQLComposerDialog& d ) |
| 93 | +{ |
| 94 | + QComboBox* widget = d.findChild<QComboBox*>( "mColumnsCombo" ); |
| 95 | + Q_ASSERT( widget ); |
| 96 | + return widget; |
| 97 | +} |
| 98 | + |
| 99 | +static QComboBox* getFunctionsCombo( QgsSQLComposerDialog& d ) |
| 100 | +{ |
| 101 | + QComboBox* widget = d.findChild<QComboBox*>( "mFunctionsCombo" ); |
| 102 | + Q_ASSERT( widget ); |
| 103 | + return widget; |
| 104 | +} |
| 105 | + |
| 106 | +static QComboBox* getSpatialPredicatesCombo( QgsSQLComposerDialog& d ) |
| 107 | +{ |
| 108 | + QComboBox* widget = d.findChild<QComboBox*>( "mSpatialPredicatesCombo" ); |
| 109 | + Q_ASSERT( widget ); |
| 110 | + return widget; |
| 111 | +} |
| 112 | + |
| 113 | +static QComboBox* getOperatorsCombo( QgsSQLComposerDialog& d ) |
| 114 | +{ |
| 115 | + QComboBox* widget = d.findChild<QComboBox*>( "mOperatorsCombo" ); |
| 116 | + Q_ASSERT( widget ); |
| 117 | + return widget; |
| 118 | +} |
| 119 | + |
| 120 | +static QWidget* getResetButton( QgsSQLComposerDialog& d ) |
| 121 | +{ |
| 122 | + QDialogButtonBox* mButtonBox = d.findChild<QDialogButtonBox*>( "mButtonBox" ); |
| 123 | + Q_ASSERT( mButtonBox ); |
| 124 | + QPushButton* button = mButtonBox->button( QDialogButtonBox::Reset ); |
| 125 | + Q_ASSERT( button ); |
| 126 | + return button; |
| 127 | +} |
| 128 | + |
| 129 | +static QTableWidget* getTableJoins( QgsSQLComposerDialog& d ) |
| 130 | +{ |
| 131 | + QTableWidget* widget = d.findChild<QTableWidget*>( "mTableJoins" ); |
| 132 | + Q_ASSERT( widget ); |
| 133 | + return widget; |
| 134 | +} |
| 135 | + |
| 136 | +static QWidget* getAddJoinButton( QgsSQLComposerDialog& d ) |
| 137 | +{ |
| 138 | + QWidget* widget = d.findChild<QWidget*>( "mAddJoinButton" ); |
| 139 | + Q_ASSERT( widget ); |
| 140 | + return widget; |
| 141 | +} |
| 142 | + |
| 143 | +static QWidget* getRemoveJoinButton( QgsSQLComposerDialog& d ) |
| 144 | +{ |
| 145 | + QWidget* widget = d.findChild<QWidget*>( "mRemoveJoinButton" ); |
| 146 | + Q_ASSERT( widget ); |
| 147 | + return widget; |
| 148 | +} |
| 149 | + |
| 150 | +static void gotoEndOfLine( QWidget* w ) |
| 151 | +{ |
| 152 | +#ifdef Q_OS_MAC |
| 153 | + QTest::keyPress( w, Qt::Key_Right, Qt::ControlModifier ); |
| 154 | +#else |
| 155 | + QTest::keyPress( w, Qt::Key_End ); |
| 156 | +#endif |
| 157 | +} |
| 158 | + |
| 159 | +void TestQgsSQLComposerDialog::testReciprocalEditorsUpdate() |
| 160 | +{ |
| 161 | + if ( !runTest() ) |
| 162 | + return; |
| 163 | + QgsSQLComposerDialog d; |
| 164 | + QString oriSql( "SELECT a_column FROM my_table JOIN join_table ON cond WHERE where_expr ORDER BY column DESC" ); |
| 165 | + d.setSql( oriSql ); |
| 166 | + QCOMPARE( d.sql(), oriSql ); |
| 167 | + |
| 168 | + gotoEndOfLine( getColumnsEditor( d ) ); |
| 169 | + QTest::keyClicks( getColumnsEditor( d ), ", another_column" ); |
| 170 | + gotoEndOfLine( getTablesEditor( d ) ); |
| 171 | + QTest::keyClicks( getTablesEditor( d ), ", another_from_table" ); |
| 172 | + gotoEndOfLine( getWhereEditor( d ) ); |
| 173 | + QTest::keyClicks( getWhereEditor( d ), " AND another_cond" ); |
| 174 | + gotoEndOfLine( getOrderEditor( d ) ); |
| 175 | + QTest::keyClicks( getOrderEditor( d ), ", another_column_asc" ); |
| 176 | + QCOMPARE( d.sql(), QString( "SELECT a_column, another_column FROM my_table, another_from_table JOIN join_table ON cond WHERE where_expr AND another_cond ORDER BY column DESC, another_column_asc" ) ); |
| 177 | + |
| 178 | + QTest::mouseClick( getResetButton( d ), Qt::LeftButton ); |
| 179 | + QCOMPARE( d.sql(), oriSql ); |
| 180 | +} |
| 181 | + |
| 182 | +static void setFocusIn( QWidget* widget ) |
| 183 | +{ |
| 184 | + QFocusEvent focusInEvent( QEvent::FocusIn ); |
| 185 | + QApplication::sendEvent( widget, &focusInEvent ); |
| 186 | +} |
| 187 | + |
| 188 | +void TestQgsSQLComposerDialog::testSelectTable() |
| 189 | +{ |
| 190 | + if ( !runTest() ) |
| 191 | + return; |
| 192 | + QgsSQLComposerDialog d; |
| 193 | + d.addTableNames( QStringList() << "my_table" ); |
| 194 | + d.addTableNames( QList<QgsSQLComposerDialog::PairNameTitle>() << QgsSQLComposerDialog::PairNameTitle( "another_table", "title" ) ); |
| 195 | + |
| 196 | + QCOMPARE( getTablesCombo( d )->itemText( 1 ), QString( "my_table" ) ); |
| 197 | + QCOMPARE( getTablesCombo( d )->itemText( 2 ), QString( "another_table (title)" ) ); |
| 198 | + |
| 199 | + d.setSql( "SELECT * FROM " ); |
| 200 | + gotoEndOfLine( getQueryEdit( d ) ); |
| 201 | + |
| 202 | + // Set focus in SQL zone |
| 203 | + setFocusIn( getQueryEdit( d ) ); |
| 204 | + |
| 205 | + // Select dummy entry in combo |
| 206 | + getTablesCombo( d )->setCurrentIndex( 0 ); |
| 207 | + |
| 208 | + // Select first entry in combo |
| 209 | + getTablesCombo( d )->setCurrentIndex( 1 ); |
| 210 | + |
| 211 | + QCOMPARE( d.sql(), QString( "SELECT * FROM my_table" ) ); |
| 212 | + |
| 213 | + // Set focus in table editor |
| 214 | + setFocusIn( getTablesEditor( d ) ); |
| 215 | + |
| 216 | + // Select second entry in combo |
| 217 | + getTablesCombo( d )->setCurrentIndex( 2 ); |
| 218 | + |
| 219 | + QCOMPARE( d.sql(), QString( "SELECT * FROM my_table, another_table" ) ); |
| 220 | +} |
| 221 | + |
| 222 | +void TestQgsSQLComposerDialog::testSelectColumn() |
| 223 | +{ |
| 224 | + if ( !runTest() ) |
| 225 | + return; |
| 226 | + QgsSQLComposerDialog d; |
| 227 | + d.addColumnNames( QList<QgsSQLComposerDialog::PairNameType>() << |
| 228 | + QgsSQLComposerDialog::PairNameType( "a", "" ) << |
| 229 | + QgsSQLComposerDialog::PairNameType( "b", "type" ), "my_table" ); |
| 230 | + |
| 231 | + QCOMPARE( getColumnsCombo( d )->itemText( 1 ), QString( "a" ) ); |
| 232 | + QCOMPARE( getColumnsCombo( d )->itemText( 2 ), QString( "b (type)" ) ); |
| 233 | + |
| 234 | + d.setSql( "SELECT " ); |
| 235 | + gotoEndOfLine( getQueryEdit( d ) ); |
| 236 | + |
| 237 | + // Set focus in SQL zone |
| 238 | + setFocusIn( getQueryEdit( d ) ); |
| 239 | + |
| 240 | + // Select dummy entry in combo |
| 241 | + getColumnsCombo( d )->setCurrentIndex( 0 ); |
| 242 | + |
| 243 | + // Select first entry in combo |
| 244 | + getColumnsCombo( d )->setCurrentIndex( 1 ); |
| 245 | + |
| 246 | + QCOMPARE( d.sql(), QString( "SELECT a" ) ); |
| 247 | + |
| 248 | + gotoEndOfLine( getQueryEdit( d ) ); |
| 249 | + QTest::keyClicks( getQueryEdit( d ), " FROM my_table" ); |
| 250 | + |
| 251 | + QCOMPARE( d.sql(), QString( "SELECT a FROM my_table" ) ); |
| 252 | + |
| 253 | + // Set focus in column editor |
| 254 | + setFocusIn( getColumnsEditor( d ) ); |
| 255 | + QTest::keyPress( getColumnsEditor( d ), Qt::Key_End ); |
| 256 | + |
| 257 | + // Select second entry in combo |
| 258 | + getColumnsCombo( d )->setCurrentIndex( 2 ); |
| 259 | + |
| 260 | + QCOMPARE( d.sql(), QString( "SELECT a,\nb FROM my_table" ) ); |
| 261 | + |
| 262 | + // Set focus in where editor |
| 263 | + setFocusIn( getWhereEditor( d ) ); |
| 264 | + getColumnsCombo( d )->setCurrentIndex( 1 ); |
| 265 | + |
| 266 | + QCOMPARE( d.sql(), QString( "SELECT a,\nb FROM my_table WHERE a" ) ); |
| 267 | + |
| 268 | + // Set focus in order editor |
| 269 | + setFocusIn( getOrderEditor( d ) ); |
| 270 | + getColumnsCombo( d )->setCurrentIndex( 2 ); |
| 271 | + |
| 272 | + QCOMPARE( d.sql(), QString( "SELECT a,\nb FROM my_table WHERE a ORDER BY b" ) ); |
| 273 | +} |
| 274 | + |
| 275 | +void TestQgsSQLComposerDialog::testSelectFunction() |
| 276 | +{ |
| 277 | + if ( !runTest() ) |
| 278 | + return; |
| 279 | + QgsSQLComposerDialog d; |
| 280 | + |
| 281 | + QList<QgsSQLComposerDialog::Function> functions; |
| 282 | + { |
| 283 | + QgsSQLComposerDialog::Function f; |
| 284 | + f.name = "first_func"; |
| 285 | + functions << f; |
| 286 | + } |
| 287 | + { |
| 288 | + QgsSQLComposerDialog::Function f; |
| 289 | + f.name = "second_func"; |
| 290 | + f.returnType = "xs:int"; |
| 291 | + functions << f; |
| 292 | + } |
| 293 | + { |
| 294 | + QgsSQLComposerDialog::Function f; |
| 295 | + f.name = "third_func"; |
| 296 | + f.minArgs = 1; |
| 297 | + f.maxArgs = 1; |
| 298 | + functions << f; |
| 299 | + } |
| 300 | + { |
| 301 | + QgsSQLComposerDialog::Function f; |
| 302 | + f.name = "fourth_func"; |
| 303 | + f.minArgs = 1; |
| 304 | + f.maxArgs = 2; |
| 305 | + functions << f; |
| 306 | + } |
| 307 | + { |
| 308 | + QgsSQLComposerDialog::Function f; |
| 309 | + f.name = "fifth_func"; |
| 310 | + f.minArgs = 1; |
| 311 | + functions << f; |
| 312 | + } |
| 313 | + { |
| 314 | + QgsSQLComposerDialog::Function f; |
| 315 | + f.name = "sixth_func"; |
| 316 | + f.argumentList << QgsSQLComposerDialog::Argument( "arg1", "" ); |
| 317 | + f.argumentList << QgsSQLComposerDialog::Argument( "arg2", "xs:double" ); |
| 318 | + f.argumentList << QgsSQLComposerDialog::Argument( "arg3", "gml:AbstractGeometryType" ); |
| 319 | + f.argumentList << QgsSQLComposerDialog::Argument( "number", "xs:int" ); |
| 320 | + functions << f; |
| 321 | + } |
| 322 | + { |
| 323 | + QgsSQLComposerDialog::Function f; |
| 324 | + f.name = "seventh_func"; |
| 325 | + f.argumentList << QgsSQLComposerDialog::Argument( "arg1", "" ); |
| 326 | + f.argumentList << QgsSQLComposerDialog::Argument( "arg2", "xs:double" ); |
| 327 | + f.minArgs = 1; |
| 328 | + functions << f; |
| 329 | + } |
| 330 | + d.addFunctions( functions ); |
| 331 | + |
| 332 | + QCOMPARE( getFunctionsCombo( d )->itemText( 1 ), QString( "first_func()" ) ); |
| 333 | + QCOMPARE( getFunctionsCombo( d )->itemText( 2 ), QString( "second_func(): int" ) ); |
| 334 | + QCOMPARE( getFunctionsCombo( d )->itemText( 3 ), QString( "third_func(1 argument)" ) ); |
| 335 | + QCOMPARE( getFunctionsCombo( d )->itemText( 4 ), QString( "fourth_func(1 to 2 arguments)" ) ); |
| 336 | + QCOMPARE( getFunctionsCombo( d )->itemText( 5 ), QString( "fifth_func(1 argument or more)" ) ); |
| 337 | + QCOMPARE( getFunctionsCombo( d )->itemText( 6 ), QString( "sixth_func(arg1, arg2: double, arg3: geometry, int)" ) ); |
| 338 | + QCOMPARE( getFunctionsCombo( d )->itemText( 7 ), QString( "seventh_func(arg1[, arg2: double])" ) ); |
| 339 | + |
| 340 | + d.setSql( "SELECT * FROM my_table" ); |
| 341 | + |
| 342 | + // Set focus in where editor |
| 343 | + setFocusIn( getWhereEditor( d ) ); |
| 344 | + |
| 345 | + getFunctionsCombo( d )->setCurrentIndex( 0 ); |
| 346 | + getFunctionsCombo( d )->setCurrentIndex( 1 ); |
| 347 | + |
| 348 | + QCOMPARE( d.sql(), QString( "SELECT * FROM my_table WHERE first_func(" ) ); |
| 349 | + |
| 350 | + // Set focus in SQL zone |
| 351 | + d.setSql( "SELECT * FROM my_table WHERE " ); |
| 352 | + setFocusIn( getQueryEdit( d ) ); |
| 353 | + gotoEndOfLine( getQueryEdit( d ) ); |
| 354 | + getFunctionsCombo( d )->setCurrentIndex( 0 ); |
| 355 | + getFunctionsCombo( d )->setCurrentIndex( 1 ); |
| 356 | + |
| 357 | + QCOMPARE( d.sql(), QString( "SELECT * FROM my_table WHERE first_func(" ) ); |
| 358 | +} |
| 359 | + |
| 360 | +void TestQgsSQLComposerDialog::testSelectSpatialPredicate() |
| 361 | +{ |
| 362 | + if ( !runTest() ) |
| 363 | + return; |
| 364 | + QgsSQLComposerDialog d; |
| 365 | + d.addSpatialPredicates( QList<QgsSQLComposerDialog::Function>() << QgsSQLComposerDialog::Function( "predicate", 2 ) ); |
| 366 | + |
| 367 | + d.setSql( "SELECT * FROM my_table" ); |
| 368 | + |
| 369 | + // Set focus in where editor |
| 370 | + setFocusIn( getWhereEditor( d ) ); |
| 371 | + getSpatialPredicatesCombo( d )->setCurrentIndex( 0 ); |
| 372 | + getSpatialPredicatesCombo( d )->setCurrentIndex( 1 ); |
| 373 | + |
| 374 | + QCOMPARE( d.sql(), QString( "SELECT * FROM my_table WHERE predicate(" ) ); |
| 375 | + |
| 376 | + // Set focus in SQL zone |
| 377 | + d.setSql( "SELECT * FROM my_table WHERE " ); |
| 378 | + setFocusIn( getQueryEdit( d ) ); |
| 379 | + gotoEndOfLine( getQueryEdit( d ) ); |
| 380 | + getSpatialPredicatesCombo( d )->setCurrentIndex( 0 ); |
| 381 | + getSpatialPredicatesCombo( d )->setCurrentIndex( 1 ); |
| 382 | + |
| 383 | + QCOMPARE( d.sql(), QString( "SELECT * FROM my_table WHERE predicate(" ) ); |
| 384 | +} |
| 385 | + |
| 386 | +void TestQgsSQLComposerDialog::testSelectOperator() |
| 387 | +{ |
| 388 | + if ( !runTest() ) |
| 389 | + return; |
| 390 | + QgsSQLComposerDialog d; |
| 391 | + |
| 392 | + d.setSql( "SELECT * FROM my_table" ); |
| 393 | + |
| 394 | + // Set focus in where editor |
| 395 | + setFocusIn( getWhereEditor( d ) ); |
| 396 | + getOperatorsCombo( d )->setCurrentIndex( 0 ); |
| 397 | + getOperatorsCombo( d )->setCurrentIndex( 1 ); |
| 398 | + |
| 399 | + QCOMPARE( d.sql(), QString( "SELECT * FROM my_table WHERE AND" ) ); |
| 400 | + |
| 401 | + // Set focus in SQL zone |
| 402 | + d.setSql( "SELECT * FROM my_table WHERE " ); |
| 403 | + setFocusIn( getQueryEdit( d ) ); |
| 404 | + gotoEndOfLine( getQueryEdit( d ) ); |
| 405 | + getOperatorsCombo( d )->setCurrentIndex( 0 ); |
| 406 | + getOperatorsCombo( d )->setCurrentIndex( 1 ); |
| 407 | + |
| 408 | + QCOMPARE( d.sql(), QString( "SELECT * FROM my_table WHERE AND" ) ); |
| 409 | +} |
| 410 | + |
| 411 | +void TestQgsSQLComposerDialog::testJoins() |
| 412 | +{ |
| 413 | + if ( !runTest() ) |
| 414 | + return; |
| 415 | + QgsSQLComposerDialog d; |
| 416 | + d.setSql( "SELECT * FROM my_table" ); |
| 417 | + d.setSupportMultipleTables( true ); |
| 418 | + |
| 419 | + QTableWidget* table = getTableJoins( d ); |
| 420 | + QCOMPARE( table->rowCount(), 1 ); |
| 421 | + QCOMPARE( table->item( 0, 0 ) != nullptr, true ); |
| 422 | + table->item( 0, 0 )->setText( "join_table" ); |
| 423 | + table->item( 0, 1 )->setText( "join_expr" ); |
| 424 | + |
| 425 | + QCOMPARE( d.sql(), QString( "SELECT * FROM my_table JOIN join_table ON join_expr" ) ); |
| 426 | + |
| 427 | + QTest::mouseClick( getAddJoinButton( d ), Qt::LeftButton ); |
| 428 | + QCOMPARE( table->rowCount(), 2 ); |
| 429 | + table->item( 1, 0 )->setText( "join2_table" ); |
| 430 | + table->item( 1, 1 )->setText( "join2_expr" ); |
| 431 | + |
| 432 | + QCOMPARE( d.sql(), QString( "SELECT * FROM my_table JOIN join_table ON join_expr JOIN join2_table ON join2_expr" ) ); |
| 433 | + |
| 434 | + table->setCurrentCell( 0, 0 ); |
| 435 | + QTest::mouseClick( getAddJoinButton( d ), Qt::LeftButton ); |
| 436 | + QCOMPARE( table->rowCount(), 3 ); |
| 437 | + table->item( 1, 0 )->setText( "join15_table" ); |
| 438 | + table->item( 1, 1 )->setText( "join15_expr" ); |
| 439 | + |
| 440 | + QCOMPARE( d.sql(), QString( "SELECT * FROM my_table JOIN join_table ON join_expr JOIN join15_table ON join15_expr JOIN join2_table ON join2_expr" ) ); |
| 441 | + |
| 442 | + table->setCurrentCell( 1, 0 ); |
| 443 | + QTest::mouseClick( getRemoveJoinButton( d ), Qt::LeftButton ); |
| 444 | + QCOMPARE( table->rowCount(), 2 ); |
| 445 | + |
| 446 | + QCOMPARE( d.sql(), QString( "SELECT * FROM my_table JOIN join_table ON join_expr JOIN join2_table ON join2_expr" ) ); |
| 447 | + |
| 448 | + QTest::mouseClick( getRemoveJoinButton( d ), Qt::LeftButton ); |
| 449 | + QCOMPARE( table->rowCount(), 1 ); |
| 450 | + |
| 451 | + QCOMPARE( d.sql(), QString( "SELECT * FROM my_table JOIN join_table ON join_expr" ) ); |
| 452 | + |
| 453 | + QTest::mouseClick( getRemoveJoinButton( d ), Qt::LeftButton ); |
| 454 | + QCOMPARE( table->rowCount(), 1 ); |
| 455 | + |
| 456 | + table->setCurrentCell( 0, 0 ); |
| 457 | + QTest::mouseClick( getRemoveJoinButton( d ), Qt::LeftButton ); |
| 458 | + QCOMPARE( table->rowCount(), 0 ); |
| 459 | + |
| 460 | + QCOMPARE( d.sql(), QString( "SELECT * FROM my_table" ) ); |
| 461 | + |
| 462 | + QTest::mouseClick( getAddJoinButton( d ), Qt::LeftButton ); |
| 463 | + QCOMPARE( table->rowCount(), 1 ); |
| 464 | + QCOMPARE( table->item( 0, 0 ) != nullptr, true ); |
| 465 | +} |
| 466 | + |
| 467 | +QTEST_MAIN( TestQgsSQLComposerDialog ) |
| 468 | +#include "testqgssqlcomposerdialog.moc" |
0 commit comments