profiler editor: filetype-driven fields and content view
- Show Size only for transparent/ber_tlv; Record length/count only for linear_fixed/cyclic; hide all size/record fields for df (unknown shows all) - Hide the Contents section entirely for df (existence-only check) - Changing file type clears now-inapplicable fields and resets content (keeps mode) when its kind switches between record and transparent - profilerSetContent defaults content kind from the selected file type Add profilerFileFields + profilerContentKindForFileType helpers + tests. SW cache v45.
This commit is contained in:
@@ -21,7 +21,7 @@ function extractFunc(src, name) {
|
||||
return src.slice(m.index, i + 1);
|
||||
}
|
||||
|
||||
const FNS = ['profilerNormHex', 'profilerMatch', 'profilerMatchMin', 'profilerMaskPrefix4', 'profilerValidateProfile'];
|
||||
const FNS = ['profilerNormHex', 'profilerMatch', 'profilerMatchMin', 'profilerMaskPrefix4', 'profilerFileFields', 'profilerContentKindForFileType', 'profilerValidateProfile'];
|
||||
let code = '';
|
||||
for (const f of FNS) code += extractFunc(html, f) + '\n';
|
||||
eval(code);
|
||||
@@ -74,6 +74,24 @@ test('profilerMaskPrefix4 keeps first 4 bytes and masks the rest', () => {
|
||||
assert.strictEqual(profilerMaskPrefix4('1234'), '1234');
|
||||
});
|
||||
|
||||
test('profilerFileFields maps file type to applicable fields', () => {
|
||||
assert.deepStrictEqual(profilerFileFields('transparent'), { size: true, records: false });
|
||||
assert.deepStrictEqual(profilerFileFields('ber_tlv'), { size: true, records: false });
|
||||
assert.deepStrictEqual(profilerFileFields('linear_fixed'), { size: false, records: true });
|
||||
assert.deepStrictEqual(profilerFileFields('cyclic'), { size: false, records: true });
|
||||
assert.deepStrictEqual(profilerFileFields('df'), { size: false, records: false });
|
||||
assert.deepStrictEqual(profilerFileFields(null), { size: true, records: true });
|
||||
assert.deepStrictEqual(profilerFileFields(''), { size: true, records: true });
|
||||
});
|
||||
|
||||
test('profilerContentKindForFileType', () => {
|
||||
assert.strictEqual(profilerContentKindForFileType('linear_fixed'), 'record');
|
||||
assert.strictEqual(profilerContentKindForFileType('cyclic'), 'record');
|
||||
assert.strictEqual(profilerContentKindForFileType('transparent'), 'transparent');
|
||||
assert.strictEqual(profilerContentKindForFileType('ber_tlv'), 'transparent');
|
||||
assert.strictEqual(profilerContentKindForFileType('df'), 'transparent');
|
||||
});
|
||||
|
||||
test('profile validation', () => {
|
||||
assert.strictEqual(profilerValidateProfile(null), 'Not an object');
|
||||
assert.strictEqual(profilerValidateProfile({ name: 'x' }), 'Missing rules array');
|
||||
|
||||
Reference in New Issue
Block a user