Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6612541

api/javax_swing/text/LabelView/index.html#getXXX[LabelView0004] fails since JDK 7 b20

XMLWordPrintable

    • b20
    • 7
    • b68
    • generic
    • generic
    • Verified

      JCK: JCK-runtime-6b b07
      J2SE: FAIL - 7 b20 PASS 7 b19 6u4 b03
      Platform[s]: FAIL - All
      switch/Mode: FAIL - default

      Test api/javax_swing/text/LabelView/index.html#getXXX[LabelView0004] fails since JDK 7. the problem is getBreakWeight starts to return View.BadBreakWeight.

      Steps to reproduce:

      run the following code:



      import java.awt.*;
      import javax.swing.*;
      import java.io.PrintWriter;
      import javax.swing.*;
      import javax.swing.text.*;


      public class Test {

          /* standalone interface */
          public static void main(String argv[]) {

              System.out.println(" === public int getBreakWeight(int axis, float pos, float len) === ");
              Element element = new StubElement("StubElement");
              LabelView c = new LabelView(element);
              int axis = View.X_AXIS;
              float pref = c.getPreferredSpan(axis); // To update metrics parameters.
              int pos = 0;
              int len = 2;
              int weight = c.getBreakWeight(axis, pos, len);

              if (!(weight == View.BadBreakWeight)) {
                  System.out.println(" Should return " + View.BadBreakWeight);
                  System.out.println(" but has returned " + weight);
                  System.out.println("public int getBreakWeight(int axis, float pos, float len) Test Failed");
              }
              pos = 23;
              len = 48;
              weight = c.getBreakWeight(axis, pos, len);

              if (weight == View.BadBreakWeight) {
                  System.out.println(" Should return value more then " + View.BadBreakWeight);
                  System.out.println(" but has returned " + weight);
                  System.out.println("public int getBreakWeight(int axis, float pos, float len) Test Failed");
              }
              System.out.println("OKAY");
          }
      }



      class StubElement implements Element {
          Document document = new DefaultStyledDocument();
          String context;
          public SimpleAttributeSet attr;

          public StubElement(String context) {
              this.context = context;
              attr = new SimpleAttributeSet();
              document = new DefaultStyledDocument();
              try {
                  document.insertString(0, context, new SimpleAttributeSet());
              } catch (BadLocationException e) {}
          }

          public Document getDocument() {
              return document;
          }

          public Element getParentElement() {
              return null;
          }

          public String getName() {
              return "StubElement";
          }

          public AttributeSet getAttributes() {
              return attr;
          }

          public int getStartOffset() {
              return 0;
          }

          public int getEndOffset() {
              return document.getLength();
          }

          public int getElementIndex(int offset) {
              return 0;
          }

          public int getElementCount() {
              return 1;
          }

          public Element getElement(int index) {
              return this;
          }

          public boolean isLeaf() {
              return true;
          }

          /**
           * Return the difference between getStartOffset() and
           * getEndOffset().
           */
          public int getLineLimit() {
              return getEndOffset() - getStartOffset();
          }
      }

            gsm Sergey Groznyh (Inactive)
            pastepan Pavel Stepanov (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: