diff options
author | Benjamin Jones <bjones@galois.com> | 2012-10-04 11:44:01 -0700 |
---|---|---|
committer | Benjamin Jones <bjones@galois.com> | 2012-10-04 11:44:01 -0700 |
commit | 0c9948b4d26a7341e1ea62290293fa28454d0185 (patch) | |
tree | bcd97e3666a8c5392085b5a04ae61b3d599c44ec /exampleData/ruleSets | |
parent | 39e5b2b67f3e041c6d86f434480441965f00a04e (diff) |
Added color, font, and image rulesets. Other minor cleanups.
Diffstat (limited to 'exampleData/ruleSets')
-rw-r--r-- | exampleData/ruleSets/alwaysErrThreeTimes.json | 4 | ||||
-rw-r--r-- | exampleData/ruleSets/colorRules.json | 74 | ||||
-rw-r--r-- | exampleData/ruleSets/fontRules.json | 38 | ||||
-rw-r--r-- | exampleData/ruleSets/imageRules.json | 10 | ||||
-rw-r--r-- | exampleData/ruleSets/template.json | 41 | ||||
-rw-r--r-- | exampleData/ruleSets/trivialReport.json | 2 |
6 files changed, 124 insertions, 45 deletions
diff --git a/exampleData/ruleSets/alwaysErrThreeTimes.json b/exampleData/ruleSets/alwaysErrThreeTimes.json index f0301ab..9060f5d 100644 --- a/exampleData/ruleSets/alwaysErrThreeTimes.json +++ b/exampleData/ruleSets/alwaysErrThreeTimes.json @@ -1,5 +1,5 @@ { "name": "always errors" -, "description": "A trivila rule set for experimentation." +, "description": "A trivial rule set for experimentation." , "rules": [ { "id":13 , "name": "Reports three times" , "description": "Test guideline that reports three errors" @@ -20,4 +20,4 @@ } } ] -}
\ No newline at end of file +} diff --git a/exampleData/ruleSets/colorRules.json b/exampleData/ruleSets/colorRules.json index 5dfb7ca..c2862e4 100644 --- a/exampleData/ruleSets/colorRules.json +++ b/exampleData/ruleSets/colorRules.json @@ -1,8 +1,16 @@ +/* colorRules.json + * Author: Benjamin Jones <bjones@galois.com> + * + * Simple rules for checking that the colors of specific elements are in a specific set. + * Test using exampleData/basic/testColorRules.html + */ + { 'name': "Colors are in a specified set" , 'description': "All background and foreground colors used on a page should be in a specificed set" , 'rules': [ - { 'image-appears': "Foregrounds" - , 'description': "Foreground colors are in a specified set" + { 'name': "Foregrounds" + , 'description': "Foreground colors should be in the set:"+ + "'#0, #FFFFFF, #3D3D3D, #B4B4B4, #4E4E4E, #C2C2C2, #F7F7F7" , 'rule': function() { //---------------------------------------------- var allowableColors = { '#0': 1, '#FFFFFF': 1, '#3D3D3D': 1, @@ -11,15 +19,17 @@ fiveui.query(':visible').each( function(i, elt) { var color = $(elt).css('color'); - // console.log('color: ' + color + ' --> ' + fiveui.colorToHex(color)); - if (!(fiveui.colorToHex(color) in allowableColors)) { - report('Disallowed FOREground color appears'); + if (!(fiveui.color.color.colorToHex(color) in allowableColors)) { + report('Disallowed FOREground color ' + + fiveui.color.colorToHex(color) + + ' appears', $(elt)); } }); } //--------------------------------------------------------- },//============================================================== - { 'image-appears': "Backgrounds" - , 'description': "Backgrounds colors are in a specified set" + { 'name': "Backgrounds" + , 'description': "Backgrounds colors are in the set:" + + "#000000, #FFFFFF, #3D3D3D, #B4B4B4, #4E4E4E, #C2C2C2" , 'rule': function() { //---------------------------------------------- var allowableColors = { '#0': 1, '#FFFFFF': 1, @@ -28,23 +38,59 @@ fiveui.query(':visible').each( function(i, elt) { var color = $(elt).css('background-color'); - if (!(fiveui.colorToHex(color) in allowableColors)) { - report('Disallowed BACKground color appears'); + if (!(fiveui.color.colorToHex(color) in allowableColors)) { + report('Disallowed BACKground color ' + + fiveui.color.colorToHex(color) + + ' appears', $(elt)); } }); } //--------------------------------------------------------- },//============================================================== - { 'image-appears': "Content Area Color" - , 'description': "Content Area Color is #F7" + { 'name': "Content Area Color" + , 'description': "Content Area Color should be #F7" , 'rule': //---------- function() { var allowableColors = { '#F7F7F7': 1 }; - fiveui.query("div[id='content'").each( + fiveui.query("#content").each( function(i, elt) { var color = $(elt).css('color'); - if (!(fiveui.colorToHex(color) in allowableColors)) { - report('Invalid color in content area'); + if (!(fiveui.color.colorToHex(color) in allowableColors)) { + report('Invalid color '+fiveui.color.colorToHex(color) + + ' in content area', $(elt)); + } + }); + } //--------------------------------------------------------- + },//============================================================== + { 'name': "Left Nav Color" + , 'description': "Left Nav Color should be #C2 (#4E if active)" + , 'rule': + //---------- + function() { + var allowableColors = { '#C2C2C2': 1 }; + fiveui.query("#nav-left").each( + function(i, elt) { + var color = $(elt).css('color'); + // if active then .. 4E + if (!(fiveui.color.colorToHex(color) in allowableColors)) { + report('Invalid color '+fiveui.color.colorToHex(color) + + ' in left nav area', $(elt)); + } + }); + } //--------------------------------------------------------- + },//============================================================== + { 'name': "Header Color" + , 'description': "Header Color should be #3D" + , 'rule': + //---------- + function() { + var allowableColors = { '#3D3D3D': 1 }; + fiveui.query(":header").each( + function(i, elt) { + var color = $(elt).css('color'); + if (!(fiveui.color.colorToHex(color) in allowableColors)) { + report('Invalid color '+fiveui.color.colorToHex(color) + + ' in header', $(elt)); } }); } //--------------------------------------------------------- diff --git a/exampleData/ruleSets/fontRules.json b/exampleData/ruleSets/fontRules.json new file mode 100644 index 0000000..a07fab4 --- /dev/null +++ b/exampleData/ruleSets/fontRules.json @@ -0,0 +1,38 @@ +/* + * fontRules.json + * Author: Benjamin Jones <bjones@galois.com> + * + * Simple rules for checking that fonts (family/weight/size) of specific elements are + * in a specific set. + * + * Test using exampleData/basic/testFontRules.html + */ + +{ 'name': "Fonts (family/size/style) are in a specified set" +, 'description': "All fonts used on a page should be in a specificed set" +, 'rules': [ + { 'name': "Font set" + , 'description': "Font (family/weight/size) should be in the set ..." + , 'rule': + function() { //---------------------------------------------- + var allowableFonts = { + "Verdana": { "bold": ["25", "22", "12", "10"] + , "normal": ["12", "11", "10"] } } + fiveui.query('body *').each( + function(i, elt) { + var family = $(elt).css('font-family'); + var sizeTxt = $(elt).css('font-size'); + var size = /([1-9][0-9])/.exec(sizeTxt)[0]; + var weight = $(elt).css('font-weight'); + console.log('Found font: ' + family + size + weight); + if (!(family in allowableFonts) || + !(weight in allowableFonts[family]) || + !(size in allowableFonts[family][weight])) { + report('Disallowed font: ' + + family + size + weight, $(elt)); + } + }); + } //--------------------------------------------------------- + }//============================================================== + ] +} diff --git a/exampleData/ruleSets/imageRules.json b/exampleData/ruleSets/imageRules.json index 0ba8f77..924d750 100644 --- a/exampleData/ruleSets/imageRules.json +++ b/exampleData/ruleSets/imageRules.json @@ -1,3 +1,13 @@ +/* + * imageRules.json + * Author: Benjamin Jones <bjones@galois.com> + * + * Simple rules for checking that specific images appear on a page and that specific images + * link back to specific URLs. + * + * Test using exampleData/basic/testImageRules.html + */ + { 'name': "Image exists and links back to URL" , 'description': "A specific image file should be included in the page and link back to a specific URL" , 'rules': [ diff --git a/exampleData/ruleSets/template.json b/exampleData/ruleSets/template.json index 6a5a886..3d098c7 100644 --- a/exampleData/ruleSets/template.json +++ b/exampleData/ruleSets/template.json @@ -1,32 +1,17 @@ -{ 'name': "Colors are in a specified set" -, 'description': "All background and foreground colors used on a page should be in a specificed set" +/* + * template.json + * Author: Benjamin Jones <bjones@galois.com> + * + * Template ruleset containing one empty rule. + */ + +{ 'name': "NAME" +, 'description': "DESCRIPTION" , 'rules': [ - { 'image-appears': "Foregrounds" - , 'description': "Foreground colors are in a specified set" + { 'name': "RULE NAME" + , 'description': "RULE DESC" , 'rule': - function() { - var allowableColors = [ '#000000', '#FFFFFF', '#3D3D3D', '#B4B4B4', '#4E4E4E', '#C2C2C2' ]; - fiveui.query('').each( - function(i, elt) { - if ($(elt).css('color') in allowableColors) { - $(elt).addClass('reportColor'); - } - }); - } + function() {} // Function that checks the rule }, - { 'image-appears': "Backgrounds" - , 'description': "Backgrounds colors are in a specified set" - , 'rule': - function() { - var allowableColors = [ 'transparent', '#000000', '#FFFFFF', '#3D3D3D', '#B4B4B4', '#4E4E4E', '#C2C2C2' ]; - fiveui.query('').each( - function(i, elt) { - if ($(elt).css('color') in allowableColors) { - $(elt).addClass('reportBackColor'); - } - }); - } - } - - ] + ] } diff --git a/exampleData/ruleSets/trivialReport.json b/exampleData/ruleSets/trivialReport.json index bd264d1..f14d3f6 100644 --- a/exampleData/ruleSets/trivialReport.json +++ b/exampleData/ruleSets/trivialReport.json @@ -4,4 +4,4 @@ 'description': 'An empty test rule', 'rule': function() { report('test error'); } } ] -}
\ No newline at end of file +} |