on xenial help sign in
added test
commit3bf02b21a41410c037630fd56b6794c8f2234864 authorNick Dedekind <nick.dedekind@canonical.com> dateFri 6 May 2016, 16:23 (10 years ago) parent72d3358
2 files changed+38−3
tests/mocks/Unity/Application/MirSurfaceItem.cpp+9−3 tests/qmltests/Stages/tst_TabletStage.qml+29
tests/mocks/Unity/Application/MirSurfaceItem.cpp+9−3
@@ -234,6 +234,10 @@ void MirSurfaceItem::setSurface(MirSurfaceInterface* surface)
234234 delete m_qmlContentComponent;
235235 m_qmlContentComponent = nullptr;
236236
237+ if (hasActiveFocus() && m_consumesInput && m_qmlSurface->live()) {
238+ m_qmlSurface->setActiveFocus(false);
239+ }
240+
237241 disconnect(m_qmlSurface, nullptr, this, nullptr);
238242 m_qmlSurface->unregisterView((qintptr)this);
239243 }
@@ -243,8 +247,6 @@ void MirSurfaceItem::setSurface(MirSurfaceInterface* surface)
243247 if (m_qmlSurface) {
244248 m_qmlSurface->registerView((qintptr)this);
245249
246− m_qmlSurface->setActiveFocus(hasActiveFocus());
247−
248250 updateSurfaceSize();
249251 updateMirSurfaceVisibility();
250252
@@ -277,6 +279,10 @@ void MirSurfaceItem::setSurface(MirSurfaceInterface* surface)
277279 default:
278280 qFatal("MirSurfaceItem: Unhandled component status");
279281 }
282+
283+ if (m_consumesInput) {
284+ m_qmlSurface->setActiveFocus(hasActiveFocus());
285+ }
280286 }
281287
282288 Q_EMIT surfaceChanged(m_qmlSurface);
@@ -285,7 +291,7 @@ void MirSurfaceItem::setSurface(MirSurfaceInterface* surface)
285291void MirSurfaceItem::itemChange(ItemChange change, const ItemChangeData & value)
286292{
287293 if (change == QQuickItem::ItemActiveFocusHasChanged) {
288− if (m_qmlSurface) {
294+ if (m_qmlSurface && m_consumesInput && m_qmlSurface->live()) {
289295 m_qmlSurface->setActiveFocus(value.boolValue);
290296 }
291297 }
tests/qmltests/Stages/tst_TabletStage.qml+29
@@ -725,5 +725,34 @@ Rectangle {
725725 // only unity8-dash surface is left
726726 compare(topSurfaceList.count, 1);
727727 }
728+
729+ function test_draggingSurfaceKeepsSurfaceFocus() {
730+ var webbrowserSurfaceId = topSurfaceList.nextId;
731+ webbrowserCheckBox.checked = true;
732+ waitUntilAppSurfaceShowsUp(webbrowserSurfaceId);
733+
734+ var appDelegate = findChild(tabletStage, "spreadDelegate_" + webbrowserSurfaceId);
735+ verify(appDelegate);
736+ compare(appDelegate.stage, ApplicationInfoInterface.MainStage);
737+
738+ tryCompare(appDelegate.surface, "activeFocus", true);
739+
740+ var pos = tabletStage.width - sideStage.width - (tabletStage.width - sideStage.width) / 2;
741+ var end_pos = tabletStage.width - sideStage.width / 2;
742+
743+ multiTouchDragUntil([0,1,2],
744+ tabletStage,
745+ pos,
746+ tabletStage.height / 2,
747+ units.gu(3),
748+ 0,
749+ function() {
750+ pos += units.gu(3);
751+ return sideStage.shown && !sideStage.showAnimation.running &&
752+ pos >= end_pos;
753+ });
754+
755+ tryCompare(appDelegate.surface, "activeFocus", true);
756+ }
728757 }
729758}