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
799678f0
Commit
799678f0
authored
Apr 18, 2018
by
Danny Tuppeny
Committed by
Danny Tuppeny
May 09, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add some tests around device+ini parsing
parent
4c67885b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
59 additions
and
4 deletions
+59
-4
android_emulator.dart
packages/flutter_tools/lib/src/android/android_emulator.dart
+3
-4
android_emulator_test.dart
...ges/flutter_tools/test/android/android_emulator_test.dart
+56
-0
No files found.
packages/flutter_tools/lib/src/android/android_emulator.dart
View file @
799678f0
...
...
@@ -81,12 +81,12 @@ void extractEmulatorAvdInfo(String text, List<AndroidEmulator> emulators) {
AndroidEmulator
_createEmulator
(
String
id
)
{
id
=
id
.
trim
();
final
File
iniFile
=
fs
.
file
(
fs
.
path
.
join
(
getAvdPath
(),
'
$id
.ini'
));
final
Map
<
String
,
String
>
ini
=
_
parseIniLines
(
iniFile
.
readAsLinesSync
());
final
Map
<
String
,
String
>
ini
=
parseIniLines
(
iniFile
.
readAsLinesSync
());
if
(
ini
[
'path'
]
!=
null
)
{
final
File
configFile
=
fs
.
file
(
fs
.
path
.
join
(
ini
[
'path'
],
'config.ini'
));
if
(
configFile
.
existsSync
())
{
final
Map
<
String
,
String
>
properties
=
_
parseIniLines
(
configFile
.
readAsLinesSync
());
final
Map
<
String
,
String
>
properties
=
parseIniLines
(
configFile
.
readAsLinesSync
());
return
new
AndroidEmulator
(
id
,
properties
);
}
}
...
...
@@ -94,9 +94,8 @@ AndroidEmulator _createEmulator(String id) {
return
new
AndroidEmulator
(
id
);
}
// TODO: Tests
@visibleForTesting
Map
<
String
,
String
>
_
parseIniLines
(
List
<
String
>
contents
)
{
Map
<
String
,
String
>
parseIniLines
(
List
<
String
>
contents
)
{
final
Map
<
String
,
String
>
results
=
<
String
,
String
>{};
final
Iterable
<
List
<
String
>>
properties
=
contents
...
...
packages/flutter_tools/test/android/android_emulator_test.dart
0 → 100644
View file @
799678f0
// Copyright 2018 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/android/android_emulator.dart'
;
import
'package:test/test.dart'
;
import
'../src/context.dart'
;
void
main
(
)
{
group
(
'android_emulator'
,
()
{
testUsingContext
(
'flags emulators without config'
,
()
{
const
String
emulatorID
=
'1234'
;
final
AndroidEmulator
emulator
=
new
AndroidEmulator
(
emulatorID
);
expect
(
emulator
.
id
,
emulatorID
);
expect
(
emulator
.
hasConfig
,
false
);
});
testUsingContext
(
'flags emulators with config'
,
()
{
const
String
emulatorID
=
'1234'
;
final
AndroidEmulator
emulator
=
new
AndroidEmulator
(
emulatorID
,
<
String
,
String
>{
'name'
:
'test'
});
expect
(
emulator
.
id
,
emulatorID
);
expect
(
emulator
.
hasConfig
,
true
);
});
testUsingContext
(
'stores expected metadata'
,
()
{
const
String
emulatorID
=
'1234'
;
const
String
name
=
'My Test Name'
;
const
String
manufacturer
=
'Me'
;
const
String
label
=
'The best one'
;
final
Map
<
String
,
String
>
properties
=
<
String
,
String
>{
'hw.device.name'
:
name
,
'hw.device.manufacturer'
:
manufacturer
,
'avd.ini.displayname'
:
label
};
final
AndroidEmulator
emulator
=
new
AndroidEmulator
(
emulatorID
,
properties
);
expect
(
emulator
.
id
,
emulatorID
);
expect
(
emulator
.
name
,
name
);
expect
(
emulator
.
manufacturer
,
manufacturer
);
expect
(
emulator
.
label
,
label
);
});
testUsingContext
(
'parses ini files'
,
()
{
const
String
iniFile
=
'''
hw.device.name=My Test Name
#hw.device.name=Bad Name
hw.device.manufacturer=Me
avd.ini.displayname = dispName
'''
;
final
Map
<
String
,
String
>
results
=
parseIniLines
(
iniFile
.
split
(
'
\n
'
));
expect
(
results
[
'hw.device.name'
],
'My Test Name'
);
expect
(
results
[
'hw.device.manufacturer'
],
'Me'
);
expect
(
results
[
'avd.ini.displayname'
],
'dispName'
);
});
});
}
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