/* individual-properties.c generated by valac 0.12.0, the Vala compiler
 * generated from individual-properties.vala, do not modify */


#include <glib.h>
#include <glib-object.h>
#include <folks-test.h>
#include <tp-test-contactlist.h>
#include <stdlib.h>
#include <string.h>
#include <folks/folks.h>
#include <gee.h>
#include <folks/folks-telepathy.h>
#include <telepathy-glib/telepathy-glib.h>


#define TYPE_INDIVIDUAL_PROPERTIES_TESTS (individual_properties_tests_get_type ())
#define INDIVIDUAL_PROPERTIES_TESTS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_INDIVIDUAL_PROPERTIES_TESTS, IndividualPropertiesTests))
#define INDIVIDUAL_PROPERTIES_TESTS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_INDIVIDUAL_PROPERTIES_TESTS, IndividualPropertiesTestsClass))
#define IS_INDIVIDUAL_PROPERTIES_TESTS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_INDIVIDUAL_PROPERTIES_TESTS))
#define IS_INDIVIDUAL_PROPERTIES_TESTS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_INDIVIDUAL_PROPERTIES_TESTS))
#define INDIVIDUAL_PROPERTIES_TESTS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_INDIVIDUAL_PROPERTIES_TESTS, IndividualPropertiesTestsClass))

typedef struct _IndividualPropertiesTests IndividualPropertiesTests;
typedef struct _IndividualPropertiesTestsClass IndividualPropertiesTestsClass;
typedef struct _IndividualPropertiesTestsPrivate IndividualPropertiesTestsPrivate;
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))
typedef struct _Block1Data Block1Data;
#define _g_main_loop_unref0(var) ((var == NULL) ? NULL : (var = (g_main_loop_unref (var), NULL)))
typedef struct _Block2Data Block2Data;
typedef struct _Block3Data Block3Data;
typedef struct _Block4Data Block4Data;
typedef struct _Block5Data Block5Data;

struct _IndividualPropertiesTests {
	FolksTestCase parent_instance;
	IndividualPropertiesTestsPrivate * priv;
};

struct _IndividualPropertiesTestsClass {
	FolksTestCaseClass parent_class;
};

struct _IndividualPropertiesTestsPrivate {
	TpTestBackend* tp_backend;
	void* _account_handle;
	gchar* individual_id_prefix;
	gint _test_timeout;
};

struct _Block1Data {
	int _ref_count_;
	IndividualPropertiesTests * self;
	GMainLoop* main_loop;
};

struct _Block2Data {
	int _ref_count_;
	IndividualPropertiesTests * self;
	GMainLoop* main_loop;
	gboolean alias_notified;
};

struct _Block3Data {
	int _ref_count_;
	Block2Data * _data2_;
	gchar* new_alias;
};

struct _Block4Data {
	int _ref_count_;
	IndividualPropertiesTests * self;
	GMainLoop* main_loop;
	gboolean alias_notified;
};

struct _Block5Data {
	int _ref_count_;
	Block4Data * _data4_;
	gchar* new_alias;
};


static gpointer individual_properties_tests_parent_class = NULL;

