diff options
| -rw-r--r-- | packages/SettingsLib/src/com/android/settingslib/wifi/AccessPoint.java | 4 | ||||
| -rw-r--r-- | packages/SettingsLib/tests/src/com/android/settingslib/wifi/AccessPointTest.java | 51 |
2 files changed, 53 insertions, 2 deletions
diff --git a/packages/SettingsLib/src/com/android/settingslib/wifi/AccessPoint.java b/packages/SettingsLib/src/com/android/settingslib/wifi/AccessPoint.java index 202e066dc30c..61c1fe2d399f 100644 --- a/packages/SettingsLib/src/com/android/settingslib/wifi/AccessPoint.java +++ b/packages/SettingsLib/src/com/android/settingslib/wifi/AccessPoint.java @@ -358,8 +358,8 @@ public class AccessPoint implements Comparable<AccessPoint> { } public CharSequence getSsid() { - SpannableString str = new SpannableString(ssid); - str.setSpan(new TtsSpan.VerbatimBuilder(ssid).build(), 0, ssid.length(), + final SpannableString str = new SpannableString(ssid); + str.setSpan(new TtsSpan.TelephoneBuilder(ssid).build(), 0, ssid.length(), Spannable.SPAN_INCLUSIVE_INCLUSIVE); return str; } diff --git a/packages/SettingsLib/tests/src/com/android/settingslib/wifi/AccessPointTest.java b/packages/SettingsLib/tests/src/com/android/settingslib/wifi/AccessPointTest.java new file mode 100644 index 000000000000..ec44b4502024 --- /dev/null +++ b/packages/SettingsLib/tests/src/com/android/settingslib/wifi/AccessPointTest.java @@ -0,0 +1,51 @@ +/* + * Copyright (C) 2016 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.settingslib.wifi; + +import android.os.Bundle; +import android.support.test.InstrumentationRegistry; +import android.support.test.filters.SmallTest; +import android.support.test.runner.AndroidJUnit4; +import android.text.SpannableString; +import android.text.style.TtsSpan; + +import org.junit.Test; +import org.junit.runner.RunWith; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +@SmallTest +@RunWith(AndroidJUnit4.class) +public class AccessPointTest { + + private static final String TEST_SSID = "test_ssid"; + + @Test + public void testSsidIsTelephoneSpan() { + final Bundle bundle = new Bundle(); + bundle.putString("key_ssid", TEST_SSID); + final AccessPoint ap = new AccessPoint(InstrumentationRegistry.getTargetContext(), bundle); + final CharSequence ssid = ap.getSsid(); + + assertTrue(ssid instanceof SpannableString); + + TtsSpan[] spans = ((SpannableString) ssid).getSpans(0, TEST_SSID.length(), TtsSpan.class); + + assertEquals(1, spans.length); + assertEquals(TtsSpan.TYPE_TELEPHONE, spans[0].getType()); + } +} |