2
* Copyright (C) 2011 Collabora Ltd.
4
* This library is free software: you can redistribute it and/or modify
5
* it under the terms of the GNU Lesser General Public License as published by
6
* the Free Software Foundation, either version 2.1 of the License, or
7
* (at your option) any later version.
9
* This library 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 Lesser General Public License for more details.
14
* You should have received a copy of the GNU Lesser General Public License
15
* along with this library. If not, see <http://www.gnu.org/licenses/>.
17
* Authors: Raul Gutierrez Segales <raul.gutierrez.segales@collabora.co.uk>
26
public class FavouriteDetailsInterfaceTests : Folks.TestCase
28
private TrackerTest.Backend _tracker_backend;
29
private GLib.MainLoop _main_loop;
30
private string _fullname_p1;
31
private string _fullname_p2;
32
private string _fullname_p3;
33
private bool _found_p1;
34
private bool _found_p2;
35
private bool _found_p3;
36
private IndividualAggregator _aggregator;
38
public FavouriteDetailsInterfaceTests ()
40
base ("FavouriteDetailsInterfaceTests");
42
this._tracker_backend = new TrackerTest.Backend ();
44
this.add_test ("test favourite details interface",
45
this.test_favourite_details_interface);
48
public override void set_up ()
52
public override void tear_down ()
56
public void test_favourite_details_interface ()
58
this._main_loop = new GLib.MainLoop (null, false);
59
Gee.HashMap<string, string> c1 = new Gee.HashMap<string, string> ();
60
Gee.HashMap<string, string> c2 = new Gee.HashMap<string, string> ();
61
Gee.HashMap<string, string> c3 = new Gee.HashMap<string, string> ();
62
this._fullname_p1 = "favourite persona #1";
63
this._fullname_p2 = "favourite persona #2";
64
this._fullname_p3 = "favourite persona #3";
66
c1.set (Trf.OntologyDefs.NCO_FULLNAME, this._fullname_p1);
67
c1.set (Trf.OntologyDefs.NAO_TAG, "");
68
this._tracker_backend.add_contact (c1);
70
c2.set (Trf.OntologyDefs.NCO_FULLNAME, this._fullname_p2);
71
c2.set (Trf.OntologyDefs.NAO_TAG, "");
72
this._tracker_backend.add_contact (c2);
74
c3.set (Trf.OntologyDefs.NCO_FULLNAME, this._fullname_p3);
75
this._tracker_backend.add_contact (c3);
77
this._tracker_backend.set_up ();
79
this._found_p1 = false;
80
this._found_p2 = false;
81
this._found_p3 = false;
83
this._test_favourite_details_interface_async ();
85
Timeout.add_seconds (5, () =>
87
this._main_loop.quit ();
91
this._main_loop.run ();
93
assert (this._found_p1 == true);
94
assert (this._found_p2 == true);
95
assert (this._found_p3 == true);
97
this._tracker_backend.tear_down ();
100
private async void _test_favourite_details_interface_async ()
102
var store = BackendStore.dup ();
103
yield store.prepare ();
104
this._aggregator = new IndividualAggregator ();
105
this._aggregator.individuals_changed.connect
106
(this._individuals_changed_cb);
109
yield this._aggregator.prepare ();
113
GLib.warning ("Error when calling prepare: %s\n", e.message);
117
private void _individuals_changed_cb
118
(Set<Individual> added,
119
Set<Individual> removed,
122
GroupDetails.ChangeReason reason)
124
foreach (var i in added)
126
string full_name = i.full_name;
127
if (full_name != null)
129
if (full_name == this._fullname_p1)
131
assert (i.is_favourite == true);
132
this._found_p1 = true;
134
else if (full_name == this._fullname_p2)
136
assert (i.is_favourite == true);
137
this._found_p2 = true;
139
else if (full_name == this._fullname_p3)
141
assert (i.is_favourite == false);
142
this._found_p3 = true;
147
assert (removed.size == 0);
149
if (this._found_p1 &&
152
this._main_loop.quit ();
156
public int main (string[] args)
158
Test.init (ref args);
160
TestSuite root = TestSuite.get_root ();
161
root.add_suite (new FavouriteDetailsInterfaceTests ().get_suite ());