| | 1031 | |
|---|
| | 1032 | function test_Map_getMaxExtent(t){ |
|---|
| | 1033 | t.plan(5); |
|---|
| | 1034 | |
|---|
| | 1035 | var options = null; |
|---|
| | 1036 | var map = {}; |
|---|
| | 1037 | |
|---|
| | 1038 | //null options, no baseLayer |
|---|
| | 1039 | var maxExtent = OpenLayers.Map.prototype.getMaxExtent.apply(map, [options]); |
|---|
| | 1040 | t.eq(maxExtent, null, "null options, no baseLayer returns null"); |
|---|
| | 1041 | |
|---|
| | 1042 | //null options.restricted, no baseLayer |
|---|
| | 1043 | maxExtent = OpenLayers.Map.prototype.getMaxExtent.apply(map, [options]); |
|---|
| | 1044 | t.eq(maxExtent, null, "null options.restricted, no baseLayer returns null"); |
|---|
| | 1045 | |
|---|
| | 1046 | //true options.restricted, null map.restrictedExtent no baseLayer |
|---|
| | 1047 | maxExtent = OpenLayers.Map.prototype.getMaxExtent.apply(map, [options]); |
|---|
| | 1048 | t.eq(maxExtent, null, "true options.restricted, null map.restrictedExtent no baseLayer returns null"); |
|---|
| | 1049 | |
|---|
| | 1050 | //true options.restricted, valid map.restrictedExtent no baseLayer |
|---|
| | 1051 | options = { |
|---|
| | 1052 | 'restricted': true |
|---|
| | 1053 | }; |
|---|
| | 1054 | map.restrictedExtent = {}; |
|---|
| | 1055 | maxExtent = OpenLayers.Map.prototype.getMaxExtent.apply(map, [options]); |
|---|
| | 1056 | t.ok(maxExtent == map.restrictedExtent, "true options.restricted, valid map.restrictedExtent no baseLayer returns map.restrictedExtent"); |
|---|
| | 1057 | |
|---|
| | 1058 | //null options, valid baseLayer |
|---|
| | 1059 | options = null; |
|---|
| | 1060 | map.baseLayer = { |
|---|
| | 1061 | 'maxExtent': {} |
|---|
| | 1062 | }; |
|---|
| | 1063 | var maxExtent = OpenLayers.Map.prototype.getMaxExtent.apply(map, [options]); |
|---|
| | 1064 | t.ok(maxExtent == map.baseLayer.maxExtent, "null options, valid baseLayer returns map.baseLayer.maxExtent"); |
|---|
| | 1065 | } |
|---|
| | 1066 | |
|---|
| | 1067 | function test_Map_zoomToMaxExtent(t){ |
|---|
| | 1068 | t.plan(4) |
|---|
| | 1069 | |
|---|
| | 1070 | gMaxExtent = {}; |
|---|
| | 1071 | |
|---|
| | 1072 | var map = { |
|---|
| | 1073 | 'getMaxExtent': function(options) { |
|---|
| | 1074 | gRestricted = options.restricted; |
|---|
| | 1075 | return gMaxExtent; |
|---|
| | 1076 | }, |
|---|
| | 1077 | 'zoomToExtent': function(extent) { |
|---|
| | 1078 | t.ok(extent == gMaxExtent, "zoomToExtent() always called on return from map.getMaxExtent()"); |
|---|
| | 1079 | } |
|---|
| | 1080 | }; |
|---|
| | 1081 | |
|---|
| | 1082 | //options is null |
|---|
| | 1083 | var options = null; |
|---|
| | 1084 | gRestricted = null; |
|---|
| | 1085 | OpenLayers.Map.prototype.zoomToMaxExtent.apply(map, [options]); |
|---|
| | 1086 | t.eq(gRestricted, true, "default 'restricted' passed to map.getMaxExtent() is true"); |
|---|
| | 1087 | |
|---|
| | 1088 | //valid options |
|---|
| | 1089 | options = { |
|---|
| | 1090 | 'restricted': {} |
|---|
| | 1091 | }; |
|---|
| | 1092 | gRestricted = null; |
|---|
| | 1093 | OpenLayers.Map.prototype.zoomToMaxExtent.apply(map, [options]); |
|---|
| | 1094 | t.ok(gRestricted == options.restricted, "when valid options argument, 'options.restricted' passed to map.getMaxExtent()"); |
|---|
| | 1095 | } |
|---|
| | 1096 | |
|---|
| | 1097 | |
|---|