1 /* 2 * Copyright (C) 2008 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package android.location.cts; 18 19 import dalvik.annotation.TestLevel; 20 import dalvik.annotation.TestTargetClass; 21 import dalvik.annotation.TestTargetNew; 22 23 import android.content.Context; 24 import android.location.Criteria; 25 import android.location.LocationManager; 26 import android.location.LocationProvider; 27 import android.test.AndroidTestCase; 28 29 @TestTargetClass(LocationProvider.class) 30 public class LocationProviderTest extends AndroidTestCase { 31 private LocationManager mLocationManager; 32 33 @Override 34 protected void setUp() throws Exception { 35 super.setUp(); 36 mLocationManager = 37 (LocationManager) getContext().getSystemService(Context.LOCATION_SERVICE); 38 } 39 40 @TestTargetNew( 41 level = TestLevel.COMPLETE, 42 method = "getName", 43 args = {} 44 ) 45 public void testGetName() { 46 String name = "gps"; 47 LocationProvider locationProvider = mLocationManager.getProvider(name); 48 assertEquals(name, locationProvider.getName()); 49 } 50 51 @TestTargetNew( 52 level = TestLevel.COMPLETE, 53 method = "meetsCriteria", 54 args = {android.location.Criteria.class} 55 ) 56 public void testMeetsCriteria() { 57 LocationProvider locationProvider = mLocationManager.getProvider("gps"); 58 59 Criteria criteria = new Criteria(); 60 criteria.setAltitudeRequired(true); 61 criteria.setBearingRequired(true); 62 assertTrue(locationProvider.meetsCriteria(criteria)); 63 } 64 } 65