55.884.1
by Andrea Azzarone
Porting of TestFavoriteStoreGSettings to Google Test. |
1 |
/*
|
2 |
* Copyright 2010 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: Neil Jagdish Patel <neil.patel@canonical.com>
|
|
18 |
* Andrea Azzarone <azzaronea@gmail.com>
|
|
19 |
*
|
|
20 |
*/
|
|
21 |
||
22 |
#include <config.h> |
|
23 |
||
24 |
#include <algorithm> |
|
55.1778.3
by Thomi Richards
Fixed favoritestore unit tests. |
25 |
#include <memory> |
55.884.1
by Andrea Azzarone
Porting of TestFavoriteStoreGSettings to Google Test. |
26 |
#include <string> |
27 |
||
28 |
#define G_SETTINGS_ENABLE_BACKEND
|
|
29 |
#include <gio/gsettingsbackend.h> |
|
55.1692.1
by Tim Penhey
Make the method public for testing, and test it. |
30 |
#include <gmock/gmock.h> |
55.1227.4
by Gord Allott
ensure the schema setting directory |
31 |
#include <glib.h> |
55.884.1
by Andrea Azzarone
Porting of TestFavoriteStoreGSettings to Google Test. |
32 |
|
33 |
#include "FavoriteStore.h" |
|
34 |
#include "FavoriteStoreGSettings.h" |
|
55.1692.1
by Tim Penhey
Make the method public for testing, and test it. |
35 |
#include "FavoriteStorePrivate.h" |
55.884.1
by Andrea Azzarone
Porting of TestFavoriteStoreGSettings to Google Test. |
36 |
#include <UnityCore/GLibWrapper.h> |
37 |
||
38 |
using namespace unity; |
|
55.1692.1
by Tim Penhey
Make the method public for testing, and test it. |
39 |
using testing::Eq; |
55.884.1
by Andrea Azzarone
Porting of TestFavoriteStoreGSettings to Google Test. |
40 |
|
41 |
namespace { |
|
55.1778.3
by Thomi Richards
Fixed favoritestore unit tests. |
42 |
|
55.884.1
by Andrea Azzarone
Porting of TestFavoriteStoreGSettings to Google Test. |
43 |
// Constant
|
55.2046.1
by Marco Trevisan (Treviño)
test_favorite_store_gsettings: refactored to use gsettings memory backend |
44 |
const gchar* SETTINGS_NAME = "com.canonical.Unity.Launcher"; |
45 |
const gchar* SETTINGS_KEY = "favorites"; |
|
55.1227.4
by Gord Allott
ensure the schema setting directory |
46 |
const gchar* SCHEMA_DIRECTORY = BUILDDIR"/settings"; |
55.1362.5
by Andrea Azzarone
Add signals tests. |
47 |
|
55.1227.5
by Gord Allott
made local desktop file tests only for gsettings |
48 |
const char* base_store_favs[] = { BUILDDIR"/tests/data/ubuntuone-installer.desktop", |
49 |
BUILDDIR"/tests/data/ubuntu-software-center.desktop", |
|
50 |
BUILDDIR"/tests/data/update-manager.desktop", |
|
55.884.1
by Andrea Azzarone
Porting of TestFavoriteStoreGSettings to Google Test. |
51 |
NULL
|
52 |
};
|
|
53 |
const int n_base_store_favs = G_N_ELEMENTS(base_store_favs) - 1; /* NULL */ |
|
55.1778.3
by Thomi Richards
Fixed favoritestore unit tests. |
54 |
|
55.1227.6
by Gord Allott
made the AddFavourite test local |
55 |
const std::string other_desktop = BUILDDIR"/tests/data/bzr-handle-patch.desktop"; |
55.884.1
by Andrea Azzarone
Porting of TestFavoriteStoreGSettings to Google Test. |
56 |
|
55.1778.3
by Thomi Richards
Fixed favoritestore unit tests. |
57 |
// Utilities
|
55.884.1
by Andrea Azzarone
Porting of TestFavoriteStoreGSettings to Google Test. |
58 |
std::string const& at(FavoriteList const& favs, int index) |
59 |
{
|
|
60 |
FavoriteList::const_iterator iter = favs.begin(); |
|
61 |
std::advance(iter, index); |
|
62 |
return *iter; |
|
63 |
}
|
|
64 |
||
65 |
bool ends_with(std::string const& value, std::string const& suffix) |
|
66 |
{
|
|
67 |
std::string::size_type pos = value.rfind(suffix); |
|
68 |
if (pos == std::string::npos) |
|
69 |
return false; |
|
70 |
else
|
|
71 |
return (pos + suffix.size()) == value.size(); |
|
72 |
}
|
|
55.1778.3
by Thomi Richards
Fixed favoritestore unit tests. |
73 |
|
55.884.1
by Andrea Azzarone
Porting of TestFavoriteStoreGSettings to Google Test. |
74 |
// A new one of these is created for each test
|
75 |
class TestFavoriteStoreGSettings : public testing::Test |
|
76 |
{
|
|
77 |
public: |
|
55.2046.1
by Marco Trevisan (Treviño)
test_favorite_store_gsettings: refactored to use gsettings memory backend |
78 |
std::unique_ptr<internal::FavoriteStoreGSettings> favorite_store; |
79 |
glib::Object<GSettings> gsettings_client; |
|
55.1778.3
by Thomi Richards
Fixed favoritestore unit tests. |
80 |
|
55.884.1
by Andrea Azzarone
Porting of TestFavoriteStoreGSettings to Google Test. |
81 |
virtual void SetUp() |
82 |
{
|
|
55.1778.3
by Thomi Richards
Fixed favoritestore unit tests. |
83 |
// set the data directory so gsettings can find the schema
|
55.2046.1
by Marco Trevisan (Treviño)
test_favorite_store_gsettings: refactored to use gsettings memory backend |
84 |
g_setenv("GSETTINGS_SCHEMA_DIR", SCHEMA_DIRECTORY, true); |
85 |
g_setenv("GSETTINGS_BACKEND", "memory", true); |
|
86 |
||
87 |
favorite_store.reset(new internal::FavoriteStoreGSettings()); |
|
88 |
||
89 |
// Setting the test values
|
|
90 |
gsettings_client = g_settings_new(SETTINGS_NAME); |
|
91 |
g_settings_set_strv(gsettings_client, SETTINGS_KEY, base_store_favs); |
|
55.884.1
by Andrea Azzarone
Porting of TestFavoriteStoreGSettings to Google Test. |
92 |
}
|
93 |
||
94 |
virtual void TearDown() |
|
95 |
{
|
|
55.2046.1
by Marco Trevisan (Treviño)
test_favorite_store_gsettings: refactored to use gsettings memory backend |
96 |
g_setenv("GSETTINGS_SCHEMA_DIR", "", true); |
97 |
g_setenv("GSETTINGS_BACKEND", "", true); |
|
55.884.1
by Andrea Azzarone
Porting of TestFavoriteStoreGSettings to Google Test. |
98 |
}
|
99 |
};
|
|
100 |
||
101 |
TEST_F(TestFavoriteStoreGSettings, TestAllocation) |
|
102 |
{
|
|
55.2046.1
by Marco Trevisan (Treviño)
test_favorite_store_gsettings: refactored to use gsettings memory backend |
103 |
FavoriteStore &settings = FavoriteStore::Instance(); |
104 |
EXPECT_EQ(&settings, favorite_store.get()); |
|
55.884.1
by Andrea Azzarone
Porting of TestFavoriteStoreGSettings to Google Test. |
105 |
}
|
106 |
||
107 |
TEST_F(TestFavoriteStoreGSettings, TestGetFavorites) |
|
108 |
{
|
|
55.1778.3
by Thomi Richards
Fixed favoritestore unit tests. |
109 |
FavoriteStore &settings = FavoriteStore::Instance(); |
55.1227.2
by Gord Allott
added error for null returned from gsettings |
110 |
FavoriteList const& favs = settings.GetFavorites(); |
55.884.1
by Andrea Azzarone
Porting of TestFavoriteStoreGSettings to Google Test. |
111 |
|
112 |
ASSERT_EQ(favs.size(), n_base_store_favs); |
|
113 |
EXPECT_TRUE(ends_with(at(favs, 0), base_store_favs[0])); |
|
114 |
EXPECT_TRUE(ends_with(at(favs, 1), base_store_favs[1])); |
|
115 |
EXPECT_TRUE(at(favs, 2) == base_store_favs[2]); |
|
116 |
}
|
|
55.1778.3
by Thomi Richards
Fixed favoritestore unit tests. |
117 |
|
55.884.1
by Andrea Azzarone
Porting of TestFavoriteStoreGSettings to Google Test. |
118 |
TEST_F(TestFavoriteStoreGSettings, TestAddFavorite) |
119 |
{
|
|
55.1778.3
by Thomi Richards
Fixed favoritestore unit tests. |
120 |
FavoriteStore &settings = FavoriteStore::Instance(); |
121 |
||
55.884.1
by Andrea Azzarone
Porting of TestFavoriteStoreGSettings to Google Test. |
122 |
settings.AddFavorite(other_desktop, 0); |
123 |
FavoriteList const& favs = settings.GetFavorites(); |
|
124 |
ASSERT_EQ(favs.size(), n_base_store_favs + 1); |
|
125 |
EXPECT_TRUE(other_desktop == at(favs, 0)); |
|
126 |
}
|
|
127 |
||
128 |
TEST_F(TestFavoriteStoreGSettings, TestAddFavoritePosition) |
|
129 |
{
|
|
55.1778.3
by Thomi Richards
Fixed favoritestore unit tests. |
130 |
FavoriteStore &settings = FavoriteStore::Instance(); |
131 |
||
55.884.1
by Andrea Azzarone
Porting of TestFavoriteStoreGSettings to Google Test. |
132 |
settings.AddFavorite(other_desktop, 2); |
133 |
FavoriteList const& favs = settings.GetFavorites(); |
|
134 |
ASSERT_EQ(favs.size(), n_base_store_favs + 1); |
|
135 |
EXPECT_TRUE(other_desktop == at(favs, 2)); |
|
136 |
}
|
|
137 |
||
138 |
TEST_F(TestFavoriteStoreGSettings,TestAddFavoriteLast) |
|
139 |
{
|
|
55.1778.3
by Thomi Richards
Fixed favoritestore unit tests. |
140 |
FavoriteStore &settings = FavoriteStore::Instance(); |
141 |
||
55.884.1
by Andrea Azzarone
Porting of TestFavoriteStoreGSettings to Google Test. |
142 |
settings.AddFavorite(other_desktop, -1); |
143 |
FavoriteList const& favs = settings.GetFavorites(); |
|
144 |
ASSERT_EQ(favs.size(), n_base_store_favs + 1); |
|
145 |
EXPECT_TRUE(other_desktop == favs.back()); |
|
146 |
}
|
|
147 |
||
148 |
TEST_F(TestFavoriteStoreGSettings,TestAddFavoriteOutOfRange) |
|
149 |
{
|
|
55.1778.3
by Thomi Richards
Fixed favoritestore unit tests. |
150 |
FavoriteStore &settings = FavoriteStore::Instance(); |
55.884.1
by Andrea Azzarone
Porting of TestFavoriteStoreGSettings to Google Test. |
151 |
|
152 |
FavoriteList const& favs = settings.GetFavorites(); |
|
153 |
settings.AddFavorite(other_desktop, n_base_store_favs + 1); |
|
154 |
// size didn't change
|
|
155 |
ASSERT_EQ(favs.size(), n_base_store_favs); |
|
156 |
// didn't get inserted
|
|
157 |
FavoriteList::const_iterator iter = std::find(favs.begin(), favs.end(), other_desktop); |
|
158 |
EXPECT_EQ(iter, favs.end()); |
|
159 |
}
|
|
160 |
||
161 |
TEST_F(TestFavoriteStoreGSettings, TestRemoveFavorite) |
|
162 |
{
|
|
55.1778.3
by Thomi Richards
Fixed favoritestore unit tests. |
163 |
FavoriteStore &settings = FavoriteStore::Instance(); |
55.884.1
by Andrea Azzarone
Porting of TestFavoriteStoreGSettings to Google Test. |
164 |
|
165 |
FavoriteList const& favs = settings.GetFavorites(); |
|
166 |
settings.RemoveFavorite(at(favs, 0)); |
|
167 |
||
168 |
ASSERT_EQ(favs.size(), n_base_store_favs - 1); |
|
169 |
EXPECT_TRUE(ends_with(at(favs, 0), base_store_favs[1])); |
|
170 |
||
171 |
settings.RemoveFavorite(at(favs, 1)); |
|
172 |
ASSERT_EQ(favs.size(), n_base_store_favs - 2); |
|
173 |
EXPECT_TRUE(ends_with(at(favs, 0), base_store_favs[1])); |
|
174 |
}
|
|
175 |
||
176 |
TEST_F(TestFavoriteStoreGSettings, TestRemoveFavoriteBad) |
|
177 |
{
|
|
55.1778.3
by Thomi Richards
Fixed favoritestore unit tests. |
178 |
FavoriteStore &settings = FavoriteStore::Instance(); |
55.884.1
by Andrea Azzarone
Porting of TestFavoriteStoreGSettings to Google Test. |
179 |
|
180 |
FavoriteList const& favs = settings.GetFavorites(); |
|
181 |
settings.RemoveFavorite(""); |
|
182 |
EXPECT_EQ(favs.size(), n_base_store_favs); |
|
183 |
||
184 |
settings.RemoveFavorite("foo.desktop"); |
|
185 |
EXPECT_EQ(favs.size(), n_base_store_favs); |
|
186 |
||
187 |
settings.RemoveFavorite("/this/desktop/doesnt/exist/hopefully.desktop"); |
|
188 |
EXPECT_EQ(favs.size(), n_base_store_favs); |
|
189 |
}
|
|
190 |
||
191 |
TEST_F(TestFavoriteStoreGSettings, TestMoveFavorite) |
|
192 |
{
|
|
55.1778.3
by Thomi Richards
Fixed favoritestore unit tests. |
193 |
FavoriteStore &settings = FavoriteStore::Instance(); |
55.884.1
by Andrea Azzarone
Porting of TestFavoriteStoreGSettings to Google Test. |
194 |
|
195 |
FavoriteList const& favs = settings.GetFavorites(); |
|
196 |
||
197 |
settings.MoveFavorite(base_store_favs[2], 0); |
|
198 |
||
199 |
ASSERT_EQ(favs.size(), n_base_store_favs); |
|
200 |
EXPECT_EQ(at(favs, 0), base_store_favs[2]); |
|
201 |
EXPECT_TRUE(ends_with(at(favs, 1), base_store_favs[0])); |
|
202 |
EXPECT_TRUE(ends_with(at(favs, 2), base_store_favs[1])); |
|
203 |
}
|
|
204 |
||
205 |
TEST_F(TestFavoriteStoreGSettings, TestMoveFavoriteBad) |
|
206 |
{
|
|
55.1778.3
by Thomi Richards
Fixed favoritestore unit tests. |
207 |
FavoriteStore &settings = FavoriteStore::Instance(); |
55.884.1
by Andrea Azzarone
Porting of TestFavoriteStoreGSettings to Google Test. |
208 |
|
209 |
FavoriteList const& favs = settings.GetFavorites(); |
|
210 |
||
211 |
settings.MoveFavorite("", 0); |
|
212 |
settings.MoveFavorite(at(favs, 0), 100); |
|
213 |
||
214 |
ASSERT_EQ(favs.size(), n_base_store_favs); |
|
215 |
EXPECT_TRUE(ends_with(at(favs, 0), base_store_favs[0])); |
|
216 |
EXPECT_TRUE(ends_with(at(favs, 1), base_store_favs[1])); |
|
217 |
EXPECT_EQ(at(favs, 2), base_store_favs[2]); |
|
218 |
}
|
|
219 |
||
55.1362.5
by Andrea Azzarone
Add signals tests. |
220 |
TEST_F(TestFavoriteStoreGSettings, TestFavoriteAddedSignalFirst) |
221 |
{
|
|
55.1778.3
by Thomi Richards
Fixed favoritestore unit tests. |
222 |
FavoriteStore &settings = FavoriteStore::Instance(); |
55.1362.5
by Andrea Azzarone
Add signals tests. |
223 |
bool signal_received = false; |
224 |
std::string position; |
|
225 |
bool before = false; |
|
55.1778.3
by Thomi Richards
Fixed favoritestore unit tests. |
226 |
|
55.1362.5
by Andrea Azzarone
Add signals tests. |
227 |
settings.favorite_added.connect([&](std::string const& path, std::string const& pos, bool bef) |
228 |
{
|
|
229 |
signal_received = true; |
|
230 |
position = pos; |
|
231 |
before = bef; |
|
232 |
});
|
|
55.1778.3
by Thomi Richards
Fixed favoritestore unit tests. |
233 |
|
55.1362.5
by Andrea Azzarone
Add signals tests. |
234 |
FavoriteList favs; |
235 |
favs.push_back(other_desktop); |
|
236 |
favs.push_back(base_store_favs[0]); |
|
237 |
favs.push_back(base_store_favs[1]); |
|
238 |
favs.push_back(base_store_favs[2]); |
|
55.2046.1
by Marco Trevisan (Treviño)
test_favorite_store_gsettings: refactored to use gsettings memory backend |
239 |
favorite_store->SaveFavorites(favs, false); |
55.1778.3
by Thomi Richards
Fixed favoritestore unit tests. |
240 |
|
55.1362.5
by Andrea Azzarone
Add signals tests. |
241 |
ASSERT_TRUE(signal_received); |
242 |
EXPECT_EQ(position, base_store_favs[0]); |
|
243 |
EXPECT_TRUE(before); |
|
244 |
}
|
|
245 |
||
246 |
TEST_F(TestFavoriteStoreGSettings, TestFavoriteAddedSignalMiddle) |
|
247 |
{
|
|
55.1778.3
by Thomi Richards
Fixed favoritestore unit tests. |
248 |
FavoriteStore &settings = FavoriteStore::Instance(); |
55.1362.5
by Andrea Azzarone
Add signals tests. |
249 |
bool signal_received = false; |
250 |
std::string position; |
|
251 |
bool before = true; |
|
55.1778.3
by Thomi Richards
Fixed favoritestore unit tests. |
252 |
|
55.1362.5
by Andrea Azzarone
Add signals tests. |
253 |
settings.favorite_added.connect([&](std::string const& path, std::string const& pos, bool bef) |
254 |
{
|
|
255 |
signal_received = true; |
|
256 |
position = pos; |
|
257 |
before = bef; |
|
258 |
});
|
|
55.1778.3
by Thomi Richards
Fixed favoritestore unit tests. |
259 |
|
55.1362.5
by Andrea Azzarone
Add signals tests. |
260 |
FavoriteList favs; |
261 |
favs.push_back(base_store_favs[0]); |
|
262 |
favs.push_back(base_store_favs[1]); |
|
263 |
favs.push_back(other_desktop); |
|
264 |
favs.push_back(base_store_favs[2]); |
|
55.2046.1
by Marco Trevisan (Treviño)
test_favorite_store_gsettings: refactored to use gsettings memory backend |
265 |
favorite_store->SaveFavorites(favs, false); |
55.1778.3
by Thomi Richards
Fixed favoritestore unit tests. |
266 |
|
55.1362.5
by Andrea Azzarone
Add signals tests. |
267 |
ASSERT_TRUE(signal_received); |
268 |
EXPECT_EQ(position, base_store_favs[1]); |
|
269 |
EXPECT_FALSE(before); |
|
270 |
}
|
|
271 |
||
272 |
TEST_F(TestFavoriteStoreGSettings, TestFavoriteAddedSignalEnd) |
|
273 |
{
|
|
55.1778.3
by Thomi Richards
Fixed favoritestore unit tests. |
274 |
FavoriteStore &settings = FavoriteStore::Instance(); |
55.1362.5
by Andrea Azzarone
Add signals tests. |
275 |
bool signal_received = false; |
276 |
std::string position; |
|
277 |
bool before = true; |
|
55.1778.3
by Thomi Richards
Fixed favoritestore unit tests. |
278 |
|
55.1362.5
by Andrea Azzarone
Add signals tests. |
279 |
settings.favorite_added.connect([&](std::string const& path, std::string const& pos, bool bef) |
280 |
{
|
|
281 |
signal_received = true; |
|
282 |
position = pos; |
|
283 |
before = bef; |
|
284 |
});
|
|
55.1778.3
by Thomi Richards
Fixed favoritestore unit tests. |
285 |
|
55.1362.5
by Andrea Azzarone
Add signals tests. |
286 |
FavoriteList favs; |
287 |
favs.push_back(base_store_favs[0]); |
|
288 |
favs.push_back(base_store_favs[1]); |
|
289 |
favs.push_back(base_store_favs[2]); |
|
290 |
favs.push_back(other_desktop); |
|
55.2046.1
by Marco Trevisan (Treviño)
test_favorite_store_gsettings: refactored to use gsettings memory backend |
291 |
favorite_store->SaveFavorites(favs, false); |
55.1778.3
by Thomi Richards
Fixed favoritestore unit tests. |
292 |
|
55.1362.5
by Andrea Azzarone
Add signals tests. |
293 |
ASSERT_TRUE(signal_received); |
294 |
EXPECT_EQ(position, base_store_favs[2]); |
|
295 |
EXPECT_FALSE(before); |
|
296 |
}
|
|
297 |
||
298 |
TEST_F(TestFavoriteStoreGSettings, TestFavoriteAddedSignalEmpty) |
|
299 |
{
|
|
55.1778.3
by Thomi Richards
Fixed favoritestore unit tests. |
300 |
FavoriteStore &settings = FavoriteStore::Instance(); |
55.1362.5
by Andrea Azzarone
Add signals tests. |
301 |
bool signal_received = false; |
302 |
std::string position; |
|
303 |
bool before = false; |
|
55.1778.3
by Thomi Richards
Fixed favoritestore unit tests. |
304 |
|
55.1362.5
by Andrea Azzarone
Add signals tests. |
305 |
settings.favorite_added.connect([&](std::string const& path, std::string const& pos, bool bef) |
306 |
{
|
|
307 |
signal_received = true; |
|
308 |
position = pos; |
|
309 |
before = bef; |
|
310 |
});
|
|
55.1778.3
by Thomi Richards
Fixed favoritestore unit tests. |
311 |
|
55.1362.5
by Andrea Azzarone
Add signals tests. |
312 |
FavoriteList favs; |
313 |
favs.push_back(other_desktop); |
|
55.2046.1
by Marco Trevisan (Treviño)
test_favorite_store_gsettings: refactored to use gsettings memory backend |
314 |
favorite_store->SaveFavorites(favs, false); |
55.1778.3
by Thomi Richards
Fixed favoritestore unit tests. |
315 |
|
55.1362.5
by Andrea Azzarone
Add signals tests. |
316 |
ASSERT_TRUE(signal_received); |
317 |
EXPECT_EQ(position, ""); |
|
318 |
EXPECT_TRUE(before); |
|
319 |
}
|
|
320 |
||
321 |
TEST_F(TestFavoriteStoreGSettings, TestFavoriteRemoved) |
|
322 |
{
|
|
55.1778.3
by Thomi Richards
Fixed favoritestore unit tests. |
323 |
FavoriteStore &settings = FavoriteStore::Instance(); |
55.1362.5
by Andrea Azzarone
Add signals tests. |
324 |
bool signal_received = false; |
325 |
std::string path_removed; |
|
55.1778.3
by Thomi Richards
Fixed favoritestore unit tests. |
326 |
|
55.1362.5
by Andrea Azzarone
Add signals tests. |
327 |
settings.favorite_removed.connect([&](std::string const& path) |
328 |
{
|
|
329 |
signal_received = true; |
|
330 |
path_removed = path; |
|
331 |
});
|
|
55.1778.3
by Thomi Richards
Fixed favoritestore unit tests. |
332 |
|
55.1362.5
by Andrea Azzarone
Add signals tests. |
333 |
FavoriteList favs; |
334 |
favs.push_back(base_store_favs[0]); |
|
335 |
favs.push_back(base_store_favs[2]); |
|
55.2046.1
by Marco Trevisan (Treviño)
test_favorite_store_gsettings: refactored to use gsettings memory backend |
336 |
favorite_store->SaveFavorites(favs, false); |
55.1778.3
by Thomi Richards
Fixed favoritestore unit tests. |
337 |
|
55.1362.5
by Andrea Azzarone
Add signals tests. |
338 |
ASSERT_TRUE(signal_received); |
339 |
EXPECT_EQ(path_removed, base_store_favs[1]); |
|
340 |
}
|
|
341 |
||
342 |
TEST_F(TestFavoriteStoreGSettings, TestFavoriteReordered) |
|
343 |
{
|
|
55.1778.3
by Thomi Richards
Fixed favoritestore unit tests. |
344 |
FavoriteStore &settings = FavoriteStore::Instance(); |
55.1362.5
by Andrea Azzarone
Add signals tests. |
345 |
bool signal_received = false; |
55.1778.3
by Thomi Richards
Fixed favoritestore unit tests. |
346 |
|
55.1362.5
by Andrea Azzarone
Add signals tests. |
347 |
settings.reordered.connect([&]() |
348 |
{
|
|
349 |
signal_received = true; |
|
350 |
});
|
|
55.1778.3
by Thomi Richards
Fixed favoritestore unit tests. |
351 |
|
55.1362.5
by Andrea Azzarone
Add signals tests. |
352 |
FavoriteList favs; |
353 |
favs.push_back(base_store_favs[0]); |
|
354 |
favs.push_back(base_store_favs[2]); |
|
355 |
favs.push_back(base_store_favs[1]); |
|
55.2046.1
by Marco Trevisan (Treviño)
test_favorite_store_gsettings: refactored to use gsettings memory backend |
356 |
favorite_store->SaveFavorites(favs, false); |
55.1778.3
by Thomi Richards
Fixed favoritestore unit tests. |
357 |
|
55.1362.5
by Andrea Azzarone
Add signals tests. |
358 |
ASSERT_TRUE(signal_received); |
55.1778.3
by Thomi Richards
Fixed favoritestore unit tests. |
359 |
|
55.1362.5
by Andrea Azzarone
Add signals tests. |
360 |
signal_received = false; |
361 |
favs.push_back(base_store_favs[0]); |
|
362 |
favs.push_back(base_store_favs[2]); |
|
363 |
favs.push_back(base_store_favs[1]); |
|
55.2046.1
by Marco Trevisan (Treviño)
test_favorite_store_gsettings: refactored to use gsettings memory backend |
364 |
favorite_store->SaveFavorites(favs, false); |
55.1778.3
by Thomi Richards
Fixed favoritestore unit tests. |
365 |
|
55.1362.5
by Andrea Azzarone
Add signals tests. |
366 |
ASSERT_FALSE(signal_received); |
367 |
}
|
|
368 |
||
369 |
TEST_F(TestFavoriteStoreGSettings, TestFavoriteSignalsMixed1) |
|
370 |
{
|
|
55.1778.3
by Thomi Richards
Fixed favoritestore unit tests. |
371 |
FavoriteStore &settings = FavoriteStore::Instance(); |
55.1362.5
by Andrea Azzarone
Add signals tests. |
372 |
bool added_received = false; |
373 |
bool removed_received = false; |
|
374 |
bool reordered_received = false; |
|
55.1778.3
by Thomi Richards
Fixed favoritestore unit tests. |
375 |
|
55.1362.5
by Andrea Azzarone
Add signals tests. |
376 |
settings.favorite_added.connect([&](std::string const& path, std::string const& pos, bool bef) |
377 |
{
|
|
378 |
added_received = true; |
|
379 |
});
|
|
55.1778.3
by Thomi Richards
Fixed favoritestore unit tests. |
380 |
|
55.1362.5
by Andrea Azzarone
Add signals tests. |
381 |
settings.favorite_removed.connect([&](std::string const& path) |
382 |
{
|
|
383 |
removed_received = true; |
|
384 |
});
|
|
55.1778.3
by Thomi Richards
Fixed favoritestore unit tests. |
385 |
|
55.1362.5
by Andrea Azzarone
Add signals tests. |
386 |
settings.reordered.connect([&]() |
387 |
{
|
|
388 |
reordered_received = true; |
|
389 |
});
|
|
55.1778.3
by Thomi Richards
Fixed favoritestore unit tests. |
390 |
|
55.1362.5
by Andrea Azzarone
Add signals tests. |
391 |
FavoriteList favs; |
392 |
favs.push_back(base_store_favs[0]); |
|
393 |
favs.push_back(base_store_favs[1]); |
|
394 |
favs.push_back(other_desktop); |
|
55.2046.1
by Marco Trevisan (Treviño)
test_favorite_store_gsettings: refactored to use gsettings memory backend |
395 |
favorite_store->SaveFavorites(favs, false); |
55.1778.3
by Thomi Richards
Fixed favoritestore unit tests. |
396 |
|
55.1362.5
by Andrea Azzarone
Add signals tests. |
397 |
EXPECT_TRUE(added_received); |
398 |
EXPECT_TRUE(removed_received); |
|
399 |
EXPECT_FALSE(reordered_received); |
|
400 |
}
|
|
401 |
||
402 |
TEST_F(TestFavoriteStoreGSettings, TestFavoriteSignalsMixed2) |
|
403 |
{
|
|
55.1778.3
by Thomi Richards
Fixed favoritestore unit tests. |
404 |
FavoriteStore &settings = FavoriteStore::Instance(); |
55.1362.5
by Andrea Azzarone
Add signals tests. |
405 |
bool added_received = false; |
406 |
bool removed_received = false; |
|
407 |
bool reordered_received = false; |
|
55.1778.3
by Thomi Richards
Fixed favoritestore unit tests. |
408 |
|
55.1362.5
by Andrea Azzarone
Add signals tests. |
409 |
settings.favorite_added.connect([&](std::string const& path, std::string const& pos, bool bef) |
410 |
{
|
|
411 |
added_received = true; |
|
412 |
});
|
|
55.1778.3
by Thomi Richards
Fixed favoritestore unit tests. |
413 |
|
55.1362.5
by Andrea Azzarone
Add signals tests. |
414 |
settings.favorite_removed.connect([&](std::string const& path) |
415 |
{
|
|
416 |
removed_received = true; |
|
417 |
});
|
|
55.1778.3
by Thomi Richards
Fixed favoritestore unit tests. |
418 |
|
55.1362.5
by Andrea Azzarone
Add signals tests. |
419 |
settings.reordered.connect([&]() |
420 |
{
|
|
421 |
reordered_received = true; |
|
422 |
});
|
|
55.1778.3
by Thomi Richards
Fixed favoritestore unit tests. |
423 |
|
55.1362.5
by Andrea Azzarone
Add signals tests. |
424 |
FavoriteList favs; |
425 |
favs.push_back(base_store_favs[1]); |
|
426 |
favs.push_back(other_desktop); |
|
427 |
favs.push_back(base_store_favs[0]); |
|
55.2046.1
by Marco Trevisan (Treviño)
test_favorite_store_gsettings: refactored to use gsettings memory backend |
428 |
favorite_store->SaveFavorites(favs, false); |
55.1778.3
by Thomi Richards
Fixed favoritestore unit tests. |
429 |
|
55.1362.5
by Andrea Azzarone
Add signals tests. |
430 |
EXPECT_TRUE(added_received); |
431 |
EXPECT_TRUE(removed_received); |
|
432 |
EXPECT_TRUE(reordered_received); |
|
433 |
}
|
|
434 |
||
435 |
TEST_F(TestFavoriteStoreGSettings, TestFavoriteSignalsMixed3) |
|
436 |
{
|
|
55.1778.3
by Thomi Richards
Fixed favoritestore unit tests. |
437 |
FavoriteStore &settings = FavoriteStore::Instance(); |
55.1362.5
by Andrea Azzarone
Add signals tests. |
438 |
bool added_received = false; |
439 |
bool removed_received = false; |
|
440 |
bool reordered_received = false; |
|
55.1778.3
by Thomi Richards
Fixed favoritestore unit tests. |
441 |
|
55.1362.5
by Andrea Azzarone
Add signals tests. |
442 |
settings.favorite_added.connect([&](std::string const& path, std::string const& pos, bool bef) |
443 |
{
|
|
444 |
added_received = true; |
|
445 |
});
|
|
55.1778.3
by Thomi Richards
Fixed favoritestore unit tests. |
446 |
|
55.1362.5
by Andrea Azzarone
Add signals tests. |
447 |
settings.favorite_removed.connect([&](std::string const& path) |
448 |
{
|
|
449 |
removed_received = true; |
|
450 |
});
|
|
55.1778.3
by Thomi Richards
Fixed favoritestore unit tests. |
451 |
|
55.1362.5
by Andrea Azzarone
Add signals tests. |
452 |
settings.reordered.connect([&]() |
453 |
{
|
|
454 |
reordered_received = true; |
|
455 |
});
|
|
55.1778.3
by Thomi Richards
Fixed favoritestore unit tests. |
456 |
|
55.1362.5
by Andrea Azzarone
Add signals tests. |
457 |
FavoriteList favs; |
458 |
favs.push_back(base_store_favs[1]); |
|
459 |
favs.push_back(base_store_favs[0]); |
|
55.2046.1
by Marco Trevisan (Treviño)
test_favorite_store_gsettings: refactored to use gsettings memory backend |
460 |
favorite_store->SaveFavorites(favs, false); |
55.1778.3
by Thomi Richards
Fixed favoritestore unit tests. |
461 |
|
55.1362.5
by Andrea Azzarone
Add signals tests. |
462 |
EXPECT_FALSE(added_received); |
463 |
EXPECT_TRUE(removed_received); |
|
464 |
EXPECT_TRUE(reordered_received); |
|
465 |
}
|
|
55.884.1
by Andrea Azzarone
Porting of TestFavoriteStoreGSettings to Google Test. |
466 |
|
467 |
} // anonymous namespace |