GType individual_properties_tests_get_type (void) G_GNUC_CONST;
#define INDIVIDUAL_PROPERTIES_TESTS_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), TYPE_INDIVIDUAL_PROPERTIES_TESTS, IndividualPropertiesTestsPrivate))
enum  {
	INDIVIDUAL_PROPERTIES_TESTS_DUMMY_PROPERTY
};
IndividualPropertiesTests* individual_properties_tests_new (void);
IndividualPropertiesTests* individual_properties_tests_construct (GType object_type);
void individual_properties_tests_test_individual_properties (IndividualPropertiesTests* self);
static void _individual_properties_tests_test_individual_properties_folks_test_case_test_method (gpointer self);
void individual_properties_tests_test_individual_properties_change_alias_through_tp_backend (IndividualPropertiesTests* self);
static void _individual_properties_tests_test_individual_properties_change_alias_through_tp_backend_folks_test_case_test_method (gpointer self);
void individual_properties_tests_test_individual_properties_change_alias_through_test_cm (IndividualPropertiesTests* self);
static void _individual_properties_tests_test_individual_properties_change_alias_through_test_cm_folks_test_case_test_method (gpointer self);
static void individual_properties_tests_real_set_up (FolksTestCase* base);
static void individual_properties_tests_real_tear_down (FolksTestCase* base);
static Block1Data* block1_data_ref (Block1Data* _data1_);
static void block1_data_unref (Block1Data* _data1_);
static void _lambda0_ (GeeSet* added, GeeSet* removed, const gchar* m, FolksPersona* a, FolksGroupDetailsChangeReason r, IndividualPropertiesTests* self);
static void __lambda0__folks_individual_aggregator_individuals_changed (FolksIndividualAggregator* _sender, GeeSet* added, GeeSet* removed, const gchar* message, FolksPersona* actor, FolksGroupDetailsChangeReason reason, gpointer self);
static gboolean _lambda1_ (Block1Data* _data1_);
static gboolean __lambda1__gsource_func (gpointer self);
static Block2Data* block2_data_ref (Block2Data* _data2_);
static void block2_data_unref (Block2Data* _data2_);
static void _lambda2_ (GeeSet* added, GeeSet* removed, const gchar* m, FolksPersona* a, FolksGroupDetailsChangeReason r, Block2Data* _data2_);
static Block3Data* block3_data_ref (Block3Data* _data3_);
static void block3_data_unref (Block3Data* _data3_);
static void _lambda3_ (GObject* s, GParamSpec* p, Block3Data* _data3_);
static void __lambda3__g_object_notify (GObject* _sender, GParamSpec* pspec, gpointer self);
static void __lambda2__folks_individual_aggregator_individuals_changed (FolksIndividualAggregator* _sender, GeeSet* added, GeeSet* removed, const gchar* message, FolksPersona* actor, FolksGroupDetailsChangeReason reason, gpointer self);
static gboolean _lambda4_ (Block2Data* _data2_);
static gboolean __lambda4__gsource_func (gpointer self);
static Block4Data* block4_data_ref (Block4Data* _data4_);
static void block4_data_unref (Block4Data* _data4_);
static void _lambda5_ (GeeSet* added, GeeSet* removed, const gchar* m, FolksPersona* a, FolksGroupDetailsChangeReason r, Block4Data* _data4_);
static Block5Data* block5_data_ref (Block5Data* _data5_);
static void block5_data_unref (Block5Data* _data5_);
static void _lambda6_ (GObject* s, GParamSpec* p, Block5Data* _data5_);
static void __lambda6__g_object_notify (GObject* _sender, GParamSpec* pspec, gpointer self);
static void __lambda5__folks_individual_aggregator_individuals_changed (FolksIndividualAggregator* _sender, GeeSet* added, GeeSet* removed, const gchar* message, FolksPersona* actor, FolksGroupDetailsChangeReason reason, gpointer self);
static gboolean _lambda7_ (Block4Data* _data4_);
static gboolean __lambda7__gsource_func (gpointer self);
static void individual_properties_tests_finalize (GObject* obj);
gint _vala_main (gchar** args, int args_length1);


static void _individual_properties_tests_test_individual_properties_folks_test_case_test_method (gpointer self) {
	individual_properties_tests_test_individual_properties (self);
}


static void _individual_properties_tests_test_individual_properties_change_alias_through_tp_backend_folks_test_case_test_method (gpointer self) {
	individual_properties_tests_test_individual_properties_change_alias_through_tp_backend (self);
}


static void _individual_properties_tests_test_individual_properties_change_alias_through_test_cm_folks_test_case_test_method (gpointer self) {
	individual_properties_tests_test_individual_properties_change_alias_through_test_cm (self);
}


IndividualPropertiesTests* individual_properties_tests_construct (GType object_type) {
	IndividualPropertiesTests * self = NULL;
	TpTestBackend* _tmp0_ = NULL;
	const gchar* _tmp1_ = NULL;
	self = (IndividualPropertiesTests*) folks_test_case_construct (object_type, "IndividualProperties");
	_tmp0_ = tp_test_backend_new ();
	_g_object_unref0 (self->priv->tp_backend);
	self->priv->tp_backend = _tmp0_;
	folks_test_case_add_test ((FolksTestCase*) self, "individual properties", _individual_properties_tests_test_individual_properties_folks_test_case_test_method, self);
	folks_test_case_add_test ((FolksTestCase*) self, "individual properties:change alias through tp backend", _individual_properties_tests_test_individual_properties_change_alias_through_tp_backend_folks_test_case_test_method, self);
	folks_test_case_add_test ((FolksTestCase*) self, "individual properties:change alias through test cm", _individual_properties_tests_test_individual_properties_change_alias_through_test_cm_folks_test_case_test_method, self);
	_tmp1_ = g_getenv ("FOLKS_TEST_VALGRIND");
	if (_tmp1_ != NULL) {
		self->priv->_test_timeout = 10;
	}
	return self;
}


