示例#1
0
        public IEnumerator Search_Assets([ValueSource(nameof(k_IterationCount))] int iterationCount)
        {
            for (int i = 0; i < iterationCount; ++i)
            {
                var qsWindow = QuickSearch.ShowWindow();
                yield return(PrepareSearchTool(qsWindow));

                yield return(SendKeyCharacterEvent(qsWindow, 'p'));

                yield return(SendKeyCharacterEvent(qsWindow, ':'));

                var queryString = "quick search tool tests";
                foreach (var c in queryString)
                {
                    yield return(SendKeyCharacterEvent(qsWindow, c));
                }

                yield return(WaitForSearchCompleted(qsWindow));

                var results = qsWindow.Results.ToArray();
                Assert.GreaterOrEqual(results.Length, 1);
                Assert.IsTrue(results.Any(r => StripHTML(r.label).Contains("QuickSearchToolTests")));

                yield return(SendKeyCharacterEvent(qsWindow, (char)0, KeyCode.Escape));
            }
        }
示例#2
0
        public bool SelectObject(UnityEditor.SearchService.ISearchContext context,
                                 Action <UnityEngine.Object, bool> selectHandler, Action <UnityEngine.Object> trackingHandler)
        {
            var selectContext = (UnityEditor.SearchService.ObjectSelector.SearchContext)context;

            return(QuickSearch.ShowObjectPicker(selectHandler, trackingHandler,
                                                selectContext.currentObject?.name ?? "",
                                                selectContext.requiredTypeNames.First(), selectContext.requiredTypes.First()) != null);
        }
示例#3
0
        public IEnumerator Open()
        {
            var qsWindow = QuickSearch.ShowWindow();

            Assert.IsNotNull(qsWindow);

            yield return(SendKeyCharacterEvent(qsWindow, (char)0, KeyCode.Escape));

            // The window should have been closed and destroy by then.
            Assert.IsTrue(!qsWindow);
        }
示例#4
0
        private static IEnumerator WaitForSearchCompleted(QuickSearch qsWindow)
        {
            qsWindow.Refresh();
            yield return(null);

            while (AsyncSearchSession.SearchInProgress)
            {
                yield return(null);
            }
            yield return(null);
        }
        private static bool OpenQuery(int instanceID, int line)
        {
            var query = EditorUtility.InstanceIDToObject(instanceID) as SearchQuery;

            if (query != null)
            {
                return(QuickSearch.OpenWithContextualProvider(query.searchQuery, false, query.providerIds.ToArray()) != null);
            }

            return(false);
        }
示例#6
0
        public bool SelectObject(ISearchContext context,
                                 Action <Object, bool> selectHandler, Action <Object> trackingHandler)
        {
            var selectContext = (ObjectSelectorSearchContext)context;

            Func <ObjectSelectorTargetInfo, bool> selectorConstraintHandler = item => selectContext.selectorConstraint(item, selectContext.editedObjects, selectContext);

            qsWindow = QuickSearch.ShowObjectPicker(selectHandler, trackingHandler, selectorConstraintHandler,
                                                    selectContext.currentObject?.name ?? "",
                                                    selectContext.requiredTypeNames.First(), selectContext.requiredTypes.First(), dockable: Utils.IsRunningTests());

            return(qsWindow != null);
        }
示例#7
0
        public static void ShowAtPosition(QuickSearch quickSearchTool, SearchContext context, Rect screenRect)
        {
            var window = CreateInstance <SearchQueryCreateWindow>();

            window.m_SearchView = quickSearchTool;
            window.m_Context    = context;

            window.m_Description   = context.searchText;
            window.m_QueryFolder   = SearchSettings.queryFolder;
            window.m_QueryFileName = SearchQuery.RemoveInvalidChars(context.searchText);

            window.ShowAsDropDown(screenRect, Styles.windowSize);
        }
示例#8
0
        private static bool OpenQuery(int instanceID, int line)
        {
            var query = EditorUtility.InstanceIDToObject(instanceID) as SearchQuery;

            if (query != null)
            {
                var qsWindow = QuickSearch.Create();
                ExecuteQuery(qsWindow, query);
                qsWindow.ShowWindow();
            }

            return(false);
        }
示例#9
0
        private static bool OpenQuery(int instanceID, int line)
        {
            var query = EditorUtility.InstanceIDToObject(instanceID) as SearchQuery;

            if (query != null)
            {
                var qsWindow = QuickSearch.Create();
                qsWindow.SetFilteredProviders(query.providerIds);
                qsWindow.context.searchText = query.searchQuery;
                qsWindow.ShowWindow();
            }

            return(false);
        }
示例#10
0
        public IEnumerator Search_SceneObjects([ValueSource(nameof(k_IterationCount))] int iterationCount)
        {
            for (int i = 0; i < iterationCount; ++i)
            {
                var hierarchyChanged = false;

                void OnEditorApplicationOnHierarchyChanged() => hierarchyChanged = true;

                EditorApplication.hierarchyChanged += OnEditorApplicationOnHierarchyChanged;

                var uniqueName = GUID.Generate().ToString().Substring(0, 8);
                var go         = new GameObject(uniqueName);
                Assert.IsNotNull(go);
                Assert.AreEqual(uniqueName, go.name);

                while (!hierarchyChanged)
                {
                    yield return(null);
                }

                EditorApplication.hierarchyChanged -= OnEditorApplicationOnHierarchyChanged;

                var qsWindow = QuickSearch.ShowWindow();
                yield return(PrepareSearchTool(qsWindow));

                var queryString = uniqueName.Substring(0, Math.Max(3, Random.Range(0, uniqueName.Length - 1)));
                Debug.Log($"Searching {queryString} in {uniqueName}");

                yield return(SendKeyCharacterEvent(qsWindow, 'h'));

                yield return(SendKeyCharacterEvent(qsWindow, ':'));

                foreach (var c in queryString)
                {
                    yield return(SendKeyCharacterEvent(qsWindow, c));
                }

                yield return(WaitForSearchCompleted(qsWindow));

                var results       = qsWindow.Results.ToArray();
                var searchContext = qsWindow.Context;
                Assert.GreaterOrEqual(results.Length, 1);
                Assert.IsTrue(results.Any(r => StripHTML(r.provider.fetchLabel(r, searchContext)).Contains(uniqueName)));

                yield return(SendKeyCharacterEvent(qsWindow, (char)0, KeyCode.Escape));
            }
        }
示例#11
0
        private IEnumerator PrepareSearchTool(QuickSearch qsWindow)
        {
            qsWindow.m_SendAnalyticsEvent = true;
            Assert.IsNotNull(qsWindow);
            yield return(null);

            qsWindow.Focus();
            yield return(null);

            yield return(SendKeyCharacterEvent(qsWindow, (char)0, KeyCode.Backspace, EventModifiers.FunctionKey));

            qsWindow.Refresh();
            while (AsyncSearchSession.SearchInProgress)
            {
                yield return(null);
            }
            yield return(null);

            Assert.IsEmpty(qsWindow.Context.searchText);
        }
示例#12
0
 public override void EndSession(ISearchContext context)
 {
     qsWindow = null;
 }