Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
- Settings › Advanced: the switch "Show all icons while macOS hides one right of the arrow" is now "Pause hiding while macOS shows Now Playing, Focus and similar items", with a note that Hidden Bar hides nothing while one of them shows. Same stored setting, same behavior ([#446](https://github.com/dwarvesf/hidden/issues/446)).

### Fixed
- Switching from the App Store version on macOS 27 (direct build) loses nothing: settings import even when the App Store copy is running at launch, "Open Hidden Bar at login" stays on and opens the new copy (after Import or "Not now"), a failed move of the App Store copy to the Trash says so, and an older direct version (1.8 to 1.12) still running gets "Quit and Switch" instead of a silent quit. The status card says "a temporary folder" instead of a random folder name, and the README, the manual and the macOS 27 notice say to remove the App Store copy before `brew install --cask hiddenbar`. The migration alerts and the macOS 27 notice are now localized.
- macOS 27 (direct build): clicking the clock while the bar is collapsed opens Notification Center again when a notification is still on screen. A notification that stays up across a collapse (such as macOS's "App Background Activity" at login) uses the same window as the panel, so Hidden Bar took it for an open panel and ignored the click. Hidden Bar now checks that the panel itself is open (it has Edit Widgets) before treating a click as one that closes it.
- macOS 14 and later: "Use the full menu bar on expanding" now takes focus. Hidden Bar became a regular app but never the active one, so the front app's menus kept the bar and the option did nothing, in full screen too. It now takes the active state from the front app, and collapsing hands focus back ([#142](https://github.com/dwarvesf/hidden/issues/142)).
- Test runs no longer read or write Hidden Bar's real preferences or act on the installed app. A test host uses its own preferences suite, and skips the "Move to Applications" offer, the App Store migration prompts, Sparkle and the saved arrow positions, so a test run cannot trash or move the installed copy.
Expand Down
27 changes: 27 additions & 0 deletions HiddenBarTests/AutoStartTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,33 @@ final class LegacyLoginItemTests: XCTestCase {
}
}

final class AutoStartTakeOverTests: XCTestCase {
// Given a login item already enabled, held by the App Store copy with the same bundle id
// When the direct build takes it over after the import
// Then it unregisters and registers again, so the item opens this copy
func test_takeOverReregistersAnEnabledItem() {
let service = RecordingLoginItem(status: .enabled)
XCTAssertTrue(AutoStart.applyUnlessTesting(enabled: true, takingOver: true, service: service, touchLoginItems: true))
XCTAssertEqual(service.calls, ["unregister", "register"])
XCTAssertEqual(service.status, .enabled)
}

func test_takeOverOfNoItemOnlyRegisters() {
let service = RecordingLoginItem(status: .notRegistered)
XCTAssertTrue(AutoStart.takeOver(service: service))
XCTAssertEqual(service.calls, ["register"])
}

// Given "Open at login" off after the import
// When applying it with takingOver
// Then it only unregisters, as a plain apply does
func test_takeOverIsOnlyForOn() {
let service = RecordingLoginItem(status: .enabled)
XCTAssertTrue(AutoStart.applyUnlessTesting(enabled: false, takingOver: true, service: service, touchLoginItems: true))
XCTAssertEqual(service.calls, ["unregister"])
}
}

// Records call order; register lands enabled and unregister notRegistered unless stubbed to throw.
private final class RecordingLoginItem: LoginItemServing {
struct StubbedError: Error {}
Expand Down
2 changes: 2 additions & 0 deletions HiddenBarTests/MacOS27NoticeTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ final class MacOS27NoticeTests: XCTestCase {
let command = try XCTUnwrap(fields.first { $0.stringValue == MacOS27Notice.brewCommand })
XCTAssertTrue(command.isSelectable)
XCTAssertFalse(command.isEditable)
XCTAssertNotNil(fields.first { $0.stringValue == MacOS27Notice.brewFirstStep.localized },
"Homebrew refuses while the App Store copy is in /Applications; the notice says to remove it first")
XCTAssertGreaterThan(stack.frame.height, 0)
}
}
Expand Down
18 changes: 18 additions & 0 deletions HiddenBarTests/SettingsModelTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,24 @@ final class SettingsModelTests: XCTestCase {
XCTAssertTrue([SettingsStatus.needsAccessibility, .outsideApplications, .appStoreOnMacOS27].allSatisfy(\.isWarning))
}

// Given Hidden Bar opened from a translocated or temporary path
// When the status card names the folder it runs from
// Then it says "a temporary folder", not the random folder name ("d.")
func test_statusCard_namesATemporaryFolderPlainly() {
let temporary = ["/private/var/folders/ab/xyz/T/AppTranslocation/1234-ABCD/d/Hidden Bar.app",
"/var/folders/ab/xyz/T/Hidden Bar.app",
"/private/tmp/x/Hidden Bar.app",
"/tmp/Hidden Bar.app"]
for path in temporary {
XCTAssertTrue(RunningFolder.isTemporary(URL(fileURLWithPath: path)), path)
XCTAssertEqual(RunningFolder.displayName(of: URL(fileURLWithPath: path), displayName: { _ in "d." }),
"a temporary folder".localized, path)
}
let downloads = URL(fileURLWithPath: "/Users/x/Downloads/Hidden Bar.app")
XCTAssertFalse(RunningFolder.isTemporary(downloads))
XCTAssertEqual(RunningFolder.displayName(of: downloads, displayName: { $0 == "/Users/x/Downloads" ? "Downloads" : "?" }), "Downloads")
}

// MARK: preview edge

func test_previewBoundary_followsTheEngine() {
Expand Down
154 changes: 154 additions & 0 deletions HiddenTests/AppStoreMigrationTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,70 @@ final class AppStoreMigrationTests: XCTestCase {
registeredDefaults: registered, alreadyAnswered: false))
}

// Given the App Store copy running at launch, so the direct build collapses before the offer
// When the first collapse wrote the separator state and the pinned-sections table
// Then those writes do not count as the direct build's own settings, and the import is still offered
func test_keysTheDirectBuildWritesAtLaunchDoNotBlockTheImport() {
let launchWrites: [String: Any] = [UserDefaults.Key.areSeparatorsHidden: true,
UserDefaultsPinnedSections.key: ["com.example.app": 1]]
XCTAssertTrue(AppStoreSettingsImport.shouldOffer(containerValues: ["isAutoHide": false], directValues: launchWrites,
registeredDefaults: registered, alreadyAnswered: false))
var chosen = launchWrites
chosen["hoverToExpand"] = true
XCTAssertFalse(AppStoreSettingsImport.shouldOffer(containerValues: ["isAutoHide": false], directValues: chosen,
registeredDefaults: registered, alreadyAnswered: false),
"a setting the user changed in this build still wins")
}

// Given the direct build's settings captured at launch
// When something is written to its domain afterwards (an alert held the launch while the bar collapsed)
// Then the import decision reads the launch values
func test_importDecisionReadsTheSettingsAsLaunchFoundThem() throws {
_ = try writeContainerPlist(["isAutoHide": false, "isAutoStart": true])
let migration = AppStoreMigration(environment: .init(home: root, bundleURL: downloadsApp, bundleIdentifier: bundleID,
defaults: defaults, registeredDefaults: registered))
migration.captureLaunchState()
defaults.set(true, forKey: UserDefaults.Key.alwaysHiddenSectionEnabled)
XCTAssertTrue(migration.wouldOfferImport)
MigrationOfferLedger(defaults: defaults).recordAnswer(MigrationOfferLedger.importKey)
XCTAssertFalse(migration.wouldOfferImport, "answered once, never again")
}

// MARK: open at login across the switch

// Given the App Store build opened at login and the import offer is still to come
// When the direct build sets up its login item at launch
// Then it leaves the item alone instead of applying its own unset "off"
func test_loginItemIsLeftAloneWhileTheImportIsPending() {
XCTAssertFalse(LaunchLoginItem.shouldApply(importOfferPending: true, containerOpensAtLogin: true, directAutoStart: false))
XCTAssertTrue(LaunchLoginItem.shouldApply(importOfferPending: false, containerOpensAtLogin: true, directAutoStart: false),
"once answered, this build's setting applies")
XCTAssertTrue(LaunchLoginItem.shouldApply(importOfferPending: true, containerOpensAtLogin: false, directAutoStart: false))
XCTAssertTrue(LaunchLoginItem.shouldApply(importOfferPending: true, containerOpensAtLogin: true, directAutoStart: true))
XCTAssertTrue(AppStoreSettingsImport.opensAtLogin(["isAutoStart": true]))
XCTAssertFalse(AppStoreSettingsImport.opensAtLogin(["isAutoStart": false]))
XCTAssertFalse(AppStoreSettingsImport.opensAtLogin(nil))
}

// Given the App Store build opened at login
// When the user answers "Not now" to the import, and Hidden Bar launches again
// Then "Open at login" stays on in this build, and nothing else is copied
func test_notNowKeepsOpenAtLogin() {
let written = AppStoreSettingsImport.applyDecline(["isAutoStart": true, "isAutoHide": false, "arrowStyle": "chevron"], to: defaults)
XCTAssertEqual(written, [UserDefaults.Key.isAutoStart])
XCTAssertTrue(defaults.bool(forKey: UserDefaults.Key.isAutoStart))
XCTAssertEqual(defaults.persistentDomain(forName: suiteName).map { Set($0.keys) }, [UserDefaults.Key.isAutoStart])
// The next launch: the offer is answered, so this build's value applies, and it is on.
XCTAssertTrue(LaunchLoginItem.shouldApply(importOfferPending: false, containerOpensAtLogin: true,
directAutoStart: defaults.bool(forKey: UserDefaults.Key.isAutoStart)))
XCTAssertTrue(defaults.bool(forKey: UserDefaults.Key.isAutoStart))

let off = UserDefaults(suiteName: suiteName + ".off")!
defer { off.removePersistentDomain(forName: suiteName + ".off") }
XCTAssertEqual(AppStoreSettingsImport.applyDecline(["isAutoStart": false, "isAutoHide": false], to: off), [])
XCTAssertNil(off.persistentDomain(forName: suiteName + ".off")?[UserDefaults.Key.isAutoStart])
}

func testOfferIsShownOnlyOnceAfterAnyAnswer() {
let ledger = MigrationOfferLedger(defaults: defaults)
XCTAssertFalse(ledger.isAnswered(MigrationOfferLedger.importKey))
Expand Down Expand Up @@ -284,6 +348,39 @@ final class AppStoreMigrationTests: XCTestCase {
countsOtherPaths: false, countsAppStoreCopies: true), .quitInFavorOf(43))
}

