/* phone-details.c generated by valac 0.13.1.106-1068, the Vala compiler
 * generated from phone-details.vala, do not modify */

/*
 * Copyright (C) 2011 Collabora Ltd.
 *
 * This library is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 2.1 of the License, or
 * (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this library.  If not, see <http://www.gnu.org/licenses/>.
 *
 * Authors: Raul Gutierrez Segales <raul.gutierrez.segales@collabora.co.uk>
 *
 */

#include <glib.h>
#include <glib-object.h>
#include <folks-test.h>
#include <eds-test.h>
#include <folks/folks.h>
#include <gee.h>
#include <stdlib.h>
#include <string.h>
#include <gio/gio.h>
#include <folks/folks-eds.h>


#define TYPE_PHONE_DETAILS_TESTS (phone_details_tests_get_type ())
#define PHONE_DETAILS_TESTS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_PHONE_DETAILS_TESTS, PhoneDetailsTests))
#define PHONE_DETAILS_TESTS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_PHONE_DETAILS_TESTS, PhoneDetailsTestsClass))
#define IS_PHONE_DETAILS_TESTS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_PHONE_DETAILS_TESTS))
#define IS_PHONE_DETAILS_TESTS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_PHONE_DETAILS_TESTS))
#define PHONE_DETAILS_TESTS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_PHONE_DETAILS_TESTS, PhoneDetailsTestsClass))

