/* primary-store-changes.c generated by valac 0.28.0.16-b1323, the Vala compiler
 * generated from primary-store-changes.vala, do not modify */

/*
 * Copyright (C) 2013 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: Philip Withnall <philip.withnall@collabora.co.uk>
 */

#include <glib.h>
#include <glib-object.h>
#include <dummy-test.h>
#include <folks/folks-dummy.h>
#include <gio/gio.h>
#include <folks-test.h>
#include <folks/folks.h>
#include <gee.h>
#include <stdlib.h>
#include <string.h>


#define TYPE_PRIMARY_STORE_CHANGES_TESTS (primary_store_changes_tests_get_type ())
#define PRIMARY_STORE_CHANGES_TESTS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_PRIMARY_STORE_CHANGES_TESTS, PrimaryStoreChangesTests))
#define PRIMARY_STORE_CHANGES_TESTS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_PRIMARY_STORE_CHANGES_TESTS, PrimaryStoreChangesTestsClass))
#define IS_PRIMARY_STORE_CHANGES_TESTS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_PRIMARY_STORE_CHANGES_TESTS))
#define IS_PRIMARY_STORE_CHANGES_TESTS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_PRIMARY_STORE_CHANGES_TESTS))
#define PRIMARY_STORE_CHANGES_TESTS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_PRIMARY_STORE_CHANGES_TESTS, PrimaryStoreChangesTestsClass))

typedef struct _PrimaryStoreChangesTests PrimaryStoreChangesTests;
typedef struct _PrimaryStoreChangesTestsClass PrimaryStoreChangesTestsClass;
typedef struct _PrimaryStoreChangesTestsPrivate PrimaryStoreChangesTestsPrivate;
#define _g_main_loop_unref0(var) ((var == NULL) ? NULL : (var = (g_main_loop_unref (var), NULL)))
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
typedef struct _PrimaryStoreChangesTestsTestChangePrimaryStoreSettingAsyncData PrimaryStoreChangesTestsTestChangePrimaryStoreSettingAsyncData;
#define _vala_assert(expr, msg) if G_LIKELY (expr) ; else g_assertion_message_expr (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, msg);
#define _vala_return_if_fail(expr, msg) if G_LIKELY (expr) ; else { g_return_if_fail_warning (G_LOG_DOMAIN, G_STRFUNC, msg); return; }
#define _vala_return_val_if_fail(expr, msg, val) if G_LIKELY (expr) ; else { g_return_if_fail_warning (G_LOG_DOMAIN, G_STRFUNC, msg); return val; }
#define _vala_warn_if_fail(expr, msg) if G_LIKELY (expr) ; else g_warn_message (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, msg);

struct _PrimaryStoreChangesTests {
	DummyTestTestCase parent_instance;
	PrimaryStoreChangesTestsPrivate * priv;
	FolksDummyPersonaStore* second_persona_store;
};

struct _PrimaryStoreChangesTestsClass {
	DummyTestTestCaseClass parent_class;
};

struct _PrimaryStoreChangesTestsPrivate {
	GMainLoop* _main_loop;
	GSettings* _settings;
};

struct _PrimaryStoreChangesTestsTestChangePrimaryStoreSettingAsyncData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GSimpleAsyncResult* _async_result;
	PrimaryStoreChangesTests* self;
	GSettings* _tmp0_;
	gboolean key_set;
	GSettings* _tmp1_;
	gboolean _tmp2_;
	FolksIndividualAggregator* aggregator;
	FolksIndividualAggregator* _tmp3_;
	GError* e;
	GError* _tmp4_;
	const gchar* _tmp5_;
	FolksPersonaStore* _tmp6_;
	FolksPersonaStore* _tmp7_;
	const gchar* _tmp8_;
	const gchar* _tmp9_;
	gboolean key_changed;
	GSettings* _tmp10_;
	gboolean _tmp11_;
	FolksPersonaStore* _tmp12_;
	FolksPersonaStore* _tmp13_;
	const gchar* _tmp14_;
	const gchar* _tmp15_;
	GMainLoop* _tmp16_;
	GError * _inner_error_;
};


static gpointer primary_store_changes_tests_parent_class = NULL;

GType primary_store_changes_tests_get_type (void) G_GNUC_CONST;
#define PRIMARY_STORE_CHANGES_TESTS_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), TYPE_PRIMARY_STORE_CHANGES_TESTS, PrimaryStoreChangesTestsPrivate))
enum  {
	PRIMARY_STORE_CHANGES_TESTS_DUMMY_PROPERTY
};
PrimaryStoreChangesTests* primary_store_changes_tests_new (void);
PrimaryStoreChangesTests* primary_store_changes_tests_construct (GType object_type);
void primary_store_changes_tests_test_change_primary_store_setting (PrimaryStoreChangesTests* self);
static void _primary_store_changes_tests_test_change_primary_store_setting_folks_test_case_test_method (gpointer self);
static void primary_store_changes_tests_real_set_up (FolksTestCase* base);
void primary_store_changes_tests_configure_second_persona_store (PrimaryStoreChangesTests* self);
static void primary_store_changes_tests_real_tear_down (FolksTestCase* base);
static gboolean _vala_string_array_contains (gchar** stack, int stack_length, gchar* needle);
static void primary_store_changes_tests_test_change_primary_store_setting_async (PrimaryStoreChangesTests* self, GAsyncReadyCallback _callback_, gpointer _user_data_);
static void primary_store_changes_tests_test_change_primary_store_setting_finish (PrimaryStoreChangesTests* self, GAsyncResult* _res_);
static void primary_store_changes_tests_test_change_primary_store_setting_async_data_free (gpointer _data);
static gboolean primary_store_changes_tests_test_change_primary_store_setting_async_co (PrimaryStoreChangesTestsTestChangePrimaryStoreSettingAsyncData* _data_);
static void primary_store_changes_tests_test_change_primary_store_setting_async_ready (GObject* source_object, GAsyncResult* _res_, gpointer _user_data_);
static void primary_store_changes_tests_finalize (GObject* obj);
gint _vala_main (gchar** args, int args_length1);
static void _vala_array_destroy (gpointer array, gint array_length, GDestroyNotify destroy_func);
static void _vala_array_free (gpointer array, gint array_length, GDestroyNotify destroy_func);
static gint _vala_array_length (gpointer array);


static void _primary_store_changes_tests_test_change_primary_store_setting_folks_test_case_test_method (gpointer self) {
#line 38 "/opt/gnome3/source/folks/tests/folks/primary-store-changes.vala"
	primary_store_changes_tests_test_change_primary_store_setting ((PrimaryStoreChangesTests*) self);
#line 131 "primary-store-changes.c"
}


PrimaryStoreChangesTests* primary_store_changes_tests_construct (GType object_type) {
	PrimaryStoreChangesTests * self = NULL;
#line 33 "/opt/gnome3/source/folks/tests/folks/primary-store-changes.vala"
	self = (PrimaryStoreChangesTests*) dummy_test_test_case_construct (object_type, "PrimaryStoreChangesTests");
#line 35 "/opt/gnome3/source/folks/tests/folks/primary-store-changes.vala"
	g_unsetenv ("FOLKS_PRIMARY_STORE");
#line 38 "/opt/gnome3/source/folks/tests/folks/primary-store-changes.vala"
	folks_test_case_add_test ((FolksTestCase*) self, "change primary-store setting", _primary_store_changes_tests_test_change_primary_store_setting_folks_test_case_test_method, self);
#line 31 "/opt/gnome3/source/folks/tests/folks/primary-store-changes.vala"
	return self;
#line 145 "primary-store-changes.c"
}


PrimaryStoreChangesTests* primary_store_changes_tests_new (void) {
#line 31 "/opt/gnome3/source/folks/tests/folks/primary-store-changes.vala"
	return primary_store_changes_tests_construct (TYPE_PRIMARY_STORE_CHANGES_TESTS);
#line 152 "primary-store-changes.c"
}


static void primary_store_changes_tests_real_set_up (FolksTestCase* base) {
	PrimaryStoreChangesTests * self;
	FolksDummyPersonaStore* _tmp0_ = NULL;
#line 42 "/opt/gnome3/source/folks/tests/folks/primary-store-changes.vala"
	self = (PrimaryStoreChangesTests*) base;
#line 44 "/opt/gnome3/source/folks/tests/folks/primary-store-changes.vala"
	FOLKS_TEST_CASE_CLASS (primary_store_changes_tests_parent_class)->set_up ((FolksTestCase*) G_TYPE_CHECK_INSTANCE_CAST (self, DUMMY_TEST_TYPE_TEST_CASE, DummyTestTestCase));
#line 46 "/opt/gnome3/source/folks/tests/folks/primary-store-changes.vala"
	primary_store_changes_tests_configure_second_persona_store (self);
#line 47 "/opt/gnome3/source/folks/tests/folks/primary-store-changes.vala"
	_tmp0_ = ((DummyTestTestCase*) self)->dummy_persona_store;
#line 47 "/opt/gnome3/source/folks/tests/folks/primary-store-changes.vala"
	folks_dummy_persona_store_update_trust_level (_tmp0_, FOLKS_PERSONA_STORE_TRUST_FULL);
#line 169 "primary-store-changes.c"
}


