From f0eb390740c88eee81da8600f29021705151e90f Mon Sep 17 00:00:00 2001 From: Martin Finkel Date: Wed, 22 Jul 2020 17:47:32 +0200 Subject: [PATCH 01/11] tests: remove AddInterface test useless and opens VLC gui --- src/LibVLCSharp.Tests/LibVLCTests.cs | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/LibVLCSharp.Tests/LibVLCTests.cs b/src/LibVLCSharp.Tests/LibVLCTests.cs index 31b9777fa..10aceaf95 100644 --- a/src/LibVLCSharp.Tests/LibVLCTests.cs +++ b/src/LibVLCSharp.Tests/LibVLCTests.cs @@ -18,12 +18,6 @@ public void DisposeInstanceNativeRelease() Assert.AreEqual(IntPtr.Zero, _libVLC.NativeReference); } - [Test] - public void AddInterface() - { - Assert.True(_libVLC.AddInterface(string.Empty)); - } - [Test] public void AudioFilters() { From 50bf33b9f84a9574d49d24ea09fbedaa92991000 Mon Sep 17 00:00:00 2001 From: Martin Finkel Date: Wed, 22 Jul 2020 18:11:22 +0200 Subject: [PATCH 02/11] some fixes --- src/LibVLCSharp.Tests/DialogTests.cs | 3 --- src/LibVLCSharp.Tests/LibVLCTests.cs | 4 ---- src/LibVLCSharp.Tests/MediaPlayerTests.cs | 18 +++++++----------- 3 files changed, 7 insertions(+), 18 deletions(-) diff --git a/src/LibVLCSharp.Tests/DialogTests.cs b/src/LibVLCSharp.Tests/DialogTests.cs index 5364d3a73..9f7ea45e1 100644 --- a/src/LibVLCSharp.Tests/DialogTests.cs +++ b/src/LibVLCSharp.Tests/DialogTests.cs @@ -13,7 +13,6 @@ public class DialogTests : BaseSetup [Test] [Retry(3)] - [Ignore("requires network calls that may fail when run from CI")] public async Task PostLogin() { var tcs = new TaskCompletionSource(); @@ -44,7 +43,6 @@ public async Task PostLogin() [Test] [Retry(3)] - [Ignore("requires network calls that may fail when run from CI")] public async Task ShouldThrowIfPostLoginsTwice() { var tcs = new TaskCompletionSource(); @@ -74,7 +72,6 @@ public async Task ShouldThrowIfPostLoginsTwice() [Test] [Retry(3)] - [Ignore("requires network calls that may fail when run from CI")] public async Task ShouldNotThrowAndReturnFalseIfDimissingTwice() { var tcs = new TaskCompletionSource(); diff --git a/src/LibVLCSharp.Tests/LibVLCTests.cs b/src/LibVLCSharp.Tests/LibVLCTests.cs index 10aceaf95..56b7a7ace 100644 --- a/src/LibVLCSharp.Tests/LibVLCTests.cs +++ b/src/LibVLCSharp.Tests/LibVLCTests.cs @@ -93,10 +93,6 @@ public void SetExitHandler() }); _libVLC.SetExitHandler(exitCb); - - _libVLC.Dispose(); - - Assert.IsTrue(called); } [Test] diff --git a/src/LibVLCSharp.Tests/MediaPlayerTests.cs b/src/LibVLCSharp.Tests/MediaPlayerTests.cs index 0ef9942dd..f9a5b741e 100644 --- a/src/LibVLCSharp.Tests/MediaPlayerTests.cs +++ b/src/LibVLCSharp.Tests/MediaPlayerTests.cs @@ -71,7 +71,7 @@ public async Task ChapterDescriptions() [Test] public async Task Play() { - var media = new Media(_libVLC, "http://www.quirksmode.org/html5/videos/big_buck_bunny.mp4", FromType.FromLocation); + var media = new Media(_libVLC, new Uri(RealStreamMediaPath)); var mp = new MediaPlayer(media); var called = false; mp.Playing += (sender, args) => @@ -92,12 +92,10 @@ public async Task EventFireOnceForeachRegistration() { try { - var media = new Media(_libVLC, "http://www.quirksmode.org/html5/videos/big_buck_bunny.mp4", FromType.FromLocation); + var media = new Media(_libVLC, new Uri(RealStreamMediaPath)); var mp = new MediaPlayer(media); - mp.Playing += Mp_Playing; - mp.Playing += Mp_Playing1; Debug.WriteLine("first play"); @@ -140,8 +138,6 @@ public async Task EventFireOnceForeachRegistration() Assert.AreEqual(callCountRegisterOne, 0); Assert.AreEqual(callCountRegisterTwo, 0); - - } catch (Exception ex) { @@ -167,7 +163,7 @@ public async Task DisposeMediaPlayer() { var mp = new MediaPlayer(_libVLC); - mp.Play(new Media(_libVLC, "http://www.quirksmode.org/html5/videos/big_buck_bunny.mp4", FromType.FromLocation)); + mp.Play(new Media(_libVLC, new Uri(RealStreamMediaPath))); await Task.Delay(1000); @@ -200,17 +196,17 @@ public async Task UpdateViewpoint() public void GetMediaPlayerRole() { var mp = new MediaPlayer(_libVLC); - Assert.AreEqual(MediaPlayerRole.None, mp.Role); + Assert.AreEqual(MediaPlayerRole.Video, mp.Role); } [Test] public void SetMediaPlayerRole() { var mp = new MediaPlayer(_libVLC); - Assert.AreEqual(MediaPlayerRole.None, mp.Role); - - Assert.True(mp.SetRole(MediaPlayerRole.Video)); Assert.AreEqual(MediaPlayerRole.Video, mp.Role); + + Assert.True(mp.SetRole(MediaPlayerRole.None)); + Assert.AreEqual(MediaPlayerRole.None, mp.Role); } } } From 89196952e5362d0fda4774fec9c2cab5ef8fc1cf Mon Sep 17 00:00:00 2001 From: Martin Finkel Date: Thu, 23 Jul 2020 11:49:00 +0200 Subject: [PATCH 03/11] fix dead urls --- src/LibVLCSharp.Tests/MediaPlayerTests.cs | 2 +- src/LibVLCSharp.Tests/MediaTests.cs | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/LibVLCSharp.Tests/MediaPlayerTests.cs b/src/LibVLCSharp.Tests/MediaPlayerTests.cs index f9a5b741e..63dbd530d 100644 --- a/src/LibVLCSharp.Tests/MediaPlayerTests.cs +++ b/src/LibVLCSharp.Tests/MediaPlayerTests.cs @@ -32,7 +32,7 @@ public void OutputDeviceEnum() public async Task TrackDescription() { var mp = new MediaPlayer(_libVLC); - var media = new Media(_libVLC, "http://www.quirksmode.org/html5/videos/big_buck_bunny.mp4", FromType.FromLocation); + var media = new Media(_libVLC, new Uri(RealStreamMediaPath)); var tcs = new TaskCompletionSource(); mp.Media = media; diff --git a/src/LibVLCSharp.Tests/MediaTests.cs b/src/LibVLCSharp.Tests/MediaTests.cs index f70c7a479..1bfe15108 100644 --- a/src/LibVLCSharp.Tests/MediaTests.cs +++ b/src/LibVLCSharp.Tests/MediaTests.cs @@ -154,7 +154,7 @@ public async Task CreateRealMediaSpecialCharacters() public async Task CreateMediaFromStreamMultiplePlay() { using var mp = new MediaPlayer(_libVLC); - using var stream = await GetStreamFromUrl("http://www.quirksmode.org/html5/videos/big_buck_bunny.mp4"); + using var stream = await GetStreamFromUrl(RealStreamMediaPath); using var mediaInput = new StreamMediaInput(stream); using var media = new Media(_libVLC, mediaInput); mp.Play(media); @@ -177,8 +177,8 @@ public async Task CreateMultipleMediaFromStreamPlay() var mp1 = new MediaPlayer(libVLC1); var mp2 = new MediaPlayer(libVLC2); - using var s1 = await GetStreamFromUrl("http://www.quirksmode.org/html5/videos/big_buck_bunny.mp4"); - using var s2 = await GetStreamFromUrl("https://streams.videolan.org/streams/mp3/05-Mr.%20Zebra.mp3"); + using var s1 = await GetStreamFromUrl(RealStreamMediaPath); + using var s2 = await GetStreamFromUrl(RealStreamMediaPath); using var i1 = new StreamMediaInput(s1); using var i2 = new StreamMediaInput(s2); From d99df987cfaf8d4ecac7760a60ccc080f3e0a2ae Mon Sep 17 00:00:00 2001 From: Martin Finkel Date: Thu, 23 Jul 2020 12:05:11 +0200 Subject: [PATCH 04/11] cake: add test task --- buildsystem/build.cake | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/buildsystem/build.cake b/buildsystem/build.cake index 30a9f736f..4f988c703 100644 --- a/buildsystem/build.cake +++ b/buildsystem/build.cake @@ -8,6 +8,7 @@ var solutionName = "LibVLCSharp"; var solutionFile = IsRunningOnWindows() ? $"{solutionName}.sln" : $"{solutionName}.Mac.sln"; var solutionPath = $"../src/{solutionFile}"; var libvlcsharpCsproj = "../src/libvlcsharp/libvlcsharp.csproj"; +var testCsproj = "../src/libvlcsharp.tests/libvlcsharp.tests.csproj"; var packagesDir = "../packages"; var isCiBuild = BuildSystem.IsRunningOnAzurePipelines || BuildSystem.IsRunningOnAzurePipelinesHosted; @@ -75,6 +76,17 @@ Task("Build-only-libvlcsharp") Build(libvlcsharpCsproj); }); +Task("Test") + .Does(() => +{ + var settings = new DotNetCoreTestSettings + { + Logger = "console;verbosity=detailed" + }; + + DotNetCoreTest(testCsproj, settings); +}); + Task("CIDeploy") .Does(() => { From 9cb8b4a82c8525a3765a7fb915a84ca7fcbc4c64 Mon Sep 17 00:00:00 2001 From: Martin Finkel Date: Thu, 23 Jul 2020 12:16:06 +0200 Subject: [PATCH 05/11] CI: Add test run --- buildsystem/azure-pipelines.yml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/buildsystem/azure-pipelines.yml b/buildsystem/azure-pipelines.yml index d73bd3aa7..01b46725b 100644 --- a/buildsystem/azure-pipelines.yml +++ b/buildsystem/azure-pipelines.yml @@ -30,6 +30,23 @@ stages: steps: - template: windows-build.yml +- stage: Test + dependsOn: Build + condition: succeeded('Build') + + jobs: + - job: test + pool: + vmImage: 'windows-latest' + steps: + - task: PowerShell@2 + displayName: 'Test' + inputs: + targetType: filePath + filePath: ./buildsystem/build.ps1 + arguments: -target Test + workingDirectory: buildsystem + - stage: Deploy dependsOn: Build condition: and(succeeded('Build'), not(eq(variables['build.reason'], 'PullRequest'))) From fca6e41716e953358ef5df10666ffddf773d7057 Mon Sep 17 00:00:00 2001 From: Martin Finkel Date: Thu, 23 Jul 2020 13:34:38 +0200 Subject: [PATCH 06/11] disable rendererDiscoverer test for CI --- buildsystem/azure-pipelines.yml | 11 +++++++---- buildsystem/build.cake | 4 ++-- src/LibVLCSharp.Tests/LibVLCSharp.Tests.csproj | 2 +- src/LibVLCSharp.Tests/RendererDiscovererTests.cs | 2 +- 4 files changed, 11 insertions(+), 8 deletions(-) diff --git a/buildsystem/azure-pipelines.yml b/buildsystem/azure-pipelines.yml index 01b46725b..cc62c05d3 100644 --- a/buildsystem/azure-pipelines.yml +++ b/buildsystem/azure-pipelines.yml @@ -10,7 +10,7 @@ stages: - stage: Build variables: DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true - + DOTNET_CLI_TELEMETRY_OPTOUT: true jobs: - job: Linux pool: @@ -33,6 +33,9 @@ stages: - stage: Test dependsOn: Build condition: succeeded('Build') + variables: + DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true + DOTNET_CLI_TELEMETRY_OPTOUT: true jobs: - job: test @@ -43,13 +46,13 @@ stages: displayName: 'Test' inputs: targetType: filePath - filePath: ./buildsystem/build.ps1 + filePath: ./buildsystem/build.ps1 arguments: -target Test workingDirectory: buildsystem - stage: Deploy - dependsOn: Build - condition: and(succeeded('Build'), not(eq(variables['build.reason'], 'PullRequest'))) + dependsOn: Test + condition: and(succeeded('Test'), not(eq(variables['build.reason'], 'PullRequest'))) jobs: - job: feedz diff --git a/buildsystem/build.cake b/buildsystem/build.cake index 4f988c703..0e1954a08 100644 --- a/buildsystem/build.cake +++ b/buildsystem/build.cake @@ -8,7 +8,7 @@ var solutionName = "LibVLCSharp"; var solutionFile = IsRunningOnWindows() ? $"{solutionName}.sln" : $"{solutionName}.Mac.sln"; var solutionPath = $"../src/{solutionFile}"; var libvlcsharpCsproj = "../src/libvlcsharp/libvlcsharp.csproj"; -var testCsproj = "../src/libvlcsharp.tests/libvlcsharp.tests.csproj"; +var testCsproj = "../src/LibVLCSharp.Tests/LibVLCSharp.Tests.csproj"; var packagesDir = "../packages"; var isCiBuild = BuildSystem.IsRunningOnAzurePipelines || BuildSystem.IsRunningOnAzurePipelinesHosted; @@ -84,7 +84,7 @@ Task("Test") Logger = "console;verbosity=detailed" }; - DotNetCoreTest(testCsproj, settings); + DotNetCoreTest(testCsproj, settings); }); Task("CIDeploy") diff --git a/src/LibVLCSharp.Tests/LibVLCSharp.Tests.csproj b/src/LibVLCSharp.Tests/LibVLCSharp.Tests.csproj index 880d478df..9d090b020 100644 --- a/src/LibVLCSharp.Tests/LibVLCSharp.Tests.csproj +++ b/src/LibVLCSharp.Tests/LibVLCSharp.Tests.csproj @@ -1,6 +1,6 @@  - netcoreapp2.1 + netcoreapp3.1 Exe false 8.0 diff --git a/src/LibVLCSharp.Tests/RendererDiscovererTests.cs b/src/LibVLCSharp.Tests/RendererDiscovererTests.cs index 6d95d8bac..7a71b484f 100644 --- a/src/LibVLCSharp.Tests/RendererDiscovererTests.cs +++ b/src/LibVLCSharp.Tests/RendererDiscovererTests.cs @@ -15,6 +15,7 @@ public class RendererDiscovererTests : BaseSetup // This test depends on both accepting the network access request made by the test runner // and having a chromecast on the same local network. [Test] + [Ignore("requires network calls that may fail when run from CI")] public async Task DiscoverItems() { Core.Initialize(); @@ -62,7 +63,6 @@ public async Task DiscoverItems() public void DisposeRendererDiscoverer() { var rendererDiscoverer = new RendererDiscoverer(_libVLC, _libVLC.RendererList.LastOrDefault().Name); - rendererDiscoverer.Start(); rendererDiscoverer.Dispose(); Assert.AreEqual(IntPtr.Zero, rendererDiscoverer.NativeReference); } From 18ee9d1eaf07e805efce7015c10b901a760e6d02 Mon Sep 17 00:00:00 2001 From: Martin Finkel Date: Wed, 29 Jul 2020 11:38:37 +0200 Subject: [PATCH 07/11] wait less --- src/LibVLCSharp.Tests/MediaTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/LibVLCSharp.Tests/MediaTests.cs b/src/LibVLCSharp.Tests/MediaTests.cs index 1bfe15108..fef98b2bd 100644 --- a/src/LibVLCSharp.Tests/MediaTests.cs +++ b/src/LibVLCSharp.Tests/MediaTests.cs @@ -144,7 +144,7 @@ public async Task CreateRealMediaSpecialCharacters() using (var mp = new MediaPlayer(media)) { Assert.True(mp.Play()); - await Task.Delay(10000); + await Task.Delay(1000); mp.Stop(); } } From e35a8e0b8cfc2e53df03af71fbfefab67356410c Mon Sep 17 00:00:00 2001 From: Martin Finkel Date: Mon, 3 Aug 2020 10:32:52 +0200 Subject: [PATCH 08/11] disable warnings as error for now --- src/LibVLCSharp.Tests/LibVLCSharp.Tests.csproj | 1 - 1 file changed, 1 deletion(-) diff --git a/src/LibVLCSharp.Tests/LibVLCSharp.Tests.csproj b/src/LibVLCSharp.Tests/LibVLCSharp.Tests.csproj index 9d090b020..51e582c98 100644 --- a/src/LibVLCSharp.Tests/LibVLCSharp.Tests.csproj +++ b/src/LibVLCSharp.Tests/LibVLCSharp.Tests.csproj @@ -5,7 +5,6 @@ false 8.0 enable - true full From a903ebaea59ad07f268a5451432821197ae5d64d Mon Sep 17 00:00:00 2001 From: Martin Finkel Date: Mon, 3 Aug 2020 11:00:41 +0200 Subject: [PATCH 09/11] fix up tests --- src/LibVLCSharp.Tests/BaseSetup.cs | 3 +-- src/LibVLCSharp.Tests/LibVLCSharp.Tests.csproj | 2 +- src/LibVLCSharp.Tests/MediaTests.cs | 8 ++++---- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/LibVLCSharp.Tests/BaseSetup.cs b/src/LibVLCSharp.Tests/BaseSetup.cs index de37e7dfd..dee350b89 100644 --- a/src/LibVLCSharp.Tests/BaseSetup.cs +++ b/src/LibVLCSharp.Tests/BaseSetup.cs @@ -19,8 +19,7 @@ public void SetUp() _libVLC = new LibVLC("--no-audio"/*, "--no-video"*/, "--verbose=2"); } - protected string RemoteAudioStream => "http://streams.videolan.org/streams/mp3/Owner-MPEG2.5.mp3"; - + protected string RealStreamMediaPath => "http://streams.videolan.org/streams/mp3/Owner-MPEG2.5.mp3"; protected string RemoteVideoStream => "https://streams.videolan.org/streams/mp4/Jago-Youtube.mp4"; protected string LocalAudioFile => Path.Combine(Directory.GetParent(Assembly.GetExecutingAssembly().Location).FullName, "sample.mp3"); diff --git a/src/LibVLCSharp.Tests/LibVLCSharp.Tests.csproj b/src/LibVLCSharp.Tests/LibVLCSharp.Tests.csproj index 51e582c98..9f7a1039f 100644 --- a/src/LibVLCSharp.Tests/LibVLCSharp.Tests.csproj +++ b/src/LibVLCSharp.Tests/LibVLCSharp.Tests.csproj @@ -15,7 +15,7 @@ - + diff --git a/src/LibVLCSharp.Tests/MediaTests.cs b/src/LibVLCSharp.Tests/MediaTests.cs index fef98b2bd..909b928cd 100644 --- a/src/LibVLCSharp.Tests/MediaTests.cs +++ b/src/LibVLCSharp.Tests/MediaTests.cs @@ -22,7 +22,7 @@ public void CreateMedia() [Test] public void CreateMediaFromUri() { - var media = new Media(_libVLC, new Uri(RemoteAudioStream, UriKind.Absolute)); + var media = new Media(_libVLC, new Uri(RealStreamMediaPath, UriKind.Absolute)); Assert.AreNotEqual(IntPtr.Zero, media.NativeReference); } @@ -64,7 +64,7 @@ public void AddOption() [Test] public async Task CreateRealMedia() { - using (var media = new Media(_libVLC, RemoteAudioStream, FromType.FromLocation)) + using (var media = new Media(_libVLC, RealStreamMediaPath, FromType.FromLocation)) { Assert.NotZero(media.Duration); using (var mp = new MediaPlayer(media)) @@ -80,7 +80,7 @@ public async Task CreateRealMedia() [Test] public async Task CreateRealMediaFromUri() { - using (var media = new Media(_libVLC, new Uri(RemoteAudioStream, UriKind.Absolute))) + using (var media = new Media(_libVLC, new Uri(RealStreamMediaPath, UriKind.Absolute))) { Assert.NotZero(media.Duration); using (var mp = new MediaPlayer(media)) @@ -229,7 +229,7 @@ public async Task ParseShouldFailIfNotMediaFile() [Test] public async Task ParseShouldBeSkippedIfLocalParseSpecifiedAndRemoteUrlProvided() { - using var media = new Media(_libVLC, RemoteAudioStream, FromType.FromLocation); + using var media = new Media(_libVLC, RealStreamMediaPath, FromType.FromLocation); var parseResult = await media.Parse(MediaParseOptions.ParseLocal); Assert.AreEqual(MediaParsedStatus.Skipped, parseResult); } From d7abf84fa9f5c78236bba0f0ffe7151a903969f5 Mon Sep 17 00:00:00 2001 From: Martin Finkel Date: Mon, 3 Aug 2020 11:32:17 +0200 Subject: [PATCH 10/11] fail earlier --- src/LibVLCSharp.Tests/EventManagerTests.cs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/LibVLCSharp.Tests/EventManagerTests.cs b/src/LibVLCSharp.Tests/EventManagerTests.cs index cdea4579d..885053293 100644 --- a/src/LibVLCSharp.Tests/EventManagerTests.cs +++ b/src/LibVLCSharp.Tests/EventManagerTests.cs @@ -23,7 +23,7 @@ public void MetaChangedEventSubscribe() media.SetMeta(MetadataType.Description, "test"); Assert.True(eventHandlerCalled); } - + public void DurationChanged() { var media = new Media(_libVLC, LocalAudioFile); @@ -75,8 +75,7 @@ public async Task OpeningStateChanged() var mp = new MediaPlayer(media); mp.Play(); - await tcs.Task; - Assert.True(tcs.Task.Result); + await Task.Delay(1000); Assert.True(openingCalled); } } From 1b040d39d59a2458ea514c6ce692293c74d9ba12 Mon Sep 17 00:00:00 2001 From: Martin Finkel Date: Mon, 3 Aug 2020 11:32:37 +0200 Subject: [PATCH 11/11] fixup --- src/LibVLCSharp.Tests/LibVLCTests.cs | 2 +- src/LibVLCSharp.Tests/MediaTests.cs | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/src/LibVLCSharp.Tests/LibVLCTests.cs b/src/LibVLCSharp.Tests/LibVLCTests.cs index 56b7a7ace..cac8eda58 100644 --- a/src/LibVLCSharp.Tests/LibVLCTests.cs +++ b/src/LibVLCSharp.Tests/LibVLCTests.cs @@ -125,7 +125,7 @@ public void DisposeLibVLC() [Test] public void LibVLCVersion() { - Assert.True(_libVLC.Version.StartsWith("3")); + Assert.AreEqual(typeof(LibVLC).Assembly.GetName()?.Version?.Major, int.Parse(_libVLC.Version.First().ToString())); } [Test] diff --git a/src/LibVLCSharp.Tests/MediaTests.cs b/src/LibVLCSharp.Tests/MediaTests.cs index 909b928cd..4fc8d51e1 100644 --- a/src/LibVLCSharp.Tests/MediaTests.cs +++ b/src/LibVLCSharp.Tests/MediaTests.cs @@ -136,8 +136,6 @@ public async Task CreateRealMediaSpecialCharacters() { using (var media = new Media(_libVLC, LocalAudioFileSpecialCharacter, FromType.FromPath)) { - Assert.AreEqual(MediaParsedStatus.Skipped, media.ParsedStatus); - await media.Parse(); await Task.Delay(5000); Assert.AreEqual(MediaParsedStatus.Done, media.ParsedStatus);