...
 
Commits (11)
......@@ -4,6 +4,7 @@ using System.Reflection;
using LibVLCSharp.Shared;
using NUnit.Framework;
[assembly: NonParallelizable]
namespace LibVLCSharp.Tests
{
public abstract class BaseSetup
......@@ -13,9 +14,11 @@ namespace LibVLCSharp.Tests
[SetUp]
public void SetUp()
{
Console.WriteLine(TestContext.CurrentContext.Test.FullName);
Core.Initialize();
_libVLC = new LibVLC("--no-audio", "--no-video");
_libVLC = new LibVLC("--no-audio", "--no-video", "--verbose=2");
}
protected string RealStreamMediaPath => "http://streams.videolan.org/streams/mp3/Owner-MPEG2.5.mp3";
......
......@@ -10,6 +10,8 @@ namespace LibVLCSharp.Tests
[Test]
public void LoadLibVLCFromSpecificPath()
{
System.Console.WriteLine(TestContext.CurrentContext.Test.FullName);
var dirPath = Path.GetDirectoryName(typeof(CoreLoadingTests).Assembly.Location);
var finalPath = Path.Combine(dirPath, "libvlc", "win-x86");
......@@ -20,6 +22,9 @@ namespace LibVLCSharp.Tests
[Test]
public void LoadLibVLCFromInferredPath()
{
System.Console.WriteLine(TestContext.CurrentContext.Test.FullName);
Assert.DoesNotThrow(() => Core.Initialize(), "fail to load libVLC dll at specified location");
var libVLC = new LibVLC("--no-audio", "--no-video");
}
......
......@@ -16,6 +16,9 @@ namespace LibVLCSharp.Tests
[Ignore("requires network calls that may fail when run from CI")]
public async Task PostLogin()
{
System.Console.WriteLine(TestContext.CurrentContext.Test.FullName);
var tcs = new TaskCompletionSource<bool>();
_libVLC.SetDialogHandlers((title, text) => Task.CompletedTask,
......@@ -47,6 +50,8 @@ namespace LibVLCSharp.Tests
[Ignore("requires network calls that may fail when run from CI")]
public async Task ShouldThrowIfPostLoginsTwice()
{
System.Console.WriteLine(TestContext.CurrentContext.Test.FullName);
var tcs = new TaskCompletionSource<bool>();
_libVLC.SetDialogHandlers((title, text) => Task.CompletedTask,
......
......@@ -10,6 +10,8 @@ namespace LibVLCSharp.Tests
[Test]
public void BasicNativeCallTest()
{
System.Console.WriteLine(TestContext.CurrentContext.Test.FullName);
var equalizer = new Equalizer();
equalizer.SetAmp(-1, 1);
Assert.AreEqual(-1, equalizer.Amp(1));
......@@ -18,6 +20,8 @@ namespace LibVLCSharp.Tests
[Test]
public void DisposeEqualizer()
{
System.Console.WriteLine(TestContext.CurrentContext.Test.FullName);
var equalizer = new Equalizer();
equalizer.SetAmp(-1, 1);
equalizer.Dispose();
......
......@@ -12,6 +12,8 @@ namespace LibVLCSharp.Tests
[Test]
public void MetaChangedEventSubscribe()
{
System.Console.WriteLine(TestContext.CurrentContext.Test.FullName);
var media = new Media(_libVLC, Path.GetTempFileName());
var eventHandlerCalled = false;
const MetadataType description = MetadataType.Description;
......@@ -26,6 +28,8 @@ namespace LibVLCSharp.Tests
public void DurationChanged()
{
System.Console.WriteLine(TestContext.CurrentContext.Test.FullName);
var media = new Media(_libVLC, RealMp3Path);
var called = false;
long duration = 0;
......@@ -45,6 +49,8 @@ namespace LibVLCSharp.Tests
[Test]
public void FreedMedia()
{
System.Console.WriteLine(TestContext.CurrentContext.Test.FullName);
var media = new Media(_libVLC, RealMp3Path);
var eventCalled = false;
media.MediaFreed += (sender, args) =>
......@@ -60,6 +66,8 @@ namespace LibVLCSharp.Tests
[Test]
public async Task OpeningStateChanged()
{
System.Console.WriteLine(TestContext.CurrentContext.Test.FullName);
var media = new Media(_libVLC, RealMp3Path);
var tcs = new TaskCompletionSource<bool>();
var openingCalled = false;
......
......@@ -17,6 +17,7 @@ namespace LibVLCSharp.Tests
const string LibVLCDeprecatedSymUrl = "https://raw.githubusercontent.com/videolan/vlc-3.0/master/include/vlc/deprecated.h";
[Test]
[Ignore("")]
public async Task CheckLibVLCCoverage()
{
string[] libvlc3Symbols;
......
......@@ -13,6 +13,7 @@
<PackageReference Include="NUnit" Version="3.11.0" />
<PackageReference Include="NUnit3TestAdapter" Version="3.12.0" />
<PackageReference Include="NUnitLite" Version="3.11.0" />
<PackageReference Include="VideoLAN.LibVLC.Mac" Version="3.1.2" />
<PackageReference Include="VideoLAN.LibVLC.Windows" Version="3.0.4" />
</ItemGroup>
<ItemGroup>
......
......@@ -14,6 +14,8 @@ namespace LibVLCSharp.Tests
[Test]
public void DisposeInstanceNativeRelease()
{
System.Console.WriteLine(TestContext.CurrentContext.Test.FullName);
_libVLC.Dispose();
Assert.AreEqual(IntPtr.Zero, _libVLC.NativeReference);
}
......@@ -21,12 +23,16 @@ namespace LibVLCSharp.Tests
[Test]
public void AddInterface()
{
System.Console.WriteLine(TestContext.CurrentContext.Test.FullName);
Assert.True(_libVLC.AddInterface(string.Empty));
}
[Test]
public void AudioFilters()
{
System.Console.WriteLine(TestContext.CurrentContext.Test.FullName);
var audioFilters = _libVLC.AudioFilters;
foreach (var filter in audioFilters)
{
......@@ -40,6 +46,8 @@ namespace LibVLCSharp.Tests
[Test]
public void VideoFilters()
{
System.Console.WriteLine(TestContext.CurrentContext.Test.FullName);
var videoFilters = _libVLC.VideoFilters;
foreach (var filter in videoFilters)
{
......@@ -52,6 +60,8 @@ namespace LibVLCSharp.Tests
[Test]
public void AudioOutputs()
{
System.Console.WriteLine(TestContext.CurrentContext.Test.FullName);
var audioOuputs = _libVLC.AudioOutputs;
foreach (var audioOutput in audioOuputs)
{
......@@ -61,8 +71,11 @@ namespace LibVLCSharp.Tests
}
[Test]
[Ignore("")]
public void AudioOutputDevices()
{
System.Console.WriteLine(TestContext.CurrentContext.Test.FullName);
var outputs = _libVLC.AudioOutputs;
var name = outputs.First(output => output.Name.Equals("mmdevice")).Name;
var audioOutputDevices = _libVLC.AudioOutputDevices(name);
......@@ -77,12 +90,16 @@ namespace LibVLCSharp.Tests
[Test]
public void EqualityTests()
{
System.Console.WriteLine(TestContext.CurrentContext.Test.FullName);
Assert.AreNotSame(new LibVLC("--no-audio"), new LibVLC("--no-audio"));
}
[Test]
public void Categories()
{
System.Console.WriteLine(TestContext.CurrentContext.Test.FullName);
var md1 = _libVLC.MediaDiscoverers(MediaDiscovererCategory.Devices);
var md2 = _libVLC.MediaDiscoverers(MediaDiscovererCategory.Lan);
var md3 = _libVLC.MediaDiscoverers(MediaDiscovererCategory.Localdirs);
......@@ -91,6 +108,8 @@ namespace LibVLCSharp.Tests
[Test]
public void SetExitHandler()
{
System.Console.WriteLine(TestContext.CurrentContext.Test.FullName);
var called = false;
var exitCb = new ExitCallback(() =>
......@@ -108,6 +127,8 @@ namespace LibVLCSharp.Tests
[Test]
public void SetLogFile()
{
System.Console.WriteLine(TestContext.CurrentContext.Test.FullName);
var path = Path.GetTempFileName();
_libVLC.SetLogFile(path);
_libVLC.CloseLogFile();
......@@ -118,6 +139,8 @@ namespace LibVLCSharp.Tests
[Test]
public void DisposeLibVLC()
{
System.Console.WriteLine(TestContext.CurrentContext.Test.FullName);
_libVLC.SetDialogHandlers((title, text) => Task.CompletedTask,
(dialog, title, text, defaultUsername, askStore, token) => Task.CompletedTask,
(dialog, title, text, type, cancelText, firstActionText, secondActonText, token) => Task.CompletedTask,
......@@ -135,12 +158,16 @@ namespace LibVLCSharp.Tests
[Test]
public void LibVLCVersion()
{
System.Console.WriteLine(TestContext.CurrentContext.Test.FullName);
Assert.True(_libVLC.Version.StartsWith("3"));
}
[Test]
public void LibVLCChangeset()
{
System.Console.WriteLine(TestContext.CurrentContext.Test.FullName);
Assert.IsNotNull(_libVLC.Changeset);
}
}
......
......@@ -13,6 +13,8 @@ namespace LibVLCSharp.Tests
[Test]
public void CreateStartAndStopDiscoverer()
{
System.Console.WriteLine(TestContext.CurrentContext.Test.FullName);
var mds = _libVLC.MediaDiscoverers(MediaDiscovererCategory.Lan);
var md = new MediaDiscoverer(_libVLC, mds.First().Name);
Assert.True(md.Start());
......@@ -24,6 +26,8 @@ namespace LibVLCSharp.Tests
[Test]
public async Task DisposeMediaDiscoverer()
{
System.Console.WriteLine(TestContext.CurrentContext.Test.FullName);
var mds = _libVLC.MediaDiscoverers(MediaDiscovererCategory.Lan);
var md = new MediaDiscoverer(_libVLC, mds.First().Name);
Assert.True(md.Start());
......
......@@ -11,6 +11,8 @@ namespace LibVLCSharp.Tests
[Test]
public void AddAndRemoveMediaFromMediaList()
{
System.Console.WriteLine(TestContext.CurrentContext.Test.FullName);
var mediaList = new MediaList(_libVLC);
var media = new Media(_libVLC, Path.GetTempFileName());
var itemAdded = false;
......@@ -30,6 +32,8 @@ namespace LibVLCSharp.Tests
[Test]
public void DisposeMediaList()
{
System.Console.WriteLine(TestContext.CurrentContext.Test.FullName);
var mediaList = new MediaList(_libVLC);
mediaList.Dispose();
Assert.AreEqual(IntPtr.Zero, mediaList.NativeReference);
......
......@@ -15,6 +15,8 @@ namespace LibVLCSharp.Tests
[Test]
public void CreateAndDestroy()
{
System.Console.WriteLine(TestContext.CurrentContext.Test.FullName);
var mp = new MediaPlayer(_libVLC);
mp.Dispose();
Assert.AreEqual(IntPtr.Zero, mp.NativeReference);
......@@ -23,6 +25,8 @@ namespace LibVLCSharp.Tests
[Test]
public void OutputDeviceEnum()
{
System.Console.WriteLine(TestContext.CurrentContext.Test.FullName);
var mp = new MediaPlayer(_libVLC);
var t = mp.AudioOutputDeviceEnum;
Debug.WriteLine(t);
......@@ -31,6 +35,8 @@ namespace LibVLCSharp.Tests
[Test]
public async Task TrackDescription()
{
System.Console.WriteLine(TestContext.CurrentContext.Test.FullName);
var mp = new MediaPlayer(_libVLC);
var media = new Media(_libVLC, "http://www.quirksmode.org/html5/videos/big_buck_bunny.mp4", FromType.FromLocation);
var tcs = new TaskCompletionSource<bool>();
......@@ -51,6 +57,8 @@ namespace LibVLCSharp.Tests
[Test]
public async Task Play()
{
System.Console.WriteLine(TestContext.CurrentContext.Test.FullName);
var media = new Media(_libVLC, "http://www.quirksmode.org/html5/videos/big_buck_bunny.mp4", FromType.FromLocation);
var mp = new MediaPlayer(media);
var called = false;
......@@ -68,6 +76,7 @@ namespace LibVLCSharp.Tests
int callCountRegisterTwo = 0;
[Test]
[Ignore("")]
public async Task EventFireOnceForeachRegistration()
{
try
......@@ -145,6 +154,8 @@ namespace LibVLCSharp.Tests
[Test]
public async Task DisposeMediaPlayer()
{
System.Console.WriteLine(TestContext.CurrentContext.Test.FullName);
var mp = new MediaPlayer(_libVLC);
mp.Play(new Media(_libVLC, "http://www.quirksmode.org/html5/videos/big_buck_bunny.mp4", FromType.FromLocation));
......@@ -159,6 +170,8 @@ namespace LibVLCSharp.Tests
[Test]
public async Task UpdateViewpoint()
{
System.Console.WriteLine(TestContext.CurrentContext.Test.FullName);
var mp = new MediaPlayer(_libVLC);
mp.Play(new Media(_libVLC, "https://streams.videolan.org/streams/360/eagle_360.mp4", FromType.FromLocation));
......@@ -177,15 +190,21 @@ namespace LibVLCSharp.Tests
}
[Test]
[Ignore("")]
public void GetMediaPlayerRole()
{
System.Console.WriteLine(TestContext.CurrentContext.Test.FullName);
var mp = new MediaPlayer(_libVLC);
Assert.AreEqual(MediaPlayerRole.None, mp.Role);
}
[Test]
[Ignore("")]
public void SetMediaPlayerRole()
{
System.Console.WriteLine(TestContext.CurrentContext.Test.FullName);
var mp = new MediaPlayer(_libVLC);
Assert.AreEqual(MediaPlayerRole.None, mp.Role);
......
......@@ -9,11 +9,14 @@ using NUnit.Framework;
namespace LibVLCSharp.Tests
{
[TestFixture]
[Ignore("media tests cause lots of freeze, lets try without")]
public class MediaTests : BaseSetup
{
[Test]
public void CreateMedia()
{
System.Console.WriteLine(TestContext.CurrentContext.Test.FullName);
var media = new Media(_libVLC, Path.GetTempFileName());
Assert.AreNotEqual(IntPtr.Zero, media.NativeReference);
......@@ -22,13 +25,18 @@ namespace LibVLCSharp.Tests
[Test]
public void CreateMediaFail()
{
System.Console.WriteLine(TestContext.CurrentContext.Test.FullName);
Assert.Throws<ArgumentNullException>(() => new Media(null, Path.GetTempFileName()));
Assert.Throws<ArgumentNullException>(() => new Media(_libVLC, string.Empty));
}
[Test]
[Ignore("freeze ci")]
public void ReleaseMedia()
{
System.Console.WriteLine(TestContext.CurrentContext.Test.FullName);
var media = new Media(_libVLC, Path.GetTempFileName());
media.Dispose();
......@@ -39,6 +47,8 @@ namespace LibVLCSharp.Tests
[Test]
public void CreateMediaFromStream()
{
System.Console.WriteLine(TestContext.CurrentContext.Test.FullName);
var media = new Media(_libVLC, new FileStream(Path.GetTempFileName(), FileMode.OpenOrCreate));
Assert.AreNotEqual(IntPtr.Zero, media.NativeReference);
}
......@@ -46,6 +56,8 @@ namespace LibVLCSharp.Tests
[Test]
public void AddOption()
{
System.Console.WriteLine(TestContext.CurrentContext.Test.FullName);
var media = new Media(_libVLC, new FileStream(Path.GetTempFileName(), FileMode.OpenOrCreate));
media.AddOption("-sout-all");
}
......@@ -53,6 +65,8 @@ namespace LibVLCSharp.Tests
[Test]
public async Task CreateRealMedia()
{
System.Console.WriteLine(TestContext.CurrentContext.Test.FullName);
using (var media = new Media(_libVLC, RealStreamMediaPath, FromType.FromLocation))
{
Assert.NotZero(media.Duration);
......@@ -69,6 +83,8 @@ namespace LibVLCSharp.Tests
[Test]
public void Duplicate()
{
System.Console.WriteLine(TestContext.CurrentContext.Test.FullName);
var media = new Media(_libVLC, new FileStream(Path.GetTempFileName(), FileMode.OpenOrCreate));
var duplicate = media.Duplicate();
Assert.AreNotEqual(duplicate.NativeReference, media.NativeReference);
......@@ -77,13 +93,18 @@ namespace LibVLCSharp.Tests
[Test]
public void CreateMediaFromFileStream()
{
System.Console.WriteLine(TestContext.CurrentContext.Test.FullName);
var media = new Media(_libVLC, new FileStream(RealMp3Path, FileMode.Open, FileAccess.Read, FileShare.Read));
Assert.AreNotEqual(IntPtr.Zero, media.NativeReference);
}
[Test]
[Ignore("freeze CI")]
public void SetMetadata()
{
System.Console.WriteLine(TestContext.CurrentContext.Test.FullName);
var media = new Media(_libVLC, Path.GetTempFileName());
const string test = "test";
media.SetMeta(MetadataType.ShowName, test);
......@@ -94,6 +115,8 @@ namespace LibVLCSharp.Tests
[Test]
public async Task GetTracks()
{
System.Console.WriteLine(TestContext.CurrentContext.Test.FullName);
var media = new Media(_libVLC, RealMp3Path);
await media.Parse();
Assert.AreEqual(media.Tracks.Single().Data.Audio.Channels, 2);
......@@ -103,6 +126,8 @@ namespace LibVLCSharp.Tests
[Test]
public async Task CreateRealMediaSpecialCharacters()
{
System.Console.WriteLine(TestContext.CurrentContext.Test.FullName);
using (var media = new Media(_libVLC, RealMp3PathSpecialCharacter, FromType.FromPath))
{
Assert.False(media.IsParsed);
......@@ -121,9 +146,13 @@ namespace LibVLCSharp.Tests
}
[Test]
[Ignore("")]
public async Task CreateMediaFromStreamMultiplePlay()
{
using(var mp = new MediaPlayer(_libVLC))
System.Console.WriteLine(TestContext.CurrentContext.Test.FullName);
using (var mp = new MediaPlayer(_libVLC))
{
var media = new Media(_libVLC, await GetStreamFromUrl("http://www.quirksmode.org/html5/videos/big_buck_bunny.mp4"));
mp.Play(media);
......@@ -141,6 +170,8 @@ namespace LibVLCSharp.Tests
[Test]
public async Task CreateMultipleMediaFromStreamPlay()
{
System.Console.WriteLine(TestContext.CurrentContext.Test.FullName);
var libVLC1 = new LibVLC("--no-audio", "--no-video");
var libVLC2 = new LibVLC("--no-audio", "--no-video");
......@@ -154,16 +185,22 @@ namespace LibVLCSharp.Tests
}
[Test]
[Ignore("freeze")]
public void ParseShouldThrowIfCancelledOperation()
{
System.Console.WriteLine(TestContext.CurrentContext.Test.FullName);
var media = new Media(_libVLC, RealMp3Path);
var cancellationToken = new CancellationToken(canceled: true);
Assert.ThrowsAsync<TaskCanceledException>(async () => await media.Parse(cancellationToken: cancellationToken));
}
[Test]
[Ignore("freeze")]
public async Task ParseShouldTimeoutWith1MillisecondLimit()
{
System.Console.WriteLine(TestContext.CurrentContext.Test.FullName);
var media = new Media(_libVLC, RealMp3Path);
var parseResult = await media.Parse(timeout: 1);
Assert.AreEqual(MediaParsedStatus.Timeout, parseResult);
......@@ -172,6 +209,8 @@ namespace LibVLCSharp.Tests
[Test]
public async Task ParseShouldSucceed()
{
System.Console.WriteLine(TestContext.CurrentContext.Test.FullName);
var media = new Media(_libVLC, RealMp3Path);
var parseResult = await media.Parse();
Assert.AreEqual(MediaParsedStatus.Done, parseResult);
......@@ -180,6 +219,8 @@ namespace LibVLCSharp.Tests
[Test]
public async Task ParseShouldFailIfNotMediaFile()
{
System.Console.WriteLine(TestContext.CurrentContext.Test.FullName);
var media = new Media(_libVLC, Path.GetTempFileName());
var parseResult = await media.Parse();
Assert.AreEqual(MediaParsedStatus.Failed, parseResult);
......@@ -188,6 +229,8 @@ namespace LibVLCSharp.Tests
[Test]
public async Task ParseShouldBeSkippedIfLocalParseSpecifiedAndRemoteUrlProvided()
{
System.Console.WriteLine(TestContext.CurrentContext.Test.FullName);
var media = new Media(_libVLC, RealStreamMediaPath, FromType.FromLocation);
var parseResult = await media.Parse(MediaParseOptions.ParseLocal);
Assert.AreEqual(MediaParsedStatus.Skipped, parseResult);
......@@ -195,6 +238,8 @@ namespace LibVLCSharp.Tests
private async Task<Stream> GetStreamFromUrl(string url)
{
System.Console.WriteLine(TestContext.CurrentContext.Test.FullName);
byte[] imageData = null;
using (var client = new System.Net.Http.HttpClient())
......
......@@ -17,6 +17,8 @@ namespace LibVLCSharp.Tests
[Test]
public async Task DiscoverItems()
{
System.Console.WriteLine(TestContext.CurrentContext.Test.FullName);
Core.Initialize();
var mp = new MediaPlayer(_libVLC)
......@@ -61,6 +63,8 @@ namespace LibVLCSharp.Tests
[Test]
public void DisposeRendererDiscoverer()
{
System.Console.WriteLine(TestContext.CurrentContext.Test.FullName);
var rendererDiscoverer = new RendererDiscoverer(_libVLC, _libVLC.RendererList.LastOrDefault().Name);
rendererDiscoverer.Start();
rendererDiscoverer.Dispose();
......