typedef struct _PhoneDetailsTests PhoneDetailsTests;
typedef struct _PhoneDetailsTestsClass PhoneDetailsTestsClass;
typedef struct _PhoneDetailsTestsPrivate PhoneDetailsTestsPrivate;
#define _eds_test_backend_unref0(var) ((var == NULL) ? NULL : (var = (eds_test_backend_unref (var), NULL)))
#define _g_main_loop_unref0(var) ((var == NULL) ? NULL : (var = (g_main_loop_unref (var), NULL)))
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define __vala_GValue_free0(var) ((var == NULL) ? NULL : (var = (_vala_GValue_free (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
typedef struct _PhoneDetailsTestsTestPhoneNumbersAsyncData PhoneDetailsTestsTestPhoneNumbersAsyncData;

struct _PhoneDetailsTests {
	FolksTestCase parent_instance;
	PhoneDetailsTestsPrivate * priv;
};

struct _PhoneDetailsTestsClass {
	FolksTestCaseClass parent_class;
};

struct _PhoneDetailsTestsPrivate {
	EdsTestBackend* _eds_backend;
	GMainLoop* _main_loop;
	FolksIndividualAggregator* _aggregator;
	gint _phones_count;
	GeeHashSet* _phone_types;
	GeeHashMap* _c1;
	GeeHashMap* _c2;
};

struct _PhoneDetailsTestsTestPhoneNumbersAsyncData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GSimpleAsyncResult* _async_result;
	PhoneDetailsTests* self;
	EdsTestBackend* _tmp0_;
	FolksBackendStore* _tmp1_;
	FolksBackendStore* store;
	FolksBackendStore* _tmp2_;
	FolksIndividualAggregator* _tmp3_;
	FolksIndividualAggregator* _tmp4_;
	FolksIndividualAggregator* _tmp5_;
	GError* e;
	GError* _tmp6_;
	const gchar* _tmp7_;
	GError * _inner_error_;
};


static gpointer phone_details_tests_parent_class = NULL;

GType phone_details_tests_get_type (void) G_GNUC_CONST;
#define PHONE_DETAILS_TESTS_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), TYPE_PHONE_DETAILS_TESTS, PhoneDetailsTestsPrivate))
enum  {
	PHONE_DETAILS_TESTS_DUMMY_PROPERTY
};
PhoneDetailsTests* phone_details_tests_new (void);
PhoneDetailsTests* phone_details_tests_construct (GType object_type);
void phone_details_tests_test_phone_numbers (PhoneDetailsTests* self);
static void _phone_details_tests_test_phone_numbers_folks_test_case_test_method (gpointer self);
static void phone_details_tests_real_set_up (FolksTestCase* base);
static void phone_details_tests_real_tear_down (FolksTestCase* base);
static GValue* _g_value_dup (GValue* self);
static void _vala_GValue_free (GValue* self);
static void _phone_details_tests_test_phone_numbers_async (PhoneDetailsTests* self, GAsyncReadyCallback _callback_, gpointer _user_data_);
static void _phone_details_tests_test_phone_numbers_finish (PhoneDetailsTests* self, GAsyncResult* _res_);
static gboolean _lambda0_ (PhoneDetailsTests* self);
static gboolean __lambda0__gsource_func (gpointer self);
static gboolean _vala_string_array_contains (const gchar** stack, int stack_length, const gchar* needle);
static void _phone_details_tests_test_phone_numbers_async_data_free (gpointer _data);
static gboolean _phone_details_tests_test_phone_numbers_async_co (PhoneDetailsTestsTestPhoneNumbersAsyncData* _data_);
static void _phone_details_tests_test_phone_numbers_async_ready (GObject* source_object, GAsyncResult* _res_, gpointer _user_data_);
static void _phone_details_tests_individuals_changed_cb (PhoneDetailsTests* self, GeeSet* added, GeeSet* removed, const gchar* message, FolksPersona* actor, FolksGroupDetailsChangeReason reason);
static void __phone_details_tests_individuals_changed_cb_folks_individual_aggregator_individuals_changed (FolksIndividualAggregator* _sender, GeeSet* added, GeeSet* removed, const gchar* message, FolksPersona* actor, FolksGroupDetailsChangeReason reason, gpointer self);
static void phone_details_tests_finalize (GObject* obj);
gint _vala_main (gchar** args, int args_length1);


static void _phone_details_tests_test_phone_numbers_folks_test_case_test_method (gpointer self) {
	phone_details_tests_test_phone_numbers (self);
}


PhoneDetailsTests* phone_details_tests_construct (GType object_type) {
	PhoneDetailsTests * self = NULL;
	EdsTestBackend* _tmp0_;
	self = (PhoneDetailsTests*) folks_test_case_construct (object_type, "PhoneDetails");
	_tmp0_ = eds_test_backend_new ();
	_eds_test_backend_unref0 (self->priv->_eds_backend);
	self->priv->_eds_backend = _tmp0_;
	folks_test_case_add_test ((FolksTestCase*) self, "phone details interface", _phone_details_tests_test_phone_numbers_folks_test_case_test_method, self);
	return self;
}


PhoneDetailsTests* phone_details_tests_new (void) {
	return phone_details_tests_construct (TYPE_PHONE_DETAILS_TESTS);
}


static void phone_details_tests_real_set_up (FolksTestCase* base) {
	PhoneDetailsTests * self;
	EdsTestBackend* _tmp0_;
	self = (PhoneDetailsTests*) base;
	_tmp0_ = self->priv->_eds_backend;
	eds_test_backend_set_up (_tmp0_);
}


static void phone_details_tests_real_tear_down (FolksTestCase* base) {
	PhoneDetailsTests * self;
	EdsTestBackend* _tmp0_;
	self = (PhoneDetailsTests*) base;
	_tmp0_ = self->priv->_eds_backend;
	eds_test_backend_tear_down (_tmp0_);
}


static GValue* _g_value_dup (GValue* self) {
	return g_boxed_copy (G_TYPE_VALUE, self);
}


static void _vala_GValue_free (GValue* self) {
	g_value_unset (self);
	g_free (self);
}


static gpointer __g_value_dup0 (gpointer self) {
	return self ? _g_value_dup (self) : NULL;
}


static gpointer _g_object_ref0 (gpointer self) {
	return self ? g_object_ref (self) : NULL;
}


static gboolean _lambda0_ (PhoneDetailsTests* self) {
	gboolean result = FALSE;
	GMainLoop* _tmp0_;
	_tmp0_ = self->priv->_main_loop;
	g_main_loop_quit (_tmp0_);
	result = FALSE;
	return result;
}


static gboolean __lambda0__gsource_func (gpointer self) {
	gboolean result;
	result = _lambda0_ (self);
	return result;
}


static gboolean _vala_string_array_contains (const gchar** stack, int stack_length, const gchar* needle) {
	int i;
	for (i = 0; i < stack_length; i++) {
		if (g_strcmp0 (stack[i], needle) == 0) {
			return TRUE;
		}
	}
	return FALSE;
}


void phone_details_tests_test_phone_numbers (PhoneDetailsTests* self) {
	GHashFunc _tmp0_;
	GEqualFunc _tmp1_;
	GeeHashSet* _tmp2_;
	GeeHashMap* _tmp3_;
	GeeHashMap* _tmp4_;
	GMainLoop* _tmp5_;
	GValue* v = NULL;
	EdsTestBackend* _tmp6_;
	GValue _tmp7_ = {0};
	GValue _tmp8_;
	GValue _tmp9_;
	GValue* _tmp10_;
	GValue* _tmp11_;
	GeeHashMap* _tmp12_;
	GValue* _tmp13_;
	GValue* _tmp14_;
	GValue _tmp15_ = {0};
	GValue _tmp16_;
	GValue _tmp17_;
	GValue* _tmp18_;
	GValue* _tmp19_;
	GeeHashMap* _tmp20_;
	GValue* _tmp21_;
	GValue* _tmp22_;
	GValue _tmp23_ = {0};
	GValue _tmp24_;
	GValue _tmp25_;
	GValue* _tmp26_;
	GValue* _tmp27_;
	GeeHashMap* _tmp28_;
	GValue* _tmp29_;
	GValue* _tmp30_;
	GValue _tmp31_ = {0};
	GValue _tmp32_;
	GValue _tmp33_;
	GValue* _tmp34_;
	GValue* _tmp35_;
	GeeHashMap* _tmp36_;
	GValue* _tmp37_;
	GValue* _tmp38_;
	EdsTestBackend* _tmp39_;
	GeeHashMap* _tmp40_;
	GeeHashMap* _tmp41_;
	GValue _tmp42_ = {0};
	GValue _tmp43_;
	GValue _tmp44_;
	GValue* _tmp45_;
	GValue* _tmp46_;
	GeeHashMap* _tmp47_;
	GValue* _tmp48_;
	GValue* _tmp49_;
	GValue _tmp50_ = {0};
	GValue _tmp51_;
	GValue _tmp52_;
	GValue* _tmp53_;
	GValue* _tmp54_;
	GeeHashMap* _tmp55_;
	GValue* _tmp56_;
	GValue* _tmp57_;
	GValue _tmp58_ = {0};
	GValue _tmp59_;
	GValue _tmp60_;
	GValue* _tmp61_;
	GValue* _tmp62_;
	GeeHashMap* _tmp63_;
	GValue* _tmp64_;
	GValue* _tmp65_;
	GValue _tmp66_ = {0};
	GValue _tmp67_;
	GValue _tmp68_;
	GValue* _tmp69_;
	GValue* _tmp70_;
	GeeHashMap* _tmp71_;
	GValue* _tmp72_;
	GValue* _tmp73_;
	EdsTestBackend* _tmp74_;
	GeeHashMap* _tmp75_;
	GeeHashMap* _tmp76_;
	GMainLoop* _tmp77_;
	gint _tmp78_;
	GeeHashSet* _tmp79_;
	gint _tmp80_;
	gint _tmp81_;
	GeeHashMap* _tmp82_;
	gint _tmp83_;
	gint _tmp84_;
	GeeHashMap* _tmp85_;
	gint _tmp86_;
	gint _tmp87_;
	g_return_if_fail (self != NULL);
	self->priv->_phones_count = 0;
	_tmp0_ = g_str_hash;
	_tmp1_ = g_str_equal;
	_tmp2_ = gee_hash_set_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, g_free, _tmp0_, _tmp1_);
	_g_object_unref0 (self->priv->_phone_types);
	self->priv->_phone_types = _tmp2_;
	_tmp3_ = gee_hash_map_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, g_free, G_TYPE_VALUE, (GBoxedCopyFunc) _g_value_dup, _vala_GValue_free, NULL, NULL, NULL);
	_g_object_unref0 (self->priv->_c1);
	self->priv->_c1 = _tmp3_;
	_tmp4_ = gee_hash_map_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, g_free, G_TYPE_VALUE, (GBoxedCopyFunc) _g_value_dup, _vala_GValue_free, NULL, NULL, NULL);
	_g_object_unref0 (self->priv->_c2);
	self->priv->_c2 = _tmp4_;
	_tmp5_ = g_main_loop_new (NULL, FALSE);
	_g_main_loop_unref0 (self->priv->_main_loop);
	self->priv->_main_loop = _tmp5_;
	_tmp6_ = self->priv->_eds_backend;
	eds_test_backend_reset (_tmp6_);
	g_value_init (&_tmp7_, G_TYPE_STRING);
	_tmp8_ = _tmp7_;
	_tmp9_ = _tmp8_;
	_tmp10_ = __g_value_dup0 (&_tmp9_);
	__vala_GValue_free0 (v);
	v = _tmp10_;
	G_IS_VALUE (&_tmp9_) ? (g_value_unset (&_tmp9_), NULL) : NULL;
	_tmp11_ = v;
	g_value_set_string (_tmp11_, "bernie h. innocenti");
	_tmp12_ = self->priv->_c1;
	_tmp13_ = v;
	v = NULL;
	_tmp14_ = _tmp13_;
	gee_abstract_map_set ((GeeAbstractMap*) _tmp12_, "full_name", _tmp14_);
	__vala_GValue_free0 (_tmp14_);
	g_value_init (&_tmp15_, G_TYPE_STRING);
	_tmp16_ = _tmp15_;
	_tmp17_ = _tmp16_;
	_tmp18_ = __g_value_dup0 (&_tmp17_);
	__vala_GValue_free0 (v);
	v = _tmp18_;
	G_IS_VALUE (&_tmp17_) ? (g_value_unset (&_tmp17_), NULL) : NULL;
	_tmp19_ = v;
	g_value_set_string (_tmp19_, "123");
	_tmp20_ = self->priv->_c1;
	_tmp21_ = v;
	v = NULL;
	_tmp22_ = _tmp21_;
	gee_abstract_map_set ((GeeAbstractMap*) _tmp20_, "car_phone", _tmp22_);
	__vala_GValue_free0 (_tmp22_);
	g_value_init (&_tmp23_, G_TYPE_STRING);
	_tmp24_ = _tmp23_;
	_tmp25_ = _tmp24_;
	_tmp26_ = __g_value_dup0 (&_tmp25_);
	__vala_GValue_free0 (v);
	v = _tmp26_;
	G_IS_VALUE (&_tmp25_) ? (g_value_unset (&_tmp25_), NULL) : NULL;
	_tmp27_ = v;
	g_value_set_string (_tmp27_, "1234");
	_tmp28_ = self->priv->_c1;
	_tmp29_ = v;
	v = NULL;
	_tmp30_ = _tmp29_;
	gee_abstract_map_set ((GeeAbstractMap*) _tmp28_, "company_phone", _tmp30_);
	__vala_GValue_free0 (_tmp30_);
	g_value_init (&_tmp31_, G_TYPE_STRING);
	_tmp32_ = _tmp31_;
	_tmp33_ = _tmp32_;
	_tmp34_ = __g_value_dup0 (&_tmp33_);
	__vala_GValue_free0 (v);
	v = _tmp34_;
	G_IS_VALUE (&_tmp33_) ? (g_value_unset (&_tmp33_), NULL) : NULL;
	_tmp35_ = v;
	g_value_set_string (_tmp35_, "12345");
	_tmp36_ = self->priv->_c1;
	_tmp37_ = v;
	v = NULL;
	_tmp38_ = _tmp37_;
	gee_abstract_map_set ((GeeAbstractMap*) _tmp36_, "home_phone", _tmp38_);
	__vala_GValue_free0 (_tmp38_);
	_tmp39_ = self->priv->_eds_backend;
	_tmp40_ = self->priv->_c1;
	_tmp41_ = _g_object_ref0 (_tmp40_);
	eds_test_backend_add_contact (_tmp39_, _tmp41_);
	g_value_init (&_tmp42_, G_TYPE_STRING);
	_tmp43_ = _tmp42_;
	_tmp44_ = _tmp43_;
	_tmp45_ = __g_value_dup0 (&_tmp44_);
	__vala_GValue_free0 (v);
	v = _tmp45_;
	G_IS_VALUE (&_tmp44_) ? (g_value_unset (&_tmp44_), NULL) : NULL;
	_tmp46_ = v;
	g_value_set_string (_tmp46_, "richard m. stallman");
	_tmp47_ = self->priv->_c2;
	_tmp48_ = v;
	v = NULL;
	_tmp49_ = _tmp48_;
	gee_abstract_map_set ((GeeAbstractMap*) _tmp47_, "full_name", _tmp49_);
	__vala_GValue_free0 (_tmp49_);
	g_value_init (&_tmp50_, G_TYPE_STRING);
	_tmp51_ = _tmp50_;
	_tmp52_ = _tmp51_;
	_tmp53_ = __g_value_dup0 (&_tmp52_);
	__vala_GValue_free0 (v);
	v = _tmp53_;
	G_IS_VALUE (&_tmp52_) ? (g_value_unset (&_tmp52_), NULL) : NULL;
	_tmp54_ = v;
	g_value_set_string (_tmp54_, "54321");
	_tmp55_ = self->priv->_c2;
	_tmp56_ = v;
	v = NULL;
	_tmp57_ = _tmp56_;
	gee_abstract_map_set ((GeeAbstractMap*) _tmp55_, "car_phone", _tmp57_);
	__vala_GValue_free0 (_tmp57_);
	g_value_init (&_tmp58_, G_TYPE_STRING);
	_tmp59_ = _tmp58_;
	_tmp60_ = _tmp59_;
	_tmp61_ = __g_value_dup0 (&_tmp60_);
	__vala_GValue_free0 (v);
	v = _tmp61_;
	G_IS_VALUE (&_tmp60_) ? (g_value_unset (&_tmp60_), NULL) : NULL;
	_tmp62_ = v;
	g_value_set_string (_tmp62_, "4321");
	_tmp63_ = self->priv->_c2;
	_tmp64_ = v;
	v = NULL;
	_tmp65_ = _tmp64_;
	gee_abstract_map_set ((GeeAbstractMap*) _tmp63_, "company_phone", _tmp65_);
	__vala_GValue_free0 (_tmp65_);
	g_value_init (&_tmp66_, G_TYPE_STRING);
	_tmp67_ = _tmp66_;
	_tmp68_ = _tmp67_;
	_tmp69_ = __g_value_dup0 (&_tmp68_);
	__vala_GValue_free0 (v);
	v = _tmp69_;
	G_IS_VALUE (&_tmp68_) ? (g_value_unset (&_tmp68_), NULL) : NULL;
	_tmp70_ = v;
	g_value_set_string (_tmp70_, "321");
	_tmp71_ = self->priv->_c2;
	_tmp72_ = v;
	v = NULL;
	_tmp73_ = _tmp72_;
	gee_abstract_map_set ((GeeAbstractMap*) _tmp71_, "home_phone", _tmp73_);
	__vala_GValue_free0 (_tmp73_);
	_tmp74_ = self->priv->_eds_backend;
	_tmp75_ = self->priv->_c2;
	_tmp76_ = _g_object_ref0 (_tmp75_);
	eds_test_backend_add_contact (_tmp74_, _tmp76_);
	_phone_details_tests_test_phone_numbers_async (self, NULL, NULL);
	g_timeout_add_seconds_full (G_PRIORITY_DEFAULT, (guint) 5, __lambda0__gsource_func, g_object_ref (self), g_object_unref);
	_tmp77_ = self->priv->_main_loop;
	g_main_loop_run (_tmp77_);
	_tmp78_ = self->priv->_phones_count;
	g_assert (_tmp78_ == 6);
	_tmp79_ = self->priv->_phone_types;
	_tmp80_ = gee_collection_get_size ((GeeCollection*) _tmp79_);
	_tmp81_ = _tmp80_;
	g_assert (_tmp81_ == 3);
	_tmp82_ = self->priv->_c1;
	_tmp83_ = gee_map_get_size ((GeeMap*) _tmp82_);
	_tmp84_ = _tmp83_;
	g_assert (_tmp84_ == 0);
	_tmp85_ = self->priv->_c2;
	_tmp86_ = gee_map_get_size ((GeeMap*) _tmp85_);
	_tmp87_ = _tmp86_;
	g_assert (_tmp87_ == 0);
	{
		GeeHashSet* _tmp88_;
		GeeIterator* _tmp89_ = NULL;
		GeeIterator* _pt_it;
		_tmp88_ = self->priv->_phone_types;
		_tmp89_ = gee_abstract_collection_iterator ((GeeAbstractCollection*) _tmp88_);
		_pt_it = _tmp89_;
		while (TRUE) {
			GeeIterator* _tmp90_;
			gboolean _tmp91_ = FALSE;
			GeeIterator* _tmp92_;
			gpointer _tmp93_ = NULL;
			gchar* pt;
			const gchar* _tmp94_;
			_tmp90_ = _pt_it;
			_tmp91_ = gee_iterator_next (_tmp90_);
			if (!_tmp91_) {
				break;
			}
			_tmp92_ = _pt_it;
			_tmp93_ = gee_iterator_get (_tmp92_);
			pt = (gchar*) _tmp93_;
			_tmp94_ = pt;
			g_assert (_vala_string_array_contains (EDSF_PERSONA_phone_fields, G_N_ELEMENTS (EDSF_PERSONA_phone_fields), _tmp94_));
			_g_free0 (pt);
		}
		_g_object_unref0 (_pt_it);
	}
	__vala_GValue_free0 (v);
}


