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

ash / system / update / quick_settings_notice_view_pixeltest_base.cc [blame]

// 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/update/quick_settings_notice_view_pixeltest_base.h"

#include <memory>

#include "ash/test/ash_test_base.h"
#include "ash/test/pixel/ash_pixel_differ.h"
#include "ash/test/pixel/ash_pixel_test_init_params.h"
#include "ui/chromeos/styles/cros_tokens_color_mappings.h"
#include "ui/gfx/geometry/size.h"
#include "ui/views/background.h"
#include "ui/views/layout/box_layout.h"
#include "ui/views/layout/box_layout_view.h"
#include "ui/views/view.h"
#include "ui/views/widget/widget.h"

namespace ash {

QuickSettingsNoticeViewPixelTestBase::QuickSettingsNoticeViewPixelTestBase() =
    default;
QuickSettingsNoticeViewPixelTestBase::~QuickSettingsNoticeViewPixelTestBase() =
    default;

void QuickSettingsNoticeViewPixelTestBase::SetUp() {
  AshTestBase::SetUp();

  widget_ = CreateFramelessTestWidget();
  widget_->SetFullscreen(true);
  auto* contents =
      widget_->SetContentsView(std::make_unique<views::BoxLayoutView>());
  contents->SetMainAxisAlignment(views::BoxLayout::MainAxisAlignment::kCenter);
  contents->SetCrossAxisAlignment(
      views::BoxLayout::CrossAxisAlignment::kCenter);
  // The stroke color has transparency, so set a background color so it
  // renders like in production.
  contents->SetBackground(views::CreateThemedSolidBackground(
      cros_tokens::kCrosSysSystemBaseElevated));
}

void QuickSettingsNoticeViewPixelTestBase::TearDown() {
  widget_.reset();

  AshTestBase::TearDown();
}

std::optional<pixel_test::InitParams>
QuickSettingsNoticeViewPixelTestBase::CreatePixelTestInitParams() const {
  return pixel_test::InitParams();
}

void QuickSettingsNoticeViewPixelTestBase::DiffView(size_t revision_number) {
  EXPECT_TRUE(GetPixelDiffer()->CompareUiComponentsOnPrimaryScreen(
      "check_view", revision_number, widget_.get()));
}

}  // namespace ash