1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
|
// Copyright 2024 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "ash/system/unified/unified_slider_bubble_controller.h"
#include <vector>
#include "ash/shelf/shelf.h"
#include "ash/system/status_area_widget.h"
#include "ash/system/unified/unified_system_tray.h"
#include "ash/test/ash_test_base.h"
#include "base/run_loop.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace ash {
namespace {
using SliderType = UnifiedSliderBubbleController::SliderType;
using UnifiedSliderBubbleControllerTest = AshTestBase;
// Tests the bubble and slider view lifetime when opening and closing each type
// of bubble.
TEST_F(UnifiedSliderBubbleControllerTest, ShowAndHideBubble) {
std::vector<SliderType> types = {
SliderType::SLIDER_TYPE_VOLUME,
SliderType::SLIDER_TYPE_DISPLAY_BRIGHTNESS,
SliderType::SLIDER_TYPE_KEYBOARD_BACKLIGHT_TOGGLE_OFF,
SliderType::SLIDER_TYPE_KEYBOARD_BACKLIGHT_TOGGLE_ON,
SliderType::SLIDER_TYPE_KEYBOARD_BRIGHTNESS,
SliderType::SLIDER_TYPE_MIC};
UnifiedSliderBubbleController controller(
GetPrimaryShelf()->GetStatusAreaWidget()->unified_system_tray());
for (auto type : types) {
controller.ShowBubble(type);
EXPECT_TRUE(controller.IsBubbleShown());
EXPECT_TRUE(controller.slider_view());
controller.CloseBubble();
base::RunLoop().RunUntilIdle();
EXPECT_FALSE(controller.IsBubbleShown());
EXPECT_FALSE(controller.slider_view());
}
}
// Regression test for b/342513656.
TEST_F(UnifiedSliderBubbleControllerTest, UpdateBubble) {
std::vector<SliderType> types = {
SliderType::SLIDER_TYPE_VOLUME,
SliderType::SLIDER_TYPE_DISPLAY_BRIGHTNESS,
SliderType::SLIDER_TYPE_KEYBOARD_BACKLIGHT_TOGGLE_OFF,
SliderType::SLIDER_TYPE_KEYBOARD_BACKLIGHT_TOGGLE_ON,
SliderType::SLIDER_TYPE_KEYBOARD_BRIGHTNESS,
SliderType::SLIDER_TYPE_MIC};
UnifiedSliderBubbleController controller(
GetPrimaryShelf()->GetStatusAreaWidget()->unified_system_tray());
for (auto type : types) {
controller.ShowBubble(type);
EXPECT_TRUE(controller.IsBubbleShown());
EXPECT_TRUE(controller.slider_view());
}
}
} // namespace
} // namespace ash
|