-
-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
115 changed files
with
2,035 additions
and
1,420 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
// Copyright (c) VolcanicArts. Licensed under the GPL-3.0 License. | ||
// See the LICENSE file in the repository root for full license text. | ||
|
||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using NUnit.Framework; | ||
using VRCOSC.Game.Modules; | ||
|
||
namespace VRCOSC.Game.Tests.Tests; | ||
|
||
public class TimedTaskTests | ||
{ | ||
[Test] | ||
public void TestStart() | ||
{ | ||
var actionInvoked = false; | ||
|
||
Task action() | ||
{ | ||
actionInvoked = true; | ||
return Task.CompletedTask; | ||
} | ||
|
||
var task = new TimedTask(action, 100); | ||
task.Start().Wait(); | ||
|
||
Thread.Sleep(500); | ||
|
||
Assert.IsTrue(actionInvoked); | ||
} | ||
|
||
[Test] | ||
public void TestStop() | ||
{ | ||
var actionInvoked = false; | ||
|
||
Task action() | ||
{ | ||
actionInvoked = true; | ||
return Task.CompletedTask; | ||
} | ||
|
||
var task = new TimedTask(action, 100); | ||
task.Start().Wait(); | ||
|
||
Thread.Sleep(500); | ||
Assert.IsTrue(actionInvoked); | ||
|
||
task.Stop().Wait(); | ||
|
||
actionInvoked = false; | ||
|
||
Thread.Sleep(500); | ||
Assert.IsFalse(actionInvoked); | ||
} | ||
|
||
[Test] | ||
public void TestExecuteOnceImmediately() | ||
{ | ||
var actionInvoked = false; | ||
|
||
Task action() | ||
{ | ||
actionInvoked = true; | ||
return Task.CompletedTask; | ||
} | ||
|
||
var task = new TimedTask(action, 100, true); | ||
task.Start().Wait(); | ||
|
||
Assert.IsTrue(actionInvoked); | ||
|
||
Thread.Sleep(500); | ||
Assert.IsTrue(actionInvoked); | ||
} | ||
|
||
[Test] | ||
public void TestStartMultipleTimes() | ||
{ | ||
var actionInvoked = false; | ||
|
||
Task action() | ||
{ | ||
actionInvoked = true; | ||
return Task.CompletedTask; | ||
} | ||
|
||
var task = new TimedTask(action, 100); | ||
task.Start().Wait(); | ||
task.Start().Wait(); | ||
|
||
Thread.Sleep(500); | ||
|
||
Assert.IsTrue(actionInvoked); | ||
} | ||
|
||
[Test] | ||
public void TestStopWithoutStart() | ||
{ | ||
var actionInvoked = false; | ||
|
||
Task action() | ||
{ | ||
actionInvoked = true; | ||
return Task.CompletedTask; | ||
} | ||
|
||
var task = new TimedTask(action, 100); | ||
|
||
task.Stop().Wait(); | ||
|
||
Thread.Sleep(500); | ||
Assert.IsFalse(actionInvoked); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// Copyright (c) VolcanicArts. Licensed under the GPL-3.0 License. | ||
// See the LICENSE file in the repository root for full license text. | ||
|
||
// ReSharper disable MemberCanBePrivate.Global | ||
|
||
namespace VRCOSC.Game; | ||
|
||
public static class Constants | ||
{ | ||
public const string OSC_ADDRESS_AVATAR_PARAMETERS_PREFIX = @"/avatar/parameters/"; | ||
public const string OSC_ADDRESS_AVATAR_CHANGE = @"/avatar/change"; | ||
public const string OSC_ADDRESS_CHATBOX_INPUT = @"/chatbox/input"; | ||
public const string OSC_ADDRESS_CHATBOX_TYPING = @"/chatbox/typing"; | ||
|
||
public const int OSC_UPDATE_FREQUENCY = 20; | ||
public const int OSC_UPDATE_DELTA = (int)(1f / OSC_UPDATE_FREQUENCY * 1000f); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.