diff --git a/tests/tests/swfs/avm2/text_engine_groupelement/Test.as b/tests/tests/swfs/avm2/text_engine_groupelement/Test.as new file mode 100644 index 000000000000..36404e7b3a05 --- /dev/null +++ b/tests/tests/swfs/avm2/text_engine_groupelement/Test.as @@ -0,0 +1,160 @@ +package { + import flash.display.Sprite; + public class Test extends Sprite { } +} + +import flash.text.engine.GroupElement; +import flash.text.engine.TextElement; +import flash.text.engine.ContentElement; + +function createGroup() { + var vector = new Vector.() + vector.push(new TextElement("aaaaa")) + vector.push(new TextElement("bbbbb")) + vector.push(new TextElement("ccccc")) + return new GroupElement(vector); +} + +trace("/// replaceElements(0, 0, null)") +var group = createGroup(); +trace("result: " + group.replaceElements(0, 0, null)); +for (var i = 0; i < group.elementCount; i++) { + trace(i + " "+ group.getElementAt(i).text); +} + +trace("/// replaceElements(50, 50, null)") +var group = createGroup(); +trace("result: " + group.replaceElements(50, 50, null)); +for (var i = 0; i < group.elementCount; i++) { + trace(i + " "+ group.getElementAt(i).text); +} + +trace("/// replaceElements(0, 1, null)") +var group = createGroup(); +trace("result: " + group.replaceElements(0, 1, null)); +for (var i = 0; i < group.elementCount; i++) { + trace(i + " "+ group.getElementAt(i).text); +} + +trace("/// replaceElements(0, 3, null)") +var group = createGroup(); +trace("result: " + group.replaceElements(0, 3, null)); +for (var i = 0; i < group.elementCount; i++) { + trace(i + " "+ group.getElementAt(i).text); +} + +/* +trace("/// replaceElements(3, 0, null)") +var group = createGroup(); +trace("result: " + group.replaceElements(3, 0, null)); +for (var i = 0; i < group.elementCount; i++) { + trace(i + " " + group.getElementAt(i)); +} +*/ + +trace("/// replaceElements(1, 1, replacement)") +var group = createGroup(); +var replacement = new Vector.; +replacement.push(new TextElement("foobar")); +trace("result: " + group.replaceElements(1, 1, replacement)); +for (var i = 0; i < group.elementCount; i++) { + trace(i + " "+ group.getElementAt(i).text); +} + +trace("/// replaceElements(1, 2, replacement)") +var group = createGroup(); +var replacement = new Vector.; +replacement.push(new TextElement("foobar")); +trace("result: " + group.replaceElements(1, 2, replacement)); +for (var i = 0; i < group.elementCount; i++) { + trace(i + " "+ group.getElementAt(i).text); +} + +trace("/// replaceElements(3, 3, replacement)") +var group = createGroup(); +var replacement = new Vector.; +replacement.push(new TextElement("foobar")); +trace("result: " + group.replaceElements(3, 3, replacement)); +for (var i = 0; i < group.elementCount; i++) { + trace(i + " "+ group.getElementAt(i).text); +} + +trace("/// replaceElements(1, 1, replacements)") +var group = createGroup(); +var replacements = new Vector.(); +replacements.push(new TextElement("11111")); +replacements.push(new TextElement("22222")); +trace("result: " + group.replaceElements(1, 1, replacements)); +for (var i = 0; i < group.elementCount; i++) { + trace(i + " "+ group.getElementAt(i).text); +} + +trace("/// replaceElements(1, 2, replacements)") +var group = createGroup(); +var replacements = new Vector.(); +replacements.push(new TextElement("11111")); +replacements.push(new TextElement("22222")); +trace("result: " + group.replaceElements(1, 2, replacements)); +for (var i = 0; i < group.elementCount; i++) { + trace(i + " "+ group.getElementAt(i).text); +} + +trace("/// splitTextElement(1, 2)"); +var group = createGroup(); +trace("result: " + group.splitTextElement(1, 2).text); +for (var i = 0; i < group.elementCount; i++) { + trace(i + " "+ group.getElementAt(i).text); +} + +trace("/// replaceElements (begin index out-of-bounds)"); +try { + var group = createGroup(); + group.replaceElements(42, 43, null); +} catch (e) { + trace(e) +} + +trace("/// replaceElements (end index out-of-bounds)") +try { + var group = createGroup(); + var replacement = new Vector.; + replacement.push(new TextElement("foobar")); + replacement.push(new TextElement("hello world")); + group.replaceElements(3, 4, replacement); +} catch (e) { + trace(e); +} + +trace("/// getElementAt (out-of-bounds)"); +try { + var group = createGroup(); + group.getElementAt(42); +} catch (e) { + trace(e) +} + +trace("/// splitTextElement (element index out-of-bounds)"); +try { + var group = createGroup(); + group.splitTextElement(42, 0); +} catch (e) { + trace(e) +} + +trace("/// splitTextElement (text index out-of-bounds)"); +try { + var group = createGroup(); + group.splitTextElement(0, 42); +} catch (e) { + trace(e) +} + +trace("/// splitTextElement (not TextElement)"); +var vector = new Vector.() +vector.push(new GroupElement()) +var group = new GroupElement(vector); +try { + group.splitTextElement(0, 1); +} catch (e) { + trace(e); +} \ No newline at end of file diff --git a/tests/tests/swfs/avm2/text_engine_groupelement/output.txt b/tests/tests/swfs/avm2/text_engine_groupelement/output.txt new file mode 100644 index 000000000000..3e51d6a3aae8 --- /dev/null +++ b/tests/tests/swfs/avm2/text_engine_groupelement/output.txt @@ -0,0 +1,64 @@ +/// replaceElements(0, 0, null) +result: null +0 aaaaa +1 bbbbb +2 ccccc +/// replaceElements(50, 50, null) +result: null +0 aaaaa +1 bbbbb +2 ccccc +/// replaceElements(0, 1, null) +result: [object TextElement] +0 bbbbb +1 ccccc +/// replaceElements(0, 3, null) +result: [object TextElement],[object TextElement],[object TextElement] +/// replaceElements(1, 1, replacement) +result: +0 aaaaa +1 foobar +2 bbbbb +3 ccccc +/// replaceElements(1, 2, replacement) +result: [object TextElement] +0 aaaaa +1 foobar +2 ccccc +/// replaceElements(3, 3, replacement) +result: +0 aaaaa +1 bbbbb +2 ccccc +3 foobar +/// replaceElements(1, 1, replacements) +result: +0 aaaaa +1 11111 +2 22222 +3 bbbbb +4 ccccc +/// replaceElements(1, 2, replacements) +result: [object TextElement] +0 aaaaa +1 11111 +2 22222 +3 ccccc +/// splitTextElement(1, 2) +result: bbb +0 aaaaa +1 bb +2 bbb +3 ccccc +/// replaceElements (begin index out-of-bounds) +RangeError: Error #2006: The supplied index is out of bounds. +/// replaceElements (end index out-of-bounds) +RangeError: Error #2006: The supplied index is out of bounds. +/// getElementAt (out-of-bounds) +RangeError: Error #2006: The supplied index is out of bounds. +/// splitTextElement (element index out-of-bounds) +RangeError: Error #2006: The supplied index is out of bounds. +/// splitTextElement (text index out-of-bounds) +RangeError: Error #2006: The supplied index is out of bounds. +/// splitTextElement (not TextElement) +ArgumentError: Error #2004: One of the parameters is invalid. diff --git a/tests/tests/swfs/avm2/text_engine_groupelement/test.swf b/tests/tests/swfs/avm2/text_engine_groupelement/test.swf new file mode 100644 index 000000000000..d2d683ee4052 Binary files /dev/null and b/tests/tests/swfs/avm2/text_engine_groupelement/test.swf differ diff --git a/tests/tests/swfs/avm2/text_engine_groupelement/test.toml b/tests/tests/swfs/avm2/text_engine_groupelement/test.toml new file mode 100644 index 000000000000..dbee897f5863 --- /dev/null +++ b/tests/tests/swfs/avm2/text_engine_groupelement/test.toml @@ -0,0 +1 @@ +num_frames = 1