Search in sources :

Example 16 with RoboMenu

use of org.robolectric.fakes.RoboMenu in project android_packages_apps_Settings by DirtyUnicorns.

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();
}
Also used : FragmentManager(android.app.FragmentManager) FragmentTransaction(android.app.FragmentTransaction) MenuInflater(android.view.MenuInflater) RoboMenu(org.robolectric.fakes.RoboMenu) MenuItem(android.view.MenuItem) Fragment(android.app.Fragment) Test(org.junit.Test)

Example 17 with RoboMenu

use of org.robolectric.fakes.RoboMenu in project android_packages_apps_Settings by DirtyUnicorns.

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));
}
Also used : MenuInflater(android.view.MenuInflater) RoboMenu(org.robolectric.fakes.RoboMenu) MenuItem(android.view.MenuItem) Test(org.junit.Test)

Example 18 with RoboMenu

use of org.robolectric.fakes.RoboMenu in project android_packages_apps_Settings by crdroidandroid.

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));
}
Also used : MenuInflater(android.view.MenuInflater) RoboMenu(org.robolectric.fakes.RoboMenu) MenuItem(android.view.MenuItem) Test(org.junit.Test)

Example 19 with RoboMenu

use of org.robolectric.fakes.RoboMenu in project android_packages_apps_Settings by crdroidandroid.

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();
}
Also used : FragmentManager(android.app.FragmentManager) FragmentTransaction(android.app.FragmentTransaction) MenuInflater(android.view.MenuInflater) RoboMenu(org.robolectric.fakes.RoboMenu) MenuItem(android.view.MenuItem) Fragment(android.app.Fragment) Test(org.junit.Test)

Example 20 with RoboMenu

use of org.robolectric.fakes.RoboMenu in project collect by opendatakit.

the class FormEntryMenuDelegateTest method onItemSelected_whenHierarchy_whenRecording_showsWarning.

@Test
public void onItemSelected_whenHierarchy_whenRecording_showsWarning() {
    RoboMenu menu = new RoboMenu();
    formEntryMenuDelegate.onCreateOptionsMenu(Robolectric.setupActivity(FragmentActivity.class).getMenuInflater(), menu);
    formEntryMenuDelegate.onPrepareOptionsMenu(menu);
    when(audioRecorder.isRecording()).thenReturn(true);
    formEntryMenuDelegate.onOptionsItemSelected(new RoboMenuItem(R.id.menu_goto));
    assertThat(shadowOf(activity).getNextStartedActivity(), is(nullValue()));
    RecordingWarningDialogFragment dialog = getFragmentByClass(activity.getSupportFragmentManager(), RecordingWarningDialogFragment.class);
    assertThat(dialog, is(notNullValue()));
    assertThat(dialog.getDialog().isShowing(), is(true));
}
Also used : RoboMenu(org.robolectric.fakes.RoboMenu) RoboMenuItem(org.robolectric.fakes.RoboMenuItem) Test(org.junit.Test)

Aggregations

RoboMenu (org.robolectric.fakes.RoboMenu)33 Test (org.junit.Test)31 MenuInflater (android.view.MenuInflater)14 MenuItem (android.view.MenuItem)12 RoboMenuItem (org.robolectric.fakes.RoboMenuItem)12 Fragment (android.app.Fragment)6 FragmentManager (android.app.FragmentManager)6 FragmentTransaction (android.app.FragmentTransaction)6 Bundle (android.os.Bundle)2 FragmentManager (androidx.fragment.app.FragmentManager)2 FragmentTransaction (androidx.fragment.app.FragmentTransaction)2 HashMap (java.util.HashMap)2 Before (org.junit.Before)2 ShadowActivity (org.robolectric.shadows.ShadowActivity)2