Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
Zbigniew Jędrzejewski-Szmek
polkit
Commits
ed968d50
Commit
ed968d50
authored
Nov 03, 2007
by
David Zeuthen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add unit tests for PolKitSeat
parent
05af4eec
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
59 additions
and
6 deletions
+59
-6
polkit/polkit-seat.c
polkit/polkit-seat.c
+57
-6
polkit/polkit-test.c
polkit/polkit-test.c
+1
-0
polkit/polkit-test.h
polkit/polkit-test.h
+1
-0
No files found.
polkit/polkit-seat.c
View file @
ed968d50
...
...
@@ -40,6 +40,8 @@
#include "polkit-debug.h"
#include "polkit-seat.h"
#include "polkit-utils.h"
#include "polkit-test.h"
#include "polkit-memory.h"
/**
* SECTION:polkit-seat
...
...
@@ -72,8 +74,11 @@ PolKitSeat *
polkit_seat_new
(
void
)
{
PolKitSeat
*
seat
;
seat
=
g_new0
(
PolKitSeat
,
1
);
seat
=
p_new0
(
PolKitSeat
,
1
);
if
(
seat
==
NULL
)
goto
out
;
seat
->
refcount
=
1
;
out:
return
seat
;
}
...
...
@@ -108,8 +113,8 @@ polkit_seat_unref (PolKitSeat *seat)
seat
->
refcount
--
;
if
(
seat
->
refcount
>
0
)
return
;
g
_free
(
seat
->
ck_objref
);
g
_free
(
seat
);
p
_free
(
seat
->
ck_objref
);
p
_free
(
seat
);
}
/**
...
...
@@ -127,9 +132,12 @@ polkit_seat_set_ck_objref (PolKitSeat *seat, const char *ck_objref)
g_return_val_if_fail
(
seat
!=
NULL
,
FALSE
);
g_return_val_if_fail
(
_pk_validate_identifier
(
ck_objref
),
FALSE
);
if
(
seat
->
ck_objref
!=
NULL
)
g_free
(
seat
->
ck_objref
);
seat
->
ck_objref
=
g_strdup
(
ck_objref
);
return
TRUE
;
p_free
(
seat
->
ck_objref
);
seat
->
ck_objref
=
p_strdup
(
ck_objref
);
if
(
seat
->
ck_objref
==
NULL
)
return
FALSE
;
else
return
TRUE
;
}
/**
...
...
@@ -178,3 +186,46 @@ polkit_seat_validate (PolKitSeat *seat)
g_return_val_if_fail
(
seat
->
ck_objref
!=
NULL
,
FALSE
);
return
TRUE
;
}
#ifdef POLKIT_BUILD_TESTS
static
polkit_bool_t
_run_test
(
void
)
{
char
*
str
;
PolKitSeat
*
s
;
s
=
polkit_seat_new
();
if
(
s
==
NULL
)
{
/* OOM */
}
else
{
if
(
!
polkit_seat_set_ck_objref
(
s
,
"/someseat"
))
{
/* OOM */
}
else
{
g_assert
(
polkit_seat_get_ck_objref
(
s
,
&
str
)
&&
strcmp
(
str
,
"/someseat"
)
==
0
);
g_assert
(
polkit_seat_validate
(
s
));
polkit_seat_ref
(
s
);
g_assert
(
polkit_seat_validate
(
s
));
polkit_seat_unref
(
s
);
g_assert
(
polkit_seat_validate
(
s
));
polkit_seat_debug
(
s
);
if
(
!
polkit_seat_set_ck_objref
(
s
,
"/someseat2"
))
{
/* OOM */
}
else
{
g_assert
(
polkit_seat_get_ck_objref
(
s
,
&
str
)
&&
strcmp
(
str
,
"/someseat2"
)
==
0
);
}
}
polkit_seat_unref
(
s
);
}
return
TRUE
;
}
PolKitTest
_test_seat
=
{
"polkit_seat"
,
NULL
,
NULL
,
_run_test
};
#endif
/* POLKIT_BUILD_TESTS */
polkit/polkit-test.c
View file @
ed968d50
...
...
@@ -34,6 +34,7 @@ static PolKitTest *tests[] = {
&
_test_action
,
&
_test_error
,
&
_test_result
,
&
_test_seat
,
};
int
...
...
polkit/polkit-test.h
View file @
ed968d50
...
...
@@ -47,6 +47,7 @@ typedef struct {
extern
PolKitTest
_test_action
;
extern
PolKitTest
_test_error
;
extern
PolKitTest
_test_result
;
extern
PolKitTest
_test_seat
;
POLKIT_END_DECLS
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment