Search in sources :

Example 11 with PageTitle

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

the class WikiSiteTest method testTitleForInternalLink.

@Test
public void testTitleForInternalLink() {
    WikiSite wiki = WikiSite.forLanguageCode("en");
    assertThat(new PageTitle("Main Page", wiki), is(wiki.titleForInternalLink("")));
    assertThat(new PageTitle("Main Page", wiki), is(wiki.titleForInternalLink("/wiki/")));
    assertThat(new PageTitle("wiki", wiki), is(wiki.titleForInternalLink("wiki")));
    assertThat(new PageTitle("wiki", wiki), is(wiki.titleForInternalLink("/wiki/wiki")));
    assertThat(new PageTitle("wiki/wiki", wiki), is(wiki.titleForInternalLink("/wiki/wiki/wiki")));
}
Also used : PageTitle(org.wikipedia.page.PageTitle) Test(org.junit.Test)

Example 12 with PageTitle

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

the class DescriptionEditClientTest method testIsEditAllowedNoWikiBaseItem.

@Test
public void testIsEditAllowedNoWikiBaseItem() {
    WikiSite wiki = WikiSite.forLanguageCode("ru");
    PageProperties props = mock(PageProperties.class);
    when(props.getWikiBaseItem()).thenReturn(null);
    Page page = new Page(new PageTitle("Test", wiki, null, null, props), Collections.<Section>emptyList(), props);
    assertThat(DescriptionEditClient.isEditAllowed(page), is(false));
}
Also used : PageProperties(org.wikipedia.page.PageProperties) PageTitle(org.wikipedia.page.PageTitle) Page(org.wikipedia.page.Page) WikiSite(org.wikipedia.dataclient.WikiSite) Test(org.junit.Test) MockWebServerTest(org.wikipedia.test.MockWebServerTest)

Example 13 with PageTitle

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

the class DescriptionEditClientTest method testIsEditAllowedSuccess.

@Test
public void testIsEditAllowedSuccess() {
    WikiSite wiki = WikiSite.forLanguageCode("ru");
    PageProperties props = mock(PageProperties.class);
    when(props.getWikiBaseItem()).thenReturn("Q123");
    when(props.canEdit()).thenReturn(true);
    Page page = new Page(new PageTitle("Test", wiki, null, null, props), Collections.<Section>emptyList(), props);
    assertThat(DescriptionEditClient.isEditAllowed(page), is(true));
}
Also used : PageProperties(org.wikipedia.page.PageProperties) PageTitle(org.wikipedia.page.PageTitle) Page(org.wikipedia.page.Page) WikiSite(org.wikipedia.dataclient.WikiSite) Test(org.junit.Test) MockWebServerTest(org.wikipedia.test.MockWebServerTest)

Example 14 with PageTitle

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

the class LangLinksActivityTest method testAddChineseEntriesForSimplifiedChinese.

@Test
public void testAddChineseEntriesForSimplifiedChinese() throws Throwable {
    PageTitle title = new PageTitle(null, "洋基体育场 (1923年)", WikiSite.forLanguageCode("zh-hans"));
    List<PageTitle> list = getBaseLanguageEntries();
    LangLinksActivity.addChineseEntriesIfNeeded(title, list);
    assertThat(list, is(getExpectedZhHansResults()));
}
Also used : PageTitle(org.wikipedia.page.PageTitle) Test(org.junit.Test)

Example 15 with PageTitle

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

the class LangLinksActivityTest method getExpectedZhHansResults.

private List<PageTitle> getExpectedZhHansResults() {
    List<PageTitle> result = getBaseLanguageEntries();
    result.add(new PageTitle("洋基体育场 (1923年)", WikiSite.forLanguageCode("zh-hant")));
    return result;
}
Also used : PageTitle(org.wikipedia.page.PageTitle)

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