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

Proposed by Khurshid Alam
Status: Merged
Approved by: Iain Lane
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
Sebastien Bacher 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.
Revision history for this message
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
=== modified file 'test/vala/test-diff.vala'
--- test/vala/test-diff.vala 2013-07-09 13:35:25 +0000
+++ test/vala/test-diff.vala 2019-03-18 15:10:29 +0000
@@ -50,13 +50,13 @@
50 Fixture.create<DiffTester> (DiffTester.test_mixed));50 Fixture.create<DiffTester> (DiffTester.test_mixed));
5151
52 GLib.Test.add_data_func ("/Unit/DiffModel/Populate",52 GLib.Test.add_data_func ("/Unit/DiffModel/Populate",
53 Fixture.create<DiffModelTester> (DiffModelTester.test_populate));53 Fixture.create<DiffModelTester0> (DiffModelTester0.test_populate));
54 GLib.Test.add_data_func ("/Unit/DiffModel/Clear",54 GLib.Test.add_data_func ("/Unit/DiffModel/Clear",
55 Fixture.create<DiffModelTester> (DiffModelTester.test_clear));55 Fixture.create<DiffModelTester1> (DiffModelTester1.test_clear));
56 GLib.Test.add_data_func ("/Unit/DiffModel/Mixed",56 GLib.Test.add_data_func ("/Unit/DiffModel/Mixed",
57 Fixture.create<DiffModelTester> (DiffModelTester.test_mixed));57 Fixture.create<DiffModelTester2> (DiffModelTester2.test_mixed));
58 GLib.Test.add_data_func ("/Unit/DiffModel/ChangedMetadata",58 GLib.Test.add_data_func ("/Unit/DiffModel/ChangedMetadata",
59 Fixture.create<DiffModelTester> (DiffModelTester.test_metadata));59 Fixture.create<DiffModelTester3> (DiffModelTester3.test_metadata));
60 }60 }
6161
62 class DiffTester: Object, Fixture62 class DiffTester: Object, Fixture
@@ -340,7 +340,7 @@
340 }340 }
341 }341 }
342342
343 class DiffModelTester: Object, Fixture343 class DiffModelTester0: Object, Fixture
344 {344 {
345 private Unity.Internal.DiffModel? model;345 private Unity.Internal.DiffModel? model;
346 private Dee.SequenceModel? backend_model;346 private Dee.SequenceModel? backend_model;
@@ -353,7 +353,7 @@
353 backend_model.set_schema_full (RESULTS_SCHEMA);353 backend_model.set_schema_full (RESULTS_SCHEMA);
354 backend_model.set_column_names_full (RESULTS_COLUMN_NAMES);354 backend_model.set_column_names_full (RESULTS_COLUMN_NAMES);
355355
356 var peer = new Dee.Server ("com.canonical.Libunity.Test");356 var peer = new Dee.Server ("com.canonical.Libunity.Test0");
357 model = new Unity.Internal.DiffModel (peer, backend_model);357 model = new Unity.Internal.DiffModel (peer, backend_model);
358 model.set_schema_full (RESULTS_SCHEMA);358 model.set_schema_full (RESULTS_SCHEMA);
359 model.set_column_names_full (RESULTS_COLUMN_NAMES);359 model.set_column_names_full (RESULTS_COLUMN_NAMES);
@@ -407,6 +407,51 @@
407 assert (rows_added == 4);407 assert (rows_added == 4);
408 assert (rows_removed == 0);408 assert (rows_removed == 0);
409 }409 }
410 }
411
412 class DiffModelTester1: Object, Fixture
413 {
414 private Unity.Internal.DiffModel? model;
415 private Dee.SequenceModel? backend_model;
416 private uint rows_added;
417 private uint rows_removed;
418
419 private void setup ()
420 {
421 backend_model = new Dee.SequenceModel ();
422 backend_model.set_schema_full (RESULTS_SCHEMA);
423 backend_model.set_column_names_full (RESULTS_COLUMN_NAMES);
424 var peer = new Dee.Server ("com.canonical.Libunity.Test1");
425 model = new Unity.Internal.DiffModel (peer, backend_model);
426 model.set_schema_full (RESULTS_SCHEMA);
427 model.set_column_names_full (RESULTS_COLUMN_NAMES);
428 model.row_added.connect (() => { rows_added++; });
429 model.row_removed.connect (() => { rows_removed++; });
430
431 var ml = new MainLoop ();
432 Utils.wait_for_model_synchronization (model, (obj, res) =>
433 {
434 ml.quit ();
435 });
436 assert (run_with_timeout (ml));
437 }
438
439 private void teardown ()
440 {
441 model = null;
442 backend_model = null;
443 }
444
445 private void add_sample_result (
446 string uri,
447 uint category,
448 HashTable<string, Variant>? metadata = null)
449 {
450 Variant metadata_v = metadata != null ?
451 metadata : new Variant.array (VariantType.VARDICT.element (), {});
452 backend_model.append (uri, "icon", category, 0, "text/plain",
453 Path.get_basename (uri), "", uri, metadata_v);
454 }
410455
411 public void test_clear ()456 public void test_clear ()
412 {457 {
@@ -431,6 +476,52 @@
431 assert (rows_added == 0);476 assert (rows_added == 0);
432 assert (rows_removed == 6);477 assert (rows_removed == 6);
433 }478 }
479 }
480
481 class DiffModelTester2: Object, Fixture
482 {
483 private Unity.Internal.DiffModel? model;
484 private Dee.SequenceModel? backend_model;
485 private uint rows_added;
486 private uint rows_removed;
487
488 private void setup ()
489 {
490 backend_model = new Dee.SequenceModel ();
491 backend_model.set_schema_full (RESULTS_SCHEMA);
492 backend_model.set_column_names_full (RESULTS_COLUMN_NAMES);
493
494 var peer = new Dee.Server ("com.canonical.Libunity.Test2");
495 model = new Unity.Internal.DiffModel (peer, backend_model);
496 model.set_schema_full (RESULTS_SCHEMA);
497 model.set_column_names_full (RESULTS_COLUMN_NAMES);
498 model.row_added.connect (() => { rows_added++; });
499 model.row_removed.connect (() => { rows_removed++; });
500
501 var ml = new MainLoop ();
502 Utils.wait_for_model_synchronization (model, (obj, res) =>
503 {
504 ml.quit ();
505 });
506 assert (run_with_timeout (ml));
507 }
508
509 private void teardown ()
510 {
511 model = null;
512 backend_model = null;
513 }
514
515 private void add_sample_result (
516 string uri,
517 uint category,
518 HashTable<string, Variant>? metadata = null)
519 {
520 Variant metadata_v = metadata != null ?
521 metadata : new Variant.array (VariantType.VARDICT.element (), {});
522 backend_model.append (uri, "icon", category, 0, "text/plain",
523 Path.get_basename (uri), "", uri, metadata_v);
524 }
434525
435 public void test_mixed ()526 public void test_mixed ()
436 {527 {
@@ -470,7 +561,53 @@
470 assert (row[ResultColumn.CATEGORY].equal (orig_row[ResultColumn.CATEGORY]));561 assert (row[ResultColumn.CATEGORY].equal (orig_row[ResultColumn.CATEGORY]));
471 }562 }
472 }563 }
473564 }
565
566 class DiffModelTester3: Object, Fixture
567 {
568 private Unity.Internal.DiffModel? model;
569 private Dee.SequenceModel? backend_model;
570 private uint rows_added;
571 private uint rows_removed;
572
573 private void setup ()
574 {
575 backend_model = new Dee.SequenceModel ();
576 backend_model.set_schema_full (RESULTS_SCHEMA);
577 backend_model.set_column_names_full (RESULTS_COLUMN_NAMES);
578
579 var peer = new Dee.Server ("com.canonical.Libunity.Test3");
580 model = new Unity.Internal.DiffModel (peer, backend_model);
581 model.set_schema_full (RESULTS_SCHEMA);
582 model.set_column_names_full (RESULTS_COLUMN_NAMES);
583 model.row_added.connect (() => { rows_added++; });
584 model.row_removed.connect (() => { rows_removed++; });
585
586 var ml = new MainLoop ();
587 Utils.wait_for_model_synchronization (model, (obj, res) =>
588 {
589 ml.quit ();
590 });
591 assert (run_with_timeout (ml));
592 }
593
594 private void teardown ()
595 {
596 model = null;
597 backend_model = null;
598 }
599
600 private void add_sample_result (
601 string uri,
602 uint category,
603 HashTable<string, Variant>? metadata = null)
604 {
605 Variant metadata_v = metadata != null ?
606 metadata : new Variant.array (VariantType.VARDICT.element (), {});
607 backend_model.append (uri, "icon", category, 0, "text/plain",
608 Path.get_basename (uri), "", uri, metadata_v);
609 }
610
474 public void test_metadata ()611 public void test_metadata ()
475 {612 {
476 var metadata = new HashTable<string, Variant> (str_hash, str_equal);613 var metadata = new HashTable<string, Variant> (str_hash, str_equal);

Subscribers

People subscribed via source and target branches