Пример #1
0
        public IEnumerator StandalonePublish()
        {
            // Restart the server, making sure there is no Shotgun client
            PythonRunner.StopServer(false);

            // Make sure the Shotgun client has stopped
            double initTime = EditorApplication.timeSinceStartup;

            while (Bootstrap.IsClientAlive())
            {
                if (EditorApplication.timeSinceStartup - initTime > shutdownTimeout)
                {
                    Assert.That(false, Is.True);
                }
                System.Threading.Thread.Sleep(100);
            }
            // Bootstrap Shotgun with our test client
            Bootstrap.SpawnClient(clientPath);

            // Give some time for the client to connect
            yield return(PythonRunner.WaitForConnection(Constants.clientName, connectionTimeout));

            // Wait until the client is fully bootstrapped
            initTime = EditorApplication.timeSinceStartup;
            while (!PythonRunner.CallServiceOnClient(Constants.clientName, "bootstrapped"))
            {
                if (EditorApplication.timeSinceStartup - initTime > bootstrapTimeout)
                {
                    break;
                }
                yield return(null);
            }

            // Fake a recording by copying a video file in the right location
            string videoFilePath   = Path.GetFullPath($"{testsPath}/standalone_publish.mp4");
            var    destinationPath = Path.Combine(System.IO.Path.GetTempPath(), Application.productName);

            destinationPath += ".mp4";

            System.IO.File.Copy(videoFilePath, destinationPath, true);

            Service.Call("standalone_publish");

            // Wait until the client has finished publishing
            initTime = EditorApplication.timeSinceStartup;
            while (!PythonRunner.CallServiceOnClient(Constants.clientName, "published"))
            {
                if (EditorApplication.timeSinceStartup - initTime > publishTimeout)
                {
                    break;
                }
                yield return(null);
            }

            // Upon success, the Python script creates a game object named
            // after the product name
            GameObject go = GameObject.Find(Application.productName);

            Assert.IsNotNull(go);
        }