lmw
2023-03-11 4df5bb59e5fe9f9d140e5610f7772dd8a05a28d4
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
package com.beloo.widget.chipslayoutmanager.gravity;
 
import android.graphics.Rect;
 
 
import com.beloo.widget.chipslayoutmanager.ParamsType;
 
import org.junit.Assume;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
 
import static com.beloo.widget.chipslayoutmanager.ParamsType.INVALID;
import static com.beloo.widget.chipslayoutmanager.ParamsType.VALID;
import static org.junit.Assert.assertEquals;
 
@RunWith(Parameterized.class)
abstract class GravityModifierTest {
 
    private IGravityModifier gravityModifier;
 
    @Before
    public void setUp() {
        gravityModifier = getGravityModifier();
    }
 
    protected abstract IGravityModifier getGravityModifier();
 
    private ParamsType paramsType;
    private int minTop;
    private int maxBottom;
    private Rect testRect;
    private Rect expectedResultRect;
 
    GravityModifierTest(ParamsType paramsType, int minTop, int maxBottom, Rect testRect, Rect expectedResultRect) {
        this.paramsType = paramsType;
        this.minTop = minTop;
        this.maxBottom = maxBottom;
        this.testRect = testRect;
        this.expectedResultRect = expectedResultRect;
    }
 
    @Test(expected = IllegalArgumentException.class)
    public void invalidDataForModifierShouldThrowIllegalArgumentException() {
        Assume.assumeTrue(paramsType.equals(INVALID));
        gravityModifier.modifyChildRect(minTop, maxBottom, testRect);
    }
 
    @Test
    public void modifierShouldAlignInputRect() {
        Assume.assumeTrue(paramsType.equals(VALID));
        Rect resultRect = gravityModifier.modifyChildRect(minTop, maxBottom, testRect);
        assertEquals(expectedResultRect, resultRect);
    }
 
}