@@ -33,13 +33,13 @@ TEST(RenderedTargetTest, LoadAndUpdateProperties)
3333 stage.setInterface (&stageModel);
3434 target.setStageModel (&stageModel);
3535 Costume costume (" " , " " , " " );
36+ std::string costumeData = readFileStr (" image.png" );
37+ costume.setData (costumeData.size (), static_cast <void *>(costumeData.data ()));
3638 costume.setRotationCenterX (-23 );
3739 costume.setRotationCenterY (72 );
3840 EngineMock engine;
3941 target.loadCostume (&costume);
4042 target.setEngine (&engine);
41- target.setCostumeWidth (102.3 );
42- target.setCostumeHeight (80.7 );
4343
4444 target.setWidth (14.3 );
4545 target.setHeight (5.8 );
@@ -61,8 +61,8 @@ TEST(RenderedTargetTest, LoadAndUpdateProperties)
6161 ASSERT_EQ (target.transformOriginPoint (), QPointF (3.4 , 9.7 ));
6262
6363 target.updateProperties ();
64- ASSERT_EQ (target.width (), 102.3 );
65- ASSERT_EQ (target.height (), 80.7 );
64+ ASSERT_EQ (target.width (), 4 );
65+ ASSERT_EQ (target.height (), 6 );
6666 ASSERT_EQ (target.x (), 283.5 );
6767 ASSERT_EQ (target.y (), 88.5 );
6868 ASSERT_EQ (target.z (), 0 );
@@ -105,8 +105,8 @@ TEST(RenderedTargetTest, LoadAndUpdateProperties)
105105 ASSERT_EQ (target.transformOriginPoint (), QPointF (3.4 , 9.7 ));
106106
107107 target.updateProperties ();
108- ASSERT_EQ (target.width (), 102 .3 );
109- ASSERT_EQ (target.height (), 80.7 );
108+ ASSERT_EQ (target.width (), 14 .3 );
109+ ASSERT_EQ (target.height (), 5.8 );
110110 ASSERT_EQ (std::round (target.x () * 100 ) / 100 , 220.62 );
111111 ASSERT_EQ (std::round (target.y () * 100 ) / 100 , -49.09 );
112112 ASSERT_EQ (target.z (), 3 );
@@ -163,17 +163,19 @@ TEST(RenderedTargetTest, LoadJpegCostume)
163163 costume.setId (" abc" );
164164
165165 RenderedTarget target;
166- ASSERT_EQ (target.costumeWidth (), 0 );
167- ASSERT_EQ (target.costumeHeight (), 0 );
168166
169167 target.loadCostume (&costume);
170- ASSERT_EQ (target.costumeWidth (), 4 / 3.0 );
171- ASSERT_EQ (target.costumeHeight (), 2 );
168+ ASSERT_FALSE (target.bitmapBuffer ()->isOpen ());
169+ target.bitmapBuffer ()->open (QBuffer::ReadOnly);
170+ ASSERT_TRUE (target.bitmapBuffer ()->readAll ().toStdString ().empty ());
171+ ASSERT_TRUE (target.bitmapUniqueKey ().toStdString ().empty ());
172+ target.bitmapBuffer ()->close ();
173+
174+ target.updateProperties ();
172175 ASSERT_FALSE (target.bitmapBuffer ()->isOpen ());
173176 target.bitmapBuffer ()->open (QBuffer::ReadOnly);
174177 ASSERT_EQ (target.bitmapBuffer ()->readAll ().toStdString (), str);
175178 ASSERT_EQ (target.bitmapUniqueKey ().toStdString (), costume.id ());
176- ASSERT_EQ (target.svgBitmap (), nullptr );
177179}
178180
179181TEST (RenderedTargetTest, LoadPngCostume)
@@ -185,17 +187,19 @@ TEST(RenderedTargetTest, LoadPngCostume)
185187 costume.setId (" abc" );
186188
187189 RenderedTarget target;
188- ASSERT_EQ (target.costumeWidth (), 0 );
189- ASSERT_EQ (target.costumeHeight (), 0 );
190190
191191 target.loadCostume (&costume);
192- ASSERT_EQ (target.costumeWidth (), 4 / 3.0 );
193- ASSERT_EQ (target.costumeHeight (), 2 );
192+ ASSERT_FALSE (target.bitmapBuffer ()->isOpen ());
193+ target.bitmapBuffer ()->open (QBuffer::ReadOnly);
194+ ASSERT_TRUE (target.bitmapBuffer ()->readAll ().toStdString ().empty ());
195+ ASSERT_TRUE (target.bitmapUniqueKey ().toStdString ().empty ());
196+ target.bitmapBuffer ()->close ();
197+
198+ target.updateProperties ();
194199 ASSERT_FALSE (target.bitmapBuffer ()->isOpen ());
195200 target.bitmapBuffer ()->open (QBuffer::ReadOnly);
196201 ASSERT_EQ (target.bitmapBuffer ()->readAll ().toStdString (), str);
197202 ASSERT_EQ (target.bitmapUniqueKey ().toStdString (), costume.id ());
198- ASSERT_EQ (target.svgBitmap (), nullptr );
199203}
200204
201205TEST (RenderedTargetTest, Engine)
@@ -246,21 +250,3 @@ TEST(RenderedTargetTest, ScratchTarget)
246250 target.setSpriteModel (&spriteModel);
247251 ASSERT_EQ (target.scratchTarget (), &sprite);
248252}
249-
250- TEST (RenderedTargetTest, CostumeWidth)
251- {
252- RenderedTarget target;
253- ASSERT_EQ (target.costumeWidth (), 0 );
254-
255- target.setCostumeWidth (64.15 );
256- ASSERT_EQ (target.costumeWidth (), 64.15 );
257- }
258-
259- TEST (RenderedTargetTest, CostumeHeight)
260- {
261- RenderedTarget target;
262- ASSERT_EQ (target.costumeHeight (), 0 );
263-
264- target.setCostumeHeight (46.48 );
265- ASSERT_EQ (target.costumeHeight (), 46.48 );
266- }
0 commit comments