Skip to content

Commit

Permalink
#10600 add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
paoloo committed Jul 23, 2024
1 parent f6f7325 commit 812516d
Show file tree
Hide file tree
Showing 3 changed files with 175 additions and 0 deletions.
21 changes: 21 additions & 0 deletions test/media/ver10/fixtures/get_osds_empty.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<SOAP-ENV:Envelope
xmlns:SOAP-ENV="http://www.w3.org/2003/05/soap-envelope"
xmlns:SOAP-ENC="http://www.w3.org/2003/05/soap-encoding"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:c14n="http://www.w3.org/2001/10/xml-exc-c14n#"
xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"
xmlns:ds="http://www.w3.org/2000/09/xmldsig#"
xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"
xmlns:wsa5="http://www.w3.org/2005/08/addressing"
xmlns:tt="http://www.onvif.org/ver10/schema"
xmlns:wsnt="http://docs.oasis-open.org/wsn/b-2"
xmlns:tns1="http://www.onvif.org/ver10/topics"
xmlns:tnsaxis="http://www.axis.com/2009/event/topics"
xmlns:tev="http://www.onvif.org/ver10/events/wsdl"
xmlns:trt="http://www.onvif.org/ver10/media/wsdl"
xmlns:ter="http://www.onvif.org/ver10/error">
<SOAP-ENV:Body>
<trt:GetOSDsResponse></trt:GetOSDsResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
84 changes: 84 additions & 0 deletions test/media/ver10/fixtures/get_osds_response.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
<?xml version="1.0" encoding="UTF-8"?>
<env:Envelope
xmlns:env="http://www.w3.org/2003/05/soap-envelope"
xmlns:soapenc="http://www.w3.org/2003/05/soap-encoding"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:tt="http://www.onvif.org/ver10/schema"
xmlns:tds="http://www.onvif.org/ver10/device/wsdl"
xmlns:trt="http://www.onvif.org/ver10/media/wsdl"
xmlns:timg="http://www.onvif.org/ver20/imaging/wsdl"
xmlns:tev="http://www.onvif.org/ver10/events/wsdl"
xmlns:tptz="http://www.onvif.org/ver20/ptz/wsdl"
xmlns:tan="http://www.onvif.org/ver20/analytics/wsdl"
xmlns:tst="http://www.onvif.org/ver10/storage/wsdl"
xmlns:ter="http://www.onvif.org/ver10/error"
xmlns:dn="http://www.onvif.org/ver10/network/wsdl"
xmlns:tns1="http://www.onvif.org/ver10/topics"
xmlns:tmd="http://www.onvif.org/ver10/deviceIO/wsdl"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl"
xmlns:wsoap12="http://schemas.xmlsoap.org/wsdl/soap12"
xmlns:http="http://schemas.xmlsoap.org/wsdl/http"
xmlns:d="http://schemas.xmlsoap.org/ws/2005/04/discovery"
xmlns:wsadis="http://schemas.xmlsoap.org/ws/2004/08/addressing"
xmlns:wsnt="http://docs.oasis-open.org/wsn/b-2"
xmlns:wsa="http://www.w3.org/2005/08/addressing"
xmlns:wstop="http://docs.oasis-open.org/wsn/t-1"
xmlns:wsrf-bf="http://docs.oasis-open.org/wsrf/bf-2"
xmlns:wsntw="http://docs.oasis-open.org/wsn/bw-2"
xmlns:wsrf-rw="http://docs.oasis-open.org/wsrf/rw-2"
xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl"
xmlns:wsrf-r="http://docs.oasis-open.org/wsrf/r-2"
xmlns:trc="http://www.onvif.org/ver10/recording/wsdl"
xmlns:tse="http://www.onvif.org/ver10/search/wsdl"
xmlns:trp="http://www.onvif.org/ver10/replay/wsdl"
xmlns:tnshik="http://www.hikvision.com/2011/event/topics"
xmlns:hikwsd="http://www.onvifext.com/onvif/ext/ver10/wsdl"
xmlns:hikxsd="http://www.onvifext.com/onvif/ext/ver10/schema"
xmlns:tas="http://www.onvif.org/ver10/advancedsecurity/wsdl"
xmlns:tr2="http://www.onvif.org/ver20/media/wsdl"
xmlns:axt="http://www.onvif.org/ver20/analytics">
<env:Body>
<trt:GetOSDsResponse>
<trt:OSDs token="OsdToken_101">
<tt:VideoSourceConfigurationToken>VideoSourceToken</tt:VideoSourceConfigurationToken>
<tt:Type>Text</tt:Type>
<tt:Position>
<tt:Type>Custom</tt:Type>
<tt:Pos x="-1.000000" y="0.866667"/>
</tt:Position>
<tt:TextString>
<tt:Type>DateAndTime</tt:Type>
<tt:DateFormat>MM/dd/yyyy</tt:DateFormat>
<tt:TimeFormat>HH:mm:ss</tt:TimeFormat>
<tt:FontSize>32</tt:FontSize>
<tt:FontColor>
<tt:Color X="0.000000" Y="0.000000" Z="0.000000" Colorspace="http://www.onvif.org/ver10/colorspace/YCbCr"/>
</tt:FontColor>
<tt:Extension>
<tt:ChannelName>false</tt:ChannelName>
</tt:Extension>
</tt:TextString>
</trt:OSDs>
<trt:OSDs token="OsdToken_100">
<tt:VideoSourceConfigurationToken>VideoSourceToken</tt:VideoSourceConfigurationToken>
<tt:Type>Text</tt:Type>
<tt:Position>
<tt:Type>Custom</tt:Type>
<tt:Pos x="0.454545" y="-0.733333"/>
</tt:Position>
<tt:TextString>
<tt:Type>Plain</tt:Type>
<tt:FontSize>32</tt:FontSize>
<tt:FontColor>
<tt:Color X="0.000000" Y="0.000000" Z="0.000000" Colorspace="http://www.onvif.org/ver10/colorspace/YCbCr"/>
</tt:FontColor>
<tt:PlainText>Camera 01</tt:PlainText>
<tt:Extension>
<tt:ChannelName>true</tt:ChannelName>
</tt:Extension>
</tt:TextString>
</trt:OSDs>
</trt:GetOSDsResponse>
</env:Body>
</env:Envelope>
70 changes: 70 additions & 0 deletions test/media/ver10/get_osds.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
defmodule Onvif.Media.Ver10.GetOSDsTest do
use ExUnit.Case, async: true

