diff options
Diffstat (limited to 'framework/src/onos/web/gui/src/main/webapp/tests/app/fw/layer')
4 files changed, 0 insertions, 520 deletions
diff --git a/framework/src/onos/web/gui/src/main/webapp/tests/app/fw/layer/flash-spec.js b/framework/src/onos/web/gui/src/main/webapp/tests/app/fw/layer/flash-spec.js deleted file mode 100644 index a17f9e78..00000000 --- a/framework/src/onos/web/gui/src/main/webapp/tests/app/fw/layer/flash-spec.js +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright 2015 Open Networking Laboratory - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* - ONOS GUI -- Layer -- Flash Service - Unit Tests - */ -describe('factory: fw/layer/flash.js', function () { - var $log, $timeout, fs, flash, d3Elem; - - beforeEach(module('onosLayer')); - - beforeEach(inject(function (_$log_, _$timeout_, FnService, FlashService) { - $log = _$log_; - $timeout = _$timeout_; - fs = FnService; - flash = FlashService; - jasmine.clock().install(); - d3Elem = d3.select('body').append('div').attr('id', 'myflashdiv'); - flash.initFlash(); - })); - - afterEach(function () { - jasmine.clock().uninstall(); - d3.select('#myflashdiv').remove(); - }); - - function flashItemSelection() { - return d3Elem.selectAll('.flashItem'); - } - - it('should define FlashService', function () { - expect(flash).toBeDefined(); - }); - - it('should define api functions', function () { - expect(fs.areFunctions(flash, [ - 'initFlash', 'flash', 'enable' - ])).toBe(true); - }); - - it('should have no items to start', function () { - expect(flashItemSelection().size()).toBe(0); - }); - - it('should flash the message Foo', function () { - var item, rect, text; - flash.flash('foo'); - jasmine.clock().tick(101); - setTimeout(function () { - item = flashItemSelection(); - expect(item.size()).toEqual(1); - expect(item.classed('flashItem')).toBeTruthy(); - expect(item.select('rect').size()).toEqual(1); - text = item.select('text'); - expect(text.size()).toEqual(1); - expect(text.text()).toEqual('foo'); - }, 100); - }); -}); diff --git a/framework/src/onos/web/gui/src/main/webapp/tests/app/fw/layer/panel-spec.js b/framework/src/onos/web/gui/src/main/webapp/tests/app/fw/layer/panel-spec.js deleted file mode 100644 index 24ed9900..00000000 --- a/framework/src/onos/web/gui/src/main/webapp/tests/app/fw/layer/panel-spec.js +++ /dev/null @@ -1,189 +0,0 @@ -/* - * Copyright 2015 Open Networking Laboratory - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* - ONOS GUI -- Layer -- Panel Service - Unit Tests - */ -describe('factory: fw/layer/panel.js', function () { - var $log, $timeout, fs, ps, d3Elem; - - beforeEach(module('onosLayer')); - - beforeEach(inject(function (_$log_, _$timeout_, FnService, PanelService) { - $log = _$log_; - $timeout = _$timeout_; - fs = FnService; - ps = PanelService; - d3Elem = d3.select('body').append('div').attr('id', 'floatpanels'); - ps.init(); - })); - - afterEach(function () { - d3.select('#floatpanels').remove(); - ps.init(); - }); - - function floatPanelSelection() { - return d3Elem.selectAll('.floatpanel'); - } - - it('should define PanelService', function () { - expect(ps).toBeDefined(); - }); - - it('should define api functions', function () { - expect(fs.areFunctions(ps, [ - 'init', 'createPanel', 'destroyPanel' - ])).toBeTruthy(); - }); - - it('should have no panels to start', function () { - expect(floatPanelSelection().size()).toBe(0); - }); - - it('should log a warning if no ID is given', function () { - spyOn($log, 'warn'); - var p = ps.createPanel(); - expect(p).toBeNull(); - expect($log.warn).toHaveBeenCalledWith('createPanel: no ID given'); - expect(floatPanelSelection().size()).toBe(0); - }); - - it('should create a default panel', function () { - spyOn($log, 'warn'); - spyOn($log, 'debug'); - var p = ps.createPanel('foo'); - expect(p).not.toBeNull(); - expect($log.warn).not.toHaveBeenCalled(); - expect(floatPanelSelection().size()).toBe(1); - expect($log.debug).toHaveBeenCalledWith('creating panel:', 'foo', { - edge: 'right', - width: 200, - margin: 20, - hideMargin: 20, - xtnTime: 750, - fade: true - }); - - // check basic properties - expect(p.width()).toEqual(200); - expect(p.isVisible()).toBeFalsy(); - - var el = floatPanelSelection(); - expect(el.style('width')).toEqual('200px'); - }); - - it('should provide an api of panel functions', function () { - var p = ps.createPanel('foo'); - expect(fs.areFunctions(p, [ - 'show', 'hide', 'toggle', 'empty', 'append', - 'width', 'height', 'isVisible', 'classed', 'el' - ])).toBeTruthy(); - }); - - it('should complain when a duplicate ID is used', function () { - spyOn($log, 'warn'); - var p = ps.createPanel('foo'); - expect(p).not.toBeNull(); - expect($log.warn).not.toHaveBeenCalled(); - expect(floatPanelSelection().size()).toBe(1); - - var dup = ps.createPanel('foo'); - expect(dup).toBeNull(); - expect($log.warn).toHaveBeenCalledWith('Panel with ID "foo" already exists'); - expect(floatPanelSelection().size()).toBe(1); - }); - - it('should note when there is no panel to destroy', function () { - spyOn($log, 'debug'); - ps.destroyPanel('bar'); - expect($log.debug).toHaveBeenCalledWith('no panel to destroy:', 'bar'); - }); - - it('should destroy the panel', function () { - spyOn($log, 'debug'); - var p = ps.createPanel('foo'); - expect(floatPanelSelection().size()).toBe(1); - - ps.destroyPanel('foo'); - expect($log.debug).toHaveBeenCalledWith('destroying panel:', 'foo'); - expect(floatPanelSelection().size()).toBe(0); - }); - - it('should allow alternate settings to be given', function () { - spyOn($log, 'debug'); - var p = ps.createPanel('foo', { width: 250, edge: 'left' }); - expect($log.debug).toHaveBeenCalledWith('creating panel:', 'foo', { - edge: 'left', - width: 250, - margin: 20, - hideMargin: 20, - xtnTime: 750, - fade: true - }); - }); - - it('should show and hide the panel', function () { - var p = ps.createPanel('foo', {xtnTime:0}); - expect(p.isVisible()).toBeFalsy(); - - p.show(); - expect(p.isVisible()).toBeTruthy(); - - p.hide(); - expect(p.isVisible()).toBeFalsy(); - }); - - it('should append content to the panel', function () { - var p = ps.createPanel('foo'); - var span = p.append('span').attr('id', 'thisIsMySpan'); - - expect(floatPanelSelection().selectAll('span').attr('id')) - .toEqual('thisIsMySpan'); - }); - - it('should remove content on empty', function () { - var p = ps.createPanel('voop'); - p.append('span'); - p.append('span'); - p.append('span'); - expect(floatPanelSelection().selectAll('span').size()).toEqual(3); - - p.empty(); - expect(floatPanelSelection().selectAll('span').size()).toEqual(0); - expect(floatPanelSelection().html()).toEqual(''); - }); - - it('should allow programmatic setting of width', function () { - var p = ps.createPanel('whatcha', {width:234}); - expect(floatPanelSelection().style('width')).toEqual('234px'); - expect(p.width()).toEqual(234); - - p.width(345); - expect(floatPanelSelection().style('width')).toEqual('345px'); - expect(p.width()).toEqual(345); - }); - - it('should allow programmatic setting of height', function () { - var p = ps.createPanel('ciao', {height:50}); - expect(floatPanelSelection().style('height')).toEqual('50px'); - expect(p.height()).toEqual(50); - - p.height(100); - expect(floatPanelSelection().style('height')).toEqual('100px'); - expect(p.height()).toEqual(100); - }); -}); diff --git a/framework/src/onos/web/gui/src/main/webapp/tests/app/fw/layer/quickhelp-spec.js b/framework/src/onos/web/gui/src/main/webapp/tests/app/fw/layer/quickhelp-spec.js deleted file mode 100644 index 0f473b42..00000000 --- a/framework/src/onos/web/gui/src/main/webapp/tests/app/fw/layer/quickhelp-spec.js +++ /dev/null @@ -1,214 +0,0 @@ -/* - * Copyright 2015 Open Networking Laboratory - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* - ONOS GUI -- Layer -- Flash Service - Unit Tests - */ -describe('factory: fw/layer/quickhelp.js', function () { - var $log, fs, qhs, d3Elem, - fade = 500, - noop = function () {}, - mockBindings = { - globalKeys: { - slash: [noop, 'Show / hide Quick Help'], - T: [noop, 'Toggle Theme'] - }, - globalFormat: ['slash', 'T'], - viewKeys: { - H: [noop, 'Show / hide hosts'], - I: [noop, 'Toggle instances panel'] - }, - viewGestures: [] - }; - - // list of needed bindings to use in aggregateData - var neededBindings = [ - 'globalKeys', 'globalFormat', 'viewKeys', 'viewGestures' - ]; - - beforeEach(module('onosUtil', 'onosSvg', 'onosLayer')); - - beforeEach(inject(function (_$log_, FnService, QuickHelpService) { - $log = _$log_; - fs = FnService; - qhs = QuickHelpService; - - jasmine.clock().install(); - d3Elem = d3.select('body').append('div').attr('id', 'quickhelp'); - qhs.initQuickHelp(); - })); - - afterEach(function () { - jasmine.clock().uninstall(); - d3.select('#quickhelp').remove(); - }); - - function helpItemSelection() { - return d3Elem.selectAll('.help'); - } - - it('should define QuickHelpService', function () { - expect(qhs).toBeDefined(); - }); - - it('should define api functions', function () { - expect(fs.areFunctions(qhs, [ - 'initQuickHelp', 'showQuickHelp', 'hideQuickHelp' - ])).toBeTruthy(); - }); - - it('should have no items to start', function () { - expect(helpItemSelection().size()).toBe(0); - }); - - // === showQuickHelp - - it('should warn if bad bindings are provided', function () { - var warning = - 'Quickhelp Service: showQuickHelp(), invalid bindings object'; - spyOn($log, 'warn'); - - expect(qhs.showQuickHelp()).toBeNull(); - expect($log.warn).toHaveBeenCalledWith(warning); - - expect(qhs.showQuickHelp({})).toBeNull(); - expect($log.warn).toHaveBeenCalledWith(warning); - - expect(qhs.showQuickHelp([1, 2, 3])).toBeNull(); - expect($log.warn).toHaveBeenCalledWith(warning); - }); - - it('should warn if not all needed bindings are provided', function () { - var warning = - 'Quickhelp Service: showQuickHelp(),' + - ' needed bindings for help panel not provided:'; - spyOn($log, 'warn'); - - expect(qhs.showQuickHelp({ - foo: 'foo', bar: 'bar' - })).toBeNull(); - expect($log.warn).toHaveBeenCalledWith(warning, neededBindings); - - expect(qhs.showQuickHelp({ - globalKeys: {} - })).toBeNull(); - expect($log.warn).toHaveBeenCalledWith(warning, neededBindings); - - expect(qhs.showQuickHelp({ - globalKeys: {}, - globalFormat: {}, - viewKeys: {} - })).toBeNull(); - expect($log.warn).toHaveBeenCalledWith(warning, neededBindings); - }); - - it('should not warn if bindings are provided', function () { - spyOn($log, 'warn'); - expect(qhs.showQuickHelp(mockBindings)).toBe(undefined); - expect($log.warn).not.toHaveBeenCalled(); - }); - - it('should append an svg', function () { - var svg = d3Elem.select('svg'); - expect(d3Elem.empty()).toBe(false); - expect(svg.empty()).toBe(true); - - qhs.showQuickHelp(mockBindings); - - svg = d3Elem.select('svg'); - expect(svg.empty()).toBe(false); - expect(svg.attr('width')).toBe('100%'); - expect(svg.attr('height')).toBe('80%'); - expect(svg.attr('viewBox')).toBe('-200 0 400 400'); - }); - - it('should create the quick help panel', function () { - var helpItems, g, rect, text, rows; - qhs.showQuickHelp(mockBindings); - - helpItems = helpItemSelection(); - expect(helpItems.size()).toBe(1); - - g = d3.select('g.help'); - expect(g.attr('opacity')).toBe('0'); - - rect = g.select('rect'); - expect(rect.attr('rx')).toBe('8'); - - text = g.select('text'); - expect(text.text()).toBe('Quick Help'); - expect(text.classed('title')).toBe(true); - expect(text.attr('dy')).toBe('1.2em'); - expect(text.attr('transform')).toBeTruthy(); - - rows = g.select('g'); - expect(rows.empty()).toBe(false); - - jasmine.clock().tick(fade + 1); - setTimeout(function () { - expect(g.attr('opacity')).toBe('1'); - }, fade); - - // TODO: test aggregate data helper function - }); - - it('should show panel with custom fade time', function () { - var g, - ctmFade = 200; - qhs.initQuickHelp({ fade: ctmFade }); - qhs.showQuickHelp(mockBindings); - - g = d3.select('g.help'); - expect(g.attr('opacity')).toBe('0'); - - jasmine.clock().tick(ctmFade + 1); - setTimeout(function () { - expect(g.attr('opacity')).toBe('1'); - }, ctmFade); - }); - - // === hideQuickHelp - - it('should hide quick help if svg exists', function () { - var svg; - - expect(qhs.hideQuickHelp()).toBe(false); - - svg = d3.select('#quickhelp') - .append('svg'); - svg.append('g') - .classed('help', true) - .attr('opacity', 1); - - expect(qhs.hideQuickHelp()).toBe(true); - - jasmine.clock().tick(fade + 1); - setTimeout(function () { - expect(svg.select('g.help').attr('opacity')).toBe('0'); - }, fade); - - jasmine.clock().tick(20); - setTimeout(function () { - expect(svg.empty()).toBe(true); - }, fade + 20); - }); - - it('should not hide quick help if svg does not exist', function () { - expect(qhs.hideQuickHelp()).toBe(false); - }); - -}); - diff --git a/framework/src/onos/web/gui/src/main/webapp/tests/app/fw/layer/veil-spec.js b/framework/src/onos/web/gui/src/main/webapp/tests/app/fw/layer/veil-spec.js deleted file mode 100644 index 155ebaab..00000000 --- a/framework/src/onos/web/gui/src/main/webapp/tests/app/fw/layer/veil-spec.js +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright 2015 Open Networking Laboratory - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* - ONOS GUI -- Layer -- Veil Service - Unit Tests - */ - -describe('factory: fw/layer/veil.js', function () { - var $log, $route, vs, fs, ks, gs; - - beforeEach(module('onosLayer', 'onosNav', 'onosSvg', 'ngRoute')); - - beforeEach(inject(function (_$log_, _$route_, VeilService, FnService, - KeyService, GlyphService) { - $log = _$log_; - $route = _$route_; - vs = VeilService; - fs = FnService; - ks = KeyService; - gs = GlyphService; - })); - - it('should define VeilService', function () { - expect(vs).toBeDefined(); - }); - - it('should define api functions', function () { - expect(fs.areFunctions(vs, [ - 'init', 'show', 'hide', 'lostServer' - ])).toBeTruthy(); - }); -}); |