213 lines
8.3 KiB
C#
213 lines
8.3 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using Paca.Mobile.Core;
|
|
using Xunit;
|
|
|
|
namespace Paca.Tests.Mobile;
|
|
|
|
/// <summary>
|
|
/// 모바일 프로덕션 7대 핵심 기능 게이트 (Gate 87 ~ Gate 92)
|
|
/// </summary>
|
|
public class MobileCoreFeaturesGateTests
|
|
{
|
|
[Fact]
|
|
public void Gate87_MobileDiscoveryEngine_UrlParsing_And_PlatformDetection_Audit()
|
|
{
|
|
// YouTube, Vimeo, Twitter, 일반 미디어 감지
|
|
var yt = MobileDiscoveryEngine.DetectPlatform("https://www.youtube.com/watch?v=dQw4w9WgXcQ");
|
|
Assert.Equal("YouTube", yt.PlatformName);
|
|
Assert.True(yt.IsSupported);
|
|
|
|
var vm = MobileDiscoveryEngine.DetectPlatform("https://vimeo.com/12345678");
|
|
Assert.Equal("Vimeo", vm.PlatformName);
|
|
Assert.True(vm.IsSupported);
|
|
|
|
var general = MobileDiscoveryEngine.DetectPlatform("https://example.com/video.m3u8");
|
|
Assert.Equal("HLS Stream", general.PlatformName);
|
|
Assert.True(general.IsSupported);
|
|
|
|
var unknown = MobileDiscoveryEngine.DetectPlatform("https://not-a-video.org/page.html");
|
|
Assert.Equal("Web Page", unknown.PlatformName);
|
|
}
|
|
|
|
[Fact]
|
|
public void Gate88_MobileQueueManager_Control_And_Retry_Audit()
|
|
{
|
|
var qm = new MobileQueueManager();
|
|
var item1 = qm.Enqueue("https://example.com/v1.mp4", "Video 1");
|
|
var item2 = qm.Enqueue("https://example.com/v2.mp4", "Video 2");
|
|
|
|
Assert.Equal(2, qm.Items.Count);
|
|
|
|
// 일시정지 & 재개
|
|
qm.Pause(item1.Id);
|
|
Assert.Equal(MobileQueueStatus.Paused, item1.Status);
|
|
qm.Resume(item1.Id);
|
|
Assert.Equal(MobileQueueStatus.Downloading, item1.Status);
|
|
|
|
// 상단 고정 (Pin)
|
|
qm.Pin(item2.Id);
|
|
Assert.True(item2.IsPinned);
|
|
|
|
// 실패 상태 설정 후 일괄 재시도 검증
|
|
item1.Status = MobileQueueStatus.Failed;
|
|
var retriedCount = qm.RetryFailedItems();
|
|
Assert.Equal(1, retriedCount);
|
|
Assert.Equal(MobileQueueStatus.Queued, item1.Status);
|
|
|
|
// 완료 항목 정리
|
|
item2.Status = MobileQueueStatus.Completed;
|
|
qm.ClearCompleted();
|
|
Assert.Single(qm.Items);
|
|
}
|
|
|
|
[Fact]
|
|
public void Gate89_MobileFavoritesManager_Stash_And_Tagging_Audit()
|
|
{
|
|
var fm = new MobileFavoritesManager();
|
|
var fav = fm.AddFavorite("https://example.com/movie.mp4", "Great Movie", "영화");
|
|
|
|
Assert.Single(fm.Favorites);
|
|
Assert.Equal("영화", fav.Tag);
|
|
Assert.False(fav.IsStashedForDownload);
|
|
|
|
// Stash(나중에 다운로드) 토글
|
|
fm.ToggleStash(fav.Id);
|
|
Assert.True(fav.IsStashedForDownload);
|
|
|
|
// 태그 검색 필터
|
|
var filtered = fm.GetByTag("영화");
|
|
Assert.Single(filtered);
|
|
}
|
|
|
|
[Fact]
|
|
public void Gate90_MobileTabSyncEngine_RemoteTabSync_Audit()
|
|
{
|
|
var sync = new MobileTabSyncEngine();
|
|
Assert.Empty(sync.RemoteTabs);
|
|
|
|
// PC 브라우저 탭 목록 동기화
|
|
var remoteTabs = new List<RemoteTabInfo>
|
|
{
|
|
new("tab-1", "GitHub Paca Repo", "https://github.com/test/paca"),
|
|
new("tab-2", "YouTube Video Stream", "https://youtube.com/watch?v=123")
|
|
};
|
|
sync.UpdateRemoteTabs(remoteTabs);
|
|
|
|
Assert.Equal(2, sync.RemoteTabs.Count);
|
|
Assert.Equal("GitHub Paca Repo", sync.RemoteTabs[0].Title);
|
|
|
|
// 모바일에서 원격 다운로드 요청 이벤트 트리거
|
|
string? requestedUrl = null;
|
|
sync.OnRemoteDownloadRequested += url => requestedUrl = url;
|
|
sync.RequestRemoteDownload("tab-2");
|
|
|
|
Assert.Equal("https://youtube.com/watch?v=123", requestedUrl);
|
|
}
|
|
|
|
[Fact]
|
|
public void Gate91_MobileSettingsManager_Preferences_Audit()
|
|
{
|
|
var settings = new MobileSettingsManager();
|
|
Assert.True(settings.AutoRetryOnReconnect);
|
|
Assert.False(settings.WifiOnlyDownload);
|
|
Assert.Equal(0, settings.SpeedLimitKbps);
|
|
Assert.Equal(MobileThemeMode.Dark, settings.ThemeMode);
|
|
|
|
settings.WifiOnlyDownload = true;
|
|
settings.SpeedLimitKbps = 2048;
|
|
settings.ThemeMode = MobileThemeMode.Light;
|
|
|
|
Assert.True(settings.WifiOnlyDownload);
|
|
Assert.Equal(2048, settings.SpeedLimitKbps);
|
|
Assert.Equal(MobileThemeMode.Light, settings.ThemeMode);
|
|
}
|
|
|
|
[Fact]
|
|
public void Gate92_MobileNetworkGuard_AutoResume_Audit()
|
|
{
|
|
var qm = new MobileQueueManager();
|
|
var guard = new MobileNetworkGuard(qm);
|
|
|
|
var item = qm.Enqueue("https://example.com/video.mp4", "Test Video");
|
|
item.Status = MobileQueueStatus.PausedNetwork;
|
|
|
|
// 네트워크 복구 이벤트 발생
|
|
guard.OnNetworkRestored(isWifi: true);
|
|
|
|
// 네트워크 단절로 멈췄던 항목이 자동으로 재개되어야 함
|
|
Assert.Equal(MobileQueueStatus.Downloading, item.Status);
|
|
}
|
|
|
|
[Fact]
|
|
public void Gate169_MobileDiscoveryEngine_ExpandedPlatforms_Audit()
|
|
{
|
|
// 모바일 8대 스피드 다이얼 및 주요 스트리밍 플랫폼 확장 감지 감사
|
|
var chzzk = MobileDiscoveryEngine.DetectPlatform("https://chzzk.naver.com/live/12345");
|
|
Assert.Equal("CHZZK", chzzk.PlatformName);
|
|
Assert.True(chzzk.IsSupported);
|
|
|
|
var soop = MobileDiscoveryEngine.DetectPlatform("https://m.sooplive.co.kr/play/abcdef");
|
|
Assert.Equal("SOOP", soop.PlatformName);
|
|
Assert.True(soop.IsSupported);
|
|
|
|
var afreeca = MobileDiscoveryEngine.DetectPlatform("https://play.afreecatv.com/streamer/999");
|
|
Assert.Equal("SOOP", afreeca.PlatformName);
|
|
Assert.True(afreeca.IsSupported);
|
|
|
|
var twitch = MobileDiscoveryEngine.DetectPlatform("https://m.twitch.tv/streamer");
|
|
Assert.Equal("Twitch", twitch.PlatformName);
|
|
Assert.True(twitch.IsSupported);
|
|
|
|
var instagram = MobileDiscoveryEngine.DetectPlatform("https://www.instagram.com/reel/C12345/");
|
|
Assert.Equal("Instagram", instagram.PlatformName);
|
|
Assert.True(instagram.IsSupported);
|
|
|
|
var tiktok = MobileDiscoveryEngine.DetectPlatform("https://www.tiktok.com/@user/video/1234567");
|
|
Assert.Equal("TikTok", tiktok.PlatformName);
|
|
Assert.True(tiktok.IsSupported);
|
|
|
|
var tiktokShort = MobileDiscoveryEngine.DetectPlatform("https://vt.tiktok.com/ZS12345/");
|
|
Assert.Equal("TikTok", tiktokShort.PlatformName);
|
|
Assert.True(tiktokShort.IsSupported);
|
|
|
|
var reddit = MobileDiscoveryEngine.DetectPlatform("https://www.reddit.com/r/funny/comments/xyz/clip/");
|
|
Assert.Equal("Reddit", reddit.PlatformName);
|
|
Assert.True(reddit.IsSupported);
|
|
|
|
var vreddit = MobileDiscoveryEngine.DetectPlatform("https://v.redd.it/abcdef123");
|
|
Assert.Equal("Reddit", vreddit.PlatformName);
|
|
Assert.True(vreddit.IsSupported);
|
|
|
|
var naverTv = MobileDiscoveryEngine.DetectPlatform("https://tv.naver.com/v/123456");
|
|
Assert.Equal("Naver TV", naverTv.PlatformName);
|
|
Assert.True(naverTv.IsSupported);
|
|
}
|
|
|
|
[Fact]
|
|
public void Gate170_MobileDiscoveryEngine_DirectMedia_QueryString_And_Extensions_Audit()
|
|
{
|
|
// 쿼리 스트링, 프래그먼트, 추가 확장자(.mkv 등) 포함 미디어 감지 감사
|
|
var mp4WithQuery = MobileDiscoveryEngine.DetectPlatform("https://cdn.example.com/stream.mp4?token=abc123&expire=9999");
|
|
Assert.Equal("Direct Media", mp4WithQuery.PlatformName);
|
|
Assert.True(mp4WithQuery.IsSupported);
|
|
|
|
var webmWithFragment = MobileDiscoveryEngine.DetectPlatform("https://cdn.example.com/clip.webm?key=val#t=10");
|
|
Assert.Equal("Direct Media", webmWithFragment.PlatformName);
|
|
Assert.True(webmWithFragment.IsSupported);
|
|
|
|
var mkvMedia = MobileDiscoveryEngine.DetectPlatform("https://cdn.example.com/movie.mkv");
|
|
Assert.Equal("Direct Media", mkvMedia.PlatformName);
|
|
Assert.True(mkvMedia.IsSupported);
|
|
|
|
var hlsWithAuth = MobileDiscoveryEngine.DetectPlatform("https://cdn.example.com/playlist.m3u8?auth=token123");
|
|
Assert.Equal("HLS Stream", hlsWithAuth.PlatformName);
|
|
Assert.True(hlsWithAuth.IsSupported);
|
|
|
|
var dashWithSession = MobileDiscoveryEngine.DetectPlatform("https://cdn.example.com/manifest.mpd?session=xyz");
|
|
Assert.Equal("DASH Stream", dashWithSession.PlatformName);
|
|
Assert.True(dashWithSession.IsSupported);
|
|
}
|
|
}
|
|
|