static void _phone_details_tests_test_phone_numbers_async_data_free (gpointer _data) {
	PhoneDetailsTestsTestPhoneNumbersAsyncData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->self);
	g_slice_free (PhoneDetailsTestsTestPhoneNumbersAsyncData, _data_);
}


static void _phone_details_tests_test_phone_numbers_async (PhoneDetailsTests* self, GAsyncReadyCallback _callback_, gpointer _user_data_) {
	PhoneDetailsTestsTestPhoneNumbersAsyncData* _data_;
	PhoneDetailsTests* _tmp0_;
	_data_ = g_slice_new0 (PhoneDetailsTestsTestPhoneNumbersAsyncData);
	_data_->_async_result = g_simple_async_result_new (G_OBJECT (self), _callback_, _user_data_, _phone_details_tests_test_phone_numbers_async);
	g_simple_async_result_set_op_res_gpointer (_data_->_async_result, _data_, _phone_details_tests_test_phone_numbers_async_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_phone_details_tests_test_phone_numbers_async_co (_data_);
}


static void _phone_details_tests_test_phone_numbers_finish (PhoneDetailsTests* self, GAsyncResult* _res_) {
	PhoneDetailsTestsTestPhoneNumbersAsyncData* _data_;
	_data_ = g_simple_async_result_get_op_res_gpointer (G_SIMPLE_ASYNC_RESULT (_res_));
}


static void _phone_details_tests_test_phone_numbers_async_ready (GObject* source_object, GAsyncResult* _res_, gpointer _user_data_) {
	PhoneDetailsTestsTestPhoneNumbersAsyncData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	_phone_details_tests_test_phone_numbers_async_co (_data_);
}


static void __phone_details_tests_individuals_changed_cb_folks_individual_aggregator_individuals_changed (FolksIndividualAggregator* _sender, GeeSet* added, GeeSet* removed, const gchar* message, FolksPersona* actor, FolksGroupDetailsChangeReason reason, gpointer self) {
	_phone_details_tests_individuals_changed_cb (self, added, removed, message, actor, reason);
}


static gboolean _phone_details_tests_test_phone_numbers_async_co (PhoneDetailsTestsTestPhoneNumbersAsyncData* _data_) {
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		case 2:
		goto _state_2;
		case 3:
		goto _state_3;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_tmp0_ = _data_->self->priv->_eds_backend;
	_data_->_state_ = 1;
	eds_test_backend_commit_contacts_to_addressbook (_data_->_tmp0_, _phone_details_tests_test_phone_numbers_async_ready, _data_);
	return FALSE;
	_state_1:
	eds_test_backend_commit_contacts_to_addressbook_finish (_data_->_tmp0_, _data_->_res_);
	_data_->_tmp1_ = NULL;
	_data_->_tmp1_ = folks_backend_store_dup ();
	_data_->store = _data_->_tmp1_;
	_data_->_tmp2_ = _data_->store;
	_data_->_state_ = 2;
	folks_backend_store_prepare (_data_->_tmp2_, _phone_details_tests_test_phone_numbers_async_ready, _data_);
	return FALSE;
	_state_2:
	folks_backend_store_prepare_finish (_data_->_tmp2_, _data_->_res_);
	_data_->_tmp3_ = folks_individual_aggregator_new ();
	_g_object_unref0 (_data_->self->priv->_aggregator);
	_data_->self->priv->_aggregator = _data_->_tmp3_;
	_data_->_tmp4_ = _data_->self->priv->_aggregator;
	g_signal_connect_object (_data_->_tmp4_, "individuals-changed", (GCallback) __phone_details_tests_individuals_changed_cb_folks_individual_aggregator_individuals_changed, _data_->self, 0);
	{
		_data_->_tmp5_ = _data_->self->priv->_aggregator;
		_data_->_state_ = 3;
		folks_individual_aggregator_prepare (_data_->_tmp5_, _phone_details_tests_test_phone_numbers_async_ready, _data_);
		return FALSE;
		_state_3:
		folks_individual_aggregator_prepare_finish (_data_->_tmp5_, _data_->_res_, &_data_->_inner_error_);
		if (_data_->_inner_error_ != NULL) {
			goto __catch0_g_error;
		}
	}
	goto __finally0;
	__catch0_g_error:
	{
		_data_->e = _data_->_inner_error_;
		_data_->_inner_error_ = NULL;
		_data_->_tmp6_ = _data_->e;
		_data_->_tmp7_ = _data_->_tmp6_->message;
		g_warning ("phone-details.vala:131: Error when calling prepare: %s\n", _data_->_tmp7_);
		_g_error_free0 (_data_->e);
	}
	__finally0:
	if (_data_->_inner_error_ != NULL) {
		_g_object_unref0 (_data_->store);
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _data_->_inner_error_->message, g_quark_to_string (_data_->_inner_error_->domain), _data_->_inner_error_->code);
		g_clear_error (&_data_->_inner_error_);
		return FALSE;
	}
	_g_object_unref0 (_data_->store);
	if (_data_->_state_ == 0) {
		g_simple_async_result_complete_in_idle (_data_->_async_result);
	} else {
		g_simple_async_result_complete (_data_->_async_result);
	}
	g_object_unref (_data_->_async_result);
	return FALSE;
}


