Merge lp:~diegosarmentero/ubuntu-system-settings/duplicate-and-credentials into lp:ubuntu-system-settings

Proposed by Diego Sarmentero
Status: Merged
Approved by: Sebastien Bacher
Approved revision: 690
Merged at revision: 692
Proposed branch: lp:~diegosarmentero/ubuntu-system-settings/duplicate-and-credentials
Merge into: lp:ubuntu-system-settings
Diff against target: 277 lines (+53/-15)
9 files modified
plugins/system-update/PageComponent.qml (+1/-2)
plugins/system-update/system_update.cpp (+1/-1)
plugins/system-update/system_update.h (+2/-0)
plugins/system-update/update_manager.cpp (+25/-7)
plugins/system-update/update_manager.h (+4/-0)
tests/plugins/system-update/fakessoservice.cpp (+8/-3)
tests/plugins/system-update/fakessoservice.h (+4/-0)
tests/plugins/system-update/fakesystemupdate.h (+2/-0)
tests/plugins/system-update/tst_updatemanager.cpp (+6/-2)
To merge this branch: bzr merge lp:~diegosarmentero/ubuntu-system-settings/duplicate-and-credentials
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Needs Fixing
Sebastien Bacher (community) Approve
Review via email: mp+218414@code.launchpad.net

Commit message

- Avoid duplicate result of Image upadte
- Don't ask for credentials on Image update

Description of the change

Some tests has also been updated according the new code.

To post a comment you must log in.
Revision history for this message
Sebastien Bacher (seb128) wrote :

Thanks for the work, the package fails to build with those changes for me though

"FAIL! : UpdateManagerTest::testCheckUpdatesModelSignal() Compared values are not the same
   Actual (manager.get_apps().size()): 0
   Expected (4) : 4
   Loc: [/tmp/build/ubuntu-system-settings-0.1+14.10.20140428/tests/plugins/system-update/tst_updatemanager.cpp(131)]
FAIL! : UpdateManagerTest::testCheckUpdatesUpdateSignal() Compared values are not the same
   Actual (manager.get_apps().size()): 0
   Expected (4) : 4
   Loc: [/tmp/build/ubuntu-system-settings-0.1+14.10.20140428/tests/plugins/system-update/tst_updatemanager.cpp(145)]

Totals: 6 passed, 2 failed, 0 skipped

(that's building on an i386 configuration)

review: Needs Fixing
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Diego Sarmentero (diegosarmentero) wrote :

> Thanks for the work, the package fails to build with those changes for me
> though
>
> "FAIL! : UpdateManagerTest::testCheckUpdatesModelSignal() Compared values are
> not the same
> Actual (manager.get_apps().size()): 0
> Expected (4) : 4
> Loc: [/tmp/build/ubuntu-system-settings-0.1+14.10.20140428/tests/plugins
> /system-update/tst_updatemanager.cpp(131)]
> FAIL! : UpdateManagerTest::testCheckUpdatesUpdateSignal() Compared values are
> not the same
> Actual (manager.get_apps().size()): 0
> Expected (4) : 4
> Loc: [/tmp/build/ubuntu-system-settings-0.1+14.10.20140428/tests/plugins
> /system-update/tst_updatemanager.cpp(145)]
>
> Totals: 6 passed, 2 failed, 0 skipped
>
> (that's building on an i386 configuration)

Weird, it's building for me in the phone, i'll check what's going on

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
691. By Diego Sarmentero

initialize m_validCredentials

Revision history for this message
Sebastien Bacher (seb128) wrote :

Looks good now, thanks

review: Approve
Revision history for this message
Sebastien Bacher (seb128) wrote :

(the autopilot tests fail here, but that's fixed by https://code.launchpad.net/~diegosarmentero/ubuntu-system-settings/ignore-updates-autopilot/+merge/218481 which is going to be included in the same landing)

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'plugins/system-update/PageComponent.qml'
--- plugins/system-update/PageComponent.qml 2014-04-11 16:34:57 +0000
+++ plugins/system-update/PageComponent.qml 2014-05-07 15:38:11 +0000
@@ -101,20 +101,19 @@
101 },101 },
102 State {102 State {
103 name: "UPDATE"103 name: "UPDATE"
104 PropertyChanges { target: notification; visible: false}
105 PropertyChanges { target: updateList; visible: true}104 PropertyChanges { target: updateList; visible: true}
106 PropertyChanges { target: installAllButton; visible: true}105 PropertyChanges { target: installAllButton; visible: true}
107 PropertyChanges { target: updateNotification; visible: false}106 PropertyChanges { target: updateNotification; visible: false}
108 },107 },
109 State {108 State {
110 name: "NOCREDENTIALS"109 name: "NOCREDENTIALS"
110 PropertyChanges { target: updateList; visible: true}
111 PropertyChanges { target: notification; text: i18n.tr("Please log into your Ubuntu One account.")}111 PropertyChanges { target: notification; text: i18n.tr("Please log into your Ubuntu One account.")}
112 PropertyChanges { target: notification; onClicked: root.open_online_accounts() }112 PropertyChanges { target: notification; onClicked: root.open_online_accounts() }
113 PropertyChanges { target: notification; progression: true}113 PropertyChanges { target: notification; progression: true}
114 PropertyChanges { target: notification; visible: true}114 PropertyChanges { target: notification; visible: true}
115 PropertyChanges { target: updateNotification; text: i18n.tr("Credentials not found")}115 PropertyChanges { target: updateNotification; text: i18n.tr("Credentials not found")}
116 PropertyChanges { target: updateNotification; visible: true}116 PropertyChanges { target: updateNotification; visible: true}
117 PropertyChanges { target: installAllButton; visible: false}
118 }117 }
119 ]118 ]
120119
121120
=== modified file 'plugins/system-update/system_update.cpp'
--- plugins/system-update/system_update.cpp 2014-02-25 20:27:51 +0000
+++ plugins/system-update/system_update.cpp 2014-05-07 15:38:11 +0000
@@ -151,7 +151,7 @@
151 QString errorReason)151 QString errorReason)
152{152{
153 update = new Update(this);153 update = new Update(this);
154 QString packageName("UbuntuImage");154 QString packageName(UBUNTU_PACKAGE_NAME);
155 update->initializeApplication(packageName, "Ubuntu",155 update->initializeApplication(packageName, "Ubuntu",
156 QString::number(this->currentBuildNumber()));156 QString::number(this->currentBuildNumber()));
157157
158158
=== modified file 'plugins/system-update/system_update.h'
--- plugins/system-update/system_update.h 2014-02-25 20:27:51 +0000
+++ plugins/system-update/system_update.h 2014-05-07 15:38:11 +0000
@@ -30,6 +30,8 @@
3030
31#include "update.h"31#include "update.h"
3232
33#define UBUNTU_PACKAGE_NAME "UbuntuImage"
34
33namespace UpdatePlugin {35namespace UpdatePlugin {
3436
35class SystemUpdate : public QObject37class SystemUpdate : public QObject
3638
=== modified file 'plugins/system-update/update_manager.cpp'
--- plugins/system-update/update_manager.cpp 2014-04-11 16:27:17 +0000
+++ plugins/system-update/update_manager.cpp 2014-05-07 15:38:11 +0000
@@ -28,6 +28,11 @@
28#include <QProcessEnvironment>28#include <QProcessEnvironment>
2929
30#define CLICK_COMMAND "click"30#define CLICK_COMMAND "click"
31#ifdef TESTS
32 #define CHECK_CREDENTIALS "IGNORE_CREDENTIALS"
33#else
34 #define CHECK_CREDENTIALS "CHECK_CREDENTIALS"
35#endif
3136
32namespace UpdatePlugin {37namespace UpdatePlugin {
3338
@@ -118,13 +123,17 @@
118 m_model.clear();123 m_model.clear();
119 m_apps.clear();124 m_apps.clear();
120 Q_EMIT modelChanged();125 Q_EMIT modelChanged();
126 bool enabled = enableAutopilotMode();
121 if (getCheckForCredentials()) {127 if (getCheckForCredentials()) {
122 m_systemUpdate.checkForUpdate();128 m_systemUpdate.checkForUpdate();
123 m_service.getCredentials();129 m_service.getCredentials();
124 } else {130 } else if (enabled) {
125 systemUpdateNotAvailable();131 systemUpdateNotAvailable();
126 Token token("", "", "", "");132 Token token("", "", "", "");
127 handleCredentialsFound(token);133 handleCredentialsFound(token);
134 } else {
135 systemUpdateNotAvailable();
136 clickUpdateNotAvailable();
128 }137 }
129}138}
130139
@@ -147,10 +156,17 @@
147bool UpdateManager::getCheckForCredentials()156bool UpdateManager::getCheckForCredentials()
148{157{
149 QProcessEnvironment environment = QProcessEnvironment::systemEnvironment();158 QProcessEnvironment environment = QProcessEnvironment::systemEnvironment();
150 QString value = environment.value("IGNORE_CREDENTIALS", QString("CHECK_CREDENTIALS"));159 QString value = environment.value("IGNORE_CREDENTIALS", QString(CHECK_CREDENTIALS));
151 return value == "CHECK_CREDENTIALS";160 return value == "CHECK_CREDENTIALS";
152}161}
153162
163bool UpdateManager::enableAutopilotMode()
164{
165 QProcessEnvironment environment = QProcessEnvironment::systemEnvironment();
166 QString value = environment.value("AUTOPILOT_ENABLED", QString("AUTOPILOT_DISABLED"));
167 return value == "AUTOPILOT_ENABLED";
168}
169
154void UpdateManager::processOutput()170void UpdateManager::processOutput()
155{171{
156 QString output(m_process.readAllStandardOutput());172 QString output(m_process.readAllStandardOutput());
@@ -179,7 +195,8 @@
179 bool updateAvailable = false;195 bool updateAvailable = false;
180 foreach (QString id, m_apps.keys()) {196 foreach (QString id, m_apps.keys()) {
181 Update *app = m_apps.value(id);197 Update *app = m_apps.value(id);
182 if(app->updateRequired()) {198 QString packagename(UBUNTU_PACKAGE_NAME);
199 if(app->getPackageName() != packagename && app->updateRequired()) {
183 updateAvailable = true;200 updateAvailable = true;
184 m_model.append(QVariant::fromValue(app));201 m_model.append(QVariant::fromValue(app));
185 }202 }
@@ -194,20 +211,21 @@
194211
195void UpdateManager::registerSystemUpdate(const QString& packageName, Update *update)212void UpdateManager::registerSystemUpdate(const QString& packageName, Update *update)
196{213{
197 m_systemCheckingUpdate = false;214 QString packagename(UBUNTU_PACKAGE_NAME);
198 if (!m_apps.contains(packageName)) {215 if (!m_apps.contains(packagename)) {
199 m_apps[packageName] = update;216 m_apps[packageName] = update;
200 m_model.insert(0, QVariant::fromValue(update));217 m_model.insert(0, QVariant::fromValue(update));
201 Q_EMIT modelChanged();218 Q_EMIT modelChanged();
219 Q_EMIT updateAvailableFound(update->updateState());
202 }220 }
203 Q_EMIT updateAvailableFound(update->updateState());221 m_systemCheckingUpdate = false;
204222
205 reportCheckState();223 reportCheckState();
206}224}
207225
208void UpdateManager::systemUpdatePaused(int value)226void UpdateManager::systemUpdatePaused(int value)
209{227{
210 QString packagename("UbuntuImage");228 QString packagename(UBUNTU_PACKAGE_NAME);
211 if (m_apps.contains(packagename)) {229 if (m_apps.contains(packagename)) {
212 Update *update = m_apps[packagename];230 Update *update = m_apps[packagename];
213 update->setSelected(true);231 update->setSelected(true);
214232
=== modified file 'plugins/system-update/update_manager.h'
--- plugins/system-update/update_manager.h 2014-04-11 16:27:17 +0000
+++ plugins/system-update/update_manager.h 2014-05-07 15:38:11 +0000
@@ -90,6 +90,9 @@
90 void set_token(Token& t) { m_token = t; }90 void set_token(Token& t) { m_token = t; }
91 Token get_token() { return m_token; }91 Token get_token() { return m_token; }
92 void setCheckintUpdates(int value) { m_checkingUpdates = value; }92 void setCheckintUpdates(int value) { m_checkingUpdates = value; }
93 void setCheckSystemUpdates(int value) { m_systemCheckingUpdate = value; }
94 void setCheckClickUpdates(int value) { m_clickCheckingUpdate = value; }
95 FakeSsoService& getService() { return m_service; }
93#endif96#endif
9497
95public Q_SLOTS:98public Q_SLOTS:
@@ -129,6 +132,7 @@
129 void checkForUpdates();132 void checkForUpdates();
130 QString getClickCommand();133 QString getClickCommand();
131 bool getCheckForCredentials();134 bool getCheckForCredentials();
135 bool enableAutopilotMode();
132 void reportCheckState();136 void reportCheckState();
133 void updateNotAvailable();137 void updateNotAvailable();
134};138};
135139
=== modified file 'tests/plugins/system-update/fakessoservice.cpp'
--- tests/plugins/system-update/fakessoservice.cpp 2014-02-26 11:26:01 +0000
+++ tests/plugins/system-update/fakessoservice.cpp 2014-05-07 15:38:11 +0000
@@ -3,14 +3,19 @@
3namespace UpdatePlugin {3namespace UpdatePlugin {
44
5FakeSsoService::FakeSsoService(QObject *parent) :5FakeSsoService::FakeSsoService(QObject *parent) :
6 QObject(parent)6 QObject(parent),
7 m_validCredentials(true)
7{8{
8}9}
910
10void FakeSsoService::getCredentials()11void FakeSsoService::getCredentials()
11{12{
12 Token token("token_key", "token_secret", "consumer_key", "consumer_secret");13 if(m_validCredentials) {
13 emit this->credentialsFound(token);14 Token token("token_key", "token_secret", "consumer_key", "consumer_secret");
15 emit this->credentialsFound(token);
16 } else {
17 emit this->credentialsNotFound();
18 }
14}19}
1520
16}21}
1722
=== modified file 'tests/plugins/system-update/fakessoservice.h'
--- tests/plugins/system-update/fakessoservice.h 2014-02-26 11:26:01 +0000
+++ tests/plugins/system-update/fakessoservice.h 2014-05-07 15:38:11 +0000
@@ -15,11 +15,15 @@
15 explicit FakeSsoService(QObject *parent = 0);15 explicit FakeSsoService(QObject *parent = 0);
1616
17 void getCredentials();17 void getCredentials();
18
19 void setValidCredentials(bool value) { m_validCredentials = value; }
18 20
19signals:21signals:
20 void credentialsFound(const Token&);22 void credentialsFound(const Token&);
21 void credentialsNotFound();23 void credentialsNotFound();
2224
25private:
26 bool m_validCredentials;
23};27};
2428
25}29}
2630
=== modified file 'tests/plugins/system-update/fakesystemupdate.h'
--- tests/plugins/system-update/fakesystemupdate.h 2014-02-26 11:26:01 +0000
+++ tests/plugins/system-update/fakesystemupdate.h 2014-05-07 15:38:11 +0000
@@ -22,6 +22,8 @@
22#include <QObject>22#include <QObject>
23#include "../../../plugins/system-update/update.h"23#include "../../../plugins/system-update/update.h"
2424
25#define UBUNTU_PACKAGE_NAME "UbuntuImage"
26
25namespace UpdatePlugin {27namespace UpdatePlugin {
2628
27class FakeSystemUpdate: public QObject29class FakeSystemUpdate: public QObject
2830
=== modified file 'tests/plugins/system-update/tst_updatemanager.cpp'
--- tests/plugins/system-update/tst_updatemanager.cpp 2014-04-11 16:27:17 +0000
+++ tests/plugins/system-update/tst_updatemanager.cpp 2014-05-07 15:38:11 +0000
@@ -58,6 +58,7 @@
58void UpdateManagerTest::testRegisterSystemUpdateRequired()58void UpdateManagerTest::testRegisterSystemUpdateRequired()
59{59{
60 UpdateManager manager;60 UpdateManager manager;
61 manager.checkUpdates();
61 QSignalSpy spy(&manager, SIGNAL(modelChanged()));62 QSignalSpy spy(&manager, SIGNAL(modelChanged()));
62 QSignalSpy spy2(&manager, SIGNAL(updateAvailableFound(bool)));63 QSignalSpy spy2(&manager, SIGNAL(updateAvailableFound(bool)));
63 QTRY_COMPARE(spy.count(), 0);64 QTRY_COMPARE(spy.count(), 0);
@@ -66,6 +67,7 @@
6667
67 Update *update = getUpdate();68 Update *update = getUpdate();
6869
70 manager.setCheckSystemUpdates(true);
69 manager.registerSystemUpdate(update->getPackageName(), update);71 manager.registerSystemUpdate(update->getPackageName(), update);
70 QTRY_COMPARE(spy.count(), 1);72 QTRY_COMPARE(spy.count(), 1);
71 QTRY_COMPARE(spy2.count(), 1);73 QTRY_COMPARE(spy2.count(), 1);
@@ -102,6 +104,7 @@
102void UpdateManagerTest::testStartDownload()104void UpdateManagerTest::testStartDownload()
103{105{
104 UpdateManager manager;106 UpdateManager manager;
107 manager.setCheckSystemUpdates(true);
105 Update *update = getUpdate();108 Update *update = getUpdate();
106 manager.registerSystemUpdate(update->getPackageName(), update);109 manager.registerSystemUpdate(update->getPackageName(), update);
107 manager.startDownload(update->getPackageName());110 manager.startDownload(update->getPackageName());
@@ -111,6 +114,7 @@
111void UpdateManagerTest::testPauseDownload()114void UpdateManagerTest::testPauseDownload()
112{115{
113 UpdateManager manager;116 UpdateManager manager;
117 manager.setCheckSystemUpdates(true);
114 Update *update = getUpdate();118 Update *update = getUpdate();
115 manager.registerSystemUpdate(update->getPackageName(), update);119 manager.registerSystemUpdate(update->getPackageName(), update);
116 update->setUpdateState(true);120 update->setUpdateState(true);
@@ -123,7 +127,7 @@
123 UpdateManager manager;127 UpdateManager manager;
124 QSignalSpy spy(&manager, SIGNAL(modelChanged()));128 QSignalSpy spy(&manager, SIGNAL(modelChanged()));
125 QTRY_COMPARE(manager.get_apps().size(), 0);129 QTRY_COMPARE(manager.get_apps().size(), 0);
126 manager.checkUpdates();130 manager.getService().getCredentials();
127 QTRY_COMPARE(manager.get_apps().size(), 4);131 QTRY_COMPARE(manager.get_apps().size(), 4);
128 QTRY_COMPARE(manager.get_model().size(), 1);132 QTRY_COMPARE(manager.get_model().size(), 1);
129 Update* app = manager.get_model()[0].value<Update*>();133 Update* app = manager.get_model()[0].value<Update*>();
@@ -137,7 +141,7 @@
137 UpdateManager manager;141 UpdateManager manager;
138 QSignalSpy spy(&manager, SIGNAL(updateAvailableFound(bool)));142 QSignalSpy spy(&manager, SIGNAL(updateAvailableFound(bool)));
139 QTRY_COMPARE(manager.get_apps().size(), 0);143 QTRY_COMPARE(manager.get_apps().size(), 0);
140 manager.checkUpdates();144 manager.getService().getCredentials();
141 QTRY_COMPARE(manager.get_apps().size(), 4);145 QTRY_COMPARE(manager.get_apps().size(), 4);
142 QTRY_COMPARE(manager.get_model().size(), 1);146 QTRY_COMPARE(manager.get_model().size(), 1);
143 Update* app = manager.get_model()[0].value<Update*>();147 Update* app = manager.get_model()[0].value<Update*>();

Subscribers

People subscribed via source and target branches