This will ensure the filename length is valid.
function testFileValidateNameLength() {
// Create a new file object.
$file = new stdClass();
// Add a filename with an allowed length and test it.
$file->filename = str_repeat('x', 240);
$this
->assertEqual(strlen($file->filename), 240);
$errors = file_validate_name_length($file);
$this
->assertEqual(count($errors), 0, 'No errors reported for 240 length filename.', 'File');
// Add a filename with a length too long and test it.
$file->filename = str_repeat('x', 241);
$errors = file_validate_name_length($file);
$this
->assertEqual(count($errors), 1, 'An error reported for 241 length filename.', 'File');
// Add a filename with an empty string and test it.
$file->filename = '';
$errors = file_validate_name_length($file);
$this
->assertEqual(count($errors), 1, 'An error reported for 0 length filename.', 'File');
}