Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
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
20 changes: 20 additions & 0 deletions build/darwin/ios_app.gni
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Copyright 2013 The Flutter Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

template("ios_app") {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we add an if (is_ios) here and assert if we're not ios and trying to use this template?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call. You can also just say assert(is_ios)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think assert(is_ios) is fine, but we can't do what I think @gw280 is asking - we need to use this template from iOS.

assert(is_ios)

copy("${target_name}__info_plist") {
sources = [ invoker.info_plist ]
outputs = [ "$root_out_dir/${target_name}.app/Info.plist" ]
}
executable("$target_name") {
forward_variables_from(invoker, "*")
output_name = "${target_name}.app/$target_name"

deps += [
":${target_name}__info_plist",
]
}
}
2 changes: 2 additions & 0 deletions ci/licenses_golden/licenses_flutter
Original file line number Diff line number Diff line change
Expand Up @@ -730,6 +730,8 @@ FILE: ../../../flutter/shell/platform/darwin/common/framework/Source/FlutterStan
FILE: ../../../flutter/shell/platform/darwin/common/framework/Source/FlutterStandardCodec_Internal.h
FILE: ../../../flutter/shell/platform/darwin/common/framework/Source/flutter_codecs_unittest.mm
FILE: ../../../flutter/shell/platform/darwin/common/framework/Source/flutter_standard_codec_unittest.mm
FILE: ../../../flutter/shell/platform/darwin/ios/FlutterTestsInfo.plist
FILE: ../../../flutter/shell/platform/darwin/ios/flutter_unittests.mm
FILE: ../../../flutter/shell/platform/darwin/ios/framework/Flutter.podspec
FILE: ../../../flutter/shell/platform/darwin/ios/framework/Headers/Flutter.h
FILE: ../../../flutter/shell/platform/darwin/ios/framework/Headers/FlutterAppDelegate.h
Expand Down
26 changes: 26 additions & 0 deletions shell/platform/darwin/ios/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@
assert(is_ios)

import("//build/config/ios/ios_sdk.gni")
import("$flutter_root/build/darwin/ios_app.gni")
import("$flutter_root/common/config.gni")
import("$flutter_root/shell/gpu/gpu.gni")
import("$flutter_root/shell/platform/darwin/common/framework_shared.gni")
import("$flutter_root/testing/testing.gni")

_flutter_framework_dir = "$root_out_dir/Flutter.framework"

Expand Down Expand Up @@ -249,6 +251,30 @@ shared_library("copy_and_verify_framework_headers") {
]
}

test_fixtures("flutter_tests_fixtures") {
fixtures = []
}

ios_app("FlutterTests") {
testonly = true

info_plist = "FlutterTestsInfo.plist"

sources = [
"flutter_unittests.mm",
]

libs = [
"Foundation.framework",
]

deps = [
":flutter_tests_fixtures",
"//flutter/runtime:libdart",
"//flutter/testing",
]
}

group("flutter_framework") {
deps = [
":copy_and_verify_framework_headers",
Expand Down
20 changes: 20 additions & 0 deletions shell/platform/darwin/ios/FlutterTestsInfo.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>FlutterTests</string>
<key>CFBundleIdentifier</key>
<string>io.flutter.FlutterTests</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>FlutterTests</string>
<key>CFBundleVersion</key>
<string>1.0</string>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need to worry about the fact that these version strings are hardcoded?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the case of witing a unit testing app, no. For a real app, we'd probably want better handling of the plist in general.

<key>CFBundleShortVersionString</key>
<string>1.0</string>
</dict>
</plist>
19 changes: 19 additions & 0 deletions shell/platform/darwin/ios/flutter_unittests.mm
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#import <Foundation/Foundation.h>

#include "flutter/testing/testing.h"

namespace flutter_tests {

TEST(SmokeTest, Success) {
EXPECT_EQ(1, 1);
}

TEST(SmokeTest, Fail) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This requires a different harness.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right now this test isn't run and nothing is tested. I wanted to see if we could somehow get the exit code from this or what log scraping might make sense for CI.

EXPECT_EQ(1, 2);
}

}
12 changes: 12 additions & 0 deletions testing/run_all_unittests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,21 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "flutter/fml/build_config.h"
#include "gtest/gtest.h"

#ifdef OS_IOS
#include <asl.h>
#endif // OS_IOS

int main(int argc, char** argv) {
#ifdef OS_IOS
asl_log_descriptor(NULL, NULL, ASL_LEVEL_NOTICE, STDOUT_FILENO,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this harness, both can be ASL_LEVEL_ERR. I don't think notices are shown by default.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In a local test they were, but I'll just make them both err.

ASL_LOG_DESCRIPTOR_WRITE);
asl_log_descriptor(NULL, NULL, ASL_LEVEL_ERR, STDERR_FILENO,
ASL_LOG_DESCRIPTOR_WRITE);
#endif // OS_IOS

::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}