View Source Membrane.Testing.Assertions (Membrane Core v0.10.2)
This module contains a set of assertion functions and macros.
These assertions will work ONLY in conjunction with
Membrane.Testing.Pipeline and ONLY when pid of tested pipeline is provided
as an argument to these assertions.
Link to this section Summary
Functions
Asserts that Membrane.Testing.Pipeline received or is going to receive end_of_stream
notification about from the element with a name element_name within the timeout period
specified in milliseconds.
Asserts that a crash group within pipeline will be down within the timeout period specified in
milliseconds.
Asserts that pipeline received or will receive a notification from the element
with name element_name within the timeout period specified in milliseconds.
Asserts that pipeline's playback state (see Membrane.PlaybackState)
changed or will change from previous_state to current_state within
the timeout period specified in milliseconds.
Asserts that pipeline received or will receive a message matching
message_pattern from another process within the timeout period specified
in milliseconds.
Asserts that Membrane.Testing.Sink with name sink_name received or will
receive a buffer matching pattern within the timeout period specified in
milliseconds.
Asserts that Membrane.Testing.Sink with name sink_name received or will
receive caps matching pattern within the timeout period specified in
milliseconds.
Asserts that Membrane.Testing.Sink with name sink_name received or will
receive an event within the timeout period specified in milliseconds.
Asserts that Membrane.Testing.Pipeline received or is going to receive start_of_stream
notification from the element with a name element_name within the timeout period
specified in milliseconds.
Refutes that a crash group within pipeline won't be down within the timeout period specified in
milliseconds.
Refutes that pipeline received or will receive a notification from the element
with name element_name within the timeout period specified in milliseconds.
Asserts that pipeline has not received and will not receive a message from
another process matching message_pattern within the timeout period
specified in milliseconds.
Asserts that Membrane.Testing.Sink with name sink_name has not received
and will not receive a buffer matching buffer_pattern within the timeout
period specified in milliseconds.
Asserts that Membrane.Testing.Sink with name sink_name has not received
and will not receive caps matching caps_pattern within the timeout
period specified in milliseconds.
Asserts that Membrane.Testing.Sink has not received and will not receive
event matching provided pattern within the timeout period specified in
milliseconds.
Link to this section Functions
assert_end_of_stream(pipeline, element_name, pad \\ :input, timeout \\ 2000)
View Source (macro)Asserts that Membrane.Testing.Pipeline received or is going to receive end_of_stream
notification about from the element with a name element_name within the timeout period
specified in milliseconds.
assert_end_of_stream(pipeline, :an_element)
assert_pipeline_crash_group_down(pipeline, group_name, timeout \\ 2000)
View Source (macro)Asserts that a crash group within pipeline will be down within the timeout period specified in
milliseconds.
Usage example:
assert_pipeline_crash_group_down(pipeline, :group_1)
assert_pipeline_notified(pipeline, element_name, notification_pattern, timeout \\ 2000)
View Source (macro)Asserts that pipeline received or will receive a notification from the element
with name element_name within the timeout period specified in milliseconds.
The notification_pattern must be a match pattern.
assert_pipeline_notified(pipeline, :element_name, :hi)
assert_pipeline_playback_changed(pipeline, previous_state, current_state, timeout \\ 2000)
View Source (macro)Asserts that pipeline's playback state (see Membrane.PlaybackState)
changed or will change from previous_state to current_state within
the timeout period specified in milliseconds.
The prev_state and current_state must be match patterns.
Assertion can be either made by providing state before and after the change as atoms:
assert_pipeline_playback_changed(pipeline, :prepared, :playing)Or by using an _ to assert on change from any state to other:
assert_pipeline_playback_changed(pipeline, _, :playing)
assert_pipeline_receive(pipeline, message_pattern, timeout \\ 2000)
View Source (macro)Asserts that pipeline received or will receive a message matching
message_pattern from another process within the timeout period specified
in milliseconds.
The message_pattern must be a match pattern.
assert_pipeline_receive(pid, :tick)Such call would flunk if the message :tick has not been handled by
c:Membrane.Parent.handle_other/3 within the timeout.
assert_sink_buffer(pipeline, sink_name, pattern, timeout \\ 2000)
View Source (macro)Asserts that Membrane.Testing.Sink with name sink_name received or will
receive a buffer matching pattern within the timeout period specified in
milliseconds.
When the Membrane.Testing.Sink is a part of Membrane.Testing.Pipeline you
can assert whether it received a buffer matching provided pattern.
children = [
....,
the_sink: %Membrane.Testing.Sink{}
]
{:ok, pid} = Membrane.Testing.Pipeline.start_link(
children: children,
links: Membrane.ParentSpec.link_linear(children)
)You can match for exact value:
assert_sink_buffer(pid, :the_sink ,%Membrane.Buffer{payload: ^specific_payload})You can also use pattern to extract data from the buffer:
assert_sink_buffer(pid, :sink, %Buffer{payload: <<data::16>> <> <<255>>})
do_something(data)
assert_sink_caps(pipeline, element_name, caps_pattern, timeout \\ 2000)
View Source (macro)Asserts that Membrane.Testing.Sink with name sink_name received or will
receive caps matching pattern within the timeout period specified in
milliseconds.
When the Membrane.Testing.Sink is a part of Membrane.Testing.Pipeline you
can assert whether it received caps matching provided pattern.
children = [
....,
the_sink: %Membrane.Testing.Sink{}
]
{:ok, pid} = Membrane.Testing.Pipeline.start_link(
children: children,
links: Membrane.ParentSpec.link_linear(children)
)You can match for exact value:
assert_sink_caps(pid, :the_sink , %Caps{prop: ^value})You can also use pattern to extract data from the caps:
assert_sink_caps(pid, :the_sink , %Caps{prop: value})
do_something(value)
assert_sink_event(pipeline, sink_name, event, timeout \\ 2000)
View Source (macro)Asserts that Membrane.Testing.Sink with name sink_name received or will
receive an event within the timeout period specified in milliseconds.
When a Membrane.Testing.Sink is part of Membrane.Testing.Pipeline you can
assert whether it received an event matching a provided pattern.
assert_sink_event(pid, :the_sink, %Discontinuity{})
assert_start_of_stream(pipeline, element_name, pad \\ :input, timeout \\ 2000)
View Source (macro)Asserts that Membrane.Testing.Pipeline received or is going to receive start_of_stream
notification from the element with a name element_name within the timeout period
specified in milliseconds.
assert_start_of_stream(pipeline, :an_element)
refute_pipeline_crash_group_down(pipeline, group_name, timeout \\ 2000)
View Source (macro)Refutes that a crash group within pipeline won't be down within the timeout period specified in
milliseconds.
Usage example:
refute_pipeline_crash_group_down(pipeline, :group_1)
refute_pipeline_notified(pipeline, element_name, notification_pattern, timeout \\ 2000)
View Source (macro)Refutes that pipeline received or will receive a notification from the element
with name element_name within the timeout period specified in milliseconds.
The notification_pattern must be a match pattern.
refute_pipeline_notified(pipeline, :element_name, :hi)
refute_pipeline_receive(pipeline, message_pattern, timeout \\ 2000)
View Source (macro)Asserts that pipeline has not received and will not receive a message from
another process matching message_pattern within the timeout period
specified in milliseconds.
The message_pattern must be a match pattern.
refute_pipeline_receive(pid, :tick)Such call would flunk if the message :tick has been handled by
c:Membrane.Parent.handle_other/3.
refute_sink_buffer(pipeline, sink_name, pattern, timeout \\ 2000)
View Source (macro)Asserts that Membrane.Testing.Sink with name sink_name has not received
and will not receive a buffer matching buffer_pattern within the timeout
period specified in milliseconds.
Similarly as in the assert_sink_buffer/4 the_sink needs to be part of a
Membrane.Testing.Pipeline.
refute_sink_buffer(pipeline, :the_sink, %Buffer{payload: <<0xA1, 0xB2>>})Such expression will flunk if the_sink received or will receive a buffer
with payload <<0xA1, 0xB2>>.
refute_sink_caps(pipeline, element_name, caps_pattern, timeout \\ 2000)
View Source (macro)Asserts that Membrane.Testing.Sink with name sink_name has not received
and will not receive caps matching caps_pattern within the timeout
period specified in milliseconds.
Similarly as in the assert_sink_caps/4 the_sink needs to be part of a
Membrane.Testing.Pipeline.
refute_sink_caps(pipeline, :the_sink, %Caps{prop: ^val})Such expression will flunk if the_sink received or will receive caps with
property equal to value of val variable.
refute_sink_event(pipeline, sink_name, event, timeout \\ 2000)
View Source (macro)Asserts that Membrane.Testing.Sink has not received and will not receive
event matching provided pattern within the timeout period specified in
milliseconds.
refute_sink_event(pid, :the_sink, %Discontinuity{})