Skip to content
Snippets Groups Projects
Commit a7b6b67b authored by Lukas Marik's avatar Lukas Marik
Browse files

create test encyclopedia, click plus/minus button, prepare method on click menu item

parent f83b3439
Branches
Tags
No related merge requests found
......@@ -52,6 +52,12 @@ import cz.nic.tablexia.util.ui.button.StandardTablexiaButton;
import cz.nic.tablexia.util.ui.button.TablexiaButton;
public class EncyclopediaScreen extends AbstractTablexiaScreen<Void> {
public static final String CONTAINER = "contrainer";
public static final String MENU = "menu";
public static final String SCROLL_MENU_PANE = "scroll menu pane";
public static final String SCROLL_CONTENT_PANE = "scroll content pane";
public static final String BUTTON_PLUS_NAME = "button plus";
public static final String BUTTON_MINUS_NAME = "button minus";
private static final String SOURCE_FILE_EXTENSION = ".json";
private static final float FONT_BUTTON_WIDTH = 70;
......@@ -137,6 +143,7 @@ public class EncyclopediaScreen extends AbstractTablexiaScreen<Void> {
container.setBackground(new TextureRegionDrawable(getColorTextureRegion(BACKGROUND_COLOR)));
getStage().addActor(container);
container.setFillParent(true);
container.setName(CONTAINER);
prepareContentLayout();
prepareRightMenu();
......@@ -191,6 +198,7 @@ public class EncyclopediaScreen extends AbstractTablexiaScreen<Void> {
contentScrollPane = new ResizableScrollPane(content);
contentScrollPane.setScrollingDisabled(true, false);
contentScrollPane.setSize(CONTENT_RELATIVE_WIDTH * getViewportWidth(), getViewportHeight());
contentScrollPane.setName(SCROLL_CONTENT_PANE);
contentStack.add(contentScrollPane).padTop(CONTENT_PAD_TOP);
container.add(contentStack);
......@@ -206,11 +214,15 @@ public class EncyclopediaScreen extends AbstractTablexiaScreen<Void> {
disposeMusic();
}
});
menuScrollPane = new ResizableScrollPane(menu);
menuScrollPane.setScrollingDisabled(true, false);
menuScrollPane.setSize(rightPanelWidth, getViewportHeight() * MENU_RELATIVE_HEIGHT);
menuScrollPane.setName(SCROLL_MENU_PANE);
buttonsPanel = new ResizableWidgetGroup();
buttonsPanel.setSize(rightPanelWidth, getViewportHeight() * (1 - MENU_RELATIVE_HEIGHT));
......@@ -226,6 +238,7 @@ public class EncyclopediaScreen extends AbstractTablexiaScreen<Void> {
container.add(rightPanelStack);
menu.setName(MENU);
menu.updateSize(rightPanelWidth);
}
......@@ -243,6 +256,9 @@ public class EncyclopediaScreen extends AbstractTablexiaScreen<Void> {
btnFontMinus.setUserObject(BUTTON_MINUS);
btnFontPlus.setUserObject(BUTTON_PLUS);
btnFontPlus.setName(BUTTON_PLUS_NAME);
btnFontMinus.setName(BUTTON_MINUS_NAME);
buttonsPanel.addActor(btnFontPlus);
buttonsPanel.addActor(btnFontMinus);
}
......@@ -258,6 +274,7 @@ public class EncyclopediaScreen extends AbstractTablexiaScreen<Void> {
c.addToCell(content, this, (CONTENT_RELATIVE_WIDTH * getViewportWidth()) - CONTENT_PAD_LEFT);
content.row();
}
}
public void playMusic(String music, final PlaybackStateButton musicButton) {
......
......@@ -130,4 +130,8 @@ public class MenuWidget extends VerticalGroup {
public int getSelectedItemIndex() {
return selectedItemIndex;
}
public int getMenuItemCount(){
return menuItems.size();
}
}
package cz.nic.tablexia.testing;
import com.badlogic.gdx.Input;
import com.badlogic.gdx.scenes.scene2d.Actor;
import com.badlogic.gdx.scenes.scene2d.Stage;
import com.badlogic.gdx.scenes.scene2d.ui.ScrollPane;
import com.badlogic.gdx.scenes.scene2d.ui.Table;
import cz.nic.tablexia.Tablexia;
import cz.nic.tablexia.TablexiaSettings;
import cz.nic.tablexia.menu.AbstractMenu;
import cz.nic.tablexia.menu.main.MainMenuDefinition;
import cz.nic.tablexia.screen.encyclopedia.EncyclopediaScreen;
import cz.nic.tablexia.screen.encyclopedia.menu.MenuWidget;
import cz.nic.tablexia.screen.halloffame.HallOfFameScreen;
import cz.nic.tablexia.shared.model.User;
/**
* Created by lmarik on 9.2.17.
*/
public class TestEncyclopedia extends AbstractTestScenario {
private int testSteps = 1;
public TestEncyclopedia(Tablexia tablexia) {
super(tablexia);
}
@Override
protected void runTestScenario() {
User user = createUser();
logIn(user);
waitForEvent(incGetSteps() + ". Wait for event opened ready", AbstractMenu.SCENARIO_STEP_READY_MENU);
clickAt(incGetSteps() +". Click at open/close menu button", AbstractMenu.OPEN_CLOSE_MENU_BUTTON_NAME);
waitForEvent(incGetSteps() +". Wait for event opened menu", AbstractMenu.SCENARIO_STEP_OPENED_MENU);
clickMainMenuButton(incGetSteps() +". Click at Hall of Fame button in the menu", MainMenuDefinition.ENCYCLOPEDIA);
waitForScreen(incGetSteps() + ". Wait for screen HallOfFameScreen", EncyclopediaScreen.class);
clickAt(incGetSteps() +". Click plus font button", EncyclopediaScreen.BUTTON_PLUS_NAME);
takeScreenShotBlocking();
clickAt(incGetSteps() +". Click minus font button", EncyclopediaScreen.BUTTON_MINUS_NAME);
//clickOnMenuItem(incGetSteps() + ". Click on menu item. Index menu item " + 3,EncyclopediaScreen.MENU,3);
// waitForScreen(incGetSteps() + ". Wait for screen HallOfFameScreen", EncyclopediaScreen.class);
}
private void clickOnMenuItem(String infoMessage,String actorName,int indexItem){
logInfo(infoMessage);
final int firtsFingerPointer = 0;
MenuWidget menu = (MenuWidget) findActorByName(actorName);
ScrollPane scrollMenu = (ScrollPane) findActorByName(EncyclopediaScreen.SCROLL_MENU_PANE);
Table container = (Table) findActorByName(EncyclopediaScreen.CONTAINER);
if(menu != null && scrollMenu != null){
float itemWidth = menu.getWidth();
float itemHeight = menu.getHeight()/menu.getMenuItemCount();
float clickX = container.getWidth() - itemWidth/2;
float clickY = container.getHeight() - (indexItem)*itemHeight; //- scrollMenu.getY());
logInfo("Container Height: " + container.getHeight() + " Item Height " + itemHeight + " SCROLL Y:= " + scrollMenu.getY());
//TODO pada OpenGl not found content pri touch Upu
touchDown(clickX,clickY,firtsFingerPointer, Input.Buttons.LEFT, container.getStage());
touchUp(clickX,clickY,firtsFingerPointer, Input.Buttons.LEFT, container.getStage());
logOK();
}else{
logError("Some menu Actors not found! " + actorName + " - " + (menu != null) +
EncyclopediaScreen.SCROLL_MENU_PANE + " - " + (scrollMenu !=null) );
stopTheTest();
}
}
private int incGetSteps(){
testSteps++;
return testSteps;
}
}
......@@ -50,6 +50,7 @@ public class TestRunner {
listOfTests.add(TestScenarioHallOfFameCrimeSceneTrophies.class);
listOfTests.add(TestScenarioHallOfFameRunesTrophies.class);
listOfTests.add(TestScenarioHeapOfTrophies.class);
listOfTests.add(TestEncyclopedia.class);
}
public TestRunner(){
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment