Skip to content

Commit

Permalink
Merge branch 'main' into sam/vpn-snooze-initial-support
Browse files Browse the repository at this point in the history
# By Alexey Martemyanov (2) and others
# Via Alexey Martemyanov (2) and GitHub (1)
* main:
  Improve Bookmarks DB Setup (#3143)
  Add RMF `messageShown` attribute (#3176)
  Enable favorites reordering on New Tab Page (#3169)
  [DuckPlayer]. 15. Move DuckPlayer code to BSK (#3171)
  Update autoconsent to v10.13.0 (#3178)
  application lock test and tab switcher test (#3163)
  Release 7.131.0-1 (#3179)
  restore CrashLogMessageExtractor with disabled __cxa_throw swapper (#3133)

# Conflicts:
#	DuckDuckGo.xcodeproj/project.pbxproj
#	DuckDuckGo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved
  • Loading branch information
samsymons committed Aug 5, 2024
2 parents f8f55b1 + 2f0187f commit ffdf570
Show file tree
Hide file tree
Showing 28 changed files with 665 additions and 474 deletions.
57 changes: 57 additions & 0 deletions .maestro/release_tests/application-lock.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# application-lock.yaml
appId: com.duckduckgo.mobile.ios
tags:
- release

---

# Set up
- runFlow:
file: ../shared/setup.yaml

- tapOn: "Settings"
- scrollUntilVisible:
element: "General"
direction: DOWN
- tapOn: "General"

- tapOn:
text: "0"
index: "0"

- stopApp

- launchApp

- assertVisible: "Unlock DuckDuckGo."
- inputText: "password"
- pressKey: Enter

- assertVisible:
id: "searchEntry"
- tapOn:
id: "searchEntry"
- inputText: "https://privacy-test-pages.site"
- pressKey: Enter

# Manage onboarding
- runFlow:
file: ../shared/onboarding_browsing.yaml

- tapOn: "Browsing Menu"
- tapOn: "Settings"
- scrollUntilVisible:
element: "General"
direction: DOWN
- tapOn: "General"

- tapOn:
text: "1"
index: "0"


- stopApp

- launchApp

- assertVisible: "Privacy Test Pages"
60 changes: 60 additions & 0 deletions .maestro/release_tests/tabswitcher.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# tabswitcher.yaml
appId: com.duckduckgo.mobile.ios
tags:
- release

---

# Set up
- runFlow:
file: ../shared/setup.yaml

# Load Site
- assertVisible:
id: "searchEntry"
- tapOn:
id: "searchEntry"
- inputText: "https://privacy-test-pages.site"
- pressKey: Enter

# Manage onboarding
- runFlow:
file: ../shared/onboarding_browsing.yaml

- assertVisible: ".*Privacy Test Pages.*"

# Add tab
- assertVisible: Tab Switcher
- tapOn: Tab Switcher
- assertVisible: ".*Privacy Test Pages.*"
- assertVisible:
id: "Add"
- tapOn:
id: "Add"
- assertVisible:
id: "searchEntry"
- tapOn:
id: "searchEntry"
- inputText: "https://www.search-company.site"
- pressKey: Enter
- assertVisible: "Search engine"

# Bookmark all
- assertVisible: Tab Switcher
- tapOn: Tab Switcher
- tapOn: "Add all tabs as bookmarks"
- assertVisible: "Bookmark All Tabs?"
- tapOn: "Bookmark"

# can't really tell if it works, but at least it won't crash
- tapOn: "Toggle between grid and list view"

# Check bookmarks were added
- tapOn: "Done"

- tapOn: "Browsing menu"
- tapOn: "Bookmarks"
- assertVisible: "Privacy Test Pages - Home"
- assertVisible: "Ad Click Flow"


21 changes: 17 additions & 4 deletions Core/BookmarksStateValidation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,23 @@ import CoreData
import Bookmarks
import Persistence

public class BookmarksStateValidation {
public protocol BookmarksStateValidation {

func validateInitialState(context: NSManagedObjectContext,
validationError: BookmarksStateValidator.ValidationError) -> Bool

func validateBookmarksStructure(context: NSManagedObjectContext)
}

public class BookmarksStateValidator: BookmarksStateValidation {

enum Constants {
static let bookmarksDBIsInitialized = "bookmarksDBIsInitialized"
}

public enum ValidationError {
case bookmarksStructureLost
case bookmarksStructureNotRecovered
case bookmarksStructureBroken(additionalParams: [String: String])
case validatorError(Error)
}
Expand All @@ -43,18 +52,22 @@ public class BookmarksStateValidation {
self.errorHandler = errorHandler
}

public func validateInitialState(context: NSManagedObjectContext) {
guard keyValueStore.object(forKey: Constants.bookmarksDBIsInitialized) != nil else { return }
public func validateInitialState(context: NSManagedObjectContext,
validationError: ValidationError) -> Bool {
guard keyValueStore.object(forKey: Constants.bookmarksDBIsInitialized) != nil else { return true }

let fetch = BookmarkEntity.fetchRequest()
do {
let count = try context.count(for: fetch)
if count == 0 {
errorHandler(.bookmarksStructureLost)
errorHandler(validationError)
return false
}
} catch {
errorHandler(.validatorError(error))
}

return true
}

public func validateBookmarksStructure(context: NSManagedObjectContext) {
Expand Down
11 changes: 9 additions & 2 deletions Core/LegacyBookmarksStoreMigration.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,14 @@ public class LegacyBookmarksStoreMigration {
}
} else {
// Initialize structure if needed
BookmarkUtils.prepareLegacyFoldersStructure(in: context)
do {
try BookmarkUtils.prepareLegacyFoldersStructure(in: context)
} catch {
Pixel.fire(pixel: .debugBookmarksInitialStructureQueryFailed, error: error)
Thread.sleep(forTimeInterval: 1)
fatalError("Could not prepare Bookmarks DB structure")
}

if context.hasChanges {
do {
try context.save(onErrorFire: .bookmarksCouldNotPrepareDatabase)
Expand Down Expand Up @@ -178,7 +185,7 @@ public class LegacyBookmarksStoreMigration {
} catch {
destination.reset()

BookmarkUtils.prepareLegacyFoldersStructure(in: destination)
try? BookmarkUtils.prepareLegacyFoldersStructure(in: destination)
do {
try destination.save(onErrorFire: .bookmarksMigrationCouldNotPrepareDatabaseOnFailedMigration)
} catch {
Expand Down
10 changes: 5 additions & 5 deletions Core/PixelEvent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,9 @@ extension Pixel {
case adAttributionLogicWrongVendorOnSuccessfulCompilation
case adAttributionLogicWrongVendorOnFailedCompilation

case debugBookmarksInitialStructureQueryFailed
case debugBookmarksStructureLost
case debugBookmarksStructureNotRecovered
case debugBookmarksInvalidRoots
case debugBookmarksValidationFailed

Expand Down Expand Up @@ -589,8 +591,6 @@ extension Pixel {
case syncDeleteAccountError
case syncLoginExistingAccountError

case syncWrongEnvironment

case swipeTabsUsedDaily
case swipeToOpenNewTab

Expand Down Expand Up @@ -1210,8 +1210,10 @@ extension Pixel.Event {
return "m_compilation_result_\(result)_time_\(waitTime)_state_\(appState)"

case .emailAutofillKeychainError: return "m_email_autofill_keychain_error"


case .debugBookmarksInitialStructureQueryFailed: return "m_d_bookmarks-initial-structure-query-failed"
case .debugBookmarksStructureLost: return "m_d_bookmarks_structure_lost"
case .debugBookmarksStructureNotRecovered: return "m_d_bookmarks_structure_not_recovered"
case .debugBookmarksInvalidRoots: return "m_d_bookmarks_invalid_roots"
case .debugBookmarksValidationFailed: return "m_d_bookmarks_validation_failed"

Expand Down Expand Up @@ -1295,8 +1297,6 @@ extension Pixel.Event {
case .syncDeleteAccountError: return "m_d_sync_delete_account_error"
case .syncLoginExistingAccountError: return "m_d_sync_login_existing_account_error"

case .syncWrongEnvironment: return "m_d_sync_wrong_environment_u"

case .swipeTabsUsedDaily: return "m_swipe-tabs-used-daily"
case .swipeToOpenNewTab: return "m_addressbar_swipe_new_tab"

Expand Down
Loading

0 comments on commit ffdf570

Please sign in to comment.