Commit 2465a876 authored by hirono@chromium.org's avatar hirono@chromium.org

Files.app: Introduce TestEntryInfo class to JavaScript code.

Currently the test entry data of 'newly added file.ogg' is doubled for creating
and verifiying the entry.  This CL introduces TestEntryInfo class to JavaScript
code and use it for both creating and verifiying the entyr.

BUG=279774
TEST=file_manager_browsertests
R=hashimoto@chromium.org, yoshiki@chromium.org

Review URL: https://codereview.chromium.org/24026003

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@222218 0039d316-1c4b-4281-b951-d872f2087c98
parent afc1d76e
...@@ -145,14 +145,14 @@ void TestEntryInfo::RegisterJSONConverter( ...@@ -145,14 +145,14 @@ void TestEntryInfo::RegisterJSONConverter(
converter->RegisterCustomField("type", converter->RegisterCustomField("type",
&TestEntryInfo::type, &TestEntryInfo::type,
&MapStringToEntryType); &MapStringToEntryType);
converter->RegisterStringField("source_file_name", converter->RegisterStringField("sourceFileName",
&TestEntryInfo::source_file_name); &TestEntryInfo::source_file_name);
converter->RegisterStringField("target_name", &TestEntryInfo::target_name); converter->RegisterStringField("targetName", &TestEntryInfo::target_name);
converter->RegisterStringField("mime_type", &TestEntryInfo::mime_type); converter->RegisterStringField("mimeType", &TestEntryInfo::mime_type);
converter->RegisterCustomField("shared_option", converter->RegisterCustomField("sharedOption",
&TestEntryInfo::shared_option, &TestEntryInfo::shared_option,
&MapStringToSharedOption); &MapStringToSharedOption);
converter->RegisterCustomField("last_modified_time", converter->RegisterCustomField("lastModifiedTime",
&TestEntryInfo::last_modified_time, &TestEntryInfo::last_modified_time,
&MapStringToTime); &MapStringToTime);
} }
......
...@@ -2,6 +2,66 @@ ...@@ -2,6 +2,66 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
'use strict';
/**
* @enum {string}
* @const
*/
var EntryType = Object.freeze({
FILE: 'file',
DIRECTORY: 'directory'
});
/**
* @enum {string}
* @const
*/
var SharedOption = Object.freeze({
NONE: 'none',
SHARED: 'shared'
});
/**
* File system entry information for tests.
*
* @param {EntryType} entryType Entry type.
* @param {string} sourceFileName Source file name that provides file contents.
* @param {string} targetName Name of entry on the test file system.
* @param {string} mimeType Mime type.
* @param {string} typeText Type name to be shown in the type column.
* @param {string} sizeText Size text to be shown in the size column.
* @param {SharedOption} sharedOption Shared option.
* @param {string} lastModifiedTime Last modified time as a text to be shown in
* the last modified column.
* @constructor
*/
var TestEntryInfo = function(entryType,
sourceFileName,
targetName,
mimeType,
typeText,
sizeText,
sharedOption,
lastModifiedTime) {
this.entryType = entryType;
this.sourceFileName = sourceFileName;
this.targetName = targetName;
this.mimeType = mimeType;
this.typeText = typeText;
this.sizeText = sizeText;
this.sharedOption = sharedOption;
this.lastModifiedTime = lastModifiedTime;
Object.freeze(this);
};
/**
* Obtains a expected row contents of the file in the file list.
*/
TestEntryInfo.prototype.getExpectedRow = function() {
return [this.targetName, this.sizeText, this.typeText, this.lastModifiedTime];
};
/** /**
* Expected files before tests are performed. Entries for Local tests. * Expected files before tests are performed. Entries for Local tests.
* @type {Array.<Array.<string>>} * @type {Array.<Array.<string>>}
...@@ -34,13 +94,16 @@ var EXPECTED_FILES_BEFORE_DRIVE = [ ...@@ -34,13 +94,16 @@ var EXPECTED_FILES_BEFORE_DRIVE = [
].sort(); ].sort();
/** /**
* Expected files added during some tests. * Filesystem entries used by the test cases.
* @type {Array.<Array.<string>>} * @type {Object.<string, TestEntryInfo>}
* @const * @const
*/ */
var EXPECTED_NEWLY_ADDED_FILE = [ var ENTRIES = {
['newly added file.ogg', '14 KB', 'OGG audio', 'Sep 4, 1998 12:00 AM'] newlyAdded: new TestEntryInfo(
]; EntryType.FILE, 'music.ogg', 'newly added file.ogg',
'audio/ogg', 'OGG audio', '14 KB', SharedOption.NONE,
'Sep 4, 1998 12:00 AM')
};
/** /**
* @param {boolean} isDrive True if the test is for Drive. * @param {boolean} isDrive True if the test is for Drive.
...@@ -166,7 +229,7 @@ testcase.intermediate.fileDisplay = function(path) { ...@@ -166,7 +229,7 @@ testcase.intermediate.fileDisplay = function(path) {
var expectedFilesBefore = getExpectedFilesBefore(path == '/drive/root'); var expectedFilesBefore = getExpectedFilesBefore(path == '/drive/root');
var expectedFilesAfter = var expectedFilesAfter =
expectedFilesBefore.concat(EXPECTED_NEWLY_ADDED_FILE).sort(); expectedFilesBefore.concat([ENTRIES.newlyAdded.getExpectedRow()]).sort();
StepsRunner.run([ StepsRunner.run([
function() { function() {
...@@ -177,14 +240,7 @@ testcase.intermediate.fileDisplay = function(path) { ...@@ -177,14 +240,7 @@ testcase.intermediate.fileDisplay = function(path) {
function(inAppId, actualFilesBefore) { function(inAppId, actualFilesBefore) {
appId = inAppId; appId = inAppId;
chrome.test.assertEq(expectedFilesBefore, actualFilesBefore); chrome.test.assertEq(expectedFilesBefore, actualFilesBefore);
addEntries(['local', 'drive'], [{ addEntries(['local', 'drive'], [ENTRIES.newlyAdded], this.next);
type: 'file',
source_file_name: 'music.ogg',
target_name: 'newly added file.ogg',
mime_type: 'audio/ogg',
shared_option: 'none',
last_modified_time: '4 Sep 1998 00:00:00'
}], this.next);
}, },
function(result) { function(result) {
chrome.test.assertTrue(result); chrome.test.assertTrue(result);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment