/* init.c generated by valac 0.14.0.50-58097f, the Vala compiler
 * generated from init.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: Guillaume Desmottes <guillaume.desmottes@collabora.co.uk>
 */

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


#define TYPE_INIT_TESTS (init_tests_get_type ())
#define INIT_TESTS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_INIT_TESTS, InitTests))
#define INIT_TESTS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_INIT_TESTS, InitTestsClass))
#define IS_INIT_TESTS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_INIT_TESTS))
#define IS_INIT_TESTS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_INIT_TESTS))
#define INIT_TESTS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_INIT_TESTS, InitTestsClass))

typedef struct _InitTests InitTests;
typedef struct _InitTestsClass InitTestsClass;
typedef struct _InitTestsPrivate InitTestsPrivate;
#define _kf_test_backend_unref0(var) ((var == NULL) ? NULL : (var = (kf_test_backend_unref (var), NULL)))
#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)))

struct _InitTests {
	FolksTestCase parent_instance;
	InitTestsPrivate * priv;
};

struct _InitTestsClass {
	FolksTestCaseClass parent_class;
};

struct _InitTestsPrivate {
	KfTestBackend* _kf_backend;
	TpTestBackend* _tp_backend;
	gint _test_timeout;
};

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


static gpointer init_tests_parent_class = NULL;

GType init_tests_get_type (void) G_GNUC_CONST;
#define INIT_TESTS_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), TYPE_INIT_TESTS, InitTestsPrivate))
enum  {
	INIT_TESTS_DUMMY_PROPERTY
};
InitTests* init_tests_new (void);
InitTests* init_tests_construct (GType object_type);
void init_tests_test_looped (InitTests* self);
static void _init_tests_test_looped_folks_test_case_test_method (gpointer self);
static void init_tests_real_set_up (FolksTestCase* base);
static void init_tests_real_tear_down (FolksTestCase* base);
static Block1Data* block1_data_ref (Block1Data* _data1_);
static void block1_data_unref (Block1Data* _data1_);
static gboolean __lambda2_ (Block1Data* _data1_);
static gboolean ___lambda2__gsource_func (gpointer self);
static void init_tests_finalize (GObject* obj);
gint _vala_main (gchar** args, int args_length1);


static void _init_tests_test_looped_folks_test_case_test_method (gpointer self) {
#line 37 "/home/treitter/collabora/folks/tests/folks/init.vala"
	init_tests_test_looped (self);
#line 95 "init.c"
}


InitTests* init_tests_construct (GType object_type) {
	InitTests * self = NULL;
	KfTestBackend* _tmp0_;
	TpTestBackend* _tmp1_;
#line 31 "/home/treitter/collabora/folks/tests/folks/init.vala"
	self = (InitTests*) folks_test_case_construct (object_type, "Init");
#line 33 "/home/treitter/collabora/folks/tests/folks/init.vala"
	_tmp0_ = kf_test_backend_new ();
#line 33 "/home/treitter/collabora/folks/tests/folks/init.vala"
	_kf_test_backend_unref0 (self->priv->_kf_backend);
#line 33 "/home/treitter/collabora/folks/tests/folks/init.vala"
	self->priv->_kf_backend = _tmp0_;
#line 34 "/home/treitter/collabora/folks/tests/folks/init.vala"
	_tmp1_ = tp_test_backend_new ();
#line 34 "/home/treitter/collabora/folks/tests/folks/init.vala"
	_g_object_unref0 (self->priv->_tp_backend);
#line 34 "/home/treitter/collabora/folks/tests/folks/init.vala"
	self->priv->_tp_backend = _tmp1_;
#line 37 "/home/treitter/collabora/folks/tests/folks/init.vala"
	folks_test_case_add_test ((FolksTestCase*) self, "looped", _init_tests_test_looped_folks_test_case_test_method, self);
#line 29 "/home/treitter/collabora/folks/tests/folks/init.vala"
	return self;
#line 121 "init.c"
}


InitTests* init_tests_new (void) {
#line 29 "/home/treitter/collabora/folks/tests/folks/init.vala"
	return init_tests_construct (TYPE_INIT_TESTS);
#line 128 "init.c"
}


static void init_tests_real_set_up (FolksTestCase* base) {
	InitTests * self;
	TpTestBackend* _tmp0_;
#line 40 "/home/treitter/collabora/folks/tests/folks/init.vala"
	self = (InitTests*) base;
#line 42 "/home/treitter/collabora/folks/tests/folks/init.vala"
	_tmp0_ = self->priv->_tp_backend;
#line 42 "/home/treitter/collabora/folks/tests/folks/init.vala"
	tp_test_backend_set_up (_tmp0_);
#line 141 "init.c"
}


static void init_tests_real_tear_down (FolksTestCase* base) {
	InitTests * self;
	TpTestBackend* _tmp0_;
#line 45 "/home/treitter/collabora/folks/tests/folks/init.vala"
	self = (InitTests*) base;
#line 47 "/home/treitter/collabora/folks/tests/folks/init.vala"
	_tmp0_ = self->priv->_tp_backend;
#line 47 "/home/treitter/collabora/folks/tests/folks/init.vala"
	tp_test_backend_tear_down (_tmp0_);
#line 154 "init.c"
}


static Block1Data* block1_data_ref (Block1Data* _data1_) {
#line 54 "/home/treitter/collabora/folks/tests/folks/init.vala"
	g_atomic_int_inc (&_data1_->_ref_count_);
#line 54 "/home/treitter/collabora/folks/tests/folks/init.vala"
	return _data1_;
#line 163 "init.c"
}


static void block1_data_unref (Block1Data* _data1_) {
#line 54 "/home/treitter/collabora/folks/tests/folks/init.vala"
	if (g_atomic_int_dec_and_test (&_data1_->_ref_count_)) {
#line 54 "/home/treitter/collabora/folks/tests/folks/init.vala"
		_g_object_unref0 (_data1_->self);
#line 54 "/home/treitter/collabora/folks/tests/folks/init.vala"
		_g_main_loop_unref0 (_data1_->main_loop);
#line 54 "/home/treitter/collabora/folks/tests/folks/init.vala"
		g_slice_free (Block1Data, _data1_);
#line 176 "init.c"
	}
}


static gboolean __lambda2_ (Block1Data* _data1_) {
	InitTests * self;
	gboolean result = FALSE;
	GMainLoop* _tmp0_;
#line 74 "/home/treitter/collabora/folks/tests/folks/init.vala"
	self = _data1_->self;
#line 76 "/home/treitter/collabora/folks/tests/folks/init.vala"
	_tmp0_ = _data1_->main_loop;
#line 76 "/home/treitter/collabora/folks/tests/folks/init.vala"
	g_main_loop_quit (_tmp0_);
#line 77 "/home/treitter/collabora/folks/tests/folks/init.vala"
	result = FALSE;
#line 77 "/home/treitter/collabora/folks/tests/folks/init.vala"
	return result;
#line 195 "init.c"
}


static gboolean ___lambda2__gsource_func (gpointer self) {
	gboolean result;
	result = __lambda2_ (self);
#line 74 "/home/treitter/collabora/folks/tests/folks/init.vala"
	return result;
#line 204 "init.c"
}


