Repository: cordova-plugin-camera Updated Branches: refs/heads/master 180f7b551 -> 9badea4c9
CB-12622: (android) Appium tests: Bust Android 6 and 7 permission dialogs Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/repo Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/commit/9badea4c Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/tree/9badea4c Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/diff/9badea4c Branch: refs/heads/master Commit: 9badea4c9509d8d40f17530fb84ea49f223fc925 Parents: 180f7b5 Author: Alexander Sorokin <[email protected]> Authored: Thu Apr 20 09:01:54 2017 +0300 Committer: Alexander Sorokin <[email protected]> Committed: Thu Apr 20 14:58:03 2017 +0300 ---------------------------------------------------------------------- appium-tests/android/android.spec.js | 37 ++++++++++++++++++++++++++++++- appium-tests/helpers/cameraHelper.js | 3 +++ 2 files changed, 39 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/blob/9badea4c/appium-tests/android/android.spec.js ---------------------------------------------------------------------- diff --git a/appium-tests/android/android.spec.js b/appium-tests/android/android.spec.js index 34e65b5..69f7e35 100644 --- a/appium-tests/android/android.spec.js +++ b/appium-tests/android/android.spec.js @@ -225,6 +225,40 @@ describe('Camera tests Android.', function () { }) .waitForDeviceReady() .injectLibraries() + .then(function () { + var options = { + quality: 50, + allowEdit: false, + sourceType: cameraConstants.PictureSourceType.SAVEDPHOTOALBUM, + saveToPhotoAlbum: false, + targetWidth: 210, + targetHeight: 210 + }; + return driver + .then(function () { return getPicture(options, true); }) + .context(CONTEXT_NATIVE_APP) + // case insensitive select, will be handy with Android 7 support + .elementByXPath('//android.widget.Button[translate(@text, "alow", "ALOW")="ALLOW"]') + .click() + .fail(function noAlert() { }) + .deviceKeyEvent(BACK_BUTTON) + .sleep(2000) + .elementById('action_bar_title') + .then(function () { + // success means we're still in native app + return driver + .deviceKeyEvent(BACK_BUTTON); + }, function () { + // error means we're already in webview + return driver; + }); + }) + .then(function () { + // doing it inside a function because otherwise + // it would not hook up to the webviewContext var change + // in the first methods of this chain + return driver.context(webviewContext); + }) .deleteFillerImage(fillerImagePath) .then(function () { fillerImagePath = null; @@ -291,6 +325,7 @@ describe('Camera tests Android.', function () { pending('This test requires a functioning camera on the Android device/emulator, and this test suite\'s functional camera test failed on your target environment.'); } } + afterAll(function (done) { checkSession(done); driver @@ -390,7 +425,7 @@ describe('Camera tests Android.', function () { return driver .elementByAndroidUIAutomator('new UiSelector().text("Choose video")') .fail(function () { - throw 'Couldn\'t find "Choose video" element.'; + throw 'Couldn\'t find a "Choose video" element.'; }); }) .deviceKeyEvent(BACK_BUTTON) http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/blob/9badea4c/appium-tests/helpers/cameraHelper.js ---------------------------------------------------------------------- diff --git a/appium-tests/helpers/cameraHelper.js b/appium-tests/helpers/cameraHelper.js index a16916f..caf0f9e 100644 --- a/appium-tests/helpers/cameraHelper.js +++ b/appium-tests/helpers/cameraHelper.js @@ -169,6 +169,7 @@ module.exports.checkPicture = function (pid, options, cb) { return; } } + try { if (result.indexOf('file:') === 0 || result.indexOf('content:') === 0 || @@ -184,6 +185,8 @@ module.exports.checkPicture = function (pid, options, cb) { } else { verifyFile(entry); } + }, function (err) { + errorCallback(err); }); } else { displayImage(result); --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
