/* change-primary-store.c generated by valac 0.14.0.15-f8b5, the Vala compiler
 * generated from change-primary-store.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 <gio/gio.h>
#include <stdlib.h>
#include <string.h>
#include <gee.h>


#define TYPE_CHANGE_PRIMARY_STORE_TESTS (change_primary_store_tests_get_type ())
#define CHANGE_PRIMARY_STORE_TESTS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_CHANGE_PRIMARY_STORE_TESTS, ChangePrimaryStoreTests))
#define CHANGE_PRIMARY_STORE_TESTS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_CHANGE_PRIMARY_STORE_TESTS, ChangePrimaryStoreTestsClass))
#define IS_CHANGE_PRIMARY_STORE_TESTS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_CHANGE_PRIMARY_STORE_TESTS))
#define IS_CHANGE_PRIMARY_STORE_TESTS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_CHANGE_PRIMARY_STORE_TESTS))
#define CHANGE_PRIMARY_STORE_TESTS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_CHANGE_PRIMARY_STORE_TESTS, ChangePrimaryStoreTestsClass))

typedef struct _ChangePrimaryStoreTests ChangePrimaryStoreTests;
typedef struct _ChangePrimaryStoreTestsClass ChangePrimaryStoreTestsClass;
typedef struct _ChangePrimaryStoreTestsPrivate ChangePrimaryStoreTestsPrivate;
#define _g_main_loop_unref0(var) ((var == NULL) ? NULL : (var = (g_main_loop_unref (var), NULL)))
#define _eds_test_backend_unref0(var) ((var == NULL) ? NULL : (var = (eds_test_backend_unref (var), NULL)))
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
typedef struct _ChangePrimaryStoreTestsTestChangePrimaryStoreData ChangePrimaryStoreTestsTestChangePrimaryStoreData;

struct _ChangePrimaryStoreTests {
	FolksTestCase parent_instance;
	ChangePrimaryStoreTestsPrivate * priv;
};

struct _ChangePrimaryStoreTestsClass {
	FolksTestCaseClass parent_class;
};

struct _ChangePrimaryStoreTestsPrivate {
	GMainLoop* _main_loop;
	EdsTestBackend* _eds_backend;
	EdsTestBackend* _eds_backend_other;
	FolksIndividualAggregator* _aggregator;
	FolksPersonaStore* _pstore1;
	FolksPersonaStore* _pstore2;
	gboolean _new_primary_store_found;
};

struct _ChangePrimaryStoreTestsTestChangePrimaryStoreData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GSimpleAsyncResult* _async_result;
	ChangePrimaryStoreTests* self;
	FolksBackendStore* _tmp0_;
	FolksBackendStore* store;
	FolksIndividualAggregator* _tmp1_;
	FolksIndividualAggregator* _tmp2_;
	EdsTestBackend* _tmp3_;
	const gchar* _tmp4_;
	const gchar* _tmp5_;
	FolksPersonaStore* _tmp6_;
	EdsTestBackend* _tmp7_;
	const gchar* _tmp8_;
	const gchar* _tmp9_;
	FolksPersonaStore* _tmp10_;
	FolksPersonaStore* _tmp11_;
	FolksPersonaStore* _tmp12_;
	FolksIndividualAggregator* _tmp13_;
	FolksPersonaStore* _tmp14_;
	FolksPersonaStore* _tmp15_;
	FolksPersonaStore* _tmp16_;
	FolksIndividualAggregator* _tmp17_;
	EdsTestBackend* _tmp18_;
	GError* e;
	GError* _tmp19_;
	const gchar* _tmp20_;
	GError * _inner_error_;
};


static gpointer change_primary_store_tests_parent_class = NULL;

GType change_primary_store_tests_get_type (void) G_GNUC_CONST;
#define CHANGE_PRIMARY_STORE_TESTS_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), TYPE_CHANGE_PRIMARY_STORE_TESTS, ChangePrimaryStoreTestsPrivate))
enum  {
	CHANGE_PRIMARY_STORE_TESTS_DUMMY_PROPERTY
};
ChangePrimaryStoreTests* change_primary_store_tests_new (void);
ChangePrimaryStoreTests* change_primary_store_tests_construct (GType object_type);
void change_primary_store_tests_test_change_primary_store (ChangePrimaryStoreTests* self);
static void _change_primary_store_tests_test_change_primary_store_folks_test_case_test_method (gpointer self);
static void change_primary_store_tests_real_set_up (FolksTestCase* base);
static void change_primary_store_tests_real_tear_down (FolksTestCase* base);
static void _change_primary_store_tests_test_change_primary_store (ChangePrimaryStoreTests* self, GAsyncReadyCallback _callback_, gpointer _user_data_);
static void _change_primary_store_tests_test_change_primary_store_finish (ChangePrimaryStoreTests* self, GAsyncResult* _res_);
static gboolean __lambda2_ (ChangePrimaryStoreTests* self);
static gboolean ___lambda2__gsource_func (gpointer self);
static void _change_primary_store_tests_test_change_primary_store_data_free (gpointer _data);
static gboolean _change_primary_store_tests_test_change_primary_store_co (ChangePrimaryStoreTestsTestChangePrimaryStoreData* _data_);
static void _change_primary_store_tests_test_change_primary_store_ready (GObject* source_object, GAsyncResult* _res_, gpointer _user_data_);
static FolksPersonaStore* _change_primary_store_tests_get_persona_store (ChangePrimaryStoreTests* self, FolksBackendStore* store, const gchar* store_id);
static void _change_primary_store_tests_primary_store_cb (ChangePrimaryStoreTests* self, GObject* ia_obj, GParamSpec* ps);
static void __change_primary_store_tests_primary_store_cb_g_object_notify (GObject* _sender, GParamSpec* pspec, gpointer self);
static void change_primary_store_tests_finalize (GObject* obj);
gint _vala_main (gchar** args, int args_length1);


static void _change_primary_store_tests_test_change_primary_store_folks_test_case_test_method (gpointer self) {
#line 43 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
	change_primary_store_tests_test_change_primary_store (self);
#line 134 "change-primary-store.c"
}


ChangePrimaryStoreTests* change_primary_store_tests_construct (GType object_type) {
	ChangePrimaryStoreTests * self = NULL;
	EdsTestBackend* _tmp0_;
	EdsTestBackend* _tmp1_;
	EdsTestBackend* _tmp2_;
	EdsTestBackend* _tmp3_;
#line 36 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
	self = (ChangePrimaryStoreTests*) folks_test_case_construct (object_type, "ChangePrimaryStoreTests");
#line 38 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
	_tmp0_ = eds_test_backend_new ();
#line 38 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
	_eds_test_backend_unref0 (self->priv->_eds_backend);
#line 38 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
	self->priv->_eds_backend = _tmp0_;
#line 39 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
	_tmp1_ = self->priv->_eds_backend;
#line 39 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
	eds_test_backend_set_address_book_uri (_tmp1_, "system");
#line 40 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
	_tmp2_ = eds_test_backend_new ();
#line 40 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
	_eds_test_backend_unref0 (self->priv->_eds_backend_other);
#line 40 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
	self->priv->_eds_backend_other = _tmp2_;
#line 41 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
	_tmp3_ = self->priv->_eds_backend_other;
#line 41 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
	eds_test_backend_set_address_book_uri (_tmp3_, "other");
#line 43 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
	folks_test_case_add_test ((FolksTestCase*) self, "test primary store changes in the IndividualAggregator", _change_primary_store_tests_test_change_primary_store_folks_test_case_test_method, self);
#line 34 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
	return self;
#line 170 "change-primary-store.c"
}


ChangePrimaryStoreTests* change_primary_store_tests_new (void) {
#line 34 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
	return change_primary_store_tests_construct (TYPE_CHANGE_PRIMARY_STORE_TESTS);
#line 177 "change-primary-store.c"
}


static void change_primary_store_tests_real_set_up (FolksTestCase* base) {
	ChangePrimaryStoreTests * self;
	EdsTestBackend* _tmp0_;
	EdsTestBackend* _tmp1_;
#line 47 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
	self = (ChangePrimaryStoreTests*) base;
#line 49 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
	g_unsetenv ("FOLKS_PRIMARY_STORE");
#line 50 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
	_tmp0_ = self->priv->_eds_backend;
#line 50 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
	eds_test_backend_set_up (_tmp0_, TRUE);
#line 51 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
	_tmp1_ = self->priv->_eds_backend_other;
#line 51 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
	eds_test_backend_set_up (_tmp1_, FALSE);
#line 197 "change-primary-store.c"
}


static void change_primary_store_tests_real_tear_down (FolksTestCase* base) {
	ChangePrimaryStoreTests * self;
	EdsTestBackend* _tmp0_;
	EdsTestBackend* _tmp1_;
#line 54 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
	self = (ChangePrimaryStoreTests*) base;
#line 56 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
	_tmp0_ = self->priv->_eds_backend;
#line 56 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
	eds_test_backend_tear_down (_tmp0_);
#line 57 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
	_tmp1_ = self->priv->_eds_backend_other;
#line 57 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
	eds_test_backend_tear_down (_tmp1_);
#line 215 "change-primary-store.c"
}


static gboolean __lambda2_ (ChangePrimaryStoreTests* self) {
	gboolean result = FALSE;
	GMainLoop* _tmp0_;
#line 69 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
	_tmp0_ = self->priv->_main_loop;
#line 69 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
	g_main_loop_quit (_tmp0_);
#line 70 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
	g_assert_not_reached ();
#line 67 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
	return result;
#line 230 "change-primary-store.c"
}


static gboolean ___lambda2__gsource_func (gpointer self) {
	gboolean result;
	result = __lambda2_ (self);
#line 67 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
	return result;
#line 239 "change-primary-store.c"
}


void change_primary_store_tests_test_change_primary_store (ChangePrimaryStoreTests* self) {
	GMainLoop* _tmp0_;
	guint _tmp1_ = 0U;
	guint timer_id;
	GMainLoop* _tmp2_;
	gboolean _tmp3_;
#line 60 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
	g_return_if_fail (self != NULL);
#line 62 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
	_tmp0_ = g_main_loop_new (NULL, FALSE);
#line 62 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
	_g_main_loop_unref0 (self->priv->_main_loop);
#line 62 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
	self->priv->_main_loop = _tmp0_;
#line 63 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
	self->priv->_new_primary_store_found = FALSE;
#line 65 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
	_change_primary_store_tests_test_change_primary_store (self, NULL, NULL);
#line 67 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
	_tmp1_ = g_timeout_add_seconds_full (G_PRIORITY_DEFAULT, (guint) 8, ___lambda2__gsource_func, g_object_ref (self), g_object_unref);
#line 67 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
	timer_id = _tmp1_;
#line 73 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
	_tmp2_ = self->priv->_main_loop;
#line 73 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
	g_main_loop_run (_tmp2_);
#line 75 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
	_tmp3_ = self->priv->_new_primary_store_found;
#line 75 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
	g_assert (_tmp3_);
#line 77 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
	g_source_remove (timer_id);
#line 78 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
	_g_object_unref0 (self->priv->_aggregator);
#line 78 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
	self->priv->_aggregator = NULL;
#line 79 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
	_g_main_loop_unref0 (self->priv->_main_loop);
#line 79 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
	self->priv->_main_loop = NULL;
#line 283 "change-primary-store.c"
}


static void _change_primary_store_tests_test_change_primary_store_data_free (gpointer _data) {
	ChangePrimaryStoreTestsTestChangePrimaryStoreData* _data_;
	_data_ = _data;
#line 24 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
	_g_object_unref0 (_data_->self);
#line 24 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
	g_slice_free (ChangePrimaryStoreTestsTestChangePrimaryStoreData, _data_);
#line 294 "change-primary-store.c"
}


static gpointer _g_object_ref0 (gpointer self) {
#line 24 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
	return self ? g_object_ref (self) : NULL;
#line 301 "change-primary-store.c"
}


static void _change_primary_store_tests_test_change_primary_store (ChangePrimaryStoreTests* self, GAsyncReadyCallback _callback_, gpointer _user_data_) {
	ChangePrimaryStoreTestsTestChangePrimaryStoreData* _data_;
	ChangePrimaryStoreTests* _tmp0_;
#line 24 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
	_data_ = g_slice_new0 (ChangePrimaryStoreTestsTestChangePrimaryStoreData);
#line 24 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
	_data_->_async_result = g_simple_async_result_new (G_OBJECT (self), _callback_, _user_data_, _change_primary_store_tests_test_change_primary_store);
#line 24 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
	g_simple_async_result_set_op_res_gpointer (_data_->_async_result, _data_, _change_primary_store_tests_test_change_primary_store_data_free);
#line 24 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
	_tmp0_ = _g_object_ref0 (self);
#line 24 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
	_data_->self = _tmp0_;
#line 24 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
	_change_primary_store_tests_test_change_primary_store_co (_data_);
#line 320 "change-primary-store.c"
}


static void _change_primary_store_tests_test_change_primary_store_finish (ChangePrimaryStoreTests* self, GAsyncResult* _res_) {
	ChangePrimaryStoreTestsTestChangePrimaryStoreData* _data_;
#line 24 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
	_data_ = g_simple_async_result_get_op_res_gpointer (G_SIMPLE_ASYNC_RESULT (_res_));
#line 328 "change-primary-store.c"
}


static void _change_primary_store_tests_test_change_primary_store_ready (GObject* source_object, GAsyncResult* _res_, gpointer _user_data_) {
	ChangePrimaryStoreTestsTestChangePrimaryStoreData* _data_;
#line 85 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
	_data_ = _user_data_;
#line 85 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
	_data_->_source_object_ = source_object;
#line 85 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
	_data_->_res_ = _res_;
#line 85 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
	_change_primary_store_tests_test_change_primary_store_co (_data_);
#line 342 "change-primary-store.c"
}


static void __change_primary_store_tests_primary_store_cb_g_object_notify (GObject* _sender, GParamSpec* pspec, gpointer self) {
#line 101 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
	_change_primary_store_tests_primary_store_cb (self, _sender, pspec);
#line 349 "change-primary-store.c"
}


static gboolean _change_primary_store_tests_test_change_primary_store_co (ChangePrimaryStoreTestsTestChangePrimaryStoreData* _data_) {
#line 82 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
	switch (_data_->_state_) {
#line 82 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
		case 0:
#line 358 "change-primary-store.c"
		goto _state_0;
#line 82 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
		case 1:
#line 362 "change-primary-store.c"
		goto _state_1;
#line 82 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
		case 2:
#line 366 "change-primary-store.c"
		goto _state_2;
		default:
#line 82 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
		g_assert_not_reached ();
#line 371 "change-primary-store.c"
	}
	_state_0:
#line 84 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
	_data_->_tmp0_ = NULL;
#line 84 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
	_data_->_tmp0_ = folks_backend_store_dup ();
#line 84 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
	_data_->store = _data_->_tmp0_;
#line 85 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
	_data_->_state_ = 1;
#line 85 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
	folks_backend_store_prepare (_data_->store, _change_primary_store_tests_test_change_primary_store_ready, _data_);
#line 85 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
	return FALSE;
#line 386 "change-primary-store.c"
	_state_1:
#line 85 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
	folks_backend_store_prepare_finish (_data_->store, _data_->_res_);
#line 86 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
	_data_->_tmp1_ = folks_individual_aggregator_new ();
#line 86 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
	_g_object_unref0 (_data_->self->priv->_aggregator);
#line 86 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
	_data_->self->priv->_aggregator = _data_->_tmp1_;
#line 396 "change-primary-store.c"
	{
#line 89 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
		_data_->_tmp2_ = _data_->self->priv->_aggregator;
#line 89 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
		_data_->_state_ = 2;
#line 89 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
		folks_individual_aggregator_prepare (_data_->_tmp2_, _change_primary_store_tests_test_change_primary_store_ready, _data_);
#line 89 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
		return FALSE;
#line 406 "change-primary-store.c"
		_state_2:
#line 89 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
		folks_individual_aggregator_prepare_finish (_data_->_tmp2_, _data_->_res_, &_data_->_inner_error_);
#line 89 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
		if (_data_->_inner_error_ != NULL) {
#line 412 "change-primary-store.c"
			goto __catch0_g_error;
		}
#line 91 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
		_data_->_tmp3_ = _data_->self->priv->_eds_backend;
#line 91 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
		_data_->_tmp4_ = eds_test_backend_get_address_book_uid (_data_->_tmp3_);
#line 91 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
		_data_->_tmp5_ = _data_->_tmp4_;
#line 91 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
		_data_->_tmp6_ = NULL;
#line 91 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
		_data_->_tmp6_ = _change_primary_store_tests_get_persona_store (_data_->self, _data_->store, _data_->_tmp5_);
#line 91 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
		_g_object_unref0 (_data_->self->priv->_pstore1);
#line 91 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
		_data_->self->priv->_pstore1 = _data_->_tmp6_;
#line 93 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
		_data_->_tmp7_ = _data_->self->priv->_eds_backend_other;
#line 93 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
		_data_->_tmp8_ = eds_test_backend_get_address_book_uid (_data_->_tmp7_);
#line 93 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
		_data_->_tmp9_ = _data_->_tmp8_;
#line 93 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
		_data_->_tmp10_ = NULL;
#line 93 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
		_data_->_tmp10_ = _change_primary_store_tests_get_persona_store (_data_->self, _data_->store, _data_->_tmp9_);
#line 93 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
		_g_object_unref0 (_data_->self->priv->_pstore2);
#line 93 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
		_data_->self->priv->_pstore2 = _data_->_tmp10_;
#line 96 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
		_data_->_tmp11_ = _data_->self->priv->_pstore1;
#line 96 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
		g_assert (_data_->_tmp11_ != NULL);
#line 97 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
		_data_->_tmp12_ = _data_->self->priv->_pstore2;
#line 97 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
		g_assert (_data_->_tmp12_ != NULL);
#line 99 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
		_data_->_tmp13_ = _data_->self->priv->_aggregator;
#line 99 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
		_data_->_tmp14_ = folks_individual_aggregator_get_primary_store (_data_->_tmp13_);
#line 99 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
		_data_->_tmp15_ = _data_->_tmp14_;
#line 99 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
		_data_->_tmp16_ = _data_->self->priv->_pstore1;
#line 99 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
		g_assert (_data_->_tmp15_ == _data_->_tmp16_);
#line 101 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
		_data_->_tmp17_ = _data_->self->priv->_aggregator;
#line 101 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
		g_signal_connect_object ((GObject*) _data_->_tmp17_, "notify::primary-store", (GCallback) __change_primary_store_tests_primary_store_cb_g_object_notify, _data_->self, 0);
#line 104 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
		_data_->_tmp18_ = _data_->self->priv->_eds_backend_other;
#line 104 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
		eds_test_backend_set_as_default (_data_->_tmp18_);
#line 469 "change-primary-store.c"
	}
	goto __finally0;
	__catch0_g_error:
	{
#line 87 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
		_data_->e = _data_->_inner_error_;
#line 87 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
		_data_->_inner_error_ = NULL;
#line 108 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
		_data_->_tmp19_ = _data_->e;
#line 108 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
		_data_->_tmp20_ = _data_->_tmp19_->message;
#line 108 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
		g_warning ("change-primary-store.vala:108: Error when calling prepare: %s\n", _data_->_tmp20_);
#line 87 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
		_g_error_free0 (_data_->e);
#line 486 "change-primary-store.c"
	}
	__finally0:
#line 87 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
	if (_data_->_inner_error_ != NULL) {
#line 87 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
		_g_object_unref0 (_data_->store);
#line 87 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
		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);
#line 87 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
		g_clear_error (&_data_->_inner_error_);
#line 87 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
		return FALSE;
#line 499 "change-primary-store.c"
	}
#line 82 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
	_g_object_unref0 (_data_->store);
#line 82 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
	if (_data_->_state_ == 0) {
#line 82 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
		g_simple_async_result_complete_in_idle (_data_->_async_result);
#line 507 "change-primary-store.c"
	} else {
#line 82 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
		g_simple_async_result_complete (_data_->_async_result);
#line 511 "change-primary-store.c"
	}
#line 82 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
	g_object_unref (_data_->_async_result);
#line 82 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
	return FALSE;
#line 517 "change-primary-store.c"
}


static FolksPersonaStore* _change_primary_store_tests_get_persona_store (ChangePrimaryStoreTests* self, FolksBackendStore* store, const gchar* store_id) {
	FolksPersonaStore* result = NULL;
	FolksPersonaStore* pstore;
#line 112 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
	g_return_val_if_fail (self != NULL, NULL);
#line 112 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
	g_return_val_if_fail (store != NULL, NULL);
#line 112 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
	g_return_val_if_fail (store_id != NULL, NULL);
#line 114 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
	pstore = NULL;
#line 532 "change-primary-store.c"
	{
		FolksBackendStore* _tmp0_;
		GeeMap* _tmp1_;
		GeeMap* _tmp2_;
		GeeCollection* _tmp3_;
		GeeCollection* _tmp4_;
		GeeCollection* _tmp5_;
		GeeIterator* _tmp6_ = NULL;
		GeeIterator* _tmp7_;
		GeeIterator* _backend_it;
#line 115 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
		_tmp0_ = store;
#line 115 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
		_tmp1_ = folks_backend_store_get_enabled_backends (_tmp0_);
#line 115 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
		_tmp2_ = _tmp1_;
#line 115 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
		_tmp3_ = gee_map_get_values (_tmp2_);
#line 115 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
		_tmp4_ = _tmp3_;
#line 115 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
		_tmp5_ = _tmp4_;
#line 115 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
		_tmp6_ = gee_iterable_iterator ((GeeIterable*) _tmp5_);
#line 115 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
		_tmp7_ = _tmp6_;
#line 115 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
		_g_object_unref0 (_tmp5_);
#line 115 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
		_backend_it = _tmp7_;
#line 115 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
		while (TRUE) {
#line 565 "change-primary-store.c"
			GeeIterator* _tmp8_;
			gboolean _tmp9_ = FALSE;
			GeeIterator* _tmp10_;
			gpointer _tmp11_ = NULL;
			FolksBackend* backend;
			FolksBackend* _tmp12_;
			GeeMap* _tmp13_;
			GeeMap* _tmp14_;
			const gchar* _tmp15_;
			gpointer _tmp16_ = NULL;
			FolksPersonaStore* _tmp17_;
#line 115 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
			_tmp8_ = _backend_it;
#line 115 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
			_tmp9_ = gee_iterator_next (_tmp8_);
#line 115 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
			if (!_tmp9_) {
#line 115 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
				break;
#line 585 "change-primary-store.c"
			}
#line 115 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
			_tmp10_ = _backend_it;
#line 115 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
			_tmp11_ = gee_iterator_get (_tmp10_);
#line 115 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
			backend = (FolksBackend*) _tmp11_;
#line 117 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
			_tmp12_ = backend;
#line 117 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
			_tmp13_ = folks_backend_get_persona_stores (_tmp12_);
#line 117 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
			_tmp14_ = _tmp13_;
#line 117 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
			_tmp15_ = store_id;
#line 117 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
			_tmp16_ = gee_map_get (_tmp14_, _tmp15_);
#line 117 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
			_g_object_unref0 (pstore);
#line 117 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
			pstore = (FolksPersonaStore*) _tmp16_;
#line 118 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
			_tmp17_ = pstore;
#line 118 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
			if (_tmp17_ != NULL) {
#line 119 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
				_g_object_unref0 (backend);
#line 119 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
				break;
#line 615 "change-primary-store.c"
			}
#line 115 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
			_g_object_unref0 (backend);
#line 619 "change-primary-store.c"
		}
#line 115 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
		_g_object_unref0 (_backend_it);
#line 623 "change-primary-store.c"
	}
#line 121 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
	result = pstore;
#line 121 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
	return result;
#line 629 "change-primary-store.c"
}


static void _change_primary_store_tests_primary_store_cb (ChangePrimaryStoreTests* self, GObject* ia_obj, GParamSpec* ps) {
	GObject* _tmp0_;
	FolksIndividualAggregator* _tmp1_;
	FolksIndividualAggregator* ia;
	FolksIndividualAggregator* _tmp2_;
	FolksPersonaStore* _tmp3_;
	FolksPersonaStore* _tmp4_;
	FolksPersonaStore* _tmp5_;
#line 124 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
	g_return_if_fail (self != NULL);
#line 124 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
	g_return_if_fail (ia_obj != NULL);
#line 124 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
	g_return_if_fail (ps != NULL);
#line 126 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
	_tmp0_ = ia_obj;
#line 126 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
	_tmp1_ = _g_object_ref0 (FOLKS_INDIVIDUAL_AGGREGATOR (_tmp0_));
#line 126 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
	ia = _tmp1_;
#line 128 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
	_tmp2_ = ia;
#line 128 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
	_tmp3_ = folks_individual_aggregator_get_primary_store (_tmp2_);
#line 128 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
	_tmp4_ = _tmp3_;
#line 128 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
	_tmp5_ = self->priv->_pstore2;
#line 128 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
	if (_tmp4_ == _tmp5_) {
#line 663 "change-primary-store.c"
		GMainLoop* _tmp6_;
#line 130 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
		self->priv->_new_primary_store_found = TRUE;
#line 131 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
		_tmp6_ = self->priv->_main_loop;
#line 131 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
		g_main_loop_quit (_tmp6_);
#line 671 "change-primary-store.c"
	}
#line 124 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
	_g_object_unref0 (ia);
#line 675 "change-primary-store.c"
}


static void change_primary_store_tests_class_init (ChangePrimaryStoreTestsClass * klass) {
#line 24 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
	change_primary_store_tests_parent_class = g_type_class_peek_parent (klass);
#line 24 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
	g_type_class_add_private (klass, sizeof (ChangePrimaryStoreTestsPrivate));
#line 24 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
	FOLKS_TEST_CASE_CLASS (klass)->set_up = change_primary_store_tests_real_set_up;
#line 24 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
	FOLKS_TEST_CASE_CLASS (klass)->tear_down = change_primary_store_tests_real_tear_down;
#line 24 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
	G_OBJECT_CLASS (klass)->finalize = change_primary_store_tests_finalize;
#line 690 "change-primary-store.c"
}


static void change_primary_store_tests_instance_init (ChangePrimaryStoreTests * self) {
#line 24 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
	self->priv = CHANGE_PRIMARY_STORE_TESTS_GET_PRIVATE (self);
#line 697 "change-primary-store.c"
}


static void change_primary_store_tests_finalize (GObject* obj) {
	ChangePrimaryStoreTests * self;
#line 24 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
	self = CHANGE_PRIMARY_STORE_TESTS (obj);
#line 26 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
	_g_main_loop_unref0 (self->priv->_main_loop);
#line 27 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
	_eds_test_backend_unref0 (self->priv->_eds_backend);
#line 28 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
	_eds_test_backend_unref0 (self->priv->_eds_backend_other);
#line 29 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
	_g_object_unref0 (self->priv->_aggregator);
#line 30 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
	_g_object_unref0 (self->priv->_pstore1);
#line 31 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
	_g_object_unref0 (self->priv->_pstore2);
#line 24 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
	G_OBJECT_CLASS (change_primary_store_tests_parent_class)->finalize (obj);
#line 719 "change-primary-store.c"
}


GType change_primary_store_tests_get_type (void) {
	static volatile gsize change_primary_store_tests_type_id__volatile = 0;
	if (g_once_init_enter (&change_primary_store_tests_type_id__volatile)) {
		static const GTypeInfo g_define_type_info = { sizeof (ChangePrimaryStoreTestsClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) change_primary_store_tests_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ChangePrimaryStoreTests), 0, (GInstanceInitFunc) change_primary_store_tests_instance_init, NULL };
		GType change_primary_store_tests_type_id;
		change_primary_store_tests_type_id = g_type_register_static (FOLKS_TYPE_TEST_CASE, "ChangePrimaryStoreTests", &g_define_type_info, 0);
		g_once_init_leave (&change_primary_store_tests_type_id__volatile, change_primary_store_tests_type_id);
	}
	return change_primary_store_tests_type_id__volatile;
}


gint _vala_main (gchar** args, int args_length1) {
	gint result = 0;
	GTestSuite* _tmp0_ = NULL;
	GTestSuite* root;
	ChangePrimaryStoreTests* _tmp1_;
	ChangePrimaryStoreTests* _tmp2_;
	GTestSuite* _tmp3_ = NULL;
#line 138 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
	g_test_init (&args_length1, &args, NULL);
#line 140 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
	_tmp0_ = g_test_get_root ();
#line 140 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
	root = _tmp0_;
#line 141 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
	_tmp1_ = change_primary_store_tests_new ();
#line 141 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
	_tmp2_ = _tmp1_;
#line 141 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
	_tmp3_ = folks_test_case_get_suite ((FolksTestCase*) _tmp2_);
#line 141 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
	g_test_suite_add_suite (root, _tmp3_);
#line 141 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
	_g_object_unref0 (_tmp2_);
#line 143 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
	g_test_run ();
#line 145 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
	result = 0;
#line 145 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
	return result;
#line 764 "change-primary-store.c"
}


int main (int argc, char ** argv) {
#line 136 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
	g_type_init ();
#line 136 "/home/treitter/collabora/folks/tests/eds/change-primary-store.vala"
	return _vala_main (argv, argc);
#line 773 "change-primary-store.c"
}



