Skip to content

Commit

Permalink
fix(YaruTitleBar): add golden tests windows variant (#801)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jupi007 authored Nov 19, 2023
1 parent 22b8bb3 commit e6d02ca
Show file tree
Hide file tree
Showing 16 changed files with 86 additions and 67 deletions.
3 changes: 3 additions & 0 deletions lib/src/widgets/yaru_title_bar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -619,6 +619,9 @@ class YaruDialogTitleBar extends YaruWindowTitleBar {
super.onRestore = null,
super.onShowMenu = YaruWindow.showMenu,
super.heroTag = _kYaruTitleBarHeroTag,
super.platform,
super.buttonPadding,
super.buttonSpacing,
});

static const defaultShape = RoundedRectangleBorder(
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
150 changes: 83 additions & 67 deletions test/widgets/yaru_title_bar_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,14 @@ void main() {
(tester) async {
final variant = goldenVariant.currentValue!;

late YaruWindowControlPlatform platform;

if (variant.label.startsWith('windows')) {
platform = YaruWindowControlPlatform.windows;
} else {
platform = YaruWindowControlPlatform.yaru;
}

final state = variant.value!;
final builder = variant.label.contains('dialog')
? YaruDialogTitleBar.new
Expand All @@ -125,6 +133,7 @@ void main() {
onMinimize: (_) {},
onRestore: (_) {},
backgroundColor: variant.label.contains('red') ? Colors.red : null,
platform: platform,
),
themeMode: variant.themeMode,
size: const Size(480, kYaruTitleBarHeight),
Expand All @@ -142,71 +151,78 @@ void main() {
}

final goldenVariant = ValueVariant({
...goldenThemeVariants(
'empty',
const YaruWindowState(
isActive: true,
title: 'empty',
),
),
...goldenThemeVariants(
'closable',
const YaruWindowState(
isActive: true,
isClosable: true,
title: 'closable',
),
),
...goldenThemeVariants(
'maximizable',
const YaruWindowState(
isActive: true,
isMinimizable: true,
isMaximizable: true,
isClosable: true,
title: 'maximizable',
),
),
...goldenThemeVariants(
'restorable',
const YaruWindowState(
isActive: true,
isMinimizable: true,
isRestorable: true,
isClosable: true,
title: 'restorable',
),
),
...goldenThemeVariants(
'inactive',
const YaruWindowState(
isActive: false,
isMinimizable: true,
isMaximizable: true,
isClosable: true,
title: 'inactive',
),
),
...goldenThemeVariants(
'dialog',
const YaruWindowState(
isActive: true,
isMinimizable: false,
isMaximizable: false,
isRestorable: false,
isClosable: true,
title: 'dialog',
),
),
...goldenThemeVariants(
'dialog-red',
const YaruWindowState(
isActive: true,
isClosable: true,
isMinimizable: false,
isMaximizable: false,
isRestorable: false,
title: 'red dialog',
),
),
for (final platform in YaruWindowControlPlatform.values)
...() {
final platformPrefix =
platform == YaruWindowControlPlatform.windows ? 'windows-' : '';
return {
...goldenThemeVariants(
'${platformPrefix}empty',
const YaruWindowState(
isActive: true,
title: 'empty',
),
),
...goldenThemeVariants(
'${platformPrefix}closable',
const YaruWindowState(
isActive: true,
isClosable: true,
title: 'closable',
),
),
...goldenThemeVariants(
'${platformPrefix}maximizable',
const YaruWindowState(
isActive: true,
isMinimizable: true,
isMaximizable: true,
isClosable: true,
title: 'maximizable',
),
),
...goldenThemeVariants(
'${platformPrefix}restorable',
const YaruWindowState(
isActive: true,
isMinimizable: true,
isRestorable: true,
isClosable: true,
title: 'restorable',
),
),
...goldenThemeVariants(
'${platformPrefix}inactive',
const YaruWindowState(
isActive: false,
isMinimizable: true,
isMaximizable: true,
isClosable: true,
title: 'inactive',
),
),
...goldenThemeVariants(
'${platformPrefix}dialog',
const YaruWindowState(
isActive: true,
isMinimizable: false,
isMaximizable: false,
isRestorable: false,
isClosable: true,
title: 'dialog',
),
),
...goldenThemeVariants(
'${platformPrefix}dialog-red',
const YaruWindowState(
isActive: true,
isClosable: true,
isMinimizable: false,
isMaximizable: false,
isRestorable: false,
title: 'red dialog',
),
),
};
}(),
});

0 comments on commit e6d02ca

Please sign in to comment.