-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use new color testing code for grid test
- Loading branch information
Showing
2 changed files
with
8 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,30 @@ | ||
|
||
private void register_grid() { | ||
|
||
Test.add_func("/LiveChart/Grid#should_generate_padding_when_y_axis_has_not_unit", () => { | ||
Test.add_func("/Grid/should_generate_padding_when_y_axis_has_not_unit", () => { | ||
//given | ||
var WIDTH = 100; | ||
var HEIGHT = 100; | ||
|
||
var red = Gdk.RGBA() { red = 1f, green = 0f, blue = 0f, alpha = 1f }; | ||
|
||
var context = create_context(WIDTH, HEIGHT); | ||
context.set_background_color(red); | ||
|
||
var config = new LiveChart.Config(); | ||
config.y_axis.update_bounds(10); | ||
config.height = HEIGHT; | ||
config.width = WIDTH; | ||
config.configure(context.ctx, null); | ||
|
||
var grid = new LiveChart.Grid(); | ||
var background = new LiveChart.Background(); | ||
background.color = { 1f, 0f, 0f, 1f }; | ||
background.draw(context.ctx, config); | ||
|
||
//when | ||
grid.draw(context.ctx, config); | ||
|
||
//then | ||
var pixbuff = Gdk.pixbuf_get_from_surface(context.surface, 0, 0, WIDTH, HEIGHT); | ||
screenshot(context); | ||
|
||
//then | ||
//Colors between left side and first pixels of "0" char on y-axis | ||
var padding_colors = colors_at(pixbuff, WIDTH, HEIGHT)(0, 80, 10, 80); | ||
assert(padding_colors.size == 11); | ||
foreach (var color in padding_colors) { | ||
assert(color.red == 1.0); | ||
assert(color.green == 0); | ||
assert(color.blue == 0); | ||
assert(color.alpha == 1); | ||
} | ||
assert(has_only_one_color_in_rectangle(context, 0, 80, 10, 80)(red)); | ||
}); | ||
} | ||
|