Improved video content filter to be more flexible, and allow custom template.
This commit is contained in:
@@ -15,7 +15,7 @@ inherit
|
||||
|
||||
feature -- Test routines
|
||||
|
||||
test_video_filter
|
||||
test_video_filter_01
|
||||
-- New test routine
|
||||
local
|
||||
f: VIDEO_CONTENT_FILTER
|
||||
@@ -23,88 +23,88 @@ feature -- Test routines
|
||||
expected_text: STRING
|
||||
do
|
||||
text := "[video:https://www.youtube.com/embed/jBMOSSnCMCk]"
|
||||
expected_text := "<iframe width=%"420%" height=%"315%"%Nsrc=%"https://www.youtube.com/embed/jBMOSSnCMCk%">%N</iframe>"
|
||||
expected_text := "<iframe src=%"https://www.youtube.com/embed/jBMOSSnCMCk%" width=%"420%" height=%"315%"></iframe>"
|
||||
create f
|
||||
f.filter (text)
|
||||
assert ("expected iframe with video", text.same_string (expected_text))
|
||||
end
|
||||
|
||||
|
||||
test_video_filter_2
|
||||
test_video_filter_02
|
||||
-- New test routine
|
||||
local
|
||||
f: VIDEO_CONTENT_FILTER
|
||||
text: STRING
|
||||
expected_text: STRING
|
||||
do
|
||||
text := "[ video : https://www.youtube.com/embed/jBMOSSnCMCk ]"
|
||||
expected_text := "<iframe width=%"420%" height=%"315%"%Nsrc=%"https://www.youtube.com/embed/jBMOSSnCMCk%">%N</iframe>"
|
||||
text := "[video: https://www.youtube.com/embed/jBMOSSnCMCk ]"
|
||||
expected_text := "<iframe src=%"https://www.youtube.com/embed/jBMOSSnCMCk%" width=%"420%" height=%"315%"></iframe>"
|
||||
create f
|
||||
f.filter (text)
|
||||
assert ("expected iframe with video", text.same_string (expected_text))
|
||||
end
|
||||
|
||||
|
||||
test_video_filter_3
|
||||
test_video_filter_03
|
||||
-- New test routine
|
||||
local
|
||||
f: VIDEO_CONTENT_FILTER
|
||||
text: STRING
|
||||
expected_text: STRING
|
||||
do
|
||||
text := "[ video :https://www.youtube.com/embed/jBMOSSnCMCk ]"
|
||||
expected_text := "<iframe width=%"420%" height=%"315%"%Nsrc=%"https://www.youtube.com/embed/jBMOSSnCMCk%">%N</iframe>"
|
||||
text := "[video:https://www.youtube.com/embed/jBMOSSnCMCk ]"
|
||||
expected_text := "<iframe src=%"https://www.youtube.com/embed/jBMOSSnCMCk%" width=%"420%" height=%"315%"></iframe>"
|
||||
create f
|
||||
f.filter (text)
|
||||
assert ("expected iframe with video", text.same_string (expected_text))
|
||||
end
|
||||
|
||||
|
||||
test_video_filter_4
|
||||
test_video_filter_04
|
||||
-- New test routine
|
||||
local
|
||||
f: VIDEO_CONTENT_FILTER
|
||||
text: STRING
|
||||
expected_text: STRING
|
||||
do
|
||||
text := "[ video :https://www.youtube.com/embed/jBMOSSnCMCk height:425]"
|
||||
expected_text := "<iframe width=%"420%" height=%"425%"%Nsrc=%"https://www.youtube.com/embed/jBMOSSnCMCk%">%N</iframe>"
|
||||
text := "[video:https://www.youtube.com/embed/jBMOSSnCMCk height:425]"
|
||||
expected_text := "<iframe src=%"https://www.youtube.com/embed/jBMOSSnCMCk%" width=%"420%" height=%"425%"></iframe>"
|
||||
create f
|
||||
f.filter (text)
|
||||
assert ("expected iframe with video", text.same_string (expected_text))
|
||||
end
|
||||
|
||||
|
||||
test_video_filter_5
|
||||
test_video_filter_05
|
||||
-- New test routine
|
||||
local
|
||||
f: VIDEO_CONTENT_FILTER
|
||||
text: STRING
|
||||
expected_text: STRING
|
||||
do
|
||||
text := "[ video :https://www.youtube.com/embed/jBMOSSnCMCk height : 425]"
|
||||
expected_text := "<iframe width=%"420%" height=%"425%"%Nsrc=%"https://www.youtube.com/embed/jBMOSSnCMCk%">%N</iframe>"
|
||||
text := "[video:https://www.youtube.com/embed/jBMOSSnCMCk height : 425]"
|
||||
expected_text := "<iframe src=%"https://www.youtube.com/embed/jBMOSSnCMCk%" width=%"420%" height=%"425%"></iframe>"
|
||||
create f
|
||||
f.filter (text)
|
||||
assert ("expected iframe with video", text.same_string (expected_text))
|
||||
end
|
||||
|
||||
|
||||
test_video_filter_6
|
||||
test_video_filter_06
|
||||
-- New test routine
|
||||
local
|
||||
f: VIDEO_CONTENT_FILTER
|
||||
text: STRING
|
||||
expected_text: STRING
|
||||
do
|
||||
text := "[ video :https://www.youtube.com/embed/jBMOSSnCMCk height : 425 width: 425]"
|
||||
expected_text := "<iframe width=%"425%" height=%"425%"%Nsrc=%"https://www.youtube.com/embed/jBMOSSnCMCk%">%N</iframe>"
|
||||
text := "[video:https://www.youtube.com/embed/jBMOSSnCMCk height : 425 width: 425]"
|
||||
expected_text := "<iframe src=%"https://www.youtube.com/embed/jBMOSSnCMCk%" width=%"425%" height=%"425%"></iframe>"
|
||||
create f
|
||||
f.filter (text)
|
||||
assert ("expected iframe with video", text.same_string (expected_text))
|
||||
end
|
||||
|
||||
test_video_filter_7
|
||||
test_video_filter_07
|
||||
-- New test routine
|
||||
local
|
||||
f: VIDEO_CONTENT_FILTER
|
||||
@@ -112,43 +112,13 @@ feature -- Test routines
|
||||
expected_text: STRING
|
||||
do
|
||||
text := "[video:https://www.youtube.com/embed/jBMOSSnCMCk height:425 width:425]"
|
||||
expected_text := "<iframe width=%"425%" height=%"425%"%Nsrc=%"https://www.youtube.com/embed/jBMOSSnCMCk%">%N</iframe>"
|
||||
expected_text := "<iframe src=%"https://www.youtube.com/embed/jBMOSSnCMCk%" width=%"425%" height=%"425%"></iframe>"
|
||||
create f
|
||||
f.filter (text)
|
||||
assert ("expected iframe with video", text.same_string (expected_text))
|
||||
end
|
||||
|
||||
|
||||
test_video_filter_8
|
||||
-- New test routine
|
||||
local
|
||||
f: VIDEO_CONTENT_FILTER
|
||||
text: STRING
|
||||
expected_text: STRING
|
||||
do
|
||||
text := "[height:425 width:425 video:https://www.youtube.com/embed/jBMOSSnCMCk ]"
|
||||
expected_text := "<iframe width=%"425%" height=%"425%"%Nsrc=%"https://www.youtube.com/embed/jBMOSSnCMCk%">%N</iframe>"
|
||||
create f
|
||||
f.filter (text)
|
||||
assert ("expected iframe with video", text.same_string (expected_text))
|
||||
end
|
||||
|
||||
|
||||
test_video_filter_9
|
||||
-- New test routine
|
||||
local
|
||||
f: VIDEO_CONTENT_FILTER
|
||||
text: STRING
|
||||
expected_text: STRING
|
||||
do
|
||||
text := "[ width:425 video:https://www.youtube.com/embed/jBMOSSnCMCk height:425]"
|
||||
expected_text := "<iframe width=%"425%" height=%"425%"%Nsrc=%"https://www.youtube.com/embed/jBMOSSnCMCk%">%N</iframe>"
|
||||
create f
|
||||
f.filter (text)
|
||||
assert ("expected iframe with video", text.same_string (expected_text))
|
||||
end
|
||||
|
||||
test_video_filter_10
|
||||
test_video_filter_08
|
||||
-- New test routine
|
||||
local
|
||||
f: VIDEO_CONTENT_FILTER
|
||||
@@ -156,14 +126,27 @@ feature -- Test routines
|
||||
expected_text: STRING
|
||||
do
|
||||
text := "[ wrong:425 video:https://www.youtube.com/embed/jBMOSSnCMCk height:425]"
|
||||
expected_text := "<iframe width=%"420%" height=%"425%"%Nsrc=%"https://www.youtube.com/embed/jBMOSSnCMCk%">%N</iframe>"
|
||||
expected_text := "[ wrong:425 video:https://www.youtube.com/embed/jBMOSSnCMCk height:425]"
|
||||
create f
|
||||
f.filter (text)
|
||||
assert ("expected iframe with video", text.same_string (expected_text))
|
||||
end
|
||||
|
||||
test_video_filter_09
|
||||
-- New test routine
|
||||
local
|
||||
f: VIDEO_CONTENT_FILTER
|
||||
text: STRING
|
||||
expected_text: STRING
|
||||
do
|
||||
text := "[video:https://www.youtube.com/embed/jBMOSSnCMCk height:425 foo:bar foo=bar foobar frameborder=%"0%" allowfullscreen]"
|
||||
expected_text := "<iframe src=%"https://www.youtube.com/embed/jBMOSSnCMCk%" width=%"420%" height=%"425%" foo=bar foobar frameborder=%"0%" allowfullscreen></iframe>"
|
||||
create f
|
||||
f.filter (text)
|
||||
assert ("expected iframe with video", text.same_string (expected_text))
|
||||
end
|
||||
|
||||
test_video_filter_11
|
||||
test_video_filter_10
|
||||
-- New test routine
|
||||
local
|
||||
f: VIDEO_CONTENT_FILTER
|
||||
@@ -177,6 +160,24 @@ feature -- Test routines
|
||||
assert ("expected iframe with video", text.same_string (expected_text))
|
||||
end
|
||||
|
||||
test_video_filter_tpl_01
|
||||
-- New test routine
|
||||
local
|
||||
f: VIDEO_CONTENT_FILTER
|
||||
text: STRING
|
||||
expected_text: STRING
|
||||
do
|
||||
text := "[video:https://www.youtube.com/embed/jBMOSSnCMCk height:425 foo:bar foo=bar foobar]"
|
||||
create f
|
||||
f.set_template ("<iframe src=%"$url%" $att allowfullscreen></iframe>")
|
||||
f.set_default_width (500)
|
||||
f.set_default_height (400)
|
||||
|
||||
expected_text := "<iframe src=%"https://www.youtube.com/embed/jBMOSSnCMCk%" width=%"500%" height=%"425%" foo=bar foobar allowfullscreen></iframe>"
|
||||
|
||||
f.filter (text)
|
||||
assert ("expected iframe with video", text.same_string (expected_text))
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||
<redirection xmlns="http://www.eiffel.com/developers/xml/configuration-1-16-0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.eiffel.com/developers/xml/configuration-1-16-0 http://www.eiffel.com/developers/xml/configuration-1-16-0.xsd" uuid="BD491995-C14C-4413-B09A-C1B4EDDA3116" message="Obsolete: use testing.ecf !" location="testing.ecf">
|
||||
</redirection>
|
||||
@@ -1,7 +1,9 @@
|
||||
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||
<system xmlns="http://www.eiffel.com/developers/xml/configuration-1-16-0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.eiffel.com/developers/xml/configuration-1-16-0 http://www.eiffel.com/developers/xml/configuration-1-16-0.xsd" name="embedded_video_testing" uuid="BD491995-C14C-4413-B09A-C1B4EDDA3116">
|
||||
<system xmlns="http://www.eiffel.com/developers/xml/configuration-1-15-0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.eiffel.com/developers/xml/configuration-1-15-0 http://www.eiffel.com/developers/xml/configuration-1-15-0.xsd" name="embedded_video_testing" uuid="BD491995-C14C-4413-B09A-C1B4EDDA3116">
|
||||
<target name="embedded_video_testing">
|
||||
<root class="ANY" feature="default_create"/>
|
||||
<option warning="true" void_safety="all">
|
||||
</option>
|
||||
<file_rule>
|
||||
<exclude>/.git$</exclude>
|
||||
<exclude>/.svn$</exclude>
|
||||
@@ -9,13 +11,10 @@
|
||||
</file_rule>
|
||||
<option warning="true">
|
||||
</option>
|
||||
<capability>
|
||||
<concurrency use="none"/>
|
||||
</capability>
|
||||
<library name="base" location="$ISE_LIBRARY\library\base\base.ecf"/>
|
||||
<library name="embeded_module" location="..\video.ecf"/>
|
||||
<library name="testing" location="$ISE_LIBRARY\library\testing\testing.ecf"/>
|
||||
<library name="text_filter" location="$ISE_LIBRARY\unstable\library\text\text_filter\text_filter.ecf"/>
|
||||
<library name="base" location="$ISE_LIBRARY\library\base\base-safe.ecf"/>
|
||||
<library name="embedded_module" location="..\embedded_video-safe.ecf" readonly="false"/>
|
||||
<library name="testing" location="$ISE_LIBRARY\library\testing\testing-safe.ecf"/>
|
||||
<library name="text_filter" location="$ISE_LIBRARY\unstable\library\text\text_filter\text_filter-safe.ecf"/>
|
||||
<tests name="src" location=".\"/>
|
||||
</target>
|
||||
</system>
|
||||
|
||||
Reference in New Issue
Block a user