mirror of
https://github.com/babalae/better-genshin-impact.git
synced 2026-05-21 09:45:48 +08:00
截取物品图标独立任务 (#1856)
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
using GameTask.Model.GameUI;
|
||||
using BetterGenshinImpact.GameTask.Model.GameUI;
|
||||
using OpenCvSharp;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@@ -10,6 +10,43 @@ namespace BetterGenshinImpact.UnitTest.GameTaskTests.Model.GameUI
|
||||
{
|
||||
public class GridScreenTests
|
||||
{
|
||||
[Theory]
|
||||
[InlineData(@"AutoArtifactSalvage\ArtifactGrid.png", 4, 2)]
|
||||
[InlineData(@"GetGridIcons\WeaponGrid3.png", 32, 8)]
|
||||
/// <summary>
|
||||
/// 测试获取各种界面中的物品图标,结果应正确
|
||||
/// </summary>
|
||||
public void GetGridIcons_ShouldBeRight(string screenshot, int count, int columns)
|
||||
{
|
||||
//
|
||||
using Mat mat = new Mat(@$"..\..\..\Assets\{screenshot}");
|
||||
|
||||
//
|
||||
var result = GridScreen.GridEnumerator.GetGridItems(mat, columns);
|
||||
|
||||
//
|
||||
Assert.Equal(count, result.Count());
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(@"GetGridIcons\FoodGrid.png", 32, 8)]
|
||||
[InlineData(@"GetGridIcons\WeaponGrid.png", 4, 2)]
|
||||
[InlineData(@"GetGridIcons\WeaponGrid3.png", 32, 8)]
|
||||
/// <summary>
|
||||
/// 测试获取各种界面中的物品图标,使用复杂的cv算法,结果应正确
|
||||
/// </summary>
|
||||
public void GetGridIconsAlpha_ShouldBeRight(string screenshot, int count, int columns)
|
||||
{
|
||||
//
|
||||
using Mat mat = new Mat(@$"..\..\..\Assets\{screenshot}");
|
||||
|
||||
//
|
||||
var result = GridScreen.GridEnumerator.GetGridItems(mat, columns, findContoursAlpha: true);
|
||||
|
||||
//
|
||||
Assert.Equal(count, result.Count());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
/// <summary>
|
||||
/// 测试判断前后两张图是否属于滚动,结果应正确
|
||||
@@ -25,7 +62,7 @@ namespace BetterGenshinImpact.UnitTest.GameTaskTests.Model.GameUI
|
||||
cropped.CopyTo(pos);
|
||||
|
||||
//
|
||||
bool result1 = GridScreen.GridEnumerator.IsScrolling(mat, scrolled, out Point2d shift);
|
||||
bool result1 = GridScreen.GridEnumerator.IsScrolling(mat, scrolled, out Point2d shift, upperThreshold: 0.99);
|
||||
bool result2 = GridScreen.GridEnumerator.IsScrolling(mat, mat, out Point2d _);
|
||||
bool result3 = GridScreen.GridEnumerator.IsScrolling(mat, black, out Point2d _);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user