/* test-case.c generated by valac 0.21.1.1-0d6f, the Vala compiler
 * generated from test-case.vala, do not modify */

/* test-case.vala
 *
 * Copyright © 2011 Collabora Ltd.
 * Copyright © 2013 Intel Corporation
 *
 * 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, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
 *
 * Author:
 *      Raul Gutierrez Segales <raul.gutierrez.segales@collabora.co.uk>
 *      Simon McVittie <simon.mcvittie@collabora.co.uk>
 */

#include <glib.h>
#include <glib-object.h>
#include <folks-test.h>
#include <stdlib.h>
#include <string.h>


#define EDS_TEST_TYPE_TEST_CASE (eds_test_test_case_get_type ())
#define EDS_TEST_TEST_CASE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EDS_TEST_TYPE_TEST_CASE, EdsTestTestCase))
#define EDS_TEST_TEST_CASE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), EDS_TEST_TYPE_TEST_CASE, EdsTestTestCaseClass))
#define EDS_TEST_IS_TEST_CASE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EDS_TEST_TYPE_TEST_CASE))
#define EDS_TEST_IS_TEST_CASE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), EDS_TEST_TYPE_TEST_CASE))
#define EDS_TEST_TEST_CASE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), EDS_TEST_TYPE_TEST_CASE, EdsTestTestCaseClass))

typedef struct _EdsTestTestCase EdsTestTestCase;
typedef struct _EdsTestTestCaseClass EdsTestTestCaseClass;
typedef struct _EdsTestTestCasePrivate EdsTestTestCasePrivate;

#define EDS_TEST_TYPE_BACKEND (eds_test_backend_get_type ())
#define EDS_TEST_BACKEND(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EDS_TEST_TYPE_BACKEND, EdsTestBackend))
#define EDS_TEST_BACKEND_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), EDS_TEST_TYPE_BACKEND, EdsTestBackendClass))
#define EDS_TEST_IS_BACKEND(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EDS_TEST_TYPE_BACKEND))
#define EDS_TEST_IS_BACKEND_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), EDS_TEST_TYPE_BACKEND))
#define EDS_TEST_BACKEND_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), EDS_TEST_TYPE_BACKEND, EdsTestBackendClass))

typedef struct _EdsTestBackend EdsTestBackend;
typedef struct _EdsTestBackendClass EdsTestBackendClass;
#define _eds_test_backend_unref0(var) ((var == NULL) ? NULL : (var = (eds_test_backend_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))
#define _vala_assert(expr, msg) if G_LIKELY (expr) ; else g_assertion_message_expr (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, msg);

struct _EdsTestTestCase {
	FolksTestCase parent_instance;
	EdsTestTestCasePrivate * priv;
	EdsTestBackend* eds_backend;
};

struct _EdsTestTestCaseClass {
	FolksTestCaseClass parent_class;
	void (*create_backend) (EdsTestTestCase* self);
	void (*configure_primary_store) (EdsTestTestCase* self);
};


static gpointer eds_test_test_case_parent_class = NULL;

GType eds_test_test_case_get_type (void) G_GNUC_CONST;
gpointer eds_test_backend_ref (gpointer instance);
void eds_test_backend_unref (gpointer instance);
GParamSpec* eds_test_param_spec_backend (const gchar* name, const gchar* nick, const gchar* blurb, GType object_type, GParamFlags flags);
void eds_test_value_set_backend (GValue* value, gpointer v_object);
void eds_test_value_take_backend (GValue* value, gpointer v_object);
gpointer eds_test_value_get_backend (const GValue* value);
GType eds_test_backend_get_type (void) G_GNUC_CONST;
enum  {
	EDS_TEST_TEST_CASE_DUMMY_PROPERTY
};
EdsTestTestCase* eds_test_test_case_new (const gchar* name);
EdsTestTestCase* eds_test_test_case_construct (GType object_type, const gchar* name);
static gchar* eds_test_test_case_real_create_transient_dir (FolksTestCase* base);
static void eds_test_test_case_real_private_bus_up (FolksTestCase* base);
static void eds_test_test_case_real_set_up (FolksTestCase* base);
void eds_test_test_case_create_backend (EdsTestTestCase* self);
void eds_test_test_case_configure_primary_store (EdsTestTestCase* self);
static void eds_test_test_case_real_create_backend (EdsTestTestCase* self);
EdsTestBackend* eds_test_backend_new (void);
EdsTestBackend* eds_test_backend_construct (GType object_type);
void eds_test_backend_set_up (EdsTestBackend* self, gboolean source_is_default, const gchar* name);
static void eds_test_test_case_real_configure_primary_store (EdsTestTestCase* self);
const gchar* eds_test_backend_get_address_book_uid (EdsTestBackend* self);
static void eds_test_test_case_real_tear_down (FolksTestCase* base);
void eds_test_backend_tear_down (EdsTestBackend* self);
static void eds_test_test_case_finalize (GObject* obj);


EdsTestTestCase* eds_test_test_case_construct (GType object_type, const gchar* name) {
	EdsTestTestCase * self = NULL;
	const gchar* _tmp0_ = NULL;
	const gchar* _tmp1_ = NULL;
#line 43 "/home/treitter/collabora/folks/tests/lib/eds/test-case.vala"
	g_return_val_if_fail (name != NULL, NULL);
#line 48 "/home/treitter/collabora/folks/tests/lib/eds/test-case.vala"
	_tmp0_ = g_getenv ("FOLKS_TESTS_SANDBOXED_DBUS");
#line 48 "/home/treitter/collabora/folks/tests/lib/eds/test-case.vala"
	if (g_strcmp0 (_tmp0_, "eds") != 0) {
#line 50 "/home/treitter/collabora/folks/tests/lib/eds/test-case.vala"
		g_error ("test-case.vala:50: %s", "e-d-s tests must be run in a private D-Bus session " "with e-d-s services");
#line 116 "test-case.c"
	}
#line 53 "/home/treitter/collabora/folks/tests/lib/eds/test-case.vala"
	_tmp1_ = name;
#line 53 "/home/treitter/collabora/folks/tests/lib/eds/test-case.vala"
	self = (EdsTestTestCase*) folks_test_case_construct (object_type, _tmp1_);
#line 55 "/home/treitter/collabora/folks/tests/lib/eds/test-case.vala"
	g_setenv ("FOLKS_BACKENDS_ALLOWED", "eds", TRUE);
#line 56 "/home/treitter/collabora/folks/tests/lib/eds/test-case.vala"
	g_setenv ("FOLKS_PRIMARY_STORE", "eds:local://test", TRUE);
#line 43 "/home/treitter/collabora/folks/tests/lib/eds/test-case.vala"
	return self;
#line 128 "test-case.c"
}


EdsTestTestCase* eds_test_test_case_new (const gchar* name) {
#line 43 "/home/treitter/collabora/folks/tests/lib/eds/test-case.vala"
	return eds_test_test_case_construct (EDS_TEST_TYPE_TEST_CASE, name);
#line 135 "test-case.c"
}


static gchar* eds_test_test_case_real_create_transient_dir (FolksTestCase* base) {
	EdsTestTestCase * self;
	gchar* result = NULL;
#line 60 "/home/treitter/collabora/folks/tests/lib/eds/test-case.vala"
	self = (EdsTestTestCase*) base;
#line 64 "/home/treitter/collabora/folks/tests/lib/eds/test-case.vala"
	result = NULL;
#line 64 "/home/treitter/collabora/folks/tests/lib/eds/test-case.vala"
	return result;
#line 148 "test-case.c"
}


static void eds_test_test_case_real_private_bus_up (FolksTestCase* base) {
	EdsTestTestCase * self;
#line 67 "/home/treitter/collabora/folks/tests/lib/eds/test-case.vala"
	self = (EdsTestTestCase*) base;
#line 156 "test-case.c"
}


static void eds_test_test_case_real_set_up (FolksTestCase* base) {
	EdsTestTestCase * self;
#line 73 "/home/treitter/collabora/folks/tests/lib/eds/test-case.vala"
	self = (EdsTestTestCase*) base;
#line 75 "/home/treitter/collabora/folks/tests/lib/eds/test-case.vala"
	FOLKS_TEST_CASE_CLASS (eds_test_test_case_parent_class)->set_up (G_TYPE_CHECK_INSTANCE_CAST (self, FOLKS_TYPE_TEST_CASE, FolksTestCase));
#line 76 "/home/treitter/collabora/folks/tests/lib/eds/test-case.vala"
	eds_test_test_case_create_backend (self);
#line 77 "/home/treitter/collabora/folks/tests/lib/eds/test-case.vala"
	eds_test_test_case_configure_primary_store (self);
#line 170 "test-case.c"
}


/**
   * Virtual method to create and set up the EDS backend.
   * Called from set_up(); may be overridden to not create the backend,
   * or to create it but not set it up.
   *
   * Subclasses may chain up, but are not required to so.
   */
