Sha256: f46ae718c7ae64b60c12ae6cb849afb3a8505de8f4c32a0681d80188cf77dbae

Contents?: true

Size: 1.68 KB

Versions: 11

Compression:

Stored size: 1.68 KB

Contents

// ==========================================================================
// Project:   SproutCore - JavaScript Application Framework
// Copyright: ©2006-2009 Apple, Inc. and contributors.
// License:   Licened under MIT license (see license.js)
// ==========================================================================

/*global module test equals context ok same */

var view ;
module("SC.View#parentViewDidChange", {
	setup: function() {
		view = SC.View.create();		
	}
});

test("invokes updateLayerLocationIfNeeded at end of runloop if has layer", function() {
	
	view.createLayer();
	ok(view.get('layer'), 'precond - has layer');
	
	var runCount = 0;
	view.updateLayerLocationIfNeeded = function() { runCount++; };
	
	SC.RunLoop.begin();
	view.parentViewDidChange();
	SC.RunLoop.end();

	equals(runCount, 1, 'did invoke');
	
});

test("invokes updateLayerLocationIfNeeded only once no matter how many times it is run", function() {
	
	view.createLayer();
	ok(view.get('layer'), 'precond - has layer');
	
	var runCount = 0;
	view.updateLayerLocationIfNeeded = function() { runCount++; };
	
	SC.RunLoop.begin();
	view.parentViewDidChange();
	view.parentViewDidChange();
	view.parentViewDidChange();
	SC.RunLoop.end();

	equals(runCount, 1, 'did invoke once');
	
});

test("calls recomputeIsVisibleInWindow each time it is called", function() {

	var runCount = 0;
	view.recomputeIsVisibleInWindow = function() { runCount++; };
	
	SC.RunLoop.begin();
	view.parentViewDidChange();
	view.parentViewDidChange();
	view.parentViewDidChange();
	SC.RunLoop.end();

	equals(runCount, 3, 'did invoke each time');	
});

test("returns receiver", function() {
	equals(view.parentViewDidChange(), view, 'receiver');
});

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
sproutit-sproutcore-1.0.0.20090408130025 frameworks/sproutcore/frameworks/foundation/tests/views/view/parentViewDidChange.js
sproutit-sproutcore-1.0.0.20090416161445 frameworks/sproutcore/frameworks/foundation/tests/views/view/parentViewDidChange.js
sproutit-sproutcore-1.0.0.20090720093355 frameworks/sproutcore/frameworks/foundation/tests/views/view/parentViewDidChange.js
sproutit-sproutcore-1.0.0.20090720202429 frameworks/sproutcore/frameworks/foundation/tests/views/view/parentViewDidChange.js
sproutit-sproutcore-1.0.0.20090721125122 frameworks/sproutcore/frameworks/foundation/tests/views/view/parentViewDidChange.js
sproutit-sproutcore-1.0.126 frameworks/sproutcore/frameworks/foundation/tests/views/view/parentViewDidChange.js
sproutit-sproutcore-1.0.20090721145251 frameworks/sproutcore/frameworks/foundation/tests/views/view/parentViewDidChange.js
sproutit-sproutcore-1.0.20090721145280 frameworks/sproutcore/frameworks/foundation/tests/views/view/parentViewDidChange.js
sproutit-sproutcore-1.0.20090721145281 frameworks/sproutcore/frameworks/foundation/tests/views/view/parentViewDidChange.js
sproutit-sproutcore-1.0.20090721145282 frameworks/sproutcore/frameworks/foundation/tests/views/view/parentViewDidChange.js
sproutit-sproutcore-1.0.203 frameworks/sproutcore/frameworks/foundation/tests/views/view/parentViewDidChange.js