static void primary_store_changes_tests_real_tear_down (FolksTestCase* base) {
	PrimaryStoreChangesTests * self;
	GSettings* _tmp0_ = NULL;
	GeeHashSet* persona_stores = NULL;
	GeeHashSet* _tmp2_ = NULL;
	FolksDummyPersonaStore* _tmp3_ = NULL;
	FolksDummyBackend* _tmp4_ = NULL;
#line 50 "/opt/gnome3/source/folks/tests/folks/primary-store-changes.vala"
	self = (PrimaryStoreChangesTests*) base;
#line 53 "/opt/gnome3/source/folks/tests/folks/primary-store-changes.vala"
	_tmp0_ = self->priv->_settings;
#line 53 "/opt/gnome3/source/folks/tests/folks/primary-store-changes.vala"
	if (_tmp0_ != NULL) {
#line 186 "primary-store-changes.c"
		GSettings* _tmp1_ = NULL;
#line 55 "/opt/gnome3/source/folks/tests/folks/primary-store-changes.vala"
		_tmp1_ = self->priv->_settings;
#line 55 "/opt/gnome3/source/folks/tests/folks/primary-store-changes.vala"
		g_settings_set_string (_tmp1_, "primary-store", "dummy:dummy-store");
#line 192 "primary-store-changes.c"
	}
#line 58 "/opt/gnome3/source/folks/tests/folks/primary-store-changes.vala"
	_tmp2_ = gee_hash_set_new (FOLKS_TYPE_PERSONA_STORE, (GBoxedCopyFunc) g_object_ref, g_object_unref, NULL, NULL, NULL, NULL, NULL, NULL);
#line 58 "/opt/gnome3/source/folks/tests/folks/primary-store-changes.vala"
	persona_stores = _tmp2_;
#line 59 "/opt/gnome3/source/folks/tests/folks/primary-store-changes.vala"
	_tmp3_ = self->second_persona_store;
#line 59 "/opt/gnome3/source/folks/tests/folks/primary-store-changes.vala"
	gee_abstract_collection_add ((GeeAbstractCollection*) persona_stores, (FolksPersonaStore*) _tmp3_);
#line 60 "/opt/gnome3/source/folks/tests/folks/primary-store-changes.vala"
	_tmp4_ = ((DummyTestTestCase*) self)->dummy_backend;
#line 60 "/opt/gnome3/source/folks/tests/folks/primary-store-changes.vala"
	folks_dummy_backend_unregister_persona_stores (_tmp4_, (GeeSet*) persona_stores);
#line 62 "/opt/gnome3/source/folks/tests/folks/primary-store-changes.vala"
	_g_object_unref0 (self->second_persona_store);
#line 62 "/opt/gnome3/source/folks/tests/folks/primary-store-changes.vala"
	self->second_persona_store = NULL;
#line 64 "/opt/gnome3/source/folks/tests/folks/primary-store-changes.vala"
	FOLKS_TEST_CASE_CLASS (primary_store_changes_tests_parent_class)->tear_down ((FolksTestCase*) G_TYPE_CHECK_INSTANCE_CAST (self, DUMMY_TEST_TYPE_TEST_CASE, DummyTestTestCase));
#line 50 "/opt/gnome3/source/folks/tests/folks/primary-store-changes.vala"
	_g_object_unref0 (persona_stores);
#line 214 "primary-store-changes.c"
}


void primary_store_changes_tests_configure_second_persona_store (PrimaryStoreChangesTests* self) {
	gchar** writable_properties = NULL;
	const gchar* _tmp0_ = NULL;
	gchar* _tmp1_ = NULL;
	const gchar* _tmp2_ = NULL;
	gchar* _tmp3_ = NULL;
	gchar** _tmp4_ = NULL;
	gint writable_properties_length1 = 0;
	gint _writable_properties_size_ = 0;
	FolksDummyPersonaStore* _tmp5_ = NULL;
	FolksDummyPersonaStore* _tmp6_ = NULL;
	GeeHashSet* persona_stores = NULL;
	GeeHashSet* _tmp7_ = NULL;
	FolksDummyPersonaStore* _tmp8_ = NULL;
	FolksDummyBackend* _tmp9_ = NULL;
#line 67 "/opt/gnome3/source/folks/tests/folks/primary-store-changes.vala"
	g_return_if_fail (self != NULL);
#line 69 "/opt/gnome3/source/folks/tests/folks/primary-store-changes.vala"
	_tmp0_ = folks_persona_store_detail_key (FOLKS_PERSONA_DETAIL_EMAIL_ADDRESSES);
#line 69 "/opt/gnome3/source/folks/tests/folks/primary-store-changes.vala"
	_tmp1_ = g_strdup (_tmp0_);
#line 69 "/opt/gnome3/source/folks/tests/folks/primary-store-changes.vala"
	_tmp2_ = folks_persona_store_detail_key (FOLKS_PERSONA_DETAIL_PHONE_NUMBERS);
#line 69 "/opt/gnome3/source/folks/tests/folks/primary-store-changes.vala"
	_tmp3_ = g_strdup (_tmp2_);
#line 69 "/opt/gnome3/source/folks/tests/folks/primary-store-changes.vala"
	_tmp4_ = g_new0 (gchar*, 3 + 1);
#line 69 "/opt/gnome3/source/folks/tests/folks/primary-store-changes.vala"
	_tmp4_[0] = _tmp1_;
#line 69 "/opt/gnome3/source/folks/tests/folks/primary-store-changes.vala"
	_tmp4_[1] = _tmp3_;
#line 69 "/opt/gnome3/source/folks/tests/folks/primary-store-changes.vala"
	_tmp4_[2] = NULL;
#line 69 "/opt/gnome3/source/folks/tests/folks/primary-store-changes.vala"
	writable_properties = _tmp4_;
#line 69 "/opt/gnome3/source/folks/tests/folks/primary-store-changes.vala"
	writable_properties_length1 = 3;
#line 69 "/opt/gnome3/source/folks/tests/folks/primary-store-changes.vala"
	_writable_properties_size_ = writable_properties_length1;
#line 77 "/opt/gnome3/source/folks/tests/folks/primary-store-changes.vala"
	_tmp5_ = folks_dummy_persona_store_new ("dummy-store-1", "Dummy personas I", writable_properties, writable_properties_length1);
#line 77 "/opt/gnome3/source/folks/tests/folks/primary-store-changes.vala"
	_g_object_unref0 (self->second_persona_store);
#line 77 "/opt/gnome3/source/folks/tests/folks/primary-store-changes.vala"
	self->second_persona_store = _tmp5_;
#line 80 "/opt/gnome3/source/folks/tests/folks/primary-store-changes.vala"
	_tmp6_ = self->second_persona_store;
#line 80 "/opt/gnome3/source/folks/tests/folks/primary-store-changes.vala"
	folks_dummy_persona_store_set_persona_type (_tmp6_, FOLKS_DUMMY_TYPE_FULL_PERSONA);
#line 83 "/opt/gnome3/source/folks/tests/folks/primary-store-changes.vala"
	_tmp7_ = gee_hash_set_new (FOLKS_TYPE_PERSONA_STORE, (GBoxedCopyFunc) g_object_ref, g_object_unref, NULL, NULL, NULL, NULL, NULL, NULL);
#line 83 "/opt/gnome3/source/folks/tests/folks/primary-store-changes.vala"
	persona_stores = _tmp7_;
#line 84 "/opt/gnome3/source/folks/tests/folks/primary-store-changes.vala"
	_tmp8_ = self->second_persona_store;
#line 84 "/opt/gnome3/source/folks/tests/folks/primary-store-changes.vala"
	gee_abstract_collection_add ((GeeAbstractCollection*) persona_stores, (FolksPersonaStore*) _tmp8_);
#line 85 "/opt/gnome3/source/folks/tests/folks/primary-store-changes.vala"
	_tmp9_ = ((DummyTestTestCase*) self)->dummy_backend;
#line 85 "/opt/gnome3/source/folks/tests/folks/primary-store-changes.vala"
	folks_dummy_backend_register_persona_stores (_tmp9_, (GeeSet*) persona_stores, TRUE);
#line 67 "/opt/gnome3/source/folks/tests/folks/primary-store-changes.vala"
	_g_object_unref0 (persona_stores);
#line 67 "/opt/gnome3/source/folks/tests/folks/primary-store-changes.vala"
	writable_properties = (_vala_array_free (writable_properties, writable_properties_length1, (GDestroyNotify) g_free), NULL);
#line 283 "primary-store-changes.c"
}


static gboolean _vala_string_array_contains (gchar** stack, int stack_length, gchar* needle) {
	int i;
#line 95 "/opt/gnome3/source/folks/tests/folks/primary-store-changes.vala"
	for (i = 0; i < stack_length; i++) {
#line 95 "/opt/gnome3/source/folks/tests/folks/primary-store-changes.vala"
		if (g_strcmp0 (stack[i], needle) == 0) {
#line 95 "/opt/gnome3/source/folks/tests/folks/primary-store-changes.vala"
			return TRUE;
#line 295 "primary-store-changes.c"
		}
	}
#line 95 "/opt/gnome3/source/folks/tests/folks/primary-store-changes.vala"
	return FALSE;
#line 300 "primary-store-changes.c"
}


void primary_store_changes_tests_test_change_primary_store_setting (PrimaryStoreChangesTests* self) {
	gchar** schemas = NULL;
	gchar** _tmp0_ = NULL;
	gchar** _tmp1_ = NULL;
	gint schemas_length1 = 0;
	gint _schemas_size_ = 0;
	gchar** _tmp2_ = NULL;
	gint _tmp2__length1 = 0;
	GMainLoop* _tmp3_ = NULL;
	GMainLoop* _tmp4_ = NULL;
#line 90 "/opt/gnome3/source/folks/tests/folks/primary-store-changes.vala"
	g_return_if_fail (self != NULL);
#line 94 "/opt/gnome3/source/folks/tests/folks/primary-store-changes.vala"
	_tmp1_ = _tmp0_ = g_settings_list_schemas ();
#line 94 "/opt/gnome3/source/folks/tests/folks/primary-store-changes.vala"
	schemas = _tmp1_;
#line 94 "/opt/gnome3/source/folks/tests/folks/primary-store-changes.vala"
	schemas_length1 = _vala_array_length (_tmp0_);
#line 94 "/opt/gnome3/source/folks/tests/folks/primary-store-changes.vala"
	_schemas_size_ = schemas_length1;
#line 95 "/opt/gnome3/source/folks/tests/folks/primary-store-changes.vala"
	_tmp2_ = schemas;
#line 95 "/opt/gnome3/source/folks/tests/folks/primary-store-changes.vala"
	_tmp2__length1 = schemas_length1;
#line 95 "/opt/gnome3/source/folks/tests/folks/primary-store-changes.vala"
	if (!_vala_string_array_contains (_tmp2_, _tmp2__length1, "org.freedesktopp.folks")) {
#line 97 "/opt/gnome3/source/folks/tests/folks/primary-store-changes.vala"
		return;
#line 332 "primary-store-changes.c"
	}
#line 100 "/opt/gnome3/source/folks/tests/folks/primary-store-changes.vala"
	_tmp3_ = g_main_loop_new (NULL, FALSE);
#line 100 "/opt/gnome3/source/folks/tests/folks/primary-store-changes.vala"
	_g_main_loop_unref0 (self->priv->_main_loop);
#line 100 "/opt/gnome3/source/folks/tests/folks/primary-store-changes.vala"
	self->priv->_main_loop = _tmp3_;
#line 101 "/opt/gnome3/source/folks/tests/folks/primary-store-changes.vala"
	primary_store_changes_tests_test_change_primary_store_setting_async (self, NULL, NULL);
#line 102 "/opt/gnome3/source/folks/tests/folks/primary-store-changes.vala"
	_tmp4_ = self->priv->_main_loop;
#line 102 "/opt/gnome3/source/folks/tests/folks/primary-store-changes.vala"
	folks_test_utils_loop_run_with_timeout (_tmp4_, 5);
#line 346 "primary-store-changes.c"
}


