public void testDeleteScript() { UiTestUtils.addNewBrick(solo, R.string.brick_broadcast_receive); solo.sleep(500); UiTestUtils.dragFloatingBrick(solo, 0); solo.sleep(500); int numberOfScripts = ProjectManager.getInstance().getCurrentSprite().getNumberOfScripts(); assertEquals("Incorrect number of scripts in list", 2, numberOfScripts); solo.waitForText(solo.getString(R.string.brick_when_started)); solo.clickOnText(solo.getString(R.string.brick_when_started)); solo.waitForText(solo.getString(R.string.brick_context_dialog_delete_script)); solo.clickOnText(solo.getString(R.string.brick_context_dialog_delete_script)); solo.waitForText(solo.getString(R.string.yes)); solo.clickOnButton(solo.getString(R.string.yes)); solo.waitForText(solo.getString(R.string.brick_broadcast_receive)); numberOfScripts = ProjectManager.getInstance().getCurrentSprite().getNumberOfScripts(); assertEquals("Incorrect number of scripts in scriptList", 1, numberOfScripts); assertEquals( "Incorrect number of elements in listView", 3, UiTestUtils.getScriptListView(solo).getChildCount()); solo.waitForText(solo.getString(R.string.brick_broadcast_receive)); solo.clickOnText(solo.getString(R.string.brick_broadcast_receive)); solo.waitForText(solo.getString(R.string.brick_context_dialog_delete_script)); solo.clickOnText(solo.getString(R.string.brick_context_dialog_delete_script)); solo.waitForText(solo.getString(R.string.yes)); solo.clickOnButton(solo.getString(R.string.yes)); solo.waitForText(solo.getString(R.string.brick_when_started)); numberOfScripts = ProjectManager.getInstance().getCurrentSprite().getNumberOfScripts(); assertEquals("Incorrect number of scripts in list", 0, numberOfScripts); assertEquals( "Incorrect number of elements in listView", 0, UiTestUtils.getScriptListView(solo).getChildCount()); UiTestUtils.addNewBrick(solo, R.string.brick_hide); solo.sleep(500); UiTestUtils.dragFloatingBrickDownwards(solo); solo.sleep(500); solo.waitForText(solo.getString(R.string.brick_when_started)); numberOfScripts = ProjectManager.getInstance().getCurrentSprite().getNumberOfScripts(); assertEquals("Incorrect number of scripts in scriptList", 1, numberOfScripts); assertEquals( "Incorrect number of elements in listView", 2, UiTestUtils.getScriptListView(solo).getChildCount()); }
@Smoke public void testIfBrick() { ListView view = UiTestUtils.getScriptListView(solo); ListView dragDropListView = UiTestUtils.getScriptListView(solo); BrickAdapter adapter = (BrickAdapter) view.getAdapter(); int childrenCount = adapter.getChildCountFromLastGroup(); UiTestUtils.testBrickWithFormulaEditor(solo, 0, 1, 5, "ifCondition", ifBrick); assertEquals( "Incorrect number of bricks.", 6, dragDropListView.getChildCount()); // don't forget the footer assertEquals("Incorrect number of bricks.", 0, childrenCount); ArrayList<Brick> projectBrickList = project.getSpriteList().get(0).getScript(0).getBrickList(); assertEquals("Incorrect number of bricks.", 4, projectBrickList.size()); assertTrue("Wrong Brick instance.", projectBrickList.get(0) instanceof IfLogicBeginBrick); assertNotNull( "TextView does not exist", solo.getText(getActivity().getString(R.string.brick_if_begin))); }
public void testNXTMotorActionBrick() { ListView dragDropListView = UiTestUtils.getScriptListView(solo); BrickAdapter adapter = (BrickAdapter) dragDropListView.getAdapter(); int childrenCount = adapter.getChildCountFromLastGroup(); int groupCount = adapter.getScriptCount(); assertEquals("Incorrect number of bricks.", 2, dragDropListView.getChildCount()); assertEquals("Incorrect number of bricks.", 1, childrenCount); ArrayList<Brick> projectBrickList = project.getSpriteList().get(0).getScript(0).getBrickList(); assertEquals("Incorrect number of bricks.", 1, projectBrickList.size()); assertEquals( "Wrong Brick instance.", projectBrickList.get(0), adapter.getChild(groupCount - 1, 0)); assertNotNull( "TextView does not exist.", solo.getText(solo.getString(R.string.nxt_brick_motor_move))); assertNotNull( "TextView does not exist.", solo.getText(solo.getString(R.string.nxt_motor_speed_to))); UiTestUtils.testBrickWithFormulaEditor( solo, ProjectManager.getInstance().getCurrentSprite(), R.id.motor_action_speed_edit_text, SET_SPEED, Brick.BrickField.LEGO_NXT_SPEED, motorBrick); String[] motors = getActivity().getResources().getStringArray(R.array.nxt_motor_chooser); assertTrue("Spinner items list too short!", motors.length == 4); int legoSpinnerIndex = 0; Spinner currentSpinner = solo.getCurrentViews(Spinner.class).get(legoSpinnerIndex); solo.pressSpinnerItem(legoSpinnerIndex, 0); solo.waitForActivity(ScriptActivity.class.getSimpleName()); assertEquals("Wrong item in spinner!", motors[0], currentSpinner.getSelectedItem()); solo.pressSpinnerItem(legoSpinnerIndex, 1); solo.waitForActivity(ScriptActivity.class.getSimpleName()); assertEquals("Wrong item in spinner!", motors[1], currentSpinner.getSelectedItem()); solo.pressSpinnerItem(legoSpinnerIndex, 1); solo.waitForActivity(ScriptActivity.class.getSimpleName()); assertEquals("Wrong item in spinner!", motors[2], currentSpinner.getSelectedItem()); solo.pressSpinnerItem(legoSpinnerIndex, 1); solo.waitForActivity(ScriptActivity.class.getSimpleName()); assertEquals("Wrong item in spinner!", motors[3], currentSpinner.getSelectedItem()); }
public void testHideBrick() { ListView dragDropListView = UiTestUtils.getScriptListView(solo); BrickAdapter adapter = (BrickAdapter) dragDropListView.getAdapter(); int childrenCount = adapter.getChildCountFromLastGroup(); int groupCount = adapter.getScriptCount(); assertEquals("Incorrect number of bricks.", 2, dragDropListView.getChildCount()); assertEquals("Incorrect number of bricks.", 1, childrenCount); ArrayList<Brick> projectBrickList = project.getSpriteList().get(0).getScript(0).getBrickList(); assertEquals("Incorrect number of bricks.", 1, projectBrickList.size()); assertEquals( "Wrong Brick instance.", projectBrickList.get(0), adapter.getChild(groupCount - 1, 0)); assertNotNull("TextView does not exist.", solo.getText(solo.getString(R.string.brick_hide))); }
public void testChangeYByNBrick() { ListView dragDropListView = UiTestUtils.getScriptListView(solo); BrickAdapter adapter = (BrickAdapter) dragDropListView.getAdapter(); int childrenCount = adapter.getChildCountFromLastGroup(); int groupCount = adapter.getScriptCount(); assertEquals("Incorrect number of bricks.", 2, dragDropListView.getChildCount()); assertEquals("Incorrect number of bricks.", 1, childrenCount); ArrayList<Brick> projectBrickList = project.getSpriteList().get(0).getScript(0).getBrickList(); assertEquals("Incorrect number of bricks.", 1, projectBrickList.size()); assertEquals( "Wrong Brick instance.", projectBrickList.get(0), adapter.getChild(groupCount - 1, 0)); assertNotNull( "TextView does not exist.", solo.getText(solo.getString(R.string.brick_change_y_by))); UiTestUtils.testBrickWithFormulaEditor(solo, 0, 1, Y_TO_CHANGE, "yMovement", changeYByNBrick); }