77import android .support .v4 .app .FragmentActivity ;
88import android .support .v4 .app .FragmentManager ;
99import android .util .AttributeSet ;
10+ import android .widget .LinearLayout ;
1011
1112import com .stepstone .stepper .adapter .AbstractFragmentStepAdapter ;
1213import com .stepstone .stepper .test .runner .StepperRobolectricTestRunner ;
1819import org .robolectric .Robolectric ;
1920
2021import static com .stepstone .stepper .test .assertion .StepperLayoutAssert .assertThat ;
22+ import static org .junit .Assert .assertEquals ;
2123import static org .mockito .Mockito .mock ;
2224
2325
@@ -31,6 +33,8 @@ public class StepperLayoutSanityTest {
3133 private static final String TYPE_DOTS = "dots" ;
3234 private static final String TYPE_TABS = "tabs" ;
3335
36+ private static final String ORIENTATION_HORIZONTAL = "horizontal" ;
37+
3438 FragmentActivity activity ;
3539
3640 @ Before
@@ -131,6 +135,38 @@ public void should_show_tabs_when_adapter_is_set_for_tabs_type() {
131135 .hasDottedProgressBarHidden ();
132136 }
133137
138+ @ Test
139+ public void should_ignore_horizontal_orientation_if_provided_from_attributes () {
140+ //given
141+ AttributeSet attributeSet = Robolectric .buildAttributeSet ()
142+ .addAttribute (R .attr .ms_stepperType , TYPE_DOTS )
143+ .addAttribute (android .R .attr .orientation , ORIENTATION_HORIZONTAL )
144+ .build ();
145+
146+ //when
147+ StepperLayout stepperLayout = new StepperLayout (activity , attributeSet );
148+
149+ //then
150+ assertVerticalOrientationUsed (stepperLayout );
151+ }
152+
153+ @ Test
154+ public void should_ignore_horizontal_orientation_if_provided_programmatically () {
155+ //given
156+ AttributeSet attributeSet = createAttributeSetWithStepperType (TYPE_DOTS );
157+ StepperLayout stepperLayout = new StepperLayout (activity , attributeSet );
158+
159+ //when
160+ stepperLayout .setOrientation (LinearLayout .HORIZONTAL );
161+
162+ //then
163+ assertVerticalOrientationUsed (stepperLayout );
164+ }
165+
166+ private void assertVerticalOrientationUsed (StepperLayout stepperLayout ) {
167+ assertEquals ("Invalid orientation" , stepperLayout .getOrientation (), LinearLayout .VERTICAL );
168+ }
169+
134170 private void whenAdapterIsSet (StepperLayout stepperLayout ) {
135171 stepperLayout .setAdapter (new DummyStepAdapter (activity .getSupportFragmentManager (), activity ));
136172 }
0 commit comments