use of com.orgzly.android.db.entity.Repo in project orgzly-android by orgzly.
the class SyncingTest method testRemovingLinkFromBook.
@Test
public void testRemovingLinkFromBook() {
Repo repo = testUtils.setupRepo(RepoType.MOCK, "mock://repo-a");
testUtils.setupBook("booky", "", repo);
ActivityScenario.launch(MainActivity.class);
onBook(0, R.id.item_book_link_repo).check(matches(allOf(withText("mock://repo-a"), isDisplayed())));
onView(allOf(withText("booky"), isDisplayed())).perform(longClick());
openContextualToolbarOverflowMenu();
onView(withText(R.string.books_context_menu_item_set_link)).perform(click());
onView(withText(R.string.remove_notebook_link)).perform(click());
onBook(0, R.id.item_book_link_container).check(matches(not(isDisplayed())));
}
use of com.orgzly.android.db.entity.Repo in project orgzly-android by orgzly.
the class SyncingTest method testEncodingAfterSyncSaving.
@Test
public void testEncodingAfterSyncSaving() {
Repo repo = testUtils.setupRepo(RepoType.MOCK, "mock://repo-a");
testUtils.setupRook(repo, "mock://repo-a/book-one.org", "Täht", "1abcde", 1400067156000L);
ActivityScenario.launch(MainActivity.class);
sync();
onBook(0, R.id.item_book_encoding_used).check(matches((withText(context.getString(R.string.argument_used, "UTF-8")))));
onBook(0, R.id.item_book_encoding_detected).check(matches((withText(context.getString(R.string.argument_detected, "UTF-8")))));
onBook(0, R.id.item_book_encoding_selected).check(matches(not(isDisplayed())));
sync();
onBook(0, R.id.item_book_encoding_used).check(matches((withText(context.getString(R.string.argument_used, "UTF-8")))));
onBook(0, R.id.item_book_encoding_detected).check(matches((withText(context.getString(R.string.argument_detected, "UTF-8")))));
onBook(0, R.id.item_book_encoding_selected).check(matches(not(isDisplayed())));
}
use of com.orgzly.android.db.entity.Repo in project orgzly-android by orgzly.
the class SyncingTest method testAutoSyncIsTriggeredAfterCreatingNote.
@Test
public void testAutoSyncIsTriggeredAfterCreatingNote() {
Repo repo = testUtils.setupRepo(RepoType.MOCK, "mock://repo-a");
testUtils.setupRook(repo, "mock://repo-a/booky.org", "", "abc", 1234567890000L);
ActivityScenario.launch(MainActivity.class);
sync();
// Set preference
onActionItemClick(R.id.activity_action_settings, R.string.settings);
clickSetting("prefs_screen_sync", R.string.sync);
clickSetting("prefs_screen_auto_sync", R.string.auto_sync);
clickSetting("pref_key_auto_sync", R.string.auto_sync);
clickSetting("pref_key_auto_sync_on_note_create", R.string.pref_title_sync_after_note_create);
pressBack();
pressBack();
pressBack();
// Open book
onBook(0).perform(click());
// Create note
onView(withId(R.id.fab)).perform(click());
onView(withId(R.id.fragment_note_title)).perform(replaceTextCloseKeyboard("new note created by test"));
onView(withId(R.id.done)).perform(click());
// Check it is synced
onView(withId(R.id.drawer_layout)).perform(open());
onView(allOf(withText(R.string.notebooks), isDescendantOfA(withId(R.id.drawer_navigation_view)))).perform(click());
onView(withId(R.id.fragment_books_view_flipper)).check(matches(isDisplayed()));
onView(allOf(withText("booky"), withId(R.id.item_book_title))).check(matches(isDisplayed()));
onView(allOf(withId(R.id.item_book_sync_needed_icon))).check(matches(not(isDisplayed())));
}
use of com.orgzly.android.db.entity.Repo in project orgzly-android by orgzly.
the class DataRepositoryTest method testShelfAndRepo.
@Test
public void testShelfAndRepo() throws IOException {
assertEquals("Starting with empty shelf", 0, dataRepository.getBooks().size());
BookView book;
book = dataRepository.createBook("local-book-1");
assertEquals("local-book-1", book.getBook().getName());
assertNull(book.getSyncedTo());
book = dataRepository.createBook("common-book-1");
assertEquals("common-book-1", book.getBook().getName());
assertNull(book.getSyncedTo());
book = dataRepository.createBook("common-book-2");
assertEquals("common-book-2", book.getBook().getName());
assertNull(book.getSyncedTo());
/* Setup mock repo. */
Repo repo = testUtils.setupRepo(RepoType.MOCK, "mock://repo-a");
testUtils.setupRook(repo, "mock://repo-a/remote-book-2.org", "", "1abcdef", 1400412756000L);
testUtils.setupRook(repo, "mock://repo-a/common-book-1.org", "", "2abcdef", 1400671956000L);
testUtils.setupRook(repo, "mock://repo-a/common-book-2.org", "", "3abcdef", 1400671956000L);
testUtils.setupRook(repo, "mock://repo-a/remote-book-1.org", "", "0abcdef", 1400067156000L);
Map<String, BookNamesake> groups = SyncService.groupAllNotebooksByName(dataRepository);
assertEquals(5, groups.size());
for (BookNamesake group : groups.values()) {
String name = group.getName();
if (name.equals("local-book-1")) {
assertFalse(group.getBook().getBook().isDummy());
assertEquals(0, group.getRooks().size());
} else if (name.equals("common-book-1")) {
assertFalse(group.getBook().getBook().isDummy());
assertEquals(1, group.getRooks().size());
} else if (name.equals("common-book-2")) {
assertFalse(group.getBook().getBook().isDummy());
assertEquals(1, group.getRooks().size());
} else if (name.equals("remote-book-1")) {
assertTrue(group.getBook().getBook().isDummy());
assertEquals(1, group.getRooks().size());
} else if (name.equals("remote-book-2")) {
assertTrue(group.getBook().getBook().isDummy());
assertEquals(1, group.getRooks().size());
} else {
fail("unexpected name " + name);
}
}
}
use of com.orgzly.android.db.entity.Repo in project orgzly-android by orgzly.
the class DataRepositoryTest method testCompareWithRepo.
@Test
public void testCompareWithRepo() throws IOException {
assertEquals("Starting with empty shelf", 0, dataRepository.getBooks().size());
Repo repo = testUtils.setupRepo(RepoType.MOCK, "mock://repo-a");
testUtils.setupRook(repo, "mock://repo-a/remote-book-1.org", "", "0abcdef", 1400067156);
testUtils.setupRook(repo, "mock://repo-a/remote-book-2.org", "", "1abcdef", 1400412756);
testUtils.setupRook(repo, "mock://repo-a/remote-book-3.org", "", "2abcdef", 1400671956);
Map<String, BookNamesake> groups = SyncService.groupAllNotebooksByName(dataRepository);
assertEquals(3, groups.size());
for (BookNamesake group : groups.values()) {
String name = group.getName();
assertTrue("Book name " + name + " not expected", name.equals("remote-book-1") || name.equals("remote-book-2") || name.equals("remote-book-3"));
assertTrue(group.getBook().getBook().isDummy());
assertEquals(1, group.getRooks().size());
}
}
Aggregations