@@ -611,7 +611,26 @@ private slots:
611611 model.addToFavorites (model.index (0 , 0 , processesIndex));
612612 QCOMPARE (proxy.rowCount (), 3 );
613613
614+ {
615+ // verify that favorites remain at the top
616+ QCOMPARE (proxy.sortOrder (), Qt::AscendingOrder);
617+ QCOMPARE (proxy.sortColumn (), 0 );
618+
619+ // favorites on top
620+ QVERIFY (proxy.index (0 , 0 , proxy.index (0 , 0 )).data (EventModel::IsFavoriteRole).toBool ());
621+ // followed by CPUs
622+ QCOMPARE (proxy.index (0 , 0 , proxy.index (1 , 0 )).data (EventModel::CpuIdRole).value <quint32>(), 1 );
623+
624+ proxy.sort (0 , Qt::DescendingOrder);
625+
626+ // favorites are still on top
627+ QVERIFY (proxy.index (0 , 0 , proxy.index (0 , 0 )).data (EventModel::IsFavoriteRole).toBool ());
628+ // followed by processes
629+ QCOMPARE (proxy.index (0 , 0 , proxy.index (1 , 0 )).data (EventModel::ProcessIdRole).value <quint32>(), 5678 );
630+ }
631+
614632 model.removeFromFavorites (model.index (0 , 0 , favoritesIndex));
633+
615634 QCOMPARE (proxy.rowCount (), 2 );
616635 }
617636
@@ -862,9 +881,9 @@ private slots:
862881 {
863882 Data::EventResults events;
864883 events.cpus .resize (3 );
865- events.cpus [0 ].cpuId = 0 ;
866- events.cpus [1 ].cpuId = 1 ; // empty
867- events.cpus [2 ].cpuId = 2 ;
884+ events.cpus [0 ].cpuId = 1 ;
885+ events.cpus [1 ].cpuId = 2 ; // empty
886+ events.cpus [2 ].cpuId = 3 ;
868887
869888 const quint64 endTime = 1000 ;
870889 const quint64 deltaTime = 10 ;
@@ -907,13 +926,13 @@ private slots:
907926 event.time = time;
908927 ++costSummary.sampleCount ;
909928 costSummary.totalPeriod += event.cost ;
910- events.cpus [cpuId].events << event;
929+ events.cpus [cpuId - 1 ].events << event;
911930 return event;
912931 };
913932 for (quint64 time = 0 ; time < endTime; time += deltaTime) {
914- thread1.events << generateEvent (time, 0 );
933+ thread1.events << generateEvent (time, 1 );
915934 if (thread2.time .contains (time)) {
916- thread2.events << generateEvent (time, 2 );
935+ thread2.events << generateEvent (time, 3 );
917936 }
918937 }
919938 events.totalCosts = {costSummary};
0 commit comments