/* 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 © 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:
 *      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 TRACKER_TEST_TYPE_TEST_CASE (tracker_test_test_case_get_type ())
#define TRACKER_TEST_TEST_CASE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TRACKER_TEST_TYPE_TEST_CASE, TrackerTestTestCase))
#define TRACKER_TEST_TEST_CASE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TRACKER_TEST_TYPE_TEST_CASE, TrackerTestTestCaseClass))
#define TRACKER_TEST_IS_TEST_CASE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TRACKER_TEST_TYPE_TEST_CASE))
#define TRACKER_TEST_IS_TEST_CASE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TRACKER_TEST_TYPE_TEST_CASE))
#define TRACKER_TEST_TEST_CASE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TRACKER_TEST_TYPE_TEST_CASE, TrackerTestTestCaseClass))

typedef struct _TrackerTestTestCase TrackerTestTestCase;
typedef struct _TrackerTestTestCaseClass TrackerTestTestCaseClass;
typedef struct _TrackerTestTestCasePrivate TrackerTestTestCasePrivate;

#define TRACKER_TEST_TYPE_BACKEND (tracker_test_backend_get_type ())
#define TRACKER_TEST_BACKEND(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TRACKER_TEST_TYPE_BACKEND, TrackerTestBackend))
#define TRACKER_TEST_BACKEND_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TRACKER_TEST_TYPE_BACKEND, TrackerTestBackendClass))
#define TRACKER_TEST_IS_BACKEND(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TRACKER_TEST_TYPE_BACKEND))
#define TRACKER_TEST_IS_BACKEND_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TRACKER_TEST_TYPE_BACKEND))
#define TRACKER_TEST_BACKEND_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TRACKER_TEST_TYPE_BACKEND, TrackerTestBackendClass))

typedef struct _TrackerTestBackend TrackerTestBackend;
typedef struct _TrackerTestBackendClass TrackerTestBackendClass;
#define _tracker_test_backend_unref0(var) ((var == NULL) ? NULL : (var = (tracker_test_backend_unref (var), NULL)))

struct _TrackerTestTestCase {
	FolksTestCase parent_instance;
	TrackerTestTestCasePrivate * priv;
	TrackerTestBackend* tracker_backend;
};

struct _TrackerTestTestCaseClass {
	FolksTestCaseClass parent_class;
};


static gpointer tracker_test_test_case_parent_class = NULL;

GType tracker_test_test_case_get_type (void) G_GNUC_CONST;
gpointer tracker_test_backend_ref (gpointer instance);
void tracker_test_backend_unref (gpointer instance);
GParamSpec* tracker_test_param_spec_backend (const gchar* name, const gchar* nick, const gchar* blurb, GType object_type, GParamFlags flags);
void tracker_test_value_set_backend (GValue* value, gpointer v_object);
void tracker_test_value_take_backend (GValue* value, gpointer v_object);
gpointer tracker_test_value_get_backend (const GValue* value);
GType tracker_test_backend_get_type (void) G_GNUC_CONST;
enum  {
	TRACKER_TEST_TEST_CASE_DUMMY_PROPERTY
};
TrackerTestTestCase* tracker_test_test_case_new (const gchar* name);
TrackerTestTestCase* tracker_test_test_case_construct (GType object_type, const gchar* name);
TrackerTestBackend* tracker_test_backend_new (void);
TrackerTestBackend* tracker_test_backend_construct (GType object_type);
static gchar* tracker_test_test_case_real_create_transient_dir (FolksTestCase* base);
static void tracker_test_test_case_real_private_bus_up (FolksTestCase* base);
static void tracker_test_test_case_real_tear_down (FolksTestCase* base);
void tracker_test_backend_tear_down (TrackerTestBackend* self);
static void tracker_test_test_case_finalize (GObject* obj);


/**
   * Set environment variables and create the tracker backend.
   *
   * FIXME: maybe it shouldn't be created until set_up()? (Tests
   * will need to be checked to make sure that's OK.)
   */
