#include <stdint.h>
#include "remoting/client/input/normalizing_input_filter_win.h"
#include "remoting/proto/event.pb.h"
#include "remoting/protocol/protocol_mock_objects.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
using ::testing::InSequence;
InputStub;
KeyEvent;
MockInputStub;
MouseEvent;
namespace remoting {
namespace {
const unsigned int kUsbKeyA = …;
const unsigned int kUsbLeftControl = …;
const unsigned int kUsbRightAlt = …;
static const uint32_t kTestLockStates = protocol::KeyEvent::LOCK_STATES_NUMLOCK;
MATCHER_P2(EqualsKeyEvent, usb_keycode, pressed, "") { … }
KeyEvent MakeKeyEvent(uint32_t keycode, bool pressed) { … }
void PressAndReleaseKey(InputStub* input_stub, uint32_t keycode) { … }
MATCHER_P2(EqualsMouseMoveEvent, x, y, "") { … }
static MouseEvent MakeMouseMoveEvent(int x, int y) { … }
}
TEST(…) {
MockInputStub stub;
NormalizingInputFilterWin processor(&stub);
{
InSequence s;
EXPECT_CALL(…);
EXPECT_CALL(…);
EXPECT_CALL(…);
EXPECT_CALL(…);
EXPECT_CALL(…);
EXPECT_CALL(…);
}
PressAndReleaseKey(&processor, kUsbLeftControl);
PressAndReleaseKey(&processor, kUsbRightAlt);
PressAndReleaseKey(&processor, kUsbLeftControl);
}
TEST(…) {
MockInputStub stub;
NormalizingInputFilterWin processor(&stub);
{
InSequence s;
EXPECT_CALL(…);
EXPECT_CALL(…);
EXPECT_CALL(…);
}
processor.InjectKeyEvent(MakeKeyEvent(kUsbLeftControl, true));
processor.InjectKeyEvent(MakeKeyEvent(kUsbLeftControl, true));
processor.InjectKeyEvent(MakeKeyEvent(kUsbLeftControl, false));
}
TEST(…) {
MockInputStub stub;
NormalizingInputFilterWin processor(&stub);
{
InSequence s;
EXPECT_CALL(…);
EXPECT_CALL(…);
EXPECT_CALL(…);
EXPECT_CALL(…);
EXPECT_CALL(…);
EXPECT_CALL(…);
}
processor.InjectKeyEvent(MakeKeyEvent(kUsbLeftControl, true));
PressAndReleaseKey(&processor, kUsbKeyA);
PressAndReleaseKey(&processor, kUsbRightAlt);
processor.InjectKeyEvent(MakeKeyEvent(kUsbLeftControl, false));
}
TEST(…) {
MockInputStub stub;
NormalizingInputFilterWin processor(&stub);
{
InSequence s;
EXPECT_CALL(…);
EXPECT_CALL(…);
EXPECT_CALL(…);
EXPECT_CALL(…);
}
processor.InjectKeyEvent(MakeKeyEvent(kUsbLeftControl, true));
processor.InjectKeyEvent(MakeKeyEvent(kUsbRightAlt, true));
PressAndReleaseKey(&processor, kUsbKeyA);
processor.InjectKeyEvent(MakeKeyEvent(kUsbRightAlt, false));
processor.InjectKeyEvent(MakeKeyEvent(kUsbLeftControl, false));
}
TEST(…) {
MockInputStub stub;
NormalizingInputFilterWin processor(&stub);
{
InSequence s;
EXPECT_CALL(…);
EXPECT_CALL(…);
EXPECT_CALL(…);
}
processor.InjectKeyEvent(MakeKeyEvent(kUsbLeftControl, true));
processor.InjectKeyEvent(MakeKeyEvent(kUsbRightAlt, true));
processor.InjectKeyEvent(MakeKeyEvent(kUsbLeftControl, true));
processor.InjectKeyEvent(MakeKeyEvent(kUsbRightAlt, true));
processor.InjectKeyEvent(MakeKeyEvent(kUsbRightAlt, false));
processor.InjectKeyEvent(MakeKeyEvent(kUsbLeftControl, false));
}
TEST(…) {
MockInputStub stub;
NormalizingInputFilterWin processor(&stub);
{
InSequence s;
EXPECT_CALL(…);
EXPECT_CALL(…);
EXPECT_CALL(…);
EXPECT_CALL(…);
EXPECT_CALL(…);
}
processor.InjectKeyEvent(MakeKeyEvent(kUsbLeftControl, true));
processor.InjectMouseEvent(MakeMouseMoveEvent(0, 0));
PressAndReleaseKey(&processor, kUsbRightAlt);
processor.InjectKeyEvent(MakeKeyEvent(kUsbLeftControl, false));
}
TEST(…) {
MockInputStub stub;
NormalizingInputFilterWin processor(&stub);
{
InSequence s;
EXPECT_CALL(…);
EXPECT_CALL(…);
EXPECT_CALL(…);
}
processor.InjectKeyEvent(MakeKeyEvent(kUsbLeftControl, true));
processor.InjectKeyEvent(MakeKeyEvent(kUsbRightAlt, true));
processor.InjectMouseEvent(MakeMouseMoveEvent(0, 0));
processor.InjectKeyEvent(MakeKeyEvent(kUsbRightAlt, false));
processor.InjectKeyEvent(MakeKeyEvent(kUsbLeftControl, false));
}
}