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

Commit e2aa235

Browse files
authored
Fix most fml tests on Fuchsia (#14007)
* Add fuchsia MessageLoopImpl; fix several tests
1 parent c2d451f commit e2aa235

File tree

7 files changed

+107
-13
lines changed

7 files changed

+107
-13
lines changed

ci/licenses_golden/licenses_flutter

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,8 @@ FILE: ../../../flutter/fml/platform/darwin/scoped_nsobject.mm
170170
FILE: ../../../flutter/fml/platform/darwin/string_range_sanitization.h
171171
FILE: ../../../flutter/fml/platform/darwin/string_range_sanitization.mm
172172
FILE: ../../../flutter/fml/platform/darwin/string_range_sanitization_unittests.mm
173+
FILE: ../../../flutter/fml/platform/fuchsia/message_loop_fuchsia.cc
174+
FILE: ../../../flutter/fml/platform/fuchsia/message_loop_fuchsia.h
173175
FILE: ../../../flutter/fml/platform/fuchsia/paths_fuchsia.cc
174176
FILE: ../../../flutter/fml/platform/linux/message_loop_linux.cc
175177
FILE: ../../../flutter/fml/platform/linux/message_loop_linux.h

fml/BUILD.gn

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -164,12 +164,28 @@ source_set("fml") {
164164
}
165165

166166
if (is_fuchsia) {
167-
sources += [ "platform/fuchsia/paths_fuchsia.cc" ]
167+
sources += [
168+
"platform/fuchsia/message_loop_fuchsia.cc",
169+
"platform/fuchsia/message_loop_fuchsia.h",
170+
"platform/fuchsia/paths_fuchsia.cc",
171+
]
168172

169173
if (using_fuchsia_sdk) {
170-
public_deps += [ "$fuchsia_sdk_root/pkg:trace" ]
174+
public_deps += [
175+
"$fuchsia_sdk_root/pkg:async-cpp",
176+
"$fuchsia_sdk_root/pkg:async-loop-cpp",
177+
"$fuchsia_sdk_root/pkg:async-loop-default",
178+
"$fuchsia_sdk_root/pkg:trace",
179+
"$fuchsia_sdk_root/pkg:zx",
180+
]
171181
} else {
172-
public_deps += [ "//zircon/public/lib/trace" ]
182+
public_deps += [
183+
"//zircon/public/lib/async-cpp",
184+
"//zircon/public/lib/async-loop-cpp",
185+
"//zircon/public/lib/async-loop-default",
186+
"//zircon/public/lib/trace",
187+
"//zircon/public/lib/zx",
188+
]
173189
}
174190
}
175191

@@ -205,31 +221,29 @@ executable("fml_unittests") {
205221
sources = [
206222
"base32_unittest.cc",
207223
"command_line_unittest.cc",
224+
"gpu_thread_merger_unittests.cc",
208225
"memory/ref_counted_unittest.cc",
209226
"memory/weak_ptr_unittest.cc",
210227
"message_loop_task_queues_merge_unmerge_unittests.cc",
228+
"message_loop_task_queues_unittests.cc",
229+
"message_loop_unittests.cc",
211230
"message_unittests.cc",
212231
"paths_unittests.cc",
213232
"platform/darwin/string_range_sanitization_unittests.mm",
233+
"synchronization/count_down_latch_unittests.cc",
214234
"synchronization/semaphore_unittest.cc",
215235
"synchronization/sync_switch_unittest.cc",
216236
"synchronization/waitable_event_unittest.cc",
217237
"thread_local_unittests.cc",
238+
"thread_unittests.cc",
218239
"time/time_delta_unittest.cc",
219240
"time/time_point_unittest.cc",
220241
"time/time_unittest.cc",
221242
]
222243

223244
# TODO(gw280): Figure out why these tests don't work currently on Fuchsia
224245
if (!is_fuchsia) {
225-
sources += [
226-
"file_unittest.cc",
227-
"gpu_thread_merger_unittests.cc",
228-
"message_loop_task_queues_unittests.cc",
229-
"message_loop_unittests.cc",
230-
"synchronization/count_down_latch_unittests.cc",
231-
"thread_unittests.cc",
232-
]
246+
sources += [ "file_unittest.cc" ]
233247
}
234248

235249
deps = [

fml/message_loop_impl.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
#include "flutter/fml/platform/darwin/message_loop_darwin.h"
1818
#elif OS_ANDROID
1919
#include "flutter/fml/platform/android/message_loop_android.h"
20+
#elif OS_FUCHSIA
21+
#include "flutter/fml/platform/fuchsia/message_loop_fuchsia.h"
2022
#elif OS_LINUX
2123
#include "flutter/fml/platform/linux/message_loop_linux.h"
2224
#elif OS_WIN
@@ -30,6 +32,8 @@ fml::RefPtr<MessageLoopImpl> MessageLoopImpl::Create() {
3032
return fml::MakeRefCounted<MessageLoopDarwin>();
3133
#elif OS_ANDROID
3234
return fml::MakeRefCounted<MessageLoopAndroid>();
35+
#elif OS_FUCHSIA
36+
return fml::MakeRefCounted<MessageLoopFuchsia>();
3337
#elif OS_LINUX
3438
return fml::MakeRefCounted<MessageLoopLinux>();
3539
#elif OS_WIN
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
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+
#include "flutter/fml/platform/fuchsia/message_loop_fuchsia.h"
6+
7+
#include <lib/async-loop/default.h>
8+
#include <lib/async/cpp/task.h>
9+
#include <lib/zx/time.h>
10+
11+
namespace fml {
12+
13+
MessageLoopFuchsia::MessageLoopFuchsia()
14+
: loop_(&kAsyncLoopConfigAttachToCurrentThread) {}
15+
16+
MessageLoopFuchsia::~MessageLoopFuchsia() = default;
17+
18+
void MessageLoopFuchsia::Run() {
19+
loop_.Run();
20+
}
21+
22+
void MessageLoopFuchsia::Terminate() {
23+
loop_.Quit();
24+
}
25+
26+
void MessageLoopFuchsia::WakeUp(fml::TimePoint time_point) {
27+
fml::TimePoint now = fml::TimePoint::Now();
28+
zx::duration due_time{0};
29+
if (time_point > now) {
30+
due_time = zx::nsec((time_point - now).ToNanoseconds());
31+
}
32+
33+
FML_DCHECK(async::PostDelayedTask(
34+
loop_.dispatcher(), [this]() { RunExpiredTasksNow(); },
35+
due_time) == ZX_OK);
36+
}
37+
38+
} // namespace fml
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
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_FML_PLATFORM_FUCHSIA_MESSAGE_LOOP_FUCHSIA_H_
6+
#define FLUTTER_FML_PLATFORM_FUCHSIA_MESSAGE_LOOP_FUCHSIA_H_
7+
8+
#include <lib/async-loop/cpp/loop.h>
9+
10+
#include "flutter/fml/macros.h"
11+
#include "flutter/fml/message_loop_impl.h"
12+
13+
namespace fml {
14+
15+
class MessageLoopFuchsia : public MessageLoopImpl {
16+
private:
17+
MessageLoopFuchsia();
18+
19+
~MessageLoopFuchsia() override;
20+
21+
void Run() override;
22+
23+
void Terminate() override;
24+
25+
void WakeUp(fml::TimePoint time_point) override;
26+
27+
async::Loop loop_;
28+
29+
FML_FRIEND_MAKE_REF_COUNTED(MessageLoopFuchsia);
30+
FML_FRIEND_REF_COUNTED_THREAD_SAFE(MessageLoopFuchsia);
31+
FML_DISALLOW_COPY_AND_ASSIGN(MessageLoopFuchsia);
32+
};
33+
34+
} // namespace fml
35+
36+
#endif // FLUTTER_FML_PLATFORM_FUCHSIA_MESSAGE_LOOP_FUCHSIA_H_

shell/platform/fuchsia/flutter/meta/flutter_runner_tests.cmx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"services": [
1111
"fuchsia.accessibility.semantics.SemanticsManager",
1212
"fuchsia.intl.PropertyProvider",
13-
"fuchsia.sys.Launcher"
13+
"fuchsia.process.Launcher"
1414
]
1515
}
1616
}

testing/fuchsia/meta/fuchsia_test.cmx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
],
1010
"services": [
1111
"fuchsia.accessibility.semantics.SemanticsManager",
12-
"fuchsia.sys.Launcher"
12+
"fuchsia.process.Launcher"
1313
]
1414
}
1515
}

0 commit comments

Comments
 (0)