Skip to content

Commit

Permalink
Fix fake TabViewController initialization in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dus7 committed Jan 21, 2025
1 parent d54b5c0 commit 1fabeb0
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 1 deletion.
4 changes: 4 additions & 0 deletions DuckDuckGo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,7 @@
6F691CCA2C4979EC002E9553 /* FavoritesTooltip.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6F691CC92C4979EC002E9553 /* FavoritesTooltip.swift */; };
6F72353D2D3EBCB800710C07 /* WebViewStateRestorationDebugView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6F72353C2D3EBCB000710C07 /* WebViewStateRestorationDebugView.swift */; };
6F72353F2D3EC11E00710C07 /* WebViewStateRestorationManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6F72353E2D3EC11500710C07 /* WebViewStateRestorationManager.swift */; };
6F7235412D3F974600710C07 /* MockTabInteractionStateSource.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6F7235402D3F973C00710C07 /* MockTabInteractionStateSource.swift */; };
6F7BACD42CEE084B00F561D8 /* OmniBarEqualityCheckTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6F7BACD32CEE084100F561D8 /* OmniBarEqualityCheckTests.swift */; };
6F7FB8E12C660B3E00867DA7 /* NewTabPageFavoritesModelTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6F7FB8DF2C660B1A00867DA7 /* NewTabPageFavoritesModelTests.swift */; };
6F7FB8E32C660BF300867DA7 /* DailyPixelFiring.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6F7FB8E22C660BF300867DA7 /* DailyPixelFiring.swift */; };
Expand Down Expand Up @@ -1744,6 +1745,7 @@
6F691CC92C4979EC002E9553 /* FavoritesTooltip.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FavoritesTooltip.swift; sourceTree = "<group>"; };
6F72353C2D3EBCB000710C07 /* WebViewStateRestorationDebugView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WebViewStateRestorationDebugView.swift; sourceTree = "<group>"; };
6F72353E2D3EC11500710C07 /* WebViewStateRestorationManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WebViewStateRestorationManager.swift; sourceTree = "<group>"; };
6F7235402D3F973C00710C07 /* MockTabInteractionStateSource.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MockTabInteractionStateSource.swift; sourceTree = "<group>"; };
6F7BACD32CEE084100F561D8 /* OmniBarEqualityCheckTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OmniBarEqualityCheckTests.swift; sourceTree = "<group>"; };
6F7FB8DF2C660B1A00867DA7 /* NewTabPageFavoritesModelTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NewTabPageFavoritesModelTests.swift; sourceTree = "<group>"; };
6F7FB8E22C660BF300867DA7 /* DailyPixelFiring.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DailyPixelFiring.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -6520,6 +6522,7 @@
F17669A91E412A17003D3222 /* Mocks */ = {
isa = PBXGroup;
children = (
6F7235402D3F973C00710C07 /* MockTabInteractionStateSource.swift */,
6F1422852D31509000B6D3DE /* MockDataExtensions.swift */,
85C503FE2CF0F4D60075DF6F /* MockWebsiteDataManager.swift */,
8598D2E52CEBAA1B00C45685 /* MockFaviconStore.swift */,
Expand Down Expand Up @@ -8716,6 +8719,7 @@
C1935A222C89CA9F001AD72D /* AutofillSurveyManagerTests.swift in Sources */,
22CB1ED8203DDD2C00D2C724 /* AppDeepLinksTests.swift in Sources */,
9847C00527A41A0A00DB07AA /* WebViewTestHelper.swift in Sources */,
6F7235412D3F974600710C07 /* MockTabInteractionStateSource.swift in Sources */,
3170048227A9504F00C03F35 /* DownloadMocks.swift in Sources */,
317045C02858C6B90016ED1F /* AutofillInterfaceEmailTruncatorTests.swift in Sources */,
6FD3AEE32B8F4EEB0060FCCC /* AdAttributionPixelReporterTests.swift in Sources */,
Expand Down
3 changes: 2 additions & 1 deletion DuckDuckGoTests/MockTabDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,8 @@ extension TabViewController {
subscriptionCookieManager: SubscriptionCookieManagerMock(),
textZoomCoordinator: MockTextZoomCoordinator(),
websiteDataManager: MockWebsiteDataManager(),
fireproofing: MockFireproofing()
fireproofing: MockFireproofing(),
tabInteractionStateSource: MockTabInteractionStateSource()
)
tab.attachWebView(configuration: .nonPersistent(), andLoadRequest: nil, consumeCookies: false, customWebView: customWebView)
return tab
Expand Down
28 changes: 28 additions & 0 deletions DuckDuckGoTests/MockTabInteractionStateSource.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
//
// MockTabInteractionStateSource.swift
// DuckDuckGo
//
// Copyright © 2025 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 DuckDuckGo

final class MockTabInteractionStateSource: TabInteractionStateSource {
func saveState(_ state: Any?, for tab: Tab) { }
func popLastStateForTab(_ tab: Tab) -> Data? { return nil }
func removeStateForTab(_ tab: Tab) { }
func removeAll(excluding excludedTabs: [Tab]) { }
}

0 comments on commit 1fabeb0

Please sign in to comment.