File size: 2,531 Bytes
18a519f | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 | using UnityEditor.TestTools.CodeCoverage.Analytics;
using UnityEngine;
namespace UnityEditor.TestTools.CodeCoverage
{
internal class PathToAddDropDownMenu
{
GenericMenu m_Menu;
string m_PathsToFilter;
readonly PathToAddHandler m_AddPathToIncludeHandler;
readonly PathToAddHandler m_AddPathToExcludeHandler;
readonly PathFilterType m_PathFilterType;
static class Styles
{
public static readonly GUIContent AddFolderLabel = EditorGUIUtility.TrTextContent("Add Folder");
public static readonly GUIContent AddFileLabel = EditorGUIUtility.TrTextContent("Add File");
}
public PathToAddDropDownMenu(CodeCoverageWindow parent, PathFilterType type)
{
m_PathFilterType = type;
m_AddPathToIncludeHandler = new PathToAddHandler(parent, PathFilterType.Include);
m_AddPathToExcludeHandler = new PathToAddHandler(parent, PathFilterType.Exclude);
}
private void PopulateMenu()
{
m_Menu = new GenericMenu();
m_Menu.AddItem(Styles.AddFolderLabel, false, () => AddFolder());
m_Menu.AddItem(Styles.AddFileLabel, false, () => AddFile());
}
public void Show(Rect position, string pathsToFilter)
{
m_PathsToFilter = pathsToFilter;
PopulateMenu();
m_Menu.DropDown(position);
}
private void AddFolder()
{
if (m_PathFilterType == PathFilterType.Include)
{
CoverageAnalytics.instance.CurrentCoverageEvent.selectAddFolder_IncludedPaths = true;
m_AddPathToIncludeHandler.BrowseForDir(m_PathsToFilter);
}
else
{
CoverageAnalytics.instance.CurrentCoverageEvent.selectAddFolder_ExcludedPaths = true;
m_AddPathToExcludeHandler.BrowseForDir(m_PathsToFilter);
}
}
private void AddFile()
{
if (m_PathFilterType == PathFilterType.Include)
{
CoverageAnalytics.instance.CurrentCoverageEvent.selectAddFile_IncludedPaths = true;
m_AddPathToIncludeHandler.BrowseForFile(m_PathsToFilter);
}
else
{
CoverageAnalytics.instance.CurrentCoverageEvent.selectAddFile_ExcludedPaths = true;
m_AddPathToExcludeHandler.BrowseForFile(m_PathsToFilter);
}
}
}
}
|