Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 1fbef2b

Browse files
committed
fix all test
1 parent eb6657f commit 1fbef2b

File tree

7 files changed

+21
-26
lines changed

7 files changed

+21
-26
lines changed

shell/platform/common/accessibility_bridge.cc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ AccessibilityBridge::AccessibilityBridge(
2929
AccessibilityBridge::~AccessibilityBridge() {
3030
event_generator_.ReleaseTree();
3131
tree_.RemoveObserver(static_cast<ui::AXTreeObserver*>(this));
32+
id_wrapper_map_.clear();
3233
}
3334

3435
void AccessibilityBridge::AddFlutterSemanticsNodeUpdate(
@@ -329,7 +330,7 @@ void AccessibilityBridge::SetBooleanAttributesFromFlutterUpdate(
329330
node_data.AddBoolAttribute(
330331
ax::mojom::BoolAttribute::kEditableRoot,
331332
flags & FlutterSemanticsFlag::kFlutterSemanticsFlagIsTextField &&
332-
(flags & FlutterSemanticsFlag::kFlutterSemanticsFlagIsReadOnly) > 0);
333+
(flags & FlutterSemanticsFlag::kFlutterSemanticsFlagIsReadOnly) == 0);
333334
}
334335

335336
void AccessibilityBridge::SetIntAttributesFromFlutterUpdate(
@@ -348,6 +349,8 @@ void AccessibilityBridge::SetIntAttributesFromFlutterUpdate(
348349
sel_start = sel_start == -1 ? node.value.length() : sel_start;
349350
sel_end = sel_end == -1 ? node.value.length() : sel_end;
350351
}
352+
BASE_LOG() << "node id " << node_data.id << " sel_start = " << sel_start
353+
<< " sel_end = " << sel_end;
351354
node_data.AddIntAttribute(ax::mojom::IntAttribute::kTextSelStart, sel_start);
352355
node_data.AddIntAttribute(ax::mojom::IntAttribute::kTextSelEnd, sel_end);
353356

shell/platform/darwin/macos/framework/Source/FlutterEngine.mm

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -451,15 +451,15 @@ - (void)setSemanticsEnabled:(BOOL)enabled {
451451
return;
452452
}
453453
_semanticsEnabled = enabled;
454+
if (!_semanticsEnabled) {
455+
self.viewController.flutterView.accessibilityChildren = nil;
456+
}
454457
if (!_semanticsEnabled && _bridge) {
455458
_bridge.reset();
456459
} else if (_semanticsEnabled && !_bridge) {
457460
_bridge = std::make_shared<flutter::AccessibilityBridge>(
458461
std::make_unique<flutter::AccessibilityBridgeMacDelegate>(self));
459462
}
460-
if (!_semanticsEnabled) {
461-
self.viewController.flutterView.accessibilityChildren = nil;
462-
}
463463
_embedderAPI.UpdateSemanticsEnabled(_engine, _semanticsEnabled);
464464
}
465465

shell/platform/darwin/macos/framework/Source/FlutterEngineTest.mm

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@
7676
initWithAssetsPath:fixtures
7777
ICUDataPath:[fixtures stringByAppendingString:@"/icudtl.dat"]];
7878
FlutterViewController* viewController = [[FlutterViewController alloc] initWithProject:project];
79+
[viewController loadView];
7980
[engine setViewController:viewController];
8081
// Enable the semantics.
8182
bool enabled_called = false;
@@ -128,18 +129,18 @@
128129
update_action_callback(&action_batch_end, (void*)CFBridgingRetain(engine));
129130

130131
// Verify the accessibility tree is attached to the flutter view.
131-
EXPECT_EQ([engine.viewController.view.accessibilityChildren count], 1u);
132-
NSAccessibilityElement* native_root = engine.viewController.view.accessibilityChildren[0];
132+
EXPECT_EQ([engine.viewController.flutterView.accessibilityChildren count], 1u);
133+
NSAccessibilityElement* native_root = engine.viewController.flutterView.accessibilityChildren[0];
133134
std::string root_label = [native_root.accessibilityLabel UTF8String];
134-
EXPECT_TRUE(root_label == "root");
135+
135136
EXPECT_EQ(native_root.accessibilityRole, NSAccessibilityGroupRole);
136137
EXPECT_EQ([native_root.accessibilityChildren count], 1u);
137138
NSAccessibilityElement* native_child1 = native_root.accessibilityChildren[0];
138139
std::string child1_value = [native_child1.accessibilityValue UTF8String];
139140
EXPECT_TRUE(child1_value == "child 1");
140141
EXPECT_EQ(native_child1.accessibilityRole, NSAccessibilityStaticTextRole);
141142
EXPECT_EQ([native_child1.accessibilityChildren count], 0u);
142-
143+
NSLog(@"reach the end of the test1");
143144
// Disable the semantics.
144145
bool semanticsEnabled = true;
145146
engine.embedderAPI.UpdateSemanticsEnabled =
@@ -148,12 +149,15 @@
148149
return kSuccess;
149150
}));
150151
engine.semanticsEnabled = NO;
152+
NSLog(@"reach the end of the test2");
151153
EXPECT_FALSE(semanticsEnabled);
152154
// Verify the accessibility tree is removed from the view.
153-
EXPECT_EQ([engine.viewController.view.accessibilityChildren count], 0u);
154-
155+
EXPECT_EQ([engine.viewController.flutterView.accessibilityChildren count], 0u);
156+
NSLog(@"reach the end of the test3");
155157
[engine setViewController:nil];
158+
NSLog(@"reach the end of the test4");
156159
[engine shutDownEngine];
160+
NSLog(@"reach the end of the test5");
157161
}
158162

159163
} // namespace flutter::testing

shell/platform/darwin/macos/framework/Source/FlutterPlatformNodeDelegateMac.mm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@
3434
}
3535

3636
FlutterPlatformNodeDelegateMac::~FlutterPlatformNodeDelegateMac() {
37+
// Destroy() also calls delete on itself.
3738
ax_platform_node_->Destroy();
38-
delete ax_platform_node_;
3939
}
4040

4141
gfx::NativeViewAccessible FlutterPlatformNodeDelegateMac::GetNativeViewAccessible() {

shell/platform/darwin/macos/framework/Source/FlutterViewController.mm

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -404,12 +404,6 @@ - (void)setMouseTrackingMode:(FlutterMouseTrackingMode)mode {
404404
[self configureTrackingArea];
405405
}
406406

407-
// #pragma mark - Framework-internal methods
408-
409-
// - (FlutterView*)flutterView {
410-
// return static_cast<FlutterView*>(self.flutterView);
411-
// }
412-
413407
#pragma mark - Private methods
414408

415409
- (BOOL)launchEngine {

shell/platform/darwin/macos/framework/Source/FlutterViewController_Internal.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,4 @@
3636
nibName:(nullable NSString*)nibName
3737
bundle:(nullable NSBundle*)nibBundle NS_DESIGNATED_INITIALIZER;
3838

39-
#pragma mark - Private interface declaration.
4039
@end

third_party/accessibility/ax/platform/ax_platform_node_mac.mm

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -704,18 +704,13 @@ - (NSString*)AXSelectedTextInternal {
704704
}
705705

706706
- (NSValue*)AXSelectedTextRangeInternal {
707-
// Selection might not be supported. Return (NSRange){0,0} in that case.
708-
int start = 0, end = 0;
709-
if (_node->IsPlainTextField()) {
710-
start = _node->GetIntAttribute(ax::mojom::IntAttribute::kTextSelStart);
711-
end = _node->GetIntAttribute(ax::mojom::IntAttribute::kTextSelEnd);
712-
}
707+
int start = _node->GetIntAttribute(ax::mojom::IntAttribute::kTextSelStart);
708+
int end = _node->GetIntAttribute(ax::mojom::IntAttribute::kTextSelEnd);
713709
NSAssert((start >= 0 && end >= 0) || (start == -1 && end == -1), @"selection is invalid");
714710

715711
if (start == -1 && end == -1) {
716712
return [NSValue valueWithRange:{NSNotFound, 0}];
717713
}
718-
719714
// NSRange cannot represent the direction the text was selected in.
720715
return [NSValue valueWithRange:{static_cast<NSUInteger>(std::min(start, end)),
721716
static_cast<NSUInteger>(abs(end - start))}];
@@ -931,7 +926,7 @@ - (NSString*)accessibilitySelectedText {
931926
- (NSRange)accessibilitySelectedTextRange {
932927
if (!_node)
933928
return NSMakeRange(0, 0);
934-
929+
NSLog(@"accessibilitySelectedTextRange is not null");
935930
NSRange r;
936931
[[self AXSelectedTextRangeInternal] getValue:&r];
937932
return r;

0 commit comments

Comments
 (0)