Search in sources :

Example 41 with PageTitle

use of org.wikipedia.page.PageTitle in project apps-android-wikipedia by wikimedia.

the class LangLinksClientTest method getExpectedResults.

private List<PageTitle> getExpectedResults() {
    List<PageTitle> result = new ArrayList<>();
    result.add(new PageTitle("Sciëntologie", WikiSite.forLanguageCode("af")));
    result.add(new PageTitle("سينتولوجيا", WikiSite.forLanguageCode("ar")));
    result.add(new PageTitle("سيينتولوجيا", WikiSite.forLanguageCode("arz")));
    return result;
}
Also used : PageTitle(org.wikipedia.page.PageTitle) ArrayList(java.util.ArrayList)

Example 42 with PageTitle

use of org.wikipedia.page.PageTitle in project apps-android-wikipedia by wikimedia.

the class ReadingListDbHelperTest method testAddPageToListForPageAddition.

@Test
public void testAddPageToListForPageAddition() {
    PageTitle page = new PageTitle("1", WikipediaApp.getInstance().getWikiSite());
    ReadingList list = readingListDbHelper.createList("Test4", "TestDesc");
    ReadingList list2 = readingListDbHelper.createList("Test5", "TestDesc");
    readingListDbHelper.addPageToList(list, page, false);
    readingListDbHelper.addPageToList(list2, page, false);
    List<ReadingListPage> pages = new ArrayList<>();
    pages.add(new ReadingListPage(page));
    List<ReadingList> lists = readingListDbHelper.getListsFromPageOccurrences(pages);
    readingListDbHelper.deleteList(list);
    readingListDbHelper.deleteList(list2);
    readingListDbHelper.markPagesForDeletion(list, pages);
    readingListDbHelper.markPagesForDeletion(list2, pages);
    Assert.assertFalse(lists.contains(list));
}
Also used : PageTitle(org.wikipedia.page.PageTitle) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 43 with PageTitle

use of org.wikipedia.page.PageTitle in project apps-android-wikipedia by wikimedia.

the class ReadingListDbHelperTest method testAddIfNotExistsForRetrievingPages.

@Test
public void testAddIfNotExistsForRetrievingPages() {
    ReadingList list = readingListDbHelper.createList("Test8", "TestDesc");
    PageTitle page = new PageTitle("1", WikipediaApp.getInstance().getWikiSite());
    PageTitle page2 = new PageTitle("2", WikipediaApp.getInstance().getWikiSite());
    PageTitle page3 = new PageTitle("3", WikipediaApp.getInstance().getWikiSite());
    readingListDbHelper.addPageToList(list, page, false);
    List<PageTitle> pages = new ArrayList<>();
    pages.add(page);
    pages.add(page2);
    pages.add(page3);
    int numAdded = readingListDbHelper.addPagesToListIfNotExist(list, pages);
    readingListDbHelper.deleteList(list);
    List<ReadingListPage> readingListPages = new ArrayList<>();
    for (PageTitle page1 : pages) {
        readingListPages.add(new ReadingListPage(page1));
    }
    readingListDbHelper.markPagesForDeletion(list, readingListPages);
    Assert.assertTrue(numAdded == 2);
}
Also used : PageTitle(org.wikipedia.page.PageTitle) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 44 with PageTitle

use of org.wikipedia.page.PageTitle in project apps-android-wikipedia by wikimedia.

the class ReadingListDbHelperTest method testGetAllPagesToBeSavedForRetrievingPages.

public void testGetAllPagesToBeSavedForRetrievingPages() {
    PageTitle page = new PageTitle("1", WikipediaApp.getInstance().getWikiSite());
    ReadingListPage readingListPage = new ReadingListPage(page);
    readingListPage.status(ReadingListPage.STATUS_QUEUE_FOR_SAVE);
    List<ReadingListPage> pagesListToBeAdded = new ArrayList<>();
    pagesListToBeAdded.add(readingListPage);
    ReadingList list = readingListDbHelper.createList("Test6", "TestDesc");
    readingListDbHelper.addPagesToList(list, pagesListToBeAdded, false);
    List<ReadingListPage> pagesList = readingListDbHelper.getAllPagesToBeSaved();
    readingListDbHelper.deleteList(list);
    List<ReadingListPage> pages = new ArrayList<>();
    pages.add(readingListPage);
    readingListDbHelper.markPagesForDeletion(list, pages);
    Assert.assertTrue(pagesList.size() != 0);
}
Also used : PageTitle(org.wikipedia.page.PageTitle) ArrayList(java.util.ArrayList)

Example 45 with PageTitle

use of org.wikipedia.page.PageTitle in project apps-android-wikipedia by wikimedia.

the class ReadingListDbHelperTest method testGetAllPageOccurrencesForRetrievingPages.

@Test
public void testGetAllPageOccurrencesForRetrievingPages() {
    ReadingList list = readingListDbHelper.createList("Test11", "TestDesc");
    ReadingList list2 = readingListDbHelper.createList("Test12", "TestDesc");
    PageTitle page = new PageTitle("6", WikipediaApp.getInstance().getWikiSite());
    readingListDbHelper.addPageToList(list, page, false);
    readingListDbHelper.addPageToList(list2, page, false);
    int numOfPages = readingListDbHelper.getAllPageOccurrences(page).size();
    readingListDbHelper.deleteList(list);
    readingListDbHelper.deleteList(list2);
    List<ReadingListPage> pages = new ArrayList<>();
    pages.add(new ReadingListPage(page));
    readingListDbHelper.markPagesForDeletion(list, pages);
    readingListDbHelper.markPagesForDeletion(list2, pages);
    Assert.assertTrue(numOfPages != 0);
}
Also used : PageTitle(org.wikipedia.page.PageTitle) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Aggregations

PageTitle (org.wikipedia.page.PageTitle)60 Test (org.junit.Test)20 ArrayList (java.util.ArrayList)15 WikiSite (org.wikipedia.dataclient.WikiSite)11 HistoryEntry (org.wikipedia.history.HistoryEntry)11 NonNull (android.support.annotation.NonNull)6 OnClick (butterknife.OnClick)5 ReadingListPage (org.wikipedia.readinglist.database.ReadingListPage)5 IOException (java.io.IOException)4 Date (java.util.Date)4 WikipediaApp (org.wikipedia.WikipediaApp)3 PageBackStackItem (org.wikipedia.page.PageBackStackItem)3 Tab (org.wikipedia.page.tabs.Tab)3 ProgressDialog (android.app.ProgressDialog)2 Intent (android.content.Intent)2 AssetManager (android.content.res.AssetManager)2 Configuration (android.content.res.Configuration)2 Resources (android.content.res.Resources)2 Bundle (android.os.Bundle)2 DisplayMetrics (android.util.DisplayMetrics)2