@moduletag capture_log: true

describe "GetOSDs/1" do
test "should list 2 OSDs" do
xml_response =
File.read!(
"test/media/ver10/fixtures/get_osds_response.xml"
)

device = Onvif.Factory.device()

Mimic.expect(Tesla, :request, fn _client, _opts ->
{:ok, %{status: 200, body: xml_response}}
end)

osds = Onvif.Media.Ver10.GetOSDs.request(device)

assert length(osds) == 2
assert hd(osds) == %Onvif.Media.Ver10.OSD{
image: nil,
position: %Onvif.Media.Ver10.OSD.Position{
pos: %{x: 0.454545, y: -0.733333},
type: :custom
},
text_string: %Onvif.Media.Ver10.OSD.TextString{
background_color: nil,
date_format: nil,
font_color: %Onvif.Media.Ver10.OSD.TextString.FontColor{
color: %{
colorspace: "http://www.onvif.org/ver10/colorspace/YCbCr",
x: 0.0,
y: 0.0,
z: 0.0
},
transparent: nil
},
font_size: 32,
is_persistent_text: nil,
plain_text: "Camera 01",
time_format: nil,
type: :plain
},
token: "OsdToken_100",
type: :text,
video_source_configuration_token: "VideoSourceToken"
}
end

test "should have no OSD available" do
xml_response =
File.read!(
"test/media/ver10/fixtures/get_osds_empty.xml"
)

device = Onvif.Factory.device()

Mimic.expect(Tesla, :request, fn _client, _opts ->
{:ok, %{status: 200, body: xml_response}}
end)

osds = Onvif.Media.Ver10.GetOSDs.request(device)

assert length(osds) == 0
end

end
end

0 comments on commit 812516d

Please sign in to comment.