Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NMC/2157 - move copy #120

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
106 changes: 106 additions & 0 deletions Tests/NextcloudUnitTests/MoveAndCopyTests.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
//
// MoveAndCopyTests.swift
// NextcloudTests
//
// Created by A200073704 on 05/06/23.
// Copyright © 2023 Marino Faggiana. All rights reserved.
//

@testable import Nextcloud
import XCTest
import NextcloudKit


class MoveAndCopyTests: XCTestCase {

var view : NCSelectCommandView?
var viewController : NCSelect?

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

let storyboard = UIStoryboard(name: "NCSelect", bundle: nil)
if let navigationController = storyboard.instantiateInitialViewController() as? UINavigationController {
let viewController = navigationController.topViewController as? NCSelect

let _ = viewController?.view
viewController?.loadViewIfNeeded()
}
view = NCSelectCommandView()

}

override func setUp() {
super.setUp()
let nib = Bundle.main.loadNibNamed("NCSelectCommandViewCopyMove", owner: nil, options: nil)
view = nib?.first as? NCSelectCommandView
}

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

viewController = nil
view = nil

}

func testCreateFolderButton() {

let image: Void? = view?.createFolderButton?.setImage(UIImage(named: "addFolder")?.withTintColor(UIColor.label), for: .normal)

XCTAssertNotNil(image)
}

func testOverwriteSwitch() {

let mySwitch = view?.overwriteSwitch

XCTAssertNotNil(mySwitch)

}

func testCopyButton() {

let copy = view?.copyButton

XCTAssertNotNil(copy)
}


func testOverwriteSwitchAlwaysOn() {

XCTAssertTrue(view?.overwriteSwitch?.isOn ?? false, "Overwrite Switch should always be on")
}

func testCopyButtonandMoveButtonCondition() {

// Disable copy and move
view?.copyButton?.isEnabled = false
view?.moveButton?.isEnabled = false

// Creating a test item
let item = tableMetadata()
item.serverUrl = "serverUrl" // Set the serverUrl property of the item

let items: [tableMetadata] = [item]

// Update the items in the view controller
viewController?.items = items

// Verify that the copy and move buttons are still disabled
XCTAssertFalse(view?.copyButton?.isEnabled ?? true, "Copy Button should remain disabled when items.first matches the condition")
XCTAssertFalse(view?.moveButton?.isEnabled ?? true, "Move Button should remain disabled when items.first matches the condition")

// Enable copy and move
view?.copyButton?.isEnabled = true
view?.moveButton?.isEnabled = true

// Update the items in the view controller
viewController?.items = [] // Empty items

// Verify that the copyButton is still enabled
XCTAssertTrue(view?.copyButton?.isEnabled ?? false, "Copy Button should remain enabled when items.first doesn't match the condition")
XCTAssertTrue(view?.moveButton?.isEnabled ?? false, "Move Button should remain enabled when items.first doesn't match the condition")
}

}
4 changes: 1 addition & 3 deletions iOSClient/Main/Collection Common/Cell/NCListCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -224,15 +224,13 @@ class NCListCell: UICollectionViewCell, UIGestureRecognizerDelegate, NCCellProto
if isEditMode {
imageItemLeftConstraint.constant = 45
imageSelect.isHidden = false
imageShared.isHidden = true
imageMore.isHidden = true
buttonShared.isHidden = true
buttonMore.isHidden = true
accessibilityCustomActions = nil
} else {
imageItemLeftConstraint.constant = 10
imageSelect.isHidden = true
imageShared.isHidden = false
imageMore.isHidden = false
buttonShared.isHidden = false
buttonMore.isHidden = false
Expand All @@ -258,7 +256,7 @@ class NCListCell: UICollectionViewCell, UIGestureRecognizerDelegate, NCCellProto

func writeInfoDateSize(date: NSDate, size: Int64) {
labelInfo.text = NCUtility().dateDiff(date as Date)
labelSubinfo.text = " · " + NCUtilityFileSystem().transformedSize(size)
labelSubinfo.text = ""
}

func setAccessibility(label: String, value: String) {
Expand Down
Loading