MDL-47494 ddimageortext: Update dd qtype tests to use js_pending not fixed waits #14895

This commit is contained in:
Tim Hunt
2015-02-13 18:59:19 +00:00
parent cf5977991c
commit 682bf667ea
9 changed files with 28 additions and 9 deletions
@@ -28,7 +28,6 @@ Feature: Preview a drag-drop onto image question
Scenario: Preview a question using the mouse.
When I click on "Preview" "link" in the "Drag onto image" "table_row"
And I switch to "questionpreview" window
And I wait "2" seconds
# Odd, but the <br>s go to nothing, not a space.
And I drag "mountainbelt" to place "1" in the drag and drop onto image question
And I drag "continentalshelf" to place "2" in the drag and drop onto image question
@@ -46,7 +45,6 @@ Feature: Preview a drag-drop onto image question
Scenario: Preview a question using the keyboard.
When I click on "Preview" "link" in the "Drag onto image" "table_row"
And I switch to "questionpreview" window
And I wait "1" seconds
And I type " " on place "1" in the drag and drop onto image question
And I type " " on place "2" in the drag and drop onto image question
And I type " " on place "3" in the drag and drop onto image question
@@ -250,14 +250,17 @@ var DDIMAGEORTEXT_QUESTION = function() {
* This is the code for question rendering.
*/
Y.extend(DDIMAGEORTEXT_QUESTION, M.qtype_ddimageortext.dd_base_class, {
pendingid: '',
initializer : function() {
this.pendingid = 'qtype_ddimageortext-' + Math.random().toString(36).slice(2); // Random string.
M.util.js_pending(this.pendingid);
this.doc = this.doc_structure(this);
this.poll_for_image_load(null, false, 0, this.create_all_drag_and_drops);
this.doc.bg_img().after('load', this.poll_for_image_load, this,
false, 0, this.create_all_drag_and_drops);
this.doc.drag_item_homes().after('load', this.poll_for_image_load, this,
false, 0, this.create_all_drag_and_drops);
Y.later(500, this, this.reposition_drags_for_question, [], true);
Y.later(500, this, this.reposition_drags_for_question, [pendingid], true);
},
create_all_drag_and_drops : function () {
this.init_drops();
@@ -293,6 +296,7 @@ Y.extend(DDIMAGEORTEXT_QUESTION, M.qtype_ddimageortext.dd_base_class, {
v.on('dragchange', this.drop_zone_key_press, this);
}, this);
}
M.util.js_complete(this.pendingid);
},
drop_zone_key_press : function (e) {
switch (e.direction) {
File diff suppressed because one or more lines are too long
@@ -250,14 +250,17 @@ var DDIMAGEORTEXT_QUESTION = function() {
* This is the code for question rendering.
*/
Y.extend(DDIMAGEORTEXT_QUESTION, M.qtype_ddimageortext.dd_base_class, {
pendingid: '',
initializer : function() {
this.pendingid = 'qtype_ddimageortext-' + Math.random().toString(36).slice(2); // Random string.
M.util.js_pending(this.pendingid);
this.doc = this.doc_structure(this);
this.poll_for_image_load(null, false, 0, this.create_all_drag_and_drops);
this.doc.bg_img().after('load', this.poll_for_image_load, this,
false, 0, this.create_all_drag_and_drops);
this.doc.drag_item_homes().after('load', this.poll_for_image_load, this,
false, 0, this.create_all_drag_and_drops);
Y.later(500, this, this.reposition_drags_for_question, [], true);
Y.later(500, this, this.reposition_drags_for_question, [pendingid], true);
},
create_all_drag_and_drops : function () {
this.init_drops();
@@ -293,6 +296,7 @@ Y.extend(DDIMAGEORTEXT_QUESTION, M.qtype_ddimageortext.dd_base_class, {
v.on('dragchange', this.drop_zone_key_press, this);
}, this);
}
M.util.js_complete(this.pendingid);
},
drop_zone_key_press : function (e) {
switch (e.direction) {
@@ -24,9 +24,12 @@ var DDIMAGEORTEXT_FORM = function() {
};
Y.extend(DDIMAGEORTEXT_FORM, M.qtype_ddimageortext.dd_base_class, {
pendingid: '',
fp : null,
initializer : function() {
this.pendingid = 'qtype_ddimageortext-form-' + Math.random().toString(36).slice(2); // Random string.
M.util.js_pending(this.pendingid);
this.fp = this.file_pickers();
var tn = Y.one(this.get('topnode'));
tn.one('div.fcontainer').append('<div class="ddarea"><div class="droparea"></div><div class="dragitems"></div>' +
File diff suppressed because one or more lines are too long
@@ -24,9 +24,12 @@ var DDIMAGEORTEXT_FORM = function() {
};
Y.extend(DDIMAGEORTEXT_FORM, M.qtype_ddimageortext.dd_base_class, {
pendingid: '',
fp : null,
initializer : function() {
this.pendingid = 'qtype_ddimageortext-form-' + Math.random().toString(36).slice(2); // Random string.
M.util.js_pending(this.pendingid);
this.fp = this.file_pickers();
var tn = Y.one(this.get('topnode'));
tn.one('div.fcontainer').append('<div class="ddarea"><div class="droparea"></div><div class="dragitems"></div>' +
@@ -248,14 +248,17 @@ var DDIMAGEORTEXT_QUESTION = function() {
* This is the code for question rendering.
*/
Y.extend(DDIMAGEORTEXT_QUESTION, M.qtype_ddimageortext.dd_base_class, {
pendingid: '',
initializer : function() {
this.pendingid = 'qtype_ddimageortext-' + Math.random().toString(36).slice(2); // Random string.
M.util.js_pending(this.pendingid);
this.doc = this.doc_structure(this);
this.poll_for_image_load(null, false, 0, this.create_all_drag_and_drops);
this.doc.bg_img().after('load', this.poll_for_image_load, this,
false, 0, this.create_all_drag_and_drops);
this.doc.drag_item_homes().after('load', this.poll_for_image_load, this,
false, 0, this.create_all_drag_and_drops);
Y.later(500, this, this.reposition_drags_for_question, [], true);
Y.later(500, this, this.reposition_drags_for_question, [pendingid], true);
},
create_all_drag_and_drops : function () {
this.init_drops();
@@ -291,6 +294,7 @@ Y.extend(DDIMAGEORTEXT_QUESTION, M.qtype_ddimageortext.dd_base_class, {
v.on('dragchange', this.drop_zone_key_press, this);
}, this);
}
M.util.js_complete(this.pendingid);
},
drop_zone_key_press : function (e) {
switch (e.direction) {
+3
View File
@@ -22,9 +22,12 @@ var DDIMAGEORTEXT_FORM = function() {
};
Y.extend(DDIMAGEORTEXT_FORM, M.qtype_ddimageortext.dd_base_class, {
pendingid: '',
fp : null,
initializer : function() {
this.pendingid = 'qtype_ddimageortext-form-' + Math.random().toString(36).slice(2); // Random string.
M.util.js_pending(this.pendingid);
this.fp = this.file_pickers();
var tn = Y.one(this.get('topnode'));
tn.one('div.fcontainer').append('<div class="ddarea"><div class="droparea"></div><div class="dragitems"></div>' +