コード例 #1
0
ファイル: test_qgsimagecache.py プロジェクト: manisandro/QGIS
    def testRemoteImage(self):
        """Test fetching remote image."""
        url = 'http://localhost:{}/qgis_local_server/sample_image.png'.format(str(TestQgsImageCache.port))
        image, in_cache = QgsApplication.imageCache().pathAsImage(url, QSize(100, 100), 1.0, True)

        # first should be waiting image
        self.assertTrue(self.imageCheck('Remote Image', 'waiting_image', image))
        self.assertFalse(QgsApplication.imageCache().originalSize(url).isValid())
        self.waitForFetch()

        # second should be correct image
        image, in_cache = QgsApplication.imageCache().pathAsImage(url, QSize(100, 100), 1.0, True)

        self.assertTrue(self.imageCheck('Remote Image', 'remote_image', image))
        self.assertEqual(QgsApplication.imageCache().originalSize(url), QSize(511, 800), 1.0)
コード例 #2
0
    def testRemoteImage(self):
        """Test fetching remote image."""
        url = 'http://localhost:{}/qgis_local_server/sample_image.png'.format(str(TestQgsImageCache.port))
        image, in_cache = QgsApplication.imageCache().pathAsImage(url, QSize(100, 100), 1.0, True)

        # first should be waiting image
        self.assertTrue(self.imageCheck('Remote Image', 'waiting_image', image))
        self.assertFalse(QgsApplication.imageCache().originalSize(url).isValid())
        self.waitForFetch()

        # second should be correct image
        image, in_cache = QgsApplication.imageCache().pathAsImage(url, QSize(100, 100), 1.0, True)

        self.assertTrue(self.imageCheck('Remote Image', 'remote_image', image))
        self.assertEqual(QgsApplication.imageCache().originalSize(url), QSize(511, 800), 1.0)
コード例 #3
0
ファイル: test_qgsimagecache.py プロジェクト: pkampf/QGIS
    def testRemoteImageMissing(self):
        """Test fetching remote image with bad url"""
        url = 'http://localhost:{}/qgis_local_server/xxx.png'.format(
            str(TestQgsImageCache.port))  # oooo naughty
        image, in_cache = QgsApplication.imageCache().pathAsImage(
            url, QSize(100, 100), 1.0, True)

        self.assertTrue(
            self.imageCheck('Remote image missing', 'waiting_image', image))
コード例 #4
0
    def testRemoteImageBlocking(self):
        """Test fetching remote image."""
        # remote not yet requested so not in cache
        url = 'http://localhost:{}/qgis_local_server/logo_2017.png'.format(
            str(TestQgsImageCache.port))
        image, in_cache = QgsApplication.imageCache().pathAsImage(url,
                                                                  QSize(
                                                                      100,
                                                                      100),
                                                                  True,
                                                                  1.0,
                                                                  blocking=1)

        # first should be correct image
        self.assertTrue(
            self.imageCheck('Remote image sync', 'remote_image_blocking',
                            image))

        # remote probably in cache
        url = 'http://localhost:{}/qgis_local_server/sample_image.png'.format(
            str(TestQgsImageCache.port))
        image, in_cache = QgsApplication.imageCache().pathAsImage(url,
                                                                  QSize(
                                                                      100,
                                                                      100),
                                                                  True,
                                                                  1.0,
                                                                  blocking=1)

        self.assertTrue(self.imageCheck('Remote Image', 'remote_image', image))

        # remote probably in cache
        url = 'http://localhost:{}/qgis_local_server/xxx.png'.format(
            str(TestQgsImageCache.port))  # oooo naughty
        image, in_cache = QgsApplication.imageCache().pathAsImage(url,
                                                                  QSize(
                                                                      100,
                                                                      100),
                                                                  True,
                                                                  1.0,
                                                                  blocking=1)

        self.assertTrue(
            self.imageCheck('Remote image missing', 'waiting_image', image))
コード例 #5
0
ファイル: test_qgsimagecache.py プロジェクト: pkampf/QGIS
    def setUp(self):
        self.report = "<h1>Python QgsImageCache Tests</h1>\n"

        self.fetched = False
        QgsApplication.imageCache().remoteImageFetched.connect(
            self.imageFetched)
コード例 #6
0
ファイル: test_qgsimagecache.py プロジェクト: manisandro/QGIS
    def testRemoteImageMissing(self):
        """Test fetching remote image with bad url"""
        url = 'http://localhost:{}/qgis_local_server/xxx.png'.format(str(TestQgsImageCache.port))  # oooo naughty
        image, in_cache = QgsApplication.imageCache().pathAsImage(url, QSize(100, 100), 1.0, True)

        self.assertTrue(self.imageCheck('Remote image missing', 'waiting_image', image))
コード例 #7
0
ファイル: test_qgsimagecache.py プロジェクト: manisandro/QGIS
    def setUp(self):
        self.report = "<h1>Python QgsImageCache Tests</h1>\n"

        self.fetched = False
        QgsApplication.imageCache().remoteImageFetched.connect(self.imageFetched)