From 2035ccb701c1b5e6fe1c8314e114b30b1e8e3dfb Mon Sep 17 00:00:00 2001 From: TSI-amrutwaghmare <96108296+TSI-amrutwaghmare@users.noreply.github.com> Date: Tue, 28 Nov 2023 11:37:14 +0530 Subject: [PATCH 1/2] nmc 2157 - move copy customisation --- .../NextcloudUnitTests/MoveAndCopyTests.swift | 106 ++++++++++++++++ .../Collection Common/Cell/NCListCell.swift | 2 - .../Select/NCSelectCommandViewCopyMove.xib | 113 +++++++++--------- 3 files changed, 164 insertions(+), 57 deletions(-) create mode 100644 Tests/NextcloudUnitTests/MoveAndCopyTests.swift diff --git a/Tests/NextcloudUnitTests/MoveAndCopyTests.swift b/Tests/NextcloudUnitTests/MoveAndCopyTests.swift new file mode 100644 index 0000000000..bd674a472f --- /dev/null +++ b/Tests/NextcloudUnitTests/MoveAndCopyTests.swift @@ -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") + } + +} diff --git a/iOSClient/Main/Collection Common/Cell/NCListCell.swift b/iOSClient/Main/Collection Common/Cell/NCListCell.swift index a10822b210..2a4b969296 100755 --- a/iOSClient/Main/Collection Common/Cell/NCListCell.swift +++ b/iOSClient/Main/Collection Common/Cell/NCListCell.swift @@ -206,7 +206,6 @@ 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 @@ -214,7 +213,6 @@ class NCListCell: UICollectionViewCell, UIGestureRecognizerDelegate, NCCellProto } else { imageItemLeftConstraint.constant = 10 imageSelect.isHidden = true - imageShared.isHidden = false imageMore.isHidden = false buttonShared.isHidden = false buttonMore.isHidden = false diff --git a/iOSClient/Select/NCSelectCommandViewCopyMove.xib b/iOSClient/Select/NCSelectCommandViewCopyMove.xib index ddf3475d85..4941320594 100644 --- a/iOSClient/Select/NCSelectCommandViewCopyMove.xib +++ b/iOSClient/Select/NCSelectCommandViewCopyMove.xib @@ -1,9 +1,9 @@ - - + + - + @@ -11,115 +11,118 @@ - - + + - - + + - + - - + + - + - + - - - - - - - - - - - - + + + + + + + + + + + + + + - + - - - - - - + + + + + + - - - - - - - + + + + + + + + From b006e4f600ed896c5b68d65242dc2c2201ea2c8b Mon Sep 17 00:00:00 2001 From: TSI-amrutwaghmare <96108296+TSI-amrutwaghmare@users.noreply.github.com> Date: Fri, 12 Apr 2024 16:07:35 +0530 Subject: [PATCH 2/2] NMC 2157 - size lable upated after nextcloud 5.2.2 release --- iOSClient/Main/Collection Common/Cell/NCListCell.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/iOSClient/Main/Collection Common/Cell/NCListCell.swift b/iOSClient/Main/Collection Common/Cell/NCListCell.swift index 2a4b969296..ae0e75b0b6 100755 --- a/iOSClient/Main/Collection Common/Cell/NCListCell.swift +++ b/iOSClient/Main/Collection Common/Cell/NCListCell.swift @@ -238,7 +238,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) {