Skip to content

Commit

Permalink
chore: Merge branch 'master' into bumpCI
Browse files Browse the repository at this point in the history
  • Loading branch information
adrien-coye committed Jan 8, 2024
2 parents dd1b27d + 145ad2d commit 4848b46
Show file tree
Hide file tree
Showing 8 changed files with 53 additions and 8 deletions.
3 changes: 2 additions & 1 deletion Project.swift
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,8 @@ let project = Project(name: "kDrive",
dependencies: [
.target(name: "kDrive"),
.target(name: "kDriveCore")
]),
],
settings: .settings(base: Constants.testSettings)),
Target(name: "kDriveResources",
platform: .iOS,
product: .staticLibrary,
Expand Down
4 changes: 4 additions & 0 deletions Tuist/ProjectDescriptionHelpers/Constants.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@
import ProjectDescription

public enum Constants {
public static let testSettings: [String: SettingValue] = [
"SWIFT_ACTIVE_COMPILATION_CONDITIONS": "TEST DEBUG"
]

public static let baseSettings = SettingsDictionary()
.automaticCodeSigning(devTeam: "864VDCS2QY")
.currentProjectVersion("1")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@ class FileListViewController: UIViewController, UICollectionViewDataSource, Swip

navigationController?.setInfomaniakAppearanceNavigationBar()

guard viewModel != nil else { return }
#if !ISEXTENSION
let plusButtonDirectory: File
if viewModel.currentDirectory.id >= DriveFileManager.constants.rootID {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ class FileListViewModel: SelectDelegate {
/// Internal realm collection of Files observed
///
/// They should be frozen by convention.
#if DEBUG
#if DEBUG || TEST
var _frozenFiles = AnyRealmCollection(List<File>()) {
willSet {
for item in newValue {
Expand Down
3 changes: 3 additions & 0 deletions kDrive/UI/Controller/MainTabViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ class MainTabViewController: UITabBarController, Restorable {
let homeViewController = HomeViewController(driveFileManager: driveFileManager)
let navigationViewController = TitleSizeAdjustingNavigationController(rootViewController: homeViewController)
navigationViewController.navigationBar.prefersLargeTitles = true
navigationViewController.restorationIdentifier = String(describing: HomeViewController.self)
navigationViewController.tabBarItem.accessibilityLabel = KDriveResourcesStrings.Localizable.homeTitle
navigationViewController.tabBarItem.image = KDriveResourcesAsset.house.image
navigationViewController.tabBarItem.selectedImage = KDriveResourcesAsset.houseFill.image
Expand All @@ -111,6 +112,7 @@ class MainTabViewController: UITabBarController, Restorable {
let menuViewController = MenuViewController(driveFileManager: driveFileManager)
let navigationViewController = TitleSizeAdjustingNavigationController(rootViewController: menuViewController)
let (placeholder, placeholderSelected) = generateProfileTabImages(image: KDriveResourcesAsset.placeholderAvatar.image)
navigationViewController.restorationIdentifier = String(describing: MenuViewController.self)
navigationViewController.tabBarItem.accessibilityLabel = KDriveResourcesStrings.Localizable.menuTitle
navigationViewController.tabBarItem.image = placeholder
navigationViewController.tabBarItem.selectedImage = placeholderSelected
Expand All @@ -120,6 +122,7 @@ class MainTabViewController: UITabBarController, Restorable {
private static func initRootViewController(with viewModel: FileListViewModel) -> UIViewController {
let fileListViewController = FileListViewController.instantiate(viewModel: viewModel)
let navigationViewController = TitleSizeAdjustingNavigationController(rootViewController: fileListViewController)
navigationViewController.restorationIdentifier = String(describing: type(of: viewModel))
navigationViewController.navigationBar.prefersLargeTitles = true
navigationViewController.tabBarItem.accessibilityLabel = viewModel.title
navigationViewController.tabBarItem.image = viewModel.configuration.tabBarIcon.image
Expand Down
2 changes: 1 addition & 1 deletion kDrive/Utils/MatomoUtils.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import MatomoTracker
class MatomoUtils {
static let shared: MatomoTracker = {
let tracker = MatomoTracker(siteId: "8", baseURL: URLConstants.matomo.url)
#if DEBUG
#if DEBUG || TEST
tracker.isOptedOut = true
#endif
@InjectService var accountManager: AccountManageable
Expand Down
10 changes: 5 additions & 5 deletions kDriveCore/Utils/Logging.swift
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public enum Logging {
]
SentryDebug.capture(error: error, context: context, contextKey: "Realm")

#if DEBUG
#if DEBUG && !TEST
copyDebugInformations()
DDLogError(
"Realm files \(realmConfiguration.fileURL?.lastPathComponent ?? "") will be deleted to prevent migration error for next launch"
Expand Down Expand Up @@ -79,9 +79,9 @@ public enum Logging {
}

private static func initNetworkLogging() {
#if DEBUG
#if DEBUG && !TEST
if !Bundle.main.isExtension {
// Atlantis.start(hostName: ProcessInfo.processInfo.environment["hostname"])
Atlantis.start(hostName: ProcessInfo.processInfo.environment["hostname"])
}
#endif
}
Expand All @@ -95,7 +95,7 @@ public enum Logging {
"AppLock enabled": UserDefaults.shared.isAppLockEnabled,
"Wifi only enabled": UserDefaults.shared.isWifiOnly
]
#if DEBUG
#if DEBUG || TEST
return nil
#else
return event
Expand All @@ -105,7 +105,7 @@ public enum Logging {
}

private static func copyDebugInformations() {
#if DEBUG
#if DEBUG && !TEST
guard !Bundle.main.isExtension else { return }
let fileManager = FileManager.default
let debugDirectory = (fileManager.urls(for: .documentDirectory, in: .userDomainMask).first?.appendingPathComponent(
Expand Down
36 changes: 36 additions & 0 deletions kDriveTestShared/TestsPreconditions.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
Infomaniak Mail - iOS App
Copyright (C) 2022 Infomaniak Network SA
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

import XCTest

/// Sanity checks of SWIFT_ACTIVE_COMPILATION_CONDITIONS
final class TestsPreconditions: XCTestCase {
func testTestFlagIsSet() {
// WHEN
#if !TEST
XCTFail("the TEST flag is expected to be set in test target")
#endif
}

func testDebugFlagIsSet() {
// WHEN
#if !DEBUG
XCTFail("the DEBUG flag is expected to be set in test target")
#endif
}
}

0 comments on commit 4848b46

Please sign in to comment.