TrackerTestTestCase* tracker_test_test_case_construct (GType object_type, const gchar* name) {
	TrackerTestTestCase * self = NULL;
	const gchar* _tmp0_ = NULL;
	const gchar* _tmp1_ = NULL;
	TrackerTestBackend* _tmp2_ = NULL;
#line 48 "/home/treitter/collabora/folks/tests/lib/tracker/test-case.vala"
	g_return_val_if_fail (name != NULL, NULL);
#line 53 "/home/treitter/collabora/folks/tests/lib/tracker/test-case.vala"
	_tmp0_ = g_getenv ("FOLKS_TESTS_SANDBOXED_DBUS");
#line 53 "/home/treitter/collabora/folks/tests/lib/tracker/test-case.vala"
	if (g_strcmp0 (_tmp0_, "tracker") != 0) {
#line 55 "/home/treitter/collabora/folks/tests/lib/tracker/test-case.vala"
		g_error ("test-case.vala:55: %s", "Tracker tests must be run in a private D-Bus session " "with Tracker services");
#line 110 "test-case.c"
	}
#line 58 "/home/treitter/collabora/folks/tests/lib/tracker/test-case.vala"
	_tmp1_ = name;
#line 58 "/home/treitter/collabora/folks/tests/lib/tracker/test-case.vala"
	self = (TrackerTestTestCase*) folks_test_case_construct (object_type, _tmp1_);
#line 60 "/home/treitter/collabora/folks/tests/lib/tracker/test-case.vala"
	g_setenv ("FOLKS_BACKENDS_ALLOWED", "tracker", TRUE);
#line 61 "/home/treitter/collabora/folks/tests/lib/tracker/test-case.vala"
	g_setenv ("FOLKS_PRIMARY_STORE", "tracker", TRUE);
#line 63 "/home/treitter/collabora/folks/tests/lib/tracker/test-case.vala"
	_tmp2_ = tracker_test_backend_new ();
#line 63 "/home/treitter/collabora/folks/tests/lib/tracker/test-case.vala"
	_tracker_test_backend_unref0 (self->tracker_backend);
#line 63 "/home/treitter/collabora/folks/tests/lib/tracker/test-case.vala"
	self->tracker_backend = _tmp2_;
#line 48 "/home/treitter/collabora/folks/tests/lib/tracker/test-case.vala"
	return self;
#line 128 "test-case.c"
}


TrackerTestTestCase* tracker_test_test_case_new (const gchar* name) {
#line 48 "/home/treitter/collabora/folks/tests/lib/tracker/test-case.vala"
	return tracker_test_test_case_construct (TRACKER_TEST_TYPE_TEST_CASE, name);
#line 135 "test-case.c"
}


static gchar* tracker_test_test_case_real_create_transient_dir (FolksTestCase* base) {
	TrackerTestTestCase * self;
	gchar* result = NULL;
#line 66 "/home/treitter/collabora/folks/tests/lib/tracker/test-case.vala"
	self = (TrackerTestTestCase*) base;
#line 70 "/home/treitter/collabora/folks/tests/lib/tracker/test-case.vala"
	result = NULL;
#line 70 "/home/treitter/collabora/folks/tests/lib/tracker/test-case.vala"
	return result;
#line 148 "test-case.c"
}


static void tracker_test_test_case_real_private_bus_up (FolksTestCase* base) {
	TrackerTestTestCase * self;
#line 73 "/home/treitter/collabora/folks/tests/lib/tracker/test-case.vala"
	self = (TrackerTestTestCase*) base;
#line 156 "test-case.c"
}


static void tracker_test_test_case_real_tear_down (FolksTestCase* base) {
	TrackerTestTestCase * self;
	TrackerTestBackend* _tmp0_ = NULL;
#line 79 "/home/treitter/collabora/folks/tests/lib/tracker/test-case.vala"
	self = (TrackerTestTestCase*) base;
#line 81 "/home/treitter/collabora/folks/tests/lib/tracker/test-case.vala"
	_tmp0_ = self->tracker_backend;
#line 81 "/home/treitter/collabora/folks/tests/lib/tracker/test-case.vala"
	if (_tmp0_ != NULL) {
#line 169 "test-case.c"
		TrackerTestBackend* _tmp1_ = NULL;
#line 83 "/home/treitter/collabora/folks/tests/lib/tracker/test-case.vala"
		_tmp1_ = self->tracker_backend;
#line 83 "/home/treitter/collabora/folks/tests/lib/tracker/test-case.vala"
		tracker_test_backend_tear_down (G_TYPE_CHECK_INSTANCE_CAST (_tmp1_, TRACKER_TEST_TYPE_BACKEND, TrackerTestBackend));
#line 175 "test-case.c"
	}
#line 86 "/home/treitter/collabora/folks/tests/lib/tracker/test-case.vala"
	FOLKS_TEST_CASE_CLASS (tracker_test_test_case_parent_class)->tear_down (G_TYPE_CHECK_INSTANCE_CAST (self, FOLKS_TYPE_TEST_CASE, FolksTestCase));
#line 179 "test-case.c"
}


static void tracker_test_test_case_class_init (TrackerTestTestCaseClass * klass) {
#line 32 "/home/treitter/collabora/folks/tests/lib/tracker/test-case.vala"
	tracker_test_test_case_parent_class = g_type_class_peek_parent (klass);
#line 32 "/home/treitter/collabora/folks/tests/lib/tracker/test-case.vala"
	FOLKS_TEST_CASE_CLASS (klass)->create_transient_dir = tracker_test_test_case_real_create_transient_dir;
#line 32 "/home/treitter/collabora/folks/tests/lib/tracker/test-case.vala"
	FOLKS_TEST_CASE_CLASS (klass)->private_bus_up = tracker_test_test_case_real_private_bus_up;
#line 32 "/home/treitter/collabora/folks/tests/lib/tracker/test-case.vala"
	FOLKS_TEST_CASE_CLASS (klass)->tear_down = tracker_test_test_case_real_tear_down;
#line 32 "/home/treitter/collabora/folks/tests/lib/tracker/test-case.vala"
	G_OBJECT_CLASS (klass)->finalize = tracker_test_test_case_finalize;
#line 194 "test-case.c"
}


static void tracker_test_test_case_instance_init (TrackerTestTestCase * self) {
#line 40 "/home/treitter/collabora/folks/tests/lib/tracker/test-case.vala"
	self->tracker_backend = NULL;
#line 201 "test-case.c"
}


static void tracker_test_test_case_finalize (GObject* obj) {
	TrackerTestTestCase * self;
#line 32 "/home/treitter/collabora/folks/tests/lib/tracker/test-case.vala"
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TRACKER_TEST_TYPE_TEST_CASE, TrackerTestTestCase);
#line 40 "/home/treitter/collabora/folks/tests/lib/tracker/test-case.vala"
	_tracker_test_backend_unref0 (self->tracker_backend);
#line 32 "/home/treitter/collabora/folks/tests/lib/tracker/test-case.vala"
	G_OBJECT_CLASS (tracker_test_test_case_parent_class)->finalize (obj);
#line 213 "test-case.c"
}


/**
 * A test case for the Tracker backend.
 *
 * Folks is configured to use the Tracker backend as primary store,
 * and no other backends.
 *
 * FIXME: For now, this relies on running under with-session-bus-tracker.sh
 * with FOLKS_BACKEND_PATH set.
 */
GType tracker_test_test_case_get_type (void) {
	static volatile gsize tracker_test_test_case_type_id__volatile = 0;
	if (g_once_init_enter (&tracker_test_test_case_type_id__volatile)) {
		static const GTypeInfo g_define_type_info = { sizeof (TrackerTestTestCaseClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) tracker_test_test_case_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (TrackerTestTestCase), 0, (GInstanceInitFunc) tracker_test_test_case_instance_init, NULL };
		GType tracker_test_test_case_type_id;
		tracker_test_test_case_type_id = g_type_register_static (FOLKS_TYPE_TEST_CASE, "TrackerTestTestCase", &g_define_type_info, 0);
		g_once_init_leave (&tracker_test_test_case_type_id__volatile, tracker_test_test_case_type_id);
	}
	return tracker_test_test_case_type_id__volatile;
}



