Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/demo' into demo
Browse files Browse the repository at this point in the history
  • Loading branch information
cindyli committed Mar 26, 2013
2 parents 74d78b6 + a5bf124 commit 80eda2c
Show file tree
Hide file tree
Showing 3 changed files with 144 additions and 67 deletions.
79 changes: 35 additions & 44 deletions src/webapp/components/uiOptions/js/SettingsPanels.js
Expand Up @@ -34,65 +34,56 @@ var fluid_1_5 = fluid_1_5 || {};
refreshView: "{that}.renderer.refreshView"
}
});

fluid.uiOptions.createSliderNode = function (that, path, type, options) {
return {
decorators: {
type: "fluid",
func: type,
options: {
listeners: {
modelChanged: function (value) {
that.applier.requestChange(path, value);
}
},
model: {
min: that.options.min,
max: that.options.max,
value: fluid.get(that.model, path)

},
sliderOptions: that.options.sliderOptions
}
}
};
};

/*************************
* UI Options Text Sizer *
*************************/

fluid.defaults("fluid.uiOptions.textfieldSlider", {
gradeNames: ["fluid.textfieldSlider", "autoInit"],
path: "value",
listeners: {
modelChanged: {
listener: "{fluid.uiOptions.settingsPanel}.applier.requestChange",
args: ["{that}.options.path", "{arguments}.0"]
}
},
model: "{fluid.uiOptions.settingsPanel}.model",
sliderOptions: "{fluid.uiOptions.settingsPanel}.options.sliderOptions"
});

/**
* A sub-component of fluid.uiOptions that renders the "text size" panel of the user preferences interface.
*/
fluid.defaults("fluid.uiOptions.textSizer", {
gradeNames: ["fluid.uiOptions.settingsPanel", "autoInit"],
model: {
value: 1
value: 1,
min: 1,
max: 2
},
min: 1,
max: 2,
sliderOptions: {
orientation: "horizontal",
step: 0.1
},
selectors: {
textSize: ".flc-uiOptions-min-text-size",
},
produceTree: "fluid.uiOptions.textSizer.produceTree",
protoTree: {
textSize: {
decorators: {
type: "fluid",
func: "fluid.uiOptions.textfieldSlider"
}
}
},
resources: {
template: {
url: "../html/UIOptionsTemplate-textSizer.html"
}
}
});

fluid.uiOptions.textSizer.produceTree = function (that) {
return {
textSize: fluid.uiOptions.createSliderNode(that, "value", "fluid.textfieldSlider")
}
};

/************************
* UI Options Text Font *
************************/
Expand Down Expand Up @@ -150,32 +141,32 @@ var fluid_1_5 = fluid_1_5 || {};
fluid.defaults("fluid.uiOptions.lineSpacer", {
gradeNames: ["fluid.uiOptions.settingsPanel", "autoInit"],
model: {
value: 1
value: 1,
min: 1,
max: 2
},
min: 1,
max: 2,
sliderOptions: {
orientation: "horizontal",
step: 0.1
},
selectors: {
lineSpacing: ".flc-uiOptions-line-spacing"
},
produceTree: "fluid.uiOptions.lineSpacer.produceTree",
protoTree: {
lineSpacing: {
decorators: {
type: "fluid",
func: "fluid.uiOptions.textfieldSlider"
}
}
},
resources: {
template: {
url: "../html/UIOptionsTemplate-lineSpacer.html"
}
}
});

fluid.uiOptions.lineSpacer.produceTree = function (that) {
var tree = {
lineSpacing: fluid.uiOptions.createSliderNode(that, "value", "fluid.textfieldSlider")
};
return tree;
};

