Flutter Engine
The Flutter Engine
windows_test_context.h
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#ifndef FLUTTER_SHELL_PLATFORM_WINDOWS_TESTING_WINDOWS_TEST_CONTEXT_H_
6#define FLUTTER_SHELL_PLATFORM_WINDOWS_TESTING_WINDOWS_TEST_CONTEXT_H_
7
8#include <string>
9#include <string_view>
10#include <vector>
11
12#include "flutter/fml/closure.h"
13#include "flutter/fml/macros.h"
14#include "flutter/testing/test_dart_native_resolver.h"
15
16namespace flutter {
17namespace testing {
18
19// Context associated with the current Windows test fixture.
20//
21// Context data includes global Flutter and Dart runtime context such as the
22// path of Flutter's asset directory, ICU path, and resolvers for any
23// registered native functions.
25 public:
26 explicit WindowsTestContext(std::string_view assets_path = "");
28
29 // Returns the path to assets required by the Flutter runtime.
30 const std::wstring& GetAssetsPath() const;
31
32 // Returns the path to the ICU library data file.
33 const std::wstring& GetIcuDataPath() const;
34
35 // Returns the path to the application's AOT library file.
36 const std::wstring& GetAotLibraryPath() const;
37
38 // Registers a native function callable from Dart code in test fixtures. In
39 // the Dart test fixture, the associated function can be declared as:
40 //
41 // @pragma('vm:external-name', 'IdentifyingName')
42 // external ReturnType functionName();
43 //
44 // where `IdentifyingName` matches the |name| parameter to this method.
45 void AddNativeFunction(std::string_view name, Dart_NativeFunction function);
46
47 // Returns the root isolate create callback to register with the Flutter
48 // runtime.
50
51 private:
52 std::wstring assets_path_;
53 std::wstring icu_data_path_ = L"icudtl.dat";
54 std::wstring aot_library_path_ = L"aot.so";
55 std::vector<fml::closure> isolate_create_callbacks_;
56 std::shared_ptr<TestDartNativeResolver> native_resolver_;
57
58 FML_DISALLOW_COPY_AND_ASSIGN(WindowsTestContext);
59};
60
61} // namespace testing
62} // namespace flutter
63
64#endif // FLUTTER_SHELL_PLATFORM_WINDOWS_TESTING_WINDOWS_TEST_CONTEXT_H_
const std::wstring & GetIcuDataPath() const
void AddNativeFunction(std::string_view name, Dart_NativeFunction function)
const std::wstring & GetAssetsPath() const
const std::wstring & GetAotLibraryPath() const
WindowsTestContext(std::string_view assets_path="")
void(* Dart_NativeFunction)(Dart_NativeArguments arguments)
Definition: dart_api.h:3207
Dart_NativeFunction function
Definition: fuchsia.cc:51
DEF_SWITCHES_START aot vmservice shared library name
Definition: switches.h:32
std::function< void()> closure
Definition: closure.h:14