-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add FXIOS-10914 [Homepage] [Top Sites] calculating top sites concurre…
…ntly (#23935)
- Loading branch information
Showing
7 changed files
with
404 additions
and
129 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
...efox-ios-tests/Tests/ClientTests/Frontend/Homepage Rebuild/Mock/MockTopSitesManager.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// This Source Code Form is subject to the terms of the Mozilla Public | ||
// License, v. 2.0. If a copy of the MPL was not distributed with this | ||
// file, You can obtain one at http://mozilla.org/MPL/2.0/ | ||
|
||
import Foundation | ||
import Storage | ||
|
||
@testable import Client | ||
|
||
final class MockTopSitesManager: TopSitesManagerInterface { | ||
var getOtherSitesCalledCount = 0 | ||
var fetchSponsoredSitesCalledCount = 0 | ||
var recalculateTopSitesCalledCount = 0 | ||
|
||
func getOtherSites() async -> [TopSiteState] { | ||
getOtherSitesCalledCount += 1 | ||
return createSites(count: 15, subtitle: ": otherSites") | ||
} | ||
|
||
func fetchSponsoredSites() async -> [SponsoredTile] { | ||
fetchSponsoredSitesCalledCount += 1 | ||
|
||
let contiles = MockContileProvider.defaultSuccessData | ||
return contiles.compactMap { SponsoredTile(contile: $0) } | ||
} | ||
|
||
func recalculateTopSites(otherSites: [TopSiteState], sponsoredSites: [SponsoredTile]) async -> [TopSiteState] { | ||
recalculateTopSitesCalledCount += 1 | ||
return createSites(subtitle: ": total top sites") | ||
} | ||
|
||
func createSites(count: Int = 30, subtitle: String = "") -> [TopSiteState] { | ||
var sites = [TopSiteState]() | ||
(0..<count).forEach { | ||
let site = Site(url: "www.url\($0).com", | ||
title: "Title \($0) \(subtitle)") | ||
sites.append(TopSiteState(site: site)) | ||
} | ||
return sites | ||
} | ||
} |
Oops, something went wrong.