123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269 |
- window.onload = function() {
- test( "taskbar basic tests", function() {
- // create task bar div
- $('#taskbars').append('<hr><h1>taskbar basic tests</h1><div id="taskbar1"></div>')
- App.TaskManager.init({
- el: $('#taskbar1'),
- offlineModus: true,
- force: true,
- })
- // add tasks
- App.TaskManager.execute({
- key: 'TestKey1',
- controller: 'TestController1',
- params: {
- message: '#1',
- },
- show: true,
- persistent: false,
- })
- equal($('#taskbars .content').length, 1, "check available active contents")
- equal($('#taskbars .content.active').length, 1, "check available active contents")
- equal($('#taskbars .content.active').text(), "some test controller message:'#1',show:'true',hide:'false',active:'true'", "check active content!")
- // verify
- task = App.TaskManager.get('TestKey1')
- equal(task.notify, false)
- deepEqual(task.state, undefined)
- deepEqual(task.params, { "message": "#1", "shown": true })
- // update
- App.TaskManager.update('TestKey1', { 'state': 'abc' })
- App.TaskManager.update('TestKey1', { 'params': { a: 12 } })
- App.TaskManager.notify('TestKey1')
- // verify
- task = App.TaskManager.get('TestKey1')
- equal(task.notify, true)
- deepEqual(task.state, 'abc')
- deepEqual(task.params, { "a": 12 })
- App.TaskManager.execute({
- key: 'TestKey2',
- controller: 'TestController1',
- params: {
- message: '#2',
- },
- show: true,
- persistent: false,
- })
- equal($('#taskbars .content').length, 2, "check available active contents")
- equal($('#taskbars .content.active').length, 1, "check available active contents")
- equal($('#taskbars .content.active').text(), "some test controller message:'#2',show:'true',hide:'false',active:'true'", "check active content!")
- equal($('#taskbars #content_permanent_TestKey1').text(), "some test controller message:'#1',show:'true',hide:'true',active:'false'", "check active content!")
- equal($('#taskbars #content_permanent_TestKey2').text(), "some test controller message:'#2',show:'true',hide:'false',active:'true'", "check active content!")
- // check task history
- equal(App.TaskManager.nextTaskUrl(), '#/some/url/#2')
- equal(App.TaskManager.nextTaskUrl(), '#/some/url/#1')
- App.TaskManager.execute({
- key: 'TestKey3',
- controller: 'TestController1',
- params: {
- message: '#3',
- },
- show: false,
- persistent: false,
- })
- equal($('#taskbars .content').length, 2, "check available active contents")
- equal($('#taskbars .content.active').length, 1, "check available active contents")
- equal($('#taskbars .content.active').text(), "some test controller message:'#2',show:'true',hide:'false',active:'true'")
- equal($('#taskbars #content_permanent_TestKey1').text(), "some test controller message:'#1',show:'true',hide:'true',active:'false'", "check active content!")
- equal($('#taskbars #content_permanent_TestKey2').text(), "some test controller message:'#2',show:'true',hide:'false',active:'true'", "check active content!")
- App.TaskManager.execute({
- key: 'TestKey3',
- controller: 'TestController1',
- params: {
- message: '#3',
- },
- show: true,
- persistent: false,
- })
- equal($('#taskbars .content').length, 3, "check available active contents")
- equal($('#taskbars .content.active').length, 1, "check available active contents")
- equal($('#taskbars .content.active').text(), "some test controller message:'#3',show:'true',hide:'true',active:'true'", "check active content!")
- equal($('#taskbars #content_permanent_TestKey1').text(), "some test controller message:'#1',show:'true',hide:'true',active:'false'", "check active content!")
- equal($('#taskbars #content_permanent_TestKey2').text(), "some test controller message:'#2',show:'true',hide:'true',active:'false'", "check active content!")
- equal($('#taskbars #content_permanent_TestKey3').text(), "some test controller message:'#3',show:'true',hide:'true',active:'true'", "check active content!")
- App.TaskManager.execute({
- key: 'TestKey4',
- controller: 'TestController1',
- params: {
- message: '#4',
- },
- show: false,
- persistent: true,
- })
- equal($('#taskbars .content').length, 3, "check available active contents")
- equal($('#taskbars .content.active').length, 1, "check available active contents")
- equal($('#taskbars .content.active').text(), "some test controller message:'#3',show:'true',hide:'true',active:'true'", "check active content!")
- equal($('#taskbars #content_permanent_TestKey1').text(), "some test controller message:'#1',show:'true',hide:'true',active:'false'", "check active content!")
- equal($('#taskbars #content_permanent_TestKey2').text(), "some test controller message:'#2',show:'true',hide:'true',active:'false'", "check active content!")
- equal($('#taskbars #content_permanent_TestKey3').text(), "some test controller message:'#3',show:'true',hide:'true',active:'true'", "check active content!")
- App.TaskManager.execute({
- key: 'TestKey5',
- controller: 'TestController1',
- params: {
- message: '#5',
- },
- show: true,
- persistent: true,
- })
- equal($('#taskbars .content').length, 4, "check available active contents")
- equal($('#taskbars .content.active').length, 1, "check available active contents")
- equal($('#taskbars .content.active').text(), "some test controller message:'#5',show:'true',hide:'false',active:'true'")
- equal($('#taskbars #content_permanent_TestKey1').text(), "some test controller message:'#1',show:'true',hide:'true',active:'false'", "check active content!")
- equal($('#taskbars #content_permanent_TestKey2').text(), "some test controller message:'#2',show:'true',hide:'true',active:'false'", "check active content!")
- equal($('#taskbars #content_permanent_TestKey3').text(), "some test controller message:'#3',show:'true',hide:'true',active:'false'", "check active content!")
- equal($('#taskbars #content_permanent_TestKey5').text(), "some test controller message:'#5',show:'true',hide:'false',active:'true'", "check active content!")
- App.TaskManager.execute({
- key: 'TestKey6',
- controller: 'TestController1',
- params: {
- message: '#6',
- },
- show: true,
- persistent: false,
- })
- equal($('#taskbars .content').length, 5, "check available active contents")
- equal($('#taskbars .content.active').length, 1, "check available active contents")
- equal($('#taskbars .content.active').text(), "some test controller message:'#6',show:'true',hide:'false',active:'true'")
- equal($('#taskbars #content_permanent_TestKey1').text(), "some test controller message:'#1',show:'true',hide:'true',active:'false'", "check active content!")
- equal($('#taskbars #content_permanent_TestKey2').text(), "some test controller message:'#2',show:'true',hide:'true',active:'false'", "check active content!")
- equal($('#taskbars #content_permanent_TestKey3').text(), "some test controller message:'#3',show:'true',hide:'true',active:'false'", "check active content!")
- equal($('#taskbars #content_permanent_TestKey5').text(), "some test controller message:'#5',show:'true',hide:'true',active:'false'", "check active content!")
- equal($('#taskbars #content_permanent_TestKey6').text(), "some test controller message:'#6',show:'true',hide:'false',active:'true'", "check active content!")
- // remove task#2
- App.TaskManager.remove('TestKey2')
- equal($('#taskbars .content').length, 4, "check available active contents")
- equal($('#taskbars .content.active').length, 1, "check available active contents")
- equal($('#taskbars .content.active').text(), "some test controller message:'#6',show:'true',hide:'false',active:'true'")
- equal($('#taskbars #content_permanent_TestKey1').text(), "some test controller message:'#1',show:'true',hide:'true',active:'false'", "check active content!")
- equal($('#taskbars #content_permanent_TestKey3').text(), "some test controller message:'#3',show:'true',hide:'true',active:'false'", "check active content!")
- equal($('#taskbars #content_permanent_TestKey5').text(), "some test controller message:'#5',show:'true',hide:'true',active:'false'", "check active content!")
- equal($('#taskbars #content_permanent_TestKey6').text(), "some test controller message:'#6',show:'true',hide:'false',active:'true'", "check active content!")
- // activate task#3
- App.TaskManager.execute({
- key: 'TestKey3',
- controller: 'TestController1',
- params: {
- message: '#3',
- },
- show: true,
- persistent: false,
- })
- equal($('#taskbars .content').length, 4, "check available active contents")
- equal($('#taskbars .content.active').length, 1, "check available active contents")
- equal($('#taskbars .content.active').text(), "some test controller message:'#3',show:'true',hide:'true',active:'true'")
- equal($('#taskbars #content_permanent_TestKey1').text(), "some test controller message:'#1',show:'true',hide:'true',active:'false'", "check active content!")
- equal($('#taskbars #content_permanent_TestKey3').text(), "some test controller message:'#3',show:'true',hide:'true',active:'true'", "check active content!")
- equal($('#taskbars #content_permanent_TestKey5').text(), "some test controller message:'#5',show:'true',hide:'true',active:'false'", "check active content!")
- equal($('#taskbars #content_permanent_TestKey6').text(), "some test controller message:'#6',show:'true',hide:'true',active:'false'", "check active content!")
- // activate task#1
- App.TaskManager.execute({
- key: 'TestKey1',
- controller: 'TestController1',
- params: {
- message: '#1',
- },
- show: true,
- persistent: false,
- })
- equal($('#taskbars .content').length, 4, "check available active contents")
- equal($('#taskbars .content.active').length, 1, "check available active contents")
- equal($('#taskbars .content.active').text(), "some test controller message:'#1',show:'true',hide:'true',active:'true'")
- equal($('#taskbars #content_permanent_TestKey1').text(), "some test controller message:'#1',show:'true',hide:'true',active:'true'", "check active content!")
- equal($('#taskbars #content_permanent_TestKey3').text(), "some test controller message:'#3',show:'true',hide:'true',active:'false'", "check active content!")
- equal($('#taskbars #content_permanent_TestKey5').text(), "some test controller message:'#5',show:'true',hide:'true',active:'false'", "check active content!")
- equal($('#taskbars #content_permanent_TestKey6').text(), "some test controller message:'#6',show:'true',hide:'true',active:'false'", "check active content!")
- // remove task#1
- App.TaskManager.remove('TestKey1')
- // verify if task#3 is active
- equal($('#taskbars .content').length, 3, "check available active contents")
- equal($('#taskbars .content.active').length, 0, "check available active contents")
- equal($('#taskbars .content.active').text(), "")
- // remove task#3
- App.TaskManager.remove('TestKey3')
- // verify if task#5 is active
- equal($('#taskbars .content').length, 2, "check available active contents")
- equal($('#taskbars .content.active').length, 0, "check available active contents")
- equal($('#taskbars .content.active').text(), "")
- // remove task#5 // can not get removed because of permanent task
- App.TaskManager.remove('TestKey5')
- // verify if task#5 is active
- equal($('#taskbars .content').length, 2, "check available active contents")
- equal($('#taskbars .content.active').length, 0, "check available active contents")
- equal($('#taskbars .content.active').text(), "")
- // create task#7
- App.TaskManager.execute({
- key: 'TestKey7',
- controller: 'TestController1',
- params: {
- message: '#7',
- },
- show: true,
- persistent: false,
- })
- equal($('#taskbars .content').length, 3, "check available active contents")
- equal($('#taskbars .content.active').length, 1, "check available active contents")
- equal($('#taskbars .content.active').text(), "some test controller message:'#7',show:'true',hide:'false',active:'true'", "check active content!")
- // remove task#7
- App.TaskManager.remove('TestKey7')
- // verify if task#5 is active
- equal($('#taskbars .content').length, 2, "check available active contents")
- equal($('#taskbars .content.active').length, 0, "check available active contents")
- equal($('#taskbars .content.active').text(), "")
- // check task history
- equal(App.TaskManager.nextTaskUrl(), '#/some/url/#6')
- equal(App.TaskManager.nextTaskUrl(), '#/some/url/#5')
- equal(App.TaskManager.nextTaskUrl(), '#/some/url/#6')
- equal(App.TaskManager.nextTaskUrl(), '#/some/url/#6')
- // remove task#6
- App.TaskManager.remove('TestKey6')
- // check task history
- equal(App.TaskManager.nextTaskUrl(), false)
- equal(App.TaskManager.nextTaskUrl(), false)
- // destroy task bar
- App.TaskManager.reset()
- // check if any taskar exists
- equal($('#taskbars .content').length, 0, "check available active contents")
- })
- }
|