/***********************
* UI Options Contrast *
***********************/
Expand Down
Expand Up @@ -23,8 +23,8 @@
<script type="text/javascript" src="../../../../framework/renderer/js/fluidParser.js"></script>
<script type="text/javascript" src="../../../../framework/renderer/js/fluidRenderer.js"></script>
<script type="text/javascript" src="../../../../framework/renderer/js/RendererUtilities.js"></script>
<script type="text/javascript" src="../../../../components/uiOptions/js/SettingsPanels.js"></script>
<script type="text/javascript" src="../../../../components/uiOptions/js/TextfieldSlider.js"></script>
<script type="text/javascript" src="../../../../components/uiOptions/js/SettingsPanels.js"></script>

<!-- These are the jqUnit test js files -->
<script type="text/javascript" src="../../../lib/qunit/js/qunit.js"></script>
Expand Down
130 changes: 108 additions & 22 deletions src/webapp/tests/component-tests/uiOptions/js/UIOptionsTests.js
Expand Up @@ -111,6 +111,14 @@ https://github.com/fluid-project/infusion/raw/master/Infusion-LICENSE.txt
theme: "cw",
lineSpacing: 1
};

var maxTextSize = {
textSize: "2.0"
};

var minTextSize = {
textSize: "1.0"
};

var testUIOptions = function (testFn, uio) {
uio = uio || fluid.uiOptionsTests;
Expand Down Expand Up @@ -505,14 +513,112 @@ https://github.com/fluid-project/infusion/raw/master/Infusion-LICENSE.txt
jqUnit.assertTrue("Check that tableOfContents sub-component is present", uiOptions.uiEnhancer.options.components.tableOfContents);
jqUnit.assertTrue("Check that store sub-component is present", uiOptions.uiEnhancer.options.components.settingsStore);
};

var checkNonDefaultUIOComponents = function (uiOptionsLoader, uiOptions) {
jqUnit.assertTrue("Check that uiEnhancer is present", uiOptions.uiEnhancer);
jqUnit.assertTrue("Check that textSizer sub-component is present", uiOptions.textSizer);
jqUnit.assertFalse("Check that lineSpacer sub-component is not present", uiOptions.lineSpacer);
jqUnit.assertFalse("Check that textFont sub-component is not present", uiOptions.textFont);
jqUnit.assertFalse("Check that contrast sub-component is not present", uiOptions.contrast);
jqUnit.assertFalse("Check that layoutControls sub-component is not present", uiOptions.layoutControls);
jqUnit.assertFalse("Check that linkControls sub-component is not present", uiOptions.linksControls);
jqUnit.assertTrue("Check that preview sub-component is present", uiOptions.options.components.preview);
jqUnit.assertTrue("Check that store sub-component is present", uiOptions.options.components.settingsStore);
jqUnit.assertTrue("Check that tableOfContents sub-component is present", uiOptions.uiEnhancer.options.components.tableOfContents);
jqUnit.assertTrue("Check that store sub-component is present", uiOptions.uiEnhancer.options.components.settingsStore);
};

var checkModelSelections = function (message, expectedSelections, actualSelections) {
jqUnit.assertEquals(message + ": Text font correctly updated", expectedSelections.textFont, actualSelections.textFont);
jqUnit.assertEquals(message + ": Theme correctly updated", expectedSelections.theme, actualSelections.theme);
jqUnit.assertEquals(message + ": Text size correctly updated", expectedSelections.textSize, actualSelections.textSize);
jqUnit.assertEquals(message + ": Line spacing correctly updated", expectedSelections.lineSpacing, actualSelections.lineSpacing);
};


var checkSaveCancel = function (uiOptions, saveModel, cancelModel) {
var saveButton = uiOptions.locate("save");
var cancelButton = uiOptions.locate("cancel");
var resetButton = uiOptions.locate("reset");

applierRequestChanges(uiOptions, saveModel);
checkModelSelections("After apply saveModel", saveModel, uiOptions.model.selections);
saveButton.click();
checkModelSelections("After clicking save", saveModel, uiOptions.settingsStore.fetch());
applierRequestChanges(uiOptions, cancelModel);
cancelButton.click();
checkModelSelections("After applying cancelModel and clicking cancel", saveModel,
uiOptions.settingsStore.fetch());
resetButton.click();
checkModelSelections("After clicking reset", uiOptions.defaultModel, uiOptions.model.selections);
cancelButton.click();
checkModelSelections("After clicking cancel", saveModel, uiOptions.settingsStore.fetch());

// apply the reset settings to make the test result page more readable
resetButton.click();
saveButton.click();
};

