#include "ash/system/time/time_tray_item_view.h"
#include "ash/constants/ash_features.h"
#include "ash/shelf/shelf.h"
#include "ash/system/time/time_view.h"
#include "ash/test/ash_test_base.h"
namespace ash {
class TimeTrayItemViewTest : public AshTestBase {
public:
TimeTrayItemViewTest() = default;
~TimeTrayItemViewTest() override = default;
void SetUp() override {
AshTestBase::SetUp();
time_tray_item_view_ = std::make_unique<TimeTrayItemView>(
GetPrimaryShelf(), TimeView::Type::kTime);
}
void TearDown() override {
time_tray_item_view_.reset();
AshTestBase::TearDown();
}
bool IsTimeViewInHorizontalLayout() {
return time_tray_item_view_->time_view_->horizontal_time_label_container_
->GetVisible();
}
protected:
std::unique_ptr<TimeTrayItemView> time_tray_item_view_;
};
TEST_F(TimeTrayItemViewTest, ShelfAlignment) {
GetPrimaryShelf()->SetAlignment(ShelfAlignment::kBottom);
time_tray_item_view_->UpdateAlignmentForShelf(GetPrimaryShelf());
EXPECT_TRUE(IsTimeViewInHorizontalLayout());
GetPrimaryShelf()->SetAlignment(ShelfAlignment::kLeft);
time_tray_item_view_->UpdateAlignmentForShelf(GetPrimaryShelf());
EXPECT_FALSE(IsTimeViewInHorizontalLayout());
GetPrimaryShelf()->SetAlignment(ShelfAlignment::kRight);
time_tray_item_view_->UpdateAlignmentForShelf(GetPrimaryShelf());
EXPECT_FALSE(IsTimeViewInHorizontalLayout());
GetPrimaryShelf()->SetAlignment(ShelfAlignment::kBottom);
time_tray_item_view_->UpdateAlignmentForShelf(GetPrimaryShelf());
EXPECT_TRUE(IsTimeViewInHorizontalLayout());
}
}