#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;
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());
}
}
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());
}
}
}
}