static void _phone_details_tests_individuals_changed_cb (PhoneDetailsTests* self, GeeSet* added, GeeSet* removed, const gchar* message, FolksPersona* actor, FolksGroupDetailsChangeReason reason) {
	gint _tmp61_;
	GeeSet* _tmp63_;
	gint _tmp64_;
	gint _tmp65_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (added != NULL);
	g_return_if_fail (removed != NULL);
	{
		GeeSet* _tmp0_;
		GeeIterator* _tmp1_ = NULL;
		GeeIterator* _i_it;
		_tmp0_ = added;
		_tmp1_ = gee_iterable_iterator ((GeeIterable*) _tmp0_);
		_i_it = _tmp1_;
		while (TRUE) {
			GeeIterator* _tmp2_;
			gboolean _tmp3_ = FALSE;
			GeeIterator* _tmp4_;
			gpointer _tmp5_ = NULL;
			FolksIndividual* i;
			GeeHashMap* contact;
			FolksIndividual* _tmp6_;
			GeeSet* _tmp7_;
			GeeSet* _tmp8_;
			gint _tmp9_;
			gint _tmp10_;
			FolksIndividual* _tmp11_;
			const gchar* _tmp12_;
			const gchar* _tmp13_;
			GeeHashMap* _tmp19_;
			GeeHashMap* _tmp20_;
			FolksIndividual* _tmp21_;
			FolksPhoneDetails* _tmp22_;
			FolksPhoneDetails* phone_numbers;
			_tmp2_ = _i_it;
			_tmp3_ = gee_iterator_next (_tmp2_);
			if (!_tmp3_) {
				break;
			}
			_tmp4_ = _i_it;
			_tmp5_ = gee_iterator_get (_tmp4_);
			i = (FolksIndividual*) _tmp5_;
			contact = NULL;
			_tmp6_ = i;
			_tmp7_ = folks_individual_get_personas (_tmp6_);
			_tmp8_ = _tmp7_;
			_tmp9_ = gee_collection_get_size ((GeeCollection*) _tmp8_);
			_tmp10_ = _tmp9_;
			g_assert (_tmp10_ == 1);
			_tmp11_ = i;
			_tmp12_ = folks_name_details_get_full_name ((FolksNameDetails*) _tmp11_);
			_tmp13_ = _tmp12_;
			if (g_strcmp0 (_tmp13_, "bernie h. innocenti") == 0) {
				GeeHashMap* _tmp14_;
				_tmp14_ = self->priv->_c1;
				contact = _tmp14_;
			} else {
				FolksIndividual* _tmp15_;
				const gchar* _tmp16_;
				const gchar* _tmp17_;
				_tmp15_ = i;
				_tmp16_ = folks_name_details_get_full_name ((FolksNameDetails*) _tmp15_);
				_tmp17_ = _tmp16_;
				if (g_strcmp0 (_tmp17_, "richard m. stallman") == 0) {
					GeeHashMap* _tmp18_;
					_tmp18_ = self->priv->_c2;
					contact = _tmp18_;
				}
			}
			_tmp19_ = contact;
			if (_tmp19_ == NULL) {
				_g_object_unref0 (i);
				continue;
			}
			_tmp20_ = contact;
			gee_abstract_map_unset ((GeeAbstractMap*) _tmp20_, "full_name", NULL);
			_tmp21_ = i;
			_tmp22_ = _g_object_ref0 (FOLKS_PHONE_DETAILS (_tmp21_));
			phone_numbers = _tmp22_;
			{
				FolksPhoneDetails* _tmp23_;
				GeeSet* _tmp24_;
				GeeSet* _tmp25_;
				GeeIterator* _tmp26_ = NULL;
				GeeIterator* _phone_fd_it;
				_tmp23_ = phone_numbers;
				_tmp24_ = folks_phone_details_get_phone_numbers (_tmp23_);
				_tmp25_ = _tmp24_;
				_tmp26_ = gee_iterable_iterator ((GeeIterable*) _tmp25_);
				_phone_fd_it = _tmp26_;
				while (TRUE) {
					GeeIterator* _tmp27_;
					gboolean _tmp28_ = FALSE;
					GeeIterator* _tmp29_;
					gpointer _tmp30_ = NULL;
					FolksPhoneFieldDetails* phone_fd;
					gint _tmp31_;
					_tmp27_ = _phone_fd_it;
					_tmp28_ = gee_iterator_next (_tmp27_);
					if (!_tmp28_) {
						break;
					}
					_tmp29_ = _phone_fd_it;
					_tmp30_ = gee_iterator_get (_tmp29_);
					phone_fd = (FolksPhoneFieldDetails*) _tmp30_;
					_tmp31_ = self->priv->_phones_count;
					self->priv->_phones_count = _tmp31_ + 1;
					{
						FolksPhoneFieldDetails* _tmp32_;
						GeeCollection* _tmp33_ = NULL;
						GeeCollection* _tmp34_;
						GeeIterator* _tmp35_ = NULL;
						GeeIterator* _tmp36_;
						GeeIterator* _t_it;
						_tmp32_ = phone_fd;
						_tmp33_ = folks_abstract_field_details_get_parameter_values ((FolksAbstractFieldDetails*) _tmp32_, "type");
						_tmp34_ = _tmp33_;
						_tmp35_ = gee_iterable_iterator ((GeeIterable*) _tmp34_);
						_tmp36_ = _tmp35_;
						_g_object_unref0 (_tmp34_);
						_t_it = _tmp36_;
						while (TRUE) {
							GeeIterator* _tmp37_;
							gboolean _tmp38_ = FALSE;
							GeeIterator* _tmp39_;
							gpointer _tmp40_ = NULL;
							gchar* t;
							gchar* v;
							const gchar* _tmp41_;
							const gchar* _tmp47_;
							GeeHashSet* _tmp48_;
							const gchar* _tmp49_;
							GeeHashMap* _tmp50_;
							const gchar* _tmp51_;
							gpointer _tmp52_ = NULL;
							GValue* _tmp53_;
							GValue _tmp54_;
							const gchar* _tmp55_ = NULL;
							FolksPhoneFieldDetails* _tmp56_;
							gconstpointer _tmp57_;
							const gchar* _tmp58_;
							GeeHashMap* _tmp59_;
							const gchar* _tmp60_;
							_tmp37_ = _t_it;
							_tmp38_ = gee_iterator_next (_tmp37_);
							if (!_tmp38_) {
								break;
							}
							_tmp39_ = _t_it;
							_tmp40_ = gee_iterator_get (_tmp39_);
							t = (gchar*) _tmp40_;
							v = NULL;
							_tmp41_ = t;
							if (g_strcmp0 (_tmp41_, "CAR") == 0) {
								gchar* _tmp42_;
								_tmp42_ = g_strdup ("car_phone");
								_g_free0 (v);
								v = _tmp42_;
							} else {
								const gchar* _tmp43_;
								_tmp43_ = t;
								if (g_strcmp0 (_tmp43_, "HOME") == 0) {
									gchar* _tmp44_;
									_tmp44_ = g_strdup ("home_phone");
									_g_free0 (v);
									v = _tmp44_;
								} else {
									const gchar* _tmp45_;
									_tmp45_ = t;
									if (g_strcmp0 (_tmp45_, "X-EVOLUTION-COMPANY") == 0) {
										gchar* _tmp46_;
										_tmp46_ = g_strdup ("company_phone");
										_g_free0 (v);
										v = _tmp46_;
									}
								}
							}
							_tmp47_ = v;
							if (_tmp47_ == NULL) {
								_g_free0 (v);
								_g_free0 (t);
								continue;
							}
							_tmp48_ = self->priv->_phone_types;
							_tmp49_ = v;
							gee_abstract_collection_add ((GeeAbstractCollection*) _tmp48_, _tmp49_);
							_tmp50_ = contact;
							_tmp51_ = v;
							_tmp52_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp50_, _tmp51_);
							_tmp53_ = (GValue*) _tmp52_;
							_tmp54_ = *_tmp53_;
							_tmp55_ = g_value_get_string (&_tmp54_);
							_tmp56_ = phone_fd;
							_tmp57_ = folks_abstract_field_details_get_value ((FolksAbstractFieldDetails*) _tmp56_);
							_tmp58_ = _tmp57_;
							g_assert (g_strcmp0 (_tmp55_, (const gchar*) _tmp58_) == 0);
							__vala_GValue_free0 (_tmp53_);
							_tmp59_ = contact;
							_tmp60_ = v;
							gee_abstract_map_unset ((GeeAbstractMap*) _tmp59_, _tmp60_, NULL);
							_g_free0 (v);
							_g_free0 (t);
						}
						_g_object_unref0 (_t_it);
					}
					_g_object_unref0 (phone_fd);
				}
				_g_object_unref0 (_phone_fd_it);
			}
			_g_object_unref0 (phone_numbers);
			_g_object_unref0 (i);
		}
		_g_object_unref0 (_i_it);
	}
	_tmp61_ = self->priv->_phones_count;
	if (_tmp61_ == 6) {
		GMainLoop* _tmp62_;
		_tmp62_ = self->priv->_main_loop;
		g_main_loop_quit (_tmp62_);
	}
	_tmp63_ = removed;
	_tmp64_ = gee_collection_get_size ((GeeCollection*) _tmp63_);
	_tmp65_ = _tmp64_;
	g_assert (_tmp65_ == 0);
}


