mirror of
https://github.com/Facepunch/Facepunch.Steamworks.git
synced 2024-12-25 06:05:46 +03:00
User Test
This commit is contained in:
parent
d211dd40e1
commit
2ea8585c48
@ -69,7 +69,7 @@ public void InstalledDepots()
|
|||||||
[TestMethod]
|
[TestMethod]
|
||||||
public async Task GetFileDetails()
|
public async Task GetFileDetails()
|
||||||
{
|
{
|
||||||
var fileinfo = await Apps.GetFileDetails( "hl2.exe" );
|
var fileinfo = await Apps.GetFileDetailsAsync( "hl2.exe" );
|
||||||
|
|
||||||
Console.WriteLine( $"fileinfo.Found: {fileinfo.Found}" );
|
Console.WriteLine( $"fileinfo.Found: {fileinfo.Found}" );
|
||||||
Console.WriteLine( $"fileinfo.SizeInBytes: {fileinfo.SizeInBytes}" );
|
Console.WriteLine( $"fileinfo.SizeInBytes: {fileinfo.SizeInBytes}" );
|
||||||
@ -78,7 +78,7 @@ public async Task GetFileDetails()
|
|||||||
}
|
}
|
||||||
|
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
public async Task CommandLine()
|
public void CommandLine()
|
||||||
{
|
{
|
||||||
var cl = Apps.CommandLine;
|
var cl = Apps.CommandLine;
|
||||||
|
|
||||||
|
119
Facepunch.Steamworks.Test/Client/UserTest.cs
Normal file
119
Facepunch.Steamworks.Test/Client/UserTest.cs
Normal file
@ -0,0 +1,119 @@
|
|||||||
|
using System;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||||
|
|
||||||
|
namespace Steamworks
|
||||||
|
{
|
||||||
|
[TestClass]
|
||||||
|
[DeploymentItem( "steam_api64.dll" )]
|
||||||
|
public class UserTest
|
||||||
|
{
|
||||||
|
[TestMethod]
|
||||||
|
public void GetVoice()
|
||||||
|
{
|
||||||
|
using ( var stream = new MemoryStream() )
|
||||||
|
{
|
||||||
|
int compressed = 0;
|
||||||
|
|
||||||
|
User.VoiceRecord = true;
|
||||||
|
|
||||||
|
var sw = Stopwatch.StartNew();
|
||||||
|
|
||||||
|
while ( sw.Elapsed.TotalSeconds < 3 )
|
||||||
|
{
|
||||||
|
System.Threading.Thread.Sleep( 10 );
|
||||||
|
compressed += User.ReadVoiceData( stream );
|
||||||
|
}
|
||||||
|
|
||||||
|
Assert.AreEqual( compressed, stream.Length );
|
||||||
|
Console.WriteLine( $"compressed: {compressed}", compressed );
|
||||||
|
Console.WriteLine( $"stream.Length: {stream.Length}", stream.Length );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
[TestMethod]
|
||||||
|
public void OptimalSampleRate()
|
||||||
|
{
|
||||||
|
var rate = User.OptimalSampleRate;
|
||||||
|
Assert.AreNotEqual( rate, 0 );
|
||||||
|
Console.WriteLine( $"User.OptimalSampleRate: {User.OptimalSampleRate}" );
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestMethod]
|
||||||
|
public void IsLoggedOn()
|
||||||
|
{
|
||||||
|
Assert.AreNotEqual( false, User.IsLoggedOn );
|
||||||
|
Console.WriteLine( $"User.IsLoggedOn: {User.IsLoggedOn}" );
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestMethod]
|
||||||
|
public void SteamID()
|
||||||
|
{
|
||||||
|
Assert.AreNotEqual( 0, User.SteamID.Value );
|
||||||
|
Console.WriteLine( $"User.SteamID: {User.SteamID.Value}" );
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestMethod]
|
||||||
|
public void AuthSession()
|
||||||
|
{
|
||||||
|
var ticket = User.GetAuthSessionTicket();
|
||||||
|
|
||||||
|
Assert.AreNotEqual( 0, ticket.Handle );
|
||||||
|
Assert.AreNotEqual( 0, ticket.Data.Length );
|
||||||
|
Console.WriteLine( $"ticket.Handle: {ticket.Handle}" );
|
||||||
|
Console.WriteLine( $"ticket.Data: { string.Join( "", ticket.Data.Select( x => x.ToString( "x" ) ) ) }" );
|
||||||
|
|
||||||
|
var result = User.BeginAuthSession( ticket.Data, User.SteamID );
|
||||||
|
Console.WriteLine( $"result: { result }" );
|
||||||
|
Assert.AreEqual( result, SteamNative.BeginAuthSessionResult.OK );
|
||||||
|
|
||||||
|
User.EndAuthSession( User.SteamID );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
[TestMethod]
|
||||||
|
public void SteamLevel()
|
||||||
|
{
|
||||||
|
Assert.AreNotEqual( 0, User.SteamLevel );
|
||||||
|
Console.WriteLine( $"User.SteamLevel: {User.SteamLevel}" );
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestMethod]
|
||||||
|
public async Task GetStoreAuthUrlAsync()
|
||||||
|
{
|
||||||
|
var rustskins = await User.GetStoreAuthUrlAsync( "https://store.steampowered.com/itemstore/252490/" );
|
||||||
|
|
||||||
|
Assert.IsNotNull( rustskins );
|
||||||
|
Console.WriteLine( $"rustskins: {rustskins}" );
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestMethod]
|
||||||
|
public void IsPhoneVerified()
|
||||||
|
{
|
||||||
|
Console.WriteLine( $"User.IsPhoneVerified: {User.IsPhoneVerified}" );
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestMethod]
|
||||||
|
public void IsTwoFactorEnabled()
|
||||||
|
{
|
||||||
|
Console.WriteLine( $"User.IsTwoFactorEnabled: {User.IsTwoFactorEnabled}" );
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestMethod]
|
||||||
|
public void IsPhoneIdentifying()
|
||||||
|
{
|
||||||
|
Console.WriteLine( $"User.IsPhoneIdentifying: {User.IsPhoneIdentifying}" );
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestMethod]
|
||||||
|
public void IsPhoneRequiringVerification()
|
||||||
|
{
|
||||||
|
Console.WriteLine( $"User.IsPhoneRequiringVerification: {User.IsPhoneRequiringVerification}" );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,123 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Diagnostics;
|
|
||||||
using System.IO;
|
|
||||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
|
||||||
|
|
||||||
namespace Facepunch.Steamworks.Test
|
|
||||||
{
|
|
||||||
[DeploymentItem( "steam_api64.dll" )]
|
|
||||||
[TestClass]
|
|
||||||
public class Voice
|
|
||||||
{
|
|
||||||
static readonly MemoryStream decompressStream = new MemoryStream();
|
|
||||||
|
|
||||||
[TestMethod]
|
|
||||||
public void GetVoice()
|
|
||||||
{
|
|
||||||
using ( var client = new Facepunch.Steamworks.Client( 252490 ) )
|
|
||||||
{
|
|
||||||
int unCompressed = 0;
|
|
||||||
int compressed = 0;
|
|
||||||
|
|
||||||
client.Voice.OnCompressedData = ( buffer, length ) =>
|
|
||||||
{
|
|
||||||
compressed += length;
|
|
||||||
|
|
||||||
if ( !client.Voice.Decompress( buffer, length, decompressStream ) )
|
|
||||||
{
|
|
||||||
Assert.Fail( "Decompress returned false" );
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
client.Voice.OnUncompressedData = ( buffer, length ) =>
|
|
||||||
{
|
|
||||||
unCompressed += length;
|
|
||||||
};
|
|
||||||
|
|
||||||
client.Voice.WantsRecording = true;
|
|
||||||
|
|
||||||
var sw = Stopwatch.StartNew();
|
|
||||||
|
|
||||||
while ( sw.Elapsed.TotalSeconds < 3 )
|
|
||||||
{
|
|
||||||
client.Update();
|
|
||||||
System.Threading.Thread.Sleep( 10 );
|
|
||||||
}
|
|
||||||
|
|
||||||
Assert.AreNotEqual( unCompressed, 0 );
|
|
||||||
Assert.AreNotEqual( compressed, 0 );
|
|
||||||
|
|
||||||
// Should really be > 0 if the mic was getting audio
|
|
||||||
Console.WriteLine( "unCompressed: {0}", unCompressed );
|
|
||||||
Console.WriteLine( "compressed: {0}", compressed );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[TestMethod]
|
|
||||||
public void CompressedOnly()
|
|
||||||
{
|
|
||||||
using ( var client = new Facepunch.Steamworks.Client( 252490 ) )
|
|
||||||
{
|
|
||||||
int compressed = 0;
|
|
||||||
|
|
||||||
client.Voice.OnCompressedData = ( buffer, length ) =>
|
|
||||||
{
|
|
||||||
compressed += length;
|
|
||||||
};
|
|
||||||
|
|
||||||
client.Voice.WantsRecording = true;
|
|
||||||
|
|
||||||
var sw = Stopwatch.StartNew();
|
|
||||||
|
|
||||||
while ( sw.Elapsed.TotalSeconds < 3 )
|
|
||||||
{
|
|
||||||
client.Update();
|
|
||||||
System.Threading.Thread.Sleep( 10 );
|
|
||||||
}
|
|
||||||
|
|
||||||
Assert.AreNotEqual( compressed, 0 );
|
|
||||||
Console.WriteLine( "compressed: {0}", compressed );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[TestMethod]
|
|
||||||
public void UnCompressedOnly()
|
|
||||||
{
|
|
||||||
using ( var client = new Facepunch.Steamworks.Client( 252490 ) )
|
|
||||||
{
|
|
||||||
int unCompressed = 0;
|
|
||||||
|
|
||||||
client.Voice.OnUncompressedData = ( buffer, length ) =>
|
|
||||||
{
|
|
||||||
unCompressed += length;
|
|
||||||
};
|
|
||||||
|
|
||||||
client.Voice.WantsRecording = true;
|
|
||||||
|
|
||||||
var sw = Stopwatch.StartNew();
|
|
||||||
|
|
||||||
while ( sw.Elapsed.TotalSeconds < 3 )
|
|
||||||
{
|
|
||||||
client.Update();
|
|
||||||
System.Threading.Thread.Sleep( 10 );
|
|
||||||
}
|
|
||||||
|
|
||||||
Assert.AreNotEqual( unCompressed, 0 );
|
|
||||||
|
|
||||||
// Should really be > 0 if the mic was getting audio
|
|
||||||
Console.WriteLine( "unCompressed: {0}", unCompressed );
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[TestMethod]
|
|
||||||
public void OptimalSampleRate()
|
|
||||||
{
|
|
||||||
using ( var client = new Facepunch.Steamworks.Client( 252490 ) )
|
|
||||||
{
|
|
||||||
var rate = client.Voice.OptimalSampleRate;
|
|
||||||
Assert.AreNotEqual( rate, 0 );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -89,6 +89,7 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="Client\AchievementsTest.cs" />
|
<Compile Include="Client\AchievementsTest.cs" />
|
||||||
|
<Compile Include="Client\UserTest.cs" />
|
||||||
<Compile Include="Client\UtilsTest.cs" />
|
<Compile Include="Client\UtilsTest.cs" />
|
||||||
<Compile Include="Client\ClientTest.cs" />
|
<Compile Include="Client\ClientTest.cs" />
|
||||||
<Compile Include="Client\LobbyTest.cs" />
|
<Compile Include="Client\LobbyTest.cs" />
|
||||||
@ -96,7 +97,6 @@
|
|||||||
<Compile Include="Client\LeaderboardTest.cs" />
|
<Compile Include="Client\LeaderboardTest.cs" />
|
||||||
<Compile Include="Client\AppTest.cs" />
|
<Compile Include="Client\AppTest.cs" />
|
||||||
<Compile Include="Client\RemoteStorageTest.cs" />
|
<Compile Include="Client\RemoteStorageTest.cs" />
|
||||||
<Compile Include="Client\VoiceTest.cs" />
|
|
||||||
<Compile Include="Client\InventoryTest.cs" />
|
<Compile Include="Client\InventoryTest.cs" />
|
||||||
<Compile Include="Client\WorkshopTest.cs" />
|
<Compile Include="Client\WorkshopTest.cs" />
|
||||||
<Compile Include="Client\NetworkingTest.cs" />
|
<Compile Include="Client\NetworkingTest.cs" />
|
||||||
|
@ -235,7 +235,7 @@ public static DownloadProgress DlcDownloadProgress( AppId appid )
|
|||||||
/// Asynchronously retrieves metadata details about a specific file in the depot manifest.
|
/// Asynchronously retrieves metadata details about a specific file in the depot manifest.
|
||||||
/// Currently provides:
|
/// Currently provides:
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static async Task<FileDetails> GetFileDetails( string filename )
|
public static async Task<FileDetails> GetFileDetailsAsync( string filename )
|
||||||
{
|
{
|
||||||
var r = await Internal.GetFileDetails( filename );
|
var r = await Internal.GetFileDetails( filename );
|
||||||
|
|
||||||
|
@ -121,20 +121,24 @@ internal static void InstallEvents()
|
|||||||
public static CSteamID SteamID => Internal.GetSteamID();
|
public static CSteamID SteamID => Internal.GetSteamID();
|
||||||
|
|
||||||
|
|
||||||
|
static bool _recordingVoice;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Starts voice recording.
|
/// Starts/Stops voice recording.
|
||||||
/// Once started, use GetAvailableVoice and GetVoice to get the data, and then call StopVoiceRecording
|
/// Once started, use GetAvailableVoice and GetVoice to get the data, and then call StopVoiceRecording
|
||||||
/// when the user has released their push-to-talk hotkey or the game session has completed.
|
/// when the user has released their push-to-talk hotkey or the game session has completed.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static void StartVoiceRecording() => Internal.StartVoiceRecording();
|
|
||||||
|
|
||||||
/// <summary>
|
public static bool VoiceRecord
|
||||||
/// Stops voice recording.
|
{
|
||||||
/// Because people often release push-to-talk keys early, the system will keep recording for a little bit
|
get => _recordingVoice;
|
||||||
/// after this function is called.As such, GetVoice should continue to be called until it returns k_EVoiceResultNotRecording,
|
set
|
||||||
/// only then will voice recording be stopped.
|
{
|
||||||
/// </summary>
|
_recordingVoice = value;
|
||||||
public static void StopVoiceRecording() => Internal.StopVoiceRecording();
|
if ( value ) Internal.StartVoiceRecording();
|
||||||
|
else Internal.StopVoiceRecording();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
Loading…
Reference in New Issue
Block a user