Flutter Engine
The Flutter Engine
mock_window.h
Go to the documentation of this file.
1// Copyright 2013 The Flutter Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef FLUTTER_SHELL_PLATFORM_WINDOWS_TESTING_MOCK_WINDOW_H_
6#define FLUTTER_SHELL_PLATFORM_WINDOWS_TESTING_MOCK_WINDOW_H_
7
8#include "flutter/fml/macros.h"
9#include "flutter/shell/platform/windows/flutter_window.h"
10#include "flutter/shell/platform/windows/testing/test_keyboard.h"
11#include "gmock/gmock.h"
12
13namespace flutter {
14namespace testing {
15
16/// Mock for the |FlutterWindow| base class.
17class MockWindow : public FlutterWindow {
18 public:
19 MockWindow();
20 MockWindow(std::unique_ptr<WindowsProcTable> windows_proc_table,
21 std::unique_ptr<TextInputManager> text_input_manager);
22 virtual ~MockWindow();
23
24 // Wrapper for GetCurrentDPI() which is a protected method.
25 UINT GetDpi();
26
27 // Set the Direct Manipulation owner for testing purposes.
29 std::unique_ptr<DirectManipulationOwner> owner);
30
31 // Simulates a WindowProc message from the OS.
33 WPARAM const wparam,
34 LPARAM const lparam);
35
36 void InjectMessageList(int count, const Win32Message* messages);
37
38 MOCK_METHOD(void, OnDpiScale, (unsigned int), (override));
39 MOCK_METHOD(void, OnResize, (unsigned int, unsigned int), (override));
40 MOCK_METHOD(void, OnPaint, (), (override));
43 (double, double, FlutterPointerDeviceKind, int32_t, int),
44 (override));
47 (double, double, FlutterPointerDeviceKind, int32_t, UINT),
48 (override));
51 (double, double, FlutterPointerDeviceKind, int32_t, UINT),
52 (override));
55 (double, double, FlutterPointerDeviceKind, int32_t),
56 (override));
57 MOCK_METHOD(void, OnSetCursor, (), (override));
58 MOCK_METHOD(void, OnText, (const std::u16string&), (override));
60 OnKey,
61 (int, int, int, char32_t, bool, bool, KeyEventCallback),
62 (override));
63 MOCK_METHOD(void, OnUpdateSemanticsEnabled, (bool), (override));
66 (),
67 (override));
70 (double, double, FlutterPointerDeviceKind, int32_t),
71 (override));
72 MOCK_METHOD(void, OnComposeBegin, (), (override));
73 MOCK_METHOD(void, OnComposeCommit, (), (override));
74 MOCK_METHOD(void, OnComposeEnd, (), (override));
75 MOCK_METHOD(void, OnComposeChange, (const std::u16string&, int), (override));
78 (UINT const, WPARAM const, LPARAM const),
79 (override));
80
81 MOCK_METHOD(void, OnThemeChange, (), (override));
82
85 (),
86 (override));
87
89
91
93 WPARAM const wparam,
94 LPARAM const lparam);
95
96 protected:
97 LRESULT Win32DefWindowProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam);
98
99 private:
100 FML_DISALLOW_COPY_AND_ASSIGN(MockWindow);
101};
102
103} // namespace testing
104} // namespace flutter
105
106#endif // FLUTTER_SHELL_PLATFORM_WINDOWS_TESTING_MOCK_WINDOW_H_
int count
Definition: FontMgrTest.cpp:50
virtual void OnPointerLeave(double x, double y, FlutterPointerDeviceKind device_kind, int32_t device_id)
virtual void OnText(const std::u16string &text) override
virtual void OnThemeChange()
virtual void OnSetCursor()
virtual ui::AXFragmentRootDelegateWin * GetAxFragmentRootDelegate()
virtual void OnScroll(double delta_x, double delta_y, FlutterPointerDeviceKind device_kind, int32_t device_id)
virtual void OnPointerUp(double x, double y, FlutterPointerDeviceKind device_kind, int32_t device_id, UINT button)
virtual void OnPointerDown(double x, double y, FlutterPointerDeviceKind device_kind, int32_t device_id, UINT button)
virtual void OnComposeCommit()
virtual void OnWindowStateEvent(WindowStateEvent event)
virtual void OnKey(int key, int scancode, int action, char32_t character, bool extended, bool was_down, KeyEventCallback callback) override
virtual void OnPointerMove(double x, double y, FlutterPointerDeviceKind device_kind, int32_t device_id, int modifiers_state)
virtual void OnComposeEnd()
virtual void OnComposeChange(const std::u16string &text, int cursor_pos)
virtual void OnImeComposition(UINT const message, WPARAM const wparam, LPARAM const lparam)
virtual void OnDpiScale(unsigned int dpi)
virtual void OnUpdateSemanticsEnabled(bool enabled)
virtual LRESULT OnGetObject(UINT const message, WPARAM const wparam, LPARAM const lparam)
virtual gfx::NativeViewAccessible GetNativeViewAccessible()
virtual void OnComposeBegin()
virtual void OnResize(unsigned int width, unsigned int height)
std::function< void(bool)> KeyEventCallback
Mock for the |FlutterWindow| base class.
Definition: mock_window.h:17
MOCK_METHOD(void, OnComposeBegin,(),(override))
LRESULT InjectWindowMessage(UINT const message, WPARAM const wparam, LPARAM const lparam)
Definition: mock_window.cc:35
MOCK_METHOD(void, OnPointerLeave,(double, double, FlutterPointerDeviceKind, int32_t),(override))
MOCK_METHOD(void, OnPaint,(),(override))
MOCK_METHOD(void, OnImeComposition,(UINT const, WPARAM const, LPARAM const),(override))
MOCK_METHOD(LRESULT, OnGetObject,(UINT, WPARAM, LPARAM),(override))
MOCK_METHOD(ui::AXFragmentRootDelegateWin *, GetAxFragmentRootDelegate,(),(override))
MOCK_METHOD(void, OnThemeChange,(),(override))
MOCK_METHOD(void, OnPointerMove,(double, double, FlutterPointerDeviceKind, int32_t, int),(override))
void InjectMessageList(int count, const Win32Message *messages)
Definition: mock_window.cc:41
MOCK_METHOD(void, OnUpdateSemanticsEnabled,(bool),(override))
MOCK_METHOD(void, OnKey,(int, int, int, char32_t, bool, bool, KeyEventCallback),(override))
MOCK_METHOD(void, OnDpiScale,(unsigned int),(override))
MOCK_METHOD(void, OnPointerDown,(double, double, FlutterPointerDeviceKind, int32_t, UINT),(override))
MOCK_METHOD(void, OnWindowStateEvent,(WindowStateEvent),(override))
MOCK_METHOD(void, OnText,(const std::u16string &),(override))
MOCK_METHOD(void, OnResize,(unsigned int, unsigned int),(override))
MOCK_METHOD(void, OnComposeChange,(const std::u16string &, int),(override))
LRESULT Win32DefWindowProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
Definition: mock_window.cc:23
MOCK_METHOD(void, OnScroll,(double, double, FlutterPointerDeviceKind, int32_t),(override))
void SetDirectManipulationOwner(std::unique_ptr< DirectManipulationOwner > owner)
Definition: mock_window.cc:30
MOCK_METHOD(gfx::NativeViewAccessible, GetNativeViewAccessible,(),(override))
MOCK_METHOD(void, OnPointerUp,(double, double, FlutterPointerDeviceKind, int32_t, UINT),(override))
MOCK_METHOD(void, OnSetCursor,(),(override))
MOCK_METHOD(void, OnComposeCommit,(),(override))
MOCK_METHOD(void, OnComposeEnd,(),(override))
void CallOnImeComposition(UINT const message, WPARAM const wparam, LPARAM const lparam)
Definition: mock_window.cc:52
FlutterPointerDeviceKind
The device type that created a pointer event.
Definition: embedder.h:1007
Win32Message message
WindowStateEvent
An event representing a change in window state that may update the.
UnimplementedNativeViewAccessible * NativeViewAccessible
LONG_PTR LRESULT
Definition: windows_types.h:61
unsigned int UINT
Definition: windows_types.h:32
LONG_PTR LPARAM
Definition: windows_types.h:60
UINT_PTR WPARAM
Definition: windows_types.h:59