flutter_flutter/shell/platform/windows/win32_window_unittests.cc
stuartmorgan 8ec8af75a2
[windows] Add horizontal scroll support (#20668)
The embedding was only handling vertical scroll events from the OS; this
adds horizontal as well.

Fixes https://github.com/flutter/flutter/issues/60835
2020-08-31 16:01:38 -07:00

42 lines
1.2 KiB
C++

// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "flutter/shell/platform/windows/testing/mock_win32_window.h"
#include "gtest/gtest.h"
namespace flutter {
namespace testing {
TEST(MockWin32Window, CreateDestroy) {
MockWin32Window window;
ASSERT_TRUE(TRUE);
}
TEST(MockWin32Window, GetDpiAfterCreate) {
MockWin32Window window;
ASSERT_TRUE(window.GetDpi() > 0);
}
TEST(MockWin32Window, VerticalScroll) {
MockWin32Window window;
const int scroll_amount = 10;
// Vertical scroll should be passed along, adjusted for scroll tick size
// and direction.
EXPECT_CALL(window, OnScroll(0, -scroll_amount / 120.0)).Times(1);
window.InjectWindowMessage(WM_MOUSEWHEEL, MAKEWPARAM(0, scroll_amount), 0);
}
TEST(MockWin32Window, HorizontalScroll) {
MockWin32Window window;
const int scroll_amount = 10;
// Vertical scroll should be passed along, adjusted for scroll tick size.
EXPECT_CALL(window, OnScroll(scroll_amount / 120.0, 0)).Times(1);
window.InjectWindowMessage(WM_MOUSEHWHEEL, MAKEWPARAM(0, scroll_amount), 0);
}
} // namespace testing
} // namespace flutter