Skip to content
This repository has been archived by the owner on Nov 3, 2021. It is now read-only.

Commit

Permalink
Merge pull request #31772 from nullaus/bug1199429
Browse files Browse the repository at this point in the history
Bug 1199429 - Run Gaia tests with Mulet. Update to tutorial to fix test failure.
  • Loading branch information
nullaus committed Sep 9, 2015
2 parents f312711 + d4532d8 commit 0a552a2
Show file tree
Hide file tree
Showing 11 changed files with 153 additions and 69 deletions.
10 changes: 5 additions & 5 deletions Makefile
Expand Up @@ -793,9 +793,9 @@ ifndef APPS
endif
endif

b2g: node_modules
mulet: node_modules
DEBUG=* ./node_modules/.bin/mozilla-download \
--product b2g-desktop \
--product mulet \
--branch mozilla-central \
$(shell pwd)
touch -c $@
Expand All @@ -812,11 +812,11 @@ test-integration: clean $(PROFILE_FOLDER) test-integration-test
#
# Remember to remove this target after bug-969215 is finished !
.PHONY: test-integration-test
test-integration-test: b2g node_modules
test-integration-test: mulet node_modules
TEST_MANIFEST=$(TEST_MANIFEST) $(NPM) run marionette -- --buildapp="$(BUILDAPP)" --reporter="$(REPORTER)"

.PHONY: jsmarionette-unit-tests
jsmarionette-unit-tests: b2g node_modules $(PROFILE_FOLDER) tests/jsmarionette/runner/marionette-js-runner/venv
jsmarionette-unit-tests: mulet node_modules $(PROFILE_FOLDER) tests/jsmarionette/runner/marionette-js-runner/venv
PROFILE_FOLDER=$(PROFILE_FOLDER) ./tests/jsmarionette/run_tests.js

tests/jsmarionette/runner/marionette-js-runner/venv:
Expand Down Expand Up @@ -1083,7 +1083,7 @@ clean:

# clean out build products and tools
really-clean: clean
rm -rf b2g-* .b2g-* b2g_sdk node_modules b2g modules.tar js-marionette-env "$(NODE_MODULES_CACHEDIR)"
rm -rf b2g-* .b2g-* b2g_sdk node_modules mulet modules.tar js-marionette-env "$(NODE_MODULES_CACHEDIR)"

.git/hooks/pre-commit: tools/pre-commit
test -d .git && cp tools/pre-commit .git/hooks/pre-commit && chmod +x .git/hooks/pre-commit || true
Expand Down
86 changes: 82 additions & 4 deletions apps/ftu/js/tutorial.js
Expand Up @@ -21,37 +21,51 @@
var isVideo = (mediaElement.nodeName === 'VIDEO');
return new Promise(function(resolve, reject) {
function onMediaLoadOrError(evt) {
console.log('TUTORIAL: _loadMedia, onMediaLoadOrError for evt.type: ' +
(evt && evt.type));
evt.target.removeEventListener('error', onMediaLoadOrError);
if (isVideo) {
evt.target.removeEventListener('canplay', onMediaLoadOrError);
evt.target.removeEventListener('abort', onMediaLoadOrError);
} else {
evt.target.removeEventListener('load', onMediaLoadOrError);
}
// Dont block progress on failure to load media
if (evt.type === 'error') {
console.error('Failed to load tutorial media: ' + src);
} else if (evt.type === 'abort') {
console.error('Loading of tutorial media aborted: ' + src);
}
resolve(evt);
}
function onVideoUnloaded(evt) {
console.log('TUTORIAL: _loadMedia, onVideoUnloaded for evt.type: ' +
(evt && evt.type));
mediaElement.removeEventListener('emptied', onVideoUnloaded);
mediaElement.removeEventListener('abort', onVideoUnloaded);
mediaElement.addEventListener('canplay', onMediaLoadOrError);
mediaElement.addEventListener('abort', onMediaLoadOrError);
mediaElement.addEventListener('error', onMediaLoadOrError);
console.log('TUTORIAL: _loadMedia, onVideoUnloaded, assigning src: ' +
src);
mediaElement.src = src;
mediaElement.load();
}
if (isVideo) {
// must unload video and force load before switching to new source
mediaElement.addEventListener('error', onMediaLoadOrError);
if (mediaElement.src) {
mediaElement.addEventListener('emptied', onVideoUnloaded, false);
mediaElement.addEventListener('abort', onVideoUnloaded, false);
console.log('TUTORIAL: _loadMedia, removing src attribute');
mediaElement.removeAttribute('src');
mediaElement.addEventListener('emptied', onVideoUnloaded, false);
console.log('TUTORIAL: _loadMedia, calling load');
mediaElement.load();
} else {
console.log('TUTORIAL: _loadMedia, no src, ' +
'just calling onVideoUnloaded');
onVideoUnloaded();
}
} else {
console.log('TUTORIAL: _loadMedia, not a video, ' +
'listen for load/error only');
mediaElement.addEventListener('load', onMediaLoadOrError, false);
mediaElement.addEventListener('error', onMediaLoadOrError, false);
mediaElement.src = src;
Expand Down Expand Up @@ -127,6 +141,47 @@
}, this);

initTasks.next();

// watch a ton of video events as context for the tutorial
// media loading/playing
var mediaEvents = this._mediaEvents = ['abort',
'canplay',
'canplaythrough',
'durationchange',
'emptied',
'ended',
'error',
'interruptbegin',
'interruptend',
'loadeddata',
'loadedmetadata',
'loadstart',
'mozaudioavailable',
'pause',
'play',
'playing',
'stalled',
'suspend',
'waiting'];

this._debugEventHandler = {
handleEvent: function(evt) {
var errCodes = {
'1': 'MEDIA_ERR_ABORTED',
'2': 'MEDIA_ERR_NETWORK',
'3': 'MEDIA_ERR_DECODE',
'4': 'MEDIA_ERR_SRC_NOT_SUPPORTED'
};
console.log('TUTORIAL: media-event: '+ evt.type);
if (evt.type == 'error') {
var errtype = errCodes[evt.target.error.code] || 'unknown';
console.log('TUTORIAL: media-event, ' + errtype + ' error');
}
}
};
mediaEvents.forEach(name => {
dom.tutorialStepVideo.addEventListener(name, this._debugEventHandler);
});
},

/**
Expand Down Expand Up @@ -154,6 +209,7 @@
}
sequence.push(function setInitialStep() {
// setStep should return promise given by _loadMedia
console.log('TUTORIAL: setInitialStep');
return this._setStep();
}.bind(this));

Expand All @@ -162,6 +218,7 @@
dom.tutorial.classList.add('show');
// Custom event that can be used to apply (screen reader) visibility
// changes.
console.log('TUTORIAL: dispatching tutorialinitialized');
window.dispatchEvent(new CustomEvent('tutorialinitialized'));
});

Expand Down Expand Up @@ -347,6 +404,25 @@
* @memberof Tutorial
*/
reset: function() {
var resetPromise = Promise.resolve();
if (dom.tutorialStepVideo) {
this._mediaEvents.forEach(name => {
dom.tutorialStepVideo.removeEventListener(
name,
this._debugEventHandler
);
});
dom.tutorialStepVideo.hidden = true;
if (dom.tutorialStepVideo.src) {
resetPromise = new Promise((resolve, reject) => {
dom.tutorialStepVideo.addEventListener('emptied', () => {
resolve();
});
dom.tutorialStepVideo.removeAttribute('src');
dom.tutorialStepVideo.load();
});
}
}
if (this._initialization) {
this._initialization.abort();
this._initialization = null;
Expand All @@ -358,6 +434,8 @@
dom.tutorial.classList.remove('show');
this._initialized = false;
}
document.getElementById('tutorial').classList.remove('show');
return resetPromise;
}
};

Expand Down
52 changes: 30 additions & 22 deletions apps/ftu/test/unit/tutorial_test.js
Expand Up @@ -86,9 +86,11 @@ suite('Tutorial >', function() {
});

suite(' lifecycle', function() {
teardown(function() {
Tutorial.reset();
document.getElementById('tutorial').classList.remove('show');
teardown(function(done) {
Tutorial.reset().then(() => {
document.getElementById('tutorial').classList.remove('show');
done();
});
});

test('reset', function(done) {
Expand All @@ -97,10 +99,14 @@ suite('Tutorial >', function() {
Tutorial.init();
//
assert.ok(Tutorial.config);
Tutorial.reset();
assert.ok(!Tutorial.config);
}
function reset() {
return Tutorial.reset().then(() => {
assert.ok(!Tutorial.config);
});
}
Tutorial.loadConfig().then(onOutcome, onOutcome)
.then(reset, reset)
.then(done, done);
});

Expand Down Expand Up @@ -131,22 +137,24 @@ suite('Tutorial >', function() {
test('start during init', function(done) {
Tutorial.init();
Tutorial.start(function() {
setTimeout(done, 0);
assert.ok(Tutorial.config);
assert.isTrue(
document.getElementById('tutorial').classList.contains('show')
);
done(function() {
assert.ok(Tutorial.config);
assert.isTrue(
document.getElementById('tutorial').classList.contains('show')
);
});
});
});

test('start after init', function(done) {
Tutorial.init(null, function() {
Tutorial.start(function() {
setTimeout(done, 0);
assert.ok(Tutorial.config);
assert.isTrue(
document.getElementById('tutorial').classList.contains('show')
);
done(function() {
assert.ok(Tutorial.config);
assert.isTrue(
document.getElementById('tutorial').classList.contains('show')
);
});
});
});
});
Expand Down Expand Up @@ -178,14 +186,14 @@ suite('Tutorial >', function() {
suite(' post-init', function() {
var getJSONStub;
suiteSetup(function(done) {
Tutorial.reset();

getJSONStub = sinon.stub(LazyLoader, 'getJSON')
.returns(Promise.resolve(mockConfig(3)));
Tutorial.reset().then(() => {
getJSONStub = sinon.stub(LazyLoader, 'getJSON')
.returns(Promise.resolve(mockConfig(3)));

Tutorial.init();
Tutorial.start(function() {
done();
Tutorial.init();
Tutorial.start(function() {
done();
});
});
});

Expand Down
8 changes: 4 additions & 4 deletions bin/gaia-test
Expand Up @@ -123,7 +123,7 @@ configure_firefox_location() {

configure_b2g_location() {
#
# Configure b2g test binary
# Configure mulet test binary
#
if [ ! -z "$1" ] ; then
B2G=`which $1`
Expand All @@ -134,11 +134,11 @@ configure_b2g_location() {
fi

if [ -z "$B2G" ] ; then
make b2g
B2G="./b2g/b2g-bin"
make mulet
B2G="./firefox/firefox-bin"
if [ ! -x "$B2G" ] ; then
# set the path for Mac OS X
B2G="./b2g/Contents/MacOS/b2g-bin"
B2G="./firefox/Contents/MacOS/firefox-bin"
fi
fi

Expand Down
18 changes: 9 additions & 9 deletions bin/gaia-ui-tests
Expand Up @@ -3,16 +3,16 @@
export GAIATEST_ACKNOWLEDGED_RISKS=true
export GAIATEST_SKIP_WARNING=true

# Get the b2g desktop binary...
get_b2g_bin() {
local folder=$(find . -d 1 -name 'b2g' | cut -f 1 -d " ")
# Download b2g...
# Get the mulet binary...
get_mulet_bin() {
local folder=$(find . -d 1 -name 'mulet' | cut -f 1 -d " ")
# Download mulet ...
if [ -z "$folder" ];
then
# Everything goes to stderr...
make b2g 1>&2
make mulet 1>&2
fi
find $folder -follow -name "b2g-bin" | tail -n 1
find $folder -follow -name "firefox-bin" | tail -n 1
}


Expand All @@ -28,12 +28,12 @@ get_profile() {
echo $folder
}

b2g=$(get_b2g_bin)
mulet=$(get_mulet_bin)
root=tests/python/gaia-ui-tests/gaiatest
profile=$(get_profile)
gaiatest="$root/cli.py"

echo "Using b2g: $b2g"
echo "Using mulet: $mulet"

# Enter the virtual env.
source ./tests/ci/venv.sh &&
Expand All @@ -45,7 +45,7 @@ python setup.py develop && \
cd $OLDPWD && \
# Run the tests.
python $gaiatest --app=b2gdesktop \
--binary=$b2g \
--binary=$mulet \
--profile=$profile \
--type=b2g \
--timeout=10000 \
Expand Down
4 changes: 2 additions & 2 deletions tests/ci/marionette_js/install
@@ -1,7 +1,7 @@
#! /bin/bash -ve

echo "Downloading b2g-desktop"
make b2g
echo "Downloading Mulet"
make mulet

# Install virtualenv and radicale on Travis.
make caldav-server-install
4 changes: 2 additions & 2 deletions tests/ci/marionette_js_stable_check/install
@@ -1,7 +1,7 @@
#! /bin/bash -ve

echo "Downloading b2g-desktop"
make b2g
echo "Downloading Mulet"
make mulet

# Install virtualenv and radicale on Travis.
make caldav-server-install
Expand Down
14 changes: 7 additions & 7 deletions tests/ci/unit-tests-in-b2g/before_script
Expand Up @@ -18,18 +18,18 @@ make node_modules
echo "Starting test-agent-server"
make test-agent-server &

echo 'Starting B2G Desktop'
echo 'Starting Mulet'

B2G_DESKTOP_PATH="./b2g/b2g-bin"
if [ ! -x "$B2G_DESKTOP_PATH" ] ; then
MULET_PATH="./firefox/firefox-bin"
if [ ! -x "$MULET_PATH" ] ; then
# set the path for Mac OS X
B2G_DESKTOP_PATH="./b2g/Contents/MacOS/b2g-bin"
MULET_PATH="./firefox/Contents/MacOS/firefox-bin"
fi

# if we still don't have it, fail
if [ ! -x "$B2G_DESKTOP_PATH" ] ; then
echo "b2g desktop path doesn't exists"
if [ ! -x "$MULET_PATH" ] ; then
echo "mulet path doesn't exists"
exit 1
fi
$B2G_DESKTOP_PATH -profile `pwd`/profile-debug --runapp 'Test Agent' &
$MULET_PATH -profile `pwd`/profile-debug app://test-agent.gaiamobile.org/ &
waiting_port 8080

0 comments on commit 0a552a2

Please sign in to comment.