{
    "version": 1,
    "supportedProjectTypes": [ "CMakeProjectManager.CMakeProject", "Qbs.QbsProject", "Qt4ProjectManager.Qt4Project" ],
    "id": "R.CatchAutoTest",
    "category": "I.TestProject",
    "trDescription": "Creates a new unit test project using Catch2. Unit tests allow you to verify that the code is fit for use and that there are no regressions.",
    "trDisplayName": "Catch2 Test Project",
    "trDisplayCategory": "Test Project",
    "icon": "../autotest.png",
    "iconKind": "Themed",
    "enabled": "%{JS: value('Plugins').indexOf('CppEditor') >= 0}",

    "options":
    [
        { "key": "ProjectFilePath",
          "value": "%{JS: value('BuildSystem') == 'qmake' ? value('ProFileName') : (value('BuildSystem') == 'qbs' ? value('QbsFileName') : value('CMakeFileName')) }"
        },
        { "key": "ProFileName",
          "value": "%{JS: Util.fileName(value('ProjectDirectory') + '/' + value('ProjectName'), 'pro')}"
        },
        {
          "key": "QbsFileName",
          "value": "%{JS: Util.fileName(value('ProjectDirectory') + '/' + value('ProjectName'), 'qbs')}"
        },
        {
          "key": "CMakeFileName",
          "value": "%{ProjectDirectory}/CMakeLists.txt"
        },
        { "key": "IsTopLevelProject",
           "value": "%{JS: !'%{Exists:ProjectExplorer.Profile.Ids}' }"
        },
        { "key": "MainCppName",
          "value": "%{JS: 'main.' + Util.preferredSuffix('text/x-c++src') }"
        },
        {
          "key": "GUARD",
          "value": "%{JS: value('TestCaseFileWithHeaderSuffix').toUpperCase().replace('.', '_') }"
        },
        {
          "key": "TestCaseFileWithCppSuffix",
          "value": "%{JS: 'tst_' + value('TestCaseName').toLowerCase() + '.' + Util.preferredSuffix('text/x-c++src') }"
        }
    ],

    "pages":
    [
        {
            "trDisplayName": "Project Location",
            "trShortTitle": "Location",
            "typeId": "Project",
            "data":
            {
                "trDescription": "This wizard creates a simple unit test project using Catch2."
            }
        },
        {
            "trDisplayName": "Project and Test Information",
            "trShortTitle": "Details",
            "typeId": "Fields",
            "data":
            [
                {
                    "name": "TestFrameWork",
                    "trDisplayName": "Test framework:",
                    "type": "ComboBox",
                    "data":
                    {
                        "index": 1,
                        "items":
                        [
                            {
                                "trKey": "Catch2 v2 (header only)",
                                "value": "Catch2"
                            },
                            {
                                "trKey": "Catch2 v3 (shared libraries)",
                                "value": "Catch2_dyn"
                            }
                        ]
                    }
                },
                {
                    "name": "TestCaseName",
                    "trDisplayName": "Test case name:",
                    "mandatory": true,
                    "type": "LineEdit",
                    "data": { "validator": "^[a-zA-Z_0-9]+$" }
                },
                {
                    "name": "CatchIncDir",
                    "trDisplayName": "Catch2 include directory (optional):",
                    "visible": "%{JS: value('TestFrameWork') === 'Catch2'}",
                    "mandatory": false,
                    "type": "PathChooser",
                    "data": {
                        "kind": "existingDirectory"
                    }
                },
                {
                    "name": "CatchInstallDir",
                    "trDisplayName": "Catch2 install directory (optional):",
                    "visible": "%{JS: value('TestFrameWork') === 'Catch2_dyn'}",
                    "mandatory": false,
                    "type": "PathChooser",
                    "data": {
                        "kind": "existingDirectory"
                    }
                },
                {
                    "name": "Catch2Main",
                    "trDisplayName": "Use own main",
                    "visible": "%{JS: '%{TestFrameWork}' === 'Catch2_dyn'}",
                    "type": "CheckBox",
                    "data": {
                        "checked": false
                    }
                },
                {
                    "name": "Catch2NeedsQt",
                    "trDisplayName": "Use Qt libraries",
                    "type": "CheckBox",
                    "data": {
                        "checked": false
                    }
                },
                {
                    "name": "BuildSystem",
                    "trDisplayName": "Build system:",
                    "type": "ComboBox",
                    "persistenceKey": "BuildSystemType",
                    "data":
                    {
                        "index": 1,
                        "items":
                        [
                            {
                                "trKey": "qmake",
                                "value": "qmake",
                                "condition": "%{JS: value('Plugins').indexOf('QmakeProjectManager') >= 0}"
                            },
                            {
                                "trKey": "CMake",
                                "value": "cmake",
                                "condition": "%{JS: value('Plugins').indexOf('CMakeProjectManager') >= 0}"
                            },
                            {
                                "trKey": "Qbs",
                                "value": "qbs",
                                "condition": "%{JS: value('Plugins').indexOf('QbsProjectManager') >= 0}"
                            }
                        ]
                    }
                }
            ]
        },
        {
            "trDisplayName": "Kit Selection",
            "trShortTitle": "Kits",
            "typeId": "Kits",
            "enabled": "%{IsTopLevelProject}",
            "data": {
                 "projectFilePath": "%{ProjectFilePath}",
                 "requiredFeatures": [ "%{JS: (value('Catch2NeedsQt') == 'true' || value('BuildSystem') === 'qmake') ? 'QtSupport.Wizards.FeatureQt' : 'DeviceType.Desktop' }" ]
            }
        },
        {
            "trDisplayName": "Project Management",
            "trShortTitle": "Summary",
            "typeId": "Summary"
        }
    ],
    "generators":
    [
        {
            "typeId": "File",
            "data":
            [
                {
                    "source": "../files/tst.pro",
                    "target": "%{ProjectFilePath}",
                    "condition": "%{JS: value('BuildSystem') == 'qmake'}",
                    "openInEditor": false,
                    "openAsProject": true
                },
                {
                    "source": "../files/catch-common.pri",
                    "target": "catch-common.pri",
                    "openInEditor": false,
                    "condition": "%{JS: value('BuildSystem') == 'qmake' && '%{TestFrameWork}' == 'Catch2_dyn'}"
                },
                {
                    "source": "../files/tst.qbs",
                    "target": "%{ProjectFilePath}",
                    "condition": "%{JS: value('BuildSystem') == 'qbs'}",
                    "openInEditor": false,
                    "openAsProject": true
                },
                {
                    "source": "../files/catchCommon.js",
                    "target": "catchCommon.js",
                    "condition": "%{JS: value('BuildSystem') == 'qbs'}",
                    "openInEditor": false
                },
                {
                    "source": "../files/tst.txt",
                    "target": "CMakeLists.txt",
                    "condition": "%{JS: value('BuildSystem') == 'cmake'}",
                    "openInEditor": false,
                    "openAsProject": true
                },
                {
                    "source": "../files/tst_main.cpp",
                    "condition": "%{JS: '%{TestFrameWork}' == 'Catch2' || value('Catch2Main') == 'true'}",
                    "target": "%{MainCppName}",
                    "openInEditor": true
                },
                {
                    "source": "../files/catch2_tst.cpp",
                    "target": "%{TestCaseFileWithCppSuffix}",
                    "openInEditor": true
                },
                {
                    "source": "../../projects/git.ignore",
                    "target": ".gitignore",
                    "condition": "%{JS: ( %{IsTopLevelProject} && value('VersionControl') === 'G.Git' )}"
                }
            ]
        }
    ]
}
