Committed by
Gerrit Code Review
GUI -- Flash messages appear for every toolbar button. Unit tests written for TableBuilderService
Change-Id: Ib43e48dcfdd165b27e848ff487f2e2cc58d83005
Showing
11 changed files
with
125 additions
and
41 deletions
... | @@ -21,7 +21,7 @@ | ... | @@ -21,7 +21,7 @@ |
21 | 'use strict'; | 21 | 'use strict'; |
22 | 22 | ||
23 | // injected refs | 23 | // injected refs |
24 | - var $log, $window, fs, wss; | 24 | + var $log, fs, wss; |
25 | 25 | ||
26 | // example params to buildTable: | 26 | // example params to buildTable: |
27 | // { | 27 | // { |
... | @@ -72,11 +72,10 @@ | ... | @@ -72,11 +72,10 @@ |
72 | 72 | ||
73 | angular.module('onosWidget') | 73 | angular.module('onosWidget') |
74 | .factory('TableBuilderService', | 74 | .factory('TableBuilderService', |
75 | - ['$log', '$window', 'FnService', 'WebSocketService', | 75 | + ['$log', 'FnService', 'WebSocketService', |
76 | 76 | ||
77 | - function (_$log_, _$window_, _fs_, _wss_) { | 77 | + function (_$log_, _fs_, _wss_) { |
78 | $log = _$log_; | 78 | $log = _$log_; |
79 | - $window = _$window_; | ||
80 | fs = _fs_; | 79 | fs = _fs_; |
81 | wss = _wss_; | 80 | wss = _wss_; |
82 | 81 | ... | ... |
... | @@ -34,7 +34,7 @@ | ... | @@ -34,7 +34,7 @@ |
34 | // constants | 34 | // constants |
35 | var topPdg = 13, | 35 | var topPdg = 13, |
36 | ctnrPdg = 24, | 36 | ctnrPdg = 24, |
37 | - scrollSize = 10, | 37 | + scrollSize = 17, |
38 | portsTblPdg = 50, | 38 | portsTblPdg = 50, |
39 | 39 | ||
40 | pName = 'device-details-panel', | 40 | pName = 'device-details-panel', | ... | ... |
... | @@ -134,6 +134,11 @@ | ... | @@ -134,6 +134,11 @@ |
134 | 134 | ||
135 | function incDevLabIndex() { | 135 | function incDevLabIndex() { |
136 | deviceLabelIndex = (deviceLabelIndex+1) % 3; | 136 | deviceLabelIndex = (deviceLabelIndex+1) % 3; |
137 | + switch(deviceLabelIndex) { | ||
138 | + case 0: return 'Hide device labels'; | ||
139 | + case 1: return 'Show friendly device labels'; | ||
140 | + case 2: return 'Show device ID labels'; | ||
141 | + } | ||
137 | } | 142 | } |
138 | 143 | ||
139 | // Returns the newly computed bounding box of the rectangle | 144 | // Returns the newly computed bounding box of the rectangle | ... | ... |
... | @@ -413,7 +413,7 @@ | ... | @@ -413,7 +413,7 @@ |
413 | } | 413 | } |
414 | 414 | ||
415 | function cycleDeviceLabels() { | 415 | function cycleDeviceLabels() { |
416 | - td3.incDevLabIndex(); | 416 | + flash.flash(td3.incDevLabIndex()); |
417 | tms.findDevices().forEach(function (d) { | 417 | tms.findDevices().forEach(function (d) { |
418 | td3.updateDeviceLabel(d); | 418 | td3.updateDeviceLabel(d); |
419 | }); | 419 | }); | ... | ... |
... | @@ -24,7 +24,7 @@ | ... | @@ -24,7 +24,7 @@ |
24 | 'use strict'; | 24 | 'use strict'; |
25 | 25 | ||
26 | // injected refs | 26 | // injected refs |
27 | - var $log, fs, sus; | 27 | + var $log, fs, sus, flash; |
28 | 28 | ||
29 | // api to topoForce | 29 | // api to topoForce |
30 | var api; | 30 | var api; |
... | @@ -217,12 +217,13 @@ | ... | @@ -217,12 +217,13 @@ |
217 | 217 | ||
218 | angular.module('ovTopo') | 218 | angular.module('ovTopo') |
219 | .factory('TopoObliqueService', | 219 | .factory('TopoObliqueService', |
220 | - ['$log', 'FnService', 'SvgUtilService', | 220 | + ['$log', 'FnService', 'SvgUtilService', 'FlashService', |
221 | 221 | ||
222 | - function (_$log_, _fs_, _sus_) { | 222 | + function (_$log_, _fs_, _sus_, _flash_) { |
223 | $log = _$log_; | 223 | $log = _$log_; |
224 | fs = _fs_; | 224 | fs = _fs_; |
225 | sus = _sus_; | 225 | sus = _sus_; |
226 | + flash = _flash_; | ||
226 | 227 | ||
227 | function initOblique(_api_) { | 228 | function initOblique(_api_) { |
228 | api = _api_; | 229 | api = _api_; |
... | @@ -234,8 +235,10 @@ angular.module('ovTopo') | ... | @@ -234,8 +235,10 @@ angular.module('ovTopo') |
234 | oblique = !oblique; | 235 | oblique = !oblique; |
235 | if (oblique) { | 236 | if (oblique) { |
236 | api.force().stop(); | 237 | api.force().stop(); |
238 | + flash.flash('Oblique view'); | ||
237 | toObliqueView(); | 239 | toObliqueView(); |
238 | } else { | 240 | } else { |
241 | + flash.flash('Normal view'); | ||
239 | toNormalView(); | 242 | toNormalView(); |
240 | } | 243 | } |
241 | } | 244 | } | ... | ... |
... | @@ -132,14 +132,14 @@ | ... | @@ -132,14 +132,14 @@ |
132 | function showNextIntentAction() { | 132 | function showNextIntentAction() { |
133 | hoverMode = hoverModeNone; | 133 | hoverMode = hoverModeNone; |
134 | wss.sendEvent('requestNextRelatedIntent'); | 134 | wss.sendEvent('requestNextRelatedIntent'); |
135 | - flash.flash('>'); | 135 | + flash.flash('Next related intent'); |
136 | } | 136 | } |
137 | 137 | ||
138 | // keystroke-left-arrow (see topo.js) | 138 | // keystroke-left-arrow (see topo.js) |
139 | function showPrevIntentAction() { | 139 | function showPrevIntentAction() { |
140 | hoverMode = hoverModeNone; | 140 | hoverMode = hoverModeNone; |
141 | wss.sendEvent('requestPrevRelatedIntent'); | 141 | wss.sendEvent('requestPrevRelatedIntent'); |
142 | - flash.flash('<'); | 142 | + flash.flash('Previous related intent'); |
143 | } | 143 | } |
144 | 144 | ||
145 | // keystroke-W (see topo.js) | 145 | // keystroke-W (see topo.js) | ... | ... |
1 | +/* | ||
2 | + * Copyright 2015 Open Networking Laboratory | ||
3 | + * | ||
4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | + * you may not use this file except in compliance with the License. | ||
6 | + * You may obtain a copy of the License at | ||
7 | + * | ||
8 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | + * | ||
10 | + * Unless required by applicable law or agreed to in writing, software | ||
11 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | + * See the License for the specific language governing permissions and | ||
14 | + * limitations under the License. | ||
15 | + */ | ||
16 | + | ||
17 | +/* | ||
18 | + ONOS GUI -- Widget -- Table Builder Service - Unit Tests | ||
19 | + */ | ||
20 | + | ||
21 | +describe('factory: fw/widget/tableBuilder.js', function () { | ||
22 | + var $log, $rootScope, fs, tbs; | ||
23 | + | ||
24 | + var mockObj, | ||
25 | + mockWss = { | ||
26 | + bindHandlers: function () {}, | ||
27 | + sendEvent: function () {}, | ||
28 | + unbindHandlers: function () {} | ||
29 | + }; | ||
30 | + | ||
31 | + beforeEach(module('onosWidget', 'onosUtil', 'onosRemote')); | ||
32 | + | ||
33 | + // TODO: actual websocket calls should be tested in the websocket service | ||
34 | + beforeEach(function () { | ||
35 | + module(function ($provide) { | ||
36 | + $provide.value('WebSocketService', mockWss); | ||
37 | + }); | ||
38 | + }); | ||
39 | + | ||
40 | + beforeEach(inject(function (_$log_, _$rootScope_, | ||
41 | + FnService, TableBuilderService) { | ||
42 | + $log = _$log_; | ||
43 | + $rootScope = _$rootScope_; | ||
44 | + fs = FnService; | ||
45 | + tbs = TableBuilderService; | ||
46 | + })); | ||
47 | + | ||
48 | + function mockSelCb(event, sel) {} | ||
49 | + | ||
50 | + beforeEach(function () { | ||
51 | + mockObj = { | ||
52 | + self: {}, | ||
53 | + scope: $rootScope.$new(), | ||
54 | + tag: 'foo', | ||
55 | + selCb: mockSelCb | ||
56 | + }; | ||
57 | + }); | ||
58 | + | ||
59 | + afterEach(function () { | ||
60 | + mockObj = {}; | ||
61 | + }); | ||
62 | + | ||
63 | + it('should define TableBuilderService', function () { | ||
64 | + expect(tbs).toBeDefined(); | ||
65 | + }); | ||
66 | + | ||
67 | + it('should define api functions', function () { | ||
68 | + expect(fs.areFunctions(tbs, [ | ||
69 | + 'buildTable' | ||
70 | + ])).toBeTruthy(); | ||
71 | + }); | ||
72 | + | ||
73 | + it('should verify sortCb', function () { | ||
74 | + spyOn(mockWss, 'sendEvent'); | ||
75 | + expect(mockObj.scope.sortCallback).not.toBeDefined(); | ||
76 | + tbs.buildTable(mockObj); | ||
77 | + expect(mockObj.scope.sortCallback).toBeDefined(); | ||
78 | + expect(mockWss.sendEvent).toHaveBeenCalled(); | ||
79 | + }); | ||
80 | + | ||
81 | + it('should set tableData', function () { | ||
82 | + expect(mockObj.self.tableData).not.toBeDefined(); | ||
83 | + tbs.buildTable(mockObj); | ||
84 | + expect(fs.isA(mockObj.self.tableData)).toBeTruthy(); | ||
85 | + expect(mockObj.self.tableData.length).toBe(0); | ||
86 | + }); | ||
87 | + | ||
88 | + it('should unbind handlers on destroyed scope', function () { | ||
89 | + spyOn(mockWss, 'unbindHandlers'); | ||
90 | + tbs.buildTable(mockObj); | ||
91 | + expect(mockWss.unbindHandlers).not.toHaveBeenCalled(); | ||
92 | + mockObj.scope.$destroy(); | ||
93 | + expect(mockWss.unbindHandlers).toHaveBeenCalled(); | ||
94 | + }); | ||
95 | + | ||
96 | + // TODO: figure out how to test respCb. | ||
97 | + // should it just be verified by the fact that the callback function | ||
98 | + // is called by the wss? | ||
99 | + | ||
100 | +}); |
... | @@ -54,6 +54,7 @@ describe('factory: fw/widget/tooltip.js', function () { | ... | @@ -54,6 +54,7 @@ describe('factory: fw/widget/tooltip.js', function () { |
54 | expect(tts.cancelTooltip()).toBeFalsy(); | 54 | expect(tts.cancelTooltip()).toBeFalsy(); |
55 | }); | 55 | }); |
56 | 56 | ||
57 | + // TODO: figure out how to test this | ||
57 | // testing mouse events is tough | 58 | // testing mouse events is tough |
58 | // showTooltip needs a d3 event, which currently has no test backend | 59 | // showTooltip needs a d3 event, which currently has no test backend |
59 | // .each is a workaround, which provides this, d, and i | 60 | // .each is a workaround, which provides this, d, and i | ... | ... |
... | @@ -20,23 +20,6 @@ | ... | @@ -20,23 +20,6 @@ |
20 | describe('Controller: OvDeviceCtrl', function () { | 20 | describe('Controller: OvDeviceCtrl', function () { |
21 | var $log, $scope, $controller, ctrl, $mockHttp; | 21 | var $log, $scope, $controller, ctrl, $mockHttp; |
22 | 22 | ||
23 | - var fakeData = { | ||
24 | - "devices": [{ | ||
25 | - "id": "of:0000000000000001", | ||
26 | - "available": true, | ||
27 | - "mfr": "Nicira, Inc.", | ||
28 | - "hw": "Open vSwitch", | ||
29 | - "sw": "2.0.1" | ||
30 | - }, | ||
31 | - { | ||
32 | - "id": "of:0000000000000004", | ||
33 | - "available": true, | ||
34 | - "mfr": "Nicira, Inc.", | ||
35 | - "hw": "Open vSwitch", | ||
36 | - "sw": "2.0.1" | ||
37 | - }] | ||
38 | - }; | ||
39 | - | ||
40 | // instantiate the Device module | 23 | // instantiate the Device module |
41 | beforeEach(module('ovDevice', 'onosRemote', 'onosLayer', 'onosSvg', | 24 | beforeEach(module('ovDevice', 'onosRemote', 'onosLayer', 'onosSvg', |
42 | 'onosNav', 'ngRoute')); | 25 | 'onosNav', 'ngRoute')); |
... | @@ -50,16 +33,6 @@ describe('Controller: OvDeviceCtrl', function () { | ... | @@ -50,16 +33,6 @@ describe('Controller: OvDeviceCtrl', function () { |
50 | 33 | ||
51 | beforeEach(function() { | 34 | beforeEach(function() { |
52 | ctrl = $controller('OvDeviceCtrl', { $scope: $scope }); | 35 | ctrl = $controller('OvDeviceCtrl', { $scope: $scope }); |
53 | - $mockHttp.whenGET(/\/device$/).respond(fakeData); | ||
54 | - }); | ||
55 | - | ||
56 | - | ||
57 | - // TODO: rewrite test to account for websocket | ||
58 | - xit('should be an empty array and then have device data', function () { | ||
59 | - expect(ctrl.deviceData).toEqual([]); | ||
60 | - $scope.sortCallback(); | ||
61 | - $mockHttp.flush(); | ||
62 | - expect(ctrl.deviceData).toEqual(fakeData.devices); | ||
63 | }); | 36 | }); |
64 | 37 | ||
65 | }); | 38 | }); | ... | ... |
... | @@ -18,14 +18,16 @@ | ... | @@ -18,14 +18,16 @@ |
18 | ONOS GUI -- Topo View -- Topo Oblique View Service - Unit Tests | 18 | ONOS GUI -- Topo View -- Topo Oblique View Service - Unit Tests |
19 | */ | 19 | */ |
20 | describe('factory: view/topo/topoOblique.js', function() { | 20 | describe('factory: view/topo/topoOblique.js', function() { |
21 | - var $log, fs, tos; | 21 | + var $log, fs, tos, flash; |
22 | 22 | ||
23 | - beforeEach(module('ovTopo', 'onosUtil')); | 23 | + beforeEach(module('ovTopo', 'onosUtil', 'onosLayer')); |
24 | 24 | ||
25 | - beforeEach(inject(function (_$log_, FnService, TopoObliqueService) { | 25 | + beforeEach(inject(function (_$log_, FnService, |
26 | + TopoObliqueService, FlashService) { | ||
26 | $log = _$log_; | 27 | $log = _$log_; |
27 | fs = FnService; | 28 | fs = FnService; |
28 | tos = TopoObliqueService; | 29 | tos = TopoObliqueService; |
30 | + flash = FlashService; | ||
29 | })); | 31 | })); |
30 | 32 | ||
31 | it('should define TopoTrafficService', function () { | 33 | it('should define TopoTrafficService', function () { | ... | ... |
-
Please register or login to post a comment