| 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
43 NSString* GetDefaultLocale() override { return mockedLocale; }
44 void DispatchSemanticsAction(int32_t id, SemanticsAction action) override {
45 SemanticsActionObservation observation(id, action);
46 observations.push_back(observation);
47 }
48 void DispatchSemanticsAction(int32_t id,
49 SemanticsAction action,
50 fml::MallocMapping args) override {
51 SemanticsActionObservation observation(id, action, args);
52 observations.push_back(observation);
53 }
54 void AccessibilityObjectDidBecomeFocused(int32_t id) override {}
55 void AccessibilityObjectDidLoseFocus(int32_t id) override {}
56 FlutterPlatformViewsController* GetPlatformViewsController() const override { return nil; }
57 std::vector<SemanticsActionObservation> observations;
58 bool isVoiceOverRunningValue;
59 NSString* mockedLocale;
60
61 private:
62 UIView* view_;
63 UIWindow* window_;
64 };
65
66 class MockAccessibilityBridgeNoWindow : public AccessibilityBridgeIos {
67 public:
68 MockAccessibilityBridgeNoWindow() : observations({}) {
69 view_ = [[UIView alloc] initWithFrame:kScreenSize];
70 }
71 bool isVoiceOverRunning() const override { return isVoiceOverRunningValue; }
72 UIView* view() const override { return view_; }
73 UIView<UITextInput>* textInputView() override { return nil; }
74 void DispatchSemanticsAction(int32_t id, SemanticsAction action) override {
75 SemanticsActionObservation observation(id, action);
76 observations.push_back(observation);
77 }
78 void DispatchSemanticsAction(int32_t id,
79 SemanticsAction action,
80 fml::MallocMapping args) override {
81 SemanticsActionObservation observation(id, action, args);
82 observations.push_back(observation);
83 }
84 void AccessibilityObjectDidBecomeFocused(int32_t id) override {}
85 void AccessibilityObjectDidLoseFocus(int32_t id) override {}
86 NSString* GetDefaultLocale() override { return nil; }
87 FlutterPlatformViewsController* GetPlatformViewsController() const override { return nil; }
88 std::vector<SemanticsActionObservation> observations;
89 bool isVoiceOverRunningValue;
90
91 private:
92 UIView* view_;
93 };
94 } // namespace testing
95 } // namespace flutter
96
97 @interface SemanticsObject (Tests)
98 - (BOOL)accessibilityScrollToVisible;
99 - (BOOL)accessibilityScrollToVisibleWithChild:(id)child;
100 - (id)_accessibilityHitTest:(CGPoint)point withEvent:(UIEvent*)event;
101 @end
102
103 #endif // FLUTTER_SHELL_PLATFORM_DARWIN_IOS_FRAMEWORK_SOURCE_SEMANTICSOBJECTTESTMOCKS_H_
initWithFrame
instancetype initWithFrame
Definition: FlutterTextInputPlugin.h:179
SemanticsObject.h
kScreenSize
const CGRect kScreenSize
Definition: SemanticsObjectTestMocks.h:10
SemanticsObject(Tests)
Definition: SemanticsObjectTestMocks.h:97
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:55
flutter::testing::MockAccessibilityBridge::mockedLocale
NSString * mockedLocale
Definition: SemanticsObjectTestMocks.h:59
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:48
flutter::testing::MockAccessibilityBridge::GetDefaultLocale
NSString * GetDefaultLocale() override
Definition: SemanticsObjectTestMocks.h:43
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:44
flutter::testing::MockAccessibilityBridge::GetPlatformViewsController
FlutterPlatformViewsController * GetPlatformViewsController() const override
Definition: SemanticsObjectTestMocks.h:56
flutter::testing::MockAccessibilityBridge::observations
std::vector< SemanticsActionObservation > observations
Definition: SemanticsObjectTestMocks.h:57
flutter::testing::MockAccessibilityBridge::AccessibilityObjectDidBecomeFocused
void AccessibilityObjectDidBecomeFocused(int32_t id) override
Definition: SemanticsObjectTestMocks.h:54
flutter::testing::MockAccessibilityBridge::isVoiceOverRunningValue
bool isVoiceOverRunningValue
Definition: SemanticsObjectTestMocks.h:58
flutter::testing::MockAccessibilityBridgeNoWindow
Definition: SemanticsObjectTestMocks.h:66
flutter::testing::MockAccessibilityBridgeNoWindow::isVoiceOverRunning
bool isVoiceOverRunning() const override
Definition: SemanticsObjectTestMocks.h:71
flutter::testing::MockAccessibilityBridgeNoWindow::MockAccessibilityBridgeNoWindow
MockAccessibilityBridgeNoWindow()
Definition: SemanticsObjectTestMocks.h:68
flutter::testing::MockAccessibilityBridgeNoWindow::observations
std::vector< SemanticsActionObservation > observations
Definition: SemanticsObjectTestMocks.h:88
flutter::testing::MockAccessibilityBridgeNoWindow::AccessibilityObjectDidBecomeFocused
void AccessibilityObjectDidBecomeFocused(int32_t id) override
Definition: SemanticsObjectTestMocks.h:84
flutter::testing::MockAccessibilityBridgeNoWindow::DispatchSemanticsAction
void DispatchSemanticsAction(int32_t id, SemanticsAction action, fml::MallocMapping args) override
Definition: SemanticsObjectTestMocks.h:78
flutter::testing::MockAccessibilityBridgeNoWindow::view
UIView * view() const override
Definition: SemanticsObjectTestMocks.h:72
flutter::testing::MockAccessibilityBridgeNoWindow::textInputView
UIView< UITextInput > * textInputView() override
Definition: SemanticsObjectTestMocks.h:73
flutter::testing::MockAccessibilityBridgeNoWindow::AccessibilityObjectDidLoseFocus
void AccessibilityObjectDidLoseFocus(int32_t id) override
Definition: SemanticsObjectTestMocks.h:85
flutter::testing::MockAccessibilityBridgeNoWindow::GetPlatformViewsController
FlutterPlatformViewsController * GetPlatformViewsController() const override
Definition: SemanticsObjectTestMocks.h:87
flutter::testing::MockAccessibilityBridgeNoWindow::GetDefaultLocale
NSString * GetDefaultLocale() override
Definition: SemanticsObjectTestMocks.h:86
flutter::testing::MockAccessibilityBridgeNoWindow::isVoiceOverRunningValue
bool isVoiceOverRunningValue
Definition: SemanticsObjectTestMocks.h:89
flutter::testing::MockAccessibilityBridgeNoWindow::DispatchSemanticsAction
void DispatchSemanticsAction(int32_t id, SemanticsAction action) override
Definition: SemanticsObjectTestMocks.h:74
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:31
flutter
Definition: accessibility_bridge.h:26