Skip to content

Commit

Permalink
MDL-47494 ddmarker: Update dd qtype tests to use js_pending not fixed…
Browse files Browse the repository at this point in the history
… waits #14895
  • Loading branch information
timhunt committed Feb 13, 2015
1 parent 24c6f2f commit 4f168c8
Show file tree
Hide file tree
Showing 9 changed files with 27 additions and 8 deletions.
2 changes: 0 additions & 2 deletions question/type/ddmarker/tests/behat/preview.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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 markers" "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 "OU" to "340,228" in the drag and drop markers question
And I drag "Railway station" to "252,195" in the drag and drop markers question
Expand All @@ -42,7 +41,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 markers" "table_row"
And I switch to "questionpreview" window
And I wait "1" seconds
And I type "up" "89" times on marker "Railway station" in the drag and drop markers question
And I type "right" "21" times on marker "Railway station" in the drag and drop markers question
And I press "Submit and finish"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -308,14 +308,18 @@ var DDMARKER_QUESTION = function() {
* This is the code for question rendering.
*/
Y.extend(DDMARKER_QUESTION, M.qtype_ddmarker.dd_base_class, {
pendingid: '',
initializer : function() {
this.pendingid = 'qtype_ddmarker-' + 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.after_image_load);
this.doc.bg_img().after('load', this.poll_for_image_load, this,
false, 0, this.after_image_load);
},
after_image_load : function () {
this.redraw_drags_and_drops();
M.util.js_complete(this.pendingid);
Y.later(2000, this, this.redraw_drags_and_drops, [], true);
},
clone_new_drag_item : function (draghome, itemno) {
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -308,14 +308,18 @@ var DDMARKER_QUESTION = function() {
* This is the code for question rendering.
*/
Y.extend(DDMARKER_QUESTION, M.qtype_ddmarker.dd_base_class, {
pendingid: '',
initializer : function() {
this.pendingid = 'qtype_ddmarker-' + 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.after_image_load);
this.doc.bg_img().after('load', this.poll_for_image_load, this,
false, 0, this.after_image_load);
},
after_image_load : function () {
this.redraw_drags_and_drops();
M.util.js_complete(this.pendingid);
Y.later(2000, this, this.redraw_drags_and_drops, [], true);
},
clone_new_drag_item : function (draghome, itemno) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ Y.extend(DDMARKER_FORM, M.qtype_ddmarker.dd_base_class, {
fp : null,

initializer : function() {
var pendingid = 'qtype_ddmarker-form-' + Math.random().toString(36).slice(2); // Random string.
M.util.js_pending(pendingid);
this.fp = this.file_pickers();
var tn = Y.one(this.get('topnode'));
tn.one('div.fcontainer').append(
Expand All @@ -39,7 +41,7 @@ Y.extend(DDMARKER_FORM, M.qtype_ddmarker.dd_base_class, {
this.stop_selector_events();
this.set_options_for_drag_item_selectors();
this.setup_form_events();
Y.later(500, this, this.update_drop_zones, [], true);
Y.later(500, this, this.update_drop_zones, [pendingid], true);
Y.after(this.load_bg_image, M.form_filepicker, 'callback', this);
this.load_bg_image();
},
Expand Down Expand Up @@ -98,6 +100,7 @@ Y.extend(DDMARKER_FORM, M.qtype_ddmarker.dd_base_class, {
.setXY(this.doc.bg_img().getXY())
.setStyle('width', this.doc.bg_img().get('width'))
.setStyle('height', this.doc.bg_img().get('height'));
M.util.js_complete(this.pendingid);
},

get_coords : function (dropzoneno) {
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ Y.extend(DDMARKER_FORM, M.qtype_ddmarker.dd_base_class, {
fp : null,

initializer : function() {
var pendingid = 'qtype_ddmarker-form-' + Math.random().toString(36).slice(2); // Random string.
M.util.js_pending(pendingid);
this.fp = this.file_pickers();
var tn = Y.one(this.get('topnode'));
tn.one('div.fcontainer').append(
Expand All @@ -39,7 +41,7 @@ Y.extend(DDMARKER_FORM, M.qtype_ddmarker.dd_base_class, {
this.stop_selector_events();
this.set_options_for_drag_item_selectors();
this.setup_form_events();
Y.later(500, this, this.update_drop_zones, [], true);
Y.later(500, this, this.update_drop_zones, [pendingid], true);
Y.after(this.load_bg_image, M.form_filepicker, 'callback', this);
this.load_bg_image();
},
Expand Down Expand Up @@ -98,6 +100,7 @@ Y.extend(DDMARKER_FORM, M.qtype_ddmarker.dd_base_class, {
.setXY(this.doc.bg_img().getXY())
.setStyle('width', this.doc.bg_img().get('width'))
.setStyle('height', this.doc.bg_img().get('height'));
M.util.js_complete(this.pendingid);
},

get_coords : function (dropzoneno) {
Expand Down
4 changes: 4 additions & 0 deletions question/type/ddmarker/yui/src/ddmarker/js/ddmarker.js
Original file line number Diff line number Diff line change
Expand Up @@ -306,14 +306,18 @@ var DDMARKER_QUESTION = function() {
* This is the code for question rendering.
*/
Y.extend(DDMARKER_QUESTION, M.qtype_ddmarker.dd_base_class, {
pendingid: '',
initializer : function() {
this.pendingid = 'qtype_ddmarker-' + 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.after_image_load);
this.doc.bg_img().after('load', this.poll_for_image_load, this,
false, 0, this.after_image_load);
},
after_image_load : function () {
this.redraw_drags_and_drops();
M.util.js_complete(this.pendingid);
Y.later(2000, this, this.redraw_drags_and_drops, [], true);
},
clone_new_drag_item : function (draghome, itemno) {
Expand Down
5 changes: 4 additions & 1 deletion question/type/ddmarker/yui/src/form/js/form.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ Y.extend(DDMARKER_FORM, M.qtype_ddmarker.dd_base_class, {
fp : null,

initializer : function() {
var pendingid = 'qtype_ddmarker-form-' + Math.random().toString(36).slice(2); // Random string.
M.util.js_pending(pendingid);
this.fp = this.file_pickers();
var tn = Y.one(this.get('topnode'));
tn.one('div.fcontainer').append(
Expand All @@ -37,7 +39,7 @@ Y.extend(DDMARKER_FORM, M.qtype_ddmarker.dd_base_class, {
this.stop_selector_events();
this.set_options_for_drag_item_selectors();
this.setup_form_events();
Y.later(500, this, this.update_drop_zones, [], true);
Y.later(500, this, this.update_drop_zones, [pendingid], true);
Y.after(this.load_bg_image, M.form_filepicker, 'callback', this);
this.load_bg_image();
},
Expand Down Expand Up @@ -96,6 +98,7 @@ Y.extend(DDMARKER_FORM, M.qtype_ddmarker.dd_base_class, {
.setXY(this.doc.bg_img().getXY())
.setStyle('width', this.doc.bg_img().get('width'))
.setStyle('height', this.doc.bg_img().get('height'));
M.util.js_complete(this.pendingid);
},

get_coords : function (dropzoneno) {
Expand Down

0 comments on commit 4f168c8

Please sign in to comment.