/* email-details.c generated by valac 0.13.1.106-1068, the Vala compiler
 * generated from email-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 <folks/folks-eds.h>
#include <gio/gio.h>


#define TYPE_EMAIL_DETAILS_TESTS (email_details_tests_get_type ())
#define EMAIL_DETAILS_TESTS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_EMAIL_DETAILS_TESTS, EmailDetailsTests))
#define EMAIL_DETAILS_TESTS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_EMAIL_DETAILS_TESTS, EmailDetailsTestsClass))
#define IS_EMAIL_DETAILS_TESTS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_EMAIL_DETAILS_TESTS))
#define IS_EMAIL_DETAILS_TESTS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_EMAIL_DETAILS_TESTS))
#define EMAIL_DETAILS_TESTS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_EMAIL_DETAILS_TESTS, EmailDetailsTestsClass))

typedef struct _EmailDetailsTests EmailDetailsTests;
typedef struct _EmailDetailsTestsClass EmailDetailsTestsClass;
typedef struct _EmailDetailsTestsPrivate EmailDetailsTestsPrivate;
#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 _EmailDetailsTestsTestEmailDetailsAsyncData EmailDetailsTestsTestEmailDetailsAsyncData;

struct _EmailDetailsTests {
	FolksTestCase parent_instance;
	EmailDetailsTestsPrivate * priv;
};

struct _EmailDetailsTestsClass {
	FolksTestCaseClass parent_class;
};

struct _EmailDetailsTestsPrivate {
	EdsTestBackend* _eds_backend;
	GMainLoop* _main_loop;
	FolksIndividualAggregator* _aggregator;
	gint _email_count;
	GeeHashSet* _email_types;
	GeeHashMap* _c1;
	GeeHashMap* _c2;
	GeeHashMap* _c3;
};

struct _EmailDetailsTestsTestEmailDetailsAsyncData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GSimpleAsyncResult* _async_result;
	EmailDetailsTests* 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 email_details_tests_parent_class = NULL;

GType email_details_tests_get_type (void) G_GNUC_CONST;
#define EMAIL_DETAILS_TESTS_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), TYPE_EMAIL_DETAILS_TESTS, EmailDetailsTestsPrivate))
enum  {
	EMAIL_DETAILS_TESTS_DUMMY_PROPERTY
};
EmailDetailsTests* email_details_tests_new (void);
EmailDetailsTests* email_details_tests_construct (GType object_type);
void email_details_tests_test_email_details (EmailDetailsTests* self);
static void _email_details_tests_test_email_details_folks_test_case_test_method (gpointer self);
static void email_details_tests_real_set_up (FolksTestCase* base);
static void email_details_tests_real_tear_down (FolksTestCase* base);
static GValue* _g_value_dup (GValue* self);
static void _vala_GValue_free (GValue* self);
static void _email_details_tests_test_email_details_async (EmailDetailsTests* self, GAsyncReadyCallback _callback_, gpointer _user_data_);
static void _email_details_tests_test_email_details_finish (EmailDetailsTests* self, GAsyncResult* _res_);
static gboolean _lambda0_ (EmailDetailsTests* self);
static gboolean __lambda0__gsource_func (gpointer self);
static void _email_details_tests_test_email_details_async_data_free (gpointer _data);
static gboolean _email_details_tests_test_email_details_async_co (EmailDetailsTestsTestEmailDetailsAsyncData* _data_);
static void _email_details_tests_test_email_details_async_ready (GObject* source_object, GAsyncResult* _res_, gpointer _user_data_);
static void _email_details_tests_individuals_changed_cb (EmailDetailsTests* self, GeeSet* added, GeeSet* removed, const gchar* message, FolksPersona* actor, FolksGroupDetailsChangeReason reason);
static void __email_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 email_details_tests_finalize (GObject* obj);
gint _vala_main (gchar** args, int args_length1);


static void _email_details_tests_test_email_details_folks_test_case_test_method (gpointer self) {
	email_details_tests_test_email_details (self);
}


EmailDetailsTests* email_details_tests_construct (GType object_type) {
	EmailDetailsTests * self = NULL;
	EdsTestBackend* _tmp0_;
	self = (EmailDetailsTests*) folks_test_case_construct (object_type, "EmailDetails");
	_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, "email details interface", _email_details_tests_test_email_details_folks_test_case_test_method, self);
	return self;
}


EmailDetailsTests* email_details_tests_new (void) {
	return email_details_tests_construct (TYPE_EMAIL_DETAILS_TESTS);
}


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


static void email_details_tests_real_tear_down (FolksTestCase* base) {
	EmailDetailsTests * self;
	EdsTestBackend* _tmp0_;
	self = (EmailDetailsTests*) 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_ (EmailDetailsTests* 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;
}


void email_details_tests_test_email_details (EmailDetailsTests* self) {
	GHashFunc _tmp0_;
	GEqualFunc _tmp1_;
	GeeHashSet* _tmp2_;
	GeeHashMap* _tmp3_;
	GeeHashMap* _tmp4_;
	GeeHashMap* _tmp5_;
	GMainLoop* _tmp6_;
	GValue* v = NULL;
	EdsTestBackend* _tmp7_;
	GValue _tmp8_ = {0};
	GValue _tmp9_;
	GValue _tmp10_;
	GValue* _tmp11_;
	GValue* _tmp12_;
	GeeHashMap* _tmp13_;
	GValue* _tmp14_;
	GValue* _tmp15_;
	GValue _tmp16_ = {0};
	GValue _tmp17_;
	GValue _tmp18_;
	GValue* _tmp19_;
	GValue* _tmp20_;
	GeeHashMap* _tmp21_;
	const gchar* _tmp22_;
	GValue* _tmp23_;
	GValue* _tmp24_;
	GValue _tmp25_ = {0};
	GValue _tmp26_;
	GValue _tmp27_;
	GValue* _tmp28_;
	GValue* _tmp29_;
	GeeHashMap* _tmp30_;
	const gchar* _tmp31_;
	GValue* _tmp32_;
	GValue* _tmp33_;
	EdsTestBackend* _tmp34_;
	GeeHashMap* _tmp35_;
	GeeHashMap* _tmp36_;
	GValue _tmp37_ = {0};
	GValue _tmp38_;
	GValue _tmp39_;
	GValue* _tmp40_;
	GValue* _tmp41_;
	GeeHashMap* _tmp42_;
	GValue* _tmp43_;
	GValue* _tmp44_;
	GValue _tmp45_ = {0};
	GValue _tmp46_;
	GValue _tmp47_;
	GValue* _tmp48_;
	GValue* _tmp49_;
	GeeHashMap* _tmp50_;
	const gchar* _tmp51_;
	GValue* _tmp52_;
	GValue* _tmp53_;
	GValue _tmp54_ = {0};
	GValue _tmp55_;
	GValue _tmp56_;
	GValue* _tmp57_;
	GValue* _tmp58_;
	GeeHashMap* _tmp59_;
	const gchar* _tmp60_;
	GValue* _tmp61_;
	GValue* _tmp62_;
	EdsTestBackend* _tmp63_;
	GeeHashMap* _tmp64_;
	GeeHashMap* _tmp65_;
	GValue _tmp66_ = {0};
	GValue _tmp67_;
	GValue _tmp68_;
	GValue* _tmp69_;
	GValue* _tmp70_;
	GeeHashMap* _tmp71_;
	GValue* _tmp72_;
	GValue* _tmp73_;
	GValue _tmp74_ = {0};
	GValue _tmp75_;
	GValue _tmp76_;
	GValue* _tmp77_;
	GValue* _tmp78_;
	GeeHashMap* _tmp79_;
	const gchar* _tmp80_;
	GValue* _tmp81_;
	GValue* _tmp82_;
	GValue _tmp83_ = {0};
	GValue _tmp84_;
	GValue _tmp85_;
	GValue* _tmp86_;
	GValue* _tmp87_;
	GeeHashMap* _tmp88_;
	const gchar* _tmp89_;
	GValue* _tmp90_;
	GValue* _tmp91_;
	EdsTestBackend* _tmp92_;
	GeeHashMap* _tmp93_;
	GeeHashMap* _tmp94_;
	GMainLoop* _tmp95_;
	gint _tmp96_;
	GeeHashSet* _tmp97_;
	gint _tmp98_;
	gint _tmp99_;
	GeeHashMap* _tmp100_;
	gint _tmp101_;
	gint _tmp102_;
	GeeHashMap* _tmp103_;
	gint _tmp104_;
	gint _tmp105_;
	GeeHashMap* _tmp106_;
	gint _tmp107_;
	gint _tmp108_;
	g_return_if_fail (self != NULL);
	self->priv->_email_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->_email_types);
	self->priv->_email_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_ = 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->_c3);
	self->priv->_c3 = _tmp5_;
	_tmp6_ = g_main_loop_new (NULL, FALSE);
	_g_main_loop_unref0 (self->priv->_main_loop);
	self->priv->_main_loop = _tmp6_;
	_tmp7_ = self->priv->_eds_backend;
	eds_test_backend_reset (_tmp7_);
	g_value_init (&_tmp8_, G_TYPE_STRING);
	_tmp9_ = _tmp8_;
	_tmp10_ = _tmp9_;
	_tmp11_ = __g_value_dup0 (&_tmp10_);
	__vala_GValue_free0 (v);
	v = _tmp11_;
	G_IS_VALUE (&_tmp10_) ? (g_value_unset (&_tmp10_), NULL) : NULL;
	_tmp12_ = v;
	g_value_set_string (_tmp12_, "bernie h. innocenti");
	_tmp13_ = self->priv->_c1;
	_tmp14_ = v;
	v = NULL;
	_tmp15_ = _tmp14_;
	gee_abstract_map_set ((GeeAbstractMap*) _tmp13_, "full_name", _tmp15_);
	__vala_GValue_free0 (_tmp15_);
	g_value_init (&_tmp16_, G_TYPE_STRING);
	_tmp17_ = _tmp16_;
	_tmp18_ = _tmp17_;
	_tmp19_ = __g_value_dup0 (&_tmp18_);
	__vala_GValue_free0 (v);
	v = _tmp19_;
	G_IS_VALUE (&_tmp18_) ? (g_value_unset (&_tmp18_), NULL) : NULL;
	_tmp20_ = v;
	g_value_set_string (_tmp20_, "bernie@example.org");
	_tmp21_ = self->priv->_c1;
	_tmp22_ = EDSF_PERSONA_email_fields[0];
	_tmp23_ = v;
	v = NULL;
	_tmp24_ = _tmp23_;
	gee_abstract_map_set ((GeeAbstractMap*) _tmp21_, _tmp22_, _tmp24_);
	__vala_GValue_free0 (_tmp24_);
	g_value_init (&_tmp25_, G_TYPE_STRING);
	_tmp26_ = _tmp25_;
	_tmp27_ = _tmp26_;
	_tmp28_ = __g_value_dup0 (&_tmp27_);
	__vala_GValue_free0 (v);
	v = _tmp28_;
	G_IS_VALUE (&_tmp27_) ? (g_value_unset (&_tmp27_), NULL) : NULL;
	_tmp29_ = v;
	g_value_set_string (_tmp29_, "bernie.innocenti@example.org");
	_tmp30_ = self->priv->_c1;
	_tmp31_ = EDSF_PERSONA_email_fields[1];
	_tmp32_ = v;
	v = NULL;
	_tmp33_ = _tmp32_;
	gee_abstract_map_set ((GeeAbstractMap*) _tmp30_, _tmp31_, _tmp33_);
	__vala_GValue_free0 (_tmp33_);
	_tmp34_ = self->priv->_eds_backend;
	_tmp35_ = self->priv->_c1;
	_tmp36_ = _g_object_ref0 (_tmp35_);
	eds_test_backend_add_contact (_tmp34_, _tmp36_);
	g_value_init (&_tmp37_, G_TYPE_STRING);
	_tmp38_ = _tmp37_;
	_tmp39_ = _tmp38_;
	_tmp40_ = __g_value_dup0 (&_tmp39_);
	__vala_GValue_free0 (v);
	v = _tmp40_;
	G_IS_VALUE (&_tmp39_) ? (g_value_unset (&_tmp39_), NULL) : NULL;
	_tmp41_ = v;
	g_value_set_string (_tmp41_, "richard m. stallman");
	_tmp42_ = self->priv->_c2;
	_tmp43_ = v;
	v = NULL;
	_tmp44_ = _tmp43_;
	gee_abstract_map_set ((GeeAbstractMap*) _tmp42_, "full_name", _tmp44_);
	__vala_GValue_free0 (_tmp44_);
	g_value_init (&_tmp45_, G_TYPE_STRING);
	_tmp46_ = _tmp45_;
	_tmp47_ = _tmp46_;
	_tmp48_ = __g_value_dup0 (&_tmp47_);
	__vala_GValue_free0 (v);
	v = _tmp48_;
	G_IS_VALUE (&_tmp47_) ? (g_value_unset (&_tmp47_), NULL) : NULL;
	_tmp49_ = v;
	g_value_set_string (_tmp49_, "rms@example.org");
	_tmp50_ = self->priv->_c2;
	_tmp51_ = EDSF_PERSONA_email_fields[0];
	_tmp52_ = v;
	v = NULL;
	_tmp53_ = _tmp52_;
	gee_abstract_map_set ((GeeAbstractMap*) _tmp50_, _tmp51_, _tmp53_);
	__vala_GValue_free0 (_tmp53_);
	g_value_init (&_tmp54_, G_TYPE_STRING);
	_tmp55_ = _tmp54_;
	_tmp56_ = _tmp55_;
	_tmp57_ = __g_value_dup0 (&_tmp56_);
	__vala_GValue_free0 (v);
	v = _tmp57_;
	G_IS_VALUE (&_tmp56_) ? (g_value_unset (&_tmp56_), NULL) : NULL;
	_tmp58_ = v;
	g_value_set_string (_tmp58_, "rms.1@example.org");
	_tmp59_ = self->priv->_c2;
	_tmp60_ = EDSF_PERSONA_email_fields[1];
	_tmp61_ = v;
	v = NULL;
	_tmp62_ = _tmp61_;
	gee_abstract_map_set ((GeeAbstractMap*) _tmp59_, _tmp60_, _tmp62_);
	__vala_GValue_free0 (_tmp62_);
	_tmp63_ = self->priv->_eds_backend;
	_tmp64_ = self->priv->_c2;
	_tmp65_ = _g_object_ref0 (_tmp64_);
	eds_test_backend_add_contact (_tmp63_, _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_, "foo bar");
	_tmp71_ = self->priv->_c3;
	_tmp72_ = v;
	v = NULL;
	_tmp73_ = _tmp72_;
	gee_abstract_map_set ((GeeAbstractMap*) _tmp71_, "full_name", _tmp73_);
	__vala_GValue_free0 (_tmp73_);
	g_value_init (&_tmp74_, G_TYPE_STRING);
	_tmp75_ = _tmp74_;
	_tmp76_ = _tmp75_;
	_tmp77_ = __g_value_dup0 (&_tmp76_);
	__vala_GValue_free0 (v);
	v = _tmp77_;
	G_IS_VALUE (&_tmp76_) ? (g_value_unset (&_tmp76_), NULL) : NULL;
	_tmp78_ = v;
	g_value_set_string (_tmp78_, "foo@example.org");
	_tmp79_ = self->priv->_c3;
	_tmp80_ = EDSF_PERSONA_email_fields[0];
	_tmp81_ = v;
	v = NULL;
	_tmp82_ = _tmp81_;
	gee_abstract_map_set ((GeeAbstractMap*) _tmp79_, _tmp80_, _tmp82_);
	__vala_GValue_free0 (_tmp82_);
	g_value_init (&_tmp83_, G_TYPE_STRING);
	_tmp84_ = _tmp83_;
	_tmp85_ = _tmp84_;
	_tmp86_ = __g_value_dup0 (&_tmp85_);
	__vala_GValue_free0 (v);
	v = _tmp86_;
	G_IS_VALUE (&_tmp85_) ? (g_value_unset (&_tmp85_), NULL) : NULL;
	_tmp87_ = v;
	g_value_set_string (_tmp87_, "foo.bar@example.org");
	_tmp88_ = self->priv->_c3;
	_tmp89_ = EDSF_PERSONA_email_fields[1];
	_tmp90_ = v;
	v = NULL;
	_tmp91_ = _tmp90_;
	gee_abstract_map_set ((GeeAbstractMap*) _tmp88_, _tmp89_, _tmp91_);
	__vala_GValue_free0 (_tmp91_);
	_tmp92_ = self->priv->_eds_backend;
	_tmp93_ = self->priv->_c3;
	_tmp94_ = _g_object_ref0 (_tmp93_);
	eds_test_backend_add_contact (_tmp92_, _tmp94_);
	_email_details_tests_test_email_details_async (self, NULL, NULL);
	g_timeout_add_seconds_full (G_PRIORITY_DEFAULT, (guint) 5, __lambda0__gsource_func, g_object_ref (self), g_object_unref);
	_tmp95_ = self->priv->_main_loop;
	g_main_loop_run (_tmp95_);
	_tmp96_ = self->priv->_email_count;
	g_assert (_tmp96_ == 6);
	_tmp97_ = self->priv->_email_types;
	_tmp98_ = gee_collection_get_size ((GeeCollection*) _tmp97_);
	_tmp99_ = _tmp98_;
	g_assert (_tmp99_ == 1);
	_tmp100_ = self->priv->_c1;
	_tmp101_ = gee_map_get_size ((GeeMap*) _tmp100_);
	_tmp102_ = _tmp101_;
	g_assert (_tmp102_ == 0);
	_tmp103_ = self->priv->_c2;
	_tmp104_ = gee_map_get_size ((GeeMap*) _tmp103_);
	_tmp105_ = _tmp104_;
	g_assert (_tmp105_ == 0);
	_tmp106_ = self->priv->_c3;
	_tmp107_ = gee_map_get_size ((GeeMap*) _tmp106_);
	_tmp108_ = _tmp107_;
	g_assert (_tmp108_ == 0);
	{
		GeeHashSet* _tmp109_;
		GeeIterator* _tmp110_ = NULL;
		GeeIterator* _pt_it;
		_tmp109_ = self->priv->_email_types;
		_tmp110_ = gee_abstract_collection_iterator ((GeeAbstractCollection*) _tmp109_);
		_pt_it = _tmp110_;
		while (TRUE) {
			GeeIterator* _tmp111_;
			gboolean _tmp112_ = FALSE;
			GeeIterator* _tmp113_;
			gpointer _tmp114_ = NULL;
			gchar* pt;
			const gchar* _tmp115_;
			_tmp111_ = _pt_it;
			_tmp112_ = gee_iterator_next (_tmp111_);
			if (!_tmp112_) {
				break;
			}
			_tmp113_ = _pt_it;
			_tmp114_ = gee_iterator_get (_tmp113_);
			pt = (gchar*) _tmp114_;
			_tmp115_ = pt;
			g_assert (g_strcmp0 (_tmp115_, "OTHER") == 0);
			_g_free0 (pt);
		}
		_g_object_unref0 (_pt_it);
	}
	__vala_GValue_free0 (v);
}


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


static void _email_details_tests_test_email_details_async (EmailDetailsTests* self, GAsyncReadyCallback _callback_, gpointer _user_data_) {
	EmailDetailsTestsTestEmailDetailsAsyncData* _data_;
	EmailDetailsTests* _tmp0_;
	_data_ = g_slice_new0 (EmailDetailsTestsTestEmailDetailsAsyncData);
	_data_->_async_result = g_simple_async_result_new (G_OBJECT (self), _callback_, _user_data_, _email_details_tests_test_email_details_async);
	g_simple_async_result_set_op_res_gpointer (_data_->_async_result, _data_, _email_details_tests_test_email_details_async_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_email_details_tests_test_email_details_async_co (_data_);
}


static void _email_details_tests_test_email_details_finish (EmailDetailsTests* self, GAsyncResult* _res_) {
	EmailDetailsTestsTestEmailDetailsAsyncData* _data_;
	_data_ = g_simple_async_result_get_op_res_gpointer (G_SIMPLE_ASYNC_RESULT (_res_));
}


static void _email_details_tests_test_email_details_async_ready (GObject* source_object, GAsyncResult* _res_, gpointer _user_data_) {
	EmailDetailsTestsTestEmailDetailsAsyncData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	_email_details_tests_test_email_details_async_co (_data_);
}


static void __email_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) {
	_email_details_tests_individuals_changed_cb (self, added, removed, message, actor, reason);
}


static gboolean _email_details_tests_test_email_details_async_co (EmailDetailsTestsTestEmailDetailsAsyncData* _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_, _email_details_tests_test_email_details_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_, _email_details_tests_test_email_details_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) __email_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_, _email_details_tests_test_email_details_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 ("email-details.vala:139: 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 _email_details_tests_individuals_changed_cb (EmailDetailsTests* self, GeeSet* added, GeeSet* removed, const gchar* message, FolksPersona* actor, FolksGroupDetailsChangeReason reason) {
	GeeSet* _tmp73_;
	gint _tmp74_;
	gint _tmp75_;
	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* _tmp23_;
			GeeHashMap* _tmp24_;
			FolksIndividual* _tmp25_;
			FolksEmailDetails* _tmp26_;
			FolksEmailDetails* email_owner;
			_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_;
				} else {
					FolksIndividual* _tmp19_;
					const gchar* _tmp20_;
					const gchar* _tmp21_;
					_tmp19_ = i;
					_tmp20_ = folks_name_details_get_full_name ((FolksNameDetails*) _tmp19_);
					_tmp21_ = _tmp20_;
					if (g_strcmp0 (_tmp21_, "foo bar") == 0) {
						GeeHashMap* _tmp22_;
						_tmp22_ = self->priv->_c3;
						contact = _tmp22_;
					}
				}
			}
			_tmp23_ = contact;
			if (_tmp23_ == NULL) {
				_g_object_unref0 (i);
				continue;
			}
			_tmp24_ = contact;
			gee_abstract_map_unset ((GeeAbstractMap*) _tmp24_, "full_name", NULL);
			_tmp25_ = i;
			_tmp26_ = _g_object_ref0 (FOLKS_EMAIL_DETAILS (_tmp25_));
			email_owner = _tmp26_;
			{
				FolksEmailDetails* _tmp27_;
				GeeSet* _tmp28_;
				GeeSet* _tmp29_;
				GeeIterator* _tmp30_ = NULL;
				GeeIterator* _e_it;
				_tmp27_ = email_owner;
				_tmp28_ = folks_email_details_get_email_addresses (_tmp27_);
				_tmp29_ = _tmp28_;
				_tmp30_ = gee_iterable_iterator ((GeeIterable*) _tmp29_);
				_e_it = _tmp30_;
				while (TRUE) {
					GeeIterator* _tmp31_;
					gboolean _tmp32_ = FALSE;
					GeeIterator* _tmp33_;
					gpointer _tmp34_ = NULL;
					FolksEmailFieldDetails* e;
					gint _tmp35_;
					gboolean found;
					gboolean _tmp61_;
					_tmp31_ = _e_it;
					_tmp32_ = gee_iterator_next (_tmp31_);
					if (!_tmp32_) {
						break;
					}
					_tmp33_ = _e_it;
					_tmp34_ = gee_iterator_get (_tmp33_);
					e = (FolksEmailFieldDetails*) _tmp34_;
					_tmp35_ = self->priv->_email_count;
					self->priv->_email_count = _tmp35_ + 1;
					found = FALSE;
					{
						gint j;
						j = 0;
						{
							gboolean _tmp36_;
							_tmp36_ = TRUE;
							while (TRUE) {
								gboolean _tmp37_;
								gint _tmp39_;
								gint _tmp40_;
								const gchar* _tmp41_;
								gchar* _tmp42_;
								gchar* v;
								gboolean _tmp43_ = FALSE;
								GeeHashMap* _tmp44_;
								const gchar* _tmp45_;
								gpointer _tmp46_ = NULL;
								GValue* _tmp47_;
								gboolean _tmp48_;
								gboolean _tmp58_;
								_tmp37_ = _tmp36_;
								if (!_tmp37_) {
									gint _tmp38_;
									_tmp38_ = j;
									j = _tmp38_ + 1;
								}
								_tmp36_ = FALSE;
								_tmp39_ = j;
								if (!(_tmp39_ < 2)) {
									break;
								}
								_tmp40_ = j;
								_tmp41_ = EDSF_PERSONA_email_fields[_tmp40_];
								_tmp42_ = g_strdup (_tmp41_);
								v = _tmp42_;
								_tmp44_ = contact;
								_tmp45_ = v;
								_tmp46_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp44_, _tmp45_);
								_tmp47_ = (GValue*) _tmp46_;
								_tmp48_ = _tmp47_ != NULL;
								__vala_GValue_free0 (_tmp47_);
								if (_tmp48_) {
									GeeHashMap* _tmp49_;
									const gchar* _tmp50_;
									gpointer _tmp51_ = NULL;
									GValue* _tmp52_;
									GValue _tmp53_;
									const gchar* _tmp54_ = NULL;
									FolksEmailFieldDetails* _tmp55_;
									gconstpointer _tmp56_;
									const gchar* _tmp57_;
									_tmp49_ = contact;
									_tmp50_ = v;
									_tmp51_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp49_, _tmp50_);
									_tmp52_ = (GValue*) _tmp51_;
									_tmp53_ = *_tmp52_;
									_tmp54_ = g_value_get_string (&_tmp53_);
									_tmp55_ = e;
									_tmp56_ = folks_abstract_field_details_get_value ((FolksAbstractFieldDetails*) _tmp55_);
									_tmp57_ = _tmp56_;
									_tmp43_ = g_strcmp0 (_tmp54_, (const gchar*) _tmp57_) == 0;
									__vala_GValue_free0 (_tmp52_);
								} else {
									_tmp43_ = FALSE;
								}
								_tmp58_ = _tmp43_;
								if (_tmp58_) {
									GeeHashMap* _tmp59_;
									const gchar* _tmp60_;
									found = TRUE;
									_tmp59_ = contact;
									_tmp60_ = v;
									gee_abstract_map_unset ((GeeAbstractMap*) _tmp59_, _tmp60_, NULL);
								}
								_g_free0 (v);
							}
						}
					}
					_tmp61_ = found;
					g_assert (_tmp61_);
					{
						FolksEmailFieldDetails* _tmp62_;
						GeeCollection* _tmp63_ = NULL;
						GeeCollection* _tmp64_;
						GeeIterator* _tmp65_ = NULL;
						GeeIterator* _tmp66_;
						GeeIterator* _v_it;
						_tmp62_ = e;
						_tmp63_ = folks_abstract_field_details_get_parameter_values ((FolksAbstractFieldDetails*) _tmp62_, "type");
						_tmp64_ = _tmp63_;
						_tmp65_ = gee_iterable_iterator ((GeeIterable*) _tmp64_);
						_tmp66_ = _tmp65_;
						_g_object_unref0 (_tmp64_);
						_v_it = _tmp66_;
						while (TRUE) {
							GeeIterator* _tmp67_;
							gboolean _tmp68_ = FALSE;
							GeeIterator* _tmp69_;
							gpointer _tmp70_ = NULL;
							gchar* v;
							GeeHashSet* _tmp71_;
							const gchar* _tmp72_;
							_tmp67_ = _v_it;
							_tmp68_ = gee_iterator_next (_tmp67_);
							if (!_tmp68_) {
								break;
							}
							_tmp69_ = _v_it;
							_tmp70_ = gee_iterator_get (_tmp69_);
							v = (gchar*) _tmp70_;
							_tmp71_ = self->priv->_email_types;
							_tmp72_ = v;
							gee_abstract_collection_add ((GeeAbstractCollection*) _tmp71_, _tmp72_);
							_g_free0 (v);
						}
						_g_object_unref0 (_v_it);
					}
					_g_object_unref0 (e);
				}
				_g_object_unref0 (_e_it);
			}
			_g_object_unref0 (email_owner);
			_g_object_unref0 (i);
		}
		_g_object_unref0 (_i_it);
	}
	_tmp73_ = removed;
	_tmp74_ = gee_collection_get_size ((GeeCollection*) _tmp73_);
	_tmp75_ = _tmp74_;
	g_assert (_tmp75_ == 0);
}


static void email_details_tests_class_init (EmailDetailsTestsClass * klass) {
	email_details_tests_parent_class = g_type_class_peek_parent (klass);
	g_type_class_add_private (klass, sizeof (EmailDetailsTestsPrivate));
	FOLKS_TEST_CASE_CLASS (klass)->set_up = email_details_tests_real_set_up;
	FOLKS_TEST_CASE_CLASS (klass)->tear_down = email_details_tests_real_tear_down;
	G_OBJECT_CLASS (klass)->finalize = email_details_tests_finalize;
}


static void email_details_tests_instance_init (EmailDetailsTests * self) {
	self->priv = EMAIL_DETAILS_TESTS_GET_PRIVATE (self);
}


static void email_details_tests_finalize (GObject* obj) {
	EmailDetailsTests * self;
	self = EMAIL_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->_email_types);
	_g_object_unref0 (self->priv->_c1);
	_g_object_unref0 (self->priv->_c2);
	_g_object_unref0 (self->priv->_c3);
	G_OBJECT_CLASS (email_details_tests_parent_class)->finalize (obj);
}


GType email_details_tests_get_type (void) {
	static volatile gsize email_details_tests_type_id__volatile = 0;
	if (g_once_init_enter (&email_details_tests_type_id__volatile)) {
		static const GTypeInfo g_define_type_info = { sizeof (EmailDetailsTestsClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) email_details_tests_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (EmailDetailsTests), 0, (GInstanceInitFunc) email_details_tests_instance_init, NULL };
		GType email_details_tests_type_id;
		email_details_tests_type_id = g_type_register_static (FOLKS_TYPE_TEST_CASE, "EmailDetailsTests", &g_define_type_info, 0);
		g_once_init_leave (&email_details_tests_type_id__volatile, email_details_tests_type_id);
	}
	return email_details_tests_type_id__volatile;
}


gint _vala_main (gchar** args, int args_length1) {
	gint result = 0;
	GTestSuite* _tmp0_ = NULL;
	GTestSuite* root;
	GTestSuite* _tmp1_;
	EmailDetailsTests* _tmp2_;
	EmailDetailsTests* _tmp3_;
	GTestSuite* _tmp4_ = NULL;
	g_test_init (&args_length1, &args, NULL);
	_tmp0_ = g_test_get_root ();
	root = _tmp0_;
	_tmp1_ = root;
	_tmp2_ = email_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);
}



