mirror of
https://github.com/ChrisTitusTech/winutil.git
synced 2026-07-18 01:40:49 +00:00
Defer status taskbar asset rendering
This commit is contained in:
42
pester/assets.Tests.ps1
Normal file
42
pester/assets.Tests.ps1
Normal file
@@ -0,0 +1,42 @@
|
||||
#===========================================================================
|
||||
# Tests - Asset rendering
|
||||
#===========================================================================
|
||||
|
||||
BeforeAll {
|
||||
$script:repoRoot = (Resolve-Path (Join-Path $PSScriptRoot "..")).Path
|
||||
}
|
||||
|
||||
Describe "Rendered asset caching" {
|
||||
It "caches rendered bitmap assets by type and size" {
|
||||
$assetScript = Get-Content -Path (Join-Path $script:repoRoot "functions\private\Invoke-WinUtilAssets.ps1") -Raw
|
||||
|
||||
$assetScript | Should -Match 'RenderedAssetCache'
|
||||
$assetScript | Should -Match '\$cacheKey = "\$\(\(\[string\]\$type\)\.ToLowerInvariant\(\)\)\|\$Size"'
|
||||
$assetScript | Should -Match 'return \$sync\.RenderedAssetCache\[\$cacheKey\]'
|
||||
$assetScript | Should -Match '\$sync\.RenderedAssetCache\[\$cacheKey\] = \$bitmapImage'
|
||||
}
|
||||
|
||||
It "renders only the logo overlay before first paint and defers status overlays" {
|
||||
$mainScript = Get-Content -Path (Join-Path $script:repoRoot "scripts\main.ps1") -Raw
|
||||
|
||||
$mainScript | Should -Match 'Initialize-WinUtilTaskbarOverlayAssets -IncludeLogo \$true -IncludeStatusAssets \$false'
|
||||
$mainScript | Should -Match 'Dispatcher\.BeginInvoke\(\[System\.Windows\.Threading\.DispatcherPriority\]::Background, \[action\]\{ Initialize-WinUtilTaskbarOverlayAssets -IncludeLogo \$false -IncludeStatusAssets \$true \}'
|
||||
$mainScript | Should -Not -Match '\$sync\["checkmarkrender"\] = \(Invoke-WinUtilAssets -Type "checkmark"'
|
||||
$mainScript | Should -Not -Match '\$sync\["warningrender"\] = \(Invoke-WinUtilAssets -Type "warning"'
|
||||
}
|
||||
|
||||
It "lazily creates taskbar overlays before assigning them" {
|
||||
$taskbarScript = Get-Content -Path (Join-Path $script:repoRoot "functions\private\Set-WinUtilTaskbarItem.ps1") -Raw
|
||||
|
||||
$taskbarScript | Should -Match 'Initialize-WinUtilTaskbarOverlayAssets -IncludeLogo \$true -IncludeStatusAssets \$false'
|
||||
$taskbarScript | Should -Match 'Initialize-WinUtilTaskbarOverlayAssets -IncludeLogo \$false -IncludeStatusAssets \$true'
|
||||
}
|
||||
|
||||
It "records individual taskbar overlay render checkpoints" {
|
||||
$overlayScript = Get-Content -Path (Join-Path $script:repoRoot "functions\private\Initialize-WinUtilTaskbarOverlayAssets.ps1") -Raw
|
||||
|
||||
$overlayScript | Should -Match 'Taskbar logo asset rendered'
|
||||
$overlayScript | Should -Match 'Taskbar checkmark asset rendered'
|
||||
$overlayScript | Should -Match 'Taskbar warning asset rendered'
|
||||
}
|
||||
}
|
||||
@@ -71,7 +71,8 @@ Describe "Startup performance checkpoints" {
|
||||
$mainScript = Get-Content -Path (Join-Path $script:repoRoot "scripts\main.ps1") -Raw
|
||||
$lazyTabScript = Get-Content -Path (Join-Path $script:repoRoot "functions\private\Initialize-WinUtilTabContent.ps1") -Raw
|
||||
$runspaceScript = Get-Content -Path (Join-Path $script:repoRoot "functions\private\Initialize-WinUtilRunspacePool.ps1") -Raw
|
||||
$startupText = "$mainScript`n$lazyTabScript`n$runspaceScript"
|
||||
$overlayScript = Get-Content -Path (Join-Path $script:repoRoot "functions\private\Initialize-WinUtilTaskbarOverlayAssets.ps1") -Raw
|
||||
$startupText = "$mainScript`n$lazyTabScript`n$runspaceScript`n$overlayScript"
|
||||
|
||||
foreach ($checkpoint in @(
|
||||
"Runspace pool initialized",
|
||||
@@ -81,7 +82,7 @@ Describe "Startup performance checkpoints" {
|
||||
"Tweaks UI created",
|
||||
"Features UI created",
|
||||
"AppX UI created",
|
||||
"Assets rendered",
|
||||
"Taskbar logo asset rendered",
|
||||
"First content rendered"
|
||||
)) {
|
||||
$startupText | Should -Match ([regex]::Escape($checkpoint))
|
||||
|
||||
@@ -302,6 +302,7 @@ Describe "XAML and sync wiring" {
|
||||
"InitializedTabs",
|
||||
"PerformanceTrace",
|
||||
"PerformanceTraceEnabled",
|
||||
"RenderedAssetCache",
|
||||
"ToggleStatusCache",
|
||||
"InstallAppAreaBorder",
|
||||
"InstallAppAreaScrollViewer",
|
||||
|
||||
Reference in New Issue
Block a user