Search in sources :

Example 1 with ConfigDefinition

use of org.apmem.tools.layouts.logic.ConfigDefinition in project android-flowlayout by ApmeM.

the class LineDefinitionTests method CanFit_TakesMarginIntoAccount.

@Test
public void CanFit_TakesMarginIntoAccount() {
    ViewDefinition view1 = CreateView(12, 34);
    ViewDefinition view2 = CreateView(56, 78);
    view1.setMargins(8, 1, 1, 1);
    view2.setMargins(8, 1, 1, 1);
    ConfigDefinition config = new ConfigDefinition();
    config.setMaxWidth(100);
    LineDefinition def = new LineDefinition(config);
    def.addView(view1);
    def.addView(view2);
    boolean canFit = def.canFit(view1);
    Assert.assertFalse(canFit);
}
Also used : ViewDefinition(org.apmem.tools.layouts.logic.ViewDefinition) LineDefinition(org.apmem.tools.layouts.logic.LineDefinition) ConfigDefinition(org.apmem.tools.layouts.logic.ConfigDefinition) Test(org.junit.Test)

Example 2 with ConfigDefinition

use of org.apmem.tools.layouts.logic.ConfigDefinition in project android-flowlayout by ApmeM.

the class CommonLogicTests method GravityApplyUseAllAvailableSpaceHorizontally.

@Test
public void GravityApplyUseAllAvailableSpaceHorizontally() {
    ConfigDefinition config = new ConfigDefinition();
    config.setMaxWidth(30);
    config.setMaxHeight(20);
    config.setGravity(Gravity.FILL);
    ArrayList<LineDefinition> lines = new ArrayList<>();
    ArrayList<ViewDefinition> views = new ArrayList<>();
    for (int i = 0; i < 4; i++) {
        ViewDefinition view = new ViewDefinition(config, null);
        view.setWidth(10);
        view.setHeight(10);
        views.add(view);
    }
    CommonLogic.fillLines(views, lines, config);
    CommonLogic.calculateLinesAndChildPosition(lines);
    CommonLogic.applyGravityToLines(lines, 30, 20, config);
    Assert.assertEquals(2, lines.size());
    Assert.assertEquals(10, lines.get(0).getViews().get(0).getWidth());
    Assert.assertEquals(10, lines.get(0).getViews().get(1).getWidth());
    Assert.assertEquals(10, lines.get(0).getViews().get(2).getWidth());
}
Also used : LineDefinition(org.apmem.tools.layouts.logic.LineDefinition) ViewDefinition(org.apmem.tools.layouts.logic.ViewDefinition) ConfigDefinition(org.apmem.tools.layouts.logic.ConfigDefinition) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 3 with ConfigDefinition

use of org.apmem.tools.layouts.logic.ConfigDefinition in project android-flowlayout by ApmeM.

the class CommonLogicTests method MaxLinesSetLinesCountEqualToMaxLines.

@Test
public void MaxLinesSetLinesCountEqualToMaxLines() {
    ConfigDefinition config = new ConfigDefinition();
    config.setMaxWidth(20);
    config.setMaxLines(2);
    ArrayList<LineDefinition> lines = new ArrayList<>();
    ArrayList<ViewDefinition> views = new ArrayList<>();
    for (int i = 0; i < 9; i++) {
        ViewDefinition view = new ViewDefinition(config, null);
        view.setWidth(10);
        view.setHeight(10);
        views.add(view);
    }
    CommonLogic.fillLines(views, lines, config);
    Assert.assertEquals(2, lines.size());
    Assert.assertEquals(2, lines.get(0).getViews().size());
    Assert.assertEquals(2, lines.get(1).getViews().size());
}
Also used : LineDefinition(org.apmem.tools.layouts.logic.LineDefinition) ViewDefinition(org.apmem.tools.layouts.logic.ViewDefinition) ConfigDefinition(org.apmem.tools.layouts.logic.ConfigDefinition) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 4 with ConfigDefinition

use of org.apmem.tools.layouts.logic.ConfigDefinition in project android-flowlayout by ApmeM.

the class LineDefinitionTests method CreateView.

private ViewDefinition CreateView(int length, int thickness) {
    ViewDefinition view = new ViewDefinition(new ConfigDefinition(), null);
    view.setLength(length);
    view.setThickness(thickness);
    return view;
}
Also used : ViewDefinition(org.apmem.tools.layouts.logic.ViewDefinition) ConfigDefinition(org.apmem.tools.layouts.logic.ConfigDefinition)

Example 5 with ConfigDefinition

use of org.apmem.tools.layouts.logic.ConfigDefinition in project android-flowlayout by ApmeM.

the class LineDefinitionTests method AddView_IncreaseLineLengthForChildLength.

@Test
public void AddView_IncreaseLineLengthForChildLength() {
    ViewDefinition view1 = CreateView(12, 34);
    ViewDefinition view2 = CreateView(56, 78);
    ConfigDefinition config = new ConfigDefinition();
    config.setMaxWidth(100);
    LineDefinition def = new LineDefinition(config);
    def.addView(view1);
    def.addView(view2);
    Assert.assertEquals(68, def.getLineLength());
}
Also used : ViewDefinition(org.apmem.tools.layouts.logic.ViewDefinition) LineDefinition(org.apmem.tools.layouts.logic.LineDefinition) ConfigDefinition(org.apmem.tools.layouts.logic.ConfigDefinition) Test(org.junit.Test)

Aggregations

ConfigDefinition (org.apmem.tools.layouts.logic.ConfigDefinition)14 ViewDefinition (org.apmem.tools.layouts.logic.ViewDefinition)14 LineDefinition (org.apmem.tools.layouts.logic.LineDefinition)13 Test (org.junit.Test)13 ArrayList (java.util.ArrayList)6