Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
142 changes: 142 additions & 0 deletions Tests/NextcloudUnitTests/CollaboraTestCase.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
//
// CollaboraTestCase.swift
// NextcloudTests
//
// Created by A200073704 on 06/05/23.
// Copyright © 2023 Marino Faggiana. All rights reserved.
//

@testable import Nextcloud
import XCTest
import NextcloudKit

class CollaboraTestCase: XCTestCase {


override func setUpWithError() throws {
// Put setup code here. This method is called before the invocation of each test method in the class.
}

override func tearDownWithError() throws {
// Put teardown code here. This method is called after the invocation of each test method in the class.
}

func testCollaboraDocumentIsPresent() {

var viewForDocument: NCMenuAction?

if let image = UIImage(named: "create_file_document") {
viewForDocument = NCMenuAction(title: NSLocalizedString("_create_new_document_", comment: ""), icon: image, action: { _ in
guard let navigationController = UIStoryboard(name: "NCCreateFormUploadDocuments", bundle: nil).instantiateInitialViewController() as? UINavigationController else {
return
}

let viewController = navigationController.topViewController as? NCCreateFormUploadDocuments
viewController?.titleForm = NSLocalizedString("_create_new_document_", comment: "")
})
}

XCTAssertNotNil(viewForDocument)

}

func testCollaboraPresentationIsPresent() {

var viewForPresentation: NCMenuAction?

if let image = UIImage(named: "create_file_ppt") {
viewForPresentation = NCMenuAction(title: NSLocalizedString("_create_new_presentation_", comment: ""), icon: image, action: { _ in
guard let navigationController = UIStoryboard(name: "NCCreateFormUploadDocuments", bundle: nil).instantiateInitialViewController() as? UINavigationController else {
return
}

let viewController = navigationController.topViewController as? NCCreateFormUploadDocuments
viewController?.titleForm = NSLocalizedString("_create_new_presentation_", comment: "")
})
}

XCTAssertNotNil(viewForPresentation)

}

func testCollaboraSpreadsheetIsPresent() {

var viewForSpreadsheet: NCMenuAction?

if let image = UIImage(named: "create_file_xls") {
viewForSpreadsheet = NCMenuAction(title: NSLocalizedString("_create_new_spreadsheet_", comment: ""), icon: image, action: { _ in
guard let navigationController = UIStoryboard(name: "NCCreateFormUploadDocuments", bundle: nil).instantiateInitialViewController() as? UINavigationController else {
return
}

let viewController = navigationController.topViewController as? NCCreateFormUploadDocuments
viewController?.titleForm = NSLocalizedString("_create_new_spreadsheet_", comment: "")
})
}

XCTAssertNotNil(viewForSpreadsheet)

}

func testTextDocumentIsPresent() {

var textMenu: NCMenuAction?

if let image = UIImage(named: "file_txt_menu") {
textMenu = NCMenuAction(title: NSLocalizedString("_create_nextcloudtext_document_", comment: ""), icon: image, action: { _ in
guard let navigationController = UIStoryboard(name: "NCCreateFormUploadDocuments", bundle: nil).instantiateInitialViewController() as? UINavigationController else {
return
}

let viewController = navigationController.topViewController as? NCCreateFormUploadDocuments
viewController?.titleForm = NSLocalizedString("_create_nextcloudtext_document_", comment: "")
})
}

XCTAssertNotNil(textMenu)

}

func testTextDocumentAction() {

let text = NCGlobal.shared.actionTextDocument
XCTAssertNotNil(text, "Text Editor Should be opened")
}

func testTextFieldIsPresent() {

let storyboard = UIStoryboard(name: "NCCreateFormUploadDocuments", bundle: nil)
guard let viewController = storyboard.instantiateInitialViewController() as? NCCreateFormUploadDocuments else {
return
}

// Verify that a text field is present in the view controller
let textFields = viewController.view.subviews.filter { $0 is UITextField }
XCTAssertFalse(textFields.isEmpty, "No text field found in NCCreateFormUploadDocuments")
}

func testSavePathFolder() {

let viewController = NCCreateFormUploadDocuments()

let form : XLFormDescriptor = XLFormDescriptor() as XLFormDescriptor
form.rowNavigationOptions = XLFormRowNavigationOptions.stopDisableRow

var row : XLFormRowDescriptor

// the section with the title "Folder Destination"

row = XLFormRowDescriptor(tag: "ButtonDestinationFolder", rowType: "kNMCFolderCustomCellType", title: "")
row.action.formSelector = #selector(viewController.changeDestinationFolder(_:))

// Verify that section was found
XCTAssertNotNil(row, "Expected save path section to exist in form.")

}






}
2 changes: 1 addition & 1 deletion iOSClient/BrowserWeb/NCBrowserWeb.swift
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class NCBrowserWeb: UIViewController {
buttonExit.isHidden = true
} else {
self.view.bringSubviewToFront(buttonExit)
let image = NCUtility().loadImage(named: "xmark", color: .systemBlue)
let image = NCUtility().loadImage(named: "xmark", color: NCBrandColor.shared.customer)
buttonExit.setImage(image, for: .normal)
}

Expand Down
9 changes: 8 additions & 1 deletion iOSClient/Data/NCManageDatabase+Metadata.swift
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,14 @@ extension NCManageDatabase {
metadata.fileNameView = file.fileName
metadata.hasPreview = file.hasPreview
metadata.hidden = file.hidden
metadata.iconName = file.iconName
switch (file.fileName as NSString).pathExtension {
case "odg":
metadata.iconName = "diagram"
case "csv", "xlsm" :
metadata.iconName = "file_xls"
default:
metadata.iconName = file.iconName
}
metadata.mountType = file.mountType
metadata.name = file.name
metadata.note = file.note
Expand Down
Loading