Skip to content

Commit

Permalink
Revert "Add support for native callbacks to the macOS embedder test h…
Browse files Browse the repository at this point in the history
…arness (flutter#26623)" (flutter#26693)

This reverts commit c7a479e.
  • Loading branch information
gw280 authored Jun 10, 2021
1 parent 08f34bc commit e0c16f0
Show file tree
Hide file tree
Showing 9 changed files with 29 additions and 142 deletions.
3 changes: 0 additions & 3 deletions ci/licenses_golden/licenses_flutter
Original file line number Diff line number Diff line change
Expand Up @@ -1160,9 +1160,6 @@ FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/FlutterEmbed
FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/FlutterEmbedderKeyResponderUnittests.mm
FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/FlutterEngine.mm
FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/FlutterEngineTest.mm
FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/FlutterEngineTestContext.mm
FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/FlutterEngineTestUtils.h
FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/FlutterEngineTestUtils.mm
FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/FlutterEngine_Internal.h
FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/FlutterExternalTextureGL.h
FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/FlutterExternalTextureGL.mm
Expand Down
2 changes: 0 additions & 2 deletions shell/platform/darwin/macos/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,6 @@ executable("flutter_desktop_darwin_unittests") {
"framework/Source/FlutterEmbedderExternalTextureUnittests.mm",
"framework/Source/FlutterEmbedderKeyResponderUnittests.mm",
"framework/Source/FlutterEngineTest.mm",
"framework/Source/FlutterEngineTestUtils.h",
"framework/Source/FlutterEngineTestUtils.mm",
"framework/Source/FlutterGLCompositorUnittests.mm",
"framework/Source/FlutterKeyboardManagerUnittests.mm",
"framework/Source/FlutterMetalCompositorUnittests.mm",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,6 @@
*/
@property(nonatomic, readonly) std::vector<std::string> switches;

/**
* The callback invoked by the engine in root isolate scope.
*/
@property(nonatomic, nullable) void (*rootIsolateCreateCallback)(void* _Nullable);

/**
* Instead of looking up the assets and ICU data path in the application bundle, this initializer
* allows callers to create a Dart project with custom locations specified for the both.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,6 @@ - (BOOL)runWithEntrypoint:(NSString*)entrypoint {
flutterArguments.shutdown_dart_vm_when_done = true;
flutterArguments.dart_entrypoint_argc = dartEntrypointArgs.size();
flutterArguments.dart_entrypoint_argv = dartEntrypointArgs.data();
flutterArguments.root_isolate_create_callback = _project.rootIsolateCreateCallback;

static size_t sTaskRunnerIdentifiers = 0;
const FlutterTaskRunnerDescription cocoa_task_runner_description = {
Expand Down
57 changes: 29 additions & 28 deletions shell/platform/darwin/macos/framework/Source/FlutterEngineTest.mm
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
#include "flutter/shell/platform/common/accessibility_bridge.h"
#import "flutter/shell/platform/darwin/macos/framework/Headers/FlutterAppDelegate.h"
#import "flutter/shell/platform/darwin/macos/framework/Headers/FlutterEngine.h"
#import "flutter/shell/platform/darwin/macos/framework/Source/FlutterEngineTestUtils.h"
#import "flutter/shell/platform/darwin/macos/framework/Source/FlutterDartProject_Internal.h"
#import "flutter/shell/platform/darwin/macos/framework/Source/FlutterEngine_Internal.h"
#import "flutter/shell/platform/darwin/macos/framework/Source/FlutterViewControllerTestUtils.h"
#include "flutter/shell/platform/embedder/embedder.h"
#include "flutter/shell/platform/embedder/test_utils/proc_table_replacement.h"
#include "flutter/testing/test_dart_native_resolver.h"
#include "flutter/testing/testing.h"

@interface FlutterEngine (Test)
/**
Expand All @@ -25,14 +25,26 @@ @interface FlutterEngine (Test)

namespace flutter::testing {

TEST_F(FlutterEngineTest, CanLaunch) {
FlutterEngine* engine = GetFlutterEngine();
namespace {
// Returns an engine configured for the test fixture resource configuration.
FlutterEngine* CreateTestEngine() {
NSString* fixtures = @(testing::GetFixturesPath());
FlutterDartProject* project = [[FlutterDartProject alloc]
initWithAssetsPath:fixtures
ICUDataPath:[fixtures stringByAppendingString:@"/icudtl.dat"]];
return [[FlutterEngine alloc] initWithName:@"test" project:project allowHeadlessExecution:true];
}
} // namespace

TEST(FlutterEngine, CanLaunch) {
FlutterEngine* engine = CreateTestEngine();
EXPECT_TRUE([engine runWithEntrypoint:@"main"]);
EXPECT_TRUE(engine.running);
[engine shutDownEngine];
}

TEST_F(FlutterEngineTest, MessengerSend) {
FlutterEngine* engine = GetFlutterEngine();
TEST(FlutterEngine, MessengerSend) {
FlutterEngine* engine = CreateTestEngine();
EXPECT_TRUE([engine runWithEntrypoint:@"main"]);

NSData* test_message = [@"a message" dataUsingEncoding:NSUTF8StringEncoding];
Expand All @@ -48,10 +60,12 @@ @interface FlutterEngine (Test)

[engine.binaryMessenger sendOnChannel:@"test" message:test_message];
EXPECT_TRUE(called);

[engine shutDownEngine];
}

TEST_F(FlutterEngineTest, CanToggleAccessibility) {
FlutterEngine* engine = GetFlutterEngine();
TEST(FlutterEngine, CanToggleAccessibility) {
FlutterEngine* engine = CreateTestEngine();
// Capture the update callbacks before the embedder API initializes.
auto original_init = engine.embedderAPI.Initialize;
std::function<void(const FlutterSemanticsNode*, void*)> update_node_callback;
Expand Down Expand Up @@ -148,10 +162,11 @@ @interface FlutterEngine (Test)
EXPECT_EQ([engine.viewController.flutterView.accessibilityChildren count], 0u);

[engine setViewController:nil];
[engine shutDownEngine];
}

TEST_F(FlutterEngineTest, CanToggleAccessibilityWhenHeadless) {
FlutterEngine* engine = GetFlutterEngine();
TEST(FlutterEngine, CanToggleAccessibilityWhenHeadless) {
FlutterEngine* engine = CreateTestEngine();
// Capture the update callbacks before the embedder API initializes.
auto original_init = engine.embedderAPI.Initialize;
std::function<void(const FlutterSemanticsNode*, void*)> update_node_callback;
Expand Down Expand Up @@ -230,10 +245,11 @@ @interface FlutterEngine (Test)
EXPECT_FALSE(semanticsEnabled);
// Still no crashes
EXPECT_EQ(engine.viewController, nil);
[engine shutDownEngine];
}

TEST_F(FlutterEngineTest, ResetsAccessibilityBridgeWhenSetsNewViewController) {
FlutterEngine* engine = GetFlutterEngine();
TEST(FlutterEngine, ResetsAccessibilityBridgeWhenSetsNewViewController) {
FlutterEngine* engine = CreateTestEngine();
// Capture the update callbacks before the embedder API initializes.
auto original_init = engine.embedderAPI.Initialize;
std::function<void(const FlutterSemanticsNode*, void*)> update_node_callback;
Expand Down Expand Up @@ -320,22 +336,7 @@ @interface FlutterEngine (Test)
EXPECT_TRUE(native_root.expired());

[engine setViewController:nil];
}

TEST_F(FlutterEngineTest, NativeCallbacks) {
FlutterEngine* engine = GetFlutterEngine();
EXPECT_TRUE([engine runWithEntrypoint:@"native_callback"]);
EXPECT_TRUE(engine.running);

fml::AutoResetWaitableEvent latch;
bool latch_called = false;

AddNativeCallback("SignalNativeTest", CREATE_NATIVE_ENTRY([&](Dart_NativeArguments args) {
latch_called = true;
latch.Signal();
}));
latch.Wait();
ASSERT_TRUE(latch_called);
[engine shutDownEngine];
}

TEST(FlutterEngine, Compositor) {
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,3 @@ void can_composite_platform_views() {
};
PlatformDispatcher.instance.scheduleFrame();
}

void signalNativeTest() native 'SignalNativeTest';

@pragma('vm:entry-point')
void native_callback() {
signalNativeTest();
}

0 comments on commit e0c16f0

Please sign in to comment.