IndividualPropertiesTests* individual_properties_tests_new (void) {
	return individual_properties_tests_construct (TYPE_INDIVIDUAL_PROPERTIES_TESTS);
}


static void individual_properties_tests_real_set_up (FolksTestCase* base) {
	IndividualPropertiesTests * self;
	void* _tmp0_ = NULL;
	self = (IndividualPropertiesTests*) base;
	tp_test_backend_set_up (self->priv->tp_backend);
	_tmp0_ = tp_test_backend_add_account (self->priv->tp_backend, "protocol", "me@example.com", "cm", "account");
	self->priv->_account_handle = _tmp0_;
}


static void individual_properties_tests_real_tear_down (FolksTestCase* base) {
	IndividualPropertiesTests * self;
	self = (IndividualPropertiesTests*) base;
	tp_test_backend_remove_account (self->priv->tp_backend, self->priv->_account_handle);
	tp_test_backend_tear_down (self->priv->tp_backend);
}


static Block1Data* block1_data_ref (Block1Data* _data1_) {
	g_atomic_int_inc (&_data1_->_ref_count_);
	return _data1_;
}


static void block1_data_unref (Block1Data* _data1_) {
	if (g_atomic_int_dec_and_test (&_data1_->_ref_count_)) {
		_g_object_unref0 (_data1_->self);
		_g_main_loop_unref0 (_data1_->main_loop);
		g_slice_free (Block1Data, _data1_);
	}
}


static void _lambda0_ (GeeSet* added, GeeSet* removed, const gchar* m, FolksPersona* a, FolksGroupDetailsChangeReason r, IndividualPropertiesTests* self) {
	gint _tmp17_;
	g_return_if_fail (added != NULL);
	g_return_if_fail (removed != NULL);
	{
		GeeIterator* _tmp0_ = NULL;
		GeeIterator* _i_it;
		_tmp0_ = gee_iterable_iterator ((GeeIterable*) added);
		_i_it = _tmp0_;
		while (TRUE) {
			gboolean _tmp1_;
			gpointer _tmp2_ = NULL;
			FolksIndividual* i;
			const gchar* _tmp3_ = NULL;
			gchar* _tmp4_;
			gchar* _tmp5_;
			gboolean _tmp6_;
			const gchar* _tmp7_ = NULL;
			const gchar* _tmp8_ = NULL;
			FolksPresenceType _tmp9_;
			gboolean _tmp10_;
			GeeSet* _tmp11_ = NULL;
			gint _tmp12_;
			GeeSet* _tmp13_ = NULL;
			gboolean _tmp14_;
			GeeSet* _tmp15_ = NULL;
			gboolean _tmp16_;
			_tmp1_ = gee_iterator_next (_i_it);
			if (!_tmp1_) {
				break;
			}
			_tmp2_ = gee_iterator_get (_i_it);
			i = (FolksIndividual*) _tmp2_;
			_tmp3_ = folks_individual_get_id (i);
			_tmp4_ = g_strconcat (self->priv->individual_id_prefix, "olivier@example.com", NULL);
			_tmp5_ = _tmp4_;
			_tmp6_ = g_strcmp0 (_tmp3_, _tmp5_) != 0;
			_g_free0 (_tmp5_);
			if (_tmp6_) {
				_g_object_unref0 (i);
				continue;
			}
			_tmp7_ = folks_alias_details_get_alias ((FolksAliasDetails*) i);
			g_assert (g_strcmp0 (_tmp7_, "Olivier") == 0);
			_tmp8_ = folks_presence_details_get_presence_message ((FolksPresenceDetails*) i);
			g_assert (g_strcmp0 (_tmp8_, "") == 0);
			_tmp9_ = folks_presence_details_get_presence_type ((FolksPresenceDetails*) i);
			g_assert (_tmp9_ == FOLKS_PRESENCE_TYPE_AWAY);
			_tmp10_ = folks_presence_details_is_online (FOLKS_PRESENCE_DETAILS (i));
			g_assert (_tmp10_ == TRUE);
			_tmp11_ = folks_group_details_get_groups ((FolksGroupDetails*) i);
			_tmp12_ = gee_collection_get_size ((GeeCollection*) _tmp11_);
			g_assert (_tmp12_ == 2);
			_tmp13_ = folks_group_details_get_groups ((FolksGroupDetails*) i);
			_tmp14_ = gee_collection_contains ((GeeCollection*) _tmp13_, "Montreal");
			g_assert (_tmp14_ == TRUE);
			_tmp15_ = folks_group_details_get_groups ((FolksGroupDetails*) i);
			_tmp16_ = gee_collection_contains ((GeeCollection*) _tmp15_, "Francophones");
			g_assert (_tmp16_ == TRUE);
			_g_object_unref0 (i);
		}
		_g_object_unref0 (_i_it);
	}
	_tmp17_ = gee_collection_get_size ((GeeCollection*) removed);
	g_assert (_tmp17_ == 0);
}


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


