Merge lp:~azzar1/unity/fix-681503 into lp:unity

Proposed by Andrea Azzarone
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
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_added.emit("a", "b", true) to say that we want to add the icon before (true) the icon b.
- favorite_added.emit("a", "", true) to say that we want to add the icon at the begin of the launcher.
- favorite_added.emit("a", "b", false) to say that we want to add the icon after (false) the icon b.

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

To post a comment you must log in.
Revision history for this message
Mirco Müller (macslow) wrote :

There's a merge-conflict in plugins/unityshell/src/BamfLauncherIcon.h with trunk...

  const char* DesktopFile();
  bool IsSticky();
<<<<<<< TREE
  void Quit();
  void Stick();
=======
  void Stick(bool save = true);
>>>>>>> MERGE-SOURCE
  void UnStick();

review: Needs Fixing
Revision history for this message
Andrea Azzarone (azzar1) wrote :

> There's a merge-conflict in plugins/unityshell/src/BamfLauncherIcon.h with
> trunk...
>
> const char* DesktopFile();
> bool IsSticky();
> <<<<<<< TREE
> void Quit();
> void Stick();
> =======
> void Stick(bool save = true);
> >>>>>>> MERGE-SOURCE
> void UnStick();

Fixed.

Revision history for this message
Mirco Müller (macslow) wrote :

Looking good now.

review: Approve
Revision history for this message
Unity Merger (unity-merger) wrote :

Attempt to merge into lp:unity failed due to conflicts:

