From 920a9799cf4a9378fb28bd2eebb9814b3e8b4f3e Mon Sep 17 00:00:00 2001 From: Andrew Ozz Date: Sat, 15 Feb 2014 21:25:15 +0000 Subject: [PATCH] TinyMCE tests: remove 'coverage' for now, has unsatisfied dependencies. Tweak the test runner so it auto-starts. See #27014. git-svn-id: https://develop.svn.wordpress.org/trunk@27180 602fd350-edb4-49c9-b593-d223f7449a82 --- tests/qunit/editor/coverage/index.html | 29 -- .../qunit/editor/coverage/js/JSCovReporter.js | 194 ----------- .../qunit/editor/coverage/js/backbone-min.js | 4 - tests/qunit/editor/coverage/js/reporter.css | 310 ------------------ tests/qunit/editor/coverage/js/reporter.js | 31 -- .../editor/coverage/js/underscore-min.js | 1 - tests/qunit/editor/js/qunit/testrunner.js | 3 + 7 files changed, 3 insertions(+), 569 deletions(-) delete mode 100644 tests/qunit/editor/coverage/index.html delete mode 100644 tests/qunit/editor/coverage/js/JSCovReporter.js delete mode 100644 tests/qunit/editor/coverage/js/backbone-min.js delete mode 100644 tests/qunit/editor/coverage/js/reporter.css delete mode 100644 tests/qunit/editor/coverage/js/reporter.js delete mode 100644 tests/qunit/editor/coverage/js/underscore-min.js diff --git a/tests/qunit/editor/coverage/index.html b/tests/qunit/editor/coverage/index.html deleted file mode 100644 index dd632bb9c6..0000000000 --- a/tests/qunit/editor/coverage/index.html +++ /dev/null @@ -1,29 +0,0 @@ - - - - -Code Coverage - - - - - - - - - - - - - -
- - - - - diff --git a/tests/qunit/editor/coverage/js/JSCovReporter.js b/tests/qunit/editor/coverage/js/JSCovReporter.js deleted file mode 100644 index 4f530019d8..0000000000 --- a/tests/qunit/editor/coverage/js/JSCovReporter.js +++ /dev/null @@ -1,194 +0,0 @@ -JSCovFileReporter = Backbone.View.extend({ - initialize: function () { - _.bindAll(this); - this.open = '{line_number}{count}'; - this.close = ''; - - this.coverObject = this.options.coverObject; - - this.error = 0; - this.pass = 0; - this.total = 0; - }, - - // substitute credits: MooTools - substitute: function(string, object){ - return string.replace(/\\?\{([^{}]+)\}/g, function(match, name){ - if (match.charAt(0) == '\\') return match.slice(1); - return (object[name] !== null) ? object[name] : ''; - }); - }, - - generateClose: function(count){ - return this.substitute(this.close, { - count: count - }); - }, - - generateOpen: function(hit_count, line_number){ - return this.substitute(this.open, { - 'count': hit_count, - 'line_number': line_number, - 'class': hit_count ? 'hit' : 'miss' - }); - }, - - report: function () { - var thisview = this; - var i, l, k; - - var code = this.coverObject.__code; - - // generate array of all tokens - var codez = []; - for (i = 0, l = code.length; i < l; i++){ - codez.push({ - pos: i, - value: code.slice(i, i + 1) - }); - } - - // CoverObject has keys like "12:200" which means from char 12 to 200 - // This orders all first gaps in a list of dictionaries to ease drawing table lines - var gaps = Object.keys(this.coverObject); - gaps = _.without(gaps, '__code'); - var first_gaps = _.map(gaps, function ( gap ) { - return { - gap: parseInt(gap.split(':')[0], 10), - hit_count: thisview.coverObject[gap] - }; - }).sort(function (a, b) { - if (a['gap'] > b['gap']) return 1; - if (b['gap'] > a['gap']) return -1; - return 0; - }); - - var second_gaps = _.map(gaps, function ( gap ) { - return { - gap: parseInt(gap.split(':')[1], 10), - hit_count: thisview.coverObject[gap] - }; - }).sort(function (a, b) { - if (a['gap'] > b['gap']) return 1; - if (b['gap'] > a['gap']) return -1; - return 0; - }); - - - // If it doesn't start from 0 it's because there are comments in the beginning - // We add a initial gap with one hit - if (first_gaps[0] !== 0) { - first_gaps.splice(0, 0, {gap: 0, hit_count: 1}); - } - - var result = ''; - var number_trailing_whitespaces = 0; - var trailing_whitespaces = ''; - - - // We will go from one gap to the next wrapping them in table lines - for (i=0, l = first_gaps.length; i < l; i++){ - - var hit_count = first_gaps[i]['hit_count']; - - this.total++; - if (hit_count) this.pass++; - else this.error++; - - var limit = null; - if (i+1 >= l) { - limit = codez.length; - } - else { - limit = first_gaps[i+1]['gap']; - } - - // Table line opening - result += this.generateOpen(hit_count, this.total); - - // Add trailing white space if it existed from previous line without carriage returns - if (number_trailing_whitespaces > 0 ) { - result += trailing_whitespaces.replace(/(\r\n|\n|\r)/gm,""); - } - - // Add lines of code without initial white spaces, and replacing conflictive chars - result += _.map(codez.slice(first_gaps[i]['gap'], limit), function (loc) { - return loc['value']; - }).join('').trimLeft().replace(//g, '>'); - - // Count trailing white spaces for future line, then remove them - var matches = result.match(/(\s+)$/); - result = result.trimRight(); - - if (matches !== null) { - number_trailing_whitespaces = matches[0].length; - trailing_whitespaces = matches[0]; - } - else { - number_trailing_whitespaces = 0; - } - - // Generate table line closing - result += this.generateClose(hit_count); - } - - return result; - } -}); - - -JSCovReporter = Backbone.View.extend({ - initialize: function () { - this.coverObject = this.options.coverObject; - - // Generate the report - this.report(); - - // Activate reporter.js scrolling UX - onload(); - }, - - report: function () { - var result = ''; - var index = ''; - - for (var file in this.coverObject) { - var fileReporter = new JSCovFileReporter({ coverObject: this.coverObject[file] }); - - var fileReport = fileReporter.report(); - var percentage = Math.round(fileReporter.pass / fileReporter.total * 100); - - this.error += fileReporter.error; - this.pass += fileReporter.pass; - this.total += fileReporter.total; - - var type_coverage = "high"; - if (percentage < 75 && percentage >= 50) { - type_coverage = 'medium'; - } - else if (percentage < 50 && percentage >= 25) { - type_coverage = 'low'; - } - else if (percentage < 25) { - type_coverage = 'terrible'; - } - - // Title - result += '

' + file + '

'; - // Stats - result += '
'+ percentage + '%
'; - result += '
' + fileReporter.total + '
' + fileReporter.pass + '
'; - result += '
' + fileReporter.error + '
'; - // Report - result += '
'; - result += '' + fileReport + '
'; - result += '
'; - - // Menu index - index += '
  • ' + percentage + '' + file + '
  • '; - } - - $('#coverage').html(result); - $('#menu').html(''); - } -}); diff --git a/tests/qunit/editor/coverage/js/backbone-min.js b/tests/qunit/editor/coverage/js/backbone-min.js deleted file mode 100644 index 3541019c58..0000000000 --- a/tests/qunit/editor/coverage/js/backbone-min.js +++ /dev/null @@ -1,4 +0,0 @@ -(function(){var t=this;var e=t.Backbone;var i=[];var r=i.push;var s=i.slice;var n=i.splice;var a;if(typeof exports!=="undefined"){a=exports}else{a=t.Backbone={}}a.VERSION="1.0.0";var h=t._;if(!h&&typeof require!=="undefined")h=require("underscore");a.$=t.jQuery||t.Zepto||t.ender||t.$;a.noConflict=function(){t.Backbone=e;return this};a.emulateHTTP=false;a.emulateJSON=false;var o=a.Events={on:function(t,e,i){if(!l(this,"on",t,[e,i])||!e)return this;this._events||(this._events={});var r=this._events[t]||(this._events[t]=[]);r.push({callback:e,context:i,ctx:i||this});return this},once:function(t,e,i){if(!l(this,"once",t,[e,i])||!e)return this;var r=this;var s=h.once(function(){r.off(t,s);e.apply(this,arguments)});s._callback=e;return this.on(t,s,i)},off:function(t,e,i){var r,s,n,a,o,u,c,f;if(!this._events||!l(this,"off",t,[e,i]))return this;if(!t&&!e&&!i){this._events={};return this}a=t?[t]:h.keys(this._events);for(o=0,u=a.length;o").attr(t);this.setElement(e,false)}else{this.setElement(h.result(this,"el"),false)}}});a.sync=function(t,e,i){var r=k[t];h.defaults(i||(i={}),{emulateHTTP:a.emulateHTTP,emulateJSON:a.emulateJSON});var s={type:r,dataType:"json"};if(!i.url){s.url=h.result(e,"url")||U()}if(i.data==null&&e&&(t==="create"||t==="update"||t==="patch")){s.contentType="application/json";s.data=JSON.stringify(i.attrs||e.toJSON(i))}if(i.emulateJSON){s.contentType="application/x-www-form-urlencoded";s.data=s.data?{model:s.data}:{}}if(i.emulateHTTP&&(r==="PUT"||r==="DELETE"||r==="PATCH")){s.type="POST";if(i.emulateJSON)s.data._method=r;var n=i.beforeSend;i.beforeSend=function(t){t.setRequestHeader("X-HTTP-Method-Override",r);if(n)return n.apply(this,arguments)}}if(s.type!=="GET"&&!i.emulateJSON){s.processData=false}if(s.type==="PATCH"&&window.ActiveXObject&&!(window.external&&window.external.msActiveXFilteringEnabled)){s.xhr=function(){return new ActiveXObject("Microsoft.XMLHTTP")}}var o=i.xhr=a.ajax(h.extend(s,i));e.trigger("request",e,o,i);return o};var k={create:"POST",update:"PUT",patch:"PATCH","delete":"DELETE",read:"GET"};a.ajax=function(){return a.$.ajax.apply(a.$,arguments)};var S=a.Router=function(t){t||(t={});if(t.routes)this.routes=t.routes;this._bindRoutes();this.initialize.apply(this,arguments)};var $=/\((.*?)\)/g;var T=/(\(\?)?:\w+/g;var H=/\*\w+/g;var A=/[\-{}\[\]+?.,\\\^$|#\s]/g;h.extend(S.prototype,o,{initialize:function(){},route:function(t,e,i){if(!h.isRegExp(t))t=this._routeToRegExp(t);if(h.isFunction(e)){i=e;e=""}if(!i)i=this[e];var r=this;a.history.route(t,function(s){var n=r._extractParameters(t,s);i&&i.apply(r,n);r.trigger.apply(r,["route:"+e].concat(n));r.trigger("route",e,n);a.history.trigger("route",r,e,n)});return this},navigate:function(t,e){a.history.navigate(t,e);return this},_bindRoutes:function(){if(!this.routes)return;this.routes=h.result(this,"routes");var t,e=h.keys(this.routes);while((t=e.pop())!=null){this.route(t,this.routes[t])}},_routeToRegExp:function(t){t=t.replace(A,"\\$&").replace($,"(?:$1)?").replace(T,function(t,e){return e?t:"([^/]+)"}).replace(H,"(.*?)");return new RegExp("^"+t+"$")},_extractParameters:function(t,e){var i=t.exec(e).slice(1);return h.map(i,function(t){return t?decodeURIComponent(t):null})}});var I=a.History=function(){this.handlers=[];h.bindAll(this,"checkUrl");if(typeof window!=="undefined"){this.location=window.location;this.history=window.history}};var N=/^[#\/]|\s+$/g;var P=/^\/+|\/+$/g;var O=/msie [\w.]+/;var C=/\/$/;I.started=false;h.extend(I.prototype,o,{interval:50,getHash:function(t){var e=(t||this).location.href.match(/#(.*)$/);return e?e[1]:""},getFragment:function(t,e){if(t==null){if(this._hasPushState||!this._wantsHashChange||e){t=this.location.pathname;var i=this.root.replace(C,"");if(!t.indexOf(i))t=t.substr(i.length)}else{t=this.getHash()}}return t.replace(N,"")},start:function(t){if(I.started)throw new Error("Backbone.history has already been started");I.started=true;this.options=h.extend({},{root:"/"},this.options,t);this.root=this.options.root;this._wantsHashChange=this.options.hashChange!==false;this._wantsPushState=!!this.options.pushState;this._hasPushState=!!(this.options.pushState&&this.history&&this.history.pushState);var e=this.getFragment();var i=document.documentMode;var r=O.exec(navigator.userAgent.toLowerCase())&&(!i||i<=7);this.root=("/"+this.root+"/").replace(P,"/");if(r&&this._wantsHashChange){this.iframe=a.$('