#pragma once #include "engine/InputEngine.h" #include #include // Records what the keyboard sends and applies it to a simulated field, so // tests check the text a user would see rather than the calls made. class FakeEngine : public InputEngine { public: void commitText(const QString &text) override { output += text; } void replaceBeforeCursor(const QString &before, const QString &text) override { if (output.endsWith(before)) output.chop(before.size()); else mismatchedReplacements++; output += text; } void sendKeysym(quint32 keysym, Qt::KeyboardModifiers modifiers) override { keysyms.append(keysym); lastModifiers = modifiers; } QString output; // the field's text int mismatchedReplacements = 0; // replaced text that wasn't before the cursor QList keysyms; Qt::KeyboardModifiers lastModifiers; };