Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
86c21c5d
Unverified
Commit
86c21c5d
authored
Feb 04, 2021
by
Jenn Magder
Committed by
GitHub
Feb 04, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Replace MockPlistParser with FakePlistParser (#75276)
parent
fd5668bb
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
52 additions
and
60 deletions
+52
-60
doctor_test.dart
...utter_tools/test/commands.shard/hermetic/doctor_test.dart
+0
-2
application_package_test.dart
...er_tools/test/general.shard/application_package_test.dart
+10
-27
simulators_test.dart
...flutter_tools/test/general.shard/ios/simulators_test.dart
+6
-5
project_test.dart
packages/flutter_tools/test/general.shard/project_test.dart
+16
-17
context.dart
packages/flutter_tools/test/src/context.dart
+1
-8
fakes.dart
packages/flutter_tools/test/src/fakes.dart
+19
-1
No files found.
packages/flutter_tools/test/commands.shard/hermetic/doctor_test.dart
View file @
86c21c5d
...
...
@@ -23,7 +23,6 @@ import 'package:flutter_tools/src/device.dart';
import
'package:flutter_tools/src/doctor.dart'
;
import
'package:flutter_tools/src/features.dart'
;
import
'package:flutter_tools/src/globals.dart'
as
globals
;
import
'package:flutter_tools/src/ios/plist_parser.dart'
;
import
'package:flutter_tools/src/reporting/reporting.dart'
;
import
'package:flutter_tools/src/version.dart'
;
import
'package:flutter_tools/src/vscode/vscode.dart'
;
...
...
@@ -1045,7 +1044,6 @@ class VsCodeValidatorTestTargets extends VsCodeValidator {
static
final
String
missingExtensions
=
globals
.
fs
.
path
.
join
(
'test'
,
'data'
,
'vscode'
,
'notExtensions'
);
}
class
MockPlistParser
extends
Mock
implements
PlistParser
{}
class
MockDeviceManager
extends
Mock
implements
DeviceManager
{}
class
MockDevice
extends
Mock
implements
Device
{
MockDevice
()
{
...
...
packages/flutter_tools/test/general.shard/application_package_test.dart
View file @
86c21c5d
...
...
@@ -4,8 +4,6 @@
// @dart = 2.8
import
'dart:convert'
;
import
'package:file/file.dart'
;
import
'package:file/memory.dart'
;
import
'package:flutter_tools/src/android/android_sdk.dart'
;
...
...
@@ -27,6 +25,7 @@ import 'package:process/process.dart';
import
'../src/common.dart'
;
import
'../src/context.dart'
;
import
'../src/fakes.dart'
;
final
Generator
_kNoColorTerminalPlatform
=
()
=>
FakePlatform
(
stdoutSupportsAnsi:
false
);
final
Map
<
Type
,
Generator
>
noColorTerminalOverride
=
<
Type
,
Generator
>{
...
...
@@ -249,16 +248,19 @@ void main() {
group
(
'PrebuiltIOSApp'
,
()
{
MockOperatingSystemUtils
os
;
FakePlistParser
testPlistParser
;
final
Map
<
Type
,
Generator
>
overrides
=
<
Type
,
Generator
>{
FileSystem:
()
=>
MemoryFileSystem
.
test
(),
ProcessManager:
()
=>
FakeProcessManager
.
any
(),
PlistParser:
()
=>
MockPlistUtils
()
,
PlistParser:
()
=>
testPlistParser
,
Platform:
_kNoColorTerminalPlatform
,
OperatingSystemUtils:
()
=>
os
,
};
setUp
(()
{
os
=
MockOperatingSystemUtils
();
testPlistParser
=
FakePlistParser
();
});
testUsingContext
(
'Error on non-existing file'
,
()
{
...
...
@@ -292,7 +294,7 @@ void main() {
testUsingContext
(
'Error on bad info.plist'
,
()
{
globals
.
fs
.
directory
(
'bundle.app'
).
createSync
();
globals
.
fs
.
file
(
'bundle.app/Info.plist'
).
writeAsStringSync
(
badPlistData
);
globals
.
fs
.
file
(
'bundle.app/Info.plist'
).
createSync
(
);
final
PrebuiltIOSApp
iosApp
=
IOSApp
.
fromPrebuiltApp
(
globals
.
fs
.
file
(
'bundle.app'
))
as
PrebuiltIOSApp
;
expect
(
iosApp
,
isNull
);
expect
(
...
...
@@ -304,7 +306,8 @@ void main() {
testUsingContext
(
'Success with app bundle'
,
()
{
globals
.
fs
.
directory
(
'bundle.app'
).
createSync
();
globals
.
fs
.
file
(
'bundle.app/Info.plist'
).
writeAsStringSync
(
plistData
);
globals
.
fs
.
file
(
'bundle.app/Info.plist'
).
createSync
();
testPlistParser
.
setProperty
(
'CFBundleIdentifier'
,
'fooBundleId'
);
final
PrebuiltIOSApp
iosApp
=
IOSApp
.
fromPrebuiltApp
(
globals
.
fs
.
file
(
'bundle.app'
))
as
PrebuiltIOSApp
;
expect
(
testLogger
.
errorText
,
isEmpty
);
expect
(
iosApp
.
bundleDir
.
path
,
'bundle.app'
);
...
...
@@ -355,9 +358,10 @@ void main() {
final
Directory
bundleAppDir
=
globals
.
fs
.
directory
(
globals
.
fs
.
path
.
join
(
targetDirectory
.
path
,
'Payload'
,
'bundle.app'
));
bundleAppDir
.
createSync
(
recursive:
true
);
testPlistParser
.
setProperty
(
'CFBundleIdentifier'
,
'fooBundleId'
);
globals
.
fs
.
file
(
globals
.
fs
.
path
.
join
(
bundleAppDir
.
path
,
'Info.plist'
))
.
writeAsStringSync
(
plistData
);
.
createSync
(
);
});
final
PrebuiltIOSApp
iosApp
=
IOSApp
.
fromPrebuiltApp
(
globals
.
fs
.
file
(
'app.ipa'
))
as
PrebuiltIOSApp
;
expect
(
testLogger
.
errorText
,
isEmpty
);
...
...
@@ -703,25 +707,4 @@ N: android=http://schemas.android.com/apk/res/android
A: android:name(0x01010003)="android.permission.INTERNET" (Raw: "android.permission.INTERNET")
'''
;
class
MockPlistUtils
extends
Mock
implements
PlistParser
{
@override
String
getValueFromFile
(
String
path
,
String
key
)
{
final
File
file
=
globals
.
fs
.
file
(
path
);
if
(!
file
.
existsSync
())
{
return
null
;
}
return
json
.
decode
(
file
.
readAsStringSync
())[
key
]
as
String
;
}
}
// Contains no bundle identifier.
const
String
badPlistData
=
'''
{}
'''
;
const
String
plistData
=
'''
{"CFBundleIdentifier": "fooBundleId"}
'''
;
class
MockOperatingSystemUtils
extends
Mock
implements
OperatingSystemUtils
{
}
packages/flutter_tools/test/general.shard/ios/simulators_test.dart
View file @
86c21c5d
...
...
@@ -25,10 +25,9 @@ import 'package:process/process.dart';
import
'../../src/common.dart'
;
import
'../../src/context.dart'
;
import
'../../src/fakes.dart'
;
import
'../../src/mocks.dart'
;
class
MockPlistUtils
extends
Mock
implements
PlistParser
{}
final
Platform
macosPlatform
=
FakePlatform
(
operatingSystem:
'macos'
,
environment:
<
String
,
String
>{
...
...
@@ -861,12 +860,14 @@ Dec 20 17:04:32 md32-11-vm1 Another App[88374]: Ignore this text'''
});
group
(
'startApp'
,
()
{
FakePlistParser
testPlistParser
;
SimControl
simControl
;
Xcode
xcode
;
setUp
(()
{
simControl
=
MockSimControl
();
xcode
=
Xcode
.
test
(
processManager:
FakeProcessManager
.
any
());
testPlistParser
=
FakePlistParser
();
});
testUsingContext
(
"startApp uses compiled app's Info.plist to find CFBundleIdentifier"
,
()
async
{
...
...
@@ -876,7 +877,7 @@ Dec 20 17:04:32 md32-11-vm1 Another App[88374]: Ignore this text'''
simulatorCategory:
'iOS 11.2'
,
simControl:
simControl
,
);
when
(
globals
.
plistParser
.
getValueFromFile
(
any
,
any
)).
thenReturn
(
'correct'
);
testPlistParser
.
setProperty
(
'CFBundleIdentifier'
,
'correct'
);
final
Directory
mockDir
=
globals
.
fs
.
currentDirectory
;
final
IOSApp
package
=
PrebuiltIOSApp
(
projectBundleId:
'incorrect'
,
bundleName:
'name'
,
bundleDir:
mockDir
);
...
...
@@ -887,7 +888,7 @@ Dec 20 17:04:32 md32-11-vm1 Another App[88374]: Ignore this text'''
verify
(
simControl
.
launch
(
any
,
'correct'
,
any
));
},
overrides:
<
Type
,
Generator
>{
PlistParser:
()
=>
MockPlistUtils
()
,
PlistParser:
()
=>
testPlistParser
,
FileSystem:
()
=>
fileSystem
,
ProcessManager:
()
=>
FakeProcessManager
.
any
(),
Xcode:
()
=>
xcode
,
...
...
@@ -910,7 +911,7 @@ Dec 20 17:04:32 md32-11-vm1 Another App[88374]: Ignore this text'''
verify
(
simControl
.
launch
(
any
,
any
,
captureAny
)).
captured
.
contains
(
'--enable-software-rendering'
);
},
overrides:
<
Type
,
Generator
>{
PlistParser:
()
=>
MockPlistUtils
()
,
PlistParser:
()
=>
testPlistParser
,
FileSystem:
()
=>
fileSystem
,
ProcessManager:
()
=>
FakeProcessManager
.
any
(),
Xcode:
()
=>
xcode
,
...
...
packages/flutter_tools/test/general.shard/project_test.dart
View file @
86c21c5d
...
...
@@ -23,6 +23,7 @@ import 'package:mockito/mockito.dart';
import
'../src/common.dart'
;
import
'../src/context.dart'
;
import
'../src/fakes.dart'
;
import
'../src/testbed.dart'
;
void
main
(
)
{
...
...
@@ -346,12 +347,12 @@ apply plugin: 'kotlin-android'
group
(
'product bundle identifier'
,
()
{
MemoryFileSystem
fs
;
MockPlistUtils
mock
PlistUtils
;
FakePlistParser
test
PlistUtils
;
MockXcodeProjectInterpreter
mockXcodeProjectInterpreter
;
FlutterProjectFactory
flutterProjectFactory
;
setUp
(()
{
fs
=
MemoryFileSystem
.
test
();
mockPlistUtils
=
MockPlistUtils
();
testPlistUtils
=
FakePlistParser
();
mockXcodeProjectInterpreter
=
MockXcodeProjectInterpreter
();
flutterProjectFactory
=
FlutterProjectFactory
(
fileSystem:
fs
,
...
...
@@ -363,7 +364,7 @@ apply plugin: 'kotlin-android'
testUsingContext
(
description
,
testMethod
,
overrides:
<
Type
,
Generator
>{
FileSystem:
()
=>
fs
,
ProcessManager:
()
=>
FakeProcessManager
.
any
(),
PlistParser:
()
=>
mock
PlistUtils
,
PlistParser:
()
=>
test
PlistUtils
,
XcodeProjectInterpreter:
()
=>
mockXcodeProjectInterpreter
,
FlutterProjectFactory:
()
=>
flutterProjectFactory
,
});
...
...
@@ -401,7 +402,7 @@ apply plugin: 'kotlin-android'
testWithMocks
(
'from plist, if no variables'
,
()
async
{
final
FlutterProject
project
=
await
someProject
();
project
.
ios
.
defaultHostInfoPlist
.
createSync
(
recursive:
true
);
when
(
mockPlistUtils
.
getValueFromFile
(
any
,
any
)).
thenReturn
(
'io.flutter.someProject'
);
testPlistUtils
.
setProperty
(
'CFBundleIdentifier'
,
'io.flutter.someProject'
);
expect
(
await
project
.
ios
.
productBundleIdentifier
(
null
),
'io.flutter.someProject'
);
});
...
...
@@ -419,7 +420,7 @@ apply plugin: 'kotlin-android'
return
Future
<
XcodeProjectInfo
>.
value
(
XcodeProjectInfo
(<
String
>[],
<
String
>[],
<
String
>[
'Runner'
],
logger
));
});
when
(
mockPlistUtils
.
getValueFromFile
(
any
,
any
)).
thenReturn
(
r'$(PRODUCT_BUNDLE_IDENTIFIER)'
);
testPlistUtils
.
setProperty
(
'CFBundleIdentifier'
,
r'$(PRODUCT_BUNDLE_IDENTIFIER)'
);
expect
(
await
project
.
ios
.
productBundleIdentifier
(
null
),
'io.flutter.someProject'
);
});
...
...
@@ -439,7 +440,7 @@ apply plugin: 'kotlin-android'
return
Future
<
XcodeProjectInfo
>.
value
(
XcodeProjectInfo
(<
String
>[],
<
String
>[],
<
String
>[
'Runner'
],
logger
));
});
when
(
mockPlistUtils
.
getValueFromFile
(
any
,
any
)).
thenReturn
(
r'$(PRODUCT_BUNDLE_IDENTIFIER).$(SUFFIX)'
);
testPlistUtils
.
setProperty
(
'CFBundleIdentifier'
,
r'$(PRODUCT_BUNDLE_IDENTIFIER).$(SUFFIX)'
);
expect
(
await
project
.
ios
.
productBundleIdentifier
(
null
),
'io.flutter.someProject.suffix'
);
});
...
...
@@ -621,12 +622,12 @@ apply plugin: 'kotlin-android'
});
group
(
'watch companion'
,
()
{
MemoryFileSystem
fs
;
MockPlistUtils
mockPlistUtils
;
FakePlistParser
testPlistParser
;
MockXcodeProjectInterpreter
mockXcodeProjectInterpreter
;
FlutterProjectFactory
flutterProjectFactory
;
setUp
(()
{
fs
=
MemoryFileSystem
.
test
();
mockPlistUtils
=
MockPlistUtils
();
testPlistParser
=
FakePlistParser
();
mockXcodeProjectInterpreter
=
MockXcodeProjectInterpreter
();
flutterProjectFactory
=
FlutterProjectFactory
(
fileSystem:
fs
,
...
...
@@ -640,7 +641,7 @@ apply plugin: 'kotlin-android'
},
overrides:
<
Type
,
Generator
>{
FileSystem:
()
=>
fs
,
ProcessManager:
()
=>
FakeProcessManager
.
any
(),
PlistParser:
()
=>
mockPlistUtils
,
PlistParser:
()
=>
testPlistParser
,
XcodeProjectInterpreter:
()
=>
mockXcodeProjectInterpreter
,
FlutterProjectFactory:
()
=>
flutterProjectFactory
,
});
...
...
@@ -665,7 +666,7 @@ apply plugin: 'kotlin-android'
},
overrides:
<
Type
,
Generator
>{
FileSystem:
()
=>
fs
,
ProcessManager:
()
=>
FakeProcessManager
.
any
(),
PlistParser:
()
=>
mockPlistUtils
,
PlistParser:
()
=>
testPlistParser
,
XcodeProjectInterpreter:
()
=>
mockXcodeProjectInterpreter
,
FlutterProjectFactory:
()
=>
flutterProjectFactory
,
});
...
...
@@ -678,7 +679,7 @@ apply plugin: 'kotlin-android'
},
overrides:
<
Type
,
Generator
>{
FileSystem:
()
=>
fs
,
ProcessManager:
()
=>
FakeProcessManager
.
any
(),
PlistParser:
()
=>
mockPlistUtils
,
PlistParser:
()
=>
testPlistParser
,
XcodeProjectInterpreter:
()
=>
mockXcodeProjectInterpreter
,
FlutterProjectFactory:
()
=>
flutterProjectFactory
,
});
...
...
@@ -687,12 +688,12 @@ apply plugin: 'kotlin-android'
final
FlutterProject
project
=
await
someProject
();
project
.
ios
.
hostAppRoot
.
childDirectory
(
'WatchTarget'
).
childFile
(
'Info.plist'
).
createSync
(
recursive:
true
);
when
(
mockPlistUtils
.
getValueFromFile
(
any
,
'WKCompanionAppBundleIdentifier'
)).
thenReturn
(
'io.flutter.someOTHERproject'
);
testPlistParser
.
setProperty
(
'WKCompanionAppBundleIdentifier'
,
'io.flutter.someOTHERproject'
);
expect
(
await
project
.
ios
.
containsWatchCompanion
(<
String
>[
'WatchTarget'
],
null
),
isFalse
);
},
overrides:
<
Type
,
Generator
>{
FileSystem:
()
=>
fs
,
ProcessManager:
()
=>
FakeProcessManager
.
any
(),
PlistParser:
()
=>
mockPlistUtils
,
PlistParser:
()
=>
testPlistParser
,
XcodeProjectInterpreter:
()
=>
mockXcodeProjectInterpreter
,
FlutterProjectFactory:
()
=>
flutterProjectFactory
,
});
...
...
@@ -701,13 +702,13 @@ apply plugin: 'kotlin-android'
final
FlutterProject
project
=
await
someProject
();
project
.
ios
.
xcodeProject
.
createSync
();
project
.
ios
.
hostAppRoot
.
childDirectory
(
'WatchTarget'
).
childFile
(
'Info.plist'
).
createSync
(
recursive:
true
);
when
(
mockPlistUtils
.
getValueFromFile
(
any
,
'WKCompanionAppBundleIdentifier'
)).
thenReturn
(
'io.flutter.someProject'
);
testPlistParser
.
setProperty
(
'WKCompanionAppBundleIdentifier'
,
'io.flutter.someProject'
);
expect
(
await
project
.
ios
.
containsWatchCompanion
(<
String
>[
'WatchTarget'
],
null
),
isTrue
);
},
overrides:
<
Type
,
Generator
>{
FileSystem:
()
=>
fs
,
ProcessManager:
()
=>
FakeProcessManager
.
any
(),
PlistParser:
()
=>
mockPlistUtils
,
PlistParser:
()
=>
testPlistParser
,
XcodeProjectInterpreter:
()
=>
mockXcodeProjectInterpreter
,
FlutterProjectFactory:
()
=>
flutterProjectFactory
,
});
...
...
@@ -969,8 +970,6 @@ File androidPluginRegistrant(Directory parent) {
.
childFile
(
'GeneratedPluginRegistrant.java'
);
}
class
MockPlistUtils
extends
Mock
implements
PlistParser
{}
class
MockXcodeProjectInterpreter
extends
Mock
implements
XcodeProjectInterpreter
{
@override
bool
get
isInstalled
=>
true
;
...
...
packages/flutter_tools/test/src/context.dart
View file @
86c21c5d
...
...
@@ -38,6 +38,7 @@ import 'package:mockito/mockito.dart';
import
'common.dart'
;
import
'fake_process_manager.dart'
;
import
'fakes.dart'
;
import
'mocks.dart'
;
import
'throwing_pub.dart'
;
...
...
@@ -382,14 +383,6 @@ class MockHttpClient extends Mock implements HttpClient {}
class
MockCrashReporter
extends
Mock
implements
CrashReporter
{}
class
FakePlistParser
implements
PlistParser
{
@override
Map
<
String
,
dynamic
>
parseFile
(
String
plistFilePath
)
=>
const
<
String
,
dynamic
>{};
@override
String
getValueFromFile
(
String
plistFilePath
,
String
key
)
=>
null
;
}
class
LocalFileSystemBlockingSetCurrentDirectory
extends
LocalFileSystem
{
LocalFileSystemBlockingSetCurrentDirectory
()
:
super
.
test
(
signals:
LocalSignals
.
instance
,
...
...
packages/flutter_tools/test/src/fakes.dart
View file @
86c21c5d
...
...
@@ -7,7 +7,6 @@
import
'dart:async'
;
import
'dart:io'
as
io
show
IOSink
,
ProcessSignal
,
Stdout
,
StdoutException
;
import
'package:flutter_tools/src/base/file_system.dart'
;
import
'package:flutter_tools/src/base/io.dart'
;
import
'package:flutter_tools/src/base/logger.dart'
;
...
...
@@ -15,6 +14,7 @@ import 'package:flutter_tools/src/base/os.dart';
import
'package:flutter_tools/src/cache.dart'
;
import
'package:flutter_tools/src/convert.dart'
;
import
'package:flutter_tools/src/device.dart'
;
import
'package:flutter_tools/src/ios/plist_parser.dart'
;
/// A fake implementation of the [DeviceLogReader].
class
FakeDeviceLogReader
extends
DeviceLogReader
{
...
...
@@ -398,3 +398,21 @@ class ThrowingPollingDeviceDiscovery extends PollingDeviceDiscovery {
@override
bool
get
canListAnything
=>
true
;
}
class
FakePlistParser
implements
PlistParser
{
final
Map
<
String
,
dynamic
>
_underlyingValues
=
<
String
,
String
>{};
void
setProperty
(
String
key
,
dynamic
value
)
{
_underlyingValues
[
key
]
=
value
;
}
@override
Map
<
String
,
dynamic
>
parseFile
(
String
plistFilePath
)
{
return
_underlyingValues
;
}
@override
String
getValueFromFile
(
String
plistFilePath
,
String
key
)
{
return
_underlyingValues
[
key
]
as
String
;
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment