WIP more fixes for vala, try out js

This commit is contained in:
Stef Walter 2012-07-13 09:35:26 +02:00
parent 9bf4efd762
commit c4549d6c8d
6 changed files with 172 additions and 15 deletions

View File

@ -1,2 +1,5 @@
// Metadata file for Vala API generation. // Metadata file for Vala API generation.
// See https://live.gnome.org/Vala/UpstreamGuide for more information // See https://live.gnome.org/Vala/UpstreamGuide for more information
// include in the same Secret namespace
* parent="Secret"

View File

@ -25,7 +25,7 @@
#include "secret-types.h" #include "secret-types.h"
/* This symbol is defined by the secret-unstable.pc pkg-config file */ /* 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 #ifndef SECRET_API_SUBJECT_TO_CHANGE
#warning "This API has not yet reached stability. Define SECRET_API_SUBJECT_TO_CHANGE to acknowledge" #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-service.h"
#include "secret-value.h" #include "secret-value.h"
#endif /* SECRET_WITH_UNSTABLE */ #endif /* SECRET_WITH_UNSTABLE || SECRET_API_SUBJECT_TO_CHANGE */
#undef __SECRET_INSIDE_HEADER__ #undef __SECRET_INSIDE_HEADER__

View File

@ -56,7 +56,8 @@ noinst_PROGRAMS = \
JS_TESTS = \ JS_TESTS = \
test-lookup-password.js \ test-lookup-password.js \
test-remove-password.js \ test-remove-password.js \
test-store-password.js test-store-password.js \
test-unstable.js
JS_ENV = \ JS_ENV = \
LD_LIBRARY_PATH=$(builddir)/../.libs:$(builddir)/.libs \ 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_PROGS += $(VALA_TESTS)
test_vala_lang_CFLAGS = -w 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) test-vala: $(VALA_TESTS)
@gtester --verbose -m $(TEST_MODE) --g-fatal-warnings $(VALA_TESTS) @gtester --verbose -m $(TEST_MODE) --g-fatal-warnings $(VALA_TESTS)
@ -154,7 +158,7 @@ noinst_DATA = \
if ENABLE_VAPIGEN if ENABLE_VAPIGEN
include $(VAPIGEN_MAKEFILE) 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 VAPIGEN_VAPIS = mock-service-0.vapi

View File

@ -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();

View File

@ -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);
}

View File

@ -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) { private static int main (string[] args) {
GLib.Test.init (ref args); GLib.Test.init (ref args);
var service = SecretUnstable.Service.get_sync(SecretUnstable.ServiceFlags.NONE); try {
var path = service.read_alias_dbus_path_sync("default", null); MockService.start ("mock-service-normal.py");
} catch ( GLib.Error e ) {
/* Just running is enough for us */ GLib.error ("Unable to start mock service: %s", e.message);
if (GLib.Test.verbose()) }
stderr.printf("Vala unstable got default path: %s\n", path);
return 0; GLib.Test.add_data_func ("/vala/unstable/read-alias", test_read_alias);
var res = GLib.Test.run ();
MockService.stop ();
return res;
} }