Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ public ChangeVariableBrick copyBrickForSprite(Sprite sprite) {
@Override
public ChangeVariableBrick clone() {
ChangeVariableBrick clonedBrick = new ChangeVariableBrick(getFormulaWithBrickField(
BrickField.VARIABLE_CHANGE).clone(), null, inUserBrick);
BrickField.VARIABLE_CHANGE).clone(), userVariable, inUserBrick);
return clonedBrick;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ public SetVariableBrick copyBrickForSprite(Sprite sprite) {
@Override
public SetVariableBrick clone() {
SetVariableBrick clonedBrick = new SetVariableBrick(getFormulaWithBrickField(BrickField.VARIABLE)
.clone(), null);
.clone(), userVariable);
return clonedBrick;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,59 @@ public void testCreateUserVariableInFormulaEditor() {
assertTrue("UserVariable Name not as expected", userVariable.getName().equals(userVariableName));
}

public void testViewInFormulaEditorAfterClone(){

String userVariableName = "testVariable1";
String userVariableNameTwo = "testVariable2";

solo.clickOnView(solo.getView(R.id.brick_change_variable_edit_text));
solo.waitForFragmentByTag(FormulaEditorFragment.FORMULA_EDITOR_FRAGMENT_TAG);
solo.clickOnView(solo.getView(R.id.formula_editor_keyboard_data));
assertTrue("Data Fragment not shown", solo.waitForFragmentByTag(FormulaEditorDataFragment.USER_DATA_TAG));

solo.clickOnView(solo.getView(R.id.button_add));
assertTrue("Add Data Dialog not shown",
solo.waitForText(solo.getString(R.string.formula_editor_data_dialog_title)));
EditText editText = (EditText) solo.getView(R.id.dialog_formula_editor_data_name_edit_text);

solo.enterText(editText, userVariableName);
finishUserVariableCreationSafeButSlow(userVariableName, true);

solo.goBack();
solo.clickOnView(solo.getView(R.id.formula_editor_keyboard_ok));

solo.clickOnText(solo.getString(R.string.brick_change_variable));
solo.clickOnText(solo.getString(R.string.brick_context_dialog_copy_brick));

solo.clickOnText(solo.getString(R.string.brick_change_variable));


solo.clickOnText(userVariableName);

solo.clickOnText(solo.getString(R.string.brick_variable_spinner_create_new_variable));


EditText editTextTwo = (EditText) solo.getView(R.id.dialog_formula_editor_data_name_edit_text);

solo.enterText(editTextTwo, userVariableNameTwo);
solo.clickOnButton(solo.getString(R.string.ok));

solo.clickOnText(solo.getString(R.string.brick_change_variable));
solo.clickOnText(solo.getString(R.string.brick_context_dialog_move_brick));

ArrayList<Integer> yPosition = UiTestUtils.getListItemYPositions(solo, 0);
int addedYPosition = UiTestUtils.getAddedListItemYPosition(solo);
solo.drag(20, 20, addedYPosition, yPosition.get(yPosition.size() - 1) + 20, 20);

solo.clickOnText(solo.getString(R.string.brick_change_variable));
solo.clickOnText(solo.getString(R.string.brick_context_dialog_formula_edit_brick));

assertTrue("Uservariable in view is not right displayed , maybe clone() is broken...",
solo.searchText(userVariableName, true));

solo.sleep(2000);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be unnecessary.

}

private void createProject() {
project = new Project(null, UiTestUtils.DEFAULT_TEST_PROJECT_NAME);
Sprite sprite = new Sprite("cat");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,61 @@ public void testCreateUserVariableInFormulaEditor() {
assertNotNull("UserVariable is null", userVariable);
assertTrue("UserVariable Name not as expected", userVariable.getName().equals(userVariableName));
}


public void testViewInFormulaEditorAfterClone(){
String userVariableName = "testVariable1";
String userVariableNameTwo = "testVariable2";

solo.clickOnView(solo.getView(R.id.brick_set_variable_edit_text));
solo.waitForFragmentByTag(FormulaEditorFragment.FORMULA_EDITOR_FRAGMENT_TAG);
solo.clickOnView(solo.getView(R.id.formula_editor_keyboard_data));
assertTrue("Data Fragment not shown", solo.waitForFragmentByTag(FormulaEditorDataFragment.USER_DATA_TAG));

solo.clickOnView(solo.getView(R.id.button_add));
assertTrue("Add Data Dialog not shown",
solo.waitForText(solo.getString(R.string.formula_editor_data_dialog_title)));
EditText editText = (EditText) solo.getView(R.id.dialog_formula_editor_data_name_edit_text);

solo.enterText(editText, userVariableName);
finishUserVariableCreationSafeButSlow(userVariableName, true);

solo.goBack();
solo.clickOnView(solo.getView(R.id.formula_editor_keyboard_ok));

solo.clickOnView(solo.getView(R.id.button_add));
solo.clickOnText(solo.getString(R.string.category_data));

solo.clickOnText(solo.getString(R.string.brick_set_variable));

solo.clickOnText(solo.getString(R.string.brick_set_variable));


solo.clickOnText(userVariableName);

solo.clickOnText(solo.getString(R.string.brick_variable_spinner_create_new_variable));


EditText editTextTwo = (EditText) solo.getView(R.id.dialog_formula_editor_data_name_edit_text);

solo.enterText(editTextTwo, userVariableNameTwo);
solo.clickOnButton(solo.getString(R.string.ok));

solo.clickOnText(solo.getString(R.string.brick_set_variable));
solo.clickOnText(solo.getString(R.string.brick_context_dialog_move_brick));

ArrayList<Integer> yPosition = UiTestUtils.getListItemYPositions(solo, 0);
int addedYPosition = UiTestUtils.getAddedListItemYPosition(solo);
solo.drag(20, 20, addedYPosition, yPosition.get(yPosition.size() - 1) + 20, 20);

solo.clickOnText(solo.getString(R.string.brick_set_variable));
solo.clickOnText(solo.getString(R.string.brick_context_dialog_formula_edit_brick));

assertTrue("Uservariable in view is not right displayed , maybe clone() is broken...",
solo.searchText(userVariableName,true));

solo.sleep(5000);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove as well

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both tests are necessary because only these two new tests show the bug that was fixed with the bugfix...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment is only about the solo.sleep at the end of the test 😉 which shouldn't be necessary... or is it?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for jenkins no ... for human yes ... :-)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Who cares about humans 🙊
I agree with @robertpainsi to remove the sleeps, the testsuite already takes a lot of time

}

private void createProject() {
project = new Project(null, UiTestUtils.DEFAULT_TEST_PROJECT_NAME);
Sprite sprite = new Sprite("cat");
Expand Down