diff options
author | Liang Qi <liang.qi@qt.io> | 2017-06-28 14:08:52 +0200 |
---|---|---|
committer | Liang Qi <liang.qi@qt.io> | 2017-06-28 12:28:39 +0000 |
commit | 80406bd6200e741740e333baa2d2095e03f1327c (patch) | |
tree | 01a318828521408a1802369c8a94d036990bc0ff /tests/auto/corelib/kernel/qwineventnotifier/tst_qwineventnotifier.cpp | |
parent | 57a77fe775886b17fc267a4acb490890748d9ee0 (diff) |
Revert "Support more than 62 instances of QWinEventNotifier"
It breaks sth in QLocalSocket which is used in QtRemoteObject.
This reverts commit 5c6210e3452f78cab2f58887e747eb5cb2501f70.
Task-number: QTBUG-61668
Change-Id: Ib11890923773496e5d998b7709ef93b0a839a759
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Diffstat (limited to 'tests/auto/corelib/kernel/qwineventnotifier/tst_qwineventnotifier.cpp')
-rw-r--r-- | tests/auto/corelib/kernel/qwineventnotifier/tst_qwineventnotifier.cpp | 88 |
1 files changed, 0 insertions, 88 deletions
diff --git a/tests/auto/corelib/kernel/qwineventnotifier/tst_qwineventnotifier.cpp b/tests/auto/corelib/kernel/qwineventnotifier/tst_qwineventnotifier.cpp index 304f6121a5..3221587300 100644 --- a/tests/auto/corelib/kernel/qwineventnotifier/tst_qwineventnotifier.cpp +++ b/tests/auto/corelib/kernel/qwineventnotifier/tst_qwineventnotifier.cpp @@ -31,8 +31,6 @@ #include <qtimer.h> #include <qt_windows.h> -#include <memory> - class tst_QWinEventNotifier : public QObject { Q_OBJECT @@ -42,7 +40,6 @@ protected slots: void simple_timerSet(); private slots: void simple(); - void manyNotifiers(); private: HANDLE simpleHEvent; @@ -90,91 +87,6 @@ void tst_QWinEventNotifier::simple() QVERIFY(simpleActivated); } -class EventWithNotifier : public QObject -{ - Q_OBJECT -public: - EventWithNotifier() - { - connect(¬ifier, &QWinEventNotifier::activated, - this, &EventWithNotifier::onNotifierActivated); - notifier.setHandle(CreateEvent(0, TRUE, FALSE, 0)); - notifier.setEnabled(true); - - static int nextIndex = 0; - idx = nextIndex++; - } - - ~EventWithNotifier() - { - notifier.setEnabled(false); - CloseHandle(notifier.handle()); - } - - HANDLE eventHandle() const { return notifier.handle(); } - int numberOfTimesActivated() const { return activatedCount; } - -signals: - void activated(); - -public slots: - void onNotifierActivated() - { - ResetEvent(notifier.handle()); - activatedCount++; - emit activated(); - } - -private: - QWinEventNotifier notifier; - int activatedCount = 0; - int idx = 0; -}; - -void tst_QWinEventNotifier::manyNotifiers() -{ - const size_t maxEvents = 100; - const size_t middleEvenEvent = maxEvents / 2; - Q_ASSERT(middleEvenEvent % 2 == 0); - using EventWithNotifierPtr = std::unique_ptr<EventWithNotifier>; - std::vector<EventWithNotifierPtr> events(maxEvents); - std::generate(events.begin(), events.end(), [] () { - return EventWithNotifierPtr(new EventWithNotifier); - }); - - QTestEventLoop loop; - auto connection = connect(events.at(8).get(), &EventWithNotifier::activated, &loop, &QTestEventLoop::exitLoop); - for (const auto &ewn : events) { - connect(ewn.get(), &EventWithNotifier::activated, [&events, &loop] () { - if (std::all_of(events.cbegin(), events.cend(), - [] (const EventWithNotifierPtr &ewn) { - return ewn->numberOfTimesActivated() > 0; })) { - loop.exitLoop(); - } - }); - } - - // Activate all even events before running the event loop. - for (size_t i = 0; i < events.size(); i += 2) - SetEvent(events.at(i)->eventHandle()); - - // Wait until event notifier with index 8 has been activated. - loop.enterLoop(30); - QObject::disconnect(connection); - - // Activate all odd events after the event loop has run for a bit. - for (size_t i = 1; i < events.size(); i += 2) - SetEvent(events.at(i)->eventHandle()); - - // Wait until all event notifiers have fired. - loop.enterLoop(30); - - // All notifiers must have been activated exactly once. - QVERIFY(std::all_of(events.cbegin(), events.cend(), [] (const EventWithNotifierPtr &ewn) { - return ewn->numberOfTimesActivated() == 1; - })); -} - QTEST_MAIN(tst_QWinEventNotifier) #include "tst_qwineventnotifier.moc" |