-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathnodegsettings_tests.js
99 lines (82 loc) · 2.94 KB
/
nodegsettings_tests.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
/*
* GPII Node.js GSettings Bridge
*
* Copyright 2012 Steven Githens
*
* Licensed under the New BSD license. You may not use this file except in
* compliance with this License.
*
* The research leading to these results has received funding from the European Union's
* Seventh Framework Programme (FP7/2007-2013)
* under grant agreement no. 289016.
*
* You may obtain a copy of the License at
* https://github.com/GPII/universal/blob/master/LICENSE.txt
*/
"use strict";
var util = require("util");
var assert = require("assert");
var gsettings = require("./build/Release/nodegsettings.node");
/* Common variables for all tests */
var keyScreenmag = "org.gnome.desktop.a11y.magnifier";
/* Test getting and setting boolean values */
var testBooleanValues = function () {
var ret = gsettings.set_gsetting(keyScreenmag, "show-cross-hairs", true);
assert.ok(ret);
ret = gsettings.set_gsetting(keyScreenmag, "show-cross-hairs", false);
assert.ok(ret);
// Todo need to set up an event for these assertions, they run too fast,
// and get the old value from gsettings before it's propagated.
// exec('gsettings get '+keyScreenmag+' show-cross-hairs', function(res, out, err) {
// testBooleanValuesCallback1 = true;
// assert.equal('true\n', out);
// });
// exec('gsettings get '+keyScreenmag+' show-cross-hairs', function(res, out, err) {
// testBooleanValuesCallback2 = true;
// assert.equal('false\n', out);
// });
};
var testDecimalValues = function () {
var ret = gsettings.set_gsetting(keyScreenmag, "mag-factor", 3.0);
assert.ok(ret);
var ret2 = gsettings.set_gsetting(keyScreenmag, "mag-factor", 5.3);
assert.ok(ret2);
};
var testStringToEnumValues = function () {
var ret = gsettings.set_gsetting(keyScreenmag, "screen-position", "left-half");
assert.ok(ret);
};
var testIntegerValues = function () {
var ret = gsettings.set_gsetting(keyScreenmag, "cross-hairs-thickness", 7);
assert.ok(ret);
};
/* Test Reading Values */
var testReadingDoubleValues = function () {
var ret = gsettings.get_gsetting(keyScreenmag, "mag-factor");
util.puts("The mag-factor is: " + ret);
};
var testReadingIntegerValues = function () {
var ret = gsettings.get_gsetting(keyScreenmag, "cross-hairs-thickness");
util.puts("The cross hairs thickness is: " + ret);
};
var testReadingStringValues = function () {
var ret = gsettings.get_gsetting(keyScreenmag, "screen-position");
util.puts("The screen-position is: " + ret);
};
var testStuff = function () {
util.puts("Testing Stuff");
var keys = gsettings.get_gsetting_keys(keyScreenmag);
for (var i = 0; i < keys.length; i++) {
util.puts("Ok: " + keys[i]);
}
util.puts("Done Testing Stuff");
};
testStuff();
/* Run test functions */
testBooleanValues();
testDecimalValues();
testStringToEnumValues();
testIntegerValues();
testReadingDoubleValues();
testReadingIntegerValues();
testReadingStringValues();