public void Begin() { if (Initialized) { return; } Initialized = true; if (!ReportingManager.IsTestWithoutRecordingFile && RecordedPlaybackPersistentData.GetRecordingMode() == RecordingMode.Playback && !File.Exists(RecordedPlaybackPersistentData.GetRecordingDataFilePath())) { logger.LogError($"Recorded Playback file does not exist."); return; } if (inputModule == null) { inputModule = gameObject.AddComponent <RecordingInputModule>(); } if (RecordedPlaybackPersistentData.GetRecordingMode() == RecordingMode.Record) { gameObject.AddComponent <GameListenerHandler>(); } SetEventSystem(); VisualFxManager.SetUp(Instance.transform); }
public static void UploadCounters(DeviceFarmOverrides dfConfOverrides = null) { AQALogger logger = new AQALogger(); var testResults = CloudTestManager.Instance.GetTestResults(dfConfOverrides); logger.Log($"Uploading counters {testResults.ToString()}"); var postUrl = $"{AutomatedQARuntimeSettings.DEVICE_TESTING_API_ENDPOINT}/v1/counters"; logger.Log($"Counters = {testResults}"); byte[] counterPayload = GetBytes(testResults); UploadHandlerRaw uH = new UploadHandlerRaw(counterPayload); uH.contentType = "application/json"; using (var uwr = new UnityWebRequest(postUrl, UnityWebRequest.kHttpVerbPOST)) { uwr.uploadHandler = uH; AsyncOperation request = uwr.SendWebRequest(); while (!request.isDone) { } if (uwr.IsError()) { logger.LogError($"Couldn't upload counters. Error - {uwr.error}"); } else { logger.Log($"Uploaded counters."); } } }
public static void DownloadRecording(string recordingFileName, string resultFileOutputPath) { var logger = new AQALogger(); var projectId = Application.cloudProjectId; var downloadUri = $"{AutomatedQARuntimeSettings.GAMESIM_API_ENDPOINT}/v1/recordings/{recordingFileName}/download?projectId={projectId}"; var dh = new DownloadHandlerFile(resultFileOutputPath); dh.removeFileOnAbort = true; logger.Log("Starting download" + downloadUri); using (var webrx = UnityWebRequest.Get(downloadUri)) { webrx.downloadHandler = dh; AsyncOperation request = webrx.SendWebRequest(); while (!request.isDone) { } if (webrx.IsError()) { logger.LogError($"Couldn't download file. Error - {webrx.error}"); } else { logger.Log($"Downloaded file saved to {resultFileOutputPath}."); } } }
public static string GetLocalRecordingFile(string testName) { var logger = new AQALogger(); //TODO: Cache this ? foreach (var testdata in GetAllRecordedTests()) { if (testdata.testMethod == testName) { return(testdata.recording); } } logger.LogError($"Recording file not found for test {testName}"); return(null); }
public static void SetRecordingDataFromFile(string sourcePath) { AQALogger logger = new AQALogger(); RecordedPlaybackPersistentData.CleanRecordingData(); string destPath = Path.Combine(AutomatedQARuntimeSettings.PersistentDataPath, kRecordedPlaybackFilename); if (!string.IsNullOrEmpty(sourcePath)) { CopyRecordingFile(sourcePath, destPath); } else { logger.LogError($"Failed to copy recording file from {sourcePath} to {destPath}"); } }
public static string CreateFileFromResource(string resourcePath, string fileName) { AQALogger logger = new AQALogger(); var resource = Path.Combine(Path.GetDirectoryName(resourcePath), Path.GetFileNameWithoutExtension(resourcePath)); var recording = Resources.Load <TextAsset>(resource); if (recording != null) { string destPath = Path.Combine(AutomatedQARuntimeSettings.PersistentDataPath, fileName); File.WriteAllText(destPath, recording.text); logger.Log($"Copied recording file {resourcePath} to {destPath}"); return(destPath); } else { logger.LogError($"Could not load recording {resourcePath}"); } return(null); }
public TestName(string testName) { logger = new AQALogger(); this.fullName = testName; var matches = Regex.Matches(testName, @"[^.][a-zA-Z0-9-_]+"); try { this.funcName = matches[matches.Count - 1].Value; this.typeName = matches[matches.Count - 2].Value; this.namespaceName = matches.Count == 3 ? matches[matches.Count - 3].Value : null; } catch (IndexOutOfRangeException) { logger.LogError($"Invalid testName: {testName}"); this.funcName = null; this.typeName = null; this.namespaceName = null; } }
private IEnumerator Start() { logger = new AQALogger(); // Wait for 1 frame to avoid initializing too early yield return(null); if (Application.isPlaying) { if (runConfig == null) { logger.LogError($"runConfig is null"); } ReportingManager.CurrentTestName = AutomatorName; CentralAutomationController.Instance.Run(runConfig); } if (!runWhileEditorIsAlreadyStarted && !EditorApplication.isPlayingOrWillChangePlaymode) { // Destroys the StartRecordedPlaybackFromEditor unless it is currently transitioning to playmode DestroyImmediate(this.gameObject); } }