1 |
commit: d2cd6dbc4a29dbb6c239c47d38cf161b3a603f83 |
2 |
Author: Jakov Smolic <jakov.smolic <AT> sartura <DOT> hr> |
3 |
AuthorDate: Sat Aug 15 09:17:06 2020 +0000 |
4 |
Commit: Sam James <sam <AT> gentoo <DOT> org> |
5 |
CommitDate: Sun Aug 16 07:19:38 2020 +0000 |
6 |
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=d2cd6dbc |
7 |
|
8 |
media-libs/libheif: run tests on <1.7.0 |
9 |
|
10 |
Package-Manager: Portage-2.3.99, Repoman-2.3.23 |
11 |
Signed-off-by: Jakov Smolic <jakov.smolic <AT> sartura.hr> |
12 |
Closes: https://github.com/gentoo/gentoo/pull/17122/commits/d17ef92b2d7cb5e5b36f64f3e383da6820a3d5c0 |
13 |
Signed-off-by: Sam James <sam <AT> gentoo.org> |
14 |
|
15 |
media-libs/libheif/files/heif_test.go | 155 ++++++++++++++++++++++++++++++++ |
16 |
media-libs/libheif/libheif-1.5.1.ebuild | 13 ++- |
17 |
media-libs/libheif/libheif-1.6.1.ebuild | 12 ++- |
18 |
media-libs/libheif/libheif-1.6.2.ebuild | 12 ++- |
19 |
4 files changed, 188 insertions(+), 4 deletions(-) |
20 |
|
21 |
diff --git a/media-libs/libheif/files/heif_test.go b/media-libs/libheif/files/heif_test.go |
22 |
new file mode 100644 |
23 |
index 00000000000..187d773dea6 |
24 |
--- /dev/null |
25 |
+++ b/media-libs/libheif/files/heif_test.go |
26 |
@@ -0,0 +1,155 @@ |
27 |
+/* |
28 |
+ * GO interface to libheif |
29 |
+ * Copyright (c) 2018 struktur AG, Joachim Bauch <bauch@××××××××.de> |
30 |
+ * |
31 |
+ * This file is part of heif, an example application using libheif. |
32 |
+ * |
33 |
+ * heif is free software: you can redistribute it and/or modify |
34 |
+ * it under the terms of the GNU General Public License as published by |
35 |
+ * the Free Software Foundation, either version 3 of the License, or |
36 |
+ * (at your option) any later version. |
37 |
+ * |
38 |
+ * heif is distributed in the hope that it will be useful, |
39 |
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of |
40 |
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
41 |
+ * GNU General Public License for more details. |
42 |
+ * |
43 |
+ * You should have received a copy of the GNU General Public License |
44 |
+ * along with heif. If not, see <http://www.gnu.org/licenses/>. |
45 |
+ */ |
46 |
+ |
47 |
+package heif |
48 |
+ |
49 |
+import ( |
50 |
+ "fmt" |
51 |
+ "image" |
52 |
+ "io/ioutil" |
53 |
+ "os" |
54 |
+ "path" |
55 |
+ "testing" |
56 |
+) |
57 |
+ |
58 |
+func TestGetVersion(t *testing.T) { |
59 |
+ version := GetVersion() |
60 |
+ if version == "" { |
61 |
+ t.Fatal("Version is missing") |
62 |
+ } |
63 |
+} |
64 |
+ |
65 |
+func CheckHeifImage(t *testing.T, handle *ImageHandle, thumbnail bool) { |
66 |
+ handle.GetWidth() |
67 |
+ handle.GetHeight() |
68 |
+ handle.HasAlphaChannel() |
69 |
+ handle.HasDepthImage() |
70 |
+ count := handle.GetNumberOfDepthImages() |
71 |
+ if ids := handle.GetListOfDepthImageIDs(); len(ids) != count { |
72 |
+ t.Errorf("Expected %d depth image ids, got %d", count, len(ids)) |
73 |
+ } |
74 |
+ if !thumbnail { |
75 |
+ count = handle.GetNumberOfThumbnails() |
76 |
+ ids := handle.GetListOfThumbnailIDs() |
77 |
+ if len(ids) != count { |
78 |
+ t.Errorf("Expected %d thumbnail image ids, got %d", count, len(ids)) |
79 |
+ } |
80 |
+ for _, id := range ids { |
81 |
+ if thumb, err := handle.GetThumbnail(id); err != nil { |
82 |
+ t.Errorf("Could not get thumbnail %d: %s", id, err) |
83 |
+ } else { |
84 |
+ CheckHeifImage(t, thumb, true) |
85 |
+ } |
86 |
+ } |
87 |
+ } |
88 |
+ |
89 |
+ if img, err := handle.DecodeImage(ColorspaceUndefined, ChromaUndefined, nil); err != nil { |
90 |
+ t.Errorf("Could not decode image: %s", err) |
91 |
+ } else { |
92 |
+ img.GetColorspace() |
93 |
+ img.GetChromaFormat() |
94 |
+ } |
95 |
+} |
96 |
+ |
97 |
+func CheckHeifFile(t *testing.T, ctx *Context) { |
98 |
+ if count := ctx.GetNumberOfTopLevelImages(); count != 2 { |
99 |
+ t.Errorf("Expected %d top level images, got %d", 2, count) |
100 |
+ } |
101 |
+ if ids := ctx.GetListOfTopLevelImageIDs(); len(ids) != 2 { |
102 |
+ t.Errorf("Expected %d top level image ids, got %+v", 2, ids) |
103 |
+ } |
104 |
+ if _, err := ctx.GetPrimaryImageID(); err != nil { |
105 |
+ t.Errorf("Expected a primary image, got %s", err) |
106 |
+ } |
107 |
+ if handle, err := ctx.GetPrimaryImageHandle(); err != nil { |
108 |
+ t.Errorf("Could not get primary image handle: %s", err) |
109 |
+ } else { |
110 |
+ if !handle.IsPrimaryImage() { |
111 |
+ t.Error("Expected primary image") |
112 |
+ } |
113 |
+ CheckHeifImage(t, handle, false) |
114 |
+ } |
115 |
+} |
116 |
+ |
117 |
+func TestReadFromFile(t *testing.T) { |
118 |
+ ctx, err := NewContext() |
119 |
+ if err != nil { |
120 |
+ t.Fatalf("Can't create context: %s", err) |
121 |
+ } |
122 |
+ |
123 |
+ filename := path.Join("..", "..", "examples", "example.heic") |
124 |
+ if err := ctx.ReadFromFile(filename); err != nil { |
125 |
+ t.Fatalf("Can't read from %s: %s", filename, err) |
126 |
+ } |
127 |
+ |
128 |
+ CheckHeifFile(t, ctx) |
129 |
+} |
130 |
+ |
131 |
+func TestReadFromMemory(t *testing.T) { |
132 |
+ ctx, err := NewContext() |
133 |
+ if err != nil { |
134 |
+ t.Fatalf("Can't create context: %s", err) |
135 |
+ } |
136 |
+ |
137 |
+ filename := path.Join("..", "..", "examples", "example.heic") |
138 |
+ data, err := ioutil.ReadFile(filename) |
139 |
+ if err != nil { |
140 |
+ t.Fatalf("Can't read file %s: %s", filename, err) |
141 |
+ } |
142 |
+ if err := ctx.ReadFromMemory(data); err != nil { |
143 |
+ t.Fatalf("Can't read from memory: %s", err) |
144 |
+ } |
145 |
+ data = nil // Make sure future processing works if "data" is GC'd |
146 |
+ |
147 |
+ CheckHeifFile(t, ctx) |
148 |
+} |
149 |
+ |
150 |
+func TestReadImage(t *testing.T) { |
151 |
+ filename := path.Join("..", "..", "examples", "example.heic") |
152 |
+ fp, err := os.Open(filename) |
153 |
+ if err != nil { |
154 |
+ t.Fatalf("Could not open %s: %s", filename, err) |
155 |
+ } |
156 |
+ defer fp.Close() |
157 |
+ |
158 |
+ config, format1, err := image.DecodeConfig(fp) |
159 |
+ if err != nil { |
160 |
+ t.Fatalf("Could not load image config from %s: %s", filename, err) |
161 |
+ } |
162 |
+ if format1 != "heif" { |
163 |
+ t.Errorf("Expected format heif, got %s", format1) |
164 |
+ } |
165 |
+ if _, err := fp.Seek(0, 0); err != nil { |
166 |
+ t.Fatalf("Could not seek to start of %s: %s", filename, err) |
167 |
+ } |
168 |
+ |
169 |
+ img, format2, err := image.Decode(fp) |
170 |
+ if err != nil { |
171 |
+ t.Fatalf("Could not load image from %s: %s", filename, err) |
172 |
+ } |
173 |
+ if format2 != "heif" { |
174 |
+ t.Errorf("Expected format heif, got %s", format2) |
175 |
+ } |
176 |
+ |
177 |
+ r := img.Bounds() |
178 |
+ if config.Width != (r.Max.X-r.Min.X) || config.Height != (r.Max.Y-r.Min.Y) { |
179 |
+ fmt.Printf("Image size %+v does not match config %+v\n", r, config) |
180 |
+ } |
181 |
+} |
182 |
|
183 |
diff --git a/media-libs/libheif/libheif-1.5.1.ebuild b/media-libs/libheif/libheif-1.5.1.ebuild |
184 |
index e737b4ce1e4..ea2fa1ddafb 100644 |
185 |
--- a/media-libs/libheif/libheif-1.5.1.ebuild |
186 |
+++ b/media-libs/libheif/libheif-1.5.1.ebuild |
187 |
@@ -1,7 +1,7 @@ |
188 |
-# Copyright 1999-2019 Gentoo Authors |
189 |
+# Copyright 1999-2020 Gentoo Authors |
190 |
# Distributed under the terms of the GNU General Public License v2 |
191 |
|
192 |
-EAPI="7" |
193 |
+EAPI=7 |
194 |
|
195 |
inherit autotools xdg-utils multilib-minimal |
196 |
|
197 |
@@ -34,6 +34,10 @@ RDEPEND="${DEPEND}" |
198 |
src_prepare() { |
199 |
default |
200 |
|
201 |
+ # heif_test.go is not included in the tarball |
202 |
+ # https://github.com/strukturag/libheif/issues/289 |
203 |
+ cp "${FILESDIR}/heif_test.go" "${S}/go/heif" || die |
204 |
+ |
205 |
sed -i -e 's:-Werror::' \ |
206 |
configure.ac || die |
207 |
|
208 |
@@ -51,6 +55,11 @@ multilib_src_configure() { |
209 |
ECONF_SOURCE="${S}" econf "${myeconfargs[@]}" |
210 |
} |
211 |
|
212 |
+multilib_src_test() { |
213 |
+ default |
214 |
+ emake -C go test |
215 |
+} |
216 |
+ |
217 |
multilib_src_install_all() { |
218 |
find "${ED}" -name '*.la' -delete || die |
219 |
if ! use static-libs ; then |
220 |
|
221 |
diff --git a/media-libs/libheif/libheif-1.6.1.ebuild b/media-libs/libheif/libheif-1.6.1.ebuild |
222 |
index 07885456ea4..68966c34be8 100644 |
223 |
--- a/media-libs/libheif/libheif-1.6.1.ebuild |
224 |
+++ b/media-libs/libheif/libheif-1.6.1.ebuild |
225 |
@@ -1,7 +1,7 @@ |
226 |
# Copyright 1999-2020 Gentoo Authors |
227 |
# Distributed under the terms of the GNU General Public License v2 |
228 |
|
229 |
-EAPI="7" |
230 |
+EAPI=7 |
231 |
|
232 |
inherit autotools xdg-utils multilib-minimal |
233 |
|
234 |
@@ -19,6 +19,7 @@ HOMEPAGE="https://github.com/strukturag/libheif" |
235 |
LICENSE="GPL-3" |
236 |
SLOT="0/1.6" |
237 |
IUSE="static-libs test +threads" |
238 |
+ |
239 |
RESTRICT="!test? ( test )" |
240 |
|
241 |
BDEPEND="test? ( dev-lang/go )" |
242 |
@@ -34,6 +35,10 @@ RDEPEND="${DEPEND}" |
243 |
src_prepare() { |
244 |
default |
245 |
|
246 |
+ # heif_test.go is not included in the tarball |
247 |
+ # https://github.com/strukturag/libheif/issues/289 |
248 |
+ cp "${FILESDIR}/heif_test.go" "${S}/go/heif" || die |
249 |
+ |
250 |
sed -i -e 's:-Werror::' configure.ac || die |
251 |
|
252 |
eautoreconf |
253 |
@@ -50,6 +55,11 @@ multilib_src_configure() { |
254 |
ECONF_SOURCE="${S}" econf "${myeconfargs[@]}" |
255 |
} |
256 |
|
257 |
+multilib_src_test() { |
258 |
+ default |
259 |
+ emake -C go test |
260 |
+} |
261 |
+ |
262 |
multilib_src_install_all() { |
263 |
find "${ED}" -name '*.la' -delete || die |
264 |
if ! use static-libs ; then |
265 |
|
266 |
diff --git a/media-libs/libheif/libheif-1.6.2.ebuild b/media-libs/libheif/libheif-1.6.2.ebuild |
267 |
index f82ec6214c6..3644fcb74e4 100644 |
268 |
--- a/media-libs/libheif/libheif-1.6.2.ebuild |
269 |
+++ b/media-libs/libheif/libheif-1.6.2.ebuild |
270 |
@@ -1,7 +1,7 @@ |
271 |
# Copyright 1999-2020 Gentoo Authors |
272 |
# Distributed under the terms of the GNU General Public License v2 |
273 |
|
274 |
-EAPI="7" |
275 |
+EAPI=7 |
276 |
|
277 |
inherit autotools xdg-utils multilib-minimal |
278 |
|
279 |
@@ -19,6 +19,7 @@ HOMEPAGE="https://github.com/strukturag/libheif" |
280 |
LICENSE="GPL-3" |
281 |
SLOT="0/1.6" |
282 |
IUSE="static-libs test +threads" |
283 |
+ |
284 |
RESTRICT="!test? ( test )" |
285 |
|
286 |
BDEPEND="test? ( dev-lang/go )" |
287 |
@@ -34,6 +35,10 @@ RDEPEND="${DEPEND}" |
288 |
src_prepare() { |
289 |
default |
290 |
|
291 |
+ # heif_test.go is not included in the tarball |
292 |
+ # https://github.com/strukturag/libheif/issues/289 |
293 |
+ cp "${FILESDIR}/heif_test.go" "${S}/go/heif" || die |
294 |
+ |
295 |
sed -i -e 's:-Werror::' configure.ac || die |
296 |
|
297 |
eautoreconf |
298 |
@@ -50,6 +55,11 @@ multilib_src_configure() { |
299 |
ECONF_SOURCE="${S}" econf "${myeconfargs[@]}" |
300 |
} |
301 |
|
302 |
+multilib_src_test() { |
303 |
+ default |
304 |
+ emake -C go test |
305 |
+} |
306 |
+ |
307 |
multilib_src_install_all() { |
308 |
find "${ED}" -name '*.la' -delete || die |
309 |
if ! use static-libs ; then |