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

Commit 484e362

Browse files
author
Chris Yang
authored
[webview_flutter] Setup XCTests (#2445)
1 parent f959157 commit 484e362

File tree

7 files changed

+211
-10
lines changed

7 files changed

+211
-10
lines changed

packages/webview_flutter/CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 0.3.19+3
2+
3+
* Setup XCTests.
4+
15
## 0.3.19+2
26

37
* Migrate from deprecated BinaryMessages to ServicesBinding.instance.defaultBinaryMessenger.

packages/webview_flutter/example/ios/Runner.xcodeproj/project.pbxproj

+129-3
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; };
1212
3B80C3941E831B6300D905FE /* App.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3B80C3931E831B6300D905FE /* App.framework */; };
1313
3B80C3951E831B6300D905FE /* App.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 3B80C3931E831B6300D905FE /* App.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
14+
68BDCAF623C3F97800D9C032 /* FLTWebViewTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 68BDCAF523C3F97800D9C032 /* FLTWebViewTests.m */; };
1415
9705A1C61CF904A100538489 /* Flutter.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9740EEBA1CF902C7004384FC /* Flutter.framework */; };
1516
9705A1C71CF904A300538489 /* Flutter.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 9740EEBA1CF902C7004384FC /* Flutter.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
1617
978B8F6F1D3862AE00F588F7 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 7AFFD8EE1D35381100E5BB4D /* AppDelegate.m */; };
@@ -21,6 +22,16 @@
2122
9D26F6F82D91F92CC095EBA9 /* libPods-Runner.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 8B845D8FBDE0AAD6BE1A0386 /* libPods-Runner.a */; };
2223
/* End PBXBuildFile section */
2324

25+
/* Begin PBXContainerItemProxy section */
26+
68BDCAEE23C3F7CB00D9C032 /* PBXContainerItemProxy */ = {
27+
isa = PBXContainerItemProxy;
28+
containerPortal = 97C146E61CF9000F007C117D /* Project object */;
29+
proxyType = 1;
30+
remoteGlobalIDString = 97C146ED1CF9000F007C117D;
31+
remoteInfo = Runner;
32+
};
33+
/* End PBXContainerItemProxy section */
34+
2435
/* Begin PBXCopyFilesBuildPhase section */
2536
9705A1C41CF9048500538489 /* Embed Frameworks */ = {
2637
isa = PBXCopyFilesBuildPhase;
@@ -42,6 +53,9 @@
4253
1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = "<group>"; };
4354
3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = "<group>"; };
4455
3B80C3931E831B6300D905FE /* App.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = App.framework; path = Flutter/App.framework; sourceTree = "<group>"; };
56+
68BDCAE923C3F7CB00D9C032 /* webview_flutter_exampleTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = webview_flutter_exampleTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
57+
68BDCAED23C3F7CB00D9C032 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
58+
68BDCAF523C3F97800D9C032 /* FLTWebViewTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = FLTWebViewTests.m; path = ../../../ios/Tests/FLTWebViewTests.m; sourceTree = "<group>"; };
4559
7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = "<group>"; };
4660
7AFFD8ED1D35381100E5BB4D /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; };
4761
7AFFD8EE1D35381100E5BB4D /* AppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = "<group>"; };
@@ -59,6 +73,13 @@
5973
/* End PBXFileReference section */
6074

