Skip to content

Commit d58025d

Browse files
committed
LIBbb10420 Unit test for com.vorlonsoft.android.rate.UriHelper
1 parent aba68cb commit d58025d

2 files changed

Lines changed: 55 additions & 8 deletions

File tree

library/src/androidTest/java/com/vorlonsoft/android/rate/UriHelperTest.java

Lines changed: 53 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,22 +14,69 @@
1414
*/
1515
public class UriHelperTest extends AndroidTestCase {
1616

17-
private static final String GOOGLE_PLAY = "https://play.google.com/store/apps/details?id=";
17+
private static final String CHINESE_STORES = "market://details?id=";
18+
19+
private static final String GOOGLE_PLAY = "market://details?id=";
20+
21+
private static final String GOOGLE_PLAY_WEB = "https://play.google.com/store/apps/details?id=";
22+
23+
@SuppressWarnings("ConstantConditions")
24+
public void testGetChineseStoresUri() {
25+
{
26+
Uri uri = UriHelper.getStoreUri(StoreType.CHINESESTORES,"");
27+
assertEquals(uri.toString(), CHINESE_STORES);
28+
}
29+
{
30+
Uri uri = UriHelper.getStoreWebUri(StoreType.CHINESESTORES,"");
31+
assertNull(uri);
32+
}
33+
{
34+
Uri uri = UriHelper.getStoreUri(StoreType.CHINESESTORES,null);
35+
assertNull(uri);
36+
}
37+
{
38+
Uri uri = UriHelper.getStoreWebUri(StoreType.CHINESESTORES,null);
39+
assertNull(uri);
40+
}
41+
{
42+
final String paramName = "com.vorlonsoft.android.rate";
43+
Uri uri = UriHelper.getStoreUri(StoreType.CHINESESTORES, paramName);
44+
assertEquals(uri.toString(), CHINESE_STORES + paramName);
45+
}
46+
{
47+
final String paramName = "com.vorlonsoft.android.rate";
48+
Uri uri = UriHelper.getStoreWebUri(StoreType.CHINESESTORES, paramName);
49+
assertNull(uri);
50+
}
51+
}
1852

1953
@SuppressWarnings("ConstantConditions")
2054
public void testGetGooglePlayUri() {
2155
{
22-
Uri uri = UriHelper.getGooglePlay("");
56+
Uri uri = UriHelper.getStoreUri(StoreType.GOOGLEPLAY,"");
2357
assertEquals(uri.toString(), GOOGLE_PLAY);
2458
}
2559
{
26-
Uri uri = UriHelper.getGooglePlay(null);
60+
Uri uri = UriHelper.getStoreWebUri(StoreType.GOOGLEPLAY,"");
61+
assertEquals(uri.toString(), GOOGLE_PLAY_WEB);
62+
}
63+
{
64+
Uri uri = UriHelper.getStoreUri(StoreType.GOOGLEPLAY,null);
2765
assertNull(uri);
2866
}
2967
{
30-
final String packageName = "com.vorlonsoft.android.rate";
31-
Uri uri = UriHelper.getGooglePlay(packageName);
32-
assertEquals(uri.toString(), GOOGLE_PLAY + packageName);
68+
Uri uri = UriHelper.getStoreWebUri(StoreType.GOOGLEPLAY,null);
69+
assertNull(uri);
70+
}
71+
{
72+
final String paramName = "com.vorlonsoft.android.rate";
73+
Uri uri = UriHelper.getStoreUri(StoreType.GOOGLEPLAY, paramName);
74+
assertEquals(uri.toString(), GOOGLE_PLAY + paramName);
75+
}
76+
{
77+
final String paramName = "com.vorlonsoft.android.rate";
78+
Uri uri = UriHelper.getStoreWebUri(StoreType.GOOGLEPLAY, paramName);
79+
assertEquals(uri.toString(), GOOGLE_PLAY_WEB + paramName);
3380
}
3481
}
3582
}

library/src/main/java/com/vorlonsoft/android/rate/UriHelper.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,10 +118,10 @@ private static Uri getStoreUri(final StoreType appStore, final String paramName,
118118
}
119119

120120
static Uri getStoreUri(final StoreType appStore, final String paramName) {
121-
return getStoreUri(appStore, paramName, false);
121+
return paramName == null ? null : getStoreUri(appStore, paramName, false);
122122
}
123123

124124
static Uri getStoreWebUri(final StoreType appStore, final String paramName) {
125-
return getStoreUri(appStore, paramName, true);
125+
return paramName == null ? null : getStoreUri(appStore, paramName, true);
126126
}
127127
}

0 commit comments

Comments
 (0)