Merge "Make it possible to have open tether network" into pi-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
b410c21a01
@@ -39,9 +39,10 @@ public class WifiUtilsTest {
|
||||
public void testPassword() {
|
||||
final String longPassword = "123456789012345678901234567890"
|
||||
+ "1234567890123456789012345678901234567890";
|
||||
assertThat(WifiUtils.isPasswordValid("123")).isFalse();
|
||||
assertThat(WifiUtils.isPasswordValid("12345678")).isTrue();
|
||||
assertThat(WifiUtils.isPasswordValid("1234567890")).isTrue();
|
||||
assertThat(WifiUtils.isPasswordValid(longPassword)).isFalse();
|
||||
assertThat(WifiUtils.isHotspotPasswordValid("123")).isFalse();
|
||||
assertThat(WifiUtils.isHotspotPasswordValid("12345678")).isTrue();
|
||||
assertThat(WifiUtils.isHotspotPasswordValid("1234567890")).isTrue();
|
||||
assertThat(WifiUtils.isHotspotPasswordValid(longPassword)).isFalse();
|
||||
assertThat(WifiUtils.isHotspotPasswordValid("")).isTrue();
|
||||
}
|
||||
}
|
||||
|
@@ -113,4 +113,36 @@ public class WifiTetherPasswordPreferenceControllerTest {
|
||||
assertThat(mController.getPassword()).isEqualTo(config.preSharedKey);
|
||||
assertThat(mPreference.getSummary()).isEqualTo(config.preSharedKey);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getSecuritySettingForPassword_returnCorrectType() {
|
||||
// valid wpa2 password
|
||||
mController.displayPreference(mScreen);
|
||||
assertThat(mController.getSecuritySettingForPassword())
|
||||
.isEqualTo(WifiConfiguration.KeyMgmt.WPA2_PSK);
|
||||
|
||||
// password which is empty returns NONE
|
||||
mConfig = new WifiConfiguration();
|
||||
mConfig.SSID = "test_1234";
|
||||
mConfig.preSharedKey = "";
|
||||
when(mContext.getSystemService(Context.WIFI_SERVICE)).thenReturn(mWifiManager);
|
||||
when(mWifiManager.getWifiApConfiguration()).thenReturn(mConfig);
|
||||
mController = new WifiTetherPasswordPreferenceController(mContext, mListener);
|
||||
|
||||
mController.displayPreference(mScreen);
|
||||
assertThat(mController.getSecuritySettingForPassword())
|
||||
.isEqualTo(WifiConfiguration.KeyMgmt.NONE);
|
||||
|
||||
// default for unsupported types is wpa2
|
||||
mConfig = new WifiConfiguration();
|
||||
mConfig.SSID = "test_1234";
|
||||
mConfig.preSharedKey = "short";
|
||||
when(mContext.getSystemService(Context.WIFI_SERVICE)).thenReturn(mWifiManager);
|
||||
when(mWifiManager.getWifiApConfiguration()).thenReturn(mConfig);
|
||||
mController = new WifiTetherPasswordPreferenceController(mContext, mListener);
|
||||
|
||||
mController.displayPreference(mScreen);
|
||||
assertThat(mController.getSecuritySettingForPassword())
|
||||
.isEqualTo(WifiConfiguration.KeyMgmt.WPA2_PSK);
|
||||
}
|
||||
}
|
||||
|
@@ -1,38 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2017 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.settings.wifi.tether;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import android.net.wifi.WifiConfiguration;
|
||||
|
||||
import com.android.settings.testutils.SettingsRobolectricTestRunner;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
@RunWith(SettingsRobolectricTestRunner.class)
|
||||
public class WifiTetherSettingsTest {
|
||||
|
||||
@Test
|
||||
public void ensureWifiConfigHasPassword_shouldGeneratePassword() {
|
||||
WifiConfiguration config = new WifiConfiguration();
|
||||
WifiTetherSettings.ensureWifiConfigHasPassword(config);
|
||||
|
||||
assertThat(config.preSharedKey).isNotEmpty();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user