* </p>
 *
 * @see br.presenter.node.AutoCompleteSelectionField
 */
function JQueryAutoCompleteControl() {
	ControlAdaptor.call(this);

	/** @private */
	this.m_eElement = {};
	this.m_jQueryInput = null;
	this.m_bOpenOnFocus = false;
	this.m_sAppendTo = 'body';
	this._viewOpened = false;
}

Core.inherit(JQueryAutoCompleteControl, ControlAdaptor);
Core.inherit(JQueryAutoCompleteControl, PropertyListener);

/**
 * @private
 * @see br.presenter.control.ControlAdaptor#setElement
 */
JQueryAutoCompleteControl.prototype.setElement = function(eElement) {
	if (eElement.type && eElement.type === 'text') {
		this.m_eElement = eElement;
	} else {
		this.m_eElement = document.createElement('input');
		eElement.appendChild(this.m_eElement);
	}
};
Example #2
0
'use strict';

/**
 * @module br/test/SubFixtureRegistry
 */

var br = require('br/Core');
var FixtureRegistry = require('br/test/FixtureRegistry');

/**
 * @private
 * @class
 * @alias module:br/test/SubFixtureRegistry
 * @implements module:br/test/FixtureRegistry
 */
function SubFixtureRegistry(parentFixtureRegistry, scope) {
	this.m_oParentFixtureRegistry = parentFixtureRegistry;
	this.m_sScope = scope;
};

br.inherit(SubFixtureRegistry, FixtureRegistry);

/** @see br.test.FixtureRegistry#addFixture */
SubFixtureRegistry.prototype.addFixture = function(scope, fixture) {
	this.m_oParentFixtureRegistry.addFixture(this.m_sScope + '.' + scope, fixture);
};

module.exports = SubFixtureRegistry;
Example #3
0
				") does not implement br.test.FixtureFactory");
	}

	this.m_oFixtureFactory.addFixtures(this);
	this.addFixture("test", new TestFixture(this));
	this.addFixture("time", new TimeFixture(TimeUtility));

	this.m_fDoGiven = GwtTestRunner.createTestMethod(this, "doGiven"),
	this.m_fDoWhen = GwtTestRunner.createTestMethod(this, "doWhen"),
	this.m_fDoThen = GwtTestRunner.createTestMethod(this, "doThen"),
	this.m_fDoAnd = GwtTestRunner.createTestMethod(this, "doAnd");
	this.m_fStartingContinuesFrom = GwtTestRunner.createTestMethod(this, "startingContinuesFrom");
	this.m_fFinishedContinuesFrom = GwtTestRunner.createTestMethod(this, "finishedContinuesFrom");
};

br.inherit(GwtTestRunner, FixtureRegistry);

GwtTestRunner.m_mTests = {};
GwtTestRunner.m_mSuites = {};
GwtTestRunner.INIT_PHASE = 1;
GwtTestRunner.GIVEN_PHASE = 2;
GwtTestRunner.WHEN_PHASE = 3;
GwtTestRunner.THEN_PHASE = 4;


// *** Static Methods ***

/**
 * Static method that needs to be called before any Jasmine tests will execute.
 */
