DataProfileTest.java revision c36b42eb847959f451900d1eac4e32be180a0b99
1/* 2 * Copyright (C) 2010 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 17package com.android.internal.telephony.dataconnection; 18 19import android.telephony.data.DataProfile; 20import android.test.suitebuilder.annotation.SmallTest; 21 22import com.android.internal.telephony.RILConstants; 23 24import junit.framework.TestCase; 25 26public class DataProfileTest extends TestCase { 27 28 private ApnSetting mApn1 = new ApnSetting( 29 2163, // id 30 "44010", // numeric 31 "sp-mode", // name 32 "fake_apn", // apn 33 "", // proxy 34 "", // port 35 "", // mmsc 36 "", // mmsproxy 37 "", // mmsport 38 "user", // user 39 "passwd", // password 40 -1, // authtype 41 new String[]{"default", "supl"}, // types 42 "IPV6", // protocol 43 "IP", // roaming_protocol 44 true, // carrier_enabled 45 0, // bearer 46 0, // bearer_bitmask 47 1234, // profile_id 48 false, // modem_cognitive 49 321, // max_conns 50 456, // wait_time 51 789, // max_conns_time 52 0, // mtu 53 "", // mvno_type 54 ""); // mnvo_match_data 55 56 private ApnSetting mApn2 = new ApnSetting( 57 2163, // id 58 "44010", // numeric 59 "sp-mode", // name 60 "fake_apn", // apn 61 "", // proxy 62 "", // port 63 "", // mmsc 64 "", // mmsproxy 65 "", // mmsport 66 "user", // user 67 "passwd", // password 68 -1, // authtype 69 new String[]{"default", "supl"}, // types 70 "IP", // protocol 71 "IP", // roaming_protocol 72 true, // carrier_enabled 73 0, // bearer 74 0, // bearer_bitmask 75 1234, // profile_id 76 false, // modem_cognitive 77 111, // max_conns 78 456, // wait_time 79 789, // max_conns_time 80 0, // mtu 81 "", // mvno_type 82 ""); // mnvo_match_data 83 84 @SmallTest 85 public void testCreateFromApnSetting() throws Exception { 86 DataProfile dp = DcTracker.createDataProfile(mApn1, mApn1.profileId); 87 assertEquals(mApn1.profileId, dp.getProfileId()); 88 assertEquals(mApn1.apn, dp.getApn()); 89 assertEquals(mApn1.protocol, dp.getProtocol()); 90 assertEquals(RILConstants.SETUP_DATA_AUTH_PAP_CHAP, dp.getAuthType()); 91 assertEquals(mApn1.user, dp.getUserName()); 92 assertEquals(mApn1.password, dp.getPassword()); 93 assertEquals(0, dp.getType()); 94 assertEquals(mApn1.maxConnsTime, dp.getMaxConnsTime()); 95 assertEquals(mApn1.maxConns, dp.getMaxConns()); 96 assertEquals(mApn1.waitTime, dp.getWaitTime()); 97 assertEquals(mApn1.carrierEnabled, dp.isEnabled()); 98 } 99 100 @SmallTest 101 public void testEquals() throws Exception { 102 DataProfile dp1 = DcTracker.createDataProfile(mApn1, mApn1.profileId); 103 DataProfile dp2 = DcTracker.createDataProfile(mApn1, mApn1.profileId); 104 assertEquals(dp1, dp2); 105 106 dp2 = DcTracker.createDataProfile(mApn2, mApn2.profileId); 107 assertFalse(dp1.equals(dp2)); 108 } 109} 110