Merge lp:~bac/juju-gui/1083933 into lp:juju-gui/experimental

Proposed by Brad Crittenden
Status: Merged
Merged at revision: 316
Proposed branch: lp:~bac/juju-gui/1083933
Merge into: lp:juju-gui/experimental
Diff against target: 140 lines (+87/-14)
3 files modified
app/views/topology/viewport.js (+1/-14)
test/index.html (+1/-0)
test/test_viewport_module.js (+85/-0)
To merge this branch: bzr merge lp:~bac/juju-gui/1083933
Reviewer Review Type Date Requested Status
Juju GUI Hackers Pending
Review via email: mp+143120@code.launchpad.net

Description of the change

Add tests for new viewport module.

Add tests for the new module. Also removed an unused function. It looked
useful but I didn't think it should hang around if not called. Ben might have
had a plan for it.

https://codereview.appspot.com/7085057/

To post a comment you must log in.
Revision history for this message
Brad Crittenden (bac) wrote :

Reviewers: mp+143120_code.launchpad.net,

Message:
Please take a look.

Description:
Add tests for new viewport module.

Add tests for the new module. Also removed an unused function. It
looked
useful but I didn't think it should hang around if not called. Ben
might have
had a plan for it.

https://code.launchpad.net/~bac/juju-gui/1083933/+merge/143120

(do not edit description out of merge proposal)

Please review this at https://codereview.appspot.com/7085057/

Affected files:
   A [revision details]
   M app/views/topology/viewport.js
   M test/index.html
   A test/test_viewport_module.js

Revision history for this message
Madison Scott-Clary (makyo) wrote :

Land as is, thanks for the tests.

https://codereview.appspot.com/7085057/

lp:~bac/juju-gui/1083933 updated
318. By Brad Crittenden

Merge from trunk

Revision history for this message
Brad Crittenden (bac) wrote :

*** Submitted:

Add tests for new viewport module.

Add tests for the new module. Also removed an unused function. It
looked
useful but I didn't think it should hang around if not called. Ben
might have
had a plan for it.

R=matthew.scott, benji
CC=
https://codereview.appspot.com/7085057

