Skip to content

Commit

Permalink
Initial import of the tester tool.
Browse files Browse the repository at this point in the history
  • Loading branch information
divdavem committed Jun 19, 2012
1 parent da7d92a commit c153974
Show file tree
Hide file tree
Showing 54 changed files with 4,213 additions and 0 deletions.
57 changes: 57 additions & 0 deletions src/aria/tester/index.html
@@ -0,0 +1,57 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<title>Aria Tester</title>
<script type="text/javascript">
// Aria Templates framework parameters
var Aria = {
memCheckMode : false, // checks that constructors and destructors are well called on all objects
debug : true
};

</script>
<script type="text/javascript" src="../bootstrap.js"></script>
<script type="text/javascript" src="../css/atskin.js"></script>
<style>
html {
overflow : hidden;
}
body {
margin : 0px;
background-color : #FAFAFA;
font-family: tahoma,arial,helvetica,sans-serif;
font-size: 11px;
}
</style>
</head>
<body >
<div id="root"></div>
<script type="text/javascript">
aria.core.AppEnvironment.setEnvironment({
contextualMenu:{enabled:true} // to get the right-click refresh menu
}, null, true);

var classpath = "aria.tester.runner.view.main.Main";

var width = {min : 180};
var height = {min : 342};

// set the minimum dimension of this page
Aria.setRootDim({
width: width,
height: height
});

Aria.loadTemplate({
classpath:classpath,
div:"root",
width: width,
height: height,
moduleCtrl: {
classpath: 'aria.tester.runner.ModuleController'
}
});
</script>
</body>
</html>
100 changes: 100 additions & 0 deletions src/aria/tester/runner/BaseFlow.js
@@ -0,0 +1,100 @@
/*
* Copyright 2012 Amadeus s.a.s.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

Aria.classDefinition({
$classpath : 'aria.tester.runner.BaseFlow',
$extends : 'aria.templates.FlowCtrl',
$constructor:function() {
this.$FlowCtrl.constructor.call(this);
},
$prototype: {
// Intercepting method called at the end of the module controller initialization:
oninitCallback : function (param) {
this.$FlowCtrl.oninitCallback.call(this, param); // call the method of the parent which sets this.data
// the flow data is stored in the data model, to be accessible by templates:
this.data.flow = this.flowData;
},

// navigate is published in the Flow interface
navigate:function(targetState) {
var flowData = this.data.flow;
var currentState = flowData.currentState;

if (!this.isTransitionValid(currentState, targetState)) {
return this.$logError("FLOW_INVALID_TRANSITION",[targetState]);
}

var json = aria.utils.Json;

// change current state to new state
json.setValue(flowData,"currentState",targetState);

// Call the internal callback on valid state transitions
this.onStateChange(targetState);

// raise event to notify templates that current state changed
this.$raiseEvent("stateChange");
},

/**
* Will be called after each valid transition change
* To be overrided by children classes
* @param {String} state
*/
onStateChange : function (state) {},

/**
* Tells if a transition is valid. Note: this information is also
* available in the data model
* @param {String} targetState the state targetted by the transition
* @return {Boolean} true if the transition is authorized
*/
isTransitionValid:function(currentState, targetState) {
var transitionMap = this._getTransitionMap();

return (
transitionMap[currentState] &&
transitionMap[currentState][targetState]
);
},

/**
*
* @return {Object}
*/
_getTransitionMap : function () {
var transitionMap = {};
var addValidTransition = function (startState, endState) {
if (!transitionMap[startState]) {
transitionMap[startState] = {};
}
transitionMap[startState][endState] = true
};

var flowData = this.flowData;
var validTransitions = flowData.validTransitions;
for (var i = 0 ; i < validTransitions.length ; i++) {
var validTransition = validTransitions[i];
addValidTransition(validTransition[0], validTransition[1])

// reverse transition
if (validTransition[2]) {
addValidTransition(validTransition[1], validTransition[0]);
}
}
return transitionMap;
}
}
});

0 comments on commit c153974

Please sign in to comment.