Merge lp:~khurshid-alam/libunity/glib-2.59.3 into lp:libunity

Proposed by Khurshid Alam on 2019-03-18
Status: Merged
Approved by: Iain Lane on 2019-03-19
Approved revision: 335
Merged at revision: 335
Proposed branch: lp:~khurshid-alam/libunity/glib-2.59.3
Merge into: lp:libunity
Prerequisite: lp:~ricotz/libunity/syntax-fixes
Diff against target: 199 lines (+144/-7)
1 file modified
test/vala/test-diff.vala (+144/-7)
To merge this branch: bzr merge lp:~khurshid-alam/libunity/glib-2.59.3
Reviewer Review Type Date Requested Status
Iain Lane Approve on 2019-03-19
Sebastien Bacher 2019-03-18 Pending
Review via email: mp+364679@code.launchpad.net

Commit message

Fix diffmodel tests against glib 2.59.3

With glib 2.59.3, dee server can't to bind to a address which is already in use. Instead use different address for each diffmodel tests.

See https://gitlab.gnome.org/GNOME/glib/merge_requests/509

Description of the change

Note: I used this fix on top of lp:~ricotz/libunity/syntax-fixes

To post a comment you must log in.
Iain Lane (laney) wrote :

Wonder if it'd be possible to reduce the duplication, but OK

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'test/vala/test-diff.vala'
2--- test/vala/test-diff.vala 2013-07-09 13:35:25 +0000
3+++ test/vala/test-diff.vala 2019-03-18 15:10:29 +0000
4@@ -50,13 +50,13 @@
5 Fixture.create<DiffTester> (DiffTester.test_mixed));
6
7 GLib.Test.add_data_func ("/Unit/DiffModel/Populate",
8- Fixture.create<DiffModelTester> (DiffModelTester.test_populate));
9+ Fixture.create<DiffModelTester0> (DiffModelTester0.test_populate));
10 GLib.Test.add_data_func ("/Unit/DiffModel/Clear",
11- Fixture.create<DiffModelTester> (DiffModelTester.test_clear));
12+ Fixture.create<DiffModelTester1> (DiffModelTester1.test_clear));
13 GLib.Test.add_data_func ("/Unit/DiffModel/Mixed",
14- Fixture.create<DiffModelTester> (DiffModelTester.test_mixed));
15+ Fixture.create<DiffModelTester2> (DiffModelTester2.test_mixed));
16 GLib.Test.add_data_func ("/Unit/DiffModel/ChangedMetadata",
17- Fixture.create<DiffModelTester> (DiffModelTester.test_metadata));
18+ Fixture.create<DiffModelTester3> (DiffModelTester3.test_metadata));
19 }
20
21 class DiffTester: Object, Fixture
22@@ -340,7 +340,7 @@
23 }
24 }
25
26- class DiffModelTester: Object, Fixture
27+ class DiffModelTester0: Object, Fixture
28 {
29 private Unity.Internal.DiffModel? model;
30 private Dee.SequenceModel? backend_model;
31@@ -353,7 +353,7 @@
32 backend_model.set_schema_full (RESULTS_SCHEMA);
33 backend_model.set_column_names_full (RESULTS_COLUMN_NAMES);
34
35- var peer = new Dee.Server ("com.canonical.Libunity.Test");
36+ var peer = new Dee.Server ("com.canonical.Libunity.Test0");
37 model = new Unity.Internal.DiffModel (peer, backend_model);
38 model.set_schema_full (RESULTS_SCHEMA);
39 model.set_column_names_full (RESULTS_COLUMN_NAMES);
40@@ -407,6 +407,51 @@
41 assert (rows_added == 4);
42 assert (rows_removed == 0);
43 }
44+ }
45+
46+ class DiffModelTester1: Object, Fixture
47+ {
48+ private Unity.Internal.DiffModel? model;
49+ private Dee.SequenceModel? backend_model;
50+ private uint rows_added;
51+ private uint rows_removed;
52+
53+ private void setup ()
54+ {
55+ backend_model = new Dee.SequenceModel ();
56+ backend_model.set_schema_full (RESULTS_SCHEMA);
57+ backend_model.set_column_names_full (RESULTS_COLUMN_NAMES);
58+ var peer = new Dee.Server ("com.canonical.Libunity.Test1");
59+ model = new Unity.Internal.DiffModel (peer, backend_model);
60+ model.set_schema_full (RESULTS_SCHEMA);
61+ model.set_column_names_full (RESULTS_COLUMN_NAMES);
62+ model.row_added.connect (() => { rows_added++; });
63+ model.row_removed.connect (() => { rows_removed++; });
64+
65+ var ml = new MainLoop ();
66+ Utils.wait_for_model_synchronization (model, (obj, res) =>
67+ {
68+ ml.quit ();
69+ });
70+ assert (run_with_timeout (ml));
71+ }
72+
73+ private void teardown ()
74+ {
75+ model = null;
76+ backend_model = null;
77+ }
78+
79+ private void add_sample_result (
80+ string uri,
81+ uint category,
82+ HashTable<string, Variant>? metadata = null)
83+ {
84+ Variant metadata_v = metadata != null ?
85+ metadata : new Variant.array (VariantType.VARDICT.element (), {});
86+ backend_model.append (uri, "icon", category, 0, "text/plain",
87+ Path.get_basename (uri), "", uri, metadata_v);
88+ }
89
90 public void test_clear ()
91 {
92@@ -431,6 +476,52 @@
93 assert (rows_added == 0);
94 assert (rows_removed == 6);
95 }
96+ }
97+
98+ class DiffModelTester2: Object, Fixture
99+ {
100+ private Unity.Internal.DiffModel? model;
101+ private Dee.SequenceModel? backend_model;
102+ private uint rows_added;
103+ private uint rows_removed;
104+
105+ private void setup ()
106+ {
107+ backend_model = new Dee.SequenceModel ();
108+ backend_model.set_schema_full (RESULTS_SCHEMA);
109+ backend_model.set_column_names_full (RESULTS_COLUMN_NAMES);
110+
111+ var peer = new Dee.Server ("com.canonical.Libunity.Test2");
112+ model = new Unity.Internal.DiffModel (peer, backend_model);
113+ model.set_schema_full (RESULTS_SCHEMA);
114+ model.set_column_names_full (RESULTS_COLUMN_NAMES);
115+ model.row_added.connect (() => { rows_added++; });
116+ model.row_removed.connect (() => { rows_removed++; });
117+
118+ var ml = new MainLoop ();
119+ Utils.wait_for_model_synchronization (model, (obj, res) =>
120+ {
121+ ml.quit ();
122+ });
123+ assert (run_with_timeout (ml));
124+ }
125+
126+ private void teardown ()
127+ {
128+ model = null;
129+ backend_model = null;
130+ }
131+
132+ private void add_sample_result (
133+ string uri,
134+ uint category,
135+ HashTable<string, Variant>? metadata = null)
136+ {
137+ Variant metadata_v = metadata != null ?
138+ metadata : new Variant.array (VariantType.VARDICT.element (), {});
139+ backend_model.append (uri, "icon", category, 0, "text/plain",
140+ Path.get_basename (uri), "", uri, metadata_v);
141+ }
142
143 public void test_mixed ()
144 {
145@@ -470,7 +561,53 @@
146 assert (row[ResultColumn.CATEGORY].equal (orig_row[ResultColumn.CATEGORY]));
147 }
148 }
149-
150+ }
151+
152+ class DiffModelTester3: Object, Fixture
153+ {
154+ private Unity.Internal.DiffModel? model;
155+ private Dee.SequenceModel? backend_model;
156+ private uint rows_added;
157+ private uint rows_removed;
158+
159+ private void setup ()
160+ {
161+ backend_model = new Dee.SequenceModel ();
162+ backend_model.set_schema_full (RESULTS_SCHEMA);
163+ backend_model.set_column_names_full (RESULTS_COLUMN_NAMES);
164+
165+ var peer = new Dee.Server ("com.canonical.Libunity.Test3");
166+ model = new Unity.Internal.DiffModel (peer, backend_model);
167+ model.set_schema_full (RESULTS_SCHEMA);
168+ model.set_column_names_full (RESULTS_COLUMN_NAMES);
169+ model.row_added.connect (() => { rows_added++; });
170+ model.row_removed.connect (() => { rows_removed++; });
171+
172+ var ml = new MainLoop ();
173+ Utils.wait_for_model_synchronization (model, (obj, res) =>
174+ {
175+ ml.quit ();
176+ });
177+ assert (run_with_timeout (ml));
178+ }
179+
180+ private void teardown ()
181+ {
182+ model = null;
183+ backend_model = null;
184+ }
185+
186+ private void add_sample_result (
187+ string uri,
188+ uint category,
189+ HashTable<string, Variant>? metadata = null)
190+ {
191+ Variant metadata_v = metadata != null ?
192+ metadata : new Variant.array (VariantType.VARDICT.element (), {});
193+ backend_model.append (uri, "icon", category, 0, "text/plain",
194+ Path.get_basename (uri), "", uri, metadata_v);
195+ }
196+
197 public void test_metadata ()
198 {
199 var metadata = new HashTable<string, Variant> (str_hash, str_equal);

Subscribers

People subscribed via source and target branches