From 3b9da531502290e31a0e99560a08501cc3e0650e Mon Sep 17 00:00:00 2001 From: thc202 Date: Mon, 5 Feb 2018 23:36:10 +0000 Subject: [PATCH] Fix ZestClientLaunch deep copy Change ZestClientLaunch to also copy the capabilities and the headless state. Add test to assert the expected behaviour. --- .../mozilla/zest/core/v1/ZestClientLaunch.java | 7 ++++++- .../zest/test/v1/ZestClientLaunchUnitTest.java | 17 +++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/mozilla/zest/core/v1/ZestClientLaunch.java b/src/main/java/org/mozilla/zest/core/v1/ZestClientLaunch.java index bae8a7c3..09ed5478 100644 --- a/src/main/java/org/mozilla/zest/core/v1/ZestClientLaunch.java +++ b/src/main/java/org/mozilla/zest/core/v1/ZestClientLaunch.java @@ -106,7 +106,12 @@ public void setHeadless(boolean headless) { @Override public ZestStatement deepCopy() { - ZestClientLaunch copy = new ZestClientLaunch(this.getWindowHandle(), this.getBrowserType(), this.getUrl()); + ZestClientLaunch copy = new ZestClientLaunch( + this.getWindowHandle(), + this.getBrowserType(), + this.getUrl(), + this.getCapabilities(), + this.isHeadless()); copy.setEnabled(this.isEnabled()); return copy; } diff --git a/src/test/java/org/mozilla/zest/test/v1/ZestClientLaunchUnitTest.java b/src/test/java/org/mozilla/zest/test/v1/ZestClientLaunchUnitTest.java index 55f7a9bf..d361966c 100644 --- a/src/test/java/org/mozilla/zest/test/v1/ZestClientLaunchUnitTest.java +++ b/src/test/java/org/mozilla/zest/test/v1/ZestClientLaunchUnitTest.java @@ -136,4 +136,21 @@ public void testSerialization() { assertEquals(zcl1.getUrl(), zcl2.getUrl()); assertEquals(zcl1.isHeadless(), zcl2.isHeadless()); } + + @Test + public void shouldDeepCopy() throws Exception { + // Given + ZestClientLaunch original = new ZestClientLaunch("handle", "browser", "url", "capabilities", false); + original.setEnabled(false); + // When + ZestClientLaunch copy = (ZestClientLaunch) original.deepCopy(); + // Then + assertEquals(original.getElementType(), copy.getElementType()); + assertEquals(original.getBrowserType(), copy.getBrowserType()); + assertEquals(original.getWindowHandle(), copy.getWindowHandle()); + assertEquals(original.getUrl(), copy.getUrl()); + assertEquals(original.getCapabilities(), copy.getCapabilities()); + assertEquals(original.isHeadless(), copy.isHeadless()); + assertEquals(original.isEnabled(), copy.isEnabled()); + } }