static gboolean _lambda1_ (Block1Data* _data1_) {
	IndividualPropertiesTests * self;
	gboolean result = FALSE;
	self = _data1_->self;
	g_main_loop_quit (_data1_->main_loop);
	result = FALSE;
	return result;
}


static gboolean __lambda1__gsource_func (gpointer self) {
	gboolean result;
	result = _lambda1_ (self);
	return result;
}


void individual_properties_tests_test_individual_properties (IndividualPropertiesTests* self) {
	Block1Data* _data1_;
	GMainLoop* _tmp0_ = NULL;
	FolksIndividualAggregator* _tmp1_ = NULL;
	FolksIndividualAggregator* aggregator;
	g_return_if_fail (self != NULL);
	_data1_ = g_slice_new0 (Block1Data);
	_data1_->_ref_count_ = 1;
	_data1_->self = g_object_ref (self);
	_tmp0_ = g_main_loop_new (NULL, FALSE);
	_data1_->main_loop = _tmp0_;
	_tmp1_ = folks_individual_aggregator_new ();
	aggregator = _tmp1_;
	g_signal_connect_object (aggregator, "individuals-changed", (GCallback) __lambda0__folks_individual_aggregator_individuals_changed, self, 0);
	folks_individual_aggregator_prepare (aggregator, NULL, NULL);
	g_timeout_add_seconds_full (G_PRIORITY_DEFAULT, (guint) self->priv->_test_timeout, __lambda1__gsource_func, block1_data_ref (_data1_), block1_data_unref);
	g_main_loop_run (_data1_->main_loop);
	_g_object_unref0 (aggregator);
	aggregator = NULL;
	_g_object_unref0 (aggregator);
	block1_data_unref (_data1_);
	_data1_ = NULL;
}


static Block2Data* block2_data_ref (Block2Data* _data2_) {
	g_atomic_int_inc (&_data2_->_ref_count_);
	return _data2_;
}


static void block2_data_unref (Block2Data* _data2_) {
	if (g_atomic_int_dec_and_test (&_data2_->_ref_count_)) {
		_g_object_unref0 (_data2_->self);
		_g_main_loop_unref0 (_data2_->main_loop);
		g_slice_free (Block2Data, _data2_);
	}
}


static Block3Data* block3_data_ref (Block3Data* _data3_) {
	g_atomic_int_inc (&_data3_->_ref_count_);
	return _data3_;
}


static void block3_data_unref (Block3Data* _data3_) {
	if (g_atomic_int_dec_and_test (&_data3_->_ref_count_)) {
		block2_data_unref (_data3_->_data2_);
		_data3_->_data2_ = NULL;
		_g_free0 (_data3_->new_alias);
		g_slice_free (Block3Data, _data3_);
	}
}


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


