use of com.skocken.presentation.presenter.BasePresenter in project Presentation by StanKocken.
the class BaseActivityTest method testShouldCallOnOptionsItemSelected.
@Test
public void testShouldCallOnOptionsItemSelected() {
BaseActivity baseActivity = new TestBaseActivity();
baseActivity.onCreate(null);
BasePresenter presenter = baseActivity.getPresenter();
when(presenter.onOptionsItemSelected(any(MenuItem.class))).thenReturn(false);
MenuItem menuItem = Mockito.mock(MenuItem.class);
verify(presenter, times(0)).onOptionsItemSelected(menuItem);
assertFalse(baseActivity.onOptionsItemSelected(menuItem));
verify(presenter, times(1)).onOptionsItemSelected(menuItem);
when(presenter.onOptionsItemSelected(any(MenuItem.class))).thenReturn(true);
assertTrue(baseActivity.onOptionsItemSelected(menuItem));
verify(presenter, times(2)).onOptionsItemSelected(menuItem);
}
use of com.skocken.presentation.presenter.BasePresenter in project Presentation by StanKocken.
the class BaseActivityTest method testShouldCallOnBackPressed.
@Test
public void testShouldCallOnBackPressed() {
BaseActivity baseActivity = new TestBaseActivity();
baseActivity.onCreate(null);
BasePresenter presenter = baseActivity.getPresenter();
when(presenter.onBackPressed()).thenReturn(false);
verify(presenter, times(0)).onBackPressed();
baseActivity.onBackPressed();
verify(presenter, times(1)).onBackPressed();
when(presenter.onBackPressed()).thenReturn(true);
baseActivity.onBackPressed();
verify(presenter, times(2)).onBackPressed();
}
use of com.skocken.presentation.presenter.BasePresenter in project Presentation by StanKocken.
the class BaseAppCompatActivityTest method testShouldCallOnBackPressed.
@Test
public void testShouldCallOnBackPressed() {
BaseAppCompatActivity baseActivity = new TestBaseAppCompatActivity();
baseActivity.onCreate(null);
BasePresenter presenter = baseActivity.getPresenter();
when(presenter.onBackPressed()).thenReturn(false);
verify(presenter, times(0)).onBackPressed();
baseActivity.onBackPressed();
verify(presenter, times(1)).onBackPressed();
when(presenter.onBackPressed()).thenReturn(true);
baseActivity.onBackPressed();
verify(presenter, times(2)).onBackPressed();
}
use of com.skocken.presentation.presenter.BasePresenter in project Presentation by StanKocken.
the class BaseAppCompatActivityTest method testShouldCallOnCreateOptionsMenu.
@Test
public void testShouldCallOnCreateOptionsMenu() {
final MenuInflater menuInflater = Mockito.mock(MenuInflater.class);
BaseAppCompatActivity baseActivity = new TestBaseAppCompatActivity() {
@NonNull
@Override
public MenuInflater getMenuInflater() {
return menuInflater;
}
};
baseActivity.onCreate(null);
BasePresenter presenter = baseActivity.getPresenter();
Menu menu = Mockito.mock(Menu.class);
verify(presenter, times(0)).onCreateOptionsMenu(menu, menuInflater);
baseActivity.onCreateOptionsMenu(menu);
verify(presenter, times(1)).onCreateOptionsMenu(menu, menuInflater);
}
use of com.skocken.presentation.presenter.BasePresenter in project Presentation by StanKocken.
the class BaseActivity method onBackPressed.
@Override
public void onBackPressed() {
BasePresenter presenter = getPresenter();
if (presenter != null && presenter.onBackPressed()) {
return;
}
super.onBackPressed();
}
Aggregations