https://codereview.appspot.com/7085057/

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'app/views/topology/viewport.js'
--- app/views/topology/viewport.js 2013-01-08 17:52:24 +0000
+++ app/views/topology/viewport.js 2013-01-14 20:14:21 +0000
@@ -7,18 +7,6 @@
7 d3ns = Y.namespace('d3');7 d3ns = Y.namespace('d3');
88
9 /**9 /**
10 * Utility function to get a number from a computed style.
11 * @method styleToNumber
12 */
13 function styleToNumber(selector, style, defaultSize) {
14 style = style || 'height';
15 defaultSize = defaultSize || 0;
16 return parseInt(Y.one(selector).getComputedStyle(style) || defaultSize,
17 10);
18 }
19
20
21 /**
22 * @module topology-viewport10 * @module topology-viewport
23 * @class ViewportModule11 * @class ViewportModule
24 * @namespace views12 * @namespace views
@@ -57,14 +45,13 @@
57 // smallest size we accept--no smaller or bigger--or else the45 // smallest size we accept--no smaller or bigger--or else the
58 // presence or absence of scrollbars may affect our calculations46 // presence or absence of scrollbars may affect our calculations
59 // incorrectly.47 // incorrectly.
60 canvas.setStyles({height: 600, width: 800});48 canvas.setStyles({height: '600px', width: '800px'});
61 var dimensions = utils.getEffectiveViewportSize(true, 800, 600);49 var dimensions = utils.getEffectiveViewportSize(true, 800, 600);
62 svg.setAttribute('width', dimensions.width);50 svg.setAttribute('width', dimensions.width);
63 svg.setAttribute('height', dimensions.height);51 svg.setAttribute('height', dimensions.height);
64 vis.attr('width', dimensions.width);52 vis.attr('width', dimensions.width);
65 vis.attr('height', dimensions.height);53 vis.attr('height', dimensions.height);
6654
67
68 zoomPlane.setAttribute('width', dimensions.width);55 zoomPlane.setAttribute('width', dimensions.width);
69 zoomPlane.setAttribute('height', dimensions.height);56 zoomPlane.setAttribute('height', dimensions.height);
70 canvas.setStyles({57 canvas.setStyles({
7158
=== modified file 'test/index.html'
--- test/index.html 2013-01-10 18:17:46 +0000
+++ test/index.html 2013-01-14 20:14:21 +0000
@@ -54,6 +54,7 @@
54 <script src="test_service_view.js"></script>54 <script src="test_service_view.js"></script>
55 <script src="test_unit_view.js"></script>55 <script src="test_unit_view.js"></script>
56 <script src="test_utils.js"></script>56 <script src="test_utils.js"></script>
57 <script src="test_viewport_module.js"></script>
5758
5859
59 <script>60 <script>
6061
=== added file 'test/test_viewport_module.js'
--- test/test_viewport_module.js 1970-01-01 00:00:00 +0000
+++ test/test_viewport_module.js 2013-01-14 20:14:21 +0000
@@ -0,0 +1,85 @@
1'use strict';
2
3describe('viewport module', function() {
4 var db, juju, models, viewContainer, views, Y, viewportModule;
5 before(function(done) {
6 Y = YUI(GlobalConfig).use(['node',
7 'juju-models',
8 'juju-views',
9 'juju-gui',
10 'juju-env',
11 'juju-tests-utils',
12 'node-event-simulate'],
13 function(Y) {
14 juju = Y.namespace('juju');
15 models = Y.namespace('juju.models');
16 views = Y.namespace('juju.views');
17 done();
18 });
19 });
20
21 beforeEach(function() {
22 viewContainer = Y.Node.create('<div />');
23 viewContainer.appendTo(Y.one('body'));
24 viewContainer.hide();
25 db = new models.Database();
26 var view = new views.environment(
27 { container: viewContainer,
28 db: db});
29 view.render();
30 view.rendered();
31 viewportModule = view.topo.modules.ViewportModule;
32 });
33
34 afterEach(function() {
35 if (viewContainer) {
36 viewContainer.remove(true);
37 }
38 });
39
40 it('should fire before and after events', function() {
41 var topo = viewportModule.get('component');
42 var events = [];
43 topo.fire = function(e) {
44 events.push(e);
45 };
46 viewportModule.resized();
47 events.should.eql(
48 ['beforePageSizeRecalculation',
49 'sizeChange',
50 'afterPageSizeRecalculation']);
51 });
52
53 it('should set canvas dimensions', function() {
54 var container = viewportModule.get('container');
55 var canvas = container.one('.topology-canvas');
56 // Initialize to absurd dimensions.
57 canvas.setStyles({height: '60px', width: '80px'});
58 viewportModule.resized();
59 canvas.getStyle('width').should.equal('800px');
60 canvas.getStyle('height').should.equal('600px');
61 });
62
63 it('should set zoom plane dimensions', function() {
64 var container = viewportModule.get('container');
65 var zoomPlane = container.one('.zoom-plane');
66 // Initialize to absurd dimensions.
67 zoomPlane.setAttribute('width', 10);
68 zoomPlane.setAttribute('height', 10);
69 viewportModule.resized();
70 zoomPlane.getAttribute('width').should.equal('800');
71 zoomPlane.getAttribute('height').should.equal('600');
72 });
73
74 it('should set svg dimensions', function() {
75 var container = viewportModule.get('container');
76 var svg = container.one('svg');
77 // Initialize to absurd dimensions.
78 svg.setAttribute('width', 10);
79 svg.setAttribute('height', 10);
80 viewportModule.resized();
81 svg.getAttribute('width').should.equal('800');
82 svg.getAttribute('height').should.equal('600');
83 });
84
85});

Subscribers

People subscribed via source and target branches