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
18fcb91e
Commit
18fcb91e
authored
Feb 01, 2017
by
Chris Bracken
Committed by
GitHub
Feb 01, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add tests for iOS doctor validaton (#7794)
parent
b082b93a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
126 additions
and
2 deletions
+126
-2
ios_workflow.dart
packages/flutter_tools/lib/src/ios/ios_workflow.dart
+8
-2
ios_workflow_test.dart
packages/flutter_tools/test/src/ios/ios_workflow_test.dart
+118
-0
No files found.
packages/flutter_tools/lib/src/ios/ios_workflow.dart
View file @
18fcb91e
...
...
@@ -38,6 +38,8 @@ class IOSWorkflow extends DoctorValidator implements Workflow {
String
get
iosDeployVersionText
=>
runSync
(<
String
>[
'ios-deploy'
,
'--version'
]).
replaceAll
(
'
\n
'
,
''
);
bool
get
hasHomebrew
=>
os
.
which
(
'brew'
)
!=
null
;
bool
get
_iosDeployIsInstalledAndMeetsVersionCheck
{
if
(!
hasIosDeploy
)
return
false
;
...
...
@@ -89,7 +91,7 @@ class IOSWorkflow extends DoctorValidator implements Workflow {
}
// brew installed
if
(
os
.
which
(
'brew'
)
!=
null
)
{
if
(
hasHomebrew
)
{
brewStatus
=
ValidationType
.
installed
;
if
(!
exitsHappy
(<
String
>[
'ideviceinstaller'
,
'-h'
]))
{
...
...
@@ -132,9 +134,13 @@ class IOSWorkflow extends DoctorValidator implements Workflow {
}
return
new
ValidationResult
(
xcodeStatus
==
brewStatus
?
xcodeStatus
:
ValidationType
.
partial
,
<
ValidationType
>[
xcodeStatus
,
brewStatus
].
reduce
(
_mergeValidationTypes
)
,
messages
,
statusInfo:
xcodeVersionInfo
);
}
ValidationType
_mergeValidationTypes
(
ValidationType
t1
,
ValidationType
t2
)
{
return
t1
==
t2
?
t1
:
ValidationType
.
partial
;
}
}
packages/flutter_tools/test/src/ios/ios_workflow_test.dart
0 → 100644
View file @
18fcb91e
// Copyright 2017 The Chromium 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
'package:flutter_tools/src/doctor.dart'
;
import
'package:flutter_tools/src/ios/ios_workflow.dart'
;
import
'package:flutter_tools/src/ios/mac.dart'
;
import
'package:mockito/mockito.dart'
;
import
'package:test/test.dart'
;
import
'../context.dart'
;
void
main
(
)
{
group
(
'iOS Workflow validation'
,
()
{
MockXCode
xcode
;
setUp
(()
{
xcode
=
new
MockXCode
();
});
testUsingContext
(
'Emit missing status when nothing is installed'
,
()
async
{
when
(
xcode
.
isInstalled
).
thenReturn
(
false
);
IOSWorkflowTestTarget
workflow
=
new
IOSWorkflowTestTarget
()
..
hasHomebrew
=
false
..
hasIosDeploy
=
false
;
ValidationResult
result
=
await
workflow
.
validate
();
expect
(
result
.
type
,
ValidationType
.
missing
);
},
overrides:
<
Type
,
Generator
>{
XCode:
()
=>
xcode
});
testUsingContext
(
'Emits partial status when Xcode is not installed'
,
()
async
{
when
(
xcode
.
isInstalled
).
thenReturn
(
false
);
IOSWorkflowTestTarget
workflow
=
new
IOSWorkflowTestTarget
();
ValidationResult
result
=
await
workflow
.
validate
();
expect
(
result
.
type
,
ValidationType
.
partial
);
},
overrides:
<
Type
,
Generator
>{
XCode:
()
=>
xcode
});
testUsingContext
(
'Emits partial status when Xcode version too low'
,
()
async
{
when
(
xcode
.
isInstalled
).
thenReturn
(
true
);
when
(
xcode
.
xcodeVersionText
)
.
thenReturn
(
'Xcode 7.0.1
\n
Build version 7C1002
\n
'
);
when
(
xcode
.
isInstalledAndMeetsVersionCheck
).
thenReturn
(
false
);
when
(
xcode
.
eulaSigned
).
thenReturn
(
true
);
IOSWorkflowTestTarget
workflow
=
new
IOSWorkflowTestTarget
();
ValidationResult
result
=
await
workflow
.
validate
();
expect
(
result
.
type
,
ValidationType
.
partial
);
},
overrides:
<
Type
,
Generator
>{
XCode:
()
=>
xcode
});
testUsingContext
(
'Emits partial status when Xcode EULA not signed'
,
()
async
{
when
(
xcode
.
isInstalled
).
thenReturn
(
true
);
when
(
xcode
.
xcodeVersionText
)
.
thenReturn
(
'Xcode 8.2.1
\n
Build version 8C1002
\n
'
);
when
(
xcode
.
isInstalledAndMeetsVersionCheck
).
thenReturn
(
true
);
when
(
xcode
.
eulaSigned
).
thenReturn
(
false
);
IOSWorkflowTestTarget
workflow
=
new
IOSWorkflowTestTarget
();
ValidationResult
result
=
await
workflow
.
validate
();
expect
(
result
.
type
,
ValidationType
.
partial
);
},
overrides:
<
Type
,
Generator
>{
XCode:
()
=>
xcode
});
testUsingContext
(
'Emits partial status when homebrew not installed'
,
()
async
{
when
(
xcode
.
isInstalled
).
thenReturn
(
true
);
when
(
xcode
.
xcodeVersionText
)
.
thenReturn
(
'Xcode 8.2.1
\n
Build version 8C1002
\n
'
);
when
(
xcode
.
isInstalledAndMeetsVersionCheck
).
thenReturn
(
true
);
when
(
xcode
.
eulaSigned
).
thenReturn
(
true
);
IOSWorkflowTestTarget
workflow
=
new
IOSWorkflowTestTarget
()
..
hasHomebrew
=
false
;
ValidationResult
result
=
await
workflow
.
validate
();
expect
(
result
.
type
,
ValidationType
.
partial
);
},
overrides:
<
Type
,
Generator
>{
XCode:
()
=>
xcode
});
testUsingContext
(
'Emits partial status when ios-deploy is not installed'
,
()
async
{
when
(
xcode
.
isInstalled
).
thenReturn
(
true
);
when
(
xcode
.
xcodeVersionText
)
.
thenReturn
(
'Xcode 8.2.1
\n
Build version 8C1002
\n
'
);
when
(
xcode
.
isInstalledAndMeetsVersionCheck
).
thenReturn
(
true
);
when
(
xcode
.
eulaSigned
).
thenReturn
(
true
);
IOSWorkflowTestTarget
workflow
=
new
IOSWorkflowTestTarget
()
..
hasIosDeploy
=
false
;
ValidationResult
result
=
await
workflow
.
validate
();
expect
(
result
.
type
,
ValidationType
.
partial
);
},
overrides:
<
Type
,
Generator
>{
XCode:
()
=>
xcode
});
testUsingContext
(
'Emits partial status when ios-deploy version is too low'
,
()
async
{
when
(
xcode
.
isInstalled
).
thenReturn
(
true
);
when
(
xcode
.
xcodeVersionText
)
.
thenReturn
(
'Xcode 8.2.1
\n
Build version 8C1002
\n
'
);
when
(
xcode
.
isInstalledAndMeetsVersionCheck
).
thenReturn
(
true
);
when
(
xcode
.
eulaSigned
).
thenReturn
(
true
);
IOSWorkflowTestTarget
workflow
=
new
IOSWorkflowTestTarget
()
..
iosDeployVersionText
=
'1.8.0'
;
ValidationResult
result
=
await
workflow
.
validate
();
expect
(
result
.
type
,
ValidationType
.
partial
);
},
overrides:
<
Type
,
Generator
>{
XCode:
()
=>
xcode
});
testUsingContext
(
'Succeeds when all checks pass'
,
()
async
{
when
(
xcode
.
isInstalled
).
thenReturn
(
true
);
when
(
xcode
.
xcodeVersionText
)
.
thenReturn
(
'Xcode 8.2.1
\n
Build version 8C1002
\n
'
);
when
(
xcode
.
isInstalledAndMeetsVersionCheck
).
thenReturn
(
true
);
when
(
xcode
.
eulaSigned
).
thenReturn
(
true
);
ValidationResult
result
=
await
new
IOSWorkflowTestTarget
().
validate
();
expect
(
result
.
type
,
ValidationType
.
installed
);
},
overrides:
<
Type
,
Generator
>{
XCode:
()
=>
xcode
});
});
}
class
MockXCode
extends
Mock
implements
XCode
{}
class
IOSWorkflowTestTarget
extends
IOSWorkflow
{
@override
bool
hasHomebrew
=
true
;
@override
bool
hasIosDeploy
=
true
;
@override
String
iosDeployVersionText
=
'1.9.0'
;
}
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