[QsRevamp Clean Up] Audio detailed view and its controller
Bug: b/305075031 Change-Id: I957a522aa550e60b3208f777b1b54066e722c27c Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4943765 Reviewed-by: Alex Newcomer <newcomer@chromium.org> Commit-Queue: Jiaming Cheng <jiamingc@chromium.org> Cr-Commit-Position: refs/heads/main@{#1211157}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
4a0b58bb3c
commit
f2e7a40fe9
@ -3323,7 +3323,7 @@ Some features are limited to increase battery life.
|
||||
<message name="IDS_ASH_STATUS_TRAY_AUDIO" desc="The label used in audio detailed page bottom header of ash tray pop up.">
|
||||
Audio settings
|
||||
</message>
|
||||
<message name="IDS_ASH_STATUS_TRAY_AUDIO_QS_REVAMP" desc="The label used in audio detailed page bottom header of ash tray pop up.">
|
||||
<message name="IDS_ASH_STATUS_TRAY_AUDIO_TITLE" desc="The label used in audio detailed page bottom header of ash tray pop up.">
|
||||
Audio
|
||||
</message>
|
||||
<message name="IDS_ASH_STATUS_TRAY_AUDIO_OUTPUT" desc="The label used in audio detailed page for audio output section of ash tray pop up.">
|
||||
|
@ -69,24 +69,20 @@
|
||||
namespace ash {
|
||||
namespace {
|
||||
|
||||
const int kLabelFontSizeDelta = 1;
|
||||
const int kToggleButtonRowViewSpacing = 18;
|
||||
const int kToggleButtonRowRightPadding = 16;
|
||||
const int kNbsWarningMinHeight = 80;
|
||||
constexpr auto kLiveCaptionContainerMargins = gfx::Insets::TLBR(0, 0, 8, 0);
|
||||
constexpr auto kToggleButtonRowLabelPadding = gfx::Insets::TLBR(16, 0, 15, 0);
|
||||
constexpr auto kToggleButtonRowViewPadding = gfx::Insets::TLBR(0, 56, 8, 0);
|
||||
constexpr auto kQsToggleButtonRowViewPadding =
|
||||
constexpr auto kToggleButtonRowViewPadding =
|
||||
gfx::Insets::TLBR(0, 32, 0, kToggleButtonRowRightPadding);
|
||||
constexpr auto kQsToggleButtonRowPreferredSize = gfx::Size(0, 32);
|
||||
constexpr auto kQsToggleButtonRowLabelPadding = gfx::Insets::VH(8, 12);
|
||||
constexpr auto kQsToggleButtonRowMargins = gfx::Insets::VH(4, 0);
|
||||
constexpr auto kToggleButtonRowPreferredSize = gfx::Size(0, 32);
|
||||
constexpr auto kToggleButtonRowLabelPadding = gfx::Insets::VH(8, 12);
|
||||
constexpr auto kToggleButtonRowMargins = gfx::Insets::VH(4, 0);
|
||||
constexpr auto kSeparatorMargins = gfx::Insets::TLBR(4, 32, 12, 32);
|
||||
constexpr auto kTextRowInsets = gfx::Insets::VH(8, 24);
|
||||
constexpr auto kDevicesNameViewPreferredSize = gfx::Size(0, 44);
|
||||
constexpr auto kDevicesTriViewInsets = gfx::Insets::TLBR(0, 24, 0, 32);
|
||||
constexpr auto kDevicesTriViewBorder = gfx::Insets::VH(0, 4);
|
||||
constexpr auto kQsSubsectionMargins = gfx::Insets::TLBR(0, 0, 4, 0);
|
||||
constexpr auto kSubsectionMargins = gfx::Insets::TLBR(0, 0, 4, 0);
|
||||
|
||||
// This callback is only used for tests.
|
||||
AudioDetailedView::NoiseCancellationCallback*
|
||||
@ -261,23 +257,13 @@ void AudioDetailedView::Update() {
|
||||
void AudioDetailedView::OnAccessibilityStatusChanged() {
|
||||
AccessibilityControllerImpl* controller =
|
||||
Shell::Get()->accessibility_controller();
|
||||
if (features::IsQsRevampEnabled()) {
|
||||
// The live caption state has been updated.
|
||||
UpdateLiveCaptionView(controller->live_caption().enabled());
|
||||
} else if (live_caption_view_ &&
|
||||
controller->IsLiveCaptionSettingVisibleInTray()) {
|
||||
TrayPopupUtils::UpdateCheckMarkVisibility(
|
||||
live_caption_view_, controller->live_caption().enabled());
|
||||
}
|
||||
// The live caption state has been updated.
|
||||
UpdateLiveCaptionView(controller->live_caption().enabled());
|
||||
}
|
||||
|
||||
void AudioDetailedView::OnCapabilityAccessUpdate(
|
||||
const apps::CapabilityAccessUpdate& update) {
|
||||
if (!features::IsQsRevampEnabled()) {
|
||||
UpdateAgcInfoRow();
|
||||
} else {
|
||||
UpdateQsAgcInfoRow();
|
||||
}
|
||||
UpdateAgcInfoRow();
|
||||
}
|
||||
|
||||
void AudioDetailedView::OnAppCapabilityAccessCacheWillBeDestroyed(
|
||||
@ -324,23 +310,12 @@ void AudioDetailedView::OnSessionStateChanged(
|
||||
void AudioDetailedView::AddAudioSubHeader(views::View* container,
|
||||
const gfx::VectorIcon& icon,
|
||||
const int text_id) {
|
||||
if (!features::IsQsRevampEnabled()) {
|
||||
TriView* header = AddScrollListSubHeader(container, icon, text_id);
|
||||
header->SetContainerVisible(TriView::Container::END, /*visible=*/false);
|
||||
return;
|
||||
}
|
||||
|
||||
auto* sub_header_label_ = TrayPopupUtils::CreateDefaultLabel();
|
||||
sub_header_label_->SetText(l10n_util::GetStringUTF16(text_id));
|
||||
sub_header_label_->SetEnabledColorId(cros_tokens::kCrosSysOnSurfaceVariant);
|
||||
if (chromeos::features::IsJellyEnabled()) {
|
||||
sub_header_label_->SetAutoColorReadabilityEnabled(false);
|
||||
TypographyProvider::Get()->StyleLabel(TypographyToken::kCrosBody2,
|
||||
*sub_header_label_);
|
||||
} else {
|
||||
TrayPopupUtils::SetLabelFontList(sub_header_label_,
|
||||
TrayPopupUtils::FontStyle::kSubHeader);
|
||||
}
|
||||
sub_header_label_->SetAutoColorReadabilityEnabled(false);
|
||||
TypographyProvider::Get()->StyleLabel(TypographyToken::kCrosBody2,
|
||||
*sub_header_label_);
|
||||
sub_header_label_->SetBorder(views::CreateEmptyBorder(kTextRowInsets));
|
||||
container->AddChildView(sub_header_label_);
|
||||
return;
|
||||
@ -361,10 +336,8 @@ views::View* AudioDetailedView::AddDeviceSlider(
|
||||
? CrasAudioHandler::Get()->IsOutputMutedForDevice(device.id)
|
||||
: CrasAudioHandler::Get()->IsInputMutedForDevice(device.id);
|
||||
UpdateDeviceContainerColor(device_name_container, is_muted);
|
||||
if (chromeos::features::IsJellyEnabled()) {
|
||||
TypographyProvider::Get()->StyleLabel(TypographyToken::kCrosButton2,
|
||||
*device_name_container->text_label());
|
||||
}
|
||||
TypographyProvider::Get()->StyleLabel(TypographyToken::kCrosButton2,
|
||||
*device_name_container->text_label());
|
||||
device_name_container->SetPaintToLayer();
|
||||
// If this device is the active one, disables event handling on
|
||||
// `device_name_container` so that `slider` can handle the events.
|
||||
@ -417,14 +390,8 @@ views::View* AudioDetailedView::AddDeviceSlider(
|
||||
|
||||
void AudioDetailedView::CreateItems() {
|
||||
CreateScrollableList();
|
||||
if (features::IsQsRevampEnabled()) {
|
||||
CreateTitleRow(IDS_ASH_STATUS_TRAY_AUDIO_QS_REVAMP);
|
||||
// `live_caption_view_` will always shows up in the revamped
|
||||
// `AudioDetailedView`.
|
||||
CreateLiveCaptionView();
|
||||
} else {
|
||||
CreateTitleRow(IDS_ASH_STATUS_TRAY_AUDIO);
|
||||
}
|
||||
CreateTitleRow(IDS_ASH_STATUS_TRAY_AUDIO_TITLE);
|
||||
CreateLiveCaptionView();
|
||||
|
||||
mic_gain_controller_ = std::make_unique<MicGainSliderController>();
|
||||
unified_volume_slider_controller_ =
|
||||
@ -455,12 +422,10 @@ void AudioDetailedView::CreateLiveCaptionView() {
|
||||
live_caption_view_->AddViewAndLabel(
|
||||
std::move(toggle_icon),
|
||||
l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_LIVE_CAPTION));
|
||||
if (chromeos::features::IsJellyEnabled()) {
|
||||
live_caption_view_->text_label()->SetEnabledColorId(
|
||||
cros_tokens::kCrosSysOnSurface);
|
||||
TypographyProvider::Get()->StyleLabel(TypographyToken::kCrosButton1,
|
||||
*live_caption_view_->text_label());
|
||||
}
|
||||
live_caption_view_->text_label()->SetEnabledColorId(
|
||||
cros_tokens::kCrosSysOnSurface);
|
||||
TypographyProvider::Get()->StyleLabel(TypographyToken::kCrosButton1,
|
||||
*live_caption_view_->text_label());
|
||||
|
||||
// Creates a toggle button on the right.
|
||||
auto toggle = std::make_unique<Switch>(base::BindRepeating(
|
||||
@ -487,69 +452,17 @@ void AudioDetailedView::CreateLiveCaptionView() {
|
||||
gfx::Insets::TLBR(8, 24, 8, kToggleButtonRowRightPadding));
|
||||
}
|
||||
|
||||
std::unique_ptr<views::View>
|
||||
AudioDetailedView::CreateNoiseCancellationToggleRow(const AudioDevice& device) {
|
||||
CrasAudioHandler* audio_handler = CrasAudioHandler::Get();
|
||||
auto noise_cancellation_toggle = std::make_unique<TrayToggleButton>(
|
||||
base::BindRepeating(
|
||||
&AudioDetailedView::OnInputNoiseCancellationTogglePressed,
|
||||
base::Unretained(this)),
|
||||
IDS_ASH_STATUS_TRAY_AUDIO_INPUT_NOISE_CANCELLATION);
|
||||
|
||||
noise_cancellation_toggle->SetIsOn(
|
||||
audio_handler->GetNoiseCancellationState());
|
||||
|
||||
auto noise_cancellation_toggle_row = std::make_unique<views::View>();
|
||||
|
||||
auto* row_layout = noise_cancellation_toggle_row->SetLayoutManager(
|
||||
std::make_unique<views::BoxLayout>(
|
||||
views::BoxLayout::Orientation::kHorizontal,
|
||||
kToggleButtonRowViewPadding, kToggleButtonRowViewSpacing));
|
||||
|
||||
noise_cancellation_toggle->SetFlipCanvasOnPaintForRTLUI(false);
|
||||
|
||||
auto noise_cancellation_label =
|
||||
std::make_unique<views::Label>(l10n_util::GetStringUTF16(
|
||||
IDS_ASH_STATUS_TRAY_AUDIO_INPUT_NOISE_CANCELLATION));
|
||||
|
||||
noise_cancellation_label->SetEnabledColorId(kColorAshTextColorPrimary);
|
||||
noise_cancellation_label->SetHorizontalAlignment(gfx::ALIGN_LEFT);
|
||||
noise_cancellation_label->SetFontList(
|
||||
gfx::FontList().DeriveWithSizeDelta(kLabelFontSizeDelta));
|
||||
noise_cancellation_label->SetAutoColorReadabilityEnabled(false);
|
||||
noise_cancellation_label->SetSubpixelRenderingEnabled(false);
|
||||
noise_cancellation_label->SetBorder(
|
||||
views::CreateEmptyBorder(kToggleButtonRowLabelPadding));
|
||||
|
||||
auto* label_ptr = noise_cancellation_toggle_row->AddChildView(
|
||||
std::move(noise_cancellation_label));
|
||||
row_layout->SetFlexForView(label_ptr, 1);
|
||||
|
||||
noise_cancellation_toggle_row->AddChildView(
|
||||
std::move(noise_cancellation_toggle));
|
||||
|
||||
// This is only used for testing.
|
||||
if (g_noise_cancellation_toggle_callback) {
|
||||
g_noise_cancellation_toggle_callback->Run(
|
||||
device.id, noise_cancellation_toggle_row.get());
|
||||
}
|
||||
|
||||
return noise_cancellation_toggle_row;
|
||||
}
|
||||
|
||||
std::unique_ptr<TriView> AudioDetailedView::CreateNbsWarningView() {
|
||||
const bool is_qs_revamp = features::IsQsRevampEnabled();
|
||||
|
||||
std::unique_ptr<TriView> nbs_warning_view(
|
||||
TrayPopupUtils::CreateDefaultRowView(
|
||||
/*use_wide_layout=*/is_qs_revamp));
|
||||
/*use_wide_layout=*/true));
|
||||
nbs_warning_view->SetMinHeight(kNbsWarningMinHeight);
|
||||
nbs_warning_view->SetContainerVisible(TriView::Container::END, false);
|
||||
nbs_warning_view->SetID(AudioDetailedViewID::kNbsWarningView);
|
||||
|
||||
std::unique_ptr<views::ImageView> image_view =
|
||||
base::WrapUnique(TrayPopupUtils::CreateMainImageView(
|
||||
/*use_wide_layout=*/is_qs_revamp));
|
||||
/*use_wide_layout=*/true));
|
||||
image_view->SetImage(
|
||||
ui::ImageModel::FromVectorIcon(vector_icons::kNotificationWarningIcon,
|
||||
kColorAshIconColorWarning, kMenuIconSize));
|
||||
@ -562,20 +475,15 @@ std::unique_ptr<TriView> AudioDetailedView::CreateNbsWarningView() {
|
||||
label->SetMultiLine(/*multi_line=*/true);
|
||||
label->SetBackground(views::CreateSolidBackground(SK_ColorTRANSPARENT));
|
||||
label->SetEnabledColorId(kColorAshTextColorWarning);
|
||||
if (chromeos::features::IsJellyEnabled()) {
|
||||
label->SetAutoColorReadabilityEnabled(false);
|
||||
TypographyProvider::Get()->StyleLabel(TypographyToken::kCrosBody2, *label);
|
||||
} else {
|
||||
TrayPopupUtils::SetLabelFontList(
|
||||
label.get(), TrayPopupUtils::FontStyle::kDetailedViewLabel);
|
||||
}
|
||||
label->SetAutoColorReadabilityEnabled(false);
|
||||
TypographyProvider::Get()->StyleLabel(TypographyToken::kCrosBody2, *label);
|
||||
|
||||
nbs_warning_view->AddView(TriView::Container::CENTER, std::move(label));
|
||||
return nbs_warning_view;
|
||||
}
|
||||
|
||||
std::unique_ptr<HoverHighlightView>
|
||||
AudioDetailedView::CreateQsNoiseCancellationToggleRow(
|
||||
const AudioDevice& device) {
|
||||
AudioDetailedView::CreateNoiseCancellationToggleRow(const AudioDevice& device) {
|
||||
bool noise_cancellation_state =
|
||||
CrasAudioHandler::Get()->GetNoiseCancellationState();
|
||||
|
||||
@ -592,13 +500,11 @@ AudioDetailedView::CreateQsNoiseCancellationToggleRow(
|
||||
std::move(toggle_icon),
|
||||
l10n_util::GetStringUTF16(
|
||||
IDS_ASH_STATUS_TRAY_AUDIO_INPUT_NOISE_CANCELLATION));
|
||||
if (chromeos::features::IsJellyEnabled()) {
|
||||
views::Label* noise_cancellation_label =
|
||||
noise_cancellation_view->text_label();
|
||||
noise_cancellation_label->SetEnabledColorId(cros_tokens::kCrosSysOnSurface);
|
||||
TypographyProvider::Get()->StyleLabel(TypographyToken::kCrosButton2,
|
||||
*noise_cancellation_label);
|
||||
}
|
||||
views::Label* noise_cancellation_label =
|
||||
noise_cancellation_view->text_label();
|
||||
noise_cancellation_label->SetEnabledColorId(cros_tokens::kCrosSysOnSurface);
|
||||
TypographyProvider::Get()->StyleLabel(TypographyToken::kCrosButton2,
|
||||
*noise_cancellation_label);
|
||||
|
||||
// Create a non-clickable non-focusable toggle button on the right. The events
|
||||
// and focus behavior should be handled by `noise_cancellation_view_` instead.
|
||||
@ -613,14 +519,14 @@ AudioDetailedView::CreateQsNoiseCancellationToggleRow(
|
||||
noise_cancellation_button_ = toggle.get();
|
||||
noise_cancellation_view->AddRightView(toggle.release());
|
||||
|
||||
noise_cancellation_view->tri_view()->SetInsets(kQsToggleButtonRowViewPadding);
|
||||
noise_cancellation_view->tri_view()->SetInsets(kToggleButtonRowViewPadding);
|
||||
noise_cancellation_view->tri_view()->SetContainerLayout(
|
||||
TriView::Container::CENTER, std::make_unique<views::BoxLayout>(
|
||||
views::BoxLayout::Orientation::kVertical,
|
||||
kQsToggleButtonRowLabelPadding));
|
||||
noise_cancellation_view->SetPreferredSize(kQsToggleButtonRowPreferredSize);
|
||||
kToggleButtonRowLabelPadding));
|
||||
noise_cancellation_view->SetPreferredSize(kToggleButtonRowPreferredSize);
|
||||
noise_cancellation_view->SetProperty(views::kMarginsKey,
|
||||
kQsToggleButtonRowMargins);
|
||||
kToggleButtonRowMargins);
|
||||
noise_cancellation_view->SetAccessibilityState(
|
||||
noise_cancellation_state
|
||||
? HoverHighlightView::AccessibilityState::CHECKED_CHECKBOX
|
||||
@ -635,40 +541,7 @@ AudioDetailedView::CreateQsNoiseCancellationToggleRow(
|
||||
return noise_cancellation_view;
|
||||
}
|
||||
|
||||
views::Builder<views::BoxLayoutView> AudioDetailedView::CreateAgcInfoRow(
|
||||
const AudioDevice& device) {
|
||||
return views::Builder<views::BoxLayoutView>()
|
||||
.SetID(AudioDetailedViewID::kAgcInfoRow)
|
||||
.SetFocusBehavior(FocusBehavior::NEVER)
|
||||
.SetDefaultFlex(1)
|
||||
.SetLayoutManager(std::make_unique<views::BoxLayout>(
|
||||
views::BoxLayout::Orientation::kHorizontal,
|
||||
kToggleButtonRowViewPadding, kToggleButtonRowViewSpacing))
|
||||
.AddChild(views::Builder<views::ImageView>().SetImage(
|
||||
ui::ImageModel::FromVectorIcon(kUnifiedMenuInfoIcon,
|
||||
cros_tokens::kCrosSysOnSurface,
|
||||
kQsSliderIconSize)))
|
||||
.AddChild(
|
||||
views::Builder<views::Label>()
|
||||
.SetText(std::u16string())
|
||||
.SetEnabledColorId(kColorAshTextColorPrimary)
|
||||
.SetHorizontalAlignment(gfx::ALIGN_LEFT)
|
||||
.SetFontList(
|
||||
gfx::FontList().DeriveWithSizeDelta(kLabelFontSizeDelta))
|
||||
.SetAutoColorReadabilityEnabled(false)
|
||||
.SetSubpixelRenderingEnabled(false)
|
||||
.SetBorder(views::CreateEmptyBorder(kToggleButtonRowLabelPadding))
|
||||
.SetFocusBehavior(FocusBehavior::ACCESSIBLE_ONLY)
|
||||
.SetID(AudioDetailedViewID::kAgcInfoLabel))
|
||||
.AddChild(views::Builder<views::LabelButton>(
|
||||
std::make_unique<views::LabelButton>(
|
||||
base::BindRepeating(&AudioDetailedView::OnSettingsButtonClicked,
|
||||
weak_factory_.GetWeakPtr()),
|
||||
l10n_util::GetStringUTF16(
|
||||
IDS_ASH_STATUS_TRAY_AUDIO_SETTINGS_SHORT_STRING))));
|
||||
}
|
||||
|
||||
std::unique_ptr<HoverHighlightView> AudioDetailedView::CreateQsAgcInfoRow(
|
||||
std::unique_ptr<HoverHighlightView> AudioDetailedView::CreateAgcInfoRow(
|
||||
const AudioDevice& device) {
|
||||
auto agc_info_view = std::make_unique<HoverHighlightView>(/*listener=*/this);
|
||||
agc_info_view->SetID(AudioDetailedViewID::kAgcInfoView);
|
||||
@ -696,13 +569,13 @@ std::unique_ptr<HoverHighlightView> AudioDetailedView::CreateQsAgcInfoRow(
|
||||
}
|
||||
agc_info_view->AddRightView(settings.release());
|
||||
|
||||
agc_info_view->tri_view()->SetInsets(kQsToggleButtonRowViewPadding);
|
||||
agc_info_view->tri_view()->SetInsets(kToggleButtonRowViewPadding);
|
||||
agc_info_view->tri_view()->SetContainerLayout(
|
||||
TriView::Container::CENTER, std::make_unique<views::BoxLayout>(
|
||||
views::BoxLayout::Orientation::kVertical,
|
||||
kQsToggleButtonRowLabelPadding));
|
||||
agc_info_view->SetPreferredSize(kQsToggleButtonRowPreferredSize);
|
||||
agc_info_view->SetProperty(views::kMarginsKey, kQsToggleButtonRowMargins);
|
||||
kToggleButtonRowLabelPadding));
|
||||
agc_info_view->SetPreferredSize(kToggleButtonRowPreferredSize);
|
||||
agc_info_view->SetProperty(views::kMarginsKey, kToggleButtonRowMargins);
|
||||
agc_info_view->SetFocusBehavior(FocusBehavior::NEVER);
|
||||
|
||||
return agc_info_view;
|
||||
@ -713,8 +586,6 @@ void AudioDetailedView::MaybeShowSodaMessage(speech::LanguageCode language_code,
|
||||
AccessibilityControllerImpl* controller =
|
||||
Shell::Get()->accessibility_controller();
|
||||
const bool is_live_caption_enabled = controller->live_caption().enabled();
|
||||
const bool is_live_caption_in_tray =
|
||||
live_caption_view_ && controller->IsLiveCaptionSettingVisibleInTray();
|
||||
// Only show updates for this feature if the language code applies to the SODA
|
||||
// binary (encoded by `LanguageCode::kNone`) or the language pack matching
|
||||
// the feature locale.
|
||||
@ -722,8 +593,7 @@ void AudioDetailedView::MaybeShowSodaMessage(speech::LanguageCode language_code,
|
||||
language_code == speech::LanguageCode::kNone ||
|
||||
language_code == GetLiveCaptionLocale();
|
||||
|
||||
if (live_caption_has_update && is_live_caption_enabled &&
|
||||
(features::IsQsRevampEnabled() || is_live_caption_in_tray)) {
|
||||
if (live_caption_has_update && is_live_caption_enabled) {
|
||||
live_caption_view_->SetSubText(message);
|
||||
}
|
||||
}
|
||||
@ -733,9 +603,7 @@ void AudioDetailedView::OnInputNoiseCancellationTogglePressed() {
|
||||
const bool new_state = !audio_handler->GetNoiseCancellationState();
|
||||
audio_handler->SetNoiseCancellationState(
|
||||
new_state, CrasAudioHandler::AudioSettingsChangeSource::kSystemTray);
|
||||
if (features::IsQsRevampEnabled()) {
|
||||
noise_cancellation_button_->SetIsOn(new_state);
|
||||
}
|
||||
noise_cancellation_button_->SetIsOn(new_state);
|
||||
}
|
||||
|
||||
void AudioDetailedView::OnSettingsButtonClicked() {
|
||||
@ -835,28 +703,12 @@ void AudioDetailedView::UpdateScrollableList() {
|
||||
device_map_.clear();
|
||||
scroll_content()->RemoveAllChildViews();
|
||||
|
||||
const bool is_qs_revamp = features::IsQsRevampEnabled();
|
||||
|
||||
// Uses the `RoundedContainer` for QsRevamp.
|
||||
views::View* container = scroll_content();
|
||||
if (is_qs_revamp) {
|
||||
container =
|
||||
scroll_content()->AddChildView(std::make_unique<RoundedContainer>());
|
||||
}
|
||||
container =
|
||||
scroll_content()->AddChildView(std::make_unique<RoundedContainer>());
|
||||
|
||||
// Adds the live caption toggle.
|
||||
AccessibilityControllerImpl* controller =
|
||||
Shell::Get()->accessibility_controller();
|
||||
if (is_qs_revamp) {
|
||||
CreateLiveCaptionView();
|
||||
} else if (controller->IsLiveCaptionSettingVisibleInTray()) {
|
||||
live_caption_view_ = AddScrollListCheckableItem(
|
||||
container, vector_icons::kLiveCaptionOnIcon,
|
||||
l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_LIVE_CAPTION),
|
||||
controller->live_caption().enabled(),
|
||||
controller->IsEnterpriseIconVisibleForLiveCaption());
|
||||
container->AddChildView(TrayPopupUtils::CreateListSubHeaderSeparator());
|
||||
}
|
||||
CreateLiveCaptionView();
|
||||
|
||||
// Adds audio output devices.
|
||||
const bool has_output_devices = output_devices_.size() > 0;
|
||||
@ -871,24 +723,18 @@ void AudioDetailedView::UpdateScrollableList() {
|
||||
container, gfx::kNoneIcon, GetAudioDeviceName(device), device.active);
|
||||
device_map_[device_name_container] = device;
|
||||
|
||||
if (is_qs_revamp) {
|
||||
// Sets this flag to false to make the assigned color id effective.
|
||||
// Otherwise it will use `color_utils::BlendForMinContrast()` to improve
|
||||
// label readability over the background.
|
||||
device_name_container->text_label()->SetAutoColorReadabilityEnabled(
|
||||
/*enabled=*/false);
|
||||
last_output_device =
|
||||
AddDeviceSlider(container, device, device_name_container,
|
||||
/*is_output_device=*/true);
|
||||
}
|
||||
// Sets this flag to false to make the assigned color id effective.
|
||||
// Otherwise it will use `color_utils::BlendForMinContrast()` to improve
|
||||
// label readability over the background.
|
||||
device_name_container->text_label()->SetAutoColorReadabilityEnabled(
|
||||
/*enabled=*/false);
|
||||
last_output_device =
|
||||
AddDeviceSlider(container, device, device_name_container,
|
||||
/*is_output_device=*/true);
|
||||
}
|
||||
|
||||
if (has_output_devices) {
|
||||
if (is_qs_revamp) {
|
||||
last_output_device->SetProperty(views::kMarginsKey, kQsSubsectionMargins);
|
||||
} else {
|
||||
container->AddChildView(TrayPopupUtils::CreateListSubHeaderSeparator());
|
||||
}
|
||||
last_output_device->SetProperty(views::kMarginsKey, kSubsectionMargins);
|
||||
}
|
||||
|
||||
// Adds audio input devices.
|
||||
@ -905,55 +751,33 @@ void AudioDetailedView::UpdateScrollableList() {
|
||||
container, gfx::kNoneIcon, GetAudioDeviceName(device), device.active);
|
||||
device_map_[device_name_container] = device;
|
||||
|
||||
if (is_qs_revamp) {
|
||||
// Sets this flag to false to make the assigned color id effective.
|
||||
device_name_container->text_label()->SetAutoColorReadabilityEnabled(
|
||||
/*enabled=*/false);
|
||||
AddDeviceSlider(container, device, device_name_container,
|
||||
/*is_output_device=*/false);
|
||||
}
|
||||
// Sets this flag to false to make the assigned color id effective.
|
||||
device_name_container->text_label()->SetAutoColorReadabilityEnabled(
|
||||
/*enabled=*/false);
|
||||
AddDeviceSlider(container, device, device_name_container,
|
||||
/*is_output_device=*/false);
|
||||
|
||||
// AGC info row is only meaningful when UI gains is going to be ignored.
|
||||
if (base::FeatureList::IsEnabled(media::kIgnoreUiGains)) {
|
||||
if (audio_handler->GetPrimaryActiveInputNode() == device.id) {
|
||||
if (features::IsQsRevampEnabled()) {
|
||||
container->AddChildView(
|
||||
AudioDetailedView::CreateQsAgcInfoRow(device));
|
||||
UpdateQsAgcInfoRow();
|
||||
}
|
||||
container->AddChildView(AudioDetailedView::CreateAgcInfoRow(device));
|
||||
UpdateAgcInfoRow();
|
||||
}
|
||||
}
|
||||
|
||||
// Adds the input noise cancellation toggle.
|
||||
if (audio_handler->GetPrimaryActiveInputNode() == device.id &&
|
||||
audio_handler->IsNoiseCancellationSupportedForDevice(device.id)) {
|
||||
if (is_qs_revamp) {
|
||||
noise_cancellation_view_ = container->AddChildView(
|
||||
AudioDetailedView::CreateQsNoiseCancellationToggleRow(device));
|
||||
noise_cancellation_view_ = container->AddChildView(
|
||||
AudioDetailedView::CreateNoiseCancellationToggleRow(device));
|
||||
|
||||
// Adds a `Separator` if this input device is not the last one.
|
||||
if (&device != &input_devices_.back()) {
|
||||
auto* separator =
|
||||
container->AddChildView(std::make_unique<views::Separator>());
|
||||
separator->SetColorId(cros_tokens::kCrosSysSeparator);
|
||||
separator->SetOrientation(views::Separator::Orientation::kHorizontal);
|
||||
separator->SetProperty(views::kMarginsKey, kSeparatorMargins);
|
||||
}
|
||||
} else {
|
||||
container->AddChildView(
|
||||
AudioDetailedView::CreateNoiseCancellationToggleRow(device));
|
||||
}
|
||||
}
|
||||
|
||||
if (!features::IsQsRevampEnabled()) {
|
||||
scroll_content()->AddChildView(mic_gain_controller_->CreateMicGainSlider(
|
||||
device.id, device.IsInternalMic()));
|
||||
// AGC info row is only meaningful when UI gains is going to be ignored.
|
||||
if (base::FeatureList::IsEnabled(media::kIgnoreUiGains)) {
|
||||
if (audio_handler->GetPrimaryActiveInputNode() == device.id) {
|
||||
container->AddChildView(CreateAgcInfoRow(device).Build());
|
||||
UpdateAgcInfoRow();
|
||||
}
|
||||
// Adds a `Separator` if this input device is not the last one.
|
||||
if (&device != &input_devices_.back()) {
|
||||
auto* separator =
|
||||
container->AddChildView(std::make_unique<views::Separator>());
|
||||
separator->SetColorId(cros_tokens::kCrosSysSeparator);
|
||||
separator->SetOrientation(views::Separator::Orientation::kHorizontal);
|
||||
separator->SetProperty(views::kMarginsKey, kSeparatorMargins);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1005,32 +829,6 @@ void AudioDetailedView::UpdateActiveDeviceColor(bool is_input, bool is_muted) {
|
||||
}
|
||||
|
||||
void AudioDetailedView::UpdateAgcInfoRow() {
|
||||
if (!base::FeatureList::IsEnabled(media::kIgnoreUiGains)) {
|
||||
return;
|
||||
}
|
||||
if (!scroll_content()) {
|
||||
return;
|
||||
}
|
||||
views::Label* label = static_cast<views::Label*>(
|
||||
scroll_content()->GetViewByID(AudioDetailedViewID::kAgcInfoLabel));
|
||||
if (!label) {
|
||||
return;
|
||||
}
|
||||
|
||||
std::vector<std::string> app_names = GetNamesOfAppsAccessingMic(
|
||||
app_registry_cache_, app_capability_access_cache_);
|
||||
|
||||
std::u16string agc_info_text = GetTextForAgcInfo(app_names);
|
||||
label->SetText(agc_info_text);
|
||||
|
||||
views::View* agc_info_row =
|
||||
scroll_content()->GetViewByID(AudioDetailedViewID::kAgcInfoRow);
|
||||
CHECK(agc_info_row);
|
||||
agc_info_row->SetAccessibleName(agc_info_text);
|
||||
agc_info_row->SetVisible(ShowAgcInfoRow() && !app_names.empty());
|
||||
}
|
||||
|
||||
void AudioDetailedView::UpdateQsAgcInfoRow() {
|
||||
if (!base::FeatureList::IsEnabled(media::kIgnoreUiGains)) {
|
||||
return;
|
||||
}
|
||||
@ -1169,11 +967,7 @@ void AudioDetailedView::OnInputMutedByMicrophoneMuteSwitchChanged(bool muted) {
|
||||
|
||||
void AudioDetailedView::OnNumStreamIgnoreUiGainsChanged(int32_t num) {
|
||||
num_stream_ignore_ui_gains_ = num;
|
||||
if (!features::IsQsRevampEnabled()) {
|
||||
UpdateAgcInfoRow();
|
||||
} else {
|
||||
UpdateQsAgcInfoRow();
|
||||
}
|
||||
UpdateAgcInfoRow();
|
||||
}
|
||||
|
||||
BEGIN_METADATA(AudioDetailedView, TrayDetailedView)
|
||||
|
@ -61,9 +61,7 @@ class ASH_EXPORT AudioDetailedView
|
||||
// Starts at 1000 to prevent potential overlapping.
|
||||
kAudioDetailedView = 1000,
|
||||
// Agc information row and corresponding text label.
|
||||
kAgcInfoRow,
|
||||
kAgcInfoLabel,
|
||||
// For QsRevamp: AGC information row.
|
||||
kAgcInfoView,
|
||||
// Warning message view when an NBS device is selected.
|
||||
kNbsWarningView,
|
||||
@ -106,7 +104,7 @@ class ASH_EXPORT AudioDetailedView
|
||||
const gfx::VectorIcon& icon,
|
||||
const int text_id);
|
||||
|
||||
// For QsRevamp: Adds the sliders for output/input devices.
|
||||
// Adds the sliders for output/input devices.
|
||||
views::View* AddDeviceSlider(views::View* container,
|
||||
const AudioDevice& device,
|
||||
HoverHighlightView* device_name_container,
|
||||
@ -118,24 +116,15 @@ class ASH_EXPORT AudioDetailedView
|
||||
// Creates the NBS warning view.
|
||||
std::unique_ptr<TriView> CreateNbsWarningView();
|
||||
|
||||
// For QsRevamp: Creates the `live_caption_view_`.
|
||||
// Creates the `live_caption_view_`.
|
||||
void CreateLiveCaptionView();
|
||||
|
||||
// Creates the noise cancellation toggle row in the input subsection.
|
||||
std::unique_ptr<views::View> CreateNoiseCancellationToggleRow(
|
||||
const AudioDevice& device);
|
||||
|
||||
// For QsRevamp: Creates the noise cancellation toggle row in the input
|
||||
// subsection.
|
||||
std::unique_ptr<HoverHighlightView> CreateQsNoiseCancellationToggleRow(
|
||||
std::unique_ptr<HoverHighlightView> CreateNoiseCancellationToggleRow(
|
||||
const AudioDevice& device);
|
||||
|
||||
// Creates the agc info row in the input subsection.
|
||||
views::Builder<views::BoxLayoutView> CreateAgcInfoRow(
|
||||
const AudioDevice& device);
|
||||
|
||||
// For QsRevamp: Creates the agc info row in the input subsection.
|
||||
std::unique_ptr<HoverHighlightView> CreateQsAgcInfoRow(
|
||||
std::unique_ptr<HoverHighlightView> CreateAgcInfoRow(
|
||||
const AudioDevice& device);
|
||||
|
||||
// Sets the subtext for `live_caption_view_` based on whether live caption has
|
||||
@ -174,7 +163,6 @@ class ASH_EXPORT AudioDetailedView
|
||||
// Updates the label of AGC info when accessibility to microphone changed.
|
||||
// Hide AGC info row if no apps is requesting AGC stream.
|
||||
void UpdateAgcInfoRow();
|
||||
void UpdateQsAgcInfoRow();
|
||||
bool ShowAgcInfoRow();
|
||||
|
||||
// TrayDetailedView:
|
||||
|
@ -27,8 +27,7 @@ constexpr uint64_t kInternalMicId = 10003;
|
||||
class AudioDetailedViewPixelTest : public AshTestBase {
|
||||
public:
|
||||
AudioDetailedViewPixelTest() {
|
||||
feature_list_.InitWithFeatures(
|
||||
{features::kQsRevamp, chromeos::features::kJelly}, {});
|
||||
feature_list_.InitWithFeatures({chromeos::features::kJelly}, {});
|
||||
}
|
||||
|
||||
// AshTestBase:
|
||||
|
@ -6,7 +6,6 @@
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "ash/constants/ash_features.h"
|
||||
#include "ash/public/cpp/test/test_system_tray_client.h"
|
||||
#include "ash/shell.h"
|
||||
#include "ash/system/tray/fake_detailed_view_delegate.h"
|
||||
@ -75,12 +74,11 @@ TEST_F(AudioDetailedViewTest, PressingSettingsButtonOpensSettings) {
|
||||
|
||||
class AudioDetailedViewAgcInfoTest
|
||||
: public AudioDetailedViewTest,
|
||||
public testing::WithParamInterface<testing::tuple<bool, bool, bool>> {
|
||||
public testing::WithParamInterface<testing::tuple<bool, bool>> {
|
||||
public:
|
||||
void SetUp() override {
|
||||
scoped_feature_list_.InitWithFeatureStates(
|
||||
{{media::kIgnoreUiGains, IsIgnoreUiGainsEnabled()},
|
||||
{features::kQsRevamp, IsQsRevampEnabled()}});
|
||||
{{media::kIgnoreUiGains, IsIgnoreUiGainsEnabled()}});
|
||||
|
||||
AudioDetailedViewTest::SetUp();
|
||||
|
||||
@ -110,16 +108,10 @@ class AudioDetailedViewAgcInfoTest
|
||||
|
||||
bool IsIgnoreUiGainsEnabled() { return std::get<0>(GetParam()); }
|
||||
bool IsForceRespectUiGainsEnabled() { return std::get<1>(GetParam()); }
|
||||
bool IsQsRevampEnabled() { return std::get<2>(GetParam()); }
|
||||
|
||||
views::View* GetAgcInfoView() {
|
||||
if (IsQsRevampEnabled()) {
|
||||
return audio_detailed_view_->GetViewByID(
|
||||
AudioDetailedView::AudioDetailedViewID::kAgcInfoView);
|
||||
} else {
|
||||
return audio_detailed_view_->GetViewByID(
|
||||
AudioDetailedView::AudioDetailedViewID::kAgcInfoRow);
|
||||
}
|
||||
return audio_detailed_view_->GetViewByID(
|
||||
AudioDetailedView::AudioDetailedViewID::kAgcInfoView);
|
||||
}
|
||||
|
||||
static apps::AppPtr MakeApp(const char* app_id, const char* name) {
|
||||
@ -204,7 +196,6 @@ TEST_P(AudioDetailedViewAgcInfoTest, AgcInfoRowShowInProperConditions) {
|
||||
INSTANTIATE_TEST_SUITE_P(AudioDetailedViewAgcInfoVisibleTest,
|
||||
AudioDetailedViewAgcInfoTest,
|
||||
testing::Combine(testing::Bool(),
|
||||
testing::Bool(),
|
||||
testing::Bool()));
|
||||
|
||||
} // namespace ash
|
||||
|
@ -135,23 +135,14 @@ AudioNodeList GenerateAudioNodeList(
|
||||
|
||||
} // namespace
|
||||
|
||||
// Test param is the version of stabel device id used by audio node.
|
||||
class UnifiedAudioDetailedViewControllerTest
|
||||
: public AshTestBase,
|
||||
public testing::WithParamInterface<bool> {
|
||||
// Test param is the version of stable device id used by audio node.
|
||||
class UnifiedAudioDetailedViewControllerTest : public AshTestBase {
|
||||
public:
|
||||
UnifiedAudioDetailedViewControllerTest() {}
|
||||
~UnifiedAudioDetailedViewControllerTest() override = default;
|
||||
|
||||
bool IsQsRevampEnabled() { return GetParam(); }
|
||||
|
||||
// AshTestBase:
|
||||
void SetUp() override {
|
||||
if (IsQsRevampEnabled()) {
|
||||
scoped_feature_list_.InitAndEnableFeature(features::kQsRevamp);
|
||||
} else {
|
||||
scoped_feature_list_.InitAndDisableFeature(features::kQsRevamp);
|
||||
}
|
||||
AshTestBase::SetUp();
|
||||
|
||||
audio_pref_handler_ = base::MakeRefCounted<AudioDevicesPrefHandlerStub>();
|
||||
@ -215,7 +206,7 @@ class UnifiedAudioDetailedViewControllerTest
|
||||
GetAudioDetailedView()->HandleViewClicked(live_caption_view());
|
||||
}
|
||||
|
||||
// Toggles the noise cancellation button for QsRevamp.
|
||||
// Toggles the noise cancellation button.
|
||||
void ToggleNoiseCancellation() {
|
||||
GetAudioDetailedView()->HandleViewClicked(
|
||||
GetAudioDetailedView()->noise_cancellation_view_);
|
||||
@ -281,12 +272,6 @@ class UnifiedAudioDetailedViewControllerTest
|
||||
}
|
||||
|
||||
views::ToggleButton* noise_cancellation_button() {
|
||||
if (!IsQsRevampEnabled()) {
|
||||
DCHECK(toggles_map_[kInternalMicId]);
|
||||
DCHECK(toggles_map_[kInternalMicId]->children().size() >= 2);
|
||||
return (views::ToggleButton*)toggles_map_[kInternalMicId]->children()[1];
|
||||
}
|
||||
|
||||
return GetAudioDetailedView()->noise_cancellation_button_;
|
||||
}
|
||||
|
||||
@ -320,18 +305,7 @@ class UnifiedAudioDetailedViewControllerTest
|
||||
base::HistogramTester histogram_tester_;
|
||||
};
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(All,
|
||||
UnifiedAudioDetailedViewControllerTest,
|
||||
testing::Bool() /* IsQsRevampEnabled() */);
|
||||
|
||||
TEST_P(UnifiedAudioDetailedViewControllerTest, ToggleNbsWarning) {
|
||||
scoped_feature_list_.Reset();
|
||||
if (!IsQsRevampEnabled()) {
|
||||
scoped_feature_list_.InitWithFeatures({}, {});
|
||||
} else {
|
||||
scoped_feature_list_.InitWithFeatures({features::kQsRevamp}, {});
|
||||
}
|
||||
|
||||
TEST_F(UnifiedAudioDetailedViewControllerTest, ToggleNbsWarning) {
|
||||
fake_cras_audio_client()->SetAudioNodesAndNotifyObserversForTesting(
|
||||
GenerateAudioNodeList({kMicJack, kNbsMic}));
|
||||
|
||||
@ -350,7 +324,7 @@ TEST_P(UnifiedAudioDetailedViewControllerTest, ToggleNbsWarning) {
|
||||
EXPECT_FALSE(nbs_warning_view());
|
||||
}
|
||||
|
||||
TEST_P(UnifiedAudioDetailedViewControllerTest, OneInputSlider) {
|
||||
TEST_F(UnifiedAudioDetailedViewControllerTest, OneInputSlider) {
|
||||
std::unique_ptr<views::View> view =
|
||||
audio_detailed_view_controller_->CreateView();
|
||||
fake_cras_audio_client()->SetAudioNodesAndNotifyObserversForTesting(
|
||||
@ -361,29 +335,20 @@ TEST_P(UnifiedAudioDetailedViewControllerTest, OneInputSlider) {
|
||||
CrasAudioHandler::ACTIVATE_BY_USER);
|
||||
EXPECT_EQ(kInternalMicId, cras_audio_handler_->GetPrimaryActiveInputNode());
|
||||
EXPECT_TRUE(input_sliders_map_.find(kInternalMicId)->second->GetVisible());
|
||||
if (!IsQsRevampEnabled()) {
|
||||
// Only slider corresponding to the Internal Mic should be visible
|
||||
// initially.
|
||||
EXPECT_FALSE(input_sliders_map_.find(kMicJackId)->second->GetVisible());
|
||||
} else {
|
||||
// Both sliders should be visible for QsRevamp.
|
||||
EXPECT_TRUE(input_sliders_map_.find(kMicJackId)->second->GetVisible());
|
||||
}
|
||||
|
||||
// Both sliders should be visible for QsRevamp.
|
||||
EXPECT_TRUE(input_sliders_map_.find(kMicJackId)->second->GetVisible());
|
||||
|
||||
cras_audio_handler_->SwitchToDevice(AudioDevice(GenerateAudioNode(kMicJack)),
|
||||
true, CrasAudioHandler::ACTIVATE_BY_USER);
|
||||
EXPECT_EQ(kMicJackId, cras_audio_handler_->GetPrimaryActiveInputNode());
|
||||
EXPECT_TRUE(input_sliders_map_.find(kMicJackId)->second->GetVisible());
|
||||
if (!IsQsRevampEnabled()) {
|
||||
// Switching to Mic Jack should flip the visibility of the sliders.
|
||||
EXPECT_FALSE(input_sliders_map_.find(kInternalMicId)->second->GetVisible());
|
||||
} else {
|
||||
// Both sliders should be visible for QsRevamp.
|
||||
EXPECT_TRUE(input_sliders_map_.find(kInternalMicId)->second->GetVisible());
|
||||
}
|
||||
|
||||
// Both sliders should be visible for QsRevamp.
|
||||
EXPECT_TRUE(input_sliders_map_.find(kInternalMicId)->second->GetVisible());
|
||||
}
|
||||
|
||||
TEST_P(UnifiedAudioDetailedViewControllerTest, OneOutputSlider) {
|
||||
TEST_F(UnifiedAudioDetailedViewControllerTest, OneOutputSlider) {
|
||||
std::unique_ptr<views::View> view =
|
||||
audio_detailed_view_controller_->CreateView();
|
||||
fake_cras_audio_client()->SetAudioNodesAndNotifyObserversForTesting(
|
||||
@ -394,26 +359,22 @@ TEST_P(UnifiedAudioDetailedViewControllerTest, OneOutputSlider) {
|
||||
CrasAudioHandler::ACTIVATE_BY_USER);
|
||||
EXPECT_EQ(kInternalSpeakerId,
|
||||
cras_audio_handler_->GetPrimaryActiveOutputNode());
|
||||
if (IsQsRevampEnabled()) {
|
||||
// Both sliders should be visible for QsRevamp.
|
||||
EXPECT_TRUE(
|
||||
output_sliders_map_.find(kInternalSpeakerId)->second->GetVisible());
|
||||
EXPECT_TRUE(output_sliders_map_.find(kHeadphoneId)->second->GetVisible());
|
||||
}
|
||||
// Both sliders should be visible.
|
||||
EXPECT_TRUE(
|
||||
output_sliders_map_.find(kInternalSpeakerId)->second->GetVisible());
|
||||
EXPECT_TRUE(output_sliders_map_.find(kHeadphoneId)->second->GetVisible());
|
||||
|
||||
cras_audio_handler_->SwitchToDevice(
|
||||
AudioDevice(GenerateAudioNode(kHeadphone)), true,
|
||||
CrasAudioHandler::ACTIVATE_BY_USER);
|
||||
EXPECT_EQ(kHeadphoneId, cras_audio_handler_->GetPrimaryActiveOutputNode());
|
||||
if (IsQsRevampEnabled()) {
|
||||
// Both sliders should be visible for QsRevamp.
|
||||
EXPECT_TRUE(output_sliders_map_.find(kHeadphoneId)->second->GetVisible());
|
||||
EXPECT_TRUE(
|
||||
output_sliders_map_.find(kInternalSpeakerId)->second->GetVisible());
|
||||
}
|
||||
// Both sliders should be visible.
|
||||
EXPECT_TRUE(output_sliders_map_.find(kHeadphoneId)->second->GetVisible());
|
||||
EXPECT_TRUE(
|
||||
output_sliders_map_.find(kInternalSpeakerId)->second->GetVisible());
|
||||
}
|
||||
|
||||
TEST_P(UnifiedAudioDetailedViewControllerTest, DualInternalMicSlider) {
|
||||
TEST_F(UnifiedAudioDetailedViewControllerTest, DualInternalMicSlider) {
|
||||
fake_cras_audio_client()->SetAudioNodesAndNotifyObserversForTesting(
|
||||
GenerateAudioNodeList({kFrontMic, kRearMic}));
|
||||
|
||||
@ -430,7 +391,7 @@ TEST_P(UnifiedAudioDetailedViewControllerTest, DualInternalMicSlider) {
|
||||
EXPECT_TRUE(input_sliders_map_.begin()->second->GetVisible());
|
||||
}
|
||||
|
||||
TEST_P(UnifiedAudioDetailedViewControllerTest,
|
||||
TEST_F(UnifiedAudioDetailedViewControllerTest,
|
||||
DualInternalMicSliderActiveState) {
|
||||
fake_cras_audio_client()->SetAudioNodesAndNotifyObserversForTesting(
|
||||
GenerateAudioNodeList({kFrontMic, kRearMic}));
|
||||
@ -450,15 +411,13 @@ TEST_P(UnifiedAudioDetailedViewControllerTest,
|
||||
// Verify the slider is visible.
|
||||
EXPECT_TRUE(mic_gain_slider_view->GetVisible());
|
||||
|
||||
// For QsRevamp: Verify the slider is active since it's the only slider.
|
||||
if (IsQsRevampEnabled()) {
|
||||
EXPECT_EQ(static_cast<QuickSettingsSlider*>(mic_gain_slider_view->slider())
|
||||
->slider_style(),
|
||||
QuickSettingsSlider::Style::kRadioActive);
|
||||
}
|
||||
// Verifies the slider is active since it's the only slider.
|
||||
EXPECT_EQ(static_cast<QuickSettingsSlider*>(mic_gain_slider_view->slider())
|
||||
->slider_style(),
|
||||
QuickSettingsSlider::Style::kRadioActive);
|
||||
}
|
||||
|
||||
TEST_P(UnifiedAudioDetailedViewControllerTest,
|
||||
TEST_F(UnifiedAudioDetailedViewControllerTest,
|
||||
DualInternalMicSliderInactiveState) {
|
||||
fake_cras_audio_client()->SetAudioNodesAndNotifyObserversForTesting(
|
||||
GenerateAudioNodeList({kFrontMic, kRearMic, kMicJack}));
|
||||
@ -484,20 +443,18 @@ TEST_P(UnifiedAudioDetailedViewControllerTest,
|
||||
cras_audio_handler_->SwitchToDevice(AudioDevice(GenerateAudioNode(kMicJack)),
|
||||
true, CrasAudioHandler::ACTIVATE_BY_USER);
|
||||
|
||||
// For QsRevamp: Verify the dual internal mic slider is inactive and its
|
||||
// volume level equals to the front mic's level.
|
||||
if (IsQsRevampEnabled()) {
|
||||
auto* mic_gain_slider_view = static_cast<MicGainSliderView*>(
|
||||
input_sliders_map_.find(kDualInternalMicId)->second);
|
||||
EXPECT_EQ(static_cast<QuickSettingsSlider*>(mic_gain_slider_view->slider())
|
||||
->slider_style(),
|
||||
QuickSettingsSlider::Style::kRadioInactive);
|
||||
EXPECT_EQ(mic_gain_slider_view->slider()->GetValue(),
|
||||
kFrontMicGainPercent / 100.0);
|
||||
}
|
||||
// Verifies the dual internal mic slider is inactive and its volume level
|
||||
// equals to the front mic's level.
|
||||
auto* mic_gain_slider_view = static_cast<MicGainSliderView*>(
|
||||
input_sliders_map_.find(kDualInternalMicId)->second);
|
||||
EXPECT_EQ(static_cast<QuickSettingsSlider*>(mic_gain_slider_view->slider())
|
||||
->slider_style(),
|
||||
QuickSettingsSlider::Style::kRadioInactive);
|
||||
EXPECT_EQ(mic_gain_slider_view->slider()->GetValue(),
|
||||
kFrontMicGainPercent / 100.0);
|
||||
}
|
||||
|
||||
TEST_P(UnifiedAudioDetailedViewControllerTest,
|
||||
TEST_F(UnifiedAudioDetailedViewControllerTest,
|
||||
NoiseCancellationToggleNotDisplayedIfNotSupported) {
|
||||
fake_cras_audio_client()->SetAudioNodesAndNotifyObserversForTesting(
|
||||
GenerateAudioNodeList({kInternalMic, kMicJack, kFrontMic, kRearMic}));
|
||||
@ -512,7 +469,7 @@ TEST_P(UnifiedAudioDetailedViewControllerTest,
|
||||
EXPECT_EQ(0u, toggles_map_.size());
|
||||
}
|
||||
|
||||
TEST_P(UnifiedAudioDetailedViewControllerTest,
|
||||
TEST_F(UnifiedAudioDetailedViewControllerTest,
|
||||
NoiseCancellationToggleDisplayedIfSupportedAndInternal) {
|
||||
fake_cras_audio_client()->SetAudioNodesAndNotifyObserversForTesting(
|
||||
GenerateAudioNodeList({kInternalMic, kMicJack, kFrontMic, kRearMic}));
|
||||
@ -530,7 +487,7 @@ TEST_P(UnifiedAudioDetailedViewControllerTest,
|
||||
noise_cancellation_button()->GetIsOn();
|
||||
}
|
||||
|
||||
TEST_P(UnifiedAudioDetailedViewControllerTest,
|
||||
TEST_F(UnifiedAudioDetailedViewControllerTest,
|
||||
NoiseCancellationToggleChangesPrefAndSendsDbusSignal) {
|
||||
audio_pref_handler_->SetNoiseCancellationState(false);
|
||||
|
||||
@ -556,30 +513,15 @@ TEST_P(UnifiedAudioDetailedViewControllerTest,
|
||||
EXPECT_FALSE(toggle->GetIsOn());
|
||||
EXPECT_FALSE(audio_pref_handler_->GetNoiseCancellationState());
|
||||
|
||||
if (!IsQsRevampEnabled()) {
|
||||
ui::MouseEvent press(ui::ET_MOUSE_PRESSED, gfx::PointF(), gfx::PointF(),
|
||||
ui::EventTimeForNow(), ui::EF_LEFT_MOUSE_BUTTON,
|
||||
ui::EF_NONE);
|
||||
// For QsRevamp, the entire row of `noise_cancellation_view_` is clickable.
|
||||
ToggleNoiseCancellation();
|
||||
EXPECT_TRUE(audio_pref_handler_->GetNoiseCancellationState());
|
||||
|
||||
// Flipping the toggle.
|
||||
views::test::ButtonTestApi(toggle).NotifyClick(press);
|
||||
// The new state of the toggle must be saved to the prefs.
|
||||
EXPECT_TRUE(audio_pref_handler_->GetNoiseCancellationState());
|
||||
|
||||
// Flipping back and checking the prefs again.
|
||||
views::test::ButtonTestApi(toggle).NotifyClick(press);
|
||||
EXPECT_FALSE(audio_pref_handler_->GetNoiseCancellationState());
|
||||
} else {
|
||||
// For QsRevamp, the entire row of `noise_cancellation_view_` is clickable.
|
||||
ToggleNoiseCancellation();
|
||||
EXPECT_TRUE(audio_pref_handler_->GetNoiseCancellationState());
|
||||
|
||||
ToggleNoiseCancellation();
|
||||
EXPECT_FALSE(audio_pref_handler_->GetNoiseCancellationState());
|
||||
}
|
||||
ToggleNoiseCancellation();
|
||||
EXPECT_FALSE(audio_pref_handler_->GetNoiseCancellationState());
|
||||
}
|
||||
|
||||
TEST_P(UnifiedAudioDetailedViewControllerTest,
|
||||
TEST_F(UnifiedAudioDetailedViewControllerTest,
|
||||
NoiseCancellationUpdatedWhenDeviceChanges) {
|
||||
fake_cras_audio_client()->SetAudioNodesAndNotifyObserversForTesting(
|
||||
GenerateAudioNodeList({kInternalMic, kMicJack, kFrontMic, kRearMic}));
|
||||
@ -600,7 +542,7 @@ TEST_P(UnifiedAudioDetailedViewControllerTest,
|
||||
EXPECT_EQ(1u, toggles_map_.size());
|
||||
}
|
||||
|
||||
TEST_P(UnifiedAudioDetailedViewControllerTest,
|
||||
TEST_F(UnifiedAudioDetailedViewControllerTest,
|
||||
NoiseCancellationUpdatedWhenOnNoiseCancellationChanges) {
|
||||
fake_cras_audio_client()->SetAudioNodesAndNotifyObserversForTesting(
|
||||
GenerateAudioNodeList({kInternalMic, kMicJack, kFrontMic, kRearMic}));
|
||||
@ -615,57 +557,31 @@ TEST_P(UnifiedAudioDetailedViewControllerTest,
|
||||
// view first.
|
||||
GetAudioDetailedView();
|
||||
|
||||
if (!IsQsRevampEnabled()) {
|
||||
EXPECT_EQ(1u, toggles_map_.size());
|
||||
// The toggle loaded the pref correctly.
|
||||
EXPECT_TRUE(noise_cancellation_button()->GetIsOn());
|
||||
EXPECT_TRUE(audio_pref_handler_->GetNoiseCancellationState());
|
||||
auto widget = CreateFramelessTestWidget();
|
||||
widget->SetContentsView(noise_cancellation_button());
|
||||
|
||||
cras_audio_handler_->SetNoiseCancellationState(
|
||||
/*noise_cancellation_on=*/false,
|
||||
CrasAudioHandler::AudioSettingsChangeSource::kSystemTray);
|
||||
// The noise cancellation button loaded the pref correctly.
|
||||
EXPECT_TRUE(noise_cancellation_button()->GetIsOn());
|
||||
EXPECT_TRUE(audio_pref_handler_->GetNoiseCancellationState());
|
||||
|
||||
EXPECT_EQ(1u, toggles_map_.size());
|
||||
// The toggle updates the pref correctly.
|
||||
EXPECT_FALSE(noise_cancellation_button()->GetIsOn());
|
||||
EXPECT_FALSE(audio_pref_handler_->GetNoiseCancellationState());
|
||||
histogram_tester_.ExpectBucketCount(
|
||||
CrasAudioHandler::kNoiseCancellationEnabledSourceHistogramName,
|
||||
CrasAudioHandler::AudioSettingsChangeSource::kSystemTray, 1);
|
||||
} else {
|
||||
auto widget = CreateFramelessTestWidget();
|
||||
widget->SetContentsView(noise_cancellation_button());
|
||||
cras_audio_handler_->SetNoiseCancellationState(
|
||||
/*noise_cancellation_on=*/false,
|
||||
CrasAudioHandler::AudioSettingsChangeSource::kSystemTray);
|
||||
|
||||
// The noise cancellation button loaded the pref correctly.
|
||||
EXPECT_TRUE(noise_cancellation_button()->GetIsOn());
|
||||
EXPECT_TRUE(audio_pref_handler_->GetNoiseCancellationState());
|
||||
|
||||
cras_audio_handler_->SetNoiseCancellationState(
|
||||
/*noise_cancellation_on=*/false,
|
||||
CrasAudioHandler::AudioSettingsChangeSource::kSystemTray);
|
||||
|
||||
// The noise cancellation button updates the pref correctly.
|
||||
EXPECT_FALSE(noise_cancellation_button()->GetIsOn());
|
||||
EXPECT_FALSE(audio_pref_handler_->GetNoiseCancellationState());
|
||||
histogram_tester_.ExpectBucketCount(
|
||||
CrasAudioHandler::kNoiseCancellationEnabledSourceHistogramName,
|
||||
CrasAudioHandler::AudioSettingsChangeSource::kSystemTray, 1);
|
||||
}
|
||||
// The noise cancellation button updates the pref correctly.
|
||||
EXPECT_FALSE(noise_cancellation_button()->GetIsOn());
|
||||
EXPECT_FALSE(audio_pref_handler_->GetNoiseCancellationState());
|
||||
histogram_tester_.ExpectBucketCount(
|
||||
CrasAudioHandler::kNoiseCancellationEnabledSourceHistogramName,
|
||||
CrasAudioHandler::AudioSettingsChangeSource::kSystemTray, 1);
|
||||
}
|
||||
|
||||
TEST_P(UnifiedAudioDetailedViewControllerTest, ToggleLiveCaption) {
|
||||
TEST_F(UnifiedAudioDetailedViewControllerTest, ToggleLiveCaption) {
|
||||
scoped_feature_list_.Reset();
|
||||
if (!IsQsRevampEnabled()) {
|
||||
scoped_feature_list_.InitWithFeatures(
|
||||
{media::kLiveCaption, media::kLiveCaptionSystemWideOnChromeOS,
|
||||
ash::features::kOnDeviceSpeechRecognition},
|
||||
{});
|
||||
} else {
|
||||
scoped_feature_list_.InitWithFeatures(
|
||||
{media::kLiveCaption, media::kLiveCaptionSystemWideOnChromeOS,
|
||||
ash::features::kOnDeviceSpeechRecognition, features::kQsRevamp},
|
||||
{});
|
||||
}
|
||||
scoped_feature_list_.InitWithFeatures(
|
||||
{media::kLiveCaption, media::kLiveCaptionSystemWideOnChromeOS,
|
||||
ash::features::kOnDeviceSpeechRecognition},
|
||||
{});
|
||||
|
||||
EXPECT_TRUE(live_caption_view());
|
||||
EXPECT_FALSE(live_caption_enabled());
|
||||
@ -679,23 +595,14 @@ TEST_P(UnifiedAudioDetailedViewControllerTest, ToggleLiveCaption) {
|
||||
EXPECT_FALSE(live_caption_enabled());
|
||||
}
|
||||
|
||||
TEST_P(UnifiedAudioDetailedViewControllerTest, LiveCaptionNotAvailable) {
|
||||
TEST_F(UnifiedAudioDetailedViewControllerTest, LiveCaptionNotAvailable) {
|
||||
// If the Live Caption feature flags are not set, the Live Caption toggle will
|
||||
// not appear in audio settings.
|
||||
if (!IsQsRevampEnabled()) {
|
||||
EXPECT_FALSE(live_caption_view());
|
||||
} else {
|
||||
EXPECT_TRUE(live_caption_view());
|
||||
}
|
||||
// not be enabled in audio settings.
|
||||
EXPECT_TRUE(live_caption_view());
|
||||
EXPECT_FALSE(live_caption_enabled());
|
||||
}
|
||||
|
||||
TEST_P(UnifiedAudioDetailedViewControllerTest, SliderFocusToggleMute) {
|
||||
// Pre-revamped slider has a different focus behavior
|
||||
if (!IsQsRevampEnabled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
TEST_F(UnifiedAudioDetailedViewControllerTest, SliderFocusToggleMute) {
|
||||
std::unique_ptr<views::View> view =
|
||||
audio_detailed_view_controller_->CreateView();
|
||||
auto widget = CreateFramelessTestWidget();
|
||||
@ -721,7 +628,7 @@ TEST_P(UnifiedAudioDetailedViewControllerTest, SliderFocusToggleMute) {
|
||||
kInternalSpeakerId);
|
||||
}
|
||||
|
||||
TEST_P(UnifiedAudioDetailedViewControllerTest,
|
||||
TEST_F(UnifiedAudioDetailedViewControllerTest,
|
||||
BluetoothOutputDeviceVolumeChange) {
|
||||
std::unique_ptr<views::View> view =
|
||||
audio_detailed_view_controller_->CreateView();
|
||||
@ -802,16 +709,11 @@ class UnifiedAudioDetailedViewControllerSodaTest
|
||||
|
||||
private:
|
||||
std::unique_ptr<speech::SodaInstallerImplChromeOS> soda_installer_impl_;
|
||||
base::test::ScopedFeatureList scoped_feature_list_;
|
||||
};
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(All,
|
||||
UnifiedAudioDetailedViewControllerSodaTest,
|
||||
testing::Bool() /* IsQsRevampEnabled() */);
|
||||
|
||||
// Ensures that the Dictation subtitle changes when SODA AND the language pack
|
||||
// matching the Live Caption locale are installed.
|
||||
TEST_P(UnifiedAudioDetailedViewControllerSodaTest,
|
||||
TEST_F(UnifiedAudioDetailedViewControllerSodaTest,
|
||||
OnSodaInstalledNotification) {
|
||||
SetLiveCaptionLocale("fr-FR");
|
||||
|
||||
@ -829,7 +731,7 @@ TEST_P(UnifiedAudioDetailedViewControllerSodaTest,
|
||||
|
||||
// Ensures we only notify the user of progress for the language pack matching
|
||||
// the Live Caption locale.
|
||||
TEST_P(UnifiedAudioDetailedViewControllerSodaTest, OnSodaProgressNotification) {
|
||||
TEST_F(UnifiedAudioDetailedViewControllerSodaTest, OnSodaProgressNotification) {
|
||||
SetLiveCaptionLocale("en-US");
|
||||
|
||||
soda_installer()->NotifySodaProgressForTesting(75, fr_fr());
|
||||
@ -843,7 +745,7 @@ TEST_P(UnifiedAudioDetailedViewControllerSodaTest, OnSodaProgressNotification) {
|
||||
|
||||
// Ensures we notify the user of an error when the SODA binary fails to
|
||||
// download.
|
||||
TEST_P(UnifiedAudioDetailedViewControllerSodaTest,
|
||||
TEST_F(UnifiedAudioDetailedViewControllerSodaTest,
|
||||
SodaBinaryErrorNotification) {
|
||||
soda_installer()->NotifySodaErrorForTesting();
|
||||
EXPECT_EQ(kSodaFailed, GetLiveCaptionViewSubtitleText());
|
||||
@ -851,7 +753,7 @@ TEST_P(UnifiedAudioDetailedViewControllerSodaTest,
|
||||
|
||||
// Ensures we only notify the user of an error if the failed language pack
|
||||
// matches the Live Caption locale.
|
||||
TEST_P(UnifiedAudioDetailedViewControllerSodaTest,
|
||||
TEST_F(UnifiedAudioDetailedViewControllerSodaTest,
|
||||
SodaLanguageErrorNotification) {
|
||||
SetLiveCaptionLocale("en-US");
|
||||
soda_installer()->NotifySodaErrorForTesting(fr_fr());
|
||||
@ -863,7 +765,7 @@ TEST_P(UnifiedAudioDetailedViewControllerSodaTest,
|
||||
|
||||
// Ensures that we don't respond to SODA download updates when Live Caption is
|
||||
// off.
|
||||
TEST_P(UnifiedAudioDetailedViewControllerSodaTest,
|
||||
TEST_F(UnifiedAudioDetailedViewControllerSodaTest,
|
||||
SodaDownloadLiveCaptionDisabled) {
|
||||
EnableLiveCaption(false);
|
||||
EXPECT_EQ(kInitialLiveCaptionViewSubtitleText,
|
||||
|
Reference in New Issue
Block a user