From 1553dfc1d3625a6330553eb2434d18cd3db40375 Mon Sep 17 00:00:00 2001 From: Chris Brind Date: Mon, 18 Nov 2024 17:03:26 +0000 Subject: [PATCH] move mock to own file and fix compile error --- DuckDuckGo.xcodeproj/project.pbxproj | 4 +++ DuckDuckGoTests/MockFaviconStore.swift | 30 +++++++++++++++++++ .../OnboardingNavigationDelegateTests.swift | 9 ------ .../SyncBookmarksAdapterTests.swift | 3 +- 4 files changed, 36 insertions(+), 10 deletions(-) create mode 100644 DuckDuckGoTests/MockFaviconStore.swift diff --git a/DuckDuckGo.xcodeproj/project.pbxproj b/DuckDuckGo.xcodeproj/project.pbxproj index 8ba3aa3d27..cf4b10a7be 100644 --- a/DuckDuckGo.xcodeproj/project.pbxproj +++ b/DuckDuckGo.xcodeproj/project.pbxproj @@ -528,6 +528,7 @@ 8598D2E22CEB98B500C45685 /* FaviconRequestModifier.swift in Sources */ = {isa = PBXBuildFile; fileRef = 85CA53AB24BBD39300A6288C /* FaviconRequestModifier.swift */; }; 8598D2E32CEB98B500C45685 /* FaviconUserScript.swift in Sources */ = {isa = PBXBuildFile; fileRef = 85D2187A24BF9F85004373D2 /* FaviconUserScript.swift */; }; 8598D2E42CEB98B500C45685 /* FaviconSourcesProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = 85D2187524BF6164004373D2 /* FaviconSourcesProvider.swift */; }; + 8598D2E62CEBAA1F00C45685 /* MockFaviconStore.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8598D2E52CEBAA1B00C45685 /* MockFaviconStore.swift */; }; 8598F67B2405EB8D00FBC70C /* KeyboardSettingsTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8598F6792405EB8600FBC70C /* KeyboardSettingsTests.swift */; }; 8599690F29D2F1C100DBF9FA /* DDGSync in Frameworks */ = {isa = PBXBuildFile; productRef = 8599690E29D2F1C100DBF9FA /* DDGSync */; }; 859DB8132CE6263C001F7210 /* TextZoomStorage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 859DB80D2CE6263B001F7210 /* TextZoomStorage.swift */; }; @@ -1839,6 +1840,7 @@ 8596C30C2B7EB1800058EF90 /* DataStoreWarmup.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DataStoreWarmup.swift; sourceTree = ""; }; 8598D2DB2CEB93A600C45685 /* FaviconsCacheType.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FaviconsCacheType.swift; sourceTree = ""; }; 8598D2DD2CEB97BE00C45685 /* FaviconHasher.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FaviconHasher.swift; sourceTree = ""; }; + 8598D2E52CEBAA1B00C45685 /* MockFaviconStore.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MockFaviconStore.swift; sourceTree = ""; }; 8598F6792405EB8600FBC70C /* KeyboardSettingsTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KeyboardSettingsTests.swift; sourceTree = ""; }; 859DB80D2CE6263B001F7210 /* TextZoomStorage.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TextZoomStorage.swift; sourceTree = ""; }; 859DB80E2CE6263B001F7210 /* TextZoomController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TextZoomController.swift; sourceTree = ""; }; @@ -6072,6 +6074,7 @@ F17669A91E412A17003D3222 /* Mocks */ = { isa = PBXGroup; children = ( + 8598D2E52CEBAA1B00C45685 /* MockFaviconStore.swift */, 9F4CC51A2C48C0C7006A96EB /* MockTabDelegate.swift */, C14882E927F20DD000D59F0C /* MockBookmarksCoreDataStorage.swift */, C158AC7A297AB5DC0008723A /* MockSecureVault.swift */, @@ -8037,6 +8040,7 @@ F1134EBC1F40D45700B73467 /* MockStatisticsStore.swift in Sources */, 9FCFCD802C6AF56D006EB7A0 /* LaunchOptionsHandlerTests.swift in Sources */, 983C52E72C2C0ACB007B5747 /* BookmarkStateRepairTests.swift in Sources */, + 8598D2E62CEBAA1F00C45685 /* MockFaviconStore.swift in Sources */, 31C138AC27A403CB00FFD4B2 /* DownloadManagerTests.swift in Sources */, BDE219EA2C457B46005D5884 /* PrivacyProDataReporterTests.swift in Sources */, EEFE9C732A603CE9005B0A26 /* NetworkProtectionStatusViewModelTests.swift in Sources */, diff --git a/DuckDuckGoTests/MockFaviconStore.swift b/DuckDuckGoTests/MockFaviconStore.swift new file mode 100644 index 0000000000..087fbd4fb3 --- /dev/null +++ b/DuckDuckGoTests/MockFaviconStore.swift @@ -0,0 +1,30 @@ +// +// MockFaviconStore.swift +// DuckDuckGo +// +// Copyright © 2024 DuckDuckGo. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +import Foundation +@testable import Bookmarks + +class MockFaviconStore: FaviconStoring { + func hasFavicon(for domain: String) -> Bool { + return false + } + + func storeFavicon(_ imageData: Data, with url: URL?, for documentURL: URL) async throws { + } +} diff --git a/DuckDuckGoTests/OnboardingNavigationDelegateTests.swift b/DuckDuckGoTests/OnboardingNavigationDelegateTests.swift index d7f528e2ab..52e2da5b9a 100644 --- a/DuckDuckGoTests/OnboardingNavigationDelegateTests.swift +++ b/DuckDuckGoTests/OnboardingNavigationDelegateTests.swift @@ -220,12 +220,3 @@ class MockRemoteMessagingAvailabilityProviding: RemoteMessagingAvailabilityProvi .eraseToAnyPublisher() } - -class MockFaviconStore: FaviconStoring { - func hasFavicon(for domain: String) -> Bool { - return false - } - - func storeFavicon(_ imageData: Data, with url: URL?, for documentURL: URL) async throws { - } -} diff --git a/DuckDuckGoTests/SyncBookmarksAdapterTests.swift b/DuckDuckGoTests/SyncBookmarksAdapterTests.swift index acf9a6da12..89e2050513 100644 --- a/DuckDuckGoTests/SyncBookmarksAdapterTests.swift +++ b/DuckDuckGoTests/SyncBookmarksAdapterTests.swift @@ -48,7 +48,8 @@ final class SyncBookmarksAdapterTests: XCTestCase { options: [:]) adapter = SyncBookmarksAdapter(database: database, favoritesDisplayModeStorage: MockFavoriteDisplayModeStorage(), - syncErrorHandler: errorHandler) + syncErrorHandler: errorHandler, + faviconStoring: MockFaviconStore()) cancellables = [] }