contentstorage/caclient/tsrc/t_caclient/src/t_caclientnotifier.cpp
changeset 117 c63ee96dbe5f
equal deleted inserted replaced
115:3ab5c078b490 117:c63ee96dbe5f
       
     1 /*
       
     2 * Copyright (c) 2009 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:  Main test class for hspluginmodel library.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include "t_caclientnotifier.h"
       
    20 #include "caentry.h"
       
    21 #include "canotifier.h"
       
    22 #include "canotifierfilter.h"
       
    23 #include "caservice.h"
       
    24 
       
    25 // ============================================================================
       
    26 TestCaClientNotifier::TestCaClientNotifier():
       
    27     mEntryId(0),
       
    28     mGroupId(0),
       
    29     mChangeType(AddChangeType),
       
    30     mEntry(NULL),
       
    31     mCount(0),
       
    32     mEntryIds(new QList<int>()),
       
    33     mGroupIds(new QList<int>()),
       
    34     mChangeTypes(new QList<ChangeType>()),
       
    35     mEntries(new QList<const CaEntry *>()),
       
    36     mFilter(NULL),
       
    37     mNotifier(NULL)
       
    38 {
       
    39 
       
    40 }
       
    41 // ============================================================================
       
    42 TestCaClientNotifier::TestCaClientNotifier(const CaService &service, CaNotifierFilter *filter):
       
    43     mEntryId(0),
       
    44     mGroupId(0),
       
    45     mChangeType(AddChangeType),
       
    46     mEntry(NULL),
       
    47     mCount(0),
       
    48     mEntryIds(new QList<int>()),
       
    49     mGroupIds(new QList<int>()),
       
    50     mChangeTypes(new QList<ChangeType>()),
       
    51     mEntries(new QList<const CaEntry *>())
       
    52 {
       
    53     if (!filter) {
       
    54         mFilter = new CaNotifierFilter();
       
    55         mNotifier = service.createNotifier(*mFilter);
       
    56     } else {
       
    57         mFilter = NULL;
       
    58         mNotifier = service.createNotifier(*filter);
       
    59     }
       
    60 }
       
    61 
       
    62 // ============================================================================
       
    63 void TestCaClientNotifier::clean()
       
    64 {
       
    65     mEntryId = 0;
       
    66     mGroupId = 0;
       
    67     mChangeType = AddChangeType;
       
    68     mCount = 0;
       
    69     delete mEntryIds;
       
    70     mEntryIds = new QList<int>();
       
    71     delete mGroupIds;
       
    72     mGroupIds = new QList<int>();
       
    73     delete mChangeTypes;
       
    74     mChangeTypes = new QList<ChangeType>();
       
    75     delete mEntries;
       
    76     mEntries = new QList<const CaEntry *>();
       
    77     delete mEntry;
       
    78     mEntry = NULL;
       
    79 }
       
    80 // ============================================================================
       
    81 TestCaClientNotifier::~TestCaClientNotifier()
       
    82 {
       
    83     delete mEntry;
       
    84     delete mFilter;
       
    85     delete mNotifier;
       
    86     delete mEntryIds;
       
    87     delete mGroupIds;
       
    88     delete mChangeTypes;
       
    89     delete mEntries;
       
    90 
       
    91 }
       
    92 // ============================================================================
       
    93 CaNotifier *TestCaClientNotifier::getNotifier() const
       
    94 {
       
    95     return mNotifier;
       
    96 }
       
    97 // ============================================================================
       
    98 CaNotifierFilter *TestCaClientNotifier::getFilter() const
       
    99 {
       
   100     return mFilter;
       
   101 }
       
   102 // ============================================================================
       
   103 void TestCaClientNotifier::entryChanged(int entryId, ChangeType changeType)
       
   104 {
       
   105     mEntryId = entryId;
       
   106     mChangeType = changeType;
       
   107     mEntryIds->append(entryId);
       
   108     mChangeTypes->append(changeType);
       
   109     mEntries->append(NULL);
       
   110     mGroupIds->append(0);
       
   111     mCount++;
       
   112 }
       
   113 // ============================================================================
       
   114 void TestCaClientNotifier::entryChanged(const CaEntry &entry, ChangeType changeType)
       
   115 {
       
   116     delete mEntry;
       
   117     mEntry = new CaEntry(entry);
       
   118     mEntryId = entry.id();
       
   119     mChangeType = changeType;
       
   120     mEntryIds->append(entry.id());
       
   121     mChangeTypes->append(changeType);
       
   122     mEntries->append(&entry);
       
   123     mGroupIds->append(0);
       
   124     mCount++;
       
   125 }
       
   126 // ============================================================================
       
   127 void TestCaClientNotifier::entryTouched(int id)
       
   128 {
       
   129     mEntryId = id;
       
   130     mEntryIds->append(id);
       
   131     mChangeTypes->append(AddChangeType);
       
   132     mEntries->append(NULL);
       
   133     mGroupIds->append(0);
       
   134     mCount++;
       
   135 }
       
   136 // ============================================================================
       
   137 void TestCaClientNotifier::groupContentChanged(int groupId)
       
   138 {
       
   139     mGroupId = groupId;
       
   140     mEntryIds->append(0);
       
   141     mChangeTypes->append(AddChangeType);
       
   142     mEntries->append(NULL);
       
   143     mGroupIds->append(groupId);
       
   144     mCount++;
       
   145 }