/*

Siesta 5.1.0
Copyright(c) 2009-2018 Bryntum AB
https://bryntum.com/contact
https://bryntum.com/products/siesta/license

*/
/**
@class Siesta.Project.Browser.SenchaTouch
@extends Siesta.Project.Browser
@mixin Siesta.Project.Browser.ExtJSCore

A Class representing the browser project. This class provides a web-based UI and defines some additional configuration options.

The default value of the `testClass` configuration option in this class is {@link Siesta.Test.SenchaTouch}, which inherits from
{@link Siesta.Test.Browser} and contains various Sencha Touch-specific assertions. Use this project class when testing Sencha Touch applications.

* **Note** Make sure, you've checked the {@link #performSetup} configuration option.

This file is for reference only, for a getting start guide and manual, please refer to <a href="#!/guide/getting_started_browser">Siesta getting started in browser environment</a> guide.

Synopsys
========

    var project = new Siesta.Project.Browser.SenchaTouch();

    project.configure({
        title           : 'Awesome Sencha Touch Application Test Suite',

        transparentEx   : true,

        preload         : [
            "http://cdn.sencha.io/ext-4.0.2a/ext-all-debug.js",
            "../awesome-project-all.js"
        ]
    })


    project.plan(
        // simple string - url relative to project file
        'sanity.t.js',

        // test file descriptor with own configuration options
        {
            url     : 'basic.t.js',

            // replace `preload` option of project
            preload : [
                "http://cdn.sencha.io/ext-4.0.6/ext-all-debug.js",
                "../awesome-project-all.js"
            ]
        },

        // groups ("folders") of test files (possibly with own options)
        {
            group       : 'Sanity',

            autoCheckGlobals    : false,

            items       : [
                'data/crud.t.js',
                ...
            ]
        },
        ...
    )


*/

Class('Siesta.Project.Browser.SenchaTouch', {

    isa: Siesta.Project.Browser,

    does    : [
        Siesta.Project.Browser.ExtJSCore
    ],

    has     : {
        /**
        * @cfg {Class} testClass The test class which will be used for creating test instances, defaults to {@link Siesta.Test.SenchaTouch}.
        * You can subclass {@link Siesta.Test.SenchaTouch} and provide a new class.
        *
        * This option can be also specified in the test file descriptor.
        */
        testClass           : Siesta.Test.SenchaTouch,

        /**
         * @cfg {Boolean} transparentEx
         */
        transparentEx       : true,
        keepNLastResults    : 0,

        /**
         * @cfg {Boolean} performSetup When set to `true`, Siesta will perform a `Ext.setup()` call, so you can safely assume there's a viewport for example.
         * If, however your test code, performs `Ext.setup()` itself, you need to disable this option.
         *
         * If this option is not explicitly specified in the test descritor, but instead inherited, it will be automatically disabled if test has {@link #pageUrl} value.
         *
         * This option can be also specified in the test file descriptor.
         */
        performSetup        : true,

        forcedRunCore       : 'sequential',

        isRunningOnMobile   : true,

        contentManagerClass : Siesta.Content.Manager.Browser.ExtJSCore
    },


    methods: {

        setup : function () {
            // TODO fix proper mobile detection, since Ext may be absent in "no-ui" project
            this.isRunningOnMobile = typeof Ext !== 'undefined' && Ext.getVersion && Ext.getVersion('touch')

            if (!this.isRunningOnMobile) this.keepNLastResults = 2

            this.SUPERARG(arguments)
        },


        getNewTestConfiguration: function (desc, scopeProvider, contentManager, launchState) {
            var config      = this.SUPERARG(arguments)
            var pageUrl     = this.getDescriptorConfig(desc, 'pageUrl');

            if (!desc.hasOwnProperty('performSetup') && pageUrl) {
                config.performSetup = false;
            } else {
                config.performSetup = this.getDescriptorConfig(desc, 'performSetup')
            }

            return config
        }
    }
})


// backward compat
Class('Siesta.Harness.Browser.SenchaTouch', { isa : Siesta.Project.Browser.SenchaTouch })