MCPcopy Create free account
hub / github.com/KDE/kdevelop / viewActivation

Method viewActivation

kdevplatform/sublime/tests/test_viewactivation.cpp:126–183  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

124}
125
126void TestViewActivation::viewActivation()
127{
128 auto* mw = new MainWindow(controller);
129 controller->addDefaultArea(area); // Q_ASSERT without this.
130 controller->addMainWindow(mw);
131
132 controller->showArea(area, mw);
133 //we should have an active view immediately after the area is shown
134 QCOMPARE(mw->activeView(), view211);
135
136 //add some widgets that are not in layout
137 auto *breaker = new QTextEdit(mw);
138 breaker->setObjectName(QStringLiteral("breaker"));
139 auto *toolBreaker = new QTextEdit(mw);
140 toolBreaker->setObjectName(QStringLiteral("toolBreaker"));
141
142 auto* dock = new QDockWidget(mw);
143 dock->setWidget(toolBreaker);
144 mw->addDockWidget(Qt::LeftDockWidgetArea, dock);
145
146 QFocusEvent focusEvent(QEvent::FocusIn);
147 //now post events to the widgets and see if mainwindow has the right active views
148 //activate view
149 QVERIFY(view212->widget());
150 qApp->sendEvent(view212->widget(), &focusEvent);
151 QString failMsg = QStringLiteral("\nWas expecting %1 to be active but got %2").
152 arg(view212->objectName(), mw->activeView()->objectName());
153 QVERIFY2(mw->activeView() == view212, failMsg.toLatin1().data());
154
155 //activate tool view and check that both view and tool view are active
156 QVERIFY(viewT31->widget());
157 qApp->sendEvent(viewT31->widget(), &focusEvent);
158 QCOMPARE(mw->activeView(), view212);
159 QCOMPARE(mw->activeToolView(), viewT31);
160
161 //active another view
162 QVERIFY(view241->widget());
163 qApp->sendEvent(view241->widget(), &focusEvent);
164 QCOMPARE(mw->activeView(), view241);
165 QCOMPARE(mw->activeToolView(), viewT31);
166
167 //focus a widget not in the area
168 qApp->sendEvent(breaker, &focusEvent);
169 QCOMPARE(mw->activeView(), view241);
170 QCOMPARE(mw->activeToolView(), viewT31);
171
172 //focus a dock not in the area
173 qApp->sendEvent(toolBreaker, &focusEvent);
174 QCOMPARE(mw->activeView(), view241);
175 QCOMPARE(mw->activeToolView(), viewT31);
176
177 //focus inner widget for view221
178 auto *inner = mw->findChild<QListView*>(QStringLiteral("doc2_inner"));
179 QVERIFY(inner);
180 qApp->sendEvent(inner, &focusEvent);
181 QCOMPARE(mw->activeView(), view221);
182 QCOMPARE(mw->activeToolView(), viewT31);
183}

Callers

nothing calls this directly

Calls 8

addDefaultAreaMethod · 0.80
addMainWindowMethod · 0.80
showAreaMethod · 0.80
setWidgetMethod · 0.80
activeToolViewMethod · 0.80
activeViewMethod · 0.45
widgetMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected