Merge "Fix Talkback say twice in MainSwitch" into sc-dev

This commit is contained in:
TreeHugger Robot
2021-07-01 13:47:10 +00:00
committed by Android (Google) Code Review
2 changed files with 3 additions and 5 deletions

View File

@@ -152,9 +152,6 @@ public class MainSwitchBar extends LinearLayout implements CompoundButton.OnChec
public void setTitle(CharSequence text) {
if (mTextView != null) {
mTextView.setText(text);
if (mSwitch != null) {
mSwitch.setContentDescription(mTextView.getText());
}
}
}

View File

@@ -19,6 +19,7 @@ package com.android.settingslib.widget;
import static com.google.common.truth.Truth.assertThat;
import android.content.Context;
import android.text.TextUtils;
import android.view.View;
import android.widget.Switch;
import android.widget.TextView;
@@ -59,13 +60,13 @@ public class MainSwitchBarTest {
}
@Test
public void setTitle_switchShouldHasContentDescription() {
public void setTitle_switchShouldNotHasContentDescription() {
final String title = "title";
mBar.setTitle(title);
final Switch switchObj = mBar.getSwitch();
assertThat(switchObj.getContentDescription()).isEqualTo(title);
assertThat(TextUtils.isEmpty(switchObj.getContentDescription())).isTrue();
}
@Test