diff options
| author | Méven Car <[email protected]> | 2026-06-18 10:41:57 +0000 |
|---|---|---|
| committer | Méven Car <[email protected]> | 2026-06-18 12:13:24 +0000 |
| commit | 2a3c40dc15d49272a750959fb9a67fecba10a453 (patch) | |
| tree | 26c019d3f218013f3ed5af22eb6b1fafb59dd637 /src/tests/kfileitemmodeltest.cpp | |
| parent | b55e45f88e8ae63115f290fc2db847cb4b370c88 (diff) | |
tests: speed up testInsertAfterExpand
The test created a file in a collapsed subtree and then waited five
seconds for an items-inserted signal that must never arrive, spending
that whole time on every run and making kfileitemmodeltest about three
times slower than it needs to be.
Create a file in the watched top directory instead and wait for its
insertion. Once that arrives the directory change has been processed and
the model has settled, so the collapsed file has had its chance to appear
and only the expected items are present. The sentinel stays as a
top-level sibling, so the later re-expansion expects it alongside the
restored subtree.
testInsertAfterExpand drops from about 4.9 seconds to 1.6 seconds and the
whole kfileitemmodeltest from about 7.2 seconds to 2.4 seconds.
Diffstat (limited to 'src/tests/kfileitemmodeltest.cpp')
| -rw-r--r-- | src/tests/kfileitemmodeltest.cpp | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/src/tests/kfileitemmodeltest.cpp b/src/tests/kfileitemmodeltest.cpp index 6583b80f4..95b2f3d09 100644 --- a/src/tests/kfileitemmodeltest.cpp +++ b/src/tests/kfileitemmodeltest.cpp @@ -2716,16 +2716,19 @@ void KFileItemModelTest::testInsertAfterExpand() // Collapse "a" whilst leaving "b" expanded m_model->setExpanded(0, false); - // Insert additional files into "a/b/" + // "a/b/2" is inside the now collapsed subtree, so it must stay out of the model. m_testDir->createFile("a/b/2"); - QVERIFY(!itemsInsertedSpy.wait(5000)); - - QCOMPARE(itemsInModel(), {"a"}); + // Create a file in the watched top directory and wait for its insertion. Its arrival + // means the directory change has been processed and the model has settled, so "a/b/2" + // has had its chance to appear: only "a" and the new top-level "c" are present. + m_testDir->createFile("c"); + QTRY_COMPARE(itemsInModel(), QStringList({"a", "c"})); + // Re-expanding "a" brings back "a/b" and its children, including "a/b/2" which is now + // read from disk. "c" stays at the end as a top-level sibling. m_model->setExpanded(0, true); - ; - QTRY_COMPARE(itemsInModel(), QStringList({"a", "b", "1", "2"})); + QTRY_COMPARE(itemsInModel(), QStringList({"a", "b", "1", "2", "c"})); QCOMPARE(m_model->expandedParentsCount(0), 0); // a QCOMPARE(m_model->expandedParentsCount(1), 1); // a/b |
