public IEnumerator ShowingContent_InEditorWindow_SurvivesDomainReload()
        {
            CloseAllWindows();
            var content = new Content();

            content.m_Data.Value = 25;
            SelectionUtility.ShowInWindow(content);
            yield return(null);

            var window = EditorWindow.GetWindow <ContentWindow>();

            Assert.That(window, Is.Not.Null);
            Assert.That(content.Name, Is.EqualTo(window.titleContent.text));
            UnityEditor.Compilation.CompilationPipeline.RequestScriptCompilation();
            yield return(new WaitForDomainReload());

            yield return(null);

            window = EditorWindow.GetWindow <ContentWindow>();
            Assert.That(window, Is.Not.Null);
            var element = window.rootVisualElement.Q <Element <Content> >();

            Assert.That(element.m_Content.m_Data.Value, Is.EqualTo(25));
            Assert.That(element.m_Content.Name, Is.EqualTo(window.titleContent.text));
            window.Close();
        }
 static void Show()
 {
     SelectionUtility.ShowInWindow(new Provider(),
                                   new ContentWindowParameters
     {
         ApplyInspectorStyling = false,
         AddScrollView         = false,
         MinSize = new Vector2(500, 400)
     });
 }
        public IEnumerator ContentProvider_WhenGivenNullContent_Exits()
        {
            var content = new NullContent();

            LogAssert.Expect(LogType.Error, "SelectionUtilityTests.NullContent: Releasing content named 'Null' because it returned null value.");
            SelectionUtility.ShowInWindow(content);
            for (var i = 0; i < 10; ++i)
            {
                yield return(null);
            }
            Assert.That(Resources.FindObjectsOfTypeAll <ContentWindow>().Any(), Is.False);
        }
        public IEnumerator ContentProvider_WhenContentThrows_Exits()
        {
            var content = new ExceptionContent();

            LogAssert.Expect(LogType.Error, "SelectionUtilityTests.ExceptionContent: Releasing content named 'Exception' because it threw an exception.");
            LogAssert.Expect(LogType.Exception, "Exception: Why are you doing this?");
            SelectionUtility.ShowInWindow(content);
            for (var i = 0; i < 10; ++i)
            {
                yield return(null);
            }
            Assert.That(Resources.FindObjectsOfTypeAll <ContentWindow>().Any(), Is.False);
        }
        public IEnumerator ShowingContent_InEditorWindow_CanControlLifecycle()
        {
            CloseAllWindows();
            var content = new LifecycleContent();

            content.Status = ContentStatus.ContentNotReady;
            SelectionUtility.ShowInWindow(content);
            var window = EditorWindow.GetWindow <ContentWindow>();

            yield return(null);

            Assert.That(window && null != window, Is.EqualTo(true));
            var element = window.rootVisualElement.Q <Element <LifecycleContent> >();

            Assert.That(element, Is.Null);
            yield return(null);

            element = window.rootVisualElement.Q <Element <LifecycleContent> >();
            Assert.That(element, Is.Null);

            content.Status = ContentStatus.ContentReady;
            yield return(null);

            element = window.rootVisualElement.Q <Element <LifecycleContent> >();
            Assert.That(element, Is.Not.Null);

            content.Status = ContentStatus.ContentNotReady;
            yield return(null);

            element = window.rootVisualElement.Q <Element <LifecycleContent> >();
            Assert.That(element, Is.Null);

            content.Status = ContentStatus.ContentUnavailable;
            yield return(null);

            Assert.That(window && null != window, Is.EqualTo(false));
        }