| Flutter macOS Embedder |

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