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