Merge lp:~unity-team/unity/y-sru1 into lp:unity/yakkety
- y-sru1
- Merge into yakkety
Proposed by
Marco Trevisan (Treviño)
Status: | Merged |
---|---|
Approved by: | Andrea Azzarone |
Approved revision: | no longer in the source branch. |
Merged at revision: | 4195 |
Proposed branch: | lp:~unity-team/unity/y-sru1 |
Merge into: | lp:unity/yakkety |
Diff against target: |
602 lines (+370/-41) 13 files modified
UnityCore/GnomeSessionManager.cpp (+59/-26) UnityCore/GnomeSessionManagerImpl.h (+2/-0) UnityCore/Variant.cpp (+30/-0) UnityCore/Variant.h (+1/-0) debian/changelog (+17/-0) decorations/DecorationsForceQuitDialog.cpp (+4/-2) launcher/FileManagerLauncherIcon.cpp (+30/-0) launcher/FileManagerLauncherIcon.h (+8/-0) launcher/StorageLauncherIcon.cpp (+7/-12) lockscreen/LockScreenController.cpp (+1/-0) tests/CMakeLists.txt (+1/-0) tests/test_file_manager_launcher_icon.cpp (+202/-0) tests/test_gnome_session_manager.cpp (+8/-1) |
To merge this branch: | bzr merge lp:~unity-team/unity/y-sru1 |
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Andrea Azzarone (community) | Approve | ||
Review via email:
|
Commit message
Releasing SRU1 for yakkety
Description of the change
To post a comment you must log in.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'UnityCore/GnomeSessionManager.cpp' | |||
2 | --- UnityCore/GnomeSessionManager.cpp 2016-09-01 17:18:03 +0000 | |||
3 | +++ UnityCore/GnomeSessionManager.cpp 2016-11-11 14:53:10 +0000 | |||
4 | @@ -101,32 +101,37 @@ | |||
5 | 101 | }); | 101 | }); |
6 | 102 | 102 | ||
7 | 103 | { | 103 | { |
34 | 104 | const char* session_id = test_mode_ ? "id0" : g_getenv("XDG_SESSION_ID"); | 104 | std::string session_id = test_mode_ ? "id0" : glib::gchar_to_string(g_getenv("XDG_SESSION_ID")); |
35 | 105 | 105 | ||
36 | 106 | login_proxy_ = std::make_shared<glib::DBusProxy>(test_mode_ ? testing::DBUS_NAME : "org.freedesktop.login1", | 106 | if (!session_id.empty()) |
37 | 107 | "/org/freedesktop/login1/session/" + glib::gchar_to_string(session_id), | 107 | { |
38 | 108 | "org.freedesktop.login1.Session", | 108 | CallLogindMethod("GetSession", g_variant_new("(s)", session_id.c_str()), [this, session_id] (GVariant* variant, glib::Error const& err) { |
39 | 109 | test_mode_ ? G_BUS_TYPE_SESSION : G_BUS_TYPE_SYSTEM, | 109 | std::string session_path; |
40 | 110 | G_DBUS_PROXY_FLAGS_GET_INVALIDATED_PROPERTIES); | 110 | |
41 | 111 | 111 | if (!err && variant) | |
42 | 112 | login_proxy_->Connect("Lock", [this](GVariant*){ | 112 | session_path = glib::Variant(variant).GetObjectPath(); |
43 | 113 | manager_->PromptLockScreen(); | 113 | |
44 | 114 | }); | 114 | if (session_path.empty()) |
45 | 115 | 115 | session_path = "/org/freedesktop/login1/session/" + session_id; | |
46 | 116 | login_proxy_->Connect("Unlock", [this](GVariant*){ | 116 | |
47 | 117 | manager_->unlock_requested.emit(); | 117 | SetupLogin1Proxy(session_path); |
48 | 118 | }); | 118 | }); |
49 | 119 | 119 | } | |
50 | 120 | login_proxy_->ConnectProperty("Active", [this] (GVariant* variant) { | 120 | else |
51 | 121 | bool active = glib::Variant(variant).GetBool(); | 121 | { |
52 | 122 | manager_->is_session_active.changed.emit(active); | 122 | auto proxy = std::make_shared<glib::DBusProxy>("org.freedesktop.login1", |
53 | 123 | if (active) | 123 | "/org/freedesktop/login1/user/self", |
54 | 124 | manager_->screensaver_requested.emit(false); | 124 | "org.freedesktop.login1.User", |
55 | 125 | }); | 125 | G_BUS_TYPE_SYSTEM); |
56 | 126 | 126 | ||
57 | 127 | manager_->is_session_active.SetGetterFunction([this] { | 127 | proxy->GetProperty("Display", [this, proxy] (GVariant *variant) { |
58 | 128 | return login_proxy_->GetProperty("Active").GetBool(); | 128 | if (!variant || g_variant_n_children(variant) < 2) |
59 | 129 | }); | 129 | return; |
60 | 130 | |||
61 | 131 | glib::Variant tmp(g_variant_get_child_value(variant, 1), glib::StealRef()); | ||
62 | 132 | SetupLogin1Proxy(tmp.GetObjectPath()); | ||
63 | 133 | }); | ||
64 | 134 | } | ||
65 | 130 | } | 135 | } |
66 | 131 | 136 | ||
67 | 132 | { | 137 | { |
68 | @@ -221,6 +226,34 @@ | |||
69 | 221 | ClosedDialog(); | 226 | ClosedDialog(); |
70 | 222 | } | 227 | } |
71 | 223 | 228 | ||
72 | 229 | void GnomeManager::Impl::SetupLogin1Proxy(std::string const& session_path) | ||
73 | 230 | { | ||
74 | 231 | login_proxy_ = std::make_shared<glib::DBusProxy>(test_mode_ ? testing::DBUS_NAME : "org.freedesktop.login1", | ||
75 | 232 | session_path, | ||
76 | 233 | "org.freedesktop.login1.Session", | ||
77 | 234 | test_mode_ ? G_BUS_TYPE_SESSION : G_BUS_TYPE_SYSTEM, | ||
78 | 235 | G_DBUS_PROXY_FLAGS_GET_INVALIDATED_PROPERTIES); | ||
79 | 236 | |||
80 | 237 | login_proxy_->Connect("Lock", [this](GVariant*){ | ||
81 | 238 | manager_->PromptLockScreen(); | ||
82 | 239 | }); | ||
83 | 240 | |||
84 | 241 | login_proxy_->Connect("Unlock", [this](GVariant*){ | ||
85 | 242 | manager_->unlock_requested.emit(); | ||
86 | 243 | }); | ||
87 | 244 | |||
88 | 245 | login_proxy_->ConnectProperty("Active", [this] (GVariant* variant) { | ||
89 | 246 | bool active = glib::Variant(variant).GetBool(); | ||
90 | 247 | manager_->is_session_active.changed.emit(active); | ||
91 | 248 | if (active) | ||
92 | 249 | manager_->screensaver_requested.emit(false); | ||
93 | 250 | }); | ||
94 | 251 | |||
95 | 252 | manager_->is_session_active.SetGetterFunction([this] { | ||
96 | 253 | return login_proxy_->GetProperty("Active").GetBool(); | ||
97 | 254 | }); | ||
98 | 255 | } | ||
99 | 256 | |||
100 | 224 | bool GnomeManager::Impl::InteractiveMode() | 257 | bool GnomeManager::Impl::InteractiveMode() |
101 | 225 | { | 258 | { |
102 | 226 | bool schema_found = false; | 259 | bool schema_found = false; |
103 | 227 | 260 | ||
104 | === modified file 'UnityCore/GnomeSessionManagerImpl.h' | |||
105 | --- UnityCore/GnomeSessionManagerImpl.h 2015-12-03 05:57:00 +0000 | |||
106 | +++ UnityCore/GnomeSessionManagerImpl.h 2016-11-11 14:53:10 +0000 | |||
107 | @@ -46,6 +46,8 @@ | |||
108 | 46 | Impl(GnomeManager* parent, bool test_mode = false); | 46 | Impl(GnomeManager* parent, bool test_mode = false); |
109 | 47 | ~Impl(); | 47 | ~Impl(); |
110 | 48 | 48 | ||
111 | 49 | void SetupLogin1Proxy(std::string const& session_path); | ||
112 | 50 | |||
113 | 49 | void ConfirmLogout(); | 51 | void ConfirmLogout(); |
114 | 50 | void ConfirmReboot(); | 52 | void ConfirmReboot(); |
115 | 51 | void ConfirmShutdown(); | 53 | void ConfirmShutdown(); |
116 | 52 | 54 | ||
117 | === modified file 'UnityCore/Variant.cpp' | |||
118 | --- UnityCore/Variant.cpp 2013-11-19 20:28:13 +0000 | |||
119 | +++ UnityCore/Variant.cpp 2016-11-11 14:53:10 +0000 | |||
120 | @@ -174,6 +174,36 @@ | |||
121 | 174 | return result ? result : ""; | 174 | return result ? result : ""; |
122 | 175 | } | 175 | } |
123 | 176 | 176 | ||
124 | 177 | std::string Variant::GetObjectPath() const | ||
125 | 178 | { | ||
126 | 179 | const gchar *result = nullptr; | ||
127 | 180 | |||
128 | 181 | if (!variant_) | ||
129 | 182 | return ""; | ||
130 | 183 | |||
131 | 184 | if (g_variant_is_of_type(variant_, G_VARIANT_TYPE_OBJECT_PATH)) | ||
132 | 185 | { | ||
133 | 186 | // g_variant_get_string doesn't duplicate the string | ||
134 | 187 | result = g_variant_get_string(variant_, nullptr); | ||
135 | 188 | } | ||
136 | 189 | else if (g_variant_is_of_type(variant_, G_VARIANT_TYPE("(o)"))) | ||
137 | 190 | { | ||
138 | 191 | // As we're using the '&' prefix we don't need to free the string! | ||
139 | 192 | g_variant_get(variant_, "(&o)", &result); | ||
140 | 193 | } | ||
141 | 194 | else | ||
142 | 195 | { | ||
143 | 196 | auto const& variant = get_variant(variant_); | ||
144 | 197 | if (variant) | ||
145 | 198 | return variant.GetObjectPath(); | ||
146 | 199 | |||
147 | 200 | LOG_ERROR(logger) << "You're trying to extract a 'o' from a variant which is of type '" | ||
148 | 201 | << g_variant_type_peek_string(g_variant_get_type(variant_)) << "'"; | ||
149 | 202 | } | ||
150 | 203 | |||
151 | 204 | return result ? result : ""; | ||
152 | 205 | } | ||
153 | 206 | |||
154 | 177 | template <typename TYPE, typename GTYPE> | 207 | template <typename TYPE, typename GTYPE> |
155 | 178 | TYPE get_numeric_value(GVariant *variant_, const char *type_str, const char *fallback_type_str) | 208 | TYPE get_numeric_value(GVariant *variant_, const char *type_str, const char *fallback_type_str) |
156 | 179 | { | 209 | { |
157 | 180 | 210 | ||
158 | === modified file 'UnityCore/Variant.h' | |||
159 | --- UnityCore/Variant.h 2013-11-19 20:28:13 +0000 | |||
160 | +++ UnityCore/Variant.h 2016-11-11 14:53:10 +0000 | |||
161 | @@ -68,6 +68,7 @@ | |||
162 | 68 | ~Variant(); | 68 | ~Variant(); |
163 | 69 | 69 | ||
164 | 70 | std::string GetString() const; | 70 | std::string GetString() const; |
165 | 71 | std::string GetObjectPath() const; | ||
166 | 71 | unsigned char GetByte() const; | 72 | unsigned char GetByte() const; |
167 | 72 | int16_t GetInt16() const; | 73 | int16_t GetInt16() const; |
168 | 73 | uint16_t GetUInt16() const; | 74 | uint16_t GetUInt16() const; |
169 | 74 | 75 | ||
170 | === modified file 'debian/changelog' | |||
171 | --- debian/changelog 2016-09-06 14:19:16 +0000 | |||
172 | +++ debian/changelog 2016-11-11 14:53:10 +0000 | |||
173 | @@ -1,3 +1,20 @@ | |||
174 | 1 | unity (7.5.0+16.10.20160906.1-0ubuntu2) UNRELEASED; urgency=medium | ||
175 | 2 | |||
176 | 3 | [ Marco Trevisan (Treviño) ] | ||
177 | 4 | * LockScreenController: ignore icon_paths_changed signal in | ||
178 | 5 | menumanager for Lockscreen (LP: #1635625) | ||
179 | 6 | |||
180 | 7 | [ Andrea Azzarone ] | ||
181 | 8 | * Properly handle the file manager copy dialog in | ||
182 | 9 | FileManagerLauncherIcon and in StorageLauncherIcon. (LP: #1575452, | ||
183 | 10 | LP: #1609845) | ||
184 | 11 | * Correctly position the force quit dialog when scaling is different | ||
185 | 12 | than 1.0 (LP: #1637991) | ||
186 | 13 | * GnomeSession: Retrieve the session id using dbus if $XDG_SESSION_ID | ||
187 | 14 | is not set (LP: #1633749) | ||
188 | 15 | |||
189 | 16 | -- Marco Trevisan (Treviño) <mail@3v1n0.net> Fri, 11 Nov 2016 14:45:03 +0100 | ||
190 | 17 | |||
191 | 1 | unity (7.5.0+16.10.20160906.1-0ubuntu1) yakkety; urgency=medium | 18 | unity (7.5.0+16.10.20160906.1-0ubuntu1) yakkety; urgency=medium |
192 | 2 | 19 | ||
193 | 3 | [ Marco Trevisan (Treviño), Ted Gould ] | 20 | [ Marco Trevisan (Treviño), Ted Gould ] |
194 | 4 | 21 | ||
195 | === modified file 'decorations/DecorationsForceQuitDialog.cpp' | |||
196 | --- decorations/DecorationsForceQuitDialog.cpp 2016-08-06 16:24:55 +0000 | |||
197 | +++ decorations/DecorationsForceQuitDialog.cpp 2016-11-11 14:53:10 +0000 | |||
198 | @@ -478,9 +478,11 @@ | |||
199 | 478 | 478 | ||
200 | 479 | void UpdateDialogPosition() | 479 | void UpdateDialogPosition() |
201 | 480 | { | 480 | { |
202 | 481 | gint scale = gtk_widget_get_scale_factor(dialog_); | ||
203 | 482 | scale = std::max<gint>(1, scale); | ||
204 | 481 | auto const& win_geo = win_->inputRect(); | 483 | auto const& win_geo = win_->inputRect(); |
207 | 482 | nux::Size walloc(gtk_widget_get_allocated_width(dialog_), gtk_widget_get_allocated_height(dialog_)); | 484 | nux::Size walloc(gtk_widget_get_allocated_width(dialog_) * scale, gtk_widget_get_allocated_height(dialog_) * scale); |
208 | 483 | gtk_window_move(GTK_WINDOW(dialog_), win_geo.centerX() - walloc.width/2, win_geo.centerY() - walloc.height/2); | 485 | gtk_window_move(GTK_WINDOW(dialog_), (win_geo.centerX() - walloc.width/2) / scale, (win_geo.centerY() - walloc.height/2) / scale); |
209 | 484 | } | 486 | } |
210 | 485 | 487 | ||
211 | 486 | ForceQuitDialog* parent_; | 488 | ForceQuitDialog* parent_; |
212 | 487 | 489 | ||
213 | === modified file 'launcher/FileManagerLauncherIcon.cpp' | |||
214 | --- launcher/FileManagerLauncherIcon.cpp 2016-07-05 13:35:56 +0000 | |||
215 | +++ launcher/FileManagerLauncherIcon.cpp 2016-11-11 14:53:10 +0000 | |||
216 | @@ -49,6 +49,11 @@ | |||
217 | 49 | SetQuirk(Quirk::VISIBLE, false); | 49 | SetQuirk(Quirk::VISIBLE, false); |
218 | 50 | SkipQuirkAnimation(Quirk::VISIBLE); | 50 | SkipQuirkAnimation(Quirk::VISIBLE); |
219 | 51 | 51 | ||
220 | 52 | signals_conn_.Add(app_->window_opened.connect([this](ApplicationWindowPtr const& win) { | ||
221 | 53 | signals_conn_.Add(win->monitor.changed.connect([this] (int) { UpdateStorageWindows(); })); | ||
222 | 54 | UpdateStorageWindows(); | ||
223 | 55 | })); | ||
224 | 56 | |||
225 | 52 | signals_conn_.Add(app_->desktop_file.changed.connect([this](std::string const& desktop_file) { | 57 | signals_conn_.Add(app_->desktop_file.changed.connect([this](std::string const& desktop_file) { |
226 | 53 | LOG_DEBUG(logger) << tooltip_text() << " desktop_file now " << desktop_file; | 58 | LOG_DEBUG(logger) << tooltip_text() << " desktop_file now " << desktop_file; |
227 | 54 | UpdateDesktopFile(); | 59 | UpdateDesktopFile(); |
228 | @@ -134,5 +139,30 @@ | |||
229 | 134 | return StorageLauncherIcon::OnShouldHighlightOnDrag(dnd_data); | 139 | return StorageLauncherIcon::OnShouldHighlightOnDrag(dnd_data); |
230 | 135 | } | 140 | } |
231 | 136 | 141 | ||
232 | 142 | bool FileManagerLauncherIcon::IsUserVisible() const | ||
233 | 143 | { | ||
234 | 144 | return ApplicationLauncherIcon::IsUserVisible(); | ||
235 | 145 | } | ||
236 | 146 | |||
237 | 147 | WindowList FileManagerLauncherIcon::WindowsOnViewport() | ||
238 | 148 | { | ||
239 | 149 | WindowFilterMask filter = 0; | ||
240 | 150 | filter |= WindowFilter::MAPPED; | ||
241 | 151 | filter |= WindowFilter::ON_CURRENT_DESKTOP; | ||
242 | 152 | filter |= WindowFilter::ON_ALL_MONITORS; | ||
243 | 153 | |||
244 | 154 | return WindowedLauncherIcon::GetWindows(filter); | ||
245 | 155 | } | ||
246 | 156 | |||
247 | 157 | WindowList FileManagerLauncherIcon::WindowsForMonitor(int monitor) | ||
248 | 158 | { | ||
249 | 159 | WindowFilterMask filter = 0; | ||
250 | 160 | filter |= WindowFilter::MAPPED; | ||
251 | 161 | filter |= WindowFilter::ON_CURRENT_DESKTOP; | ||
252 | 162 | |||
253 | 163 | return WindowedLauncherIcon::GetWindows(filter, monitor); | ||
254 | 164 | } | ||
255 | 165 | |||
256 | 166 | |||
257 | 137 | } // namespace launcher | 167 | } // namespace launcher |
258 | 138 | } // namespace unity | 168 | } // namespace unity |
259 | 139 | 169 | ||
260 | === modified file 'launcher/FileManagerLauncherIcon.h' | |||
261 | --- launcher/FileManagerLauncherIcon.h 2015-12-09 12:02:48 +0000 | |||
262 | +++ launcher/FileManagerLauncherIcon.h 2016-11-11 14:53:10 +0000 | |||
263 | @@ -32,8 +32,16 @@ | |||
264 | 32 | class FileManagerLauncherIcon : public ApplicationLauncherIcon, public StorageLauncherIcon | 32 | class FileManagerLauncherIcon : public ApplicationLauncherIcon, public StorageLauncherIcon |
265 | 33 | { | 33 | { |
266 | 34 | public: | 34 | public: |
267 | 35 | typedef nux::ObjectPtr<FileManagerLauncherIcon> Ptr; | ||
268 | 36 | |||
269 | 35 | FileManagerLauncherIcon(ApplicationPtr const&, DeviceLauncherSection::Ptr const&, FileManager::Ptr const& = nullptr); | 37 | FileManagerLauncherIcon(ApplicationPtr const&, DeviceLauncherSection::Ptr const&, FileManager::Ptr const& = nullptr); |
270 | 36 | 38 | ||
271 | 39 | bool IsUserVisible() const override; | ||
272 | 40 | |||
273 | 41 | protected: | ||
274 | 42 | WindowList WindowsOnViewport() override; | ||
275 | 43 | WindowList WindowsForMonitor(int monitor) override; | ||
276 | 44 | |||
277 | 37 | private: | 45 | private: |
278 | 38 | WindowList GetManagedWindows() const override; | 46 | WindowList GetManagedWindows() const override; |
279 | 39 | WindowList GetStorageWindows() const override; | 47 | WindowList GetStorageWindows() const override; |
280 | 40 | 48 | ||
281 | === modified file 'launcher/StorageLauncherIcon.cpp' | |||
282 | --- launcher/StorageLauncherIcon.cpp 2015-12-08 14:31:30 +0000 | |||
283 | +++ launcher/StorageLauncherIcon.cpp 2016-11-11 14:53:10 +0000 | |||
284 | @@ -36,7 +36,7 @@ | |||
285 | 36 | bool active = false; | 36 | bool active = false; |
286 | 37 | bool urgent = false; | 37 | bool urgent = false; |
287 | 38 | bool check_visibility = (GetIconType() == IconType::APPLICATION); | 38 | bool check_visibility = (GetIconType() == IconType::APPLICATION); |
289 | 39 | bool visible = IsSticky(); | 39 | bool visible = false; |
290 | 40 | 40 | ||
291 | 41 | managed_windows_ = GetStorageWindows(); | 41 | managed_windows_ = GetStorageWindows(); |
292 | 42 | windows_connections_.Clear(); | 42 | windows_connections_.Clear(); |
293 | @@ -54,13 +54,8 @@ | |||
294 | 54 | if (!urgent && win->urgent()) | 54 | if (!urgent && win->urgent()) |
295 | 55 | urgent = true; | 55 | urgent = true; |
296 | 56 | 56 | ||
304 | 57 | if (check_visibility) | 57 | if (check_visibility && !visible) |
305 | 58 | { | 58 | visible = true; |
299 | 59 | windows_connections_.Add(win->visible.changed.connect([this] (bool) { OnWindowStateChanged(); })); | ||
300 | 60 | |||
301 | 61 | if (!visible && win->visible()) | ||
302 | 62 | visible = true; | ||
303 | 63 | } | ||
306 | 64 | } | 59 | } |
307 | 65 | 60 | ||
308 | 66 | SetQuirk(Quirk::RUNNING, !managed_windows_.empty()); | 61 | SetQuirk(Quirk::RUNNING, !managed_windows_.empty()); |
309 | @@ -68,7 +63,7 @@ | |||
310 | 68 | SetQuirk(Quirk::URGENT, urgent); | 63 | SetQuirk(Quirk::URGENT, urgent); |
311 | 69 | 64 | ||
312 | 70 | if (check_visibility) | 65 | if (check_visibility) |
314 | 71 | SetQuirk(Quirk::VISIBLE, visible); | 66 | SetQuirk(Quirk::VISIBLE, visible || IsSticky()); |
315 | 72 | 67 | ||
316 | 73 | EnsureWindowsLocation(); | 68 | EnsureWindowsLocation(); |
317 | 74 | } | 69 | } |
318 | @@ -83,7 +78,7 @@ | |||
319 | 83 | bool active = false; | 78 | bool active = false; |
320 | 84 | bool urgent = false; | 79 | bool urgent = false; |
321 | 85 | bool check_visibility = (GetIconType() == IconType::APPLICATION); | 80 | bool check_visibility = (GetIconType() == IconType::APPLICATION); |
323 | 86 | bool visible = IsSticky(); | 81 | bool visible = false; |
324 | 87 | 82 | ||
325 | 88 | for (auto const& win : managed_windows_) | 83 | for (auto const& win : managed_windows_) |
326 | 89 | { | 84 | { |
327 | @@ -93,7 +88,7 @@ | |||
328 | 93 | if (!urgent && win->urgent()) | 88 | if (!urgent && win->urgent()) |
329 | 94 | urgent = true; | 89 | urgent = true; |
330 | 95 | 90 | ||
332 | 96 | if (check_visibility && !visible && win->visible()) | 91 | if (check_visibility && !visible) |
333 | 97 | visible = true; | 92 | visible = true; |
334 | 98 | } | 93 | } |
335 | 99 | 94 | ||
336 | @@ -101,7 +96,7 @@ | |||
337 | 101 | SetQuirk(Quirk::URGENT, urgent); | 96 | SetQuirk(Quirk::URGENT, urgent); |
338 | 102 | 97 | ||
339 | 103 | if (check_visibility) | 98 | if (check_visibility) |
341 | 104 | SetQuirk(Quirk::VISIBLE, visible); | 99 | SetQuirk(Quirk::VISIBLE, visible || IsSticky()); |
342 | 105 | } | 100 | } |
343 | 106 | 101 | ||
344 | 107 | bool StorageLauncherIcon::OnShouldHighlightOnDrag(DndData const& dnd_data) | 102 | bool StorageLauncherIcon::OnShouldHighlightOnDrag(DndData const& dnd_data) |
345 | 108 | 103 | ||
346 | === modified file 'lockscreen/LockScreenController.cpp' | |||
347 | --- lockscreen/LockScreenController.cpp 2016-09-02 13:36:37 +0000 | |||
348 | +++ lockscreen/LockScreenController.cpp 2016-11-11 14:53:10 +0000 | |||
349 | @@ -467,6 +467,7 @@ | |||
350 | 467 | void Controller::LockScreen() | 467 | void Controller::LockScreen() |
351 | 468 | { | 468 | { |
352 | 469 | menu_manager_ = std::make_shared<menu::Manager>(std::make_shared<indicator::LockScreenDBusIndicators>(), key_grabber_); | 469 | menu_manager_ = std::make_shared<menu::Manager>(std::make_shared<indicator::LockScreenDBusIndicators>(), key_grabber_); |
353 | 470 | menu_manager_->Indicators()->icon_paths_changed.clear(); // Ignore custom icon themes for lockscreen, see bug #1635625 | ||
354 | 470 | upstart_wrapper_->Emit("desktop-lock"); | 471 | upstart_wrapper_->Emit("desktop-lock"); |
355 | 471 | systemd_wrapper_->Start(SYSTEMD_LOCK_TARGET); | 472 | systemd_wrapper_->Start(SYSTEMD_LOCK_TARGET); |
356 | 472 | 473 | ||
357 | 473 | 474 | ||
358 | === modified file 'tests/CMakeLists.txt' | |||
359 | --- tests/CMakeLists.txt 2016-07-20 15:55:32 +0000 | |||
360 | +++ tests/CMakeLists.txt 2016-11-11 14:53:10 +0000 | |||
361 | @@ -224,6 +224,7 @@ | |||
362 | 224 | test_error_preview.cpp | 224 | test_error_preview.cpp |
363 | 225 | test_edge_barrier_controller.cpp | 225 | test_edge_barrier_controller.cpp |
364 | 226 | test_expo_launcher_icon.cpp | 226 | test_expo_launcher_icon.cpp |
365 | 227 | test_file_manager_launcher_icon.cpp | ||
366 | 227 | test_filter_widgets.cpp | 228 | test_filter_widgets.cpp |
367 | 228 | test_glib_dbus_server.cpp | 229 | test_glib_dbus_server.cpp |
368 | 229 | test_gnome_session_manager.cpp | 230 | test_gnome_session_manager.cpp |
369 | 230 | 231 | ||
370 | === added file 'tests/test_file_manager_launcher_icon.cpp' | |||
371 | --- tests/test_file_manager_launcher_icon.cpp 1970-01-01 00:00:00 +0000 | |||
372 | +++ tests/test_file_manager_launcher_icon.cpp 2016-11-11 14:53:10 +0000 | |||
373 | @@ -0,0 +1,202 @@ | |||
374 | 1 | /* | ||
375 | 2 | * Copyright 2016 Canonical Ltd. | ||
376 | 3 | * | ||
377 | 4 | * This program is free software: you can redistribute it and/or modify it | ||
378 | 5 | * under the terms of the GNU General Public License version 3, as published | ||
379 | 6 | * by the Free Software Foundation. | ||
380 | 7 | * | ||
381 | 8 | * This program is distributed in the hope that it will be useful, but | ||
382 | 9 | * WITHOUT ANY WARRANTY; without even the implied warranties of | ||
383 | 10 | * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR | ||
384 | 11 | * PURPOSE. See the GNU General Public License for more details. | ||
385 | 12 | * | ||
386 | 13 | * You should have received a copy of the GNU General Public License | ||
387 | 14 | * version 3 along with this program. If not, see | ||
388 | 15 | * <http://www.gnu.org/licenses/> | ||
389 | 16 | * | ||
390 | 17 | * Authored by: Andrea Azzarone <andrea.azzarone@canonical.com> | ||
391 | 18 | */ | ||
392 | 19 | |||
393 | 20 | #include <gmock/gmock.h> | ||
394 | 21 | using namespace testing; | ||
395 | 22 | |||
396 | 23 | #include "FileManagerLauncherIcon.h" | ||
397 | 24 | #include "UnityCore/DesktopUtilities.h" | ||
398 | 25 | |||
399 | 26 | #include "test_mock_devices.h" | ||
400 | 27 | #include "test_mock_filemanager.h" | ||
401 | 28 | #include "mock-application.h" | ||
402 | 29 | |||
403 | 30 | using namespace unity; | ||
404 | 31 | using namespace unity::launcher; | ||
405 | 32 | using namespace testmocks; | ||
406 | 33 | |||
407 | 34 | namespace | ||
408 | 35 | { | ||
409 | 36 | |||
410 | 37 | const std::string TRASH_URI = "trash:"; | ||
411 | 38 | const std::string TRASH_PATH = "file://" + DesktopUtilities::GetUserTrashDirectory(); | ||
412 | 39 | |||
413 | 40 | struct TestFileManagerLauncherIcon : public Test | ||
414 | 41 | { | ||
415 | 42 | TestFileManagerLauncherIcon() | ||
416 | 43 | : app_(std::make_shared<MockApplication::Nice>()) | ||
417 | 44 | , fm_(std::make_shared<MockFileManager::Nice>()) | ||
418 | 45 | , dev_ (std::make_shared<MockDeviceLauncherSection>(2)) | ||
419 | 46 | , icon_(new FileManagerLauncherIcon(app_, dev_, fm_)) | ||
420 | 47 | { | ||
421 | 48 | } | ||
422 | 49 | |||
423 | 50 | MockApplication::Ptr app_; | ||
424 | 51 | MockFileManager::Ptr fm_; | ||
425 | 52 | DeviceLauncherSection::Ptr dev_; | ||
426 | 53 | FileManagerLauncherIcon::Ptr icon_; | ||
427 | 54 | }; | ||
428 | 55 | |||
429 | 56 | TEST_F(TestFileManagerLauncherIcon, IconType) | ||
430 | 57 | { | ||
431 | 58 | EXPECT_EQ(icon_->GetIconType(), AbstractLauncherIcon::IconType::APPLICATION); | ||
432 | 59 | } | ||
433 | 60 | |||
434 | 61 | TEST_F(TestFileManagerLauncherIcon, NoWindow) | ||
435 | 62 | { | ||
436 | 63 | EXPECT_FALSE(icon_->IsVisible()); | ||
437 | 64 | } | ||
438 | 65 | |||
439 | 66 | TEST_F(TestFileManagerLauncherIcon, NoManagedWindow_TrashUri) | ||
440 | 67 | { | ||
441 | 68 | EXPECT_CALL(*fm_, LocationForWindow(_)).Times(1); | ||
442 | 69 | ON_CALL(*fm_, LocationForWindow(_)).WillByDefault(Return(TRASH_URI)); | ||
443 | 70 | |||
444 | 71 | auto win = std::make_shared<MockApplicationWindow::Nice>(g_random_int()); | ||
445 | 72 | app_->windows_ = { win }; | ||
446 | 73 | app_->window_opened.emit(win); | ||
447 | 74 | |||
448 | 75 | EXPECT_FALSE(icon_->IsVisible()); | ||
449 | 76 | EXPECT_FALSE(icon_->IsRunning()); | ||
450 | 77 | } | ||
451 | 78 | |||
452 | 79 | TEST_F(TestFileManagerLauncherIcon, NoManagedWindow_TrashPath) | ||
453 | 80 | { | ||
454 | 81 | EXPECT_CALL(*fm_, LocationForWindow(_)).Times(1); | ||
455 | 82 | ON_CALL(*fm_, LocationForWindow(_)).WillByDefault(Return(TRASH_PATH)); | ||
456 | 83 | |||
457 | 84 | auto win = std::make_shared<MockApplicationWindow::Nice>(g_random_int()); | ||
458 | 85 | app_->windows_ = { win }; | ||
459 | 86 | app_->window_opened.emit(win); | ||
460 | 87 | |||
461 | 88 | EXPECT_FALSE(icon_->IsVisible()); | ||
462 | 89 | EXPECT_FALSE(icon_->IsRunning()); | ||
463 | 90 | } | ||
464 | 91 | |||
465 | 92 | TEST_F(TestFileManagerLauncherIcon, NoManagedWindow_Device) | ||
466 | 93 | { | ||
467 | 94 | auto const& device_icons = dev_->GetIcons(); | ||
468 | 95 | ASSERT_EQ(2, device_icons.size()); | ||
469 | 96 | |||
470 | 97 | device_icons.at(0)->Activate(ActionArg()); | ||
471 | 98 | |||
472 | 99 | EXPECT_CALL(*fm_, LocationForWindow(_)).Times(1); | ||
473 | 100 | ON_CALL(*fm_, LocationForWindow(_)).WillByDefault(Return(device_icons.at(0)->GetVolumeUri())); | ||
474 | 101 | |||
475 | 102 | auto win = std::make_shared<MockApplicationWindow::Nice>(g_random_int()); | ||
476 | 103 | app_->windows_ = { win }; | ||
477 | 104 | app_->window_opened.emit(win); | ||
478 | 105 | |||
479 | 106 | EXPECT_FALSE(icon_->IsVisible()); | ||
480 | 107 | EXPECT_FALSE(icon_->IsRunning()); | ||
481 | 108 | } | ||
482 | 109 | |||
483 | 110 | TEST_F(TestFileManagerLauncherIcon, ManagedWindows) | ||
484 | 111 | { | ||
485 | 112 | EXPECT_CALL(*fm_, LocationForWindow(_)).Times(1); | ||
486 | 113 | ON_CALL(*fm_, LocationForWindow(_)).WillByDefault(Return("/usr/bin")); | ||
487 | 114 | |||
488 | 115 | auto win = std::make_shared<MockApplicationWindow::Nice>(g_random_int()); | ||
489 | 116 | app_->windows_ = { win }; | ||
490 | 117 | app_->window_opened.emit(win); | ||
491 | 118 | |||
492 | 119 | EXPECT_TRUE(icon_->IsVisible()); | ||
493 | 120 | EXPECT_TRUE(icon_->IsRunning()); | ||
494 | 121 | } | ||
495 | 122 | |||
496 | 123 | TEST_F(TestFileManagerLauncherIcon, ManagedWindows_EmptyLocation) | ||
497 | 124 | { | ||
498 | 125 | EXPECT_CALL(*fm_, LocationForWindow(_)).Times(1); | ||
499 | 126 | ON_CALL(*fm_, LocationForWindow(_)).WillByDefault(Return("")); | ||
500 | 127 | |||
501 | 128 | auto win = std::make_shared<MockApplicationWindow::Nice>(g_random_int()); | ||
502 | 129 | app_->windows_ = { win }; | ||
503 | 130 | app_->window_opened.emit(win); | ||
504 | 131 | |||
505 | 132 | EXPECT_TRUE(icon_->IsVisible()); | ||
506 | 133 | EXPECT_TRUE(icon_->IsRunning()); | ||
507 | 134 | } | ||
508 | 135 | |||
509 | 136 | TEST_F(TestFileManagerLauncherIcon, ManagedWindows_CopyDialog) | ||
510 | 137 | { | ||
511 | 138 | EXPECT_CALL(*fm_, LocationForWindow(_)).Times(1); | ||
512 | 139 | ON_CALL(*fm_, LocationForWindow(_)).WillByDefault(Return("")); | ||
513 | 140 | |||
514 | 141 | auto win = std::make_shared<MockApplicationWindow::Nice>(g_random_int()); | ||
515 | 142 | win->visible_ = false; | ||
516 | 143 | app_->windows_ = { win }; | ||
517 | 144 | app_->window_opened.emit(win); | ||
518 | 145 | |||
519 | 146 | EXPECT_TRUE(icon_->IsVisible()); | ||
520 | 147 | EXPECT_TRUE(icon_->IsRunning()); | ||
521 | 148 | } | ||
522 | 149 | |||
523 | 150 | |||
524 | 151 | TEST_F(TestFileManagerLauncherIcon, ManagedWindows_CopyDialogAndManagedWindow) | ||
525 | 152 | { | ||
526 | 153 | EXPECT_CALL(*fm_, LocationForWindow(_)).Times(3); | ||
527 | 154 | ON_CALL(*fm_, LocationForWindow(_)).WillByDefault(Return("")); | ||
528 | 155 | |||
529 | 156 | auto win = std::make_shared<MockApplicationWindow::Nice>(g_random_int()); | ||
530 | 157 | app_->windows_ = { win }; | ||
531 | 158 | app_->window_opened.emit(win); | ||
532 | 159 | |||
533 | 160 | win = std::make_shared<MockApplicationWindow::Nice>(g_random_int()); | ||
534 | 161 | win->visible_ = false; | ||
535 | 162 | app_->windows_.push_back(win); | ||
536 | 163 | app_->window_opened.emit(win); | ||
537 | 164 | |||
538 | 165 | EXPECT_TRUE(icon_->IsVisible()); | ||
539 | 166 | EXPECT_TRUE(icon_->IsRunning()); | ||
540 | 167 | EXPECT_EQ(2, icon_->WindowsVisibleOnMonitor(0)); | ||
541 | 168 | } | ||
542 | 169 | |||
543 | 170 | TEST_F(TestFileManagerLauncherIcon, ManagedWindows_CopyDialogAndNoManagedWindow) | ||
544 | 171 | { | ||
545 | 172 | { | ||
546 | 173 | InSequence s; | ||
547 | 174 | |||
548 | 175 | EXPECT_CALL(*fm_, LocationForWindow(_)) | ||
549 | 176 | .Times(1) | ||
550 | 177 | .WillOnce(Return("")); | ||
551 | 178 | |||
552 | 179 | EXPECT_CALL(*fm_, LocationForWindow(_)) | ||
553 | 180 | .Times(1) | ||
554 | 181 | .WillOnce(Return("")); | ||
555 | 182 | |||
556 | 183 | EXPECT_CALL(*fm_, LocationForWindow(_)) | ||
557 | 184 | .Times(1) | ||
558 | 185 | .WillOnce(Return(TRASH_PATH)); | ||
559 | 186 | } | ||
560 | 187 | |||
561 | 188 | auto win = std::make_shared<MockApplicationWindow::Nice>(g_random_int()); | ||
562 | 189 | app_->windows_ = { win }; | ||
563 | 190 | app_->window_opened.emit(win); | ||
564 | 191 | |||
565 | 192 | win = std::make_shared<MockApplicationWindow::Nice>(g_random_int()); | ||
566 | 193 | win->visible_ = false; | ||
567 | 194 | app_->windows_.push_back(win); | ||
568 | 195 | app_->window_opened.emit(win); | ||
569 | 196 | |||
570 | 197 | EXPECT_TRUE(icon_->IsVisible()); | ||
571 | 198 | EXPECT_TRUE(icon_->IsRunning()); | ||
572 | 199 | EXPECT_EQ(1, icon_->WindowsVisibleOnMonitor(0)); | ||
573 | 200 | } | ||
574 | 201 | |||
575 | 202 | } | ||
576 | 0 | 203 | ||
577 | === modified file 'tests/test_gnome_session_manager.cpp' | |||
578 | --- tests/test_gnome_session_manager.cpp 2016-05-17 02:14:33 +0000 | |||
579 | +++ tests/test_gnome_session_manager.cpp 2016-11-11 14:53:10 +0000 | |||
580 | @@ -70,6 +70,9 @@ | |||
581 | 70 | const std::string LOGIND_MANAGER = | 70 | const std::string LOGIND_MANAGER = |
582 | 71 | R"(<node> | 71 | R"(<node> |
583 | 72 | <interface name="org.freedesktop.login1.Manager"> | 72 | <interface name="org.freedesktop.login1.Manager"> |
584 | 73 | <method name="GetSession"> | ||
585 | 74 | <arg type="s" name="result" direction="out"/> | ||
586 | 75 | </method> | ||
587 | 73 | <method name="CanSuspend"> | 76 | <method name="CanSuspend"> |
588 | 74 | <arg type="s" name="result" direction="out"/> | 77 | <arg type="s" name="result" direction="out"/> |
589 | 75 | </method> | 78 | </method> |
590 | @@ -186,7 +189,11 @@ | |||
591 | 186 | logind_->AddObjects(introspection::LOGIND_MANAGER, LOGIND_MANAGER_PATH); | 189 | logind_->AddObjects(introspection::LOGIND_MANAGER, LOGIND_MANAGER_PATH); |
592 | 187 | logind_->AddObjects(introspection::LOGIND_SESSION, LOGIND_SESSION_PATH); | 190 | logind_->AddObjects(introspection::LOGIND_SESSION, LOGIND_SESSION_PATH); |
593 | 188 | logind_->GetObjects().front()->SetMethodsCallsHandler([&] (std::string const& method, GVariant*) -> GVariant* { | 191 | logind_->GetObjects().front()->SetMethodsCallsHandler([&] (std::string const& method, GVariant*) -> GVariant* { |
595 | 189 | if (method == "CanSuspend") | 192 | if (method == "GetSession") |
596 | 193 | { | ||
597 | 194 | return g_variant_new("(o)", "id0"); | ||
598 | 195 | } | ||
599 | 196 | else if (method == "CanSuspend") | ||
600 | 190 | { | 197 | { |
601 | 191 | suspend_called = true; | 198 | suspend_called = true; |
602 | 192 | return g_variant_new("(s)", can_suspend_ ? "yes" : "no"); | 199 | return g_variant_new("(s)", can_suspend_ ? "yes" : "no"); |
+1 Thanks