cordova-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vladimir-kotikov <...@git.apache.org>
Subject [GitHub] cordova-plugin-camera pull request: Appium tests stability improve...
Date Mon, 11 Apr 2016 11:33:11 GMT
Github user vladimir-kotikov commented on a diff in the pull request:

    https://github.com/apache/cordova-plugin-camera/pull/202#discussion_r59189798
  
    --- Diff: appium-tests/android/android.spec.js ---
    @@ -251,141 +200,50 @@ describe('Camera tests Android.', function () {
                         .click();
                 }, function () {
                     // couldn't find Delete menu item. Possibly there is no image.
    -                return;
    +                return driver;
                 });
         }
     
         function getDriver() {
             driver = wdHelper.getDriver('Android');
    -        return driver;
    -    }
    -
    -    function checkStopFlag() {
    -        if (stopFlag) {
    -            fail('Something went wrong: the stopFlag is on. Please see the log for more
details.');
    -        }
    -        return stopFlag;
    +        return wdHelper.getWebviewContext(driver)
    +            .then(function(context) {
    +                webviewContext = context;
    +                return driver.context(webviewContext);
    +            })
    +            .then(function () {
    +                return wdHelper.waitForDeviceReady(driver);
    +            })
    +            .then(function () {
    +                return wdHelper.injectLibraries(driver);
    +            });
         }
     
    -    beforeEach(function () {
    -        jasmine.addMatchers({
    -            toFailWithMessage : function () {
    -                return {
    -                    compare: function (actual, msg) {
    -                        console.log('Failing with message: ' + msg);
    -                        var result = {
    -                            pass: false,
    -                            message: msg
    -                        };
    -                        // status 6 means that we've lost the session
    -                        // status 7 means that Appium couldn't find an element
    -                        // both these statuses mean that the test has failed but
    -                        // we should try to recreate the session for the following tests
    -                        if (msg.indexOf('Error response status: 6') >= 0 ||
    -                            msg.indexOf('Error response status: 7') >= 0) {
    -                            errorFlag = true;
    -                        }
    -                        return result;
    -                    }
    -                };
    -            }
    -        });
    -    });
    -
         it('camera.ui.util configuring driver and starting a session', function (done) {
    -        stopFlag = true; // just in case of timeout
    -        getDriver().then(function () {
    -            stopFlag = false;
    -        }, function (error) {
    -            fail(error);
    -        })
    -        .finally(done);
    +        getDriver()
    +            .fail(fail)
    +            .done(done);
         }, 5 * MINUTE);
     
    -    it('camera.ui.util determine webview context name', function (done) {
    -        var i = 0;
    -        return driver
    -            .contexts(function (err, contexts) {
    -                if (err) {
    -                    console.log(err);
    -                }
    -                for (i = 0; i < contexts.length; i++) {
    -                    if (contexts[i].indexOf('mobilespec') >= 0) {
    -                        webviewContext = contexts[i];
    -                    }
    -                }
    -                done();
    -            });
    -    }, MINUTE);
    -
         it('camera.ui.util determine screen dimensions', function (done) {
    -        return enterTest()
    -            .execute('document.getElementById(\'info\').innerHTML = window.innerWidth;')
    -            .sleep(5000)
    -            .elementById('info')
    -            .getAttribute('innerHTML')
    -            .then(function (html) {
    -                if (html !== STARTING_MESSAGE) {
    -                    screenWidth = Number(html);
    -                }
    +        return driver
    +            .context(webviewContext)
    +            .execute(function () {
    +                return window.innerWidth;
    --- End diff --
    
    Is it possible to combine requesting both `window.innerWidth` and `window.innerHeight`
into one `execute` call? I think you can just return an object `{width: ..., height: ...}`


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@cordova.apache.org
For additional commands, e-mail: dev-help@cordova.apache.org


Mime
View raw message