1 // Copyright 2011 Google Inc. All Rights Reserved.
4 * @fileoverview Regression tests for range selector.
5 * @author paul.eric.felix@gmail.com (Paul Felix)
7 var RangeSelectorTestCase
= TestCase("range-selector");
9 RangeSelectorTestCase
.prototype.setUp
= function() {
10 document
.body
.innerHTML
= "<div id='graph'></div>";
13 RangeSelectorTestCase
.prototype.tearDown
= function() {
16 RangeSelectorTestCase
.prototype.testRangeSelector
= function() {
20 showRangeSelector
: true
33 var graph
= document
.getElementById("graph");
34 var g
= new Dygraph(graph
, data
, opts
);
35 this.assertGraphExistence(g
, graph
);
38 RangeSelectorTestCase
.prototype.testRangeSelectorWithErrorBars
= function() {
43 showRangeSelector
: true
56 var graph
= document
.getElementById("graph");
57 var g
= new Dygraph(graph
, data
, opts
);
58 this.assertGraphExistence(g
, graph
);
61 RangeSelectorTestCase
.prototype.testRangeSelectorWithCustomBars
= function() {
66 showRangeSelector
: true
79 var graph
= document
.getElementById("graph");
80 var g
= new Dygraph(graph
, data
, opts
);
81 this.assertGraphExistence(g
, graph
);
84 RangeSelectorTestCase
.prototype.testRangeSelectorWithLogScale
= function() {
89 showRangeSelector
: true
102 var graph
= document
.getElementById("graph");
103 var g
= new Dygraph(graph
, data
, opts
);
104 this.assertGraphExistence(g
, graph
);
107 RangeSelectorTestCase
.prototype.testRangeSelectorOptions
= function() {
111 showRangeSelector
: true,
112 rangeSelectorHeight
: 30,
113 rangeSelectorPlotFillColor
: 'lightyellow',
114 rangeSelectorPlotStyleColor
: 'yellow'
127 var graph
= document
.getElementById("graph");
128 var g
= new Dygraph(graph
, data
, opts
);
129 this.assertGraphExistence(g
, graph
);
132 RangeSelectorTestCase
.prototype.testRangeSelectorEnablingAfterCreation
= function() {
148 var graph
= document
.getElementById("graph");
149 var g
= new Dygraph(graph
, data
, opts
);
150 g
.updateOptions({showRangeSelector
: true});
151 this.assertGraphExistence(g
, graph
);
154 // The animatedZooms option does not work with the range selector. Make sure it gets turned off.
155 RangeSelectorTestCase
.prototype.testRangeSelectorWithAnimatedZoomsOption
= function() {
159 showRangeSelector
: true,
173 var graph
= document
.getElementById("graph");
174 var g
= new Dygraph(graph
, data
, opts
);
175 this.assertGraphExistence(g
, graph
);
176 assertFalse(g
.getOption('animatedZooms'));
179 RangeSelectorTestCase
.prototype.testRangeSelectorWithAnimatedZoomsOption2
= function() {
196 var graph
= document
.getElementById("graph");
197 var g
= new Dygraph(graph
, data
, opts
);
198 g
.updateOptions({showRangeSelector
: true});
199 this.assertGraphExistence(g
, graph
);
200 assertFalse(g
.getOption('animatedZooms'));
203 RangeSelectorTestCase
.prototype.assertGraphExistence
= function(g
, graph
) {
205 var zoomhandles
= graph
.getElementsByClassName('dygraph-rangesel-zoomhandle');
206 assertEquals(2, zoomhandles
.length
);
207 var bgcanvas
= graph
.getElementsByClassName('dygraph-rangesel-bgcanvas');
208 assertEquals(1, bgcanvas
.length
);
209 var fgcanvas
= graph
.getElementsByClassName('dygraph-rangesel-fgcanvas');
210 assertEquals(1, fgcanvas
.length
);