[librsvg] Move test in the correct place.
- From: Paolo Borelli <pborelli src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg] Move test in the correct place.
- Date: Fri, 27 Dec 2019 18:57:42 +0000 (UTC)
commit 528a84f99f1f555bb74f8335fba1f41a8dffe404
Author: Paolo Borelli <pborelli gnome org>
Date: Fri Dec 27 19:38:23 2019 +0100
Move test in the correct place.
This code was moved to the surface utils, move the test as well.
rsvg_internals/src/filters/context.rs | 46 ----------------------
rsvg_internals/src/surface_utils/shared_surface.rs | 46 ++++++++++++++++++++++
2 files changed, 46 insertions(+), 46 deletions(-)
---
diff --git a/rsvg_internals/src/filters/context.rs b/rsvg_internals/src/filters/context.rs
index 50c14ea2..f3a0324a 100644
--- a/rsvg_internals/src/filters/context.rs
+++ b/rsvg_internals/src/filters/context.rs
@@ -456,49 +456,3 @@ impl FilterInput {
}
}
}
-
-#[cfg(test)]
-mod tests {
- use super::*;
- use crate::surface_utils::iterators::Pixels;
-
- #[test]
- fn test_extract_alpha() {
- const WIDTH: i32 = 32;
- const HEIGHT: i32 = 64;
-
- let bounds = IRect::new(8, 24, 16, 48);
- let full_bounds = IRect::from_size(WIDTH, HEIGHT);
-
- let mut surface =
- cairo::ImageSurface::create(cairo::Format::ARgb32, WIDTH, HEIGHT).unwrap();
-
- // Fill the surface with some data.
- {
- let mut data = surface.get_data().unwrap();
-
- let mut counter = 0u16;
- for x in data.iter_mut() {
- *x = counter as u8;
- counter = (counter + 1) % 256;
- }
- }
-
- let surface = SharedImageSurface::new(surface, SurfaceType::SRgb).unwrap();
- let alpha = surface.extract_alpha(bounds).unwrap();
-
- for (x, y, p, pa) in
- Pixels::new(&surface, full_bounds).map(|(x, y, p)| (x, y, p, alpha.get_pixel(x, y)))
- {
- assert_eq!(pa.r, 0);
- assert_eq!(pa.g, 0);
- assert_eq!(pa.b, 0);
-
- if !bounds.contains(x as i32, y as i32) {
- assert_eq!(pa.a, 0);
- } else {
- assert_eq!(pa.a, p.a);
- }
- }
- }
-}
diff --git a/rsvg_internals/src/surface_utils/shared_surface.rs
b/rsvg_internals/src/surface_utils/shared_surface.rs
index 6ba6f421..53a5b040 100644
--- a/rsvg_internals/src/surface_utils/shared_surface.rs
+++ b/rsvg_internals/src/surface_utils/shared_surface.rs
@@ -895,3 +895,49 @@ impl SharedImageSurface {
self.surface.to_glib_none()
}
}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+ use crate::surface_utils::iterators::Pixels;
+
+ #[test]
+ fn test_extract_alpha() {
+ const WIDTH: i32 = 32;
+ const HEIGHT: i32 = 64;
+
+ let bounds = IRect::new(8, 24, 16, 48);
+ let full_bounds = IRect::from_size(WIDTH, HEIGHT);
+
+ let mut surface =
+ cairo::ImageSurface::create(cairo::Format::ARgb32, WIDTH, HEIGHT).unwrap();
+
+ // Fill the surface with some data.
+ {
+ let mut data = surface.get_data().unwrap();
+
+ let mut counter = 0u16;
+ for x in data.iter_mut() {
+ *x = counter as u8;
+ counter = (counter + 1) % 256;
+ }
+ }
+
+ let surface = SharedImageSurface::new(surface, SurfaceType::SRgb).unwrap();
+ let alpha = surface.extract_alpha(bounds).unwrap();
+
+ for (x, y, p, pa) in
+ Pixels::new(&surface, full_bounds).map(|(x, y, p)| (x, y, p, alpha.get_pixel(x, y)))
+ {
+ assert_eq!(pa.r, 0);
+ assert_eq!(pa.g, 0);
+ assert_eq!(pa.b, 0);
+
+ if !bounds.contains(x as i32, y as i32) {
+ assert_eq!(pa.a, 0);
+ } else {
+ assert_eq!(pa.a, p.a);
+ }
+ }
+ }
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]