Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
chunhtai committed Nov 18, 2024
1 parent 77cce92 commit 4faea5a
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 49 deletions.
54 changes: 24 additions & 30 deletions runtime/runtime_controller_unittests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
#include "flutter/runtime/runtime_delegate.h"

#include "flutter/lib/ui/semantics/semantics_update.h"
#include "flutter/testing/testing.h"
#include "flutter/shell/common/shell_test.h"
#include "flutter/testing/testing.h"

namespace flutter {

Expand All @@ -20,75 +20,69 @@ class MockRuntimeDelegate : public RuntimeDelegate {
FontCollection font;
std::vector<SemanticsNodeUpdates> updates;
std::vector<CustomAccessibilityActionUpdates> actions;
std::string DefaultRouteName() override {
return "";
}
std::string DefaultRouteName() override { return ""; }

void ScheduleFrame(bool regenerate_layer_trees = true) override {}

void OnAllViewsRendered() override {}

void Render(int64_t view_id,
std::unique_ptr<flutter::LayerTree> layer_tree,
float device_pixel_ratio) override {}
std::unique_ptr<flutter::LayerTree> layer_tree,
float device_pixel_ratio) override {}

void UpdateSemantics(SemanticsNodeUpdates update,
CustomAccessibilityActionUpdates actions) override {
CustomAccessibilityActionUpdates actions) override {
this->updates.push_back(update);
this->actions.push_back(actions);
}

void HandlePlatformMessage(
std::unique_ptr<PlatformMessage> message) override {}

FontCollection& GetFontCollection() override {
return font;
}
FontCollection& GetFontCollection() override { return font; }

std::shared_ptr<AssetManager> GetAssetManager() override {
return nullptr;
}
std::shared_ptr<AssetManager> GetAssetManager() override { return nullptr; }

void OnRootIsolateCreated() override {};

void UpdateIsolateDescription(const std::string isolate_name,
int64_t isolate_port) override {};
int64_t isolate_port) override {};

void SetNeedsReportTimings(bool value) override {};

std::unique_ptr<std::vector<std::string>>
ComputePlatformResolvedLocale(
std::unique_ptr<std::vector<std::string>> ComputePlatformResolvedLocale(
const std::vector<std::string>& supported_locale_data) override {
return nullptr;
}

void RequestDartDeferredLibrary(intptr_t loading_unit_id) override {}

std::weak_ptr<PlatformMessageHandler> GetPlatformMessageHandler() const override {
std::weak_ptr<PlatformMessageHandler> GetPlatformMessageHandler()
const override {
return {};
}

void SendChannelUpdate(std::string name, bool listening) override {}

double GetScaledFontSize(double unscaled_font_size,
int configuration_id) const override {
int configuration_id) const override {
return 0.0;
}
};

class RuntimeControllerTester {
public:
RuntimeControllerTester(UIDartState::Context& context) : context_(context),
runtime_controller_(delegate_,
nullptr,
{},
{},
{},
{},
{},
nullptr,
context_) {
}
RuntimeControllerTester(UIDartState::Context& context)
: context_(context),
runtime_controller_(delegate_,
nullptr,
{},
{},
{},
{},
{},
nullptr,
context_) {}

MockRuntimeDelegate delegate_;
UIDartState::Context& context_;
Expand Down Expand Up @@ -144,5 +138,5 @@ TEST_F(RuntimeControllerTest, CanHandleAttributedStrings) {
DestroyShell(std::move(shell), task_runners);
}

}
} // namespace testing
} // namespace flutter
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,8 @@ static bool DidFlagChange(const flutter::SemanticsNode& oldNode,
NSString* type = message[@"type"];
if ([type isEqualToString:@"announce"]) {
NSString* messageToAnnounce = message[@"data"][@"message"];
ios_delegate_->PostAccessibilityNotification(UIAccessibilityAnnouncementNotification, messageToAnnounce);
ios_delegate_->PostAccessibilityNotification(UIAccessibilityAnnouncementNotification,
messageToAnnounce);
}
if ([type isEqualToString:@"focus"]) {
SemanticsObject* node = objects_[message[@"nodeId"]];
Expand Down
6 changes: 2 additions & 4 deletions shell/platform/darwin/ios/platform_view_ios.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
namespace flutter {

namespace testing {
class TestPlatformViewIOS;
class TestPlatformViewIOS;
}

/**
Expand Down Expand Up @@ -107,9 +107,7 @@ class PlatformViewIOS : public PlatformView {
return platform_message_handler_;
}

AccessibilityBridge* GetAccessibilityBridge() {
return accessibility_bridge_.get();
}
AccessibilityBridge* GetAccessibilityBridge() { return accessibility_bridge_.get(); }

/**
* Handles accessibility message from accessibility channel.
Expand Down
12 changes: 6 additions & 6 deletions shell/platform/darwin/ios/platform_view_ios.mm
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,10 @@ new PlatformMessageHandlerIos(task_runners.GetPlatformTaskRunner())) {}
accessibility_bridge_.reset();
}
if (owner_controller) {
accessibility_channel_ =
[[FlutterBasicMessageChannel alloc] initWithName:@"flutter/accessibility"
binaryMessenger:owner_controller.engine.binaryMessenger
codec:[FlutterStandardMessageCodec sharedInstance]];
accessibility_channel_ = [[FlutterBasicMessageChannel alloc]
initWithName:@"flutter/accessibility"
binaryMessenger:owner_controller.engine.binaryMessenger
codec:[FlutterStandardMessageCodec sharedInstance]];
[accessibility_channel_ setMessageHandler:^(id message, FlutterReply reply) {
handleAccessibilityMessage(message, reply);
}];
Expand Down Expand Up @@ -130,8 +130,8 @@ new PlatformMessageHandlerIos(task_runners.GetPlatformTaskRunner())) {}
BOOL generating = [message[@"data"][@"generating"] boolValue];
if (generating) {
if (!accessibility_bridge_) {
accessibility_bridge_ = std::make_unique<AccessibilityBridge>(
owner_controller_, this, platform_views_controller_);
accessibility_bridge_ = std::make_unique<AccessibilityBridge>(owner_controller_, this,
platform_views_controller_);
}
} else {
accessibility_bridge_.reset();
Expand Down
12 changes: 4 additions & 8 deletions shell/platform/darwin/ios/platform_view_ios_test.mm
Original file line number Diff line number Diff line change
Expand Up @@ -103,15 +103,11 @@ - (void)testCreate {
thread_task_runner->PostTask([&] {
platform_view->SetOwnerViewController(flutterViewController);
XCTAssertFalse(platform_view->GetAccessibilityBridge());
platform_view->handleAccessibilityMessage(@{
@"type": @"generatingSemanticsTree",
@"data": @{@"generating": @(YES)}
}, nil);
platform_view->handleAccessibilityMessage(
@{@"type" : @"generatingSemanticsTree", @"data" : @{@"generating" : @(YES)}}, nil);
XCTAssertTrue(platform_view->GetAccessibilityBridge());
platform_view->handleAccessibilityMessage(@{
@"type": @"generatingSemanticsTree",
@"data": @{@"generating": @(NO)}
}, nil);
platform_view->handleAccessibilityMessage(
@{@"type" : @"generatingSemanticsTree", @"data" : @{@"generating" : @(NO)}}, nil);
XCTAssertFalse(platform_view->GetAccessibilityBridge());
latch.Signal();
});
Expand Down

0 comments on commit 4faea5a

Please sign in to comment.