Merge lp:~ken-vandine/ubuntu-system-settings/rtm_click_framework_check into lp:ubuntu-system-settings/rtm-14.09
- rtm_click_framework_check
- Merge into rtm-14.09
Status: | Merged |
---|---|
Approved by: | Ken VanDine |
Approved revision: | 1018 |
Merged at revision: | 1012 |
Proposed branch: | lp:~ken-vandine/ubuntu-system-settings/rtm_click_framework_check |
Merge into: | lp:ubuntu-system-settings/rtm-14.09 |
Diff against target: |
233 lines (+136/-5) 5 files modified
debian/control (+1/-0) plugins/system-update/network/network.cpp (+60/-5) plugins/system-update/network/network.h (+7/-0) tests/plugins/system-update/CMakeLists.txt (+10/-0) tests/plugins/system-update/tst_network.cpp (+58/-0) |
To merge this branch: | bzr merge lp:~ken-vandine/ubuntu-system-settings/rtm_click_framework_check |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
PS Jenkins bot | continuous-integration | Approve | |
Manuel de la Peña (community) | Approve | ||
Review via email: mp+257781@code.launchpad.net |
Commit message
Include supported frameworks and arch when checking for updates
Description of the change
Include supported frameworks and arch when checking for updates
- 1013. By Ken VanDine
-
Added tests to ensure framework and arch are included in check for click updates
- 1014. By Ken VanDine
-
Use rawHeader on the request to pass framework and arch
PS Jenkins bot (ps-jenkins) wrote : | # |
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:1014
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
- 1015. By Ken VanDine
-
Don't use QByteArray:
:fromStdString, it was just introduced in 5.4
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:1015
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
- 1016. By Ken VanDine
-
Added build depends on ubuntu-sdk-libs to get click frameworks needed by tests
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:1016
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
- 1017. By Ken VanDine
-
fixed url for click updates
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:1017
http://
Executed test runs:
UNSTABLE: http://
SUCCESS: http://
deb: http://
UNSTABLE: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:1017
http://
Executed test runs:
UNSTABLE: http://
SUCCESS: http://
deb: http://
UNSTABLE: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
- 1018. By Ken VanDine
-
cleaned up based on review feedback
Manuel de la Peña (mandel) : | # |
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:1017
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
- 1019. By Ken VanDine
-
Fixed function rename missed in merge from trunk
Preview Diff
1 | === modified file 'debian/control' | |||
2 | --- debian/control 2015-02-17 12:55:11 +0000 | |||
3 | +++ debian/control 2015-04-30 14:58:55 +0000 | |||
4 | @@ -40,6 +40,7 @@ | |||
5 | 40 | pep8, | 40 | pep8, |
6 | 41 | python3-pep8, | 41 | python3-pep8, |
7 | 42 | pyflakes, | 42 | pyflakes, |
8 | 43 | ubuntu-sdk-libs, | ||
9 | 43 | Standards-Version: 3.9.6 | 44 | Standards-Version: 3.9.6 |
10 | 44 | Homepage: https://launchpad.net/ubuntu-system-settings | 45 | Homepage: https://launchpad.net/ubuntu-system-settings |
11 | 45 | # If you aren't a member of ~system-settings-touch but need to upload packaging | 46 | # If you aren't a member of ~system-settings-touch but need to upload packaging |
12 | 46 | 47 | ||
13 | === modified file 'plugins/system-update/network/network.cpp' | |||
14 | --- plugins/system-update/network/network.cpp 2014-09-18 13:50:15 +0000 | |||
15 | +++ plugins/system-update/network/network.cpp 2015-04-30 14:58:55 +0000 | |||
16 | @@ -17,6 +17,7 @@ | |||
17 | 17 | */ | 17 | */ |
18 | 18 | 18 | ||
19 | 19 | #include "network.h" | 19 | #include "network.h" |
20 | 20 | #include <sstream> | ||
21 | 20 | #include <QJsonDocument> | 21 | #include <QJsonDocument> |
22 | 21 | #include <QJsonObject> | 22 | #include <QJsonObject> |
23 | 22 | #include <QJsonArray> | 23 | #include <QJsonArray> |
24 | @@ -25,9 +26,13 @@ | |||
25 | 25 | #include <QUrl> | 26 | #include <QUrl> |
26 | 26 | #include <QProcessEnvironment> | 27 | #include <QProcessEnvironment> |
27 | 27 | 28 | ||
31 | 28 | #define URL_APPS "https://myapps.developer.ubuntu.com/dev/api/click-metadata/" | 29 | namespace { |
32 | 29 | 30 | const QString URL_APPS = "https://search.apps.ubuntu.com/api/v1/click-metadata"; | |
33 | 30 | #define APPS_DATA "APPS_DATA" | 31 | const QString APPS_DATA = "APPS_DATA"; |
34 | 32 | constexpr static const char* FRAMEWORKS_FOLDER {"/usr/share/click/frameworks/"}; | ||
35 | 33 | constexpr static const char* FRAMEWORKS_PATTERN {"*.framework"}; | ||
36 | 34 | constexpr static const int FRAMEWORKS_EXTENSION_LENGTH = 10; // strlen(".framework") | ||
37 | 35 | } | ||
38 | 31 | 36 | ||
39 | 32 | namespace UpdatePlugin { | 37 | namespace UpdatePlugin { |
40 | 33 | 38 | ||
41 | @@ -39,10 +44,55 @@ | |||
42 | 39 | this, SLOT(onReply(QNetworkReply*))); | 44 | this, SLOT(onReply(QNetworkReply*))); |
43 | 40 | } | 45 | } |
44 | 41 | 46 | ||
45 | 47 | std::string Network::getArchitecture() | ||
46 | 48 | { | ||
47 | 49 | static const std::string deb_arch {architectureFromDpkg()}; | ||
48 | 50 | return deb_arch; | ||
49 | 51 | } | ||
50 | 52 | |||
51 | 53 | std::vector<std::string> Network::getAvailableFrameworks() | ||
52 | 54 | { | ||
53 | 55 | std::vector<std::string> result; | ||
54 | 56 | for (auto f: listFolder(FRAMEWORKS_FOLDER, FRAMEWORKS_PATTERN)) { | ||
55 | 57 | result.push_back(f.substr(0, f.size()-FRAMEWORKS_EXTENSION_LENGTH)); | ||
56 | 58 | } | ||
57 | 59 | return result; | ||
58 | 60 | } | ||
59 | 61 | |||
60 | 62 | std::string Network::architectureFromDpkg() | ||
61 | 63 | { | ||
62 | 64 | QString program("dpkg"); | ||
63 | 65 | QStringList arguments; | ||
64 | 66 | arguments << "--print-architecture"; | ||
65 | 67 | QProcess archDetector; | ||
66 | 68 | archDetector.start(program, arguments); | ||
67 | 69 | if(!archDetector.waitForFinished()) { | ||
68 | 70 | qWarning() << "Architecture detection failed."; | ||
69 | 71 | } | ||
70 | 72 | auto output = archDetector.readAllStandardOutput(); | ||
71 | 73 | auto ostr = QString::fromUtf8(output); | ||
72 | 74 | |||
73 | 75 | return ostr.trimmed().toStdString(); | ||
74 | 76 | } | ||
75 | 77 | |||
76 | 78 | std::vector<std::string> Network::listFolder(const std::string& folder, const std::string& pattern) | ||
77 | 79 | { | ||
78 | 80 | std::vector<std::string> result; | ||
79 | 81 | |||
80 | 82 | QDir dir(QString::fromStdString(folder), QString::fromStdString(pattern), | ||
81 | 83 | QDir::Unsorted, QDir::Readable | QDir::Files); | ||
82 | 84 | QStringList entries = dir.entryList(); | ||
83 | 85 | for (int i = 0; i < entries.size(); ++i) { | ||
84 | 86 | QString filename = entries.at(i); | ||
85 | 87 | result.push_back(filename.toStdString()); | ||
86 | 88 | } | ||
87 | 89 | |||
88 | 90 | return result; | ||
89 | 91 | } | ||
90 | 92 | |||
91 | 42 | void Network::checkForNewVersions(QHash<QString, Update*> &apps) | 93 | void Network::checkForNewVersions(QHash<QString, Update*> &apps) |
92 | 43 | { | 94 | { |
93 | 44 | m_apps = apps; | 95 | m_apps = apps; |
94 | 45 | |||
95 | 46 | QJsonObject serializer; | 96 | QJsonObject serializer; |
96 | 47 | QJsonArray array; | 97 | QJsonArray array; |
97 | 48 | foreach(QString id, m_apps.keys()) { | 98 | foreach(QString id, m_apps.keys()) { |
98 | @@ -50,13 +100,18 @@ | |||
99 | 50 | } | 100 | } |
100 | 51 | 101 | ||
101 | 52 | serializer.insert("name", array); | 102 | serializer.insert("name", array); |
102 | 103 | std::stringstream frameworks; | ||
103 | 104 | for (auto f: getAvailableFrameworks()) { | ||
104 | 105 | frameworks << "," << f; | ||
105 | 106 | } | ||
106 | 53 | QJsonDocument doc(serializer); | 107 | QJsonDocument doc(serializer); |
107 | 54 | |||
108 | 55 | QByteArray content = doc.toJson(); | 108 | QByteArray content = doc.toJson(); |
109 | 56 | 109 | ||
110 | 57 | QString urlApps = getUrlApps(); | 110 | QString urlApps = getUrlApps(); |
111 | 58 | QNetworkRequest request; | 111 | QNetworkRequest request; |
112 | 59 | request.setHeader(QNetworkRequest::ContentTypeHeader, "application/json"); | 112 | request.setHeader(QNetworkRequest::ContentTypeHeader, "application/json"); |
113 | 113 | request.setRawHeader(QByteArray("X-Ubuntu-Frameworks"), QByteArray(frameworks.str().c_str())); | ||
114 | 114 | request.setRawHeader(QByteArray("X-Ubuntu-Architecture"), QByteArray(getArchitecture().c_str())); | ||
115 | 60 | request.setUrl(QUrl(urlApps)); | 115 | request.setUrl(QUrl(urlApps)); |
116 | 61 | RequestObject* reqObject = new RequestObject(QString(APPS_DATA)); | 116 | RequestObject* reqObject = new RequestObject(QString(APPS_DATA)); |
117 | 62 | request.setOriginatingObject(reqObject); | 117 | request.setOriginatingObject(reqObject); |
118 | 63 | 118 | ||
119 | === modified file 'plugins/system-update/network/network.h' | |||
120 | --- plugins/system-update/network/network.h 2014-10-07 17:50:03 +0000 | |||
121 | +++ plugins/system-update/network/network.h 2015-04-30 14:58:55 +0000 | |||
122 | @@ -51,6 +51,8 @@ | |||
123 | 51 | void checkForNewVersions(QHash<QString, Update*> &apps); | 51 | void checkForNewVersions(QHash<QString, Update*> &apps); |
124 | 52 | void getClickToken(Update *app, const QString &url, | 52 | void getClickToken(Update *app, const QString &url, |
125 | 53 | const QString &authHeader); | 53 | const QString &authHeader); |
126 | 54 | virtual std::vector<std::string> getAvailableFrameworks(); | ||
127 | 55 | virtual std::string getArchitecture(); | ||
128 | 54 | 56 | ||
129 | 55 | Q_SIGNALS: | 57 | Q_SIGNALS: |
130 | 56 | void updatesFound(); | 58 | void updatesFound(); |
131 | @@ -68,6 +70,11 @@ | |||
132 | 68 | QHash<QString, Update*> m_apps; | 70 | QHash<QString, Update*> m_apps; |
133 | 69 | 71 | ||
134 | 70 | QString getUrlApps(); | 72 | QString getUrlApps(); |
135 | 73 | |||
136 | 74 | protected: | ||
137 | 75 | virtual std::string architectureFromDpkg(); | ||
138 | 76 | virtual std::vector<std::string> listFolder(const std::string &folder, const std::string &pattern); | ||
139 | 77 | |||
140 | 71 | }; | 78 | }; |
141 | 72 | 79 | ||
142 | 73 | } | 80 | } |
143 | 74 | 81 | ||
144 | === modified file 'tests/plugins/system-update/CMakeLists.txt' | |||
145 | --- tests/plugins/system-update/CMakeLists.txt 2014-10-23 13:27:05 +0000 | |||
146 | +++ tests/plugins/system-update/CMakeLists.txt 2015-04-30 14:58:55 +0000 | |||
147 | @@ -25,6 +25,12 @@ | |||
148 | 25 | ../../../plugins/system-update/update.cpp | 25 | ../../../plugins/system-update/update.cpp |
149 | 26 | ) | 26 | ) |
150 | 27 | 27 | ||
151 | 28 | add_executable(tst-network | ||
152 | 29 | tst_network.cpp | ||
153 | 30 | ../../../plugins/system-update/update.cpp | ||
154 | 31 | ../../../plugins/system-update/network/network.cpp | ||
155 | 32 | ) | ||
156 | 33 | |||
157 | 28 | # set the path to the library folder | 34 | # set the path to the library folder |
158 | 29 | include_directories(/usr/include/apt-pkg/) | 35 | include_directories(/usr/include/apt-pkg/) |
159 | 30 | 36 | ||
160 | @@ -36,6 +42,10 @@ | |||
161 | 36 | target_link_libraries(tst-update apt-pkg update-plugin) | 42 | target_link_libraries(tst-update apt-pkg update-plugin) |
162 | 37 | add_test(NAME tst-update COMMAND ${XVFB_CMD} ${CMAKE_CURRENT_BINARY_DIR}/tst-update) | 43 | add_test(NAME tst-update COMMAND ${XVFB_CMD} ${CMAKE_CURRENT_BINARY_DIR}/tst-update) |
163 | 38 | 44 | ||
164 | 45 | qt5_use_modules(tst-network Qml Quick Core DBus Xml Network Test) | ||
165 | 46 | target_link_libraries(tst-network apt-pkg update-plugin) | ||
166 | 47 | add_test(NAME tst-network COMMAND ${XVFB_CMD} ${CMAKE_CURRENT_BINARY_DIR}/tst-network) | ||
167 | 48 | |||
168 | 39 | add_custom_command( | 49 | add_custom_command( |
169 | 40 | TARGET tst-update-manager | 50 | TARGET tst-update-manager |
170 | 41 | COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_LIST_DIR}/click.result ${CMAKE_CURRENT_BINARY_DIR}/click.result | 51 | COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_LIST_DIR}/click.result ${CMAKE_CURRENT_BINARY_DIR}/click.result |
171 | 42 | 52 | ||
172 | === added file 'tests/plugins/system-update/tst_network.cpp' | |||
173 | --- tests/plugins/system-update/tst_network.cpp 1970-01-01 00:00:00 +0000 | |||
174 | +++ tests/plugins/system-update/tst_network.cpp 2015-04-30 14:58:55 +0000 | |||
175 | @@ -0,0 +1,58 @@ | |||
176 | 1 | /* | ||
177 | 2 | * This file is part of system-settings | ||
178 | 3 | * | ||
179 | 4 | * Copyright (C) 2015 Canonical Ltd. | ||
180 | 5 | * | ||
181 | 6 | * This program is free software: you can redistribute it and/or modify it | ||
182 | 7 | * under the terms of the GNU General Public License version 3, as published | ||
183 | 8 | * by the Free Software Foundation. | ||
184 | 9 | * | ||
185 | 10 | * This program is distributed in the hope that it will be useful, but | ||
186 | 11 | * WITHOUT ANY WARRANTY; without even the implied warranties of | ||
187 | 12 | * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR | ||
188 | 13 | * PURPOSE. See the GNU General Public License for more details. | ||
189 | 14 | * | ||
190 | 15 | * You should have received a copy of the GNU General Public License along | ||
191 | 16 | * with this program. If not, see <http://www.gnu.org/licenses/>. | ||
192 | 17 | */ | ||
193 | 18 | |||
194 | 19 | #include <QDebug> | ||
195 | 20 | #include <QtQml> | ||
196 | 21 | #include <QtQml/QQmlContext> | ||
197 | 22 | #include <QObject> | ||
198 | 23 | #include <QTest> | ||
199 | 24 | #include <QString> | ||
200 | 25 | #include "network/network.h" | ||
201 | 26 | #include "update.h" | ||
202 | 27 | |||
203 | 28 | using namespace UpdatePlugin; | ||
204 | 29 | |||
205 | 30 | class NetworkTest: public QObject | ||
206 | 31 | { | ||
207 | 32 | Q_OBJECT | ||
208 | 33 | |||
209 | 34 | public: | ||
210 | 35 | NetworkTest() {}; | ||
211 | 36 | |||
212 | 37 | private Q_SLOTS: | ||
213 | 38 | void testArch(); | ||
214 | 39 | void testFrameworks(); | ||
215 | 40 | |||
216 | 41 | }; | ||
217 | 42 | |||
218 | 43 | void NetworkTest::testFrameworks() | ||
219 | 44 | { | ||
220 | 45 | Network net; | ||
221 | 46 | auto frameworks = net.getAvailableFrameworks(); | ||
222 | 47 | QCOMPARE(frameworks.empty(), false); | ||
223 | 48 | } | ||
224 | 49 | |||
225 | 50 | void NetworkTest::testArch() | ||
226 | 51 | { | ||
227 | 52 | Network net; | ||
228 | 53 | auto arch = net.getArchitecture(); | ||
229 | 54 | QCOMPARE(arch.empty(), false); | ||
230 | 55 | } | ||
231 | 56 | |||
232 | 57 | QTEST_MAIN(NetworkTest) | ||
233 | 58 | #include "tst_network.moc" |
FAILED: Continuous integration, rev:1013 jenkins. qa.ubuntu. com/job/ ubuntu- system- settings- rtm-14. 09-ci/75/ jenkins. qa.ubuntu. com/job/ generic- deb-autopilot- 14.09-touch/ 54 jenkins. qa.ubuntu. com/job/ ubuntu- system- settings- rtm-14. 09-14.09- armhf-ci/ 76 jenkins. qa.ubuntu. com/job/ ubuntu- system- settings- rtm-14. 09-14.09- armhf-ci/ 76/artifact/ work/output/ *zip*/output. zip jenkins. qa.ubuntu. com/job/ generic- deb-autopilot- runner- 14.09-mako/ 55 jenkins. qa.ubuntu. com/job/ generic- mediumtests- builder- 14.09-armhf/ 54 jenkins. qa.ubuntu. com/job/ generic- mediumtests- builder- 14.09-armhf/ 54/artifact/ work/output/ *zip*/output. zip s-jenkins. ubuntu- ci:8080/ job/touch- flash-device/ 20026
http://
Executed test runs:
UNSTABLE: http://
SUCCESS: http://
deb: http://
UNSTABLE: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild: s-jenkins. ubuntu- ci:8080/ job/ubuntu- system- settings- rtm-14. 09-ci/75/ rebuild
http://