jqUnit.asyncTest("Non-default UIOptions Integration tests", function () {
fluid.staticEnvironment.uiOptionsTestsIntegration = fluid.typeTag("fluid.uiOptions.testsNonDefaultIntegration");

fluid.demands("fluid.uiOptions", ["fluid.uiOptions.testsNonDefaultIntegration", "fluid.uiOptions.tests", "fluid.uiOptionsTests"], {
funcName: "fluid.uiOptions",
options: {
selectors: {
textSizer: ".flc-uiOptions-text-sizer"
},
components: {
textSizer: {
type: "fluid.uiOptions.textSizer",
container: "{uiOptions}.dom.textSizer",
createOnEvent: "onUIOptionsMarkupReady",
options: {
sourceApplier: "{uiOptions}.applier",
rules: {
"selections.textSize": "value"
},
listeners: {
"{uiOptions}.events.onUIOptionsRefresh": "{that}.refreshView"
},
resources: {
template: "{templateLoader}.resources.textSizer"
}
}
},
uiEnhancer: {
type: "fluid.uiEnhancer",
container: "body",
priority: "first",
options: {
components: {
textSize: {
type: "fluid.uiOptions.actionAnts.textSizerEnactor",
container: "{uiEnhancer}.container",
options: {
fontSizeMap: "{uiEnhancer}.options.fontSizeMap",
sourceApplier: "{uiEnhancer}.applier",
rules: {
"textSize": "value"
}
}
}
}
}
},
settingsStore: "{uiEnhancer}.settingsStore"
},
autoSave: false
}
});

testUIOptions(function (uiOptionsLoader, uiOptions) {
checkNonDefaultUIOComponents(uiOptionsLoader, uiOptions);
checkSaveCancel(uiOptions, maxTextSize, minTextSize);
delete fluid.staticEnvironment.testsNonDefaultIntegration;
jqUnit.start();
});
});

jqUnit.asyncTest("UIOptions Integration tests", function () {
fluid.staticEnvironment.uiOptionsTestsIntegration = fluid.typeTag("fluid.uiOptions.testsIntegration");

Expand Down Expand Up @@ -541,27 +647,7 @@ https://github.com/fluid-project/infusion/raw/master/Infusion-LICENSE.txt

testUIOptions(function (uiOptionsLoader, uiOptions) {
checkUIOComponents(uiOptionsLoader, uiOptions);

var saveButton = uiOptions.locate("save");
var cancelButton = uiOptions.locate("cancel");
var resetButton = uiOptions.locate("reset");

applierRequestChanges(uiOptions, bwSkin);
checkModelSelections("After apply bwSkin", bwSkin, uiOptions.model.selections);
saveButton.click();
checkModelSelections("After clicking save", bwSkin, uiOptions.settingsStore.fetch());
applierRequestChanges(uiOptions, bwSkin2);
cancelButton.click();
checkModelSelections("After applying bwSkin2 and clicking cancel", bwSkin, uiOptions.settingsStore.fetch());
resetButton.click();
checkModelSelections("After clicking reset", uiOptions.defaultModel, uiOptions.model.selections);
cancelButton.click();
checkModelSelections("After clicking cancel", bwSkin, uiOptions.settingsStore.fetch());

// apply the reset settings to make the test result page more readable
resetButton.click();
saveButton.click();

checkSaveCancel(uiOptions, bwSkin, bwSkin2);
delete fluid.staticEnvironment.uiOptionsTestsIntegration;
jqUnit.start();
});
Expand Down

0 comments on commit 80eda2c

Please sign in to comment.