GwtTestRunner.initialize = function() {
Example #4
0
 */

var br = require('br/Core');
var Errors = require('br/Errors');
var Fixture = require('br/test/Fixture');
var ViewFixture = require('br/test/ViewFixture');

/**
 * @private
 * @class
 * @alias module:br/test/TestFixture
 */
function TestFixture(gwtTestRunner) {
	this.m_oGwtTestRunner = gwtTestRunner;
}
br.inherit(TestFixture, Fixture);

TestFixture.prototype.canHandleExactMatch = function() {
	return false;
};

TestFixture.prototype.canHandleProperty = function(property) {
	return property == 'continuesFrom';
};

TestFixture.prototype.addSubFixtures = function(fixtureRegistry) {
	fixtureRegistry.addFixture('page', new ViewFixture('body'));
};

TestFixture.prototype.doGiven = function(propertyName, value) {
	// Note: this line is needed to overcome a strange bug in IE that otherwise causes the exceptions thrown
/**
 * @private
 * @class
 * @alias module:br/presenter/node/FieldValuePropertyListener
 * @implements module:br/presenter/property/PropertyListener
 *
 * @param {module:br/presenter/node/Field} oField
 *
 */
function FieldValuePropertyListener(oField) {
	this.m_oField = oField;
	oField.value.addListener(this, true);
	// TODO: we need to invoke removeListener() in our destructor
}

Core.inherit(FieldValuePropertyListener, PropertyListener);


// *********************** PropertyListener Interface ***********************

/**
 * @private
 * @see br.presenter.property.PropertyListener#onValidationComplete
 */
FieldValuePropertyListener.prototype.onValidationComplete = function() {
	if (this.m_oField.pending) {
		this.m_oField.pending.setValue(false);
	}
};

/**
/**
 * Constructs a <code>br.presenter.testing.PresentationModelFixture</code>.
 * 
 * @class
 * @alias module:br/presenter/testing/PresentationModelFixture
 * @implements module:br/component/testing/ComponentModelFixture
 * 
 * @classdesc
 * The <code>PresentationModelFixture</code> serves to manipulate and verify the state of the presentation
 * model of a presenter component. 
 */
function PresentationModelFixture() {
	this._initializePlugins();
}

Core.inherit(PresentationModelFixture, ComponentModelFixture);

/**
 * @private
 */
PresentationModelFixture.prototype._initializePlugins = function() {
	presenter_knockout.bindingHandlers.event = new KnockoutInvocationCountPlugin();
};

// * **********************************************************************************
// *						 ComponentModelFixture interface
// ************************************************************************************

PresentationModelFixture.prototype.setComponent = function(oComponent) {
	this.m_oPresentationModel = oComponent.getPresentationModel();
};
'use strict';

var Fixture = require('br/test/Fixture');
var Core = require('br/Core');

function BrowserDetectorFixture() {
	this.m_oBrowserDetector = null;
}

Core.inherit(BrowserDetectorFixture, Fixture);

BrowserDetectorFixture.prototype.setBrowserDetector = function(oBrowserDetector) {
	this.m_oBrowserDetector = oBrowserDetector;
};

BrowserDetectorFixture.prototype.canHandleExactMatch = function() {
	return false;
};

BrowserDetectorFixture.prototype.canHandleProperty = function(sProperty) {
	return sProperty == 'name' || sProperty == 'version';
};

BrowserDetectorFixture.prototype._doGivenAndDoWhen = function(sPropertyName, vValue) {
	if (sPropertyName == 'name') {
		this.m_oBrowserDetector.browserName = vValue;
	} else if (sPropertyName == 'version') {
		this.m_oBrowserDetector.browserVersion = vValue;
	} else {
		fail('Unknown property ' + sPropertyName);
	}
Example #8
0
		text: new Text(),
		typedValue: new TypedValue(),
		value: new Value(),
		width: new Width(),
		borderWidth: new BorderWidth(),
		borderColor: new BorderColor(),
		topMarginWidth: new TopMarginWidth(),
		bottomMarginWidth: new BottomMarginWidth(),
		rightMarginWidth: new RightMarginWidth(),
		leftMarginWidth: new LeftMarginWidth(),
		color: new Color(),
		onKeyDown: new OnKeyDown(),
		top: new Top()
	};
}
br.inherit(ViewFixture, Fixture);

ViewFixture.prototype.setUp = function() {
	var viewElements;

	if (this.m_sViewSelector) {
		viewElements = jQuery(this.m_sViewSelector);
		this._verifyOnlyOneElementSelected(viewElements, this.m_sViewSelector);
		this.setViewElement(viewElements[0]);
	}
};

ViewFixture.prototype.tearDown = function() {
	this.m_eViewElement = null;

	if (this.m_oBlurHandler) {
var brCore = require("br/Core");
var Fixture = require("br/test/Fixture");

var GrandParentTestFixture = function()
{
	var ParentTestFixture = require("br/test/ParentTestFixture");
	this.m_oChildMockFixture = new ParentTestFixture();
};

brCore.inherit(GrandParentTestFixture, Fixture);

GrandParentTestFixture.prototype.addSubFixtures = function(oFixtureRegistry)
{
	oFixtureRegistry.addFixture("childFixture", this.m_oChildMockFixture);
};

GrandParentTestFixture.prototype.canHandleExactMatch = function()
{
	return false;
};

GrandParentTestFixture.prototype.canHandleProperty = function(sProperty)
{
	return false;
};

GrandParentTestFixture.prototype.getChildMockFixture = function()
{
	return this.m_oChildMockFixture;
};
Example #10
0
'use strict';

var br = require('br/Core');
var Errors = require('br/Errors');
var Fixture = require('br/test/Fixture');

/**
 * @name br.test.AlertFixture
 * @class
 * The <code>AlertFixture</code> allows for testing of browser alerts.
 * @interface
 */
function AlertFixture() {
};
br.inherit(AlertFixture, Fixture);

AlertFixture.prototype.setUp = function() {
	this.m_pAlertStack = [];
	this.m_fOriginalWindowAlertFunction = window.alert;

	var self = this;
	window.alert = function(alertMessage) {
		self.m_pAlertStack.push(alertMessage);
	};
};

AlertFixture.prototype.tearDown = function() {
	window.alert = this.m_fOriginalWindowAlertFunction;
	assertTrue('there were alerts triggered that were not expected in the test', this.m_pAlertStack.length === 0);
};
Example #11
0
	this.m_fPermittedClass = fNodeClass || PresentationNode;

	/** @private */
	this.m_pUpdateListeners = [];

	/** @private */
	this.m_oObservable = new Observable();

	/** @private */
	this.m_oChangeListenerFactory = new ListenerFactory(NodeListListener, 'onNodeListChanged');

	this._copiesAndChecksNodesAndClearsNodePaths(pPresentationNodes);
}

Core.extend(NodeList, PresentationNode);
Core.inherit(NodeList, KnockoutNodeList);

/**
 * Returns the list of {@link module:br/presenter/node/PresentationNode} instances as an array.
 *
 * @type Array
 */
NodeList.prototype.getPresentationNodesArray = function() {
	return this.m_pItems;
};

/**
 * Returns the name of the template used to render the given presentation node.
 *
 * @param {module:br/presenter/node/PresentationNode} oPresentationNode The presentation node being queried.
 * @type String
Example #12
0
 * This class is constructed by presenter automatically on your behalf.
 * 
 * <p>The toggle-switch control is aliased by <em>br.toggle-switch</em>,
 * and can be used within templates as follows:</p>
 * 
 * <pre>
 *   &lt;span data-bind="controlNode:selectionFieldProperty, control:'br.toggle-switch'"&gt;&lt;/span&gt;
 * </pre>
 * 
 * <p>The toggle-switch control can only be used to display <code>SelectionField</code> instances
 * having exactly two options.</p>
 */
function ToggleSwitchControl() {
}

Core.inherit(ToggleSwitchControl, PropertyListener);
Core.inherit(ToggleSwitchControl, ControlAdaptor);

// *********************** PropertyListener Interface ***********************

/**
 * @private
 * @see br.presenter.property.PropertyListener#onPropertyChanged
 */
ToggleSwitchControl.prototype.onPropertyChanged = function() {
	this._refresh();
};


// *********************** ControlAdaptor Interface ***********************