Search in sources :

Example 11 with Repo

use of com.orgzly.android.db.entity.Repo in project orgzly-android by orgzly.

the class SyncingTest method testBackToModifiedBookAfterSyncing.

@Test
public void testBackToModifiedBookAfterSyncing() throws IOException {
    Repo repo = testUtils.setupRepo(RepoType.MOCK, "mock://repo-a");
    testUtils.setupBook("booky", "Sample book used for tests\n" + "* Note #1.\n" + "* Note #2.\n" + "** TODO Note #3.\n" + "** Note #4.\n" + "*** DONE Note #5.\n" + "**** Note #6.\n" + "** Note #7.\n" + "* Note #8.\n" + "**** Note #9.\n" + "** ANTIVIVISECTIONISTS Note #10.\n" + "** Note #11. DIE PERSER (Ü: Andreas Röhler) Schauspiel 1 D 3 H Stand:\n" + "");
    ActivityScenario.launch(MainActivity.class);
    sync();
    onView(allOf(withText("booky"), isDisplayed())).perform(click());
    onView(withId(R.id.drawer_layout)).perform(open());
    onView(allOf(withText(R.string.notebooks), isDisplayed())).perform(click());
    /* Make sure book has been uploaded to repo and is linked now. */
    onBook(0, R.id.item_book_link_repo).check(matches(allOf(withText("mock://repo-a"), isDisplayed())));
    onBook(0, R.id.item_book_synced_url).check(matches(allOf(withText("mock://repo-a/booky.org"), isDisplayed())));
    /* Modify remote book directly. */
    testUtils.setupRook(repo, "mock://repo-a/booky.org", "NEW CONTENT", "abc", 1234567890000L);
    sync();
    /* Go back to book. */
    pressBack();
    onView(withText("NEW CONTENT")).check(matches(isDisplayed()));
}
Also used : Repo(com.orgzly.android.db.entity.Repo) OrgzlyTest(com.orgzly.android.OrgzlyTest) Test(org.junit.Test)

Example 12 with Repo

use of com.orgzly.android.db.entity.Repo in project orgzly-android by orgzly.

the class SyncingTest method testForceLoadingBookWithLink.

@Test
public void testForceLoadingBookWithLink() {
    Repo repo = testUtils.setupRepo(RepoType.MOCK, "mock://repo-a");
    testUtils.setupRook(repo, "mock://repo-a/booky.org", "New content", "abc", 1234567890000L);
    testUtils.setupBook("booky", "First book used for testing\n* Note A");
    ActivityScenario.launch(MainActivity.class);
    onView(allOf(withText("booky"), isDisplayed())).perform(longClick());
    openContextualToolbarOverflowMenu();
    onView(withText(R.string.books_context_menu_item_set_link)).perform(click());
    onView(withText("mock://repo-a")).perform(click());
    onView(allOf(withText("booky"), isDisplayed())).perform(longClick());
    onView(withId(R.id.books_context_menu_force_load)).perform(click());
    onView(withText(R.string.overwrite)).perform(click());
    onBook(0, R.id.item_book_last_action).check(matches((withText(containsString(context.getString(R.string.force_loaded_from_uri, "mock://repo-a/booky.org"))))));
    onView(allOf(withText("booky"), isDisplayed())).perform(click());
    onView(withText("New content")).check(matches(isDisplayed()));
}
Also used : Repo(com.orgzly.android.db.entity.Repo) OrgzlyTest(com.orgzly.android.OrgzlyTest) Test(org.junit.Test)

Example 13 with Repo

use of com.orgzly.android.db.entity.Repo in project orgzly-android by orgzly.

the class SyncingTest method testSyncTwiceInARow.

@Test
public void testSyncTwiceInARow() {
    testUtils.setupRepo(RepoType.MOCK, "mock://repo-a");
    Repo repoB = testUtils.setupRepo(RepoType.MOCK, "mock://repo-b");
    testUtils.setupRook(repoB, "mock://repo-b/book-2.org", "Remote content for book 2", "abc", 1234567890000L);
    testUtils.setupRook(repoB, "mock://repo-b/book-3.org", "Remote content for book 3", "def", 1234567891000L);
    testUtils.setupBook("book-1", "Local content for book 1");
    testUtils.setupBook("book-2", "Local content for book 2", repoB);
    ActivityScenario.launch(MainActivity.class);
    sync();
    onBook(0, R.id.item_book_last_action).check(matches(allOf(withText(containsString(BookSyncStatus.ONLY_BOOK_WITHOUT_LINK_AND_MULTIPLE_REPOS.msg())), isDisplayed())));
    onBook(1, R.id.item_book_last_action).check(matches(allOf(withText(containsString(BookSyncStatus.CONFLICT_BOOK_WITH_LINK_AND_ROOK_BUT_NEVER_SYNCED_BEFORE.msg())), isDisplayed())));
    onBook(2, R.id.item_book_last_action).check(matches(allOf(withText(containsString(BookSyncStatus.DUMMY_WITHOUT_LINK_AND_ONE_ROOK.msg())), isDisplayed())));
    onBook(0).perform(click());
    onView(withText("Local content for book 1")).check(matches(isDisplayed()));
    pressBack();
    onBook(1).perform(click());
    onView(withText("Local content for book 2")).check(matches(isDisplayed()));
    pressBack();
    /* Whole notebook view is too big to fit on small devices' screen, so we get
         * "at least 90 percent of the view's area is displayed to the user"
         * when trying to click on it. Clicking on specific view inside (book name) instead.
         */
    onBook(2, R.id.item_book_title).perform(click());
    onView(withText("Remote content for book 3")).check(matches(isDisplayed()));
    pressBack();
    sync();
    onBook(0, R.id.item_book_last_action).check(matches(allOf(withText(containsString(BookSyncStatus.ONLY_BOOK_WITHOUT_LINK_AND_MULTIPLE_REPOS.msg())), isDisplayed())));
    onBook(1, R.id.item_book_last_action).check(matches(allOf(withText(containsString(BookSyncStatus.CONFLICT_BOOK_WITH_LINK_AND_ROOK_BUT_NEVER_SYNCED_BEFORE.msg())), isDisplayed())));
    onBook(2, R.id.item_book_last_action).check(matches(allOf(withText(containsString(BookSyncStatus.NO_CHANGE.msg())), isDisplayed())));
    onBook(0).perform(click());
    onView(withText("Local content for book 1")).check(matches(isDisplayed()));
    pressBack();
    onBook(1).perform(click());
    onView(withText("Local content for book 2")).check(matches(isDisplayed()));
    pressBack();
    onBook(2).perform(click());
    onView(withText("Remote content for book 3")).check(matches(isDisplayed()));
}
Also used : Repo(com.orgzly.android.db.entity.Repo) OrgzlyTest(com.orgzly.android.OrgzlyTest) Test(org.junit.Test)

Example 14 with Repo

use of com.orgzly.android.db.entity.Repo in project orgzly-android by orgzly.

the class SyncingTest method testChangeBookLink.

@Test
public void testChangeBookLink() throws IOException {
    Repo repoA = testUtils.setupRepo(RepoType.MOCK, "mock://repo-a");
    Repo repoB = testUtils.setupRepo(RepoType.MOCK, "mock://repo-b");
    testUtils.setupRook(repoA, "mock://repo-a/book-1.org", "Remote content for book in repo a", "abc", 1234567890);
    testUtils.setupRook(repoB, "mock://repo-b/book-1.org", "Remote content for book in repo b", "def", 1234567891);
    ActivityScenario.launch(MainActivity.class);
    sync();
    onBook(0, R.id.item_book_last_action).check(matches(allOf(withText(containsString(BookSyncStatus.DUMMY_WITHOUT_LINK_AND_MULTIPLE_ROOKS.msg())), isDisplayed())));
    /* Set link to repo-b. */
    onView(allOf(withText("book-1"), isDisplayed())).perform(longClick());
    openContextualToolbarOverflowMenu();
    onView(withText(R.string.books_context_menu_item_set_link)).perform(click());
    onView(withText("mock://repo-b")).perform(click());
    onBook(0, R.id.item_book_link_repo).check(matches(withText("mock://repo-b")));
    sync();
    onBook(0, R.id.item_book_last_action).check(matches(allOf(withText(containsString(BookSyncStatus.DUMMY_WITH_LINK.msg())), isDisplayed())));
    onBook(0).perform(click());
    onView(withText("Remote content for book in repo b")).check(matches(isDisplayed()));
    pressBack();
    /* Set link to repo-a. */
    onView(allOf(withText("book-1"), isDisplayed())).perform(longClick());
    openContextualToolbarOverflowMenu();
    onView(withText(R.string.books_context_menu_item_set_link)).perform(click());
    onView(withText("mock://repo-a")).perform(click());
    onBook(0, R.id.item_book_link_repo).check(matches(withText("mock://repo-a")));
    sync();
    onBook(0, R.id.item_book_last_action).check(matches(allOf(withText(containsString(BookSyncStatus.CONFLICT_LAST_SYNCED_ROOK_AND_LATEST_ROOK_ARE_DIFFERENT.msg())), isDisplayed())));
    /* Still the same content due to conflict. */
    onBook(0).perform(click());
    onView(withText("Remote content for book in repo b")).check(matches(isDisplayed()));
}
Also used : Repo(com.orgzly.android.db.entity.Repo) OrgzlyTest(com.orgzly.android.OrgzlyTest) Test(org.junit.Test)

