Skip to content

Commit

Permalink
Merge pull request #319 from marcjansen/test-iframe-hide-strategy
Browse files Browse the repository at this point in the history
Change the way we hide the test iframe
  • Loading branch information
marcjansen committed Nov 27, 2014
2 parents 74f9e40 + e74b595 commit b392290
Show file tree
Hide file tree
Showing 9 changed files with 10 additions and 139 deletions.
8 changes: 8 additions & 0 deletions tests/Test.AnotherWay.css
Original file line number Diff line number Diff line change
Expand Up @@ -240,4 +240,12 @@ body {

#record_input {
width: 53%;
}
#taw-test-iframe {
padding: 0;
width: 200px;
height: 200px;
position: absolute;
top: -1000px;
left: -1000px;
}
1 change: 1 addition & 0 deletions tests/Test.AnotherWay.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ Test.AnotherWay._g_pages_to_run = null; // list of pages to run automatically af
Test.AnotherWay._g_run_on_main_load = false; // special handling for run_pages_to_run when it might be called before onload or before list of test pages is known.
Test.AnotherWay._g_run_on_list_load = false;
Test.AnotherWay._g_main_loaded = false;
Test.AnotherWay._test_page_onload_delay_ms = 2000; // Number of milliseconds to wait after the iframe fired the onload event

Test.AnotherWay._run_pages_to_run = function(called_from_outside){
if (!Test.AnotherWay._g_main_loaded) {
Expand Down
4 changes: 0 additions & 4 deletions tests/container/VectorLegend.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@

<script src="http://openlayers.org/api/2.13.1/OpenLayers.js"></script>

<script src="../test-utility.js"></script>

<script type="text/javascript">

Ext.Loader.setConfig({
Expand Down Expand Up @@ -134,7 +132,6 @@
}

function test_saferemove(t) {
showTestIframe();
t.plan(3);

var map = new OpenLayers.Map();
Expand Down Expand Up @@ -170,7 +167,6 @@

legend.destroy();
map.destroy();
hideTestIframe();
});
});
}
Expand Down
74 changes: 0 additions & 74 deletions tests/panel/Map.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@

<script src="http://openlayers.org/api/2.13.1/OpenLayers.js"></script>

<script src="../test-utility.js"></script>

