use of com.orgzly.android.NotePosition in project orgzly-android by orgzly.
the class StructureTest method testCutNoteUnderFoldedThenPaste.
@Test
public void testCutNoteUnderFoldedThenPaste() throws IOException {
Book book = shelfTestUtils.setupBook("notebook", "" + "description\n" + "\n" + "* Note 1\n" + "** Note 1.1\n" + "*** Note 1.1.1\n");
/* Cut & paste hidden 1.1.1 */
shelf.toggleFoldedState(shelf.getNote("Note 1.1").getId());
shelf.cut(book.getId(), shelf.getNote("Note 1.1.1").getId());
Note n = shelf.getNote("Note 1");
shelf.paste(n.getPosition().getBookId(), n.getId(), Place.UNDER);
assertEquals("description\n" + "\n" + "* Note 1\n" + "** Note 1.1\n" + "** Note 1.1.1\n", shelf.getBookContent("notebook", BookName.Format.ORG));
NotePosition n1 = shelf.getNote("Note 1").getPosition();
NotePosition n11 = shelf.getNote("Note 1.1").getPosition();
NotePosition n111 = shelf.getNote("Note 1.1.1").getPosition();
assertEquals(0, n1.getFoldedUnderId());
assertEquals(0, n11.getFoldedUnderId());
assertEquals(0, n111.getFoldedUnderId());
}
use of com.orgzly.android.NotePosition in project orgzly-android by orgzly.
the class StructureTest method testDemote.
@Test
public void testDemote() throws IOException {
Book book = shelfTestUtils.setupBook("notebook", "" + "description\n" + "\n" + "* Note 1\n" + "** Note 1.1\n" + "* Note 2\n");
/* Demote 2. */
assertEquals(1, shelf.demote(book.getId(), shelf.getNote("Note 2").getId()));
assertEquals("description\n" + "\n" + "* Note 1\n" + "** Note 1.1\n" + "** Note 2\n", shelf.getBookContent("notebook", BookName.Format.ORG));
NotePosition n1 = shelf.getNote("Note 1").getPosition();
NotePosition n11 = shelf.getNote("Note 1.1").getPosition();
NotePosition n2 = shelf.getNote("Note 2").getPosition();
assertEquals(2, n1.getDescendantsCount());
assertEquals(0, n11.getDescendantsCount());
assertEquals(0, n2.getDescendantsCount());
assertEquals(1, n1.getLevel());
assertEquals(2, n11.getLevel());
assertEquals(2, n2.getLevel());
assertTrue(n1.getLft() < n11.getLft());
assertTrue(n11.getLft() < n11.getRgt());
assertTrue(n11.getRgt() < n2.getLft());
assertTrue(n2.getLft() < n2.getRgt());
assertTrue(n2.getRgt() < n1.getRgt());
}
Aggregations