static void eds_test_test_case_real_create_backend (EdsTestTestCase* self) {
	EdsTestBackend* _tmp0_ = NULL;
	EdsTestBackend* _tmp1_ = NULL;
#line 89 "/home/treitter/collabora/folks/tests/lib/eds/test-case.vala"
	_tmp0_ = eds_test_backend_new ();
#line 89 "/home/treitter/collabora/folks/tests/lib/eds/test-case.vala"
	_eds_test_backend_unref0 (self->eds_backend);
#line 89 "/home/treitter/collabora/folks/tests/lib/eds/test-case.vala"
	self->eds_backend = _tmp0_;
#line 90 "/home/treitter/collabora/folks/tests/lib/eds/test-case.vala"
	_tmp1_ = self->eds_backend;
#line 90 "/home/treitter/collabora/folks/tests/lib/eds/test-case.vala"
	eds_test_backend_set_up (G_TYPE_CHECK_INSTANCE_CAST (_tmp1_, EDS_TEST_TYPE_BACKEND, EdsTestBackend), FALSE, "test");
#line 194 "test-case.c"
}


void eds_test_test_case_create_backend (EdsTestTestCase* self) {
#line 87 "/home/treitter/collabora/folks/tests/lib/eds/test-case.vala"
	g_return_if_fail (self != NULL);
#line 87 "/home/treitter/collabora/folks/tests/lib/eds/test-case.vala"
	EDS_TEST_TEST_CASE_GET_CLASS (self)->create_backend (self);
#line 203 "test-case.c"
}


/**
   * Virtual method to configure ``FOLKS_PRIMARY_STORE`` to point to
   * our //eds_backend//.
   *
   * Subclasses may chain up, but are not required to so.
   */
static void eds_test_test_case_real_configure_primary_store (EdsTestTestCase* self) {
	EdsTestBackend* _tmp0_ = NULL;
	gchar* config_val = NULL;
	EdsTestBackend* _tmp1_ = NULL;
	const gchar* _tmp2_ = NULL;
	const gchar* _tmp3_ = NULL;
	gchar* _tmp4_ = NULL;
#line 102 "/home/treitter/collabora/folks/tests/lib/eds/test-case.vala"
	_tmp0_ = self->eds_backend;
#line 102 "/home/treitter/collabora/folks/tests/lib/eds/test-case.vala"
	_vala_assert (_tmp0_ != NULL, "this.eds_backend != null");
#line 103 "/home/treitter/collabora/folks/tests/lib/eds/test-case.vala"
	_tmp1_ = self->eds_backend;
#line 103 "/home/treitter/collabora/folks/tests/lib/eds/test-case.vala"
	_tmp2_ = eds_test_backend_get_address_book_uid (G_TYPE_CHECK_INSTANCE_CAST (_tmp1_, EDS_TEST_TYPE_BACKEND, EdsTestBackend));
#line 103 "/home/treitter/collabora/folks/tests/lib/eds/test-case.vala"
	_tmp3_ = _tmp2_;
#line 103 "/home/treitter/collabora/folks/tests/lib/eds/test-case.vala"
	_tmp4_ = g_strconcat ("eds:", _tmp3_, NULL);
#line 103 "/home/treitter/collabora/folks/tests/lib/eds/test-case.vala"
	config_val = _tmp4_;
#line 104 "/home/treitter/collabora/folks/tests/lib/eds/test-case.vala"
	g_setenv ("FOLKS_PRIMARY_STORE", config_val, TRUE);
#line 99 "/home/treitter/collabora/folks/tests/lib/eds/test-case.vala"
	_g_free0 (config_val);
#line 238 "test-case.c"
}


void eds_test_test_case_configure_primary_store (EdsTestTestCase* self) {
#line 99 "/home/treitter/collabora/folks/tests/lib/eds/test-case.vala"
	g_return_if_fail (self != NULL);
#line 99 "/home/treitter/collabora/folks/tests/lib/eds/test-case.vala"
	EDS_TEST_TEST_CASE_GET_CLASS (self)->configure_primary_store (self);
#line 247 "test-case.c"
}


static void eds_test_test_case_real_tear_down (FolksTestCase* base) {
	EdsTestTestCase * self;
	EdsTestBackend* _tmp0_ = NULL;
#line 107 "/home/treitter/collabora/folks/tests/lib/eds/test-case.vala"
	self = (EdsTestTestCase*) base;
#line 109 "/home/treitter/collabora/folks/tests/lib/eds/test-case.vala"
	_tmp0_ = self->eds_backend;
#line 109 "/home/treitter/collabora/folks/tests/lib/eds/test-case.vala"
	if (_tmp0_ != NULL) {
#line 260 "test-case.c"
		EdsTestBackend* _tmp1_ = NULL;
#line 111 "/home/treitter/collabora/folks/tests/lib/eds/test-case.vala"
		_tmp1_ = self->eds_backend;
#line 111 "/home/treitter/collabora/folks/tests/lib/eds/test-case.vala"
		eds_test_backend_tear_down (G_TYPE_CHECK_INSTANCE_CAST (_tmp1_, EDS_TEST_TYPE_BACKEND, EdsTestBackend));
#line 112 "/home/treitter/collabora/folks/tests/lib/eds/test-case.vala"
		_eds_test_backend_unref0 (self->eds_backend);
#line 112 "/home/treitter/collabora/folks/tests/lib/eds/test-case.vala"
		self->eds_backend = NULL;
#line 270 "test-case.c"
	}
#line 115 "/home/treitter/collabora/folks/tests/lib/eds/test-case.vala"
	g_unsetenv ("FOLKS_PRIMARY_STORE");
#line 117 "/home/treitter/collabora/folks/tests/lib/eds/test-case.vala"
	FOLKS_TEST_CASE_CLASS (eds_test_test_case_parent_class)->tear_down (G_TYPE_CHECK_INSTANCE_CAST (self, FOLKS_TYPE_TEST_CASE, FolksTestCase));
#line 276 "test-case.c"
}


static void eds_test_test_case_class_init (EdsTestTestCaseClass * klass) {
#line 32 "/home/treitter/collabora/folks/tests/lib/eds/test-case.vala"
	eds_test_test_case_parent_class = g_type_class_peek_parent (klass);
#line 32 "/home/treitter/collabora/folks/tests/lib/eds/test-case.vala"
	FOLKS_TEST_CASE_CLASS (klass)->create_transient_dir = eds_test_test_case_real_create_transient_dir;
#line 32 "/home/treitter/collabora/folks/tests/lib/eds/test-case.vala"
	FOLKS_TEST_CASE_CLASS (klass)->private_bus_up = eds_test_test_case_real_private_bus_up;
#line 32 "/home/treitter/collabora/folks/tests/lib/eds/test-case.vala"
	FOLKS_TEST_CASE_CLASS (klass)->set_up = eds_test_test_case_real_set_up;
#line 32 "/home/treitter/collabora/folks/tests/lib/eds/test-case.vala"
	EDS_TEST_TEST_CASE_CLASS (klass)->create_backend = eds_test_test_case_real_create_backend;
#line 32 "/home/treitter/collabora/folks/tests/lib/eds/test-case.vala"
	EDS_TEST_TEST_CASE_CLASS (klass)->configure_primary_store = eds_test_test_case_real_configure_primary_store;
#line 32 "/home/treitter/collabora/folks/tests/lib/eds/test-case.vala"
	FOLKS_TEST_CASE_CLASS (klass)->tear_down = eds_test_test_case_real_tear_down;
#line 32 "/home/treitter/collabora/folks/tests/lib/eds/test-case.vala"
	G_OBJECT_CLASS (klass)->finalize = eds_test_test_case_finalize;
#line 297 "test-case.c"
}


static void eds_test_test_case_instance_init (EdsTestTestCase * self) {
#line 41 "/home/treitter/collabora/folks/tests/lib/eds/test-case.vala"
	self->eds_backend = NULL;
#line 304 "test-case.c"
}


static void eds_test_test_case_finalize (GObject* obj) {
	EdsTestTestCase * self;
#line 32 "/home/treitter/collabora/folks/tests/lib/eds/test-case.vala"
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, EDS_TEST_TYPE_TEST_CASE, EdsTestTestCase);
#line 41 "/home/treitter/collabora/folks/tests/lib/eds/test-case.vala"
	_eds_test_backend_unref0 (self->eds_backend);
#line 32 "/home/treitter/collabora/folks/tests/lib/eds/test-case.vala"
	G_OBJECT_CLASS (eds_test_test_case_parent_class)->finalize (obj);
#line 316 "test-case.c"
}


/**
 * A test case whose private D-Bus session contains the necessary daemons
 * for an Evolution address-book.
 *
 * FIXME: For now, this relies on running under with-session-bus-eds.sh
 * with FOLKS_BACKEND_PATH set.
 */
GType eds_test_test_case_get_type (void) {
	static volatile gsize eds_test_test_case_type_id__volatile = 0;
	if (g_once_init_enter (&eds_test_test_case_type_id__volatile)) {
		static const GTypeInfo g_define_type_info = { sizeof (EdsTestTestCaseClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) eds_test_test_case_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (EdsTestTestCase), 0, (GInstanceInitFunc) eds_test_test_case_instance_init, NULL };
		GType eds_test_test_case_type_id;
		eds_test_test_case_type_id = g_type_register_static (FOLKS_TYPE_TEST_CASE, "EdsTestTestCase", &g_define_type_info, 0);
		g_once_init_leave (&eds_test_test_case_type_id__volatile, eds_test_test_case_type_id);
	}
	return eds_test_test_case_type_id__volatile;
}



