Skip to content

Commit

Permalink
replace testtools
Browse files Browse the repository at this point in the history
  • Loading branch information
neuecc committed Mar 10, 2015
1 parent d6b0220 commit 823989d
Show file tree
Hide file tree
Showing 209 changed files with 4,794 additions and 370 deletions.
Binary file modified Assets/LINQtoGameObject/Examples/SampleScene.unity
Binary file not shown.
Binary file added Assets/Sandbox/uGUI.unity
Binary file not shown.
41 changes: 41 additions & 0 deletions Assets/Sandbox/uGUIScene.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
using UnityEngine;
using Unity.Linq;
using System.Collections;
using UnityEngine.UI;
using UnityEngine.EventSystems;

public class uGUIScene : MonoBehaviour
{
public GameObject Panel;
public GameObject CloneFrom;
public Button Button;
public int HogeHoge;

public void OnEnable()
{
var clone = GameObject.Instantiate(CloneFrom);
Panel.MoveToLast(clone);
}




// Use this for initialization
void Start()
{

Button.onClick.AddListener(() =>
{
var clone = GameObject.Instantiate(CloneFrom);

Panel.MoveToLast(clone);
});

}

// Update is called once per frame
void Update()
{

}
}
2 changes: 2 additions & 0 deletions Assets/UnityTestTools/Assertions/AssertionComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,12 @@ public ActionBase Action

public Object GetFailureReferenceObject()
{
#if UNITY_EDITOR
if (!string.IsNullOrEmpty(m_CreatedInFilePath))
{
return Resources.LoadAssetAtPath(m_CreatedInFilePath, typeof(Object));
}
#endif
return this;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,18 +136,18 @@ private IListRenderer GetResultRendere()

private void DrawMenuPanel()
{
EditorGUILayout.BeginHorizontal();
EditorGUILayout.LabelField("Group by", GUILayout.MaxWidth(60));
m_GroupBy = (GroupByType)EditorGUILayout.EnumPopup(m_GroupBy, GUILayout.MaxWidth(150));
EditorGUILayout.BeginHorizontal(EditorStyles.toolbar);
EditorGUILayout.LabelField("Group by:", Styles.toolbarLabel, GUILayout.MaxWidth(60));
m_GroupBy = (GroupByType)EditorGUILayout.EnumPopup(m_GroupBy, EditorStyles.toolbarPopup, GUILayout.MaxWidth(150));

GUILayout.FlexibleSpace();

m_ShowType = (ShowType)EditorGUILayout.EnumPopup(m_ShowType, GUILayout.MaxWidth(100));
m_ShowType = (ShowType)EditorGUILayout.EnumPopup(m_ShowType, EditorStyles.toolbarPopup, GUILayout.MaxWidth(100));

EditorGUILayout.LabelField("Filter by", GUILayout.MaxWidth(50));
m_FilterType = (FilterType)EditorGUILayout.EnumPopup(m_FilterType, GUILayout.MaxWidth(100));
m_FilterText = EditorGUILayout.TextField(m_FilterText, GUILayout.MaxWidth(100));
if (GUILayout.Button("Clear", GUILayout.ExpandWidth(false)))
EditorGUILayout.LabelField("Filter by:", Styles.toolbarLabel, GUILayout.MaxWidth(50));
m_FilterType = (FilterType)EditorGUILayout.EnumPopup(m_FilterType, EditorStyles.toolbarPopup, GUILayout.MaxWidth(100));
m_FilterText = GUILayout.TextField(m_FilterText, "ToolbarSeachTextField", GUILayout.MaxWidth(100));
if (GUILayout.Button(GUIContent.none, string.IsNullOrEmpty(m_FilterText) ? "ToolbarSeachCancelButtonEmpty" : "ToolbarSeachCancelButton", GUILayout.ExpandWidth(false)))
m_FilterText = "";
EditorGUILayout.EndHorizontal();
}
Expand Down
7 changes: 5 additions & 2 deletions Assets/UnityTestTools/Assertions/MemberResolver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,11 @@ public object GetValue(bool useCache)
var member = fullCallStack[i];
result = GetValueFromMember(result, member);
tempCallstack.Add(member);
if (result == null) return null;
if (!IsValueType(result.GetType()))
if (result == null) return null;
var type = result.GetType();

//String is not a value type but we don't want to cache it
if (!IsValueType(type) && type != typeof(System.String))
{
tempCallstack.Clear();
m_CallingObjectRef = result;
Expand Down
22 changes: 0 additions & 22 deletions Assets/UnityTestTools/Common/Editor/Icons.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,10 @@ public static class Icons

public static readonly Texture2D FailImg;
public static readonly Texture2D IgnoreImg;
public static readonly Texture2D RunImg;
public static readonly Texture2D RunFailedImg;
public static readonly Texture2D RunAllImg;
public static readonly Texture2D SuccessImg;
public static readonly Texture2D UnknownImg;
public static readonly Texture2D InconclusiveImg;
public static readonly Texture2D StopwatchImg;
public static readonly Texture2D PlusImg;
public static readonly Texture2D GearImg;

public static readonly GUIContent GUIUnknownImg;
public static readonly GUIContent GUIInconclusiveImg;
Expand All @@ -47,23 +42,6 @@ static Icons()
InconclusiveImg = LoadTexture("inconclusive.png");
StopwatchImg = LoadTexture("stopwatch.png");

if (EditorGUIUtility.isProSkin)
{
RunAllImg = LoadTexture("play-darktheme.png");
RunImg = LoadTexture("play_selected-darktheme.png");
RunFailedImg = LoadTexture("rerun-darktheme.png");
PlusImg = LoadTexture("create-darktheme.png");
GearImg = LoadTexture("options-darktheme.png");
}
else
{
RunAllImg = LoadTexture("play-lighttheme.png");
RunImg = LoadTexture("play_selected-lighttheme.png");
RunFailedImg = LoadTexture("rerun-lighttheme.png");
PlusImg = LoadTexture("create-lighttheme.png");
GearImg = LoadTexture("options-lighttheme.png");
}

GUIUnknownImg = new GUIContent(UnknownImg);
GUIInconclusiveImg = new GUIContent(InconclusiveImg);
GUIIgnoreImg = new GUIContent(IgnoreImg);
Expand Down
2 changes: 1 addition & 1 deletion Assets/UnityTestTools/Common/Editor/ProjectSettingsBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public abstract class ProjectSettingsBase : ScriptableObject
private static readonly string k_SettingsPath = Path.Combine("UnityTestTools", "Common");
const string k_SettingsFolder = "Settings";

public void Save()
public virtual void Save()
{
EditorUtility.SetDirty(this);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public class ResultSummarizer

private TimeSpan m_Duration;

public ResultSummarizer(ITestResult[] results)
public ResultSummarizer(IEnumerable<ITestResult> results)
{
foreach (var result in results)
Summarize(result);
Expand Down Expand Up @@ -125,7 +125,19 @@ public void Summarize(ITestResult result)
{
m_Duration += TimeSpan.FromSeconds(result.Duration);
m_ResultCount++;


if(!result.Executed)
{
if(result.IsIgnored)
{
m_IgnoreCount++;
return;
}

m_SkipCount++;
return;
}

switch (result.ResultState)
{
case TestResultState.Success:
Expand Down
26 changes: 12 additions & 14 deletions Assets/UnityTestTools/Common/Editor/Styles.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,43 +7,41 @@ namespace UnityTest
{
public static class Styles
{
public static GUIStyle buttonLeft;
public static GUIStyle buttonMid;
public static GUIStyle buttonRight;
public static GUIStyle info;
public static GUIStyle testList;

public static GUIStyle selectedLabel;
public static GUIStyle label;
public static GUIStyle selectedFoldout;
public static GUIStyle foldout;
public static GUIStyle toolbarLabel;

public static GUIStyle testName;

private static readonly Color k_SelectedColor = new Color(0.3f, 0.5f, 0.85f);

static Styles()
{
buttonLeft = GUI.skin.FindStyle(GUI.skin.button.name + "left");
buttonMid = GUI.skin.FindStyle(GUI.skin.button.name + "mid");
buttonRight = GUI.skin.FindStyle(GUI.skin.button.name + "right");

info = new GUIStyle(EditorStyles.wordWrappedLabel);
info.wordWrap = false;
info.stretchHeight = true;
info.margin.right = 15;

testList = new GUIStyle("CN Box");
testList.margin.top = 3;
testList.margin.top = 0;
testList.padding.left = 3;

label = new GUIStyle(EditorStyles.label);
selectedLabel = new GUIStyle(EditorStyles.label);
selectedLabel.active.textColor = selectedLabel.normal.textColor = selectedLabel.onActive.textColor = k_SelectedColor;

foldout = new GUIStyle(EditorStyles.foldout);
selectedFoldout = new GUIStyle(EditorStyles.foldout);
selectedFoldout.onFocused.textColor = selectedFoldout.focused.textColor =
selectedFoldout.onActive.textColor = selectedFoldout.active.textColor =
selectedFoldout.onNormal.textColor = selectedFoldout.normal.textColor = k_SelectedColor;

toolbarLabel = new GUIStyle(EditorStyles.toolbarButton);
toolbarLabel.normal.background = null;
toolbarLabel.contentOffset = new Vector2(0, -2);

testName = new GUIStyle(EditorStyles.label);
testName.padding.left += 12;
testName.focused.textColor = testName.onFocused.textColor = k_SelectedColor;
}
}
}
104 changes: 104 additions & 0 deletions Assets/UnityTestTools/Common/Editor/TestFilterSettings.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
using System;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
using System.Linq;

namespace UnityTest
{
public class TestFilterSettings
{
public bool ShowSucceeded;
public bool ShowFailed;
public bool ShowIgnored;
public bool ShowNotRun;

public string FilterByName;
public int FilterByCategory;

private GUIContent _succeededBtn;
private GUIContent _failedBtn;
private GUIContent _ignoredBtn;
private GUIContent _notRunBtn;

public string[] AvailableCategories;

private readonly string _prefsKey;

public TestFilterSettings(string prefsKey)
{
_prefsKey = prefsKey;
Load();
UpdateCounters(Enumerable.Empty<ITestResult>());
}

public void Load()
{
ShowSucceeded = EditorPrefs.GetBool(_prefsKey + ".ShowSucceeded", true);
ShowFailed = EditorPrefs.GetBool(_prefsKey + ".ShowFailed", true);
ShowIgnored = EditorPrefs.GetBool(_prefsKey + ".ShowIgnored", true);
ShowNotRun = EditorPrefs.GetBool(_prefsKey + ".ShowNotRun", true);
FilterByName = EditorPrefs.GetString(_prefsKey + ".FilterByName", string.Empty);
FilterByCategory = EditorPrefs.GetInt(_prefsKey + ".FilterByCategory", 0);
}

public void Save()
{
EditorPrefs.SetBool(_prefsKey + ".ShowSucceeded", ShowSucceeded);
EditorPrefs.SetBool(_prefsKey + ".ShowFailed", ShowFailed);
EditorPrefs.SetBool(_prefsKey + ".ShowIgnored", ShowIgnored);
EditorPrefs.SetBool(_prefsKey + ".ShowNotRun", ShowNotRun);
EditorPrefs.SetString(_prefsKey + ".FilterByName", FilterByName);
EditorPrefs.SetInt(_prefsKey + ".FilterByCategory", FilterByCategory);
}

public void UpdateCounters(IEnumerable<ITestResult> results)
{
var summary = new ResultSummarizer(results);

_succeededBtn = new GUIContent(summary.Passed.ToString(), Icons.SuccessImg, "Show tests that succeeded");
_failedBtn = new GUIContent((summary.Errors + summary.Failures + summary.Inconclusive).ToString(), Icons.FailImg, "Show tests that failed");
_ignoredBtn = new GUIContent((summary.Ignored + summary.NotRunnable).ToString(), Icons.IgnoreImg, "Show tests that are ignored");
_notRunBtn = new GUIContent((summary.TestsNotRun - summary.Ignored - summary.NotRunnable).ToString(), Icons.UnknownImg, "Show tests that didn't run");
}

public string[] GetSelectedCategories()
{
if(AvailableCategories == null) return new string[0];

return AvailableCategories.Where ((c, i) => (FilterByCategory & (1 << i)) != 0).ToArray();
}

public void OnGUI()
{
EditorGUI.BeginChangeCheck();

FilterByName = GUILayout.TextField(FilterByName, "ToolbarSeachTextField", GUILayout.MinWidth(100), GUILayout.MaxWidth(250), GUILayout.ExpandWidth(true));
if(GUILayout.Button (GUIContent.none, string.IsNullOrEmpty(FilterByName) ? "ToolbarSeachCancelButtonEmpty" : "ToolbarSeachCancelButton"))
FilterByName = string.Empty;

if (AvailableCategories != null && AvailableCategories.Length > 0)
FilterByCategory = EditorGUILayout.MaskField(FilterByCategory, AvailableCategories, EditorStyles.toolbarDropDown, GUILayout.MaxWidth(90));

ShowSucceeded = GUILayout.Toggle(ShowSucceeded, _succeededBtn, EditorStyles.toolbarButton);
ShowFailed = GUILayout.Toggle(ShowFailed, _failedBtn, EditorStyles.toolbarButton);
ShowIgnored = GUILayout.Toggle(ShowIgnored, _ignoredBtn, EditorStyles.toolbarButton);
ShowNotRun = GUILayout.Toggle(ShowNotRun, _notRunBtn, EditorStyles.toolbarButton);

if(EditorGUI.EndChangeCheck()) Save ();
}

public RenderingOptions BuildRenderingOptions()
{
var options = new RenderingOptions();
options.showSucceeded = ShowSucceeded;
options.showFailed = ShowFailed;
options.showIgnored = ShowIgnored;
options.showNotRunned = ShowNotRun;
options.nameFilter = FilterByName;
options.categories = GetSelectedCategories();
return options;
}
}

}
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
12 changes: 12 additions & 0 deletions Assets/UnityTestTools/Common/ITestResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,24 @@
public interface ITestResult
{
TestResultState ResultState { get; }

string Message { get; }

string Logs { get; }

bool Executed { get; }

string Name { get; }

string FullName { get; }

string Id { get; }

bool IsSuccess { get; }

double Duration { get; }

string StackTrace { get; }

bool IsIgnored { get; }
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading

0 comments on commit 823989d

Please sign in to comment.