From 80406bd6200e741740e333baa2d2095e03f1327c Mon Sep 17 00:00:00 2001 From: Liang Qi Date: Wed, 28 Jun 2017 14:08:52 +0200 Subject: 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 --- .../qwineventnotifier/tst_qwineventnotifier.cpp | 88 ---------------------- 1 file changed, 88 deletions(-) (limited to 'tests/auto/corelib/kernel/qwineventnotifier/tst_qwineventnotifier.cpp') 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 #include -#include - 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; - std::vector 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" -- cgit v1.2.3