diff --git a/test/gui/shared/scripts/helpers/FilesHelper.py b/test/gui/shared/scripts/helpers/FilesHelper.py index 34bd808e6b8..52db0017636 100644 --- a/test/gui/shared/scripts/helpers/FilesHelper.py +++ b/test/gui/shared/scripts/helpers/FilesHelper.py @@ -1,5 +1,6 @@ import os import re +import ctypes def buildConflictedRegex(filename): @@ -78,3 +79,10 @@ def get_size_in_bytes(size): return size_num * (multiplier**3) raise Exception("Invalid size: " + size) + + +def get_file_size_on_disk(resource_path): + file_size_high = ctypes.c_ulonglong(0) + return ctypes.windll.kernel32.GetCompressedFileSizeW( + ctypes.c_wchar_p(resource_path), ctypes.pointer(file_size_high) + ) diff --git a/test/gui/shared/steps/file_context.py b/test/gui/shared/steps/file_context.py index 0c41dc93d8c..2c62fcdb1ab 100644 --- a/test/gui/shared/steps/file_context.py +++ b/test/gui/shared/steps/file_context.py @@ -19,6 +19,7 @@ read_file_content, is_empty_sync_folder, get_size_in_bytes, + get_file_size_on_disk, ) from helpers.SetupClientHelper import ( getTempResourcePath, @@ -347,3 +348,26 @@ def step(context, username, zip_file_name): destination_dir = getResourcePath('/', username) zip_file_path = join(destination_dir, zip_file_name) extractZip(zip_file_path, destination_dir) + + +@Then('the placeholder of file "|any|" should exist on the file system') +def step(context, file_name): + resource_path = getResourcePath(file_name) + size_on_disk = get_file_size_on_disk(resource_path) + if isWindows(): + test.compare( + size_on_disk, 0, f"Size of the placeholder on the disk is: '{size_on_disk}'" + ) + + +@Then('the file "|any|" should be downloaded') +def step(context, file_name): + resource_path = getResourcePath(file_name) + size_on_disk = get_file_size_on_disk(resource_path) + file_size = os.stat(resource_path).st_size + if isWindows(): + test.compare( + size_on_disk, + file_size, + f"Size of original file: '{file_size}' is not equal to it's size on disk '{size_on_disk}'", + ) diff --git a/test/gui/tst_vfs/test.feature b/test/gui/tst_vfs/test.feature index f15a5cbe0c7..236cd306729 100644 --- a/test/gui/tst_vfs/test.feature +++ b/test/gui/tst_vfs/test.feature @@ -8,8 +8,23 @@ Feature: Enable/disable virtual file support Scenario: Disable/Enable VFS Given user "Alice" has been created on the server with default attributes and without skeleton files + And user "Alice" has uploaded file with content "ownCloud" to "testFile.txt" in the server + And user "Alice" has created folder "folder1" in the server + And user "Alice" has uploaded file with content "some contents" to "folder1/lorem.txt" in the server And user "Alice" has set up a client with default settings + Then the placeholder of file "testFile.txt" should exist on the file system + And the placeholder of file "folder1/lorem.txt" should exist on the file system When the user disables virtual file support Then the "Enable virtual file support..." button should be available + And the file "testFile.txt" should exist on the file system with the following content + """ + ownCloud + """ + And the file "folder1/lorem.txt" should exist on the file system with the following content + """ + some contents + """ + And the file "testFile.txt" should be downloaded + And the file "folder1/lorem.txt" should be downloaded When the user enables virtual file support - Then the "Disable virtual file support..." button should be available \ No newline at end of file + Then the "Disable virtual file support..." button should be available