Add test for deleting images after they scroll off
This commit is contained in:
parent
240c9b5d8b
commit
259e01e879
@ -16,6 +16,7 @@
|
||||
|
||||
#include <zlib.h>
|
||||
#include <png.h>
|
||||
#include <structmember.h>
|
||||
|
||||
#define REPORT_ERROR(...) { fprintf(stderr, __VA_ARGS__); fprintf(stderr, "\n"); }
|
||||
|
||||
@ -629,9 +630,9 @@ grman_scroll_images(GraphicsManager *self, int32_t amt, int32_t limit) {
|
||||
size_t i, j;
|
||||
|
||||
if (self->image_count) {
|
||||
for (i = self->image_count; i-- > 0; i--) {
|
||||
for (i = self->image_count; i-- > 0;) {
|
||||
img = self->images + i;
|
||||
for (j = img->refcnt; j-- > 0; j--) {
|
||||
for (j = img->refcnt; j-- > 0;) {
|
||||
ref = img->refs + j;
|
||||
ref->start_row += amt;
|
||||
if (ref->start_row + (int32_t)ref->effective_num_rows < limit) {
|
||||
@ -768,6 +769,10 @@ static PyMethodDef methods[] = {
|
||||
{NULL} /* Sentinel */
|
||||
};
|
||||
|
||||
static PyMemberDef members[] = {
|
||||
{"image_count", T_UINT, offsetof(GraphicsManager, image_count), 0, "image_count"},
|
||||
{NULL},
|
||||
};
|
||||
|
||||
PyTypeObject GraphicsManager_Type = {
|
||||
PyVarObject_HEAD_INIT(NULL, 0)
|
||||
@ -778,6 +783,7 @@ PyTypeObject GraphicsManager_Type = {
|
||||
.tp_doc = "GraphicsManager",
|
||||
.tp_new = new,
|
||||
.tp_methods = methods,
|
||||
.tp_members = members,
|
||||
};
|
||||
|
||||
static PyMethodDef module_methods[] = {
|
||||
|
||||
@ -208,3 +208,19 @@ class TestGraphics(BaseTest):
|
||||
rect_eq(l[1]['dest_rect'], -1, 1, -1 + dx, 1 - dy)
|
||||
self.ae(l[0]['group_count'], 1), self.ae(l[1]['group_count'], 1)
|
||||
self.ae(s.cursor.x, 0), self.ae(s.cursor.y, 1)
|
||||
|
||||
def test_gr_scroll(self):
|
||||
cw, ch = 10, 20
|
||||
s, dx, dy, put_image, put_ref, layers, rect_eq = put_helpers(self, cw, ch)
|
||||
put_image(s, 10, 20) # a one cell image at (0, 0)
|
||||
self.ae(len(layers(s)), 1)
|
||||
for i in range(s.lines):
|
||||
s.index()
|
||||
self.ae(len(layers(s)), 1), self.ae(s.grman.image_count, 1)
|
||||
s.index()
|
||||
self.ae(len(layers(s)), 0), self.ae(s.grman.image_count, 1)
|
||||
for i in range(s.historybuf.ynum - 1):
|
||||
s.index()
|
||||
self.ae(s.grman.image_count, 1)
|
||||
s.index()
|
||||
self.ae(s.grman.image_count, 0)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user