static void _lambda3_ (GObject* s, GParamSpec* p, Block3Data* _data3_) {
	Block2Data* _data2_;
	IndividualPropertiesTests * self;
	FolksIndividual* _tmp0_;
	FolksIndividual* ind;
	const gchar* _tmp1_ = NULL;
	_data2_ = _data3_->_data2_;
	self = _data2_->self;
	g_return_if_fail (s != NULL);
	g_return_if_fail (p != NULL);
	_tmp0_ = _g_object_ref0 (FOLKS_INDIVIDUAL (s));
	ind = _tmp0_;
	_tmp1_ = folks_alias_details_get_alias ((FolksAliasDetails*) ind);
	if (g_strcmp0 (_tmp1_, _data3_->new_alias) == 0) {
		_data2_->alias_notified = TRUE;
	}
	_g_object_unref0 (ind);
}


static void __lambda3__g_object_notify (GObject* _sender, GParamSpec* pspec, gpointer self) {
	_lambda3_ (_sender, pspec, self);
}


static void _lambda2_ (GeeSet* added, GeeSet* removed, const gchar* m, FolksPersona* a, FolksGroupDetailsChangeReason r, Block2Data* _data2_) {
	IndividualPropertiesTests * self;
	Block3Data* _data3_;
	gchar* _tmp0_;
	gint _tmp14_;
	self = _data2_->self;
	g_return_if_fail (added != NULL);
	g_return_if_fail (removed != NULL);
	_data3_ = g_slice_new0 (Block3Data);
	_data3_->_ref_count_ = 1;
	_data3_->_data2_ = block2_data_ref (_data2_);
	_tmp0_ = g_strdup ("New Alias");
	_data3_->new_alias = _tmp0_;
	{
		GeeIterator* _tmp1_ = NULL;
		GeeIterator* _i_it;
		_tmp1_ = gee_iterable_iterator ((GeeIterable*) added);
		_i_it = _tmp1_;
		while (TRUE) {
			gboolean _tmp2_;
			gpointer _tmp3_ = NULL;
			FolksIndividual* i;
			const gchar* _tmp4_ = NULL;
			gchar* _tmp5_;
			gchar* _tmp6_;
			gboolean _tmp7_;
			const gchar* _tmp8_ = NULL;
			FolksPersona* persona;
			_tmp2_ = gee_iterator_next (_i_it);
			if (!_tmp2_) {
				break;
			}
			_tmp3_ = gee_iterator_get (_i_it);
			i = (FolksIndividual*) _tmp3_;
			_tmp4_ = folks_individual_get_id (i);
			_tmp5_ = g_strconcat (self->priv->individual_id_prefix, "olivier@example.com", NULL);
			_tmp6_ = _tmp5_;
			_tmp7_ = g_strcmp0 (_tmp4_, _tmp6_) != 0;
			_g_free0 (_tmp6_);
			if (_tmp7_) {
				_g_object_unref0 (i);
				continue;
			}
			_tmp8_ = folks_alias_details_get_alias ((FolksAliasDetails*) i);
			g_assert (g_strcmp0 (_tmp8_, _data3_->new_alias) != 0);
			g_signal_connect_data ((GObject*) i, "notify::alias", (GCallback) __lambda3__g_object_notify, block3_data_ref (_data3_), (GClosureNotify) block3_data_unref, 0);
			persona = NULL;
			{
				GeeSet* _tmp9_ = NULL;
				GeeIterator* _tmp10_ = NULL;
				GeeIterator* _p_it;
				_tmp9_ = folks_individual_get_personas (i);
				_tmp10_ = gee_iterable_iterator ((GeeIterable*) _tmp9_);
				_p_it = _tmp10_;
				while (TRUE) {
					gboolean _tmp11_;
					gpointer _tmp12_ = NULL;
					FolksPersona* p;
					FolksPersona* _tmp13_;
					_tmp11_ = gee_iterator_next (_p_it);
					if (!_tmp11_) {
						break;
					}
					_tmp12_ = gee_iterator_get (_p_it);
					p = (FolksPersona*) _tmp12_;
					_tmp13_ = _g_object_ref0 (p);
					_g_object_unref0 (persona);
					persona = _tmp13_;
					_g_object_unref0 (p);
					break;
				}
				_g_object_unref0 (_p_it);
			}
			g_assert (TPF_IS_PERSONA (persona));
			folks_alias_details_set_alias ((FolksAliasDetails*) TPF_PERSONA (persona), _data3_->new_alias);
			_g_object_unref0 (persona);
			_g_object_unref0 (i);
		}
		_g_object_unref0 (_i_it);
	}
	_tmp14_ = gee_collection_get_size ((GeeCollection*) removed);
	g_assert (_tmp14_ == 0);
	block3_data_unref (_data3_);
	_data3_ = NULL;
}


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


