Gentoo Archives: gentoo-commits

From: Joonas Niilola <juippis@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: media-libs/libheif/files/
Date: Wed, 28 Oct 2020 12:10:10
Message-Id: 1603886997.f7c8575f3eb43887c8081061661c0767d637c155.juippis@gentoo
1 commit: f7c8575f3eb43887c8081061661c0767d637c155
2 Author: Jakov Smolic <jakov.smolic <AT> sartura <DOT> hr>
3 AuthorDate: Thu Oct 22 10:11:57 2020 +0000
4 Commit: Joonas Niilola <juippis <AT> gentoo <DOT> org>
5 CommitDate: Wed Oct 28 12:09:57 2020 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=f7c8575f
7
8 media-libs/libheif: ebuild_unused_patches
9
10 - Remove unused patch
11
12 Package-Manager: Portage-3.0.8, Repoman-3.0.1
13 Signed-off-by: Jakov Smolic <jakov.smolic <AT> sartura.hr>
14 Signed-off-by: Joonas Niilola <juippis <AT> gentoo.org>
15
16 media-libs/libheif/files/heif_test.go | 155 ----------------------------------
17 1 file changed, 155 deletions(-)
18
19 diff --git a/media-libs/libheif/files/heif_test.go b/media-libs/libheif/files/heif_test.go
20 deleted file mode 100644
21 index 187d773dea6..00000000000
22 --- a/media-libs/libheif/files/heif_test.go
23 +++ /dev/null
24 @@ -1,155 +0,0 @@
25 -/*
26 - * GO interface to libheif
27 - * Copyright (c) 2018 struktur AG, Joachim Bauch <bauch@××××××××.de>
28 - *
29 - * This file is part of heif, an example application using libheif.
30 - *
31 - * heif is free software: you can redistribute it and/or modify
32 - * it under the terms of the GNU General Public License as published by
33 - * the Free Software Foundation, either version 3 of the License, or
34 - * (at your option) any later version.
35 - *
36 - * heif is distributed in the hope that it will be useful,
37 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
38 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
39 - * GNU General Public License for more details.
40 - *
41 - * You should have received a copy of the GNU General Public License
42 - * along with heif. If not, see <http://www.gnu.org/licenses/>.
43 - */
44 -
45 -package heif
46 -
47 -import (
48 - "fmt"
49 - "image"
50 - "io/ioutil"
51 - "os"
52 - "path"
53 - "testing"
54 -)
55 -
56 -func TestGetVersion(t *testing.T) {
57 - version := GetVersion()
58 - if version == "" {
59 - t.Fatal("Version is missing")
60 - }
61 -}
62 -
63 -func CheckHeifImage(t *testing.T, handle *ImageHandle, thumbnail bool) {
64 - handle.GetWidth()
65 - handle.GetHeight()
66 - handle.HasAlphaChannel()
67 - handle.HasDepthImage()
68 - count := handle.GetNumberOfDepthImages()
69 - if ids := handle.GetListOfDepthImageIDs(); len(ids) != count {
70 - t.Errorf("Expected %d depth image ids, got %d", count, len(ids))
71 - }
72 - if !thumbnail {
73 - count = handle.GetNumberOfThumbnails()
74 - ids := handle.GetListOfThumbnailIDs()
75 - if len(ids) != count {
76 - t.Errorf("Expected %d thumbnail image ids, got %d", count, len(ids))
77 - }
78 - for _, id := range ids {
79 - if thumb, err := handle.GetThumbnail(id); err != nil {
80 - t.Errorf("Could not get thumbnail %d: %s", id, err)
81 - } else {
82 - CheckHeifImage(t, thumb, true)
83 - }
84 - }
85 - }
86 -
87 - if img, err := handle.DecodeImage(ColorspaceUndefined, ChromaUndefined, nil); err != nil {
88 - t.Errorf("Could not decode image: %s", err)
89 - } else {
90 - img.GetColorspace()
91 - img.GetChromaFormat()
92 - }
93 -}
94 -
95 -func CheckHeifFile(t *testing.T, ctx *Context) {
96 - if count := ctx.GetNumberOfTopLevelImages(); count != 2 {
97 - t.Errorf("Expected %d top level images, got %d", 2, count)
98 - }
99 - if ids := ctx.GetListOfTopLevelImageIDs(); len(ids) != 2 {
100 - t.Errorf("Expected %d top level image ids, got %+v", 2, ids)
101 - }
102 - if _, err := ctx.GetPrimaryImageID(); err != nil {
103 - t.Errorf("Expected a primary image, got %s", err)
104 - }
105 - if handle, err := ctx.GetPrimaryImageHandle(); err != nil {
106 - t.Errorf("Could not get primary image handle: %s", err)
107 - } else {
108 - if !handle.IsPrimaryImage() {
109 - t.Error("Expected primary image")
110 - }
111 - CheckHeifImage(t, handle, false)
112 - }
113 -}
114 -
115 -func TestReadFromFile(t *testing.T) {
116 - ctx, err := NewContext()
117 - if err != nil {
118 - t.Fatalf("Can't create context: %s", err)
119 - }
120 -
121 - filename := path.Join("..", "..", "examples", "example.heic")
122 - if err := ctx.ReadFromFile(filename); err != nil {
123 - t.Fatalf("Can't read from %s: %s", filename, err)
124 - }
125 -
126 - CheckHeifFile(t, ctx)
127 -}
128 -
129 -func TestReadFromMemory(t *testing.T) {
130 - ctx, err := NewContext()
131 - if err != nil {
132 - t.Fatalf("Can't create context: %s", err)
133 - }
134 -
135 - filename := path.Join("..", "..", "examples", "example.heic")
136 - data, err := ioutil.ReadFile(filename)
137 - if err != nil {
138 - t.Fatalf("Can't read file %s: %s", filename, err)
139 - }
140 - if err := ctx.ReadFromMemory(data); err != nil {
141 - t.Fatalf("Can't read from memory: %s", err)
142 - }
143 - data = nil // Make sure future processing works if "data" is GC'd
144 -
145 - CheckHeifFile(t, ctx)
146 -}
147 -
148 -func TestReadImage(t *testing.T) {
149 - filename := path.Join("..", "..", "examples", "example.heic")
150 - fp, err := os.Open(filename)
151 - if err != nil {
152 - t.Fatalf("Could not open %s: %s", filename, err)
153 - }
154 - defer fp.Close()
155 -
156 - config, format1, err := image.DecodeConfig(fp)
157 - if err != nil {
158 - t.Fatalf("Could not load image config from %s: %s", filename, err)
159 - }
160 - if format1 != "heif" {
161 - t.Errorf("Expected format heif, got %s", format1)
162 - }
163 - if _, err := fp.Seek(0, 0); err != nil {
164 - t.Fatalf("Could not seek to start of %s: %s", filename, err)
165 - }
166 -
167 - img, format2, err := image.Decode(fp)
168 - if err != nil {
169 - t.Fatalf("Could not load image from %s: %s", filename, err)
170 - }
171 - if format2 != "heif" {
172 - t.Errorf("Expected format heif, got %s", format2)
173 - }
174 -
175 - r := img.Bounds()
176 - if config.Width != (r.Max.X-r.Min.X) || config.Height != (r.Max.Y-r.Min.Y) {
177 - fmt.Printf("Image size %+v does not match config %+v\n", r, config)
178 - }
179 -}