uiaccelerator_plat/alf_extended_visual_api/tsrc/src/UT_CAlfLCTGridLayout.cpp
branchRCL_3
changeset 20 31fccae4f8a7
parent 10 7c5dd702d6d3
equal deleted inserted replaced
19:e5af45d51884 20:31fccae4f8a7
       
     1 /*
       
     2 * Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description: 
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 //  CLASS HEADER
       
    20 #include "UT_CAlfLCTGridLayout.h"
       
    21 
       
    22 //  EXTERNAL INCLUDES
       
    23 #include <EUnitMacros.h>
       
    24 
       
    25 
       
    26 //  INTERNAL INCLUDES
       
    27 #include "alf/alflctGridLayout.h"
       
    28 #include "alf/alfdecklayout.h"
       
    29 #include "alf/alfenv.h"
       
    30 #include "alf/alfcontrol.h"
       
    31 
       
    32 #include <aknlayout2def.h>
       
    33 #include <aknlayoutscalable_avkon.cdl.h>
       
    34 #include <aknlayout2hierarchy.h>
       
    35 #include <LayoutMetaData.cdl.h>
       
    36 
       
    37 
       
    38 // =================
       
    39 // Test Class
       
    40 // =================
       
    41 
       
    42 // CONSTRUCTION
       
    43 UT_CAlfLCTGridLayout* UT_CAlfLCTGridLayout::NewL()
       
    44     {
       
    45     UT_CAlfLCTGridLayout* self = UT_CAlfLCTGridLayout::NewLC();
       
    46     CleanupStack::Pop();
       
    47 
       
    48     return self;
       
    49     }
       
    50 
       
    51 UT_CAlfLCTGridLayout* UT_CAlfLCTGridLayout::NewLC()
       
    52     {
       
    53     UT_CAlfLCTGridLayout* self = new( ELeave ) UT_CAlfLCTGridLayout();
       
    54     CleanupStack::PushL( self );
       
    55 
       
    56     self->ConstructL();
       
    57 
       
    58     return self;
       
    59     }
       
    60 
       
    61 // Destructor (virtual by CBase)
       
    62 UT_CAlfLCTGridLayout::~UT_CAlfLCTGridLayout()
       
    63     {
       
    64     }
       
    65 
       
    66 // Default constructor
       
    67 UT_CAlfLCTGridLayout::UT_CAlfLCTGridLayout()
       
    68     {
       
    69     }
       
    70 
       
    71 // Second phase construct
       
    72 void UT_CAlfLCTGridLayout::ConstructL()
       
    73     {
       
    74     // The ConstructL from the base class CEUnitTestSuiteClass must be called.
       
    75     // It generates the test case table.
       
    76     CEUnitTestSuiteClass::ConstructL();
       
    77     }
       
    78 
       
    79 // =================
       
    80 // Tests
       
    81 // =================
       
    82 
       
    83 void UT_CAlfLCTGridLayout::SetupL(  )
       
    84     {
       
    85     iEnv = CAlfEnv::NewL();
       
    86     
       
    87     iControl = new( ELeave ) CAlfControl;
       
    88     iControl->ConstructL( *iEnv );
       
    89 
       
    90     iLayout = (CAlfLCTGridLayout*)iControl->AppendLayoutL( EAlfLayoutTypeLCTGrid );
       
    91     }
       
    92 
       
    93 void UT_CAlfLCTGridLayout::Teardown(  )
       
    94     {
       
    95     if ( iControl && iEnv && !iEnv->FindControl( iControl->Id() ) )
       
    96         {
       
    97         delete iControl;
       
    98         iControl = NULL;
       
    99         }
       
   100     delete iEnv;
       
   101     iEnv = NULL;
       
   102     }
       
   103 
       
   104 void UT_CAlfLCTGridLayout::UT_CAlfLCTGridLayout_CAlfLCTGridLayoutL(  )
       
   105     {
       
   106     __UHEAP_MARK;
       
   107     CAlfLCTGridLayout* visual = new (ELeave) CAlfLCTGridLayout;
       
   108     delete visual;
       
   109     __UHEAP_MARKEND;
       
   110     }
       
   111 
       
   112 void UT_CAlfLCTGridLayout::UT_CAlfLCTGridLayout_ConstructLL(  )
       
   113     {
       
   114     __UHEAP_MARK;
       
   115     CAlfLCTGridLayout* visual = new (ELeave) CAlfLCTGridLayout;
       
   116     CleanupStack::PushL( visual );
       
   117     visual->ConstructL( *iControl );
       
   118     CleanupStack::PopAndDestroy( visual );
       
   119     __UHEAP_MARKEND;
       
   120     }
       
   121 
       
   122 void UT_CAlfLCTGridLayout::UT_CAlfLCTGridLayout_RemoveAndDestroyAllDL(  )
       
   123     {
       
   124     iLayout->RemoveAndDestroyAllD();
       
   125     iLayout = NULL;
       
   126     }
       
   127 
       
   128 void UT_CAlfLCTGridLayout::UT_CAlfLCTGridLayout_SetColsAndRows(  )
       
   129     {
       
   130     TInt cell_app_pane_variety = Layout_Meta_Data::IsLandscapeOrientation() ? 2 : 1;
       
   131     TAknLayoutScalableParameterLimits cell_app_pane_limits = AknLayoutScalable_Avkon::cell_app_pane_ParamLimits(cell_app_pane_variety);
       
   132     TInt cols = cell_app_pane_limits.LastColumn() + 1;
       
   133     TInt rows = cell_app_pane_limits.LastRow() + 1;
       
   134 
       
   135     TAknLayoutHierarchyComponentHandle cell_app_pane_Handle(
       
   136         KUidAknLayoutSystemId_AknLayout2,
       
   137         AknLayoutScalable_Avkon::KCdlInterfaceUidValue, 
       
   138         AknLayoutScalable_Avkon::EApiId_cell_app_pane);
       
   139 
       
   140     cell_app_pane_Handle.SetVarietyIndex(cell_app_pane_variety);
       
   141 
       
   142     TAlfTimedPoint timedPoint;
       
   143     iLayout->SetColsAndRows(cell_app_pane_Handle, timedPoint);
       
   144     
       
   145     TInt resultCols = iLayout->ColumnCount();
       
   146     TInt resultRows = iLayout->RowCount();
       
   147     
       
   148     EUNIT_ASSERT_EQUALS( cols, resultCols );
       
   149     EUNIT_ASSERT_EQUALS( rows, resultRows );
       
   150     }
       
   151 
       
   152 // =================
       
   153 // Test Table
       
   154 // =================
       
   155 
       
   156 
       
   157 EUNIT_BEGIN_TEST_TABLE(
       
   158     UT_CAlfLCTGridLayout,
       
   159     "Alf Unit Tests",
       
   160     "UNIT" )
       
   161 
       
   162 EUNIT_TEST(
       
   163     "CAlfLCTGridLayout - test ",
       
   164     "CAlfLCTGridLayout",
       
   165     "CAlfLCTGridLayout",
       
   166     "FUNCTIONALITY",
       
   167     SetupL, UT_CAlfLCTGridLayout_CAlfLCTGridLayoutL, Teardown)
       
   168 
       
   169 EUNIT_TEST(
       
   170     "ConstructL - test ",
       
   171     "CAlfLCTGridLayout",
       
   172     "ConstructL",
       
   173     "FUNCTIONALITY",
       
   174     SetupL, UT_CAlfLCTGridLayout_ConstructLL, Teardown)
       
   175 
       
   176 EUNIT_TEST(
       
   177     "RemoveAndDestroyAllD - test ",
       
   178     "CAlfLCTGridLayout",
       
   179     "RemoveAndDestroyAllD",
       
   180     "FUNCTIONALITY",
       
   181     SetupL, UT_CAlfLCTGridLayout_RemoveAndDestroyAllDL, Teardown)
       
   182 
       
   183 /** TODO: FIX TEST
       
   184  * THIS TEST IS NOT USED BECAUSE TEST FAILS. 
       
   185  * REQUIRES FURTHER STUDY AND FIX.
       
   186 EUNIT_TEST(
       
   187     "SetColsAndRows - test ",
       
   188     "CAlfLCTGridLayout",
       
   189     "SetColsAndRows",
       
   190     "FUNCTIONALITY",
       
   191     SetupL, UT_CAlfLCTGridLayout_SetColsAndRows, Teardown)
       
   192 */
       
   193 
       
   194 EUNIT_END_TEST_TABLE
       
   195 
       
   196 //  END OF FILE