Skip to content

Commit

Permalink
vaev-style: Fix tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
sleepy-monax committed Jan 15, 2025
1 parent 1c6d805 commit 8a25e95
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 2 deletions.
43 changes: 43 additions & 0 deletions src/web/vaev-style/tests/test-media-features.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ static Media const TEST_MEDIA = {
.forcedColors = Colors::NONE,
.prefersColorScheme = ColorScheme::LIGHT,
.prefersReducedData = ReducedData::REDUCE,

.deviceWidth = 1920_px,
.deviceHeight = 1080_px,
.deviceAspectRatio = 16.0 / 9.0,
};

test$("feature-type") {
Expand Down Expand Up @@ -251,4 +255,43 @@ test$("feature-prefers-reduced-data") {
return Ok();
}

test$("feature-device-width") {
expect$(DeviceWidthFeature::min(1920_px)
.match(TEST_MEDIA));

expect$(DeviceWidthFeature::max(1920_px)
.match(TEST_MEDIA));

expect$(DeviceWidthFeature::exact(1920_px)
.match(TEST_MEDIA));

return Ok();
}

test$("feature-device-height") {
expect$(DeviceHeightFeature::min(1080_px)
.match(TEST_MEDIA));

expect$(DeviceHeightFeature::max(1080_px)
.match(TEST_MEDIA));

expect$(DeviceHeightFeature::exact(1080_px)
.match(TEST_MEDIA));

return Ok();
}

test$("feature-device-aspect-ratio") {
expect$(DeviceAspectRatioFeature::min(16.0 / 9.0)
.match(TEST_MEDIA));

expect$(DeviceAspectRatioFeature::max(16.0 / 9.0)
.match(TEST_MEDIA));

expect$(DeviceAspectRatioFeature::exact(16.0 / 9.0)
.match(TEST_MEDIA));

return Ok();
}

} // namespace Vaev::Style::Tests
8 changes: 6 additions & 2 deletions src/web/vaev-style/tests/test-media-query.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ namespace Vaev::Style::Tests {

static Media const TEST_MEDIA = {
.type = MediaType::SCREEN,
.width = Px(1920),
.height = Px(1080),
.width = 1920_px,
.height = 1080_px,
.aspectRatio = 16.0 / 9.0,
.orientation = Print::Orientation::LANDSCAPE,

Expand All @@ -32,6 +32,10 @@ static Media const TEST_MEDIA = {
.forcedColors = Colors::NONE,
.prefersColorScheme = ColorScheme::LIGHT,
.prefersReducedData = ReducedData::REDUCE,

.deviceWidth = 1920_px,
.deviceHeight = 1080_px,
.deviceAspectRatio = 16.0 / 9.0,
};

test$("logical-and") {
Expand Down

0 comments on commit 8a25e95

Please sign in to comment.