Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
single_frame_codec_unittests.cc
Go to the documentation of this file.
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/lib/ui/painting/single_frame_codec.h"
6
7#include <memory>
8
9#include "flutter/common/task_runners.h"
10#include "flutter/fml/synchronization/waitable_event.h"
11#include "flutter/runtime/dart_vm.h"
12#include "flutter/shell/common/shell_test.h"
13#include "flutter/shell/common/thread_host.h"
14#include "flutter/testing/testing.h"
15
16namespace flutter {
17namespace testing {
18
19TEST_F(ShellTest, SingleFrameCodecAccuratelyReportsSize) {
20 auto message_latch = std::make_shared<fml::AutoResetWaitableEvent>();
21
22 auto validate_codec = [](Dart_NativeArguments args) {
23 auto handle = Dart_GetNativeArgument(args, 0);
24 intptr_t peer = 0;
27 ASSERT_FALSE(Dart_IsError(result));
28 };
29 auto finish = [message_latch](Dart_NativeArguments args) {
30 message_latch->Signal();
31 };
32
33 Settings settings = CreateSettingsForFixture();
34 TaskRunners task_runners("test", // label
35 GetCurrentTaskRunner(), // platform
36 CreateNewThread(), // raster
37 CreateNewThread(), // ui
38 CreateNewThread() // io
39 );
40
41 AddNativeCallback("ValidateCodec", CREATE_NATIVE_ENTRY(validate_codec));
42 AddNativeCallback("Finish", CREATE_NATIVE_ENTRY(finish));
43
44 std::unique_ptr<Shell> shell = CreateShell(settings, task_runners);
45
46 ASSERT_TRUE(shell->IsSetup());
47 auto configuration = RunConfiguration::InferFromSettings(settings);
48 configuration.SetEntrypoint("createSingleFrameCodec");
49
50 shell->RunEngine(std::move(configuration), [](auto result) {
52 });
53
54 message_latch->Wait();
55 DestroyShell(std::move(shell), task_runners);
56}
57
58} // namespace testing
59} // namespace flutter
static RunConfiguration InferFromSettings(const Settings &settings, const fml::RefPtr< fml::TaskRunner > &io_worker=nullptr, IsolateLaunchType launch_type=IsolateLaunchType::kNewGroup)
Attempts to infer a run configuration from the settings object. This tries to create a run configurat...
struct _Dart_Handle * Dart_Handle
Definition dart_api.h:258
DART_EXPORT Dart_Handle Dart_GetNativeArgument(Dart_NativeArguments args, int index)
DART_EXPORT Dart_Handle Dart_GetNativeInstanceField(Dart_Handle obj, int index, intptr_t *value)
struct _Dart_NativeArguments * Dart_NativeArguments
Definition dart_api.h:3010
DART_EXPORT bool Dart_IsError(Dart_Handle handle)
G_BEGIN_DECLS G_MODULE_EXPORT FlValue * args
GAsyncResult * result
TEST_F(DisplayListTest, Defaults)
#define CREATE_NATIVE_ENTRY(native_entry)