static void phone_details_tests_class_init (PhoneDetailsTestsClass * klass) {
	phone_details_tests_parent_class = g_type_class_peek_parent (klass);
	g_type_class_add_private (klass, sizeof (PhoneDetailsTestsPrivate));
	FOLKS_TEST_CASE_CLASS (klass)->set_up = phone_details_tests_real_set_up;
	FOLKS_TEST_CASE_CLASS (klass)->tear_down = phone_details_tests_real_tear_down;
	G_OBJECT_CLASS (klass)->finalize = phone_details_tests_finalize;
}


static void phone_details_tests_instance_init (PhoneDetailsTests * self) {
	self->priv = PHONE_DETAILS_TESTS_GET_PRIVATE (self);
}


static void phone_details_tests_finalize (GObject* obj) {
	PhoneDetailsTests * self;
	self = PHONE_DETAILS_TESTS (obj);
	_eds_test_backend_unref0 (self->priv->_eds_backend);
	_g_main_loop_unref0 (self->priv->_main_loop);
	_g_object_unref0 (self->priv->_aggregator);
	_g_object_unref0 (self->priv->_phone_types);
	_g_object_unref0 (self->priv->_c1);
	_g_object_unref0 (self->priv->_c2);
	G_OBJECT_CLASS (phone_details_tests_parent_class)->finalize (obj);
}


GType phone_details_tests_get_type (void) {
	static volatile gsize phone_details_tests_type_id__volatile = 0;
	if (g_once_init_enter (&phone_details_tests_type_id__volatile)) {
		static const GTypeInfo g_define_type_info = { sizeof (PhoneDetailsTestsClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) phone_details_tests_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (PhoneDetailsTests), 0, (GInstanceInitFunc) phone_details_tests_instance_init, NULL };
		GType phone_details_tests_type_id;
		phone_details_tests_type_id = g_type_register_static (FOLKS_TYPE_TEST_CASE, "PhoneDetailsTests", &g_define_type_info, 0);
		g_once_init_leave (&phone_details_tests_type_id__volatile, phone_details_tests_type_id);
	}
	return phone_details_tests_type_id__volatile;
}


gint _vala_main (gchar** args, int args_length1) {
	gint result = 0;
	GTestSuite* _tmp0_ = NULL;
	GTestSuite* root;
	GTestSuite* _tmp1_;
	PhoneDetailsTests* _tmp2_;
	PhoneDetailsTests* _tmp3_;
	GTestSuite* _tmp4_ = NULL;
	g_test_init (&args_length1, &args, NULL);
	_tmp0_ = g_test_get_root ();
	root = _tmp0_;
	_tmp1_ = root;
	_tmp2_ = phone_details_tests_new ();
	_tmp3_ = _tmp2_;
	_tmp4_ = folks_test_case_get_suite ((FolksTestCase*) _tmp3_);
	g_test_suite_add_suite (_tmp1_, _tmp4_);
	_g_object_unref0 (_tmp3_);
	g_test_run ();
	result = 0;
	return result;
}


int main (int argc, char ** argv) {
	g_type_init ();
	return _vala_main (argv, argc);
}



