Merge lp:~sylvain-pineau/checkbox/937696_update_selection_tree_on_recover into lp:checkbox

Proposed by Sylvain Pineau
Status: Merged
Merged at revision: 1337
Proposed branch: lp:~sylvain-pineau/checkbox/937696_update_selection_tree_on_recover
Merge into: lp:checkbox
Diff against target: 232 lines (+50/-15)
6 files modified
checkbox_qt/qt_interface.py (+11/-5)
debian/changelog (+3/-0)
plugins/jobs_prompt.py (+4/-0)
plugins/suites_prompt.py (+16/-2)
qt/frontend/qtfront.cpp (+14/-6)
qt/frontend/qtfront.h (+2/-2)
To merge this branch: bzr merge lp:~sylvain-pineau/checkbox/937696_update_selection_tree_on_recover
Reviewer Review Type Date Requested Status
Jeff Lane  Approve
Review via email: mp+98534@code.launchpad.net

Description of the change

The selection tree is now updated when recovering from a previous run, both tests selection and status are updated.

To post a comment you must log in.
1335. By Sylvain Pineau

Fix a previous merge error in qt_interface.py

Revision history for this message
Jeff Lane  (bladernr) wrote :

Thanks. Approve... tested this a couple times by launching checkbox-qt and selecting a handful of tests, killing checkbox then restarting. Works well, each recovery shows only the previously selected tests as being selected on subsequent runs.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'checkbox_qt/qt_interface.py'
2--- checkbox_qt/qt_interface.py 2012-03-20 19:47:17 +0000
3+++ checkbox_qt/qt_interface.py 2012-03-21 09:26:19 +0000
4@@ -126,21 +126,27 @@
5
6 def show_tree(self, text, options={}, default={}):
7 indexedOptions = {}
8+ indexedDefaults = {}
9
10 def onStartTestsClicked():
11 self.direction = NEXT
12 self.loop.quit()
13
14- def buildBranch(options, baseIndex="1"):
15+ def buildBranch(options, default, baseIndex="1"):
16 internalIndex = 1
17 for test, state in options.iteritems():
18+ active = test in default
19 if isinstance(state, dict):
20 indexedOptions[
21 baseIndex + "." + str(internalIndex)] = {test: ''}
22- buildBranch(state, baseIndex + "." + str(internalIndex))
23+ indexedDefaults[
24+ baseIndex + "." + str(internalIndex)] = {test: active}
25+ buildBranch(state, default.get(test, {}), baseIndex + "." + str(internalIndex))
26 else:
27 indexedOptions[
28 baseIndex + "." + str(internalIndex)] = {test: state}
29+ indexedDefaults[
30+ baseIndex + "." + str(internalIndex)] = {test: active}
31 internalIndex += 1
32
33 def buildDict(options, baseIndex="1"):
34@@ -161,9 +167,9 @@
35 return branch
36
37 self._set_main_title()
38- buildBranch(options)
39+ buildBranch(options, default)
40
41- self.qtiface.showTree(text, indexedOptions)
42+ self.qtiface.showTree(text, indexedOptions, indexedDefaults)
43 self.wait_on_signals(
44 startTestsClicked=onStartTestsClicked)
45
46@@ -211,7 +217,7 @@
47 if not "data" in test:
48 test["data"] = ""
49 if "command" in test:
50- enableTestButton = True
51+ enableTestButton = True
52
53 self.qtiface.showTest(
54 test["purpose"], test["steps"], test["verification"], info, test["data"],
55
56=== modified file 'debian/changelog'
57--- debian/changelog 2012-03-20 19:57:16 +0000
58+++ debian/changelog 2012-03-21 09:26:19 +0000
59@@ -62,6 +62,9 @@
60 right click menu (LP: #956757)
61 * checkbox_qt/qt_interface.py, qt/frontend/qtfront.cpp,
62 qt/frontend/qtfront.h: Tests now select Yes on PASS status (LP: #954556)
63+ * qt/frontend/qtfront.cpp, qt/frontend/qtfront.h, plugins/suites_prompt.py,
64+ checkbox_qt/qt_interface.py, plugins/jobs_prompt.py: The selection tree is
65+ now updated when recovering from a previous run (LP: #937696)
66
67 [Brendan Donegan]
68 * jobs/suspend.txt.in: Fixed dependencies on wireless and suspend_advanced
69
70=== modified file 'plugins/jobs_prompt.py'
71--- plugins/jobs_prompt.py 2012-03-01 22:35:44 +0000
72+++ plugins/jobs_prompt.py 2012-03-21 09:26:19 +0000
73@@ -55,6 +55,7 @@
74 self._store = None
75
76 for (rt, rh) in [
77+ ("expose-msgstore", self.expose_msgstore),
78 ("begin-persist", self.begin_persist),
79 ("begin-recover", self.begin_recover),
80 ("ignore-jobs", self.ignore_jobs),
81@@ -72,6 +73,9 @@
82 #all other gathering callbacks are finished)
83 self._manager.reactor.call_on("gather", self.end_gather, 900)
84
85+ def expose_msgstore(self):
86+ self._manager.reactor.fire("store-access", self.store)
87+
88 def begin_persist(self, persist):
89 self._persist = persist
90
91
92=== modified file 'plugins/suites_prompt.py'
93--- plugins/suites_prompt.py 2012-03-14 21:11:06 +0000
94+++ plugins/suites_prompt.py 2012-03-21 09:26:19 +0000
95@@ -51,7 +51,8 @@
96 for (rt, rh) in [
97 ("begin-persist", self.begin_persist),
98 ("begin-recover", self.begin_recover),
99- ("report-suite", self.report_suite)]:
100+ ("report-suite", self.report_suite),
101+ ("store-access", self.store_access)]:
102 self._manager.reactor.call_on(rt, rh)
103
104 for (rt, rh) in [
105@@ -72,6 +73,9 @@
106 def report_suite(self, suite):
107 suite.setdefault("type", "suite")
108
109+ def store_access(self, store):
110+ self.store = store
111+
112 def report_job(self, job):
113 if job.get("type") == "suite":
114 attribute = "description"
115@@ -94,11 +98,21 @@
116
117 # Build options
118 options = {}
119+ self._manager.reactor.fire("expose-msgstore")
120+ offset = self.store.get_pending_offset()
121+ self.store.set_pending_offset(0)
122+ messages = self.store.get_pending_messages()
123+ self.store.add_pending_offset(offset)
124+ tests = dict([(m["name"], m) for m in messages
125+ if m.get("type") in ("test", "metric")])
126 for job in resolver.get_dependents():
127 suboptions = options
128 dependencies = resolver.get_dependencies(job)
129 for dependency in dependencies:
130- value = self._statuses.get(dependency, {})
131+ if dependency in tests:
132+ value = tests[dependency]["status"]
133+ else:
134+ value = self._statuses.get(dependency, {})
135 suboptions = suboptions.setdefault(self._jobs[dependency], value)
136
137 # Build defaults
138
139=== modified file 'qt/frontend/qtfront.cpp'
140--- qt/frontend/qtfront.cpp 2012-03-20 19:47:17 +0000
141+++ qt/frontend/qtfront.cpp 2012-03-21 09:26:19 +0000
142@@ -418,27 +418,35 @@
143 updateTestStatus(status);
144 }
145
146-void QtFront::buildTree(QVariantMap options, QString baseIndex, QStandardItem *parentItem, QStandardItem *parentStatusItem)
147+void QtFront::buildTree(QVariantMap options, QVariantMap defaults, QString baseIndex, QStandardItem *parentItem, QStandardItem *parentStatusItem)
148 {
149 int internalIndex = 1;
150 while (true) {
151 QString index = baseIndex+"."+QString::number(internalIndex);
152 QVariant value = options.value(index);
153+ QVariant defaultValue = defaults.value(index);
154 QDBusArgument arg = value.value<QDBusArgument>();
155+ QDBusArgument defaultArg = defaultValue.value<QDBusArgument>();
156 if (arg.currentSignature().isEmpty()) {
157 break;
158 }
159 QMap<QString, QString> items = qdbus_cast<QMap<QString, QString> >(arg);
160+ QMap<QString, bool> defaultItems = qdbus_cast<QMap<QString, bool> >(defaultArg);
161 if (items.isEmpty()) {
162 break;
163 } else {
164 QString test = items.keys().at(0);
165 QString status = items.values().at(0);
166+ bool active = defaultItems.values().at(0);
167 QStandardItem *item = new QStandardItem(test);
168 QStandardItem *testStatusItem = new QStandardItem(m_statusStrings[status]);
169
170 item->setFlags(Qt::ItemIsUserCheckable | Qt::ItemIsEnabled| Qt::ItemIsTristate);
171- item->setData(QVariant(Qt::Checked), Qt::CheckStateRole);
172+ if (active) {
173+ item->setData(QVariant(Qt::Checked), Qt::CheckStateRole);
174+ } else {
175+ item->setData(QVariant(Qt::Unchecked), Qt::CheckStateRole);
176+ }
177
178 testStatusItem->setData(test, Qt::UserRole);
179 testStatusItem->setFlags(Qt::ItemIsUserCheckable | Qt::ItemIsEnabled|Qt::ItemIsTristate);
180@@ -448,10 +456,10 @@
181 // for children nodes
182 parentItem->appendRow(item);
183 parentStatusItem->appendRow(testStatusItem);
184- buildTree(options, index, item, testStatusItem);
185+ buildTree(options, defaults, index, item, testStatusItem);
186 } else {
187 // for root nodes
188- buildTree(options, index, item, testStatusItem);
189+ buildTree(options, defaults, index, item, testStatusItem);
190 m_model->appendRow(item);
191 m_statusModel->appendRow(testStatusItem);
192 }
193@@ -460,7 +468,7 @@
194 }
195 }
196
197-void QtFront::showTree(QString text, QVariantMap options)
198+void QtFront::showTree(QString text, QVariantMap options, QVariantMap defaults)
199 {
200 Q_UNUSED(text);
201 currentState = TREE;
202@@ -471,7 +479,7 @@
203 // build the model only once
204 if (!this->m_model) {
205 this->m_model = new TreeModel();
206- buildTree(options, "1");
207+ buildTree(options, defaults, "1");
208 ui->treeView->setModel(m_model);
209 ui->statusView->setModel(m_statusModel);
210 }
211
212=== modified file 'qt/frontend/qtfront.h'
213--- qt/frontend/qtfront.h 2012-03-20 19:47:17 +0000
214+++ qt/frontend/qtfront.h 2012-03-21 09:26:19 +0000
215@@ -46,7 +46,7 @@
216 void startProgressBar(QString text);
217 void showError(QString text);
218 void stopProgressBar();
219- void showTree(QString text, QVariantMap options);
220+ void showTree(QString text, QVariantMap options, QVariantMap defaults);
221 void showEntry(QString text);
222 QVariantMap getTestsToRun();
223 QString getEmailAddress();
224@@ -90,7 +90,7 @@
225
226 private:
227 bool registerService();
228- void buildTree(QVariantMap options, QString baseIndex = "1", QStandardItem *parentItem = 0, QStandardItem *parentStatusItem = 0);
229+ void buildTree(QVariantMap options, QVariantMap defaults, QString baseIndex = "1", QStandardItem *parentItem = 0, QStandardItem *parentStatusItem = 0);
230 void buildTestsToRun(QStandardItem *item, QString baseIndex, QVariantMap &items);
231 Ui_main *ui;
232 QWidget *m_mainWindow;

Subscribers

People subscribed via source and target branches