aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohannes Dahlström <johannesd@vaadin.com>2015-06-09 16:46:56 +0300
committerVaadin Code Review <review@vaadin.com>2015-06-09 15:47:18 +0000
commit4837e3838e22bf8699ac88a967ca6d5063df39d0 (patch)
treea61d255de3f34745bef621a17caad6c0e0b23d67
parent5b965ff478ef22a83a476eeebdf70554a776bae6 (diff)
downloadvaadin-framework-4837e3838e22bf8699ac88a967ca6d5063df39d0.tar.gz
vaadin-framework-4837e3838e22bf8699ac88a967ca6d5063df39d0.zip
Properly display Slider values greater than Integer.MAX_VALUE (#18192)
Change-Id: Ic83d067b69eff8b34acf7945e84fb645160d8ae2
-rw-r--r--client/src/com/vaadin/client/ui/VSlider.java9
-rw-r--r--client/src/com/vaadin/client/ui/slider/SliderConnector.java1
-rw-r--r--uitest/src/com/vaadin/tests/components/slider/SliderFeedback.java43
-rw-r--r--uitest/src/com/vaadin/tests/components/slider/SliderFeedbackTest.java44
4 files changed, 89 insertions, 8 deletions
diff --git a/client/src/com/vaadin/client/ui/VSlider.java b/client/src/com/vaadin/client/ui/VSlider.java
index 651880502c..952c387539 100644
--- a/client/src/com/vaadin/client/ui/VSlider.java
+++ b/client/src/com/vaadin/client/ui/VSlider.java
@@ -160,11 +160,7 @@ public class VSlider extends SimpleFocusablePanel implements Field,
}
public void setFeedbackValue(double value) {
- String currentValue = "" + value;
- if (resolution == 0) {
- currentValue = "" + new Double(value).intValue();
- }
- feedback.setText(currentValue);
+ feedback.setText(String.valueOf(value));
}
private void updateFeedbackPosition() {
@@ -218,8 +214,7 @@ public class VSlider extends SimpleFocusablePanel implements Field,
public void execute() {
final Element p = getElement();
if (p.getPropertyInt(domProperty) > (MIN_SIZE + 5)
- || propertyNotNullOrEmpty(styleAttribute,
- p)) {
+ || propertyNotNullOrEmpty(styleAttribute, p)) {
if (isVertical()) {
setHeight();
} else {
diff --git a/client/src/com/vaadin/client/ui/slider/SliderConnector.java b/client/src/com/vaadin/client/ui/slider/SliderConnector.java
index 1e5120ce76..8c3c0254d3 100644
--- a/client/src/com/vaadin/client/ui/slider/SliderConnector.java
+++ b/client/src/com/vaadin/client/ui/slider/SliderConnector.java
@@ -89,7 +89,6 @@ public class SliderConnector extends AbstractFieldConnector implements
getWidget().setMaxValue(getState().maxValue);
getWidget().setResolution(getState().resolution);
getWidget().setValue(getState().value, false);
- getWidget().setFeedbackValue(getState().value);
getWidget().buildBase();
getWidget().setTabIndex(getState().tabIndex);
diff --git a/uitest/src/com/vaadin/tests/components/slider/SliderFeedback.java b/uitest/src/com/vaadin/tests/components/slider/SliderFeedback.java
new file mode 100644
index 0000000000..f28dfc8f79
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/slider/SliderFeedback.java
@@ -0,0 +1,43 @@
+/*
+ * Copyright 2000-2014 Vaadin Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package com.vaadin.tests.components.slider;
+
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.tests.components.AbstractTestUI;
+import com.vaadin.ui.Slider;
+
+public class SliderFeedback extends AbstractTestUI {
+
+ @Override
+ protected void setup(VaadinRequest request) {
+ Slider slider = new Slider(0, 5);
+ slider.setWidth(800, Unit.PIXELS);
+ slider.setMin(0);
+ slider.setMax(1e12);
+ addComponent(slider);
+ }
+
+ @Override
+ protected String getTestDescription() {
+ return "Slider feedback popup should display the correct value";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 18192;
+ }
+
+}
diff --git a/uitest/src/com/vaadin/tests/components/slider/SliderFeedbackTest.java b/uitest/src/com/vaadin/tests/components/slider/SliderFeedbackTest.java
new file mode 100644
index 0000000000..86bc351480
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/slider/SliderFeedbackTest.java
@@ -0,0 +1,44 @@
+/*
+ * Copyright 2000-2014 Vaadin Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package com.vaadin.tests.components.slider;
+
+import org.junit.Test;
+import org.openqa.selenium.By;
+import org.openqa.selenium.WebElement;
+import org.openqa.selenium.interactions.Actions;
+
+import com.vaadin.tests.tb3.MultiBrowserTest;
+
+public class SliderFeedbackTest extends MultiBrowserTest {
+
+ @Test
+ public void testValueGreaterThanMaxInt() {
+ openTestURL();
+
+ WebElement handle = findElement(By.className("v-slider-handle"));
+ new Actions(driver).dragAndDropBy(handle, 400, 0).perform();
+ testBench().waitForVaadin();
+
+ double value = Double.valueOf(findElement(
+ By.className("v-slider-feedback")).getText());
+
+ // Allow for some tolerance due to, you guessed it, IE8
+ assertLessThan("Unexpected feedback value {1} < {0}", 505000000000.0,
+ value);
+ assertGreater("Unexpected feedback value {1} > {0}", 510000000000.0,
+ value);
+ }
+}