Exemple #1
0
        public static bool ShowAtPosition(QuickSearchTool quickSearchTool, Rect rect)
        {
            var screenPos    = GUIUtility.GUIToScreenPoint(new Vector2(rect.x, rect.y));
            var screenRect   = new Rect(screenPos, rect.size);
            var filterWindow = ScriptableObject.CreateInstance <FilterWindow>();

            filterWindow.quickSearchTool = quickSearchTool;
            filterWindow.ShowAsDropDown(screenRect, Styles.windowSize);
            return(true);
        }
Exemple #2
0
        public IEnumerator Open()
        {
            var qsWindow = QuickSearchTool.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);
        }
Exemple #3
0
        private static IEnumerator WaitForSearchCompleted(QuickSearchTool qsWindow)
        {
            qsWindow.Refresh();
            yield return(null);

            while (AsyncSearchSession.SearchInProgress)
            {
                yield return(null);
            }
            yield return(null);
        }
Exemple #4
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();
                var go         = new GameObject(uniqueName);
                Assert.IsNotNull(go);
                Assert.AreEqual(uniqueName, go.name);

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

                EditorApplication.hierarchyChanged -= OnEditorApplicationOnHierarchyChanged;

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

                var queryString = uniqueName.Substring(Random.Range(0, uniqueName.Length / 2 - 1), Math.Max(3, Random.Range(0, uniqueName.Length / 2 - 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));
            }
        }
Exemple #5
0
        private static SettingsProvider CreateSearchSettings()
        {
            var settings = new SettingsProvider(settingsPreferencesKey, SettingsScope.User)
            {
                keywords   = new[] { "quick", "omni", "search" },
                guiHandler = searchContext =>
                {
                    EditorGUIUtility.labelWidth = 500;
                    GUILayout.BeginHorizontal();
                    {
                        GUILayout.Space(10);
                        GUILayout.BeginVertical();
                        {
                            GUILayout.Space(10);
                            EditorGUI.BeginChangeCheck();
                            {
                                trackSelection    = EditorGUILayout.Toggle(Styles.trackSelectionContent, trackSelection);
                                fetchPreview      = EditorGUILayout.Toggle(Styles.fetchPreviewContent, fetchPreview);
                                useDockableWindow = EditorGUILayout.Toggle(Styles.useDockableWindowContent, useDockableWindow);

                                rowHeight = EditorGUILayout.FloatField(Styles.rowHeightContent, rowHeight);

                                if (useDockableWindow)
                                {
                                    closeWindowByDefault = EditorGUILayout.Toggle(Styles.closeWindowByDefaultContent, closeWindowByDefault);
                                }
                                GUILayout.Space(10);
                                DrawProviderSettings();
                            }
                            if (EditorGUI.EndChangeCheck())
                            {
                                Save();
                                SearchService.Refresh();
                                QuickSearchTool.RefreshStyles();
                            }
                        }
                        GUILayout.EndVertical();
                    }
                    GUILayout.EndHorizontal();
                }
            };

            return(settings);
        }
Exemple #6
0
        private IEnumerator PrepareSearchTool(QuickSearchTool 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);
        }
Exemple #7
0
        public IEnumerator Search_Assets([ValueSource(nameof(k_IterationCount))] int iterationCount)
        {
            for (int i = 0; i < iterationCount; ++i)
            {
                var qsWindow = QuickSearchTool.ShowWindow();
                yield return(PrepareSearchTool(qsWindow));

                var queryString = "test 42";
                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("test_material_42")));

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