private void BuildAndRun()
        {
            SaveToPreferences();

            var config = new PlatformRunnerConfiguration
            {
                buildTarget            = m_BuildTarget,
                buildScenes            = m_OtherScenesToBuild,
                testScenes             = m_IntegrationTestScenes,
                projectName            = m_IntegrationTestScenes.Count > 1 ? "IntegrationTests" : Path.GetFileNameWithoutExtension(SceneManager.GetActiveScene().path),
                resultsDir             = m_Settings.resultsPath,
                sendResultsOverNetwork = m_Settings.sendResultsOverNetwork,
                ipList = m_Interfaces.Skip(1).ToList(),
                port   = m_Settings.port
            };

            if (m_SelectedInterface > 0)
            {
                config.ipList = new List <string> {
                    m_Interfaces.ElementAt(m_SelectedInterface)
                }
            }
            ;

            PlatformRunner.BuildAndRunInPlayer(config);
            Close();
        }
Beispiel #2
0
        public void OnGUI()
        {
            EditorGUILayout.BeginVertical();

            EditorGUILayout.LabelField("List of scenes to build:", EditorStyles.boldLabel);
            m_ScrollPosition = EditorGUILayout.BeginScrollView(m_ScrollPosition, Styles.testList);
            EditorGUI.indentLevel++;
            foreach (var scenePath in m_SceneList)
            {
                var path       = Path.GetFileNameWithoutExtension(scenePath);
                var guiContent = new GUIContent(path, scenePath);
                var rect       = GUILayoutUtility.GetRect(guiContent, EditorStyles.label);
                if (rect.Contains(Event.current.mousePosition))
                {
                    if (Event.current.type == EventType.mouseDown && Event.current.button == 0)
                    {
                        if (!Event.current.control && !Event.current.command)
                        {
                            m_SelectedScenes.Clear();
                        }
                        if (!m_SelectedScenes.Contains(scenePath))
                        {
                            m_SelectedScenes.Add(scenePath);
                        }
                        else
                        {
                            m_SelectedScenes.Remove(scenePath);
                        }
                        Event.current.Use();
                    }
                }
                var style = new GUIStyle(EditorStyles.label);
                if (m_SelectedScenes.Contains(scenePath))
                {
                    style.normal.textColor = new Color(0.3f, 0.5f, 0.85f);
                }
                EditorGUI.LabelField(rect, guiContent, style);
            }
            EditorGUI.indentLevel--;
            EditorGUILayout.EndScrollView();

            GUILayout.Space(3);

            m_BuildTarget = (BuildTarget)EditorGUILayout.EnumPopup("Build tests for", m_BuildTarget);

            if (PlatformRunner.defaultBuildTarget != m_BuildTarget)
            {
                if (GUILayout.Button("Make default target platform"))
                {
                    PlatformRunner.defaultBuildTarget = m_BuildTarget;
                }
            }
            DrawSetting();
            var build = GUILayout.Button("Build and run tests");

            EditorGUILayout.EndVertical();

            if (!build)
            {
                return;
            }

            var config = new PlatformRunnerConfiguration
            {
                buildTarget            = m_BuildTarget,
                scenes                 = m_SelectedScenes.ToArray(),
                projectName            = m_SelectedScenes.Count > 1 ? "IntegrationTests" : Path.GetFileNameWithoutExtension(EditorApplication.currentScene),
                resultsDir             = m_Settings.resultsPath,
                sendResultsOverNetwork = m_Settings.sendResultsOverNetwork,
                ipList                 = m_Interfaces.Skip(1).ToList(),
                port = m_Settings.port
            };

            if (m_SelectedInterface > 0)
            {
                config.ipList = new List <string> {
                    m_Interfaces.ElementAt(m_SelectedInterface)
                }
            }
            ;

            PlatformRunner.BuildAndRunInPlayer(config);
            Close();
        }
        private void OnGUI()
        {
            EditorGUILayout.BeginVertical();

            scrollPosition = EditorGUILayout.BeginScrollView(scrollPosition);
            EditorGUILayout.LabelField("List of scenes to build:", EditorStyles.boldLabel);
            EditorGUI.indentLevel++;
            foreach (var scenePath in sceneList)
            {
                var path       = Path.GetFileNameWithoutExtension(scenePath);
                var guiContent = new GUIContent(path, scenePath);
                var rect       = GUILayoutUtility.GetRect(guiContent, EditorStyles.label);

                if (rect.Contains(Event.current.mousePosition))
                {
                    if (Event.current.type == EventType.mouseDown && Event.current.button == 0)
                    {
                        if (!Event.current.control)
                        {
                            selectedScenes.Clear();
                        }

                        if (!selectedScenes.Contains(scenePath))
                        {
                            selectedScenes.Add(scenePath);
                        }

                        else
                        {
                            selectedScenes.Remove(scenePath);
                        }

                        Event.current.Use();
                    }
                }

                var style = new GUIStyle(EditorStyles.label);

                if (selectedScenes.Contains(scenePath))
                {
                    style.normal.textColor = new Color(0.3f, 0.5f, 0.85f);
                }

                EditorGUI.LabelField(rect, guiContent, style);
            }
            EditorGUI.indentLevel--;
            EditorGUILayout.EndScrollView();

            GUILayout.Box("", new[] { GUILayout.ExpandWidth(true), GUILayout.Height(1) });

            buildTarget = (BuildTarget)EditorGUILayout.EnumPopup("Build tests for", buildTarget);

            if (PlatformRunner.defaultBuildTarget != buildTarget)
            {
                if (GUILayout.Button("Make default target platform"))
                {
                    PlatformRunner.defaultBuildTarget = buildTarget;
                }
            }

            DrawSetting();
            var build = GUILayout.Button("Build and run tests");

            EditorGUILayout.EndVertical();

            if (!build)
            {
                return;
            }

            PlatformRunner.BuildAndRunInPlayer(buildTarget, selectedScenes.ToArray(), "IntegrationTests", resultsPath);
            Close();
        }