GUI -- Started writing the ToolbarService with its unit tests -- WIP

Change-Id: I3adb60cdf9b516e3a325a85f1b0487710ef22178
diff --git a/web/gui/src/main/webapp/app/fw/README.txt b/web/gui/src/main/webapp/app/fw/README.txt
index e99ece9..e173c52 100644
--- a/web/gui/src/main/webapp/app/fw/README.txt
+++ b/web/gui/src/main/webapp/app/fw/README.txt
@@ -26,4 +26,5 @@
     - Web Socket Service
 
 - Widget
-    - Table Service
+    - Table Styling Directives
+    - Toolbar Service
diff --git a/web/gui/src/main/webapp/app/fw/widget/toolbar.js b/web/gui/src/main/webapp/app/fw/widget/toolbar.js
new file mode 100644
index 0000000..ee60985
--- /dev/null
+++ b/web/gui/src/main/webapp/app/fw/widget/toolbar.js
@@ -0,0 +1,83 @@
+/*
+ * 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 -- Widget -- Toolbar Service
+ */
+(function () {
+    'use strict';
+
+    var $log;
+
+    // rids will hold all the ids used with makeRadio so that you can create
+    // more radio buttons not in order
+    // TODO: implement this --^
+    var rids = {},
+        ridCtr = 0;
+
+    // toggle state is used in createToolbar (not needed in makeToggle) (??)
+    var toggle = false;
+
+    function makeButton(id, gid, cb) {
+        return {
+            t: 'btn',
+            id: id,
+            gid: gid,
+            cb: cb
+        };
+    }
+
+    function makeToggle(id, gid, cb) {
+        return {
+            t: 'tog',
+            id: id,
+            gid: gid,
+            cb: cb
+        };
+    }
+
+    function makeRadio(id, cb) {
+        return {
+            t: 'rad',
+            id: id + '-' + ridCtr,
+            cb: cb
+        };
+    }
+
+    function separator() {
+        return {
+            t: 'sep'
+        };
+    }
+
+    function createToolbar() {
+
+    }
+
+    angular.module('onosWidget')
+        .factory('ToolbarService', ['$log', function (_$log_) {
+            $log = _$log_;
+
+            return {
+                makeButton: makeButton,
+                makeToggle: makeToggle,
+                makeRadio: makeRadio,
+                separator: separator,
+                createToolbar: createToolbar
+            };
+        }]);
+
+}());
\ No newline at end of file
diff --git a/web/gui/src/main/webapp/app/index.html b/web/gui/src/main/webapp/app/index.html
index f6e2be7..dc8b51c 100644
--- a/web/gui/src/main/webapp/app/index.html
+++ b/web/gui/src/main/webapp/app/index.html
@@ -58,6 +58,7 @@
 
     <script src="fw/widget/widget.js"></script>
     <script src="fw/widget/table.js"></script>
+    <script src="fw/widget/toolbar.js"></script>
 
     <script src="fw/layer/layer.js"></script>
     <script src="fw/layer/panel.js"></script>
diff --git a/web/gui/src/main/webapp/tests/app/fw/widget/toolbar-spec.js b/web/gui/src/main/webapp/tests/app/fw/widget/toolbar-spec.js
new file mode 100644
index 0000000..2269642
--- /dev/null
+++ b/web/gui/src/main/webapp/tests/app/fw/widget/toolbar-spec.js
@@ -0,0 +1,77 @@
+/*
+ * 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 -- Widget -- Toolbar Service - Unit Tests
+ */
+describe('factory: fw/widget/toolbar.js', function () {
+    var $log, fs, tbs;
+
+    beforeEach(module('onosWidget', 'onosUtil'));
+
+    beforeEach(inject(function (_$log_, FnService, ToolbarService) {
+        $log = _$log_;
+        fs = FnService;
+        tbs = ToolbarService;
+    }));
+
+    it('should define ToolbarService', function () {
+        expect(tbs).toBeDefined();
+    });
+
+    it('should define api functions', function () {
+        expect(fs.areFunctions(tbs, [
+            'makeButton', 'makeToggle', 'makeRadio', 'separator', 'createToolbar'
+        ])).toBeTruthy();
+    });
+
+    it("should verify makeButton's returned object", function () {
+        var button = tbs.makeButton('foo', 'glyph-bar', function () {});
+
+        expect(button.t).toBe('btn');
+        expect(button.id).toBe('foo');
+        expect(button.gid).toBe('glyph-bar');
+        expect(fs.isF(button.cb)).toBeTruthy();
+    });
+
+    it("should verify makeToggle's returned object", function () {
+        var toggle = tbs.makeToggle('foo', 'glyph-bar', function () {});
+
+        expect(toggle.t).toBe('tog');
+        expect(toggle.id).toBe('foo');
+        expect(toggle.gid).toBe('glyph-bar');
+        expect(fs.isF(toggle.cb)).toBeTruthy();
+    });
+
+    it("should verify makeRadio's returned object", function () {
+        // TODO: finish this
+
+        //var rFoo1 = tbs.makeRadio('foo', function () {});
+        //var rFoo2 = tbs.makeRadio('foo', function () {});
+        //var rFoo3 = tbs.makeRadio('foo', function () {});
+        //var rBar1 = tbs.makeRadio('bar', function () {});
+        //
+        //expect(radio1.t).toBe('rad');
+        //expect(radio1.id).toBe('foo');
+        //expect(fs.isF(radio1.cb)).toBeTruthy();
+    });
+
+    it("should verify separator's returned object", function () {
+        var separator = tbs.separator();
+        expect(separator.t).toBe('sep');
+    });
+
+});