mirror of
https://github.com/geometer/FBReaderJ.git
synced 2025-10-03 09:49:19 +02:00
add some test on tree model
git-svn-id: https://only.mawhrin.net/repos/FBReaderJ/trunk@91 6a642e6f-84f6-412e-ac94-c4a38d5a04b0
This commit is contained in:
parent
b30df723a4
commit
65e878e276
2 changed files with 99 additions and 1 deletions
|
@ -1,6 +1,7 @@
|
||||||
package org.test.zlibrary.model;
|
package org.test.zlibrary.model;
|
||||||
|
|
||||||
import org.zlibrary.text.model.ZLTextTreeModel;
|
import org.zlibrary.text.model.ZLTextTreeModel;
|
||||||
|
import org.zlibrary.text.model.ZLTextTreeParagraph;
|
||||||
import org.zlibrary.text.model.impl.ZLModelFactory;
|
import org.zlibrary.text.model.impl.ZLModelFactory;
|
||||||
|
|
||||||
import junit.framework.TestCase;
|
import junit.framework.TestCase;
|
||||||
|
@ -10,6 +11,18 @@ public class TestTreeModel extends TestCase {
|
||||||
|
|
||||||
public void testCreateParagraph() {
|
public void testCreateParagraph() {
|
||||||
ZLTextTreeModel model = factory.createZLTextTreeModel();
|
ZLTextTreeModel model = factory.createZLTextTreeModel();
|
||||||
model.createParagraph(factory.createTreeParagraph());
|
ZLTextTreeParagraph parant = factory.createTreeParagraph();
|
||||||
|
ZLTextTreeParagraph paragraph = model.createParagraph(parant);
|
||||||
|
assertTrue(paragraph.getParent() == parant);
|
||||||
|
assertTrue(model.getParagraphsNumber() == 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testRemoveParagraph() {
|
||||||
|
ZLTextTreeModel model = factory.createZLTextTreeModel();
|
||||||
|
ZLTextTreeParagraph parant = factory.createTreeParagraph();
|
||||||
|
ZLTextTreeParagraph paragraph = model.createParagraph(parant);
|
||||||
|
model.removeParagraphInternal(0);
|
||||||
|
assertTrue(model.getParagraphsNumber() == 0);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
package org.test.zlibrary.model;
|
package org.test.zlibrary.model;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import org.zlibrary.text.model.ZLTextTreeParagraph;
|
import org.zlibrary.text.model.ZLTextTreeParagraph;
|
||||||
import org.zlibrary.text.model.impl.ZLModelFactory;
|
import org.zlibrary.text.model.impl.ZLModelFactory;
|
||||||
|
|
||||||
|
@ -16,4 +18,87 @@ public class TestTreeParagraph extends TestCase {
|
||||||
assertTrue(paragraph2.getDepth() == 1);
|
assertTrue(paragraph2.getDepth() == 1);
|
||||||
assertTrue(paragraph2.getParent() == paragraph);
|
assertTrue(paragraph2.getParent() == paragraph);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testIsOpen() {
|
||||||
|
ZLTextTreeParagraph paragraph = factory.createTreeParagraph();
|
||||||
|
assertTrue(!paragraph.isOpen());
|
||||||
|
paragraph.open(true);
|
||||||
|
assertTrue(paragraph.isOpen());
|
||||||
|
paragraph.open(false);
|
||||||
|
assertTrue(!paragraph.isOpen());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testOpenTree() {
|
||||||
|
ZLTextTreeParagraph paragraph = factory.createTreeParagraph();
|
||||||
|
ZLTextTreeParagraph paragraph2 = factory.createTreeParagraph(paragraph);
|
||||||
|
ZLTextTreeParagraph paragraph4 = factory.createTreeParagraph(paragraph2);
|
||||||
|
paragraph4.openTree();
|
||||||
|
assertTrue(paragraph2.isOpen());
|
||||||
|
assertTrue(paragraph.isOpen());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testGetDepth() {
|
||||||
|
ZLTextTreeParagraph paragraph = factory.createTreeParagraph();
|
||||||
|
ZLTextTreeParagraph paragraph2 = factory.createTreeParagraph(paragraph);
|
||||||
|
ZLTextTreeParagraph paragraph3 = factory.createTreeParagraph(paragraph);
|
||||||
|
ZLTextTreeParagraph paragraph4 = factory.createTreeParagraph(paragraph2);
|
||||||
|
assertTrue(paragraph.getDepth() == 0);
|
||||||
|
assertTrue(paragraph2.getDepth() == 1);
|
||||||
|
assertTrue(paragraph3.getDepth() == 1);
|
||||||
|
assertTrue(paragraph4.getDepth() == 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testGetParent() {
|
||||||
|
ZLTextTreeParagraph paragraph = factory.createTreeParagraph();
|
||||||
|
ZLTextTreeParagraph paragraph2 = factory.createTreeParagraph(paragraph);
|
||||||
|
ZLTextTreeParagraph paragraph3 = factory.createTreeParagraph(paragraph);
|
||||||
|
ZLTextTreeParagraph paragraph4 = factory.createTreeParagraph(paragraph2);
|
||||||
|
assertTrue(paragraph.getParent() == null);
|
||||||
|
assertTrue(paragraph2.getParent() == paragraph);
|
||||||
|
assertTrue(paragraph3.getParent() == paragraph);
|
||||||
|
assertTrue(paragraph4.getParent() == paragraph2);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testGetChildren() {
|
||||||
|
ZLTextTreeParagraph paragraph = factory.createTreeParagraph();
|
||||||
|
ZLTextTreeParagraph paragraph2 = factory.createTreeParagraph(paragraph);
|
||||||
|
ZLTextTreeParagraph paragraph3 = factory.createTreeParagraph(paragraph);
|
||||||
|
ZLTextTreeParagraph paragraph4 = factory.createTreeParagraph(paragraph2);
|
||||||
|
assertTrue(paragraph.getChildren().size() == 2);
|
||||||
|
assertTrue(paragraph.getChildren().contains(paragraph2));
|
||||||
|
assertTrue(paragraph.getChildren().contains(paragraph3));
|
||||||
|
assertTrue(paragraph2.getChildren().contains(paragraph4));
|
||||||
|
assertTrue(paragraph2.getChildren().size() == 1);
|
||||||
|
assertTrue(paragraph3.getChildren().size() == 0);
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
*
|
||||||
|
void removeFromParent();
|
||||||
|
*
|
||||||
|
* */
|
||||||
|
|
||||||
|
public void testGetFullSize() {
|
||||||
|
ZLTextTreeParagraph paragraph = factory.createTreeParagraph();
|
||||||
|
ZLTextTreeParagraph paragraph2 = factory.createTreeParagraph(paragraph);
|
||||||
|
ZLTextTreeParagraph paragraph3 = factory.createTreeParagraph(paragraph);
|
||||||
|
ZLTextTreeParagraph paragraph4 = factory.createTreeParagraph(paragraph2);
|
||||||
|
|
||||||
|
assertTrue(paragraph.getFullSize() == 4);
|
||||||
|
assertTrue(paragraph2.getFullSize() == 2);
|
||||||
|
assertTrue(paragraph3.getFullSize() == 1);
|
||||||
|
assertTrue(paragraph4.getFullSize() == 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testRemoveFromParent() {
|
||||||
|
ZLTextTreeParagraph paragraph = factory.createTreeParagraph();
|
||||||
|
ZLTextTreeParagraph paragraph2 = factory.createTreeParagraph(paragraph);
|
||||||
|
ZLTextTreeParagraph paragraph3 = factory.createTreeParagraph(paragraph);
|
||||||
|
ZLTextTreeParagraph paragraph4 = factory.createTreeParagraph(paragraph2);
|
||||||
|
paragraph4.removeFromParent();
|
||||||
|
assertTrue(paragraph4.getChildren().size() == 0);
|
||||||
|
paragraph2.removeFromParent();
|
||||||
|
assertTrue(paragraph2.getChildren().size() == 0);
|
||||||
|
paragraph.removeFromParent();
|
||||||
|
assertTrue(paragraph.getChildren().size() == 2);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue