Skip to content

Commit

Permalink
Merge pull request #6597
Browse files Browse the repository at this point in the history
  • Loading branch information
shunter committed May 17, 2018
2 parents 835d715 + 0fe2c9f commit 33f5225
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 3 deletions.
3 changes: 2 additions & 1 deletion Source/Scene/BingMapsImageryProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ define([

this._key = BingMapsApi.getKey(options.key);
this._resource = Resource.createIfNeeded(options.url);
this._resource.appendForwardSlash();
this._tileProtocol = options.tileProtocol;
this._mapStyle = defaultValue(options.mapStyle, BingMapsStyle.AERIAL);
this._culture = defaultValue(options.culture, '');
Expand Down Expand Up @@ -141,7 +142,7 @@ define([
this._readyPromise = when.defer();

var metadataResource = this._resource.getDerivedResource({
url:'/REST/v1/Imagery/Metadata/' + this._mapStyle,
url:'REST/v1/Imagery/Metadata/' + this._mapStyle,
queryParameters: {
incl: 'ImageryProviders',
key: this._key
Expand Down
42 changes: 40 additions & 2 deletions Specs/Scene/BingMapsImageryProviderSpec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
defineSuite([
'Scene/BingMapsImageryProvider',
'Core/appendForwardSlash',
'Core/DefaultProxy',
'Core/defined',
'Core/queryToObject',
Expand All @@ -16,6 +17,7 @@ defineSuite([
'ThirdParty/Uri'
], function(
BingMapsImageryProvider,
appendForwardSlash,
DefaultProxy,
defined,
queryToObject,
Expand Down Expand Up @@ -147,7 +149,7 @@ defineSuite([
}

function installFakeMetadataRequest(url, mapStyle, proxy) {
var expectedUrl = url + '/REST/v1/Imagery/Metadata/' + mapStyle;
var expectedUri = new Uri('REST/v1/Imagery/Metadata/' + mapStyle).resolve(new Uri(appendForwardSlash(url)));

Resource._Implementations.loadAndExecuteScript = function(url, functionName) {
var uri = new Uri(url);
Expand All @@ -161,7 +163,7 @@ defineSuite([
expect(query.key).toBeDefined();

uri.query = undefined;
expect(uri.toString()).toStartWith(expectedUrl);
expect(uri.toString()).toStartWith(expectedUri.toString());

setTimeout(function() {
window[functionName](createFakeMetadataResponse(mapStyle));
Expand Down Expand Up @@ -235,6 +237,42 @@ defineSuite([
});
});

it('resolves readyPromise with a path', function() {
var url = 'http://fake.fake.invalid/some/subdirectory';
var mapStyle = BingMapsStyle.ROAD;

installFakeMetadataRequest(url, mapStyle);
installFakeImageRequest();

var provider = new BingMapsImageryProvider({
url : url,
mapStyle : mapStyle
});

return provider.readyPromise.then(function(result) {
expect(result).toBe(true);
expect(provider.ready).toBe(true);
});
});

it('resolves readyPromise with a path ending with a slash', function() {
var url = 'http://fake.fake.invalid/some/subdirectory/';
var mapStyle = BingMapsStyle.ROAD;

installFakeMetadataRequest(url, mapStyle);
installFakeImageRequest();

var provider = new BingMapsImageryProvider({
url : url,
mapStyle : mapStyle
});

return provider.readyPromise.then(function(result) {
expect(result).toBe(true);
expect(provider.ready).toBe(true);
});
});

it('resolves readyPromise with Resource', function() {
var url = 'http://fake.fake.invalid';
var mapStyle = BingMapsStyle.ROAD;
Expand Down

0 comments on commit 33f5225

Please sign in to comment.