// Given an older direct copy (1.8 to 1.12) running from another folder
// When this newer copy opens
// Then it offers "Quit and Switch" instead of quitting silently
func test_olderDirectCopyIsOfferedAQuit() {
let older = OtherRunningCopy.Instance(pid: 42, bundleURL: URL(fileURLWithPath: "/Applications/Hidden Bar.app"),
isAppStoreBuild: false, version: "1.12")
XCTAssertEqual(OtherRunningCopy.decide(others: [older], runningBundle: downloadsApp, runningVersion: "1.13.0"),
.offerToReplaceOlderCopy(42))
let v18 = OtherRunningCopy.Instance(pid: 43, bundleURL: URL(fileURLWithPath: "/Applications/Hidden Bar.app"),
isAppStoreBuild: false, version: "1.8")
XCTAssertEqual(OtherRunningCopy.decide(others: [v18], runningBundle: downloadsApp, runningVersion: "1.13.0"),
.offerToReplaceOlderCopy(43))
}

// Given another direct copy that is not older, or whose version is unknown, or a relaunch of this same copy
// When this copy opens
// Then it brings that copy forward and quits, as before
func test_directCopyNotOlderStillWinsSilently() {
func copy(_ version: String?, _ path: String = "/Applications/Hidden Bar.app") -> OtherRunningCopy.Instance {
.init(pid: 42, bundleURL: URL(fileURLWithPath: path), isAppStoreBuild: false, version: version)
}
XCTAssertEqual(OtherRunningCopy.decide(others: [copy("1.13.0")], runningBundle: downloadsApp, runningVersion: "1.13.0"), .quitInFavorOf(42))
XCTAssertEqual(OtherRunningCopy.decide(others: [copy("1.14")], runningBundle: downloadsApp, runningVersion: "1.13.0"), .quitInFavorOf(42))
XCTAssertEqual(OtherRunningCopy.decide(others: [copy(nil)], runningBundle: downloadsApp, runningVersion: "1.13.0"), .quitInFavorOf(42))
XCTAssertEqual(OtherRunningCopy.decide(others: [copy("1.12", downloadsApp.path)], runningBundle: downloadsApp, runningVersion: "1.13.0"),
.quitInFavorOf(42), "a relaunch of the same bundle path")
XCTAssertTrue(OtherRunningCopy.isOlder("1.9", than: "1.13.0"))
XCTAssertTrue(OtherRunningCopy.isOlder("1.12.3", than: "1.13"))
XCTAssertFalse(OtherRunningCopy.isOlder("1.13.0", than: "1.13.0"))
XCTAssertFalse(OtherRunningCopy.isOlder(nil, than: "1.13.0"))
XCTAssertFalse(OtherRunningCopy.isOlder("1.12", than: nil))
}

// Given an import from the App Store build
// When its settings are applied
// Then the pinned-sections notice goes out too, as the engine and the catalog listen to it, not to prefsChanged
Expand All @@ -292,6 +389,63 @@ final class AppStoreMigrationTests: XCTestCase {
XCTAssertTrue(AppDelegate.importedPreferenceNotifications.contains(.prefsChanged))
}

// Given the migration alerts and the status card's button
// When looking in every Localizable.strings the app ships
// Then each locale carries them with the same placeholders, so none shows a raw key or drops a path
func test_everyLocale_carriesTheMigrationStrings() {
let keys = [
"Hidden Bar from the App Store is running. Quit it and switch to this version?",
"Only one Hidden Bar can run at a time. The App Store version stays installed until you choose otherwise.",
"Hidden Bar %@ is running. Quit it and switch to this version?",
"Only one Hidden Bar can run at a time. The older version stays where it is until you choose otherwise.",
"Quit and Switch",
"Cancel",
"Import your settings from the App Store version?",
"Hidden Bar from the App Store keeps its settings in a separate place. Import them so this version starts the way you set it up.",
"Import",
"Not now",
"Move the App Store copy to the Trash?",
"The App Store version of Hidden Bar is still installed:\n%@\nYou can restore it from the Trash later.",
"Move to Trash",
"Hidden Bar could not move the App Store copy to the Trash",
"Drag it to the Trash in Finder instead:\n%@",
"The App Store copy is in /Applications. Quit Hidden Bar, move /Applications/Hidden Bar.app to the Trash, drag this copy into Applications, then open it from there.",
"This account can't add apps to /Applications. Ask an administrator to drag Hidden Bar into /Applications, then open it from there.",
"Hidden Bar is running from outside Applications. The copy already in Applications goes to the Trash, then Hidden Bar relaunches from there.",
"Hidden Bar is running from outside Applications. Move it there so it keeps working after you empty Downloads, then relaunch.",
"Move Hidden Bar to the Applications folder?",
"Move to Applications",
"Hidden Bar can hide icons only from /Applications",
"OK",
"a temporary folder",
"Hidden Bar cannot hide icons on macOS 27",
"macOS 27 no longer lets App Store apps hide menu-bar icons. Hidden Bar from github.com/consolelabs/hidden (free, open source) works on macOS 27.",
"Open github.com/consolelabs/hidden",
"Close",
"Don't show again",
"Hidden Bar on macOS 27",
"macOS 27: get the working version...",
"Or install it with Homebrew:",
"Quit this App Store version and move it to the Trash first. Homebrew does not install over it.",
]
let localizations = Bundle.main.localizations.filter { $0 != "Base" }
XCTAssertGreaterThan(localizations.count, 5)
for locale in localizations {
guard let path = Bundle.main.path(forResource: "Localizable", ofType: "strings", inDirectory: nil, forLocalization: locale),
let table = NSDictionary(contentsOfFile: path) as? [String: String] else {
XCTFail("no Localizable.strings for \(locale)")
continue
}
for key in keys {
guard let value = table[key] else { XCTFail("\(locale) is missing \"\(key)\""); continue }
for token in ["%@", "\n"] {
XCTAssertEqual(value.components(separatedBy: token).count, key.components(separatedBy: token).count,
"\(locale) \"\(key)\" changes the \(token) count")
}
}
}
}

// Given a build that does not use the native engine
// When the app registers its shortcuts
// Then the palette and presentation shortcuts are not registered; with the native engine they are
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ The Hidden Bar is notarized before distributed out side App Store. It's safe to
brew install --cask hiddenbar
```

Coming from the App Store version? Quit it and move `/Applications/Hidden Bar.app` to the Trash first: Homebrew does not install over it. Your settings stay; the new version offers to import them on first launch.

#### Manual download

- [Download latest version](https://github.com/consolelabs/hidden/releases/latest)
Expand Down
Loading