~ubuntu-branches/ubuntu/precise/folks/precise

« back to all changes in this revision

Viewing changes to tests/folks/aggregation.vala

  • Committer: Bazaar Package Importer
  • Author(s): Ken VanDine
  • Date: 2011-06-10 11:28:11 UTC
  • mfrom: (1.2.11 upstream) (4.2.1 experimental)
  • Revision ID: james.westby@ubuntu.com-20110610112811-whyeodbo9mjezxfp
Tags: 0.5.2-1ubuntu1
* Merge with Debian experimental, remaining Ubuntu changes:
  - debian/control:
    + Add Vcs-Bzr link

Show diffs side-by-side

added added

removed removed

Lines of Context:
7
7
  private KfTest.Backend _kf_backend;
8
8
  private TpTest.Backend _tp_backend;
9
9
  private HashSet<string> _default_individuals;
10
 
  private string _individual_id_prefix = "telepathy:protocol:";
11
10
  private int _test_timeout = 3;
12
11
 
13
12
  public AggregationTests ()
81
80
      HashSet<string> expected_individuals = new HashSet<string> ();
82
81
      foreach (var id in this._default_individuals)
83
82
        {
84
 
          expected_individuals.add (this._individual_id_prefix + id);
 
83
          expected_individuals.add (id);
85
84
        }
86
85
 
87
86
      /* Set up the aggregator */
92
91
           * individuals (if they were originally on it) */
93
92
          foreach (Individual i in removed)
94
93
            {
 
94
              var parts = i.id.split (":");
 
95
              var id = parts[2];
 
96
 
95
97
              if (!i.is_user &&
96
 
                  i.personas.length () == 2 &&
97
 
                  this._default_individuals.contains (i.id))
 
98
                  i.personas.size == 2 &&
 
99
                  this._default_individuals.contains (id))
98
100
                {
99
 
                  expected_individuals.add (i.id);
 
101
                  expected_individuals.add (id);
100
102
                }
101
103
            }
102
104
 
104
106
           * from the set of expected individuals. */
105
107
          foreach (Individual i in added)
106
108
            {
107
 
              unowned GLib.List<Persona> personas = i.personas;
 
109
              var parts = i.id.split (":");
 
110
              var id = parts[2];
 
111
 
 
112
              var personas = i.personas;
108
113
 
109
114
              /* We're not testing the user here */
110
 
              if (!i.is_user && personas.length () == 2)
 
115
              if (!i.is_user && personas.size == 2)
111
116
                {
112
 
                  assert (expected_individuals.remove (i.id));
113
 
                  assert (personas.data.iid == personas.next.data.iid);
 
117
                  assert (expected_individuals.remove (id));
 
118
 
 
119
                  string iid = null;
 
120
                  foreach (var persona in personas)
 
121
                    {
 
122
                      if (iid != null)
 
123
                        {
 
124
                          assert (persona.iid == iid);
 
125
                        }
 
126
                      else
 
127
                        {
 
128
                          iid = persona.iid;
 
129
                        }
 
130
                    }
114
131
                }
115
132
            }
116
133
        });
193
210
        {
194
211
          foreach (Individual i in removed)
195
212
            {
196
 
              if (!i.is_user && i.personas.length () == 5)
 
213
              if (!i.is_user && i.personas.size == 5)
197
214
                {
198
215
                  if (i == individual1)
199
216
                    {
213
230
 
214
231
          foreach (Individual i in added)
215
232
            {
216
 
              if (!i.is_user && i.personas.length () == 5)
 
233
              if (!i.is_user && i.personas.size == 5)
217
234
                {
218
235
                  if (individual1 == null)
219
236
                    {
366
383
        {
367
384
          foreach (Individual i in removed)
368
385
            {
369
 
              if (!i.is_user && i.personas.length () == 9)
 
386
              if (!i.is_user && i.personas.size == 9)
370
387
                {
371
388
                  if (i == individual1)
372
389
                    {
386
403
 
387
404
          foreach (Individual i in added)
388
405
            {
389
 
              if (!i.is_user && i.personas.length () == 9)
 
406
              if (!i.is_user && i.personas.size == 9)
390
407
                {
391
408
                  if (individual1 == null)
392
409
                    {
555
572
      assert (aggregator.user == user_individual);
556
573
 
557
574
      /* The user individual should comprise personas from the two accounts */
558
 
      assert (user_individual.personas.length () == 2);
559
 
      assert ((user_individual.personas.data.display_id == "me@example.com" &&
560
 
          user_individual.personas.next.data.display_id == "me2@example.com") ||
561
 
          (user_individual.personas.data.display_id == "me2@example.com" &&
562
 
          user_individual.personas.next.data.display_id == "me@example.com"));
 
575
      assert (user_individual.personas.size == 2);
 
576
 
 
577
      var display_ids = new HashSet<string> ();
 
578
      foreach (var persona in user_individual.personas)
 
579
        {
 
580
          display_ids.add (persona.display_id);
 
581
        }
 
582
 
 
583
      assert (display_ids.contains ("me@example.com") &&
 
584
          display_ids.contains ("me2@example.com"));
563
585
 
564
586
      /* Clean up for the next test */
565
587
      this._tp_backend.remove_account (account2_handle);
597
619
           * personas for the user). */
598
620
          foreach (Individual i in removed)
599
621
            {
600
 
              assert (i.is_user || i.personas.length () == 1);
 
622
              assert (i.is_user || i.personas.size == 1);
601
623
            }
602
624
 
603
625
          foreach (Individual i in added)
604
626
            {
605
 
              assert (i.is_user || i.personas.length () == 1);
 
627
              assert (i.is_user || i.personas.size == 1);
606
628
            }
607
629
        });
608
630