Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TIMOB-14372] Anvil test cases for yahoo, stream, filesystem, network_socket_tcp #4545

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,10 @@ module.exports = new function() {
this.dotSlash = function(testRun) {
var f;
var blob;
valueOf(testRun, function(){f = Ti.Filesystem.getFile('./file.txt');}).shouldNotThrowException();
valueOf(testRun, function(){f = Ti.Filesystem.getFile(Ti.Filesystem.resourcesDirectory, './file.txt');}).shouldNotThrowException();
//Resource files are readonly, but only on device, not simulator. As such, we can't test
//the use case of where writable should be false.
f.write('Appcelerator');
valueOf(testRun, function(){blob = f.read();}).shouldNotThrowException();
var text;
valueOf(testRun, function(){text = blob.text;}).shouldNotThrowException();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,9 @@ module.exports = new function() {
var readPassed = false;
var writePassed = false;
var sourceBuffer = Ti.createBuffer({
data:"ALL WORK AND NO PLAY MAKES JACK A DULL BOY ALL WORK AND NO PLAY MAKES JACK A DULL BOY ALL WORK AND NO PLAY MAKES JACK A DULL BOY"
});
value:"ALL WORK AND NO PLAY MAKES JACK A DULL BOY ALL WORK AND NO PLAY MAKES JACK A DULL BOY ALL WORK AND NO PLAY MAKES JACK A DULL BOY"
// To create a buffer with string, 'createBuffer()' must use attribute "value" instead of "data".
});
var readBuffer = Ti.createBuffer({
length:sourceBuffer.length
});
Expand Down
48 changes: 25 additions & 23 deletions support/anvil/configSet/Resources/suites/stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -373,21 +373,33 @@ module.exports = new function() {
var numOfPass = 0;

function handler(e) {
valueOf(testRun, e.errorState).shouldBeNumber();
valueOf(testRun, e.errorDescription).shouldBeString();
valueOf(testRun, e.bytesProcessed).shouldBeLessThanEqual(chunksize);
valueOf(testRun, e.buffer).shouldNotBeNull();

for (var i=0; i < e.buffer.length; i++) {
valueOf(testRun, e.buffer[i]).shouldBeExactly(sourceValue(i,totalsize));
}

if (e.bytesProcessed != -1) {
if (e.bytesProcessed != -1) { // If "e.bytesProcessed" equals -1 "e.buffer" will be undefined
valueOf(testRun, e.errorState).shouldBeNumber();
valueOf(testRun, e.errorDescription).shouldBeString();
valueOf(testRun, e.bytesProcessed).shouldBeLessThanEqual(chunksize);
valueOf(testRun, e.buffer).shouldNotBeNull();

for (var i=0; i < e.buffer.length; i++) {
valueOf(testRun, e.buffer[i]).shouldBeExactly(sourceValue(i,totalsize));
}
totalsize += e.bytesProcessed;
valueOf(testRun, totalsize).shouldBeExactly(e.totalBytesProcessed);
}
valueOf(testRun, totalsize).shouldBeExactly(e.totalBytesProcessed);

numOfPass += 1;
else {// "numOfPass" is incremented after completion of each pump
numOfPass += 1;
}
if (numOfPass == 1 && e.bytesProcessed == -1) { // confirms that the first pump has just completed and ready for the second pump
sourceValue = function(pos, totalsize) {
return sourceBlobStr.charCodeAt(pos+totalsize);
};
var blobStream = Ti.Stream.createStream({source:sourceBlob, mode:Ti.Stream.MODE_READ});
valueOf(testRun, blobStream).shouldNotBeNull();

// Asynch pump
totalsize = 0;
Ti.Stream.pump(blobStream, handler, chunksize, true);
}

if (numOfPass == 2) {
finish(testRun);
}
Expand All @@ -401,15 +413,5 @@ module.exports = new function() {

// Synch pump
Ti.Stream.pump(bufferStream, handler, chunksize);

sourceValue = function(pos, totalsize) {
return sourceBlobStr.charCodeAt(pos+totalsize);
};
var blobStream = Ti.Stream.createStream({source:sourceBlob, mode:Ti.Stream.MODE_READ});
valueOf(testRun, blobStream).shouldNotBeNull();

// Asynch pump
totalsize = 0;
Ti.Stream.pump(blobStream, handler, chunksize, true);
}
}