summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2013-07-07 10:12:24 -0700
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-07-20 00:22:03 +0200
commit674e79416fefe7b5acf2a8c18d3c91d8feddcc18 (patch)
tree97d70c8e9be1249cffa6b36abd0bcfcbcfc69e73 /tests/auto
parent4a7e37b0a3741f11dad3cca435badaaf42e59741 (diff)
Fix incomplete override of QIODevice::open in QProcess and QLocalSocket
The rule for a new override is that it must still work if the old implementation is called. The catch is that any class that derives from QProcess and isn't recompiled will still have QIODevice::open in its virtual table. That is equivalent to overriding open() and calling QIODevice::open() (like the tests). In Qt 5.0, QProcess::start() called QIODevice::open directly, not the virtual open(), so there's no expectation that a user-overridden open() be called. With that in mind, simply fix QProcess::start to not call the virtual open at all. Similarly with QLocalSocket, the calls to open were always non-virtual. Task-number: QTBUG-32284 Change-Id: I88925f0ba08bc23c849658b54582744997e69a4c Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/corelib/io/qprocess/tst_qprocess.cpp20
-rw-r--r--tests/auto/network/socket/qlocalsocket/tst_qlocalsocket.cpp28
2 files changed, 48 insertions, 0 deletions
diff --git a/tests/auto/corelib/io/qprocess/tst_qprocess.cpp b/tests/auto/corelib/io/qprocess/tst_qprocess.cpp
index 3862553a4b..f2759dfd6e 100644
--- a/tests/auto/corelib/io/qprocess/tst_qprocess.cpp
+++ b/tests/auto/corelib/io/qprocess/tst_qprocess.cpp
@@ -82,6 +82,7 @@ private slots:
void constructing();
void simpleStart();
void startWithOpen();
+ void startWithOldOpen();
void execute();
void startDetached();
void crashTest();
@@ -297,6 +298,25 @@ void tst_QProcess::startWithOpen()
}
//-----------------------------------------------------------------------------
+void tst_QProcess::startWithOldOpen()
+{
+ // similar to the above, but we start with start() actually
+ // while open() is overridden to call QIODevice::open().
+ // This tests the BC requirement that "it works with the old implementation"
+ class OverriddenOpen : public QProcess
+ {
+ public:
+ virtual bool open(OpenMode mode) Q_DECL_OVERRIDE
+ { return QIODevice::open(mode); }
+ };
+
+ OverriddenOpen p;
+ p.start("testProcessNormal/testProcessNormal");
+ QVERIFY(p.waitForStarted(5000));
+ QVERIFY(p.waitForFinished(5000));
+}
+
+//-----------------------------------------------------------------------------
void tst_QProcess::execute()
{
QCOMPARE(QProcess::execute("testProcessNormal/testProcessNormal",
diff --git a/tests/auto/network/socket/qlocalsocket/tst_qlocalsocket.cpp b/tests/auto/network/socket/qlocalsocket/tst_qlocalsocket.cpp
index 70fb7dc9fe..7065f5be36 100644
--- a/tests/auto/network/socket/qlocalsocket/tst_qlocalsocket.cpp
+++ b/tests/auto/network/socket/qlocalsocket/tst_qlocalsocket.cpp
@@ -79,6 +79,7 @@ private slots:
void listenAndConnect();
void connectWithOpen();
+ void connectWithOldOpen();
void sendData_data();
void sendData();
@@ -475,6 +476,33 @@ void tst_QLocalSocket::connectWithOpen()
server.close();
}
+void tst_QLocalSocket::connectWithOldOpen()
+{
+ class OverriddenOpen : public LocalSocket
+ {
+ public:
+ virtual bool open(OpenMode mode) Q_DECL_OVERRIDE
+ { return QIODevice::open(mode); }
+ };
+
+ LocalServer server;
+ QCOMPARE(server.listen("tst_qlocalsocket"), true);
+
+ OverriddenOpen socket;
+ socket.connectToServer("tst_qlocalsocket");
+
+ bool timedOut = true;
+ QVERIFY(server.waitForNewConnection(3000, &timedOut));
+
+#if defined(QT_LOCALSOCKET_TCP)
+ QTest::qWait(250);
+#endif
+ QVERIFY(!timedOut);
+
+ socket.close();
+ server.close();
+}
+
void tst_QLocalSocket::sendData_data()
{
listenAndConnect_data();