Search in sources :

Example 26 with Repo

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

the class SyncTest method testOnlyBookWithLink.

@Test
public void testOnlyBookWithLink() {
    Repo repoA = testUtils.setupRepo(RepoType.MOCK, "mock://repo-a");
    BookView book = testUtils.setupBook("book-1", "Content");
    dataRepository.setLink(book.getBook().getId(), repoA);
    testUtils.sync();
    book = dataRepository.getBooks().get(0);
    assertEquals(BookSyncStatus.ONLY_BOOK_WITH_LINK.toString(), book.getBook().getSyncStatus());
}
Also used : Repo(com.orgzly.android.db.entity.Repo) BookView(com.orgzly.android.db.entity.BookView) OrgzlyTest(com.orgzly.android.OrgzlyTest) Test(org.junit.Test)

Example 27 with Repo

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

the class TestUtils method renameRepo.

public void renameRepo(String fromUrl, String toUrl) {
    Repo repo = dataRepository.getRepo(fromUrl);
    if (repo != null) {
        Repo newRepo = new Repo(repo.getId(), repo.getType(), toUrl);
        dataRepository.updateRepo(new RepoWithProps(newRepo));
    } else {
        throw new IllegalStateException("Repo " + fromUrl + " does not exist");
    }
}
Also used : RepoWithProps(com.orgzly.android.repos.RepoWithProps) Repo(com.orgzly.android.db.entity.Repo) SyncRepo(com.orgzly.android.repos.SyncRepo)

Example 28 with Repo

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

the class SyncingTest method testSettingLinkToRenamedRepo.

@Test
public void testSettingLinkToRenamedRepo() {
    Assume.assumeTrue(BuildConfig.IS_DROPBOX_ENABLED);
    Repo repo = testUtils.setupRepo(RepoType.MOCK, "mock://repo-a");
    testUtils.setupRook(repo, "mock://repo-a/booky.org", "Täht", "1abcde", 1400067156000L);
    ActivityScenario.launch(MainActivity.class);
    sync();
    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())));
    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())));
    /* Rename repository. */
    onActionItemClick(R.id.activity_action_settings, R.string.settings);
    clickSetting("prefs_screen_sync", R.string.sync);
    clickSetting("pref_key_repos", R.string.repos_preference_title);
    onListItem(0).perform(click());
    onView(withId(R.id.activity_repo_dropbox_directory)).perform(replaceTextCloseKeyboard("repo-b"));
    onActionItemClick(R.id.done, R.string.done);
    pressBack();
    pressBack();
    pressBack();
    /* Set link to new repository. */
    onView(withId(R.id.drawer_layout)).perform(open());
    onView(allOf(withText(R.string.notebooks), isDescendantOfA(withId(R.id.drawer_navigation_view)))).perform(click());
    onView(allOf(withText("booky"), isDisplayed())).perform(longClick());
    openContextualToolbarOverflowMenu();
    onView(withText(R.string.books_context_menu_item_set_link)).perform(click());
    onView(withText("dropbox:/repo-b")).perform(click());
    onBook(0, R.id.item_book_link_repo).check(matches(allOf(withText("dropbox:/repo-b"), isDisplayed())));
    onBook(0, R.id.item_book_synced_url).check(matches(not(isDisplayed())));
    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())));
    onView(allOf(withText("booky"), isDisplayed())).perform(longClick());
    openContextualToolbarOverflowMenu();
    onView(withText(R.string.books_context_menu_item_set_link)).perform(click());
    // Current value
    onView(withText("dropbox:/repo-b")).check(matches(isDisplayed()));
}
Also used : Repo(com.orgzly.android.db.entity.Repo) OrgzlyTest(com.orgzly.android.OrgzlyTest) Test(org.junit.Test)

Example 29 with Repo

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

the class SyncingTest method testSettingLinkForLoadedOrgTxtBook.

@Test
public void testSettingLinkForLoadedOrgTxtBook() {
    Repo repo = testUtils.setupRepo(RepoType.MOCK, "mock://repo-a");
    testUtils.setupRook(repo, "mock://repo-a/booky.org.txt", "", "1abcdef", 1400067155);
    ActivityScenario.launch(MainActivity.class);
    sync();
    onBook(0, R.id.item_book_link_repo).check(matches(allOf(withText("mock://repo-a"), isDisplayed())));
    onBook(0, R.id.item_book_last_action).check(matches(withText(containsString("Loaded from mock://repo-a/booky.org.txt"))));
    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());
    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.txt"), isDisplayed())));
}
Also used : Repo(com.orgzly.android.db.entity.Repo) OrgzlyTest(com.orgzly.android.OrgzlyTest) Test(org.junit.Test)

Example 30 with Repo

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

the class SyncingTest method testSpaceSeparatedBookName.

@Test
public void testSpaceSeparatedBookName() throws IOException {
    Repo repo = testUtils.setupRepo(RepoType.MOCK, "mock://repo-a");
    testUtils.setupRook(repo, "mock://repo-a/Book%20Name.org", "", "1abcdef", 1400067155);
    ActivityScenario.launch(MainActivity.class);
    sync();
    onBook(0, R.id.item_book_synced_url).check(matches(allOf(withText("mock://repo-a/Book%20Name.org"), isDisplayed())));
    onBook(0, R.id.item_book_last_action).check(matches(allOf(withText(endsWith("Loaded from mock://repo-a/Book%20Name.org")), isDisplayed())));
}
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