mirror of
				https://github.com/commons-app/apps-android-commons.git
				synced 2025-10-31 14:53:59 +01:00 
			
		
		
		
	Moved 2 other tests over to use robolectric.
This commit is contained in:
		
							parent
							
								
									58013ef10c
								
							
						
					
					
						commit
						1f1a2822e8
					
				
					 5 changed files with 79 additions and 90 deletions
				
			
		|  | @ -1,6 +1,5 @@ | |||
| package fr.free.nrw.commons; | ||||
| 
 | ||||
| import org.junit.Assert; | ||||
| import org.junit.Test; | ||||
| import org.junit.runner.RunWith; | ||||
| import org.robolectric.RobolectricTestRunner; | ||||
|  | @ -9,62 +8,63 @@ import org.robolectric.annotation.Config; | |||
| import java.net.URLEncoder; | ||||
| 
 | ||||
| import static org.hamcrest.CoreMatchers.is; | ||||
| import static org.junit.Assert.assertThat; | ||||
| 
 | ||||
| @RunWith(RobolectricTestRunner.class) | ||||
| @Config(constants = BuildConfig.class, sdk = 21) | ||||
| public class PageTitleTest { | ||||
|     @Test | ||||
|     public void displayTextShouldNotBeUnderscored() { | ||||
|         Assert.assertThat(new PageTitle("Ex_1 ").getDisplayText(), | ||||
|         assertThat(new PageTitle("Ex_1 ").getDisplayText(), | ||||
|                 is("Ex 1")); | ||||
|     } | ||||
| 
 | ||||
|     @Test | ||||
|     public void moreThanTwoColons() { | ||||
|         Assert.assertThat(new PageTitle("File:sample:a.jpg").getPrefixedText(), | ||||
|         assertThat(new PageTitle("File:sample:a.jpg").getPrefixedText(), | ||||
|                 is("File:Sample:a.jpg")); | ||||
|     } | ||||
| 
 | ||||
|     @Test | ||||
|     public void getTextShouldReturnWithoutNamespace() { | ||||
|         Assert.assertThat(new PageTitle("File:sample.jpg").getText(), | ||||
|         assertThat(new PageTitle("File:sample.jpg").getText(), | ||||
|                 is("Sample.jpg")); | ||||
|     } | ||||
| 
 | ||||
| 
 | ||||
|     @Test | ||||
|     public void capitalizeNameAfterNamespace() { | ||||
|         Assert.assertThat(new PageTitle("File:sample.jpg").getPrefixedText(), | ||||
|         assertThat(new PageTitle("File:sample.jpg").getPrefixedText(), | ||||
|                 is("File:Sample.jpg")); | ||||
|     } | ||||
| 
 | ||||
|     @Test | ||||
|     public void prefixedTextShouldBeUnderscored() { | ||||
|         Assert.assertThat(new PageTitle("Ex 1 ").getPrefixedText(), | ||||
|         assertThat(new PageTitle("Ex 1 ").getPrefixedText(), | ||||
|                 is("Ex_1")); | ||||
|     } | ||||
| 
 | ||||
|     @Test | ||||
|     public void getMobileUriForTest() { | ||||
|         Assert.assertThat(new PageTitle("Test").getMobileUri().toString(), | ||||
|         assertThat(new PageTitle("Test").getMobileUri().toString(), | ||||
|                 is(BuildConfig.MOBILE_HOME_URL + "Test")); | ||||
|     } | ||||
| 
 | ||||
|     @Test | ||||
|     public void spaceBecomesUnderscoreInUri() { | ||||
|         Assert.assertThat(new PageTitle("File:Ex 1.jpg").getCanonicalUri().toString(), | ||||
|         assertThat(new PageTitle("File:Ex 1.jpg").getCanonicalUri().toString(), | ||||
|                 is(BuildConfig.HOME_URL + "File:Ex_1.jpg")); | ||||
|     } | ||||
| 
 | ||||
|     @Test | ||||
|     public void leaveSubpageNamesUncapitalizedInUri() { | ||||
|         Assert.assertThat(new PageTitle("User:Ex/subpage").getCanonicalUri().toString(), | ||||
|         assertThat(new PageTitle("User:Ex/subpage").getCanonicalUri().toString(), | ||||
|                 is(BuildConfig.HOME_URL + "User:Ex/subpage")); | ||||
|     } | ||||
| 
 | ||||
|     @Test | ||||
|     public void unicodeUri() throws Throwable { | ||||
|         Assert.assertThat(new PageTitle("User:例").getCanonicalUri().toString(), | ||||
|         assertThat(new PageTitle("User:例").getCanonicalUri().toString(), | ||||
|                 is(BuildConfig.HOME_URL + "User:" + URLEncoder.encode("例", "utf-8"))); | ||||
|     } | ||||
| } | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Paul Hawke
						Paul Hawke