feat(ads/seo/release): v1.2.0 with live Google Ads, isolated ad profile, ads.txt, and SEO/AEO/GEO optimization
This commit is contained in:
parent
a88aafa1e5
commit
0e568f1f0a
975 changed files with 130593 additions and 16783 deletions
82
tests/Paca.Tests/App/AppDebugScreenshotServiceTests.cs
Normal file
82
tests/Paca.Tests/App/AppDebugScreenshotServiceTests.cs
Normal file
|
|
@ -0,0 +1,82 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using System.Threading;
|
||||
using System.Windows;
|
||||
using Paca.App.Core;
|
||||
using Paca.App.Services;
|
||||
using Paca.Tests.Infrastructure;
|
||||
using Xunit;
|
||||
|
||||
namespace Paca.Tests.App;
|
||||
|
||||
public class AppDebugScreenshotServiceTests
|
||||
{
|
||||
[Fact]
|
||||
public void AppDebugScreenshotService_GetDefaultScreenshotPath_ReturnsValidPngPath()
|
||||
{
|
||||
var path = AppDebugScreenshotService.GetDefaultScreenshotPath();
|
||||
Assert.False(string.IsNullOrWhiteSpace(path));
|
||||
Assert.EndsWith(".png", path, StringComparison.OrdinalIgnoreCase);
|
||||
Assert.Contains(AppPaths.DataDir, path, StringComparison.OrdinalIgnoreCase);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void AppDebugScreenshotService_CaptureWindow_STA_GeneratesValidPngFile()
|
||||
{
|
||||
using var sta = StaDispatcher.Start();
|
||||
WpfTestApp.Ensure(sta.Dispatcher);
|
||||
|
||||
var tempOut = Path.Combine(Path.GetTempPath(), $"paca_test_shot_{Guid.NewGuid():N}.png");
|
||||
try
|
||||
{
|
||||
var result = sta.Invoke(() =>
|
||||
{
|
||||
var window = new Window
|
||||
{
|
||||
Width = 300,
|
||||
Height = 200,
|
||||
Title = "TestCaptureWindow"
|
||||
};
|
||||
window.Show();
|
||||
|
||||
var ok = AppDebugScreenshotService.CaptureWindow(window, tempOut);
|
||||
window.Close();
|
||||
return ok;
|
||||
});
|
||||
|
||||
Assert.True(result, "CaptureWindow should return true for a valid window.");
|
||||
Assert.True(File.Exists(tempOut), "Screenshot file must exist.");
|
||||
var fi = new FileInfo(tempOut);
|
||||
Assert.True(fi.Length > 0, "Screenshot file must not be empty.");
|
||||
|
||||
// PNG magic byte verification: 0x89, 'P', 'N', 'G'
|
||||
var header = new byte[8];
|
||||
using (var fs = File.OpenRead(tempOut))
|
||||
{
|
||||
fs.Read(header, 0, 8);
|
||||
}
|
||||
Assert.Equal(0x89, header[0]);
|
||||
Assert.Equal((byte)'P', header[1]);
|
||||
Assert.Equal((byte)'N', header[2]);
|
||||
Assert.Equal((byte)'G', header[3]);
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (File.Exists(tempOut))
|
||||
{
|
||||
try { File.Delete(tempOut); } catch { }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void AppDebugScreenshotService_ProcessTriggerContent_ParsesTargetPath()
|
||||
{
|
||||
var customPath = @"C:\dummy\target.png";
|
||||
var resolved = AppDebugScreenshotService.ResolveTriggerPath(customPath);
|
||||
Assert.Equal(customPath, resolved);
|
||||
|
||||
var emptyResolved = AppDebugScreenshotService.ResolveTriggerPath("");
|
||||
Assert.Equal(AppDebugScreenshotService.GetDefaultScreenshotPath(), emptyResolved);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue