Skip to content

Commit

Permalink
4938-rippleTestsRefactoringFix
Browse files Browse the repository at this point in the history
  • Loading branch information
Maiia_Afanaseva authored and Maiia_Afanaseva committed Aug 15, 2023
1 parent ecb285a commit 152c042
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 71 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public void unboundedTest() {
@Test(description = "Test checks ripple feature: centered")
public void centeredTest() {
rippleContainer.center();
rippleContainer.ripple();
rippleContainer.is().centered();
}

Expand Down Expand Up @@ -102,18 +103,6 @@ public void rippleRadiusAndColorTest() {
rippleContainer.is().radius(is(expectedRadius)).and().color(is(expectedColor.toLowerCase()));
}

@Test(description = "Test checks ripple is centered has correct radius and value")
public void rippleRadiusAndColorAndCenteredTest() {
rippleContainer.center();
String expectedColor = "rgba(28, 140, 16, 0.1)";
int expectedRadius = 150;
rippleContainer.setColor(expectedColor);
rippleContainer.setRadius(expectedRadius);
rippleContainer.is().radius(is(expectedRadius))
.and().color(is(expectedColor.toLowerCase()))
.and().centered();
}

@Test(description = "Test checks ripple center coordinates and radius value")
public void mouseClickByCoordinatesAndRadiusTest() {
int x = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,66 +24,25 @@ public void displayedTest() {
assertTrue(rippleContainer.isDisplayed());
}

@Test(description = "Unit test checks that ripple does not appear if 'disabled' option chosen")
public void disabledTest() {
rippleContainer.disable();
rippleContainer.ripple();
assertTrue(rippleContainer.isNotActive());
rippleContainer.enable();
rippleContainer.ripple();
assertTrue(rippleContainer.isActive());
}

@Test(description = "Unit test checks element's feature 'unbounded'")
public void unboundedTest() {
rippleContainer.unbound();
rippleContainer.ripple();
assertTrue(rippleContainer.isUnbounded());
}

@Test(description = "Unit test checks element's feature 'centered'")
public void centeredTest() {
rippleContainer.center();
rippleContainer.ripple();
assertTrue(rippleContainer.isCentered());
}

@Test(description = "Unit test checks that 'ripple' activates if element is clicked")
public void rippleActionTest() {
rippleContainer.ripple();
assertTrue(rippleContainer.isActive());
}

@Test(description = "Unit test checks that 'ripple effect' has correct value of radius")
public void rippleRadiusTest() {
int expectedRadius = 195;
rippleContainer.setRadius(expectedRadius);
assertEquals(rippleContainer.radius(), expectedRadius, "The radius has an incorrect value");
rippleContainer.is().active();
}

@Test(description = "Unit test checks that 'ripple' element has correct value of color")
public void rippleColorTest() {
String expectedColor = "AqUaMaRiNe";
rippleContainer.setColor(expectedColor);
assertEquals(rippleContainer.color(), expectedColor.toLowerCase(), "The color has an incorrect value");
}

@Test(description = "Unit test checks that 'ripple' element has correct value of color rgba")
public void rippleRgbaColorTest() {
refresh();
String expectedColor = "rgba(200, 100, 50, 0.5)";
rippleContainer.setColor(expectedColor);
assertEquals(rippleContainer.color(), expectedColor, "The color has an incorrect value");
}

@Test(description = "Unit test checks that when 'centered' with any click in container 'ripple' is centered")
public void mouseClickCenteredTest() {
refresh();
rippleContainer.center();
int x = 179;
int y = 243;
rippleContainer.ripple(x, y);
assertTrue(rippleContainer.isCentered());
rippleContainer.is().centered();
}

@Test(description = "Unit test checks that when 'not-centered' - 'ripple' center is click coordinates")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,92 +12,93 @@ public class RippleAssert extends UIAssert<RippleAssert, Ripple> {
@JDIAction("Assert that '{name}' displayed")
@Override
public RippleAssert displayed() {
jdiAssert(element().isDisplayed(), Matchers.is(true));
jdiAssert(element().isDisplayed(), Matchers.is(true), "Ripple container is not displayed");
return this;
}

@JDIAction("Assert that '{name}' disabled")
@Override
public RippleAssert disabled() {
jdiAssert(element().isDisabled(), Matchers.is(true));
jdiAssert(element().isDisabled(), Matchers.is(true), "Ripple is not disabled");
return this;
}

@JDIAction("Assert that '{name}' unbounded")
public RippleAssert unbounded() {
jdiAssert(element().isUnbounded(), Matchers.is(true));
jdiAssert(element().isUnbounded(), Matchers.is(true), "Ripple is bounded");
return this;
}

@JDIAction("Assert that '{name}' centered")
public RippleAssert centered() {
jdiAssert(element().isCentered(), Matchers.is(true));
jdiAssert(element().isCentered(), Matchers.is(true), "Ripple is not centered");
return this;
}

@JDIAction("Assert that '{name}' is active")
public RippleAssert active() {
jdiAssert(element().isActive(), Matchers.is(true));
jdiAssert(element().isActive(), Matchers.is(true), "Ripple is not active");
return this;
}

@JDIAction("Assert that '{name}' is active")
@JDIAction("Assert that '{name}' is not active")
public RippleAssert notActive() {
jdiAssert(element().isActive(), Matchers.is(false));
jdiAssert(element().isActive(), Matchers.is(false), "Ripple is active");
return this;
}

@JDIAction("Assert that '{name}' ripple center by coordinates x:'{0}'; y:'{1}'")
public RippleAssert rippleCenter(final int x, final int y) {
jdiAssert(element().isRippleCenter(x, y), Matchers.is(true));
jdiAssert(element().isRippleCenter(x, y), Matchers.is(true),
String.format("Ripple center coordinates are not equal %d, %d", x, y));
return this;
}

@JDIAction("Assert that '{name}' radius '{0}'")
public RippleAssert radius(final Matcher<Integer> condition) {
jdiAssert(element().radius(), condition);
jdiAssert(element().radius(), condition, "Ripple radius is not equal " + condition);
return this;
}

@JDIAction("Assert that '{name}' ripple radius: '{0}'")
public RippleAssert radius(final int radius) {
jdiAssert(element().isRadius(radius), Matchers.is(true));
jdiAssert(element().isRadius(radius), Matchers.is(true), "Ripple radius in not equal " + radius);
return this;
}

@JDIAction("Assert that '{name}' color '{0}'")
public RippleAssert color(final Matcher<String> condition) {
jdiAssert(element().color(), condition);
jdiAssert(element().color(), condition, "Ripple color is not equal " + condition);
return this;
}

@JDIAction("Assert that '{name}' ripple color: '{0}'")
public RippleAssert color(final String color) {
jdiAssert(element().isColor(color), Matchers.is(true));
jdiAssert(element().isColor(color), Matchers.is(true), "Ripple color is not equal " + color);
return this;
}

@JDIAction("Assert that '{name}' input color is correct")
public RippleAssert correctColor() {
jdiAssert(element().isCorrectColor(), Matchers.is(true));
jdiAssert(element().isCorrectColor(), Matchers.is(true), "Ripple does not have color attributes");
return this;
}

@JDIAction("Assert that '{name}' input color is incorrect")
public RippleAssert incorrectColor() {
jdiAssert(element().isCorrectColor(), Matchers.is(false));
jdiAssert(element().isCorrectColor(), Matchers.is(false), "Ripple has color attributes");
return this;
}

@JDIAction("Assert that '{name}' input radius is correct")
public RippleAssert correctRadius() {
jdiAssert(element().isCorrectRadius(), Matchers.is(true));
jdiAssert(element().isCorrectRadius(), Matchers.is(true), "Ripple does not have radius attributes");
return this;
}

@JDIAction("Assert that '{name}' input radius is incorrect")
public RippleAssert incorrectRadius() {
jdiAssert(element().isCorrectRadius(), Matchers.is(false));
jdiAssert(element().isCorrectRadius(), Matchers.is(false), "Ripple has color attributes");
return this;
}
}

0 comments on commit 152c042

Please sign in to comment.