GUI -- Completed Show Summary panel.
- added GlyphService.addGlyph().
- added SvgUtilService.translate().
Change-Id: I0bbc51a8f1d9c24b8b4f1377236570070da6f160
diff --git a/web/gui/src/main/webapp/tests/app/fw/svg/glyph-spec.js b/web/gui/src/main/webapp/tests/app/fw/svg/glyph-spec.js
index 587d617..b72de5a 100644
--- a/web/gui/src/main/webapp/tests/app/fw/svg/glyph-spec.js
+++ b/web/gui/src/main/webapp/tests/app/fw/svg/glyph-spec.js
@@ -18,7 +18,7 @@
ONOS GUI -- SVG -- Glyph Service - Unit Tests
*/
describe('factory: fw/svg/glyph.js', function() {
- var $log, fs, gs, d3Elem;
+ var $log, fs, gs, d3Elem, svg;
var numBaseGlyphs = 13,
vbBird = '352 224 113 112',
@@ -47,13 +47,16 @@
beforeEach(module('onosUtil', 'onosSvg'));
beforeEach(inject(function (_$log_, FnService, GlyphService) {
+ var body = d3.select('body');
$log = _$log_;
fs = FnService;
gs = GlyphService;
- d3Elem = d3.select('body').append('defs').attr('id', 'myDefs');
+ d3Elem = body.append('defs').attr('id', 'myDefs');
+ svg = body.append('svg').attr('id', 'mySvg');
}));
afterEach(function () {
+ d3.select('#mySvg').remove();
d3.select('#myDefs').remove();
gs.clear();
});
@@ -64,7 +67,7 @@
it('should define api functions', function () {
expect(fs.areFunctions(gs, [
- 'clear', 'init', 'register', 'ids', 'glyph', 'loadDefs'
+ 'clear', 'init', 'register', 'ids', 'glyph', 'loadDefs', 'addGlyph'
])).toBeTruthy();
});
@@ -246,4 +249,40 @@
verifyLoadedInDom('chain', vbGlyph);
verifyLoadedInDom('node', vbGlyph);
});
+
+ it('should add a glyph with default size', function () {
+ gs.init();
+ gs.addGlyph(svg, 'crown');
+ var what = svg.selectAll('use');
+ expect(what.size()).toEqual(1);
+ expect(what.attr('width')).toEqual('40');
+ expect(what.attr('height')).toEqual('40');
+ expect(what.attr('xlink:href')).toEqual('#crown');
+ expect(what.classed('glyph')).toBeTruthy();
+ expect(what.classed('overlay')).toBeFalsy();
+ });
+
+ it('should add a glyph with given size', function () {
+ gs.init();
+ gs.addGlyph(svg, 'crown', 37);
+ var what = svg.selectAll('use');
+ expect(what.size()).toEqual(1);
+ expect(what.attr('width')).toEqual('37');
+ expect(what.attr('height')).toEqual('37');
+ expect(what.attr('xlink:href')).toEqual('#crown');
+ expect(what.classed('glyph')).toBeTruthy();
+ expect(what.classed('overlay')).toBeFalsy();
+ });
+
+ it('should add a glyph marked as overlay', function () {
+ gs.init();
+ gs.addGlyph(svg, 'crown', 20, true);
+ var what = svg.selectAll('use');
+ expect(what.size()).toEqual(1);
+ expect(what.attr('width')).toEqual('20');
+ expect(what.attr('height')).toEqual('20');
+ expect(what.attr('xlink:href')).toEqual('#crown');
+ expect(what.classed('glyph')).toBeTruthy();
+ expect(what.classed('overlay')).toBeTruthy();
+ });
});