{
    "version": 1,
    "supportedProjectTypes": [ "CMakeProjectManager.CMakeProject", "Qbs.QbsProject", "Qt4ProjectManager.Qt4Project" ],
    "id": "R.AutoTest",
    "category": "H.Project",
    "trDescription": "Creates a new unit test project. Unit tests allow you to verify that the code is fit for use and that there are no regressions.",
    "trDisplayName": "Auto Test Project",
    "trDisplayCategory": "Other Project",
    "icon": "autotest.png",
    "iconKind": "Themed",
    "featuresRequired": [ "QtSupport.Wizards.FeatureDesktop" ],
    "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": "TestCaseFileGTestWithCppSuffix",
          "value": "%{JS: 'tst_' + value('TestCaseName').toLowerCase() + '.' + 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') }"
        },
        {
            "key": "TestCaseFileWithQmlSuffix",
            "value": "%{JS: 'tst_' + value('TestCaseName').toLowerCase() + '.qml' }"
        }
    ],

    "pages":
    [
        {
            "trDisplayName": "Project Location",
            "trShortTitle": "Location",
            "typeId": "Project",
            "data":
            {
                "trDescription": "This wizard creates a simple unit test project."
            }
        },
        {
            "trDisplayName": "Project and Test Information",
            "trShortTitle": "Details",
            "typeId": "Fields",
            "data":
            [
                {
                    "name": "TestFrameWork",
                    "trDisplayName": "Test framework:",
                    "type": "ComboBox",
                    "data":
                    {
                        "index": 0,
                        "items":
                        [
                            {
                                "trKey": "Qt Test",
                                "value": "QtTest"
                            },
                            {
                                "trKey": "Google Test",
                                "value": "GTest"
                            },
                            {
                                "trKey": "Qt Quick Test",
                                "value": "QtQuickTest"
                            },
                            {
                                "trKey": "Boost Test (header only)",
                                "value": "BoostTest"
                            },
                            {
                                "trKey": "Boost Test (shared libraries)",
                                "value": "BoostTest_dyn"
                            },
                            {
                                "trKey": "Catch2",
                                "value": "Catch2"
                            }

                        ]
                    }
                },
                {
                    "name": "RequireGUI",
                    "trDisplayName": "GUI Application",
                    "visible": "%{JS: value('TestFrameWork') === 'QtTest'}",
                    "type": "CheckBox",
                    "data": {
                        "checked": false
                    }
                },
                {
                    "name": "TestSuiteName",
                    "trDisplayName": "Test suite name:",
                    "visible": "%{JS: ['BoostTest', 'BoostTest_dyn', 'GTest'].indexOf(value('TestFrameWork')) >= 0}",
                    "mandatory": true,
                    "type": "LineEdit",
                    "data": { "validator": "^[a-zA-Z_0-9]+$" }
                },
                {
                    "name": "TestCaseName",
                    "trDisplayName": "Test case name:",
                    "mandatory": true,
                    "type": "LineEdit",
                    "data": { "validator": "^[a-zA-Z_0-9]+$" }
                },
                {
                    "name": "RequireApplication",
                    "trDisplayName": "Requires QApplication",
                    "visible": "%{JS: value('TestFrameWork') === 'QtTest'}",
                    "type": "CheckBox",
                    "data": {
                        "checked": false
                    }
                },
                {
                    "name": "UseSetupCode",
                    "trDisplayName": "Generate setup code",
                    "visible": "%{JS: value('TestFrameWork') === 'QtQuickTest'}",
                    "type": "CheckBox",
                    "data": {
                        "checked": false
                    }
                },
                {
                    "name": "GenerateInitAndCleanup",
                    "trDisplayName": "Generate initialization and cleanup code",
                    "visible": "%{JS: [ 'QtTest', 'QtQuickTest' ].indexOf(value('TestFrameWork')) >= 0 }",
                    "type": "CheckBox",
                    "data": {
                        "checked": false
                    }
                },
                {
                    "name": "GTestCXX11",
                    "trDisplayName": "Enable C++11",
                    "visible": "%{JS: value('TestFrameWork') === 'GTest'}",
                    "type": "CheckBox",
                    "data": {
                        "checked": false
                    }
                },
                {
                    "name": "GTestRepository",
                    "trDisplayName": "Googletest source directory (optional):",
                    "visible": "%{JS: value('TestFrameWork') === 'GTest'}",
                    "mandatory": false,
                    "type": "PathChooser",
                    "data": {
                        "kind": "existingDirectory"
                    }
                },
                {
                    "name": "BoostIncDir",
                    "trDisplayName": "Boost include directory (optional):",
                    "visible": "%{JS: value('TestFrameWork') == 'BoostTest'}",
                    "mandatory": false,
                    "type": "PathChooser",
                    "data": {
                        "kind": "existingDirectory"
                    }
                },
                {
                    "name": "BoostInstallDir",
                    "trDisplayName": "Boost install directory (optional):",
                    "visible": "%{JS: value('TestFrameWork') == 'BoostTest_dyn'}",
                    "mandatory": false,
                    "type": "PathChooser",
                    "data": {
                        "kind": "existingDirectory"
                    }
                },
                {
                    "name": "CatchIncDir",
                    "trDisplayName": "Catch2 include directory (optional):",
                    "visible": "%{JS: value('TestFrameWork') === 'Catch2'}",
                    "mandatory": false,
                    "type": "PathChooser",
                    "data": {
                        "kind": "existingDirectory"
                    }
                },
                {
                    "name": "Catch2NeedsQt",
                    "trDisplayName": "Use Qt libraries",
                    "visible": "%{JS: '%{TestFrameWork}' === 'Catch2'}",
                    "type": "CheckBox",
                    "data": {
                        "checked": true
                    }
                },
                {
                    "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('TestFrameWork') === 'QtQuickTest' ? 'QtSupport.Wizards.FeatureQtQuick.2' : ((value('BuildSystem') === 'qmake' || value('TestFrameWork') === 'QtTest') ? 'QtSupport.Wizards.FeatureQt' : 'DeviceType.Desktop' )) }" ]
            }
        },
        {
            "trDisplayName": "Project Management",
            "trShortTitle": "Summary",
            "typeId": "Summary"
        }
    ],
    "generators":
    [
        {
            "typeId": "File",
            "data":
            [
                {
                    "source": "files/gtest_dependency.pri",
                    "target": "gtest_dependency.pri",
                    "condition": "%{JS: value('TestFrameWork') == 'GTest' && value('BuildSystem') == 'qmake'}",
                    "openInEditor": false
                },
                {
                    "source": "files/googlecommon.js",
                    "target": "googlecommon.js",
                    "condition": "%{JS: value('TestFrameWork') == 'GTest' && value('BuildSystem') == 'qbs'}",
                    "openInEditor": false
                },
                {
                    "source": "files/tst.pro",
                    "target": "%{ProjectFilePath}",
                    "condition": "%{JS: value('BuildSystem') == 'qmake'}",
                    "openInEditor": false,
                    "openAsProject": true
                },
                {
                    "source": "files/tst.qbs",
                    "target": "%{ProjectFilePath}",
                    "condition": "%{JS: value('BuildSystem') == 'qbs'}",
                    "openInEditor": false,
                    "openAsProject": true
                },
                {
                    "source": "files/tst.txt",
                    "target": "CMakeLists.txt",
                    "condition": "%{JS: value('BuildSystem') == 'cmake'}",
                    "openInEditor": false,
                    "openAsProject": true
                },
                {
                    "source": "files/tst_src_gt.cpp",
                    "target": "%{TestCaseFileGTestWithCppSuffix}",
                    "condition": "%{JS: value('TestFrameWork') == 'GTest'}",
                    "openInEditor": true
                },
                {
                    "source": "files/tst_src.cpp",
                    "target": "%{TestCaseFileWithCppSuffix}",
                    "condition": "%{JS: value('TestFrameWork') == 'QtTest'}",
                    "openInEditor": true
                },
                {
                    "source": "files/tst_main.cpp",
                    "target": "%{MainCppName}",
                    "condition": "%{JS: ['GTest', 'QtQuickTest', 'BoostTest', 'BoostTest_dyn', 'Catch2'].indexOf(value('TestFrameWork')) >= 0}",
                    "openInEditor": true
                },
                {
                    "source": "files/tst_src_boost.cpp",
                    "target": "%{TestCaseFileWithCppSuffix}",
                    "condition": "%{JS: value('TestFrameWork') === 'BoostTest_dyn'}"
                },
                {
                    "source": "files/tst_qml.tmpl",
                    "target": "%{TestCaseFileWithQmlSuffix}",
                    "condition": "%{JS: value('TestFrameWork') === 'QtQuickTest'}",
                    "openInEditor": true
                },
                {
                    "source": "files/setup.cpp",
                    "target": "setup.cpp",
                    "condition": "%{JS: value('TestFrameWork') === 'QtQuickTest'}",
                    "openInEditor": true
                },
                {
                    "source": "files/setup.h",
                    "target": "setup.h",
                    "condition": "%{JS: value('TestFrameWork') === 'QtQuickTest'}",
                    "openInEditor": true
                },
                {
                    "source": "files/catch2_tst.cpp",
                    "target": "%{TestCaseFileWithCppSuffix}",
                    "condition": "%{JS: '%{TestFrameWork}' === 'Catch2'}",
                    "openInEditor": true
                },
                {
                    "source": "../projects/git.ignore",
                    "target": ".gitignore",
                    "condition": "%{JS: ( %{IsTopLevelProject} && value('VersionControl') === 'G.Git' )}"
                }
            ]
        }
    ]
}
