All tests pass

This commit is contained in:
Rachel Fenichel
2017-12-04 14:29:16 -08:00
parent d1c2401fcf
commit 6bb048d1bb
4 changed files with 10 additions and 22 deletions

View File

@@ -338,12 +338,4 @@ Blockly.Variables.generateVariableFieldXml_ = function(variableModel) {
'" variabletype="' + typeString +
'">' + variableModel.name + '</field>';
return text;
// var element = goog.dom.createDom('field');
// element.setAttribute('name', 'VAR');
// element.setAttribute('variabletype', variableModel.type);
// element.setAttribute('id', variableModel.getId());
// element.textContent = variableModel.name;
// var xmlString = Blockly.Xml.domToText(element);
// return xmlString;
};

View File

@@ -87,7 +87,6 @@ Blockly.Xml.blockToDomWithXY = function(block, opt_noId) {
};
Blockly.Xml.fieldToDomVariable_ = function(field, workspace) {
// Ugh that's not true at all.
var id = field.getValue();
var variable = workspace.getVariableById(id);
if (!variable) {
@@ -420,7 +419,6 @@ Blockly.Xml.domToWorkspace = function(xml, workspace) {
}
Blockly.Field.stopCache();
}
workspace.updateVariableStore(false);
// Re-enable workspace resizing.
if (workspace.setResizesEnabled) {
workspace.setResizesEnabled(true);

View File

@@ -8,7 +8,7 @@
</head>
<body>
<script src="test_utilities.js"></script>
<!-- <script src="connection_db_test.js"></script>
<script src="connection_db_test.js"></script>
<script src="connection_test.js"></script>
<script src="event_test.js"></script>
<script src="extensions_test.js"></script>
@@ -27,7 +27,7 @@
<script src="variable_model_test.js"></script>
<script src="workspace_test.js"></script>
<script src="workspace_undo_redo_test.js"></script>
<script src="widget_div_test.js"></script> -->
<script src="widget_div_test.js"></script>
<script src="xml_test.js"></script>
</body>
</html>

View File

@@ -345,14 +345,14 @@ function test_variablesToDom_oneVariable() {
function test_variablesToDom_twoVariables_oneBlock() {
xmlTest_setUpWithMockBlocks();
workspace.createVariable('name1', 'type1', 'id1');
workspace.createVariable('name1', '', 'id1');
workspace.createVariable('name2', 'type2', 'id2');
var block = new Blockly.Block(workspace, 'field_variable_test_block');
block.inputList[0].fieldRow[0].setValue('name1');
block.inputList[0].fieldRow[0].setValue('id1');
var resultDom = Blockly.Xml.variablesToDom(workspace.getAllVariables());
assertEquals(2, resultDom.children.length);
xmlTest_checkVariableDomValues(resultDom.children[0], 'type1', 'id1',
xmlTest_checkVariableDomValues(resultDom.children[0], '', 'id1',
'name1');
xmlTest_checkVariableDomValues(resultDom.children[1], 'type2', 'id2',
'name2');
@@ -380,14 +380,12 @@ function test_variableFieldXml_caseSensitive() {
}
};
var generatedXml = Blockly.Variables.generateVariableFieldXml_(mockVariableModel);
// The field contains this XML tag as a result of how we're generating this
// XML. This is not desirable, but the goal of this test is to make sure
// we're preserving case-sensitivity.
var xmlns = 'xmlns="http://www.w3.org/1999/xhtml"';
var generatedXml =
Blockly.Variables.generateVariableFieldXml_(mockVariableModel);
var goldenXml =
'<field ' + xmlns + ' name="VAR"' +
'<field name="VAR"' +
' id="' + id + '"' +
' variabletype="' + type + '"' +
' id="' + id + '">' + name + '</field>';
'>' + name + '</field>';
assertEquals(goldenXml, generatedXml);
}