Differential D8903 Diff 22614 kdevplatform/language/backgroundparser/tests/test_backgroundparser.cpp
Changeset View
Changeset View
Standalone View
Standalone View
kdevplatform/language/backgroundparser/tests/test_backgroundparser.cpp
Show First 20 Lines • Show All 78 Lines • ▼ Show 20 Line(s) | 72 | { | |||
---|---|---|---|---|---|
79 | Q_ASSERT(testJob); | 79 | Q_ASSERT(testJob); | ||
80 | 80 | | |||
81 | qDebug() << "assigning propierties for created job" << testJob->document().toUrl(); | 81 | qDebug() << "assigning propierties for created job" << testJob->document().toUrl(); | ||
82 | testJob->duration_ms = jobForUrl(testJob->document()).m_duration; | 82 | testJob->duration_ms = jobForUrl(testJob->document()).m_duration; | ||
83 | 83 | | |||
84 | m_createdJobs.append(testJob->document()); | 84 | m_createdJobs.append(testJob->document()); | ||
85 | } | 85 | } | ||
86 | 86 | | |||
87 | bool JobPlan::runJobs(int timeoutMS) | 87 | void JobPlan::addJobsToParser() | ||
88 | { | 88 | { | ||
89 | // add parse jobs | 89 | // add parse jobs | ||
90 | foreach(const JobPrototype& job, m_jobs) { | 90 | foreach(const JobPrototype& job, m_jobs) { | ||
91 | ICore::self()->languageController()->backgroundParser()->addDocument( | 91 | ICore::self()->languageController()->backgroundParser()->addDocument( | ||
92 | job.m_url, TopDUContext::Empty, job.m_priority, this, job.m_flags | 92 | job.m_url, TopDUContext::Empty, job.m_priority, this, job.m_flags | ||
93 | ); | 93 | ); | ||
94 | } | 94 | } | ||
95 | } | ||||
96 | | ||||
97 | bool JobPlan::runJobs(int timeoutMS) | ||||
98 | { | ||||
99 | addJobsToParser(); | ||||
95 | 100 | | |||
96 | ICore::self()->languageController()->backgroundParser()->parseDocuments(); | 101 | ICore::self()->languageController()->backgroundParser()->parseDocuments(); | ||
97 | 102 | | |||
98 | QElapsedTimer t; | 103 | QElapsedTimer t; | ||
99 | t.start(); | 104 | t.start(); | ||
100 | 105 | | |||
101 | while ( !t.hasExpired(timeoutMS) && m_jobs.size() != m_finishedJobs.size() ) { | 106 | while ( !t.hasExpired(timeoutMS) && m_jobs.size() != m_finishedJobs.size() ) { | ||
102 | QTest::qWait(50); | 107 | QTest::qWait(50); | ||
▲ Show 20 Lines • Show All 88 Lines • ▼ Show 20 Line(s) | 195 | { | |||
191 | m_jobPlan.clear(); | 196 | m_jobPlan.clear(); | ||
192 | // prove that background parsing happens with sequential flags although there is a high-priority | 197 | // prove that background parsing happens with sequential flags although there is a high-priority | ||
193 | // foreground thread (active document being edited, ...) running all the time. | 198 | // foreground thread (active document being edited, ...) running all the time. | ||
194 | 199 | | |||
195 | // the long-running high-prio job | 200 | // the long-running high-prio job | ||
196 | m_jobPlan.addJob(JobPrototype(QUrl::fromLocalFile(QStringLiteral("/test_fgt_hp.txt")), | 201 | m_jobPlan.addJob(JobPrototype(QUrl::fromLocalFile(QStringLiteral("/test_fgt_hp.txt")), | ||
197 | -500, ParseJob::IgnoresSequentialProcessing, 1000)); | 202 | -500, ParseJob::IgnoresSequentialProcessing, 1000)); | ||
198 | 203 | | |||
199 | // add parse jobs | 204 | m_jobPlan.addJobsToParser(); | ||
200 | foreach(const JobPrototype& job, m_jobPlan.m_jobs) { | | |||
201 | ICore::self()->languageController()->backgroundParser()->addDocument( | | |||
202 | job.m_url, TopDUContext::Empty, job.m_priority, this, job.m_flags | | |||
203 | ); | | |||
204 | } | | |||
205 | 205 | | |||
206 | ICore::self()->languageController()->backgroundParser()->parseDocuments(); | 206 | ICore::self()->languageController()->backgroundParser()->parseDocuments(); | ||
207 | QTest::qWait(50); | 207 | QTest::qWait(50); | ||
208 | 208 | | |||
209 | // shut down with running jobs, make sure we don't crash | 209 | // shut down with running jobs, make sure we don't crash | ||
210 | cleanupTestCase(); | 210 | cleanupTestCase(); | ||
211 | 211 | | |||
212 | // restart again to restore invariant (core always running in test functions) | 212 | // restart again to restore invariant (core always running in test functions) | ||
▲ Show 20 Lines • Show All 175 Lines • Show Last 20 Lines |