Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Format
  • Loading branch information
yaakovschectman committed Oct 26, 2022
commit 885f4dc4c54fdbe982fd15699becd50816635ebd
3 changes: 2 additions & 1 deletion shell/platform/windows/accessibility_root_node.cc
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,8 @@ IFACEMETHODIMP AccessibilityRootNode::get_accChild(VARIANT var_child,
} else if (child_id == kAlertChildId && alert_accessible_) {
*disp_child = alert_accessible_;
} else if (child_id < 0) {
// A negative child ID can be used to refer to an AX node directly by its ID.
// A negative child ID can be used to refer to an AX node directly by its
// ID.
return window_accessible_->get_accChild(var_child, disp_child);
} else {
return E_FAIL;
Expand Down
5 changes: 4 additions & 1 deletion shell/platform/windows/flutter_window_unittests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,10 @@ TEST(FlutterWindowTest, AlertNode) {
ON_CALL(*win32window, GetPlatformWindow()).WillByDefault(Return(nullptr));
AccessibilityRootNode* root_node = win32window->GetAccessibilityRootNode();
TestFlutterWindowsView view(std::move(win32window));
EXPECT_CALL(view, NotifyWinEventWrapper(EVENT_SYSTEM_ALERT, nullptr, OBJID_CLIENT, AccessibilityRootNode::kAlertChildId)).Times(1);
EXPECT_CALL(view,
NotifyWinEventWrapper(EVENT_SYSTEM_ALERT, nullptr, OBJID_CLIENT,
AccessibilityRootNode::kAlertChildId))
.Times(1);
std::wstring message = L"Test alert";
view.AnnounceAlert(message);
IAccessible* alert = root_node->GetOrCreateAlert();
Expand Down
30 changes: 16 additions & 14 deletions shell/platform/windows/flutter_windows_engine_unittests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,8 @@ TEST_F(FlutterWindowsEngineTest, PostRasterThreadTask) {

class MockFlutterWindowsView : public FlutterWindowsView {
public:
MockFlutterWindowsView(std::unique_ptr<WindowBindingHandler> wbh) : FlutterWindowsView(std::move(wbh)) {}
MockFlutterWindowsView(std::unique_ptr<WindowBindingHandler> wbh)
: FlutterWindowsView(std::move(wbh)) {}
~MockFlutterWindowsView() {}

MOCK_METHOD4(NotifyWinEventWrapper, void(DWORD, HWND, LONG, LONG));
Expand All @@ -535,9 +536,11 @@ TEST_F(FlutterWindowsEngineTest, AlertPlatformMessage) {

FlutterProjectBundle project(properties);

auto window_binding_handler = std::make_unique<::testing::NiceMock<MockWindowBindingHandler>>();
auto window_binding_handler =
std::make_unique<::testing::NiceMock<MockWindowBindingHandler>>();
AccessibilityRootNode* root_node = AccessibilityRootNode::Create();
ON_CALL(*window_binding_handler, GetAccessibilityRootNode).WillByDefault(::testing::Return(root_node));
ON_CALL(*window_binding_handler, GetAccessibilityRootNode)
.WillByDefault(::testing::Return(root_node));
MockFlutterWindowsView view(std::move(window_binding_handler));
view.SetEngine(std::make_unique<FlutterWindowsEngine>(project));
FlutterWindowsEngine* engine = view.GetEngine();
Expand All @@ -548,23 +551,22 @@ TEST_F(FlutterWindowsEngineTest, AlertPlatformMessage) {
auto binary_messenger =
std::make_unique<BinaryMessengerImpl>(engine->messenger());
binary_messenger->SetMessageHandler(
"semantics",
[&engine](
const uint8_t* message, size_t message_size, BinaryReply reply) {
engine->UpdateSemanticsEnabled(true);
char response[] = "";
reply(reinterpret_cast<uint8_t*>(response), 0);
"semantics", [&engine](const uint8_t* message, size_t message_size,
BinaryReply reply) {
engine->UpdateSemanticsEnabled(true);
char response[] = "";
reply(reinterpret_cast<uint8_t*>(response), 0);
});

bool did_call = false;
ON_CALL(view, NotifyWinEventWrapper).WillByDefault([&did_call](DWORD event, HWND hwnd, LONG obj, LONG child) {
did_call = true;
});

ON_CALL(view, NotifyWinEventWrapper)
.WillByDefault([&did_call](DWORD event, HWND hwnd, LONG obj, LONG child) {
did_call = true;
});

engine->UpdateSemanticsEnabled(true);
engine->Run();

// Rely on timeout mechanism in CI.
while (!did_call) {
engine->task_runner()->ProcessTasks();
Expand Down
11 changes: 8 additions & 3 deletions shell/platform/windows/flutter_windows_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -657,15 +657,20 @@ FlutterWindowsEngine* FlutterWindowsView::GetEngine() {
}

void FlutterWindowsView::AnnounceAlert(const std::wstring& text) {
AccessibilityRootNode* root_node = binding_handler_->GetAccessibilityRootNode();
AccessibilityRootNode* root_node =
binding_handler_->GetAccessibilityRootNode();
AccessibilityAlert* alert =
binding_handler_->GetAccessibilityRootNode()->GetOrCreateAlert();
alert->SetText(text);
HWND hwnd = GetPlatformWindow();
NotifyWinEventWrapper(EVENT_SYSTEM_ALERT, hwnd, OBJID_CLIENT, AccessibilityRootNode::kAlertChildId);
NotifyWinEventWrapper(EVENT_SYSTEM_ALERT, hwnd, OBJID_CLIENT,
AccessibilityRootNode::kAlertChildId);
}

void FlutterWindowsView::NotifyWinEventWrapper(DWORD event, HWND hwnd, LONG idObject, LONG idChild) {
void FlutterWindowsView::NotifyWinEventWrapper(DWORD event,
HWND hwnd,
LONG idObject,
LONG idChild) {
if (hwnd) {
NotifyWinEvent(EVENT_SYSTEM_ALERT, hwnd, OBJID_CLIENT,
AccessibilityRootNode::kAlertChildId);
Expand Down
5 changes: 4 additions & 1 deletion shell/platform/windows/flutter_windows_view.h
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,10 @@ class FlutterWindowsView : public WindowBindingHandlerDelegate,
virtual std::unique_ptr<TextInputPlugin> CreateTextInputPlugin(
BinaryMessenger* messenger);

virtual void NotifyWinEventWrapper(DWORD event, HWND hwnd, LONG idObject, LONG idChild);
virtual void NotifyWinEventWrapper(DWORD event,
HWND hwnd,
LONG idObject,
LONG idChild);

private:
// Struct holding the state of an individual pointer. The engine doesn't keep
Expand Down