Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

[macOS] Clean up resources in ViewController tests #47792

Merged
merged 1 commit into from
Nov 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
#import "flutter/shell/platform/darwin/macos/framework/Headers/FlutterEngine.h"

#import <OCMock/OCMock.h>

#include "flutter/testing/autoreleasepool_test.h"
#include "flutter/testing/test_dart_native_resolver.h"
#include "gtest/gtest.h"

Expand Down Expand Up @@ -36,6 +38,30 @@ class FlutterEngineTest : public ::testing::Test {

// Returns a mock FlutterEngine that is able to work in environments
// without a real pasteboard.
//
// Callers MUST call [mockEngine shutDownEngine] when finished with the returned engine.
id CreateMockFlutterEngine(NSString* pasteboardString);

class MockFlutterEngineTest : public AutoreleasePoolTest {
public:
MockFlutterEngineTest();

void SetUp() override;
void TearDown() override;

id GetMockEngine() { return engine_mock_; }

void ShutDownEngine();

~MockFlutterEngineTest() {
[engine_mock_ shutDownEngine];
[engine_mock_ stopMocking];
}

private:
id engine_mock_;

FML_DISALLOW_COPY_AND_ASSIGN(MockFlutterEngineTest);
};

} // namespace flutter::testing
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,21 @@ id CreateMockFlutterEngine(NSString* pasteboardString) {
}
}

MockFlutterEngineTest::MockFlutterEngineTest() = default;

void MockFlutterEngineTest::SetUp() {
engine_mock_ = CreateMockFlutterEngine(@"");
}

void MockFlutterEngineTest::TearDown() {
[engine_mock_ shutDownEngine];
[engine_mock_ stopMocking];
engine_mock_ = nil;
}

void MockFlutterEngineTest::ShutDownEngine() {
[engine_mock_ shutDownEngine];
engine_mock_ = nil;
}

} // namespace flutter::testing
Loading