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
b8597f0a
Unverified
Commit
b8597f0a
authored
Jul 03, 2019
by
Jonah Williams
Committed by
GitHub
Jul 03, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move usage flutter create tests into memory filesystem. (#35160)
parent
d41eeeb5
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
171 additions
and
64 deletions
+171
-64
create_test.dart
packages/flutter_tools/test/commands/create_test.dart
+0
-63
create_usage_test.dart
packages/flutter_tools/test/commands/create_usage_test.dart
+104
-0
testbed.dart
packages/flutter_tools/test/src/testbed.dart
+67
-1
No files found.
packages/flutter_tools/test/commands/create_test.dart
View file @
b8597f0a
...
...
@@ -17,7 +17,6 @@ import 'package:flutter_tools/src/cache.dart';
import
'package:flutter_tools/src/commands/create.dart'
;
import
'package:flutter_tools/src/dart/sdk.dart'
;
import
'package:flutter_tools/src/project.dart'
;
import
'package:flutter_tools/src/usage.dart'
;
import
'package:flutter_tools/src/version.dart'
;
import
'package:mockito/mockito.dart'
;
...
...
@@ -1055,68 +1054,6 @@ void main() {
HttpClientFactory:
()
=>
()
=>
MockHttpClient
(
404
,
result:
'not found'
),
});
group
(
'usageValues'
,
()
{
testUsingContext
(
'set template type as usage value'
,
()
async
{
Cache
.
flutterRoot
=
'../..'
;
final
CreateCommand
command
=
CreateCommand
();
final
CommandRunner
<
void
>
runner
=
createTestCommandRunner
(
command
);
await
runner
.
run
(<
String
>[
'create'
,
'--no-pub'
,
'--template=module'
,
projectDir
.
path
]);
expect
(
await
command
.
usageValues
,
containsPair
(
kCommandCreateProjectType
,
'module'
));
await
runner
.
run
(<
String
>[
'create'
,
'--no-pub'
,
'--template=app'
,
projectDir
.
path
]);
expect
(
await
command
.
usageValues
,
containsPair
(
kCommandCreateProjectType
,
'app'
));
await
runner
.
run
(<
String
>[
'create'
,
'--no-pub'
,
'--template=package'
,
projectDir
.
path
]);
expect
(
await
command
.
usageValues
,
containsPair
(
kCommandCreateProjectType
,
'package'
));
await
runner
.
run
(<
String
>[
'create'
,
'--no-pub'
,
'--template=plugin'
,
projectDir
.
path
]);
expect
(
await
command
.
usageValues
,
containsPair
(
kCommandCreateProjectType
,
'plugin'
));
},
timeout:
allowForCreateFlutterProject
);
testUsingContext
(
'set iOS host language type as usage value'
,
()
async
{
Cache
.
flutterRoot
=
'../..'
;
final
CreateCommand
command
=
CreateCommand
();
final
CommandRunner
<
void
>
runner
=
createTestCommandRunner
(
command
);
await
runner
.
run
(<
String
>[
'create'
,
'--no-pub'
,
'--template=app'
,
projectDir
.
path
]);
expect
(
await
command
.
usageValues
,
containsPair
(
kCommandCreateIosLanguage
,
'objc'
));
await
runner
.
run
(<
String
>[
'create'
,
'--no-pub'
,
'--template=app'
,
'--ios-language=swift'
,
projectDir
.
path
,
]);
expect
(
await
command
.
usageValues
,
containsPair
(
kCommandCreateIosLanguage
,
'swift'
));
},
timeout:
allowForCreateFlutterProject
);
testUsingContext
(
'set Android host language type as usage value'
,
()
async
{
Cache
.
flutterRoot
=
'../..'
;
final
CreateCommand
command
=
CreateCommand
();
final
CommandRunner
<
void
>
runner
=
createTestCommandRunner
(
command
);
await
runner
.
run
(<
String
>[
'create'
,
'--no-pub'
,
'--template=app'
,
projectDir
.
path
]);
expect
(
await
command
.
usageValues
,
containsPair
(
kCommandCreateAndroidLanguage
,
'java'
));
await
runner
.
run
(<
String
>[
'create'
,
'--no-pub'
,
'--template=app'
,
'--android-language=kotlin'
,
projectDir
.
path
,
]);
expect
(
await
command
.
usageValues
,
containsPair
(
kCommandCreateAndroidLanguage
,
'kotlin'
));
},
timeout:
allowForCreateFlutterProject
);
});
}
...
...
packages/flutter_tools/test/commands/create_usage_test.dart
0 → 100644
View file @
b8597f0a
// Copyright 2015 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:args/command_runner.dart'
;
import
'package:flutter_tools/src/base/file_system.dart'
;
import
'package:flutter_tools/src/cache.dart'
;
import
'package:flutter_tools/src/commands/create.dart'
;
import
'package:flutter_tools/src/doctor.dart'
;
import
'package:flutter_tools/src/usage.dart'
;
import
'../src/common.dart'
;
import
'../src/testbed.dart'
;
void
main
(
)
{
group
(
'usageValues'
,
()
{
Testbed
testbed
;
setUpAll
(()
{
Cache
.
disableLocking
();
});
setUp
(()
{
testbed
=
Testbed
(
setup:
()
{
final
List
<
String
>
paths
=
<
String
>[
fs
.
path
.
join
(
'flutter'
,
'packages'
,
'flutter'
,
'pubspec.yaml'
),
fs
.
path
.
join
(
'flutter'
,
'packages'
,
'flutter_driver'
,
'pubspec.yaml'
),
fs
.
path
.
join
(
'flutter'
,
'packages'
,
'flutter_test'
,
'pubspec.yaml'
),
fs
.
path
.
join
(
'flutter'
,
'bin'
,
'cache'
,
'artifacts'
,
'gradle_wrapper'
,
'wrapper'
),
fs
.
path
.
join
(
'usr'
,
'local'
,
'bin'
,
'adb'
),
fs
.
path
.
join
(
'Android'
,
'platform-tools'
,
'foo'
),
];
for
(
String
path
in
paths
)
{
fs
.
file
(
path
).
createSync
(
recursive:
true
);
}
},
overrides:
<
Type
,
Generator
>{
DoctorValidatorsProvider:
()
=>
FakeDoctorValidatorsProvider
(),
});
});
test
(
'set template type as usage value'
,
()
=>
testbed
.
run
(()
async
{
final
CreateCommand
command
=
CreateCommand
();
final
CommandRunner
<
void
>
runner
=
createTestCommandRunner
(
command
);
await
runner
.
run
(<
String
>[
'create'
,
'--flutter-root=flutter'
,
'--no-pub'
,
'--template=module'
,
'testy'
]);
expect
(
await
command
.
usageValues
,
containsPair
(
kCommandCreateProjectType
,
'module'
));
await
runner
.
run
(<
String
>[
'create'
,
'--flutter-root=flutter'
,
'--no-pub'
,
'--template=app'
,
'testy'
]);
expect
(
await
command
.
usageValues
,
containsPair
(
kCommandCreateProjectType
,
'app'
));
await
runner
.
run
(<
String
>[
'create'
,
'--flutter-root=flutter'
,
'--no-pub'
,
'--template=package'
,
'testy'
]);
expect
(
await
command
.
usageValues
,
containsPair
(
kCommandCreateProjectType
,
'package'
));
await
runner
.
run
(<
String
>[
'create'
,
'--flutter-root=flutter'
,
'--no-pub'
,
'--template=plugin'
,
'testy'
]);
expect
(
await
command
.
usageValues
,
containsPair
(
kCommandCreateProjectType
,
'plugin'
));
}));
test
(
'set iOS host language type as usage value'
,
()
=>
testbed
.
run
(()
async
{
final
CreateCommand
command
=
CreateCommand
();
final
CommandRunner
<
void
>
runner
=
createTestCommandRunner
(
command
);
await
runner
.
run
(<
String
>[
'create'
,
'--flutter-root=flutter'
,
'--no-pub'
,
'--template=app'
,
'testy'
]);
expect
(
await
command
.
usageValues
,
containsPair
(
kCommandCreateIosLanguage
,
'objc'
));
await
runner
.
run
(<
String
>[
'create'
,
'--flutter-root=flutter'
,
'--no-pub'
,
'--template=app'
,
'--ios-language=swift'
,
'testy'
,
]);
expect
(
await
command
.
usageValues
,
containsPair
(
kCommandCreateIosLanguage
,
'swift'
));
}));
test
(
'set Android host language type as usage value'
,
()
=>
testbed
.
run
(()
async
{
final
CreateCommand
command
=
CreateCommand
();
final
CommandRunner
<
void
>
runner
=
createTestCommandRunner
(
command
);
await
runner
.
run
(<
String
>[
'create'
,
'--flutter-root=flutter'
,
'--no-pub'
,
'--template=app'
,
'testy'
]);
expect
(
await
command
.
usageValues
,
containsPair
(
kCommandCreateAndroidLanguage
,
'java'
));
await
runner
.
run
(<
String
>[
'create'
,
'--flutter-root=flutter'
,
'--no-pub'
,
'--template=app'
,
'--android-language=kotlin'
,
'testy'
,
]);
expect
(
await
command
.
usageValues
,
containsPair
(
kCommandCreateAndroidLanguage
,
'kotlin'
));
}));
});
}
class
FakeDoctorValidatorsProvider
implements
DoctorValidatorsProvider
{
@override
List
<
DoctorValidator
>
get
validators
=>
<
DoctorValidator
>[];
@override
List
<
Workflow
>
get
workflows
=>
<
Workflow
>[];
}
packages/flutter_tools/test/src/testbed.dart
View file @
b8597f0a
...
...
@@ -13,6 +13,7 @@ import 'package:flutter_tools/src/base/terminal.dart';
import
'package:flutter_tools/src/cache.dart'
;
import
'package:flutter_tools/src/context_runner.dart'
;
import
'package:flutter_tools/src/usage.dart'
;
import
'package:flutter_tools/src/version.dart'
;
import
'context.dart'
;
...
...
@@ -28,6 +29,7 @@ final Map<Type, Generator> _testbedDefaults = <Type, Generator>{
Logger:
()
=>
BufferLogger
(),
// Allows reading logs and prevents stdout.
OutputPreferences:
()
=>
OutputPreferences
(
showColor:
false
),
// configures BufferLogger to avoid color codes.
Usage:
()
=>
NoOpUsage
(),
// prevent addition of analytics from burdening test mocks
FlutterVersion:
()
=>
FakeFlutterVersion
()
// prevent requirement to mock git for test runner.
};
/// Manages interaction with the tool injection and runner system.
...
...
@@ -141,3 +143,67 @@ class NoOpUsage implements Usage {
@override
void
sendTiming
(
String
category
,
String
variableName
,
Duration
duration
,
{
String
label
})
{}
}
class
FakeFlutterVersion
implements
FlutterVersion
{
@override
String
get
channel
=>
'master'
;
@override
Future
<
void
>
checkFlutterVersionFreshness
()
async
{
}
@override
bool
checkRevisionAncestry
({
String
tentativeDescendantRevision
,
String
tentativeAncestorRevision
})
{
throw
UnimplementedError
();
}
@override
String
get
dartSdkVersion
=>
'12'
;
@override
String
get
engineRevision
=>
'42.2'
;
@override
String
get
engineRevisionShort
=>
'42'
;
@override
Future
<
void
>
ensureVersionFile
()
async
{
}
@override
String
get
frameworkAge
=>
null
;
@override
String
get
frameworkCommitDate
=>
null
;
@override
String
get
frameworkDate
=>
null
;
@override
String
get
frameworkRevision
=>
null
;
@override
String
get
frameworkRevisionShort
=>
null
;
@override
String
get
frameworkVersion
=>
null
;
@override
String
getBranchName
({
bool
redactUnknownBranches
=
false
})
{
return
'master'
;
}
@override
String
getVersionString
({
bool
redactUnknownBranches
=
false
})
{
return
'v0.0.0'
;
}
@override
bool
get
isMaster
=>
true
;
@override
String
get
repositoryUrl
=>
null
;
@override
Map
<
String
,
Object
>
toJson
()
{
return
null
;
}
}
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