Skip to content

Commit

Permalink
Bug fix for github issue web-platform-tests#244 in w3c/automotive
Browse files Browse the repository at this point in the history
  • Loading branch information
aShinjiroUrata committed Nov 27, 2017
1 parent 760c51b commit bff1997
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 27 deletions.
47 changes: 22 additions & 25 deletions vehicle/viss/0260-unsubscribeall-success.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
<br>
<b>Expected Result:</b><br>
- By sending 'UnsubscribeAll' request, receives 'UnsubscribeSuccessResponse'.<br>
- After receiving 'UnsubscribeSuccessResponse', no 'SubscirbeNotivication' will not reach.<br>
- After receiving 'UnsubscribeSuccessResponse', no 'SubscirbeNotification' will not reach.<br>
</div>

<div id="result"></div>
Expand Down Expand Up @@ -92,19 +92,25 @@
} else if (phase == PH_SENT_SUBSCRIBE) {
t.step_func(function() {
// wait for subscribe response
if (isSubscribeSuccessResponse(reqId1, msg)) {
addLogMessage("reqId1: subscribeSuccessResponse received. subId = " + msg.subscriptionId);
subSuccess1 = true;

if (reqId1 === msg.requestId) {
if (isSubscribeSuccessResponse(reqId1, msg)) {
addLogMessage("reqId1: subscribeSuccessResponse received. subId = " + msg.subscriptionId);
subSuccess1 = true;
}
}
if (isSubscribeSuccessResponse(reqId2, msg)) {
addLogMessage("reqId2: subscribeSuccessResponse received. subId = " + msg.subscriptionId);
subSuccess2 = true;
if (reqId2 === msg.requestId) {
if (isSubscribeSuccessResponse(reqId2, msg)) {
addLogMessage("reqId2: subscribeSuccessResponse received. subId = " + msg.subscriptionId);
subSuccess2 = true;
}
}
if (isSubscribeSuccessResponse(reqId3, msg)) {
addLogMessage("reqId3: subscribeSuccessResponse received. subId = " + msg.subscriptionId);
subSuccess3 = true;
if (reqId3 === msg.requestId) {
if (isSubscribeSuccessResponse(reqId3, msg)) {
addLogMessage("reqId3: subscribeSuccessResponse received. subId = " + msg.subscriptionId);
subSuccess3 = true;
}
}

// If all the Subscribe requests turned out successful, go to next phase
if (subSuccess1 && subSuccess2 && subSuccess3) {
phase = PH_SENT_UNSUBSCRIBE;
Expand All @@ -131,20 +137,11 @@
})();
} else if (phase == PH_SENT_UNSUBSCRIBE) {
t.step_func(function() {

// Ignore SubscriptionNotificationResponse/ErrorResponse
// comming before UbsubscribeAll response reached.
var res1 = isSubscriptionNotificationResponse(subId, msg);
if (res1) {
addLogMessage("Ignore SubscriptionNotificationResponse.");
if (msg.action !== "unsubscribeAll") {
addLogMessage("Ignore messages except for UnsubscribeAll response.");
addLogMessage(" msg = " + JSON.stringify(msg));
return;
}
var res2 = isSubscriptionNotificationErrorResponse(subId, msg);
if (res2) {
addLogMessage("Ignore SubscriptionNotificationErrorResponse.");
return;
}

if (isUnsubscribeAllSuccessResponse(reqId_unsubAll, msg)) {
addLogMessage( "UnsubscribeSuccess response received." );
// unsubscibe success
Expand All @@ -165,8 +162,8 @@
}, TIME_CONFIRM_UNSUBSCRIBED);
}, TIME_WAIT_SUB_NOTIF_END);

} else if (isUnsubscribeErrorResponse(reqId_unsubAll, "", msg)) {
addLogMessage( "UnsubscribeError response received." );
} else if (isUnsubscribeAllErrorResponse(reqId_unsubAll, "", msg)) {
addLogMessage( "UnsubscribeAllError response received." );
// unsubscibe error
// Test is already success. Terminate anyway
phase = PH_END;
Expand Down
4 changes: 2 additions & 2 deletions vehicle/viss/vehicle-test-helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ function isUnsubscribeAllSuccessResponse( _reqId, _inJson) {
// TODO: better to check with Json schema
if (_inJson.action === "unsubscribeAll" &&
_inJson.requestId &&
_inJson.subscriptionId === null &&
_inJson.subscriptionId === undefined &&
_inJson.timestamp && //'timestamp' exists
_inJson.error === undefined)
{
Expand All @@ -282,7 +282,7 @@ function isUnsubscribeAllErrorResponse( _reqId, _inJson) {
// TODO: better to check with Json schema
if (_inJson.action === "unsubscribeAll" &&
_inJson.requestId &&
_inJson.subscriptionId === null &&
_inJson.subscriptionId === undefined &&
_inJson.timestamp && //'timestamp' exists
_inJson.error) //'error' exists
{
Expand Down

0 comments on commit bff1997

Please sign in to comment.