photosgallery/viewframework/commandhandlers/tsrc/ut_commandhandlerdrm/inc/ut_glxdummymedialist.h
changeset 0 4e91876724a2
equal deleted inserted replaced
-1:000000000000 0:4e91876724a2
       
     1 /*
       
     2 * Copyright (c) 2007 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:    CGlxMediaList unit tests
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 //  CLASS HEADER
       
    22 #include <mglxmedialist.h>
       
    23 
       
    24 //
       
    25 CGlxMedia::CGlxMedia(const TGlxMediaId& aId)
       
    26 		: iId(aId)
       
    27     {
       
    28     }
       
    29     
       
    30 CGlxMedia::~CGlxMedia()
       
    31     {
       
    32 	Reset();
       
    33     iValues.Close(); 
       
    34     iAttributes.Close();
       
    35     
       
    36     }    
       
    37        	
       
    38 class _CGlxTestMediaList: public CBase, public MGlxMediaList
       
    39 	{
       
    40 public:
       
    41 	~_CGlxTestMediaList() 
       
    42 	    {
       
    43 	    iItems.Close();
       
    44         iMedia.ResetAndDestroy();
       
    45         iSelectedItems.Close();
       
    46         iItemListObservers.Close();
       
    47 	    }
       
    48 	    
       
    49 	virtual void Close() 
       
    50 	    {
       
    51 	    };
       
    52 	virtual TGlxMediaListId Id() const 
       
    53 	    {
       
    54 	    return KGlxIdNone;
       
    55 	    }
       
    56 
       
    57 	virtual TInt Count(NGlxListDefs::TCountType /*aType*/) const 
       
    58 	    {
       
    59 	    return iItems.Count();
       
    60 	    }
       
    61 	
       
    62 	virtual TInt FocusIndex() const 
       
    63 	    {
       
    64 	    return iFocusIndex;
       
    65 	    }
       
    66 
       
    67 	virtual void SetFocusL(NGlxListDefs::TFocusSetType /*aType*/, TInt aValue) 
       
    68 	    {
       
    69 	    iFocusIndex = aValue;
       
    70 	    }
       
    71 	
       
    72 	virtual const TGlxMedia& Item(TInt aIndex) const 
       
    73 	    {
       
    74 	    return iItems[aIndex];
       
    75 	    }
       
    76 
       
    77 	virtual TInt Index(const TGlxIdSpaceId& /* aIdSpaceId */, const TGlxMediaId& aId) const 
       
    78 	    {
       
    79 	    TInt count = iItems.Count();
       
    80 	    for (TInt i = 0; i < count; i++)
       
    81 	        {
       
    82 	        if (iItems[i].Id() == aId)
       
    83 	            {
       
    84 	            return i;
       
    85 	            }
       
    86 	        }
       
    87 	    return KErrNotFound;
       
    88 	    }
       
    89 	
       
    90 	virtual void AddMediaListObserverL(MGlxMediaListObserver* aObserver) 
       
    91 	    {
       
    92 	    iItemListObservers.AppendL(aObserver);
       
    93 	    }
       
    94 	
       
    95 	virtual void RemoveMediaListObserver(MGlxMediaListObserver* aObserver) 
       
    96 	    {
       
    97 	    TInt index = iItemListObservers.Find(aObserver);
       
    98   
       
    99         if (index != KErrNotFound) 
       
   100             {
       
   101             iItemListObservers.Remove(index);	
       
   102             }
       
   103 	    }
       
   104 
       
   105     virtual void AddContextL(const MGlxFetchContext* /*aContext*/, TInt /*aPriority*/) 
       
   106         {
       
   107         }
       
   108 
       
   109 	virtual void RemoveContext(const MGlxFetchContext* /*aContext*/) 
       
   110 	    {
       
   111 	    }
       
   112 	
       
   113 	virtual MMPXCollection& Collection() const 
       
   114 	    {
       
   115 	    // we know that this method is not called in our tests, this is just to make the code compile
       
   116 	    MMPXCollection* empty = NULL;
       
   117 	    return *empty;
       
   118 	    }
       
   119 
       
   120 	virtual TBool IsSelected(TInt aIndex) const 
       
   121 	    {
       
   122 	    TInt idx = iSelectedItems.Find(aIndex);
       
   123 	    return (idx != KErrNotFound);
       
   124 	    }
       
   125 
       
   126 	virtual void SetSelectedL(TInt aIndex, TBool aSelected) 
       
   127 	    {
       
   128 	    if (aSelected)
       
   129 	        {
       
   130             iSelectedItems.InsertInOrder(aIndex);
       
   131 	        }
       
   132 	    else 
       
   133 	        {
       
   134 	        iSelectedItems.Remove(iSelectedItems.Find(aIndex));
       
   135 	        }
       
   136 	    }
       
   137 
       
   138 	virtual const TArray<TInt> Selection() const 
       
   139 	    {
       
   140 	    return iSelectedItems.Array();
       
   141 	    }
       
   142 
       
   143 	virtual void CommandL(CMPXCommand& /*aCommand*/) 
       
   144 	    {
       
   145 	    }
       
   146 
       
   147 	virtual void CancelCommand() 
       
   148 	    {
       
   149 	    }
       
   150 
       
   151 	virtual void SetFilterL(CMPXFilter* /*aFilter*/) 
       
   152 	    {
       
   153 	    }
       
   154 
       
   155 	virtual CMPXFilter* Filter() const 
       
   156 	    {
       
   157 	    return NULL;
       
   158 	    }
       
   159 
       
   160     virtual TGlxIdSpaceId IdSpaceId(TInt /*aIndex*/) const 
       
   161         {
       
   162         return KGlxIdNone;
       
   163         }
       
   164     
       
   165     void AppendL(TInt aId, TBool aCreateMedia) 
       
   166         {
       
   167         if (aCreateMedia) 
       
   168             {
       
   169             CGlxMedia* media = new (ELeave) CGlxMedia(TGlxMediaId(aId));
       
   170             CleanupStack::PushL(media);
       
   171             iMedia.AppendL(media);
       
   172             CleanupStack::Pop(media);
       
   173             iItems.AppendL(TGlxMedia(TGlxMediaId(aId), media));
       
   174             }
       
   175         else 
       
   176             {
       
   177             iItems.AppendL(TGlxMedia(TGlxMediaId(aId)));
       
   178             }
       
   179             
       
   180         TInt pos = iItems.Count() -1;
       
   181             
       
   182         TInt obCount = iItemListObservers.Count();
       
   183         for(TInt i = 0; i < obCount; i++)
       
   184             {
       
   185             iItemListObservers[i]->HandleItemAddedL(pos, pos, this );
       
   186             }
       
   187         }
       
   188         
       
   189     void AppendL(TInt aId, CGlxMedia* aMedia) 
       
   190         {
       
   191         iMedia.AppendL(aMedia);   
       
   192         iItems.AppendL(TGlxMedia(TGlxMediaId(aId), aMedia));
       
   193         
       
   194         TInt pos = iItems.Count() -1;
       
   195             
       
   196         TInt obCount = iItemListObservers.Count();
       
   197         for(TInt i = 0; i < obCount; i++)
       
   198             {
       
   199             iItemListObservers[i]->HandleItemAddedL(pos, pos, this );
       
   200             }
       
   201         }
       
   202         
       
   203     void HandleAttributesAvailableL() 
       
   204         {
       
   205         RArray<TMPXAttribute> attrArray;
       
   206         TInt obCount = iItemListObservers.Count();
       
   207         for(TInt i = 0; i < obCount; i++)
       
   208             {
       
   209             iItemListObservers[i]->HandleAttributesAvailableL(0, attrArray, this );
       
   210             }
       
   211         attrArray.Close();
       
   212         }    
       
   213         
       
   214     CGlxMedia* MediaObj(TInt aIndex) const 
       
   215         {
       
   216         return const_cast<CGlxMedia*>(static_cast<const CGlxMedia*>(iItems[aIndex].Properties()));
       
   217         }
       
   218         
       
   219     CMPXCollectionPath* PathLC(NGlxListDefs::TPathType /*aType*/) const
       
   220     	{
       
   221     	return NULL;
       
   222     	}
       
   223     
       
   224     TInt SelectionCount() const
       
   225     	{
       
   226     	return iSelectedItems.Count();
       
   227     	}
       
   228     	
       
   229     TInt SelectedItemIndex(TInt /*aSelectionIndex*/) const
       
   230     	{
       
   231     	return 0;
       
   232     	}
       
   233     	
       
   234     TBool IsPopulated() const
       
   235         {
       
   236         return ETrue;
       
   237         }
       
   238     
       
   239     void AddStaticItemL( CGlxMedia* /*aStaticItem*/,
       
   240         NGlxListDefs::TInsertionPosition /*aTargetPosition*/ ) {};
       
   241     
       
   242     void RemoveStaticItem(const TGlxMediaId& /*aItemId*/) {};
       
   243     
       
   244     void SetStaticItemsEnabled( TBool aEnabled ) { iStaticItemsEnabled = aEnabled; };
       
   245     
       
   246     TBool IsStaticItemsEnabled() const { return iStaticItemsEnabled; };
       
   247     
       
   248     void SetFocusInitialPosition(NGlxListDefs::TFocusInitialPosition aFocusInitialPosition){};
       
   249 
       
   250     void ResetFocus(){};        
       
   251 
       
   252     void SetVisibleWindowIndexL( TInt aIndex ){};
       
   253     TInt VisibleWindowIndex() const {};
       
   254     virtual void CancelPreviousRequests() {};
       
   255     RArray<TGlxMedia> iItems;
       
   256     RPointerArray<CGlxMedia> iMedia;
       
   257     RArray<TInt> iSelectedItems;
       
   258     TInt iFocusIndex;
       
   259     
       
   260     RPointerArray<MGlxMediaListObserver> iItemListObservers;
       
   261     TBool iStaticItemsEnabled;
       
   262 	};    
       
   263 
       
   264 //  END OF FILE