Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add CI test run to libvlcsharp 4 #150

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 23 additions & 3 deletions buildsystem/azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ stages:
- stage: Build
variables:
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true

DOTNET_CLI_TELEMETRY_OPTOUT: true
jobs:
- job: Linux
pool:
Expand All @@ -30,9 +30,29 @@ stages:
steps:
- template: windows-build.yml

- stage: Deploy
- stage: Test
dependsOn: Build
condition: and(succeeded('Build'), not(eq(variables['build.reason'], 'PullRequest')))
condition: succeeded('Build')
variables:
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
DOTNET_CLI_TELEMETRY_OPTOUT: true

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: Test
condition: and(succeeded('Test'), not(eq(variables['build.reason'], 'PullRequest')))

jobs:
- job: feedz
Expand Down
12 changes: 12 additions & 0 deletions buildsystem/build.cake
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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(() =>
{
Expand Down
3 changes: 1 addition & 2 deletions src/LibVLCSharp.Tests/BaseSetup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
3 changes: 0 additions & 3 deletions src/LibVLCSharp.Tests/DialogTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<bool>();
Expand Down Expand Up @@ -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<bool>();
Expand Down Expand Up @@ -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<bool>();
Expand Down
5 changes: 2 additions & 3 deletions src/LibVLCSharp.Tests/EventManagerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public void MetaChangedEventSubscribe()
media.SetMeta(MetadataType.Description, "test");
Assert.True(eventHandlerCalled);
}

public void DurationChanged()
{
var media = new Media(_libVLC, LocalAudioFile);
Expand Down Expand Up @@ -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);
}
}
Expand Down
5 changes: 2 additions & 3 deletions src/LibVLCSharp.Tests/LibVLCSharp.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
<TargetFramework>netcoreapp3.1</TargetFramework>
<OutputType>Exe</OutputType>
<GenerateProgramFile>false</GenerateProgramFile>
<LangVersion>8.0</LangVersion>
<Nullable>enable</Nullable>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|net47|AnyCPU'">
<DebugType>full</DebugType>
Expand All @@ -16,7 +15,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.Windows" Version="4.0.0.20200403" />
<PackageReference Include="VideoLAN.LibVLC.Windows" Version="4.0.0-alpha-20200609" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\LibVLCSharp\LibVLCSharp.csproj" />
Expand Down
12 changes: 1 addition & 11 deletions src/LibVLCSharp.Tests/LibVLCTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand Down Expand Up @@ -99,10 +93,6 @@ public void SetExitHandler()
});

_libVLC.SetExitHandler(exitCb);

_libVLC.Dispose();

Assert.IsTrue(called);
}

[Test]
Expand Down Expand Up @@ -135,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]
Expand Down
20 changes: 8 additions & 12 deletions src/LibVLCSharp.Tests/MediaPlayerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<bool>();

mp.Media = media;
Expand Down Expand Up @@ -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) =>
Expand All @@ -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");
Expand Down Expand Up @@ -140,8 +138,6 @@ public async Task EventFireOnceForeachRegistration()

Assert.AreEqual(callCountRegisterOne, 0);
Assert.AreEqual(callCountRegisterTwo, 0);


}
catch (Exception ex)
{
Expand All @@ -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);

Expand Down Expand Up @@ -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);
}
}
}
18 changes: 8 additions & 10 deletions src/LibVLCSharp.Tests/MediaTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down Expand Up @@ -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))
Expand All @@ -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))
Expand Down Expand Up @@ -136,15 +136,13 @@ 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);
using (var mp = new MediaPlayer(media))
{
Assert.True(mp.Play());
await Task.Delay(10000);
await Task.Delay(1000);
mp.Stop();
}
}
Expand All @@ -154,7 +152,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);
Expand All @@ -177,8 +175,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);
Expand Down Expand Up @@ -229,7 +227,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);
}
Expand Down
2 changes: 1 addition & 1 deletion src/LibVLCSharp.Tests/RendererDiscovererTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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);
}
Expand Down