If Color constructor is passed a value > 0xFFFFFFFF, Sky crashes
We now ensure the color is <= 0xFFFFFFFF. Fixes #245 R=ianh@google.com Review URL: https://codereview.chromium.org/1179413008.
This commit is contained in:
8
engine/src/flutter/tests/raw/color_bounds-expected.txt
Normal file
8
engine/src/flutter/tests/raw/color_bounds-expected.txt
Normal file
@@ -0,0 +1,8 @@
|
||||
CONSOLE: unittest-suite-wait-for-done
|
||||
CONSOLE: PASS: paint set to black
|
||||
CONSOLE: PASS: color created with out of bounds value
|
||||
CONSOLE: PASS: color created with wildly out of bounds value
|
||||
CONSOLE:
|
||||
CONSOLE: All 3 tests passed.
|
||||
CONSOLE: unittest-suite-success
|
||||
DONE
|
||||
35
engine/src/flutter/tests/raw/color_bounds.dart
Normal file
35
engine/src/flutter/tests/raw/color_bounds.dart
Normal file
@@ -0,0 +1,35 @@
|
||||
import 'dart:sky' as sky;
|
||||
|
||||
import '../resources/third_party/unittest/unittest.dart';
|
||||
import '../resources/unit.dart';
|
||||
|
||||
void main() {
|
||||
initUnit();
|
||||
|
||||
test("paint set to black", () {
|
||||
sky.Color c = new sky.Color(0x00000000);
|
||||
sky.Paint p = new sky.Paint();
|
||||
p.color = c;
|
||||
expect(c.toString(), equals('Color(0x00000000)'));
|
||||
});
|
||||
|
||||
test("color created with out of bounds value", () {
|
||||
try {
|
||||
sky.Color c = new sky.Color(0x100 << 24);
|
||||
sky.Paint p = new sky.Paint();
|
||||
p.color = c;
|
||||
} catch (e) {
|
||||
expect(e != null, equals(true));
|
||||
}
|
||||
});
|
||||
|
||||
test("color created with wildly out of bounds value", () {
|
||||
try {
|
||||
sky.Color c = new sky.Color(1 << 1000000);
|
||||
sky.Paint p = new sky.Paint();
|
||||
p.color = c;
|
||||
} catch (e) {
|
||||
expect(e != null, equals(true));
|
||||
}
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user