Search in sources :

Example 26 with Note

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());
}
Also used : Book(com.orgzly.android.Book) NotePosition(com.orgzly.android.NotePosition) Note(com.orgzly.android.Note) OrgzlyTest(com.orgzly.android.OrgzlyTest) Test(org.junit.Test)

Example 27 with Note

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());
}
Also used : Book(com.orgzly.android.Book) Note(com.orgzly.android.Note) OrgzlyTest(com.orgzly.android.OrgzlyTest) Test(org.junit.Test)

Example 28 with Note

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());
}
Also used : Book(com.orgzly.android.Book) Note(com.orgzly.android.Note) OrgzlyTest(com.orgzly.android.OrgzlyTest) Test(org.junit.Test)

Example 29 with Note

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());
}
Also used : Book(com.orgzly.android.Book) Note(com.orgzly.android.Note) OrgzlyTest(com.orgzly.android.OrgzlyTest) Test(org.junit.Test)

Aggregations

Note (com.orgzly.android.Note)29 OrgzlyTest (com.orgzly.android.OrgzlyTest)21 Test (org.junit.Test)21 Book (com.orgzly.android.Book)18 NotePosition (com.orgzly.android.NotePosition)11 NotePlace (com.orgzly.android.ui.NotePlace)4 OrgHead (com.orgzly.org.OrgHead)4 DbNote (com.orgzly.android.provider.models.DbNote)3 Intent (android.content.Intent)2 Cursor (android.database.Cursor)2 AppIntent (com.orgzly.android.AppIntent)2 Shelf (com.orgzly.android.Shelf)2 ContentValues (android.content.ContentValues)1 OrgProperties (com.orgzly.org.OrgProperties)1 OrgRange (com.orgzly.org.datetime.OrgRange)1 HashSet (java.util.HashSet)1