use of org.robolectric.fakes.RoboMenu in project collect by opendatakit.
the class FormEntryMenuDelegateTest method onItemSelected_whenAddRepeat_savesScreenAnswers.
@Test
public void onItemSelected_whenAddRepeat_savesScreenAnswers() {
RoboMenu menu = new RoboMenu();
formEntryMenuDelegate.onCreateOptionsMenu(Robolectric.setupActivity(FragmentActivity.class).getMenuInflater(), menu);
formEntryMenuDelegate.onPrepareOptionsMenu(menu);
HashMap answers = new HashMap();
when(answersProvider.getAnswers()).thenReturn(answers);
formEntryMenuDelegate.onOptionsItemSelected(new RoboMenuItem(R.id.menu_add_repeat));
verify(formSaveViewModel).saveAnswersForScreen(answers);
}
use of org.robolectric.fakes.RoboMenu in project android_packages_apps_Settings by omnirom.
the class BluetoothDeviceDetailsFragmentTest method setUp.
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
mContext = spy(RuntimeEnvironment.application);
FakeFeatureFactory.setupForTest();
mFragment = spy(BluetoothDeviceDetailsFragment.newInstance(TEST_ADDRESS));
doReturn(mLocalManager).when(mFragment).getLocalBluetoothManager(any());
doReturn(mCachedDevice).when(mFragment).getCachedDevice(any());
doReturn(mPreferenceScreen).when(mFragment).getPreferenceScreen();
FragmentManager fragmentManager = mock(FragmentManager.class);
when(mFragment.getFragmentManager()).thenReturn(fragmentManager);
mFragmentTransaction = mock(FragmentTransaction.class);
when(fragmentManager.beginTransaction()).thenReturn(mFragmentTransaction);
when(mCachedDevice.getAddress()).thenReturn(TEST_ADDRESS);
Bundle args = new Bundle();
args.putString(BluetoothDeviceDetailsFragment.KEY_DEVICE_ADDRESS, TEST_ADDRESS);
mFragment.setArguments(args);
mFragment.onAttach(mContext);
mMenu = new RoboMenu(mContext);
mInflater = new MenuInflater(mContext);
}
use of org.robolectric.fakes.RoboMenu in project android_packages_apps_Settings by LineageOS.
the class BluetoothDeviceDetailsFragmentTest method renameControlClicked.
@Test
public void renameControlClicked() {
RoboMenu menu = new RoboMenu(mContext);
MenuInflater inflater = new MenuInflater(mContext);
mFragment.onCreateOptionsMenu(menu, inflater);
MenuItem item = menu.getItem(0);
assertThat(item.getItemId()).isEqualTo(BluetoothDeviceDetailsFragment.EDIT_DEVICE_NAME_ITEM_ID);
FragmentManager fragmentManager = mock(FragmentManager.class);
when(mFragment.getFragmentManager()).thenReturn(fragmentManager);
FragmentTransaction ft = mock(FragmentTransaction.class);
when(fragmentManager.beginTransaction()).thenReturn(ft);
ArgumentCaptor<Fragment> captor = ArgumentCaptor.forClass(Fragment.class);
mFragment.onOptionsItemSelected(item);
verify(ft).add(captor.capture(), eq(RemoteDeviceNameDialogFragment.TAG));
RemoteDeviceNameDialogFragment dialog = (RemoteDeviceNameDialogFragment) captor.getValue();
assertThat(dialog).isNotNull();
}
use of org.robolectric.fakes.RoboMenu in project android_packages_apps_Settings by LineageOS.
the class BluetoothDeviceDetailsFragmentTest method renameControlGetsAdded.
@Test
public void renameControlGetsAdded() {
RoboMenu menu = new RoboMenu(mContext);
MenuInflater inflater = new MenuInflater(mContext);
mFragment.onCreateOptionsMenu(menu, inflater);
MenuItem item = menu.getItem(0);
assertThat(item.getTitle()).isEqualTo(mContext.getString(R.string.bluetooth_rename_button));
assertThat(item.getIcon()).isEqualTo(mContext.getDrawable(R.drawable.ic_mode_edit));
}
use of org.robolectric.fakes.RoboMenu in project android_packages_apps_Settings by omnirom.
the class BluetoothDeviceDetailsFragmentTest method renameControlClicked.
@Test
public void renameControlClicked() {
RoboMenu menu = new RoboMenu(mContext);
MenuInflater inflater = new MenuInflater(mContext);
mFragment.onCreateOptionsMenu(menu, inflater);
MenuItem item = menu.getItem(0);
assertThat(item.getItemId()).isEqualTo(BluetoothDeviceDetailsFragment.EDIT_DEVICE_NAME_ITEM_ID);
FragmentManager fragmentManager = mock(FragmentManager.class);
when(mFragment.getFragmentManager()).thenReturn(fragmentManager);
FragmentTransaction ft = mock(FragmentTransaction.class);
when(fragmentManager.beginTransaction()).thenReturn(ft);
ArgumentCaptor<Fragment> captor = ArgumentCaptor.forClass(Fragment.class);
mFragment.onOptionsItemSelected(item);
verify(ft).add(captor.capture(), eq(RemoteDeviceNameDialogFragment.TAG));
RemoteDeviceNameDialogFragment dialog = (RemoteDeviceNameDialogFragment) captor.getValue();
assertThat(dialog).isNotNull();
}
Aggregations