diff options
Diffstat (limited to 'devtools/client/performance/test/unit/test_profiler-categories.js')
-rw-r--r-- | devtools/client/performance/test/unit/test_profiler-categories.js | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/devtools/client/performance/test/unit/test_profiler-categories.js b/devtools/client/performance/test/unit/test_profiler-categories.js new file mode 100644 index 000000000..7ba288167 --- /dev/null +++ b/devtools/client/performance/test/unit/test_profiler-categories.js @@ -0,0 +1,38 @@ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ +"use strict"; + +/** + * Tests if the profiler categories are mapped correctly. + */ + +function run_test() { + run_next_test(); +} + +add_task(function () { + let { CATEGORIES, CATEGORY_MAPPINGS } = require("devtools/client/performance/modules/categories"); + let { L10N } = require("devtools/client/performance/modules/global"); + let count = CATEGORIES.length; + + ok(count, + "Should have a non-empty list of categories available."); + + ok(CATEGORIES.some(e => e.color), + "All categories have an associated color."); + + ok(CATEGORIES.every(e => e.label), + "All categories have an associated label."); + + ok(CATEGORIES.every(e => e.label === L10N.getStr("category." + e.abbrev)), + "All categories have a correctly localized label."); + + ok(Object.keys(CATEGORY_MAPPINGS).every(e => (Number(e) >= 9000 && Number(e) <= 9999) || + Number.isInteger(Math.log2(e))), + "All bitmask mappings keys are powers of 2, or between 9000-9999 for special " + + "categories."); + + ok(Object.keys(CATEGORY_MAPPINGS).every(e => CATEGORIES.indexOf(CATEGORY_MAPPINGS[e]) + !== -1), + "All bitmask mappings point to a category."); +}); |