static void primary_store_changes_tests_test_change_primary_store_setting_async_data_free (gpointer _data) {
	PrimaryStoreChangesTestsTestChangePrimaryStoreSettingAsyncData* _data_;
	_data_ = _data;
#line 23 "/opt/gnome3/source/folks/tests/folks/primary-store-changes.vala"
	_g_object_unref0 (_data_->self);
#line 23 "/opt/gnome3/source/folks/tests/folks/primary-store-changes.vala"
	g_slice_free (PrimaryStoreChangesTestsTestChangePrimaryStoreSettingAsyncData, _data_);
#line 357 "primary-store-changes.c"
}


static gpointer _g_object_ref0 (gpointer self) {
#line 23 "/opt/gnome3/source/folks/tests/folks/primary-store-changes.vala"
	return self ? g_object_ref (self) : NULL;
#line 364 "primary-store-changes.c"
}


static void primary_store_changes_tests_test_change_primary_store_setting_async (PrimaryStoreChangesTests* self, GAsyncReadyCallback _callback_, gpointer _user_data_) {
	PrimaryStoreChangesTestsTestChangePrimaryStoreSettingAsyncData* _data_;
	PrimaryStoreChangesTests* _tmp0_ = NULL;
#line 23 "/opt/gnome3/source/folks/tests/folks/primary-store-changes.vala"
	_data_ = g_slice_new0 (PrimaryStoreChangesTestsTestChangePrimaryStoreSettingAsyncData);
#line 23 "/opt/gnome3/source/folks/tests/folks/primary-store-changes.vala"
	_data_->_async_result = g_simple_async_result_new (G_OBJECT (self), _callback_, _user_data_, primary_store_changes_tests_test_change_primary_store_setting_async);
#line 23 "/opt/gnome3/source/folks/tests/folks/primary-store-changes.vala"
	g_simple_async_result_set_op_res_gpointer (_data_->_async_result, _data_, primary_store_changes_tests_test_change_primary_store_setting_async_data_free);
#line 23 "/opt/gnome3/source/folks/tests/folks/primary-store-changes.vala"
	_tmp0_ = _g_object_ref0 (self);
#line 23 "/opt/gnome3/source/folks/tests/folks/primary-store-changes.vala"
	_data_->self = _tmp0_;
#line 23 "/opt/gnome3/source/folks/tests/folks/primary-store-changes.vala"
	primary_store_changes_tests_test_change_primary_store_setting_async_co (_data_);
#line 383 "primary-store-changes.c"
}


static void primary_store_changes_tests_test_change_primary_store_setting_finish (PrimaryStoreChangesTests* self, GAsyncResult* _res_) {
	PrimaryStoreChangesTestsTestChangePrimaryStoreSettingAsyncData* _data_;
#line 23 "/opt/gnome3/source/folks/tests/folks/primary-store-changes.vala"
	_data_ = g_simple_async_result_get_op_res_gpointer (G_SIMPLE_ASYNC_RESULT (_res_));
#line 391 "primary-store-changes.c"
}


static void primary_store_changes_tests_test_change_primary_store_setting_async_ready (GObject* source_object, GAsyncResult* _res_, gpointer _user_data_) {
	PrimaryStoreChangesTestsTestChangePrimaryStoreSettingAsyncData* _data_;
#line 115 "/opt/gnome3/source/folks/tests/folks/primary-store-changes.vala"
	_data_ = _user_data_;
#line 115 "/opt/gnome3/source/folks/tests/folks/primary-store-changes.vala"
	_data_->_source_object_ = source_object;
#line 115 "/opt/gnome3/source/folks/tests/folks/primary-store-changes.vala"
	_data_->_res_ = _res_;
#line 115 "/opt/gnome3/source/folks/tests/folks/primary-store-changes.vala"
	primary_store_changes_tests_test_change_primary_store_setting_async_co (_data_);
#line 405 "primary-store-changes.c"
}


