292 { |
292 { |
293 int totalsize = 1000; |
293 int totalsize = 1000; |
294 int bufferSize = 100; |
294 int bufferSize = 100; |
295 bmh = new BMHelper(totalsize); |
295 bmh = new BMHelper(totalsize); |
296 bm = new HgBufferManager(bmh, bufferSize, 40, 0, totalsize); |
296 bm = new HgBufferManager(bmh, bufferSize, 40, 0, totalsize); |
297 |
|
298 totalsize--; |
297 totalsize--; |
299 bmh->itemCountChanged(0, true, totalsize); |
298 bmh->itemCountChanged(0, true, totalsize); |
300 bm->itemCountChanged(0, true, totalsize); |
299 bm->itemCountChanged(0, true, totalsize); |
301 QVERIFY(bmh->isIntergal(bufferSize)); |
300 QVERIFY(bmh->isIntergal(bufferSize)); |
302 |
301 |
303 totalsize--; |
302 totalsize--; |
304 bmh->itemCountChanged(150, true, totalsize); |
303 bmh->itemCountChanged(150, true, totalsize); |
1032 // qWarning()<<res.toString(); |
1037 // qWarning()<<res.toString(); |
1033 QCOMPARE(res.toString(), s); |
1038 QCOMPARE(res.toString(), s); |
1034 |
1039 |
1035 } |
1040 } |
1036 |
1041 |
1037 //void TestCacheProxy::testCP_Filter() |
1042 void TestCacheProxy::testCP_Filter() |
1038 //{ |
1043 { |
1039 // cp = new HgCacheProxyModel(); |
1044 cp = new HgCacheProxyModel(); |
1040 // cph = new CacheProxyHelper(cp); |
1045 cph = new CacheProxyHelper(cp); |
1041 // dph = new DataProviderHelper(200); |
1046 dph = new DataProviderHelper(200); |
1042 // cp->setDataProvider(dph, 50, 20); |
1047 cp->setDataProvider(dph, 50, 20); |
1043 // |
1048 |
1044 // QModelIndex idx = cp->index(1, 0); |
1049 QModelIndex idx = cp->index(1, 0); |
1045 // QVariant res = cp->data(idx, Qt::DisplayRole); |
1050 QVariant res = cp->data(idx, Qt::DisplayRole); |
1046 // QCOMPARE(res.isValid(), true); |
1051 QCOMPARE(res.isValid(), true); |
1047 // QCOMPARE(res.toString().startsWith("item"), true); |
1052 QCOMPARE(res.toString().startsWith("item"), true); |
1048 // |
1053 |
1049 // QRegExp regexp = QRegExp("ITEM*", Qt::CaseSensitive, QRegExp::Wildcard); |
1054 QRegExp regexp = QRegExp("ITEM*", Qt::CaseSensitive, QRegExp::Wildcard); |
1050 // |
1055 |
1051 // cp->setFilterRegExp(regexp); |
1056 cp->setFilterRegExp(regexp); |
1052 // QVERIFY(cp->filterRegExp() == regexp); |
1057 QVERIFY(cp->filterRegExp() == regexp); |
1053 // cp->setFilterCaseSensitivity(Qt::CaseSensitive); |
1058 cp->setFilterCaseSensitivity(Qt::CaseSensitive); |
1054 // QCOMPARE(cp->filterCaseSensitivity(), Qt::CaseSensitive); |
1059 QCOMPARE(cp->filterCaseSensitivity(), Qt::CaseSensitive); |
1055 // |
1060 |
1056 // idx = cp->index(1, 0); |
1061 idx = cp->index(1, 0); |
1057 // res = cp->data(idx, Qt::DisplayRole); |
1062 res = cp->data(idx, Qt::DisplayRole); |
1058 // QCOMPARE(res.isValid(), true); |
1063 QCOMPARE(res.isValid(), true); |
1059 // QCOMPARE(res.toString().startsWith("item"), false); |
1064 QCOMPARE(res.toString().startsWith("item"), false); |
1060 // |
1065 |
1061 // cp->setFilterKeyColumn(1); |
1066 cp->setFilterKeyColumn(1); |
1062 // QCOMPARE(cp->filterKeyColumn (), 1); |
1067 QCOMPARE(cp->filterKeyColumn (), 1); |
1063 // cp->setFilterKeyColumn(0); |
1068 cp->setFilterKeyColumn(0); |
1064 // |
1069 |
1065 // cp->setFilterRole(Qt::UserRole+1); |
1070 cp->setFilterRole(Qt::UserRole+1); |
1066 // QCOMPARE(cp->filterRole(), Qt::UserRole+1); |
1071 QCOMPARE(cp->filterRole(), Qt::UserRole+1); |
1067 // cp->setFilterRole(Qt::DisplayRole); |
1072 cp->setFilterRole(Qt::DisplayRole); |
1068 // |
1073 |
1069 // regexp = QRegExp("ITEM*", Qt::CaseInsensitive, QRegExp::Wildcard); |
1074 regexp = QRegExp("ITEM*", Qt::CaseInsensitive, QRegExp::Wildcard); |
1070 // cp->setFilterRegExp(regexp); |
1075 cp->setFilterRegExp(regexp); |
1071 // QVERIFY(cp->filterRegExp() == regexp); |
1076 QVERIFY(cp->filterRegExp() == regexp); |
1072 // cp->setFilterCaseSensitivity(Qt::CaseInsensitive); |
1077 cp->setFilterCaseSensitivity(Qt::CaseInsensitive); |
1073 // QCOMPARE(cp->filterCaseSensitivity(), Qt::CaseInsensitive); |
1078 QCOMPARE(cp->filterCaseSensitivity(), Qt::CaseInsensitive); |
1074 // |
1079 |
1075 // idx = cp->index(1, 0); |
1080 idx = cp->index(1, 0); |
1076 // res = cp->data(idx, Qt::DisplayRole); |
1081 res = cp->data(idx, Qt::DisplayRole); |
1077 // QCOMPARE(res.isValid(), true); |
1082 QCOMPARE(res.isValid(), true); |
1078 // QCOMPARE(res.toString().startsWith("item"), true); |
1083 QCOMPARE(res.toString().startsWith("item"), true); |
1079 // |
1084 |
1080 //} |
1085 } |
1081 |
1086 |
1082 |
1087 |
1083 #ifdef _CACHEPROXYDATAMODEL_UNITTEST_LOG_TO_C |
1088 #ifdef _CACHEPROXYDATAMODEL_UNITTEST_LOG_TO_C |
1084 int main (int argc, char* argv[]) |
1089 int main (int argc, char* argv[]) |
1085 { |
1090 { |
1086 QApplication app(argc, argv); |
1091 QApplication app(argc, argv); |
1087 TestCacheProxy tc; |
1092 TestCacheProxy tc; |
1088 int c = 3; |
1093 int c = 5; |
1089 char* v[] = {argv[0], "-o", "c:/test.txt"}; |
1094 char* v[] = {argv[0], "-o", "c:/test.txt", "-maxwarnings", "0"}; |
1090 return QTest::qExec(&tc, c, v); |
1095 return QTest::qExec(&tc, c, v); |
1091 } |
1096 } |
1092 #else |
1097 #else |
1093 QTEST_MAIN(TestCacheProxy) |
1098 QTEST_MAIN(TestCacheProxy) |
1094 #endif |
1099 #endif |