use of io.github.hidroh.materialistic.test.TestWebItem in project materialistic by hidroh.
the class BaseListActivityTest method testSelectItemStartActionView.
@Test
public void testSelectItemStartActionView() {
RobolectricPackageManager packageManager = (RobolectricPackageManager) RuntimeEnvironment.application.getPackageManager();
packageManager.addResolveInfoForIntent(new Intent(Intent.ACTION_VIEW, Uri.parse("http://example.com")), ShadowResolveInfo.newResolveInfo("label", "com.android.chrome", "DefaultActivity"));
packageManager.addResolveInfoForIntent(new Intent(Intent.ACTION_VIEW, Uri.parse("http://example.com")), ShadowResolveInfo.newResolveInfo("label", "com.android.browser", "DefaultActivity"));
PreferenceManager.getDefaultSharedPreferences(activity).edit().putBoolean(activity.getString(R.string.pref_external), true).commit();
controller.pause().resume();
activity.onItemSelected(new TestWebItem() {
@Override
public String getUrl() {
return "http://example.com";
}
});
assertThat(shadowOf(activity).getNextStartedActivity()).hasAction(Intent.ACTION_VIEW);
}
use of io.github.hidroh.materialistic.test.TestWebItem in project materialistic by hidroh.
the class ItemActivityTest method testVolumeNavigation.
@Test
public void testVolumeNavigation() {
Intent intent = new Intent();
WebItem webItem = new TestWebItem() {
@Override
public String getUrl() {
return "http://example.com";
}
@Override
public String getId() {
return "1";
}
};
intent.putExtra(ItemActivity.EXTRA_ITEM, webItem);
controller.withIntent(intent).create().start().resume().visible();
activity.onKeyDown(KeyEvent.KEYCODE_VOLUME_UP, new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_VOLUME_UP));
verify(keyDelegate).setScrollable(any(Scrollable.class), any(AppBarLayout.class));
verify(keyDelegate).onKeyDown(anyInt(), any(KeyEvent.class));
activity.onKeyUp(KeyEvent.KEYCODE_VOLUME_UP, new KeyEvent(KeyEvent.ACTION_UP, KeyEvent.KEYCODE_VOLUME_UP));
verify(keyDelegate).onKeyUp(anyInt(), any(KeyEvent.class));
activity.onKeyLongPress(KeyEvent.KEYCODE_VOLUME_UP, new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_VOLUME_UP));
verify(keyDelegate).onKeyLongPress(anyInt(), any(KeyEvent.class));
}
use of io.github.hidroh.materialistic.test.TestWebItem in project materialistic by hidroh.
the class BaseListActivityTest method testSelectItemOpenExternal.
@Test
public void testSelectItemOpenExternal() {
RobolectricPackageManager packageManager = (RobolectricPackageManager) RuntimeEnvironment.application.getPackageManager();
packageManager.addResolveInfoForIntent(new Intent(Intent.ACTION_VIEW, Uri.parse("http://example.com")), ShadowResolveInfo.newResolveInfo("label", "com.android.chrome", "DefaultActivity"));
PreferenceManager.getDefaultSharedPreferences(activity).edit().putBoolean(activity.getString(R.string.pref_external), true).commit();
controller.pause().resume();
activity.onItemSelected(new TestWebItem() {
@Override
public String getUrl() {
return "http://example.com";
}
});
assertThat(shadowOf(activity).getNextStartedActivity()).hasAction(Intent.ACTION_VIEW);
}
use of io.github.hidroh.materialistic.test.TestWebItem in project materialistic by hidroh.
the class BaseListActivityTest method testSelectItemOpenWeb.
@Test
public void testSelectItemOpenWeb() {
activity.onItemSelected(new TestWebItem() {
@Override
public String getUrl() {
return "http://example.com";
}
});
Intent actual = shadowOf(activity).getNextStartedActivity();
assertEquals(ItemActivity.class.getName(), actual.getComponent().getClassName());
}
use of io.github.hidroh.materialistic.test.TestWebItem in project materialistic by hidroh.
the class BaseListActivityTest method testSelectItemOpenChooser.
@Test
public void testSelectItemOpenChooser() {
RobolectricPackageManager packageManager = (RobolectricPackageManager) RuntimeEnvironment.application.getPackageManager();
packageManager.addResolveInfoForIntent(new Intent(Intent.ACTION_VIEW, Uri.parse("http://news.ycombinator.com/item?id=1")), ShadowResolveInfo.newResolveInfo("label", "com.android.chrome", "DefaultActivity"));
packageManager.addResolveInfoForIntent(new Intent(Intent.ACTION_VIEW, Uri.parse("http://news.ycombinator.com/item?id=1")), ShadowResolveInfo.newResolveInfo("label", "com.android.browser", "DefaultActivity"));
PreferenceManager.getDefaultSharedPreferences(activity).edit().putBoolean(activity.getString(R.string.pref_external), true).commit();
controller.pause().resume();
activity.onItemSelected(new TestWebItem() {
@Override
public String getUrl() {
return "http://news.ycombinator.com/item?id=1";
}
});
assertThat(shadowOf(activity).getNextStartedActivity()).hasAction(Intent.ACTION_CHOOSER);
}
Aggregations