You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

PageScaleTest.java 2.3KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /*
  2. * Licensed to the Apache Software Foundation (ASF) under one or more
  3. * contributor license agreements. See the NOTICE file distributed with
  4. * this work for additional information regarding copyright ownership.
  5. * The ASF licenses this file to You under the Apache License, Version 2.0
  6. * (the "License"); you may not use this file except in compliance with
  7. * the License. You may obtain a copy of the License at
  8. *
  9. * http://www.apache.org/licenses/LICENSE-2.0
  10. *
  11. * Unless required by applicable law or agreed to in writing, software
  12. * distributed under the License is distributed on an "AS IS" BASIS,
  13. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. * See the License for the specific language governing permissions and
  15. * limitations under the License.
  16. */
  17. /* $Id$ */
  18. package org.apache.fop.render.extensions.prepress;
  19. import java.awt.geom.Point2D;
  20. import junit.framework.TestCase;
  21. /**
  22. * Tests for the fox:scale extension property.
  23. */
  24. public class PageScaleTest extends TestCase {
  25. /**
  26. * Default constructor.
  27. */
  28. public PageScaleTest() {
  29. super();
  30. }
  31. /**
  32. * Creates a test case with the given name.
  33. *
  34. * @param name name for the test case
  35. */
  36. public PageScaleTest(String name) {
  37. super(name);
  38. }
  39. /** 1 value is used for both x and y. */
  40. public void testScale1() {
  41. Point2D res = PageScale.getScale(".5");
  42. assertEquals(0.5, res.getX(), 0.0);
  43. assertEquals(0.5, res.getY(), 0.0);
  44. }
  45. /** Two values, used resp. for x and y. */
  46. public void testScale2() {
  47. Point2D res = PageScale.getScale("1. \t \n 1.2");
  48. assertEquals(1.0, res.getX(), 0.0);
  49. assertEquals(1.2, res.getY(), 0.0);
  50. }
  51. /** Scale must not contain units. */
  52. public void testScaleFail() {
  53. try {
  54. PageScale.getScale("0.5mm 0.5cm");
  55. fail("Expected IllegalArgumentException. Scale shouldn't contain units");
  56. } catch (IllegalArgumentException iae) {
  57. // Good!
  58. }
  59. }
  60. /** @{code null} is returned when scale is unspecified. */
  61. public void testScaleNull() {
  62. Point2D res = PageScale.getScale(null);
  63. assertNull("Result should be null", res);
  64. res = PageScale.getScale("");
  65. assertNull("Result should be null", res);
  66. }
  67. }