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

Commit

Permalink
Revert " - Amend the test cases."
Browse files Browse the repository at this point in the history
This reverts commit 733f17c.

Reverted for not containing the proper bug number. See bug 985853.
  • Loading branch information
KevinGrandon committed Oct 29, 2014
1 parent a9a8479 commit a025586
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 73 deletions.
8 changes: 4 additions & 4 deletions apps/keyboard/js/keyboard/active_targets_manager.js
Expand Up @@ -101,11 +101,11 @@ ActiveTargetsManager.prototype._handlePressStart = function(press, id) {
}

// Notify current targets about the new touch.
if (typeof this.onnewtargetwillactivate === 'function') {
this.activeTargets.forEach(function(target, id) {
this.activeTargets.forEach(function(target, id) {
if (typeof this.onnewtargetwillactivate === 'function') {
this.onnewtargetwillactivate(target);
}, this);
}
}
}, this);

var target = press.target;
this.activeTargets.set(id, target);
Expand Down
16 changes: 9 additions & 7 deletions apps/keyboard/test/unit/keyboard/active_targets_manager_test.js
Expand Up @@ -38,7 +38,6 @@ suite('ActiveTargetsManager', function() {
manager.ontargetcommitted = this.sinon.stub();
manager.ontargetcancelled = this.sinon.stub();
manager.ontargetdoubletapped = this.sinon.stub();
manager.onnewtargetwillactivate = this.sinon.stub();
manager.start();

assert.isTrue(window.UserPressManager.calledWithNew());
Expand Down Expand Up @@ -453,12 +452,15 @@ suite('ActiveTargetsManager', function() {
userPressManagerStub.onpressstart(press1, id1);

assert.isTrue(manager.onnewtargetwillactivate.calledWith(press0.target),
'onnewtargetwillactivate called.');
'Determine commit the first press or not' +
' when the second press starts.');
assert.isTrue(alternativesCharMenuManagerStub.hide.calledOnce);

assert.isTrue(manager.ontargetactivated.calledWith(press1.target));
assert.isTrue(
manager.ontargetactivated.calledWith(press1.target));

assert.equal(window.clearTimeout.callCount, 2);
assert.equal(window.setTimeout.callCount, 1);
assert.equal(window.clearTimeout.callCount, 3);
assert.equal(window.setTimeout.callCount, 3);
});

test('press end second press, and first press', function() {
Expand All @@ -469,10 +471,10 @@ suite('ActiveTargetsManager', function() {
};
userPressManagerStub.onpressend(pressEnd, id1);

assert.isTrue(alternativesCharMenuManagerStub.hide.calledOnce);
assert.isTrue(alternativesCharMenuManagerStub.hide.calledTwice);
assert.isTrue(
manager.ontargetcommitted.calledWith(press1.target));
assert.equal(window.clearTimeout.callCount, 3);
assert.equal(window.clearTimeout.callCount, 4);

var pressEnd2 = {
target: {
Expand Down
25 changes: 1 addition & 24 deletions apps/keyboard/test/unit/keyboard/target_handlers_manager_test.js
Expand Up @@ -99,12 +99,6 @@ suite('TargetHandlersManager', function() {
assert.isTrue(handlerStub.doubleTap.calledOnce);
});

test('New Target activated', function() {
activeTargetsManagerStub.onnewtargetwillactivate(target);

assert.isTrue(handlerStub.newTargetActivate.calledOnce);
});

suite('longPress', function() {
setup(function() {
activeTargetsManagerStub.ontargetlongpressed(target);
Expand Down Expand Up @@ -135,12 +129,6 @@ suite('TargetHandlersManager', function() {

assert.isTrue(handlerStub.doubleTap.calledOnce);
});

test('New target activated', function() {
activeTargetsManagerStub.onnewtargetwillactivate(target);

assert.isTrue(handlerStub.newTargetActivate.calledOnce);
});
});
});

Expand Down Expand Up @@ -187,12 +175,6 @@ suite('TargetHandlersManager', function() {
assert.isTrue(handlerStub.doubleTap.calledOnce);
});

test('New target activated', function() {
activeTargetsManagerStub.onnewtargetwillactivate(target);

assert.isTrue(handlerStub.newTargetActivate.calledOnce);
});

suite('longPress', function() {
setup(function() {
activeTargetsManagerStub.ontargetlongpressed(target);
Expand Down Expand Up @@ -223,12 +205,6 @@ suite('TargetHandlersManager', function() {

assert.isTrue(handlerStub.doubleTap.calledOnce);
});

test('New target activated', function() {
activeTargetsManagerStub.onnewtargetwillactivate(target);

assert.isTrue(handlerStub.newTargetActivate.calledOnce);
});
});
});

Expand Down Expand Up @@ -285,6 +261,7 @@ suite('TargetHandlersManager', function() {
assert.isTrue(handlerStub.activate.calledOnce);
});


test('SpaceKeyTargetHandler', function() {
var target = {
keyCode: KeyEvent.DOM_VK_SPACE
Expand Down
84 changes: 46 additions & 38 deletions apps/keyboard/test/unit/keyboard/target_handlers_test.js
Expand Up @@ -131,21 +131,6 @@ suite('target handlers', function() {
assert.isTrue(app.visualHighlightManager.hide.calledOnce);
});

test('new target activated', function() {
handler.newTargetActivate();

assert.isTrue(
app.inputMethodManager.currentIMEngine.click.calledWith(99));
assert.isTrue(app.inputMethodManager.currentIMEngine.click.calledOnce);

assert.isTrue(app.visualHighlightManager.hide.calledWith(target));
assert.isTrue(app.visualHighlightManager.hide.calledOnce);

handler.commit();
// Won't commit again
assert.isTrue(app.inputMethodManager.currentIMEngine.click.calledOnce);
});

suite('longPress', function() {
setup(function() {
handler.longPress();
Expand Down Expand Up @@ -737,22 +722,59 @@ suite('target handlers', function() {
var target;
setup(function() {
target = {};

handler = new CapsLockTargetHandler(target, app);
});

test('activate', function() {
handler.activate();
setup(function() {
handler.activate();

assert.isTrue(app.upperCaseStateManager.switchUpperCaseState
.calledWith({
isUpperCaseLocked: true
}));
assert.isTrue(app.feedbackManager.triggerFeedback.calledWith(target));
assert.isTrue(app.feedbackManager.triggerFeedback.calledOnce);

assert.isTrue(app.visualHighlightManager.show.calledWith(target));
assert.isTrue(app.visualHighlightManager.show.calledOnce);
});

test('commit', function() {
handler.commit();

assert.isTrue(app.upperCaseStateManager.switchUpperCaseState
.calledWith({
isUpperCase: true,
isUpperCaseLocked: false
}));

assert.isTrue(app.visualHighlightManager.hide.calledWith(target));
assert.isTrue(app.visualHighlightManager.hide.calledOnce);
});

test('moveOut', function() {
handler.moveOut();

assert.isTrue(app.visualHighlightManager.hide.calledWith(target));
assert.isTrue(app.visualHighlightManager.hide.calledOnce);
});

assert.isTrue(app.feedbackManager.triggerFeedback.calledWith(target));
assert.isTrue(app.feedbackManager.triggerFeedback.calledOnce);
test('cancel', function() {
handler.cancel();

assert.isTrue(app.visualHighlightManager.hide.calledWith(target));
assert.isTrue(app.visualHighlightManager.hide.calledOnce);
});

assert.isTrue(app.visualHighlightManager.show.calledWith(target));
assert.isTrue(app.visualHighlightManager.show.calledOnce);
test('doubleTap', function() {
handler.doubleTap();

assert.isTrue(app.upperCaseStateManager.switchUpperCaseState
.calledWith({
isUpperCaseLocked: true
}));

assert.isTrue(app.visualHighlightManager.hide.calledWith(target));
assert.isTrue(app.visualHighlightManager.hide.calledOnce);
});
});

test('longPress', function() {
Expand Down Expand Up @@ -782,20 +804,6 @@ suite('target handlers', function() {
assert.isTrue(app.visualHighlightManager.hide.calledOnce);
});

test('combo key - activate and then with new arget activated', function() {
handler.newTargetActivate();
handler.commit();

assert.isTrue(app.upperCaseStateManager.switchUpperCaseState
.calledWith({
isUpperCase: false,
isUpperCaseLocked: false
}));

assert.isTrue(app.visualHighlightManager.hide.calledWith(target));
assert.isTrue(app.visualHighlightManager.hide.calledOnce);
});

test('cancel', function() {
assert.equal(handler.cancel, DefaultTargetHandler.prototype.cancel,
'function not overwritten');
Expand Down

0 comments on commit a025586

Please sign in to comment.