/* individual-properties.c generated by valac 0.13.1.106-1068, the Vala compiler
 * generated from individual-properties.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: Travis Reitter <travis.reitter@collabora.co.uk>
 */

#include <glib.h>
#include <glib-object.h>
#include <folks-test.h>
#include <tp-test-contactlist.h>
#include <folks/folks.h>
#include <gee.h>
#include <stdlib.h>
#include <string.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)))
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;
#define _g_free0(var) (var = (g_free (var), NULL))
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;
	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_;
	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;
	TpTestBackend* _tmp0_;
	TpTestBackend* _tmp1_;
	void* _tmp2_ = NULL;
	self = (IndividualPropertiesTests*) base;
	_tmp0_ = self->priv->tp_backend;
	tp_test_backend_set_up (_tmp0_);
	_tmp1_ = self->priv->tp_backend;
	_tmp2_ = tp_test_backend_add_account (_tmp1_, "protocol", "me@example.com", "cm", "account");
	self->priv->_account_handle = _tmp2_;
}


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


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) {
	GeeSet* _tmp36_;
	gint _tmp37_;
	gint _tmp38_;
	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;
			FolksIndividual* _tmp6_;
			const gchar* _tmp7_;
			const gchar* _tmp8_;
			FolksIndividual* _tmp9_;
			const gchar* _tmp10_;
			const gchar* _tmp11_;
			FolksIndividual* _tmp12_;
			const gchar* _tmp13_;
			const gchar* _tmp14_;
			FolksIndividual* _tmp15_;
			const gchar* _tmp16_;
			const gchar* _tmp17_;
			FolksIndividual* _tmp18_;
			FolksPresenceType _tmp19_;
			FolksPresenceType _tmp20_;
			FolksIndividual* _tmp21_;
			gboolean _tmp22_ = FALSE;
			FolksIndividual* _tmp23_;
			GeeSet* _tmp24_;
			GeeSet* _tmp25_;
			gint _tmp26_;
			gint _tmp27_;
			FolksIndividual* _tmp28_;
			GeeSet* _tmp29_;
			GeeSet* _tmp30_;
			gboolean _tmp31_ = FALSE;
			FolksIndividual* _tmp32_;
			GeeSet* _tmp33_;
			GeeSet* _tmp34_;
			gboolean _tmp35_ = FALSE;
			_tmp2_ = _i_it;
			_tmp3_ = gee_iterator_next (_tmp2_);
			if (!_tmp3_) {
				break;
			}
			_tmp4_ = _i_it;
			_tmp5_ = gee_iterator_get (_tmp4_);
			i = (FolksIndividual*) _tmp5_;
			_tmp6_ = i;
			_tmp7_ = folks_individual_get_id (_tmp6_);
			_tmp8_ = _tmp7_;
			if (g_strcmp0 (_tmp8_, "0e46c5e74f61908f49550d241f2a1651892a1695") != 0) {
				_g_object_unref0 (i);
				continue;
			}
			_tmp9_ = i;
			_tmp10_ = folks_alias_details_get_alias ((FolksAliasDetails*) _tmp9_);
			_tmp11_ = _tmp10_;
			g_assert (g_strcmp0 (_tmp11_, "Olivier") == 0);
			_tmp12_ = i;
			_tmp13_ = folks_presence_details_get_presence_message ((FolksPresenceDetails*) _tmp12_);
			_tmp14_ = _tmp13_;
			g_assert (g_strcmp0 (_tmp14_, "") == 0);
			_tmp15_ = i;
			_tmp16_ = folks_presence_details_get_presence_status ((FolksPresenceDetails*) _tmp15_);
			_tmp17_ = _tmp16_;
			g_assert (g_strcmp0 (_tmp17_, "away") == 0);
			_tmp18_ = i;
			_tmp19_ = folks_presence_details_get_presence_type ((FolksPresenceDetails*) _tmp18_);
			_tmp20_ = _tmp19_;
			g_assert (_tmp20_ == FOLKS_PRESENCE_TYPE_AWAY);
			_tmp21_ = i;
			_tmp22_ = folks_presence_details_is_online (FOLKS_PRESENCE_DETAILS (_tmp21_));
			g_assert (_tmp22_ == TRUE);
			_tmp23_ = i;
			_tmp24_ = folks_group_details_get_groups ((FolksGroupDetails*) _tmp23_);
			_tmp25_ = _tmp24_;
			_tmp26_ = gee_collection_get_size ((GeeCollection*) _tmp25_);
			_tmp27_ = _tmp26_;
			g_assert (_tmp27_ == 2);
			_tmp28_ = i;
			_tmp29_ = folks_group_details_get_groups ((FolksGroupDetails*) _tmp28_);
			_tmp30_ = _tmp29_;
			_tmp31_ = gee_collection_contains ((GeeCollection*) _tmp30_, "Montreal");
			g_assert (_tmp31_ == TRUE);
			_tmp32_ = i;
			_tmp33_ = folks_group_details_get_groups ((FolksGroupDetails*) _tmp32_);
			_tmp34_ = _tmp33_;
			_tmp35_ = gee_collection_contains ((GeeCollection*) _tmp34_, "Francophones");
			g_assert (_tmp35_ == TRUE);
			_g_object_unref0 (i);
		}
		_g_object_unref0 (_i_it);
	}
	_tmp36_ = removed;
	_tmp37_ = gee_collection_get_size ((GeeCollection*) _tmp36_);
	_tmp38_ = _tmp37_;
	g_assert (_tmp38_ == 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;
	GMainLoop* _tmp0_;
	self = _data1_->self;
	_tmp0_ = _data1_->main_loop;
	g_main_loop_quit (_tmp0_);
	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_;
	FolksIndividualAggregator* _tmp1_;
	FolksIndividualAggregator* aggregator;
	FolksIndividualAggregator* _tmp2_;
	FolksIndividualAggregator* _tmp3_;
	gint _tmp4_;
	GMainLoop* _tmp5_;
	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_;
	_tmp2_ = aggregator;
	g_signal_connect_object (_tmp2_, "individuals-changed", (GCallback) __lambda0__folks_individual_aggregator_individuals_changed, self, 0);
	_tmp3_ = aggregator;
	folks_individual_aggregator_prepare (_tmp3_, NULL, NULL);
	_tmp4_ = self->priv->_test_timeout;
	g_timeout_add_seconds_full (G_PRIORITY_DEFAULT, (guint) _tmp4_, __lambda1__gsource_func, block1_data_ref (_data1_), block1_data_unref);
	_tmp5_ = _data1_->main_loop;
	g_main_loop_run (_tmp5_);
	_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;
	GObject* _tmp0_;
	FolksIndividual* _tmp1_;
	FolksIndividual* ind;
	FolksIndividual* _tmp2_;
	const gchar* _tmp3_;
	const gchar* _tmp4_;
	const gchar* _tmp5_;
	_data2_ = _data3_->_data2_;
	self = _data2_->self;
	g_return_if_fail (s != NULL);
	g_return_if_fail (p != NULL);
	_tmp0_ = s;
	_tmp1_ = _g_object_ref0 (FOLKS_INDIVIDUAL (_tmp0_));
	ind = _tmp1_;
	_tmp2_ = ind;
	_tmp3_ = folks_alias_details_get_alias ((FolksAliasDetails*) _tmp2_);
	_tmp4_ = _tmp3_;
	_tmp5_ = _data3_->new_alias;
	if (g_strcmp0 (_tmp4_, _tmp5_) == 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_;
	GeeSet* _tmp28_;
	gint _tmp29_;
	gint _tmp30_;
	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_;
	{
		GeeSet* _tmp1_;
		GeeIterator* _tmp2_ = NULL;
		GeeIterator* _i_it;
		_tmp1_ = added;
		_tmp2_ = gee_iterable_iterator ((GeeIterable*) _tmp1_);
		_i_it = _tmp2_;
		while (TRUE) {
			GeeIterator* _tmp3_;
			gboolean _tmp4_ = FALSE;
			GeeIterator* _tmp5_;
			gpointer _tmp6_ = NULL;
			FolksIndividual* i;
			FolksIndividual* _tmp7_;
			const gchar* _tmp8_;
			const gchar* _tmp9_;
			FolksIndividual* _tmp10_;
			const gchar* _tmp11_;
			const gchar* _tmp12_;
			const gchar* _tmp13_;
			FolksIndividual* _tmp14_;
			FolksPersona* persona;
			FolksPersona* _tmp25_;
			FolksPersona* _tmp26_;
			const gchar* _tmp27_;
			_tmp3_ = _i_it;
			_tmp4_ = gee_iterator_next (_tmp3_);
			if (!_tmp4_) {
				break;
			}
			_tmp5_ = _i_it;
			_tmp6_ = gee_iterator_get (_tmp5_);
			i = (FolksIndividual*) _tmp6_;
			_tmp7_ = i;
			_tmp8_ = folks_individual_get_id (_tmp7_);
			_tmp9_ = _tmp8_;
			if (g_strcmp0 (_tmp9_, "0e46c5e74f61908f49550d241f2a1651892a1695") != 0) {
				_g_object_unref0 (i);
				continue;
			}
			_tmp10_ = i;
			_tmp11_ = folks_alias_details_get_alias ((FolksAliasDetails*) _tmp10_);
			_tmp12_ = _tmp11_;
			_tmp13_ = _data3_->new_alias;
			g_assert (g_strcmp0 (_tmp12_, _tmp13_) != 0);
			_tmp14_ = i;
			g_signal_connect_data ((GObject*) _tmp14_, "notify::alias", (GCallback) __lambda3__g_object_notify, block3_data_ref (_data3_), (GClosureNotify) block3_data_unref, 0);
			persona = NULL;
			{
				FolksIndividual* _tmp15_;
				GeeSet* _tmp16_;
				GeeSet* _tmp17_;
				GeeIterator* _tmp18_ = NULL;
				GeeIterator* _p_it;
				_tmp15_ = i;
				_tmp16_ = folks_individual_get_personas (_tmp15_);
				_tmp17_ = _tmp16_;
				_tmp18_ = gee_iterable_iterator ((GeeIterable*) _tmp17_);
				_p_it = _tmp18_;
				while (TRUE) {
					GeeIterator* _tmp19_;
					gboolean _tmp20_ = FALSE;
					GeeIterator* _tmp21_;
					gpointer _tmp22_ = NULL;
					FolksPersona* p;
					FolksPersona* _tmp23_;
					FolksPersona* _tmp24_;
					_tmp19_ = _p_it;
					_tmp20_ = gee_iterator_next (_tmp19_);
					if (!_tmp20_) {
						break;
					}
					_tmp21_ = _p_it;
					_tmp22_ = gee_iterator_get (_tmp21_);
					p = (FolksPersona*) _tmp22_;
					_tmp23_ = p;
					_tmp24_ = _g_object_ref0 (_tmp23_);
					_g_object_unref0 (persona);
					persona = _tmp24_;
					_g_object_unref0 (p);
					break;
				}
				_g_object_unref0 (_p_it);
			}
			_tmp25_ = persona;
			g_assert (TPF_IS_PERSONA (_tmp25_));
			_tmp26_ = persona;
			_tmp27_ = _data3_->new_alias;
			folks_alias_details_set_alias ((FolksAliasDetails*) TPF_PERSONA (_tmp26_), _tmp27_);
			_g_object_unref0 (persona);
			_g_object_unref0 (i);
		}
		_g_object_unref0 (_i_it);
	}
	_tmp28_ = removed;
	_tmp29_ = gee_collection_get_size ((GeeCollection*) _tmp28_);
	_tmp30_ = _tmp29_;
	g_assert (_tmp30_ == 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;
	GMainLoop* _tmp0_;
	self = _data2_->self;
	_tmp0_ = _data2_->main_loop;
	g_main_loop_quit (_tmp0_);
	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_;
	FolksIndividualAggregator* _tmp1_;
	FolksIndividualAggregator* aggregator;
	FolksIndividualAggregator* _tmp2_;
	FolksIndividualAggregator* _tmp3_;
	gint _tmp4_;
	GMainLoop* _tmp5_;
	gboolean _tmp6_;
	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_;
	_tmp2_ = aggregator;
	g_signal_connect_data (_tmp2_, "individuals-changed", (GCallback) __lambda2__folks_individual_aggregator_individuals_changed, block2_data_ref (_data2_), (GClosureNotify) block2_data_unref, 0);
	_tmp3_ = aggregator;
	folks_individual_aggregator_prepare (_tmp3_, NULL, NULL);
	_tmp4_ = self->priv->_test_timeout;
	g_timeout_add_seconds_full (G_PRIORITY_DEFAULT, (guint) _tmp4_, __lambda4__gsource_func, block2_data_ref (_data2_), block2_data_unref);
	_tmp5_ = _data2_->main_loop;
	g_main_loop_run (_tmp5_);
	_tmp6_ = _data2_->alias_notified;
	g_assert (_tmp6_);
	_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;
	GObject* _tmp0_;
	FolksIndividual* _tmp1_;
	FolksIndividual* ind;
	FolksIndividual* _tmp2_;
	const gchar* _tmp3_;
	const gchar* _tmp4_;
	const gchar* _tmp5_;
	_data4_ = _data5_->_data4_;
	self = _data4_->self;
	g_return_if_fail (s != NULL);
	g_return_if_fail (p != NULL);
	_tmp0_ = s;
	_tmp1_ = _g_object_ref0 (FOLKS_INDIVIDUAL (_tmp0_));
	ind = _tmp1_;
	_tmp2_ = ind;
	_tmp3_ = folks_alias_details_get_alias ((FolksAliasDetails*) _tmp2_);
	_tmp4_ = _tmp3_;
	_tmp5_ = _data5_->new_alias;
	if (g_strcmp0 (_tmp4_, _tmp5_) == 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_;
	GeeSet* _tmp38_;
	gint _tmp39_;
	gint _tmp40_;
	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_;
	{
		GeeSet* _tmp1_;
		GeeIterator* _tmp2_ = NULL;
		GeeIterator* _i_it;
		_tmp1_ = added;
		_tmp2_ = gee_iterable_iterator ((GeeIterable*) _tmp1_);
		_i_it = _tmp2_;
		while (TRUE) {
			GeeIterator* _tmp3_;
			gboolean _tmp4_ = FALSE;
			GeeIterator* _tmp5_;
			gpointer _tmp6_ = NULL;
			FolksIndividual* i;
			FolksIndividual* _tmp7_;
			const gchar* _tmp8_;
			const gchar* _tmp9_;
			FolksIndividual* _tmp10_;
			const gchar* _tmp11_;
			const gchar* _tmp12_;
			const gchar* _tmp13_;
			FolksIndividual* _tmp14_;
			FolksPersona* persona;
			FolksPersona* _tmp25_;
			FolksPersona* _tmp26_;
			TpContact* _tmp27_;
			TpContact* _tmp28_;
			guint _tmp29_ = 0U;
			guint _tmp30_;
			TpHandle handle;
			TpTestBackend* _tmp31_;
			TpTestContactListConnection* _tmp32_;
			TpTestContactListConnection* _tmp33_;
			TpTestContactListManager* _tmp34_;
			TpTestContactListManager* _tmp35_;
			TpHandle _tmp36_;
			const gchar* _tmp37_;
			_tmp3_ = _i_it;
			_tmp4_ = gee_iterator_next (_tmp3_);
			if (!_tmp4_) {
				break;
			}
			_tmp5_ = _i_it;
			_tmp6_ = gee_iterator_get (_tmp5_);
			i = (FolksIndividual*) _tmp6_;
			_tmp7_ = i;
			_tmp8_ = folks_individual_get_id (_tmp7_);
			_tmp9_ = _tmp8_;
			if (g_strcmp0 (_tmp9_, "0e46c5e74f61908f49550d241f2a1651892a1695") != 0) {
				_g_object_unref0 (i);
				continue;
			}
			_tmp10_ = i;
			_tmp11_ = folks_alias_details_get_alias ((FolksAliasDetails*) _tmp10_);
			_tmp12_ = _tmp11_;
			_tmp13_ = _data5_->new_alias;
			g_assert (g_strcmp0 (_tmp12_, _tmp13_) != 0);
			_tmp14_ = i;
			g_signal_connect_data ((GObject*) _tmp14_, "notify::alias", (GCallback) __lambda6__g_object_notify, block5_data_ref (_data5_), (GClosureNotify) block5_data_unref, 0);
			persona = NULL;
			{
				FolksIndividual* _tmp15_;
				GeeSet* _tmp16_;
				GeeSet* _tmp17_;
				GeeIterator* _tmp18_ = NULL;
				GeeIterator* _p_it;
				_tmp15_ = i;
				_tmp16_ = folks_individual_get_personas (_tmp15_);
				_tmp17_ = _tmp16_;
				_tmp18_ = gee_iterable_iterator ((GeeIterable*) _tmp17_);
				_p_it = _tmp18_;
				while (TRUE) {
					GeeIterator* _tmp19_;
					gboolean _tmp20_ = FALSE;
					GeeIterator* _tmp21_;
					gpointer _tmp22_ = NULL;
					FolksPersona* p;
					FolksPersona* _tmp23_;
					FolksPersona* _tmp24_;
					_tmp19_ = _p_it;
					_tmp20_ = gee_iterator_next (_tmp19_);
					if (!_tmp20_) {
						break;
					}
					_tmp21_ = _p_it;
					_tmp22_ = gee_iterator_get (_tmp21_);
					p = (FolksPersona*) _tmp22_;
					_tmp23_ = p;
					_tmp24_ = _g_object_ref0 (_tmp23_);
					_g_object_unref0 (persona);
					persona = _tmp24_;
					_g_object_unref0 (p);
					break;
				}
				_g_object_unref0 (_p_it);
			}
			_tmp25_ = persona;
			g_assert (TPF_IS_PERSONA (_tmp25_));
			_tmp26_ = persona;
			_tmp27_ = tpf_persona_get_contact (TPF_PERSONA (_tmp26_));
			_tmp28_ = _tmp27_;
			g_object_get (_tmp28_, "handle", &_tmp29_, NULL);
			_tmp30_ = _tmp29_;
			handle = (TpHandle) _tmp30_;
			_tmp31_ = self->priv->tp_backend;
			_tmp32_ = tp_test_backend_get_connection (_tmp31_);
			_tmp33_ = _tmp32_;
			_tmp34_ = tp_test_contact_list_connection_get_manager (_tmp33_);
			_tmp35_ = _tmp34_;
			_tmp36_ = handle;
			_tmp37_ = _data5_->new_alias;
			tp_test_contact_list_manager_set_alias (_tmp35_, _tmp36_, _tmp37_);
			_g_object_unref0 (persona);
			_g_object_unref0 (i);
		}
		_g_object_unref0 (_i_it);
	}
	_tmp38_ = removed;
	_tmp39_ = gee_collection_get_size ((GeeCollection*) _tmp38_);
	_tmp40_ = _tmp39_;
	g_assert (_tmp40_ == 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;
	GMainLoop* _tmp0_;
	self = _data4_->self;
	_tmp0_ = _data4_->main_loop;
	g_main_loop_quit (_tmp0_);
	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_;
	FolksIndividualAggregator* _tmp1_;
	FolksIndividualAggregator* aggregator;
	FolksIndividualAggregator* _tmp2_;
	FolksIndividualAggregator* _tmp3_;
	gint _tmp4_;
	GMainLoop* _tmp5_;
	gboolean _tmp6_;
	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_;
	_tmp2_ = aggregator;
	g_signal_connect_data (_tmp2_, "individuals-changed", (GCallback) __lambda5__folks_individual_aggregator_individuals_changed, block4_data_ref (_data4_), (GClosureNotify) block4_data_unref, 0);
	_tmp3_ = aggregator;
	folks_individual_aggregator_prepare (_tmp3_, NULL, NULL);
	_tmp4_ = self->priv->_test_timeout;
	g_timeout_add_seconds_full (G_PRIORITY_DEFAULT, (guint) _tmp4_, __lambda7__gsource_func, block4_data_ref (_data4_), block4_data_unref);
	_tmp5_ = _data4_->main_loop;
	g_main_loop_run (_tmp5_);
	_tmp6_ = _data4_->alias_notified;
	g_assert (_tmp6_);
	_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) {
	self->priv = INDIVIDUAL_PROPERTIES_TESTS_GET_PRIVATE (self);
	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_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;
	GTestSuite* _tmp1_;
	IndividualPropertiesTests* _tmp2_;
	IndividualPropertiesTests* _tmp3_;
	GTestSuite* _tmp4_ = NULL;
	g_test_init (&args_length1, &args, NULL);
	_tmp0_ = g_test_get_root ();
	root = _tmp0_;
	_tmp1_ = root;
	_tmp2_ = individual_properties_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);
}



