hgcacheproxymodel/tsrc/unit/test_hgcacheproxydatamodel.cpp
branchGCC_SURGE
changeset 10 c348b9772569
parent 8 15f034b8a3b5
child 7 5ebec3429918
equal deleted inserted replaced
4:463f1934e292 10:c348b9772569
    11 *
    11 *
    12 * Contributors:
    12 * Contributors:
    13 *
    13 *
    14 * Description:
    14 * Description:
    15 *
    15 *
    16 *  Version     : %version: 5 %
    16 *  Version     : %version: 10 %
    17 */
    17 */
    18 #include <QtTest/QtTest>
    18 #include <QtTest/QtTest>
    19 #include <hgwidgets/hgcacheproxymodel.h>
    19 #include <hgwidgets/hgcacheproxymodel.h>
    20 #include "test_hgcacheproxydatamodel.h"
    20 #include "test_hgcacheproxydatamodel.h"
    21 
    21 
    23 #include "bmhelper.h"
    23 #include "bmhelper.h"
    24 
    24 
    25 #include "dataproviderhelper.h"
    25 #include "dataproviderhelper.h"
    26 #include "cacheproxyhelper.h"
    26 #include "cacheproxyhelper.h"
    27 #include <QtDebug>
    27 #include <QtDebug>
       
    28 #include <HbIcon>
       
    29 #include <QIcon>
       
    30 #include <QImage>
       
    31 #include <QPixmap>
       
    32 
    28 
    33 
    29 // ======== MEMBER FUNCTIONS ========
    34 // ======== MEMBER FUNCTIONS ========
    30 void TestCacheProxy::testQAbstractItemModel(QAbstractItemModel* model, int rows, int columns)
    35 void TestCacheProxy::testQAbstractItemModel(QAbstractItemModel* model, int rows, int columns)
    31 {
    36 {
    32     QVERIFY(model != 0);
    37     QVERIFY(model != 0);
    82     
    87     
    83     idx = model->parent(idx);
    88     idx = model->parent(idx);
    84     QVERIFY(idx.isValid() == false);
    89     QVERIFY(idx.isValid() == false);
    85     QVERIFY(model->columnCount() == columns);
    90     QVERIFY(model->columnCount() == columns);
    86     QVERIFY(model->rowCount() == rows);
    91     QVERIFY(model->rowCount() == rows);
    87     
    92         
    88 //    QVERIFY(model->hasChildren() == false);
       
    89 //    QVERIFY(model->headerData(0, Qt::Horizontal).isValid == false);
       
    90     
       
    91 }
    93 }
    92 
    94 
    93 void TestCacheProxy::initTestCase()
    95 void TestCacheProxy::initTestCase()
    94 {
    96 {
    95     bm = 0;
    97     bm = 0;
   153     delete bm;
   155     delete bm;
   154     
   156     
   155     totalsize = 100;
   157     totalsize = 100;
   156     bufferSize = 200;
   158     bufferSize = 200;
   157     bmh = new BMHelper(totalsize);
   159     bmh = new BMHelper(totalsize);
   158     bm = new HgBufferManager(bmh, bufferSize, 40, -20, totalsize);
   160     bm = new HgBufferManager(bmh, bufferSize, 40, 2*bufferSize, totalsize);    
       
   161     bufferSize = 300;
       
   162     bm->resizeCache(bufferSize, 20);
       
   163     bm->setPosition(5);
       
   164     QVERIFY(bmh->isIntergal(bufferSize));
       
   165     bm->setPosition(5000);
       
   166     QVERIFY(bmh->isIntergal(bufferSize));
   159     delete bmh;
   167     delete bmh;
   160     delete bm;
   168     delete bm;
   161 
   169 
       
   170     bmh = new BMHelper(totalsize);
       
   171     bm = new HgBufferManager(bmh, bufferSize, 40, -10, totalsize);
       
   172     delete bmh;
       
   173     delete bm;
       
   174     
       
   175     
   162     totalsize = 1000;
   176     totalsize = 1000;
   163     bufferSize = 100;
   177     bufferSize = 100;
   164     bmh = new BMHelper(totalsize);
   178     bmh = new BMHelper(totalsize);
   165     bm = new HgBufferManager(bmh, bufferSize, 40, 0, totalsize);
   179     bm = new HgBufferManager(bmh, bufferSize, 40, 0, totalsize);
   166     
   180     
   292 {
   306 {
   293     int totalsize = 1000;
   307     int totalsize = 1000;
   294     int bufferSize = 100;
   308     int bufferSize = 100;
   295     bmh = new BMHelper(totalsize);
   309     bmh = new BMHelper(totalsize);
   296     bm = new HgBufferManager(bmh, bufferSize, 40, 0, totalsize);    
   310     bm = new HgBufferManager(bmh, bufferSize, 40, 0, totalsize);    
       
   311     bm->aboutToRemoveItem(0);
       
   312     bmh->remove(0);
       
   313     bm->removedItem(0);
       
   314     QVERIFY(bmh->isIntergal(bufferSize));
   297     totalsize--;
   315     totalsize--;
   298     bmh->itemCountChanged(0, true, totalsize);    
   316     QCOMPARE(bmh->totalSize(), totalsize);
   299     bm->itemCountChanged(0, true, totalsize);
   317 
   300     QVERIFY(bmh->isIntergal(bufferSize));
   318     bm->aboutToRemoveItem(150);
   301 
   319     bmh->remove(150);
       
   320     bm->removedItem(150);
       
   321     QVERIFY(bmh->isIntergal(bufferSize));
   302     totalsize--;
   322     totalsize--;
   303     bmh->itemCountChanged(150, true, totalsize);
   323     QCOMPARE(bmh->totalSize(), totalsize);
   304     bm->itemCountChanged(150, true, totalsize);
   324 
   305     QVERIFY(bmh->isIntergal(bufferSize));
   325     bm->setPosition(100);
   306 
   326     bm->aboutToRemoveItem(150);
       
   327     bmh->remove(150);
       
   328     bm->removedItem(150);
       
   329     QVERIFY(bmh->isIntergal(bufferSize));
   307     totalsize--;
   330     totalsize--;
       
   331     QCOMPARE(bmh->totalSize(), totalsize);
       
   332 
       
   333     bm->setPosition(891);
       
   334     bm->aboutToRemoveItem(150);
       
   335     bmh->remove(150);
       
   336     bm->removedItem(150);
       
   337     QVERIFY(bmh->isIntergal(bufferSize));
       
   338     totalsize--;
       
   339     QCOMPARE(bmh->totalSize(), totalsize);
       
   340     
       
   341     bm->setPosition(0);
       
   342     bm->aboutToRemoveItem(150);
       
   343     bmh->remove(150);
       
   344     bm->removedItem(150);
       
   345     QVERIFY(bmh->isIntergal(bufferSize));
       
   346     totalsize--;
       
   347     QCOMPARE(bmh->totalSize(), totalsize);    
       
   348     
       
   349     bm->setPosition(900);
       
   350     bm->aboutToRemoveItem(890);
       
   351     bmh->remove(890);
       
   352     bm->removedItem(890);
       
   353     QVERIFY(bmh->isIntergal(bufferSize));
       
   354     totalsize--;
       
   355     QCOMPARE(bmh->totalSize(), totalsize);
       
   356     
       
   357     bm->setPosition(totalsize);
       
   358     bm->aboutToRemoveItem(totalsize);
       
   359     bmh->remove(totalsize);
       
   360     bm->removedItem(totalsize);
       
   361     QVERIFY(bmh->isIntergal(bufferSize));
       
   362 //    totalsize--;//no item remove since totalsize is outside
       
   363     QCOMPARE(bmh->totalSize(), totalsize);
       
   364     
       
   365     bm->setPosition(totalsize);
       
   366     bm->aboutToRemoveItem(totalsize-1);
       
   367     bmh->remove(totalsize-1);
       
   368     bm->removedItem(totalsize-1);
       
   369     QVERIFY(bmh->isIntergal(bufferSize));
       
   370     totalsize--;
       
   371     QCOMPARE(bmh->totalSize(), totalsize);
       
   372     
       
   373     bm->setPosition(totalsize+200);
       
   374     bm->aboutToRemoveItem(totalsize+200);
       
   375     bmh->remove(totalsize+200);
       
   376     bm->removedItem(totalsize+200);
       
   377     QVERIFY(bmh->isIntergal(bufferSize));
       
   378 //    totalsize--; //no item remove since totalsize+200 is outside
       
   379     QCOMPARE(bmh->totalSize(), totalsize);
       
   380     
       
   381     bm->aboutToRemoveItem(-20);
       
   382     bmh->remove(-20);
       
   383     bm->removedItem(-20);
       
   384     QVERIFY(bmh->isIntergal(bufferSize));
       
   385 //    totalsize--; //no item remove since totalsize+200 is outside
       
   386     QCOMPARE(bmh->totalSize(), totalsize);
       
   387     
       
   388     
       
   389     bm->aboutToRemoveItem(totalsize+10);
       
   390     bmh->remove(totalsize+10);
       
   391     bm->removedItem(totalsize+10);
       
   392     QVERIFY(bmh->isIntergal(bufferSize));
       
   393 //    totalsize--; //no item remove since totalsize+200 is outside
       
   394     QCOMPARE(bmh->totalSize(), totalsize);
       
   395 
       
   396     
       
   397     bm->resetBuffer(0, 10);
       
   398     bmh->resizeCache(10);
       
   399     bm->aboutToRemoveItem(1);
       
   400     bmh->remove(1);
       
   401     bm->removedItem(1);
       
   402     QCOMPARE(bmh->totalSize(), 9);
       
   403 
       
   404     bmh->resizeCache(totalsize);
       
   405     bm->resetBuffer(0, totalsize);
       
   406     
       
   407     //insert
       
   408     
       
   409     bm->setPosition(0);
       
   410     bm->aboutToInsertItem(0);
       
   411     bmh->insert(0); 
       
   412     bm->insertedItem(0);
       
   413     QVERIFY(bmh->isIntergal(bufferSize));
       
   414     totalsize++;
       
   415     QCOMPARE(bmh->totalSize(), totalsize);
       
   416     
       
   417     bm->aboutToInsertItem(50);
       
   418     bmh->insert(50);  
       
   419     bm->insertedItem(50);
       
   420     QVERIFY(bmh->isIntergal(bufferSize));
       
   421     totalsize++;
       
   422     QCOMPARE(bmh->totalSize(), totalsize);
       
   423     
   308     bm->setPosition(100);
   424     bm->setPosition(100);
   309     bmh->itemCountChanged(150, true, totalsize);
   425     bm->aboutToInsertItem(80);
   310     bm->itemCountChanged(150, true, totalsize);
   426     bmh->insert(80);   
   311     QVERIFY(bmh->isIntergal(bufferSize));
   427     bm->insertedItem(80);
   312 
   428     QVERIFY(bmh->isIntergal(bufferSize));
   313     totalsize--;
       
   314     bm->setPosition(891);
       
   315     bmh->itemCountChanged(150, true, totalsize);
       
   316     bm->itemCountChanged(150, true, totalsize);
       
   317     QVERIFY(bmh->isIntergal(bufferSize));
       
   318     
       
   319     totalsize--;
       
   320     bm->setPosition(900);
       
   321     bmh->itemCountChanged(890, true, totalsize);
       
   322     bm->itemCountChanged(890, true, totalsize);
       
   323     QVERIFY(bmh->isIntergal(bufferSize));
       
   324     
       
   325     totalsize--;
       
   326     bm->setPosition(totalsize);
       
   327     bmh->itemCountChanged(totalsize, true, totalsize);
       
   328     bm->itemCountChanged(totalsize, true, totalsize);
       
   329     QVERIFY(bmh->isIntergal(bufferSize));
       
   330     
       
   331     totalsize--;
       
   332     bm->setPosition(totalsize+200);
       
   333     bmh->itemCountChanged(totalsize+200, true, totalsize);
       
   334     bm->itemCountChanged(totalsize+200, true, totalsize);
       
   335     QVERIFY(bmh->isIntergal(bufferSize));
       
   336     
       
   337     
       
   338     totalsize= totalsize - 10;
       
   339     bm->setPosition(0);
       
   340     bmh->itemCountChanged(0, true, totalsize);
       
   341     bm->itemCountChanged(0, true, totalsize);
       
   342     QVERIFY(bmh->isIntergal(bufferSize));
       
   343     
       
   344     totalsize= totalsize - 10;
       
   345     bm->setPosition(totalsize);
       
   346     bmh->itemCountChanged(totalsize, true, totalsize);
       
   347     bm->itemCountChanged(totalsize, true, totalsize);
       
   348     QVERIFY(bmh->isIntergal(bufferSize));
       
   349     
       
   350     totalsize= totalsize - 10;
       
   351     bm->setPosition(totalsize/2);
       
   352     bmh->itemCountChanged(totalsize/2, true, totalsize);
       
   353     bm->itemCountChanged(totalsize/2, true, totalsize);
       
   354     QVERIFY(bmh->isIntergal(bufferSize));
       
   355     
       
   356     totalsize++;
   429     totalsize++;
   357     bm->setPosition(0);
   430     QCOMPARE(bmh->totalSize(), totalsize);
   358     bmh->itemCountChanged(0, false, totalsize);
   431     
   359     bm->itemCountChanged(0, false, totalsize);
       
   360     QVERIFY(bmh->isIntergal(bufferSize));
       
   361     
       
   362     totalsize++;    
       
   363     bmh->itemCountChanged(50, false, totalsize);
       
   364     bm->itemCountChanged(50, false, totalsize);
       
   365     QVERIFY(bmh->isIntergal(bufferSize));
       
   366     
       
   367     totalsize++;    
       
   368     bm->setPosition(100);
       
   369     bmh->itemCountChanged(80, false, totalsize);
       
   370     bm->itemCountChanged(80, false, totalsize);
       
   371     QVERIFY(bmh->isIntergal(bufferSize));
       
   372     
       
   373     totalsize++;    
       
   374     bm->setPosition(500);
   432     bm->setPosition(500);
   375     bmh->itemCountChanged(480, false, totalsize);
   433     bm->aboutToInsertItem(80);
   376     bm->itemCountChanged(480, false, totalsize);
   434     bmh->insert(80);   
   377     QVERIFY(bmh->isIntergal(bufferSize));
   435     bm->insertedItem(80);
   378     
   436     QVERIFY(bmh->isIntergal(bufferSize));
   379     totalsize++;    
   437     totalsize++;
       
   438     QCOMPARE(bmh->totalSize(), totalsize);    
       
   439     
       
   440     bm->setPosition(500);
       
   441     bm->aboutToInsertItem(480);
       
   442     bmh->insert(480); 
       
   443     bm->insertedItem(480);
       
   444     QVERIFY(bmh->isIntergal(bufferSize));
       
   445     totalsize++;
       
   446     QCOMPARE(bmh->totalSize(), totalsize);
       
   447     
   380     bm->setPosition(totalsize-20);
   448     bm->setPosition(totalsize-20);
   381     bmh->itemCountChanged(totalsize, false, totalsize);
   449     bm->aboutToInsertItem(totalsize);
   382     bm->itemCountChanged(totalsize, false, totalsize);
   450     bmh->insert(totalsize); 
   383     QVERIFY(bmh->isIntergal(bufferSize));
   451     bm->insertedItem(totalsize);
   384     
   452     QVERIFY(bmh->isIntergal(bufferSize));
   385     totalsize=totalsize+10;
   453     totalsize++;
       
   454     QCOMPARE(bmh->totalSize(), totalsize);
       
   455     
   386     bm->setPosition(totalsize-20);
   456     bm->setPosition(totalsize-20);
   387     bmh->itemCountChanged(totalsize, false, totalsize);
   457     bm->aboutToInsertItem(totalsize+20);
   388     bm->itemCountChanged(totalsize, false, totalsize);
   458     bmh->insert(totalsize+20); 
   389     QVERIFY(bmh->isIntergal(bufferSize));
   459     bm->insertedItem(totalsize+20);
   390     
   460     QVERIFY(bmh->isIntergal(bufferSize));
   391     totalsize=totalsize+10;
   461 //    totalsize++; //no insert
   392     bm->setPosition(20);
   462     QCOMPARE(bmh->totalSize(), totalsize);
   393     bmh->itemCountChanged(totalsize, false, totalsize);
   463 
   394     bm->itemCountChanged(totalsize, false, totalsize);
   464     bm->setPosition(2*totalsize);
   395     QVERIFY(bmh->isIntergal(bufferSize));
   465     bm->aboutToInsertItem(2*totalsize);
   396 
   466     bmh->insert(2*totalsize); 
   397     totalsize=totalsize+10;
   467     bm->insertedItem(2*totalsize);
   398     bm->setPosition(totalsize/2-20);
   468     QVERIFY(bmh->isIntergal(bufferSize));
   399     bmh->itemCountChanged(totalsize, false, totalsize);
   469 //    totalsize++; //no insert
   400     bm->itemCountChanged(totalsize, false, totalsize);
   470     QCOMPARE(bmh->totalSize(), totalsize);
   401     QVERIFY(bmh->isIntergal(bufferSize));   
   471 
       
   472     
   402 }
   473 }
   403 
   474 
   404 void TestCacheProxy::testBM_ResizeCache()
   475 void TestCacheProxy::testBM_ResizeCache()
   405 {
   476 {
   406     int totalsize = 1000;
   477     int totalsize = 1000;
   575 
   646 
   576     idx = dph->index(2, 0);
   647     idx = dph->index(2, 0);
   577     res = dph->data(idx, Qt::DecorationRole);
   648     res = dph->data(idx, Qt::DecorationRole);
   578     QVERIFY(res == dph->defaultIcon());    
   649     QVERIFY(res == dph->defaultIcon());    
   579     
   650     
       
   651     dph->testClearItem(2, false);
       
   652     updates = dph->getSignalDataUpdated();
       
   653     QVERIFY(updates.count() == 1); //1 update
       
   654     QVERIFY(updates[0].first == 2); //for 2
       
   655     QVERIFY(updates[0].second == 2); //for 2
       
   656     QVERIFY(dph->itemData(idx).count() == 0 ); //for 2
       
   657     
       
   658     QVERIFY(dph->itemData( dph->testCreateIndex(999999, 0)).count() == 0 );
       
   659 
       
   660     dph->testClearItem(2, true);
       
   661     updates = dph->getSignalDataUpdated();
       
   662     QVERIFY(updates.count() == 0); //no updates
       
   663     
       
   664     dph->testClearItem(-10, true);
       
   665     updates = dph->getSignalDataUpdated();
       
   666     QVERIFY(updates.count() == 0); //no updates
       
   667 
   580     idx = dph->index(3, 0);
   668     idx = dph->index(3, 0);
   581     res = dph->data(idx, Qt::DecorationRole);
   669     res = dph->data(idx, Qt::DecorationRole);
   582     QVERIFY(res == dph->defaultIcon());    
   670     QVERIFY(res == dph->defaultIcon());    
   583     dph->registerObserver(NULL);
   671     dph->registerObserver(NULL);
   584     dph->request(list);
   672     dph->request(list);
   621     QString s = "NEWITEM";
   709     QString s = "NEWITEM";
   622     list.append( QPair< QVariant, int >(s, Qt::DisplayRole) );
   710     list.append( QPair< QVariant, int >(s, Qt::DisplayRole) );
   623     
   711     
   624     dph->testUpdate(0, &list, false); //update shouldn't change - no item
   712     dph->testUpdate(0, &list, false); //update shouldn't change - no item
   625     dph->testUpdate(-1, &list, true); //update shouldn't change - no item
   713     dph->testUpdate(-1, &list, true); //update shouldn't change - no item
       
   714     dph->testUpdate(-1, s, Qt::DisplayRole, true); //update shouldn't change - no item
       
   715     dph->testUpdateIcon(-1, s);
   626     dph->testUpdate(120000, &list, false); //update shouldn't change - no item
   716     dph->testUpdate(120000, &list, false); //update shouldn't change - no item
   627     res = dph->data(idx, Qt::DisplayRole);
   717     res = dph->data(idx, Qt::DisplayRole);
   628     QVERIFY(res.isValid() == false);
   718     QVERIFY(res.isValid() == false);
   629     QVERIFY(dph->getObserverDataUpdated().count() == 0);
   719     QVERIFY(dph->getObserverDataUpdated().count() == 0);
   630 
   720     
   631     dph->testNewItem(&list, false);
   721     dph->testNewItem(&list, false);
   632     QList< QPair< int, int > > resList = dph->getSignalRowsAboutToBeInserted();
   722     QList< QPair< int, int > > resList = dph->getSignalRowsAboutToBeInserted();
   633     QVERIFY(resList.count() == 1);
   723     QVERIFY(resList.count() == 1);
   634     QVERIFY(resList[0].first == 0); //for item 0
   724     QVERIFY(resList[0].first == 0); //for item 0
   635     QVERIFY(resList[0].second == 0); //for item 0
   725     QVERIFY(resList[0].second == 0); //for item 0
   636     resList = dph->getSignalRowsInserted();
   726     resList = dph->getSignalRowsInserted();
   637     QVERIFY(resList.count() == 1);
   727     QVERIFY(resList.count() == 1);
   638     QVERIFY(resList[0].first == 0); //for item 0
   728     QVERIFY(resList[0].first == 0); //for item 0
   639     QVERIFY(resList[0].second == 0); //for item 0
   729     QVERIFY(resList[0].second == 0); //for item 0
       
   730 
       
   731     dph->testUpdateIcon(0, s, false);
       
   732     dph->testUpdateIcon(0, s, true);
       
   733     res = dph->data(idx, Qt::DecorationRole);
       
   734     QCOMPARE(res.isValid(), true);
       
   735     QVERIFY(res == s);
       
   736     QCOMPARE(dph->getSignalDataUpdated().count(), 1);
   640     
   737     
   641     QVERIFY(dph->rowCount() == 1);
   738     QVERIFY(dph->rowCount() == 1);
   642     
   739     
   643     idx = dph->index(0,0);
   740     idx = dph->index(0,0);
   644     res = dph->data(idx, Qt::DisplayRole);
   741     res = dph->data(idx, Qt::DisplayRole);
   741     QVERIFY(resList[0].first == 100);
   838     QVERIFY(resList[0].first == 100);
   742     QVERIFY(resList[0].second == 100); 
   839     QVERIFY(resList[0].second == 100); 
   743     
   840     
   744     dph->getSignalRowsInserted();
   841     dph->getSignalRowsInserted();
   745     dph->getSignalRowsRemoved();
   842     dph->getSignalRowsRemoved();
   746     dph->testInsertItem(-10, QPair< QVariant, int >(QString(""), Qt::DisplayRole), false); //insert with -10 puts it at begining
   843     dph->testInsertItem(0, QPair< QVariant, int >(QString(""), Qt::DisplayRole), false); //insert with 0 puts at begining
   747     resList = dph->getSignalRowsInserted();
   844     resList = dph->getSignalRowsInserted();
   748     QVERIFY(resList.count() == 1);
   845     QVERIFY(resList.count() == 1);    
   749     QVERIFY(resList[0].first == 0);
   846     QVERIFY(resList[0].first == 0);
   750     QVERIFY(resList[0].second == 0);
   847     QVERIFY(resList[0].second == 0);
       
   848     
       
   849     dph->getSignalRowsInserted();
       
   850     dph->getSignalRowsRemoved();
       
   851     dph->testInsertItem(-10, QPair< QVariant, int >(QString(""), Qt::DisplayRole), false); //insert with -10 not adds to collection
       
   852     resList = dph->getSignalRowsInserted();
       
   853     QVERIFY(resList.count() == 0);
   751     dph->testRemoveItem(-10);
   854     dph->testRemoveItem(-10);
   752     resList = dph->getSignalRowsRemoved();
   855     resList = dph->getSignalRowsRemoved();
   753     QVERIFY(resList.count() == 0);
   856     QVERIFY(resList.count() == 0);
   754 
   857     
   755     dph->getSignalRowsInserted();
   858     dph->getSignalRowsInserted();
   756     dph->getSignalRowsRemoved();
   859     dph->getSignalRowsRemoved();
   757     dph->testInsertItem(100000, QPair< QVariant, int >(QString(""), Qt::DisplayRole), false); //insert with beyond range puts it at end
   860     dph->testInsertItem(dph->rowCount(), QPair< QVariant, int >(QString(""), Qt::DisplayRole), false); //insert at dph->rowCount() puts at end
   758     resList = dph->getSignalRowsInserted();
   861     resList = dph->getSignalRowsInserted();
   759     QVERIFY(resList.count() == 1);
   862     QVERIFY(resList.count() == 1);
   760     QVERIFY(resList[0].first == dph->rowCount()-1);
   863     QVERIFY(resList[0].first == dph->rowCount()-1);
   761     QVERIFY(resList[0].second == dph->rowCount()-1);    
   864     QVERIFY(resList[0].second == dph->rowCount()-1);
       
   865     
       
   866     dph->getSignalRowsInserted();
       
   867     dph->getSignalRowsRemoved();
       
   868     dph->testInsertItem(100000, QPair< QVariant, int >(QString(""), Qt::DisplayRole), false); //insert with beyond range not adds to collection
       
   869     resList = dph->getSignalRowsInserted();
       
   870     QVERIFY(resList.count() == 0);
   762     dph->testRemoveItem(100000);
   871     dph->testRemoveItem(100000);
   763     resList = dph->getSignalRowsRemoved();
   872     resList = dph->getSignalRowsRemoved();
   764     QVERIFY(resList.count() == 0);
   873     QVERIFY(resList.count() == 0);
   765     
   874     
   766     idx = dph->index(579,0);
   875     idx = dph->index(579,0);
   767     QMap<int, QVariant> it = dph->itemData(idx);
   876     QMap<int, QVariant> it = dph->itemData(idx);
   768     QCOMPARE(it.size(), 4);
   877     QCOMPARE(it.size(), 4);
   769     QCOMPARE(it.contains(Qt::DisplayRole), true);
   878     QCOMPARE(it.contains(Qt::DisplayRole), true);
   770     QVariant r2 = it[Qt::DisplayRole];
   879     QVariant r2 = it[Qt::DisplayRole];
   771     QCOMPARE(r2.isValid(), true);
   880     QCOMPARE(r2.isValid(), true);
       
   881 
       
   882     idx = dph->index(-10,0);
       
   883     it = dph->itemData(idx);
       
   884     
   772     res = dph->data(idx, Qt::DisplayRole);
   885     res = dph->data(idx, Qt::DisplayRole);
   773     QCOMPARE(res.isValid(), true);
   886     QCOMPARE(res.isValid(), false);
   774     QCOMPARE(res.toString(), r2.toString());
   887 
   775     
       
   776 }
   888 }
   777 
   889 
   778 void TestCacheProxy::testDP_QPixmapPool()
   890 void TestCacheProxy::testDP_QPixmapPool()
   779 {
   891 {
   780     dph = new DataProviderHelper(100);
   892     dph = new DataProviderHelper(100);
   817     dph->testCreateIcon(4, pix);
   929     dph->testCreateIcon(4, pix);
   818     dph->testCreateIcon(6, pix);
   930     dph->testCreateIcon(6, pix);
   819     dph->resizeQPixmapPool(1);
   931     dph->resizeQPixmapPool(1);
   820     res = dph->testCreateIcon(10, pix);
   932     res = dph->testCreateIcon(10, pix);
   821     QVERIFY(res.isValid() == false);    
   933     QVERIFY(res.isValid() == false);    
       
   934     
       
   935     dph->resizeQPixmapPool(110);
       
   936     for ( int i = 0; i < 100; i ++)
       
   937         dph->testCreateIcon(i, pix);
       
   938     
       
   939     for ( int i = 20; i < 40; i ++)
       
   940         dph->testReleasePixmap(i);
       
   941     
       
   942     dph->resizeQPixmapPool(50);
       
   943     dph->testReleasePixmap(5);
       
   944     
       
   945     dph->resizeQPixmapPool(1);
       
   946     dph->testReleasePixmap(0);
       
   947     dph->testReleasePixmap(2);
       
   948     dph->testReleasePixmap(1);
       
   949     dph->resizeQPixmapPool(10);
       
   950 
       
   951     
       
   952     
       
   953 }
       
   954 
       
   955 void TestCacheProxy::testDP_IconMode()
       
   956 {
       
   957     dph = new DataProviderHelper(100);
       
   958     QCOMPARE( dph->testIconMode(), HgDataProviderModel::HgDataProviderIconHbIcon);
       
   959     dph->resizeQPixmapPool(10);
       
   960     QPixmap pix;
       
   961     QVariant res = dph->testCreateIcon(0, pix);
       
   962     QVERIFY(res.isValid() == true);
       
   963     QVERIFY(res.canConvert<HbIcon>());
       
   964     
       
   965     dph->testChangeIconMode(HgDataProviderModel::HgDataProviderIconHbIcon);
       
   966     res = dph->testCreateIcon(0, pix);
       
   967     QVERIFY(res.isValid() == true);
       
   968     QVERIFY(res.canConvert<HbIcon>());
       
   969     
       
   970     dph->testChangeIconMode(HgDataProviderModel::HgDataProviderIconQIcon);
       
   971     res = dph->testCreateIcon(0, pix);
       
   972     QVERIFY(res.isValid() == true);
       
   973     QVERIFY(res.canConvert<QIcon>());
       
   974     
       
   975     dph->testChangeIconMode(HgDataProviderModel::HgDataProviderIconQImage);
       
   976     res = dph->testCreateIcon(0, pix);
       
   977     QVERIFY(res.isValid() == true);
       
   978     QVERIFY(res.canConvert<QImage>());
       
   979     
       
   980     dph->testChangeIconMode(HgDataProviderModel::HgDataProviderIconQPixmap);
       
   981     res = dph->testCreateIcon(0, pix);
       
   982     QVERIFY(res.isValid() == true);
       
   983     QVERIFY(res.canConvert<QPixmap>());
       
   984     
       
   985     dph->testChangeIconMode( (HgDataProviderModel::HgDataProviderIconMode)10 );
       
   986     res = dph->testCreateIcon(0, pix);
       
   987     QVERIFY(res.isValid() == false);
   822 }
   988 }
   823 
   989 
   824 void TestCacheProxy::testCP_QAbstractItemModel()
   990 void TestCacheProxy::testCP_QAbstractItemModel()
   825 {
   991 {
   826     cp = new HgCacheProxyModel();
   992     cp = new HgCacheProxyModel();
   836     cp->setDataProvider(dph);
  1002     cp->setDataProvider(dph);
   837     QVERIFY(cp->DataProvider() == dph);
  1003     QVERIFY(cp->DataProvider() == dph);
   838 
  1004 
   839     cp->setDataProvider(dph);
  1005     cp->setDataProvider(dph);
   840     QVERIFY(cp->DataProvider() == dph);
  1006     QVERIFY(cp->DataProvider() == dph);
       
  1007     
       
  1008     QList< QPair< QVariant, int > > list;
       
  1009     QString s = "NEWITEM";
       
  1010     list.append( QPair< QVariant, int >(s, Qt::DisplayRole) );
       
  1011     dph->testNewItem(&list, false);
       
  1012     
       
  1013     dph->testRemoveItems(0, 1);//should remove item
       
  1014 
       
  1015     QModelIndex idx = cp->index(0,0);
       
  1016     QCOMPARE(cp->hasChildren(idx), true);
       
  1017     QSize s1 = cp->span(idx);
       
  1018     QSize s2 = cp->span(cp->index(1, 0));
       
  1019     QVERIFY(s1 == s2);
       
  1020     cp->submit();
       
  1021     cp->revert();
       
  1022     Qt::ItemFlags f1 = cp->flags(idx);
       
  1023     Qt::ItemFlags f2 = cp->flags(cp->index(1, 0));
       
  1024     QVERIFY(f1 == f2);
       
  1025     
       
  1026     QVariant res = cp->headerData(0, Qt::Horizontal, Qt::DecorationRole);
       
  1027     QCOMPARE(res.isValid(), false);
       
  1028     //default implementation ignores that
       
  1029     cp->setHeaderData(0, Qt::Horizontal, QString("headerdata"), Qt::DecorationRole);
       
  1030     res = cp->headerData(0, Qt::Horizontal, Qt::DecorationRole);
       
  1031     QCOMPARE(res.isValid(), false);
       
  1032     
       
  1033     QStringList li = cp->mimeTypes();
       
  1034     QCOMPARE(li.count(), 1);
       
  1035     
       
  1036     QModelIndexList li2;
       
  1037     li2<< idx;
       
  1038     QMimeData* md1 = cp->mimeData(li2);
       
  1039     QVERIFY(md1 != NULL);
       
  1040     QCOMPARE(cp->dropMimeData(NULL, Qt::MoveAction, 10, 0, QModelIndex() ), false);    
       
  1041     QCOMPARE(cp->supportedDragActions(), Qt::CopyAction);
       
  1042 
       
  1043     QCOMPARE(cp->canFetchMore(idx), false);
       
  1044     cp->fetchMore(idx);
       
  1045     
       
  1046     QModelIndex idx2 = cp->buddy(idx);
       
  1047     QCOMPARE(idx2.row(), idx.row());
       
  1048     QCOMPARE(idx2.column(), idx.column());
       
  1049     
       
  1050     li2 = cp->match(idx, Qt::DisplayRole, QString("ITEM"), 1000, Qt::MatchContains);
       
  1051     QCOMPARE(li2.count(), dph->getCount());
       
  1052 
       
  1053     
       
  1054     
       
  1055     cp->setDataProvider(NULL);
       
  1056     QVERIFY(cp->DataProvider() == NULL);
       
  1057     idx = cp->index(100,0);
       
  1058     res = dph->data(idx, Qt::DisplayRole);
       
  1059     QCOMPARE(res.isValid(), false);
       
  1060     
       
  1061     QCOMPARE(cp->insertRows(0, 10), false); //default implementation returns false
       
  1062     QCOMPARE(cp->removeRows(0, 10), false);//default implementation returns false
       
  1063 
       
  1064     QCOMPARE(cp->insertRow(0), false); //default implementation returns false
       
  1065     QCOMPARE(cp->removeRow(0), false);//default implementation returns false
       
  1066     
       
  1067     QCOMPARE(cp->insertColumns(0, 10), false); //default implementation returns false
       
  1068     QCOMPARE(cp->removeColumns(0, 10), false);//default implementation returns false
       
  1069 
       
  1070     QCOMPARE(cp->insertColumn(0), false); //default implementation returns false
       
  1071     QCOMPARE(cp->removeColumn(0), false);//default implementation returns false
       
  1072     
       
  1073     
   841 }
  1074 }
   842 
  1075 
   843 void TestCacheProxy::testCP_SignalsForward()
  1076 void TestCacheProxy::testCP_SignalsForward()
   844 {
  1077 {
   845     cp = new HgCacheProxyModel();
  1078     cp = new HgCacheProxyModel();
   846     cph = new CacheProxyHelper(cp);
  1079     cph = new CacheProxyHelper(cp);
   847     dph = new DataProviderHelper(200);    
  1080     dph = new DataProviderHelper(200);
   848     cp->setDataProvider(dph, 50, 20);
  1081     cp->setDataProvider(dph, 50, 20);
   849     
  1082     
   850     QList< QPair< int, int > > resList = cph->getSignalDataChanged();
  1083     QList< QPair< int, int > > resList = cph->getSignalDataChanged();
   851     QVERIFY(resList.count() == 50);
  1084     QVERIFY(resList.count() == 50);
   852     QVERIFY(resList[0].first == 0);
  1085     QVERIFY(resList[0].first == 0);
   882     cph->getSignalModelReset();
  1115     cph->getSignalModelReset();
   883     dph->resetModel();
  1116     dph->resetModel();
   884     QVERIFY(cph->getSignalModelAboutToBeReset() == true);
  1117     QVERIFY(cph->getSignalModelAboutToBeReset() == true);
   885     QVERIFY(cph->getSignalModelReset() == true);
  1118     QVERIFY(cph->getSignalModelReset() == true);
   886     QVERIFY(cp->columnCount() == 1);
  1119     QVERIFY(cp->columnCount() == 1);
   887     QVERIFY(cp->rowCount() == 1000);
  1120     QVERIFY(cp->rowCount() == 1000);    
   888 
  1121     
       
  1122     cph->getSignalDataChanged();
       
  1123     dph->testEmitDataChanged(dph->index(0,0), dph->index(10,0));
       
  1124     resList = cph->getSignalDataChanged();
       
  1125     QCOMPARE(resList.count(), 1);
       
  1126     QCOMPARE(resList[0].first, 0);
       
  1127     QCOMPARE(resList[0].second, 10);
       
  1128 
       
  1129     cph->getSignalColumnsAboutToBeInserted();
       
  1130     cph->getSignalColumnsInserted();
       
  1131     dph->testEmitColumnsInsert(dph->index(0,0),0, 10);
       
  1132     resList = cph->getSignalColumnsAboutToBeInserted();
       
  1133     QCOMPARE(resList.count(), 1);
       
  1134     QCOMPARE(resList[0].first, 0);
       
  1135     QCOMPARE(resList[0].second, 10);
       
  1136     resList = cph->getSignalColumnsInserted();
       
  1137     QCOMPARE(resList.count(), 1);
       
  1138     QCOMPARE(resList[0].first, 0);
       
  1139     QCOMPARE(resList[0].second, 10);
       
  1140 
       
  1141     cph->getSignalColumnsAboutToBeRemoved();
       
  1142     cph->getSignalColumnsRemoved();
       
  1143     dph->testEmitColumnsRemove(dph->index(0,0),0, 10);
       
  1144     resList = cph->getSignalColumnsAboutToBeRemoved();
       
  1145     QCOMPARE(resList.count(), 1);
       
  1146     QCOMPARE(resList[0].first, 0);
       
  1147     QCOMPARE(resList[0].second, 10);
       
  1148     resList = cph->getSignalColumnsRemoved();
       
  1149     QCOMPARE(resList.count(), 1);
       
  1150     QCOMPARE(resList[0].first, 0);
       
  1151     QCOMPARE(resList[0].second, 10);
       
  1152     
       
  1153 //    cph->getSignalColumnsAboutToBeMoved();
       
  1154 //    cph->getSignalColumnsMoved();
       
  1155 //    QCOMPARE(dph->testEmitColumnsAboutToBeMoved(0, 10), false);
       
  1156 //    resList = cph->getSignalColumnsAboutToBeMoved();
       
  1157 //    QCOMPARE(resList.count(), 0);
       
  1158     
       
  1159 //    dph->testEmitColumnsMoved(0, 10);
       
  1160 //    resList = cph->getSignalColumnsMoved();
       
  1161 //    QCOMPARE(resList.count(), 0);
       
  1162     
       
  1163     
       
  1164 //    cph->getSignalRowsAboutToBeMoved();
       
  1165 //    cph->getSignalRowsMoved();
       
  1166 //    QCOMPARE(dph->testEmitRowsAboutToBeMoved(0, 10), false);
       
  1167 //    resList = cph->getSignalRowsAboutToBeMoved();
       
  1168 //    QCOMPARE(resList.count(), 0);
       
  1169     
       
  1170 //    dph->testEmitRowsMoved(0, 10);
       
  1171 //    resList = cph->getSignalRowsMoved();
       
  1172 //    QCOMPARE(resList.count(), 0);
       
  1173     
       
  1174     
       
  1175     cph->getSignalHeaderDataChanged();
       
  1176     dph->testEmitHeaderDataChanged(Qt::Horizontal, 0, 0);
       
  1177     resList = cph->getSignalHeaderDataChanged();
       
  1178     QCOMPARE(resList.count(), 1);
       
  1179     QCOMPARE(resList[0].first, 0);
       
  1180     QCOMPARE(resList[0].second, 0);
       
  1181 
       
  1182     
   889 }
  1183 }
   890 
  1184 
   891 void TestCacheProxy::testCP_ResizeCache()
  1185 void TestCacheProxy::testCP_ResizeCache()
   892 {
  1186 {
   893     cp = new HgCacheProxyModel();
  1187     cp = new HgCacheProxyModel();
   894     cph = new CacheProxyHelper(cp);
  1188     cph = new CacheProxyHelper(cp);
   895     dph = new DataProviderHelper(200);
  1189     dph = new DataProviderHelper(200);
       
  1190     cp->resizeCache(100, 20);
   896     cp->setDataProvider(dph, 50, 20);
  1191     cp->setDataProvider(dph, 50, 20);
   897     dph->getLastRelease();
  1192     dph->getLastRelease();
   898     dph->getLastRequest();
  1193     dph->getLastRequest();
   899     cp->resizeCache(20, 5);
  1194     cp->resizeCache(20, 5);
   900     
  1195     
   969     map[v]=v;
  1264     map[v]=v;
   970     cp->setItemData(idx, map);
  1265     cp->setItemData(idx, map);
   971     res = cp->data(idx, v);
  1266     res = cp->data(idx, v);
   972     QCOMPARE(res.isValid(), true);
  1267     QCOMPARE(res.isValid(), true);
   973     QCOMPARE(res.toInt(), v);
  1268     QCOMPARE(res.toInt(), v);
   974 
  1269    
   975     
  1270     dph->getLastRelease();
       
  1271     dph->getLastRequest();
       
  1272     cp->release(0, 100);
       
  1273     QCOMPARE(dph->getLastRelease().count(), 101);
       
  1274     cp->release(-10, 0);
       
  1275     QCOMPARE(dph->getLastRelease().count(), 1);
       
  1276     cp->release(10, -10);
       
  1277     QCOMPARE(dph->getLastRelease().count(), 11);
       
  1278     cp->request(0, 100);
       
  1279     QCOMPARE(dph->getLastRequest().count(), 101);
       
  1280     cp->request(-10, 0);
       
  1281     QCOMPARE(dph->getLastRequest().count(), 1);
       
  1282     cp->request(-10, 10, HgBufferManagerObserver::HgRequestOrderDescending);
       
  1283     QCOMPARE(dph->getLastRequest().count(), 11);
       
  1284     
       
  1285     cp->setDataProvider(NULL, 50, 20);
       
  1286     res = cp->data(idx, v);
       
  1287     QCOMPARE(res.isValid(), false);
       
  1288     cp->request(0, 100, HgBufferManagerObserver::HgRequestOrderAscending);   
       
  1289     QCOMPARE(dph->getLastRequest().count(), 0);    
       
  1290     cp->release(0, 100);
       
  1291     QCOMPARE(dph->getLastRelease().count(), 0);
       
  1292 
   976 }
  1293 }
   977 
  1294 
   978 void TestCacheProxy::testCP_Sort()
  1295 void TestCacheProxy::testCP_Sort()
   979 {
  1296 {
   980     cp = new HgCacheProxyModel();
  1297     cp = new HgCacheProxyModel();
   982     dph = new DataProviderHelper(200);
  1299     dph = new DataProviderHelper(200);
   983     cp->setDataProvider(dph, 50, 20);
  1300     cp->setDataProvider(dph, 50, 20);
   984 
  1301 
   985     cp->setSortRole(Qt::UserRole+2);
  1302     cp->setSortRole(Qt::UserRole+2);
   986     QCOMPARE(cp->sortRole(), Qt::UserRole+2);
  1303     QCOMPARE(cp->sortRole(), Qt::UserRole+2);
       
  1304     cp->setSortRole(Qt::UserRole+2);
   987     cp->sort(0, Qt::AscendingOrder);
  1305     cp->sort(0, Qt::AscendingOrder);
   988     QCOMPARE(cp->sortColumn(), 0);
  1306     QCOMPARE(cp->sortColumn(), 0);
   989     QCOMPARE(cp->sortOrder(), Qt::AscendingOrder);
  1307     QCOMPARE(cp->sortOrder(), Qt::AscendingOrder);
   990     
  1308     
   991     QModelIndex idx = cp->index(10, 0);
  1309     QModelIndex idx = cp->index(10, 0);
  1005     QCOMPARE(res.toInt(), cp->rowCount(idx) -1 -50);
  1323     QCOMPARE(res.toInt(), cp->rowCount(idx) -1 -50);
  1006     
  1324     
  1007     cp->setSortRole(Qt::DisplayRole);
  1325     cp->setSortRole(Qt::DisplayRole);
  1008     cp->setSortCaseSensitivity(Qt::CaseSensitive);
  1326     cp->setSortCaseSensitivity(Qt::CaseSensitive);
  1009     QCOMPARE(cp->sortCaseSensitivity(), Qt::CaseSensitive);
  1327     QCOMPARE(cp->sortCaseSensitivity(), Qt::CaseSensitive);
       
  1328     cp->setSortCaseSensitivity(Qt::CaseSensitive);
       
  1329     cp->setSortCaseSensitivity(Qt::CaseInsensitive);
       
  1330     cp->setSortCaseSensitivity(Qt::CaseSensitive);
  1010     cp->sort(0, Qt::AscendingOrder);
  1331     cp->sort(0, Qt::AscendingOrder);
  1011     
  1332     
  1012     idx = cp->index(10, 0);
  1333     idx = cp->index(10, 0);
  1013     res = cp->data(idx, Qt::UserRole+1);
  1334     res = cp->data(idx, Qt::UserRole+1);
  1014     QCOMPARE(res.isValid(), true);
  1335     QCOMPARE(res.isValid(), true);
  1020 //    qWarning("i=%d",res.toInt());
  1341 //    qWarning("i=%d",res.toInt());
  1021     QCOMPARE(res.toInt()%2, 1);
  1342     QCOMPARE(res.toInt()%2, 1);
  1022     
  1343     
  1023     cp->setSortLocaleAware(true);
  1344     cp->setSortLocaleAware(true);
  1024     QCOMPARE(cp->isSortLocaleAware(), true);
  1345     QCOMPARE(cp->isSortLocaleAware(), true);
       
  1346     cp->setSortLocaleAware(true);
  1025     cp->setSortLocaleAware(false);
  1347     cp->setSortLocaleAware(false);
  1026     QCOMPARE(cp->isSortLocaleAware(), false);
  1348     QCOMPARE(cp->isSortLocaleAware(), false);
  1027         
  1349         
  1028     QString s = QString("AAA");
  1350     QString s = QString("AAA");
  1029     cp->setDynamicSortFilter(true);
  1351     cp->setDynamicSortFilter(true);
  1030     QCOMPARE(cp->dynamicSortFilter(), true);
  1352     QCOMPARE(cp->dynamicSortFilter(), true);
       
  1353     cp->setDynamicSortFilter(true);
  1031     cp->setSortRole(Qt::DisplayRole);
  1354     cp->setSortRole(Qt::DisplayRole);
  1032     cp->setSortCaseSensitivity(Qt::CaseSensitive);
  1355     cp->setSortCaseSensitivity(Qt::CaseSensitive);
  1033     dph->testInsertItem(10, QPair< QVariant, int >(s, Qt::DisplayRole), false);
  1356     dph->testInsertItem(10, QPair< QVariant, int >(s, Qt::DisplayRole), false);
  1034     idx = cp->index(0, 0);
  1357     idx = cp->index(0, 0);
  1035     res = cp->data(idx, Qt::DisplayRole);
  1358     res = cp->data(idx, Qt::DisplayRole);
  1053     
  1376     
  1054     QRegExp regexp = QRegExp("ITEM*", Qt::CaseSensitive, QRegExp::Wildcard);
  1377     QRegExp regexp = QRegExp("ITEM*", Qt::CaseSensitive, QRegExp::Wildcard);
  1055     
  1378     
  1056     cp->setFilterRegExp(regexp);
  1379     cp->setFilterRegExp(regexp);
  1057     QVERIFY(cp->filterRegExp() == regexp);
  1380     QVERIFY(cp->filterRegExp() == regexp);
       
  1381     cp->setFilterRegExp(regexp);
  1058     cp->setFilterCaseSensitivity(Qt::CaseSensitive);
  1382     cp->setFilterCaseSensitivity(Qt::CaseSensitive);
  1059     QCOMPARE(cp->filterCaseSensitivity(), Qt::CaseSensitive);   
  1383     QCOMPARE(cp->filterCaseSensitivity(), Qt::CaseSensitive);   
       
  1384     cp->setFilterCaseSensitivity(Qt::CaseSensitive);
       
  1385     cp->setFilterCaseSensitivity(Qt::CaseInsensitive);
       
  1386     cp->setFilterCaseSensitivity(Qt::CaseSensitive);
  1060     
  1387     
  1061     idx = cp->index(1, 0);
  1388     idx = cp->index(1, 0);
  1062     res = cp->data(idx, Qt::DisplayRole);
  1389     res = cp->data(idx, Qt::DisplayRole);
  1063     QCOMPARE(res.isValid(), true);
  1390     QCOMPARE(res.isValid(), true);
  1064     QCOMPARE(res.toString().startsWith("item"), false);
  1391     QCOMPARE(res.toString().startsWith("item"), false);
  1065     
  1392     
  1066     cp->setFilterKeyColumn(1);
  1393     cp->setFilterKeyColumn(1);
  1067     QCOMPARE(cp->filterKeyColumn (), 1);
  1394     QCOMPARE(cp->filterKeyColumn (), 1);
       
  1395     cp->setFilterKeyColumn(1);
  1068     cp->setFilterKeyColumn(0);
  1396     cp->setFilterKeyColumn(0);
  1069     
  1397     
  1070     cp->setFilterRole(Qt::UserRole+1);
  1398     cp->setFilterRole(Qt::UserRole+1);
  1071     QCOMPARE(cp->filterRole(), Qt::UserRole+1);
  1399     QCOMPARE(cp->filterRole(), Qt::UserRole+1);
       
  1400     cp->setFilterRole(Qt::UserRole+1);
  1072     cp->setFilterRole(Qt::DisplayRole);     
  1401     cp->setFilterRole(Qt::DisplayRole);     
  1073     
  1402     
  1074     regexp = QRegExp("ITEM*", Qt::CaseInsensitive, QRegExp::Wildcard);
  1403     regexp = QRegExp("ITEM*", Qt::CaseInsensitive, QRegExp::Wildcard);
  1075     cp->setFilterRegExp(regexp);
  1404     cp->setFilterRegExp(regexp);
  1076     QVERIFY(cp->filterRegExp() == regexp);
  1405     QVERIFY(cp->filterRegExp() == regexp);
  1077     cp->setFilterCaseSensitivity(Qt::CaseInsensitive);
  1406     cp->setFilterCaseSensitivity(Qt::CaseInsensitive);
  1078     QCOMPARE(cp->filterCaseSensitivity(), Qt::CaseInsensitive);   
  1407     QCOMPARE(cp->filterCaseSensitivity(), Qt::CaseInsensitive);   
       
  1408     cp->setFilterCaseSensitivity(Qt::CaseInsensitive);
  1079 
  1409 
  1080     idx = cp->index(1, 0);
  1410     idx = cp->index(1, 0);
  1081     res = cp->data(idx, Qt::DisplayRole);
  1411     res = cp->data(idx, Qt::DisplayRole);
  1082     QCOMPARE(res.isValid(), true);
  1412     QCOMPARE(res.isValid(), true);
  1083     QCOMPARE(res.toString().startsWith("item"), true);
  1413     QCOMPARE(res.toString().startsWith("item"), true);