use of com.orgzly.android.Note 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.Note in project orgzly-android by orgzly.
the class StructureTest method testNewNote.
@Test
public void testNewNote() throws IOException {
Book book = shelfTestUtils.setupBook("notebook", "" + "description\n" + "\n" + "* Note 1\n" + "** Note 1.1\n");
Note newNote = new Note();
newNote.getPosition().setBookId(book.getId());
newNote.getHead().setTitle("Note 2");
shelf.createNote(newNote, null);
assertEquals("description\n" + "\n" + "* Note 1\n" + "** Note 1.1\n" + "* Note 2\n", shelf.getBookContent("notebook", BookName.Format.ORG));
assertEquals(shelf.getNote("").getId(), shelf.getNote("Note 2").getPosition().getParentId());
}
use of com.orgzly.android.Note in project orgzly-android by orgzly.
the class StructureTest method testPasteFolded.
@Test
public void testPasteFolded() throws IOException {
Book book = shelfTestUtils.setupBook("notebook", "" + "description\n" + "\n" + "* Note 1\n" + "** Note 1.1\n" + "* Note 2\n");
shelf.toggleFoldedState(shelf.getNote("Note 1").getId());
shelf.cut(book.getId(), shelf.getNote("Note 1").getId());
Note n = shelf.getNote("Note 2");
shelf.paste(n.getPosition().getBookId(), n.getId(), Place.ABOVE);
/* Remains folded. */
assertTrue(shelf.getNote("Note 1").getPosition().isFolded());
assertNotSame(0, shelf.getNote("Note 1.1").getPosition().getFoldedUnderId());
}
use of com.orgzly.android.Note in project orgzly-android by orgzly.
the class StructureTest method testNewNoteAfterMovingUnder.
/* After moving one note under another, test lft and rgt od third newly created note. */
@Test
public void testNewNoteAfterMovingUnder() throws IOException {
Book book = shelfTestUtils.setupBook("notebook", "* Note 1\n* Note 2");
shelf.cut(book.getId(), shelf.getNote("Note 1").getId());
shelf.paste(book.getId(), shelf.getNote("Note 2").getId(), Place.UNDER);
Note newNote = new Note();
newNote.getPosition().setBookId(book.getId());
newNote.getHead().setTitle("Note 3");
shelf.createNote(newNote, null);
assertTrue(shelf.getNote("Note 2").getPosition().getRgt() < shelf.getNote("Note 3").getPosition().getLft());
}
Aggregations