/
ApplicationTest.java
52 lines (43 loc) · 2.17 KB
/
ApplicationTest.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package news.androidtv.tvapprepo;
import android.app.Application;
import android.content.ComponentName;
import android.content.Intent;
import android.test.ApplicationTestCase;
import android.util.Log;
import java.io.File;
import java.net.URISyntaxException;
import dalvik.annotation.TestTargetClass;
import news.androidtv.tvapprepo.intents.IntentUriGenerator;
/**
* <a href="http://d.android.com/tools/testing/testing_android.html">Testing Fundamentals</a>
*/
public class ApplicationTest extends ApplicationTestCase<Application> {
public static final String TAG = ApplicationTest.class.getSimpleName();
public ApplicationTest() {
super(Application.class);
}
public void testWebBookmarks() {
final String expected = "intent://google.com#Intent;scheme=http;end";
String actual = IntentUriGenerator.generateWebBookmark("http://google.com");
Log.d(TAG, actual);
assertEquals(expected, actual);
}
public void testActivityShortcut() {
final String expected = "intent:#Intent;component=news.androidtv.tvapprepo/.activities.SettingsActivity;end";
String actual = IntentUriGenerator.generateActivityShortcut(new ComponentName("news.androidtv.tvapprepo", ".activities.SettingsActivity"));
Log.d(TAG, actual);
assertEquals(expected, actual);
}
public void testFileOpening() {
// Note: This can be flaky if your device doesn't have this file. Future versions of this
// test should create and delete a temporary file.
final String expected = "intent:///storage/emulated/0/Download/com.felkertech.n.cumulustv.test.apk#Intent;scheme=file;launchFlags=0x10000000;end";
String actual = IntentUriGenerator.generateVideoPlayback(new File("/storage/emulated/0/Download/com.felkertech.n.cumulustv.test.apk"));
Log.d(TAG, actual);
assertEquals(expected, actual);
}
public void testOpenGoogle() throws URISyntaxException {
String string = "intent:#Intent;component=news.androidtv.tvapprepo/.activities.SettingsActivity;end";
getContext().startActivity(Intent.parseUri(string, Intent.URI_INTENT_SCHEME));
}
}