break;
case DBUS_TYPE_BOOLEAN:
- /* Any non-nil object will be regarded as `t', so we don't apply
- further type check. */
+ /* There must be an argument. */
+ if (EQ (QCboolean, object))
+ wrong_type_argument (intern ("booleanp"), object);
sprintf (signature, "%c", dtype);
break;
case DBUS_TYPE_STRING:
case DBUS_TYPE_OBJECT_PATH:
case DBUS_TYPE_SIGNATURE:
+ /* We dont check the syntax of object path and signature. This
+ will be done by libdbus. */
CHECK_STRING (object);
sprintf (signature, "%c", dtype);
break;
}
case DBUS_TYPE_BOOLEAN:
+ /* There must be an argument. */
+ if (EQ (QCboolean, object))
+ wrong_type_argument (intern ("booleanp"), object);
{
dbus_bool_t val = (NILP (object)) ? FALSE : TRUE;
XD_DEBUG_MESSAGE ("%c %s", dtype, (val == FALSE) ? "false" : "true");
case DBUS_TYPE_STRING:
case DBUS_TYPE_OBJECT_PATH:
case DBUS_TYPE_SIGNATURE:
+ /* We dont check the syntax of object path and signature.
+ This will be done by libdbus. */
CHECK_STRING (object);
{
/* We need to send a valid UTF-8 string. We could encode `object'
In the first case, the key in the hash table is the list (TYPE BUS
INTERFACE MEMBER). TYPE is one of the Lisp symbols `:method',
-`:signal' or `:property'. BUS is either a Lisp symbol, `:system' or
-`:session', or a string denoting the bus address. INTERFACE is a
-string which denotes a D-Bus interface, and MEMBER, also a string, is
-either a method, a signal or a property INTERFACE is offering. All
-arguments but BUS must not be nil.
+`:signal', `:property' or `:monitor'. BUS is either a Lisp symbol,
+`:system', `:session', `:system-private' or `:session-private', or a
+string denoting the bus address. INTERFACE is a string which denotes
+a D-Bus interface, and MEMBER, also a string, is either a method, a
+signal or a property INTERFACE is offering. All arguments can be nil.
The value in the hash table is a list of quadruple lists ((UNAME
SERVICE PATH OBJECT [RULE]) ...). SERVICE is the service name as
"Check basic D-Bus type arguments."
(skip-unless dbus--test-enabled-session-bus)
- ;; Unknown keyword.
+ ;; No argument or unknown keyword.
+ (should-error
+ (dbus-check-arguments :session dbus--test-service)
+ :type 'wrong-number-of-arguments)
(should-error
(dbus-check-arguments :session dbus--test-service :keyword)
:type 'wrong-type-argument)
;; `:string'.
(should (dbus-check-arguments :session dbus--test-service "string"))
(should (dbus-check-arguments :session dbus--test-service :string "string"))
+ (should-error
+ (dbus-check-arguments :session dbus--test-service :string)
+ :type 'wrong-type-argument)
(should-error
(dbus-check-arguments :session dbus--test-service :string 0.5)
:type 'wrong-type-argument)
(should
(dbus-check-arguments
:session dbus--test-service :object-path "/object/path"))
+ (should-error
+ (dbus-check-arguments :session dbus--test-service :object-path)
+ :type 'wrong-type-argument)
+ ;; Raises an error on stdin.
(should-error
(dbus-check-arguments :session dbus--test-service :object-path "string")
:type 'dbus-error)
;; `:signature'.
(should (dbus-check-arguments :session dbus--test-service :signature "as"))
+ (should-error
+ (dbus-check-arguments :session dbus--test-service :signature)
+ :type 'wrong-type-argument)
+ ;; Raises an error on stdin.
(should-error
(dbus-check-arguments :session dbus--test-service :signature "string")
:type 'dbus-error)
(should (dbus-check-arguments :session dbus--test-service t))
(should (dbus-check-arguments :session dbus--test-service :boolean nil))
(should (dbus-check-arguments :session dbus--test-service :boolean t))
- ;; Will be handled as `nil'.
- (should (dbus-check-arguments :session dbus--test-service :boolean))
- ;; Will be handled as `t'.
(should (dbus-check-arguments :session dbus--test-service :boolean 'whatever))
+ (should-error
+ (dbus-check-arguments :session dbus--test-service :boolean)
+ :type 'wrong-type-argument)
;; `:byte'.
(should (dbus-check-arguments :session dbus--test-service :byte 0))
;; Only the least significant byte is taken into account.
(should
(dbus-check-arguments :session dbus--test-service :byte most-positive-fixnum))
+ (should-error
+ (dbus-check-arguments :session dbus--test-service :byte)
+ :type 'wrong-type-argument)
(should-error
(dbus-check-arguments :session dbus--test-service :byte -1)
:type 'wrong-type-argument)
(should (dbus-check-arguments :session dbus--test-service :int16 0))
(should (dbus-check-arguments :session dbus--test-service :int16 #x7fff))
(should (dbus-check-arguments :session dbus--test-service :int16 #x-8000))
+ (should-error
+ (dbus-check-arguments :session dbus--test-service :int16)
+ :type 'wrong-type-argument)
(should-error
(dbus-check-arguments :session dbus--test-service :int16 #x8000)
:type 'args-out-of-range)
;; `:uint16'.
(should (dbus-check-arguments :session dbus--test-service :uint16 0))
(should (dbus-check-arguments :session dbus--test-service :uint16 #xffff))
+ (should-error
+ (dbus-check-arguments :session dbus--test-service :uint16)
+ :type 'wrong-type-argument)
(should-error
(dbus-check-arguments :session dbus--test-service :uint16 #x10000)
:type 'args-out-of-range)
(should (dbus-check-arguments :session dbus--test-service :int32 0))
(should (dbus-check-arguments :session dbus--test-service :int32 #x7fffffff))
(should (dbus-check-arguments :session dbus--test-service :int32 #x-80000000))
+ (should-error
+ (dbus-check-arguments :session dbus--test-service :int32)
+ :type 'wrong-type-argument)
(should-error
(dbus-check-arguments :session dbus--test-service :int32 #x80000000)
:type 'args-out-of-range)
(should (dbus-check-arguments :session dbus--test-service 0))
(should (dbus-check-arguments :session dbus--test-service :uint32 0))
(should (dbus-check-arguments :session dbus--test-service :uint32 #xffffffff))
+ (should-error
+ (dbus-check-arguments :session dbus--test-service :uint32)
+ :type 'wrong-type-argument)
(should-error
(dbus-check-arguments :session dbus--test-service :uint32 #x100000000)
:type 'args-out-of-range)
(dbus-check-arguments :session dbus--test-service :int64 #x7fffffffffffffff))
(should
(dbus-check-arguments :session dbus--test-service :int64 #x-8000000000000000))
+ (should-error
+ (dbus-check-arguments :session dbus--test-service :int64)
+ :type 'wrong-type-argument)
(should-error
(dbus-check-arguments :session dbus--test-service :int64 #x8000000000000000)
:type 'args-out-of-range)
(should (dbus-check-arguments :session dbus--test-service :uint64 0))
(should
(dbus-check-arguments :session dbus--test-service :uint64 #xffffffffffffffff))
+ (should-error
+ (dbus-check-arguments :session dbus--test-service :uint64)
+ :type 'wrong-type-argument)
(should-error
(dbus-check-arguments :session dbus--test-service :uint64 #x10000000000000000)
:type 'args-out-of-range)
;; Shall both be supported?
(should (dbus-check-arguments :session dbus--test-service :double 1.0e+INF))
(should (dbus-check-arguments :session dbus--test-service :double 0.0e+NaN))
+ (should-error
+ (dbus-check-arguments :session dbus--test-service :double)
+ :type 'wrong-type-argument)
(should-error
(dbus-check-arguments :session dbus--test-service :double "string")
:type 'wrong-type-argument)
;; D-Bus message). Mainly testing, that values out of `:uint32'
;; type range fail.
(should (dbus-check-arguments :session dbus--test-service :unix-fd 0))
+ (should-error
+ (dbus-check-arguments :session dbus--test-service :unix-fd)
+ :type 'wrong-type-argument)
(should-error
(dbus-check-arguments :session dbus--test-service :unix-fd -1)
:type 'args-out-of-range)
(should
(dbus-check-arguments
:session dbus--test-service '(:array :string "string1" "string2")))
- ;; Empty array.
+ ;; Empty array (of strings).
(should (dbus-check-arguments :session dbus--test-service '(:array)))
(should
(dbus-check-arguments :session dbus--test-service '(:array :signature "o")))
(should
(dbus-check-arguments
:session dbus--test-service '(:variant (:array "string"))))
- ;; More than one element.
+ ;; No or more than one element.
+ ;; FIXME.
+ ;; (should-error
+ ;; (dbus-check-arguments :session dbus--test-service '(:variant))
+ ;; :type 'wrong-type-argument)
(should-error
(dbus-check-arguments
:session dbus--test-service
(dbus-check-arguments
:session dbus--test-service
'(:array :dict-entry (:string "string" :boolean t))))
- ;; The second element is `nil' (implicitly). FIXME: Is this right?
- (should
- (dbus-check-arguments
- :session dbus--test-service '(:array (:dict-entry :string "string"))))
+ ;; FIXME: Must be errors.
+ ;; (should
+ ;; (dbus-check-arguments
+ ;; :session dbus--test-service '(:array (:dict-entry))))
+ ;; (should
+ ;; (dbus-check-arguments
+ ;; :session dbus--test-service '(:array (:dict-entry :string "string"))))
;; Not two elements.
(should-error
(dbus-check-arguments
(dbus-check-arguments
:session dbus--test-service '(:dict-entry :string "string" :boolean t))
:type 'wrong-type-argument)
- ;; Different dict entry types can be part of an array.
+ ;; FIXME:! This doesn't look right.
+ ;; Different dict entry types can be part of an array ???
(should
(dbus-check-arguments
:session dbus--test-service
(:dict-entry :string "string2" :object-path "/object/path"))))
;; `:struct'. There is no restriction what could be an element of a struct.
+ ;; Empty struct. FIXME: Is this right?
+ ;; (should (dbus-check-arguments :session dbus--test-service '(:struct)))
(should
(dbus-check-arguments
:session dbus--test-service