FileDocCategorySizeDatePackage
TestItemLFImplLDoInternalLayout.javaAPI DocphoneME MR2 API (J2ME)31236Wed May 02 18:00:18 BST 2007javax.microedition.lcdui

TestItemLFImplLDoInternalLayout

public class TestItemLFImplLDoInternalLayout extends TestCase
This test is designed to test Chameleon's ItemLFImpl.lDoInternalLayout() routine only. It does not test label size or content size calculations. It tests label location and content location calculations. Internal layout for all items is handled in ItemLFImpl. lDoInternalLayout() is given label and content sizes and available width, height, it should place label and content in correct place. Here is what to expect: If label and content are empty, both bounds are set to 0. If label is empty, content is given as much space as it needs but not more than available. If content is empty, label is given as much space as it needs but not more than available. If label is a single line label (its height <= label font height) then there is an attempt to fit label, content and 3 pixel padding between them on the same line. Otherwise content is placed under label with 2 pixel horizontal padding in between. Furthermore, if label and content are on the same line than shorter part (label or content) is vertically centered against the taller one (content or label). Then if there is extra space (item can fit in smaller size than it is given) then the space is distributed based on the layout primitives set. ItemLFImpl and Item area abstract in javax.microedition.lcdui. We extend them to test lDoInternalLayout().

Fields Summary
Constructors Summary
Methods Summary
private voidcheckLayout(javax.microedition.lcdui.TestItemLFImplLDoInternalLayout$TestItemLFImpl item, int labelX, int labelY, int contentX, int contetnY)

        item.checkLayout(labelX, labelY, contentX, contetnY);
    
public voidrunTests()


        // no extra space, null label, null content
        declare("test1");
        checkLayout(new TestItemLFImpl(0, 0,  // labelSize
                                       0, 0,  // contentSize
                                       0, 0,  // itemSize
                                       10),   // label font height
                    0, 0,  // checked label location
                    0, 0); // checked content location

        // no extra space, null label, non null content
        declare("test2");
        checkLayout(new TestItemLFImpl(0, 0,      // labelSize
                                       100, 100,  // contentSize
                                       100, 100,  // itemSize
                                       10),   // label font height
                    0, 0,  // checked label location
                    0, 0); // checked content location

        // no extra space, non null label, null content
        declare("test3");
        checkLayout(new TestItemLFImpl(100, 100,  // labelSize
                                       0, 0,      // contentSize
                                       100, 100,  // itemSize
                                       10),   // label font height
                    0, 0,  // checked label location
                    0, 0); // checked content location




        // no extra space, non null label, non null content;
        // label and content are on the same line;
        // label height > content height
        declare("test4");
        checkLayout(new TestItemLFImpl(50, 20,  // labelSize
                                       50, 10,  // contentSize
                                       103, 20, // itemSize
                                       20),     // labelHeight to be single ln 
                    0, 0,  // checked label location
                    53, 5); // checked content location

        // no extra space, non null label, non null content
        // label and content are on the same line
        // label height < content height
        declare("test5");
        checkLayout(new TestItemLFImpl(50, 10,  // labelSize
                                       50, 20,  // contentSize
                                       103, 20, // itemSize
                                       10),     // labelHeight to be single ln 
                    0, 5,  // checked label location
                    53, 0); // checked content location

        // no extra space, non null label, non null content
        // label and content are on different lines (due to width)
        // label width < content width
        declare("test6");
        checkLayout(new TestItemLFImpl(30, 10,  // labelSize
                                       50, 20,  // contentSize
                                       50, 32, // itemSize
                                       10),     // labelHeight to be single ln 
                    0, 0,  // checked label location
                    0, 12); // checked content location

        // no extra space, non null label, non null content
        // label and content are on different lines (due to multiline label)
        // label width < content width
        declare("test7");
        checkLayout(new TestItemLFImpl(30, 20,  // labelSize
                                       50, 30,  // contentSize
                                       50, 52, // itemSize
                                       10),     // labelHeight to be single ln 
                    0, 0,  // checked label location
                    0, 22); // checked content location

        // no extra space, non null label, non null content
        // label and content are on different lines (due to width)
        // label width > content width
        declare("test8");
        checkLayout(new TestItemLFImpl(50, 10,  // labelSize
                                       30, 20,  // contentSize
                                       50, 32, // itemSize
                                       10),     // labelHeight to be single ln 
                    0, 0,  // checked label location
                    0, 12); // checked content location

        // no extra space, non null label, non null content
        // label and content are on different lines (due to mulitline label)
        // label width > content width
        declare("test9");
        checkLayout(new TestItemLFImpl(50, 20,  // labelSize
                                       30, 30,  // contentSize
                                       50, 52, // itemSize
                                       10),     // labelHeight to be single ln 
                    0, 0,  // checked label location
                    0, 22); // checked content location


        // ************ more space HORIZONTALLY  **************************
        // ****************************************************************

        // there IS extra space horizontally, 
        // LAYOUT_CENTER and LAYOUT_RIGHT are NOT set
        // null label, non null content
        declare("test10");
        checkLayout(new TestItemLFImpl(0, 0,    // labelSize
                                       50, 50,  // contentSize
                                       100, 50, // itemSize
                                       10),     // labelHeight to be single ln 
                    0, 0,  // checked label location
                    0, 0); // checked content location
        
        // there IS extra space horizontally, 
        // LAYOUT_CENTER and LAYOUT_RIGHT are NOT set
        // non null label, null content
        declare("test11");
        checkLayout(new TestItemLFImpl(50, 50,   // labelSize
                                       0, 0,     // contentSize
                                       100, 50, // itemSize
                                       10),     // labelHeight to be single ln 
                    0, 0,  // checked label location
                    0, 0); // checked content location



        // there IS extra space horizontally, 
        // LAYOUT_CENTER and LAYOUT_RIGHT are NOT set
        // non null label, non null content
        // label and content on the same line;
        // label height > content height
        declare("test11");
        checkLayout(new TestItemLFImpl(47, 20,    // labelSize
                                       50, 10,  // contentSize
                                       200, 20, // itemSize
                                       20),     // labelHeight to be single ln 
                    0, 0,  // checked label location
                    50, 5); // checked content location

        // there IS extra space horizontally, 
        // LAYOUT_CENTER and LAYOUT_RIGHT are NOT set
        // non null label, non null content
        // label and content on the same line
        // label height < content height
        declare("test12");
        checkLayout(new TestItemLFImpl(47, 10,    // labelSize
                                       50, 20,  // contentSize
                                       200, 20, // itemSize
                                       10),    // labelHeight to be single ln 
                    0, 5,  // checked label location
                    50, 0); // checked content location

        // there IS extra space horizontally, 
        // LAYOUT_CENTER and LAYOUT_RIGHT are NOT set
        // non null label, non null content
        // label and content on different lines
        // label width < content width
        declare("test13");
        checkLayout(new TestItemLFImpl(30, 20,  // labelSize
                                       50, 20,  // contentSize
                                       100, 32, // itemSize
                                       10),     // labelHeight to be single ln 
                    0, 0,  // checked label location
                    0, 22); // checked content location


        // there IS extra space horizontally, 
        // LAYOUT_CENTER and LAYOUT_RIGHT are NOT set
        // non null label, non null content
        // label and content on different lines
        // label width > content width
        declare("test14");
        checkLayout(new TestItemLFImpl(50, 20,  // labelSize
                                       30, 20,  // contentSize
                                       100, 32, // itemSize
                                       10),     // labelHeight to be single ln 
                    0, 0,  // checked label location
                    0, 22); // checked content location


        // **********************************************
        
        // there IS extra space horizontally, 
        // LAYOUT_CENTER is set
        // non null label, non null content
        // label and content on the same line;
        // label height > content height
        declare("test15");
        checkLayout(new TestItemLFImpl(47, 20,    // labelSize
                                       50, 10,  // contentSize
                                       200, 20, // itemSize
                                       20,     // labelHeight to be single ln 
                                       Item.LAYOUT_CENTER),
                    50, 0,  // checked label location
                    100, 5); // checked content location
        
        // there IS extra space horizontally, 
        // LAYOUT_CENTER is set
        // non null label, non null content
        // label and content on the same line
        // label height < content height
        declare("test16");
        checkLayout(new TestItemLFImpl(47, 10,    // labelSize
                                       50, 20,  // contentSize
                                       200, 20, // itemSize
                                       10,     // labelHeight to be single ln 
                                       Item.LAYOUT_CENTER),
                    50, 5,  // checked label location
                    100, 0); // checked content location


        // there IS extra space horizontally, 
        // LAYOUT_CENTER is set
        // non null label, non null content
        // label and content on different lines
        // label width < content width
        declare("test17");
        checkLayout(new TestItemLFImpl(30, 20,  // labelSize
                                       50, 20,  // contentSize
                                       100, 32, // itemSize
                                       10,     // labelHeight to be single ln 
                                       Item.LAYOUT_CENTER),
                    35, 0,  // checked label location
                    25, 22); // checked content location

        // there IS extra space horizontally, 
        // LAYOUT_CENTER is set
        // non null label, non null content
        // label and content on different lines
        // label width > content width
        declare("test18");
        checkLayout(new TestItemLFImpl(50, 20,  // labelSize
                                       30, 20,  // contentSize
                                       100, 32, // itemSize
                                       10,     // labelHeight to be single ln 
                                       Item.LAYOUT_CENTER),
                    25, 0,  // checked label location
                    35, 22); // checked content location


        // *****************


        // there IS extra space horizontally, 
        // LAYOUT_RIGHT is set
        // non null label, non null content
        // label and content on the same line;
        // label height > content height
        declare("test19");
        checkLayout(new TestItemLFImpl(47, 20,    // labelSize
                                       50, 10,  // contentSize
                                       200, 20, // itemSize
                                       20,     // labelHeight to be single ln 
                                       Item.LAYOUT_RIGHT),
                    100, 0,  // checked label location
                    150, 5); // checked content location

        // there IS extra space horizontally, 
        // LAYOUT_RIGHT is set
        // non null label, non null content
        // label and content on the same line
        // label height < content height
        declare("test20");
        checkLayout(new TestItemLFImpl(47, 10,    // labelSize
                                       50, 20,  // contentSize
                                       200, 20, // itemSize
                                       10,     // labelHeight to be single ln 
                                       Item.LAYOUT_RIGHT),
                    100, 5,  // checked label location
                    150, 0); // checked content location

        // there IS extra space horizontally, 
        // LAYOUT_RIGHT is set
        // non null label, non null content
        // label and content on different lines
        // label width < content width
        declare("test21");
        checkLayout(new TestItemLFImpl(30, 20,  // labelSize
                                       50, 20,  // contentSize
                                       100, 32, // itemSize
                                       10,     // labelHeight to be single ln 
                                       Item.LAYOUT_RIGHT),
                    50, 0,  // checked label location
                    50, 22); // checked content location

        // there IS extra space horizontally, 
        // LAYOUT_RIGHT is set
        // non null label, non null content
        // label and content on different lines
        // label width > content width
        declare("test22");
        checkLayout(new TestItemLFImpl(30, 20,  // labelSize
                                       50, 20,  // contentSize
                                       100, 32, // itemSize
                                       10,     // labelHeight to be single ln 
                                       Item.LAYOUT_RIGHT),
                    50, 0,  // checked label location
                    50, 22); // checked content location

        // ************ more space VERTICALLY  **************************
        // ****************************************************************

        // there IS extra space vertically, 
        // LAYOUT_VCENTER and LAYOUT_BOTTOM are NOT set
        // null label, non null content
        declare("test23");
        checkLayout(new TestItemLFImpl(0, 0,    // labelSize
                                       50, 50,  // contentSize
                                       50, 100, // itemSize
                                       10),     // labelHeight to be single ln 
                    0, 0,  // checked label location
                    0, 0); // checked content location
        
        // there IS extra space vertically, 
        // LAYOUT_VCENTER and LAYOUT_BOTTOM are NOT set
        // non null label, null content
        declare("test24");
        checkLayout(new TestItemLFImpl(50, 50,   // labelSize
                                       0, 0,     // contentSize
                                       50, 100, // itemSize
                                       10),     // labelHeight to be single ln 
                    0, 0,  // checked label location
                    0, 0); // checked content location


        // there IS extra space vertically, 
        // LAYOUT_VCENTER and LAYOUT_BOTTOM are NOT set
        // non null label, non null content
        // label and content on the same line;
        // label height > content height
        declare("test25");
        checkLayout(new TestItemLFImpl(47, 20,    // labelSize
                                       50, 10,  // contentSize
                                       100, 100, // itemSize
                                       20),     // labelHeight to be single ln 
                    0, 0,  // checked label location
                    50, 5); // checked content location

        // there IS extra space vertically, 
        // LAYOUT_VCENTER and LAYOUT_BOTTOM are NOT set
        // non null label, non null content
        // label and content on the same line
        // label height < content height
        declare("test26");
        checkLayout(new TestItemLFImpl(47, 10,    // labelSize
                                       50, 20,  // contentSize
                                       100, 100, // itemSize
                                       10),    // labelHeight to be single ln 
                    0, 5,  // checked label location
                    50, 0); // checked content location

        // there IS extra space vertically, 
        // LAYOUT_VCENTER and LAYOUT_BOTTOM are NOT set
        // non null label, non null content
        // label and content are on different lines
        // label width < content width
        declare("test27");
        checkLayout(new TestItemLFImpl(30, 20,  // labelSize
                                       50, 20,  // contentSize
                                       50, 100, // itemSize
                                       10),     // labelHeight to be single ln 
                    0, 0,  // checked label location
                    0, 22); // checked content location


        // there IS extra space vertically, 
        // LAYOUT_VCENTER and LAYOUT_BOTTOM are NOT set
        // non null label, non null content
        // label and content are on different lines
        // label width > content width
        declare("test28");
        checkLayout(new TestItemLFImpl(50, 20,  // labelSize
                                       30, 20,  // contentSize
                                       50, 100, // itemSize
                                       10),     // labelHeight to be single ln 
                    0, 0,  // checked label location
                    0, 22); // checked content location


        // **********************************************
        
        // there IS extra space vertically, 
        // LAYOUT_VCENTER is set
        // non null label, non null content
        // label and content on the same line;
        // label height > content height
        declare("test29");
        checkLayout(new TestItemLFImpl(47, 20,    // labelSize
                                       50, 10,  // contentSize
                                       100, 100, // itemSize
                                       20,     // labelHeight to be single ln 
                                       Item.LAYOUT_VCENTER),
                    0, 40,  // checked label location
                    50, 45); // checked content location
        
        // there IS extra space vertically, 
        // LAYOUT_VCENTER is set
        // non null label, non null content
        // label and content on the same line
        // label height < content height
        declare("test30");
        checkLayout(new TestItemLFImpl(47, 10,    // labelSize
                                       50, 20,  // contentSize
                                       100, 100, // itemSize
                                       10,     // labelHeight to be single ln 
                                       Item.LAYOUT_VCENTER),
                    0, 45,  // checked label location
                    50, 40); // checked content location


        // there IS extra space vertically, 
        // LAYOUT_VCENTER is set
        // non null label, non null content
        // label and content on different lines
        // label width < content width
        declare("test31");
        checkLayout(new TestItemLFImpl(30, 18,  // labelSize
                                       50, 20,  // contentSize
                                       50, 100, // itemSize
                                       10,     // labelHeight to be single ln 
                                       Item.LAYOUT_VCENTER),
                    0, 30,  // checked label location
                    0, 50); // checked content location

        // there IS extra space vertically, 
        // LAYOUT_VCENTER is set
        // non null label, non null content
        // label and content on different lines
        // label width > content width
        declare("test32");
        checkLayout(new TestItemLFImpl(50, 18,  // labelSize
                                       30, 20,  // contentSize
                                       50, 100, // itemSize
                                       10,     // labelHeight to be single ln 
                                       Item.LAYOUT_VCENTER),
                    0, 30,  // checked label location
                    0, 50); // checked content location


        // *************************************************************

        // there IS extra space vertically, 
        // LAYOUT_BOTTOM is set
        // non null label, non null content
        // label and content are on the same line;
        // label height > content height
        declare("test33");
        checkLayout(new TestItemLFImpl(47, 20,    // labelSize
                                       50, 10,  // contentSize
                                       100, 100, // itemSize
                                       20,     // labelHeight to be single ln 
                                       Item.LAYOUT_BOTTOM),
                    0, 80,  // checked label location
                    50, 85); // checked content location

        // there IS extra space vertically, 
        // LAYOUT_BOTTOM is set
        // non null label, non null content
        // label and content on the same line
        // label height < content height
        declare("test34");
        checkLayout(new TestItemLFImpl(47, 10,    // labelSize
                                       50, 20,  // contentSize
                                       100, 100, // itemSize
                                       10,     // labelHeight to be single ln 
                                       Item.LAYOUT_BOTTOM),
                    0, 85,  // checked label location
                    50, 80); // checked content location

        // there IS extra space vertically, 
        // LAYOUT_BOTTOM is set
        // non null label, non null content
        // label and content on different lines
        // label width < content width
        declare("test35");
        checkLayout(new TestItemLFImpl(30, 18,  // labelSize
                                       50, 20,  // contentSize
                                       50, 100, // itemSize
                                       10,     // labelHeight to be single ln 
                                       Item.LAYOUT_BOTTOM),
                    0, 60,  // checked label location
                    0, 80); // checked content location

        // there IS extra space vertically, 
        // LAYOUT_BOTTOM is set
        // non null label, non null content
        // label and content on different lines
        // label width > content width
        declare("test36");
        checkLayout(new TestItemLFImpl(30, 18,  // labelSize
                                       50, 20,  // contentSize
                                       50, 100, // itemSize
                                       10,     // labelHeight to be single ln 
                                       Item.LAYOUT_BOTTOM),
                    0, 60,  // checked label location
                    0, 80); // checked content location

        // ***** more space VERTICALLY and HORIZONTALLY ******************
        // ****************************************************************

        // there IS extra space vertically and horizontally 
        // LAYOUT_CENTER & LAYOUT_VCENTER is set
        // non null label, non null content
        // label and content are on the same line;
        declare("test37");
        checkLayout(new TestItemLFImpl(47, 20,    // labelSize
                                       50, 10,  // contentSize
                                       200, 100, // itemSize
                                       20,     // labelHeight to be single ln 
                                       Item.LAYOUT_CENTER | 
                                       Item.LAYOUT_VCENTER),
                    50, 40,  // checked label location
                    100, 45); // checked content location


        // there IS extra space vertically and horizontally, 
        // LAYOUT_CENTER & LAYOUT_VCENTER is set
        // non null label, non null content
        // label and content are on different lines
        declare("test38");
        checkLayout(new TestItemLFImpl(30, 18,  // labelSize
                                       50, 20,  // contentSize
                                       100, 100, // itemSize
                                       10,     // labelHeight to be single ln 
                                       Item.LAYOUT_CENTER | 
                                       Item.LAYOUT_VCENTER),
                    35, 30,  // checked label location
                    25, 50); // checked content location

        // there IS extra space vertically and horizontally 
        // LAYOUT_RIGHT & LAYOUT_BOTTOM is set
        // non null label, non null content
        // label and content are on the same line;
        declare("test39");
        checkLayout(new TestItemLFImpl(47, 20,    // labelSize
                                       50, 10,  // contentSize
                                       200, 100, // itemSize
                                       20,     // labelHeight to be single ln 
                                       Item.LAYOUT_RIGHT | Item.LAYOUT_BOTTOM),
                    100, 80,  // checked label location
                    150, 85); // checked content location

        // there IS extra space vertically and horizontally, 
        // LAYOUT_RIGHT & LAYOUT_BOTTOM is set
        // non null label, non null content
        // label and content are on different lines
        declare("test40");
        checkLayout(new TestItemLFImpl(30, 18,  // labelSize
                                       50, 20,  // contentSize
                                       100, 100, // itemSize
                                       10,     // labelHeight to be single ln 
                                       Item.LAYOUT_RIGHT | Item.LAYOUT_BOTTOM),
                    50, 60,  // checked label location
                    50, 80); // checked content location