diff options
-rw-r--r-- | sw/qa/complex/writer/TextPortionEnumerationTest.java | 331 | ||||
-rw-r--r-- | sw/qa/python/text_portion_enumeration_test.py | 353 |
2 files changed, 353 insertions, 331 deletions
diff --git a/sw/qa/complex/writer/TextPortionEnumerationTest.java b/sw/qa/complex/writer/TextPortionEnumerationTest.java index 266134ffb7a3..0866ec897d51 100644 --- a/sw/qa/complex/writer/TextPortionEnumerationTest.java +++ b/sw/qa/complex/writer/TextPortionEnumerationTest.java @@ -1258,337 +1258,6 @@ public class TextPortionEnumerationTest util.DesktopTools.closeDoc(m_xDoc); } - @Test public void testRangeHyperlinkMeta() throws Exception - { - RangeInserter inserter = new RangeInserter(m_xDoc); - TreeNode text = new TextNode("123456789"); - inserter.insertRange( new Range(0, 0, text) ); - TreeNode url1 = new HyperlinkNode( mkName("url") ); - inserter.insertRange( new Range(1, 4, url1) ); - // overlap left - TreeNode met2 = new MetaNode( mkId("id") ); - inserter.insertRange( new Range(0, 2, met2) ); - TreeNode root = new TreeNode() - .appendChild( met2.dup() - .appendChild( new TextNode("1") ) - .appendChild( url1.dup().appendChild( new TextNode("2") ) ) ) - .appendChild( url1.dup().appendChild( new TextNode("34") ) ) - .appendChild( new TextNode("56789") ); - doTest(root, false); - // overlap right - TreeNode met3 = new MetaNode( mkId("id") ); - inserter.insertRange( new Range(4/*-1*/, 6/*-1*/, met3) ); - root = new TreeNode() - .appendChild( met2.dup() - .appendChild( new TextNode("1") ) - .appendChild( url1.dup().appendChild( new TextNode("2") ) ) ) - .appendChild( url1.dup().appendChild( new TextNode("3") ) ) - .appendChild( met3.dup() - .appendChild( url1.dup().appendChild( new TextNode("4") ) ) - .appendChild( new TextNode("5") ) ) - .appendChild( new TextNode("6789") ); - doTest(root, false); - // around - TreeNode met4 = new MetaNode( mkId("id") ); - inserter.insertRange( new Range(3/*-1*/, 4/*-1*/, met4) ); - root = new TreeNode() - .appendChild( met2.dup() - .appendChild( new TextNode("1") ) - .appendChild( url1.dup().appendChild( new TextNode("2") ) ) ) - .appendChild( met4.dup() - .appendChild( url1.dup().appendChild( new TextNode("3") ) ) ) - .appendChild( met3.dup() - .appendChild( url1.dup().appendChild( new TextNode("4") ) ) - .appendChild( new TextNode("5") ) ) - .appendChild( new TextNode("6789") ); - doTest(root, false); - // inside - TreeNode url5 = new HyperlinkNode( mkName("url") ); - inserter.insertRange( new Range(9/*-3*/, 12/*-3*/, url5) ); - TreeNode met6 = new MetaNode( mkId("id") ); - inserter.insertRange( new Range(10/*-3*/, 11/*-3*/, met6) ); - root = new TreeNode() - .appendChild( met2.dup() - .appendChild( new TextNode("1") ) - .appendChild( url1.dup().appendChild( new TextNode("2") ) ) ) - .appendChild( met4.dup() - .appendChild( url1.dup().appendChild( new TextNode("3") ) ) ) - .appendChild( met3.dup() - .appendChild( url1.dup().appendChild( new TextNode("4") ) ) - .appendChild( new TextNode("5") ) ) - .appendChild( new TextNode("6") ) - .appendChild( url5.dup().appendChild( new TextNode("7") ) ) - .appendChild( met6.dup() - .appendChild( url5.dup().appendChild( new TextNode("8") ) ) ) - .appendChild( url5.dup().appendChild( new TextNode("9") ) ); - doTest(root, false); - } - - @Test public void testRangeRubyMeta() throws Exception - { - RangeInserter inserter = new RangeInserter(m_xDoc); - TreeNode text = new TextNode("123456789"); - inserter.insertRange( new Range(0, 0, text) ); - TreeNode rby1 = new RubyNode( mkName("ruby") ); - inserter.insertRange( new Range(1, 4, rby1) ); - // overlap left - TreeNode met2 = new MetaNode( mkId("id") ); - inserter.insertRange( new Range(0, 2, met2) ); - TreeNode root = new TreeNode() - .appendChild( met2.dup() - .appendChild( new TextNode("1") ) - .appendChild( rby1.dup().appendChild( new TextNode("2") ) ) ) - .appendChild( rby1.dup().appendChild( new TextNode("34") ) ) - .appendChild( new TextNode("56789") ); - doTest(root, false); - // overlap right - TreeNode met3 = new MetaNode( mkId("id") ); - inserter.insertRange( new Range(4/*-1*/, 6/*-1*/, met3) ); - root = new TreeNode() - .appendChild( met2.dup() - .appendChild( new TextNode("1") ) - .appendChild( rby1.dup().appendChild( new TextNode("2") ) ) ) - .appendChild( rby1.dup().appendChild( new TextNode("3") ) ) - .appendChild( met3.dup() - .appendChild( rby1.dup().appendChild( new TextNode("4") ) ) - .appendChild( new TextNode("5") ) ) - .appendChild( new TextNode("6789") ); - doTest(root, false); - // around - TreeNode met4 = new MetaNode( mkId("id") ); - inserter.insertRange( new Range(3/*-1*/, 4/*-1*/, met4) ); - root = new TreeNode() - .appendChild( met2.dup() - .appendChild( new TextNode("1") ) - .appendChild( rby1.dup().appendChild( new TextNode("2") ) ) ) - .appendChild( met4.dup() - .appendChild( rby1.dup().appendChild( new TextNode("3") ) ) ) - .appendChild( met3.dup() - .appendChild( rby1.dup().appendChild( new TextNode("4") ) ) - .appendChild( new TextNode("5") ) ) - .appendChild( new TextNode("6789") ); - doTest(root, false); - // inside - TreeNode rby5 = new RubyNode( mkName("ruby") ); - inserter.insertRange( new Range(9/*-3*/, 12/*-3*/, rby5) ); - TreeNode met6 = new MetaNode( mkId("id") ); - inserter.insertRange( new Range(10/*-3*/, 11/*-3*/, met6) ); - root = new TreeNode() - .appendChild( met2.dup() - .appendChild( new TextNode("1") ) - .appendChild( rby1.dup().appendChild( new TextNode("2") ) ) ) - .appendChild( met4.dup() - .appendChild( rby1.dup().appendChild( new TextNode("3") ) ) ) - .appendChild( met3.dup() - .appendChild( rby1.dup().appendChild( new TextNode("4") ) ) - .appendChild( new TextNode("5") ) ) - .appendChild( new TextNode("6") ) - .appendChild( rby5.dup() - .appendChild( new TextNode("7") ) - .appendChild( met6.dup() - .appendChild( new TextNode("8") ) ) - .appendChild( new TextNode("9") ) ); - doTest(root, false); - } - - @Test public void testRangeMetaHyperlink() throws Exception - { - RangeInserter inserter = new RangeInserter(m_xDoc); - TreeNode text = new TextNode("123456789"); - inserter.insertRange( new Range(0, 0, text) ); - TreeNode met1 = new MetaNode( mkId("id") ); - inserter.insertRange( new Range(1, 6, met1) ); - // overlap left - TreeNode url2 = new HyperlinkNode( mkName("url") ); - inserter.insertRange( new Range(0, 4/*-1*/, url2) ); - TreeNode root = new TreeNode() - .appendChild( url2.dup().appendChild( new TextNode("1") ) ) - .appendChild( met1.dup() - .appendChild( url2.dup().appendChild( new TextNode("23") ) ) - .appendChild( new TextNode("456") ) ) - .appendChild( new TextNode("789") ); - doTest(root, false); - // overlap right - TreeNode url3 = new HyperlinkNode( mkName("url") ); - inserter.insertRange( new Range(6/*-1*/, 8/*-1*/, url3) ); - root = new TreeNode() - .appendChild( url2.dup().appendChild( new TextNode("1") ) ) - .appendChild( met1.dup() - .appendChild( url2.dup().appendChild( new TextNode("23") ) ) - .appendChild( new TextNode("45") ) - .appendChild( url3.dup().appendChild( new TextNode("6") ) ) ) - .appendChild( url3.dup().appendChild( new TextNode("7") ) ) - .appendChild( new TextNode("89") ); - doTest(root, false); - // around (not quite, due to API) - TreeNode url4 = new HyperlinkNode( mkName("url") ); - inserter.insertRange( new Range(1, 9/*-1*/, url4) ); - root = new TreeNode() - .appendChild( url2.dup().appendChild( new TextNode("1") ) ) - .appendChild( met1.dup() - .appendChild( url4.dup() - .appendChild( new TextNode("23456") ) ) ) - .appendChild( url4.dup().appendChild( new TextNode("78") ) ) - .appendChild( new TextNode("9") ); - doTest(root, false); - // inside - TreeNode url5 = new HyperlinkNode( mkName("url") ); - inserter.insertRange( new Range(4/*-1*/, 6/*-1*/, url5) ); - root = new TreeNode() - .appendChild( url2.dup().appendChild( new TextNode("1") ) ) - .appendChild( met1.dup() - .appendChild( url4.dup() - .appendChild( new TextNode("23") ) ) - .appendChild( url5.dup() - .appendChild( new TextNode("45") ) ) - .appendChild( url4.dup() - .appendChild( new TextNode("6") ) ) ) - .appendChild( url4.dup().appendChild( new TextNode("78") ) ) - .appendChild( new TextNode("9") ); - doTest(root, false); - } - - @Test public void testRangeMetaRuby() throws Exception - { - RangeInserter inserter = new RangeInserter(m_xDoc); - TreeNode text = new TextNode("123456789"); - inserter.insertRange( new Range(0, 0, text) ); - TreeNode met1 = new MetaNode( mkId("id") ); - inserter.insertRange( new Range(1, 5, met1) ); - // overlap left - TreeNode rby2 = new RubyNode( mkName("ruby") ); - inserter.insertRange( new Range(0, 3/*-1*/, rby2) ); - TreeNode root = new TreeNode() - .appendChild( rby2.dup().appendChild( new TextNode("1") ) ) - .appendChild( met1.dup() - .appendChild( rby2.dup().appendChild( new TextNode("2") ) ) - .appendChild( new TextNode("345") ) ) - .appendChild( new TextNode("6789") ); - doTest(root, false); - // overlap right - TreeNode rby3 = new RubyNode( mkName("ruby") ); - inserter.insertRange( new Range(5/*-1*/, 7/*-1*/, rby3) ); - root = new TreeNode() - .appendChild( rby2.dup().appendChild( new TextNode("1") ) ) - .appendChild( met1.dup() - .appendChild( rby2.dup().appendChild( new TextNode("2") ) ) - .appendChild( new TextNode("34") ) - .appendChild( rby3.dup().appendChild( new TextNode("5") ) ) ) - .appendChild( rby3.dup().appendChild( new TextNode("6") ) ) - .appendChild( new TextNode("789") ); - doTest(root, false); - // around - TreeNode rby4 = new RubyNode( mkName("ruby") ); - inserter.insertRange( new Range(1, 7/*-1*/, rby4) ); - root = new TreeNode() - .appendChild( rby2.dup().appendChild( new TextNode("1") ) ) - .appendChild( rby4.dup() - .appendChild( met1.dup() - .appendChild( new TextNode("2345") ) ) - .appendChild( new TextNode("6") ) ) - .appendChild( new TextNode("789") ); - doTest(root, false); - // inside - TreeNode met5 = new MetaNode( mkId("id") ); - inserter.insertRange( new Range(7/*-1*/, 9/*-1*/, met5) ); - TreeNode rby6 = new RubyNode( mkName("ruby") ); - inserter.insertRange( new Range(9/*-2*/, 10/*-2*/, rby6) ); - root = new TreeNode() - .appendChild( rby2.dup().appendChild( new TextNode("1") ) ) - .appendChild( rby4.dup() - .appendChild( met1.dup() - .appendChild( new TextNode("2345") ) ) - .appendChild( new TextNode("6") ) ) - .appendChild( met5.dup() - .appendChild( new TextNode("7") ) - .appendChild( rby6.dup() - .appendChild( new TextNode("8") ) ) ) - .appendChild( new TextNode("9") ); - doTest(root, false); - // inside, with invalid range that includes the dummy char - TreeNode rby7 = new RubyNode( mkName("ruby") ); - inserter.insertRange( new Range(7/*-1*/, 9/*-2*/, rby7) ); - root = new TreeNode() - .appendChild( rby2.dup().appendChild( new TextNode("1") ) ) - .appendChild( rby4.dup() - .appendChild( met1.dup() - .appendChild( new TextNode("2345") ) ) - .appendChild( new TextNode("6") ) ) - .appendChild( met5.dup() - .appendChild( rby7.dup() - .appendChild( new TextNode("7") ) ) - .appendChild( rby6.dup() - .appendChild( new TextNode("8") ) ) ) - .appendChild( new TextNode("9") ); - doTest(root, false); - // around, at same position as meta - TreeNode rby8 = new RubyNode( mkName("ruby") ); - inserter.insertRange( new Range(7/*-1*/, 10/*-2*/, rby8) ); - root = new TreeNode() - .appendChild( rby2.dup().appendChild( new TextNode("1") ) ) - .appendChild( rby4.dup() - .appendChild( met1.dup() - .appendChild( new TextNode("2345") ) ) - .appendChild( new TextNode("6") ) ) - .appendChild( rby8.dup() - .appendChild( met5.dup() - .appendChild( new TextNode("78") ) ) ) - .appendChild( new TextNode("9") ); - doTest(root, false); - } - - @Test public void testRangeMetaMeta() throws Exception - { - RangeInserter inserter = new RangeInserter(m_xDoc); - TreeNode text = new TextNode("123456789"); - inserter.insertRange( new Range(0, 0, text) ); - TreeNode met1 = new MetaNode( mkId("id") ); - inserter.insertRange( new Range(3, 6, met1) ); - // overlap left - TreeNode met2 = new MetaNode( mkId("id") ); - try { - inserter.insertRange( new Range(0, 4, met2) ); - fail("testRangeMetaMeta: overlap left allowed"); - } catch (com.sun.star.lang.IllegalArgumentException e) { /* ignore */ } - TreeNode root = new TreeNode() - .appendChild( new TextNode("123") ) - .appendChild( met1.dup().appendChild( new TextNode("456") ) ) - .appendChild( new TextNode("789") ); - doTest(root, false); - // overlap right - TreeNode met3 = new MetaNode( mkId("id") ); - try { - inserter.insertRange( new Range(5/*-1*/, 8/*-1*/, met3) ); - fail("testRangeMetaMeta: overlap right allowed"); - } catch (com.sun.star.lang.IllegalArgumentException e) { /* ignore */ } - root = new TreeNode() - .appendChild( new TextNode("123") ) - .appendChild( met1.dup().appendChild( new TextNode("456") ) ) - .appendChild( new TextNode("789") ); - doTest(root, false); - // around - TreeNode met4 = new MetaNode( mkId("id") ); - inserter.insertRange( new Range(3, 7/*-1*/, met4) ); - root = new TreeNode() - .appendChild( new TextNode("123") ) - .appendChild( met4.dup() - .appendChild( met1.dup().appendChild( new TextNode("456") ) ) ) - .appendChild( new TextNode("789") ); - doTest(root, false); - // inside - TreeNode met5 = new MetaNode( mkId("id") ); - inserter.insertRange( new Range(6/*-2*/, 8/*-2*/, met5) ); - root = new TreeNode() - .appendChild( new TextNode("123") ) - .appendChild( met4.dup() - .appendChild( met1.dup() - .appendChild( new TextNode("4") ) - .appendChild( met5.dup() - .appendChild( new TextNode("56") ) ) ) ) - .appendChild( new TextNode("789") ); - doTest(root, false); - } - @Test public void testRange2() throws Exception { RangeInserter inserter = new RangeInserter(m_xDoc); diff --git a/sw/qa/python/text_portion_enumeration_test.py b/sw/qa/python/text_portion_enumeration_test.py index 856fdb7571e9..e6bec7230020 100644 --- a/sw/qa/python/text_portion_enumeration_test.py +++ b/sw/qa/python/text_portion_enumeration_test.py @@ -628,6 +628,12 @@ class RangeInserter(Inserter): elif nodetype == "Ruby": ruby = node self.insertruby(xParaCursor, ruby.ruby) + elif nodetype == "InContentMetadata": + meta = node + return self.insertmeta(xParaCursor, meta.xmlid) + elif nodetype == "MetadataField": + meta = node + return self.insertmetafield(xParaCursor, meta.xmlid) elif nodetype == "SoftPageBreak": raise RuntimeError("sorry, cannot test SoftPageBreak") else: @@ -1776,6 +1782,353 @@ class TextPortionEnumerationTest(unittest.TestCase): root.appendchild(TextNode("89")) self.dotest(root, False) + def test_range_hyperlink_meta(self): + inserter = RangeInserter(self.__class__.xDoc) + text = TextNode("123456789") + inserter.insertrange(Range(0, 0, text)) + url1 = HyperlinkNode(self.mkname("url")) + inserter.insertrange(Range(1, 4, url1)) + ## overlap left + met2 = MetaNode(self.mkid("id")) + inserter.insertrange(Range(0, 2, met2)) + root = TreeNode() + root.appendchild(met2.dup() + .appendchild(TextNode("1")) + .appendchild(url1.dup().appendchild(TextNode("2")))) + root.appendchild(url1.dup().appendchild(TextNode("34"))) + root.appendchild(TextNode("56789")) + self.dotest(root, False) + ## overlap right + met3 = MetaNode(self.mkid("id")) + # inserter.insertrange(Range(4-1, 6-1, met3)) + inserter.insertrange(Range(4, 6, met3)) + root = TreeNode() + root.appendchild(met2.dup() + .appendchild(TextNode("1")) + .appendchild(url1.dup().appendchild(TextNode("2")))) + root.appendchild(url1.dup().appendchild(TextNode("3"))) + root.appendchild(met3.dup() + .appendchild(url1.dup().appendchild(TextNode("4"))) + .appendchild(TextNode("5"))) + root.appendchild(TextNode("6789")) + self.dotest(root, False) + ## around + met4 = MetaNode(self.mkid("id")) + # inserter.insertrange(Range(3-1, 4-1, met4)) + inserter.insertrange(Range(3, 4, met4)) + root = TreeNode() + root.appendchild(met2.dup() + .appendchild(TextNode("1")) + .appendchild(url1.dup().appendchild(TextNode("2")))) + root.appendchild(met4.dup() + .appendchild(url1.dup().appendchild(TextNode("3")))) + root.appendchild(met3.dup() + .appendchild(url1.dup().appendchild(TextNode("4"))) + .appendchild(TextNode("5"))) + root.appendchild(TextNode("6789")) + self.dotest(root, False) + ## inside + url5 = HyperlinkNode(self.mkname("url")) + # inserter.insertrange(Range(9-3, 12-3, url5)) + inserter.insertrange(Range(9, 12, url5)) + met6 = MetaNode(self.mkid("id")) + # inserter.insertrange(Range(10-3, 11-3, met6)) + inserter.insertrange(Range(10, 11, met6)) + root = TreeNode() + root.appendchild(met2.dup() + .appendchild(TextNode("1")) + .appendchild(url1.dup().appendchild(TextNode("2")))) + root.appendchild(met4.dup() + .appendchild(url1.dup().appendchild(TextNode("3")))) + root.appendchild(met3.dup() + .appendchild(url1.dup().appendchild(TextNode("4"))) + .appendchild(TextNode("5"))) + root.appendchild(TextNode("6")) + root.appendchild(url5.dup().appendchild(TextNode("7"))) + root.appendchild(met6.dup() + .appendchild(url5.dup().appendchild(TextNode("8")))) + root.appendchild(url5.dup().appendchild(TextNode("9"))) + self.dotest(root, False) + + def test_range_ruby_meta(self): + inserter = RangeInserter(self.__class__.xDoc) + text = TextNode("123456789") + inserter.insertrange(Range(0, 0, text)) + rby1 = RubyNode(self.mkname("ruby")) + inserter.insertrange(Range(1, 4, rby1)) + ## overlap left + met2 = MetaNode(self.mkid("id")) + inserter.insertrange(Range(0, 2, met2)) + root = TreeNode() + root.appendchild(met2.dup() + .appendchild(TextNode("1")) + .appendchild(rby1.dup().appendchild(TextNode("2")))) + root.appendchild(rby1.dup().appendchild(TextNode("34"))) + root.appendchild(TextNode("56789")) + self.dotest(root, False) + ## overlap right + met3 = MetaNode(self.mkid("id")) + # inserter.insertrange(Range(4-1, 6-1, met3)) + inserter.insertrange(Range(4, 6, met3)) + root = TreeNode() + root.appendchild(met2.dup() + .appendchild(TextNode("1")) + .appendchild(rby1.dup().appendchild(TextNode("2")))) + root.appendchild(rby1.dup().appendchild(TextNode("3"))) + root.appendchild(met3.dup() + .appendchild(rby1.dup().appendchild(TextNode("4"))) + .appendchild(TextNode("5"))) + root.appendchild(TextNode("6789")) + self.dotest(root, False) + ## around + met4 = MetaNode(self.mkid("id")) + # inserter.insertrange(Range(3-1, 4-1, met4)) + inserter.insertrange(Range(3, 4, met4)) + root = TreeNode() + root.appendchild(met2.dup() + .appendchild(TextNode("1")) + .appendchild(rby1.dup().appendchild(TextNode("2")))) + root.appendchild(met4.dup() + .appendchild(rby1.dup().appendchild(TextNode("3")))) + root.appendchild(met3.dup() + .appendchild(rby1.dup().appendchild(TextNode("4"))) + .appendchild(TextNode("5"))) + root.appendchild(TextNode("6789")) + self.dotest(root, False) + ## inside + rby5 = RubyNode(self.mkname("ruby")) + # inserter.insertrange(Range(9-3, 12-3, rby5)) + inserter.insertrange(Range(9, 12, rby5)) + met6 = MetaNode(self.mkid("id")) + # inserter.insertrange(Range(10-3, 11-3, met6)) + inserter.insertrange(Range(10, 11, met6)) + root = TreeNode() + root.appendchild(met2.dup() + .appendchild(TextNode("1")) + .appendchild(rby1.dup().appendchild(TextNode("2")))) + root.appendchild(met4.dup() + .appendchild(rby1.dup().appendchild(TextNode("3")))) + root.appendchild(met3.dup() + .appendchild(rby1.dup().appendchild(TextNode("4"))) + .appendchild(TextNode("5"))) + root.appendchild(TextNode("6")) + root.appendchild(rby5.dup() + .appendchild(TextNode("7")) + .appendchild(met6.dup() + .appendchild(TextNode("8"))) + .appendchild(TextNode("9"))) + self.dotest(root, False) + + def test_range_meta_hyperlink(self): + inserter = RangeInserter(self.__class__.xDoc) + text = TextNode("123456789") + inserter.insertrange(Range(0, 0, text)) + met1 = MetaNode(self.mkid("id")) + inserter.insertrange(Range(1, 6, met1)) + ## overlap left + url2 = HyperlinkNode(self.mkname("url")) + # inserter.insertrange(Range(0, 4-1, url2)) + inserter.insertrange(Range(0, 4, url2)) + root = TreeNode() + root.appendchild(url2.dup().appendchild(TextNode("1"))) + root.appendchild(met1.dup() + .appendchild(url2.dup().appendchild(TextNode("23"))) + .appendchild(TextNode("456"))) + root.appendchild(TextNode("789")) + self.dotest(root, False) + ## overlap right + url3 = HyperlinkNode(self.mkname("url")) + # inserter.insertrange(Range(6-1, 8-1, url3)) + inserter.insertrange(Range(6, 8, url3)) + root = TreeNode() + root.appendchild(url2.dup().appendchild(TextNode("1"))) + root.appendchild(met1.dup() + .appendchild(url2.dup().appendchild(TextNode("23"))) + .appendchild(TextNode("45")) + .appendchild(url3.dup().appendchild(TextNode("6")))) + root.appendchild(url3.dup().appendchild(TextNode("7"))) + root.appendchild(TextNode("89")) + self.dotest(root, False) + ## around (not quite, due to API) + url4 = HyperlinkNode(self.mkname("url")) + # inserter.insertrange(Range(1, 9-1, url4)) + inserter.insertrange(Range(1, 9, url4)) + root = TreeNode() + root.appendchild(url2.dup().appendchild(TextNode("1"))) + root.appendchild(met1.dup() + .appendchild(url4.dup() + .appendchild(TextNode("23456")))) + root.appendchild(url4.dup().appendchild(TextNode("78"))) + root.appendchild(TextNode("9")) + self.dotest(root, False) + ## inside + url5 = HyperlinkNode(self.mkname("url")) + # inserter.insertrange(Range(4-1, 6-1, url5)) + inserter.insertrange(Range(4, 6, url5)) + root = TreeNode() + root.appendchild(url2.dup().appendchild(TextNode("1"))) + root.appendchild(met1.dup() + .appendchild(url4.dup() + .appendchild(TextNode("23"))) + .appendchild(url5.dup() + .appendchild(TextNode("45"))) + .appendchild(url4.dup() + .appendchild(TextNode("6")))) + root.appendchild(url4.dup().appendchild(TextNode("78"))) + root.appendchild(TextNode("9")) + self.dotest(root, False) + + def test_range_meta_ruby(self): + inserter = RangeInserter(self.__class__.xDoc) + text = TextNode("123456789") + inserter.insertrange(Range(0, 0, text)) + met1 = MetaNode(self.mkid("id")) + inserter.insertrange(Range(1, 5, met1)) + ## overlap left + rby2 = RubyNode(self.mkname("ruby")) + # inserter.insertrange(Range(0, 3-1, rby2)) + inserter.insertrange(Range(0, 3, rby2)) + root = TreeNode() + root.appendchild(rby2.dup().appendchild(TextNode("1"))) + root.appendchild(met1.dup() + .appendchild(rby2.dup().appendchild(TextNode("2"))) + .appendchild(TextNode("345"))) + root.appendchild(TextNode("6789")) + self.dotest(root, False) + ## overlap right + rby3 = RubyNode(self.mkname("ruby")) + # inserter.insertrange(Range(5-1, 7-1, rby3)) + inserter.insertrange(Range(5, 7, rby3)) + root = TreeNode() + root.appendchild(rby2.dup().appendchild(TextNode("1"))) + root.appendchild(met1.dup() + .appendchild(rby2.dup().appendchild(TextNode("2"))) + .appendchild(TextNode("34")) + .appendchild(rby3.dup().appendchild(TextNode("5")))) + root.appendchild(rby3.dup().appendchild(TextNode("6"))) + root.appendchild(TextNode("789")) + self.dotest(root, False) + ## // around + rby4 = RubyNode(self.mkname("ruby")) + # inserter.insertrange(Range(1, 7-1, rby4)) + inserter.insertrange(Range(1, 7, rby4)) + root = TreeNode() + root.appendchild(rby2.dup().appendchild(TextNode("1"))) + root.appendchild(rby4.dup() + .appendchild(met1.dup() + .appendchild(TextNode("2345"))) + .appendchild(TextNode("6"))) + root.appendchild(TextNode("789")) + self.dotest(root, False) + ## inside + met5 = MetaNode(self.mkid("id")) + # inserter.insertrange(Range(7-1, 9-1, met5)) + inserter.insertrange(Range(7, 9, met5)) + rby6 = RubyNode(self.mkname("ruby")) + # inserter.insertrange(Range(9-2, 10/-2, rby6)) + inserter.insertrange(Range(9, 10, rby6)) + root = TreeNode() + root.appendchild(rby2.dup().appendchild(TextNode("1"))) + root.appendchild(rby4.dup() + .appendchild(met1.dup() + .appendchild(TextNode("2345"))) + .appendchild(TextNode("6"))) + root.appendchild(met5.dup() + .appendchild(TextNode("7")) + .appendchild(rby6.dup() + .appendchild(TextNode("8")))) + root.appendchild(TextNode("9")) + self.dotest(root, False) + ## inside, with invalid range that includes the dummy char + rby7 = RubyNode(self.mkname("ruby")) + # inserter.insertrange(Range(7-1, 9-2, rby7)) + inserter.insertrange(Range(7, 9, rby7)) + root = TreeNode() + root.appendchild(rby2.dup().appendchild(TextNode("1"))) + root.appendchild(rby4.dup() + .appendchild(met1.dup() + .appendchild(TextNode("2345"))) + .appendchild(TextNode("6"))) + root.appendchild(met5.dup() + .appendchild(rby7.dup() + .appendchild(TextNode("7"))) + .appendchild(rby6.dup() + .appendchild(TextNode("8")))) + root.appendchild(TextNode("9")) + self.dotest(root, False) + ## around, at same position as meta + rby8 = RubyNode(self.mkname("ruby")) + # inserter.insertrange(Range(7-1, 10-2, rby8)) + inserter.insertrange(Range(7, 10, rby8)) + root = TreeNode() + root.appendchild(rby2.dup().appendchild(TextNode("1"))) + root.appendchild(rby4.dup() + .appendchild(met1.dup() + .appendchild(TextNode("2345"))) + .appendchild(TextNode("6"))) + root.appendchild(rby8.dup() + .appendchild(met5.dup() + .appendchild(TextNode("78")))) + root.appendchild(TextNode("9")) + self.dotest(root, False) + + def test_range_meta_meta(self): + inserter = RangeInserter(self.__class__.xDoc) + text = TextNode("123456789") + inserter.insertrange(Range(0, 0, text)) + met1 = MetaNode(self.mkid("id")) + inserter.insertrange(Range(3, 6, met1)) + ## overlap left + met2 = MetaNode(self.mkid("id")) + try: + inserter.insertrange(Range(0, 4, met2)) + fail("testRangeMetaMeta: overlap left allowed") + except IllegalArgumentException: + pass + root = TreeNode() + root.appendchild(TextNode("123")) + root.appendchild(met1.dup().appendchild(TextNode("456"))) + root.appendchild(TextNode("789")) + self.dotest(root, False) + ## overlap right + met3 = MetaNode(self.mkid("id")) + + try: + # inserter.insertrange(Range(5-1, 8-1, met3)) + inserter.insertrange(Range(5, 8, met3)) + self.fail("testRangeMetaMeta: overlap right allowed") + except IllegalArgumentException: + pass + + root = TreeNode() + root.appendchild(TextNode("123")) + root.appendchild(met1.dup().appendchild(TextNode("456"))) + root.appendchild(TextNode("789")) + self.dotest(root, False) + ## around + met4 = MetaNode(self.mkid("id")) + # inserter.insertrange(Range(3, 7-1, met4)) + inserter.insertrange(Range(3, 7, met4)) + root = TreeNode() + root.appendchild(TextNode("123")) + root.appendchild(met4.dup() + .appendchild(met1.dup().appendchild(TextNode("456")))) + root.appendchild(TextNode("789")) + self.dotest(root, False) + ## inside + met5 = MetaNode(self.mkid("id")) + # inserter.insertrange(Range(6-2, 8-2, met5)) + inserter.insertrange(Range(6, 8, met5)) + root = TreeNode() + root.appendchild(TextNode("123")) + root.appendchild(met4.dup() + .appendchild(met1.dup() + .appendchild(TextNode("4")) + .appendchild(met5.dup() + .appendchild(TextNode("56"))))) + root.appendchild(TextNode("789")) + self.dotest(root, False) + def dotest(self, intree, insert=True): xDoc = self.__class__.xDoc self._dotest(xDoc, intree, insert) |