Example 15 with Repo

use of com.orgzly.android.db.entity.Repo in project orgzly-android by orgzly.

the class SyncingTest method testForceLoadingMultipleTimes.

/* Books view was returning multiple entries for the same book, due to duplicates in encodings
     * table. The last statement in this method will fail if there are multiple books matching.
     */
@Test
public void testForceLoadingMultipleTimes() {
    Repo repo = testUtils.setupRepo(RepoType.MOCK, "mock://repo-a");
    testUtils.setupRook(repo, "mock://repo-a/book-one.org", "New content", "abc", 1234567890000L);
    testUtils.setupBook("book-one", "First book used for testing\n* Note A");
    testUtils.setupBook("book-two", "Second book used for testing\n* Note 1\n* Note 2");
    ActivityScenario.launch(MainActivity.class);
    onView(allOf(withText("book-one"), isDisplayed())).perform(longClick());
    openContextualToolbarOverflowMenu();
    onView(withText(R.string.books_context_menu_item_set_link)).perform(click());
    onView(withText("mock://repo-a")).perform(click());
    onView(allOf(withText("book-one"), isDisplayed())).perform(longClick());
    onView(withId(R.id.books_context_menu_force_load)).perform(click());
    onView(withText(R.string.overwrite)).perform(click());
    onBook(0, R.id.item_book_last_action).check(matches(withText(endsWith(context.getString(R.string.force_loaded_from_uri, "mock://repo-a/book-one.org")))));
    onView(allOf(withText("book-one"), isDisplayed())).perform(longClick());
    onView(withId(R.id.books_context_menu_force_load)).perform(click());
    onView(withText(R.string.overwrite)).perform(click());
    onBook(0, R.id.item_book_last_action).check(matches(withText(endsWith(context.getString(R.string.force_loaded_from_uri, "mock://repo-a/book-one.org")))));
}
Also used : Repo(com.orgzly.android.db.entity.Repo) OrgzlyTest(com.orgzly.android.OrgzlyTest) Test(org.junit.Test)

Aggregations

Repo (com.orgzly.android.db.entity.Repo)38 OrgzlyTest (com.orgzly.android.OrgzlyTest)35 Test (org.junit.Test)35 BookView (com.orgzly.android.db.entity.BookView)11 BookNamesake (com.orgzly.android.sync.BookNamesake)5 File (java.io.File)4 Intent (android.content.Intent)2 Uri (android.net.Uri)2 AppIntent (com.orgzly.android.AppIntent)2 Book (com.orgzly.android.db.entity.Book)2 AlertDialog (android.app.AlertDialog)1 BroadcastReceiver (android.content.BroadcastReceiver)1 Context (android.content.Context)1 IntentFilter (android.content.IntentFilter)1 Configuration (android.content.res.Configuration)1 Bundle (android.os.Bundle)1 Handler (android.os.Handler)1 Menu (android.view.Menu)1 MenuItem (android.view.MenuItem)1 View (android.view.View)1