use of io.github.hidroh.materialistic.test.TestWebItem in project materialistic by hidroh.
the class ItemActivityTest method testFullscreen.
@Config(shadows = { ShadowFloatingActionButton.class })
@Test
public void testFullscreen() {
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();
ShadowFloatingActionButton shadowFab = (ShadowFloatingActionButton) ShadowExtractor.extract(activity.findViewById(R.id.reply_button));
assertTrue(shadowFab.isVisible());
ShadowLocalBroadcastManager.getInstance(activity).sendBroadcast(new Intent(WebFragment.ACTION_FULLSCREEN).putExtra(WebFragment.EXTRA_FULLSCREEN, true));
assertFalse(shadowFab.isVisible());
ShadowLocalBroadcastManager.getInstance(activity).sendBroadcast(new Intent(WebFragment.ACTION_FULLSCREEN).putExtra(WebFragment.EXTRA_FULLSCREEN, false));
assertTrue(shadowFab.isVisible());
}
use of io.github.hidroh.materialistic.test.TestWebItem in project materialistic by hidroh.
the class ItemActivityTest method testFullscreenBackPressed.
@Test
public void testFullscreenBackPressed() {
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();
ShadowLocalBroadcastManager.getInstance(activity).sendBroadcast(new Intent(WebFragment.ACTION_FULLSCREEN).putExtra(WebFragment.EXTRA_FULLSCREEN, true));
activity.onBackPressed();
assertThat(activity).isNotFinishing();
activity.onBackPressed();
assertThat(activity).isFinishing();
}
use of io.github.hidroh.materialistic.test.TestWebItem in project materialistic by hidroh.
the class ItemActivityTest method testBackPressed.
@Test
public void testBackPressed() {
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_BACK, new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_BACK));
verify(keyDelegate).setBackInterceptor(any());
verify(keyDelegate).onKeyDown(anyInt(), any(KeyEvent.class));
}
use of io.github.hidroh.materialistic.test.TestWebItem in project materialistic by hidroh.
the class BaseListActivityTest method testSelectItemOpenItem.
@Test
public void testSelectItemOpenItem() {
PreferenceManager.getDefaultSharedPreferences(activity).edit().putString(activity.getString(R.string.pref_story_display), activity.getString(R.string.pref_story_display_value_comments)).commit();
controller.pause().resume();
activity.onItemSelected(new TestWebItem() {
@Override
public String getId() {
return "1";
}
});
assertEquals(ItemActivity.class.getName(), shadowOf(activity).getNextStartedActivity().getComponent().getClassName());
}
use of io.github.hidroh.materialistic.test.TestWebItem in project materialistic by hidroh.
the class BaseListActivityTest method testGetSelectedItem.
@Test
public void testGetSelectedItem() {
activity.onItemSelected(new TestWebItem() {
@Override
public boolean isStoryType() {
return true;
}
@Override
public String getId() {
return "1";
}
});
assertNotNull(activity.getSelectedItem());
}
Aggregations