Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

implement default zoom per site #2566

Merged
merged 28 commits into from
May 17, 2024
Merged
Changes from 1 commit
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
17822f1
implement default zoom per site
SabrinaTardio Apr 8, 2024
08faec9
fix UI
SabrinaTardio Apr 8, 2024
f1a026b
Merge branch 'main' into sabrina/improve-zoom-feature
SabrinaTardio May 7, 2024
d52c969
remove zoom button on hover, fix bar button treatment
SabrinaTardio May 7, 2024
123b604
fix test in CI
SabrinaTardio May 7, 2024
0dd9cfc
little UI fix
SabrinaTardio May 7, 2024
22a9cbb
fix tests in CI
SabrinaTardio May 7, 2024
c91f1ee
fix test
SabrinaTardio May 7, 2024
4d74971
improve tests
SabrinaTardio May 8, 2024
5d584d2
adjust popover position
SabrinaTardio May 8, 2024
0dedd2c
Merge branch 'main' into sabrina/improve-zoom-feature
SabrinaTardio May 8, 2024
3484758
add tranlsations
SabrinaTardio May 8, 2024
e505e90
make test more robust
SabrinaTardio May 8, 2024
4c310ce
clean up
SabrinaTardio May 8, 2024
b878c29
fix tests in CI
SabrinaTardio May 8, 2024
0f9aa02
improve icon
SabrinaTardio May 8, 2024
ead4ad3
fix tests
SabrinaTardio May 8, 2024
1c358c5
address ship review comments
SabrinaTardio May 13, 2024
715b3f2
connect zoom to right setting
SabrinaTardio May 13, 2024
8727e41
make popover indipendent from preferences
SabrinaTardio May 13, 2024
b281135
set up zoom for fire window
SabrinaTardio May 13, 2024
47cbfc4
refactor
SabrinaTardio May 13, 2024
c0311e7
Merge branch 'main' into sabrina/improve-zoom-feature
SabrinaTardio May 13, 2024
17d3739
fix test
SabrinaTardio May 13, 2024
97b1d8c
fix internal link on new tab
SabrinaTardio May 14, 2024
3ffe2d0
fix button open/close
SabrinaTardio May 14, 2024
014eec4
Merge branch 'main' into sabrina/improve-zoom-feature
SabrinaTardio May 15, 2024
a09f90e
add test
SabrinaTardio May 15, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix test in CI
SabrinaTardio committed May 7, 2024
commit 123b60451505febb4fe7d4c5b0377d9ed0aae190
1 change: 1 addition & 0 deletions DuckDuckGo/Common/Localizables/UserText.swift
Original file line number Diff line number Diff line change
@@ -490,6 +490,7 @@ struct UserText {
static let mobileBookmarksImportedFolderTitle = NSLocalizedString("bookmarks.imported.mobile.folder.title", value: "Mobile bookmarks", comment: "Name of the \"Mobile bookmarks\" folder imported from other browser")

static let zoom = NSLocalizedString("zoom", value: "Zoom", comment: "Menu with Zooming commands")
static let resetZoom = NSLocalizedString("reset-zoom", value: "Reset", comment: "Button that allows the user to reset the zoom level of the browser page")

static let emailOptionsMenuItem = NSLocalizedString("email.optionsMenu", value: "Email Protection", comment: "Menu item email feature")
static let emailOptionsMenuCreateAddressSubItem = NSLocalizedString("email.optionsMenu.createAddress", value: "Generate Private Duck Address", comment: "Create an email alias sub menu item")
2 changes: 1 addition & 1 deletion DuckDuckGo/NavigationBar/View/ZoomPopover.swift
Original file line number Diff line number Diff line change
@@ -31,7 +31,7 @@ struct ZoomPopoverContentView: View {
Button {
viewModel.reset()
} label: {
Text("Reset")
Text(UserText.resetZoom)
.frame(height: 28)
.padding(.horizontal, 8)
}
2 changes: 2 additions & 0 deletions UnitTests/Tab/ViewModel/ZoomPopoverViewModelTests.swift
Original file line number Diff line number Diff line change
@@ -70,14 +70,16 @@

@MainActor
func test_WhenResetZoomFromPopover_ThenWebViewIsReset() {
let expectation = self.expectation(forNotification: AccessibilityPreferences.zoomPerWebsiteUpdated, object: nil, handler: nil)

Check warning on line 73 in UnitTests/Tab/ViewModel/ZoomPopoverViewModelTests.swift

GitHub Actions / Test (Sandbox)

initialization of immutable value 'expectation' was never used; consider replacing with assignment to '_' or removing it

Check warning on line 73 in UnitTests/Tab/ViewModel/ZoomPopoverViewModelTests.swift

GitHub Actions / Test (Non-Sandbox)

initialization of immutable value 'expectation' was never used; consider replacing with assignment to '_' or removing it
let randomZoomLevel = DefaultZoomValue.allCases.randomElement()!
tabVM.tab.webView.defaultZoomValue = .percent100
tabVM.tab.webView.zoomLevel = randomZoomLevel

zoomPopover.reset()

waitForExpectations(timeout: 5)
XCTAssertEqual(.percent100, tabVM.tab.webView.zoomLevel)
XCTAssertEqual(.percent100, zoomPopover.zoomLevel)

Check failure on line 82 in UnitTests/Tab/ViewModel/ZoomPopoverViewModelTests.swift

GitHub Actions / Test (Non-Sandbox)

test_WhenResetZoomFromPopover_ThenWebViewIsReset, XCTAssertEqual failed: ("percent100") is not equal to ("percent125")
}

@MainActor

Unchanged files with check annotations Beta

let randomZoomLevel = DefaultZoomValue.allCases.randomElement()!
AccessibilityPreferences.shared.updateZoomPerWebsite(zoomLevel: randomZoomLevel, url: hostURL)
let tab = Tab(url: url)
let tabView = TabViewModel(tab: tab)

Check warning on line 345 in UnitTests/Tab/ViewModel/TabViewModelTests.swift

GitHub Actions / Test (Non-Sandbox)

initialization of immutable value 'tabView' was never used; consider replacing with assignment to '_' or removing it
// WHEN
tab.webView.resetZoomLevel()
window.contentView?.addSubview(tab.webView)
tab.webView.frame = window.contentView!.bounds
window.makeKeyAndOrderFront(nil)
let tabView = TabViewModel(tab: tab)

Check warning on line 370 in UnitTests/Tab/ViewModel/TabViewModelTests.swift

GitHub Actions / Test (Non-Sandbox)

initialization of immutable value 'tabView' was never used; consider replacing with assignment to '_' or removing it
// WHEN
tab.webView.zoomIn()
window.contentView?.addSubview(tab.webView)
tab.webView.frame = window.contentView!.bounds
window.makeKeyAndOrderFront(nil)
let tabView = TabViewModel(tab: tab)

Check warning on line 395 in UnitTests/Tab/ViewModel/TabViewModelTests.swift

GitHub Actions / Test (Non-Sandbox)

initialization of immutable value 'tabView' was never used; consider replacing with assignment to '_' or removing it
// WHEN
tab.webView.zoomOut()
// THEN
XCTAssertEqual(AccessibilityPreferences.shared.zoomPerWebsite(url: hostURL), previousZoomLevel)

Check failure on line 401 in UnitTests/Tab/ViewModel/TabViewModelTests.swift

GitHub Actions / Test (Non-Sandbox)

test_WhenWebViewZoomOutForASite_ThenNewZoomSavedForTheSite, XCTAssertEqual failed: ("nil") is not equal to ("Optional(DuckDuckGo_Privacy_Browser.DefaultZoomValue.percent50)")
}
private func randomLevelAndAdjacent() -> (randomLevel: DefaultZoomValue, nextLevel: DefaultZoomValue, previousLevel: DefaultZoomValue) {