未验证 提交 e2aa235a 编写于 作者: D David Worsham 提交者: GitHub

Fix most fml tests on Fuchsia (#14007)

* Add fuchsia MessageLoopImpl; fix several tests
上级 c2d451f6
......@@ -170,6 +170,8 @@ FILE: ../../../flutter/fml/platform/darwin/scoped_nsobject.mm
FILE: ../../../flutter/fml/platform/darwin/string_range_sanitization.h
FILE: ../../../flutter/fml/platform/darwin/string_range_sanitization.mm
FILE: ../../../flutter/fml/platform/darwin/string_range_sanitization_unittests.mm
FILE: ../../../flutter/fml/platform/fuchsia/message_loop_fuchsia.cc
FILE: ../../../flutter/fml/platform/fuchsia/message_loop_fuchsia.h
FILE: ../../../flutter/fml/platform/fuchsia/paths_fuchsia.cc
FILE: ../../../flutter/fml/platform/linux/message_loop_linux.cc
FILE: ../../../flutter/fml/platform/linux/message_loop_linux.h
......
......@@ -164,12 +164,28 @@ source_set("fml") {
}
if (is_fuchsia) {
sources += [ "platform/fuchsia/paths_fuchsia.cc" ]
sources += [
"platform/fuchsia/message_loop_fuchsia.cc",
"platform/fuchsia/message_loop_fuchsia.h",
"platform/fuchsia/paths_fuchsia.cc",
]
if (using_fuchsia_sdk) {
public_deps += [ "$fuchsia_sdk_root/pkg:trace" ]
public_deps += [
"$fuchsia_sdk_root/pkg:async-cpp",
"$fuchsia_sdk_root/pkg:async-loop-cpp",
"$fuchsia_sdk_root/pkg:async-loop-default",
"$fuchsia_sdk_root/pkg:trace",
"$fuchsia_sdk_root/pkg:zx",
]
} else {
public_deps += [ "//zircon/public/lib/trace" ]
public_deps += [
"//zircon/public/lib/async-cpp",
"//zircon/public/lib/async-loop-cpp",
"//zircon/public/lib/async-loop-default",
"//zircon/public/lib/trace",
"//zircon/public/lib/zx",
]
}
}
......@@ -205,16 +221,21 @@ executable("fml_unittests") {
sources = [
"base32_unittest.cc",
"command_line_unittest.cc",
"gpu_thread_merger_unittests.cc",
"memory/ref_counted_unittest.cc",
"memory/weak_ptr_unittest.cc",
"message_loop_task_queues_merge_unmerge_unittests.cc",
"message_loop_task_queues_unittests.cc",
"message_loop_unittests.cc",
"message_unittests.cc",
"paths_unittests.cc",
"platform/darwin/string_range_sanitization_unittests.mm",
"synchronization/count_down_latch_unittests.cc",
"synchronization/semaphore_unittest.cc",
"synchronization/sync_switch_unittest.cc",
"synchronization/waitable_event_unittest.cc",
"thread_local_unittests.cc",
"thread_unittests.cc",
"time/time_delta_unittest.cc",
"time/time_point_unittest.cc",
"time/time_unittest.cc",
......@@ -222,14 +243,7 @@ executable("fml_unittests") {
# TODO(gw280): Figure out why these tests don't work currently on Fuchsia
if (!is_fuchsia) {
sources += [
"file_unittest.cc",
"gpu_thread_merger_unittests.cc",
"message_loop_task_queues_unittests.cc",
"message_loop_unittests.cc",
"synchronization/count_down_latch_unittests.cc",
"thread_unittests.cc",
]
sources += [ "file_unittest.cc" ]
}
deps = [
......
......@@ -17,6 +17,8 @@
#include "flutter/fml/platform/darwin/message_loop_darwin.h"
#elif OS_ANDROID
#include "flutter/fml/platform/android/message_loop_android.h"
#elif OS_FUCHSIA
#include "flutter/fml/platform/fuchsia/message_loop_fuchsia.h"
#elif OS_LINUX
#include "flutter/fml/platform/linux/message_loop_linux.h"
#elif OS_WIN
......@@ -30,6 +32,8 @@ fml::RefPtr<MessageLoopImpl> MessageLoopImpl::Create() {
return fml::MakeRefCounted<MessageLoopDarwin>();
#elif OS_ANDROID
return fml::MakeRefCounted<MessageLoopAndroid>();
#elif OS_FUCHSIA
return fml::MakeRefCounted<MessageLoopFuchsia>();
#elif OS_LINUX
return fml::MakeRefCounted<MessageLoopLinux>();
#elif OS_WIN
......
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "flutter/fml/platform/fuchsia/message_loop_fuchsia.h"
#include <lib/async-loop/default.h>
#include <lib/async/cpp/task.h>
#include <lib/zx/time.h>
namespace fml {
MessageLoopFuchsia::MessageLoopFuchsia()
: loop_(&kAsyncLoopConfigAttachToCurrentThread) {}
MessageLoopFuchsia::~MessageLoopFuchsia() = default;
void MessageLoopFuchsia::Run() {
loop_.Run();
}
void MessageLoopFuchsia::Terminate() {
loop_.Quit();
}
void MessageLoopFuchsia::WakeUp(fml::TimePoint time_point) {
fml::TimePoint now = fml::TimePoint::Now();
zx::duration due_time{0};
if (time_point > now) {
due_time = zx::nsec((time_point - now).ToNanoseconds());
}
FML_DCHECK(async::PostDelayedTask(
loop_.dispatcher(), [this]() { RunExpiredTasksNow(); },
due_time) == ZX_OK);
}
} // namespace fml
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef FLUTTER_FML_PLATFORM_FUCHSIA_MESSAGE_LOOP_FUCHSIA_H_
#define FLUTTER_FML_PLATFORM_FUCHSIA_MESSAGE_LOOP_FUCHSIA_H_
#include <lib/async-loop/cpp/loop.h>
#include "flutter/fml/macros.h"
#include "flutter/fml/message_loop_impl.h"
namespace fml {
class MessageLoopFuchsia : public MessageLoopImpl {
private:
MessageLoopFuchsia();
~MessageLoopFuchsia() override;
void Run() override;
void Terminate() override;
void WakeUp(fml::TimePoint time_point) override;
async::Loop loop_;
FML_FRIEND_MAKE_REF_COUNTED(MessageLoopFuchsia);
FML_FRIEND_REF_COUNTED_THREAD_SAFE(MessageLoopFuchsia);
FML_DISALLOW_COPY_AND_ASSIGN(MessageLoopFuchsia);
};
} // namespace fml
#endif // FLUTTER_FML_PLATFORM_FUCHSIA_MESSAGE_LOOP_FUCHSIA_H_
......@@ -10,7 +10,7 @@
"services": [
"fuchsia.accessibility.semantics.SemanticsManager",
"fuchsia.intl.PropertyProvider",
"fuchsia.sys.Launcher"
"fuchsia.process.Launcher"
]
}
}
......@@ -9,7 +9,7 @@
],
"services": [
"fuchsia.accessibility.semantics.SemanticsManager",
"fuchsia.sys.Launcher"
"fuchsia.process.Launcher"
]
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册