Remove Q_ASSERT from QCompleter autotest
authorJason McDonald <jason.mcdonald@nokia.com>
Wed, 20 Apr 2011 02:16:58 +0000 (12:16 +1000)
committerRohan McGovern <rohan.mcgovern@nokia.com>
Wed, 18 May 2011 00:46:41 +0000 (10:46 +1000)
If a combobox had no completer, this test would assert in a debug build
and crash in a release build.  This commit makes the test report a test
failure and avoid terminating in all builds.

Change-Id: Ib2924412e3d55f10875675cb65079259cd4ef552
Task-number: QTBUG-17582
Reviewed-by: Rohan McGovern
(cherry picked from commit a5bd4abed834ce3670b2f28d4f932d612a033b36)

tests/auto/qcompleter/tst_qcompleter.cpp

index 1bb21eb..1a052d5 100644 (file)
@@ -1280,10 +1280,11 @@ public:
     {
         setEditable(true);
         setInsertPolicy(NoInsert);
-        Q_ASSERT(completer());
-        completer()->setCompletionMode(QCompleter::PopupCompletion);
-        completer()->setCompletionRole(Qt::DisplayRole);
-        connect(lineEdit(), SIGNAL(editingFinished()), SLOT(setCompletionPrefix()));
+        if (completer()) {
+            completer()->setCompletionMode(QCompleter::PopupCompletion);
+            completer()->setCompletionRole(Qt::DisplayRole);
+            connect(lineEdit(), SIGNAL(editingFinished()), SLOT(setCompletionPrefix()));
+        }
     }
 private slots:
     void setCompletionPrefix() { completer()->setCompletionPrefix(lineEdit()->text()); }
@@ -1292,6 +1293,7 @@ private slots:
 void tst_QCompleter::task246056_setCompletionPrefix()
 {
     task246056_ComboBox *comboBox = new task246056_ComboBox;
+    QVERIFY(comboBox->completer());
     comboBox->addItem("");
     comboBox->addItem("a1");
     comboBox->addItem("a2");