Bläddra i källkod

Add test for external tile loading.

pull/881/head
Nico Höllerich 4 år sedan
förälder
incheckning
076307ea55
2 ändrade filer med 56 tillägg och 1 borttagningar
  1. +11
    -0
      tests/run_tests.py
  2. +45
    -1
      tests/tests.html

+ 11
- 0
tests/run_tests.py Visa fil

@@ -183,6 +183,17 @@ class PannellumTester(object):
assert self.browser.execute_script("var hs = viewer.getConfig().hotSpots[0]; return Math.abs(hs.yaw) < 0.001 && Math.abs(hs.pitch) < 0.001")
print("PASS: hot spot dragging")

# Check multires with external tile loading
self.browser.execute_script("viewer.loadScene('multires-loader')")
time.sleep(5)
if create_ref:
self.take_screenshot("panorama", "tests/multires.png")
subprocess.call(["optipng", "-o7", "-strip", "all", "tests/multires.png"])
else:
reference = Image.open("tests/multires.png")
comparator = self.take_screenshot("panorama")
self.equal_images(reference, comparator, "multires with external tile loading")

self.httpd.server_close()

def get_browser(self, name=None):


+ 45
- 1
tests/tests.html Visa fil

@@ -90,7 +90,51 @@ viewer = pannellum.viewer('panorama', {
"dragHandlerFunc": console.log
}
]
}
},
"multires-loader": {
"title": "multires title",
"type": "multires",
"hfov": 85,
"multiRes": {
"basePath": "../examples/multires",
"path": "/%l/%s%x%y",
"fallbackPath": "/fallback/%s",
"extension": "png",
"tileResolution": 256,
"maxLevel": 4,
"cubeResolution": 2048,
"loader": function(node){
var resolver;
var rejector;
var promise = {};
promise.then = function(callback){
resolver = callback;
return promise;
}
promise.catch = function(callback){
rejector = callback;
return promise;
}
var img = document.createElement('img');
img.onload = function () {
if(resolver)
resolver(img);
}
img.onerror = function(err) {
if(rejector)
rejector(err);
}
img.src = node.uri;
return promise;
}
}
}
}
});
</script>


Laddar…
Avbryt
Spara