Browse Source

intent test cases for #1201

renovate/org.robolectric-robolectric-4.x
Austin Huang 4 years ago
parent
commit
65addf8c92
No known key found for this signature in database GPG Key ID: 84C23AA04587A91F
  1. 11
      app/src/main/AndroidManifest.xml
  2. 25
      app/src/test/java/awais/instagrabber/utils/IntentUtilsTest.java

11
app/src/main/AndroidManifest.xml

@ -51,8 +51,6 @@
<data android:scheme="http" />
<data android:scheme="https" />
<data android:host="ig.me" />
<data android:host="www.ig.me" />
<data android:host="instagr.am" />
<data android:host="www.instagr.am" />
<data android:host="instagram.com" />
@ -60,6 +58,7 @@
<data android:pathPrefix="/" />
<data android:pathPrefix="/p" />
<data android:pathPrefix="/explore/tags" />
<data android:pathPrefix="/explore/locations" />
</intent-filter>
</activity>
<activity
@ -104,14 +103,6 @@
<data android:mimeType="text/plain" />
</intent-filter>
<intent-filter>
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:host="ig.me" />
<data android:scheme="http" />
<data android:scheme="https" />
</intent-filter>
</activity>
<activity
android:name=".activities.Login"

25
app/src/test/java/awais/instagrabber/utils/IntentUtilsTest.java

@ -0,0 +1,25 @@
package awais.instagrabber.utils;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import awais.instagrabber.models.IntentModel;
import awais.instagrabber.models.enums.IntentModelType;
class IntentUtilsTest {
@Test
void getIntentFromUrl() {
IntentModel intent = IntentUtils.parseUrl("https://instagr.am/austinhuang.me");
Assertions.assertEquals(new IntentModel(IntentModelType.USERNAME, "austinhuang.me"), intent);
intent = IntentUtils.parseUrl("https://www.instagr.am/_u/austinhuang.me");
Assertions.assertEquals(new IntentModel(IntentModelType.USERNAME, "austinhuang.me"), intent);
intent = IntentUtils.parseUrl("https://instagram.com/p/BmjKdkxjzO7/");
Assertions.assertEquals(new IntentModel(IntentModelType.POST, "BmjKdkxjzO7"), intent);
intent = IntentUtils.parseUrl("https://www.instagram.com/explore/tags/metrodemontreal/");
Assertions.assertEquals(new IntentModel(IntentModelType.HASHTAG, "metrodemontreal"), intent);
intent = IntentUtils.parseUrl("http://www.instagram.com/explore/locations/538444610/abcde");
Assertions.assertEquals(new IntentModel(IntentModelType.LOCATION, "538444610"), intent);
// todo: reel and igtv test cases that are sfw and preferably n i c e
}
}
Loading…
Cancel
Save