on xenial help sign in
use sendEvents
4e39418Nick Dedekind
tests/plugins/Unity/Indicators/UnityMenuModelStackTest.cpp+2−11
@@ -43,8 +43,8 @@ private Q_SLOTS:
43 {
43 {
44 delete m_model;
44 delete m_model;
45 m_model = nullptr;
45 m_model = nullptr;
46− // quick wait cycle for deleteLaters to act.
46+ // send deleteLaters to avoid leaks.
47− waitFor([]{ return false;}, 1);
47+ QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
48 }
48 }
49
49
50 void testHeadOnSetHead()
50 void testHeadOnSetHead()
@@ -148,19 +148,10 @@ private Q_SLOTS:
148
148
149 m_model->removeRow(removeIndex);
149 m_model->removeRow(removeIndex);
150
150
151− waitFor([&stack, resultCount]() { return stack.count() == resultCount; }, 1000);
152 QCOMPARE(stack.count(), resultCount);
151 QCOMPARE(stack.count(), resultCount);
153 }
152 }
154
153
155private:
154private:
156− bool waitFor(std::function<bool()> functor, int ms) {
157−
158− QElapsedTimer timer;
159− timer.start();
160− while(!functor() && timer.elapsed() < ms) { QTest::qWait(10); }
161− return functor();
162− }
163−
164 QVariant recuseAddMenu(int subMenuCount, int depth_remaining)
155 QVariant recuseAddMenu(int subMenuCount, int depth_remaining)
165 {
156 {
166 QVariantList rows;
157 QVariantList rows;