Changeset View
Changeset View
Standalone View
Standalone View
libs/ui/tests/kis_prescaled_projection_test.cpp
Show First 20 Lines • Show All 291 Lines • ▼ Show 20 Line(s) | 285 | PrescaledProjectionTester() { | |||
---|---|---|---|---|---|
292 | layer = new KisPaintLayer(image, "test", OPACITY_OPAQUE_U8, cs); | 292 | layer = new KisPaintLayer(image, "test", OPACITY_OPAQUE_U8, cs); | ||
293 | layer->paintDevice()->convertFromQImage(sourceImage, 0); | 293 | layer->paintDevice()->convertFromQImage(sourceImage, 0); | ||
294 | 294 | | |||
295 | image->addNode(layer, image->rootLayer(), 0); | 295 | image->addNode(layer, image->rootLayer(), 0); | ||
296 | 296 | | |||
297 | converter.setResolution(100, 100); | 297 | converter.setResolution(100, 100); | ||
298 | converter.setZoom(1.); | 298 | converter.setZoom(1.); | ||
299 | converter.setImage(image); | 299 | converter.setImage(image); | ||
300 | converter.setCanvasWidgetSize(QSize(100,100)); | 300 | converter.setCanvasWidgetSize(QSize(100,100), 1.0); | ||
301 | converter.setDocumentOffset(QPoint(100,100)); | 301 | converter.setDocumentOffsetDevicePixel(QPoint(100,100)); | ||
302 | 302 | | |||
303 | projection.setCoordinatesConverter(&converter); | 303 | projection.setCoordinatesConverter(&converter); | ||
304 | projection.setMonitorProfile(0, | 304 | projection.setMonitorProfile(0, | ||
305 | KoColorConversionTransformation::internalRenderingIntent(), | 305 | KoColorConversionTransformation::internalRenderingIntent(), | ||
306 | KoColorConversionTransformation::internalConversionFlags()); | 306 | KoColorConversionTransformation::internalConversionFlags()); | ||
307 | projection.setImage(image); | 307 | projection.setImage(image); | ||
308 | projection.notifyCanvasSizeChanged(QSize(100,100)); | 308 | projection.notifyCanvasSizeChanged(QSize(100,100)); | ||
309 | projection.notifyZoomChanged(); | 309 | projection.notifyZoomChanged(); | ||
Show All 12 Lines | 320 | { | |||
322 | 322 | | |||
323 | QImage result = t.projection.prescaledQImage(); | 323 | QImage result = t.projection.prescaledQImage(); | ||
324 | QImage reference = t.sourceImage.copy(QRect(100,100,100,100)); | 324 | QImage reference = t.sourceImage.copy(QRect(100,100,100,100)); | ||
325 | 325 | | |||
326 | QPoint pt; | 326 | QPoint pt; | ||
327 | QVERIFY(TestUtil::compareQImages(pt, result, reference)); | 327 | QVERIFY(TestUtil::compareQImages(pt, result, reference)); | ||
328 | 328 | | |||
329 | // Test actual scrolling | 329 | // Test actual scrolling | ||
330 | t.converter.setDocumentOffset(QPoint(150,150)); | 330 | t.converter.setDocumentOffsetDevicePixel(QPoint(150,150)); | ||
331 | t.projection.viewportMoved(QPoint(-50,-50)); | 331 | t.projection.viewportMoved(QPoint(-50,-50)); | ||
332 | 332 | | |||
333 | result = t.projection.prescaledQImage(); | 333 | result = t.projection.prescaledQImage(); | ||
334 | reference = t.sourceImage.copy(QRect(150,150,100,100)); | 334 | reference = t.sourceImage.copy(QRect(150,150,100,100)); | ||
335 | 335 | | |||
336 | QEXPECT_FAIL("", "Images should be the same, but aren't", Continue); | 336 | QEXPECT_FAIL("", "Images should be the same, but aren't", Continue); | ||
337 | QVERIFY(TestUtil::compareQImages(pt, result, reference)); | 337 | QVERIFY(TestUtil::compareQImages(pt, result, reference)); | ||
338 | } | 338 | } | ||
339 | 339 | | |||
340 | void KisPrescaledProjectionTest::testScrollingZoom50() | 340 | void KisPrescaledProjectionTest::testScrollingZoom50() | ||
341 | { | 341 | { | ||
342 | PrescaledProjectionTester t; | 342 | PrescaledProjectionTester t; | ||
343 | 343 | | |||
344 | t.converter.setDocumentOffset(QPoint(0,0)); | 344 | t.converter.setDocumentOffsetDevicePixel(QPoint(0,0)); | ||
345 | 345 | | |||
346 | t.converter.setCanvasWidgetSize(QSize(300,300)); | 346 | t.converter.setCanvasWidgetSize(QSize(300,300), 1.0); | ||
347 | t.projection.notifyCanvasSizeChanged(QSize(300,300)); | 347 | t.projection.notifyCanvasSizeChanged(QSize(300,300)); | ||
348 | 348 | | |||
349 | QEXPECT_FAIL("", "Images should be the same, but aren't", Continue); | 349 | QEXPECT_FAIL("", "Images should be the same, but aren't", Continue); | ||
350 | QVERIFY(TestUtil::checkQImage(t.projection.prescaledQImage(), | 350 | QVERIFY(TestUtil::checkQImage(t.projection.prescaledQImage(), | ||
351 | "prescaled_projection_test", | 351 | "prescaled_projection_test", | ||
352 | "testScrollingZoom50", | 352 | "testScrollingZoom50", | ||
353 | "initial")); | 353 | "initial")); | ||
354 | 354 | | |||
355 | t.converter.setZoom(0.5); | 355 | t.converter.setZoom(0.5); | ||
356 | t.projection.notifyZoomChanged(); | 356 | t.projection.notifyZoomChanged(); | ||
357 | 357 | | |||
358 | QEXPECT_FAIL("", "Images should be the same, but aren't", Continue); | 358 | QEXPECT_FAIL("", "Images should be the same, but aren't", Continue); | ||
359 | QVERIFY(TestUtil::checkQImage(t.projection.prescaledQImage(), | 359 | QVERIFY(TestUtil::checkQImage(t.projection.prescaledQImage(), | ||
360 | "prescaled_projection_test", | 360 | "prescaled_projection_test", | ||
361 | "testScrollingZoom50", | 361 | "testScrollingZoom50", | ||
362 | "zoom50")); | 362 | "zoom50")); | ||
363 | 363 | | |||
364 | t.converter.setDocumentOffset(QPoint(50,50)); | 364 | t.converter.setDocumentOffsetDevicePixel(QPoint(50,50)); | ||
365 | t.projection.viewportMoved(QPoint(-50,-50)); | 365 | t.projection.viewportMoved(QPoint(-50,-50)); | ||
366 | 366 | | |||
367 | QEXPECT_FAIL("", "Images should be the same, but aren't", Continue); | 367 | QEXPECT_FAIL("", "Images should be the same, but aren't", Continue); | ||
368 | QVERIFY(TestUtil::checkQImage(t.projection.prescaledQImage(), | 368 | QVERIFY(TestUtil::checkQImage(t.projection.prescaledQImage(), | ||
369 | "prescaled_projection_test", | 369 | "prescaled_projection_test", | ||
370 | "testScrollingZoom50", | 370 | "testScrollingZoom50", | ||
371 | "zoom50_moved50")); | 371 | "zoom50_moved50")); | ||
372 | } | 372 | } | ||
373 | 373 | | |||
374 | void KisPrescaledProjectionTest::testUpdates() | 374 | void KisPrescaledProjectionTest::testUpdates() | ||
375 | { | 375 | { | ||
376 | PrescaledProjectionTester t; | 376 | PrescaledProjectionTester t; | ||
377 | 377 | | |||
378 | t.converter.setDocumentOffset(QPoint(10,10)); | 378 | t.converter.setDocumentOffsetDevicePixel(QPoint(10,10)); | ||
379 | 379 | | |||
380 | t.converter.setCanvasWidgetSize(2*QSize(300,300)); | 380 | t.converter.setCanvasWidgetSize(2*QSize(300,300), 1.0); | ||
381 | t.projection.notifyCanvasSizeChanged(2*QSize(300,300)); | 381 | t.projection.notifyCanvasSizeChanged(2*QSize(300,300)); | ||
382 | 382 | | |||
383 | 383 | | |||
384 | t.converter.setZoom(0.50); | 384 | t.converter.setZoom(0.50); | ||
385 | t.projection.notifyZoomChanged(); | 385 | t.projection.notifyZoomChanged(); | ||
386 | 386 | | |||
387 | QEXPECT_FAIL("", "Images should be the same, but aren't", Continue); | 387 | QEXPECT_FAIL("", "Images should be the same, but aren't", Continue); | ||
388 | QVERIFY(TestUtil::checkQImage(t.projection.prescaledQImage(), | 388 | QVERIFY(TestUtil::checkQImage(t.projection.prescaledQImage(), | ||
▲ Show 20 Lines • Show All 93 Lines • Show Last 20 Lines |