]> source.dussan.org Git - vaadin-framework.git/commitdiff
Properly display Slider values greater than Integer.MAX_VALUE (#18192)
authorJohannes Dahlström <johannesd@vaadin.com>
Tue, 9 Jun 2015 13:46:56 +0000 (16:46 +0300)
committerVaadin Code Review <review@vaadin.com>
Tue, 9 Jun 2015 15:47:18 +0000 (15:47 +0000)
Change-Id: Ic83d067b69eff8b34acf7945e84fb645160d8ae2

client/src/com/vaadin/client/ui/VSlider.java
client/src/com/vaadin/client/ui/slider/SliderConnector.java
uitest/src/com/vaadin/tests/components/slider/SliderFeedback.java [new file with mode: 0644]
uitest/src/com/vaadin/tests/components/slider/SliderFeedbackTest.java [new file with mode: 0644]

index 651880502c658a94bfabbc7a2dff352924ef8148..952c387539f4bb0cb79b134ce4591b49dc8bf379 100644 (file)
@@ -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 {
index 1e5120ce76962c92ad55ae2a85c469a16ecb6a63..8c3c0254d35a6ca91bc3a27bc2acd3ebebe96cd8 100644 (file)
@@ -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 (file)
index 0000000..f28dfc8
--- /dev/null
@@ -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 (file)
index 0000000..86bc351
--- /dev/null
@@ -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);
+    }
+}