static gboolean primary_store_changes_tests_test_change_primary_store_setting_async_co (PrimaryStoreChangesTestsTestChangePrimaryStoreSettingAsyncData* _data_) {
#line 105 "/opt/gnome3/source/folks/tests/folks/primary-store-changes.vala"
	switch (_data_->_state_) {
#line 105 "/opt/gnome3/source/folks/tests/folks/primary-store-changes.vala"
		case 0:
#line 414 "primary-store-changes.c"
		goto _state_0;
#line 105 "/opt/gnome3/source/folks/tests/folks/primary-store-changes.vala"
		case 1:
#line 418 "primary-store-changes.c"
		goto _state_1;
		default:
#line 105 "/opt/gnome3/source/folks/tests/folks/primary-store-changes.vala"
		g_assert_not_reached ();
#line 423 "primary-store-changes.c"
	}
	_state_0:
#line 107 "/opt/gnome3/source/folks/tests/folks/primary-store-changes.vala"
	_data_->_tmp0_ = NULL;
#line 107 "/opt/gnome3/source/folks/tests/folks/primary-store-changes.vala"
	_data_->_tmp0_ = g_settings_new ("org.freedesktop.folks");
#line 107 "/opt/gnome3/source/folks/tests/folks/primary-store-changes.vala"
	_g_object_unref0 (_data_->self->priv->_settings);
#line 107 "/opt/gnome3/source/folks/tests/folks/primary-store-changes.vala"
	_data_->self->priv->_settings = _data_->_tmp0_;
#line 108 "/opt/gnome3/source/folks/tests/folks/primary-store-changes.vala"
	_data_->_tmp1_ = NULL;
#line 108 "/opt/gnome3/source/folks/tests/folks/primary-store-changes.vala"
	_data_->_tmp1_ = _data_->self->priv->_settings;
#line 108 "/opt/gnome3/source/folks/tests/folks/primary-store-changes.vala"
	_data_->_tmp2_ = FALSE;
#line 108 "/opt/gnome3/source/folks/tests/folks/primary-store-changes.vala"
	_data_->_tmp2_ = g_settings_set_string (_data_->_tmp1_, "primary-store", "dummy:dummy-store");
#line 108 "/opt/gnome3/source/folks/tests/folks/primary-store-changes.vala"
	_data_->key_set = _data_->_tmp2_;
#line 109 "/opt/gnome3/source/folks/tests/folks/primary-store-changes.vala"
	_vala_assert (_data_->key_set == TRUE, "key_set == true");
#line 111 "/opt/gnome3/source/folks/tests/folks/primary-store-changes.vala"
	_data_->_tmp3_ = NULL;
#line 111 "/opt/gnome3/source/folks/tests/folks/primary-store-changes.vala"
	_data_->_tmp3_ = folks_individual_aggregator_dup ();
#line 111 "/opt/gnome3/source/folks/tests/folks/primary-store-changes.vala"
	_data_->aggregator = _data_->_tmp3_;
#line 452 "primary-store-changes.c"
	{
#line 115 "/opt/gnome3/source/folks/tests/folks/primary-store-changes.vala"
		_data_->_state_ = 1;
#line 115 "/opt/gnome3/source/folks/tests/folks/primary-store-changes.vala"
		folks_individual_aggregator_prepare (_data_->aggregator, primary_store_changes_tests_test_change_primary_store_setting_async_ready, _data_);
#line 115 "/opt/gnome3/source/folks/tests/folks/primary-store-changes.vala"
		return FALSE;
#line 460 "primary-store-changes.c"
		_state_1:
#line 115 "/opt/gnome3/source/folks/tests/folks/primary-store-changes.vala"
		folks_individual_aggregator_prepare_finish (_data_->aggregator, _data_->_res_, &_data_->_inner_error_);
#line 115 "/opt/gnome3/source/folks/tests/folks/primary-store-changes.vala"
		if (G_UNLIKELY (_data_->_inner_error_ != NULL)) {
#line 466 "primary-store-changes.c"
			goto __catch0_g_error;
		}
	}
	goto __finally0;
	__catch0_g_error:
	{
#line 113 "/opt/gnome3/source/folks/tests/folks/primary-store-changes.vala"
		_data_->e = _data_->_inner_error_;
#line 113 "/opt/gnome3/source/folks/tests/folks/primary-store-changes.vala"
		_data_->_inner_error_ = NULL;
#line 119 "/opt/gnome3/source/folks/tests/folks/primary-store-changes.vala"
		_data_->_tmp4_ = NULL;
#line 119 "/opt/gnome3/source/folks/tests/folks/primary-store-changes.vala"
		_data_->_tmp4_ = _data_->e;
#line 119 "/opt/gnome3/source/folks/tests/folks/primary-store-changes.vala"
		_data_->_tmp5_ = NULL;
#line 119 "/opt/gnome3/source/folks/tests/folks/primary-store-changes.vala"
		_data_->_tmp5_ = _data_->_tmp4_->message;
#line 119 "/opt/gnome3/source/folks/tests/folks/primary-store-changes.vala"
		g_warning ("primary-store-changes.vala:119: Error when calling prepare: %s\n", _data_->_tmp5_);
#line 113 "/opt/gnome3/source/folks/tests/folks/primary-store-changes.vala"
		_g_error_free0 (_data_->e);
#line 489 "primary-store-changes.c"
	}
	__finally0:
#line 113 "/opt/gnome3/source/folks/tests/folks/primary-store-changes.vala"
	if (G_UNLIKELY (_data_->_inner_error_ != NULL)) {
#line 113 "/opt/gnome3/source/folks/tests/folks/primary-store-changes.vala"
		_g_object_unref0 (_data_->aggregator);
#line 113 "/opt/gnome3/source/folks/tests/folks/primary-store-changes.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 113 "/opt/gnome3/source/folks/tests/folks/primary-store-changes.vala"
		g_clear_error (&_data_->_inner_error_);
#line 113 "/opt/gnome3/source/folks/tests/folks/primary-store-changes.vala"
		return FALSE;
#line 502 "primary-store-changes.c"
	}
#line 123 "/opt/gnome3/source/folks/tests/folks/primary-store-changes.vala"
	_data_->_tmp6_ = NULL;
#line 123 "/opt/gnome3/source/folks/tests/folks/primary-store-changes.vala"
	_data_->_tmp6_ = folks_individual_aggregator_get_primary_store (_data_->aggregator);
#line 123 "/opt/gnome3/source/folks/tests/folks/primary-store-changes.vala"
	_data_->_tmp7_ = NULL;
#line 123 "/opt/gnome3/source/folks/tests/folks/primary-store-changes.vala"
	_data_->_tmp7_ = _data_->_tmp6_;
#line 123 "/opt/gnome3/source/folks/tests/folks/primary-store-changes.vala"
	_data_->_tmp8_ = NULL;
#line 123 "/opt/gnome3/source/folks/tests/folks/primary-store-changes.vala"
	_data_->_tmp8_ = folks_persona_store_get_id (_data_->_tmp7_);
#line 123 "/opt/gnome3/source/folks/tests/folks/primary-store-changes.vala"
	_data_->_tmp9_ = NULL;
#line 123 "/opt/gnome3/source/folks/tests/folks/primary-store-changes.vala"
	_data_->_tmp9_ = _data_->_tmp8_;
#line 123 "/opt/gnome3/source/folks/tests/folks/primary-store-changes.vala"
	_vala_assert (g_strcmp0 (_data_->_tmp9_, "dummy-store") == 0, "aggregator.primary_store.id == \"dummy-store\"");
#line 126 "/opt/gnome3/source/folks/tests/folks/primary-store-changes.vala"
	_data_->_tmp10_ = NULL;
#line 126 "/opt/gnome3/source/folks/tests/folks/primary-store-changes.vala"
	_data_->_tmp10_ = _data_->self->priv->_settings;
#line 126 "/opt/gnome3/source/folks/tests/folks/primary-store-changes.vala"
	_data_->_tmp11_ = FALSE;
#line 126 "/opt/gnome3/source/folks/tests/folks/primary-store-changes.vala"
	_data_->_tmp11_ = g_settings_set_string (_data_->_tmp10_, "primary-store", "dummy:dummy-store-1");
#line 126 "/opt/gnome3/source/folks/tests/folks/primary-store-changes.vala"
	_data_->key_changed = _data_->_tmp11_;
#line 128 "/opt/gnome3/source/folks/tests/folks/primary-store-changes.vala"
	_vala_assert (_data_->key_changed == TRUE, "key_changed == true");
#line 131 "/opt/gnome3/source/folks/tests/folks/primary-store-changes.vala"
	_data_->_tmp12_ = NULL;
#line 131 "/opt/gnome3/source/folks/tests/folks/primary-store-changes.vala"
	_data_->_tmp12_ = folks_individual_aggregator_get_primary_store (_data_->aggregator);
#line 131 "/opt/gnome3/source/folks/tests/folks/primary-store-changes.vala"
	_data_->_tmp13_ = NULL;
#line 131 "/opt/gnome3/source/folks/tests/folks/primary-store-changes.vala"
	_data_->_tmp13_ = _data_->_tmp12_;
#line 131 "/opt/gnome3/source/folks/tests/folks/primary-store-changes.vala"
	_data_->_tmp14_ = NULL;
#line 131 "/opt/gnome3/source/folks/tests/folks/primary-store-changes.vala"
	_data_->_tmp14_ = folks_persona_store_get_id (_data_->_tmp13_);
#line 131 "/opt/gnome3/source/folks/tests/folks/primary-store-changes.vala"
	_data_->_tmp15_ = NULL;
#line 131 "/opt/gnome3/source/folks/tests/folks/primary-store-changes.vala"
	_data_->_tmp15_ = _data_->_tmp14_;
#line 131 "/opt/gnome3/source/folks/tests/folks/primary-store-changes.vala"
	_vala_assert (g_strcmp0 (_data_->_tmp15_, "dummy-store-1") == 0, "aggregator.primary_store.id == \"dummy-store-1\"");
#line 133 "/opt/gnome3/source/folks/tests/folks/primary-store-changes.vala"
	_data_->_tmp16_ = NULL;
#line 133 "/opt/gnome3/source/folks/tests/folks/primary-store-changes.vala"
	_data_->_tmp16_ = _data_->self->priv->_main_loop;
#line 133 "/opt/gnome3/source/folks/tests/folks/primary-store-changes.vala"
	g_main_loop_quit (_data_->_tmp16_);
#line 105 "/opt/gnome3/source/folks/tests/folks/primary-store-changes.vala"
	_g_object_unref0 (_data_->aggregator);
#line 105 "/opt/gnome3/source/folks/tests/folks/primary-store-changes.vala"
	if (_data_->_state_ == 0) {
#line 105 "/opt/gnome3/source/folks/tests/folks/primary-store-changes.vala"
		g_simple_async_result_complete_in_idle (_data_->_async_result);
#line 564 "primary-store-changes.c"
	} else {
#line 105 "/opt/gnome3/source/folks/tests/folks/primary-store-changes.vala"
		g_simple_async_result_complete (_data_->_async_result);
#line 568 "primary-store-changes.c"
	}
#line 105 "/opt/gnome3/source/folks/tests/folks/primary-store-changes.vala"
	g_object_unref (_data_->_async_result);
#line 105 "/opt/gnome3/source/folks/tests/folks/primary-store-changes.vala"
	return FALSE;
#line 574 "primary-store-changes.c"
}