void init_tests_test_looped (InitTests* self) {
	Block1Data* _data1_;
	GMainLoop* _tmp0_;
	KfTestBackend* _tmp1_;
	TpTestBackend* _tmp2_;
	void* _tmp3_ = NULL;
	void* account1_handle;
	TpTestBackend* _tmp4_;
	void* _tmp5_ = NULL;
	void* account2_handle;
	gint _tmp12_;
	GMainLoop* _tmp13_;
	TpTestBackend* _tmp14_;
	void* _tmp15_;
	TpTestBackend* _tmp16_;
	void* _tmp17_;
	KfTestBackend* _tmp18_;
#line 54 "/home/treitter/collabora/folks/tests/folks/init.vala"
	g_return_if_fail (self != NULL);
#line 54 "/home/treitter/collabora/folks/tests/folks/init.vala"
	_data1_ = g_slice_new0 (Block1Data);
#line 54 "/home/treitter/collabora/folks/tests/folks/init.vala"
	_data1_->_ref_count_ = 1;
#line 54 "/home/treitter/collabora/folks/tests/folks/init.vala"
	_data1_->self = g_object_ref (self);
#line 56 "/home/treitter/collabora/folks/tests/folks/init.vala"
	_tmp0_ = g_main_loop_new (NULL, FALSE);
#line 56 "/home/treitter/collabora/folks/tests/folks/init.vala"
	_data1_->main_loop = _tmp0_;
#line 58 "/home/treitter/collabora/folks/tests/folks/init.vala"
	_tmp1_ = self->priv->_kf_backend;
#line 58 "/home/treitter/collabora/folks/tests/folks/init.vala"
	kf_test_backend_set_up (_tmp1_, "");
#line 60 "/home/treitter/collabora/folks/tests/folks/init.vala"
	_tmp2_ = self->priv->_tp_backend;
#line 60 "/home/treitter/collabora/folks/tests/folks/init.vala"
	_tmp3_ = tp_test_backend_add_account (_tmp2_, "protocol", "me@example.com", "cm", "account");
#line 60 "/home/treitter/collabora/folks/tests/folks/init.vala"
	account1_handle = _tmp3_;
#line 62 "/home/treitter/collabora/folks/tests/folks/init.vala"
	_tmp4_ = self->priv->_tp_backend;
#line 62 "/home/treitter/collabora/folks/tests/folks/init.vala"
	_tmp5_ = tp_test_backend_add_account (_tmp4_, "protocol", "me2@example.com", "cm", "account2");
#line 62 "/home/treitter/collabora/folks/tests/folks/init.vala"
	account2_handle = _tmp5_;
#line 253 "init.c"
	{
		guint i;
#line 66 "/home/treitter/collabora/folks/tests/folks/init.vala"
		i = (guint) 0;
#line 258 "init.c"
		{
			gboolean _tmp6_;
#line 66 "/home/treitter/collabora/folks/tests/folks/init.vala"
			_tmp6_ = TRUE;
#line 66 "/home/treitter/collabora/folks/tests/folks/init.vala"
			while (TRUE) {
#line 265 "init.c"
				gboolean _tmp7_;
				guint _tmp9_;
				FolksIndividualAggregator* _tmp10_;
				FolksIndividualAggregator* aggregator;
				FolksIndividualAggregator* _tmp11_;
#line 66 "/home/treitter/collabora/folks/tests/folks/init.vala"
				_tmp7_ = _tmp6_;
#line 66 "/home/treitter/collabora/folks/tests/folks/init.vala"
				if (!_tmp7_) {
#line 275 "init.c"
					guint _tmp8_;
#line 66 "/home/treitter/collabora/folks/tests/folks/init.vala"
					_tmp8_ = i;
#line 66 "/home/treitter/collabora/folks/tests/folks/init.vala"
					i = _tmp8_ + 1;
#line 281 "init.c"
				}
#line 66 "/home/treitter/collabora/folks/tests/folks/init.vala"
				_tmp6_ = FALSE;
#line 66 "/home/treitter/collabora/folks/tests/folks/init.vala"
				_tmp9_ = i;
#line 66 "/home/treitter/collabora/folks/tests/folks/init.vala"
				if (!(_tmp9_ < ((guint) 10))) {
#line 66 "/home/treitter/collabora/folks/tests/folks/init.vala"
					break;
#line 291 "init.c"
				}
#line 68 "/home/treitter/collabora/folks/tests/folks/init.vala"
				_tmp10_ = folks_individual_aggregator_new ();
#line 68 "/home/treitter/collabora/folks/tests/folks/init.vala"
				aggregator = _tmp10_;
#line 69 "/home/treitter/collabora/folks/tests/folks/init.vala"
				_tmp11_ = aggregator;
#line 69 "/home/treitter/collabora/folks/tests/folks/init.vala"
				folks_individual_aggregator_prepare (_tmp11_, NULL, NULL);
#line 70 "/home/treitter/collabora/folks/tests/folks/init.vala"
				_g_object_unref0 (aggregator);
#line 70 "/home/treitter/collabora/folks/tests/folks/init.vala"
				aggregator = NULL;
#line 66 "/home/treitter/collabora/folks/tests/folks/init.vala"
				_g_object_unref0 (aggregator);
#line 307 "init.c"
			}
		}
	}
#line 74 "/home/treitter/collabora/folks/tests/folks/init.vala"
	_tmp12_ = self->priv->_test_timeout;
#line 74 "/home/treitter/collabora/folks/tests/folks/init.vala"
	g_timeout_add_seconds_full (G_PRIORITY_DEFAULT, (guint) _tmp12_, ___lambda2__gsource_func, block1_data_ref (_data1_), block1_data_unref);
#line 80 "/home/treitter/collabora/folks/tests/folks/init.vala"
	_tmp13_ = _data1_->main_loop;
#line 80 "/home/treitter/collabora/folks/tests/folks/init.vala"
	g_main_loop_run (_tmp13_);
#line 83 "/home/treitter/collabora/folks/tests/folks/init.vala"
	_tmp14_ = self->priv->_tp_backend;
#line 83 "/home/treitter/collabora/folks/tests/folks/init.vala"
	_tmp15_ = account2_handle;
#line 83 "/home/treitter/collabora/folks/tests/folks/init.vala"
	tp_test_backend_remove_account (_tmp14_, _tmp15_);
#line 84 "/home/treitter/collabora/folks/tests/folks/init.vala"
	_tmp16_ = self->priv->_tp_backend;
#line 84 "/home/treitter/collabora/folks/tests/folks/init.vala"
	_tmp17_ = account1_handle;
#line 84 "/home/treitter/collabora/folks/tests/folks/init.vala"
	tp_test_backend_remove_account (_tmp16_, _tmp17_);
#line 85 "/home/treitter/collabora/folks/tests/folks/init.vala"
	_tmp18_ = self->priv->_kf_backend;
#line 85 "/home/treitter/collabora/folks/tests/folks/init.vala"
	kf_test_backend_tear_down (_tmp18_);
#line 54 "/home/treitter/collabora/folks/tests/folks/init.vala"
	block1_data_unref (_data1_);
#line 54 "/home/treitter/collabora/folks/tests/folks/init.vala"
	_data1_ = NULL;
#line 339 "init.c"
}


static void init_tests_class_init (InitTestsClass * klass) {
#line 23 "/home/treitter/collabora/folks/tests/folks/init.vala"
	init_tests_parent_class = g_type_class_peek_parent (klass);
#line 23 "/home/treitter/collabora/folks/tests/folks/init.vala"
	g_type_class_add_private (klass, sizeof (InitTestsPrivate));
#line 23 "/home/treitter/collabora/folks/tests/folks/init.vala"
	FOLKS_TEST_CASE_CLASS (klass)->set_up = init_tests_real_set_up;
#line 23 "/home/treitter/collabora/folks/tests/folks/init.vala"
	FOLKS_TEST_CASE_CLASS (klass)->tear_down = init_tests_real_tear_down;
#line 23 "/home/treitter/collabora/folks/tests/folks/init.vala"
	G_OBJECT_CLASS (klass)->finalize = init_tests_finalize;
#line 354 "init.c"
}


static void init_tests_instance_init (InitTests * self) {
#line 23 "/home/treitter/collabora/folks/tests/folks/init.vala"
	self->priv = INIT_TESTS_GET_PRIVATE (self);
#line 27 "/home/treitter/collabora/folks/tests/folks/init.vala"
	self->priv->_test_timeout = 5;
#line 363 "init.c"
}


static void init_tests_finalize (GObject* obj) {
	InitTests * self;
#line 23 "/home/treitter/collabora/folks/tests/folks/init.vala"
	self = INIT_TESTS (obj);
#line 25 "/home/treitter/collabora/folks/tests/folks/init.vala"
	_kf_test_backend_unref0 (self->priv->_kf_backend);
#line 26 "/home/treitter/collabora/folks/tests/folks/init.vala"
	_g_object_unref0 (self->priv->_tp_backend);
#line 23 "/home/treitter/collabora/folks/tests/folks/init.vala"
	G_OBJECT_CLASS (init_tests_parent_class)->finalize (obj);
#line 377 "init.c"
}


GType init_tests_get_type (void) {
	static volatile gsize init_tests_type_id__volatile = 0;
	if (g_once_init_enter (&init_tests_type_id__volatile)) {
		static const GTypeInfo g_define_type_info = { sizeof (InitTestsClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) init_tests_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (InitTests), 0, (GInstanceInitFunc) init_tests_instance_init, NULL };
		GType init_tests_type_id;
		init_tests_type_id = g_type_register_static (FOLKS_TYPE_TEST_CASE, "InitTests", &g_define_type_info, 0);
		g_once_init_leave (&init_tests_type_id__volatile, init_tests_type_id);
	}
	return init_tests_type_id__volatile;
}


gint _vala_main (gchar** args, int args_length1) {
	gint result = 0;
	GTestSuite* _tmp0_ = NULL;
	GTestSuite* root;
	InitTests* _tmp1_;
	InitTests* _tmp2_;
	GTestSuite* _tmp3_ = NULL;
#line 91 "/home/treitter/collabora/folks/tests/folks/init.vala"
	g_test_init (&args_length1, &args, NULL);
#line 93 "/home/treitter/collabora/folks/tests/folks/init.vala"
	_tmp0_ = g_test_get_root ();
#line 93 "/home/treitter/collabora/folks/tests/folks/init.vala"
	root = _tmp0_;
#line 94 "/home/treitter/collabora/folks/tests/folks/init.vala"
	_tmp1_ = init_tests_new ();
#line 94 "/home/treitter/collabora/folks/tests/folks/init.vala"
	_tmp2_ = _tmp1_;
#line 94 "/home/treitter/collabora/folks/tests/folks/init.vala"
	_tmp3_ = folks_test_case_get_suite ((FolksTestCase*) _tmp2_);
#line 94 "/home/treitter/collabora/folks/tests/folks/init.vala"
	g_test_suite_add_suite (root, _tmp3_);
#line 94 "/home/treitter/collabora/folks/tests/folks/init.vala"
	_g_object_unref0 (_tmp2_);
#line 96 "/home/treitter/collabora/folks/tests/folks/init.vala"
	g_test_run ();
#line 98 "/home/treitter/collabora/folks/tests/folks/init.vala"
	result = 0;
#line 98 "/home/treitter/collabora/folks/tests/folks/init.vala"
	return result;
#line 422 "init.c"
}


int main (int argc, char ** argv) {
#line 89 "/home/treitter/collabora/folks/tests/folks/init.vala"
	g_type_init ();
#line 89 "/home/treitter/collabora/folks/tests/folks/init.vala"
	return _vala_main (argv, argc);
#line 431 "init.c"
}



