1 /* 2 * Copyright (C) 2009 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.telephony.cts; 18 19 import static android.telephony.TelephonyManager.NETWORK_TYPE_UNKNOWN; 20 import static android.telephony.TelephonyManager.NETWORK_TYPE_EDGE; 21 import static android.telephony.TelephonyManager.NETWORK_TYPE_GPRS; 22 import static android.telephony.TelephonyManager.NETWORK_TYPE_UMTS; 23 24 import static org.junit.Assert.assertEquals; 25 26 import android.os.Parcel; 27 import android.telephony.NeighboringCellInfo; 28 29 import org.junit.Test; 30 31 public class NeighboringCellInfoTest { 32 private static final int RSSI = 20; 33 private static final int CID = 0xffff; 34 35 @Test testNeighboringCellInfo()36 public void testNeighboringCellInfo() { 37 int rssi = 31; 38 String location = "ffffffff"; 39 NeighboringCellInfo nc; 40 41 // test constructor 42 nc = new NeighboringCellInfo(rssi, "FFFFFFF", NETWORK_TYPE_EDGE); 43 assertEquals(NETWORK_TYPE_EDGE, nc.getNetworkType()); 44 assertEquals(rssi, nc.getRssi()); 45 assertEquals(0xfff, nc.getLac()); 46 assertEquals(0xffff, nc.getCid()); 47 assertEquals(NeighboringCellInfo.UNKNOWN_CID, nc.getPsc()); 48 49 nc = new NeighboringCellInfo(rssi, "1FF", NETWORK_TYPE_UMTS); 50 assertEquals(NETWORK_TYPE_UMTS, nc.getNetworkType()); 51 assertEquals(rssi, nc.getRssi()); 52 assertEquals(NeighboringCellInfo.UNKNOWN_CID, nc.getCid()); 53 assertEquals(NeighboringCellInfo.UNKNOWN_CID, nc.getLac()); 54 assertEquals(0x1ff, nc.getPsc()); 55 56 nc = new NeighboringCellInfo(rssi, "1FF", NETWORK_TYPE_UNKNOWN); 57 assertEquals(NETWORK_TYPE_UNKNOWN, nc.getNetworkType()); 58 assertEquals(rssi, nc.getRssi()); 59 assertEquals(NeighboringCellInfo.UNKNOWN_CID, nc.getCid()); 60 assertEquals(NeighboringCellInfo.UNKNOWN_CID, nc.getLac()); 61 assertEquals(NeighboringCellInfo.UNKNOWN_CID, nc.getPsc()); 62 63 // test parcel 64 nc = new NeighboringCellInfo(rssi, "12345678", NETWORK_TYPE_GPRS); 65 assertEquals(NETWORK_TYPE_GPRS, nc.getNetworkType()); 66 assertEquals(rssi, nc.getRssi()); 67 assertEquals(0x1234, nc.getLac()); 68 assertEquals(0x5678, nc.getCid()); 69 assertEquals(NeighboringCellInfo.UNKNOWN_CID, nc.getPsc()); 70 71 Parcel p = Parcel.obtain(); 72 p.setDataPosition(0); 73 nc.writeToParcel(p, 0); 74 75 p.setDataPosition(0); 76 NeighboringCellInfo nw = new NeighboringCellInfo(p); 77 assertEquals(NETWORK_TYPE_GPRS, nw.getNetworkType()); 78 assertEquals(rssi, nw.getRssi()); 79 assertEquals(0x1234, nw.getLac()); 80 assertEquals(0x5678, nw.getCid()); 81 assertEquals(NeighboringCellInfo.UNKNOWN_CID, nw.getPsc()); 82 } 83 } 84