static void primary_store_changes_tests_class_init (PrimaryStoreChangesTestsClass * klass) {
#line 23 "/opt/gnome3/source/folks/tests/folks/primary-store-changes.vala"
	primary_store_changes_tests_parent_class = g_type_class_peek_parent (klass);
#line 23 "/opt/gnome3/source/folks/tests/folks/primary-store-changes.vala"
	g_type_class_add_private (klass, sizeof (PrimaryStoreChangesTestsPrivate));
#line 23 "/opt/gnome3/source/folks/tests/folks/primary-store-changes.vala"
	((FolksTestCaseClass *) klass)->set_up = primary_store_changes_tests_real_set_up;
#line 23 "/opt/gnome3/source/folks/tests/folks/primary-store-changes.vala"
	((FolksTestCaseClass *) klass)->tear_down = primary_store_changes_tests_real_tear_down;
#line 23 "/opt/gnome3/source/folks/tests/folks/primary-store-changes.vala"
	G_OBJECT_CLASS (klass)->finalize = primary_store_changes_tests_finalize;
#line 589 "primary-store-changes.c"
}


static void primary_store_changes_tests_instance_init (PrimaryStoreChangesTests * self) {
#line 23 "/opt/gnome3/source/folks/tests/folks/primary-store-changes.vala"
	self->priv = PRIMARY_STORE_CHANGES_TESTS_GET_PRIVATE (self);
#line 27 "/opt/gnome3/source/folks/tests/folks/primary-store-changes.vala"
	self->priv->_settings = NULL;
#line 598 "primary-store-changes.c"
}


