mirror of
https://github.com/google/blockly.git
synced 2026-01-10 02:17:09 +01:00
committed by
Sam El-Husseini
parent
6516363469
commit
1c3db256fa
@@ -467,6 +467,104 @@ Blockly.defineBlocksWithJsonArray([ // BEGIN JSON EXTRACT
|
||||
"output": "Note",
|
||||
"tooltip": "A midi note."
|
||||
},
|
||||
{
|
||||
"type": "test_angles_protractor",
|
||||
"message0": "protractor %1",
|
||||
"args0": [
|
||||
{
|
||||
"type": "field_angle",
|
||||
"name": "FIELDNAME",
|
||||
"angle": 0,
|
||||
"mode": "protractor"
|
||||
}
|
||||
],
|
||||
"style": "math_blocks",
|
||||
"tooltip": "test tooltip"
|
||||
},
|
||||
{
|
||||
"type": "test_angles_compass",
|
||||
"message0": "compass %1",
|
||||
"args0": [
|
||||
{
|
||||
"type": "field_angle",
|
||||
"name": "FIELDNAME",
|
||||
"angle": 0,
|
||||
"mode": "compass"
|
||||
}
|
||||
],
|
||||
"style": "math_blocks",
|
||||
"tooltip": "test tooltip"
|
||||
},
|
||||
{
|
||||
"type": "test_angles_clockwise",
|
||||
"message0": "clockwise %1",
|
||||
"args0": [
|
||||
{
|
||||
"type": "field_angle",
|
||||
"name": "FIELDNAME",
|
||||
"angle": 0,
|
||||
"clockwise": true
|
||||
}
|
||||
],
|
||||
"style": "math_blocks",
|
||||
"tooltip": "test tooltip"
|
||||
},
|
||||
{
|
||||
"type": "test_angles_offset",
|
||||
"message0": "offset 90 %1",
|
||||
"args0": [
|
||||
{
|
||||
"type": "field_angle",
|
||||
"name": "FIELDNAME",
|
||||
"angle": 0,
|
||||
"offset": 90
|
||||
}
|
||||
],
|
||||
"style": "math_blocks",
|
||||
"tooltip": "test tooltip"
|
||||
},
|
||||
{
|
||||
"type": "test_angles_wrap",
|
||||
"message0": "wrap %1",
|
||||
"args0": [
|
||||
{
|
||||
"type": "field_angle",
|
||||
"name": "FIELDNAME",
|
||||
"angle": 0,
|
||||
"wrap": 180
|
||||
}
|
||||
],
|
||||
"style": "math_blocks",
|
||||
"tooltip": "test tooltip"
|
||||
},
|
||||
{
|
||||
"type": "test_angles_round_30",
|
||||
"message0": "round 30 %1",
|
||||
"args0": [
|
||||
{
|
||||
"type": "field_angle",
|
||||
"name": "FIELDNAME",
|
||||
"angle": 0,
|
||||
"round": 30
|
||||
}
|
||||
],
|
||||
"style": "math_blocks",
|
||||
"tooltip": "test tooltip"
|
||||
},
|
||||
{
|
||||
"type": "test_angles_round_0",
|
||||
"message0": "no round %1",
|
||||
"args0": [
|
||||
{
|
||||
"type": "field_angle",
|
||||
"name": "FIELDNAME",
|
||||
"angle": 0,
|
||||
"round": 0
|
||||
}
|
||||
],
|
||||
"style": "math_blocks",
|
||||
"tooltip": "test tooltip"
|
||||
},
|
||||
{
|
||||
"type": "test_images_datauri",
|
||||
"message0": "Image data: URI %1",
|
||||
|
||||
@@ -262,4 +262,134 @@ suite('Angle Fields', function() {
|
||||
});
|
||||
});
|
||||
});
|
||||
suite('Customizations', function() {
|
||||
suite('Clockwise', function() {
|
||||
test('JS Configuration', function() {
|
||||
var field = new Blockly.FieldAngle(0, null, {
|
||||
clockwise: true
|
||||
});
|
||||
chai.assert.isTrue(field.clockwise_);
|
||||
});
|
||||
test('JSON Definition', function() {
|
||||
var field = Blockly.FieldAngle.fromJson({
|
||||
value: 0,
|
||||
clockwise: true
|
||||
});
|
||||
chai.assert.isTrue(field.clockwise_);
|
||||
});
|
||||
test('Constant', function() {
|
||||
// Note: Generally constants should be set at compile time, not
|
||||
// runtime (since they are constants) but for testing purposes we
|
||||
// can do this.
|
||||
Blockly.FieldAngle.CLOCKWISE = true;
|
||||
var field = new Blockly.FieldAngle();
|
||||
chai.assert.isTrue(field.clockwise_);
|
||||
});
|
||||
});
|
||||
suite('Offset', function() {
|
||||
test('JS Configuration', function() {
|
||||
var field = new Blockly.FieldAngle(0, null, {
|
||||
offset: 90
|
||||
});
|
||||
chai.assert.equal(field.offset_, 90);
|
||||
});
|
||||
test('JSON Definition', function() {
|
||||
var field = Blockly.FieldAngle.fromJson({
|
||||
value: 0,
|
||||
offset: 90
|
||||
});
|
||||
chai.assert.equal(field.offset_, 90);
|
||||
});
|
||||
test('Constant', function() {
|
||||
// Note: Generally constants should be set at compile time, not
|
||||
// runtime (since they are constants) but for testing purposes we
|
||||
// can do this.
|
||||
Blockly.FieldAngle.OFFSET = 90;
|
||||
var field = new Blockly.FieldAngle();
|
||||
chai.assert.equal(field.offset_, 90);
|
||||
});
|
||||
});
|
||||
suite('Wrap', function() {
|
||||
test('JS Configuration', function() {
|
||||
var field = new Blockly.FieldAngle(0, null, {
|
||||
wrap: 180
|
||||
});
|
||||
chai.assert.equal(field.wrap_, 180);
|
||||
});
|
||||
test('JSON Definition', function() {
|
||||
var field = Blockly.FieldAngle.fromJson({
|
||||
value: 0,
|
||||
wrap: 180
|
||||
});
|
||||
chai.assert.equal(field.wrap_, 180);
|
||||
});
|
||||
test('Constant', function() {
|
||||
// Note: Generally constants should be set at compile time, not
|
||||
// runtime (since they are constants) but for testing purposes we
|
||||
// can do this.
|
||||
Blockly.FieldAngle.WRAP = 180;
|
||||
var field = new Blockly.FieldAngle();
|
||||
chai.assert.equal(field.wrap_, 180);
|
||||
});
|
||||
});
|
||||
suite('Round', function() {
|
||||
test('JS Configuration', function() {
|
||||
var field = new Blockly.FieldAngle(0, null, {
|
||||
round: 30
|
||||
});
|
||||
chai.assert.equal(field.round_, 30);
|
||||
});
|
||||
test('JSON Definition', function() {
|
||||
var field = Blockly.FieldAngle.fromJson({
|
||||
value: 0,
|
||||
round: 30
|
||||
});
|
||||
chai.assert.equal(field.round_, 30);
|
||||
});
|
||||
test('Constant', function() {
|
||||
// Note: Generally constants should be set at compile time, not
|
||||
// runtime (since they are constants) but for testing purposes we
|
||||
// can do this.
|
||||
Blockly.FieldAngle.ROUND = 30;
|
||||
var field = new Blockly.FieldAngle();
|
||||
chai.assert.equal(field.round_, 30);
|
||||
});
|
||||
});
|
||||
suite('Mode', function() {
|
||||
suite('Compass', function() {
|
||||
test('JS Configuration', function() {
|
||||
var field = new Blockly.FieldAngle(0, null, {
|
||||
mode: 'compass'
|
||||
});
|
||||
chai.assert.equal(field.offset_, 90);
|
||||
chai.assert.isTrue(field.clockwise_);
|
||||
});
|
||||
test('JS Configuration', function() {
|
||||
var field = Blockly.FieldAngle.fromJson({
|
||||
value: 0,
|
||||
mode: 'compass'
|
||||
});
|
||||
chai.assert.equal(field.offset_, 90);
|
||||
chai.assert.isTrue(field.clockwise_);
|
||||
});
|
||||
});
|
||||
suite('Protractor', function() {
|
||||
test('JS Configuration', function() {
|
||||
var field = new Blockly.FieldAngle(0, null, {
|
||||
mode: 'protractor'
|
||||
});
|
||||
chai.assert.equal(field.offset_, 0);
|
||||
chai.assert.isFalse(field.clockwise_);
|
||||
});
|
||||
test('JS Configuration', function() {
|
||||
var field = Blockly.FieldAngle.fromJson({
|
||||
value: 0,
|
||||
mode: 'protractor'
|
||||
});
|
||||
chai.assert.equal(field.offset_, 0);
|
||||
chai.assert.isFalse(field.clockwise_);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1464,6 +1464,15 @@ var spaghettiXml = [
|
||||
<field name="NOTE">60</field>
|
||||
</block>
|
||||
</category>
|
||||
<category name="Angles">
|
||||
<block type="test_angles_clockwise"></block>
|
||||
<block type="test_angles_offset"></block>
|
||||
<block type="test_angles_wrap"></block>
|
||||
<block type="test_angles_round_30"></block>
|
||||
<block type="test_angles_round_0"></block>
|
||||
<block type="test_angles_protractor"></block>
|
||||
<block type="test_angles_compass"></block>
|
||||
</category>
|
||||
<category name="Drop-downs">
|
||||
<label text="Dynamic"></label>
|
||||
<block type="test_dropdowns_dynamic"></block>
|
||||
|
||||
Reference in New Issue
Block a user