~people-project/people-core/deep-refactoring

« back to all changes in this revision

Viewing changes to people-libs/people/base-test/test-contact-source-persistence.vala

  • Committer: Ali Sabil
  • Date: 2009-01-29 23:42:18 UTC
  • Revision ID: ali.sabil@gmail.com-20090129234218-avnl7d1dr6rsyp9d
- Ported people-libs/people/base-test to use libcore

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
 *
19
19
 */
20
20
 
21
 
using Gee;
 
21
using Core.Container;
22
22
 
23
23
using People;
24
 
using People.Utils;
 
24
using Core.Async;
25
25
 
26
26
 
27
27
namespace People.Backend.Test {
28
28
 
29
 
        public abstract class ContactSourcePersistence : TestIt.Suite {
 
29
        public abstract class ContactSourcePersistence : Core.Trial.Suite {
30
30
                protected string backend_name = "Null";
31
31
                protected Backend.ContactSourceFactory contact_source_factory;
32
 
                protected Gee.HashMap<string, string> parameters;
 
32
                protected Core.Container.HashMap<string, string> parameters;
33
33
                protected Backend.ContactSource contact_source;
34
34
                protected string contact_id = null;
35
35
 
40
40
 
41
41
                protected override void set_up () {
42
42
                        try {
43
 
                                var op = contact_source.request_contact (null);
44
 
                                var contact = op.get_result();
45
 
                                var fields = new Gee.HashMap<string, string> (str_hash, str_equal, str_equal);
 
43
                                var async_result = contact_source.request_contact (null);
 
44
                                var contact = async_result.get();
 
45
                                var fields = new Core.Container.HashMap<string, string> (str_hash, str_equal, str_equal);
46
46
                                fields.set ("identity.name.first", "John");
47
47
                                fields.set ("identity.name.last", "Doe");
48
48
                                contact.set_fields (fields);
60
60
                        contact_source = null;
61
61
                }
62
62
 
63
 
                private void async_callback (AsyncOperation op, void* data) {
 
63
                private void async_callback (AsyncResult async_result) {
64
64
                        async_break ();
65
65
                }
66
66
 
67
67
                private void test_contact_creation_persistence () {
68
68
                        try {
69
 
                                var op = contact_source_factory.request_contact_source (parameters);
70
 
                                op.add_callback (async_callback);
 
69
                                var async_result = contact_source_factory.request_contact_source (parameters);
 
70
                                async_result.add_callback (async_callback);
71
71
                                async_wait ();
72
72
 
73
 
                                contact_source = op.get_result ();
 
73
                                contact_source = async_result.get ();
74
74
                        } catch (Backend.Error e) {
75
75
                                failure ();
76
76
                        }
77
77
 
78
78
                        try {
79
 
                                var op = contact_source.request_contact (contact_id);
80
 
                                op.add_callback (async_callback);
 
79
                                var async_result = contact_source.request_contact (contact_id);
 
80
                                async_result.add_callback (async_callback);
81
81
                                async_wait ();
82
82
 
83
 
                                var contact = op.get_result ();
 
83
                                var contact = async_result.get ();
84
84
                                assert_true (contact != null);
85
85
                        } catch (Error e) {
86
86
                                failure ();