text conflict in tests/CMakeLists.txt

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'plugins/unityshell/src/BamfLauncherIcon.cpp'
--- plugins/unityshell/src/BamfLauncherIcon.cpp 2012-01-24 02:19:04 +0000
+++ plugins/unityshell/src/BamfLauncherIcon.cpp 2012-01-26 14:42:28 +0000
@@ -871,7 +871,7 @@
871 g_list_free(children);871 g_list_free(children);
872}872}
873873
874void BamfLauncherIcon::Stick()874void BamfLauncherIcon::Stick(bool save)
875{875{
876 BamfView* view = BAMF_VIEW(m_App);876 BamfView* view = BAMF_VIEW(m_App);
877 877
@@ -881,7 +881,7 @@
881 const gchar* desktop_file = DesktopFile();881 const gchar* desktop_file = DesktopFile();
882 bamf_view_set_sticky(view, true);882 bamf_view_set_sticky(view, true);
883 883
884 if (desktop_file && strlen(desktop_file) > 0)884 if (save && desktop_file && strlen(desktop_file) > 0)
885 FavoriteStore::GetDefault().AddFavorite(desktop_file, -1);885 FavoriteStore::GetDefault().AddFavorite(desktop_file, -1);
886}886}
887887
888888
=== modified file 'plugins/unityshell/src/BamfLauncherIcon.h'
--- plugins/unityshell/src/BamfLauncherIcon.h 2012-01-15 19:01:11 +0000
+++ plugins/unityshell/src/BamfLauncherIcon.h 2012-01-26 14:42:28 +0000
@@ -46,9 +46,9 @@
4646
47 const char* DesktopFile();47 const char* DesktopFile();
48 bool IsSticky();48 bool IsSticky();
49 void Stick(bool save = true);
50 void UnStick();
49 void Quit();51 void Quit();
50 void Stick();
51 void UnStick();
5252
53 void ActivateLauncherIcon(ActionArg arg);53 void ActivateLauncherIcon(ActionArg arg);
5454
5555
=== modified file 'plugins/unityshell/src/FavoriteStore.h'
--- plugins/unityshell/src/FavoriteStore.h 2011-07-21 14:59:25 +0000
+++ plugins/unityshell/src/FavoriteStore.h 2012-01-26 14:42:28 +0000
@@ -34,7 +34,7 @@
34// Use GetDefault () to get the correct store for the session34// Use GetDefault () to get the correct store for the session
35typedef std::list<std::string> FavoriteList;35typedef std::list<std::string> FavoriteList;
3636
37class FavoriteStore : boost::noncopyable37class FavoriteStore : public sigc::trackable, boost::noncopyable
38{38{
39public:39public:
40 virtual ~FavoriteStore();40 virtual ~FavoriteStore();
@@ -54,12 +54,12 @@
54 virtual void SetFavorites(FavoriteList const& desktop_paths) = 0;54 virtual void SetFavorites(FavoriteList const& desktop_paths) = 0;
5555
56 // Signals56 // Signals
57 // Therse only emit if something has changed the GSettings object externally57 // These only emit if something has changed the GSettings object externally
5858
59 //desktop_path, position59 //desktop_path, position, before/after
60 sigc::signal<void, std::string, int> favorite_added;60 sigc::signal<void, std::string const&, std::string const&, bool> favorite_added;
61 //desktop_path61 //desktop_path
62 sigc::signal<void, std::string> favorite_removed;62 sigc::signal<void, std::string const&> favorite_removed;
63 sigc::signal<void> reordered;63 sigc::signal<void> reordered;
64};64};
6565
6666
=== modified file 'plugins/unityshell/src/FavoriteStoreGSettings.cpp'
--- plugins/unityshell/src/FavoriteStoreGSettings.cpp 2011-11-28 15:19:31 +0000
+++ plugins/unityshell/src/FavoriteStoreGSettings.cpp 2012-01-26 14:42:28 +0000
@@ -17,15 +17,14 @@
17* Authored by: Neil Jagdish Patel <neil.patel@canonical.com>17* Authored by: Neil Jagdish Patel <neil.patel@canonical.com>
18*/18*/
1919
20#include "FavoriteStoreGSettings.h"
21
22#include <algorithm>20#include <algorithm>
23#include <iostream>
2421
25#include <gio/gdesktopappinfo.h>22#include <gio/gdesktopappinfo.h>
26
27#include <NuxCore/Logger.h>23#include <NuxCore/Logger.h>
2824
25#include "FavoriteStoreGSettings.h"
26#include "FavoriteStorePrivate.h"
27
29#include "config.h"28#include "config.h"
3029
31/**30/**
@@ -103,7 +102,12 @@
103102
104void FavoriteStoreGSettings::Refresh()103void FavoriteStoreGSettings::Refresh()
105{104{
106 favorites_.clear();105 FillList(favorites_);
106}
107
108void FavoriteStoreGSettings::FillList(FavoriteList& list)
109{
110 list.clear();
107111
108 gchar** favs = g_settings_get_strv(settings_, "favorites");112 gchar** favs = g_settings_get_strv(settings_, "favorites");
109113
@@ -114,7 +118,7 @@
114 {118 {
115 if (g_file_test(favs[i], G_FILE_TEST_EXISTS))119 if (g_file_test(favs[i], G_FILE_TEST_EXISTS))
116 {120 {
117 favorites_.push_back(favs[i]);121 list.push_back(favs[i]);
118 }122 }
119 else123 else
120 {124 {
@@ -131,12 +135,11 @@
131135
132 if (filename)136 if (filename)
133 {137 {
134 favorites_.push_back(filename);138 list.push_back(filename);
135 }139 }
136 else140 else
137 {141 {
138 LOG_WARNING(logger) << "Unable to load GDesktopAppInfo for '"142 LOG_WARNING(logger) << "Unable to load GDesktopAppInfo for '" << favs[i] << "'";
139 << favs[i] << "'";
140 }143 }
141 }144 }
142 }145 }
@@ -222,7 +225,7 @@
222 Refresh();225 Refresh();
223}226}
224227
225void FavoriteStoreGSettings::SaveFavorites(FavoriteList const& favorites)228void FavoriteStoreGSettings::SaveFavorites(FavoriteList const& favorites, bool ignore)
226{229{
227 const int size = favorites.size();230 const int size = favorites.size();
228 const char* favs[size + 1];231 const char* favs[size + 1];
@@ -244,7 +247,7 @@
244 favs[index] = iter->c_str();247 favs[index] = iter->c_str();
245 }248 }
246249
247 ignore_signals_ = true;250 ignore_signals_ = ignore;
248 if (!g_settings_set_strv(settings_, "favorites", favs))251 if (!g_settings_set_strv(settings_, "favorites", favs))
249 {252 {
250 LOG_WARNING(logger) << "Saving favorites failed.";253 LOG_WARNING(logger) << "Saving favorites failed.";
@@ -254,10 +257,34 @@
254257
255void FavoriteStoreGSettings::Changed(std::string const& key)258void FavoriteStoreGSettings::Changed(std::string const& key)
256{259{
257 if (ignore_signals_)260 if (ignore_signals_ or key != "favorites")
258 return;261 return;
259262
260 LOG_DEBUG(logger) << "Changed: " << key;263 FavoriteList old(favorites_);
264 FillList(favorites_);
265
266 auto newbies = impl::GetNewbies(old, favorites_);
267
268 for (auto it : favorites_)
269 {
270 if (std::find(newbies.begin(), newbies.end(), it) == newbies.end())
271 continue;
272
273 std::string pos;
274 bool before;
275
276 impl::GetSignalAddedInfo(favorites_, newbies , it, pos, before);
277 favorite_added.emit(it, pos, before);
278 }
279
280 for (auto it : impl::GetRemoved(old, favorites_))
281 {
282 favorite_removed.emit(it);
283 }
284
285 if (impl::NeedToBeReordered(old, favorites_))
286 reordered.emit();
287
261}288}
262289
263namespace290namespace
264291
=== modified file 'plugins/unityshell/src/FavoriteStoreGSettings.h'
--- plugins/unityshell/src/FavoriteStoreGSettings.h 2011-07-21 14:59:25 +0000
+++ plugins/unityshell/src/FavoriteStoreGSettings.h 2012-01-26 14:42:28 +0000
@@ -42,6 +42,7 @@
42 virtual void AddFavorite(std::string const& desktop_path, int position);42 virtual void AddFavorite(std::string const& desktop_path, int position);
43 virtual void RemoveFavorite(std::string const& desktop_path);43 virtual void RemoveFavorite(std::string const& desktop_path);
44 virtual void MoveFavorite(std::string const& desktop_path, int position);44 virtual void MoveFavorite(std::string const& desktop_path, int position);
45 void SaveFavorites(FavoriteList const& favorites, bool ignore = true);
45 virtual void SetFavorites(FavoriteList const& desktop_paths);46 virtual void SetFavorites(FavoriteList const& desktop_paths);
4647
47 //Methods48 //Methods
@@ -50,7 +51,7 @@
50private:51private:
51 void Init();52 void Init();
52 void Refresh();53 void Refresh();
53 void SaveFavorites(FavoriteList const& favorites);54 void FillList(FavoriteList& list);
5455
55 FavoriteList favorites_;56 FavoriteList favorites_;
56 glib::Object<GSettings> settings_;57 glib::Object<GSettings> settings_;
5758
=== added file 'plugins/unityshell/src/FavoriteStorePrivate.cpp'
--- plugins/unityshell/src/FavoriteStorePrivate.cpp 1970-01-01 00:00:00 +0000
+++ plugins/unityshell/src/FavoriteStorePrivate.cpp 2012-01-26 14:42:28 +0000
@@ -0,0 +1,130 @@
1// -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*-
2/*
3* Copyright (C) 2011 Canonical Ltd
4*
5* This program is free software: you can redistribute it and/or modify
6* it under the terms of the GNU General Public License version 3 as
7* published by the Free Software Foundation.
8*
9* This program is distributed in the hope that it will be useful,
10* but WITHOUT ANY WARRANTY; without even the implied warranty of
11* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12* GNU General Public License for more details.
13*
14* You should have received a copy of the GNU General Public License
15* along with this program. If not, see <http://www.gnu.org/licenses/>.
16*
17* Authored by: Andrea Azzaronea <azzaronea@gmail.com>
18*/
19
20#include <algorithm>
21#include <boost/utility.hpp>
22
23#include "FavoriteStorePrivate.h"
24
25namespace unity
26{
27namespace internal
28{
29namespace impl
30{
31
32std::vector<std::string> GetNewbies(std::list<std::string> const& old, std::list<std::string> const& fresh)
33{
34 auto sorted_old(old);
35 auto sorted_fresh(fresh);
36
37 sorted_old.sort();
38 sorted_fresh.sort();
39
40 std::vector<std::string> result;
41 std::set_difference(sorted_fresh.begin(), sorted_fresh.end(), sorted_old.begin(), sorted_old.end(),
42 std::inserter(result, result.end()));
43
44 return result;
45}
46
47void GetSignalAddedInfo(std::list<std::string> const& favs, std::vector<std::string> const& newbies,
48 std::string const& path, std::string& position, bool& before)
49{
50 auto it = std::find(favs.begin(), favs.end(), path);
51 before = (it == favs.begin());
52 position = "";
53
54 if (before and favs.size() > 1)
55 {
56 while (it != favs.end() && std::find(newbies.begin(), newbies.end(), *it) != newbies.end())
57 ++it;
58
59 if (it != favs.end())
60 position = *it;
61 }
62 else if (!before)
63 {
64 position = *(boost::prior(it));
65 }
66
67}
68
69std::vector<std::string> GetRemoved(std::list<std::string> const& old, std::list<std::string> const& fresh)
70{
71 auto sorted_old(old);
72 auto sorted_fresh(fresh);
73
74 sorted_old.sort();
75 sorted_fresh.sort();
76
77 std::vector<std::string> result;
78 std::set_difference(sorted_old.begin(), sorted_old.end(), sorted_fresh.begin(), sorted_fresh.end(),
79 std::inserter(result, result.end()));
80
81 return result;
82}
83
84
85bool NeedToBeReordered(std::list<std::string> const& old, std::list<std::string> const& fresh)
86{
87 auto sorted_old(old);
88 auto sorted_fresh(fresh);
89
90 sorted_old.sort();
91 sorted_fresh.sort();
92
93 std::vector<std::string> ignore_old, ignore_fresh;
94
95 std::set_difference(sorted_old.begin(), sorted_old.end(), sorted_fresh.begin(), sorted_fresh.end(),
96 std::inserter(ignore_old, ignore_old.end()));
97 std::set_difference(sorted_fresh.begin(), sorted_fresh.end(), sorted_old.begin(), sorted_old.end(),
98 std::inserter(ignore_fresh, ignore_fresh.end()));
99
100 auto it_old = old.begin();
101 auto it_fresh = fresh.begin();
102
103 while (it_old != old.end() && it_fresh != fresh.end())
104 {
105
106 while (it_old != old.end() && std::find(ignore_old.begin(), ignore_old.end(), *it_old) != ignore_old.end())
107 ++it_old;
108
109 while (it_fresh != fresh.end() && std::find(ignore_fresh.begin(), ignore_fresh.end(), *it_fresh) != ignore_fresh.end())
110 ++it_fresh;
111
112 if (it_old == old.end() || it_fresh == fresh.end())
113 break;
114
115 if (*it_old != *it_fresh)
116 {
117 return true;
118 }
119
120 ++it_old;
121 ++it_fresh;
122 }
123
124 return false;
125}
126
127
128} // namespace impl
129} // namespace internal
130} // namespace unity
0131
=== added file 'plugins/unityshell/src/FavoriteStorePrivate.h'
--- plugins/unityshell/src/FavoriteStorePrivate.h 1970-01-01 00:00:00 +0000
+++ plugins/unityshell/src/FavoriteStorePrivate.h 2012-01-26 14:42:28 +0000
@@ -0,0 +1,47 @@
1// -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*-
2/*
3* Copyright (C) 2011 Canonical Ltd
4*
5* This program is free software: you can redistribute it and/or modify
6* it under the terms of the GNU General Public License version 3 as
7* published by the Free Software Foundation.
8*
9* This program is distributed in the hope that it will be useful,
10* but WITHOUT ANY WARRANTY; without even the implied warranty of
11* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12* GNU General Public License for more details.
13*
14* You should have received a copy of the GNU General Public License
15* along with this program. If not, see <http://www.gnu.org/licenses/>.
16*
17* Authored by: Andrea Azzaronea <azzaronea@gmail.com>
18*/
19
20#ifndef UNITYSHELL_FAVORITESTOREPRIVATE_H
21#define UNITYSHELL_FAVORITESTOREPRIVATE_H
22
23#include <list>
24#include <string>
25
26namespace unity
27{
28namespace internal
29{
30namespace impl
31{
32
33std::vector<std::string> GetNewbies(std::list<std::string> const& old, std::list<std::string> const& fresh);
34
35void GetSignalAddedInfo(std::list<std::string> const& favs, std::vector<std::string> const& newbies,
36 std::string const& path, std::string& position, bool& before);
37
38std::vector<std::string> GetRemoved(std::list<std::string> const& old, std::list<std::string> const& fresh);
39
40bool NeedToBeReordered(std::list<std::string> const& old, std::list<std::string> const& fresh);
41
42} // namespace impl
43} // namespace internal
44} // namespace unity
45
46#endif
47
048
=== modified file 'plugins/unityshell/src/LauncherController.cpp'
--- plugins/unityshell/src/LauncherController.cpp 2012-01-23 13:07:40 +0000
+++ plugins/unityshell/src/LauncherController.cpp 2012-01-26 14:42:28 +0000
@@ -73,6 +73,11 @@
7373
74 void OnLauncherEntryRemoteAdded(LauncherEntryRemote* entry);74 void OnLauncherEntryRemoteAdded(LauncherEntryRemote* entry);
75 void OnLauncherEntryRemoteRemoved(LauncherEntryRemote* entry);75 void OnLauncherEntryRemoteRemoved(LauncherEntryRemote* entry);
76
77 void OnFavoriteStoreFavoriteAdded(std::string const& entry, std::string const& pos, bool before);
78 void OnFavoriteStoreFavoriteRemoved(std::string const& entry);
79 void OnFavoriteStoreReordered();
80
7681
77 void InsertExpoAction();82 void InsertExpoAction();
78 void RemoveExpoAction();83 void RemoveExpoAction();
@@ -179,6 +184,10 @@
179184
180 remote_model_.entry_added.connect(sigc::mem_fun(this, &Impl::OnLauncherEntryRemoteAdded));185 remote_model_.entry_added.connect(sigc::mem_fun(this, &Impl::OnLauncherEntryRemoteAdded));
181 remote_model_.entry_removed.connect(sigc::mem_fun(this, &Impl::OnLauncherEntryRemoteRemoved));186 remote_model_.entry_removed.connect(sigc::mem_fun(this, &Impl::OnLauncherEntryRemoteRemoved));
187
188 FavoriteStore::GetDefault().favorite_added.connect(sigc::mem_fun(this, &Impl::OnFavoriteStoreFavoriteAdded));
189 FavoriteStore::GetDefault().favorite_removed.connect(sigc::mem_fun(this, &Impl::OnFavoriteStoreFavoriteRemoved));
190 FavoriteStore::GetDefault().reordered.connect(sigc::mem_fun(this, &Impl::OnFavoriteStoreReordered));
182191
183 RegisterIcon(new BFBLauncherIcon(raw_launcher));192 RegisterIcon(new BFBLauncherIcon(raw_launcher));
184 desktop_icon_ = new DesktopLauncherIcon(raw_launcher);193 desktop_icon_ = new DesktopLauncherIcon(raw_launcher);
@@ -349,6 +358,82 @@
349 }358 }
350}359}
351360
361void Controller::Impl::OnFavoriteStoreFavoriteAdded(std::string const& entry, std::string const& pos, bool before)
362{
363 auto bamf_list = model_->GetSublist<BamfLauncherIcon>();
364 LauncherIcon* other = (bamf_list.size() > 0) ? *(bamf_list.begin()) : nullptr;
365
366 if (!pos.empty())
367 {
368 for (auto it : bamf_list)
369 {
370 if (it->GetQuirk(LauncherIcon::QUIRK_VISIBLE) && pos == it->DesktopFile())
371 other = it;
372 }
373 }
374
375 for (auto it : bamf_list)
376 {
377 if (entry == it->DesktopFile())
378 {
379 it->Stick(false);
380 if (!before)
381 model_->ReorderAfter(it, other);
382 else
383 model_->ReorderBefore(it, other, false);
384 return;
385 }
386 }
387
388 LauncherIcon* result = CreateFavorite(entry.c_str());
389 if (result)
390 {
391 RegisterIcon(result);
392 if (!before)
393 model_->ReorderAfter(result, other);
394 else
395 model_->ReorderBefore(result, other, false);
396 }
397}
398
399void Controller::Impl::OnFavoriteStoreFavoriteRemoved(std::string const& entry)
400{
401 for (auto it : model_->GetSublist<BamfLauncherIcon> ())
402 {
403 if (it->DesktopFile() == entry)
404 {
405 OnLauncherRemoveRequest(it);
406 break;
407 }
408 }
409}
410
411void Controller::Impl::OnFavoriteStoreReordered()
412{
413 FavoriteList const& favs = FavoriteStore::GetDefault().GetFavorites();
414 auto bamf_list = model_->GetSublist<BamfLauncherIcon>();
415
416 int i = 0;
417 for (auto it : favs)
418 {
419 auto icon = std::find_if(bamf_list.begin(), bamf_list.end(),
420 [&it](BamfLauncherIcon* x) { return (x->DesktopFile() == it); });
421
422 if (icon != bamf_list.end())
423 {
424 (*icon)->SetSortPriority(i++);
425 }
426 }
427
428 for (auto it : bamf_list)
429 {
430 if (!it->IsSticky())
431 it->SetSortPriority(i++);
432 }
433
434 model_->Sort();
435}
436
352void Controller::Impl::OnExpoActivated()437void Controller::Impl::OnExpoActivated()
353{438{
354 WindowManager::Default()->InitiateExpo();439 WindowManager::Default()->InitiateExpo();
355440
=== modified file 'plugins/unityshell/src/LauncherModel.cpp'
--- plugins/unityshell/src/LauncherModel.cpp 2012-01-25 03:02:57 +0000
+++ plugins/unityshell/src/LauncherModel.cpp 2012-01-26 14:42:28 +0000
@@ -188,6 +188,36 @@
188}188}
189189
190void190void
191LauncherModel::ReorderAfter(LauncherIcon* icon, LauncherIcon* other)
192{
193 if (icon == other)
194 return;
195
196 int i = 0;
197 for (LauncherModel::iterator it = begin(); it != end(); ++it)
198 {
199 if ((*it) == icon)
200 continue;
201
202 if ((*it) == other)
203 {
204 (*it)->SetSortPriority(i);
205 ++i;
206
207 icon->SetSortPriority(i);
208 ++i;
209 }
210 else
211 {
212 (*it)->SetSortPriority(i);
213 ++i;
214 }
215 }
216
217 Sort();
218}
219
220void
191LauncherModel::ReorderBefore(LauncherIcon* icon, LauncherIcon* other, bool save)221LauncherModel::ReorderBefore(LauncherIcon* icon, LauncherIcon* other, bool save)
192{222{
193 if (icon == other)223 if (icon == other)
194224
=== modified file 'plugins/unityshell/src/LauncherModel.h'
--- plugins/unityshell/src/LauncherModel.h 2011-10-05 23:55:59 +0000
+++ plugins/unityshell/src/LauncherModel.h 2012-01-26 14:42:28 +0000
@@ -51,6 +51,7 @@
5151
52 bool IconHasSister(LauncherIcon* icon);52 bool IconHasSister(LauncherIcon* icon);
5353
54 void ReorderAfter(LauncherIcon* icon, LauncherIcon* other);
54 void ReorderBefore(LauncherIcon* icon, LauncherIcon* other, bool save);55 void ReorderBefore(LauncherIcon* icon, LauncherIcon* other, bool save);
5556
56 void ReorderSmart(LauncherIcon* icon, LauncherIcon* other, bool save);57 void ReorderSmart(LauncherIcon* icon, LauncherIcon* other, bool save);
5758
=== modified file 'tests/CMakeLists.txt'
--- tests/CMakeLists.txt 2012-01-26 08:25:52 +0000
+++ tests/CMakeLists.txt 2012-01-26 14:42:28 +0000
@@ -119,6 +119,7 @@
119 test_glib_variant.cpp119 test_glib_variant.cpp
120 ${CMAKE_CURRENT_BINARY_DIR}/test_glib_signals_utils_marshal.cpp120 ${CMAKE_CURRENT_BINARY_DIR}/test_glib_signals_utils_marshal.cpp
121 test_favorite_store_gsettings.cpp121 test_favorite_store_gsettings.cpp
122 test_favorite_store_private.cpp
122 test_home_lens.cpp123 test_home_lens.cpp
123 test_shortcut_model.cpp124 test_shortcut_model.cpp
124 test_shortcut_private.cpp125 test_shortcut_private.cpp
@@ -137,6 +138,8 @@
137 ${UNITY_SRC}/FavoriteStore.h138 ${UNITY_SRC}/FavoriteStore.h
138 ${UNITY_SRC}/FavoriteStoreGSettings.cpp139 ${UNITY_SRC}/FavoriteStoreGSettings.cpp
139 ${UNITY_SRC}/FavoriteStoreGSettings.h140 ${UNITY_SRC}/FavoriteStoreGSettings.h
141 ${UNITY_SRC}/FavoriteStorePrivate.cpp
142 ${UNITY_SRC}/FavoriteStorePrivate.h
140 ${UNITY_SRC}/MockLauncherIcon.h143 ${UNITY_SRC}/MockLauncherIcon.h
141 ${UNITY_SRC}/MockShortcutHint.h144 ${UNITY_SRC}/MockShortcutHint.h
142 ${UNITY_SRC}/ShortcutModel.cpp145 ${UNITY_SRC}/ShortcutModel.cpp
143146
=== modified file 'tests/test_favorite_store_gsettings.cpp'
--- tests/test_favorite_store_gsettings.cpp 2011-11-28 16:02:32 +0000
+++ tests/test_favorite_store_gsettings.cpp 2012-01-26 14:42:28 +0000
@@ -42,8 +42,8 @@
42const gchar* SCHEMA_DIRECTORY = BUILDDIR"/settings";42const gchar* SCHEMA_DIRECTORY = BUILDDIR"/settings";
43const gchar* BASE_STORE_FILE = BUILDDIR"/settings/test-favorite-store-gsettings.store";43const gchar* BASE_STORE_FILE = BUILDDIR"/settings/test-favorite-store-gsettings.store";
44const gchar* BASE_STORE_CONTENTS = "[desktop/unity/launcher]\n" \44const gchar* BASE_STORE_CONTENTS = "[desktop/unity/launcher]\n" \
45 "favorites=['%s', '%s', '%s']";45 "favorites=['%s', '%s', '%s']";
46 46
47const char* base_store_favs[] = { BUILDDIR"/tests/data/ubuntuone-installer.desktop",47const char* base_store_favs[] = { BUILDDIR"/tests/data/ubuntuone-installer.desktop",
48 BUILDDIR"/tests/data/ubuntu-software-center.desktop",48 BUILDDIR"/tests/data/ubuntu-software-center.desktop",
49 BUILDDIR"/tests/data/update-manager.desktop",49 BUILDDIR"/tests/data/update-manager.desktop",
@@ -222,5 +222,271 @@
222 EXPECT_EQ(at(favs, 2), base_store_favs[2]);222 EXPECT_EQ(at(favs, 2), base_store_favs[2]);
223}223}
224224
225TEST_F(TestFavoriteStoreGSettings, TestFavoriteAddedSignalFirst)
226{
227 internal::FavoriteStoreGSettings settings(backend.RawPtr());
228 bool signal_received = false;
229 std::string position;
230 bool before = false;
231
232 settings.favorite_added.connect([&](std::string const& path, std::string const& pos, bool bef)
233 {
234 signal_received = true;
235 position = pos;
236 before = bef;
237 });
238
239 FavoriteList favs;
240 favs.push_back(other_desktop);
241 favs.push_back(base_store_favs[0]);
242 favs.push_back(base_store_favs[1]);
243 favs.push_back(base_store_favs[2]);
244 settings.SaveFavorites(favs, false);
245
246 sleep(1);
247
248 ASSERT_TRUE(signal_received);
249 EXPECT_EQ(position, base_store_favs[0]);
250 EXPECT_TRUE(before);
251}
252
253TEST_F(TestFavoriteStoreGSettings, TestFavoriteAddedSignalMiddle)
254{
255 internal::FavoriteStoreGSettings settings(backend.RawPtr());
256 bool signal_received = false;
257 std::string position;
258 bool before = true;
259
260 settings.favorite_added.connect([&](std::string const& path, std::string const& pos, bool bef)
261 {
262 signal_received = true;
263 position = pos;
264 before = bef;
265 });
266
267 FavoriteList favs;
268 favs.push_back(base_store_favs[0]);
269 favs.push_back(base_store_favs[1]);
270 favs.push_back(other_desktop);
271 favs.push_back(base_store_favs[2]);
272 settings.SaveFavorites(favs, false);
273
274 sleep(1);
275
276 ASSERT_TRUE(signal_received);
277 EXPECT_EQ(position, base_store_favs[1]);
278 EXPECT_FALSE(before);
279}
280
281TEST_F(TestFavoriteStoreGSettings, TestFavoriteAddedSignalEnd)
282{
283 internal::FavoriteStoreGSettings settings(backend.RawPtr());
284 bool signal_received = false;
285 std::string position;
286 bool before = true;
287
288 settings.favorite_added.connect([&](std::string const& path, std::string const& pos, bool bef)
289 {
290 signal_received = true;
291 position = pos;
292 before = bef;
293 });
294
295 FavoriteList favs;
296 favs.push_back(base_store_favs[0]);
297 favs.push_back(base_store_favs[1]);
298 favs.push_back(base_store_favs[2]);
299 favs.push_back(other_desktop);
300 settings.SaveFavorites(favs, false);
301
302 sleep(1);
303
304 ASSERT_TRUE(signal_received);
305 EXPECT_EQ(position, base_store_favs[2]);
306 EXPECT_FALSE(before);
307}
308
309TEST_F(TestFavoriteStoreGSettings, TestFavoriteAddedSignalEmpty)
310{
311 internal::FavoriteStoreGSettings settings(backend.RawPtr());
312 bool signal_received = false;
313 std::string position;
314 bool before = false;
315
316 settings.favorite_added.connect([&](std::string const& path, std::string const& pos, bool bef)
317 {
318 signal_received = true;
319 position = pos;
320 before = bef;
321 });
322
323 FavoriteList favs;
324 favs.push_back(other_desktop);
325 settings.SaveFavorites(favs, false);
326
327 sleep(1);
328
329 ASSERT_TRUE(signal_received);
330 EXPECT_EQ(position, "");
331 EXPECT_TRUE(before);
332}
333
334TEST_F(TestFavoriteStoreGSettings, TestFavoriteRemoved)
335{
336 internal::FavoriteStoreGSettings settings(backend.RawPtr());
337 bool signal_received = false;
338 std::string path_removed;
339
340 settings.favorite_removed.connect([&](std::string const& path)
341 {
342 signal_received = true;
343 path_removed = path;
344 });
345
346 FavoriteList favs;
347 favs.push_back(base_store_favs[0]);
348 favs.push_back(base_store_favs[2]);
349 settings.SaveFavorites(favs, false);
350
351 sleep(1);
352
353 ASSERT_TRUE(signal_received);
354 EXPECT_EQ(path_removed, base_store_favs[1]);
355}
356
357TEST_F(TestFavoriteStoreGSettings, TestFavoriteReordered)
358{
359 internal::FavoriteStoreGSettings settings(backend.RawPtr());
360 bool signal_received = false;
361
362 settings.reordered.connect([&]()
363 {
364 signal_received = true;
365 });
366
367 FavoriteList favs;
368 favs.push_back(base_store_favs[0]);
369 favs.push_back(base_store_favs[2]);
370 favs.push_back(base_store_favs[1]);
371 settings.SaveFavorites(favs, false);
372
373 sleep(1);
374
375 ASSERT_TRUE(signal_received);
376
377 signal_received = false;
378 favs.push_back(base_store_favs[0]);
379 favs.push_back(base_store_favs[2]);
380 favs.push_back(base_store_favs[1]);
381 settings.SaveFavorites(favs, false);
382
383 sleep(1);
384
385 ASSERT_FALSE(signal_received);
386}
387
388TEST_F(TestFavoriteStoreGSettings, TestFavoriteSignalsMixed1)
389{
390 internal::FavoriteStoreGSettings settings(backend.RawPtr());
391 bool added_received = false;
392 bool removed_received = false;
393 bool reordered_received = false;
394
395 settings.favorite_added.connect([&](std::string const& path, std::string const& pos, bool bef)
396 {
397 added_received = true;
398 });
399
400 settings.favorite_removed.connect([&](std::string const& path)
401 {
402 removed_received = true;
403 });
404
405 settings.reordered.connect([&]()
406 {
407 reordered_received = true;
408 });
409
410 FavoriteList favs;
411 favs.push_back(base_store_favs[0]);
412 favs.push_back(base_store_favs[1]);
413 favs.push_back(other_desktop);
414 settings.SaveFavorites(favs, false);
415
416 sleep(1);
417
418 EXPECT_TRUE(added_received);
419 EXPECT_TRUE(removed_received);
420 EXPECT_FALSE(reordered_received);
421}
422
423TEST_F(TestFavoriteStoreGSettings, TestFavoriteSignalsMixed2)
424{
425 internal::FavoriteStoreGSettings settings(backend.RawPtr());
426 bool added_received = false;
427 bool removed_received = false;
428 bool reordered_received = false;
429
430 settings.favorite_added.connect([&](std::string const& path, std::string const& pos, bool bef)
431 {
432 added_received = true;
433 });
434
435 settings.favorite_removed.connect([&](std::string const& path)
436 {
437 removed_received = true;
438 });
439
440 settings.reordered.connect([&]()
441 {
442 reordered_received = true;
443 });
444
445 FavoriteList favs;
446 favs.push_back(base_store_favs[1]);
447 favs.push_back(other_desktop);
448 favs.push_back(base_store_favs[0]);
449 settings.SaveFavorites(favs, false);
450
451 sleep(1);
452
453 EXPECT_TRUE(added_received);
454 EXPECT_TRUE(removed_received);
455 EXPECT_TRUE(reordered_received);
456}
457
458TEST_F(TestFavoriteStoreGSettings, TestFavoriteSignalsMixed3)
459{
460 internal::FavoriteStoreGSettings settings(backend.RawPtr());
461 bool added_received = false;
462 bool removed_received = false;
463 bool reordered_received = false;
464
465 settings.favorite_added.connect([&](std::string const& path, std::string const& pos, bool bef)
466 {
467 added_received = true;
468 });
469
470 settings.favorite_removed.connect([&](std::string const& path)
471 {
472 removed_received = true;
473 });
474
475 settings.reordered.connect([&]()
476 {
477 reordered_received = true;
478 });
479
480 FavoriteList favs;
481 favs.push_back(base_store_favs[1]);
482 favs.push_back(base_store_favs[0]);
483 settings.SaveFavorites(favs, false);
484
485 sleep(1);
486
487 EXPECT_FALSE(added_received);
488 EXPECT_TRUE(removed_received);
489 EXPECT_TRUE(reordered_received);
490}
225491
226} // anonymous namespace492} // anonymous namespace
227493
=== added file 'tests/test_favorite_store_private.cpp'
--- tests/test_favorite_store_private.cpp 1970-01-01 00:00:00 +0000
+++ tests/test_favorite_store_private.cpp 2012-01-26 14:42:28 +0000
@@ -0,0 +1,417 @@
1/*
2 * Copyright 2011 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 3, as published
6 * by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranties of
10 * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR
11 * PURPOSE. See the GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * version 3 along with this program. If not, see
15 * <http://www.gnu.org/licenses/>
16 *
17 * Authored by: Andrea Azzarone <azzaronea@gmail.com>
18 *
19 */
20
21#include <gtest/gtest.h>
22
23#include "FavoriteStorePrivate.h"
24
25using namespace unity;
26
27TEST(TestFavoriteStorePrivate, TestGetNewbies)
28{
29 std::list<std::string> old;
30 std::list<std::string> fresh;
31 std::vector<std::string> result;
32
33 old.push_back("a");
34 old.push_back("b");
35 old.push_back("c");
36 old.push_back("d");
37
38 // No change.
39 fresh.push_back("a");
40 fresh.push_back("b");
41 fresh.push_back("c");
42 fresh.push_back("d");
43
44 result = internal::impl::GetNewbies(old, fresh);
45
46 EXPECT_TRUE(result.empty());
47
48 // Permutation.
49 fresh.clear();
50 result.clear();
51 fresh.push_back("a");
52 fresh.push_back("c");
53 fresh.push_back("b");
54 fresh.push_back("d");
55
56 result = internal::impl::GetNewbies(old, fresh);
57
58 EXPECT_TRUE(result.empty());
59
60 // a b c d -> a c b
61 fresh.clear();
62 result.clear();
63 fresh.push_back("a");
64 fresh.push_back("c");
65 fresh.push_back("b");
66
67 result = internal::impl::GetNewbies(old, fresh);
68
69 EXPECT_TRUE(result.empty());
70
71 // a b c d -> a b c d e f
72 fresh.clear();
73 result.clear();
74 fresh.push_back("a");
75 fresh.push_back("b");
76 fresh.push_back("c");
77 fresh.push_back("d");
78 fresh.push_back("e");
79 fresh.push_back("f");
80
81 result = internal::impl::GetNewbies(old, fresh);
82
83 EXPECT_EQ(result.size(), 2);
84 EXPECT_EQ(result[0], "e");
85 EXPECT_EQ(result[1], "f");
86
87 // a b c d -> a b c e f
88 fresh.clear();
89 result.clear();
90 fresh.push_back("a");
91 fresh.push_back("b");
92 fresh.push_back("c");
93 fresh.push_back("e");
94 fresh.push_back("f");
95
96 result = internal::impl::GetNewbies(old, fresh);
97
98 EXPECT_EQ(result.size(), 2);
99 EXPECT_EQ(result[0], "e");
100 EXPECT_EQ(result[1], "f");
101}
102
103TEST(TestFavoriteStorePrivate, TestGetSignalAddedInfo)
104{
105 std::list<std::string> favs;
106 std::vector<std::string> newbies;
107 std::string position;
108 bool before;
109
110 favs.push_back("a");
111 favs.push_back("b");
112 favs.push_back("c");
113 favs.push_back("d");
114 favs.push_back("e");
115
116 // b c d e -> a b c d e
117 newbies.push_back("a");
118 internal::impl::GetSignalAddedInfo(favs, newbies, "a", position, before);
119 EXPECT_TRUE(before);
120 EXPECT_EQ(position, "b");
121
122 // a c d e -> a b c d e
123 newbies.clear();
124 newbies.push_back("b");
125 internal::impl::GetSignalAddedInfo(favs, newbies, "b", position, before);
126 EXPECT_FALSE(before);
127 EXPECT_EQ(position, "a");
128
129 // a b d e -> a b c d e
130 newbies.clear();
131 newbies.push_back("c");
132 internal::impl::GetSignalAddedInfo(favs, newbies, "c", position, before);
133 EXPECT_FALSE(before);
134 EXPECT_EQ(position, "b");
135
136 // a b c e -> a b c d e
137 newbies.clear();
138 newbies.push_back("d");
139 internal::impl::GetSignalAddedInfo(favs, newbies, "d", position, before);
140 EXPECT_FALSE(before);
141 EXPECT_EQ(position, "c");
142
143 // a b c d -> a b c d e
144 newbies.clear();
145 newbies.push_back("e");
146 internal::impl::GetSignalAddedInfo(favs, newbies, "e", position, before);
147 EXPECT_FALSE(before);
148 EXPECT_EQ(position, "d");
149
150 // -> b a c
151 favs.clear();
152 favs.push_back("b");
153 favs.push_back("a");
154 favs.push_back("c");
155 newbies.clear();
156 newbies.push_back("a");
157 newbies.push_back("b");
158 newbies.push_back("c");
159
160 internal::impl::GetSignalAddedInfo(favs, newbies, "b", position, before);
161 EXPECT_TRUE(before);
162 EXPECT_EQ(position, "");
163
164 internal::impl::GetSignalAddedInfo(favs, newbies, "a", position, before);
165 EXPECT_FALSE(before);
166 EXPECT_EQ(position, "b");
167
168 internal::impl::GetSignalAddedInfo(favs, newbies, "c", position, before);
169 EXPECT_FALSE(before);
170 EXPECT_EQ(position, "a");
171}
172
173
174TEST(TestFavoriteStorePrivate, TestGetRemoved)
175{
176 std::list<std::string> old;
177 std::list<std::string> fresh;
178 std::vector<std::string> result;
179
180 old.push_back("a");
181 old.push_back("b");
182 old.push_back("c");
183 old.push_back("d");
184
185 // No change.
186 fresh.push_back("a");
187 fresh.push_back("b");
188 fresh.push_back("c");
189 fresh.push_back("d");
190
191 result = internal::impl::GetRemoved(old, fresh);
192
193 EXPECT_TRUE(result.empty());
194
195 // Permutation.
196 fresh.clear();
197 result.clear();
198 fresh.push_back("a");
199 fresh.push_back("c");
200 fresh.push_back("b");
201 fresh.push_back("d");
202
203 result = internal::impl::GetRemoved(old, fresh);
204
205 EXPECT_TRUE(result.empty());
206
207 // a b c d -> b c
208 fresh.clear();
209 result.clear();
210 fresh.push_back("b");
211 fresh.push_back("c");
212
213 result = internal::impl::GetRemoved(old, fresh);
214
215 EXPECT_EQ(result.size(), 2);
216 EXPECT_EQ(result[0], "a");
217 EXPECT_EQ(result[1], "d");
218
219 // a b c d -> a e f d
220 fresh.clear();
221 result.clear();
222 fresh.push_back("a");
223 fresh.push_back("e");
224 fresh.push_back("f");
225 fresh.push_back("d");
226
227
228 result = internal::impl::GetRemoved(old, fresh);
229
230 EXPECT_EQ(result.size(), 2);
231 EXPECT_EQ(result[0], "b");
232 EXPECT_EQ(result[1], "c");
233}
234
235
236TEST(TestFavoriteStorePrivate, TestNeedToBeReorderedBasic)
237{
238 std::list<std::string> old;
239 std::list<std::string> fresh;
240
241 old.push_back("a");
242 old.push_back("b");
243 old.push_back("c");
244 old.push_back("d");
245
246 // No change.
247 fresh.push_back("a");
248 fresh.push_back("b");
249 fresh.push_back("c");
250 fresh.push_back("d");
251
252 EXPECT_FALSE(internal::impl::NeedToBeReordered(old, fresh));
253
254 // Permutation.
255 fresh.clear();
256 fresh.push_back("a");
257 fresh.push_back("c");
258 fresh.push_back("b");
259 fresh.push_back("d");
260
261 EXPECT_TRUE(internal::impl::NeedToBeReordered(old, fresh));
262
263 // Empty.
264 fresh.clear();
265
266 EXPECT_FALSE(internal::impl::NeedToBeReordered(old, fresh));
267}
268
269TEST(TestFavoriteStorePrivate, TestNeedToBeReorderedLess)
270{
271 std::list<std::string> old;
272 std::list<std::string> fresh;
273
274 old.push_back("a");
275 old.push_back("b");
276 old.push_back("c");
277 old.push_back("d");
278
279 // a b c d -> a b c
280 fresh.clear();
281 fresh.push_back("a");
282 fresh.push_back("b");
283 fresh.push_back("c");
284
285 EXPECT_FALSE(internal::impl::NeedToBeReordered(old, fresh));
286
287 // a b c d -> b c d
288 fresh.clear();
289 fresh.push_back("b");
290 fresh.push_back("c");
291 fresh.push_back("d");
292
293 EXPECT_FALSE(internal::impl::NeedToBeReordered(old, fresh));
294
295 // a b c d -> a b d
296 fresh.clear();
297 fresh.push_back("a");
298 fresh.push_back("b");
299 fresh.push_back("d");
300
301 EXPECT_FALSE(internal::impl::NeedToBeReordered(old, fresh));
302
303 // a b c d -> a
304 fresh.clear();
305 fresh.push_back("a");
306
307 EXPECT_FALSE(internal::impl::NeedToBeReordered(old, fresh));
308
309 // a b c d -> a d b
310 fresh.clear();
311 fresh.push_back("a");
312 fresh.push_back("d");
313 fresh.push_back("b");
314
315 EXPECT_TRUE(internal::impl::NeedToBeReordered(old, fresh));
316
317 // a b c d -> b a c
318 fresh.clear();
319 fresh.push_back("b");
320 fresh.push_back("a");
321 fresh.push_back("c");
322
323 EXPECT_TRUE(internal::impl::NeedToBeReordered(old, fresh));
324}
325
326TEST(TestFavoriteStorePrivate, TestNeedToBeReorderedPlus)
327{
328 std::list<std::string> old;
329 std::list<std::string> fresh;
330
331 old.push_back("a");
332 old.push_back("b");
333 old.push_back("c");
334 old.push_back("d");
335
336 // All new elements.
337 fresh.clear();
338 fresh.push_back("e");
339 fresh.push_back("f");
340 fresh.push_back("g");
341 fresh.push_back("h");
342
343 EXPECT_FALSE(internal::impl::NeedToBeReordered(old, fresh));
344
345 // a b c d -> a b c d e
346 fresh.clear();
347 fresh.push_back("a");
348 fresh.push_back("b");
349 fresh.push_back("c");
350 fresh.push_back("d");
351 fresh.push_back("e");
352
353 EXPECT_FALSE(internal::impl::NeedToBeReordered(old, fresh));
354
355 // a b c d -> a b e c d
356 fresh.clear();
357 fresh.push_back("a");
358 fresh.push_back("b");
359 fresh.push_back("e");
360 fresh.push_back("c");
361 fresh.push_back("d");
362
363 EXPECT_FALSE(internal::impl::NeedToBeReordered(old, fresh));
364
365 // a b c d -> a b e d c
366 fresh.clear();
367 fresh.push_back("a");
368 fresh.push_back("b");
369 fresh.push_back("e");
370 fresh.push_back("d");
371 fresh.push_back("c");
372
373 EXPECT_TRUE(internal::impl::NeedToBeReordered(old, fresh));
374
375 // a b c d -> f a b c d
376 fresh.clear();
377 fresh.push_back("f");
378 fresh.push_back("a");
379 fresh.push_back("b");
380 fresh.push_back("c");
381 fresh.push_back("d");
382
383 EXPECT_FALSE(internal::impl::NeedToBeReordered(old, fresh));
384}
385
386TEST(TestFavoriteStorePrivate, TestNeedToBeReorderedMixed)
387{
388 std::list<std::string> old;
389 std::list<std::string> fresh;
390
391 old.push_back("a");
392 old.push_back("b");
393 old.push_back("c");
394 old.push_back("d");
395
396 // a b c d -> b f c g h
397 fresh.clear();
398 fresh.push_back("b");
399 fresh.push_back("f");
400 fresh.push_back("c");
401 fresh.push_back("g");
402 fresh.push_back("h");
403
404 EXPECT_FALSE(internal::impl::NeedToBeReordered(old, fresh));
405
406
407 // a b c d -> c f b g h
408 fresh.clear();
409 fresh.push_back("c");
410 fresh.push_back("f");
411 fresh.push_back("b");
412 fresh.push_back("g");
413 fresh.push_back("h");
414
415 EXPECT_TRUE(internal::impl::NeedToBeReordered(old, fresh));
416}
417