2024-11-04 22:34:22 +00:00
|
|
|
//
|
2024-11-28 16:31:17 +00:00
|
|
|
// AppContext+Testing.swift
|
2024-11-04 22:34:22 +00:00
|
|
|
// Passepartout
|
|
|
|
//
|
2024-11-28 16:31:17 +00:00
|
|
|
// Created by Davide De Rosa on 11/28/24.
|
2024-11-04 22:34:22 +00:00
|
|
|
// Copyright (c) 2024 Davide De Rosa. All rights reserved.
|
|
|
|
//
|
|
|
|
// https://github.com/passepartoutvpn
|
|
|
|
//
|
|
|
|
// This file is part of Passepartout.
|
|
|
|
//
|
|
|
|
// Passepartout 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.
|
|
|
|
//
|
|
|
|
// Passepartout 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 Passepartout. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
//
|
|
|
|
|
|
|
|
import CommonLibrary
|
|
|
|
import CommonUtils
|
|
|
|
import Foundation
|
|
|
|
import PassepartoutKit
|
2024-11-28 16:31:17 +00:00
|
|
|
import UILibrary
|
2024-11-04 22:34:22 +00:00
|
|
|
|
|
|
|
extension AppContext {
|
2024-11-28 16:31:17 +00:00
|
|
|
static func forUITesting(withRegistry registry: Registry) -> AppContext {
|
2024-12-08 17:56:39 +00:00
|
|
|
let dependencies: Dependencies = .shared
|
2024-11-04 22:34:22 +00:00
|
|
|
let iapManager = IAPManager(
|
2024-11-28 14:51:03 +00:00
|
|
|
customUserLevel: .subscriber,
|
2024-12-08 17:56:39 +00:00
|
|
|
inAppHelper: dependencies.appProductHelper(),
|
2024-11-20 17:05:47 +00:00
|
|
|
receiptReader: FakeAppReceiptReader(),
|
2024-11-21 17:57:32 +00:00
|
|
|
betaChecker: TestFlightChecker(),
|
2024-11-04 22:34:22 +00:00
|
|
|
productsAtBuild: { _ in
|
|
|
|
[]
|
|
|
|
}
|
|
|
|
)
|
2024-12-08 17:56:39 +00:00
|
|
|
let processor = dependencies.appProcessor(with: iapManager)
|
|
|
|
let profileManager: ProfileManager = .forUITesting(
|
|
|
|
withRegistry: dependencies.registry,
|
2024-11-28 16:31:17 +00:00
|
|
|
processor: processor
|
2024-11-04 22:34:22 +00:00
|
|
|
)
|
|
|
|
let tunnelEnvironment = InMemoryEnvironment()
|
|
|
|
let tunnel = ExtendedTunnel(
|
|
|
|
tunnel: Tunnel(strategy: FakeTunnelStrategy(environment: tunnelEnvironment)),
|
|
|
|
environment: tunnelEnvironment,
|
|
|
|
processor: processor,
|
|
|
|
interval: Constants.shared.tunnel.refreshInterval
|
|
|
|
)
|
|
|
|
let providerManager = ProviderManager(
|
|
|
|
repository: InMemoryProviderRepository()
|
|
|
|
)
|
2024-11-14 10:02:26 +00:00
|
|
|
let migrationManager = MigrationManager()
|
2024-12-08 17:56:39 +00:00
|
|
|
let preferencesManager = PreferencesManager()
|
2024-11-28 16:31:17 +00:00
|
|
|
|
2024-11-04 22:34:22 +00:00
|
|
|
return AppContext(
|
|
|
|
iapManager: iapManager,
|
2024-11-14 10:02:26 +00:00
|
|
|
migrationManager: migrationManager,
|
2024-11-04 22:34:22 +00:00
|
|
|
profileManager: profileManager,
|
2024-11-14 10:02:26 +00:00
|
|
|
providerManager: providerManager,
|
2024-12-08 17:56:39 +00:00
|
|
|
preferencesManager: preferencesManager,
|
2024-11-14 10:02:26 +00:00
|
|
|
registry: registry,
|
2024-11-17 10:34:43 +00:00
|
|
|
tunnel: tunnel,
|
|
|
|
tunnelReceiptURL: BundleConfiguration.urlForBetaReceipt
|
2024-11-04 22:34:22 +00:00
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|