blob: 335653bc2f18673531bc1aca28dfb92cae32711e [file] [log] [blame]
Sundeep Ghuman7c32aa32017-06-26 17:13:00 -07001/*
2 * Copyright (C) 2017 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 */
16package com.android.settingslib.wifi;
17
18import static com.google.common.truth.Truth.assertThat;
19
20import android.content.Context;
21
22import com.android.settingslib.SettingLibRobolectricTestRunner;
23import com.android.settingslib.TestConfig;
24
25import org.junit.Test;
26import org.junit.runner.RunWith;
27import org.robolectric.RuntimeEnvironment;
28import org.robolectric.annotation.Config;
29
30@RunWith(SettingLibRobolectricTestRunner.class)
31@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
32public class AccessPointPreferenceTest {
33
34 private Context mContext = RuntimeEnvironment.application;
35
36 @Test
37 public void generatePreferenceKey_shouldReturnSsidPlusSecurity() {
38 String ssid = "ssid";
39 int security = AccessPoint.SECURITY_WEP;
40 String expectedKey = ssid + ',' + security;
41
42 TestAccessPointBuilder builder = new TestAccessPointBuilder(mContext);
43 builder.setSsid(ssid).setSecurity(security);
44
45 assertThat(AccessPointPreference.generatePreferenceKey(builder.build()))
46 .isEqualTo(expectedKey);
47 }
48
49 @Test
50 public void generatePreferenceKey_shouldReturnBssidPlusSecurity() {
51 String bssid = "bssid";
52 int security = AccessPoint.SECURITY_WEP;
53 String expectedKey = bssid + ',' + security;
54
55 TestAccessPointBuilder builder = new TestAccessPointBuilder(mContext);
56 builder.setBssid(bssid).setSecurity(security);
57
58 assertThat(AccessPointPreference.generatePreferenceKey(builder.build()))
59 .isEqualTo(expectedKey);
60 }
61}