2018-02-22 08:36:54 +08:00
|
|
|
#include <stdlib.h>
|
2018-03-18 11:29:31 +08:00
|
|
|
#include "gtest/gtest.h"
|
|
|
|
#include "base/image_manager.h"
|
2018-02-21 19:36:38 +08:00
|
|
|
|
|
|
|
TEST(ImageManager, basic) {
|
2018-03-18 11:29:31 +08:00
|
|
|
bitmap_t bmp;
|
2018-04-27 11:23:09 +08:00
|
|
|
ASSERT_EQ(image_manager_load(image_manager(), "checked", &bmp), RET_OK);
|
2018-04-28 15:09:07 +08:00
|
|
|
ASSERT_EQ(image_manager_lookup(image_manager(), "checked", &bmp), RET_OK);
|
2018-04-27 11:23:09 +08:00
|
|
|
ASSERT_EQ(image_manager_load(image_manager(), "not found", &bmp), RET_NOT_FOUND);
|
2018-04-28 15:09:07 +08:00
|
|
|
ASSERT_EQ(image_manager_lookup(image_manager(), "unchecked", &bmp), RET_NOT_FOUND);
|
|
|
|
|
|
|
|
ASSERT_EQ(image_manager_unload_unused(image_manager(), 0), RET_OK);
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST(ImageManager, unload) {
|
|
|
|
bitmap_t bmp;
|
|
|
|
|
|
|
|
ASSERT_EQ(image_manager_load(image_manager(), "checked", &bmp), RET_OK);
|
|
|
|
ASSERT_EQ(image_manager_lookup(image_manager(), "checked", &bmp), RET_OK);
|
|
|
|
ASSERT_EQ(image_manager_unload_unused(image_manager(), 0), RET_OK);
|
|
|
|
ASSERT_EQ(image_manager_lookup(image_manager(), "checked", &bmp), RET_NOT_FOUND);
|
|
|
|
|
|
|
|
ASSERT_EQ(image_manager_unload_unused(image_manager(), 0), RET_OK);
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST(ImageManager, add) {
|
|
|
|
bitmap_t bmp;
|
|
|
|
bmp.w = 10;
|
|
|
|
bmp.h = 10;
|
|
|
|
bmp.data = NULL;
|
|
|
|
bmp.destroy = NULL;
|
|
|
|
|
|
|
|
ASSERT_EQ(image_manager_add(image_manager(), "checked", &bmp), RET_OK);
|
|
|
|
ASSERT_EQ(image_manager_lookup(image_manager(), "checked", &bmp), RET_OK);
|
|
|
|
ASSERT_EQ(image_manager_unload_unused(image_manager(), 0), RET_OK);
|
2018-02-21 19:36:38 +08:00
|
|
|
}
|