1. German Larrain
  2. bitbeaker

Commits

Ville Saalo  committed 418549d

Better code coverage for LauncherActivity.

  • Participants
  • Parent commits 9309f02
  • Branches default

Comments (0)

Files changed (1)

File src/com/saibotd/bitbeaker/tests/LauncherActivityTest.java

View file
 	}
 	
 	public void test_single_issue() throws Exception {
-		Uri uri = Uri.parse("http://bitbucket.org/saibotd/bitbeaker/issue/11/implement-show-edit-add-and-delete");
+		Uri uri = Uri.parse("http://bitbucket.org/thisUser/thatRepository/issue/11/some-issue-description");
 		handleUriData.invoke(activity, uri);
 		
 		String[] resultParams = activity.getParameters();
 		assertNotNull(resultParams);
 		assertEquals(3, resultParams.length);
-		assertEquals("https://api.bitbucket.org/1.0/repositories/saibotd/bitbeaker/issues/11", resultParams[0]);
+		assertEquals("https://api.bitbucket.org/1.0/repositories/thisUser/thatRepository/issues/11", resultParams[0]);
 		assertNull(resultParams[1]);
-		assertEquals("Async error -- test message", resultParams[2]);
+		assertEquals("Async error -- test message!", resultParams[2]);
 	}
 	
 	public void test_changesets() throws Exception {
-		Uri uri = Uri.parse("https://bitbucket.org/saibotd/bitbeaker/changeset/e5dc8a46eda8d9a2bfc518f7ba98cc54b5ae4b26");
+		Uri uri = Uri.parse("https://bitbucket.org/testUser/testSlug/changeset/e5dc8a46ed");
 		handleUriData.invoke(activity, uri);
 		
 		String[] resultParams = activity.getParameters();
 		assertNotNull(resultParams);
 		assertEquals(3, resultParams.length);
-		assertEquals("https://api.bitbucket.org/1.0/repositories/saibotd/bitbeaker/changesets/e5dc8a46eda8d9a2bfc518f7ba98cc54b5ae4b26", resultParams[0]);
+		assertEquals("https://api.bitbucket.org/1.0/repositories/testUser/testSlug/changesets/e5dc8a46ed", resultParams[0]);
 		assertNull(resultParams[1]);
-		assertEquals("Async error -- test message", resultParams[2]);
+		assertEquals("Async error -- test message!", resultParams[2]);
+	}
+	
+	public void test_source_code_browser() throws Exception {
+		Uri uri = Uri.parse("http://bitbucket.org/someFakeUser/someTestProject/src/");
+		handleUriData.invoke(activity, uri);
+		
+		String[] resultParams = activity.getParameters();
+		assertNotNull(resultParams);
+		assertEquals(3, resultParams.length);
+		assertEquals("https://api.bitbucket.org/1.0/repositories/someFakeUser/someTestProject/branches", resultParams[0]);
+		assertNull(resultParams[1]);
+		assertEquals("No branches -- test message!", resultParams[2]);
+	}
+	
+	public void test_unknown_link_type() throws Exception {
+		Uri uri = Uri.parse("http://bitbucket.org/myUser/myProject/downloads");
+		handleUriData.invoke(activity, uri);
+
+		assertEquals(null, activity.getParameters());
+		assertEquals(R.string.link_not_supported, activity.getToastTextId());
 	}
 	
 	/**
 	 * passed to that method.
 	 */
 	private class TestableLauncherActivity extends LauncherActivity {
-		private String[] parameters;
+		private String[] parameters = null;
+		private int toastTextId = -1;
 		
 		@Override
 		public AsyncTask<String, Integer, String> executeAsyncLoader(String... params) {
 			return null;
 		}
 		
+		@Override
+		public void makeToast(int textId) {
+			toastTextId = textId;
+		}
+		
+		public int getToastTextId() {
+			return toastTextId;
+		}
+		
 		public String[] getParameters() {
 			return parameters;
 		}