update libs
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 461bfd99d0923cd4a8dae2f440af1064
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d7d9c6cc805e072429392e7a378d2c9c
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,15 @@
|
||||
using AssetStoreTools.Validator.Data;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace AssetStoreTools.Validator.UI.Data
|
||||
{
|
||||
internal interface IValidatorResults
|
||||
{
|
||||
event Action OnResultsChanged;
|
||||
event Action OnRequireSerialize;
|
||||
|
||||
void LoadResult(ValidationResult result);
|
||||
IEnumerable<IValidatorTestGroup> GetSortedTestGroups();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 91c62333b36d5ef47989289e8f90c056
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 115
|
||||
packageName: Asset Store Publishing Tools
|
||||
packageVersion: 12.0.1
|
||||
assetPath: Packages/com.unity.asset-store-tools/Editor/Validator/Scripts/UI/Data/Abstractions/IValidatorResults.cs
|
||||
uploadId: 724584
|
||||
@@ -0,0 +1,31 @@
|
||||
using AssetStoreTools.Validator.Data;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace AssetStoreTools.Validator.UI.Data
|
||||
{
|
||||
internal interface IValidatorSettings
|
||||
{
|
||||
event Action OnCategoryChanged;
|
||||
event Action OnValidationTypeChanged;
|
||||
event Action OnValidationPathsChanged;
|
||||
event Action OnRequireSerialize;
|
||||
|
||||
void LoadSettings(ValidationSettings settings);
|
||||
|
||||
string GetActiveCategory();
|
||||
void SetActiveCategory(string category);
|
||||
List<string> GetAvailableCategories();
|
||||
|
||||
ValidationType GetValidationType();
|
||||
void SetValidationType(ValidationType validationType);
|
||||
|
||||
List<string> GetValidationPaths();
|
||||
void AddValidationPath(string path);
|
||||
void RemoveValidationPath(string path);
|
||||
void ClearValidationPaths();
|
||||
bool IsValidationPathValid(string path, out string error);
|
||||
|
||||
IValidator CreateValidator();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: cc6516196465ac6469258ef8950da607
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 115
|
||||
packageName: Asset Store Publishing Tools
|
||||
packageVersion: 12.0.1
|
||||
assetPath: Packages/com.unity.asset-store-tools/Editor/Validator/Scripts/UI/Data/Abstractions/IValidatorSettings.cs
|
||||
uploadId: 724584
|
||||
@@ -0,0 +1,15 @@
|
||||
using AssetStoreTools.Validator.Data;
|
||||
|
||||
namespace AssetStoreTools.Validator.UI.Data
|
||||
{
|
||||
internal interface IValidatorTest
|
||||
{
|
||||
int Id { get; }
|
||||
string Name { get; }
|
||||
string Description { get; }
|
||||
ValidationType ValidationType { get; }
|
||||
TestResult Result { get; }
|
||||
|
||||
void SetResult(TestResult result);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d1e4d9ba8de8cfc4aa42786fbbc5037a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 115
|
||||
packageName: Asset Store Publishing Tools
|
||||
packageVersion: 12.0.1
|
||||
assetPath: Packages/com.unity.asset-store-tools/Editor/Validator/Scripts/UI/Data/Abstractions/IValidatorTest.cs
|
||||
uploadId: 724584
|
||||
@@ -0,0 +1,12 @@
|
||||
using AssetStoreTools.Validator.Data;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace AssetStoreTools.Validator.UI.Data
|
||||
{
|
||||
internal interface IValidatorTestGroup
|
||||
{
|
||||
string Name { get; }
|
||||
TestResultStatus Status { get; }
|
||||
IEnumerable<IValidatorTest> Tests { get; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fa8735b7eb65d3147ab8bdbf922f36cf
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 115
|
||||
packageName: Asset Store Publishing Tools
|
||||
packageVersion: 12.0.1
|
||||
assetPath: Packages/com.unity.asset-store-tools/Editor/Validator/Scripts/UI/Data/Abstractions/IValidatorTestGroup.cs
|
||||
uploadId: 724584
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ec536685238584f41bd268edaaf0ad7d
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,28 @@
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace AssetStoreTools.Validator.UI.Data.Serialization
|
||||
{
|
||||
internal class ValidatorStateData
|
||||
{
|
||||
[JsonProperty("validation_settings")]
|
||||
private ValidatorStateSettings _settings;
|
||||
[JsonProperty("validation_results")]
|
||||
private ValidatorStateResults _results;
|
||||
|
||||
public ValidatorStateData()
|
||||
{
|
||||
_settings = new ValidatorStateSettings();
|
||||
_results = new ValidatorStateResults();
|
||||
}
|
||||
|
||||
public ValidatorStateSettings GetSettings()
|
||||
{
|
||||
return _settings;
|
||||
}
|
||||
|
||||
public ValidatorStateResults GetResults()
|
||||
{
|
||||
return _results;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: da7a885e302cb6b43855b68f44f2c0fc
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 115
|
||||
packageName: Asset Store Publishing Tools
|
||||
packageVersion: 12.0.1
|
||||
assetPath: Packages/com.unity.asset-store-tools/Editor/Validator/Scripts/UI/Data/Serialization/ValidatorStateData.cs
|
||||
uploadId: 724584
|
||||
@@ -0,0 +1,26 @@
|
||||
using Newtonsoft.Json.Serialization;
|
||||
|
||||
namespace AssetStoreTools.Validator.UI.Data.Serialization
|
||||
{
|
||||
internal class ValidatorStateDataContractResolver : DefaultContractResolver
|
||||
{
|
||||
private static ValidatorStateDataContractResolver _instance;
|
||||
public static ValidatorStateDataContractResolver Instance => _instance ?? (_instance = new ValidatorStateDataContractResolver());
|
||||
|
||||
private NamingStrategy _namingStrategy;
|
||||
|
||||
private ValidatorStateDataContractResolver()
|
||||
{
|
||||
_namingStrategy = new SnakeCaseNamingStrategy();
|
||||
}
|
||||
|
||||
protected override string ResolvePropertyName(string propertyName)
|
||||
{
|
||||
var resolvedName = _namingStrategy.GetPropertyName(propertyName, false);
|
||||
if (resolvedName.StartsWith("_"))
|
||||
return resolvedName.Substring(1);
|
||||
|
||||
return resolvedName;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 60f0e8d9b2ab86547a288c337fb2be0a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 115
|
||||
packageName: Asset Store Publishing Tools
|
||||
packageVersion: 12.0.1
|
||||
assetPath: Packages/com.unity.asset-store-tools/Editor/Validator/Scripts/UI/Data/Serialization/ValidatorStateDataContractResolver.cs
|
||||
uploadId: 724584
|
||||
@@ -0,0 +1,83 @@
|
||||
using AssetStoreTools.Validator.Data;
|
||||
using AssetStoreTools.Validator.TestDefinitions;
|
||||
using Newtonsoft.Json;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace AssetStoreTools.Validator.UI.Data.Serialization
|
||||
{
|
||||
internal class ValidatorStateResults
|
||||
{
|
||||
// Primary data
|
||||
[JsonProperty("validation_status")]
|
||||
private ValidationStatus _status;
|
||||
[JsonProperty("test_results")]
|
||||
private SortedDictionary<int, TestResult> _results;
|
||||
|
||||
// Secondary data
|
||||
[JsonProperty("project_path")]
|
||||
private string _projectPath;
|
||||
[JsonProperty("had_compilation_errors")]
|
||||
private bool _hadCompilationErrors;
|
||||
|
||||
public ValidatorStateResults()
|
||||
{
|
||||
_projectPath = string.Empty;
|
||||
_status = ValidationStatus.NotRun;
|
||||
_hadCompilationErrors = false;
|
||||
_results = new SortedDictionary<int, TestResult>();
|
||||
}
|
||||
|
||||
public ValidationStatus GetStatus()
|
||||
{
|
||||
return _status;
|
||||
}
|
||||
|
||||
public void SetStatus(ValidationStatus status)
|
||||
{
|
||||
if (_status == status)
|
||||
return;
|
||||
|
||||
_status = status;
|
||||
}
|
||||
|
||||
public SortedDictionary<int, TestResult> GetResults()
|
||||
{
|
||||
return _results;
|
||||
}
|
||||
|
||||
public void SetResults(IEnumerable<AutomatedTest> tests)
|
||||
{
|
||||
_results.Clear();
|
||||
foreach (var test in tests)
|
||||
{
|
||||
_results.Add(test.Id, test.Result);
|
||||
}
|
||||
}
|
||||
|
||||
public string GetProjectPath()
|
||||
{
|
||||
return _projectPath;
|
||||
}
|
||||
|
||||
public void SetProjectPath(string projectPath)
|
||||
{
|
||||
if (_projectPath == projectPath)
|
||||
return;
|
||||
|
||||
_projectPath = projectPath;
|
||||
}
|
||||
|
||||
public bool GetHadCompilationErrors()
|
||||
{
|
||||
return _hadCompilationErrors;
|
||||
}
|
||||
|
||||
public void SetHadCompilationErrors(bool hadCompilationErrors)
|
||||
{
|
||||
if (_hadCompilationErrors == hadCompilationErrors)
|
||||
return;
|
||||
|
||||
_hadCompilationErrors = hadCompilationErrors;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a90c3acfa50e8da4aa3da2b9c669502d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 115
|
||||
packageName: Asset Store Publishing Tools
|
||||
packageVersion: 12.0.1
|
||||
assetPath: Packages/com.unity.asset-store-tools/Editor/Validator/Scripts/UI/Data/Serialization/ValidatorStateResults.cs
|
||||
uploadId: 724584
|
||||
@@ -0,0 +1,63 @@
|
||||
using AssetStoreTools.Validator.Data;
|
||||
using Newtonsoft.Json;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace AssetStoreTools.Validator.UI.Data.Serialization
|
||||
{
|
||||
internal class ValidatorStateSettings
|
||||
{
|
||||
[JsonProperty("category")]
|
||||
private string _category;
|
||||
[JsonProperty("validation_type")]
|
||||
private ValidationType _validationType;
|
||||
[JsonProperty("validation_paths")]
|
||||
private List<string> _validationPaths;
|
||||
|
||||
public ValidatorStateSettings()
|
||||
{
|
||||
_category = string.Empty;
|
||||
_validationType = ValidationType.UnityPackage;
|
||||
_validationPaths = new List<string>();
|
||||
}
|
||||
|
||||
public string GetCategory()
|
||||
{
|
||||
return _category;
|
||||
}
|
||||
|
||||
public void SetCategory(string category)
|
||||
{
|
||||
if (_category == category)
|
||||
return;
|
||||
|
||||
_category = category;
|
||||
}
|
||||
|
||||
public ValidationType GetValidationType()
|
||||
{
|
||||
return _validationType;
|
||||
}
|
||||
|
||||
public void SetValidationType(ValidationType validationType)
|
||||
{
|
||||
if (validationType == _validationType)
|
||||
return;
|
||||
|
||||
_validationType = validationType;
|
||||
}
|
||||
|
||||
public List<string> GetValidationPaths()
|
||||
{
|
||||
return _validationPaths;
|
||||
}
|
||||
|
||||
public void SetValidationPaths(List<string> validationPaths)
|
||||
{
|
||||
if (_validationPaths.SequenceEqual(validationPaths))
|
||||
return;
|
||||
|
||||
_validationPaths = validationPaths;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d39d56313ade8a8409aafe95dc84f79a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 115
|
||||
packageName: Asset Store Publishing Tools
|
||||
packageVersion: 12.0.1
|
||||
assetPath: Packages/com.unity.asset-store-tools/Editor/Validator/Scripts/UI/Data/Serialization/ValidatorStateSettings.cs
|
||||
uploadId: 724584
|
||||
@@ -0,0 +1,137 @@
|
||||
using AssetStoreTools.Validator.Data;
|
||||
using AssetStoreTools.Validator.TestDefinitions;
|
||||
using AssetStoreTools.Validator.UI.Data.Serialization;
|
||||
using AssetStoreTools.Validator.Utility;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace AssetStoreTools.Validator.UI.Data
|
||||
{
|
||||
internal class ValidatorResults : IValidatorResults
|
||||
{
|
||||
private ValidatorStateResults _stateData;
|
||||
|
||||
private IValidatorSettings _settings;
|
||||
private IEnumerable<IValidatorTest> _tests;
|
||||
|
||||
private readonly TestResultStatus[] _priorityGroups = new TestResultStatus[]
|
||||
{
|
||||
TestResultStatus.Undefined,
|
||||
TestResultStatus.Fail,
|
||||
TestResultStatus.Warning
|
||||
};
|
||||
|
||||
public event Action OnResultsChanged;
|
||||
public event Action OnRequireSerialize;
|
||||
|
||||
public ValidatorResults(IValidatorSettings settings, ValidatorStateResults stateData)
|
||||
{
|
||||
_settings = settings;
|
||||
_stateData = stateData;
|
||||
|
||||
_tests = GetAllTests();
|
||||
|
||||
Deserialize();
|
||||
}
|
||||
|
||||
private IEnumerable<IValidatorTest> GetAllTests()
|
||||
{
|
||||
var tests = new List<IValidatorTest>();
|
||||
var testObjects = ValidatorUtility.GetAutomatedTestCases(ValidatorUtility.SortType.Alphabetical);
|
||||
|
||||
foreach (var testObject in testObjects)
|
||||
{
|
||||
var testSource = new AutomatedTest(testObject);
|
||||
var test = new ValidatorTest(testSource);
|
||||
tests.Add(test);
|
||||
}
|
||||
|
||||
return tests;
|
||||
}
|
||||
|
||||
public void LoadResult(ValidationResult result)
|
||||
{
|
||||
if (result == null)
|
||||
return;
|
||||
|
||||
foreach (var test in _tests)
|
||||
{
|
||||
if (!result.Tests.Any(x => x.Id == test.Id))
|
||||
continue;
|
||||
|
||||
var matchingResult = result.Tests.First(x => x.Id == test.Id);
|
||||
test.SetResult(matchingResult.Result);
|
||||
}
|
||||
|
||||
OnResultsChanged?.Invoke();
|
||||
|
||||
Serialize(result);
|
||||
}
|
||||
|
||||
public IEnumerable<IValidatorTestGroup> GetSortedTestGroups()
|
||||
{
|
||||
var groups = new List<IValidatorTestGroup>();
|
||||
var testsByStatus = _tests
|
||||
.Where(x => x.ValidationType == ValidationType.Generic || x.ValidationType == _settings.GetValidationType())
|
||||
.GroupBy(x => x.Result.Status).ToDictionary(x => x.Key, x => x.ToList());
|
||||
|
||||
foreach (var kvp in testsByStatus)
|
||||
{
|
||||
var group = new ValidatorTestGroup(kvp.Key, kvp.Value);
|
||||
groups.Add(group);
|
||||
}
|
||||
|
||||
return SortGroups(groups);
|
||||
}
|
||||
|
||||
private IEnumerable<IValidatorTestGroup> SortGroups(IEnumerable<IValidatorTestGroup> unsortedGroups)
|
||||
{
|
||||
var sortedGroups = new List<IValidatorTestGroup>();
|
||||
var groups = unsortedGroups.OrderBy(x => x.Status).ToList();
|
||||
|
||||
// Select priority groups first
|
||||
foreach (var priority in _priorityGroups)
|
||||
{
|
||||
var priorityGroup = groups.FirstOrDefault(x => x.Status == priority);
|
||||
if (priorityGroup == null)
|
||||
continue;
|
||||
|
||||
sortedGroups.Add(priorityGroup);
|
||||
groups.Remove(priorityGroup);
|
||||
}
|
||||
|
||||
// Add the rest
|
||||
sortedGroups.AddRange(groups);
|
||||
|
||||
return sortedGroups;
|
||||
}
|
||||
|
||||
private void Serialize(ValidationResult result)
|
||||
{
|
||||
_stateData.SetStatus(result.Status);
|
||||
_stateData.SetResults(result.Tests);
|
||||
_stateData.SetProjectPath(result.ProjectPath);
|
||||
_stateData.SetHadCompilationErrors(result.HadCompilationErrors);
|
||||
OnRequireSerialize?.Invoke();
|
||||
}
|
||||
|
||||
private void Deserialize()
|
||||
{
|
||||
if (_stateData == null)
|
||||
return;
|
||||
|
||||
var serializedResults = _stateData.GetResults();
|
||||
foreach (var test in _tests)
|
||||
{
|
||||
if (!serializedResults.Any(x => x.Key == test.Id))
|
||||
continue;
|
||||
|
||||
var matchingResult = serializedResults.First(x => x.Key == test.Id);
|
||||
test.SetResult(matchingResult.Value);
|
||||
}
|
||||
|
||||
OnResultsChanged?.Invoke();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bf2839f8b2340294aae39c2965039d2a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 115
|
||||
packageName: Asset Store Publishing Tools
|
||||
packageVersion: 12.0.1
|
||||
assetPath: Packages/com.unity.asset-store-tools/Editor/Validator/Scripts/UI/Data/ValidatorResults.cs
|
||||
uploadId: 724584
|
||||
@@ -0,0 +1,236 @@
|
||||
using AssetStoreTools.Utility;
|
||||
using AssetStoreTools.Validator.Data;
|
||||
using AssetStoreTools.Validator.UI.Data.Serialization;
|
||||
using AssetStoreTools.Validator.Utility;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
|
||||
namespace AssetStoreTools.Validator.UI.Data
|
||||
{
|
||||
internal class ValidatorSettings : IValidatorSettings
|
||||
{
|
||||
private ValidatorStateSettings _stateData;
|
||||
|
||||
private string _category;
|
||||
private ValidationType _validationType;
|
||||
private List<string> _validationPaths;
|
||||
|
||||
public event Action OnCategoryChanged;
|
||||
public event Action OnValidationTypeChanged;
|
||||
public event Action OnValidationPathsChanged;
|
||||
public event Action OnRequireSerialize;
|
||||
|
||||
public ValidatorSettings(ValidatorStateSettings stateData)
|
||||
{
|
||||
_stateData = stateData;
|
||||
|
||||
_category = string.Empty;
|
||||
_validationType = ValidationType.UnityPackage;
|
||||
_validationPaths = new List<string>();
|
||||
|
||||
Deserialize();
|
||||
}
|
||||
|
||||
public void LoadSettings(ValidationSettings settings)
|
||||
{
|
||||
if (settings == null)
|
||||
return;
|
||||
|
||||
var currentProjectValidationSettings = settings as CurrentProjectValidationSettings;
|
||||
if (currentProjectValidationSettings == null)
|
||||
throw new ArgumentException($"Only {nameof(CurrentProjectValidationSettings)} can be loaded");
|
||||
|
||||
_category = currentProjectValidationSettings.Category;
|
||||
OnCategoryChanged?.Invoke();
|
||||
|
||||
_validationType = currentProjectValidationSettings.ValidationType;
|
||||
OnValidationTypeChanged?.Invoke();
|
||||
|
||||
_validationPaths = currentProjectValidationSettings.ValidationPaths.ToList();
|
||||
OnValidationPathsChanged?.Invoke();
|
||||
|
||||
Serialize();
|
||||
}
|
||||
|
||||
public string GetActiveCategory()
|
||||
{
|
||||
return _category;
|
||||
}
|
||||
|
||||
public void SetActiveCategory(string category)
|
||||
{
|
||||
if (category == _category)
|
||||
return;
|
||||
|
||||
_category = category;
|
||||
Serialize();
|
||||
OnCategoryChanged?.Invoke();
|
||||
}
|
||||
|
||||
public List<string> GetAvailableCategories()
|
||||
{
|
||||
var categories = new HashSet<string>();
|
||||
|
||||
var testData = ValidatorUtility.GetAutomatedTestCases();
|
||||
foreach (var test in testData)
|
||||
{
|
||||
if (test.CategoryInfo == null)
|
||||
continue;
|
||||
|
||||
foreach (var filter in test.CategoryInfo.Filter)
|
||||
categories.Add(ConvertSlashToUnicodeSlash(filter));
|
||||
}
|
||||
|
||||
return categories.OrderBy(x => x).ToList();
|
||||
}
|
||||
|
||||
private string ConvertSlashToUnicodeSlash(string text)
|
||||
{
|
||||
return text.Replace('/', '\u2215');
|
||||
}
|
||||
|
||||
public ValidationType GetValidationType()
|
||||
{
|
||||
return _validationType;
|
||||
}
|
||||
|
||||
public void SetValidationType(ValidationType validationType)
|
||||
{
|
||||
if (validationType == _validationType)
|
||||
return;
|
||||
|
||||
_validationType = validationType;
|
||||
|
||||
Serialize();
|
||||
OnValidationTypeChanged?.Invoke();
|
||||
}
|
||||
|
||||
public List<string> GetValidationPaths()
|
||||
{
|
||||
return _validationPaths;
|
||||
}
|
||||
|
||||
public void AddValidationPath(string path)
|
||||
{
|
||||
if (string.IsNullOrEmpty(path))
|
||||
return;
|
||||
|
||||
if (_validationPaths.Contains(path))
|
||||
return;
|
||||
|
||||
// Prevent redundancy for new paths
|
||||
var existingPath = _validationPaths.FirstOrDefault(x => path.StartsWith(x + "/"));
|
||||
if (existingPath != null)
|
||||
{
|
||||
Debug.LogWarning($"Path '{path}' is already included with existing path: '{existingPath}'");
|
||||
return;
|
||||
}
|
||||
|
||||
// Prevent redundancy for already added paths
|
||||
var redundantPaths = _validationPaths.Where(x => x.StartsWith(path + "/")).ToArray();
|
||||
foreach (var redundantPath in redundantPaths)
|
||||
{
|
||||
Debug.LogWarning($"Existing validation path '{redundantPath}' has been made redundant by the inclusion of new validation path: '{path}'");
|
||||
_validationPaths.Remove(redundantPath);
|
||||
}
|
||||
|
||||
_validationPaths.Add(path);
|
||||
|
||||
Serialize();
|
||||
OnValidationPathsChanged?.Invoke();
|
||||
}
|
||||
|
||||
public void RemoveValidationPath(string path)
|
||||
{
|
||||
if (!_validationPaths.Contains(path))
|
||||
return;
|
||||
|
||||
_validationPaths.Remove(path);
|
||||
|
||||
Serialize();
|
||||
OnValidationPathsChanged?.Invoke();
|
||||
}
|
||||
|
||||
public void ClearValidationPaths()
|
||||
{
|
||||
if (_validationPaths.Count == 0)
|
||||
return;
|
||||
|
||||
_validationPaths.Clear();
|
||||
|
||||
Serialize();
|
||||
OnValidationPathsChanged?.Invoke();
|
||||
}
|
||||
|
||||
public bool IsValidationPathValid(string path, out string error)
|
||||
{
|
||||
error = string.Empty;
|
||||
|
||||
if (string.IsNullOrEmpty(path))
|
||||
{
|
||||
error = "Path cannot be empty";
|
||||
return false;
|
||||
}
|
||||
|
||||
var isAssetsPath = path.StartsWith("Assets/")
|
||||
|| path.Equals("Assets");
|
||||
var isPackagePath = PackageUtility.GetPackageByManifestPath($"{path}/package.json", out _);
|
||||
|
||||
if (!isAssetsPath && !isPackagePath)
|
||||
{
|
||||
error = "Selected path must be within the Assets folder or point to a root path of a package";
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!Directory.Exists(path))
|
||||
{
|
||||
error = "Path does not exist";
|
||||
return false;
|
||||
}
|
||||
|
||||
if (path.Split('/').Any(x => x.StartsWith(".") || x.EndsWith("~")))
|
||||
{
|
||||
error = $"Path '{path}' cannot be validated as it is a hidden folder and not part of the Asset Database";
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public IValidator CreateValidator()
|
||||
{
|
||||
var settings = new CurrentProjectValidationSettings()
|
||||
{
|
||||
Category = _category,
|
||||
ValidationType = _validationType,
|
||||
ValidationPaths = _validationPaths
|
||||
};
|
||||
|
||||
var validator = new CurrentProjectValidator(settings);
|
||||
return validator;
|
||||
}
|
||||
|
||||
private void Serialize()
|
||||
{
|
||||
_stateData.SetCategory(_category);
|
||||
_stateData.SetValidationType(_validationType);
|
||||
_stateData.SetValidationPaths(_validationPaths);
|
||||
|
||||
OnRequireSerialize?.Invoke();
|
||||
}
|
||||
|
||||
private void Deserialize()
|
||||
{
|
||||
if (_stateData == null)
|
||||
return;
|
||||
|
||||
_category = _stateData.GetCategory();
|
||||
_validationType = _stateData.GetValidationType();
|
||||
foreach (var path in _stateData.GetValidationPaths())
|
||||
_validationPaths.Add(path);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 89504c2259614a743a164c5c162a197a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 115
|
||||
packageName: Asset Store Publishing Tools
|
||||
packageVersion: 12.0.1
|
||||
assetPath: Packages/com.unity.asset-store-tools/Editor/Validator/Scripts/UI/Data/ValidatorSettings.cs
|
||||
uploadId: 724584
|
||||
@@ -0,0 +1,28 @@
|
||||
using AssetStoreTools.Validator.Data;
|
||||
using AssetStoreTools.Validator.TestDefinitions;
|
||||
|
||||
namespace AssetStoreTools.Validator.UI.Data
|
||||
{
|
||||
internal class ValidatorTest : IValidatorTest
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
public string Name { get; private set; }
|
||||
public string Description { get; private set; }
|
||||
public ValidationType ValidationType { get; private set; }
|
||||
public TestResult Result { get; private set; }
|
||||
|
||||
public ValidatorTest(AutomatedTest source)
|
||||
{
|
||||
Id = source.Id;
|
||||
Name = source.Title;
|
||||
Description = source.Description;
|
||||
ValidationType = source.ValidationType;
|
||||
Result = source.Result;
|
||||
}
|
||||
|
||||
public void SetResult(TestResult result)
|
||||
{
|
||||
Result = result;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 838e8d45ce997d8489185bc194dfcf25
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 115
|
||||
packageName: Asset Store Publishing Tools
|
||||
packageVersion: 12.0.1
|
||||
assetPath: Packages/com.unity.asset-store-tools/Editor/Validator/Scripts/UI/Data/ValidatorTest.cs
|
||||
uploadId: 724584
|
||||
@@ -0,0 +1,18 @@
|
||||
using AssetStoreTools.Validator.Data;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace AssetStoreTools.Validator.UI.Data
|
||||
{
|
||||
internal class ValidatorTestGroup : IValidatorTestGroup
|
||||
{
|
||||
public string Name => Status.ToString();
|
||||
public TestResultStatus Status { get; private set; }
|
||||
public IEnumerable<IValidatorTest> Tests { get; private set; }
|
||||
|
||||
public ValidatorTestGroup(TestResultStatus status, IEnumerable<IValidatorTest> tests)
|
||||
{
|
||||
Status = status;
|
||||
Tests = tests;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8f5d1fc9ff785904fb2e663e9232a7a5
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 115
|
||||
packageName: Asset Store Publishing Tools
|
||||
packageVersion: 12.0.1
|
||||
assetPath: Packages/com.unity.asset-store-tools/Editor/Validator/Scripts/UI/Data/ValidatorTestGroup.cs
|
||||
uploadId: 724584
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7ee7e5be29b8b184ba2abcd3ed38454e
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,50 @@
|
||||
using AssetStoreTools.Validator.UI.Data;
|
||||
using System;
|
||||
using UnityEngine.UIElements;
|
||||
|
||||
namespace AssetStoreTools.Validator.UI.Elements
|
||||
{
|
||||
internal class ValidatorButtonElement : VisualElement
|
||||
{
|
||||
// Data
|
||||
private IValidatorSettings _settings;
|
||||
|
||||
// UI
|
||||
private Button _validateButton;
|
||||
|
||||
public event Action OnValidate;
|
||||
|
||||
public ValidatorButtonElement(IValidatorSettings settings)
|
||||
{
|
||||
_settings = settings;
|
||||
_settings.OnValidationPathsChanged += ValidationPathsChanged;
|
||||
|
||||
Create();
|
||||
Deserialize();
|
||||
}
|
||||
|
||||
private void Create()
|
||||
{
|
||||
_validateButton = new Button(Validate) { text = "Validate" };
|
||||
_validateButton.AddToClassList("validator-validate-button");
|
||||
|
||||
Add(_validateButton);
|
||||
}
|
||||
|
||||
private void Validate()
|
||||
{
|
||||
OnValidate?.Invoke();
|
||||
}
|
||||
|
||||
private void ValidationPathsChanged()
|
||||
{
|
||||
var validationPathsPresent = _settings.GetValidationPaths().Count > 0;
|
||||
_validateButton.SetEnabled(validationPathsPresent);
|
||||
}
|
||||
|
||||
private void Deserialize()
|
||||
{
|
||||
ValidationPathsChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 44fac105314df6341bf6a70fb3200baf
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 115
|
||||
packageName: Asset Store Publishing Tools
|
||||
packageVersion: 12.0.1
|
||||
assetPath: Packages/com.unity.asset-store-tools/Editor/Validator/Scripts/UI/Elements/ValidatorButtonElement.cs
|
||||
uploadId: 724584
|
||||
@@ -0,0 +1,114 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.UIElements;
|
||||
|
||||
namespace AssetStoreTools.Validator.UI.Elements
|
||||
{
|
||||
internal class ValidatorDescriptionElement : VisualElement
|
||||
{
|
||||
private const string DescriptionFoldoutText = "Validate your package to ensure your content follows the chosen submission guidelines.";
|
||||
private const string DescriptionFoldoutContentText = "The validations below do not cover all of the content standards, and passing all validations does not " +
|
||||
"guarantee that your package will be accepted to the Asset Store.\n\n" +
|
||||
"The tests are not obligatory for submitting your assets, but they can help avoid instant rejection by the " +
|
||||
"automated vetting system, or clarify reasons of rejection communicated by the vetting team.\n\n" +
|
||||
"For more information about the validations, view the message by expanding the tests or contact our support team.";
|
||||
|
||||
private VisualElement _descriptionSimpleContainer;
|
||||
private Label _descriptionSimpleLabel;
|
||||
private Button _showMoreButton;
|
||||
|
||||
private VisualElement _descriptionFullContainer;
|
||||
private Button _showLessButton;
|
||||
|
||||
public ValidatorDescriptionElement()
|
||||
{
|
||||
AddToClassList("validator-description");
|
||||
Create();
|
||||
}
|
||||
|
||||
private void Create()
|
||||
{
|
||||
CreateSimpleDescription();
|
||||
CreateFullDescription();
|
||||
}
|
||||
|
||||
private void CreateSimpleDescription()
|
||||
{
|
||||
_descriptionSimpleContainer = new VisualElement();
|
||||
_descriptionSimpleContainer.AddToClassList("validator-description-simple-container");
|
||||
|
||||
_descriptionSimpleLabel = new Label(DescriptionFoldoutText);
|
||||
_descriptionSimpleLabel.AddToClassList("validator-description-simple-label");
|
||||
|
||||
_showMoreButton = new Button(ToggleFullDescription) { text = "Show more..." };
|
||||
_showMoreButton.AddToClassList("validator-description-show-button");
|
||||
_showMoreButton.AddToClassList("validator-description-hyperlink-button");
|
||||
|
||||
_descriptionSimpleContainer.Add(_descriptionSimpleLabel);
|
||||
_descriptionSimpleContainer.Add(_showMoreButton);
|
||||
|
||||
Add(_descriptionSimpleContainer);
|
||||
}
|
||||
|
||||
private void CreateFullDescription()
|
||||
{
|
||||
_descriptionFullContainer = new VisualElement();
|
||||
_descriptionFullContainer.AddToClassList("validator-description-full-container");
|
||||
|
||||
var validatorDescription = new Label()
|
||||
{
|
||||
text = DescriptionFoldoutContentText
|
||||
};
|
||||
validatorDescription.AddToClassList("validator-description-full-label");
|
||||
|
||||
var submissionGuidelinesButton = new Button(OpenSubmissionGuidelinesUrl)
|
||||
{
|
||||
text = "Submission Guidelines"
|
||||
};
|
||||
submissionGuidelinesButton.AddToClassList("validator-description-hyperlink-button");
|
||||
|
||||
var supportTicketButton = new Button(OpenSupportTicketUrl)
|
||||
{
|
||||
text = "Contact our Support Team"
|
||||
};
|
||||
supportTicketButton.AddToClassList("validator-description-hyperlink-button");
|
||||
|
||||
_showLessButton = new Button(ToggleFullDescription) { text = "Show less..." };
|
||||
_showLessButton.AddToClassList("validator-description-hide-button");
|
||||
_showLessButton.AddToClassList("validator-description-hyperlink-button");
|
||||
|
||||
_descriptionFullContainer.Add(validatorDescription);
|
||||
_descriptionFullContainer.Add(submissionGuidelinesButton);
|
||||
_descriptionFullContainer.Add(supportTicketButton);
|
||||
_descriptionFullContainer.Add(_showLessButton);
|
||||
|
||||
_descriptionFullContainer.style.display = DisplayStyle.None;
|
||||
Add(_descriptionFullContainer);
|
||||
}
|
||||
|
||||
private void ToggleFullDescription()
|
||||
{
|
||||
var displayFullDescription = _descriptionFullContainer.style.display == DisplayStyle.None;
|
||||
|
||||
if (displayFullDescription)
|
||||
{
|
||||
_showMoreButton.style.display = DisplayStyle.None;
|
||||
_descriptionFullContainer.style.display = DisplayStyle.Flex;
|
||||
}
|
||||
else
|
||||
{
|
||||
_showMoreButton.style.display = DisplayStyle.Flex;
|
||||
_descriptionFullContainer.style.display = DisplayStyle.None;
|
||||
}
|
||||
}
|
||||
|
||||
private void OpenSubmissionGuidelinesUrl()
|
||||
{
|
||||
Application.OpenURL(Constants.Validator.SubmissionGuidelinesUrl);
|
||||
}
|
||||
|
||||
private void OpenSupportTicketUrl()
|
||||
{
|
||||
Application.OpenURL(Constants.Validator.SupportTicketUrl);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9866d77420d947ba852055eed2bac895
|
||||
timeCreated: 1653383883
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 115
|
||||
packageName: Asset Store Publishing Tools
|
||||
packageVersion: 12.0.1
|
||||
assetPath: Packages/com.unity.asset-store-tools/Editor/Validator/Scripts/UI/Elements/ValidatorDescriptionElement.cs
|
||||
uploadId: 724584
|
||||
@@ -0,0 +1,128 @@
|
||||
using AssetStoreTools.Utility;
|
||||
using AssetStoreTools.Validator.UI.Data;
|
||||
using UnityEditor;
|
||||
using UnityEngine.UIElements;
|
||||
|
||||
namespace AssetStoreTools.Validator.UI.Elements
|
||||
{
|
||||
internal class ValidatorPathsElement : VisualElement
|
||||
{
|
||||
// Data
|
||||
private IValidatorSettings _settings;
|
||||
|
||||
// UI
|
||||
private ScrollView _pathBoxScrollView;
|
||||
|
||||
public ValidatorPathsElement(IValidatorSettings settings)
|
||||
{
|
||||
AddToClassList("validator-paths");
|
||||
|
||||
_settings = settings;
|
||||
_settings.OnValidationPathsChanged += ValidationPathsChanged;
|
||||
|
||||
Create();
|
||||
Deserialize();
|
||||
}
|
||||
|
||||
private void Create()
|
||||
{
|
||||
var pathSelectionRow = new VisualElement();
|
||||
pathSelectionRow.AddToClassList("validator-settings-selection-row");
|
||||
|
||||
VisualElement labelHelpRow = new VisualElement();
|
||||
labelHelpRow.AddToClassList("validator-settings-selection-label-help-row");
|
||||
labelHelpRow.style.alignSelf = Align.FlexStart;
|
||||
|
||||
Label pathLabel = new Label { text = "Validation paths" };
|
||||
Image pathLabelTooltip = new Image
|
||||
{
|
||||
tooltip = "Select the folder (or multiple folders) that your package consists of." +
|
||||
"\n\nAll files and folders of your package should be contained within " +
|
||||
"a single root folder that is named after your package " +
|
||||
"(e.g. 'Assets/[MyPackageName]' or 'Packages/[MyPackageName]')" +
|
||||
"\n\nIf your package includes special folders that cannot be nested within " +
|
||||
"the root package folder (e.g. 'WebGLTemplates'), they should be added to this list " +
|
||||
"together with the root package folder"
|
||||
};
|
||||
|
||||
labelHelpRow.Add(pathLabel);
|
||||
labelHelpRow.Add(pathLabelTooltip);
|
||||
|
||||
var fullPathBox = new VisualElement() { name = "ValidationPaths" };
|
||||
fullPathBox.AddToClassList("validator-paths-box");
|
||||
|
||||
_pathBoxScrollView = new ScrollView { name = "ValidationPathsScrollView" };
|
||||
_pathBoxScrollView.AddToClassList("validator-paths-scroll-view");
|
||||
|
||||
VisualElement scrollViewBottomRow = new VisualElement();
|
||||
scrollViewBottomRow.AddToClassList("validator-paths-scroll-view-bottom-row");
|
||||
|
||||
var addExtraPathsButton = new Button(BrowsePath) { text = "Add a path" };
|
||||
addExtraPathsButton.AddToClassList("validator-paths-add-button");
|
||||
scrollViewBottomRow.Add(addExtraPathsButton);
|
||||
|
||||
fullPathBox.Add(_pathBoxScrollView);
|
||||
fullPathBox.Add(scrollViewBottomRow);
|
||||
|
||||
pathSelectionRow.Add(labelHelpRow);
|
||||
pathSelectionRow.Add(fullPathBox);
|
||||
|
||||
Add(pathSelectionRow);
|
||||
}
|
||||
|
||||
private VisualElement CreateSinglePathElement(string path)
|
||||
{
|
||||
var validationPath = new VisualElement();
|
||||
validationPath.AddToClassList("validator-paths-path-row");
|
||||
|
||||
var folderPathLabel = new Label(path);
|
||||
folderPathLabel.AddToClassList("validator-paths-path-row-input-field");
|
||||
|
||||
var removeButton = new Button(() =>
|
||||
{
|
||||
_settings.RemoveValidationPath(path);
|
||||
});
|
||||
removeButton.text = "X";
|
||||
removeButton.AddToClassList("validator-paths-path-row-remove-button");
|
||||
|
||||
validationPath.Add(folderPathLabel);
|
||||
validationPath.Add(removeButton);
|
||||
|
||||
return validationPath;
|
||||
}
|
||||
|
||||
private void BrowsePath()
|
||||
{
|
||||
string absolutePath = EditorUtility.OpenFolderPanel("Select a directory", "Assets", "");
|
||||
|
||||
if (string.IsNullOrEmpty(absolutePath))
|
||||
return;
|
||||
|
||||
var relativePath = FileUtility.AbsolutePathToRelativePath(absolutePath, ASToolsPreferences.Instance.EnableSymlinkSupport);
|
||||
|
||||
if (!_settings.IsValidationPathValid(relativePath, out var error))
|
||||
{
|
||||
EditorUtility.DisplayDialog("Invalid path", error, "OK");
|
||||
return;
|
||||
}
|
||||
|
||||
_settings.AddValidationPath(relativePath);
|
||||
}
|
||||
|
||||
private void ValidationPathsChanged()
|
||||
{
|
||||
var validationPaths = _settings.GetValidationPaths();
|
||||
|
||||
_pathBoxScrollView.Clear();
|
||||
foreach (var path in validationPaths)
|
||||
{
|
||||
_pathBoxScrollView.Add(CreateSinglePathElement(path));
|
||||
}
|
||||
}
|
||||
|
||||
private void Deserialize()
|
||||
{
|
||||
ValidationPathsChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 370dcd3bc87ace647940b4b07147bf93
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 115
|
||||
packageName: Asset Store Publishing Tools
|
||||
packageVersion: 12.0.1
|
||||
assetPath: Packages/com.unity.asset-store-tools/Editor/Validator/Scripts/UI/Elements/ValidatorPathsElement.cs
|
||||
uploadId: 724584
|
||||
@@ -0,0 +1,47 @@
|
||||
using AssetStoreTools.Validator.UI.Data;
|
||||
using System.Linq;
|
||||
using UnityEngine.UIElements;
|
||||
|
||||
namespace AssetStoreTools.Validator.UI.Elements
|
||||
{
|
||||
internal class ValidatorResultsElement : ScrollView
|
||||
{
|
||||
private IValidatorResults _results;
|
||||
|
||||
public ValidatorResultsElement(IValidatorResults results)
|
||||
{
|
||||
AddToClassList("validator-test-list");
|
||||
|
||||
_results = results;
|
||||
_results.OnResultsChanged += ResultsChanged;
|
||||
|
||||
Create();
|
||||
}
|
||||
|
||||
private void Create()
|
||||
{
|
||||
var groups = _results.GetSortedTestGroups().ToList();
|
||||
for (int i = 0; i < groups.Count; i++)
|
||||
{
|
||||
var groupElement = new ValidatorTestGroupElement(groups[i]);
|
||||
Add(groupElement);
|
||||
if (i != groups.Count - 1)
|
||||
Add(CreateSeparator());
|
||||
}
|
||||
}
|
||||
|
||||
private void ResultsChanged()
|
||||
{
|
||||
Clear();
|
||||
Create();
|
||||
}
|
||||
|
||||
private VisualElement CreateSeparator()
|
||||
{
|
||||
var groupSeparator = new VisualElement { name = "GroupSeparator" };
|
||||
groupSeparator.AddToClassList("validator-test-list-group-separator");
|
||||
|
||||
return groupSeparator;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 12f80f9088944a149a34b3f078ca859a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 115
|
||||
packageName: Asset Store Publishing Tools
|
||||
packageVersion: 12.0.1
|
||||
assetPath: Packages/com.unity.asset-store-tools/Editor/Validator/Scripts/UI/Elements/ValidatorResultsElement.cs
|
||||
uploadId: 724584
|
||||
@@ -0,0 +1,96 @@
|
||||
using AssetStoreTools.Validator.UI.Data;
|
||||
using UnityEditor.UIElements;
|
||||
using UnityEngine.UIElements;
|
||||
|
||||
namespace AssetStoreTools.Validator.UI.Elements
|
||||
{
|
||||
internal class ValidatorSettingsElement : VisualElement
|
||||
{
|
||||
// Data
|
||||
private IValidatorSettings _settings;
|
||||
|
||||
// UI
|
||||
private ToolbarMenu _categoryMenu;
|
||||
private ValidatorPathsElement _validationPathsElement;
|
||||
|
||||
public ValidatorSettingsElement(IValidatorSettings settings)
|
||||
{
|
||||
AddToClassList("validator-settings");
|
||||
|
||||
_settings = settings;
|
||||
_settings.OnCategoryChanged += CategoryChanged;
|
||||
|
||||
Create();
|
||||
Deserialize();
|
||||
}
|
||||
|
||||
public void Create()
|
||||
{
|
||||
CreateCategorySelection();
|
||||
CreateValidationPathSelection();
|
||||
}
|
||||
|
||||
private void CreateCategorySelection()
|
||||
{
|
||||
var categorySelectionBox = new VisualElement();
|
||||
categorySelectionBox.AddToClassList("validator-settings-selection-row");
|
||||
|
||||
VisualElement labelHelpRow = new VisualElement();
|
||||
labelHelpRow.AddToClassList("validator-settings-selection-label-help-row");
|
||||
|
||||
Label categoryLabel = new Label { text = "Category" };
|
||||
Image categoryLabelTooltip = new Image
|
||||
{
|
||||
tooltip = "Choose a base category of your package" +
|
||||
"\n\nThis can be found in the Publishing Portal when creating the package listing or just " +
|
||||
"selecting a planned one." +
|
||||
"\n\nNote: Different categories could have different severities of several test cases."
|
||||
};
|
||||
|
||||
labelHelpRow.Add(categoryLabel);
|
||||
labelHelpRow.Add(categoryLabelTooltip);
|
||||
|
||||
_categoryMenu = new ToolbarMenu { name = "CategoryMenu" };
|
||||
_categoryMenu.AddToClassList("validator-settings-selection-dropdown");
|
||||
|
||||
categorySelectionBox.Add(labelHelpRow);
|
||||
categorySelectionBox.Add(_categoryMenu);
|
||||
|
||||
// Append available categories
|
||||
var categories = _settings.GetAvailableCategories();
|
||||
foreach (var category in categories)
|
||||
{
|
||||
_categoryMenu.menu.AppendAction(category, _ => _settings.SetActiveCategory(category));
|
||||
}
|
||||
|
||||
// Append misc category
|
||||
_categoryMenu.menu.AppendAction("Other", _ => _settings.SetActiveCategory(string.Empty));
|
||||
|
||||
Add(categorySelectionBox);
|
||||
}
|
||||
|
||||
private void CreateValidationPathSelection()
|
||||
{
|
||||
_validationPathsElement = new ValidatorPathsElement(_settings);
|
||||
Add(_validationPathsElement);
|
||||
}
|
||||
|
||||
private void CategoryChanged()
|
||||
{
|
||||
var category = _settings.GetActiveCategory();
|
||||
if (!string.IsNullOrEmpty(category))
|
||||
_categoryMenu.text = category;
|
||||
else
|
||||
_categoryMenu.text = "Other";
|
||||
}
|
||||
|
||||
private void Deserialize()
|
||||
{
|
||||
if (_settings == null)
|
||||
return;
|
||||
|
||||
// Set initial category
|
||||
CategoryChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 760d25556d755d544bece3a605adea09
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 115
|
||||
packageName: Asset Store Publishing Tools
|
||||
packageVersion: 12.0.1
|
||||
assetPath: Packages/com.unity.asset-store-tools/Editor/Validator/Scripts/UI/Elements/ValidatorSettingsElement.cs
|
||||
uploadId: 724584
|
||||
@@ -0,0 +1,239 @@
|
||||
using AssetStoreTools.Validator.Data;
|
||||
using AssetStoreTools.Validator.UI.Data;
|
||||
using AssetStoreTools.Validator.Utility;
|
||||
using System.Linq;
|
||||
using UnityEditor.SceneManagement;
|
||||
using UnityEditor.UIElements;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
using UnityEngine.SceneManagement;
|
||||
using UnityEngine.UIElements;
|
||||
|
||||
namespace AssetStoreTools.Validator.UI.Elements
|
||||
{
|
||||
internal class ValidatorTestElement : VisualElement
|
||||
{
|
||||
// Data
|
||||
private IValidatorTest _test;
|
||||
private bool _isExpanded;
|
||||
|
||||
// UI
|
||||
private Button _testFoldoutButton;
|
||||
private Label _testFoldoutExpandStateLabel;
|
||||
private Label _testFoldoutLabel;
|
||||
private Image _testStatusImage;
|
||||
|
||||
private VisualElement _testContent;
|
||||
private VisualElement _resultMessagesBox;
|
||||
|
||||
public ValidatorTestElement(IValidatorTest test)
|
||||
{
|
||||
AddToClassList("validator-test");
|
||||
|
||||
_test = test;
|
||||
|
||||
Create();
|
||||
Unexpand();
|
||||
|
||||
SubscribeToSceneChanges();
|
||||
}
|
||||
|
||||
private void Create()
|
||||
{
|
||||
CreateFoldoutButton();
|
||||
CreateTestContent();
|
||||
CreateTestDescription();
|
||||
CreateTestMessages();
|
||||
}
|
||||
|
||||
private void CreateFoldoutButton()
|
||||
{
|
||||
_testFoldoutButton = new Button(ToggleExpand) { name = _test.Name };
|
||||
_testFoldoutButton.AddToClassList("validator-test-foldout");
|
||||
|
||||
// Expander and Asset Label
|
||||
VisualElement labelExpanderRow = new VisualElement { name = "labelExpanderRow" };
|
||||
labelExpanderRow.AddToClassList("validator-test-expander");
|
||||
|
||||
_testFoldoutExpandStateLabel = new Label { name = "ExpanderLabel", text = "►" };
|
||||
_testFoldoutExpandStateLabel.AddToClassList("validator-test-expander-arrow");
|
||||
|
||||
_testFoldoutLabel = new Label { name = "TestLabel", text = _test.Name };
|
||||
_testFoldoutLabel.AddToClassList("validator-text-expander-label");
|
||||
|
||||
labelExpanderRow.Add(_testFoldoutExpandStateLabel);
|
||||
labelExpanderRow.Add(_testFoldoutLabel);
|
||||
|
||||
_testStatusImage = new Image
|
||||
{
|
||||
name = "TestImage",
|
||||
image = ValidatorUtility.GetStatusTexture(_test.Result.Status)
|
||||
};
|
||||
|
||||
_testStatusImage.AddToClassList("validator-test-expander-image");
|
||||
|
||||
_testFoldoutButton.Add(labelExpanderRow);
|
||||
_testFoldoutButton.Add(_testStatusImage);
|
||||
|
||||
Add(_testFoldoutButton);
|
||||
}
|
||||
|
||||
private void CreateTestContent()
|
||||
{
|
||||
_testContent = new VisualElement();
|
||||
_testContent.AddToClassList("validator-test-content");
|
||||
Add(_testContent);
|
||||
}
|
||||
|
||||
private void CreateTestDescription()
|
||||
{
|
||||
var testCaseDescription = new TextField
|
||||
{
|
||||
name = "Description",
|
||||
value = _test.Description,
|
||||
isReadOnly = true,
|
||||
multiline = true,
|
||||
focusable = false,
|
||||
doubleClickSelectsWord = false,
|
||||
tripleClickSelectsLine = false
|
||||
};
|
||||
testCaseDescription.AddToClassList("validator-test-content-textfield");
|
||||
|
||||
#if UNITY_2022_1_OR_NEWER
|
||||
testCaseDescription.focusable = true;
|
||||
testCaseDescription.selectAllOnFocus = false;
|
||||
testCaseDescription.selectAllOnMouseUp = false;
|
||||
#endif
|
||||
|
||||
_testContent.Add(testCaseDescription);
|
||||
}
|
||||
|
||||
private void CreateTestMessages()
|
||||
{
|
||||
if (_test.Result.MessageCount == 0)
|
||||
return;
|
||||
|
||||
_resultMessagesBox = new VisualElement();
|
||||
_resultMessagesBox.AddToClassList("validator-test-content-result-messages");
|
||||
|
||||
switch (_test.Result.Status)
|
||||
{
|
||||
case TestResultStatus.Pass:
|
||||
_resultMessagesBox.AddToClassList("validator-test-content-result-messages-pass");
|
||||
break;
|
||||
case TestResultStatus.Warning:
|
||||
_resultMessagesBox.AddToClassList("validator-test-content-result-messages-warning");
|
||||
break;
|
||||
case TestResultStatus.Fail:
|
||||
_resultMessagesBox.AddToClassList("validator-test-content-result-messages-fail");
|
||||
break;
|
||||
}
|
||||
|
||||
for (int i = 0; i < _test.Result.MessageCount; i++)
|
||||
{
|
||||
_resultMessagesBox.Add(CreateMessage(_test.Result.GetMessage(i)));
|
||||
|
||||
if (i == _test.Result.MessageCount - 1)
|
||||
continue;
|
||||
|
||||
var separator = new VisualElement() { name = "Separator" };
|
||||
separator.AddToClassList("message-separator");
|
||||
_resultMessagesBox.Add(separator);
|
||||
}
|
||||
|
||||
_testContent.Add(_resultMessagesBox);
|
||||
}
|
||||
|
||||
private VisualElement CreateMessage(TestResultMessage message)
|
||||
{
|
||||
var resultText = message.GetText();
|
||||
var clickAction = message.GetClickAction();
|
||||
|
||||
var resultMessage = new VisualElement { name = "ResultMessageElement" };
|
||||
resultMessage.AddToClassList("validator-test-content-result-messages-content");
|
||||
|
||||
var informationButton = new Button();
|
||||
informationButton.AddToClassList("validator-test-content-result-messages-content-button");
|
||||
|
||||
if (clickAction != null)
|
||||
{
|
||||
informationButton.tooltip = clickAction.Tooltip;
|
||||
informationButton.clicked += clickAction.Execute;
|
||||
informationButton.SetEnabled(true);
|
||||
}
|
||||
|
||||
var informationDescription = new Label { name = "InfoDesc", text = resultText };
|
||||
informationDescription.AddToClassList("validator-test-content-result-messages-content-label");
|
||||
|
||||
informationButton.Add(informationDescription);
|
||||
resultMessage.Add(informationButton);
|
||||
|
||||
for (int i = 0; i < message.MessageObjectCount; i++)
|
||||
{
|
||||
var obj = message.GetMessageObject(i);
|
||||
if (obj == null)
|
||||
continue;
|
||||
|
||||
if (obj.GetObject() == null)
|
||||
continue;
|
||||
|
||||
var objectField = new ObjectField() { objectType = obj.GetType(), value = obj.GetObject() };
|
||||
objectField.RegisterCallback<ChangeEvent<UnityEngine.Object>>((evt) =>
|
||||
objectField.SetValueWithoutNotify(evt.previousValue));
|
||||
resultMessage.Add(objectField);
|
||||
}
|
||||
|
||||
return resultMessage;
|
||||
}
|
||||
|
||||
private void ToggleExpand()
|
||||
{
|
||||
if (!_isExpanded)
|
||||
Expand();
|
||||
else
|
||||
Unexpand();
|
||||
}
|
||||
|
||||
private void Expand()
|
||||
{
|
||||
_testFoldoutExpandStateLabel.text = "▼";
|
||||
_testFoldoutButton.AddToClassList("validator-test-foldout-expanded");
|
||||
_testContent.style.display = DisplayStyle.Flex;
|
||||
_isExpanded = true;
|
||||
}
|
||||
|
||||
private void Unexpand()
|
||||
{
|
||||
_testFoldoutExpandStateLabel.text = "►";
|
||||
_testFoldoutButton.RemoveFromClassList("validator-test-foldout-expanded");
|
||||
_testContent.style.display = DisplayStyle.None;
|
||||
_isExpanded = false;
|
||||
}
|
||||
|
||||
private void SubscribeToSceneChanges()
|
||||
{
|
||||
// Some result message objects only exist in specific scenes,
|
||||
// therefore the UI must be refreshed on scene change
|
||||
var windowToSubscribeTo = Resources.FindObjectsOfTypeAll<ValidatorWindow>().FirstOrDefault();
|
||||
UnityAction<Scene, Scene> sceneChanged = null;
|
||||
sceneChanged = new UnityAction<Scene, Scene>((_, __) => RefreshObjects(windowToSubscribeTo));
|
||||
EditorSceneManager.activeSceneChangedInEditMode += sceneChanged;
|
||||
|
||||
void RefreshObjects(ValidatorWindow subscribedWindow)
|
||||
{
|
||||
// Remove callback if validator window instance changed
|
||||
var activeWindow = Resources.FindObjectsOfTypeAll<ValidatorWindow>().FirstOrDefault();
|
||||
if (subscribedWindow == null || subscribedWindow != activeWindow)
|
||||
{
|
||||
EditorSceneManager.activeSceneChangedInEditMode -= sceneChanged;
|
||||
return;
|
||||
}
|
||||
|
||||
if (_resultMessagesBox != null)
|
||||
_testContent.Remove(_resultMessagesBox);
|
||||
|
||||
CreateTestMessages();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 56c93e6f23ba5724da8cc38f832be4e0
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 115
|
||||
packageName: Asset Store Publishing Tools
|
||||
packageVersion: 12.0.1
|
||||
assetPath: Packages/com.unity.asset-store-tools/Editor/Validator/Scripts/UI/Elements/ValidatorTestElement.cs
|
||||
uploadId: 724584
|
||||
@@ -0,0 +1,102 @@
|
||||
using AssetStoreTools.Validator.UI.Data;
|
||||
using AssetStoreTools.Validator.Utility;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UnityEngine.UIElements;
|
||||
|
||||
namespace AssetStoreTools.Validator.UI.Elements
|
||||
{
|
||||
internal class ValidatorTestGroupElement : VisualElement
|
||||
{
|
||||
// Data
|
||||
private IValidatorTestGroup _group;
|
||||
private bool _isExpanded;
|
||||
|
||||
// UI
|
||||
private Button _groupFoldoutButton;
|
||||
private Label _groupExpandStateLabel;
|
||||
private Label _groupFoldoutLabel;
|
||||
private Image _groupStatusImage;
|
||||
|
||||
private VisualElement _groupContent;
|
||||
private List<ValidatorTestElement> _testElements;
|
||||
|
||||
public ValidatorTestGroupElement(IValidatorTestGroup group)
|
||||
{
|
||||
AddToClassList("validator-test-list-group");
|
||||
|
||||
_group = group;
|
||||
|
||||
Create();
|
||||
}
|
||||
|
||||
private void Create()
|
||||
{
|
||||
CreateGroupFoldout();
|
||||
CreateGroupContent();
|
||||
}
|
||||
|
||||
private void CreateGroupFoldout()
|
||||
{
|
||||
_groupFoldoutButton = new Button(ToggleExpand);
|
||||
_groupFoldoutButton.AddToClassList("validator-test-list-group-expander");
|
||||
|
||||
_groupExpandStateLabel = new Label { name = "ExpanderLabel", text = "►" };
|
||||
_groupExpandStateLabel.AddToClassList("validator-test-list-group-expander-arrow");
|
||||
|
||||
_groupStatusImage = new Image
|
||||
{
|
||||
name = "TestImage",
|
||||
image = ValidatorUtility.GetStatusTexture(_group.Status)
|
||||
};
|
||||
_groupStatusImage.AddToClassList("validator-test-list-group-expander-image");
|
||||
|
||||
_groupFoldoutLabel = new Label() { text = $"{_group.Name} ({_group.Tests.Count()})" };
|
||||
_groupFoldoutLabel.AddToClassList("validator-test-list-group-expander-label");
|
||||
|
||||
_groupFoldoutButton.Add(_groupExpandStateLabel);
|
||||
_groupFoldoutButton.Add(_groupStatusImage);
|
||||
_groupFoldoutButton.Add(_groupFoldoutLabel);
|
||||
|
||||
Add(_groupFoldoutButton);
|
||||
}
|
||||
|
||||
private void CreateGroupContent()
|
||||
{
|
||||
_groupContent = new VisualElement();
|
||||
_groupContent.AddToClassList("validator-test-list-group-content");
|
||||
|
||||
Add(_groupContent);
|
||||
|
||||
_testElements = new List<ValidatorTestElement>();
|
||||
foreach (var test in _group.Tests)
|
||||
{
|
||||
var testElement = new ValidatorTestElement(test);
|
||||
_testElements.Add(testElement);
|
||||
_groupContent.Add(testElement);
|
||||
}
|
||||
}
|
||||
|
||||
private void ToggleExpand()
|
||||
{
|
||||
if (!_isExpanded)
|
||||
Expand();
|
||||
else
|
||||
Unexpand();
|
||||
}
|
||||
|
||||
private void Expand()
|
||||
{
|
||||
_groupExpandStateLabel.text = "▼";
|
||||
_groupContent.style.display = DisplayStyle.Flex;
|
||||
_isExpanded = true;
|
||||
}
|
||||
|
||||
private void Unexpand()
|
||||
{
|
||||
_groupExpandStateLabel.text = "►";
|
||||
_groupContent.style.display = DisplayStyle.None;
|
||||
_isExpanded = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d7c7a8788d0ea324e843a475244d8e18
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 115
|
||||
packageName: Asset Store Publishing Tools
|
||||
packageVersion: 12.0.1
|
||||
assetPath: Packages/com.unity.asset-store-tools/Editor/Validator/Scripts/UI/Elements/ValidatorTestGroupElement.cs
|
||||
uploadId: 724584
|
||||
@@ -0,0 +1,56 @@
|
||||
using AssetStoreTools.Utility;
|
||||
using AssetStoreTools.Validator.Data;
|
||||
using AssetStoreTools.Validator.Services;
|
||||
using AssetStoreTools.Validator.UI.Views;
|
||||
using UnityEditor.UIElements;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UIElements;
|
||||
|
||||
namespace AssetStoreTools.Validator.UI
|
||||
{
|
||||
|
||||
internal class ValidatorWindow : AssetStoreToolsWindow
|
||||
{
|
||||
protected override string WindowTitle => "Asset Store Validator";
|
||||
|
||||
private ICachingService _cachingService;
|
||||
|
||||
private ValidatorTestsView _validationTestsView;
|
||||
|
||||
protected override void Init()
|
||||
{
|
||||
minSize = new Vector2(350, 350);
|
||||
|
||||
this.SetAntiAliasing(4);
|
||||
|
||||
VisualElement root = rootVisualElement;
|
||||
|
||||
// Clean it out, in case the window gets initialized again
|
||||
root.Clear();
|
||||
|
||||
// Getting a reference to the USS Document and adding stylesheet to the root
|
||||
root.styleSheets.Add(StyleSelector.ValidatorWindow.ValidatorWindowStyle);
|
||||
root.styleSheets.Add(StyleSelector.ValidatorWindow.ValidatorWindowTheme);
|
||||
|
||||
GetServices();
|
||||
ConstructWindow();
|
||||
}
|
||||
|
||||
private void GetServices()
|
||||
{
|
||||
_cachingService = ValidatorServiceProvider.Instance.GetService<ICachingService>();
|
||||
}
|
||||
|
||||
private void ConstructWindow()
|
||||
{
|
||||
_validationTestsView = new ValidatorTestsView(_cachingService);
|
||||
rootVisualElement.Add(_validationTestsView);
|
||||
}
|
||||
|
||||
public void Load(ValidationSettings settings, ValidationResult result)
|
||||
{
|
||||
_validationTestsView.LoadSettings(settings);
|
||||
_validationTestsView.LoadResult(result);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a0dc99b826513dd4f868f1cf405c3923
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 115
|
||||
packageName: Asset Store Publishing Tools
|
||||
packageVersion: 12.0.1
|
||||
assetPath: Packages/com.unity.asset-store-tools/Editor/Validator/Scripts/UI/ValidatorWindow.cs
|
||||
uploadId: 724584
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8a973656ad14b8941b790ed83c874e97
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,103 @@
|
||||
using AssetStoreTools.Validator.Data;
|
||||
using AssetStoreTools.Validator.Services;
|
||||
using AssetStoreTools.Validator.UI.Data;
|
||||
using AssetStoreTools.Validator.UI.Data.Serialization;
|
||||
using AssetStoreTools.Validator.UI.Elements;
|
||||
using UnityEditor;
|
||||
using UnityEngine.UIElements;
|
||||
|
||||
namespace AssetStoreTools.Validator.UI.Views
|
||||
{
|
||||
internal class ValidatorTestsView : VisualElement
|
||||
{
|
||||
// Data
|
||||
private ValidatorStateData _stateData;
|
||||
private IValidatorSettings _settings;
|
||||
private IValidatorResults _results;
|
||||
|
||||
private ICachingService _cachingService;
|
||||
|
||||
// UI
|
||||
private ValidatorSettingsElement _validatorSettingsElement;
|
||||
private ValidatorButtonElement _validatorButtonElement;
|
||||
private ValidatorResultsElement _validationTestListElement;
|
||||
|
||||
public ValidatorTestsView(ICachingService cachingService)
|
||||
{
|
||||
_cachingService = cachingService;
|
||||
|
||||
if (!_cachingService.GetCachedValidatorStateData(out _stateData))
|
||||
_stateData = new ValidatorStateData();
|
||||
|
||||
_settings = new ValidatorSettings(_stateData.GetSettings());
|
||||
_settings.OnRequireSerialize += Serialize;
|
||||
|
||||
_results = new ValidatorResults(_settings, _stateData.GetResults());
|
||||
_results.OnRequireSerialize += Serialize;
|
||||
|
||||
Create();
|
||||
}
|
||||
|
||||
private void Create()
|
||||
{
|
||||
CreateValidatorDescription();
|
||||
CreateValidationSettings();
|
||||
CreateValidationButton();
|
||||
CreateValidatorResults();
|
||||
}
|
||||
|
||||
private void CreateValidatorDescription()
|
||||
{
|
||||
var validationInfoElement = new ValidatorDescriptionElement();
|
||||
Add(validationInfoElement);
|
||||
}
|
||||
|
||||
private void CreateValidationSettings()
|
||||
{
|
||||
_validatorSettingsElement = new ValidatorSettingsElement(_settings);
|
||||
Add(_validatorSettingsElement);
|
||||
}
|
||||
|
||||
private void CreateValidationButton()
|
||||
{
|
||||
_validatorButtonElement = new ValidatorButtonElement(_settings);
|
||||
_validatorButtonElement.OnValidate += Validate;
|
||||
Add(_validatorButtonElement);
|
||||
}
|
||||
|
||||
private void CreateValidatorResults()
|
||||
{
|
||||
_validationTestListElement = new ValidatorResultsElement(_results);
|
||||
Add(_validationTestListElement);
|
||||
}
|
||||
|
||||
private void Validate()
|
||||
{
|
||||
var validator = _settings.CreateValidator();
|
||||
var result = validator.Validate();
|
||||
|
||||
if (result.Status == ValidationStatus.Failed)
|
||||
{
|
||||
EditorUtility.DisplayDialog("Validation failed", result.Exception.Message, "OK");
|
||||
return;
|
||||
}
|
||||
|
||||
LoadResult(result);
|
||||
}
|
||||
|
||||
public void LoadSettings(ValidationSettings settings)
|
||||
{
|
||||
_settings.LoadSettings(settings);
|
||||
}
|
||||
|
||||
public void LoadResult(ValidationResult result)
|
||||
{
|
||||
_results.LoadResult(result);
|
||||
}
|
||||
|
||||
private void Serialize()
|
||||
{
|
||||
_cachingService.CacheValidatorStateData(_stateData);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c5e0da39c6638684c9d3faf8e62c60d3
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 115
|
||||
packageName: Asset Store Publishing Tools
|
||||
packageVersion: 12.0.1
|
||||
assetPath: Packages/com.unity.asset-store-tools/Editor/Validator/Scripts/UI/Views/ValidatorTestsView.cs
|
||||
uploadId: 724584
|
||||
Reference in New Issue
Block a user