Search in sources :

Example 21 with WikiSite

use of org.wikipedia.dataclient.WikiSite in project apps-android-wikipedia by wikimedia.

the class PageTitleTest method testPrefixedText.

@Test
public void testPrefixedText() throws Throwable {
    WikiSite enwiki = WikiSite.forLanguageCode("en");
    assertThat(new PageTitle(null, "Test  title", enwiki).getPrefixedText(), is("Test__title"));
    assertThat(new PageTitle(null, "Test title", enwiki).getPrefixedText(), is("Test_title"));
    assertThat(new PageTitle("Talk", "Test title", enwiki).getPrefixedText(), is("Talk:Test_title"));
    assertThat(new PageTitle(null, "Test title", enwiki).getText(), is("Test_title"));
}
Also used : WikiSite(org.wikipedia.dataclient.WikiSite) Test(org.junit.Test)

Example 22 with WikiSite

use of org.wikipedia.dataclient.WikiSite in project apps-android-wikipedia by wikimedia.

the class PageTitleTest method testFromInternalLink.

@Test
public void testFromInternalLink() throws Throwable {
    WikiSite enwiki = WikiSite.forLanguageCode("en");
    assertThat(enwiki.titleForInternalLink("/wiki/India").getPrefixedText(), is("India"));
    assertThat(enwiki.titleForInternalLink("/wiki/India").getNamespace(), nullValue());
    assertThat(enwiki.titleForInternalLink("/wiki/Talk:India").getNamespace(), is("Talk"));
    assertThat(enwiki.titleForInternalLink("/wiki/Talk:India").getText(), is("India"));
    assertThat(enwiki.titleForInternalLink("/wiki/Talk:India").getFragment(), nullValue());
    assertThat(enwiki.titleForInternalLink("/wiki/Talk:India#").getNamespace(), is("Talk"));
    assertThat(enwiki.titleForInternalLink("/wiki/Talk:India#").getText(), is("India"));
    assertThat(enwiki.titleForInternalLink("/wiki/Talk:India#").getFragment(), is(""));
    assertThat(enwiki.titleForInternalLink("/wiki/Talk:India#History").getNamespace(), is("Talk"));
    assertThat(enwiki.titleForInternalLink("/wiki/Talk:India#History").getText(), is("India"));
    assertThat(enwiki.titleForInternalLink("/wiki/Talk:India#History").getFragment(), is("History"));
}
Also used : WikiSite(org.wikipedia.dataclient.WikiSite) Test(org.junit.Test)

Example 23 with WikiSite

use of org.wikipedia.dataclient.WikiSite in project apps-android-wikipedia by wikimedia.

the class PageTitleTest method testCanonicalURL.

@Test
public void testCanonicalURL() throws Throwable {
    WikiSite enwiki = WikiSite.forLanguageCode("en");
    assertThat(enwiki.titleForInternalLink("/wiki/India").getCanonicalUri(), is("https://en.wikipedia.org/wiki/India"));
    assertThat(enwiki.titleForInternalLink("/wiki/India Gate").getCanonicalUri(), is("https://en.wikipedia.org/wiki/India_Gate"));
    assertThat(enwiki.titleForInternalLink("/wiki/India's Gate").getCanonicalUri(), is("https://en.wikipedia.org/wiki/India%27s_Gate"));
}
Also used : WikiSite(org.wikipedia.dataclient.WikiSite) Test(org.junit.Test)

Example 24 with WikiSite

use of org.wikipedia.dataclient.WikiSite in project apps-android-wikipedia by wikimedia.

the class PageTitleTest method testMainPage.

@Test
public void testMainPage() throws Throwable {
    WikiSite enwiki = WikiSite.forLanguageCode("en");
    assertThat(new PageTitle("", enwiki), is(new PageTitle(MainPageNameData.valueFor("en"), enwiki)));
}
Also used : WikiSite(org.wikipedia.dataclient.WikiSite) Test(org.junit.Test)

Example 25 with WikiSite

use of org.wikipedia.dataclient.WikiSite in project apps-android-wikipedia by wikimedia.

the class PageTitleTest method testIsMainPageNoTitleNoProps.

@Test
public void testIsMainPageNoTitleNoProps() throws Throwable {
    final String text = null;
    WikiSite wiki = WikiSite.forLanguageCode("test");
    final String thumbUrl = null;
    final String desc = null;
    final PageProperties props = null;
    PageTitle subject = new PageTitle(text, wiki, thumbUrl, desc, props);
    assertThat(subject.isMainPage(), is(true));
}
Also used : WikiSite(org.wikipedia.dataclient.WikiSite) Test(org.junit.Test)

Aggregations

WikiSite (org.wikipedia.dataclient.WikiSite)35 Test (org.junit.Test)22 PageTitle (org.wikipedia.page.PageTitle)11 HistoryEntry (org.wikipedia.history.HistoryEntry)5 Date (java.util.Date)4 Uri (android.net.Uri)3 Bundle (android.os.Bundle)2 View (android.view.View)2 ArrayList (java.util.ArrayList)2 JSONException (org.json.JSONException)2 JSONObject (org.json.JSONObject)2 Page (org.wikipedia.page.Page)2 PageBackStackItem (org.wikipedia.page.PageBackStackItem)2 PageProperties (org.wikipedia.page.PageProperties)2 Tab (org.wikipedia.page.tabs.Tab)2 MockWebServerTest (org.wikipedia.test.MockWebServerTest)2 ProgressDialog (android.app.ProgressDialog)1 AssetManager (android.content.res.AssetManager)1 Configuration (android.content.res.Configuration)1 Resources (android.content.res.Resources)1