6175
/* Begin PBXFrameworksBuildPhase section */
76+
68BDCAE623C3F7CB00D9C032 /* Frameworks */ = {
77+
isa = PBXFrameworksBuildPhase;
78+
buildActionMask = 2147483647;
79+
files = (
80+
);
81+
runOnlyForDeploymentPostprocessing = 0;
82+
};
6283
97C146EB1CF9000F007C117D /* Frameworks */ = {
6384
isa = PBXFrameworksBuildPhase;
6485
buildActionMask = 2147483647;
@@ -72,6 +93,15 @@
7293
/* End PBXFrameworksBuildPhase section */
7394

7495
/* Begin PBXGroup section */
96+
68BDCAEA23C3F7CB00D9C032 /* webview_flutter_exampleTests */ = {
97+
isa = PBXGroup;
98+
children = (
99+
68BDCAF523C3F97800D9C032 /* FLTWebViewTests.m */,
100+
68BDCAED23C3F7CB00D9C032 /* Info.plist */,
101+
);
102+
path = webview_flutter_exampleTests;
103+
sourceTree = "<group>";
104+
};
75105
9740EEB11CF90186004384FC /* Flutter */ = {
76106
isa = PBXGroup;
77107
children = (
@@ -90,6 +120,7 @@
90120
children = (
91121
9740EEB11CF90186004384FC /* Flutter */,
92122
97C146F01CF9000F007C117D /* Runner */,
123+
68BDCAEA23C3F7CB00D9C032 /* webview_flutter_exampleTests */,
93124
97C146EF1CF9000F007C117D /* Products */,
94125
C6FFB52F5C2B8A41A7E39DE2 /* Pods */,
95126
B6736FC417BDCCDA377E779D /* Frameworks */,
@@ -100,6 +131,7 @@
100131
isa = PBXGroup;
101132
children = (
102133
97C146EE1CF9000F007C117D /* Runner.app */,
134+
68BDCAE923C3F7CB00D9C032 /* webview_flutter_exampleTests.xctest */,
103135
);
104136
name = Products;
105137
sourceTree = "<group>";
@@ -148,6 +180,24 @@
148180
/* End PBXGroup section */
149181

150182
/* Begin PBXNativeTarget section */
183+
68BDCAE823C3F7CB00D9C032 /* webview_flutter_exampleTests */ = {
184+
isa = PBXNativeTarget;
185+
buildConfigurationList = 68BDCAF223C3F7CB00D9C032 /* Build configuration list for PBXNativeTarget "webview_flutter_exampleTests" */;
186+
buildPhases = (
187+
68BDCAE523C3F7CB00D9C032 /* Sources */,
188+
68BDCAE623C3F7CB00D9C032 /* Frameworks */,
189+
68BDCAE723C3F7CB00D9C032 /* Resources */,
190+
);
191+
buildRules = (
192+
);
193+
dependencies = (
194+
68BDCAEF23C3F7CB00D9C032 /* PBXTargetDependency */,
195+
);
196+
name = webview_flutter_exampleTests;
197+
productName = webview_flutter_exampleTests;
198+
productReference = 68BDCAE923C3F7CB00D9C032 /* webview_flutter_exampleTests.xctest */;
199+
productType = "com.apple.product-type.bundle.unit-test";
200+
};
151201
97C146ED1CF9000F007C117D /* Runner */ = {
152202
isa = PBXNativeTarget;
153203
buildConfigurationList = 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */;
@@ -176,6 +226,7 @@
176226
97C146E61CF9000F007C117D /* Project object */ = {
177227
isa = PBXProject;
178228
attributes = {
229+
DefaultBuildSystemTypeForWorkspace = Original;
179230
LastUpgradeCheck = 1030;
180231
ORGANIZATIONNAME = "The Chromium Authors";
181232
TargetAttributes = {
@@ -198,11 +249,19 @@
198249
projectRoot = "";
199250
targets = (
200251
97C146ED1CF9000F007C117D /* Runner */,
252+
68BDCAE823C3F7CB00D9C032 /* webview_flutter_exampleTests */,
201253
);
202254
};
203255
/* End PBXProject section */
204256

205257
/* Begin PBXResourcesBuildPhase section */
258+
68BDCAE723C3F7CB00D9C032 /* Resources */ = {
259+
isa = PBXResourcesBuildPhase;
260+
buildActionMask = 2147483647;
261+
files = (
262+
);
263+
runOnlyForDeploymentPostprocessing = 0;
264+
};
206265
97C146EC1CF9000F007C117D /* Resources */ = {
207266
isa = PBXResourcesBuildPhase;
208267
buildActionMask = 2147483647;
@@ -251,12 +310,9 @@
251310
files = (
252311
);
253312
inputPaths = (
254-
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh",
255-
"${PODS_ROOT}/../.symlinks/flutter/ios/Flutter.framework",
256313
);
257314
name = "[CP] Embed Pods Frameworks";
258315
outputPaths = (
259-
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Flutter.framework",
260316
);
261317
runOnlyForDeploymentPostprocessing = 0;
262318
shellPath = /bin/sh;
@@ -284,6 +340,14 @@
284340
/* End PBXShellScriptBuildPhase section */
285341

286342
/* Begin PBXSourcesBuildPhase section */
343+
68BDCAE523C3F7CB00D9C032 /* Sources */ = {
344+
isa = PBXSourcesBuildPhase;
345+
buildActionMask = 2147483647;
346+
files = (
347+
68BDCAF623C3F97800D9C032 /* FLTWebViewTests.m in Sources */,
348+
);
349+
runOnlyForDeploymentPostprocessing = 0;
350+
};
287351
97C146EA1CF9000F007C117D /* Sources */ = {
288352
isa = PBXSourcesBuildPhase;
289353
buildActionMask = 2147483647;
@@ -296,6 +360,14 @@
296360
};
297361
/* End PBXSourcesBuildPhase section */
298362

363+
/* Begin PBXTargetDependency section */
364+
68BDCAEF23C3F7CB00D9C032 /* PBXTargetDependency */ = {
365+
isa = PBXTargetDependency;
366+
target = 97C146ED1CF9000F007C117D /* Runner */;
367+
targetProxy = 68BDCAEE23C3F7CB00D9C032 /* PBXContainerItemProxy */;
368+
};
369+
/* End PBXTargetDependency section */
370+
299371
/* Begin PBXVariantGroup section */
300372
97C146FA1CF9000F007C117D /* Main.storyboard */ = {
301373
isa = PBXVariantGroup;
@@ -316,6 +388,51 @@
316388
/* End PBXVariantGroup section */
317389

318390
/* Begin XCBuildConfiguration section */
391+
68BDCAF023C3F7CB00D9C032 /* Debug */ = {
392+
isa = XCBuildConfiguration;
393+
buildSettings = {
394+
BUNDLE_LOADER = "$(TEST_HOST)";
395+
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
396+
CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
397+
CLANG_ENABLE_OBJC_WEAK = YES;
398+
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
399+
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
400+
CODE_SIGN_STYLE = Automatic;
401+
GCC_C_LANGUAGE_STANDARD = gnu11;
402+
INFOPLIST_FILE = webview_flutter_exampleTests/Info.plist;
403+
IPHONEOS_DEPLOYMENT_TARGET = 13.2;
404+
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
405+
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
406+
MTL_FAST_MATH = YES;
407+
PRODUCT_BUNDLE_IDENTIFIER = "com.google.webview-flutter-exampleTests";
408+
PRODUCT_NAME = "$(TARGET_NAME)";
409+
TARGETED_DEVICE_FAMILY = "1,2";
410+
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Runner.app/Runner";
411+
};
412+
name = Debug;
413+
};
414+
68BDCAF123C3F7CB00D9C032 /* Release */ = {
415+
isa = XCBuildConfiguration;
416+
buildSettings = {
417+
BUNDLE_LOADER = "$(TEST_HOST)";
418+
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
419+
CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
420+
CLANG_ENABLE_OBJC_WEAK = YES;
421+
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
422+
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
423+
CODE_SIGN_STYLE = Automatic;
424+
GCC_C_LANGUAGE_STANDARD = gnu11;
425+
INFOPLIST_FILE = webview_flutter_exampleTests/Info.plist;
426+
IPHONEOS_DEPLOYMENT_TARGET = 13.2;
427+
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
428+
MTL_FAST_MATH = YES;
429+
PRODUCT_BUNDLE_IDENTIFIER = "com.google.webview-flutter-exampleTests";
430+
PRODUCT_NAME = "$(TARGET_NAME)";
431+
TARGETED_DEVICE_FAMILY = "1,2";
432+
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Runner.app/Runner";
433+
};
434+
name = Release;
435+
};
319436
97C147031CF9000F007C117D /* Debug */ = {
320437
isa = XCBuildConfiguration;
321438
baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */;
@@ -475,6 +592,15 @@
475592
/* End XCBuildConfiguration section */
476593

477594
/* Begin XCConfigurationList section */
595+
68BDCAF223C3F7CB00D9C032 /* Build configuration list for PBXNativeTarget "webview_flutter_exampleTests" */ = {
596+
isa = XCConfigurationList;
597+
buildConfigurations = (
598+
68BDCAF023C3F7CB00D9C032 /* Debug */,
599+
68BDCAF123C3F7CB00D9C032 /* Release */,
600+
);
601+
defaultConfigurationIsVisible = 0;
602+
defaultConfigurationName = Release;
603+
};
478604
97C146E91CF9000F007C117D /* Build configuration list for PBXProject "Runner" */ = {
479605
isa = XCConfigurationList;
480606
buildConfigurations = (

packages/webview_flutter/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme

+12-6
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@
2727
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
2828
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
2929
shouldUseLaunchSchemeArgsEnv = "YES">
30-
<Testables>
31-
</Testables>
3230
<MacroExpansion>
3331
<BuildableReference
3432
BuildableIdentifier = "primary"
@@ -38,8 +36,18 @@
3836
ReferencedContainer = "container:Runner.xcodeproj">
3937
</BuildableReference>
4038
</MacroExpansion>
41-
<AdditionalOptions>
42-
</AdditionalOptions>
39+
<Testables>
40+
<TestableReference
41+
skipped = "NO">
42+
<BuildableReference
43+
BuildableIdentifier = "primary"
44+
BlueprintIdentifier = "68BDCAE823C3F7CB00D9C032"
45+
BuildableName = "webview_flutter_exampleTests.xctest"
46+
BlueprintName = "webview_flutter_exampleTests"
47+
ReferencedContainer = "container:Runner.xcodeproj">
48+
</BuildableReference>
49+
</TestableReference>
50+
</Testables>
4351
</TestAction>
4452
<LaunchAction
4553
buildConfiguration = "Debug"
@@ -61,8 +69,6 @@
6169
ReferencedContainer = "container:Runner.xcodeproj">
6270
</BuildableReference>
6371
</BuildableProductRunnable>
64-
<AdditionalOptions>
65-
</AdditionalOptions>
6672
</LaunchAction>
6773
<ProfileAction
6874
buildConfiguration = "Release"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
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>$(DEVELOPMENT_LANGUAGE)</string>
7+
<key>CFBundleExecutable</key>
8+
<string>$(EXECUTABLE_NAME)</string>
9+
<key>CFBundleIdentifier</key>
10+
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
11+
<key>CFBundleInfoDictionaryVersion</key>
12+
<string>6.0</string>
13+
<key>CFBundleName</key>
14+
<string>$(PRODUCT_NAME)</string>
15+
<key>CFBundlePackageType</key>
16+
<string>$(PRODUCT_BUNDLE_PACKAGE_TYPE)</string>
17+
<key>CFBundleShortVersionString</key>
18+
<string>1.0</string>
19+
<key>CFBundleVersion</key>
20+
<string>1</string>
21+
</dict>
22+
</plist>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
// Copyright 2019 The Chromium 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;
6+
@import OCMock;
7+
@import XCTest;
8+
@import webview_flutter;
9+
10+
@interface FLTWebViewTests : XCTestCase
11+
12+
@property(strong, nonatomic) NSObject<FlutterBinaryMessenger> *mockBinaryMessenger;
13+
14+
@end
15+
16+
@implementation FLTWebViewTests
17+
18+
- (void)setUp {
19+
[super setUp];
20+
self.mockBinaryMessenger = OCMProtocolMock(@protocol(FlutterBinaryMessenger));
21+
}
22+
23+
- (void)canInitFLTWebViewController {
24+
FLTWebViewController *controller =
25+
[[FLTWebViewController alloc] initWithFrame:CGRectMake(0, 0, 300, 400)
26+
viewIdentifier:1
27+
arguments:nil
28+
binaryMessenger:self.mockBinaryMessenger];
29+
XCTAssertNotNil(controller);
30+
}
31+
32+
- (void)canInitFLTWebViewFactory {
33+
FLTWebViewFactory *factory =
34+
[[FLTWebViewFactory alloc] initWithMessenger:self.mockBinaryMessenger];
35+
XCTAssertNotNil(factory);
36+
}
37+
38+
@end

packages/webview_flutter/ios/webview_flutter.podspec

+5
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,9 @@ A WebView Plugin for Flutter.
1818

1919
s.platform = :ios, '8.0'
2020
s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES', 'VALID_ARCHS[sdk=iphonesimulator*]' => 'x86_64' }
21+
22+
s.test_spec 'Tests' do |test_spec|
23+
test_spec.source_files = 'Tests/**/*'
24+
test_spec.dependency 'OCMock','3.5'
25+
end
2126
end

packages/webview_flutter/pubspec.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: webview_flutter
22
description: A Flutter plugin that provides a WebView widget on Android and iOS.
3-
version: 0.3.19+2
3+
version: 0.3.19+3
44
homepage: https://github.com/flutter/plugins/tree/master/packages/webview_flutter
55

66
environment:

0 commit comments

Comments
 (0)