Merge lp:~ted/ubuntu-app-launch/relax-icon-rules into lp:ubuntu-app-launch/16.10
- relax-icon-rules
- Merge into trunk.16.10
Status: | Merged |
---|---|
Approved by: | Marcus Tomlinson |
Approved revision: | 255 |
Merged at revision: | 259 |
Proposed branch: | lp:~ted/ubuntu-app-launch/relax-icon-rules |
Merge into: | lp:ubuntu-app-launch/16.10 |
Prerequisite: | lp:~ted/ubuntu-app-launch/icon-basepath |
Diff against target: |
540 lines (+211/-121) 4 files modified
libubuntu-app-launch/application-info-desktop.cpp (+62/-29) libubuntu-app-launch/application-info-desktop.h (+1/-1) tests/CMakeLists.txt (+1/-0) tests/application-info-desktop.cpp (+147/-91) |
To merge this branch: | bzr merge lp:~ted/ubuntu-app-launch/relax-icon-rules |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Marcus Tomlinson (community) | Approve | ||
unity-api-1-bot | continuous-integration | Approve | |
Review via email: mp+305736@code.launchpad.net |
Commit message
Don't throw an exception when a Desktop file fails to include an Icon key
Description of the change
This branch changes the handling of the Icon key in desktop files but has two cleanups as well.
It changes the desktop helper functions to have a normal and a "Required" version to try and make the differences more clear on whether it'll throw an exception or not.
It does automatic code formatting on the application-
unity-api-1-bot (unity-api-1-bot) wrote : | # |
Marcus Tomlinson (marcustomlinson) wrote : | # |
Again, outstanding commitment to testing.
Diff looks alright, but I'm getting a 404 when trying to download the build artefacts, so I've hit rebuild. Will come back to test in a bit.
unity-api-1-bot (unity-api-1-bot) wrote : | # |
PASSED: Continuous integration, rev:255
https:/
Executed test runs:
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
Click here to trigger a rebuild:
https:/
Marcus Tomlinson (marcustomlinson) wrote : | # |
Cool, confirmed this fixes the bug. +1
Preview Diff
1 | === modified file 'libubuntu-app-launch/application-info-desktop.cpp' |
2 | --- libubuntu-app-launch/application-info-desktop.cpp 2016-09-14 16:48:27 +0000 |
3 | +++ libubuntu-app-launch/application-info-desktop.cpp 2016-09-14 16:48:28 +0000 |
4 | @@ -43,8 +43,9 @@ |
5 | } // anonymous namespace |
6 | |
7 | template <typename T> |
8 | -auto stringFromKeyfile(std::shared_ptr<GKeyFile> keyfile, const std::string& key, const std::string& exceptionText = {}) |
9 | - -> T |
10 | +auto stringFromKeyfileRequired(const std::shared_ptr<GKeyFile>& keyfile, |
11 | + const std::string& key, |
12 | + const std::string& exceptionText) -> T |
13 | { |
14 | GError* error = nullptr; |
15 | auto keyval = g_key_file_get_locale_string(keyfile.get(), DESKTOP_GROUP, key.c_str(), nullptr, &error); |
16 | @@ -66,11 +67,17 @@ |
17 | } |
18 | |
19 | template <typename T> |
20 | -auto fileFromKeyfile(std::shared_ptr<GKeyFile> keyfile, |
21 | - const std::string& basePath, |
22 | - const std::string& rootDir, |
23 | - const std::string& key, |
24 | - const std::string& exceptionText = {}) -> T |
25 | +auto stringFromKeyfile(const std::shared_ptr<GKeyFile>& keyfile, const std::string& key) -> T |
26 | +{ |
27 | + return stringFromKeyfileRequired<T>(keyfile, key, {}); |
28 | +} |
29 | + |
30 | +template <typename T> |
31 | +auto fileFromKeyfileRequired(const std::shared_ptr<GKeyFile>& keyfile, |
32 | + const std::string& basePath, |
33 | + const std::string& rootDir, |
34 | + const std::string& key, |
35 | + const std::string& exceptionText) -> T |
36 | { |
37 | GError* error = nullptr; |
38 | auto keyval = g_key_file_get_locale_string(keyfile.get(), DESKTOP_GROUP, key.c_str(), nullptr, &error); |
39 | @@ -113,10 +120,18 @@ |
40 | } |
41 | |
42 | template <typename T> |
43 | -auto boolFromKeyfile(std::shared_ptr<GKeyFile> keyfile, |
44 | - const std::string& key, |
45 | - bool defaultReturn, |
46 | - const std::string& exceptionText = {}) -> T |
47 | +auto fileFromKeyfile(const std::shared_ptr<GKeyFile>& keyfile, |
48 | + const std::string& basePath, |
49 | + const std::string& rootDir, |
50 | + const std::string& key) -> T |
51 | +{ |
52 | + return fileFromKeyfileRequired<T>(keyfile, basePath, rootDir, key, {}); |
53 | +} |
54 | + |
55 | +template <typename T> |
56 | +auto boolFromKeyfileRequired(const std::shared_ptr<GKeyFile>& keyfile, |
57 | + const std::string& key, |
58 | + const std::string& exceptionText) -> T |
59 | { |
60 | GError* error = nullptr; |
61 | auto keyval = g_key_file_get_boolean(keyfile.get(), DESKTOP_GROUP, key.c_str(), &error); |
62 | @@ -124,21 +139,30 @@ |
63 | if (error != nullptr) |
64 | { |
65 | auto perror = std::shared_ptr<GError>(error, g_error_free); |
66 | - if (!exceptionText.empty()) |
67 | - { |
68 | - throw std::runtime_error(exceptionText + perror.get()->message); |
69 | - } |
70 | - |
71 | + throw std::runtime_error(exceptionText + perror.get()->message); |
72 | + } |
73 | + |
74 | + T retval = T::from_raw(keyval == TRUE); |
75 | + return retval; |
76 | +} |
77 | + |
78 | +template <typename T> |
79 | +auto boolFromKeyfile(const std::shared_ptr<GKeyFile>& keyfile, const std::string& key, bool defaultReturn) -> T |
80 | +{ |
81 | + try |
82 | + { |
83 | + return boolFromKeyfileRequired<T>(keyfile, key, "Boolean value not available, but not required"); |
84 | + } |
85 | + catch (std::runtime_error& e) |
86 | + { |
87 | return T::from_raw(defaultReturn); |
88 | } |
89 | - |
90 | - T retval = T::from_raw(keyval == TRUE); |
91 | - return retval; |
92 | } |
93 | |
94 | template <typename T> |
95 | -auto stringlistFromKeyfile(std::shared_ptr<GKeyFile> keyfile, const gchar* key, const std::string& exceptionText = {}) |
96 | - -> T |
97 | +auto stringlistFromKeyfileRequired(const std::shared_ptr<GKeyFile>& keyfile, |
98 | + const gchar* key, |
99 | + const std::string& exceptionText) -> T |
100 | { |
101 | GError* error = nullptr; |
102 | auto keyval = g_key_file_get_locale_string_list(keyfile.get(), DESKTOP_GROUP, key, nullptr, nullptr, &error); |
103 | @@ -167,7 +191,13 @@ |
104 | return T::from_raw(results); |
105 | } |
106 | |
107 | -bool stringlistFromKeyfileContains(std::shared_ptr<GKeyFile> keyfile, |
108 | +template <typename T> |
109 | +auto stringlistFromKeyfile(const std::shared_ptr<GKeyFile>& keyfile, const gchar* key) -> T |
110 | +{ |
111 | + return stringlistFromKeyfileRequired<T>(keyfile, key, {}); |
112 | +} |
113 | + |
114 | +bool stringlistFromKeyfileContains(const std::shared_ptr<GKeyFile>& keyfile, |
115 | const gchar* key, |
116 | const std::string& match, |
117 | bool defaultValue) |
118 | @@ -194,7 +224,7 @@ |
119 | return result; |
120 | } |
121 | |
122 | -Desktop::Desktop(std::shared_ptr<GKeyFile> keyfile, |
123 | +Desktop::Desktop(const std::shared_ptr<GKeyFile>& keyfile, |
124 | const std::string& basePath, |
125 | const std::string& rootDir, |
126 | std::bitset<2> flags, |
127 | @@ -233,17 +263,20 @@ |
128 | }()) |
129 | , _basePath(basePath) |
130 | , _rootDir(rootDir) |
131 | - , _name(stringFromKeyfile<Application::Info::Name>(keyfile, "Name", "Unable to get name from keyfile")) |
132 | + , _name(stringFromKeyfileRequired<Application::Info::Name>(keyfile, "Name", "Unable to get name from keyfile")) |
133 | , _description(stringFromKeyfile<Application::Info::Description>(keyfile, "Comment")) |
134 | , _iconPath([keyfile, basePath, rootDir, registry]() { |
135 | if (registry != nullptr) |
136 | { |
137 | - auto iconName = |
138 | - stringFromKeyfile<Application::Info::IconPath>(keyfile, "Icon", "Missing icon for desktop file"); |
139 | - return registry->impl->getIconFinder(basePath)->find(iconName); |
140 | + auto iconName = stringFromKeyfile<Application::Info::IconPath>(keyfile, "Icon"); |
141 | + |
142 | + if (!iconName.value().empty() && iconName.value()[0] != '/') |
143 | + { |
144 | + /* If it is not a direct filename look it up */ |
145 | + return registry->impl->getIconFinder(basePath)->find(iconName); |
146 | + } |
147 | } |
148 | - return fileFromKeyfile<Application::Info::IconPath>(keyfile, basePath, rootDir, "Icon", |
149 | - "Missing icon for desktop file"); |
150 | + return fileFromKeyfile<Application::Info::IconPath>(keyfile, basePath, rootDir, "Icon"); |
151 | }()) |
152 | , _defaultDepartment( |
153 | stringFromKeyfile<Application::Info::DefaultDepartment>(keyfile, "X-Ubuntu-Default-Department-ID")) |
154 | |
155 | === modified file 'libubuntu-app-launch/application-info-desktop.h' |
156 | --- libubuntu-app-launch/application-info-desktop.h 2016-09-14 16:48:27 +0000 |
157 | +++ libubuntu-app-launch/application-info-desktop.h 2016-09-14 16:48:28 +0000 |
158 | @@ -41,7 +41,7 @@ |
159 | class Desktop : public Application::Info |
160 | { |
161 | public: |
162 | - Desktop(std::shared_ptr<GKeyFile> keyfile, |
163 | + Desktop(const std::shared_ptr<GKeyFile>& keyfile, |
164 | const std::string& basePath, |
165 | const std::string& rootDir, |
166 | std::bitset<2> flags, |
167 | |
168 | === modified file 'tests/CMakeLists.txt' |
169 | --- tests/CMakeLists.txt 2016-09-14 16:48:27 +0000 |
170 | +++ tests/CMakeLists.txt 2016-09-14 16:48:28 +0000 |
171 | @@ -157,6 +157,7 @@ |
172 | |
173 | add_custom_target(format-tests |
174 | COMMAND clang-format -i -style=file |
175 | + application-info-desktop.cpp |
176 | libual-cpp-test.cc |
177 | list-apps.cpp |
178 | eventually-fixture.h |
179 | |
180 | === modified file 'tests/application-info-desktop.cpp' |
181 | --- tests/application-info-desktop.cpp 2016-09-14 16:48:27 +0000 |
182 | +++ tests/application-info-desktop.cpp 2016-09-14 16:48:28 +0000 |
183 | @@ -19,8 +19,8 @@ |
184 | |
185 | #include "application-info-desktop.h" |
186 | |
187 | +#include <cstdlib> |
188 | #include <gtest/gtest.h> |
189 | -#include <cstdlib> |
190 | |
191 | namespace |
192 | { |
193 | @@ -30,7 +30,7 @@ |
194 | { |
195 | protected: |
196 | ApplicationInfoDesktop() |
197 | - : test_dekstop_env("SomeFreeDesktop") |
198 | + : test_dekstop_env("SomeFreeDesktop") |
199 | { |
200 | } |
201 | |
202 | @@ -56,10 +56,10 @@ |
203 | const std::string test_dekstop_env; |
204 | }; |
205 | |
206 | - |
207 | TEST_F(ApplicationInfoDesktop, DefaultState) |
208 | { |
209 | - auto appinfo = ubuntu::app_launch::app_info::Desktop(defaultKeyfile(), "/", {}, ubuntu::app_launch::app_info::DesktopFlags::NONE, nullptr); |
210 | + auto appinfo = ubuntu::app_launch::app_info::Desktop(defaultKeyfile(), "/", {}, |
211 | + ubuntu::app_launch::app_info::DesktopFlags::NONE, nullptr); |
212 | |
213 | EXPECT_EQ("Foo App", appinfo.name().value()); |
214 | EXPECT_EQ("", appinfo.description().value()); |
215 | @@ -71,7 +71,7 @@ |
216 | EXPECT_EQ("", appinfo.splash().backgroundColor.value()); |
217 | EXPECT_EQ("", appinfo.splash().headerColor.value()); |
218 | EXPECT_EQ("", appinfo.splash().footerColor.value()); |
219 | - EXPECT_FALSE( appinfo.splash().showHeader.value()); |
220 | + EXPECT_FALSE(appinfo.splash().showHeader.value()); |
221 | |
222 | EXPECT_TRUE(appinfo.supportedOrientations().portrait); |
223 | EXPECT_TRUE(appinfo.supportedOrientations().landscape); |
224 | @@ -86,35 +86,41 @@ |
225 | TEST_F(ApplicationInfoDesktop, KeyfileErrors) |
226 | { |
227 | // empty |
228 | - EXPECT_THROW(ubuntu::app_launch::app_info::Desktop({}, "/", {}, ubuntu::app_launch::app_info::DesktopFlags::NONE, nullptr), std::runtime_error); |
229 | + EXPECT_THROW( |
230 | + ubuntu::app_launch::app_info::Desktop({}, "/", {}, ubuntu::app_launch::app_info::DesktopFlags::NONE, nullptr), |
231 | + std::runtime_error); |
232 | |
233 | // empty name |
234 | auto noname = defaultKeyfile(); |
235 | g_key_file_remove_key(noname.get(), DESKTOP, "Name", nullptr); |
236 | - EXPECT_THROW(ubuntu::app_launch::app_info::Desktop(noname, "/", {}, ubuntu::app_launch::app_info::DesktopFlags::NONE, nullptr), std::runtime_error); |
237 | - |
238 | - // empty icon |
239 | - auto noicon = defaultKeyfile(); |
240 | - g_key_file_remove_key(noicon.get(), DESKTOP, "Icon", nullptr); |
241 | - EXPECT_THROW(ubuntu::app_launch::app_info::Desktop(noicon, "/", {}, ubuntu::app_launch::app_info::DesktopFlags::NONE, nullptr), std::runtime_error); |
242 | + EXPECT_THROW(ubuntu::app_launch::app_info::Desktop(noname, "/", {}, |
243 | + ubuntu::app_launch::app_info::DesktopFlags::NONE, nullptr), |
244 | + std::runtime_error); |
245 | |
246 | // wrong type |
247 | auto wrongtype = defaultKeyfile(); |
248 | g_key_file_set_string(wrongtype.get(), DESKTOP, "Type", "MimeType"); |
249 | - EXPECT_THROW(ubuntu::app_launch::app_info::Desktop(wrongtype, "/", {}, ubuntu::app_launch::app_info::DesktopFlags::NONE, nullptr), std::runtime_error); |
250 | + EXPECT_THROW(ubuntu::app_launch::app_info::Desktop(wrongtype, "/", {}, |
251 | + ubuntu::app_launch::app_info::DesktopFlags::NONE, nullptr), |
252 | + std::runtime_error); |
253 | |
254 | // not displayable |
255 | auto nodisplay = defaultKeyfile(); |
256 | g_key_file_set_boolean(nodisplay.get(), DESKTOP, "NoDisplay", TRUE); |
257 | - EXPECT_THROW(ubuntu::app_launch::app_info::Desktop(nodisplay, "/", {}, ubuntu::app_launch::app_info::DesktopFlags::NONE, nullptr), std::runtime_error); |
258 | - EXPECT_NO_THROW(ubuntu::app_launch::app_info::Desktop(nodisplay, "/", {}, ubuntu::app_launch::app_info::DesktopFlags::ALLOW_NO_DISPLAY, nullptr)); |
259 | + EXPECT_THROW(ubuntu::app_launch::app_info::Desktop(nodisplay, "/", {}, |
260 | + ubuntu::app_launch::app_info::DesktopFlags::NONE, nullptr), |
261 | + std::runtime_error); |
262 | + EXPECT_NO_THROW(ubuntu::app_launch::app_info::Desktop( |
263 | + nodisplay, "/", {}, ubuntu::app_launch::app_info::DesktopFlags::ALLOW_NO_DISPLAY, nullptr)); |
264 | |
265 | // hidden |
266 | auto hidden = defaultKeyfile(); |
267 | g_key_file_set_string(hidden.get(), DESKTOP, "Hidden", "true"); |
268 | - EXPECT_THROW(ubuntu::app_launch::app_info::Desktop(hidden, "/", {}, ubuntu::app_launch::app_info::DesktopFlags::NONE, nullptr), std::runtime_error); |
269 | + EXPECT_THROW(ubuntu::app_launch::app_info::Desktop(hidden, "/", {}, |
270 | + ubuntu::app_launch::app_info::DesktopFlags::NONE, nullptr), |
271 | + std::runtime_error); |
272 | |
273 | - /* Disabling for OTA11 */ |
274 | +/* Disabling for OTA11 */ |
275 | #if 0 |
276 | // not shown in Unity |
277 | auto notshowin = defaultKeyfile(); |
278 | @@ -134,12 +140,14 @@ |
279 | std::string datadir = "/foo/usr/share"; |
280 | std::string basedir = "/foo"; |
281 | |
282 | - auto defappinfo = ubuntu::app_launch::app_info::Desktop(defkeyfile, datadir, basedir, ubuntu::app_launch::app_info::DesktopFlags::NONE, nullptr); |
283 | + auto defappinfo = ubuntu::app_launch::app_info::Desktop(defkeyfile, datadir, basedir, |
284 | + ubuntu::app_launch::app_info::DesktopFlags::NONE, nullptr); |
285 | EXPECT_EQ("/foo/usr/share/foo.png", defappinfo.iconPath().value()); |
286 | |
287 | auto rootkeyfile = defaultKeyfile(); |
288 | g_key_file_set_string(rootkeyfile.get(), DESKTOP, "Icon", "/bar/foo.png"); |
289 | - auto rootappinfo = ubuntu::app_launch::app_info::Desktop(rootkeyfile, datadir, basedir, ubuntu::app_launch::app_info::DesktopFlags::NONE, nullptr); |
290 | + auto rootappinfo = ubuntu::app_launch::app_info::Desktop(rootkeyfile, datadir, basedir, |
291 | + ubuntu::app_launch::app_info::DesktopFlags::NONE, nullptr); |
292 | EXPECT_EQ("/foo/bar/foo.png", rootappinfo.iconPath().value()); |
293 | } |
294 | |
295 | @@ -147,125 +155,173 @@ |
296 | { |
297 | auto keyfile = defaultKeyfile(); |
298 | g_key_file_set_string(keyfile.get(), DESKTOP, "X-Ubuntu-Default-Department-ID", "foo"); |
299 | - EXPECT_NO_THROW(ubuntu::app_launch::app_info::Desktop(keyfile, "/", {}, ubuntu::app_launch::app_info::DesktopFlags::NONE, nullptr)); |
300 | + EXPECT_NO_THROW(ubuntu::app_launch::app_info::Desktop(keyfile, "/", {}, |
301 | + ubuntu::app_launch::app_info::DesktopFlags::NONE, nullptr)); |
302 | } |
303 | |
304 | TEST_F(ApplicationInfoDesktop, KeyfileScreenshotPath) |
305 | { |
306 | auto keyfile = defaultKeyfile(); |
307 | g_key_file_set_string(keyfile.get(), DESKTOP, "X-Screenshot", "foo.png"); |
308 | - EXPECT_EQ("/foo.png", ubuntu::app_launch::app_info::Desktop(keyfile, "/", {}, ubuntu::app_launch::app_info::DesktopFlags::NONE, nullptr).screenshotPath().value()); |
309 | + EXPECT_EQ("/foo.png", ubuntu::app_launch::app_info::Desktop( |
310 | + keyfile, "/", {}, ubuntu::app_launch::app_info::DesktopFlags::NONE, nullptr) |
311 | + .screenshotPath() |
312 | + .value()); |
313 | } |
314 | |
315 | TEST_F(ApplicationInfoDesktop, KeyfileKeywords) |
316 | { |
317 | - std::vector<std::string>expectedKeywords{"foo", "bar", "baz"}; |
318 | + std::vector<std::string> expectedKeywords{"foo", "bar", "baz"}; |
319 | |
320 | auto keyfile = defaultKeyfile(); |
321 | g_key_file_set_string(keyfile.get(), DESKTOP, "Keywords", "foo;bar;baz;"); |
322 | - EXPECT_EQ(expectedKeywords, ubuntu::app_launch::app_info::Desktop(keyfile, "/", {}, ubuntu::app_launch::app_info::DesktopFlags::NONE, nullptr).keywords().value()); |
323 | + EXPECT_EQ(expectedKeywords, ubuntu::app_launch::app_info::Desktop( |
324 | + keyfile, "/", {}, ubuntu::app_launch::app_info::DesktopFlags::NONE, nullptr) |
325 | + .keywords() |
326 | + .value()); |
327 | } |
328 | |
329 | TEST_F(ApplicationInfoDesktop, KeyfileShowListEdgeCases) |
330 | { |
331 | - // Not appearing in not show list |
332 | - auto notshowin = defaultKeyfile(); |
333 | - g_key_file_set_string(notshowin.get(), DESKTOP, "NotShowIn", "Gnome;KDE;"); |
334 | - EXPECT_NO_THROW(ubuntu::app_launch::app_info::Desktop(notshowin, "/", {}, ubuntu::app_launch::app_info::DesktopFlags::NONE, nullptr)); |
335 | - |
336 | - // Appearing explicitly in only show list |
337 | - auto onlyshowin = defaultKeyfile(); |
338 | - g_key_file_set_string(onlyshowin.get(), DESKTOP, "OnlyShowIn", (test_dekstop_env + ";Gnome;").c_str()); |
339 | - EXPECT_NO_THROW(ubuntu::app_launch::app_info::Desktop(onlyshowin, "/", {}, ubuntu::app_launch::app_info::DesktopFlags::NONE, nullptr)); |
340 | - |
341 | - // Appearing explicitly in only show list not first |
342 | - auto onlyshowinmiddle = defaultKeyfile(); |
343 | - g_key_file_set_string(onlyshowinmiddle.get(), DESKTOP, "OnlyShowIn", ("Gnome;" + test_dekstop_env + ";KDE;").c_str()); |
344 | - EXPECT_NO_THROW(ubuntu::app_launch::app_info::Desktop(onlyshowinmiddle, "/", {}, ubuntu::app_launch::app_info::DesktopFlags::NONE, nullptr)); |
345 | + // Not appearing in not show list |
346 | + auto notshowin = defaultKeyfile(); |
347 | + g_key_file_set_string(notshowin.get(), DESKTOP, "NotShowIn", "Gnome;KDE;"); |
348 | + EXPECT_NO_THROW(ubuntu::app_launch::app_info::Desktop(notshowin, "/", {}, |
349 | + ubuntu::app_launch::app_info::DesktopFlags::NONE, nullptr)); |
350 | + |
351 | + // Appearing explicitly in only show list |
352 | + auto onlyshowin = defaultKeyfile(); |
353 | + g_key_file_set_string(onlyshowin.get(), DESKTOP, "OnlyShowIn", (test_dekstop_env + ";Gnome;").c_str()); |
354 | + EXPECT_NO_THROW(ubuntu::app_launch::app_info::Desktop(onlyshowin, "/", {}, |
355 | + ubuntu::app_launch::app_info::DesktopFlags::NONE, nullptr)); |
356 | + |
357 | + // Appearing explicitly in only show list not first |
358 | + auto onlyshowinmiddle = defaultKeyfile(); |
359 | + g_key_file_set_string(onlyshowinmiddle.get(), DESKTOP, "OnlyShowIn", |
360 | + ("Gnome;" + test_dekstop_env + ";KDE;").c_str()); |
361 | + EXPECT_NO_THROW(ubuntu::app_launch::app_info::Desktop(onlyshowinmiddle, "/", {}, |
362 | + ubuntu::app_launch::app_info::DesktopFlags::NONE, nullptr)); |
363 | } |
364 | |
365 | TEST_F(ApplicationInfoDesktop, Orientations) |
366 | { |
367 | ubuntu::app_launch::Application::Info::Orientations defaultOrientations = |
368 | - { |
369 | -portrait: |
370 | - true, |
371 | -landscape: |
372 | - true, |
373 | -invertedPortrait: |
374 | - true, |
375 | -invertedLandscape: |
376 | - true |
377 | - }; |
378 | + {portrait : true, landscape : true, invertedPortrait : true, invertedLandscape : true}; |
379 | |
380 | auto keyfile = defaultKeyfile(); |
381 | |
382 | - EXPECT_EQ(defaultOrientations, ubuntu::app_launch::app_info::Desktop(keyfile, "/", {}, ubuntu::app_launch::app_info::DesktopFlags::NONE, nullptr).supportedOrientations()); |
383 | + EXPECT_EQ(defaultOrientations, ubuntu::app_launch::app_info::Desktop( |
384 | + keyfile, "/", {}, ubuntu::app_launch::app_info::DesktopFlags::NONE, nullptr) |
385 | + .supportedOrientations()); |
386 | |
387 | g_key_file_set_string(keyfile.get(), DESKTOP, "X-Ubuntu-Supported-Orientations", "this should not parse"); |
388 | - EXPECT_EQ(defaultOrientations, ubuntu::app_launch::app_info::Desktop(keyfile, "/", {}, ubuntu::app_launch::app_info::DesktopFlags::NONE, nullptr).supportedOrientations()); |
389 | + EXPECT_EQ(defaultOrientations, ubuntu::app_launch::app_info::Desktop( |
390 | + keyfile, "/", {}, ubuntu::app_launch::app_info::DesktopFlags::NONE, nullptr) |
391 | + .supportedOrientations()); |
392 | |
393 | g_key_file_set_string(keyfile.get(), DESKTOP, "X-Ubuntu-Supported-Orientations", "this;should;not;parse;"); |
394 | - EXPECT_EQ(defaultOrientations, ubuntu::app_launch::app_info::Desktop(keyfile, "/", {}, ubuntu::app_launch::app_info::DesktopFlags::NONE, nullptr).supportedOrientations()); |
395 | + EXPECT_EQ(defaultOrientations, ubuntu::app_launch::app_info::Desktop( |
396 | + keyfile, "/", {}, ubuntu::app_launch::app_info::DesktopFlags::NONE, nullptr) |
397 | + .supportedOrientations()); |
398 | |
399 | g_key_file_set_string(keyfile.get(), DESKTOP, "X-Ubuntu-Supported-Orientations", "portrait;"); |
400 | - EXPECT_EQ((ubuntu::app_launch::Application::Info::Orientations {portrait: true, landscape: false, invertedPortrait: false, invertedLandscape: false}), |
401 | - ubuntu::app_launch::app_info::Desktop(keyfile, "/", {}, ubuntu::app_launch::app_info::DesktopFlags::NONE, nullptr).supportedOrientations()); |
402 | + EXPECT_EQ((ubuntu::app_launch::Application::Info:: |
403 | + Orientations{portrait : true, landscape : false, invertedPortrait : false, invertedLandscape : false}), |
404 | + ubuntu::app_launch::app_info::Desktop(keyfile, "/", {}, ubuntu::app_launch::app_info::DesktopFlags::NONE, |
405 | + nullptr) |
406 | + .supportedOrientations()); |
407 | |
408 | g_key_file_set_string(keyfile.get(), DESKTOP, "X-Ubuntu-Supported-Orientations", "landscape;portrait;"); |
409 | - EXPECT_EQ((ubuntu::app_launch::Application::Info::Orientations {portrait: true, landscape: true, invertedPortrait: false, invertedLandscape: false}), |
410 | - ubuntu::app_launch::app_info::Desktop(keyfile, "/", {}, ubuntu::app_launch::app_info::DesktopFlags::NONE, nullptr).supportedOrientations()); |
411 | + EXPECT_EQ((ubuntu::app_launch::Application::Info:: |
412 | + Orientations{portrait : true, landscape : true, invertedPortrait : false, invertedLandscape : false}), |
413 | + ubuntu::app_launch::app_info::Desktop(keyfile, "/", {}, ubuntu::app_launch::app_info::DesktopFlags::NONE, |
414 | + nullptr) |
415 | + .supportedOrientations()); |
416 | |
417 | - g_key_file_set_string(keyfile.get(), DESKTOP, "X-Ubuntu-Supported-Orientations", "landscape ; portrait; invertedPortrait"); |
418 | - EXPECT_EQ((ubuntu::app_launch::Application::Info::Orientations {portrait: true, landscape: true, invertedPortrait: true, invertedLandscape: false}), |
419 | - ubuntu::app_launch::app_info::Desktop(keyfile, "/", {}, ubuntu::app_launch::app_info::DesktopFlags::NONE, nullptr).supportedOrientations()); |
420 | + g_key_file_set_string(keyfile.get(), DESKTOP, "X-Ubuntu-Supported-Orientations", |
421 | + "landscape ; portrait; invertedPortrait"); |
422 | + EXPECT_EQ((ubuntu::app_launch::Application::Info:: |
423 | + Orientations{portrait : true, landscape : true, invertedPortrait : true, invertedLandscape : false}), |
424 | + ubuntu::app_launch::app_info::Desktop(keyfile, "/", {}, ubuntu::app_launch::app_info::DesktopFlags::NONE, |
425 | + nullptr) |
426 | + .supportedOrientations()); |
427 | |
428 | g_key_file_set_string(keyfile.get(), DESKTOP, "X-Ubuntu-Supported-Orientations", "portrait;landscape;"); |
429 | - EXPECT_EQ((ubuntu::app_launch::Application::Info::Orientations {portrait: true, landscape: true, invertedPortrait: false, invertedLandscape: false}), |
430 | - ubuntu::app_launch::app_info::Desktop(keyfile, "/", {}, ubuntu::app_launch::app_info::DesktopFlags::NONE, nullptr).supportedOrientations()); |
431 | + EXPECT_EQ((ubuntu::app_launch::Application::Info:: |
432 | + Orientations{portrait : true, landscape : true, invertedPortrait : false, invertedLandscape : false}), |
433 | + ubuntu::app_launch::app_info::Desktop(keyfile, "/", {}, ubuntu::app_launch::app_info::DesktopFlags::NONE, |
434 | + nullptr) |
435 | + .supportedOrientations()); |
436 | |
437 | - g_key_file_set_string(keyfile.get(), DESKTOP, "X-Ubuntu-Supported-Orientations", "portrait;landscape;invertedportrait;invertedlandscape;"); |
438 | - EXPECT_EQ((ubuntu::app_launch::Application::Info::Orientations {portrait: true, landscape: true, invertedPortrait: true, invertedLandscape: true}), |
439 | - ubuntu::app_launch::app_info::Desktop(keyfile, "/", {}, ubuntu::app_launch::app_info::DesktopFlags::NONE, nullptr).supportedOrientations()); |
440 | + g_key_file_set_string(keyfile.get(), DESKTOP, "X-Ubuntu-Supported-Orientations", |
441 | + "portrait;landscape;invertedportrait;invertedlandscape;"); |
442 | + EXPECT_EQ((ubuntu::app_launch::Application::Info:: |
443 | + Orientations{portrait : true, landscape : true, invertedPortrait : true, invertedLandscape : true}), |
444 | + ubuntu::app_launch::app_info::Desktop(keyfile, "/", {}, ubuntu::app_launch::app_info::DesktopFlags::NONE, |
445 | + nullptr) |
446 | + .supportedOrientations()); |
447 | |
448 | g_key_file_set_string(keyfile.get(), DESKTOP, "X-Ubuntu-Supported-Orientations", "PORTRAIT;"); |
449 | - EXPECT_EQ((ubuntu::app_launch::Application::Info::Orientations {portrait: true, landscape: false, invertedPortrait: false, invertedLandscape: false}), |
450 | - ubuntu::app_launch::app_info::Desktop(keyfile, "/", {}, ubuntu::app_launch::app_info::DesktopFlags::NONE, nullptr).supportedOrientations()); |
451 | + EXPECT_EQ((ubuntu::app_launch::Application::Info:: |
452 | + Orientations{portrait : true, landscape : false, invertedPortrait : false, invertedLandscape : false}), |
453 | + ubuntu::app_launch::app_info::Desktop(keyfile, "/", {}, ubuntu::app_launch::app_info::DesktopFlags::NONE, |
454 | + nullptr) |
455 | + .supportedOrientations()); |
456 | |
457 | - g_key_file_set_string(keyfile.get(), DESKTOP, "X-Ubuntu-Supported-Orientations", "pOrTraIt;lANDscApE;inVErtEDpORtrAit;iNVErtEDLAnDsCapE;"); |
458 | - EXPECT_EQ((ubuntu::app_launch::Application::Info::Orientations {portrait: true, landscape: true, invertedPortrait: true, invertedLandscape: true}), |
459 | - ubuntu::app_launch::app_info::Desktop(keyfile, "/", {}, ubuntu::app_launch::app_info::DesktopFlags::NONE, nullptr).supportedOrientations()); |
460 | + g_key_file_set_string(keyfile.get(), DESKTOP, "X-Ubuntu-Supported-Orientations", |
461 | + "pOrTraIt;lANDscApE;inVErtEDpORtrAit;iNVErtEDLAnDsCapE;"); |
462 | + EXPECT_EQ((ubuntu::app_launch::Application::Info:: |
463 | + Orientations{portrait : true, landscape : true, invertedPortrait : true, invertedLandscape : true}), |
464 | + ubuntu::app_launch::app_info::Desktop(keyfile, "/", {}, ubuntu::app_launch::app_info::DesktopFlags::NONE, |
465 | + nullptr) |
466 | + .supportedOrientations()); |
467 | |
468 | g_key_file_set_string(keyfile.get(), DESKTOP, "X-Ubuntu-Supported-Orientations", "primary;"); |
469 | - EXPECT_EQ((ubuntu::app_launch::Application::Info::Orientations {portrait: false, landscape: false, invertedPortrait: false, invertedLandscape: false}), |
470 | - ubuntu::app_launch::app_info::Desktop(keyfile, "/", {}, ubuntu::app_launch::app_info::DesktopFlags::NONE, nullptr).supportedOrientations()); |
471 | + EXPECT_EQ((ubuntu::app_launch::Application::Info:: |
472 | + Orientations{portrait : false, landscape : false, invertedPortrait : false, invertedLandscape : false}), |
473 | + ubuntu::app_launch::app_info::Desktop(keyfile, "/", {}, ubuntu::app_launch::app_info::DesktopFlags::NONE, |
474 | + nullptr) |
475 | + .supportedOrientations()); |
476 | |
477 | g_key_file_set_string(keyfile.get(), DESKTOP, "X-Ubuntu-Supported-Orientations", "foobar;primary;"); |
478 | - EXPECT_EQ(defaultOrientations, |
479 | - ubuntu::app_launch::app_info::Desktop(keyfile, "/", {}, ubuntu::app_launch::app_info::DesktopFlags::NONE, nullptr).supportedOrientations()); |
480 | + EXPECT_EQ(defaultOrientations, ubuntu::app_launch::app_info::Desktop( |
481 | + keyfile, "/", {}, ubuntu::app_launch::app_info::DesktopFlags::NONE, nullptr) |
482 | + .supportedOrientations()); |
483 | } |
484 | |
485 | TEST_F(ApplicationInfoDesktop, XMirCases) |
486 | { |
487 | - auto xmirunset = defaultKeyfile(); |
488 | - EXPECT_FALSE( |
489 | - ubuntu::app_launch::app_info::Desktop(xmirunset, "/", {}, ubuntu::app_launch::app_info::DesktopFlags::NONE, nullptr).xMirEnable().value()); |
490 | - EXPECT_TRUE( |
491 | - ubuntu::app_launch::app_info::Desktop(xmirunset, "/", {}, ubuntu::app_launch::app_info::DesktopFlags::XMIR_DEFAULT, nullptr).xMirEnable().value()); |
492 | - |
493 | - auto xmirtrue = defaultKeyfile(); |
494 | - g_key_file_set_boolean(xmirtrue.get(), DESKTOP, "X-Ubuntu-XMir-Enable", TRUE); |
495 | - EXPECT_TRUE( |
496 | - ubuntu::app_launch::app_info::Desktop(xmirtrue, "/", {}, ubuntu::app_launch::app_info::DesktopFlags::NONE, nullptr).xMirEnable().value()); |
497 | - EXPECT_TRUE( |
498 | - ubuntu::app_launch::app_info::Desktop(xmirtrue, "/", {}, ubuntu::app_launch::app_info::DesktopFlags::XMIR_DEFAULT, nullptr).xMirEnable().value()); |
499 | - |
500 | - auto xmirfalse = defaultKeyfile(); |
501 | - g_key_file_set_boolean(xmirfalse.get(), DESKTOP, "X-Ubuntu-XMir-Enable", FALSE); |
502 | - EXPECT_FALSE( |
503 | - ubuntu::app_launch::app_info::Desktop(xmirfalse, "/", {}, ubuntu::app_launch::app_info::DesktopFlags::NONE, nullptr).xMirEnable().value()); |
504 | - EXPECT_FALSE( |
505 | - ubuntu::app_launch::app_info::Desktop(xmirfalse, "/", {}, ubuntu::app_launch::app_info::DesktopFlags::XMIR_DEFAULT, nullptr).xMirEnable().value()); |
506 | + auto xmirunset = defaultKeyfile(); |
507 | + EXPECT_FALSE(ubuntu::app_launch::app_info::Desktop(xmirunset, "/", {}, |
508 | + ubuntu::app_launch::app_info::DesktopFlags::NONE, nullptr) |
509 | + .xMirEnable() |
510 | + .value()); |
511 | + EXPECT_TRUE(ubuntu::app_launch::app_info::Desktop(xmirunset, "/", {}, |
512 | + ubuntu::app_launch::app_info::DesktopFlags::XMIR_DEFAULT, nullptr) |
513 | + .xMirEnable() |
514 | + .value()); |
515 | + |
516 | + auto xmirtrue = defaultKeyfile(); |
517 | + g_key_file_set_boolean(xmirtrue.get(), DESKTOP, "X-Ubuntu-XMir-Enable", TRUE); |
518 | + EXPECT_TRUE(ubuntu::app_launch::app_info::Desktop(xmirtrue, "/", {}, |
519 | + ubuntu::app_launch::app_info::DesktopFlags::NONE, nullptr) |
520 | + .xMirEnable() |
521 | + .value()); |
522 | + EXPECT_TRUE(ubuntu::app_launch::app_info::Desktop(xmirtrue, "/", {}, |
523 | + ubuntu::app_launch::app_info::DesktopFlags::XMIR_DEFAULT, nullptr) |
524 | + .xMirEnable() |
525 | + .value()); |
526 | + |
527 | + auto xmirfalse = defaultKeyfile(); |
528 | + g_key_file_set_boolean(xmirfalse.get(), DESKTOP, "X-Ubuntu-XMir-Enable", FALSE); |
529 | + EXPECT_FALSE(ubuntu::app_launch::app_info::Desktop(xmirfalse, "/", {}, |
530 | + ubuntu::app_launch::app_info::DesktopFlags::NONE, nullptr) |
531 | + .xMirEnable() |
532 | + .value()); |
533 | + EXPECT_FALSE(ubuntu::app_launch::app_info::Desktop( |
534 | + xmirfalse, "/", {}, ubuntu::app_launch::app_info::DesktopFlags::XMIR_DEFAULT, nullptr) |
535 | + .xMirEnable() |
536 | + .value()); |
537 | } |
538 | |
539 | -} //anonymous namespace |
540 | +} // anonymous namespace |
PASSED: Continuous integration, rev:255 /jenkins. canonical. com/unity- api-1/job/ lp-ubuntu- app-launch- ci/97/ /jenkins. canonical. com/unity- api-1/job/ build/644 /jenkins. canonical. com/unity- api-1/job/ build-0- fetch/650 /jenkins. canonical. com/unity- api-1/job/ build-2- binpkg/ arch=amd64, release= vivid+overlay/ 466 /jenkins. canonical. com/unity- api-1/job/ build-2- binpkg/ arch=amd64, release= vivid+overlay/ 466/artifact/ output/ *zip*/output. zip /jenkins. canonical. com/unity- api-1/job/ build-2- binpkg/ arch=amd64, release= xenial+ overlay/ 466 /jenkins. canonical. com/unity- api-1/job/ build-2- binpkg/ arch=amd64, release= xenial+ overlay/ 466/artifact/ output/ *zip*/output. zip /jenkins. canonical. com/unity- api-1/job/ build-2- binpkg/ arch=amd64, release= yakkety/ 466 /jenkins. canonical. com/unity- api-1/job/ build-2- binpkg/ arch=amd64, release= yakkety/ 466/artifact/ output/ *zip*/output. zip /jenkins. canonical. com/unity- api-1/job/ build-2- binpkg/ arch=armhf, release= vivid+overlay/ 466 /jenkins. canonical. com/unity- api-1/job/ build-2- binpkg/ arch=armhf, release= vivid+overlay/ 466/artifact/ output/ *zip*/output. zip /jenkins. canonical. com/unity- api-1/job/ build-2- binpkg/ arch=armhf, release= xenial+ overlay/ 466 /jenkins. canonical. com/unity- api-1/job/ build-2- binpkg/ arch=armhf, release= xenial+ overlay/ 466/artifact/ output/ *zip*/output. zip /jenkins. canonical. com/unity- api-1/job/ build-2- binpkg/ arch=armhf, release= yakkety/ 466 /jenkins. canonical. com/unity- api-1/job/ build-2- binpkg/ arch=armhf, release= yakkety/ 466/artifact/ output/ *zip*/output. zip /jenkins. canonical. com/unity- api-1/job/ build-2- binpkg/ arch=i386, release= vivid+overlay/ 466 /jenkins. canonical. com/unity- api-1/job/ build-2- binpkg/ arch=i386, release= vivid+overlay/ 466/artifact/ output/ *zip*/output. zip /jenkins. canonical. com/unity- api-1/job/ build-2- binpkg/ arch=i386, release= xenial+ overlay/ 466 /jenkins. canonical. com/unity- api-1/job/ build-2- binpkg/ arch=i386, release= xenial+ overlay/ 466/artifact/ output/ *zip*/output. zip /jenkins. canonical. com/unity- api-1/job/ build-2- binpkg/ arch=i386, release= yakkety/ 466 /jenkins. canonical. com/unity- api-1/job/ build-2- binpkg/ arch=i386, release= yakkety/ 466/artifact/ output/ *zip*/output. zip
https:/
Executed test runs:
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
Click here to trigger a rebuild: /jenkins. canonical. com/unity- api-1/job/ lp-ubuntu- app-launch- ci/97/rebuild
https:/