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 20 import android.content.Context; 21 import android.location.GpsSatellite; 22 import android.location.GpsStatus; 23 import android.location.LocationManager; 24 import android.test.AndroidTestCase; 25 26 import java.util.Iterator; 27 28 public class GpsSatelliteTest extends AndroidTestCase { 29 private GpsSatellite mGpsSatellite; 30 31 @Override 32 protected void setUp() throws Exception { 33 super.setUp(); 34 LocationManager lm = 35 (LocationManager) getContext().getSystemService(Context.LOCATION_SERVICE); 36 GpsStatus gpsStatus = lm.getGpsStatus(null); 37 38 Iterator<GpsSatellite> iterator = gpsStatus.getSatellites().iterator(); 39 if (iterator.hasNext()) { 40 mGpsSatellite = iterator.next(); 41 } 42 } 43 44 public void testGetAzimuth() { 45 if (mGpsSatellite != null) { 46 assertTrue(mGpsSatellite.getAzimuth() >= 0 && mGpsSatellite.getAzimuth() <= 360); 47 } 48 } 49 50 public void testGetElevation() { 51 if (mGpsSatellite != null) { 52 assertTrue(mGpsSatellite.getElevation() >= 0 && mGpsSatellite.getElevation() <= 90); 53 } 54 } 55 56 public void testGetPrn() { 57 if (mGpsSatellite != null) { 58 // make sure there is no exception. 59 mGpsSatellite.getPrn(); 60 } 61 } 62 63 public void testGetSnr() { 64 if (mGpsSatellite != null) { 65 // make sure there is no exception. 66 mGpsSatellite.getSnr(); 67 } 68 } 69 70 public void testHasAlmanac() { 71 if (mGpsSatellite != null) { 72 // make sure there is no exception. 73 mGpsSatellite.hasAlmanac(); 74 } 75 } 76 77 public void testHasEphemeris() { 78 if (mGpsSatellite != null) { 79 // make sure there is no exception. 80 mGpsSatellite.hasEphemeris(); 81 } 82 } 83 84 public void testUsedInFix() { 85 if (mGpsSatellite != null) { 86 // make sure there is no exception. 87 mGpsSatellite.usedInFix(); 88 } 89 } 90 } 91