static gboolean _lambda4_ (Block2Data* _data2_) {
	IndividualPropertiesTests * self;
	gboolean result = FALSE;
	self = _data2_->self;
	g_main_loop_quit (_data2_->main_loop);
	result = FALSE;
	return result;
}


static gboolean __lambda4__gsource_func (gpointer self) {
	gboolean result;
	result = _lambda4_ (self);
	return result;
}


void individual_properties_tests_test_individual_properties_change_alias_through_tp_backend (IndividualPropertiesTests* self) {
	Block2Data* _data2_;
	GMainLoop* _tmp0_ = NULL;
	FolksIndividualAggregator* _tmp1_ = NULL;
	FolksIndividualAggregator* aggregator;
	g_return_if_fail (self != NULL);
	_data2_ = g_slice_new0 (Block2Data);
	_data2_->_ref_count_ = 1;
	_data2_->self = g_object_ref (self);
	_tmp0_ = g_main_loop_new (NULL, FALSE);
	_data2_->main_loop = _tmp0_;
	_data2_->alias_notified = FALSE;
	_tmp1_ = folks_individual_aggregator_new ();
	aggregator = _tmp1_;
	g_signal_connect_data (aggregator, "individuals-changed", (GCallback) __lambda2__folks_individual_aggregator_individuals_changed, block2_data_ref (_data2_), (GClosureNotify) block2_data_unref, 0);
	folks_individual_aggregator_prepare (aggregator, NULL, NULL);
	g_timeout_add_seconds_full (G_PRIORITY_DEFAULT, (guint) self->priv->_test_timeout, __lambda4__gsource_func, block2_data_ref (_data2_), block2_data_unref);
	g_main_loop_run (_data2_->main_loop);
	g_assert (_data2_->alias_notified);
	_g_object_unref0 (aggregator);
	aggregator = NULL;
	_g_object_unref0 (aggregator);
	block2_data_unref (_data2_);
	_data2_ = NULL;
}


static Block4Data* block4_data_ref (Block4Data* _data4_) {
	g_atomic_int_inc (&_data4_->_ref_count_);
	return _data4_;
}


static void block4_data_unref (Block4Data* _data4_) {
	if (g_atomic_int_dec_and_test (&_data4_->_ref_count_)) {
		_g_object_unref0 (_data4_->self);
		_g_main_loop_unref0 (_data4_->main_loop);
		g_slice_free (Block4Data, _data4_);
	}
}


static Block5Data* block5_data_ref (Block5Data* _data5_) {
	g_atomic_int_inc (&_data5_->_ref_count_);
	return _data5_;
}


static void block5_data_unref (Block5Data* _data5_) {
	if (g_atomic_int_dec_and_test (&_data5_->_ref_count_)) {
		block4_data_unref (_data5_->_data4_);
		_data5_->_data4_ = NULL;
		_g_free0 (_data5_->new_alias);
		g_slice_free (Block5Data, _data5_);
	}
}


static void _lambda6_ (GObject* s, GParamSpec* p, Block5Data* _data5_) {
	Block4Data* _data4_;
	IndividualPropertiesTests * self;
	FolksIndividual* _tmp0_;
	FolksIndividual* ind;
	const gchar* _tmp1_ = NULL;
	_data4_ = _data5_->_data4_;
	self = _data4_->self;
	g_return_if_fail (s != NULL);
	g_return_if_fail (p != NULL);
	_tmp0_ = _g_object_ref0 (FOLKS_INDIVIDUAL (s));
	ind = _tmp0_;
	_tmp1_ = folks_alias_details_get_alias ((FolksAliasDetails*) ind);
	if (g_strcmp0 (_tmp1_, _data5_->new_alias) == 0) {
		_data4_->alias_notified = TRUE;
	}
	_g_object_unref0 (ind);
}


static void __lambda6__g_object_notify (GObject* _sender, GParamSpec* pspec, gpointer self) {
	_lambda6_ (_sender, pspec, self);
}


