Parametrize additional pixel tests for notification width change.
Refactors additional pixel tests to include the Notification Width Resizing Feature Flag to be included in the scoped features list. Also fixes to make sure that feature flag is actually being enabled for appropriate tests. Bug: 343768137 Change-Id: I9d4cc6f5ae68bb3f63491226efa8a3c2a6d1c76d Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5631241 Reviewed-by: Ahmed Fakhry <afakhry@chromium.org> Commit-Queue: Bhuvana Betini <bbetini@google.com> Reviewed-by: Andre Le <leandre@chromium.org> Cr-Commit-Position: refs/heads/main@{#1317608}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
6650241adf
commit
d0f8c55927
ash
capture_mode
scalable_iph
system
notification_center
@ -14,6 +14,8 @@
|
||||
#include "ash/test/pixel/ash_pixel_test_init_params.h"
|
||||
#include "base/strings/strcat.h"
|
||||
#include "base/strings/utf_string_conversions.h"
|
||||
#include "base/test/scoped_feature_list.h"
|
||||
#include "chromeos/constants/chromeos_features.h"
|
||||
#include "ui/base/ui_base_features.h"
|
||||
#include "ui/message_center/views/message_popup_view.h"
|
||||
#include "ui/message_center/views/message_view.h"
|
||||
@ -48,11 +50,15 @@ std::string GetDisplayTypeName(DisplayType type) {
|
||||
}
|
||||
}
|
||||
|
||||
std::string GetScreenshotName(const std::string& test_name, bool new_width) {
|
||||
return test_name + (new_width ? "_new_width" : "_old_width");
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
class DisplayParameterizedCaptureModePixelTest
|
||||
: public AshTestBase,
|
||||
public testing::WithParamInterface<DisplayType> {
|
||||
public testing::WithParamInterface<std::tuple<DisplayType, bool>> {
|
||||
public:
|
||||
// AshTestBase:
|
||||
std::optional<pixel_test::InitParams> CreatePixelTestInitParams()
|
||||
@ -82,6 +88,11 @@ class DisplayParameterizedCaptureModePixelTest
|
||||
CreateAppWindow(/*bounds_in_screen=*/gfx::Rect(220, 220, 100, 100));
|
||||
DecorateWindow(window1_.get(), u"Window1", SK_ColorDKGRAY);
|
||||
DecorateWindow(window2_.get(), u"Window2", SK_ColorBLUE);
|
||||
|
||||
scoped_feature_list_ = std::make_unique<base::test::ScopedFeatureList>();
|
||||
scoped_feature_list_->InitWithFeatureState(
|
||||
chromeos::features::kNotificationWidthIncrease,
|
||||
IsNotificationWidthIncreaseEnabled());
|
||||
}
|
||||
|
||||
void TearDown() override {
|
||||
@ -92,20 +103,25 @@ class DisplayParameterizedCaptureModePixelTest
|
||||
|
||||
NotificationCenterTestApi* test_api() { return test_api_.get(); }
|
||||
|
||||
DisplayType GetDisplayType() const { return GetParam(); }
|
||||
DisplayType GetDisplayType() const { return std::get<0>(GetParam()); }
|
||||
|
||||
bool IsNotificationWidthIncreaseEnabled() { return std::get<1>(GetParam()); }
|
||||
|
||||
private:
|
||||
std::unique_ptr<aura::Window> window1_;
|
||||
std::unique_ptr<aura::Window> window2_;
|
||||
|
||||
std::unique_ptr<NotificationCenterTestApi> test_api_;
|
||||
std::unique_ptr<base::test::ScopedFeatureList> scoped_feature_list_;
|
||||
};
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(DisplaySize,
|
||||
DisplayParameterizedCaptureModePixelTest,
|
||||
testing::ValuesIn({DisplayType::kNormal,
|
||||
DisplayType::kUltraWidth,
|
||||
DisplayType::kUltraHeight}));
|
||||
INSTANTIATE_TEST_SUITE_P(
|
||||
DisplaySize,
|
||||
DisplayParameterizedCaptureModePixelTest,
|
||||
testing::Combine(testing::ValuesIn({DisplayType::kNormal,
|
||||
DisplayType::kUltraWidth,
|
||||
DisplayType::kUltraHeight}),
|
||||
/*IsNotificationWidthIncreaseEnabled()=*/testing::Bool()));
|
||||
|
||||
TEST_P(DisplayParameterizedCaptureModePixelTest,
|
||||
ScreenCaptureNotificationPopup) {
|
||||
@ -122,9 +138,10 @@ TEST_P(DisplayParameterizedCaptureModePixelTest,
|
||||
|
||||
// Get the notification view.
|
||||
EXPECT_TRUE(GetPixelDiffer()->CompareUiComponentsOnPrimaryScreen(
|
||||
base::StrCat({"screen_capture_popup_notification_",
|
||||
GetDisplayTypeName(GetDisplayType())}),
|
||||
/*revision_number=*/1,
|
||||
GetScreenshotName(base::StrCat({"screen_capture_popup_notification_",
|
||||
GetDisplayTypeName(GetDisplayType())}),
|
||||
IsNotificationWidthIncreaseEnabled()),
|
||||
/*revision_number=*/0,
|
||||
test_api()->GetPopupViewForId(kScreenCaptureNotificationId)));
|
||||
}
|
||||
|
||||
@ -154,17 +171,19 @@ TEST_P(DisplayParameterizedCaptureModePixelTest, VideoCaptureNotification) {
|
||||
test_api()->GetPopupViewForId(notification_id);
|
||||
|
||||
EXPECT_TRUE(GetPixelDiffer()->CompareUiComponentsOnPrimaryScreen(
|
||||
base::StrCat({"video_capture_notification_popup_",
|
||||
GetDisplayTypeName(GetDisplayType())}),
|
||||
/*revision_number=*/4, notification_popup_view));
|
||||
GetScreenshotName(base::StrCat({"video_capture_notification_popup_",
|
||||
GetDisplayTypeName(GetDisplayType())}),
|
||||
IsNotificationWidthIncreaseEnabled()),
|
||||
/*revision_number=*/0, notification_popup_view));
|
||||
|
||||
test_api()->ToggleBubble();
|
||||
auto* notification_view =
|
||||
test_api()->GetNotificationViewForId(notification_id);
|
||||
EXPECT_TRUE(GetPixelDiffer()->CompareUiComponentsOnPrimaryScreen(
|
||||
base::StrCat({"video_capture_notification_view_",
|
||||
GetDisplayTypeName(GetDisplayType())}),
|
||||
/*revision_number=*/4, notification_view));
|
||||
GetScreenshotName(base::StrCat({"video_capture_notification_view_",
|
||||
GetDisplayTypeName(GetDisplayType())}),
|
||||
IsNotificationWidthIncreaseEnabled()),
|
||||
/*revision_number=*/0, notification_view));
|
||||
}
|
||||
|
||||
} // namespace ash
|
||||
|
@ -7,6 +7,8 @@
|
||||
#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 "base/test/scoped_feature_list.h"
|
||||
#include "chromeos/constants/chromeos_features.h"
|
||||
#include "ui/gfx/paint_vector_icon.h"
|
||||
#include "ui/message_center/message_center.h"
|
||||
#include "ui/message_center/public/cpp/notification.h"
|
||||
@ -17,19 +19,46 @@
|
||||
namespace ash {
|
||||
namespace {
|
||||
constexpr char kTestNotificationId[] = "TestNotificationId";
|
||||
|
||||
std::string GetScreenshotName(const std::string& test_name, bool new_width) {
|
||||
return test_name + (new_width ? "_new_width" : "_old_width");
|
||||
}
|
||||
|
||||
class ScalableIphPixelTest : public AshTestBase {
|
||||
} // namespace
|
||||
|
||||
class ScalableIphPixelTest : public AshTestBase,
|
||||
public testing::WithParamInterface<bool> {
|
||||
public:
|
||||
bool IsNotificationWidthIncreaseEnabled() { return GetParam(); }
|
||||
|
||||
void SetUp() override {
|
||||
scoped_feature_list_ = std::make_unique<base::test::ScopedFeatureList>();
|
||||
scoped_feature_list_->InitWithFeatureState(
|
||||
chromeos::features::kNotificationWidthIncrease,
|
||||
IsNotificationWidthIncreaseEnabled());
|
||||
AshTestBase::SetUp();
|
||||
test_api_ = std::make_unique<NotificationCenterTestApi>();
|
||||
}
|
||||
|
||||
protected:
|
||||
std::optional<pixel_test::InitParams> CreatePixelTestInitParams()
|
||||
const override {
|
||||
return pixel_test::InitParams();
|
||||
}
|
||||
|
||||
private:
|
||||
std::unique_ptr<NotificationCenterTestApi> test_api_;
|
||||
std::unique_ptr<base::test::ScopedFeatureList> scoped_feature_list_;
|
||||
};
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(
|
||||
All,
|
||||
ScalableIphPixelTest,
|
||||
/*IsNotificationWidthIncreaseEnabled()=*/testing::Bool());
|
||||
|
||||
// To show a notification with no body text, we set an empty string to message
|
||||
// field. Make sure that it shows our desired UI output.
|
||||
TEST_F(ScalableIphPixelTest, NotificationNoBodyText) {
|
||||
TEST_P(ScalableIphPixelTest, NotificationNoBodyText) {
|
||||
// TODO(b/323426306): update this test to test logic in ash.
|
||||
std::unique_ptr<message_center::Notification> notification =
|
||||
ash::CreateSystemNotificationPtr(
|
||||
@ -53,8 +82,8 @@ TEST_F(ScalableIphPixelTest, NotificationNoBodyText) {
|
||||
ASSERT_TRUE(message_view);
|
||||
|
||||
EXPECT_TRUE(GetPixelDiffer()->CompareUiComponentsOnPrimaryScreen(
|
||||
"scalable_iph_notification_no_body_text", /*revision_number=*/0,
|
||||
message_view));
|
||||
GetScreenshotName("scalable_iph_notification_no_body_text",
|
||||
IsNotificationWidthIncreaseEnabled()),
|
||||
/*revision_number=*/0, message_view));
|
||||
}
|
||||
|
||||
} // namespace ash
|
||||
|
@ -44,8 +44,8 @@ const ui::ImageModel test_green_icon = ui::ImageModel::FromImageSkia(
|
||||
CreateSolidColorTestImage(gfx::Size(/*width=*/48, /*height=*/48),
|
||||
SK_ColorGREEN));
|
||||
|
||||
std::string GetScreenshotName(const std::string& test_name, bool newWidth) {
|
||||
return test_name + (newWidth ? "_new_width" : "old_width");
|
||||
std::string GetScreenshotName(const std::string& test_name, bool new_width) {
|
||||
return test_name + (new_width ? "_new_width" : "_old_width");
|
||||
}
|
||||
} // namespace
|
||||
|
||||
@ -78,7 +78,7 @@ class AshNotificationViewPixelTest : public AshPixelTestBase,
|
||||
scoped_feature_list_ = std::make_unique<base::test::ScopedFeatureList>();
|
||||
scoped_feature_list_->InitWithFeatureState(
|
||||
chromeos::features::kNotificationWidthIncrease,
|
||||
chromeos::features::IsNotificationWidthIncreaseEnabled());
|
||||
IsNotificationWidthIncreaseEnabled());
|
||||
AshPixelTestBase::SetUp();
|
||||
}
|
||||
|
||||
@ -121,7 +121,7 @@ TEST_P(AshNotificationViewPixelTest, CloseButtonFocused) {
|
||||
EXPECT_TRUE(GetPixelDiffer()->CompareUiComponentsOnPrimaryScreen(
|
||||
GetScreenshotName("close_button_focused",
|
||||
IsNotificationWidthIncreaseEnabled()),
|
||||
/*revision_number=*/0, notification_view));
|
||||
/*revision_number=*/1, notification_view));
|
||||
}
|
||||
|
||||
// Regression test for http://b/267195370. Tests that a notification with no
|
||||
@ -144,7 +144,7 @@ TEST_P(AshNotificationViewPixelTest, CollapsedNoMessage) {
|
||||
EXPECT_TRUE(GetPixelDiffer()->CompareUiComponentsOnPrimaryScreen(
|
||||
GetScreenshotName("collapsed_no_message",
|
||||
IsNotificationWidthIncreaseEnabled()),
|
||||
/*revision_number=*/0, notification_view));
|
||||
/*revision_number=*/1, notification_view));
|
||||
}
|
||||
|
||||
// Tests that a progress notification does not have its title vertically
|
||||
@ -167,7 +167,7 @@ TEST_P(AshNotificationViewPixelTest, ProgressCollapsed) {
|
||||
EXPECT_TRUE(GetPixelDiffer()->CompareUiComponentsOnPrimaryScreen(
|
||||
GetScreenshotName("progress_collapsed",
|
||||
IsNotificationWidthIncreaseEnabled()),
|
||||
/*revision_number=*/0, notification_view));
|
||||
/*revision_number=*/1, notification_view));
|
||||
}
|
||||
|
||||
// Tests the control buttons UI for the case of a notification with just the
|
||||
@ -191,7 +191,7 @@ TEST_P(AshNotificationViewPixelTest, CloseControlButton) {
|
||||
EXPECT_TRUE(GetPixelDiffer()->CompareUiComponentsOnPrimaryScreen(
|
||||
GetScreenshotName("close_control_button",
|
||||
IsNotificationWidthIncreaseEnabled()),
|
||||
/*revision_number=*/0, notification_view));
|
||||
/*revision_number=*/1, notification_view));
|
||||
}
|
||||
|
||||
// Tests the control buttons UI for the case of a notification with both the
|
||||
@ -215,7 +215,7 @@ TEST_P(AshNotificationViewPixelTest, SettingsAndCloseControlButtons) {
|
||||
EXPECT_TRUE(GetPixelDiffer()->CompareUiComponentsOnPrimaryScreen(
|
||||
GetScreenshotName("settings_and_close_control_buttons",
|
||||
IsNotificationWidthIncreaseEnabled()),
|
||||
/*revision_number=*/0, notification_view));
|
||||
/*revision_number=*/1, notification_view));
|
||||
}
|
||||
|
||||
// Tests the inline reply UI for AshNotificationView.
|
||||
@ -241,7 +241,7 @@ TEST_P(AshNotificationViewPixelTest, InlineReply) {
|
||||
EXPECT_TRUE(GetPixelDiffer()->CompareUiComponentsOnPrimaryScreen(
|
||||
GetScreenshotName("inline_reply_focused",
|
||||
IsNotificationWidthIncreaseEnabled()),
|
||||
/*revision_number=*/0, notification_view));
|
||||
/*revision_number=*/1, notification_view));
|
||||
}
|
||||
|
||||
// Tests the focus ring for the expand button in AshNotificationView.
|
||||
@ -258,7 +258,7 @@ TEST_P(AshNotificationViewPixelTest, ExpandButtonFocusRing) {
|
||||
EXPECT_TRUE(GetPixelDiffer()->CompareUiComponentsOnPrimaryScreen(
|
||||
GetScreenshotName("expand_button_focus_ring",
|
||||
IsNotificationWidthIncreaseEnabled()),
|
||||
/*revision_number=*/0, notification_view));
|
||||
/*revision_number=*/1, notification_view));
|
||||
}
|
||||
|
||||
TEST_P(AshNotificationViewPixelTest, NotificationViewFocusRing) {
|
||||
@ -272,7 +272,7 @@ TEST_P(AshNotificationViewPixelTest, NotificationViewFocusRing) {
|
||||
EXPECT_TRUE(GetPixelDiffer()->CompareUiComponentsOnPrimaryScreen(
|
||||
GetScreenshotName("notification_view_focus_ring",
|
||||
IsNotificationWidthIncreaseEnabled()),
|
||||
/*revision_number=*/0, notification_view));
|
||||
/*revision_number=*/1, notification_view));
|
||||
}
|
||||
|
||||
TEST_P(AshNotificationViewPixelTest, NotificationPopupFocusRing) {
|
||||
@ -290,7 +290,7 @@ TEST_P(AshNotificationViewPixelTest, NotificationPopupFocusRing) {
|
||||
EXPECT_TRUE(GetPixelDiffer()->CompareUiComponentsOnPrimaryScreen(
|
||||
GetScreenshotName("notification_popup_focus_ring",
|
||||
IsNotificationWidthIncreaseEnabled()),
|
||||
/*revision_number=*/0, notification_view));
|
||||
/*revision_number=*/1, notification_view));
|
||||
}
|
||||
|
||||
// Tests that a notification's icon is sized and positioned correctly at
|
||||
@ -307,7 +307,7 @@ class AshNotificationViewIconPixelTest
|
||||
scoped_feature_list_ = std::make_unique<base::test::ScopedFeatureList>();
|
||||
scoped_feature_list_->InitWithFeatureState(
|
||||
chromeos::features::kNotificationWidthIncrease,
|
||||
chromeos::features::IsNotificationWidthIncreaseEnabled());
|
||||
IsNotificationWidthIncreaseEnabled());
|
||||
AshPixelTestBase::SetUp();
|
||||
}
|
||||
|
||||
@ -347,7 +347,7 @@ TEST_P(AshNotificationViewIconPixelTest, NotificationIcon) {
|
||||
EXPECT_TRUE(GetPixelDiffer()->CompareUiComponentsOnPrimaryScreen(
|
||||
GetScreenshotName(base::StringPrintf("expanded_icon_size_%u", size),
|
||||
IsNotificationWidthIncreaseEnabled()),
|
||||
/*revision_number=*/0, notification_view));
|
||||
/*revision_number=*/1, notification_view));
|
||||
|
||||
notification_view->ToggleExpand();
|
||||
ASSERT_FALSE(notification_view->IsExpanded());
|
||||
@ -359,7 +359,7 @@ TEST_P(AshNotificationViewIconPixelTest, NotificationIcon) {
|
||||
EXPECT_TRUE(GetPixelDiffer()->CompareUiComponentsOnPrimaryScreen(
|
||||
GetScreenshotName(base::StringPrintf("collapsed_icon_size_%u", size),
|
||||
IsNotificationWidthIncreaseEnabled()),
|
||||
/*revision_number=*/0, notification_view));
|
||||
/*revision_number=*/1, notification_view));
|
||||
}
|
||||
|
||||
class AshNotificationViewTitlePixelTest
|
||||
@ -376,7 +376,7 @@ class AshNotificationViewTitlePixelTest
|
||||
scoped_feature_list_ = std::make_unique<base::test::ScopedFeatureList>();
|
||||
scoped_feature_list_->InitWithFeatureState(
|
||||
chromeos::features::kNotificationWidthIncrease,
|
||||
chromeos::features::IsNotificationWidthIncreaseEnabled());
|
||||
IsNotificationWidthIncreaseEnabled());
|
||||
AshPixelTestBase::SetUp();
|
||||
}
|
||||
|
||||
@ -422,7 +422,7 @@ TEST_P(AshNotificationViewTitlePixelTest, NotificationTitleTest) {
|
||||
EXPECT_TRUE(GetPixelDiffer()->CompareUiComponentsOnPrimaryScreen(
|
||||
::ash::GetScreenshotName(screenshot_name,
|
||||
IsNotificationWidthIncreaseEnabled()),
|
||||
/*revision_number=*/0, notification_view));
|
||||
/*revision_number=*/1, notification_view));
|
||||
}
|
||||
|
||||
class AshNotificationViewCollapsedLongTextPixelTest
|
||||
@ -441,7 +441,7 @@ class AshNotificationViewCollapsedLongTextPixelTest
|
||||
scoped_feature_list_ = std::make_unique<base::test::ScopedFeatureList>();
|
||||
scoped_feature_list_->InitWithFeatureState(
|
||||
chromeos::features::kNotificationWidthIncrease,
|
||||
chromeos::features::IsNotificationWidthIncreaseEnabled());
|
||||
IsNotificationWidthIncreaseEnabled());
|
||||
AshPixelTestBase::SetUp();
|
||||
}
|
||||
|
||||
@ -492,7 +492,7 @@ TEST_P(AshNotificationViewCollapsedLongTextPixelTest, ElidedTextSpacing) {
|
||||
EXPECT_TRUE(GetPixelDiffer()->CompareUiComponentsOnPrimaryScreen(
|
||||
GetScreenshotName("elided_text_spacing",
|
||||
IsNotificationWidthIncreaseEnabled()),
|
||||
/*revision_number=*/0, notification_view));
|
||||
/*revision_number=*/1, notification_view));
|
||||
}
|
||||
|
||||
} // namespace ash
|
||||
|
Reference in New Issue
Block a user