Merge lp:~carlos-mazieri/ubuntu-filemanager-app/filemanager-bug-1405759 into lp:ubuntu-filemanager-app

Proposed by Carlos Jose Mazieri
Status: Merged
Approved by: Arto Jalkanen
Approved revision: 352
Merged at revision: 354
Proposed branch: lp:~carlos-mazieri/ubuntu-filemanager-app/filemanager-bug-1405759
Merge into: lp:ubuntu-filemanager-app
Diff against target: 139 lines (+78/-5)
1 file modified
src/plugin/test_folderlistmodel/regression/tst_folderlistmodel.cpp (+78/-5)
To merge this branch: bzr merge lp:~carlos-mazieri/ubuntu-filemanager-app/filemanager-bug-1405759
Reviewer Review Type Date Requested Status
Arto Jalkanen Approve
Ubuntu Phone Apps Jenkins Bot continuous-integration Approve
Review via email: mp+245395@code.launchpad.net

Commit message

enhances the test case TestDirModel::modelCancelRemoveAction()

Description of the change

It just enhances the test case TestDirModel::modelCancelRemoveAction() to match the scenario described in the bug #1405759.

It does not solve the bug, the test above worked reproducing such scenario.

To post a comment you must log in.
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Arto Jalkanen (ajalkane) wrote :

Always good to have more tests, looks fine :).

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/plugin/test_folderlistmodel/regression/tst_folderlistmodel.cpp'
2--- src/plugin/test_folderlistmodel/regression/tst_folderlistmodel.cpp 2014-06-17 21:41:59 +0000
3+++ src/plugin/test_folderlistmodel/regression/tst_folderlistmodel.cpp 2014-12-27 15:17:08 +0000
4@@ -199,6 +199,7 @@
5 int m_extFSWatcherPathModifiedCounter;
6 int m_selectedItemsCounter;
7 int m_selectionMode;
8+ int m_minimumProgressToCancelAction;
9
10 };
11
12@@ -345,11 +346,11 @@
13 }
14
15 void TestDirModel::cancel(int index, int, int percent)
16-{
17- DirModel * model = static_cast<DirModel*> (sender());
18- if (index > 1 || percent > 1)
19+{
20+ if (index > 1 || percent > m_minimumProgressToCancelAction)
21 {
22- model->cancelAction();
23+ DirModel * model = static_cast<DirModel*> (sender());
24+ model->cancelAction();
25 }
26 }
27
28@@ -453,6 +454,7 @@
29 m_extFSWatcherPathModifiedCounter = 0;
30 m_selectedItemsCounter = 0;
31 m_selectionMode = -1;
32+ m_minimumProgressToCancelAction = 1;
33 }
34
35
36@@ -475,6 +477,7 @@
37 m_extFSWatcherPathModifiedCounter = 0;
38 m_selectedItemsCounter = 0;
39 m_selectionMode = -1;
40+ m_minimumProgressToCancelAction = 1;
41 }
42
43
44@@ -931,6 +934,23 @@
45 QCOMPARE(totalCopied, m_progressTotalItems);
46 }
47
48+
49+/*!
50+ * \brief TestDirModel::modelCancelRemoveAction()
51+ *
52+ * It tests cancel on a remove operation
53+ *
54+ * Two directories with a deep tree of items are created
55+ *
56+ * The first directory is removed and the cancel is triggered after 10 percent of the all files be removed,
57+ * then the first phase of the checks are performed
58+ *
59+ * The second phase consists in remove the same directory after the cancel operation
60+ * then a new set of checks are performed
61+ *
62+ * The third phase consists in remove the second directory previously created
63+ *
64+ */
65 void TestDirModel::modelCancelRemoveAction()
66 {
67 const int level = 30;
68@@ -943,17 +963,70 @@
69 QCOMPARE(m_dirModel_01->rowCount(), 1);
70 connect(m_dirModel_01, SIGNAL(progress(int,int,int)),
71 this, SLOT(progress(int,int,int)));
72+
73+ connect(m_dirModel_01, SIGNAL(error(QString,QString)),
74+ this, SLOT(slotError(QString,QString)));
75+
76+ //cancel only after removing some files
77+ m_minimumProgressToCancelAction = 10;
78 connect(m_dirModel_01, SIGNAL(progress(int,int,int)),
79 this, SLOT(cancel(int,int,int)));
80
81+
82+ //create a second directory
83+ m_deepDir_02 = new DeepDir("modelCancelRemoveAction2", level);
84+ QCOMPARE( QFileInfo(m_deepDir_02->path()).exists(), true);
85+
86+ m_dirModel_02->setPath(m_deepDir_02->path());
87+ QTest::qWait(TIME_TO_REFRESH_DIR);
88+ QCOMPARE(m_dirModel_02->rowCount(), 1);
89+
90+
91+ //remove from first directory
92 m_dirModel_01->removeIndex(0);
93 QTest::qWait(TIME_TO_PROCESS);
94 QTest::qWait(5);
95
96- QCOMPARE(m_filesRemoved.count() , 0);
97+ // sub items do not emit removed()
98+ QCOMPARE(m_filesRemoved.count(), 0);
99 QCOMPARE(m_dirModel_01->rowCount(), 1);
100 QVERIFY(m_progressCurrentItem > 0); // some file were performed
101 QVERIFY(m_progressPercentDone < 100); //
102+ QCOMPARE(m_receivedErrorSignal, false);
103+ // high level item still exists
104+ QDir a(m_deepDir_01->path(), QString(), QDir::NoSort, QDir::AllEntries | QDir::NoDotAndDotDot);
105+ QCOMPARE(a.exists(), true);
106+ QCOMPARE((int)a.count(), 1);
107+
108+ //First phase OK cancel worked
109+ //SECOND PHASE now remove everything
110+ disconnect(m_dirModel_01, SIGNAL(progress(int,int,int)),
111+ this, SLOT(cancel(int,int,int)));
112+
113+ m_dirModel_01->removeIndex(0);
114+ QTest::qWait(TIME_TO_PROCESS * 2);
115+ QTest::qWait(5);
116+ QCOMPARE(m_progressPercentDone, 100);
117+ QCOMPARE(m_filesRemoved.count(), 1);
118+ QCOMPARE(m_dirModel_01->rowCount(), 0);
119+ QCOMPARE(m_receivedErrorSignal, false);
120+ // high level item does NOT exist anymore
121+ QDir b(m_deepDir_01->path(), QString(), QDir::NoSort, QDir::AllEntries | QDir::NoDotAndDotDot);
122+ QCOMPARE(b.exists(), true);
123+ QCOMPARE((int)b.count(), 0);
124+
125+ //THIRD PHASE
126+ //now remove the second directory
127+ QDir c(m_deepDir_02->path(), QString(), QDir::NoSort, QDir::AllEntries | QDir::NoDotAndDotDot);
128+ QCOMPARE(c.exists(), true);
129+ QCOMPARE((int)c.count(), 1);
130+ m_dirModel_02->removeIndex(0);
131+ QTest::qWait(TIME_TO_PROCESS * 2);
132+ QDir d(m_deepDir_02->path(), QString(), QDir::NoSort, QDir::AllEntries | QDir::NoDotAndDotDot);
133+ QCOMPARE(d.exists(), true);
134+ QCOMPARE((int)d.count(), 0);
135+ QCOMPARE(m_receivedErrorSignal, false);
136+ QCOMPARE(m_dirModel_02->rowCount(), 0);
137 }
138
139 void TestDirModel::modelTestFileSize()

Subscribers

People subscribed via source and target branches