~ubuntu-desktop/dee/ubuntu

« back to all changes in this revision

Viewing changes to tests/model-helper-clear3rows.c

  • Committer: Didier Roche
  • Date: 2012-01-12 16:14:54 UTC
  • mfrom: (130.1.206 MASTER)
  • mto: (250.1.1 ubuntu)
  • mto: This revision was merged to the branch mainline in revision 218.
  • Revision ID: didier.roche@canonical.com-20120112161454-31xl6hgcfngm6abi
Tags: upstream-1.0.0
ImportĀ upstreamĀ versionĀ 1.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
#include <gtx.h>
26
26
#include <dee.h>
27
27
 
 
28
guint64 before_begin_seqnum, before_end_seqnum,
 
29
        after_begin_seqnum, after_end_seqnum;
 
30
 
 
31
static void
 
32
_begin_txn (DeeSharedModel *model, guint64 begin_seqnum, guint64 end_seqnum)
 
33
{
 
34
  before_begin_seqnum = begin_seqnum;
 
35
  before_end_seqnum = end_seqnum;
 
36
}
 
37
 
 
38
static void
 
39
_end_txn (DeeSharedModel *model, guint64 begin_seqnum, guint64 end_seqnum)
 
40
{
 
41
  after_begin_seqnum = begin_seqnum;
 
42
  after_end_seqnum = end_seqnum;
 
43
}
 
44
 
28
45
static void
29
46
_row_removed (DeeModel *model, DeeModelIter *iter, GSList **removed)
30
47
{
42
59
  g_type_init (); 
43
60
  g_thread_init (NULL);
44
61
 
45
 
  model = dee_shared_model_new (argv[1]);
 
62
  if (argc == 2)
 
63
    model = dee_shared_model_new (argv[1]);
 
64
  else
 
65
    model = dee_shared_model_new_for_peer ((DeePeer*) dee_client_new (argv[1]));
 
66
 
 
67
  g_signal_connect (model, "begin-transaction", G_CALLBACK (_begin_txn), NULL);
 
68
  g_signal_connect (model, "end-transaction", G_CALLBACK (_end_txn), NULL);
46
69
  
47
70
  if (gtx_wait_for_signal (G_OBJECT (model), 100000, "notify::synchronized", NULL))
48
71
    g_error ("Helper model timed out waiting for 'ready' signal");
59
82
  g_assert_cmpint (g_slist_length (removed), ==, 3);
60
83
  g_assert_cmpint (dee_model_get_n_rows(model), ==, 0);
61
84
  
 
85
  g_assert_cmpint (6, ==, (guint) dee_serializable_model_get_seqnum (model));
 
86
  
 
87
  g_assert (before_begin_seqnum == after_begin_seqnum);
 
88
  g_assert (before_end_seqnum == after_end_seqnum);
 
89
  g_assert_cmpint (3, ==, (guint) before_begin_seqnum);
 
90
  g_assert_cmpint (6, ==, (guint) before_end_seqnum);
 
91
  
 
92
  gtx_assert_last_unref (model);
 
93
  g_slist_free (removed);
 
94
  
62
95
  return 0;
63
96
}