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

Commit 0622b05

Browse files
authored
Minimal test harness for iOS (#13029)
1 parent ed1557f commit 0622b05

File tree

6 files changed

+99
-0
lines changed

6 files changed

+99
-0
lines changed

build/darwin/ios_app.gni

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
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+
template("ios_app") {
6+
assert(is_ios)
7+
8+
copy("${target_name}__info_plist") {
9+
sources = [ invoker.info_plist ]
10+
outputs = [ "$root_out_dir/${target_name}.app/Info.plist" ]
11+
}
12+
executable("$target_name") {
13+
forward_variables_from(invoker, "*")
14+
output_name = "${target_name}.app/$target_name"
15+
16+
deps += [
17+
":${target_name}__info_plist",
18+
]
19+
}
20+
}

ci/licenses_golden/licenses_flutter

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -731,6 +731,8 @@ FILE: ../../../flutter/shell/platform/darwin/common/framework/Source/FlutterStan
731731
FILE: ../../../flutter/shell/platform/darwin/common/framework/Source/FlutterStandardCodec_Internal.h
732732
FILE: ../../../flutter/shell/platform/darwin/common/framework/Source/flutter_codecs_unittest.mm
733733
FILE: ../../../flutter/shell/platform/darwin/common/framework/Source/flutter_standard_codec_unittest.mm
734+
FILE: ../../../flutter/shell/platform/darwin/ios/FlutterTestsInfo.plist
735+
FILE: ../../../flutter/shell/platform/darwin/ios/flutter_unittests.mm
734736
FILE: ../../../flutter/shell/platform/darwin/ios/framework/Flutter.podspec
735737
FILE: ../../../flutter/shell/platform/darwin/ios/framework/Headers/Flutter.h
736738
FILE: ../../../flutter/shell/platform/darwin/ios/framework/Headers/FlutterAppDelegate.h

shell/platform/darwin/ios/BUILD.gn

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@
55
assert(is_ios)
66

77
import("//build/config/ios/ios_sdk.gni")
8+
import("$flutter_root/build/darwin/ios_app.gni")
89
import("$flutter_root/common/config.gni")
910
import("$flutter_root/shell/gpu/gpu.gni")
1011
import("$flutter_root/shell/platform/darwin/common/framework_shared.gni")
12+
import("$flutter_root/testing/testing.gni")
1113

1214
_flutter_framework_dir = "$root_out_dir/Flutter.framework"
1315

@@ -248,6 +250,30 @@ shared_library("copy_and_verify_framework_headers") {
248250
]
249251
}
250252

253+
test_fixtures("flutter_tests_fixtures") {
254+
fixtures = []
255+
}
256+
257+
ios_app("FlutterTests") {
258+
testonly = true
259+
260+
info_plist = "FlutterTestsInfo.plist"
261+
262+
sources = [
263+
"flutter_unittests.mm",
264+
]
265+
266+
libs = [
267+
"Foundation.framework",
268+
]
269+
270+
deps = [
271+
":flutter_tests_fixtures",
272+
"//flutter/runtime:libdart",
273+
"//flutter/testing",
274+
]
275+
}
276+
251277
group("flutter_framework") {
252278
deps = [
253279
":copy_and_verify_framework_headers",
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>CFBundleDevelopmentRegion</key>
6+
<string>en</string>
7+
<key>CFBundleExecutable</key>
8+
<string>FlutterTests</string>
9+
<key>CFBundleIdentifier</key>
10+
<string>io.flutter.FlutterTests</string>
11+
<key>CFBundleInfoDictionaryVersion</key>
12+
<string>6.0</string>
13+
<key>CFBundleName</key>
14+
<string>FlutterTests</string>
15+
<key>CFBundleVersion</key>
16+
<string>1.0</string>
17+
<key>CFBundleShortVersionString</key>
18+
<string>1.0</string>
19+
</dict>
20+
</plist>
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
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 <Foundation/Foundation.h>
6+
7+
#include "flutter/testing/testing.h"
8+
9+
namespace flutter_tests {
10+
11+
TEST(SmokeTest, Success) {
12+
EXPECT_EQ(1, 1);
13+
}
14+
15+
TEST(SmokeTest, Fail) {
16+
EXPECT_EQ(1, 2);
17+
}
18+
19+
}

testing/run_all_unittests.cc

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,21 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

5+
#include "flutter/fml/build_config.h"
56
#include "gtest/gtest.h"
67

8+
#ifdef OS_IOS
9+
#include <asl.h>
10+
#endif // OS_IOS
11+
712
int main(int argc, char** argv) {
13+
#ifdef OS_IOS
14+
asl_log_descriptor(NULL, NULL, ASL_LEVEL_NOTICE, STDOUT_FILENO,
15+
ASL_LOG_DESCRIPTOR_WRITE);
16+
asl_log_descriptor(NULL, NULL, ASL_LEVEL_ERR, STDERR_FILENO,
17+
ASL_LOG_DESCRIPTOR_WRITE);
18+
#endif // OS_IOS
19+
820
::testing::InitGoogleTest(&argc, argv);
921
return RUN_ALL_TESTS();
1022
}

0 commit comments

Comments
 (0)