Merge lp:~bregma/qtmir/use-ual-info into lp:qtmir
- use-ual-info
- Merge into trunk
Proposed by
Stephen M. Webb
Status: | Work in progress |
---|---|
Proposed branch: | lp:~bregma/qtmir/use-ual-info |
Merge into: | lp:qtmir |
Diff against target: |
3126 lines (+493/-1554) 30 files modified
debian/control (+1/-1) src/modules/Unity/Application/CMakeLists.txt (+2/-1) src/modules/Unity/Application/application.cpp (+22/-67) src/modules/Unity/Application/application.h (+3/-9) src/modules/Unity/Application/application_manager.cpp (+29/-42) src/modules/Unity/Application/application_manager.h (+0/-3) src/modules/Unity/Application/applicationinfo.h (+59/-0) src/modules/Unity/Application/dbuswindowstack.cpp (+1/-1) src/modules/Unity/Application/desktopfilereader.cpp (+0/-320) src/modules/Unity/Application/desktopfilereader.h (+0/-78) src/modules/Unity/Application/taskcontroller.h (+3/-3) src/modules/Unity/Application/upstart/applicationinfo.cpp (+109/-0) src/modules/Unity/Application/upstart/applicationinfo.h (+57/-0) src/modules/Unity/Application/upstart/taskcontroller.cpp (+75/-93) src/modules/Unity/Application/upstart/taskcontroller.h (+1/-2) tests/framework/CMakeLists.txt (+3/-3) tests/framework/fake_application_info.cpp (+31/-41) tests/framework/fake_application_info.h (+12/-17) tests/framework/mock_application_info.cpp (+23/-94) tests/framework/mock_application_info.h (+17/-35) tests/framework/mock_task_controller.cpp (+5/-17) tests/framework/mock_task_controller.h (+2/-5) tests/framework/qtmir_test.cpp (+0/-10) tests/framework/qtmir_test.h (+0/-2) tests/modules/Application/application_test.cpp (+15/-14) tests/modules/ApplicationManager/application_manager_test.cpp (+23/-246) tests/modules/CMakeLists.txt (+0/-1) tests/modules/DesktopFileReader/CMakeLists.txt (+0/-22) tests/modules/DesktopFileReader/calculator.desktop (+0/-227) tests/modules/DesktopFileReader/desktopfilereader_test.cpp (+0/-200) |
To merge this branch: | bzr merge lp:~bregma/qtmir/use-ual-info |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Mir development team | Pending | ||
Review via email: mp+284523@code.launchpad.net |
Commit message
add required param to mock app object ctor to fix ftbfs
Description of the change
fix params to mock object ctor
To post a comment you must log in.
lp:~bregma/qtmir/use-ual-info
updated
- 445. By Michael Terry
-
Merge from trunk
- 446. By Michael Terry
-
Remove leftover junk file from merge
- 447. By Michael Terry
-
And another
- 448. By Stephen M. Webb
-
synch with trunk
Unmerged revisions
- 448. By Stephen M. Webb
-
synch with trunk
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'debian/control' |
2 | --- debian/control 2016-02-03 16:40:09 +0000 |
3 | +++ debian/control 2016-03-02 00:44:09 +0000 |
4 | @@ -19,7 +19,7 @@ |
5 | libqt5sensors5-dev, |
6 | libqtdbusmock1-dev (>= 0.2), |
7 | libqtdbustest1-dev (>= 0.2), |
8 | - libubuntu-app-launch2-dev, |
9 | + libubuntu-app-launch2-dev (>= 0.9), |
10 | libubuntu-application-api-dev (>= 2.1.0), |
11 | libudev-dev, |
12 | libunity-api-dev (>= 7.106), |
13 | |
14 | === modified file 'src/modules/Unity/Application/CMakeLists.txt' |
15 | --- src/modules/Unity/Application/CMakeLists.txt 2016-02-11 11:52:06 +0000 |
16 | +++ src/modules/Unity/Application/CMakeLists.txt 2016-03-02 00:44:09 +0000 |
17 | @@ -27,7 +27,6 @@ |
18 | application.cpp |
19 | ../../../common/abstractdbusservicemonitor.cpp |
20 | ../../../common/debughelpers.cpp |
21 | - desktopfilereader.cpp |
22 | plugin.cpp |
23 | applicationscreenshotprovider.cpp |
24 | dbuswindowstack.cpp |
25 | @@ -41,6 +40,7 @@ |
26 | session.cpp |
27 | sessionmanager.cpp |
28 | sharedwakelock.cpp |
29 | + upstart/applicationinfo.cpp |
30 | upstart/taskcontroller.cpp |
31 | timer.cpp |
32 | timesource.cpp |
33 | @@ -54,6 +54,7 @@ |
34 | ${APPLICATION_API_INCLUDEDIR}/unity/shell/application/Mir.h |
35 | # Feed the automoc monster |
36 | session_interface.h |
37 | + applicationinfo.h |
38 | taskcontroller.h |
39 | settings_interface.h |
40 | ) |
41 | |
42 | === modified file 'src/modules/Unity/Application/application.cpp' |
43 | --- src/modules/Unity/Application/application.cpp 2016-02-12 00:07:09 +0000 |
44 | +++ src/modules/Unity/Application/application.cpp 2016-03-02 00:44:09 +0000 |
45 | @@ -16,8 +16,8 @@ |
46 | |
47 | // local |
48 | #include "application.h" |
49 | +#include "applicationinfo.h" |
50 | #include "application_manager.h" |
51 | -#include "desktopfilereader.h" |
52 | #include "session.h" |
53 | #include "sharedwakelock.h" |
54 | #include "timer.h" |
55 | @@ -38,14 +38,14 @@ |
56 | { |
57 | |
58 | Application::Application(const QSharedPointer<SharedWakelock>& sharedWakelock, |
59 | - DesktopFileReader *desktopFileReader, |
60 | + ApplicationInfo *appInfo, |
61 | const QStringList &arguments, |
62 | ApplicationManager *parent) |
63 | - : ApplicationInfoInterface(desktopFileReader->appId(), parent) |
64 | + : ApplicationInfoInterface(appInfo->appId(), parent) |
65 | , m_sharedWakelock(sharedWakelock) |
66 | - , m_desktopData(desktopFileReader) |
67 | + , m_appInfo(appInfo) |
68 | , m_pid(0) |
69 | - , m_stage((desktopFileReader->stageHint() == "SideStage") ? Application::SideStage : Application::MainStage) |
70 | + , m_stage(Application::MainStage) |
71 | , m_state(InternalState::Starting) |
72 | , m_focused(false) |
73 | , m_arguments(arguments) |
74 | @@ -55,17 +55,14 @@ |
75 | , m_closeTimer(nullptr) |
76 | , m_exemptFromLifecycle(false) |
77 | { |
78 | - qCDebug(QTMIR_APPLICATIONS) << "Application::Application - appId=" << desktopFileReader->appId(); |
79 | + qCDebug(QTMIR_APPLICATIONS) << "Application::Application - appId=" << appInfo->appId(); |
80 | |
81 | // Because m_state is InternalState::Starting |
82 | acquireWakelock(); |
83 | |
84 | - // FIXME(greyback) need to save long appId internally until ubuntu-app-launch can hide it from us |
85 | - m_longAppId = desktopFileReader->file().remove(QRegExp(".desktop$")).split('/').last(); |
86 | - |
87 | - m_supportedOrientations = m_desktopData->supportedOrientations(); |
88 | - |
89 | - m_rotatesWindowContents = m_desktopData->rotatesWindowContents(); |
90 | + m_supportedOrientations = m_appInfo->supportedOrientations(); |
91 | + |
92 | + m_rotatesWindowContents = m_appInfo->rotatesWindowContents(); |
93 | |
94 | setCloseTimer(new Timer); |
95 | } |
96 | @@ -102,7 +99,7 @@ |
97 | m_session->setApplication(nullptr); |
98 | delete m_session; |
99 | } |
100 | - delete m_desktopData; |
101 | + delete m_appInfo; |
102 | delete m_closeTimer; |
103 | } |
104 | |
105 | @@ -124,64 +121,37 @@ |
106 | |
107 | bool Application::isValid() const |
108 | { |
109 | - return m_desktopData->loaded(); |
110 | -} |
111 | - |
112 | -QString Application::desktopFile() const |
113 | -{ |
114 | - return m_desktopData->file(); |
115 | + return !appId().isEmpty(); |
116 | } |
117 | |
118 | QString Application::appId() const |
119 | { |
120 | - return m_desktopData->appId(); |
121 | + return m_appInfo->appId(); |
122 | } |
123 | |
124 | QString Application::name() const |
125 | { |
126 | - return m_desktopData->name(); |
127 | + return m_appInfo->name(); |
128 | } |
129 | |
130 | QString Application::comment() const |
131 | { |
132 | - return m_desktopData->comment(); |
133 | + return m_appInfo->comment(); |
134 | } |
135 | |
136 | QUrl Application::icon() const |
137 | { |
138 | - QString iconString = m_desktopData->icon(); |
139 | - QString pathString = m_desktopData->path(); |
140 | - |
141 | - if (QFileInfo(iconString).exists()) { |
142 | - return QUrl(iconString); |
143 | - } else if (QFileInfo(pathString + '/' + iconString).exists()) { |
144 | - return QUrl(pathString + '/' + iconString); |
145 | - } else { |
146 | - return QUrl("image://theme/" + iconString); |
147 | - } |
148 | + return m_appInfo->icon(); |
149 | } |
150 | |
151 | QString Application::splashTitle() const |
152 | { |
153 | - return m_desktopData->splashTitle(); |
154 | + return m_appInfo->splashTitle(); |
155 | } |
156 | |
157 | QUrl Application::splashImage() const |
158 | { |
159 | - if (m_desktopData->splashImage().isEmpty()) { |
160 | - return QUrl(); |
161 | - } else { |
162 | - QFileInfo imageFileInfo(m_desktopData->path(), m_desktopData->splashImage()); |
163 | - if (imageFileInfo.exists()) { |
164 | - return QUrl::fromLocalFile(imageFileInfo.canonicalFilePath()); |
165 | - } else { |
166 | - qCWarning(QTMIR_APPLICATIONS) |
167 | - << QString("Application(%1).splashImage file does not exist: \"%2\". Ignoring it.") |
168 | - .arg(appId()).arg(imageFileInfo.absoluteFilePath()); |
169 | - |
170 | - return QUrl(); |
171 | - } |
172 | - } |
173 | + return m_appInfo->splashImage(); |
174 | } |
175 | |
176 | QColor Application::colorFromString(const QString &colorString, const char *colorName) const |
177 | @@ -236,37 +206,27 @@ |
178 | |
179 | bool Application::splashShowHeader() const |
180 | { |
181 | - QString showHeader = m_desktopData->splashShowHeader(); |
182 | - if (showHeader.toLower() == "true") { |
183 | - return true; |
184 | - } else { |
185 | - return false; |
186 | - } |
187 | + return m_appInfo->splashShowHeader(); |
188 | } |
189 | |
190 | QColor Application::splashColor() const |
191 | { |
192 | - QString colorStr = m_desktopData->splashColor(); |
193 | + QString colorStr = m_appInfo->splashColor(); |
194 | return colorFromString(colorStr, "splashColor"); |
195 | } |
196 | |
197 | QColor Application::splashColorHeader() const |
198 | { |
199 | - QString colorStr = m_desktopData->splashColorHeader(); |
200 | + QString colorStr = m_appInfo->splashColorHeader(); |
201 | return colorFromString(colorStr, "splashColorHeader"); |
202 | } |
203 | |
204 | QColor Application::splashColorFooter() const |
205 | { |
206 | - QString colorStr = m_desktopData->splashColorFooter(); |
207 | + QString colorStr = m_appInfo->splashColorFooter(); |
208 | return colorFromString(colorStr, "splashColorFooter"); |
209 | } |
210 | |
211 | -QString Application::exec() const |
212 | -{ |
213 | - return m_desktopData->exec(); |
214 | -} |
215 | - |
216 | Application::Stage Application::stage() const |
217 | { |
218 | return m_stage; |
219 | @@ -690,7 +650,7 @@ |
220 | |
221 | bool Application::isTouchApp() const |
222 | { |
223 | - return m_desktopData->isTouchApp(); |
224 | + return m_appInfo->isTouchApp(); |
225 | } |
226 | |
227 | bool Application::exemptFromLifecycle() const |
228 | @@ -709,11 +669,6 @@ |
229 | } |
230 | } |
231 | |
232 | -QString Application::longAppId() const |
233 | -{ |
234 | - return m_longAppId; |
235 | -} |
236 | - |
237 | Qt::ScreenOrientations Application::supportedOrientations() const |
238 | { |
239 | return m_supportedOrientations; |
240 | |
241 | === modified file 'src/modules/Unity/Application/application.h' |
242 | --- src/modules/Unity/Application/application.h 2016-02-11 11:54:59 +0000 |
243 | +++ src/modules/Unity/Application/application.h 2016-03-02 00:44:09 +0000 |
244 | @@ -40,7 +40,7 @@ |
245 | { |
246 | |
247 | class ApplicationManager; |
248 | -class DesktopFileReader; |
249 | +class ApplicationInfo; |
250 | class Session; |
251 | class SharedWakelock; |
252 | class AbstractTimer; |
253 | @@ -49,8 +49,6 @@ |
254 | { |
255 | Q_OBJECT |
256 | |
257 | - Q_PROPERTY(QString desktopFile READ desktopFile CONSTANT) |
258 | - Q_PROPERTY(QString exec READ exec CONSTANT) |
259 | Q_PROPERTY(bool fullscreen READ fullscreen NOTIFY fullscreenChanged) |
260 | Q_PROPERTY(Stage stage READ stage WRITE setStage NOTIFY stageChanged) |
261 | Q_PROPERTY(SessionInterface* session READ session NOTIFY sessionChanged DESIGNABLE false) |
262 | @@ -82,7 +80,7 @@ |
263 | }; |
264 | |
265 | Application(const QSharedPointer<SharedWakelock>& sharedWakelock, |
266 | - DesktopFileReader *desktopFileReader, |
267 | + ApplicationInfo *appInfo, |
268 | const QStringList &arguments, |
269 | ApplicationManager *parent); |
270 | virtual ~Application(); |
271 | @@ -124,8 +122,6 @@ |
272 | bool canBeResumed() const; |
273 | |
274 | bool isValid() const; |
275 | - QString desktopFile() const; |
276 | - QString exec() const; |
277 | bool fullscreen() const; |
278 | |
279 | Stages supportedStages() const; |
280 | @@ -156,7 +152,6 @@ |
281 | |
282 | private: |
283 | |
284 | - QString longAppId() const; |
285 | void acquireWakelock() const; |
286 | void releaseWakelock() const; |
287 | void setPid(pid_t pid); |
288 | @@ -175,8 +170,7 @@ |
289 | void doClose(); |
290 | |
291 | QSharedPointer<SharedWakelock> m_sharedWakelock; |
292 | - DesktopFileReader* m_desktopData; |
293 | - QString m_longAppId; |
294 | + ApplicationInfo *m_appInfo; |
295 | pid_t m_pid; |
296 | Stage m_stage; |
297 | Stages m_supportedStages; |
298 | |
299 | === modified file 'src/modules/Unity/Application/application_manager.cpp' |
300 | --- src/modules/Unity/Application/application_manager.cpp 2016-02-11 11:54:59 +0000 |
301 | +++ src/modules/Unity/Application/application_manager.cpp 2016-03-02 00:44:09 +0000 |
302 | @@ -17,7 +17,7 @@ |
303 | // local |
304 | #include "application_manager.h" |
305 | #include "application.h" |
306 | -#include "desktopfilereader.h" |
307 | +#include "applicationinfo.h" |
308 | #include "dbuswindowstack.h" |
309 | #include "session.h" |
310 | #include "sharedwakelock.h" |
311 | @@ -125,7 +125,6 @@ |
312 | SessionAuthorizer *sessionAuthorizer = static_cast<SessionAuthorizer*>(nativeInterface->nativeResourceForIntegration("SessionAuthorizer")); |
313 | |
314 | QSharedPointer<TaskController> taskController(new upstart::TaskController()); |
315 | - QSharedPointer<DesktopFileReader::Factory> fileReaderFactory(new DesktopFileReader::Factory()); |
316 | QSharedPointer<ProcInfo> procInfo(new ProcInfo()); |
317 | QSharedPointer<SharedWakelock> sharedWakelock(new SharedWakelock); |
318 | QSharedPointer<Settings> settings(new Settings()); |
319 | @@ -139,7 +138,6 @@ |
320 | mirServer, |
321 | taskController, |
322 | sharedWakelock, |
323 | - fileReaderFactory, |
324 | procInfo, |
325 | settings |
326 | ); |
327 | @@ -178,7 +176,6 @@ |
328 | const QSharedPointer<MirServer>& mirServer, |
329 | const QSharedPointer<TaskController>& taskController, |
330 | const QSharedPointer<SharedWakelock>& sharedWakelock, |
331 | - const QSharedPointer<DesktopFileReader::Factory>& desktopFileReaderFactory, |
332 | const QSharedPointer<ProcInfo>& procInfo, |
333 | const QSharedPointer<SettingsInterface>& settings, |
334 | QObject *parent) |
335 | @@ -187,7 +184,6 @@ |
336 | , m_focusedApplication(nullptr) |
337 | , m_dbusWindowStack(new DBusWindowStack(this)) |
338 | , m_taskController(taskController) |
339 | - , m_desktopFileReaderFactory(desktopFileReaderFactory) |
340 | , m_procInfo(procInfo) |
341 | , m_sharedWakelock(sharedWakelock) |
342 | , m_settings(settings) |
343 | @@ -383,17 +379,18 @@ |
344 | if (application) { |
345 | application->setArguments(arguments); |
346 | } else { |
347 | + auto appInfo = m_taskController->getInfoForApp(appId); |
348 | + if (!appInfo) { |
349 | + qWarning() << "Unable to instantiate application with appId" << appId; |
350 | + return nullptr; |
351 | + } |
352 | + |
353 | application = new Application( |
354 | m_sharedWakelock, |
355 | - m_desktopFileReaderFactory->createInstance(appId, m_taskController->findDesktopFileForAppId(appId)), |
356 | + appInfo, |
357 | arguments, |
358 | this); |
359 | |
360 | - if (!application->isValid()) { |
361 | - qWarning() << "Unable to instantiate application with appId" << appId; |
362 | - return nullptr; |
363 | - } |
364 | - |
365 | // override stage if necessary |
366 | if (application->stage() == Application::SideStage && flags.testFlag(ApplicationManager::ForceMainStage)) { |
367 | application->setStage(Application::MainStage); |
368 | @@ -411,17 +408,17 @@ |
369 | |
370 | Application *application = findApplication(appId); |
371 | if (!application) { // then shell did not start this application, so ubuntu-app-launch must have - add to list |
372 | + auto appInfo = m_taskController->getInfoForApp(appId); |
373 | + if (!appInfo) { |
374 | + qWarning() << "Unable to instantiate application with appId" << appId; |
375 | + return; |
376 | + } |
377 | + |
378 | application = new Application( |
379 | m_sharedWakelock, |
380 | - m_desktopFileReaderFactory->createInstance(appId, m_taskController->findDesktopFileForAppId(appId)), |
381 | + appInfo, |
382 | QStringList(), |
383 | this); |
384 | - |
385 | - if (!application->isValid()) { |
386 | - qWarning() << "Unable to instantiate application with appId" << appId; |
387 | - return; |
388 | - } |
389 | - |
390 | add(application); |
391 | Q_EMIT focusRequested(appId); |
392 | } |
393 | @@ -606,36 +603,27 @@ |
394 | return; |
395 | } |
396 | |
397 | - qCDebug(QTMIR_APPLICATIONS) << "Process supplied desktop_file_hint, loading:" << desktopFileName; |
398 | - |
399 | // Guess appId from the desktop file hint |
400 | const QString appId = toShortAppIdIfPossible(desktopFileName.split('/').last().remove(QRegExp(".desktop$"))); |
401 | |
402 | - // FIXME: right now we support --desktop_file_hint=appId for historical reasons. So let's try that in |
403 | - // case we didn't get an existing .desktop file path |
404 | - DesktopFileReader* desktopData; |
405 | - if (QFileInfo::exists(desktopFileName)) { |
406 | - desktopData = m_desktopFileReaderFactory->createInstance(appId, QFileInfo(desktopFileName)); |
407 | - } else { |
408 | - qCDebug(QTMIR_APPLICATIONS) << "Unable to find file:" << desktopFileName |
409 | - << "so will search standard paths for one named" << appId << ".desktop"; |
410 | - desktopData = m_desktopFileReaderFactory->createInstance(appId, m_taskController->findDesktopFileForAppId(appId)); |
411 | - } |
412 | - |
413 | - if (!desktopData->loaded()) { |
414 | - delete desktopData; |
415 | + qCDebug(QTMIR_APPLICATIONS) << "Process supplied desktop_file_hint, loading:" << appId; |
416 | + |
417 | + ApplicationInfo* appInfo; |
418 | + appInfo = m_taskController->getInfoForApp(appId); |
419 | + |
420 | + if (!appInfo) { |
421 | qCritical() << "ApplicationManager REJECTED connection from app with pid" << pid |
422 | - << "as the file specified by the desktop_file_hint argument could not be opened"; |
423 | + << "as the app specified by the desktop_file_hint argument could not be found"; |
424 | return; |
425 | } |
426 | |
427 | // some naughty applications use a script to launch the actual application. Check for the |
428 | // case where shell actually launched the script. |
429 | - Application *application = findApplication(desktopData->appId()); |
430 | + Application *application = findApplication(appInfo->appId()); |
431 | if (application && application->state() == Application::Starting) { |
432 | qCDebug(QTMIR_APPLICATIONS) << "Process with pid" << pid << "appeared, attaching to existing entry" |
433 | << "in application list with appId:" << application->appId(); |
434 | - delete desktopData; |
435 | + delete appInfo; |
436 | application->setPid(pid); |
437 | authorized = true; |
438 | return; |
439 | @@ -650,12 +638,12 @@ |
440 | } |
441 | |
442 | qCDebug(QTMIR_APPLICATIONS) << "New process with pid" << pid << "appeared, adding new application to the" |
443 | - << "application list with appId:" << desktopData->appId(); |
444 | + << "application list with appId:" << appInfo->appId(); |
445 | |
446 | QStringList arguments(info->asStringList()); |
447 | application = new Application( |
448 | m_sharedWakelock, |
449 | - desktopData, |
450 | + appInfo, |
451 | arguments, |
452 | this); |
453 | application->setPid(pid); |
454 | @@ -742,7 +730,6 @@ |
455 | connect(application, &Application::stageChanged, this, [this](Application::Stage) { onAppDataChanged(RoleStage); }); |
456 | |
457 | QString appId = application->appId(); |
458 | - QString longAppId = application->longAppId(); |
459 | QStringList arguments = application->arguments(); |
460 | |
461 | // The connection is queued as a workaround an issue in the PhoneStage animation that |
462 | @@ -755,7 +742,7 @@ |
463 | Qt::QueuedConnection); |
464 | |
465 | connect(application, &Application::stopProcessRequested, this, [=]() { |
466 | - if (!m_taskController->stop(application->longAppId()) && application->pid() > 0) { |
467 | + if (!m_taskController->stop(appId) && application->pid() > 0) { |
468 | qWarning() << "FAILED to ask Upstart to stop application with appId" << appId |
469 | << "Sending SIGTERM to process:" << appId; |
470 | kill(application->pid(), SIGTERM); |
471 | @@ -763,8 +750,8 @@ |
472 | } |
473 | }); |
474 | |
475 | - connect(application, &Application::suspendProcessRequested, this, [=]() { m_taskController->suspend(longAppId); } ); |
476 | - connect(application, &Application::resumeProcessRequested, this, [=]() { m_taskController->resume(longAppId); } ); |
477 | + connect(application, &Application::suspendProcessRequested, this, [=]() { m_taskController->suspend(appId); } ); |
478 | + connect(application, &Application::resumeProcessRequested, this, [=]() { m_taskController->resume(appId); } ); |
479 | |
480 | connect(application, &Application::stopped, this, [=]() { |
481 | remove(application); |
482 | |
483 | === modified file 'src/modules/Unity/Application/application_manager.h' |
484 | --- src/modules/Unity/Application/application_manager.h 2016-02-11 11:54:59 +0000 |
485 | +++ src/modules/Unity/Application/application_manager.h 2016-03-02 00:44:09 +0000 |
486 | @@ -29,7 +29,6 @@ |
487 | |
488 | // local |
489 | #include "application.h" |
490 | -#include "desktopfilereader.h" |
491 | #include "taskcontroller.h" |
492 | |
493 | namespace mir { |
494 | @@ -85,7 +84,6 @@ |
495 | const QSharedPointer<MirServer> &mirServer, |
496 | const QSharedPointer<TaskController> &taskController, |
497 | const QSharedPointer<SharedWakelock> &sharedWakelock, |
498 | - const QSharedPointer<DesktopFileReader::Factory> &desktopFileReaderFactory, |
499 | const QSharedPointer<ProcInfo> &processInfo, |
500 | const QSharedPointer<SettingsInterface> &settings, |
501 | QObject *parent = 0); |
502 | @@ -159,7 +157,6 @@ |
503 | Application* m_focusedApplication; |
504 | DBusWindowStack* m_dbusWindowStack; |
505 | QSharedPointer<TaskController> m_taskController; |
506 | - QSharedPointer<DesktopFileReader::Factory> m_desktopFileReaderFactory; |
507 | QSharedPointer<ProcInfo> m_procInfo; |
508 | QSharedPointer<SharedWakelock> m_sharedWakelock; |
509 | QSharedPointer<SettingsInterface> m_settings; |
510 | |
511 | === added file 'src/modules/Unity/Application/applicationinfo.h' |
512 | --- src/modules/Unity/Application/applicationinfo.h 1970-01-01 00:00:00 +0000 |
513 | +++ src/modules/Unity/Application/applicationinfo.h 2016-03-02 00:44:09 +0000 |
514 | @@ -0,0 +1,59 @@ |
515 | +/* |
516 | + * Copyright (C) 2014-2015 Canonical, Ltd. |
517 | + * |
518 | + * This program is free software: you can redistribute it and/or modify it under |
519 | + * the terms of the GNU Lesser General Public License version 3, as published by |
520 | + * the Free Software Foundation. |
521 | + * |
522 | + * This program is distributed in the hope that it will be useful, but WITHOUT |
523 | + * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY, |
524 | + * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
525 | + * Lesser General Public License for more details. |
526 | + * |
527 | + * You should have received a copy of the GNU Lesser General Public License |
528 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
529 | + * |
530 | + */ |
531 | + |
532 | +#ifndef APPLICATION_INFO_H |
533 | +#define APPLICATION_INFO_H |
534 | + |
535 | +#include <QColor> |
536 | +#include <QObject> |
537 | +#include <QString> |
538 | +#include <QUrl> |
539 | + |
540 | +namespace qtmir |
541 | +{ |
542 | + |
543 | +class ApplicationInfo : public QObject |
544 | +{ |
545 | + Q_OBJECT |
546 | + |
547 | +public: |
548 | + ApplicationInfo(const ApplicationInfo&) = delete; |
549 | + virtual ~ApplicationInfo() = default; |
550 | + |
551 | + ApplicationInfo& operator=(const ApplicationInfo&) = delete; |
552 | + |
553 | + virtual QString appId() const = 0; |
554 | + virtual QString name() const = 0; |
555 | + virtual QString comment() const = 0; |
556 | + virtual QUrl icon() const = 0; |
557 | + virtual QString splashTitle() const = 0; |
558 | + virtual QUrl splashImage() const = 0; |
559 | + virtual bool splashShowHeader() const = 0; |
560 | + virtual QString splashColor() const = 0; |
561 | + virtual QString splashColorHeader() const = 0; |
562 | + virtual QString splashColorFooter() const = 0; |
563 | + virtual Qt::ScreenOrientations supportedOrientations() const = 0; |
564 | + virtual bool rotatesWindowContents() const = 0; |
565 | + virtual bool isTouchApp() const = 0; |
566 | + |
567 | +protected: |
568 | + ApplicationInfo() = default; |
569 | +}; |
570 | + |
571 | +} // namespace qtmir |
572 | + |
573 | +#endif // APPLICATION_INFO_H |
574 | |
575 | === modified file 'src/modules/Unity/Application/dbuswindowstack.cpp' |
576 | --- src/modules/Unity/Application/dbuswindowstack.cpp 2015-08-11 12:08:32 +0000 |
577 | +++ src/modules/Unity/Application/dbuswindowstack.cpp 2016-03-02 00:44:09 +0000 |
578 | @@ -49,7 +49,7 @@ |
579 | const Application *app = appMgr->findApplicationWithPid(pid); |
580 | if (app) { |
581 | res.app_id = app->appId(); |
582 | - res.desktop_file = app->desktopFile(); |
583 | + res.desktop_file = ""; |
584 | } |
585 | return res; |
586 | } |
587 | |
588 | === removed file 'src/modules/Unity/Application/desktopfilereader.cpp' |
589 | --- src/modules/Unity/Application/desktopfilereader.cpp 2015-11-19 12:55:57 +0000 |
590 | +++ src/modules/Unity/Application/desktopfilereader.cpp 1970-01-01 00:00:00 +0000 |
591 | @@ -1,320 +0,0 @@ |
592 | -/* |
593 | - * Copyright (C) 2013-2015 Canonical, Ltd. |
594 | - * |
595 | - * This program is free software: you can redistribute it and/or modify it under |
596 | - * the terms of the GNU Lesser General Public License version 3, as published by |
597 | - * the Free Software Foundation. |
598 | - * |
599 | - * This program is distributed in the hope that it will be useful, but WITHOUT |
600 | - * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY, |
601 | - * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
602 | - * Lesser General Public License for more details. |
603 | - * |
604 | - * You should have received a copy of the GNU Lesser General Public License |
605 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. |
606 | - */ |
607 | - |
608 | -// local |
609 | -#include "desktopfilereader.h" |
610 | -#include "gscopedpointer.h" |
611 | -#include "logging.h" |
612 | - |
613 | -// Qt |
614 | -#include <QFile> |
615 | -#include <QLocale> |
616 | - |
617 | -// GIO |
618 | -#include <gio/gdesktopappinfo.h> |
619 | - |
620 | -namespace qtmir |
621 | -{ |
622 | - |
623 | - |
624 | -DesktopFileReader* DesktopFileReader::Factory::createInstance(const QString &appId, const QFileInfo& fi) |
625 | -{ |
626 | - return new DesktopFileReader(appId, fi); |
627 | -} |
628 | - |
629 | -typedef GObjectScopedPointer<GAppInfo> GAppInfoPointer; |
630 | - |
631 | -class DesktopFileReaderPrivate |
632 | -{ |
633 | -public: |
634 | - DesktopFileReaderPrivate(DesktopFileReader *parent): |
635 | - q_ptr( parent ) |
636 | - {} |
637 | - |
638 | - QString getKey(const char *key) const |
639 | - { |
640 | - if (!loaded()) return QString(); |
641 | - |
642 | - return QString::fromUtf8(g_desktop_app_info_get_string((GDesktopAppInfo*)appInfo.data(), key)); |
643 | - } |
644 | - |
645 | - bool loaded() const |
646 | - { |
647 | - return !appInfo.isNull(); |
648 | - } |
649 | - |
650 | - DesktopFileReader * const q_ptr; |
651 | - Q_DECLARE_PUBLIC(DesktopFileReader) |
652 | - |
653 | - QString appId; |
654 | - QString file; |
655 | - GAppInfoPointer appInfo; // GAppInfo is actually implemented by GDesktopAppInfo |
656 | -}; |
657 | - |
658 | - |
659 | -DesktopFileReader::DesktopFileReader(const QString &appId, const QFileInfo &desktopFile) |
660 | - : d_ptr(new DesktopFileReaderPrivate(this)) |
661 | -{ |
662 | - Q_D(DesktopFileReader); |
663 | - qCDebug(QTMIR_APPLICATIONS) << "Loading desktop file" << desktopFile.absoluteFilePath() |
664 | - << "for appId" << appId; |
665 | - |
666 | - d->appId = appId; |
667 | - d->file = desktopFile.absoluteFilePath(); |
668 | - d->appInfo.reset((GAppInfo*) g_desktop_app_info_new_from_filename(d->file.toUtf8().constData())); |
669 | - |
670 | - if (!d->loaded()) { |
671 | - if (!desktopFile.exists()) { |
672 | - qCWarning(QTMIR_APPLICATIONS) << "Desktop file for appId:" << appId << "at:" << d->file |
673 | - << "does not exist"; |
674 | - } else { |
675 | - qCWarning(QTMIR_APPLICATIONS) << "Desktop file for appId:" << appId << "at:" << d->file |
676 | - << "is not valid - check its syntax, and that the binary specified" |
677 | - << "by the Exec line is installed!"; |
678 | - } |
679 | - } |
680 | -} |
681 | - |
682 | -DesktopFileReader::~DesktopFileReader() |
683 | -{ |
684 | - delete d_ptr; |
685 | -} |
686 | - |
687 | -QString DesktopFileReader::file() const |
688 | -{ |
689 | - Q_D(const DesktopFileReader); |
690 | - return d->file; |
691 | -} |
692 | - |
693 | -QString DesktopFileReader::appId() const |
694 | -{ |
695 | - Q_D(const DesktopFileReader); |
696 | - return d->appId; |
697 | -} |
698 | - |
699 | -QString DesktopFileReader::name() const |
700 | -{ |
701 | - Q_D(const DesktopFileReader); |
702 | - if (!d->loaded()) return QString(); |
703 | - |
704 | - return QString::fromUtf8(g_app_info_get_name(d->appInfo.data())); |
705 | -} |
706 | - |
707 | -QString DesktopFileReader::comment() const |
708 | -{ |
709 | - Q_D(const DesktopFileReader); |
710 | - if (!d->loaded()) return QString(); |
711 | - |
712 | - return QString::fromUtf8(g_app_info_get_description(d->appInfo.data())); |
713 | -} |
714 | - |
715 | -QString DesktopFileReader::icon() const |
716 | -{ |
717 | - Q_D(const DesktopFileReader); |
718 | - return d->getKey("Icon"); |
719 | -} |
720 | - |
721 | -QString DesktopFileReader::exec() const |
722 | -{ |
723 | - Q_D(const DesktopFileReader); |
724 | - if (!d->loaded()) return QString(); |
725 | - |
726 | - return QString::fromUtf8(g_app_info_get_commandline(d->appInfo.data())); |
727 | -} |
728 | - |
729 | -QString DesktopFileReader::path() const |
730 | -{ |
731 | - Q_D(const DesktopFileReader); |
732 | - return d->getKey("Path"); |
733 | -} |
734 | - |
735 | -QString DesktopFileReader::stageHint() const |
736 | -{ |
737 | - Q_D(const DesktopFileReader); |
738 | - return d->getKey("X-Ubuntu-StageHint"); |
739 | -} |
740 | - |
741 | -QString DesktopFileReader::splashTitle() const |
742 | -{ |
743 | - Q_D(const DesktopFileReader); |
744 | - if (!d->loaded()) return QString(); |
745 | - |
746 | - /* Sadly GDesktopAppInfo only considers Name, GenericName, Comments and Keywords to be keys |
747 | - * which can have locale-specific entries. So we need to work to make X-Ubuntu-Splash-Title |
748 | - * locale-aware, by generating a locale-correct key name and seeing if that exists. If yes, |
749 | - * get the value and return it. Else fallback to the non-localized value. |
750 | - */ |
751 | - GDesktopAppInfo *info = (GDesktopAppInfo*)d->appInfo.data(); |
752 | - QLocale defaultLocale; |
753 | - QStringList locales = defaultLocale.uiLanguages(); |
754 | - |
755 | - QString keyTemplate("X-Ubuntu-Splash-Title[%1]"); |
756 | - for (QString locale: locales) { |
757 | - // Desktop files use local specifiers with underscore separators but Qt uses hyphens |
758 | - locale = locale.replace('-', '_'); |
759 | - const char* key = keyTemplate.arg(locale).toUtf8().constData(); |
760 | - if (g_desktop_app_info_has_key(info, key)) { |
761 | - return d->getKey(key); |
762 | - } |
763 | - } |
764 | - |
765 | - // Fallback to the non-localized string, if available |
766 | - return d->getKey("X-Ubuntu-Splash-Title"); |
767 | -} |
768 | - |
769 | -QString DesktopFileReader::splashImage() const |
770 | -{ |
771 | - Q_D(const DesktopFileReader); |
772 | - return d->getKey("X-Ubuntu-Splash-Image"); |
773 | -} |
774 | - |
775 | -QString DesktopFileReader::splashShowHeader() const |
776 | -{ |
777 | - Q_D(const DesktopFileReader); |
778 | - return d->getKey("X-Ubuntu-Splash-Show-Header"); |
779 | -} |
780 | - |
781 | -QString DesktopFileReader::splashColor() const |
782 | -{ |
783 | - Q_D(const DesktopFileReader); |
784 | - return d->getKey("X-Ubuntu-Splash-Color"); |
785 | -} |
786 | - |
787 | -QString DesktopFileReader::splashColorHeader() const |
788 | -{ |
789 | - Q_D(const DesktopFileReader); |
790 | - return d->getKey("X-Ubuntu-Splash-Color-Header"); |
791 | -} |
792 | - |
793 | -QString DesktopFileReader::splashColorFooter() const |
794 | -{ |
795 | - Q_D(const DesktopFileReader); |
796 | - return d->getKey("X-Ubuntu-Splash-Color-Footer"); |
797 | -} |
798 | - |
799 | -Qt::ScreenOrientations DesktopFileReader::supportedOrientations() const |
800 | -{ |
801 | - Q_D(const DesktopFileReader); |
802 | - Qt::ScreenOrientations result; |
803 | - |
804 | - if (!parseOrientations(d->getKey("X-Ubuntu-Supported-Orientations"), result)) { |
805 | - qCWarning(QTMIR_APPLICATIONS) << d->file << "has an invalid X-Ubuntu-Supported-Orientations entry."; |
806 | - } |
807 | - |
808 | - return result; |
809 | -} |
810 | - |
811 | -bool DesktopFileReader::rotatesWindowContents() const |
812 | -{ |
813 | - Q_D(const DesktopFileReader); |
814 | - bool result; |
815 | - |
816 | - if (!parseBoolean(d->getKey("X-Ubuntu-Rotates-Window-Contents"), result)) { |
817 | - qCWarning(QTMIR_APPLICATIONS) << d->file << "has an invalid X-Ubuntu-Rotates-Window-Contents entry."; |
818 | - } |
819 | - |
820 | - return result; |
821 | -} |
822 | - |
823 | -bool DesktopFileReader::isTouchApp() const |
824 | -{ |
825 | - Q_D(const DesktopFileReader); |
826 | - bool result; |
827 | - |
828 | - if (!parseBoolean(d->getKey("X-Ubuntu-Touch"), result)) { |
829 | - qCWarning(QTMIR_APPLICATIONS) << d->file << "has an invalid X-Ubuntu-Touch entry."; |
830 | - } |
831 | - |
832 | - return result; |
833 | -} |
834 | - |
835 | -bool DesktopFileReader::parseOrientations(const QString &rawString, Qt::ScreenOrientations &result) |
836 | -{ |
837 | - // Default to all orientations |
838 | - result = Qt::PortraitOrientation | Qt::LandscapeOrientation |
839 | - | Qt::InvertedPortraitOrientation | Qt::InvertedLandscapeOrientation; |
840 | - |
841 | - if (rawString.isEmpty()) { |
842 | - return true; |
843 | - } |
844 | - |
845 | - Qt::ScreenOrientations parsedOrientations = 0; |
846 | - bool ok = true; |
847 | - |
848 | - QStringList orientationsList = rawString |
849 | - .simplified() |
850 | - .replace(QChar(','), ";") |
851 | - .remove(QChar(' ')) |
852 | - .remove(QChar('-')) |
853 | - .remove(QChar('_')) |
854 | - .toLower() |
855 | - .split(";"); |
856 | - |
857 | - for (int i = 0; i < orientationsList.count() && ok; ++i) { |
858 | - const QString &orientationString = orientationsList.at(i); |
859 | - if (orientationString.isEmpty()) { |
860 | - // skip it |
861 | - continue; |
862 | - } |
863 | - |
864 | - if (orientationString == "portrait") { |
865 | - parsedOrientations |= Qt::PortraitOrientation; |
866 | - } else if (orientationString == "landscape") { |
867 | - parsedOrientations |= Qt::LandscapeOrientation; |
868 | - } else if (orientationString == "invertedportrait") { |
869 | - parsedOrientations |= Qt::InvertedPortraitOrientation; |
870 | - } else if (orientationString == "invertedlandscape") { |
871 | - parsedOrientations |= Qt::InvertedLandscapeOrientation; |
872 | - } else if (orientationsList.count() == 1 && orientationString == "primary") { |
873 | - // Special case: primary orientation must be alone |
874 | - // There's no sense in supporting primary orientation + other orientations |
875 | - // like "primary,landscape" |
876 | - parsedOrientations = Qt::PrimaryOrientation; |
877 | - } else { |
878 | - ok = false; |
879 | - } |
880 | - } |
881 | - |
882 | - if (ok) { |
883 | - result = parsedOrientations; |
884 | - } |
885 | - |
886 | - return ok; |
887 | -} |
888 | - |
889 | -bool DesktopFileReader::parseBoolean(const QString &rawString, bool &result) |
890 | -{ |
891 | - QString cookedString = rawString.trimmed().toLower(); |
892 | - |
893 | - result = cookedString == "y" |
894 | - || cookedString == "1" |
895 | - || cookedString == "yes" |
896 | - || cookedString == "true"; |
897 | - |
898 | - return result || rawString.isEmpty() |
899 | - || cookedString == "n" |
900 | - || cookedString == "0" |
901 | - || cookedString == "no" |
902 | - || cookedString == "false"; |
903 | -} |
904 | - |
905 | -bool DesktopFileReader::loaded() const |
906 | -{ |
907 | - Q_D(const DesktopFileReader); |
908 | - return d->loaded(); |
909 | -} |
910 | - |
911 | -} // namespace qtmir |
912 | |
913 | === removed file 'src/modules/Unity/Application/desktopfilereader.h' |
914 | --- src/modules/Unity/Application/desktopfilereader.h 2015-09-28 20:11:39 +0000 |
915 | +++ src/modules/Unity/Application/desktopfilereader.h 1970-01-01 00:00:00 +0000 |
916 | @@ -1,78 +0,0 @@ |
917 | -/* |
918 | - * Copyright (C) 2013-2015 Canonical, Ltd. |
919 | - * |
920 | - * This program is free software: you can redistribute it and/or modify it under |
921 | - * the terms of the GNU Lesser General Public License version 3, as published by |
922 | - * the Free Software Foundation. |
923 | - * |
924 | - * This program is distributed in the hope that it will be useful, but WITHOUT |
925 | - * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY, |
926 | - * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
927 | - * Lesser General Public License for more details. |
928 | - * |
929 | - * You should have received a copy of the GNU Lesser General Public License |
930 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. |
931 | - */ |
932 | - |
933 | -#ifndef DESKTOPFILEREADER_H |
934 | -#define DESKTOPFILEREADER_H |
935 | - |
936 | -#include <QString> |
937 | -#include <QFileInfo> |
938 | - |
939 | -namespace qtmir |
940 | -{ |
941 | - |
942 | -class DesktopFileReaderPrivate; |
943 | -class DesktopFileReader { |
944 | -public: |
945 | - class Factory |
946 | - { |
947 | - public: |
948 | - Factory() = default; |
949 | - virtual ~Factory() = default; |
950 | - |
951 | - Factory(const Factory&) = delete; |
952 | - |
953 | - Factory& operator=(const Factory&) = delete; |
954 | - |
955 | - virtual DesktopFileReader* createInstance(const QString &appId, const QFileInfo& fi); |
956 | - }; |
957 | - |
958 | - virtual ~DesktopFileReader(); |
959 | - |
960 | - virtual QString file() const; |
961 | - virtual QString appId() const; |
962 | - virtual QString name() const; |
963 | - virtual QString comment() const; |
964 | - virtual QString icon() const; |
965 | - virtual QString exec() const; |
966 | - virtual QString path() const; |
967 | - virtual QString stageHint() const; |
968 | - virtual QString splashTitle() const; |
969 | - virtual QString splashImage() const; |
970 | - virtual QString splashShowHeader() const; |
971 | - virtual QString splashColor() const; |
972 | - virtual QString splashColorHeader() const; |
973 | - virtual QString splashColorFooter() const; |
974 | - virtual Qt::ScreenOrientations supportedOrientations() const; |
975 | - virtual bool rotatesWindowContents() const; |
976 | - virtual bool isTouchApp() const; |
977 | - virtual bool loaded() const; |
978 | - |
979 | - static bool parseOrientations(const QString &rawString, Qt::ScreenOrientations &result); |
980 | - static bool parseBoolean(const QString &rawString, bool &result); |
981 | - |
982 | -protected: |
983 | - DesktopFileReader() : d_ptr(nullptr) {} |
984 | - DesktopFileReader(const QString &appId, const QFileInfo &desktopFile); |
985 | - |
986 | - DesktopFileReaderPrivate * const d_ptr; |
987 | - |
988 | -private: |
989 | - Q_DECLARE_PRIVATE(DesktopFileReader) |
990 | -}; |
991 | - |
992 | -} // namespace qtmir |
993 | - |
994 | -#endif // DESKTOPFILEREADER_H |
995 | |
996 | === modified file 'src/modules/Unity/Application/taskcontroller.h' |
997 | --- src/modules/Unity/Application/taskcontroller.h 2016-02-11 11:52:06 +0000 |
998 | +++ src/modules/Unity/Application/taskcontroller.h 2016-03-02 00:44:09 +0000 |
999 | @@ -21,11 +21,12 @@ |
1000 | #include <QObject> |
1001 | #include <QString> |
1002 | #include <QStringList> |
1003 | -#include <QFileInfo> |
1004 | |
1005 | namespace qtmir |
1006 | { |
1007 | |
1008 | +class ApplicationInfo; |
1009 | + |
1010 | class TaskController : public QObject |
1011 | { |
1012 | Q_OBJECT |
1013 | @@ -42,7 +43,6 @@ |
1014 | |
1015 | TaskController& operator=(const TaskController&) = delete; |
1016 | |
1017 | - virtual pid_t primaryPidForAppId(const QString &appId) = 0; |
1018 | virtual bool appIdHasProcessId(const QString &appId, pid_t pid) = 0; |
1019 | |
1020 | virtual bool stop(const QString &appId) = 0; |
1021 | @@ -51,7 +51,7 @@ |
1022 | virtual bool suspend(const QString &appId) = 0; |
1023 | virtual bool resume(const QString &appId) = 0; |
1024 | |
1025 | - virtual QFileInfo findDesktopFileForAppId(const QString &appId) const = 0; |
1026 | + virtual qtmir::ApplicationInfo *getInfoForApp(const QString &appId) const = 0; |
1027 | |
1028 | Q_SIGNALS: |
1029 | void processStarting(const QString &appId); |
1030 | |
1031 | === added file 'src/modules/Unity/Application/upstart/applicationinfo.cpp' |
1032 | --- src/modules/Unity/Application/upstart/applicationinfo.cpp 1970-01-01 00:00:00 +0000 |
1033 | +++ src/modules/Unity/Application/upstart/applicationinfo.cpp 2016-03-02 00:44:09 +0000 |
1034 | @@ -0,0 +1,109 @@ |
1035 | +/* |
1036 | + * Copyright (C) 2014,2015 Canonical, Ltd. |
1037 | + * |
1038 | + * This program is free software: you can redistribute it and/or modify it under |
1039 | + * the terms of the GNU Lesser General Public License version 3, as published by |
1040 | + * the Free Software Foundation. |
1041 | + * |
1042 | + * This program is distributed in the hope that it will be useful, but WITHOUT |
1043 | + * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY, |
1044 | + * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
1045 | + * Lesser General Public License for more details. |
1046 | + * |
1047 | + * You should have received a copy of the GNU Lesser General Public License |
1048 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
1049 | + * |
1050 | + */ |
1051 | + |
1052 | +#include "applicationinfo.h" |
1053 | + |
1054 | +namespace qtmir |
1055 | +{ |
1056 | +namespace upstart |
1057 | +{ |
1058 | + |
1059 | +ApplicationInfo::ApplicationInfo(const QString &appId, std::shared_ptr<ubuntu::app_launch::Application::Info> info) |
1060 | + : qtmir::ApplicationInfo(), |
1061 | + m_appId(appId), |
1062 | + m_info(info) |
1063 | +{ |
1064 | +} |
1065 | + |
1066 | +QString ApplicationInfo::appId() const |
1067 | +{ |
1068 | + return m_appId; |
1069 | +} |
1070 | + |
1071 | +QString ApplicationInfo::name() const |
1072 | +{ |
1073 | + return QString::fromStdString(m_info->name().value()); |
1074 | +} |
1075 | + |
1076 | +QString ApplicationInfo::comment() const |
1077 | +{ |
1078 | + return QString::fromStdString(m_info->description().value()); |
1079 | +} |
1080 | + |
1081 | +QUrl ApplicationInfo::icon() const |
1082 | +{ |
1083 | + return QUrl::fromLocalFile(QString::fromStdString(m_info->iconPath().value())); |
1084 | +} |
1085 | + |
1086 | +QString ApplicationInfo::splashTitle() const |
1087 | +{ |
1088 | + return QString::fromStdString(m_info->splash().title.value()); |
1089 | +} |
1090 | + |
1091 | +QUrl ApplicationInfo::splashImage() const |
1092 | +{ |
1093 | + return QUrl::fromLocalFile(QString::fromStdString(m_info->splash().image.value())); |
1094 | +} |
1095 | + |
1096 | +bool ApplicationInfo::splashShowHeader() const |
1097 | +{ |
1098 | + return m_info->splash().showHeader.value(); |
1099 | +} |
1100 | + |
1101 | +QString ApplicationInfo::splashColor() const |
1102 | +{ |
1103 | + return QString::fromStdString(m_info->splash().backgroundColor.value()); |
1104 | +} |
1105 | + |
1106 | +QString ApplicationInfo::splashColorHeader() const |
1107 | +{ |
1108 | + return QString::fromStdString(m_info->splash().headerColor.value()); |
1109 | +} |
1110 | + |
1111 | +QString ApplicationInfo::splashColorFooter() const |
1112 | +{ |
1113 | + return QString::fromStdString(m_info->splash().footerColor.value()); |
1114 | +} |
1115 | + |
1116 | +Qt::ScreenOrientations ApplicationInfo::supportedOrientations() const |
1117 | +{ |
1118 | + Qt::ScreenOrientations response = 0; |
1119 | + auto orientations = m_info->supportedOrientations(); |
1120 | + if (orientations.portrait) |
1121 | + response |= Qt::PortraitOrientation; |
1122 | + if (orientations.landscape) |
1123 | + response |= Qt::LandscapeOrientation; |
1124 | + if (orientations.invertedPortrait) |
1125 | + response |= Qt::InvertedPortraitOrientation; |
1126 | + if (orientations.invertedLandscape) |
1127 | + response |= Qt::InvertedLandscapeOrientation; |
1128 | + return response; |
1129 | +} |
1130 | + |
1131 | +bool ApplicationInfo::rotatesWindowContents() const |
1132 | +{ |
1133 | + return m_info->rotatesWindowContents().value(); |
1134 | +} |
1135 | + |
1136 | + |
1137 | +bool ApplicationInfo::isTouchApp() const |
1138 | +{ |
1139 | + return m_info->supportsUbuntuLifecycle().value(); |
1140 | +} |
1141 | + |
1142 | +} // namespace upstart |
1143 | +} // namespace qtmir |
1144 | |
1145 | === added file 'src/modules/Unity/Application/upstart/applicationinfo.h' |
1146 | --- src/modules/Unity/Application/upstart/applicationinfo.h 1970-01-01 00:00:00 +0000 |
1147 | +++ src/modules/Unity/Application/upstart/applicationinfo.h 2016-03-02 00:44:09 +0000 |
1148 | @@ -0,0 +1,57 @@ |
1149 | +/* |
1150 | + * Copyright (C) 2013 Canonical, Ltd. |
1151 | + * |
1152 | + * This program is free software: you can redistribute it and/or modify it under |
1153 | + * the terms of the GNU Lesser General Public License version 3, as published by |
1154 | + * the Free Software Foundation. |
1155 | + * |
1156 | + * This program is distributed in the hope that it will be useful, but WITHOUT |
1157 | + * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY, |
1158 | + * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
1159 | + * Lesser General Public License for more details. |
1160 | + * |
1161 | + * You should have received a copy of the GNU Lesser General Public License |
1162 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
1163 | + * |
1164 | + */ |
1165 | + |
1166 | +#ifndef UPSTART_APPLICATION_INFO_H |
1167 | +#define UPSTART_APPLICATION_INFO_H |
1168 | + |
1169 | +#include "../applicationinfo.h" |
1170 | + |
1171 | +#include <ubuntu-app-launch/application.h> |
1172 | + |
1173 | +namespace qtmir |
1174 | +{ |
1175 | +namespace upstart |
1176 | +{ |
1177 | + |
1178 | +class ApplicationInfo : public qtmir::ApplicationInfo |
1179 | +{ |
1180 | +public: |
1181 | + ApplicationInfo(const QString &appId, std::shared_ptr<ubuntu::app_launch::Application::Info> info); |
1182 | + |
1183 | + QString appId() const override; |
1184 | + QString name() const override; |
1185 | + QString comment() const override; |
1186 | + QUrl icon() const override; |
1187 | + QString splashTitle() const override; |
1188 | + QUrl splashImage() const override; |
1189 | + bool splashShowHeader() const override; |
1190 | + QString splashColor() const override; |
1191 | + QString splashColorHeader() const override; |
1192 | + QString splashColorFooter() const override; |
1193 | + Qt::ScreenOrientations supportedOrientations() const override; |
1194 | + bool rotatesWindowContents() const override; |
1195 | + bool isTouchApp() const override; |
1196 | + |
1197 | +private: |
1198 | + QString m_appId; |
1199 | + std::shared_ptr<ubuntu::app_launch::Application::Info> m_info; |
1200 | +}; |
1201 | + |
1202 | +} // namespace upstart |
1203 | +} // namespace qtmir |
1204 | + |
1205 | +#endif // UPSTART_APPLICATION_INFO_H |
1206 | |
1207 | === modified file 'src/modules/Unity/Application/upstart/taskcontroller.cpp' |
1208 | --- src/modules/Unity/Application/upstart/taskcontroller.cpp 2016-02-11 11:52:06 +0000 |
1209 | +++ src/modules/Unity/Application/upstart/taskcontroller.cpp 2016-03-02 00:44:09 +0000 |
1210 | @@ -15,6 +15,7 @@ |
1211 | * |
1212 | */ |
1213 | |
1214 | +#include "applicationinfo.h" |
1215 | #include "taskcontroller.h" |
1216 | |
1217 | // qtmir |
1218 | @@ -27,6 +28,9 @@ |
1219 | extern "C" { |
1220 | #include "ubuntu-app-launch.h" |
1221 | } |
1222 | +#include <ubuntu-app-launch/registry.h> |
1223 | + |
1224 | +namespace ual = ubuntu::app_launch; |
1225 | |
1226 | namespace qtmir |
1227 | { |
1228 | @@ -35,6 +39,7 @@ |
1229 | |
1230 | struct TaskController::Private |
1231 | { |
1232 | + std::shared_ptr<ual::Registry> registry; |
1233 | UbuntuAppLaunchAppObserver preStartCallback = nullptr; |
1234 | UbuntuAppLaunchAppObserver startedCallback = nullptr; |
1235 | UbuntuAppLaunchAppObserver stopCallback = nullptr; |
1236 | @@ -63,39 +68,14 @@ |
1237 | } |
1238 | } |
1239 | |
1240 | -/** |
1241 | - * @brief toLongAppIdIfPossible |
1242 | - * @param shortAppId - any string that you think is a short appId |
1243 | - * @return if valid short appId was input, the corresponding long appId is returned. If a long appId was |
1244 | - * entered, it is returned unchanged. Anything else is also returned unchanged. |
1245 | - */ |
1246 | -QString toLongAppIdIfPossible(const QString &shortAppId) { |
1247 | - if (ubuntu_app_launch_app_id_parse(shortAppId.toLatin1().constData(), nullptr, nullptr, nullptr)) { |
1248 | - // then we got a long appId after all, just return it |
1249 | - return shortAppId; |
1250 | - } else { |
1251 | - // try to parse the string in the form "$package_$application" |
1252 | - QRegExp shortAppIdMask("[a-z0-9][a-z0-9+.-]+_[a-zA-Z0-9+.-]+"); |
1253 | - if (!shortAppIdMask.exactMatch(shortAppId)) { |
1254 | - // input string not a short appId, so just return it unchanged |
1255 | - return shortAppId; |
1256 | - } |
1257 | - |
1258 | - // ask upstart for the long appId corresponding to this short appId |
1259 | - QStringList parts = shortAppId.split("_"); |
1260 | - gchar *longAppId; |
1261 | - longAppId = ubuntu_app_launch_triplet_to_app_id(parts.first().toLatin1().constData(), |
1262 | - parts.last().toLatin1().constData(), |
1263 | - nullptr); |
1264 | - if (longAppId == nullptr) { |
1265 | - // was unable to construct a long appId from the short appId, return input unchanged |
1266 | - return shortAppId; |
1267 | - } else { |
1268 | - QString appId(longAppId); |
1269 | - g_free(longAppId); |
1270 | - return appId; |
1271 | - } |
1272 | +std::shared_ptr<ual::Application> createApp(const QString &inputAppId, std::shared_ptr<ual::Registry> registry) |
1273 | +{ |
1274 | + auto appId = ual::AppID::find(inputAppId.toStdString()); |
1275 | + if (appId.empty()) { |
1276 | + qCDebug(QTMIR_APPLICATIONS) << "ApplicationController::createApp could not find appId" << inputAppId; |
1277 | + return {}; |
1278 | } |
1279 | + return ual::Application::create(appId, registry); |
1280 | } |
1281 | |
1282 | } // namespace |
1283 | @@ -104,6 +84,8 @@ |
1284 | : qtmir::TaskController(), |
1285 | impl(new Private()) |
1286 | { |
1287 | + impl->registry = std::make_shared<ual::Registry>(); |
1288 | + |
1289 | impl->preStartCallback = [](const gchar * appId, gpointer userData) { |
1290 | auto thiz = static_cast<TaskController*>(userData); |
1291 | Q_EMIT(thiz->processStarting(toShortAppIdIfPossible(appId))); |
1292 | @@ -166,91 +148,91 @@ |
1293 | ubuntu_app_launch_observer_delete_app_failed(impl->failureCallback, this); |
1294 | } |
1295 | |
1296 | -pid_t TaskController::primaryPidForAppId(const QString& appId) |
1297 | -{ |
1298 | - GPid pid = ubuntu_app_launch_get_primary_pid(toLongAppIdIfPossible(appId).toLatin1().constData()); |
1299 | - if (!pid) |
1300 | - qDebug() << "TaskController::primaryPidForAppId FAILED to get PID for appId=" << appId; |
1301 | - |
1302 | - return pid; |
1303 | -} |
1304 | - |
1305 | bool TaskController::appIdHasProcessId(const QString& appId, pid_t pid) |
1306 | { |
1307 | - return ubuntu_app_launch_pid_in_app_id(pid, toLongAppIdIfPossible(appId).toLatin1().constData()); |
1308 | + auto app = createApp(appId, impl->registry); |
1309 | + if (!app) { |
1310 | + return false; |
1311 | + } |
1312 | + |
1313 | + for (auto &instance: app->instances()) { |
1314 | + if (instance->hasPid(pid)) { |
1315 | + return true; |
1316 | + } |
1317 | + } |
1318 | + |
1319 | + return false; |
1320 | } |
1321 | |
1322 | bool TaskController::stop(const QString& appId) |
1323 | { |
1324 | - auto result = ubuntu_app_launch_stop_application(toLongAppIdIfPossible(appId).toLatin1().constData()); |
1325 | - if (!result) |
1326 | - qDebug() << "TaskController::stopApplication FAILED to stop appId=" << appId; |
1327 | - |
1328 | - return result; |
1329 | + auto app = createApp(appId, impl->registry); |
1330 | + if (!app) { |
1331 | + return false; |
1332 | + } |
1333 | + |
1334 | + for (auto &instance: app->instances()) { |
1335 | + instance->stop(); |
1336 | + } |
1337 | + |
1338 | + return true; |
1339 | } |
1340 | |
1341 | bool TaskController::start(const QString& appId, const QStringList& arguments) |
1342 | { |
1343 | + auto app = createApp(appId, impl->registry); |
1344 | + if (!app) { |
1345 | + return false; |
1346 | + } |
1347 | + |
1348 | // Convert arguments QStringList into format suitable for ubuntu-app-launch |
1349 | - // The last item should be null, which is done by g_new0, we just don't fill it. |
1350 | - auto upstartArgs = g_new0(gchar *, arguments.length() + 1); |
1351 | - |
1352 | - for (int i=0; i<arguments.length(); i++) { |
1353 | - upstartArgs[i] = g_strdup(arguments.at(i).toUtf8().data()); |
1354 | + std::vector<ual::Application::URL> urls; |
1355 | + for (auto &arg: arguments) { |
1356 | + urls.emplace_back(ual::Application::URL::from_raw(arg.toStdString())); |
1357 | } |
1358 | |
1359 | - auto result = ubuntu_app_launch_start_application( |
1360 | - toLongAppIdIfPossible(appId).toLatin1().constData(), |
1361 | - static_cast<const gchar * const *>(upstartArgs)); |
1362 | - |
1363 | - g_strfreev(upstartArgs); |
1364 | - |
1365 | - if (!result) |
1366 | - qDebug() << "TaskController::start FAILED to start appId" << appId; |
1367 | - |
1368 | - return result; |
1369 | + app->launch(urls); |
1370 | + |
1371 | + return true; |
1372 | } |
1373 | |
1374 | bool TaskController::suspend(const QString& appId) |
1375 | { |
1376 | - auto result = ubuntu_app_launch_pause_application(toLongAppIdIfPossible(appId).toLatin1().constData()); |
1377 | - if (!result) |
1378 | - qDebug() << "TaskController::pauseApplication FAILED to pause appId=" << appId; |
1379 | - |
1380 | - return result; |
1381 | + auto app = createApp(appId, impl->registry); |
1382 | + if (!app) { |
1383 | + return false; |
1384 | + } |
1385 | + |
1386 | + for (auto &instance: app->instances()) { |
1387 | + instance->pause(); |
1388 | + } |
1389 | + |
1390 | + return true; |
1391 | } |
1392 | |
1393 | bool TaskController::resume(const QString& appId) |
1394 | { |
1395 | - auto result = ubuntu_app_launch_resume_application(toLongAppIdIfPossible(appId).toLatin1().constData()); |
1396 | - if (!result) |
1397 | - qDebug() << "TaskController::resumeApplication FAILED to resume appId=" << appId; |
1398 | - |
1399 | - return result; |
1400 | + auto app = createApp(appId, impl->registry); |
1401 | + if (!app) { |
1402 | + return false; |
1403 | + } |
1404 | + |
1405 | + for (auto &instance: app->instances()) { |
1406 | + instance->resume(); |
1407 | + } |
1408 | + |
1409 | + return true; |
1410 | } |
1411 | |
1412 | - |
1413 | -QFileInfo TaskController::findDesktopFileForAppId(const QString &appId) const |
1414 | +qtmir::ApplicationInfo *TaskController::getInfoForApp(const QString &appId) const |
1415 | { |
1416 | - qCDebug(QTMIR_APPLICATIONS) << "TaskController::desktopFilePathForAppId - appId=" << appId; |
1417 | - |
1418 | - // Search for the correct desktop file using a simple heuristic |
1419 | - int dashPos = -1; |
1420 | - QString helper = toLongAppIdIfPossible(appId); |
1421 | - QString desktopFile; |
1422 | - |
1423 | - do { |
1424 | - if (dashPos != -1) { |
1425 | - helper = helper.replace(dashPos, 1, '/'); |
1426 | - } |
1427 | - |
1428 | - desktopFile = QStandardPaths::locate(QStandardPaths::ApplicationsLocation, QString("%1.desktop").arg(helper)); |
1429 | - if (!desktopFile.isEmpty()) return desktopFile; |
1430 | - |
1431 | - dashPos = helper.indexOf("-"); |
1432 | - } while (dashPos != -1); |
1433 | - |
1434 | - return QFileInfo(); |
1435 | + auto app = createApp(appId, impl->registry); |
1436 | + if (!app || !app->info()) { |
1437 | + return nullptr; |
1438 | + } |
1439 | + |
1440 | + QString shortAppId = toShortAppIdIfPossible(QString::fromStdString(std::string(app->appId()))); |
1441 | + return new qtmir::upstart::ApplicationInfo(shortAppId, app->info()); |
1442 | } |
1443 | |
1444 | } // namespace upstart |
1445 | |
1446 | === modified file 'src/modules/Unity/Application/upstart/taskcontroller.h' |
1447 | --- src/modules/Unity/Application/upstart/taskcontroller.h 2016-02-11 11:52:06 +0000 |
1448 | +++ src/modules/Unity/Application/upstart/taskcontroller.h 2016-03-02 00:44:09 +0000 |
1449 | @@ -31,7 +31,6 @@ |
1450 | TaskController(); |
1451 | ~TaskController(); |
1452 | |
1453 | - pid_t primaryPidForAppId(const QString& appId) override; |
1454 | bool appIdHasProcessId(const QString& appId, pid_t pid) override; |
1455 | |
1456 | bool stop(const QString& appId) override; |
1457 | @@ -40,7 +39,7 @@ |
1458 | bool suspend(const QString& appId) override; |
1459 | bool resume(const QString& appId) override; |
1460 | |
1461 | - QFileInfo findDesktopFileForAppId(const QString &appId) const override; |
1462 | + qtmir::ApplicationInfo *getInfoForApp(const QString &appId) const override; |
1463 | |
1464 | private: |
1465 | struct Private; |
1466 | |
1467 | === modified file 'tests/framework/CMakeLists.txt' |
1468 | --- tests/framework/CMakeLists.txt 2016-02-11 11:52:06 +0000 |
1469 | +++ tests/framework/CMakeLists.txt 2016-03-02 00:44:09 +0000 |
1470 | @@ -10,11 +10,10 @@ |
1471 | ) |
1472 | |
1473 | set(QTMIR_TEST_PRIVATE_SRC |
1474 | - fake_desktopfilereader.cpp |
1475 | + fake_application_info.cpp |
1476 | fake_mirsurface.cpp |
1477 | fake_session.cpp |
1478 | - mock_task_controller.cpp |
1479 | - mock_desktop_file_reader.cpp |
1480 | + mock_application_info.cpp |
1481 | mock_display.cpp |
1482 | mock_display_configuration.cpp |
1483 | mock_gl_display_buffer.cpp |
1484 | @@ -28,6 +27,7 @@ |
1485 | mock_settings.cpp |
1486 | mock_shared_wakelock.cpp |
1487 | mock_surface.cpp |
1488 | + mock_task_controller.cpp |
1489 | stub_input_channel.cpp |
1490 | stub_scene_surface.cpp |
1491 | qtmir_test.cpp |
1492 | |
1493 | === renamed file 'tests/framework/fake_desktopfilereader.cpp' => 'tests/framework/fake_application_info.cpp' |
1494 | --- tests/framework/fake_desktopfilereader.cpp 2016-02-11 11:52:06 +0000 |
1495 | +++ tests/framework/fake_application_info.cpp 2016-03-02 00:44:09 +0000 |
1496 | @@ -14,63 +14,53 @@ |
1497 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
1498 | */ |
1499 | |
1500 | -#include "fake_desktopfilereader.h" |
1501 | +#include "fake_application_info.h" |
1502 | |
1503 | #include <QDebug> |
1504 | |
1505 | namespace qtmir |
1506 | { |
1507 | |
1508 | -FakeDesktopFileReader::FakeDesktopFileReader(const QString &appId) |
1509 | - : DesktopFileReader() |
1510 | +FakeApplicationInfo::FakeApplicationInfo(const QString &appId) |
1511 | + : ApplicationInfo() |
1512 | , m_appId(appId) |
1513 | { |
1514 | } |
1515 | |
1516 | -FakeDesktopFileReader::FakeDesktopFileReader() |
1517 | - : DesktopFileReader() |
1518 | +FakeApplicationInfo::FakeApplicationInfo() |
1519 | + : ApplicationInfo() |
1520 | , m_appId("foo-app") |
1521 | { |
1522 | } |
1523 | |
1524 | -FakeDesktopFileReader::~FakeDesktopFileReader() |
1525 | +FakeApplicationInfo::~FakeApplicationInfo() |
1526 | { |
1527 | } |
1528 | |
1529 | -QString FakeDesktopFileReader::file() const { return m_appId + ".desktop"; } |
1530 | - |
1531 | -QString FakeDesktopFileReader::appId() const { return m_appId; } |
1532 | - |
1533 | -QString FakeDesktopFileReader::name() const { return QString(); } |
1534 | - |
1535 | -QString FakeDesktopFileReader::comment() const { return QString(); } |
1536 | - |
1537 | -QString FakeDesktopFileReader::icon() const { return QString(); } |
1538 | - |
1539 | -QString FakeDesktopFileReader::exec() const { return QString(); } |
1540 | - |
1541 | -QString FakeDesktopFileReader::path() const { return QString(); } |
1542 | - |
1543 | -QString FakeDesktopFileReader::stageHint() const { return QString(); } |
1544 | - |
1545 | -QString FakeDesktopFileReader::splashTitle() const { return QString(); } |
1546 | - |
1547 | -QString FakeDesktopFileReader::splashImage() const { return QString(); } |
1548 | - |
1549 | -QString FakeDesktopFileReader::splashShowHeader() const { return QString(); } |
1550 | - |
1551 | -QString FakeDesktopFileReader::splashColor() const { return QString(); } |
1552 | - |
1553 | -QString FakeDesktopFileReader::splashColorHeader() const { return QString(); } |
1554 | - |
1555 | -QString FakeDesktopFileReader::splashColorFooter() const { return QString(); } |
1556 | - |
1557 | -Qt::ScreenOrientations FakeDesktopFileReader::supportedOrientations() const { return Qt::PortraitOrientation; } |
1558 | - |
1559 | -bool FakeDesktopFileReader::rotatesWindowContents() const { return false; } |
1560 | - |
1561 | -bool FakeDesktopFileReader::isTouchApp() const { return true; } |
1562 | - |
1563 | -bool FakeDesktopFileReader::loaded() const { return true; } |
1564 | +QString FakeApplicationInfo::appId() const { return m_appId; } |
1565 | + |
1566 | +QString FakeApplicationInfo::name() const { return QString(); } |
1567 | + |
1568 | +QString FakeApplicationInfo::comment() const { return QString(); } |
1569 | + |
1570 | +QUrl FakeApplicationInfo::icon() const { return QUrl(); } |
1571 | + |
1572 | +QString FakeApplicationInfo::splashTitle() const { return QString(); } |
1573 | + |
1574 | +QUrl FakeApplicationInfo::splashImage() const { return QUrl(); } |
1575 | + |
1576 | +bool FakeApplicationInfo::splashShowHeader() const { return false; } |
1577 | + |
1578 | +QString FakeApplicationInfo::splashColor() const { return QString(); } |
1579 | + |
1580 | +QString FakeApplicationInfo::splashColorHeader() const { return QString(); } |
1581 | + |
1582 | +QString FakeApplicationInfo::splashColorFooter() const { return QString(); } |
1583 | + |
1584 | +Qt::ScreenOrientations FakeApplicationInfo::supportedOrientations() const { return Qt::PortraitOrientation; } |
1585 | + |
1586 | +bool FakeApplicationInfo::rotatesWindowContents() const { return false; } |
1587 | + |
1588 | +bool FakeApplicationInfo::isTouchApp() const { return true; } |
1589 | |
1590 | } // namespace qtmir |
1591 | |
1592 | === renamed file 'tests/framework/fake_desktopfilereader.h' => 'tests/framework/fake_application_info.h' |
1593 | --- tests/framework/fake_desktopfilereader.h 2016-02-11 11:52:06 +0000 |
1594 | +++ tests/framework/fake_application_info.h 2016-03-02 00:44:09 +0000 |
1595 | @@ -1,5 +1,5 @@ |
1596 | /* |
1597 | - * Copyright (C) 2015 Canonical, Ltd. |
1598 | + * Copyright (C) 2015,2016 Canonical, Ltd. |
1599 | * |
1600 | * This program is free software: you can redistribute it and/or modify it under |
1601 | * the terms of the GNU Lesser General Public License version 3, as published by |
1602 | @@ -14,42 +14,37 @@ |
1603 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
1604 | */ |
1605 | |
1606 | -#ifndef FAKE_DESKTOPFILEREADER_H |
1607 | -#define FAKE_DESKTOPFILEREADER_H |
1608 | +#ifndef FAKE_APPLICATION_INFO_H |
1609 | +#define FAKE_APPLICATION_INFO_H |
1610 | |
1611 | -#include <Unity/Application/desktopfilereader.h> |
1612 | +#include <Unity/Application/applicationinfo.h> |
1613 | |
1614 | namespace qtmir { |
1615 | |
1616 | -class FakeDesktopFileReader : public qtmir::DesktopFileReader |
1617 | +class FakeApplicationInfo : public ApplicationInfo |
1618 | { |
1619 | public: |
1620 | - FakeDesktopFileReader(const QString &appId); |
1621 | - FakeDesktopFileReader(); |
1622 | - virtual ~FakeDesktopFileReader(); |
1623 | + FakeApplicationInfo(const QString &appId); |
1624 | + FakeApplicationInfo(); |
1625 | + virtual ~FakeApplicationInfo(); |
1626 | |
1627 | - QString file() const override; |
1628 | QString appId() const override; |
1629 | QString name() const override; |
1630 | QString comment() const override; |
1631 | - QString icon() const override; |
1632 | - QString exec() const override; |
1633 | - QString path() const override; |
1634 | - QString stageHint() const override; |
1635 | + QUrl icon() const override; |
1636 | QString splashTitle() const override; |
1637 | - QString splashImage() const override; |
1638 | - QString splashShowHeader() const override; |
1639 | + QUrl splashImage() const override; |
1640 | + bool splashShowHeader() const override; |
1641 | QString splashColor() const override; |
1642 | QString splashColorHeader() const override; |
1643 | QString splashColorFooter() const override; |
1644 | Qt::ScreenOrientations supportedOrientations() const override; |
1645 | bool rotatesWindowContents() const override; |
1646 | bool isTouchApp() const override; |
1647 | - bool loaded() const override; |
1648 | |
1649 | QString m_appId; |
1650 | }; |
1651 | |
1652 | } // namespace qtmir |
1653 | |
1654 | -#endif // FAKE_DESKTOPFILEREADER_H |
1655 | +#endif // FAKE_APPLICATION_INFO_H |
1656 | |
1657 | === renamed file 'tests/framework/mock_desktop_file_reader.cpp' => 'tests/framework/mock_application_info.cpp' |
1658 | --- tests/framework/mock_desktop_file_reader.cpp 2015-11-11 10:43:36 +0000 |
1659 | +++ tests/framework/mock_application_info.cpp 2016-03-02 00:44:09 +0000 |
1660 | @@ -14,104 +14,33 @@ |
1661 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
1662 | */ |
1663 | |
1664 | -#include "mock_desktop_file_reader.h" |
1665 | +#include "mock_application_info.h" |
1666 | |
1667 | namespace qtmir |
1668 | { |
1669 | |
1670 | -MockDesktopFileReader::MockDesktopFileReader(const QString &appId, const QFileInfo &fileInfo) |
1671 | - : DesktopFileReader(appId, fileInfo) |
1672 | -{ |
1673 | - using namespace ::testing; |
1674 | - |
1675 | - ON_CALL(*this, file()).WillByDefault(Invoke(this, &MockDesktopFileReader::doFile)); |
1676 | - ON_CALL(*this, appId()).WillByDefault(Invoke(this, &MockDesktopFileReader::doAppId)); |
1677 | - ON_CALL(*this, name()).WillByDefault(Invoke(this, &MockDesktopFileReader::doName)); |
1678 | - ON_CALL(*this, comment()).WillByDefault(Invoke(this, &MockDesktopFileReader::doComment)); |
1679 | - ON_CALL(*this, icon()).WillByDefault(Invoke(this, &MockDesktopFileReader::doIcon)); |
1680 | - ON_CALL(*this, exec()).WillByDefault(Invoke(this, &MockDesktopFileReader::doExec)); |
1681 | - ON_CALL(*this, path()).WillByDefault(Invoke(this, &MockDesktopFileReader::doPath)); |
1682 | - ON_CALL(*this, stageHint()).WillByDefault(Invoke(this, &MockDesktopFileReader::doStageHint)); |
1683 | - ON_CALL(*this, isTouchApp()).WillByDefault(Invoke(this, &MockDesktopFileReader::doIsTouchApp)); |
1684 | - ON_CALL(*this, loaded()).WillByDefault(Invoke(this, &MockDesktopFileReader::doLoaded)); |
1685 | -} |
1686 | - |
1687 | -MockDesktopFileReader::~MockDesktopFileReader() |
1688 | -{ |
1689 | -} |
1690 | - |
1691 | -QString MockDesktopFileReader::doFile() const |
1692 | -{ |
1693 | - return DesktopFileReader::file(); |
1694 | -} |
1695 | - |
1696 | -QString MockDesktopFileReader::doAppId() const |
1697 | -{ |
1698 | - return DesktopFileReader::appId(); |
1699 | -} |
1700 | - |
1701 | -QString MockDesktopFileReader::doName() const |
1702 | -{ |
1703 | - return DesktopFileReader::name(); |
1704 | -} |
1705 | - |
1706 | -QString MockDesktopFileReader::doComment() const |
1707 | -{ |
1708 | - return DesktopFileReader::comment(); |
1709 | -} |
1710 | - |
1711 | -QString MockDesktopFileReader::doIcon() const |
1712 | -{ |
1713 | - return DesktopFileReader::icon(); |
1714 | -} |
1715 | - |
1716 | -QString MockDesktopFileReader::doExec() const |
1717 | -{ |
1718 | - return DesktopFileReader::exec(); |
1719 | -} |
1720 | - |
1721 | -QString MockDesktopFileReader::doPath() const |
1722 | -{ |
1723 | - return DesktopFileReader::path(); |
1724 | -} |
1725 | - |
1726 | -QString MockDesktopFileReader::doStageHint() const |
1727 | -{ |
1728 | - return DesktopFileReader::stageHint(); |
1729 | -} |
1730 | - |
1731 | -bool MockDesktopFileReader::doIsTouchApp() const |
1732 | -{ |
1733 | - return DesktopFileReader::isTouchApp(); |
1734 | -} |
1735 | - |
1736 | -bool MockDesktopFileReader::doLoaded() const |
1737 | -{ |
1738 | - return DesktopFileReader::loaded(); |
1739 | -} |
1740 | - |
1741 | - |
1742 | -MockDesktopFileReaderFactory::MockDesktopFileReaderFactory() |
1743 | -{ |
1744 | - using namespace ::testing; |
1745 | - ON_CALL(*this, createInstance(_, _)) |
1746 | - .WillByDefault( |
1747 | - Invoke( |
1748 | - this, |
1749 | - &MockDesktopFileReaderFactory::doCreateInstance)); |
1750 | -} |
1751 | - |
1752 | -MockDesktopFileReaderFactory::~MockDesktopFileReaderFactory() |
1753 | -{ |
1754 | -} |
1755 | - |
1756 | -qtmir::DesktopFileReader *MockDesktopFileReaderFactory::doCreateInstance(const QString &appId, const QFileInfo &fi) |
1757 | -{ |
1758 | - using namespace ::testing; |
1759 | - auto instance = new NiceMock<MockDesktopFileReader>(appId, fi); |
1760 | - ON_CALL(*instance, loaded()).WillByDefault(Return(true)); |
1761 | - |
1762 | - return instance; |
1763 | +MockApplicationInfo::MockApplicationInfo(const QString &appId) |
1764 | + : ApplicationInfo() |
1765 | +{ |
1766 | + using namespace ::testing; |
1767 | + |
1768 | + ON_CALL(*this, appId()).WillByDefault(Return(appId)); |
1769 | + ON_CALL(*this, name()).WillByDefault(Return(QString())); |
1770 | + ON_CALL(*this, comment()).WillByDefault(Return(QString())); |
1771 | + ON_CALL(*this, icon()).WillByDefault(Return(QUrl())); |
1772 | + ON_CALL(*this, splashTitle()).WillByDefault(Return(QString())); |
1773 | + ON_CALL(*this, splashImage()).WillByDefault(Return(QUrl())); |
1774 | + ON_CALL(*this, splashShowHeader()).WillByDefault(Return(false)); |
1775 | + ON_CALL(*this, splashColor()).WillByDefault(Return(QString())); |
1776 | + ON_CALL(*this, splashColorHeader()).WillByDefault(Return(QString())); |
1777 | + ON_CALL(*this, splashColorFooter()).WillByDefault(Return(QString())); |
1778 | + ON_CALL(*this, supportedOrientations()).WillByDefault(Return(Qt::PrimaryOrientation)); |
1779 | + ON_CALL(*this, rotatesWindowContents()).WillByDefault(Return(false)); |
1780 | + ON_CALL(*this, isTouchApp()).WillByDefault(Return(true)); |
1781 | +} |
1782 | + |
1783 | +MockApplicationInfo::~MockApplicationInfo() |
1784 | +{ |
1785 | } |
1786 | |
1787 | } // namespace qtmir |
1788 | |
1789 | === renamed file 'tests/framework/mock_desktop_file_reader.h' => 'tests/framework/mock_application_info.h' |
1790 | --- tests/framework/mock_desktop_file_reader.h 2015-11-11 10:43:36 +0000 |
1791 | +++ tests/framework/mock_application_info.h 2016-03-02 00:44:09 +0000 |
1792 | @@ -14,54 +14,36 @@ |
1793 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
1794 | */ |
1795 | |
1796 | -#ifndef MOCK_DESKTOP_FILE_READER_H |
1797 | -#define MOCK_DESKTOP_FILE_READER_H |
1798 | +#ifndef MOCK_APPLICATION_INFO_H |
1799 | +#define MOCK_APPLICATION_INFO_H |
1800 | |
1801 | -#include <Unity/Application/desktopfilereader.h> |
1802 | +#include <Unity/Application/applicationinfo.h> |
1803 | |
1804 | #include <gmock/gmock.h> |
1805 | |
1806 | namespace qtmir |
1807 | { |
1808 | |
1809 | -struct MockDesktopFileReader : public qtmir::DesktopFileReader |
1810 | +struct MockApplicationInfo : public qtmir::ApplicationInfo |
1811 | { |
1812 | - MockDesktopFileReader(const QString &appId, const QFileInfo& fileInfo); |
1813 | - virtual ~MockDesktopFileReader(); |
1814 | + MockApplicationInfo(const QString &appId); |
1815 | + virtual ~MockApplicationInfo(); |
1816 | |
1817 | - MOCK_CONST_METHOD0(file, QString()); |
1818 | - MOCK_CONST_METHOD0(appId, QString ()); |
1819 | + MOCK_CONST_METHOD0(appId, QString()); |
1820 | MOCK_CONST_METHOD0(name, QString()); |
1821 | MOCK_CONST_METHOD0(comment, QString()); |
1822 | - MOCK_CONST_METHOD0(icon, QString()); |
1823 | - MOCK_CONST_METHOD0(exec, QString()); |
1824 | - MOCK_CONST_METHOD0(path, QString()); |
1825 | - MOCK_CONST_METHOD0(stageHint, QString()); |
1826 | + MOCK_CONST_METHOD0(icon, QUrl()); |
1827 | + MOCK_CONST_METHOD0(splashTitle, QString()); |
1828 | + MOCK_CONST_METHOD0(splashImage, QUrl()); |
1829 | + MOCK_CONST_METHOD0(splashShowHeader, bool()); |
1830 | + MOCK_CONST_METHOD0(splashColor, QString()); |
1831 | + MOCK_CONST_METHOD0(splashColorHeader, QString()); |
1832 | + MOCK_CONST_METHOD0(splashColorFooter, QString()); |
1833 | + MOCK_CONST_METHOD0(supportedOrientations, Qt::ScreenOrientations()); |
1834 | + MOCK_CONST_METHOD0(rotatesWindowContents, bool()); |
1835 | MOCK_CONST_METHOD0(isTouchApp, bool()); |
1836 | - MOCK_CONST_METHOD0(loaded, bool()); |
1837 | - |
1838 | - QString doFile() const; |
1839 | - QString doAppId() const; |
1840 | - QString doName() const; |
1841 | - QString doComment() const; |
1842 | - QString doIcon() const; |
1843 | - QString doExec() const; |
1844 | - QString doPath() const; |
1845 | - QString doStageHint() const; |
1846 | - bool doIsTouchApp() const; |
1847 | - bool doLoaded() const; |
1848 | -}; |
1849 | - |
1850 | -struct MockDesktopFileReaderFactory : public qtmir::DesktopFileReader::Factory |
1851 | -{ |
1852 | - MockDesktopFileReaderFactory(); |
1853 | - virtual ~MockDesktopFileReaderFactory(); |
1854 | - |
1855 | - virtual qtmir::DesktopFileReader* doCreateInstance(const QString &appId, const QFileInfo &fi); |
1856 | - |
1857 | - MOCK_METHOD2(createInstance, qtmir::DesktopFileReader*(const QString &appId, const QFileInfo &fi)); |
1858 | }; |
1859 | |
1860 | } // namespace qtmir |
1861 | |
1862 | -#endif // MOCK_DESKTOP_FILE_READER_H |
1863 | +#endif // MOCK_APPLICATION_INFO_H |
1864 | |
1865 | === modified file 'tests/framework/mock_task_controller.cpp' |
1866 | --- tests/framework/mock_task_controller.cpp 2016-02-11 11:52:06 +0000 |
1867 | +++ tests/framework/mock_task_controller.cpp 2016-03-02 00:44:09 +0000 |
1868 | @@ -14,6 +14,7 @@ |
1869 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
1870 | */ |
1871 | |
1872 | +#include "mock_application_info.h" |
1873 | #include "mock_task_controller.h" |
1874 | |
1875 | namespace qtmir |
1876 | @@ -22,17 +23,14 @@ |
1877 | MockTaskController::MockTaskController() |
1878 | { |
1879 | using namespace ::testing; |
1880 | - ON_CALL(*this, primaryPidForAppId(_)) |
1881 | - .WillByDefault( |
1882 | - Invoke(this, &MockTaskController::doPrimaryPidForAppId)); |
1883 | |
1884 | ON_CALL(*this, appIdHasProcessId(_, _)) |
1885 | .WillByDefault( |
1886 | Invoke(this, &MockTaskController::doAppIdHasProcessId)); |
1887 | |
1888 | - ON_CALL(*this, findDesktopFileForAppId(_)) |
1889 | + ON_CALL(*this, getInfoForApp(_)) |
1890 | .WillByDefault( |
1891 | - Invoke(this, &MockTaskController::doFindDesktopFileForAppId)); |
1892 | + Invoke(this, &MockTaskController::doGetInfoForApp)); |
1893 | |
1894 | ON_CALL(*this, stop(_)) |
1895 | .WillByDefault( |
1896 | @@ -56,15 +54,6 @@ |
1897 | |
1898 | } |
1899 | |
1900 | -pid_t MockTaskController::doPrimaryPidForAppId(const QString &appId) |
1901 | -{ |
1902 | - auto it = children.find(appId); |
1903 | - if (it == children.end()) |
1904 | - return -1; |
1905 | - |
1906 | - return it->pid(); |
1907 | -} |
1908 | - |
1909 | |
1910 | bool MockTaskController::doAppIdHasProcessId(const QString &appId, pid_t pid) |
1911 | { |
1912 | @@ -76,10 +65,9 @@ |
1913 | } |
1914 | |
1915 | |
1916 | -QFileInfo MockTaskController::doFindDesktopFileForAppId(const QString &appId) const |
1917 | +qtmir::ApplicationInfo *MockTaskController::doGetInfoForApp(const QString& appId) const |
1918 | { |
1919 | - QString path = QString("/usr/share/applications/%1.desktop").arg(appId); |
1920 | - return QFileInfo(path); |
1921 | + return new testing::NiceMock<MockApplicationInfo>(appId); |
1922 | } |
1923 | |
1924 | |
1925 | |
1926 | === modified file 'tests/framework/mock_task_controller.h' |
1927 | --- tests/framework/mock_task_controller.h 2016-02-11 11:52:06 +0000 |
1928 | +++ tests/framework/mock_task_controller.h 2016-03-02 00:44:09 +0000 |
1929 | @@ -31,20 +31,17 @@ |
1930 | MockTaskController(); |
1931 | virtual ~MockTaskController(); |
1932 | |
1933 | - MOCK_METHOD1(primaryPidForAppId, pid_t(const QString& appId)); |
1934 | MOCK_METHOD2(appIdHasProcessId, bool(const QString&, pid_t)); |
1935 | - MOCK_CONST_METHOD1(findDesktopFileForAppId, QFileInfo(const QString &appId)); |
1936 | + MOCK_CONST_METHOD1(getInfoForApp, qtmir::ApplicationInfo *(const QString &)); |
1937 | |
1938 | MOCK_METHOD1(stop, bool(const QString&)); |
1939 | MOCK_METHOD2(start, bool(const QString&, const QStringList&)); |
1940 | MOCK_METHOD1(suspend, bool(const QString&)); |
1941 | MOCK_METHOD1(resume, bool(const QString&)); |
1942 | |
1943 | - pid_t doPrimaryPidForAppId(const QString& appId); |
1944 | - |
1945 | bool doAppIdHasProcessId(const QString& appId, pid_t pid); |
1946 | |
1947 | - QFileInfo doFindDesktopFileForAppId(const QString& appId) const; |
1948 | + qtmir::ApplicationInfo *doGetInfoForApp(const QString& appId) const; |
1949 | |
1950 | bool doStop(const QString& appId); |
1951 | |
1952 | |
1953 | === modified file 'tests/framework/qtmir_test.cpp' |
1954 | --- tests/framework/qtmir_test.cpp 2016-02-11 11:52:06 +0000 |
1955 | +++ tests/framework/qtmir_test.cpp 2016-03-02 00:44:09 +0000 |
1956 | @@ -123,7 +123,6 @@ |
1957 | , applicationManager(mirServer, |
1958 | taskControllerSharedPointer, |
1959 | QSharedPointer<MockSharedWakelock>(&sharedWakelock, [](MockSharedWakelock *){}), |
1960 | - QSharedPointer<DesktopFileReader::Factory>(&desktopFileReaderFactory,[](DesktopFileReader::Factory*){}), |
1961 | QSharedPointer<ProcInfo>(&procInfo,[](ProcInfo *){}), |
1962 | QSharedPointer<MockSettings>(&settings,[](MockSettings *){})) |
1963 | , sessionManager(mirServer, &applicationManager) |
1964 | @@ -143,14 +142,6 @@ |
1965 | ON_CALL(*taskController,appIdHasProcessId(appId, procId)).WillByDefault(Return(true)); |
1966 | |
1967 | // Set up Mocks & signal watcher |
1968 | - auto mockDesktopFileReader = new NiceMock<MockDesktopFileReader>(appId, QFileInfo()); |
1969 | - ON_CALL(*mockDesktopFileReader, loaded()).WillByDefault(Return(true)); |
1970 | - ON_CALL(*mockDesktopFileReader, appId()).WillByDefault(Return(appId)); |
1971 | - |
1972 | - EXPECT_CALL(desktopFileReaderFactory, createInstance(appId, _)) |
1973 | - .Times(1) |
1974 | - .WillOnce(Return(mockDesktopFileReader)); |
1975 | - |
1976 | EXPECT_CALL(*taskController, start(appId, _)) |
1977 | .Times(1) |
1978 | .WillOnce(Return(true)); |
1979 | @@ -167,7 +158,6 @@ |
1980 | sessionManager.onSessionStarting(appSession); |
1981 | |
1982 | Mock::VerifyAndClearExpectations(taskController); |
1983 | - Mock::VerifyAndClearExpectations(&desktopFileReaderFactory); |
1984 | return application; |
1985 | } |
1986 | |
1987 | |
1988 | === modified file 'tests/framework/qtmir_test.h' |
1989 | --- tests/framework/qtmir_test.h 2016-02-11 11:52:06 +0000 |
1990 | +++ tests/framework/qtmir_test.h 2016-03-02 00:44:09 +0000 |
1991 | @@ -32,7 +32,6 @@ |
1992 | #include <Unity/Application/proc_info.h> |
1993 | #include <mirserver.h> |
1994 | |
1995 | -#include "mock_desktop_file_reader.h" |
1996 | #include "mock_proc_info.h" |
1997 | #include "mock_mir_session.h" |
1998 | #include "mock_prompt_session_manager.h" |
1999 | @@ -67,7 +66,6 @@ |
2000 | QSharedPointer<qtmir::TaskController> taskControllerSharedPointer{new testing::NiceMock<qtmir::MockTaskController>}; |
2001 | testing::NiceMock<qtmir::MockTaskController> *taskController{static_cast<testing::NiceMock<qtmir::MockTaskController>*>(taskControllerSharedPointer.data())}; |
2002 | testing::NiceMock<MockProcInfo> procInfo; |
2003 | - testing::NiceMock<MockDesktopFileReaderFactory> desktopFileReaderFactory; |
2004 | testing::NiceMock<MockSharedWakelock> sharedWakelock; |
2005 | testing::NiceMock<MockSettings> settings; |
2006 | std::shared_ptr<StubPromptSessionManager> promptSessionManager; |
2007 | |
2008 | === modified file 'tests/modules/Application/application_test.cpp' |
2009 | --- tests/modules/Application/application_test.cpp 2015-10-15 14:40:58 +0000 |
2010 | +++ tests/modules/Application/application_test.cpp 2016-03-02 00:44:09 +0000 |
2011 | @@ -19,8 +19,9 @@ |
2012 | |
2013 | #include "qtmir_test.h" |
2014 | |
2015 | -#include <fake_desktopfilereader.h> |
2016 | +#include <fake_application_info.h> |
2017 | #include <fake_session.h> |
2018 | +#include <mock_application_info.h> |
2019 | #include <mock_session.h> |
2020 | |
2021 | #include <QScopedPointer> |
2022 | @@ -41,7 +42,7 @@ |
2023 | |
2024 | QScopedPointer<Application> application(new Application( |
2025 | QSharedPointer<MockSharedWakelock>(&sharedWakelock, [](MockSharedWakelock *){}), |
2026 | - new FakeDesktopFileReader, QStringList(), nullptr)); |
2027 | + new FakeApplicationInfo(), QStringList(), nullptr)); |
2028 | |
2029 | application->setProcessState(Application::ProcessRunning); |
2030 | |
2031 | @@ -79,7 +80,7 @@ |
2032 | |
2033 | QScopedPointer<Application> application(new Application( |
2034 | QSharedPointer<MockSharedWakelock>(&sharedWakelock, [](MockSharedWakelock *){}), |
2035 | - new FakeDesktopFileReader, QStringList(), nullptr)); |
2036 | + new FakeApplicationInfo(), QStringList(), nullptr)); |
2037 | NiceMock<MockSession> *session = new NiceMock<MockSession>; |
2038 | |
2039 | // Get it running and then suspend it |
2040 | @@ -106,7 +107,7 @@ |
2041 | |
2042 | QScopedPointer<Application> application(new Application( |
2043 | QSharedPointer<MockSharedWakelock>(&sharedWakelock, [](MockSharedWakelock *){}), |
2044 | - new FakeDesktopFileReader, QStringList(), nullptr)); |
2045 | + new FakeApplicationInfo(), QStringList(), nullptr)); |
2046 | NiceMock<MockSession> *session = new NiceMock<MockSession>; |
2047 | |
2048 | // Get it running, suspend it, and finally stop it |
2049 | @@ -140,12 +141,12 @@ |
2050 | EXPECT_CALL(sharedWakelock, acquire(_)).Times(0); |
2051 | EXPECT_CALL(sharedWakelock, release(_)).Times(0); |
2052 | |
2053 | - FakeDesktopFileReader *desktopFileReader = new FakeDesktopFileReader; |
2054 | - desktopFileReader->m_appId = QString("unity8-dash"); |
2055 | + auto applicationInfo = new FakeApplicationInfo(); |
2056 | + applicationInfo->m_appId = QString("unity8-dash"); |
2057 | |
2058 | QScopedPointer<Application> application(new Application( |
2059 | QSharedPointer<MockSharedWakelock>(&sharedWakelock, [](MockSharedWakelock *){}), |
2060 | - desktopFileReader, QStringList(), nullptr)); |
2061 | + applicationInfo, QStringList(), nullptr)); |
2062 | |
2063 | application->setProcessState(Application::ProcessRunning); |
2064 | |
2065 | @@ -183,7 +184,7 @@ |
2066 | |
2067 | QScopedPointer<Application> application(new Application( |
2068 | QSharedPointer<MockSharedWakelock>(&sharedWakelock, [](MockSharedWakelock *){}), |
2069 | - new FakeDesktopFileReader, QStringList(), nullptr)); |
2070 | + new FakeApplicationInfo(), QStringList(), nullptr)); |
2071 | |
2072 | application->setProcessState(Application::ProcessRunning); |
2073 | |
2074 | @@ -218,7 +219,7 @@ |
2075 | |
2076 | QScopedPointer<Application> application(new Application( |
2077 | QSharedPointer<MockSharedWakelock>(&sharedWakelock, [](MockSharedWakelock *){}), |
2078 | - new FakeDesktopFileReader, QStringList(), nullptr)); |
2079 | + new FakeApplicationInfo(), QStringList(), nullptr)); |
2080 | |
2081 | application->setProcessState(Application::ProcessRunning); |
2082 | |
2083 | @@ -250,7 +251,7 @@ |
2084 | |
2085 | QScopedPointer<Application> application(new Application( |
2086 | QSharedPointer<MockSharedWakelock>(&sharedWakelock, [](MockSharedWakelock *){}), |
2087 | - new FakeDesktopFileReader, QStringList(), nullptr)); |
2088 | + new FakeApplicationInfo(), QStringList(), nullptr)); |
2089 | |
2090 | application->setProcessState(Application::ProcessRunning); |
2091 | |
2092 | @@ -292,14 +293,14 @@ |
2093 | { |
2094 | using namespace ::testing; |
2095 | |
2096 | - auto mockDesktopFileReader = new NiceMock<MockDesktopFileReader>(QString(), QFileInfo()); |
2097 | + auto mockApplicationInfo = new NiceMock<MockApplicationInfo>("foo-app"); |
2098 | QScopedPointer<Application> application(new Application( |
2099 | QSharedPointer<MockSharedWakelock>(&sharedWakelock, [](MockSharedWakelock *){}), |
2100 | - mockDesktopFileReader, QStringList(), nullptr)); |
2101 | + mockApplicationInfo, QStringList(), nullptr)); |
2102 | |
2103 | - ON_CALL(*mockDesktopFileReader, isTouchApp()).WillByDefault(Return(true)); |
2104 | + ON_CALL(*mockApplicationInfo, isTouchApp()).WillByDefault(Return(true)); |
2105 | ASSERT_TRUE(application->isTouchApp()); |
2106 | |
2107 | - ON_CALL(*mockDesktopFileReader, isTouchApp()).WillByDefault(Return(false)); |
2108 | + ON_CALL(*mockApplicationInfo, isTouchApp()).WillByDefault(Return(false)); |
2109 | ASSERT_FALSE(application->isTouchApp()); |
2110 | } |
2111 | |
2112 | === modified file 'tests/modules/ApplicationManager/application_manager_test.cpp' |
2113 | --- tests/modules/ApplicationManager/application_manager_test.cpp 2016-02-12 00:07:09 +0000 |
2114 | +++ tests/modules/ApplicationManager/application_manager_test.cpp 2016-03-02 00:44:09 +0000 |
2115 | @@ -23,8 +23,8 @@ |
2116 | #include <Unity/Application/applicationscreenshotprovider.h> |
2117 | #include <Unity/Application/timer.h> |
2118 | |
2119 | -#include <fake_desktopfilereader.h> |
2120 | #include <fake_mirsurface.h> |
2121 | +#include <mock_application_info.h> |
2122 | #include <mock_surface.h> |
2123 | #include <qtmir_test.h> |
2124 | |
2125 | @@ -152,9 +152,7 @@ |
2126 | const QString shortAppId("com.canonical.test_test"); |
2127 | |
2128 | EXPECT_CALL(*taskController, start(_, _)).Times(1); |
2129 | - EXPECT_CALL(*taskController, findDesktopFileForAppId(shortAppId)).Times(1); |
2130 | - |
2131 | - EXPECT_CALL(desktopFileReaderFactory, createInstance(_, _)).Times(1); |
2132 | + EXPECT_CALL(*taskController, getInfoForApp(shortAppId)).Times(1); |
2133 | |
2134 | auto application = applicationManager.startApplication( |
2135 | shortAppId, |
2136 | @@ -172,9 +170,7 @@ |
2137 | const QString shortAppId("com.canonical.test_test"); |
2138 | |
2139 | EXPECT_CALL(*taskController, start(_, _)).Times(1); |
2140 | - EXPECT_CALL(*taskController, findDesktopFileForAppId(shortAppId)).Times(1); |
2141 | - |
2142 | - EXPECT_CALL(desktopFileReaderFactory, createInstance(_, _)).Times(1); |
2143 | + EXPECT_CALL(*taskController, getInfoForApp(shortAppId)).Times(1); |
2144 | |
2145 | auto application = applicationManager.startApplication( |
2146 | longAppId, |
2147 | @@ -299,28 +295,6 @@ |
2148 | EXPECT_EQ(second_session, the_app->session()->session()); |
2149 | } |
2150 | |
2151 | -TEST_F(ApplicationManagerTests,DISABLED_upstart_launching_sidestage_app_on_phone_forced_into_mainstage) |
2152 | -{ |
2153 | - using namespace ::testing; |
2154 | - QString appId("sideStage"); |
2155 | - |
2156 | - EXPECT_CALL(*taskController, findDesktopFileForAppId(appId)).Times(1); |
2157 | - |
2158 | - auto mockDesktopFileReader = new NiceMock<MockDesktopFileReader>(appId, QFileInfo()); |
2159 | - ON_CALL(*mockDesktopFileReader, loaded()).WillByDefault(Return(true)); |
2160 | - ON_CALL(*mockDesktopFileReader, stageHint()).WillByDefault(Return("SideStage")); |
2161 | - |
2162 | - ON_CALL(desktopFileReaderFactory, createInstance(appId, _)).WillByDefault(Return(mockDesktopFileReader)); |
2163 | - |
2164 | - // mock upstart launching an app which reports itself as sidestage, but we're on phone |
2165 | - applicationManager.onProcessStarting(appId); |
2166 | - |
2167 | - // ensure the app stage is overridden to be main stage |
2168 | - Application* theApp = applicationManager.findApplication(appId); |
2169 | - ASSERT_NE(theApp, nullptr); |
2170 | - EXPECT_EQ(Application::MainStage, theApp->stage()); |
2171 | -} |
2172 | - |
2173 | TEST_F(ApplicationManagerTests,two_session_on_one_application_after_starting) |
2174 | { |
2175 | using namespace ::testing; |
2176 | @@ -473,12 +447,12 @@ |
2177 | const QString name("Test App"); |
2178 | |
2179 | // Set up Mocks & signal watcher |
2180 | - auto mockDesktopFileReader = new NiceMock<MockDesktopFileReader>(appId, QFileInfo()); |
2181 | - ON_CALL(*mockDesktopFileReader, loaded()).WillByDefault(Return(true)); |
2182 | - ON_CALL(*mockDesktopFileReader, appId()).WillByDefault(Return(appId)); |
2183 | - ON_CALL(*mockDesktopFileReader, name()).WillByDefault(Return(name)); |
2184 | + auto mockApplicationInfo = new NiceMock<MockApplicationInfo>(appId); |
2185 | + ON_CALL(*mockApplicationInfo, name()).WillByDefault(Return(name)); |
2186 | |
2187 | - ON_CALL(desktopFileReaderFactory, createInstance(appId, _)).WillByDefault(Return(mockDesktopFileReader)); |
2188 | + EXPECT_CALL(*taskController, getInfoForApp(appId)) |
2189 | + .Times(1) |
2190 | + .WillOnce(Return(mockApplicationInfo)); |
2191 | |
2192 | EXPECT_CALL(*taskController, start(appId, _)) |
2193 | .Times(1) |
2194 | @@ -518,12 +492,12 @@ |
2195 | const QString name("Test App"); |
2196 | |
2197 | // Set up Mocks & signal watcher |
2198 | - auto mockDesktopFileReader = new NiceMock<MockDesktopFileReader>(appId, QFileInfo()); |
2199 | - ON_CALL(*mockDesktopFileReader, loaded()).WillByDefault(Return(true)); |
2200 | - ON_CALL(*mockDesktopFileReader, appId()).WillByDefault(Return(appId)); |
2201 | - ON_CALL(*mockDesktopFileReader, name()).WillByDefault(Return(name)); |
2202 | + auto mockApplicationInfo = new NiceMock<MockApplicationInfo>(appId); |
2203 | + ON_CALL(*mockApplicationInfo, name()).WillByDefault(Return(name)); |
2204 | |
2205 | - ON_CALL(desktopFileReaderFactory, createInstance(appId, _)).WillByDefault(Return(mockDesktopFileReader)); |
2206 | + EXPECT_CALL(*taskController, getInfoForApp(appId)) |
2207 | + .Times(1) |
2208 | + .WillOnce(Return(mockApplicationInfo)); |
2209 | |
2210 | QSignalSpy countSpy(&applicationManager, SIGNAL(countChanged())); |
2211 | QSignalSpy addedSpy(&applicationManager, SIGNAL(applicationAdded(const QString &))); |
2212 | @@ -567,12 +541,12 @@ |
2213 | .Times(1) |
2214 | .WillOnce(Return(cmdLine)); |
2215 | |
2216 | - auto mockDesktopFileReader = new NiceMock<MockDesktopFileReader>(appId, QFileInfo()); |
2217 | - ON_CALL(*mockDesktopFileReader, loaded()).WillByDefault(Return(true)); |
2218 | - ON_CALL(*mockDesktopFileReader, appId()).WillByDefault(Return(appId)); |
2219 | - ON_CALL(*mockDesktopFileReader, name()).WillByDefault(Return(name)); |
2220 | + auto mockApplicationInfo = new NiceMock<MockApplicationInfo>(appId); |
2221 | + ON_CALL(*mockApplicationInfo, name()).WillByDefault(Return(name)); |
2222 | |
2223 | - ON_CALL(desktopFileReaderFactory, createInstance(appId, _)).WillByDefault(Return(mockDesktopFileReader)); |
2224 | + EXPECT_CALL(*taskController, getInfoForApp(appId)) |
2225 | + .Times(1) |
2226 | + .WillOnce(Return(mockApplicationInfo)); |
2227 | |
2228 | QSignalSpy countSpy(&applicationManager, SIGNAL(countChanged())); |
2229 | QSignalSpy addedSpy(&applicationManager, SIGNAL(applicationAdded(const QString &))); |
2230 | @@ -632,35 +606,6 @@ |
2231 | } |
2232 | |
2233 | /* |
2234 | - * Test that an application launched via the command line with the --desktop_file_hint but an incorrect |
2235 | - * desktop file specified is rejected |
2236 | - */ |
2237 | -TEST_F(ApplicationManagerTests,appDoesNotStartWhenUsingBadDesktopFileHintFile) |
2238 | -{ |
2239 | - using namespace ::testing; |
2240 | - const QString appId("testAppId"); |
2241 | - const QString badDesktopFile = QString("%1.desktop").arg(appId); |
2242 | - const pid_t procId = 5551; |
2243 | - QByteArray cmdLine("/usr/bin/testApp --desktop_file_hint="); |
2244 | - cmdLine = cmdLine.append(badDesktopFile); |
2245 | - |
2246 | - // Set up Mocks & signal watcher |
2247 | - EXPECT_CALL(procInfo,command_line(procId)) |
2248 | - .Times(1) |
2249 | - .WillOnce(Return(cmdLine)); |
2250 | - |
2251 | - auto mockDesktopFileReader = new NiceMock<MockDesktopFileReader>(appId, QFileInfo()); |
2252 | - ON_CALL(*mockDesktopFileReader, loaded()).WillByDefault(Return(false)); |
2253 | - |
2254 | - ON_CALL(desktopFileReaderFactory, createInstance(appId, _)).WillByDefault(Return(mockDesktopFileReader)); |
2255 | - |
2256 | - // Mir requests authentication for an application that was started, should fail |
2257 | - bool authed = true; |
2258 | - applicationManager.authorizeSession(procId, authed); |
2259 | - EXPECT_EQ(authed, false); |
2260 | -} |
2261 | - |
2262 | -/* |
2263 | * Test that if TaskController synchronously calls back processStarted, that ApplicationManager |
2264 | * does not add the app to the model twice. |
2265 | */ |
2266 | @@ -671,12 +616,12 @@ |
2267 | const QString name("Test App"); |
2268 | |
2269 | // Set up Mocks & signal watcher |
2270 | - auto mockDesktopFileReader = new NiceMock<MockDesktopFileReader>(appId, QFileInfo()); |
2271 | - ON_CALL(*mockDesktopFileReader, loaded()).WillByDefault(Return(true)); |
2272 | - ON_CALL(*mockDesktopFileReader, appId()).WillByDefault(Return(appId)); |
2273 | - ON_CALL(*mockDesktopFileReader, name()).WillByDefault(Return(name)); |
2274 | + auto mockApplicationInfo = new NiceMock<MockApplicationInfo>(appId); |
2275 | + ON_CALL(*mockApplicationInfo, name()).WillByDefault(Return(name)); |
2276 | |
2277 | - ON_CALL(desktopFileReaderFactory, createInstance(appId, _)).WillByDefault(Return(mockDesktopFileReader)); |
2278 | + EXPECT_CALL(*taskController, getInfoForApp(appId)) |
2279 | + .Times(1) |
2280 | + .WillOnce(Return(mockApplicationInfo)); |
2281 | |
2282 | ON_CALL(*taskController, start(appId, _)) |
2283 | .WillByDefault(Invoke( |
2284 | @@ -751,12 +696,6 @@ |
2285 | const QString appId("testAppId"); |
2286 | |
2287 | // Set up Mocks & signal watcher |
2288 | - auto mockDesktopFileReader = new NiceMock<MockDesktopFileReader>(appId, QFileInfo()); |
2289 | - ON_CALL(*mockDesktopFileReader, loaded()).WillByDefault(Return(true)); |
2290 | - ON_CALL(*mockDesktopFileReader, appId()).WillByDefault(Return(appId)); |
2291 | - |
2292 | - ON_CALL(desktopFileReaderFactory, createInstance(appId, _)).WillByDefault(Return(mockDesktopFileReader)); |
2293 | - |
2294 | EXPECT_CALL(*taskController, start(appId, _)) |
2295 | .Times(1) |
2296 | .WillOnce(Return(true)); |
2297 | @@ -789,12 +728,6 @@ |
2298 | const pid_t procId = 5551; |
2299 | |
2300 | // Set up Mocks & signal watcher |
2301 | - auto mockDesktopFileReader = new NiceMock<MockDesktopFileReader>(appId, QFileInfo()); |
2302 | - ON_CALL(*mockDesktopFileReader, loaded()).WillByDefault(Return(true)); |
2303 | - ON_CALL(*mockDesktopFileReader, appId()).WillByDefault(Return(appId)); |
2304 | - |
2305 | - ON_CALL(desktopFileReaderFactory, createInstance(appId, _)).WillByDefault(Return(mockDesktopFileReader)); |
2306 | - |
2307 | EXPECT_CALL(*taskController, start(appId, _)) |
2308 | .Times(1) |
2309 | .WillOnce(Return(true)); |
2310 | @@ -833,12 +766,6 @@ |
2311 | const pid_t procId = 5551; |
2312 | |
2313 | // Set up Mocks & signal watcher |
2314 | - auto mockDesktopFileReader = new NiceMock<MockDesktopFileReader>(appId, QFileInfo()); |
2315 | - ON_CALL(*mockDesktopFileReader, loaded()).WillByDefault(Return(true)); |
2316 | - ON_CALL(*mockDesktopFileReader, appId()).WillByDefault(Return(appId)); |
2317 | - |
2318 | - ON_CALL(desktopFileReaderFactory, createInstance(appId, _)).WillByDefault(Return(mockDesktopFileReader)); |
2319 | - |
2320 | EXPECT_CALL(*taskController, start(appId, _)) |
2321 | .Times(1) |
2322 | .WillOnce(Return(true)); |
2323 | @@ -869,17 +796,9 @@ |
2324 | { |
2325 | using namespace ::testing; |
2326 | const QString appId("testAppId"); |
2327 | - const QString desktopFilePath("testAppId.desktop"); |
2328 | const pid_t procId = 5551; |
2329 | |
2330 | // Set up Mocks & signal watcher |
2331 | - auto mockDesktopFileReader = new NiceMock<MockDesktopFileReader>(appId, QFileInfo()); |
2332 | - ON_CALL(*mockDesktopFileReader, loaded()).WillByDefault(Return(true)); |
2333 | - ON_CALL(*mockDesktopFileReader, appId()).WillByDefault(Return(appId)); |
2334 | - ON_CALL(*mockDesktopFileReader, file()).WillByDefault(Return(desktopFilePath)); |
2335 | - |
2336 | - ON_CALL(desktopFileReaderFactory, createInstance(appId, _)).WillByDefault(Return(mockDesktopFileReader)); |
2337 | - |
2338 | EXPECT_CALL(*taskController, start(appId, _)) |
2339 | .Times(1) |
2340 | .WillOnce(Return(true)); |
2341 | @@ -917,12 +836,6 @@ |
2342 | const pid_t procId = 5551; |
2343 | |
2344 | // Set up Mocks & signal watcher |
2345 | - auto mockDesktopFileReader = new NiceMock<MockDesktopFileReader>(appId, QFileInfo()); |
2346 | - ON_CALL(*mockDesktopFileReader, loaded()).WillByDefault(Return(true)); |
2347 | - ON_CALL(*mockDesktopFileReader, appId()).WillByDefault(Return(appId)); |
2348 | - |
2349 | - ON_CALL(desktopFileReaderFactory, createInstance(appId, _)).WillByDefault(Return(mockDesktopFileReader)); |
2350 | - |
2351 | EXPECT_CALL(*taskController, start(appId, _)) |
2352 | .Times(1) |
2353 | .WillOnce(Return(true)); |
2354 | @@ -960,12 +873,6 @@ |
2355 | const pid_t procId = 5551; |
2356 | |
2357 | // Set up Mocks & signal watcher |
2358 | - auto mockDesktopFileReader = new NiceMock<MockDesktopFileReader>(appId, QFileInfo()); |
2359 | - ON_CALL(*mockDesktopFileReader, loaded()).WillByDefault(Return(true)); |
2360 | - ON_CALL(*mockDesktopFileReader, appId()).WillByDefault(Return(appId)); |
2361 | - |
2362 | - ON_CALL(desktopFileReaderFactory, createInstance(appId, _)).WillByDefault(Return(mockDesktopFileReader)); |
2363 | - |
2364 | EXPECT_CALL(*taskController, start(appId, _)) |
2365 | .Times(1) |
2366 | .WillOnce(Return(true)); |
2367 | @@ -1006,12 +913,6 @@ |
2368 | const pid_t procId = 5551; |
2369 | |
2370 | // Set up Mocks & signal watcher |
2371 | - auto mockDesktopFileReader = new NiceMock<MockDesktopFileReader>(appId, QFileInfo()); |
2372 | - ON_CALL(*mockDesktopFileReader, loaded()).WillByDefault(Return(true)); |
2373 | - ON_CALL(*mockDesktopFileReader, appId()).WillByDefault(Return(appId)); |
2374 | - |
2375 | - ON_CALL(desktopFileReaderFactory, createInstance(appId, _)).WillByDefault(Return(mockDesktopFileReader)); |
2376 | - |
2377 | EXPECT_CALL(*taskController, start(appId, _)) |
2378 | .Times(1) |
2379 | .WillOnce(Return(true)); |
2380 | @@ -1051,12 +952,6 @@ |
2381 | const pid_t procId = 5551; |
2382 | |
2383 | // Set up Mocks & signal watcher |
2384 | - auto mockDesktopFileReader = new NiceMock<MockDesktopFileReader>(appId, QFileInfo()); |
2385 | - ON_CALL(*mockDesktopFileReader, loaded()).WillByDefault(Return(true)); |
2386 | - ON_CALL(*mockDesktopFileReader, appId()).WillByDefault(Return(appId)); |
2387 | - |
2388 | - ON_CALL(desktopFileReaderFactory, createInstance(appId, _)).WillByDefault(Return(mockDesktopFileReader)); |
2389 | - |
2390 | EXPECT_CALL(*taskController, start(appId, _)) |
2391 | .Times(1) |
2392 | .WillOnce(Return(true)); |
2393 | @@ -1102,12 +997,6 @@ |
2394 | const pid_t procId = 5551; |
2395 | |
2396 | // Set up Mocks & signal watcher |
2397 | - auto mockDesktopFileReader = new NiceMock<MockDesktopFileReader>(appId, QFileInfo()); |
2398 | - ON_CALL(*mockDesktopFileReader, loaded()).WillByDefault(Return(true)); |
2399 | - ON_CALL(*mockDesktopFileReader, appId()).WillByDefault(Return(appId)); |
2400 | - |
2401 | - ON_CALL(desktopFileReaderFactory, createInstance(appId, _)).WillByDefault(Return(mockDesktopFileReader)); |
2402 | - |
2403 | EXPECT_CALL(*taskController, start(appId, _)) |
2404 | .Times(1) |
2405 | .WillOnce(Return(true)); |
2406 | @@ -1160,12 +1049,6 @@ |
2407 | const pid_t procId = 5551; |
2408 | |
2409 | // Set up Mocks & signal watcher |
2410 | - auto mockDesktopFileReader = new NiceMock<MockDesktopFileReader>(appId, QFileInfo()); |
2411 | - ON_CALL(*mockDesktopFileReader, loaded()).WillByDefault(Return(true)); |
2412 | - ON_CALL(*mockDesktopFileReader, appId()).WillByDefault(Return(appId)); |
2413 | - |
2414 | - ON_CALL(desktopFileReaderFactory, createInstance(appId, _)).WillByDefault(Return(mockDesktopFileReader)); |
2415 | - |
2416 | EXPECT_CALL(*taskController, start(appId, _)) |
2417 | .Times(1) |
2418 | .WillOnce(Return(true)); |
2419 | @@ -1213,12 +1096,6 @@ |
2420 | const pid_t procId = 5551; |
2421 | |
2422 | // Set up Mocks & signal watcher |
2423 | - auto mockDesktopFileReader = new NiceMock<MockDesktopFileReader>(appId, QFileInfo()); |
2424 | - ON_CALL(*mockDesktopFileReader, loaded()).WillByDefault(Return(true)); |
2425 | - ON_CALL(*mockDesktopFileReader, appId()).WillByDefault(Return(appId)); |
2426 | - |
2427 | - ON_CALL(desktopFileReaderFactory, createInstance(appId, _)).WillByDefault(Return(mockDesktopFileReader)); |
2428 | - |
2429 | EXPECT_CALL(*taskController, start(appId, _)) |
2430 | .Times(1) |
2431 | .WillOnce(Return(true)); |
2432 | @@ -1252,12 +1129,6 @@ |
2433 | const pid_t procId = 5551; |
2434 | |
2435 | // Set up Mocks & signal watcher |
2436 | - auto mockDesktopFileReader = new NiceMock<MockDesktopFileReader>(appId, QFileInfo()); |
2437 | - ON_CALL(*mockDesktopFileReader, loaded()).WillByDefault(Return(true)); |
2438 | - ON_CALL(*mockDesktopFileReader, appId()).WillByDefault(Return(appId)); |
2439 | - |
2440 | - ON_CALL(desktopFileReaderFactory, createInstance(appId, _)).WillByDefault(Return(mockDesktopFileReader)); |
2441 | - |
2442 | EXPECT_CALL(*taskController, start(appId, _)) |
2443 | .Times(1) |
2444 | .WillOnce(Return(true)); |
2445 | @@ -1294,7 +1165,6 @@ |
2446 | { |
2447 | using namespace ::testing; |
2448 | const QString appId("testAppId"); |
2449 | - const QString name("Test App"); |
2450 | const pid_t procId = 5551; |
2451 | QByteArray cmdLine("/usr/bin/testApp --desktop_file_hint="); |
2452 | cmdLine = cmdLine.append(appId); |
2453 | @@ -1304,13 +1174,6 @@ |
2454 | .Times(1) |
2455 | .WillOnce(Return(cmdLine)); |
2456 | |
2457 | - auto mockDesktopFileReader = new NiceMock<MockDesktopFileReader>(appId, QFileInfo()); |
2458 | - ON_CALL(*mockDesktopFileReader, loaded()).WillByDefault(Return(true)); |
2459 | - ON_CALL(*mockDesktopFileReader, appId()).WillByDefault(Return(appId)); |
2460 | - ON_CALL(*mockDesktopFileReader, name()).WillByDefault(Return(name)); |
2461 | - |
2462 | - ON_CALL(desktopFileReaderFactory, createInstance(appId, _)).WillByDefault(Return(mockDesktopFileReader)); |
2463 | - |
2464 | // Mir requests authentication for an application that was started |
2465 | bool authed = true; |
2466 | applicationManager.authorizeSession(procId, authed); |
2467 | @@ -1348,12 +1211,6 @@ |
2468 | const pid_t procId = 5551; |
2469 | |
2470 | // Set up Mocks & signal watcher |
2471 | - auto mockDesktopFileReader = new NiceMock<MockDesktopFileReader>(appId, QFileInfo()); |
2472 | - ON_CALL(*mockDesktopFileReader, loaded()).WillByDefault(Return(true)); |
2473 | - ON_CALL(*mockDesktopFileReader, appId()).WillByDefault(Return(appId)); |
2474 | - |
2475 | - ON_CALL(desktopFileReaderFactory, createInstance(appId, _)).WillByDefault(Return(mockDesktopFileReader)); |
2476 | - |
2477 | EXPECT_CALL(*taskController, start(appId, _)) |
2478 | .Times(1) |
2479 | .WillOnce(Return(true)); |
2480 | @@ -1407,13 +1264,6 @@ |
2481 | const pid_t procId = 5551; |
2482 | |
2483 | // Set up Mocks & signal watcher |
2484 | - auto mockDesktopFileReader = new NiceMock<MockDesktopFileReader>(appId, QFileInfo()); |
2485 | - ON_CALL(*mockDesktopFileReader, loaded()).WillByDefault(Return(true)); |
2486 | - ON_CALL(*mockDesktopFileReader, appId()).WillByDefault(Return(appId)); |
2487 | - ON_CALL(*mockDesktopFileReader, file()).WillByDefault(Return(appId + ".desktop")); |
2488 | - |
2489 | - ON_CALL(desktopFileReaderFactory, createInstance(appId, _)).WillByDefault(Return(mockDesktopFileReader)); |
2490 | - |
2491 | EXPECT_CALL(*taskController, start(appId, _)) |
2492 | .Times(1) |
2493 | .WillOnce(Return(true)); |
2494 | @@ -1465,12 +1315,6 @@ |
2495 | ON_CALL(*taskController,appIdHasProcessId(_, procId2)).WillByDefault(Return(false)); |
2496 | |
2497 | // Set up Mocks & signal watcher |
2498 | - auto mockDesktopFileReader = new NiceMock<MockDesktopFileReader>(appId, QFileInfo()); |
2499 | - ON_CALL(*mockDesktopFileReader, loaded()).WillByDefault(Return(true)); |
2500 | - ON_CALL(*mockDesktopFileReader, appId()).WillByDefault(Return(appId)); |
2501 | - |
2502 | - ON_CALL(desktopFileReaderFactory, createInstance(appId, _)).WillByDefault(Return(mockDesktopFileReader)); |
2503 | - |
2504 | EXPECT_CALL(*taskController, start(appId, _)) |
2505 | .Times(1) |
2506 | .WillOnce(Return(true)); |
2507 | @@ -1525,12 +1369,6 @@ |
2508 | ON_CALL(*taskController,appIdHasProcessId(_, procId2)).WillByDefault(Return(false)); |
2509 | |
2510 | // Set up Mocks & signal watcher |
2511 | - auto mockDesktopFileReader = new NiceMock<MockDesktopFileReader>(appId, QFileInfo()); |
2512 | - ON_CALL(*mockDesktopFileReader, loaded()).WillByDefault(Return(true)); |
2513 | - ON_CALL(*mockDesktopFileReader, appId()).WillByDefault(Return(appId)); |
2514 | - |
2515 | - ON_CALL(desktopFileReaderFactory, createInstance(appId, _)).WillByDefault(Return(mockDesktopFileReader)); |
2516 | - |
2517 | EXPECT_CALL(*taskController, start(appId, _)) |
2518 | .Times(1) |
2519 | .WillOnce(Return(true)); |
2520 | @@ -1583,12 +1421,6 @@ |
2521 | const pid_t procId = 5551; |
2522 | |
2523 | // Set up Mocks & signal watcher |
2524 | - auto mockDesktopFileReader = new NiceMock<MockDesktopFileReader>(appId, QFileInfo()); |
2525 | - ON_CALL(*mockDesktopFileReader, loaded()).WillByDefault(Return(true)); |
2526 | - ON_CALL(*mockDesktopFileReader, appId()).WillByDefault(Return(appId)); |
2527 | - |
2528 | - ON_CALL(desktopFileReaderFactory, createInstance(appId, _)).WillByDefault(Return(mockDesktopFileReader)); |
2529 | - |
2530 | EXPECT_CALL(*taskController, start(appId, _)) |
2531 | .Times(1) |
2532 | .WillOnce(Return(true)); |
2533 | @@ -1636,13 +1468,6 @@ |
2534 | std::condition_variable cv; |
2535 | bool done = false; |
2536 | |
2537 | - auto mockDesktopFileReader = new NiceMock<MockDesktopFileReader>(appId, QFileInfo()); |
2538 | - ON_CALL(*mockDesktopFileReader, loaded()).WillByDefault(Return(true)); |
2539 | - ON_CALL(*mockDesktopFileReader, appId()).WillByDefault(Return(appId)); |
2540 | - ON_CALL(*mockDesktopFileReader, file()).WillByDefault(Return(desktopFilePath)); |
2541 | - |
2542 | - ON_CALL(desktopFileReaderFactory, createInstance(appId, _)).WillByDefault(Return(mockDesktopFileReader)); |
2543 | - |
2544 | EXPECT_CALL(*taskController, start(appId, _)) |
2545 | .Times(1) |
2546 | .WillOnce(Return(true)); |
2547 | @@ -1753,12 +1578,6 @@ |
2548 | const quint64 procId = 12345; |
2549 | |
2550 | // Set up Mocks & signal watcher |
2551 | - auto mockDesktopFileReader = new NiceMock<MockDesktopFileReader>(appId, QFileInfo()); |
2552 | - ON_CALL(*mockDesktopFileReader, loaded()).WillByDefault(Return(true)); |
2553 | - ON_CALL(*mockDesktopFileReader, appId()).WillByDefault(Return(appId)); |
2554 | - |
2555 | - ON_CALL(desktopFileReaderFactory, createInstance(appId, _)).WillByDefault(Return(mockDesktopFileReader)); |
2556 | - |
2557 | EXPECT_CALL(*taskController, start(appId, _)) |
2558 | .Times(1) |
2559 | .WillOnce(Return(true)); |
2560 | @@ -1821,12 +1640,6 @@ |
2561 | const quint64 procId = 12345; |
2562 | |
2563 | // Set up Mocks & signal watcher |
2564 | - auto mockDesktopFileReader = new NiceMock<MockDesktopFileReader>(appId, QFileInfo()); |
2565 | - ON_CALL(*mockDesktopFileReader, loaded()).WillByDefault(Return(true)); |
2566 | - ON_CALL(*mockDesktopFileReader, appId()).WillByDefault(Return(appId)); |
2567 | - |
2568 | - ON_CALL(desktopFileReaderFactory, createInstance(appId, _)).WillByDefault(Return(mockDesktopFileReader)); |
2569 | - |
2570 | EXPECT_CALL(*taskController, start(appId, _)) |
2571 | .Times(1) |
2572 | .WillOnce(Return(true)); |
2573 | @@ -1863,13 +1676,6 @@ |
2574 | const pid_t procId = 5551; |
2575 | |
2576 | // Set up Mocks & signal watcher |
2577 | - auto mockDesktopFileReader = new NiceMock<MockDesktopFileReader>(appId, QFileInfo()); |
2578 | - ON_CALL(*mockDesktopFileReader, loaded()).WillByDefault(Return(true)); |
2579 | - ON_CALL(*mockDesktopFileReader, appId()).WillByDefault(Return(appId)); |
2580 | - ON_CALL(*mockDesktopFileReader, file()).WillByDefault(Return(appId + ".desktop")); |
2581 | - |
2582 | - ON_CALL(desktopFileReaderFactory, createInstance(appId, _)).WillByDefault(Return(mockDesktopFileReader)); |
2583 | - |
2584 | EXPECT_CALL(*taskController, start(appId, _)) |
2585 | .Times(1) |
2586 | .WillOnce(Return(true)); |
2587 | @@ -1908,12 +1714,6 @@ |
2588 | const pid_t procId = 5551; |
2589 | |
2590 | // Set up Mocks & signal watcher |
2591 | - auto mockDesktopFileReader = new NiceMock<MockDesktopFileReader>(appId, QFileInfo()); |
2592 | - ON_CALL(*mockDesktopFileReader, loaded()).WillByDefault(Return(true)); |
2593 | - ON_CALL(*mockDesktopFileReader, appId()).WillByDefault(Return(appId)); |
2594 | - |
2595 | - ON_CALL(desktopFileReaderFactory, createInstance(appId, _)).WillByDefault(Return(mockDesktopFileReader)); |
2596 | - |
2597 | EXPECT_CALL(*taskController, start(appId, _)) |
2598 | .Times(1) |
2599 | .WillOnce(Return(true)); |
2600 | @@ -1957,12 +1757,6 @@ |
2601 | const pid_t procId = 5551; |
2602 | |
2603 | // Set up Mocks & signal watcher |
2604 | - auto mockDesktopFileReader = new NiceMock<MockDesktopFileReader>(appId, QFileInfo()); |
2605 | - ON_CALL(*mockDesktopFileReader, loaded()).WillByDefault(Return(true)); |
2606 | - ON_CALL(*mockDesktopFileReader, appId()).WillByDefault(Return(appId)); |
2607 | - |
2608 | - ON_CALL(desktopFileReaderFactory, createInstance(appId, _)).WillByDefault(Return(mockDesktopFileReader)); |
2609 | - |
2610 | EXPECT_CALL(*taskController, start(appId, _)) |
2611 | .Times(1) |
2612 | .WillOnce(Return(true)); |
2613 | @@ -2032,13 +1826,6 @@ |
2614 | const QString appId("testAppId"); |
2615 | quint64 procId = 5551; |
2616 | |
2617 | - auto mockDesktopFileReader = new NiceMock<MockDesktopFileReader>(appId, QFileInfo()); |
2618 | - ON_CALL(*mockDesktopFileReader, loaded()).WillByDefault(Return(true)); |
2619 | - ON_CALL(*mockDesktopFileReader, appId()).WillByDefault(Return(appId)); |
2620 | - ON_CALL(*mockDesktopFileReader, file()).WillByDefault(Return(appId + ".desktop")); |
2621 | - |
2622 | - ON_CALL(desktopFileReaderFactory, createInstance(appId, _)).WillByDefault(Return(mockDesktopFileReader)); |
2623 | - |
2624 | EXPECT_CALL(*taskController, start(appId, _)) |
2625 | .Times(1) |
2626 | .WillOnce(Return(true)); |
2627 | @@ -2085,11 +1872,6 @@ |
2628 | const QString appId("testAppId"); |
2629 | quint64 procId = 5551; |
2630 | |
2631 | - ON_CALL(desktopFileReaderFactory, createInstance(appId, _)) |
2632 | - .WillByDefault(Invoke( |
2633 | - [](const QString &appId, const QFileInfo&) { return new FakeDesktopFileReader(appId); } |
2634 | - )); |
2635 | - |
2636 | EXPECT_CALL(*taskController, start(appId, _)) |
2637 | .Times(1) |
2638 | .WillOnce(Return(true)); |
2639 | @@ -2186,11 +1968,6 @@ |
2640 | ON_CALL(procInfo,command_line(procId)).WillByDefault(Return(QByteArray("/usr/bin/testAppId"))); |
2641 | ON_CALL(*taskController,appIdHasProcessId(appId, procId)).WillByDefault(Return(true)); |
2642 | |
2643 | - ON_CALL(desktopFileReaderFactory, createInstance(appId, _)) |
2644 | - .WillByDefault(Invoke( |
2645 | - [](const QString &appId, const QFileInfo&) { return new FakeDesktopFileReader(appId); } |
2646 | - )); |
2647 | - |
2648 | auto app = applicationManager.startApplication(appId, ApplicationManager::NoFlag); |
2649 | applicationManager.onProcessStarting(appId); |
2650 | std::shared_ptr<mir::scene::Session> session = std::make_shared<MockSession>("", procId); |
2651 | |
2652 | === modified file 'tests/modules/CMakeLists.txt' |
2653 | --- tests/modules/CMakeLists.txt 2016-02-11 11:52:06 +0000 |
2654 | +++ tests/modules/CMakeLists.txt 2016-03-02 00:44:09 +0000 |
2655 | @@ -1,6 +1,5 @@ |
2656 | add_subdirectory(Application) |
2657 | add_subdirectory(ApplicationManager) |
2658 | -add_subdirectory(DesktopFileReader) |
2659 | add_subdirectory(General) |
2660 | add_subdirectory(SharedWakelock) |
2661 | add_subdirectory(SessionManager) |
2662 | |
2663 | === removed directory 'tests/modules/DesktopFileReader' |
2664 | === removed file 'tests/modules/DesktopFileReader/CMakeLists.txt' |
2665 | --- tests/modules/DesktopFileReader/CMakeLists.txt 2015-09-30 15:45:17 +0000 |
2666 | +++ tests/modules/DesktopFileReader/CMakeLists.txt 1970-01-01 00:00:00 +0000 |
2667 | @@ -1,22 +0,0 @@ |
2668 | -add_definitions(-DTEST_SOURCE_DIR="${CMAKE_CURRENT_SOURCE_DIR}") |
2669 | - |
2670 | -set( |
2671 | - DESKTOP_FILE_READER_TEST_SOURCES |
2672 | - desktopfilereader_test.cpp |
2673 | -) |
2674 | - |
2675 | -include_directories( |
2676 | - ${CMAKE_SOURCE_DIR}/src/modules |
2677 | -) |
2678 | - |
2679 | -add_executable(desktop_file_reader_test ${DESKTOP_FILE_READER_TEST_SOURCES}) |
2680 | - |
2681 | -target_link_libraries( |
2682 | - desktop_file_reader_test |
2683 | - |
2684 | - unityapplicationplugin |
2685 | - |
2686 | - ${GTEST_BOTH_LIBRARIES} |
2687 | -) |
2688 | - |
2689 | -add_test(DesktopFileReader desktop_file_reader_test) |
2690 | |
2691 | === removed file 'tests/modules/DesktopFileReader/calculator.desktop' |
2692 | --- tests/modules/DesktopFileReader/calculator.desktop 2014-10-06 22:37:55 +0000 |
2693 | +++ tests/modules/DesktopFileReader/calculator.desktop 1970-01-01 00:00:00 +0000 |
2694 | @@ -1,227 +0,0 @@ |
2695 | -[Desktop Entry] |
2696 | -Name=Calculator |
2697 | -Name[am]=መደመሪያ |
2698 | -Name[ar]=الآلة الحاسبة |
2699 | -Name[ast]=Calculadora |
2700 | -Name[az]=Kalkulyator |
2701 | -Name[be]=Калькулятар |
2702 | -Name[bg]=Калкулатор |
2703 | -Name[br]=Jederez |
2704 | -Name[bs]=Kalkulator |
2705 | -Name[ca]=Calculadora |
2706 | -Name[cs]=Kalkulačka |
2707 | -Name[cy]=Cyfrifiannell |
2708 | -Name[da]=Lommeregner |
2709 | -Name[de]=Taschenrechner |
2710 | -Name[el]=Αριθμομηχανή |
2711 | -Name[en_AU]=Calculator |
2712 | -Name[en_CA]=Calculator |
2713 | -Name[en_GB]=Calculator |
2714 | -Name[es]=Calculadora |
2715 | -Name[eu]=Kalkulagailua |
2716 | -Name[fa]=ماشینحساب |
2717 | -Name[fi]=Laskin |
2718 | -Name[fr]=Calculatrice |
2719 | -Name[gd]=An t-àireamhair |
2720 | -Name[gl]=Calculadora |
2721 | -Name[gu]=કેલ્ક્યુલેટર |
2722 | -Name[he]=מחשבון |
2723 | -Name[hi]=कैलकुलेटर |
2724 | -Name[hu]=Számológép |
2725 | -Name[id]=Kalkulator |
2726 | -Name[is]=Reiknivél |
2727 | -Name[it]=Calcolatrice |
2728 | -Name[ja]=電卓 |
2729 | -Name[km]=ម៉ាស៊ីនគិតលេខ |
2730 | -Name[ko]=계산기 |
2731 | -Name[lv]=Kalkulators |
2732 | -Name[mr]=गणनयंत्र |
2733 | -Name[ms]=Kalkulator |
2734 | -Name[my]=ဂဏန်းတွက်စက် |
2735 | -Name[nb]=Kalkulator |
2736 | -Name[ne]=क्याल्कुलेटर |
2737 | -Name[nl]=Rekenmachine |
2738 | -Name[pa]=ਕੈਲਕੂਲੇਟਰ |
2739 | -Name[pl]=Kalkulator |
2740 | -Name[pt]=Calculadora |
2741 | -Name[pt_BR]=Calculadora |
2742 | -Name[ro]=Calculator |
2743 | -Name[ru]=Калькулятор |
2744 | -Name[sa]=सङ्कलकम् |
2745 | -Name[shn]=ၸၢၵ်ႈၼပ့်သွၼ် |
2746 | -Name[sl]=Računalo |
2747 | -Name[sr]=Калкулатор |
2748 | -Name[sv]=Kalkylator |
2749 | -Name[ta]=கணிப்பான் |
2750 | -Name[te]=గణన పరికరం |
2751 | -Name[tr]=Hesap Makinesi |
2752 | -Name[ug]=ھېسابلىغۇچ |
2753 | -Name[uk]=Калькулятор |
2754 | -Name[zh_CN]=计算器 |
2755 | -Name[zh_HK]=計數機 |
2756 | -Name[zh_TW]=計算機 |
2757 | -Comment=A simple calculator for Ubuntu. |
2758 | -Comment[am]=ለ ኡቡንቱ ቀላል መደመሪያ |
2759 | -Comment[ar]=آلة حاسبة بسيطة لأوبونتو. |
2760 | -Comment[ast]=Una calculadora cenciella pa Ubuntu. |
2761 | -Comment[az]=Ubuntu üçün sadә kalkulyator. |
2762 | -Comment[br]=Ur jederez eeun evit Ubuntu. |
2763 | -Comment[ca]=Una calculadora simple per a l'Ubuntu. |
2764 | -Comment[cy]=Cyfrifiannell hawdd ar gyfer Ubuntu. |
2765 | -Comment[da]=En simpel lommeregner til Ubuntu. |
2766 | -Comment[de]=Ein einfach Tachenrechner für Ubuntu. |
2767 | -Comment[el]=Μια απλή αριθμομηχανή για το Ubuntu |
2768 | -Comment[en_AU]=A simple calculator for Ubuntu. |
2769 | -Comment[en_GB]=A simple calculator for Ubuntu. |
2770 | -Comment[es]=Una calculadora sencilla para Ubuntu. |
2771 | -Comment[eu]=Ubunturako kalkulagailu sinplea. |
2772 | -Comment[fa]=یک ماشین حساب ساده برای اوبونتو. |
2773 | -Comment[fi]=Laskin Ubuntulle. |
2774 | -Comment[fr]=Une calculatrice simple pour Ubuntu. |
2775 | -Comment[gd]=Àireamhair simplidh airson Ubuntu. |
2776 | -Comment[gl]=Calculadora sinxela para Ubuntu. |
2777 | -Comment[he]=מחשבון פשוט לאובונטו. |
2778 | -Comment[hu]=Egyszerű számológép Ubuntuhoz. |
2779 | -Comment[is]=Einföld reiknivél |
2780 | -Comment[it]=Una semplice calcolatrice per Ubuntu. |
2781 | -Comment[ja]=Ubuntu用のシンプルな電卓です。 |
2782 | -Comment[km]=ម៉ាស៊ីនគិតលេខធម្មតាសម្រាប់ Ubuntu ។ |
2783 | -Comment[ko]=우분투를 위한 간단한 계산기 |
2784 | -Comment[lv]=Vienkāršs kalkulators priekš Ubuntu |
2785 | -Comment[nb]=En enkel kalkulator for Ubuntu. |
2786 | -Comment[ne]=Ubuntu को लागि एक सरल कैलकुलेटर। |
2787 | -Comment[nl]=Een eenvoudige rekenmachine voor Ubuntu. |
2788 | -Comment[pa]=ਉਬੰਤੂ ਲਈ ਇੱਕ ਸਧਾਰਨ ਕੈਲਕੂਲੇਟਰ |
2789 | -Comment[pl]=Prosty kalkulator dla Ubuntu |
2790 | -Comment[pt]=Uma calculadora simples para o Ubuntu. |
2791 | -Comment[pt_BR]=Uma simples calculadora para Ubuntu |
2792 | -Comment[ro]=Un calculator simplu pentru Ubuntu. |
2793 | -Comment[ru]=Простой калькулятор для Ubuntu |
2794 | -Comment[sa]=Ubuntu इत्यस्मा एकं सरलं सङ्कलकम्। |
2795 | -Comment[sl]=Preprost kalkulator za Ubuntu. |
2796 | -Comment[sr]=Једноставан калкулатор за Убунту |
2797 | -Comment[sv]=En enkel kalkylator för Ubuntu. |
2798 | -Comment[tr]=Ubuntu için sade bir hesap makinesi. |
2799 | -Comment[ug]=ئاددىي ھېسابلىغۇچى |
2800 | -Comment[uk]=Простий калькулятор для Ubuntu. |
2801 | -Comment[zh_CN]=Ubuntu 简易计算器 |
2802 | -Comment[zh_TW]=Ubuntu 簡易計算機。 |
2803 | -Keywords=math;addition;subtraction;multiplication;division; |
2804 | -Keywords[am]=ሂሳብ;መደመሪያ;መቀነሻ;ማባዣ;ማካፈያ; |
2805 | -Keywords[ar]=رياضة;ياضيات;حساب;حسابات;جمع;طرح;ضرب;قسمة; |
2806 | -Keywords[ast]=matemática;suma;resta;multiplicación;división; |
2807 | -Keywords[az]=riyaziyyat;әlavә etmә;çıxma;vurma;bölmә;toplama; |
2808 | -Keywords[br]=matematikoù;sammadenn;lamadenn;lieskementadenn;rannadenn; |
2809 | -Keywords[ca]=suma;resta;calculadora;multiplica;divideix |
2810 | -Keywords[da]=matematik;plus;minus;gange;dividere;beregning;lommeregner; |
2811 | -Keywords[de]=Mathe;Mathematik;Multiplikation;Subtraktion;Addition;Division; |
2812 | -Keywords[en_AU]=math;addition;subtraction;multiplication;division; |
2813 | -Keywords[en_GB]=maths;addition;subtraction;multiplication;division; |
2814 | -Keywords[es]=matemática;suma;resta;multiplicación;división; |
2815 | -Keywords[eu]=matematikak;gehitu;kendu;biderkatu;zatitu; |
2816 | -Keywords[fa]=حساب;جمع;تفریق;ضرب;تقسیم |
2817 | -Keywords[fi]=math;addition;subtraction;multiplication;division;matematiikka;lisäys;vähennys;kertaus;jakaminen; |
2818 | -Keywords[fr]=math;addition;soustraction;multiplication;division; |
2819 | -Keywords[gd]=math;addition;subtraction;multiplication;division;matamataig;roinneadh;toirt air falbh;cur ris;iomadadh |
2820 | -Keywords[gl]=matemáticas;suma;resta;multiplicación;división; |
2821 | -Keywords[he]=מתמטיקה;חשבון;חיבור;חיסור;כפל;חילוק; |
2822 | -Keywords[hu]=számolás;összeadás;kivonás;szorzás;osztás; |
2823 | -Keywords[is]=reikna;samlagning;frádráttur;margföldun;deiling |
2824 | -Keywords[it]=matematica;addizioni;sottrazioni;moltiplicazioni;divisioni; |
2825 | -Keywords[ja]=math;addition;subtraction;multiplication;division;計算;電卓;足し算;引き算;かけ算;わり算; |
2826 | -Keywords[km]=math;addition;subtraction;multiplication;division; |
2827 | -Keywords[ko]=수학;덧셈;뺄셈;곱셈;나눗셈; |
2828 | -Keywords[nb]=matte;addisjon;subtraksjon;multiplikasjon;divisjon; |
2829 | -Keywords[ne]=गणित; जोड्; घटाउ; गुणन; विभाजन; |
2830 | -Keywords[nl]=math;addition;subtraction;multiplication;division;optellen;aftrekken;vermenigvuldigen;delen; |
2831 | -Keywords[pa]=ਹਿਸਾਬ;ਜੋੜ;ਘਟਾਉ;ਗੁਣਾ;ਭਾਗ; |
2832 | -Keywords[pl]=liczenie;dodawanie;odejmowanie;mnożenie;dzielenie; |
2833 | -Keywords[pt]=matemática;soma;subtracção;multiplicação;divisão; |
2834 | -Keywords[pt_BR]=matemática;adição;subtração;multiplicação;divisão |
2835 | -Keywords[ro]=matematică;adunare;scădere;înmulțire;împărțire |
2836 | -Keywords[ru]=математика;сложение;умножение;деление; |
2837 | -Keywords[sa]=गणितम्;योजनम्;वियोजनम्;गुणनम्;विभाजनम्; |
2838 | -Keywords[sl]=matematika;seštevanje;odštevanje;množenje;deljenje; |
2839 | -Keywords[sr]=математика;сабирање;одузимање;множење;дељење;рачунање;дигитрон; |
2840 | -Keywords[sv]=matematik;addition;substraktion;multiplikation;division |
2841 | -Keywords[tr]=matematik;ekleme;çıkarma;çarpma;bölme;toplama |
2842 | -Keywords[ug]=ماتېماتىكا;قوشۇش;ئېلىش;كۆپەيتىش;بۆلۈش; |
2843 | -Keywords[uk]=math;addition;subtraction;multiplication;division;математика;додавання;віднімання;множення;ділення;калькулятор; |
2844 | -Keywords[zh_CN]=数学;加;减;乘;除; |
2845 | -Keywords[zh_TW]=math;addition;subtraction;multiplication;division;數學;加;減;乘;除; |
2846 | -Type=Application |
2847 | -Terminal=false |
2848 | -Exec=yes -p com.ubuntu.calculator_calculator_1.3.329 -- qmlscene -qt5 ubuntu-calculator-app.qml |
2849 | -Icon=/usr/share/click/preinstalled/.click/users/@all/com.ubuntu.calculator/calculator-app@30.png |
2850 | -X-Ubuntu-Touch=true |
2851 | -X-Ubuntu-StageHint=SideStage |
2852 | -X-Ubuntu-Default-Department-ID=accessories |
2853 | -Path=/usr/share/click/preinstalled/.click/users/@all/com.ubuntu.calculator |
2854 | -X-Ubuntu-Old-Icon=calculator-app@30.png |
2855 | -X-Ubuntu-Application-ID=com.ubuntu.calculator_calculator_1.3.329 |
2856 | -X-Ubuntu-Splash-Show-Header=True |
2857 | -X-Ubuntu-Splash-Color=#aabbcc |
2858 | -X-Ubuntu-Splash-Color-Header=purple |
2859 | -X-Ubuntu-Splash-Color-Footer=#deadbeefda |
2860 | -X-Ubuntu-Splash-Image=/usr/share/click/preinstalled/.click/users/@all/com.ubuntu.calculator/calculator-app@30.png |
2861 | -X-Ubuntu-Splash-Title=Calculator 2.0 |
2862 | -X-Ubuntu-Splash-Title[am]=መደመሪያ 2.0 |
2863 | -X-Ubuntu-Splash-Title[ar]=الآلة 2.0الحاسبة |
2864 | -X-Ubuntu-Splash-Title[ast]=Calculadora 2.0 |
2865 | -X-Ubuntu-Splash-Title[az]=Kalkulyator 2.0 |
2866 | -X-Ubuntu-Splash-Title[be]=Калькулятар 2.0 |
2867 | -X-Ubuntu-Splash-Title[bg]=Калкулатор 2.0 |
2868 | -X-Ubuntu-Splash-Title[br]=Jederez 2.0 |
2869 | -X-Ubuntu-Splash-Title[bs]=Kalkulator 2.0 |
2870 | -X-Ubuntu-Splash-Title[ca]=Calculadora 2.0 |
2871 | -X-Ubuntu-Splash-Title[cs]=Kalkulačka 2.0 |
2872 | -X-Ubuntu-Splash-Title[cy]=Cyfrifiannell 2.0 |
2873 | -X-Ubuntu-Splash-Title[da]=Lommeregner 2.0 |
2874 | -X-Ubuntu-Splash-Title[de]=Taschenrechner 2.0 |
2875 | -X-Ubuntu-Splash-Title[el]=Αριθμομηχανή 2.0 |
2876 | -X-Ubuntu-Splash-Title[en_AU]=Calculator 2.0 |
2877 | -X-Ubuntu-Splash-Title[en_CA]=Calculator 2.0 |
2878 | -X-Ubuntu-Splash-Title[en_GB]=Calculator 2.0 |
2879 | -X-Ubuntu-Splash-Title[es]=Calculadora 2.0 |
2880 | -X-Ubuntu-Splash-Title[eu]=Kalkulagailua 2.0 |
2881 | -X-Ubuntu-Splash-Title[fa]= 2.0ماشینحساب |
2882 | -X-Ubuntu-Splash-Title[fi]=Laskin 2.0 |
2883 | -X-Ubuntu-Splash-Title[fr]=Calculatrice 2.0 |
2884 | -X-Ubuntu-Splash-Title[gd]=An t-àireamhair 2.0 |
2885 | -X-Ubuntu-Splash-Title[gl]=Calculadora 2.0 |
2886 | -X-Ubuntu-Splash-Title[gu]=કેલ્ક્યુલેટર 2.0 |
2887 | -X-Ubuntu-Splash-Title[he]= 2.0מחשבון |
2888 | -X-Ubuntu-Splash-Title[hi]=कैलकुलेटर 2.0 |
2889 | -X-Ubuntu-Splash-Title[hu]=Számológép 2.0 |
2890 | -X-Ubuntu-Splash-Title[id]=Kalkulator 2.0 |
2891 | -X-Ubuntu-Splash-Title[is]=Reiknivél 2.0 |
2892 | -X-Ubuntu-Splash-Title[it]=Calcolatrice 2.0 |
2893 | -X-Ubuntu-Splash-Title[ja]=電卓 2.0 |
2894 | -X-Ubuntu-Splash-Title[km]=ម៉ាស៊ីនគិតលេខ 2.0 |
2895 | -X-Ubuntu-Splash-Title[ko]=계산기 2.0 |
2896 | -X-Ubuntu-Splash-Title[lv]=Kalkulators 2.0 |
2897 | -X-Ubuntu-Splash-Title[mr]=गणनयंत्र 2.0 |
2898 | -X-Ubuntu-Splash-Title[ms]=Kalkulator 2.0 |
2899 | -X-Ubuntu-Splash-Title[my]=ဂဏန်းတွက်စက် 2.0 |
2900 | -X-Ubuntu-Splash-Title[nb]=Kalkulator 2.0 |
2901 | -X-Ubuntu-Splash-Title[ne]=क्याल्कुलेटर 2.0 |
2902 | -X-Ubuntu-Splash-Title[nl]=Rekenmachine 2.0 |
2903 | -X-Ubuntu-Splash-Title[pa]=ਕੈਲਕੂਲੇਟਰ 2.0 |
2904 | -X-Ubuntu-Splash-Title[pl]=Kalkulator 2.0 |
2905 | -X-Ubuntu-Splash-Title[pt]=Calculadora 2.0 |
2906 | -X-Ubuntu-Splash-Title[pt_BR]=Calculadora 2.0 |
2907 | -X-Ubuntu-Splash-Title[ro]=Calculator 2.0 |
2908 | -X-Ubuntu-Splash-Title[ru]=Калькулятор 2.0 |
2909 | -X-Ubuntu-Splash-Title[sa]=सङ्कलकम् 2.0 |
2910 | -X-Ubuntu-Splash-Title[shn]=ၸၢၵ်ႈၼပ့်သွၼ် 2.0 |
2911 | -X-Ubuntu-Splash-Title[sl]=Računalo 2.0 |
2912 | -X-Ubuntu-Splash-Title[sr]=Калкулатор 2.0 |
2913 | -X-Ubuntu-Splash-Title[sv]=Kalkylator 2.0 |
2914 | -X-Ubuntu-Splash-Title[ta]=கணிப்பான் 2.0 |
2915 | -X-Ubuntu-Splash-Title[te]=గణన పరికరం 2.0 |
2916 | -X-Ubuntu-Splash-Title[tr]=Hesap Makinesi 2.0 |
2917 | -X-Ubuntu-Splash-Title[ug]= 2.0ھېسابلىغۇچ |
2918 | -X-Ubuntu-Splash-Title[uk]=Калькулятор 2.0 |
2919 | -X-Ubuntu-Splash-Title[zh_CN]=计算器 2.0 |
2920 | -X-Ubuntu-Splash-Title[zh_HK]=計數機 2.0 |
2921 | -X-Ubuntu-Splash-Title[zh_TW]=計算機 2.0 |
2922 | |
2923 | === removed file 'tests/modules/DesktopFileReader/desktopfilereader_test.cpp' |
2924 | --- tests/modules/DesktopFileReader/desktopfilereader_test.cpp 2015-09-28 20:11:39 +0000 |
2925 | +++ tests/modules/DesktopFileReader/desktopfilereader_test.cpp 1970-01-01 00:00:00 +0000 |
2926 | @@ -1,200 +0,0 @@ |
2927 | -/* |
2928 | - * Copyright (C) 2014-2015 Canonical, Ltd. |
2929 | - * |
2930 | - * This program is free software: you can redistribute it and/or modify it under |
2931 | - * the terms of the GNU Lesser General Public License version 3, as published by |
2932 | - * the Free Software Foundation. |
2933 | - * |
2934 | - * This program is distributed in the hope that it will be useful, but WITHOUT |
2935 | - * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY, |
2936 | - * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
2937 | - * Lesser General Public License for more details. |
2938 | - * |
2939 | - * You should have received a copy of the GNU Lesser General Public License |
2940 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. |
2941 | - */ |
2942 | - |
2943 | -#include <Unity/Application/desktopfilereader.h> |
2944 | - |
2945 | -#include <gtest/gtest.h> |
2946 | - |
2947 | -#include <QDir> |
2948 | -#include <QFileInfo> |
2949 | -#include <QLocale> |
2950 | -#include <QtGlobal> |
2951 | -#include <QString> |
2952 | - |
2953 | -using namespace qtmir; |
2954 | - |
2955 | -namespace { |
2956 | - static void setLocale(const char *locale) |
2957 | - { |
2958 | - qputenv("LANGUAGE", locale); |
2959 | - qputenv("LC_ALL", locale); // set these for GIO |
2960 | - QLocale::setDefault(QString(locale)); // set for Qt |
2961 | - } |
2962 | -} |
2963 | - |
2964 | -TEST(DesktopFileReader, testReadsDesktopFile) |
2965 | -{ |
2966 | - using namespace ::testing; |
2967 | - setLocale("C"); |
2968 | - |
2969 | - QFileInfo fileInfo(QString(TEST_SOURCE_DIR) + "/calculator.desktop"); |
2970 | - DesktopFileReader::Factory readerFactory; |
2971 | - DesktopFileReader *reader = readerFactory.createInstance("calculator", fileInfo); |
2972 | - |
2973 | - EXPECT_EQ(reader->loaded(), true); |
2974 | - EXPECT_EQ(reader->appId(), "calculator"); |
2975 | - EXPECT_EQ(reader->name(), "Calculator"); |
2976 | - EXPECT_EQ(reader->exec(), "yes -p com.ubuntu.calculator_calculator_1.3.329 -- qmlscene -qt5 ubuntu-calculator-app.qml"); |
2977 | - EXPECT_EQ(reader->icon(), "/usr/share/click/preinstalled/.click/users/@all/com.ubuntu.calculator/calculator-app@30.png"); |
2978 | - EXPECT_EQ(reader->path(), "/usr/share/click/preinstalled/.click/users/@all/com.ubuntu.calculator"); |
2979 | - EXPECT_EQ(reader->comment(), "A simple calculator for Ubuntu."); |
2980 | - EXPECT_EQ(reader->stageHint(), "SideStage"); |
2981 | - EXPECT_EQ(reader->splashColor(), "#aabbcc"); |
2982 | - EXPECT_EQ(reader->splashColorFooter(), "#deadbeefda"); |
2983 | - EXPECT_EQ(reader->splashColorHeader(), "purple"); |
2984 | - EXPECT_EQ(reader->splashImage(), "/usr/share/click/preinstalled/.click/users/@all/com.ubuntu.calculator/calculator-app@30.png"); |
2985 | - EXPECT_EQ(reader->splashShowHeader(), "True"); |
2986 | - EXPECT_EQ(reader->splashTitle(), "Calculator 2.0"); |
2987 | - EXPECT_EQ(reader->isTouchApp(), true); |
2988 | -} |
2989 | - |
2990 | -TEST(DesktopFileReader, testReadsLocalizedDesktopFile) |
2991 | -{ |
2992 | - using namespace ::testing; |
2993 | - setLocale("de"); |
2994 | - |
2995 | - QFileInfo fileInfo(QString(TEST_SOURCE_DIR) + "/calculator.desktop"); |
2996 | - DesktopFileReader::Factory readerFactory; |
2997 | - DesktopFileReader *reader = readerFactory.createInstance("calculator", fileInfo); |
2998 | - |
2999 | - EXPECT_EQ(reader->loaded(), true); |
3000 | - EXPECT_EQ(reader->appId(), "calculator"); |
3001 | - EXPECT_EQ(reader->name(), "Taschenrechner"); |
3002 | - EXPECT_EQ(reader->exec(), "yes -p com.ubuntu.calculator_calculator_1.3.329 -- qmlscene -qt5 ubuntu-calculator-app.qml"); |
3003 | - EXPECT_EQ(reader->icon(), "/usr/share/click/preinstalled/.click/users/@all/com.ubuntu.calculator/calculator-app@30.png"); |
3004 | - EXPECT_EQ(reader->path(), "/usr/share/click/preinstalled/.click/users/@all/com.ubuntu.calculator"); |
3005 | - EXPECT_EQ(reader->comment(), "Ein einfach Tachenrechner für Ubuntu."); |
3006 | - EXPECT_EQ(reader->stageHint(), "SideStage"); |
3007 | - EXPECT_EQ(reader->splashColor(), "#aabbcc"); |
3008 | - EXPECT_EQ(reader->splashColorFooter(), "#deadbeefda"); |
3009 | - EXPECT_EQ(reader->splashColorHeader(), "purple"); |
3010 | - EXPECT_EQ(reader->splashImage(), "/usr/share/click/preinstalled/.click/users/@all/com.ubuntu.calculator/calculator-app@30.png"); |
3011 | - EXPECT_EQ(reader->splashShowHeader(), "True"); |
3012 | - EXPECT_EQ(reader->splashTitle(), "Taschenrechner 2.0"); |
3013 | - EXPECT_EQ(reader->isTouchApp(), true); |
3014 | -} |
3015 | - |
3016 | -TEST(DesktopFileReader, testMissingDesktopFile) |
3017 | -{ |
3018 | - using namespace ::testing; |
3019 | - setLocale("C"); |
3020 | - |
3021 | - QFileInfo fileInfo(QString(TEST_SOURCE_DIR) + "/missing.desktop"); |
3022 | - DesktopFileReader::Factory readerFactory; |
3023 | - DesktopFileReader *reader = readerFactory.createInstance("calculator", fileInfo); |
3024 | - |
3025 | - EXPECT_EQ(reader->loaded(), false); |
3026 | - EXPECT_EQ(reader->appId(), "calculator"); |
3027 | - EXPECT_EQ(reader->name(), ""); |
3028 | - EXPECT_EQ(reader->exec(), ""); |
3029 | - EXPECT_EQ(reader->icon(), ""); |
3030 | - EXPECT_EQ(reader->path(), ""); |
3031 | - EXPECT_EQ(reader->comment(), ""); |
3032 | - EXPECT_EQ(reader->stageHint(), ""); |
3033 | - EXPECT_EQ(reader->splashColor(), ""); |
3034 | - EXPECT_EQ(reader->splashColorFooter(), ""); |
3035 | - EXPECT_EQ(reader->splashColorHeader(), ""); |
3036 | - EXPECT_EQ(reader->splashImage(), ""); |
3037 | - EXPECT_EQ(reader->splashShowHeader(), ""); |
3038 | - EXPECT_EQ(reader->splashTitle(), ""); |
3039 | - EXPECT_EQ(reader->isTouchApp(), false); |
3040 | -} |
3041 | - |
3042 | -TEST(DesktopFileReader, testUTF8Characters) |
3043 | -{ |
3044 | - using namespace ::testing; |
3045 | - setLocale("zh_CN"); |
3046 | - |
3047 | - QFileInfo fileInfo(QString(TEST_SOURCE_DIR) + "/calculator.desktop"); |
3048 | - DesktopFileReader::Factory readerFactory; |
3049 | - DesktopFileReader *reader = readerFactory.createInstance("calculator", fileInfo); |
3050 | - |
3051 | - EXPECT_EQ(reader->loaded(), true); |
3052 | - EXPECT_EQ(reader->appId(), "calculator"); |
3053 | - EXPECT_EQ(reader->name(), "计算器"); |
3054 | - EXPECT_EQ(reader->comment(), "Ubuntu 简易计算器"); |
3055 | - EXPECT_EQ(reader->splashTitle(), "计算器 2.0"); |
3056 | -} |
3057 | - |
3058 | -TEST(DesktopFileReader, parseOrientations) |
3059 | -{ |
3060 | - using namespace ::testing; |
3061 | - |
3062 | - const Qt::ScreenOrientations defaultOrientations = Qt::PortraitOrientation | Qt::LandscapeOrientation |
3063 | - | Qt::InvertedPortraitOrientation | Qt::InvertedLandscapeOrientation; |
3064 | - bool ok; |
3065 | - Qt::ScreenOrientations orientations; |
3066 | - |
3067 | - ok = DesktopFileReader::parseOrientations(QString(), orientations); |
3068 | - ASSERT_TRUE(ok); |
3069 | - EXPECT_EQ(defaultOrientations, orientations); |
3070 | - |
3071 | - ok = DesktopFileReader::parseOrientations("An invalid string!", orientations); |
3072 | - ASSERT_FALSE(ok); |
3073 | - EXPECT_EQ(defaultOrientations, orientations); |
3074 | - |
3075 | - ok = DesktopFileReader::parseOrientations("landscape", orientations); |
3076 | - ASSERT_TRUE(ok); |
3077 | - EXPECT_EQ(Qt::LandscapeOrientation, orientations); |
3078 | - |
3079 | - ok = DesktopFileReader::parseOrientations(" InvertedPortrait , Portrait ", orientations); |
3080 | - ASSERT_TRUE(ok); |
3081 | - EXPECT_EQ(Qt::InvertedPortraitOrientation | Qt::PortraitOrientation, orientations); |
3082 | - |
3083 | - ok = DesktopFileReader::parseOrientations(",inverted-landscape, inverted_portrait, ", orientations); |
3084 | - ASSERT_TRUE(ok); |
3085 | - EXPECT_EQ(Qt::InvertedPortraitOrientation | Qt::InvertedLandscapeOrientation, orientations); |
3086 | - |
3087 | - ok = DesktopFileReader::parseOrientations(",inverted-landscape, some-invalid-text, ", orientations); |
3088 | - ASSERT_FALSE(ok); |
3089 | - EXPECT_EQ(defaultOrientations, orientations); |
3090 | - |
3091 | - ok = DesktopFileReader::parseOrientations("landscape;portrait", orientations); |
3092 | - ASSERT_TRUE(ok); |
3093 | - EXPECT_EQ(Qt::PortraitOrientation | Qt::LandscapeOrientation, orientations); |
3094 | - |
3095 | - ok = DesktopFileReader::parseOrientations("primary", orientations); |
3096 | - ASSERT_TRUE(ok); |
3097 | - EXPECT_EQ(Qt::PrimaryOrientation, orientations); |
3098 | - |
3099 | - ok = DesktopFileReader::parseOrientations("landscpe,primary", orientations); |
3100 | - ASSERT_FALSE(ok); |
3101 | - EXPECT_EQ(defaultOrientations, orientations); |
3102 | -} |
3103 | - |
3104 | -TEST(DesktopFileReader, parseBoolean) |
3105 | -{ |
3106 | - using namespace ::testing; |
3107 | - |
3108 | - bool ok; |
3109 | - bool boolean; |
3110 | - |
3111 | - ok = DesktopFileReader::parseBoolean(QString(), boolean); |
3112 | - ASSERT_TRUE(ok); |
3113 | - EXPECT_FALSE(boolean); |
3114 | - |
3115 | - ok = DesktopFileReader::parseBoolean(" Yes ", boolean); |
3116 | - ASSERT_TRUE(ok); |
3117 | - EXPECT_TRUE(boolean); |
3118 | - |
3119 | - ok = DesktopFileReader::parseBoolean("False", boolean); |
3120 | - ASSERT_TRUE(ok); |
3121 | - EXPECT_FALSE(boolean); |
3122 | - |
3123 | - ok = DesktopFileReader::parseBoolean("Hello World!", boolean); |
3124 | - ASSERT_FALSE(ok); |
3125 | - EXPECT_FALSE(boolean); |
3126 | -} |