| 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) {}
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<PlatformViewsController> 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<PlatformViewsController> GetPlatformViewsController() const override {
78 return nil;
79 }
80 std::vector<SemanticsActionObservation> observations;
81 bool isVoiceOverRunningValue;
82
83 private:
84 UIView* view_;
85 };
86 } // namespace testing
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 // FLUTTER_SHELL_PLATFORM_DARWIN_IOS_FRAMEWORK_SOURCE_SEMANTICSOBJECTTESTMOCKS_H_
flutter::testing::MockAccessibilityBridgeNoWindow::textInputView
UIView< UITextInput > * textInputView() override
Definition: SemanticsObjectTestMocks.h:64
flutter::testing::MockAccessibilityBridgeNoWindow::DispatchSemanticsAction
void DispatchSemanticsAction(int32_t id, SemanticsAction action, fml::MallocMapping args) override
Definition: SemanticsObjectTestMocks.h:69
SemanticsObject(Tests)
Definition: SemanticsObjectTestMocks.h:89
flutter::testing::SemanticsActionObservation::id
int32_t id
Definition: SemanticsObjectTestMocks.h:20
flutter::testing::MockAccessibilityBridgeNoWindow::observations
std::vector< SemanticsActionObservation > observations
Definition: SemanticsObjectTestMocks.h:80
flutter::testing::MockAccessibilityBridgeNoWindow::AccessibilityObjectDidLoseFocus
void AccessibilityObjectDidLoseFocus(int32_t id) override
Definition: SemanticsObjectTestMocks.h:76
flutter::testing::MockAccessibilityBridge
Definition: SemanticsObjectTestMocks.h:24
flutter::testing::MockAccessibilityBridgeNoWindow::isVoiceOverRunning
bool isVoiceOverRunning() const override
Definition: SemanticsObjectTestMocks.h:62
flutter::testing::MockAccessibilityBridge::GetPlatformViewsController
std::shared_ptr< PlatformViewsController > GetPlatformViewsController() const override
Definition: SemanticsObjectTestMocks.h:46
flutter::testing::MockAccessibilityBridgeNoWindow::MockAccessibilityBridgeNoWindow
MockAccessibilityBridgeNoWindow()
Definition: SemanticsObjectTestMocks.h:59
flutter::testing::MockAccessibilityBridge::observations
std::vector< SemanticsActionObservation > observations
Definition: SemanticsObjectTestMocks.h:49
flutter::testing::MockAccessibilityBridge::MockAccessibilityBridge
MockAccessibilityBridge()
Definition: SemanticsObjectTestMocks.h:26
initWithFrame
instancetype initWithFrame
Definition: FlutterTextInputPlugin.h:172
flutter::testing::MockAccessibilityBridgeNoWindow::isVoiceOverRunningValue
bool isVoiceOverRunningValue
Definition: SemanticsObjectTestMocks.h:81
flutter::testing::SemanticsActionObservation::action
SemanticsAction action
Definition: SemanticsObjectTestMocks.h:21
flutter::testing::SemanticsActionObservation::SemanticsActionObservation
SemanticsActionObservation(int32_t observed_id, SemanticsAction observed_action)
Definition: SemanticsObjectTestMocks.h:17
flutter::testing::MockAccessibilityBridgeNoWindow::AccessibilityObjectDidBecomeFocused
void AccessibilityObjectDidBecomeFocused(int32_t id) override
Definition: SemanticsObjectTestMocks.h:75
flutter
Definition: accessibility_bridge.h:28
flutter::testing::MockAccessibilityBridgeNoWindow::view
UIView * view() const override
Definition: SemanticsObjectTestMocks.h:63
flutter::testing::MockAccessibilityBridgeNoWindow::DispatchSemanticsAction
void DispatchSemanticsAction(int32_t id, SemanticsAction action) override
Definition: SemanticsObjectTestMocks.h:65
flutter::AccessibilityBridgeIos
Interface that represents an accessibility bridge for iOS.
Definition: accessibility_bridge_ios.h:20
flutter::testing::MockAccessibilityBridge::DispatchSemanticsAction
void DispatchSemanticsAction(int32_t id, SemanticsAction action) override
Definition: SemanticsObjectTestMocks.h:34
flutter::testing::MockAccessibilityBridge::DispatchSemanticsAction
void DispatchSemanticsAction(int32_t id, SemanticsAction action, fml::MallocMapping args) override
Definition: SemanticsObjectTestMocks.h:38
flutter::testing::MockAccessibilityBridge::AccessibilityObjectDidLoseFocus
void AccessibilityObjectDidLoseFocus(int32_t id) override
Definition: SemanticsObjectTestMocks.h:45
flutter::testing::MockAccessibilityBridge::textInputView
UIView< UITextInput > * textInputView() override
Definition: SemanticsObjectTestMocks.h:33
SemanticsObject.h
flutter::testing::MockAccessibilityBridgeNoWindow
Definition: SemanticsObjectTestMocks.h:57
flutter::testing::MockAccessibilityBridge::isVoiceOverRunning
bool isVoiceOverRunning() const override
Definition: SemanticsObjectTestMocks.h:31
kScreenSize
const CGRect kScreenSize
Definition: SemanticsObjectTestMocks.h:10
flutter::testing::SemanticsActionObservation
Definition: SemanticsObjectTestMocks.h:15
flutter::testing::MockAccessibilityBridge::view
UIView * view() const override
Definition: SemanticsObjectTestMocks.h:32
flutter::testing::MockAccessibilityBridge::AccessibilityObjectDidBecomeFocused
void AccessibilityObjectDidBecomeFocused(int32_t id) override
Definition: SemanticsObjectTestMocks.h:44
flutter::testing::MockAccessibilityBridgeNoWindow::GetPlatformViewsController
std::shared_ptr< PlatformViewsController > GetPlatformViewsController() const override
Definition: SemanticsObjectTestMocks.h:77
flutter::testing::MockAccessibilityBridge::isVoiceOverRunningValue
bool isVoiceOverRunningValue
Definition: SemanticsObjectTestMocks.h:50