Home | History | Annotate | Download | only in shadows
      1 package com.xtremelabs.robolectric.shadows;
      2 
      3 import static org.hamcrest.MatcherAssert.assertThat;
      4 import junit.framework.Assert;
      5 
      6 import org.hamcrest.core.IsEqual;
      7 import org.junit.Before;
      8 import org.junit.Test;
      9 import org.junit.runner.RunWith;
     10 
     11 import android.location.Criteria;
     12 
     13 import com.xtremelabs.robolectric.WithTestDefaultsRunner;
     14 
     15 @RunWith(WithTestDefaultsRunner.class)
     16 public class CriteriaTest {
     17     private Criteria criteria;
     18 
     19     @Before
     20     public void setUp() {
     21         criteria = new Criteria();
     22     }
     23 
     24     @Test
     25     public void shouldReturnAccuracy() {
     26         criteria.setAccuracy(Criteria.ACCURACY_COARSE);
     27         assertThat(Criteria.ACCURACY_COARSE, IsEqual.equalTo(criteria.getAccuracy()));
     28     }
     29 
     30     @Test
     31     public void shouldReturnPowerRequirement() {
     32         criteria.setPowerRequirement(Criteria.POWER_HIGH);
     33         assertThat(Criteria.POWER_HIGH, IsEqual.equalTo(criteria.getPowerRequirement()));
     34     }
     35 
     36     @Test
     37     public void shouldBeEqual() {
     38         criteria.setPowerRequirement(Criteria.POWER_HIGH);
     39         criteria.setAccuracy(Criteria.ACCURACY_COARSE);
     40 
     41         Criteria criteria1 = new Criteria(criteria);
     42         Assert.assertTrue(criteria1.equals(criteria));
     43 
     44         Criteria criteria2 = new Criteria();
     45         criteria2.setPowerRequirement(Criteria.POWER_HIGH);
     46         criteria2.setAccuracy(Criteria.ACCURACY_COARSE);
     47         Assert.assertTrue(criteria2.equals(criteria));
     48     }
     49 
     50 }
     51