Created
October 24, 2014 04:24
-
-
Save yzen/0c154d8d9f1135d684c5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
--- a/apps/calendar/test/marionette/lib/calendar.js | |
+++ b/apps/calendar/test/marionette/lib/calendar.js | |
@@ -10,7 +10,9 @@ var AdvancedSettings = require('./views/advanced_settings'), | |
MonthDay = require('./views/month_day'), | |
ReadEvent = require('./views/read_event'), | |
Settings = require('./views/settings'), | |
- Week = require('./views/week'); | |
+ Week = require('./views/week'), | |
+ AccessibilityHelper = require( | |
+ '../../../../../tests/js-marionette/accessibility_helper.js'); | |
function Calendar(client) { | |
this.client = client.scope({ searchTimeout: 5000 }); | |
@@ -27,6 +29,7 @@ function Calendar(client) { | |
this.readEvent = new ReadEvent(client); | |
this.settings = new Settings(client); | |
this.week = new Week(client); | |
+ this.accessibilityHelper = new AccessibilityHelper(client); | |
} | |
module.exports = Calendar; | |
@@ -149,6 +152,12 @@ Calendar.prototype = { | |
return this; | |
}, | |
+ a11yClickToday: function() { | |
+ this.accessibilityHelper.click(this.client.findElement( | |
+ '#view-selector a[href="#today"]')); | |
+ return this; | |
+ }, | |
+ | |
*/ | |
//============= | |
'use strict'; | |
/* global require, module */ | |
var fs = require('fs'); | |
var atom = fs.readFileSync('./tests/atoms/accessibility.js', { | |
encoding: 'utf-8' | |
}); | |
var AccessibilityHelper = function(client) { | |
function run_async_script(method, args) { | |
client.setScriptTimeout(10000); | |
var value = client.executeAsyncScript( | |
atom + 'return Accessibility.' + method + '(arguments);\n', args); | |
if (!value) { | |
return; | |
} | |
if (value.error) { | |
throw new Error('accessibility.js error: '+ value.error); | |
} else { | |
return value.result; | |
} | |
} | |
this.click = function(element) { | |
run_async_script('click', [element]); | |
}; | |
this.isHidden = function(element) { | |
return run_async_script('isHidden', [element]); | |
}; | |
this.isVisible = function(element) { | |
return run_async_script('isVisible', [element]); | |
}; | |
this.isDisabled = function(element) { | |
return run_async_script('isDisabled', [element]); | |
}; | |
this.wheel = function(element, direction) { | |
client.executeScript( | |
atom + 'Accessibility.wheel(arguments);\n', [element, direction]); | |
}; | |
this.getName = function(element) { | |
return run_async_script('getName', [element]); | |
}; | |
this.getRole = function(element) { | |
return run_async_script('getRole', [element]); | |
}; | |
this.dispatchEvent = function() { | |
client.executeScript('window.wrappedJSObject.dispatchEvent(new ' + | |
'CustomEvent("accessibility-action"))\n'); | |
}; | |
}; | |
module.exports = AccessibilityHelper; | |
//============= |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment