comparison tests/core_tests/test_imagepool.cpp @ 156:376b8afc9a18

Fixed a horrendous misconeception in the pool. The map was sorted by pointer comparison. Needs a bit cleanup, though.
author phoku@33b003aa-7bff-0310-803a-e67f0ece8222
date Sun, 12 Oct 2008 20:30:09 +0000
parents 72c25cc27d8b
children 64738befdf3b
comparison
equal deleted inserted replaced
155:29309cd5e240 156:376b8afc9a18
81 pool.addResourceLoader(new ImageLoader(vfs.get())); 81 pool.addResourceLoader(new ImageLoader(vfs.get()));
82 82
83 CHECK_EQUAL(0, pool.getResourceCount(RES_LOADED)); 83 CHECK_EQUAL(0, pool.getResourceCount(RES_LOADED));
84 CHECK_EQUAL(0, pool.getResourceCount(RES_NON_LOADED)); 84 CHECK_EQUAL(0, pool.getResourceCount(RES_NON_LOADED));
85 85
86 pool.addResourceFromLocation(ImageLocation(IMAGE_FILE)); 86 ImageLocation location(IMAGE_FILE);
87 pool.addResourceFromLocation(&location);
87 CHECK_EQUAL(0, pool.getResourceCount(RES_LOADED)); 88 CHECK_EQUAL(0, pool.getResourceCount(RES_LOADED));
88 CHECK_EQUAL(1, pool.getResourceCount(RES_NON_LOADED)); 89 CHECK_EQUAL(1, pool.getResourceCount(RES_NON_LOADED));
89 ImageLocation location(SUBIMAGE_FILE); 90
91 location = ImageLocation(SUBIMAGE_FILE);
90 ImageLoader imgprovider(vfs.get()); 92 ImageLoader imgprovider(vfs.get());
91 int fullImgInd = pool.addResourceFromLocation(ImageLocation(SUBIMAGE_FILE)); 93 int fullImgInd = pool.addResourceFromLocation(&location);
92 CHECK_EQUAL(0, pool.getResourceCount(RES_LOADED)); 94 CHECK_EQUAL(0, pool.getResourceCount(RES_LOADED));
93 CHECK_EQUAL(2, pool.getResourceCount(RES_NON_LOADED)); 95 CHECK_EQUAL(2, pool.getResourceCount(RES_NON_LOADED));
94 Image& img = pool.getImage(fullImgInd); 96 Image& img = pool.getImage(fullImgInd);
95 CHECK_EQUAL(1, pool.getResourceCount(RES_LOADED)); 97 CHECK_EQUAL(1, pool.getResourceCount(RES_LOADED));
96 CHECK_EQUAL(1, pool.getResourceCount(RES_NON_LOADED)); 98 CHECK_EQUAL(1, pool.getResourceCount(RES_NON_LOADED));
100 int w = W / 12; 102 int w = W / 12;
101 int H = img.getHeight(); 103 int H = img.getHeight();
102 int h = H / 12; 104 int h = H / 12;
103 location.setWidth(w); 105 location.setWidth(w);
104 location.setHeight(h); 106 location.setHeight(h);
105 pool.addResourceFromLocation(location); 107 CHECK(w != 0 && h !=0);
108
109 int subImgInd = pool.addResourceFromLocation(&location);
110 CHECK(fullImgInd != subImgInd);
106 111
107 CHECK_EQUAL(1, pool.getResourceCount(RES_LOADED)); 112 CHECK_EQUAL(1, pool.getResourceCount(RES_LOADED));
108 CHECK_EQUAL(2, pool.getResourceCount(RES_NON_LOADED)); 113 CHECK_EQUAL(2, pool.getResourceCount(RES_NON_LOADED));
109 114
110 for (int k = 0; k < 3; k++) { 115 for (int k = 0; k < 3; k++) {