| 196 | } |
| 197 | |
| 198 | void TestWorkingSetController::restoreSplits() |
| 199 | { |
| 200 | // we need to show the window to calculate actual widget sizes |
| 201 | m_mainWindow->show(); |
| 202 | |
| 203 | // Create a persistent working set with 4 split views |
| 204 | m_area->setWorkingSet(setName); |
| 205 | auto set2 = m_workingSetCtrl->workingSet(m_area->workingSet()); |
| 206 | set2->setPersistent(true); |
| 207 | auto doc = m_documentCtrl->openDocument(QUrl::fromLocalFile(m_file.fileName())); |
| 208 | |
| 209 | // Split view |
| 210 | auto view_bottom_left = dynamic_cast<Sublime::Document*>(doc)->createView(); |
| 211 | m_area->addView(view_bottom_left, m_area->activeView(), Qt::Vertical); |
| 212 | auto view_top_right = dynamic_cast<Sublime::Document*>(doc)->createView(); |
| 213 | m_area->addView(view_top_right, m_area->activeView(), Qt::Horizontal); |
| 214 | auto view_bottom_right = dynamic_cast<Sublime::Document*>(doc)->createView(); |
| 215 | m_area->addView(view_bottom_right, view_bottom_left, Qt::Horizontal); |
| 216 | |
| 217 | // required to arrange the view widgets in the window |
| 218 | QApplication::processEvents(); |
| 219 | |
| 220 | QSet<Sublime::AreaIndex*> indices; |
| 221 | for (auto &view : m_area->views()) { |
| 222 | indices.insert(m_area->indexOf(view)); |
| 223 | } |
| 224 | QCOMPARE(indices.size(), 4); // number of view containers |
| 225 | |
| 226 | auto *splitter_bottom = qobject_cast<QSplitter*>(view_bottom_left->widget() |
| 227 | ->parentWidget() |
| 228 | ->parentWidget() // view container |
| 229 | ->parentWidget() // splitter containing a single container |
| 230 | ->parentWidget()); // splitter containing lower containers |
| 231 | QVERIFY(splitter_bottom); |
| 232 | |
| 233 | QVERIFY(splitter_bottom->isVisible()); |
| 234 | // ensure the splitter handle is visible, which is esp. required for running the test with the offscreen QPA |
| 235 | splitter_bottom->handle(0)->setVisible(true); |
| 236 | QVERIFY(splitter_bottom->handle(0)->isVisible()); |
| 237 | |
| 238 | QApplication::processEvents(); |
| 239 | |
| 240 | splitter_bottom->setSizes({1, 1000}); |
| 241 | auto sizes_bottom = splitter_bottom->sizes(); |
| 242 | QVERIFY(sizes_bottom.at(0) < sizes_bottom.at(1)); |
| 243 | |
| 244 | auto *splitter_mid = qobject_cast<QSplitter*>(splitter_bottom->parentWidget()); |
| 245 | QVERIFY(splitter_mid); |
| 246 | splitter_mid->setSizes({1, 1000}); |
| 247 | auto sizes_mid = splitter_mid->sizes(); |
| 248 | QVERIFY(sizes_mid.at(0) < sizes_mid.at(1)); |
| 249 | |
| 250 | QVERIFY(!qobject_cast<QSplitter*>(splitter_mid->parentWidget())); |
| 251 | |
| 252 | // Create and activate another persistent working set with a single view |
| 253 | m_area->setWorkingSet(setName2); |
| 254 | auto set = m_workingSetCtrl->workingSet(m_area->workingSet()); |
| 255 | set->setPersistent(true); |
nothing calls this directly
no test coverage detected