#include "remoting/client/input/normalizing_input_filter_cros.h"
#include <stdint.h>
#include "remoting/proto/event.pb.h"
#include "remoting/protocol/protocol_mock_objects.h"
#include "remoting/protocol/test_event_matchers.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/events/keycodes/dom/dom_code.h"
using ::testing::InSequence;
InputStub;
KeyEvent;
MockInputStub;
MouseEvent;
EqualsKeyEvent;
EqualsKeyEventWithNumLock;
EqualsMouseButtonEvent;
EqualsMouseMoveEvent;
namespace remoting {
namespace {
KeyEvent MakeKeyEvent(ui::DomCode keycode, bool pressed) { … }
void PressAndReleaseKey(InputStub* input_stub, ui::DomCode keycode) { … }
static MouseEvent MakeMouseMoveEvent(int x, int y) { … }
static MouseEvent MakeMouseButtonEvent(MouseEvent::MouseButton button,
bool button_down) { … }
}
TEST(…) {
MockInputStub stub;
std::unique_ptr<protocol::InputFilter> processor(
new NormalizingInputFilterCros(&stub));
{
InSequence s;
EXPECT_CALL(…);
EXPECT_CALL(…);
EXPECT_CALL(…);
EXPECT_CALL(…);
}
PressAndReleaseKey(processor.get(), ui::DomCode::META_LEFT);
PressAndReleaseKey(processor.get(), ui::DomCode::META_RIGHT);
}
TEST(…) {
MockInputStub stub;
std::unique_ptr<protocol::InputFilter> processor(
new NormalizingInputFilterCros(&stub));
{
InSequence s;
EXPECT_CALL(…);
EXPECT_CALL(…);
EXPECT_CALL(…);
}
processor->InjectKeyEvent(MakeKeyEvent(ui::DomCode::META_LEFT, true));
processor->InjectKeyEvent(MakeKeyEvent(ui::DomCode::META_LEFT, true));
processor->InjectKeyEvent(MakeKeyEvent(ui::DomCode::META_LEFT, true));
}
TEST(…) {
MockInputStub stub;
std::unique_ptr<protocol::InputFilter> processor(
new NormalizingInputFilterCros(&stub));
{
InSequence s;
EXPECT_CALL(…);
EXPECT_CALL(…);
}
processor->InjectKeyEvent(MakeKeyEvent(ui::DomCode::META_LEFT, true));
PressAndReleaseKey(processor.get(), ui::DomCode::F1);
processor->InjectKeyEvent(MakeKeyEvent(ui::DomCode::META_LEFT, false));
}
TEST(…) {
MockInputStub stub;
std::unique_ptr<protocol::InputFilter> processor(
new NormalizingInputFilterCros(&stub));
{
InSequence s;
EXPECT_CALL(…);
EXPECT_CALL(…);
}
processor->InjectKeyEvent(MakeKeyEvent(ui::DomCode::META_LEFT, true));
PressAndReleaseKey(processor.get(), ui::DomCode::INSERT);
processor->InjectKeyEvent(MakeKeyEvent(ui::DomCode::META_LEFT, false));
}
TEST(…) {
MockInputStub stub;
std::unique_ptr<protocol::InputFilter> processor(
new NormalizingInputFilterCros(&stub));
{
InSequence s;
EXPECT_CALL(…);
EXPECT_CALL(…);
EXPECT_CALL(…);
EXPECT_CALL(…);
}
processor->InjectKeyEvent(MakeKeyEvent(ui::DomCode::META_LEFT, true));
PressAndReleaseKey(processor.get(), ui::DomCode::TAB);
processor->InjectKeyEvent(MakeKeyEvent(ui::DomCode::META_LEFT, false));
}
TEST(…) {
MockInputStub stub;
std::unique_ptr<protocol::InputFilter> processor(
new NormalizingInputFilterCros(&stub));
{
InSequence s;
EXPECT_CALL(…);
EXPECT_CALL(…);
EXPECT_CALL(…);
EXPECT_CALL(…);
EXPECT_CALL(…);
EXPECT_CALL(…);
}
processor->InjectKeyEvent(MakeKeyEvent(ui::DomCode::META_LEFT, true));
PressAndReleaseKey(processor.get(), ui::DomCode::INSERT);
PressAndReleaseKey(processor.get(), ui::DomCode::TAB);
processor->InjectKeyEvent(MakeKeyEvent(ui::DomCode::META_LEFT, false));
}
TEST(…) {
MockInputStub stub;
std::unique_ptr<protocol::InputFilter> processor(
new NormalizingInputFilterCros(&stub));
{
InSequence s;
EXPECT_CALL(…);
EXPECT_CALL(…);
EXPECT_CALL(…);
}
processor->InjectKeyEvent(MakeKeyEvent(ui::DomCode::META_LEFT, true));
processor->InjectMouseEvent(MakeMouseMoveEvent(0, 0));
processor->InjectKeyEvent(MakeKeyEvent(ui::DomCode::META_LEFT, false));
}
TEST(…) {
MockInputStub stub;
std::unique_ptr<protocol::InputFilter> processor(
new NormalizingInputFilterCros(&stub));
{
InSequence s;
EXPECT_CALL(…);
EXPECT_CALL(…);
EXPECT_CALL(…);
EXPECT_CALL(…);
}
processor->InjectKeyEvent(MakeKeyEvent(ui::DomCode::ALT_LEFT, true));
processor->InjectMouseEvent(
MakeMouseButtonEvent(MouseEvent::BUTTON_RIGHT, true));
processor->InjectMouseEvent(
MakeMouseButtonEvent(MouseEvent::BUTTON_RIGHT, false));
processor->InjectKeyEvent(MakeKeyEvent(ui::DomCode::ALT_LEFT, false));
}
TEST(…) {
MockInputStub stub;
std::unique_ptr<protocol::InputFilter> processor(
new NormalizingInputFilterCros(&stub));
{
InSequence s;
EXPECT_CALL(…);
EXPECT_CALL(…);
EXPECT_CALL(…);
EXPECT_CALL(…);
}
processor->InjectKeyEvent(MakeKeyEvent(ui::DomCode::ALT_RIGHT, true));
processor->InjectMouseEvent(
MakeMouseButtonEvent(MouseEvent::BUTTON_RIGHT, true));
processor->InjectMouseEvent(
MakeMouseButtonEvent(MouseEvent::BUTTON_RIGHT, false));
processor->InjectKeyEvent(MakeKeyEvent(ui::DomCode::ALT_RIGHT, false));
}
TEST(…) {
MockInputStub stub;
std::unique_ptr<protocol::InputFilter> processor(
new NormalizingInputFilterCros(&stub));
{
InSequence s;
EXPECT_CALL(…);
EXPECT_CALL(…);
EXPECT_CALL(…);
EXPECT_CALL(…);
EXPECT_CALL(…);
EXPECT_CALL(…);
EXPECT_CALL(…);
EXPECT_CALL(…);
EXPECT_CALL(…);
EXPECT_CALL(…);
EXPECT_CALL(…);
EXPECT_CALL(…);
EXPECT_CALL(…);
EXPECT_CALL(…);
EXPECT_CALL(…);
EXPECT_CALL(…);
}
processor->InjectKeyEvent(MakeKeyEvent(ui::DomCode::ALT_LEFT, true));
PressAndReleaseKey(processor.get(), ui::DomCode::PAGE_UP);
PressAndReleaseKey(processor.get(), ui::DomCode::PAGE_DOWN);
PressAndReleaseKey(processor.get(), ui::DomCode::DEL);
processor->InjectKeyEvent(MakeKeyEvent(ui::DomCode::ALT_LEFT, false));
processor->InjectKeyEvent(MakeKeyEvent(ui::DomCode::ALT_RIGHT, true));
PressAndReleaseKey(processor.get(), ui::DomCode::PAGE_UP);
PressAndReleaseKey(processor.get(), ui::DomCode::PAGE_DOWN);
PressAndReleaseKey(processor.get(), ui::DomCode::DEL);
processor->InjectKeyEvent(MakeKeyEvent(ui::DomCode::ALT_RIGHT, false));
}
}