summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStef Walter <stefw@gnome.org>2012-07-13 09:35:26 +0200
committerStef Walter <stefw@gnome.org>2012-07-13 09:35:26 +0200
commitc4549d6c8d629485e2cebca39e126b979833c14a (patch)
tree437aea3ce9d84c3c91bcfc5416249e9ed326a04c
parent9bf4efd762a4a59027c312d861f04f62944270b1 (diff)
downloadlibsecret-wip/unstable.tar.gz
WIP more fixes for vala, try out jswip/unstable
-rw-r--r--library/SecretUnstable.metadata3
-rw-r--r--library/secret.h4
-rw-r--r--library/tests/Makefile.am10
-rw-r--r--library/tests/test-unstable.js17
-rw-r--r--library/tests/test-vala-unstable.c119
-rw-r--r--library/tests/test-vala-unstable.vala28
6 files changed, 169 insertions, 12 deletions
diff --git a/library/SecretUnstable.metadata b/library/SecretUnstable.metadata
index b175213..a54b215 100644
--- a/library/SecretUnstable.metadata
+++ b/library/SecretUnstable.metadata
@@ -1,2 +1,5 @@
// Metadata file for Vala API generation.
// See https://live.gnome.org/Vala/UpstreamGuide for more information
+
+// include in the same Secret namespace
+* parent="Secret" \ No newline at end of file
diff --git a/library/secret.h b/library/secret.h
index db7e66e..5fa93d4 100644
--- a/library/secret.h
+++ b/library/secret.h
@@ -25,7 +25,7 @@
#include "secret-types.h"
/* This symbol is defined by the secret-unstable.pc pkg-config file */
-#ifdef SECRET_WITH_UNSTABLE
+#if defined(SECRET_WITH_UNSTABLE) || defined(SECRET_API_SUBJECT_TO_CHANGE)
#ifndef SECRET_API_SUBJECT_TO_CHANGE
#warning "This API has not yet reached stability. Define SECRET_API_SUBJECT_TO_CHANGE to acknowledge"
@@ -40,7 +40,7 @@
#include "secret-service.h"
#include "secret-value.h"
-#endif /* SECRET_WITH_UNSTABLE */
+#endif /* SECRET_WITH_UNSTABLE || SECRET_API_SUBJECT_TO_CHANGE */
#undef __SECRET_INSIDE_HEADER__
diff --git a/library/tests/Makefile.am b/library/tests/Makefile.am
index 0d04964..209ed3a 100644
--- a/library/tests/Makefile.am
+++ b/library/tests/Makefile.am
@@ -56,7 +56,8 @@ noinst_PROGRAMS = \
JS_TESTS = \
test-lookup-password.js \
test-remove-password.js \
- test-store-password.js
+ test-store-password.js \
+ test-unstable.js
JS_ENV = \
LD_LIBRARY_PATH=$(builddir)/../.libs:$(builddir)/.libs \
@@ -103,8 +104,11 @@ test-vala-unstable.c: test-vala-unstable.vala $(VALA_TESTS_VAPIS)
TEST_PROGS += $(VALA_TESTS)
test_vala_lang_CFLAGS = -w
+test_vala_unstable_CFLAGS = -DSECRET_WITH_UNSTABLE -w
-DISTCLEANFILES = test-vala-lang.c
+DISTCLEANFILES = \
+ test-vala-lang.c \
+ test-vala-unstable.c
test-vala: $(VALA_TESTS)
@gtester --verbose -m $(TEST_MODE) --g-fatal-warnings $(VALA_TESTS)
@@ -154,7 +158,7 @@ noinst_DATA = \
if ENABLE_VAPIGEN
include $(VAPIGEN_MAKEFILE)
-mock-service-0.vapi: MockService-0.gir libsecret-@SECRET_MAJOR@.vapi
+mock-service-0.vapi: MockService-0.gir $(builddir)/../libsecret-@SECRET_MAJOR@.vapi
VAPIGEN_VAPIS = mock-service-0.vapi
diff --git a/library/tests/test-unstable.js b/library/tests/test-unstable.js
new file mode 100644
index 0000000..7a20d74
--- /dev/null
+++ b/library/tests/test-unstable.js
@@ -0,0 +1,17 @@
+
+const Mock = imports.gi.MockService;
+const Secret = imports.gi.SecretUnstable;
+const GLib = imports.gi.GLib;
+
+const JsUnit = imports.jsUnit;
+const assertNotEquals = JsUnit.assertNotEquals;
+
+Mock.start("mock-service-normal.py");
+
+var service = SecretUnstable.Service.get_sync(SecretUnstable.ServiceFlags.NONE);
+var path = service.read_alias_dbus_path_sync("default", null);
+
+/* Just running this without error is good enough for us to test the unstable gir */
+assertNotEquals(path, null);
+
+Mock.stop();
diff --git a/library/tests/test-vala-unstable.c b/library/tests/test-vala-unstable.c
new file mode 100644
index 0000000..52de896
--- /dev/null
+++ b/library/tests/test-vala-unstable.c
@@ -0,0 +1,119 @@
+/* test-vala-unstable.c generated by valac 0.17.2.18-57ff, the Vala compiler
+ * generated from test-vala-unstable.vala, do not modify */
+
+
+#include <glib.h>
+#include <glib-object.h>
+#include "secret.h"
+#include <stdlib.h>
+#include <string.h>
+#include "mock-service.h"
+
+#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
+#define _g_free0(var) (var = (g_free (var), NULL))
+#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_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);
+
+
+
+void test_read_alias (void);
+gint _vala_main (gchar** args, int args_length1);
+static void _test_read_alias_gtest_data_func (gpointer self);
+
+
+void test_read_alias (void) {
+ GError * _inner_error_ = NULL;
+ {
+ SecretService* _tmp0_ = NULL;
+ SecretService* service;
+ SecretService* _tmp1_;
+ gchar* _tmp2_ = NULL;
+ gchar* path;
+ const gchar* _tmp3_;
+ _tmp0_ = secret_service_get_sync (SECRET_SERVICE_NONE, NULL, &_inner_error_);
+ service = _tmp0_;
+ if (_inner_error_ != NULL) {
+ goto __catch0_g_error;
+ }
+ _tmp1_ = service;
+ _tmp2_ = secret_service_read_alias_dbus_path_sync (_tmp1_, "default", NULL, &_inner_error_);
+ path = _tmp2_;
+ if (_inner_error_ != NULL) {
+ _g_object_unref0 (service);
+ goto __catch0_g_error;
+ }
+ _tmp3_ = path;
+ _vala_assert (_tmp3_ != NULL, "path != null");
+ _g_free0 (path);
+ _g_object_unref0 (service);
+ }
+ goto __finally0;
+ __catch0_g_error:
+ {
+ GError* e = NULL;
+ const gchar* _tmp4_;
+ e = _inner_error_;
+ _inner_error_ = NULL;
+ _tmp4_ = e->message;
+ g_error ("test-vala-unstable.vala:7: %s", _tmp4_);
+ _g_error_free0 (e);
+ }
+ __finally0:
+ if (_inner_error_ != NULL) {
+ g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
+ g_clear_error (&_inner_error_);
+ return;
+ }
+}
+
+
+static void _test_read_alias_gtest_data_func (gpointer self) {
+ test_read_alias ();
+}
+
+
+gint _vala_main (gchar** args, int args_length1) {
+ gint result = 0;
+ gint _tmp1_ = 0;
+ gint res;
+ GError * _inner_error_ = NULL;
+ g_test_init (&args_length1, &args, NULL);
+ {
+ mock_service_start ("mock-service-normal.py", &_inner_error_);
+ if (_inner_error_ != NULL) {
+ goto __catch1_g_error;
+ }
+ }
+ goto __finally1;
+ __catch1_g_error:
+ {
+ GError* e = NULL;
+ const gchar* _tmp0_;
+ e = _inner_error_;
+ _inner_error_ = NULL;
+ _tmp0_ = e->message;
+ g_error ("test-vala-unstable.vala:17: Unable to start mock service: %s", _tmp0_);
+ _g_error_free0 (e);
+ }
+ __finally1:
+ if (_inner_error_ != NULL) {
+ g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
+ g_clear_error (&_inner_error_);
+ return 0;
+ }
+ g_test_add_data_func ("/vala/unstable/read-alias", NULL, _test_read_alias_gtest_data_func);
+ _tmp1_ = g_test_run ();
+ res = _tmp1_;
+ mock_service_stop ();
+ result = res;
+ return result;
+}
+
+
+int main (int argc, char ** argv) {
+ g_type_init ();
+ return _vala_main (argv, argc);
+}
+
+
+
diff --git a/library/tests/test-vala-unstable.vala b/library/tests/test-vala-unstable.vala
index 390d75d..ac28ce5 100644
--- a/library/tests/test-vala-unstable.vala
+++ b/library/tests/test-vala-unstable.vala
@@ -1,11 +1,25 @@
+private void test_read_alias () {
+ try {
+ var service = Secret.Service.get_sync(Secret.ServiceFlags.NONE);
+ var path = service.read_alias_dbus_path_sync("default", null);
+ GLib.assert (path != null);
+ } catch ( GLib.Error e ) {
+ GLib.error (e.message);
+ }
+}
+
private static int main (string[] args) {
- GLib.Test.init (ref args);
+ GLib.Test.init (ref args);
+
+ try {
+ MockService.start ("mock-service-normal.py");
+ } catch ( GLib.Error e ) {
+ GLib.error ("Unable to start mock service: %s", e.message);
+ }
- var service = SecretUnstable.Service.get_sync(SecretUnstable.ServiceFlags.NONE);
- var path = service.read_alias_dbus_path_sync("default", null);
+ GLib.Test.add_data_func ("/vala/unstable/read-alias", test_read_alias);
- /* Just running is enough for us */
- if (GLib.Test.verbose())
- stderr.printf("Vala unstable got default path: %s\n", path);
- return 0;
+ var res = GLib.Test.run ();
+ MockService.stop ();
+ return res;
}