Code example for Spinner

Methods: setAdapter, getSelectedItem

0
		assertThat(spinner.getSelectedItem(), nullValue());
	} 
	 
	@Test (expected = IndexOutOfBoundsException.class)	 
	public void getSelectedItemShouldThrowException_EmptyArray(){ 
		spinner.setAdapter(new MyArrayAdapter(context, new String[]{}));
		spinner.getSelectedItem();		
	} 
	 
	@Test 
	public void setSelectionWithAnimatedTransition() {		 
		spinner.setAdapter(arrayAdapter);
		spinner.setSelection(0, true);
		 
		assertThat((String) spinner.getSelectedItem(), equalTo("foo"));
		assertThat((String) spinner.getSelectedItem(), not(equalTo("bar")));
		 
		assertThat(shadowSpinner.isAnimatedTransition(), equalTo(true));
	} 
 
Experience pair programming with AI  Get Codota for Java