1/* 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 */ 16 17package com.android.settings.wifi; 18 19 20import com.android.settings.TestConfig; 21import com.android.settings.testutils.SettingsRobolectricTestRunner; 22 23import org.junit.Test; 24import org.junit.runner.RunWith; 25import org.robolectric.annotation.Config; 26 27import static com.google.common.truth.Truth.assertThat; 28 29@RunWith(SettingsRobolectricTestRunner.class) 30@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION) 31public class WifiUtilsTest { 32 33 @Test 34 public void testSSID() { 35 assertThat(WifiUtils.isSSIDTooLong("123")).isFalse(); 36 assertThat(WifiUtils.isSSIDTooLong("☎☎☎☎☎☎☎☎☎☎☎☎☎☎☎☎☎☎☎☎☎☎☎☎☎☎☎☎☎☎☎☎☎☎")).isTrue(); 37 38 assertThat(WifiUtils.isSSIDTooShort("123")).isFalse(); 39 assertThat(WifiUtils.isSSIDTooShort("")).isTrue(); 40 } 41 42 @Test 43 public void testPassword() { 44 final String longPassword = "123456789012345678901234567890" 45 + "1234567890123456789012345678901234567890"; 46 assertThat(WifiUtils.isPasswordValid("123")).isFalse(); 47 assertThat(WifiUtils.isPasswordValid("12345678")).isTrue(); 48 assertThat(WifiUtils.isPasswordValid("1234567890")).isTrue(); 49 assertThat(WifiUtils.isPasswordValid(longPassword)).isFalse(); 50 } 51 52} 53