Skip to content

chore: support standalone mode for netcode runtimetests #1115

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

Merged
merged 4 commits into from
Aug 31, 2021
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

#if UNITY_EDITOR
[assembly: InternalsVisibleTo("Unity.Netcode.EditorTests")]
[assembly: InternalsVisibleTo("Unity.Netcode.RuntimeTests")]
[assembly: InternalsVisibleTo("Unity.Netcode.Editor.CodeGen")]
[assembly: InternalsVisibleTo("Unity.Netcode.Editor")]
[assembly: InternalsVisibleTo("TestProject.EditorTests")]
[assembly: InternalsVisibleTo("TestProject.RuntimeTests")]
#endif
[assembly: InternalsVisibleTo("Unity.Netcode.RuntimeTests")]
2 changes: 1 addition & 1 deletion com.unity.netcode.gameobjects/Runtime/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

#if UNITY_EDITOR
[assembly: InternalsVisibleTo("Unity.Netcode.EditorTests")]
[assembly: InternalsVisibleTo("Unity.Netcode.RuntimeTests")]
[assembly: InternalsVisibleTo("Unity.Netcode.Editor.CodeGen")]
[assembly: InternalsVisibleTo("Unity.Netcode.Editor")]
[assembly: InternalsVisibleTo("TestProject.EditorTests")]
[assembly: InternalsVisibleTo("TestProject.RuntimeTests")]
#endif
[assembly: InternalsVisibleTo("Unity.Netcode.RuntimeTests")]
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
using System;
using System.Collections.Generic;
#if UNITY_EDITOR
using Unity.Netcode.Editor;
#endif
using UnityEngine;

namespace Unity.Netcode.RuntimeTests
Expand All @@ -11,7 +13,9 @@ namespace Unity.Netcode.RuntimeTests
/// it's designed for the netcode in a way where no networking stack has to be available
/// it's designed for testing purposes and it's not designed with speed in mind
/// </summary>
#if UNITY_EDITOR
[DontShowInTransportDropdown]
#endif
public class SIPTransport : NetworkTransport
{
private struct Event
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@
"Unity.Netcode.Runtime",
"Unity.Netcode.Editor",
"Unity.Netcode.Prototyping",
"UnityEngine.TestRunner",
"UnityEditor.TestRunner",
"Unity.Multiplayer.MetricTypes",
"Unity.Multiplayer.NetStats"
"Unity.Multiplayer.NetStats",
"UnityEngine.TestRunner"
],
"includePlatforms": [],
"excludePlatforms": [],
Expand All @@ -19,8 +18,6 @@
],
"autoReferenced": false,
"defineConstraints": [
"UNITY_INCLUDE_TESTS",
"UNITY_EDITOR",
"UNITY_INCLUDE_TESTS"
],
"versionDefines": [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Reflection;
using NUnit.Framework;
using UnityEditor.PackageManager;
using UnityEditor.SceneManagement;
using UnityEngine.SceneManagement;
using UnityEngine.TestTools;
Expand All @@ -27,9 +24,7 @@ public IEnumerator Setup()
{
SceneManager.sceneLoaded += OnSceneLoaded;

var execAssembly = Assembly.GetExecutingAssembly();
var packagePath = PackageInfo.FindForAssembly(execAssembly).assetPath;
var scenePath = Path.Combine(packagePath, $"Tests/Runtime/GlobalObjectIdHash/{nameof(NetworkObjectGlobalObjectIdHashTests)}.unity");
const string scenePath = "Assets/Tests/Runtime/GlobalObjectIdHash/" + nameof(NetworkObjectGlobalObjectIdHashTests) + ".unity";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

less programmatic but also less dependent — path looks clear and obvious to me, so I think this is fine.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do these paths work on mobile platforms?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AFAIK, they should. IIRC, Assets/xxx is a project relative path and not directly OS-dependent.


yield return EditorSceneManager.LoadSceneAsyncInPlayMode(scenePath, new LoadSceneParameters(LoadSceneMode.Additive));
Assert.That(m_TestScene.isLoaded, Is.True);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Reflection;
using NUnit.Framework;
using UnityEditor.PackageManager;
using UnityEditor.SceneManagement;
using UnityEngine.SceneManagement;
using UnityEngine.TestTools;
Expand All @@ -27,10 +24,7 @@ public IEnumerator Setup()
{
SceneManager.sceneLoaded += OnSceneLoaded;

var execAssembly = Assembly.GetExecutingAssembly();
var packagePath = PackageInfo.FindForAssembly(execAssembly).assetPath;
var scenePath = Path.Combine(packagePath, $"Tests/Runtime/GlobalObjectIdHash/{nameof(NetworkPrefabGlobalObjectIdHashTests)}.unity");

const string scenePath = "Assets/Tests/Runtime/GlobalObjectIdHash/" + nameof(NetworkPrefabGlobalObjectIdHashTests) + ".unity";
yield return EditorSceneManager.LoadSceneAsyncInPlayMode(scenePath, new LoadSceneParameters(LoadSceneMode.Additive));
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
using System.Collections;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text.RegularExpressions;
using NUnit.Framework;
using UnityEditor.PackageManager;
using UnityEditor.SceneManagement;
using UnityEngine;
using UnityEngine.SceneManagement;
Expand Down Expand Up @@ -58,9 +55,7 @@ public IEnumerator Setup()
// we are running a unit test or not. (it is this or manually setting a property)
Assert.That(MultiInstanceHelpers.Create(k_ClientInstanceCount, out m_ServerNetworkManager, out m_ClientNetworkManagers));

var execAssembly = Assembly.GetExecutingAssembly();
var packagePath = PackageInfo.FindForAssembly(execAssembly).assetPath;
var scenePath = Path.Combine(packagePath, $"Tests/Runtime/ObjectParenting/{nameof(NetworkObjectParentingTests)}.unity");
const string scenePath = "Assets/Tests/Runtime/ObjectParenting/" + nameof(NetworkObjectParentingTests) + ".unity";

m_InitScene = SceneManager.GetActiveScene();
yield return EditorSceneManager.LoadSceneAsyncInPlayMode(scenePath, new LoadSceneParameters(LoadSceneMode.Additive));
Expand Down