static void primary_store_changes_tests_finalize (GObject* obj) {
	PrimaryStoreChangesTests * self;
#line 23 "/opt/gnome3/source/folks/tests/folks/primary-store-changes.vala"
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_PRIMARY_STORE_CHANGES_TESTS, PrimaryStoreChangesTests);
#line 25 "/opt/gnome3/source/folks/tests/folks/primary-store-changes.vala"
	_g_main_loop_unref0 (self->priv->_main_loop);
#line 27 "/opt/gnome3/source/folks/tests/folks/primary-store-changes.vala"
	_g_object_unref0 (self->priv->_settings);
#line 29 "/opt/gnome3/source/folks/tests/folks/primary-store-changes.vala"
	_g_object_unref0 (self->second_persona_store);
#line 23 "/opt/gnome3/source/folks/tests/folks/primary-store-changes.vala"
	G_OBJECT_CLASS (primary_store_changes_tests_parent_class)->finalize (obj);
#line 614 "primary-store-changes.c"
}


GType primary_store_changes_tests_get_type (void) {
	static volatile gsize primary_store_changes_tests_type_id__volatile = 0;
	if (g_once_init_enter (&primary_store_changes_tests_type_id__volatile)) {
		static const GTypeInfo g_define_type_info = { sizeof (PrimaryStoreChangesTestsClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) primary_store_changes_tests_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (PrimaryStoreChangesTests), 0, (GInstanceInitFunc) primary_store_changes_tests_instance_init, NULL };
		GType primary_store_changes_tests_type_id;
		primary_store_changes_tests_type_id = g_type_register_static (DUMMY_TEST_TYPE_TEST_CASE, "PrimaryStoreChangesTests", &g_define_type_info, 0);
		g_once_init_leave (&primary_store_changes_tests_type_id__volatile, primary_store_changes_tests_type_id);
	}
	return primary_store_changes_tests_type_id__volatile;
}


gint _vala_main (gchar** args, int args_length1) {
	gint result = 0;
	PrimaryStoreChangesTests* tests = NULL;
	PrimaryStoreChangesTests* _tmp0_ = NULL;
#line 139 "/opt/gnome3/source/folks/tests/folks/primary-store-changes.vala"
	g_test_init (&args_length1, &args, NULL);
#line 141 "/opt/gnome3/source/folks/tests/folks/primary-store-changes.vala"
	_tmp0_ = primary_store_changes_tests_new ();
#line 141 "/opt/gnome3/source/folks/tests/folks/primary-store-changes.vala"
	tests = _tmp0_;
#line 142 "/opt/gnome3/source/folks/tests/folks/primary-store-changes.vala"
	folks_test_case_register ((FolksTestCase*) tests);
#line 143 "/opt/gnome3/source/folks/tests/folks/primary-store-changes.vala"
	g_test_run ();
#line 144 "/opt/gnome3/source/folks/tests/folks/primary-store-changes.vala"
	folks_test_case_final_tear_down ((FolksTestCase*) tests);
#line 146 "/opt/gnome3/source/folks/tests/folks/primary-store-changes.vala"
	result = 0;
#line 146 "/opt/gnome3/source/folks/tests/folks/primary-store-changes.vala"
	_g_object_unref0 (tests);
#line 146 "/opt/gnome3/source/folks/tests/folks/primary-store-changes.vala"
	return result;
#line 652 "primary-store-changes.c"
}


int main (int argc, char ** argv) {
#if !GLIB_CHECK_VERSION (2,35,0)
	g_type_init ();
#endif
#line 137 "/opt/gnome3/source/folks/tests/folks/primary-store-changes.vala"
	return _vala_main (argv, argc);
#line 662 "primary-store-changes.c"
}


static void _vala_array_destroy (gpointer array, gint array_length, GDestroyNotify destroy_func) {
	if ((array != NULL) && (destroy_func != NULL)) {
		int i;
		for (i = 0; i < array_length; i = i + 1) {
			if (((gpointer*) array)[i] != NULL) {
				destroy_func (((gpointer*) array)[i]);
			}
		}
	}
}


static void _vala_array_free (gpointer array, gint array_length, GDestroyNotify destroy_func) {
	_vala_array_destroy (array, array_length, destroy_func);
	g_free (array);
}


static gint _vala_array_length (gpointer array) {
	int length;
	length = 0;
	if (array) {
		while (((gpointer*) array)[length]) {
			length++;
		}
	}
	return length;
}



