Esempio n. 1
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);
        }
Esempio n. 2
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));
            }
        }
Esempio n. 3
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));
            }
        }