Flutter Engine
The Flutter Engine
FlutterEngineTestUtils.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_DARWIN_MACOS_FRAMEWORK_SOURCE_FLUTTERENGINETESTUTILS_H_
6#define FLUTTER_SHELL_PLATFORM_DARWIN_MACOS_FRAMEWORK_SOURCE_FLUTTERENGINETESTUTILS_H_
7
8#import "flutter/shell/platform/darwin/macos/framework/Headers/FlutterEngine.h"
9
10#import <OCMock/OCMock.h>
11
12#include "flutter/testing/autoreleasepool_test.h"
13#include "flutter/testing/test_dart_native_resolver.h"
14#include "gtest/gtest.h"
15
16namespace flutter::testing {
17
19 public:
21
22 FlutterEngine* GetFlutterEngine() { return engine_; };
23
24 void SetUp() override;
25 void TearDown() override;
26
28
29 static void IsolateCreateCallback(void* user_data);
30
31 void ShutDownEngine();
32
33 private:
34 inline static std::shared_ptr<TestDartNativeResolver> native_resolver_;
35
36 FlutterDartProject* project_;
37 FlutterEngine* engine_;
38
39 FML_DISALLOW_COPY_AND_ASSIGN(FlutterEngineTest);
40};
41
42// Returns a mock FlutterEngine that is able to work in environments
43// without a real pasteboard.
44//
45// Callers MUST call [mockEngine shutDownEngine] when finished with the returned engine.
46id CreateMockFlutterEngine(NSString* pasteboardString);
47
49 public:
51
52 void SetUp() override;
53 void TearDown() override;
54
55 id GetMockEngine() { return engine_mock_; }
56
57 void ShutDownEngine();
58
60 [engine_mock_ shutDownEngine];
61 [engine_mock_ stopMocking];
62 }
63
64 private:
65 id engine_mock_;
66
67 FML_DISALLOW_COPY_AND_ASSIGN(MockFlutterEngineTest);
68};
69
70} // namespace flutter::testing
71
72#endif // FLUTTER_SHELL_PLATFORM_DARWIN_MACOS_FRAMEWORK_SOURCE_FLUTTERENGINETESTUTILS_H_
static void IsolateCreateCallback(void *user_data)
void AddNativeCallback(const char *name, Dart_NativeFunction function)
void(* Dart_NativeFunction)(Dart_NativeArguments arguments)
Definition: dart_api.h:3207
Dart_NativeFunction function
Definition: fuchsia.cc:51
id CreateMockFlutterEngine(NSString *pasteboardString)
DEF_SWITCHES_START aot vmservice shared library name
Definition: switches.h:32
void * user_data