瀏覽代碼

Add unit tests for efficient dirty rectangle merging.

tags/v0.99.beta17
Sam Hocevar sam 15 年之前
父節點
當前提交
33fd017a70
共有 1 個檔案被更改,包括 37 行新增0 行删除
  1. +37
    -0
      tests/dirty.cpp

+ 37
- 0
tests/dirty.cpp 查看文件

@@ -27,6 +27,7 @@ class DirtyTest : public CppUnit::TestCase
CPPUNIT_TEST(test_create);
CPPUNIT_TEST(test_put_char_dirty);
CPPUNIT_TEST(test_put_char_not_dirty);
CPPUNIT_TEST(test_simplify);
CPPUNIT_TEST(test_box);
CPPUNIT_TEST(test_blit);
CPPUNIT_TEST_SUITE_END();
@@ -172,6 +173,42 @@ public:
CPPUNIT_ASSERT_EQUAL(0, caca_get_dirty_rect_count(cv));
}

void test_simplify()
{
caca_canvas_t *cv;
int dx, dy, dw, dh;

cv = caca_create_canvas(WIDTH, HEIGHT);

/* Check that N adjacent blits only create one dirty rectangle */
caca_clear_dirty_rect_list(cv);
for(int i = 0; i < 10; i++)
{
caca_put_char(cv, 7 + i, 3, '-');

CPPUNIT_ASSERT_EQUAL(1, caca_get_dirty_rect_count(cv));
caca_get_dirty_rect(cv, 0, &dx, &dy, &dw, &dh);
CPPUNIT_ASSERT_EQUAL(7, dx);
CPPUNIT_ASSERT_EQUAL(3, dy);
CPPUNIT_ASSERT_EQUAL(1 + i, dw);
CPPUNIT_ASSERT_EQUAL(1, dh);
}

/* Check that N adjacent blits only create one dirty rectangle */
caca_clear_dirty_rect_list(cv);
for(int j = 0; j < 10; j++)
{
caca_put_char(cv, 7, 3 + j, '|');

CPPUNIT_ASSERT_EQUAL(1, caca_get_dirty_rect_count(cv));
caca_get_dirty_rect(cv, 0, &dx, &dy, &dw, &dh);
CPPUNIT_ASSERT_EQUAL(7, dx);
CPPUNIT_ASSERT_EQUAL(3, dy);
CPPUNIT_ASSERT_EQUAL(1, dw);
CPPUNIT_ASSERT_EQUAL(1 + j, dh);
}
}

void test_box()
{
caca_canvas_t *cv;


Loading…
取消
儲存