[librsvg: 14/30] tests/examples: update per api changes
- From: Marge Bot <marge-bot src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg: 14/30] tests/examples: update per api changes
- Date: Wed, 23 Jun 2021 23:05:39 +0000 (UTC)
commit 1d679447d7757a6dd6e00e8dd73b2ddd10acc6ca
Author: Bilal Elmoussaoui <bil elmoussaoui gmail com>
Date: Thu Jun 17 14:05:58 2021 +0200
tests/examples: update per api changes
Part-of: <https://gitlab.gnome.org/GNOME/librsvg/-/merge_requests/516>
examples/proportional.rs | 2 +-
tests/src/api.rs | 12 ++++++------
tests/src/bugs.rs | 10 +++++-----
tests/src/compare_surfaces.rs | 4 ++--
tests/src/errors.rs | 2 +-
tests/src/filters.rs | 4 ++--
tests/src/intrinsic_dimensions.rs | 10 +++++-----
tests/src/primitives.rs | 14 +++++++-------
tests/src/reference.rs | 4 ++--
tests/src/reference_utils.rs | 5 ++---
tests/src/render_crash.rs | 2 +-
tests/src/utils.rs | 4 ++--
12 files changed, 36 insertions(+), 37 deletions(-)
---
diff --git a/examples/proportional.rs b/examples/proportional.rs
index ba3e7932..9924b3ed 100644
--- a/examples/proportional.rs
+++ b/examples/proportional.rs
@@ -40,7 +40,7 @@ fn main() {
let renderer = librsvg::CairoRenderer::new(&handle);
let surface = cairo::ImageSurface::create(cairo::Format::ARgb32, width, height).unwrap();
- let cr = cairo::Context::new(&surface);
+ let cr = cairo::Context::new(&surface).expect("Failed to create a cairo context");
let res = renderer.render_document(
&cr,
diff --git a/tests/src/api.rs b/tests/src/api.rs
index 2a59194b..6cb55397 100644
--- a/tests/src/api.rs
+++ b/tests/src/api.rs
@@ -52,7 +52,7 @@ fn render_layer() {
let output = cairo::ImageSurface::create(cairo::Format::ARgb32, 300, 300).unwrap();
let res = {
- let cr = cairo::Context::new(&output);
+ let cr = cairo::Context::new(&output).expect("Failed to create cairo context");
let viewport = cairo::Rectangle {
x: 100.0,
y: 100.0,
@@ -70,7 +70,7 @@ fn render_layer() {
let reference_surf = cairo::ImageSurface::create(cairo::Format::ARgb32, 300, 300).unwrap();
{
- let cr = cairo::Context::new(&reference_surf);
+ let cr = cairo::Context::new(&reference_surf).expect("Failed to create a cairo context");
cr.translate(100.0, 100.0);
@@ -134,7 +134,7 @@ fn untransformed_element() {
let output = cairo::ImageSurface::create(cairo::Format::ARgb32, 300, 300).unwrap();
let res = {
- let cr = cairo::Context::new(&output);
+ let cr = cairo::Context::new(&output).expect("Failed to create cairo context");
let viewport = cairo::Rectangle {
x: 100.0,
y: 100.0,
@@ -152,7 +152,7 @@ fn untransformed_element() {
let reference_surf = cairo::ImageSurface::create(cairo::Format::ARgb32, 300, 300).unwrap();
{
- let cr = cairo::Context::new(&reference_surf);
+ let cr = cairo::Context::new(&reference_surf).expect("Failed to create a cairo context");
cr.translate(100.0, 100.0);
@@ -190,7 +190,7 @@ fn set_stylesheet() {
let output = cairo::ImageSurface::create(cairo::Format::ARgb32, 100, 100).unwrap();
let res = {
- let cr = cairo::Context::new(&output);
+ let cr = cairo::Context::new(&output).expect("Failed to create cairo context");
let viewport = cairo::Rectangle {
x: 0.0,
y: 0.0,
@@ -208,7 +208,7 @@ fn set_stylesheet() {
let reference_surf = cairo::ImageSurface::create(cairo::Format::ARgb32, 100, 100).unwrap();
{
- let cr = cairo::Context::new(&reference_surf);
+ let cr = cairo::Context::new(&reference_surf).expect("Failed to create a cairo context");
cr.rectangle(10.0, 20.0, 30.0, 40.0);
cr.set_source_rgba(0.0, 1.0, 0.0, 1.0);
diff --git a/tests/src/bugs.rs b/tests/src/bugs.rs
index b36c21bd..d5ab54f4 100644
--- a/tests/src/bugs.rs
+++ b/tests/src/bugs.rs
@@ -69,7 +69,7 @@ fn nonexistent_image_shouldnt_cancel_rendering() {
let reference_surf = cairo::ImageSurface::create(cairo::Format::ARgb32, 50, 50).unwrap();
{
- let cr = cairo::Context::new(&reference_surf);
+ let cr = cairo::Context::new(&reference_surf).unwrap();
cr.rectangle(10.0, 10.0, 30.0, 30.0);
cr.set_source_rgba(0.0, 0.0, 1.0, 1.0);
@@ -118,7 +118,7 @@ fn href_attribute_overrides_xlink_href() {
let reference_surf = cairo::ImageSurface::create(cairo::Format::ARgb32, 500, 500).unwrap();
{
- let cr = cairo::Context::new(&reference_surf);
+ let cr = cairo::Context::new(&reference_surf).unwrap();
cr.rectangle(100.0, 100.0, 100.0, 100.0);
cr.set_source_rgba(0.0, 1.0, 0.0, 1.0);
@@ -159,7 +159,7 @@ fn nonexistent_filter_leaves_object_unfiltered() {
let reference_surf = cairo::ImageSurface::create(cairo::Format::ARgb32, 500, 500).unwrap();
{
- let cr = cairo::Context::new(&reference_surf);
+ let cr = cairo::Context::new(&reference_surf).unwrap();
cr.rectangle(100.0, 100.0, 100.0, 100.0);
cr.set_source_rgba(0.0, 1.0, 0.0, 1.0);
@@ -224,7 +224,7 @@ fn recursive_paint_servers_fallback_to_color() {
let reference_surf = cairo::ImageSurface::create(cairo::Format::ARgb32, 200, 200).unwrap();
{
- let cr = cairo::Context::new(&reference_surf);
+ let cr = cairo::Context::new(&reference_surf).unwrap();
cr.rectangle(0.0, 100.0, 200.0, 100.0);
cr.set_source_rgba(0.0, 1.0, 0.0, 1.0);
@@ -387,7 +387,7 @@ fn switch_element_should_ignore_elements_in_error() {
let reference_surf = cairo::ImageSurface::create(cairo::Format::ARgb32, 100, 100).unwrap();
{
- let cr = cairo::Context::new(&reference_surf);
+ let cr = cairo::Context::new(&reference_surf).unwrap();
cr.rectangle(10.0, 10.0, 10.0, 10.0);
cr.set_source_rgba(0.0, 0.0, 1.0, 1.0);
diff --git a/tests/src/compare_surfaces.rs b/tests/src/compare_surfaces.rs
index 0f94fd4e..4b7032ae 100644
--- a/tests/src/compare_surfaces.rs
+++ b/tests/src/compare_surfaces.rs
@@ -67,7 +67,7 @@ pub fn compare_surfaces(
}
let mut surf_diff = cairo::ImageSurface::create(cairo::Format::ARgb32, a_width, a_height)?;
- let diff_stride = surf_diff.get_stride() as usize;
+ let diff_stride = surf_diff.stride() as usize;
let mut num_pixels_changed = 0;
let mut max_diff = 0;
@@ -75,7 +75,7 @@ pub fn compare_surfaces(
let black = Pixel::default().alpha(255);
{
- let mut diff_data = surf_diff.get_data().unwrap();
+ let mut diff_data = surf_diff.data().unwrap();
for ((xa, ya, pixel_a), (_, _, pixel_b)) in Pixels::new(surf_a).zip(Pixels::new(surf_b)) {
let dest = if pixel_a != pixel_b {
diff --git a/tests/src/errors.rs b/tests/src/errors.rs
index 93b4f9dc..def44f9f 100644
--- a/tests/src/errors.rs
+++ b/tests/src/errors.rs
@@ -32,7 +32,7 @@ fn rendering_instancing_limit(name: &str) {
.unwrap_or_else(|e| panic!("could not load: {}", e));
let surface = cairo::ImageSurface::create(cairo::Format::ARgb32, 500, 500).unwrap();
- let cr = cairo::Context::new(&surface);
+ let cr = cairo::Context::new(&surface).expect("Failed to create a cairo context");
// Note that at least 515-patttern-billion-laughs.svg requires a viewport of this size
// or bigger; a smaller one causes the recursive patterns to get so small that they
diff --git a/tests/src/filters.rs b/tests/src/filters.rs
index 9f534c3d..1674bcd6 100644
--- a/tests/src/filters.rs
+++ b/tests/src/filters.rs
@@ -38,7 +38,7 @@ fn invalid_filter_reference_cancels_filter_chain() {
let reference_surf = cairo::ImageSurface::create(cairo::Format::ARgb32, 400, 400).unwrap();
{
- let cr = cairo::Context::new(&reference_surf);
+ let cr = cairo::Context::new(&reference_surf).expect("Failed to create a cairo context");
cr.rectangle(100.0, 100.0, 200.0, 200.0);
cr.set_source_rgb(0.0, 1.0, 0.0);
@@ -88,7 +88,7 @@ fn non_filter_reference_cancels_filter_chain() {
let reference_surf = cairo::ImageSurface::create(cairo::Format::ARgb32, 400, 400).unwrap();
{
- let cr = cairo::Context::new(&reference_surf);
+ let cr = cairo::Context::new(&reference_surf).expect("Failed to create a cairo context");
cr.rectangle(100.0, 100.0, 200.0, 200.0);
cr.set_source_rgb(0.0, 1.0, 0.0);
diff --git a/tests/src/intrinsic_dimensions.rs b/tests/src/intrinsic_dimensions.rs
index 9b6298b8..053c2af3 100644
--- a/tests/src/intrinsic_dimensions.rs
+++ b/tests/src/intrinsic_dimensions.rs
@@ -449,7 +449,7 @@ fn render_to_viewport_with_different_size() {
let reference_surf = cairo::ImageSurface::create(cairo::Format::ARgb32, 128, 128).unwrap();
{
- let cr = cairo::Context::new(&reference_surf);
+ let cr = cairo::Context::new(&reference_surf).expect("Failed to create a cairo context");
cr.scale(128.0 / 48.0, 128.0 / 48.0);
@@ -490,7 +490,7 @@ fn render_to_offsetted_viewport() {
let reference_surf = cairo::ImageSurface::create(cairo::Format::ARgb32, 100, 100).unwrap();
{
- let cr = cairo::Context::new(&reference_surf);
+ let cr = cairo::Context::new(&reference_surf).expect("Failed to create a cairo context");
cr.translate(10.0, 20.0);
@@ -533,7 +533,7 @@ fn render_to_viewport_with_transform() {
let reference_surf = cairo::ImageSurface::create(cairo::Format::ARgb32, 100, 100).unwrap();
{
- let cr = cairo::Context::new(&reference_surf);
+ let cr = cairo::Context::new(&reference_surf).expect("Failed to create a cairo context");
cr.translate(10.0, 20.0);
cr.translate(-10.0, -10.0);
@@ -583,7 +583,7 @@ fn clip_on_transformed_viewport() {
let reference_surf = cairo::ImageSurface::create(cairo::Format::ARgb32, 200, 200).unwrap();
{
- let cr = cairo::Context::new(&reference_surf);
+ let cr = cairo::Context::new(&reference_surf).expect("Failed to create a cairo context");
cr.translate(50.0, 50.0);
@@ -649,7 +649,7 @@ fn mask_on_transformed_viewport() {
let reference_surf = cairo::ImageSurface::create(cairo::Format::ARgb32, 200, 200).unwrap();
{
- let cr = cairo::Context::new(&reference_surf);
+ let cr = cairo::Context::new(&reference_surf).expect("Failed to create a cairo context");
cr.translate(50.0, 50.0);
diff --git a/tests/src/primitives.rs b/tests/src/primitives.rs
index ed5f9d91..e305bc5b 100644
--- a/tests/src/primitives.rs
+++ b/tests/src/primitives.rs
@@ -32,7 +32,7 @@ fn simple_opacity_with_transform() {
let reference_surf = cairo::ImageSurface::create(cairo::Format::ARgb32, 150, 150).unwrap();
{
- let cr = cairo::Context::new(&reference_surf);
+ let cr = cairo::Context::new(&reference_surf).expect("Failed to create a cairo context");
cr.translate(50.0, 50.0);
cr.rectangle(10.0, 10.0, 30.0, 30.0);
@@ -74,7 +74,7 @@ fn simple_opacity_with_offset_viewport() {
let reference_surf = cairo::ImageSurface::create(cairo::Format::ARgb32, 150, 150).unwrap();
{
- let cr = cairo::Context::new(&reference_surf);
+ let cr = cairo::Context::new(&reference_surf).expect("Failed to create a cairo context");
cr.translate(50.0, 50.0);
cr.rectangle(10.0, 10.0, 30.0, 30.0);
@@ -120,7 +120,7 @@ fn simple_opacity_with_scale() {
let reference_surf = cairo::ImageSurface::create(cairo::Format::ARgb32, 500, 500).unwrap();
{
- let cr = cairo::Context::new(&reference_surf);
+ let cr = cairo::Context::new(&reference_surf).expect("Failed to create a cairo context");
cr.translate(50.0, 50.0);
cr.scale(8.0, 8.0);
@@ -169,7 +169,7 @@ fn markers_with_scale() {
let reference_surf = cairo::ImageSurface::create(cairo::Format::ARgb32, 800, 800).unwrap();
{
- let cr = cairo::Context::new(&reference_surf);
+ let cr = cairo::Context::new(&reference_surf).expect("Failed to create a cairo context");
cr.scale(4.0, 4.0);
@@ -222,7 +222,7 @@ fn opacity_inside_transformed_group() {
let reference_surf = cairo::ImageSurface::create(cairo::Format::ARgb32, 140, 140).unwrap();
{
- let cr = cairo::Context::new(&reference_surf);
+ let cr = cairo::Context::new(&reference_surf).expect("Failed to create a cairo context");
cr.translate(20.0, 20.0);
cr.rectangle(20.0, 20.0, 60.0, 60.0);
@@ -269,7 +269,7 @@ fn compound_opacity() {
let reference_surf = cairo::ImageSurface::create(cairo::Format::ARgb32, 500, 380).unwrap();
{
- let cr = cairo::Context::new(&reference_surf);
+ let cr = cairo::Context::new(&reference_surf).expect("Failed to create a cairo context");
cr.translate(10.0, 10.0);
@@ -340,7 +340,7 @@ fn nested_masks() {
cairo::ImageSurface::create(cairo::Format::ARgb32, 321 + 20, 27 + 20).unwrap();
{
- let cr = cairo::Context::new(&reference_surf);
+ let cr = cairo::Context::new(&reference_surf).expect("Failed to create a cairo context");
cr.translate(10.0, 10.0);
cr.scale(321.0 / 6420.0, 27.0 / 540.0);
diff --git a/tests/src/reference.rs b/tests/src/reference.rs
index b1fd6536..831d73a0 100644
--- a/tests/src/reference.rs
+++ b/tests/src/reference.rs
@@ -65,7 +65,7 @@ fn reference_test(path: &str) {
.unwrap();
{
- let cr = cairo::Context::new(&surface);
+ let cr = cairo::Context::new(&surface).expect("Failed to create a cairo context");
cr.translate(f64::from(FRAME_SIZE), f64::from(FRAME_SIZE));
renderer
.render_document(
@@ -107,7 +107,7 @@ fn extract_rectangle(
h: i32,
) -> Result<cairo::ImageSurface, cairo::Error> {
let dest = cairo::ImageSurface::create(cairo::Format::ARgb32, w, h)?;
- let cr = cairo::Context::new(&dest);
+ let cr = cairo::Context::new(&dest).expect("Failed to create a cairo context");
cr.set_source_surface(&source, f64::from(-x), f64::from(-y));
cr.paint();
Ok(dest)
diff --git a/tests/src/reference_utils.rs b/tests/src/reference_utils.rs
index 77b5adb9..c2650887 100644
--- a/tests/src/reference_utils.rs
+++ b/tests/src/reference_utils.rs
@@ -173,11 +173,10 @@ where
R: Read,
{
let png = cairo::ImageSurface::create_from_png(stream)?;
- let argb =
- cairo::ImageSurface::create(cairo::Format::ARgb32, png.get_width(), png.get_height())?;
+ let argb = cairo::ImageSurface::create(cairo::Format::ARgb32, png.width(), png.height())?;
{
// convert to ARGB; the PNG may come as Rgb24
- let cr = cairo::Context::new(&argb);
+ let cr = cairo::Context::new(&argb).expect("Failed to create a cairo context");
cr.set_source_surface(&png, 0.0, 0.0);
cr.paint();
}
diff --git a/tests/src/render_crash.rs b/tests/src/render_crash.rs
index d0c8b42f..ce8dfc72 100644
--- a/tests/src/render_crash.rs
+++ b/tests/src/render_crash.rs
@@ -16,7 +16,7 @@ fn loading_crash(path: &str) {
.unwrap_or_else(|e| panic!("could not load: {}", e));
let surface = cairo::ImageSurface::create(cairo::Format::ARgb32, 100, 100).unwrap();
- let cr = cairo::Context::new(&surface);
+ let cr = cairo::Context::new(&surface).expect("Failed to create a cairo context");
// We just test for crashes during rendering, and don't care about success/error.
let _ = CairoRenderer::new(&handle).render_document(
diff --git a/tests/src/utils.rs b/tests/src/utils.rs
index 180062a7..895b4ee3 100644
--- a/tests/src/utils.rs
+++ b/tests/src/utils.rs
@@ -38,7 +38,7 @@ pub fn render_document<F: FnOnce(&cairo::Context)>(
let output = cairo::ImageSurface::create(cairo::Format::ARgb32, width, height).unwrap();
let res = {
- let cr = cairo::Context::new(&output);
+ let cr = cairo::Context::new(&output).expect("Failed to create a cairo context");
cr_transform(&cr);
Ok(renderer.render_document(&cr, &viewport)?)
};
@@ -81,7 +81,7 @@ mod pango_ft2 {
}
}
- let font_map = FontMap::new_for_font_type(cairo::FontType::FontTypeFt).unwrap();
+ let font_map = FontMap::for_font_type(cairo::FontType::FontTypeFt).unwrap();
let raw_font_map: *mut pango::ffi::PangoFontMap = font_map.to_glib_none().0;
pango_fc_font_map_set_config(raw_font_map as *mut _, config);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]