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