Sha256: d968730e325e36dd6b4a16ae1321c941d69af4d32752bf8e74695ffb338884d8

Contents?: true

Size: 1.68 KB

Versions: 17

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

17 entries across 17 versions & 2 rubygems

Version Path
sproutit-sproutcore-1.0.20090721145285 frameworks/sproutcore/frameworks/foundation/tests/views/view/parentViewDidChange.js
sproutcore-1.0.1046 frameworks/sproutcore/frameworks/foundation/tests/views/view/parentViewDidChange.js
sproutcore-1.0.1043 frameworks/sproutcore/frameworks/foundation/tests/views/view/parentViewDidChange.js
sproutcore-1.0.1042 frameworks/sproutcore/frameworks/foundation/tests/views/view/parentViewDidChange.js
sproutcore-1.0.1037 frameworks/sproutcore/frameworks/foundation/tests/views/view/parentViewDidChange.js
sproutcore-1.0.1035 frameworks/sproutcore/frameworks/foundation/tests/views/view/parentViewDidChange.js
sproutcore-1.0.1031 frameworks/sproutcore/frameworks/foundation/tests/views/view/parentViewDidChange.js
sproutcore-1.0.1030 frameworks/sproutcore/frameworks/foundation/tests/views/view/parentViewDidChange.js
sproutcore-1.0.1029 frameworks/sproutcore/frameworks/foundation/tests/views/view/parentViewDidChange.js
sproutcore-1.0.1027 frameworks/sproutcore/frameworks/foundation/tests/views/view/parentViewDidChange.js
sproutcore-1.0.1028 frameworks/sproutcore/frameworks/foundation/tests/views/view/parentViewDidChange.js
sproutcore-1.0.1026 frameworks/sproutcore/frameworks/foundation/tests/views/view/parentViewDidChange.js
sproutcore-1.0.1025 frameworks/sproutcore/frameworks/foundation/tests/views/view/parentViewDidChange.js
sproutcore-1.0.1024 frameworks/sproutcore/frameworks/foundation/tests/views/view/parentViewDidChange.js
sproutcore-1.0.1009 frameworks/sproutcore/frameworks/foundation/tests/views/view/parentViewDidChange.js
sproutcore-1.0.1008 frameworks/sproutcore/frameworks/foundation/tests/views/view/parentViewDidChange.js
sproutcore-1.0.1003 frameworks/sproutcore/frameworks/foundation/tests/views/view/parentViewDidChange.js