Home | History | Annotate | Download | only in shadows
      1 package com.xtremelabs.robolectric.shadows;
      2 
      3 
      4 import java.util.Locale;
      5 
      6 import android.content.res.Configuration;
      7 
      8 import com.xtremelabs.robolectric.Robolectric;
      9 import com.xtremelabs.robolectric.WithTestDefaultsRunner;
     10 import org.junit.Before;
     11 import org.junit.Test;
     12 import org.junit.runner.RunWith;
     13 
     14 import static org.hamcrest.CoreMatchers.equalTo;
     15 import static org.junit.Assert.assertThat;
     16 
     17 @RunWith(WithTestDefaultsRunner.class)
     18 public class ConfigurationTest {
     19 
     20     private Configuration configuration;
     21     private ShadowConfiguration shConfiguration;
     22 
     23     @Before
     24     public void setUp() throws Exception {
     25         configuration = new Configuration();
     26         shConfiguration = Robolectric.shadowOf( configuration );
     27     }
     28 
     29     @Test
     30     public void testSetToDefaults() throws Exception {
     31         configuration.setToDefaults();
     32         assertThat(configuration.screenLayout, equalTo(Configuration.SCREENLAYOUT_LONG_NO | Configuration.SCREENLAYOUT_SIZE_NORMAL));
     33     }
     34 
     35     @Test
     36     public void testSetLocale() {
     37     	shConfiguration.setLocale( Locale.US );
     38     	assertThat( configuration.locale, equalTo( Locale.US ) );
     39 
     40     	shConfiguration.setLocale( Locale.FRANCE);
     41     	assertThat( configuration.locale, equalTo( Locale.FRANCE ) );
     42 }
     43 
     44 }
     45