diff --git a/GureumTests/GureumTests.swift b/GureumTests/GureumTests.swift index 151e8ebf..5b732451 100644 --- a/GureumTests/GureumTests.swift +++ b/GureumTests/GureumTests.swift @@ -68,7 +68,7 @@ class GureumTests: XCTestCase { XCTFail() return } - let versionInfo = UpdateManager.VersionInfo(data: versionInfoJSON) + let versionInfo = UpdateManager.VersionInfo(data: versionInfoJSON, experimental: true) UpdateManager.shared.notifyUpdate(info: versionInfo) XCTAssertEqual("최신 버전: 1.10.0 현재 버전: \(UpdateManager.bundleVersion ?? "-")\nMojave 대응을 포함한 대형 업데이트", lastNotification.informativeText) XCTAssertEqual(["url": "https://github.com/gureum/gureum/releases/tag/1.10.0"], lastNotification.userInfo as! [String: String]) diff --git a/GureumTests/MockInputClient.m b/GureumTests/MockInputClient.m index cd615766..0e9151fd 100644 --- a/GureumTests/MockInputClient.m +++ b/GureumTests/MockInputClient.m @@ -27,6 +27,7 @@ - (NSString *)selectedString { } - (void)insertText:(id)string replacementRange:(NSRange)replacementRange { + // NSAssert(replacementRange.location == NSNotFound || replacementRange.length != 0, @"-"); [super insertText:string replacementRange:replacementRange]; } diff --git a/OSX/UpdateManager.swift b/OSX/UpdateManager.swift index 09fb0cf8..ea3875d9 100644 --- a/OSX/UpdateManager.swift +++ b/OSX/UpdateManager.swift @@ -16,8 +16,10 @@ class UpdateManager { class VersionInfo { let current: String? = UpdateManager.bundleVersion let data: [String: String] - init(data: [String: String]) { + let experimental: Bool + init(data: [String: String], experimental: Bool) { self.data = data + self.experimental = experimental } var recent: String? { @@ -36,7 +38,7 @@ class UpdateManager { } } - func fetchVersionInfo(from url: URL) -> VersionInfo? { + func fetchVersionInfo(from url: URL, experimental: Bool) -> VersionInfo? { var request = URLRequest(url: url) request.timeoutInterval = 0.5 request.cachePolicy = .reloadIgnoringCacheData @@ -49,17 +51,17 @@ class UpdateManager { guard let info = try? JSONSerialization.jsonObject(with: data as Data) as? [String: String] else { return nil } - return VersionInfo(data: info) + return VersionInfo(data: info, experimental: experimental) } func fetchOfficialVersionInfo() -> VersionInfo? { let url = URL(string: "http://gureum.io/version.json")! - return fetchVersionInfo(from: url) + return fetchVersionInfo(from: url, experimental: false) } func fetchExperimentalVersionInfo() -> VersionInfo? { let url = URL(string: "http://gureum.io/version-experimental.json")! - return fetchVersionInfo(from: url) + return fetchVersionInfo(from: url, experimental: true) } func fetchAutoUpdateVersionInfo() -> VersionInfo? { @@ -75,7 +77,11 @@ class UpdateManager { func notifyUpdate(info: VersionInfo) { let notification = NSUserNotification() - notification.title = "구름 입력기 업데이트 알림" + var title = "구름 입력기 업데이트 알림" + if info.experimental { + title += " (실험 버전)" + } + notification.title = title notification.hasActionButton = true notification.hasReplyButton = false notification.actionButtonTitle = "업데이트"