Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Moves the SC.SliderView tests into its own directory and files for ea…

…sier identification.
  • Loading branch information...
commit ff8a6efd702968c7e2223b94dc8ab0ad0d1d668e 1 parent 95fcb48
@publickeating publickeating authored
View
89 frameworks/desktop/tests/views/progress/methods.js
@@ -4,9 +4,9 @@
// portions copyright @2011 Apple Inc.
// License: Licensed under MIT license (see license.js)
// ==========================================================================
-
/*global module test htmlbody ok equals same stop start */
-/*
+
+
module("SC.ProgressView Methods", {
setup: function() {
SC.RunLoop.begin();
@@ -20,10 +20,10 @@ module("SC.ProgressView Methods", {
});
pane.append(); // make sure there is a layer...
SC.RunLoop.end();
-
+
view = pane.childViews[0];
- },
-
+ },
+
teardown: function() {
pane.remove();
pane = view = null ;
@@ -35,94 +35,23 @@ test("changing a progress view value to maximum", function() {
equals(view.get('isIndeterminate'), NO, 'precon - value should be NO');
equals(view.get('isRunning'), NO, 'precon - value should be NO');
equals(view.get('isEnabled'), YES, 'precon - value should be YES');
-
+
SC.RunLoop.begin();
view.set('value', 100);
SC.RunLoop.end();
-
+
equals(view.get('value'), 100, 'should be 100');
});
test("changing value of a disabled progress view", function() {
equals(view.get('value'), 25, 'precon - value should be 25');
equals(view.get('isEnabled'), YES, 'precon - value should be YES');
-
+
SC.RunLoop.begin();
view.set('isEnabled', NO);
view.set('value', 100);
SC.RunLoop.end();
-
+
// changing while disabled is allowed
equals(view.get('value'), 100, 'should be 100');
});
-
-// ..........................................................
-// SC.SliderView
-//
-
-module("SC.SliderView Methods", {
- setup: function() {
- SC.RunLoop.begin();
- pane = SC.MainPane.create({
- childViews: [
- SC.SliderView.extend({
- value: 50,
- minimum: 0,
- maximum: 100
- })]
- });
- pane.append(); // make sure there is a layer...
- SC.RunLoop.end();
-
- view = pane.childViews[0];
- },
-
- teardown: function() {
- pane.remove();
- pane = view = null ;
- }
-});
-
-test("changing value of the slider will change its left position", function() {
- equals(view.get('value'), 50, 'precond - value should be 50');
- equals(view.$('.sc-handle').css('left'), '50%', 'left of sc-handle should be 50%');
-
- var elem = view.get('layer');
-
- SC.RunLoop.begin();
- view.set('value', 100);
- SC.RunLoop.end();
-
- equals(view.get('value'), 100, 'value should now be 100');
- equals(view.$('.sc-handle').css('left'), '100%', 'left of sc-handle should be 100%');
-
-});
-
-test("going over maximum slider limit", function() {
- equals(view.get('value'), 50, 'precond - value should be 50');
-
- var elem = view.get('layer');
-
- SC.RunLoop.begin();
- view.set('value', 150);
- SC.RunLoop.end();
-
- // TODO: should we allow setting value higher then maximum?
- equals(view.get('value'), 150, 'value should now be 150');
- equals(view.$('.sc-handle').css('left'), '100%', 'left of sc-handle should be 100%');
-});
-
-test("going below minimum slider limit", function() {
- equals(view.get('value'), 50, 'precond - value should be 50');
-
- var elem = view.get('layer');
-
- SC.RunLoop.begin();
- view.set('value', -10);
- SC.RunLoop.end();
-
- // TODO: should we allow setting value lower then minimum?
- equals(view.get('value'), -10, 'value should now be -10');
- equals(view.$('.sc-handle').css('left'), '0%', 'left of sc-handle should be 0%');
-});
-*/
View
132 frameworks/desktop/tests/views/progress/ui.js
@@ -9,7 +9,6 @@
(function() {
var pane = SC.ControlTestPane.design()
-
.add("progress basic", SC.ProgressView, {
layout: {top:0, bottom:0, left:0, width: 250},
value: 25,
@@ -77,70 +76,6 @@ var pane = SC.ControlTestPane.design()
minimum: 0,
maximum: 100,
isEnabled: NO
- })
-
- // Slider View UI
- .add("slider basic", SC.SliderView, {
- layout: {top:0, bottom:0, left:0, width: 250},
- value: 50,
- minimum: 0,
- maximum: 100
- })
- .add("slider disabled", SC.SliderView, {
- layout: {top:0, bottom:0, left:0, width: 250},
- value: 50,
- minimum: 0,
- maximum: 100,
- isEnabled: NO
- })
- .add("slider value 100", SC.SliderView, {
- layout: {top:0, bottom:0, left:0, width: 250},
- value: 100,
- minimum: 0,
- maximum: 100
- })
- .add("slider basic step 20", SC.SliderView, {
- layout: {top:0, bottom:0, left:0, width: 250},
- value: 50,
- minimum: 0,
- maximum: 100,
- step: 20
- })
- .add("slider aria-role", SC.SliderView, {
- layout: {top:0, bottom:0, left:0, width: 250},
- value: 10,
- minimum: 0,
- maximum: 50
- })
- .add("slider aria-valuemax", SC.SliderView, {
- layout: {top:0, bottom:0, left:0, width: 250},
- value: 40,
- minimum: 0,
- maximum: 100
- })
- .add("slider aria-valuemin", SC.SliderView, {
- layout: {top:0, bottom:0, left:0, width: 250},
- value: 20,
- minimum: 0,
- maximum: 100
- })
- .add("slider aria-valuenow", SC.SliderView, {
- layout: {top:0, bottom:0, left:0, width: 250},
- value: 40,
- minimum: 0,
- maximum: 100
- })
- .add("slider aria-valuetext", SC.SliderView, {
- layout: {top:0, bottom:0, left:0, width: 250},
- value: 20,
- minimum: 0,
- maximum: 100
- })
- .add("slider aria-orientation", SC.SliderView, {
- layout: {top:0, bottom:0, left:0, width: 250},
- value: 50,
- minimum: 0,
- maximum: 100
});
// ..........................................................
@@ -356,71 +291,4 @@ test("Check if attribute aria-valuetext is set correctly", function() {
equals(viewElem.attr('aria-valuetext'), 20, 'aria-valuetext should be 20');
});
-
-// ..........................................................
-// SC.SliderView
-//
-
-module("SC.SliderView UI", pane.standardSetup());
-
-test("basic", function() {
- var view = pane.view('slider basic');
-
- ok(!view.$().hasClass('disabled'), 'should NOT have disabled class');
- ok(view.$('.track').length > 0, 'should have track classed element');
- ok(view.$('.sc-handle').length > 0, 'should have sc-handle classed element');
- equals(view.$('.sc-handle')[0].style.left, '50%', 'left of sc-handle should be 50%');
-});
-
-test("disabled", function() {
- var view = pane.view('slider disabled');
-
- ok(view.$().hasClass('disabled'), 'should have disabled class');
- ok(view.$('.track').length > 0, 'should have track classed element');
- ok(view.$('.sc-handle').length > 0, 'should have sc-handle classed element');
- equals(view.$('.sc-handle')[0].style.left, '50%', 'left of sc-handle should be 50%');
-});
-
-test("basic value 100", function() {
- var view = pane.view('slider value 100');
-
- ok(!view.$().hasClass('disabled'), 'should have disabled class');
- ok(view.$('.track').length > 0, 'should have track classed element');
- ok(view.$('.sc-handle').length > 0, 'should have sc-handle classed element');
- equals(view.$('.sc-handle')[0].style.left, '100%', 'left of sc-handle should be 100%');
-});
-
-test("basic step 20", function() {
- var view = pane.view('slider basic step 20');
-
- ok(!view.$().hasClass('disabled'), 'should have disabled class');
- ok(view.$('.track').length > 0, 'should have track classed element');
- ok(view.$('.sc-handle').length > 0, 'should have sc-handle classed element');
- equals(view.$('.sc-handle')[0].style.left, '60%', 'left of sc-handle should be 60%');
-});
-
-test("Check if aria role is set to slider view", function() {
- var viewElem = pane.view('slider aria-role').$();
- ok(viewElem.attr('role') === 'slider', 'aria-role is set to the slider view');
-});
-
-test("Check if attribute aria-valuemax is set correctly", function() {
- var viewElem = pane.view('slider aria-valuemax').$();
- equals(viewElem.attr('aria-valuemax'), 100, 'aria-valuemax should be 100');
-});
-
-test("Check if attribute aria-valuemin is set correctly", function() {
- var viewElem = pane.view('slider aria-valuemin').$();
- equals(viewElem.attr('aria-valuemin'), 0, 'aria-valuemin should be 0');
-});
-
-test("Check if attribute aria-valuenow is set correctly", function() {
- var viewElem = pane.view('slider aria-valuenow').$();
- equals(viewElem.attr('aria-valuenow'), 40, 'aria-valuenow should be 40');
-});
-
-test("Check if attribute aria-orientation is set correctly", function() {
- var viewElem = pane.view('slider aria-orientation').$();
- equals(viewElem.attr('aria-orientation'), "horizontal", 'aria-orientation should be horizontal');
-});
})();
View
74 frameworks/desktop/tests/views/slider/methods.js
@@ -0,0 +1,74 @@
+// ==========================================================================
+// Project: SproutCore - JavaScript Application Framework
+// Copyright: ©2006-2011 Strobe Inc. and contributors.
+// portions copyright @2011 Apple Inc.
+// License: Licensed under MIT license (see license.js)
+// ==========================================================================
+/*global module test htmlbody ok equals same stop start */
+
+
+module("SC.SliderView Methods", {
+ setup: function() {
+ // SC.RunLoop.begin();
+ pane = SC.MainPane.create({
+ childViews: [
+ SC.SliderView.extend({
+ value: 50,
+ minimum: 0,
+ maximum: 100
+ })]
+ });
+ pane.append(); // make sure there is a layer...
+ // SC.RunLoop.end();
+
+ view = pane.childViews[0];
+ },
+
+ teardown: function() {
+ pane.remove();
+ pane = view = null ;
+ }
+});
+
+test("changing value of the slider will change its left position", function() {
+ equals(view.get('value'), 50, 'precond - value should be 50');
+ equals(view.$('.sc-handle').css('left'), '50%', 'left of sc-handle should be 50%');
+
+ var elem = view.get('layer');
+
+ SC.RunLoop.begin();
+ view.set('value', 100);
+ SC.RunLoop.end();
+
+ equals(view.get('value'), 100, 'value should now be 100');
+ equals(view.$('.sc-handle').css('left'), '100%', 'left of sc-handle should be 100%');
+
+});
+
+test("going over maximum slider limit", function() {
+ equals(view.get('value'), 50, 'precond - value should be 50');
+
+ var elem = view.get('layer');
+
+ SC.RunLoop.begin();
+ view.set('value', 150);
+ SC.RunLoop.end();
+
+ // TODO: should we allow setting value higher then maximum?
+ equals(view.get('value'), 150, 'value should now be 150');
+ equals(view.$('.sc-handle').css('left'), '100%', 'left of sc-handle should be 100%');
+});
+
+test("going below minimum slider limit", function() {
+ equals(view.get('value'), 50, 'precond - value should be 50');
+
+ var elem = view.get('layer');
+
+ SC.RunLoop.begin();
+ view.set('value', -10);
+ SC.RunLoop.end();
+
+ // TODO: should we allow setting value lower then minimum?
+ equals(view.get('value'), -10, 'value should now be -10');
+ equals(view.$('.sc-handle').css('left'), '0%', 'left of sc-handle should be 0%');
+});
View
141 frameworks/desktop/tests/views/slider/ui.js
@@ -0,0 +1,141 @@
+// ==========================================================================
+// Project: SproutCore - JavaScript Application Framework
+// Copyright: ©2006-2011 Strobe Inc. and contributors.
+// portions copyright @2011 Apple Inc.
+// License: Licensed under MIT license (see license.js)
+// ==========================================================================
+
+/*global module test htmlbody ok equals same stop start */
+
+(function() {
+var pane = SC.ControlTestPane.design()
+ .add("slider basic", SC.SliderView, {
+ layout: {top:0, bottom:0, left:0, width: 250},
+ value: 50,
+ minimum: 0,
+ maximum: 100
+ })
+ .add("slider disabled", SC.SliderView, {
+ layout: {top:0, bottom:0, left:0, width: 250},
+ value: 50,
+ minimum: 0,
+ maximum: 100,
+ isEnabled: NO
+ })
+ .add("slider value 100", SC.SliderView, {
+ layout: {top:0, bottom:0, left:0, width: 250},
+ value: 100,
+ minimum: 0,
+ maximum: 100
+ })
+ .add("slider basic step 20", SC.SliderView, {
+ layout: {top:0, bottom:0, left:0, width: 250},
+ value: 50,
+ minimum: 0,
+ maximum: 100,
+ step: 20
+ })
+ .add("slider aria-role", SC.SliderView, {
+ layout: {top:0, bottom:0, left:0, width: 250},
+ value: 10,
+ minimum: 0,
+ maximum: 50
+ })
+ .add("slider aria-valuemax", SC.SliderView, {
+ layout: {top:0, bottom:0, left:0, width: 250},
+ value: 40,
+ minimum: 0,
+ maximum: 100
+ })
+ .add("slider aria-valuemin", SC.SliderView, {
+ layout: {top:0, bottom:0, left:0, width: 250},
+ value: 20,
+ minimum: 0,
+ maximum: 100
+ })
+ .add("slider aria-valuenow", SC.SliderView, {
+ layout: {top:0, bottom:0, left:0, width: 250},
+ value: 40,
+ minimum: 0,
+ maximum: 100
+ })
+ .add("slider aria-valuetext", SC.SliderView, {
+ layout: {top:0, bottom:0, left:0, width: 250},
+ value: 20,
+ minimum: 0,
+ maximum: 100
+ })
+ .add("slider aria-orientation", SC.SliderView, {
+ layout: {top:0, bottom:0, left:0, width: 250},
+ value: 50,
+ minimum: 0,
+ maximum: 100
+ });
+
+// ..........................................................
+// TEST VIEWS
+//
+
+module("SC.SliderView UI", pane.standardSetup());
+
+test("basic", function() {
+ var view = pane.view('slider basic');
+
+ ok(!view.$().hasClass('disabled'), 'should NOT have disabled class');
+ ok(view.$('.track').length > 0, 'should have track classed element');
+ ok(view.$('.sc-handle').length > 0, 'should have sc-handle classed element');
+ equals(view.$('.sc-handle')[0].style.left, '50%', 'left of sc-handle should be 50%');
+});
+
+test("disabled", function() {
+ var view = pane.view('slider disabled');
+
+ ok(view.$().hasClass('disabled'), 'should have disabled class');
+ ok(view.$('.track').length > 0, 'should have track classed element');
+ ok(view.$('.sc-handle').length > 0, 'should have sc-handle classed element');
+ equals(view.$('.sc-handle')[0].style.left, '50%', 'left of sc-handle should be 50%');
+});
+
+test("basic value 100", function() {
+ var view = pane.view('slider value 100');
+
+ ok(!view.$().hasClass('disabled'), 'should have disabled class');
+ ok(view.$('.track').length > 0, 'should have track classed element');
+ ok(view.$('.sc-handle').length > 0, 'should have sc-handle classed element');
+ equals(view.$('.sc-handle')[0].style.left, '100%', 'left of sc-handle should be 100%');
+});
+
+test("basic step 20", function() {
+ var view = pane.view('slider basic step 20');
+
+ ok(!view.$().hasClass('disabled'), 'should have disabled class');
+ ok(view.$('.track').length > 0, 'should have track classed element');
+ ok(view.$('.sc-handle').length > 0, 'should have sc-handle classed element');
+ equals(view.$('.sc-handle')[0].style.left, '60%', 'left of sc-handle should be 60%');
+});
+
+test("Check if aria role is set to slider view", function() {
+ var viewElem = pane.view('slider aria-role').$();
+ ok(viewElem.attr('role') === 'slider', 'aria-role is set to the slider view');
+});
+
+test("Check if attribute aria-valuemax is set correctly", function() {
+ var viewElem = pane.view('slider aria-valuemax').$();
+ equals(viewElem.attr('aria-valuemax'), 100, 'aria-valuemax should be 100');
+});
+
+test("Check if attribute aria-valuemin is set correctly", function() {
+ var viewElem = pane.view('slider aria-valuemin').$();
+ equals(viewElem.attr('aria-valuemin'), 0, 'aria-valuemin should be 0');
+});
+
+test("Check if attribute aria-valuenow is set correctly", function() {
+ var viewElem = pane.view('slider aria-valuenow').$();
+ equals(viewElem.attr('aria-valuenow'), 40, 'aria-valuenow should be 40');
+});
+
+test("Check if attribute aria-orientation is set correctly", function() {
+ var viewElem = pane.view('slider aria-orientation').$();
+ equals(viewElem.attr('aria-orientation'), "horizontal", 'aria-orientation should be horizontal');
+});
+})();
Please sign in to comment.
Something went wrong with that request. Please try again.