static void _lambda5_ (GeeSet* added, GeeSet* removed, const gchar* m, FolksPersona* a, FolksGroupDetailsChangeReason r, Block4Data* _data4_) {
	IndividualPropertiesTests * self;
	Block5Data* _data5_;
	gchar* _tmp0_;
	gint _tmp18_;
	self = _data4_->self;
	g_return_if_fail (added != NULL);
	g_return_if_fail (removed != NULL);
	_data5_ = g_slice_new0 (Block5Data);
	_data5_->_ref_count_ = 1;
	_data5_->_data4_ = block4_data_ref (_data4_);
	_tmp0_ = g_strdup ("New Alias");
	_data5_->new_alias = _tmp0_;
	{
		GeeIterator* _tmp1_ = NULL;
		GeeIterator* _i_it;
		_tmp1_ = gee_iterable_iterator ((GeeIterable*) added);
		_i_it = _tmp1_;
		while (TRUE) {
			gboolean _tmp2_;
			gpointer _tmp3_ = NULL;
			FolksIndividual* i;
			const gchar* _tmp4_ = NULL;
			gchar* _tmp5_;
			gchar* _tmp6_;
			gboolean _tmp7_;
			const gchar* _tmp8_ = NULL;
			FolksPersona* persona;
			TpContact* _tmp14_ = NULL;
			guint _tmp15_;
			TpHandle handle;
			TpTestContactListConnection* _tmp16_ = NULL;
			TpTestContactListManager* _tmp17_ = NULL;
			_tmp2_ = gee_iterator_next (_i_it);
			if (!_tmp2_) {
				break;
			}
			_tmp3_ = gee_iterator_get (_i_it);
			i = (FolksIndividual*) _tmp3_;
			_tmp4_ = folks_individual_get_id (i);
			_tmp5_ = g_strconcat (self->priv->individual_id_prefix, "olivier@example.com", NULL);
			_tmp6_ = _tmp5_;
			_tmp7_ = g_strcmp0 (_tmp4_, _tmp6_) != 0;
			_g_free0 (_tmp6_);
			if (_tmp7_) {
				_g_object_unref0 (i);
				continue;
			}
			_tmp8_ = folks_alias_details_get_alias ((FolksAliasDetails*) i);
			g_assert (g_strcmp0 (_tmp8_, _data5_->new_alias) != 0);
			g_signal_connect_data ((GObject*) i, "notify::alias", (GCallback) __lambda6__g_object_notify, block5_data_ref (_data5_), (GClosureNotify) block5_data_unref, 0);
			persona = NULL;
			{
				GeeSet* _tmp9_ = NULL;
				GeeIterator* _tmp10_ = NULL;
				GeeIterator* _p_it;
				_tmp9_ = folks_individual_get_personas (i);
				_tmp10_ = gee_iterable_iterator ((GeeIterable*) _tmp9_);
				_p_it = _tmp10_;
				while (TRUE) {
					gboolean _tmp11_;
					gpointer _tmp12_ = NULL;
					FolksPersona* p;
					FolksPersona* _tmp13_;
					_tmp11_ = gee_iterator_next (_p_it);
					if (!_tmp11_) {
						break;
					}
					_tmp12_ = gee_iterator_get (_p_it);
					p = (FolksPersona*) _tmp12_;
					_tmp13_ = _g_object_ref0 (p);
					_g_object_unref0 (persona);
					persona = _tmp13_;
					_g_object_unref0 (p);
					break;
				}
				_g_object_unref0 (_p_it);
			}
			g_assert (TPF_IS_PERSONA (persona));
			_tmp14_ = tpf_persona_get_contact (TPF_PERSONA (persona));
			_tmp15_ = tp_contact_get_handle (_tmp14_);
			handle = (TpHandle) _tmp15_;
			_tmp16_ = tp_test_backend_get_connection (self->priv->tp_backend);
			_tmp17_ = tp_test_contact_list_connection_get_manager (_tmp16_);
			tp_test_contact_list_manager_set_alias (_tmp17_, handle, _data5_->new_alias);
			_g_object_unref0 (persona);
			_g_object_unref0 (i);
		}
		_g_object_unref0 (_i_it);
	}
	_tmp18_ = gee_collection_get_size ((GeeCollection*) removed);
	g_assert (_tmp18_ == 0);
	block5_data_unref (_data5_);
	_data5_ = NULL;
}


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


static gboolean _lambda7_ (Block4Data* _data4_) {
	IndividualPropertiesTests * self;
	gboolean result = FALSE;
	self = _data4_->self;
	g_main_loop_quit (_data4_->main_loop);
	result = FALSE;
	return result;
}


static gboolean __lambda7__gsource_func (gpointer self) {
	gboolean result;
	result = _lambda7_ (self);
	return result;
}


void individual_properties_tests_test_individual_properties_change_alias_through_test_cm (IndividualPropertiesTests* self) {
	Block4Data* _data4_;
	GMainLoop* _tmp0_ = NULL;
	FolksIndividualAggregator* _tmp1_ = NULL;
	FolksIndividualAggregator* aggregator;
	g_return_if_fail (self != NULL);
	_data4_ = g_slice_new0 (Block4Data);
	_data4_->_ref_count_ = 1;
	_data4_->self = g_object_ref (self);
	_tmp0_ = g_main_loop_new (NULL, FALSE);
	_data4_->main_loop = _tmp0_;
	_data4_->alias_notified = FALSE;
	_tmp1_ = folks_individual_aggregator_new ();
	aggregator = _tmp1_;
	g_signal_connect_data (aggregator, "individuals-changed", (GCallback) __lambda5__folks_individual_aggregator_individuals_changed, block4_data_ref (_data4_), (GClosureNotify) block4_data_unref, 0);
	folks_individual_aggregator_prepare (aggregator, NULL, NULL);
	g_timeout_add_seconds_full (G_PRIORITY_DEFAULT, (guint) self->priv->_test_timeout, __lambda7__gsource_func, block4_data_ref (_data4_), block4_data_unref);
	g_main_loop_run (_data4_->main_loop);
	g_assert (_data4_->alias_notified);
	_g_object_unref0 (aggregator);
	aggregator = NULL;
	_g_object_unref0 (aggregator);
	block4_data_unref (_data4_);
	_data4_ = NULL;
}


static void individual_properties_tests_class_init (IndividualPropertiesTestsClass * klass) {
	individual_properties_tests_parent_class = g_type_class_peek_parent (klass);
	g_type_class_add_private (klass, sizeof (IndividualPropertiesTestsPrivate));
	FOLKS_TEST_CASE_CLASS (klass)->set_up = individual_properties_tests_real_set_up;
	FOLKS_TEST_CASE_CLASS (klass)->tear_down = individual_properties_tests_real_tear_down;
	G_OBJECT_CLASS (klass)->finalize = individual_properties_tests_finalize;
}


static void individual_properties_tests_instance_init (IndividualPropertiesTests * self) {
	gchar* _tmp0_;
	self->priv = INDIVIDUAL_PROPERTIES_TESTS_GET_PRIVATE (self);
	_tmp0_ = g_strdup ("telepathy:/org/freedesktop/Telepathy/Account/cm/protocol/account:");
	self->priv->individual_id_prefix = _tmp0_;
	self->priv->_test_timeout = 3;
}


static void individual_properties_tests_finalize (GObject* obj) {
	IndividualPropertiesTests * self;
	self = INDIVIDUAL_PROPERTIES_TESTS (obj);
	_g_object_unref0 (self->priv->tp_backend);
	_g_free0 (self->priv->individual_id_prefix);
	G_OBJECT_CLASS (individual_properties_tests_parent_class)->finalize (obj);
}


GType individual_properties_tests_get_type (void) {
	static volatile gsize individual_properties_tests_type_id__volatile = 0;
	if (g_once_init_enter (&individual_properties_tests_type_id__volatile)) {
		static const GTypeInfo g_define_type_info = { sizeof (IndividualPropertiesTestsClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) individual_properties_tests_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (IndividualPropertiesTests), 0, (GInstanceInitFunc) individual_properties_tests_instance_init, NULL };
		GType individual_properties_tests_type_id;
		individual_properties_tests_type_id = g_type_register_static (FOLKS_TYPE_TEST_CASE, "IndividualPropertiesTests", &g_define_type_info, 0);
		g_once_init_leave (&individual_properties_tests_type_id__volatile, individual_properties_tests_type_id);
	}
	return individual_properties_tests_type_id__volatile;
}


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


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



