浏览代码

Finish test result window. Accessible in "Internal / Graphic Tests / Test Result Window"

/main
Remy 7 年前
当前提交
901f41aa
共有 3 个文件被更改,包括 70 次插入56 次删除
  1. 77
      Tests/Scripts/Editor/GraphicTests/Framework/TestResultWindow.cs
  2. 11
      Tests/Scripts/Editor/GraphicTests/Framework/GraphicTestContext.cs.meta
  3. 38
      Tests/Scripts/Editor/GraphicTests/Framework/GraphicTestContext.cs

77
Tests/Scripts/Editor/GraphicTests/Framework/TestResultWindow.cs


private int[] diffStylesValues = new int[] {0, 1, 2, 3, 4, 5};
private int topBarHeight = 20;
private int leftBarWidth = 200;
private int leftBarWidth = 300;
private bool testOKOrNotRun = false;

{
sceneAsset = _sceneAsset;
if (sceneAsset == null) return;
if (sceneAsset != null ) templateImage = TestFrameworkTools.GetTemplateImage(sceneAsset, ref tmp);
if (sceneAsset != null)
{
templateImage = TestFrameworkTools.GetTemplateImage(sceneAsset, ref tmp);
templateImage.filterMode = FilterMode.Point;
templateImage.mipMapBias = -10;
templateImage.hideFlags = HideFlags.HideAndDontSave;
DontDestroyOnLoad(templateImage);
}
string templatePath = Path.Combine( TestFrameworkTools.s_RootPath, "ImageTemplates");

if (diffMaterial == null)
{
diffMaterial = new Material(Shader.Find("GraphicTests/ComparerShader"));
diffMaterial.hideFlags = HideFlags.HideAndDontSave;
DontDestroyOnLoad(diffMaterial);
diffMaterial.SetFloat("_CorrectGamma", 1f);
diffMaterial.SetFloat("_FlipV2", 0f);
}

if (File.Exists(misMatchLocationResult))
{
resultImage = new Texture2D(templateImage.width, templateImage.height, TextureFormat.ARGB32, false);
resultImage.filterMode = FilterMode.Point;
resultImage.mipMapBias = -10;
resultImage.hideFlags = HideFlags.HideAndDontSave;
DontDestroyOnLoad(resultImage);
byte[] resultBytes = File.ReadAllBytes(misMatchLocationResult);
resultImage.LoadImage(resultBytes);

testResultTreeView.Reload();
}
private void OnDisable()
{
DestroyImmediate(templateImage);
DestroyImmediate(resultImage);
DestroyImmediate(diffMaterial);
}
private void OnGUI()
{
// tree view

GUILayout.BeginHorizontal(GUILayout.Height(topBarHeight));
{
if (GUILayout.Button(reloadContent))
Reload();
Reload(sceneAsset.name+".unity");
if (GUILayout.Button(wipeResultContent))
{

GUILayout.FlexibleSpace();
}
if (GUILayout.Button("Quick Switch"))
{
if (maxDiff > 0f)
{
minDiff = 0f;
maxDiff = 0f;
}
else
{
minDiff = 1f;
maxDiff = 1f;
}
ApplyValues();
}
if (GUILayout.Button("Reset"))
{
minDiff = 0.45f;
maxDiff = 0.55f;
ApplyValues();
}
GUILayout.FlexibleSpace();
GUILayout.Label("Diff. type: ");
diffStyle = EditorGUILayout.IntPopup(diffStyle, diffStylesList, diffStylesValues,
GUILayout.Width(200f));

EditorGUILayout.MinMaxSlider(ref minDiff, ref maxDiff, 0f, 1f, GUILayout.Height(topBarHeight));
if (EditorGUI.EndChangeCheck()) ApplyValues();
// template / diff / result visualisation
float w = position.width - leftBarWidth;
Color c = GUI.color;
Rect rect1 = new Rect(0, topBarHeight * 2, w * minDiff, topBarHeight);
Rect rect2 = new Rect(rect1.max.x, rect1.y, w * (maxDiff - minDiff), topBarHeight);
Rect rect3 = new Rect(rect2.max.x, rect2.y, w * (1f - maxDiff), topBarHeight);
GUI.color = Color.green;
if (rect1.width > 0) GUI.Box(rect1, "Template");
GUI.color = Color.black;
if (rect2.width > 0) GUI.Box(rect2, "Diff" );
GUI.color = Color.blue;
if (rect3.width > 0) GUI.Box(rect3, "Result");
GUI.color = c;
Rect textureRect = new Rect(leftBarWidth, topBarHeight * 2, position.width - leftBarWidth,
position.height - topBarHeight * 2);
Rect textureRect = new Rect(leftBarWidth, topBarHeight * 3, position.width - leftBarWidth,
position.height - topBarHeight * 3);
EditorGUI.DrawPreviewTexture(textureRect, templateImage, diffMaterial, ScaleMode.ScaleToFit, 0, 0);
}
}

var prjRelativeGraphsPath = TestFrameworkTools.s_Path.Aggregate(TestFrameworkTools.s_RootPath, Path.Combine);
var filePath = Path.Combine(prjRelativeGraphsPath, info.relativePath);
filePath = filePath.Replace(Application.dataPath, "");
filePath = string.Format("Assets{0}", filePath.Replace(Application.dataPath, "") );
SceneAsset sceneObject = AssetDatabase.LoadAssetAtPath<SceneAsset>(filePath);

var prjRelativeGraphsPath = TestFrameworkTools.s_Path.Aggregate(TestFrameworkTools.s_RootPath, Path.Combine);
var filePath = Path.Combine(prjRelativeGraphsPath, info.relativePath);
filePath = filePath.Replace(Application.dataPath, "");
filePath = string.Format("Assets{0}", filePath.Replace(Application.dataPath, ""));
SceneAsset sceneObject = AssetDatabase.LoadAssetAtPath<SceneAsset>(filePath);

11
Tests/Scripts/Editor/GraphicTests/Framework/GraphicTestContext.cs.meta


fileFormatVersion: 2
guid: adf58e95bb5f8eb40aca04ec74f4dae5
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

38
Tests/Scripts/Editor/GraphicTests/Framework/GraphicTestContext.cs


using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
using System.IO;
namespace UnityEngine.Experimental.Rendering
{
public class GraphicTestContext
{
[MenuItem("Assets/Open Graphic Test Result")]
private static void OpenGraphicTestResult()
{
TestResultWindow.OpenWindow((SceneAsset) Selection.activeObject);
}
[MenuItem("Assets/Open Graphic Test Result", true)]
private static bool OpenGraphicTestResultValidation()
{
if (((SceneAsset) Selection.activeObject) == null) return false;
List<string> scenes = new List<string>();
foreach (TestFrameworkTools.TestInfo testInfo in TestFrameworkTools.CollectScenes.HDRP)
{
scenes.Add(testInfo.name);
}
foreach (TestFrameworkTools.TestInfo testInfo in TestFrameworkTools.CollectScenes.LWRP)
{
scenes.Add(testInfo.name);
}
return scenes.Contains(Path.GetFileName( AssetDatabase.GetAssetPath(Selection.activeObject) ));
}
}
}
正在加载...
取消
保存