Commit fa229ae7 authored by techird's avatar techird

Merge branch 'dev' of github.com:fex-team/kityminder into dev

parents 324bfbc2 beba0c5a
setlocal EnableDelayedExpansion
del /q /s .\spec\coverage\json_files\*.json
for /f %%j in ('karma start ./spec/karma.conf.js') do set karmaRe=%%j
for /f %%i in ('node ./spec/mergeCoverageForIstanbul.js') do set re=%%i
istanbul report html spec/coverage/json_files/%re%.json
\ No newline at end of file
karmaɵĽjsonʽ
\ No newline at end of file
// Karma configuration
// Generated on Wed Oct 09 2013 19:20:49 GMT+0800 (中国标准时间)
//karma-coverage@0.1.4
module.exports = function(config) {
var base_path = '../';
config.set({
// base path, that will be used to resolve files and exclude
basePath: '',
// frameworks to use
frameworks: ['jasmine'],
// list of files / patterns to load in the browser
files: [
base_path+'spec/tools/js/UserAction.js'
,base_path+'spec/SpecHelper.js'
,base_path+'kity/dist/kitygraph.all.js'
,base_path+'lib/jquery-2.1.0.min.js'
,base_path+'lib/jquery.xml2json.js'
,base_path+'src/core/kityminder.js'
,base_path+'src/core/utils.js'
,base_path+'src/core/command.js'
,base_path+'src/core/node.js'
,base_path+'src/core/module.js'
,base_path+'src/core/event.js'
,base_path+'src/core/minder.js'
,base_path+'src/core/minder.data.js'
,base_path+'src/core/minder.event.js'
,base_path+'src/core/minder.module.js'
,base_path+'src/core/minder.command.js'
,base_path+'src/core/minder.node.js'
,base_path+'src/core/keymap.js'
,base_path+'src/core/minder.lang.js'
,base_path+'src/core/minder.defaultoptions.js'
,base_path+'src/module/geometry.js'
,base_path+'src/module/history.js'
,base_path+'src/module/icon.js'
,base_path+'src/module/layout.js'
,base_path+'src/module/layout.default.js'
,base_path+'src/module/layout.bottom.js'
,base_path+'src/core/minder.select.js'
,base_path+'src/module/view.js'
,base_path+'src/module/dragtree.js'
,base_path+'src/module/dropfile.js'
,base_path+'src/module/keyboard.js'
,base_path+'src/module/select.js'
,base_path+'src/module/history.js'
,base_path+'src/module/editor.js'
,base_path+'src/module/editor.range.js'
,base_path+'src/module/editor.receiver.js'
,base_path+'src/module/editor.selection.js'
,base_path+'src/module/basestyle.js'
,base_path+'src/module/font.js'
,base_path+'src/module/zoom.js'
,base_path+'src/ui/jquery-ui-1.10.4.custom.min.js'
,base_path+'src/ui/widget.js'
,base_path+'src/ui/button.js'
,base_path+'src/ui/toolbar.js'
,base_path+'src/ui/menu.js'
,base_path+'src/ui/dropmenu.js'
,base_path+'src/ui/splitbutton.js'
,base_path+'src/ui/colorsplitbutton.js'
,base_path+'src/ui/popup.js'
,base_path+'src/ui/scale.js'
,base_path+'src/ui/colorpicker.js'
,base_path+'src/ui/combobox.js'
,base_path+'src/ui/buttoncombobox.js'
,base_path+'src/ui/modal.js'
,base_path+'src/ui/tooltip.js'
,base_path+'src/ui/tab.js'
,base_path+'src/ui/separator.js'
,base_path+'src/ui/scale.js'
,base_path+'src/adapter/utils.js'
,base_path+'src/adapter/adapter.js'
,base_path+'src/adapter/button.js'
,base_path+'src/adapter/combobox.js'
,base_path+'src/adapter/saveto.js'
,base_path+'src/adapter/view.js'
,base_path+'src/adapter/tooltips.js'
,base_path+'src/adapter/layout.js'
,base_path+'src/adapter/node.js'
,base_path+'src/adapter/contextmenu.js'
,base_path+'src/adapter/dialog.js'
,base_path+'src/protocal/xmind.js'
,base_path+'src/protocal/freemind.js'
,base_path+'src/protocal/mindmanager.js'
,base_path+'src/protocal/plain.js'
,base_path+'src/protocal/json.js'
,base_path+'src/protocal/png.js'
,base_path+'src/protocal/svg.js'
,base_path+'spec/core/*.js'
,base_path+'spec/module/*.js'
,base_path+'spec/protocal/*.js'
],
// list of files to exclude
exclude: [
'karma.conf.js'
],
// test results reporter to use
// possible values: 'dots', 'progress', 'junit', 'growl', 'coverage'
// reporters: ['progress'],
// web server port
port: 9876,
// enable / disable colors in the output (reporters and logs)
colors: true,
// level of logging
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
logLevel: config.LOG_INFO,
// enable / disable watching file and executing tests whenever any file changes
autoWatch: true,
// Start these browsers, currently available:
// - Chrome
// - ChromeCanary
// - Firefox
// - Opera
// - Safari (only Mac)
// - PhantomJS
// - IE (only Windows)
browsers: ['Firefox','Chrome'],//,'Chrome'
// If browser does not capture in given timeout [ms], kill it
captureTimeout: 60000,
// Continuous Integration mode
// if true, it capture browsers, run tests and exit
singleRun: true,
//coverage
reporters: ['progress', 'coverage','junit'],
preprocessors: {
'../src/core/*.js': ['coverage'],
'../src/adapter/*.js': ['coverage'],
'../src/module/*.js': ['coverage'],
'../src/protocal/*.js': ['coverage'],
'../src/ui/*.js': ['coverage']
}
,
coverageReporter: {
type: 'text',
dir: './coverage/json_files/'
}
,
junitReporter: {
outputFile: './test-results.xml'
}
});
};
/**
* Created by dongyancen on 14-3-26.
*/
var fs = require('fs');
var browsers = ['Chrome', 'Firefox', 'PhantomJS', 'IE'];
var result_forBrowser = {};
var jsonFileBasePath = './spec/coverage/json_files/';
var jsonFiles = fs.readdirSync(jsonFileBasePath);
var finalJsonFile = 'defaultFileName';
var curPath = '/spec';
var resultPath = '.';
//找出所有的json文件
for (var i = 0; i < jsonFiles.length; i++) {
// json文件名必须是有8位的日期和6位的时间戳如:-20140326_161249
if (!isJsonFiles(jsonFiles[i])) {
jsonFiles.splice(i, 1);
i--;
}
}
//没有找到合适的文件
if(jsonFiles.length==0)return;
//先排序 按时间从小到大 及从旧到新
jsonFiles.sort(function (f1, f2) {
var t1 = getFileTime(f1);//形如['-20140326_161249','20140326','161249']
var t2 = getFileTime(f2);
var dateDiff = parseInt(t1[1]) - parseInt(t2[1]);
if (dateDiff != 0)return dateDiff;
else return parseInt(t1[2]) - parseInt(t2[2]);
});
//以时间命名新的文件
finalJsonFile = getFileTime(jsonFiles[jsonFiles.length-1])[0].substring(1);
//如:20140326_161249
//取最新的
// 按浏览器类型分类 result_forBrowser属性形如:{'Crome':'filename1','Firefox':'filename2'}
for (i = 0; i < jsonFiles.length; i++) {
for (var j = 0; j < browsers.length; j++) {
if (eval('/' + browsers[j] + '/.test("' + jsonFiles[i] + '");')) {
eval('result_forBrowser.' + browsers[j] + '="' + jsonFiles[i] + '";');
}
}
}
//以上得到所有要合计的json文件
//读取,合计数字,需要合计的属性: 's' 'b' 'f' 'l'
//修正路径
var jsonToWrite = null;
for (var a in result_forBrowser) {
var r = fs.readFileSync(jsonFileBasePath + result_forBrowser[a]);
if (!jsonToWrite) {
jsonToWrite = JSON.parse(r);
continue;
} else {
jsonToWrite = mergeResult(jsonToWrite, JSON.parse(r));
}
}
//写文件
fs.writeFileSync(jsonFileBasePath+finalJsonFile+'.json',JSON.stringify(jsonToWrite));
function isJsonFiles(fileName) {
var e = fileName.substring(fileName.lastIndexOf(".") + 1);
// json文件名必须是有8位的日期和6位的时间戳如:-20140326_161249
//否则无法判断文件生成时间,也就无法合并同一次运行产生的结果
return e == 'json' && getFileTime(fileName);
}
function getFileTime(fileName) {
// json文件名必须是有8位的日期和6位的时间戳如:-20140326_161249
return fileName.match(/-(\d{8})_(\d{6})/);
}
function mergeResult(allR, addR) {
var resultR = {};
for (var allRKey in allR) {
if (addR[allRKey]) {
allR[allRKey] = mergeDetail(allR[allRKey], addR[allRKey], 's', 1);
allR[allRKey] = mergeDetail(allR[allRKey], addR[allRKey], 'f', 1);
allR[allRKey] = mergeDetail(allR[allRKey], addR[allRKey], 'l', 1);
allR[allRKey] = mergeDetail(allR[allRKey], addR[allRKey], 'b', 2);
}
//修正路径
resultR[fixPath(allRKey)] = allR[allRKey]
}
return resultR;
}
//type = 1 合并 s f l ,如:{"1":1,"2":1,"3":1}
//type = 2 合并 b ,如:{"1":[0,0],"2":[0,0]}
function mergeDetail(allEle, addEle, attrName, type) {
if (allEle[attrName] && addEle[attrName]) {
if (type == 1) {
for (var k in allEle[attrName]) {
//todo 现在没有考虑两个文件中同一项覆盖率的统计行数不一致的问题
if ( parseInt(allEle[attrName][k])==0 && parseInt(addEle[attrName][k]) ==1) {
allEle[attrName][k] = 1;
}
}
}
else if (type == 2) {
for (var k in allEle[attrName]) {
//todo 现在没有考虑两个文件中同一项覆盖率的统计行数不一致的问题
if (addEle[attrName][k]) {
if (parseInt(allEle[attrName][k][0])==0 &&parseInt(addEle[attrName][k][0])==1 ) {
allEle[attrName][k][0] = 1;
}
if (parseInt(allEle[attrName][k][1])==0 &&parseInt(addEle[attrName][k][1])==1 ) {
allEle[attrName][k][1] = 1;
}
}
}
}
}
return allEle;
}
//修正路径
function fixPath(oldPath){
//例如把 "D:/workspace/ufinder/_src/core/finder.js" 修正为
// ./_src/core/finder.js 注意这里一定要用相对路径(相对于_spec/coverage)
var s = __dirname.replace(/\\/g,'/');
if(s.lastIndexOf(curPath)){
s = s.substring(0,s.lastIndexOf(curPath) );
}
oldPath = oldPath.replace(s,resultPath);
return oldPath;
}
console.log(finalJsonFile);
\ No newline at end of file
setlocal EnableDelayedExpansion
del /q /s .\coverage\json_files\*.json
for /f %%j in ('karma start ./karma.conf.js') do set karmaRe=%%j
for /f %%i in ('node ./mergeCoverageForIstanbul.js') do set re=%%i
istanbul report html coverage/json_files/%re%.json
pause
@echo off
setlocal EnableDelayedExpansion
del /q /s .\coverage\json_files\*.*
karma start ./karma.conf.js
\ No newline at end of file
......@@ -411,7 +411,7 @@ KityMinder.registerModule( "LayoutBottom", function () {
this.appendChildNode( _cleanbuffer[ j ].getLayout().parent, _cleanbuffer[ j ] );
}
},
appendChildNode: function ( parent, node, sibling ) {
appendChildNode: function ( parent, node, focus, sibling ) {
node.clearLayout();
var parentLayout = parent.getLayout();
var expand = parent.getData( "expand" );
......
......@@ -69,7 +69,9 @@ KityMinder.registerProtocal( 'xmind', function () {
function xml2km(xml){
var json = $.xml2json(xml);
var result = {};
processTopic(json.sheet.topic, result);
var sheet = json.sheet;
var topic = utils.isArray(sheet) ? sheet[0].topic : sheet.topic;
processTopic(topic, result);
return result;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment