Skip to content

Commit

Permalink
FLUID-4787: Removing setupTestEnvironmentFeature in favour of setStat…
Browse files Browse the repository at this point in the history
…icEnv and cleanupEnv
  • Loading branch information
michelled committed Oct 16, 2012
1 parent e13e4ac commit a8a8691
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 47 deletions.
7 changes: 1 addition & 6 deletions tests/js/TestUtils.js
Expand Up @@ -85,7 +85,7 @@ fluid.registerNamespace("fluid.testUtils");

fluid.testUtils.setStaticEnv = function (features) {
fluid.each(features, function (val, key) {
fluid.staticEnvironment[key] = val ? fluid.typeTag(val.typeName) : undefined;
fluid.staticEnvironment[key] = val ? fluid.typeTag(val) : undefined;
});
};

Expand All @@ -95,9 +95,4 @@ fluid.registerNamespace("fluid.testUtils");
});
};

fluid.testUtils.setupTestEnvironmentFeature = function (environmentFeature, flag) {
delete fluid.staticEnvironment[environmentFeature];
fluid.staticEnvironment[environmentFeature] = (flag) ? fluid.typeTag("fluid.browser." + environmentFeature) : undefined;
};

})(jQuery);
36 changes: 21 additions & 15 deletions tests/js/VideoPlayerControlsTests.js
Expand Up @@ -23,7 +23,13 @@ fluid.registerNamespace("fluid.tests");

// TODO: The various "fluid.tests.initXXX" functions could probably be refactored to reduce duplication

var videoPlayerControlsTests = new jqUnit.TestCase("Video Player Controls Tests");
var envFeatures = {"supportsFullScreen": "fluid.browser.supportsFullScreen"};

var teardown = function () {
fluid.testUtils.cleanupEnv(envFeatures);
};

var videoPlayerControlsTests = new jqUnit.TestCase("Video Player Controls Tests", null, teardown);

var baseVideoPlayerOpts = {
video: {
Expand Down Expand Up @@ -73,7 +79,7 @@ fluid.registerNamespace("fluid.tests");

videoPlayerControlsTests.asyncTest("Volume controls", function () {
jqUnit.expect(5);
var checkSlider = function(ariavaluenow, expectedValue) {
var checkSlider = function (ariavaluenow, expectedValue) {
jqUnit.assertEquals("The slider button should have valuenow of " + expectedValue, expectedValue, ariavaluenow);
},
checkTooltipOnHover = function (element, expectedText) {
Expand Down Expand Up @@ -131,7 +137,7 @@ fluid.registerNamespace("fluid.tests");
videoPlayerControlsTests.asyncTest("Fullscreen button should be present in the browsers which support fullscreen mode", function () {
jqUnit.expect(2);

fluid.testUtils.setupTestEnvironmentFeature("supportsFullScreen", true);
fluid.testUtils.setStaticEnv(envFeatures);
var testPlayer = fluid.tests.initVideoPlayer({
listeners: {
onControllersReady: function (that) {
Expand All @@ -145,8 +151,8 @@ fluid.registerNamespace("fluid.tests");

videoPlayerControlsTests.asyncTest("Fullscreen button should NOT be present since component should be null", function () {
jqUnit.expect(1);
fluid.testUtils.setStaticEnv({"supportsFullScreen": false});

fluid.testUtils.setupTestEnvironmentFeature("supportsFullScreen", false);
var testPlayer = fluid.tests.initVideoPlayer({
listeners: {
onControllersReady: function (that) {
Expand All @@ -158,14 +164,14 @@ fluid.registerNamespace("fluid.tests");
});

fluid.tests.checkFullScreenButtonStyle = function (options) {
jqUnit[options.expectedFullScreen ? "assertTrue": "assertFalse"](options.message, options.modelFullScreen);
jqUnit[options.expectedFullScreen ? "assertTrue" : "assertFalse"](options.message, options.modelFullScreen);
jqUnit.assertEquals("After click, full screen button should have a proper styling", !options.expectedFullScreen, options.fullScreenButton.hasClass(options.fullScreenButtonStyles.init));
jqUnit.assertEquals("After click, full screen button should have a proper styling", options.expectedFullScreen, options.fullScreenButton.hasClass(options.fullScreenButtonStyles.pressed));
};

videoPlayerControlsTests.asyncTest("Fullscreen button", function () {
jqUnit.expect(9);
fluid.testUtils.setupTestEnvironmentFeature("supportsFullScreen", true);
fluid.testUtils.setStaticEnv(envFeatures);

var testPlayer = fluid.tests.initVideoPlayer({
listeners: {
Expand Down Expand Up @@ -211,15 +217,15 @@ fluid.registerNamespace("fluid.tests");
var testBufferEndTime;

var baseScrubberOpts = {
model: {
buffered: {
length: 1,
end: function (index) {
return testBufferEndTime;
}
},
totalTime: 200
}
model: {
buffered: {
length: 1,
end: function (index) {
return testBufferEndTime;
}
},
totalTime: 200
}
};

fluid.tests.initScrubber = function (testOpts) {
Expand Down
30 changes: 9 additions & 21 deletions tests/js/VideoPlayerHTML5CaptionatorTests.js
Expand Up @@ -20,10 +20,10 @@ https://github.com/fluid-project/infusion/raw/master/Infusion-LICENSE.txt
$(document).ready(function () {
fluid.setLogging(false); // disable it not to mess up with FireBug in FF

var supportsHtml5 = {
typeName: "fluid.browser.supportsHtml5"
var envFeatures = {
"supportsHtml5": "fluid.browser.supportsHtml5"
};

var container = ".videoPlayer";
var firstEnglishCaption = "English caption here";
var firstFrenchCaption = "French caption here";
Expand Down Expand Up @@ -158,9 +158,7 @@ https://github.com/fluid-project/infusion/raw/master/Infusion-LICENSE.txt
}
}, {
desc: "HTML5: html5Captionator was initialized but without tracks",
envFeatures: {
supportsHtml5: supportsHtml5
},
envFeatures: envFeatures,
testFn: function () {
testInit({
options: defaultOptionsNoCaptions,
Expand All @@ -170,9 +168,7 @@ https://github.com/fluid-project/infusion/raw/master/Infusion-LICENSE.txt
}
}, {
desc: "HTML5: html5Captionator was initialized",
envFeatures: {
supportsHtml5: supportsHtml5
},
envFeatures: envFeatures,
testFn: function () {
testInit({
options: optionsFull,
Expand All @@ -182,9 +178,7 @@ https://github.com/fluid-project/infusion/raw/master/Infusion-LICENSE.txt
}
}, {
desc: "html5Captionator changing tracks and more",
envFeatures: {
supportsHtml5: supportsHtml5
},
envFeatures: envFeatures,
testFn: function () {
initVideoPlayer(optionsFull, function (videoPlayer) {
// VERY BAD. There is no callback for a captionator to fire when it loaded its captions, so we have to wait 1 second before do the test check
Expand Down Expand Up @@ -212,9 +206,7 @@ https://github.com/fluid-project/infusion/raw/master/Infusion-LICENSE.txt
}
}, { // TEST FLUID-4618. Writing a test to verify that functions in preInit work properly
desc: "html5Captionator displayCaptions test",
envFeatures: {
supportsHtml5: supportsHtml5
},
envFeatures: envFeatures,
testFn: function () {
initVideoPlayer(optionsFull, function (videoPlayer) {
// VERY BAD. There is no callback for a captionator to fire when it loaded its captions, so we have to wait 1 second before do the test check
Expand All @@ -230,9 +222,7 @@ https://github.com/fluid-project/infusion/raw/master/Infusion-LICENSE.txt
}
}, {
desc: "html5Captionator without currentTrack",
envFeatures: {
supportsHtml5: supportsHtml5
},
envFeatures: envFeatures,
testFn: function () {
initVideoPlayer(optionsWithoutCurrentTrack, function (videoPlayer) {
setTimeout(function () {
Expand Down Expand Up @@ -261,9 +251,7 @@ https://github.com/fluid-project/infusion/raw/master/Infusion-LICENSE.txt
}
}, {
desc: "displayCaptions is set to false so no captions should be present at all in the DOM",
envFeatures: {
supportsHtml5: supportsHtml5
},
envFeatures: envFeatures,
testFn: function () {
initVideoPlayer(optionsFullWithDisplayCaptionsOff, function (videoPlayer) {
setTimeout(function () {
Expand Down
15 changes: 10 additions & 5 deletions tests/js/VideoPlayerTests.js
Expand Up @@ -18,8 +18,13 @@ https://github.com/fluid-project/infusion/raw/master/Infusion-LICENSE.txt

(function ($) {
$(document).ready(function () {
var envFeatures = {"supportsHtml5": "fluid.browser.supportsHtml5"};

var videoPlayerTests = new jqUnit.TestCase("Video Player Tests");
var teardown = function () {
fluid.testUtils.cleanupEnv(envFeatures);
};

var videoPlayerTests = new jqUnit.TestCase("Video Player Tests", null, teardown);

var initVideoPlayer = function (testOptions) {
var opts = {
Expand Down Expand Up @@ -85,7 +90,7 @@ https://github.com/fluid-project/infusion/raw/master/Infusion-LICENSE.txt
videoPlayerTests.asyncTest("HTML5: video player instantiation with customized controller", function () {
jqUnit.expect(6);

fluid.testUtils.setupTestEnvironmentFeature("supportsHtml5", true);
fluid.testUtils.setStaticEnv(envFeatures);

initVideoPlayer({
controls: "custom",
Expand All @@ -107,7 +112,7 @@ https://github.com/fluid-project/infusion/raw/master/Infusion-LICENSE.txt
videoPlayerTests.asyncTest("HTML5: video player instantiation with native controller", function () {
jqUnit.expect(6);

fluid.testUtils.setupTestEnvironmentFeature("supportsHtml5", true);
fluid.testUtils.setStaticEnv(envFeatures);

initVideoPlayer({
controls: "native",
Expand All @@ -129,7 +134,7 @@ https://github.com/fluid-project/infusion/raw/master/Infusion-LICENSE.txt
videoPlayerTests.asyncTest("HTML5: Controllers instantiation", function () {
jqUnit.expect(5);

fluid.testUtils.setupTestEnvironmentFeature("supportsHtml5", true);
fluid.testUtils.setStaticEnv(envFeatures);

initVideoPlayer({
controls: "custom",
Expand All @@ -150,7 +155,7 @@ https://github.com/fluid-project/infusion/raw/master/Infusion-LICENSE.txt
videoPlayerTests.asyncTest("NON-HTML5: video player instantiation", function () {
jqUnit.expect(5);

fluid.testUtils.setupTestEnvironmentFeature("supportsHtml5", false);
fluid.testUtils.setStaticEnv({"supportsHtml5": false});

initVideoPlayer({
listeners: {
Expand Down

0 comments on commit a8a8691

Please sign in to comment.