Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc-gpu
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
videolan
vlc-gpu
Commits
a8879770
Commit
a8879770
authored
Feb 25, 2008
by
Pierre d'Herbemont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
testapi.c: Test libvlc's events.
parent
9a4101d7
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
108 additions
and
0 deletions
+108
-0
src/control/testapi.c
src/control/testapi.c
+108
-0
No files found.
src/control/testapi.c
View file @
a8879770
...
@@ -152,6 +152,112 @@ static void test_file_playback (const char ** argv, int argc, const char * file)
...
@@ -152,6 +152,112 @@ static void test_file_playback (const char ** argv, int argc, const char * file)
catch
();
catch
();
}
}
/* This one is an internal API. We use it here to run tests that
* don't depends on playback, and only test the event framework */
extern
void
libvlc_event_send
(
libvlc_event_manager_t
*
,
libvlc_event_t
*
);
static
void
test_events_dummy_callback
(
const
libvlc_event_t
*
event
,
void
*
user_data
)
{
vlc_bool_t
*
callback_was_called
=
user_data
;
*
callback_was_called
=
VLC_TRUE
;
}
static
void
test_events_callback_and_detach
(
const
libvlc_event_t
*
event
,
void
*
user_data
)
{
vlc_bool_t
*
callback_was_called
=
user_data
;
libvlc_event_manager_t
*
em
;
em
=
libvlc_media_instance_event_manager
(
event
->
p_obj
,
&
ex
);
catch
();
libvlc_event_detach
(
em
,
event
->
type
,
test_events_callback_and_detach
,
user_data
,
&
ex
);
*
callback_was_called
=
VLC_TRUE
;
}
static
void
test_event_type_reception
(
libvlc_event_manager_t
*
em
,
libvlc_event_type_t
event_type
,
vlc_bool_t
*
callback_was_called
)
{
libvlc_event_t
event
;
event
.
type
=
event_type
;
*
callback_was_called
=
VLC_FALSE
;
libvlc_event_send
(
em
,
&
event
);
assert
(
*
callback_was_called
);
}
static
void
test_events
(
const
char
**
argv
,
int
argc
)
{
libvlc_instance_t
*
vlc
;
libvlc_media_instance_t
*
mi
;
libvlc_event_manager_t
*
em
;
vlc_bool_t
callback_was_called
;
libvlc_exception_t
ex
;
libvlc_event_type_t
mi_events
[]
=
{
libvlc_MediaInstancePlayed
,
libvlc_MediaInstancePaused
,
libvlc_MediaInstanceReachedEnd
,
libvlc_MediaInstanceEncounteredError
,
libvlc_MediaInstanceTimeChanged
,
libvlc_MediaInstancePositionChanged
,
};
int
i
,
mi_events_len
=
sizeof
(
mi_events
)
/
sizeof
(
*
mi_events
);
log
(
"Testing events
\n
"
);
libvlc_exception_init
(
&
ex
);
vlc
=
libvlc_new
(
argc
,
argv
,
&
ex
);
catch
();
mi
=
libvlc_media_instance_new
(
vlc
,
&
ex
);
catch
();
em
=
libvlc_media_instance_event_manager
(
mi
,
&
ex
);
log
(
"Testing attaching to Media Instance
\n
"
);
for
(
i
=
0
;
i
<
mi_events_len
;
i
++
)
{
libvlc_event_attach
(
em
,
mi_events
[
i
],
test_events_dummy_callback
,
&
callback_was_called
,
&
ex
);
catch
();
}
log
(
"Testing event reception
\n
"
);
for
(
i
=
0
;
i
<
mi_events_len
;
i
++
)
test_event_type_reception
(
em
,
mi_events
[
i
],
&
callback_was_called
);
log
(
"Testing event detaching while in the event callback
\n
"
);
libvlc_event_t
event
;
event
.
type
=
mi_events
[
mi_events_len
-
1
];
callback_was_called
=
VLC_FALSE
;
libvlc_event_detach
(
em
,
mi_events
[
mi_events_len
-
1
],
test_events_dummy_callback
,
&
callback_was_called
,
&
ex
);
catch
();
libvlc_event_attach
(
em
,
mi_events
[
mi_events_len
-
1
],
test_events_callback_and_detach
,
&
callback_was_called
,
&
ex
);
catch
();
libvlc_event_send
(
em
,
&
event
);
assert
(
callback_was_called
);
callback_was_called
=
VLC_FALSE
;
libvlc_event_send
(
em
,
&
event
);
assert
(
!
callback_was_called
);
libvlc_event_detach
(
em
,
mi_events
[
i
],
test_events_callback_and_detach
,
&
callback_was_called
,
&
ex
);
catch
();
/* Detach the other events */
for
(
i
=
0
;
i
<
mi_events_len
-
1
;
i
++
)
{
libvlc_event_detach
(
em
,
mi_events
[
i
],
test_events_dummy_callback
,
&
callback_was_called
,
&
ex
);
catch
();
}
libvlc_media_instance_release
(
mi
);
catch
();
libvlc_release
(
vlc
);
catch
();
}
int
main
(
int
argc
,
char
*
argv
[])
int
main
(
int
argc
,
char
*
argv
[])
{
{
const
char
*
args
[
argc
+
5
];
const
char
*
args
[
argc
+
5
];
...
@@ -170,6 +276,8 @@ int main (int argc, char *argv[])
...
@@ -170,6 +276,8 @@ int main (int argc, char *argv[])
test_core
(
args
,
nlibvlc_args
);
test_core
(
args
,
nlibvlc_args
);
test_events
(
args
,
nlibvlc_args
);
test_media_list
(
args
,
nlibvlc_args
);
test_media_list
(
args
,
nlibvlc_args
);
return
0
;
return
0
;
...
...
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