mirror of https://github.com/vitalif/phantomjs
commit
e6090d541e
|
@ -142,6 +142,7 @@ QVariant FileSystem::lastModified(const QString &path) const
|
|||
return QVariant(QDateTime());
|
||||
}
|
||||
|
||||
// Tests
|
||||
bool FileSystem::exists(const QString &path) const
|
||||
{
|
||||
return QFile::exists(path);
|
||||
|
@ -157,6 +158,27 @@ bool FileSystem::isFile(const QString &path) const
|
|||
return QFileInfo(path).isFile();
|
||||
}
|
||||
|
||||
bool FileSystem::isAbsolute(const QString &path) const {
|
||||
return QFileInfo(path).isAbsolute();
|
||||
}
|
||||
|
||||
bool FileSystem::isExecutable(const QString &path) const {
|
||||
return QFileInfo(path).isExecutable();
|
||||
}
|
||||
|
||||
bool FileSystem::isLink(const QString &path) const {
|
||||
return QFileInfo(path).isSymLink();
|
||||
}
|
||||
|
||||
bool FileSystem::isReadable(const QString &path) const {
|
||||
return QFileInfo(path).isReadable();
|
||||
}
|
||||
|
||||
bool FileSystem::isWritable(const QString &path) const {
|
||||
return QFileInfo(path).isWritable();
|
||||
}
|
||||
|
||||
// Directory
|
||||
bool FileSystem::makeDirectory(const QString &path) const
|
||||
{
|
||||
return QDir().mkdir(path);
|
||||
|
|
|
@ -113,12 +113,11 @@ public slots:
|
|||
bool exists(const QString &path) const;
|
||||
bool isDirectory(const QString &path) const;
|
||||
bool isFile(const QString &path) const;
|
||||
// - isAbsolute()
|
||||
// - isExecutable()
|
||||
// - isLink()
|
||||
// - isMount()
|
||||
// - isReadable()
|
||||
// - isWritable()
|
||||
bool isAbsolute(const QString &path) const;
|
||||
bool isExecutable(const QString &path) const;
|
||||
bool isReadable(const QString &path) const;
|
||||
bool isWritable(const QString &path) const;
|
||||
bool isLink(const QString &path) const;
|
||||
};
|
||||
|
||||
#endif // FILESYSTEM_H
|
||||
|
|
|
@ -0,0 +1,70 @@
|
|||
describe("Tests Files API", function() {
|
||||
var ABSENT_DIR = "absentdir04",
|
||||
ABSENT_FILE = "absentfile04",
|
||||
TEST_DIR = "testdir04",
|
||||
TEST_FILE = "testfile04",
|
||||
TEST_FILE_PATH = TEST_DIR + fs.separator + TEST_FILE,
|
||||
TEST_CONTENT = "test content",
|
||||
START_CWD = null;
|
||||
|
||||
it("should create some temporary file and directory", function(){
|
||||
fs.makeDirectory(TEST_DIR);
|
||||
fs.write(TEST_FILE_PATH, TEST_CONTENT, "w");
|
||||
});
|
||||
|
||||
it("should confirm that test file and test dir exist, while the absent ones don't", function(){
|
||||
expect(fs.exists(TEST_FILE_PATH)).toBeTruthy();
|
||||
expect(fs.exists(TEST_DIR)).toBeTruthy();
|
||||
expect(fs.exists(ABSENT_FILE)).toBeFalsy();
|
||||
expect(fs.exists(ABSENT_DIR)).toBeFalsy();
|
||||
});
|
||||
|
||||
it("should confirm that the temporary directory is infact a directory, while the absent one doesn't", function(){
|
||||
expect(fs.isDirectory(TEST_DIR)).toBeTruthy();
|
||||
expect(fs.isDirectory(ABSENT_DIR)).toBeFalsy();
|
||||
});
|
||||
|
||||
it("should confirm that the temporary file is infact a file, while the absent one doesn't", function(){
|
||||
expect(fs.isFile(TEST_FILE_PATH)).toBeTruthy();
|
||||
expect(fs.isFile(ABSENT_FILE)).toBeFalsy();
|
||||
});
|
||||
|
||||
it("should confirm that a relative path is not absolute, while an absolute one is", function(){
|
||||
var absPath = fs.absolute(TEST_FILE_PATH);
|
||||
|
||||
expect(fs.isAbsolute(TEST_FILE_PATH)).toBeFalsy();
|
||||
expect(fs.isAbsolute(absPath)).toBeTruthy();
|
||||
});
|
||||
|
||||
it("should confirm that temporary file is readable, writable and non-executable, while absent file is none of those", function(){
|
||||
expect(fs.isReadable(TEST_FILE_PATH)).toBeTruthy();
|
||||
expect(fs.isWritable(TEST_FILE_PATH)).toBeTruthy();
|
||||
expect(fs.isExecutable(TEST_FILE_PATH)).toBeFalsy();
|
||||
|
||||
expect(fs.isReadable(ABSENT_FILE)).toBeFalsy();
|
||||
expect(fs.isWritable(ABSENT_FILE)).toBeFalsy();
|
||||
expect(fs.isExecutable(ABSENT_FILE)).toBeFalsy();
|
||||
});
|
||||
|
||||
it("should confirm that temporary directory is readable, writable and executable, while absent dir is none of those", function(){
|
||||
expect(fs.isReadable(TEST_DIR)).toBeTruthy();
|
||||
expect(fs.isWritable(TEST_DIR)).toBeTruthy();
|
||||
expect(fs.isExecutable(TEST_DIR)).toBeTruthy();
|
||||
|
||||
expect(fs.isReadable(ABSENT_DIR)).toBeFalsy();
|
||||
expect(fs.isWritable(ABSENT_DIR)).toBeFalsy();
|
||||
expect(fs.isExecutable(ABSENT_DIR)).toBeFalsy();
|
||||
});
|
||||
|
||||
it("should confirm that neither temporary file/dir or absent file/dir are links", function(){
|
||||
expect(fs.isLink(TEST_DIR)).toBeFalsy();
|
||||
expect(fs.isLink(TEST_FILE_PATH)).toBeFalsy();
|
||||
expect(fs.isLink(ABSENT_DIR)).toBeFalsy();
|
||||
expect(fs.isLink(ABSENT_FILE)).toBeFalsy();
|
||||
});
|
||||
|
||||
it("should delete the temporary directory and file", function(){
|
||||
fs.removeTree(TEST_DIR);
|
||||
});
|
||||
|
||||
});
|
|
@ -40,12 +40,12 @@ jasmine.ConsoleReporter = function(print, doneCallback, showColors) {
|
|||
newline();
|
||||
}
|
||||
|
||||
function greenDot() {
|
||||
print(greenStr("."));
|
||||
function greenPass() {
|
||||
print(greenStr("PASS"));
|
||||
}
|
||||
|
||||
function redF() {
|
||||
print(redStr("F"));
|
||||
function redFail() {
|
||||
print(redStr("FAIL"));
|
||||
}
|
||||
|
||||
function yellowStar() {
|
||||
|
@ -76,10 +76,8 @@ jasmine.ConsoleReporter = function(print, doneCallback, showColors) {
|
|||
function specFailureDetails(suiteDescription, specDescription, stackTraces) {
|
||||
newline();
|
||||
print(suiteDescription + " " + specDescription);
|
||||
newline();
|
||||
for (var i = 0; i < stackTraces.length; i++) {
|
||||
print(indent(stackTraces[i], 2));
|
||||
newline();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -92,8 +90,6 @@ jasmine.ConsoleReporter = function(print, doneCallback, showColors) {
|
|||
newline();
|
||||
print(colorF(specs + " " + plural(language.spec, specs) + ", " +
|
||||
failed + " " + plural(language.failure, failed)));
|
||||
newline();
|
||||
newline();
|
||||
}
|
||||
|
||||
function greenSummary(specs, failed) {
|
||||
|
@ -126,10 +122,14 @@ jasmine.ConsoleReporter = function(print, doneCallback, showColors) {
|
|||
var results = spec.results();
|
||||
if (results.skipped) {
|
||||
yellowStar();
|
||||
} else if (results.passed()) {
|
||||
greenDot();
|
||||
} else {
|
||||
redF();
|
||||
if (results.passed()) {
|
||||
print('#' + spec.id + ' ' + spec.suite.description + ': ' + spec.description);
|
||||
greenPass();
|
||||
} else {
|
||||
print(redStr('#' + spec.id + ' ' + spec.suite.description + ': ' + spec.description));
|
||||
redFail();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -161,8 +161,6 @@ jasmine.ConsoleReporter = function(print, doneCallback, showColors) {
|
|||
}
|
||||
|
||||
this.reportRunnerResults = function(runner) {
|
||||
newline();
|
||||
|
||||
eachSpecFailure(this.suiteResults, function(suiteDescription, specDescription, stackTraces) {
|
||||
specFailureDetails(suiteDescription, specDescription, stackTraces);
|
||||
});
|
||||
|
|
|
@ -6,7 +6,8 @@ phantom.injectJs("./lib/jasmine-console.js");
|
|||
phantom.injectJs("./phantom-spec.js");
|
||||
phantom.injectJs("./fs-spec-01.js"); //< Filesystem Specs 01 (Basic)
|
||||
phantom.injectJs("./fs-spec-02.js"); //< Filesystem Specs 02 (Attributes)
|
||||
phantom.injectJs("./fs-spec-03.js"); //< Filesystem Specs 02 (Paths)
|
||||
phantom.injectJs("./fs-spec-03.js"); //< Filesystem Specs 03 (Paths)
|
||||
phantom.injectJs("./fs-spec-04.js"); //< Filesystem Specs 04 (Tests)
|
||||
|
||||
// Launch tests
|
||||
var jasmineEnv = jasmine.getEnv();
|
||||
|
|
Loading…
Reference in New Issue