| Flutter iOS Embedder |

SemanticsObjectTestMocks.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_DARWIN_IOS_FRAMEWORK_SOURCE_SEMANTICSOBJECTTESTMOCKS_H_
6 #define FLUTTER_SHELL_PLATFORM_DARWIN_IOS_FRAMEWORK_SOURCE_SEMANTICSOBJECTTESTMOCKS_H_
7
8 #import "flutter/shell/platform/darwin/ios/framework/Source/SemanticsObject.h"
9
10 const CGRect kScreenSize = CGRectMake(0, 0, 600, 800);
11
12 namespace flutter {
13 namespace testing {
14
15 class SemanticsActionObservation {
16 public:
17 SemanticsActionObservation(int32_t observed_id, SemanticsAction observed_action)
18 : id(observed_id), action(observed_action), args({}) {}
19
20 SemanticsActionObservation(int32_t observed_id,
21 SemanticsAction observed_action,
22 fml::MallocMapping& args)
23 : id(observed_id),
24 action(observed_action),
25 args(args.GetMapping(), args.GetMapping() + args.GetSize()) {}
26
27 int32_t id;
28 SemanticsAction action;
29 std::vector<uint8_t> args;
30 };
31
32 class MockAccessibilityBridge : public AccessibilityBridgeIos {
33 public:
34 MockAccessibilityBridge() : observations({}) {
35 view_ = [[UIView alloc] initWithFrame:kScreenSize];
36 window_ = [[UIWindow alloc] initWithFrame:kScreenSize];
37 [window_ addSubview:view_];
38 }
39 bool isVoiceOverRunning() const override { return isVoiceOverRunningValue; }
40 UIView* view() const override { return view_; }
41 UIView<UITextInput>* textInputView() override { return nil; }
42 void DispatchSemanticsAction(int32_t id, SemanticsAction action) override {
43 SemanticsActionObservation observation(id, action);
44 observations.push_back(observation);
45 }
46 void DispatchSemanticsAction(int32_t id,
47 SemanticsAction action,
48 fml::MallocMapping args) override {
49 SemanticsActionObservation observation(id, action, args);
50 observations.push_back(observation);
51 }
52 void AccessibilityObjectDidBecomeFocused(int32_t id) override {}
53 void AccessibilityObjectDidLoseFocus(int32_t id) override {}
54 FlutterPlatformViewsController* GetPlatformViewsController() const override { return nil; }
55 std::vector<SemanticsActionObservation> observations;
56 bool isVoiceOverRunningValue;
57
58 private:
59 UIView* view_;
60 UIWindow* window_;
61 };
62
63 class MockAccessibilityBridgeNoWindow : public AccessibilityBridgeIos {
64 public:
65 MockAccessibilityBridgeNoWindow() : observations({}) {
66 view_ = [[UIView alloc] initWithFrame:kScreenSize];
67 }
68 bool isVoiceOverRunning() const override { return isVoiceOverRunningValue; }
69 UIView* view() const override { return view_; }
70 UIView<UITextInput>* textInputView() override { return nil; }
71 void DispatchSemanticsAction(int32_t id, SemanticsAction action) override {
72 SemanticsActionObservation observation(id, action);
73 observations.push_back(observation);
74 }
75 void DispatchSemanticsAction(int32_t id,
76 SemanticsAction action,
77 fml::MallocMapping args) override {
78 SemanticsActionObservation observation(id, action, args);
79 observations.push_back(observation);
80 }
81 void AccessibilityObjectDidBecomeFocused(int32_t id) override {}
82 void AccessibilityObjectDidLoseFocus(int32_t id) override {}
83 FlutterPlatformViewsController* GetPlatformViewsController() const override { return nil; }
84 std::vector<SemanticsActionObservation> observations;
85 bool isVoiceOverRunningValue;
86
87 private:
88 UIView* view_;
89 };
90 } // namespace testing
91 } // namespace flutter
92
93 @interface SemanticsObject (Tests)
94 - (BOOL)accessibilityScrollToVisible;
95 - (BOOL)accessibilityScrollToVisibleWithChild:(id)child;
96 - (id)_accessibilityHitTest:(CGPoint)point withEvent:(UIEvent*)event;
97 @end
98
99 #endif // FLUTTER_SHELL_PLATFORM_DARWIN_IOS_FRAMEWORK_SOURCE_SEMANTICSOBJECTTESTMOCKS_H_
initWithFrame
instancetype initWithFrame
Definition: FlutterTextInputPlugin.h:172
SemanticsObject.h
kScreenSize
const CGRect kScreenSize
Definition: SemanticsObjectTestMocks.h:10
SemanticsObject(Tests)
Definition: SemanticsObjectTestMocks.h:93
flutter::AccessibilityBridgeIos
Interface that represents an accessibility bridge for iOS.
Definition: accessibility_bridge_ios.h:20
flutter::testing::MockAccessibilityBridge
Definition: SemanticsObjectTestMocks.h:32
flutter::testing::MockAccessibilityBridge::AccessibilityObjectDidLoseFocus
void AccessibilityObjectDidLoseFocus(int32_t id) override
Definition: SemanticsObjectTestMocks.h:53
flutter::testing::MockAccessibilityBridge::textInputView
UIView< UITextInput > * textInputView() override
Definition: SemanticsObjectTestMocks.h:41
flutter::testing::MockAccessibilityBridge::MockAccessibilityBridge
MockAccessibilityBridge()
Definition: SemanticsObjectTestMocks.h:34
flutter::testing::MockAccessibilityBridge::DispatchSemanticsAction
void DispatchSemanticsAction(int32_t id, SemanticsAction action, fml::MallocMapping args) override
Definition: SemanticsObjectTestMocks.h:46
flutter::testing::MockAccessibilityBridge::view
UIView * view() const override
Definition: SemanticsObjectTestMocks.h:40
flutter::testing::MockAccessibilityBridge::isVoiceOverRunning
bool isVoiceOverRunning() const override
Definition: SemanticsObjectTestMocks.h:39
flutter::testing::MockAccessibilityBridge::DispatchSemanticsAction
void DispatchSemanticsAction(int32_t id, SemanticsAction action) override
Definition: SemanticsObjectTestMocks.h:42
flutter::testing::MockAccessibilityBridge::GetPlatformViewsController
FlutterPlatformViewsController * GetPlatformViewsController() const override
Definition: SemanticsObjectTestMocks.h:54
flutter::testing::MockAccessibilityBridge::observations
std::vector< SemanticsActionObservation > observations
Definition: SemanticsObjectTestMocks.h:55
flutter::testing::MockAccessibilityBridge::AccessibilityObjectDidBecomeFocused
void AccessibilityObjectDidBecomeFocused(int32_t id) override
Definition: SemanticsObjectTestMocks.h:52
flutter::testing::MockAccessibilityBridge::isVoiceOverRunningValue
bool isVoiceOverRunningValue
Definition: SemanticsObjectTestMocks.h:56
flutter::testing::MockAccessibilityBridgeNoWindow
Definition: SemanticsObjectTestMocks.h:63
flutter::testing::MockAccessibilityBridgeNoWindow::isVoiceOverRunning
bool isVoiceOverRunning() const override
Definition: SemanticsObjectTestMocks.h:68
flutter::testing::MockAccessibilityBridgeNoWindow::MockAccessibilityBridgeNoWindow
MockAccessibilityBridgeNoWindow()
Definition: SemanticsObjectTestMocks.h:65
flutter::testing::MockAccessibilityBridgeNoWindow::observations
std::vector< SemanticsActionObservation > observations
Definition: SemanticsObjectTestMocks.h:84
flutter::testing::MockAccessibilityBridgeNoWindow::AccessibilityObjectDidBecomeFocused
void AccessibilityObjectDidBecomeFocused(int32_t id) override
Definition: SemanticsObjectTestMocks.h:81
flutter::testing::MockAccessibilityBridgeNoWindow::DispatchSemanticsAction
void DispatchSemanticsAction(int32_t id, SemanticsAction action, fml::MallocMapping args) override
Definition: SemanticsObjectTestMocks.h:75
flutter::testing::MockAccessibilityBridgeNoWindow::view
UIView * view() const override
Definition: SemanticsObjectTestMocks.h:69
flutter::testing::MockAccessibilityBridgeNoWindow::textInputView
UIView< UITextInput > * textInputView() override
Definition: SemanticsObjectTestMocks.h:70
flutter::testing::MockAccessibilityBridgeNoWindow::AccessibilityObjectDidLoseFocus
void AccessibilityObjectDidLoseFocus(int32_t id) override
Definition: SemanticsObjectTestMocks.h:82
flutter::testing::MockAccessibilityBridgeNoWindow::GetPlatformViewsController
FlutterPlatformViewsController * GetPlatformViewsController() const override
Definition: SemanticsObjectTestMocks.h:83
flutter::testing::MockAccessibilityBridgeNoWindow::isVoiceOverRunningValue
bool isVoiceOverRunningValue
Definition: SemanticsObjectTestMocks.h:85
flutter::testing::MockAccessibilityBridgeNoWindow::DispatchSemanticsAction
void DispatchSemanticsAction(int32_t id, SemanticsAction action) override
Definition: SemanticsObjectTestMocks.h:71
flutter::testing::SemanticsActionObservation
Definition: SemanticsObjectTestMocks.h:15
flutter::testing::SemanticsActionObservation::action
SemanticsAction action
Definition: SemanticsObjectTestMocks.h:28
flutter::testing::SemanticsActionObservation::args
std::vector< uint8_t > args
Definition: SemanticsObjectTestMocks.h:29
flutter::testing::SemanticsActionObservation::SemanticsActionObservation
SemanticsActionObservation(int32_t observed_id, SemanticsAction observed_action)
Definition: SemanticsObjectTestMocks.h:17
flutter::testing::SemanticsActionObservation::SemanticsActionObservation
SemanticsActionObservation(int32_t observed_id, SemanticsAction observed_action, fml::MallocMapping &args)
Definition: SemanticsObjectTestMocks.h:20
flutter::testing::SemanticsActionObservation::id
int32_t id
Definition: SemanticsObjectTestMocks.h:27
FlutterPlatformViewsController
Definition: FlutterPlatformViewsController.h:32
flutter
Definition: accessibility_bridge.h:27