51
60
miral::WindowInfo createMirALWindowInfo(QPoint position = {160, 320}, QSize size = {100, 200})
53
62
const miral::Application app{stubSession};
63
stubSurface->setSize(size);
54
64
const miral::Window window{app, stubSurface};
56
66
ms::SurfaceCreationParameters windowSpec;
57
windowSpec.of_size(toMirSize(size));
67
// windowSpec.of_size(toMirSize(size)); // useless, Window/Surface has the size actually used
58
68
windowSpec.of_position(toMirPoint(position));
59
69
return miral::WindowInfo{window, windowSpec};
72
miral::WindowInfo createMirALWindowInfoForInputMethod()
74
const miral::Application app{stubSession};
75
const miral::Window window{app, stubSurface};
77
ms::SurfaceCreationParameters windowSpec;
78
windowSpec.of_type(mir_surface_type_inputmethod);
79
return miral::WindowInfo{window, windowSpec};
62
82
MirSurface *getMirSurfaceFromModel(const WindowModel &model, int index)
64
85
return model.data(model.index(index, 0), WindowModel::SurfaceRole).value<MirSurface*>();
596
662
* Test: with 2 windows, ensure window resize does not impact other MirSurfaces
598
TEST_F(WindowModelTest, DISABLED_WindowResizeDoesNotTouchOtherMirSurfaces)
664
TEST_F(WindowModelTest, WindowResizeDoesNotTouchOtherMirSurfaces)
600
666
WindowModelNotifier notifier;
601
667
WindowModel model(¬ifier, nullptr); // no need for controller in this testcase
603
QSize fixedPosition(300, 400);
669
QSize fixedSize(300, 400);
605
671
auto mirWindowInfo1 = createMirALWindowInfo(QPoint(), QSize(100, 200));
606
auto mirWindowInfo2 = createMirALWindowInfo(QPoint(), fixedPosition);
672
auto mirWindowInfo2 = createMirALWindowInfo(QPoint(), fixedSize);
607
673
notifier.addWindow(mirWindowInfo1);
608
674
notifier.addWindow(mirWindowInfo2);
610
676
auto surface = getMirSurfaceFromModel(model, 1);
613
679
notifier.resizeWindow(mirWindowInfo1, toMirSize(QSize(150, 220)));
615
682
// Ensure other window untouched
616
EXPECT_EQ(fixedPosition, surface->size());
683
EXPECT_EQ(fixedSize, surface->size());
687
* Test: that the WindowModelNotifier.addWindow for an Input Method Window causes
688
* the Qt-side WindowModel to register the input method surface
690
TEST_F(WindowModelTest, WhenAddInputMethodWindowNotifiedModelEmitsInputMethodChangedSignal)
692
WindowModelNotifier notifier;
693
WindowModel model(¬ifier, nullptr); // no need for controller in this testcase
695
auto mirWindowInfo = createMirALWindowInfoForInputMethod();
697
QSignalSpy spyCountChanged(&model, SIGNAL(inputMethodSurfaceChanged(MirSurfaceInterface*)));
699
notifier.addWindow(mirWindowInfo);
702
EXPECT_EQ(1, spyCountChanged.count());
706
* Test: that the WindowModelNotifier.addWindow for an Input Method Window causes
707
* the Qt-side WindowModel::inputMethodSurface property to be correctly set
709
TEST_F(WindowModelTest, WhenAddInputMethodWindowNotifiedModelPropertyHasCorrectWindow)
711
WindowModelNotifier notifier;
712
WindowModel model(¬ifier, nullptr); // no need for controller in this testcase
714
auto mirWindowInfo = createMirALWindowInfoForInputMethod();
716
notifier.addWindow(mirWindowInfo);
719
auto miralWindow = static_cast<MirSurface*>(model.inputMethodSurface())->window();
720
EXPECT_EQ(mirWindowInfo.window(), miralWindow);
724
* Test: that the WindowModelNotifier.removeWindow for an Input Method Window causes
725
* the Qt-side WindowModel to reset the WindowModel::inputMethodSurface property to null
727
TEST_F(WindowModelTest, WhenRemoveInputMethodWindowNotifiedModelPropertyReset)
729
WindowModelNotifier notifier;
730
WindowModel model(¬ifier, nullptr); // no need for controller in this testcase
732
auto mirWindowInfo = createMirALWindowInfoForInputMethod();
733
notifier.addWindow(mirWindowInfo);
735
// Test removing the window
736
notifier.removeWindow(mirWindowInfo);
739
EXPECT_EQ(nullptr, model.inputMethodSurface());