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
47 changes: 47 additions & 0 deletions Nextcloud.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,19 @@
AFCE353527E4ED5900FEA6C2 /* DateFormatter+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = AFCE353427E4ED5900FEA6C2 /* DateFormatter+Extension.swift */; };
AFCE353727E4ED7B00FEA6C2 /* NCShareCells.swift in Sources */ = {isa = PBXBuildFile; fileRef = AFCE353627E4ED7B00FEA6C2 /* NCShareCells.swift */; };
AFCE353927E5DE0500FEA6C2 /* Shareable.swift in Sources */ = {isa = PBXBuildFile; fileRef = AFCE353827E5DE0400FEA6C2 /* Shareable.swift */; };
AFCE353927E5DE0500FEA6C2 /* NCShare+Helper.swift in Sources */ = {isa = PBXBuildFile; fileRef = AFCE353827E5DE0400FEA6C2 /* NCShare+Helper.swift */; };
B54315362DA64EB100981E7E /* PrivacyPolicyTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = B54315352DA64EB100981E7E /* PrivacyPolicyTest.swift */; };
B54315412DA669C700981E7E /* InitialPrivacySettingsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = B54315392DA669C700981E7E /* InitialPrivacySettingsViewController.swift */; };
B54315422DA669C700981E7E /* RequiredDataCollectionSwitch.swift in Sources */ = {isa = PBXBuildFile; fileRef = B543153D2DA669C700981E7E /* RequiredDataCollectionSwitch.swift */; };
B54315432DA669C700981E7E /* PrivacySettingsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = B543153C2DA669C700981E7E /* PrivacySettingsViewController.swift */; };
B54315442DA669C700981E7E /* AnalysisDataCollectionSwitch.swift in Sources */ = {isa = PBXBuildFile; fileRef = B54315372DA669C700981E7E /* AnalysisDataCollectionSwitch.swift */; };
B54315452DA669C700981E7E /* PrivacyPolicyViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = B543153B2DA669C700981E7E /* PrivacyPolicyViewController.swift */; };
B54315462DA669C700981E7E /* SaveSettingsCustomButtonCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = B543153F2DA669C700981E7E /* SaveSettingsCustomButtonCell.swift */; };
B54315472DA669C700981E7E /* AnalysisDataCollectionSwitch.xib in Resources */ = {isa = PBXBuildFile; fileRef = B54315382DA669C700981E7E /* AnalysisDataCollectionSwitch.xib */; };
B54315482DA669C700981E7E /* NCSettings.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = B543153A2DA669C700981E7E /* NCSettings.storyboard */; };
B54315492DA669C700981E7E /* SaveSettingsCustomButtonCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = B54315402DA669C700981E7E /* SaveSettingsCustomButtonCell.xib */; };
B543154A2DA669C700981E7E /* RequiredDataCollectionSwitch.xib in Resources */ = {isa = PBXBuildFile; fileRef = B543153E2DA669C700981E7E /* RequiredDataCollectionSwitch.xib */; };
C04E2F232A17BB4D001BAD85 /* FilesIntegrationTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C04E2F222A17BB4D001BAD85 /* FilesIntegrationTests.swift */; };
D575039F27146F93008DC9DC /* String+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = F7A0D1342591FBC5008F8A13 /* String+Extension.swift */; };
D5B6AA7827200C7200D49C24 /* NCActivityTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = D5B6AA7727200C7200D49C24 /* NCActivityTableViewCell.swift */; };
F310B1EF2BA862F1001C42F5 /* NCViewerMedia+VisionKit.swift in Sources */ = {isa = PBXBuildFile; fileRef = F310B1EE2BA862F1001C42F5 /* NCViewerMedia+VisionKit.swift */; };
Expand Down Expand Up @@ -1319,6 +1332,18 @@
AFCE353427E4ED5900FEA6C2 /* DateFormatter+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "DateFormatter+Extension.swift"; sourceTree = "<group>"; };
AFCE353627E4ED7B00FEA6C2 /* NCShareCells.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NCShareCells.swift; sourceTree = "<group>"; };
AFCE353827E5DE0400FEA6C2 /* Shareable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Shareable.swift; sourceTree = "<group>"; };
AFCE353827E5DE0400FEA6C2 /* NCShare+Helper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "NCShare+Helper.swift"; sourceTree = "<group>"; };
B54315352DA64EB100981E7E /* PrivacyPolicyTest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PrivacyPolicyTest.swift; sourceTree = "<group>"; };
B54315372DA669C700981E7E /* AnalysisDataCollectionSwitch.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AnalysisDataCollectionSwitch.swift; sourceTree = "<group>"; };
B54315382DA669C700981E7E /* AnalysisDataCollectionSwitch.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = AnalysisDataCollectionSwitch.xib; sourceTree = "<group>"; };
B54315392DA669C700981E7E /* InitialPrivacySettingsViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InitialPrivacySettingsViewController.swift; sourceTree = "<group>"; };
B543153A2DA669C700981E7E /* NCSettings.storyboard */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; path = NCSettings.storyboard; sourceTree = "<group>"; };
B543153B2DA669C700981E7E /* PrivacyPolicyViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PrivacyPolicyViewController.swift; sourceTree = "<group>"; };
B543153C2DA669C700981E7E /* PrivacySettingsViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PrivacySettingsViewController.swift; sourceTree = "<group>"; };
B543153D2DA669C700981E7E /* RequiredDataCollectionSwitch.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RequiredDataCollectionSwitch.swift; sourceTree = "<group>"; };
B543153E2DA669C700981E7E /* RequiredDataCollectionSwitch.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = RequiredDataCollectionSwitch.xib; sourceTree = "<group>"; };
B543153F2DA669C700981E7E /* SaveSettingsCustomButtonCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SaveSettingsCustomButtonCell.swift; sourceTree = "<group>"; };
B54315402DA669C700981E7E /* SaveSettingsCustomButtonCell.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = SaveSettingsCustomButtonCell.xib; sourceTree = "<group>"; };
C0046CDA2A17B98400D87C9D /* NextcloudUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = NextcloudUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
C04E2F202A17BB4D001BAD85 /* NextcloudIntegrationTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = NextcloudIntegrationTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
D5B6AA7727200C7200D49C24 /* NCActivityTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NCActivityTableViewCell.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -2096,6 +2121,8 @@
isa = PBXGroup;
children = (
AA52EB452D42AC5A0089C348 /* Placeholder.swift */,
B54315352DA64EB100981E7E /* PrivacyPolicyTest.swift */,
AF8ED1FB2757821000B8DBC4 /* NextcloudUnitTests.swift */,
);
path = NextcloudUnitTests;
sourceTree = "<group>";
Expand Down Expand Up @@ -2559,6 +2586,16 @@
F76882042C0DD1E7001CF441 /* Settings */ = {
isa = PBXGroup;
children = (
B54315372DA669C700981E7E /* AnalysisDataCollectionSwitch.swift */,
B54315382DA669C700981E7E /* AnalysisDataCollectionSwitch.xib */,
B54315392DA669C700981E7E /* InitialPrivacySettingsViewController.swift */,
B543153A2DA669C700981E7E /* NCSettings.storyboard */,
B543153B2DA669C700981E7E /* PrivacyPolicyViewController.swift */,
B543153C2DA669C700981E7E /* PrivacySettingsViewController.swift */,
B543153D2DA669C700981E7E /* RequiredDataCollectionSwitch.swift */,
B543153E2DA669C700981E7E /* RequiredDataCollectionSwitch.xib */,
B543153F2DA669C700981E7E /* SaveSettingsCustomButtonCell.swift */,
B54315402DA669C700981E7E /* SaveSettingsCustomButtonCell.xib */,
F768820B2C0DD1E7001CF441 /* Settings */,
F76882162C0DD1E7001CF441 /* AutoUpload */,
F768821C2C0DD1E7001CF441 /* Display */,
Expand Down Expand Up @@ -3943,6 +3980,10 @@
3704EB2A23D5A58400455C5B /* NCMenu.storyboard in Resources */,
AF93471C27E2361E002537EE /* NCShareHeader.xib in Resources */,
F75D901F2D2BE12E003E740B /* NCRecommendationsCell.xib in Resources */,
B54315472DA669C700981E7E /* AnalysisDataCollectionSwitch.xib in Resources */,
B54315482DA669C700981E7E /* NCSettings.storyboard in Resources */,
B54315492DA669C700981E7E /* SaveSettingsCustomButtonCell.xib in Resources */,
B543154A2DA669C700981E7E /* RequiredDataCollectionSwitch.xib in Resources */,
F76032A0252F0F8E0015A421 /* NCTransferCell.xib in Resources */,
F7F4F10527ECDBDB008676F9 /* Inconsolata-SemiBold.ttf in Resources */,
F7A48415297028FC00BD1B49 /* Nextcloud Hub.png in Resources */,
Expand Down Expand Up @@ -4578,6 +4619,12 @@
F72408332B8A27C900F128E2 /* NCMedia+Command.swift in Sources */,
F755CB402B8CB13C00CE27E9 /* NCMediaLayout.swift in Sources */,
F73EF7B72B0224AB0087E6E9 /* NCManageDatabase+ExternalSites.swift in Sources */,
B54315412DA669C700981E7E /* InitialPrivacySettingsViewController.swift in Sources */,
B54315422DA669C700981E7E /* RequiredDataCollectionSwitch.swift in Sources */,
B54315432DA669C700981E7E /* PrivacySettingsViewController.swift in Sources */,
B54315442DA669C700981E7E /* AnalysisDataCollectionSwitch.swift in Sources */,
B54315452DA669C700981E7E /* PrivacyPolicyViewController.swift in Sources */,
B54315462DA669C700981E7E /* SaveSettingsCustomButtonCell.swift in Sources */,
AF4BF61927562A4B0081CEEF /* NCManageDatabase+Metadata.swift in Sources */,
F73EF7E72B0226B90087E6E9 /* NCManageDatabase+UserStatus.swift in Sources */,
F78A18B623CDD07D00F681F3 /* NCViewerRichWorkspaceWebView.swift in Sources */,
Expand Down
154 changes: 154 additions & 0 deletions Tests/NextcloudUnitTests/PrivacyPolicyTest.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
//
// PrivacyPolicyTest.swift
// NextcloudTests
//
// Created by A200073704 on 27/04/23.
// Copyright © 2023 Marino Faggiana. All rights reserved.
//

@testable import Nextcloud
import XCTest
import NextcloudKit
import XLForm


class PrivacyPolicyTest: XCTestCase {

var viewController: InitialPrivacySettingsViewController?
var privacySettingsView = PrivacySettingsViewController()

override func setUpWithError() throws {

// To Create an instance of UIStoryboard
let storyboard = UIStoryboard(name: "NCSettings", bundle: nil)

// To Instantiate UIViewController with Storyboard ID
viewController = storyboard.instantiateViewController(withIdentifier: "privacyPolicyViewController") as? InitialPrivacySettingsViewController

// Outlets are connected
let _ = viewController?.view

// Make the viewDidLoad() execute.
viewController?.loadViewIfNeeded()

}

override func tearDownWithError() throws {
viewController = nil
}

func testPrivacyPolicyViewControllerIsOpen() {

// Check that the InitialPrivacyPolicyViewController gets opened
let storyboard = UIStoryboard(name: "NCSettings", bundle: nil)
if let privacyPolicyViewController = storyboard.instantiateViewController(withIdentifier: "privacyPolicyViewController") as? InitialPrivacySettingsViewController {
let navigationController = UINavigationController(rootViewController: privacyPolicyViewController)

privacyPolicyViewController.loadViewIfNeeded()

XCTAssertTrue(navigationController.topViewController is InitialPrivacySettingsViewController, "Privacy policy view controller should be open")
}
}

func testTextViewHasCorrectText() {

//Check that the text displayed is correct
let expectedText = NSLocalizedString("_privacy_help_text_after_login_", comment: "")
viewController?.privacySettingsHelpText?.text = expectedText

let actualText = viewController?.privacySettingsHelpText?.text
XCTAssertEqual(actualText, expectedText, "The text view does not have the expected text")
}

func testHasAcceptButton() {

// Check that view has the accept button
let acceptButton = viewController?.acceptButton

XCTAssertNotNil(acceptButton, "View controller does not have an accept button")

}

func testSettingsLinkTypeNavigatesToPrivacySettingsViewController() {

// Simulate tapping the "Settings" link type
let linkType = LinkType.settings

UserDefaults.standard.set(true, forKey: "showSettingsButton")
viewController?.privacySettingsHelpText.hyperLink(originalText: viewController?.privacyHelpText ?? "", linkTextsAndTypes: [NSLocalizedString("_key_settings_help_", comment: ""): linkType.rawValue])

// Check that the correct view controller was pushed onto the navigation stack
XCTAssertNotNil(viewController?.navigationController?.visibleViewController is PrivacySettingsViewController)
}

func testPrivacyPolicyLinkType_NavigatesToPrivacyPolicyViewController() {

// Simulate tapping the "Privacy Policy" link type
let linkType = LinkType.privacyPolicy

viewController?.privacySettingsHelpText.hyperLink(originalText: viewController?.privacyHelpText ?? "", linkTextsAndTypes: [NSLocalizedString("_key_privacy_help_", comment: ""): linkType.rawValue])

// Check that the correct view controller was pushed onto the navigation
XCTAssertNotNil(viewController?.navigationController?.visibleViewController is PrivacyPolicyViewController)
}

func testCorrectImagePresentOnInitialPrivacySettingsViewController() {

// Check that the image view has the correct image
let expectedImage = UIImage(named: "dataPrivacy")
XCTAssertNotNil(expectedImage)
}

func testAcceptButtonHasBackgroundColor() {

// Check that the accept button has the correct background color
let expectedColor = NCBrandColor.shared.brand
XCTAssertEqual(viewController?.acceptButton.backgroundColor, expectedColor)

}

func testShowSaveSettingsButton() {

privacySettingsView.isShowSettingsButton = UserDefaults.standard.bool(forKey: "showSettingsButton")

XCTAssertTrue(privacySettingsView.isShowSettingsButton)

}

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

var section : XLFormSectionDescriptor
var row : XLFormRowDescriptor

// the section with the title "Required Data Collection"
row = XLFormRowDescriptor(tag: "ButtonDestinationFolder", rowType: "RequiredDataCollectionCustomCellType", title: "")
section = XLFormSectionDescriptor.formSection(withTitle: "")
section.footerTitle = NSLocalizedString("_required_data_collection_help_text_", comment: "")

// Verify that section was found
XCTAssertNotNil(row, "Expected 'Required Data Collection' section to exist in form.")
}

func testAnalysisDataCollectionSection() {

let form : XLFormDescriptor = XLFormDescriptor() as XLFormDescriptor
form.rowNavigationOptions = XLFormRowNavigationOptions.stopDisableRow
var section : XLFormSectionDescriptor
var row : XLFormRowDescriptor

// row with tag "AnalysisDataCollectionSwitch"
row = XLFormRowDescriptor(tag: "AnalysisDataCollectionSwitch", rowType: "AnalysisDataCollectionCustomCellType", title: "")
section = XLFormSectionDescriptor.formSection(withTitle: "")
section.footerTitle = NSLocalizedString("_analysis_data_acqusition_help_text_", comment: "")

// Assert that the row exists
XCTAssertNotNil(row, "Expected row with tag 'AnalysisDataCollectionSwitch' to exist in form.")

// Verify the switch is off
XCTAssertFalse(UserDefaults.standard.bool(forKey: "isAnalysisDataCollectionSwitchOn"), "Expected isAnalysisDataCollectionSwitchOn to be false.")
}


}
23 changes: 23 additions & 0 deletions iOSClient/Images.xcassets/dataPrivacy.imageset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"images" : [
{
"filename" : "default copy@2x.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "default copy@3x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "default copy@4x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,47 @@ extension NCCollectionViewCommon: UICollectionViewDelegateFlowLayout {
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, referenceSizeForFooterInSection section: Int) -> CGSize {
return sizeForFooterInSection(section: section)
}

func getHeaderHeight() -> CGFloat {

var size: CGFloat = 0
// transfer in progress
if headerMenuTransferView,
let metadata = NCManageDatabase.shared.getMetadataFromOcId(NCNetworking.shared.transferInForegorund?.ocId),
metadata.isTransferInForeground {
if !isSearchingMode {
size += NCGlobal.shared.heightHeaderTransfer
}
} else {
NCNetworking.shared.transferInForegorund = nil
}

if headerMenuButtonsView {
size += NCGlobal.shared.heightButtonsView
}

return size
}

func getHeaderHeight(section: Int) -> (heightHeaderCommands: CGFloat, heightHeaderRichWorkspace: CGFloat, heightHeaderSection: CGFloat) {

var headerRichWorkspace: CGFloat = 0

if let richWorkspaceText = richWorkspaceText, showDescription {
let trimmed = richWorkspaceText.trimmingCharacters(in: .whitespaces)
if !trimmed.isEmpty && !isSearchingMode {
headerRichWorkspace = UIScreen.main.bounds.size.height / 6
}
}

if isSearchingMode || layoutForView?.layout == NCGlobal.shared.layoutGrid || dataSource.numberOfSections() > 1 {
if section == 0 {
return (getHeaderHeight(), headerRichWorkspace, NCGlobal.shared.heightSection)
} else {
return (0, 0, NCGlobal.shared.heightSection)
}
} else {
return (getHeaderHeight(), headerRichWorkspace, 0)
}
}
}
Loading