Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add unit tests
  • Loading branch information
stuartmorgan-g committed Aug 20, 2020
commit b769ab9fed9e9f13bcdb2810d495dd4d9f4f4528
4 changes: 2 additions & 2 deletions shell/platform/windows/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,8 @@ executable("flutter_windows_unittests") {
"system_utils_unittests.cc",
"testing/win32_flutter_window_test.cc",
"testing/win32_flutter_window_test.h",
"testing/win32_window_test.cc",
"testing/win32_window_test.h",
"testing/mock_win32_window.cc",
"testing/mock_win32_window.h",
"win32_dpi_utils_unittests.cc",
"win32_flutter_window_unittests.cc",
"win32_window_proc_delegate_manager_unittests.cc",
Expand Down
21 changes: 21 additions & 0 deletions shell/platform/windows/testing/mock_win32_window.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#include "flutter/shell/platform/windows/testing/mock_win32_window.h"

namespace flutter {
namespace testing {

MockWin32Window::MockWin32Window() : Win32Window(){};

MockWin32Window::~MockWin32Window() = default;

UINT MockWin32Window::GetDpi() {
return GetCurrentDPI();
}

void MockWin32Window::InjectWindowMessage(UINT const message,
WPARAM const wparam,
LPARAM const lparam) {
HandleMessage(message, wparam, lparam);
}

} // namespace testing
} // namespace flutter
45 changes: 45 additions & 0 deletions shell/platform/windows/testing/mock_win32_window.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// 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 <windowsx.h>

#include "flutter/shell/platform/windows/win32_window.h"
#include "gmock/gmock.h"

namespace flutter {
namespace testing {

/// Mock for the Win32Window base class.
class MockWin32Window : public Win32Window {
public:
MockWin32Window();
virtual ~MockWin32Window();

// Prevent copying.
MockWin32Window(MockWin32Window const&) = delete;
MockWin32Window& operator=(MockWin32Window const&) = delete;

// Wrapper for GetCurrentDPI() which is a protected method.
UINT GetDpi();

// Simulates a WindowProc message from the OS.
void InjectWindowMessage(UINT const message,
WPARAM const wparam,
LPARAM const lparam);

MOCK_METHOD1(OnDpiScale, void(unsigned int));
MOCK_METHOD2(OnResize, void(unsigned int, unsigned int));
MOCK_METHOD2(OnPointerMove, void(double, double));
MOCK_METHOD3(OnPointerDown, void(double, double, UINT));
MOCK_METHOD3(OnPointerUp, void(double, double, UINT));
MOCK_METHOD0(OnPointerLeave, void());
MOCK_METHOD0(OnSetCursor, void());
MOCK_METHOD1(OnText, void(const std::u16string&));
MOCK_METHOD4(OnKey, void(int, int, int, char32_t));
MOCK_METHOD2(OnScroll, void(double, double));
MOCK_METHOD0(OnFontChange, void());
};

} // namespace testing
} // namespace flutter
40 changes: 0 additions & 40 deletions shell/platform/windows/testing/win32_window_test.cc

This file was deleted.

61 changes: 0 additions & 61 deletions shell/platform/windows/testing/win32_window_test.h

This file was deleted.

Loading