Skip to content

Commit

Permalink
nmc 2157 - move copy customisation
Browse files Browse the repository at this point in the history
  • Loading branch information
TSI-amrutwaghmare committed Nov 28, 2023
1 parent 2a9b9d8 commit 5dccb8c
Show file tree
Hide file tree
Showing 4 changed files with 444 additions and 151 deletions.
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")
}

}
2 changes: 0 additions & 2 deletions iOSClient/Main/Collection Common/NCListCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -223,15 +223,13 @@ class NCListCell: UICollectionViewCell, UIGestureRecognizerDelegate, NCCellProto
if status {
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 Down
Loading

0 comments on commit 5dccb8c

Please sign in to comment.