Example #1
0
    def testCanvasAPI(self):
        def checkMainScreenshot():
            bmp1 = player.screenshot()
            bmp2 = mainCanvas.screenshot()
            self.assert_(self.areSimilarBmps(bmp1, bmp2, 0.01, 0.01))

        def checkCanvasScreenshot():
            bmp = offscreenCanvas.screenshot()
            self.compareBitmapToFile(bmp, "testOffscreenScreenshot")

        def createCompressed():
            avg.ImageNode(href="canvas:offscreencanvas",
                          compression="B5G6R5",
                          parent=root)

        root = self.loadEmptyScene()
        mainCanvas = player.getMainCanvas()
        self.assertEqual(mainCanvas.getRootNode(), root)
        offscreenCanvas = self.__createOffscreenCanvas("offscreencanvas",
                                                       False)
        self.assertEqual(offscreenCanvas, player.getCanvas("offscreencanvas"))
        self.assertEqual(
            offscreenCanvas.getElementByID("test1").href, "rgb24-65x65.png")
        self.assertEqual(offscreenCanvas.getElementByID("missingnode"), None)
        self.assertRaises(avg.Exception, player.screenshot)
        self.assertRaises(avg.Exception, createCompressed)
        self.start(False, (checkMainScreenshot, checkCanvasScreenshot))
    def testCanvasAPI(self):
        def checkMainScreenshot():
            bmp1 = player.screenshot()
            bmp2 = mainCanvas.screenshot()
            self.assert_(self.areSimilarBmps(bmp1, bmp2, 0.01, 0.01))

        def checkCanvasScreenshot():
            bmp = offscreenCanvas.screenshot()
            self.compareBitmapToFile(bmp, "testOffscreenScreenshot")

        def createCompressed():
            avg.ImageNode(href="canvas:offscreencanvas", compression="B5G6R5", 
                    parent=root)

        root = self.loadEmptyScene()
        mainCanvas = player.getMainCanvas()
        self.assertEqual(mainCanvas.getRootNode(), root)
        offscreenCanvas = self.__createOffscreenCanvas("offscreencanvas", False)
        self.assertEqual(offscreenCanvas, player.getCanvas("offscreencanvas"))
        self.assertEqual(offscreenCanvas.getElementByID("test1").href, "rgb24-65x65.png")
        self.assertEqual(offscreenCanvas.getElementByID("missingnode"), None)
        self.assertRaises(avg.Exception, player.screenshot)
        self.assertRaises(avg.Exception, createCompressed)
        self.start(False,
                (checkMainScreenshot,
                 checkCanvasScreenshot))