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