Contain XCUI ImGui adapters behind explicit host seams
This commit is contained in:
@@ -27,6 +27,11 @@ void PrepareImGui(float width = 1024.0f, float height = 768.0f) {
|
||||
ImGuiIO& io = ImGui::GetIO();
|
||||
io.DisplaySize = ImVec2(width, height);
|
||||
io.DeltaTime = 1.0f / 60.0f;
|
||||
unsigned char* fontPixels = nullptr;
|
||||
int fontWidth = 0;
|
||||
int fontHeight = 0;
|
||||
io.Fonts->GetTexDataAsRGBA32(&fontPixels, &fontWidth, &fontHeight);
|
||||
io.Fonts->SetTexID(static_cast<ImTextureID>(1));
|
||||
}
|
||||
|
||||
} // namespace
|
||||
@@ -36,17 +41,17 @@ TEST(ImGuiXCUIInputAdapterTest, CaptureSnapshotMapsImGuiStateIntoXCUIFrameSnapsh
|
||||
PrepareImGui(800.0f, 600.0f);
|
||||
|
||||
ImGuiIO& io = ImGui::GetIO();
|
||||
io.MousePos = ImVec2(120.0f, 72.0f);
|
||||
io.MouseDown[0] = true;
|
||||
io.MouseWheel = 1.0f;
|
||||
io.WantCaptureMouse = true;
|
||||
io.WantCaptureKeyboard = true;
|
||||
io.WantTextInput = true;
|
||||
io.AddMousePosEvent(120.0f, 72.0f);
|
||||
io.AddMouseButtonEvent(0, true);
|
||||
io.AddMouseWheelEvent(0.0f, 1.0f);
|
||||
io.AddKeyEvent(ImGuiKey_LeftCtrl, true);
|
||||
io.AddKeyEvent(ImGuiKey_P, true);
|
||||
io.AddInputCharacter('p');
|
||||
|
||||
ImGui::NewFrame();
|
||||
io.KeyCtrl = true;
|
||||
io.KeysData[ImGuiKey_LeftCtrl - ImGuiKey_NamedKey_BEGIN].Down = true;
|
||||
io.KeysData[ImGuiKey_P - ImGuiKey_NamedKey_BEGIN].Down = true;
|
||||
io.InputQueueCharacters.resize(0);
|
||||
io.InputQueueCharacters.push_back(static_cast<ImWchar>('p'));
|
||||
|
||||
XCUIInputBridgeCaptureOptions options = {};
|
||||
options.pointerOffset = XCEngine::UI::UIPoint(20.0f, 12.0f);
|
||||
@@ -55,8 +60,6 @@ TEST(ImGuiXCUIInputAdapterTest, CaptureSnapshotMapsImGuiStateIntoXCUIFrameSnapsh
|
||||
|
||||
const auto snapshot = ImGuiXCUIInputAdapter::CaptureSnapshot(io, options);
|
||||
|
||||
ImGui::EndFrame();
|
||||
|
||||
EXPECT_FLOAT_EQ(snapshot.pointerPosition.x, 100.0f);
|
||||
EXPECT_FLOAT_EQ(snapshot.pointerPosition.y, 60.0f);
|
||||
EXPECT_TRUE(snapshot.pointerInside);
|
||||
|
||||
Reference in New Issue
Block a user