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
3b104a81
Commit
3b104a81
authored
Jan 20, 2017
by
Adam Barth
Committed by
GitHub
Jan 20, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve test coverage (#7564)
Also, fix some minor bugs with SynchronousFuture.
parent
86f5c78f
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
157 additions
and
4 deletions
+157
-4
synchronous_future.dart
packages/flutter/lib/src/foundation/synchronous_future.dart
+4
-2
button.dart
packages/flutter/lib/src/material/button.dart
+1
-1
animation_controller_test.dart
...ges/flutter/test/animation/animation_controller_test.dart
+14
-0
animations_test.dart
packages/flutter/test/animation/animations_test.dart
+14
-1
caching_iterable_test.dart
packages/flutter/test/foundation/caching_iterable_test.dart
+17
-0
synchronous_future_test.dart
...ages/flutter/test/foundation/synchronous_future_test.dart
+54
-0
icon_theme_data_test.dart
packages/flutter/test/material/icon_theme_data_test.dart
+21
-0
theme_data_test.dart
packages/flutter/test/material/theme_data_test.dart
+14
-0
priority_test.dart
packages/flutter/test/scheduler/priority_test.dart
+16
-0
ticker_test.dart
packages/flutter/test/scheduler/ticker_test.dart
+2
-0
No files found.
packages/flutter/lib/src/foundation/synchronous_future.dart
View file @
3b104a81
...
...
@@ -42,7 +42,9 @@ class SynchronousFuture<T> implements Future<T> {
}
@override
Future
<
T
>
timeout
(
Duration
timeLimit
,
{
dynamic
onTimeout
()
})
=>
new
Completer
<
T
>().
future
;
Future
<
T
>
timeout
(
Duration
timeLimit
,
{
dynamic
onTimeout
()
})
{
return
new
Future
<
T
>.
value
(
_value
).
timeout
(
timeLimit
,
onTimeout:
onTimeout
);
}
@override
Future
<
T
>
whenComplete
(
dynamic
action
())
{
...
...
@@ -55,4 +57,4 @@ class SynchronousFuture<T> implements Future<T> {
return
new
Future
<
T
>.
error
(
e
,
stack
);
}
}
}
\ No newline at end of file
}
packages/flutter/lib/src/material/button.dart
View file @
3b104a81
...
...
@@ -230,6 +230,7 @@ class _MaterialButtonState extends State<MaterialButton> {
}
}
}
else
{
assert
(
_colorBrightness
!=
null
);
switch
(
_colorBrightness
)
{
case
Brightness
.
light
:
return
Colors
.
black26
;
...
...
@@ -237,7 +238,6 @@ class _MaterialButtonState extends State<MaterialButton> {
return
Colors
.
white30
;
}
}
assert
(
_colorBrightness
!=
null
);
return
null
;
}
...
...
packages/flutter/test/animation/animation_controller_test.dart
View file @
3b104a81
...
...
@@ -269,4 +269,18 @@ void main() {
controller
.
dispose
();
expect
(
controller
,
hasOneLineDescription
);
});
test
(
'AnimationController error handling'
,
()
{
AnimationController
controller
=
new
AnimationController
(
vsync:
const
TestVSync
(),
);
expect
(
controller
.
forward
,
throwsFlutterError
);
expect
(
controller
.
reverse
,
throwsFlutterError
);
expect
(()
{
controller
.
animateTo
(
0.5
);
},
throwsFlutterError
);
expect
(
controller
.
repeat
,
throwsFlutterError
);
controller
.
dispose
();
expect
(
controller
.
dispose
,
throwsFlutterError
);
});
}
packages/flutter/test/animation/animations_test.dart
View file @
3b104a81
...
...
@@ -6,6 +6,11 @@ import 'package:flutter_test/flutter_test.dart';
import
'package:flutter/animation.dart'
;
import
'package:flutter/widgets.dart'
;
class
BogusCurve
extends
Curve
{
@override
double
transform
(
double
t
)
=>
100.0
;
}
void
main
(
)
{
setUp
(()
{
WidgetsFlutterBinding
.
ensureInitialized
();
...
...
@@ -113,7 +118,6 @@ void main() {
expect
(
animation
.
toString
(),
contains
(
'no next'
));
});
test
(
'AnimationMean control test'
,
()
{
AnimationController
left
=
new
AnimationController
(
value:
0.5
,
...
...
@@ -148,4 +152,13 @@ void main() {
expect
(
mean
.
value
,
equals
(
0.50
));
expect
(
log
,
isEmpty
);
});
test
(
'CurvedAnimation with bogus curve'
,
()
{
AnimationController
controller
=
new
AnimationController
(
vsync:
const
TestVSync
(),
);
CurvedAnimation
curved
=
new
CurvedAnimation
(
parent:
controller
,
curve:
new
BogusCurve
());
expect
(()
{
curved
.
value
;
},
throwsFlutterError
);
});
}
packages/flutter/test/foundation/caching_iterable_test.dart
View file @
3b104a81
...
...
@@ -90,4 +90,21 @@ void main() {
expect
(
integers
,
equals
(<
int
>[
1
,
2
,
3
,
4
,
5
]));
expect
(
yieldCount
,
equals
(
5
));
});
test
(
'The Caching Iterable: expand'
,
()
{
Iterable
<
int
>
integers
=
new
CachingIterable
<
int
>(
range
(
1
,
5
).
iterator
);
expect
(
yieldCount
,
equals
(
0
));
Iterable
<
int
>
expanded1
=
integers
.
expand
((
int
i
)
=>
<
int
>[
i
,
i
]);
expect
(
yieldCount
,
equals
(
0
));
expect
(
expanded1
,
equals
(<
int
>[
1
,
1
,
2
,
2
,
3
,
3
,
4
,
4
,
5
,
5
]));
expect
(
yieldCount
,
equals
(
5
));
Iterable
<
int
>
expanded2
=
integers
.
expand
((
int
i
)
=>
<
int
>[
i
,
i
]);
expect
(
yieldCount
,
equals
(
5
));
expect
(
expanded2
,
equals
(<
int
>[
1
,
1
,
2
,
2
,
3
,
3
,
4
,
4
,
5
,
5
]));
expect
(
yieldCount
,
equals
(
5
));
});
}
packages/flutter/test/foundation/synchronous_future_test.dart
0 → 100644
View file @
3b104a81
// 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
'dart:async'
;
import
'package:flutter/foundation.dart'
;
import
'package:test/test.dart'
;
void
main
(
)
{
test
(
'SynchronousFuture control test'
,
()
async
{
Future
<
int
>
future
=
new
SynchronousFuture
<
int
>(
42
);
int
result
;
future
.
then
((
int
value
)
{
result
=
value
;
});
expect
(
result
,
equals
(
42
));
result
=
null
;
Future
<
int
>
futureWithTimeout
=
future
.
timeout
(
const
Duration
(
milliseconds:
1
));
futureWithTimeout
.
then
((
int
value
)
{
result
=
value
;
});
expect
(
result
,
isNull
);
await
futureWithTimeout
;
expect
(
result
,
equals
(
42
));
result
=
null
;
Stream
<
int
>
stream
=
future
.
asStream
();
expect
(
await
stream
.
single
,
equals
(
42
));
bool
ranAction
=
false
;
Future
<
int
>
completeResult
=
future
.
whenComplete
(()
{
ranAction
=
true
;
return
new
Future
<
int
>.
value
(
31
);
});
expect
(
ranAction
,
isTrue
);
ranAction
=
false
;
expect
(
await
completeResult
,
equals
(
42
));
Object
exception
;
try
{
await
future
.
whenComplete
(()
{
throw
null
;
});
// Unreached.
expect
(
false
,
isTrue
);
}
catch
(
e
)
{
exception
=
e
;
}
expect
(
exception
,
isNullThrownError
);
});
}
packages/flutter/test/material/icon_theme_data_test.dart
0 → 100644
View file @
3b104a81
// Copyright 2016 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/material.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
void
main
(
)
{
test
(
'IconThemeData control test'
,
()
{
IconThemeData
data
=
new
IconThemeData
(
color:
Colors
.
green
[
500
],
opacity:
0.5
,
size:
16.0
);
expect
(
data
,
hasOneLineDescription
);
expect
(
data
,
equals
(
data
.
copyWith
()));
expect
(
data
.
hashCode
,
equals
(
data
.
copyWith
().
hashCode
));
IconThemeData
lerped
=
IconThemeData
.
lerp
(
data
,
const
IconThemeData
.
fallback
(),
0.25
);
expect
(
lerped
.
color
,
equals
(
Color
.
lerp
(
Colors
.
green
[
500
],
Colors
.
black
,
0.25
)));
expect
(
lerped
.
opacity
,
equals
(
0.625
));
expect
(
lerped
.
size
,
equals
(
18.0
));
});
}
packages/flutter/test/material/theme_data_test.dart
View file @
3b104a81
...
...
@@ -6,6 +6,20 @@ import 'package:flutter/material.dart';
import
'package:flutter_test/flutter_test.dart'
;
void
main
(
)
{
test
(
'Theme data control test'
,
()
{
ThemeData
dark
=
new
ThemeData
.
dark
();
expect
(
dark
,
hasOneLineDescription
);
expect
(
dark
,
equals
(
dark
.
copyWith
()));
expect
(
dark
.
hashCode
,
equals
(
dark
.
copyWith
().
hashCode
));
ThemeData
light
=
new
ThemeData
.
light
();
ThemeData
dawn
=
ThemeData
.
lerp
(
dark
,
light
,
0.25
);
expect
(
dawn
.
brightness
,
Brightness
.
dark
);
expect
(
dawn
.
primaryColor
,
Color
.
lerp
(
dark
.
primaryColor
,
light
.
primaryColor
,
0.25
));
});
test
(
'Defaults to the default typography for the platform'
,
()
{
for
(
TargetPlatform
platform
in
TargetPlatform
.
values
)
{
ThemeData
theme
=
new
ThemeData
(
platform:
platform
);
...
...
packages/flutter/test/scheduler/priority_test.dart
0 → 100644
View file @
3b104a81
// 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/scheduler.dart'
;
import
'package:test/test.dart'
;
void
main
(
)
{
test
(
'Priority operators control test'
,
()
async
{
Priority
priority
=
Priority
.
idle
+
(
Priority
.
kMaxOffset
+
100
);
expect
(
priority
.
value
,
equals
(
Priority
.
idle
.
value
+
Priority
.
kMaxOffset
));
priority
=
Priority
.
animation
-
(
Priority
.
kMaxOffset
+
100
);
expect
(
priority
.
value
,
equals
(
Priority
.
animation
.
value
-
Priority
.
kMaxOffset
));
});
}
packages/flutter/test/scheduler/ticker_test.dart
View file @
3b104a81
...
...
@@ -23,6 +23,8 @@ void main() {
expect
(
ticker
.
isActive
,
isTrue
);
expect
(
tickCount
,
equals
(
0
));
expect
(
ticker
.
start
,
throwsFlutterError
);
await
tester
.
pump
(
const
Duration
(
milliseconds:
10
));
expect
(
tickCount
,
equals
(
1
));
...
...
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