NavisworksTransport/UnitTests/Integration/AnimationPlaybackControlAutomationTests.cs
tian 8e5d9e845f feat: 集成测试补 T11-T15(P0+P1+P2 全部完成,24/24 通过)
- T11 路径编辑(PathEditingAutomationTests):删除点/更新位置/正交化/去环
- T12 路径导出(ExportImportRoundTripAutomationTests):XML/JSON 导出→导入回环
- T13 播放控制(AnimationPlaybackControlAutomationTests):pause 验证帧停止/resume 前进
- T14 批量队列(BatchQueueAutomationTests):队列添加/计数递增
- T15 路径分析(PathAnalysisAutomationTests):评分结构验证
- 服务端新增 5 端点:export-route-file/edit-route/animation-playback-control/batch-queue-add/analyze-path
- 产品 bug 修复:PathDatabase.CollisionResults 表已废弃→GetCollisionCount 改查 CollisionReports、
  SaveCollisions 异常保护;路径编辑真删点走 PathRoute.RemovePoint(RemovePathPoint 仅 3D 标记)

验证:集成测试 24/24 通过,完整集 74.6s(15fps/5s 动画)
2026-08-04 18:39:16 +08:00

75 lines
3.4 KiB
C#
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using System;
using System.Threading.Tasks;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Newtonsoft.Json.Linq;
namespace NavisworksTransport.UnitTests.Integration
{
/// <summary>
/// 动画播放控制集成测试(覆盖计划 T13
///
/// 验证 PathAnimationManager 播放链路完整:
/// - 播放开始playing 阶段帧前进)
/// - 暂停生效paused 阶段帧停止pauseVerified=true
/// - 恢复播放resumed 阶段帧继续前进)
/// - 播放完成finished 阶段状态 Finished
/// </summary>
[TestClass]
[TestCategory("NavisworksIntegration")]
public class AnimationPlaybackControlAutomationTests
{
private const int TestFrameRate = 15;
private const double TestDurationSeconds = 5.0;
[TestMethod]
[Timeout(240000)]
public async Task GroundVirtualObject_PlaybackControl_PauseResumeWork()
{
using (var client = new NavisworksTestAutomationClient())
{
await client.EnsureServiceReadyAsync(TimeSpan.FromSeconds(90)).ConfigureAwait(false);
JObject response = await client.AnimationPlaybackControlAsync(
"Ground",
180,
TestFrameRate,
TestDurationSeconds).ConfigureAwait(false);
Assert.IsTrue(response.Value<bool>("ok"), "播放控制序列失败: " + (string)response["error"]);
JObject data = (JObject)response["data"];
// 动画参数
Assert.IsTrue((int)data["totalFrames"] > 0, "总帧数应大于 0");
Assert.AreEqual("自动测试_Ground", (string)data["route"]["name"], "播放控制路径不匹配");
// 暂停验证:暂停期间帧数不变
Assert.IsTrue((bool)data["pauseVerified"], "暂停期间帧数仍在前进");
Assert.AreEqual((int)data["pausedFrame"], (int)data["frameAfterPause"], "暂停后帧数不应变化");
// 各阶段状态
JArray stages = (JArray)data["stages"];
Assert.IsNotNull(stages, "缺少 stages");
Assert.AreEqual(4, stages.Count, "阶段数应为 4playing/paused/resumed/finished");
Assert.AreEqual("playing", (string)stages[0]["stage"]);
Assert.AreEqual("paused", (string)stages[1]["stage"]);
Assert.AreEqual("resumed", (string)stages[2]["stage"]);
Assert.AreEqual("finished", (string)stages[3]["stage"]);
// 帧前进playing < paused < resumed < finished
int playingFrame = (int)stages[0]["frame"];
int pausedFrame = (int)stages[1]["frame"];
int resumedFrame = (int)stages[2]["frame"];
int finishedFrame = (int)stages[3]["frame"];
Assert.IsTrue(playingFrame > 0, "播放开始后帧数应大于 0");
Assert.IsTrue(pausedFrame > playingFrame, "暂停帧应晚于播放开始帧");
Assert.IsTrue(resumedFrame > pausedFrame, "恢复后帧数应前进");
Assert.IsTrue(finishedFrame >= resumedFrame, "完成帧不应早于恢复帧");
// 完成状态
Assert.AreEqual("Finished", (string)stages[3]["state"], "动画最终状态应为 Finished");
}
}
}
}