<script type="text/javascript">
Ext.Loader.setConfig({
disableCaching: false,
Expand All @@ -32,11 +30,6 @@
function test_mappanel(t) {
t.plan(4)

// make the hidden span element visible, because setSize does not
// work in iframes that are inside a hidden container in FF and IE.
// (hidden again at the end of the test)
showTestIframe();

var moveToCnt;

var map = createMap();
Expand Down Expand Up @@ -75,18 +68,11 @@
map.destroy();

mapPanel.destroy();

hideTestIframe();
}

function test_allOverlaysAndFallThrough(t) {
t.plan(12);

// make the hidden span element visible, because setSize does not
// work in iframes that are inside a hidden container in FF and IE.
// (hidden again at the end of the test)
showTestIframe();

var map, panel;
// a flag being reset after each test to see if a fallThrough
// warning has been issued upon Ext.create('GeoExt.panel.Map', {})
Expand Down Expand Up @@ -175,18 +161,11 @@

// Restore the original warning method.
GeoExt.panel.Map.prototype.warnMapFallThrough = origWarnMapFallThrough;

hideTestIframe();
}

function test_zoom(t) {
t.plan(1);

// make the hidden span element visible, because setSize does not
// work in iframes that are inside a hidden container in FF and IE.
// (hidden again at the end of the test)
showTestIframe();

var panel = Ext.create('GeoExt.panel.Map', {
title: "GeoExt MapPanel",
renderTo: "mappanel",
Expand All @@ -199,18 +178,11 @@
t.eq(panel.map.zoom, 4, "zoom correctly set");

panel.destroy();

hideTestIframe();
}

function test_extent(t) {
t.plan(4);

// make the hidden span element visible, because setSize does not
// work in iframes that are inside a hidden container in FF and IE.
// (hidden again at the end of the test)
showTestIframe();

var map, panel, log = {};

map = createMap();
Expand Down Expand Up @@ -273,18 +245,11 @@
panel.map.addLayer(new OpenLayers.Layer());
t.ok(panel.map.getExtent(), "map has an extent after layer is added");
panel.destroy();

hideTestIframe();
}

function test_center(t) {
t.plan(3);

// make the hidden span element visible, because setSize does not
// work in iframes that are inside a hidden container in FF and IE.
// (hidden again at the end of the test)
showTestIframe();

var map, panel, log = {};

map = createMap();
Expand Down Expand Up @@ -337,8 +302,6 @@
// since we created the map, we destroy it
map.destroy();
panel.destroy();

hideTestIframe();
}

function test_destroy(t) {
Expand All @@ -352,11 +315,6 @@
*/

t.plan(3);

// make the hidden span element visible, because setSize does not
// work in iframes that are inside a hidden container in FF and IE.
// (hidden again at the end of the test)
showTestIframe();

var panel = Ext.create('GeoExt.panel.Map', {
renderTo: "mappanel",
Expand All @@ -380,20 +338,13 @@
t.fail("panel.destroy causes problems: " + err);
}
t.ok(!panel.map, "panel has no reference to a map");

hideTestIframe();
}

function test_applyState_called(t) {
t.plan(1);

// set up

// make the hidden span element visible, because setSize does not
// work in iframes that are inside a hidden container in FF and IE.
// (hidden again at the end of the test)
showTestIframe();

var provider, applyState, mapPanel, log;

provider = new Ext.state.Provider();
Expand Down Expand Up @@ -425,19 +376,13 @@

GeoExt.panel.Map.prototype.applyState = applyState;
mapPanel.destroy();
hideTestIframe();
}

function test_applyState(t) {
t.plan(21);

// set up

// make the hidden span element visible, because setSize does not
// work in iframes that are inside a hidden container in FF and IE.
// (hidden again at the end of the test)
showTestIframe();

var state;

var layers = [
Expand Down Expand Up @@ -549,19 +494,13 @@
// tear down

mapPanel.destroy();
hideTestIframe();
}

function test_getState_called(t) {
t.plan(6);

// set up

// make the hidden span element visible, because setSize does not
// work in iframes that are inside a hidden container in FF and IE.
// (hidden again at the end of the test)
showTestIframe();

var getState, mapPanel, log;

getState = GeoExt.panel.Map.prototype.getState;
Expand Down Expand Up @@ -641,20 +580,13 @@
GeoExt.panel.Map.prototype.getState = getState;
mapPanel.destroy();
});

hideTestIframe();
}

function test_getState(t) {
t.plan(14);

// set up

// make the hidden span element visible, because setSize does not
// work in iframes that are inside a hidden container in FF and IE.
// (hidden again at the end of the test)
showTestIframe();

var state;

// test
Expand Down Expand Up @@ -732,11 +664,9 @@
"state.opacity_barid correctly set");

mapPanel.destroy();
hideTestIframe();
}

function test_add(t) {
showTestIframe();
t.plan(1);
var layers = [
new OpenLayers.Layer("foo", {visibility: true}),
Expand All @@ -758,13 +688,11 @@
t.ok(mapPanel.items.get(0).getEl().dom.parentNode === mapPanel.body.dom,
"Map Panel item has the panels's body div as parent.");
mapPanel.destroy();
hideTestIframe();
}

// This test is originally coming from issue #61:
// https://github.com/geoext/geoext2/pull/61
function test_destroyInTabbedPanelTest(t) {
showTestIframe();
t.plan(3);

var layers = [
Expand Down Expand Up @@ -829,8 +757,6 @@
mappanel.destroy();

t.eq(panel.items.length, 0, "Panel destroy was successful");

hideTestIframe();
}

function test_events(t) {
Expand Down
3 changes: 1 addition & 2 deletions tests/run-tests.html
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,10 @@
</div>
</div>
</div>
<iframe id="taw-test-iframe" name="test_iframe" onload="window.setTimeout(Test.AnotherWay._test_page_onload,Test.AnotherWay._test_page_onload_delay_ms);"></iframe>
<span style="display:none">
<iframe name="list_iframe" onload="Test.AnotherWay._list_iframe_onload();">
</iframe>
<iframe name="test_iframe" onload="Test.AnotherWay._test_page_onload();">
</iframe>
<!-- record_control div is to be imported into other documents, so all its styles are inline -->-
<div id="record_control" style="position:absolute;bottom:0;left:0;margin:0;padding:0.5em;width:22em;height:22em;border:1px solid;background:#ffd;font: normal normal 8pt sans-serif; color:#000; text-align: left">
<p style="margin:0 0 0 0; padding:0">
Expand Down
4 changes: 0 additions & 4 deletions tests/selection/FeatureModel.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@

<script src="http://openlayers.org/api/2.13.1/OpenLayers.js"></script>

<script src="../test-utility.js"></script>

<script type="text/javascript">
Ext.Loader.setConfig({
disableCaching: false,
Expand Down Expand Up @@ -397,7 +395,6 @@
}

function test_autopan_map_on_selection(t) {
showTestIframe();
t.plan(4);

/*
Expand Down Expand Up @@ -490,7 +487,6 @@
* Tear down
*/
grid.destroy();
hideTestIframe();
});

}
Expand Down
6 changes: 0 additions & 6 deletions tests/slider/Zoom.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@

<script src="http://openlayers.org/api/2.13.1/OpenLayers.js"></script>

<script src="../test-utility.js"></script>

<script type="text/javascript">
Ext.Loader.setConfig({
disableCaching: false,
Expand All @@ -22,7 +20,6 @@
]);

function test_zoomslider(t) {
showTestIframe();
t.plan(7);

var map = new OpenLayers.Map({
Expand Down Expand Up @@ -72,15 +69,13 @@
}

map.destroy();
hideTestIframe();
});
});


}

function test_zoomslider_aggressive(t) {
showTestIframe();
t.plan(2);
var slider1 = new GeoExt.ZoomSlider({
renderTo: document.body
Expand All @@ -105,7 +100,6 @@

slider1.destroy();
slider2.destroy();
hideTestIframe();
}

</script>
Expand Down
Loading

0 comments on commit b392290

Please sign in to comment.