Skip to content

Commit

Permalink
spectron sample 적용
Browse files Browse the repository at this point in the history
  • Loading branch information
kimorkim committed Jun 13, 2016
1 parent 89a6cdc commit bbee3d3
Show file tree
Hide file tree
Showing 4 changed files with 142 additions and 1 deletion.
36 changes: 36 additions & 0 deletions app/src/workspace.js
Original file line number Diff line number Diff line change
Expand Up @@ -495,6 +495,42 @@ angular.module('workspace').controller("WorkspaceController",
});
}

$scope.loadWorkspaceTest = function (filePath) {
// $scope.showSpinner();
$scope.doPopupControl({
'type':'spinner',
'msg': Lang.Workspace.loading_msg
});
var canLoad = false;
if(!Entry.stateManager.isSaved()) {
canLoad = !confirm(Lang.Menus.save_dismiss);
}

if(!canLoad) {
Entry.stateManager.addStamp();
storage.removeItem('tempProject');
Entry.plugin.beforeStatus = 'load';
var default_path = storage.getItem('defaultPath') || '';

var pathInfo = path.parse(filePath);

if(pathInfo.ext === '.ent') {
var parser = path.parse(filePath);
storage.setItem('defaultPath', parser.dir);
$scope.loadProject(filePath);
} else {
alert(Lang.Workspace.check_entry_file_msg);
$scope.doPopupControl({
'type':'hide'
});
}
} else {
$scope.doPopupControl({
'type':'hide'
});
}
}

// 불러오기
$scope.loadWorkspace = function() {
// $scope.showSpinner();
Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
"dist:win64": "build --arch x64",
"pack:win": "electron-packager ./dist --platform=win32 --arch=ia32",
"dist:osx": "build",
"start": "set NODE_ENV=development&&electron -d app"
"start": "set NODE_ENV=development&&electron -d app",
"test": "mocha test/default.js"
},
"build": {
"osx": {
Expand Down Expand Up @@ -47,6 +48,7 @@
"electron-builder": "^3.25.0",
"electron-packager": "^7.0.2",
"electron-prebuilt": "1.1.1",
"mocha": "^2.5.3",
"rimraf": "^2.5.2",
"spectron": "^3.2.3"
},
Expand Down
103 changes: 103 additions & 0 deletions test/default.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
var Application = require('spectron').Application;
var assert = require('assert');
var path = require('path');
var electronPath = path.join(__dirname, '..', 'node_modules', '.bin', 'electron')
if (process.platform === 'win32') electronPath += '.cmd'
var appPath = path.join('app');

describe('application launch', function () {
this.timeout(10000);
before(function () {
this.app = new Application({
path: electronPath,
args: [appPath]
})
return this.app.start();
})

after(function () {
if (this.app && this.app.isRunning()) {
return this.app.stop()
}
})

describe('기본 실행 확인', function () {
it('창이 1개 뜨는지 확인', function () {
return this.app.client.getWindowCount().then(function (count) {
assert.equal(count, 1)
});
});

it('창이 보이는지 확인합니다.', function () {
return this.app.browserWindow.isVisible().then(function (isVisible) {
assert.equal(isVisible, true);
});
});

it('윈도우 제목 확인', function () {
return this.app.browserWindow.getTitle().then(function (title) {
if(title.indexOf('엔트리') >= 0) {
assert.ok(title);
} else {
assert.fail(title, '엔트리', '잘못된 제목 삽입');
}
});
});
});



/*
describe('파일 로드 확인', function () {
it('1번 파일', function (done) {
var self = this;
console.log('a');
return this.app.client.execute(function () {
// console.log(angular);
var file_path = path.join(__dirname, '..', 'test', 'test_file', 'test_case1.ent');
console.log(file_path);
try{
var a = angular.element('.entryRunButtonWorkspace_w').scope();
console.log(a);
console.log(angular);
return angular.element('.entryRunButtonWorkspace_w').scope().loadWorkspaceTest(file_path);
} catch(e) {
throw new Error(e);
return false;
}
}).then(function (equal) {
'자동문 의 사본'
var a = self.app.client.waitForText('#project_name').then(function (a, b, c) {
console.log(a);
console.log(b);
console.log(c);
console.log(equal);
done();
});
});
});
});
*/
})


// var self = this;
// this.app.start().then(function () {
// // 윈도우가 보이는지 확인합니다.
// return self.app.browserWindow.isVisible()
// }).then(function (isVisible) {
// // 윈도우가 보이는지 검증합니다.
// assert.equal(isVisible, true)
// }).then(function () {
// // 윈도우의 제목을 가져옵니다.
// return self.app.client.getTitle()
// }).then(function (title) {
// // 윈도우의 제목을 검증합니다.
// assert.equal(title, 'My App')
// }).then(function () {
// // 어플리케이션을 중지합니다.
// return self.app.stop()
// }).catch(function (error) {
// // 테스트의 실패가 있다면 로깅합니다.
// console.error('Test failed', error.message)
// })
Binary file added test/test_file/test_case1.ent
Binary file not shown.

0 comments on commit bbee3d3

Please sign in to comment.