Commit 8ad09550 authored by Ru Cindrea's avatar Ru Cindrea

Merge branch '179-project-refactoring-server' into 'master'

Resolve "Project refactoring: Server"

Closes #179

See merge request !108
parents 149b2186 7fe701cf
package ro.altom.altunitytester;
import com.google.gson.Gson;
import com.sun.javafx.geom.Vec2f;
import lombok.extern.slf4j.Slf4j;
import ro.altom.altunitytester.altUnityTesterExceptions.*;
......@@ -9,9 +8,6 @@ import java.io.DataInputStream;
import java.io.IOException;
import java.io.PrintWriter;
import java.net.Socket;
import java.util.Set;
import static ro.altom.altunitytester.AltUnityDriver.By.TAG;
@Slf4j
public class AltUnityDriver {
......@@ -944,8 +940,8 @@ public class AltUnityDriver {
throw new ObjectWasNotFoundException(data);
} else if ("error:propertyCannotBeSet".equals(typeOfException)) {
throw new PropertyNotFoundException(data);
} else if ("error:nullRefferenceException".equals(typeOfException)) {
throw new NullRefferenceException(data);
} else if ("error:nullReferenceException".equals(typeOfException)) {
throw new NullReferenceException(data);
} else if ("error:unknownError".equals(typeOfException)) {
throw new UnknownErrorException(data);
} else if ("error:formatException".equals(typeOfException)) {
......
package ro.altom.altunitytester.altUnityTesterExceptions;
public class NullRefferenceException extends AltUnityException {
public NullRefferenceException() {
public class NullReferenceException extends AltUnityException {
public NullReferenceException() {
}
public NullRefferenceException(String message) {
public NullReferenceException(String message) {
super(message);
}
}
......@@ -42,9 +42,9 @@ class PropertyCannotBeSetException(AltUnityException):
def __init__(self,message):
super(PropertyCannotBeSetException,self).__init__(message)
class NullRefferenceException(AltUnityException):
class NullReferenceException(AltUnityException):
def __init__(self,message):
super(NullRefferenceException,self).__init__(message)
super(NullReferenceException,self).__init__(message)
class UnknownErrorException(AltUnityException):
def __init__(self,message):
......
......@@ -714,8 +714,8 @@ class AltrunUnityDriver(object):
raise ObjectWasNotFoundException(data)
elif ('error:propertyCannotBeSet' in data):
raise PropertyNotFoundException(data)
elif ('error:nullRefferenceException' in data):
raise NullRefferenceException(data)
elif ('error:nullReferenceException' in data):
raise NullReferenceException(data)
elif ('error:unknownError' in data):
raise UnknownErrorException(data)
elif ('error:formatException' in data):
......
......@@ -9,7 +9,6 @@ public class StarCounter : MonoBehaviour
int starsCollected = 0;
private void Start()
{
stars = GameObject.FindGameObjectsWithTag("Star").Length;
text.text = starsCollected + "/" + stars;
}
public void UpdateStarCounter(bool created)
......
......@@ -6,6 +6,8 @@ using System.Threading;
using Assets.AltUnityTester.AltUnityDriver;
using NUnit.Framework.Constraints;
using UnityEngine;
using NullReferenceException = Assets.AltUnityTester.AltUnityDriver.NullReferenceException;
[Timeout(5000)]
public class TestForScene1WithOldSearch
{
......@@ -243,9 +245,9 @@ public class TestForScene1WithOldSearch
altElement.SetComponentProperty(componentName, propertyName, "2");
Assert.Fail();
}
catch (ComponentNotFoundException exception)
catch (NullReferenceException exception)
{
Assert.AreEqual(exception.Message, "error:componentNotFound");
Assert.AreEqual(exception.Message, "error:nullReferenceException");
}
}
......
......@@ -295,9 +295,9 @@ public class TestForScene1TestSample
altElement.SetComponentProperty(componentName, propertyName, "2");
Assert.Fail();
}
catch (ComponentNotFoundException exception)
catch (Assets.AltUnityTester.AltUnityDriver.NullReferenceException exception)
{
Assert.AreEqual(exception.Message, "error:componentNotFound");
Assert.AreEqual(exception.Message, "error:nullReferenceException");
}
}
......
......@@ -842,8 +842,8 @@ public class AltUnityDriver
throw new Assets.AltUnityTester.AltUnityDriver.ObjectWasNotFoundException(data);
case "error:propertyCannotBeSet":
throw new Assets.AltUnityTester.AltUnityDriver.PropertyNotFoundException(data);
case "error:nullRefferenceException":
throw new Assets.AltUnityTester.AltUnityDriver.NullRefferenceException(data);
case "error:nullReferenceException":
throw new Assets.AltUnityTester.AltUnityDriver.NullReferenceException(data);
case "error:unknownError":
throw new Assets.AltUnityTester.AltUnityDriver.UnknownErrorException(data);
case "error:formatException":
......
......@@ -124,13 +124,13 @@ namespace Assets.AltUnityTester.AltUnityDriver
}
}
public class NullRefferenceException : AltUnityException
public class NullReferenceException : AltUnityException
{
public NullRefferenceException()
public NullReferenceException()
{
}
public NullRefferenceException(string message) : base(message)
public NullReferenceException(string message) : base(message)
{
}
}
......
This source diff could not be displayed because it is too large. You can view the blob instead.
fileFormatVersion: 2
guid: 0c3e273d5777a0244ac02177f05ef329
guid: 8166891cdc0b4014cbd2e76d68c22646
folderAsset: yes
DefaultImporter:
externalObjects: {}
......
public abstract class Command
{
public void SendResponse(AltClientSocketHandler handler)
{
AltUnityRunner._responseQueue.ScheduleResponse(delegate
{
string response = null;
try
{
response = Execute();
}
catch (System.NullReferenceException exception)
{
UnityEngine.Debug.Log(exception);
response = AltUnityRunner._altUnityRunner.errorNullRefferenceMessage;
}
catch (System.ArgumentException exception)
{
UnityEngine.Debug.Log(exception);
response = AltUnityRunner._altUnityRunner.errorFailedToParseArguments;
}
catch (System.Reflection.TargetParameterCountException)
{
response = AltUnityRunner._altUnityRunner.errorIncorrectNumberOfParameters;
}
catch (Newtonsoft.Json.JsonException e)
{
UnityEngine.Debug.Log(e);
response = AltUnityRunner._altUnityRunner.errorCouldNotParseJsonString;
}
catch (System.Exception exception)
{
UnityEngine.Debug.Log(exception);
response = AltUnityRunner._altUnityRunner.errorUnknownError + AltUnityRunner._altUnityRunner.requestSeparatorString + exception;
}
finally
{
handler.SendResponse(response);
}
});
}
public abstract string Execute();
}
fileFormatVersion: 2
guid: 53c1ef4cdc3a5441aaeb481f1eed0685
timeCreated: 1516857363
licenseType: Pro
guid: 86cbfbed516e4c54d868fc1e6c338d39
MonoImporter:
externalObjects: {}
serializedVersion: 2
......
fileFormatVersion: 2
guid: 2733536a67a19254eae177c73910167d
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: 54c6977baacfa7c418010db814d04567
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Assets.AltUnityTester.AltUnityServer.Commands
{
class FindActiveObjectsByName:Command
{
string methodParameters;
public FindActiveObjectsByName(string stringSent)
{
this.methodParameters = stringSent;
}
public override string Execute()
{
var pieces = methodParameters.Split(new string[] { AltUnityRunner._altUnityRunner.requestSeparatorString }, System.StringSplitOptions.None);
string objectName = pieces[0];
UnityEngine.Debug.Log("findActiveObjectByName for: " + objectName);
string cameraName = pieces[1];
bool enabled = System.Convert.ToBoolean(pieces[2]);
string response = AltUnityRunner._altUnityRunner.errorNotFoundMessage;
var foundGameObject = UnityEngine.GameObject.Find(objectName);
if (foundGameObject != null)
{
if (cameraName.Equals(""))
response = Newtonsoft.Json.JsonConvert.SerializeObject(AltUnityRunner._altUnityRunner.GameObjectToAltUnityObject(foundGameObject));
else
{
UnityEngine.Camera camera = UnityEngine.Camera.allCameras.ToList().Find(c => c.name.Equals(cameraName));
response = camera == null ? AltUnityRunner._altUnityRunner.errorNotFoundMessage : Newtonsoft.Json.JsonConvert.SerializeObject(AltUnityRunner._altUnityRunner.GameObjectToAltUnityObject(foundGameObject, camera));
}
}
return response;
}
}
}
fileFormatVersion: 2
guid: 9bfbeeb93f05dc34da70df6e1b4bb638
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Assets.AltUnityTester.AltUnityServer.Commands
{
class FindAllObjects :Command
{
string methodParameter;
public FindAllObjects(string methodParameter)
{
this.methodParameter = methodParameter;
}
public override string Execute()
{
UnityEngine.Debug.Log("all objects requested");
var parameters = ";" + methodParameter;
return new FindObjectsByName(parameters).Execute();
}
}
}
fileFormatVersion: 2
guid: fc3e4e3fd9a78fc46be663dc3f96fc50
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
using System.Linq;
namespace Assets.AltUnityTester.AltUnityServer.Commands
{
class FindObject:BaseClassFindObjects
{
string stringSent;
public FindObject(string stringSent)
{
this.stringSent = stringSent;
}
public override string Execute()
{
UnityEngine.Debug.Log("findObject for: " + stringSent);
var pieces = stringSent.Split(new string[] { AltUnityRunner._altUnityRunner.requestSeparatorString }, System.StringSplitOptions.None);
string objectName = pieces[0];
string cameraName = pieces[1];
bool enabled = System.Convert.ToBoolean(pieces[2]);
string response = AltUnityRunner._altUnityRunner.errorNotFoundMessage;
var path = ProcessPath(objectName);
var isDirectChild = IsNextElementDirectChild(path[0]);
var foundGameObject = FindObjects(null, path, 1, true, isDirectChild, enabled);
if (foundGameObject.Count() == 1)
{
if (cameraName.Equals(""))
response = Newtonsoft.Json.JsonConvert.SerializeObject(AltUnityRunner._altUnityRunner.GameObjectToAltUnityObject(foundGameObject[0]));
else
{
UnityEngine.Camera camera = UnityEngine.Camera.allCameras.ToList().Find(c => c.name.Equals(cameraName));
response = camera == null ? AltUnityRunner._altUnityRunner.errorNotFoundMessage : Newtonsoft.Json.JsonConvert.SerializeObject(AltUnityRunner._altUnityRunner.GameObjectToAltUnityObject(foundGameObject[0], camera));
}
}
return response;
}
}
}
fileFormatVersion: 2
guid: c4a70adb90f03224bacf7b6736680584
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
using System.Linq;
namespace Assets.AltUnityTester.AltUnityServer.Commands
{
class FindObjects: BaseClassFindObjects
{
string stringSent;
public FindObjects(string stringSent)
{
this.stringSent = stringSent;
}
public override string Execute()
{
var pieces = stringSent.Split(new string[] { AltUnityRunner._altUnityRunner.requestSeparatorString }, System.StringSplitOptions.None);
string objectName = pieces[0];
UnityEngine.Debug.Log("findObjects for: " + objectName);
string cameraName = pieces[1];
bool enabled = System.Convert.ToBoolean(pieces[2]);
UnityEngine.Camera camera = null;
if (cameraName != null)
{
camera = UnityEngine.Camera.allCameras.ToList().Find(c => c.name.Equals(cameraName));
}
string response = AltUnityRunner._altUnityRunner.errorNotFoundMessage;
var path = ProcessPath(objectName);
var isDirectChild = IsNextElementDirectChild(path[0]);
System.Collections.Generic.List<AltUnityObject> foundObjects = new System.Collections.Generic.List<AltUnityObject>();
foreach (UnityEngine.GameObject testableObject in FindObjects(null, path, 1, false, isDirectChild, enabled))
{
foundObjects.Add(AltUnityRunner._altUnityRunner.GameObjectToAltUnityObject(testableObject, camera));
}
response = Newtonsoft.Json.JsonConvert.SerializeObject(foundObjects);
return response;
}
}
}
fileFormatVersion: 2
guid: 13ac668dae648d04294445d85a9df31f
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
namespace Assets.AltUnityTester.AltUnityServer.Commands
{
class GetAllCameras : Command
{
public override string Execute()
{
UnityEngine.Debug.Log("getAllCameras");
string response = AltUnityRunner._altUnityRunner.errorNotFoundMessage;
var cameras = UnityEngine.GameObject.FindObjectsOfType<UnityEngine.Camera>();
System.Collections.Generic.List<string> cameraNames = new System.Collections.Generic.List<string>();
foreach (UnityEngine.Camera camera in cameras)
{
cameraNames.Add(camera.name);
}
response = Newtonsoft.Json.JsonConvert.SerializeObject(cameraNames);
return response;
}
}
}
fileFormatVersion: 2
guid: b759c08cbbc82eb419172282080759fa
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
public class GetAllScenes : Command
{
public override string Execute()
{
UnityEngine.Debug.Log("getAllScenes");
System.Collections.Generic.List<string> SceneNames = new System.Collections.Generic.List<string>();
for (int i = 0; i < UnityEngine.SceneManagement.SceneManager.sceneCountInBuildSettings; i++)
{
var s = System.IO.Path.GetFileNameWithoutExtension(UnityEngine.SceneManagement.SceneUtility.GetScenePathByBuildIndex(i));
SceneNames.Add(s);
}
return Newtonsoft.Json.JsonConvert.SerializeObject(SceneNames);
}
}
fileFormatVersion: 2
guid: c9ee5e22b2d3a744393f084195bcbb70
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
namespace altunitytester.Assets.AltUnityTester.AltUnityServer
{
public class GetCurrentScene : Command
{
public override string Execute()
{
UnityEngine.Debug.Log("get current scene");
AltUnityObject scene = new AltUnityObject(name: UnityEngine.SceneManagement.SceneManager.GetActiveScene().name,
type: "UnityScene");
return UnityEngine.JsonUtility.ToJson(scene);
}
}
}
\ No newline at end of file
fileFormatVersion: 2
guid: d0829ef4831d8c84cb21a385af42b778
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: 3d67a8ca8f59d3946ac21481f6909d50
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
namespace Assets.AltUnityTester.AltUnityServer.Commands
{
class ActionFinished : Command
{
public override string Execute()
{
string response = AltUnityRunner._altUnityRunner.errorNotFoundMessage;
#if ALTUNITYTESTER
UnityEngine.Debug.Log("actionFinished");
if (Input.Finished)
response = "Yes";
else
{
response = "No";
}
#endif
return response;
}
}
}
fileFormatVersion: 2
guid: 49e1b91a5a4acdd408656b26fb4a657a
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Assets.AltUnityTester.AltUnityServer.Commands
{
class ClickEvent: Command
{
AltUnityObject altUnityObject;
public ClickEvent(AltUnityObject altObject)
{
this.altUnityObject = altObject;
}
public override string Execute()
{
UnityEngine.Debug.Log("ClickEvent on " + altUnityObject);
string response = AltUnityRunner._altUnityRunner.errorNotFoundMessage;
UnityEngine.GameObject foundGameObject = AltUnityRunner.GetGameObject(altUnityObject);
var pointerEventData = new UnityEngine.EventSystems.PointerEventData(UnityEngine.EventSystems.EventSystem.current);
UnityEngine.EventSystems.ExecuteEvents.Execute(foundGameObject, pointerEventData, UnityEngine.EventSystems.ExecuteEvents.pointerClickHandler);
response = Newtonsoft.Json.JsonConvert.SerializeObject(AltUnityRunner._altUnityRunner.GameObjectToAltUnityObject(foundGameObject));
return response;
}
}
}
fileFormatVersion: 2
guid: e00c085c665baf3429c8d6098c11bbf1
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;