Merge lp:~azzar1/unity/fix-681503 into lp:unity
- fix-681503
- Merge into trunk
Status: | Merged | ||||
---|---|---|---|---|---|
Approved by: | Andrea Azzarone | ||||
Approved revision: | no longer in the source branch. | ||||
Merged at revision: | 1871 | ||||
Proposed branch: | lp:~azzar1/unity/fix-681503 | ||||
Merge into: | lp:unity | ||||
Diff against target: |
1285 lines (+1033/-26) 13 files modified
plugins/unityshell/src/BamfLauncherIcon.cpp (+2/-2) plugins/unityshell/src/BamfLauncherIcon.h (+2/-2) plugins/unityshell/src/FavoriteStore.h (+5/-5) plugins/unityshell/src/FavoriteStoreGSettings.cpp (+41/-14) plugins/unityshell/src/FavoriteStoreGSettings.h (+2/-1) plugins/unityshell/src/FavoriteStorePrivate.cpp (+130/-0) plugins/unityshell/src/FavoriteStorePrivate.h (+47/-0) plugins/unityshell/src/LauncherController.cpp (+85/-0) plugins/unityshell/src/LauncherModel.cpp (+30/-0) plugins/unityshell/src/LauncherModel.h (+1/-0) tests/CMakeLists.txt (+3/-0) tests/test_favorite_store_gsettings.cpp (+268/-2) tests/test_favorite_store_private.cpp (+417/-0) |
||||
To merge this branch: | bzr merge lp:~azzar1/unity/fix-681503 | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Mirco Müller (community) | Approve | ||
Review via email: mp+87849@code.launchpad.net |
Commit message
Add FavoriteStore external change support.
Description of the change
Add FavoriteStore external change support.
FavoriteStore can emit 3 signals:
* favorite_added
* favorite_removed
* reordered
Because favorite icons are not separated (in the launcher) from no-favorite icons, we do something like this:
- favorite_
- favorite_
- favorite_
The reordered signal is not emitted if we don't really need it. For example:
- A B C D -> A C D we don't need the reordered signal
- A B C D -> A C E D we don't need it
- A B C D -> A F B H C D we don't need it
- A B C D -> A B D C we need it
- A B C D -> B A we need it
- A B C D -> B A F C D we need it
Andrea Azzarone (azzar1) wrote : | # |
> There's a merge-conflict in plugins/
> trunk...
>
> const char* DesktopFile();
> bool IsSticky();
> <<<<<<< TREE
> void Quit();
> void Stick();
> =======
> void Stick(bool save = true);
> >>>>>>> MERGE-SOURCE
> void UnStick();
Fixed.
Mirco Müller (macslow) wrote : | # |
Looking good now.
Unity Merger (unity-merger) wrote : | # |
Attempt to merge into lp:unity failed due to conflicts:
text conflict in tests/CMakeList
Preview Diff
1 | === modified file 'plugins/unityshell/src/BamfLauncherIcon.cpp' | |||
2 | --- plugins/unityshell/src/BamfLauncherIcon.cpp 2012-01-24 02:19:04 +0000 | |||
3 | +++ plugins/unityshell/src/BamfLauncherIcon.cpp 2012-01-26 14:42:28 +0000 | |||
4 | @@ -871,7 +871,7 @@ | |||
5 | 871 | g_list_free(children); | 871 | g_list_free(children); |
6 | 872 | } | 872 | } |
7 | 873 | 873 | ||
9 | 874 | void BamfLauncherIcon::Stick() | 874 | void BamfLauncherIcon::Stick(bool save) |
10 | 875 | { | 875 | { |
11 | 876 | BamfView* view = BAMF_VIEW(m_App); | 876 | BamfView* view = BAMF_VIEW(m_App); |
12 | 877 | 877 | ||
13 | @@ -881,7 +881,7 @@ | |||
14 | 881 | const gchar* desktop_file = DesktopFile(); | 881 | const gchar* desktop_file = DesktopFile(); |
15 | 882 | bamf_view_set_sticky(view, true); | 882 | bamf_view_set_sticky(view, true); |
16 | 883 | 883 | ||
18 | 884 | if (desktop_file && strlen(desktop_file) > 0) | 884 | if (save && desktop_file && strlen(desktop_file) > 0) |
19 | 885 | FavoriteStore::GetDefault().AddFavorite(desktop_file, -1); | 885 | FavoriteStore::GetDefault().AddFavorite(desktop_file, -1); |
20 | 886 | } | 886 | } |
21 | 887 | 887 | ||
22 | 888 | 888 | ||
23 | === modified file 'plugins/unityshell/src/BamfLauncherIcon.h' | |||
24 | --- plugins/unityshell/src/BamfLauncherIcon.h 2012-01-15 19:01:11 +0000 | |||
25 | +++ plugins/unityshell/src/BamfLauncherIcon.h 2012-01-26 14:42:28 +0000 | |||
26 | @@ -46,9 +46,9 @@ | |||
27 | 46 | 46 | ||
28 | 47 | const char* DesktopFile(); | 47 | const char* DesktopFile(); |
29 | 48 | bool IsSticky(); | 48 | bool IsSticky(); |
30 | 49 | void Stick(bool save = true); | ||
31 | 50 | void UnStick(); | ||
32 | 49 | void Quit(); | 51 | void Quit(); |
33 | 50 | void Stick(); | ||
34 | 51 | void UnStick(); | ||
35 | 52 | 52 | ||
36 | 53 | void ActivateLauncherIcon(ActionArg arg); | 53 | void ActivateLauncherIcon(ActionArg arg); |
37 | 54 | 54 | ||
38 | 55 | 55 | ||
39 | === modified file 'plugins/unityshell/src/FavoriteStore.h' | |||
40 | --- plugins/unityshell/src/FavoriteStore.h 2011-07-21 14:59:25 +0000 | |||
41 | +++ plugins/unityshell/src/FavoriteStore.h 2012-01-26 14:42:28 +0000 | |||
42 | @@ -34,7 +34,7 @@ | |||
43 | 34 | // Use GetDefault () to get the correct store for the session | 34 | // Use GetDefault () to get the correct store for the session |
44 | 35 | typedef std::list<std::string> FavoriteList; | 35 | typedef std::list<std::string> FavoriteList; |
45 | 36 | 36 | ||
47 | 37 | class FavoriteStore : boost::noncopyable | 37 | class FavoriteStore : public sigc::trackable, boost::noncopyable |
48 | 38 | { | 38 | { |
49 | 39 | public: | 39 | public: |
50 | 40 | virtual ~FavoriteStore(); | 40 | virtual ~FavoriteStore(); |
51 | @@ -54,12 +54,12 @@ | |||
52 | 54 | virtual void SetFavorites(FavoriteList const& desktop_paths) = 0; | 54 | virtual void SetFavorites(FavoriteList const& desktop_paths) = 0; |
53 | 55 | 55 | ||
54 | 56 | // Signals | 56 | // Signals |
56 | 57 | // Therse only emit if something has changed the GSettings object externally | 57 | // These only emit if something has changed the GSettings object externally |
57 | 58 | 58 | ||
60 | 59 | //desktop_path, position | 59 | //desktop_path, position, before/after |
61 | 60 | sigc::signal<void, std::string, int> favorite_added; | 60 | sigc::signal<void, std::string const&, std::string const&, bool> favorite_added; |
62 | 61 | //desktop_path | 61 | //desktop_path |
64 | 62 | sigc::signal<void, std::string> favorite_removed; | 62 | sigc::signal<void, std::string const&> favorite_removed; |
65 | 63 | sigc::signal<void> reordered; | 63 | sigc::signal<void> reordered; |
66 | 64 | }; | 64 | }; |
67 | 65 | 65 | ||
68 | 66 | 66 | ||
69 | === modified file 'plugins/unityshell/src/FavoriteStoreGSettings.cpp' | |||
70 | --- plugins/unityshell/src/FavoriteStoreGSettings.cpp 2011-11-28 15:19:31 +0000 | |||
71 | +++ plugins/unityshell/src/FavoriteStoreGSettings.cpp 2012-01-26 14:42:28 +0000 | |||
72 | @@ -17,15 +17,14 @@ | |||
73 | 17 | * Authored by: Neil Jagdish Patel <neil.patel@canonical.com> | 17 | * Authored by: Neil Jagdish Patel <neil.patel@canonical.com> |
74 | 18 | */ | 18 | */ |
75 | 19 | 19 | ||
76 | 20 | #include "FavoriteStoreGSettings.h" | ||
77 | 21 | |||
78 | 22 | #include <algorithm> | 20 | #include <algorithm> |
79 | 23 | #include <iostream> | ||
80 | 24 | 21 | ||
81 | 25 | #include <gio/gdesktopappinfo.h> | 22 | #include <gio/gdesktopappinfo.h> |
82 | 26 | |||
83 | 27 | #include <NuxCore/Logger.h> | 23 | #include <NuxCore/Logger.h> |
84 | 28 | 24 | ||
85 | 25 | #include "FavoriteStoreGSettings.h" | ||
86 | 26 | #include "FavoriteStorePrivate.h" | ||
87 | 27 | |||
88 | 29 | #include "config.h" | 28 | #include "config.h" |
89 | 30 | 29 | ||
90 | 31 | /** | 30 | /** |
91 | @@ -103,7 +102,12 @@ | |||
92 | 103 | 102 | ||
93 | 104 | void FavoriteStoreGSettings::Refresh() | 103 | void FavoriteStoreGSettings::Refresh() |
94 | 105 | { | 104 | { |
96 | 106 | favorites_.clear(); | 105 | FillList(favorites_); |
97 | 106 | } | ||
98 | 107 | |||
99 | 108 | void FavoriteStoreGSettings::FillList(FavoriteList& list) | ||
100 | 109 | { | ||
101 | 110 | list.clear(); | ||
102 | 107 | 111 | ||
103 | 108 | gchar** favs = g_settings_get_strv(settings_, "favorites"); | 112 | gchar** favs = g_settings_get_strv(settings_, "favorites"); |
104 | 109 | 113 | ||
105 | @@ -114,7 +118,7 @@ | |||
106 | 114 | { | 118 | { |
107 | 115 | if (g_file_test(favs[i], G_FILE_TEST_EXISTS)) | 119 | if (g_file_test(favs[i], G_FILE_TEST_EXISTS)) |
108 | 116 | { | 120 | { |
110 | 117 | favorites_.push_back(favs[i]); | 121 | list.push_back(favs[i]); |
111 | 118 | } | 122 | } |
112 | 119 | else | 123 | else |
113 | 120 | { | 124 | { |
114 | @@ -131,12 +135,11 @@ | |||
115 | 131 | 135 | ||
116 | 132 | if (filename) | 136 | if (filename) |
117 | 133 | { | 137 | { |
119 | 134 | favorites_.push_back(filename); | 138 | list.push_back(filename); |
120 | 135 | } | 139 | } |
121 | 136 | else | 140 | else |
122 | 137 | { | 141 | { |
125 | 138 | LOG_WARNING(logger) << "Unable to load GDesktopAppInfo for '" | 142 | LOG_WARNING(logger) << "Unable to load GDesktopAppInfo for '" << favs[i] << "'"; |
124 | 139 | << favs[i] << "'"; | ||
126 | 140 | } | 143 | } |
127 | 141 | } | 144 | } |
128 | 142 | } | 145 | } |
129 | @@ -222,7 +225,7 @@ | |||
130 | 222 | Refresh(); | 225 | Refresh(); |
131 | 223 | } | 226 | } |
132 | 224 | 227 | ||
134 | 225 | void FavoriteStoreGSettings::SaveFavorites(FavoriteList const& favorites) | 228 | void FavoriteStoreGSettings::SaveFavorites(FavoriteList const& favorites, bool ignore) |
135 | 226 | { | 229 | { |
136 | 227 | const int size = favorites.size(); | 230 | const int size = favorites.size(); |
137 | 228 | const char* favs[size + 1]; | 231 | const char* favs[size + 1]; |
138 | @@ -244,7 +247,7 @@ | |||
139 | 244 | favs[index] = iter->c_str(); | 247 | favs[index] = iter->c_str(); |
140 | 245 | } | 248 | } |
141 | 246 | 249 | ||
143 | 247 | ignore_signals_ = true; | 250 | ignore_signals_ = ignore; |
144 | 248 | if (!g_settings_set_strv(settings_, "favorites", favs)) | 251 | if (!g_settings_set_strv(settings_, "favorites", favs)) |
145 | 249 | { | 252 | { |
146 | 250 | LOG_WARNING(logger) << "Saving favorites failed."; | 253 | LOG_WARNING(logger) << "Saving favorites failed."; |
147 | @@ -254,10 +257,34 @@ | |||
148 | 254 | 257 | ||
149 | 255 | void FavoriteStoreGSettings::Changed(std::string const& key) | 258 | void FavoriteStoreGSettings::Changed(std::string const& key) |
150 | 256 | { | 259 | { |
152 | 257 | if (ignore_signals_) | 260 | if (ignore_signals_ or key != "favorites") |
153 | 258 | return; | 261 | return; |
156 | 259 | 262 | ||
157 | 260 | LOG_DEBUG(logger) << "Changed: " << key; | 263 | FavoriteList old(favorites_); |
158 | 264 | FillList(favorites_); | ||
159 | 265 | |||
160 | 266 | auto newbies = impl::GetNewbies(old, favorites_); | ||
161 | 267 | |||
162 | 268 | for (auto it : favorites_) | ||
163 | 269 | { | ||
164 | 270 | if (std::find(newbies.begin(), newbies.end(), it) == newbies.end()) | ||
165 | 271 | continue; | ||
166 | 272 | |||
167 | 273 | std::string pos; | ||
168 | 274 | bool before; | ||
169 | 275 | |||
170 | 276 | impl::GetSignalAddedInfo(favorites_, newbies , it, pos, before); | ||
171 | 277 | favorite_added.emit(it, pos, before); | ||
172 | 278 | } | ||
173 | 279 | |||
174 | 280 | for (auto it : impl::GetRemoved(old, favorites_)) | ||
175 | 281 | { | ||
176 | 282 | favorite_removed.emit(it); | ||
177 | 283 | } | ||
178 | 284 | |||
179 | 285 | if (impl::NeedToBeReordered(old, favorites_)) | ||
180 | 286 | reordered.emit(); | ||
181 | 287 | |||
182 | 261 | } | 288 | } |
183 | 262 | 289 | ||
184 | 263 | namespace | 290 | namespace |
185 | 264 | 291 | ||
186 | === modified file 'plugins/unityshell/src/FavoriteStoreGSettings.h' | |||
187 | --- plugins/unityshell/src/FavoriteStoreGSettings.h 2011-07-21 14:59:25 +0000 | |||
188 | +++ plugins/unityshell/src/FavoriteStoreGSettings.h 2012-01-26 14:42:28 +0000 | |||
189 | @@ -42,6 +42,7 @@ | |||
190 | 42 | virtual void AddFavorite(std::string const& desktop_path, int position); | 42 | virtual void AddFavorite(std::string const& desktop_path, int position); |
191 | 43 | virtual void RemoveFavorite(std::string const& desktop_path); | 43 | virtual void RemoveFavorite(std::string const& desktop_path); |
192 | 44 | virtual void MoveFavorite(std::string const& desktop_path, int position); | 44 | virtual void MoveFavorite(std::string const& desktop_path, int position); |
193 | 45 | void SaveFavorites(FavoriteList const& favorites, bool ignore = true); | ||
194 | 45 | virtual void SetFavorites(FavoriteList const& desktop_paths); | 46 | virtual void SetFavorites(FavoriteList const& desktop_paths); |
195 | 46 | 47 | ||
196 | 47 | //Methods | 48 | //Methods |
197 | @@ -50,7 +51,7 @@ | |||
198 | 50 | private: | 51 | private: |
199 | 51 | void Init(); | 52 | void Init(); |
200 | 52 | void Refresh(); | 53 | void Refresh(); |
202 | 53 | void SaveFavorites(FavoriteList const& favorites); | 54 | void FillList(FavoriteList& list); |
203 | 54 | 55 | ||
204 | 55 | FavoriteList favorites_; | 56 | FavoriteList favorites_; |
205 | 56 | glib::Object<GSettings> settings_; | 57 | glib::Object<GSettings> settings_; |
206 | 57 | 58 | ||
207 | === added file 'plugins/unityshell/src/FavoriteStorePrivate.cpp' | |||
208 | --- plugins/unityshell/src/FavoriteStorePrivate.cpp 1970-01-01 00:00:00 +0000 | |||
209 | +++ plugins/unityshell/src/FavoriteStorePrivate.cpp 2012-01-26 14:42:28 +0000 | |||
210 | @@ -0,0 +1,130 @@ | |||
211 | 1 | // -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*- | ||
212 | 2 | /* | ||
213 | 3 | * Copyright (C) 2011 Canonical Ltd | ||
214 | 4 | * | ||
215 | 5 | * This program is free software: you can redistribute it and/or modify | ||
216 | 6 | * it under the terms of the GNU General Public License version 3 as | ||
217 | 7 | * published by the Free Software Foundation. | ||
218 | 8 | * | ||
219 | 9 | * This program is distributed in the hope that it will be useful, | ||
220 | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
221 | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
222 | 12 | * GNU General Public License for more details. | ||
223 | 13 | * | ||
224 | 14 | * You should have received a copy of the GNU General Public License | ||
225 | 15 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
226 | 16 | * | ||
227 | 17 | * Authored by: Andrea Azzaronea <azzaronea@gmail.com> | ||
228 | 18 | */ | ||
229 | 19 | |||
230 | 20 | #include <algorithm> | ||
231 | 21 | #include <boost/utility.hpp> | ||
232 | 22 | |||
233 | 23 | #include "FavoriteStorePrivate.h" | ||
234 | 24 | |||
235 | 25 | namespace unity | ||
236 | 26 | { | ||
237 | 27 | namespace internal | ||
238 | 28 | { | ||
239 | 29 | namespace impl | ||
240 | 30 | { | ||
241 | 31 | |||
242 | 32 | std::vector<std::string> GetNewbies(std::list<std::string> const& old, std::list<std::string> const& fresh) | ||
243 | 33 | { | ||
244 | 34 | auto sorted_old(old); | ||
245 | 35 | auto sorted_fresh(fresh); | ||
246 | 36 | |||
247 | 37 | sorted_old.sort(); | ||
248 | 38 | sorted_fresh.sort(); | ||
249 | 39 | |||
250 | 40 | std::vector<std::string> result; | ||
251 | 41 | std::set_difference(sorted_fresh.begin(), sorted_fresh.end(), sorted_old.begin(), sorted_old.end(), | ||
252 | 42 | std::inserter(result, result.end())); | ||
253 | 43 | |||
254 | 44 | return result; | ||
255 | 45 | } | ||
256 | 46 | |||
257 | 47 | void GetSignalAddedInfo(std::list<std::string> const& favs, std::vector<std::string> const& newbies, | ||
258 | 48 | std::string const& path, std::string& position, bool& before) | ||
259 | 49 | { | ||
260 | 50 | auto it = std::find(favs.begin(), favs.end(), path); | ||
261 | 51 | before = (it == favs.begin()); | ||
262 | 52 | position = ""; | ||
263 | 53 | |||
264 | 54 | if (before and favs.size() > 1) | ||
265 | 55 | { | ||
266 | 56 | while (it != favs.end() && std::find(newbies.begin(), newbies.end(), *it) != newbies.end()) | ||
267 | 57 | ++it; | ||
268 | 58 | |||
269 | 59 | if (it != favs.end()) | ||
270 | 60 | position = *it; | ||
271 | 61 | } | ||
272 | 62 | else if (!before) | ||
273 | 63 | { | ||
274 | 64 | position = *(boost::prior(it)); | ||
275 | 65 | } | ||
276 | 66 | |||
277 | 67 | } | ||
278 | 68 | |||
279 | 69 | std::vector<std::string> GetRemoved(std::list<std::string> const& old, std::list<std::string> const& fresh) | ||
280 | 70 | { | ||
281 | 71 | auto sorted_old(old); | ||
282 | 72 | auto sorted_fresh(fresh); | ||
283 | 73 | |||
284 | 74 | sorted_old.sort(); | ||
285 | 75 | sorted_fresh.sort(); | ||
286 | 76 | |||
287 | 77 | std::vector<std::string> result; | ||
288 | 78 | std::set_difference(sorted_old.begin(), sorted_old.end(), sorted_fresh.begin(), sorted_fresh.end(), | ||
289 | 79 | std::inserter(result, result.end())); | ||
290 | 80 | |||
291 | 81 | return result; | ||
292 | 82 | } | ||
293 | 83 | |||
294 | 84 | |||
295 | 85 | bool NeedToBeReordered(std::list<std::string> const& old, std::list<std::string> const& fresh) | ||
296 | 86 | { | ||
297 | 87 | auto sorted_old(old); | ||
298 | 88 | auto sorted_fresh(fresh); | ||
299 | 89 | |||
300 | 90 | sorted_old.sort(); | ||
301 | 91 | sorted_fresh.sort(); | ||
302 | 92 | |||
303 | 93 | std::vector<std::string> ignore_old, ignore_fresh; | ||
304 | 94 | |||
305 | 95 | std::set_difference(sorted_old.begin(), sorted_old.end(), sorted_fresh.begin(), sorted_fresh.end(), | ||
306 | 96 | std::inserter(ignore_old, ignore_old.end())); | ||
307 | 97 | std::set_difference(sorted_fresh.begin(), sorted_fresh.end(), sorted_old.begin(), sorted_old.end(), | ||
308 | 98 | std::inserter(ignore_fresh, ignore_fresh.end())); | ||
309 | 99 | |||
310 | 100 | auto it_old = old.begin(); | ||
311 | 101 | auto it_fresh = fresh.begin(); | ||
312 | 102 | |||
313 | 103 | while (it_old != old.end() && it_fresh != fresh.end()) | ||
314 | 104 | { | ||
315 | 105 | |||
316 | 106 | while (it_old != old.end() && std::find(ignore_old.begin(), ignore_old.end(), *it_old) != ignore_old.end()) | ||
317 | 107 | ++it_old; | ||
318 | 108 | |||
319 | 109 | while (it_fresh != fresh.end() && std::find(ignore_fresh.begin(), ignore_fresh.end(), *it_fresh) != ignore_fresh.end()) | ||
320 | 110 | ++it_fresh; | ||
321 | 111 | |||
322 | 112 | if (it_old == old.end() || it_fresh == fresh.end()) | ||
323 | 113 | break; | ||
324 | 114 | |||
325 | 115 | if (*it_old != *it_fresh) | ||
326 | 116 | { | ||
327 | 117 | return true; | ||
328 | 118 | } | ||
329 | 119 | |||
330 | 120 | ++it_old; | ||
331 | 121 | ++it_fresh; | ||
332 | 122 | } | ||
333 | 123 | |||
334 | 124 | return false; | ||
335 | 125 | } | ||
336 | 126 | |||
337 | 127 | |||
338 | 128 | } // namespace impl | ||
339 | 129 | } // namespace internal | ||
340 | 130 | } // namespace unity | ||
341 | 0 | 131 | ||
342 | === added file 'plugins/unityshell/src/FavoriteStorePrivate.h' | |||
343 | --- plugins/unityshell/src/FavoriteStorePrivate.h 1970-01-01 00:00:00 +0000 | |||
344 | +++ plugins/unityshell/src/FavoriteStorePrivate.h 2012-01-26 14:42:28 +0000 | |||
345 | @@ -0,0 +1,47 @@ | |||
346 | 1 | // -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*- | ||
347 | 2 | /* | ||
348 | 3 | * Copyright (C) 2011 Canonical Ltd | ||
349 | 4 | * | ||
350 | 5 | * This program is free software: you can redistribute it and/or modify | ||
351 | 6 | * it under the terms of the GNU General Public License version 3 as | ||
352 | 7 | * published by the Free Software Foundation. | ||
353 | 8 | * | ||
354 | 9 | * This program is distributed in the hope that it will be useful, | ||
355 | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
356 | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
357 | 12 | * GNU General Public License for more details. | ||
358 | 13 | * | ||
359 | 14 | * You should have received a copy of the GNU General Public License | ||
360 | 15 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
361 | 16 | * | ||
362 | 17 | * Authored by: Andrea Azzaronea <azzaronea@gmail.com> | ||
363 | 18 | */ | ||
364 | 19 | |||
365 | 20 | #ifndef UNITYSHELL_FAVORITESTOREPRIVATE_H | ||
366 | 21 | #define UNITYSHELL_FAVORITESTOREPRIVATE_H | ||
367 | 22 | |||
368 | 23 | #include <list> | ||
369 | 24 | #include <string> | ||
370 | 25 | |||
371 | 26 | namespace unity | ||
372 | 27 | { | ||
373 | 28 | namespace internal | ||
374 | 29 | { | ||
375 | 30 | namespace impl | ||
376 | 31 | { | ||
377 | 32 | |||
378 | 33 | std::vector<std::string> GetNewbies(std::list<std::string> const& old, std::list<std::string> const& fresh); | ||
379 | 34 | |||
380 | 35 | void GetSignalAddedInfo(std::list<std::string> const& favs, std::vector<std::string> const& newbies, | ||
381 | 36 | std::string const& path, std::string& position, bool& before); | ||
382 | 37 | |||
383 | 38 | std::vector<std::string> GetRemoved(std::list<std::string> const& old, std::list<std::string> const& fresh); | ||
384 | 39 | |||
385 | 40 | bool NeedToBeReordered(std::list<std::string> const& old, std::list<std::string> const& fresh); | ||
386 | 41 | |||
387 | 42 | } // namespace impl | ||
388 | 43 | } // namespace internal | ||
389 | 44 | } // namespace unity | ||
390 | 45 | |||
391 | 46 | #endif | ||
392 | 47 | |||
393 | 0 | 48 | ||
394 | === modified file 'plugins/unityshell/src/LauncherController.cpp' | |||
395 | --- plugins/unityshell/src/LauncherController.cpp 2012-01-23 13:07:40 +0000 | |||
396 | +++ plugins/unityshell/src/LauncherController.cpp 2012-01-26 14:42:28 +0000 | |||
397 | @@ -73,6 +73,11 @@ | |||
398 | 73 | 73 | ||
399 | 74 | void OnLauncherEntryRemoteAdded(LauncherEntryRemote* entry); | 74 | void OnLauncherEntryRemoteAdded(LauncherEntryRemote* entry); |
400 | 75 | void OnLauncherEntryRemoteRemoved(LauncherEntryRemote* entry); | 75 | void OnLauncherEntryRemoteRemoved(LauncherEntryRemote* entry); |
401 | 76 | |||
402 | 77 | void OnFavoriteStoreFavoriteAdded(std::string const& entry, std::string const& pos, bool before); | ||
403 | 78 | void OnFavoriteStoreFavoriteRemoved(std::string const& entry); | ||
404 | 79 | void OnFavoriteStoreReordered(); | ||
405 | 80 | |||
406 | 76 | 81 | ||
407 | 77 | void InsertExpoAction(); | 82 | void InsertExpoAction(); |
408 | 78 | void RemoveExpoAction(); | 83 | void RemoveExpoAction(); |
409 | @@ -179,6 +184,10 @@ | |||
410 | 179 | 184 | ||
411 | 180 | remote_model_.entry_added.connect(sigc::mem_fun(this, &Impl::OnLauncherEntryRemoteAdded)); | 185 | remote_model_.entry_added.connect(sigc::mem_fun(this, &Impl::OnLauncherEntryRemoteAdded)); |
412 | 181 | remote_model_.entry_removed.connect(sigc::mem_fun(this, &Impl::OnLauncherEntryRemoteRemoved)); | 186 | remote_model_.entry_removed.connect(sigc::mem_fun(this, &Impl::OnLauncherEntryRemoteRemoved)); |
413 | 187 | |||
414 | 188 | FavoriteStore::GetDefault().favorite_added.connect(sigc::mem_fun(this, &Impl::OnFavoriteStoreFavoriteAdded)); | ||
415 | 189 | FavoriteStore::GetDefault().favorite_removed.connect(sigc::mem_fun(this, &Impl::OnFavoriteStoreFavoriteRemoved)); | ||
416 | 190 | FavoriteStore::GetDefault().reordered.connect(sigc::mem_fun(this, &Impl::OnFavoriteStoreReordered)); | ||
417 | 182 | 191 | ||
418 | 183 | RegisterIcon(new BFBLauncherIcon(raw_launcher)); | 192 | RegisterIcon(new BFBLauncherIcon(raw_launcher)); |
419 | 184 | desktop_icon_ = new DesktopLauncherIcon(raw_launcher); | 193 | desktop_icon_ = new DesktopLauncherIcon(raw_launcher); |
420 | @@ -349,6 +358,82 @@ | |||
421 | 349 | } | 358 | } |
422 | 350 | } | 359 | } |
423 | 351 | 360 | ||
424 | 361 | void Controller::Impl::OnFavoriteStoreFavoriteAdded(std::string const& entry, std::string const& pos, bool before) | ||
425 | 362 | { | ||
426 | 363 | auto bamf_list = model_->GetSublist<BamfLauncherIcon>(); | ||
427 | 364 | LauncherIcon* other = (bamf_list.size() > 0) ? *(bamf_list.begin()) : nullptr; | ||
428 | 365 | |||
429 | 366 | if (!pos.empty()) | ||
430 | 367 | { | ||
431 | 368 | for (auto it : bamf_list) | ||
432 | 369 | { | ||
433 | 370 | if (it->GetQuirk(LauncherIcon::QUIRK_VISIBLE) && pos == it->DesktopFile()) | ||
434 | 371 | other = it; | ||
435 | 372 | } | ||
436 | 373 | } | ||
437 | 374 | |||
438 | 375 | for (auto it : bamf_list) | ||
439 | 376 | { | ||
440 | 377 | if (entry == it->DesktopFile()) | ||
441 | 378 | { | ||
442 | 379 | it->Stick(false); | ||
443 | 380 | if (!before) | ||
444 | 381 | model_->ReorderAfter(it, other); | ||
445 | 382 | else | ||
446 | 383 | model_->ReorderBefore(it, other, false); | ||
447 | 384 | return; | ||
448 | 385 | } | ||
449 | 386 | } | ||
450 | 387 | |||
451 | 388 | LauncherIcon* result = CreateFavorite(entry.c_str()); | ||
452 | 389 | if (result) | ||
453 | 390 | { | ||
454 | 391 | RegisterIcon(result); | ||
455 | 392 | if (!before) | ||
456 | 393 | model_->ReorderAfter(result, other); | ||
457 | 394 | else | ||
458 | 395 | model_->ReorderBefore(result, other, false); | ||
459 | 396 | } | ||
460 | 397 | } | ||
461 | 398 | |||
462 | 399 | void Controller::Impl::OnFavoriteStoreFavoriteRemoved(std::string const& entry) | ||
463 | 400 | { | ||
464 | 401 | for (auto it : model_->GetSublist<BamfLauncherIcon> ()) | ||
465 | 402 | { | ||
466 | 403 | if (it->DesktopFile() == entry) | ||
467 | 404 | { | ||
468 | 405 | OnLauncherRemoveRequest(it); | ||
469 | 406 | break; | ||
470 | 407 | } | ||
471 | 408 | } | ||
472 | 409 | } | ||
473 | 410 | |||
474 | 411 | void Controller::Impl::OnFavoriteStoreReordered() | ||
475 | 412 | { | ||
476 | 413 | FavoriteList const& favs = FavoriteStore::GetDefault().GetFavorites(); | ||
477 | 414 | auto bamf_list = model_->GetSublist<BamfLauncherIcon>(); | ||
478 | 415 | |||
479 | 416 | int i = 0; | ||
480 | 417 | for (auto it : favs) | ||
481 | 418 | { | ||
482 | 419 | auto icon = std::find_if(bamf_list.begin(), bamf_list.end(), | ||
483 | 420 | [&it](BamfLauncherIcon* x) { return (x->DesktopFile() == it); }); | ||
484 | 421 | |||
485 | 422 | if (icon != bamf_list.end()) | ||
486 | 423 | { | ||
487 | 424 | (*icon)->SetSortPriority(i++); | ||
488 | 425 | } | ||
489 | 426 | } | ||
490 | 427 | |||
491 | 428 | for (auto it : bamf_list) | ||
492 | 429 | { | ||
493 | 430 | if (!it->IsSticky()) | ||
494 | 431 | it->SetSortPriority(i++); | ||
495 | 432 | } | ||
496 | 433 | |||
497 | 434 | model_->Sort(); | ||
498 | 435 | } | ||
499 | 436 | |||
500 | 352 | void Controller::Impl::OnExpoActivated() | 437 | void Controller::Impl::OnExpoActivated() |
501 | 353 | { | 438 | { |
502 | 354 | WindowManager::Default()->InitiateExpo(); | 439 | WindowManager::Default()->InitiateExpo(); |
503 | 355 | 440 | ||
504 | === modified file 'plugins/unityshell/src/LauncherModel.cpp' | |||
505 | --- plugins/unityshell/src/LauncherModel.cpp 2012-01-25 03:02:57 +0000 | |||
506 | +++ plugins/unityshell/src/LauncherModel.cpp 2012-01-26 14:42:28 +0000 | |||
507 | @@ -188,6 +188,36 @@ | |||
508 | 188 | } | 188 | } |
509 | 189 | 189 | ||
510 | 190 | void | 190 | void |
511 | 191 | LauncherModel::ReorderAfter(LauncherIcon* icon, LauncherIcon* other) | ||
512 | 192 | { | ||
513 | 193 | if (icon == other) | ||
514 | 194 | return; | ||
515 | 195 | |||
516 | 196 | int i = 0; | ||
517 | 197 | for (LauncherModel::iterator it = begin(); it != end(); ++it) | ||
518 | 198 | { | ||
519 | 199 | if ((*it) == icon) | ||
520 | 200 | continue; | ||
521 | 201 | |||
522 | 202 | if ((*it) == other) | ||
523 | 203 | { | ||
524 | 204 | (*it)->SetSortPriority(i); | ||
525 | 205 | ++i; | ||
526 | 206 | |||
527 | 207 | icon->SetSortPriority(i); | ||
528 | 208 | ++i; | ||
529 | 209 | } | ||
530 | 210 | else | ||
531 | 211 | { | ||
532 | 212 | (*it)->SetSortPriority(i); | ||
533 | 213 | ++i; | ||
534 | 214 | } | ||
535 | 215 | } | ||
536 | 216 | |||
537 | 217 | Sort(); | ||
538 | 218 | } | ||
539 | 219 | |||
540 | 220 | void | ||
541 | 191 | LauncherModel::ReorderBefore(LauncherIcon* icon, LauncherIcon* other, bool save) | 221 | LauncherModel::ReorderBefore(LauncherIcon* icon, LauncherIcon* other, bool save) |
542 | 192 | { | 222 | { |
543 | 193 | if (icon == other) | 223 | if (icon == other) |
544 | 194 | 224 | ||
545 | === modified file 'plugins/unityshell/src/LauncherModel.h' | |||
546 | --- plugins/unityshell/src/LauncherModel.h 2011-10-05 23:55:59 +0000 | |||
547 | +++ plugins/unityshell/src/LauncherModel.h 2012-01-26 14:42:28 +0000 | |||
548 | @@ -51,6 +51,7 @@ | |||
549 | 51 | 51 | ||
550 | 52 | bool IconHasSister(LauncherIcon* icon); | 52 | bool IconHasSister(LauncherIcon* icon); |
551 | 53 | 53 | ||
552 | 54 | void ReorderAfter(LauncherIcon* icon, LauncherIcon* other); | ||
553 | 54 | void ReorderBefore(LauncherIcon* icon, LauncherIcon* other, bool save); | 55 | void ReorderBefore(LauncherIcon* icon, LauncherIcon* other, bool save); |
554 | 55 | 56 | ||
555 | 56 | void ReorderSmart(LauncherIcon* icon, LauncherIcon* other, bool save); | 57 | void ReorderSmart(LauncherIcon* icon, LauncherIcon* other, bool save); |
556 | 57 | 58 | ||
557 | === modified file 'tests/CMakeLists.txt' | |||
558 | --- tests/CMakeLists.txt 2012-01-26 08:25:52 +0000 | |||
559 | +++ tests/CMakeLists.txt 2012-01-26 14:42:28 +0000 | |||
560 | @@ -119,6 +119,7 @@ | |||
561 | 119 | test_glib_variant.cpp | 119 | test_glib_variant.cpp |
562 | 120 | ${CMAKE_CURRENT_BINARY_DIR}/test_glib_signals_utils_marshal.cpp | 120 | ${CMAKE_CURRENT_BINARY_DIR}/test_glib_signals_utils_marshal.cpp |
563 | 121 | test_favorite_store_gsettings.cpp | 121 | test_favorite_store_gsettings.cpp |
564 | 122 | test_favorite_store_private.cpp | ||
565 | 122 | test_home_lens.cpp | 123 | test_home_lens.cpp |
566 | 123 | test_shortcut_model.cpp | 124 | test_shortcut_model.cpp |
567 | 124 | test_shortcut_private.cpp | 125 | test_shortcut_private.cpp |
568 | @@ -137,6 +138,8 @@ | |||
569 | 137 | ${UNITY_SRC}/FavoriteStore.h | 138 | ${UNITY_SRC}/FavoriteStore.h |
570 | 138 | ${UNITY_SRC}/FavoriteStoreGSettings.cpp | 139 | ${UNITY_SRC}/FavoriteStoreGSettings.cpp |
571 | 139 | ${UNITY_SRC}/FavoriteStoreGSettings.h | 140 | ${UNITY_SRC}/FavoriteStoreGSettings.h |
572 | 141 | ${UNITY_SRC}/FavoriteStorePrivate.cpp | ||
573 | 142 | ${UNITY_SRC}/FavoriteStorePrivate.h | ||
574 | 140 | ${UNITY_SRC}/MockLauncherIcon.h | 143 | ${UNITY_SRC}/MockLauncherIcon.h |
575 | 141 | ${UNITY_SRC}/MockShortcutHint.h | 144 | ${UNITY_SRC}/MockShortcutHint.h |
576 | 142 | ${UNITY_SRC}/ShortcutModel.cpp | 145 | ${UNITY_SRC}/ShortcutModel.cpp |
577 | 143 | 146 | ||
578 | === modified file 'tests/test_favorite_store_gsettings.cpp' | |||
579 | --- tests/test_favorite_store_gsettings.cpp 2011-11-28 16:02:32 +0000 | |||
580 | +++ tests/test_favorite_store_gsettings.cpp 2012-01-26 14:42:28 +0000 | |||
581 | @@ -42,8 +42,8 @@ | |||
582 | 42 | const gchar* SCHEMA_DIRECTORY = BUILDDIR"/settings"; | 42 | const gchar* SCHEMA_DIRECTORY = BUILDDIR"/settings"; |
583 | 43 | const gchar* BASE_STORE_FILE = BUILDDIR"/settings/test-favorite-store-gsettings.store"; | 43 | const gchar* BASE_STORE_FILE = BUILDDIR"/settings/test-favorite-store-gsettings.store"; |
584 | 44 | const gchar* BASE_STORE_CONTENTS = "[desktop/unity/launcher]\n" \ | 44 | const gchar* BASE_STORE_CONTENTS = "[desktop/unity/launcher]\n" \ |
587 | 45 | "favorites=['%s', '%s', '%s']"; | 45 | "favorites=['%s', '%s', '%s']"; |
588 | 46 | 46 | ||
589 | 47 | const char* base_store_favs[] = { BUILDDIR"/tests/data/ubuntuone-installer.desktop", | 47 | const char* base_store_favs[] = { BUILDDIR"/tests/data/ubuntuone-installer.desktop", |
590 | 48 | BUILDDIR"/tests/data/ubuntu-software-center.desktop", | 48 | BUILDDIR"/tests/data/ubuntu-software-center.desktop", |
591 | 49 | BUILDDIR"/tests/data/update-manager.desktop", | 49 | BUILDDIR"/tests/data/update-manager.desktop", |
592 | @@ -222,5 +222,271 @@ | |||
593 | 222 | EXPECT_EQ(at(favs, 2), base_store_favs[2]); | 222 | EXPECT_EQ(at(favs, 2), base_store_favs[2]); |
594 | 223 | } | 223 | } |
595 | 224 | 224 | ||
596 | 225 | TEST_F(TestFavoriteStoreGSettings, TestFavoriteAddedSignalFirst) | ||
597 | 226 | { | ||
598 | 227 | internal::FavoriteStoreGSettings settings(backend.RawPtr()); | ||
599 | 228 | bool signal_received = false; | ||
600 | 229 | std::string position; | ||
601 | 230 | bool before = false; | ||
602 | 231 | |||
603 | 232 | settings.favorite_added.connect([&](std::string const& path, std::string const& pos, bool bef) | ||
604 | 233 | { | ||
605 | 234 | signal_received = true; | ||
606 | 235 | position = pos; | ||
607 | 236 | before = bef; | ||
608 | 237 | }); | ||
609 | 238 | |||
610 | 239 | FavoriteList favs; | ||
611 | 240 | favs.push_back(other_desktop); | ||
612 | 241 | favs.push_back(base_store_favs[0]); | ||
613 | 242 | favs.push_back(base_store_favs[1]); | ||
614 | 243 | favs.push_back(base_store_favs[2]); | ||
615 | 244 | settings.SaveFavorites(favs, false); | ||
616 | 245 | |||
617 | 246 | sleep(1); | ||
618 | 247 | |||
619 | 248 | ASSERT_TRUE(signal_received); | ||
620 | 249 | EXPECT_EQ(position, base_store_favs[0]); | ||
621 | 250 | EXPECT_TRUE(before); | ||
622 | 251 | } | ||
623 | 252 | |||
624 | 253 | TEST_F(TestFavoriteStoreGSettings, TestFavoriteAddedSignalMiddle) | ||
625 | 254 | { | ||
626 | 255 | internal::FavoriteStoreGSettings settings(backend.RawPtr()); | ||
627 | 256 | bool signal_received = false; | ||
628 | 257 | std::string position; | ||
629 | 258 | bool before = true; | ||
630 | 259 | |||
631 | 260 | settings.favorite_added.connect([&](std::string const& path, std::string const& pos, bool bef) | ||
632 | 261 | { | ||
633 | 262 | signal_received = true; | ||
634 | 263 | position = pos; | ||
635 | 264 | before = bef; | ||
636 | 265 | }); | ||
637 | 266 | |||
638 | 267 | FavoriteList favs; | ||
639 | 268 | favs.push_back(base_store_favs[0]); | ||
640 | 269 | favs.push_back(base_store_favs[1]); | ||
641 | 270 | favs.push_back(other_desktop); | ||
642 | 271 | favs.push_back(base_store_favs[2]); | ||
643 | 272 | settings.SaveFavorites(favs, false); | ||
644 | 273 | |||
645 | 274 | sleep(1); | ||
646 | 275 | |||
647 | 276 | ASSERT_TRUE(signal_received); | ||
648 | 277 | EXPECT_EQ(position, base_store_favs[1]); | ||
649 | 278 | EXPECT_FALSE(before); | ||
650 | 279 | } | ||
651 | 280 | |||
652 | 281 | TEST_F(TestFavoriteStoreGSettings, TestFavoriteAddedSignalEnd) | ||
653 | 282 | { | ||
654 | 283 | internal::FavoriteStoreGSettings settings(backend.RawPtr()); | ||
655 | 284 | bool signal_received = false; | ||
656 | 285 | std::string position; | ||
657 | 286 | bool before = true; | ||
658 | 287 | |||
659 | 288 | settings.favorite_added.connect([&](std::string const& path, std::string const& pos, bool bef) | ||
660 | 289 | { | ||
661 | 290 | signal_received = true; | ||
662 | 291 | position = pos; | ||
663 | 292 | before = bef; | ||
664 | 293 | }); | ||
665 | 294 | |||
666 | 295 | FavoriteList favs; | ||
667 | 296 | favs.push_back(base_store_favs[0]); | ||
668 | 297 | favs.push_back(base_store_favs[1]); | ||
669 | 298 | favs.push_back(base_store_favs[2]); | ||
670 | 299 | favs.push_back(other_desktop); | ||
671 | 300 | settings.SaveFavorites(favs, false); | ||
672 | 301 | |||
673 | 302 | sleep(1); | ||
674 | 303 | |||
675 | 304 | ASSERT_TRUE(signal_received); | ||
676 | 305 | EXPECT_EQ(position, base_store_favs[2]); | ||
677 | 306 | EXPECT_FALSE(before); | ||
678 | 307 | } | ||
679 | 308 | |||
680 | 309 | TEST_F(TestFavoriteStoreGSettings, TestFavoriteAddedSignalEmpty) | ||
681 | 310 | { | ||
682 | 311 | internal::FavoriteStoreGSettings settings(backend.RawPtr()); | ||
683 | 312 | bool signal_received = false; | ||
684 | 313 | std::string position; | ||
685 | 314 | bool before = false; | ||
686 | 315 | |||
687 | 316 | settings.favorite_added.connect([&](std::string const& path, std::string const& pos, bool bef) | ||
688 | 317 | { | ||
689 | 318 | signal_received = true; | ||
690 | 319 | position = pos; | ||
691 | 320 | before = bef; | ||
692 | 321 | }); | ||
693 | 322 | |||
694 | 323 | FavoriteList favs; | ||
695 | 324 | favs.push_back(other_desktop); | ||
696 | 325 | settings.SaveFavorites(favs, false); | ||
697 | 326 | |||
698 | 327 | sleep(1); | ||
699 | 328 | |||
700 | 329 | ASSERT_TRUE(signal_received); | ||
701 | 330 | EXPECT_EQ(position, ""); | ||
702 | 331 | EXPECT_TRUE(before); | ||
703 | 332 | } | ||
704 | 333 | |||
705 | 334 | TEST_F(TestFavoriteStoreGSettings, TestFavoriteRemoved) | ||
706 | 335 | { | ||
707 | 336 | internal::FavoriteStoreGSettings settings(backend.RawPtr()); | ||
708 | 337 | bool signal_received = false; | ||
709 | 338 | std::string path_removed; | ||
710 | 339 | |||
711 | 340 | settings.favorite_removed.connect([&](std::string const& path) | ||
712 | 341 | { | ||
713 | 342 | signal_received = true; | ||
714 | 343 | path_removed = path; | ||
715 | 344 | }); | ||
716 | 345 | |||
717 | 346 | FavoriteList favs; | ||
718 | 347 | favs.push_back(base_store_favs[0]); | ||
719 | 348 | favs.push_back(base_store_favs[2]); | ||
720 | 349 | settings.SaveFavorites(favs, false); | ||
721 | 350 | |||
722 | 351 | sleep(1); | ||
723 | 352 | |||
724 | 353 | ASSERT_TRUE(signal_received); | ||
725 | 354 | EXPECT_EQ(path_removed, base_store_favs[1]); | ||
726 | 355 | } | ||
727 | 356 | |||
728 | 357 | TEST_F(TestFavoriteStoreGSettings, TestFavoriteReordered) | ||
729 | 358 | { | ||
730 | 359 | internal::FavoriteStoreGSettings settings(backend.RawPtr()); | ||
731 | 360 | bool signal_received = false; | ||
732 | 361 | |||
733 | 362 | settings.reordered.connect([&]() | ||
734 | 363 | { | ||
735 | 364 | signal_received = true; | ||
736 | 365 | }); | ||
737 | 366 | |||
738 | 367 | FavoriteList favs; | ||
739 | 368 | favs.push_back(base_store_favs[0]); | ||
740 | 369 | favs.push_back(base_store_favs[2]); | ||
741 | 370 | favs.push_back(base_store_favs[1]); | ||
742 | 371 | settings.SaveFavorites(favs, false); | ||
743 | 372 | |||
744 | 373 | sleep(1); | ||
745 | 374 | |||
746 | 375 | ASSERT_TRUE(signal_received); | ||
747 | 376 | |||
748 | 377 | signal_received = false; | ||
749 | 378 | favs.push_back(base_store_favs[0]); | ||
750 | 379 | favs.push_back(base_store_favs[2]); | ||
751 | 380 | favs.push_back(base_store_favs[1]); | ||
752 | 381 | settings.SaveFavorites(favs, false); | ||
753 | 382 | |||
754 | 383 | sleep(1); | ||
755 | 384 | |||
756 | 385 | ASSERT_FALSE(signal_received); | ||
757 | 386 | } | ||
758 | 387 | |||
759 | 388 | TEST_F(TestFavoriteStoreGSettings, TestFavoriteSignalsMixed1) | ||
760 | 389 | { | ||
761 | 390 | internal::FavoriteStoreGSettings settings(backend.RawPtr()); | ||
762 | 391 | bool added_received = false; | ||
763 | 392 | bool removed_received = false; | ||
764 | 393 | bool reordered_received = false; | ||
765 | 394 | |||
766 | 395 | settings.favorite_added.connect([&](std::string const& path, std::string const& pos, bool bef) | ||
767 | 396 | { | ||
768 | 397 | added_received = true; | ||
769 | 398 | }); | ||
770 | 399 | |||
771 | 400 | settings.favorite_removed.connect([&](std::string const& path) | ||
772 | 401 | { | ||
773 | 402 | removed_received = true; | ||
774 | 403 | }); | ||
775 | 404 | |||
776 | 405 | settings.reordered.connect([&]() | ||
777 | 406 | { | ||
778 | 407 | reordered_received = true; | ||
779 | 408 | }); | ||
780 | 409 | |||
781 | 410 | FavoriteList favs; | ||
782 | 411 | favs.push_back(base_store_favs[0]); | ||
783 | 412 | favs.push_back(base_store_favs[1]); | ||
784 | 413 | favs.push_back(other_desktop); | ||
785 | 414 | settings.SaveFavorites(favs, false); | ||
786 | 415 | |||
787 | 416 | sleep(1); | ||
788 | 417 | |||
789 | 418 | EXPECT_TRUE(added_received); | ||
790 | 419 | EXPECT_TRUE(removed_received); | ||
791 | 420 | EXPECT_FALSE(reordered_received); | ||
792 | 421 | } | ||
793 | 422 | |||
794 | 423 | TEST_F(TestFavoriteStoreGSettings, TestFavoriteSignalsMixed2) | ||
795 | 424 | { | ||
796 | 425 | internal::FavoriteStoreGSettings settings(backend.RawPtr()); | ||
797 | 426 | bool added_received = false; | ||
798 | 427 | bool removed_received = false; | ||
799 | 428 | bool reordered_received = false; | ||
800 | 429 | |||
801 | 430 | settings.favorite_added.connect([&](std::string const& path, std::string const& pos, bool bef) | ||
802 | 431 | { | ||
803 | 432 | added_received = true; | ||
804 | 433 | }); | ||
805 | 434 | |||
806 | 435 | settings.favorite_removed.connect([&](std::string const& path) | ||
807 | 436 | { | ||
808 | 437 | removed_received = true; | ||
809 | 438 | }); | ||
810 | 439 | |||
811 | 440 | settings.reordered.connect([&]() | ||
812 | 441 | { | ||
813 | 442 | reordered_received = true; | ||
814 | 443 | }); | ||
815 | 444 | |||
816 | 445 | FavoriteList favs; | ||
817 | 446 | favs.push_back(base_store_favs[1]); | ||
818 | 447 | favs.push_back(other_desktop); | ||
819 | 448 | favs.push_back(base_store_favs[0]); | ||
820 | 449 | settings.SaveFavorites(favs, false); | ||
821 | 450 | |||
822 | 451 | sleep(1); | ||
823 | 452 | |||
824 | 453 | EXPECT_TRUE(added_received); | ||
825 | 454 | EXPECT_TRUE(removed_received); | ||
826 | 455 | EXPECT_TRUE(reordered_received); | ||
827 | 456 | } | ||
828 | 457 | |||
829 | 458 | TEST_F(TestFavoriteStoreGSettings, TestFavoriteSignalsMixed3) | ||
830 | 459 | { | ||
831 | 460 | internal::FavoriteStoreGSettings settings(backend.RawPtr()); | ||
832 | 461 | bool added_received = false; | ||
833 | 462 | bool removed_received = false; | ||
834 | 463 | bool reordered_received = false; | ||
835 | 464 | |||
836 | 465 | settings.favorite_added.connect([&](std::string const& path, std::string const& pos, bool bef) | ||
837 | 466 | { | ||
838 | 467 | added_received = true; | ||
839 | 468 | }); | ||
840 | 469 | |||
841 | 470 | settings.favorite_removed.connect([&](std::string const& path) | ||
842 | 471 | { | ||
843 | 472 | removed_received = true; | ||
844 | 473 | }); | ||
845 | 474 | |||
846 | 475 | settings.reordered.connect([&]() | ||
847 | 476 | { | ||
848 | 477 | reordered_received = true; | ||
849 | 478 | }); | ||
850 | 479 | |||
851 | 480 | FavoriteList favs; | ||
852 | 481 | favs.push_back(base_store_favs[1]); | ||
853 | 482 | favs.push_back(base_store_favs[0]); | ||
854 | 483 | settings.SaveFavorites(favs, false); | ||
855 | 484 | |||
856 | 485 | sleep(1); | ||
857 | 486 | |||
858 | 487 | EXPECT_FALSE(added_received); | ||
859 | 488 | EXPECT_TRUE(removed_received); | ||
860 | 489 | EXPECT_TRUE(reordered_received); | ||
861 | 490 | } | ||
862 | 225 | 491 | ||
863 | 226 | } // anonymous namespace | 492 | } // anonymous namespace |
864 | 227 | 493 | ||
865 | === added file 'tests/test_favorite_store_private.cpp' | |||
866 | --- tests/test_favorite_store_private.cpp 1970-01-01 00:00:00 +0000 | |||
867 | +++ tests/test_favorite_store_private.cpp 2012-01-26 14:42:28 +0000 | |||
868 | @@ -0,0 +1,417 @@ | |||
869 | 1 | /* | ||
870 | 2 | * Copyright 2011 Canonical Ltd. | ||
871 | 3 | * | ||
872 | 4 | * This program is free software: you can redistribute it and/or modify it | ||
873 | 5 | * under the terms of the GNU General Public License version 3, as published | ||
874 | 6 | * by the Free Software Foundation. | ||
875 | 7 | * | ||
876 | 8 | * This program is distributed in the hope that it will be useful, but | ||
877 | 9 | * WITHOUT ANY WARRANTY; without even the implied warranties of | ||
878 | 10 | * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR | ||
879 | 11 | * PURPOSE. See the GNU General Public License for more details. | ||
880 | 12 | * | ||
881 | 13 | * You should have received a copy of the GNU General Public License | ||
882 | 14 | * version 3 along with this program. If not, see | ||
883 | 15 | * <http://www.gnu.org/licenses/> | ||
884 | 16 | * | ||
885 | 17 | * Authored by: Andrea Azzarone <azzaronea@gmail.com> | ||
886 | 18 | * | ||
887 | 19 | */ | ||
888 | 20 | |||
889 | 21 | #include <gtest/gtest.h> | ||
890 | 22 | |||
891 | 23 | #include "FavoriteStorePrivate.h" | ||
892 | 24 | |||
893 | 25 | using namespace unity; | ||
894 | 26 | |||
895 | 27 | TEST(TestFavoriteStorePrivate, TestGetNewbies) | ||
896 | 28 | { | ||
897 | 29 | std::list<std::string> old; | ||
898 | 30 | std::list<std::string> fresh; | ||
899 | 31 | std::vector<std::string> result; | ||
900 | 32 | |||
901 | 33 | old.push_back("a"); | ||
902 | 34 | old.push_back("b"); | ||
903 | 35 | old.push_back("c"); | ||
904 | 36 | old.push_back("d"); | ||
905 | 37 | |||
906 | 38 | // No change. | ||
907 | 39 | fresh.push_back("a"); | ||
908 | 40 | fresh.push_back("b"); | ||
909 | 41 | fresh.push_back("c"); | ||
910 | 42 | fresh.push_back("d"); | ||
911 | 43 | |||
912 | 44 | result = internal::impl::GetNewbies(old, fresh); | ||
913 | 45 | |||
914 | 46 | EXPECT_TRUE(result.empty()); | ||
915 | 47 | |||
916 | 48 | // Permutation. | ||
917 | 49 | fresh.clear(); | ||
918 | 50 | result.clear(); | ||
919 | 51 | fresh.push_back("a"); | ||
920 | 52 | fresh.push_back("c"); | ||
921 | 53 | fresh.push_back("b"); | ||
922 | 54 | fresh.push_back("d"); | ||
923 | 55 | |||
924 | 56 | result = internal::impl::GetNewbies(old, fresh); | ||
925 | 57 | |||
926 | 58 | EXPECT_TRUE(result.empty()); | ||
927 | 59 | |||
928 | 60 | // a b c d -> a c b | ||
929 | 61 | fresh.clear(); | ||
930 | 62 | result.clear(); | ||
931 | 63 | fresh.push_back("a"); | ||
932 | 64 | fresh.push_back("c"); | ||
933 | 65 | fresh.push_back("b"); | ||
934 | 66 | |||
935 | 67 | result = internal::impl::GetNewbies(old, fresh); | ||
936 | 68 | |||
937 | 69 | EXPECT_TRUE(result.empty()); | ||
938 | 70 | |||
939 | 71 | // a b c d -> a b c d e f | ||
940 | 72 | fresh.clear(); | ||
941 | 73 | result.clear(); | ||
942 | 74 | fresh.push_back("a"); | ||
943 | 75 | fresh.push_back("b"); | ||
944 | 76 | fresh.push_back("c"); | ||
945 | 77 | fresh.push_back("d"); | ||
946 | 78 | fresh.push_back("e"); | ||
947 | 79 | fresh.push_back("f"); | ||
948 | 80 | |||
949 | 81 | result = internal::impl::GetNewbies(old, fresh); | ||
950 | 82 | |||
951 | 83 | EXPECT_EQ(result.size(), 2); | ||
952 | 84 | EXPECT_EQ(result[0], "e"); | ||
953 | 85 | EXPECT_EQ(result[1], "f"); | ||
954 | 86 | |||
955 | 87 | // a b c d -> a b c e f | ||
956 | 88 | fresh.clear(); | ||
957 | 89 | result.clear(); | ||
958 | 90 | fresh.push_back("a"); | ||
959 | 91 | fresh.push_back("b"); | ||
960 | 92 | fresh.push_back("c"); | ||
961 | 93 | fresh.push_back("e"); | ||
962 | 94 | fresh.push_back("f"); | ||
963 | 95 | |||
964 | 96 | result = internal::impl::GetNewbies(old, fresh); | ||
965 | 97 | |||
966 | 98 | EXPECT_EQ(result.size(), 2); | ||
967 | 99 | EXPECT_EQ(result[0], "e"); | ||
968 | 100 | EXPECT_EQ(result[1], "f"); | ||
969 | 101 | } | ||
970 | 102 | |||
971 | 103 | TEST(TestFavoriteStorePrivate, TestGetSignalAddedInfo) | ||
972 | 104 | { | ||
973 | 105 | std::list<std::string> favs; | ||
974 | 106 | std::vector<std::string> newbies; | ||
975 | 107 | std::string position; | ||
976 | 108 | bool before; | ||
977 | 109 | |||
978 | 110 | favs.push_back("a"); | ||
979 | 111 | favs.push_back("b"); | ||
980 | 112 | favs.push_back("c"); | ||
981 | 113 | favs.push_back("d"); | ||
982 | 114 | favs.push_back("e"); | ||
983 | 115 | |||
984 | 116 | // b c d e -> a b c d e | ||
985 | 117 | newbies.push_back("a"); | ||
986 | 118 | internal::impl::GetSignalAddedInfo(favs, newbies, "a", position, before); | ||
987 | 119 | EXPECT_TRUE(before); | ||
988 | 120 | EXPECT_EQ(position, "b"); | ||
989 | 121 | |||
990 | 122 | // a c d e -> a b c d e | ||
991 | 123 | newbies.clear(); | ||
992 | 124 | newbies.push_back("b"); | ||
993 | 125 | internal::impl::GetSignalAddedInfo(favs, newbies, "b", position, before); | ||
994 | 126 | EXPECT_FALSE(before); | ||
995 | 127 | EXPECT_EQ(position, "a"); | ||
996 | 128 | |||
997 | 129 | // a b d e -> a b c d e | ||
998 | 130 | newbies.clear(); | ||
999 | 131 | newbies.push_back("c"); | ||
1000 | 132 | internal::impl::GetSignalAddedInfo(favs, newbies, "c", position, before); | ||
1001 | 133 | EXPECT_FALSE(before); | ||
1002 | 134 | EXPECT_EQ(position, "b"); | ||
1003 | 135 | |||
1004 | 136 | // a b c e -> a b c d e | ||
1005 | 137 | newbies.clear(); | ||
1006 | 138 | newbies.push_back("d"); | ||
1007 | 139 | internal::impl::GetSignalAddedInfo(favs, newbies, "d", position, before); | ||
1008 | 140 | EXPECT_FALSE(before); | ||
1009 | 141 | EXPECT_EQ(position, "c"); | ||
1010 | 142 | |||
1011 | 143 | // a b c d -> a b c d e | ||
1012 | 144 | newbies.clear(); | ||
1013 | 145 | newbies.push_back("e"); | ||
1014 | 146 | internal::impl::GetSignalAddedInfo(favs, newbies, "e", position, before); | ||
1015 | 147 | EXPECT_FALSE(before); | ||
1016 | 148 | EXPECT_EQ(position, "d"); | ||
1017 | 149 | |||
1018 | 150 | // -> b a c | ||
1019 | 151 | favs.clear(); | ||
1020 | 152 | favs.push_back("b"); | ||
1021 | 153 | favs.push_back("a"); | ||
1022 | 154 | favs.push_back("c"); | ||
1023 | 155 | newbies.clear(); | ||
1024 | 156 | newbies.push_back("a"); | ||
1025 | 157 | newbies.push_back("b"); | ||
1026 | 158 | newbies.push_back("c"); | ||
1027 | 159 | |||
1028 | 160 | internal::impl::GetSignalAddedInfo(favs, newbies, "b", position, before); | ||
1029 | 161 | EXPECT_TRUE(before); | ||
1030 | 162 | EXPECT_EQ(position, ""); | ||
1031 | 163 | |||
1032 | 164 | internal::impl::GetSignalAddedInfo(favs, newbies, "a", position, before); | ||
1033 | 165 | EXPECT_FALSE(before); | ||
1034 | 166 | EXPECT_EQ(position, "b"); | ||
1035 | 167 | |||
1036 | 168 | internal::impl::GetSignalAddedInfo(favs, newbies, "c", position, before); | ||
1037 | 169 | EXPECT_FALSE(before); | ||
1038 | 170 | EXPECT_EQ(position, "a"); | ||
1039 | 171 | } | ||
1040 | 172 | |||
1041 | 173 | |||
1042 | 174 | TEST(TestFavoriteStorePrivate, TestGetRemoved) | ||
1043 | 175 | { | ||
1044 | 176 | std::list<std::string> old; | ||
1045 | 177 | std::list<std::string> fresh; | ||
1046 | 178 | std::vector<std::string> result; | ||
1047 | 179 | |||
1048 | 180 | old.push_back("a"); | ||
1049 | 181 | old.push_back("b"); | ||
1050 | 182 | old.push_back("c"); | ||
1051 | 183 | old.push_back("d"); | ||
1052 | 184 | |||
1053 | 185 | // No change. | ||
1054 | 186 | fresh.push_back("a"); | ||
1055 | 187 | fresh.push_back("b"); | ||
1056 | 188 | fresh.push_back("c"); | ||
1057 | 189 | fresh.push_back("d"); | ||
1058 | 190 | |||
1059 | 191 | result = internal::impl::GetRemoved(old, fresh); | ||
1060 | 192 | |||
1061 | 193 | EXPECT_TRUE(result.empty()); | ||
1062 | 194 | |||
1063 | 195 | // Permutation. | ||
1064 | 196 | fresh.clear(); | ||
1065 | 197 | result.clear(); | ||
1066 | 198 | fresh.push_back("a"); | ||
1067 | 199 | fresh.push_back("c"); | ||
1068 | 200 | fresh.push_back("b"); | ||
1069 | 201 | fresh.push_back("d"); | ||
1070 | 202 | |||
1071 | 203 | result = internal::impl::GetRemoved(old, fresh); | ||
1072 | 204 | |||
1073 | 205 | EXPECT_TRUE(result.empty()); | ||
1074 | 206 | |||
1075 | 207 | // a b c d -> b c | ||
1076 | 208 | fresh.clear(); | ||
1077 | 209 | result.clear(); | ||
1078 | 210 | fresh.push_back("b"); | ||
1079 | 211 | fresh.push_back("c"); | ||
1080 | 212 | |||
1081 | 213 | result = internal::impl::GetRemoved(old, fresh); | ||
1082 | 214 | |||
1083 | 215 | EXPECT_EQ(result.size(), 2); | ||
1084 | 216 | EXPECT_EQ(result[0], "a"); | ||
1085 | 217 | EXPECT_EQ(result[1], "d"); | ||
1086 | 218 | |||
1087 | 219 | // a b c d -> a e f d | ||
1088 | 220 | fresh.clear(); | ||
1089 | 221 | result.clear(); | ||
1090 | 222 | fresh.push_back("a"); | ||
1091 | 223 | fresh.push_back("e"); | ||
1092 | 224 | fresh.push_back("f"); | ||
1093 | 225 | fresh.push_back("d"); | ||
1094 | 226 | |||
1095 | 227 | |||
1096 | 228 | result = internal::impl::GetRemoved(old, fresh); | ||
1097 | 229 | |||
1098 | 230 | EXPECT_EQ(result.size(), 2); | ||
1099 | 231 | EXPECT_EQ(result[0], "b"); | ||
1100 | 232 | EXPECT_EQ(result[1], "c"); | ||
1101 | 233 | } | ||
1102 | 234 | |||
1103 | 235 | |||
1104 | 236 | TEST(TestFavoriteStorePrivate, TestNeedToBeReorderedBasic) | ||
1105 | 237 | { | ||
1106 | 238 | std::list<std::string> old; | ||
1107 | 239 | std::list<std::string> fresh; | ||
1108 | 240 | |||
1109 | 241 | old.push_back("a"); | ||
1110 | 242 | old.push_back("b"); | ||
1111 | 243 | old.push_back("c"); | ||
1112 | 244 | old.push_back("d"); | ||
1113 | 245 | |||
1114 | 246 | // No change. | ||
1115 | 247 | fresh.push_back("a"); | ||
1116 | 248 | fresh.push_back("b"); | ||
1117 | 249 | fresh.push_back("c"); | ||
1118 | 250 | fresh.push_back("d"); | ||
1119 | 251 | |||
1120 | 252 | EXPECT_FALSE(internal::impl::NeedToBeReordered(old, fresh)); | ||
1121 | 253 | |||
1122 | 254 | // Permutation. | ||
1123 | 255 | fresh.clear(); | ||
1124 | 256 | fresh.push_back("a"); | ||
1125 | 257 | fresh.push_back("c"); | ||
1126 | 258 | fresh.push_back("b"); | ||
1127 | 259 | fresh.push_back("d"); | ||
1128 | 260 | |||
1129 | 261 | EXPECT_TRUE(internal::impl::NeedToBeReordered(old, fresh)); | ||
1130 | 262 | |||
1131 | 263 | // Empty. | ||
1132 | 264 | fresh.clear(); | ||
1133 | 265 | |||
1134 | 266 | EXPECT_FALSE(internal::impl::NeedToBeReordered(old, fresh)); | ||
1135 | 267 | } | ||
1136 | 268 | |||
1137 | 269 | TEST(TestFavoriteStorePrivate, TestNeedToBeReorderedLess) | ||
1138 | 270 | { | ||
1139 | 271 | std::list<std::string> old; | ||
1140 | 272 | std::list<std::string> fresh; | ||
1141 | 273 | |||
1142 | 274 | old.push_back("a"); | ||
1143 | 275 | old.push_back("b"); | ||
1144 | 276 | old.push_back("c"); | ||
1145 | 277 | old.push_back("d"); | ||
1146 | 278 | |||
1147 | 279 | // a b c d -> a b c | ||
1148 | 280 | fresh.clear(); | ||
1149 | 281 | fresh.push_back("a"); | ||
1150 | 282 | fresh.push_back("b"); | ||
1151 | 283 | fresh.push_back("c"); | ||
1152 | 284 | |||
1153 | 285 | EXPECT_FALSE(internal::impl::NeedToBeReordered(old, fresh)); | ||
1154 | 286 | |||
1155 | 287 | // a b c d -> b c d | ||
1156 | 288 | fresh.clear(); | ||
1157 | 289 | fresh.push_back("b"); | ||
1158 | 290 | fresh.push_back("c"); | ||
1159 | 291 | fresh.push_back("d"); | ||
1160 | 292 | |||
1161 | 293 | EXPECT_FALSE(internal::impl::NeedToBeReordered(old, fresh)); | ||
1162 | 294 | |||
1163 | 295 | // a b c d -> a b d | ||
1164 | 296 | fresh.clear(); | ||
1165 | 297 | fresh.push_back("a"); | ||
1166 | 298 | fresh.push_back("b"); | ||
1167 | 299 | fresh.push_back("d"); | ||
1168 | 300 | |||
1169 | 301 | EXPECT_FALSE(internal::impl::NeedToBeReordered(old, fresh)); | ||
1170 | 302 | |||
1171 | 303 | // a b c d -> a | ||
1172 | 304 | fresh.clear(); | ||
1173 | 305 | fresh.push_back("a"); | ||
1174 | 306 | |||
1175 | 307 | EXPECT_FALSE(internal::impl::NeedToBeReordered(old, fresh)); | ||
1176 | 308 | |||
1177 | 309 | // a b c d -> a d b | ||
1178 | 310 | fresh.clear(); | ||
1179 | 311 | fresh.push_back("a"); | ||
1180 | 312 | fresh.push_back("d"); | ||
1181 | 313 | fresh.push_back("b"); | ||
1182 | 314 | |||
1183 | 315 | EXPECT_TRUE(internal::impl::NeedToBeReordered(old, fresh)); | ||
1184 | 316 | |||
1185 | 317 | // a b c d -> b a c | ||
1186 | 318 | fresh.clear(); | ||
1187 | 319 | fresh.push_back("b"); | ||
1188 | 320 | fresh.push_back("a"); | ||
1189 | 321 | fresh.push_back("c"); | ||
1190 | 322 | |||
1191 | 323 | EXPECT_TRUE(internal::impl::NeedToBeReordered(old, fresh)); | ||
1192 | 324 | } | ||
1193 | 325 | |||
1194 | 326 | TEST(TestFavoriteStorePrivate, TestNeedToBeReorderedPlus) | ||
1195 | 327 | { | ||
1196 | 328 | std::list<std::string> old; | ||
1197 | 329 | std::list<std::string> fresh; | ||
1198 | 330 | |||
1199 | 331 | old.push_back("a"); | ||
1200 | 332 | old.push_back("b"); | ||
1201 | 333 | old.push_back("c"); | ||
1202 | 334 | old.push_back("d"); | ||
1203 | 335 | |||
1204 | 336 | // All new elements. | ||
1205 | 337 | fresh.clear(); | ||
1206 | 338 | fresh.push_back("e"); | ||
1207 | 339 | fresh.push_back("f"); | ||
1208 | 340 | fresh.push_back("g"); | ||
1209 | 341 | fresh.push_back("h"); | ||
1210 | 342 | |||
1211 | 343 | EXPECT_FALSE(internal::impl::NeedToBeReordered(old, fresh)); | ||
1212 | 344 | |||
1213 | 345 | // a b c d -> a b c d e | ||
1214 | 346 | fresh.clear(); | ||
1215 | 347 | fresh.push_back("a"); | ||
1216 | 348 | fresh.push_back("b"); | ||
1217 | 349 | fresh.push_back("c"); | ||
1218 | 350 | fresh.push_back("d"); | ||
1219 | 351 | fresh.push_back("e"); | ||
1220 | 352 | |||
1221 | 353 | EXPECT_FALSE(internal::impl::NeedToBeReordered(old, fresh)); | ||
1222 | 354 | |||
1223 | 355 | // a b c d -> a b e c d | ||
1224 | 356 | fresh.clear(); | ||
1225 | 357 | fresh.push_back("a"); | ||
1226 | 358 | fresh.push_back("b"); | ||
1227 | 359 | fresh.push_back("e"); | ||
1228 | 360 | fresh.push_back("c"); | ||
1229 | 361 | fresh.push_back("d"); | ||
1230 | 362 | |||
1231 | 363 | EXPECT_FALSE(internal::impl::NeedToBeReordered(old, fresh)); | ||
1232 | 364 | |||
1233 | 365 | // a b c d -> a b e d c | ||
1234 | 366 | fresh.clear(); | ||
1235 | 367 | fresh.push_back("a"); | ||
1236 | 368 | fresh.push_back("b"); | ||
1237 | 369 | fresh.push_back("e"); | ||
1238 | 370 | fresh.push_back("d"); | ||
1239 | 371 | fresh.push_back("c"); | ||
1240 | 372 | |||
1241 | 373 | EXPECT_TRUE(internal::impl::NeedToBeReordered(old, fresh)); | ||
1242 | 374 | |||
1243 | 375 | // a b c d -> f a b c d | ||
1244 | 376 | fresh.clear(); | ||
1245 | 377 | fresh.push_back("f"); | ||
1246 | 378 | fresh.push_back("a"); | ||
1247 | 379 | fresh.push_back("b"); | ||
1248 | 380 | fresh.push_back("c"); | ||
1249 | 381 | fresh.push_back("d"); | ||
1250 | 382 | |||
1251 | 383 | EXPECT_FALSE(internal::impl::NeedToBeReordered(old, fresh)); | ||
1252 | 384 | } | ||
1253 | 385 | |||
1254 | 386 | TEST(TestFavoriteStorePrivate, TestNeedToBeReorderedMixed) | ||
1255 | 387 | { | ||
1256 | 388 | std::list<std::string> old; | ||
1257 | 389 | std::list<std::string> fresh; | ||
1258 | 390 | |||
1259 | 391 | old.push_back("a"); | ||
1260 | 392 | old.push_back("b"); | ||
1261 | 393 | old.push_back("c"); | ||
1262 | 394 | old.push_back("d"); | ||
1263 | 395 | |||
1264 | 396 | // a b c d -> b f c g h | ||
1265 | 397 | fresh.clear(); | ||
1266 | 398 | fresh.push_back("b"); | ||
1267 | 399 | fresh.push_back("f"); | ||
1268 | 400 | fresh.push_back("c"); | ||
1269 | 401 | fresh.push_back("g"); | ||
1270 | 402 | fresh.push_back("h"); | ||
1271 | 403 | |||
1272 | 404 | EXPECT_FALSE(internal::impl::NeedToBeReordered(old, fresh)); | ||
1273 | 405 | |||
1274 | 406 | |||
1275 | 407 | // a b c d -> c f b g h | ||
1276 | 408 | fresh.clear(); | ||
1277 | 409 | fresh.push_back("c"); | ||
1278 | 410 | fresh.push_back("f"); | ||
1279 | 411 | fresh.push_back("b"); | ||
1280 | 412 | fresh.push_back("g"); | ||
1281 | 413 | fresh.push_back("h"); | ||
1282 | 414 | |||
1283 | 415 | EXPECT_TRUE(internal::impl::NeedToBeReordered(old, fresh)); | ||
1284 | 416 | } | ||
1285 | 417 |
There's a merge-conflict in plugins/ unityshell/ src/BamfLaunche rIcon.h with trunk...
const char* DesktopFile();
bool IsSticky();
<<<<<<< TREE
void Quit();
void Stick();
=======
void Stick(bool save = true);
>>>>>>> MERGE-SOURCE
void UnStick();